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
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
393 LttTime evtime
= ltt_event_time(e
);
394 TimeWindow time_window
=
395 lttvwindow_get_time_window(control_flow_data
->tab
);
397 LttTime end_time
= time_window
.end_time
;
399 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
400 || ltt_time_compare(evtime
, end_time
) == 1)
402 guint width
= drawing
->width
;
404 /* we are in a schedchange, before the state update. We must draw the
405 * items corresponding to the state before it changes : now is the right
412 LttField
*f
= ltt_event_field(e
);
414 element
= ltt_field_member(f
,0);
415 pid_out
= ltt_event_get_long_unsigned(e
,element
);
416 element
= ltt_field_member(f
,1);
417 pid_in
= ltt_event_get_long_unsigned(e
,element
);
418 g_debug("out : %u in : %u", pid_out
, pid_in
);
422 /* For the pid_out */
423 /* First, check if the current process is in the state computation
424 * process list. If it is there, that means we must add it right now and
425 * draw items from the beginning of the read for it. If it is not
426 * present, it's a new process and it was not present : it will
427 * be added after the state update. */
428 LttvProcessState
*process
;
429 process
= lttv_state_find_process(tfs
, pid_out
);
431 if(process
!= NULL
) {
432 /* Well, the process_out existed : we must get it in the process hash
433 * or add it, and draw its items.
435 /* Add process to process list (if not present) */
436 guint y
= 0, height
= 0, pl_height
= 0;
437 HashedProcessData
*hashed_process_data
= NULL
;
438 ProcessList
*process_list
= control_flow_data
->process_list
;
439 LttTime birth
= process
->creation_time
;
440 const gchar
*name
= g_quark_to_string(process
->name
);
442 if(processlist_get_process_pixels(process_list
,
446 tfc
->t_context
->index
,
449 &hashed_process_data
) == 1)
451 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
452 /* Process not present */
453 processlist_add(process_list
,
458 tfc
->t_context
->index
,
461 &hashed_process_data
);
462 processlist_get_process_pixels(process_list
,
466 tfc
->t_context
->index
,
469 &hashed_process_data
);
470 drawing_insert_square( drawing
, y
, height
);
473 /* Now, the process is in the state hash and our own process hash.
474 * We definitely can draw the items related to the ending state.
477 /* Check if the x position is unset. In can have been left unset by
478 * a draw closure from a after chunk hook. This should never happen,
479 * because it must be set by before chunk hook to the damage_begin
482 g_assert(hashed_process_data
->x
.middle
!= -1);
485 convert_time_to_pixels(
486 time_window
.start_time
,
487 time_window
.time_width
,
494 /* Jump over draw if we are at the same x position */
495 if(x
== hashed_process_data
->x
.middle
&&
496 hashed_process_data
->x
.middle_used
)
498 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
499 /* Draw collision indicator */
500 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
501 gdk_draw_point(drawing
->pixmap
,
505 hashed_process_data
->x
.middle_marked
= TRUE
;
509 DrawContext draw_context
;
511 /* Now create the drawing context that will be used to draw
512 * items related to the last state. */
513 draw_context
.drawable
= drawing
->pixmap
;
514 draw_context
.gc
= drawing
->gc
;
515 draw_context
.pango_layout
= drawing
->pango_layout
;
516 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
517 draw_context
.drawinfo
.end
.x
= x
;
519 draw_context
.drawinfo
.y
.over
= y
+1;
520 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
521 draw_context
.drawinfo
.y
.under
= y
+height
;
523 draw_context
.drawinfo
.start
.offset
.over
= 0;
524 draw_context
.drawinfo
.start
.offset
.middle
= 0;
525 draw_context
.drawinfo
.start
.offset
.under
= 0;
526 draw_context
.drawinfo
.end
.offset
.over
= 0;
527 draw_context
.drawinfo
.end
.offset
.middle
= 0;
528 draw_context
.drawinfo
.end
.offset
.under
= 0;
532 PropertiesLine prop_line
= prepare_s_e_line(process
);
533 draw_line((void*)&prop_line
, (void*)&draw_context
);
536 /* become the last x position */
537 hashed_process_data
->x
.middle
= x
;
538 hashed_process_data
->x
.middle_used
= TRUE
;
539 hashed_process_data
->x
.middle_marked
= FALSE
;
547 /* First, check if the current process is in the state computation
548 * process list. If it is there, that means we must add it right now and
549 * draw items from the beginning of the read for it. If it is not
550 * present, it's a new process and it was not present : it will
551 * be added after the state update. */
552 LttvProcessState
*process
;
553 process
= lttv_state_find_process(tfs
, pid_in
);
555 if(process
!= NULL
) {
556 /* Well, the process_out existed : we must get it in the process hash
557 * or add it, and draw its items.
559 /* Add process to process list (if not present) */
560 guint y
= 0, height
= 0, pl_height
= 0;
561 HashedProcessData
*hashed_process_data
= NULL
;
562 ProcessList
*process_list
= control_flow_data
->process_list
;
563 LttTime birth
= process
->creation_time
;
564 const gchar
*name
= g_quark_to_string(process
->name
);
566 if(processlist_get_process_pixels(process_list
,
570 tfc
->t_context
->index
,
573 &hashed_process_data
) == 1)
575 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
576 /* Process not present */
577 processlist_add(process_list
,
582 tfc
->t_context
->index
,
585 &hashed_process_data
);
586 processlist_get_process_pixels(process_list
,
590 tfc
->t_context
->index
,
593 &hashed_process_data
);
594 drawing_insert_square( drawing
, y
, height
);
597 /* Now, the process is in the state hash and our own process hash.
598 * We definitely can draw the items related to the ending state.
601 /* Check if the x position is unset. In can have been left unset by
602 * a draw closure from a after chunk hook. This should never happen,
603 * because it must be set by before chunk hook to the damage_begin
606 g_assert(hashed_process_data
->x
.middle
!= -1);
610 convert_time_to_pixels(
611 time_window
.start_time
,
612 time_window
.time_width
,
619 /* Jump over draw if we are at the same x position */
620 if(x
== hashed_process_data
->x
.middle
&&
621 hashed_process_data
->x
.middle_used
)
623 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
624 /* Draw collision indicator */
625 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
626 gdk_draw_point(drawing
->pixmap
,
630 hashed_process_data
->x
.middle_marked
= TRUE
;
634 DrawContext draw_context
;
636 /* Now create the drawing context that will be used to draw
637 * items related to the last state. */
638 draw_context
.drawable
= drawing
->pixmap
;
639 draw_context
.gc
= drawing
->gc
;
640 draw_context
.pango_layout
= drawing
->pango_layout
;
641 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
642 draw_context
.drawinfo
.end
.x
= x
;
644 draw_context
.drawinfo
.y
.over
= y
+1;
645 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
646 draw_context
.drawinfo
.y
.under
= y
+height
;
648 draw_context
.drawinfo
.start
.offset
.over
= 0;
649 draw_context
.drawinfo
.start
.offset
.middle
= 0;
650 draw_context
.drawinfo
.start
.offset
.under
= 0;
651 draw_context
.drawinfo
.end
.offset
.over
= 0;
652 draw_context
.drawinfo
.end
.offset
.middle
= 0;
653 draw_context
.drawinfo
.end
.offset
.under
= 0;
657 PropertiesLine prop_line
= prepare_s_e_line(process
);
658 draw_line((void*)&prop_line
, (void*)&draw_context
);
662 /* become the last x position */
663 hashed_process_data
->x
.middle
= x
;
664 hashed_process_data
->x
.middle_used
= TRUE
;
665 hashed_process_data
->x
.middle_marked
= FALSE
;
674 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
675 ControlFlowData
*control_flow_data
=
676 (ControlFlowData
*)events_request
->viewer_data
;
677 Tab
*tab
= control_flow_data
->tab
;
679 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
681 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
682 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
687 LttTime evtime
= ltt_event_time(e
);
688 TimeWindow time_window
=
689 lttvwindow_get_time_window(tab
);
691 LttTime end_time
= time_window
.end_time
;
693 //if(time < time_beg || time > time_end) return;
694 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
695 || ltt_time_compare(evtime
, end_time
) == 1)
698 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
700 g_debug("schedchange!");
702 /* Add process to process list (if not present) and get drawing "y" from
703 * process position */
704 guint pid_out
, pid_in
;
705 LttvProcessState
*process_out
, *process_in
;
707 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
709 ProcessList
*process_list
= control_flow_data
->process_list
;
712 LttField
*f
= ltt_event_field(e
);
714 element
= ltt_field_member(f
,0);
715 pid_out
= ltt_event_get_long_unsigned(e
,element
);
716 element
= ltt_field_member(f
,1);
717 pid_in
= ltt_event_get_long_unsigned(e
,element
);
718 g_debug("out : %u in : %u", pid_out
, pid_in
);
721 /* Find process pid_out in the list... */
722 process_out
= lttv_state_find_process(tfs
, pid_out
);
723 if(process_out
== NULL
) return 0;
724 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
726 birth
= process_out
->creation_time
;
727 const gchar
*name
= g_quark_to_string(process_out
->name
);
728 HashedProcessData
*hashed_process_data_out
= NULL
;
730 if(processlist_get_process_pixels(process_list
,
733 tfc
->t_context
->index
,
736 &hashed_process_data_out
) == 1)
738 /* Process not present */
739 processlist_add(process_list
,
742 tfc
->t_context
->index
,
745 &hashed_process_data_out
);
746 g_assert(processlist_get_process_pixels(process_list
,
749 tfc
->t_context
->index
,
752 &hashed_process_data_out
)==0);
753 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
757 /* Find process pid_in in the list... */
758 process_in
= lttv_state_find_process(tfs
, pid_in
);
759 if(process_in
== NULL
) return 0;
760 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
762 birth
= process_in
->creation_time
;
763 name
= g_quark_to_string(process_in
->name
);
764 HashedProcessData
*hashed_process_data_in
= NULL
;
766 if(processlist_get_process_pixels(process_list
,
769 tfc
->t_context
->index
,
772 &hashed_process_data_in
) == 1)
774 /* Process not present */
775 processlist_add(process_list
,
778 tfc
->t_context
->index
,
781 &hashed_process_data_in
);
782 processlist_get_process_pixels(process_list
,
785 tfc
->t_context
->index
,
788 &hashed_process_data_in
);
790 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
795 /* Find pixels corresponding to time of the event. If the time does
796 * not fit in the window, show a warning, not supposed to happend. */
798 guint width
= control_flow_data
->drawing
->width
;
800 LttTime time
= ltt_event_time(e
);
802 LttTime window_end
= ltt_time_add(time_window
.time_width
,
803 time_window
.start_time
);
806 convert_time_to_pixels(
807 time_window
.start_time
,
808 time_window
.time_width
,
813 //assert(x <= width);
815 /* draw what represents the event for outgoing process. */
817 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
818 draw_context_out
->current
->modify_over
->x
= x
;
819 draw_context_out
->current
->modify_under
->x
= x
;
820 draw_context_out
->current
->modify_over
->y
= y_out
;
821 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
822 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
823 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
824 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
825 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
826 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
827 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
828 //draw_context_out->gc = widget->style->black_gc;
830 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
831 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
833 /* Draw the line/background of the out process */
834 if(draw_context_out
->previous
->middle
->x
== -1)
836 draw_context_out
->previous
->over
->x
=
837 control_flow_data
->drawing
->damage_begin
;
838 draw_context_out
->previous
->middle
->x
=
839 control_flow_data
->drawing
->damage_begin
;
840 draw_context_out
->previous
->under
->x
=
841 control_flow_data
->drawing
->damage_begin
;
843 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
846 draw_context_out
->current
->middle
->x
= x
;
847 draw_context_out
->current
->over
->x
= x
;
848 draw_context_out
->current
->under
->x
= x
;
849 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
850 draw_context_out
->current
->over
->y
= y_out
;
851 draw_context_out
->current
->under
->y
= y_out
+ height
;
852 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
853 draw_context_out
->previous
->over
->y
= y_out
;
854 draw_context_out
->previous
->under
->y
= y_out
+ height
;
856 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
857 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
859 if(process_out
->state
->s
== LTTV_STATE_RUN
)
861 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
862 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
863 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
865 PropertiesBG prop_bg
;
866 prop_bg
.color
= g_new(GdkColor
,1);
870 prop_bg
.color
->red
= 0x1515;
871 prop_bg
.color
->green
= 0x1515;
872 prop_bg
.color
->blue
= 0x8c8c;
875 prop_bg
.color
->red
= 0x4e4e;
876 prop_bg
.color
->green
= 0xa9a9;
877 prop_bg
.color
->blue
= 0xa4a4;
880 prop_bg
.color
->red
= 0x7a7a;
881 prop_bg
.color
->green
= 0x4a4a;
882 prop_bg
.color
->blue
= 0x8b8b;
885 prop_bg
.color
->red
= 0x8080;
886 prop_bg
.color
->green
= 0x7777;
887 prop_bg
.color
->blue
= 0x4747;
890 prop_bg
.color
->red
= 0xe7e7;
891 prop_bg
.color
->green
= 0xe7e7;
892 prop_bg
.color
->blue
= 0xe7e7;
895 g_debug("calling from draw_event");
896 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
897 g_free(prop_bg
.color
);
898 //gdk_gc_unref(draw_context_out->gc);
901 draw_context_out
->gc
= widget
->style
->black_gc
;
903 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
904 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
905 PropertiesText prop_text_out
;
906 prop_text_out
.foreground
= &colorfg_out
;
907 prop_text_out
.background
= &colorbg_out
;
908 prop_text_out
.size
= 6;
909 prop_text_out
.position
= OVER
;
911 /* color of text : status of the process */
912 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
914 prop_text_out
.foreground
->red
= 0xffff;
915 prop_text_out
.foreground
->green
= 0xffff;
916 prop_text_out
.foreground
->blue
= 0xffff;
918 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
920 prop_text_out
.foreground
->red
= 0x0fff;
921 prop_text_out
.foreground
->green
= 0xffff;
922 prop_text_out
.foreground
->blue
= 0xfff0;
924 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
926 prop_text_out
.foreground
->red
= 0xffff;
927 prop_text_out
.foreground
->green
= 0xffff;
928 prop_text_out
.foreground
->blue
= 0x0000;
930 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
932 prop_text_out
.foreground
->red
= 0xffff;
933 prop_text_out
.foreground
->green
= 0x0000;
934 prop_text_out
.foreground
->blue
= 0xffff;
936 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
938 prop_text_out
.foreground
->red
= 0xffff;
939 prop_text_out
.foreground
->green
= 0x0000;
940 prop_text_out
.foreground
->blue
= 0x0000;
942 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
944 prop_text_out
.foreground
->red
= 0x0000;
945 prop_text_out
.foreground
->green
= 0xffff;
946 prop_text_out
.foreground
->blue
= 0x0000;
950 prop_text_out
.foreground
->red
= 0xffff;
951 prop_text_out
.foreground
->green
= 0xffff;
952 prop_text_out
.foreground
->blue
= 0xffff;
956 /* Print status of the process : U, WF, WC, E, W, R */
957 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
958 prop_text_out
.text
= "U->";
959 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
960 prop_text_out
.text
= "WF->";
961 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
962 prop_text_out
.text
= "WC->";
963 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
964 prop_text_out
.text
= "E->";
965 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
966 prop_text_out
.text
= "W->";
967 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
968 prop_text_out
.text
= "R->";
970 prop_text_out
.text
= "U";
972 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
973 //gdk_gc_unref(draw_context_out->gc);
975 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
976 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
977 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
979 PropertiesLine prop_line_out
;
980 prop_line_out
.color
= g_new(GdkColor
,1);
981 prop_line_out
.line_width
= 2;
982 prop_line_out
.style
= GDK_LINE_SOLID
;
983 prop_line_out
.position
= MIDDLE
;
985 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
987 /* color of line : status of the process */
988 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
990 prop_line_out
.color
->red
= 0xffff;
991 prop_line_out
.color
->green
= 0xffff;
992 prop_line_out
.color
->blue
= 0xffff;
994 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
996 prop_line_out
.color
->red
= 0x0fff;
997 prop_line_out
.color
->green
= 0xffff;
998 prop_line_out
.color
->blue
= 0xfff0;
1000 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1002 prop_line_out
.color
->red
= 0xffff;
1003 prop_line_out
.color
->green
= 0xffff;
1004 prop_line_out
.color
->blue
= 0x0000;
1006 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1008 prop_line_out
.color
->red
= 0xffff;
1009 prop_line_out
.color
->green
= 0x0000;
1010 prop_line_out
.color
->blue
= 0xffff;
1012 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1014 prop_line_out
.color
->red
= 0xffff;
1015 prop_line_out
.color
->green
= 0x0000;
1016 prop_line_out
.color
->blue
= 0x0000;
1018 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1020 prop_line_out
.color
->red
= 0x0000;
1021 prop_line_out
.color
->green
= 0xffff;
1022 prop_line_out
.color
->blue
= 0x0000;
1026 prop_line_out
.color
->red
= 0xffff;
1027 prop_line_out
.color
->green
= 0xffff;
1028 prop_line_out
.color
->blue
= 0xffff;
1031 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1032 g_free(prop_line_out
.color
);
1033 //gdk_gc_unref(draw_context_out->gc);
1034 /* Note : finishing line will have to be added when trace read over. */
1036 /* Finally, update the drawing context of the pid_in. */
1038 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1039 draw_context_in
->current
->modify_over
->x
= x
;
1040 draw_context_in
->current
->modify_under
->x
= x
;
1041 draw_context_in
->current
->modify_over
->y
= y_in
;
1042 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1043 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1044 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1045 widget
= control_flow_data
->drawing
->drawing_area
;
1046 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1047 //draw_context_in->gc = widget->style->black_gc;
1048 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1049 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1051 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1052 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1054 /* Draw the line/bg of the in process */
1055 if(draw_context_in
->previous
->middle
->x
== -1)
1057 draw_context_in
->previous
->over
->x
=
1058 control_flow_data
->drawing
->damage_begin
;
1059 draw_context_in
->previous
->middle
->x
=
1060 control_flow_data
->drawing
->damage_begin
;
1061 draw_context_in
->previous
->under
->x
=
1062 control_flow_data
->drawing
->damage_begin
;
1064 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1068 draw_context_in
->current
->middle
->x
= x
;
1069 draw_context_in
->current
->over
->x
= x
;
1070 draw_context_in
->current
->under
->x
= x
;
1071 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1072 draw_context_in
->current
->over
->y
= y_in
;
1073 draw_context_in
->current
->under
->y
= y_in
+ height
;
1074 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1075 draw_context_in
->previous
->over
->y
= y_in
;
1076 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1078 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1079 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1082 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1084 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1085 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1086 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1088 PropertiesBG prop_bg
;
1089 prop_bg
.color
= g_new(GdkColor
,1);
1091 switch(tfc
->index
) {
1093 prop_bg
.color
->red
= 0x1515;
1094 prop_bg
.color
->green
= 0x1515;
1095 prop_bg
.color
->blue
= 0x8c8c;
1098 prop_bg
.color
->red
= 0x4e4e;
1099 prop_bg
.color
->green
= 0xa9a9;
1100 prop_bg
.color
->blue
= 0xa4a4;
1103 prop_bg
.color
->red
= 0x7a7a;
1104 prop_bg
.color
->green
= 0x4a4a;
1105 prop_bg
.color
->blue
= 0x8b8b;
1108 prop_bg
.color
->red
= 0x8080;
1109 prop_bg
.color
->green
= 0x7777;
1110 prop_bg
.color
->blue
= 0x4747;
1113 prop_bg
.color
->red
= 0xe7e7;
1114 prop_bg
.color
->green
= 0xe7e7;
1115 prop_bg
.color
->blue
= 0xe7e7;
1119 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1120 g_free(prop_bg
.color
);
1121 //gdk_gc_unref(draw_context_in->gc);
1124 draw_context_in
->gc
= widget
->style
->black_gc
;
1126 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1127 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1128 PropertiesText prop_text_in
;
1129 prop_text_in
.foreground
= &colorfg_in
;
1130 prop_text_in
.background
= &colorbg_in
;
1131 prop_text_in
.size
= 6;
1132 prop_text_in
.position
= OVER
;
1134 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1135 /* foreground of text : status of the process */
1136 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1138 prop_text_in
.foreground
->red
= 0xffff;
1139 prop_text_in
.foreground
->green
= 0xffff;
1140 prop_text_in
.foreground
->blue
= 0xffff;
1142 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1144 prop_text_in
.foreground
->red
= 0x0fff;
1145 prop_text_in
.foreground
->green
= 0xffff;
1146 prop_text_in
.foreground
->blue
= 0xfff0;
1148 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1150 prop_text_in
.foreground
->red
= 0xffff;
1151 prop_text_in
.foreground
->green
= 0xffff;
1152 prop_text_in
.foreground
->blue
= 0x0000;
1154 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1156 prop_text_in
.foreground
->red
= 0xffff;
1157 prop_text_in
.foreground
->green
= 0x0000;
1158 prop_text_in
.foreground
->blue
= 0xffff;
1160 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1162 prop_text_in
.foreground
->red
= 0xffff;
1163 prop_text_in
.foreground
->green
= 0x0000;
1164 prop_text_in
.foreground
->blue
= 0x0000;
1166 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1168 prop_text_in
.foreground
->red
= 0x0000;
1169 prop_text_in
.foreground
->green
= 0xffff;
1170 prop_text_in
.foreground
->blue
= 0x0000;
1174 prop_text_in
.foreground
->red
= 0xffff;
1175 prop_text_in
.foreground
->green
= 0xffff;
1176 prop_text_in
.foreground
->blue
= 0xffff;
1181 /* Print status of the process : U, WF, WC, E, W, R */
1182 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1183 prop_text_in
.text
= "U->";
1184 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1185 prop_text_in
.text
= "WF->";
1186 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1187 prop_text_in
.text
= "WC->";
1188 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1189 prop_text_in
.text
= "E->";
1190 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1191 prop_text_in
.text
= "W->";
1192 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1193 prop_text_in
.text
= "R->";
1195 prop_text_in
.text
= "U";
1197 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1198 //gdk_gc_unref(draw_context_in->gc);
1200 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1201 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1202 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1204 PropertiesLine prop_line_in
;
1205 prop_line_in
.color
= g_new(GdkColor
,1);
1206 prop_line_in
.line_width
= 2;
1207 prop_line_in
.style
= GDK_LINE_SOLID
;
1208 prop_line_in
.position
= MIDDLE
;
1210 /* color of line : status of the process */
1211 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1213 prop_line_in
.color
->red
= 0xffff;
1214 prop_line_in
.color
->green
= 0xffff;
1215 prop_line_in
.color
->blue
= 0xffff;
1217 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1219 prop_line_in
.color
->red
= 0x0fff;
1220 prop_line_in
.color
->green
= 0xffff;
1221 prop_line_in
.color
->blue
= 0xfff0;
1223 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1225 prop_line_in
.color
->red
= 0xffff;
1226 prop_line_in
.color
->green
= 0xffff;
1227 prop_line_in
.color
->blue
= 0x0000;
1229 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1231 prop_line_in
.color
->red
= 0xffff;
1232 prop_line_in
.color
->green
= 0x0000;
1233 prop_line_in
.color
->blue
= 0xffff;
1235 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1237 prop_line_in
.color
->red
= 0xffff;
1238 prop_line_in
.color
->green
= 0x0000;
1239 prop_line_in
.color
->blue
= 0x0000;
1241 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1243 prop_line_in
.color
->red
= 0x0000;
1244 prop_line_in
.color
->green
= 0xffff;
1245 prop_line_in
.color
->blue
= 0x0000;
1249 prop_line_in
.color
->red
= 0xffff;
1250 prop_line_in
.color
->green
= 0xffff;
1251 prop_line_in
.color
->blue
= 0xffff;
1254 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1255 g_free(prop_line_in
.color
);
1256 //gdk_gc_unref(draw_context_in->gc);
1266 GString
*string
= g_string_new("");;
1267 gboolean field_names
= TRUE
, state
= TRUE
;
1269 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1270 g_string_append_printf(string
,"\n");
1273 g_string_append_printf(string
, " %s",
1274 g_quark_to_string(tfs
->process
->state
->s
));
1277 g_info("%s",string
->str
);
1279 g_string_free(string
, TRUE
);
1281 /* End of text dump */
1286 /* after_schedchange_hook
1288 * The draw after hook is called by the reading API to have a
1289 * particular event drawn on the screen.
1290 * @param hook_data ControlFlowData structure of the viewer.
1291 * @param call_data Event context.
1293 * This function adds items to be drawn in a queue for each process.
1296 int after_schedchange_hook(void *hook_data
, void *call_data
)
1298 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1299 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1301 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1303 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1304 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1309 LttTime evtime
= ltt_event_time(e
);
1310 TimeWindow time_window
=
1311 lttvwindow_get_time_window(control_flow_data
->tab
);
1313 LttTime end_time
= time_window
.end_time
;
1315 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1316 || ltt_time_compare(evtime
, end_time
) == 1)
1319 guint width
= control_flow_data
->drawing
->width
;
1321 /* Add process to process list (if not present) */
1322 LttvProcessState
*process_out
, *process_in
;
1324 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1325 HashedProcessData
*hashed_process_data_in
= NULL
;
1327 ProcessList
*process_list
= control_flow_data
->process_list
;
1332 LttField
*f
= ltt_event_field(e
);
1334 element
= ltt_field_member(f
,0);
1335 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1336 element
= ltt_field_member(f
,1);
1337 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1338 g_debug("out : %u in : %u", pid_out
, pid_in
);
1342 /* Find process pid_in in the list... */
1343 process_in
= lttv_state_find_process(tfs
, pid_in
);
1344 /* It should exist, because we are after the state update. */
1345 g_assert(process_in
!= NULL
);
1347 birth
= process_in
->creation_time
;
1348 const gchar
*name
= g_quark_to_string(process_in
->name
);
1350 if(processlist_get_process_pixels(process_list
,
1352 process_in
->last_cpu
,
1354 tfc
->t_context
->index
,
1357 &hashed_process_data_in
) == 1)
1359 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1360 /* Process not present */
1361 processlist_add(process_list
,
1363 process_in
->last_cpu
,
1366 tfc
->t_context
->index
,
1369 &hashed_process_data_in
);
1370 processlist_get_process_pixels(process_list
,
1372 process_in
->last_cpu
,
1374 tfc
->t_context
->index
,
1377 &hashed_process_data_in
);
1378 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1383 convert_time_to_pixels(
1384 time_window
.start_time
,
1385 time_window
.time_width
,
1391 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1392 hashed_process_data_in
->x
.middle
= new_x
;
1393 hashed_process_data_in
->x
.middle_used
= FALSE
;
1394 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1404 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1405 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1407 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1409 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1410 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1416 LttTime evtime
= ltt_event_time(e
);
1417 TimeWindow time_window
=
1418 lttvwindow_get_time_window(control_flow_data
->tab
);
1420 LttTime end_time
= time_window
.end_time
;
1422 //if(time < time_beg || time > time_end) return;
1423 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1424 || ltt_time_compare(evtime
, end_time
) == 1)
1428 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1430 g_debug("schedchange!");
1432 /* Add process to process list (if not present) and get drawing "y" from
1433 * process position */
1434 guint pid_out
, pid_in
;
1435 LttvProcessState
*process_out
, *process_in
;
1437 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1439 ProcessList
*process_list
= control_flow_data
->process_list
;
1442 LttField
*f
= ltt_event_field(e
);
1444 element
= ltt_field_member(f
,0);
1445 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1446 element
= ltt_field_member(f
,1);
1447 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1448 //g_debug("out : %u in : %u", pid_out, pid_in);
1451 /* Find process pid_out in the list... */
1452 process_out
= lttv_state_find_process(tfs
, pid_out
);
1453 if(process_out
== NULL
) return 0;
1454 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1456 birth
= process_out
->creation_time
;
1457 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1458 HashedProcessData
*hashed_process_data_out
= NULL
;
1460 if(processlist_get_process_pixels(process_list
,
1463 tfc
->t_context
->index
,
1466 &hashed_process_data_out
) == 1)
1468 /* Process not present */
1469 processlist_add(process_list
,
1472 tfc
->t_context
->index
,
1475 &hashed_process_data_out
);
1476 processlist_get_process_pixels(process_list
,
1479 tfc
->t_context
->index
,
1482 &hashed_process_data_out
);
1483 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1488 /* Find process pid_in in the list... */
1489 process_in
= lttv_state_find_process(tfs
, pid_in
);
1490 if(process_in
== NULL
) return 0;
1491 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1493 birth
= process_in
->creation_time
;
1494 name
= strdup(g_quark_to_string(process_in
->name
));
1495 HashedProcessData
*hashed_process_data_in
= NULL
;
1497 if(processlist_get_process_pixels(process_list
,
1500 tfc
->t_context
->index
,
1503 &hashed_process_data_in
) == 1)
1505 /* Process not present */
1506 processlist_add(process_list
,
1509 tfc
->t_context
->index
,
1512 &hashed_process_data_in
);
1513 processlist_get_process_pixels(process_list
,
1516 tfc
->t_context
->index
,
1519 &hashed_process_data_in
);
1521 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1526 /* Find pixels corresponding to time of the event. If the time does
1527 * not fit in the window, show a warning, not supposed to happend. */
1529 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1531 //LttTime time = ltt_event_time(e);
1533 //LttTime window_end = ltt_time_add(time_window->time_width,
1534 // time_window->start_time);
1537 //convert_time_to_pixels(
1538 // time_window->start_time,
1539 // time_window.time_width,
1545 //assert(x <= width);
1547 /* draw what represents the event for outgoing process. */
1549 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1550 //draw_context_out->current->modify_over->x = x;
1551 draw_context_out
->current
->modify_over
->y
= y_out
;
1552 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1553 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1554 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1555 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1556 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1558 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1559 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1561 /*if(process_out->state->s == LTTV_STATE_RUN)
1563 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1564 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1565 PropertiesBG prop_bg;
1566 prop_bg.color = g_new(GdkColor,1);
1568 prop_bg.color->red = 0xffff;
1569 prop_bg.color->green = 0xffff;
1570 prop_bg.color->blue = 0xffff;
1572 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1573 g_free(prop_bg.color);
1574 gdk_gc_unref(draw_context_out->gc);
1577 draw_context_out
->gc
= widget
->style
->black_gc
;
1579 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1580 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1581 PropertiesText prop_text_out
;
1582 prop_text_out
.foreground
= &colorfg_out
;
1583 prop_text_out
.background
= &colorbg_out
;
1584 prop_text_out
.size
= 6;
1585 prop_text_out
.position
= OVER
;
1587 /* color of text : status of the process */
1588 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1590 prop_text_out
.foreground
->red
= 0xffff;
1591 prop_text_out
.foreground
->green
= 0xffff;
1592 prop_text_out
.foreground
->blue
= 0xffff;
1594 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1596 prop_text_out
.foreground
->red
= 0x0fff;
1597 prop_text_out
.foreground
->green
= 0xffff;
1598 prop_text_out
.foreground
->blue
= 0xfff0;
1600 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1602 prop_text_out
.foreground
->red
= 0xffff;
1603 prop_text_out
.foreground
->green
= 0xffff;
1604 prop_text_out
.foreground
->blue
= 0x0000;
1606 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1608 prop_text_out
.foreground
->red
= 0xffff;
1609 prop_text_out
.foreground
->green
= 0x0000;
1610 prop_text_out
.foreground
->blue
= 0xffff;
1612 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1614 prop_text_out
.foreground
->red
= 0xffff;
1615 prop_text_out
.foreground
->green
= 0x0000;
1616 prop_text_out
.foreground
->blue
= 0x0000;
1618 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1620 prop_text_out
.foreground
->red
= 0x0000;
1621 prop_text_out
.foreground
->green
= 0xffff;
1622 prop_text_out
.foreground
->blue
= 0x0000;
1626 prop_text_out
.foreground
->red
= 0xffff;
1627 prop_text_out
.foreground
->green
= 0xffff;
1628 prop_text_out
.foreground
->blue
= 0xffff;
1631 /* Print status of the process : U, WF, WC, E, W, R */
1632 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1633 prop_text_out
.text
= "U";
1634 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1635 prop_text_out
.text
= "WF";
1636 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1637 prop_text_out
.text
= "WC";
1638 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1639 prop_text_out
.text
= "E";
1640 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1641 prop_text_out
.text
= "W";
1642 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1643 prop_text_out
.text
= "R";
1645 prop_text_out
.text
= "U";
1647 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1649 //gdk_gc_unref(draw_context_out->gc);
1651 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1652 draw_context_out
->current
->over
->y
= y_out
;
1653 draw_context_out
->current
->under
->y
= y_out
+height
;
1654 draw_context_out
->current
->status
= process_out
->state
->s
;
1656 /* for pid_out : remove previous, Prev = current, new current (default) */
1657 g_free(draw_context_out
->previous
->modify_under
);
1658 g_free(draw_context_out
->previous
->modify_middle
);
1659 g_free(draw_context_out
->previous
->modify_over
);
1660 g_free(draw_context_out
->previous
->under
);
1661 g_free(draw_context_out
->previous
->middle
);
1662 g_free(draw_context_out
->previous
->over
);
1663 g_free(draw_context_out
->previous
);
1665 draw_context_out
->previous
= draw_context_out
->current
;
1667 draw_context_out
->current
= g_new(DrawInfo
,1);
1668 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1669 draw_context_out
->current
->over
->x
= -1;
1670 draw_context_out
->current
->over
->y
= -1;
1671 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1672 draw_context_out
->current
->middle
->x
= -1;
1673 draw_context_out
->current
->middle
->y
= -1;
1674 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1675 draw_context_out
->current
->under
->x
= -1;
1676 draw_context_out
->current
->under
->y
= -1;
1677 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1678 draw_context_out
->current
->modify_over
->x
= -1;
1679 draw_context_out
->current
->modify_over
->y
= -1;
1680 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1681 draw_context_out
->current
->modify_middle
->x
= -1;
1682 draw_context_out
->current
->modify_middle
->y
= -1;
1683 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1684 draw_context_out
->current
->modify_under
->x
= -1;
1685 draw_context_out
->current
->modify_under
->y
= -1;
1686 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1688 /* Finally, update the drawing context of the pid_in. */
1690 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1691 //draw_context_in->current->modify_over->x = x;
1692 draw_context_in
->current
->modify_over
->y
= y_in
;
1693 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1694 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1695 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1696 widget
= control_flow_data
->drawing
->drawing_area
;
1697 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1699 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1700 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1702 /*if(process_in->state->s == LTTV_STATE_RUN)
1704 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1705 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1706 PropertiesBG prop_bg;
1707 prop_bg.color = g_new(GdkColor,1);
1709 prop_bg.color->red = 0xffff;
1710 prop_bg.color->green = 0xffff;
1711 prop_bg.color->blue = 0xffff;
1713 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1714 g_free(prop_bg.color);
1715 gdk_gc_unref(draw_context_in->gc);
1718 draw_context_in
->gc
= widget
->style
->black_gc
;
1720 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1721 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1722 PropertiesText prop_text_in
;
1723 prop_text_in
.foreground
= &colorfg_in
;
1724 prop_text_in
.background
= &colorbg_in
;
1725 prop_text_in
.size
= 6;
1726 prop_text_in
.position
= OVER
;
1728 /* foreground of text : status of the process */
1729 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1731 prop_text_in
.foreground
->red
= 0xffff;
1732 prop_text_in
.foreground
->green
= 0xffff;
1733 prop_text_in
.foreground
->blue
= 0xffff;
1735 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1737 prop_text_in
.foreground
->red
= 0x0fff;
1738 prop_text_in
.foreground
->green
= 0xffff;
1739 prop_text_in
.foreground
->blue
= 0xfff0;
1741 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1743 prop_text_in
.foreground
->red
= 0xffff;
1744 prop_text_in
.foreground
->green
= 0xffff;
1745 prop_text_in
.foreground
->blue
= 0x0000;
1747 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1749 prop_text_in
.foreground
->red
= 0xffff;
1750 prop_text_in
.foreground
->green
= 0x0000;
1751 prop_text_in
.foreground
->blue
= 0xffff;
1753 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1755 prop_text_in
.foreground
->red
= 0xffff;
1756 prop_text_in
.foreground
->green
= 0x0000;
1757 prop_text_in
.foreground
->blue
= 0x0000;
1759 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1761 prop_text_in
.foreground
->red
= 0x0000;
1762 prop_text_in
.foreground
->green
= 0xffff;
1763 prop_text_in
.foreground
->blue
= 0x0000;
1767 prop_text_in
.foreground
->red
= 0xffff;
1768 prop_text_in
.foreground
->green
= 0xffff;
1769 prop_text_in
.foreground
->blue
= 0xffff;
1773 /* Print status of the process : U, WF, WC, E, W, R */
1774 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1775 prop_text_in
.text
= "U";
1776 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1777 prop_text_in
.text
= "WF";
1778 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1779 prop_text_in
.text
= "WC";
1780 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1781 prop_text_in
.text
= "E";
1782 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1783 prop_text_in
.text
= "W";
1784 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1785 prop_text_in
.text
= "R";
1787 prop_text_in
.text
= "U";
1789 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1792 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1795 prop_text_in
.foreground
= &colorfg_in
;
1796 prop_text_in
.background
= &colorbg_in
;
1797 prop_text_in
.foreground
->red
= 0xffff;
1798 prop_text_in
.foreground
->green
= 0xffff;
1799 prop_text_in
.foreground
->blue
= 0xffff;
1800 prop_text_in
.size
= 6;
1801 prop_text_in
.position
= UNDER
;
1803 prop_text_in
.text
= g_new(gchar
, 260);
1804 strcpy(prop_text_in
.text
, "CPU ");
1805 snprintf(tmp
, 255, "%u", tfc
->index
);
1806 strcat(prop_text_in
.text
, tmp
);
1808 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1809 g_free(prop_text_in
.text
);
1813 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1814 draw_context_in
->current
->over
->y
= y_in
;
1815 draw_context_in
->current
->under
->y
= y_in
+height
;
1816 draw_context_in
->current
->status
= process_in
->state
->s
;
1818 /* for pid_in : remove previous, Prev = current, new current (default) */
1819 g_free(draw_context_in
->previous
->modify_under
);
1820 g_free(draw_context_in
->previous
->modify_middle
);
1821 g_free(draw_context_in
->previous
->modify_over
);
1822 g_free(draw_context_in
->previous
->under
);
1823 g_free(draw_context_in
->previous
->middle
);
1824 g_free(draw_context_in
->previous
->over
);
1825 g_free(draw_context_in
->previous
);
1827 draw_context_in
->previous
= draw_context_in
->current
;
1829 draw_context_in
->current
= g_new(DrawInfo
,1);
1830 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1831 draw_context_in
->current
->over
->x
= -1;
1832 draw_context_in
->current
->over
->y
= -1;
1833 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1834 draw_context_in
->current
->middle
->x
= -1;
1835 draw_context_in
->current
->middle
->y
= -1;
1836 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1837 draw_context_in
->current
->under
->x
= -1;
1838 draw_context_in
->current
->under
->y
= -1;
1839 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1840 draw_context_in
->current
->modify_over
->x
= -1;
1841 draw_context_in
->current
->modify_over
->y
= -1;
1842 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1843 draw_context_in
->current
->modify_middle
->x
= -1;
1844 draw_context_in
->current
->modify_middle
->y
= -1;
1845 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1846 draw_context_in
->current
->modify_under
->x
= -1;
1847 draw_context_in
->current
->modify_under
->y
= -1;
1848 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1857 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1859 PropertiesLine prop_line
;
1860 prop_line
.line_width
= 1;
1861 prop_line
.style
= GDK_LINE_SOLID
;
1863 //GdkColormap *colormap = gdk_colormap_get_system();
1865 /* color of line : execution mode of the process */
1866 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1867 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1868 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1869 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1870 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1871 prop_line
.color
= drawing_colors
[COL_TRAP
];
1872 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1873 prop_line
.color
= drawing_colors
[COL_IRQ
];
1874 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1875 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1877 prop_line
.color
= drawing_colors
[COL_WHITE
];
1879 //gdk_colormap_alloc_color(colormap,
1890 /* before_execmode_hook
1892 * This function basically draw lines and icons. Two types of lines are drawn :
1893 * one small (3 pixels?) representing the state of the process and the second
1894 * type is thicker (10 pixels?) representing on which CPU a process is running
1895 * (and this only in running state).
1897 * Extremums of the lines :
1898 * x_min : time of the last event context for this process kept in memory.
1899 * x_max : time of the current event.
1900 * y : middle of the process in the process list. The process is found in the
1901 * list, therefore is it's position in pixels.
1903 * The choice of lines'color is defined by the context of the last event for this
1908 int before_execmode_hook(void *hook_data
, void *call_data
)
1910 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1911 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1912 Drawing_t
*drawing
= control_flow_data
->drawing
;
1914 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1916 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1917 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1922 LttTime evtime
= ltt_event_time(e
);
1923 TimeWindow time_window
=
1924 lttvwindow_get_time_window(control_flow_data
->tab
);
1926 LttTime end_time
= time_window
.end_time
;
1928 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1929 || ltt_time_compare(evtime
, end_time
) == 1)
1932 guint width
= drawing
->width
;
1934 /* we are in a execmode, before the state update. We must draw the
1935 * items corresponding to the state before it changes : now is the right
1939 LttvProcessState
*process
= tfs
->process
;
1940 g_assert(process
!= NULL
);
1942 guint pid
= process
->pid
;
1944 /* Well, the process_out existed : we must get it in the process hash
1945 * or add it, and draw its items.
1947 /* Add process to process list (if not present) */
1948 guint y
= 0, height
= 0, pl_height
= 0;
1949 HashedProcessData
*hashed_process_data
= NULL
;
1950 ProcessList
*process_list
= control_flow_data
->process_list
;
1951 LttTime birth
= process
->creation_time
;
1952 const gchar
*name
= g_quark_to_string(process
->name
);
1954 if(processlist_get_process_pixels(process_list
,
1958 tfc
->t_context
->index
,
1961 &hashed_process_data
) == 1)
1963 g_assert(pid
== 0 || pid
!= process
->ppid
);
1964 /* Process not present */
1965 processlist_add(process_list
,
1970 tfc
->t_context
->index
,
1973 &hashed_process_data
);
1974 processlist_get_process_pixels(process_list
,
1978 tfc
->t_context
->index
,
1981 &hashed_process_data
);
1982 drawing_insert_square( drawing
, y
, height
);
1985 /* Now, the process is in the state hash and our own process hash.
1986 * We definitely can draw the items related to the ending state.
1989 /* Check if the x position is unset. In can have been left unset by
1990 * a draw closure from a after chunk hook. This should never happen,
1991 * because it must be set by before chunk hook to the damage_begin
1994 g_assert(hashed_process_data
->x
.over
!= -1);
1998 convert_time_to_pixels(
1999 time_window
.start_time
,
2000 time_window
.time_width
,
2007 /* Jump over draw if we are at the same x position */
2008 if(x
== hashed_process_data
->x
.middle
&&
2009 hashed_process_data
->x
.middle_used
)
2011 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2012 /* Draw collision indicator */
2013 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2014 gdk_draw_point(drawing
->pixmap
,
2018 hashed_process_data
->x
.middle_marked
= TRUE
;
2023 DrawContext draw_context
;
2024 /* Now create the drawing context that will be used to draw
2025 * items related to the last state. */
2026 draw_context
.drawable
= drawing
->pixmap
;
2027 draw_context
.gc
= drawing
->gc
;
2028 draw_context
.pango_layout
= drawing
->pango_layout
;
2029 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2030 draw_context
.drawinfo
.end
.x
= x
;
2032 draw_context
.drawinfo
.y
.over
= y
+1;
2033 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2034 draw_context
.drawinfo
.y
.under
= y
+height
;
2036 draw_context
.drawinfo
.start
.offset
.over
= 0;
2037 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2038 draw_context
.drawinfo
.start
.offset
.under
= 0;
2039 draw_context
.drawinfo
.end
.offset
.over
= 0;
2040 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2041 draw_context
.drawinfo
.end
.offset
.under
= 0;
2045 PropertiesLine prop_line
= prepare_s_e_line(process
);
2046 draw_line((void*)&prop_line
, (void*)&draw_context
);
2049 /* become the last x position */
2050 hashed_process_data
->x
.middle
= x
;
2051 hashed_process_data
->x
.middle_used
= TRUE
;
2052 hashed_process_data
->x
.middle_marked
= FALSE
;
2059 /* after_execmode_hook
2061 * The draw after hook is called by the reading API to have a
2062 * particular event drawn on the screen.
2063 * @param hook_data ControlFlowData structure of the viewer.
2064 * @param call_data Event context.
2066 * This function adds items to be drawn in a queue for each process.
2069 int after_execmode_hook(void *hook_data
, void *call_data
)
2071 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2072 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2074 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2076 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2077 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2082 LttTime evtime
= ltt_event_time(e
);
2083 TimeWindow time_window
=
2084 lttvwindow_get_time_window(control_flow_data
->tab
);
2086 LttTime end_time
= time_window
.end_time
;
2088 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2089 || ltt_time_compare(evtime
, end_time
) == 1)
2092 guint width
= control_flow_data
->drawing
->width
;
2094 /* Add process to process list (if not present) */
2095 LttvProcessState
*process
;
2097 guint y
= 0, height
= 0, pl_height
= 0;
2098 HashedProcessData
*hashed_process_data
= NULL
;
2100 ProcessList
*process_list
= control_flow_data
->process_list
;
2102 /* Find process pid_in in the list... */
2103 process
= tfs
->process
;
2104 /* It should exist, because we are after the state update. */
2105 g_assert(process
!= NULL
);
2107 guint pid
= process
->pid
;
2109 birth
= process
->creation_time
;
2110 const gchar
*name
= g_quark_to_string(process
->name
);
2112 if(processlist_get_process_pixels(process_list
,
2116 tfc
->t_context
->index
,
2119 &hashed_process_data
) == 1)
2121 g_assert(pid
== 0 || pid
!= process
->ppid
);
2122 /* Process not present */
2123 processlist_add(process_list
,
2128 tfc
->t_context
->index
,
2131 &hashed_process_data
);
2132 processlist_get_process_pixels(process_list
,
2136 tfc
->t_context
->index
,
2139 &hashed_process_data
);
2140 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2145 convert_time_to_pixels(
2146 time_window
.start_time
,
2147 time_window
.time_width
,
2153 if(hashed_process_data
->x
.middle
!= new_x
) {
2154 hashed_process_data
->x
.middle
= new_x
;
2155 hashed_process_data
->x
.middle_used
= FALSE
;
2156 hashed_process_data
->x
.middle_marked
= FALSE
;
2164 /* before_process_hook
2166 * Draw lines for process event.
2168 * @param hook_data ControlFlowData structure of the viewer.
2169 * @param call_data Event context.
2171 * This function adds items to be drawn in a queue for each process.
2174 int before_process_hook(void *hook_data
, void *call_data
)
2176 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2177 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2178 Drawing_t
*drawing
= control_flow_data
->drawing
;
2180 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2182 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2183 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2188 LttTime evtime
= ltt_event_time(e
);
2189 TimeWindow time_window
=
2190 lttvwindow_get_time_window(control_flow_data
->tab
);
2192 LttTime end_time
= time_window
.end_time
;
2194 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2195 || ltt_time_compare(evtime
, end_time
) == 1)
2198 guint width
= control_flow_data
->drawing
->width
;
2202 LttField
*f
= ltt_event_field(e
);
2204 element
= ltt_field_member(f
,0);
2205 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2208 if(sub_id
== 3) { /* exit */
2210 /* Add process to process list (if not present) */
2211 LttvProcessState
*process
= tfs
->process
;
2212 guint pid
= process
->pid
;
2214 guint y
= 0, height
= 0, pl_height
= 0;
2215 HashedProcessData
*hashed_process_data
= NULL
;
2217 ProcessList
*process_list
= control_flow_data
->process_list
;
2219 g_assert(process
!= NULL
);
2221 birth
= process
->creation_time
;
2222 const gchar
*name
= g_quark_to_string(process
->name
);
2224 if(processlist_get_process_pixels(process_list
,
2228 tfc
->t_context
->index
,
2231 &hashed_process_data
) == 1)
2233 g_assert(pid
== 0 || pid
!= process
->ppid
);
2234 /* Process not present */
2235 processlist_add(process_list
,
2240 tfc
->t_context
->index
,
2243 &hashed_process_data
);
2244 processlist_get_process_pixels(process_list
,
2248 tfc
->t_context
->index
,
2251 &hashed_process_data
);
2252 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2255 /* Now, the process is in the state hash and our own process hash.
2256 * We definitely can draw the items related to the ending state.
2259 /* Check if the x position is unset. In can have been left unset by
2260 * a draw closure from a after chunk hook. This should never happen,
2261 * because it must be set by before chunk hook to the damage_begin
2264 g_assert(hashed_process_data
->x
.over
!= -1);
2268 convert_time_to_pixels(
2269 time_window
.start_time
,
2270 time_window
.time_width
,
2277 /* Jump over draw if we are at the same x position */
2278 if(x
== hashed_process_data
->x
.middle
&&
2279 hashed_process_data
->x
.middle_used
)
2281 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2282 /* Draw collision indicator */
2283 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2284 gdk_draw_point(drawing
->pixmap
,
2288 hashed_process_data
->x
.middle_marked
= TRUE
;
2292 DrawContext draw_context
;
2294 /* Now create the drawing context that will be used to draw
2295 * items related to the last state. */
2296 draw_context
.drawable
= drawing
->pixmap
;
2297 draw_context
.gc
= drawing
->gc
;
2298 draw_context
.pango_layout
= drawing
->pango_layout
;
2299 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2300 draw_context
.drawinfo
.end
.x
= x
;
2302 draw_context
.drawinfo
.y
.over
= y
+1;
2303 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2304 draw_context
.drawinfo
.y
.under
= y
+height
;
2306 draw_context
.drawinfo
.start
.offset
.over
= 0;
2307 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2308 draw_context
.drawinfo
.start
.offset
.under
= 0;
2309 draw_context
.drawinfo
.end
.offset
.over
= 0;
2310 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2311 draw_context
.drawinfo
.end
.offset
.under
= 0;
2315 PropertiesLine prop_line
= prepare_s_e_line(process
);
2316 draw_line((void*)&prop_line
, (void*)&draw_context
);
2319 /* become the last x position */
2320 hashed_process_data
->x
.middle
= x
;
2321 hashed_process_data
->x
.middle_used
= TRUE
;
2322 hashed_process_data
->x
.middle_marked
= FALSE
;
2336 /* after_process_hook
2338 * Create the processlist entry for the child process. Put the last
2339 * position in x at the current time value.
2341 * @param hook_data ControlFlowData structure of the viewer.
2342 * @param call_data Event context.
2344 * This function adds items to be drawn in a queue for each process.
2347 int after_process_hook(void *hook_data
, void *call_data
)
2349 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2350 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2352 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2354 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2355 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2360 LttTime evtime
= ltt_event_time(e
);
2361 TimeWindow time_window
=
2362 lttvwindow_get_time_window(control_flow_data
->tab
);
2364 LttTime end_time
= time_window
.end_time
;
2366 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2367 || ltt_time_compare(evtime
, end_time
) == 1)
2370 guint width
= control_flow_data
->drawing
->width
;
2375 LttField
*f
= ltt_event_field(e
);
2377 element
= ltt_field_member(f
,0);
2378 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2379 element
= ltt_field_member(f
,1);
2380 param1
= ltt_event_get_long_unsigned(e
,element
);
2383 if(sub_id
== 2) { /* fork */
2385 guint child_pid
= param1
;
2386 /* Add process to process list (if not present) */
2387 LttvProcessState
*process_child
;
2389 guint y_child
= 0, height
= 0, pl_height
= 0;
2390 HashedProcessData
*hashed_process_data_child
= NULL
;
2392 ProcessList
*process_list
= control_flow_data
->process_list
;
2394 /* Find child in the list... */
2395 process_child
= lttv_state_find_process(tfs
, child_pid
);
2396 /* It should exist, because we are after the state update. */
2397 g_assert(process_child
!= NULL
);
2399 birth
= process_child
->creation_time
;
2400 const gchar
*name
= g_quark_to_string(process_child
->name
);
2402 if(processlist_get_process_pixels(process_list
,
2404 process_child
->last_cpu
,
2406 tfc
->t_context
->index
,
2409 &hashed_process_data_child
) == 1)
2411 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2412 /* Process not present */
2413 processlist_add(process_list
,
2415 process_child
->last_cpu
,
2416 process_child
->ppid
,
2418 tfc
->t_context
->index
,
2421 &hashed_process_data_child
);
2422 processlist_get_process_pixels(process_list
,
2424 process_child
->last_cpu
,
2426 tfc
->t_context
->index
,
2429 &hashed_process_data_child
);
2430 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2434 convert_time_to_pixels(
2435 time_window
.start_time
,
2436 time_window
.time_width
,
2442 if(hashed_process_data_child
->x
.over
!= new_x
) {
2443 hashed_process_data_child
->x
.over
= new_x
;
2444 hashed_process_data_child
->x
.over_used
= FALSE
;
2445 hashed_process_data_child
->x
.over_marked
= FALSE
;
2447 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2448 hashed_process_data_child
->x
.middle
= new_x
;
2449 hashed_process_data_child
->x
.middle_used
= FALSE
;
2450 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2452 if(hashed_process_data_child
->x
.under
!= new_x
) {
2453 hashed_process_data_child
->x
.under
= new_x
;
2454 hashed_process_data_child
->x
.under_used
= FALSE
;
2455 hashed_process_data_child
->x
.under_marked
= FALSE
;
2458 } else if(sub_id
== 3) { /* exit */
2460 /* Add process to process list (if not present) */
2461 LttvProcessState
*process
= tfs
->process
;
2462 guint pid
= process
->pid
;
2464 guint y
= 0, height
= 0, pl_height
= 0;
2465 HashedProcessData
*hashed_process_data
= NULL
;
2467 ProcessList
*process_list
= control_flow_data
->process_list
;
2469 /* It should exist, because we are after the state update. */
2470 g_assert(process
!= NULL
);
2472 birth
= process
->creation_time
;
2473 const gchar
*name
= g_quark_to_string(process
->name
);
2475 if(processlist_get_process_pixels(process_list
,
2479 tfc
->t_context
->index
,
2482 &hashed_process_data
) == 1)
2484 g_assert(pid
== 0 || pid
!= process
->ppid
);
2485 /* Process not present */
2486 processlist_add(process_list
,
2491 tfc
->t_context
->index
,
2494 &hashed_process_data
);
2495 processlist_get_process_pixels(process_list
,
2499 tfc
->t_context
->index
,
2502 &hashed_process_data
);
2503 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2507 convert_time_to_pixels(
2508 time_window
.start_time
,
2509 time_window
.time_width
,
2514 if(hashed_process_data
->x
.middle
!= new_x
) {
2515 hashed_process_data
->x
.middle
= new_x
;
2516 hashed_process_data
->x
.middle_used
= FALSE
;
2517 hashed_process_data
->x
.middle_marked
= FALSE
;
2527 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2529 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2530 Drawing_t
*drawing
= control_flow_data
->drawing
;
2532 const TimeWindowNotifyData
*time_window_nofify_data
=
2533 ((const TimeWindowNotifyData
*)call_data
);
2535 TimeWindow
*old_time_window
=
2536 time_window_nofify_data
->old_time_window
;
2537 TimeWindow
*new_time_window
=
2538 time_window_nofify_data
->new_time_window
;
2540 /* Update the ruler */
2541 drawing_update_ruler(control_flow_data
->drawing
,
2545 /* Two cases : zoom in/out or scrolling */
2547 /* In order to make sure we can reuse the old drawing, the scale must
2548 * be the same and the new time interval being partly located in the
2549 * currently shown time interval. (reuse is only for scrolling)
2552 g_info("Old time window HOOK : %u, %u to %u, %u",
2553 old_time_window
->start_time
.tv_sec
,
2554 old_time_window
->start_time
.tv_nsec
,
2555 old_time_window
->time_width
.tv_sec
,
2556 old_time_window
->time_width
.tv_nsec
);
2558 g_info("New time window HOOK : %u, %u to %u, %u",
2559 new_time_window
->start_time
.tv_sec
,
2560 new_time_window
->start_time
.tv_nsec
,
2561 new_time_window
->time_width
.tv_sec
,
2562 new_time_window
->time_width
.tv_nsec
);
2564 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2565 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2567 /* Same scale (scrolling) */
2568 g_info("scrolling");
2569 LttTime
*ns
= &new_time_window
->start_time
;
2570 LttTime
*nw
= &new_time_window
->time_width
;
2571 LttTime
*os
= &old_time_window
->start_time
;
2572 LttTime
*ow
= &old_time_window
->time_width
;
2573 LttTime old_end
= old_time_window
->end_time
;
2574 LttTime new_end
= new_time_window
->end_time
;
2576 //if(ns<os+w && os+w<ns+w)
2577 //if(ns<old_end && os<ns)
2578 if(ltt_time_compare(*ns
, old_end
) == -1
2579 && ltt_time_compare(*os
, *ns
) == -1)
2581 g_info("scrolling near right");
2582 /* Scroll right, keep right part of the screen */
2584 guint width
= control_flow_data
->drawing
->width
;
2585 convert_time_to_pixels(
2593 /* Copy old data to new location */
2594 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2595 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2596 control_flow_data
->drawing
->pixmap
,
2599 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2601 if(drawing
->damage_begin
== drawing
->damage_end
)
2602 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2604 drawing
->damage_begin
= 0;
2606 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2608 /* Clear the data request background, but not SAFETY */
2609 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2610 //control_flow_data->drawing->drawing_area->style->black_gc,
2611 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2613 drawing
->damage_begin
+SAFETY
, 0,
2614 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2615 control_flow_data
->drawing
->height
);
2617 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2619 control_flow_data
->drawing
->width
,
2620 control_flow_data
->drawing
->height
);
2622 /* Get new data for the rest. */
2623 drawing_data_request(control_flow_data
->drawing
,
2624 &control_flow_data
->drawing
->pixmap
,
2625 drawing
->damage_begin
, 0,
2626 drawing
->damage_end
- drawing
->damage_begin
,
2627 control_flow_data
->drawing
->height
);
2630 //if(ns<os && os<ns+w)
2631 //if(ns<os && os<new_end)
2632 if(ltt_time_compare(*ns
,*os
) == -1
2633 && ltt_time_compare(*os
,new_end
) == -1)
2635 g_info("scrolling near left");
2636 /* Scroll left, keep left part of the screen */
2638 guint width
= control_flow_data
->drawing
->width
;
2639 convert_time_to_pixels(
2648 /* Copy old data to new location */
2649 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2650 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2651 control_flow_data
->drawing
->pixmap
,
2656 if(drawing
->damage_begin
== drawing
->damage_end
)
2657 drawing
->damage_end
= x
;
2659 drawing
->damage_end
=
2660 control_flow_data
->drawing
->width
;
2662 drawing
->damage_begin
= 0;
2664 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2665 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2667 drawing
->damage_begin
, 0,
2668 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2669 control_flow_data
->drawing
->height
);
2671 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2673 control_flow_data
->drawing
->width
,
2674 control_flow_data
->drawing
->height
);
2677 /* Get new data for the rest. */
2678 drawing_data_request(control_flow_data
->drawing
,
2679 &control_flow_data
->drawing
->pixmap
,
2680 drawing
->damage_begin
, 0,
2681 drawing
->damage_end
- drawing
->damage_begin
,
2682 control_flow_data
->drawing
->height
);
2685 if(ltt_time_compare(*ns
,*os
) == 0)
2687 g_info("not scrolling");
2689 g_info("scrolling far");
2690 /* Cannot reuse any part of the screen : far jump */
2693 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2694 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2697 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2698 control_flow_data
->drawing
->height
);
2700 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2702 control_flow_data
->drawing
->width
,
2703 control_flow_data
->drawing
->height
);
2705 drawing
->damage_begin
= 0;
2706 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2708 drawing_data_request(control_flow_data
->drawing
,
2709 &control_flow_data
->drawing
->pixmap
,
2711 control_flow_data
->drawing
->width
,
2712 control_flow_data
->drawing
->height
);
2718 /* Different scale (zoom) */
2721 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2722 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2725 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2726 control_flow_data
->drawing
->height
);
2728 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2730 control_flow_data
->drawing
->width
,
2731 control_flow_data
->drawing
->height
);
2733 drawing
->damage_begin
= 0;
2734 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2736 drawing_data_request(control_flow_data
->drawing
,
2737 &control_flow_data
->drawing
->pixmap
,
2739 control_flow_data
->drawing
->width
,
2740 control_flow_data
->drawing
->height
);
2748 gint
traceset_notify(void *hook_data
, void *call_data
)
2750 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2751 Drawing_t
*drawing
= control_flow_data
->drawing
;
2752 GtkWidget
*widget
= drawing
->drawing_area
;
2755 drawing_clear(control_flow_data
->drawing
);
2756 processlist_clear(control_flow_data
->process_list
);
2757 redraw_notify(control_flow_data
, NULL
);
2759 request_background_data(control_flow_data
);
2761 drawing
->damage_begin
= 0;
2762 drawing
->damage_end
= drawing
->width
;
2763 if(drawing
->damage_begin
< drawing
->damage_end
)
2765 drawing_data_request(drawing
,
2767 drawing
->damage_begin
,
2769 drawing
->damage_end
-drawing
->damage_begin
,
2773 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2782 gint
redraw_notify(void *hook_data
, void *call_data
)
2784 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2785 Drawing_t
*drawing
= control_flow_data
->drawing
;
2786 GtkWidget
*widget
= drawing
->drawing_area
;
2788 drawing
->damage_begin
= 0;
2789 drawing
->damage_end
= drawing
->width
;
2791 /* fun feature, to be separated someday... */
2792 drawing_clear(control_flow_data
->drawing
);
2793 processlist_clear(control_flow_data
->process_list
);
2796 gdk_draw_rectangle (drawing
->pixmap
,
2797 widget
->style
->black_gc
,
2800 drawing
->width
+SAFETY
,
2804 if(drawing
->damage_begin
< drawing
->damage_end
)
2806 drawing_data_request(drawing
,
2808 drawing
->damage_begin
,
2810 drawing
->damage_end
-drawing
->damage_begin
,
2814 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2823 gint
continue_notify(void *hook_data
, void *call_data
)
2825 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2826 Drawing_t
*drawing
= control_flow_data
->drawing
;
2827 GtkWidget
*widget
= drawing
->drawing_area
;
2829 //g_assert(widget->allocation.width == drawing->damage_end);
2831 if(drawing
->damage_begin
< drawing
->damage_end
)
2833 drawing_data_request(drawing
,
2835 drawing
->damage_begin
,
2837 drawing
->damage_end
-drawing
->damage_begin
,
2845 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2847 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2848 Drawing_t
*drawing
= control_flow_data
->drawing
;
2850 LttTime current_time
= *((LttTime
*)call_data
);
2852 TimeWindow time_window
=
2853 lttvwindow_get_time_window(control_flow_data
->tab
);
2855 LttTime time_begin
= time_window
.start_time
;
2856 LttTime width
= time_window
.time_width
;
2859 guint64 time_ll
= ltt_time_to_uint64(width
);
2860 time_ll
= time_ll
>> 1; /* divide by two */
2861 half_width
= ltt_time_from_uint64(time_ll
);
2863 LttTime time_end
= ltt_time_add(time_begin
, width
);
2865 LttvTracesetContext
* tsc
=
2866 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2868 LttTime trace_start
= tsc
->time_span
.start_time
;
2869 LttTime trace_end
= tsc
->time_span
.end_time
;
2871 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2872 current_time
.tv_nsec
);
2876 /* If current time is inside time interval, just move the highlight
2879 /* Else, we have to change the time interval. We have to tell it
2880 * to the main window. */
2881 /* The time interval change will take care of placing the current
2882 * time at the center of the visible area, or nearest possible if we are
2883 * at one end of the trace. */
2886 if(ltt_time_compare(current_time
, time_begin
) == -1)
2888 TimeWindow new_time_window
;
2890 if(ltt_time_compare(current_time
,
2891 ltt_time_add(trace_start
,half_width
)) == -1)
2892 time_begin
= trace_start
;
2894 time_begin
= ltt_time_sub(current_time
,half_width
);
2896 new_time_window
.start_time
= time_begin
;
2897 new_time_window
.time_width
= width
;
2898 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2900 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2902 else if(ltt_time_compare(current_time
, time_end
) == 1)
2904 TimeWindow new_time_window
;
2906 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2907 time_begin
= ltt_time_sub(trace_end
,width
);
2909 time_begin
= ltt_time_sub(current_time
,half_width
);
2911 new_time_window
.start_time
= time_begin
;
2912 new_time_window
.time_width
= width
;
2913 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2915 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2918 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2919 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2927 typedef struct _ClosureData
{
2928 EventsRequest
*events_request
;
2929 LttvTracesetState
*tss
;
2934 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2936 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2937 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2938 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2940 EventsRequest
*events_request
= closure_data
->events_request
;
2941 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2942 Drawing_t
*drawing
= control_flow_data
->drawing
;
2944 LttvTracesetState
*tss
= closure_data
->tss
;
2945 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2947 LttTime evtime
= closure_data
->end_time
;
2948 TimeWindow time_window
=
2949 lttvwindow_get_time_window(control_flow_data
->tab
);
2951 LttTime end_time
= time_window
.end_time
;
2953 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2954 || ltt_time_compare(evtime
, end_time
) == 1)
2957 guint width
= drawing
->width
;
2960 /* For the process */
2961 /* First, check if the current process is in the state computation
2962 * process list. If it is there, that means we must add it right now and
2963 * draw items from the beginning of the read for it. If it is not
2964 * present, it's a new process and it was not present : it will
2965 * be added after the state update. */
2966 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2968 /* tracefiles[0] is ok here, because we draw for every PID, and
2969 * assume CPU 0 for PID 0 //FIXME */
2970 LttvTracefileState
*tfs
=
2971 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2973 LttvProcessState
*process
;
2974 process
= lttv_state_find_process(tfs
,
2977 if(process
!= NULL
) {
2979 /* Only draw for processes that are currently in the trace states */
2981 guint y
= 0, height
= 0, pl_height
= 0;
2982 ProcessList
*process_list
= control_flow_data
->process_list
;
2983 LttTime birth
= process_info
->birth
;
2985 /* Should be alike when background info is ready */
2986 if(control_flow_data
->background_info_waiting
==0)
2987 g_assert(ltt_time_compare(process
->creation_time
,
2988 process_info
->birth
) == 0);
2989 const gchar
*name
= g_quark_to_string(process
->name
);
2991 /* process HAS to be present */
2992 g_assert(processlist_get_process_pixels(process_list
,
2996 process_info
->trace_num
,
2999 &hashed_process_data
) != 1);
3001 /* Now, the process is in the state hash and our own process hash.
3002 * We definitely can draw the items related to the ending state.
3005 /* Check if the x position is unset. In can have been left unset by
3006 * a draw closure from a after chunk hook. This should never happen,
3007 * because it must be set by before chunk hook to the damage_begin
3010 g_assert(hashed_process_data
->x
.over
!= -1);
3014 convert_time_to_pixels(
3015 time_window
.start_time
,
3016 time_window
.time_width
,
3022 DrawContext draw_context
;
3024 /* Now create the drawing context that will be used to draw
3025 * items related to the last state. */
3026 draw_context
.drawable
= drawing
->pixmap
;
3027 draw_context
.gc
= drawing
->gc
;
3028 draw_context
.pango_layout
= drawing
->pango_layout
;
3029 draw_context
.drawinfo
.end
.x
= x
;
3031 draw_context
.drawinfo
.y
.over
= y
+1;
3032 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3033 draw_context
.drawinfo
.y
.under
= y
+height
;
3035 draw_context
.drawinfo
.start
.offset
.over
= 0;
3036 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3037 draw_context
.drawinfo
.start
.offset
.under
= 0;
3038 draw_context
.drawinfo
.end
.offset
.over
= 0;
3039 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3040 draw_context
.drawinfo
.end
.offset
.under
= 0;
3042 /* Jump over draw if we are at the same x position */
3043 if(x
== hashed_process_data
->x
.over
)
3047 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3049 PropertiesLine prop_line
= prepare_execmode_line(process
);
3050 draw_line((void*)&prop_line
, (void*)&draw_context
);
3052 hashed_process_data
->x
.over
= x
;
3056 if(x
== hashed_process_data
->x
.middle
&&
3057 hashed_process_data
->x
.middle_used
) {
3058 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3059 /* Draw collision indicator */
3060 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3061 gdk_draw_point(drawing
->pixmap
,
3065 hashed_process_data
->x
.middle_marked
= TRUE
;
3069 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3071 PropertiesLine prop_line
= prepare_s_e_line(process
);
3072 draw_line((void*)&prop_line
, (void*)&draw_context
);
3074 /* become the last x position */
3075 if(x
!= hashed_process_data
->x
.middle
) {
3076 hashed_process_data
->x
.middle
= x
;
3077 /* but don't use the pixel */
3078 hashed_process_data
->x
.middle_used
= FALSE
;
3087 int before_chunk(void *hook_data
, void *call_data
)
3089 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3090 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3092 drawing_chunk_begin(events_request
, tss
);
3097 int before_request(void *hook_data
, void *call_data
)
3099 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3100 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3102 drawing_data_request_begin(events_request
, tss
);
3109 * after request is necessary in addition of after chunk in order to draw
3110 * lines until the end of the screen. after chunk just draws lines until
3117 int after_request(void *hook_data
, void *call_data
)
3119 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3120 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3121 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3122 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3124 ProcessList
*process_list
= control_flow_data
->process_list
;
3125 LttTime end_time
= events_request
->end_time
;
3127 ClosureData closure_data
;
3128 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3129 closure_data
.tss
= tss
;
3130 closure_data
.end_time
= end_time
;
3132 /* Draw last items */
3133 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3134 (void*)&closure_data
);
3136 /* Request expose */
3137 drawing_request_expose(events_request
, tss
, end_time
);
3146 int after_chunk(void *hook_data
, void *call_data
)
3148 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3149 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3150 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3151 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3152 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3155 ProcessList
*process_list
= control_flow_data
->process_list
;
3158 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3159 else /* end of traceset, or position now out of request : end */
3160 end_time
= events_request
->end_time
;
3162 ClosureData closure_data
;
3163 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3164 closure_data
.tss
= tss
;
3165 closure_data
.end_time
= end_time
;
3167 /* Draw last items */
3168 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3169 (void*)&closure_data
);
3171 /* Request expose */
3172 drawing_request_expose(events_request
, tss
, end_time
);