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
61 //#include <pango/pango.h>
63 #include <ltt/event.h>
65 #include <ltt/trace.h>
67 #include <lttv/lttv.h>
68 #include <lttv/hook.h>
69 #include <lttv/state.h>
70 #include <lttvwindow/lttvwindow.h>
71 #include <lttvwindow/lttvwindowtraces.h>
72 #include <lttvwindow/support.h>
75 #include "eventhooks.h"
77 #include "processlist.h"
81 #define MAX_PATH_LEN 256
82 #define STATE_LINE_WIDTH 6
83 #define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3)
85 extern GSList
*g_legend_list
;
88 /* Action to do when background computation completed.
90 * Wait for all the awaited computations to be over.
93 static gint
background_ready(void *hook_data
, void *call_data
)
95 ControlFlowData
*resourceview_data
= (ControlFlowData
*)hook_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 int before_execmode_hook_irq(void *hook_data
, void *call_data
);
625 int before_execmode_hook_soft_irq(void *hook_data
, void *call_data
);
626 int before_execmode_hook_trap(void *hook_data
, void *call_data
);
628 /* before_execmode_hook
630 * This function basically draw lines and icons. Two types of lines are drawn :
631 * one small (3 pixels?) representing the state of the process and the second
632 * type is thicker (10 pixels?) representing on which CPU a process is running
633 * (and this only in running state).
635 * Extremums of the lines :
636 * x_min : time of the last event context for this process kept in memory.
637 * x_max : time of the current event.
638 * y : middle of the process in the process list. The process is found in the
639 * list, therefore is it's position in pixels.
641 * The choice of lines'color is defined by the context of the last event for this
645 int before_execmode_hook(void *hook_data
, void *call_data
)
647 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
648 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
649 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
651 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
653 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
654 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
657 e
= ltt_tracefile_get_event(tfc
->tf
);
659 LttTime evtime
= ltt_event_time(e
);
661 before_execmode_hook_irq(hook_data
, call_data
);
662 before_execmode_hook_soft_irq(hook_data
, call_data
);
663 before_execmode_hook_trap(hook_data
, call_data
);
665 /* we are in a execmode, before the state update. We must draw the
666 * items corresponding to the state before it changes : now is the right
670 guint cpu
= tfs
->cpu
;
672 guint trace_num
= ts
->parent
.index
;
673 LttvProcessState
*process
= ts
->running_process
[cpu
];
674 g_assert(process
!= NULL
);
676 /* Well, the process_out existed : we must get it in the process hash
677 * or add it, and draw its items.
679 /* Add process to process list (if not present) */
681 HashedResourceData
*hashed_process_data
= NULL
;
682 ProcessList
*process_list
= resourceview_data
->process_list
;
684 LttTime birth
= process
->creation_time
;
686 if(likely(process_list
->current_hash_data
[trace_num
][cpu
] != NULL
)) {
687 hashed_process_data
= process_list
->current_hash_data
[trace_num
][cpu
];
689 hashed_process_data
= resourcelist_obtain_cpu(resourceview_data
, trace_num
, cpu
);
691 /* Set the current process */
692 process_list
->current_hash_data
[trace_num
][process
->cpu
] =
696 /* Now, the process is in the state hash and our own process hash.
697 * We definitely can draw the items related to the ending state.
700 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
703 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
704 TimeWindow time_window
=
705 lttvwindow_get_time_window(resourceview_data
->tab
);
708 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
709 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
712 Drawing_t
*drawing
= resourceview_data
->drawing
;
713 guint width
= drawing
->width
;
715 convert_time_to_pixels(
721 /* Draw collision indicator */
722 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
723 gdk_draw_point(hashed_process_data
->pixmap
,
726 COLLISION_POSITION(hashed_process_data
->height
));
727 hashed_process_data
->x
.middle_marked
= TRUE
;
731 TimeWindow time_window
=
732 lttvwindow_get_time_window(resourceview_data
->tab
);
735 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
736 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
739 Drawing_t
*drawing
= resourceview_data
->drawing
;
740 guint width
= drawing
->width
;
743 convert_time_to_pixels(
750 /* Jump over draw if we are at the same x position */
751 if(unlikely(x
== hashed_process_data
->x
.middle
&&
752 hashed_process_data
->x
.middle_used
))
754 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
755 /* Draw collision indicator */
756 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
757 gdk_draw_point(hashed_process_data
->pixmap
,
760 COLLISION_POSITION(hashed_process_data
->height
));
761 hashed_process_data
->x
.middle_marked
= TRUE
;
767 DrawContext draw_context
;
768 /* Now create the drawing context that will be used to draw
769 * items related to the last state. */
770 draw_context
.drawable
= hashed_process_data
->pixmap
;
771 draw_context
.gc
= drawing
->gc
;
772 draw_context
.pango_layout
= drawing
->pango_layout
;
773 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
774 draw_context
.drawinfo
.end
.x
= x
;
776 draw_context
.drawinfo
.y
.over
= 1;
777 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
778 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
780 draw_context
.drawinfo
.start
.offset
.over
= 0;
781 draw_context
.drawinfo
.start
.offset
.middle
= 0;
782 draw_context
.drawinfo
.start
.offset
.under
= 0;
783 draw_context
.drawinfo
.end
.offset
.over
= 0;
784 draw_context
.drawinfo
.end
.offset
.middle
= 0;
785 draw_context
.drawinfo
.end
.offset
.under
= 0;
789 PropertiesLine prop_line
;
790 prop_line
.line_width
= STATE_LINE_WIDTH
;
791 prop_line
.style
= GDK_LINE_SOLID
;
792 prop_line
.y
= MIDDLE
;
793 cpu_set_line_color(&prop_line
, tfs
->cpu_state
);
794 draw_line((void*)&prop_line
, (void*)&draw_context
);
796 /* become the last x position */
797 hashed_process_data
->x
.middle
= x
;
798 hashed_process_data
->x
.middle_used
= TRUE
;
799 hashed_process_data
->x
.middle_marked
= FALSE
;
801 /* Calculate the next good time */
802 convert_pixels_to_time(width
, x
+1, time_window
,
803 &hashed_process_data
->next_good_time
);
810 int before_execmode_hook_irq(void *hook_data
, void *call_data
)
812 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
813 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
814 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
816 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
818 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
819 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
820 struct marker_info
*minfo
;
823 e
= ltt_tracefile_get_event(tfc
->tf
);
825 LttTime evtime
= ltt_event_time(e
);
827 LttTrace
*trace
= tfc
->t_context
->t
;
829 /* we are in a execmode, before the state update. We must draw the
830 * items corresponding to the state before it changes : now is the right
836 guint cpu
= tfs
->cpu
;
839 * Check for LTT_CHANNEL_KERNEL channel name and event ID
840 * corresponding to LTT_EVENT_IRQ_ENTRY or LTT_EVENT_IRQ_EXIT.
842 if (tfc
->tf
->name
!= LTT_CHANNEL_KERNEL
)
844 minfo
= marker_get_info_from_id(tfc
->tf
->mdata
, e
->event_id
);
845 g_assert(minfo
!= NULL
);
846 if (minfo
->name
== LTT_EVENT_IRQ_ENTRY
) {
847 irq
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
848 } else if (minfo
->name
== LTT_EVENT_IRQ_EXIT
) {
849 gint len
= ts
->cpu_states
[cpu
].irq_stack
->len
;
851 irq
= g_array_index(ts
->cpu_states
[cpu
].irq_stack
, gint
, len
-1);
859 guint trace_num
= ts
->parent
.index
;
861 /* Well, the process_out existed : we must get it in the process hash
862 * or add it, and draw its items.
864 /* Add process to process list (if not present) */
866 HashedResourceData
*hashed_process_data
= NULL
;
867 ProcessList
*process_list
= resourceview_data
->process_list
;
869 hashed_process_data
= resourcelist_obtain_irq(resourceview_data
, trace_num
, irq
);
870 // TODO: fix this, it's ugly and slow:
874 str
= g_strdup_printf("IRQ %" PRIu64
" [%s]", irq
, (char*)g_quark_to_string(ts
->irq_names
[irq
]));
875 name
= g_quark_from_string(str
);
878 gtk_tree_store_set(resourceview_data
->process_list
->list_store
, &hashed_process_data
->y_iter
, NAME_COLUMN
, g_quark_to_string(name
), -1);
880 /* Now, the process is in the state hash and our own process hash.
881 * We definitely can draw the items related to the ending state.
884 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
887 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
888 TimeWindow time_window
=
889 lttvwindow_get_time_window(resourceview_data
->tab
);
892 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
893 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
896 Drawing_t
*drawing
= resourceview_data
->drawing
;
897 guint width
= drawing
->width
;
899 convert_time_to_pixels(
905 /* Draw collision indicator */
906 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
907 gdk_draw_point(hashed_process_data
->pixmap
,
910 COLLISION_POSITION(hashed_process_data
->height
));
911 hashed_process_data
->x
.middle_marked
= TRUE
;
915 TimeWindow time_window
=
916 lttvwindow_get_time_window(resourceview_data
->tab
);
919 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
920 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
923 Drawing_t
*drawing
= resourceview_data
->drawing
;
924 guint width
= drawing
->width
;
927 convert_time_to_pixels(
934 /* Jump over draw if we are at the same x position */
935 if(unlikely(x
== hashed_process_data
->x
.middle
&&
936 hashed_process_data
->x
.middle_used
))
938 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
939 /* Draw collision indicator */
940 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
941 gdk_draw_point(hashed_process_data
->pixmap
,
944 COLLISION_POSITION(hashed_process_data
->height
));
945 hashed_process_data
->x
.middle_marked
= TRUE
;
951 DrawContext draw_context
;
952 /* Now create the drawing context that will be used to draw
953 * items related to the last state. */
954 draw_context
.drawable
= hashed_process_data
->pixmap
;
955 draw_context
.gc
= drawing
->gc
;
956 draw_context
.pango_layout
= drawing
->pango_layout
;
957 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
958 draw_context
.drawinfo
.end
.x
= x
;
960 draw_context
.drawinfo
.y
.over
= 1;
961 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
962 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
964 draw_context
.drawinfo
.start
.offset
.over
= 0;
965 draw_context
.drawinfo
.start
.offset
.middle
= 0;
966 draw_context
.drawinfo
.start
.offset
.under
= 0;
967 draw_context
.drawinfo
.end
.offset
.over
= 0;
968 draw_context
.drawinfo
.end
.offset
.middle
= 0;
969 draw_context
.drawinfo
.end
.offset
.under
= 0;
973 PropertiesLine prop_line
;
974 prop_line
.line_width
= STATE_LINE_WIDTH
;
975 prop_line
.style
= GDK_LINE_SOLID
;
976 prop_line
.y
= MIDDLE
;
977 irq_set_line_color(&prop_line
, &ts
->irq_states
[irq
]);
978 draw_line((void*)&prop_line
, (void*)&draw_context
);
980 /* become the last x position */
981 hashed_process_data
->x
.middle
= x
;
982 hashed_process_data
->x
.middle_used
= TRUE
;
983 hashed_process_data
->x
.middle_marked
= FALSE
;
985 /* Calculate the next good time */
986 convert_pixels_to_time(width
, x
+1, time_window
,
987 &hashed_process_data
->next_good_time
);
994 int before_execmode_hook_soft_irq(void *hook_data
, void *call_data
)
996 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
997 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
998 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
1000 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1002 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1003 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1004 struct marker_info
*minfo
;
1007 e
= ltt_tracefile_get_event(tfc
->tf
);
1009 LttTime evtime
= ltt_event_time(e
);
1011 LttTrace
*trace
= tfc
->t_context
->t
;
1013 /* we are in a execmode, before the state update. We must draw the
1014 * items corresponding to the state before it changes : now is the right
1020 guint cpu
= tfs
->cpu
;
1023 * Check for LTT_CHANNEL_KERNEL channel name and event ID
1024 * corresponding to LTT_EVENT_SOFT_IRQ_RAISE, LTT_EVENT_SOFT_IRQ_ENTRY
1025 * or LTT_EVENT_SOFT_IRQ_EXIT.
1027 if (tfc
->tf
->name
!= LTT_CHANNEL_KERNEL
)
1029 minfo
= marker_get_info_from_id(tfc
->tf
->mdata
, e
->event_id
);
1030 g_assert(minfo
!= NULL
);
1031 if (minfo
->name
== LTT_EVENT_SOFT_IRQ_RAISE
1032 || minfo
->name
== LTT_EVENT_SOFT_IRQ_ENTRY
) {
1033 softirq
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
1034 } else if (minfo
->name
== LTT_EVENT_SOFT_IRQ_EXIT
) {
1035 softirq
= ts
->cpu_states
[cpu
].last_soft_irq
;
1039 guint trace_num
= ts
->parent
.index
;
1041 /* Well, the process_out existed : we must get it in the process hash
1042 * or add it, and draw its items.
1044 /* Add process to process list (if not present) */
1045 guint pl_height
= 0;
1046 HashedResourceData
*hashed_process_data
= NULL
;
1047 ProcessList
*process_list
= resourceview_data
->process_list
;
1049 hashed_process_data
= resourcelist_obtain_soft_irq(resourceview_data
, trace_num
, softirq
);
1051 /* Now, the process is in the state hash and our own process hash.
1052 * We definitely can draw the items related to the ending state.
1055 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1058 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1059 TimeWindow time_window
=
1060 lttvwindow_get_time_window(resourceview_data
->tab
);
1063 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1064 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1066 #endif //EXTRA_CHECK
1067 Drawing_t
*drawing
= resourceview_data
->drawing
;
1068 guint width
= drawing
->width
;
1070 convert_time_to_pixels(
1076 /* Draw collision indicator */
1077 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1078 gdk_draw_point(hashed_process_data
->pixmap
,
1081 COLLISION_POSITION(hashed_process_data
->height
));
1082 hashed_process_data
->x
.middle_marked
= TRUE
;
1086 TimeWindow time_window
=
1087 lttvwindow_get_time_window(resourceview_data
->tab
);
1090 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1091 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1093 #endif //EXTRA_CHECK
1094 Drawing_t
*drawing
= resourceview_data
->drawing
;
1095 guint width
= drawing
->width
;
1098 convert_time_to_pixels(
1105 /* Jump over draw if we are at the same x position */
1106 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1107 hashed_process_data
->x
.middle_used
))
1109 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1110 /* Draw collision indicator */
1111 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1112 gdk_draw_point(hashed_process_data
->pixmap
,
1115 COLLISION_POSITION(hashed_process_data
->height
));
1116 hashed_process_data
->x
.middle_marked
= TRUE
;
1122 DrawContext draw_context
;
1123 /* Now create the drawing context that will be used to draw
1124 * items related to the last state. */
1125 draw_context
.drawable
= hashed_process_data
->pixmap
;
1126 draw_context
.gc
= drawing
->gc
;
1127 draw_context
.pango_layout
= drawing
->pango_layout
;
1128 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1129 draw_context
.drawinfo
.end
.x
= x
;
1131 draw_context
.drawinfo
.y
.over
= 1;
1132 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1133 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1135 draw_context
.drawinfo
.start
.offset
.over
= 0;
1136 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1137 draw_context
.drawinfo
.start
.offset
.under
= 0;
1138 draw_context
.drawinfo
.end
.offset
.over
= 0;
1139 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1140 draw_context
.drawinfo
.end
.offset
.under
= 0;
1144 PropertiesLine prop_line
;
1145 prop_line
.line_width
= STATE_LINE_WIDTH
;
1146 prop_line
.style
= GDK_LINE_SOLID
;
1147 prop_line
.y
= MIDDLE
;
1148 soft_irq_set_line_color(&prop_line
, &ts
->soft_irq_states
[softirq
]);
1149 draw_line((void*)&prop_line
, (void*)&draw_context
);
1151 /* become the last x position */
1152 hashed_process_data
->x
.middle
= x
;
1153 hashed_process_data
->x
.middle_used
= TRUE
;
1154 hashed_process_data
->x
.middle_marked
= FALSE
;
1156 /* Calculate the next good time */
1157 convert_pixels_to_time(width
, x
+1, time_window
,
1158 &hashed_process_data
->next_good_time
);
1165 int before_execmode_hook_trap(void *hook_data
, void *call_data
)
1167 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
1168 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
1169 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
1171 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1173 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1174 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1175 struct marker_info
*minfo
;
1178 e
= ltt_tracefile_get_event(tfc
->tf
);
1180 LttTime evtime
= ltt_event_time(e
);
1182 LttTrace
*trace
= tfc
->t_context
->t
;
1184 /* we are in a execmode, before the state update. We must draw the
1185 * items corresponding to the state before it changes : now is the right
1191 guint cpu
= tfs
->cpu
;
1194 * Check for LTT_CHANNEL_KERNEL channel name and event ID
1195 * corresponding to LTT_EVENT_TRAP/PAGE_FAULT_ENTRY or
1196 * LTT_EVENT_TRAP/PAGE_FAULT_EXIT.
1198 if (tfc
->tf
->name
!= LTT_CHANNEL_KERNEL
)
1200 minfo
= marker_get_info_from_id(tfc
->tf
->mdata
, e
->event_id
);
1201 g_assert(minfo
!= NULL
);
1202 if (minfo
->name
== LTT_EVENT_TRAP_ENTRY
1203 || minfo
->name
== LTT_EVENT_PAGE_FAULT_ENTRY
1204 || minfo
->name
== LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
) {
1205 trap
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
1206 } else if (minfo
->name
== LTT_EVENT_TRAP_EXIT
1207 || minfo
->name
== LTT_EVENT_PAGE_FAULT_EXIT
1208 || minfo
->name
== LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
) {
1209 trap
= ts
->cpu_states
[cpu
].last_trap
;
1213 guint trace_num
= ts
->parent
.index
;
1215 /* Well, the process_out existed : we must get it in the process hash
1216 * or add it, and draw its items.
1218 /* Add process to process list (if not present) */
1219 guint pl_height
= 0;
1220 HashedResourceData
*hashed_process_data
= NULL
;
1221 ProcessList
*process_list
= resourceview_data
->process_list
;
1223 hashed_process_data
= resourcelist_obtain_trap(resourceview_data
, trace_num
, trap
);
1225 /* Now, the process is in the state hash and our own process hash.
1226 * We definitely can draw the items related to the ending state.
1229 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1232 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1233 TimeWindow time_window
=
1234 lttvwindow_get_time_window(resourceview_data
->tab
);
1237 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1238 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1240 #endif //EXTRA_CHECK
1241 Drawing_t
*drawing
= resourceview_data
->drawing
;
1242 guint width
= drawing
->width
;
1244 convert_time_to_pixels(
1250 /* Draw collision indicator */
1251 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1252 gdk_draw_point(hashed_process_data
->pixmap
,
1255 COLLISION_POSITION(hashed_process_data
->height
));
1256 hashed_process_data
->x
.middle_marked
= TRUE
;
1260 TimeWindow time_window
=
1261 lttvwindow_get_time_window(resourceview_data
->tab
);
1264 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1265 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1267 #endif //EXTRA_CHECK
1268 Drawing_t
*drawing
= resourceview_data
->drawing
;
1269 guint width
= drawing
->width
;
1272 convert_time_to_pixels(
1279 /* Jump over draw if we are at the same x position */
1280 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1281 hashed_process_data
->x
.middle_used
))
1283 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1284 /* Draw collision indicator */
1285 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1286 gdk_draw_point(hashed_process_data
->pixmap
,
1289 COLLISION_POSITION(hashed_process_data
->height
));
1290 hashed_process_data
->x
.middle_marked
= TRUE
;
1296 DrawContext draw_context
;
1297 /* Now create the drawing context that will be used to draw
1298 * items related to the last state. */
1299 draw_context
.drawable
= hashed_process_data
->pixmap
;
1300 draw_context
.gc
= drawing
->gc
;
1301 draw_context
.pango_layout
= drawing
->pango_layout
;
1302 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1303 draw_context
.drawinfo
.end
.x
= x
;
1305 draw_context
.drawinfo
.y
.over
= 1;
1306 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1307 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1309 draw_context
.drawinfo
.start
.offset
.over
= 0;
1310 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1311 draw_context
.drawinfo
.start
.offset
.under
= 0;
1312 draw_context
.drawinfo
.end
.offset
.over
= 0;
1313 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1314 draw_context
.drawinfo
.end
.offset
.under
= 0;
1318 PropertiesLine prop_line
;
1319 prop_line
.line_width
= STATE_LINE_WIDTH
;
1320 prop_line
.style
= GDK_LINE_SOLID
;
1321 prop_line
.y
= MIDDLE
;
1322 trap_set_line_color(&prop_line
, &ts
->trap_states
[trap
]);
1323 draw_line((void*)&prop_line
, (void*)&draw_context
);
1325 /* become the last x position */
1326 hashed_process_data
->x
.middle
= x
;
1327 hashed_process_data
->x
.middle_used
= TRUE
;
1328 hashed_process_data
->x
.middle_marked
= FALSE
;
1330 /* Calculate the next good time */
1331 convert_pixels_to_time(width
, x
+1, time_window
,
1332 &hashed_process_data
->next_good_time
);
1340 int before_bdev_event_hook(void *hook_data
, void *call_data
)
1342 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
1343 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
1344 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
1346 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1348 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1349 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1352 e
= ltt_tracefile_get_event(tfc
->tf
);
1354 LttTime evtime
= ltt_event_time(e
);
1356 /* we are in a execmode, before the state update. We must draw the
1357 * items corresponding to the state before it changes : now is the right
1362 guint cpu
= tfs
->cpu
;
1363 guint8 major
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 0));
1364 guint8 minor
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 1));
1365 guint oper
= ltt_event_get_long_unsigned(e
, lttv_trace_get_hook_field(th
, 2));
1366 gint devcode_gint
= MKDEV(major
,minor
);
1368 guint trace_num
= ts
->parent
.index
;
1370 LttvBdevState
*bdev
= g_hash_table_lookup(ts
->bdev_states
, &devcode_gint
);
1371 /* the result of the lookup might be NULL. that's ok, the rest of the function
1372 should understand it was not found and that its state is unknown */
1374 /* Well, the process_out existed : we must get it in the process hash
1375 * or add it, and draw its items.
1377 /* Add process to process list (if not present) */
1378 guint pl_height
= 0;
1379 HashedResourceData
*hashed_process_data
= NULL
;
1380 ProcessList
*process_list
= resourceview_data
->process_list
;
1381 // LttTime birth = process->creation_time;
1383 // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1384 // hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1386 hashed_process_data
= resourcelist_obtain_bdev(resourceview_data
, trace_num
, devcode_gint
);
1387 ////hashed_process_data = processlist_get_process_data(process_list, resourceq, trace_num);
1388 // hashed_process_data = processlist_get_process_data(process_list,
1394 /* Set the current process */
1395 // process_list->current_hash_data[trace_num][process->cpu] =
1396 // hashed_process_data;
1399 /* Now, the process is in the state hash and our own process hash.
1400 * We definitely can draw the items related to the ending state.
1403 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
1406 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1407 TimeWindow time_window
=
1408 lttvwindow_get_time_window(resourceview_data
->tab
);
1411 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1412 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1414 #endif //EXTRA_CHECK
1415 Drawing_t
*drawing
= resourceview_data
->drawing
;
1416 guint width
= drawing
->width
;
1418 convert_time_to_pixels(
1424 /* Draw collision indicator */
1425 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1426 gdk_draw_point(hashed_process_data
->pixmap
,
1429 COLLISION_POSITION(hashed_process_data
->height
));
1430 hashed_process_data
->x
.middle_marked
= TRUE
;
1434 TimeWindow time_window
=
1435 lttvwindow_get_time_window(resourceview_data
->tab
);
1438 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1439 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1441 #endif //EXTRA_CHECK
1442 Drawing_t
*drawing
= resourceview_data
->drawing
;
1443 guint width
= drawing
->width
;
1446 convert_time_to_pixels(
1453 /* Jump over draw if we are at the same x position */
1454 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1455 hashed_process_data
->x
.middle_used
))
1457 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
1458 /* Draw collision indicator */
1459 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1460 gdk_draw_point(hashed_process_data
->pixmap
,
1463 COLLISION_POSITION(hashed_process_data
->height
));
1464 hashed_process_data
->x
.middle_marked
= TRUE
;
1470 DrawContext draw_context
;
1471 /* Now create the drawing context that will be used to draw
1472 * items related to the last state. */
1473 draw_context
.drawable
= hashed_process_data
->pixmap
;
1474 draw_context
.gc
= drawing
->gc
;
1475 draw_context
.pango_layout
= drawing
->pango_layout
;
1476 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1477 draw_context
.drawinfo
.end
.x
= x
;
1479 draw_context
.drawinfo
.y
.over
= 1;
1480 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1481 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1483 draw_context
.drawinfo
.start
.offset
.over
= 0;
1484 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1485 draw_context
.drawinfo
.start
.offset
.under
= 0;
1486 draw_context
.drawinfo
.end
.offset
.over
= 0;
1487 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1488 draw_context
.drawinfo
.end
.offset
.under
= 0;
1492 PropertiesLine prop_line
;
1493 prop_line
.line_width
= STATE_LINE_WIDTH
;
1494 prop_line
.style
= GDK_LINE_SOLID
;
1495 prop_line
.y
= MIDDLE
;
1496 bdev_set_line_color(&prop_line
, bdev
);
1497 draw_line((void*)&prop_line
, (void*)&draw_context
);
1499 /* become the last x position */
1500 hashed_process_data
->x
.middle
= x
;
1501 hashed_process_data
->x
.middle_used
= TRUE
;
1502 hashed_process_data
->x
.middle_marked
= FALSE
;
1504 /* Calculate the next good time */
1505 convert_pixels_to_time(width
, x
+1, time_window
,
1506 &hashed_process_data
->next_good_time
);
1513 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1515 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
1516 Drawing_t
*drawing
= resourceview_data
->drawing
;
1517 ProcessList
*process_list
= resourceview_data
->process_list
;
1519 const TimeWindowNotifyData
*time_window_nofify_data
=
1520 ((const TimeWindowNotifyData
*)call_data
);
1522 TimeWindow
*old_time_window
=
1523 time_window_nofify_data
->old_time_window
;
1524 TimeWindow
*new_time_window
=
1525 time_window_nofify_data
->new_time_window
;
1527 /* Update the ruler */
1528 drawing_update_ruler(resourceview_data
->drawing
,
1532 /* Two cases : zoom in/out or scrolling */
1534 /* In order to make sure we can reuse the old drawing, the scale must
1535 * be the same and the new time interval being partly located in the
1536 * currently shown time interval. (reuse is only for scrolling)
1539 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
1540 old_time_window
->start_time
.tv_sec
,
1541 old_time_window
->start_time
.tv_nsec
,
1542 old_time_window
->time_width
.tv_sec
,
1543 old_time_window
->time_width
.tv_nsec
);
1545 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
1546 new_time_window
->start_time
.tv_sec
,
1547 new_time_window
->start_time
.tv_nsec
,
1548 new_time_window
->time_width
.tv_sec
,
1549 new_time_window
->time_width
.tv_nsec
);
1551 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1552 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1554 /* Same scale (scrolling) */
1555 g_info("scrolling");
1556 LttTime
*ns
= &new_time_window
->start_time
;
1557 LttTime
*nw
= &new_time_window
->time_width
;
1558 LttTime
*os
= &old_time_window
->start_time
;
1559 LttTime
*ow
= &old_time_window
->time_width
;
1560 LttTime old_end
= old_time_window
->end_time
;
1561 LttTime new_end
= new_time_window
->end_time
;
1563 //if(ns<os+w && os+w<ns+w)
1564 //if(ns<old_end && os<ns)
1565 if(ltt_time_compare(*ns
, old_end
) == -1
1566 && ltt_time_compare(*os
, *ns
) == -1)
1568 g_info("scrolling near right");
1569 /* Scroll right, keep right part of the screen */
1571 guint width
= resourceview_data
->drawing
->width
;
1572 convert_time_to_pixels(
1578 /* Copy old data to new location */
1579 copy_pixmap_region(process_list
,
1581 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1585 resourceview_data
->drawing
->width
-x
+SAFETY
, -1);
1587 if(drawing
->damage_begin
== drawing
->damage_end
)
1588 drawing
->damage_begin
= resourceview_data
->drawing
->width
-x
;
1590 drawing
->damage_begin
= 0;
1592 drawing
->damage_end
= resourceview_data
->drawing
->width
;
1594 /* Clear the data request background, but not SAFETY */
1595 rectangle_pixmap(process_list
,
1596 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1598 drawing
->damage_begin
+SAFETY
, 0,
1599 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1601 gtk_widget_queue_draw(drawing
->drawing_area
);
1603 /* Get new data for the rest. */
1604 drawing_data_request(resourceview_data
->drawing
,
1605 drawing
->damage_begin
, 0,
1606 drawing
->damage_end
- drawing
->damage_begin
,
1607 resourceview_data
->drawing
->height
);
1609 if(ltt_time_compare(*ns
,*os
) == -1
1610 && ltt_time_compare(*os
,new_end
) == -1)
1612 g_info("scrolling near left");
1613 /* Scroll left, keep left part of the screen */
1615 guint width
= resourceview_data
->drawing
->width
;
1616 convert_time_to_pixels(
1622 /* Copy old data to new location */
1623 copy_pixmap_region (process_list
,
1625 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1631 if(drawing
->damage_begin
== drawing
->damage_end
)
1632 drawing
->damage_end
= x
;
1634 drawing
->damage_end
=
1635 resourceview_data
->drawing
->width
;
1637 drawing
->damage_begin
= 0;
1639 rectangle_pixmap (process_list
,
1640 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1642 drawing
->damage_begin
, 0,
1643 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1646 gtk_widget_queue_draw(drawing
->drawing_area
);
1648 /* Get new data for the rest. */
1649 drawing_data_request(resourceview_data
->drawing
,
1650 drawing
->damage_begin
, 0,
1651 drawing
->damage_end
- drawing
->damage_begin
,
1652 resourceview_data
->drawing
->height
);
1655 if(ltt_time_compare(*ns
,*os
) == 0)
1657 g_info("not scrolling");
1659 g_info("scrolling far");
1660 /* Cannot reuse any part of the screen : far jump */
1663 rectangle_pixmap (process_list
,
1664 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1667 resourceview_data
->drawing
->width
+SAFETY
, // do not overlap
1670 gtk_widget_queue_draw(drawing
->drawing_area
);
1672 drawing
->damage_begin
= 0;
1673 drawing
->damage_end
= resourceview_data
->drawing
->width
;
1675 drawing_data_request(resourceview_data
->drawing
,
1677 resourceview_data
->drawing
->width
,
1678 resourceview_data
->drawing
->height
);
1684 /* Different scale (zoom) */
1687 rectangle_pixmap (process_list
,
1688 resourceview_data
->drawing
->drawing_area
->style
->black_gc
,
1691 resourceview_data
->drawing
->width
+SAFETY
, // do not overlap
1694 gtk_widget_queue_draw(drawing
->drawing_area
);
1696 drawing
->damage_begin
= 0;
1697 drawing
->damage_end
= resourceview_data
->drawing
->width
;
1699 drawing_data_request(resourceview_data
->drawing
,
1701 resourceview_data
->drawing
->width
,
1702 resourceview_data
->drawing
->height
);
1705 /* Update directly when scrolling */
1706 gdk_window_process_updates(resourceview_data
->drawing
->drawing_area
->window
,
1712 gint
traceset_notify(void *hook_data
, void *call_data
)
1714 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
1715 Drawing_t
*drawing
= resourceview_data
->drawing
;
1717 if(unlikely(drawing
->gc
== NULL
)) {
1720 if(drawing
->dotted_gc
== NULL
) {
1724 drawing_clear(resourceview_data
->drawing
);
1725 processlist_clear(resourceview_data
->process_list
);
1726 gtk_widget_set_size_request(
1727 resourceview_data
->drawing
->drawing_area
,
1728 -1, processlist_get_height(resourceview_data
->process_list
));
1729 redraw_notify(resourceview_data
, NULL
);
1731 request_background_data(resourceview_data
);
1736 gint
redraw_notify(void *hook_data
, void *call_data
)
1738 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
1739 Drawing_t
*drawing
= resourceview_data
->drawing
;
1740 GtkWidget
*widget
= drawing
->drawing_area
;
1742 drawing
->damage_begin
= 0;
1743 drawing
->damage_end
= drawing
->width
;
1745 /* fun feature, to be separated someday... */
1746 drawing_clear(resourceview_data
->drawing
);
1747 processlist_clear(resourceview_data
->process_list
);
1748 gtk_widget_set_size_request(
1749 resourceview_data
->drawing
->drawing_area
,
1750 -1, processlist_get_height(resourceview_data
->process_list
));
1752 rectangle_pixmap (resourceview_data
->process_list
,
1753 widget
->style
->black_gc
,
1756 drawing
->alloc_width
,
1759 gtk_widget_queue_draw(drawing
->drawing_area
);
1761 if(drawing
->damage_begin
< drawing
->damage_end
)
1763 drawing_data_request(drawing
,
1764 drawing
->damage_begin
,
1766 drawing
->damage_end
-drawing
->damage_begin
,
1775 gint
continue_notify(void *hook_data
, void *call_data
)
1777 ControlFlowData
*resourceview_data
= (ControlFlowData
*) hook_data
;
1778 Drawing_t
*drawing
= resourceview_data
->drawing
;
1780 if(drawing
->damage_begin
< drawing
->damage_end
)
1782 drawing_data_request(drawing
,
1783 drawing
->damage_begin
,
1785 drawing
->damage_end
-drawing
->damage_begin
,
1793 gint
update_current_time_hook(void *hook_data
, void *call_data
)
1795 ControlFlowData
*resourceview_data
= (ControlFlowData
*)hook_data
;
1796 Drawing_t
*drawing
= resourceview_data
->drawing
;
1798 LttTime current_time
= *((LttTime
*)call_data
);
1800 TimeWindow time_window
=
1801 lttvwindow_get_time_window(resourceview_data
->tab
);
1803 LttTime time_begin
= time_window
.start_time
;
1804 LttTime width
= time_window
.time_width
;
1807 guint64 time_ll
= ltt_time_to_uint64(width
);
1808 time_ll
= time_ll
>> 1; /* divide by two */
1809 half_width
= ltt_time_from_uint64(time_ll
);
1811 LttTime time_end
= ltt_time_add(time_begin
, width
);
1813 LttvTracesetContext
* tsc
=
1814 lttvwindow_get_traceset_context(resourceview_data
->tab
);
1816 LttTime trace_start
= tsc
->time_span
.start_time
;
1817 LttTime trace_end
= tsc
->time_span
.end_time
;
1819 g_info("New current time HOOK : %lu, %lu", current_time
.tv_sec
,
1820 current_time
.tv_nsec
);
1822 /* If current time is inside time interval, just move the highlight
1825 /* Else, we have to change the time interval. We have to tell it
1826 * to the main window. */
1827 /* The time interval change will take care of placing the current
1828 * time at the center of the visible area, or nearest possible if we are
1829 * at one end of the trace. */
1832 if(ltt_time_compare(current_time
, time_begin
) < 0)
1834 TimeWindow new_time_window
;
1836 if(ltt_time_compare(current_time
,
1837 ltt_time_add(trace_start
,half_width
)) < 0)
1838 time_begin
= trace_start
;
1840 time_begin
= ltt_time_sub(current_time
,half_width
);
1842 new_time_window
.start_time
= time_begin
;
1843 new_time_window
.time_width
= width
;
1844 new_time_window
.time_width_double
= ltt_time_to_double(width
);
1845 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
1847 lttvwindow_report_time_window(resourceview_data
->tab
, new_time_window
);
1849 else if(ltt_time_compare(current_time
, time_end
) > 0)
1851 TimeWindow new_time_window
;
1853 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) > 0)
1854 time_begin
= ltt_time_sub(trace_end
,width
);
1856 time_begin
= ltt_time_sub(current_time
,half_width
);
1858 new_time_window
.start_time
= time_begin
;
1859 new_time_window
.time_width
= width
;
1860 new_time_window
.time_width_double
= ltt_time_to_double(width
);
1861 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
1863 lttvwindow_report_time_window(resourceview_data
->tab
, new_time_window
);
1866 gtk_widget_queue_draw(resourceview_data
->drawing
->drawing_area
);
1868 /* Update directly when scrolling */
1869 gdk_window_process_updates(resourceview_data
->drawing
->drawing_area
->window
,
1875 typedef struct _ClosureData
{
1876 EventsRequest
*events_request
;
1877 LttvTracesetState
*tss
;
1882 /* Draw line until end of the screen */
1884 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1886 ResourceUniqueNumeric
*process_info
= (ResourceUniqueNumeric
*)key
;
1887 HashedResourceData
*hashed_process_data
= (HashedResourceData
*)value
;
1888 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1890 EventsRequest
*events_request
= closure_data
->events_request
;
1891 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
1893 LttvTracesetState
*tss
= closure_data
->tss
;
1894 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
1896 LttTime evtime
= closure_data
->end_time
;
1898 gboolean dodraw
= TRUE
;
1900 if(hashed_process_data
->type
== RV_RESOURCE_MACHINE
)
1904 /* For the process */
1905 /* First, check if the current process is in the state computation
1906 * process list. If it is there, that means we must add it right now and
1907 * draw items from the beginning of the read for it. If it is not
1908 * present, it's a new process and it was not present : it will
1909 * be added after the state update. */
1911 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
1912 #endif //EXTRA_CHECK
1913 LttvTraceContext
*tc
= tsc
->traces
[process_info
->trace_num
];
1914 LttvTraceState
*ts
= (LttvTraceState
*)tc
;
1916 /* Only draw for processes that are currently in the trace states */
1918 ProcessList
*process_list
= resourceview_data
->process_list
;
1920 /* Should be alike when background info is ready */
1921 if(resourceview_data
->background_info_waiting
==0)
1922 g_assert(ltt_time_compare(process
->creation_time
,
1923 process_info
->birth
) == 0);
1924 #endif //EXTRA_CHECK
1926 /* Now, the process is in the state hash and our own process hash.
1927 * We definitely can draw the items related to the ending state.
1930 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
1933 TimeWindow time_window
=
1934 lttvwindow_get_time_window(resourceview_data
->tab
);
1937 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1938 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1940 #endif //EXTRA_CHECK
1941 Drawing_t
*drawing
= resourceview_data
->drawing
;
1942 guint width
= drawing
->width
;
1944 guint x
= closure_data
->x_end
;
1946 DrawContext draw_context
;
1948 /* Now create the drawing context that will be used to draw
1949 * items related to the last state. */
1950 draw_context
.drawable
= hashed_process_data
->pixmap
;
1951 draw_context
.gc
= drawing
->gc
;
1952 draw_context
.pango_layout
= drawing
->pango_layout
;
1953 draw_context
.drawinfo
.end
.x
= x
;
1955 draw_context
.drawinfo
.y
.over
= 1;
1956 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
1957 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
1959 draw_context
.drawinfo
.start
.offset
.over
= 0;
1960 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1961 draw_context
.drawinfo
.start
.offset
.under
= 0;
1962 draw_context
.drawinfo
.end
.offset
.over
= 0;
1963 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1964 draw_context
.drawinfo
.end
.offset
.under
= 0;
1966 /* Jump over draw if we are at the same x position */
1967 if(x
== hashed_process_data
->x
.over
)
1971 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
1973 PropertiesLine prop_line
= prepare_execmode_line(process
);
1974 draw_line((void*)&prop_line
, (void*)&draw_context
);
1976 hashed_process_data
->x
.over
= x
;
1980 if(unlikely(x
== hashed_process_data
->x
.middle
&&
1981 hashed_process_data
->x
.middle_used
)) {
1982 #if 0 /* do not mark closure : not missing information */
1983 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
1984 /* Draw collision indicator */
1985 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
1986 gdk_draw_point(drawing
->pixmap
,
1990 hashed_process_data
->x
.middle_marked
= TRUE
;
1995 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1998 PropertiesLine prop_line
;
1999 prop_line
.line_width
= STATE_LINE_WIDTH
;
2000 prop_line
.style
= GDK_LINE_SOLID
;
2001 prop_line
.y
= MIDDLE
;
2002 if(hashed_process_data
->type
== RV_RESOURCE_CPU
)
2003 cpu_set_line_color(&prop_line
, &ts
->cpu_states
[process_info
->id
]);
2004 else if(hashed_process_data
->type
== RV_RESOURCE_IRQ
)
2005 irq_set_line_color(&prop_line
, &ts
->irq_states
[process_info
->id
]);
2006 else if(hashed_process_data
->type
== RV_RESOURCE_SOFT_IRQ
)
2007 soft_irq_set_line_color(&prop_line
, &ts
->soft_irq_states
[process_info
->id
]);
2008 else if(hashed_process_data
->type
== RV_RESOURCE_TRAP
)
2009 trap_set_line_color(&prop_line
, &ts
->trap_states
[process_info
->id
]);
2010 else if(hashed_process_data
->type
== RV_RESOURCE_BDEV
) {
2011 gint devcode_gint
= process_info
->id
;
2012 LttvBdevState
*bdev
= g_hash_table_lookup(ts
->bdev_states
, &devcode_gint
);
2013 // the lookup may return null; bdev_set_line_color must act appropriately
2014 bdev_set_line_color(&prop_line
, bdev
);
2017 draw_line((void*)&prop_line
, (void*)&draw_context
);
2020 /* become the last x position */
2021 if(likely(x
!= hashed_process_data
->x
.middle
)) {
2022 hashed_process_data
->x
.middle
= x
;
2023 /* but don't use the pixel */
2024 hashed_process_data
->x
.middle_used
= FALSE
;
2026 /* Calculate the next good time */
2027 convert_pixels_to_time(width
, x
+1, time_window
,
2028 &hashed_process_data
->next_good_time
);
2035 int before_chunk(void *hook_data
, void *call_data
)
2037 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2038 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2039 ControlFlowData
*cfd
= (ControlFlowData
*)events_request
->viewer_data
;
2041 /* Deactivate sort */
2042 gtk_tree_sortable_set_sort_column_id(
2043 GTK_TREE_SORTABLE(cfd
->process_list
->list_store
),
2045 GTK_SORT_ASCENDING
);
2047 drawing_chunk_begin(events_request
, tss
);
2054 * This gets executed just before an events request is executed
2057 int before_request(void *hook_data
, void *call_data
)
2059 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2060 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2062 drawing_data_request_begin(events_request
, tss
);
2069 * after request is necessary in addition of after chunk in order to draw
2070 * lines until the end of the screen. after chunk just draws lines until
2077 int after_request(void *hook_data
, void *call_data
)
2080 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2081 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
2082 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2084 ProcessList
*process_list
= resourceview_data
->process_list
;
2085 LttTime end_time
= events_request
->end_time
;
2087 ClosureData closure_data
;
2088 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2089 closure_data
.tss
= tss
;
2090 closure_data
.end_time
= end_time
;
2092 TimeWindow time_window
=
2093 lttvwindow_get_time_window(resourceview_data
->tab
);
2094 guint width
= resourceview_data
->drawing
->width
;
2095 convert_time_to_pixels(
2099 &closure_data
.x_end
);
2102 /* Draw last items */
2103 for(i
=0; i
<RV_RESOURCE_COUNT
; i
++) {
2104 g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data
, i
), draw_closure
,
2105 (void*)&closure_data
);
2108 /* Request expose */
2109 drawing_request_expose(events_request
, tss
, end_time
);
2118 int after_chunk(void *hook_data
, void *call_data
)
2120 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2121 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
2122 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
2123 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
2124 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
2127 ProcessList
*process_list
= resourceview_data
->process_list
;
2129 LttvTraceset
*traceset
= tsc
->ts
;
2130 guint nb_trace
= lttv_traceset_number(traceset
);
2132 /* Only execute when called for the first trace's events request */
2133 if(!process_list
->current_hash_data
)
2136 for(i
= 0 ; i
< nb_trace
; i
++) {
2137 g_free(process_list
->current_hash_data
[i
]);
2139 g_free(process_list
->current_hash_data
);
2140 process_list
->current_hash_data
= NULL
;
2143 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
2144 else /* end of traceset, or position now out of request : end */
2145 end_time
= events_request
->end_time
;
2147 ClosureData closure_data
;
2148 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2149 closure_data
.tss
= tss
;
2150 closure_data
.end_time
= end_time
;
2152 TimeWindow time_window
=
2153 lttvwindow_get_time_window(resourceview_data
->tab
);
2154 guint width
= resourceview_data
->drawing
->width
;
2155 convert_time_to_pixels(
2159 &closure_data
.x_end
);
2161 /* Draw last items */
2162 for(i
=0; i
<RV_RESOURCE_COUNT
; i
++) {
2163 g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data
, i
), draw_closure
,
2164 (void*)&closure_data
);
2167 /* Reactivate sort */
2168 gtk_tree_sortable_set_sort_column_id(
2169 GTK_TREE_SORTABLE(resourceview_data
->process_list
->list_store
),
2170 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
2171 GTK_SORT_ASCENDING
);
2173 update_index_to_pixmap(resourceview_data
->process_list
);
2174 /* Request a full expose : drawing scrambled */
2175 gtk_widget_queue_draw(resourceview_data
->drawing
->drawing_area
);
2177 /* Request expose (updates damages zone also) */
2178 drawing_request_expose(events_request
, tss
, end_time
);
2183 /* after_statedump_end
2185 * @param hook_data ControlFlowData structure of the viewer.
2186 * @param call_data Event context.
2188 * This function adds items to be drawn in a queue for each process.
2191 int before_statedump_end(void *hook_data
, void *call_data
)
2195 LttvTraceHook
*th
= (LttvTraceHook
*)hook_data
;
2196 EventsRequest
*events_request
= (EventsRequest
*)th
->hook_data
;
2197 ControlFlowData
*resourceview_data
= events_request
->viewer_data
;
2199 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2201 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2203 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
2205 LttvTracesetState
*tss
= (LttvTracesetState
*)tfc
->t_context
->ts_context
;
2206 ProcessList
*process_list
= resourceview_data
->process_list
;
2209 e
= ltt_tracefile_get_event(tfc
->tf
);
2211 LttvFilter
*filter
= resourceview_data
->filter
;
2212 if(filter
!= NULL
&& filter
->head
!= NULL
)
2213 if(!lttv_filter_tree_parse(filter
->head
,e
,tfc
->tf
,
2214 tfc
->t_context
->t
,tfc
,NULL
,NULL
))
2217 LttTime evtime
= ltt_event_time(e
);
2219 ClosureData closure_data
;
2220 closure_data
.events_request
= events_request
;
2221 closure_data
.tss
= tss
;
2222 closure_data
.end_time
= evtime
;
2224 TimeWindow time_window
=
2225 lttvwindow_get_time_window(resourceview_data
->tab
);
2226 guint width
= resourceview_data
->drawing
->width
;
2227 convert_time_to_pixels(
2231 &closure_data
.x_end
);
2233 /* Draw last items */
2235 for(i
=0; i
<RV_RESOURCE_COUNT
; i
++) {
2236 g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data
, i
), draw_closure
,
2237 (void*)&closure_data
);
2240 /* Reactivate sort */
2241 gtk_tree_sortable_set_sort_column_id(
2242 GTK_TREE_SORTABLE(resourceview_data
->process_list
->list_store
),
2243 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
2244 GTK_SORT_ASCENDING
);
2246 update_index_to_pixmap(resourceview_data
->process_list
);
2247 /* Request a full expose : drawing scrambled */
2248 gtk_widget_queue_draw(resourceview_data
->drawing
->drawing_area
);
2250 /* Request expose (updates damages zone also) */
2251 drawing_request_expose(events_request
, tss
, evtime
);