1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 /*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
25 /* Event hooks are the drawing hooks called during traceset read. They draw the
26 * icons, text, lines and background color corresponding to the events read.
28 * Two hooks are used for drawing : before_schedchange and after_schedchange hooks. The
29 * before_schedchange is called before the state update that occurs with an event and
30 * the after_schedchange hook is called after this state update.
32 * The before_schedchange hooks fulfill the task of drawing the visible objects that
33 * corresponds to the data accumulated by the after_schedchange hook.
35 * The after_schedchange hook accumulates the data that need to be shown on the screen
36 * (items) into a queue. Then, the next before_schedchange hook will draw what that
37 * queue contains. That's the Right Way (TM) of drawing items on the screen,
38 * because we need to draw the background first (and then add icons, text, ...
39 * over it), but we only know the length of a background region once the state
40 * corresponding to it is over, which happens to be at the next before_schedchange
43 * We also have a hook called at the end of a chunk to draw the information left
44 * undrawn in each process queue. We use the current time as end of
49 //#define PANGO_ENABLE_BACKEND
57 //#include <pango/pango.h>
59 #include <ltt/event.h>
63 #include <lttv/lttv.h>
64 #include <lttv/hook.h>
65 #include <lttv/state.h>
66 #include <lttvwindow/lttvwindow.h>
67 #include <lttvwindow/lttvwindowtraces.h>
70 #include "eventhooks.h"
72 #include "processlist.h"
76 #define MAX_PATH_LEN 256
80 typedef struct _ProcessAddClosure
{
85 static void process_add(gpointer key
,
89 LttvProcessState
*process
= (LttvProcessState
*)value
;
90 ProcessAddClosure
*closure
= (ProcessAddClosure
*)user_data
;
91 ControlFlowData
*control_flow_data
= closure
->cfd
;
92 guint trace_num
= closure
->trace_num
;
94 /* Add process to process list (if not present) */
97 guint y
= 0, height
= 0, pl_height
= 0;
99 ProcessList
*process_list
= control_flow_data
->process_list
;
102 birth
= process
->creation_time
;
103 const gchar
*name
= g_quark_to_string(process
->name
);
104 HashedProcessData
*hashed_process_data
= NULL
;
106 if(processlist_get_process_pixels(process_list
,
112 &hashed_process_data
) == 1)
114 /* Process not present */
115 processlist_add(process_list
,
121 &hashed_process_data
);
122 processlist_get_process_pixels(process_list
,
128 &hashed_process_data
);
129 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
135 /* Action to do when background computation completed.
137 * Wait for all the awaited computations to be over.
140 gint
background_ready(void *hook_data
, void *call_data
)
142 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
143 LttvTrace
*trace
= (LttvTrace
*)call_data
;
145 control_flow_data
->background_info_waiting
--;
147 if(control_flow_data
->background_info_waiting
== 0) {
148 g_debug("control flow viewer : background computation data ready.");
150 drawing_clear(control_flow_data
->drawing
);
151 processlist_clear(control_flow_data
->process_list
);
152 redraw_notify(control_flow_data
, NULL
);
159 /* Request background computation. Verify if it is in progress or ready first.
160 * Only for each trace in the tab's traceset.
162 void request_background_data(ControlFlowData
*control_flow_data
)
164 LttvTracesetContext
* tsc
=
165 lttvwindow_get_traceset_context(control_flow_data
->tab
);
166 gint num_traces
= lttv_traceset_number(tsc
->ts
);
170 LttvHooks
*background_ready_hook
=
172 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
174 control_flow_data
->background_info_waiting
= 0;
176 for(i
=0;i
<num_traces
;i
++) {
177 trace
= lttv_traceset_get(tsc
->ts
, i
);
179 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
181 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
183 /* We first remove requests that could have been done for the same
184 * information. Happens when two viewers ask for it before servicing
187 lttvwindowtraces_background_request_remove(trace
, "state");
188 lttvwindowtraces_background_request_queue(trace
,
190 lttvwindowtraces_background_notify_queue(control_flow_data
,
194 background_ready_hook
);
195 control_flow_data
->background_info_waiting
++;
196 } else { /* in progress */
198 lttvwindowtraces_background_notify_current(control_flow_data
,
202 background_ready_hook
);
203 control_flow_data
->background_info_waiting
++;
206 /* Data ready. Be its nature, this viewer doesn't need to have
207 * its data ready hook called htere, because a background
208 * request is always linked with a redraw.
214 lttv_hooks_destroy(background_ready_hook
);
221 * Event Viewer's constructor hook
223 * This constructor is given as a parameter to the menuitem and toolbar button
224 * registration. It creates the list.
225 * @param tab A pointer to the parent tab.
226 * @return The widget created.
229 h_guicontrolflow(Tab
*tab
)
231 g_info("h_guicontrolflow, %p", tab
);
232 ControlFlowData
*control_flow_data
= guicontrolflow() ;
234 control_flow_data
->tab
= tab
;
236 // Unreg done in the GuiControlFlow_Destructor
237 lttvwindow_register_traceset_notify(tab
,
241 lttvwindow_register_time_window_notify(tab
,
242 update_time_window_hook
,
244 lttvwindow_register_current_time_notify(tab
,
245 update_current_time_hook
,
247 lttvwindow_register_redraw_notify(tab
,
250 lttvwindow_register_continue_notify(tab
,
253 request_background_data(control_flow_data
);
256 return guicontrolflow_get_widget(control_flow_data
) ;
260 int event_selected_hook(void *hook_data
, void *call_data
)
262 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
263 guint
*event_number
= (guint
*) call_data
;
265 g_debug("DEBUG : event selected by main window : %u", *event_number
);
270 /* Function that selects the color of status&exemode line */
271 static inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
273 PropertiesLine prop_line
;
274 prop_line
.line_width
= 2;
275 prop_line
.style
= GDK_LINE_SOLID
;
276 prop_line
.y
= MIDDLE
;
277 //GdkColormap *colormap = gdk_colormap_get_system();
279 if(process
->state
->s
== LTTV_STATE_RUN
) {
280 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
281 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
282 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
283 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
284 else if(process
->state
->t
== LTTV_STATE_TRAP
)
285 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
286 else if(process
->state
->t
== LTTV_STATE_IRQ
)
287 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
288 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
289 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
291 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
292 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
293 /* We don't show if we wait while in user mode, trap, irq or syscall */
294 prop_line
.color
= drawing_colors
[COL_WAIT
];
295 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
296 /* We don't show if we wait for CPU while in user mode, trap, irq
298 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
299 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
300 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
301 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
302 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
303 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
304 prop_line
.color
= drawing_colors
[COL_EXIT
];
305 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
306 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
308 g_assert(FALSE
); /* UNKNOWN STATE */
315 static inline PropertiesLine
prepare_status_line(LttvProcessState
*process
)
317 PropertiesLine prop_line
;
318 prop_line
.line_width
= 2;
319 prop_line
.style
= GDK_LINE_SOLID
;
320 prop_line
.y
= MIDDLE
;
321 //GdkColormap *colormap = gdk_colormap_get_system();
323 g_debug("prepare_status_line for state : %s",
324 g_quark_to_string(process
->state
->s
));
326 /* color of line : status of the process */
327 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
328 prop_line
.color
= drawing_colors
[COL_WHITE
];
329 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
330 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
331 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
332 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
333 else if(process
->state
->s
== LTTV_STATE_EXIT
)
334 prop_line
.color
= drawing_colors
[COL_EXIT
];
335 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
336 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
337 else if(process
->state
->s
== LTTV_STATE_WAIT
)
338 prop_line
.color
= drawing_colors
[COL_WAIT
];
339 else if(process
->state
->s
== LTTV_STATE_RUN
)
340 prop_line
.color
= drawing_colors
[COL_RUN
];
342 prop_line
.color
= drawing_colors
[COL_WHITE
];
344 //gdk_colormap_alloc_color(colormap,
355 /* before_schedchange_hook
357 * This function basically draw lines and icons. Two types of lines are drawn :
358 * one small (3 pixels?) representing the state of the process and the second
359 * type is thicker (10 pixels?) representing on which CPU a process is running
360 * (and this only in running state).
362 * Extremums of the lines :
363 * x_min : time of the last event context for this process kept in memory.
364 * x_max : time of the current event.
365 * y : middle of the process in the process list. The process is found in the
366 * list, therefore is it's position in pixels.
368 * The choice of lines'color is defined by the context of the last event for this
373 int before_schedchange_hook(void *hook_data
, void *call_data
)
375 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
376 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
378 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
380 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
385 LttTime evtime
= ltt_event_time(e
);
387 /* we are in a schedchange, before the state update. We must draw the
388 * items corresponding to the state before it changes : now is the right
395 LttField
*f
= ltt_event_field(e
);
397 element
= ltt_field_member(f
,0);
398 pid_out
= ltt_event_get_long_unsigned(e
,element
);
399 element
= ltt_field_member(f
,1);
400 pid_in
= ltt_event_get_long_unsigned(e
,element
);
404 /* For the pid_out */
405 /* First, check if the current process is in the state computation
406 * process list. If it is there, that means we must add it right now and
407 * draw items from the beginning of the read for it. If it is not
408 * present, it's a new process and it was not present : it will
409 * be added after the state update. */
410 LttvProcessState
*process
;
411 /* unknown state, bad current pid */
412 if(tfs
->process
->pid
!= pid_out
)
413 process
= lttv_state_find_process(tfs
, pid_out
);
415 process
= tfs
->process
;
417 if(process
!= NULL
) {
418 /* Well, the process_out existed : we must get it in the process hash
419 * or add it, and draw its items.
421 /* Add process to process list (if not present) */
423 HashedProcessData
*hashed_process_data
= NULL
;
424 ProcessList
*process_list
= control_flow_data
->process_list
;
425 LttTime birth
= process
->creation_time
;
427 hashed_process_data
= processlist_get_process_data(process_list
,
429 process
->last_cpu_index
,
431 tfc
->t_context
->index
);
432 if(hashed_process_data
== NULL
)
434 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
435 const gchar
*name
= g_quark_to_string(process
->name
);
436 /* Process not present */
437 ProcessInfo
*process_info
;
438 Drawing_t
*drawing
= control_flow_data
->drawing
;
439 processlist_add(process_list
,
442 process
->last_cpu_index
,
445 tfc
->t_context
->index
,
449 &hashed_process_data
);
450 gtk_widget_set_size_request(drawing
->drawing_area
,
453 gtk_widget_queue_draw(drawing
->drawing_area
);
457 /* Now, the process is in the state hash and our own process hash.
458 * We definitely can draw the items related to the ending state.
461 if(ltt_time_compare(hashed_process_data
->next_good_time
,
464 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
466 TimeWindow time_window
=
467 lttvwindow_get_time_window(control_flow_data
->tab
);
469 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
470 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
473 Drawing_t
*drawing
= control_flow_data
->drawing
;
474 guint width
= drawing
->width
;
476 convert_time_to_pixels(
482 /* Draw collision indicator */
483 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
484 gdk_draw_point(hashed_process_data
->pixmap
,
487 (hashed_process_data
->height
/2)-3);
488 hashed_process_data
->x
.middle_marked
= TRUE
;
491 TimeWindow time_window
=
492 lttvwindow_get_time_window(control_flow_data
->tab
);
494 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
495 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
498 Drawing_t
*drawing
= control_flow_data
->drawing
;
499 guint width
= drawing
->width
;
501 convert_time_to_pixels(
508 /* Jump over draw if we are at the same x position */
509 if(x
== hashed_process_data
->x
.middle
&&
510 hashed_process_data
->x
.middle_used
)
512 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
513 /* Draw collision indicator */
514 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
515 gdk_draw_point(hashed_process_data
->pixmap
,
518 (hashed_process_data
->height
/2)-3);
519 hashed_process_data
->x
.middle_marked
= TRUE
;
523 DrawContext draw_context
;
525 /* Now create the drawing context that will be used to draw
526 * items related to the last state. */
527 draw_context
.drawable
= hashed_process_data
->pixmap
;
528 draw_context
.gc
= drawing
->gc
;
529 draw_context
.pango_layout
= drawing
->pango_layout
;
530 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
531 draw_context
.drawinfo
.end
.x
= x
;
533 draw_context
.drawinfo
.y
.over
= 1;
534 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
535 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
537 draw_context
.drawinfo
.start
.offset
.over
= 0;
538 draw_context
.drawinfo
.start
.offset
.middle
= 0;
539 draw_context
.drawinfo
.start
.offset
.under
= 0;
540 draw_context
.drawinfo
.end
.offset
.over
= 0;
541 draw_context
.drawinfo
.end
.offset
.middle
= 0;
542 draw_context
.drawinfo
.end
.offset
.under
= 0;
546 PropertiesLine prop_line
= prepare_s_e_line(process
);
547 draw_line((void*)&prop_line
, (void*)&draw_context
);
550 /* become the last x position */
551 hashed_process_data
->x
.middle
= x
;
552 hashed_process_data
->x
.middle_used
= TRUE
;
553 hashed_process_data
->x
.middle_marked
= FALSE
;
555 /* Calculate the next good time */
556 convert_pixels_to_time(width
, x
+1, time_window
,
557 &hashed_process_data
->next_good_time
);
565 /* First, check if the current process is in the state computation
566 * process list. If it is there, that means we must add it right now and
567 * draw items from the beginning of the read for it. If it is not
568 * present, it's a new process and it was not present : it will
569 * be added after the state update. */
570 LttvProcessState
*process
;
571 process
= lttv_state_find_process(tfs
, pid_in
);
573 if(process
!= NULL
) {
574 /* Well, the process_out existed : we must get it in the process hash
575 * or add it, and draw its items.
577 /* Add process to process list (if not present) */
579 HashedProcessData
*hashed_process_data
= NULL
;
580 ProcessList
*process_list
= control_flow_data
->process_list
;
581 LttTime birth
= process
->creation_time
;
583 hashed_process_data
= processlist_get_process_data(process_list
,
585 process
->last_cpu_index
,
587 tfc
->t_context
->index
);
588 if(hashed_process_data
== NULL
)
590 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
591 const gchar
*name
= g_quark_to_string(process
->name
);
592 /* Process not present */
593 ProcessInfo
*process_info
;
594 Drawing_t
*drawing
= control_flow_data
->drawing
;
595 processlist_add(process_list
,
598 process
->last_cpu_index
,
601 tfc
->t_context
->index
,
605 &hashed_process_data
);
606 gtk_widget_set_size_request(drawing
->drawing_area
,
609 gtk_widget_queue_draw(drawing
->drawing_area
);
612 //We could set the current process and hash here, but will be done
613 //by after schedchange hook
615 /* Now, the process is in the state hash and our own process hash.
616 * We definitely can draw the items related to the ending state.
619 if(ltt_time_compare(hashed_process_data
->next_good_time
,
622 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
624 TimeWindow time_window
=
625 lttvwindow_get_time_window(control_flow_data
->tab
);
627 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
628 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
631 Drawing_t
*drawing
= control_flow_data
->drawing
;
632 guint width
= drawing
->width
;
634 convert_time_to_pixels(
640 /* Draw collision indicator */
641 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
642 gdk_draw_point(hashed_process_data
->pixmap
,
645 (hashed_process_data
->height
/2)-3);
646 hashed_process_data
->x
.middle_marked
= TRUE
;
649 TimeWindow time_window
=
650 lttvwindow_get_time_window(control_flow_data
->tab
);
652 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
653 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
656 Drawing_t
*drawing
= control_flow_data
->drawing
;
657 guint width
= drawing
->width
;
660 convert_time_to_pixels(
667 /* Jump over draw if we are at the same x position */
668 if(x
== hashed_process_data
->x
.middle
&&
669 hashed_process_data
->x
.middle_used
)
671 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
672 /* Draw collision indicator */
673 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
674 gdk_draw_point(hashed_process_data
->pixmap
,
677 (hashed_process_data
->height
/2)-3);
678 hashed_process_data
->x
.middle_marked
= TRUE
;
682 DrawContext draw_context
;
684 /* Now create the drawing context that will be used to draw
685 * items related to the last state. */
686 draw_context
.drawable
= hashed_process_data
->pixmap
;
687 draw_context
.gc
= drawing
->gc
;
688 draw_context
.pango_layout
= drawing
->pango_layout
;
689 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
690 draw_context
.drawinfo
.end
.x
= x
;
692 draw_context
.drawinfo
.y
.over
= 1;
693 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
694 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
696 draw_context
.drawinfo
.start
.offset
.over
= 0;
697 draw_context
.drawinfo
.start
.offset
.middle
= 0;
698 draw_context
.drawinfo
.start
.offset
.under
= 0;
699 draw_context
.drawinfo
.end
.offset
.over
= 0;
700 draw_context
.drawinfo
.end
.offset
.middle
= 0;
701 draw_context
.drawinfo
.end
.offset
.under
= 0;
705 PropertiesLine prop_line
= prepare_s_e_line(process
);
706 draw_line((void*)&prop_line
, (void*)&draw_context
);
710 /* become the last x position */
711 hashed_process_data
->x
.middle
= x
;
712 hashed_process_data
->x
.middle_used
= TRUE
;
713 hashed_process_data
->x
.middle_marked
= FALSE
;
715 /* Calculate the next good time */
716 convert_pixels_to_time(width
, x
+1, time_window
,
717 &hashed_process_data
->next_good_time
);
726 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
727 ControlFlowData
*control_flow_data
=
728 (ControlFlowData
*)events_request
->viewer_data
;
729 Tab
*tab
= control_flow_data
->tab
;
731 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
733 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
734 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
739 LttTime evtime
= ltt_event_time(e
);
740 TimeWindow time_window
=
741 lttvwindow_get_time_window(tab
);
743 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
745 //if(time < time_beg || time > time_end) return;
746 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
747 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
750 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
752 g_debug("schedchange!");
754 /* Add process to process list (if not present) and get drawing "y" from
755 * process position */
756 guint pid_out
, pid_in
;
757 LttvProcessState
*process_out
, *process_in
;
759 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
761 ProcessList
*process_list
= control_flow_data
->process_list
;
764 LttField
*f
= ltt_event_field(e
);
766 element
= ltt_field_member(f
,0);
767 pid_out
= ltt_event_get_long_unsigned(e
,element
);
768 element
= ltt_field_member(f
,1);
769 pid_in
= ltt_event_get_long_unsigned(e
,element
);
770 g_debug("out : %u in : %u", pid_out
, pid_in
);
773 /* Find process pid_out in the list... */
774 process_out
= lttv_state_find_process(tfs
, pid_out
);
775 if(process_out
== NULL
) return 0;
776 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
778 birth
= process_out
->creation_time
;
779 const gchar
*name
= g_quark_to_string(process_out
->name
);
780 HashedProcessData
*hashed_process_data_out
= NULL
;
782 if(processlist_get_process_pixels(process_list
,
785 tfc
->t_context
->index
,
788 &hashed_process_data_out
) == 1)
790 /* Process not present */
791 processlist_add(process_list
,
794 tfc
->t_context
->index
,
797 &hashed_process_data_out
);
798 g_assert(processlist_get_process_pixels(process_list
,
801 tfc
->t_context
->index
,
804 &hashed_process_data_out
)==0);
805 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
809 /* Find process pid_in in the list... */
810 process_in
= lttv_state_find_process(tfs
, pid_in
);
811 if(process_in
== NULL
) return 0;
812 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
814 birth
= process_in
->creation_time
;
815 name
= g_quark_to_string(process_in
->name
);
816 HashedProcessData
*hashed_process_data_in
= NULL
;
818 if(processlist_get_process_pixels(process_list
,
821 tfc
->t_context
->index
,
824 &hashed_process_data_in
) == 1)
826 /* Process not present */
827 processlist_add(process_list
,
830 tfc
->t_context
->index
,
833 &hashed_process_data_in
);
834 processlist_get_process_pixels(process_list
,
837 tfc
->t_context
->index
,
840 &hashed_process_data_in
);
842 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
847 /* Find pixels corresponding to time of the event. If the time does
848 * not fit in the window, show a warning, not supposed to happend. */
850 guint width
= control_flow_data
->drawing
->width
;
852 LttTime time
= ltt_event_time(e
);
854 LttTime window_end
= time_window
.time_window
.end_time
;
856 convert_time_to_pixels(
861 //assert(x <= width);
863 /* draw what represents the event for outgoing process. */
865 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
866 draw_context_out
->current
->modify_over
->x
= x
;
867 draw_context_out
->current
->modify_under
->x
= x
;
868 draw_context_out
->current
->modify_over
->y
= y_out
;
869 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
870 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
871 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
872 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
873 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
874 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
875 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
876 //draw_context_out->gc = widget->style->black_gc;
878 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
879 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
881 /* Draw the line/background of the out process */
882 if(draw_context_out
->previous
->middle
->x
== -1)
884 draw_context_out
->previous
->over
->x
=
885 control_flow_data
->drawing
->damage_begin
;
886 draw_context_out
->previous
->middle
->x
=
887 control_flow_data
->drawing
->damage_begin
;
888 draw_context_out
->previous
->under
->x
=
889 control_flow_data
->drawing
->damage_begin
;
890 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
893 draw_context_out
->current
->middle
->x
= x
;
894 draw_context_out
->current
->over
->x
= x
;
895 draw_context_out
->current
->under
->x
= x
;
896 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
897 draw_context_out
->current
->over
->y
= y_out
;
898 draw_context_out
->current
->under
->y
= y_out
+ height
;
899 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
900 draw_context_out
->previous
->over
->y
= y_out
;
901 draw_context_out
->previous
->under
->y
= y_out
+ height
;
903 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
904 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
906 if(process_out
->state
->s
== LTTV_STATE_RUN
)
908 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
909 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
910 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
912 PropertiesBG prop_bg
;
913 prop_bg
.color
= g_new(GdkColor
,1);
917 prop_bg
.color
->red
= 0x1515;
918 prop_bg
.color
->green
= 0x1515;
919 prop_bg
.color
->blue
= 0x8c8c;
922 prop_bg
.color
->red
= 0x4e4e;
923 prop_bg
.color
->green
= 0xa9a9;
924 prop_bg
.color
->blue
= 0xa4a4;
927 prop_bg
.color
->red
= 0x7a7a;
928 prop_bg
.color
->green
= 0x4a4a;
929 prop_bg
.color
->blue
= 0x8b8b;
932 prop_bg
.color
->red
= 0x8080;
933 prop_bg
.color
->green
= 0x7777;
934 prop_bg
.color
->blue
= 0x4747;
937 prop_bg
.color
->red
= 0xe7e7;
938 prop_bg
.color
->green
= 0xe7e7;
939 prop_bg
.color
->blue
= 0xe7e7;
942 g_debug("calling from draw_event");
943 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
944 g_free(prop_bg
.color
);
945 //gdk_gc_unref(draw_context_out->gc);
948 draw_context_out
->gc
= widget
->style
->black_gc
;
950 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
951 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
952 PropertiesText prop_text_out
;
953 prop_text_out
.foreground
= &colorfg_out
;
954 prop_text_out
.background
= &colorbg_out
;
955 prop_text_out
.size
= 6;
956 prop_text_out
.position
= OVER
;
958 /* color of text : status of the process */
959 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
961 prop_text_out
.foreground
->red
= 0xffff;
962 prop_text_out
.foreground
->green
= 0xffff;
963 prop_text_out
.foreground
->blue
= 0xffff;
965 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
967 prop_text_out
.foreground
->red
= 0x0fff;
968 prop_text_out
.foreground
->green
= 0xffff;
969 prop_text_out
.foreground
->blue
= 0xfff0;
971 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
973 prop_text_out
.foreground
->red
= 0xffff;
974 prop_text_out
.foreground
->green
= 0xffff;
975 prop_text_out
.foreground
->blue
= 0x0000;
977 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
979 prop_text_out
.foreground
->red
= 0xffff;
980 prop_text_out
.foreground
->green
= 0x0000;
981 prop_text_out
.foreground
->blue
= 0xffff;
983 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
985 prop_text_out
.foreground
->red
= 0xffff;
986 prop_text_out
.foreground
->green
= 0x0000;
987 prop_text_out
.foreground
->blue
= 0x0000;
989 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
991 prop_text_out
.foreground
->red
= 0x0000;
992 prop_text_out
.foreground
->green
= 0xffff;
993 prop_text_out
.foreground
->blue
= 0x0000;
997 prop_text_out
.foreground
->red
= 0xffff;
998 prop_text_out
.foreground
->green
= 0xffff;
999 prop_text_out
.foreground
->blue
= 0xffff;
1003 /* Print status of the process : U, WF, WC, E, W, R */
1004 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1005 prop_text_out
.text
= "U->";
1006 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1007 prop_text_out
.text
= "WF->";
1008 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1009 prop_text_out
.text
= "WC->";
1010 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1011 prop_text_out
.text
= "E->";
1012 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1013 prop_text_out
.text
= "W->";
1014 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1015 prop_text_out
.text
= "R->";
1017 prop_text_out
.text
= "U";
1019 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1020 //gdk_gc_unref(draw_context_out->gc);
1022 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1023 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1024 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
1026 PropertiesLine prop_line_out
;
1027 prop_line_out
.color
= g_new(GdkColor
,1);
1028 prop_line_out
.line_width
= 2;
1029 prop_line_out
.style
= GDK_LINE_SOLID
;
1030 prop_line_out
.position
= MIDDLE
;
1032 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
1034 /* color of line : status of the process */
1035 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1037 prop_line_out
.color
->red
= 0xffff;
1038 prop_line_out
.color
->green
= 0xffff;
1039 prop_line_out
.color
->blue
= 0xffff;
1041 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1043 prop_line_out
.color
->red
= 0x0fff;
1044 prop_line_out
.color
->green
= 0xffff;
1045 prop_line_out
.color
->blue
= 0xfff0;
1047 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1049 prop_line_out
.color
->red
= 0xffff;
1050 prop_line_out
.color
->green
= 0xffff;
1051 prop_line_out
.color
->blue
= 0x0000;
1053 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1055 prop_line_out
.color
->red
= 0xffff;
1056 prop_line_out
.color
->green
= 0x0000;
1057 prop_line_out
.color
->blue
= 0xffff;
1059 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1061 prop_line_out
.color
->red
= 0xffff;
1062 prop_line_out
.color
->green
= 0x0000;
1063 prop_line_out
.color
->blue
= 0x0000;
1065 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1067 prop_line_out
.color
->red
= 0x0000;
1068 prop_line_out
.color
->green
= 0xffff;
1069 prop_line_out
.color
->blue
= 0x0000;
1073 prop_line_out
.color
->red
= 0xffff;
1074 prop_line_out
.color
->green
= 0xffff;
1075 prop_line_out
.color
->blue
= 0xffff;
1078 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1079 g_free(prop_line_out
.color
);
1080 //gdk_gc_unref(draw_context_out->gc);
1081 /* Note : finishing line will have to be added when trace read over. */
1083 /* Finally, update the drawing context of the pid_in. */
1085 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1086 draw_context_in
->current
->modify_over
->x
= x
;
1087 draw_context_in
->current
->modify_under
->x
= x
;
1088 draw_context_in
->current
->modify_over
->y
= y_in
;
1089 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1090 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1091 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1092 widget
= control_flow_data
->drawing
->drawing_area
;
1093 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1094 //draw_context_in->gc = widget->style->black_gc;
1095 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1096 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1098 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1099 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1101 /* Draw the line/bg of the in process */
1102 if(draw_context_in
->previous
->middle
->x
== -1)
1104 draw_context_in
->previous
->over
->x
=
1105 control_flow_data
->drawing
->damage_begin
;
1106 draw_context_in
->previous
->middle
->x
=
1107 control_flow_data
->drawing
->damage_begin
;
1108 draw_context_in
->previous
->under
->x
=
1109 control_flow_data
->drawing
->damage_begin
;
1111 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1115 draw_context_in
->current
->middle
->x
= x
;
1116 draw_context_in
->current
->over
->x
= x
;
1117 draw_context_in
->current
->under
->x
= x
;
1118 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1119 draw_context_in
->current
->over
->y
= y_in
;
1120 draw_context_in
->current
->under
->y
= y_in
+ height
;
1121 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1122 draw_context_in
->previous
->over
->y
= y_in
;
1123 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1125 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1126 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1129 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1131 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1132 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1133 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1135 PropertiesBG prop_bg
;
1136 prop_bg
.color
= g_new(GdkColor
,1);
1138 switch(tfc
->index
) {
1140 prop_bg
.color
->red
= 0x1515;
1141 prop_bg
.color
->green
= 0x1515;
1142 prop_bg
.color
->blue
= 0x8c8c;
1145 prop_bg
.color
->red
= 0x4e4e;
1146 prop_bg
.color
->green
= 0xa9a9;
1147 prop_bg
.color
->blue
= 0xa4a4;
1150 prop_bg
.color
->red
= 0x7a7a;
1151 prop_bg
.color
->green
= 0x4a4a;
1152 prop_bg
.color
->blue
= 0x8b8b;
1155 prop_bg
.color
->red
= 0x8080;
1156 prop_bg
.color
->green
= 0x7777;
1157 prop_bg
.color
->blue
= 0x4747;
1160 prop_bg
.color
->red
= 0xe7e7;
1161 prop_bg
.color
->green
= 0xe7e7;
1162 prop_bg
.color
->blue
= 0xe7e7;
1166 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1167 g_free(prop_bg
.color
);
1168 //gdk_gc_unref(draw_context_in->gc);
1171 draw_context_in
->gc
= widget
->style
->black_gc
;
1173 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1174 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1175 PropertiesText prop_text_in
;
1176 prop_text_in
.foreground
= &colorfg_in
;
1177 prop_text_in
.background
= &colorbg_in
;
1178 prop_text_in
.size
= 6;
1179 prop_text_in
.position
= OVER
;
1181 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1182 /* foreground of text : status of the process */
1183 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1185 prop_text_in
.foreground
->red
= 0xffff;
1186 prop_text_in
.foreground
->green
= 0xffff;
1187 prop_text_in
.foreground
->blue
= 0xffff;
1189 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1191 prop_text_in
.foreground
->red
= 0x0fff;
1192 prop_text_in
.foreground
->green
= 0xffff;
1193 prop_text_in
.foreground
->blue
= 0xfff0;
1195 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1197 prop_text_in
.foreground
->red
= 0xffff;
1198 prop_text_in
.foreground
->green
= 0xffff;
1199 prop_text_in
.foreground
->blue
= 0x0000;
1201 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1203 prop_text_in
.foreground
->red
= 0xffff;
1204 prop_text_in
.foreground
->green
= 0x0000;
1205 prop_text_in
.foreground
->blue
= 0xffff;
1207 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1209 prop_text_in
.foreground
->red
= 0xffff;
1210 prop_text_in
.foreground
->green
= 0x0000;
1211 prop_text_in
.foreground
->blue
= 0x0000;
1213 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1215 prop_text_in
.foreground
->red
= 0x0000;
1216 prop_text_in
.foreground
->green
= 0xffff;
1217 prop_text_in
.foreground
->blue
= 0x0000;
1221 prop_text_in
.foreground
->red
= 0xffff;
1222 prop_text_in
.foreground
->green
= 0xffff;
1223 prop_text_in
.foreground
->blue
= 0xffff;
1228 /* Print status of the process : U, WF, WC, E, W, R */
1229 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1230 prop_text_in
.text
= "U->";
1231 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1232 prop_text_in
.text
= "WF->";
1233 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1234 prop_text_in
.text
= "WC->";
1235 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1236 prop_text_in
.text
= "E->";
1237 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1238 prop_text_in
.text
= "W->";
1239 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1240 prop_text_in
.text
= "R->";
1242 prop_text_in
.text
= "U";
1244 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1245 //gdk_gc_unref(draw_context_in->gc);
1247 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1248 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1249 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1251 PropertiesLine prop_line_in
;
1252 prop_line_in
.color
= g_new(GdkColor
,1);
1253 prop_line_in
.line_width
= 2;
1254 prop_line_in
.style
= GDK_LINE_SOLID
;
1255 prop_line_in
.position
= MIDDLE
;
1257 /* color of line : status of the process */
1258 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1260 prop_line_in
.color
->red
= 0xffff;
1261 prop_line_in
.color
->green
= 0xffff;
1262 prop_line_in
.color
->blue
= 0xffff;
1264 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1266 prop_line_in
.color
->red
= 0x0fff;
1267 prop_line_in
.color
->green
= 0xffff;
1268 prop_line_in
.color
->blue
= 0xfff0;
1270 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1272 prop_line_in
.color
->red
= 0xffff;
1273 prop_line_in
.color
->green
= 0xffff;
1274 prop_line_in
.color
->blue
= 0x0000;
1276 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1278 prop_line_in
.color
->red
= 0xffff;
1279 prop_line_in
.color
->green
= 0x0000;
1280 prop_line_in
.color
->blue
= 0xffff;
1282 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1284 prop_line_in
.color
->red
= 0xffff;
1285 prop_line_in
.color
->green
= 0x0000;
1286 prop_line_in
.color
->blue
= 0x0000;
1288 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1290 prop_line_in
.color
->red
= 0x0000;
1291 prop_line_in
.color
->green
= 0xffff;
1292 prop_line_in
.color
->blue
= 0x0000;
1296 prop_line_in
.color
->red
= 0xffff;
1297 prop_line_in
.color
->green
= 0xffff;
1298 prop_line_in
.color
->blue
= 0xffff;
1301 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1302 g_free(prop_line_in
.color
);
1303 //gdk_gc_unref(draw_context_in->gc);
1313 GString
*string
= g_string_new("");;
1314 gboolean field_names
= TRUE
, state
= TRUE
;
1316 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1317 g_string_append_printf(string
,"\n");
1320 g_string_append_printf(string
, " %s",
1321 g_quark_to_string(tfs
->process
->state
->s
));
1324 g_info("%s",string
->str
);
1326 g_string_free(string
, TRUE
);
1328 /* End of text dump */
1333 /* after_schedchange_hook
1335 * The draw after hook is called by the reading API to have a
1336 * particular event drawn on the screen.
1337 * @param hook_data ControlFlowData structure of the viewer.
1338 * @param call_data Event context.
1340 * This function adds items to be drawn in a queue for each process.
1343 int after_schedchange_hook(void *hook_data
, void *call_data
)
1345 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1346 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1348 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1350 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1355 LttTime evtime
= ltt_event_time(e
);
1357 /* Add process to process list (if not present) */
1358 LttvProcessState
*process_in
;
1360 guint pl_height
= 0;
1361 HashedProcessData
*hashed_process_data_in
= NULL
;
1363 ProcessList
*process_list
= control_flow_data
->process_list
;
1368 LttField
*f
= ltt_event_field(e
);
1370 element
= ltt_field_member(f
,0);
1371 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1372 element
= ltt_field_member(f
,1);
1373 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1377 /* Find process pid_in in the list... */
1378 //process_in = lttv_state_find_process(tfs, pid_in);
1379 process_in
= tfs
->process
;
1380 /* It should exist, because we are after the state update. */
1382 g_assert(process_in
!= NULL
);
1383 #endif //EXTRA_CHECK
1384 birth
= process_in
->creation_time
;
1386 hashed_process_data_in
= processlist_get_process_data(process_list
,
1388 process_in
->last_cpu_index
,
1390 tfc
->t_context
->index
);
1391 if(hashed_process_data_in
== NULL
)
1393 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1394 const gchar
*name
= g_quark_to_string(process_in
->name
);
1395 ProcessInfo
*process_info
;
1396 Drawing_t
*drawing
= control_flow_data
->drawing
;
1397 /* Process not present */
1398 processlist_add(process_list
,
1401 process_in
->last_cpu_index
,
1404 tfc
->t_context
->index
,
1408 &hashed_process_data_in
);
1409 gtk_widget_set_size_request(drawing
->drawing_area
,
1412 gtk_widget_queue_draw(drawing
->drawing_area
);
1414 /* Set the current process */
1415 process_list
->current_hash_data
[process_in
->last_cpu_index
] =
1416 hashed_process_data_in
;
1418 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
1421 TimeWindow time_window
=
1422 lttvwindow_get_time_window(control_flow_data
->tab
);
1425 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1426 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1428 #endif //EXTRA_CHECK
1429 Drawing_t
*drawing
= control_flow_data
->drawing
;
1430 guint width
= drawing
->width
;
1433 convert_time_to_pixels(
1439 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1440 hashed_process_data_in
->x
.middle
= new_x
;
1441 hashed_process_data_in
->x
.middle_used
= FALSE
;
1442 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1452 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1453 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1455 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1457 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1458 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1464 LttTime evtime
= ltt_event_time(e
);
1465 TimeWindow time_window
=
1466 lttvwindow_get_time_window(control_flow_data
->tab
);
1468 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
1470 //if(time < time_beg || time > time_end) return;
1471 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1472 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1476 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1478 g_debug("schedchange!");
1480 /* Add process to process list (if not present) and get drawing "y" from
1481 * process position */
1482 guint pid_out
, pid_in
;
1483 LttvProcessState
*process_out
, *process_in
;
1485 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1487 ProcessList
*process_list
= control_flow_data
->process_list
;
1490 LttField
*f
= ltt_event_field(e
);
1492 element
= ltt_field_member(f
,0);
1493 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1494 element
= ltt_field_member(f
,1);
1495 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1496 //g_debug("out : %u in : %u", pid_out, pid_in);
1499 /* Find process pid_out in the list... */
1500 process_out
= lttv_state_find_process(tfs
, pid_out
);
1501 if(process_out
== NULL
) return 0;
1502 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1504 birth
= process_out
->creation_time
;
1505 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1506 HashedProcessData
*hashed_process_data_out
= NULL
;
1508 if(processlist_get_process_pixels(process_list
,
1511 tfc
->t_context
->index
,
1514 &hashed_process_data_out
) == 1)
1516 /* Process not present */
1517 processlist_add(process_list
,
1520 tfc
->t_context
->index
,
1523 &hashed_process_data_out
);
1524 processlist_get_process_pixels(process_list
,
1527 tfc
->t_context
->index
,
1530 &hashed_process_data_out
);
1531 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1536 /* Find process pid_in in the list... */
1537 process_in
= lttv_state_find_process(tfs
, pid_in
);
1538 if(process_in
== NULL
) return 0;
1539 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1541 birth
= process_in
->creation_time
;
1542 name
= strdup(g_quark_to_string(process_in
->name
));
1543 HashedProcessData
*hashed_process_data_in
= NULL
;
1545 if(processlist_get_process_pixels(process_list
,
1548 tfc
->t_context
->index
,
1551 &hashed_process_data_in
) == 1)
1553 /* Process not present */
1554 processlist_add(process_list
,
1557 tfc
->t_context
->index
,
1560 &hashed_process_data_in
);
1561 processlist_get_process_pixels(process_list
,
1564 tfc
->t_context
->index
,
1567 &hashed_process_data_in
);
1569 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1574 /* Find pixels corresponding to time of the event. If the time does
1575 * not fit in the window, show a warning, not supposed to happend. */
1577 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1579 //LttTime time = ltt_event_time(e);
1581 //LttTime window_end = time_window->time_window.end_time;
1584 //convert_time_to_pixels(
1590 //assert(x <= width);
1592 /* draw what represents the event for outgoing process. */
1594 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1595 //draw_context_out->current->modify_over->x = x;
1596 draw_context_out
->current
->modify_over
->y
= y_out
;
1597 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1598 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1599 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1600 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1601 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1603 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1604 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1606 /*if(process_out->state->s == LTTV_STATE_RUN)
1608 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1609 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1610 PropertiesBG prop_bg;
1611 prop_bg.color = g_new(GdkColor,1);
1613 prop_bg.color->red = 0xffff;
1614 prop_bg.color->green = 0xffff;
1615 prop_bg.color->blue = 0xffff;
1617 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1618 g_free(prop_bg.color);
1619 gdk_gc_unref(draw_context_out->gc);
1622 draw_context_out
->gc
= widget
->style
->black_gc
;
1624 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1625 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1626 PropertiesText prop_text_out
;
1627 prop_text_out
.foreground
= &colorfg_out
;
1628 prop_text_out
.background
= &colorbg_out
;
1629 prop_text_out
.size
= 6;
1630 prop_text_out
.position
= OVER
;
1632 /* color of text : status of the process */
1633 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1635 prop_text_out
.foreground
->red
= 0xffff;
1636 prop_text_out
.foreground
->green
= 0xffff;
1637 prop_text_out
.foreground
->blue
= 0xffff;
1639 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1641 prop_text_out
.foreground
->red
= 0x0fff;
1642 prop_text_out
.foreground
->green
= 0xffff;
1643 prop_text_out
.foreground
->blue
= 0xfff0;
1645 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1647 prop_text_out
.foreground
->red
= 0xffff;
1648 prop_text_out
.foreground
->green
= 0xffff;
1649 prop_text_out
.foreground
->blue
= 0x0000;
1651 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1653 prop_text_out
.foreground
->red
= 0xffff;
1654 prop_text_out
.foreground
->green
= 0x0000;
1655 prop_text_out
.foreground
->blue
= 0xffff;
1657 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1659 prop_text_out
.foreground
->red
= 0xffff;
1660 prop_text_out
.foreground
->green
= 0x0000;
1661 prop_text_out
.foreground
->blue
= 0x0000;
1663 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1665 prop_text_out
.foreground
->red
= 0x0000;
1666 prop_text_out
.foreground
->green
= 0xffff;
1667 prop_text_out
.foreground
->blue
= 0x0000;
1671 prop_text_out
.foreground
->red
= 0xffff;
1672 prop_text_out
.foreground
->green
= 0xffff;
1673 prop_text_out
.foreground
->blue
= 0xffff;
1676 /* Print status of the process : U, WF, WC, E, W, R */
1677 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1678 prop_text_out
.text
= "U";
1679 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1680 prop_text_out
.text
= "WF";
1681 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1682 prop_text_out
.text
= "WC";
1683 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1684 prop_text_out
.text
= "E";
1685 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1686 prop_text_out
.text
= "W";
1687 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1688 prop_text_out
.text
= "R";
1690 prop_text_out
.text
= "U";
1692 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1694 //gdk_gc_unref(draw_context_out->gc);
1696 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1697 draw_context_out
->current
->over
->y
= y_out
;
1698 draw_context_out
->current
->under
->y
= y_out
+height
;
1699 draw_context_out
->current
->status
= process_out
->state
->s
;
1701 /* for pid_out : remove previous, Prev = current, new current (default) */
1702 g_free(draw_context_out
->previous
->modify_under
);
1703 g_free(draw_context_out
->previous
->modify_middle
);
1704 g_free(draw_context_out
->previous
->modify_over
);
1705 g_free(draw_context_out
->previous
->under
);
1706 g_free(draw_context_out
->previous
->middle
);
1707 g_free(draw_context_out
->previous
->over
);
1708 g_free(draw_context_out
->previous
);
1710 draw_context_out
->previous
= draw_context_out
->current
;
1712 draw_context_out
->current
= g_new(DrawInfo
,1);
1713 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1714 draw_context_out
->current
->over
->x
= -1;
1715 draw_context_out
->current
->over
->y
= -1;
1716 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1717 draw_context_out
->current
->middle
->x
= -1;
1718 draw_context_out
->current
->middle
->y
= -1;
1719 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1720 draw_context_out
->current
->under
->x
= -1;
1721 draw_context_out
->current
->under
->y
= -1;
1722 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1723 draw_context_out
->current
->modify_over
->x
= -1;
1724 draw_context_out
->current
->modify_over
->y
= -1;
1725 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1726 draw_context_out
->current
->modify_middle
->x
= -1;
1727 draw_context_out
->current
->modify_middle
->y
= -1;
1728 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1729 draw_context_out
->current
->modify_under
->x
= -1;
1730 draw_context_out
->current
->modify_under
->y
= -1;
1731 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1733 /* Finally, update the drawing context of the pid_in. */
1735 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1736 //draw_context_in->current->modify_over->x = x;
1737 draw_context_in
->current
->modify_over
->y
= y_in
;
1738 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1739 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1740 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1741 widget
= control_flow_data
->drawing
->drawing_area
;
1742 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1744 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1745 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1747 /*if(process_in->state->s == LTTV_STATE_RUN)
1749 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1750 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1751 PropertiesBG prop_bg;
1752 prop_bg.color = g_new(GdkColor,1);
1754 prop_bg.color->red = 0xffff;
1755 prop_bg.color->green = 0xffff;
1756 prop_bg.color->blue = 0xffff;
1758 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1759 g_free(prop_bg.color);
1760 gdk_gc_unref(draw_context_in->gc);
1763 draw_context_in
->gc
= widget
->style
->black_gc
;
1765 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1766 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1767 PropertiesText prop_text_in
;
1768 prop_text_in
.foreground
= &colorfg_in
;
1769 prop_text_in
.background
= &colorbg_in
;
1770 prop_text_in
.size
= 6;
1771 prop_text_in
.position
= OVER
;
1773 /* foreground of text : status of the process */
1774 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1776 prop_text_in
.foreground
->red
= 0xffff;
1777 prop_text_in
.foreground
->green
= 0xffff;
1778 prop_text_in
.foreground
->blue
= 0xffff;
1780 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1782 prop_text_in
.foreground
->red
= 0x0fff;
1783 prop_text_in
.foreground
->green
= 0xffff;
1784 prop_text_in
.foreground
->blue
= 0xfff0;
1786 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1788 prop_text_in
.foreground
->red
= 0xffff;
1789 prop_text_in
.foreground
->green
= 0xffff;
1790 prop_text_in
.foreground
->blue
= 0x0000;
1792 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1794 prop_text_in
.foreground
->red
= 0xffff;
1795 prop_text_in
.foreground
->green
= 0x0000;
1796 prop_text_in
.foreground
->blue
= 0xffff;
1798 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1800 prop_text_in
.foreground
->red
= 0xffff;
1801 prop_text_in
.foreground
->green
= 0x0000;
1802 prop_text_in
.foreground
->blue
= 0x0000;
1804 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1806 prop_text_in
.foreground
->red
= 0x0000;
1807 prop_text_in
.foreground
->green
= 0xffff;
1808 prop_text_in
.foreground
->blue
= 0x0000;
1812 prop_text_in
.foreground
->red
= 0xffff;
1813 prop_text_in
.foreground
->green
= 0xffff;
1814 prop_text_in
.foreground
->blue
= 0xffff;
1818 /* Print status of the process : U, WF, WC, E, W, R */
1819 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1820 prop_text_in
.text
= "U";
1821 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1822 prop_text_in
.text
= "WF";
1823 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1824 prop_text_in
.text
= "WC";
1825 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1826 prop_text_in
.text
= "E";
1827 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1828 prop_text_in
.text
= "W";
1829 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1830 prop_text_in
.text
= "R";
1832 prop_text_in
.text
= "U";
1834 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1837 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1840 prop_text_in
.foreground
= &colorfg_in
;
1841 prop_text_in
.background
= &colorbg_in
;
1842 prop_text_in
.foreground
->red
= 0xffff;
1843 prop_text_in
.foreground
->green
= 0xffff;
1844 prop_text_in
.foreground
->blue
= 0xffff;
1845 prop_text_in
.size
= 6;
1846 prop_text_in
.position
= UNDER
;
1848 prop_text_in
.text
= g_new(gchar
, 260);
1849 strcpy(prop_text_in
.text
, "CPU ");
1850 snprintf(tmp
, 255, "%u", tfc
->index
);
1851 strcat(prop_text_in
.text
, tmp
);
1853 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1854 g_free(prop_text_in
.text
);
1858 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1859 draw_context_in
->current
->over
->y
= y_in
;
1860 draw_context_in
->current
->under
->y
= y_in
+height
;
1861 draw_context_in
->current
->status
= process_in
->state
->s
;
1863 /* for pid_in : remove previous, Prev = current, new current (default) */
1864 g_free(draw_context_in
->previous
->modify_under
);
1865 g_free(draw_context_in
->previous
->modify_middle
);
1866 g_free(draw_context_in
->previous
->modify_over
);
1867 g_free(draw_context_in
->previous
->under
);
1868 g_free(draw_context_in
->previous
->middle
);
1869 g_free(draw_context_in
->previous
->over
);
1870 g_free(draw_context_in
->previous
);
1872 draw_context_in
->previous
= draw_context_in
->current
;
1874 draw_context_in
->current
= g_new(DrawInfo
,1);
1875 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1876 draw_context_in
->current
->over
->x
= -1;
1877 draw_context_in
->current
->over
->y
= -1;
1878 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1879 draw_context_in
->current
->middle
->x
= -1;
1880 draw_context_in
->current
->middle
->y
= -1;
1881 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1882 draw_context_in
->current
->under
->x
= -1;
1883 draw_context_in
->current
->under
->y
= -1;
1884 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1885 draw_context_in
->current
->modify_over
->x
= -1;
1886 draw_context_in
->current
->modify_over
->y
= -1;
1887 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1888 draw_context_in
->current
->modify_middle
->x
= -1;
1889 draw_context_in
->current
->modify_middle
->y
= -1;
1890 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1891 draw_context_in
->current
->modify_under
->x
= -1;
1892 draw_context_in
->current
->modify_under
->y
= -1;
1893 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1902 static inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1904 PropertiesLine prop_line
;
1905 prop_line
.line_width
= 1;
1906 prop_line
.style
= GDK_LINE_SOLID
;
1908 //GdkColormap *colormap = gdk_colormap_get_system();
1910 /* color of line : execution mode of the process */
1911 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1912 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1913 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1914 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1915 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1916 prop_line
.color
= drawing_colors
[COL_TRAP
];
1917 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1918 prop_line
.color
= drawing_colors
[COL_IRQ
];
1919 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1920 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1922 prop_line
.color
= drawing_colors
[COL_WHITE
];
1924 //gdk_colormap_alloc_color(colormap,
1935 /* before_execmode_hook
1937 * This function basically draw lines and icons. Two types of lines are drawn :
1938 * one small (3 pixels?) representing the state of the process and the second
1939 * type is thicker (10 pixels?) representing on which CPU a process is running
1940 * (and this only in running state).
1942 * Extremums of the lines :
1943 * x_min : time of the last event context for this process kept in memory.
1944 * x_max : time of the current event.
1945 * y : middle of the process in the process list. The process is found in the
1946 * list, therefore is it's position in pixels.
1948 * The choice of lines'color is defined by the context of the last event for this
1953 int before_execmode_hook(void *hook_data
, void *call_data
)
1955 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1956 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1958 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1960 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1965 LttTime evtime
= ltt_event_time(e
);
1967 /* we are in a execmode, before the state update. We must draw the
1968 * items corresponding to the state before it changes : now is the right
1972 LttvProcessState
*process
= tfs
->process
;
1973 g_assert(process
!= NULL
);
1975 guint pid
= process
->pid
;
1977 /* Well, the process_out existed : we must get it in the process hash
1978 * or add it, and draw its items.
1980 /* Add process to process list (if not present) */
1981 guint pl_height
= 0;
1982 HashedProcessData
*hashed_process_data
= NULL
;
1983 ProcessList
*process_list
= control_flow_data
->process_list
;
1984 LttTime birth
= process
->creation_time
;
1986 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
1987 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
1989 hashed_process_data
= processlist_get_process_data(process_list
,
1991 process
->last_cpu_index
,
1993 tfc
->t_context
->index
);
1994 if(unlikely(hashed_process_data
== NULL
))
1996 g_assert(pid
== 0 || pid
!= process
->ppid
);
1997 ProcessInfo
*process_info
;
1998 /* Process not present */
1999 Drawing_t
*drawing
= control_flow_data
->drawing
;
2000 const gchar
*name
= g_quark_to_string(process
->name
);
2001 processlist_add(process_list
,
2004 process
->last_cpu_index
,
2007 tfc
->t_context
->index
,
2011 &hashed_process_data
);
2012 gtk_widget_set_size_request(drawing
->drawing_area
,
2015 gtk_widget_queue_draw(drawing
->drawing_area
);
2017 /* Set the current process */
2018 process_list
->current_hash_data
[process
->last_cpu_index
] =
2019 hashed_process_data
;
2022 /* Now, the process is in the state hash and our own process hash.
2023 * We definitely can draw the items related to the ending state.
2026 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2029 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2030 TimeWindow time_window
=
2031 lttvwindow_get_time_window(control_flow_data
->tab
);
2034 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2035 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2037 #endif //EXTRA_CHECK
2038 Drawing_t
*drawing
= control_flow_data
->drawing
;
2039 guint width
= drawing
->width
;
2041 convert_time_to_pixels(
2047 /* Draw collision indicator */
2048 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2049 gdk_draw_point(hashed_process_data
->pixmap
,
2052 (hashed_process_data
->height
/2)-3);
2053 hashed_process_data
->x
.middle_marked
= TRUE
;
2056 TimeWindow time_window
=
2057 lttvwindow_get_time_window(control_flow_data
->tab
);
2060 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2061 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2063 #endif //EXTRA_CHECK
2064 Drawing_t
*drawing
= control_flow_data
->drawing
;
2065 guint width
= drawing
->width
;
2068 convert_time_to_pixels(
2075 /* Jump over draw if we are at the same x position */
2076 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2077 hashed_process_data
->x
.middle_used
))
2079 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2080 /* Draw collision indicator */
2081 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2082 gdk_draw_point(hashed_process_data
->pixmap
,
2085 (hashed_process_data
->height
/2)-3);
2086 hashed_process_data
->x
.middle_marked
= TRUE
;
2091 DrawContext draw_context
;
2092 /* Now create the drawing context that will be used to draw
2093 * items related to the last state. */
2094 draw_context
.drawable
= hashed_process_data
->pixmap
;
2095 draw_context
.gc
= drawing
->gc
;
2096 draw_context
.pango_layout
= drawing
->pango_layout
;
2097 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2098 draw_context
.drawinfo
.end
.x
= x
;
2100 draw_context
.drawinfo
.y
.over
= 1;
2101 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2102 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2104 draw_context
.drawinfo
.start
.offset
.over
= 0;
2105 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2106 draw_context
.drawinfo
.start
.offset
.under
= 0;
2107 draw_context
.drawinfo
.end
.offset
.over
= 0;
2108 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2109 draw_context
.drawinfo
.end
.offset
.under
= 0;
2113 PropertiesLine prop_line
= prepare_s_e_line(process
);
2114 draw_line((void*)&prop_line
, (void*)&draw_context
);
2117 /* become the last x position */
2118 hashed_process_data
->x
.middle
= x
;
2119 hashed_process_data
->x
.middle_used
= TRUE
;
2120 hashed_process_data
->x
.middle_marked
= FALSE
;
2122 /* Calculate the next good time */
2123 convert_pixels_to_time(width
, x
+1, time_window
,
2124 &hashed_process_data
->next_good_time
);
2131 /* after_execmode_hook
2133 * The draw after hook is called by the reading API to have a
2134 * particular event drawn on the screen.
2135 * @param hook_data ControlFlowData structure of the viewer.
2136 * @param call_data Event context.
2138 * This function adds items to be drawn in a queue for each process.
2141 int after_execmode_hook(void *hook_data
, void *call_data
)
2143 /**************** DOES NOTHING!! *************/
2144 /* hook desactivated in drawing.c */
2149 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2150 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2152 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2154 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2159 LttTime evtime
= ltt_event_time(e
);
2161 /* Add process to process list (if not present) */
2162 LttvProcessState
*process
;
2164 guint pl_height
= 0;
2165 HashedProcessData
*hashed_process_data
= NULL
;
2167 ProcessList
*process_list
= control_flow_data
->process_list
;
2169 /* Find process pid_in in the list... */
2170 process
= tfs
->process
;
2171 /* It should exist, because we are after the state update. */
2172 g_assert(process
!= NULL
);
2174 guint pid
= process
->pid
;
2176 birth
= process
->creation_time
;
2178 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
2179 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2181 hashed_process_data
= processlist_get_process_data(process_list
,
2183 process
->last_cpu_index
,
2185 tfc
->t_context
->index
);
2186 if(unlikely(hashed_process_data
== NULL
))
2188 g_assert(pid
== 0 || pid
!= process
->ppid
);
2189 /* Process not present */
2190 Drawing_t
*drawing
= control_flow_data
->drawing
;
2191 const gchar
*name
= g_quark_to_string(process
->name
);
2192 ProcessInfo
*process_info
;
2193 processlist_add(process_list
,
2196 process
->last_cpu_index
,
2199 tfc
->t_context
->index
,
2203 &hashed_process_data
);
2204 gtk_widget_set_size_request(drawing
->drawing_area
,
2207 gtk_widget_queue_draw(drawing
->drawing_area
);
2209 /* Set the current process */
2210 process_list
->current_hash_data
[process
->last_cpu_index
] =
2211 hashed_process_data
;
2214 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2217 TimeWindow time_window
=
2218 lttvwindow_get_time_window(control_flow_data
->tab
);
2221 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2222 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2224 #endif //EXTRA_CHECK
2225 Drawing_t
*drawing
= control_flow_data
->drawing
;
2226 guint width
= drawing
->width
;
2229 convert_time_to_pixels(
2235 if(hashed_process_data
->x
.middle
!= new_x
) {
2236 hashed_process_data
->x
.middle
= new_x
;
2237 hashed_process_data
->x
.middle_used
= FALSE
;
2238 hashed_process_data
->x
.middle_marked
= FALSE
;
2246 /* before_process_hook
2248 * Draw lines for process event.
2250 * @param hook_data ControlFlowData structure of the viewer.
2251 * @param call_data Event context.
2253 * This function adds items to be drawn in a queue for each process.
2256 int before_process_hook(void *hook_data
, void *call_data
)
2258 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2259 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2261 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2263 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2268 LttTime evtime
= ltt_event_time(e
);
2272 LttField
*f
= ltt_event_field(e
);
2274 element
= ltt_field_member(f
,0);
2275 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2278 if(sub_id
== 3) { /* exit */
2280 /* Add process to process list (if not present) */
2281 LttvProcessState
*process
= tfs
->process
;
2282 guint pid
= process
->pid
;
2284 guint pl_height
= 0;
2285 HashedProcessData
*hashed_process_data
= NULL
;
2287 ProcessList
*process_list
= control_flow_data
->process_list
;
2289 g_assert(process
!= NULL
);
2291 birth
= process
->creation_time
;
2293 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
2294 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2296 hashed_process_data
= processlist_get_process_data(process_list
,
2298 process
->last_cpu_index
,
2300 tfc
->t_context
->index
);
2301 if(unlikely(hashed_process_data
== NULL
))
2303 g_assert(pid
== 0 || pid
!= process
->ppid
);
2304 /* Process not present */
2305 Drawing_t
*drawing
= control_flow_data
->drawing
;
2306 const gchar
*name
= g_quark_to_string(process
->name
);
2307 ProcessInfo
*process_info
;
2308 processlist_add(process_list
,
2311 process
->last_cpu_index
,
2314 tfc
->t_context
->index
,
2318 &hashed_process_data
);
2319 gtk_widget_set_size_request(drawing
->drawing_area
,
2322 gtk_widget_queue_draw(drawing
->drawing_area
);
2326 /* Now, the process is in the state hash and our own process hash.
2327 * We definitely can draw the items related to the ending state.
2330 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2333 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2334 TimeWindow time_window
=
2335 lttvwindow_get_time_window(control_flow_data
->tab
);
2338 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2339 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2341 #endif //EXTRA_CHECK
2342 Drawing_t
*drawing
= control_flow_data
->drawing
;
2343 guint width
= drawing
->width
;
2345 convert_time_to_pixels(
2351 /* Draw collision indicator */
2352 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2353 gdk_draw_point(hashed_process_data
->pixmap
,
2356 (hashed_process_data
->height
/2)-3);
2357 hashed_process_data
->x
.middle_marked
= TRUE
;
2360 TimeWindow time_window
=
2361 lttvwindow_get_time_window(control_flow_data
->tab
);
2364 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2365 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2367 #endif //EXTRA_CHECK
2368 Drawing_t
*drawing
= control_flow_data
->drawing
;
2369 guint width
= drawing
->width
;
2372 convert_time_to_pixels(
2379 /* Jump over draw if we are at the same x position */
2380 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2381 hashed_process_data
->x
.middle_used
))
2383 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2384 /* Draw collision indicator */
2385 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2386 gdk_draw_point(hashed_process_data
->pixmap
,
2389 (hashed_process_data
->height
/2)-3);
2390 hashed_process_data
->x
.middle_marked
= TRUE
;
2394 DrawContext draw_context
;
2396 /* Now create the drawing context that will be used to draw
2397 * items related to the last state. */
2398 draw_context
.drawable
= hashed_process_data
->pixmap
;
2399 draw_context
.gc
= drawing
->gc
;
2400 draw_context
.pango_layout
= drawing
->pango_layout
;
2401 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2402 draw_context
.drawinfo
.end
.x
= x
;
2404 draw_context
.drawinfo
.y
.over
= 1;
2405 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2406 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2408 draw_context
.drawinfo
.start
.offset
.over
= 0;
2409 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2410 draw_context
.drawinfo
.start
.offset
.under
= 0;
2411 draw_context
.drawinfo
.end
.offset
.over
= 0;
2412 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2413 draw_context
.drawinfo
.end
.offset
.under
= 0;
2417 PropertiesLine prop_line
= prepare_s_e_line(process
);
2418 draw_line((void*)&prop_line
, (void*)&draw_context
);
2421 /* become the last x position */
2422 hashed_process_data
->x
.middle
= x
;
2423 hashed_process_data
->x
.middle_used
= TRUE
;
2424 hashed_process_data
->x
.middle_marked
= FALSE
;
2426 /* Calculate the next good time */
2427 convert_pixels_to_time(width
, x
+1, time_window
,
2428 &hashed_process_data
->next_good_time
);
2442 /* after_process_hook
2444 * Create the processlist entry for the child process. Put the last
2445 * position in x at the current time value.
2447 * @param hook_data ControlFlowData structure of the viewer.
2448 * @param call_data Event context.
2450 * This function adds items to be drawn in a queue for each process.
2453 int after_process_hook(void *hook_data
, void *call_data
)
2455 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2456 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2458 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2460 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2465 LttTime evtime
= ltt_event_time(e
);
2470 LttField
*f
= ltt_event_field(e
);
2472 element
= ltt_field_member(f
,0);
2473 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2474 element
= ltt_field_member(f
,1);
2475 param1
= ltt_event_get_long_unsigned(e
,element
);
2478 if(sub_id
== 2) { /* fork */
2480 guint child_pid
= param1
;
2481 /* Add process to process list (if not present) */
2482 LttvProcessState
*process_child
;
2484 guint pl_height
= 0;
2485 HashedProcessData
*hashed_process_data_child
= NULL
;
2487 ProcessList
*process_list
= control_flow_data
->process_list
;
2489 /* Find child in the list... */
2490 process_child
= lttv_state_find_process(tfs
, child_pid
);
2491 /* It should exist, because we are after the state update. */
2492 g_assert(process_child
!= NULL
);
2494 birth
= process_child
->creation_time
;
2496 hashed_process_data_child
= processlist_get_process_data(process_list
,
2498 process_child
->last_cpu_index
,
2500 tfc
->t_context
->index
);
2501 if(likely(hashed_process_data_child
== NULL
))
2503 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2504 /* Process not present */
2505 Drawing_t
*drawing
= control_flow_data
->drawing
;
2506 const gchar
*name
= g_quark_to_string(process_child
->name
);
2507 ProcessInfo
*process_info
;
2508 processlist_add(process_list
,
2511 process_child
->last_cpu_index
,
2512 process_child
->ppid
,
2514 tfc
->t_context
->index
,
2518 &hashed_process_data_child
);
2519 gtk_widget_set_size_request(drawing
->drawing_area
,
2522 gtk_widget_queue_draw(drawing
->drawing_area
);
2526 if(likely(ltt_time_compare(hashed_process_data_child
->next_good_time
,
2529 TimeWindow time_window
=
2530 lttvwindow_get_time_window(control_flow_data
->tab
);
2533 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2534 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2536 #endif //EXTRA_CHECK
2537 Drawing_t
*drawing
= control_flow_data
->drawing
;
2538 guint width
= drawing
->width
;
2540 convert_time_to_pixels(
2546 if(likely(hashed_process_data_child
->x
.over
!= new_x
)) {
2547 hashed_process_data_child
->x
.over
= new_x
;
2548 hashed_process_data_child
->x
.over_used
= FALSE
;
2549 hashed_process_data_child
->x
.over_marked
= FALSE
;
2551 if(likely(hashed_process_data_child
->x
.middle
!= new_x
)) {
2552 hashed_process_data_child
->x
.middle
= new_x
;
2553 hashed_process_data_child
->x
.middle_used
= FALSE
;
2554 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2556 if(likely(hashed_process_data_child
->x
.under
!= new_x
)) {
2557 hashed_process_data_child
->x
.under
= new_x
;
2558 hashed_process_data_child
->x
.under_used
= FALSE
;
2559 hashed_process_data_child
->x
.under_marked
= FALSE
;
2563 } else if(sub_id
== 3) { /* exit */
2565 /* Add process to process list (if not present) */
2566 LttvProcessState
*process
= tfs
->process
;
2567 guint pid
= process
->pid
;
2569 guint pl_height
= 0;
2570 HashedProcessData
*hashed_process_data
= NULL
;
2572 ProcessList
*process_list
= control_flow_data
->process_list
;
2574 /* It should exist, because we are after the state update. */
2575 g_assert(process
!= NULL
);
2577 birth
= process
->creation_time
;
2579 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
) ){
2580 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2582 hashed_process_data
= processlist_get_process_data(process_list
,
2584 process
->last_cpu_index
,
2586 tfc
->t_context
->index
);
2587 if(unlikely(hashed_process_data
== NULL
))
2589 g_assert(pid
== 0 || pid
!= process
->ppid
);
2590 /* Process not present */
2591 Drawing_t
*drawing
= control_flow_data
->drawing
;
2592 const gchar
*name
= g_quark_to_string(process
->name
);
2593 ProcessInfo
*process_info
;
2594 processlist_add(process_list
,
2597 process
->last_cpu_index
,
2600 tfc
->t_context
->index
,
2604 &hashed_process_data
);
2605 gtk_widget_set_size_request(drawing
->drawing_area
,
2608 gtk_widget_queue_draw(drawing
->drawing_area
);
2611 /* Set the current process */
2612 process_list
->current_hash_data
[process
->last_cpu_index
] =
2613 hashed_process_data
;
2616 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2619 TimeWindow time_window
=
2620 lttvwindow_get_time_window(control_flow_data
->tab
);
2623 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2624 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2626 #endif //EXTRA_CHECK
2627 Drawing_t
*drawing
= control_flow_data
->drawing
;
2628 guint width
= drawing
->width
;
2630 convert_time_to_pixels(
2635 if(unlikely(hashed_process_data
->x
.middle
!= new_x
)) {
2636 hashed_process_data
->x
.middle
= new_x
;
2637 hashed_process_data
->x
.middle_used
= FALSE
;
2638 hashed_process_data
->x
.middle_marked
= FALSE
;
2648 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2650 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2651 Drawing_t
*drawing
= control_flow_data
->drawing
;
2652 ProcessList
*process_list
= control_flow_data
->process_list
;
2654 const TimeWindowNotifyData
*time_window_nofify_data
=
2655 ((const TimeWindowNotifyData
*)call_data
);
2657 TimeWindow
*old_time_window
=
2658 time_window_nofify_data
->old_time_window
;
2659 TimeWindow
*new_time_window
=
2660 time_window_nofify_data
->new_time_window
;
2662 /* Update the ruler */
2663 drawing_update_ruler(control_flow_data
->drawing
,
2667 /* Two cases : zoom in/out or scrolling */
2669 /* In order to make sure we can reuse the old drawing, the scale must
2670 * be the same and the new time interval being partly located in the
2671 * currently shown time interval. (reuse is only for scrolling)
2674 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
2675 old_time_window
->start_time
.tv_sec
,
2676 old_time_window
->start_time
.tv_nsec
,
2677 old_time_window
->time_width
.tv_sec
,
2678 old_time_window
->time_width
.tv_nsec
);
2680 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
2681 new_time_window
->start_time
.tv_sec
,
2682 new_time_window
->start_time
.tv_nsec
,
2683 new_time_window
->time_width
.tv_sec
,
2684 new_time_window
->time_width
.tv_nsec
);
2686 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2687 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2689 /* Same scale (scrolling) */
2690 g_info("scrolling");
2691 LttTime
*ns
= &new_time_window
->start_time
;
2692 LttTime
*nw
= &new_time_window
->time_width
;
2693 LttTime
*os
= &old_time_window
->start_time
;
2694 LttTime
*ow
= &old_time_window
->time_width
;
2695 LttTime old_end
= old_time_window
->end_time
;
2696 LttTime new_end
= new_time_window
->end_time
;
2698 //if(ns<os+w && os+w<ns+w)
2699 //if(ns<old_end && os<ns)
2700 if(ltt_time_compare(*ns
, old_end
) == -1
2701 && ltt_time_compare(*os
, *ns
) == -1)
2703 g_info("scrolling near right");
2704 /* Scroll right, keep right part of the screen */
2706 guint width
= control_flow_data
->drawing
->width
;
2707 convert_time_to_pixels(
2713 /* Copy old data to new location */
2714 copy_pixmap_region(process_list
,
2716 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2720 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2722 if(drawing
->damage_begin
== drawing
->damage_end
)
2723 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2725 drawing
->damage_begin
= 0;
2727 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2729 /* Clear the data request background, but not SAFETY */
2730 rectangle_pixmap(process_list
,
2731 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2733 drawing
->damage_begin
+SAFETY
, 0,
2734 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2736 gtk_widget_queue_draw(drawing
->drawing_area
);
2737 //gtk_widget_queue_draw_area (drawing->drawing_area,
2739 // control_flow_data->drawing->width,
2740 // control_flow_data->drawing->height);
2742 /* Get new data for the rest. */
2743 drawing_data_request(control_flow_data
->drawing
,
2744 drawing
->damage_begin
, 0,
2745 drawing
->damage_end
- drawing
->damage_begin
,
2746 control_flow_data
->drawing
->height
);
2749 //if(ns<os && os<ns+w)
2750 //if(ns<os && os<new_end)
2751 if(ltt_time_compare(*ns
,*os
) == -1
2752 && ltt_time_compare(*os
,new_end
) == -1)
2754 g_info("scrolling near left");
2755 /* Scroll left, keep left part of the screen */
2757 guint width
= control_flow_data
->drawing
->width
;
2758 convert_time_to_pixels(
2764 /* Copy old data to new location */
2765 copy_pixmap_region (process_list
,
2767 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2773 if(drawing
->damage_begin
== drawing
->damage_end
)
2774 drawing
->damage_end
= x
;
2776 drawing
->damage_end
=
2777 control_flow_data
->drawing
->width
;
2779 drawing
->damage_begin
= 0;
2781 rectangle_pixmap (process_list
,
2782 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2784 drawing
->damage_begin
, 0,
2785 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2788 gtk_widget_queue_draw(drawing
->drawing_area
);
2789 //gtk_widget_queue_draw_area (drawing->drawing_area,
2791 // control_flow_data->drawing->width,
2792 // control_flow_data->drawing->height);
2795 /* Get new data for the rest. */
2796 drawing_data_request(control_flow_data
->drawing
,
2797 drawing
->damage_begin
, 0,
2798 drawing
->damage_end
- drawing
->damage_begin
,
2799 control_flow_data
->drawing
->height
);
2802 if(ltt_time_compare(*ns
,*os
) == 0)
2804 g_info("not scrolling");
2806 g_info("scrolling far");
2807 /* Cannot reuse any part of the screen : far jump */
2810 rectangle_pixmap (process_list
,
2811 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2814 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2817 //gtk_widget_queue_draw_area (drawing->drawing_area,
2819 // control_flow_data->drawing->width,
2820 // control_flow_data->drawing->height);
2821 gtk_widget_queue_draw(drawing
->drawing_area
);
2823 drawing
->damage_begin
= 0;
2824 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2826 drawing_data_request(control_flow_data
->drawing
,
2828 control_flow_data
->drawing
->width
,
2829 control_flow_data
->drawing
->height
);
2835 /* Different scale (zoom) */
2838 rectangle_pixmap (process_list
,
2839 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2842 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2845 //gtk_widget_queue_draw_area (drawing->drawing_area,
2847 // control_flow_data->drawing->width,
2848 // control_flow_data->drawing->height);
2849 gtk_widget_queue_draw(drawing
->drawing_area
);
2851 drawing
->damage_begin
= 0;
2852 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2854 drawing_data_request(control_flow_data
->drawing
,
2856 control_flow_data
->drawing
->width
,
2857 control_flow_data
->drawing
->height
);
2865 gint
traceset_notify(void *hook_data
, void *call_data
)
2867 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2868 Drawing_t
*drawing
= control_flow_data
->drawing
;
2871 drawing_clear(control_flow_data
->drawing
);
2872 processlist_clear(control_flow_data
->process_list
);
2873 redraw_notify(control_flow_data
, NULL
);
2875 request_background_data(control_flow_data
);
2880 gint
redraw_notify(void *hook_data
, void *call_data
)
2882 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2883 Drawing_t
*drawing
= control_flow_data
->drawing
;
2884 GtkWidget
*widget
= drawing
->drawing_area
;
2886 drawing
->damage_begin
= 0;
2887 drawing
->damage_end
= drawing
->width
;
2889 /* fun feature, to be separated someday... */
2890 drawing_clear(control_flow_data
->drawing
);
2891 processlist_clear(control_flow_data
->process_list
);
2894 rectangle_pixmap (control_flow_data
->process_list
,
2895 widget
->style
->black_gc
,
2898 drawing
->alloc_width
,
2901 gtk_widget_queue_draw(drawing
->drawing_area
);
2903 if(drawing
->damage_begin
< drawing
->damage_end
)
2905 drawing_data_request(drawing
,
2906 drawing
->damage_begin
,
2908 drawing
->damage_end
-drawing
->damage_begin
,
2912 //gtk_widget_queue_draw_area(drawing->drawing_area,
2915 // drawing->height);
2921 gint
continue_notify(void *hook_data
, void *call_data
)
2923 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2924 Drawing_t
*drawing
= control_flow_data
->drawing
;
2926 //g_assert(widget->allocation.width == drawing->damage_end);
2928 if(drawing
->damage_begin
< drawing
->damage_end
)
2930 drawing_data_request(drawing
,
2931 drawing
->damage_begin
,
2933 drawing
->damage_end
-drawing
->damage_begin
,
2941 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2943 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2944 Drawing_t
*drawing
= control_flow_data
->drawing
;
2946 LttTime current_time
= *((LttTime
*)call_data
);
2948 TimeWindow time_window
=
2949 lttvwindow_get_time_window(control_flow_data
->tab
);
2951 LttTime time_begin
= time_window
.start_time
;
2952 LttTime width
= time_window
.time_width
;
2955 guint64 time_ll
= ltt_time_to_uint64(width
);
2956 time_ll
= time_ll
>> 1; /* divide by two */
2957 half_width
= ltt_time_from_uint64(time_ll
);
2959 LttTime time_end
= ltt_time_add(time_begin
, width
);
2961 LttvTracesetContext
* tsc
=
2962 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2964 LttTime trace_start
= tsc
->time_span
.start_time
;
2965 LttTime trace_end
= tsc
->time_span
.end_time
;
2967 g_info("New current time HOOK : %lu, %lu", current_time
.tv_sec
,
2968 current_time
.tv_nsec
);
2972 /* If current time is inside time interval, just move the highlight
2975 /* Else, we have to change the time interval. We have to tell it
2976 * to the main window. */
2977 /* The time interval change will take care of placing the current
2978 * time at the center of the visible area, or nearest possible if we are
2979 * at one end of the trace. */
2982 if(ltt_time_compare(current_time
, time_begin
) == -1)
2984 TimeWindow new_time_window
;
2986 if(ltt_time_compare(current_time
,
2987 ltt_time_add(trace_start
,half_width
)) == -1)
2988 time_begin
= trace_start
;
2990 time_begin
= ltt_time_sub(current_time
,half_width
);
2992 new_time_window
.start_time
= time_begin
;
2993 new_time_window
.time_width
= width
;
2994 new_time_window
.time_width_double
= ltt_time_to_double(width
);
2995 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2997 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2999 else if(ltt_time_compare(current_time
, time_end
) == 1)
3001 TimeWindow new_time_window
;
3003 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
3004 time_begin
= ltt_time_sub(trace_end
,width
);
3006 time_begin
= ltt_time_sub(current_time
,half_width
);
3008 new_time_window
.start_time
= time_begin
;
3009 new_time_window
.time_width
= width
;
3010 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3011 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3013 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3016 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
3022 typedef struct _ClosureData
{
3023 EventsRequest
*events_request
;
3024 LttvTracesetState
*tss
;
3030 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3032 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3033 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3034 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3036 EventsRequest
*events_request
= closure_data
->events_request
;
3037 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3039 LttvTracesetState
*tss
= closure_data
->tss
;
3040 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
3042 LttTime evtime
= closure_data
->end_time
;
3045 /* For the process */
3046 /* First, check if the current process is in the state computation
3047 * process list. If it is there, that means we must add it right now and
3048 * draw items from the beginning of the read for it. If it is not
3049 * present, it's a new process and it was not present : it will
3050 * be added after the state update. */
3052 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3053 #endif //EXTRA_CHECK
3054 /* tracefiles[0] is ok here, because we draw for every PID, and
3055 * assume CPU 0 for PID 0 //FIXME */
3056 LttvTracefileState
*tfs
=
3057 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
3059 LttvProcessState
*process
;
3060 process
= lttv_state_find_process(tfs
,
3063 if(unlikely(process
!= NULL
)) {
3065 /* Only draw for processes that are currently in the trace states */
3067 ProcessList
*process_list
= control_flow_data
->process_list
;
3069 /* Should be alike when background info is ready */
3070 if(control_flow_data
->background_info_waiting
==0)
3071 g_assert(ltt_time_compare(process
->creation_time
,
3072 process_info
->birth
) == 0);
3073 #endif //EXTRA_CHECK
3075 /* Now, the process is in the state hash and our own process hash.
3076 * We definitely can draw the items related to the ending state.
3079 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
3082 TimeWindow time_window
=
3083 lttvwindow_get_time_window(control_flow_data
->tab
);
3086 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3087 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3089 #endif //EXTRA_CHECK
3090 Drawing_t
*drawing
= control_flow_data
->drawing
;
3091 guint width
= drawing
->width
;
3093 guint x
= closure_data
->x_end
;
3095 DrawContext draw_context
;
3097 /* Now create the drawing context that will be used to draw
3098 * items related to the last state. */
3099 draw_context
.drawable
= hashed_process_data
->pixmap
;
3100 draw_context
.gc
= drawing
->gc
;
3101 draw_context
.pango_layout
= drawing
->pango_layout
;
3102 draw_context
.drawinfo
.end
.x
= x
;
3104 draw_context
.drawinfo
.y
.over
= 1;
3105 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
3106 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
3108 draw_context
.drawinfo
.start
.offset
.over
= 0;
3109 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3110 draw_context
.drawinfo
.start
.offset
.under
= 0;
3111 draw_context
.drawinfo
.end
.offset
.over
= 0;
3112 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3113 draw_context
.drawinfo
.end
.offset
.under
= 0;
3115 /* Jump over draw if we are at the same x position */
3116 if(x
== hashed_process_data
->x
.over
)
3120 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3122 PropertiesLine prop_line
= prepare_execmode_line(process
);
3123 draw_line((void*)&prop_line
, (void*)&draw_context
);
3125 hashed_process_data
->x
.over
= x
;
3129 if(unlikely(x
== hashed_process_data
->x
.middle
&&
3130 hashed_process_data
->x
.middle_used
)) {
3131 #if 0 /* do not mark closure : not missing information */
3132 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3133 /* Draw collision indicator */
3134 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3135 gdk_draw_point(drawing
->pixmap
,
3139 hashed_process_data
->x
.middle_marked
= TRUE
;
3144 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3146 PropertiesLine prop_line
= prepare_s_e_line(process
);
3147 draw_line((void*)&prop_line
, (void*)&draw_context
);
3149 /* become the last x position */
3150 if(likely(x
!= hashed_process_data
->x
.middle
)) {
3151 hashed_process_data
->x
.middle
= x
;
3152 /* but don't use the pixel */
3153 hashed_process_data
->x
.middle_used
= FALSE
;
3155 /* Calculate the next good time */
3156 convert_pixels_to_time(width
, x
+1, time_window
,
3157 &hashed_process_data
->next_good_time
);
3166 int before_chunk(void *hook_data
, void *call_data
)
3168 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3169 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3171 drawing_chunk_begin(events_request
, tss
);
3176 int before_request(void *hook_data
, void *call_data
)
3178 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3179 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3181 drawing_data_request_begin(events_request
, tss
);
3188 * after request is necessary in addition of after chunk in order to draw
3189 * lines until the end of the screen. after chunk just draws lines until
3196 int after_request(void *hook_data
, void *call_data
)
3198 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3199 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3200 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3202 ProcessList
*process_list
= control_flow_data
->process_list
;
3203 LttTime end_time
= events_request
->end_time
;
3205 ClosureData closure_data
;
3206 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3207 closure_data
.tss
= tss
;
3208 closure_data
.end_time
= end_time
;
3210 TimeWindow time_window
=
3211 lttvwindow_get_time_window(control_flow_data
->tab
);
3212 guint width
= control_flow_data
->drawing
->width
;
3213 convert_time_to_pixels(
3217 &closure_data
.x_end
);
3220 /* Draw last items */
3221 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3222 (void*)&closure_data
);
3224 /* Request expose */
3225 drawing_request_expose(events_request
, tss
, end_time
);
3234 int after_chunk(void *hook_data
, void *call_data
)
3236 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3237 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3238 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3239 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3240 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3243 ProcessList
*process_list
= control_flow_data
->process_list
;
3245 g_free(process_list
->current_hash_data
);
3246 process_list
->current_hash_data
= NULL
;
3249 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3250 else /* end of traceset, or position now out of request : end */
3251 end_time
= events_request
->end_time
;
3253 ClosureData closure_data
;
3254 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3255 closure_data
.tss
= tss
;
3256 closure_data
.end_time
= end_time
;
3258 TimeWindow time_window
=
3259 lttvwindow_get_time_window(control_flow_data
->tab
);
3260 guint width
= control_flow_data
->drawing
->width
;
3261 convert_time_to_pixels(
3265 &closure_data
.x_end
);
3267 /* Draw last items */
3268 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3269 (void*)&closure_data
);
3271 /* Request expose */
3272 drawing_request_expose(events_request
, tss
, end_time
);