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
=
101 guicontrolflow_get_process_list(control_flow_data
);
104 birth
= process
->creation_time
;
105 const gchar
*name
= g_quark_to_string(process
->name
);
106 HashedProcessData
*hashed_process_data
= NULL
;
108 if(processlist_get_process_pixels(process_list
,
114 &hashed_process_data
) == 1)
116 /* Process not present */
117 processlist_add(process_list
,
123 &hashed_process_data
);
124 processlist_get_process_pixels(process_list
,
130 &hashed_process_data
);
131 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
137 /* Action to do when background computation completed.
139 * Wait for all the awaited computations to be over.
142 gint
background_ready(void *hook_data
, void *call_data
)
144 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
145 LttvTrace
*trace
= (LttvTrace
*)call_data
;
146 LttvTracesetContext
*tsc
=
147 lttvwindow_get_traceset_context(control_flow_data
->tab
);
149 control_flow_data
->background_info_waiting
--;
151 if(control_flow_data
->background_info_waiting
== 0) {
152 g_debug("control flow viewer : background computation data ready.");
154 drawing_clear(control_flow_data
->drawing
);
155 processlist_clear(control_flow_data
->process_list
);
156 redraw_notify(control_flow_data
, NULL
);
163 /* Request background computation. Verify if it is in progress or ready first.
164 * Only for each trace in the tab's traceset.
166 void request_background_data(ControlFlowData
*control_flow_data
)
168 LttvTracesetContext
* tsc
=
169 lttvwindow_get_traceset_context(control_flow_data
->tab
);
170 gint num_traces
= lttv_traceset_number(tsc
->ts
);
174 LttvHooks
*background_ready_hook
=
176 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
178 control_flow_data
->background_info_waiting
= 0;
180 for(i
=0;i
<num_traces
;i
++) {
181 trace
= lttv_traceset_get(tsc
->ts
, i
);
183 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
185 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
187 /* We first remove requests that could have been done for the same
188 * information. Happens when two viewers ask for it before servicing
191 lttvwindowtraces_background_request_remove(trace
, "state");
192 lttvwindowtraces_background_request_queue(trace
,
194 lttvwindowtraces_background_notify_queue(control_flow_data
,
198 background_ready_hook
);
199 control_flow_data
->background_info_waiting
++;
200 } else { /* in progress */
202 lttvwindowtraces_background_notify_current(control_flow_data
,
206 background_ready_hook
);
207 control_flow_data
->background_info_waiting
++;
210 /* Data ready. Be its nature, this viewer doesn't need to have
211 * its data ready hook called htere, because a background
212 * request is always linked with a redraw.
218 lttv_hooks_destroy(background_ready_hook
);
225 * Event Viewer's constructor hook
227 * This constructor is given as a parameter to the menuitem and toolbar button
228 * registration. It creates the list.
229 * @param tab A pointer to the parent tab.
230 * @return The widget created.
233 h_guicontrolflow(Tab
*tab
)
235 g_info("h_guicontrolflow, %p", tab
);
236 ControlFlowData
*control_flow_data
= guicontrolflow() ;
238 control_flow_data
->tab
= tab
;
240 //g_debug("time width2 : %u",time_window->time_width);
241 // Unreg done in the GuiControlFlow_Destructor
242 lttvwindow_register_traceset_notify(tab
,
246 lttvwindow_register_time_window_notify(tab
,
247 update_time_window_hook
,
249 lttvwindow_register_current_time_notify(tab
,
250 update_current_time_hook
,
252 lttvwindow_register_redraw_notify(tab
,
255 lttvwindow_register_continue_notify(tab
,
258 request_background_data(control_flow_data
);
261 return guicontrolflow_get_widget(control_flow_data
) ;
265 int event_selected_hook(void *hook_data
, void *call_data
)
267 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
268 guint
*event_number
= (guint
*) call_data
;
270 g_debug("DEBUG : event selected by main window : %u", *event_number
);
274 /* Function that selects the color of status&exemode line */
275 static __inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
277 PropertiesLine prop_line
;
278 prop_line
.line_width
= 2;
279 prop_line
.style
= GDK_LINE_SOLID
;
280 prop_line
.y
= MIDDLE
;
281 //GdkColormap *colormap = gdk_colormap_get_system();
283 g_debug("prepare_status_line for state : %s",
284 g_quark_to_string(process
->state
->s
));
286 if(process
->state
->s
== LTTV_STATE_RUN
) {
287 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
288 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
289 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
290 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
291 else if(process
->state
->t
== LTTV_STATE_TRAP
)
292 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
293 else if(process
->state
->t
== LTTV_STATE_IRQ
)
294 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
295 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
296 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
298 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
299 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
300 /* We don't show if we wait while in user mode, trap, irq or syscall */
301 prop_line
.color
= drawing_colors
[COL_WAIT
];
302 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
303 /* We don't show if we wait for CPU while in user mode, trap, irq
305 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
306 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
307 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
308 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
309 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
310 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
311 prop_line
.color
= drawing_colors
[COL_EXIT
];
312 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
313 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
315 g_assert(FALSE
); /* UNKNOWN STATE */
322 static __inline PropertiesLine
prepare_status_line(LttvProcessState
*process
)
324 PropertiesLine prop_line
;
325 prop_line
.line_width
= 2;
326 prop_line
.style
= GDK_LINE_SOLID
;
327 prop_line
.y
= MIDDLE
;
328 //GdkColormap *colormap = gdk_colormap_get_system();
330 g_debug("prepare_status_line for state : %s",
331 g_quark_to_string(process
->state
->s
));
333 /* color of line : status of the process */
334 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
335 prop_line
.color
= drawing_colors
[COL_WHITE
];
336 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
337 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
338 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
339 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
340 else if(process
->state
->s
== LTTV_STATE_EXIT
)
341 prop_line
.color
= drawing_colors
[COL_EXIT
];
342 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
343 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
344 else if(process
->state
->s
== LTTV_STATE_WAIT
)
345 prop_line
.color
= drawing_colors
[COL_WAIT
];
346 else if(process
->state
->s
== LTTV_STATE_RUN
)
347 prop_line
.color
= drawing_colors
[COL_RUN
];
349 prop_line
.color
= drawing_colors
[COL_WHITE
];
351 //gdk_colormap_alloc_color(colormap,
362 /* before_schedchange_hook
364 * This function basically draw lines and icons. Two types of lines are drawn :
365 * one small (3 pixels?) representing the state of the process and the second
366 * type is thicker (10 pixels?) representing on which CPU a process is running
367 * (and this only in running state).
369 * Extremums of the lines :
370 * x_min : time of the last event context for this process kept in memory.
371 * x_max : time of the current event.
372 * y : middle of the process in the process list. The process is found in the
373 * list, therefore is it's position in pixels.
375 * The choice of lines'color is defined by the context of the last event for this
380 int before_schedchange_hook(void *hook_data
, void *call_data
)
382 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
383 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
384 Drawing_t
*drawing
= control_flow_data
->drawing
;
386 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
388 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
389 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
394 LttTime evtime
= ltt_event_time(e
);
395 TimeWindow time_window
=
396 lttvwindow_get_time_window(control_flow_data
->tab
);
398 LttTime end_time
= ltt_time_add(time_window
.start_time
,
399 time_window
.time_width
);
401 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
402 || ltt_time_compare(evtime
, end_time
) == 1)
404 guint width
= drawing
->width
;
406 /* we are in a schedchange, before the state update. We must draw the
407 * items corresponding to the state before it changes : now is the right
414 LttField
*f
= ltt_event_field(e
);
416 element
= ltt_field_member(f
,0);
417 pid_out
= ltt_event_get_long_unsigned(e
,element
);
418 element
= ltt_field_member(f
,1);
419 pid_in
= ltt_event_get_long_unsigned(e
,element
);
420 g_debug("out : %u in : %u", pid_out
, pid_in
);
424 /* For the pid_out */
425 /* First, check if the current process is in the state computation
426 * process list. If it is there, that means we must add it right now and
427 * draw items from the beginning of the read for it. If it is not
428 * present, it's a new process and it was not present : it will
429 * be added after the state update. */
430 LttvProcessState
*process
;
431 process
= lttv_state_find_process(tfs
, pid_out
);
433 if(process
!= NULL
) {
434 /* Well, the process_out existed : we must get it in the process hash
435 * or add it, and draw its items.
437 /* Add process to process list (if not present) */
438 guint y
= 0, height
= 0, pl_height
= 0;
439 HashedProcessData
*hashed_process_data
= NULL
;
440 ProcessList
*process_list
=
441 guicontrolflow_get_process_list(control_flow_data
);
442 LttTime birth
= process
->creation_time
;
443 const gchar
*name
= g_quark_to_string(process
->name
);
445 if(processlist_get_process_pixels(process_list
,
449 tfc
->t_context
->index
,
452 &hashed_process_data
) == 1)
454 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
455 /* Process not present */
456 processlist_add(process_list
,
461 tfc
->t_context
->index
,
464 &hashed_process_data
);
465 processlist_get_process_pixels(process_list
,
469 tfc
->t_context
->index
,
472 &hashed_process_data
);
473 drawing_insert_square( drawing
, y
, height
);
476 /* Now, the process is in the state hash and our own process hash.
477 * We definitely can draw the items related to the ending state.
480 /* Check if the x position is unset. In can have been left unset by
481 * a draw closure from a after chunk hook. This should never happen,
482 * because it must be set by before chunk hook to the damage_begin
485 g_assert(hashed_process_data
->x
.middle
!= -1);
488 convert_time_to_pixels(
489 time_window
.start_time
,
496 /* Jump over draw if we are at the same x position */
497 if(x
== hashed_process_data
->x
.middle
&&
498 hashed_process_data
->x
.middle_used
)
500 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
501 /* Draw collision indicator */
502 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
503 gdk_draw_point(drawing
->pixmap
,
507 hashed_process_data
->x
.middle_marked
= TRUE
;
511 DrawContext draw_context
;
513 /* Now create the drawing context that will be used to draw
514 * items related to the last state. */
515 draw_context
.drawable
= drawing
->pixmap
;
516 draw_context
.gc
= drawing
->gc
;
517 draw_context
.pango_layout
= drawing
->pango_layout
;
518 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
519 draw_context
.drawinfo
.end
.x
= x
;
521 draw_context
.drawinfo
.y
.over
= y
+1;
522 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
523 draw_context
.drawinfo
.y
.under
= y
+height
;
525 draw_context
.drawinfo
.start
.offset
.over
= 0;
526 draw_context
.drawinfo
.start
.offset
.middle
= 0;
527 draw_context
.drawinfo
.start
.offset
.under
= 0;
528 draw_context
.drawinfo
.end
.offset
.over
= 0;
529 draw_context
.drawinfo
.end
.offset
.middle
= 0;
530 draw_context
.drawinfo
.end
.offset
.under
= 0;
534 PropertiesLine prop_line
= prepare_s_e_line(process
);
535 draw_line((void*)&prop_line
, (void*)&draw_context
);
538 /* become the last x position */
539 hashed_process_data
->x
.middle
= x
;
540 hashed_process_data
->x
.middle_used
= TRUE
;
541 hashed_process_data
->x
.middle_marked
= FALSE
;
549 /* First, check if the current process is in the state computation
550 * process list. If it is there, that means we must add it right now and
551 * draw items from the beginning of the read for it. If it is not
552 * present, it's a new process and it was not present : it will
553 * be added after the state update. */
554 LttvProcessState
*process
;
555 process
= lttv_state_find_process(tfs
, pid_in
);
557 if(process
!= NULL
) {
558 /* Well, the process_out existed : we must get it in the process hash
559 * or add it, and draw its items.
561 /* Add process to process list (if not present) */
562 guint y
= 0, height
= 0, pl_height
= 0;
563 HashedProcessData
*hashed_process_data
= NULL
;
564 ProcessList
*process_list
=
565 guicontrolflow_get_process_list(control_flow_data
);
566 LttTime birth
= process
->creation_time
;
567 const gchar
*name
= g_quark_to_string(process
->name
);
569 if(processlist_get_process_pixels(process_list
,
573 tfc
->t_context
->index
,
576 &hashed_process_data
) == 1)
578 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
579 /* Process not present */
580 processlist_add(process_list
,
585 tfc
->t_context
->index
,
588 &hashed_process_data
);
589 processlist_get_process_pixels(process_list
,
593 tfc
->t_context
->index
,
596 &hashed_process_data
);
597 drawing_insert_square( drawing
, y
, height
);
600 /* Now, the process is in the state hash and our own process hash.
601 * We definitely can draw the items related to the ending state.
604 /* Check if the x position is unset. In can have been left unset by
605 * a draw closure from a after chunk hook. This should never happen,
606 * because it must be set by before chunk hook to the damage_begin
609 g_assert(hashed_process_data
->x
.middle
!= -1);
613 convert_time_to_pixels(
614 time_window
.start_time
,
621 /* Jump over draw if we are at the same x position */
622 if(x
== hashed_process_data
->x
.middle
&&
623 hashed_process_data
->x
.middle_used
)
625 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
626 /* Draw collision indicator */
627 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
628 gdk_draw_point(drawing
->pixmap
,
632 hashed_process_data
->x
.middle_marked
= TRUE
;
636 DrawContext draw_context
;
638 /* Now create the drawing context that will be used to draw
639 * items related to the last state. */
640 draw_context
.drawable
= drawing
->pixmap
;
641 draw_context
.gc
= drawing
->gc
;
642 draw_context
.pango_layout
= drawing
->pango_layout
;
643 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
644 draw_context
.drawinfo
.end
.x
= x
;
646 draw_context
.drawinfo
.y
.over
= y
+1;
647 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
648 draw_context
.drawinfo
.y
.under
= y
+height
;
650 draw_context
.drawinfo
.start
.offset
.over
= 0;
651 draw_context
.drawinfo
.start
.offset
.middle
= 0;
652 draw_context
.drawinfo
.start
.offset
.under
= 0;
653 draw_context
.drawinfo
.end
.offset
.over
= 0;
654 draw_context
.drawinfo
.end
.offset
.middle
= 0;
655 draw_context
.drawinfo
.end
.offset
.under
= 0;
659 PropertiesLine prop_line
= prepare_s_e_line(process
);
660 draw_line((void*)&prop_line
, (void*)&draw_context
);
664 /* become the last x position */
665 hashed_process_data
->x
.middle
= x
;
666 hashed_process_data
->x
.middle_used
= TRUE
;
667 hashed_process_data
->x
.middle_marked
= FALSE
;
676 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
677 ControlFlowData
*control_flow_data
=
678 (ControlFlowData
*)events_request
->viewer_data
;
679 Tab
*tab
= control_flow_data
->tab
;
681 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
683 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
684 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
689 LttTime evtime
= ltt_event_time(e
);
690 TimeWindow time_window
=
691 lttvwindow_get_time_window(tab
);
693 LttTime end_time
= ltt_time_add(time_window
.start_time
,
694 time_window
.time_width
);
695 //if(time < time_beg || time > time_end) return;
696 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
697 || ltt_time_compare(evtime
, end_time
) == 1)
700 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
702 g_debug("schedchange!");
704 /* Add process to process list (if not present) and get drawing "y" from
705 * process position */
706 guint pid_out
, pid_in
;
707 LttvProcessState
*process_out
, *process_in
;
709 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
711 ProcessList
*process_list
=
712 guicontrolflow_get_process_list(control_flow_data
);
715 LttField
*f
= ltt_event_field(e
);
717 element
= ltt_field_member(f
,0);
718 pid_out
= ltt_event_get_long_unsigned(e
,element
);
719 element
= ltt_field_member(f
,1);
720 pid_in
= ltt_event_get_long_unsigned(e
,element
);
721 g_debug("out : %u in : %u", pid_out
, pid_in
);
724 /* Find process pid_out in the list... */
725 process_out
= lttv_state_find_process(tfs
, pid_out
);
726 if(process_out
== NULL
) return 0;
727 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
729 birth
= process_out
->creation_time
;
730 const gchar
*name
= g_quark_to_string(process_out
->name
);
731 HashedProcessData
*hashed_process_data_out
= NULL
;
733 if(processlist_get_process_pixels(process_list
,
736 tfc
->t_context
->index
,
739 &hashed_process_data_out
) == 1)
741 /* Process not present */
742 processlist_add(process_list
,
745 tfc
->t_context
->index
,
748 &hashed_process_data_out
);
749 g_assert(processlist_get_process_pixels(process_list
,
752 tfc
->t_context
->index
,
755 &hashed_process_data_out
)==0);
756 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
760 /* Find process pid_in in the list... */
761 process_in
= lttv_state_find_process(tfs
, pid_in
);
762 if(process_in
== NULL
) return 0;
763 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
765 birth
= process_in
->creation_time
;
766 name
= g_quark_to_string(process_in
->name
);
767 HashedProcessData
*hashed_process_data_in
= NULL
;
769 if(processlist_get_process_pixels(process_list
,
772 tfc
->t_context
->index
,
775 &hashed_process_data_in
) == 1)
777 /* Process not present */
778 processlist_add(process_list
,
781 tfc
->t_context
->index
,
784 &hashed_process_data_in
);
785 processlist_get_process_pixels(process_list
,
788 tfc
->t_context
->index
,
791 &hashed_process_data_in
);
793 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
798 /* Find pixels corresponding to time of the event. If the time does
799 * not fit in the window, show a warning, not supposed to happend. */
801 guint width
= control_flow_data
->drawing
->width
;
803 LttTime time
= ltt_event_time(e
);
805 LttTime window_end
= ltt_time_add(time_window
.time_width
,
806 time_window
.start_time
);
809 convert_time_to_pixels(
810 time_window
.start_time
,
815 //assert(x <= width);
817 /* draw what represents the event for outgoing process. */
819 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
820 draw_context_out
->current
->modify_over
->x
= x
;
821 draw_context_out
->current
->modify_under
->x
= x
;
822 draw_context_out
->current
->modify_over
->y
= y_out
;
823 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
824 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
825 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
826 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
827 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
828 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
829 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
830 //draw_context_out->gc = widget->style->black_gc;
832 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
833 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
835 /* Draw the line/background of the out process */
836 if(draw_context_out
->previous
->middle
->x
== -1)
838 draw_context_out
->previous
->over
->x
=
839 control_flow_data
->drawing
->damage_begin
;
840 draw_context_out
->previous
->middle
->x
=
841 control_flow_data
->drawing
->damage_begin
;
842 draw_context_out
->previous
->under
->x
=
843 control_flow_data
->drawing
->damage_begin
;
845 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
848 draw_context_out
->current
->middle
->x
= x
;
849 draw_context_out
->current
->over
->x
= x
;
850 draw_context_out
->current
->under
->x
= x
;
851 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
852 draw_context_out
->current
->over
->y
= y_out
;
853 draw_context_out
->current
->under
->y
= y_out
+ height
;
854 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
855 draw_context_out
->previous
->over
->y
= y_out
;
856 draw_context_out
->previous
->under
->y
= y_out
+ height
;
858 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
859 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
861 if(process_out
->state
->s
== LTTV_STATE_RUN
)
863 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
864 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
865 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
867 PropertiesBG prop_bg
;
868 prop_bg
.color
= g_new(GdkColor
,1);
872 prop_bg
.color
->red
= 0x1515;
873 prop_bg
.color
->green
= 0x1515;
874 prop_bg
.color
->blue
= 0x8c8c;
877 prop_bg
.color
->red
= 0x4e4e;
878 prop_bg
.color
->green
= 0xa9a9;
879 prop_bg
.color
->blue
= 0xa4a4;
882 prop_bg
.color
->red
= 0x7a7a;
883 prop_bg
.color
->green
= 0x4a4a;
884 prop_bg
.color
->blue
= 0x8b8b;
887 prop_bg
.color
->red
= 0x8080;
888 prop_bg
.color
->green
= 0x7777;
889 prop_bg
.color
->blue
= 0x4747;
892 prop_bg
.color
->red
= 0xe7e7;
893 prop_bg
.color
->green
= 0xe7e7;
894 prop_bg
.color
->blue
= 0xe7e7;
897 g_debug("calling from draw_event");
898 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
899 g_free(prop_bg
.color
);
900 //gdk_gc_unref(draw_context_out->gc);
903 draw_context_out
->gc
= widget
->style
->black_gc
;
905 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
906 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
907 PropertiesText prop_text_out
;
908 prop_text_out
.foreground
= &colorfg_out
;
909 prop_text_out
.background
= &colorbg_out
;
910 prop_text_out
.size
= 6;
911 prop_text_out
.position
= OVER
;
913 /* color of text : status of the process */
914 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
916 prop_text_out
.foreground
->red
= 0xffff;
917 prop_text_out
.foreground
->green
= 0xffff;
918 prop_text_out
.foreground
->blue
= 0xffff;
920 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
922 prop_text_out
.foreground
->red
= 0x0fff;
923 prop_text_out
.foreground
->green
= 0xffff;
924 prop_text_out
.foreground
->blue
= 0xfff0;
926 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
928 prop_text_out
.foreground
->red
= 0xffff;
929 prop_text_out
.foreground
->green
= 0xffff;
930 prop_text_out
.foreground
->blue
= 0x0000;
932 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
934 prop_text_out
.foreground
->red
= 0xffff;
935 prop_text_out
.foreground
->green
= 0x0000;
936 prop_text_out
.foreground
->blue
= 0xffff;
938 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
940 prop_text_out
.foreground
->red
= 0xffff;
941 prop_text_out
.foreground
->green
= 0x0000;
942 prop_text_out
.foreground
->blue
= 0x0000;
944 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
946 prop_text_out
.foreground
->red
= 0x0000;
947 prop_text_out
.foreground
->green
= 0xffff;
948 prop_text_out
.foreground
->blue
= 0x0000;
952 prop_text_out
.foreground
->red
= 0xffff;
953 prop_text_out
.foreground
->green
= 0xffff;
954 prop_text_out
.foreground
->blue
= 0xffff;
958 /* Print status of the process : U, WF, WC, E, W, R */
959 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
960 prop_text_out
.text
= "U->";
961 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
962 prop_text_out
.text
= "WF->";
963 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
964 prop_text_out
.text
= "WC->";
965 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
966 prop_text_out
.text
= "E->";
967 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
968 prop_text_out
.text
= "W->";
969 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
970 prop_text_out
.text
= "R->";
972 prop_text_out
.text
= "U";
974 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
975 //gdk_gc_unref(draw_context_out->gc);
977 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
978 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
979 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
981 PropertiesLine prop_line_out
;
982 prop_line_out
.color
= g_new(GdkColor
,1);
983 prop_line_out
.line_width
= 2;
984 prop_line_out
.style
= GDK_LINE_SOLID
;
985 prop_line_out
.position
= MIDDLE
;
987 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
989 /* color of line : status of the process */
990 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
992 prop_line_out
.color
->red
= 0xffff;
993 prop_line_out
.color
->green
= 0xffff;
994 prop_line_out
.color
->blue
= 0xffff;
996 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
998 prop_line_out
.color
->red
= 0x0fff;
999 prop_line_out
.color
->green
= 0xffff;
1000 prop_line_out
.color
->blue
= 0xfff0;
1002 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1004 prop_line_out
.color
->red
= 0xffff;
1005 prop_line_out
.color
->green
= 0xffff;
1006 prop_line_out
.color
->blue
= 0x0000;
1008 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1010 prop_line_out
.color
->red
= 0xffff;
1011 prop_line_out
.color
->green
= 0x0000;
1012 prop_line_out
.color
->blue
= 0xffff;
1014 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1016 prop_line_out
.color
->red
= 0xffff;
1017 prop_line_out
.color
->green
= 0x0000;
1018 prop_line_out
.color
->blue
= 0x0000;
1020 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1022 prop_line_out
.color
->red
= 0x0000;
1023 prop_line_out
.color
->green
= 0xffff;
1024 prop_line_out
.color
->blue
= 0x0000;
1028 prop_line_out
.color
->red
= 0xffff;
1029 prop_line_out
.color
->green
= 0xffff;
1030 prop_line_out
.color
->blue
= 0xffff;
1033 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1034 g_free(prop_line_out
.color
);
1035 //gdk_gc_unref(draw_context_out->gc);
1036 /* Note : finishing line will have to be added when trace read over. */
1038 /* Finally, update the drawing context of the pid_in. */
1040 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1041 draw_context_in
->current
->modify_over
->x
= x
;
1042 draw_context_in
->current
->modify_under
->x
= x
;
1043 draw_context_in
->current
->modify_over
->y
= y_in
;
1044 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1045 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1046 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1047 widget
= control_flow_data
->drawing
->drawing_area
;
1048 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1049 //draw_context_in->gc = widget->style->black_gc;
1050 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1051 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1053 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1054 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1056 /* Draw the line/bg of the in process */
1057 if(draw_context_in
->previous
->middle
->x
== -1)
1059 draw_context_in
->previous
->over
->x
=
1060 control_flow_data
->drawing
->damage_begin
;
1061 draw_context_in
->previous
->middle
->x
=
1062 control_flow_data
->drawing
->damage_begin
;
1063 draw_context_in
->previous
->under
->x
=
1064 control_flow_data
->drawing
->damage_begin
;
1066 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1070 draw_context_in
->current
->middle
->x
= x
;
1071 draw_context_in
->current
->over
->x
= x
;
1072 draw_context_in
->current
->under
->x
= x
;
1073 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1074 draw_context_in
->current
->over
->y
= y_in
;
1075 draw_context_in
->current
->under
->y
= y_in
+ height
;
1076 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1077 draw_context_in
->previous
->over
->y
= y_in
;
1078 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1080 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1081 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1084 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1086 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1087 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1088 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1090 PropertiesBG prop_bg
;
1091 prop_bg
.color
= g_new(GdkColor
,1);
1093 switch(tfc
->index
) {
1095 prop_bg
.color
->red
= 0x1515;
1096 prop_bg
.color
->green
= 0x1515;
1097 prop_bg
.color
->blue
= 0x8c8c;
1100 prop_bg
.color
->red
= 0x4e4e;
1101 prop_bg
.color
->green
= 0xa9a9;
1102 prop_bg
.color
->blue
= 0xa4a4;
1105 prop_bg
.color
->red
= 0x7a7a;
1106 prop_bg
.color
->green
= 0x4a4a;
1107 prop_bg
.color
->blue
= 0x8b8b;
1110 prop_bg
.color
->red
= 0x8080;
1111 prop_bg
.color
->green
= 0x7777;
1112 prop_bg
.color
->blue
= 0x4747;
1115 prop_bg
.color
->red
= 0xe7e7;
1116 prop_bg
.color
->green
= 0xe7e7;
1117 prop_bg
.color
->blue
= 0xe7e7;
1121 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1122 g_free(prop_bg
.color
);
1123 //gdk_gc_unref(draw_context_in->gc);
1126 draw_context_in
->gc
= widget
->style
->black_gc
;
1128 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1129 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1130 PropertiesText prop_text_in
;
1131 prop_text_in
.foreground
= &colorfg_in
;
1132 prop_text_in
.background
= &colorbg_in
;
1133 prop_text_in
.size
= 6;
1134 prop_text_in
.position
= OVER
;
1136 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1137 /* foreground of text : status of the process */
1138 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1140 prop_text_in
.foreground
->red
= 0xffff;
1141 prop_text_in
.foreground
->green
= 0xffff;
1142 prop_text_in
.foreground
->blue
= 0xffff;
1144 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1146 prop_text_in
.foreground
->red
= 0x0fff;
1147 prop_text_in
.foreground
->green
= 0xffff;
1148 prop_text_in
.foreground
->blue
= 0xfff0;
1150 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1152 prop_text_in
.foreground
->red
= 0xffff;
1153 prop_text_in
.foreground
->green
= 0xffff;
1154 prop_text_in
.foreground
->blue
= 0x0000;
1156 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1158 prop_text_in
.foreground
->red
= 0xffff;
1159 prop_text_in
.foreground
->green
= 0x0000;
1160 prop_text_in
.foreground
->blue
= 0xffff;
1162 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1164 prop_text_in
.foreground
->red
= 0xffff;
1165 prop_text_in
.foreground
->green
= 0x0000;
1166 prop_text_in
.foreground
->blue
= 0x0000;
1168 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1170 prop_text_in
.foreground
->red
= 0x0000;
1171 prop_text_in
.foreground
->green
= 0xffff;
1172 prop_text_in
.foreground
->blue
= 0x0000;
1176 prop_text_in
.foreground
->red
= 0xffff;
1177 prop_text_in
.foreground
->green
= 0xffff;
1178 prop_text_in
.foreground
->blue
= 0xffff;
1183 /* Print status of the process : U, WF, WC, E, W, R */
1184 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1185 prop_text_in
.text
= "U->";
1186 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1187 prop_text_in
.text
= "WF->";
1188 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1189 prop_text_in
.text
= "WC->";
1190 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1191 prop_text_in
.text
= "E->";
1192 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1193 prop_text_in
.text
= "W->";
1194 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1195 prop_text_in
.text
= "R->";
1197 prop_text_in
.text
= "U";
1199 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1200 //gdk_gc_unref(draw_context_in->gc);
1202 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1203 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1204 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1206 PropertiesLine prop_line_in
;
1207 prop_line_in
.color
= g_new(GdkColor
,1);
1208 prop_line_in
.line_width
= 2;
1209 prop_line_in
.style
= GDK_LINE_SOLID
;
1210 prop_line_in
.position
= MIDDLE
;
1212 /* color of line : status of the process */
1213 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1215 prop_line_in
.color
->red
= 0xffff;
1216 prop_line_in
.color
->green
= 0xffff;
1217 prop_line_in
.color
->blue
= 0xffff;
1219 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1221 prop_line_in
.color
->red
= 0x0fff;
1222 prop_line_in
.color
->green
= 0xffff;
1223 prop_line_in
.color
->blue
= 0xfff0;
1225 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1227 prop_line_in
.color
->red
= 0xffff;
1228 prop_line_in
.color
->green
= 0xffff;
1229 prop_line_in
.color
->blue
= 0x0000;
1231 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1233 prop_line_in
.color
->red
= 0xffff;
1234 prop_line_in
.color
->green
= 0x0000;
1235 prop_line_in
.color
->blue
= 0xffff;
1237 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1239 prop_line_in
.color
->red
= 0xffff;
1240 prop_line_in
.color
->green
= 0x0000;
1241 prop_line_in
.color
->blue
= 0x0000;
1243 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1245 prop_line_in
.color
->red
= 0x0000;
1246 prop_line_in
.color
->green
= 0xffff;
1247 prop_line_in
.color
->blue
= 0x0000;
1251 prop_line_in
.color
->red
= 0xffff;
1252 prop_line_in
.color
->green
= 0xffff;
1253 prop_line_in
.color
->blue
= 0xffff;
1256 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1257 g_free(prop_line_in
.color
);
1258 //gdk_gc_unref(draw_context_in->gc);
1268 GString
*string
= g_string_new("");;
1269 gboolean field_names
= TRUE
, state
= TRUE
;
1271 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1272 g_string_append_printf(string
,"\n");
1275 g_string_append_printf(string
, " %s",
1276 g_quark_to_string(tfs
->process
->state
->s
));
1279 g_info("%s",string
->str
);
1281 g_string_free(string
, TRUE
);
1283 /* End of text dump */
1288 /* after_schedchange_hook
1290 * The draw after hook is called by the reading API to have a
1291 * particular event drawn on the screen.
1292 * @param hook_data ControlFlowData structure of the viewer.
1293 * @param call_data Event context.
1295 * This function adds items to be drawn in a queue for each process.
1298 int after_schedchange_hook(void *hook_data
, void *call_data
)
1300 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1301 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1303 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1305 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1306 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1311 LttTime evtime
= ltt_event_time(e
);
1312 TimeWindow time_window
=
1313 lttvwindow_get_time_window(control_flow_data
->tab
);
1315 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1316 time_window
.time_width
);
1318 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1319 || ltt_time_compare(evtime
, end_time
) == 1)
1322 guint width
= control_flow_data
->drawing
->width
;
1324 /* Add process to process list (if not present) */
1325 LttvProcessState
*process_out
, *process_in
;
1327 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1328 HashedProcessData
*hashed_process_data_in
= NULL
;
1330 ProcessList
*process_list
=
1331 guicontrolflow_get_process_list(control_flow_data
);
1336 LttField
*f
= ltt_event_field(e
);
1338 element
= ltt_field_member(f
,0);
1339 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1340 element
= ltt_field_member(f
,1);
1341 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1342 g_debug("out : %u in : %u", pid_out
, pid_in
);
1346 /* Find process pid_in in the list... */
1347 process_in
= lttv_state_find_process(tfs
, pid_in
);
1348 /* It should exist, because we are after the state update. */
1349 g_assert(process_in
!= NULL
);
1351 birth
= process_in
->creation_time
;
1352 const gchar
*name
= g_quark_to_string(process_in
->name
);
1354 if(processlist_get_process_pixels(process_list
,
1356 process_in
->last_cpu
,
1358 tfc
->t_context
->index
,
1361 &hashed_process_data_in
) == 1)
1363 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1364 /* Process not present */
1365 processlist_add(process_list
,
1367 process_in
->last_cpu
,
1370 tfc
->t_context
->index
,
1373 &hashed_process_data_in
);
1374 processlist_get_process_pixels(process_list
,
1376 process_in
->last_cpu
,
1378 tfc
->t_context
->index
,
1381 &hashed_process_data_in
);
1382 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1387 convert_time_to_pixels(
1388 time_window
.start_time
,
1394 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1395 hashed_process_data_in
->x
.middle
= new_x
;
1396 hashed_process_data_in
->x
.middle_used
= FALSE
;
1397 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1407 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1408 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1410 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1412 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1413 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1419 LttTime evtime
= ltt_event_time(e
);
1420 TimeWindow time_window
=
1421 lttvwindow_get_time_window(control_flow_data
->tab
);
1423 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1424 time_window
.time_width
);
1425 //if(time < time_beg || time > time_end) return;
1426 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1427 || ltt_time_compare(evtime
, end_time
) == 1)
1431 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1433 g_debug("schedchange!");
1435 /* Add process to process list (if not present) and get drawing "y" from
1436 * process position */
1437 guint pid_out
, pid_in
;
1438 LttvProcessState
*process_out
, *process_in
;
1440 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1442 ProcessList
*process_list
=
1443 guicontrolflow_get_process_list(control_flow_data
);
1446 LttField
*f
= ltt_event_field(e
);
1448 element
= ltt_field_member(f
,0);
1449 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1450 element
= ltt_field_member(f
,1);
1451 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1452 //g_debug("out : %u in : %u", pid_out, pid_in);
1455 /* Find process pid_out in the list... */
1456 process_out
= lttv_state_find_process(tfs
, pid_out
);
1457 if(process_out
== NULL
) return 0;
1458 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1460 birth
= process_out
->creation_time
;
1461 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1462 HashedProcessData
*hashed_process_data_out
= NULL
;
1464 if(processlist_get_process_pixels(process_list
,
1467 tfc
->t_context
->index
,
1470 &hashed_process_data_out
) == 1)
1472 /* Process not present */
1473 processlist_add(process_list
,
1476 tfc
->t_context
->index
,
1479 &hashed_process_data_out
);
1480 processlist_get_process_pixels(process_list
,
1483 tfc
->t_context
->index
,
1486 &hashed_process_data_out
);
1487 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1492 /* Find process pid_in in the list... */
1493 process_in
= lttv_state_find_process(tfs
, pid_in
);
1494 if(process_in
== NULL
) return 0;
1495 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1497 birth
= process_in
->creation_time
;
1498 name
= strdup(g_quark_to_string(process_in
->name
));
1499 HashedProcessData
*hashed_process_data_in
= NULL
;
1501 if(processlist_get_process_pixels(process_list
,
1504 tfc
->t_context
->index
,
1507 &hashed_process_data_in
) == 1)
1509 /* Process not present */
1510 processlist_add(process_list
,
1513 tfc
->t_context
->index
,
1516 &hashed_process_data_in
);
1517 processlist_get_process_pixels(process_list
,
1520 tfc
->t_context
->index
,
1523 &hashed_process_data_in
);
1525 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1530 /* Find pixels corresponding to time of the event. If the time does
1531 * not fit in the window, show a warning, not supposed to happend. */
1533 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1535 //LttTime time = ltt_event_time(e);
1537 //LttTime window_end = ltt_time_add(time_window->time_width,
1538 // time_window->start_time);
1541 //convert_time_to_pixels(
1542 // time_window->start_time,
1548 //assert(x <= width);
1550 /* draw what represents the event for outgoing process. */
1552 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1553 //draw_context_out->current->modify_over->x = x;
1554 draw_context_out
->current
->modify_over
->y
= y_out
;
1555 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1556 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1557 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1558 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1559 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1561 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1562 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1564 /*if(process_out->state->s == LTTV_STATE_RUN)
1566 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1567 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1568 PropertiesBG prop_bg;
1569 prop_bg.color = g_new(GdkColor,1);
1571 prop_bg.color->red = 0xffff;
1572 prop_bg.color->green = 0xffff;
1573 prop_bg.color->blue = 0xffff;
1575 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1576 g_free(prop_bg.color);
1577 gdk_gc_unref(draw_context_out->gc);
1580 draw_context_out
->gc
= widget
->style
->black_gc
;
1582 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1583 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1584 PropertiesText prop_text_out
;
1585 prop_text_out
.foreground
= &colorfg_out
;
1586 prop_text_out
.background
= &colorbg_out
;
1587 prop_text_out
.size
= 6;
1588 prop_text_out
.position
= OVER
;
1590 /* color of text : status of the process */
1591 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1593 prop_text_out
.foreground
->red
= 0xffff;
1594 prop_text_out
.foreground
->green
= 0xffff;
1595 prop_text_out
.foreground
->blue
= 0xffff;
1597 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1599 prop_text_out
.foreground
->red
= 0x0fff;
1600 prop_text_out
.foreground
->green
= 0xffff;
1601 prop_text_out
.foreground
->blue
= 0xfff0;
1603 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1605 prop_text_out
.foreground
->red
= 0xffff;
1606 prop_text_out
.foreground
->green
= 0xffff;
1607 prop_text_out
.foreground
->blue
= 0x0000;
1609 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1611 prop_text_out
.foreground
->red
= 0xffff;
1612 prop_text_out
.foreground
->green
= 0x0000;
1613 prop_text_out
.foreground
->blue
= 0xffff;
1615 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1617 prop_text_out
.foreground
->red
= 0xffff;
1618 prop_text_out
.foreground
->green
= 0x0000;
1619 prop_text_out
.foreground
->blue
= 0x0000;
1621 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1623 prop_text_out
.foreground
->red
= 0x0000;
1624 prop_text_out
.foreground
->green
= 0xffff;
1625 prop_text_out
.foreground
->blue
= 0x0000;
1629 prop_text_out
.foreground
->red
= 0xffff;
1630 prop_text_out
.foreground
->green
= 0xffff;
1631 prop_text_out
.foreground
->blue
= 0xffff;
1634 /* Print status of the process : U, WF, WC, E, W, R */
1635 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1636 prop_text_out
.text
= "U";
1637 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1638 prop_text_out
.text
= "WF";
1639 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1640 prop_text_out
.text
= "WC";
1641 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1642 prop_text_out
.text
= "E";
1643 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1644 prop_text_out
.text
= "W";
1645 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1646 prop_text_out
.text
= "R";
1648 prop_text_out
.text
= "U";
1650 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1652 //gdk_gc_unref(draw_context_out->gc);
1654 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1655 draw_context_out
->current
->over
->y
= y_out
;
1656 draw_context_out
->current
->under
->y
= y_out
+height
;
1657 draw_context_out
->current
->status
= process_out
->state
->s
;
1659 /* for pid_out : remove previous, Prev = current, new current (default) */
1660 g_free(draw_context_out
->previous
->modify_under
);
1661 g_free(draw_context_out
->previous
->modify_middle
);
1662 g_free(draw_context_out
->previous
->modify_over
);
1663 g_free(draw_context_out
->previous
->under
);
1664 g_free(draw_context_out
->previous
->middle
);
1665 g_free(draw_context_out
->previous
->over
);
1666 g_free(draw_context_out
->previous
);
1668 draw_context_out
->previous
= draw_context_out
->current
;
1670 draw_context_out
->current
= g_new(DrawInfo
,1);
1671 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1672 draw_context_out
->current
->over
->x
= -1;
1673 draw_context_out
->current
->over
->y
= -1;
1674 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1675 draw_context_out
->current
->middle
->x
= -1;
1676 draw_context_out
->current
->middle
->y
= -1;
1677 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1678 draw_context_out
->current
->under
->x
= -1;
1679 draw_context_out
->current
->under
->y
= -1;
1680 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1681 draw_context_out
->current
->modify_over
->x
= -1;
1682 draw_context_out
->current
->modify_over
->y
= -1;
1683 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1684 draw_context_out
->current
->modify_middle
->x
= -1;
1685 draw_context_out
->current
->modify_middle
->y
= -1;
1686 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1687 draw_context_out
->current
->modify_under
->x
= -1;
1688 draw_context_out
->current
->modify_under
->y
= -1;
1689 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1691 /* Finally, update the drawing context of the pid_in. */
1693 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1694 //draw_context_in->current->modify_over->x = x;
1695 draw_context_in
->current
->modify_over
->y
= y_in
;
1696 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1697 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1698 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1699 widget
= control_flow_data
->drawing
->drawing_area
;
1700 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1702 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1703 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1705 /*if(process_in->state->s == LTTV_STATE_RUN)
1707 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1708 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1709 PropertiesBG prop_bg;
1710 prop_bg.color = g_new(GdkColor,1);
1712 prop_bg.color->red = 0xffff;
1713 prop_bg.color->green = 0xffff;
1714 prop_bg.color->blue = 0xffff;
1716 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1717 g_free(prop_bg.color);
1718 gdk_gc_unref(draw_context_in->gc);
1721 draw_context_in
->gc
= widget
->style
->black_gc
;
1723 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1724 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1725 PropertiesText prop_text_in
;
1726 prop_text_in
.foreground
= &colorfg_in
;
1727 prop_text_in
.background
= &colorbg_in
;
1728 prop_text_in
.size
= 6;
1729 prop_text_in
.position
= OVER
;
1731 /* foreground of text : status of the process */
1732 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1734 prop_text_in
.foreground
->red
= 0xffff;
1735 prop_text_in
.foreground
->green
= 0xffff;
1736 prop_text_in
.foreground
->blue
= 0xffff;
1738 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1740 prop_text_in
.foreground
->red
= 0x0fff;
1741 prop_text_in
.foreground
->green
= 0xffff;
1742 prop_text_in
.foreground
->blue
= 0xfff0;
1744 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1746 prop_text_in
.foreground
->red
= 0xffff;
1747 prop_text_in
.foreground
->green
= 0xffff;
1748 prop_text_in
.foreground
->blue
= 0x0000;
1750 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1752 prop_text_in
.foreground
->red
= 0xffff;
1753 prop_text_in
.foreground
->green
= 0x0000;
1754 prop_text_in
.foreground
->blue
= 0xffff;
1756 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1758 prop_text_in
.foreground
->red
= 0xffff;
1759 prop_text_in
.foreground
->green
= 0x0000;
1760 prop_text_in
.foreground
->blue
= 0x0000;
1762 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1764 prop_text_in
.foreground
->red
= 0x0000;
1765 prop_text_in
.foreground
->green
= 0xffff;
1766 prop_text_in
.foreground
->blue
= 0x0000;
1770 prop_text_in
.foreground
->red
= 0xffff;
1771 prop_text_in
.foreground
->green
= 0xffff;
1772 prop_text_in
.foreground
->blue
= 0xffff;
1776 /* Print status of the process : U, WF, WC, E, W, R */
1777 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1778 prop_text_in
.text
= "U";
1779 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1780 prop_text_in
.text
= "WF";
1781 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1782 prop_text_in
.text
= "WC";
1783 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1784 prop_text_in
.text
= "E";
1785 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1786 prop_text_in
.text
= "W";
1787 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1788 prop_text_in
.text
= "R";
1790 prop_text_in
.text
= "U";
1792 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1795 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1798 prop_text_in
.foreground
= &colorfg_in
;
1799 prop_text_in
.background
= &colorbg_in
;
1800 prop_text_in
.foreground
->red
= 0xffff;
1801 prop_text_in
.foreground
->green
= 0xffff;
1802 prop_text_in
.foreground
->blue
= 0xffff;
1803 prop_text_in
.size
= 6;
1804 prop_text_in
.position
= UNDER
;
1806 prop_text_in
.text
= g_new(gchar
, 260);
1807 strcpy(prop_text_in
.text
, "CPU ");
1808 snprintf(tmp
, 255, "%u", tfc
->index
);
1809 strcat(prop_text_in
.text
, tmp
);
1811 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1812 g_free(prop_text_in
.text
);
1816 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1817 draw_context_in
->current
->over
->y
= y_in
;
1818 draw_context_in
->current
->under
->y
= y_in
+height
;
1819 draw_context_in
->current
->status
= process_in
->state
->s
;
1821 /* for pid_in : remove previous, Prev = current, new current (default) */
1822 g_free(draw_context_in
->previous
->modify_under
);
1823 g_free(draw_context_in
->previous
->modify_middle
);
1824 g_free(draw_context_in
->previous
->modify_over
);
1825 g_free(draw_context_in
->previous
->under
);
1826 g_free(draw_context_in
->previous
->middle
);
1827 g_free(draw_context_in
->previous
->over
);
1828 g_free(draw_context_in
->previous
);
1830 draw_context_in
->previous
= draw_context_in
->current
;
1832 draw_context_in
->current
= g_new(DrawInfo
,1);
1833 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1834 draw_context_in
->current
->over
->x
= -1;
1835 draw_context_in
->current
->over
->y
= -1;
1836 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1837 draw_context_in
->current
->middle
->x
= -1;
1838 draw_context_in
->current
->middle
->y
= -1;
1839 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1840 draw_context_in
->current
->under
->x
= -1;
1841 draw_context_in
->current
->under
->y
= -1;
1842 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1843 draw_context_in
->current
->modify_over
->x
= -1;
1844 draw_context_in
->current
->modify_over
->y
= -1;
1845 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1846 draw_context_in
->current
->modify_middle
->x
= -1;
1847 draw_context_in
->current
->modify_middle
->y
= -1;
1848 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1849 draw_context_in
->current
->modify_under
->x
= -1;
1850 draw_context_in
->current
->modify_under
->y
= -1;
1851 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1860 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1862 PropertiesLine prop_line
;
1863 prop_line
.line_width
= 1;
1864 prop_line
.style
= GDK_LINE_SOLID
;
1866 //GdkColormap *colormap = gdk_colormap_get_system();
1868 /* color of line : execution mode of the process */
1869 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1870 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1871 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1872 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1873 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1874 prop_line
.color
= drawing_colors
[COL_TRAP
];
1875 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1876 prop_line
.color
= drawing_colors
[COL_IRQ
];
1877 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1878 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1880 prop_line
.color
= drawing_colors
[COL_WHITE
];
1882 //gdk_colormap_alloc_color(colormap,
1893 /* before_execmode_hook
1895 * This function basically draw lines and icons. Two types of lines are drawn :
1896 * one small (3 pixels?) representing the state of the process and the second
1897 * type is thicker (10 pixels?) representing on which CPU a process is running
1898 * (and this only in running state).
1900 * Extremums of the lines :
1901 * x_min : time of the last event context for this process kept in memory.
1902 * x_max : time of the current event.
1903 * y : middle of the process in the process list. The process is found in the
1904 * list, therefore is it's position in pixels.
1906 * The choice of lines'color is defined by the context of the last event for this
1911 int before_execmode_hook(void *hook_data
, void *call_data
)
1913 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1914 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1915 Drawing_t
*drawing
= control_flow_data
->drawing
;
1917 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1919 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1920 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1925 LttTime evtime
= ltt_event_time(e
);
1926 TimeWindow time_window
=
1927 lttvwindow_get_time_window(control_flow_data
->tab
);
1929 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1930 time_window
.time_width
);
1932 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1933 || ltt_time_compare(evtime
, end_time
) == 1)
1936 guint width
= drawing
->width
;
1938 /* we are in a execmode, before the state update. We must draw the
1939 * items corresponding to the state before it changes : now is the right
1943 LttvProcessState
*process
= tfs
->process
;
1944 g_assert(process
!= NULL
);
1946 guint pid
= process
->pid
;
1948 /* Well, the process_out existed : we must get it in the process hash
1949 * or add it, and draw its items.
1951 /* Add process to process list (if not present) */
1952 guint y
= 0, height
= 0, pl_height
= 0;
1953 HashedProcessData
*hashed_process_data
= NULL
;
1954 ProcessList
*process_list
=
1955 guicontrolflow_get_process_list(control_flow_data
);
1956 LttTime birth
= process
->creation_time
;
1957 const gchar
*name
= g_quark_to_string(process
->name
);
1959 if(processlist_get_process_pixels(process_list
,
1963 tfc
->t_context
->index
,
1966 &hashed_process_data
) == 1)
1968 g_assert(pid
== 0 || pid
!= process
->ppid
);
1969 /* Process not present */
1970 processlist_add(process_list
,
1975 tfc
->t_context
->index
,
1978 &hashed_process_data
);
1979 processlist_get_process_pixels(process_list
,
1983 tfc
->t_context
->index
,
1986 &hashed_process_data
);
1987 drawing_insert_square( drawing
, y
, height
);
1990 /* Now, the process is in the state hash and our own process hash.
1991 * We definitely can draw the items related to the ending state.
1994 /* Check if the x position is unset. In can have been left unset by
1995 * a draw closure from a after chunk hook. This should never happen,
1996 * because it must be set by before chunk hook to the damage_begin
1999 g_assert(hashed_process_data
->x
.over
!= -1);
2003 convert_time_to_pixels(
2004 time_window
.start_time
,
2011 /* Jump over draw if we are at the same x position */
2012 if(x
== hashed_process_data
->x
.middle
&&
2013 hashed_process_data
->x
.middle_used
)
2015 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2016 /* Draw collision indicator */
2017 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2018 gdk_draw_point(drawing
->pixmap
,
2022 hashed_process_data
->x
.middle_marked
= TRUE
;
2027 DrawContext draw_context
;
2028 /* Now create the drawing context that will be used to draw
2029 * items related to the last state. */
2030 draw_context
.drawable
= drawing
->pixmap
;
2031 draw_context
.gc
= drawing
->gc
;
2032 draw_context
.pango_layout
= drawing
->pango_layout
;
2033 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2034 draw_context
.drawinfo
.end
.x
= x
;
2036 draw_context
.drawinfo
.y
.over
= y
+1;
2037 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2038 draw_context
.drawinfo
.y
.under
= y
+height
;
2040 draw_context
.drawinfo
.start
.offset
.over
= 0;
2041 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2042 draw_context
.drawinfo
.start
.offset
.under
= 0;
2043 draw_context
.drawinfo
.end
.offset
.over
= 0;
2044 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2045 draw_context
.drawinfo
.end
.offset
.under
= 0;
2049 PropertiesLine prop_line
= prepare_s_e_line(process
);
2050 draw_line((void*)&prop_line
, (void*)&draw_context
);
2053 /* become the last x position */
2054 hashed_process_data
->x
.middle
= x
;
2055 hashed_process_data
->x
.middle_used
= TRUE
;
2056 hashed_process_data
->x
.middle_marked
= FALSE
;
2063 /* after_execmode_hook
2065 * The draw after hook is called by the reading API to have a
2066 * particular event drawn on the screen.
2067 * @param hook_data ControlFlowData structure of the viewer.
2068 * @param call_data Event context.
2070 * This function adds items to be drawn in a queue for each process.
2073 int after_execmode_hook(void *hook_data
, void *call_data
)
2075 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2076 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2078 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2080 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2081 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2086 LttTime evtime
= ltt_event_time(e
);
2087 TimeWindow time_window
=
2088 lttvwindow_get_time_window(control_flow_data
->tab
);
2090 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2091 time_window
.time_width
);
2093 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2094 || ltt_time_compare(evtime
, end_time
) == 1)
2097 guint width
= control_flow_data
->drawing
->width
;
2099 /* Add process to process list (if not present) */
2100 LttvProcessState
*process
;
2102 guint y
= 0, height
= 0, pl_height
= 0;
2103 HashedProcessData
*hashed_process_data
= NULL
;
2105 ProcessList
*process_list
=
2106 guicontrolflow_get_process_list(control_flow_data
);
2109 /* Find process pid_in in the list... */
2110 process
= tfs
->process
;
2111 /* It should exist, because we are after the state update. */
2112 g_assert(process
!= NULL
);
2114 guint pid
= process
->pid
;
2116 birth
= process
->creation_time
;
2117 const gchar
*name
= g_quark_to_string(process
->name
);
2119 if(processlist_get_process_pixels(process_list
,
2123 tfc
->t_context
->index
,
2126 &hashed_process_data
) == 1)
2128 g_assert(pid
== 0 || pid
!= process
->ppid
);
2129 /* Process not present */
2130 processlist_add(process_list
,
2135 tfc
->t_context
->index
,
2138 &hashed_process_data
);
2139 processlist_get_process_pixels(process_list
,
2143 tfc
->t_context
->index
,
2146 &hashed_process_data
);
2147 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2152 convert_time_to_pixels(
2153 time_window
.start_time
,
2159 if(hashed_process_data
->x
.middle
!= new_x
) {
2160 hashed_process_data
->x
.middle
= new_x
;
2161 hashed_process_data
->x
.middle_used
= FALSE
;
2162 hashed_process_data
->x
.middle_marked
= FALSE
;
2170 /* before_process_hook
2172 * Draw lines for process event.
2174 * @param hook_data ControlFlowData structure of the viewer.
2175 * @param call_data Event context.
2177 * This function adds items to be drawn in a queue for each process.
2180 int before_process_hook(void *hook_data
, void *call_data
)
2182 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2183 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2184 Drawing_t
*drawing
= control_flow_data
->drawing
;
2186 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2188 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2189 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2194 LttTime evtime
= ltt_event_time(e
);
2195 TimeWindow time_window
=
2196 lttvwindow_get_time_window(control_flow_data
->tab
);
2198 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2199 time_window
.time_width
);
2201 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2202 || ltt_time_compare(evtime
, end_time
) == 1)
2205 guint width
= control_flow_data
->drawing
->width
;
2209 LttField
*f
= ltt_event_field(e
);
2211 element
= ltt_field_member(f
,0);
2212 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2215 if(sub_id
== 3) { /* exit */
2217 /* Add process to process list (if not present) */
2218 LttvProcessState
*process
= tfs
->process
;
2219 guint pid
= process
->pid
;
2221 guint y
= 0, height
= 0, pl_height
= 0;
2222 HashedProcessData
*hashed_process_data
= NULL
;
2224 ProcessList
*process_list
=
2225 guicontrolflow_get_process_list(control_flow_data
);
2227 g_assert(process
!= NULL
);
2229 birth
= process
->creation_time
;
2230 const gchar
*name
= g_quark_to_string(process
->name
);
2232 if(processlist_get_process_pixels(process_list
,
2236 tfc
->t_context
->index
,
2239 &hashed_process_data
) == 1)
2241 g_assert(pid
== 0 || pid
!= process
->ppid
);
2242 /* Process not present */
2243 processlist_add(process_list
,
2248 tfc
->t_context
->index
,
2251 &hashed_process_data
);
2252 processlist_get_process_pixels(process_list
,
2256 tfc
->t_context
->index
,
2259 &hashed_process_data
);
2260 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2263 /* Now, the process is in the state hash and our own process hash.
2264 * We definitely can draw the items related to the ending state.
2267 /* Check if the x position is unset. In can have been left unset by
2268 * a draw closure from a after chunk hook. This should never happen,
2269 * because it must be set by before chunk hook to the damage_begin
2272 g_assert(hashed_process_data
->x
.over
!= -1);
2276 convert_time_to_pixels(
2277 time_window
.start_time
,
2284 /* Jump over draw if we are at the same x position */
2285 if(x
== hashed_process_data
->x
.middle
&&
2286 hashed_process_data
->x
.middle_used
)
2288 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2289 /* Draw collision indicator */
2290 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2291 gdk_draw_point(drawing
->pixmap
,
2295 hashed_process_data
->x
.middle_marked
= TRUE
;
2299 DrawContext draw_context
;
2301 /* Now create the drawing context that will be used to draw
2302 * items related to the last state. */
2303 draw_context
.drawable
= drawing
->pixmap
;
2304 draw_context
.gc
= drawing
->gc
;
2305 draw_context
.pango_layout
= drawing
->pango_layout
;
2306 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2307 draw_context
.drawinfo
.end
.x
= x
;
2309 draw_context
.drawinfo
.y
.over
= y
+1;
2310 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2311 draw_context
.drawinfo
.y
.under
= y
+height
;
2313 draw_context
.drawinfo
.start
.offset
.over
= 0;
2314 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2315 draw_context
.drawinfo
.start
.offset
.under
= 0;
2316 draw_context
.drawinfo
.end
.offset
.over
= 0;
2317 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2318 draw_context
.drawinfo
.end
.offset
.under
= 0;
2322 PropertiesLine prop_line
= prepare_s_e_line(process
);
2323 draw_line((void*)&prop_line
, (void*)&draw_context
);
2326 /* become the last x position */
2327 hashed_process_data
->x
.middle
= x
;
2328 hashed_process_data
->x
.middle_used
= TRUE
;
2329 hashed_process_data
->x
.middle_marked
= FALSE
;
2343 /* after_process_hook
2345 * Create the processlist entry for the child process. Put the last
2346 * position in x at the current time value.
2348 * @param hook_data ControlFlowData structure of the viewer.
2349 * @param call_data Event context.
2351 * This function adds items to be drawn in a queue for each process.
2354 int after_process_hook(void *hook_data
, void *call_data
)
2356 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2357 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2359 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2361 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2362 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2367 LttTime evtime
= ltt_event_time(e
);
2368 TimeWindow time_window
=
2369 lttvwindow_get_time_window(control_flow_data
->tab
);
2371 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2372 time_window
.time_width
);
2374 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2375 || ltt_time_compare(evtime
, end_time
) == 1)
2378 guint width
= control_flow_data
->drawing
->width
;
2383 LttField
*f
= ltt_event_field(e
);
2385 element
= ltt_field_member(f
,0);
2386 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2387 element
= ltt_field_member(f
,1);
2388 param1
= ltt_event_get_long_unsigned(e
,element
);
2391 if(sub_id
== 2) { /* fork */
2393 guint child_pid
= param1
;
2394 /* Add process to process list (if not present) */
2395 LttvProcessState
*process_child
;
2397 guint y_child
= 0, height
= 0, pl_height
= 0;
2398 HashedProcessData
*hashed_process_data_child
= NULL
;
2400 ProcessList
*process_list
=
2401 guicontrolflow_get_process_list(control_flow_data
);
2404 /* Find child in the list... */
2405 process_child
= lttv_state_find_process(tfs
, child_pid
);
2406 /* It should exist, because we are after the state update. */
2407 g_assert(process_child
!= NULL
);
2409 birth
= process_child
->creation_time
;
2410 const gchar
*name
= g_quark_to_string(process_child
->name
);
2412 if(processlist_get_process_pixels(process_list
,
2414 process_child
->last_cpu
,
2416 tfc
->t_context
->index
,
2419 &hashed_process_data_child
) == 1)
2421 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2422 /* Process not present */
2423 processlist_add(process_list
,
2425 process_child
->last_cpu
,
2426 process_child
->ppid
,
2428 tfc
->t_context
->index
,
2431 &hashed_process_data_child
);
2432 processlist_get_process_pixels(process_list
,
2434 process_child
->last_cpu
,
2436 tfc
->t_context
->index
,
2439 &hashed_process_data_child
);
2440 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2444 convert_time_to_pixels(
2445 time_window
.start_time
,
2451 if(hashed_process_data_child
->x
.over
!= new_x
) {
2452 hashed_process_data_child
->x
.over
= new_x
;
2453 hashed_process_data_child
->x
.over_used
= FALSE
;
2454 hashed_process_data_child
->x
.over_marked
= FALSE
;
2456 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2457 hashed_process_data_child
->x
.middle
= new_x
;
2458 hashed_process_data_child
->x
.middle_used
= FALSE
;
2459 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2461 if(hashed_process_data_child
->x
.under
!= new_x
) {
2462 hashed_process_data_child
->x
.under
= new_x
;
2463 hashed_process_data_child
->x
.under_used
= FALSE
;
2464 hashed_process_data_child
->x
.under_marked
= FALSE
;
2467 } else if(sub_id
== 3) { /* exit */
2469 /* Add process to process list (if not present) */
2470 LttvProcessState
*process
= tfs
->process
;
2471 guint pid
= process
->pid
;
2473 guint y
= 0, height
= 0, pl_height
= 0;
2474 HashedProcessData
*hashed_process_data
= NULL
;
2476 ProcessList
*process_list
=
2477 guicontrolflow_get_process_list(control_flow_data
);
2480 /* It should exist, because we are after the state update. */
2481 g_assert(process
!= NULL
);
2483 birth
= process
->creation_time
;
2484 const gchar
*name
= g_quark_to_string(process
->name
);
2486 if(processlist_get_process_pixels(process_list
,
2490 tfc
->t_context
->index
,
2493 &hashed_process_data
) == 1)
2495 g_assert(pid
== 0 || pid
!= process
->ppid
);
2496 /* Process not present */
2497 processlist_add(process_list
,
2502 tfc
->t_context
->index
,
2505 &hashed_process_data
);
2506 processlist_get_process_pixels(process_list
,
2510 tfc
->t_context
->index
,
2513 &hashed_process_data
);
2514 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2518 convert_time_to_pixels(
2519 time_window
.start_time
,
2524 if(hashed_process_data
->x
.middle
!= new_x
) {
2525 hashed_process_data
->x
.middle
= new_x
;
2526 hashed_process_data
->x
.middle_used
= FALSE
;
2527 hashed_process_data
->x
.middle_marked
= FALSE
;
2537 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2539 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2540 Drawing_t
*drawing
= control_flow_data
->drawing
;
2542 const TimeWindowNotifyData
*time_window_nofify_data
=
2543 ((const TimeWindowNotifyData
*)call_data
);
2545 TimeWindow
*old_time_window
=
2546 time_window_nofify_data
->old_time_window
;
2547 TimeWindow
*new_time_window
=
2548 time_window_nofify_data
->new_time_window
;
2550 /* Update the ruler */
2551 drawing_update_ruler(control_flow_data
->drawing
,
2555 /* Two cases : zoom in/out or scrolling */
2557 /* In order to make sure we can reuse the old drawing, the scale must
2558 * be the same and the new time interval being partly located in the
2559 * currently shown time interval. (reuse is only for scrolling)
2562 g_info("Old time window HOOK : %u, %u to %u, %u",
2563 old_time_window
->start_time
.tv_sec
,
2564 old_time_window
->start_time
.tv_nsec
,
2565 old_time_window
->time_width
.tv_sec
,
2566 old_time_window
->time_width
.tv_nsec
);
2568 g_info("New time window HOOK : %u, %u to %u, %u",
2569 new_time_window
->start_time
.tv_sec
,
2570 new_time_window
->start_time
.tv_nsec
,
2571 new_time_window
->time_width
.tv_sec
,
2572 new_time_window
->time_width
.tv_nsec
);
2574 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2575 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2577 /* Same scale (scrolling) */
2578 g_info("scrolling");
2579 LttTime
*ns
= &new_time_window
->start_time
;
2580 LttTime
*os
= &old_time_window
->start_time
;
2581 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
2582 old_time_window
->time_width
);
2583 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
2584 new_time_window
->time_width
);
2586 //if(ns<os+w && os+w<ns+w)
2587 //if(ns<old_end && os<ns)
2588 if(ltt_time_compare(*ns
, old_end
) == -1
2589 && ltt_time_compare(*os
, *ns
) == -1)
2591 g_info("scrolling near right");
2592 /* Scroll right, keep right part of the screen */
2594 guint width
= control_flow_data
->drawing
->width
;
2595 convert_time_to_pixels(
2602 /* Copy old data to new location */
2603 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2604 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2605 control_flow_data
->drawing
->pixmap
,
2608 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2610 if(drawing
->damage_begin
== drawing
->damage_end
)
2611 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2613 drawing
->damage_begin
= 0;
2615 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2617 /* Clear the data request background, but not SAFETY */
2618 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2619 //control_flow_data->drawing->drawing_area->style->black_gc,
2620 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2622 drawing
->damage_begin
+SAFETY
, 0,
2623 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2624 control_flow_data
->drawing
->height
);
2626 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2628 control_flow_data
->drawing
->width
,
2629 control_flow_data
->drawing
->height
);
2631 /* Get new data for the rest. */
2632 drawing_data_request(control_flow_data
->drawing
,
2633 &control_flow_data
->drawing
->pixmap
,
2634 drawing
->damage_begin
, 0,
2635 drawing
->damage_end
- drawing
->damage_begin
,
2636 control_flow_data
->drawing
->height
);
2639 //if(ns<os && os<ns+w)
2640 //if(ns<os && os<new_end)
2641 if(ltt_time_compare(*ns
,*os
) == -1
2642 && ltt_time_compare(*os
,new_end
) == -1)
2644 g_info("scrolling near left");
2645 /* Scroll left, keep left part of the screen */
2647 guint width
= control_flow_data
->drawing
->width
;
2648 convert_time_to_pixels(
2656 /* Copy old data to new location */
2657 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2658 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2659 control_flow_data
->drawing
->pixmap
,
2664 if(drawing
->damage_begin
== drawing
->damage_end
)
2665 drawing
->damage_end
= x
;
2667 drawing
->damage_end
=
2668 control_flow_data
->drawing
->width
;
2670 drawing
->damage_begin
= 0;
2672 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2673 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2675 drawing
->damage_begin
, 0,
2676 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2677 control_flow_data
->drawing
->height
);
2679 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2681 control_flow_data
->drawing
->width
,
2682 control_flow_data
->drawing
->height
);
2685 /* Get new data for the rest. */
2686 drawing_data_request(control_flow_data
->drawing
,
2687 &control_flow_data
->drawing
->pixmap
,
2688 drawing
->damage_begin
, 0,
2689 drawing
->damage_end
- drawing
->damage_begin
,
2690 control_flow_data
->drawing
->height
);
2693 if(ltt_time_compare(*ns
,*os
) == 0)
2695 g_info("not scrolling");
2697 g_info("scrolling far");
2698 /* Cannot reuse any part of the screen : far jump */
2701 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2702 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2705 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2706 control_flow_data
->drawing
->height
);
2708 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2710 control_flow_data
->drawing
->width
,
2711 control_flow_data
->drawing
->height
);
2713 drawing
->damage_begin
= 0;
2714 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2716 drawing_data_request(control_flow_data
->drawing
,
2717 &control_flow_data
->drawing
->pixmap
,
2719 control_flow_data
->drawing
->width
,
2720 control_flow_data
->drawing
->height
);
2726 /* Different scale (zoom) */
2729 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2730 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2733 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2734 control_flow_data
->drawing
->height
);
2736 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2738 control_flow_data
->drawing
->width
,
2739 control_flow_data
->drawing
->height
);
2741 drawing
->damage_begin
= 0;
2742 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2744 drawing_data_request(control_flow_data
->drawing
,
2745 &control_flow_data
->drawing
->pixmap
,
2747 control_flow_data
->drawing
->width
,
2748 control_flow_data
->drawing
->height
);
2756 gint
traceset_notify(void *hook_data
, void *call_data
)
2758 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2759 Drawing_t
*drawing
= control_flow_data
->drawing
;
2760 GtkWidget
*widget
= drawing
->drawing_area
;
2763 drawing_clear(control_flow_data
->drawing
);
2764 processlist_clear(control_flow_data
->process_list
);
2765 redraw_notify(control_flow_data
, NULL
);
2767 request_background_data(control_flow_data
);
2769 drawing
->damage_begin
= 0;
2770 drawing
->damage_end
= drawing
->width
;
2771 if(drawing
->damage_begin
< drawing
->damage_end
)
2773 drawing_data_request(drawing
,
2775 drawing
->damage_begin
,
2777 drawing
->damage_end
-drawing
->damage_begin
,
2781 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2790 gint
redraw_notify(void *hook_data
, void *call_data
)
2792 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2793 Drawing_t
*drawing
= control_flow_data
->drawing
;
2794 GtkWidget
*widget
= drawing
->drawing_area
;
2796 drawing
->damage_begin
= 0;
2797 drawing
->damage_end
= drawing
->width
;
2799 /* fun feature, to be separated someday... */
2800 drawing_clear(control_flow_data
->drawing
);
2801 processlist_clear(control_flow_data
->process_list
);
2804 gdk_draw_rectangle (drawing
->pixmap
,
2805 widget
->style
->black_gc
,
2808 drawing
->width
+SAFETY
,
2812 if(drawing
->damage_begin
< drawing
->damage_end
)
2814 drawing_data_request(drawing
,
2816 drawing
->damage_begin
,
2818 drawing
->damage_end
-drawing
->damage_begin
,
2822 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2831 gint
continue_notify(void *hook_data
, void *call_data
)
2833 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2834 Drawing_t
*drawing
= control_flow_data
->drawing
;
2835 GtkWidget
*widget
= drawing
->drawing_area
;
2837 //g_assert(widget->allocation.width == drawing->damage_end);
2839 if(drawing
->damage_begin
< drawing
->damage_end
)
2841 drawing_data_request(drawing
,
2843 drawing
->damage_begin
,
2845 drawing
->damage_end
-drawing
->damage_begin
,
2853 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2855 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2856 Drawing_t
*drawing
= control_flow_data
->drawing
;
2858 LttTime current_time
= *((LttTime
*)call_data
);
2860 TimeWindow time_window
=
2861 lttvwindow_get_time_window(control_flow_data
->tab
);
2863 LttTime time_begin
= time_window
.start_time
;
2864 LttTime width
= time_window
.time_width
;
2867 guint64 time_ll
= ltt_time_to_uint64(width
);
2868 time_ll
= time_ll
>> 1; /* divide by two */
2869 half_width
= ltt_time_from_uint64(time_ll
);
2871 LttTime time_end
= ltt_time_add(time_begin
, width
);
2873 LttvTracesetContext
* tsc
=
2874 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2876 LttTime trace_start
= tsc
->time_span
.start_time
;
2877 LttTime trace_end
= tsc
->time_span
.end_time
;
2879 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2880 current_time
.tv_nsec
);
2884 /* If current time is inside time interval, just move the highlight
2887 /* Else, we have to change the time interval. We have to tell it
2888 * to the main window. */
2889 /* The time interval change will take care of placing the current
2890 * time at the center of the visible area, or nearest possible if we are
2891 * at one end of the trace. */
2894 if(ltt_time_compare(current_time
, time_begin
) == -1)
2896 TimeWindow new_time_window
;
2898 if(ltt_time_compare(current_time
,
2899 ltt_time_add(trace_start
,half_width
)) == -1)
2900 time_begin
= trace_start
;
2902 time_begin
= ltt_time_sub(current_time
,half_width
);
2904 new_time_window
.start_time
= time_begin
;
2905 new_time_window
.time_width
= width
;
2907 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2909 else if(ltt_time_compare(current_time
, time_end
) == 1)
2911 TimeWindow new_time_window
;
2913 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2914 time_begin
= ltt_time_sub(trace_end
,width
);
2916 time_begin
= ltt_time_sub(current_time
,half_width
);
2918 new_time_window
.start_time
= time_begin
;
2919 new_time_window
.time_width
= width
;
2921 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2924 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2925 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2933 typedef struct _ClosureData
{
2934 EventsRequest
*events_request
;
2935 LttvTracesetState
*tss
;
2940 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2942 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2943 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2944 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2946 EventsRequest
*events_request
= closure_data
->events_request
;
2947 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2948 Drawing_t
*drawing
= control_flow_data
->drawing
;
2950 LttvTracesetState
*tss
= closure_data
->tss
;
2951 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2953 LttTime evtime
= closure_data
->end_time
;
2954 TimeWindow time_window
=
2955 lttvwindow_get_time_window(control_flow_data
->tab
);
2957 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2958 time_window
.time_width
);
2960 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2961 || ltt_time_compare(evtime
, end_time
) == 1)
2964 guint width
= drawing
->width
;
2967 /* For the process */
2968 /* First, check if the current process is in the state computation
2969 * process list. If it is there, that means we must add it right now and
2970 * draw items from the beginning of the read for it. If it is not
2971 * present, it's a new process and it was not present : it will
2972 * be added after the state update. */
2973 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2975 /* tracefiles[0] is ok here, because we draw for every PID, and
2976 * assume CPU 0 for PID 0 //FIXME */
2977 LttvTracefileState
*tfs
=
2978 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2980 LttvProcessState
*process
;
2981 process
= lttv_state_find_process(tfs
,
2984 if(process
!= NULL
) {
2986 /* Only draw for processes that are currently in the trace states */
2988 guint y
= 0, height
= 0, pl_height
= 0;
2989 ProcessList
*process_list
=
2990 guicontrolflow_get_process_list(control_flow_data
);
2991 LttTime birth
= process_info
->birth
;
2993 /* Should be alike when background info is ready */
2994 if(control_flow_data
->background_info_waiting
==0)
2995 g_assert(ltt_time_compare(process
->creation_time
,
2996 process_info
->birth
) == 0);
2997 const gchar
*name
= g_quark_to_string(process
->name
);
2999 /* process HAS to be present */
3000 g_assert(processlist_get_process_pixels(process_list
,
3004 process_info
->trace_num
,
3007 &hashed_process_data
) != 1);
3009 /* Now, the process is in the state hash and our own process hash.
3010 * We definitely can draw the items related to the ending state.
3013 /* Check if the x position is unset. In can have been left unset by
3014 * a draw closure from a after chunk hook. This should never happen,
3015 * because it must be set by before chunk hook to the damage_begin
3018 g_assert(hashed_process_data
->x
.over
!= -1);
3022 convert_time_to_pixels(
3023 time_window
.start_time
,
3029 DrawContext draw_context
;
3031 /* Now create the drawing context that will be used to draw
3032 * items related to the last state. */
3033 draw_context
.drawable
= drawing
->pixmap
;
3034 draw_context
.gc
= drawing
->gc
;
3035 draw_context
.pango_layout
= drawing
->pango_layout
;
3036 draw_context
.drawinfo
.end
.x
= x
;
3038 draw_context
.drawinfo
.y
.over
= y
+1;
3039 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3040 draw_context
.drawinfo
.y
.under
= y
+height
;
3042 draw_context
.drawinfo
.start
.offset
.over
= 0;
3043 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3044 draw_context
.drawinfo
.start
.offset
.under
= 0;
3045 draw_context
.drawinfo
.end
.offset
.over
= 0;
3046 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3047 draw_context
.drawinfo
.end
.offset
.under
= 0;
3049 /* Jump over draw if we are at the same x position */
3050 if(x
== hashed_process_data
->x
.over
)
3054 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3056 PropertiesLine prop_line
= prepare_execmode_line(process
);
3057 draw_line((void*)&prop_line
, (void*)&draw_context
);
3059 hashed_process_data
->x
.over
= x
;
3063 if(x
== hashed_process_data
->x
.middle
&&
3064 hashed_process_data
->x
.middle_used
) {
3065 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3066 /* Draw collision indicator */
3067 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3068 gdk_draw_point(drawing
->pixmap
,
3072 hashed_process_data
->x
.middle_marked
= TRUE
;
3076 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3078 PropertiesLine prop_line
= prepare_s_e_line(process
);
3079 draw_line((void*)&prop_line
, (void*)&draw_context
);
3081 /* become the last x position */
3082 if(x
!= hashed_process_data
->x
.middle
) {
3083 hashed_process_data
->x
.middle
= x
;
3084 /* but don't use the pixel */
3085 hashed_process_data
->x
.middle_used
= FALSE
;
3094 int before_chunk(void *hook_data
, void *call_data
)
3096 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3097 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3099 drawing_chunk_begin(events_request
, tss
);
3104 int before_request(void *hook_data
, void *call_data
)
3106 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3107 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3109 drawing_data_request_begin(events_request
, tss
);
3116 * after request is necessary in addition of after chunk in order to draw
3117 * lines until the end of the screen. after chunk just draws lines until
3124 int after_request(void *hook_data
, void *call_data
)
3126 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3127 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3128 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3129 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3131 ProcessList
*process_list
=
3132 guicontrolflow_get_process_list(control_flow_data
);
3133 LttTime end_time
= events_request
->end_time
;
3135 ClosureData closure_data
;
3136 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3137 closure_data
.tss
= tss
;
3138 closure_data
.end_time
= end_time
;
3140 /* Draw last items */
3141 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3142 (void*)&closure_data
);
3144 /* Request expose */
3145 drawing_request_expose(events_request
, tss
, end_time
);
3154 int after_chunk(void *hook_data
, void *call_data
)
3156 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3157 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3158 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3159 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3160 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3163 ProcessList
*process_list
=
3164 guicontrolflow_get_process_list(control_flow_data
);
3167 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3168 else /* end of traceset, or position now out of request : end */
3169 end_time
= events_request
->end_time
;
3171 ClosureData closure_data
;
3172 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3173 closure_data
.tss
= tss
;
3174 closure_data
.end_time
= end_time
;
3176 /* Draw last items */
3177 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3178 (void*)&closure_data
);
3180 /* Request expose */
3181 drawing_request_expose(events_request
, tss
, end_time
);