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 6
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
*resourceview_data
= (ControlFlowData
*)hook_data
;
95 LttvTrace
*trace
= (LttvTrace
*)call_data
;
97 resourceview_data
->background_info_waiting
--;
99 if(resourceview_data
->background_info_waiting
== 0) {
100 g_message("control flow viewer : background computation data ready.");
102 drawing_clear(resourceview_data
->drawing
);
103 processlist_clear(resourceview_data
->process_list
);
104 gtk_widget_set_size_request(
105 resourceview_data
->drawing
->drawing_area
,
106 -1, processlist_get_height(resourceview_data
->process_list
));
107 redraw_notify(resourceview_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
*resourceview_data
)
119 LttvTracesetContext
* tsc
=
120 lttvwindow_get_traceset_context(resourceview_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
, resourceview_data
,
130 resourceview_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(resourceview_data
->tab
), trace
, "state");
148 lttvwindowtraces_background_notify_queue(resourceview_data
,
152 background_ready_hook
);
153 resourceview_data
->background_info_waiting
++;
154 } else { /* in progress */
156 lttvwindowtraces_background_notify_current(resourceview_data
,
160 background_ready_hook
);
161 resourceview_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.
171 lttv_hooks_destroy(background_ready_hook
);
176 * Event Viewer's constructor hook
178 * This constructor is given as a parameter to the menuitem and toolbar button
179 * registration. It creates the list.
180 * @param tab A pointer to the parent tab.
181 * @return The widget created.
184 h_resourceview(LttvPlugin
*plugin
)
186 LttvPluginTab
*ptab
= LTTV_PLUGIN_TAB(plugin
);
187 Tab
*tab
= ptab
->tab
;
188 g_info("h_guicontrolflow, %p", tab
);
189 ControlFlowData
*resourceview_data
= resourceview(ptab
);
191 resourceview_data
->tab
= tab
;
193 // Unreg done in the GuiControlFlow_Destructor
194 lttvwindow_register_traceset_notify(tab
,
198 lttvwindow_register_time_window_notify(tab
,
199 update_time_window_hook
,
201 lttvwindow_register_current_time_notify(tab
,
202 update_current_time_hook
,
204 lttvwindow_register_redraw_notify(tab
,
207 lttvwindow_register_continue_notify(tab
,
210 request_background_data(resourceview_data
);
213 return guicontrolflow_get_widget(resourceview_data
) ;
217 void legend_destructor(GtkWindow
*legend
)
219 g_legend_list
= g_slist_remove(g_legend_list
, legend
);
222 /* Create a popup legend */
224 h_legend(LttvPlugin
*plugin
)
226 LttvPluginTab
*ptab
= LTTV_PLUGIN_TAB(plugin
);
227 Tab
*tab
= ptab
->tab
;
228 g_info("h_legend, %p", tab
);
230 GtkWindow
*legend
= GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL
));
232 g_legend_list
= g_slist_append(
236 g_object_set_data_full(
240 (GDestroyNotify
)legend_destructor
);
242 gtk_window_set_title(legend
, "Control Flow View Legend");
244 GtkWidget
*pixmap
= create_pixmap(GTK_WIDGET(legend
), "lttv-color-list.png");
246 gtk_container_add(GTK_CONTAINER(legend
), GTK_WIDGET(pixmap
));
248 gtk_widget_show(GTK_WIDGET(pixmap
));
249 gtk_widget_show(GTK_WIDGET(legend
));
252 return NULL
; /* This is a popup window */
256 int event_selected_hook(void *hook_data
, void *call_data
)
258 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
259 guint
*event_number
= (guint
*) call_data
;
261 g_debug("DEBUG : event selected by main window : %u", *event_number
);
266 static void cpu_set_line_color(PropertiesLine
*prop_line
, LttvCPUState
*s
)
268 GQuark present_state
;
270 if(s
->mode_stack
->len
== 0)
271 present_state
= LTTV_CPU_UNKNOWN
;
273 present_state
= ((GQuark
*)s
->mode_stack
->data
)[s
->mode_stack
->len
-1];
275 if(present_state
== LTTV_CPU_IDLE
) {
276 prop_line
->color
= drawing_colors_cpu
[COL_CPU_IDLE
];
278 else if(present_state
== LTTV_CPU_BUSY
) {
279 prop_line
->color
= drawing_colors_cpu
[COL_CPU_BUSY
];
281 else if(present_state
== LTTV_CPU_IRQ
) {
282 prop_line
->color
= drawing_colors_cpu
[COL_CPU_IRQ
];
284 else if(present_state
== LTTV_CPU_SOFT_IRQ
) {
285 prop_line
->color
= drawing_colors_cpu
[COL_CPU_SOFT_IRQ
];
287 else if(present_state
== LTTV_CPU_TRAP
) {
288 prop_line
->color
= drawing_colors_cpu
[COL_CPU_TRAP
];
290 prop_line
->color
= drawing_colors_cpu
[COL_CPU_UNKNOWN
];
294 static void irq_set_line_color(PropertiesLine
*prop_line
, LttvIRQState
*s
)
296 GQuark present_state
;
297 if(s
->mode_stack
->len
== 0)
298 present_state
= LTTV_IRQ_UNKNOWN
;
300 present_state
= ((GQuark
*)s
->mode_stack
->data
)[s
->mode_stack
->len
-1];
302 if(present_state
== LTTV_IRQ_IDLE
) {
303 prop_line
->color
= drawing_colors_irq
[COL_IRQ_IDLE
];
305 else if(present_state
== LTTV_IRQ_BUSY
) {
306 prop_line
->color
= drawing_colors_irq
[COL_IRQ_BUSY
];
309 prop_line
->color
= drawing_colors_irq
[COL_IRQ_UNKNOWN
];
313 static void soft_irq_set_line_color(PropertiesLine
*prop_line
, LttvSoftIRQState
*s
)
315 GQuark present_state
;
317 prop_line
->color
= drawing_colors_soft_irq
[COL_SOFT_IRQ_BUSY
];
319 prop_line
->color
= drawing_colors_soft_irq
[COL_SOFT_IRQ_PENDING
];
321 prop_line
->color
= drawing_colors_soft_irq
[COL_SOFT_IRQ_IDLE
];
324 static void trap_set_line_color(PropertiesLine
*prop_line
, LttvTrapState
*s
)
326 GQuark present_state
;
328 prop_line
->color
= drawing_colors_trap
[COL_TRAP_IDLE
];
330 prop_line
->color
= drawing_colors_trap
[COL_TRAP_BUSY
];
333 static void bdev_set_line_color(PropertiesLine
*prop_line
, LttvBdevState
*s
)
335 GQuark present_state
;
336 if(s
== 0 || s
->mode_stack
->len
== 0)
337 present_state
= LTTV_BDEV_UNKNOWN
;
339 present_state
= ((GQuark
*)s
->mode_stack
->data
)[s
->mode_stack
->len
-1];
341 if(present_state
== LTTV_BDEV_IDLE
) {
342 prop_line
->color
= drawing_colors_bdev
[COL_BDEV_IDLE
];
344 else if(present_state
== LTTV_BDEV_BUSY_READING
) {
345 prop_line
->color
= drawing_colors_bdev
[COL_BDEV_BUSY_READING
];
347 else if(present_state
== LTTV_BDEV_BUSY_WRITING
) {
348 prop_line
->color
= drawing_colors_bdev
[COL_BDEV_BUSY_WRITING
];
351 prop_line
->color
= drawing_colors_bdev
[COL_BDEV_UNKNOWN
];
355 /* before_schedchange_hook
357 * This function basically draw lines and icons. Two types of lines are drawn :
358 * one small (3 pixels?) representing the state of the process and the second
359 * type is thicker (10 pixels?) representing on which CPU a process is running
360 * (and this only in running state).
362 * Extremums of the lines :
363 * x_min : time of the last event context for this process kept in memory.
364 * x_max : time of the current event.
365 * y : middle of the process in the process list. The process is found in the
366 * list, therefore is it's position in pixels.
368 * The choice of lines'color is defined by the context of the last event for this
373 int before_schedchange_hook(void *hook_data
, void *call_data
)
375 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
376 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
377 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
379 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
381 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
382 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
385 e
= ltt_tracefile_get_event(tfc
->tf
);
386 gint target_pid_saved
= tfc
->target_pid
;
388 LttTime evtime
= ltt_event_time(e
);
389 LttvFilter
*filter
= resourceview_data
->filter
;
391 /* we are in a schedchange, before the state update. We must draw the
392 * items corresponding to the state before it changes : now is the right
398 pid_out
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
399 pid_in
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 1));
400 // TODO: can't we reenable this? pmf
401 // if(pid_in != 0 && pid_out != 0) {
402 // /* not a transition to/from idle */
406 tfc
->target_pid
= pid_out
;
408 guint cpu
= tfs
->cpu
;
410 guint trace_num
= ts
->parent
.index
;
411 /* Add process to process list (if not present) */
413 HashedResourceData
*hashed_process_data
= NULL
;
414 ProcessList
*process_list
= resourceview_data
->process_list
;
416 hashed_process_data
= resourcelist_obtain_cpu(resourceview_data
, trace_num
, cpu
);
418 /* Now, the process is in the state hash and our own process hash.
419 * We definitely can draw the items related to the ending state.
422 if(ltt_time_compare(hashed_process_data
->next_good_time
,
425 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
427 TimeWindow time_window
=
428 lttvwindow_get_time_window(resourceview_data
->tab
);
430 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
431 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
434 Drawing_t
*drawing
= resourceview_data
->drawing
;
435 guint width
= drawing
->width
;
437 convert_time_to_pixels(
443 /* Draw collision indicator */
444 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
445 gdk_draw_point(hashed_process_data
->pixmap
,
448 COLLISION_POSITION(hashed_process_data
->height
));
449 hashed_process_data
->x
.middle_marked
= TRUE
;
452 TimeWindow time_window
=
453 lttvwindow_get_time_window(resourceview_data
->tab
);
455 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
456 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
459 Drawing_t
*drawing
= resourceview_data
->drawing
;
460 guint width
= drawing
->width
;
462 convert_time_to_pixels(
468 /* Jump over draw if we are at the same x position */
469 if(x
== hashed_process_data
->x
.middle
&&
470 hashed_process_data
->x
.middle_used
)
472 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
473 /* Draw collision indicator */
474 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
475 gdk_draw_point(hashed_process_data
->pixmap
,
478 COLLISION_POSITION(hashed_process_data
->height
));
479 hashed_process_data
->x
.middle_marked
= TRUE
;
483 DrawContext draw_context
;
485 /* Now create the drawing context that will be used to draw
486 * items related to the last state. */
487 draw_context
.drawable
= hashed_process_data
->pixmap
;
488 draw_context
.gc
= drawing
->gc
;
489 draw_context
.pango_layout
= drawing
->pango_layout
;
490 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
491 draw_context
.drawinfo
.end
.x
= x
;
493 draw_context
.drawinfo
.y
.over
= 1;
494 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
495 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
497 draw_context
.drawinfo
.start
.offset
.over
= 0;
498 draw_context
.drawinfo
.start
.offset
.middle
= 0;
499 draw_context
.drawinfo
.start
.offset
.under
= 0;
500 draw_context
.drawinfo
.end
.offset
.over
= 0;
501 draw_context
.drawinfo
.end
.offset
.middle
= 0;
502 draw_context
.drawinfo
.end
.offset
.under
= 0;
506 //PropertiesLine prop_line = prepare_s_e_line(process);
507 PropertiesLine prop_line
;
508 prop_line
.line_width
= STATE_LINE_WIDTH
;
509 prop_line
.style
= GDK_LINE_SOLID
;
510 prop_line
.y
= MIDDLE
;
511 cpu_set_line_color(&prop_line
, tfs
->cpu_state
);
512 draw_line((void*)&prop_line
, (void*)&draw_context
);
515 /* become the last x position */
516 hashed_process_data
->x
.middle
= x
;
517 hashed_process_data
->x
.middle_used
= TRUE
;
518 hashed_process_data
->x
.middle_marked
= FALSE
;
520 /* Calculate the next good time */
521 convert_pixels_to_time(width
, x
+1, time_window
,
522 &hashed_process_data
->next_good_time
);
529 /* after_schedchange_hook
531 * The draw after hook is called by the reading API to have a
532 * particular event drawn on the screen.
533 * @param hook_data ControlFlowData structure of the viewer.
534 * @param call_data Event context.
536 * This function adds items to be drawn in a queue for each process.
539 int after_schedchange_hook(void *hook_data
, void *call_data
)
541 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
542 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
543 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
544 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
545 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
546 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
549 e
= ltt_tracefile_get_event(tfc
->tf
);
551 LttvFilter
*filter
= resourceview_data
->filter
;
552 if(filter
!= NULL
&& filter
->head
!= NULL
)
553 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
554 tfc
->t_context
->t
,tfc
,NULL
,NULL
))
557 LttTime evtime
= ltt_event_time(e
);
559 /* Add process to process list (if not present) */
560 LttvProcessState
*process_in
;
563 HashedResourceData
*hashed_process_data_in
= NULL
;
565 ProcessList
*process_list
= resourceview_data
->process_list
;
570 pid_out
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
571 pid_in
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 1));
575 /* Find process pid_in in the list... */
576 //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
577 //process_in = tfs->process;
578 guint cpu
= tfs
->cpu
;
579 guint trace_num
= ts
->parent
.index
;
580 process_in
= ts
->running_process
[cpu
];
581 /* It should exist, because we are after the state update. */
583 g_assert(process_in
!= NULL
);
585 birth
= process_in
->creation_time
;
587 //hashed_process_data_in = processlist_get_process_data(process_list, cpuq, trace_num);
588 hashed_process_data_in
= resourcelist_obtain_cpu(resourceview_data
, trace_num
, cpu
);
590 /* Set the current process */
591 process_list
->current_hash_data
[trace_num
][process_in
->cpu
] =
592 hashed_process_data_in
;
594 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
597 TimeWindow time_window
=
598 lttvwindow_get_time_window(resourceview_data
->tab
);
601 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
602 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
605 Drawing_t
*drawing
= resourceview_data
->drawing
;
606 guint width
= drawing
->width
;
609 convert_time_to_pixels(
615 if(hashed_process_data_in
->x
.middle
!= new_x
) {
616 hashed_process_data_in
->x
.middle
= new_x
;
617 hashed_process_data_in
->x
.middle_used
= FALSE
;
618 hashed_process_data_in
->x
.middle_marked
= FALSE
;
624 /* before_execmode_hook
626 * This function basically draw lines and icons. Two types of lines are drawn :
627 * one small (3 pixels?) representing the state of the process and the second
628 * type is thicker (10 pixels?) representing on which CPU a process is running
629 * (and this only in running state).
631 * Extremums of the lines :
632 * x_min : time of the last event context for this process kept in memory.
633 * x_max : time of the current event.
634 * y : middle of the process in the process list. The process is found in the
635 * list, therefore is it's position in pixels.
637 * The choice of lines'color is defined by the context of the last event for this
641 int before_execmode_hook(void *hook_data
, void *call_data
)
643 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
644 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
645 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
647 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
649 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
650 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
653 e
= ltt_tracefile_get_event(tfc
->tf
);
655 LttTime evtime
= ltt_event_time(e
);
657 before_execmode_hook_irq(hook_data
, call_data
);
658 before_execmode_hook_soft_irq(hook_data
, call_data
);
659 before_execmode_hook_trap(hook_data
, call_data
);
661 /* we are in a execmode, before the state update. We must draw the
662 * items corresponding to the state before it changes : now is the right
666 guint cpu
= tfs
->cpu
;
668 guint trace_num
= ts
->parent
.index
;
669 LttvProcessState
*process
= ts
->running_process
[cpu
];
670 g_assert(process
!= NULL
);
672 /* Well, the process_out existed : we must get it in the process hash
673 * or add it, and draw its items.
675 /* Add process to process list (if not present) */
677 HashedResourceData
*hashed_process_data
= NULL
;
678 ProcessList
*process_list
= resourceview_data
->process_list
;
680 LttTime birth
= process
->creation_time
;
682 if(likely(process_list
->current_hash_data
[trace_num
][cpu
] != NULL
)) {
683 hashed_process_data
= process_list
->current_hash_data
[trace_num
][cpu
];
685 hashed_process_data
= resourcelist_obtain_cpu(resourceview_data
, trace_num
, cpu
);
687 /* Set the current process */
688 process_list
->current_hash_data
[trace_num
][process
->cpu
] =
692 /* Now, the process is in the state hash and our own process hash.
693 * We definitely can draw the items related to the ending state.
696 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
699 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
700 TimeWindow time_window
=
701 lttvwindow_get_time_window(resourceview_data
->tab
);
704 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
705 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
708 Drawing_t
*drawing
= resourceview_data
->drawing
;
709 guint width
= drawing
->width
;
711 convert_time_to_pixels(
717 /* Draw collision indicator */
718 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
719 gdk_draw_point(hashed_process_data
->pixmap
,
722 COLLISION_POSITION(hashed_process_data
->height
));
723 hashed_process_data
->x
.middle_marked
= TRUE
;
727 TimeWindow time_window
=
728 lttvwindow_get_time_window(resourceview_data
->tab
);
731 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
732 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
735 Drawing_t
*drawing
= resourceview_data
->drawing
;
736 guint width
= drawing
->width
;
739 convert_time_to_pixels(
746 /* Jump over draw if we are at the same x position */
747 if(unlikely(x
== hashed_process_data
->x
.middle
&&
748 hashed_process_data
->x
.middle_used
))
750 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
751 /* Draw collision indicator */
752 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
753 gdk_draw_point(hashed_process_data
->pixmap
,
756 COLLISION_POSITION(hashed_process_data
->height
));
757 hashed_process_data
->x
.middle_marked
= TRUE
;
763 DrawContext draw_context
;
764 /* Now create the drawing context that will be used to draw
765 * items related to the last state. */
766 draw_context
.drawable
= hashed_process_data
->pixmap
;
767 draw_context
.gc
= drawing
->gc
;
768 draw_context
.pango_layout
= drawing
->pango_layout
;
769 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
770 draw_context
.drawinfo
.end
.x
= x
;
772 draw_context
.drawinfo
.y
.over
= 1;
773 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
774 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
776 draw_context
.drawinfo
.start
.offset
.over
= 0;
777 draw_context
.drawinfo
.start
.offset
.middle
= 0;
778 draw_context
.drawinfo
.start
.offset
.under
= 0;
779 draw_context
.drawinfo
.end
.offset
.over
= 0;
780 draw_context
.drawinfo
.end
.offset
.middle
= 0;
781 draw_context
.drawinfo
.end
.offset
.under
= 0;
785 PropertiesLine prop_line
;
786 prop_line
.line_width
= STATE_LINE_WIDTH
;
787 prop_line
.style
= GDK_LINE_SOLID
;
788 prop_line
.y
= MIDDLE
;
789 cpu_set_line_color(&prop_line
, tfs
->cpu_state
);
790 draw_line((void*)&prop_line
, (void*)&draw_context
);
792 /* become the last x position */
793 hashed_process_data
->x
.middle
= x
;
794 hashed_process_data
->x
.middle_used
= TRUE
;
795 hashed_process_data
->x
.middle_marked
= FALSE
;
797 /* Calculate the next good time */
798 convert_pixels_to_time(width
, x
+1, time_window
,
799 &hashed_process_data
->next_good_time
);
806 int before_execmode_hook_irq(void *hook_data
, void *call_data
)
808 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
809 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
810 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
812 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
814 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
815 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
816 struct marker_info
*minfo
;
819 e
= ltt_tracefile_get_event(tfc
->tf
);
821 LttTime evtime
= ltt_event_time(e
);
823 LttTrace
*trace
= tfc
->t_context
->t
;
825 /* we are in a execmode, before the state update. We must draw the
826 * items corresponding to the state before it changes : now is the right
832 guint cpu
= tfs
->cpu
;
835 * Check for LTT_CHANNEL_KERNEL channel name and event ID
836 * corresponding to LTT_EVENT_IRQ_ENTRY or LTT_EVENT_IRQ_EXIT.
838 if (tfc
->tf
->name
!= LTT_CHANNEL_KERNEL
)
840 minfo
= marker_get_info_from_id(tfc
->tf
->mdata
, e
->event_id
);
841 g_assert(minfo
!= NULL
);
842 if (minfo
->name
== LTT_EVENT_IRQ_ENTRY
) {
843 irq
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
844 } else if (minfo
->name
== LTT_EVENT_IRQ_EXIT
) {
845 irq
= ts
->cpu_states
[cpu
].last_irq
;
849 guint trace_num
= ts
->parent
.index
;
851 /* Well, the process_out existed : we must get it in the process hash
852 * or add it, and draw its items.
854 /* Add process to process list (if not present) */
856 HashedResourceData
*hashed_process_data
= NULL
;
857 ProcessList
*process_list
= resourceview_data
->process_list
;
859 hashed_process_data
= resourcelist_obtain_irq(resourceview_data
, trace_num
, irq
);
860 // TODO: fix this, it's ugly and slow:
864 str
= g_strdup_printf("IRQ %llu [%s]", irq
, (char*)g_quark_to_string(ts
->irq_names
[irq
]));
865 name
= g_quark_from_string(str
);
868 gtk_tree_store_set(resourceview_data
->process_list
->list_store
, &hashed_process_data
->y_iter
, NAME_COLUMN
, g_quark_to_string(name
), -1);
870 /* Now, the process is in the state hash and our own process hash.
871 * We definitely can draw the items related to the ending state.
874 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
877 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
878 TimeWindow time_window
=
879 lttvwindow_get_time_window(resourceview_data
->tab
);
882 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
883 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
886 Drawing_t
*drawing
= resourceview_data
->drawing
;
887 guint width
= drawing
->width
;
889 convert_time_to_pixels(
895 /* Draw collision indicator */
896 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
897 gdk_draw_point(hashed_process_data
->pixmap
,
900 COLLISION_POSITION(hashed_process_data
->height
));
901 hashed_process_data
->x
.middle_marked
= TRUE
;
905 TimeWindow time_window
=
906 lttvwindow_get_time_window(resourceview_data
->tab
);
909 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
910 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
913 Drawing_t
*drawing
= resourceview_data
->drawing
;
914 guint width
= drawing
->width
;
917 convert_time_to_pixels(
924 /* Jump over draw if we are at the same x position */
925 if(unlikely(x
== hashed_process_data
->x
.middle
&&
926 hashed_process_data
->x
.middle_used
))
928 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
929 /* Draw collision indicator */
930 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
931 gdk_draw_point(hashed_process_data
->pixmap
,
934 COLLISION_POSITION(hashed_process_data
->height
));
935 hashed_process_data
->x
.middle_marked
= TRUE
;
941 DrawContext draw_context
;
942 /* Now create the drawing context that will be used to draw
943 * items related to the last state. */
944 draw_context
.drawable
= hashed_process_data
->pixmap
;
945 draw_context
.gc
= drawing
->gc
;
946 draw_context
.pango_layout
= drawing
->pango_layout
;
947 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
948 draw_context
.drawinfo
.end
.x
= x
;
950 draw_context
.drawinfo
.y
.over
= 1;
951 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
952 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
954 draw_context
.drawinfo
.start
.offset
.over
= 0;
955 draw_context
.drawinfo
.start
.offset
.middle
= 0;
956 draw_context
.drawinfo
.start
.offset
.under
= 0;
957 draw_context
.drawinfo
.end
.offset
.over
= 0;
958 draw_context
.drawinfo
.end
.offset
.middle
= 0;
959 draw_context
.drawinfo
.end
.offset
.under
= 0;
963 PropertiesLine prop_line
;
964 prop_line
.line_width
= STATE_LINE_WIDTH
;
965 prop_line
.style
= GDK_LINE_SOLID
;
966 prop_line
.y
= MIDDLE
;
967 irq_set_line_color(&prop_line
, &ts
->irq_states
[irq
]);
968 draw_line((void*)&prop_line
, (void*)&draw_context
);
970 /* become the last x position */
971 hashed_process_data
->x
.middle
= x
;
972 hashed_process_data
->x
.middle_used
= TRUE
;
973 hashed_process_data
->x
.middle_marked
= FALSE
;
975 /* Calculate the next good time */
976 convert_pixels_to_time(width
, x
+1, time_window
,
977 &hashed_process_data
->next_good_time
);
984 int before_execmode_hook_soft_irq(void *hook_data
, void *call_data
)
986 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
987 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
988 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
990 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
992 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
993 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
994 struct marker_info
*minfo
;
997 e
= ltt_tracefile_get_event(tfc
->tf
);
999 LttTime evtime
= ltt_event_time(e
);
1001 LttTrace
*trace
= tfc
->t_context
->t
;
1003 /* we are in a execmode, before the state update. We must draw the
1004 * items corresponding to the state before it changes : now is the right
1010 guint cpu
= tfs
->cpu
;
1013 * Check for LTT_CHANNEL_KERNEL channel name and event ID
1014 * corresponding to LTT_EVENT_SOFT_IRQ_RAISE, LTT_EVENT_SOFT_IRQ_ENTRY
1015 * or LTT_EVENT_SOFT_IRQ_EXIT.
1017 if (tfc
->tf
->name
!= LTT_CHANNEL_KERNEL
)
1019 minfo
= marker_get_info_from_id(tfc
->tf
->mdata
, e
->event_id
);
1020 g_assert(minfo
!= NULL
);
1021 if (minfo
->name
== LTT_EVENT_SOFT_IRQ_RAISE
1022 || minfo
->name
== LTT_EVENT_SOFT_IRQ_ENTRY
) {
1023 softirq
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
1024 } else if (minfo
->name
== LTT_EVENT_SOFT_IRQ_EXIT
) {
1025 softirq
= ts
->cpu_states
[cpu
].last_soft_irq
;
1029 guint trace_num
= ts
->parent
.index
;
1031 /* Well, the process_out existed : we must get it in the process hash
1032 * or add it, and draw its items.
1034 /* Add process to process list (if not present) */
1035 guint pl_height
= 0;
1036 HashedResourceData
*hashed_process_data
= NULL
;
1037 ProcessList
*process_list
= resourceview_data
->process_list
;
1039 hashed_process_data
= resourcelist_obtain_soft_irq(resourceview_data
, trace_num
, softirq
);
1041 /* Now, the process is in the state hash and our own process hash.
1042 * We definitely can draw the items related to the ending state.
1045 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1048 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1049 TimeWindow time_window
=
1050 lttvwindow_get_time_window(resourceview_data
->tab
);
1053 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1054 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1056 #endif //EXTRA_CHECK
1057 Drawing_t
*drawing
= resourceview_data
->drawing
;
1058 guint width
= drawing
->width
;
1060 convert_time_to_pixels(
1066 /* Draw collision indicator */
1067 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1068 gdk_draw_point(hashed_process_data
->pixmap
,
1071 COLLISION_POSITION(hashed_process_data
->height
));
1072 hashed_process_data
->x
.middle_marked
= TRUE
;
1076 TimeWindow time_window
=
1077 lttvwindow_get_time_window(resourceview_data
->tab
);
1080 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1081 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1083 #endif //EXTRA_CHECK
1084 Drawing_t
*drawing
= resourceview_data
->drawing
;
1085 guint width
= drawing
->width
;
1088 convert_time_to_pixels(
1095 /* Jump over draw if we are at the same x position */
1096 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1097 hashed_process_data
->x
.middle_used
))
1099 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1100 /* Draw collision indicator */
1101 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1102 gdk_draw_point(hashed_process_data
->pixmap
,
1105 COLLISION_POSITION(hashed_process_data
->height
));
1106 hashed_process_data
->x
.middle_marked
= TRUE
;
1112 DrawContext draw_context
;
1113 /* Now create the drawing context that will be used to draw
1114 * items related to the last state. */
1115 draw_context
.drawable
= hashed_process_data
->pixmap
;
1116 draw_context
.gc
= drawing
->gc
;
1117 draw_context
.pango_layout
= drawing
->pango_layout
;
1118 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1119 draw_context
.drawinfo
.end
.x
= x
;
1121 draw_context
.drawinfo
.y
.over
= 1;
1122 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1123 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1125 draw_context
.drawinfo
.start
.offset
.over
= 0;
1126 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1127 draw_context
.drawinfo
.start
.offset
.under
= 0;
1128 draw_context
.drawinfo
.end
.offset
.over
= 0;
1129 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1130 draw_context
.drawinfo
.end
.offset
.under
= 0;
1134 PropertiesLine prop_line
;
1135 prop_line
.line_width
= STATE_LINE_WIDTH
;
1136 prop_line
.style
= GDK_LINE_SOLID
;
1137 prop_line
.y
= MIDDLE
;
1138 soft_irq_set_line_color(&prop_line
, &ts
->soft_irq_states
[softirq
]);
1139 draw_line((void*)&prop_line
, (void*)&draw_context
);
1141 /* become the last x position */
1142 hashed_process_data
->x
.middle
= x
;
1143 hashed_process_data
->x
.middle_used
= TRUE
;
1144 hashed_process_data
->x
.middle_marked
= FALSE
;
1146 /* Calculate the next good time */
1147 convert_pixels_to_time(width
, x
+1, time_window
,
1148 &hashed_process_data
->next_good_time
);
1155 int before_execmode_hook_trap(void *hook_data
, void *call_data
)
1157 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
1158 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
1159 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
1161 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1163 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1164 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1165 struct marker_info
*minfo
;
1168 e
= ltt_tracefile_get_event(tfc
->tf
);
1170 LttTime evtime
= ltt_event_time(e
);
1172 LttTrace
*trace
= tfc
->t_context
->t
;
1174 /* we are in a execmode, before the state update. We must draw the
1175 * items corresponding to the state before it changes : now is the right
1181 guint cpu
= tfs
->cpu
;
1184 * Check for LTT_CHANNEL_KERNEL channel name and event ID
1185 * corresponding to LTT_EVENT_TRAP_ENTRY or LTT_EVENT_TRAP_EXIT.
1187 if (tfc
->tf
->name
!= LTT_CHANNEL_KERNEL
)
1189 minfo
= marker_get_info_from_id(tfc
->tf
->mdata
, e
->event_id
);
1190 g_assert(minfo
!= NULL
);
1191 if (minfo
->name
== LTT_EVENT_TRAP_ENTRY
) {
1192 trap
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
1193 } else if (minfo
->name
== LTT_EVENT_TRAP_EXIT
) {
1194 trap
= ts
->cpu_states
[cpu
].last_trap
;
1198 guint trace_num
= ts
->parent
.index
;
1200 /* Well, the process_out existed : we must get it in the process hash
1201 * or add it, and draw its items.
1203 /* Add process to process list (if not present) */
1204 guint pl_height
= 0;
1205 HashedResourceData
*hashed_process_data
= NULL
;
1206 ProcessList
*process_list
= resourceview_data
->process_list
;
1208 hashed_process_data
= resourcelist_obtain_trap(resourceview_data
, trace_num
, trap
);
1210 /* Now, the process is in the state hash and our own process hash.
1211 * We definitely can draw the items related to the ending state.
1214 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1217 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1218 TimeWindow time_window
=
1219 lttvwindow_get_time_window(resourceview_data
->tab
);
1222 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1223 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1225 #endif //EXTRA_CHECK
1226 Drawing_t
*drawing
= resourceview_data
->drawing
;
1227 guint width
= drawing
->width
;
1229 convert_time_to_pixels(
1235 /* Draw collision indicator */
1236 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1237 gdk_draw_point(hashed_process_data
->pixmap
,
1240 COLLISION_POSITION(hashed_process_data
->height
));
1241 hashed_process_data
->x
.middle_marked
= TRUE
;
1245 TimeWindow time_window
=
1246 lttvwindow_get_time_window(resourceview_data
->tab
);
1249 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1250 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1252 #endif //EXTRA_CHECK
1253 Drawing_t
*drawing
= resourceview_data
->drawing
;
1254 guint width
= drawing
->width
;
1257 convert_time_to_pixels(
1264 /* Jump over draw if we are at the same x position */
1265 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1266 hashed_process_data
->x
.middle_used
))
1268 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
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
;
1281 DrawContext draw_context
;
1282 /* Now create the drawing context that will be used to draw
1283 * items related to the last state. */
1284 draw_context
.drawable
= hashed_process_data
->pixmap
;
1285 draw_context
.gc
= drawing
->gc
;
1286 draw_context
.pango_layout
= drawing
->pango_layout
;
1287 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1288 draw_context
.drawinfo
.end
.x
= x
;
1290 draw_context
.drawinfo
.y
.over
= 1;
1291 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1292 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1294 draw_context
.drawinfo
.start
.offset
.over
= 0;
1295 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1296 draw_context
.drawinfo
.start
.offset
.under
= 0;
1297 draw_context
.drawinfo
.end
.offset
.over
= 0;
1298 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1299 draw_context
.drawinfo
.end
.offset
.under
= 0;
1303 PropertiesLine prop_line
;
1304 prop_line
.line_width
= STATE_LINE_WIDTH
;
1305 prop_line
.style
= GDK_LINE_SOLID
;
1306 prop_line
.y
= MIDDLE
;
1307 trap_set_line_color(&prop_line
, &ts
->trap_states
[trap
]);
1308 draw_line((void*)&prop_line
, (void*)&draw_context
);
1310 /* become the last x position */
1311 hashed_process_data
->x
.middle
= x
;
1312 hashed_process_data
->x
.middle_used
= TRUE
;
1313 hashed_process_data
->x
.middle_marked
= FALSE
;
1315 /* Calculate the next good time */
1316 convert_pixels_to_time(width
, x
+1, time_window
,
1317 &hashed_process_data
->next_good_time
);
1325 int before_bdev_event_hook(void *hook_data
, void *call_data
)
1327 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
1328 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
1329 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
1331 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1333 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1334 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1337 e
= ltt_tracefile_get_event(tfc
->tf
);
1339 LttTime evtime
= ltt_event_time(e
);
1341 /* we are in a execmode, before the state update. We must draw the
1342 * items corresponding to the state before it changes : now is the right
1347 guint cpu
= tfs
->cpu
;
1348 guint8 major
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
1349 guint8 minor
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 1));
1350 guint oper
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 2));
1351 gint devcode_gint
= MKDEV(major
,minor
);
1353 guint trace_num
= ts
->parent
.index
;
1355 LttvBdevState
*bdev
= g_hash_table_lookup(ts
->bdev_states
, &devcode_gint
);
1356 /* the result of the lookup might be NULL. that's ok, the rest of the function
1357 should understand it was not found and that its state is unknown */
1359 /* Well, the process_out existed : we must get it in the process hash
1360 * or add it, and draw its items.
1362 /* Add process to process list (if not present) */
1363 guint pl_height
= 0;
1364 HashedResourceData
*hashed_process_data
= NULL
;
1365 ProcessList
*process_list
= resourceview_data
->process_list
;
1366 // LttTime birth = process->creation_time;
1368 // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1369 // hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1371 hashed_process_data
= resourcelist_obtain_bdev(resourceview_data
, trace_num
, devcode_gint
);
1372 ////hashed_process_data = processlist_get_process_data(process_list, resourceq, trace_num);
1373 // hashed_process_data = processlist_get_process_data(process_list,
1379 /* Set the current process */
1380 // process_list->current_hash_data[trace_num][process->cpu] =
1381 // hashed_process_data;
1384 /* Now, the process is in the state hash and our own process hash.
1385 * We definitely can draw the items related to the ending state.
1388 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1391 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1392 TimeWindow time_window
=
1393 lttvwindow_get_time_window(resourceview_data
->tab
);
1396 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1397 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1399 #endif //EXTRA_CHECK
1400 Drawing_t
*drawing
= resourceview_data
->drawing
;
1401 guint width
= drawing
->width
;
1403 convert_time_to_pixels(
1409 /* Draw collision indicator */
1410 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1411 gdk_draw_point(hashed_process_data
->pixmap
,
1414 COLLISION_POSITION(hashed_process_data
->height
));
1415 hashed_process_data
->x
.middle_marked
= TRUE
;
1419 TimeWindow time_window
=
1420 lttvwindow_get_time_window(resourceview_data
->tab
);
1423 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1424 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1426 #endif //EXTRA_CHECK
1427 Drawing_t
*drawing
= resourceview_data
->drawing
;
1428 guint width
= drawing
->width
;
1431 convert_time_to_pixels(
1438 /* Jump over draw if we are at the same x position */
1439 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1440 hashed_process_data
->x
.middle_used
))
1442 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1443 /* Draw collision indicator */
1444 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1445 gdk_draw_point(hashed_process_data
->pixmap
,
1448 COLLISION_POSITION(hashed_process_data
->height
));
1449 hashed_process_data
->x
.middle_marked
= TRUE
;
1455 DrawContext draw_context
;
1456 /* Now create the drawing context that will be used to draw
1457 * items related to the last state. */
1458 draw_context
.drawable
= hashed_process_data
->pixmap
;
1459 draw_context
.gc
= drawing
->gc
;
1460 draw_context
.pango_layout
= drawing
->pango_layout
;
1461 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1462 draw_context
.drawinfo
.end
.x
= x
;
1464 draw_context
.drawinfo
.y
.over
= 1;
1465 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1466 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1468 draw_context
.drawinfo
.start
.offset
.over
= 0;
1469 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1470 draw_context
.drawinfo
.start
.offset
.under
= 0;
1471 draw_context
.drawinfo
.end
.offset
.over
= 0;
1472 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1473 draw_context
.drawinfo
.end
.offset
.under
= 0;
1477 PropertiesLine prop_line
;
1478 prop_line
.line_width
= STATE_LINE_WIDTH
;
1479 prop_line
.style
= GDK_LINE_SOLID
;
1480 prop_line
.y
= MIDDLE
;
1481 bdev_set_line_color(&prop_line
, bdev
);
1482 draw_line((void*)&prop_line
, (void*)&draw_context
);
1484 /* become the last x position */
1485 hashed_process_data
->x
.middle
= x
;
1486 hashed_process_data
->x
.middle_used
= TRUE
;
1487 hashed_process_data
->x
.middle_marked
= FALSE
;
1489 /* Calculate the next good time */
1490 convert_pixels_to_time(width
, x
+1, time_window
,
1491 &hashed_process_data
->next_good_time
);
1498 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1500 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
1501 Drawing_t
*drawing
= resourceview_data
->drawing
;
1502 ProcessList
*process_list
= resourceview_data
->process_list
;
1504 const TimeWindowNotifyData
*time_window_nofify_data
=
1505 ((const TimeWindowNotifyData
*)call_data
);
1507 TimeWindow
*old_time_window
=
1508 time_window_nofify_data
->old_time_window
;
1509 TimeWindow
*new_time_window
=
1510 time_window_nofify_data
->new_time_window
;
1512 /* Update the ruler */
1513 drawing_update_ruler(resourceview_data
->drawing
,
1517 /* Two cases : zoom in/out or scrolling */
1519 /* In order to make sure we can reuse the old drawing, the scale must
1520 * be the same and the new time interval being partly located in the
1521 * currently shown time interval. (reuse is only for scrolling)
1524 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
1525 old_time_window
->start_time
.tv_sec
,
1526 old_time_window
->start_time
.tv_nsec
,
1527 old_time_window
->time_width
.tv_sec
,
1528 old_time_window
->time_width
.tv_nsec
);
1530 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
1531 new_time_window
->start_time
.tv_sec
,
1532 new_time_window
->start_time
.tv_nsec
,
1533 new_time_window
->time_width
.tv_sec
,
1534 new_time_window
->time_width
.tv_nsec
);
1536 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1537 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1539 /* Same scale (scrolling) */
1540 g_info("scrolling");
1541 LttTime
*ns
= &new_time_window
->start_time
;
1542 LttTime
*nw
= &new_time_window
->time_width
;
1543 LttTime
*os
= &old_time_window
->start_time
;
1544 LttTime
*ow
= &old_time_window
->time_width
;
1545 LttTime old_end
= old_time_window
->end_time
;
1546 LttTime new_end
= new_time_window
->end_time
;
1548 //if(ns<os+w && os+w<ns+w)
1549 //if(ns<old_end && os<ns)
1550 if(ltt_time_compare(*ns
, old_end
) == -1
1551 && ltt_time_compare(*os
, *ns
) == -1)
1553 g_info("scrolling near right");
1554 /* Scroll right, keep right part of the screen */
1556 guint width
= resourceview_data
->drawing
->width
;
1557 convert_time_to_pixels(
1563 /* Copy old data to new location */
1564 copy_pixmap_region(process_list
,
1566 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1570 resourceview_data
->drawing
->width
-x
+SAFETY
, -1);
1572 if(drawing
->damage_begin
== drawing
->damage_end
)
1573 drawing
->damage_begin
= resourceview_data
->drawing
->width
-x
;
1575 drawing
->damage_begin
= 0;
1577 drawing
->damage_end
= resourceview_data
->drawing
->width
;
1579 /* Clear the data request background, but not SAFETY */
1580 rectangle_pixmap(process_list
,
1581 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1583 drawing
->damage_begin
+SAFETY
, 0,
1584 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1586 gtk_widget_queue_draw(drawing
->drawing_area
);
1588 /* Get new data for the rest. */
1589 drawing_data_request(resourceview_data
->drawing
,
1590 drawing
->damage_begin
, 0,
1591 drawing
->damage_end
- drawing
->damage_begin
,
1592 resourceview_data
->drawing
->height
);
1594 if(ltt_time_compare(*ns
,*os
) == -1
1595 && ltt_time_compare(*os
,new_end
) == -1)
1597 g_info("scrolling near left");
1598 /* Scroll left, keep left part of the screen */
1600 guint width
= resourceview_data
->drawing
->width
;
1601 convert_time_to_pixels(
1607 /* Copy old data to new location */
1608 copy_pixmap_region (process_list
,
1610 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1616 if(drawing
->damage_begin
== drawing
->damage_end
)
1617 drawing
->damage_end
= x
;
1619 drawing
->damage_end
=
1620 resourceview_data
->drawing
->width
;
1622 drawing
->damage_begin
= 0;
1624 rectangle_pixmap (process_list
,
1625 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1627 drawing
->damage_begin
, 0,
1628 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1631 gtk_widget_queue_draw(drawing
->drawing_area
);
1633 /* Get new data for the rest. */
1634 drawing_data_request(resourceview_data
->drawing
,
1635 drawing
->damage_begin
, 0,
1636 drawing
->damage_end
- drawing
->damage_begin
,
1637 resourceview_data
->drawing
->height
);
1640 if(ltt_time_compare(*ns
,*os
) == 0)
1642 g_info("not scrolling");
1644 g_info("scrolling far");
1645 /* Cannot reuse any part of the screen : far jump */
1648 rectangle_pixmap (process_list
,
1649 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1652 resourceview_data
->drawing
->width
+SAFETY
, // do not overlap
1655 gtk_widget_queue_draw(drawing
->drawing_area
);
1657 drawing
->damage_begin
= 0;
1658 drawing
->damage_end
= resourceview_data
->drawing
->width
;
1660 drawing_data_request(resourceview_data
->drawing
,
1662 resourceview_data
->drawing
->width
,
1663 resourceview_data
->drawing
->height
);
1669 /* Different scale (zoom) */
1672 rectangle_pixmap (process_list
,
1673 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1676 resourceview_data
->drawing
->width
+SAFETY
, // do not overlap
1679 gtk_widget_queue_draw(drawing
->drawing_area
);
1681 drawing
->damage_begin
= 0;
1682 drawing
->damage_end
= resourceview_data
->drawing
->width
;
1684 drawing_data_request(resourceview_data
->drawing
,
1686 resourceview_data
->drawing
->width
,
1687 resourceview_data
->drawing
->height
);
1690 /* Update directly when scrolling */
1691 gdk_window_process_updates(resourceview_data
->drawing
->drawing_area
->window
,
1697 gint
traceset_notify(void *hook_data
, void *call_data
)
1699 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
1700 Drawing_t
*drawing
= resourceview_data
->drawing
;
1702 if(unlikely(drawing
->gc
== NULL
)) {
1705 if(drawing
->dotted_gc
== NULL
) {
1709 drawing_clear(resourceview_data
->drawing
);
1710 processlist_clear(resourceview_data
->process_list
);
1711 gtk_widget_set_size_request(
1712 resourceview_data
->drawing
->drawing_area
,
1713 -1, processlist_get_height(resourceview_data
->process_list
));
1714 redraw_notify(resourceview_data
, NULL
);
1716 request_background_data(resourceview_data
);
1721 gint
redraw_notify(void *hook_data
, void *call_data
)
1723 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
1724 Drawing_t
*drawing
= resourceview_data
->drawing
;
1725 GtkWidget
*widget
= drawing
->drawing_area
;
1727 drawing
->damage_begin
= 0;
1728 drawing
->damage_end
= drawing
->width
;
1730 /* fun feature, to be separated someday... */
1731 drawing_clear(resourceview_data
->drawing
);
1732 processlist_clear(resourceview_data
->process_list
);
1733 gtk_widget_set_size_request(
1734 resourceview_data
->drawing
->drawing_area
,
1735 -1, processlist_get_height(resourceview_data
->process_list
));
1737 rectangle_pixmap (resourceview_data
->process_list
,
1738 widget
->style
->black_gc
,
1741 drawing
->alloc_width
,
1744 gtk_widget_queue_draw(drawing
->drawing_area
);
1746 if(drawing
->damage_begin
< drawing
->damage_end
)
1748 drawing_data_request(drawing
,
1749 drawing
->damage_begin
,
1751 drawing
->damage_end
-drawing
->damage_begin
,
1760 gint
continue_notify(void *hook_data
, void *call_data
)
1762 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
1763 Drawing_t
*drawing
= resourceview_data
->drawing
;
1765 if(drawing
->damage_begin
< drawing
->damage_end
)
1767 drawing_data_request(drawing
,
1768 drawing
->damage_begin
,
1770 drawing
->damage_end
-drawing
->damage_begin
,
1778 gint
update_current_time_hook(void *hook_data
, void *call_data
)
1780 ControlFlowData
*resourceview_data
= (ControlFlowData
*)hook_data
;
1781 Drawing_t
*drawing
= resourceview_data
->drawing
;
1783 LttTime current_time
= *((LttTime
*)call_data
);
1785 TimeWindow time_window
=
1786 lttvwindow_get_time_window(resourceview_data
->tab
);
1788 LttTime time_begin
= time_window
.start_time
;
1789 LttTime width
= time_window
.time_width
;
1792 guint64 time_ll
= ltt_time_to_uint64(width
);
1793 time_ll
= time_ll
>> 1; /* divide by two */
1794 half_width
= ltt_time_from_uint64(time_ll
);
1796 LttTime time_end
= ltt_time_add(time_begin
, width
);
1798 LttvTracesetContext
* tsc
=
1799 lttvwindow_get_traceset_context(resourceview_data
->tab
);
1801 LttTime trace_start
= tsc
->time_span
.start_time
;
1802 LttTime trace_end
= tsc
->time_span
.end_time
;
1804 g_info("New current time HOOK : %lu, %lu", current_time
.tv_sec
,
1805 current_time
.tv_nsec
);
1807 /* If current time is inside time interval, just move the highlight
1810 /* Else, we have to change the time interval. We have to tell it
1811 * to the main window. */
1812 /* The time interval change will take care of placing the current
1813 * time at the center of the visible area, or nearest possible if we are
1814 * at one end of the trace. */
1817 if(ltt_time_compare(current_time
, time_begin
) < 0)
1819 TimeWindow new_time_window
;
1821 if(ltt_time_compare(current_time
,
1822 ltt_time_add(trace_start
,half_width
)) < 0)
1823 time_begin
= trace_start
;
1825 time_begin
= ltt_time_sub(current_time
,half_width
);
1827 new_time_window
.start_time
= time_begin
;
1828 new_time_window
.time_width
= width
;
1829 new_time_window
.time_width_double
= ltt_time_to_double(width
);
1830 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
1832 lttvwindow_report_time_window(resourceview_data
->tab
, new_time_window
);
1834 else if(ltt_time_compare(current_time
, time_end
) > 0)
1836 TimeWindow new_time_window
;
1838 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) > 0)
1839 time_begin
= ltt_time_sub(trace_end
,width
);
1841 time_begin
= ltt_time_sub(current_time
,half_width
);
1843 new_time_window
.start_time
= time_begin
;
1844 new_time_window
.time_width
= width
;
1845 new_time_window
.time_width_double
= ltt_time_to_double(width
);
1846 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
1848 lttvwindow_report_time_window(resourceview_data
->tab
, new_time_window
);
1851 gtk_widget_queue_draw(resourceview_data
->drawing
->drawing_area
);
1853 /* Update directly when scrolling */
1854 gdk_window_process_updates(resourceview_data
->drawing
->drawing_area
->window
,
1860 typedef struct _ClosureData
{
1861 EventsRequest
*events_request
;
1862 LttvTracesetState
*tss
;
1867 /* Draw line until end of the screen */
1869 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1871 ResourceUniqueNumeric
*process_info
= (ResourceUniqueNumeric
*)key
;
1872 HashedResourceData
*hashed_process_data
= (HashedResourceData
*)value
;
1873 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1875 EventsRequest
*events_request
= closure_data
->events_request
;
1876 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
1878 LttvTracesetState
*tss
= closure_data
->tss
;
1879 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
1881 LttTime evtime
= closure_data
->end_time
;
1883 gboolean dodraw
= TRUE
;
1885 if(hashed_process_data
->type
== RV_RESOURCE_MACHINE
)
1889 /* For the process */
1890 /* First, check if the current process is in the state computation
1891 * process list. If it is there, that means we must add it right now and
1892 * draw items from the beginning of the read for it. If it is not
1893 * present, it's a new process and it was not present : it will
1894 * be added after the state update. */
1896 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
1897 #endif //EXTRA_CHECK
1898 LttvTraceContext
*tc
= tsc
->traces
[process_info
->trace_num
];
1899 LttvTraceState
*ts
= (LttvTraceState
*)tc
;
1901 /* Only draw for processes that are currently in the trace states */
1903 ProcessList
*process_list
= resourceview_data
->process_list
;
1905 /* Should be alike when background info is ready */
1906 if(resourceview_data
->background_info_waiting
==0)
1907 g_assert(ltt_time_compare(process
->creation_time
,
1908 process_info
->birth
) == 0);
1909 #endif //EXTRA_CHECK
1911 /* Now, the process is in the state hash and our own process hash.
1912 * We definitely can draw the items related to the ending state.
1915 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
1918 TimeWindow time_window
=
1919 lttvwindow_get_time_window(resourceview_data
->tab
);
1922 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1923 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1925 #endif //EXTRA_CHECK
1926 Drawing_t
*drawing
= resourceview_data
->drawing
;
1927 guint width
= drawing
->width
;
1929 guint x
= closure_data
->x_end
;
1931 DrawContext draw_context
;
1933 /* Now create the drawing context that will be used to draw
1934 * items related to the last state. */
1935 draw_context
.drawable
= hashed_process_data
->pixmap
;
1936 draw_context
.gc
= drawing
->gc
;
1937 draw_context
.pango_layout
= drawing
->pango_layout
;
1938 draw_context
.drawinfo
.end
.x
= x
;
1940 draw_context
.drawinfo
.y
.over
= 1;
1941 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1942 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1944 draw_context
.drawinfo
.start
.offset
.over
= 0;
1945 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1946 draw_context
.drawinfo
.start
.offset
.under
= 0;
1947 draw_context
.drawinfo
.end
.offset
.over
= 0;
1948 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1949 draw_context
.drawinfo
.end
.offset
.under
= 0;
1951 /* Jump over draw if we are at the same x position */
1952 if(x
== hashed_process_data
->x
.over
)
1956 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
1958 PropertiesLine prop_line
= prepare_execmode_line(process
);
1959 draw_line((void*)&prop_line
, (void*)&draw_context
);
1961 hashed_process_data
->x
.over
= x
;
1965 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1966 hashed_process_data
->x
.middle_used
)) {
1967 #if 0 /* do not mark closure : not missing information */
1968 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
1969 /* Draw collision indicator */
1970 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1971 gdk_draw_point(drawing
->pixmap
,
1975 hashed_process_data
->x
.middle_marked
= TRUE
;
1980 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1983 PropertiesLine prop_line
;
1984 prop_line
.line_width
= STATE_LINE_WIDTH
;
1985 prop_line
.style
= GDK_LINE_SOLID
;
1986 prop_line
.y
= MIDDLE
;
1987 if(hashed_process_data
->type
== RV_RESOURCE_CPU
)
1988 cpu_set_line_color(&prop_line
, &ts
->cpu_states
[process_info
->id
]);
1989 else if(hashed_process_data
->type
== RV_RESOURCE_IRQ
)
1990 irq_set_line_color(&prop_line
, &ts
->irq_states
[process_info
->id
]);
1991 else if(hashed_process_data
->type
== RV_RESOURCE_SOFT_IRQ
)
1992 soft_irq_set_line_color(&prop_line
, &ts
->soft_irq_states
[process_info
->id
]);
1993 else if(hashed_process_data
->type
== RV_RESOURCE_TRAP
)
1994 trap_set_line_color(&prop_line
, &ts
->trap_states
[process_info
->id
]);
1995 else if(hashed_process_data
->type
== RV_RESOURCE_BDEV
) {
1996 gint devcode_gint
= process_info
->id
;
1997 LttvBdevState
*bdev
= g_hash_table_lookup(ts
->bdev_states
, &devcode_gint
);
1998 // the lookup may return null; bdev_set_line_color must act appropriately
1999 bdev_set_line_color(&prop_line
, bdev
);
2002 draw_line((void*)&prop_line
, (void*)&draw_context
);
2005 /* become the last x position */
2006 if(likely(x
!= hashed_process_data
->x
.middle
)) {
2007 hashed_process_data
->x
.middle
= x
;
2008 /* but don't use the pixel */
2009 hashed_process_data
->x
.middle_used
= FALSE
;
2011 /* Calculate the next good time */
2012 convert_pixels_to_time(width
, x
+1, time_window
,
2013 &hashed_process_data
->next_good_time
);
2020 int before_chunk(void *hook_data
, void *call_data
)
2022 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2023 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2024 ControlFlowData
*cfd
= (ControlFlowData
*)events_request
->viewer_data
;
2026 /* Deactivate sort */
2027 gtk_tree_sortable_set_sort_column_id(
2028 GTK_TREE_SORTABLE(cfd
->process_list
->list_store
),
2030 GTK_SORT_ASCENDING
);
2032 drawing_chunk_begin(events_request
, tss
);
2039 * This gets executed just before an events request is executed
2042 int before_request(void *hook_data
, void *call_data
)
2044 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2045 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2047 drawing_data_request_begin(events_request
, tss
);
2054 * after request is necessary in addition of after chunk in order to draw
2055 * lines until the end of the screen. after chunk just draws lines until
2062 int after_request(void *hook_data
, void *call_data
)
2065 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2066 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
2067 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2069 ProcessList
*process_list
= resourceview_data
->process_list
;
2070 LttTime end_time
= events_request
->end_time
;
2072 ClosureData closure_data
;
2073 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2074 closure_data
.tss
= tss
;
2075 closure_data
.end_time
= end_time
;
2077 TimeWindow time_window
=
2078 lttvwindow_get_time_window(resourceview_data
->tab
);
2079 guint width
= resourceview_data
->drawing
->width
;
2080 convert_time_to_pixels(
2084 &closure_data
.x_end
);
2087 /* Draw last items */
2088 for(i
=0; i
<RV_RESOURCE_COUNT
; i
++) {
2089 g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data
, i
), draw_closure
,
2090 (void*)&closure_data
);
2093 /* Request expose */
2094 drawing_request_expose(events_request
, tss
, end_time
);
2103 int after_chunk(void *hook_data
, void *call_data
)
2105 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2106 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
2107 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2108 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
2109 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
2112 ProcessList
*process_list
= resourceview_data
->process_list
;
2114 LttvTraceset
*traceset
= tsc
->ts
;
2115 guint nb_trace
= lttv_traceset_number(traceset
);
2117 /* Only execute when called for the first trace's events request */
2118 if(!process_list
->current_hash_data
) return;
2120 for(i
= 0 ; i
< nb_trace
; i
++) {
2121 g_free(process_list
->current_hash_data
[i
]);
2123 g_free(process_list
->current_hash_data
);
2124 process_list
->current_hash_data
= NULL
;
2127 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
2128 else /* end of traceset, or position now out of request : end */
2129 end_time
= events_request
->end_time
;
2131 ClosureData closure_data
;
2132 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2133 closure_data
.tss
= tss
;
2134 closure_data
.end_time
= end_time
;
2136 TimeWindow time_window
=
2137 lttvwindow_get_time_window(resourceview_data
->tab
);
2138 guint width
= resourceview_data
->drawing
->width
;
2139 convert_time_to_pixels(
2143 &closure_data
.x_end
);
2145 /* Draw last items */
2146 for(i
=0; i
<RV_RESOURCE_COUNT
; i
++) {
2147 g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data
, i
), draw_closure
,
2148 (void*)&closure_data
);
2151 /* Reactivate sort */
2152 gtk_tree_sortable_set_sort_column_id(
2153 GTK_TREE_SORTABLE(resourceview_data
->process_list
->list_store
),
2154 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
2155 GTK_SORT_ASCENDING
);
2157 update_index_to_pixmap(resourceview_data
->process_list
);
2158 /* Request a full expose : drawing scrambled */
2159 gtk_widget_queue_draw(resourceview_data
->drawing
->drawing_area
);
2161 /* Request expose (updates damages zone also) */
2162 drawing_request_expose(events_request
, tss
, end_time
);
2167 /* after_statedump_end
2169 * @param hook_data ControlFlowData structure of the viewer.
2170 * @param call_data Event context.
2172 * This function adds items to be drawn in a queue for each process.
2175 int before_statedump_end(void *hook_data
, void *call_data
)
2179 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
2180 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
2181 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
2183 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2185 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2187 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
2189 LttvTracesetState
*tss
= (LttvTracesetState
*)tfc
->t_context
->ts_context
;
2190 ProcessList
*process_list
= resourceview_data
->process_list
;
2193 e
= ltt_tracefile_get_event(tfc
->tf
);
2195 LttvFilter
*filter
= resourceview_data
->filter
;
2196 if(filter
!= NULL
&& filter
->head
!= NULL
)
2197 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
2198 tfc
->t_context
->t
,tfc
,NULL
,NULL
))
2201 LttTime evtime
= ltt_event_time(e
);
2203 ClosureData closure_data
;
2204 closure_data
.events_request
= events_request
;
2205 closure_data
.tss
= tss
;
2206 closure_data
.end_time
= evtime
;
2208 TimeWindow time_window
=
2209 lttvwindow_get_time_window(resourceview_data
->tab
);
2210 guint width
= resourceview_data
->drawing
->width
;
2211 convert_time_to_pixels(
2215 &closure_data
.x_end
);
2217 /* Draw last items */
2219 for(i
=0; i
<RV_RESOURCE_COUNT
; i
++) {
2220 g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data
, i
), draw_closure
,
2221 (void*)&closure_data
);
2224 /* Reactivate sort */
2225 gtk_tree_sortable_set_sort_column_id(
2226 GTK_TREE_SORTABLE(resourceview_data
->process_list
->list_store
),
2227 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
2228 GTK_SORT_ASCENDING
);
2230 update_index_to_pixmap(resourceview_data
->process_list
);
2231 /* Request a full expose : drawing scrambled */
2232 gtk_widget_queue_draw(resourceview_data
->drawing
->drawing_area
);
2234 /* Request expose (updates damages zone also) */
2235 drawing_request_expose(events_request
, tss
, evtime
);