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