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
,
510 DrawContext draw_context
;
512 /* Now create the drawing context that will be used to draw
513 * items related to the last state. */
514 draw_context
.drawable
= drawing
->pixmap
;
515 draw_context
.gc
= drawing
->gc
;
516 draw_context
.pango_layout
= drawing
->pango_layout
;
517 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
518 draw_context
.drawinfo
.end
.x
= x
;
520 draw_context
.drawinfo
.y
.over
= y
+1;
521 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
522 draw_context
.drawinfo
.y
.under
= y
+height
;
524 draw_context
.drawinfo
.start
.offset
.over
= 0;
525 draw_context
.drawinfo
.start
.offset
.middle
= 0;
526 draw_context
.drawinfo
.start
.offset
.under
= 0;
527 draw_context
.drawinfo
.end
.offset
.over
= 0;
528 draw_context
.drawinfo
.end
.offset
.middle
= 0;
529 draw_context
.drawinfo
.end
.offset
.under
= 0;
533 PropertiesLine prop_line
= prepare_s_e_line(process
);
534 draw_line((void*)&prop_line
, (void*)&draw_context
);
537 /* become the last x position */
538 hashed_process_data
->x
.middle
= x
;
539 hashed_process_data
->x
.middle_used
= TRUE
;
540 hashed_process_data
->x
.middle_marked
= FALSE
;
548 /* First, check if the current process is in the state computation
549 * process list. If it is there, that means we must add it right now and
550 * draw items from the beginning of the read for it. If it is not
551 * present, it's a new process and it was not present : it will
552 * be added after the state update. */
553 LttvProcessState
*process
;
554 process
= lttv_state_find_process(tfs
, pid_in
);
556 if(process
!= NULL
) {
557 /* Well, the process_out existed : we must get it in the process hash
558 * or add it, and draw its items.
560 /* Add process to process list (if not present) */
561 guint y
= 0, height
= 0, pl_height
= 0;
562 HashedProcessData
*hashed_process_data
= NULL
;
563 ProcessList
*process_list
=
564 guicontrolflow_get_process_list(control_flow_data
);
565 LttTime birth
= process
->creation_time
;
566 const gchar
*name
= g_quark_to_string(process
->name
);
568 if(processlist_get_process_pixels(process_list
,
572 tfc
->t_context
->index
,
575 &hashed_process_data
) == 1)
577 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
578 /* Process not present */
579 processlist_add(process_list
,
584 tfc
->t_context
->index
,
587 &hashed_process_data
);
588 processlist_get_process_pixels(process_list
,
592 tfc
->t_context
->index
,
595 &hashed_process_data
);
596 drawing_insert_square( drawing
, y
, height
);
599 /* Now, the process is in the state hash and our own process hash.
600 * We definitely can draw the items related to the ending state.
603 /* Check if the x position is unset. In can have been left unset by
604 * a draw closure from a after chunk hook. This should never happen,
605 * because it must be set by before chunk hook to the damage_begin
608 g_assert(hashed_process_data
->x
.middle
!= -1);
612 convert_time_to_pixels(
613 time_window
.start_time
,
620 /* Jump over draw if we are at the same x position */
621 if(x
== hashed_process_data
->x
.middle
&&
622 hashed_process_data
->x
.middle_used
)
624 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
625 /* Draw collision indicator */
626 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
627 gdk_draw_point(drawing
->pixmap
,
634 DrawContext draw_context
;
636 /* Now create the drawing context that will be used to draw
637 * items related to the last state. */
638 draw_context
.drawable
= drawing
->pixmap
;
639 draw_context
.gc
= drawing
->gc
;
640 draw_context
.pango_layout
= drawing
->pango_layout
;
641 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
642 draw_context
.drawinfo
.end
.x
= x
;
644 draw_context
.drawinfo
.y
.over
= y
+1;
645 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
646 draw_context
.drawinfo
.y
.under
= y
+height
;
648 draw_context
.drawinfo
.start
.offset
.over
= 0;
649 draw_context
.drawinfo
.start
.offset
.middle
= 0;
650 draw_context
.drawinfo
.start
.offset
.under
= 0;
651 draw_context
.drawinfo
.end
.offset
.over
= 0;
652 draw_context
.drawinfo
.end
.offset
.middle
= 0;
653 draw_context
.drawinfo
.end
.offset
.under
= 0;
657 PropertiesLine prop_line
= prepare_s_e_line(process
);
658 draw_line((void*)&prop_line
, (void*)&draw_context
);
662 /* become the last x position */
663 hashed_process_data
->x
.middle
= x
;
664 hashed_process_data
->x
.middle_used
= TRUE
;
665 hashed_process_data
->x
.middle_marked
= FALSE
;
674 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
675 ControlFlowData
*control_flow_data
=
676 (ControlFlowData
*)events_request
->viewer_data
;
677 Tab
*tab
= control_flow_data
->tab
;
679 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
681 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
682 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
687 LttTime evtime
= ltt_event_time(e
);
688 TimeWindow time_window
=
689 lttvwindow_get_time_window(tab
);
691 LttTime end_time
= ltt_time_add(time_window
.start_time
,
692 time_window
.time_width
);
693 //if(time < time_beg || time > time_end) return;
694 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
695 || ltt_time_compare(evtime
, end_time
) == 1)
698 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
700 g_debug("schedchange!");
702 /* Add process to process list (if not present) and get drawing "y" from
703 * process position */
704 guint pid_out
, pid_in
;
705 LttvProcessState
*process_out
, *process_in
;
707 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
709 ProcessList
*process_list
=
710 guicontrolflow_get_process_list(control_flow_data
);
713 LttField
*f
= ltt_event_field(e
);
715 element
= ltt_field_member(f
,0);
716 pid_out
= ltt_event_get_long_unsigned(e
,element
);
717 element
= ltt_field_member(f
,1);
718 pid_in
= ltt_event_get_long_unsigned(e
,element
);
719 g_debug("out : %u in : %u", pid_out
, pid_in
);
722 /* Find process pid_out in the list... */
723 process_out
= lttv_state_find_process(tfs
, pid_out
);
724 if(process_out
== NULL
) return 0;
725 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
727 birth
= process_out
->creation_time
;
728 const gchar
*name
= g_quark_to_string(process_out
->name
);
729 HashedProcessData
*hashed_process_data_out
= NULL
;
731 if(processlist_get_process_pixels(process_list
,
734 tfc
->t_context
->index
,
737 &hashed_process_data_out
) == 1)
739 /* Process not present */
740 processlist_add(process_list
,
743 tfc
->t_context
->index
,
746 &hashed_process_data_out
);
747 g_assert(processlist_get_process_pixels(process_list
,
750 tfc
->t_context
->index
,
753 &hashed_process_data_out
)==0);
754 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
758 /* Find process pid_in in the list... */
759 process_in
= lttv_state_find_process(tfs
, pid_in
);
760 if(process_in
== NULL
) return 0;
761 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
763 birth
= process_in
->creation_time
;
764 name
= g_quark_to_string(process_in
->name
);
765 HashedProcessData
*hashed_process_data_in
= NULL
;
767 if(processlist_get_process_pixels(process_list
,
770 tfc
->t_context
->index
,
773 &hashed_process_data_in
) == 1)
775 /* Process not present */
776 processlist_add(process_list
,
779 tfc
->t_context
->index
,
782 &hashed_process_data_in
);
783 processlist_get_process_pixels(process_list
,
786 tfc
->t_context
->index
,
789 &hashed_process_data_in
);
791 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
796 /* Find pixels corresponding to time of the event. If the time does
797 * not fit in the window, show a warning, not supposed to happend. */
799 guint width
= control_flow_data
->drawing
->width
;
801 LttTime time
= ltt_event_time(e
);
803 LttTime window_end
= ltt_time_add(time_window
.time_width
,
804 time_window
.start_time
);
807 convert_time_to_pixels(
808 time_window
.start_time
,
813 //assert(x <= width);
815 /* draw what represents the event for outgoing process. */
817 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
818 draw_context_out
->current
->modify_over
->x
= x
;
819 draw_context_out
->current
->modify_under
->x
= x
;
820 draw_context_out
->current
->modify_over
->y
= y_out
;
821 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
822 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
823 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
824 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
825 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
826 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
827 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
828 //draw_context_out->gc = widget->style->black_gc;
830 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
831 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
833 /* Draw the line/background of the out process */
834 if(draw_context_out
->previous
->middle
->x
== -1)
836 draw_context_out
->previous
->over
->x
=
837 control_flow_data
->drawing
->damage_begin
;
838 draw_context_out
->previous
->middle
->x
=
839 control_flow_data
->drawing
->damage_begin
;
840 draw_context_out
->previous
->under
->x
=
841 control_flow_data
->drawing
->damage_begin
;
843 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
846 draw_context_out
->current
->middle
->x
= x
;
847 draw_context_out
->current
->over
->x
= x
;
848 draw_context_out
->current
->under
->x
= x
;
849 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
850 draw_context_out
->current
->over
->y
= y_out
;
851 draw_context_out
->current
->under
->y
= y_out
+ height
;
852 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
853 draw_context_out
->previous
->over
->y
= y_out
;
854 draw_context_out
->previous
->under
->y
= y_out
+ height
;
856 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
857 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
859 if(process_out
->state
->s
== LTTV_STATE_RUN
)
861 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
862 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
863 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
865 PropertiesBG prop_bg
;
866 prop_bg
.color
= g_new(GdkColor
,1);
870 prop_bg
.color
->red
= 0x1515;
871 prop_bg
.color
->green
= 0x1515;
872 prop_bg
.color
->blue
= 0x8c8c;
875 prop_bg
.color
->red
= 0x4e4e;
876 prop_bg
.color
->green
= 0xa9a9;
877 prop_bg
.color
->blue
= 0xa4a4;
880 prop_bg
.color
->red
= 0x7a7a;
881 prop_bg
.color
->green
= 0x4a4a;
882 prop_bg
.color
->blue
= 0x8b8b;
885 prop_bg
.color
->red
= 0x8080;
886 prop_bg
.color
->green
= 0x7777;
887 prop_bg
.color
->blue
= 0x4747;
890 prop_bg
.color
->red
= 0xe7e7;
891 prop_bg
.color
->green
= 0xe7e7;
892 prop_bg
.color
->blue
= 0xe7e7;
895 g_debug("calling from draw_event");
896 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
897 g_free(prop_bg
.color
);
898 //gdk_gc_unref(draw_context_out->gc);
901 draw_context_out
->gc
= widget
->style
->black_gc
;
903 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
904 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
905 PropertiesText prop_text_out
;
906 prop_text_out
.foreground
= &colorfg_out
;
907 prop_text_out
.background
= &colorbg_out
;
908 prop_text_out
.size
= 6;
909 prop_text_out
.position
= OVER
;
911 /* color of text : status of the process */
912 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
914 prop_text_out
.foreground
->red
= 0xffff;
915 prop_text_out
.foreground
->green
= 0xffff;
916 prop_text_out
.foreground
->blue
= 0xffff;
918 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
920 prop_text_out
.foreground
->red
= 0x0fff;
921 prop_text_out
.foreground
->green
= 0xffff;
922 prop_text_out
.foreground
->blue
= 0xfff0;
924 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
926 prop_text_out
.foreground
->red
= 0xffff;
927 prop_text_out
.foreground
->green
= 0xffff;
928 prop_text_out
.foreground
->blue
= 0x0000;
930 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
932 prop_text_out
.foreground
->red
= 0xffff;
933 prop_text_out
.foreground
->green
= 0x0000;
934 prop_text_out
.foreground
->blue
= 0xffff;
936 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
938 prop_text_out
.foreground
->red
= 0xffff;
939 prop_text_out
.foreground
->green
= 0x0000;
940 prop_text_out
.foreground
->blue
= 0x0000;
942 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
944 prop_text_out
.foreground
->red
= 0x0000;
945 prop_text_out
.foreground
->green
= 0xffff;
946 prop_text_out
.foreground
->blue
= 0x0000;
950 prop_text_out
.foreground
->red
= 0xffff;
951 prop_text_out
.foreground
->green
= 0xffff;
952 prop_text_out
.foreground
->blue
= 0xffff;
956 /* Print status of the process : U, WF, WC, E, W, R */
957 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
958 prop_text_out
.text
= "U->";
959 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
960 prop_text_out
.text
= "WF->";
961 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
962 prop_text_out
.text
= "WC->";
963 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
964 prop_text_out
.text
= "E->";
965 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
966 prop_text_out
.text
= "W->";
967 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
968 prop_text_out
.text
= "R->";
970 prop_text_out
.text
= "U";
972 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
973 //gdk_gc_unref(draw_context_out->gc);
975 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
976 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
977 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
979 PropertiesLine prop_line_out
;
980 prop_line_out
.color
= g_new(GdkColor
,1);
981 prop_line_out
.line_width
= 2;
982 prop_line_out
.style
= GDK_LINE_SOLID
;
983 prop_line_out
.position
= MIDDLE
;
985 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
987 /* color of line : status of the process */
988 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
990 prop_line_out
.color
->red
= 0xffff;
991 prop_line_out
.color
->green
= 0xffff;
992 prop_line_out
.color
->blue
= 0xffff;
994 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
996 prop_line_out
.color
->red
= 0x0fff;
997 prop_line_out
.color
->green
= 0xffff;
998 prop_line_out
.color
->blue
= 0xfff0;
1000 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1002 prop_line_out
.color
->red
= 0xffff;
1003 prop_line_out
.color
->green
= 0xffff;
1004 prop_line_out
.color
->blue
= 0x0000;
1006 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1008 prop_line_out
.color
->red
= 0xffff;
1009 prop_line_out
.color
->green
= 0x0000;
1010 prop_line_out
.color
->blue
= 0xffff;
1012 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1014 prop_line_out
.color
->red
= 0xffff;
1015 prop_line_out
.color
->green
= 0x0000;
1016 prop_line_out
.color
->blue
= 0x0000;
1018 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1020 prop_line_out
.color
->red
= 0x0000;
1021 prop_line_out
.color
->green
= 0xffff;
1022 prop_line_out
.color
->blue
= 0x0000;
1026 prop_line_out
.color
->red
= 0xffff;
1027 prop_line_out
.color
->green
= 0xffff;
1028 prop_line_out
.color
->blue
= 0xffff;
1031 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1032 g_free(prop_line_out
.color
);
1033 //gdk_gc_unref(draw_context_out->gc);
1034 /* Note : finishing line will have to be added when trace read over. */
1036 /* Finally, update the drawing context of the pid_in. */
1038 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1039 draw_context_in
->current
->modify_over
->x
= x
;
1040 draw_context_in
->current
->modify_under
->x
= x
;
1041 draw_context_in
->current
->modify_over
->y
= y_in
;
1042 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1043 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1044 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1045 widget
= control_flow_data
->drawing
->drawing_area
;
1046 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1047 //draw_context_in->gc = widget->style->black_gc;
1048 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1049 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1051 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1052 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1054 /* Draw the line/bg of the in process */
1055 if(draw_context_in
->previous
->middle
->x
== -1)
1057 draw_context_in
->previous
->over
->x
=
1058 control_flow_data
->drawing
->damage_begin
;
1059 draw_context_in
->previous
->middle
->x
=
1060 control_flow_data
->drawing
->damage_begin
;
1061 draw_context_in
->previous
->under
->x
=
1062 control_flow_data
->drawing
->damage_begin
;
1064 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1068 draw_context_in
->current
->middle
->x
= x
;
1069 draw_context_in
->current
->over
->x
= x
;
1070 draw_context_in
->current
->under
->x
= x
;
1071 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1072 draw_context_in
->current
->over
->y
= y_in
;
1073 draw_context_in
->current
->under
->y
= y_in
+ height
;
1074 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1075 draw_context_in
->previous
->over
->y
= y_in
;
1076 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1078 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1079 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1082 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1084 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1085 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1086 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1088 PropertiesBG prop_bg
;
1089 prop_bg
.color
= g_new(GdkColor
,1);
1091 switch(tfc
->index
) {
1093 prop_bg
.color
->red
= 0x1515;
1094 prop_bg
.color
->green
= 0x1515;
1095 prop_bg
.color
->blue
= 0x8c8c;
1098 prop_bg
.color
->red
= 0x4e4e;
1099 prop_bg
.color
->green
= 0xa9a9;
1100 prop_bg
.color
->blue
= 0xa4a4;
1103 prop_bg
.color
->red
= 0x7a7a;
1104 prop_bg
.color
->green
= 0x4a4a;
1105 prop_bg
.color
->blue
= 0x8b8b;
1108 prop_bg
.color
->red
= 0x8080;
1109 prop_bg
.color
->green
= 0x7777;
1110 prop_bg
.color
->blue
= 0x4747;
1113 prop_bg
.color
->red
= 0xe7e7;
1114 prop_bg
.color
->green
= 0xe7e7;
1115 prop_bg
.color
->blue
= 0xe7e7;
1119 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1120 g_free(prop_bg
.color
);
1121 //gdk_gc_unref(draw_context_in->gc);
1124 draw_context_in
->gc
= widget
->style
->black_gc
;
1126 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1127 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1128 PropertiesText prop_text_in
;
1129 prop_text_in
.foreground
= &colorfg_in
;
1130 prop_text_in
.background
= &colorbg_in
;
1131 prop_text_in
.size
= 6;
1132 prop_text_in
.position
= OVER
;
1134 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1135 /* foreground of text : status of the process */
1136 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1138 prop_text_in
.foreground
->red
= 0xffff;
1139 prop_text_in
.foreground
->green
= 0xffff;
1140 prop_text_in
.foreground
->blue
= 0xffff;
1142 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1144 prop_text_in
.foreground
->red
= 0x0fff;
1145 prop_text_in
.foreground
->green
= 0xffff;
1146 prop_text_in
.foreground
->blue
= 0xfff0;
1148 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1150 prop_text_in
.foreground
->red
= 0xffff;
1151 prop_text_in
.foreground
->green
= 0xffff;
1152 prop_text_in
.foreground
->blue
= 0x0000;
1154 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1156 prop_text_in
.foreground
->red
= 0xffff;
1157 prop_text_in
.foreground
->green
= 0x0000;
1158 prop_text_in
.foreground
->blue
= 0xffff;
1160 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1162 prop_text_in
.foreground
->red
= 0xffff;
1163 prop_text_in
.foreground
->green
= 0x0000;
1164 prop_text_in
.foreground
->blue
= 0x0000;
1166 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1168 prop_text_in
.foreground
->red
= 0x0000;
1169 prop_text_in
.foreground
->green
= 0xffff;
1170 prop_text_in
.foreground
->blue
= 0x0000;
1174 prop_text_in
.foreground
->red
= 0xffff;
1175 prop_text_in
.foreground
->green
= 0xffff;
1176 prop_text_in
.foreground
->blue
= 0xffff;
1181 /* Print status of the process : U, WF, WC, E, W, R */
1182 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1183 prop_text_in
.text
= "U->";
1184 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1185 prop_text_in
.text
= "WF->";
1186 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1187 prop_text_in
.text
= "WC->";
1188 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1189 prop_text_in
.text
= "E->";
1190 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1191 prop_text_in
.text
= "W->";
1192 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1193 prop_text_in
.text
= "R->";
1195 prop_text_in
.text
= "U";
1197 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1198 //gdk_gc_unref(draw_context_in->gc);
1200 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1201 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1202 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1204 PropertiesLine prop_line_in
;
1205 prop_line_in
.color
= g_new(GdkColor
,1);
1206 prop_line_in
.line_width
= 2;
1207 prop_line_in
.style
= GDK_LINE_SOLID
;
1208 prop_line_in
.position
= MIDDLE
;
1210 /* color of line : status of the process */
1211 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1213 prop_line_in
.color
->red
= 0xffff;
1214 prop_line_in
.color
->green
= 0xffff;
1215 prop_line_in
.color
->blue
= 0xffff;
1217 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1219 prop_line_in
.color
->red
= 0x0fff;
1220 prop_line_in
.color
->green
= 0xffff;
1221 prop_line_in
.color
->blue
= 0xfff0;
1223 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1225 prop_line_in
.color
->red
= 0xffff;
1226 prop_line_in
.color
->green
= 0xffff;
1227 prop_line_in
.color
->blue
= 0x0000;
1229 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1231 prop_line_in
.color
->red
= 0xffff;
1232 prop_line_in
.color
->green
= 0x0000;
1233 prop_line_in
.color
->blue
= 0xffff;
1235 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1237 prop_line_in
.color
->red
= 0xffff;
1238 prop_line_in
.color
->green
= 0x0000;
1239 prop_line_in
.color
->blue
= 0x0000;
1241 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1243 prop_line_in
.color
->red
= 0x0000;
1244 prop_line_in
.color
->green
= 0xffff;
1245 prop_line_in
.color
->blue
= 0x0000;
1249 prop_line_in
.color
->red
= 0xffff;
1250 prop_line_in
.color
->green
= 0xffff;
1251 prop_line_in
.color
->blue
= 0xffff;
1254 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1255 g_free(prop_line_in
.color
);
1256 //gdk_gc_unref(draw_context_in->gc);
1266 GString
*string
= g_string_new("");;
1267 gboolean field_names
= TRUE
, state
= TRUE
;
1269 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1270 g_string_append_printf(string
,"\n");
1273 g_string_append_printf(string
, " %s",
1274 g_quark_to_string(tfs
->process
->state
->s
));
1277 g_info("%s",string
->str
);
1279 g_string_free(string
, TRUE
);
1281 /* End of text dump */
1286 /* after_schedchange_hook
1288 * The draw after hook is called by the reading API to have a
1289 * particular event drawn on the screen.
1290 * @param hook_data ControlFlowData structure of the viewer.
1291 * @param call_data Event context.
1293 * This function adds items to be drawn in a queue for each process.
1296 int after_schedchange_hook(void *hook_data
, void *call_data
)
1298 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1299 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1301 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1303 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1304 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1309 LttTime evtime
= ltt_event_time(e
);
1310 TimeWindow time_window
=
1311 lttvwindow_get_time_window(control_flow_data
->tab
);
1313 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1314 time_window
.time_width
);
1316 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1317 || ltt_time_compare(evtime
, end_time
) == 1)
1320 guint width
= control_flow_data
->drawing
->width
;
1322 /* Add process to process list (if not present) */
1323 LttvProcessState
*process_out
, *process_in
;
1325 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1326 HashedProcessData
*hashed_process_data_in
= NULL
;
1328 ProcessList
*process_list
=
1329 guicontrolflow_get_process_list(control_flow_data
);
1334 LttField
*f
= ltt_event_field(e
);
1336 element
= ltt_field_member(f
,0);
1337 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1338 element
= ltt_field_member(f
,1);
1339 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1340 g_debug("out : %u in : %u", pid_out
, pid_in
);
1344 /* Find process pid_in in the list... */
1345 process_in
= lttv_state_find_process(tfs
, pid_in
);
1346 /* It should exist, because we are after the state update. */
1347 g_assert(process_in
!= NULL
);
1349 birth
= process_in
->creation_time
;
1350 const gchar
*name
= g_quark_to_string(process_in
->name
);
1352 if(processlist_get_process_pixels(process_list
,
1354 process_in
->last_cpu
,
1356 tfc
->t_context
->index
,
1359 &hashed_process_data_in
) == 1)
1361 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1362 /* Process not present */
1363 processlist_add(process_list
,
1365 process_in
->last_cpu
,
1368 tfc
->t_context
->index
,
1371 &hashed_process_data_in
);
1372 processlist_get_process_pixels(process_list
,
1374 process_in
->last_cpu
,
1376 tfc
->t_context
->index
,
1379 &hashed_process_data_in
);
1380 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1385 convert_time_to_pixels(
1386 time_window
.start_time
,
1392 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1393 hashed_process_data_in
->x
.middle
= new_x
;
1394 hashed_process_data_in
->x
.middle_used
= FALSE
;
1395 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1405 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1406 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1408 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1410 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1411 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1417 LttTime evtime
= ltt_event_time(e
);
1418 TimeWindow time_window
=
1419 lttvwindow_get_time_window(control_flow_data
->tab
);
1421 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1422 time_window
.time_width
);
1423 //if(time < time_beg || time > time_end) return;
1424 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1425 || ltt_time_compare(evtime
, end_time
) == 1)
1429 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1431 g_debug("schedchange!");
1433 /* Add process to process list (if not present) and get drawing "y" from
1434 * process position */
1435 guint pid_out
, pid_in
;
1436 LttvProcessState
*process_out
, *process_in
;
1438 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1440 ProcessList
*process_list
=
1441 guicontrolflow_get_process_list(control_flow_data
);
1444 LttField
*f
= ltt_event_field(e
);
1446 element
= ltt_field_member(f
,0);
1447 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1448 element
= ltt_field_member(f
,1);
1449 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1450 //g_debug("out : %u in : %u", pid_out, pid_in);
1453 /* Find process pid_out in the list... */
1454 process_out
= lttv_state_find_process(tfs
, pid_out
);
1455 if(process_out
== NULL
) return 0;
1456 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1458 birth
= process_out
->creation_time
;
1459 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1460 HashedProcessData
*hashed_process_data_out
= NULL
;
1462 if(processlist_get_process_pixels(process_list
,
1465 tfc
->t_context
->index
,
1468 &hashed_process_data_out
) == 1)
1470 /* Process not present */
1471 processlist_add(process_list
,
1474 tfc
->t_context
->index
,
1477 &hashed_process_data_out
);
1478 processlist_get_process_pixels(process_list
,
1481 tfc
->t_context
->index
,
1484 &hashed_process_data_out
);
1485 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1490 /* Find process pid_in in the list... */
1491 process_in
= lttv_state_find_process(tfs
, pid_in
);
1492 if(process_in
== NULL
) return 0;
1493 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1495 birth
= process_in
->creation_time
;
1496 name
= strdup(g_quark_to_string(process_in
->name
));
1497 HashedProcessData
*hashed_process_data_in
= NULL
;
1499 if(processlist_get_process_pixels(process_list
,
1502 tfc
->t_context
->index
,
1505 &hashed_process_data_in
) == 1)
1507 /* Process not present */
1508 processlist_add(process_list
,
1511 tfc
->t_context
->index
,
1514 &hashed_process_data_in
);
1515 processlist_get_process_pixels(process_list
,
1518 tfc
->t_context
->index
,
1521 &hashed_process_data_in
);
1523 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1528 /* Find pixels corresponding to time of the event. If the time does
1529 * not fit in the window, show a warning, not supposed to happend. */
1531 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1533 //LttTime time = ltt_event_time(e);
1535 //LttTime window_end = ltt_time_add(time_window->time_width,
1536 // time_window->start_time);
1539 //convert_time_to_pixels(
1540 // time_window->start_time,
1546 //assert(x <= width);
1548 /* draw what represents the event for outgoing process. */
1550 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1551 //draw_context_out->current->modify_over->x = x;
1552 draw_context_out
->current
->modify_over
->y
= y_out
;
1553 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1554 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1555 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1556 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1557 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1559 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1560 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1562 /*if(process_out->state->s == LTTV_STATE_RUN)
1564 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1565 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1566 PropertiesBG prop_bg;
1567 prop_bg.color = g_new(GdkColor,1);
1569 prop_bg.color->red = 0xffff;
1570 prop_bg.color->green = 0xffff;
1571 prop_bg.color->blue = 0xffff;
1573 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1574 g_free(prop_bg.color);
1575 gdk_gc_unref(draw_context_out->gc);
1578 draw_context_out
->gc
= widget
->style
->black_gc
;
1580 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1581 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1582 PropertiesText prop_text_out
;
1583 prop_text_out
.foreground
= &colorfg_out
;
1584 prop_text_out
.background
= &colorbg_out
;
1585 prop_text_out
.size
= 6;
1586 prop_text_out
.position
= OVER
;
1588 /* color of text : status of the process */
1589 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1591 prop_text_out
.foreground
->red
= 0xffff;
1592 prop_text_out
.foreground
->green
= 0xffff;
1593 prop_text_out
.foreground
->blue
= 0xffff;
1595 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1597 prop_text_out
.foreground
->red
= 0x0fff;
1598 prop_text_out
.foreground
->green
= 0xffff;
1599 prop_text_out
.foreground
->blue
= 0xfff0;
1601 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1603 prop_text_out
.foreground
->red
= 0xffff;
1604 prop_text_out
.foreground
->green
= 0xffff;
1605 prop_text_out
.foreground
->blue
= 0x0000;
1607 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1609 prop_text_out
.foreground
->red
= 0xffff;
1610 prop_text_out
.foreground
->green
= 0x0000;
1611 prop_text_out
.foreground
->blue
= 0xffff;
1613 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1615 prop_text_out
.foreground
->red
= 0xffff;
1616 prop_text_out
.foreground
->green
= 0x0000;
1617 prop_text_out
.foreground
->blue
= 0x0000;
1619 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1621 prop_text_out
.foreground
->red
= 0x0000;
1622 prop_text_out
.foreground
->green
= 0xffff;
1623 prop_text_out
.foreground
->blue
= 0x0000;
1627 prop_text_out
.foreground
->red
= 0xffff;
1628 prop_text_out
.foreground
->green
= 0xffff;
1629 prop_text_out
.foreground
->blue
= 0xffff;
1632 /* Print status of the process : U, WF, WC, E, W, R */
1633 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1634 prop_text_out
.text
= "U";
1635 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1636 prop_text_out
.text
= "WF";
1637 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1638 prop_text_out
.text
= "WC";
1639 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1640 prop_text_out
.text
= "E";
1641 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1642 prop_text_out
.text
= "W";
1643 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1644 prop_text_out
.text
= "R";
1646 prop_text_out
.text
= "U";
1648 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1650 //gdk_gc_unref(draw_context_out->gc);
1652 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1653 draw_context_out
->current
->over
->y
= y_out
;
1654 draw_context_out
->current
->under
->y
= y_out
+height
;
1655 draw_context_out
->current
->status
= process_out
->state
->s
;
1657 /* for pid_out : remove previous, Prev = current, new current (default) */
1658 g_free(draw_context_out
->previous
->modify_under
);
1659 g_free(draw_context_out
->previous
->modify_middle
);
1660 g_free(draw_context_out
->previous
->modify_over
);
1661 g_free(draw_context_out
->previous
->under
);
1662 g_free(draw_context_out
->previous
->middle
);
1663 g_free(draw_context_out
->previous
->over
);
1664 g_free(draw_context_out
->previous
);
1666 draw_context_out
->previous
= draw_context_out
->current
;
1668 draw_context_out
->current
= g_new(DrawInfo
,1);
1669 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1670 draw_context_out
->current
->over
->x
= -1;
1671 draw_context_out
->current
->over
->y
= -1;
1672 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1673 draw_context_out
->current
->middle
->x
= -1;
1674 draw_context_out
->current
->middle
->y
= -1;
1675 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1676 draw_context_out
->current
->under
->x
= -1;
1677 draw_context_out
->current
->under
->y
= -1;
1678 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1679 draw_context_out
->current
->modify_over
->x
= -1;
1680 draw_context_out
->current
->modify_over
->y
= -1;
1681 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1682 draw_context_out
->current
->modify_middle
->x
= -1;
1683 draw_context_out
->current
->modify_middle
->y
= -1;
1684 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1685 draw_context_out
->current
->modify_under
->x
= -1;
1686 draw_context_out
->current
->modify_under
->y
= -1;
1687 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1689 /* Finally, update the drawing context of the pid_in. */
1691 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1692 //draw_context_in->current->modify_over->x = x;
1693 draw_context_in
->current
->modify_over
->y
= y_in
;
1694 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1695 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1696 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1697 widget
= control_flow_data
->drawing
->drawing_area
;
1698 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1700 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1701 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1703 /*if(process_in->state->s == LTTV_STATE_RUN)
1705 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1706 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1707 PropertiesBG prop_bg;
1708 prop_bg.color = g_new(GdkColor,1);
1710 prop_bg.color->red = 0xffff;
1711 prop_bg.color->green = 0xffff;
1712 prop_bg.color->blue = 0xffff;
1714 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1715 g_free(prop_bg.color);
1716 gdk_gc_unref(draw_context_in->gc);
1719 draw_context_in
->gc
= widget
->style
->black_gc
;
1721 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1722 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1723 PropertiesText prop_text_in
;
1724 prop_text_in
.foreground
= &colorfg_in
;
1725 prop_text_in
.background
= &colorbg_in
;
1726 prop_text_in
.size
= 6;
1727 prop_text_in
.position
= OVER
;
1729 /* foreground of text : status of the process */
1730 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1732 prop_text_in
.foreground
->red
= 0xffff;
1733 prop_text_in
.foreground
->green
= 0xffff;
1734 prop_text_in
.foreground
->blue
= 0xffff;
1736 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1738 prop_text_in
.foreground
->red
= 0x0fff;
1739 prop_text_in
.foreground
->green
= 0xffff;
1740 prop_text_in
.foreground
->blue
= 0xfff0;
1742 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1744 prop_text_in
.foreground
->red
= 0xffff;
1745 prop_text_in
.foreground
->green
= 0xffff;
1746 prop_text_in
.foreground
->blue
= 0x0000;
1748 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1750 prop_text_in
.foreground
->red
= 0xffff;
1751 prop_text_in
.foreground
->green
= 0x0000;
1752 prop_text_in
.foreground
->blue
= 0xffff;
1754 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1756 prop_text_in
.foreground
->red
= 0xffff;
1757 prop_text_in
.foreground
->green
= 0x0000;
1758 prop_text_in
.foreground
->blue
= 0x0000;
1760 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1762 prop_text_in
.foreground
->red
= 0x0000;
1763 prop_text_in
.foreground
->green
= 0xffff;
1764 prop_text_in
.foreground
->blue
= 0x0000;
1768 prop_text_in
.foreground
->red
= 0xffff;
1769 prop_text_in
.foreground
->green
= 0xffff;
1770 prop_text_in
.foreground
->blue
= 0xffff;
1774 /* Print status of the process : U, WF, WC, E, W, R */
1775 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1776 prop_text_in
.text
= "U";
1777 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1778 prop_text_in
.text
= "WF";
1779 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1780 prop_text_in
.text
= "WC";
1781 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1782 prop_text_in
.text
= "E";
1783 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1784 prop_text_in
.text
= "W";
1785 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1786 prop_text_in
.text
= "R";
1788 prop_text_in
.text
= "U";
1790 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1793 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1796 prop_text_in
.foreground
= &colorfg_in
;
1797 prop_text_in
.background
= &colorbg_in
;
1798 prop_text_in
.foreground
->red
= 0xffff;
1799 prop_text_in
.foreground
->green
= 0xffff;
1800 prop_text_in
.foreground
->blue
= 0xffff;
1801 prop_text_in
.size
= 6;
1802 prop_text_in
.position
= UNDER
;
1804 prop_text_in
.text
= g_new(gchar
, 260);
1805 strcpy(prop_text_in
.text
, "CPU ");
1806 snprintf(tmp
, 255, "%u", tfc
->index
);
1807 strcat(prop_text_in
.text
, tmp
);
1809 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1810 g_free(prop_text_in
.text
);
1814 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1815 draw_context_in
->current
->over
->y
= y_in
;
1816 draw_context_in
->current
->under
->y
= y_in
+height
;
1817 draw_context_in
->current
->status
= process_in
->state
->s
;
1819 /* for pid_in : remove previous, Prev = current, new current (default) */
1820 g_free(draw_context_in
->previous
->modify_under
);
1821 g_free(draw_context_in
->previous
->modify_middle
);
1822 g_free(draw_context_in
->previous
->modify_over
);
1823 g_free(draw_context_in
->previous
->under
);
1824 g_free(draw_context_in
->previous
->middle
);
1825 g_free(draw_context_in
->previous
->over
);
1826 g_free(draw_context_in
->previous
);
1828 draw_context_in
->previous
= draw_context_in
->current
;
1830 draw_context_in
->current
= g_new(DrawInfo
,1);
1831 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1832 draw_context_in
->current
->over
->x
= -1;
1833 draw_context_in
->current
->over
->y
= -1;
1834 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1835 draw_context_in
->current
->middle
->x
= -1;
1836 draw_context_in
->current
->middle
->y
= -1;
1837 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1838 draw_context_in
->current
->under
->x
= -1;
1839 draw_context_in
->current
->under
->y
= -1;
1840 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1841 draw_context_in
->current
->modify_over
->x
= -1;
1842 draw_context_in
->current
->modify_over
->y
= -1;
1843 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1844 draw_context_in
->current
->modify_middle
->x
= -1;
1845 draw_context_in
->current
->modify_middle
->y
= -1;
1846 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1847 draw_context_in
->current
->modify_under
->x
= -1;
1848 draw_context_in
->current
->modify_under
->y
= -1;
1849 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1858 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1860 PropertiesLine prop_line
;
1861 prop_line
.line_width
= 1;
1862 prop_line
.style
= GDK_LINE_SOLID
;
1864 //GdkColormap *colormap = gdk_colormap_get_system();
1866 /* color of line : execution mode of the process */
1867 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1868 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1869 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1870 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1871 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1872 prop_line
.color
= drawing_colors
[COL_TRAP
];
1873 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1874 prop_line
.color
= drawing_colors
[COL_IRQ
];
1875 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1876 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1878 prop_line
.color
= drawing_colors
[COL_WHITE
];
1880 //gdk_colormap_alloc_color(colormap,
1891 /* before_execmode_hook
1893 * This function basically draw lines and icons. Two types of lines are drawn :
1894 * one small (3 pixels?) representing the state of the process and the second
1895 * type is thicker (10 pixels?) representing on which CPU a process is running
1896 * (and this only in running state).
1898 * Extremums of the lines :
1899 * x_min : time of the last event context for this process kept in memory.
1900 * x_max : time of the current event.
1901 * y : middle of the process in the process list. The process is found in the
1902 * list, therefore is it's position in pixels.
1904 * The choice of lines'color is defined by the context of the last event for this
1909 int before_execmode_hook(void *hook_data
, void *call_data
)
1911 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1912 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1913 Drawing_t
*drawing
= control_flow_data
->drawing
;
1915 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1917 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1918 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1923 LttTime evtime
= ltt_event_time(e
);
1924 TimeWindow time_window
=
1925 lttvwindow_get_time_window(control_flow_data
->tab
);
1927 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1928 time_window
.time_width
);
1930 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1931 || ltt_time_compare(evtime
, end_time
) == 1)
1934 guint width
= drawing
->width
;
1936 /* we are in a execmode, before the state update. We must draw the
1937 * items corresponding to the state before it changes : now is the right
1941 LttvProcessState
*process
= tfs
->process
;
1942 g_assert(process
!= NULL
);
1944 guint pid
= process
->pid
;
1946 /* Well, the process_out existed : we must get it in the process hash
1947 * or add it, and draw its items.
1949 /* Add process to process list (if not present) */
1950 guint y
= 0, height
= 0, pl_height
= 0;
1951 HashedProcessData
*hashed_process_data
= NULL
;
1952 ProcessList
*process_list
=
1953 guicontrolflow_get_process_list(control_flow_data
);
1954 LttTime birth
= process
->creation_time
;
1955 const gchar
*name
= g_quark_to_string(process
->name
);
1957 if(processlist_get_process_pixels(process_list
,
1961 tfc
->t_context
->index
,
1964 &hashed_process_data
) == 1)
1966 g_assert(pid
== 0 || pid
!= process
->ppid
);
1967 /* Process not present */
1968 processlist_add(process_list
,
1973 tfc
->t_context
->index
,
1976 &hashed_process_data
);
1977 processlist_get_process_pixels(process_list
,
1981 tfc
->t_context
->index
,
1984 &hashed_process_data
);
1985 drawing_insert_square( drawing
, y
, height
);
1988 /* Now, the process is in the state hash and our own process hash.
1989 * We definitely can draw the items related to the ending state.
1992 /* Check if the x position is unset. In can have been left unset by
1993 * a draw closure from a after chunk hook. This should never happen,
1994 * because it must be set by before chunk hook to the damage_begin
1997 g_assert(hashed_process_data
->x
.over
!= -1);
2001 convert_time_to_pixels(
2002 time_window
.start_time
,
2009 /* Jump over draw if we are at the same x position */
2010 if(x
== hashed_process_data
->x
.middle
&&
2011 hashed_process_data
->x
.middle_used
)
2013 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2014 /* Draw collision indicator */
2015 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2016 gdk_draw_point(drawing
->pixmap
,
2024 DrawContext draw_context
;
2025 /* Now create the drawing context that will be used to draw
2026 * items related to the last state. */
2027 draw_context
.drawable
= drawing
->pixmap
;
2028 draw_context
.gc
= drawing
->gc
;
2029 draw_context
.pango_layout
= drawing
->pango_layout
;
2030 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2031 draw_context
.drawinfo
.end
.x
= x
;
2033 draw_context
.drawinfo
.y
.over
= y
+1;
2034 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2035 draw_context
.drawinfo
.y
.under
= y
+height
;
2037 draw_context
.drawinfo
.start
.offset
.over
= 0;
2038 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2039 draw_context
.drawinfo
.start
.offset
.under
= 0;
2040 draw_context
.drawinfo
.end
.offset
.over
= 0;
2041 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2042 draw_context
.drawinfo
.end
.offset
.under
= 0;
2046 PropertiesLine prop_line
= prepare_s_e_line(process
);
2047 draw_line((void*)&prop_line
, (void*)&draw_context
);
2050 /* become the last x position */
2051 hashed_process_data
->x
.middle
= x
;
2052 hashed_process_data
->x
.middle_used
= TRUE
;
2053 hashed_process_data
->x
.middle_marked
= FALSE
;
2060 /* after_execmode_hook
2062 * The draw after hook is called by the reading API to have a
2063 * particular event drawn on the screen.
2064 * @param hook_data ControlFlowData structure of the viewer.
2065 * @param call_data Event context.
2067 * This function adds items to be drawn in a queue for each process.
2070 int after_execmode_hook(void *hook_data
, void *call_data
)
2072 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2073 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2075 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2077 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2078 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2083 LttTime evtime
= ltt_event_time(e
);
2084 TimeWindow time_window
=
2085 lttvwindow_get_time_window(control_flow_data
->tab
);
2087 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2088 time_window
.time_width
);
2090 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2091 || ltt_time_compare(evtime
, end_time
) == 1)
2094 guint width
= control_flow_data
->drawing
->width
;
2096 /* Add process to process list (if not present) */
2097 LttvProcessState
*process
;
2099 guint y
= 0, height
= 0, pl_height
= 0;
2100 HashedProcessData
*hashed_process_data
= NULL
;
2102 ProcessList
*process_list
=
2103 guicontrolflow_get_process_list(control_flow_data
);
2106 /* Find process pid_in in the list... */
2107 process
= tfs
->process
;
2108 /* It should exist, because we are after the state update. */
2109 g_assert(process
!= NULL
);
2111 guint pid
= process
->pid
;
2113 birth
= process
->creation_time
;
2114 const gchar
*name
= g_quark_to_string(process
->name
);
2116 if(processlist_get_process_pixels(process_list
,
2120 tfc
->t_context
->index
,
2123 &hashed_process_data
) == 1)
2125 g_assert(pid
== 0 || pid
!= process
->ppid
);
2126 /* Process not present */
2127 processlist_add(process_list
,
2132 tfc
->t_context
->index
,
2135 &hashed_process_data
);
2136 processlist_get_process_pixels(process_list
,
2140 tfc
->t_context
->index
,
2143 &hashed_process_data
);
2144 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2149 convert_time_to_pixels(
2150 time_window
.start_time
,
2156 if(hashed_process_data
->x
.middle
!= new_x
) {
2157 hashed_process_data
->x
.middle
= new_x
;
2158 hashed_process_data
->x
.middle_used
= FALSE
;
2159 hashed_process_data
->x
.middle_marked
= FALSE
;
2167 /* before_process_hook
2169 * Draw lines for process event.
2171 * @param hook_data ControlFlowData structure of the viewer.
2172 * @param call_data Event context.
2174 * This function adds items to be drawn in a queue for each process.
2177 int before_process_hook(void *hook_data
, void *call_data
)
2179 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2180 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2181 Drawing_t
*drawing
= control_flow_data
->drawing
;
2183 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2185 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2186 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2191 LttTime evtime
= ltt_event_time(e
);
2192 TimeWindow time_window
=
2193 lttvwindow_get_time_window(control_flow_data
->tab
);
2195 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2196 time_window
.time_width
);
2198 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2199 || ltt_time_compare(evtime
, end_time
) == 1)
2202 guint width
= control_flow_data
->drawing
->width
;
2206 LttField
*f
= ltt_event_field(e
);
2208 element
= ltt_field_member(f
,0);
2209 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2212 if(sub_id
== 3) { /* exit */
2214 /* Add process to process list (if not present) */
2215 LttvProcessState
*process
= tfs
->process
;
2216 guint pid
= process
->pid
;
2218 guint y
= 0, height
= 0, pl_height
= 0;
2219 HashedProcessData
*hashed_process_data
= NULL
;
2221 ProcessList
*process_list
=
2222 guicontrolflow_get_process_list(control_flow_data
);
2224 g_assert(process
!= NULL
);
2226 birth
= process
->creation_time
;
2227 const gchar
*name
= g_quark_to_string(process
->name
);
2229 if(processlist_get_process_pixels(process_list
,
2233 tfc
->t_context
->index
,
2236 &hashed_process_data
) == 1)
2238 g_assert(pid
== 0 || pid
!= process
->ppid
);
2239 /* Process not present */
2240 processlist_add(process_list
,
2245 tfc
->t_context
->index
,
2248 &hashed_process_data
);
2249 processlist_get_process_pixels(process_list
,
2253 tfc
->t_context
->index
,
2256 &hashed_process_data
);
2257 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2260 /* Now, the process is in the state hash and our own process hash.
2261 * We definitely can draw the items related to the ending state.
2264 /* Check if the x position is unset. In can have been left unset by
2265 * a draw closure from a after chunk hook. This should never happen,
2266 * because it must be set by before chunk hook to the damage_begin
2269 g_assert(hashed_process_data
->x
.over
!= -1);
2273 convert_time_to_pixels(
2274 time_window
.start_time
,
2281 /* Jump over draw if we are at the same x position */
2282 if(x
== hashed_process_data
->x
.middle
&&
2283 hashed_process_data
->x
.middle_used
)
2285 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2286 /* Draw collision indicator */
2287 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2288 gdk_draw_point(drawing
->pixmap
,
2295 DrawContext draw_context
;
2297 /* Now create the drawing context that will be used to draw
2298 * items related to the last state. */
2299 draw_context
.drawable
= drawing
->pixmap
;
2300 draw_context
.gc
= drawing
->gc
;
2301 draw_context
.pango_layout
= drawing
->pango_layout
;
2302 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2303 draw_context
.drawinfo
.end
.x
= x
;
2305 draw_context
.drawinfo
.y
.over
= y
+1;
2306 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2307 draw_context
.drawinfo
.y
.under
= y
+height
;
2309 draw_context
.drawinfo
.start
.offset
.over
= 0;
2310 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2311 draw_context
.drawinfo
.start
.offset
.under
= 0;
2312 draw_context
.drawinfo
.end
.offset
.over
= 0;
2313 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2314 draw_context
.drawinfo
.end
.offset
.under
= 0;
2318 PropertiesLine prop_line
= prepare_s_e_line(process
);
2319 draw_line((void*)&prop_line
, (void*)&draw_context
);
2322 /* become the last x position */
2323 hashed_process_data
->x
.middle
= x
;
2324 hashed_process_data
->x
.middle_used
= TRUE
;
2325 hashed_process_data
->x
.middle_marked
= FALSE
;
2339 /* after_process_hook
2341 * Create the processlist entry for the child process. Put the last
2342 * position in x at the current time value.
2344 * @param hook_data ControlFlowData structure of the viewer.
2345 * @param call_data Event context.
2347 * This function adds items to be drawn in a queue for each process.
2350 int after_process_hook(void *hook_data
, void *call_data
)
2352 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2353 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2355 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2357 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2358 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2363 LttTime evtime
= ltt_event_time(e
);
2364 TimeWindow time_window
=
2365 lttvwindow_get_time_window(control_flow_data
->tab
);
2367 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2368 time_window
.time_width
);
2370 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2371 || ltt_time_compare(evtime
, end_time
) == 1)
2374 guint width
= control_flow_data
->drawing
->width
;
2379 LttField
*f
= ltt_event_field(e
);
2381 element
= ltt_field_member(f
,0);
2382 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2383 element
= ltt_field_member(f
,1);
2384 param1
= ltt_event_get_long_unsigned(e
,element
);
2387 if(sub_id
== 2) { /* fork */
2389 guint child_pid
= param1
;
2390 /* Add process to process list (if not present) */
2391 LttvProcessState
*process_child
;
2393 guint y_child
= 0, height
= 0, pl_height
= 0;
2394 HashedProcessData
*hashed_process_data_child
= NULL
;
2396 ProcessList
*process_list
=
2397 guicontrolflow_get_process_list(control_flow_data
);
2400 /* Find child in the list... */
2401 process_child
= lttv_state_find_process(tfs
, child_pid
);
2402 /* It should exist, because we are after the state update. */
2403 g_assert(process_child
!= NULL
);
2405 birth
= process_child
->creation_time
;
2406 const gchar
*name
= g_quark_to_string(process_child
->name
);
2408 if(processlist_get_process_pixels(process_list
,
2410 process_child
->last_cpu
,
2412 tfc
->t_context
->index
,
2415 &hashed_process_data_child
) == 1)
2417 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2418 /* Process not present */
2419 processlist_add(process_list
,
2421 process_child
->last_cpu
,
2422 process_child
->ppid
,
2424 tfc
->t_context
->index
,
2427 &hashed_process_data_child
);
2428 processlist_get_process_pixels(process_list
,
2430 process_child
->last_cpu
,
2432 tfc
->t_context
->index
,
2435 &hashed_process_data_child
);
2436 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2440 convert_time_to_pixels(
2441 time_window
.start_time
,
2447 if(hashed_process_data_child
->x
.over
!= new_x
) {
2448 hashed_process_data_child
->x
.over
= new_x
;
2449 hashed_process_data_child
->x
.over_used
= FALSE
;
2450 hashed_process_data_child
->x
.over_marked
= FALSE
;
2452 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2453 hashed_process_data_child
->x
.middle
= new_x
;
2454 hashed_process_data_child
->x
.middle_used
= FALSE
;
2455 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2457 if(hashed_process_data_child
->x
.under
!= new_x
) {
2458 hashed_process_data_child
->x
.under
= new_x
;
2459 hashed_process_data_child
->x
.under_used
= FALSE
;
2460 hashed_process_data_child
->x
.under_marked
= FALSE
;
2463 } else if(sub_id
== 3) { /* exit */
2465 /* Add process to process list (if not present) */
2466 LttvProcessState
*process
= tfs
->process
;
2467 guint pid
= process
->pid
;
2469 guint y
= 0, height
= 0, pl_height
= 0;
2470 HashedProcessData
*hashed_process_data
= NULL
;
2472 ProcessList
*process_list
=
2473 guicontrolflow_get_process_list(control_flow_data
);
2476 /* It should exist, because we are after the state update. */
2477 g_assert(process
!= NULL
);
2479 birth
= process
->creation_time
;
2480 const gchar
*name
= g_quark_to_string(process
->name
);
2482 if(processlist_get_process_pixels(process_list
,
2486 tfc
->t_context
->index
,
2489 &hashed_process_data
) == 1)
2491 g_assert(pid
== 0 || pid
!= process
->ppid
);
2492 /* Process not present */
2493 processlist_add(process_list
,
2498 tfc
->t_context
->index
,
2501 &hashed_process_data
);
2502 processlist_get_process_pixels(process_list
,
2506 tfc
->t_context
->index
,
2509 &hashed_process_data
);
2510 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2514 convert_time_to_pixels(
2515 time_window
.start_time
,
2520 if(hashed_process_data
->x
.middle
!= new_x
) {
2521 hashed_process_data
->x
.middle
= new_x
;
2522 hashed_process_data
->x
.middle_used
= FALSE
;
2523 hashed_process_data
->x
.middle_marked
= FALSE
;
2533 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2535 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2536 Drawing_t
*drawing
= control_flow_data
->drawing
;
2538 const TimeWindowNotifyData
*time_window_nofify_data
=
2539 ((const TimeWindowNotifyData
*)call_data
);
2541 TimeWindow
*old_time_window
=
2542 time_window_nofify_data
->old_time_window
;
2543 TimeWindow
*new_time_window
=
2544 time_window_nofify_data
->new_time_window
;
2546 /* Update the ruler */
2547 drawing_update_ruler(control_flow_data
->drawing
,
2551 /* Two cases : zoom in/out or scrolling */
2553 /* In order to make sure we can reuse the old drawing, the scale must
2554 * be the same and the new time interval being partly located in the
2555 * currently shown time interval. (reuse is only for scrolling)
2558 g_info("Old time window HOOK : %u, %u to %u, %u",
2559 old_time_window
->start_time
.tv_sec
,
2560 old_time_window
->start_time
.tv_nsec
,
2561 old_time_window
->time_width
.tv_sec
,
2562 old_time_window
->time_width
.tv_nsec
);
2564 g_info("New time window HOOK : %u, %u to %u, %u",
2565 new_time_window
->start_time
.tv_sec
,
2566 new_time_window
->start_time
.tv_nsec
,
2567 new_time_window
->time_width
.tv_sec
,
2568 new_time_window
->time_width
.tv_nsec
);
2570 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2571 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2573 /* Same scale (scrolling) */
2574 g_info("scrolling");
2575 LttTime
*ns
= &new_time_window
->start_time
;
2576 LttTime
*os
= &old_time_window
->start_time
;
2577 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
2578 old_time_window
->time_width
);
2579 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
2580 new_time_window
->time_width
);
2582 //if(ns<os+w && os+w<ns+w)
2583 //if(ns<old_end && os<ns)
2584 if(ltt_time_compare(*ns
, old_end
) == -1
2585 && ltt_time_compare(*os
, *ns
) == -1)
2587 g_info("scrolling near right");
2588 /* Scroll right, keep right part of the screen */
2590 guint width
= control_flow_data
->drawing
->width
;
2591 convert_time_to_pixels(
2598 /* Copy old data to new location */
2599 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2600 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2601 control_flow_data
->drawing
->pixmap
,
2604 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2606 if(drawing
->damage_begin
== drawing
->damage_end
)
2607 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2609 drawing
->damage_begin
= 0;
2611 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2613 /* Clear the data request background, but not SAFETY */
2614 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2615 //control_flow_data->drawing->drawing_area->style->black_gc,
2616 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2618 drawing
->damage_begin
+SAFETY
, 0,
2619 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2620 control_flow_data
->drawing
->height
);
2622 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2624 control_flow_data
->drawing
->width
,
2625 control_flow_data
->drawing
->height
);
2627 /* Get new data for the rest. */
2628 drawing_data_request(control_flow_data
->drawing
,
2629 &control_flow_data
->drawing
->pixmap
,
2630 drawing
->damage_begin
, 0,
2631 drawing
->damage_end
- drawing
->damage_begin
,
2632 control_flow_data
->drawing
->height
);
2635 //if(ns<os && os<ns+w)
2636 //if(ns<os && os<new_end)
2637 if(ltt_time_compare(*ns
,*os
) == -1
2638 && ltt_time_compare(*os
,new_end
) == -1)
2640 g_info("scrolling near left");
2641 /* Scroll left, keep left part of the screen */
2643 guint width
= control_flow_data
->drawing
->width
;
2644 convert_time_to_pixels(
2652 /* Copy old data to new location */
2653 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2654 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2655 control_flow_data
->drawing
->pixmap
,
2660 if(drawing
->damage_begin
== drawing
->damage_end
)
2661 drawing
->damage_end
= x
;
2663 drawing
->damage_end
=
2664 control_flow_data
->drawing
->width
;
2666 drawing
->damage_begin
= 0;
2668 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2669 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2671 drawing
->damage_begin
, 0,
2672 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2673 control_flow_data
->drawing
->height
);
2675 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2677 control_flow_data
->drawing
->width
,
2678 control_flow_data
->drawing
->height
);
2681 /* Get new data for the rest. */
2682 drawing_data_request(control_flow_data
->drawing
,
2683 &control_flow_data
->drawing
->pixmap
,
2684 drawing
->damage_begin
, 0,
2685 drawing
->damage_end
- drawing
->damage_begin
,
2686 control_flow_data
->drawing
->height
);
2689 if(ltt_time_compare(*ns
,*os
) == 0)
2691 g_info("not scrolling");
2693 g_info("scrolling far");
2694 /* Cannot reuse any part of the screen : far jump */
2697 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2698 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2701 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2702 control_flow_data
->drawing
->height
);
2704 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2706 control_flow_data
->drawing
->width
,
2707 control_flow_data
->drawing
->height
);
2709 drawing
->damage_begin
= 0;
2710 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2712 drawing_data_request(control_flow_data
->drawing
,
2713 &control_flow_data
->drawing
->pixmap
,
2715 control_flow_data
->drawing
->width
,
2716 control_flow_data
->drawing
->height
);
2722 /* Different scale (zoom) */
2725 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2726 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2729 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2730 control_flow_data
->drawing
->height
);
2732 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2734 control_flow_data
->drawing
->width
,
2735 control_flow_data
->drawing
->height
);
2737 drawing
->damage_begin
= 0;
2738 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2740 drawing_data_request(control_flow_data
->drawing
,
2741 &control_flow_data
->drawing
->pixmap
,
2743 control_flow_data
->drawing
->width
,
2744 control_flow_data
->drawing
->height
);
2752 gint
traceset_notify(void *hook_data
, void *call_data
)
2754 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2755 Drawing_t
*drawing
= control_flow_data
->drawing
;
2756 GtkWidget
*widget
= drawing
->drawing_area
;
2759 drawing_clear(control_flow_data
->drawing
);
2760 processlist_clear(control_flow_data
->process_list
);
2761 redraw_notify(control_flow_data
, NULL
);
2763 request_background_data(control_flow_data
);
2765 drawing
->damage_begin
= 0;
2766 drawing
->damage_end
= drawing
->width
;
2767 if(drawing
->damage_begin
< drawing
->damage_end
)
2769 drawing_data_request(drawing
,
2771 drawing
->damage_begin
,
2773 drawing
->damage_end
-drawing
->damage_begin
,
2777 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2786 gint
redraw_notify(void *hook_data
, void *call_data
)
2788 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2789 Drawing_t
*drawing
= control_flow_data
->drawing
;
2790 GtkWidget
*widget
= drawing
->drawing_area
;
2792 drawing
->damage_begin
= 0;
2793 drawing
->damage_end
= drawing
->width
;
2795 /* fun feature, to be separated someday... */
2796 drawing_clear(control_flow_data
->drawing
);
2797 processlist_clear(control_flow_data
->process_list
);
2800 gdk_draw_rectangle (drawing
->pixmap
,
2801 widget
->style
->black_gc
,
2804 drawing
->width
+SAFETY
,
2808 if(drawing
->damage_begin
< drawing
->damage_end
)
2810 drawing_data_request(drawing
,
2812 drawing
->damage_begin
,
2814 drawing
->damage_end
-drawing
->damage_begin
,
2818 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2827 gint
continue_notify(void *hook_data
, void *call_data
)
2829 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2830 Drawing_t
*drawing
= control_flow_data
->drawing
;
2831 GtkWidget
*widget
= drawing
->drawing_area
;
2833 //g_assert(widget->allocation.width == drawing->damage_end);
2835 if(drawing
->damage_begin
< drawing
->damage_end
)
2837 drawing_data_request(drawing
,
2839 drawing
->damage_begin
,
2841 drawing
->damage_end
-drawing
->damage_begin
,
2849 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2851 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2852 Drawing_t
*drawing
= control_flow_data
->drawing
;
2854 LttTime current_time
= *((LttTime
*)call_data
);
2856 TimeWindow time_window
=
2857 lttvwindow_get_time_window(control_flow_data
->tab
);
2859 LttTime time_begin
= time_window
.start_time
;
2860 LttTime width
= time_window
.time_width
;
2863 guint64 time_ll
= ltt_time_to_uint64(width
);
2864 time_ll
= time_ll
>> 1; /* divide by two */
2865 half_width
= ltt_time_from_uint64(time_ll
);
2867 LttTime time_end
= ltt_time_add(time_begin
, width
);
2869 LttvTracesetContext
* tsc
=
2870 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2872 LttTime trace_start
= tsc
->time_span
.start_time
;
2873 LttTime trace_end
= tsc
->time_span
.end_time
;
2875 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2876 current_time
.tv_nsec
);
2880 /* If current time is inside time interval, just move the highlight
2883 /* Else, we have to change the time interval. We have to tell it
2884 * to the main window. */
2885 /* The time interval change will take care of placing the current
2886 * time at the center of the visible area, or nearest possible if we are
2887 * at one end of the trace. */
2890 if(ltt_time_compare(current_time
, time_begin
) == -1)
2892 TimeWindow new_time_window
;
2894 if(ltt_time_compare(current_time
,
2895 ltt_time_add(trace_start
,half_width
)) == -1)
2896 time_begin
= trace_start
;
2898 time_begin
= ltt_time_sub(current_time
,half_width
);
2900 new_time_window
.start_time
= time_begin
;
2901 new_time_window
.time_width
= width
;
2903 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2905 else if(ltt_time_compare(current_time
, time_end
) == 1)
2907 TimeWindow new_time_window
;
2909 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2910 time_begin
= ltt_time_sub(trace_end
,width
);
2912 time_begin
= ltt_time_sub(current_time
,half_width
);
2914 new_time_window
.start_time
= time_begin
;
2915 new_time_window
.time_width
= width
;
2917 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2920 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2921 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2929 typedef struct _ClosureData
{
2930 EventsRequest
*events_request
;
2931 LttvTracesetState
*tss
;
2936 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2938 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2939 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2940 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2942 EventsRequest
*events_request
= closure_data
->events_request
;
2943 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2944 Drawing_t
*drawing
= control_flow_data
->drawing
;
2946 LttvTracesetState
*tss
= closure_data
->tss
;
2947 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2949 LttTime evtime
= closure_data
->end_time
;
2950 TimeWindow time_window
=
2951 lttvwindow_get_time_window(control_flow_data
->tab
);
2953 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2954 time_window
.time_width
);
2956 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2957 || ltt_time_compare(evtime
, end_time
) == 1)
2960 guint width
= drawing
->width
;
2963 /* For the process */
2964 /* First, check if the current process is in the state computation
2965 * process list. If it is there, that means we must add it right now and
2966 * draw items from the beginning of the read for it. If it is not
2967 * present, it's a new process and it was not present : it will
2968 * be added after the state update. */
2969 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2971 /* tracefiles[0] is ok here, because we draw for every PID, and
2972 * assume CPU 0 for PID 0 //FIXME */
2973 LttvTracefileState
*tfs
=
2974 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2976 LttvProcessState
*process
;
2977 process
= lttv_state_find_process(tfs
,
2980 if(process
!= NULL
) {
2982 /* Only draw for processes that are currently in the trace states */
2984 guint y
= 0, height
= 0, pl_height
= 0;
2985 ProcessList
*process_list
=
2986 guicontrolflow_get_process_list(control_flow_data
);
2987 LttTime birth
= process_info
->birth
;
2989 /* Should be alike when background info is ready */
2990 if(control_flow_data
->background_info_waiting
==0)
2991 g_assert(ltt_time_compare(process
->creation_time
,
2992 process_info
->birth
) == 0);
2993 const gchar
*name
= g_quark_to_string(process
->name
);
2995 /* process HAS to be present */
2996 g_assert(processlist_get_process_pixels(process_list
,
3000 process_info
->trace_num
,
3003 &hashed_process_data
) != 1);
3005 /* Now, the process is in the state hash and our own process hash.
3006 * We definitely can draw the items related to the ending state.
3009 /* Check if the x position is unset. In can have been left unset by
3010 * a draw closure from a after chunk hook. This should never happen,
3011 * because it must be set by before chunk hook to the damage_begin
3014 g_assert(hashed_process_data
->x
.over
!= -1);
3018 convert_time_to_pixels(
3019 time_window
.start_time
,
3025 DrawContext draw_context
;
3027 /* Now create the drawing context that will be used to draw
3028 * items related to the last state. */
3029 draw_context
.drawable
= drawing
->pixmap
;
3030 draw_context
.gc
= drawing
->gc
;
3031 draw_context
.pango_layout
= drawing
->pango_layout
;
3032 draw_context
.drawinfo
.end
.x
= x
;
3034 draw_context
.drawinfo
.y
.over
= y
+1;
3035 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3036 draw_context
.drawinfo
.y
.under
= y
+height
;
3038 draw_context
.drawinfo
.start
.offset
.over
= 0;
3039 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3040 draw_context
.drawinfo
.start
.offset
.under
= 0;
3041 draw_context
.drawinfo
.end
.offset
.over
= 0;
3042 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3043 draw_context
.drawinfo
.end
.offset
.under
= 0;
3045 /* Jump over draw if we are at the same x position */
3046 if(x
== hashed_process_data
->x
.over
)
3050 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3052 PropertiesLine prop_line
= prepare_execmode_line(process
);
3053 draw_line((void*)&prop_line
, (void*)&draw_context
);
3055 hashed_process_data
->x
.over
= x
;
3059 if(x
== hashed_process_data
->x
.middle
&&
3060 hashed_process_data
->x
.middle_used
) {
3061 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3062 /* Draw collision indicator */
3063 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3064 gdk_draw_point(drawing
->pixmap
,
3067 draw_context
.drawinfo
.y
.over
);
3071 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3073 PropertiesLine prop_line
= prepare_s_e_line(process
);
3074 draw_line((void*)&prop_line
, (void*)&draw_context
);
3076 /* become the last x position */
3077 if(x
!= hashed_process_data
->x
.middle
) {
3078 hashed_process_data
->x
.middle
= x
;
3079 /* but don't use the pixel */
3080 hashed_process_data
->x
.middle_used
= FALSE
;
3089 int before_chunk(void *hook_data
, void *call_data
)
3091 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3092 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3094 drawing_chunk_begin(events_request
, tss
);
3099 int before_request(void *hook_data
, void *call_data
)
3101 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3102 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3104 drawing_data_request_begin(events_request
, tss
);
3111 * after request is necessary in addition of after chunk in order to draw
3112 * lines until the end of the screen. after chunk just draws lines until
3119 int after_request(void *hook_data
, void *call_data
)
3121 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3122 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3123 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3124 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3126 ProcessList
*process_list
=
3127 guicontrolflow_get_process_list(control_flow_data
);
3128 LttTime end_time
= events_request
->end_time
;
3130 ClosureData closure_data
;
3131 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3132 closure_data
.tss
= tss
;
3133 closure_data
.end_time
= end_time
;
3135 /* Draw last items */
3136 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3137 (void*)&closure_data
);
3139 /* Request expose */
3140 drawing_request_expose(events_request
, tss
, end_time
);
3149 int after_chunk(void *hook_data
, void *call_data
)
3151 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3152 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3153 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3154 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3155 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3158 ProcessList
*process_list
=
3159 guicontrolflow_get_process_list(control_flow_data
);
3162 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3163 else /* end of traceset, or position now out of request : end */
3164 end_time
= events_request
->end_time
;
3166 ClosureData closure_data
;
3167 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3168 closure_data
.tss
= tss
;
3169 closure_data
.end_time
= end_time
;
3171 /* Draw last items */
3172 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3173 (void*)&closure_data
);
3175 /* Request expose */
3176 drawing_request_expose(events_request
, tss
, end_time
);