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
);
395 guint width
= drawing
->width
;
397 /* we are in a schedchange, before the state update. We must draw the
398 * items corresponding to the state before it changes : now is the right
405 LttField
*f
= ltt_event_field(e
);
407 element
= ltt_field_member(f
,0);
408 pid_out
= ltt_event_get_long_unsigned(e
,element
);
409 element
= ltt_field_member(f
,1);
410 pid_in
= ltt_event_get_long_unsigned(e
,element
);
411 g_debug("out : %u in : %u", pid_out
, pid_in
);
415 /* For the pid_out */
416 /* First, check if the current process is in the state computation
417 * process list. If it is there, that means we must add it right now and
418 * draw items from the beginning of the read for it. If it is not
419 * present, it's a new process and it was not present : it will
420 * be added after the state update. */
421 LttvProcessState
*process
;
422 process
= lttv_state_find_process(tfs
, pid_out
);
423 //process = tfs->process;
425 if(process
!= NULL
) {
426 /* Well, the process_out existed : we must get it in the process hash
427 * or add it, and draw its items.
429 /* Add process to process list (if not present) */
430 guint y
= 0, height
= 0, pl_height
= 0;
431 HashedProcessData
*hashed_process_data
= NULL
;
432 ProcessList
*process_list
= control_flow_data
->process_list
;
433 LttTime birth
= process
->creation_time
;
434 const gchar
*name
= g_quark_to_string(process
->name
);
436 if(processlist_get_process_pixels(process_list
,
440 tfc
->t_context
->index
,
443 &hashed_process_data
) == 1)
445 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
446 /* Process not present */
447 ProcessInfo
*process_info
;
448 processlist_add(process_list
,
453 tfc
->t_context
->index
,
457 &hashed_process_data
);
458 processlist_get_pixels_from_data(process_list
,
463 drawing_insert_square( drawing
, y
, height
);
466 /* Now, the process is in the state hash and our own process hash.
467 * We definitely can draw the items related to the ending state.
470 /* Check if the x position is unset. In can have been left unset by
471 * a draw closure from a after chunk hook. This should never happen,
472 * because it must be set by before chunk hook to the damage_begin
475 g_assert(hashed_process_data
->x
.middle
!= -1);
476 if(ltt_time_compare(hashed_process_data
->next_good_time
,
479 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
480 TimeWindow time_window
=
481 lttvwindow_get_time_window(control_flow_data
->tab
);
483 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
484 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
489 convert_time_to_pixels(
495 /* Draw collision indicator */
496 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
497 gdk_draw_point(drawing
->pixmap
,
501 hashed_process_data
->x
.middle_marked
= TRUE
;
504 TimeWindow time_window
=
505 lttvwindow_get_time_window(control_flow_data
->tab
);
507 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
508 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
513 convert_time_to_pixels(
520 /* Jump over draw if we are at the same x position */
521 if(x
== hashed_process_data
->x
.middle
&&
522 hashed_process_data
->x
.middle_used
)
524 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
525 /* Draw collision indicator */
526 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
527 gdk_draw_point(drawing
->pixmap
,
531 hashed_process_data
->x
.middle_marked
= TRUE
;
535 DrawContext draw_context
;
537 /* Now create the drawing context that will be used to draw
538 * items related to the last state. */
539 draw_context
.drawable
= drawing
->pixmap
;
540 draw_context
.gc
= drawing
->gc
;
541 draw_context
.pango_layout
= drawing
->pango_layout
;
542 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
543 draw_context
.drawinfo
.end
.x
= x
;
545 draw_context
.drawinfo
.y
.over
= y
+1;
546 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
547 draw_context
.drawinfo
.y
.under
= y
+height
;
549 draw_context
.drawinfo
.start
.offset
.over
= 0;
550 draw_context
.drawinfo
.start
.offset
.middle
= 0;
551 draw_context
.drawinfo
.start
.offset
.under
= 0;
552 draw_context
.drawinfo
.end
.offset
.over
= 0;
553 draw_context
.drawinfo
.end
.offset
.middle
= 0;
554 draw_context
.drawinfo
.end
.offset
.under
= 0;
558 PropertiesLine prop_line
= prepare_s_e_line(process
);
559 draw_line((void*)&prop_line
, (void*)&draw_context
);
562 /* become the last x position */
563 hashed_process_data
->x
.middle
= x
;
564 hashed_process_data
->x
.middle_used
= TRUE
;
565 hashed_process_data
->x
.middle_marked
= FALSE
;
567 /* Calculate the next good time */
568 convert_pixels_to_time(width
, x
+1, time_window
,
569 &hashed_process_data
->next_good_time
);
577 /* First, check if the current process is in the state computation
578 * process list. If it is there, that means we must add it right now and
579 * draw items from the beginning of the read for it. If it is not
580 * present, it's a new process and it was not present : it will
581 * be added after the state update. */
582 LttvProcessState
*process
;
583 process
= lttv_state_find_process(tfs
, pid_in
);
585 if(process
!= NULL
) {
586 /* Well, the process_out existed : we must get it in the process hash
587 * or add it, and draw its items.
589 /* Add process to process list (if not present) */
590 guint y
= 0, height
= 0, pl_height
= 0;
591 HashedProcessData
*hashed_process_data
= NULL
;
592 ProcessList
*process_list
= control_flow_data
->process_list
;
593 LttTime birth
= process
->creation_time
;
594 const gchar
*name
= g_quark_to_string(process
->name
);
596 if(processlist_get_process_pixels(process_list
,
600 tfc
->t_context
->index
,
603 &hashed_process_data
) == 1)
605 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
606 /* Process not present */
607 ProcessInfo
*process_info
;
608 processlist_add(process_list
,
613 tfc
->t_context
->index
,
617 &hashed_process_data
);
618 processlist_get_pixels_from_data(process_list
,
623 drawing_insert_square( drawing
, y
, height
);
626 /* Now, the process is in the state hash and our own process hash.
627 * We definitely can draw the items related to the ending state.
630 /* Check if the x position is unset. In can have been left unset by
631 * a draw closure from a after chunk hook. This should never happen,
632 * because it must be set by before chunk hook to the damage_begin
635 g_assert(hashed_process_data
->x
.middle
!= -1);
637 if(ltt_time_compare(hashed_process_data
->next_good_time
,
640 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
641 TimeWindow time_window
=
642 lttvwindow_get_time_window(control_flow_data
->tab
);
644 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
645 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
649 convert_time_to_pixels(
655 /* Draw collision indicator */
656 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
657 gdk_draw_point(drawing
->pixmap
,
661 hashed_process_data
->x
.middle_marked
= TRUE
;
664 TimeWindow time_window
=
665 lttvwindow_get_time_window(control_flow_data
->tab
);
667 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
668 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
673 convert_time_to_pixels(
680 /* Jump over draw if we are at the same x position */
681 if(x
== hashed_process_data
->x
.middle
&&
682 hashed_process_data
->x
.middle_used
)
684 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
685 /* Draw collision indicator */
686 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
687 gdk_draw_point(drawing
->pixmap
,
691 hashed_process_data
->x
.middle_marked
= TRUE
;
695 DrawContext draw_context
;
697 /* Now create the drawing context that will be used to draw
698 * items related to the last state. */
699 draw_context
.drawable
= drawing
->pixmap
;
700 draw_context
.gc
= drawing
->gc
;
701 draw_context
.pango_layout
= drawing
->pango_layout
;
702 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
703 draw_context
.drawinfo
.end
.x
= x
;
705 draw_context
.drawinfo
.y
.over
= y
+1;
706 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
707 draw_context
.drawinfo
.y
.under
= y
+height
;
709 draw_context
.drawinfo
.start
.offset
.over
= 0;
710 draw_context
.drawinfo
.start
.offset
.middle
= 0;
711 draw_context
.drawinfo
.start
.offset
.under
= 0;
712 draw_context
.drawinfo
.end
.offset
.over
= 0;
713 draw_context
.drawinfo
.end
.offset
.middle
= 0;
714 draw_context
.drawinfo
.end
.offset
.under
= 0;
718 PropertiesLine prop_line
= prepare_s_e_line(process
);
719 draw_line((void*)&prop_line
, (void*)&draw_context
);
723 /* become the last x position */
724 hashed_process_data
->x
.middle
= x
;
725 hashed_process_data
->x
.middle_used
= TRUE
;
726 hashed_process_data
->x
.middle_marked
= FALSE
;
728 /* Calculate the next good time */
729 convert_pixels_to_time(width
, x
+1, time_window
,
730 &hashed_process_data
->next_good_time
);
739 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
740 ControlFlowData
*control_flow_data
=
741 (ControlFlowData
*)events_request
->viewer_data
;
742 Tab
*tab
= control_flow_data
->tab
;
744 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
746 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
747 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
752 LttTime evtime
= ltt_event_time(e
);
753 TimeWindow time_window
=
754 lttvwindow_get_time_window(tab
);
756 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
758 //if(time < time_beg || time > time_end) return;
759 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
760 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
763 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
765 g_debug("schedchange!");
767 /* Add process to process list (if not present) and get drawing "y" from
768 * process position */
769 guint pid_out
, pid_in
;
770 LttvProcessState
*process_out
, *process_in
;
772 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
774 ProcessList
*process_list
= control_flow_data
->process_list
;
777 LttField
*f
= ltt_event_field(e
);
779 element
= ltt_field_member(f
,0);
780 pid_out
= ltt_event_get_long_unsigned(e
,element
);
781 element
= ltt_field_member(f
,1);
782 pid_in
= ltt_event_get_long_unsigned(e
,element
);
783 g_debug("out : %u in : %u", pid_out
, pid_in
);
786 /* Find process pid_out in the list... */
787 process_out
= lttv_state_find_process(tfs
, pid_out
);
788 if(process_out
== NULL
) return 0;
789 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
791 birth
= process_out
->creation_time
;
792 const gchar
*name
= g_quark_to_string(process_out
->name
);
793 HashedProcessData
*hashed_process_data_out
= NULL
;
795 if(processlist_get_process_pixels(process_list
,
798 tfc
->t_context
->index
,
801 &hashed_process_data_out
) == 1)
803 /* Process not present */
804 processlist_add(process_list
,
807 tfc
->t_context
->index
,
810 &hashed_process_data_out
);
811 g_assert(processlist_get_process_pixels(process_list
,
814 tfc
->t_context
->index
,
817 &hashed_process_data_out
)==0);
818 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
822 /* Find process pid_in in the list... */
823 process_in
= lttv_state_find_process(tfs
, pid_in
);
824 if(process_in
== NULL
) return 0;
825 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
827 birth
= process_in
->creation_time
;
828 name
= g_quark_to_string(process_in
->name
);
829 HashedProcessData
*hashed_process_data_in
= NULL
;
831 if(processlist_get_process_pixels(process_list
,
834 tfc
->t_context
->index
,
837 &hashed_process_data_in
) == 1)
839 /* Process not present */
840 processlist_add(process_list
,
843 tfc
->t_context
->index
,
846 &hashed_process_data_in
);
847 processlist_get_process_pixels(process_list
,
850 tfc
->t_context
->index
,
853 &hashed_process_data_in
);
855 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
860 /* Find pixels corresponding to time of the event. If the time does
861 * not fit in the window, show a warning, not supposed to happend. */
863 guint width
= control_flow_data
->drawing
->width
;
865 LttTime time
= ltt_event_time(e
);
867 LttTime window_end
= time_window
.time_window
.end_time
;
869 convert_time_to_pixels(
874 //assert(x <= width);
876 /* draw what represents the event for outgoing process. */
878 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
879 draw_context_out
->current
->modify_over
->x
= x
;
880 draw_context_out
->current
->modify_under
->x
= x
;
881 draw_context_out
->current
->modify_over
->y
= y_out
;
882 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
883 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
884 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
885 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
886 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
887 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
888 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
889 //draw_context_out->gc = widget->style->black_gc;
891 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
892 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
894 /* Draw the line/background of the out process */
895 if(draw_context_out
->previous
->middle
->x
== -1)
897 draw_context_out
->previous
->over
->x
=
898 control_flow_data
->drawing
->damage_begin
;
899 draw_context_out
->previous
->middle
->x
=
900 control_flow_data
->drawing
->damage_begin
;
901 draw_context_out
->previous
->under
->x
=
902 control_flow_data
->drawing
->damage_begin
;
904 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
907 draw_context_out
->current
->middle
->x
= x
;
908 draw_context_out
->current
->over
->x
= x
;
909 draw_context_out
->current
->under
->x
= x
;
910 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
911 draw_context_out
->current
->over
->y
= y_out
;
912 draw_context_out
->current
->under
->y
= y_out
+ height
;
913 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
914 draw_context_out
->previous
->over
->y
= y_out
;
915 draw_context_out
->previous
->under
->y
= y_out
+ height
;
917 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
918 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
920 if(process_out
->state
->s
== LTTV_STATE_RUN
)
922 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
923 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
924 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
926 PropertiesBG prop_bg
;
927 prop_bg
.color
= g_new(GdkColor
,1);
931 prop_bg
.color
->red
= 0x1515;
932 prop_bg
.color
->green
= 0x1515;
933 prop_bg
.color
->blue
= 0x8c8c;
936 prop_bg
.color
->red
= 0x4e4e;
937 prop_bg
.color
->green
= 0xa9a9;
938 prop_bg
.color
->blue
= 0xa4a4;
941 prop_bg
.color
->red
= 0x7a7a;
942 prop_bg
.color
->green
= 0x4a4a;
943 prop_bg
.color
->blue
= 0x8b8b;
946 prop_bg
.color
->red
= 0x8080;
947 prop_bg
.color
->green
= 0x7777;
948 prop_bg
.color
->blue
= 0x4747;
951 prop_bg
.color
->red
= 0xe7e7;
952 prop_bg
.color
->green
= 0xe7e7;
953 prop_bg
.color
->blue
= 0xe7e7;
956 g_debug("calling from draw_event");
957 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
958 g_free(prop_bg
.color
);
959 //gdk_gc_unref(draw_context_out->gc);
962 draw_context_out
->gc
= widget
->style
->black_gc
;
964 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
965 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
966 PropertiesText prop_text_out
;
967 prop_text_out
.foreground
= &colorfg_out
;
968 prop_text_out
.background
= &colorbg_out
;
969 prop_text_out
.size
= 6;
970 prop_text_out
.position
= OVER
;
972 /* color of text : status of the process */
973 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
975 prop_text_out
.foreground
->red
= 0xffff;
976 prop_text_out
.foreground
->green
= 0xffff;
977 prop_text_out
.foreground
->blue
= 0xffff;
979 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
981 prop_text_out
.foreground
->red
= 0x0fff;
982 prop_text_out
.foreground
->green
= 0xffff;
983 prop_text_out
.foreground
->blue
= 0xfff0;
985 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
987 prop_text_out
.foreground
->red
= 0xffff;
988 prop_text_out
.foreground
->green
= 0xffff;
989 prop_text_out
.foreground
->blue
= 0x0000;
991 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
993 prop_text_out
.foreground
->red
= 0xffff;
994 prop_text_out
.foreground
->green
= 0x0000;
995 prop_text_out
.foreground
->blue
= 0xffff;
997 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
999 prop_text_out
.foreground
->red
= 0xffff;
1000 prop_text_out
.foreground
->green
= 0x0000;
1001 prop_text_out
.foreground
->blue
= 0x0000;
1003 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1005 prop_text_out
.foreground
->red
= 0x0000;
1006 prop_text_out
.foreground
->green
= 0xffff;
1007 prop_text_out
.foreground
->blue
= 0x0000;
1011 prop_text_out
.foreground
->red
= 0xffff;
1012 prop_text_out
.foreground
->green
= 0xffff;
1013 prop_text_out
.foreground
->blue
= 0xffff;
1017 /* Print status of the process : U, WF, WC, E, W, R */
1018 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1019 prop_text_out
.text
= "U->";
1020 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1021 prop_text_out
.text
= "WF->";
1022 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1023 prop_text_out
.text
= "WC->";
1024 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1025 prop_text_out
.text
= "E->";
1026 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1027 prop_text_out
.text
= "W->";
1028 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1029 prop_text_out
.text
= "R->";
1031 prop_text_out
.text
= "U";
1033 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1034 //gdk_gc_unref(draw_context_out->gc);
1036 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1037 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1038 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
1040 PropertiesLine prop_line_out
;
1041 prop_line_out
.color
= g_new(GdkColor
,1);
1042 prop_line_out
.line_width
= 2;
1043 prop_line_out
.style
= GDK_LINE_SOLID
;
1044 prop_line_out
.position
= MIDDLE
;
1046 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
1048 /* color of line : status of the process */
1049 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1051 prop_line_out
.color
->red
= 0xffff;
1052 prop_line_out
.color
->green
= 0xffff;
1053 prop_line_out
.color
->blue
= 0xffff;
1055 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1057 prop_line_out
.color
->red
= 0x0fff;
1058 prop_line_out
.color
->green
= 0xffff;
1059 prop_line_out
.color
->blue
= 0xfff0;
1061 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1063 prop_line_out
.color
->red
= 0xffff;
1064 prop_line_out
.color
->green
= 0xffff;
1065 prop_line_out
.color
->blue
= 0x0000;
1067 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1069 prop_line_out
.color
->red
= 0xffff;
1070 prop_line_out
.color
->green
= 0x0000;
1071 prop_line_out
.color
->blue
= 0xffff;
1073 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1075 prop_line_out
.color
->red
= 0xffff;
1076 prop_line_out
.color
->green
= 0x0000;
1077 prop_line_out
.color
->blue
= 0x0000;
1079 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1081 prop_line_out
.color
->red
= 0x0000;
1082 prop_line_out
.color
->green
= 0xffff;
1083 prop_line_out
.color
->blue
= 0x0000;
1087 prop_line_out
.color
->red
= 0xffff;
1088 prop_line_out
.color
->green
= 0xffff;
1089 prop_line_out
.color
->blue
= 0xffff;
1092 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1093 g_free(prop_line_out
.color
);
1094 //gdk_gc_unref(draw_context_out->gc);
1095 /* Note : finishing line will have to be added when trace read over. */
1097 /* Finally, update the drawing context of the pid_in. */
1099 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1100 draw_context_in
->current
->modify_over
->x
= x
;
1101 draw_context_in
->current
->modify_under
->x
= x
;
1102 draw_context_in
->current
->modify_over
->y
= y_in
;
1103 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1104 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1105 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1106 widget
= control_flow_data
->drawing
->drawing_area
;
1107 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1108 //draw_context_in->gc = widget->style->black_gc;
1109 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1110 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1112 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1113 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1115 /* Draw the line/bg of the in process */
1116 if(draw_context_in
->previous
->middle
->x
== -1)
1118 draw_context_in
->previous
->over
->x
=
1119 control_flow_data
->drawing
->damage_begin
;
1120 draw_context_in
->previous
->middle
->x
=
1121 control_flow_data
->drawing
->damage_begin
;
1122 draw_context_in
->previous
->under
->x
=
1123 control_flow_data
->drawing
->damage_begin
;
1125 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1129 draw_context_in
->current
->middle
->x
= x
;
1130 draw_context_in
->current
->over
->x
= x
;
1131 draw_context_in
->current
->under
->x
= x
;
1132 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1133 draw_context_in
->current
->over
->y
= y_in
;
1134 draw_context_in
->current
->under
->y
= y_in
+ height
;
1135 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1136 draw_context_in
->previous
->over
->y
= y_in
;
1137 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1139 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1140 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1143 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1145 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1146 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1147 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1149 PropertiesBG prop_bg
;
1150 prop_bg
.color
= g_new(GdkColor
,1);
1152 switch(tfc
->index
) {
1154 prop_bg
.color
->red
= 0x1515;
1155 prop_bg
.color
->green
= 0x1515;
1156 prop_bg
.color
->blue
= 0x8c8c;
1159 prop_bg
.color
->red
= 0x4e4e;
1160 prop_bg
.color
->green
= 0xa9a9;
1161 prop_bg
.color
->blue
= 0xa4a4;
1164 prop_bg
.color
->red
= 0x7a7a;
1165 prop_bg
.color
->green
= 0x4a4a;
1166 prop_bg
.color
->blue
= 0x8b8b;
1169 prop_bg
.color
->red
= 0x8080;
1170 prop_bg
.color
->green
= 0x7777;
1171 prop_bg
.color
->blue
= 0x4747;
1174 prop_bg
.color
->red
= 0xe7e7;
1175 prop_bg
.color
->green
= 0xe7e7;
1176 prop_bg
.color
->blue
= 0xe7e7;
1180 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1181 g_free(prop_bg
.color
);
1182 //gdk_gc_unref(draw_context_in->gc);
1185 draw_context_in
->gc
= widget
->style
->black_gc
;
1187 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1188 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1189 PropertiesText prop_text_in
;
1190 prop_text_in
.foreground
= &colorfg_in
;
1191 prop_text_in
.background
= &colorbg_in
;
1192 prop_text_in
.size
= 6;
1193 prop_text_in
.position
= OVER
;
1195 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1196 /* foreground of text : status of the process */
1197 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1199 prop_text_in
.foreground
->red
= 0xffff;
1200 prop_text_in
.foreground
->green
= 0xffff;
1201 prop_text_in
.foreground
->blue
= 0xffff;
1203 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1205 prop_text_in
.foreground
->red
= 0x0fff;
1206 prop_text_in
.foreground
->green
= 0xffff;
1207 prop_text_in
.foreground
->blue
= 0xfff0;
1209 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1211 prop_text_in
.foreground
->red
= 0xffff;
1212 prop_text_in
.foreground
->green
= 0xffff;
1213 prop_text_in
.foreground
->blue
= 0x0000;
1215 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1217 prop_text_in
.foreground
->red
= 0xffff;
1218 prop_text_in
.foreground
->green
= 0x0000;
1219 prop_text_in
.foreground
->blue
= 0xffff;
1221 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1223 prop_text_in
.foreground
->red
= 0xffff;
1224 prop_text_in
.foreground
->green
= 0x0000;
1225 prop_text_in
.foreground
->blue
= 0x0000;
1227 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1229 prop_text_in
.foreground
->red
= 0x0000;
1230 prop_text_in
.foreground
->green
= 0xffff;
1231 prop_text_in
.foreground
->blue
= 0x0000;
1235 prop_text_in
.foreground
->red
= 0xffff;
1236 prop_text_in
.foreground
->green
= 0xffff;
1237 prop_text_in
.foreground
->blue
= 0xffff;
1242 /* Print status of the process : U, WF, WC, E, W, R */
1243 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1244 prop_text_in
.text
= "U->";
1245 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1246 prop_text_in
.text
= "WF->";
1247 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1248 prop_text_in
.text
= "WC->";
1249 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1250 prop_text_in
.text
= "E->";
1251 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1252 prop_text_in
.text
= "W->";
1253 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1254 prop_text_in
.text
= "R->";
1256 prop_text_in
.text
= "U";
1258 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1259 //gdk_gc_unref(draw_context_in->gc);
1261 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1262 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1263 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1265 PropertiesLine prop_line_in
;
1266 prop_line_in
.color
= g_new(GdkColor
,1);
1267 prop_line_in
.line_width
= 2;
1268 prop_line_in
.style
= GDK_LINE_SOLID
;
1269 prop_line_in
.position
= MIDDLE
;
1271 /* color of line : status of the process */
1272 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1274 prop_line_in
.color
->red
= 0xffff;
1275 prop_line_in
.color
->green
= 0xffff;
1276 prop_line_in
.color
->blue
= 0xffff;
1278 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1280 prop_line_in
.color
->red
= 0x0fff;
1281 prop_line_in
.color
->green
= 0xffff;
1282 prop_line_in
.color
->blue
= 0xfff0;
1284 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1286 prop_line_in
.color
->red
= 0xffff;
1287 prop_line_in
.color
->green
= 0xffff;
1288 prop_line_in
.color
->blue
= 0x0000;
1290 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1292 prop_line_in
.color
->red
= 0xffff;
1293 prop_line_in
.color
->green
= 0x0000;
1294 prop_line_in
.color
->blue
= 0xffff;
1296 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1298 prop_line_in
.color
->red
= 0xffff;
1299 prop_line_in
.color
->green
= 0x0000;
1300 prop_line_in
.color
->blue
= 0x0000;
1302 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1304 prop_line_in
.color
->red
= 0x0000;
1305 prop_line_in
.color
->green
= 0xffff;
1306 prop_line_in
.color
->blue
= 0x0000;
1310 prop_line_in
.color
->red
= 0xffff;
1311 prop_line_in
.color
->green
= 0xffff;
1312 prop_line_in
.color
->blue
= 0xffff;
1315 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1316 g_free(prop_line_in
.color
);
1317 //gdk_gc_unref(draw_context_in->gc);
1327 GString
*string
= g_string_new("");;
1328 gboolean field_names
= TRUE
, state
= TRUE
;
1330 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1331 g_string_append_printf(string
,"\n");
1334 g_string_append_printf(string
, " %s",
1335 g_quark_to_string(tfs
->process
->state
->s
));
1338 g_info("%s",string
->str
);
1340 g_string_free(string
, TRUE
);
1342 /* End of text dump */
1347 /* after_schedchange_hook
1349 * The draw after hook is called by the reading API to have a
1350 * particular event drawn on the screen.
1351 * @param hook_data ControlFlowData structure of the viewer.
1352 * @param call_data Event context.
1354 * This function adds items to be drawn in a queue for each process.
1357 int after_schedchange_hook(void *hook_data
, void *call_data
)
1359 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1360 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1362 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1364 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1365 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
1370 LttTime evtime
= ltt_event_time(e
);
1372 guint width
= control_flow_data
->drawing
->width
;
1374 /* Add process to process list (if not present) */
1375 LttvProcessState
*process_out
, *process_in
;
1377 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1378 HashedProcessData
*hashed_process_data_in
= NULL
;
1380 ProcessList
*process_list
= control_flow_data
->process_list
;
1385 LttField
*f
= ltt_event_field(e
);
1387 element
= ltt_field_member(f
,0);
1388 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1389 element
= ltt_field_member(f
,1);
1390 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1391 g_debug("out : %u in : %u", pid_out
, pid_in
);
1395 /* Find process pid_in in the list... */
1396 process_in
= lttv_state_find_process(tfs
, pid_in
);
1397 /* It should exist, because we are after the state update. */
1398 g_assert(process_in
!= NULL
);
1400 birth
= process_in
->creation_time
;
1401 const gchar
*name
= g_quark_to_string(process_in
->name
);
1403 if(processlist_get_process_pixels(process_list
,
1405 process_in
->last_cpu
,
1407 tfc
->t_context
->index
,
1410 &hashed_process_data_in
) == 1)
1412 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1413 ProcessInfo
*process_info
;
1414 /* Process not present */
1415 processlist_add(process_list
,
1417 process_in
->last_cpu
,
1420 tfc
->t_context
->index
,
1424 &hashed_process_data_in
);
1425 processlist_get_pixels_from_data(process_list
,
1427 hashed_process_data_in
,
1430 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1433 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
1436 TimeWindow time_window
=
1437 lttvwindow_get_time_window(control_flow_data
->tab
);
1440 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1441 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1443 #endif //EXTRA_CHECK
1447 convert_time_to_pixels(
1453 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1454 hashed_process_data_in
->x
.middle
= new_x
;
1455 hashed_process_data_in
->x
.middle_used
= FALSE
;
1456 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1466 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1467 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1469 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1471 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1472 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1478 LttTime evtime
= ltt_event_time(e
);
1479 TimeWindow time_window
=
1480 lttvwindow_get_time_window(control_flow_data
->tab
);
1482 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
1484 //if(time < time_beg || time > time_end) return;
1485 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1486 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1490 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1492 g_debug("schedchange!");
1494 /* Add process to process list (if not present) and get drawing "y" from
1495 * process position */
1496 guint pid_out
, pid_in
;
1497 LttvProcessState
*process_out
, *process_in
;
1499 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1501 ProcessList
*process_list
= control_flow_data
->process_list
;
1504 LttField
*f
= ltt_event_field(e
);
1506 element
= ltt_field_member(f
,0);
1507 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1508 element
= ltt_field_member(f
,1);
1509 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1510 //g_debug("out : %u in : %u", pid_out, pid_in);
1513 /* Find process pid_out in the list... */
1514 process_out
= lttv_state_find_process(tfs
, pid_out
);
1515 if(process_out
== NULL
) return 0;
1516 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1518 birth
= process_out
->creation_time
;
1519 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1520 HashedProcessData
*hashed_process_data_out
= NULL
;
1522 if(processlist_get_process_pixels(process_list
,
1525 tfc
->t_context
->index
,
1528 &hashed_process_data_out
) == 1)
1530 /* Process not present */
1531 processlist_add(process_list
,
1534 tfc
->t_context
->index
,
1537 &hashed_process_data_out
);
1538 processlist_get_process_pixels(process_list
,
1541 tfc
->t_context
->index
,
1544 &hashed_process_data_out
);
1545 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1550 /* Find process pid_in in the list... */
1551 process_in
= lttv_state_find_process(tfs
, pid_in
);
1552 if(process_in
== NULL
) return 0;
1553 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1555 birth
= process_in
->creation_time
;
1556 name
= strdup(g_quark_to_string(process_in
->name
));
1557 HashedProcessData
*hashed_process_data_in
= NULL
;
1559 if(processlist_get_process_pixels(process_list
,
1562 tfc
->t_context
->index
,
1565 &hashed_process_data_in
) == 1)
1567 /* Process not present */
1568 processlist_add(process_list
,
1571 tfc
->t_context
->index
,
1574 &hashed_process_data_in
);
1575 processlist_get_process_pixels(process_list
,
1578 tfc
->t_context
->index
,
1581 &hashed_process_data_in
);
1583 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1588 /* Find pixels corresponding to time of the event. If the time does
1589 * not fit in the window, show a warning, not supposed to happend. */
1591 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1593 //LttTime time = ltt_event_time(e);
1595 //LttTime window_end = time_window->time_window.end_time;
1598 //convert_time_to_pixels(
1604 //assert(x <= width);
1606 /* draw what represents the event for outgoing process. */
1608 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1609 //draw_context_out->current->modify_over->x = x;
1610 draw_context_out
->current
->modify_over
->y
= y_out
;
1611 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1612 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1613 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1614 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1615 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1617 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1618 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1620 /*if(process_out->state->s == LTTV_STATE_RUN)
1622 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1623 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1624 PropertiesBG prop_bg;
1625 prop_bg.color = g_new(GdkColor,1);
1627 prop_bg.color->red = 0xffff;
1628 prop_bg.color->green = 0xffff;
1629 prop_bg.color->blue = 0xffff;
1631 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1632 g_free(prop_bg.color);
1633 gdk_gc_unref(draw_context_out->gc);
1636 draw_context_out
->gc
= widget
->style
->black_gc
;
1638 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1639 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1640 PropertiesText prop_text_out
;
1641 prop_text_out
.foreground
= &colorfg_out
;
1642 prop_text_out
.background
= &colorbg_out
;
1643 prop_text_out
.size
= 6;
1644 prop_text_out
.position
= OVER
;
1646 /* color of text : status of the process */
1647 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1649 prop_text_out
.foreground
->red
= 0xffff;
1650 prop_text_out
.foreground
->green
= 0xffff;
1651 prop_text_out
.foreground
->blue
= 0xffff;
1653 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1655 prop_text_out
.foreground
->red
= 0x0fff;
1656 prop_text_out
.foreground
->green
= 0xffff;
1657 prop_text_out
.foreground
->blue
= 0xfff0;
1659 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1661 prop_text_out
.foreground
->red
= 0xffff;
1662 prop_text_out
.foreground
->green
= 0xffff;
1663 prop_text_out
.foreground
->blue
= 0x0000;
1665 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1667 prop_text_out
.foreground
->red
= 0xffff;
1668 prop_text_out
.foreground
->green
= 0x0000;
1669 prop_text_out
.foreground
->blue
= 0xffff;
1671 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1673 prop_text_out
.foreground
->red
= 0xffff;
1674 prop_text_out
.foreground
->green
= 0x0000;
1675 prop_text_out
.foreground
->blue
= 0x0000;
1677 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1679 prop_text_out
.foreground
->red
= 0x0000;
1680 prop_text_out
.foreground
->green
= 0xffff;
1681 prop_text_out
.foreground
->blue
= 0x0000;
1685 prop_text_out
.foreground
->red
= 0xffff;
1686 prop_text_out
.foreground
->green
= 0xffff;
1687 prop_text_out
.foreground
->blue
= 0xffff;
1690 /* Print status of the process : U, WF, WC, E, W, R */
1691 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1692 prop_text_out
.text
= "U";
1693 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1694 prop_text_out
.text
= "WF";
1695 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1696 prop_text_out
.text
= "WC";
1697 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1698 prop_text_out
.text
= "E";
1699 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1700 prop_text_out
.text
= "W";
1701 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1702 prop_text_out
.text
= "R";
1704 prop_text_out
.text
= "U";
1706 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1708 //gdk_gc_unref(draw_context_out->gc);
1710 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1711 draw_context_out
->current
->over
->y
= y_out
;
1712 draw_context_out
->current
->under
->y
= y_out
+height
;
1713 draw_context_out
->current
->status
= process_out
->state
->s
;
1715 /* for pid_out : remove previous, Prev = current, new current (default) */
1716 g_free(draw_context_out
->previous
->modify_under
);
1717 g_free(draw_context_out
->previous
->modify_middle
);
1718 g_free(draw_context_out
->previous
->modify_over
);
1719 g_free(draw_context_out
->previous
->under
);
1720 g_free(draw_context_out
->previous
->middle
);
1721 g_free(draw_context_out
->previous
->over
);
1722 g_free(draw_context_out
->previous
);
1724 draw_context_out
->previous
= draw_context_out
->current
;
1726 draw_context_out
->current
= g_new(DrawInfo
,1);
1727 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1728 draw_context_out
->current
->over
->x
= -1;
1729 draw_context_out
->current
->over
->y
= -1;
1730 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1731 draw_context_out
->current
->middle
->x
= -1;
1732 draw_context_out
->current
->middle
->y
= -1;
1733 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1734 draw_context_out
->current
->under
->x
= -1;
1735 draw_context_out
->current
->under
->y
= -1;
1736 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1737 draw_context_out
->current
->modify_over
->x
= -1;
1738 draw_context_out
->current
->modify_over
->y
= -1;
1739 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1740 draw_context_out
->current
->modify_middle
->x
= -1;
1741 draw_context_out
->current
->modify_middle
->y
= -1;
1742 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1743 draw_context_out
->current
->modify_under
->x
= -1;
1744 draw_context_out
->current
->modify_under
->y
= -1;
1745 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1747 /* Finally, update the drawing context of the pid_in. */
1749 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1750 //draw_context_in->current->modify_over->x = x;
1751 draw_context_in
->current
->modify_over
->y
= y_in
;
1752 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1753 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1754 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1755 widget
= control_flow_data
->drawing
->drawing_area
;
1756 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1758 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1759 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1761 /*if(process_in->state->s == LTTV_STATE_RUN)
1763 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1764 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1765 PropertiesBG prop_bg;
1766 prop_bg.color = g_new(GdkColor,1);
1768 prop_bg.color->red = 0xffff;
1769 prop_bg.color->green = 0xffff;
1770 prop_bg.color->blue = 0xffff;
1772 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1773 g_free(prop_bg.color);
1774 gdk_gc_unref(draw_context_in->gc);
1777 draw_context_in
->gc
= widget
->style
->black_gc
;
1779 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1780 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1781 PropertiesText prop_text_in
;
1782 prop_text_in
.foreground
= &colorfg_in
;
1783 prop_text_in
.background
= &colorbg_in
;
1784 prop_text_in
.size
= 6;
1785 prop_text_in
.position
= OVER
;
1787 /* foreground of text : status of the process */
1788 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1790 prop_text_in
.foreground
->red
= 0xffff;
1791 prop_text_in
.foreground
->green
= 0xffff;
1792 prop_text_in
.foreground
->blue
= 0xffff;
1794 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1796 prop_text_in
.foreground
->red
= 0x0fff;
1797 prop_text_in
.foreground
->green
= 0xffff;
1798 prop_text_in
.foreground
->blue
= 0xfff0;
1800 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1802 prop_text_in
.foreground
->red
= 0xffff;
1803 prop_text_in
.foreground
->green
= 0xffff;
1804 prop_text_in
.foreground
->blue
= 0x0000;
1806 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1808 prop_text_in
.foreground
->red
= 0xffff;
1809 prop_text_in
.foreground
->green
= 0x0000;
1810 prop_text_in
.foreground
->blue
= 0xffff;
1812 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1814 prop_text_in
.foreground
->red
= 0xffff;
1815 prop_text_in
.foreground
->green
= 0x0000;
1816 prop_text_in
.foreground
->blue
= 0x0000;
1818 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1820 prop_text_in
.foreground
->red
= 0x0000;
1821 prop_text_in
.foreground
->green
= 0xffff;
1822 prop_text_in
.foreground
->blue
= 0x0000;
1826 prop_text_in
.foreground
->red
= 0xffff;
1827 prop_text_in
.foreground
->green
= 0xffff;
1828 prop_text_in
.foreground
->blue
= 0xffff;
1832 /* Print status of the process : U, WF, WC, E, W, R */
1833 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1834 prop_text_in
.text
= "U";
1835 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1836 prop_text_in
.text
= "WF";
1837 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1838 prop_text_in
.text
= "WC";
1839 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1840 prop_text_in
.text
= "E";
1841 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1842 prop_text_in
.text
= "W";
1843 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1844 prop_text_in
.text
= "R";
1846 prop_text_in
.text
= "U";
1848 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1851 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1854 prop_text_in
.foreground
= &colorfg_in
;
1855 prop_text_in
.background
= &colorbg_in
;
1856 prop_text_in
.foreground
->red
= 0xffff;
1857 prop_text_in
.foreground
->green
= 0xffff;
1858 prop_text_in
.foreground
->blue
= 0xffff;
1859 prop_text_in
.size
= 6;
1860 prop_text_in
.position
= UNDER
;
1862 prop_text_in
.text
= g_new(gchar
, 260);
1863 strcpy(prop_text_in
.text
, "CPU ");
1864 snprintf(tmp
, 255, "%u", tfc
->index
);
1865 strcat(prop_text_in
.text
, tmp
);
1867 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1868 g_free(prop_text_in
.text
);
1872 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1873 draw_context_in
->current
->over
->y
= y_in
;
1874 draw_context_in
->current
->under
->y
= y_in
+height
;
1875 draw_context_in
->current
->status
= process_in
->state
->s
;
1877 /* for pid_in : remove previous, Prev = current, new current (default) */
1878 g_free(draw_context_in
->previous
->modify_under
);
1879 g_free(draw_context_in
->previous
->modify_middle
);
1880 g_free(draw_context_in
->previous
->modify_over
);
1881 g_free(draw_context_in
->previous
->under
);
1882 g_free(draw_context_in
->previous
->middle
);
1883 g_free(draw_context_in
->previous
->over
);
1884 g_free(draw_context_in
->previous
);
1886 draw_context_in
->previous
= draw_context_in
->current
;
1888 draw_context_in
->current
= g_new(DrawInfo
,1);
1889 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1890 draw_context_in
->current
->over
->x
= -1;
1891 draw_context_in
->current
->over
->y
= -1;
1892 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1893 draw_context_in
->current
->middle
->x
= -1;
1894 draw_context_in
->current
->middle
->y
= -1;
1895 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1896 draw_context_in
->current
->under
->x
= -1;
1897 draw_context_in
->current
->under
->y
= -1;
1898 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1899 draw_context_in
->current
->modify_over
->x
= -1;
1900 draw_context_in
->current
->modify_over
->y
= -1;
1901 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1902 draw_context_in
->current
->modify_middle
->x
= -1;
1903 draw_context_in
->current
->modify_middle
->y
= -1;
1904 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1905 draw_context_in
->current
->modify_under
->x
= -1;
1906 draw_context_in
->current
->modify_under
->y
= -1;
1907 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1916 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1918 PropertiesLine prop_line
;
1919 prop_line
.line_width
= 1;
1920 prop_line
.style
= GDK_LINE_SOLID
;
1922 //GdkColormap *colormap = gdk_colormap_get_system();
1924 /* color of line : execution mode of the process */
1925 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1926 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1927 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1928 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1929 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1930 prop_line
.color
= drawing_colors
[COL_TRAP
];
1931 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1932 prop_line
.color
= drawing_colors
[COL_IRQ
];
1933 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1934 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1936 prop_line
.color
= drawing_colors
[COL_WHITE
];
1938 //gdk_colormap_alloc_color(colormap,
1949 /* before_execmode_hook
1951 * This function basically draw lines and icons. Two types of lines are drawn :
1952 * one small (3 pixels?) representing the state of the process and the second
1953 * type is thicker (10 pixels?) representing on which CPU a process is running
1954 * (and this only in running state).
1956 * Extremums of the lines :
1957 * x_min : time of the last event context for this process kept in memory.
1958 * x_max : time of the current event.
1959 * y : middle of the process in the process list. The process is found in the
1960 * list, therefore is it's position in pixels.
1962 * The choice of lines'color is defined by the context of the last event for this
1967 int before_execmode_hook(void *hook_data
, void *call_data
)
1969 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1970 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1971 Drawing_t
*drawing
= control_flow_data
->drawing
;
1973 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1975 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1976 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
1981 LttTime evtime
= ltt_event_time(e
);
1982 guint width
= drawing
->width
;
1984 /* we are in a execmode, before the state update. We must draw the
1985 * items corresponding to the state before it changes : now is the right
1989 LttvProcessState
*process
= tfs
->process
;
1990 g_assert(process
!= NULL
);
1992 guint pid
= process
->pid
;
1994 /* Well, the process_out existed : we must get it in the process hash
1995 * or add it, and draw its items.
1997 /* Add process to process list (if not present) */
1998 guint y
= 0, height
= 0, pl_height
= 0;
1999 HashedProcessData
*hashed_process_data
= NULL
;
2000 ProcessList
*process_list
= control_flow_data
->process_list
;
2001 LttTime birth
= process
->creation_time
;
2002 const gchar
*name
= g_quark_to_string(process
->name
);
2004 if(processlist_get_process_pixels(process_list
,
2008 tfc
->t_context
->index
,
2011 &hashed_process_data
) == 1)
2013 g_assert(pid
== 0 || pid
!= process
->ppid
);
2014 ProcessInfo
*process_info
;
2015 /* Process not present */
2016 processlist_add(process_list
,
2021 tfc
->t_context
->index
,
2025 &hashed_process_data
);
2026 processlist_get_pixels_from_data(process_list
,
2028 hashed_process_data
,
2031 drawing_insert_square( drawing
, y
, height
);
2034 /* Now, the process is in the state hash and our own process hash.
2035 * We definitely can draw the items related to the ending state.
2038 /* Check if the x position is unset. In can have been left unset by
2039 * a draw closure from a after chunk hook. This should never happen,
2040 * because it must be set by before chunk hook to the damage_begin
2043 g_assert(hashed_process_data
->x
.over
!= -1);
2045 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2048 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2049 TimeWindow time_window
=
2050 lttvwindow_get_time_window(control_flow_data
->tab
);
2053 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2054 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2056 #endif //EXTRA_CHECK
2058 convert_time_to_pixels(
2064 /* Draw collision indicator */
2065 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2066 gdk_draw_point(drawing
->pixmap
,
2070 hashed_process_data
->x
.middle_marked
= TRUE
;
2073 TimeWindow time_window
=
2074 lttvwindow_get_time_window(control_flow_data
->tab
);
2077 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2078 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2080 #endif //EXTRA_CHECK
2083 convert_time_to_pixels(
2090 /* Jump over draw if we are at the same x position */
2091 if(x
== hashed_process_data
->x
.middle
&&
2092 hashed_process_data
->x
.middle_used
)
2094 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2095 /* Draw collision indicator */
2096 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2097 gdk_draw_point(drawing
->pixmap
,
2101 hashed_process_data
->x
.middle_marked
= TRUE
;
2106 DrawContext draw_context
;
2107 /* Now create the drawing context that will be used to draw
2108 * items related to the last state. */
2109 draw_context
.drawable
= drawing
->pixmap
;
2110 draw_context
.gc
= drawing
->gc
;
2111 draw_context
.pango_layout
= drawing
->pango_layout
;
2112 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2113 draw_context
.drawinfo
.end
.x
= x
;
2115 draw_context
.drawinfo
.y
.over
= y
+1;
2116 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2117 draw_context
.drawinfo
.y
.under
= y
+height
;
2119 draw_context
.drawinfo
.start
.offset
.over
= 0;
2120 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2121 draw_context
.drawinfo
.start
.offset
.under
= 0;
2122 draw_context
.drawinfo
.end
.offset
.over
= 0;
2123 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2124 draw_context
.drawinfo
.end
.offset
.under
= 0;
2128 PropertiesLine prop_line
= prepare_s_e_line(process
);
2129 draw_line((void*)&prop_line
, (void*)&draw_context
);
2132 /* become the last x position */
2133 hashed_process_data
->x
.middle
= x
;
2134 hashed_process_data
->x
.middle_used
= TRUE
;
2135 hashed_process_data
->x
.middle_marked
= FALSE
;
2137 /* Calculate the next good time */
2138 convert_pixels_to_time(width
, x
+1, time_window
,
2139 &hashed_process_data
->next_good_time
);
2146 /* after_execmode_hook
2148 * The draw after hook is called by the reading API to have a
2149 * particular event drawn on the screen.
2150 * @param hook_data ControlFlowData structure of the viewer.
2151 * @param call_data Event context.
2153 * This function adds items to be drawn in a queue for each process.
2156 int after_execmode_hook(void *hook_data
, void *call_data
)
2158 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2159 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2161 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2163 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2164 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2169 LttTime evtime
= ltt_event_time(e
);
2170 guint width
= control_flow_data
->drawing
->width
;
2172 /* Add process to process list (if not present) */
2173 LttvProcessState
*process
;
2175 guint y
= 0, height
= 0, pl_height
= 0;
2176 HashedProcessData
*hashed_process_data
= NULL
;
2178 ProcessList
*process_list
= control_flow_data
->process_list
;
2180 /* Find process pid_in in the list... */
2181 process
= tfs
->process
;
2182 /* It should exist, because we are after the state update. */
2183 g_assert(process
!= NULL
);
2185 guint pid
= process
->pid
;
2187 birth
= process
->creation_time
;
2188 const gchar
*name
= g_quark_to_string(process
->name
);
2190 if(processlist_get_process_pixels(process_list
,
2194 tfc
->t_context
->index
,
2197 &hashed_process_data
) == 1)
2199 g_assert(pid
== 0 || pid
!= process
->ppid
);
2200 /* Process not present */
2201 ProcessInfo
*process_info
;
2202 processlist_add(process_list
,
2207 tfc
->t_context
->index
,
2211 &hashed_process_data
);
2212 processlist_get_pixels_from_data(process_list
,
2214 hashed_process_data
,
2217 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2220 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2223 TimeWindow time_window
=
2224 lttvwindow_get_time_window(control_flow_data
->tab
);
2227 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2228 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2230 #endif //EXTRA_CHECK
2235 convert_time_to_pixels(
2241 if(hashed_process_data
->x
.middle
!= new_x
) {
2242 hashed_process_data
->x
.middle
= new_x
;
2243 hashed_process_data
->x
.middle_used
= FALSE
;
2244 hashed_process_data
->x
.middle_marked
= FALSE
;
2252 /* before_process_hook
2254 * Draw lines for process event.
2256 * @param hook_data ControlFlowData structure of the viewer.
2257 * @param call_data Event context.
2259 * This function adds items to be drawn in a queue for each process.
2262 int before_process_hook(void *hook_data
, void *call_data
)
2264 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2265 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2266 Drawing_t
*drawing
= control_flow_data
->drawing
;
2268 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2270 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2271 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2276 LttTime evtime
= ltt_event_time(e
);
2277 guint width
= control_flow_data
->drawing
->width
;
2281 LttField
*f
= ltt_event_field(e
);
2283 element
= ltt_field_member(f
,0);
2284 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2287 if(sub_id
== 3) { /* exit */
2289 /* Add process to process list (if not present) */
2290 LttvProcessState
*process
= tfs
->process
;
2291 guint pid
= process
->pid
;
2293 guint y
= 0, height
= 0, pl_height
= 0;
2294 HashedProcessData
*hashed_process_data
= NULL
;
2296 ProcessList
*process_list
= control_flow_data
->process_list
;
2298 g_assert(process
!= NULL
);
2300 birth
= process
->creation_time
;
2301 const gchar
*name
= g_quark_to_string(process
->name
);
2303 if(processlist_get_process_pixels(process_list
,
2307 tfc
->t_context
->index
,
2310 &hashed_process_data
) == 1)
2312 g_assert(pid
== 0 || pid
!= process
->ppid
);
2313 /* Process not present */
2314 ProcessInfo
*process_info
;
2315 processlist_add(process_list
,
2320 tfc
->t_context
->index
,
2324 &hashed_process_data
);
2325 processlist_get_pixels_from_data(process_list
,
2327 hashed_process_data
,
2330 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2333 /* Now, the process is in the state hash and our own process hash.
2334 * We definitely can draw the items related to the ending state.
2337 /* Check if the x position is unset. In can have been left unset by
2338 * a draw closure from a after chunk hook. This should never happen,
2339 * because it must be set by before chunk hook to the damage_begin
2342 g_assert(hashed_process_data
->x
.over
!= -1);
2344 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2347 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2348 TimeWindow time_window
=
2349 lttvwindow_get_time_window(control_flow_data
->tab
);
2352 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2353 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2355 #endif //EXTRA_CHECK
2358 convert_time_to_pixels(
2364 /* Draw collision indicator */
2365 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2366 gdk_draw_point(drawing
->pixmap
,
2370 hashed_process_data
->x
.middle_marked
= TRUE
;
2373 TimeWindow time_window
=
2374 lttvwindow_get_time_window(control_flow_data
->tab
);
2377 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2378 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2380 #endif //EXTRA_CHECK
2384 convert_time_to_pixels(
2391 /* Jump over draw if we are at the same x position */
2392 if(x
== hashed_process_data
->x
.middle
&&
2393 hashed_process_data
->x
.middle_used
)
2395 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2396 /* Draw collision indicator */
2397 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2398 gdk_draw_point(drawing
->pixmap
,
2402 hashed_process_data
->x
.middle_marked
= TRUE
;
2406 DrawContext draw_context
;
2408 /* Now create the drawing context that will be used to draw
2409 * items related to the last state. */
2410 draw_context
.drawable
= drawing
->pixmap
;
2411 draw_context
.gc
= drawing
->gc
;
2412 draw_context
.pango_layout
= drawing
->pango_layout
;
2413 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2414 draw_context
.drawinfo
.end
.x
= x
;
2416 draw_context
.drawinfo
.y
.over
= y
+1;
2417 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2418 draw_context
.drawinfo
.y
.under
= y
+height
;
2420 draw_context
.drawinfo
.start
.offset
.over
= 0;
2421 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2422 draw_context
.drawinfo
.start
.offset
.under
= 0;
2423 draw_context
.drawinfo
.end
.offset
.over
= 0;
2424 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2425 draw_context
.drawinfo
.end
.offset
.under
= 0;
2429 PropertiesLine prop_line
= prepare_s_e_line(process
);
2430 draw_line((void*)&prop_line
, (void*)&draw_context
);
2433 /* become the last x position */
2434 hashed_process_data
->x
.middle
= x
;
2435 hashed_process_data
->x
.middle_used
= TRUE
;
2436 hashed_process_data
->x
.middle_marked
= FALSE
;
2438 /* Calculate the next good time */
2439 convert_pixels_to_time(width
, x
+1, time_window
,
2440 &hashed_process_data
->next_good_time
);
2454 /* after_process_hook
2456 * Create the processlist entry for the child process. Put the last
2457 * position in x at the current time value.
2459 * @param hook_data ControlFlowData structure of the viewer.
2460 * @param call_data Event context.
2462 * This function adds items to be drawn in a queue for each process.
2465 int after_process_hook(void *hook_data
, void *call_data
)
2467 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2468 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2470 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2472 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2473 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2478 LttTime evtime
= ltt_event_time(e
);
2479 guint width
= control_flow_data
->drawing
->width
;
2484 LttField
*f
= ltt_event_field(e
);
2486 element
= ltt_field_member(f
,0);
2487 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2488 element
= ltt_field_member(f
,1);
2489 param1
= ltt_event_get_long_unsigned(e
,element
);
2492 if(sub_id
== 2) { /* fork */
2494 guint child_pid
= param1
;
2495 /* Add process to process list (if not present) */
2496 LttvProcessState
*process_child
;
2498 guint y_child
= 0, height
= 0, pl_height
= 0;
2499 HashedProcessData
*hashed_process_data_child
= NULL
;
2501 ProcessList
*process_list
= control_flow_data
->process_list
;
2503 /* Find child in the list... */
2504 process_child
= lttv_state_find_process(tfs
, child_pid
);
2505 /* It should exist, because we are after the state update. */
2506 g_assert(process_child
!= NULL
);
2508 birth
= process_child
->creation_time
;
2509 const gchar
*name
= g_quark_to_string(process_child
->name
);
2511 if(processlist_get_process_pixels(process_list
,
2513 process_child
->last_cpu
,
2515 tfc
->t_context
->index
,
2518 &hashed_process_data_child
) == 1)
2520 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2521 /* Process not present */
2522 ProcessInfo
*process_info
;
2523 processlist_add(process_list
,
2525 process_child
->last_cpu
,
2526 process_child
->ppid
,
2528 tfc
->t_context
->index
,
2532 &hashed_process_data_child
);
2533 processlist_get_pixels_from_data(process_list
,
2535 hashed_process_data_child
,
2538 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2541 if(ltt_time_compare(hashed_process_data_child
->next_good_time
,
2544 TimeWindow time_window
=
2545 lttvwindow_get_time_window(control_flow_data
->tab
);
2548 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2549 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2551 #endif //EXTRA_CHECK
2554 convert_time_to_pixels(
2560 if(hashed_process_data_child
->x
.over
!= new_x
) {
2561 hashed_process_data_child
->x
.over
= new_x
;
2562 hashed_process_data_child
->x
.over_used
= FALSE
;
2563 hashed_process_data_child
->x
.over_marked
= FALSE
;
2565 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2566 hashed_process_data_child
->x
.middle
= new_x
;
2567 hashed_process_data_child
->x
.middle_used
= FALSE
;
2568 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2570 if(hashed_process_data_child
->x
.under
!= new_x
) {
2571 hashed_process_data_child
->x
.under
= new_x
;
2572 hashed_process_data_child
->x
.under_used
= FALSE
;
2573 hashed_process_data_child
->x
.under_marked
= FALSE
;
2577 } else if(sub_id
== 3) { /* exit */
2579 /* Add process to process list (if not present) */
2580 LttvProcessState
*process
= tfs
->process
;
2581 guint pid
= process
->pid
;
2583 guint y
= 0, height
= 0, pl_height
= 0;
2584 HashedProcessData
*hashed_process_data
= NULL
;
2586 ProcessList
*process_list
= control_flow_data
->process_list
;
2588 /* It should exist, because we are after the state update. */
2589 g_assert(process
!= NULL
);
2591 birth
= process
->creation_time
;
2592 const gchar
*name
= g_quark_to_string(process
->name
);
2594 if(processlist_get_process_pixels(process_list
,
2598 tfc
->t_context
->index
,
2601 &hashed_process_data
) == 1)
2603 g_assert(pid
== 0 || pid
!= process
->ppid
);
2604 /* Process not present */
2605 ProcessInfo
*process_info
;
2606 processlist_add(process_list
,
2611 tfc
->t_context
->index
,
2615 &hashed_process_data
);
2616 processlist_get_pixels_from_data(process_list
,
2618 hashed_process_data
,
2621 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2624 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2627 TimeWindow time_window
=
2628 lttvwindow_get_time_window(control_flow_data
->tab
);
2631 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2632 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2634 #endif //EXTRA_CHECK
2637 convert_time_to_pixels(
2642 if(hashed_process_data
->x
.middle
!= new_x
) {
2643 hashed_process_data
->x
.middle
= new_x
;
2644 hashed_process_data
->x
.middle_used
= FALSE
;
2645 hashed_process_data
->x
.middle_marked
= FALSE
;
2655 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2657 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2658 Drawing_t
*drawing
= control_flow_data
->drawing
;
2660 const TimeWindowNotifyData
*time_window_nofify_data
=
2661 ((const TimeWindowNotifyData
*)call_data
);
2663 TimeWindow
*old_time_window
=
2664 time_window_nofify_data
->old_time_window
;
2665 TimeWindow
*new_time_window
=
2666 time_window_nofify_data
->new_time_window
;
2668 /* Update the ruler */
2669 drawing_update_ruler(control_flow_data
->drawing
,
2673 /* Two cases : zoom in/out or scrolling */
2675 /* In order to make sure we can reuse the old drawing, the scale must
2676 * be the same and the new time interval being partly located in the
2677 * currently shown time interval. (reuse is only for scrolling)
2680 g_info("Old time window HOOK : %u, %u to %u, %u",
2681 old_time_window
->start_time
.tv_sec
,
2682 old_time_window
->start_time
.tv_nsec
,
2683 old_time_window
->time_width
.tv_sec
,
2684 old_time_window
->time_width
.tv_nsec
);
2686 g_info("New time window HOOK : %u, %u to %u, %u",
2687 new_time_window
->start_time
.tv_sec
,
2688 new_time_window
->start_time
.tv_nsec
,
2689 new_time_window
->time_width
.tv_sec
,
2690 new_time_window
->time_width
.tv_nsec
);
2692 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2693 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2695 /* Same scale (scrolling) */
2696 g_info("scrolling");
2697 LttTime
*ns
= &new_time_window
->start_time
;
2698 LttTime
*nw
= &new_time_window
->time_width
;
2699 LttTime
*os
= &old_time_window
->start_time
;
2700 LttTime
*ow
= &old_time_window
->time_width
;
2701 LttTime old_end
= old_time_window
->end_time
;
2702 LttTime new_end
= new_time_window
->end_time
;
2704 //if(ns<os+w && os+w<ns+w)
2705 //if(ns<old_end && os<ns)
2706 if(ltt_time_compare(*ns
, old_end
) == -1
2707 && ltt_time_compare(*os
, *ns
) == -1)
2709 g_info("scrolling near right");
2710 /* Scroll right, keep right part of the screen */
2712 guint width
= control_flow_data
->drawing
->width
;
2713 convert_time_to_pixels(
2719 /* Copy old data to new location */
2720 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2721 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2722 control_flow_data
->drawing
->pixmap
,
2725 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2727 if(drawing
->damage_begin
== drawing
->damage_end
)
2728 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2730 drawing
->damage_begin
= 0;
2732 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2734 /* Clear the data request background, but not SAFETY */
2735 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2736 //control_flow_data->drawing->drawing_area->style->black_gc,
2737 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2739 drawing
->damage_begin
+SAFETY
, 0,
2740 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2741 control_flow_data
->drawing
->height
);
2743 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2745 control_flow_data
->drawing
->width
,
2746 control_flow_data
->drawing
->height
);
2748 /* Get new data for the rest. */
2749 drawing_data_request(control_flow_data
->drawing
,
2750 &control_flow_data
->drawing
->pixmap
,
2751 drawing
->damage_begin
, 0,
2752 drawing
->damage_end
- drawing
->damage_begin
,
2753 control_flow_data
->drawing
->height
);
2756 //if(ns<os && os<ns+w)
2757 //if(ns<os && os<new_end)
2758 if(ltt_time_compare(*ns
,*os
) == -1
2759 && ltt_time_compare(*os
,new_end
) == -1)
2761 g_info("scrolling near left");
2762 /* Scroll left, keep left part of the screen */
2764 guint width
= control_flow_data
->drawing
->width
;
2765 convert_time_to_pixels(
2772 /* Copy old data to new location */
2773 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2774 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2775 control_flow_data
->drawing
->pixmap
,
2780 if(drawing
->damage_begin
== drawing
->damage_end
)
2781 drawing
->damage_end
= x
;
2783 drawing
->damage_end
=
2784 control_flow_data
->drawing
->width
;
2786 drawing
->damage_begin
= 0;
2788 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2789 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2791 drawing
->damage_begin
, 0,
2792 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2793 control_flow_data
->drawing
->height
);
2795 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2797 control_flow_data
->drawing
->width
,
2798 control_flow_data
->drawing
->height
);
2801 /* Get new data for the rest. */
2802 drawing_data_request(control_flow_data
->drawing
,
2803 &control_flow_data
->drawing
->pixmap
,
2804 drawing
->damage_begin
, 0,
2805 drawing
->damage_end
- drawing
->damage_begin
,
2806 control_flow_data
->drawing
->height
);
2809 if(ltt_time_compare(*ns
,*os
) == 0)
2811 g_info("not scrolling");
2813 g_info("scrolling far");
2814 /* Cannot reuse any part of the screen : far jump */
2817 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2818 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2821 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2822 control_flow_data
->drawing
->height
);
2824 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2826 control_flow_data
->drawing
->width
,
2827 control_flow_data
->drawing
->height
);
2829 drawing
->damage_begin
= 0;
2830 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2832 drawing_data_request(control_flow_data
->drawing
,
2833 &control_flow_data
->drawing
->pixmap
,
2835 control_flow_data
->drawing
->width
,
2836 control_flow_data
->drawing
->height
);
2842 /* Different scale (zoom) */
2845 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2846 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2849 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2850 control_flow_data
->drawing
->height
);
2852 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2854 control_flow_data
->drawing
->width
,
2855 control_flow_data
->drawing
->height
);
2857 drawing
->damage_begin
= 0;
2858 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2860 drawing_data_request(control_flow_data
->drawing
,
2861 &control_flow_data
->drawing
->pixmap
,
2863 control_flow_data
->drawing
->width
,
2864 control_flow_data
->drawing
->height
);
2872 gint
traceset_notify(void *hook_data
, void *call_data
)
2874 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2875 Drawing_t
*drawing
= control_flow_data
->drawing
;
2876 GtkWidget
*widget
= drawing
->drawing_area
;
2879 drawing_clear(control_flow_data
->drawing
);
2880 processlist_clear(control_flow_data
->process_list
);
2881 redraw_notify(control_flow_data
, NULL
);
2883 request_background_data(control_flow_data
);
2885 drawing
->damage_begin
= 0;
2886 drawing
->damage_end
= drawing
->width
;
2887 if(drawing
->damage_begin
< drawing
->damage_end
)
2889 drawing_data_request(drawing
,
2891 drawing
->damage_begin
,
2893 drawing
->damage_end
-drawing
->damage_begin
,
2897 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2906 gint
redraw_notify(void *hook_data
, void *call_data
)
2908 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2909 Drawing_t
*drawing
= control_flow_data
->drawing
;
2910 GtkWidget
*widget
= drawing
->drawing_area
;
2912 drawing
->damage_begin
= 0;
2913 drawing
->damage_end
= drawing
->width
;
2915 /* fun feature, to be separated someday... */
2916 drawing_clear(control_flow_data
->drawing
);
2917 processlist_clear(control_flow_data
->process_list
);
2920 gdk_draw_rectangle (drawing
->pixmap
,
2921 widget
->style
->black_gc
,
2924 drawing
->width
+SAFETY
,
2928 if(drawing
->damage_begin
< drawing
->damage_end
)
2930 drawing_data_request(drawing
,
2932 drawing
->damage_begin
,
2934 drawing
->damage_end
-drawing
->damage_begin
,
2938 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2947 gint
continue_notify(void *hook_data
, void *call_data
)
2949 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2950 Drawing_t
*drawing
= control_flow_data
->drawing
;
2951 GtkWidget
*widget
= drawing
->drawing_area
;
2953 //g_assert(widget->allocation.width == drawing->damage_end);
2955 if(drawing
->damage_begin
< drawing
->damage_end
)
2957 drawing_data_request(drawing
,
2959 drawing
->damage_begin
,
2961 drawing
->damage_end
-drawing
->damage_begin
,
2969 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2971 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2972 Drawing_t
*drawing
= control_flow_data
->drawing
;
2974 LttTime current_time
= *((LttTime
*)call_data
);
2976 TimeWindow time_window
=
2977 lttvwindow_get_time_window(control_flow_data
->tab
);
2979 LttTime time_begin
= time_window
.start_time
;
2980 LttTime width
= time_window
.time_width
;
2983 guint64 time_ll
= ltt_time_to_uint64(width
);
2984 time_ll
= time_ll
>> 1; /* divide by two */
2985 half_width
= ltt_time_from_uint64(time_ll
);
2987 LttTime time_end
= ltt_time_add(time_begin
, width
);
2989 LttvTracesetContext
* tsc
=
2990 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2992 LttTime trace_start
= tsc
->time_span
.start_time
;
2993 LttTime trace_end
= tsc
->time_span
.end_time
;
2995 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2996 current_time
.tv_nsec
);
3000 /* If current time is inside time interval, just move the highlight
3003 /* Else, we have to change the time interval. We have to tell it
3004 * to the main window. */
3005 /* The time interval change will take care of placing the current
3006 * time at the center of the visible area, or nearest possible if we are
3007 * at one end of the trace. */
3010 if(ltt_time_compare(current_time
, time_begin
) == -1)
3012 TimeWindow new_time_window
;
3014 if(ltt_time_compare(current_time
,
3015 ltt_time_add(trace_start
,half_width
)) == -1)
3016 time_begin
= trace_start
;
3018 time_begin
= ltt_time_sub(current_time
,half_width
);
3020 new_time_window
.start_time
= time_begin
;
3021 new_time_window
.time_width
= width
;
3022 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3023 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3025 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3027 else if(ltt_time_compare(current_time
, time_end
) == 1)
3029 TimeWindow new_time_window
;
3031 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
3032 time_begin
= ltt_time_sub(trace_end
,width
);
3034 time_begin
= ltt_time_sub(current_time
,half_width
);
3036 new_time_window
.start_time
= time_begin
;
3037 new_time_window
.time_width
= width
;
3038 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3039 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3041 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3044 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
3045 gtk_widget_queue_draw_area(drawing
->drawing_area
,
3053 typedef struct _ClosureData
{
3054 EventsRequest
*events_request
;
3055 LttvTracesetState
*tss
;
3060 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3062 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3063 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3064 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3066 EventsRequest
*events_request
= closure_data
->events_request
;
3067 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3068 Drawing_t
*drawing
= control_flow_data
->drawing
;
3070 LttvTracesetState
*tss
= closure_data
->tss
;
3071 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
3073 LttTime evtime
= closure_data
->end_time
;
3074 guint width
= drawing
->width
;
3077 /* For the process */
3078 /* First, check if the current process is in the state computation
3079 * process list. If it is there, that means we must add it right now and
3080 * draw items from the beginning of the read for it. If it is not
3081 * present, it's a new process and it was not present : it will
3082 * be added after the state update. */
3083 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3085 /* tracefiles[0] is ok here, because we draw for every PID, and
3086 * assume CPU 0 for PID 0 //FIXME */
3087 LttvTracefileState
*tfs
=
3088 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
3090 LttvProcessState
*process
;
3091 process
= lttv_state_find_process(tfs
,
3094 if(process
!= NULL
) {
3096 /* Only draw for processes that are currently in the trace states */
3098 guint y
= 0, height
= 0, pl_height
= 0;
3099 ProcessList
*process_list
= control_flow_data
->process_list
;
3100 LttTime birth
= process_info
->birth
;
3102 /* Should be alike when background info is ready */
3103 if(control_flow_data
->background_info_waiting
==0)
3104 g_assert(ltt_time_compare(process
->creation_time
,
3105 process_info
->birth
) == 0);
3106 const gchar
*name
= g_quark_to_string(process
->name
);
3108 /* process HAS to be present */
3109 processlist_get_pixels_from_data(process_list
,
3111 hashed_process_data
,
3115 /* Now, the process is in the state hash and our own process hash.
3116 * We definitely can draw the items related to the ending state.
3119 /* Check if the x position is unset. In can have been left unset by
3120 * a draw closure from a after chunk hook. This should never happen,
3121 * because it must be set by before chunk hook to the damage_begin
3124 g_assert(hashed_process_data
->x
.over
!= -1);
3126 if(ltt_time_compare(hashed_process_data
->next_good_time
,
3129 TimeWindow time_window
=
3130 lttvwindow_get_time_window(control_flow_data
->tab
);
3133 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3134 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3136 #endif //EXTRA_CHECK
3139 convert_time_to_pixels(
3145 DrawContext draw_context
;
3147 /* Now create the drawing context that will be used to draw
3148 * items related to the last state. */
3149 draw_context
.drawable
= drawing
->pixmap
;
3150 draw_context
.gc
= drawing
->gc
;
3151 draw_context
.pango_layout
= drawing
->pango_layout
;
3152 draw_context
.drawinfo
.end
.x
= x
;
3154 draw_context
.drawinfo
.y
.over
= y
+1;
3155 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3156 draw_context
.drawinfo
.y
.under
= y
+height
;
3158 draw_context
.drawinfo
.start
.offset
.over
= 0;
3159 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3160 draw_context
.drawinfo
.start
.offset
.under
= 0;
3161 draw_context
.drawinfo
.end
.offset
.over
= 0;
3162 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3163 draw_context
.drawinfo
.end
.offset
.under
= 0;
3165 /* Jump over draw if we are at the same x position */
3166 if(x
== hashed_process_data
->x
.over
)
3170 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3172 PropertiesLine prop_line
= prepare_execmode_line(process
);
3173 draw_line((void*)&prop_line
, (void*)&draw_context
);
3175 hashed_process_data
->x
.over
= x
;
3179 if(x
== hashed_process_data
->x
.middle
&&
3180 hashed_process_data
->x
.middle_used
) {
3181 #if 0 /* do not mark closure : not missing information */
3182 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3183 /* Draw collision indicator */
3184 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3185 gdk_draw_point(drawing
->pixmap
,
3189 hashed_process_data
->x
.middle_marked
= TRUE
;
3194 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3196 PropertiesLine prop_line
= prepare_s_e_line(process
);
3197 draw_line((void*)&prop_line
, (void*)&draw_context
);
3199 /* become the last x position */
3200 if(x
!= hashed_process_data
->x
.middle
) {
3201 hashed_process_data
->x
.middle
= x
;
3202 /* but don't use the pixel */
3203 hashed_process_data
->x
.middle_used
= FALSE
;
3205 /* Calculate the next good time */
3206 convert_pixels_to_time(width
, x
+1, time_window
,
3207 &hashed_process_data
->next_good_time
);
3216 int before_chunk(void *hook_data
, void *call_data
)
3218 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3219 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3221 drawing_chunk_begin(events_request
, tss
);
3226 int before_request(void *hook_data
, void *call_data
)
3228 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3229 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3231 drawing_data_request_begin(events_request
, tss
);
3238 * after request is necessary in addition of after chunk in order to draw
3239 * lines until the end of the screen. after chunk just draws lines until
3246 int after_request(void *hook_data
, void *call_data
)
3248 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3249 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3250 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3251 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3253 ProcessList
*process_list
= control_flow_data
->process_list
;
3254 LttTime end_time
= events_request
->end_time
;
3256 ClosureData closure_data
;
3257 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3258 closure_data
.tss
= tss
;
3259 closure_data
.end_time
= end_time
;
3261 /* Draw last items */
3262 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3263 (void*)&closure_data
);
3265 /* Request expose */
3266 drawing_request_expose(events_request
, tss
, end_time
);
3275 int after_chunk(void *hook_data
, void *call_data
)
3277 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3278 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3279 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3280 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3281 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3284 ProcessList
*process_list
= control_flow_data
->process_list
;
3287 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3288 else /* end of traceset, or position now out of request : end */
3289 end_time
= events_request
->end_time
;
3291 ClosureData closure_data
;
3292 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3293 closure_data
.tss
= tss
;
3294 closure_data
.end_time
= end_time
;
3296 /* Draw last items */
3297 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3298 (void*)&closure_data
);
3300 /* Request expose */
3301 drawing_request_expose(events_request
, tss
, end_time
);