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
52 //#define PANGO_ENABLE_BACKEND
60 //#include <pango/pango.h>
62 #include <ltt/event.h>
66 #include <lttv/lttv.h>
67 #include <lttv/hook.h>
68 #include <lttv/state.h>
69 #include <lttvwindow/lttvwindow.h>
70 #include <lttvwindow/lttvwindowtraces.h>
73 #include "eventhooks.h"
75 #include "processlist.h"
79 #define MAX_PATH_LEN 256
83 typedef struct _ProcessAddClosure
{
88 static void process_add(gpointer key
,
92 LttvProcessState
*process
= (LttvProcessState
*)value
;
93 ProcessAddClosure
*closure
= (ProcessAddClosure
*)user_data
;
94 ControlFlowData
*control_flow_data
= closure
->cfd
;
95 guint trace_num
= closure
->trace_num
;
97 /* Add process to process list (if not present) */
100 guint y
= 0, height
= 0, pl_height
= 0;
102 ProcessList
*process_list
= control_flow_data
->process_list
;
105 birth
= process
->creation_time
;
106 const gchar
*name
= g_quark_to_string(process
->name
);
107 HashedProcessData
*hashed_process_data
= NULL
;
109 if(processlist_get_process_pixels(process_list
,
115 &hashed_process_data
) == 1)
117 /* Process not present */
118 processlist_add(process_list
,
124 &hashed_process_data
);
125 processlist_get_process_pixels(process_list
,
131 &hashed_process_data
);
132 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
138 /* Action to do when background computation completed.
140 * Wait for all the awaited computations to be over.
143 gint
background_ready(void *hook_data
, void *call_data
)
145 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
146 LttvTrace
*trace
= (LttvTrace
*)call_data
;
148 control_flow_data
->background_info_waiting
--;
150 if(control_flow_data
->background_info_waiting
== 0) {
151 g_debug("control flow viewer : background computation data ready.");
153 drawing_clear(control_flow_data
->drawing
);
154 processlist_clear(control_flow_data
->process_list
);
155 gtk_widget_set_size_request(
156 control_flow_data
->drawing
->drawing_area
,
157 -1, processlist_get_height(control_flow_data
->process_list
));
158 redraw_notify(control_flow_data
, NULL
);
165 /* Request background computation. Verify if it is in progress or ready first.
166 * Only for each trace in the tab's traceset.
168 void request_background_data(ControlFlowData
*control_flow_data
)
170 LttvTracesetContext
* tsc
=
171 lttvwindow_get_traceset_context(control_flow_data
->tab
);
172 gint num_traces
= lttv_traceset_number(tsc
->ts
);
176 LttvHooks
*background_ready_hook
=
178 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
180 control_flow_data
->background_info_waiting
= 0;
182 for(i
=0;i
<num_traces
;i
++) {
183 trace
= lttv_traceset_get(tsc
->ts
, i
);
185 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
187 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
189 /* We first remove requests that could have been done for the same
190 * information. Happens when two viewers ask for it before servicing
193 lttvwindowtraces_background_request_remove(trace
, "state");
194 lttvwindowtraces_background_request_queue(trace
,
196 lttvwindowtraces_background_notify_queue(control_flow_data
,
200 background_ready_hook
);
201 control_flow_data
->background_info_waiting
++;
202 } else { /* in progress */
204 lttvwindowtraces_background_notify_current(control_flow_data
,
208 background_ready_hook
);
209 control_flow_data
->background_info_waiting
++;
212 /* Data ready. Be its nature, this viewer doesn't need to have
213 * its data ready hook called htere, because a background
214 * request is always linked with a redraw.
220 lttv_hooks_destroy(background_ready_hook
);
227 * Event Viewer's constructor hook
229 * This constructor is given as a parameter to the menuitem and toolbar button
230 * registration. It creates the list.
231 * @param tab A pointer to the parent tab.
232 * @return The widget created.
235 h_guicontrolflow(Tab
*tab
)
237 g_info("h_guicontrolflow, %p", tab
);
238 ControlFlowData
*control_flow_data
= guicontrolflow() ;
240 control_flow_data
->tab
= tab
;
242 // Unreg done in the GuiControlFlow_Destructor
243 lttvwindow_register_traceset_notify(tab
,
247 lttvwindow_register_time_window_notify(tab
,
248 update_time_window_hook
,
250 lttvwindow_register_current_time_notify(tab
,
251 update_current_time_hook
,
253 lttvwindow_register_redraw_notify(tab
,
256 lttvwindow_register_continue_notify(tab
,
259 request_background_data(control_flow_data
);
262 return guicontrolflow_get_widget(control_flow_data
) ;
266 int event_selected_hook(void *hook_data
, void *call_data
)
268 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
269 guint
*event_number
= (guint
*) call_data
;
271 g_debug("DEBUG : event selected by main window : %u", *event_number
);
276 /* Function that selects the color of status&exemode line */
277 static inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
279 PropertiesLine prop_line
;
280 prop_line
.line_width
= 2;
281 prop_line
.style
= GDK_LINE_SOLID
;
282 prop_line
.y
= MIDDLE
;
283 //GdkColormap *colormap = gdk_colormap_get_system();
285 if(process
->state
->s
== LTTV_STATE_RUN
) {
286 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
287 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
288 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
289 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
290 else if(process
->state
->t
== LTTV_STATE_TRAP
)
291 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
292 else if(process
->state
->t
== LTTV_STATE_IRQ
)
293 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
294 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
295 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
297 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
298 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
299 /* We don't show if we wait while in user mode, trap, irq or syscall */
300 prop_line
.color
= drawing_colors
[COL_WAIT
];
301 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
302 /* We don't show if we wait for CPU while in user mode, trap, irq
304 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
305 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
306 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
307 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
308 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
309 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
310 prop_line
.color
= drawing_colors
[COL_EXIT
];
311 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
312 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
314 g_assert(FALSE
); /* UNKNOWN STATE */
321 static inline PropertiesLine
prepare_status_line(LttvProcessState
*process
)
323 PropertiesLine prop_line
;
324 prop_line
.line_width
= 2;
325 prop_line
.style
= GDK_LINE_SOLID
;
326 prop_line
.y
= MIDDLE
;
327 //GdkColormap *colormap = gdk_colormap_get_system();
329 g_debug("prepare_status_line for state : %s",
330 g_quark_to_string(process
->state
->s
));
332 /* color of line : status of the process */
333 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
334 prop_line
.color
= drawing_colors
[COL_WHITE
];
335 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
336 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
337 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
338 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
339 else if(process
->state
->s
== LTTV_STATE_EXIT
)
340 prop_line
.color
= drawing_colors
[COL_EXIT
];
341 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
342 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
343 else if(process
->state
->s
== LTTV_STATE_WAIT
)
344 prop_line
.color
= drawing_colors
[COL_WAIT
];
345 else if(process
->state
->s
== LTTV_STATE_RUN
)
346 prop_line
.color
= drawing_colors
[COL_RUN
];
348 prop_line
.color
= drawing_colors
[COL_WHITE
];
350 //gdk_colormap_alloc_color(colormap,
361 /* before_schedchange_hook
363 * This function basically draw lines and icons. Two types of lines are drawn :
364 * one small (3 pixels?) representing the state of the process and the second
365 * type is thicker (10 pixels?) representing on which CPU a process is running
366 * (and this only in running state).
368 * Extremums of the lines :
369 * x_min : time of the last event context for this process kept in memory.
370 * x_max : time of the current event.
371 * y : middle of the process in the process list. The process is found in the
372 * list, therefore is it's position in pixels.
374 * The choice of lines'color is defined by the context of the last event for this
379 int before_schedchange_hook(void *hook_data
, void *call_data
)
381 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
382 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
384 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
386 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
391 LttTime evtime
= ltt_event_time(e
);
393 /* we are in a schedchange, before the state update. We must draw the
394 * items corresponding to the state before it changes : now is the right
401 LttField
*f
= ltt_event_field(e
);
403 element
= ltt_field_member(f
,0);
404 pid_out
= ltt_event_get_long_unsigned(e
,element
);
405 element
= ltt_field_member(f
,1);
406 pid_in
= ltt_event_get_long_unsigned(e
,element
);
410 /* For the pid_out */
411 /* First, check if the current process is in the state computation
412 * process list. If it is there, that means we must add it right now and
413 * draw items from the beginning of the read for it. If it is not
414 * present, it's a new process and it was not present : it will
415 * be added after the state update. */
416 LttvProcessState
*process
;
417 /* unknown state, bad current pid */
418 if(tfs
->process
->pid
!= pid_out
)
419 process
= lttv_state_find_process(tfs
, pid_out
);
421 process
= tfs
->process
;
423 if(process
!= NULL
) {
424 /* Well, the process_out existed : we must get it in the process hash
425 * or add it, and draw its items.
427 /* Add process to process list (if not present) */
429 HashedProcessData
*hashed_process_data
= NULL
;
430 ProcessList
*process_list
= control_flow_data
->process_list
;
431 LttTime birth
= process
->creation_time
;
433 hashed_process_data
= processlist_get_process_data(process_list
,
435 process
->last_cpu_index
,
437 tfc
->t_context
->index
);
438 if(hashed_process_data
== NULL
)
440 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
441 const gchar
*name
= g_quark_to_string(process
->name
);
442 /* Process not present */
443 ProcessInfo
*process_info
;
444 Drawing_t
*drawing
= control_flow_data
->drawing
;
445 processlist_add(process_list
,
448 process
->last_cpu_index
,
451 tfc
->t_context
->index
,
455 &hashed_process_data
);
456 gtk_widget_set_size_request(drawing
->drawing_area
,
459 gtk_widget_queue_draw(drawing
->drawing_area
);
463 /* Now, the process is in the state hash and our own process hash.
464 * We definitely can draw the items related to the ending state.
467 if(ltt_time_compare(hashed_process_data
->next_good_time
,
470 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
472 TimeWindow time_window
=
473 lttvwindow_get_time_window(control_flow_data
->tab
);
475 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
476 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
479 Drawing_t
*drawing
= control_flow_data
->drawing
;
480 guint width
= drawing
->width
;
482 convert_time_to_pixels(
488 /* Draw collision indicator */
489 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
490 gdk_draw_point(hashed_process_data
->pixmap
,
493 (hashed_process_data
->height
/2)-3);
494 hashed_process_data
->x
.middle_marked
= TRUE
;
497 TimeWindow time_window
=
498 lttvwindow_get_time_window(control_flow_data
->tab
);
500 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
501 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
504 Drawing_t
*drawing
= control_flow_data
->drawing
;
505 guint width
= drawing
->width
;
507 convert_time_to_pixels(
514 /* Jump over draw if we are at the same x position */
515 if(x
== hashed_process_data
->x
.middle
&&
516 hashed_process_data
->x
.middle_used
)
518 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
519 /* Draw collision indicator */
520 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
521 gdk_draw_point(hashed_process_data
->pixmap
,
524 (hashed_process_data
->height
/2)-3);
525 hashed_process_data
->x
.middle_marked
= TRUE
;
529 DrawContext draw_context
;
531 /* Now create the drawing context that will be used to draw
532 * items related to the last state. */
533 draw_context
.drawable
= hashed_process_data
->pixmap
;
534 draw_context
.gc
= drawing
->gc
;
535 draw_context
.pango_layout
= drawing
->pango_layout
;
536 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
537 draw_context
.drawinfo
.end
.x
= x
;
539 draw_context
.drawinfo
.y
.over
= 1;
540 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
541 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
543 draw_context
.drawinfo
.start
.offset
.over
= 0;
544 draw_context
.drawinfo
.start
.offset
.middle
= 0;
545 draw_context
.drawinfo
.start
.offset
.under
= 0;
546 draw_context
.drawinfo
.end
.offset
.over
= 0;
547 draw_context
.drawinfo
.end
.offset
.middle
= 0;
548 draw_context
.drawinfo
.end
.offset
.under
= 0;
552 PropertiesLine prop_line
= prepare_s_e_line(process
);
553 draw_line((void*)&prop_line
, (void*)&draw_context
);
556 /* become the last x position */
557 hashed_process_data
->x
.middle
= x
;
558 hashed_process_data
->x
.middle_used
= TRUE
;
559 hashed_process_data
->x
.middle_marked
= FALSE
;
561 /* Calculate the next good time */
562 convert_pixels_to_time(width
, x
+1, time_window
,
563 &hashed_process_data
->next_good_time
);
571 /* First, check if the current process is in the state computation
572 * process list. If it is there, that means we must add it right now and
573 * draw items from the beginning of the read for it. If it is not
574 * present, it's a new process and it was not present : it will
575 * be added after the state update. */
576 LttvProcessState
*process
;
577 process
= lttv_state_find_process(tfs
, pid_in
);
579 if(process
!= NULL
) {
580 /* Well, the process_out existed : we must get it in the process hash
581 * or add it, and draw its items.
583 /* Add process to process list (if not present) */
585 HashedProcessData
*hashed_process_data
= NULL
;
586 ProcessList
*process_list
= control_flow_data
->process_list
;
587 LttTime birth
= process
->creation_time
;
589 hashed_process_data
= processlist_get_process_data(process_list
,
591 process
->last_cpu_index
,
593 tfc
->t_context
->index
);
594 if(hashed_process_data
== NULL
)
596 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
597 const gchar
*name
= g_quark_to_string(process
->name
);
598 /* Process not present */
599 ProcessInfo
*process_info
;
600 Drawing_t
*drawing
= control_flow_data
->drawing
;
601 processlist_add(process_list
,
604 process
->last_cpu_index
,
607 tfc
->t_context
->index
,
611 &hashed_process_data
);
612 gtk_widget_set_size_request(drawing
->drawing_area
,
615 gtk_widget_queue_draw(drawing
->drawing_area
);
618 //We could set the current process and hash here, but will be done
619 //by after schedchange hook
621 /* Now, the process is in the state hash and our own process hash.
622 * We definitely can draw the items related to the ending state.
625 if(ltt_time_compare(hashed_process_data
->next_good_time
,
628 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
630 TimeWindow time_window
=
631 lttvwindow_get_time_window(control_flow_data
->tab
);
633 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
634 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
637 Drawing_t
*drawing
= control_flow_data
->drawing
;
638 guint width
= drawing
->width
;
640 convert_time_to_pixels(
646 /* Draw collision indicator */
647 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
648 gdk_draw_point(hashed_process_data
->pixmap
,
651 (hashed_process_data
->height
/2)-3);
652 hashed_process_data
->x
.middle_marked
= TRUE
;
655 TimeWindow time_window
=
656 lttvwindow_get_time_window(control_flow_data
->tab
);
658 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
659 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
662 Drawing_t
*drawing
= control_flow_data
->drawing
;
663 guint width
= drawing
->width
;
666 convert_time_to_pixels(
673 /* Jump over draw if we are at the same x position */
674 if(x
== hashed_process_data
->x
.middle
&&
675 hashed_process_data
->x
.middle_used
)
677 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
678 /* Draw collision indicator */
679 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
680 gdk_draw_point(hashed_process_data
->pixmap
,
683 (hashed_process_data
->height
/2)-3);
684 hashed_process_data
->x
.middle_marked
= TRUE
;
688 DrawContext draw_context
;
690 /* Now create the drawing context that will be used to draw
691 * items related to the last state. */
692 draw_context
.drawable
= hashed_process_data
->pixmap
;
693 draw_context
.gc
= drawing
->gc
;
694 draw_context
.pango_layout
= drawing
->pango_layout
;
695 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
696 draw_context
.drawinfo
.end
.x
= x
;
698 draw_context
.drawinfo
.y
.over
= 1;
699 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
700 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
702 draw_context
.drawinfo
.start
.offset
.over
= 0;
703 draw_context
.drawinfo
.start
.offset
.middle
= 0;
704 draw_context
.drawinfo
.start
.offset
.under
= 0;
705 draw_context
.drawinfo
.end
.offset
.over
= 0;
706 draw_context
.drawinfo
.end
.offset
.middle
= 0;
707 draw_context
.drawinfo
.end
.offset
.under
= 0;
711 PropertiesLine prop_line
= prepare_s_e_line(process
);
712 draw_line((void*)&prop_line
, (void*)&draw_context
);
716 /* become the last x position */
717 hashed_process_data
->x
.middle
= x
;
718 hashed_process_data
->x
.middle_used
= TRUE
;
719 hashed_process_data
->x
.middle_marked
= FALSE
;
721 /* Calculate the next good time */
722 convert_pixels_to_time(width
, x
+1, time_window
,
723 &hashed_process_data
->next_good_time
);
732 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
733 ControlFlowData
*control_flow_data
=
734 (ControlFlowData
*)events_request
->viewer_data
;
735 Tab
*tab
= control_flow_data
->tab
;
737 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
739 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
740 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
745 LttTime evtime
= ltt_event_time(e
);
746 TimeWindow time_window
=
747 lttvwindow_get_time_window(tab
);
749 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
751 //if(time < time_beg || time > time_end) return;
752 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
753 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
756 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
758 g_debug("schedchange!");
760 /* Add process to process list (if not present) and get drawing "y" from
761 * process position */
762 guint pid_out
, pid_in
;
763 LttvProcessState
*process_out
, *process_in
;
765 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
767 ProcessList
*process_list
= control_flow_data
->process_list
;
770 LttField
*f
= ltt_event_field(e
);
772 element
= ltt_field_member(f
,0);
773 pid_out
= ltt_event_get_long_unsigned(e
,element
);
774 element
= ltt_field_member(f
,1);
775 pid_in
= ltt_event_get_long_unsigned(e
,element
);
776 g_debug("out : %u in : %u", pid_out
, pid_in
);
779 /* Find process pid_out in the list... */
780 process_out
= lttv_state_find_process(tfs
, pid_out
);
781 if(process_out
== NULL
) return 0;
782 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
784 birth
= process_out
->creation_time
;
785 const gchar
*name
= g_quark_to_string(process_out
->name
);
786 HashedProcessData
*hashed_process_data_out
= NULL
;
788 if(processlist_get_process_pixels(process_list
,
791 tfc
->t_context
->index
,
794 &hashed_process_data_out
) == 1)
796 /* Process not present */
797 processlist_add(process_list
,
800 tfc
->t_context
->index
,
803 &hashed_process_data_out
);
804 g_assert(processlist_get_process_pixels(process_list
,
807 tfc
->t_context
->index
,
810 &hashed_process_data_out
)==0);
811 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
815 /* Find process pid_in in the list... */
816 process_in
= lttv_state_find_process(tfs
, pid_in
);
817 if(process_in
== NULL
) return 0;
818 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
820 birth
= process_in
->creation_time
;
821 name
= g_quark_to_string(process_in
->name
);
822 HashedProcessData
*hashed_process_data_in
= NULL
;
824 if(processlist_get_process_pixels(process_list
,
827 tfc
->t_context
->index
,
830 &hashed_process_data_in
) == 1)
832 /* Process not present */
833 processlist_add(process_list
,
836 tfc
->t_context
->index
,
839 &hashed_process_data_in
);
840 processlist_get_process_pixels(process_list
,
843 tfc
->t_context
->index
,
846 &hashed_process_data_in
);
848 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
853 /* Find pixels corresponding to time of the event. If the time does
854 * not fit in the window, show a warning, not supposed to happend. */
856 guint width
= control_flow_data
->drawing
->width
;
858 LttTime time
= ltt_event_time(e
);
860 LttTime window_end
= time_window
.time_window
.end_time
;
862 convert_time_to_pixels(
867 //assert(x <= width);
869 /* draw what represents the event for outgoing process. */
871 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
872 draw_context_out
->current
->modify_over
->x
= x
;
873 draw_context_out
->current
->modify_under
->x
= x
;
874 draw_context_out
->current
->modify_over
->y
= y_out
;
875 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
876 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
877 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
878 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
879 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
880 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
881 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
882 //draw_context_out->gc = widget->style->black_gc;
884 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
885 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
887 /* Draw the line/background of the out process */
888 if(draw_context_out
->previous
->middle
->x
== -1)
890 draw_context_out
->previous
->over
->x
=
891 control_flow_data
->drawing
->damage_begin
;
892 draw_context_out
->previous
->middle
->x
=
893 control_flow_data
->drawing
->damage_begin
;
894 draw_context_out
->previous
->under
->x
=
895 control_flow_data
->drawing
->damage_begin
;
896 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
899 draw_context_out
->current
->middle
->x
= x
;
900 draw_context_out
->current
->over
->x
= x
;
901 draw_context_out
->current
->under
->x
= x
;
902 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
903 draw_context_out
->current
->over
->y
= y_out
;
904 draw_context_out
->current
->under
->y
= y_out
+ height
;
905 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
906 draw_context_out
->previous
->over
->y
= y_out
;
907 draw_context_out
->previous
->under
->y
= y_out
+ height
;
909 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
910 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
912 if(process_out
->state
->s
== LTTV_STATE_RUN
)
914 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
915 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
916 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
918 PropertiesBG prop_bg
;
919 prop_bg
.color
= g_new(GdkColor
,1);
923 prop_bg
.color
->red
= 0x1515;
924 prop_bg
.color
->green
= 0x1515;
925 prop_bg
.color
->blue
= 0x8c8c;
928 prop_bg
.color
->red
= 0x4e4e;
929 prop_bg
.color
->green
= 0xa9a9;
930 prop_bg
.color
->blue
= 0xa4a4;
933 prop_bg
.color
->red
= 0x7a7a;
934 prop_bg
.color
->green
= 0x4a4a;
935 prop_bg
.color
->blue
= 0x8b8b;
938 prop_bg
.color
->red
= 0x8080;
939 prop_bg
.color
->green
= 0x7777;
940 prop_bg
.color
->blue
= 0x4747;
943 prop_bg
.color
->red
= 0xe7e7;
944 prop_bg
.color
->green
= 0xe7e7;
945 prop_bg
.color
->blue
= 0xe7e7;
948 g_debug("calling from draw_event");
949 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
950 g_free(prop_bg
.color
);
951 //gdk_gc_unref(draw_context_out->gc);
954 draw_context_out
->gc
= widget
->style
->black_gc
;
956 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
957 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
958 PropertiesText prop_text_out
;
959 prop_text_out
.foreground
= &colorfg_out
;
960 prop_text_out
.background
= &colorbg_out
;
961 prop_text_out
.size
= 6;
962 prop_text_out
.position
= OVER
;
964 /* color of text : status of the process */
965 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
967 prop_text_out
.foreground
->red
= 0xffff;
968 prop_text_out
.foreground
->green
= 0xffff;
969 prop_text_out
.foreground
->blue
= 0xffff;
971 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
973 prop_text_out
.foreground
->red
= 0x0fff;
974 prop_text_out
.foreground
->green
= 0xffff;
975 prop_text_out
.foreground
->blue
= 0xfff0;
977 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
979 prop_text_out
.foreground
->red
= 0xffff;
980 prop_text_out
.foreground
->green
= 0xffff;
981 prop_text_out
.foreground
->blue
= 0x0000;
983 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
985 prop_text_out
.foreground
->red
= 0xffff;
986 prop_text_out
.foreground
->green
= 0x0000;
987 prop_text_out
.foreground
->blue
= 0xffff;
989 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
991 prop_text_out
.foreground
->red
= 0xffff;
992 prop_text_out
.foreground
->green
= 0x0000;
993 prop_text_out
.foreground
->blue
= 0x0000;
995 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
997 prop_text_out
.foreground
->red
= 0x0000;
998 prop_text_out
.foreground
->green
= 0xffff;
999 prop_text_out
.foreground
->blue
= 0x0000;
1003 prop_text_out
.foreground
->red
= 0xffff;
1004 prop_text_out
.foreground
->green
= 0xffff;
1005 prop_text_out
.foreground
->blue
= 0xffff;
1009 /* Print status of the process : U, WF, WC, E, W, R */
1010 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1011 prop_text_out
.text
= "U->";
1012 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1013 prop_text_out
.text
= "WF->";
1014 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1015 prop_text_out
.text
= "WC->";
1016 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1017 prop_text_out
.text
= "E->";
1018 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1019 prop_text_out
.text
= "W->";
1020 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1021 prop_text_out
.text
= "R->";
1023 prop_text_out
.text
= "U";
1025 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1026 //gdk_gc_unref(draw_context_out->gc);
1028 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1029 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1030 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
1032 PropertiesLine prop_line_out
;
1033 prop_line_out
.color
= g_new(GdkColor
,1);
1034 prop_line_out
.line_width
= 2;
1035 prop_line_out
.style
= GDK_LINE_SOLID
;
1036 prop_line_out
.position
= MIDDLE
;
1038 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
1040 /* color of line : status of the process */
1041 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1043 prop_line_out
.color
->red
= 0xffff;
1044 prop_line_out
.color
->green
= 0xffff;
1045 prop_line_out
.color
->blue
= 0xffff;
1047 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1049 prop_line_out
.color
->red
= 0x0fff;
1050 prop_line_out
.color
->green
= 0xffff;
1051 prop_line_out
.color
->blue
= 0xfff0;
1053 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1055 prop_line_out
.color
->red
= 0xffff;
1056 prop_line_out
.color
->green
= 0xffff;
1057 prop_line_out
.color
->blue
= 0x0000;
1059 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1061 prop_line_out
.color
->red
= 0xffff;
1062 prop_line_out
.color
->green
= 0x0000;
1063 prop_line_out
.color
->blue
= 0xffff;
1065 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1067 prop_line_out
.color
->red
= 0xffff;
1068 prop_line_out
.color
->green
= 0x0000;
1069 prop_line_out
.color
->blue
= 0x0000;
1071 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1073 prop_line_out
.color
->red
= 0x0000;
1074 prop_line_out
.color
->green
= 0xffff;
1075 prop_line_out
.color
->blue
= 0x0000;
1079 prop_line_out
.color
->red
= 0xffff;
1080 prop_line_out
.color
->green
= 0xffff;
1081 prop_line_out
.color
->blue
= 0xffff;
1084 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1085 g_free(prop_line_out
.color
);
1086 //gdk_gc_unref(draw_context_out->gc);
1087 /* Note : finishing line will have to be added when trace read over. */
1089 /* Finally, update the drawing context of the pid_in. */
1091 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1092 draw_context_in
->current
->modify_over
->x
= x
;
1093 draw_context_in
->current
->modify_under
->x
= x
;
1094 draw_context_in
->current
->modify_over
->y
= y_in
;
1095 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1096 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1097 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1098 widget
= control_flow_data
->drawing
->drawing_area
;
1099 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1100 //draw_context_in->gc = widget->style->black_gc;
1101 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1102 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1104 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1105 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1107 /* Draw the line/bg of the in process */
1108 if(draw_context_in
->previous
->middle
->x
== -1)
1110 draw_context_in
->previous
->over
->x
=
1111 control_flow_data
->drawing
->damage_begin
;
1112 draw_context_in
->previous
->middle
->x
=
1113 control_flow_data
->drawing
->damage_begin
;
1114 draw_context_in
->previous
->under
->x
=
1115 control_flow_data
->drawing
->damage_begin
;
1117 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1121 draw_context_in
->current
->middle
->x
= x
;
1122 draw_context_in
->current
->over
->x
= x
;
1123 draw_context_in
->current
->under
->x
= x
;
1124 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1125 draw_context_in
->current
->over
->y
= y_in
;
1126 draw_context_in
->current
->under
->y
= y_in
+ height
;
1127 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1128 draw_context_in
->previous
->over
->y
= y_in
;
1129 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1131 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1132 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1135 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1137 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1138 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1139 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1141 PropertiesBG prop_bg
;
1142 prop_bg
.color
= g_new(GdkColor
,1);
1144 switch(tfc
->index
) {
1146 prop_bg
.color
->red
= 0x1515;
1147 prop_bg
.color
->green
= 0x1515;
1148 prop_bg
.color
->blue
= 0x8c8c;
1151 prop_bg
.color
->red
= 0x4e4e;
1152 prop_bg
.color
->green
= 0xa9a9;
1153 prop_bg
.color
->blue
= 0xa4a4;
1156 prop_bg
.color
->red
= 0x7a7a;
1157 prop_bg
.color
->green
= 0x4a4a;
1158 prop_bg
.color
->blue
= 0x8b8b;
1161 prop_bg
.color
->red
= 0x8080;
1162 prop_bg
.color
->green
= 0x7777;
1163 prop_bg
.color
->blue
= 0x4747;
1166 prop_bg
.color
->red
= 0xe7e7;
1167 prop_bg
.color
->green
= 0xe7e7;
1168 prop_bg
.color
->blue
= 0xe7e7;
1172 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1173 g_free(prop_bg
.color
);
1174 //gdk_gc_unref(draw_context_in->gc);
1177 draw_context_in
->gc
= widget
->style
->black_gc
;
1179 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1180 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1181 PropertiesText prop_text_in
;
1182 prop_text_in
.foreground
= &colorfg_in
;
1183 prop_text_in
.background
= &colorbg_in
;
1184 prop_text_in
.size
= 6;
1185 prop_text_in
.position
= OVER
;
1187 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1188 /* foreground of text : status of the process */
1189 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1191 prop_text_in
.foreground
->red
= 0xffff;
1192 prop_text_in
.foreground
->green
= 0xffff;
1193 prop_text_in
.foreground
->blue
= 0xffff;
1195 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1197 prop_text_in
.foreground
->red
= 0x0fff;
1198 prop_text_in
.foreground
->green
= 0xffff;
1199 prop_text_in
.foreground
->blue
= 0xfff0;
1201 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1203 prop_text_in
.foreground
->red
= 0xffff;
1204 prop_text_in
.foreground
->green
= 0xffff;
1205 prop_text_in
.foreground
->blue
= 0x0000;
1207 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1209 prop_text_in
.foreground
->red
= 0xffff;
1210 prop_text_in
.foreground
->green
= 0x0000;
1211 prop_text_in
.foreground
->blue
= 0xffff;
1213 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1215 prop_text_in
.foreground
->red
= 0xffff;
1216 prop_text_in
.foreground
->green
= 0x0000;
1217 prop_text_in
.foreground
->blue
= 0x0000;
1219 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1221 prop_text_in
.foreground
->red
= 0x0000;
1222 prop_text_in
.foreground
->green
= 0xffff;
1223 prop_text_in
.foreground
->blue
= 0x0000;
1227 prop_text_in
.foreground
->red
= 0xffff;
1228 prop_text_in
.foreground
->green
= 0xffff;
1229 prop_text_in
.foreground
->blue
= 0xffff;
1234 /* Print status of the process : U, WF, WC, E, W, R */
1235 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1236 prop_text_in
.text
= "U->";
1237 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1238 prop_text_in
.text
= "WF->";
1239 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1240 prop_text_in
.text
= "WC->";
1241 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1242 prop_text_in
.text
= "E->";
1243 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1244 prop_text_in
.text
= "W->";
1245 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1246 prop_text_in
.text
= "R->";
1248 prop_text_in
.text
= "U";
1250 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1251 //gdk_gc_unref(draw_context_in->gc);
1253 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1254 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1255 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1257 PropertiesLine prop_line_in
;
1258 prop_line_in
.color
= g_new(GdkColor
,1);
1259 prop_line_in
.line_width
= 2;
1260 prop_line_in
.style
= GDK_LINE_SOLID
;
1261 prop_line_in
.position
= MIDDLE
;
1263 /* color of line : status of the process */
1264 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1266 prop_line_in
.color
->red
= 0xffff;
1267 prop_line_in
.color
->green
= 0xffff;
1268 prop_line_in
.color
->blue
= 0xffff;
1270 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1272 prop_line_in
.color
->red
= 0x0fff;
1273 prop_line_in
.color
->green
= 0xffff;
1274 prop_line_in
.color
->blue
= 0xfff0;
1276 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1278 prop_line_in
.color
->red
= 0xffff;
1279 prop_line_in
.color
->green
= 0xffff;
1280 prop_line_in
.color
->blue
= 0x0000;
1282 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1284 prop_line_in
.color
->red
= 0xffff;
1285 prop_line_in
.color
->green
= 0x0000;
1286 prop_line_in
.color
->blue
= 0xffff;
1288 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1290 prop_line_in
.color
->red
= 0xffff;
1291 prop_line_in
.color
->green
= 0x0000;
1292 prop_line_in
.color
->blue
= 0x0000;
1294 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1296 prop_line_in
.color
->red
= 0x0000;
1297 prop_line_in
.color
->green
= 0xffff;
1298 prop_line_in
.color
->blue
= 0x0000;
1302 prop_line_in
.color
->red
= 0xffff;
1303 prop_line_in
.color
->green
= 0xffff;
1304 prop_line_in
.color
->blue
= 0xffff;
1307 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1308 g_free(prop_line_in
.color
);
1309 //gdk_gc_unref(draw_context_in->gc);
1319 GString
*string
= g_string_new("");;
1320 gboolean field_names
= TRUE
, state
= TRUE
;
1322 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1323 g_string_append_printf(string
,"\n");
1326 g_string_append_printf(string
, " %s",
1327 g_quark_to_string(tfs
->process
->state
->s
));
1330 g_info("%s",string
->str
);
1332 g_string_free(string
, TRUE
);
1334 /* End of text dump */
1339 /* after_schedchange_hook
1341 * The draw after hook is called by the reading API to have a
1342 * particular event drawn on the screen.
1343 * @param hook_data ControlFlowData structure of the viewer.
1344 * @param call_data Event context.
1346 * This function adds items to be drawn in a queue for each process.
1349 int after_schedchange_hook(void *hook_data
, void *call_data
)
1351 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1352 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1354 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1356 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1361 LttTime evtime
= ltt_event_time(e
);
1363 /* Add process to process list (if not present) */
1364 LttvProcessState
*process_in
;
1366 guint pl_height
= 0;
1367 HashedProcessData
*hashed_process_data_in
= NULL
;
1369 ProcessList
*process_list
= control_flow_data
->process_list
;
1374 LttField
*f
= ltt_event_field(e
);
1376 element
= ltt_field_member(f
,0);
1377 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1378 element
= ltt_field_member(f
,1);
1379 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1383 /* Find process pid_in in the list... */
1384 //process_in = lttv_state_find_process(tfs, pid_in);
1385 process_in
= tfs
->process
;
1386 /* It should exist, because we are after the state update. */
1388 g_assert(process_in
!= NULL
);
1389 #endif //EXTRA_CHECK
1390 birth
= process_in
->creation_time
;
1392 hashed_process_data_in
= processlist_get_process_data(process_list
,
1394 process_in
->last_cpu_index
,
1396 tfc
->t_context
->index
);
1397 if(hashed_process_data_in
== NULL
)
1399 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1400 const gchar
*name
= g_quark_to_string(process_in
->name
);
1401 ProcessInfo
*process_info
;
1402 Drawing_t
*drawing
= control_flow_data
->drawing
;
1403 /* Process not present */
1404 processlist_add(process_list
,
1407 process_in
->last_cpu_index
,
1410 tfc
->t_context
->index
,
1414 &hashed_process_data_in
);
1415 gtk_widget_set_size_request(drawing
->drawing_area
,
1418 gtk_widget_queue_draw(drawing
->drawing_area
);
1420 /* Set the current process */
1421 process_list
->current_hash_data
[process_in
->last_cpu_index
] =
1422 hashed_process_data_in
;
1424 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
1427 TimeWindow time_window
=
1428 lttvwindow_get_time_window(control_flow_data
->tab
);
1431 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1432 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1434 #endif //EXTRA_CHECK
1435 Drawing_t
*drawing
= control_flow_data
->drawing
;
1436 guint width
= drawing
->width
;
1439 convert_time_to_pixels(
1445 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1446 hashed_process_data_in
->x
.middle
= new_x
;
1447 hashed_process_data_in
->x
.middle_used
= FALSE
;
1448 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1458 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1459 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1461 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1463 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1464 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1470 LttTime evtime
= ltt_event_time(e
);
1471 TimeWindow time_window
=
1472 lttvwindow_get_time_window(control_flow_data
->tab
);
1474 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
1476 //if(time < time_beg || time > time_end) return;
1477 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1478 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1482 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1484 g_debug("schedchange!");
1486 /* Add process to process list (if not present) and get drawing "y" from
1487 * process position */
1488 guint pid_out
, pid_in
;
1489 LttvProcessState
*process_out
, *process_in
;
1491 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1493 ProcessList
*process_list
= control_flow_data
->process_list
;
1496 LttField
*f
= ltt_event_field(e
);
1498 element
= ltt_field_member(f
,0);
1499 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1500 element
= ltt_field_member(f
,1);
1501 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1502 //g_debug("out : %u in : %u", pid_out, pid_in);
1505 /* Find process pid_out in the list... */
1506 process_out
= lttv_state_find_process(tfs
, pid_out
);
1507 if(process_out
== NULL
) return 0;
1508 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1510 birth
= process_out
->creation_time
;
1511 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1512 HashedProcessData
*hashed_process_data_out
= NULL
;
1514 if(processlist_get_process_pixels(process_list
,
1517 tfc
->t_context
->index
,
1520 &hashed_process_data_out
) == 1)
1522 /* Process not present */
1523 processlist_add(process_list
,
1526 tfc
->t_context
->index
,
1529 &hashed_process_data_out
);
1530 processlist_get_process_pixels(process_list
,
1533 tfc
->t_context
->index
,
1536 &hashed_process_data_out
);
1537 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1542 /* Find process pid_in in the list... */
1543 process_in
= lttv_state_find_process(tfs
, pid_in
);
1544 if(process_in
== NULL
) return 0;
1545 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1547 birth
= process_in
->creation_time
;
1548 name
= strdup(g_quark_to_string(process_in
->name
));
1549 HashedProcessData
*hashed_process_data_in
= NULL
;
1551 if(processlist_get_process_pixels(process_list
,
1554 tfc
->t_context
->index
,
1557 &hashed_process_data_in
) == 1)
1559 /* Process not present */
1560 processlist_add(process_list
,
1563 tfc
->t_context
->index
,
1566 &hashed_process_data_in
);
1567 processlist_get_process_pixels(process_list
,
1570 tfc
->t_context
->index
,
1573 &hashed_process_data_in
);
1575 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1580 /* Find pixels corresponding to time of the event. If the time does
1581 * not fit in the window, show a warning, not supposed to happend. */
1583 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1585 //LttTime time = ltt_event_time(e);
1587 //LttTime window_end = time_window->time_window.end_time;
1590 //convert_time_to_pixels(
1596 //assert(x <= width);
1598 /* draw what represents the event for outgoing process. */
1600 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1601 //draw_context_out->current->modify_over->x = x;
1602 draw_context_out
->current
->modify_over
->y
= y_out
;
1603 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1604 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1605 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1606 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1607 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1609 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1610 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1612 /*if(process_out->state->s == LTTV_STATE_RUN)
1614 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1615 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1616 PropertiesBG prop_bg;
1617 prop_bg.color = g_new(GdkColor,1);
1619 prop_bg.color->red = 0xffff;
1620 prop_bg.color->green = 0xffff;
1621 prop_bg.color->blue = 0xffff;
1623 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1624 g_free(prop_bg.color);
1625 gdk_gc_unref(draw_context_out->gc);
1628 draw_context_out
->gc
= widget
->style
->black_gc
;
1630 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1631 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1632 PropertiesText prop_text_out
;
1633 prop_text_out
.foreground
= &colorfg_out
;
1634 prop_text_out
.background
= &colorbg_out
;
1635 prop_text_out
.size
= 6;
1636 prop_text_out
.position
= OVER
;
1638 /* color of text : status of the process */
1639 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1641 prop_text_out
.foreground
->red
= 0xffff;
1642 prop_text_out
.foreground
->green
= 0xffff;
1643 prop_text_out
.foreground
->blue
= 0xffff;
1645 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1647 prop_text_out
.foreground
->red
= 0x0fff;
1648 prop_text_out
.foreground
->green
= 0xffff;
1649 prop_text_out
.foreground
->blue
= 0xfff0;
1651 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1653 prop_text_out
.foreground
->red
= 0xffff;
1654 prop_text_out
.foreground
->green
= 0xffff;
1655 prop_text_out
.foreground
->blue
= 0x0000;
1657 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1659 prop_text_out
.foreground
->red
= 0xffff;
1660 prop_text_out
.foreground
->green
= 0x0000;
1661 prop_text_out
.foreground
->blue
= 0xffff;
1663 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1665 prop_text_out
.foreground
->red
= 0xffff;
1666 prop_text_out
.foreground
->green
= 0x0000;
1667 prop_text_out
.foreground
->blue
= 0x0000;
1669 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1671 prop_text_out
.foreground
->red
= 0x0000;
1672 prop_text_out
.foreground
->green
= 0xffff;
1673 prop_text_out
.foreground
->blue
= 0x0000;
1677 prop_text_out
.foreground
->red
= 0xffff;
1678 prop_text_out
.foreground
->green
= 0xffff;
1679 prop_text_out
.foreground
->blue
= 0xffff;
1682 /* Print status of the process : U, WF, WC, E, W, R */
1683 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1684 prop_text_out
.text
= "U";
1685 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1686 prop_text_out
.text
= "WF";
1687 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1688 prop_text_out
.text
= "WC";
1689 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1690 prop_text_out
.text
= "E";
1691 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1692 prop_text_out
.text
= "W";
1693 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1694 prop_text_out
.text
= "R";
1696 prop_text_out
.text
= "U";
1698 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1700 //gdk_gc_unref(draw_context_out->gc);
1702 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1703 draw_context_out
->current
->over
->y
= y_out
;
1704 draw_context_out
->current
->under
->y
= y_out
+height
;
1705 draw_context_out
->current
->status
= process_out
->state
->s
;
1707 /* for pid_out : remove previous, Prev = current, new current (default) */
1708 g_free(draw_context_out
->previous
->modify_under
);
1709 g_free(draw_context_out
->previous
->modify_middle
);
1710 g_free(draw_context_out
->previous
->modify_over
);
1711 g_free(draw_context_out
->previous
->under
);
1712 g_free(draw_context_out
->previous
->middle
);
1713 g_free(draw_context_out
->previous
->over
);
1714 g_free(draw_context_out
->previous
);
1716 draw_context_out
->previous
= draw_context_out
->current
;
1718 draw_context_out
->current
= g_new(DrawInfo
,1);
1719 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1720 draw_context_out
->current
->over
->x
= -1;
1721 draw_context_out
->current
->over
->y
= -1;
1722 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1723 draw_context_out
->current
->middle
->x
= -1;
1724 draw_context_out
->current
->middle
->y
= -1;
1725 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1726 draw_context_out
->current
->under
->x
= -1;
1727 draw_context_out
->current
->under
->y
= -1;
1728 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1729 draw_context_out
->current
->modify_over
->x
= -1;
1730 draw_context_out
->current
->modify_over
->y
= -1;
1731 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1732 draw_context_out
->current
->modify_middle
->x
= -1;
1733 draw_context_out
->current
->modify_middle
->y
= -1;
1734 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1735 draw_context_out
->current
->modify_under
->x
= -1;
1736 draw_context_out
->current
->modify_under
->y
= -1;
1737 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1739 /* Finally, update the drawing context of the pid_in. */
1741 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1742 //draw_context_in->current->modify_over->x = x;
1743 draw_context_in
->current
->modify_over
->y
= y_in
;
1744 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1745 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1746 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1747 widget
= control_flow_data
->drawing
->drawing_area
;
1748 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1750 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1751 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1753 /*if(process_in->state->s == LTTV_STATE_RUN)
1755 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1756 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1757 PropertiesBG prop_bg;
1758 prop_bg.color = g_new(GdkColor,1);
1760 prop_bg.color->red = 0xffff;
1761 prop_bg.color->green = 0xffff;
1762 prop_bg.color->blue = 0xffff;
1764 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1765 g_free(prop_bg.color);
1766 gdk_gc_unref(draw_context_in->gc);
1769 draw_context_in
->gc
= widget
->style
->black_gc
;
1771 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1772 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1773 PropertiesText prop_text_in
;
1774 prop_text_in
.foreground
= &colorfg_in
;
1775 prop_text_in
.background
= &colorbg_in
;
1776 prop_text_in
.size
= 6;
1777 prop_text_in
.position
= OVER
;
1779 /* foreground of text : status of the process */
1780 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1782 prop_text_in
.foreground
->red
= 0xffff;
1783 prop_text_in
.foreground
->green
= 0xffff;
1784 prop_text_in
.foreground
->blue
= 0xffff;
1786 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1788 prop_text_in
.foreground
->red
= 0x0fff;
1789 prop_text_in
.foreground
->green
= 0xffff;
1790 prop_text_in
.foreground
->blue
= 0xfff0;
1792 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1794 prop_text_in
.foreground
->red
= 0xffff;
1795 prop_text_in
.foreground
->green
= 0xffff;
1796 prop_text_in
.foreground
->blue
= 0x0000;
1798 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1800 prop_text_in
.foreground
->red
= 0xffff;
1801 prop_text_in
.foreground
->green
= 0x0000;
1802 prop_text_in
.foreground
->blue
= 0xffff;
1804 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1806 prop_text_in
.foreground
->red
= 0xffff;
1807 prop_text_in
.foreground
->green
= 0x0000;
1808 prop_text_in
.foreground
->blue
= 0x0000;
1810 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1812 prop_text_in
.foreground
->red
= 0x0000;
1813 prop_text_in
.foreground
->green
= 0xffff;
1814 prop_text_in
.foreground
->blue
= 0x0000;
1818 prop_text_in
.foreground
->red
= 0xffff;
1819 prop_text_in
.foreground
->green
= 0xffff;
1820 prop_text_in
.foreground
->blue
= 0xffff;
1824 /* Print status of the process : U, WF, WC, E, W, R */
1825 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1826 prop_text_in
.text
= "U";
1827 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1828 prop_text_in
.text
= "WF";
1829 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1830 prop_text_in
.text
= "WC";
1831 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1832 prop_text_in
.text
= "E";
1833 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1834 prop_text_in
.text
= "W";
1835 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1836 prop_text_in
.text
= "R";
1838 prop_text_in
.text
= "U";
1840 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1843 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1846 prop_text_in
.foreground
= &colorfg_in
;
1847 prop_text_in
.background
= &colorbg_in
;
1848 prop_text_in
.foreground
->red
= 0xffff;
1849 prop_text_in
.foreground
->green
= 0xffff;
1850 prop_text_in
.foreground
->blue
= 0xffff;
1851 prop_text_in
.size
= 6;
1852 prop_text_in
.position
= UNDER
;
1854 prop_text_in
.text
= g_new(gchar
, 260);
1855 strcpy(prop_text_in
.text
, "CPU ");
1856 snprintf(tmp
, 255, "%u", tfc
->index
);
1857 strcat(prop_text_in
.text
, tmp
);
1859 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1860 g_free(prop_text_in
.text
);
1864 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1865 draw_context_in
->current
->over
->y
= y_in
;
1866 draw_context_in
->current
->under
->y
= y_in
+height
;
1867 draw_context_in
->current
->status
= process_in
->state
->s
;
1869 /* for pid_in : remove previous, Prev = current, new current (default) */
1870 g_free(draw_context_in
->previous
->modify_under
);
1871 g_free(draw_context_in
->previous
->modify_middle
);
1872 g_free(draw_context_in
->previous
->modify_over
);
1873 g_free(draw_context_in
->previous
->under
);
1874 g_free(draw_context_in
->previous
->middle
);
1875 g_free(draw_context_in
->previous
->over
);
1876 g_free(draw_context_in
->previous
);
1878 draw_context_in
->previous
= draw_context_in
->current
;
1880 draw_context_in
->current
= g_new(DrawInfo
,1);
1881 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1882 draw_context_in
->current
->over
->x
= -1;
1883 draw_context_in
->current
->over
->y
= -1;
1884 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1885 draw_context_in
->current
->middle
->x
= -1;
1886 draw_context_in
->current
->middle
->y
= -1;
1887 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1888 draw_context_in
->current
->under
->x
= -1;
1889 draw_context_in
->current
->under
->y
= -1;
1890 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1891 draw_context_in
->current
->modify_over
->x
= -1;
1892 draw_context_in
->current
->modify_over
->y
= -1;
1893 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1894 draw_context_in
->current
->modify_middle
->x
= -1;
1895 draw_context_in
->current
->modify_middle
->y
= -1;
1896 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1897 draw_context_in
->current
->modify_under
->x
= -1;
1898 draw_context_in
->current
->modify_under
->y
= -1;
1899 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1908 static inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1910 PropertiesLine prop_line
;
1911 prop_line
.line_width
= 1;
1912 prop_line
.style
= GDK_LINE_SOLID
;
1914 //GdkColormap *colormap = gdk_colormap_get_system();
1916 /* color of line : execution mode of the process */
1917 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1918 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1919 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1920 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1921 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1922 prop_line
.color
= drawing_colors
[COL_TRAP
];
1923 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1924 prop_line
.color
= drawing_colors
[COL_IRQ
];
1925 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1926 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1928 prop_line
.color
= drawing_colors
[COL_WHITE
];
1930 //gdk_colormap_alloc_color(colormap,
1941 /* before_execmode_hook
1943 * This function basically draw lines and icons. Two types of lines are drawn :
1944 * one small (3 pixels?) representing the state of the process and the second
1945 * type is thicker (10 pixels?) representing on which CPU a process is running
1946 * (and this only in running state).
1948 * Extremums of the lines :
1949 * x_min : time of the last event context for this process kept in memory.
1950 * x_max : time of the current event.
1951 * y : middle of the process in the process list. The process is found in the
1952 * list, therefore is it's position in pixels.
1954 * The choice of lines'color is defined by the context of the last event for this
1959 int before_execmode_hook(void *hook_data
, void *call_data
)
1961 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1962 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1964 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1966 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1971 LttTime evtime
= ltt_event_time(e
);
1973 /* we are in a execmode, before the state update. We must draw the
1974 * items corresponding to the state before it changes : now is the right
1978 LttvProcessState
*process
= tfs
->process
;
1979 g_assert(process
!= NULL
);
1981 guint pid
= process
->pid
;
1983 /* Well, the process_out existed : we must get it in the process hash
1984 * or add it, and draw its items.
1986 /* Add process to process list (if not present) */
1987 guint pl_height
= 0;
1988 HashedProcessData
*hashed_process_data
= NULL
;
1989 ProcessList
*process_list
= control_flow_data
->process_list
;
1990 LttTime birth
= process
->creation_time
;
1992 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
1993 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
1995 hashed_process_data
= processlist_get_process_data(process_list
,
1997 process
->last_cpu_index
,
1999 tfc
->t_context
->index
);
2000 if(unlikely(hashed_process_data
== NULL
))
2002 g_assert(pid
== 0 || pid
!= process
->ppid
);
2003 ProcessInfo
*process_info
;
2004 /* Process not present */
2005 Drawing_t
*drawing
= control_flow_data
->drawing
;
2006 const gchar
*name
= g_quark_to_string(process
->name
);
2007 processlist_add(process_list
,
2010 process
->last_cpu_index
,
2013 tfc
->t_context
->index
,
2017 &hashed_process_data
);
2018 gtk_widget_set_size_request(drawing
->drawing_area
,
2021 gtk_widget_queue_draw(drawing
->drawing_area
);
2023 /* Set the current process */
2024 process_list
->current_hash_data
[process
->last_cpu_index
] =
2025 hashed_process_data
;
2028 /* Now, the process is in the state hash and our own process hash.
2029 * We definitely can draw the items related to the ending state.
2032 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2035 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2036 TimeWindow time_window
=
2037 lttvwindow_get_time_window(control_flow_data
->tab
);
2040 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2041 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2043 #endif //EXTRA_CHECK
2044 Drawing_t
*drawing
= control_flow_data
->drawing
;
2045 guint width
= drawing
->width
;
2047 convert_time_to_pixels(
2053 /* Draw collision indicator */
2054 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2055 gdk_draw_point(hashed_process_data
->pixmap
,
2058 (hashed_process_data
->height
/2)-3);
2059 hashed_process_data
->x
.middle_marked
= TRUE
;
2062 TimeWindow time_window
=
2063 lttvwindow_get_time_window(control_flow_data
->tab
);
2066 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2067 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2069 #endif //EXTRA_CHECK
2070 Drawing_t
*drawing
= control_flow_data
->drawing
;
2071 guint width
= drawing
->width
;
2074 convert_time_to_pixels(
2081 /* Jump over draw if we are at the same x position */
2082 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2083 hashed_process_data
->x
.middle_used
))
2085 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2086 /* Draw collision indicator */
2087 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2088 gdk_draw_point(hashed_process_data
->pixmap
,
2091 (hashed_process_data
->height
/2)-3);
2092 hashed_process_data
->x
.middle_marked
= TRUE
;
2097 DrawContext draw_context
;
2098 /* Now create the drawing context that will be used to draw
2099 * items related to the last state. */
2100 draw_context
.drawable
= hashed_process_data
->pixmap
;
2101 draw_context
.gc
= drawing
->gc
;
2102 draw_context
.pango_layout
= drawing
->pango_layout
;
2103 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2104 draw_context
.drawinfo
.end
.x
= x
;
2106 draw_context
.drawinfo
.y
.over
= 1;
2107 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2108 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2110 draw_context
.drawinfo
.start
.offset
.over
= 0;
2111 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2112 draw_context
.drawinfo
.start
.offset
.under
= 0;
2113 draw_context
.drawinfo
.end
.offset
.over
= 0;
2114 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2115 draw_context
.drawinfo
.end
.offset
.under
= 0;
2119 PropertiesLine prop_line
= prepare_s_e_line(process
);
2120 draw_line((void*)&prop_line
, (void*)&draw_context
);
2123 /* become the last x position */
2124 hashed_process_data
->x
.middle
= x
;
2125 hashed_process_data
->x
.middle_used
= TRUE
;
2126 hashed_process_data
->x
.middle_marked
= FALSE
;
2128 /* Calculate the next good time */
2129 convert_pixels_to_time(width
, x
+1, time_window
,
2130 &hashed_process_data
->next_good_time
);
2137 /* after_execmode_hook
2139 * The draw after hook is called by the reading API to have a
2140 * particular event drawn on the screen.
2141 * @param hook_data ControlFlowData structure of the viewer.
2142 * @param call_data Event context.
2144 * This function adds items to be drawn in a queue for each process.
2147 int after_execmode_hook(void *hook_data
, void *call_data
)
2149 /**************** DOES NOTHING!! *************/
2150 /* hook desactivated in drawing.c */
2155 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2156 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2158 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2160 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2165 LttTime evtime
= ltt_event_time(e
);
2167 /* Add process to process list (if not present) */
2168 LttvProcessState
*process
;
2170 guint pl_height
= 0;
2171 HashedProcessData
*hashed_process_data
= NULL
;
2173 ProcessList
*process_list
= control_flow_data
->process_list
;
2175 /* Find process pid_in in the list... */
2176 process
= tfs
->process
;
2177 /* It should exist, because we are after the state update. */
2178 g_assert(process
!= NULL
);
2180 guint pid
= process
->pid
;
2182 birth
= process
->creation_time
;
2184 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
2185 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2187 hashed_process_data
= processlist_get_process_data(process_list
,
2189 process
->last_cpu_index
,
2191 tfc
->t_context
->index
);
2192 if(unlikely(hashed_process_data
== NULL
))
2194 g_assert(pid
== 0 || pid
!= process
->ppid
);
2195 /* Process not present */
2196 Drawing_t
*drawing
= control_flow_data
->drawing
;
2197 const gchar
*name
= g_quark_to_string(process
->name
);
2198 ProcessInfo
*process_info
;
2199 processlist_add(process_list
,
2202 process
->last_cpu_index
,
2205 tfc
->t_context
->index
,
2209 &hashed_process_data
);
2210 gtk_widget_set_size_request(drawing
->drawing_area
,
2213 gtk_widget_queue_draw(drawing
->drawing_area
);
2215 /* Set the current process */
2216 process_list
->current_hash_data
[process
->last_cpu_index
] =
2217 hashed_process_data
;
2220 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2223 TimeWindow time_window
=
2224 lttvwindow_get_time_window(control_flow_data
->tab
);
2227 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2228 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2230 #endif //EXTRA_CHECK
2231 Drawing_t
*drawing
= control_flow_data
->drawing
;
2232 guint width
= drawing
->width
;
2235 convert_time_to_pixels(
2241 if(hashed_process_data
->x
.middle
!= new_x
) {
2242 hashed_process_data
->x
.middle
= new_x
;
2243 hashed_process_data
->x
.middle_used
= FALSE
;
2244 hashed_process_data
->x
.middle_marked
= FALSE
;
2252 /* before_process_hook
2254 * Draw lines for process event.
2256 * @param hook_data ControlFlowData structure of the viewer.
2257 * @param call_data Event context.
2259 * This function adds items to be drawn in a queue for each process.
2262 int before_process_hook(void *hook_data
, void *call_data
)
2264 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2265 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2267 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2269 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2274 LttTime evtime
= ltt_event_time(e
);
2278 LttField
*f
= ltt_event_field(e
);
2280 element
= ltt_field_member(f
,0);
2281 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2284 if(sub_id
== 3) { /* exit */
2286 /* Add process to process list (if not present) */
2287 LttvProcessState
*process
= tfs
->process
;
2288 guint pid
= process
->pid
;
2290 guint pl_height
= 0;
2291 HashedProcessData
*hashed_process_data
= NULL
;
2293 ProcessList
*process_list
= control_flow_data
->process_list
;
2295 g_assert(process
!= NULL
);
2297 birth
= process
->creation_time
;
2299 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
2300 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2302 hashed_process_data
= processlist_get_process_data(process_list
,
2304 process
->last_cpu_index
,
2306 tfc
->t_context
->index
);
2307 if(unlikely(hashed_process_data
== NULL
))
2309 g_assert(pid
== 0 || pid
!= process
->ppid
);
2310 /* Process not present */
2311 Drawing_t
*drawing
= control_flow_data
->drawing
;
2312 const gchar
*name
= g_quark_to_string(process
->name
);
2313 ProcessInfo
*process_info
;
2314 processlist_add(process_list
,
2317 process
->last_cpu_index
,
2320 tfc
->t_context
->index
,
2324 &hashed_process_data
);
2325 gtk_widget_set_size_request(drawing
->drawing_area
,
2328 gtk_widget_queue_draw(drawing
->drawing_area
);
2332 /* Now, the process is in the state hash and our own process hash.
2333 * We definitely can draw the items related to the ending state.
2336 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2339 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2340 TimeWindow time_window
=
2341 lttvwindow_get_time_window(control_flow_data
->tab
);
2344 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2345 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2347 #endif //EXTRA_CHECK
2348 Drawing_t
*drawing
= control_flow_data
->drawing
;
2349 guint width
= drawing
->width
;
2351 convert_time_to_pixels(
2357 /* Draw collision indicator */
2358 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2359 gdk_draw_point(hashed_process_data
->pixmap
,
2362 (hashed_process_data
->height
/2)-3);
2363 hashed_process_data
->x
.middle_marked
= TRUE
;
2366 TimeWindow time_window
=
2367 lttvwindow_get_time_window(control_flow_data
->tab
);
2370 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2371 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2373 #endif //EXTRA_CHECK
2374 Drawing_t
*drawing
= control_flow_data
->drawing
;
2375 guint width
= drawing
->width
;
2378 convert_time_to_pixels(
2385 /* Jump over draw if we are at the same x position */
2386 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2387 hashed_process_data
->x
.middle_used
))
2389 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2390 /* Draw collision indicator */
2391 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2392 gdk_draw_point(hashed_process_data
->pixmap
,
2395 (hashed_process_data
->height
/2)-3);
2396 hashed_process_data
->x
.middle_marked
= TRUE
;
2400 DrawContext draw_context
;
2402 /* Now create the drawing context that will be used to draw
2403 * items related to the last state. */
2404 draw_context
.drawable
= hashed_process_data
->pixmap
;
2405 draw_context
.gc
= drawing
->gc
;
2406 draw_context
.pango_layout
= drawing
->pango_layout
;
2407 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2408 draw_context
.drawinfo
.end
.x
= x
;
2410 draw_context
.drawinfo
.y
.over
= 1;
2411 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2412 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2414 draw_context
.drawinfo
.start
.offset
.over
= 0;
2415 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2416 draw_context
.drawinfo
.start
.offset
.under
= 0;
2417 draw_context
.drawinfo
.end
.offset
.over
= 0;
2418 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2419 draw_context
.drawinfo
.end
.offset
.under
= 0;
2423 PropertiesLine prop_line
= prepare_s_e_line(process
);
2424 draw_line((void*)&prop_line
, (void*)&draw_context
);
2427 /* become the last x position */
2428 hashed_process_data
->x
.middle
= x
;
2429 hashed_process_data
->x
.middle_used
= TRUE
;
2430 hashed_process_data
->x
.middle_marked
= FALSE
;
2432 /* Calculate the next good time */
2433 convert_pixels_to_time(width
, x
+1, time_window
,
2434 &hashed_process_data
->next_good_time
);
2438 } else if(sub_id
== 7) /* release */ {
2442 LttField
*f
= ltt_event_field(e
);
2444 element
= ltt_field_member(f
,1);
2445 pid
= ltt_event_get_long_unsigned(e
,element
);
2448 /* Add process to process list (if not present) */
2449 /* Don't care about the process if it's not in the state hash already :
2450 * that means a process that has never done anything in the trace and
2451 * unknown suddently gets destroyed : no state meaningful to show. */
2452 LttvProcessState
*process
= lttv_state_find_process(tfs
, pid
);
2454 if(process
!= NULL
) {
2456 guint pl_height
= 0;
2457 HashedProcessData
*hashed_process_data
= NULL
;
2459 ProcessList
*process_list
= control_flow_data
->process_list
;
2461 birth
= process
->creation_time
;
2463 /* Cannot use current process : this event happens on another process,
2464 * action done by the parent. */
2465 hashed_process_data
= processlist_get_process_data(process_list
,
2467 process
->last_cpu_index
,
2469 tfc
->t_context
->index
);
2470 if(unlikely(hashed_process_data
== NULL
))
2472 g_assert(pid
== 0 || pid
!= process
->ppid
);
2473 /* Process not present */
2474 Drawing_t
*drawing
= control_flow_data
->drawing
;
2475 const gchar
*name
= g_quark_to_string(process
->name
);
2476 ProcessInfo
*process_info
;
2477 processlist_add(process_list
,
2480 process
->last_cpu_index
,
2483 tfc
->t_context
->index
,
2487 &hashed_process_data
);
2488 gtk_widget_set_size_request(drawing
->drawing_area
,
2491 gtk_widget_queue_draw(drawing
->drawing_area
);
2494 /* Now, the process is in the state hash and our own process hash.
2495 * We definitely can draw the items related to the ending state.
2498 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2501 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2502 TimeWindow time_window
=
2503 lttvwindow_get_time_window(control_flow_data
->tab
);
2506 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2507 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2509 #endif //EXTRA_CHECK
2510 Drawing_t
*drawing
= control_flow_data
->drawing
;
2511 guint width
= drawing
->width
;
2513 convert_time_to_pixels(
2519 /* Draw collision indicator */
2520 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2521 gdk_draw_point(hashed_process_data
->pixmap
,
2524 (hashed_process_data
->height
/2)-3);
2525 hashed_process_data
->x
.middle_marked
= TRUE
;
2528 TimeWindow time_window
=
2529 lttvwindow_get_time_window(control_flow_data
->tab
);
2532 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2533 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2535 #endif //EXTRA_CHECK
2536 Drawing_t
*drawing
= control_flow_data
->drawing
;
2537 guint width
= drawing
->width
;
2540 convert_time_to_pixels(
2547 /* Jump over draw if we are at the same x position */
2548 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2549 hashed_process_data
->x
.middle_used
))
2551 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2552 /* Draw collision indicator */
2553 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2554 gdk_draw_point(hashed_process_data
->pixmap
,
2557 (hashed_process_data
->height
/2)-3);
2558 hashed_process_data
->x
.middle_marked
= TRUE
;
2562 DrawContext draw_context
;
2564 /* Now create the drawing context that will be used to draw
2565 * items related to the last state. */
2566 draw_context
.drawable
= hashed_process_data
->pixmap
;
2567 draw_context
.gc
= drawing
->gc
;
2568 draw_context
.pango_layout
= drawing
->pango_layout
;
2569 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2570 draw_context
.drawinfo
.end
.x
= x
;
2572 draw_context
.drawinfo
.y
.over
= 1;
2573 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2574 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2576 draw_context
.drawinfo
.start
.offset
.over
= 0;
2577 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2578 draw_context
.drawinfo
.start
.offset
.under
= 0;
2579 draw_context
.drawinfo
.end
.offset
.over
= 0;
2580 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2581 draw_context
.drawinfo
.end
.offset
.under
= 0;
2585 PropertiesLine prop_line
= prepare_s_e_line(process
);
2586 draw_line((void*)&prop_line
, (void*)&draw_context
);
2589 /* become the last x position */
2590 hashed_process_data
->x
.middle
= x
;
2591 hashed_process_data
->x
.middle_used
= TRUE
;
2592 hashed_process_data
->x
.middle_marked
= FALSE
;
2594 /* Calculate the next good time */
2595 convert_pixels_to_time(width
, x
+1, time_window
,
2596 &hashed_process_data
->next_good_time
);
2611 /* after_process_hook
2613 * Create the processlist entry for the child process. Put the last
2614 * position in x at the current time value.
2616 * @param hook_data ControlFlowData structure of the viewer.
2617 * @param call_data Event context.
2619 * This function adds items to be drawn in a queue for each process.
2622 int after_process_hook(void *hook_data
, void *call_data
)
2624 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2625 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2627 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2629 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2634 LttTime evtime
= ltt_event_time(e
);
2639 LttField
*f
= ltt_event_field(e
);
2641 element
= ltt_field_member(f
,0);
2642 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2643 element
= ltt_field_member(f
,1);
2644 param1
= ltt_event_get_long_unsigned(e
,element
);
2647 if(sub_id
== 2) { /* fork */
2649 guint child_pid
= param1
;
2650 /* Add process to process list (if not present) */
2651 LttvProcessState
*process_child
;
2653 guint pl_height
= 0;
2654 HashedProcessData
*hashed_process_data_child
= NULL
;
2656 ProcessList
*process_list
= control_flow_data
->process_list
;
2658 /* Find child in the list... */
2659 process_child
= lttv_state_find_process(tfs
, child_pid
);
2660 /* It should exist, because we are after the state update. */
2661 g_assert(process_child
!= NULL
);
2663 birth
= process_child
->creation_time
;
2665 /* Cannot use current process, because this action is done by the parent
2667 hashed_process_data_child
= processlist_get_process_data(process_list
,
2669 process_child
->last_cpu_index
,
2671 tfc
->t_context
->index
);
2672 if(likely(hashed_process_data_child
== NULL
))
2674 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2675 /* Process not present */
2676 Drawing_t
*drawing
= control_flow_data
->drawing
;
2677 const gchar
*name
= g_quark_to_string(process_child
->name
);
2678 ProcessInfo
*process_info
;
2679 processlist_add(process_list
,
2682 process_child
->last_cpu_index
,
2683 process_child
->ppid
,
2685 tfc
->t_context
->index
,
2689 &hashed_process_data_child
);
2690 gtk_widget_set_size_request(drawing
->drawing_area
,
2693 gtk_widget_queue_draw(drawing
->drawing_area
);
2697 if(likely(ltt_time_compare(hashed_process_data_child
->next_good_time
,
2700 TimeWindow time_window
=
2701 lttvwindow_get_time_window(control_flow_data
->tab
);
2704 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2705 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2707 #endif //EXTRA_CHECK
2708 Drawing_t
*drawing
= control_flow_data
->drawing
;
2709 guint width
= drawing
->width
;
2711 convert_time_to_pixels(
2717 if(likely(hashed_process_data_child
->x
.over
!= new_x
)) {
2718 hashed_process_data_child
->x
.over
= new_x
;
2719 hashed_process_data_child
->x
.over_used
= FALSE
;
2720 hashed_process_data_child
->x
.over_marked
= FALSE
;
2722 if(likely(hashed_process_data_child
->x
.middle
!= new_x
)) {
2723 hashed_process_data_child
->x
.middle
= new_x
;
2724 hashed_process_data_child
->x
.middle_used
= FALSE
;
2725 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2727 if(likely(hashed_process_data_child
->x
.under
!= new_x
)) {
2728 hashed_process_data_child
->x
.under
= new_x
;
2729 hashed_process_data_child
->x
.under_used
= FALSE
;
2730 hashed_process_data_child
->x
.under_marked
= FALSE
;
2734 } else if(sub_id
== 3) { /* exit */
2736 /* Add process to process list (if not present) */
2737 LttvProcessState
*process
= tfs
->process
;
2738 guint pid
= process
->pid
;
2740 guint pl_height
= 0;
2741 HashedProcessData
*hashed_process_data
= NULL
;
2743 ProcessList
*process_list
= control_flow_data
->process_list
;
2745 /* It should exist, because we are after the state update. */
2746 g_assert(process
!= NULL
);
2748 birth
= process
->creation_time
;
2750 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
) ){
2751 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2753 hashed_process_data
= processlist_get_process_data(process_list
,
2755 process
->last_cpu_index
,
2757 tfc
->t_context
->index
);
2758 if(unlikely(hashed_process_data
== NULL
))
2760 g_assert(pid
== 0 || pid
!= process
->ppid
);
2761 /* Process not present */
2762 Drawing_t
*drawing
= control_flow_data
->drawing
;
2763 const gchar
*name
= g_quark_to_string(process
->name
);
2764 ProcessInfo
*process_info
;
2765 processlist_add(process_list
,
2768 process
->last_cpu_index
,
2771 tfc
->t_context
->index
,
2775 &hashed_process_data
);
2776 gtk_widget_set_size_request(drawing
->drawing_area
,
2779 gtk_widget_queue_draw(drawing
->drawing_area
);
2782 /* Set the current process */
2783 process_list
->current_hash_data
[process
->last_cpu_index
] =
2784 hashed_process_data
;
2787 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2790 TimeWindow time_window
=
2791 lttvwindow_get_time_window(control_flow_data
->tab
);
2794 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2795 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2797 #endif //EXTRA_CHECK
2798 Drawing_t
*drawing
= control_flow_data
->drawing
;
2799 guint width
= drawing
->width
;
2801 convert_time_to_pixels(
2806 if(unlikely(hashed_process_data
->x
.middle
!= new_x
)) {
2807 hashed_process_data
->x
.middle
= new_x
;
2808 hashed_process_data
->x
.middle_used
= FALSE
;
2809 hashed_process_data
->x
.middle_marked
= FALSE
;
2819 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2821 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2822 Drawing_t
*drawing
= control_flow_data
->drawing
;
2823 ProcessList
*process_list
= control_flow_data
->process_list
;
2825 const TimeWindowNotifyData
*time_window_nofify_data
=
2826 ((const TimeWindowNotifyData
*)call_data
);
2828 TimeWindow
*old_time_window
=
2829 time_window_nofify_data
->old_time_window
;
2830 TimeWindow
*new_time_window
=
2831 time_window_nofify_data
->new_time_window
;
2833 /* Update the ruler */
2834 drawing_update_ruler(control_flow_data
->drawing
,
2838 /* Two cases : zoom in/out or scrolling */
2840 /* In order to make sure we can reuse the old drawing, the scale must
2841 * be the same and the new time interval being partly located in the
2842 * currently shown time interval. (reuse is only for scrolling)
2845 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
2846 old_time_window
->start_time
.tv_sec
,
2847 old_time_window
->start_time
.tv_nsec
,
2848 old_time_window
->time_width
.tv_sec
,
2849 old_time_window
->time_width
.tv_nsec
);
2851 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
2852 new_time_window
->start_time
.tv_sec
,
2853 new_time_window
->start_time
.tv_nsec
,
2854 new_time_window
->time_width
.tv_sec
,
2855 new_time_window
->time_width
.tv_nsec
);
2857 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2858 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2860 /* Same scale (scrolling) */
2861 g_info("scrolling");
2862 LttTime
*ns
= &new_time_window
->start_time
;
2863 LttTime
*nw
= &new_time_window
->time_width
;
2864 LttTime
*os
= &old_time_window
->start_time
;
2865 LttTime
*ow
= &old_time_window
->time_width
;
2866 LttTime old_end
= old_time_window
->end_time
;
2867 LttTime new_end
= new_time_window
->end_time
;
2869 //if(ns<os+w && os+w<ns+w)
2870 //if(ns<old_end && os<ns)
2871 if(ltt_time_compare(*ns
, old_end
) == -1
2872 && ltt_time_compare(*os
, *ns
) == -1)
2874 g_info("scrolling near right");
2875 /* Scroll right, keep right part of the screen */
2877 guint width
= control_flow_data
->drawing
->width
;
2878 convert_time_to_pixels(
2884 /* Copy old data to new location */
2885 copy_pixmap_region(process_list
,
2887 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2891 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2893 if(drawing
->damage_begin
== drawing
->damage_end
)
2894 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2896 drawing
->damage_begin
= 0;
2898 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2900 /* Clear the data request background, but not SAFETY */
2901 rectangle_pixmap(process_list
,
2902 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2904 drawing
->damage_begin
+SAFETY
, 0,
2905 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2907 gtk_widget_queue_draw(drawing
->drawing_area
);
2908 //gtk_widget_queue_draw_area (drawing->drawing_area,
2910 // control_flow_data->drawing->width,
2911 // control_flow_data->drawing->height);
2913 /* Get new data for the rest. */
2914 drawing_data_request(control_flow_data
->drawing
,
2915 drawing
->damage_begin
, 0,
2916 drawing
->damage_end
- drawing
->damage_begin
,
2917 control_flow_data
->drawing
->height
);
2920 //if(ns<os && os<ns+w)
2921 //if(ns<os && os<new_end)
2922 if(ltt_time_compare(*ns
,*os
) == -1
2923 && ltt_time_compare(*os
,new_end
) == -1)
2925 g_info("scrolling near left");
2926 /* Scroll left, keep left part of the screen */
2928 guint width
= control_flow_data
->drawing
->width
;
2929 convert_time_to_pixels(
2935 /* Copy old data to new location */
2936 copy_pixmap_region (process_list
,
2938 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2944 if(drawing
->damage_begin
== drawing
->damage_end
)
2945 drawing
->damage_end
= x
;
2947 drawing
->damage_end
=
2948 control_flow_data
->drawing
->width
;
2950 drawing
->damage_begin
= 0;
2952 rectangle_pixmap (process_list
,
2953 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2955 drawing
->damage_begin
, 0,
2956 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2959 gtk_widget_queue_draw(drawing
->drawing_area
);
2960 //gtk_widget_queue_draw_area (drawing->drawing_area,
2962 // control_flow_data->drawing->width,
2963 // control_flow_data->drawing->height);
2966 /* Get new data for the rest. */
2967 drawing_data_request(control_flow_data
->drawing
,
2968 drawing
->damage_begin
, 0,
2969 drawing
->damage_end
- drawing
->damage_begin
,
2970 control_flow_data
->drawing
->height
);
2973 if(ltt_time_compare(*ns
,*os
) == 0)
2975 g_info("not scrolling");
2977 g_info("scrolling far");
2978 /* Cannot reuse any part of the screen : far jump */
2981 rectangle_pixmap (process_list
,
2982 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2985 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2988 //gtk_widget_queue_draw_area (drawing->drawing_area,
2990 // control_flow_data->drawing->width,
2991 // control_flow_data->drawing->height);
2992 gtk_widget_queue_draw(drawing
->drawing_area
);
2994 drawing
->damage_begin
= 0;
2995 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2997 drawing_data_request(control_flow_data
->drawing
,
2999 control_flow_data
->drawing
->width
,
3000 control_flow_data
->drawing
->height
);
3006 /* Different scale (zoom) */
3009 rectangle_pixmap (process_list
,
3010 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
3013 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
3016 //gtk_widget_queue_draw_area (drawing->drawing_area,
3018 // control_flow_data->drawing->width,
3019 // control_flow_data->drawing->height);
3020 gtk_widget_queue_draw(drawing
->drawing_area
);
3022 drawing
->damage_begin
= 0;
3023 drawing
->damage_end
= control_flow_data
->drawing
->width
;
3025 drawing_data_request(control_flow_data
->drawing
,
3027 control_flow_data
->drawing
->width
,
3028 control_flow_data
->drawing
->height
);
3036 gint
traceset_notify(void *hook_data
, void *call_data
)
3038 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3039 Drawing_t
*drawing
= control_flow_data
->drawing
;
3042 drawing_clear(control_flow_data
->drawing
);
3043 processlist_clear(control_flow_data
->process_list
);
3044 gtk_widget_set_size_request(
3045 control_flow_data
->drawing
->drawing_area
,
3046 -1, processlist_get_height(control_flow_data
->process_list
));
3047 redraw_notify(control_flow_data
, NULL
);
3049 request_background_data(control_flow_data
);
3054 gint
redraw_notify(void *hook_data
, void *call_data
)
3056 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3057 Drawing_t
*drawing
= control_flow_data
->drawing
;
3058 GtkWidget
*widget
= drawing
->drawing_area
;
3060 drawing
->damage_begin
= 0;
3061 drawing
->damage_end
= drawing
->width
;
3063 /* fun feature, to be separated someday... */
3064 drawing_clear(control_flow_data
->drawing
);
3065 processlist_clear(control_flow_data
->process_list
);
3066 gtk_widget_set_size_request(
3067 control_flow_data
->drawing
->drawing_area
,
3068 -1, processlist_get_height(control_flow_data
->process_list
));
3070 rectangle_pixmap (control_flow_data
->process_list
,
3071 widget
->style
->black_gc
,
3074 drawing
->alloc_width
,
3077 gtk_widget_queue_draw(drawing
->drawing_area
);
3079 if(drawing
->damage_begin
< drawing
->damage_end
)
3081 drawing_data_request(drawing
,
3082 drawing
->damage_begin
,
3084 drawing
->damage_end
-drawing
->damage_begin
,
3088 //gtk_widget_queue_draw_area(drawing->drawing_area,
3091 // drawing->height);
3097 gint
continue_notify(void *hook_data
, void *call_data
)
3099 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3100 Drawing_t
*drawing
= control_flow_data
->drawing
;
3102 //g_assert(widget->allocation.width == drawing->damage_end);
3104 if(drawing
->damage_begin
< drawing
->damage_end
)
3106 drawing_data_request(drawing
,
3107 drawing
->damage_begin
,
3109 drawing
->damage_end
-drawing
->damage_begin
,
3117 gint
update_current_time_hook(void *hook_data
, void *call_data
)
3119 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
3120 Drawing_t
*drawing
= control_flow_data
->drawing
;
3122 LttTime current_time
= *((LttTime
*)call_data
);
3124 TimeWindow time_window
=
3125 lttvwindow_get_time_window(control_flow_data
->tab
);
3127 LttTime time_begin
= time_window
.start_time
;
3128 LttTime width
= time_window
.time_width
;
3131 guint64 time_ll
= ltt_time_to_uint64(width
);
3132 time_ll
= time_ll
>> 1; /* divide by two */
3133 half_width
= ltt_time_from_uint64(time_ll
);
3135 LttTime time_end
= ltt_time_add(time_begin
, width
);
3137 LttvTracesetContext
* tsc
=
3138 lttvwindow_get_traceset_context(control_flow_data
->tab
);
3140 LttTime trace_start
= tsc
->time_span
.start_time
;
3141 LttTime trace_end
= tsc
->time_span
.end_time
;
3143 g_info("New current time HOOK : %lu, %lu", current_time
.tv_sec
,
3144 current_time
.tv_nsec
);
3148 /* If current time is inside time interval, just move the highlight
3151 /* Else, we have to change the time interval. We have to tell it
3152 * to the main window. */
3153 /* The time interval change will take care of placing the current
3154 * time at the center of the visible area, or nearest possible if we are
3155 * at one end of the trace. */
3158 if(ltt_time_compare(current_time
, time_begin
) < 0)
3160 TimeWindow new_time_window
;
3162 if(ltt_time_compare(current_time
,
3163 ltt_time_add(trace_start
,half_width
)) < 0)
3164 time_begin
= trace_start
;
3166 time_begin
= ltt_time_sub(current_time
,half_width
);
3168 new_time_window
.start_time
= time_begin
;
3169 new_time_window
.time_width
= width
;
3170 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3171 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3173 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3175 else if(ltt_time_compare(current_time
, time_end
) > 0)
3177 TimeWindow new_time_window
;
3179 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) > 0)
3180 time_begin
= ltt_time_sub(trace_end
,width
);
3182 time_begin
= ltt_time_sub(current_time
,half_width
);
3184 new_time_window
.start_time
= time_begin
;
3185 new_time_window
.time_width
= width
;
3186 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3187 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3189 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3192 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
3198 typedef struct _ClosureData
{
3199 EventsRequest
*events_request
;
3200 LttvTracesetState
*tss
;
3206 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3208 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3209 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3210 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3212 EventsRequest
*events_request
= closure_data
->events_request
;
3213 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3215 LttvTracesetState
*tss
= closure_data
->tss
;
3216 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
3218 LttTime evtime
= closure_data
->end_time
;
3221 /* For the process */
3222 /* First, check if the current process is in the state computation
3223 * process list. If it is there, that means we must add it right now and
3224 * draw items from the beginning of the read for it. If it is not
3225 * present, it's a new process and it was not present : it will
3226 * be added after the state update. */
3228 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3229 #endif //EXTRA_CHECK
3231 LttvTracefileState
*tfs
=
3232 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->
3233 tracefiles
[process_info
->cpu
];
3235 LttvProcessState
*process
;
3236 process
= lttv_state_find_process(tfs
,
3239 if(unlikely(process
!= NULL
)) {
3241 /* Only draw for processes that are currently in the trace states */
3243 ProcessList
*process_list
= control_flow_data
->process_list
;
3245 /* Should be alike when background info is ready */
3246 if(control_flow_data
->background_info_waiting
==0)
3247 g_assert(ltt_time_compare(process
->creation_time
,
3248 process_info
->birth
) == 0);
3249 #endif //EXTRA_CHECK
3251 /* Now, the process is in the state hash and our own process hash.
3252 * We definitely can draw the items related to the ending state.
3255 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
3258 TimeWindow time_window
=
3259 lttvwindow_get_time_window(control_flow_data
->tab
);
3262 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3263 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3265 #endif //EXTRA_CHECK
3266 Drawing_t
*drawing
= control_flow_data
->drawing
;
3267 guint width
= drawing
->width
;
3269 guint x
= closure_data
->x_end
;
3271 DrawContext draw_context
;
3273 /* Now create the drawing context that will be used to draw
3274 * items related to the last state. */
3275 draw_context
.drawable
= hashed_process_data
->pixmap
;
3276 draw_context
.gc
= drawing
->gc
;
3277 draw_context
.pango_layout
= drawing
->pango_layout
;
3278 draw_context
.drawinfo
.end
.x
= x
;
3280 draw_context
.drawinfo
.y
.over
= 1;
3281 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
3282 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
3284 draw_context
.drawinfo
.start
.offset
.over
= 0;
3285 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3286 draw_context
.drawinfo
.start
.offset
.under
= 0;
3287 draw_context
.drawinfo
.end
.offset
.over
= 0;
3288 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3289 draw_context
.drawinfo
.end
.offset
.under
= 0;
3291 /* Jump over draw if we are at the same x position */
3292 if(x
== hashed_process_data
->x
.over
)
3296 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3298 PropertiesLine prop_line
= prepare_execmode_line(process
);
3299 draw_line((void*)&prop_line
, (void*)&draw_context
);
3301 hashed_process_data
->x
.over
= x
;
3305 if(unlikely(x
== hashed_process_data
->x
.middle
&&
3306 hashed_process_data
->x
.middle_used
)) {
3307 #if 0 /* do not mark closure : not missing information */
3308 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3309 /* Draw collision indicator */
3310 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3311 gdk_draw_point(drawing
->pixmap
,
3315 hashed_process_data
->x
.middle_marked
= TRUE
;
3320 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3322 PropertiesLine prop_line
= prepare_s_e_line(process
);
3323 draw_line((void*)&prop_line
, (void*)&draw_context
);
3325 /* become the last x position */
3326 if(likely(x
!= hashed_process_data
->x
.middle
)) {
3327 hashed_process_data
->x
.middle
= x
;
3328 /* but don't use the pixel */
3329 hashed_process_data
->x
.middle_used
= FALSE
;
3331 /* Calculate the next good time */
3332 convert_pixels_to_time(width
, x
+1, time_window
,
3333 &hashed_process_data
->next_good_time
);
3342 int before_chunk(void *hook_data
, void *call_data
)
3344 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3345 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3346 ControlFlowData
*cfd
= (ControlFlowData
*)events_request
->viewer_data
;
3348 /* Desactivate sort */
3349 gtk_tree_sortable_set_sort_column_id(
3350 GTK_TREE_SORTABLE(cfd
->process_list
->list_store
),
3352 GTK_SORT_ASCENDING
);
3354 drawing_chunk_begin(events_request
, tss
);
3359 int before_request(void *hook_data
, void *call_data
)
3361 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3362 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3364 drawing_data_request_begin(events_request
, tss
);
3371 * after request is necessary in addition of after chunk in order to draw
3372 * lines until the end of the screen. after chunk just draws lines until
3379 int after_request(void *hook_data
, void *call_data
)
3381 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3382 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3383 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3385 ProcessList
*process_list
= control_flow_data
->process_list
;
3386 LttTime end_time
= events_request
->end_time
;
3388 ClosureData closure_data
;
3389 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3390 closure_data
.tss
= tss
;
3391 closure_data
.end_time
= end_time
;
3393 TimeWindow time_window
=
3394 lttvwindow_get_time_window(control_flow_data
->tab
);
3395 guint width
= control_flow_data
->drawing
->width
;
3396 convert_time_to_pixels(
3400 &closure_data
.x_end
);
3403 /* Draw last items */
3404 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3405 (void*)&closure_data
);
3408 /* Request expose */
3409 drawing_request_expose(events_request
, tss
, end_time
);
3418 int after_chunk(void *hook_data
, void *call_data
)
3420 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3421 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3422 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3423 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3424 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3427 ProcessList
*process_list
= control_flow_data
->process_list
;
3429 g_free(process_list
->current_hash_data
);
3430 process_list
->current_hash_data
= NULL
;
3433 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3434 else /* end of traceset, or position now out of request : end */
3435 end_time
= events_request
->end_time
;
3437 ClosureData closure_data
;
3438 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3439 closure_data
.tss
= tss
;
3440 closure_data
.end_time
= end_time
;
3442 TimeWindow time_window
=
3443 lttvwindow_get_time_window(control_flow_data
->tab
);
3444 guint width
= control_flow_data
->drawing
->width
;
3445 convert_time_to_pixels(
3449 &closure_data
.x_end
);
3451 /* Draw last items */
3452 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3453 (void*)&closure_data
);
3455 /* Reactivate sort */
3456 gtk_tree_sortable_set_sort_column_id(
3457 GTK_TREE_SORTABLE(control_flow_data
->process_list
->list_store
),
3458 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
3459 GTK_SORT_ASCENDING
);
3461 update_index_to_pixmap(control_flow_data
->process_list
);
3462 /* Request a full expose : drawing scrambled */
3463 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
3465 /* Request expose (updates damages zone also) */
3466 drawing_request_expose(events_request
, tss
, end_time
);