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
49 //#define PANGO_ENABLE_BACKEND
57 //#include <pango/pango.h>
59 #include <ltt/event.h>
63 #include <lttv/lttv.h>
64 #include <lttv/hook.h>
65 #include <lttv/state.h>
66 #include <lttvwindow/lttvwindow.h>
67 #include <lttvwindow/lttvwindowtraces.h>
70 #include "eventhooks.h"
72 #include "processlist.h"
74 #include "cfv-private.h"
77 #define MAX_PATH_LEN 256
81 typedef struct _ProcessAddClosure
{
86 static void process_add(gpointer key
,
90 LttvProcessState
*process
= (LttvProcessState
*)value
;
91 ProcessAddClosure
*closure
= (ProcessAddClosure
*)user_data
;
92 ControlFlowData
*control_flow_data
= closure
->cfd
;
93 guint trace_num
= closure
->trace_num
;
95 /* Add process to process list (if not present) */
98 guint y
= 0, height
= 0, pl_height
= 0;
100 ProcessList
*process_list
= control_flow_data
->process_list
;
103 birth
= process
->creation_time
;
104 const gchar
*name
= g_quark_to_string(process
->name
);
105 HashedProcessData
*hashed_process_data
= NULL
;
107 if(processlist_get_process_pixels(process_list
,
113 &hashed_process_data
) == 1)
115 /* Process not present */
116 processlist_add(process_list
,
122 &hashed_process_data
);
123 processlist_get_process_pixels(process_list
,
129 &hashed_process_data
);
130 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
136 /* Action to do when background computation completed.
138 * Wait for all the awaited computations to be over.
141 gint
background_ready(void *hook_data
, void *call_data
)
143 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
144 LttvTrace
*trace
= (LttvTrace
*)call_data
;
145 LttvTracesetContext
*tsc
=
146 lttvwindow_get_traceset_context(control_flow_data
->tab
);
148 control_flow_data
->background_info_waiting
--;
150 if(control_flow_data
->background_info_waiting
== 0) {
151 g_debug("control flow viewer : background computation data ready.");
153 drawing_clear(control_flow_data
->drawing
);
154 processlist_clear(control_flow_data
->process_list
);
155 redraw_notify(control_flow_data
, NULL
);
162 /* Request background computation. Verify if it is in progress or ready first.
163 * Only for each trace in the tab's traceset.
165 void request_background_data(ControlFlowData
*control_flow_data
)
167 LttvTracesetContext
* tsc
=
168 lttvwindow_get_traceset_context(control_flow_data
->tab
);
169 gint num_traces
= lttv_traceset_number(tsc
->ts
);
173 LttvHooks
*background_ready_hook
=
175 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
177 control_flow_data
->background_info_waiting
= 0;
179 for(i
=0;i
<num_traces
;i
++) {
180 trace
= lttv_traceset_get(tsc
->ts
, i
);
182 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
184 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
186 /* We first remove requests that could have been done for the same
187 * information. Happens when two viewers ask for it before servicing
190 lttvwindowtraces_background_request_remove(trace
, "state");
191 lttvwindowtraces_background_request_queue(trace
,
193 lttvwindowtraces_background_notify_queue(control_flow_data
,
197 background_ready_hook
);
198 control_flow_data
->background_info_waiting
++;
199 } else { /* in progress */
201 lttvwindowtraces_background_notify_current(control_flow_data
,
205 background_ready_hook
);
206 control_flow_data
->background_info_waiting
++;
209 /* Data ready. Be its nature, this viewer doesn't need to have
210 * its data ready hook called htere, because a background
211 * request is always linked with a redraw.
217 lttv_hooks_destroy(background_ready_hook
);
224 * Event Viewer's constructor hook
226 * This constructor is given as a parameter to the menuitem and toolbar button
227 * registration. It creates the list.
228 * @param tab A pointer to the parent tab.
229 * @return The widget created.
232 h_guicontrolflow(Tab
*tab
)
234 g_info("h_guicontrolflow, %p", tab
);
235 ControlFlowData
*control_flow_data
= guicontrolflow() ;
237 control_flow_data
->tab
= tab
;
239 //g_debug("time width2 : %u",time_window->time_width);
240 // Unreg done in the GuiControlFlow_Destructor
241 lttvwindow_register_traceset_notify(tab
,
245 lttvwindow_register_time_window_notify(tab
,
246 update_time_window_hook
,
248 lttvwindow_register_current_time_notify(tab
,
249 update_current_time_hook
,
251 lttvwindow_register_redraw_notify(tab
,
254 lttvwindow_register_continue_notify(tab
,
257 request_background_data(control_flow_data
);
260 return guicontrolflow_get_widget(control_flow_data
) ;
264 int event_selected_hook(void *hook_data
, void *call_data
)
266 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
267 guint
*event_number
= (guint
*) call_data
;
269 g_debug("DEBUG : event selected by main window : %u", *event_number
);
273 /* Function that selects the color of status&exemode line */
274 static __inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
276 PropertiesLine prop_line
;
277 prop_line
.line_width
= 2;
278 prop_line
.style
= GDK_LINE_SOLID
;
279 prop_line
.y
= MIDDLE
;
280 //GdkColormap *colormap = gdk_colormap_get_system();
282 g_debug("prepare_status_line for state : %s",
283 g_quark_to_string(process
->state
->s
));
285 if(process
->state
->s
== LTTV_STATE_RUN
) {
286 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
287 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
288 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
289 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
290 else if(process
->state
->t
== LTTV_STATE_TRAP
)
291 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
292 else if(process
->state
->t
== LTTV_STATE_IRQ
)
293 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
294 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
295 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
297 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
298 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
299 /* We don't show if we wait while in user mode, trap, irq or syscall */
300 prop_line
.color
= drawing_colors
[COL_WAIT
];
301 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
302 /* We don't show if we wait for CPU while in user mode, trap, irq
304 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
305 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
306 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
307 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
308 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
309 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
310 prop_line
.color
= drawing_colors
[COL_EXIT
];
311 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
312 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
314 g_assert(FALSE
); /* UNKNOWN STATE */
321 static __inline PropertiesLine
prepare_status_line(LttvProcessState
*process
)
323 PropertiesLine prop_line
;
324 prop_line
.line_width
= 2;
325 prop_line
.style
= GDK_LINE_SOLID
;
326 prop_line
.y
= MIDDLE
;
327 //GdkColormap *colormap = gdk_colormap_get_system();
329 g_debug("prepare_status_line for state : %s",
330 g_quark_to_string(process
->state
->s
));
332 /* color of line : status of the process */
333 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
334 prop_line
.color
= drawing_colors
[COL_WHITE
];
335 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
336 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
337 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
338 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
339 else if(process
->state
->s
== LTTV_STATE_EXIT
)
340 prop_line
.color
= drawing_colors
[COL_EXIT
];
341 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
342 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
343 else if(process
->state
->s
== LTTV_STATE_WAIT
)
344 prop_line
.color
= drawing_colors
[COL_WAIT
];
345 else if(process
->state
->s
== LTTV_STATE_RUN
)
346 prop_line
.color
= drawing_colors
[COL_RUN
];
348 prop_line
.color
= drawing_colors
[COL_WHITE
];
350 //gdk_colormap_alloc_color(colormap,
361 /* before_schedchange_hook
363 * This function basically draw lines and icons. Two types of lines are drawn :
364 * one small (3 pixels?) representing the state of the process and the second
365 * type is thicker (10 pixels?) representing on which CPU a process is running
366 * (and this only in running state).
368 * Extremums of the lines :
369 * x_min : time of the last event context for this process kept in memory.
370 * x_max : time of the current event.
371 * y : middle of the process in the process list. The process is found in the
372 * list, therefore is it's position in pixels.
374 * The choice of lines'color is defined by the context of the last event for this
379 int before_schedchange_hook(void *hook_data
, void *call_data
)
381 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
382 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
383 Drawing_t
*drawing
= control_flow_data
->drawing
;
385 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
387 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
388 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
393 LttTime evtime
= ltt_event_time(e
);
394 TimeWindow time_window
=
395 lttvwindow_get_time_window(control_flow_data
->tab
);
397 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
398 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
401 guint width
= drawing
->width
;
403 /* we are in a schedchange, before the state update. We must draw the
404 * items corresponding to the state before it changes : now is the right
411 LttField
*f
= ltt_event_field(e
);
413 element
= ltt_field_member(f
,0);
414 pid_out
= ltt_event_get_long_unsigned(e
,element
);
415 element
= ltt_field_member(f
,1);
416 pid_in
= ltt_event_get_long_unsigned(e
,element
);
417 g_debug("out : %u in : %u", pid_out
, pid_in
);
421 /* For the pid_out */
422 /* First, check if the current process is in the state computation
423 * process list. If it is there, that means we must add it right now and
424 * draw items from the beginning of the read for it. If it is not
425 * present, it's a new process and it was not present : it will
426 * be added after the state update. */
427 LttvProcessState
*process
;
428 process
= lttv_state_find_process(tfs
, pid_out
);
429 //process = tfs->process;
431 if(process
!= NULL
) {
432 /* Well, the process_out existed : we must get it in the process hash
433 * or add it, and draw its items.
435 /* Add process to process list (if not present) */
436 guint y
= 0, height
= 0, pl_height
= 0;
437 HashedProcessData
*hashed_process_data
= NULL
;
438 ProcessList
*process_list
= control_flow_data
->process_list
;
439 LttTime birth
= process
->creation_time
;
440 const gchar
*name
= g_quark_to_string(process
->name
);
442 if(processlist_get_process_pixels(process_list
,
446 tfc
->t_context
->index
,
449 &hashed_process_data
) == 1)
451 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
452 /* Process not present */
453 ProcessInfo
*process_info
;
454 processlist_add(process_list
,
459 tfc
->t_context
->index
,
463 &hashed_process_data
);
464 processlist_get_pixels_from_data(process_list
,
469 drawing_insert_square( drawing
, y
, height
);
472 /* Now, the process is in the state hash and our own process hash.
473 * We definitely can draw the items related to the ending state.
476 /* Check if the x position is unset. In can have been left unset by
477 * a draw closure from a after chunk hook. This should never happen,
478 * because it must be set by before chunk hook to the damage_begin
481 g_assert(hashed_process_data
->x
.middle
!= -1);
482 if(ltt_time_compare(hashed_process_data
->next_good_time
,
485 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
487 convert_time_to_pixels(
493 /* Draw collision indicator */
494 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
495 gdk_draw_point(drawing
->pixmap
,
499 hashed_process_data
->x
.middle_marked
= TRUE
;
503 convert_time_to_pixels(
510 /* Jump over draw if we are at the same x position */
511 if(x
== hashed_process_data
->x
.middle
&&
512 hashed_process_data
->x
.middle_used
)
514 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
515 /* Draw collision indicator */
516 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
517 gdk_draw_point(drawing
->pixmap
,
521 hashed_process_data
->x
.middle_marked
= TRUE
;
525 DrawContext draw_context
;
527 /* Now create the drawing context that will be used to draw
528 * items related to the last state. */
529 draw_context
.drawable
= drawing
->pixmap
;
530 draw_context
.gc
= drawing
->gc
;
531 draw_context
.pango_layout
= drawing
->pango_layout
;
532 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
533 draw_context
.drawinfo
.end
.x
= x
;
535 draw_context
.drawinfo
.y
.over
= y
+1;
536 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
537 draw_context
.drawinfo
.y
.under
= y
+height
;
539 draw_context
.drawinfo
.start
.offset
.over
= 0;
540 draw_context
.drawinfo
.start
.offset
.middle
= 0;
541 draw_context
.drawinfo
.start
.offset
.under
= 0;
542 draw_context
.drawinfo
.end
.offset
.over
= 0;
543 draw_context
.drawinfo
.end
.offset
.middle
= 0;
544 draw_context
.drawinfo
.end
.offset
.under
= 0;
548 PropertiesLine prop_line
= prepare_s_e_line(process
);
549 draw_line((void*)&prop_line
, (void*)&draw_context
);
552 /* become the last x position */
553 hashed_process_data
->x
.middle
= x
;
554 hashed_process_data
->x
.middle_used
= TRUE
;
555 hashed_process_data
->x
.middle_marked
= FALSE
;
557 /* Calculate the next good time */
558 convert_pixels_to_time(width
, x
+1, time_window
,
559 &hashed_process_data
->next_good_time
);
567 /* First, check if the current process is in the state computation
568 * process list. If it is there, that means we must add it right now and
569 * draw items from the beginning of the read for it. If it is not
570 * present, it's a new process and it was not present : it will
571 * be added after the state update. */
572 LttvProcessState
*process
;
573 process
= lttv_state_find_process(tfs
, pid_in
);
575 if(process
!= NULL
) {
576 /* Well, the process_out existed : we must get it in the process hash
577 * or add it, and draw its items.
579 /* Add process to process list (if not present) */
580 guint y
= 0, height
= 0, pl_height
= 0;
581 HashedProcessData
*hashed_process_data
= NULL
;
582 ProcessList
*process_list
= control_flow_data
->process_list
;
583 LttTime birth
= process
->creation_time
;
584 const gchar
*name
= g_quark_to_string(process
->name
);
586 if(processlist_get_process_pixels(process_list
,
590 tfc
->t_context
->index
,
593 &hashed_process_data
) == 1)
595 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
596 /* Process not present */
597 ProcessInfo
*process_info
;
598 processlist_add(process_list
,
603 tfc
->t_context
->index
,
607 &hashed_process_data
);
608 processlist_get_pixels_from_data(process_list
,
613 drawing_insert_square( drawing
, y
, height
);
616 /* Now, the process is in the state hash and our own process hash.
617 * We definitely can draw the items related to the ending state.
620 /* Check if the x position is unset. In can have been left unset by
621 * a draw closure from a after chunk hook. This should never happen,
622 * because it must be set by before chunk hook to the damage_begin
625 g_assert(hashed_process_data
->x
.middle
!= -1);
627 if(ltt_time_compare(hashed_process_data
->next_good_time
,
630 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
632 convert_time_to_pixels(
638 /* Draw collision indicator */
639 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
640 gdk_draw_point(drawing
->pixmap
,
644 hashed_process_data
->x
.middle_marked
= TRUE
;
649 convert_time_to_pixels(
656 /* Jump over draw if we are at the same x position */
657 if(x
== hashed_process_data
->x
.middle
&&
658 hashed_process_data
->x
.middle_used
)
660 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
661 /* Draw collision indicator */
662 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
663 gdk_draw_point(drawing
->pixmap
,
667 hashed_process_data
->x
.middle_marked
= TRUE
;
671 DrawContext draw_context
;
673 /* Now create the drawing context that will be used to draw
674 * items related to the last state. */
675 draw_context
.drawable
= drawing
->pixmap
;
676 draw_context
.gc
= drawing
->gc
;
677 draw_context
.pango_layout
= drawing
->pango_layout
;
678 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
679 draw_context
.drawinfo
.end
.x
= x
;
681 draw_context
.drawinfo
.y
.over
= y
+1;
682 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
683 draw_context
.drawinfo
.y
.under
= y
+height
;
685 draw_context
.drawinfo
.start
.offset
.over
= 0;
686 draw_context
.drawinfo
.start
.offset
.middle
= 0;
687 draw_context
.drawinfo
.start
.offset
.under
= 0;
688 draw_context
.drawinfo
.end
.offset
.over
= 0;
689 draw_context
.drawinfo
.end
.offset
.middle
= 0;
690 draw_context
.drawinfo
.end
.offset
.under
= 0;
694 PropertiesLine prop_line
= prepare_s_e_line(process
);
695 draw_line((void*)&prop_line
, (void*)&draw_context
);
699 /* become the last x position */
700 hashed_process_data
->x
.middle
= x
;
701 hashed_process_data
->x
.middle_used
= TRUE
;
702 hashed_process_data
->x
.middle_marked
= FALSE
;
704 /* Calculate the next good time */
705 convert_pixels_to_time(width
, x
+1, time_window
,
706 &hashed_process_data
->next_good_time
);
715 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
716 ControlFlowData
*control_flow_data
=
717 (ControlFlowData
*)events_request
->viewer_data
;
718 Tab
*tab
= control_flow_data
->tab
;
720 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
722 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
723 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
728 LttTime evtime
= ltt_event_time(e
);
729 TimeWindow time_window
=
730 lttvwindow_get_time_window(tab
);
732 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
734 //if(time < time_beg || time > time_end) return;
735 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
736 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
739 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
741 g_debug("schedchange!");
743 /* Add process to process list (if not present) and get drawing "y" from
744 * process position */
745 guint pid_out
, pid_in
;
746 LttvProcessState
*process_out
, *process_in
;
748 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
750 ProcessList
*process_list
= control_flow_data
->process_list
;
753 LttField
*f
= ltt_event_field(e
);
755 element
= ltt_field_member(f
,0);
756 pid_out
= ltt_event_get_long_unsigned(e
,element
);
757 element
= ltt_field_member(f
,1);
758 pid_in
= ltt_event_get_long_unsigned(e
,element
);
759 g_debug("out : %u in : %u", pid_out
, pid_in
);
762 /* Find process pid_out in the list... */
763 process_out
= lttv_state_find_process(tfs
, pid_out
);
764 if(process_out
== NULL
) return 0;
765 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
767 birth
= process_out
->creation_time
;
768 const gchar
*name
= g_quark_to_string(process_out
->name
);
769 HashedProcessData
*hashed_process_data_out
= NULL
;
771 if(processlist_get_process_pixels(process_list
,
774 tfc
->t_context
->index
,
777 &hashed_process_data_out
) == 1)
779 /* Process not present */
780 processlist_add(process_list
,
783 tfc
->t_context
->index
,
786 &hashed_process_data_out
);
787 g_assert(processlist_get_process_pixels(process_list
,
790 tfc
->t_context
->index
,
793 &hashed_process_data_out
)==0);
794 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
798 /* Find process pid_in in the list... */
799 process_in
= lttv_state_find_process(tfs
, pid_in
);
800 if(process_in
== NULL
) return 0;
801 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
803 birth
= process_in
->creation_time
;
804 name
= g_quark_to_string(process_in
->name
);
805 HashedProcessData
*hashed_process_data_in
= NULL
;
807 if(processlist_get_process_pixels(process_list
,
810 tfc
->t_context
->index
,
813 &hashed_process_data_in
) == 1)
815 /* Process not present */
816 processlist_add(process_list
,
819 tfc
->t_context
->index
,
822 &hashed_process_data_in
);
823 processlist_get_process_pixels(process_list
,
826 tfc
->t_context
->index
,
829 &hashed_process_data_in
);
831 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
836 /* Find pixels corresponding to time of the event. If the time does
837 * not fit in the window, show a warning, not supposed to happend. */
839 guint width
= control_flow_data
->drawing
->width
;
841 LttTime time
= ltt_event_time(e
);
843 LttTime window_end
= time_window
.time_window
.end_time
;
845 convert_time_to_pixels(
850 //assert(x <= width);
852 /* draw what represents the event for outgoing process. */
854 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
855 draw_context_out
->current
->modify_over
->x
= x
;
856 draw_context_out
->current
->modify_under
->x
= x
;
857 draw_context_out
->current
->modify_over
->y
= y_out
;
858 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
859 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
860 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
861 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
862 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
863 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
864 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
865 //draw_context_out->gc = widget->style->black_gc;
867 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
868 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
870 /* Draw the line/background of the out process */
871 if(draw_context_out
->previous
->middle
->x
== -1)
873 draw_context_out
->previous
->over
->x
=
874 control_flow_data
->drawing
->damage_begin
;
875 draw_context_out
->previous
->middle
->x
=
876 control_flow_data
->drawing
->damage_begin
;
877 draw_context_out
->previous
->under
->x
=
878 control_flow_data
->drawing
->damage_begin
;
880 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
883 draw_context_out
->current
->middle
->x
= x
;
884 draw_context_out
->current
->over
->x
= x
;
885 draw_context_out
->current
->under
->x
= x
;
886 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
887 draw_context_out
->current
->over
->y
= y_out
;
888 draw_context_out
->current
->under
->y
= y_out
+ height
;
889 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
890 draw_context_out
->previous
->over
->y
= y_out
;
891 draw_context_out
->previous
->under
->y
= y_out
+ height
;
893 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
894 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
896 if(process_out
->state
->s
== LTTV_STATE_RUN
)
898 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
899 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
900 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
902 PropertiesBG prop_bg
;
903 prop_bg
.color
= g_new(GdkColor
,1);
907 prop_bg
.color
->red
= 0x1515;
908 prop_bg
.color
->green
= 0x1515;
909 prop_bg
.color
->blue
= 0x8c8c;
912 prop_bg
.color
->red
= 0x4e4e;
913 prop_bg
.color
->green
= 0xa9a9;
914 prop_bg
.color
->blue
= 0xa4a4;
917 prop_bg
.color
->red
= 0x7a7a;
918 prop_bg
.color
->green
= 0x4a4a;
919 prop_bg
.color
->blue
= 0x8b8b;
922 prop_bg
.color
->red
= 0x8080;
923 prop_bg
.color
->green
= 0x7777;
924 prop_bg
.color
->blue
= 0x4747;
927 prop_bg
.color
->red
= 0xe7e7;
928 prop_bg
.color
->green
= 0xe7e7;
929 prop_bg
.color
->blue
= 0xe7e7;
932 g_debug("calling from draw_event");
933 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
934 g_free(prop_bg
.color
);
935 //gdk_gc_unref(draw_context_out->gc);
938 draw_context_out
->gc
= widget
->style
->black_gc
;
940 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
941 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
942 PropertiesText prop_text_out
;
943 prop_text_out
.foreground
= &colorfg_out
;
944 prop_text_out
.background
= &colorbg_out
;
945 prop_text_out
.size
= 6;
946 prop_text_out
.position
= OVER
;
948 /* color of text : status of the process */
949 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
951 prop_text_out
.foreground
->red
= 0xffff;
952 prop_text_out
.foreground
->green
= 0xffff;
953 prop_text_out
.foreground
->blue
= 0xffff;
955 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
957 prop_text_out
.foreground
->red
= 0x0fff;
958 prop_text_out
.foreground
->green
= 0xffff;
959 prop_text_out
.foreground
->blue
= 0xfff0;
961 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
963 prop_text_out
.foreground
->red
= 0xffff;
964 prop_text_out
.foreground
->green
= 0xffff;
965 prop_text_out
.foreground
->blue
= 0x0000;
967 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
969 prop_text_out
.foreground
->red
= 0xffff;
970 prop_text_out
.foreground
->green
= 0x0000;
971 prop_text_out
.foreground
->blue
= 0xffff;
973 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
975 prop_text_out
.foreground
->red
= 0xffff;
976 prop_text_out
.foreground
->green
= 0x0000;
977 prop_text_out
.foreground
->blue
= 0x0000;
979 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
981 prop_text_out
.foreground
->red
= 0x0000;
982 prop_text_out
.foreground
->green
= 0xffff;
983 prop_text_out
.foreground
->blue
= 0x0000;
987 prop_text_out
.foreground
->red
= 0xffff;
988 prop_text_out
.foreground
->green
= 0xffff;
989 prop_text_out
.foreground
->blue
= 0xffff;
993 /* Print status of the process : U, WF, WC, E, W, R */
994 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
995 prop_text_out
.text
= "U->";
996 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
997 prop_text_out
.text
= "WF->";
998 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
999 prop_text_out
.text
= "WC->";
1000 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1001 prop_text_out
.text
= "E->";
1002 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1003 prop_text_out
.text
= "W->";
1004 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1005 prop_text_out
.text
= "R->";
1007 prop_text_out
.text
= "U";
1009 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1010 //gdk_gc_unref(draw_context_out->gc);
1012 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1013 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1014 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
1016 PropertiesLine prop_line_out
;
1017 prop_line_out
.color
= g_new(GdkColor
,1);
1018 prop_line_out
.line_width
= 2;
1019 prop_line_out
.style
= GDK_LINE_SOLID
;
1020 prop_line_out
.position
= MIDDLE
;
1022 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
1024 /* color of line : status of the process */
1025 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1027 prop_line_out
.color
->red
= 0xffff;
1028 prop_line_out
.color
->green
= 0xffff;
1029 prop_line_out
.color
->blue
= 0xffff;
1031 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1033 prop_line_out
.color
->red
= 0x0fff;
1034 prop_line_out
.color
->green
= 0xffff;
1035 prop_line_out
.color
->blue
= 0xfff0;
1037 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1039 prop_line_out
.color
->red
= 0xffff;
1040 prop_line_out
.color
->green
= 0xffff;
1041 prop_line_out
.color
->blue
= 0x0000;
1043 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1045 prop_line_out
.color
->red
= 0xffff;
1046 prop_line_out
.color
->green
= 0x0000;
1047 prop_line_out
.color
->blue
= 0xffff;
1049 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1051 prop_line_out
.color
->red
= 0xffff;
1052 prop_line_out
.color
->green
= 0x0000;
1053 prop_line_out
.color
->blue
= 0x0000;
1055 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1057 prop_line_out
.color
->red
= 0x0000;
1058 prop_line_out
.color
->green
= 0xffff;
1059 prop_line_out
.color
->blue
= 0x0000;
1063 prop_line_out
.color
->red
= 0xffff;
1064 prop_line_out
.color
->green
= 0xffff;
1065 prop_line_out
.color
->blue
= 0xffff;
1068 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1069 g_free(prop_line_out
.color
);
1070 //gdk_gc_unref(draw_context_out->gc);
1071 /* Note : finishing line will have to be added when trace read over. */
1073 /* Finally, update the drawing context of the pid_in. */
1075 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1076 draw_context_in
->current
->modify_over
->x
= x
;
1077 draw_context_in
->current
->modify_under
->x
= x
;
1078 draw_context_in
->current
->modify_over
->y
= y_in
;
1079 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1080 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1081 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1082 widget
= control_flow_data
->drawing
->drawing_area
;
1083 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1084 //draw_context_in->gc = widget->style->black_gc;
1085 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1086 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1088 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1089 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1091 /* Draw the line/bg of the in process */
1092 if(draw_context_in
->previous
->middle
->x
== -1)
1094 draw_context_in
->previous
->over
->x
=
1095 control_flow_data
->drawing
->damage_begin
;
1096 draw_context_in
->previous
->middle
->x
=
1097 control_flow_data
->drawing
->damage_begin
;
1098 draw_context_in
->previous
->under
->x
=
1099 control_flow_data
->drawing
->damage_begin
;
1101 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1105 draw_context_in
->current
->middle
->x
= x
;
1106 draw_context_in
->current
->over
->x
= x
;
1107 draw_context_in
->current
->under
->x
= x
;
1108 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1109 draw_context_in
->current
->over
->y
= y_in
;
1110 draw_context_in
->current
->under
->y
= y_in
+ height
;
1111 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1112 draw_context_in
->previous
->over
->y
= y_in
;
1113 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1115 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1116 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1119 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1121 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1122 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1123 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1125 PropertiesBG prop_bg
;
1126 prop_bg
.color
= g_new(GdkColor
,1);
1128 switch(tfc
->index
) {
1130 prop_bg
.color
->red
= 0x1515;
1131 prop_bg
.color
->green
= 0x1515;
1132 prop_bg
.color
->blue
= 0x8c8c;
1135 prop_bg
.color
->red
= 0x4e4e;
1136 prop_bg
.color
->green
= 0xa9a9;
1137 prop_bg
.color
->blue
= 0xa4a4;
1140 prop_bg
.color
->red
= 0x7a7a;
1141 prop_bg
.color
->green
= 0x4a4a;
1142 prop_bg
.color
->blue
= 0x8b8b;
1145 prop_bg
.color
->red
= 0x8080;
1146 prop_bg
.color
->green
= 0x7777;
1147 prop_bg
.color
->blue
= 0x4747;
1150 prop_bg
.color
->red
= 0xe7e7;
1151 prop_bg
.color
->green
= 0xe7e7;
1152 prop_bg
.color
->blue
= 0xe7e7;
1156 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1157 g_free(prop_bg
.color
);
1158 //gdk_gc_unref(draw_context_in->gc);
1161 draw_context_in
->gc
= widget
->style
->black_gc
;
1163 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1164 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1165 PropertiesText prop_text_in
;
1166 prop_text_in
.foreground
= &colorfg_in
;
1167 prop_text_in
.background
= &colorbg_in
;
1168 prop_text_in
.size
= 6;
1169 prop_text_in
.position
= OVER
;
1171 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1172 /* foreground of text : status of the process */
1173 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1175 prop_text_in
.foreground
->red
= 0xffff;
1176 prop_text_in
.foreground
->green
= 0xffff;
1177 prop_text_in
.foreground
->blue
= 0xffff;
1179 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1181 prop_text_in
.foreground
->red
= 0x0fff;
1182 prop_text_in
.foreground
->green
= 0xffff;
1183 prop_text_in
.foreground
->blue
= 0xfff0;
1185 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1187 prop_text_in
.foreground
->red
= 0xffff;
1188 prop_text_in
.foreground
->green
= 0xffff;
1189 prop_text_in
.foreground
->blue
= 0x0000;
1191 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1193 prop_text_in
.foreground
->red
= 0xffff;
1194 prop_text_in
.foreground
->green
= 0x0000;
1195 prop_text_in
.foreground
->blue
= 0xffff;
1197 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1199 prop_text_in
.foreground
->red
= 0xffff;
1200 prop_text_in
.foreground
->green
= 0x0000;
1201 prop_text_in
.foreground
->blue
= 0x0000;
1203 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1205 prop_text_in
.foreground
->red
= 0x0000;
1206 prop_text_in
.foreground
->green
= 0xffff;
1207 prop_text_in
.foreground
->blue
= 0x0000;
1211 prop_text_in
.foreground
->red
= 0xffff;
1212 prop_text_in
.foreground
->green
= 0xffff;
1213 prop_text_in
.foreground
->blue
= 0xffff;
1218 /* Print status of the process : U, WF, WC, E, W, R */
1219 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1220 prop_text_in
.text
= "U->";
1221 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1222 prop_text_in
.text
= "WF->";
1223 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1224 prop_text_in
.text
= "WC->";
1225 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1226 prop_text_in
.text
= "E->";
1227 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1228 prop_text_in
.text
= "W->";
1229 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1230 prop_text_in
.text
= "R->";
1232 prop_text_in
.text
= "U";
1234 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1235 //gdk_gc_unref(draw_context_in->gc);
1237 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1238 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1239 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1241 PropertiesLine prop_line_in
;
1242 prop_line_in
.color
= g_new(GdkColor
,1);
1243 prop_line_in
.line_width
= 2;
1244 prop_line_in
.style
= GDK_LINE_SOLID
;
1245 prop_line_in
.position
= MIDDLE
;
1247 /* color of line : status of the process */
1248 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1250 prop_line_in
.color
->red
= 0xffff;
1251 prop_line_in
.color
->green
= 0xffff;
1252 prop_line_in
.color
->blue
= 0xffff;
1254 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1256 prop_line_in
.color
->red
= 0x0fff;
1257 prop_line_in
.color
->green
= 0xffff;
1258 prop_line_in
.color
->blue
= 0xfff0;
1260 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1262 prop_line_in
.color
->red
= 0xffff;
1263 prop_line_in
.color
->green
= 0xffff;
1264 prop_line_in
.color
->blue
= 0x0000;
1266 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1268 prop_line_in
.color
->red
= 0xffff;
1269 prop_line_in
.color
->green
= 0x0000;
1270 prop_line_in
.color
->blue
= 0xffff;
1272 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1274 prop_line_in
.color
->red
= 0xffff;
1275 prop_line_in
.color
->green
= 0x0000;
1276 prop_line_in
.color
->blue
= 0x0000;
1278 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1280 prop_line_in
.color
->red
= 0x0000;
1281 prop_line_in
.color
->green
= 0xffff;
1282 prop_line_in
.color
->blue
= 0x0000;
1286 prop_line_in
.color
->red
= 0xffff;
1287 prop_line_in
.color
->green
= 0xffff;
1288 prop_line_in
.color
->blue
= 0xffff;
1291 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1292 g_free(prop_line_in
.color
);
1293 //gdk_gc_unref(draw_context_in->gc);
1303 GString
*string
= g_string_new("");;
1304 gboolean field_names
= TRUE
, state
= TRUE
;
1306 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1307 g_string_append_printf(string
,"\n");
1310 g_string_append_printf(string
, " %s",
1311 g_quark_to_string(tfs
->process
->state
->s
));
1314 g_info("%s",string
->str
);
1316 g_string_free(string
, TRUE
);
1318 /* End of text dump */
1323 /* after_schedchange_hook
1325 * The draw after hook is called by the reading API to have a
1326 * particular event drawn on the screen.
1327 * @param hook_data ControlFlowData structure of the viewer.
1328 * @param call_data Event context.
1330 * This function adds items to be drawn in a queue for each process.
1333 int after_schedchange_hook(void *hook_data
, void *call_data
)
1335 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1336 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1338 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1340 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1341 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
1346 LttTime evtime
= ltt_event_time(e
);
1347 TimeWindow time_window
=
1348 lttvwindow_get_time_window(control_flow_data
->tab
);
1351 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1352 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1354 #endif //EXTRA_CHECK
1356 guint width
= control_flow_data
->drawing
->width
;
1358 /* Add process to process list (if not present) */
1359 LttvProcessState
*process_out
, *process_in
;
1361 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1362 HashedProcessData
*hashed_process_data_in
= NULL
;
1364 ProcessList
*process_list
= control_flow_data
->process_list
;
1369 LttField
*f
= ltt_event_field(e
);
1371 element
= ltt_field_member(f
,0);
1372 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1373 element
= ltt_field_member(f
,1);
1374 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1375 g_debug("out : %u in : %u", pid_out
, pid_in
);
1379 /* Find process pid_in in the list... */
1380 process_in
= lttv_state_find_process(tfs
, pid_in
);
1381 /* It should exist, because we are after the state update. */
1382 g_assert(process_in
!= NULL
);
1384 birth
= process_in
->creation_time
;
1385 const gchar
*name
= g_quark_to_string(process_in
->name
);
1387 if(processlist_get_process_pixels(process_list
,
1389 process_in
->last_cpu
,
1391 tfc
->t_context
->index
,
1394 &hashed_process_data_in
) == 1)
1396 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1397 ProcessInfo
*process_info
;
1398 /* Process not present */
1399 processlist_add(process_list
,
1401 process_in
->last_cpu
,
1404 tfc
->t_context
->index
,
1408 &hashed_process_data_in
);
1409 processlist_get_pixels_from_data(process_list
,
1411 hashed_process_data_in
,
1414 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1417 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
1422 convert_time_to_pixels(
1428 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1429 hashed_process_data_in
->x
.middle
= new_x
;
1430 hashed_process_data_in
->x
.middle_used
= FALSE
;
1431 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1441 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1442 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1444 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1446 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1447 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1453 LttTime evtime
= ltt_event_time(e
);
1454 TimeWindow time_window
=
1455 lttvwindow_get_time_window(control_flow_data
->tab
);
1457 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
1459 //if(time < time_beg || time > time_end) return;
1460 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1461 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1465 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1467 g_debug("schedchange!");
1469 /* Add process to process list (if not present) and get drawing "y" from
1470 * process position */
1471 guint pid_out
, pid_in
;
1472 LttvProcessState
*process_out
, *process_in
;
1474 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1476 ProcessList
*process_list
= control_flow_data
->process_list
;
1479 LttField
*f
= ltt_event_field(e
);
1481 element
= ltt_field_member(f
,0);
1482 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1483 element
= ltt_field_member(f
,1);
1484 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1485 //g_debug("out : %u in : %u", pid_out, pid_in);
1488 /* Find process pid_out in the list... */
1489 process_out
= lttv_state_find_process(tfs
, pid_out
);
1490 if(process_out
== NULL
) return 0;
1491 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1493 birth
= process_out
->creation_time
;
1494 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1495 HashedProcessData
*hashed_process_data_out
= NULL
;
1497 if(processlist_get_process_pixels(process_list
,
1500 tfc
->t_context
->index
,
1503 &hashed_process_data_out
) == 1)
1505 /* Process not present */
1506 processlist_add(process_list
,
1509 tfc
->t_context
->index
,
1512 &hashed_process_data_out
);
1513 processlist_get_process_pixels(process_list
,
1516 tfc
->t_context
->index
,
1519 &hashed_process_data_out
);
1520 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1525 /* Find process pid_in in the list... */
1526 process_in
= lttv_state_find_process(tfs
, pid_in
);
1527 if(process_in
== NULL
) return 0;
1528 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1530 birth
= process_in
->creation_time
;
1531 name
= strdup(g_quark_to_string(process_in
->name
));
1532 HashedProcessData
*hashed_process_data_in
= NULL
;
1534 if(processlist_get_process_pixels(process_list
,
1537 tfc
->t_context
->index
,
1540 &hashed_process_data_in
) == 1)
1542 /* Process not present */
1543 processlist_add(process_list
,
1546 tfc
->t_context
->index
,
1549 &hashed_process_data_in
);
1550 processlist_get_process_pixels(process_list
,
1553 tfc
->t_context
->index
,
1556 &hashed_process_data_in
);
1558 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1563 /* Find pixels corresponding to time of the event. If the time does
1564 * not fit in the window, show a warning, not supposed to happend. */
1566 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1568 //LttTime time = ltt_event_time(e);
1570 //LttTime window_end = time_window->time_window.end_time;
1573 //convert_time_to_pixels(
1579 //assert(x <= width);
1581 /* draw what represents the event for outgoing process. */
1583 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1584 //draw_context_out->current->modify_over->x = x;
1585 draw_context_out
->current
->modify_over
->y
= y_out
;
1586 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1587 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1588 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1589 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1590 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1592 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1593 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1595 /*if(process_out->state->s == LTTV_STATE_RUN)
1597 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1598 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1599 PropertiesBG prop_bg;
1600 prop_bg.color = g_new(GdkColor,1);
1602 prop_bg.color->red = 0xffff;
1603 prop_bg.color->green = 0xffff;
1604 prop_bg.color->blue = 0xffff;
1606 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1607 g_free(prop_bg.color);
1608 gdk_gc_unref(draw_context_out->gc);
1611 draw_context_out
->gc
= widget
->style
->black_gc
;
1613 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1614 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1615 PropertiesText prop_text_out
;
1616 prop_text_out
.foreground
= &colorfg_out
;
1617 prop_text_out
.background
= &colorbg_out
;
1618 prop_text_out
.size
= 6;
1619 prop_text_out
.position
= OVER
;
1621 /* color of text : status of the process */
1622 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1624 prop_text_out
.foreground
->red
= 0xffff;
1625 prop_text_out
.foreground
->green
= 0xffff;
1626 prop_text_out
.foreground
->blue
= 0xffff;
1628 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1630 prop_text_out
.foreground
->red
= 0x0fff;
1631 prop_text_out
.foreground
->green
= 0xffff;
1632 prop_text_out
.foreground
->blue
= 0xfff0;
1634 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1636 prop_text_out
.foreground
->red
= 0xffff;
1637 prop_text_out
.foreground
->green
= 0xffff;
1638 prop_text_out
.foreground
->blue
= 0x0000;
1640 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1642 prop_text_out
.foreground
->red
= 0xffff;
1643 prop_text_out
.foreground
->green
= 0x0000;
1644 prop_text_out
.foreground
->blue
= 0xffff;
1646 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1648 prop_text_out
.foreground
->red
= 0xffff;
1649 prop_text_out
.foreground
->green
= 0x0000;
1650 prop_text_out
.foreground
->blue
= 0x0000;
1652 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1654 prop_text_out
.foreground
->red
= 0x0000;
1655 prop_text_out
.foreground
->green
= 0xffff;
1656 prop_text_out
.foreground
->blue
= 0x0000;
1660 prop_text_out
.foreground
->red
= 0xffff;
1661 prop_text_out
.foreground
->green
= 0xffff;
1662 prop_text_out
.foreground
->blue
= 0xffff;
1665 /* Print status of the process : U, WF, WC, E, W, R */
1666 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1667 prop_text_out
.text
= "U";
1668 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1669 prop_text_out
.text
= "WF";
1670 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1671 prop_text_out
.text
= "WC";
1672 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1673 prop_text_out
.text
= "E";
1674 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1675 prop_text_out
.text
= "W";
1676 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1677 prop_text_out
.text
= "R";
1679 prop_text_out
.text
= "U";
1681 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1683 //gdk_gc_unref(draw_context_out->gc);
1685 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1686 draw_context_out
->current
->over
->y
= y_out
;
1687 draw_context_out
->current
->under
->y
= y_out
+height
;
1688 draw_context_out
->current
->status
= process_out
->state
->s
;
1690 /* for pid_out : remove previous, Prev = current, new current (default) */
1691 g_free(draw_context_out
->previous
->modify_under
);
1692 g_free(draw_context_out
->previous
->modify_middle
);
1693 g_free(draw_context_out
->previous
->modify_over
);
1694 g_free(draw_context_out
->previous
->under
);
1695 g_free(draw_context_out
->previous
->middle
);
1696 g_free(draw_context_out
->previous
->over
);
1697 g_free(draw_context_out
->previous
);
1699 draw_context_out
->previous
= draw_context_out
->current
;
1701 draw_context_out
->current
= g_new(DrawInfo
,1);
1702 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1703 draw_context_out
->current
->over
->x
= -1;
1704 draw_context_out
->current
->over
->y
= -1;
1705 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1706 draw_context_out
->current
->middle
->x
= -1;
1707 draw_context_out
->current
->middle
->y
= -1;
1708 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1709 draw_context_out
->current
->under
->x
= -1;
1710 draw_context_out
->current
->under
->y
= -1;
1711 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1712 draw_context_out
->current
->modify_over
->x
= -1;
1713 draw_context_out
->current
->modify_over
->y
= -1;
1714 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1715 draw_context_out
->current
->modify_middle
->x
= -1;
1716 draw_context_out
->current
->modify_middle
->y
= -1;
1717 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1718 draw_context_out
->current
->modify_under
->x
= -1;
1719 draw_context_out
->current
->modify_under
->y
= -1;
1720 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1722 /* Finally, update the drawing context of the pid_in. */
1724 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1725 //draw_context_in->current->modify_over->x = x;
1726 draw_context_in
->current
->modify_over
->y
= y_in
;
1727 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1728 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1729 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1730 widget
= control_flow_data
->drawing
->drawing_area
;
1731 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1733 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1734 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1736 /*if(process_in->state->s == LTTV_STATE_RUN)
1738 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1739 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1740 PropertiesBG prop_bg;
1741 prop_bg.color = g_new(GdkColor,1);
1743 prop_bg.color->red = 0xffff;
1744 prop_bg.color->green = 0xffff;
1745 prop_bg.color->blue = 0xffff;
1747 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1748 g_free(prop_bg.color);
1749 gdk_gc_unref(draw_context_in->gc);
1752 draw_context_in
->gc
= widget
->style
->black_gc
;
1754 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1755 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1756 PropertiesText prop_text_in
;
1757 prop_text_in
.foreground
= &colorfg_in
;
1758 prop_text_in
.background
= &colorbg_in
;
1759 prop_text_in
.size
= 6;
1760 prop_text_in
.position
= OVER
;
1762 /* foreground of text : status of the process */
1763 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1765 prop_text_in
.foreground
->red
= 0xffff;
1766 prop_text_in
.foreground
->green
= 0xffff;
1767 prop_text_in
.foreground
->blue
= 0xffff;
1769 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1771 prop_text_in
.foreground
->red
= 0x0fff;
1772 prop_text_in
.foreground
->green
= 0xffff;
1773 prop_text_in
.foreground
->blue
= 0xfff0;
1775 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1777 prop_text_in
.foreground
->red
= 0xffff;
1778 prop_text_in
.foreground
->green
= 0xffff;
1779 prop_text_in
.foreground
->blue
= 0x0000;
1781 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1783 prop_text_in
.foreground
->red
= 0xffff;
1784 prop_text_in
.foreground
->green
= 0x0000;
1785 prop_text_in
.foreground
->blue
= 0xffff;
1787 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1789 prop_text_in
.foreground
->red
= 0xffff;
1790 prop_text_in
.foreground
->green
= 0x0000;
1791 prop_text_in
.foreground
->blue
= 0x0000;
1793 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1795 prop_text_in
.foreground
->red
= 0x0000;
1796 prop_text_in
.foreground
->green
= 0xffff;
1797 prop_text_in
.foreground
->blue
= 0x0000;
1801 prop_text_in
.foreground
->red
= 0xffff;
1802 prop_text_in
.foreground
->green
= 0xffff;
1803 prop_text_in
.foreground
->blue
= 0xffff;
1807 /* Print status of the process : U, WF, WC, E, W, R */
1808 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1809 prop_text_in
.text
= "U";
1810 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1811 prop_text_in
.text
= "WF";
1812 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1813 prop_text_in
.text
= "WC";
1814 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1815 prop_text_in
.text
= "E";
1816 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1817 prop_text_in
.text
= "W";
1818 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1819 prop_text_in
.text
= "R";
1821 prop_text_in
.text
= "U";
1823 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1826 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1829 prop_text_in
.foreground
= &colorfg_in
;
1830 prop_text_in
.background
= &colorbg_in
;
1831 prop_text_in
.foreground
->red
= 0xffff;
1832 prop_text_in
.foreground
->green
= 0xffff;
1833 prop_text_in
.foreground
->blue
= 0xffff;
1834 prop_text_in
.size
= 6;
1835 prop_text_in
.position
= UNDER
;
1837 prop_text_in
.text
= g_new(gchar
, 260);
1838 strcpy(prop_text_in
.text
, "CPU ");
1839 snprintf(tmp
, 255, "%u", tfc
->index
);
1840 strcat(prop_text_in
.text
, tmp
);
1842 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1843 g_free(prop_text_in
.text
);
1847 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1848 draw_context_in
->current
->over
->y
= y_in
;
1849 draw_context_in
->current
->under
->y
= y_in
+height
;
1850 draw_context_in
->current
->status
= process_in
->state
->s
;
1852 /* for pid_in : remove previous, Prev = current, new current (default) */
1853 g_free(draw_context_in
->previous
->modify_under
);
1854 g_free(draw_context_in
->previous
->modify_middle
);
1855 g_free(draw_context_in
->previous
->modify_over
);
1856 g_free(draw_context_in
->previous
->under
);
1857 g_free(draw_context_in
->previous
->middle
);
1858 g_free(draw_context_in
->previous
->over
);
1859 g_free(draw_context_in
->previous
);
1861 draw_context_in
->previous
= draw_context_in
->current
;
1863 draw_context_in
->current
= g_new(DrawInfo
,1);
1864 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1865 draw_context_in
->current
->over
->x
= -1;
1866 draw_context_in
->current
->over
->y
= -1;
1867 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1868 draw_context_in
->current
->middle
->x
= -1;
1869 draw_context_in
->current
->middle
->y
= -1;
1870 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1871 draw_context_in
->current
->under
->x
= -1;
1872 draw_context_in
->current
->under
->y
= -1;
1873 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1874 draw_context_in
->current
->modify_over
->x
= -1;
1875 draw_context_in
->current
->modify_over
->y
= -1;
1876 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1877 draw_context_in
->current
->modify_middle
->x
= -1;
1878 draw_context_in
->current
->modify_middle
->y
= -1;
1879 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1880 draw_context_in
->current
->modify_under
->x
= -1;
1881 draw_context_in
->current
->modify_under
->y
= -1;
1882 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1891 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1893 PropertiesLine prop_line
;
1894 prop_line
.line_width
= 1;
1895 prop_line
.style
= GDK_LINE_SOLID
;
1897 //GdkColormap *colormap = gdk_colormap_get_system();
1899 /* color of line : execution mode of the process */
1900 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1901 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1902 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1903 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1904 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1905 prop_line
.color
= drawing_colors
[COL_TRAP
];
1906 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1907 prop_line
.color
= drawing_colors
[COL_IRQ
];
1908 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1909 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1911 prop_line
.color
= drawing_colors
[COL_WHITE
];
1913 //gdk_colormap_alloc_color(colormap,
1924 /* before_execmode_hook
1926 * This function basically draw lines and icons. Two types of lines are drawn :
1927 * one small (3 pixels?) representing the state of the process and the second
1928 * type is thicker (10 pixels?) representing on which CPU a process is running
1929 * (and this only in running state).
1931 * Extremums of the lines :
1932 * x_min : time of the last event context for this process kept in memory.
1933 * x_max : time of the current event.
1934 * y : middle of the process in the process list. The process is found in the
1935 * list, therefore is it's position in pixels.
1937 * The choice of lines'color is defined by the context of the last event for this
1942 int before_execmode_hook(void *hook_data
, void *call_data
)
1944 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1945 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1946 Drawing_t
*drawing
= control_flow_data
->drawing
;
1948 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1950 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1951 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
1956 LttTime evtime
= ltt_event_time(e
);
1957 TimeWindow time_window
=
1958 lttvwindow_get_time_window(control_flow_data
->tab
);
1961 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1962 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1964 #endif //EXTRA_CHECK
1966 guint width
= drawing
->width
;
1968 /* we are in a execmode, before the state update. We must draw the
1969 * items corresponding to the state before it changes : now is the right
1973 LttvProcessState
*process
= tfs
->process
;
1974 g_assert(process
!= NULL
);
1976 guint pid
= process
->pid
;
1978 /* Well, the process_out existed : we must get it in the process hash
1979 * or add it, and draw its items.
1981 /* Add process to process list (if not present) */
1982 guint y
= 0, height
= 0, pl_height
= 0;
1983 HashedProcessData
*hashed_process_data
= NULL
;
1984 ProcessList
*process_list
= control_flow_data
->process_list
;
1985 LttTime birth
= process
->creation_time
;
1986 const gchar
*name
= g_quark_to_string(process
->name
);
1988 if(processlist_get_process_pixels(process_list
,
1992 tfc
->t_context
->index
,
1995 &hashed_process_data
) == 1)
1997 g_assert(pid
== 0 || pid
!= process
->ppid
);
1998 ProcessInfo
*process_info
;
1999 /* Process not present */
2000 processlist_add(process_list
,
2005 tfc
->t_context
->index
,
2009 &hashed_process_data
);
2010 processlist_get_pixels_from_data(process_list
,
2012 hashed_process_data
,
2015 drawing_insert_square( drawing
, y
, height
);
2018 /* Now, the process is in the state hash and our own process hash.
2019 * We definitely can draw the items related to the ending state.
2022 /* Check if the x position is unset. In can have been left unset by
2023 * a draw closure from a after chunk hook. This should never happen,
2024 * because it must be set by before chunk hook to the damage_begin
2027 g_assert(hashed_process_data
->x
.over
!= -1);
2029 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2032 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2034 convert_time_to_pixels(
2040 /* Draw collision indicator */
2041 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2042 gdk_draw_point(drawing
->pixmap
,
2046 hashed_process_data
->x
.middle_marked
= TRUE
;
2051 convert_time_to_pixels(
2058 /* Jump over draw if we are at the same x position */
2059 if(x
== hashed_process_data
->x
.middle
&&
2060 hashed_process_data
->x
.middle_used
)
2062 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2063 /* Draw collision indicator */
2064 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2065 gdk_draw_point(drawing
->pixmap
,
2069 hashed_process_data
->x
.middle_marked
= TRUE
;
2074 DrawContext draw_context
;
2075 /* Now create the drawing context that will be used to draw
2076 * items related to the last state. */
2077 draw_context
.drawable
= drawing
->pixmap
;
2078 draw_context
.gc
= drawing
->gc
;
2079 draw_context
.pango_layout
= drawing
->pango_layout
;
2080 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2081 draw_context
.drawinfo
.end
.x
= x
;
2083 draw_context
.drawinfo
.y
.over
= y
+1;
2084 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2085 draw_context
.drawinfo
.y
.under
= y
+height
;
2087 draw_context
.drawinfo
.start
.offset
.over
= 0;
2088 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2089 draw_context
.drawinfo
.start
.offset
.under
= 0;
2090 draw_context
.drawinfo
.end
.offset
.over
= 0;
2091 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2092 draw_context
.drawinfo
.end
.offset
.under
= 0;
2096 PropertiesLine prop_line
= prepare_s_e_line(process
);
2097 draw_line((void*)&prop_line
, (void*)&draw_context
);
2100 /* become the last x position */
2101 hashed_process_data
->x
.middle
= x
;
2102 hashed_process_data
->x
.middle_used
= TRUE
;
2103 hashed_process_data
->x
.middle_marked
= FALSE
;
2105 /* Calculate the next good time */
2106 convert_pixels_to_time(width
, x
+1, time_window
,
2107 &hashed_process_data
->next_good_time
);
2114 /* after_execmode_hook
2116 * The draw after hook is called by the reading API to have a
2117 * particular event drawn on the screen.
2118 * @param hook_data ControlFlowData structure of the viewer.
2119 * @param call_data Event context.
2121 * This function adds items to be drawn in a queue for each process.
2124 int after_execmode_hook(void *hook_data
, void *call_data
)
2126 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2127 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2129 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2131 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2132 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2137 LttTime evtime
= ltt_event_time(e
);
2138 TimeWindow time_window
=
2139 lttvwindow_get_time_window(control_flow_data
->tab
);
2142 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2143 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2145 #endif //EXTRA_CHECK
2147 guint width
= control_flow_data
->drawing
->width
;
2149 /* Add process to process list (if not present) */
2150 LttvProcessState
*process
;
2152 guint y
= 0, height
= 0, pl_height
= 0;
2153 HashedProcessData
*hashed_process_data
= NULL
;
2155 ProcessList
*process_list
= control_flow_data
->process_list
;
2157 /* Find process pid_in in the list... */
2158 process
= tfs
->process
;
2159 /* It should exist, because we are after the state update. */
2160 g_assert(process
!= NULL
);
2162 guint pid
= process
->pid
;
2164 birth
= process
->creation_time
;
2165 const gchar
*name
= g_quark_to_string(process
->name
);
2167 if(processlist_get_process_pixels(process_list
,
2171 tfc
->t_context
->index
,
2174 &hashed_process_data
) == 1)
2176 g_assert(pid
== 0 || pid
!= process
->ppid
);
2177 /* Process not present */
2178 ProcessInfo
*process_info
;
2179 processlist_add(process_list
,
2184 tfc
->t_context
->index
,
2188 &hashed_process_data
);
2189 processlist_get_pixels_from_data(process_list
,
2191 hashed_process_data
,
2194 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2197 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2202 convert_time_to_pixels(
2208 if(hashed_process_data
->x
.middle
!= new_x
) {
2209 hashed_process_data
->x
.middle
= new_x
;
2210 hashed_process_data
->x
.middle_used
= FALSE
;
2211 hashed_process_data
->x
.middle_marked
= FALSE
;
2219 /* before_process_hook
2221 * Draw lines for process event.
2223 * @param hook_data ControlFlowData structure of the viewer.
2224 * @param call_data Event context.
2226 * This function adds items to be drawn in a queue for each process.
2229 int before_process_hook(void *hook_data
, void *call_data
)
2231 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2232 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2233 Drawing_t
*drawing
= control_flow_data
->drawing
;
2235 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2237 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2238 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2243 LttTime evtime
= ltt_event_time(e
);
2244 TimeWindow time_window
=
2245 lttvwindow_get_time_window(control_flow_data
->tab
);
2248 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2249 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2251 #endif //EXTRA_CHECK
2253 guint width
= control_flow_data
->drawing
->width
;
2257 LttField
*f
= ltt_event_field(e
);
2259 element
= ltt_field_member(f
,0);
2260 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2263 if(sub_id
== 3) { /* exit */
2265 /* Add process to process list (if not present) */
2266 LttvProcessState
*process
= tfs
->process
;
2267 guint pid
= process
->pid
;
2269 guint y
= 0, height
= 0, pl_height
= 0;
2270 HashedProcessData
*hashed_process_data
= NULL
;
2272 ProcessList
*process_list
= control_flow_data
->process_list
;
2274 g_assert(process
!= NULL
);
2276 birth
= process
->creation_time
;
2277 const gchar
*name
= g_quark_to_string(process
->name
);
2279 if(processlist_get_process_pixels(process_list
,
2283 tfc
->t_context
->index
,
2286 &hashed_process_data
) == 1)
2288 g_assert(pid
== 0 || pid
!= process
->ppid
);
2289 /* Process not present */
2290 ProcessInfo
*process_info
;
2291 processlist_add(process_list
,
2296 tfc
->t_context
->index
,
2300 &hashed_process_data
);
2301 processlist_get_pixels_from_data(process_list
,
2303 hashed_process_data
,
2306 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2309 /* Now, the process is in the state hash and our own process hash.
2310 * We definitely can draw the items related to the ending state.
2313 /* Check if the x position is unset. In can have been left unset by
2314 * a draw closure from a after chunk hook. This should never happen,
2315 * because it must be set by before chunk hook to the damage_begin
2318 g_assert(hashed_process_data
->x
.over
!= -1);
2320 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2323 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2325 convert_time_to_pixels(
2331 /* Draw collision indicator */
2332 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2333 gdk_draw_point(drawing
->pixmap
,
2337 hashed_process_data
->x
.middle_marked
= TRUE
;
2342 convert_time_to_pixels(
2349 /* Jump over draw if we are at the same x position */
2350 if(x
== hashed_process_data
->x
.middle
&&
2351 hashed_process_data
->x
.middle_used
)
2353 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2354 /* Draw collision indicator */
2355 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2356 gdk_draw_point(drawing
->pixmap
,
2360 hashed_process_data
->x
.middle_marked
= TRUE
;
2364 DrawContext draw_context
;
2366 /* Now create the drawing context that will be used to draw
2367 * items related to the last state. */
2368 draw_context
.drawable
= drawing
->pixmap
;
2369 draw_context
.gc
= drawing
->gc
;
2370 draw_context
.pango_layout
= drawing
->pango_layout
;
2371 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2372 draw_context
.drawinfo
.end
.x
= x
;
2374 draw_context
.drawinfo
.y
.over
= y
+1;
2375 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2376 draw_context
.drawinfo
.y
.under
= y
+height
;
2378 draw_context
.drawinfo
.start
.offset
.over
= 0;
2379 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2380 draw_context
.drawinfo
.start
.offset
.under
= 0;
2381 draw_context
.drawinfo
.end
.offset
.over
= 0;
2382 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2383 draw_context
.drawinfo
.end
.offset
.under
= 0;
2387 PropertiesLine prop_line
= prepare_s_e_line(process
);
2388 draw_line((void*)&prop_line
, (void*)&draw_context
);
2391 /* become the last x position */
2392 hashed_process_data
->x
.middle
= x
;
2393 hashed_process_data
->x
.middle_used
= TRUE
;
2394 hashed_process_data
->x
.middle_marked
= FALSE
;
2396 /* Calculate the next good time */
2397 convert_pixels_to_time(width
, x
+1, time_window
,
2398 &hashed_process_data
->next_good_time
);
2412 /* after_process_hook
2414 * Create the processlist entry for the child process. Put the last
2415 * position in x at the current time value.
2417 * @param hook_data ControlFlowData structure of the viewer.
2418 * @param call_data Event context.
2420 * This function adds items to be drawn in a queue for each process.
2423 int after_process_hook(void *hook_data
, void *call_data
)
2425 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2426 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2428 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2430 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2431 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2436 LttTime evtime
= ltt_event_time(e
);
2437 TimeWindow time_window
=
2438 lttvwindow_get_time_window(control_flow_data
->tab
);
2441 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2442 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2444 #endif //EXTRA_CHECK
2446 guint width
= control_flow_data
->drawing
->width
;
2451 LttField
*f
= ltt_event_field(e
);
2453 element
= ltt_field_member(f
,0);
2454 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2455 element
= ltt_field_member(f
,1);
2456 param1
= ltt_event_get_long_unsigned(e
,element
);
2459 if(sub_id
== 2) { /* fork */
2461 guint child_pid
= param1
;
2462 /* Add process to process list (if not present) */
2463 LttvProcessState
*process_child
;
2465 guint y_child
= 0, height
= 0, pl_height
= 0;
2466 HashedProcessData
*hashed_process_data_child
= NULL
;
2468 ProcessList
*process_list
= control_flow_data
->process_list
;
2470 /* Find child in the list... */
2471 process_child
= lttv_state_find_process(tfs
, child_pid
);
2472 /* It should exist, because we are after the state update. */
2473 g_assert(process_child
!= NULL
);
2475 birth
= process_child
->creation_time
;
2476 const gchar
*name
= g_quark_to_string(process_child
->name
);
2478 if(processlist_get_process_pixels(process_list
,
2480 process_child
->last_cpu
,
2482 tfc
->t_context
->index
,
2485 &hashed_process_data_child
) == 1)
2487 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2488 /* Process not present */
2489 ProcessInfo
*process_info
;
2490 processlist_add(process_list
,
2492 process_child
->last_cpu
,
2493 process_child
->ppid
,
2495 tfc
->t_context
->index
,
2499 &hashed_process_data_child
);
2500 processlist_get_pixels_from_data(process_list
,
2502 hashed_process_data_child
,
2505 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2508 if(ltt_time_compare(hashed_process_data_child
->next_good_time
,
2512 convert_time_to_pixels(
2518 if(hashed_process_data_child
->x
.over
!= new_x
) {
2519 hashed_process_data_child
->x
.over
= new_x
;
2520 hashed_process_data_child
->x
.over_used
= FALSE
;
2521 hashed_process_data_child
->x
.over_marked
= FALSE
;
2523 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2524 hashed_process_data_child
->x
.middle
= new_x
;
2525 hashed_process_data_child
->x
.middle_used
= FALSE
;
2526 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2528 if(hashed_process_data_child
->x
.under
!= new_x
) {
2529 hashed_process_data_child
->x
.under
= new_x
;
2530 hashed_process_data_child
->x
.under_used
= FALSE
;
2531 hashed_process_data_child
->x
.under_marked
= FALSE
;
2535 } else if(sub_id
== 3) { /* exit */
2537 /* Add process to process list (if not present) */
2538 LttvProcessState
*process
= tfs
->process
;
2539 guint pid
= process
->pid
;
2541 guint y
= 0, height
= 0, pl_height
= 0;
2542 HashedProcessData
*hashed_process_data
= NULL
;
2544 ProcessList
*process_list
= control_flow_data
->process_list
;
2546 /* It should exist, because we are after the state update. */
2547 g_assert(process
!= NULL
);
2549 birth
= process
->creation_time
;
2550 const gchar
*name
= g_quark_to_string(process
->name
);
2552 if(processlist_get_process_pixels(process_list
,
2556 tfc
->t_context
->index
,
2559 &hashed_process_data
) == 1)
2561 g_assert(pid
== 0 || pid
!= process
->ppid
);
2562 /* Process not present */
2563 ProcessInfo
*process_info
;
2564 processlist_add(process_list
,
2569 tfc
->t_context
->index
,
2573 &hashed_process_data
);
2574 processlist_get_pixels_from_data(process_list
,
2576 hashed_process_data
,
2579 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2582 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2586 convert_time_to_pixels(
2591 if(hashed_process_data
->x
.middle
!= new_x
) {
2592 hashed_process_data
->x
.middle
= new_x
;
2593 hashed_process_data
->x
.middle_used
= FALSE
;
2594 hashed_process_data
->x
.middle_marked
= FALSE
;
2604 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2606 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2607 Drawing_t
*drawing
= control_flow_data
->drawing
;
2609 const TimeWindowNotifyData
*time_window_nofify_data
=
2610 ((const TimeWindowNotifyData
*)call_data
);
2612 TimeWindow
*old_time_window
=
2613 time_window_nofify_data
->old_time_window
;
2614 TimeWindow
*new_time_window
=
2615 time_window_nofify_data
->new_time_window
;
2617 /* Update the ruler */
2618 drawing_update_ruler(control_flow_data
->drawing
,
2622 /* Two cases : zoom in/out or scrolling */
2624 /* In order to make sure we can reuse the old drawing, the scale must
2625 * be the same and the new time interval being partly located in the
2626 * currently shown time interval. (reuse is only for scrolling)
2629 g_info("Old time window HOOK : %u, %u to %u, %u",
2630 old_time_window
->start_time
.tv_sec
,
2631 old_time_window
->start_time
.tv_nsec
,
2632 old_time_window
->time_width
.tv_sec
,
2633 old_time_window
->time_width
.tv_nsec
);
2635 g_info("New time window HOOK : %u, %u to %u, %u",
2636 new_time_window
->start_time
.tv_sec
,
2637 new_time_window
->start_time
.tv_nsec
,
2638 new_time_window
->time_width
.tv_sec
,
2639 new_time_window
->time_width
.tv_nsec
);
2641 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2642 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2644 /* Same scale (scrolling) */
2645 g_info("scrolling");
2646 LttTime
*ns
= &new_time_window
->start_time
;
2647 LttTime
*nw
= &new_time_window
->time_width
;
2648 LttTime
*os
= &old_time_window
->start_time
;
2649 LttTime
*ow
= &old_time_window
->time_width
;
2650 LttTime old_end
= old_time_window
->end_time
;
2651 LttTime new_end
= new_time_window
->end_time
;
2653 //if(ns<os+w && os+w<ns+w)
2654 //if(ns<old_end && os<ns)
2655 if(ltt_time_compare(*ns
, old_end
) == -1
2656 && ltt_time_compare(*os
, *ns
) == -1)
2658 g_info("scrolling near right");
2659 /* Scroll right, keep right part of the screen */
2661 guint width
= control_flow_data
->drawing
->width
;
2662 convert_time_to_pixels(
2668 /* Copy old data to new location */
2669 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2670 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2671 control_flow_data
->drawing
->pixmap
,
2674 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2676 if(drawing
->damage_begin
== drawing
->damage_end
)
2677 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2679 drawing
->damage_begin
= 0;
2681 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2683 /* Clear the data request background, but not SAFETY */
2684 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2685 //control_flow_data->drawing->drawing_area->style->black_gc,
2686 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2688 drawing
->damage_begin
+SAFETY
, 0,
2689 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2690 control_flow_data
->drawing
->height
);
2692 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2694 control_flow_data
->drawing
->width
,
2695 control_flow_data
->drawing
->height
);
2697 /* Get new data for the rest. */
2698 drawing_data_request(control_flow_data
->drawing
,
2699 &control_flow_data
->drawing
->pixmap
,
2700 drawing
->damage_begin
, 0,
2701 drawing
->damage_end
- drawing
->damage_begin
,
2702 control_flow_data
->drawing
->height
);
2705 //if(ns<os && os<ns+w)
2706 //if(ns<os && os<new_end)
2707 if(ltt_time_compare(*ns
,*os
) == -1
2708 && ltt_time_compare(*os
,new_end
) == -1)
2710 g_info("scrolling near left");
2711 /* Scroll left, keep left part of the screen */
2713 guint width
= control_flow_data
->drawing
->width
;
2714 convert_time_to_pixels(
2721 /* Copy old data to new location */
2722 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2723 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2724 control_flow_data
->drawing
->pixmap
,
2729 if(drawing
->damage_begin
== drawing
->damage_end
)
2730 drawing
->damage_end
= x
;
2732 drawing
->damage_end
=
2733 control_flow_data
->drawing
->width
;
2735 drawing
->damage_begin
= 0;
2737 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2738 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2740 drawing
->damage_begin
, 0,
2741 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2742 control_flow_data
->drawing
->height
);
2744 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2746 control_flow_data
->drawing
->width
,
2747 control_flow_data
->drawing
->height
);
2750 /* Get new data for the rest. */
2751 drawing_data_request(control_flow_data
->drawing
,
2752 &control_flow_data
->drawing
->pixmap
,
2753 drawing
->damage_begin
, 0,
2754 drawing
->damage_end
- drawing
->damage_begin
,
2755 control_flow_data
->drawing
->height
);
2758 if(ltt_time_compare(*ns
,*os
) == 0)
2760 g_info("not scrolling");
2762 g_info("scrolling far");
2763 /* Cannot reuse any part of the screen : far jump */
2766 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2767 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2770 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2771 control_flow_data
->drawing
->height
);
2773 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2775 control_flow_data
->drawing
->width
,
2776 control_flow_data
->drawing
->height
);
2778 drawing
->damage_begin
= 0;
2779 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2781 drawing_data_request(control_flow_data
->drawing
,
2782 &control_flow_data
->drawing
->pixmap
,
2784 control_flow_data
->drawing
->width
,
2785 control_flow_data
->drawing
->height
);
2791 /* Different scale (zoom) */
2794 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2795 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2798 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2799 control_flow_data
->drawing
->height
);
2801 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2803 control_flow_data
->drawing
->width
,
2804 control_flow_data
->drawing
->height
);
2806 drawing
->damage_begin
= 0;
2807 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2809 drawing_data_request(control_flow_data
->drawing
,
2810 &control_flow_data
->drawing
->pixmap
,
2812 control_flow_data
->drawing
->width
,
2813 control_flow_data
->drawing
->height
);
2821 gint
traceset_notify(void *hook_data
, void *call_data
)
2823 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2824 Drawing_t
*drawing
= control_flow_data
->drawing
;
2825 GtkWidget
*widget
= drawing
->drawing_area
;
2828 drawing_clear(control_flow_data
->drawing
);
2829 processlist_clear(control_flow_data
->process_list
);
2830 redraw_notify(control_flow_data
, NULL
);
2832 request_background_data(control_flow_data
);
2834 drawing
->damage_begin
= 0;
2835 drawing
->damage_end
= drawing
->width
;
2836 if(drawing
->damage_begin
< drawing
->damage_end
)
2838 drawing_data_request(drawing
,
2840 drawing
->damage_begin
,
2842 drawing
->damage_end
-drawing
->damage_begin
,
2846 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2855 gint
redraw_notify(void *hook_data
, void *call_data
)
2857 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2858 Drawing_t
*drawing
= control_flow_data
->drawing
;
2859 GtkWidget
*widget
= drawing
->drawing_area
;
2861 drawing
->damage_begin
= 0;
2862 drawing
->damage_end
= drawing
->width
;
2864 /* fun feature, to be separated someday... */
2865 drawing_clear(control_flow_data
->drawing
);
2866 processlist_clear(control_flow_data
->process_list
);
2869 gdk_draw_rectangle (drawing
->pixmap
,
2870 widget
->style
->black_gc
,
2873 drawing
->width
+SAFETY
,
2877 if(drawing
->damage_begin
< drawing
->damage_end
)
2879 drawing_data_request(drawing
,
2881 drawing
->damage_begin
,
2883 drawing
->damage_end
-drawing
->damage_begin
,
2887 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2896 gint
continue_notify(void *hook_data
, void *call_data
)
2898 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2899 Drawing_t
*drawing
= control_flow_data
->drawing
;
2900 GtkWidget
*widget
= drawing
->drawing_area
;
2902 //g_assert(widget->allocation.width == drawing->damage_end);
2904 if(drawing
->damage_begin
< drawing
->damage_end
)
2906 drawing_data_request(drawing
,
2908 drawing
->damage_begin
,
2910 drawing
->damage_end
-drawing
->damage_begin
,
2918 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2920 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2921 Drawing_t
*drawing
= control_flow_data
->drawing
;
2923 LttTime current_time
= *((LttTime
*)call_data
);
2925 TimeWindow time_window
=
2926 lttvwindow_get_time_window(control_flow_data
->tab
);
2928 LttTime time_begin
= time_window
.start_time
;
2929 LttTime width
= time_window
.time_width
;
2932 guint64 time_ll
= ltt_time_to_uint64(width
);
2933 time_ll
= time_ll
>> 1; /* divide by two */
2934 half_width
= ltt_time_from_uint64(time_ll
);
2936 LttTime time_end
= ltt_time_add(time_begin
, width
);
2938 LttvTracesetContext
* tsc
=
2939 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2941 LttTime trace_start
= tsc
->time_span
.start_time
;
2942 LttTime trace_end
= tsc
->time_span
.end_time
;
2944 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2945 current_time
.tv_nsec
);
2949 /* If current time is inside time interval, just move the highlight
2952 /* Else, we have to change the time interval. We have to tell it
2953 * to the main window. */
2954 /* The time interval change will take care of placing the current
2955 * time at the center of the visible area, or nearest possible if we are
2956 * at one end of the trace. */
2959 if(ltt_time_compare(current_time
, time_begin
) == -1)
2961 TimeWindow new_time_window
;
2963 if(ltt_time_compare(current_time
,
2964 ltt_time_add(trace_start
,half_width
)) == -1)
2965 time_begin
= trace_start
;
2967 time_begin
= ltt_time_sub(current_time
,half_width
);
2969 new_time_window
.start_time
= time_begin
;
2970 new_time_window
.time_width
= width
;
2971 new_time_window
.time_width_double
= ltt_time_to_double(width
);
2972 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2974 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2976 else if(ltt_time_compare(current_time
, time_end
) == 1)
2978 TimeWindow new_time_window
;
2980 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2981 time_begin
= ltt_time_sub(trace_end
,width
);
2983 time_begin
= ltt_time_sub(current_time
,half_width
);
2985 new_time_window
.start_time
= time_begin
;
2986 new_time_window
.time_width
= width
;
2987 new_time_window
.time_width_double
= ltt_time_to_double(width
);
2988 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2990 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2993 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2994 gtk_widget_queue_draw_area(drawing
->drawing_area
,
3002 typedef struct _ClosureData
{
3003 EventsRequest
*events_request
;
3004 LttvTracesetState
*tss
;
3009 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3011 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3012 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3013 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3015 EventsRequest
*events_request
= closure_data
->events_request
;
3016 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3017 Drawing_t
*drawing
= control_flow_data
->drawing
;
3019 LttvTracesetState
*tss
= closure_data
->tss
;
3020 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
3022 LttTime evtime
= closure_data
->end_time
;
3023 TimeWindow time_window
=
3024 lttvwindow_get_time_window(control_flow_data
->tab
);
3027 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3028 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3030 #endif //EXTRA_CHECK
3032 guint width
= drawing
->width
;
3035 /* For the process */
3036 /* First, check if the current process is in the state computation
3037 * process list. If it is there, that means we must add it right now and
3038 * draw items from the beginning of the read for it. If it is not
3039 * present, it's a new process and it was not present : it will
3040 * be added after the state update. */
3041 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3043 /* tracefiles[0] is ok here, because we draw for every PID, and
3044 * assume CPU 0 for PID 0 //FIXME */
3045 LttvTracefileState
*tfs
=
3046 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
3048 LttvProcessState
*process
;
3049 process
= lttv_state_find_process(tfs
,
3052 if(process
!= NULL
) {
3054 /* Only draw for processes that are currently in the trace states */
3056 guint y
= 0, height
= 0, pl_height
= 0;
3057 ProcessList
*process_list
= control_flow_data
->process_list
;
3058 LttTime birth
= process_info
->birth
;
3060 /* Should be alike when background info is ready */
3061 if(control_flow_data
->background_info_waiting
==0)
3062 g_assert(ltt_time_compare(process
->creation_time
,
3063 process_info
->birth
) == 0);
3064 const gchar
*name
= g_quark_to_string(process
->name
);
3066 /* process HAS to be present */
3067 processlist_get_pixels_from_data(process_list
,
3069 hashed_process_data
,
3073 /* Now, the process is in the state hash and our own process hash.
3074 * We definitely can draw the items related to the ending state.
3077 /* Check if the x position is unset. In can have been left unset by
3078 * a draw closure from a after chunk hook. This should never happen,
3079 * because it must be set by before chunk hook to the damage_begin
3082 g_assert(hashed_process_data
->x
.over
!= -1);
3084 if(ltt_time_compare(hashed_process_data
->next_good_time
,
3089 convert_time_to_pixels(
3095 DrawContext draw_context
;
3097 /* Now create the drawing context that will be used to draw
3098 * items related to the last state. */
3099 draw_context
.drawable
= drawing
->pixmap
;
3100 draw_context
.gc
= drawing
->gc
;
3101 draw_context
.pango_layout
= drawing
->pango_layout
;
3102 draw_context
.drawinfo
.end
.x
= x
;
3104 draw_context
.drawinfo
.y
.over
= y
+1;
3105 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3106 draw_context
.drawinfo
.y
.under
= y
+height
;
3108 draw_context
.drawinfo
.start
.offset
.over
= 0;
3109 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3110 draw_context
.drawinfo
.start
.offset
.under
= 0;
3111 draw_context
.drawinfo
.end
.offset
.over
= 0;
3112 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3113 draw_context
.drawinfo
.end
.offset
.under
= 0;
3115 /* Jump over draw if we are at the same x position */
3116 if(x
== hashed_process_data
->x
.over
)
3120 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3122 PropertiesLine prop_line
= prepare_execmode_line(process
);
3123 draw_line((void*)&prop_line
, (void*)&draw_context
);
3125 hashed_process_data
->x
.over
= x
;
3129 if(x
== hashed_process_data
->x
.middle
&&
3130 hashed_process_data
->x
.middle_used
) {
3131 #if 0 /* do not mark closure : not missing information */
3132 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3133 /* Draw collision indicator */
3134 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3135 gdk_draw_point(drawing
->pixmap
,
3139 hashed_process_data
->x
.middle_marked
= TRUE
;
3144 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3146 PropertiesLine prop_line
= prepare_s_e_line(process
);
3147 draw_line((void*)&prop_line
, (void*)&draw_context
);
3149 /* become the last x position */
3150 if(x
!= hashed_process_data
->x
.middle
) {
3151 hashed_process_data
->x
.middle
= x
;
3152 /* but don't use the pixel */
3153 hashed_process_data
->x
.middle_used
= FALSE
;
3155 /* Calculate the next good time */
3156 convert_pixels_to_time(width
, x
+1, time_window
,
3157 &hashed_process_data
->next_good_time
);
3166 int before_chunk(void *hook_data
, void *call_data
)
3168 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3169 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3171 drawing_chunk_begin(events_request
, tss
);
3176 int before_request(void *hook_data
, void *call_data
)
3178 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3179 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3181 drawing_data_request_begin(events_request
, tss
);
3188 * after request is necessary in addition of after chunk in order to draw
3189 * lines until the end of the screen. after chunk just draws lines until
3196 int after_request(void *hook_data
, void *call_data
)
3198 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3199 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3200 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3201 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3203 ProcessList
*process_list
= control_flow_data
->process_list
;
3204 LttTime end_time
= events_request
->end_time
;
3206 ClosureData closure_data
;
3207 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3208 closure_data
.tss
= tss
;
3209 closure_data
.end_time
= end_time
;
3211 /* Draw last items */
3212 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3213 (void*)&closure_data
);
3215 /* Request expose */
3216 drawing_request_expose(events_request
, tss
, end_time
);
3225 int after_chunk(void *hook_data
, void *call_data
)
3227 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3228 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3229 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3230 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3231 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3234 ProcessList
*process_list
= control_flow_data
->process_list
;
3237 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3238 else /* end of traceset, or position now out of request : end */
3239 end_time
= events_request
->end_time
;
3241 ClosureData closure_data
;
3242 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3243 closure_data
.tss
= tss
;
3244 closure_data
.end_time
= end_time
;
3246 /* Draw last items */
3247 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3248 (void*)&closure_data
);
3250 /* Request expose */
3251 drawing_request_expose(events_request
, tss
, end_time
);