1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 /*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
25 /* Event hooks are the drawing hooks called during traceset read. They draw the
26 * icons, text, lines and background color corresponding to the events read.
28 * Two hooks are used for drawing : before_schedchange and after_schedchange hooks. The
29 * before_schedchange is called before the state update that occurs with an event and
30 * the after_schedchange hook is called after this state update.
32 * The before_schedchange hooks fulfill the task of drawing the visible objects that
33 * corresponds to the data accumulated by the after_schedchange hook.
35 * The after_schedchange hook accumulates the data that need to be shown on the screen
36 * (items) into a queue. Then, the next before_schedchange hook will draw what that
37 * queue contains. That's the Right Way (TM) of drawing items on the screen,
38 * because we need to draw the background first (and then add icons, text, ...
39 * over it), but we only know the length of a background region once the state
40 * corresponding to it is over, which happens to be at the next before_schedchange
43 * We also have a hook called at the end of a chunk to draw the information left
44 * undrawn in each process queue. We use the current time as end of
49 //#define PANGO_ENABLE_BACKEND
57 //#include <pango/pango.h>
59 #include <ltt/event.h>
63 #include <lttv/lttv.h>
64 #include <lttv/hook.h>
65 #include <lttv/state.h>
66 #include <lttvwindow/lttvwindow.h>
67 #include <lttvwindow/lttvwindowtraces.h>
70 #include "eventhooks.h"
72 #include "processlist.h"
74 #include "cfv-private.h"
77 #define MAX_PATH_LEN 256
81 typedef struct _ProcessAddClosure
{
86 static void process_add(gpointer key
,
90 LttvProcessState
*process
= (LttvProcessState
*)value
;
91 ProcessAddClosure
*closure
= (ProcessAddClosure
*)user_data
;
92 ControlFlowData
*control_flow_data
= closure
->cfd
;
93 guint trace_num
= closure
->trace_num
;
95 /* Add process to process list (if not present) */
98 guint y
= 0, height
= 0, pl_height
= 0;
100 ProcessList
*process_list
= control_flow_data
->process_list
;
103 birth
= process
->creation_time
;
104 const gchar
*name
= g_quark_to_string(process
->name
);
105 HashedProcessData
*hashed_process_data
= NULL
;
107 if(processlist_get_process_pixels(process_list
,
113 &hashed_process_data
) == 1)
115 /* Process not present */
116 processlist_add(process_list
,
122 &hashed_process_data
);
123 processlist_get_process_pixels(process_list
,
129 &hashed_process_data
);
130 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
136 /* Action to do when background computation completed.
138 * Wait for all the awaited computations to be over.
141 gint
background_ready(void *hook_data
, void *call_data
)
143 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
144 LttvTrace
*trace
= (LttvTrace
*)call_data
;
145 LttvTracesetContext
*tsc
=
146 lttvwindow_get_traceset_context(control_flow_data
->tab
);
148 control_flow_data
->background_info_waiting
--;
150 if(control_flow_data
->background_info_waiting
== 0) {
151 g_debug("control flow viewer : background computation data ready.");
153 drawing_clear(control_flow_data
->drawing
);
154 processlist_clear(control_flow_data
->process_list
);
155 redraw_notify(control_flow_data
, NULL
);
162 /* Request background computation. Verify if it is in progress or ready first.
163 * Only for each trace in the tab's traceset.
165 void request_background_data(ControlFlowData
*control_flow_data
)
167 LttvTracesetContext
* tsc
=
168 lttvwindow_get_traceset_context(control_flow_data
->tab
);
169 gint num_traces
= lttv_traceset_number(tsc
->ts
);
173 LttvHooks
*background_ready_hook
=
175 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
177 control_flow_data
->background_info_waiting
= 0;
179 for(i
=0;i
<num_traces
;i
++) {
180 trace
= lttv_traceset_get(tsc
->ts
, i
);
182 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
184 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
186 /* We first remove requests that could have been done for the same
187 * information. Happens when two viewers ask for it before servicing
190 lttvwindowtraces_background_request_remove(trace
, "state");
191 lttvwindowtraces_background_request_queue(trace
,
193 lttvwindowtraces_background_notify_queue(control_flow_data
,
197 background_ready_hook
);
198 control_flow_data
->background_info_waiting
++;
199 } else { /* in progress */
201 lttvwindowtraces_background_notify_current(control_flow_data
,
205 background_ready_hook
);
206 control_flow_data
->background_info_waiting
++;
209 /* Data ready. Be its nature, this viewer doesn't need to have
210 * its data ready hook called htere, because a background
211 * request is always linked with a redraw.
217 lttv_hooks_destroy(background_ready_hook
);
224 * Event Viewer's constructor hook
226 * This constructor is given as a parameter to the menuitem and toolbar button
227 * registration. It creates the list.
228 * @param tab A pointer to the parent tab.
229 * @return The widget created.
232 h_guicontrolflow(Tab
*tab
)
234 g_info("h_guicontrolflow, %p", tab
);
235 ControlFlowData
*control_flow_data
= guicontrolflow() ;
237 control_flow_data
->tab
= tab
;
239 //g_debug("time width2 : %u",time_window->time_width);
240 // Unreg done in the GuiControlFlow_Destructor
241 lttvwindow_register_traceset_notify(tab
,
245 lttvwindow_register_time_window_notify(tab
,
246 update_time_window_hook
,
248 lttvwindow_register_current_time_notify(tab
,
249 update_current_time_hook
,
251 lttvwindow_register_redraw_notify(tab
,
254 lttvwindow_register_continue_notify(tab
,
257 request_background_data(control_flow_data
);
260 return guicontrolflow_get_widget(control_flow_data
) ;
264 int event_selected_hook(void *hook_data
, void *call_data
)
266 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
267 guint
*event_number
= (guint
*) call_data
;
269 g_debug("DEBUG : event selected by main window : %u", *event_number
);
273 /* Function that selects the color of status&exemode line */
274 static __inline__ PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
276 PropertiesLine prop_line
;
277 prop_line
.line_width
= 2;
278 prop_line
.style
= GDK_LINE_SOLID
;
279 prop_line
.y
= MIDDLE
;
280 //GdkColormap *colormap = gdk_colormap_get_system();
282 g_debug("prepare_status_line for state : %s",
283 g_quark_to_string(process
->state
->s
));
285 if(process
->state
->s
== LTTV_STATE_RUN
) {
286 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
287 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
288 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
289 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
290 else if(process
->state
->t
== LTTV_STATE_TRAP
)
291 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
292 else if(process
->state
->t
== LTTV_STATE_IRQ
)
293 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
294 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
295 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
297 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
298 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
299 /* We don't show if we wait while in user mode, trap, irq or syscall */
300 prop_line
.color
= drawing_colors
[COL_WAIT
];
301 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
302 /* We don't show if we wait for CPU while in user mode, trap, irq
304 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
305 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
306 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
307 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
308 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
309 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
310 prop_line
.color
= drawing_colors
[COL_EXIT
];
311 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
312 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
314 g_assert(FALSE
); /* UNKNOWN STATE */
321 static __inline__ PropertiesLine
prepare_status_line(LttvProcessState
*process
)
323 PropertiesLine prop_line
;
324 prop_line
.line_width
= 2;
325 prop_line
.style
= GDK_LINE_SOLID
;
326 prop_line
.y
= MIDDLE
;
327 //GdkColormap *colormap = gdk_colormap_get_system();
329 g_debug("prepare_status_line for state : %s",
330 g_quark_to_string(process
->state
->s
));
332 /* color of line : status of the process */
333 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
334 prop_line
.color
= drawing_colors
[COL_WHITE
];
335 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
336 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
337 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
338 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
339 else if(process
->state
->s
== LTTV_STATE_EXIT
)
340 prop_line
.color
= drawing_colors
[COL_EXIT
];
341 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
342 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
343 else if(process
->state
->s
== LTTV_STATE_WAIT
)
344 prop_line
.color
= drawing_colors
[COL_WAIT
];
345 else if(process
->state
->s
== LTTV_STATE_RUN
)
346 prop_line
.color
= drawing_colors
[COL_RUN
];
348 prop_line
.color
= drawing_colors
[COL_WHITE
];
350 //gdk_colormap_alloc_color(colormap,
361 /* before_schedchange_hook
363 * This function basically draw lines and icons. Two types of lines are drawn :
364 * one small (3 pixels?) representing the state of the process and the second
365 * type is thicker (10 pixels?) representing on which CPU a process is running
366 * (and this only in running state).
368 * Extremums of the lines :
369 * x_min : time of the last event context for this process kept in memory.
370 * x_max : time of the current event.
371 * y : middle of the process in the process list. The process is found in the
372 * list, therefore is it's position in pixels.
374 * The choice of lines'color is defined by the context of the last event for this
379 int before_schedchange_hook(void *hook_data
, void *call_data
)
381 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
382 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
383 Drawing_t
*drawing
= control_flow_data
->drawing
;
385 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
387 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
388 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
393 LttTime evtime
= ltt_event_time(e
);
395 guint width
= drawing
->width
;
397 /* we are in a schedchange, before the state update. We must draw the
398 * items corresponding to the state before it changes : now is the right
405 LttField
*f
= ltt_event_field(e
);
407 element
= ltt_field_member(f
,0);
408 pid_out
= ltt_event_get_long_unsigned(e
,element
);
409 element
= ltt_field_member(f
,1);
410 pid_in
= ltt_event_get_long_unsigned(e
,element
);
411 g_debug("out : %u in : %u", pid_out
, pid_in
);
415 /* For the pid_out */
416 /* First, check if the current process is in the state computation
417 * process list. If it is there, that means we must add it right now and
418 * draw items from the beginning of the read for it. If it is not
419 * present, it's a new process and it was not present : it will
420 * be added after the state update. */
421 LttvProcessState
*process
;
422 /* unknown state, bad current pid */
423 if(tfs
->process
->pid
!= pid_out
)
424 process
= lttv_state_find_process(tfs
, pid_out
);
426 process
= tfs
->process
;
428 if(process
!= NULL
) {
429 /* Well, the process_out existed : we must get it in the process hash
430 * or add it, and draw its items.
432 /* Add process to process list (if not present) */
433 guint y
= 0, height
= 0, pl_height
= 0;
434 HashedProcessData
*hashed_process_data
= NULL
;
435 ProcessList
*process_list
= control_flow_data
->process_list
;
436 LttTime birth
= process
->creation_time
;
438 hashed_process_data
= processlist_get_process_data(process_list
,
440 process
->last_cpu_index
,
442 tfc
->t_context
->index
);
443 if(hashed_process_data
== NULL
)
445 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
446 const gchar
*name
= g_quark_to_string(process
->name
);
447 /* Process not present */
448 ProcessInfo
*process_info
;
449 processlist_add(process_list
,
451 process
->last_cpu_index
,
454 tfc
->t_context
->index
,
458 &hashed_process_data
);
459 processlist_get_pixels_from_data(process_list
,
463 drawing_insert_square( drawing
, y
, height
);
466 /* Now, the process is in the state hash and our own process hash.
467 * We definitely can draw the items related to the ending state.
470 /* Check if the x position is unset. In can have been left unset by
471 * a draw closure from a after chunk hook. This should never happen,
472 * because it must be set by before chunk hook to the damage_begin
475 g_assert(hashed_process_data
->x
.middle
!= -1);
476 if(ltt_time_compare(hashed_process_data
->next_good_time
,
479 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
480 processlist_get_pixels_from_data(process_list
,
485 TimeWindow time_window
=
486 lttvwindow_get_time_window(control_flow_data
->tab
);
488 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
489 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
494 convert_time_to_pixels(
500 /* Draw collision indicator */
501 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
502 gdk_draw_point(drawing
->pixmap
,
506 hashed_process_data
->x
.middle_marked
= TRUE
;
509 processlist_get_pixels_from_data(process_list
,
515 TimeWindow time_window
=
516 lttvwindow_get_time_window(control_flow_data
->tab
);
518 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
519 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
524 convert_time_to_pixels(
531 /* Jump over draw if we are at the same x position */
532 if(x
== hashed_process_data
->x
.middle
&&
533 hashed_process_data
->x
.middle_used
)
535 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
536 /* Draw collision indicator */
537 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
538 gdk_draw_point(drawing
->pixmap
,
542 hashed_process_data
->x
.middle_marked
= TRUE
;
546 DrawContext draw_context
;
548 /* Now create the drawing context that will be used to draw
549 * items related to the last state. */
550 draw_context
.drawable
= drawing
->pixmap
;
551 draw_context
.gc
= drawing
->gc
;
552 draw_context
.pango_layout
= drawing
->pango_layout
;
553 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
554 draw_context
.drawinfo
.end
.x
= x
;
556 draw_context
.drawinfo
.y
.over
= y
+1;
557 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
558 draw_context
.drawinfo
.y
.under
= y
+height
;
560 draw_context
.drawinfo
.start
.offset
.over
= 0;
561 draw_context
.drawinfo
.start
.offset
.middle
= 0;
562 draw_context
.drawinfo
.start
.offset
.under
= 0;
563 draw_context
.drawinfo
.end
.offset
.over
= 0;
564 draw_context
.drawinfo
.end
.offset
.middle
= 0;
565 draw_context
.drawinfo
.end
.offset
.under
= 0;
569 PropertiesLine prop_line
= prepare_s_e_line(process
);
570 draw_line((void*)&prop_line
, (void*)&draw_context
);
573 /* become the last x position */
574 hashed_process_data
->x
.middle
= x
;
575 hashed_process_data
->x
.middle_used
= TRUE
;
576 hashed_process_data
->x
.middle_marked
= FALSE
;
578 /* Calculate the next good time */
579 convert_pixels_to_time(width
, x
+1, time_window
,
580 &hashed_process_data
->next_good_time
);
588 /* First, check if the current process is in the state computation
589 * process list. If it is there, that means we must add it right now and
590 * draw items from the beginning of the read for it. If it is not
591 * present, it's a new process and it was not present : it will
592 * be added after the state update. */
593 LttvProcessState
*process
;
594 process
= lttv_state_find_process(tfs
, pid_in
);
596 if(process
!= NULL
) {
597 /* Well, the process_out existed : we must get it in the process hash
598 * or add it, and draw its items.
600 /* Add process to process list (if not present) */
601 guint y
= 0, height
= 0, pl_height
= 0;
602 HashedProcessData
*hashed_process_data
= NULL
;
603 ProcessList
*process_list
= control_flow_data
->process_list
;
604 LttTime birth
= process
->creation_time
;
606 hashed_process_data
= processlist_get_process_data(process_list
,
608 process
->last_cpu_index
,
610 tfc
->t_context
->index
);
611 if(hashed_process_data
== NULL
)
613 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
614 const gchar
*name
= g_quark_to_string(process
->name
);
615 /* Process not present */
616 ProcessInfo
*process_info
;
617 processlist_add(process_list
,
619 process
->last_cpu_index
,
622 tfc
->t_context
->index
,
626 &hashed_process_data
);
627 processlist_get_pixels_from_data(process_list
,
631 drawing_insert_square( drawing
, y
, height
);
633 //We could set the current process and hash here, but will be done
634 //by after schedchange hook
636 /* Now, the process is in the state hash and our own process hash.
637 * We definitely can draw the items related to the ending state.
640 /* Check if the x position is unset. In can have been left unset by
641 * a draw closure from a after chunk hook. This should never happen,
642 * because it must be set by before chunk hook to the damage_begin
645 g_assert(hashed_process_data
->x
.middle
!= -1);
647 if(ltt_time_compare(hashed_process_data
->next_good_time
,
650 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
652 processlist_get_pixels_from_data(process_list
,
656 TimeWindow time_window
=
657 lttvwindow_get_time_window(control_flow_data
->tab
);
659 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
660 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
664 convert_time_to_pixels(
670 /* Draw collision indicator */
671 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
672 gdk_draw_point(drawing
->pixmap
,
676 hashed_process_data
->x
.middle_marked
= TRUE
;
679 processlist_get_pixels_from_data(process_list
,
683 TimeWindow time_window
=
684 lttvwindow_get_time_window(control_flow_data
->tab
);
686 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
687 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
692 convert_time_to_pixels(
699 /* Jump over draw if we are at the same x position */
700 if(x
== hashed_process_data
->x
.middle
&&
701 hashed_process_data
->x
.middle_used
)
703 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
704 /* Draw collision indicator */
705 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
706 gdk_draw_point(drawing
->pixmap
,
710 hashed_process_data
->x
.middle_marked
= TRUE
;
714 DrawContext draw_context
;
716 /* Now create the drawing context that will be used to draw
717 * items related to the last state. */
718 draw_context
.drawable
= drawing
->pixmap
;
719 draw_context
.gc
= drawing
->gc
;
720 draw_context
.pango_layout
= drawing
->pango_layout
;
721 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
722 draw_context
.drawinfo
.end
.x
= x
;
724 draw_context
.drawinfo
.y
.over
= y
+1;
725 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
726 draw_context
.drawinfo
.y
.under
= y
+height
;
728 draw_context
.drawinfo
.start
.offset
.over
= 0;
729 draw_context
.drawinfo
.start
.offset
.middle
= 0;
730 draw_context
.drawinfo
.start
.offset
.under
= 0;
731 draw_context
.drawinfo
.end
.offset
.over
= 0;
732 draw_context
.drawinfo
.end
.offset
.middle
= 0;
733 draw_context
.drawinfo
.end
.offset
.under
= 0;
737 PropertiesLine prop_line
= prepare_s_e_line(process
);
738 draw_line((void*)&prop_line
, (void*)&draw_context
);
742 /* become the last x position */
743 hashed_process_data
->x
.middle
= x
;
744 hashed_process_data
->x
.middle_used
= TRUE
;
745 hashed_process_data
->x
.middle_marked
= FALSE
;
747 /* Calculate the next good time */
748 convert_pixels_to_time(width
, x
+1, time_window
,
749 &hashed_process_data
->next_good_time
);
758 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
759 ControlFlowData
*control_flow_data
=
760 (ControlFlowData
*)events_request
->viewer_data
;
761 Tab
*tab
= control_flow_data
->tab
;
763 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
765 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
766 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
771 LttTime evtime
= ltt_event_time(e
);
772 TimeWindow time_window
=
773 lttvwindow_get_time_window(tab
);
775 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
777 //if(time < time_beg || time > time_end) return;
778 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
779 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
782 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
784 g_debug("schedchange!");
786 /* Add process to process list (if not present) and get drawing "y" from
787 * process position */
788 guint pid_out
, pid_in
;
789 LttvProcessState
*process_out
, *process_in
;
791 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
793 ProcessList
*process_list
= control_flow_data
->process_list
;
796 LttField
*f
= ltt_event_field(e
);
798 element
= ltt_field_member(f
,0);
799 pid_out
= ltt_event_get_long_unsigned(e
,element
);
800 element
= ltt_field_member(f
,1);
801 pid_in
= ltt_event_get_long_unsigned(e
,element
);
802 g_debug("out : %u in : %u", pid_out
, pid_in
);
805 /* Find process pid_out in the list... */
806 process_out
= lttv_state_find_process(tfs
, pid_out
);
807 if(process_out
== NULL
) return 0;
808 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
810 birth
= process_out
->creation_time
;
811 const gchar
*name
= g_quark_to_string(process_out
->name
);
812 HashedProcessData
*hashed_process_data_out
= NULL
;
814 if(processlist_get_process_pixels(process_list
,
817 tfc
->t_context
->index
,
820 &hashed_process_data_out
) == 1)
822 /* Process not present */
823 processlist_add(process_list
,
826 tfc
->t_context
->index
,
829 &hashed_process_data_out
);
830 g_assert(processlist_get_process_pixels(process_list
,
833 tfc
->t_context
->index
,
836 &hashed_process_data_out
)==0);
837 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
841 /* Find process pid_in in the list... */
842 process_in
= lttv_state_find_process(tfs
, pid_in
);
843 if(process_in
== NULL
) return 0;
844 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
846 birth
= process_in
->creation_time
;
847 name
= g_quark_to_string(process_in
->name
);
848 HashedProcessData
*hashed_process_data_in
= NULL
;
850 if(processlist_get_process_pixels(process_list
,
853 tfc
->t_context
->index
,
856 &hashed_process_data_in
) == 1)
858 /* Process not present */
859 processlist_add(process_list
,
862 tfc
->t_context
->index
,
865 &hashed_process_data_in
);
866 processlist_get_process_pixels(process_list
,
869 tfc
->t_context
->index
,
872 &hashed_process_data_in
);
874 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
879 /* Find pixels corresponding to time of the event. If the time does
880 * not fit in the window, show a warning, not supposed to happend. */
882 guint width
= control_flow_data
->drawing
->width
;
884 LttTime time
= ltt_event_time(e
);
886 LttTime window_end
= time_window
.time_window
.end_time
;
888 convert_time_to_pixels(
893 //assert(x <= width);
895 /* draw what represents the event for outgoing process. */
897 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
898 draw_context_out
->current
->modify_over
->x
= x
;
899 draw_context_out
->current
->modify_under
->x
= x
;
900 draw_context_out
->current
->modify_over
->y
= y_out
;
901 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
902 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
903 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
904 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
905 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
906 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
907 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
908 //draw_context_out->gc = widget->style->black_gc;
910 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
911 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
913 /* Draw the line/background of the out process */
914 if(draw_context_out
->previous
->middle
->x
== -1)
916 draw_context_out
->previous
->over
->x
=
917 control_flow_data
->drawing
->damage_begin
;
918 draw_context_out
->previous
->middle
->x
=
919 control_flow_data
->drawing
->damage_begin
;
920 draw_context_out
->previous
->under
->x
=
921 control_flow_data
->drawing
->damage_begin
;
923 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
926 draw_context_out
->current
->middle
->x
= x
;
927 draw_context_out
->current
->over
->x
= x
;
928 draw_context_out
->current
->under
->x
= x
;
929 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
930 draw_context_out
->current
->over
->y
= y_out
;
931 draw_context_out
->current
->under
->y
= y_out
+ height
;
932 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
933 draw_context_out
->previous
->over
->y
= y_out
;
934 draw_context_out
->previous
->under
->y
= y_out
+ height
;
936 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
937 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
939 if(process_out
->state
->s
== LTTV_STATE_RUN
)
941 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
942 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
943 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
945 PropertiesBG prop_bg
;
946 prop_bg
.color
= g_new(GdkColor
,1);
950 prop_bg
.color
->red
= 0x1515;
951 prop_bg
.color
->green
= 0x1515;
952 prop_bg
.color
->blue
= 0x8c8c;
955 prop_bg
.color
->red
= 0x4e4e;
956 prop_bg
.color
->green
= 0xa9a9;
957 prop_bg
.color
->blue
= 0xa4a4;
960 prop_bg
.color
->red
= 0x7a7a;
961 prop_bg
.color
->green
= 0x4a4a;
962 prop_bg
.color
->blue
= 0x8b8b;
965 prop_bg
.color
->red
= 0x8080;
966 prop_bg
.color
->green
= 0x7777;
967 prop_bg
.color
->blue
= 0x4747;
970 prop_bg
.color
->red
= 0xe7e7;
971 prop_bg
.color
->green
= 0xe7e7;
972 prop_bg
.color
->blue
= 0xe7e7;
975 g_debug("calling from draw_event");
976 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
977 g_free(prop_bg
.color
);
978 //gdk_gc_unref(draw_context_out->gc);
981 draw_context_out
->gc
= widget
->style
->black_gc
;
983 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
984 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
985 PropertiesText prop_text_out
;
986 prop_text_out
.foreground
= &colorfg_out
;
987 prop_text_out
.background
= &colorbg_out
;
988 prop_text_out
.size
= 6;
989 prop_text_out
.position
= OVER
;
991 /* color of text : status of the process */
992 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
994 prop_text_out
.foreground
->red
= 0xffff;
995 prop_text_out
.foreground
->green
= 0xffff;
996 prop_text_out
.foreground
->blue
= 0xffff;
998 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1000 prop_text_out
.foreground
->red
= 0x0fff;
1001 prop_text_out
.foreground
->green
= 0xffff;
1002 prop_text_out
.foreground
->blue
= 0xfff0;
1004 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1006 prop_text_out
.foreground
->red
= 0xffff;
1007 prop_text_out
.foreground
->green
= 0xffff;
1008 prop_text_out
.foreground
->blue
= 0x0000;
1010 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1012 prop_text_out
.foreground
->red
= 0xffff;
1013 prop_text_out
.foreground
->green
= 0x0000;
1014 prop_text_out
.foreground
->blue
= 0xffff;
1016 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1018 prop_text_out
.foreground
->red
= 0xffff;
1019 prop_text_out
.foreground
->green
= 0x0000;
1020 prop_text_out
.foreground
->blue
= 0x0000;
1022 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1024 prop_text_out
.foreground
->red
= 0x0000;
1025 prop_text_out
.foreground
->green
= 0xffff;
1026 prop_text_out
.foreground
->blue
= 0x0000;
1030 prop_text_out
.foreground
->red
= 0xffff;
1031 prop_text_out
.foreground
->green
= 0xffff;
1032 prop_text_out
.foreground
->blue
= 0xffff;
1036 /* Print status of the process : U, WF, WC, E, W, R */
1037 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1038 prop_text_out
.text
= "U->";
1039 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1040 prop_text_out
.text
= "WF->";
1041 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1042 prop_text_out
.text
= "WC->";
1043 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1044 prop_text_out
.text
= "E->";
1045 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1046 prop_text_out
.text
= "W->";
1047 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1048 prop_text_out
.text
= "R->";
1050 prop_text_out
.text
= "U";
1052 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1053 //gdk_gc_unref(draw_context_out->gc);
1055 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1056 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1057 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
1059 PropertiesLine prop_line_out
;
1060 prop_line_out
.color
= g_new(GdkColor
,1);
1061 prop_line_out
.line_width
= 2;
1062 prop_line_out
.style
= GDK_LINE_SOLID
;
1063 prop_line_out
.position
= MIDDLE
;
1065 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
1067 /* color of line : status of the process */
1068 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1070 prop_line_out
.color
->red
= 0xffff;
1071 prop_line_out
.color
->green
= 0xffff;
1072 prop_line_out
.color
->blue
= 0xffff;
1074 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1076 prop_line_out
.color
->red
= 0x0fff;
1077 prop_line_out
.color
->green
= 0xffff;
1078 prop_line_out
.color
->blue
= 0xfff0;
1080 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1082 prop_line_out
.color
->red
= 0xffff;
1083 prop_line_out
.color
->green
= 0xffff;
1084 prop_line_out
.color
->blue
= 0x0000;
1086 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1088 prop_line_out
.color
->red
= 0xffff;
1089 prop_line_out
.color
->green
= 0x0000;
1090 prop_line_out
.color
->blue
= 0xffff;
1092 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1094 prop_line_out
.color
->red
= 0xffff;
1095 prop_line_out
.color
->green
= 0x0000;
1096 prop_line_out
.color
->blue
= 0x0000;
1098 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1100 prop_line_out
.color
->red
= 0x0000;
1101 prop_line_out
.color
->green
= 0xffff;
1102 prop_line_out
.color
->blue
= 0x0000;
1106 prop_line_out
.color
->red
= 0xffff;
1107 prop_line_out
.color
->green
= 0xffff;
1108 prop_line_out
.color
->blue
= 0xffff;
1111 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1112 g_free(prop_line_out
.color
);
1113 //gdk_gc_unref(draw_context_out->gc);
1114 /* Note : finishing line will have to be added when trace read over. */
1116 /* Finally, update the drawing context of the pid_in. */
1118 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1119 draw_context_in
->current
->modify_over
->x
= x
;
1120 draw_context_in
->current
->modify_under
->x
= x
;
1121 draw_context_in
->current
->modify_over
->y
= y_in
;
1122 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1123 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1124 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1125 widget
= control_flow_data
->drawing
->drawing_area
;
1126 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1127 //draw_context_in->gc = widget->style->black_gc;
1128 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1129 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1131 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1132 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1134 /* Draw the line/bg of the in process */
1135 if(draw_context_in
->previous
->middle
->x
== -1)
1137 draw_context_in
->previous
->over
->x
=
1138 control_flow_data
->drawing
->damage_begin
;
1139 draw_context_in
->previous
->middle
->x
=
1140 control_flow_data
->drawing
->damage_begin
;
1141 draw_context_in
->previous
->under
->x
=
1142 control_flow_data
->drawing
->damage_begin
;
1144 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1148 draw_context_in
->current
->middle
->x
= x
;
1149 draw_context_in
->current
->over
->x
= x
;
1150 draw_context_in
->current
->under
->x
= x
;
1151 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1152 draw_context_in
->current
->over
->y
= y_in
;
1153 draw_context_in
->current
->under
->y
= y_in
+ height
;
1154 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1155 draw_context_in
->previous
->over
->y
= y_in
;
1156 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1158 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1159 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1162 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1164 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1165 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1166 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1168 PropertiesBG prop_bg
;
1169 prop_bg
.color
= g_new(GdkColor
,1);
1171 switch(tfc
->index
) {
1173 prop_bg
.color
->red
= 0x1515;
1174 prop_bg
.color
->green
= 0x1515;
1175 prop_bg
.color
->blue
= 0x8c8c;
1178 prop_bg
.color
->red
= 0x4e4e;
1179 prop_bg
.color
->green
= 0xa9a9;
1180 prop_bg
.color
->blue
= 0xa4a4;
1183 prop_bg
.color
->red
= 0x7a7a;
1184 prop_bg
.color
->green
= 0x4a4a;
1185 prop_bg
.color
->blue
= 0x8b8b;
1188 prop_bg
.color
->red
= 0x8080;
1189 prop_bg
.color
->green
= 0x7777;
1190 prop_bg
.color
->blue
= 0x4747;
1193 prop_bg
.color
->red
= 0xe7e7;
1194 prop_bg
.color
->green
= 0xe7e7;
1195 prop_bg
.color
->blue
= 0xe7e7;
1199 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1200 g_free(prop_bg
.color
);
1201 //gdk_gc_unref(draw_context_in->gc);
1204 draw_context_in
->gc
= widget
->style
->black_gc
;
1206 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1207 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1208 PropertiesText prop_text_in
;
1209 prop_text_in
.foreground
= &colorfg_in
;
1210 prop_text_in
.background
= &colorbg_in
;
1211 prop_text_in
.size
= 6;
1212 prop_text_in
.position
= OVER
;
1214 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1215 /* foreground of text : status of the process */
1216 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1218 prop_text_in
.foreground
->red
= 0xffff;
1219 prop_text_in
.foreground
->green
= 0xffff;
1220 prop_text_in
.foreground
->blue
= 0xffff;
1222 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1224 prop_text_in
.foreground
->red
= 0x0fff;
1225 prop_text_in
.foreground
->green
= 0xffff;
1226 prop_text_in
.foreground
->blue
= 0xfff0;
1228 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1230 prop_text_in
.foreground
->red
= 0xffff;
1231 prop_text_in
.foreground
->green
= 0xffff;
1232 prop_text_in
.foreground
->blue
= 0x0000;
1234 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1236 prop_text_in
.foreground
->red
= 0xffff;
1237 prop_text_in
.foreground
->green
= 0x0000;
1238 prop_text_in
.foreground
->blue
= 0xffff;
1240 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1242 prop_text_in
.foreground
->red
= 0xffff;
1243 prop_text_in
.foreground
->green
= 0x0000;
1244 prop_text_in
.foreground
->blue
= 0x0000;
1246 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1248 prop_text_in
.foreground
->red
= 0x0000;
1249 prop_text_in
.foreground
->green
= 0xffff;
1250 prop_text_in
.foreground
->blue
= 0x0000;
1254 prop_text_in
.foreground
->red
= 0xffff;
1255 prop_text_in
.foreground
->green
= 0xffff;
1256 prop_text_in
.foreground
->blue
= 0xffff;
1261 /* Print status of the process : U, WF, WC, E, W, R */
1262 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1263 prop_text_in
.text
= "U->";
1264 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1265 prop_text_in
.text
= "WF->";
1266 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1267 prop_text_in
.text
= "WC->";
1268 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1269 prop_text_in
.text
= "E->";
1270 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1271 prop_text_in
.text
= "W->";
1272 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1273 prop_text_in
.text
= "R->";
1275 prop_text_in
.text
= "U";
1277 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1278 //gdk_gc_unref(draw_context_in->gc);
1280 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1281 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1282 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1284 PropertiesLine prop_line_in
;
1285 prop_line_in
.color
= g_new(GdkColor
,1);
1286 prop_line_in
.line_width
= 2;
1287 prop_line_in
.style
= GDK_LINE_SOLID
;
1288 prop_line_in
.position
= MIDDLE
;
1290 /* color of line : status of the process */
1291 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1293 prop_line_in
.color
->red
= 0xffff;
1294 prop_line_in
.color
->green
= 0xffff;
1295 prop_line_in
.color
->blue
= 0xffff;
1297 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1299 prop_line_in
.color
->red
= 0x0fff;
1300 prop_line_in
.color
->green
= 0xffff;
1301 prop_line_in
.color
->blue
= 0xfff0;
1303 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1305 prop_line_in
.color
->red
= 0xffff;
1306 prop_line_in
.color
->green
= 0xffff;
1307 prop_line_in
.color
->blue
= 0x0000;
1309 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1311 prop_line_in
.color
->red
= 0xffff;
1312 prop_line_in
.color
->green
= 0x0000;
1313 prop_line_in
.color
->blue
= 0xffff;
1315 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1317 prop_line_in
.color
->red
= 0xffff;
1318 prop_line_in
.color
->green
= 0x0000;
1319 prop_line_in
.color
->blue
= 0x0000;
1321 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1323 prop_line_in
.color
->red
= 0x0000;
1324 prop_line_in
.color
->green
= 0xffff;
1325 prop_line_in
.color
->blue
= 0x0000;
1329 prop_line_in
.color
->red
= 0xffff;
1330 prop_line_in
.color
->green
= 0xffff;
1331 prop_line_in
.color
->blue
= 0xffff;
1334 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1335 g_free(prop_line_in
.color
);
1336 //gdk_gc_unref(draw_context_in->gc);
1346 GString
*string
= g_string_new("");;
1347 gboolean field_names
= TRUE
, state
= TRUE
;
1349 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1350 g_string_append_printf(string
,"\n");
1353 g_string_append_printf(string
, " %s",
1354 g_quark_to_string(tfs
->process
->state
->s
));
1357 g_info("%s",string
->str
);
1359 g_string_free(string
, TRUE
);
1361 /* End of text dump */
1366 /* after_schedchange_hook
1368 * The draw after hook is called by the reading API to have a
1369 * particular event drawn on the screen.
1370 * @param hook_data ControlFlowData structure of the viewer.
1371 * @param call_data Event context.
1373 * This function adds items to be drawn in a queue for each process.
1376 int after_schedchange_hook(void *hook_data
, void *call_data
)
1378 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1379 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1381 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1383 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1384 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
1389 LttTime evtime
= ltt_event_time(e
);
1391 guint width
= control_flow_data
->drawing
->width
;
1393 /* Add process to process list (if not present) */
1394 LttvProcessState
*process_out
, *process_in
;
1396 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1397 HashedProcessData
*hashed_process_data_in
= NULL
;
1399 ProcessList
*process_list
= control_flow_data
->process_list
;
1404 LttField
*f
= ltt_event_field(e
);
1406 element
= ltt_field_member(f
,0);
1407 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1408 element
= ltt_field_member(f
,1);
1409 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1410 g_debug("out : %u in : %u", pid_out
, pid_in
);
1414 /* Find process pid_in in the list... */
1415 //process_in = lttv_state_find_process(tfs, pid_in);
1416 process_in
= tfs
->process
;
1417 /* It should exist, because we are after the state update. */
1418 g_assert(process_in
!= NULL
);
1420 birth
= process_in
->creation_time
;
1422 hashed_process_data_in
= processlist_get_process_data(process_list
,
1424 process_in
->last_cpu_index
,
1426 tfc
->t_context
->index
);
1427 if(hashed_process_data_in
== NULL
)
1429 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1430 const gchar
*name
= g_quark_to_string(process_in
->name
);
1431 ProcessInfo
*process_info
;
1432 /* Process not present */
1433 processlist_add(process_list
,
1435 process_in
->last_cpu_index
,
1438 tfc
->t_context
->index
,
1442 &hashed_process_data_in
);
1443 processlist_get_pixels_from_data(process_list
,
1444 hashed_process_data_in
,
1447 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1449 /* Set the current process */
1450 process_list
->current_hash_data
[process_in
->last_cpu_index
] =
1451 hashed_process_data_in
;
1453 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
1456 processlist_get_pixels_from_data(process_list
,
1457 hashed_process_data_in
,
1460 TimeWindow time_window
=
1461 lttvwindow_get_time_window(control_flow_data
->tab
);
1464 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1465 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1467 #endif //EXTRA_CHECK
1471 convert_time_to_pixels(
1477 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1478 hashed_process_data_in
->x
.middle
= new_x
;
1479 hashed_process_data_in
->x
.middle_used
= FALSE
;
1480 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1490 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1491 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1493 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1495 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1496 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1502 LttTime evtime
= ltt_event_time(e
);
1503 TimeWindow time_window
=
1504 lttvwindow_get_time_window(control_flow_data
->tab
);
1506 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
1508 //if(time < time_beg || time > time_end) return;
1509 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1510 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1514 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1516 g_debug("schedchange!");
1518 /* Add process to process list (if not present) and get drawing "y" from
1519 * process position */
1520 guint pid_out
, pid_in
;
1521 LttvProcessState
*process_out
, *process_in
;
1523 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1525 ProcessList
*process_list
= control_flow_data
->process_list
;
1528 LttField
*f
= ltt_event_field(e
);
1530 element
= ltt_field_member(f
,0);
1531 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1532 element
= ltt_field_member(f
,1);
1533 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1534 //g_debug("out : %u in : %u", pid_out, pid_in);
1537 /* Find process pid_out in the list... */
1538 process_out
= lttv_state_find_process(tfs
, pid_out
);
1539 if(process_out
== NULL
) return 0;
1540 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1542 birth
= process_out
->creation_time
;
1543 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1544 HashedProcessData
*hashed_process_data_out
= NULL
;
1546 if(processlist_get_process_pixels(process_list
,
1549 tfc
->t_context
->index
,
1552 &hashed_process_data_out
) == 1)
1554 /* Process not present */
1555 processlist_add(process_list
,
1558 tfc
->t_context
->index
,
1561 &hashed_process_data_out
);
1562 processlist_get_process_pixels(process_list
,
1565 tfc
->t_context
->index
,
1568 &hashed_process_data_out
);
1569 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1574 /* Find process pid_in in the list... */
1575 process_in
= lttv_state_find_process(tfs
, pid_in
);
1576 if(process_in
== NULL
) return 0;
1577 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1579 birth
= process_in
->creation_time
;
1580 name
= strdup(g_quark_to_string(process_in
->name
));
1581 HashedProcessData
*hashed_process_data_in
= NULL
;
1583 if(processlist_get_process_pixels(process_list
,
1586 tfc
->t_context
->index
,
1589 &hashed_process_data_in
) == 1)
1591 /* Process not present */
1592 processlist_add(process_list
,
1595 tfc
->t_context
->index
,
1598 &hashed_process_data_in
);
1599 processlist_get_process_pixels(process_list
,
1602 tfc
->t_context
->index
,
1605 &hashed_process_data_in
);
1607 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1612 /* Find pixels corresponding to time of the event. If the time does
1613 * not fit in the window, show a warning, not supposed to happend. */
1615 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1617 //LttTime time = ltt_event_time(e);
1619 //LttTime window_end = time_window->time_window.end_time;
1622 //convert_time_to_pixels(
1628 //assert(x <= width);
1630 /* draw what represents the event for outgoing process. */
1632 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1633 //draw_context_out->current->modify_over->x = x;
1634 draw_context_out
->current
->modify_over
->y
= y_out
;
1635 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1636 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1637 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1638 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1639 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1641 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1642 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1644 /*if(process_out->state->s == LTTV_STATE_RUN)
1646 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1647 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1648 PropertiesBG prop_bg;
1649 prop_bg.color = g_new(GdkColor,1);
1651 prop_bg.color->red = 0xffff;
1652 prop_bg.color->green = 0xffff;
1653 prop_bg.color->blue = 0xffff;
1655 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1656 g_free(prop_bg.color);
1657 gdk_gc_unref(draw_context_out->gc);
1660 draw_context_out
->gc
= widget
->style
->black_gc
;
1662 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1663 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1664 PropertiesText prop_text_out
;
1665 prop_text_out
.foreground
= &colorfg_out
;
1666 prop_text_out
.background
= &colorbg_out
;
1667 prop_text_out
.size
= 6;
1668 prop_text_out
.position
= OVER
;
1670 /* color of text : status of the process */
1671 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1673 prop_text_out
.foreground
->red
= 0xffff;
1674 prop_text_out
.foreground
->green
= 0xffff;
1675 prop_text_out
.foreground
->blue
= 0xffff;
1677 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1679 prop_text_out
.foreground
->red
= 0x0fff;
1680 prop_text_out
.foreground
->green
= 0xffff;
1681 prop_text_out
.foreground
->blue
= 0xfff0;
1683 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1685 prop_text_out
.foreground
->red
= 0xffff;
1686 prop_text_out
.foreground
->green
= 0xffff;
1687 prop_text_out
.foreground
->blue
= 0x0000;
1689 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1691 prop_text_out
.foreground
->red
= 0xffff;
1692 prop_text_out
.foreground
->green
= 0x0000;
1693 prop_text_out
.foreground
->blue
= 0xffff;
1695 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1697 prop_text_out
.foreground
->red
= 0xffff;
1698 prop_text_out
.foreground
->green
= 0x0000;
1699 prop_text_out
.foreground
->blue
= 0x0000;
1701 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1703 prop_text_out
.foreground
->red
= 0x0000;
1704 prop_text_out
.foreground
->green
= 0xffff;
1705 prop_text_out
.foreground
->blue
= 0x0000;
1709 prop_text_out
.foreground
->red
= 0xffff;
1710 prop_text_out
.foreground
->green
= 0xffff;
1711 prop_text_out
.foreground
->blue
= 0xffff;
1714 /* Print status of the process : U, WF, WC, E, W, R */
1715 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1716 prop_text_out
.text
= "U";
1717 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1718 prop_text_out
.text
= "WF";
1719 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1720 prop_text_out
.text
= "WC";
1721 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1722 prop_text_out
.text
= "E";
1723 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1724 prop_text_out
.text
= "W";
1725 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1726 prop_text_out
.text
= "R";
1728 prop_text_out
.text
= "U";
1730 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1732 //gdk_gc_unref(draw_context_out->gc);
1734 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1735 draw_context_out
->current
->over
->y
= y_out
;
1736 draw_context_out
->current
->under
->y
= y_out
+height
;
1737 draw_context_out
->current
->status
= process_out
->state
->s
;
1739 /* for pid_out : remove previous, Prev = current, new current (default) */
1740 g_free(draw_context_out
->previous
->modify_under
);
1741 g_free(draw_context_out
->previous
->modify_middle
);
1742 g_free(draw_context_out
->previous
->modify_over
);
1743 g_free(draw_context_out
->previous
->under
);
1744 g_free(draw_context_out
->previous
->middle
);
1745 g_free(draw_context_out
->previous
->over
);
1746 g_free(draw_context_out
->previous
);
1748 draw_context_out
->previous
= draw_context_out
->current
;
1750 draw_context_out
->current
= g_new(DrawInfo
,1);
1751 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1752 draw_context_out
->current
->over
->x
= -1;
1753 draw_context_out
->current
->over
->y
= -1;
1754 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1755 draw_context_out
->current
->middle
->x
= -1;
1756 draw_context_out
->current
->middle
->y
= -1;
1757 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1758 draw_context_out
->current
->under
->x
= -1;
1759 draw_context_out
->current
->under
->y
= -1;
1760 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1761 draw_context_out
->current
->modify_over
->x
= -1;
1762 draw_context_out
->current
->modify_over
->y
= -1;
1763 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1764 draw_context_out
->current
->modify_middle
->x
= -1;
1765 draw_context_out
->current
->modify_middle
->y
= -1;
1766 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1767 draw_context_out
->current
->modify_under
->x
= -1;
1768 draw_context_out
->current
->modify_under
->y
= -1;
1769 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1771 /* Finally, update the drawing context of the pid_in. */
1773 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1774 //draw_context_in->current->modify_over->x = x;
1775 draw_context_in
->current
->modify_over
->y
= y_in
;
1776 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1777 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1778 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1779 widget
= control_flow_data
->drawing
->drawing_area
;
1780 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1782 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1783 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1785 /*if(process_in->state->s == LTTV_STATE_RUN)
1787 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1788 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1789 PropertiesBG prop_bg;
1790 prop_bg.color = g_new(GdkColor,1);
1792 prop_bg.color->red = 0xffff;
1793 prop_bg.color->green = 0xffff;
1794 prop_bg.color->blue = 0xffff;
1796 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1797 g_free(prop_bg.color);
1798 gdk_gc_unref(draw_context_in->gc);
1801 draw_context_in
->gc
= widget
->style
->black_gc
;
1803 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1804 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1805 PropertiesText prop_text_in
;
1806 prop_text_in
.foreground
= &colorfg_in
;
1807 prop_text_in
.background
= &colorbg_in
;
1808 prop_text_in
.size
= 6;
1809 prop_text_in
.position
= OVER
;
1811 /* foreground of text : status of the process */
1812 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1814 prop_text_in
.foreground
->red
= 0xffff;
1815 prop_text_in
.foreground
->green
= 0xffff;
1816 prop_text_in
.foreground
->blue
= 0xffff;
1818 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1820 prop_text_in
.foreground
->red
= 0x0fff;
1821 prop_text_in
.foreground
->green
= 0xffff;
1822 prop_text_in
.foreground
->blue
= 0xfff0;
1824 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1826 prop_text_in
.foreground
->red
= 0xffff;
1827 prop_text_in
.foreground
->green
= 0xffff;
1828 prop_text_in
.foreground
->blue
= 0x0000;
1830 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1832 prop_text_in
.foreground
->red
= 0xffff;
1833 prop_text_in
.foreground
->green
= 0x0000;
1834 prop_text_in
.foreground
->blue
= 0xffff;
1836 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1838 prop_text_in
.foreground
->red
= 0xffff;
1839 prop_text_in
.foreground
->green
= 0x0000;
1840 prop_text_in
.foreground
->blue
= 0x0000;
1842 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1844 prop_text_in
.foreground
->red
= 0x0000;
1845 prop_text_in
.foreground
->green
= 0xffff;
1846 prop_text_in
.foreground
->blue
= 0x0000;
1850 prop_text_in
.foreground
->red
= 0xffff;
1851 prop_text_in
.foreground
->green
= 0xffff;
1852 prop_text_in
.foreground
->blue
= 0xffff;
1856 /* Print status of the process : U, WF, WC, E, W, R */
1857 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1858 prop_text_in
.text
= "U";
1859 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1860 prop_text_in
.text
= "WF";
1861 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1862 prop_text_in
.text
= "WC";
1863 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1864 prop_text_in
.text
= "E";
1865 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1866 prop_text_in
.text
= "W";
1867 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1868 prop_text_in
.text
= "R";
1870 prop_text_in
.text
= "U";
1872 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1875 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1878 prop_text_in
.foreground
= &colorfg_in
;
1879 prop_text_in
.background
= &colorbg_in
;
1880 prop_text_in
.foreground
->red
= 0xffff;
1881 prop_text_in
.foreground
->green
= 0xffff;
1882 prop_text_in
.foreground
->blue
= 0xffff;
1883 prop_text_in
.size
= 6;
1884 prop_text_in
.position
= UNDER
;
1886 prop_text_in
.text
= g_new(gchar
, 260);
1887 strcpy(prop_text_in
.text
, "CPU ");
1888 snprintf(tmp
, 255, "%u", tfc
->index
);
1889 strcat(prop_text_in
.text
, tmp
);
1891 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1892 g_free(prop_text_in
.text
);
1896 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1897 draw_context_in
->current
->over
->y
= y_in
;
1898 draw_context_in
->current
->under
->y
= y_in
+height
;
1899 draw_context_in
->current
->status
= process_in
->state
->s
;
1901 /* for pid_in : remove previous, Prev = current, new current (default) */
1902 g_free(draw_context_in
->previous
->modify_under
);
1903 g_free(draw_context_in
->previous
->modify_middle
);
1904 g_free(draw_context_in
->previous
->modify_over
);
1905 g_free(draw_context_in
->previous
->under
);
1906 g_free(draw_context_in
->previous
->middle
);
1907 g_free(draw_context_in
->previous
->over
);
1908 g_free(draw_context_in
->previous
);
1910 draw_context_in
->previous
= draw_context_in
->current
;
1912 draw_context_in
->current
= g_new(DrawInfo
,1);
1913 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1914 draw_context_in
->current
->over
->x
= -1;
1915 draw_context_in
->current
->over
->y
= -1;
1916 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1917 draw_context_in
->current
->middle
->x
= -1;
1918 draw_context_in
->current
->middle
->y
= -1;
1919 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1920 draw_context_in
->current
->under
->x
= -1;
1921 draw_context_in
->current
->under
->y
= -1;
1922 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1923 draw_context_in
->current
->modify_over
->x
= -1;
1924 draw_context_in
->current
->modify_over
->y
= -1;
1925 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1926 draw_context_in
->current
->modify_middle
->x
= -1;
1927 draw_context_in
->current
->modify_middle
->y
= -1;
1928 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1929 draw_context_in
->current
->modify_under
->x
= -1;
1930 draw_context_in
->current
->modify_under
->y
= -1;
1931 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1940 static __inline__ PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1942 PropertiesLine prop_line
;
1943 prop_line
.line_width
= 1;
1944 prop_line
.style
= GDK_LINE_SOLID
;
1946 //GdkColormap *colormap = gdk_colormap_get_system();
1948 /* color of line : execution mode of the process */
1949 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1950 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1951 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1952 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1953 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1954 prop_line
.color
= drawing_colors
[COL_TRAP
];
1955 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1956 prop_line
.color
= drawing_colors
[COL_IRQ
];
1957 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1958 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1960 prop_line
.color
= drawing_colors
[COL_WHITE
];
1962 //gdk_colormap_alloc_color(colormap,
1973 /* before_execmode_hook
1975 * This function basically draw lines and icons. Two types of lines are drawn :
1976 * one small (3 pixels?) representing the state of the process and the second
1977 * type is thicker (10 pixels?) representing on which CPU a process is running
1978 * (and this only in running state).
1980 * Extremums of the lines :
1981 * x_min : time of the last event context for this process kept in memory.
1982 * x_max : time of the current event.
1983 * y : middle of the process in the process list. The process is found in the
1984 * list, therefore is it's position in pixels.
1986 * The choice of lines'color is defined by the context of the last event for this
1991 int before_execmode_hook(void *hook_data
, void *call_data
)
1993 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1994 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1995 Drawing_t
*drawing
= control_flow_data
->drawing
;
1997 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1999 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2000 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2005 LttTime evtime
= ltt_event_time(e
);
2006 guint width
= drawing
->width
;
2008 /* we are in a execmode, before the state update. We must draw the
2009 * items corresponding to the state before it changes : now is the right
2013 LttvProcessState
*process
= tfs
->process
;
2014 g_assert(process
!= NULL
);
2016 guint pid
= process
->pid
;
2018 /* Well, the process_out existed : we must get it in the process hash
2019 * or add it, and draw its items.
2021 /* Add process to process list (if not present) */
2022 guint y
= 0, height
= 0, pl_height
= 0;
2023 HashedProcessData
*hashed_process_data
= NULL
;
2024 ProcessList
*process_list
= control_flow_data
->process_list
;
2025 LttTime birth
= process
->creation_time
;
2027 if(process_list
->current_hash_data
[tfc
->index
] != NULL
) {
2028 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2030 hashed_process_data
= processlist_get_process_data(process_list
,
2032 process
->last_cpu_index
,
2034 tfc
->t_context
->index
);
2035 if(hashed_process_data
== NULL
)
2037 g_assert(pid
== 0 || pid
!= process
->ppid
);
2038 ProcessInfo
*process_info
;
2039 /* Process not present */
2040 const gchar
*name
= g_quark_to_string(process
->name
);
2041 processlist_add(process_list
,
2043 process
->last_cpu_index
,
2046 tfc
->t_context
->index
,
2050 &hashed_process_data
);
2051 processlist_get_pixels_from_data(process_list
,
2052 hashed_process_data
,
2055 drawing_insert_square( drawing
, y
, height
);
2057 /* Set the current process */
2058 process_list
->current_hash_data
[process
->last_cpu_index
] =
2059 hashed_process_data
;
2062 /* Now, the process is in the state hash and our own process hash.
2063 * We definitely can draw the items related to the ending state.
2066 /* Check if the x position is unset. In can have been left unset by
2067 * a draw closure from a after chunk hook. This should never happen,
2068 * because it must be set by before chunk hook to the damage_begin
2071 g_assert(hashed_process_data
->x
.over
!= -1);
2073 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2076 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2077 processlist_get_pixels_from_data(process_list
,
2078 hashed_process_data
,
2081 TimeWindow time_window
=
2082 lttvwindow_get_time_window(control_flow_data
->tab
);
2085 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2086 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2088 #endif //EXTRA_CHECK
2090 convert_time_to_pixels(
2096 /* Draw collision indicator */
2097 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2098 gdk_draw_point(drawing
->pixmap
,
2102 hashed_process_data
->x
.middle_marked
= TRUE
;
2105 processlist_get_pixels_from_data(process_list
,
2106 hashed_process_data
,
2109 TimeWindow time_window
=
2110 lttvwindow_get_time_window(control_flow_data
->tab
);
2113 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2114 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2116 #endif //EXTRA_CHECK
2119 convert_time_to_pixels(
2126 /* Jump over draw if we are at the same x position */
2127 if(x
== hashed_process_data
->x
.middle
&&
2128 hashed_process_data
->x
.middle_used
)
2130 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2131 /* Draw collision indicator */
2132 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2133 gdk_draw_point(drawing
->pixmap
,
2137 hashed_process_data
->x
.middle_marked
= TRUE
;
2142 DrawContext draw_context
;
2143 /* Now create the drawing context that will be used to draw
2144 * items related to the last state. */
2145 draw_context
.drawable
= drawing
->pixmap
;
2146 draw_context
.gc
= drawing
->gc
;
2147 draw_context
.pango_layout
= drawing
->pango_layout
;
2148 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2149 draw_context
.drawinfo
.end
.x
= x
;
2151 draw_context
.drawinfo
.y
.over
= y
+1;
2152 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2153 draw_context
.drawinfo
.y
.under
= y
+height
;
2155 draw_context
.drawinfo
.start
.offset
.over
= 0;
2156 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2157 draw_context
.drawinfo
.start
.offset
.under
= 0;
2158 draw_context
.drawinfo
.end
.offset
.over
= 0;
2159 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2160 draw_context
.drawinfo
.end
.offset
.under
= 0;
2164 PropertiesLine prop_line
= prepare_s_e_line(process
);
2165 draw_line((void*)&prop_line
, (void*)&draw_context
);
2168 /* become the last x position */
2169 hashed_process_data
->x
.middle
= x
;
2170 hashed_process_data
->x
.middle_used
= TRUE
;
2171 hashed_process_data
->x
.middle_marked
= FALSE
;
2173 /* Calculate the next good time */
2174 convert_pixels_to_time(width
, x
+1, time_window
,
2175 &hashed_process_data
->next_good_time
);
2182 /* after_execmode_hook
2184 * The draw after hook is called by the reading API to have a
2185 * particular event drawn on the screen.
2186 * @param hook_data ControlFlowData structure of the viewer.
2187 * @param call_data Event context.
2189 * This function adds items to be drawn in a queue for each process.
2192 int after_execmode_hook(void *hook_data
, void *call_data
)
2194 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2195 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2197 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2199 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2200 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2205 LttTime evtime
= ltt_event_time(e
);
2206 guint width
= control_flow_data
->drawing
->width
;
2208 /* Add process to process list (if not present) */
2209 LttvProcessState
*process
;
2211 guint y
= 0, height
= 0, pl_height
= 0;
2212 HashedProcessData
*hashed_process_data
= NULL
;
2214 ProcessList
*process_list
= control_flow_data
->process_list
;
2216 /* Find process pid_in in the list... */
2217 process
= tfs
->process
;
2218 /* It should exist, because we are after the state update. */
2219 g_assert(process
!= NULL
);
2221 guint pid
= process
->pid
;
2223 birth
= process
->creation_time
;
2225 if(process_list
->current_hash_data
[tfc
->index
] != NULL
) {
2226 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2228 hashed_process_data
= processlist_get_process_data(process_list
,
2230 process
->last_cpu_index
,
2232 tfc
->t_context
->index
);
2233 if(hashed_process_data
== NULL
)
2235 g_assert(pid
== 0 || pid
!= process
->ppid
);
2236 /* Process not present */
2237 const gchar
*name
= g_quark_to_string(process
->name
);
2238 ProcessInfo
*process_info
;
2239 processlist_add(process_list
,
2241 process
->last_cpu_index
,
2244 tfc
->t_context
->index
,
2248 &hashed_process_data
);
2249 processlist_get_pixels_from_data(process_list
,
2250 hashed_process_data
,
2253 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2255 /* Set the current process */
2256 process_list
->current_hash_data
[process
->last_cpu_index
] =
2257 hashed_process_data
;
2260 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2264 processlist_get_pixels_from_data(process_list
,
2265 hashed_process_data
,
2269 TimeWindow time_window
=
2270 lttvwindow_get_time_window(control_flow_data
->tab
);
2273 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2274 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2276 #endif //EXTRA_CHECK
2281 convert_time_to_pixels(
2287 if(hashed_process_data
->x
.middle
!= new_x
) {
2288 hashed_process_data
->x
.middle
= new_x
;
2289 hashed_process_data
->x
.middle_used
= FALSE
;
2290 hashed_process_data
->x
.middle_marked
= FALSE
;
2298 /* before_process_hook
2300 * Draw lines for process event.
2302 * @param hook_data ControlFlowData structure of the viewer.
2303 * @param call_data Event context.
2305 * This function adds items to be drawn in a queue for each process.
2308 int before_process_hook(void *hook_data
, void *call_data
)
2310 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2311 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2312 Drawing_t
*drawing
= control_flow_data
->drawing
;
2314 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2316 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2317 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2322 LttTime evtime
= ltt_event_time(e
);
2323 guint width
= control_flow_data
->drawing
->width
;
2327 LttField
*f
= ltt_event_field(e
);
2329 element
= ltt_field_member(f
,0);
2330 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2333 if(sub_id
== 3) { /* exit */
2335 /* Add process to process list (if not present) */
2336 LttvProcessState
*process
= tfs
->process
;
2337 guint pid
= process
->pid
;
2339 guint y
= 0, height
= 0, pl_height
= 0;
2340 HashedProcessData
*hashed_process_data
= NULL
;
2342 ProcessList
*process_list
= control_flow_data
->process_list
;
2344 g_assert(process
!= NULL
);
2346 birth
= process
->creation_time
;
2348 if(process_list
->current_hash_data
[tfc
->index
] != NULL
) {
2349 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2351 hashed_process_data
= processlist_get_process_data(process_list
,
2353 process
->last_cpu_index
,
2355 tfc
->t_context
->index
);
2356 if(hashed_process_data
== NULL
)
2358 g_assert(pid
== 0 || pid
!= process
->ppid
);
2359 /* Process not present */
2360 const gchar
*name
= g_quark_to_string(process
->name
);
2361 ProcessInfo
*process_info
;
2362 processlist_add(process_list
,
2364 process
->last_cpu_index
,
2367 tfc
->t_context
->index
,
2371 &hashed_process_data
);
2372 processlist_get_pixels_from_data(process_list
,
2373 hashed_process_data
,
2376 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2380 /* Now, the process is in the state hash and our own process hash.
2381 * We definitely can draw the items related to the ending state.
2384 /* Check if the x position is unset. In can have been left unset by
2385 * a draw closure from a after chunk hook. This should never happen,
2386 * because it must be set by before chunk hook to the damage_begin
2389 g_assert(hashed_process_data
->x
.over
!= -1);
2391 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2394 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2395 processlist_get_pixels_from_data(process_list
,
2396 hashed_process_data
,
2399 TimeWindow time_window
=
2400 lttvwindow_get_time_window(control_flow_data
->tab
);
2403 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2404 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2406 #endif //EXTRA_CHECK
2409 convert_time_to_pixels(
2415 /* Draw collision indicator */
2416 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2417 gdk_draw_point(drawing
->pixmap
,
2421 hashed_process_data
->x
.middle_marked
= TRUE
;
2424 processlist_get_pixels_from_data(process_list
,
2425 hashed_process_data
,
2428 TimeWindow time_window
=
2429 lttvwindow_get_time_window(control_flow_data
->tab
);
2432 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2433 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2435 #endif //EXTRA_CHECK
2439 convert_time_to_pixels(
2446 /* Jump over draw if we are at the same x position */
2447 if(x
== hashed_process_data
->x
.middle
&&
2448 hashed_process_data
->x
.middle_used
)
2450 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2451 /* Draw collision indicator */
2452 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2453 gdk_draw_point(drawing
->pixmap
,
2457 hashed_process_data
->x
.middle_marked
= TRUE
;
2461 DrawContext draw_context
;
2463 /* Now create the drawing context that will be used to draw
2464 * items related to the last state. */
2465 draw_context
.drawable
= drawing
->pixmap
;
2466 draw_context
.gc
= drawing
->gc
;
2467 draw_context
.pango_layout
= drawing
->pango_layout
;
2468 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2469 draw_context
.drawinfo
.end
.x
= x
;
2471 draw_context
.drawinfo
.y
.over
= y
+1;
2472 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2473 draw_context
.drawinfo
.y
.under
= y
+height
;
2475 draw_context
.drawinfo
.start
.offset
.over
= 0;
2476 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2477 draw_context
.drawinfo
.start
.offset
.under
= 0;
2478 draw_context
.drawinfo
.end
.offset
.over
= 0;
2479 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2480 draw_context
.drawinfo
.end
.offset
.under
= 0;
2484 PropertiesLine prop_line
= prepare_s_e_line(process
);
2485 draw_line((void*)&prop_line
, (void*)&draw_context
);
2488 /* become the last x position */
2489 hashed_process_data
->x
.middle
= x
;
2490 hashed_process_data
->x
.middle_used
= TRUE
;
2491 hashed_process_data
->x
.middle_marked
= FALSE
;
2493 /* Calculate the next good time */
2494 convert_pixels_to_time(width
, x
+1, time_window
,
2495 &hashed_process_data
->next_good_time
);
2509 /* after_process_hook
2511 * Create the processlist entry for the child process. Put the last
2512 * position in x at the current time value.
2514 * @param hook_data ControlFlowData structure of the viewer.
2515 * @param call_data Event context.
2517 * This function adds items to be drawn in a queue for each process.
2520 int after_process_hook(void *hook_data
, void *call_data
)
2522 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2523 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2525 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2527 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2528 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2533 LttTime evtime
= ltt_event_time(e
);
2534 guint width
= control_flow_data
->drawing
->width
;
2539 LttField
*f
= ltt_event_field(e
);
2541 element
= ltt_field_member(f
,0);
2542 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2543 element
= ltt_field_member(f
,1);
2544 param1
= ltt_event_get_long_unsigned(e
,element
);
2547 if(sub_id
== 2) { /* fork */
2549 guint child_pid
= param1
;
2550 /* Add process to process list (if not present) */
2551 LttvProcessState
*process_child
;
2553 guint y_child
= 0, height
= 0, pl_height
= 0;
2554 HashedProcessData
*hashed_process_data_child
= NULL
;
2556 ProcessList
*process_list
= control_flow_data
->process_list
;
2558 /* Find child in the list... */
2559 process_child
= lttv_state_find_process(tfs
, child_pid
);
2560 /* It should exist, because we are after the state update. */
2561 g_assert(process_child
!= NULL
);
2563 birth
= process_child
->creation_time
;
2565 hashed_process_data_child
= processlist_get_process_data(process_list
,
2567 process_child
->last_cpu_index
,
2569 tfc
->t_context
->index
);
2570 if(hashed_process_data_child
== NULL
)
2572 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2573 /* Process not present */
2574 const gchar
*name
= g_quark_to_string(process_child
->name
);
2575 ProcessInfo
*process_info
;
2576 processlist_add(process_list
,
2578 process_child
->last_cpu_index
,
2579 process_child
->ppid
,
2581 tfc
->t_context
->index
,
2585 &hashed_process_data_child
);
2586 processlist_get_pixels_from_data(process_list
,
2587 hashed_process_data_child
,
2590 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2594 if(ltt_time_compare(hashed_process_data_child
->next_good_time
,
2598 processlist_get_pixels_from_data(process_list
,
2599 hashed_process_data_child
,
2603 TimeWindow time_window
=
2604 lttvwindow_get_time_window(control_flow_data
->tab
);
2607 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2608 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2610 #endif //EXTRA_CHECK
2613 convert_time_to_pixels(
2619 if(hashed_process_data_child
->x
.over
!= new_x
) {
2620 hashed_process_data_child
->x
.over
= new_x
;
2621 hashed_process_data_child
->x
.over_used
= FALSE
;
2622 hashed_process_data_child
->x
.over_marked
= FALSE
;
2624 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2625 hashed_process_data_child
->x
.middle
= new_x
;
2626 hashed_process_data_child
->x
.middle_used
= FALSE
;
2627 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2629 if(hashed_process_data_child
->x
.under
!= new_x
) {
2630 hashed_process_data_child
->x
.under
= new_x
;
2631 hashed_process_data_child
->x
.under_used
= FALSE
;
2632 hashed_process_data_child
->x
.under_marked
= FALSE
;
2636 } else if(sub_id
== 3) { /* exit */
2638 /* Add process to process list (if not present) */
2639 LttvProcessState
*process
= tfs
->process
;
2640 guint pid
= process
->pid
;
2642 guint y
= 0, height
= 0, pl_height
= 0;
2643 HashedProcessData
*hashed_process_data
= NULL
;
2645 ProcessList
*process_list
= control_flow_data
->process_list
;
2647 /* It should exist, because we are after the state update. */
2648 g_assert(process
!= NULL
);
2650 birth
= process
->creation_time
;
2652 if(process_list
->current_hash_data
[tfc
->index
] != NULL
) {
2653 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2655 hashed_process_data
= processlist_get_process_data(process_list
,
2657 process
->last_cpu_index
,
2659 tfc
->t_context
->index
);
2660 if(hashed_process_data
== NULL
)
2662 g_assert(pid
== 0 || pid
!= process
->ppid
);
2663 /* Process not present */
2664 const gchar
*name
= g_quark_to_string(process
->name
);
2665 ProcessInfo
*process_info
;
2666 processlist_add(process_list
,
2668 process
->last_cpu_index
,
2671 tfc
->t_context
->index
,
2675 &hashed_process_data
);
2676 processlist_get_pixels_from_data(process_list
,
2677 hashed_process_data
,
2680 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2683 /* Set the current process */
2684 process_list
->current_hash_data
[process
->last_cpu_index
] =
2685 hashed_process_data
;
2688 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2692 processlist_get_pixels_from_data(process_list
,
2693 hashed_process_data
,
2697 TimeWindow time_window
=
2698 lttvwindow_get_time_window(control_flow_data
->tab
);
2701 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2702 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2704 #endif //EXTRA_CHECK
2707 convert_time_to_pixels(
2712 if(hashed_process_data
->x
.middle
!= new_x
) {
2713 hashed_process_data
->x
.middle
= new_x
;
2714 hashed_process_data
->x
.middle_used
= FALSE
;
2715 hashed_process_data
->x
.middle_marked
= FALSE
;
2725 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2727 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2728 Drawing_t
*drawing
= control_flow_data
->drawing
;
2730 const TimeWindowNotifyData
*time_window_nofify_data
=
2731 ((const TimeWindowNotifyData
*)call_data
);
2733 TimeWindow
*old_time_window
=
2734 time_window_nofify_data
->old_time_window
;
2735 TimeWindow
*new_time_window
=
2736 time_window_nofify_data
->new_time_window
;
2738 /* Update the ruler */
2739 drawing_update_ruler(control_flow_data
->drawing
,
2743 /* Two cases : zoom in/out or scrolling */
2745 /* In order to make sure we can reuse the old drawing, the scale must
2746 * be the same and the new time interval being partly located in the
2747 * currently shown time interval. (reuse is only for scrolling)
2750 g_info("Old time window HOOK : %u, %u to %u, %u",
2751 old_time_window
->start_time
.tv_sec
,
2752 old_time_window
->start_time
.tv_nsec
,
2753 old_time_window
->time_width
.tv_sec
,
2754 old_time_window
->time_width
.tv_nsec
);
2756 g_info("New time window HOOK : %u, %u to %u, %u",
2757 new_time_window
->start_time
.tv_sec
,
2758 new_time_window
->start_time
.tv_nsec
,
2759 new_time_window
->time_width
.tv_sec
,
2760 new_time_window
->time_width
.tv_nsec
);
2762 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2763 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2765 /* Same scale (scrolling) */
2766 g_info("scrolling");
2767 LttTime
*ns
= &new_time_window
->start_time
;
2768 LttTime
*nw
= &new_time_window
->time_width
;
2769 LttTime
*os
= &old_time_window
->start_time
;
2770 LttTime
*ow
= &old_time_window
->time_width
;
2771 LttTime old_end
= old_time_window
->end_time
;
2772 LttTime new_end
= new_time_window
->end_time
;
2774 //if(ns<os+w && os+w<ns+w)
2775 //if(ns<old_end && os<ns)
2776 if(ltt_time_compare(*ns
, old_end
) == -1
2777 && ltt_time_compare(*os
, *ns
) == -1)
2779 g_info("scrolling near right");
2780 /* Scroll right, keep right part of the screen */
2782 guint width
= control_flow_data
->drawing
->width
;
2783 convert_time_to_pixels(
2789 /* Copy old data to new location */
2790 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2791 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2792 control_flow_data
->drawing
->pixmap
,
2795 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2797 if(drawing
->damage_begin
== drawing
->damage_end
)
2798 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2800 drawing
->damage_begin
= 0;
2802 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2804 /* Clear the data request background, but not SAFETY */
2805 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2806 //control_flow_data->drawing->drawing_area->style->black_gc,
2807 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2809 drawing
->damage_begin
+SAFETY
, 0,
2810 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2811 control_flow_data
->drawing
->height
);
2813 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2815 control_flow_data
->drawing
->width
,
2816 control_flow_data
->drawing
->height
);
2818 /* Get new data for the rest. */
2819 drawing_data_request(control_flow_data
->drawing
,
2820 &control_flow_data
->drawing
->pixmap
,
2821 drawing
->damage_begin
, 0,
2822 drawing
->damage_end
- drawing
->damage_begin
,
2823 control_flow_data
->drawing
->height
);
2826 //if(ns<os && os<ns+w)
2827 //if(ns<os && os<new_end)
2828 if(ltt_time_compare(*ns
,*os
) == -1
2829 && ltt_time_compare(*os
,new_end
) == -1)
2831 g_info("scrolling near left");
2832 /* Scroll left, keep left part of the screen */
2834 guint width
= control_flow_data
->drawing
->width
;
2835 convert_time_to_pixels(
2842 /* Copy old data to new location */
2843 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2844 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2845 control_flow_data
->drawing
->pixmap
,
2850 if(drawing
->damage_begin
== drawing
->damage_end
)
2851 drawing
->damage_end
= x
;
2853 drawing
->damage_end
=
2854 control_flow_data
->drawing
->width
;
2856 drawing
->damage_begin
= 0;
2858 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2859 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2861 drawing
->damage_begin
, 0,
2862 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2863 control_flow_data
->drawing
->height
);
2865 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2867 control_flow_data
->drawing
->width
,
2868 control_flow_data
->drawing
->height
);
2871 /* Get new data for the rest. */
2872 drawing_data_request(control_flow_data
->drawing
,
2873 &control_flow_data
->drawing
->pixmap
,
2874 drawing
->damage_begin
, 0,
2875 drawing
->damage_end
- drawing
->damage_begin
,
2876 control_flow_data
->drawing
->height
);
2879 if(ltt_time_compare(*ns
,*os
) == 0)
2881 g_info("not scrolling");
2883 g_info("scrolling far");
2884 /* Cannot reuse any part of the screen : far jump */
2887 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2888 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2891 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2892 control_flow_data
->drawing
->height
);
2894 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2896 control_flow_data
->drawing
->width
,
2897 control_flow_data
->drawing
->height
);
2899 drawing
->damage_begin
= 0;
2900 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2902 drawing_data_request(control_flow_data
->drawing
,
2903 &control_flow_data
->drawing
->pixmap
,
2905 control_flow_data
->drawing
->width
,
2906 control_flow_data
->drawing
->height
);
2912 /* Different scale (zoom) */
2915 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2916 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2919 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2920 control_flow_data
->drawing
->height
);
2922 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2924 control_flow_data
->drawing
->width
,
2925 control_flow_data
->drawing
->height
);
2927 drawing
->damage_begin
= 0;
2928 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2930 drawing_data_request(control_flow_data
->drawing
,
2931 &control_flow_data
->drawing
->pixmap
,
2933 control_flow_data
->drawing
->width
,
2934 control_flow_data
->drawing
->height
);
2942 gint
traceset_notify(void *hook_data
, void *call_data
)
2944 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2945 Drawing_t
*drawing
= control_flow_data
->drawing
;
2946 GtkWidget
*widget
= drawing
->drawing_area
;
2949 drawing_clear(control_flow_data
->drawing
);
2950 processlist_clear(control_flow_data
->process_list
);
2951 redraw_notify(control_flow_data
, NULL
);
2953 request_background_data(control_flow_data
);
2955 drawing
->damage_begin
= 0;
2956 drawing
->damage_end
= drawing
->width
;
2957 if(drawing
->damage_begin
< drawing
->damage_end
)
2959 drawing_data_request(drawing
,
2961 drawing
->damage_begin
,
2963 drawing
->damage_end
-drawing
->damage_begin
,
2967 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2976 gint
redraw_notify(void *hook_data
, void *call_data
)
2978 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2979 Drawing_t
*drawing
= control_flow_data
->drawing
;
2980 GtkWidget
*widget
= drawing
->drawing_area
;
2982 drawing
->damage_begin
= 0;
2983 drawing
->damage_end
= drawing
->width
;
2985 /* fun feature, to be separated someday... */
2986 drawing_clear(control_flow_data
->drawing
);
2987 processlist_clear(control_flow_data
->process_list
);
2990 gdk_draw_rectangle (drawing
->pixmap
,
2991 widget
->style
->black_gc
,
2994 drawing
->width
+SAFETY
,
2998 if(drawing
->damage_begin
< drawing
->damage_end
)
3000 drawing_data_request(drawing
,
3002 drawing
->damage_begin
,
3004 drawing
->damage_end
-drawing
->damage_begin
,
3008 gtk_widget_queue_draw_area(drawing
->drawing_area
,
3017 gint
continue_notify(void *hook_data
, void *call_data
)
3019 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3020 Drawing_t
*drawing
= control_flow_data
->drawing
;
3021 GtkWidget
*widget
= drawing
->drawing_area
;
3023 //g_assert(widget->allocation.width == drawing->damage_end);
3025 if(drawing
->damage_begin
< drawing
->damage_end
)
3027 drawing_data_request(drawing
,
3029 drawing
->damage_begin
,
3031 drawing
->damage_end
-drawing
->damage_begin
,
3039 gint
update_current_time_hook(void *hook_data
, void *call_data
)
3041 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
3042 Drawing_t
*drawing
= control_flow_data
->drawing
;
3044 LttTime current_time
= *((LttTime
*)call_data
);
3046 TimeWindow time_window
=
3047 lttvwindow_get_time_window(control_flow_data
->tab
);
3049 LttTime time_begin
= time_window
.start_time
;
3050 LttTime width
= time_window
.time_width
;
3053 guint64 time_ll
= ltt_time_to_uint64(width
);
3054 time_ll
= time_ll
>> 1; /* divide by two */
3055 half_width
= ltt_time_from_uint64(time_ll
);
3057 LttTime time_end
= ltt_time_add(time_begin
, width
);
3059 LttvTracesetContext
* tsc
=
3060 lttvwindow_get_traceset_context(control_flow_data
->tab
);
3062 LttTime trace_start
= tsc
->time_span
.start_time
;
3063 LttTime trace_end
= tsc
->time_span
.end_time
;
3065 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
3066 current_time
.tv_nsec
);
3070 /* If current time is inside time interval, just move the highlight
3073 /* Else, we have to change the time interval. We have to tell it
3074 * to the main window. */
3075 /* The time interval change will take care of placing the current
3076 * time at the center of the visible area, or nearest possible if we are
3077 * at one end of the trace. */
3080 if(ltt_time_compare(current_time
, time_begin
) == -1)
3082 TimeWindow new_time_window
;
3084 if(ltt_time_compare(current_time
,
3085 ltt_time_add(trace_start
,half_width
)) == -1)
3086 time_begin
= trace_start
;
3088 time_begin
= ltt_time_sub(current_time
,half_width
);
3090 new_time_window
.start_time
= time_begin
;
3091 new_time_window
.time_width
= width
;
3092 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3093 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3095 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3097 else if(ltt_time_compare(current_time
, time_end
) == 1)
3099 TimeWindow new_time_window
;
3101 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
3102 time_begin
= ltt_time_sub(trace_end
,width
);
3104 time_begin
= ltt_time_sub(current_time
,half_width
);
3106 new_time_window
.start_time
= time_begin
;
3107 new_time_window
.time_width
= width
;
3108 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3109 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3111 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3114 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
3115 gtk_widget_queue_draw_area(drawing
->drawing_area
,
3123 typedef struct _ClosureData
{
3124 EventsRequest
*events_request
;
3125 LttvTracesetState
*tss
;
3130 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3132 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3133 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3134 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3136 EventsRequest
*events_request
= closure_data
->events_request
;
3137 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3138 Drawing_t
*drawing
= control_flow_data
->drawing
;
3140 LttvTracesetState
*tss
= closure_data
->tss
;
3141 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
3143 LttTime evtime
= closure_data
->end_time
;
3144 guint width
= drawing
->width
;
3147 /* For the process */
3148 /* First, check if the current process is in the state computation
3149 * process list. If it is there, that means we must add it right now and
3150 * draw items from the beginning of the read for it. If it is not
3151 * present, it's a new process and it was not present : it will
3152 * be added after the state update. */
3154 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3155 #endif //EXTRA_CHECK
3156 /* tracefiles[0] is ok here, because we draw for every PID, and
3157 * assume CPU 0 for PID 0 //FIXME */
3158 LttvTracefileState
*tfs
=
3159 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
3161 LttvProcessState
*process
;
3162 process
= lttv_state_find_process(tfs
,
3165 if(process
!= NULL
) {
3167 /* Only draw for processes that are currently in the trace states */
3169 guint y
= 0, height
= 0, pl_height
= 0;
3170 ProcessList
*process_list
= control_flow_data
->process_list
;
3171 LttTime birth
= process_info
->birth
;
3173 /* Should be alike when background info is ready */
3174 if(control_flow_data
->background_info_waiting
==0)
3175 g_assert(ltt_time_compare(process
->creation_time
,
3176 process_info
->birth
) == 0);
3177 /* process HAS to be present */
3178 processlist_get_pixels_from_data(process_list
,
3179 hashed_process_data
,
3183 /* Now, the process is in the state hash and our own process hash.
3184 * We definitely can draw the items related to the ending state.
3187 /* Check if the x position is unset. In can have been left unset by
3188 * a draw closure from a after chunk hook. This should never happen,
3189 * because it must be set by before chunk hook to the damage_begin
3192 g_assert(hashed_process_data
->x
.over
!= -1);
3194 if(ltt_time_compare(hashed_process_data
->next_good_time
,
3197 TimeWindow time_window
=
3198 lttvwindow_get_time_window(control_flow_data
->tab
);
3201 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3202 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3204 #endif //EXTRA_CHECK
3207 convert_time_to_pixels(
3213 DrawContext draw_context
;
3215 /* Now create the drawing context that will be used to draw
3216 * items related to the last state. */
3217 draw_context
.drawable
= drawing
->pixmap
;
3218 draw_context
.gc
= drawing
->gc
;
3219 draw_context
.pango_layout
= drawing
->pango_layout
;
3220 draw_context
.drawinfo
.end
.x
= x
;
3222 draw_context
.drawinfo
.y
.over
= y
+1;
3223 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3224 draw_context
.drawinfo
.y
.under
= y
+height
;
3226 draw_context
.drawinfo
.start
.offset
.over
= 0;
3227 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3228 draw_context
.drawinfo
.start
.offset
.under
= 0;
3229 draw_context
.drawinfo
.end
.offset
.over
= 0;
3230 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3231 draw_context
.drawinfo
.end
.offset
.under
= 0;
3233 /* Jump over draw if we are at the same x position */
3234 if(x
== hashed_process_data
->x
.over
)
3238 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3240 PropertiesLine prop_line
= prepare_execmode_line(process
);
3241 draw_line((void*)&prop_line
, (void*)&draw_context
);
3243 hashed_process_data
->x
.over
= x
;
3247 if(x
== hashed_process_data
->x
.middle
&&
3248 hashed_process_data
->x
.middle_used
) {
3249 #if 0 /* do not mark closure : not missing information */
3250 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3251 /* Draw collision indicator */
3252 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3253 gdk_draw_point(drawing
->pixmap
,
3257 hashed_process_data
->x
.middle_marked
= TRUE
;
3262 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3264 PropertiesLine prop_line
= prepare_s_e_line(process
);
3265 draw_line((void*)&prop_line
, (void*)&draw_context
);
3267 /* become the last x position */
3268 if(x
!= hashed_process_data
->x
.middle
) {
3269 hashed_process_data
->x
.middle
= x
;
3270 /* but don't use the pixel */
3271 hashed_process_data
->x
.middle_used
= FALSE
;
3273 /* Calculate the next good time */
3274 convert_pixels_to_time(width
, x
+1, time_window
,
3275 &hashed_process_data
->next_good_time
);
3284 int before_chunk(void *hook_data
, void *call_data
)
3286 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3287 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3289 drawing_chunk_begin(events_request
, tss
);
3294 int before_request(void *hook_data
, void *call_data
)
3296 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3297 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3299 drawing_data_request_begin(events_request
, tss
);
3306 * after request is necessary in addition of after chunk in order to draw
3307 * lines until the end of the screen. after chunk just draws lines until
3314 int after_request(void *hook_data
, void *call_data
)
3316 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3317 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3318 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3319 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3321 ProcessList
*process_list
= control_flow_data
->process_list
;
3322 LttTime end_time
= events_request
->end_time
;
3324 ClosureData closure_data
;
3325 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3326 closure_data
.tss
= tss
;
3327 closure_data
.end_time
= end_time
;
3329 /* Draw last items */
3330 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3331 (void*)&closure_data
);
3333 /* Request expose */
3334 drawing_request_expose(events_request
, tss
, end_time
);
3343 int after_chunk(void *hook_data
, void *call_data
)
3345 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3346 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3347 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3348 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3349 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3352 ProcessList
*process_list
= control_flow_data
->process_list
;
3354 g_free(process_list
->current_hash_data
);
3355 process_list
->current_hash_data
= NULL
;
3358 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3359 else /* end of traceset, or position now out of request : end */
3360 end_time
= events_request
->end_time
;
3362 ClosureData closure_data
;
3363 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3364 closure_data
.tss
= tss
;
3365 closure_data
.end_time
= end_time
;
3367 /* Draw last items */
3368 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3369 (void*)&closure_data
);
3371 /* Request expose */
3372 drawing_request_expose(events_request
, tss
, end_time
);