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 /**************** DOES NOTHING!! *************/
2195 /* hook desactivated in drawing.c */
2200 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2201 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2203 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2205 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2206 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2211 LttTime evtime
= ltt_event_time(e
);
2212 guint width
= control_flow_data
->drawing
->width
;
2214 /* Add process to process list (if not present) */
2215 LttvProcessState
*process
;
2217 guint y
= 0, height
= 0, pl_height
= 0;
2218 HashedProcessData
*hashed_process_data
= NULL
;
2220 ProcessList
*process_list
= control_flow_data
->process_list
;
2222 /* Find process pid_in in the list... */
2223 process
= tfs
->process
;
2224 /* It should exist, because we are after the state update. */
2225 g_assert(process
!= NULL
);
2227 guint pid
= process
->pid
;
2229 birth
= process
->creation_time
;
2231 if(process_list
->current_hash_data
[tfc
->index
] != NULL
) {
2232 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2234 hashed_process_data
= processlist_get_process_data(process_list
,
2236 process
->last_cpu_index
,
2238 tfc
->t_context
->index
);
2239 if(hashed_process_data
== NULL
)
2241 g_assert(pid
== 0 || pid
!= process
->ppid
);
2242 /* Process not present */
2243 const gchar
*name
= g_quark_to_string(process
->name
);
2244 ProcessInfo
*process_info
;
2245 processlist_add(process_list
,
2247 process
->last_cpu_index
,
2250 tfc
->t_context
->index
,
2254 &hashed_process_data
);
2255 processlist_get_pixels_from_data(process_list
,
2256 hashed_process_data
,
2259 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2261 /* Set the current process */
2262 process_list
->current_hash_data
[process
->last_cpu_index
] =
2263 hashed_process_data
;
2266 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2270 processlist_get_pixels_from_data(process_list
,
2271 hashed_process_data
,
2275 TimeWindow time_window
=
2276 lttvwindow_get_time_window(control_flow_data
->tab
);
2279 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2280 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2282 #endif //EXTRA_CHECK
2287 convert_time_to_pixels(
2293 if(hashed_process_data
->x
.middle
!= new_x
) {
2294 hashed_process_data
->x
.middle
= new_x
;
2295 hashed_process_data
->x
.middle_used
= FALSE
;
2296 hashed_process_data
->x
.middle_marked
= FALSE
;
2304 /* before_process_hook
2306 * Draw lines for process event.
2308 * @param hook_data ControlFlowData structure of the viewer.
2309 * @param call_data Event context.
2311 * This function adds items to be drawn in a queue for each process.
2314 int before_process_hook(void *hook_data
, void *call_data
)
2316 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2317 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2318 Drawing_t
*drawing
= control_flow_data
->drawing
;
2320 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2322 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2323 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2328 LttTime evtime
= ltt_event_time(e
);
2329 guint width
= control_flow_data
->drawing
->width
;
2333 LttField
*f
= ltt_event_field(e
);
2335 element
= ltt_field_member(f
,0);
2336 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2339 if(sub_id
== 3) { /* exit */
2341 /* Add process to process list (if not present) */
2342 LttvProcessState
*process
= tfs
->process
;
2343 guint pid
= process
->pid
;
2345 guint y
= 0, height
= 0, pl_height
= 0;
2346 HashedProcessData
*hashed_process_data
= NULL
;
2348 ProcessList
*process_list
= control_flow_data
->process_list
;
2350 g_assert(process
!= NULL
);
2352 birth
= process
->creation_time
;
2354 if(process_list
->current_hash_data
[tfc
->index
] != NULL
) {
2355 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2357 hashed_process_data
= processlist_get_process_data(process_list
,
2359 process
->last_cpu_index
,
2361 tfc
->t_context
->index
);
2362 if(hashed_process_data
== NULL
)
2364 g_assert(pid
== 0 || pid
!= process
->ppid
);
2365 /* Process not present */
2366 const gchar
*name
= g_quark_to_string(process
->name
);
2367 ProcessInfo
*process_info
;
2368 processlist_add(process_list
,
2370 process
->last_cpu_index
,
2373 tfc
->t_context
->index
,
2377 &hashed_process_data
);
2378 processlist_get_pixels_from_data(process_list
,
2379 hashed_process_data
,
2382 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2386 /* Now, the process is in the state hash and our own process hash.
2387 * We definitely can draw the items related to the ending state.
2390 /* Check if the x position is unset. In can have been left unset by
2391 * a draw closure from a after chunk hook. This should never happen,
2392 * because it must be set by before chunk hook to the damage_begin
2395 g_assert(hashed_process_data
->x
.over
!= -1);
2397 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2400 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2401 processlist_get_pixels_from_data(process_list
,
2402 hashed_process_data
,
2405 TimeWindow time_window
=
2406 lttvwindow_get_time_window(control_flow_data
->tab
);
2409 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2410 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2412 #endif //EXTRA_CHECK
2415 convert_time_to_pixels(
2421 /* Draw collision indicator */
2422 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2423 gdk_draw_point(drawing
->pixmap
,
2427 hashed_process_data
->x
.middle_marked
= TRUE
;
2430 processlist_get_pixels_from_data(process_list
,
2431 hashed_process_data
,
2434 TimeWindow time_window
=
2435 lttvwindow_get_time_window(control_flow_data
->tab
);
2438 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2439 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2441 #endif //EXTRA_CHECK
2445 convert_time_to_pixels(
2452 /* Jump over draw if we are at the same x position */
2453 if(x
== hashed_process_data
->x
.middle
&&
2454 hashed_process_data
->x
.middle_used
)
2456 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2457 /* Draw collision indicator */
2458 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2459 gdk_draw_point(drawing
->pixmap
,
2463 hashed_process_data
->x
.middle_marked
= TRUE
;
2467 DrawContext draw_context
;
2469 /* Now create the drawing context that will be used to draw
2470 * items related to the last state. */
2471 draw_context
.drawable
= drawing
->pixmap
;
2472 draw_context
.gc
= drawing
->gc
;
2473 draw_context
.pango_layout
= drawing
->pango_layout
;
2474 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2475 draw_context
.drawinfo
.end
.x
= x
;
2477 draw_context
.drawinfo
.y
.over
= y
+1;
2478 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2479 draw_context
.drawinfo
.y
.under
= y
+height
;
2481 draw_context
.drawinfo
.start
.offset
.over
= 0;
2482 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2483 draw_context
.drawinfo
.start
.offset
.under
= 0;
2484 draw_context
.drawinfo
.end
.offset
.over
= 0;
2485 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2486 draw_context
.drawinfo
.end
.offset
.under
= 0;
2490 PropertiesLine prop_line
= prepare_s_e_line(process
);
2491 draw_line((void*)&prop_line
, (void*)&draw_context
);
2494 /* become the last x position */
2495 hashed_process_data
->x
.middle
= x
;
2496 hashed_process_data
->x
.middle_used
= TRUE
;
2497 hashed_process_data
->x
.middle_marked
= FALSE
;
2499 /* Calculate the next good time */
2500 convert_pixels_to_time(width
, x
+1, time_window
,
2501 &hashed_process_data
->next_good_time
);
2515 /* after_process_hook
2517 * Create the processlist entry for the child process. Put the last
2518 * position in x at the current time value.
2520 * @param hook_data ControlFlowData structure of the viewer.
2521 * @param call_data Event context.
2523 * This function adds items to be drawn in a queue for each process.
2526 int after_process_hook(void *hook_data
, void *call_data
)
2528 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2529 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2531 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2533 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2534 LttvTraceState
*ts
=(LttvTraceState
*)((LttvTracefileContext
*)tfs
)->t_context
;
2539 LttTime evtime
= ltt_event_time(e
);
2540 guint width
= control_flow_data
->drawing
->width
;
2545 LttField
*f
= ltt_event_field(e
);
2547 element
= ltt_field_member(f
,0);
2548 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2549 element
= ltt_field_member(f
,1);
2550 param1
= ltt_event_get_long_unsigned(e
,element
);
2553 if(sub_id
== 2) { /* fork */
2555 guint child_pid
= param1
;
2556 /* Add process to process list (if not present) */
2557 LttvProcessState
*process_child
;
2559 guint y_child
= 0, height
= 0, pl_height
= 0;
2560 HashedProcessData
*hashed_process_data_child
= NULL
;
2562 ProcessList
*process_list
= control_flow_data
->process_list
;
2564 /* Find child in the list... */
2565 process_child
= lttv_state_find_process(tfs
, child_pid
);
2566 /* It should exist, because we are after the state update. */
2567 g_assert(process_child
!= NULL
);
2569 birth
= process_child
->creation_time
;
2571 hashed_process_data_child
= processlist_get_process_data(process_list
,
2573 process_child
->last_cpu_index
,
2575 tfc
->t_context
->index
);
2576 if(hashed_process_data_child
== NULL
)
2578 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2579 /* Process not present */
2580 const gchar
*name
= g_quark_to_string(process_child
->name
);
2581 ProcessInfo
*process_info
;
2582 processlist_add(process_list
,
2584 process_child
->last_cpu_index
,
2585 process_child
->ppid
,
2587 tfc
->t_context
->index
,
2591 &hashed_process_data_child
);
2592 processlist_get_pixels_from_data(process_list
,
2593 hashed_process_data_child
,
2596 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2600 if(ltt_time_compare(hashed_process_data_child
->next_good_time
,
2604 processlist_get_pixels_from_data(process_list
,
2605 hashed_process_data_child
,
2609 TimeWindow time_window
=
2610 lttvwindow_get_time_window(control_flow_data
->tab
);
2613 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2614 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2616 #endif //EXTRA_CHECK
2619 convert_time_to_pixels(
2625 if(hashed_process_data_child
->x
.over
!= new_x
) {
2626 hashed_process_data_child
->x
.over
= new_x
;
2627 hashed_process_data_child
->x
.over_used
= FALSE
;
2628 hashed_process_data_child
->x
.over_marked
= FALSE
;
2630 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2631 hashed_process_data_child
->x
.middle
= new_x
;
2632 hashed_process_data_child
->x
.middle_used
= FALSE
;
2633 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2635 if(hashed_process_data_child
->x
.under
!= new_x
) {
2636 hashed_process_data_child
->x
.under
= new_x
;
2637 hashed_process_data_child
->x
.under_used
= FALSE
;
2638 hashed_process_data_child
->x
.under_marked
= FALSE
;
2642 } else if(sub_id
== 3) { /* exit */
2644 /* Add process to process list (if not present) */
2645 LttvProcessState
*process
= tfs
->process
;
2646 guint pid
= process
->pid
;
2648 guint y
= 0, height
= 0, pl_height
= 0;
2649 HashedProcessData
*hashed_process_data
= NULL
;
2651 ProcessList
*process_list
= control_flow_data
->process_list
;
2653 /* It should exist, because we are after the state update. */
2654 g_assert(process
!= NULL
);
2656 birth
= process
->creation_time
;
2658 if(process_list
->current_hash_data
[tfc
->index
] != NULL
) {
2659 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2661 hashed_process_data
= processlist_get_process_data(process_list
,
2663 process
->last_cpu_index
,
2665 tfc
->t_context
->index
);
2666 if(hashed_process_data
== NULL
)
2668 g_assert(pid
== 0 || pid
!= process
->ppid
);
2669 /* Process not present */
2670 const gchar
*name
= g_quark_to_string(process
->name
);
2671 ProcessInfo
*process_info
;
2672 processlist_add(process_list
,
2674 process
->last_cpu_index
,
2677 tfc
->t_context
->index
,
2681 &hashed_process_data
);
2682 processlist_get_pixels_from_data(process_list
,
2683 hashed_process_data
,
2686 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2689 /* Set the current process */
2690 process_list
->current_hash_data
[process
->last_cpu_index
] =
2691 hashed_process_data
;
2694 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2698 processlist_get_pixels_from_data(process_list
,
2699 hashed_process_data
,
2703 TimeWindow time_window
=
2704 lttvwindow_get_time_window(control_flow_data
->tab
);
2707 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2708 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2710 #endif //EXTRA_CHECK
2713 convert_time_to_pixels(
2718 if(hashed_process_data
->x
.middle
!= new_x
) {
2719 hashed_process_data
->x
.middle
= new_x
;
2720 hashed_process_data
->x
.middle_used
= FALSE
;
2721 hashed_process_data
->x
.middle_marked
= FALSE
;
2731 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2733 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2734 Drawing_t
*drawing
= control_flow_data
->drawing
;
2736 const TimeWindowNotifyData
*time_window_nofify_data
=
2737 ((const TimeWindowNotifyData
*)call_data
);
2739 TimeWindow
*old_time_window
=
2740 time_window_nofify_data
->old_time_window
;
2741 TimeWindow
*new_time_window
=
2742 time_window_nofify_data
->new_time_window
;
2744 /* Update the ruler */
2745 drawing_update_ruler(control_flow_data
->drawing
,
2749 /* Two cases : zoom in/out or scrolling */
2751 /* In order to make sure we can reuse the old drawing, the scale must
2752 * be the same and the new time interval being partly located in the
2753 * currently shown time interval. (reuse is only for scrolling)
2756 g_info("Old time window HOOK : %u, %u to %u, %u",
2757 old_time_window
->start_time
.tv_sec
,
2758 old_time_window
->start_time
.tv_nsec
,
2759 old_time_window
->time_width
.tv_sec
,
2760 old_time_window
->time_width
.tv_nsec
);
2762 g_info("New time window HOOK : %u, %u to %u, %u",
2763 new_time_window
->start_time
.tv_sec
,
2764 new_time_window
->start_time
.tv_nsec
,
2765 new_time_window
->time_width
.tv_sec
,
2766 new_time_window
->time_width
.tv_nsec
);
2768 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2769 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2771 /* Same scale (scrolling) */
2772 g_info("scrolling");
2773 LttTime
*ns
= &new_time_window
->start_time
;
2774 LttTime
*nw
= &new_time_window
->time_width
;
2775 LttTime
*os
= &old_time_window
->start_time
;
2776 LttTime
*ow
= &old_time_window
->time_width
;
2777 LttTime old_end
= old_time_window
->end_time
;
2778 LttTime new_end
= new_time_window
->end_time
;
2780 //if(ns<os+w && os+w<ns+w)
2781 //if(ns<old_end && os<ns)
2782 if(ltt_time_compare(*ns
, old_end
) == -1
2783 && ltt_time_compare(*os
, *ns
) == -1)
2785 g_info("scrolling near right");
2786 /* Scroll right, keep right part of the screen */
2788 guint width
= control_flow_data
->drawing
->width
;
2789 convert_time_to_pixels(
2795 /* Copy old data to new location */
2796 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2797 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2798 control_flow_data
->drawing
->pixmap
,
2801 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2803 if(drawing
->damage_begin
== drawing
->damage_end
)
2804 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2806 drawing
->damage_begin
= 0;
2808 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2810 /* Clear the data request background, but not SAFETY */
2811 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2812 //control_flow_data->drawing->drawing_area->style->black_gc,
2813 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2815 drawing
->damage_begin
+SAFETY
, 0,
2816 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2817 control_flow_data
->drawing
->height
);
2819 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2821 control_flow_data
->drawing
->width
,
2822 control_flow_data
->drawing
->height
);
2824 /* Get new data for the rest. */
2825 drawing_data_request(control_flow_data
->drawing
,
2826 &control_flow_data
->drawing
->pixmap
,
2827 drawing
->damage_begin
, 0,
2828 drawing
->damage_end
- drawing
->damage_begin
,
2829 control_flow_data
->drawing
->height
);
2832 //if(ns<os && os<ns+w)
2833 //if(ns<os && os<new_end)
2834 if(ltt_time_compare(*ns
,*os
) == -1
2835 && ltt_time_compare(*os
,new_end
) == -1)
2837 g_info("scrolling near left");
2838 /* Scroll left, keep left part of the screen */
2840 guint width
= control_flow_data
->drawing
->width
;
2841 convert_time_to_pixels(
2848 /* Copy old data to new location */
2849 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2850 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2851 control_flow_data
->drawing
->pixmap
,
2856 if(drawing
->damage_begin
== drawing
->damage_end
)
2857 drawing
->damage_end
= x
;
2859 drawing
->damage_end
=
2860 control_flow_data
->drawing
->width
;
2862 drawing
->damage_begin
= 0;
2864 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2865 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2867 drawing
->damage_begin
, 0,
2868 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2869 control_flow_data
->drawing
->height
);
2871 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2873 control_flow_data
->drawing
->width
,
2874 control_flow_data
->drawing
->height
);
2877 /* Get new data for the rest. */
2878 drawing_data_request(control_flow_data
->drawing
,
2879 &control_flow_data
->drawing
->pixmap
,
2880 drawing
->damage_begin
, 0,
2881 drawing
->damage_end
- drawing
->damage_begin
,
2882 control_flow_data
->drawing
->height
);
2885 if(ltt_time_compare(*ns
,*os
) == 0)
2887 g_info("not scrolling");
2889 g_info("scrolling far");
2890 /* Cannot reuse any part of the screen : far jump */
2893 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2894 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2897 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2898 control_flow_data
->drawing
->height
);
2900 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2902 control_flow_data
->drawing
->width
,
2903 control_flow_data
->drawing
->height
);
2905 drawing
->damage_begin
= 0;
2906 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2908 drawing_data_request(control_flow_data
->drawing
,
2909 &control_flow_data
->drawing
->pixmap
,
2911 control_flow_data
->drawing
->width
,
2912 control_flow_data
->drawing
->height
);
2918 /* Different scale (zoom) */
2921 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2922 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2925 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2926 control_flow_data
->drawing
->height
);
2928 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2930 control_flow_data
->drawing
->width
,
2931 control_flow_data
->drawing
->height
);
2933 drawing
->damage_begin
= 0;
2934 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2936 drawing_data_request(control_flow_data
->drawing
,
2937 &control_flow_data
->drawing
->pixmap
,
2939 control_flow_data
->drawing
->width
,
2940 control_flow_data
->drawing
->height
);
2948 gint
traceset_notify(void *hook_data
, void *call_data
)
2950 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2951 Drawing_t
*drawing
= control_flow_data
->drawing
;
2952 GtkWidget
*widget
= drawing
->drawing_area
;
2955 drawing_clear(control_flow_data
->drawing
);
2956 processlist_clear(control_flow_data
->process_list
);
2957 redraw_notify(control_flow_data
, NULL
);
2959 request_background_data(control_flow_data
);
2961 drawing
->damage_begin
= 0;
2962 drawing
->damage_end
= drawing
->width
;
2963 if(drawing
->damage_begin
< drawing
->damage_end
)
2965 drawing_data_request(drawing
,
2967 drawing
->damage_begin
,
2969 drawing
->damage_end
-drawing
->damage_begin
,
2973 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2982 gint
redraw_notify(void *hook_data
, void *call_data
)
2984 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2985 Drawing_t
*drawing
= control_flow_data
->drawing
;
2986 GtkWidget
*widget
= drawing
->drawing_area
;
2988 drawing
->damage_begin
= 0;
2989 drawing
->damage_end
= drawing
->width
;
2991 /* fun feature, to be separated someday... */
2992 drawing_clear(control_flow_data
->drawing
);
2993 processlist_clear(control_flow_data
->process_list
);
2996 gdk_draw_rectangle (drawing
->pixmap
,
2997 widget
->style
->black_gc
,
3000 drawing
->width
+SAFETY
,
3004 if(drawing
->damage_begin
< drawing
->damage_end
)
3006 drawing_data_request(drawing
,
3008 drawing
->damage_begin
,
3010 drawing
->damage_end
-drawing
->damage_begin
,
3014 gtk_widget_queue_draw_area(drawing
->drawing_area
,
3023 gint
continue_notify(void *hook_data
, void *call_data
)
3025 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3026 Drawing_t
*drawing
= control_flow_data
->drawing
;
3027 GtkWidget
*widget
= drawing
->drawing_area
;
3029 //g_assert(widget->allocation.width == drawing->damage_end);
3031 if(drawing
->damage_begin
< drawing
->damage_end
)
3033 drawing_data_request(drawing
,
3035 drawing
->damage_begin
,
3037 drawing
->damage_end
-drawing
->damage_begin
,
3045 gint
update_current_time_hook(void *hook_data
, void *call_data
)
3047 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
3048 Drawing_t
*drawing
= control_flow_data
->drawing
;
3050 LttTime current_time
= *((LttTime
*)call_data
);
3052 TimeWindow time_window
=
3053 lttvwindow_get_time_window(control_flow_data
->tab
);
3055 LttTime time_begin
= time_window
.start_time
;
3056 LttTime width
= time_window
.time_width
;
3059 guint64 time_ll
= ltt_time_to_uint64(width
);
3060 time_ll
= time_ll
>> 1; /* divide by two */
3061 half_width
= ltt_time_from_uint64(time_ll
);
3063 LttTime time_end
= ltt_time_add(time_begin
, width
);
3065 LttvTracesetContext
* tsc
=
3066 lttvwindow_get_traceset_context(control_flow_data
->tab
);
3068 LttTime trace_start
= tsc
->time_span
.start_time
;
3069 LttTime trace_end
= tsc
->time_span
.end_time
;
3071 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
3072 current_time
.tv_nsec
);
3076 /* If current time is inside time interval, just move the highlight
3079 /* Else, we have to change the time interval. We have to tell it
3080 * to the main window. */
3081 /* The time interval change will take care of placing the current
3082 * time at the center of the visible area, or nearest possible if we are
3083 * at one end of the trace. */
3086 if(ltt_time_compare(current_time
, time_begin
) == -1)
3088 TimeWindow new_time_window
;
3090 if(ltt_time_compare(current_time
,
3091 ltt_time_add(trace_start
,half_width
)) == -1)
3092 time_begin
= trace_start
;
3094 time_begin
= ltt_time_sub(current_time
,half_width
);
3096 new_time_window
.start_time
= time_begin
;
3097 new_time_window
.time_width
= width
;
3098 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3099 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3101 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3103 else if(ltt_time_compare(current_time
, time_end
) == 1)
3105 TimeWindow new_time_window
;
3107 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
3108 time_begin
= ltt_time_sub(trace_end
,width
);
3110 time_begin
= ltt_time_sub(current_time
,half_width
);
3112 new_time_window
.start_time
= time_begin
;
3113 new_time_window
.time_width
= width
;
3114 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3115 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3117 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3120 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
3121 gtk_widget_queue_draw_area(drawing
->drawing_area
,
3129 typedef struct _ClosureData
{
3130 EventsRequest
*events_request
;
3131 LttvTracesetState
*tss
;
3136 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3138 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3139 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3140 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3142 EventsRequest
*events_request
= closure_data
->events_request
;
3143 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3144 Drawing_t
*drawing
= control_flow_data
->drawing
;
3146 LttvTracesetState
*tss
= closure_data
->tss
;
3147 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
3149 LttTime evtime
= closure_data
->end_time
;
3150 guint width
= drawing
->width
;
3153 /* For the process */
3154 /* First, check if the current process is in the state computation
3155 * process list. If it is there, that means we must add it right now and
3156 * draw items from the beginning of the read for it. If it is not
3157 * present, it's a new process and it was not present : it will
3158 * be added after the state update. */
3160 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3161 #endif //EXTRA_CHECK
3162 /* tracefiles[0] is ok here, because we draw for every PID, and
3163 * assume CPU 0 for PID 0 //FIXME */
3164 LttvTracefileState
*tfs
=
3165 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
3167 LttvProcessState
*process
;
3168 process
= lttv_state_find_process(tfs
,
3171 if(process
!= NULL
) {
3173 /* Only draw for processes that are currently in the trace states */
3175 guint y
= 0, height
= 0, pl_height
= 0;
3176 ProcessList
*process_list
= control_flow_data
->process_list
;
3177 LttTime birth
= process_info
->birth
;
3179 /* Should be alike when background info is ready */
3180 if(control_flow_data
->background_info_waiting
==0)
3181 g_assert(ltt_time_compare(process
->creation_time
,
3182 process_info
->birth
) == 0);
3183 /* process HAS to be present */
3184 processlist_get_pixels_from_data(process_list
,
3185 hashed_process_data
,
3189 /* Now, the process is in the state hash and our own process hash.
3190 * We definitely can draw the items related to the ending state.
3193 /* Check if the x position is unset. In can have been left unset by
3194 * a draw closure from a after chunk hook. This should never happen,
3195 * because it must be set by before chunk hook to the damage_begin
3198 g_assert(hashed_process_data
->x
.over
!= -1);
3200 if(ltt_time_compare(hashed_process_data
->next_good_time
,
3203 TimeWindow time_window
=
3204 lttvwindow_get_time_window(control_flow_data
->tab
);
3207 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3208 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3210 #endif //EXTRA_CHECK
3213 convert_time_to_pixels(
3219 DrawContext draw_context
;
3221 /* Now create the drawing context that will be used to draw
3222 * items related to the last state. */
3223 draw_context
.drawable
= drawing
->pixmap
;
3224 draw_context
.gc
= drawing
->gc
;
3225 draw_context
.pango_layout
= drawing
->pango_layout
;
3226 draw_context
.drawinfo
.end
.x
= x
;
3228 draw_context
.drawinfo
.y
.over
= y
+1;
3229 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3230 draw_context
.drawinfo
.y
.under
= y
+height
;
3232 draw_context
.drawinfo
.start
.offset
.over
= 0;
3233 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3234 draw_context
.drawinfo
.start
.offset
.under
= 0;
3235 draw_context
.drawinfo
.end
.offset
.over
= 0;
3236 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3237 draw_context
.drawinfo
.end
.offset
.under
= 0;
3239 /* Jump over draw if we are at the same x position */
3240 if(x
== hashed_process_data
->x
.over
)
3244 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3246 PropertiesLine prop_line
= prepare_execmode_line(process
);
3247 draw_line((void*)&prop_line
, (void*)&draw_context
);
3249 hashed_process_data
->x
.over
= x
;
3253 if(x
== hashed_process_data
->x
.middle
&&
3254 hashed_process_data
->x
.middle_used
) {
3255 #if 0 /* do not mark closure : not missing information */
3256 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3257 /* Draw collision indicator */
3258 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3259 gdk_draw_point(drawing
->pixmap
,
3263 hashed_process_data
->x
.middle_marked
= TRUE
;
3268 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3270 PropertiesLine prop_line
= prepare_s_e_line(process
);
3271 draw_line((void*)&prop_line
, (void*)&draw_context
);
3273 /* become the last x position */
3274 if(x
!= hashed_process_data
->x
.middle
) {
3275 hashed_process_data
->x
.middle
= x
;
3276 /* but don't use the pixel */
3277 hashed_process_data
->x
.middle_used
= FALSE
;
3279 /* Calculate the next good time */
3280 convert_pixels_to_time(width
, x
+1, time_window
,
3281 &hashed_process_data
->next_good_time
);
3290 int before_chunk(void *hook_data
, void *call_data
)
3292 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3293 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3295 drawing_chunk_begin(events_request
, tss
);
3300 int before_request(void *hook_data
, void *call_data
)
3302 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3303 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3305 drawing_data_request_begin(events_request
, tss
);
3312 * after request is necessary in addition of after chunk in order to draw
3313 * lines until the end of the screen. after chunk just draws lines until
3320 int after_request(void *hook_data
, void *call_data
)
3322 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3323 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3324 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3325 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3327 ProcessList
*process_list
= control_flow_data
->process_list
;
3328 LttTime end_time
= events_request
->end_time
;
3330 ClosureData closure_data
;
3331 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3332 closure_data
.tss
= tss
;
3333 closure_data
.end_time
= end_time
;
3335 /* Draw last items */
3336 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3337 (void*)&closure_data
);
3339 /* Request expose */
3340 drawing_request_expose(events_request
, tss
, end_time
);
3349 int after_chunk(void *hook_data
, void *call_data
)
3351 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3352 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3353 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3354 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3355 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3358 ProcessList
*process_list
= control_flow_data
->process_list
;
3360 g_free(process_list
->current_hash_data
);
3361 process_list
->current_hash_data
= NULL
;
3364 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3365 else /* end of traceset, or position now out of request : end */
3366 end_time
= events_request
->end_time
;
3368 ClosureData closure_data
;
3369 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3370 closure_data
.tss
= tss
;
3371 closure_data
.end_time
= end_time
;
3373 /* Draw last items */
3374 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3375 (void*)&closure_data
);
3377 /* Request expose */
3378 drawing_request_expose(events_request
, tss
, end_time
);