ce0214a6 |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2003-2004 Mathieu Desnoyers |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License Version 2 as |
6 | * published by the Free Software Foundation; |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
16 | * MA 02111-1307, USA. |
17 | */ |
18 | |
19 | |
f0d936c0 |
20 | /***************************************************************************** |
21 | * Hooks to be called by the main window * |
22 | *****************************************************************************/ |
23 | |
f0d936c0 |
24 | |
b9a010a2 |
25 | /* Event hooks are the drawing hooks called during traceset read. They draw the |
26 | * icons, text, lines and background color corresponding to the events read. |
27 | * |
e92eabaf |
28 | * Two hooks are used for drawing : before_schedchange and after_schedchange hooks. The |
29 | * before_schedchange is called before the state update that occurs with an event and |
30 | * the after_schedchange hook is called after this state update. |
b9a010a2 |
31 | * |
e92eabaf |
32 | * The before_schedchange hooks fulfill the task of drawing the visible objects that |
33 | * corresponds to the data accumulated by the after_schedchange hook. |
b9a010a2 |
34 | * |
e92eabaf |
35 | * The after_schedchange hook accumulates the data that need to be shown on the screen |
36 | * (items) into a queue. Then, the next before_schedchange hook will draw what that |
b9a010a2 |
37 | * queue contains. That's the Right Way (TM) of drawing items on the screen, |
38 | * because we need to draw the background first (and then add icons, text, ... |
39 | * over it), but we only know the length of a background region once the state |
e92eabaf |
40 | * corresponding to it is over, which happens to be at the next before_schedchange |
b9a010a2 |
41 | * hook. |
42 | * |
43 | * We also have a hook called at the end of a chunk to draw the information left |
44 | * undrawn in each process queue. We use the current time as end of |
45 | * line/background. |
46 | */ |
47 | |
4e4d11b3 |
48 | #ifdef HAVE_CONFIG_H |
49 | #include <config.h> |
50 | #endif |
b9a010a2 |
51 | |
cf6cb7e0 |
52 | //#define PANGO_ENABLE_BACKEND |
558aa013 |
53 | #include <gtk/gtk.h> |
54 | #include <gdk/gdk.h> |
5f16133f |
55 | #include <glib.h> |
80a52ff8 |
56 | #include <assert.h> |
50439712 |
57 | #include <string.h> |
319e9d81 |
58 | #include <stdio.h> |
5f16133f |
59 | |
cf6cb7e0 |
60 | //#include <pango/pango.h> |
61 | |
80a52ff8 |
62 | #include <ltt/event.h> |
4ba42155 |
63 | #include <ltt/time.h> |
2c82c4dc |
64 | #include <ltt/trace.h> |
80a52ff8 |
65 | |
2a2fa4f0 |
66 | #include <lttv/lttv.h> |
558aa013 |
67 | #include <lttv/hook.h> |
80a52ff8 |
68 | #include <lttv/state.h> |
2d262115 |
69 | #include <lttvwindow/lttvwindow.h> |
6395d57c |
70 | #include <lttvwindow/lttvwindowtraces.h> |
0de51231 |
71 | #include <lttvwindow/support.h> |
80a52ff8 |
72 | |
f0d936c0 |
73 | |
a117e3f7 |
74 | #include "eventhooks.h" |
75 | #include "cfv.h" |
76 | #include "processlist.h" |
77 | #include "drawing.h" |
5f16133f |
78 | |
80a52ff8 |
79 | |
1a31868c |
80 | #define MAX_PATH_LEN 256 |
5bb606ce |
81 | #define STATE_LINE_WIDTH 4 |
82 | #define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3) |
1a31868c |
83 | |
0de51231 |
84 | extern GSList *g_legend_list; |
85 | |
b9a010a2 |
86 | |
6395d57c |
87 | /* Action to do when background computation completed. |
88 | * |
e800cf84 |
89 | * Wait for all the awaited computations to be over. |
6395d57c |
90 | */ |
91 | |
703b25fa |
92 | static gint background_ready(void *hook_data, void *call_data) |
6395d57c |
93 | { |
94 | ControlFlowData *control_flow_data = (ControlFlowData *)hook_data; |
95 | LttvTrace *trace = (LttvTrace*)call_data; |
96 | |
e800cf84 |
97 | control_flow_data->background_info_waiting--; |
98 | |
99 | if(control_flow_data->background_info_waiting == 0) { |
4a24fa1f |
100 | g_message("control flow viewer : background computation data ready."); |
6395d57c |
101 | |
e800cf84 |
102 | drawing_clear(control_flow_data->drawing); |
103 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
104 | gtk_widget_set_size_request( |
105 | control_flow_data->drawing->drawing_area, |
106 | -1, processlist_get_height(control_flow_data->process_list)); |
e800cf84 |
107 | redraw_notify(control_flow_data, NULL); |
b9a010a2 |
108 | } |
6395d57c |
109 | |
110 | return 0; |
111 | } |
112 | |
113 | |
114 | /* Request background computation. Verify if it is in progress or ready first. |
e800cf84 |
115 | * Only for each trace in the tab's traceset. |
6395d57c |
116 | */ |
3f7f592e |
117 | static void request_background_data(ControlFlowData *control_flow_data) |
6395d57c |
118 | { |
e800cf84 |
119 | LttvTracesetContext * tsc = |
120 | lttvwindow_get_traceset_context(control_flow_data->tab); |
121 | gint num_traces = lttv_traceset_number(tsc->ts); |
6395d57c |
122 | gint i; |
123 | LttvTrace *trace; |
7df20ca4 |
124 | LttvTraceState *tstate; |
6395d57c |
125 | |
126 | LttvHooks *background_ready_hook = |
127 | lttv_hooks_new(); |
128 | lttv_hooks_add(background_ready_hook, background_ready, control_flow_data, |
129 | LTTV_PRIO_DEFAULT); |
e800cf84 |
130 | control_flow_data->background_info_waiting = 0; |
6395d57c |
131 | |
132 | for(i=0;i<num_traces;i++) { |
e800cf84 |
133 | trace = lttv_traceset_get(tsc->ts, i); |
7df20ca4 |
134 | tstate = LTTV_TRACE_STATE(tsc->traces[i]); |
6395d57c |
135 | |
7df20ca4 |
136 | if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE |
137 | && !tstate->has_precomputed_states) { |
6395d57c |
138 | |
139 | if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"), |
140 | trace) == FALSE) { |
141 | /* We first remove requests that could have been done for the same |
142 | * information. Happens when two viewers ask for it before servicing |
143 | * starts. |
144 | */ |
93ac601b |
145 | if(!lttvwindowtraces_background_request_find(trace, "state")) |
b5e17af5 |
146 | lttvwindowtraces_background_request_queue( |
147 | main_window_get_widget(control_flow_data->tab), trace, "state"); |
6395d57c |
148 | lttvwindowtraces_background_notify_queue(control_flow_data, |
149 | trace, |
150 | ltt_time_infinite, |
151 | NULL, |
152 | background_ready_hook); |
e800cf84 |
153 | control_flow_data->background_info_waiting++; |
6395d57c |
154 | } else { /* in progress */ |
155 | |
156 | lttvwindowtraces_background_notify_current(control_flow_data, |
157 | trace, |
158 | ltt_time_infinite, |
159 | NULL, |
160 | background_ready_hook); |
e800cf84 |
161 | control_flow_data->background_info_waiting++; |
6395d57c |
162 | } |
4368b993 |
163 | } else { |
7df20ca4 |
164 | /* Data ready. By its nature, this viewer doesn't need to have |
618fbcc1 |
165 | * its data ready hook called there, because a background |
4368b993 |
166 | * request is always linked with a redraw. |
167 | */ |
6395d57c |
168 | } |
4368b993 |
169 | |
6395d57c |
170 | } |
171 | |
172 | lttv_hooks_destroy(background_ready_hook); |
173 | } |
174 | |
175 | |
176 | |
177 | |
f0d936c0 |
178 | /** |
179 | * Event Viewer's constructor hook |
180 | * |
181 | * This constructor is given as a parameter to the menuitem and toolbar button |
182 | * registration. It creates the list. |
ca0f8a8e |
183 | * @param tab A pointer to the parent tab. |
f0d936c0 |
184 | * @return The widget created. |
185 | */ |
186 | GtkWidget * |
e433e6d6 |
187 | h_guicontrolflow(LttvPlugin *plugin) |
f0d936c0 |
188 | { |
e433e6d6 |
189 | LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin); |
190 | Tab *tab = ptab->tab; |
d47b33d2 |
191 | g_info("h_guicontrolflow, %p", tab); |
e433e6d6 |
192 | ControlFlowData *control_flow_data = guicontrolflow(ptab); |
a56a1ba4 |
193 | |
ca0f8a8e |
194 | control_flow_data->tab = tab; |
a56a1ba4 |
195 | |
a56a1ba4 |
196 | // Unreg done in the GuiControlFlow_Destructor |
6395d57c |
197 | lttvwindow_register_traceset_notify(tab, |
198 | traceset_notify, |
199 | control_flow_data); |
200 | |
ca0f8a8e |
201 | lttvwindow_register_time_window_notify(tab, |
224446ce |
202 | update_time_window_hook, |
203 | control_flow_data); |
ca0f8a8e |
204 | lttvwindow_register_current_time_notify(tab, |
224446ce |
205 | update_current_time_hook, |
206 | control_flow_data); |
ca0f8a8e |
207 | lttvwindow_register_redraw_notify(tab, |
208 | redraw_notify, |
209 | control_flow_data); |
210 | lttvwindow_register_continue_notify(tab, |
211 | continue_notify, |
212 | control_flow_data); |
667ca2a0 |
213 | request_background_data(control_flow_data); |
6395d57c |
214 | |
ca0f8a8e |
215 | |
68997a22 |
216 | return guicontrolflow_get_widget(control_flow_data) ; |
a56a1ba4 |
217 | |
f0d936c0 |
218 | } |
219 | |
0de51231 |
220 | void legend_destructor(GtkWindow *legend) |
221 | { |
222 | g_legend_list = g_slist_remove(g_legend_list, legend); |
223 | } |
224 | |
225 | /* Create a popup legend */ |
226 | GtkWidget * |
e433e6d6 |
227 | h_legend(LttvPlugin *plugin) |
0de51231 |
228 | { |
e433e6d6 |
229 | LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin); |
230 | Tab *tab = ptab->tab; |
0de51231 |
231 | g_info("h_legend, %p", tab); |
232 | |
233 | GtkWindow *legend = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
234 | |
235 | g_legend_list = g_slist_append( |
236 | g_legend_list, |
237 | legend); |
238 | |
239 | g_object_set_data_full( |
240 | G_OBJECT(legend), |
241 | "legend", |
242 | legend, |
243 | (GDestroyNotify)legend_destructor); |
244 | |
245 | gtk_window_set_title(legend, "Control Flow View Legend"); |
246 | |
247 | GtkWidget *pixmap = create_pixmap(GTK_WIDGET(legend), "lttv-color-list.png"); |
248 | |
249 | // GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixmap( |
250 | // GDK_PIXMAP(pixmap), NULL)); |
251 | |
252 | gtk_container_add(GTK_CONTAINER(legend), GTK_WIDGET(pixmap)); |
253 | |
254 | gtk_widget_show(GTK_WIDGET(pixmap)); |
255 | gtk_widget_show(GTK_WIDGET(legend)); |
256 | |
257 | |
258 | return NULL; /* This is a popup window */ |
259 | } |
260 | |
261 | |
3cff8cc1 |
262 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 |
263 | { |
68997a22 |
264 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
14963be0 |
265 | guint *event_number = (guint*) call_data; |
f0d936c0 |
266 | |
2a2fa4f0 |
267 | g_debug("DEBUG : event selected by main window : %u", *event_number); |
a56a1ba4 |
268 | |
2eef04b5 |
269 | return 0; |
f0d936c0 |
270 | } |
271 | |
9a1ec01b |
272 | /* Function that selects the color of status&exemode line */ |
6550d711 |
273 | static inline PropertiesLine prepare_s_e_line(LttvProcessState *process) |
9a1ec01b |
274 | { |
275 | PropertiesLine prop_line; |
5bb606ce |
276 | prop_line.line_width = STATE_LINE_WIDTH; |
9a1ec01b |
277 | prop_line.style = GDK_LINE_SOLID; |
278 | prop_line.y = MIDDLE; |
279 | //GdkColormap *colormap = gdk_colormap_get_system(); |
280 | |
9a1ec01b |
281 | if(process->state->s == LTTV_STATE_RUN) { |
282 | if(process->state->t == LTTV_STATE_USER_MODE) |
283 | prop_line.color = drawing_colors[COL_RUN_USER_MODE]; |
284 | else if(process->state->t == LTTV_STATE_SYSCALL) |
285 | prop_line.color = drawing_colors[COL_RUN_SYSCALL]; |
286 | else if(process->state->t == LTTV_STATE_TRAP) |
287 | prop_line.color = drawing_colors[COL_RUN_TRAP]; |
288 | else if(process->state->t == LTTV_STATE_IRQ) |
289 | prop_line.color = drawing_colors[COL_RUN_IRQ]; |
faf074a3 |
290 | else if(process->state->t == LTTV_STATE_SOFT_IRQ) |
291 | prop_line.color = drawing_colors[COL_RUN_SOFT_IRQ]; |
9a1ec01b |
292 | else if(process->state->t == LTTV_STATE_MODE_UNKNOWN) |
293 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; |
294 | else |
295 | g_assert(FALSE); /* RUNNING MODE UNKNOWN */ |
296 | } else if(process->state->s == LTTV_STATE_WAIT) { |
297 | /* We don't show if we wait while in user mode, trap, irq or syscall */ |
298 | prop_line.color = drawing_colors[COL_WAIT]; |
299 | } else if(process->state->s == LTTV_STATE_WAIT_CPU) { |
300 | /* We don't show if we wait for CPU while in user mode, trap, irq |
301 | * or syscall */ |
302 | prop_line.color = drawing_colors[COL_WAIT_CPU]; |
303 | } else if(process->state->s == LTTV_STATE_ZOMBIE) { |
304 | prop_line.color = drawing_colors[COL_ZOMBIE]; |
305 | } else if(process->state->s == LTTV_STATE_WAIT_FORK) { |
306 | prop_line.color = drawing_colors[COL_WAIT_FORK]; |
307 | } else if(process->state->s == LTTV_STATE_EXIT) { |
308 | prop_line.color = drawing_colors[COL_EXIT]; |
309 | } else if(process->state->s == LTTV_STATE_UNNAMED) { |
310 | prop_line.color = drawing_colors[COL_UNNAMED]; |
b3fd4c02 |
311 | } else { |
312 | g_critical("unknown state : %s", g_quark_to_string(process->state->s)); |
9a1ec01b |
313 | g_assert(FALSE); /* UNKNOWN STATE */ |
b3fd4c02 |
314 | } |
9a1ec01b |
315 | |
316 | return prop_line; |
317 | |
318 | } |
319 | |
c8bba5fa |
320 | |
e92eabaf |
321 | /* before_schedchange_hook |
b9a010a2 |
322 | * |
f0d936c0 |
323 | * This function basically draw lines and icons. Two types of lines are drawn : |
324 | * one small (3 pixels?) representing the state of the process and the second |
325 | * type is thicker (10 pixels?) representing on which CPU a process is running |
326 | * (and this only in running state). |
327 | * |
328 | * Extremums of the lines : |
329 | * x_min : time of the last event context for this process kept in memory. |
330 | * x_max : time of the current event. |
331 | * y : middle of the process in the process list. The process is found in the |
332 | * list, therefore is it's position in pixels. |
333 | * |
334 | * The choice of lines'color is defined by the context of the last event for this |
335 | * process. |
336 | */ |
b9a010a2 |
337 | |
338 | |
e92eabaf |
339 | int before_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 |
340 | { |
dd455fb8 |
341 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
342 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
b9a010a2 |
343 | ControlFlowData *control_flow_data = events_request->viewer_data; |
344 | |
345 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
346 | |
347 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
348c6ba8 |
348 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
b9a010a2 |
349 | |
350 | LttEvent *e; |
2c82c4dc |
351 | e = ltt_tracefile_get_event(tfc->tf); |
e38d9ea0 |
352 | gint target_pid_saved = tfc->target_pid; |
b9a010a2 |
353 | |
354 | LttTime evtime = ltt_event_time(e); |
e38d9ea0 |
355 | LttvFilter *filter = control_flow_data->filter; |
fd22065b |
356 | |
10a1069a |
357 | /* we are in a schedchange, before the state update. We must draw the |
358 | * items corresponding to the state before it changes : now is the right |
359 | * time to do it. |
360 | */ |
b9a010a2 |
361 | |
10a1069a |
362 | guint pid_out; |
363 | guint pid_in; |
364 | { |
dd455fb8 |
365 | pid_out = ltt_event_get_long_unsigned(e, th->f1); |
366 | pid_in = ltt_event_get_long_unsigned(e, th->f2); |
10a1069a |
367 | } |
368 | |
e38d9ea0 |
369 | tfc->target_pid = pid_out; |
370 | if(!filter || !filter->head || |
371 | lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
372 | tfc->t_context->t,tfc,NULL,NULL)) { |
10a1069a |
373 | /* For the pid_out */ |
374 | /* First, check if the current process is in the state computation |
375 | * process list. If it is there, that means we must add it right now and |
376 | * draw items from the beginning of the read for it. If it is not |
377 | * present, it's a new process and it was not present : it will |
378 | * be added after the state update. */ |
ae3d0f50 |
379 | guint cpu = tfs->cpu; |
0f090e21 |
380 | guint trace_num = ts->parent.index; |
348c6ba8 |
381 | LttvProcessState *process = ts->running_process[cpu]; |
40debf7b |
382 | /* unknown state, bad current pid */ |
348c6ba8 |
383 | if(process->pid != pid_out) |
800aa029 |
384 | process = lttv_state_find_process(ts, |
ae3d0f50 |
385 | tfs->cpu, pid_out); |
b9a010a2 |
386 | |
10a1069a |
387 | if(process != NULL) { |
388 | /* Well, the process_out existed : we must get it in the process hash |
389 | * or add it, and draw its items. |
390 | */ |
391 | /* Add process to process list (if not present) */ |
1c736ed5 |
392 | guint pl_height = 0; |
10a1069a |
393 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
394 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
395 | LttTime birth = process->creation_time; |
b9a010a2 |
396 | |
ac4e21cf |
397 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
398 | pid_out, |
348c6ba8 |
399 | process->cpu, |
10a1069a |
400 | &birth, |
0f090e21 |
401 | trace_num); |
ac4e21cf |
402 | if(hashed_process_data == NULL) |
10a1069a |
403 | { |
404 | g_assert(pid_out == 0 || pid_out != process->ppid); |
405 | /* Process not present */ |
4e86ae2e |
406 | ProcessInfo *process_info; |
1c736ed5 |
407 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
408 | processlist_add(process_list, |
1c736ed5 |
409 | drawing, |
10a1069a |
410 | pid_out, |
fcc08e1e |
411 | process->tgid, |
348c6ba8 |
412 | process->cpu, |
10a1069a |
413 | process->ppid, |
414 | &birth, |
0f090e21 |
415 | trace_num, |
f4b88a7d |
416 | process->name, |
7b5f6cf1 |
417 | process->brand, |
10a1069a |
418 | &pl_height, |
4e86ae2e |
419 | &process_info, |
10a1069a |
420 | &hashed_process_data); |
1c736ed5 |
421 | gtk_widget_set_size_request(drawing->drawing_area, |
422 | -1, |
423 | pl_height); |
424 | gtk_widget_queue_draw(drawing->drawing_area); |
425 | |
10a1069a |
426 | } |
ac4e21cf |
427 | |
10a1069a |
428 | /* Now, the process is in the state hash and our own process hash. |
429 | * We definitely can draw the items related to the ending state. |
430 | */ |
e800cf84 |
431 | |
b2743953 |
432 | if(ltt_time_compare(hashed_process_data->next_good_time, |
433 | evtime) > 0) |
10a1069a |
434 | { |
b2743953 |
435 | if(hashed_process_data->x.middle_marked == FALSE) { |
ac4e21cf |
436 | |
fd22065b |
437 | TimeWindow time_window = |
438 | lttvwindow_get_time_window(control_flow_data->tab); |
439 | #ifdef EXTRA_CHECK |
440 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
441 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
442 | return; |
443 | #endif //EXTRA_CHECK |
d6fef890 |
444 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
445 | guint width = drawing->width; |
b2743953 |
446 | guint x; |
447 | convert_time_to_pixels( |
448 | time_window, |
449 | evtime, |
450 | width, |
451 | &x); |
452 | |
453 | /* Draw collision indicator */ |
454 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
455 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
456 | drawing->gc, |
457 | x, |
5bb606ce |
458 | COLLISION_POSITION(hashed_process_data->height)); |
b2743953 |
459 | hashed_process_data->x.middle_marked = TRUE; |
460 | } |
461 | } else { |
ac4e21cf |
462 | TimeWindow time_window = |
463 | lttvwindow_get_time_window(control_flow_data->tab); |
fd22065b |
464 | #ifdef EXTRA_CHECK |
ac4e21cf |
465 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
466 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
467 | return; |
fd22065b |
468 | #endif //EXTRA_CHECK |
d6fef890 |
469 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
470 | guint width = drawing->width; |
10a1069a |
471 | guint x; |
10a1069a |
472 | convert_time_to_pixels( |
a18124ff |
473 | time_window, |
4b7dc462 |
474 | evtime, |
475 | width, |
476 | &x); |
10a1069a |
477 | |
10a1069a |
478 | |
4b7dc462 |
479 | /* Jump over draw if we are at the same x position */ |
e72908ed |
480 | if(x == hashed_process_data->x.middle && |
481 | hashed_process_data->x.middle_used) |
e800cf84 |
482 | { |
e72908ed |
483 | if(hashed_process_data->x.middle_marked == FALSE) { |
484 | /* Draw collision indicator */ |
485 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
486 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
487 | drawing->gc, |
488 | x, |
5bb606ce |
489 | COLLISION_POSITION(hashed_process_data->height)); |
de4ea1ad |
490 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
491 | } |
4b7dc462 |
492 | /* jump */ |
493 | } else { |
494 | DrawContext draw_context; |
10a1069a |
495 | |
4b7dc462 |
496 | /* Now create the drawing context that will be used to draw |
497 | * items related to the last state. */ |
1c736ed5 |
498 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
499 | draw_context.gc = drawing->gc; |
500 | draw_context.pango_layout = drawing->pango_layout; |
501 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
502 | draw_context.drawinfo.end.x = x; |
503 | |
1c736ed5 |
504 | draw_context.drawinfo.y.over = 1; |
505 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
506 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
507 | |
508 | draw_context.drawinfo.start.offset.over = 0; |
509 | draw_context.drawinfo.start.offset.middle = 0; |
510 | draw_context.drawinfo.start.offset.under = 0; |
511 | draw_context.drawinfo.end.offset.over = 0; |
512 | draw_context.drawinfo.end.offset.middle = 0; |
513 | draw_context.drawinfo.end.offset.under = 0; |
514 | |
515 | { |
516 | /* Draw the line */ |
9a1ec01b |
517 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
518 | draw_line((void*)&prop_line, (void*)&draw_context); |
519 | |
520 | } |
521 | /* become the last x position */ |
522 | hashed_process_data->x.middle = x; |
e72908ed |
523 | hashed_process_data->x.middle_used = TRUE; |
524 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
525 | |
526 | /* Calculate the next good time */ |
527 | convert_pixels_to_time(width, x+1, time_window, |
528 | &hashed_process_data->next_good_time); |
e800cf84 |
529 | } |
530 | } |
531 | } |
10a1069a |
532 | } |
e800cf84 |
533 | |
e38d9ea0 |
534 | tfc->target_pid = pid_in; |
535 | if(!filter || !filter->head || |
536 | lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
537 | tfc->t_context->t,tfc,NULL,NULL)) { |
10a1069a |
538 | /* For the pid_in */ |
539 | /* First, check if the current process is in the state computation |
540 | * process list. If it is there, that means we must add it right now and |
541 | * draw items from the beginning of the read for it. If it is not |
542 | * present, it's a new process and it was not present : it will |
543 | * be added after the state update. */ |
544 | LttvProcessState *process; |
800aa029 |
545 | process = lttv_state_find_process(ts, |
ae3d0f50 |
546 | tfs->cpu, pid_in); |
0f090e21 |
547 | guint trace_num = ts->parent.index; |
10a1069a |
548 | |
549 | if(process != NULL) { |
800aa029 |
550 | /* Well, the process existed : we must get it in the process hash |
10a1069a |
551 | * or add it, and draw its items. |
552 | */ |
553 | /* Add process to process list (if not present) */ |
1c736ed5 |
554 | guint pl_height = 0; |
10a1069a |
555 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
556 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
557 | LttTime birth = process->creation_time; |
e800cf84 |
558 | |
ac4e21cf |
559 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
560 | pid_in, |
ae3d0f50 |
561 | tfs->cpu, |
10a1069a |
562 | &birth, |
0f090e21 |
563 | trace_num); |
ac4e21cf |
564 | if(hashed_process_data == NULL) |
10a1069a |
565 | { |
566 | g_assert(pid_in == 0 || pid_in != process->ppid); |
567 | /* Process not present */ |
4e86ae2e |
568 | ProcessInfo *process_info; |
1c736ed5 |
569 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
570 | processlist_add(process_list, |
1c736ed5 |
571 | drawing, |
10a1069a |
572 | pid_in, |
fcc08e1e |
573 | process->tgid, |
ae3d0f50 |
574 | tfs->cpu, |
10a1069a |
575 | process->ppid, |
576 | &birth, |
0f090e21 |
577 | trace_num, |
f4b88a7d |
578 | process->name, |
7b5f6cf1 |
579 | process->brand, |
10a1069a |
580 | &pl_height, |
4e86ae2e |
581 | &process_info, |
10a1069a |
582 | &hashed_process_data); |
1c736ed5 |
583 | gtk_widget_set_size_request(drawing->drawing_area, |
584 | -1, |
585 | pl_height); |
586 | gtk_widget_queue_draw(drawing->drawing_area); |
587 | |
10a1069a |
588 | } |
40debf7b |
589 | //We could set the current process and hash here, but will be done |
590 | //by after schedchange hook |
10a1069a |
591 | |
592 | /* Now, the process is in the state hash and our own process hash. |
593 | * We definitely can draw the items related to the ending state. |
594 | */ |
b9a010a2 |
595 | |
b2743953 |
596 | if(ltt_time_compare(hashed_process_data->next_good_time, |
597 | evtime) > 0) |
10a1069a |
598 | { |
b2743953 |
599 | if(hashed_process_data->x.middle_marked == FALSE) { |
ac4e21cf |
600 | |
fd22065b |
601 | TimeWindow time_window = |
602 | lttvwindow_get_time_window(control_flow_data->tab); |
603 | #ifdef EXTRA_CHECK |
604 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
605 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
606 | return; |
607 | #endif //EXTRA_CHECK |
d6fef890 |
608 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
609 | guint width = drawing->width; |
b2743953 |
610 | guint x; |
611 | convert_time_to_pixels( |
612 | time_window, |
613 | evtime, |
614 | width, |
615 | &x); |
616 | |
617 | /* Draw collision indicator */ |
618 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
619 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
620 | drawing->gc, |
621 | x, |
5bb606ce |
622 | COLLISION_POSITION(hashed_process_data->height)); |
b2743953 |
623 | hashed_process_data->x.middle_marked = TRUE; |
624 | } |
625 | } else { |
fd22065b |
626 | TimeWindow time_window = |
627 | lttvwindow_get_time_window(control_flow_data->tab); |
628 | #ifdef EXTRA_CHECK |
629 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
630 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
631 | return; |
632 | #endif //EXTRA_CHECK |
d6fef890 |
633 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
634 | guint width = drawing->width; |
10a1069a |
635 | guint x; |
10a1069a |
636 | |
637 | convert_time_to_pixels( |
a18124ff |
638 | time_window, |
4b7dc462 |
639 | evtime, |
640 | width, |
641 | &x); |
10a1069a |
642 | |
10a1069a |
643 | |
4b7dc462 |
644 | /* Jump over draw if we are at the same x position */ |
e72908ed |
645 | if(x == hashed_process_data->x.middle && |
646 | hashed_process_data->x.middle_used) |
4b7dc462 |
647 | { |
e72908ed |
648 | if(hashed_process_data->x.middle_marked == FALSE) { |
649 | /* Draw collision indicator */ |
650 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
651 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
652 | drawing->gc, |
653 | x, |
5bb606ce |
654 | COLLISION_POSITION(hashed_process_data->height)); |
de4ea1ad |
655 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
656 | } |
4b7dc462 |
657 | /* jump */ |
658 | } else { |
659 | DrawContext draw_context; |
10a1069a |
660 | |
4b7dc462 |
661 | /* Now create the drawing context that will be used to draw |
662 | * items related to the last state. */ |
1c736ed5 |
663 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
664 | draw_context.gc = drawing->gc; |
665 | draw_context.pango_layout = drawing->pango_layout; |
666 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
667 | draw_context.drawinfo.end.x = x; |
10a1069a |
668 | |
1c736ed5 |
669 | draw_context.drawinfo.y.over = 1; |
670 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
671 | draw_context.drawinfo.y.under = hashed_process_data->height; |
10a1069a |
672 | |
4b7dc462 |
673 | draw_context.drawinfo.start.offset.over = 0; |
674 | draw_context.drawinfo.start.offset.middle = 0; |
675 | draw_context.drawinfo.start.offset.under = 0; |
676 | draw_context.drawinfo.end.offset.over = 0; |
677 | draw_context.drawinfo.end.offset.middle = 0; |
678 | draw_context.drawinfo.end.offset.under = 0; |
679 | |
680 | { |
681 | /* Draw the line */ |
9a1ec01b |
682 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
683 | draw_line((void*)&prop_line, (void*)&draw_context); |
684 | } |
685 | |
686 | |
687 | /* become the last x position */ |
688 | hashed_process_data->x.middle = x; |
e72908ed |
689 | hashed_process_data->x.middle_used = TRUE; |
690 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
691 | |
692 | /* Calculate the next good time */ |
693 | convert_pixels_to_time(width, x+1, time_window, |
694 | &hashed_process_data->next_good_time); |
4b7dc462 |
695 | } |
c8bba5fa |
696 | } |
8e680509 |
697 | } else |
698 | g_warning("Cannot find pin_in in schedchange %u", pid_in); |
b9a010a2 |
699 | } |
e38d9ea0 |
700 | tfc->target_pid = target_pid_saved; |
b9a010a2 |
701 | return 0; |
702 | |
703 | |
b9a010a2 |
704 | |
a56a1ba4 |
705 | |
51705146 |
706 | /* Text dump */ |
80a52ff8 |
707 | #ifdef DONTSHOW |
a56a1ba4 |
708 | GString *string = g_string_new("");; |
709 | gboolean field_names = TRUE, state = TRUE; |
80a52ff8 |
710 | |
e9a9c513 |
711 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
712 | g_string_append_printf(string,"\n"); |
713 | |
714 | if(state) { |
715 | g_string_append_printf(string, " %s", |
716 | g_quark_to_string(tfs->process->state->s)); |
717 | } |
718 | |
719 | g_info("%s",string->str); |
720 | |
a56a1ba4 |
721 | g_string_free(string, TRUE); |
722 | |
723 | /* End of text dump */ |
80a52ff8 |
724 | #endif //DONTSHOW |
50439712 |
725 | |
f0d936c0 |
726 | } |
727 | |
e92eabaf |
728 | /* after_schedchange_hook |
b9a010a2 |
729 | * |
730 | * The draw after hook is called by the reading API to have a |
731 | * particular event drawn on the screen. |
732 | * @param hook_data ControlFlowData structure of the viewer. |
733 | * @param call_data Event context. |
734 | * |
735 | * This function adds items to be drawn in a queue for each process. |
736 | * |
737 | */ |
e92eabaf |
738 | int after_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 |
739 | { |
dd455fb8 |
740 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
741 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
ca0f8a8e |
742 | ControlFlowData *control_flow_data = events_request->viewer_data; |
50439712 |
743 | |
a56a1ba4 |
744 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
50439712 |
745 | |
746 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
747 | |
348c6ba8 |
748 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
749 | |
b9a010a2 |
750 | LttEvent *e; |
2c82c4dc |
751 | e = ltt_tracefile_get_event(tfc->tf); |
b9a010a2 |
752 | |
e38d9ea0 |
753 | LttvFilter *filter = control_flow_data->filter; |
754 | if(filter != NULL && filter->head != NULL) |
755 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
756 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
757 | return FALSE; |
758 | |
b9a010a2 |
759 | LttTime evtime = ltt_event_time(e); |
b9a010a2 |
760 | |
10a1069a |
761 | /* Add process to process list (if not present) */ |
2eef04b5 |
762 | LttvProcessState *process_in; |
10a1069a |
763 | LttTime birth; |
1c736ed5 |
764 | guint pl_height = 0; |
10a1069a |
765 | HashedProcessData *hashed_process_data_in = NULL; |
b9a010a2 |
766 | |
5c230fc4 |
767 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
768 | |
769 | guint pid_in; |
770 | { |
771 | guint pid_out; |
dd455fb8 |
772 | pid_out = ltt_event_get_long_unsigned(e, th->f1); |
773 | pid_in = ltt_event_get_long_unsigned(e, th->f2); |
10a1069a |
774 | } |
b9a010a2 |
775 | |
776 | |
10a1069a |
777 | /* Find process pid_in in the list... */ |
348c6ba8 |
778 | //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in); |
779 | //process_in = tfs->process; |
ae3d0f50 |
780 | guint cpu = tfs->cpu; |
0f090e21 |
781 | guint trace_num = ts->parent.index; |
348c6ba8 |
782 | process_in = ts->running_process[cpu]; |
10a1069a |
783 | /* It should exist, because we are after the state update. */ |
96947fcf |
784 | #ifdef EXTRA_CHECK |
10a1069a |
785 | g_assert(process_in != NULL); |
96947fcf |
786 | #endif //EXTRA_CHECK |
10a1069a |
787 | birth = process_in->creation_time; |
b9a010a2 |
788 | |
ac4e21cf |
789 | hashed_process_data_in = processlist_get_process_data(process_list, |
10a1069a |
790 | pid_in, |
348c6ba8 |
791 | process_in->cpu, |
10a1069a |
792 | &birth, |
0f090e21 |
793 | trace_num); |
ac4e21cf |
794 | if(hashed_process_data_in == NULL) |
10a1069a |
795 | { |
796 | g_assert(pid_in == 0 || pid_in != process_in->ppid); |
4e86ae2e |
797 | ProcessInfo *process_info; |
1c736ed5 |
798 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
799 | /* Process not present */ |
800 | processlist_add(process_list, |
1c736ed5 |
801 | drawing, |
10a1069a |
802 | pid_in, |
fcc08e1e |
803 | process_in->tgid, |
348c6ba8 |
804 | process_in->cpu, |
10a1069a |
805 | process_in->ppid, |
806 | &birth, |
0f090e21 |
807 | trace_num, |
f4b88a7d |
808 | process_in->name, |
7b5f6cf1 |
809 | process_in->brand, |
10a1069a |
810 | &pl_height, |
4e86ae2e |
811 | &process_info, |
10a1069a |
812 | &hashed_process_data_in); |
1c736ed5 |
813 | gtk_widget_set_size_request(drawing->drawing_area, |
814 | -1, |
815 | pl_height); |
816 | gtk_widget_queue_draw(drawing->drawing_area); |
b9a010a2 |
817 | } |
40debf7b |
818 | /* Set the current process */ |
0f090e21 |
819 | process_list->current_hash_data[trace_num][process_in->cpu] = |
40debf7b |
820 | hashed_process_data_in; |
10a1069a |
821 | |
b2743953 |
822 | if(ltt_time_compare(hashed_process_data_in->next_good_time, |
823 | evtime) <= 0) |
824 | { |
fd22065b |
825 | TimeWindow time_window = |
826 | lttvwindow_get_time_window(control_flow_data->tab); |
827 | |
828 | #ifdef EXTRA_CHECK |
829 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
830 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
831 | return; |
832 | #endif //EXTRA_CHECK |
d6fef890 |
833 | Drawing_t *drawing = control_flow_data->drawing; |
834 | guint width = drawing->width; |
b2743953 |
835 | guint new_x; |
836 | |
837 | convert_time_to_pixels( |
838 | time_window, |
839 | evtime, |
840 | width, |
841 | &new_x); |
e72908ed |
842 | |
b2743953 |
843 | if(hashed_process_data_in->x.middle != new_x) { |
844 | hashed_process_data_in->x.middle = new_x; |
845 | hashed_process_data_in->x.middle_used = FALSE; |
846 | hashed_process_data_in->x.middle_marked = FALSE; |
847 | } |
848 | } |
b9a010a2 |
849 | return 0; |
4a24fa1f |
850 | } |
b9a010a2 |
851 | |
852 | |
853 | |
e72908ed |
854 | |
4a24fa1f |
855 | /* before_execmode_hook |
856 | * |
857 | * This function basically draw lines and icons. Two types of lines are drawn : |
858 | * one small (3 pixels?) representing the state of the process and the second |
859 | * type is thicker (10 pixels?) representing on which CPU a process is running |
860 | * (and this only in running state). |
861 | * |
862 | * Extremums of the lines : |
863 | * x_min : time of the last event context for this process kept in memory. |
864 | * x_max : time of the current event. |
865 | * y : middle of the process in the process list. The process is found in the |
866 | * list, therefore is it's position in pixels. |
867 | * |
868 | * The choice of lines'color is defined by the context of the last event for this |
869 | * process. |
870 | */ |
871 | |
e72908ed |
872 | |
4a24fa1f |
873 | int before_execmode_hook(void *hook_data, void *call_data) |
874 | { |
dd455fb8 |
875 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
876 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
b9a010a2 |
877 | ControlFlowData *control_flow_data = events_request->viewer_data; |
878 | |
879 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
880 | |
881 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
b9a010a2 |
882 | |
4a24fa1f |
883 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
884 | |
50439712 |
885 | LttEvent *e; |
4a24fa1f |
886 | e = ltt_tracefile_get_event(tfc->tf); |
50439712 |
887 | |
e38d9ea0 |
888 | LttvFilter *filter = control_flow_data->filter; |
889 | if(filter != NULL && filter->head != NULL) |
890 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
891 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
892 | return FALSE; |
893 | |
9444deae |
894 | LttTime evtime = ltt_event_time(e); |
9444deae |
895 | |
4a24fa1f |
896 | /* we are in a execmode, before the state update. We must draw the |
897 | * items corresponding to the state before it changes : now is the right |
898 | * time to do it. |
899 | */ |
900 | /* For the pid */ |
901 | //LttvProcessState *process = tfs->process; |
ae3d0f50 |
902 | guint cpu = tfs->cpu; |
0f090e21 |
903 | guint trace_num = ts->parent.index; |
4a24fa1f |
904 | LttvProcessState *process = ts->running_process[cpu]; |
905 | g_assert(process != NULL); |
23093869 |
906 | |
10a1069a |
907 | guint pid = process->pid; |
23093869 |
908 | |
10a1069a |
909 | /* Well, the process_out existed : we must get it in the process hash |
910 | * or add it, and draw its items. |
911 | */ |
912 | /* Add process to process list (if not present) */ |
1c736ed5 |
913 | guint pl_height = 0; |
10a1069a |
914 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
915 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
916 | LttTime birth = process->creation_time; |
40debf7b |
917 | |
0f090e21 |
918 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
919 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
40debf7b |
920 | } else { |
ac4e21cf |
921 | hashed_process_data = processlist_get_process_data(process_list, |
40debf7b |
922 | pid, |
348c6ba8 |
923 | process->cpu, |
40debf7b |
924 | &birth, |
0f090e21 |
925 | trace_num); |
1d1df11d |
926 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
927 | { |
928 | g_assert(pid == 0 || pid != process->ppid); |
929 | ProcessInfo *process_info; |
930 | /* Process not present */ |
1c736ed5 |
931 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
932 | processlist_add(process_list, |
1c736ed5 |
933 | drawing, |
40debf7b |
934 | pid, |
fcc08e1e |
935 | process->tgid, |
348c6ba8 |
936 | process->cpu, |
40debf7b |
937 | process->ppid, |
938 | &birth, |
0f090e21 |
939 | trace_num, |
f4b88a7d |
940 | process->name, |
7b5f6cf1 |
941 | process->brand, |
40debf7b |
942 | &pl_height, |
943 | &process_info, |
944 | &hashed_process_data); |
1c736ed5 |
945 | gtk_widget_set_size_request(drawing->drawing_area, |
946 | -1, |
947 | pl_height); |
948 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
949 | } |
950 | /* Set the current process */ |
0f090e21 |
951 | process_list->current_hash_data[trace_num][process->cpu] = |
40debf7b |
952 | hashed_process_data; |
10a1069a |
953 | } |
23093869 |
954 | |
10a1069a |
955 | /* Now, the process is in the state hash and our own process hash. |
956 | * We definitely can draw the items related to the ending state. |
957 | */ |
b2743953 |
958 | |
1d1df11d |
959 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
960 | evtime) > 0)) |
10a1069a |
961 | { |
1d1df11d |
962 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
fd22065b |
963 | TimeWindow time_window = |
964 | lttvwindow_get_time_window(control_flow_data->tab); |
965 | |
966 | #ifdef EXTRA_CHECK |
967 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
968 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
969 | return; |
970 | #endif //EXTRA_CHECK |
d6fef890 |
971 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
972 | guint width = drawing->width; |
b2743953 |
973 | guint x; |
974 | convert_time_to_pixels( |
975 | time_window, |
976 | evtime, |
977 | width, |
978 | &x); |
979 | |
980 | /* Draw collision indicator */ |
981 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
982 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
983 | drawing->gc, |
984 | x, |
5bb606ce |
985 | COLLISION_POSITION(hashed_process_data->height)); |
b2743953 |
986 | hashed_process_data->x.middle_marked = TRUE; |
987 | } |
988 | } else { |
fd22065b |
989 | TimeWindow time_window = |
990 | lttvwindow_get_time_window(control_flow_data->tab); |
991 | |
992 | #ifdef EXTRA_CHECK |
993 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
994 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
995 | return; |
996 | #endif //EXTRA_CHECK |
d6fef890 |
997 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
998 | guint width = drawing->width; |
10a1069a |
999 | guint x; |
dbd243b1 |
1000 | |
10a1069a |
1001 | convert_time_to_pixels( |
a18124ff |
1002 | time_window, |
10a1069a |
1003 | evtime, |
1004 | width, |
1005 | &x); |
dbd243b1 |
1006 | |
23093869 |
1007 | |
4b7dc462 |
1008 | /* Jump over draw if we are at the same x position */ |
1d1df11d |
1009 | if(unlikely(x == hashed_process_data->x.middle && |
1010 | hashed_process_data->x.middle_used)) |
10a1069a |
1011 | { |
1d1df11d |
1012 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
e72908ed |
1013 | /* Draw collision indicator */ |
1014 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
1015 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
1016 | drawing->gc, |
1017 | x, |
5bb606ce |
1018 | COLLISION_POSITION(hashed_process_data->height)); |
de4ea1ad |
1019 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
1020 | } |
4b7dc462 |
1021 | /* jump */ |
1022 | } else { |
1023 | |
1024 | DrawContext draw_context; |
1025 | /* Now create the drawing context that will be used to draw |
1026 | * items related to the last state. */ |
1c736ed5 |
1027 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
1028 | draw_context.gc = drawing->gc; |
1029 | draw_context.pango_layout = drawing->pango_layout; |
9a1ec01b |
1030 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
4b7dc462 |
1031 | draw_context.drawinfo.end.x = x; |
1032 | |
1c736ed5 |
1033 | draw_context.drawinfo.y.over = 1; |
1034 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
1035 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
1036 | |
1037 | draw_context.drawinfo.start.offset.over = 0; |
1038 | draw_context.drawinfo.start.offset.middle = 0; |
1039 | draw_context.drawinfo.start.offset.under = 0; |
1040 | draw_context.drawinfo.end.offset.over = 0; |
1041 | draw_context.drawinfo.end.offset.middle = 0; |
1042 | draw_context.drawinfo.end.offset.under = 0; |
1043 | |
1044 | { |
1045 | /* Draw the line */ |
9a1ec01b |
1046 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
1047 | draw_line((void*)&prop_line, (void*)&draw_context); |
23093869 |
1048 | |
4b7dc462 |
1049 | } |
1050 | /* become the last x position */ |
9a1ec01b |
1051 | hashed_process_data->x.middle = x; |
e72908ed |
1052 | hashed_process_data->x.middle_used = TRUE; |
1053 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
1054 | |
1055 | /* Calculate the next good time */ |
1056 | convert_pixels_to_time(width, x+1, time_window, |
1057 | &hashed_process_data->next_good_time); |
23093869 |
1058 | } |
1059 | } |
1060 | |
1061 | return 0; |
1062 | } |
1063 | |
4a24fa1f |
1064 | /* before_process_exit_hook |
23093869 |
1065 | * |
4a24fa1f |
1066 | * Draw lines for process event. |
1067 | * |
23093869 |
1068 | * @param hook_data ControlFlowData structure of the viewer. |
1069 | * @param call_data Event context. |
1070 | * |
1071 | * This function adds items to be drawn in a queue for each process. |
1072 | * |
1073 | */ |
8869ac08 |
1074 | |
1075 | |
4a24fa1f |
1076 | int before_process_exit_hook(void *hook_data, void *call_data) |
1077 | { |
dd455fb8 |
1078 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1079 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
4a24fa1f |
1080 | |
23093869 |
1081 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1082 | |
1083 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1084 | |
1085 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
23093869 |
1086 | |
4a24fa1f |
1087 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1088 | |
23093869 |
1089 | LttEvent *e; |
2c82c4dc |
1090 | e = ltt_tracefile_get_event(tfc->tf); |
23093869 |
1091 | |
e38d9ea0 |
1092 | LttvFilter *filter = control_flow_data->filter; |
1093 | if(filter != NULL && filter->head != NULL) |
1094 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1095 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1096 | return FALSE; |
1097 | |
23093869 |
1098 | LttTime evtime = ltt_event_time(e); |
23093869 |
1099 | |
10a1069a |
1100 | /* Add process to process list (if not present) */ |
4a24fa1f |
1101 | //LttvProcessState *process = tfs->process; |
ae3d0f50 |
1102 | guint cpu = tfs->cpu; |
0f090e21 |
1103 | guint trace_num = ts->parent.index; |
4a24fa1f |
1104 | LttvProcessState *process = ts->running_process[cpu]; |
1105 | guint pid = process->pid; |
10a1069a |
1106 | LttTime birth; |
1c736ed5 |
1107 | guint pl_height = 0; |
10a1069a |
1108 | HashedProcessData *hashed_process_data = NULL; |
23093869 |
1109 | |
5c230fc4 |
1110 | ProcessList *process_list = control_flow_data->process_list; |
4a24fa1f |
1111 | |
10a1069a |
1112 | g_assert(process != NULL); |
23093869 |
1113 | |
10a1069a |
1114 | birth = process->creation_time; |
23093869 |
1115 | |
0f090e21 |
1116 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
1117 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
40debf7b |
1118 | } else { |
ac4e21cf |
1119 | hashed_process_data = processlist_get_process_data(process_list, |
4a24fa1f |
1120 | pid, |
1121 | process->cpu, |
1122 | &birth, |
0f090e21 |
1123 | trace_num); |
1d1df11d |
1124 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
1125 | { |
1126 | g_assert(pid == 0 || pid != process->ppid); |
1127 | /* Process not present */ |
1c736ed5 |
1128 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
1129 | ProcessInfo *process_info; |
1130 | processlist_add(process_list, |
1c736ed5 |
1131 | drawing, |
40debf7b |
1132 | pid, |
fcc08e1e |
1133 | process->tgid, |
4a24fa1f |
1134 | process->cpu, |
40debf7b |
1135 | process->ppid, |
1136 | &birth, |
0f090e21 |
1137 | trace_num, |
4a24fa1f |
1138 | process->name, |
7b5f6cf1 |
1139 | process->brand, |
40debf7b |
1140 | &pl_height, |
1141 | &process_info, |
1142 | &hashed_process_data); |
4a24fa1f |
1143 | gtk_widget_set_size_request(drawing->drawing_area, |
1144 | -1, |
1145 | pl_height); |
1146 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
1147 | } |
23093869 |
1148 | } |
40debf7b |
1149 | |
4a24fa1f |
1150 | /* Now, the process is in the state hash and our own process hash. |
1151 | * We definitely can draw the items related to the ending state. |
1152 | */ |
1153 | |
1154 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
1155 | evtime) > 0)) |
b2743953 |
1156 | { |
4a24fa1f |
1157 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
1158 | TimeWindow time_window = |
1159 | lttvwindow_get_time_window(control_flow_data->tab); |
1160 | |
1161 | #ifdef EXTRA_CHECK |
1162 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1163 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1164 | return; |
1165 | #endif //EXTRA_CHECK |
1166 | Drawing_t *drawing = control_flow_data->drawing; |
1167 | guint width = drawing->width; |
1168 | guint x; |
1169 | convert_time_to_pixels( |
1170 | time_window, |
1171 | evtime, |
1172 | width, |
1173 | &x); |
1174 | |
1175 | /* Draw collision indicator */ |
1176 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1177 | gdk_draw_point(hashed_process_data->pixmap, |
1178 | drawing->gc, |
1179 | x, |
5bb606ce |
1180 | COLLISION_POSITION(hashed_process_data->height)); |
4a24fa1f |
1181 | hashed_process_data->x.middle_marked = TRUE; |
1182 | } |
1183 | } else { |
fd22065b |
1184 | TimeWindow time_window = |
1185 | lttvwindow_get_time_window(control_flow_data->tab); |
1186 | |
1187 | #ifdef EXTRA_CHECK |
1188 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1189 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1190 | return; |
1191 | #endif //EXTRA_CHECK |
d6fef890 |
1192 | Drawing_t *drawing = control_flow_data->drawing; |
1193 | guint width = drawing->width; |
4a24fa1f |
1194 | guint x; |
1195 | |
2c82c4dc |
1196 | convert_time_to_pixels( |
1197 | time_window, |
1198 | evtime, |
1199 | width, |
1200 | &x); |
1201 | |
b2743953 |
1202 | |
2c82c4dc |
1203 | /* Jump over draw if we are at the same x position */ |
1204 | if(unlikely(x == hashed_process_data->x.middle && |
1205 | hashed_process_data->x.middle_used)) |
1206 | { |
1207 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
b2743953 |
1208 | /* Draw collision indicator */ |
1209 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
1210 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
1211 | drawing->gc, |
1212 | x, |
5bb606ce |
1213 | COLLISION_POSITION(hashed_process_data->height)); |
b2743953 |
1214 | hashed_process_data->x.middle_marked = TRUE; |
1215 | } |
2c82c4dc |
1216 | /* jump */ |
b2743953 |
1217 | } else { |
2c82c4dc |
1218 | DrawContext draw_context; |
fd22065b |
1219 | |
2c82c4dc |
1220 | /* Now create the drawing context that will be used to draw |
1221 | * items related to the last state. */ |
1222 | draw_context.drawable = hashed_process_data->pixmap; |
1223 | draw_context.gc = drawing->gc; |
1224 | draw_context.pango_layout = drawing->pango_layout; |
1225 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
1226 | draw_context.drawinfo.end.x = x; |
dbd243b1 |
1227 | |
2c82c4dc |
1228 | draw_context.drawinfo.y.over = 1; |
1229 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
1230 | draw_context.drawinfo.y.under = hashed_process_data->height; |
dbd243b1 |
1231 | |
2c82c4dc |
1232 | draw_context.drawinfo.start.offset.over = 0; |
1233 | draw_context.drawinfo.start.offset.middle = 0; |
1234 | draw_context.drawinfo.start.offset.under = 0; |
1235 | draw_context.drawinfo.end.offset.over = 0; |
1236 | draw_context.drawinfo.end.offset.middle = 0; |
1237 | draw_context.drawinfo.end.offset.under = 0; |
dbd243b1 |
1238 | |
2c82c4dc |
1239 | { |
1240 | /* Draw the line */ |
1241 | PropertiesLine prop_line = prepare_s_e_line(process); |
1242 | draw_line((void*)&prop_line, (void*)&draw_context); |
dbd243b1 |
1243 | |
2c82c4dc |
1244 | } |
1245 | /* become the last x position */ |
1246 | hashed_process_data->x.middle = x; |
1247 | hashed_process_data->x.middle_used = TRUE; |
1248 | hashed_process_data->x.middle_marked = FALSE; |
dbd243b1 |
1249 | |
2c82c4dc |
1250 | /* Calculate the next good time */ |
1251 | convert_pixels_to_time(width, x+1, time_window, |
1252 | &hashed_process_data->next_good_time); |
1253 | } |
1254 | } |
1255 | |
1256 | return 0; |
1257 | |
1258 | } |
1259 | |
1260 | |
1261 | |
1262 | /* before_process_release_hook |
1263 | * |
1264 | * Draw lines for process event. |
1265 | * |
1266 | * @param hook_data ControlFlowData structure of the viewer. |
1267 | * @param call_data Event context. |
1268 | * |
1269 | * This function adds items to be drawn in a queue for each process. |
1270 | * |
1271 | */ |
1272 | |
1273 | |
1274 | int before_process_release_hook(void *hook_data, void *call_data) |
1275 | { |
dd455fb8 |
1276 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1277 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
2c82c4dc |
1278 | |
1279 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1280 | |
1281 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1282 | |
1283 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1284 | |
348c6ba8 |
1285 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1286 | |
2c82c4dc |
1287 | LttEvent *e; |
1288 | e = ltt_tracefile_get_event(tfc->tf); |
1289 | |
e38d9ea0 |
1290 | LttvFilter *filter = control_flow_data->filter; |
1291 | if(filter != NULL && filter->head != NULL) |
1292 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1293 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1294 | return FALSE; |
1295 | |
2c82c4dc |
1296 | LttTime evtime = ltt_event_time(e); |
1297 | |
0f090e21 |
1298 | guint trace_num = ts->parent.index; |
2c82c4dc |
1299 | |
1300 | guint pid; |
1301 | { |
dd455fb8 |
1302 | pid = ltt_event_get_long_unsigned(e, th->f1); |
2c82c4dc |
1303 | } |
1304 | |
1305 | /* Add process to process list (if not present) */ |
1306 | /* Don't care about the process if it's not in the state hash already : |
1307 | * that means a process that has never done anything in the trace and |
1308 | * unknown suddently gets destroyed : no state meaningful to show. */ |
348c6ba8 |
1309 | LttvProcessState *process = lttv_state_find_process(ts, ANY_CPU, pid); |
2c82c4dc |
1310 | |
1311 | if(process != NULL) { |
1312 | LttTime birth; |
1313 | guint pl_height = 0; |
1314 | HashedProcessData *hashed_process_data = NULL; |
1315 | |
1316 | ProcessList *process_list = control_flow_data->process_list; |
1317 | |
1318 | birth = process->creation_time; |
1319 | |
1320 | /* Cannot use current process : this event happens on another process, |
1321 | * action done by the parent. */ |
1322 | hashed_process_data = processlist_get_process_data(process_list, |
1323 | pid, |
348c6ba8 |
1324 | process->cpu, |
2c82c4dc |
1325 | &birth, |
0f090e21 |
1326 | trace_num); |
2c82c4dc |
1327 | if(unlikely(hashed_process_data == NULL)) |
1328 | { |
1329 | g_assert(pid == 0 || pid != process->ppid); |
1330 | /* Process not present */ |
1331 | Drawing_t *drawing = control_flow_data->drawing; |
2c82c4dc |
1332 | ProcessInfo *process_info; |
1333 | processlist_add(process_list, |
1334 | drawing, |
1335 | pid, |
fcc08e1e |
1336 | process->tgid, |
348c6ba8 |
1337 | process->cpu, |
2c82c4dc |
1338 | process->ppid, |
1339 | &birth, |
0f090e21 |
1340 | trace_num, |
f4b88a7d |
1341 | process->name, |
7b5f6cf1 |
1342 | process->brand, |
2c82c4dc |
1343 | &pl_height, |
1344 | &process_info, |
1345 | &hashed_process_data); |
1346 | gtk_widget_set_size_request(drawing->drawing_area, |
1347 | -1, |
1348 | pl_height); |
1349 | gtk_widget_queue_draw(drawing->drawing_area); |
1350 | } |
1351 | |
1352 | /* Now, the process is in the state hash and our own process hash. |
1353 | * We definitely can draw the items related to the ending state. |
1354 | */ |
1355 | |
1356 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
1357 | evtime) > 0)) |
1358 | { |
1359 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
1360 | TimeWindow time_window = |
1361 | lttvwindow_get_time_window(control_flow_data->tab); |
1362 | |
1363 | #ifdef EXTRA_CHECK |
1364 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1365 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1366 | return; |
1367 | #endif //EXTRA_CHECK |
1368 | Drawing_t *drawing = control_flow_data->drawing; |
1369 | guint width = drawing->width; |
1370 | guint x; |
1371 | convert_time_to_pixels( |
1372 | time_window, |
1373 | evtime, |
1374 | width, |
1375 | &x); |
1376 | |
1377 | /* Draw collision indicator */ |
1378 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1379 | gdk_draw_point(hashed_process_data->pixmap, |
1380 | drawing->gc, |
1381 | x, |
5bb606ce |
1382 | COLLISION_POSITION(hashed_process_data->height)); |
2c82c4dc |
1383 | hashed_process_data->x.middle_marked = TRUE; |
1384 | } |
1385 | } else { |
1386 | TimeWindow time_window = |
1387 | lttvwindow_get_time_window(control_flow_data->tab); |
1388 | |
1389 | #ifdef EXTRA_CHECK |
1390 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
4a24fa1f |
1391 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1392 | return; |
2da61677 |
1393 | #endif //EXTRA_CHECK |
4a24fa1f |
1394 | Drawing_t *drawing = control_flow_data->drawing; |
1395 | guint width = drawing->width; |
1396 | guint x; |
1397 | |
1398 | convert_time_to_pixels( |
1399 | time_window, |
1400 | evtime, |
1401 | width, |
1402 | &x); |
1403 | |
2da61677 |
1404 | |
4a24fa1f |
1405 | /* Jump over draw if we are at the same x position */ |
1406 | if(unlikely(x == hashed_process_data->x.middle && |
1407 | hashed_process_data->x.middle_used)) |
1408 | { |
1409 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2da61677 |
1410 | /* Draw collision indicator */ |
1411 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1412 | gdk_draw_point(hashed_process_data->pixmap, |
1413 | drawing->gc, |
1414 | x, |
5bb606ce |
1415 | COLLISION_POSITION(hashed_process_data->height)); |
2da61677 |
1416 | hashed_process_data->x.middle_marked = TRUE; |
1417 | } |
4a24fa1f |
1418 | /* jump */ |
2da61677 |
1419 | } else { |
4a24fa1f |
1420 | DrawContext draw_context; |
2da61677 |
1421 | |
4a24fa1f |
1422 | /* Now create the drawing context that will be used to draw |
1423 | * items related to the last state. */ |
1424 | draw_context.drawable = hashed_process_data->pixmap; |
1425 | draw_context.gc = drawing->gc; |
1426 | draw_context.pango_layout = drawing->pango_layout; |
1427 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
1428 | draw_context.drawinfo.end.x = x; |
2da61677 |
1429 | |
4a24fa1f |
1430 | draw_context.drawinfo.y.over = 1; |
1431 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
1432 | draw_context.drawinfo.y.under = hashed_process_data->height; |
2da61677 |
1433 | |
4a24fa1f |
1434 | draw_context.drawinfo.start.offset.over = 0; |
1435 | draw_context.drawinfo.start.offset.middle = 0; |
1436 | draw_context.drawinfo.start.offset.under = 0; |
1437 | draw_context.drawinfo.end.offset.over = 0; |
1438 | draw_context.drawinfo.end.offset.middle = 0; |
1439 | draw_context.drawinfo.end.offset.under = 0; |
2da61677 |
1440 | |
4a24fa1f |
1441 | { |
1442 | /* Draw the line */ |
1443 | PropertiesLine prop_line = prepare_s_e_line(process); |
1444 | draw_line((void*)&prop_line, (void*)&draw_context); |
2da61677 |
1445 | |
2da61677 |
1446 | } |
4a24fa1f |
1447 | /* become the last x position */ |
1448 | hashed_process_data->x.middle = x; |
1449 | hashed_process_data->x.middle_used = TRUE; |
1450 | hashed_process_data->x.middle_marked = FALSE; |
1451 | |
1452 | /* Calculate the next good time */ |
1453 | convert_pixels_to_time(width, x+1, time_window, |
1454 | &hashed_process_data->next_good_time); |
2da61677 |
1455 | } |
1456 | } |
dbd243b1 |
1457 | } |
dbd243b1 |
1458 | |
4a24fa1f |
1459 | return 0; |
dbd243b1 |
1460 | } |
1461 | |
4a24fa1f |
1462 | |
2c82c4dc |
1463 | |
1464 | |
1465 | |
1466 | /* after_process_fork_hook |
1467 | * |
1468 | * Create the processlist entry for the child process. Put the last |
1469 | * position in x at the current time value. |
1470 | * |
1471 | * @param hook_data ControlFlowData structure of the viewer. |
1472 | * @param call_data Event context. |
1473 | * |
1474 | * This function adds items to be drawn in a queue for each process. |
1475 | * |
1476 | */ |
1477 | int after_process_fork_hook(void *hook_data, void *call_data) |
1478 | { |
dd455fb8 |
1479 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1480 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
2c82c4dc |
1481 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1482 | |
1483 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1484 | |
1485 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1486 | |
348c6ba8 |
1487 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1488 | |
2c82c4dc |
1489 | LttEvent *e; |
1490 | e = ltt_tracefile_get_event(tfc->tf); |
1491 | |
e38d9ea0 |
1492 | LttvFilter *filter = control_flow_data->filter; |
1493 | if(filter != NULL && filter->head != NULL) |
1494 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1495 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1496 | return FALSE; |
1497 | |
2c82c4dc |
1498 | LttTime evtime = ltt_event_time(e); |
1499 | |
1500 | guint child_pid; |
1501 | { |
dd455fb8 |
1502 | child_pid = ltt_event_get_long_unsigned(e, th->f2); |
2c82c4dc |
1503 | } |
1504 | |
1505 | /* Add process to process list (if not present) */ |
1506 | LttvProcessState *process_child; |
1507 | LttTime birth; |
1508 | guint pl_height = 0; |
1509 | HashedProcessData *hashed_process_data_child = NULL; |
1510 | |
1511 | ProcessList *process_list = control_flow_data->process_list; |
1512 | |
1513 | /* Find child in the list... */ |
348c6ba8 |
1514 | process_child = lttv_state_find_process(ts, ANY_CPU, child_pid); |
2c82c4dc |
1515 | /* It should exist, because we are after the state update. */ |
1516 | g_assert(process_child != NULL); |
1517 | |
1518 | birth = process_child->creation_time; |
0f090e21 |
1519 | guint trace_num = ts->parent.index; |
2c82c4dc |
1520 | |
1521 | /* Cannot use current process, because this action is done by the parent |
1522 | * on its child. */ |
1523 | hashed_process_data_child = processlist_get_process_data(process_list, |
1524 | child_pid, |
348c6ba8 |
1525 | process_child->cpu, |
2c82c4dc |
1526 | &birth, |
0f090e21 |
1527 | trace_num); |
2c82c4dc |
1528 | if(likely(hashed_process_data_child == NULL)) |
1529 | { |
1530 | g_assert(child_pid == 0 || child_pid != process_child->ppid); |
1531 | /* Process not present */ |
1532 | Drawing_t *drawing = control_flow_data->drawing; |
2c82c4dc |
1533 | ProcessInfo *process_info; |
1534 | processlist_add(process_list, |
1535 | drawing, |
1536 | child_pid, |
fcc08e1e |
1537 | process_child->tgid, |
348c6ba8 |
1538 | process_child->cpu, |
2c82c4dc |
1539 | process_child->ppid, |
1540 | &birth, |
0f090e21 |
1541 | trace_num, |
f4b88a7d |
1542 | process_child->name, |
7b5f6cf1 |
1543 | process_child->brand, |
2c82c4dc |
1544 | &pl_height, |
1545 | &process_info, |
1546 | &hashed_process_data_child); |
1547 | gtk_widget_set_size_request(drawing->drawing_area, |
1548 | -1, |
1549 | pl_height); |
1550 | gtk_widget_queue_draw(drawing->drawing_area); |
fcc08e1e |
1551 | } else { |
1552 | processlist_set_ppid(process_list, process_child->ppid, |
1553 | hashed_process_data_child); |
1554 | processlist_set_tgid(process_list, process_child->tgid, |
1555 | hashed_process_data_child); |
2c82c4dc |
1556 | } |
1557 | |
1558 | |
1559 | if(likely(ltt_time_compare(hashed_process_data_child->next_good_time, |
1560 | evtime) <= 0)) |
1561 | { |
1562 | TimeWindow time_window = |
1563 | lttvwindow_get_time_window(control_flow_data->tab); |
1564 | |
1565 | #ifdef EXTRA_CHECK |
1566 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1567 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1568 | return; |
1569 | #endif //EXTRA_CHECK |
1570 | Drawing_t *drawing = control_flow_data->drawing; |
1571 | guint width = drawing->width; |
1572 | guint new_x; |
1573 | convert_time_to_pixels( |
1574 | time_window, |
1575 | evtime, |
1576 | width, |
1577 | &new_x); |
1578 | |
1579 | if(likely(hashed_process_data_child->x.over != new_x)) { |
1580 | hashed_process_data_child->x.over = new_x; |
1581 | hashed_process_data_child->x.over_used = FALSE; |
1582 | hashed_process_data_child->x.over_marked = FALSE; |
1583 | } |
1584 | if(likely(hashed_process_data_child->x.middle != new_x)) { |
1585 | hashed_process_data_child->x.middle = new_x; |
1586 | hashed_process_data_child->x.middle_used = FALSE; |
1587 | hashed_process_data_child->x.middle_marked = FALSE; |
1588 | } |
1589 | if(likely(hashed_process_data_child->x.under != new_x)) { |
1590 | hashed_process_data_child->x.under = new_x; |
1591 | hashed_process_data_child->x.under_used = FALSE; |
1592 | hashed_process_data_child->x.under_marked = FALSE; |
1593 | } |
1594 | } |
1595 | return 0; |
1596 | } |
1597 | |
1598 | |
1599 | |
1600 | /* after_process_exit_hook |
1601 | * |
1602 | * Create the processlist entry for the child process. Put the last |
1603 | * position in x at the current time value. |
1604 | * |
1605 | * @param hook_data ControlFlowData structure of the viewer. |
1606 | * @param call_data Event context. |
1607 | * |
1608 | * This function adds items to be drawn in a queue for each process. |
1609 | * |
1610 | */ |
1611 | int after_process_exit_hook(void *hook_data, void *call_data) |
1612 | { |
dd455fb8 |
1613 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1614 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
2c82c4dc |
1615 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1616 | |
1617 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1618 | |
1619 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1620 | |
348c6ba8 |
1621 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1622 | |
2c82c4dc |
1623 | LttEvent *e; |
1624 | e = ltt_tracefile_get_event(tfc->tf); |
1625 | |
e38d9ea0 |
1626 | LttvFilter *filter = control_flow_data->filter; |
1627 | if(filter != NULL && filter->head != NULL) |
1628 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1629 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1630 | return FALSE; |
1631 | |
2c82c4dc |
1632 | LttTime evtime = ltt_event_time(e); |
1633 | |
1634 | /* Add process to process list (if not present) */ |
348c6ba8 |
1635 | //LttvProcessState *process = tfs->process; |
ae3d0f50 |
1636 | guint cpu = tfs->cpu; |
0f090e21 |
1637 | guint trace_num = ts->parent.index; |
348c6ba8 |
1638 | LttvProcessState *process = ts->running_process[cpu]; |
1639 | |
1640 | /* It should exist, because we are after the state update. */ |
1641 | g_assert(process != NULL); |
1642 | |
2c82c4dc |
1643 | guint pid = process->pid; |
1644 | LttTime birth; |
1645 | guint pl_height = 0; |
1646 | HashedProcessData *hashed_process_data = NULL; |
1647 | |
1648 | ProcessList *process_list = control_flow_data->process_list; |
1649 | |
2c82c4dc |
1650 | birth = process->creation_time; |
1651 | |
0f090e21 |
1652 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){ |
1653 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
2c82c4dc |
1654 | } else { |
1655 | hashed_process_data = processlist_get_process_data(process_list, |
1656 | pid, |
348c6ba8 |
1657 | process->cpu, |
2c82c4dc |
1658 | &birth, |
0f090e21 |
1659 | trace_num); |
2c82c4dc |
1660 | if(unlikely(hashed_process_data == NULL)) |
1661 | { |
1662 | g_assert(pid == 0 || pid != process->ppid); |
1663 | /* Process not present */ |
1664 | Drawing_t *drawing = control_flow_data->drawing; |
2c82c4dc |
1665 | ProcessInfo *process_info; |
1666 | processlist_add(process_list, |
1667 | drawing, |
1668 | pid, |
fcc08e1e |
1669 | process->tgid, |
348c6ba8 |
1670 | process->cpu, |
2c82c4dc |
1671 | process->ppid, |
1672 | &birth, |
0f090e21 |
1673 | trace_num, |
f4b88a7d |
1674 | process->name, |
7b5f6cf1 |
1675 | process->brand, |
2c82c4dc |
1676 | &pl_height, |
1677 | &process_info, |
1678 | &hashed_process_data); |
1679 | gtk_widget_set_size_request(drawing->drawing_area, |
1680 | -1, |
1681 | pl_height); |
1682 | gtk_widget_queue_draw(drawing->drawing_area); |
1683 | } |
1684 | |
1685 | /* Set the current process */ |
0f090e21 |
1686 | process_list->current_hash_data[trace_num][process->cpu] = |
2c82c4dc |
1687 | hashed_process_data; |
1688 | } |
1689 | |
1690 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
1691 | evtime) <= 0)) |
1692 | { |
1693 | TimeWindow time_window = |
1694 | lttvwindow_get_time_window(control_flow_data->tab); |
dbd243b1 |
1695 | |
2c82c4dc |
1696 | #ifdef EXTRA_CHECK |
1697 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1698 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1699 | return; |
1700 | #endif //EXTRA_CHECK |
1701 | Drawing_t *drawing = control_flow_data->drawing; |
1702 | guint width = drawing->width; |
1703 | guint new_x; |
1704 | convert_time_to_pixels( |
1705 | time_window, |
1706 | evtime, |
1707 | width, |
1708 | &new_x); |
1709 | if(unlikely(hashed_process_data->x.middle != new_x)) { |
1710 | hashed_process_data->x.middle = new_x; |
1711 | hashed_process_data->x.middle_used = FALSE; |
1712 | hashed_process_data->x.middle_marked = FALSE; |
1713 | } |
1714 | } |
dbd243b1 |
1715 | |
2c82c4dc |
1716 | return 0; |
1717 | } |
dbd243b1 |
1718 | |
1719 | |
f4b88a7d |
1720 | /* Get the filename of the process to print */ |
1721 | int after_fs_exec_hook(void *hook_data, void *call_data) |
1722 | { |
dd455fb8 |
1723 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1724 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
f4b88a7d |
1725 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1726 | |
1727 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1728 | |
1729 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1730 | |
1731 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1732 | |
e38d9ea0 |
1733 | LttEvent *e; |
1734 | e = ltt_tracefile_get_event(tfc->tf); |
1735 | |
1736 | LttvFilter *filter = control_flow_data->filter; |
1737 | if(filter != NULL && filter->head != NULL) |
1738 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1739 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1740 | return FALSE; |
1741 | |
ae3d0f50 |
1742 | guint cpu = tfs->cpu; |
0f090e21 |
1743 | guint trace_num = ts->parent.index; |
f4b88a7d |
1744 | LttvProcessState *process = ts->running_process[cpu]; |
1745 | g_assert(process != NULL); |
1746 | |
1747 | guint pid = process->pid; |
1748 | |
1749 | /* Well, the process_out existed : we must get it in the process hash |
1750 | * or add it, and draw its items. |
1751 | */ |
1752 | /* Add process to process list (if not present) */ |
1753 | guint pl_height = 0; |
1754 | HashedProcessData *hashed_process_data = NULL; |
1755 | ProcessList *process_list = control_flow_data->process_list; |
1756 | LttTime birth = process->creation_time; |
1757 | |
0f090e21 |
1758 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
1759 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
f4b88a7d |
1760 | } else { |
1761 | hashed_process_data = processlist_get_process_data(process_list, |
1762 | pid, |
1763 | process->cpu, |
1764 | &birth, |
0f090e21 |
1765 | trace_num); |
f4b88a7d |
1766 | if(unlikely(hashed_process_data == NULL)) |
1767 | { |
1768 | g_assert(pid == 0 || pid != process->ppid); |
1769 | ProcessInfo *process_info; |
1770 | /* Process not present */ |
1771 | Drawing_t *drawing = control_flow_data->drawing; |
1772 | processlist_add(process_list, |
1773 | drawing, |
1774 | pid, |
fcc08e1e |
1775 | process->tgid, |
f4b88a7d |
1776 | process->cpu, |
1777 | process->ppid, |
1778 | &birth, |
0f090e21 |
1779 | trace_num, |
f4b88a7d |
1780 | process->name, |
7b5f6cf1 |
1781 | process->brand, |
f4b88a7d |
1782 | &pl_height, |
1783 | &process_info, |
1784 | &hashed_process_data); |
1785 | gtk_widget_set_size_request(drawing->drawing_area, |
1786 | -1, |
1787 | pl_height); |
1788 | gtk_widget_queue_draw(drawing->drawing_area); |
1789 | } |
1790 | /* Set the current process */ |
0f090e21 |
1791 | process_list->current_hash_data[trace_num][process->cpu] = |
f4b88a7d |
1792 | hashed_process_data; |
1793 | } |
1794 | |
1795 | processlist_set_name(process_list, process->name, hashed_process_data); |
1796 | |
1797 | return 0; |
1798 | |
1799 | } |
1800 | |
7b5f6cf1 |
1801 | /* Get the filename of the process to print */ |
1802 | int after_user_generic_thread_brand_hook(void *hook_data, void *call_data) |
1803 | { |
dd455fb8 |
1804 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1805 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
7b5f6cf1 |
1806 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1807 | |
1808 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1809 | |
1810 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1811 | |
1812 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1813 | |
e38d9ea0 |
1814 | LttEvent *e; |
1815 | e = ltt_tracefile_get_event(tfc->tf); |
1816 | |
1817 | LttvFilter *filter = control_flow_data->filter; |
1818 | if(filter != NULL && filter->head != NULL) |
1819 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1820 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1821 | return FALSE; |
1822 | |
7b5f6cf1 |
1823 | guint cpu = tfs->cpu; |
0f090e21 |
1824 | guint trace_num = ts->parent.index; |
7b5f6cf1 |
1825 | LttvProcessState *process = ts->running_process[cpu]; |
1826 | g_assert(process != NULL); |
1827 | |
1828 | guint pid = process->pid; |
1829 | |
1830 | /* Well, the process_out existed : we must get it in the process hash |
1831 | * or add it, and draw its items. |
1832 | */ |
1833 | /* Add process to process list (if not present) */ |
1834 | guint pl_height = 0; |
1835 | HashedProcessData *hashed_process_data = NULL; |
1836 | ProcessList *process_list = control_flow_data->process_list; |
1837 | LttTime birth = process->creation_time; |
1838 | |
0f090e21 |
1839 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
1840 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
7b5f6cf1 |
1841 | } else { |
1842 | hashed_process_data = processlist_get_process_data(process_list, |
1843 | pid, |
1844 | process->cpu, |
1845 | &birth, |
0f090e21 |
1846 | trace_num); |
7b5f6cf1 |
1847 | if(unlikely(hashed_process_data == NULL)) |
1848 | { |
1849 | g_assert(pid == 0 || pid != process->ppid); |
1850 | ProcessInfo *process_info; |
1851 | /* Process not present */ |
1852 | Drawing_t *drawing = control_flow_data->drawing; |
1853 | processlist_add(process_list, |
1854 | drawing, |
1855 | pid, |
fcc08e1e |
1856 | process->tgid, |
7b5f6cf1 |
1857 | process->cpu, |
1858 | process->ppid, |
1859 | &birth, |
0f090e21 |
1860 | trace_num, |
7b5f6cf1 |
1861 | process->name, |
1862 | process->brand, |
1863 | &pl_height, |
1864 | &process_info, |
1865 | &hashed_process_data); |
1866 | gtk_widget_set_size_request(drawing->drawing_area, |
1867 | -1, |
1868 | pl_height); |
1869 | gtk_widget_queue_draw(drawing->drawing_area); |
1870 | } |
1871 | /* Set the current process */ |
0f090e21 |
1872 | process_list->current_hash_data[trace_num][process->cpu] = |
7b5f6cf1 |
1873 | hashed_process_data; |
1874 | } |
1875 | |
1876 | processlist_set_brand(process_list, process->brand, hashed_process_data); |
1877 | |
1878 | return 0; |
1879 | |
1880 | } |
1881 | |
1882 | |
b3fd4c02 |
1883 | /* after_event_enum_process_hook |
1884 | * |
b3fd4c02 |
1885 | * Create the processlist entry for the child process. Put the last |
1886 | * position in x at the current time value. |
1887 | * |
1888 | * @param hook_data ControlFlowData structure of the viewer. |
1889 | * @param call_data Event context. |
1890 | * |
1891 | * This function adds items to be drawn in a queue for each process. |
1892 | * |
1893 | */ |
1894 | int after_event_enum_process_hook(void *hook_data, void *call_data) |
1895 | { |
dd455fb8 |
1896 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1897 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
b3fd4c02 |
1898 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1899 | |
1900 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1901 | |
1902 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1903 | |
1904 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1905 | |
c4a72569 |
1906 | guint first_cpu, nb_cpus, cpu; |
1907 | |
b3fd4c02 |
1908 | LttEvent *e; |
1909 | e = ltt_tracefile_get_event(tfc->tf); |
1910 | |
e38d9ea0 |
1911 | LttvFilter *filter = control_flow_data->filter; |
1912 | if(filter != NULL && filter->head != NULL) |
1913 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1914 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1915 | return FALSE; |
1916 | |
b3fd4c02 |
1917 | LttTime evtime = ltt_event_time(e); |
1918 | |
1919 | /* Add process to process list (if not present) */ |
1920 | LttvProcessState *process_in; |
1921 | LttTime birth; |
1922 | guint pl_height = 0; |
1923 | HashedProcessData *hashed_process_data_in = NULL; |
1924 | |
1925 | ProcessList *process_list = control_flow_data->process_list; |
0f090e21 |
1926 | guint trace_num = ts->parent.index; |
b3fd4c02 |
1927 | |
1928 | guint pid_in; |
1929 | { |
dd455fb8 |
1930 | pid_in = ltt_event_get_long_unsigned(e, th->f1); |
b3fd4c02 |
1931 | } |
c4a72569 |
1932 | |
1933 | if(pid_in == 0) { |
1934 | first_cpu = 0; |
1935 | nb_cpus = ltt_trace_get_num_cpu(ts->parent.t); |
1936 | } else { |
1937 | first_cpu = ANY_CPU; |
1938 | nb_cpus = ANY_CPU+1; |
1939 | } |
b3fd4c02 |
1940 | |
c4a72569 |
1941 | for(cpu = first_cpu; cpu < nb_cpus; cpu++) { |
1942 | /* Find process pid_in in the list... */ |
1943 | process_in = lttv_state_find_process(ts, cpu, pid_in); |
1944 | //process_in = tfs->process; |
1945 | //guint cpu = tfs->cpu; |
1946 | //guint trace_num = ts->parent.index; |
1947 | //process_in = ts->running_process[cpu]; |
1948 | /* It should exist, because we are after the state update. */ |
1949 | #ifdef EXTRA_CHECK |
1950 | //g_assert(process_in != NULL); |
1951 | #endif //EXTRA_CHECK |
1952 | birth = process_in->creation_time; |
1953 | |
1954 | hashed_process_data_in = processlist_get_process_data(process_list, |
1955 | pid_in, |
1956 | process_in->cpu, |
1957 | &birth, |
1958 | trace_num); |
1959 | if(hashed_process_data_in == NULL) |
1960 | { |
1961 | if(pid_in != 0 && pid_in == process_in->ppid) |
1962 | g_critical("TEST %u , %u", pid_in, process_in->ppid); |
1963 | g_assert(pid_in == 0 || pid_in != process_in->ppid); |
1964 | ProcessInfo *process_info; |
1965 | Drawing_t *drawing = control_flow_data->drawing; |
1966 | /* Process not present */ |
1967 | processlist_add(process_list, |
1968 | drawing, |
b3fd4c02 |
1969 | pid_in, |
c4a72569 |
1970 | process_in->tgid, |
b3fd4c02 |
1971 | process_in->cpu, |
c4a72569 |
1972 | process_in->ppid, |
b3fd4c02 |
1973 | &birth, |
c4a72569 |
1974 | trace_num, |
1975 | process_in->name, |
1976 | process_in->brand, |
1977 | &pl_height, |
1978 | &process_info, |
1979 | &hashed_process_data_in); |
1980 | gtk_widget_set_size_request(drawing->drawing_area, |
1981 | -1, |
1982 | pl_height); |
1983 | gtk_widget_queue_draw(drawing->drawing_area); |
1984 | } else { |
1985 | processlist_set_name(process_list, process_in->name, |
1986 | hashed_process_data_in); |
1987 | processlist_set_ppid(process_list, process_in->ppid, |
1988 | hashed_process_data_in); |
1989 | processlist_set_tgid(process_list, process_in->tgid, |
1990 | hashed_process_data_in); |
1991 | } |
1992 | } |
b3fd4c02 |
1993 | return 0; |
1994 | } |
f4b88a7d |
1995 | |
1996 | |
1b238973 |
1997 | gint update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
1998 | { |
a56a1ba4 |
1999 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
a43d67ba |
2000 | Drawing_t *drawing = control_flow_data->drawing; |
1c736ed5 |
2001 | ProcessList *process_list = control_flow_data->process_list; |
a43d67ba |
2002 | |
224446ce |
2003 | const TimeWindowNotifyData *time_window_nofify_data = |
2004 | ((const TimeWindowNotifyData *)call_data); |
2005 | |
14963be0 |
2006 | TimeWindow *old_time_window = |
224446ce |
2007 | time_window_nofify_data->old_time_window; |
2008 | TimeWindow *new_time_window = |
2009 | time_window_nofify_data->new_time_window; |
a56a1ba4 |
2010 | |
3cb8b205 |
2011 | /* Update the ruler */ |
2012 | drawing_update_ruler(control_flow_data->drawing, |
2013 | new_time_window); |
2014 | |
2015 | |
a56a1ba4 |
2016 | /* Two cases : zoom in/out or scrolling */ |
2017 | |
2018 | /* In order to make sure we can reuse the old drawing, the scale must |
2019 | * be the same and the new time interval being partly located in the |
2020 | * currently shown time interval. (reuse is only for scrolling) |
2021 | */ |
2022 | |
2eef04b5 |
2023 | g_info("Old time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 |
2024 | old_time_window->start_time.tv_sec, |
2025 | old_time_window->start_time.tv_nsec, |
2026 | old_time_window->time_width.tv_sec, |
2027 | old_time_window->time_width.tv_nsec); |
a56a1ba4 |
2028 | |
2eef04b5 |
2029 | g_info("New time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 |
2030 | new_time_window->start_time.tv_sec, |
2031 | new_time_window->start_time.tv_nsec, |
2032 | new_time_window->time_width.tv_sec, |
2033 | new_time_window->time_width.tv_nsec); |
a56a1ba4 |
2034 | |
14963be0 |
2035 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
2036 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) |
a56a1ba4 |
2037 | { |
2038 | /* Same scale (scrolling) */ |
2039 | g_info("scrolling"); |
14963be0 |
2040 | LttTime *ns = &new_time_window->start_time; |
20640e70 |
2041 | LttTime *nw = &new_time_window->time_width; |
14963be0 |
2042 | LttTime *os = &old_time_window->start_time; |
20640e70 |
2043 | LttTime *ow = &old_time_window->time_width; |
6f26fc38 |
2044 | LttTime old_end = old_time_window->end_time; |
2045 | LttTime new_end = new_time_window->end_time; |
a56a1ba4 |
2046 | //if(ns<os+w<ns+w) |
2047 | //if(ns<os+w && os+w<ns+w) |
2048 | //if(ns<old_end && os<ns) |
2049 | if(ltt_time_compare(*ns, old_end) == -1 |
2050 | && ltt_time_compare(*os, *ns) == -1) |
2051 | { |
2052 | g_info("scrolling near right"); |
2053 | /* Scroll right, keep right part of the screen */ |
2054 | guint x = 0; |
51705146 |
2055 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
2056 | convert_time_to_pixels( |
a18124ff |
2057 | *old_time_window, |
a56a1ba4 |
2058 | *ns, |
2059 | width, |
2060 | &x); |
2061 | |
2062 | /* Copy old data to new location */ |
1c736ed5 |
2063 | copy_pixmap_region(process_list, |
2064 | NULL, |
2065 | control_flow_data->drawing->drawing_area->style->black_gc, |
2066 | NULL, |
2067 | x, 0, |
2068 | 0, 0, |
2069 | control_flow_data->drawing->width-x+SAFETY, -1); |
2070 | |
6395d57c |
2071 | if(drawing->damage_begin == drawing->damage_end) |
2072 | drawing->damage_begin = control_flow_data->drawing->width-x; |
2073 | else |
2074 | drawing->damage_begin = 0; |
2075 | |
2076 | drawing->damage_end = control_flow_data->drawing->width; |
2077 | |
a56a1ba4 |
2078 | /* Clear the data request background, but not SAFETY */ |
1c736ed5 |
2079 | rectangle_pixmap(process_list, |
cfe526b1 |
2080 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
2081 | TRUE, |
6395d57c |
2082 | drawing->damage_begin+SAFETY, 0, |
2083 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1c736ed5 |
2084 | -1); |
7abb23ad |
2085 | gtk_widget_queue_draw(drawing->drawing_area); |
2086 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2087 | // 0,0, |
2088 | // control_flow_data->drawing->width, |
2089 | // control_flow_data->drawing->height); |
a43d67ba |
2090 | |
a56a1ba4 |
2091 | /* Get new data for the rest. */ |
501d5405 |
2092 | drawing_data_request(control_flow_data->drawing, |
6395d57c |
2093 | drawing->damage_begin, 0, |
2094 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
2095 | control_flow_data->drawing->height); |
a56a1ba4 |
2096 | } else { |
2097 | //if(ns<os<ns+w) |
2098 | //if(ns<os && os<ns+w) |
2099 | //if(ns<os && os<new_end) |
2100 | if(ltt_time_compare(*ns,*os) == -1 |
2101 | && ltt_time_compare(*os,new_end) == -1) |
2102 | { |
2103 | g_info("scrolling near left"); |
2104 | /* Scroll left, keep left part of the screen */ |
2105 | guint x = 0; |
51705146 |
2106 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
2107 | convert_time_to_pixels( |
a18124ff |
2108 | *new_time_window, |
a56a1ba4 |
2109 | *os, |
2110 | width, |
2111 | &x); |
6395d57c |
2112 | |
a56a1ba4 |
2113 | /* Copy old data to new location */ |
1c736ed5 |
2114 | copy_pixmap_region (process_list, |
2115 | NULL, |
cfe526b1 |
2116 | control_flow_data->drawing->drawing_area->style->black_gc, |
1c736ed5 |
2117 | NULL, |
a56a1ba4 |
2118 | 0, 0, |
2119 | x, 0, |
2120 | -1, -1); |
2121 | |
6395d57c |
2122 | if(drawing->damage_begin == drawing->damage_end) |
2123 | drawing->damage_end = x; |
2124 | else |
2125 | drawing->damage_end = |
51705146 |
2126 | control_flow_data->drawing->width; |
6395d57c |
2127 | |
2128 | drawing->damage_begin = 0; |
2129 | |
1c736ed5 |
2130 | rectangle_pixmap (process_list, |
cfe526b1 |
2131 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
2132 | TRUE, |
6395d57c |
2133 | drawing->damage_begin, 0, |
2134 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1c736ed5 |
2135 | -1); |
a43d67ba |
2136 | |
7abb23ad |
2137 | gtk_widget_queue_draw(drawing->drawing_area); |
2138 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2139 | // 0,0, |
2140 | // control_flow_data->drawing->width, |
2141 | // control_flow_data->drawing->height); |
a43d67ba |
2142 | |
6395d57c |
2143 | |
a56a1ba4 |
2144 | /* Get new data for the rest. */ |
501d5405 |
2145 | drawing_data_request(control_flow_data->drawing, |
6395d57c |
2146 | drawing->damage_begin, 0, |
2147 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
2148 | control_flow_data->drawing->height); |
a56a1ba4 |
2149 | |
a56a1ba4 |
2150 | } else { |
a43d67ba |
2151 | if(ltt_time_compare(*ns,*os) == 0) |
2152 | { |
2153 | g_info("not scrolling"); |
2154 | } else { |
2155 | g_info("scrolling far"); |
2156 | /* Cannot reuse any part of the screen : far jump */ |
2157 | |
2158 | |
1c736ed5 |
2159 | rectangle_pixmap (process_list, |
a43d67ba |
2160 | control_flow_data->drawing->drawing_area->style->black_gc, |
2161 | TRUE, |
a56a1ba4 |
2162 | 0, 0, |
a43d67ba |
2163 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 |
2164 | -1); |
a43d67ba |
2165 | |
7abb23ad |
2166 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2167 | // 0,0, |
2168 | // control_flow_data->drawing->width, |
2169 | // control_flow_data->drawing->height); |
2170 | gtk_widget_queue_draw(drawing->drawing_area); |
a43d67ba |
2171 | |
6395d57c |
2172 | drawing->damage_begin = 0; |
2173 | drawing->damage_end = control_flow_data->drawing->width; |
2174 | |
a43d67ba |
2175 | drawing_data_request(control_flow_data->drawing, |
a43d67ba |
2176 | 0, 0, |
2177 | control_flow_data->drawing->width, |
2178 | control_flow_data->drawing->height); |
2179 | |
2180 | } |
a56a1ba4 |
2181 | } |
2182 | } |
2183 | } else { |
2184 | /* Different scale (zoom) */ |
2185 | g_info("zoom"); |
2186 | |
1c736ed5 |
2187 | rectangle_pixmap (process_list, |
cfe526b1 |
2188 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
2189 | TRUE, |
2190 | 0, 0, |
501d5405 |
2191 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 |
2192 | -1); |
a56a1ba4 |
2193 | |
7abb23ad |
2194 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2195 | // 0,0, |
2196 | // control_flow_data->drawing->width, |
2197 | // control_flow_data->drawing->height); |
2198 | gtk_widget_queue_draw(drawing->drawing_area); |
a56a1ba4 |
2199 | |
6395d57c |
2200 | drawing->damage_begin = 0; |
2201 | drawing->damage_end = control_flow_data->drawing->width; |
2202 | |
501d5405 |
2203 | drawing_data_request(control_flow_data->drawing, |
a56a1ba4 |
2204 | 0, 0, |
501d5405 |
2205 | control_flow_data->drawing->width, |
2206 | control_flow_data->drawing->height); |
a56a1ba4 |
2207 | } |
2208 | |
15f77e3b |
2209 | /* Update directly when scrolling */ |
2210 | gdk_window_process_updates(control_flow_data->drawing->drawing_area->window, |
2211 | TRUE); |
3cb8b205 |
2212 | |
a56a1ba4 |
2213 | return 0; |
f7afe191 |
2214 | } |
2215 | |
6395d57c |
2216 | gint traceset_notify(void *hook_data, void *call_data) |
2217 | { |
2218 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
2219 | Drawing_t *drawing = control_flow_data->drawing; |
6395d57c |
2220 | |
6cec4cd2 |
2221 | if(unlikely(drawing->gc == NULL)) { |
2222 | return FALSE; |
2223 | } |
2224 | if(drawing->dotted_gc == NULL) { |
2225 | return FALSE; |
2226 | } |
6395d57c |
2227 | |
b9a010a2 |
2228 | drawing_clear(control_flow_data->drawing); |
2229 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
2230 | gtk_widget_set_size_request( |
2231 | control_flow_data->drawing->drawing_area, |
2232 | -1, processlist_get_height(control_flow_data->process_list)); |
d9267eec |
2233 | redraw_notify(control_flow_data, NULL); |
6395d57c |
2234 | |
d9267eec |
2235 | request_background_data(control_flow_data); |
6395d57c |
2236 | |
2237 | return FALSE; |
2238 | } |
2239 | |
ca0f8a8e |
2240 | gint redraw_notify(void *hook_data, void *call_data) |
2241 | { |
2242 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
2243 | Drawing_t *drawing = control_flow_data->drawing; |
2244 | GtkWidget *widget = drawing->drawing_area; |
2245 | |
2246 | drawing->damage_begin = 0; |
51705146 |
2247 | drawing->damage_end = drawing->width; |
ca0f8a8e |
2248 | |
49217bd4 |
2249 | /* fun feature, to be separated someday... */ |
2250 | drawing_clear(control_flow_data->drawing); |
2251 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
2252 | gtk_widget_set_size_request( |
2253 | control_flow_data->drawing->drawing_area, |
2254 | -1, processlist_get_height(control_flow_data->process_list)); |
1c736ed5 |
2255 | // Clear the images |
2256 | rectangle_pixmap (control_flow_data->process_list, |
ca0f8a8e |
2257 | widget->style->black_gc, |
2258 | TRUE, |
2259 | 0, 0, |
f3b7430d |
2260 | drawing->alloc_width, |
1c736ed5 |
2261 | -1); |
ca0f8a8e |
2262 | |
f3b7430d |
2263 | gtk_widget_queue_draw(drawing->drawing_area); |
4a24fa1f |
2264 | |
ca0f8a8e |
2265 | if(drawing->damage_begin < drawing->damage_end) |
2266 | { |
2267 | drawing_data_request(drawing, |
ca0f8a8e |
2268 | drawing->damage_begin, |
2269 | 0, |
2270 | drawing->damage_end-drawing->damage_begin, |
51705146 |
2271 | drawing->height); |
ca0f8a8e |
2272 | } |
2273 | |
7abb23ad |
2274 | //gtk_widget_queue_draw_area(drawing->drawing_area, |
2275 | // 0,0, |
2276 | // drawing->width, |
2277 | // drawing->height); |
ca0f8a8e |
2278 | return FALSE; |
2279 | |
2280 | } |
2281 | |
2282 | |
2283 | gint continue_notify(void *hook_data, void *call_data) |
a43d67ba |
2284 | { |
2285 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
ca0f8a8e |
2286 | Drawing_t *drawing = control_flow_data->drawing; |
a43d67ba |
2287 | |
6395d57c |
2288 | //g_assert(widget->allocation.width == drawing->damage_end); |
ca0f8a8e |
2289 | |
2290 | if(drawing->damage_begin < drawing->damage_end) |
2291 | { |
2292 | drawing_data_request(drawing, |
ca0f8a8e |
2293 | drawing->damage_begin, |
2294 | 0, |
2295 | drawing->damage_end-drawing->damage_begin, |
51705146 |
2296 | drawing->height); |
ca0f8a8e |
2297 | } |
2298 | |
2299 | return FALSE; |
2300 | } |
2301 | |
2302 | |
1b238973 |
2303 | gint update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
2304 | { |
14963be0 |
2305 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
a43d67ba |
2306 | Drawing_t *drawing = control_flow_data->drawing; |
a56a1ba4 |
2307 | |
224446ce |
2308 | LttTime current_time = *((LttTime*)call_data); |
a56a1ba4 |
2309 | |
ca0f8a8e |
2310 | TimeWindow time_window = |
2311 | lttvwindow_get_time_window(control_flow_data->tab); |
a56a1ba4 |
2312 | |
ca0f8a8e |
2313 | LttTime time_begin = time_window.start_time; |
2314 | LttTime width = time_window.time_width; |
90ef7e4a |
2315 | LttTime half_width; |
2316 | { |
2317 | guint64 time_ll = ltt_time_to_uint64(width); |
2318 | time_ll = time_ll >> 1; /* divide by two */ |
2319 | half_width = ltt_time_from_uint64(time_ll); |
2320 | } |
a56a1ba4 |
2321 | LttTime time_end = ltt_time_add(time_begin, width); |
2322 | |
2323 | LttvTracesetContext * tsc = |
ca0f8a8e |
2324 | lttvwindow_get_traceset_context(control_flow_data->tab); |
a56a1ba4 |
2325 | |
ca0f8a8e |
2326 | LttTime trace_start = tsc->time_span.start_time; |
2327 | LttTime trace_end = tsc->time_span.end_time; |
a56a1ba4 |
2328 | |
2eef04b5 |
2329 | g_info("New current time HOOK : %lu, %lu", current_time.tv_sec, |
224446ce |
2330 | current_time.tv_nsec); |
a56a1ba4 |
2331 | |
2332 | |
2333 | |
2334 | /* If current time is inside time interval, just move the highlight |
2335 | * bar */ |
2336 | |
2337 | /* Else, we have to change the time interval. We have to tell it |
2338 | * to the main window. */ |
2339 | /* The time interval change will take care of placing the current |
2340 | * time at the center of the visible area, or nearest possible if we are |
2341 | * at one end of the trace. */ |
2342 | |
2343 | |
dbc0ef8a |
2344 | if(ltt_time_compare(current_time, time_begin) < 0) |
a56a1ba4 |
2345 | { |
224446ce |
2346 | TimeWindow new_time_window; |
2347 | |
2348 | if(ltt_time_compare(current_time, |
dbc0ef8a |
2349 | ltt_time_add(trace_start,half_width)) < 0) |
a56a1ba4 |
2350 | time_begin = trace_start; |
2351 | else |
224446ce |
2352 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
2353 | |
224446ce |
2354 | new_time_window.start_time = time_begin; |
2355 | new_time_window.time_width = width; |
a18124ff |
2356 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 |
2357 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 |
2358 | |
e800cf84 |
2359 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 |
2360 | } |
dbc0ef8a |
2361 | else if(ltt_time_compare(current_time, time_end) > 0) |
a56a1ba4 |
2362 | { |
224446ce |
2363 | TimeWindow new_time_window; |
2364 | |
dbc0ef8a |
2365 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0) |
a56a1ba4 |
2366 | time_begin = ltt_time_sub(trace_end,width); |
2367 | else |
224446ce |
2368 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
2369 | |
224446ce |
2370 | new_time_window.start_time = time_begin; |
2371 | new_time_window.time_width = width; |
a18124ff |
2372 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 |
2373 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 |
2374 | |
e800cf84 |
2375 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 |
2376 | |
2377 | } |
7abb23ad |
2378 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
a56a1ba4 |
2379 | |
15f77e3b |
2380 | /* Update directly when scrolling */ |
2381 | gdk_window_process_updates(control_flow_data->drawing->drawing_area->window, |
2382 | TRUE); |
2383 | |
a56a1ba4 |
2384 | return 0; |
f7afe191 |
2385 | } |
2386 | |
8b90e648 |
2387 | typedef struct _ClosureData { |
ca0f8a8e |
2388 | EventsRequest *events_request; |
d0cd7f09 |
2389 | LttvTracesetState *tss; |
b9a010a2 |
2390 | LttTime end_time; |
bc8d270b |
2391 | guint x_end; |
8b90e648 |
2392 | } ClosureData; |
a56a1ba4 |
2393 | |
8b90e648 |
2394 | |
e800cf84 |
2395 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
2396 | { |
a56a1ba4 |
2397 | ProcessInfo *process_info = (ProcessInfo*)key; |
2398 | HashedProcessData *hashed_process_data = (HashedProcessData*)value; |
2399 | ClosureData *closure_data = (ClosureData*)user_data; |
2400 | |
e800cf84 |
2401 | EventsRequest *events_request = closure_data->events_request; |
2402 | ControlFlowData *control_flow_data = events_request->viewer_data; |
a56a1ba4 |
2403 | |
e800cf84 |
2404 | LttvTracesetState *tss = closure_data->tss; |
d6fef890 |
2405 | LttvTracesetContext *tsc = (LttvTracesetContext*)tss; |
a56a1ba4 |
2406 | |
e800cf84 |
2407 | LttTime evtime = closure_data->end_time; |
d0cd7f09 |
2408 | |
e3162168 |
2409 | gboolean dodraw = TRUE; |
2410 | |
e800cf84 |
2411 | { |
2412 | /* For the process */ |
2413 | /* First, check if the current process is in the state computation |
2414 | * process list. If it is there, that means we must add it right now and |
2415 | * draw items from the beginning of the read for it. If it is not |
2416 | * present, it's a new process and it was not present : it will |
2417 | * be added after the state update. */ |
31b6868d |
2418 | #ifdef EXTRA_CHECK |
e800cf84 |
2419 | g_assert(lttv_traceset_number(tsc->ts) > 0); |
31b6868d |
2420 | #endif //EXTRA_CHECK |
2c82c4dc |
2421 | LttvTraceContext *tc = tsc->traces[process_info->trace_num]; |
348c6ba8 |
2422 | LttvTraceState *ts = (LttvTraceState*)tc; |
2c82c4dc |
2423 | |
348c6ba8 |
2424 | #if 0 |
2c82c4dc |
2425 | //FIXME : optimize data structures. |
2426 | LttvTracefileState *tfs; |
2427 | LttvTracefileContext *tfc; |
2428 | guint i; |
2429 | for(i=0;i<tc->tracefiles->len;i++) { |
2430 | tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i); |
2431 | if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU |
ae3d0f50 |
2432 | && tfs->cpu == process_info->cpu) |
2c82c4dc |
2433 | break; |
2434 | |
2435 | } |
2436 | g_assert(i<tc->tracefiles->len); |
2437 | tfs = LTTV_TRACEFILE_STATE(tfc); |
348c6ba8 |
2438 | #endif //0 |
2c82c4dc |
2439 | // LttvTracefileState *tfs = |
2440 | // (LttvTracefileState*)tsc->traces[process_info->trace_num]-> |
2441 | // tracefiles[process_info->cpu]; |
2da61677 |
2442 | |
e800cf84 |
2443 | LttvProcessState *process; |
348c6ba8 |
2444 | process = lttv_state_find_process(ts, process_info->cpu, |
e025a729 |
2445 | process_info->pid); |
a56a1ba4 |
2446 | |
1d1df11d |
2447 | if(unlikely(process != NULL)) { |
e800cf84 |
2448 | |
b6ef18af |
2449 | LttvFilter *filter = control_flow_data->filter; |
2450 | if(filter != NULL && filter->head != NULL) |
2451 | if(!lttv_filter_tree_parse(filter->head,NULL,NULL, |
2452 | tc->t,NULL,process,tc)) |
e3162168 |
2453 | dodraw = FALSE; |
b6ef18af |
2454 | |
e800cf84 |
2455 | /* Only draw for processes that are currently in the trace states */ |
ad2e83ba |
2456 | |
5c230fc4 |
2457 | ProcessList *process_list = control_flow_data->process_list; |
1d1df11d |
2458 | #ifdef EXTRA_CHECK |
e800cf84 |
2459 | /* Should be alike when background info is ready */ |
2460 | if(control_flow_data->background_info_waiting==0) |
2461 | g_assert(ltt_time_compare(process->creation_time, |
2462 | process_info->birth) == 0); |
1d1df11d |
2463 | #endif //EXTRA_CHECK |
e800cf84 |
2464 | |
2465 | /* Now, the process is in the state hash and our own process hash. |
2466 | * We definitely can draw the items related to the ending state. |
2467 | */ |
2468 | |
1d1df11d |
2469 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
2470 | evtime) <= 0)) |
e800cf84 |
2471 | { |
fd22065b |
2472 | TimeWindow time_window = |
2473 | lttvwindow_get_time_window(control_flow_data->tab); |
2474 | |
2475 | #ifdef EXTRA_CHECK |
2476 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2477 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2478 | return; |
2479 | #endif //EXTRA_CHECK |
d6fef890 |
2480 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2481 | guint width = drawing->width; |
a56a1ba4 |
2482 | |
bc8d270b |
2483 | guint x = closure_data->x_end; |
8b90e648 |
2484 | |
4b7dc462 |
2485 | DrawContext draw_context; |
2486 | |
e800cf84 |
2487 | /* Now create the drawing context that will be used to draw |
2488 | * items related to the last state. */ |
1c736ed5 |
2489 | draw_context.drawable = hashed_process_data->pixmap; |
e800cf84 |
2490 | draw_context.gc = drawing->gc; |
2491 | draw_context.pango_layout = drawing->pango_layout; |
e800cf84 |
2492 | draw_context.drawinfo.end.x = x; |
2493 | |
1c736ed5 |
2494 | draw_context.drawinfo.y.over = 1; |
2495 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2496 | draw_context.drawinfo.y.under = hashed_process_data->height; |
e800cf84 |
2497 | |
2498 | draw_context.drawinfo.start.offset.over = 0; |
2499 | draw_context.drawinfo.start.offset.middle = 0; |
2500 | draw_context.drawinfo.start.offset.under = 0; |
2501 | draw_context.drawinfo.end.offset.over = 0; |
2502 | draw_context.drawinfo.end.offset.middle = 0; |
2503 | draw_context.drawinfo.end.offset.under = 0; |
9a1ec01b |
2504 | #if 0 |
4b7dc462 |
2505 | /* Jump over draw if we are at the same x position */ |
2506 | if(x == hashed_process_data->x.over) |
e800cf84 |
2507 | { |
4b7dc462 |
2508 | /* jump */ |
2509 | } else { |
23093869 |
2510 | draw_context.drawinfo.start.x = hashed_process_data->x.over; |
2511 | /* Draw the line */ |
2512 | PropertiesLine prop_line = prepare_execmode_line(process); |
2513 | draw_line((void*)&prop_line, (void*)&draw_context); |
2514 | |
4b7dc462 |
2515 | hashed_process_data->x.over = x; |
23093869 |
2516 | } |
9a1ec01b |
2517 | #endif //0 |
4b7dc462 |
2518 | |
1d1df11d |
2519 | if(unlikely(x == hashed_process_data->x.middle && |
2520 | hashed_process_data->x.middle_used)) { |
b2743953 |
2521 | #if 0 /* do not mark closure : not missing information */ |
e72908ed |
2522 | if(hashed_process_data->x.middle_marked == FALSE) { |
2523 | /* Draw collision indicator */ |
2524 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2525 | gdk_draw_point(drawing->pixmap, |
2526 | drawing->gc, |
2527 | x, |
2c6618bc |
2528 | y+(height/2)-3); |
de4ea1ad |
2529 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
2530 | } |
b2743953 |
2531 | #endif //0 |
4b7dc462 |
2532 | /* Jump */ |
2533 | } else { |
23093869 |
2534 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
e800cf84 |
2535 | /* Draw the line */ |
c4a72569 |
2536 | if(dodraw) { |
2537 | PropertiesLine prop_line = prepare_s_e_line(process); |
2538 | draw_line((void*)&prop_line, (void*)&draw_context); |
2539 | } |
e800cf84 |
2540 | |
4b7dc462 |
2541 | /* become the last x position */ |
1d1df11d |
2542 | if(likely(x != hashed_process_data->x.middle)) { |
e72908ed |
2543 | hashed_process_data->x.middle = x; |
2544 | /* but don't use the pixel */ |
2545 | hashed_process_data->x.middle_used = FALSE; |
b2743953 |
2546 | |
2547 | /* Calculate the next good time */ |
2548 | convert_pixels_to_time(width, x+1, time_window, |
2549 | &hashed_process_data->next_good_time); |
e72908ed |
2550 | } |
e800cf84 |
2551 | } |
e800cf84 |
2552 | } |
2553 | } |
2554 | } |
2555 | return; |
8b90e648 |
2556 | } |
2557 | |
b9a010a2 |
2558 | int before_chunk(void *hook_data, void *call_data) |
2559 | { |
2560 | EventsRequest *events_request = (EventsRequest*)hook_data; |
16b9cadb |
2561 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
7c0125e0 |
2562 | ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data; |
cd3892fe |
2563 | #if 0 |
7c0125e0 |
2564 | /* Desactivate sort */ |
2565 | gtk_tree_sortable_set_sort_column_id( |
2566 | GTK_TREE_SORTABLE(cfd->process_list->list_store), |
2567 | TRACE_COLUMN, |
2568 | GTK_SORT_ASCENDING); |
cd3892fe |
2569 | #endif //0 |
b9a010a2 |
2570 | drawing_chunk_begin(events_request, tss); |
2571 | |
2572 | return 0; |
2573 | } |
2574 | |
2575 | int before_request(void *hook_data, void *call_data) |
ca0f8a8e |
2576 | { |
2577 | EventsRequest *events_request = (EventsRequest*)hook_data; |
16b9cadb |
2578 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
7c0125e0 |
2579 | |
ca0f8a8e |
2580 | drawing_data_request_begin(events_request, tss); |
2581 | |
2582 | return 0; |
2583 | } |
2584 | |
2585 | |
8b90e648 |
2586 | /* |
b9a010a2 |
2587 | * after request is necessary in addition of after chunk in order to draw |
2588 | * lines until the end of the screen. after chunk just draws lines until |
2589 | * the last event. |
2590 | * |
8b90e648 |
2591 | * for each process |
a56a1ba4 |
2592 | * draw closing line |
b9a010a2 |
2593 | * expose |
8b90e648 |
2594 | */ |
b9a010a2 |
2595 | int after_request(void *hook_data, void *call_data) |
8b90e648 |
2596 | { |
ca0f8a8e |
2597 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2598 | ControlFlowData *control_flow_data = events_request->viewer_data; |
16b9cadb |
2599 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
a56a1ba4 |
2600 | |
5c230fc4 |
2601 | ProcessList *process_list = control_flow_data->process_list; |
b9a010a2 |
2602 | LttTime end_time = events_request->end_time; |
2603 | |
2604 | ClosureData closure_data; |
2605 | closure_data.events_request = (EventsRequest*)hook_data; |
2606 | closure_data.tss = tss; |
2607 | closure_data.end_time = end_time; |
2608 | |
bc8d270b |
2609 | TimeWindow time_window = |
2610 | lttvwindow_get_time_window(control_flow_data->tab); |
2611 | guint width = control_flow_data->drawing->width; |
2612 | convert_time_to_pixels( |
2613 | time_window, |
2614 | end_time, |
2615 | width, |
2616 | &closure_data.x_end); |
2617 | |
2618 | |
b9a010a2 |
2619 | /* Draw last items */ |
2620 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
2621 | (void*)&closure_data); |
7c0125e0 |
2622 | |
b9a010a2 |
2623 | |
2624 | /* Request expose */ |
2625 | drawing_request_expose(events_request, tss, end_time); |
2626 | return 0; |
2627 | } |
2628 | |
2629 | /* |
2630 | * for each process |
2631 | * draw closing line |
e800cf84 |
2632 | * expose |
b9a010a2 |
2633 | */ |
2634 | int after_chunk(void *hook_data, void *call_data) |
2635 | { |
2636 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2637 | ControlFlowData *control_flow_data = events_request->viewer_data; |
16b9cadb |
2638 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
2639 | LttvTracesetContext *tsc = (LttvTracesetContext*)call_data; |
b9a010a2 |
2640 | LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc); |
2641 | LttTime end_time; |
2642 | |
5c230fc4 |
2643 | ProcessList *process_list = control_flow_data->process_list; |
0f090e21 |
2644 | guint i; |
2645 | LttvTraceset *traceset = tsc->ts; |
2646 | guint nb_trace = lttv_traceset_number(traceset); |
b9a010a2 |
2647 | |
0f090e21 |
2648 | /* Only execute when called for the first trace's events request */ |
2649 | if(!process_list->current_hash_data) return; |
2650 | |
2651 | for(i = 0 ; i < nb_trace ; i++) { |
2652 | g_free(process_list->current_hash_data[i]); |
2653 | } |
40debf7b |
2654 | g_free(process_list->current_hash_data); |
2655 | process_list->current_hash_data = NULL; |
0f090e21 |
2656 | |
e800cf84 |
2657 | if(tfc != NULL) |
2658 | end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time); |
0c5dbe3b |
2659 | else /* end of traceset, or position now out of request : end */ |
2660 | end_time = events_request->end_time; |
2661 | |
a56a1ba4 |
2662 | ClosureData closure_data; |
ca0f8a8e |
2663 | closure_data.events_request = (EventsRequest*)hook_data; |
2664 | closure_data.tss = tss; |
b9a010a2 |
2665 | closure_data.end_time = end_time; |
a56a1ba4 |
2666 | |
bc8d270b |
2667 | TimeWindow time_window = |
2668 | lttvwindow_get_time_window(control_flow_data->tab); |
2669 | guint width = control_flow_data->drawing->width; |
2670 | convert_time_to_pixels( |
2671 | time_window, |
2672 | end_time, |
2673 | width, |
2674 | &closure_data.x_end); |
2675 | |
b9a010a2 |
2676 | /* Draw last items */ |
14963be0 |
2677 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
a56a1ba4 |
2678 | (void*)&closure_data); |
cd3892fe |
2679 | #if 0 |
7c0125e0 |
2680 | /* Reactivate sort */ |
2681 | gtk_tree_sortable_set_sort_column_id( |
2682 | GTK_TREE_SORTABLE(control_flow_data->process_list->list_store), |
2683 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
2684 | GTK_SORT_ASCENDING); |
2685 | |
2686 | update_index_to_pixmap(control_flow_data->process_list); |
cd3892fe |
2687 | /* Request a full expose : drawing scrambled */ |
2688 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
2689 | #endif //0 |
2690 | /* Request expose (updates damages zone also) */ |
b9a010a2 |
2691 | drawing_request_expose(events_request, tss, end_time); |
ca0f8a8e |
2692 | |
2693 | return 0; |
8b90e648 |
2694 | } |
2695 | |
b70ceef8 |
2696 | /* after_statedump_end |
2697 | * |
2698 | * @param hook_data ControlFlowData structure of the viewer. |
2699 | * @param call_data Event context. |
2700 | * |
2701 | * This function adds items to be drawn in a queue for each process. |
2702 | * |
2703 | */ |
2704 | int before_statedump_end(void *hook_data, void *call_data) |
2705 | { |
dd455fb8 |
2706 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
2707 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
b70ceef8 |
2708 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2709 | |
2710 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
2711 | |
2712 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
2713 | |
2714 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
2715 | |
2716 | LttvTracesetState *tss = (LttvTracesetState*)tfc->t_context->ts_context; |
2717 | ProcessList *process_list = control_flow_data->process_list; |
2718 | |
2719 | LttEvent *e; |
2720 | e = ltt_tracefile_get_event(tfc->tf); |
2721 | |
2722 | LttvFilter *filter = control_flow_data->filter; |
2723 | if(filter != NULL && filter->head != NULL) |
2724 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
2725 | tfc->t_context->t,tfc,NULL,NULL)) |
b70ceef8 |
2726 | return FALSE; |
2727 | |
2728 | LttTime evtime = ltt_event_time(e); |
2729 | |
2730 | ClosureData closure_data; |
2731 | closure_data.events_request = events_request; |
2732 | closure_data.tss = tss; |
2733 | closure_data.end_time = evtime; |
2734 | |
2735 | TimeWindow time_window = |
2736 | lttvwindow_get_time_window(control_flow_data->tab); |
2737 | guint width = control_flow_data->drawing->width; |
2738 | convert_time_to_pixels( |
2739 | time_window, |
2740 | evtime, |
2741 | width, |
2742 | &closure_data.x_end); |
2743 | |
2744 | /* Draw last items */ |
2745 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
2746 | (void*)&closure_data); |
2747 | #if 0 |
2748 | /* Reactivate sort */ |
2749 | gtk_tree_sortable_set_sort_column_id( |
2750 | GTK_TREE_SORTABLE(control_flow_data->process_list->list_store), |
2751 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
2752 | GTK_SORT_ASCENDING); |
2753 | |
2754 | update_index_to_pixmap(control_flow_data->process_list); |
2755 | /* Request a full expose : drawing scrambled */ |
2756 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
2757 | #endif //0 |
2758 | /* Request expose (updates damages zone also) */ |
2759 | drawing_request_expose(events_request, tss, evtime); |
2760 | |
2761 | return 0; |
2762 | } |