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>
64 #include <ltt/trace.h>
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>
74 #include "eventhooks.h"
76 #include "processlist.h"
80 #define MAX_PATH_LEN 256
81 #define STATE_LINE_WIDTH 4
82 #define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3)
84 extern GSList
*g_legend_list
;
87 /* Action to do when background computation completed.
89 * Wait for all the awaited computations to be over.
92 static gint
background_ready(void *hook_data
, void *call_data
)
94 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
95 LttvTrace
*trace
= (LttvTrace
*)call_data
;
97 control_flow_data
->background_info_waiting
--;
99 if(control_flow_data
->background_info_waiting
== 0) {
100 g_message("control flow viewer : background computation data ready.");
102 drawing_clear(control_flow_data
->drawing
);
103 processlist_clear(control_flow_data
->process_list
);
104 gtk_widget_set_size_request(
105 control_flow_data
->drawing
->drawing_area
,
106 -1, processlist_get_height(control_flow_data
->process_list
));
107 redraw_notify(control_flow_data
, NULL
);
114 /* Request background computation. Verify if it is in progress or ready first.
115 * Only for each trace in the tab's traceset.
117 static void request_background_data(ControlFlowData
*control_flow_data
)
119 LttvTracesetContext
* tsc
=
120 lttvwindow_get_traceset_context(control_flow_data
->tab
);
121 gint num_traces
= lttv_traceset_number(tsc
->ts
);
124 LttvTraceState
*tstate
;
126 LttvHooks
*background_ready_hook
=
128 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
130 control_flow_data
->background_info_waiting
= 0;
132 for(i
=0;i
<num_traces
;i
++) {
133 trace
= lttv_traceset_get(tsc
->ts
, i
);
134 tstate
= LTTV_TRACE_STATE(tsc
->traces
[i
]);
136 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
137 && !tstate
->has_precomputed_states
) {
139 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
141 /* We first remove requests that could have been done for the same
142 * information. Happens when two viewers ask for it before servicing
145 if(!lttvwindowtraces_background_request_find(trace
, "state"))
146 lttvwindowtraces_background_request_queue(
147 main_window_get_widget(control_flow_data
->tab
), trace
, "state");
148 lttvwindowtraces_background_notify_queue(control_flow_data
,
152 background_ready_hook
);
153 control_flow_data
->background_info_waiting
++;
154 } else { /* in progress */
156 lttvwindowtraces_background_notify_current(control_flow_data
,
160 background_ready_hook
);
161 control_flow_data
->background_info_waiting
++;
164 /* Data ready. By its nature, this viewer doesn't need to have
165 * its data ready hook called there, because a background
166 * request is always linked with a redraw.
172 lttv_hooks_destroy(background_ready_hook
);
179 * Event Viewer's constructor hook
181 * This constructor is given as a parameter to the menuitem and toolbar button
182 * registration. It creates the list.
183 * @param tab A pointer to the parent tab.
184 * @return The widget created.
187 h_resourceview(LttvPlugin
*plugin
)
189 LttvPluginTab
*ptab
= LTTV_PLUGIN_TAB(plugin
);
190 Tab
*tab
= ptab
->tab
;
191 g_info("h_guicontrolflow, %p", tab
);
192 ControlFlowData
*control_flow_data
= resourceview(ptab
);
194 control_flow_data
->tab
= tab
;
196 // Unreg done in the GuiControlFlow_Destructor
197 lttvwindow_register_traceset_notify(tab
,
201 lttvwindow_register_time_window_notify(tab
,
202 update_time_window_hook
,
204 lttvwindow_register_current_time_notify(tab
,
205 update_current_time_hook
,
207 lttvwindow_register_redraw_notify(tab
,
210 lttvwindow_register_continue_notify(tab
,
213 request_background_data(control_flow_data
);
216 return guicontrolflow_get_widget(control_flow_data
) ;
220 void legend_destructor(GtkWindow
*legend
)
222 g_legend_list
= g_slist_remove(g_legend_list
, legend
);
225 /* Create a popup legend */
227 h_legend(LttvPlugin
*plugin
)
229 LttvPluginTab
*ptab
= LTTV_PLUGIN_TAB(plugin
);
230 Tab
*tab
= ptab
->tab
;
231 g_info("h_legend, %p", tab
);
233 GtkWindow
*legend
= GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL
));
235 g_legend_list
= g_slist_append(
239 g_object_set_data_full(
243 (GDestroyNotify
)legend_destructor
);
245 gtk_window_set_title(legend
, "Control Flow View Legend");
247 GtkWidget
*pixmap
= create_pixmap(GTK_WIDGET(legend
), "lttv-color-list.png");
249 // GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixmap(
250 // GDK_PIXMAP(pixmap), NULL));
252 gtk_container_add(GTK_CONTAINER(legend
), GTK_WIDGET(pixmap
));
254 gtk_widget_show(GTK_WIDGET(pixmap
));
255 gtk_widget_show(GTK_WIDGET(legend
));
258 return NULL
; /* This is a popup window */
262 int event_selected_hook(void *hook_data
, void *call_data
)
264 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
265 guint
*event_number
= (guint
*) call_data
;
267 g_debug("DEBUG : event selected by main window : %u", *event_number
);
272 /* Function that selects the color of status&exemode line */
273 static inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
275 PropertiesLine prop_line
;
276 prop_line
.line_width
= STATE_LINE_WIDTH
;
277 prop_line
.style
= GDK_LINE_SOLID
;
278 prop_line
.y
= MIDDLE
;
280 if(process
->state
->s
== LTTV_STATE_RUN
) {
281 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
282 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
283 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
284 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
285 else if(process
->state
->t
== LTTV_STATE_TRAP
)
286 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
287 else if(process
->state
->t
== LTTV_STATE_IRQ
)
288 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
289 else if(process
->state
->t
== LTTV_STATE_SOFT_IRQ
)
290 prop_line
.color
= drawing_colors
[COL_RUN_SOFT_IRQ
];
291 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
292 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
294 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
295 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
296 /* We don't show if we wait while in user mode, trap, irq or syscall */
297 prop_line
.color
= drawing_colors
[COL_WAIT
];
298 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
299 /* We don't show if we wait for CPU while in user mode, trap, irq
301 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
302 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
303 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
304 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
305 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
306 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
307 prop_line
.color
= drawing_colors
[COL_EXIT
];
308 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
309 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
311 g_critical("unknown state : %s", g_quark_to_string(process
->state
->s
));
312 g_assert(FALSE
); /* UNKNOWN STATE */
319 static void cpu_set_line_color(PropertiesLine
*prop_line
, LttvCPUState
*s
)
321 GQuark present_state
;
323 if(s
->mode_stack
->len
== 0)
324 present_state
= LTTV_CPU_UNKNOWN
;
326 present_state
= ((GQuark
*)s
->mode_stack
->data
)[s
->mode_stack
->len
-1];
328 if(present_state
== LTTV_CPU_IDLE
) {
329 prop_line
->color
= drawing_colors_cpu
[COL_CPU_IDLE
];
331 else if(present_state
== LTTV_CPU_BUSY
) {
332 prop_line
->color
= drawing_colors_cpu
[COL_CPU_BUSY
];
334 else if(present_state
== LTTV_CPU_IRQ
) {
335 prop_line
->color
= drawing_colors_cpu
[COL_CPU_IRQ
];
337 else if(present_state
== LTTV_CPU_TRAP
) {
338 prop_line
->color
= drawing_colors_cpu
[COL_CPU_TRAP
];
340 prop_line
->color
= drawing_colors_cpu
[COL_CPU_UNKNOWN
];
344 static void irq_set_line_color(PropertiesLine
*prop_line
, LttvIRQState
*s
)
346 GQuark present_state
;
347 if(s
->mode_stack
->len
== 0)
348 present_state
= LTTV_IRQ_UNKNOWN
;
350 present_state
= ((GQuark
*)s
->mode_stack
->data
)[s
->mode_stack
->len
-1];
352 if(present_state
== LTTV_IRQ_IDLE
) {
353 prop_line
->color
= drawing_colors_irq
[COL_IRQ_IDLE
];
355 else if(present_state
== LTTV_IRQ_BUSY
) {
356 prop_line
->color
= drawing_colors_irq
[COL_IRQ_BUSY
];
359 prop_line
->color
= drawing_colors_irq
[COL_IRQ_UNKNOWN
];
363 static void bdev_set_line_color(PropertiesLine
*prop_line
, LttvBdevState
*s
)
365 GQuark present_state
;
366 if(s
== 0 || s
->mode_stack
->len
== 0)
367 present_state
= LTTV_BDEV_UNKNOWN
;
369 present_state
= ((GQuark
*)s
->mode_stack
->data
)[s
->mode_stack
->len
-1];
371 if(present_state
== LTTV_BDEV_IDLE
) {
372 prop_line
->color
= drawing_colors_bdev
[COL_BDEV_IDLE
];
374 else if(present_state
== LTTV_BDEV_BUSY_READING
) {
375 prop_line
->color
= drawing_colors_bdev
[COL_BDEV_BUSY_READING
];
377 else if(present_state
== LTTV_BDEV_BUSY_WRITING
) {
378 prop_line
->color
= drawing_colors_bdev
[COL_BDEV_BUSY_WRITING
];
381 prop_line
->color
= drawing_colors_bdev
[COL_BDEV_UNKNOWN
];
385 /* before_schedchange_hook
387 * This function basically draw lines and icons. Two types of lines are drawn :
388 * one small (3 pixels?) representing the state of the process and the second
389 * type is thicker (10 pixels?) representing on which CPU a process is running
390 * (and this only in running state).
392 * Extremums of the lines :
393 * x_min : time of the last event context for this process kept in memory.
394 * x_max : time of the current event.
395 * y : middle of the process in the process list. The process is found in the
396 * list, therefore is it's position in pixels.
398 * The choice of lines'color is defined by the context of the last event for this
403 int before_schedchange_hook(void *hook_data
, void *call_data
)
405 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
406 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
407 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
409 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
411 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
412 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
415 e
= ltt_tracefile_get_event(tfc
->tf
);
416 gint target_pid_saved
= tfc
->target_pid
;
418 LttTime evtime
= ltt_event_time(e
);
419 LttvFilter
*filter
= control_flow_data
->filter
;
423 /* we are in a schedchange, before the state update. We must draw the
424 * items corresponding to the state before it changes : now is the right
430 pid_out
= ltt_event_get_long_unsigned(e
, th
->f1
);
431 pid_in
= ltt_event_get_long_unsigned(e
, th
->f2
);
432 // if(pid_in != 0 && pid_out != 0) {
433 // /* not a transition to/from idle */
437 tfc
->target_pid
= pid_out
;
438 // if(!filter || !filter->head ||
439 // lttv_filter_tree_parse(filter->head,e,tfc->tf,
440 // tfc->t_context->t,tfc,NULL,NULL)) {
441 /* For the pid_out */
442 /* First, check if the current process is in the state computation
443 * process list. If it is there, that means we must add it right now and
444 * draw items from the beginning of the read for it. If it is not
445 * present, it's a new process and it was not present : it will
446 * be added after the state update. */
447 guint cpu
= tfs
->cpu
;
450 cpustr
= g_strdup_printf("CPU%u", cpu
);
451 cpuq
= g_quark_from_string(cpustr
);
455 guint trace_num
= ts
->parent
.index
;
456 // LttvProcessState *process = ts->running_process[cpu];
457 /* unknown state, bad current pid */
458 // if(process->pid != pid_out)
459 // process = lttv_state_find_process(ts,
460 // tfs->cpu, pid_out);
462 // if(process != NULL) {
463 /* Well, the process_out existed : we must get it in the process hash
464 * or add it, and draw its items.
466 /* Add process to process list (if not present) */
468 HashedResourceData
*hashed_process_data
= NULL
;
469 ProcessList
*process_list
= control_flow_data
->process_list
;
470 // LttTime birth = process->creation_time;
472 hashed_process_data
= processlist_get_process_data(process_list
, cpuq
, trace_num
);
473 // hashed_process_data = processlist_get_process_data(process_list,
478 if(hashed_process_data
== NULL
)
480 // g_assert(pid_out == 0 || pid_out != process->ppid);
481 /* Process not present */
482 ResourceInfo
*process_info
;
483 Drawing_t
*drawing
= control_flow_data
->drawing
;
484 resourcelist_add(process_list
,
487 cpuq
, //process->name,
492 &hashed_process_data
);
493 gtk_widget_set_size_request(drawing
->drawing_area
,
496 gtk_widget_queue_draw(drawing
->drawing_area
);
500 /* Now, the process is in the state hash and our own process hash.
501 * We definitely can draw the items related to the ending state.
504 if(ltt_time_compare(hashed_process_data
->next_good_time
,
507 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
509 TimeWindow time_window
=
510 lttvwindow_get_time_window(control_flow_data
->tab
);
512 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
513 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
516 Drawing_t
*drawing
= control_flow_data
->drawing
;
517 guint width
= drawing
->width
;
519 convert_time_to_pixels(
525 /* Draw collision indicator */
526 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
527 gdk_draw_point(hashed_process_data
->pixmap
,
530 COLLISION_POSITION(hashed_process_data
->height
));
531 hashed_process_data
->x
.middle_marked
= TRUE
;
534 TimeWindow time_window
=
535 lttvwindow_get_time_window(control_flow_data
->tab
);
537 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
538 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
541 Drawing_t
*drawing
= control_flow_data
->drawing
;
542 guint width
= drawing
->width
;
544 convert_time_to_pixels(
550 /* Jump over draw if we are at the same x position */
551 if(x
== hashed_process_data
->x
.middle
&&
552 hashed_process_data
->x
.middle_used
)
554 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
555 /* Draw collision indicator */
556 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
557 gdk_draw_point(hashed_process_data
->pixmap
,
560 COLLISION_POSITION(hashed_process_data
->height
));
561 hashed_process_data
->x
.middle_marked
= TRUE
;
565 DrawContext draw_context
;
567 /* Now create the drawing context that will be used to draw
568 * items related to the last state. */
569 draw_context
.drawable
= hashed_process_data
->pixmap
;
570 draw_context
.gc
= drawing
->gc
;
571 draw_context
.pango_layout
= drawing
->pango_layout
;
572 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
573 draw_context
.drawinfo
.end
.x
= x
;
575 draw_context
.drawinfo
.y
.over
= 1;
576 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
577 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
579 draw_context
.drawinfo
.start
.offset
.over
= 0;
580 draw_context
.drawinfo
.start
.offset
.middle
= 0;
581 draw_context
.drawinfo
.start
.offset
.under
= 0;
582 draw_context
.drawinfo
.end
.offset
.over
= 0;
583 draw_context
.drawinfo
.end
.offset
.middle
= 0;
584 draw_context
.drawinfo
.end
.offset
.under
= 0;
588 //PropertiesLine prop_line = prepare_s_e_line(process);
589 PropertiesLine prop_line
;
590 prop_line
.line_width
= STATE_LINE_WIDTH
;
591 prop_line
.style
= GDK_LINE_SOLID
;
592 prop_line
.y
= MIDDLE
;
593 cpu_set_line_color(&prop_line
, tfs
->cpu_state
);
594 draw_line((void*)&prop_line
, (void*)&draw_context
);
597 /* become the last x position */
598 hashed_process_data
->x
.middle
= x
;
599 hashed_process_data
->x
.middle_used
= TRUE
;
600 hashed_process_data
->x
.middle_marked
= FALSE
;
602 /* Calculate the next good time */
603 convert_pixels_to_time(width
, x
+1, time_window
,
604 &hashed_process_data
->next_good_time
);
610 // tfc->target_pid = pid_in;
611 // if(!filter || !filter->head ||
612 // lttv_filter_tree_parse(filter->head,e,tfc->tf,
613 // tfc->t_context->t,tfc,NULL,NULL)) {
614 // /* For the pid_in */
615 // /* First, check if the current process is in the state computation
616 // * process list. If it is there, that means we must add it right now and
617 // * draw items from the beginning of the read for it. If it is not
618 // * present, it's a new process and it was not present : it will
619 // * be added after the state update. */
620 // LttvProcessState *process;
621 // process = lttv_state_find_process(ts,
622 // tfs->cpu, pid_in);
623 // guint trace_num = ts->parent.index;
625 // if(process != NULL) {
626 // /* Well, the process existed : we must get it in the process hash
627 // * or add it, and draw its items.
629 // /* Add process to process list (if not present) */
630 // guint pl_height = 0;
631 // HashedResourceData *hashed_process_data = NULL;
632 // ProcessList *process_list = control_flow_data->process_list;
633 // LttTime birth = process->creation_time;
635 // hashed_process_data = processlist_get_process_data(process_list, cpuq);
636 //// hashed_process_data = processlist_get_process_data(process_list,
641 // if(hashed_process_data == NULL)
643 // g_assert(pid_in == 0 || pid_in != process->ppid);
644 // /* Process not present */
645 // ResourceInfo *process_info;
646 // Drawing_t *drawing = control_flow_data->drawing;
647 // resourcelist_add(process_list,
659 // &hashed_process_data);
660 // gtk_widget_set_size_request(drawing->drawing_area,
663 // gtk_widget_queue_draw(drawing->drawing_area);
666 // //We could set the current process and hash here, but will be done
667 // //by after schedchange hook
669 // /* Now, the process is in the state hash and our own process hash.
670 // * We definitely can draw the items related to the ending state.
673 // if(ltt_time_compare(hashed_process_data->next_good_time,
676 // if(hashed_process_data->x.middle_marked == FALSE) {
678 // TimeWindow time_window =
679 // lttvwindow_get_time_window(control_flow_data->tab);
681 // if(ltt_time_compare(evtime, time_window.start_time) == -1
682 // || ltt_time_compare(evtime, time_window.end_time) == 1)
684 //#endif //EXTRA_CHECK
685 // Drawing_t *drawing = control_flow_data->drawing;
686 // guint width = drawing->width;
688 // convert_time_to_pixels(
694 // /* Draw collision indicator */
695 // gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
696 // gdk_draw_point(hashed_process_data->pixmap,
699 // COLLISION_POSITION(hashed_process_data->height));
700 // hashed_process_data->x.middle_marked = TRUE;
703 // TimeWindow time_window =
704 // lttvwindow_get_time_window(control_flow_data->tab);
706 // if(ltt_time_compare(evtime, time_window.start_time) == -1
707 // || ltt_time_compare(evtime, time_window.end_time) == 1)
709 //#endif //EXTRA_CHECK
710 // Drawing_t *drawing = control_flow_data->drawing;
711 // guint width = drawing->width;
714 // convert_time_to_pixels(
721 // /* Jump over draw if we are at the same x position */
722 // if(x == hashed_process_data->x.middle &&
723 // hashed_process_data->x.middle_used)
725 // if(hashed_process_data->x.middle_marked == FALSE) {
726 // /* Draw collision indicator */
727 // gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
728 // gdk_draw_point(hashed_process_data->pixmap,
731 // COLLISION_POSITION(hashed_process_data->height));
732 // hashed_process_data->x.middle_marked = TRUE;
736 // DrawContext draw_context;
738 // /* Now create the drawing context that will be used to draw
739 // * items related to the last state. */
740 // draw_context.drawable = hashed_process_data->pixmap;
741 // draw_context.gc = drawing->gc;
742 // draw_context.pango_layout = drawing->pango_layout;
743 // draw_context.drawinfo.start.x = hashed_process_data->x.middle;
744 // draw_context.drawinfo.end.x = x;
746 // draw_context.drawinfo.y.over = 1;
747 // draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
748 // draw_context.drawinfo.y.under = hashed_process_data->height;
750 // draw_context.drawinfo.start.offset.over = 0;
751 // draw_context.drawinfo.start.offset.middle = 0;
752 // draw_context.drawinfo.start.offset.under = 0;
753 // draw_context.drawinfo.end.offset.over = 0;
754 // draw_context.drawinfo.end.offset.middle = 0;
755 // draw_context.drawinfo.end.offset.under = 0;
758 // /* Draw the line */
759 // PropertiesLine prop_line = prepare_s_e_line(process);
760 // draw_line((void*)&prop_line, (void*)&draw_context);
764 // /* become the last x position */
765 // hashed_process_data->x.middle = x;
766 // hashed_process_data->x.middle_used = TRUE;
767 // hashed_process_data->x.middle_marked = FALSE;
769 // /* Calculate the next good time */
770 // convert_pixels_to_time(width, x+1, time_window,
771 // &hashed_process_data->next_good_time);
775 // g_warning("Cannot find pin_in in schedchange %u", pid_in);
777 // tfc->target_pid = target_pid_saved;
785 GString
*string
= g_string_new("");;
786 gboolean field_names
= TRUE
, state
= TRUE
;
788 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
789 g_string_append_printf(string
,"\n");
792 g_string_append_printf(string
, " %s",
793 g_quark_to_string(tfs
->process
->state
->s
));
796 g_info("%s",string
->str
);
798 g_string_free(string
, TRUE
);
800 /* End of text dump */
805 /* after_schedchange_hook
807 * The draw after hook is called by the reading API to have a
808 * particular event drawn on the screen.
809 * @param hook_data ControlFlowData structure of the viewer.
810 * @param call_data Event context.
812 * This function adds items to be drawn in a queue for each process.
815 int after_schedchange_hook(void *hook_data
, void *call_data
)
817 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
818 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
819 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
821 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
823 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
825 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
828 e
= ltt_tracefile_get_event(tfc
->tf
);
830 LttvFilter
*filter
= control_flow_data
->filter
;
831 if(filter
!= NULL
&& filter
->head
!= NULL
)
832 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
833 tfc
->t_context
->t
,tfc
,NULL
,NULL
))
836 LttTime evtime
= ltt_event_time(e
);
840 /* Add process to process list (if not present) */
841 LttvProcessState
*process_in
;
844 HashedResourceData
*hashed_process_data_in
= NULL
;
846 ProcessList
*process_list
= control_flow_data
->process_list
;
851 pid_out
= ltt_event_get_long_unsigned(e
, th
->f1
);
852 pid_in
= ltt_event_get_long_unsigned(e
, th
->f2
);
856 /* Find process pid_in in the list... */
857 //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
858 //process_in = tfs->process;
859 guint cpu
= tfs
->cpu
;
862 cpustr
= g_strdup_printf("CPU%u", cpu
);
863 cpuq
= g_quark_from_string(cpustr
);
866 guint trace_num
= ts
->parent
.index
;
867 process_in
= ts
->running_process
[cpu
];
868 /* It should exist, because we are after the state update. */
870 g_assert(process_in
!= NULL
);
872 birth
= process_in
->creation_time
;
874 hashed_process_data_in
= processlist_get_process_data(process_list
, cpuq
, trace_num
);
875 // hashed_process_data_in = processlist_get_process_data(process_list,
880 if(hashed_process_data_in
== NULL
)
882 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
883 ResourceInfo
*process_info
;
884 Drawing_t
*drawing
= control_flow_data
->drawing
;
885 /* Process not present */
886 resourcelist_add(process_list
,
894 &hashed_process_data_in
);
895 gtk_widget_set_size_request(drawing
->drawing_area
,
898 gtk_widget_queue_draw(drawing
->drawing_area
);
900 /* Set the current process */
901 process_list
->current_hash_data
[trace_num
][process_in
->cpu
] =
902 hashed_process_data_in
;
904 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
907 TimeWindow time_window
=
908 lttvwindow_get_time_window(control_flow_data
->tab
);
911 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
912 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
915 Drawing_t
*drawing
= control_flow_data
->drawing
;
916 guint width
= drawing
->width
;
919 convert_time_to_pixels(
925 if(hashed_process_data_in
->x
.middle
!= new_x
) {
926 hashed_process_data_in
->x
.middle
= new_x
;
927 hashed_process_data_in
->x
.middle_used
= FALSE
;
928 hashed_process_data_in
->x
.middle_marked
= FALSE
;
934 /* before_execmode_hook
936 * This function basically draw lines and icons. Two types of lines are drawn :
937 * one small (3 pixels?) representing the state of the process and the second
938 * type is thicker (10 pixels?) representing on which CPU a process is running
939 * (and this only in running state).
941 * Extremums of the lines :
942 * x_min : time of the last event context for this process kept in memory.
943 * x_max : time of the current event.
944 * y : middle of the process in the process list. The process is found in the
945 * list, therefore is it's position in pixels.
947 * The choice of lines'color is defined by the context of the last event for this
951 int before_execmode_hook(void *hook_data
, void *call_data
)
953 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
954 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
955 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
957 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
959 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
960 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
963 e
= ltt_tracefile_get_event(tfc
->tf
);
965 LttTime evtime
= ltt_event_time(e
);
969 before_execmode_hook_irq(hook_data
, call_data
);
971 /* we are in a execmode, before the state update. We must draw the
972 * items corresponding to the state before it changes : now is the right
976 //LttvProcessState *process = tfs->process;
977 guint cpu
= tfs
->cpu
;
980 cpustr
= g_strdup_printf("CPU%u", cpu
);
981 cpuq
= g_quark_from_string(cpustr
);
984 guint trace_num
= ts
->parent
.index
;
985 LttvProcessState
*process
= ts
->running_process
[cpu
];
986 g_assert(process
!= NULL
);
988 // guint pid = process->pid;
990 /* Well, the process_out existed : we must get it in the process hash
991 * or add it, and draw its items.
993 /* Add process to process list (if not present) */
995 HashedResourceData
*hashed_process_data
= NULL
;
996 ProcessList
*process_list
= control_flow_data
->process_list
;
997 LttTime birth
= process
->creation_time
;
999 if(likely(process_list
->current_hash_data
[trace_num
][cpu
] != NULL
)) {
1000 hashed_process_data
= process_list
->current_hash_data
[trace_num
][cpu
];
1002 hashed_process_data
= processlist_get_process_data(process_list
, cpuq
, trace_num
);
1003 // hashed_process_data = processlist_get_process_data(process_list,
1008 if(unlikely(hashed_process_data
== NULL
))
1010 //g_assert(pid == 0 || pid != process->ppid);
1011 ResourceInfo
*process_info
;
1012 /* Process not present */
1013 Drawing_t
*drawing
= control_flow_data
->drawing
;
1014 resourcelist_add(process_list
,
1017 cpuq
, //process->name,
1022 &hashed_process_data
);
1023 gtk_widget_set_size_request(drawing
->drawing_area
,
1026 gtk_widget_queue_draw(drawing
->drawing_area
);
1028 /* Set the current process */
1029 process_list
->current_hash_data
[trace_num
][process
->cpu
] =
1030 hashed_process_data
;
1033 /* Now, the process is in the state hash and our own process hash.
1034 * We definitely can draw the items related to the ending state.
1037 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1040 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1041 TimeWindow time_window
=
1042 lttvwindow_get_time_window(control_flow_data
->tab
);
1045 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1046 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1048 #endif //EXTRA_CHECK
1049 Drawing_t
*drawing
= control_flow_data
->drawing
;
1050 guint width
= drawing
->width
;
1052 convert_time_to_pixels(
1058 /* Draw collision indicator */
1059 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1060 gdk_draw_point(hashed_process_data
->pixmap
,
1063 COLLISION_POSITION(hashed_process_data
->height
));
1064 hashed_process_data
->x
.middle_marked
= TRUE
;
1068 TimeWindow time_window
=
1069 lttvwindow_get_time_window(control_flow_data
->tab
);
1072 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1073 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1075 #endif //EXTRA_CHECK
1076 Drawing_t
*drawing
= control_flow_data
->drawing
;
1077 guint width
= drawing
->width
;
1080 convert_time_to_pixels(
1087 /* Jump over draw if we are at the same x position */
1088 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1089 hashed_process_data
->x
.middle_used
))
1091 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1092 /* Draw collision indicator */
1093 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1094 gdk_draw_point(hashed_process_data
->pixmap
,
1097 COLLISION_POSITION(hashed_process_data
->height
));
1098 hashed_process_data
->x
.middle_marked
= TRUE
;
1104 DrawContext draw_context
;
1105 /* Now create the drawing context that will be used to draw
1106 * items related to the last state. */
1107 draw_context
.drawable
= hashed_process_data
->pixmap
;
1108 draw_context
.gc
= drawing
->gc
;
1109 draw_context
.pango_layout
= drawing
->pango_layout
;
1110 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1111 draw_context
.drawinfo
.end
.x
= x
;
1113 draw_context
.drawinfo
.y
.over
= 1;
1114 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1115 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1117 draw_context
.drawinfo
.start
.offset
.over
= 0;
1118 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1119 draw_context
.drawinfo
.start
.offset
.under
= 0;
1120 draw_context
.drawinfo
.end
.offset
.over
= 0;
1121 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1122 draw_context
.drawinfo
.end
.offset
.under
= 0;
1126 PropertiesLine prop_line
;
1127 prop_line
.line_width
= STATE_LINE_WIDTH
;
1128 prop_line
.style
= GDK_LINE_SOLID
;
1129 prop_line
.y
= MIDDLE
;
1130 cpu_set_line_color(&prop_line
, tfs
->cpu_state
);
1131 draw_line((void*)&prop_line
, (void*)&draw_context
);
1133 /* become the last x position */
1134 hashed_process_data
->x
.middle
= x
;
1135 hashed_process_data
->x
.middle_used
= TRUE
;
1136 hashed_process_data
->x
.middle_marked
= FALSE
;
1138 /* Calculate the next good time */
1139 convert_pixels_to_time(width
, x
+1, time_window
,
1140 &hashed_process_data
->next_good_time
);
1147 int before_execmode_hook_irq(void *hook_data
, void *call_data
)
1149 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
1150 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
1151 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1153 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1155 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1156 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1159 e
= ltt_tracefile_get_event(tfc
->tf
);
1161 LttTime evtime
= ltt_event_time(e
);
1165 /* we are in a execmode, before the state update. We must draw the
1166 * items corresponding to the state before it changes : now is the right
1172 guint cpu
= tfs
->cpu
;
1174 LttFacility
*ev_facility
= ltt_event_facility(e
);
1175 if(ltt_facility_name(ev_facility
) != LTT_FACILITY_KERNEL
)
1177 guint8 ev_id_entry
= ltt_eventtype_id(ltt_facility_eventtype_get_by_name(ev_facility
, LTT_EVENT_IRQ_ENTRY
));
1178 guint8 ev_id_exit
= ltt_eventtype_id(ltt_facility_eventtype_get_by_name(ev_facility
, LTT_EVENT_IRQ_EXIT
));
1179 if(ltt_facility_name(ev_facility
) == LTT_FACILITY_KERNEL
&&
1180 ev_id_entry
== ltt_event_eventtype_id(e
)) {
1181 irq
= ltt_event_get_long_unsigned(e
, th
->f1
);
1183 else if(ltt_facility_name(ev_facility
) == LTT_FACILITY_KERNEL
&&
1184 ev_id_exit
== ltt_event_eventtype_id(e
)) {
1185 irq
= ts
->cpu_states
[cpu
].last_irq
;
1193 irqstr
= g_strdup_printf("IRQ %llu [%s]", irq
, g_quark_to_string(ts
->irq_names
[irq
]));
1194 resourceq
= g_quark_from_string(irqstr
);
1197 guint trace_num
= ts
->parent
.index
;
1199 // guint pid = process->pid;
1201 /* Well, the process_out existed : we must get it in the process hash
1202 * or add it, and draw its items.
1204 /* Add process to process list (if not present) */
1205 guint pl_height
= 0;
1206 HashedResourceData
*hashed_process_data
= NULL
;
1207 ProcessList
*process_list
= control_flow_data
->process_list
;
1208 // LttTime birth = process->creation_time;
1210 // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1211 // hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1213 hashed_process_data
= processlist_get_process_data(process_list
, resourceq
, trace_num
);
1214 // hashed_process_data = processlist_get_process_data(process_list,
1219 if(unlikely(hashed_process_data
== NULL
))
1221 //g_assert(pid == 0 || pid != process->ppid);
1222 ResourceInfo
*process_info
;
1223 /* Process not present */
1224 Drawing_t
*drawing
= control_flow_data
->drawing
;
1225 resourcelist_add(process_list
,
1228 resourceq
, //process->name,
1233 &hashed_process_data
);
1234 gtk_widget_set_size_request(drawing
->drawing_area
,
1237 gtk_widget_queue_draw(drawing
->drawing_area
);
1239 /* Set the current process */
1240 // process_list->current_hash_data[trace_num][process->cpu] =
1241 // hashed_process_data;
1244 /* Now, the process is in the state hash and our own process hash.
1245 * We definitely can draw the items related to the ending state.
1248 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1251 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1252 TimeWindow time_window
=
1253 lttvwindow_get_time_window(control_flow_data
->tab
);
1256 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1257 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1259 #endif //EXTRA_CHECK
1260 Drawing_t
*drawing
= control_flow_data
->drawing
;
1261 guint width
= drawing
->width
;
1263 convert_time_to_pixels(
1269 /* Draw collision indicator */
1270 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1271 gdk_draw_point(hashed_process_data
->pixmap
,
1274 COLLISION_POSITION(hashed_process_data
->height
));
1275 hashed_process_data
->x
.middle_marked
= TRUE
;
1279 TimeWindow time_window
=
1280 lttvwindow_get_time_window(control_flow_data
->tab
);
1283 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1284 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1286 #endif //EXTRA_CHECK
1287 Drawing_t
*drawing
= control_flow_data
->drawing
;
1288 guint width
= drawing
->width
;
1291 convert_time_to_pixels(
1298 /* Jump over draw if we are at the same x position */
1299 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1300 hashed_process_data
->x
.middle_used
))
1302 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1303 /* Draw collision indicator */
1304 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1305 gdk_draw_point(hashed_process_data
->pixmap
,
1308 COLLISION_POSITION(hashed_process_data
->height
));
1309 hashed_process_data
->x
.middle_marked
= TRUE
;
1315 DrawContext draw_context
;
1316 /* Now create the drawing context that will be used to draw
1317 * items related to the last state. */
1318 draw_context
.drawable
= hashed_process_data
->pixmap
;
1319 draw_context
.gc
= drawing
->gc
;
1320 draw_context
.pango_layout
= drawing
->pango_layout
;
1321 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1322 draw_context
.drawinfo
.end
.x
= x
;
1324 draw_context
.drawinfo
.y
.over
= 1;
1325 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1326 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1328 draw_context
.drawinfo
.start
.offset
.over
= 0;
1329 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1330 draw_context
.drawinfo
.start
.offset
.under
= 0;
1331 draw_context
.drawinfo
.end
.offset
.over
= 0;
1332 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1333 draw_context
.drawinfo
.end
.offset
.under
= 0;
1337 PropertiesLine prop_line
;
1338 prop_line
.line_width
= STATE_LINE_WIDTH
;
1339 prop_line
.style
= GDK_LINE_SOLID
;
1340 prop_line
.y
= MIDDLE
;
1341 irq_set_line_color(&prop_line
, &ts
->irq_states
[irq
]);
1342 draw_line((void*)&prop_line
, (void*)&draw_context
);
1344 /* become the last x position */
1345 hashed_process_data
->x
.middle
= x
;
1346 hashed_process_data
->x
.middle_used
= TRUE
;
1347 hashed_process_data
->x
.middle_marked
= FALSE
;
1349 /* Calculate the next good time */
1350 convert_pixels_to_time(width
, x
+1, time_window
,
1351 &hashed_process_data
->next_good_time
);
1358 int before_bdev_event_hook(void *hook_data
, void *call_data
)
1360 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
1361 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
1362 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1364 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1366 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1367 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1370 e
= ltt_tracefile_get_event(tfc
->tf
);
1372 LttTime evtime
= ltt_event_time(e
);
1376 /* we are in a execmode, before the state update. We must draw the
1377 * items corresponding to the state before it changes : now is the right
1382 guint cpu
= tfs
->cpu
;
1383 guint8 major
= ltt_event_get_long_unsigned(e
, th
->f1
);
1384 guint8 minor
= ltt_event_get_long_unsigned(e
, th
->f2
);
1385 guint oper
= ltt_event_get_long_unsigned(e
, th
->f3
);
1386 gint devcode_gint
= MKDEV(major
,minor
);
1390 resourcestr
= g_strdup_printf("Blockdev (%u,%u)", major
, minor
);
1391 resourceq
= g_quark_from_string(resourcestr
);
1392 g_free(resourcestr
);
1394 guint trace_num
= ts
->parent
.index
;
1396 LttvBdevState
*bdev
= g_hash_table_lookup(ts
->bdev_states
, &devcode_gint
);
1397 /* the result of the lookup might be NULL. that's ok, the rest of the function
1398 should understand it was not found and that its state is unknown */
1400 // guint pid = process->pid;
1402 /* Well, the process_out existed : we must get it in the process hash
1403 * or add it, and draw its items.
1405 /* Add process to process list (if not present) */
1406 guint pl_height
= 0;
1407 HashedResourceData
*hashed_process_data
= NULL
;
1408 ProcessList
*process_list
= control_flow_data
->process_list
;
1409 // LttTime birth = process->creation_time;
1411 // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1412 // hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1414 hashed_process_data
= processlist_get_process_data(process_list
, resourceq
, trace_num
);
1415 // hashed_process_data = processlist_get_process_data(process_list,
1420 if(unlikely(hashed_process_data
== NULL
))
1422 //g_assert(pid == 0 || pid != process->ppid);
1423 ResourceInfo
*process_info
;
1424 /* Process not present */
1425 Drawing_t
*drawing
= control_flow_data
->drawing
;
1426 resourcelist_add(process_list
,
1429 resourceq
, //process->name,
1431 devcode_gint
, /* MKDEV(major,minor) */
1434 &hashed_process_data
);
1435 gtk_widget_set_size_request(drawing
->drawing_area
,
1438 gtk_widget_queue_draw(drawing
->drawing_area
);
1440 /* Set the current process */
1441 // process_list->current_hash_data[trace_num][process->cpu] =
1442 // hashed_process_data;
1445 /* Now, the process is in the state hash and our own process hash.
1446 * We definitely can draw the items related to the ending state.
1449 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1452 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1453 TimeWindow time_window
=
1454 lttvwindow_get_time_window(control_flow_data
->tab
);
1457 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1458 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1460 #endif //EXTRA_CHECK
1461 Drawing_t
*drawing
= control_flow_data
->drawing
;
1462 guint width
= drawing
->width
;
1464 convert_time_to_pixels(
1470 /* Draw collision indicator */
1471 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1472 gdk_draw_point(hashed_process_data
->pixmap
,
1475 COLLISION_POSITION(hashed_process_data
->height
));
1476 hashed_process_data
->x
.middle_marked
= TRUE
;
1480 TimeWindow time_window
=
1481 lttvwindow_get_time_window(control_flow_data
->tab
);
1484 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1485 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1487 #endif //EXTRA_CHECK
1488 Drawing_t
*drawing
= control_flow_data
->drawing
;
1489 guint width
= drawing
->width
;
1492 convert_time_to_pixels(
1499 /* Jump over draw if we are at the same x position */
1500 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1501 hashed_process_data
->x
.middle_used
))
1503 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1504 /* Draw collision indicator */
1505 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1506 gdk_draw_point(hashed_process_data
->pixmap
,
1509 COLLISION_POSITION(hashed_process_data
->height
));
1510 hashed_process_data
->x
.middle_marked
= TRUE
;
1516 DrawContext draw_context
;
1517 /* Now create the drawing context that will be used to draw
1518 * items related to the last state. */
1519 draw_context
.drawable
= hashed_process_data
->pixmap
;
1520 draw_context
.gc
= drawing
->gc
;
1521 draw_context
.pango_layout
= drawing
->pango_layout
;
1522 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1523 draw_context
.drawinfo
.end
.x
= x
;
1525 draw_context
.drawinfo
.y
.over
= 1;
1526 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1527 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1529 draw_context
.drawinfo
.start
.offset
.over
= 0;
1530 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1531 draw_context
.drawinfo
.start
.offset
.under
= 0;
1532 draw_context
.drawinfo
.end
.offset
.over
= 0;
1533 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1534 draw_context
.drawinfo
.end
.offset
.under
= 0;
1538 PropertiesLine prop_line
;
1539 prop_line
.line_width
= STATE_LINE_WIDTH
;
1540 prop_line
.style
= GDK_LINE_SOLID
;
1541 prop_line
.y
= MIDDLE
;
1542 bdev_set_line_color(&prop_line
, bdev
);
1543 draw_line((void*)&prop_line
, (void*)&draw_context
);
1545 /* become the last x position */
1546 hashed_process_data
->x
.middle
= x
;
1547 hashed_process_data
->x
.middle_used
= TRUE
;
1548 hashed_process_data
->x
.middle_marked
= FALSE
;
1550 /* Calculate the next good time */
1551 convert_pixels_to_time(width
, x
+1, time_window
,
1552 &hashed_process_data
->next_good_time
);
1559 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1561 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1562 Drawing_t
*drawing
= control_flow_data
->drawing
;
1563 ProcessList
*process_list
= control_flow_data
->process_list
;
1565 const TimeWindowNotifyData
*time_window_nofify_data
=
1566 ((const TimeWindowNotifyData
*)call_data
);
1568 TimeWindow
*old_time_window
=
1569 time_window_nofify_data
->old_time_window
;
1570 TimeWindow
*new_time_window
=
1571 time_window_nofify_data
->new_time_window
;
1573 /* Update the ruler */
1574 drawing_update_ruler(control_flow_data
->drawing
,
1578 /* Two cases : zoom in/out or scrolling */
1580 /* In order to make sure we can reuse the old drawing, the scale must
1581 * be the same and the new time interval being partly located in the
1582 * currently shown time interval. (reuse is only for scrolling)
1585 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
1586 old_time_window
->start_time
.tv_sec
,
1587 old_time_window
->start_time
.tv_nsec
,
1588 old_time_window
->time_width
.tv_sec
,
1589 old_time_window
->time_width
.tv_nsec
);
1591 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
1592 new_time_window
->start_time
.tv_sec
,
1593 new_time_window
->start_time
.tv_nsec
,
1594 new_time_window
->time_width
.tv_sec
,
1595 new_time_window
->time_width
.tv_nsec
);
1597 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1598 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1600 /* Same scale (scrolling) */
1601 g_info("scrolling");
1602 LttTime
*ns
= &new_time_window
->start_time
;
1603 LttTime
*nw
= &new_time_window
->time_width
;
1604 LttTime
*os
= &old_time_window
->start_time
;
1605 LttTime
*ow
= &old_time_window
->time_width
;
1606 LttTime old_end
= old_time_window
->end_time
;
1607 LttTime new_end
= new_time_window
->end_time
;
1609 //if(ns<os+w && os+w<ns+w)
1610 //if(ns<old_end && os<ns)
1611 if(ltt_time_compare(*ns
, old_end
) == -1
1612 && ltt_time_compare(*os
, *ns
) == -1)
1614 g_info("scrolling near right");
1615 /* Scroll right, keep right part of the screen */
1617 guint width
= control_flow_data
->drawing
->width
;
1618 convert_time_to_pixels(
1624 /* Copy old data to new location */
1625 copy_pixmap_region(process_list
,
1627 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1631 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
1633 if(drawing
->damage_begin
== drawing
->damage_end
)
1634 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
1636 drawing
->damage_begin
= 0;
1638 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1640 /* Clear the data request background, but not SAFETY */
1641 rectangle_pixmap(process_list
,
1642 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1644 drawing
->damage_begin
+SAFETY
, 0,
1645 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1647 gtk_widget_queue_draw(drawing
->drawing_area
);
1648 //gtk_widget_queue_draw_area (drawing->drawing_area,
1650 // control_flow_data->drawing->width,
1651 // control_flow_data->drawing->height);
1653 /* Get new data for the rest. */
1654 drawing_data_request(control_flow_data
->drawing
,
1655 drawing
->damage_begin
, 0,
1656 drawing
->damage_end
- drawing
->damage_begin
,
1657 control_flow_data
->drawing
->height
);
1660 //if(ns<os && os<ns+w)
1661 //if(ns<os && os<new_end)
1662 if(ltt_time_compare(*ns
,*os
) == -1
1663 && ltt_time_compare(*os
,new_end
) == -1)
1665 g_info("scrolling near left");
1666 /* Scroll left, keep left part of the screen */
1668 guint width
= control_flow_data
->drawing
->width
;
1669 convert_time_to_pixels(
1675 /* Copy old data to new location */
1676 copy_pixmap_region (process_list
,
1678 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1684 if(drawing
->damage_begin
== drawing
->damage_end
)
1685 drawing
->damage_end
= x
;
1687 drawing
->damage_end
=
1688 control_flow_data
->drawing
->width
;
1690 drawing
->damage_begin
= 0;
1692 rectangle_pixmap (process_list
,
1693 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1695 drawing
->damage_begin
, 0,
1696 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1699 gtk_widget_queue_draw(drawing
->drawing_area
);
1700 //gtk_widget_queue_draw_area (drawing->drawing_area,
1702 // control_flow_data->drawing->width,
1703 // control_flow_data->drawing->height);
1706 /* Get new data for the rest. */
1707 drawing_data_request(control_flow_data
->drawing
,
1708 drawing
->damage_begin
, 0,
1709 drawing
->damage_end
- drawing
->damage_begin
,
1710 control_flow_data
->drawing
->height
);
1713 if(ltt_time_compare(*ns
,*os
) == 0)
1715 g_info("not scrolling");
1717 g_info("scrolling far");
1718 /* Cannot reuse any part of the screen : far jump */
1721 rectangle_pixmap (process_list
,
1722 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1725 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1728 //gtk_widget_queue_draw_area (drawing->drawing_area,
1730 // control_flow_data->drawing->width,
1731 // control_flow_data->drawing->height);
1732 gtk_widget_queue_draw(drawing
->drawing_area
);
1734 drawing
->damage_begin
= 0;
1735 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1737 drawing_data_request(control_flow_data
->drawing
,
1739 control_flow_data
->drawing
->width
,
1740 control_flow_data
->drawing
->height
);
1746 /* Different scale (zoom) */
1749 rectangle_pixmap (process_list
,
1750 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1753 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1756 //gtk_widget_queue_draw_area (drawing->drawing_area,
1758 // control_flow_data->drawing->width,
1759 // control_flow_data->drawing->height);
1760 gtk_widget_queue_draw(drawing
->drawing_area
);
1762 drawing
->damage_begin
= 0;
1763 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1765 drawing_data_request(control_flow_data
->drawing
,
1767 control_flow_data
->drawing
->width
,
1768 control_flow_data
->drawing
->height
);
1771 /* Update directly when scrolling */
1772 gdk_window_process_updates(control_flow_data
->drawing
->drawing_area
->window
,
1778 gint
traceset_notify(void *hook_data
, void *call_data
)
1780 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1781 Drawing_t
*drawing
= control_flow_data
->drawing
;
1783 if(unlikely(drawing
->gc
== NULL
)) {
1786 if(drawing
->dotted_gc
== NULL
) {
1790 drawing_clear(control_flow_data
->drawing
);
1791 processlist_clear(control_flow_data
->process_list
);
1792 gtk_widget_set_size_request(
1793 control_flow_data
->drawing
->drawing_area
,
1794 -1, processlist_get_height(control_flow_data
->process_list
));
1795 redraw_notify(control_flow_data
, NULL
);
1797 request_background_data(control_flow_data
);
1802 gint
redraw_notify(void *hook_data
, void *call_data
)
1804 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1805 Drawing_t
*drawing
= control_flow_data
->drawing
;
1806 GtkWidget
*widget
= drawing
->drawing_area
;
1808 drawing
->damage_begin
= 0;
1809 drawing
->damage_end
= drawing
->width
;
1811 /* fun feature, to be separated someday... */
1812 drawing_clear(control_flow_data
->drawing
);
1813 processlist_clear(control_flow_data
->process_list
);
1814 gtk_widget_set_size_request(
1815 control_flow_data
->drawing
->drawing_area
,
1816 -1, processlist_get_height(control_flow_data
->process_list
));
1818 rectangle_pixmap (control_flow_data
->process_list
,
1819 widget
->style
->black_gc
,
1822 drawing
->alloc_width
,
1825 gtk_widget_queue_draw(drawing
->drawing_area
);
1827 if(drawing
->damage_begin
< drawing
->damage_end
)
1829 drawing_data_request(drawing
,
1830 drawing
->damage_begin
,
1832 drawing
->damage_end
-drawing
->damage_begin
,
1836 //gtk_widget_queue_draw_area(drawing->drawing_area,
1839 // drawing->height);
1845 gint
continue_notify(void *hook_data
, void *call_data
)
1847 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1848 Drawing_t
*drawing
= control_flow_data
->drawing
;
1850 //g_assert(widget->allocation.width == drawing->damage_end);
1852 if(drawing
->damage_begin
< drawing
->damage_end
)
1854 drawing_data_request(drawing
,
1855 drawing
->damage_begin
,
1857 drawing
->damage_end
-drawing
->damage_begin
,
1865 gint
update_current_time_hook(void *hook_data
, void *call_data
)
1867 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
1868 Drawing_t
*drawing
= control_flow_data
->drawing
;
1870 LttTime current_time
= *((LttTime
*)call_data
);
1872 TimeWindow time_window
=
1873 lttvwindow_get_time_window(control_flow_data
->tab
);
1875 LttTime time_begin
= time_window
.start_time
;
1876 LttTime width
= time_window
.time_width
;
1879 guint64 time_ll
= ltt_time_to_uint64(width
);
1880 time_ll
= time_ll
>> 1; /* divide by two */
1881 half_width
= ltt_time_from_uint64(time_ll
);
1883 LttTime time_end
= ltt_time_add(time_begin
, width
);
1885 LttvTracesetContext
* tsc
=
1886 lttvwindow_get_traceset_context(control_flow_data
->tab
);
1888 LttTime trace_start
= tsc
->time_span
.start_time
;
1889 LttTime trace_end
= tsc
->time_span
.end_time
;
1891 g_info("New current time HOOK : %lu, %lu", current_time
.tv_sec
,
1892 current_time
.tv_nsec
);
1896 /* If current time is inside time interval, just move the highlight
1899 /* Else, we have to change the time interval. We have to tell it
1900 * to the main window. */
1901 /* The time interval change will take care of placing the current
1902 * time at the center of the visible area, or nearest possible if we are
1903 * at one end of the trace. */
1906 if(ltt_time_compare(current_time
, time_begin
) < 0)
1908 TimeWindow new_time_window
;
1910 if(ltt_time_compare(current_time
,
1911 ltt_time_add(trace_start
,half_width
)) < 0)
1912 time_begin
= trace_start
;
1914 time_begin
= ltt_time_sub(current_time
,half_width
);
1916 new_time_window
.start_time
= time_begin
;
1917 new_time_window
.time_width
= width
;
1918 new_time_window
.time_width_double
= ltt_time_to_double(width
);
1919 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
1921 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
1923 else if(ltt_time_compare(current_time
, time_end
) > 0)
1925 TimeWindow new_time_window
;
1927 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) > 0)
1928 time_begin
= ltt_time_sub(trace_end
,width
);
1930 time_begin
= ltt_time_sub(current_time
,half_width
);
1932 new_time_window
.start_time
= time_begin
;
1933 new_time_window
.time_width
= width
;
1934 new_time_window
.time_width_double
= ltt_time_to_double(width
);
1935 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
1937 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
1940 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
1942 /* Update directly when scrolling */
1943 gdk_window_process_updates(control_flow_data
->drawing
->drawing_area
->window
,
1949 typedef struct _ClosureData
{
1950 EventsRequest
*events_request
;
1951 LttvTracesetState
*tss
;
1956 /* Draw line until end of the screen */
1958 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1960 ResourceInfo
*process_info
= (ResourceInfo
*)key
;
1961 HashedResourceData
*hashed_process_data
= (HashedResourceData
*)value
;
1962 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1964 EventsRequest
*events_request
= closure_data
->events_request
;
1965 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1967 LttvTracesetState
*tss
= closure_data
->tss
;
1968 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
1970 LttTime evtime
= closure_data
->end_time
;
1972 gboolean dodraw
= TRUE
;
1975 /* For the process */
1976 /* First, check if the current process is in the state computation
1977 * process list. If it is there, that means we must add it right now and
1978 * draw items from the beginning of the read for it. If it is not
1979 * present, it's a new process and it was not present : it will
1980 * be added after the state update. */
1982 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
1983 #endif //EXTRA_CHECK
1984 LttvTraceContext
*tc
= tsc
->traces
[process_info
->trace_num
];
1985 LttvTraceState
*ts
= (LttvTraceState
*)tc
;
1988 //FIXME : optimize data structures.
1989 LttvTracefileState
*tfs
;
1990 LttvTracefileContext
*tfc
;
1992 for(i
=0;i
<tc
->tracefiles
->len
;i
++) {
1993 tfc
= g_array_index(tc
->tracefiles
, LttvTracefileContext
*, i
);
1994 if(ltt_tracefile_name(tfc
->tf
) == LTT_NAME_CPU
1995 && tfs
->cpu
== process_info
->cpu
)
1999 g_assert(i
<tc
->tracefiles
->len
);
2000 tfs
= LTTV_TRACEFILE_STATE(tfc
);
2002 // LttvTracefileState *tfs =
2003 // (LttvTracefileState*)tsc->traces[process_info->trace_num]->
2004 // tracefiles[process_info->cpu];
2006 // LttvProcessState *process;
2007 // process = lttv_state_find_process(ts, process_info->cpu,
2008 // process_info->pid);
2010 // if(unlikely(process != NULL)) {
2012 // LttvFilter *filter = control_flow_data->filter;
2013 // if(filter != NULL && filter->head != NULL)
2014 // if(!lttv_filter_tree_parse(filter->head,NULL,NULL,
2015 // tc->t,NULL,process,tc))
2018 /* Only draw for processes that are currently in the trace states */
2020 ProcessList
*process_list
= control_flow_data
->process_list
;
2022 /* Should be alike when background info is ready */
2023 if(control_flow_data
->background_info_waiting
==0)
2024 g_assert(ltt_time_compare(process
->creation_time
,
2025 process_info
->birth
) == 0);
2026 #endif //EXTRA_CHECK
2028 /* Now, the process is in the state hash and our own process hash.
2029 * We definitely can draw the items related to the ending state.
2032 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2035 TimeWindow time_window
=
2036 lttvwindow_get_time_window(control_flow_data
->tab
);
2039 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2040 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2042 #endif //EXTRA_CHECK
2043 Drawing_t
*drawing
= control_flow_data
->drawing
;
2044 guint width
= drawing
->width
;
2046 guint x
= closure_data
->x_end
;
2048 DrawContext draw_context
;
2050 /* Now create the drawing context that will be used to draw
2051 * items related to the last state. */
2052 draw_context
.drawable
= hashed_process_data
->pixmap
;
2053 draw_context
.gc
= drawing
->gc
;
2054 draw_context
.pango_layout
= drawing
->pango_layout
;
2055 draw_context
.drawinfo
.end
.x
= x
;
2057 draw_context
.drawinfo
.y
.over
= 1;
2058 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2059 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2061 draw_context
.drawinfo
.start
.offset
.over
= 0;
2062 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2063 draw_context
.drawinfo
.start
.offset
.under
= 0;
2064 draw_context
.drawinfo
.end
.offset
.over
= 0;
2065 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2066 draw_context
.drawinfo
.end
.offset
.under
= 0;
2068 /* Jump over draw if we are at the same x position */
2069 if(x
== hashed_process_data
->x
.over
)
2073 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
2075 PropertiesLine prop_line
= prepare_execmode_line(process
);
2076 draw_line((void*)&prop_line
, (void*)&draw_context
);
2078 hashed_process_data
->x
.over
= x
;
2082 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2083 hashed_process_data
->x
.middle_used
)) {
2084 #if 0 /* do not mark closure : not missing information */
2085 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2086 /* Draw collision indicator */
2087 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2088 gdk_draw_point(drawing
->pixmap
,
2092 hashed_process_data
->x
.middle_marked
= TRUE
;
2097 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2100 PropertiesLine prop_line
;
2101 prop_line
.line_width
= STATE_LINE_WIDTH
;
2102 prop_line
.style
= GDK_LINE_SOLID
;
2103 prop_line
.y
= MIDDLE
;
2104 if(process_info
->type
== 0)
2105 cpu_set_line_color(&prop_line
, &ts
->cpu_states
[process_info
->id
]);
2106 else if(process_info
->type
== 1)
2107 irq_set_line_color(&prop_line
, &ts
->irq_states
[process_info
->id
]);
2108 else if(process_info
->type
== 2) {
2109 gint devcode_gint
= process_info
->id
;
2110 LttvBdevState
*bdev
= g_hash_table_lookup(ts
->bdev_states
, &devcode_gint
);
2111 // the lookup may return null; bdev_set_line_color must act appropriately
2112 bdev_set_line_color(&prop_line
, bdev
);
2115 draw_line((void*)&prop_line
, (void*)&draw_context
);
2118 /* become the last x position */
2119 if(likely(x
!= hashed_process_data
->x
.middle
)) {
2120 hashed_process_data
->x
.middle
= x
;
2121 /* but don't use the pixel */
2122 hashed_process_data
->x
.middle_used
= FALSE
;
2124 /* Calculate the next good time */
2125 convert_pixels_to_time(width
, x
+1, time_window
,
2126 &hashed_process_data
->next_good_time
);
2135 int before_chunk(void *hook_data
, void *call_data
)
2137 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2138 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2139 ControlFlowData
*cfd
= (ControlFlowData
*)events_request
->viewer_data
;
2141 /* Desactivate sort */
2142 gtk_tree_sortable_set_sort_column_id(
2143 GTK_TREE_SORTABLE(cfd
->process_list
->list_store
),
2145 GTK_SORT_ASCENDING
);
2147 drawing_chunk_begin(events_request
, tss
);
2152 int before_request(void *hook_data
, void *call_data
)
2154 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2155 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2157 drawing_data_request_begin(events_request
, tss
);
2164 * after request is necessary in addition of after chunk in order to draw
2165 * lines until the end of the screen. after chunk just draws lines until
2172 // TODO pmf: reenable this
2173 int after_request(void *hook_data
, void *call_data
)
2175 // EventsRequest *events_request = (EventsRequest*)hook_data;
2176 // ControlFlowData *control_flow_data = events_request->viewer_data;
2177 // LttvTracesetState *tss = (LttvTracesetState*)call_data;
2179 // ProcessList *process_list = control_flow_data->process_list;
2180 // LttTime end_time = events_request->end_time;
2182 // ClosureData closure_data;
2183 // closure_data.events_request = (EventsRequest*)hook_data;
2184 // closure_data.tss = tss;
2185 // closure_data.end_time = end_time;
2187 // TimeWindow time_window =
2188 // lttvwindow_get_time_window(control_flow_data->tab);
2189 // guint width = control_flow_data->drawing->width;
2190 // convert_time_to_pixels(
2194 // &closure_data.x_end);
2197 // /* Draw last items */
2198 // g_hash_table_foreach(process_list->process_hash, draw_closure,
2199 // (void*)&closure_data);
2202 // /* Request expose */
2203 // drawing_request_expose(events_request, tss, end_time);
2212 int after_chunk(void *hook_data
, void *call_data
)
2214 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2215 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2216 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2217 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
2218 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
2221 ProcessList
*process_list
= control_flow_data
->process_list
;
2223 LttvTraceset
*traceset
= tsc
->ts
;
2224 guint nb_trace
= lttv_traceset_number(traceset
);
2226 /* Only execute when called for the first trace's events request */
2227 if(!process_list
->current_hash_data
) return;
2229 for(i
= 0 ; i
< nb_trace
; i
++) {
2230 g_free(process_list
->current_hash_data
[i
]);
2232 g_free(process_list
->current_hash_data
);
2233 process_list
->current_hash_data
= NULL
;
2236 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
2237 else /* end of traceset, or position now out of request : end */
2238 end_time
= events_request
->end_time
;
2240 ClosureData closure_data
;
2241 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2242 closure_data
.tss
= tss
;
2243 closure_data
.end_time
= end_time
;
2245 TimeWindow time_window
=
2246 lttvwindow_get_time_window(control_flow_data
->tab
);
2247 guint width
= control_flow_data
->drawing
->width
;
2248 convert_time_to_pixels(
2252 &closure_data
.x_end
);
2254 /* Draw last items */
2255 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2256 (void*)&closure_data
);
2258 /* Reactivate sort */
2259 gtk_tree_sortable_set_sort_column_id(
2260 GTK_TREE_SORTABLE(control_flow_data
->process_list
->list_store
),
2261 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
2262 GTK_SORT_ASCENDING
);
2264 update_index_to_pixmap(control_flow_data
->process_list
);
2265 /* Request a full expose : drawing scrambled */
2266 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
2268 /* Request expose (updates damages zone also) */
2269 drawing_request_expose(events_request
, tss
, end_time
);
2274 /* after_statedump_end
2276 * @param hook_data ControlFlowData structure of the viewer.
2277 * @param call_data Event context.
2279 * This function adds items to be drawn in a queue for each process.
2282 int before_statedump_end(void *hook_data
, void *call_data
)
2284 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
2285 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
2286 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2288 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2290 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2292 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
2294 LttvTracesetState
*tss
= (LttvTracesetState
*)tfc
->t_context
->ts_context
;
2295 ProcessList
*process_list
= control_flow_data
->process_list
;
2298 e
= ltt_tracefile_get_event(tfc
->tf
);
2300 LttvFilter
*filter
= control_flow_data
->filter
;
2301 if(filter
!= NULL
&& filter
->head
!= NULL
)
2302 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
2303 tfc
->t_context
->t
,tfc
,NULL
,NULL
))
2306 LttTime evtime
= ltt_event_time(e
);
2308 ClosureData closure_data
;
2309 closure_data
.events_request
= events_request
;
2310 closure_data
.tss
= tss
;
2311 closure_data
.end_time
= evtime
;
2313 TimeWindow time_window
=
2314 lttvwindow_get_time_window(control_flow_data
->tab
);
2315 guint width
= control_flow_data
->drawing
->width
;
2316 convert_time_to_pixels(
2320 &closure_data
.x_end
);
2322 /* Draw last items */
2323 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2324 (void*)&closure_data
);
2326 /* Reactivate sort */
2327 gtk_tree_sortable_set_sort_column_id(
2328 GTK_TREE_SORTABLE(control_flow_data
->process_list
->list_store
),
2329 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
2330 GTK_SORT_ASCENDING
);
2332 update_index_to_pixmap(control_flow_data
->process_list
);
2333 /* Request a full expose : drawing scrambled */
2334 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
2336 /* Request expose (updates damages zone also) */
2337 drawing_request_expose(events_request
, tss
, evtime
);