1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
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;
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.
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,
20 /*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
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.
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.
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.
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
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
52 //#define PANGO_ENABLE_BACKEND
60 //#include <pango/pango.h>
62 #include <ltt/event.h>
65 #include <ltt/trace.h>
67 #include <lttv/lttv.h>
68 #include <lttv/hook.h>
69 #include <lttv/state.h>
70 #include <lttvwindow/lttvwindow.h>
71 #include <lttvwindow/lttvwindowtraces.h>
72 #include <lttvwindow/support.h>
75 #include "eventhooks.h"
77 #include "processlist.h"
81 #define MAX_PATH_LEN 256
83 extern GSList
*g_legend_list
;
86 /* Action to do when background computation completed.
88 * Wait for all the awaited computations to be over.
91 static gint
background_ready(void *hook_data
, void *call_data
)
93 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
94 LttvTrace
*trace
= (LttvTrace
*)call_data
;
96 control_flow_data
->background_info_waiting
--;
98 if(control_flow_data
->background_info_waiting
== 0) {
99 g_message("control flow viewer : background computation data ready.");
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
);
113 /* Request background computation. Verify if it is in progress or ready first.
114 * Only for each trace in the tab's traceset.
116 static void request_background_data(ControlFlowData
*control_flow_data
)
118 LttvTracesetContext
* tsc
=
119 lttvwindow_get_traceset_context(control_flow_data
->tab
);
120 gint num_traces
= lttv_traceset_number(tsc
->ts
);
124 LttvHooks
*background_ready_hook
=
126 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
128 control_flow_data
->background_info_waiting
= 0;
130 for(i
=0;i
<num_traces
;i
++) {
131 trace
= lttv_traceset_get(tsc
->ts
, i
);
133 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
135 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
137 /* We first remove requests that could have been done for the same
138 * information. Happens when two viewers ask for it before servicing
141 if(!lttvwindowtraces_background_request_find(trace
, "state"))
142 lttvwindowtraces_background_request_queue(
143 main_window_get_widget(control_flow_data
->tab
), trace
, "state");
144 lttvwindowtraces_background_notify_queue(control_flow_data
,
148 background_ready_hook
);
149 control_flow_data
->background_info_waiting
++;
150 } else { /* in progress */
152 lttvwindowtraces_background_notify_current(control_flow_data
,
156 background_ready_hook
);
157 control_flow_data
->background_info_waiting
++;
160 /* Data ready. Be its nature, this viewer doesn't need to have
161 * its data ready hook called there, because a background
162 * request is always linked with a redraw.
168 lttv_hooks_destroy(background_ready_hook
);
175 * Event Viewer's constructor hook
177 * This constructor is given as a parameter to the menuitem and toolbar button
178 * registration. It creates the list.
179 * @param tab A pointer to the parent tab.
180 * @return The widget created.
183 h_guicontrolflow(LttvPlugin
*plugin
)
185 LttvPluginTab
*ptab
= LTTV_PLUGIN_TAB(plugin
);
186 Tab
*tab
= ptab
->tab
;
187 g_info("h_guicontrolflow, %p", tab
);
188 ControlFlowData
*control_flow_data
= guicontrolflow(ptab
);
190 control_flow_data
->tab
= tab
;
192 // Unreg done in the GuiControlFlow_Destructor
193 lttvwindow_register_traceset_notify(tab
,
197 lttvwindow_register_time_window_notify(tab
,
198 update_time_window_hook
,
200 lttvwindow_register_current_time_notify(tab
,
201 update_current_time_hook
,
203 lttvwindow_register_redraw_notify(tab
,
206 lttvwindow_register_continue_notify(tab
,
209 request_background_data(control_flow_data
);
212 return guicontrolflow_get_widget(control_flow_data
) ;
216 void legend_destructor(GtkWindow
*legend
)
218 g_legend_list
= g_slist_remove(g_legend_list
, legend
);
221 /* Create a popup legend */
223 h_legend(LttvPlugin
*plugin
)
225 LttvPluginTab
*ptab
= LTTV_PLUGIN_TAB(plugin
);
226 Tab
*tab
= ptab
->tab
;
227 g_info("h_legend, %p", tab
);
229 GtkWindow
*legend
= GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL
));
231 g_legend_list
= g_slist_append(
235 g_object_set_data_full(
239 (GDestroyNotify
)legend_destructor
);
241 gtk_window_set_title(legend
, "Control Flow View Legend");
243 GtkWidget
*pixmap
= create_pixmap(GTK_WIDGET(legend
), "lttv-color-list.png");
245 // GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixmap(
246 // GDK_PIXMAP(pixmap), NULL));
248 gtk_container_add(GTK_CONTAINER(legend
), GTK_WIDGET(pixmap
));
250 gtk_widget_show(GTK_WIDGET(pixmap
));
251 gtk_widget_show(GTK_WIDGET(legend
));
254 return NULL
; /* This is a popup window */
258 int event_selected_hook(void *hook_data
, void *call_data
)
260 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
261 guint
*event_number
= (guint
*) call_data
;
263 g_debug("DEBUG : event selected by main window : %u", *event_number
);
268 /* Function that selects the color of status&exemode line */
269 static inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
271 PropertiesLine prop_line
;
272 prop_line
.line_width
= 5;
273 prop_line
.style
= GDK_LINE_SOLID
;
274 prop_line
.y
= MIDDLE
;
275 //GdkColormap *colormap = gdk_colormap_get_system();
277 if(process
->state
->s
== LTTV_STATE_RUN
) {
278 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
279 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
280 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
281 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
282 else if(process
->state
->t
== LTTV_STATE_TRAP
)
283 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
284 else if(process
->state
->t
== LTTV_STATE_IRQ
)
285 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
286 else if(process
->state
->t
== LTTV_STATE_SOFT_IRQ
)
287 prop_line
.color
= drawing_colors
[COL_RUN_SOFT_IRQ
];
288 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
289 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
291 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
292 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
293 /* We don't show if we wait while in user mode, trap, irq or syscall */
294 prop_line
.color
= drawing_colors
[COL_WAIT
];
295 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
296 /* We don't show if we wait for CPU while in user mode, trap, irq
298 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
299 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
300 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
301 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
302 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
303 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
304 prop_line
.color
= drawing_colors
[COL_EXIT
];
305 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
306 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
308 g_critical("unknown state : %s", g_quark_to_string(process
->state
->s
));
309 g_assert(FALSE
); /* UNKNOWN STATE */
317 /* before_schedchange_hook
319 * This function basically draw lines and icons. Two types of lines are drawn :
320 * one small (3 pixels?) representing the state of the process and the second
321 * type is thicker (10 pixels?) representing on which CPU a process is running
322 * (and this only in running state).
324 * Extremums of the lines :
325 * x_min : time of the last event context for this process kept in memory.
326 * x_max : time of the current event.
327 * y : middle of the process in the process list. The process is found in the
328 * list, therefore is it's position in pixels.
330 * The choice of lines'color is defined by the context of the last event for this
335 int before_schedchange_hook(void *hook_data
, void *call_data
)
337 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
338 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
339 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
341 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
343 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
344 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
347 e
= ltt_tracefile_get_event(tfc
->tf
);
348 gint target_pid_saved
= tfc
->target_pid
;
350 LttTime evtime
= ltt_event_time(e
);
351 LttvFilter
*filter
= control_flow_data
->filter
;
353 /* we are in a schedchange, before the state update. We must draw the
354 * items corresponding to the state before it changes : now is the right
361 pid_out
= ltt_event_get_long_unsigned(e
, thf
->f1
);
362 pid_in
= ltt_event_get_long_unsigned(e
, thf
->f2
);
365 tfc
->target_pid
= pid_out
;
366 if(!filter
|| !filter
->head
||
367 lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
368 tfc
->t_context
->t
,tfc
)) {
369 /* For the pid_out */
370 /* First, check if the current process is in the state computation
371 * process list. If it is there, that means we must add it right now and
372 * draw items from the beginning of the read for it. If it is not
373 * present, it's a new process and it was not present : it will
374 * be added after the state update. */
375 guint cpu
= tfs
->cpu
;
376 guint trace_num
= ts
->parent
.index
;
377 LttvProcessState
*process
= ts
->running_process
[cpu
];
378 /* unknown state, bad current pid */
379 if(process
->pid
!= pid_out
)
380 process
= lttv_state_find_process(ts
,
383 if(process
!= NULL
) {
384 /* Well, the process_out existed : we must get it in the process hash
385 * or add it, and draw its items.
387 /* Add process to process list (if not present) */
389 HashedProcessData
*hashed_process_data
= NULL
;
390 ProcessList
*process_list
= control_flow_data
->process_list
;
391 LttTime birth
= process
->creation_time
;
393 hashed_process_data
= processlist_get_process_data(process_list
,
398 if(hashed_process_data
== NULL
)
400 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
401 /* Process not present */
402 ProcessInfo
*process_info
;
403 Drawing_t
*drawing
= control_flow_data
->drawing
;
404 processlist_add(process_list
,
416 &hashed_process_data
);
417 gtk_widget_set_size_request(drawing
->drawing_area
,
420 gtk_widget_queue_draw(drawing
->drawing_area
);
424 /* Now, the process is in the state hash and our own process hash.
425 * We definitely can draw the items related to the ending state.
428 if(ltt_time_compare(hashed_process_data
->next_good_time
,
431 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
433 TimeWindow time_window
=
434 lttvwindow_get_time_window(control_flow_data
->tab
);
436 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
437 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
440 Drawing_t
*drawing
= control_flow_data
->drawing
;
441 guint width
= drawing
->width
;
443 convert_time_to_pixels(
449 /* Draw collision indicator */
450 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
451 gdk_draw_point(hashed_process_data
->pixmap
,
454 (hashed_process_data
->height
/2)-3);
455 hashed_process_data
->x
.middle_marked
= TRUE
;
458 TimeWindow time_window
=
459 lttvwindow_get_time_window(control_flow_data
->tab
);
461 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
462 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
465 Drawing_t
*drawing
= control_flow_data
->drawing
;
466 guint width
= drawing
->width
;
468 convert_time_to_pixels(
475 /* Jump over draw if we are at the same x position */
476 if(x
== hashed_process_data
->x
.middle
&&
477 hashed_process_data
->x
.middle_used
)
479 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
480 /* Draw collision indicator */
481 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
482 gdk_draw_point(hashed_process_data
->pixmap
,
485 (hashed_process_data
->height
/2)-3);
486 hashed_process_data
->x
.middle_marked
= TRUE
;
490 DrawContext draw_context
;
492 /* Now create the drawing context that will be used to draw
493 * items related to the last state. */
494 draw_context
.drawable
= hashed_process_data
->pixmap
;
495 draw_context
.gc
= drawing
->gc
;
496 draw_context
.pango_layout
= drawing
->pango_layout
;
497 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
498 draw_context
.drawinfo
.end
.x
= x
;
500 draw_context
.drawinfo
.y
.over
= 1;
501 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
502 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
504 draw_context
.drawinfo
.start
.offset
.over
= 0;
505 draw_context
.drawinfo
.start
.offset
.middle
= 0;
506 draw_context
.drawinfo
.start
.offset
.under
= 0;
507 draw_context
.drawinfo
.end
.offset
.over
= 0;
508 draw_context
.drawinfo
.end
.offset
.middle
= 0;
509 draw_context
.drawinfo
.end
.offset
.under
= 0;
513 PropertiesLine prop_line
= prepare_s_e_line(process
);
514 draw_line((void*)&prop_line
, (void*)&draw_context
);
517 /* become the last x position */
518 hashed_process_data
->x
.middle
= x
;
519 hashed_process_data
->x
.middle_used
= TRUE
;
520 hashed_process_data
->x
.middle_marked
= FALSE
;
522 /* Calculate the next good time */
523 convert_pixels_to_time(width
, x
+1, time_window
,
524 &hashed_process_data
->next_good_time
);
530 tfc
->target_pid
= pid_in
;
531 if(!filter
|| !filter
->head
||
532 lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
533 tfc
->t_context
->t
,tfc
)) {
535 /* First, check if the current process is in the state computation
536 * process list. If it is there, that means we must add it right now and
537 * draw items from the beginning of the read for it. If it is not
538 * present, it's a new process and it was not present : it will
539 * be added after the state update. */
540 LttvProcessState
*process
;
541 process
= lttv_state_find_process(ts
,
543 guint trace_num
= ts
->parent
.index
;
545 if(process
!= NULL
) {
546 /* Well, the process existed : we must get it in the process hash
547 * or add it, and draw its items.
549 /* Add process to process list (if not present) */
551 HashedProcessData
*hashed_process_data
= NULL
;
552 ProcessList
*process_list
= control_flow_data
->process_list
;
553 LttTime birth
= process
->creation_time
;
555 hashed_process_data
= processlist_get_process_data(process_list
,
560 if(hashed_process_data
== NULL
)
562 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
563 /* Process not present */
564 ProcessInfo
*process_info
;
565 Drawing_t
*drawing
= control_flow_data
->drawing
;
566 processlist_add(process_list
,
578 &hashed_process_data
);
579 gtk_widget_set_size_request(drawing
->drawing_area
,
582 gtk_widget_queue_draw(drawing
->drawing_area
);
585 //We could set the current process and hash here, but will be done
586 //by after schedchange hook
588 /* Now, the process is in the state hash and our own process hash.
589 * We definitely can draw the items related to the ending state.
592 if(ltt_time_compare(hashed_process_data
->next_good_time
,
595 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
597 TimeWindow time_window
=
598 lttvwindow_get_time_window(control_flow_data
->tab
);
600 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
601 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
604 Drawing_t
*drawing
= control_flow_data
->drawing
;
605 guint width
= drawing
->width
;
607 convert_time_to_pixels(
613 /* Draw collision indicator */
614 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
615 gdk_draw_point(hashed_process_data
->pixmap
,
618 (hashed_process_data
->height
/2)-3);
619 hashed_process_data
->x
.middle_marked
= TRUE
;
622 TimeWindow time_window
=
623 lttvwindow_get_time_window(control_flow_data
->tab
);
625 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
626 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
629 Drawing_t
*drawing
= control_flow_data
->drawing
;
630 guint width
= drawing
->width
;
633 convert_time_to_pixels(
640 /* Jump over draw if we are at the same x position */
641 if(x
== hashed_process_data
->x
.middle
&&
642 hashed_process_data
->x
.middle_used
)
644 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
645 /* Draw collision indicator */
646 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
647 gdk_draw_point(hashed_process_data
->pixmap
,
650 (hashed_process_data
->height
/2)-3);
651 hashed_process_data
->x
.middle_marked
= TRUE
;
655 DrawContext draw_context
;
657 /* Now create the drawing context that will be used to draw
658 * items related to the last state. */
659 draw_context
.drawable
= hashed_process_data
->pixmap
;
660 draw_context
.gc
= drawing
->gc
;
661 draw_context
.pango_layout
= drawing
->pango_layout
;
662 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
663 draw_context
.drawinfo
.end
.x
= x
;
665 draw_context
.drawinfo
.y
.over
= 1;
666 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
667 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
669 draw_context
.drawinfo
.start
.offset
.over
= 0;
670 draw_context
.drawinfo
.start
.offset
.middle
= 0;
671 draw_context
.drawinfo
.start
.offset
.under
= 0;
672 draw_context
.drawinfo
.end
.offset
.over
= 0;
673 draw_context
.drawinfo
.end
.offset
.middle
= 0;
674 draw_context
.drawinfo
.end
.offset
.under
= 0;
678 PropertiesLine prop_line
= prepare_s_e_line(process
);
679 draw_line((void*)&prop_line
, (void*)&draw_context
);
683 /* become the last x position */
684 hashed_process_data
->x
.middle
= x
;
685 hashed_process_data
->x
.middle_used
= TRUE
;
686 hashed_process_data
->x
.middle_marked
= FALSE
;
688 /* Calculate the next good time */
689 convert_pixels_to_time(width
, x
+1, time_window
,
690 &hashed_process_data
->next_good_time
);
694 g_warning("Cannot find pin_in in schedchange %u", pid_in
);
696 tfc
->target_pid
= target_pid_saved
;
704 GString
*string
= g_string_new("");;
705 gboolean field_names
= TRUE
, state
= TRUE
;
707 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
708 g_string_append_printf(string
,"\n");
711 g_string_append_printf(string
, " %s",
712 g_quark_to_string(tfs
->process
->state
->s
));
715 g_info("%s",string
->str
);
717 g_string_free(string
, TRUE
);
719 /* End of text dump */
724 /* after_schedchange_hook
726 * The draw after hook is called by the reading API to have a
727 * particular event drawn on the screen.
728 * @param hook_data ControlFlowData structure of the viewer.
729 * @param call_data Event context.
731 * This function adds items to be drawn in a queue for each process.
734 int after_schedchange_hook(void *hook_data
, void *call_data
)
736 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
737 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
738 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
740 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
742 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
744 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
747 e
= ltt_tracefile_get_event(tfc
->tf
);
749 LttvFilter
*filter
= control_flow_data
->filter
;
750 if(filter
!= NULL
&& filter
->head
!= NULL
)
751 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
752 tfc
->t_context
->t
,tfc
))
755 LttTime evtime
= ltt_event_time(e
);
757 /* Add process to process list (if not present) */
758 LttvProcessState
*process_in
;
761 HashedProcessData
*hashed_process_data_in
= NULL
;
763 ProcessList
*process_list
= control_flow_data
->process_list
;
768 pid_out
= ltt_event_get_long_unsigned(e
, thf
->f1
);
769 pid_in
= ltt_event_get_long_unsigned(e
, thf
->f2
);
773 /* Find process pid_in in the list... */
774 //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
775 //process_in = tfs->process;
776 guint cpu
= tfs
->cpu
;
777 guint trace_num
= ts
->parent
.index
;
778 process_in
= ts
->running_process
[cpu
];
779 /* It should exist, because we are after the state update. */
781 g_assert(process_in
!= NULL
);
783 birth
= process_in
->creation_time
;
785 hashed_process_data_in
= processlist_get_process_data(process_list
,
790 if(hashed_process_data_in
== NULL
)
792 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
793 ProcessInfo
*process_info
;
794 Drawing_t
*drawing
= control_flow_data
->drawing
;
795 /* Process not present */
796 processlist_add(process_list
,
808 &hashed_process_data_in
);
809 gtk_widget_set_size_request(drawing
->drawing_area
,
812 gtk_widget_queue_draw(drawing
->drawing_area
);
814 /* Set the current process */
815 process_list
->current_hash_data
[trace_num
][process_in
->cpu
] =
816 hashed_process_data_in
;
818 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
821 TimeWindow time_window
=
822 lttvwindow_get_time_window(control_flow_data
->tab
);
825 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
826 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
829 Drawing_t
*drawing
= control_flow_data
->drawing
;
830 guint width
= drawing
->width
;
833 convert_time_to_pixels(
839 if(hashed_process_data_in
->x
.middle
!= new_x
) {
840 hashed_process_data_in
->x
.middle
= new_x
;
841 hashed_process_data_in
->x
.middle_used
= FALSE
;
842 hashed_process_data_in
->x
.middle_marked
= FALSE
;
851 /* before_execmode_hook
853 * This function basically draw lines and icons. Two types of lines are drawn :
854 * one small (3 pixels?) representing the state of the process and the second
855 * type is thicker (10 pixels?) representing on which CPU a process is running
856 * (and this only in running state).
858 * Extremums of the lines :
859 * x_min : time of the last event context for this process kept in memory.
860 * x_max : time of the current event.
861 * y : middle of the process in the process list. The process is found in the
862 * list, therefore is it's position in pixels.
864 * The choice of lines'color is defined by the context of the last event for this
869 int before_execmode_hook(void *hook_data
, void *call_data
)
871 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
872 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
873 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
875 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
877 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
879 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
882 e
= ltt_tracefile_get_event(tfc
->tf
);
884 LttvFilter
*filter
= control_flow_data
->filter
;
885 if(filter
!= NULL
&& filter
->head
!= NULL
)
886 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
887 tfc
->t_context
->t
,tfc
))
890 LttTime evtime
= ltt_event_time(e
);
892 /* we are in a execmode, before the state update. We must draw the
893 * items corresponding to the state before it changes : now is the right
897 //LttvProcessState *process = tfs->process;
898 guint cpu
= tfs
->cpu
;
899 guint trace_num
= ts
->parent
.index
;
900 LttvProcessState
*process
= ts
->running_process
[cpu
];
901 g_assert(process
!= NULL
);
903 guint pid
= process
->pid
;
905 /* Well, the process_out existed : we must get it in the process hash
906 * or add it, and draw its items.
908 /* Add process to process list (if not present) */
910 HashedProcessData
*hashed_process_data
= NULL
;
911 ProcessList
*process_list
= control_flow_data
->process_list
;
912 LttTime birth
= process
->creation_time
;
914 if(likely(process_list
->current_hash_data
[trace_num
][cpu
] != NULL
)) {
915 hashed_process_data
= process_list
->current_hash_data
[trace_num
][cpu
];
917 hashed_process_data
= processlist_get_process_data(process_list
,
922 if(unlikely(hashed_process_data
== NULL
))
924 g_assert(pid
== 0 || pid
!= process
->ppid
);
925 ProcessInfo
*process_info
;
926 /* Process not present */
927 Drawing_t
*drawing
= control_flow_data
->drawing
;
928 processlist_add(process_list
,
940 &hashed_process_data
);
941 gtk_widget_set_size_request(drawing
->drawing_area
,
944 gtk_widget_queue_draw(drawing
->drawing_area
);
946 /* Set the current process */
947 process_list
->current_hash_data
[trace_num
][process
->cpu
] =
951 /* Now, the process is in the state hash and our own process hash.
952 * We definitely can draw the items related to the ending state.
955 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
958 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
959 TimeWindow time_window
=
960 lttvwindow_get_time_window(control_flow_data
->tab
);
963 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
964 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
967 Drawing_t
*drawing
= control_flow_data
->drawing
;
968 guint width
= drawing
->width
;
970 convert_time_to_pixels(
976 /* Draw collision indicator */
977 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
978 gdk_draw_point(hashed_process_data
->pixmap
,
981 (hashed_process_data
->height
/2)-3);
982 hashed_process_data
->x
.middle_marked
= TRUE
;
985 TimeWindow time_window
=
986 lttvwindow_get_time_window(control_flow_data
->tab
);
989 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
990 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
993 Drawing_t
*drawing
= control_flow_data
->drawing
;
994 guint width
= drawing
->width
;
997 convert_time_to_pixels(
1004 /* Jump over draw if we are at the same x position */
1005 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1006 hashed_process_data
->x
.middle_used
))
1008 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1009 /* Draw collision indicator */
1010 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1011 gdk_draw_point(hashed_process_data
->pixmap
,
1014 (hashed_process_data
->height
/2)-3);
1015 hashed_process_data
->x
.middle_marked
= TRUE
;
1020 DrawContext draw_context
;
1021 /* Now create the drawing context that will be used to draw
1022 * items related to the last state. */
1023 draw_context
.drawable
= hashed_process_data
->pixmap
;
1024 draw_context
.gc
= drawing
->gc
;
1025 draw_context
.pango_layout
= drawing
->pango_layout
;
1026 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1027 draw_context
.drawinfo
.end
.x
= x
;
1029 draw_context
.drawinfo
.y
.over
= 1;
1030 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1031 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1033 draw_context
.drawinfo
.start
.offset
.over
= 0;
1034 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1035 draw_context
.drawinfo
.start
.offset
.under
= 0;
1036 draw_context
.drawinfo
.end
.offset
.over
= 0;
1037 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1038 draw_context
.drawinfo
.end
.offset
.under
= 0;
1042 PropertiesLine prop_line
= prepare_s_e_line(process
);
1043 draw_line((void*)&prop_line
, (void*)&draw_context
);
1046 /* become the last x position */
1047 hashed_process_data
->x
.middle
= x
;
1048 hashed_process_data
->x
.middle_used
= TRUE
;
1049 hashed_process_data
->x
.middle_marked
= FALSE
;
1051 /* Calculate the next good time */
1052 convert_pixels_to_time(width
, x
+1, time_window
,
1053 &hashed_process_data
->next_good_time
);
1060 /* before_process_exit_hook
1062 * Draw lines for process event.
1064 * @param hook_data ControlFlowData structure of the viewer.
1065 * @param call_data Event context.
1067 * This function adds items to be drawn in a queue for each process.
1072 int before_process_exit_hook(void *hook_data
, void *call_data
)
1074 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1075 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1077 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1079 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1081 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1083 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1086 e
= ltt_tracefile_get_event(tfc
->tf
);
1088 LttvFilter
*filter
= control_flow_data
->filter
;
1089 if(filter
!= NULL
&& filter
->head
!= NULL
)
1090 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
1091 tfc
->t_context
->t
,tfc
))
1094 LttTime evtime
= ltt_event_time(e
);
1096 /* Add process to process list (if not present) */
1097 //LttvProcessState *process = tfs->process;
1098 guint cpu
= tfs
->cpu
;
1099 guint trace_num
= ts
->parent
.index
;
1100 LttvProcessState
*process
= ts
->running_process
[cpu
];
1101 guint pid
= process
->pid
;
1103 guint pl_height
= 0;
1104 HashedProcessData
*hashed_process_data
= NULL
;
1106 ProcessList
*process_list
= control_flow_data
->process_list
;
1108 g_assert(process
!= NULL
);
1110 birth
= process
->creation_time
;
1112 if(likely(process_list
->current_hash_data
[trace_num
][cpu
] != NULL
)) {
1113 hashed_process_data
= process_list
->current_hash_data
[trace_num
][cpu
];
1115 hashed_process_data
= processlist_get_process_data(process_list
,
1120 if(unlikely(hashed_process_data
== NULL
))
1122 g_assert(pid
== 0 || pid
!= process
->ppid
);
1123 /* Process not present */
1124 Drawing_t
*drawing
= control_flow_data
->drawing
;
1125 ProcessInfo
*process_info
;
1126 processlist_add(process_list
,
1138 &hashed_process_data
);
1139 gtk_widget_set_size_request(drawing
->drawing_area
,
1142 gtk_widget_queue_draw(drawing
->drawing_area
);
1146 /* Now, the process is in the state hash and our own process hash.
1147 * We definitely can draw the items related to the ending state.
1150 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1153 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1154 TimeWindow time_window
=
1155 lttvwindow_get_time_window(control_flow_data
->tab
);
1158 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1159 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1161 #endif //EXTRA_CHECK
1162 Drawing_t
*drawing
= control_flow_data
->drawing
;
1163 guint width
= drawing
->width
;
1165 convert_time_to_pixels(
1171 /* Draw collision indicator */
1172 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1173 gdk_draw_point(hashed_process_data
->pixmap
,
1176 (hashed_process_data
->height
/2)-3);
1177 hashed_process_data
->x
.middle_marked
= TRUE
;
1180 TimeWindow time_window
=
1181 lttvwindow_get_time_window(control_flow_data
->tab
);
1184 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1185 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1187 #endif //EXTRA_CHECK
1188 Drawing_t
*drawing
= control_flow_data
->drawing
;
1189 guint width
= drawing
->width
;
1192 convert_time_to_pixels(
1199 /* Jump over draw if we are at the same x position */
1200 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1201 hashed_process_data
->x
.middle_used
))
1203 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1204 /* Draw collision indicator */
1205 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1206 gdk_draw_point(hashed_process_data
->pixmap
,
1209 (hashed_process_data
->height
/2)-3);
1210 hashed_process_data
->x
.middle_marked
= TRUE
;
1214 DrawContext draw_context
;
1216 /* Now create the drawing context that will be used to draw
1217 * items related to the last state. */
1218 draw_context
.drawable
= hashed_process_data
->pixmap
;
1219 draw_context
.gc
= drawing
->gc
;
1220 draw_context
.pango_layout
= drawing
->pango_layout
;
1221 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1222 draw_context
.drawinfo
.end
.x
= x
;
1224 draw_context
.drawinfo
.y
.over
= 1;
1225 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1226 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1228 draw_context
.drawinfo
.start
.offset
.over
= 0;
1229 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1230 draw_context
.drawinfo
.start
.offset
.under
= 0;
1231 draw_context
.drawinfo
.end
.offset
.over
= 0;
1232 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1233 draw_context
.drawinfo
.end
.offset
.under
= 0;
1237 PropertiesLine prop_line
= prepare_s_e_line(process
);
1238 draw_line((void*)&prop_line
, (void*)&draw_context
);
1241 /* become the last x position */
1242 hashed_process_data
->x
.middle
= x
;
1243 hashed_process_data
->x
.middle_used
= TRUE
;
1244 hashed_process_data
->x
.middle_marked
= FALSE
;
1246 /* Calculate the next good time */
1247 convert_pixels_to_time(width
, x
+1, time_window
,
1248 &hashed_process_data
->next_good_time
);
1258 /* before_process_release_hook
1260 * Draw lines for process event.
1262 * @param hook_data ControlFlowData structure of the viewer.
1263 * @param call_data Event context.
1265 * This function adds items to be drawn in a queue for each process.
1270 int before_process_release_hook(void *hook_data
, void *call_data
)
1272 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1273 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1275 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1277 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1279 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1281 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1284 e
= ltt_tracefile_get_event(tfc
->tf
);
1286 LttvFilter
*filter
= control_flow_data
->filter
;
1287 if(filter
!= NULL
&& filter
->head
!= NULL
)
1288 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
1289 tfc
->t_context
->t
,tfc
))
1292 LttTime evtime
= ltt_event_time(e
);
1294 guint trace_num
= ts
->parent
.index
;
1298 pid
= ltt_event_get_long_unsigned(e
, thf
->f1
);
1301 /* Add process to process list (if not present) */
1302 /* Don't care about the process if it's not in the state hash already :
1303 * that means a process that has never done anything in the trace and
1304 * unknown suddently gets destroyed : no state meaningful to show. */
1305 LttvProcessState
*process
= lttv_state_find_process(ts
, ANY_CPU
, pid
);
1307 if(process
!= NULL
) {
1309 guint pl_height
= 0;
1310 HashedProcessData
*hashed_process_data
= NULL
;
1312 ProcessList
*process_list
= control_flow_data
->process_list
;
1314 birth
= process
->creation_time
;
1316 /* Cannot use current process : this event happens on another process,
1317 * action done by the parent. */
1318 hashed_process_data
= processlist_get_process_data(process_list
,
1323 if(unlikely(hashed_process_data
== NULL
))
1325 g_assert(pid
== 0 || pid
!= process
->ppid
);
1326 /* Process not present */
1327 Drawing_t
*drawing
= control_flow_data
->drawing
;
1328 ProcessInfo
*process_info
;
1329 processlist_add(process_list
,
1341 &hashed_process_data
);
1342 gtk_widget_set_size_request(drawing
->drawing_area
,
1345 gtk_widget_queue_draw(drawing
->drawing_area
);
1348 /* Now, the process is in the state hash and our own process hash.
1349 * We definitely can draw the items related to the ending state.
1352 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1355 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1356 TimeWindow time_window
=
1357 lttvwindow_get_time_window(control_flow_data
->tab
);
1360 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1361 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1363 #endif //EXTRA_CHECK
1364 Drawing_t
*drawing
= control_flow_data
->drawing
;
1365 guint width
= drawing
->width
;
1367 convert_time_to_pixels(
1373 /* Draw collision indicator */
1374 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1375 gdk_draw_point(hashed_process_data
->pixmap
,
1378 (hashed_process_data
->height
/2)-3);
1379 hashed_process_data
->x
.middle_marked
= TRUE
;
1382 TimeWindow time_window
=
1383 lttvwindow_get_time_window(control_flow_data
->tab
);
1386 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1387 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1389 #endif //EXTRA_CHECK
1390 Drawing_t
*drawing
= control_flow_data
->drawing
;
1391 guint width
= drawing
->width
;
1394 convert_time_to_pixels(
1401 /* Jump over draw if we are at the same x position */
1402 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1403 hashed_process_data
->x
.middle_used
))
1405 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1406 /* Draw collision indicator */
1407 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1408 gdk_draw_point(hashed_process_data
->pixmap
,
1411 (hashed_process_data
->height
/2)-3);
1412 hashed_process_data
->x
.middle_marked
= TRUE
;
1416 DrawContext draw_context
;
1418 /* Now create the drawing context that will be used to draw
1419 * items related to the last state. */
1420 draw_context
.drawable
= hashed_process_data
->pixmap
;
1421 draw_context
.gc
= drawing
->gc
;
1422 draw_context
.pango_layout
= drawing
->pango_layout
;
1423 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1424 draw_context
.drawinfo
.end
.x
= x
;
1426 draw_context
.drawinfo
.y
.over
= 1;
1427 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1428 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1430 draw_context
.drawinfo
.start
.offset
.over
= 0;
1431 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1432 draw_context
.drawinfo
.start
.offset
.under
= 0;
1433 draw_context
.drawinfo
.end
.offset
.over
= 0;
1434 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1435 draw_context
.drawinfo
.end
.offset
.under
= 0;
1439 PropertiesLine prop_line
= prepare_s_e_line(process
);
1440 draw_line((void*)&prop_line
, (void*)&draw_context
);
1443 /* become the last x position */
1444 hashed_process_data
->x
.middle
= x
;
1445 hashed_process_data
->x
.middle_used
= TRUE
;
1446 hashed_process_data
->x
.middle_marked
= FALSE
;
1448 /* Calculate the next good time */
1449 convert_pixels_to_time(width
, x
+1, time_window
,
1450 &hashed_process_data
->next_good_time
);
1462 /* after_process_fork_hook
1464 * Create the processlist entry for the child process. Put the last
1465 * position in x at the current time value.
1467 * @param hook_data ControlFlowData structure of the viewer.
1468 * @param call_data Event context.
1470 * This function adds items to be drawn in a queue for each process.
1473 int after_process_fork_hook(void *hook_data
, void *call_data
)
1475 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1476 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1477 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1479 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1481 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1483 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1486 e
= ltt_tracefile_get_event(tfc
->tf
);
1488 LttvFilter
*filter
= control_flow_data
->filter
;
1489 if(filter
!= NULL
&& filter
->head
!= NULL
)
1490 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
1491 tfc
->t_context
->t
,tfc
))
1494 LttTime evtime
= ltt_event_time(e
);
1498 child_pid
= ltt_event_get_long_unsigned(e
, thf
->f2
);
1501 /* Add process to process list (if not present) */
1502 LttvProcessState
*process_child
;
1504 guint pl_height
= 0;
1505 HashedProcessData
*hashed_process_data_child
= NULL
;
1507 ProcessList
*process_list
= control_flow_data
->process_list
;
1509 /* Find child in the list... */
1510 process_child
= lttv_state_find_process(ts
, ANY_CPU
, child_pid
);
1511 /* It should exist, because we are after the state update. */
1512 g_assert(process_child
!= NULL
);
1514 birth
= process_child
->creation_time
;
1515 guint trace_num
= ts
->parent
.index
;
1517 /* Cannot use current process, because this action is done by the parent
1519 hashed_process_data_child
= processlist_get_process_data(process_list
,
1524 if(likely(hashed_process_data_child
== NULL
))
1526 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
1527 /* Process not present */
1528 Drawing_t
*drawing
= control_flow_data
->drawing
;
1529 ProcessInfo
*process_info
;
1530 processlist_add(process_list
,
1533 process_child
->tgid
,
1535 process_child
->ppid
,
1538 process_child
->name
,
1539 process_child
->brand
,
1542 &hashed_process_data_child
);
1543 gtk_widget_set_size_request(drawing
->drawing_area
,
1546 gtk_widget_queue_draw(drawing
->drawing_area
);
1548 processlist_set_ppid(process_list
, process_child
->ppid
,
1549 hashed_process_data_child
);
1550 processlist_set_tgid(process_list
, process_child
->tgid
,
1551 hashed_process_data_child
);
1555 if(likely(ltt_time_compare(hashed_process_data_child
->next_good_time
,
1558 TimeWindow time_window
=
1559 lttvwindow_get_time_window(control_flow_data
->tab
);
1562 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1563 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1565 #endif //EXTRA_CHECK
1566 Drawing_t
*drawing
= control_flow_data
->drawing
;
1567 guint width
= drawing
->width
;
1569 convert_time_to_pixels(
1575 if(likely(hashed_process_data_child
->x
.over
!= new_x
)) {
1576 hashed_process_data_child
->x
.over
= new_x
;
1577 hashed_process_data_child
->x
.over_used
= FALSE
;
1578 hashed_process_data_child
->x
.over_marked
= FALSE
;
1580 if(likely(hashed_process_data_child
->x
.middle
!= new_x
)) {
1581 hashed_process_data_child
->x
.middle
= new_x
;
1582 hashed_process_data_child
->x
.middle_used
= FALSE
;
1583 hashed_process_data_child
->x
.middle_marked
= FALSE
;
1585 if(likely(hashed_process_data_child
->x
.under
!= new_x
)) {
1586 hashed_process_data_child
->x
.under
= new_x
;
1587 hashed_process_data_child
->x
.under_used
= FALSE
;
1588 hashed_process_data_child
->x
.under_marked
= FALSE
;
1596 /* after_process_exit_hook
1598 * Create the processlist entry for the child process. Put the last
1599 * position in x at the current time value.
1601 * @param hook_data ControlFlowData structure of the viewer.
1602 * @param call_data Event context.
1604 * This function adds items to be drawn in a queue for each process.
1607 int after_process_exit_hook(void *hook_data
, void *call_data
)
1609 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1610 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1611 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1613 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1615 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1617 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1620 e
= ltt_tracefile_get_event(tfc
->tf
);
1622 LttvFilter
*filter
= control_flow_data
->filter
;
1623 if(filter
!= NULL
&& filter
->head
!= NULL
)
1624 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
1625 tfc
->t_context
->t
,tfc
))
1628 LttTime evtime
= ltt_event_time(e
);
1630 /* Add process to process list (if not present) */
1631 //LttvProcessState *process = tfs->process;
1632 guint cpu
= tfs
->cpu
;
1633 guint trace_num
= ts
->parent
.index
;
1634 LttvProcessState
*process
= ts
->running_process
[cpu
];
1636 /* It should exist, because we are after the state update. */
1637 g_assert(process
!= NULL
);
1639 guint pid
= process
->pid
;
1641 guint pl_height
= 0;
1642 HashedProcessData
*hashed_process_data
= NULL
;
1644 ProcessList
*process_list
= control_flow_data
->process_list
;
1646 birth
= process
->creation_time
;
1648 if(likely(process_list
->current_hash_data
[trace_num
][cpu
] != NULL
) ){
1649 hashed_process_data
= process_list
->current_hash_data
[trace_num
][cpu
];
1651 hashed_process_data
= processlist_get_process_data(process_list
,
1656 if(unlikely(hashed_process_data
== NULL
))
1658 g_assert(pid
== 0 || pid
!= process
->ppid
);
1659 /* Process not present */
1660 Drawing_t
*drawing
= control_flow_data
->drawing
;
1661 ProcessInfo
*process_info
;
1662 processlist_add(process_list
,
1674 &hashed_process_data
);
1675 gtk_widget_set_size_request(drawing
->drawing_area
,
1678 gtk_widget_queue_draw(drawing
->drawing_area
);
1681 /* Set the current process */
1682 process_list
->current_hash_data
[trace_num
][process
->cpu
] =
1683 hashed_process_data
;
1686 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
1689 TimeWindow time_window
=
1690 lttvwindow_get_time_window(control_flow_data
->tab
);
1693 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1694 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1696 #endif //EXTRA_CHECK
1697 Drawing_t
*drawing
= control_flow_data
->drawing
;
1698 guint width
= drawing
->width
;
1700 convert_time_to_pixels(
1705 if(unlikely(hashed_process_data
->x
.middle
!= new_x
)) {
1706 hashed_process_data
->x
.middle
= new_x
;
1707 hashed_process_data
->x
.middle_used
= FALSE
;
1708 hashed_process_data
->x
.middle_marked
= FALSE
;
1716 /* Get the filename of the process to print */
1717 int after_fs_exec_hook(void *hook_data
, void *call_data
)
1719 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1720 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1721 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1723 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1725 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1727 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1730 e
= ltt_tracefile_get_event(tfc
->tf
);
1732 LttvFilter
*filter
= control_flow_data
->filter
;
1733 if(filter
!= NULL
&& filter
->head
!= NULL
)
1734 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
1735 tfc
->t_context
->t
,tfc
))
1738 guint cpu
= tfs
->cpu
;
1739 guint trace_num
= ts
->parent
.index
;
1740 LttvProcessState
*process
= ts
->running_process
[cpu
];
1741 g_assert(process
!= NULL
);
1743 guint pid
= process
->pid
;
1745 /* Well, the process_out existed : we must get it in the process hash
1746 * or add it, and draw its items.
1748 /* Add process to process list (if not present) */
1749 guint pl_height
= 0;
1750 HashedProcessData
*hashed_process_data
= NULL
;
1751 ProcessList
*process_list
= control_flow_data
->process_list
;
1752 LttTime birth
= process
->creation_time
;
1754 if(likely(process_list
->current_hash_data
[trace_num
][cpu
] != NULL
)) {
1755 hashed_process_data
= process_list
->current_hash_data
[trace_num
][cpu
];
1757 hashed_process_data
= processlist_get_process_data(process_list
,
1762 if(unlikely(hashed_process_data
== NULL
))
1764 g_assert(pid
== 0 || pid
!= process
->ppid
);
1765 ProcessInfo
*process_info
;
1766 /* Process not present */
1767 Drawing_t
*drawing
= control_flow_data
->drawing
;
1768 processlist_add(process_list
,
1780 &hashed_process_data
);
1781 gtk_widget_set_size_request(drawing
->drawing_area
,
1784 gtk_widget_queue_draw(drawing
->drawing_area
);
1786 /* Set the current process */
1787 process_list
->current_hash_data
[trace_num
][process
->cpu
] =
1788 hashed_process_data
;
1791 processlist_set_name(process_list
, process
->name
, hashed_process_data
);
1797 /* Get the filename of the process to print */
1798 int after_user_generic_thread_brand_hook(void *hook_data
, void *call_data
)
1800 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1801 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1802 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1804 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1806 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1808 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1811 e
= ltt_tracefile_get_event(tfc
->tf
);
1813 LttvFilter
*filter
= control_flow_data
->filter
;
1814 if(filter
!= NULL
&& filter
->head
!= NULL
)
1815 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
1816 tfc
->t_context
->t
,tfc
))
1819 guint cpu
= tfs
->cpu
;
1820 guint trace_num
= ts
->parent
.index
;
1821 LttvProcessState
*process
= ts
->running_process
[cpu
];
1822 g_assert(process
!= NULL
);
1824 guint pid
= process
->pid
;
1826 /* Well, the process_out existed : we must get it in the process hash
1827 * or add it, and draw its items.
1829 /* Add process to process list (if not present) */
1830 guint pl_height
= 0;
1831 HashedProcessData
*hashed_process_data
= NULL
;
1832 ProcessList
*process_list
= control_flow_data
->process_list
;
1833 LttTime birth
= process
->creation_time
;
1835 if(likely(process_list
->current_hash_data
[trace_num
][cpu
] != NULL
)) {
1836 hashed_process_data
= process_list
->current_hash_data
[trace_num
][cpu
];
1838 hashed_process_data
= processlist_get_process_data(process_list
,
1843 if(unlikely(hashed_process_data
== NULL
))
1845 g_assert(pid
== 0 || pid
!= process
->ppid
);
1846 ProcessInfo
*process_info
;
1847 /* Process not present */
1848 Drawing_t
*drawing
= control_flow_data
->drawing
;
1849 processlist_add(process_list
,
1861 &hashed_process_data
);
1862 gtk_widget_set_size_request(drawing
->drawing_area
,
1865 gtk_widget_queue_draw(drawing
->drawing_area
);
1867 /* Set the current process */
1868 process_list
->current_hash_data
[trace_num
][process
->cpu
] =
1869 hashed_process_data
;
1872 processlist_set_brand(process_list
, process
->brand
, hashed_process_data
);
1879 /* after_event_enum_process_hook
1881 * Create the processlist entry for the child process. Put the last
1882 * position in x at the current time value.
1884 * @param hook_data ControlFlowData structure of the viewer.
1885 * @param call_data Event context.
1887 * This function adds items to be drawn in a queue for each process.
1890 int after_event_enum_process_hook(void *hook_data
, void *call_data
)
1892 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1893 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1894 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1896 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1898 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1900 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1903 e
= ltt_tracefile_get_event(tfc
->tf
);
1905 LttvFilter
*filter
= control_flow_data
->filter
;
1906 if(filter
!= NULL
&& filter
->head
!= NULL
)
1907 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
1908 tfc
->t_context
->t
,tfc
))
1911 LttTime evtime
= ltt_event_time(e
);
1913 /* Add process to process list (if not present) */
1914 LttvProcessState
*process_in
;
1916 guint pl_height
= 0;
1917 HashedProcessData
*hashed_process_data_in
= NULL
;
1919 ProcessList
*process_list
= control_flow_data
->process_list
;
1920 guint trace_num
= ts
->parent
.index
;
1924 pid_in
= ltt_event_get_long_unsigned(e
, thf
->f1
);
1928 /* Find process pid_in in the list... */
1929 process_in
= lttv_state_find_process(ts
, ANY_CPU
, pid_in
);
1930 //process_in = tfs->process;
1931 //guint cpu = tfs->cpu;
1932 //guint trace_num = ts->parent.index;
1933 //process_in = ts->running_process[cpu];
1934 /* It should exist, because we are after the state update. */
1936 //g_assert(process_in != NULL);
1937 #endif //EXTRA_CHECK
1938 birth
= process_in
->creation_time
;
1940 hashed_process_data_in
= processlist_get_process_data(process_list
,
1945 if(hashed_process_data_in
== NULL
)
1947 if(pid_in
!= 0 && pid_in
== process_in
->ppid
)
1948 g_critical("TEST %u , %u", pid_in
, process_in
->ppid
);
1949 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1950 ProcessInfo
*process_info
;
1951 Drawing_t
*drawing
= control_flow_data
->drawing
;
1952 /* Process not present */
1953 processlist_add(process_list
,
1965 &hashed_process_data_in
);
1966 gtk_widget_set_size_request(drawing
->drawing_area
,
1969 gtk_widget_queue_draw(drawing
->drawing_area
);
1971 processlist_set_name(process_list
, process_in
->name
,
1972 hashed_process_data_in
);
1973 processlist_set_ppid(process_list
, process_in
->ppid
,
1974 hashed_process_data_in
);
1975 processlist_set_tgid(process_list
, process_in
->tgid
,
1976 hashed_process_data_in
);
1982 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1984 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1985 Drawing_t
*drawing
= control_flow_data
->drawing
;
1986 ProcessList
*process_list
= control_flow_data
->process_list
;
1988 const TimeWindowNotifyData
*time_window_nofify_data
=
1989 ((const TimeWindowNotifyData
*)call_data
);
1991 TimeWindow
*old_time_window
=
1992 time_window_nofify_data
->old_time_window
;
1993 TimeWindow
*new_time_window
=
1994 time_window_nofify_data
->new_time_window
;
1996 /* Update the ruler */
1997 drawing_update_ruler(control_flow_data
->drawing
,
2001 /* Two cases : zoom in/out or scrolling */
2003 /* In order to make sure we can reuse the old drawing, the scale must
2004 * be the same and the new time interval being partly located in the
2005 * currently shown time interval. (reuse is only for scrolling)
2008 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
2009 old_time_window
->start_time
.tv_sec
,
2010 old_time_window
->start_time
.tv_nsec
,
2011 old_time_window
->time_width
.tv_sec
,
2012 old_time_window
->time_width
.tv_nsec
);
2014 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
2015 new_time_window
->start_time
.tv_sec
,
2016 new_time_window
->start_time
.tv_nsec
,
2017 new_time_window
->time_width
.tv_sec
,
2018 new_time_window
->time_width
.tv_nsec
);
2020 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2021 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2023 /* Same scale (scrolling) */
2024 g_info("scrolling");
2025 LttTime
*ns
= &new_time_window
->start_time
;
2026 LttTime
*nw
= &new_time_window
->time_width
;
2027 LttTime
*os
= &old_time_window
->start_time
;
2028 LttTime
*ow
= &old_time_window
->time_width
;
2029 LttTime old_end
= old_time_window
->end_time
;
2030 LttTime new_end
= new_time_window
->end_time
;
2032 //if(ns<os+w && os+w<ns+w)
2033 //if(ns<old_end && os<ns)
2034 if(ltt_time_compare(*ns
, old_end
) == -1
2035 && ltt_time_compare(*os
, *ns
) == -1)
2037 g_info("scrolling near right");
2038 /* Scroll right, keep right part of the screen */
2040 guint width
= control_flow_data
->drawing
->width
;
2041 convert_time_to_pixels(
2047 /* Copy old data to new location */
2048 copy_pixmap_region(process_list
,
2050 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2054 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2056 if(drawing
->damage_begin
== drawing
->damage_end
)
2057 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2059 drawing
->damage_begin
= 0;
2061 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2063 /* Clear the data request background, but not SAFETY */
2064 rectangle_pixmap(process_list
,
2065 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2067 drawing
->damage_begin
+SAFETY
, 0,
2068 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2070 gtk_widget_queue_draw(drawing
->drawing_area
);
2071 //gtk_widget_queue_draw_area (drawing->drawing_area,
2073 // control_flow_data->drawing->width,
2074 // control_flow_data->drawing->height);
2076 /* Get new data for the rest. */
2077 drawing_data_request(control_flow_data
->drawing
,
2078 drawing
->damage_begin
, 0,
2079 drawing
->damage_end
- drawing
->damage_begin
,
2080 control_flow_data
->drawing
->height
);
2083 //if(ns<os && os<ns+w)
2084 //if(ns<os && os<new_end)
2085 if(ltt_time_compare(*ns
,*os
) == -1
2086 && ltt_time_compare(*os
,new_end
) == -1)
2088 g_info("scrolling near left");
2089 /* Scroll left, keep left part of the screen */
2091 guint width
= control_flow_data
->drawing
->width
;
2092 convert_time_to_pixels(
2098 /* Copy old data to new location */
2099 copy_pixmap_region (process_list
,
2101 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2107 if(drawing
->damage_begin
== drawing
->damage_end
)
2108 drawing
->damage_end
= x
;
2110 drawing
->damage_end
=
2111 control_flow_data
->drawing
->width
;
2113 drawing
->damage_begin
= 0;
2115 rectangle_pixmap (process_list
,
2116 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2118 drawing
->damage_begin
, 0,
2119 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2122 gtk_widget_queue_draw(drawing
->drawing_area
);
2123 //gtk_widget_queue_draw_area (drawing->drawing_area,
2125 // control_flow_data->drawing->width,
2126 // control_flow_data->drawing->height);
2129 /* Get new data for the rest. */
2130 drawing_data_request(control_flow_data
->drawing
,
2131 drawing
->damage_begin
, 0,
2132 drawing
->damage_end
- drawing
->damage_begin
,
2133 control_flow_data
->drawing
->height
);
2136 if(ltt_time_compare(*ns
,*os
) == 0)
2138 g_info("not scrolling");
2140 g_info("scrolling far");
2141 /* Cannot reuse any part of the screen : far jump */
2144 rectangle_pixmap (process_list
,
2145 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2148 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2151 //gtk_widget_queue_draw_area (drawing->drawing_area,
2153 // control_flow_data->drawing->width,
2154 // control_flow_data->drawing->height);
2155 gtk_widget_queue_draw(drawing
->drawing_area
);
2157 drawing
->damage_begin
= 0;
2158 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2160 drawing_data_request(control_flow_data
->drawing
,
2162 control_flow_data
->drawing
->width
,
2163 control_flow_data
->drawing
->height
);
2169 /* Different scale (zoom) */
2172 rectangle_pixmap (process_list
,
2173 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2176 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2179 //gtk_widget_queue_draw_area (drawing->drawing_area,
2181 // control_flow_data->drawing->width,
2182 // control_flow_data->drawing->height);
2183 gtk_widget_queue_draw(drawing
->drawing_area
);
2185 drawing
->damage_begin
= 0;
2186 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2188 drawing_data_request(control_flow_data
->drawing
,
2190 control_flow_data
->drawing
->width
,
2191 control_flow_data
->drawing
->height
);
2194 /* Update directly when scrolling */
2195 gdk_window_process_updates(control_flow_data
->drawing
->drawing_area
->window
,
2201 gint
traceset_notify(void *hook_data
, void *call_data
)
2203 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2204 Drawing_t
*drawing
= control_flow_data
->drawing
;
2206 if(unlikely(drawing
->gc
== NULL
)) {
2209 if(drawing
->dotted_gc
== NULL
) {
2213 drawing_clear(control_flow_data
->drawing
);
2214 processlist_clear(control_flow_data
->process_list
);
2215 gtk_widget_set_size_request(
2216 control_flow_data
->drawing
->drawing_area
,
2217 -1, processlist_get_height(control_flow_data
->process_list
));
2218 redraw_notify(control_flow_data
, NULL
);
2220 request_background_data(control_flow_data
);
2225 gint
redraw_notify(void *hook_data
, void *call_data
)
2227 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2228 Drawing_t
*drawing
= control_flow_data
->drawing
;
2229 GtkWidget
*widget
= drawing
->drawing_area
;
2231 drawing
->damage_begin
= 0;
2232 drawing
->damage_end
= drawing
->width
;
2234 /* fun feature, to be separated someday... */
2235 drawing_clear(control_flow_data
->drawing
);
2236 processlist_clear(control_flow_data
->process_list
);
2237 gtk_widget_set_size_request(
2238 control_flow_data
->drawing
->drawing_area
,
2239 -1, processlist_get_height(control_flow_data
->process_list
));
2241 rectangle_pixmap (control_flow_data
->process_list
,
2242 widget
->style
->black_gc
,
2245 drawing
->alloc_width
,
2248 gtk_widget_queue_draw(drawing
->drawing_area
);
2250 if(drawing
->damage_begin
< drawing
->damage_end
)
2252 drawing_data_request(drawing
,
2253 drawing
->damage_begin
,
2255 drawing
->damage_end
-drawing
->damage_begin
,
2259 //gtk_widget_queue_draw_area(drawing->drawing_area,
2262 // drawing->height);
2268 gint
continue_notify(void *hook_data
, void *call_data
)
2270 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2271 Drawing_t
*drawing
= control_flow_data
->drawing
;
2273 //g_assert(widget->allocation.width == drawing->damage_end);
2275 if(drawing
->damage_begin
< drawing
->damage_end
)
2277 drawing_data_request(drawing
,
2278 drawing
->damage_begin
,
2280 drawing
->damage_end
-drawing
->damage_begin
,
2288 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2290 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2291 Drawing_t
*drawing
= control_flow_data
->drawing
;
2293 LttTime current_time
= *((LttTime
*)call_data
);
2295 TimeWindow time_window
=
2296 lttvwindow_get_time_window(control_flow_data
->tab
);
2298 LttTime time_begin
= time_window
.start_time
;
2299 LttTime width
= time_window
.time_width
;
2302 guint64 time_ll
= ltt_time_to_uint64(width
);
2303 time_ll
= time_ll
>> 1; /* divide by two */
2304 half_width
= ltt_time_from_uint64(time_ll
);
2306 LttTime time_end
= ltt_time_add(time_begin
, width
);
2308 LttvTracesetContext
* tsc
=
2309 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2311 LttTime trace_start
= tsc
->time_span
.start_time
;
2312 LttTime trace_end
= tsc
->time_span
.end_time
;
2314 g_info("New current time HOOK : %lu, %lu", current_time
.tv_sec
,
2315 current_time
.tv_nsec
);
2319 /* If current time is inside time interval, just move the highlight
2322 /* Else, we have to change the time interval. We have to tell it
2323 * to the main window. */
2324 /* The time interval change will take care of placing the current
2325 * time at the center of the visible area, or nearest possible if we are
2326 * at one end of the trace. */
2329 if(ltt_time_compare(current_time
, time_begin
) < 0)
2331 TimeWindow new_time_window
;
2333 if(ltt_time_compare(current_time
,
2334 ltt_time_add(trace_start
,half_width
)) < 0)
2335 time_begin
= trace_start
;
2337 time_begin
= ltt_time_sub(current_time
,half_width
);
2339 new_time_window
.start_time
= time_begin
;
2340 new_time_window
.time_width
= width
;
2341 new_time_window
.time_width_double
= ltt_time_to_double(width
);
2342 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2344 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2346 else if(ltt_time_compare(current_time
, time_end
) > 0)
2348 TimeWindow new_time_window
;
2350 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) > 0)
2351 time_begin
= ltt_time_sub(trace_end
,width
);
2353 time_begin
= ltt_time_sub(current_time
,half_width
);
2355 new_time_window
.start_time
= time_begin
;
2356 new_time_window
.time_width
= width
;
2357 new_time_window
.time_width_double
= ltt_time_to_double(width
);
2358 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2360 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2363 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
2365 /* Update directly when scrolling */
2366 gdk_window_process_updates(control_flow_data
->drawing
->drawing_area
->window
,
2372 typedef struct _ClosureData
{
2373 EventsRequest
*events_request
;
2374 LttvTracesetState
*tss
;
2380 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2382 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2383 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2384 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2386 EventsRequest
*events_request
= closure_data
->events_request
;
2387 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2389 LttvTracesetState
*tss
= closure_data
->tss
;
2390 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
2392 LttTime evtime
= closure_data
->end_time
;
2395 /* For the process */
2396 /* First, check if the current process is in the state computation
2397 * process list. If it is there, that means we must add it right now and
2398 * draw items from the beginning of the read for it. If it is not
2399 * present, it's a new process and it was not present : it will
2400 * be added after the state update. */
2402 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2403 #endif //EXTRA_CHECK
2404 LttvTraceContext
*tc
= tsc
->traces
[process_info
->trace_num
];
2405 LttvTraceState
*ts
= (LttvTraceState
*)tc
;
2408 //FIXME : optimize data structures.
2409 LttvTracefileState
*tfs
;
2410 LttvTracefileContext
*tfc
;
2412 for(i
=0;i
<tc
->tracefiles
->len
;i
++) {
2413 tfc
= g_array_index(tc
->tracefiles
, LttvTracefileContext
*, i
);
2414 if(ltt_tracefile_name(tfc
->tf
) == LTT_NAME_CPU
2415 && tfs
->cpu
== process_info
->cpu
)
2419 g_assert(i
<tc
->tracefiles
->len
);
2420 tfs
= LTTV_TRACEFILE_STATE(tfc
);
2422 // LttvTracefileState *tfs =
2423 // (LttvTracefileState*)tsc->traces[process_info->trace_num]->
2424 // tracefiles[process_info->cpu];
2426 LttvProcessState
*process
;
2427 process
= lttv_state_find_process(ts
, process_info
->cpu
,
2430 if(unlikely(process
!= NULL
)) {
2432 /* Only draw for processes that are currently in the trace states */
2434 ProcessList
*process_list
= control_flow_data
->process_list
;
2436 /* Should be alike when background info is ready */
2437 if(control_flow_data
->background_info_waiting
==0)
2438 g_assert(ltt_time_compare(process
->creation_time
,
2439 process_info
->birth
) == 0);
2440 #endif //EXTRA_CHECK
2442 /* Now, the process is in the state hash and our own process hash.
2443 * We definitely can draw the items related to the ending state.
2446 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2449 TimeWindow time_window
=
2450 lttvwindow_get_time_window(control_flow_data
->tab
);
2453 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2454 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2456 #endif //EXTRA_CHECK
2457 Drawing_t
*drawing
= control_flow_data
->drawing
;
2458 guint width
= drawing
->width
;
2460 guint x
= closure_data
->x_end
;
2462 DrawContext draw_context
;
2464 /* Now create the drawing context that will be used to draw
2465 * items related to the last state. */
2466 draw_context
.drawable
= hashed_process_data
->pixmap
;
2467 draw_context
.gc
= drawing
->gc
;
2468 draw_context
.pango_layout
= drawing
->pango_layout
;
2469 draw_context
.drawinfo
.end
.x
= x
;
2471 draw_context
.drawinfo
.y
.over
= 1;
2472 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2473 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2475 draw_context
.drawinfo
.start
.offset
.over
= 0;
2476 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2477 draw_context
.drawinfo
.start
.offset
.under
= 0;
2478 draw_context
.drawinfo
.end
.offset
.over
= 0;
2479 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2480 draw_context
.drawinfo
.end
.offset
.under
= 0;
2482 /* Jump over draw if we are at the same x position */
2483 if(x
== hashed_process_data
->x
.over
)
2487 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
2489 PropertiesLine prop_line
= prepare_execmode_line(process
);
2490 draw_line((void*)&prop_line
, (void*)&draw_context
);
2492 hashed_process_data
->x
.over
= x
;
2496 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2497 hashed_process_data
->x
.middle_used
)) {
2498 #if 0 /* do not mark closure : not missing information */
2499 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2500 /* Draw collision indicator */
2501 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2502 gdk_draw_point(drawing
->pixmap
,
2506 hashed_process_data
->x
.middle_marked
= TRUE
;
2511 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2513 PropertiesLine prop_line
= prepare_s_e_line(process
);
2514 draw_line((void*)&prop_line
, (void*)&draw_context
);
2516 /* become the last x position */
2517 if(likely(x
!= hashed_process_data
->x
.middle
)) {
2518 hashed_process_data
->x
.middle
= x
;
2519 /* but don't use the pixel */
2520 hashed_process_data
->x
.middle_used
= FALSE
;
2522 /* Calculate the next good time */
2523 convert_pixels_to_time(width
, x
+1, time_window
,
2524 &hashed_process_data
->next_good_time
);
2533 int before_chunk(void *hook_data
, void *call_data
)
2535 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2536 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2537 ControlFlowData
*cfd
= (ControlFlowData
*)events_request
->viewer_data
;
2539 /* Desactivate sort */
2540 gtk_tree_sortable_set_sort_column_id(
2541 GTK_TREE_SORTABLE(cfd
->process_list
->list_store
),
2543 GTK_SORT_ASCENDING
);
2545 drawing_chunk_begin(events_request
, tss
);
2550 int before_request(void *hook_data
, void *call_data
)
2552 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2553 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2555 drawing_data_request_begin(events_request
, tss
);
2562 * after request is necessary in addition of after chunk in order to draw
2563 * lines until the end of the screen. after chunk just draws lines until
2570 int after_request(void *hook_data
, void *call_data
)
2572 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2573 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2574 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2576 ProcessList
*process_list
= control_flow_data
->process_list
;
2577 LttTime end_time
= events_request
->end_time
;
2579 ClosureData closure_data
;
2580 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2581 closure_data
.tss
= tss
;
2582 closure_data
.end_time
= end_time
;
2584 TimeWindow time_window
=
2585 lttvwindow_get_time_window(control_flow_data
->tab
);
2586 guint width
= control_flow_data
->drawing
->width
;
2587 convert_time_to_pixels(
2591 &closure_data
.x_end
);
2594 /* Draw last items */
2595 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2596 (void*)&closure_data
);
2599 /* Request expose */
2600 drawing_request_expose(events_request
, tss
, end_time
);
2609 int after_chunk(void *hook_data
, void *call_data
)
2611 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2612 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2613 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2614 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
2615 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
2618 ProcessList
*process_list
= control_flow_data
->process_list
;
2620 LttvTraceset
*traceset
= tsc
->ts
;
2621 guint nb_trace
= lttv_traceset_number(traceset
);
2623 /* Only execute when called for the first trace's events request */
2624 if(!process_list
->current_hash_data
) return;
2626 for(i
= 0 ; i
< nb_trace
; i
++) {
2627 g_free(process_list
->current_hash_data
[i
]);
2629 g_free(process_list
->current_hash_data
);
2630 process_list
->current_hash_data
= NULL
;
2633 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
2634 else /* end of traceset, or position now out of request : end */
2635 end_time
= events_request
->end_time
;
2637 ClosureData closure_data
;
2638 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2639 closure_data
.tss
= tss
;
2640 closure_data
.end_time
= end_time
;
2642 TimeWindow time_window
=
2643 lttvwindow_get_time_window(control_flow_data
->tab
);
2644 guint width
= control_flow_data
->drawing
->width
;
2645 convert_time_to_pixels(
2649 &closure_data
.x_end
);
2651 /* Draw last items */
2652 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2653 (void*)&closure_data
);
2655 /* Reactivate sort */
2656 gtk_tree_sortable_set_sort_column_id(
2657 GTK_TREE_SORTABLE(control_flow_data
->process_list
->list_store
),
2658 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
2659 GTK_SORT_ASCENDING
);
2661 update_index_to_pixmap(control_flow_data
->process_list
);
2662 /* Request a full expose : drawing scrambled */
2663 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
2665 /* Request expose (updates damages zone also) */
2666 drawing_request_expose(events_request
, tss
, end_time
);