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
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
393 LttTime evtime
= ltt_event_time(e
);
394 TimeWindow time_window
=
395 lttvwindow_get_time_window(control_flow_data
->tab
);
397 LttTime end_time
= ltt_time_add(time_window
.start_time
,
398 time_window
.time_width
);
400 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
401 || ltt_time_compare(evtime
, end_time
) == 1)
403 guint width
= drawing
->width
;
405 /* we are in a schedchange, before the state update. We must draw the
406 * items corresponding to the state before it changes : now is the right
413 LttField
*f
= ltt_event_field(e
);
415 element
= ltt_field_member(f
,0);
416 pid_out
= ltt_event_get_long_unsigned(e
,element
);
417 element
= ltt_field_member(f
,1);
418 pid_in
= ltt_event_get_long_unsigned(e
,element
);
419 g_debug("out : %u in : %u", pid_out
, pid_in
);
423 /* For the pid_out */
424 /* First, check if the current process is in the state computation
425 * process list. If it is there, that means we must add it right now and
426 * draw items from the beginning of the read for it. If it is not
427 * present, it's a new process and it was not present : it will
428 * be added after the state update. */
429 LttvProcessState
*process
;
430 process
= lttv_state_find_process(tfs
, pid_out
);
432 if(process
!= NULL
) {
433 /* Well, the process_out existed : we must get it in the process hash
434 * or add it, and draw its items.
436 /* Add process to process list (if not present) */
437 guint y
= 0, height
= 0, pl_height
= 0;
438 HashedProcessData
*hashed_process_data
= NULL
;
439 ProcessList
*process_list
= control_flow_data
->process_list
;
440 LttTime birth
= process
->creation_time
;
441 const gchar
*name
= g_quark_to_string(process
->name
);
443 if(processlist_get_process_pixels(process_list
,
447 tfc
->t_context
->index
,
450 &hashed_process_data
) == 1)
452 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
453 /* Process not present */
454 processlist_add(process_list
,
459 tfc
->t_context
->index
,
462 &hashed_process_data
);
463 processlist_get_process_pixels(process_list
,
467 tfc
->t_context
->index
,
470 &hashed_process_data
);
471 drawing_insert_square( drawing
, y
, height
);
474 /* Now, the process is in the state hash and our own process hash.
475 * We definitely can draw the items related to the ending state.
478 /* Check if the x position is unset. In can have been left unset by
479 * a draw closure from a after chunk hook. This should never happen,
480 * because it must be set by before chunk hook to the damage_begin
483 g_assert(hashed_process_data
->x
.middle
!= -1);
486 convert_time_to_pixels(
487 time_window
.start_time
,
494 /* Jump over draw if we are at the same x position */
495 if(x
== hashed_process_data
->x
.middle
&&
496 hashed_process_data
->x
.middle_used
)
498 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
499 /* Draw collision indicator */
500 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
501 gdk_draw_point(drawing
->pixmap
,
505 hashed_process_data
->x
.middle_marked
= TRUE
;
509 DrawContext draw_context
;
511 /* Now create the drawing context that will be used to draw
512 * items related to the last state. */
513 draw_context
.drawable
= drawing
->pixmap
;
514 draw_context
.gc
= drawing
->gc
;
515 draw_context
.pango_layout
= drawing
->pango_layout
;
516 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
517 draw_context
.drawinfo
.end
.x
= x
;
519 draw_context
.drawinfo
.y
.over
= y
+1;
520 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
521 draw_context
.drawinfo
.y
.under
= y
+height
;
523 draw_context
.drawinfo
.start
.offset
.over
= 0;
524 draw_context
.drawinfo
.start
.offset
.middle
= 0;
525 draw_context
.drawinfo
.start
.offset
.under
= 0;
526 draw_context
.drawinfo
.end
.offset
.over
= 0;
527 draw_context
.drawinfo
.end
.offset
.middle
= 0;
528 draw_context
.drawinfo
.end
.offset
.under
= 0;
532 PropertiesLine prop_line
= prepare_s_e_line(process
);
533 draw_line((void*)&prop_line
, (void*)&draw_context
);
536 /* become the last x position */
537 hashed_process_data
->x
.middle
= x
;
538 hashed_process_data
->x
.middle_used
= TRUE
;
539 hashed_process_data
->x
.middle_marked
= FALSE
;
547 /* First, check if the current process is in the state computation
548 * process list. If it is there, that means we must add it right now and
549 * draw items from the beginning of the read for it. If it is not
550 * present, it's a new process and it was not present : it will
551 * be added after the state update. */
552 LttvProcessState
*process
;
553 process
= lttv_state_find_process(tfs
, pid_in
);
555 if(process
!= NULL
) {
556 /* Well, the process_out existed : we must get it in the process hash
557 * or add it, and draw its items.
559 /* Add process to process list (if not present) */
560 guint y
= 0, height
= 0, pl_height
= 0;
561 HashedProcessData
*hashed_process_data
= NULL
;
562 ProcessList
*process_list
= control_flow_data
->process_list
;
563 LttTime birth
= process
->creation_time
;
564 const gchar
*name
= g_quark_to_string(process
->name
);
566 if(processlist_get_process_pixels(process_list
,
570 tfc
->t_context
->index
,
573 &hashed_process_data
) == 1)
575 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
576 /* Process not present */
577 processlist_add(process_list
,
582 tfc
->t_context
->index
,
585 &hashed_process_data
);
586 processlist_get_process_pixels(process_list
,
590 tfc
->t_context
->index
,
593 &hashed_process_data
);
594 drawing_insert_square( drawing
, y
, height
);
597 /* Now, the process is in the state hash and our own process hash.
598 * We definitely can draw the items related to the ending state.
601 /* Check if the x position is unset. In can have been left unset by
602 * a draw closure from a after chunk hook. This should never happen,
603 * because it must be set by before chunk hook to the damage_begin
606 g_assert(hashed_process_data
->x
.middle
!= -1);
610 convert_time_to_pixels(
611 time_window
.start_time
,
618 /* Jump over draw if we are at the same x position */
619 if(x
== hashed_process_data
->x
.middle
&&
620 hashed_process_data
->x
.middle_used
)
622 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
623 /* Draw collision indicator */
624 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
625 gdk_draw_point(drawing
->pixmap
,
629 hashed_process_data
->x
.middle_marked
= TRUE
;
633 DrawContext draw_context
;
635 /* Now create the drawing context that will be used to draw
636 * items related to the last state. */
637 draw_context
.drawable
= drawing
->pixmap
;
638 draw_context
.gc
= drawing
->gc
;
639 draw_context
.pango_layout
= drawing
->pango_layout
;
640 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
641 draw_context
.drawinfo
.end
.x
= x
;
643 draw_context
.drawinfo
.y
.over
= y
+1;
644 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
645 draw_context
.drawinfo
.y
.under
= y
+height
;
647 draw_context
.drawinfo
.start
.offset
.over
= 0;
648 draw_context
.drawinfo
.start
.offset
.middle
= 0;
649 draw_context
.drawinfo
.start
.offset
.under
= 0;
650 draw_context
.drawinfo
.end
.offset
.over
= 0;
651 draw_context
.drawinfo
.end
.offset
.middle
= 0;
652 draw_context
.drawinfo
.end
.offset
.under
= 0;
656 PropertiesLine prop_line
= prepare_s_e_line(process
);
657 draw_line((void*)&prop_line
, (void*)&draw_context
);
661 /* become the last x position */
662 hashed_process_data
->x
.middle
= x
;
663 hashed_process_data
->x
.middle_used
= TRUE
;
664 hashed_process_data
->x
.middle_marked
= FALSE
;
673 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
674 ControlFlowData
*control_flow_data
=
675 (ControlFlowData
*)events_request
->viewer_data
;
676 Tab
*tab
= control_flow_data
->tab
;
678 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
680 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
681 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
686 LttTime evtime
= ltt_event_time(e
);
687 TimeWindow time_window
=
688 lttvwindow_get_time_window(tab
);
690 LttTime end_time
= ltt_time_add(time_window
.start_time
,
691 time_window
.time_width
);
692 //if(time < time_beg || time > time_end) return;
693 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
694 || ltt_time_compare(evtime
, end_time
) == 1)
697 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
699 g_debug("schedchange!");
701 /* Add process to process list (if not present) and get drawing "y" from
702 * process position */
703 guint pid_out
, pid_in
;
704 LttvProcessState
*process_out
, *process_in
;
706 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
708 ProcessList
*process_list
= control_flow_data
->process_list
;
711 LttField
*f
= ltt_event_field(e
);
713 element
= ltt_field_member(f
,0);
714 pid_out
= ltt_event_get_long_unsigned(e
,element
);
715 element
= ltt_field_member(f
,1);
716 pid_in
= ltt_event_get_long_unsigned(e
,element
);
717 g_debug("out : %u in : %u", pid_out
, pid_in
);
720 /* Find process pid_out in the list... */
721 process_out
= lttv_state_find_process(tfs
, pid_out
);
722 if(process_out
== NULL
) return 0;
723 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
725 birth
= process_out
->creation_time
;
726 const gchar
*name
= g_quark_to_string(process_out
->name
);
727 HashedProcessData
*hashed_process_data_out
= NULL
;
729 if(processlist_get_process_pixels(process_list
,
732 tfc
->t_context
->index
,
735 &hashed_process_data_out
) == 1)
737 /* Process not present */
738 processlist_add(process_list
,
741 tfc
->t_context
->index
,
744 &hashed_process_data_out
);
745 g_assert(processlist_get_process_pixels(process_list
,
748 tfc
->t_context
->index
,
751 &hashed_process_data_out
)==0);
752 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
756 /* Find process pid_in in the list... */
757 process_in
= lttv_state_find_process(tfs
, pid_in
);
758 if(process_in
== NULL
) return 0;
759 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
761 birth
= process_in
->creation_time
;
762 name
= g_quark_to_string(process_in
->name
);
763 HashedProcessData
*hashed_process_data_in
= NULL
;
765 if(processlist_get_process_pixels(process_list
,
768 tfc
->t_context
->index
,
771 &hashed_process_data_in
) == 1)
773 /* Process not present */
774 processlist_add(process_list
,
777 tfc
->t_context
->index
,
780 &hashed_process_data_in
);
781 processlist_get_process_pixels(process_list
,
784 tfc
->t_context
->index
,
787 &hashed_process_data_in
);
789 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
794 /* Find pixels corresponding to time of the event. If the time does
795 * not fit in the window, show a warning, not supposed to happend. */
797 guint width
= control_flow_data
->drawing
->width
;
799 LttTime time
= ltt_event_time(e
);
801 LttTime window_end
= ltt_time_add(time_window
.time_width
,
802 time_window
.start_time
);
805 convert_time_to_pixels(
806 time_window
.start_time
,
811 //assert(x <= width);
813 /* draw what represents the event for outgoing process. */
815 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
816 draw_context_out
->current
->modify_over
->x
= x
;
817 draw_context_out
->current
->modify_under
->x
= x
;
818 draw_context_out
->current
->modify_over
->y
= y_out
;
819 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
820 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
821 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
822 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
823 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
824 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
825 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
826 //draw_context_out->gc = widget->style->black_gc;
828 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
829 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
831 /* Draw the line/background of the out process */
832 if(draw_context_out
->previous
->middle
->x
== -1)
834 draw_context_out
->previous
->over
->x
=
835 control_flow_data
->drawing
->damage_begin
;
836 draw_context_out
->previous
->middle
->x
=
837 control_flow_data
->drawing
->damage_begin
;
838 draw_context_out
->previous
->under
->x
=
839 control_flow_data
->drawing
->damage_begin
;
841 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
844 draw_context_out
->current
->middle
->x
= x
;
845 draw_context_out
->current
->over
->x
= x
;
846 draw_context_out
->current
->under
->x
= x
;
847 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
848 draw_context_out
->current
->over
->y
= y_out
;
849 draw_context_out
->current
->under
->y
= y_out
+ height
;
850 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
851 draw_context_out
->previous
->over
->y
= y_out
;
852 draw_context_out
->previous
->under
->y
= y_out
+ height
;
854 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
855 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
857 if(process_out
->state
->s
== LTTV_STATE_RUN
)
859 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
860 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
861 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
863 PropertiesBG prop_bg
;
864 prop_bg
.color
= g_new(GdkColor
,1);
868 prop_bg
.color
->red
= 0x1515;
869 prop_bg
.color
->green
= 0x1515;
870 prop_bg
.color
->blue
= 0x8c8c;
873 prop_bg
.color
->red
= 0x4e4e;
874 prop_bg
.color
->green
= 0xa9a9;
875 prop_bg
.color
->blue
= 0xa4a4;
878 prop_bg
.color
->red
= 0x7a7a;
879 prop_bg
.color
->green
= 0x4a4a;
880 prop_bg
.color
->blue
= 0x8b8b;
883 prop_bg
.color
->red
= 0x8080;
884 prop_bg
.color
->green
= 0x7777;
885 prop_bg
.color
->blue
= 0x4747;
888 prop_bg
.color
->red
= 0xe7e7;
889 prop_bg
.color
->green
= 0xe7e7;
890 prop_bg
.color
->blue
= 0xe7e7;
893 g_debug("calling from draw_event");
894 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
895 g_free(prop_bg
.color
);
896 //gdk_gc_unref(draw_context_out->gc);
899 draw_context_out
->gc
= widget
->style
->black_gc
;
901 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
902 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
903 PropertiesText prop_text_out
;
904 prop_text_out
.foreground
= &colorfg_out
;
905 prop_text_out
.background
= &colorbg_out
;
906 prop_text_out
.size
= 6;
907 prop_text_out
.position
= OVER
;
909 /* color of text : status of the process */
910 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
912 prop_text_out
.foreground
->red
= 0xffff;
913 prop_text_out
.foreground
->green
= 0xffff;
914 prop_text_out
.foreground
->blue
= 0xffff;
916 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
918 prop_text_out
.foreground
->red
= 0x0fff;
919 prop_text_out
.foreground
->green
= 0xffff;
920 prop_text_out
.foreground
->blue
= 0xfff0;
922 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
924 prop_text_out
.foreground
->red
= 0xffff;
925 prop_text_out
.foreground
->green
= 0xffff;
926 prop_text_out
.foreground
->blue
= 0x0000;
928 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
930 prop_text_out
.foreground
->red
= 0xffff;
931 prop_text_out
.foreground
->green
= 0x0000;
932 prop_text_out
.foreground
->blue
= 0xffff;
934 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
936 prop_text_out
.foreground
->red
= 0xffff;
937 prop_text_out
.foreground
->green
= 0x0000;
938 prop_text_out
.foreground
->blue
= 0x0000;
940 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
942 prop_text_out
.foreground
->red
= 0x0000;
943 prop_text_out
.foreground
->green
= 0xffff;
944 prop_text_out
.foreground
->blue
= 0x0000;
948 prop_text_out
.foreground
->red
= 0xffff;
949 prop_text_out
.foreground
->green
= 0xffff;
950 prop_text_out
.foreground
->blue
= 0xffff;
954 /* Print status of the process : U, WF, WC, E, W, R */
955 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
956 prop_text_out
.text
= "U->";
957 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
958 prop_text_out
.text
= "WF->";
959 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
960 prop_text_out
.text
= "WC->";
961 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
962 prop_text_out
.text
= "E->";
963 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
964 prop_text_out
.text
= "W->";
965 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
966 prop_text_out
.text
= "R->";
968 prop_text_out
.text
= "U";
970 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
971 //gdk_gc_unref(draw_context_out->gc);
973 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
974 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
975 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
977 PropertiesLine prop_line_out
;
978 prop_line_out
.color
= g_new(GdkColor
,1);
979 prop_line_out
.line_width
= 2;
980 prop_line_out
.style
= GDK_LINE_SOLID
;
981 prop_line_out
.position
= MIDDLE
;
983 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
985 /* color of line : status of the process */
986 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
988 prop_line_out
.color
->red
= 0xffff;
989 prop_line_out
.color
->green
= 0xffff;
990 prop_line_out
.color
->blue
= 0xffff;
992 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
994 prop_line_out
.color
->red
= 0x0fff;
995 prop_line_out
.color
->green
= 0xffff;
996 prop_line_out
.color
->blue
= 0xfff0;
998 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1000 prop_line_out
.color
->red
= 0xffff;
1001 prop_line_out
.color
->green
= 0xffff;
1002 prop_line_out
.color
->blue
= 0x0000;
1004 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1006 prop_line_out
.color
->red
= 0xffff;
1007 prop_line_out
.color
->green
= 0x0000;
1008 prop_line_out
.color
->blue
= 0xffff;
1010 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1012 prop_line_out
.color
->red
= 0xffff;
1013 prop_line_out
.color
->green
= 0x0000;
1014 prop_line_out
.color
->blue
= 0x0000;
1016 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1018 prop_line_out
.color
->red
= 0x0000;
1019 prop_line_out
.color
->green
= 0xffff;
1020 prop_line_out
.color
->blue
= 0x0000;
1024 prop_line_out
.color
->red
= 0xffff;
1025 prop_line_out
.color
->green
= 0xffff;
1026 prop_line_out
.color
->blue
= 0xffff;
1029 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1030 g_free(prop_line_out
.color
);
1031 //gdk_gc_unref(draw_context_out->gc);
1032 /* Note : finishing line will have to be added when trace read over. */
1034 /* Finally, update the drawing context of the pid_in. */
1036 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1037 draw_context_in
->current
->modify_over
->x
= x
;
1038 draw_context_in
->current
->modify_under
->x
= x
;
1039 draw_context_in
->current
->modify_over
->y
= y_in
;
1040 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1041 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1042 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1043 widget
= control_flow_data
->drawing
->drawing_area
;
1044 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1045 //draw_context_in->gc = widget->style->black_gc;
1046 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1047 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1049 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1050 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1052 /* Draw the line/bg of the in process */
1053 if(draw_context_in
->previous
->middle
->x
== -1)
1055 draw_context_in
->previous
->over
->x
=
1056 control_flow_data
->drawing
->damage_begin
;
1057 draw_context_in
->previous
->middle
->x
=
1058 control_flow_data
->drawing
->damage_begin
;
1059 draw_context_in
->previous
->under
->x
=
1060 control_flow_data
->drawing
->damage_begin
;
1062 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1066 draw_context_in
->current
->middle
->x
= x
;
1067 draw_context_in
->current
->over
->x
= x
;
1068 draw_context_in
->current
->under
->x
= x
;
1069 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1070 draw_context_in
->current
->over
->y
= y_in
;
1071 draw_context_in
->current
->under
->y
= y_in
+ height
;
1072 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1073 draw_context_in
->previous
->over
->y
= y_in
;
1074 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1076 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1077 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1080 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1082 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1083 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1084 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1086 PropertiesBG prop_bg
;
1087 prop_bg
.color
= g_new(GdkColor
,1);
1089 switch(tfc
->index
) {
1091 prop_bg
.color
->red
= 0x1515;
1092 prop_bg
.color
->green
= 0x1515;
1093 prop_bg
.color
->blue
= 0x8c8c;
1096 prop_bg
.color
->red
= 0x4e4e;
1097 prop_bg
.color
->green
= 0xa9a9;
1098 prop_bg
.color
->blue
= 0xa4a4;
1101 prop_bg
.color
->red
= 0x7a7a;
1102 prop_bg
.color
->green
= 0x4a4a;
1103 prop_bg
.color
->blue
= 0x8b8b;
1106 prop_bg
.color
->red
= 0x8080;
1107 prop_bg
.color
->green
= 0x7777;
1108 prop_bg
.color
->blue
= 0x4747;
1111 prop_bg
.color
->red
= 0xe7e7;
1112 prop_bg
.color
->green
= 0xe7e7;
1113 prop_bg
.color
->blue
= 0xe7e7;
1117 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1118 g_free(prop_bg
.color
);
1119 //gdk_gc_unref(draw_context_in->gc);
1122 draw_context_in
->gc
= widget
->style
->black_gc
;
1124 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1125 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1126 PropertiesText prop_text_in
;
1127 prop_text_in
.foreground
= &colorfg_in
;
1128 prop_text_in
.background
= &colorbg_in
;
1129 prop_text_in
.size
= 6;
1130 prop_text_in
.position
= OVER
;
1132 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1133 /* foreground of text : status of the process */
1134 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1136 prop_text_in
.foreground
->red
= 0xffff;
1137 prop_text_in
.foreground
->green
= 0xffff;
1138 prop_text_in
.foreground
->blue
= 0xffff;
1140 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1142 prop_text_in
.foreground
->red
= 0x0fff;
1143 prop_text_in
.foreground
->green
= 0xffff;
1144 prop_text_in
.foreground
->blue
= 0xfff0;
1146 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1148 prop_text_in
.foreground
->red
= 0xffff;
1149 prop_text_in
.foreground
->green
= 0xffff;
1150 prop_text_in
.foreground
->blue
= 0x0000;
1152 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1154 prop_text_in
.foreground
->red
= 0xffff;
1155 prop_text_in
.foreground
->green
= 0x0000;
1156 prop_text_in
.foreground
->blue
= 0xffff;
1158 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1160 prop_text_in
.foreground
->red
= 0xffff;
1161 prop_text_in
.foreground
->green
= 0x0000;
1162 prop_text_in
.foreground
->blue
= 0x0000;
1164 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1166 prop_text_in
.foreground
->red
= 0x0000;
1167 prop_text_in
.foreground
->green
= 0xffff;
1168 prop_text_in
.foreground
->blue
= 0x0000;
1172 prop_text_in
.foreground
->red
= 0xffff;
1173 prop_text_in
.foreground
->green
= 0xffff;
1174 prop_text_in
.foreground
->blue
= 0xffff;
1179 /* Print status of the process : U, WF, WC, E, W, R */
1180 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1181 prop_text_in
.text
= "U->";
1182 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1183 prop_text_in
.text
= "WF->";
1184 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1185 prop_text_in
.text
= "WC->";
1186 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1187 prop_text_in
.text
= "E->";
1188 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1189 prop_text_in
.text
= "W->";
1190 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1191 prop_text_in
.text
= "R->";
1193 prop_text_in
.text
= "U";
1195 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1196 //gdk_gc_unref(draw_context_in->gc);
1198 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1199 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1200 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1202 PropertiesLine prop_line_in
;
1203 prop_line_in
.color
= g_new(GdkColor
,1);
1204 prop_line_in
.line_width
= 2;
1205 prop_line_in
.style
= GDK_LINE_SOLID
;
1206 prop_line_in
.position
= MIDDLE
;
1208 /* color of line : status of the process */
1209 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1211 prop_line_in
.color
->red
= 0xffff;
1212 prop_line_in
.color
->green
= 0xffff;
1213 prop_line_in
.color
->blue
= 0xffff;
1215 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1217 prop_line_in
.color
->red
= 0x0fff;
1218 prop_line_in
.color
->green
= 0xffff;
1219 prop_line_in
.color
->blue
= 0xfff0;
1221 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1223 prop_line_in
.color
->red
= 0xffff;
1224 prop_line_in
.color
->green
= 0xffff;
1225 prop_line_in
.color
->blue
= 0x0000;
1227 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1229 prop_line_in
.color
->red
= 0xffff;
1230 prop_line_in
.color
->green
= 0x0000;
1231 prop_line_in
.color
->blue
= 0xffff;
1233 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1235 prop_line_in
.color
->red
= 0xffff;
1236 prop_line_in
.color
->green
= 0x0000;
1237 prop_line_in
.color
->blue
= 0x0000;
1239 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1241 prop_line_in
.color
->red
= 0x0000;
1242 prop_line_in
.color
->green
= 0xffff;
1243 prop_line_in
.color
->blue
= 0x0000;
1247 prop_line_in
.color
->red
= 0xffff;
1248 prop_line_in
.color
->green
= 0xffff;
1249 prop_line_in
.color
->blue
= 0xffff;
1252 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1253 g_free(prop_line_in
.color
);
1254 //gdk_gc_unref(draw_context_in->gc);
1264 GString
*string
= g_string_new("");;
1265 gboolean field_names
= TRUE
, state
= TRUE
;
1267 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1268 g_string_append_printf(string
,"\n");
1271 g_string_append_printf(string
, " %s",
1272 g_quark_to_string(tfs
->process
->state
->s
));
1275 g_info("%s",string
->str
);
1277 g_string_free(string
, TRUE
);
1279 /* End of text dump */
1284 /* after_schedchange_hook
1286 * The draw after hook is called by the reading API to have a
1287 * particular event drawn on the screen.
1288 * @param hook_data ControlFlowData structure of the viewer.
1289 * @param call_data Event context.
1291 * This function adds items to be drawn in a queue for each process.
1294 int after_schedchange_hook(void *hook_data
, void *call_data
)
1296 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1297 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1299 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1301 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1302 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1307 LttTime evtime
= ltt_event_time(e
);
1308 TimeWindow time_window
=
1309 lttvwindow_get_time_window(control_flow_data
->tab
);
1311 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1312 time_window
.time_width
);
1314 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1315 || ltt_time_compare(evtime
, end_time
) == 1)
1318 guint width
= control_flow_data
->drawing
->width
;
1320 /* Add process to process list (if not present) */
1321 LttvProcessState
*process_out
, *process_in
;
1323 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1324 HashedProcessData
*hashed_process_data_in
= NULL
;
1326 ProcessList
*process_list
= control_flow_data
->process_list
;
1331 LttField
*f
= ltt_event_field(e
);
1333 element
= ltt_field_member(f
,0);
1334 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1335 element
= ltt_field_member(f
,1);
1336 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1337 g_debug("out : %u in : %u", pid_out
, pid_in
);
1341 /* Find process pid_in in the list... */
1342 process_in
= lttv_state_find_process(tfs
, pid_in
);
1343 /* It should exist, because we are after the state update. */
1344 g_assert(process_in
!= NULL
);
1346 birth
= process_in
->creation_time
;
1347 const gchar
*name
= g_quark_to_string(process_in
->name
);
1349 if(processlist_get_process_pixels(process_list
,
1351 process_in
->last_cpu
,
1353 tfc
->t_context
->index
,
1356 &hashed_process_data_in
) == 1)
1358 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1359 /* Process not present */
1360 processlist_add(process_list
,
1362 process_in
->last_cpu
,
1365 tfc
->t_context
->index
,
1368 &hashed_process_data_in
);
1369 processlist_get_process_pixels(process_list
,
1371 process_in
->last_cpu
,
1373 tfc
->t_context
->index
,
1376 &hashed_process_data_in
);
1377 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1382 convert_time_to_pixels(
1383 time_window
.start_time
,
1389 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1390 hashed_process_data_in
->x
.middle
= new_x
;
1391 hashed_process_data_in
->x
.middle_used
= FALSE
;
1392 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1402 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1403 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1405 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1407 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1408 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1414 LttTime evtime
= ltt_event_time(e
);
1415 TimeWindow time_window
=
1416 lttvwindow_get_time_window(control_flow_data
->tab
);
1418 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1419 time_window
.time_width
);
1420 //if(time < time_beg || time > time_end) return;
1421 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1422 || ltt_time_compare(evtime
, end_time
) == 1)
1426 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1428 g_debug("schedchange!");
1430 /* Add process to process list (if not present) and get drawing "y" from
1431 * process position */
1432 guint pid_out
, pid_in
;
1433 LttvProcessState
*process_out
, *process_in
;
1435 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1437 ProcessList
*process_list
= control_flow_data
->process_list
;
1440 LttField
*f
= ltt_event_field(e
);
1442 element
= ltt_field_member(f
,0);
1443 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1444 element
= ltt_field_member(f
,1);
1445 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1446 //g_debug("out : %u in : %u", pid_out, pid_in);
1449 /* Find process pid_out in the list... */
1450 process_out
= lttv_state_find_process(tfs
, pid_out
);
1451 if(process_out
== NULL
) return 0;
1452 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1454 birth
= process_out
->creation_time
;
1455 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1456 HashedProcessData
*hashed_process_data_out
= NULL
;
1458 if(processlist_get_process_pixels(process_list
,
1461 tfc
->t_context
->index
,
1464 &hashed_process_data_out
) == 1)
1466 /* Process not present */
1467 processlist_add(process_list
,
1470 tfc
->t_context
->index
,
1473 &hashed_process_data_out
);
1474 processlist_get_process_pixels(process_list
,
1477 tfc
->t_context
->index
,
1480 &hashed_process_data_out
);
1481 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1486 /* Find process pid_in in the list... */
1487 process_in
= lttv_state_find_process(tfs
, pid_in
);
1488 if(process_in
== NULL
) return 0;
1489 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1491 birth
= process_in
->creation_time
;
1492 name
= strdup(g_quark_to_string(process_in
->name
));
1493 HashedProcessData
*hashed_process_data_in
= NULL
;
1495 if(processlist_get_process_pixels(process_list
,
1498 tfc
->t_context
->index
,
1501 &hashed_process_data_in
) == 1)
1503 /* Process not present */
1504 processlist_add(process_list
,
1507 tfc
->t_context
->index
,
1510 &hashed_process_data_in
);
1511 processlist_get_process_pixels(process_list
,
1514 tfc
->t_context
->index
,
1517 &hashed_process_data_in
);
1519 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1524 /* Find pixels corresponding to time of the event. If the time does
1525 * not fit in the window, show a warning, not supposed to happend. */
1527 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1529 //LttTime time = ltt_event_time(e);
1531 //LttTime window_end = ltt_time_add(time_window->time_width,
1532 // time_window->start_time);
1535 //convert_time_to_pixels(
1536 // time_window->start_time,
1542 //assert(x <= width);
1544 /* draw what represents the event for outgoing process. */
1546 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1547 //draw_context_out->current->modify_over->x = x;
1548 draw_context_out
->current
->modify_over
->y
= y_out
;
1549 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1550 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1551 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1552 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1553 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1555 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1556 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1558 /*if(process_out->state->s == LTTV_STATE_RUN)
1560 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1561 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1562 PropertiesBG prop_bg;
1563 prop_bg.color = g_new(GdkColor,1);
1565 prop_bg.color->red = 0xffff;
1566 prop_bg.color->green = 0xffff;
1567 prop_bg.color->blue = 0xffff;
1569 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1570 g_free(prop_bg.color);
1571 gdk_gc_unref(draw_context_out->gc);
1574 draw_context_out
->gc
= widget
->style
->black_gc
;
1576 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1577 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1578 PropertiesText prop_text_out
;
1579 prop_text_out
.foreground
= &colorfg_out
;
1580 prop_text_out
.background
= &colorbg_out
;
1581 prop_text_out
.size
= 6;
1582 prop_text_out
.position
= OVER
;
1584 /* color of text : status of the process */
1585 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1587 prop_text_out
.foreground
->red
= 0xffff;
1588 prop_text_out
.foreground
->green
= 0xffff;
1589 prop_text_out
.foreground
->blue
= 0xffff;
1591 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1593 prop_text_out
.foreground
->red
= 0x0fff;
1594 prop_text_out
.foreground
->green
= 0xffff;
1595 prop_text_out
.foreground
->blue
= 0xfff0;
1597 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1599 prop_text_out
.foreground
->red
= 0xffff;
1600 prop_text_out
.foreground
->green
= 0xffff;
1601 prop_text_out
.foreground
->blue
= 0x0000;
1603 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1605 prop_text_out
.foreground
->red
= 0xffff;
1606 prop_text_out
.foreground
->green
= 0x0000;
1607 prop_text_out
.foreground
->blue
= 0xffff;
1609 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1611 prop_text_out
.foreground
->red
= 0xffff;
1612 prop_text_out
.foreground
->green
= 0x0000;
1613 prop_text_out
.foreground
->blue
= 0x0000;
1615 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1617 prop_text_out
.foreground
->red
= 0x0000;
1618 prop_text_out
.foreground
->green
= 0xffff;
1619 prop_text_out
.foreground
->blue
= 0x0000;
1623 prop_text_out
.foreground
->red
= 0xffff;
1624 prop_text_out
.foreground
->green
= 0xffff;
1625 prop_text_out
.foreground
->blue
= 0xffff;
1628 /* Print status of the process : U, WF, WC, E, W, R */
1629 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1630 prop_text_out
.text
= "U";
1631 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1632 prop_text_out
.text
= "WF";
1633 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1634 prop_text_out
.text
= "WC";
1635 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1636 prop_text_out
.text
= "E";
1637 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1638 prop_text_out
.text
= "W";
1639 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1640 prop_text_out
.text
= "R";
1642 prop_text_out
.text
= "U";
1644 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1646 //gdk_gc_unref(draw_context_out->gc);
1648 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1649 draw_context_out
->current
->over
->y
= y_out
;
1650 draw_context_out
->current
->under
->y
= y_out
+height
;
1651 draw_context_out
->current
->status
= process_out
->state
->s
;
1653 /* for pid_out : remove previous, Prev = current, new current (default) */
1654 g_free(draw_context_out
->previous
->modify_under
);
1655 g_free(draw_context_out
->previous
->modify_middle
);
1656 g_free(draw_context_out
->previous
->modify_over
);
1657 g_free(draw_context_out
->previous
->under
);
1658 g_free(draw_context_out
->previous
->middle
);
1659 g_free(draw_context_out
->previous
->over
);
1660 g_free(draw_context_out
->previous
);
1662 draw_context_out
->previous
= draw_context_out
->current
;
1664 draw_context_out
->current
= g_new(DrawInfo
,1);
1665 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1666 draw_context_out
->current
->over
->x
= -1;
1667 draw_context_out
->current
->over
->y
= -1;
1668 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1669 draw_context_out
->current
->middle
->x
= -1;
1670 draw_context_out
->current
->middle
->y
= -1;
1671 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1672 draw_context_out
->current
->under
->x
= -1;
1673 draw_context_out
->current
->under
->y
= -1;
1674 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1675 draw_context_out
->current
->modify_over
->x
= -1;
1676 draw_context_out
->current
->modify_over
->y
= -1;
1677 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1678 draw_context_out
->current
->modify_middle
->x
= -1;
1679 draw_context_out
->current
->modify_middle
->y
= -1;
1680 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1681 draw_context_out
->current
->modify_under
->x
= -1;
1682 draw_context_out
->current
->modify_under
->y
= -1;
1683 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1685 /* Finally, update the drawing context of the pid_in. */
1687 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1688 //draw_context_in->current->modify_over->x = x;
1689 draw_context_in
->current
->modify_over
->y
= y_in
;
1690 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1691 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1692 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1693 widget
= control_flow_data
->drawing
->drawing_area
;
1694 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1696 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1697 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1699 /*if(process_in->state->s == LTTV_STATE_RUN)
1701 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1702 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1703 PropertiesBG prop_bg;
1704 prop_bg.color = g_new(GdkColor,1);
1706 prop_bg.color->red = 0xffff;
1707 prop_bg.color->green = 0xffff;
1708 prop_bg.color->blue = 0xffff;
1710 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1711 g_free(prop_bg.color);
1712 gdk_gc_unref(draw_context_in->gc);
1715 draw_context_in
->gc
= widget
->style
->black_gc
;
1717 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1718 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1719 PropertiesText prop_text_in
;
1720 prop_text_in
.foreground
= &colorfg_in
;
1721 prop_text_in
.background
= &colorbg_in
;
1722 prop_text_in
.size
= 6;
1723 prop_text_in
.position
= OVER
;
1725 /* foreground of text : status of the process */
1726 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1728 prop_text_in
.foreground
->red
= 0xffff;
1729 prop_text_in
.foreground
->green
= 0xffff;
1730 prop_text_in
.foreground
->blue
= 0xffff;
1732 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1734 prop_text_in
.foreground
->red
= 0x0fff;
1735 prop_text_in
.foreground
->green
= 0xffff;
1736 prop_text_in
.foreground
->blue
= 0xfff0;
1738 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1740 prop_text_in
.foreground
->red
= 0xffff;
1741 prop_text_in
.foreground
->green
= 0xffff;
1742 prop_text_in
.foreground
->blue
= 0x0000;
1744 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1746 prop_text_in
.foreground
->red
= 0xffff;
1747 prop_text_in
.foreground
->green
= 0x0000;
1748 prop_text_in
.foreground
->blue
= 0xffff;
1750 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1752 prop_text_in
.foreground
->red
= 0xffff;
1753 prop_text_in
.foreground
->green
= 0x0000;
1754 prop_text_in
.foreground
->blue
= 0x0000;
1756 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1758 prop_text_in
.foreground
->red
= 0x0000;
1759 prop_text_in
.foreground
->green
= 0xffff;
1760 prop_text_in
.foreground
->blue
= 0x0000;
1764 prop_text_in
.foreground
->red
= 0xffff;
1765 prop_text_in
.foreground
->green
= 0xffff;
1766 prop_text_in
.foreground
->blue
= 0xffff;
1770 /* Print status of the process : U, WF, WC, E, W, R */
1771 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1772 prop_text_in
.text
= "U";
1773 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1774 prop_text_in
.text
= "WF";
1775 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1776 prop_text_in
.text
= "WC";
1777 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1778 prop_text_in
.text
= "E";
1779 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1780 prop_text_in
.text
= "W";
1781 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1782 prop_text_in
.text
= "R";
1784 prop_text_in
.text
= "U";
1786 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1789 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1792 prop_text_in
.foreground
= &colorfg_in
;
1793 prop_text_in
.background
= &colorbg_in
;
1794 prop_text_in
.foreground
->red
= 0xffff;
1795 prop_text_in
.foreground
->green
= 0xffff;
1796 prop_text_in
.foreground
->blue
= 0xffff;
1797 prop_text_in
.size
= 6;
1798 prop_text_in
.position
= UNDER
;
1800 prop_text_in
.text
= g_new(gchar
, 260);
1801 strcpy(prop_text_in
.text
, "CPU ");
1802 snprintf(tmp
, 255, "%u", tfc
->index
);
1803 strcat(prop_text_in
.text
, tmp
);
1805 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1806 g_free(prop_text_in
.text
);
1810 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1811 draw_context_in
->current
->over
->y
= y_in
;
1812 draw_context_in
->current
->under
->y
= y_in
+height
;
1813 draw_context_in
->current
->status
= process_in
->state
->s
;
1815 /* for pid_in : remove previous, Prev = current, new current (default) */
1816 g_free(draw_context_in
->previous
->modify_under
);
1817 g_free(draw_context_in
->previous
->modify_middle
);
1818 g_free(draw_context_in
->previous
->modify_over
);
1819 g_free(draw_context_in
->previous
->under
);
1820 g_free(draw_context_in
->previous
->middle
);
1821 g_free(draw_context_in
->previous
->over
);
1822 g_free(draw_context_in
->previous
);
1824 draw_context_in
->previous
= draw_context_in
->current
;
1826 draw_context_in
->current
= g_new(DrawInfo
,1);
1827 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1828 draw_context_in
->current
->over
->x
= -1;
1829 draw_context_in
->current
->over
->y
= -1;
1830 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1831 draw_context_in
->current
->middle
->x
= -1;
1832 draw_context_in
->current
->middle
->y
= -1;
1833 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1834 draw_context_in
->current
->under
->x
= -1;
1835 draw_context_in
->current
->under
->y
= -1;
1836 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1837 draw_context_in
->current
->modify_over
->x
= -1;
1838 draw_context_in
->current
->modify_over
->y
= -1;
1839 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1840 draw_context_in
->current
->modify_middle
->x
= -1;
1841 draw_context_in
->current
->modify_middle
->y
= -1;
1842 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1843 draw_context_in
->current
->modify_under
->x
= -1;
1844 draw_context_in
->current
->modify_under
->y
= -1;
1845 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1854 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1856 PropertiesLine prop_line
;
1857 prop_line
.line_width
= 1;
1858 prop_line
.style
= GDK_LINE_SOLID
;
1860 //GdkColormap *colormap = gdk_colormap_get_system();
1862 /* color of line : execution mode of the process */
1863 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1864 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1865 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1866 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1867 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1868 prop_line
.color
= drawing_colors
[COL_TRAP
];
1869 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1870 prop_line
.color
= drawing_colors
[COL_IRQ
];
1871 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1872 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1874 prop_line
.color
= drawing_colors
[COL_WHITE
];
1876 //gdk_colormap_alloc_color(colormap,
1887 /* before_execmode_hook
1889 * This function basically draw lines and icons. Two types of lines are drawn :
1890 * one small (3 pixels?) representing the state of the process and the second
1891 * type is thicker (10 pixels?) representing on which CPU a process is running
1892 * (and this only in running state).
1894 * Extremums of the lines :
1895 * x_min : time of the last event context for this process kept in memory.
1896 * x_max : time of the current event.
1897 * y : middle of the process in the process list. The process is found in the
1898 * list, therefore is it's position in pixels.
1900 * The choice of lines'color is defined by the context of the last event for this
1905 int before_execmode_hook(void *hook_data
, void *call_data
)
1907 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1908 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1909 Drawing_t
*drawing
= control_flow_data
->drawing
;
1911 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1913 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1914 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1919 LttTime evtime
= ltt_event_time(e
);
1920 TimeWindow time_window
=
1921 lttvwindow_get_time_window(control_flow_data
->tab
);
1923 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1924 time_window
.time_width
);
1926 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1927 || ltt_time_compare(evtime
, end_time
) == 1)
1930 guint width
= drawing
->width
;
1932 /* we are in a execmode, before the state update. We must draw the
1933 * items corresponding to the state before it changes : now is the right
1937 LttvProcessState
*process
= tfs
->process
;
1938 g_assert(process
!= NULL
);
1940 guint pid
= process
->pid
;
1942 /* Well, the process_out existed : we must get it in the process hash
1943 * or add it, and draw its items.
1945 /* Add process to process list (if not present) */
1946 guint y
= 0, height
= 0, pl_height
= 0;
1947 HashedProcessData
*hashed_process_data
= NULL
;
1948 ProcessList
*process_list
= control_flow_data
->process_list
;
1949 LttTime birth
= process
->creation_time
;
1950 const gchar
*name
= g_quark_to_string(process
->name
);
1952 if(processlist_get_process_pixels(process_list
,
1956 tfc
->t_context
->index
,
1959 &hashed_process_data
) == 1)
1961 g_assert(pid
== 0 || pid
!= process
->ppid
);
1962 /* Process not present */
1963 processlist_add(process_list
,
1968 tfc
->t_context
->index
,
1971 &hashed_process_data
);
1972 processlist_get_process_pixels(process_list
,
1976 tfc
->t_context
->index
,
1979 &hashed_process_data
);
1980 drawing_insert_square( drawing
, y
, height
);
1983 /* Now, the process is in the state hash and our own process hash.
1984 * We definitely can draw the items related to the ending state.
1987 /* Check if the x position is unset. In can have been left unset by
1988 * a draw closure from a after chunk hook. This should never happen,
1989 * because it must be set by before chunk hook to the damage_begin
1992 g_assert(hashed_process_data
->x
.over
!= -1);
1996 convert_time_to_pixels(
1997 time_window
.start_time
,
2004 /* Jump over draw if we are at the same x position */
2005 if(x
== hashed_process_data
->x
.middle
&&
2006 hashed_process_data
->x
.middle_used
)
2008 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2009 /* Draw collision indicator */
2010 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2011 gdk_draw_point(drawing
->pixmap
,
2015 hashed_process_data
->x
.middle_marked
= TRUE
;
2020 DrawContext draw_context
;
2021 /* Now create the drawing context that will be used to draw
2022 * items related to the last state. */
2023 draw_context
.drawable
= drawing
->pixmap
;
2024 draw_context
.gc
= drawing
->gc
;
2025 draw_context
.pango_layout
= drawing
->pango_layout
;
2026 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2027 draw_context
.drawinfo
.end
.x
= x
;
2029 draw_context
.drawinfo
.y
.over
= y
+1;
2030 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2031 draw_context
.drawinfo
.y
.under
= y
+height
;
2033 draw_context
.drawinfo
.start
.offset
.over
= 0;
2034 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2035 draw_context
.drawinfo
.start
.offset
.under
= 0;
2036 draw_context
.drawinfo
.end
.offset
.over
= 0;
2037 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2038 draw_context
.drawinfo
.end
.offset
.under
= 0;
2042 PropertiesLine prop_line
= prepare_s_e_line(process
);
2043 draw_line((void*)&prop_line
, (void*)&draw_context
);
2046 /* become the last x position */
2047 hashed_process_data
->x
.middle
= x
;
2048 hashed_process_data
->x
.middle_used
= TRUE
;
2049 hashed_process_data
->x
.middle_marked
= FALSE
;
2056 /* after_execmode_hook
2058 * The draw after hook is called by the reading API to have a
2059 * particular event drawn on the screen.
2060 * @param hook_data ControlFlowData structure of the viewer.
2061 * @param call_data Event context.
2063 * This function adds items to be drawn in a queue for each process.
2066 int after_execmode_hook(void *hook_data
, void *call_data
)
2068 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2069 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2071 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2073 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2074 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2079 LttTime evtime
= ltt_event_time(e
);
2080 TimeWindow time_window
=
2081 lttvwindow_get_time_window(control_flow_data
->tab
);
2083 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2084 time_window
.time_width
);
2086 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2087 || ltt_time_compare(evtime
, end_time
) == 1)
2090 guint width
= control_flow_data
->drawing
->width
;
2092 /* Add process to process list (if not present) */
2093 LttvProcessState
*process
;
2095 guint y
= 0, height
= 0, pl_height
= 0;
2096 HashedProcessData
*hashed_process_data
= NULL
;
2098 ProcessList
*process_list
= control_flow_data
->process_list
;
2100 /* Find process pid_in in the list... */
2101 process
= tfs
->process
;
2102 /* It should exist, because we are after the state update. */
2103 g_assert(process
!= NULL
);
2105 guint pid
= process
->pid
;
2107 birth
= process
->creation_time
;
2108 const gchar
*name
= g_quark_to_string(process
->name
);
2110 if(processlist_get_process_pixels(process_list
,
2114 tfc
->t_context
->index
,
2117 &hashed_process_data
) == 1)
2119 g_assert(pid
== 0 || pid
!= process
->ppid
);
2120 /* Process not present */
2121 processlist_add(process_list
,
2126 tfc
->t_context
->index
,
2129 &hashed_process_data
);
2130 processlist_get_process_pixels(process_list
,
2134 tfc
->t_context
->index
,
2137 &hashed_process_data
);
2138 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2143 convert_time_to_pixels(
2144 time_window
.start_time
,
2150 if(hashed_process_data
->x
.middle
!= new_x
) {
2151 hashed_process_data
->x
.middle
= new_x
;
2152 hashed_process_data
->x
.middle_used
= FALSE
;
2153 hashed_process_data
->x
.middle_marked
= FALSE
;
2161 /* before_process_hook
2163 * Draw lines for process event.
2165 * @param hook_data ControlFlowData structure of the viewer.
2166 * @param call_data Event context.
2168 * This function adds items to be drawn in a queue for each process.
2171 int before_process_hook(void *hook_data
, void *call_data
)
2173 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2174 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2175 Drawing_t
*drawing
= control_flow_data
->drawing
;
2177 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2179 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2180 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2185 LttTime evtime
= ltt_event_time(e
);
2186 TimeWindow time_window
=
2187 lttvwindow_get_time_window(control_flow_data
->tab
);
2189 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2190 time_window
.time_width
);
2192 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2193 || ltt_time_compare(evtime
, end_time
) == 1)
2196 guint width
= control_flow_data
->drawing
->width
;
2200 LttField
*f
= ltt_event_field(e
);
2202 element
= ltt_field_member(f
,0);
2203 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2206 if(sub_id
== 3) { /* exit */
2208 /* Add process to process list (if not present) */
2209 LttvProcessState
*process
= tfs
->process
;
2210 guint pid
= process
->pid
;
2212 guint y
= 0, height
= 0, pl_height
= 0;
2213 HashedProcessData
*hashed_process_data
= NULL
;
2215 ProcessList
*process_list
= control_flow_data
->process_list
;
2217 g_assert(process
!= NULL
);
2219 birth
= process
->creation_time
;
2220 const gchar
*name
= g_quark_to_string(process
->name
);
2222 if(processlist_get_process_pixels(process_list
,
2226 tfc
->t_context
->index
,
2229 &hashed_process_data
) == 1)
2231 g_assert(pid
== 0 || pid
!= process
->ppid
);
2232 /* Process not present */
2233 processlist_add(process_list
,
2238 tfc
->t_context
->index
,
2241 &hashed_process_data
);
2242 processlist_get_process_pixels(process_list
,
2246 tfc
->t_context
->index
,
2249 &hashed_process_data
);
2250 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2253 /* Now, the process is in the state hash and our own process hash.
2254 * We definitely can draw the items related to the ending state.
2257 /* Check if the x position is unset. In can have been left unset by
2258 * a draw closure from a after chunk hook. This should never happen,
2259 * because it must be set by before chunk hook to the damage_begin
2262 g_assert(hashed_process_data
->x
.over
!= -1);
2266 convert_time_to_pixels(
2267 time_window
.start_time
,
2274 /* Jump over draw if we are at the same x position */
2275 if(x
== hashed_process_data
->x
.middle
&&
2276 hashed_process_data
->x
.middle_used
)
2278 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2279 /* Draw collision indicator */
2280 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2281 gdk_draw_point(drawing
->pixmap
,
2285 hashed_process_data
->x
.middle_marked
= TRUE
;
2289 DrawContext draw_context
;
2291 /* Now create the drawing context that will be used to draw
2292 * items related to the last state. */
2293 draw_context
.drawable
= drawing
->pixmap
;
2294 draw_context
.gc
= drawing
->gc
;
2295 draw_context
.pango_layout
= drawing
->pango_layout
;
2296 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2297 draw_context
.drawinfo
.end
.x
= x
;
2299 draw_context
.drawinfo
.y
.over
= y
+1;
2300 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2301 draw_context
.drawinfo
.y
.under
= y
+height
;
2303 draw_context
.drawinfo
.start
.offset
.over
= 0;
2304 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2305 draw_context
.drawinfo
.start
.offset
.under
= 0;
2306 draw_context
.drawinfo
.end
.offset
.over
= 0;
2307 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2308 draw_context
.drawinfo
.end
.offset
.under
= 0;
2312 PropertiesLine prop_line
= prepare_s_e_line(process
);
2313 draw_line((void*)&prop_line
, (void*)&draw_context
);
2316 /* become the last x position */
2317 hashed_process_data
->x
.middle
= x
;
2318 hashed_process_data
->x
.middle_used
= TRUE
;
2319 hashed_process_data
->x
.middle_marked
= FALSE
;
2333 /* after_process_hook
2335 * Create the processlist entry for the child process. Put the last
2336 * position in x at the current time value.
2338 * @param hook_data ControlFlowData structure of the viewer.
2339 * @param call_data Event context.
2341 * This function adds items to be drawn in a queue for each process.
2344 int after_process_hook(void *hook_data
, void *call_data
)
2346 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2347 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2349 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2351 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2352 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2357 LttTime evtime
= ltt_event_time(e
);
2358 TimeWindow time_window
=
2359 lttvwindow_get_time_window(control_flow_data
->tab
);
2361 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2362 time_window
.time_width
);
2364 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2365 || ltt_time_compare(evtime
, end_time
) == 1)
2368 guint width
= control_flow_data
->drawing
->width
;
2373 LttField
*f
= ltt_event_field(e
);
2375 element
= ltt_field_member(f
,0);
2376 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2377 element
= ltt_field_member(f
,1);
2378 param1
= ltt_event_get_long_unsigned(e
,element
);
2381 if(sub_id
== 2) { /* fork */
2383 guint child_pid
= param1
;
2384 /* Add process to process list (if not present) */
2385 LttvProcessState
*process_child
;
2387 guint y_child
= 0, height
= 0, pl_height
= 0;
2388 HashedProcessData
*hashed_process_data_child
= NULL
;
2390 ProcessList
*process_list
= control_flow_data
->process_list
;
2392 /* Find child in the list... */
2393 process_child
= lttv_state_find_process(tfs
, child_pid
);
2394 /* It should exist, because we are after the state update. */
2395 g_assert(process_child
!= NULL
);
2397 birth
= process_child
->creation_time
;
2398 const gchar
*name
= g_quark_to_string(process_child
->name
);
2400 if(processlist_get_process_pixels(process_list
,
2402 process_child
->last_cpu
,
2404 tfc
->t_context
->index
,
2407 &hashed_process_data_child
) == 1)
2409 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2410 /* Process not present */
2411 processlist_add(process_list
,
2413 process_child
->last_cpu
,
2414 process_child
->ppid
,
2416 tfc
->t_context
->index
,
2419 &hashed_process_data_child
);
2420 processlist_get_process_pixels(process_list
,
2422 process_child
->last_cpu
,
2424 tfc
->t_context
->index
,
2427 &hashed_process_data_child
);
2428 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2432 convert_time_to_pixels(
2433 time_window
.start_time
,
2439 if(hashed_process_data_child
->x
.over
!= new_x
) {
2440 hashed_process_data_child
->x
.over
= new_x
;
2441 hashed_process_data_child
->x
.over_used
= FALSE
;
2442 hashed_process_data_child
->x
.over_marked
= FALSE
;
2444 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2445 hashed_process_data_child
->x
.middle
= new_x
;
2446 hashed_process_data_child
->x
.middle_used
= FALSE
;
2447 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2449 if(hashed_process_data_child
->x
.under
!= new_x
) {
2450 hashed_process_data_child
->x
.under
= new_x
;
2451 hashed_process_data_child
->x
.under_used
= FALSE
;
2452 hashed_process_data_child
->x
.under_marked
= FALSE
;
2455 } else if(sub_id
== 3) { /* exit */
2457 /* Add process to process list (if not present) */
2458 LttvProcessState
*process
= tfs
->process
;
2459 guint pid
= process
->pid
;
2461 guint y
= 0, height
= 0, pl_height
= 0;
2462 HashedProcessData
*hashed_process_data
= NULL
;
2464 ProcessList
*process_list
= control_flow_data
->process_list
;
2466 /* It should exist, because we are after the state update. */
2467 g_assert(process
!= NULL
);
2469 birth
= process
->creation_time
;
2470 const gchar
*name
= g_quark_to_string(process
->name
);
2472 if(processlist_get_process_pixels(process_list
,
2476 tfc
->t_context
->index
,
2479 &hashed_process_data
) == 1)
2481 g_assert(pid
== 0 || pid
!= process
->ppid
);
2482 /* Process not present */
2483 processlist_add(process_list
,
2488 tfc
->t_context
->index
,
2491 &hashed_process_data
);
2492 processlist_get_process_pixels(process_list
,
2496 tfc
->t_context
->index
,
2499 &hashed_process_data
);
2500 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2504 convert_time_to_pixels(
2505 time_window
.start_time
,
2510 if(hashed_process_data
->x
.middle
!= new_x
) {
2511 hashed_process_data
->x
.middle
= new_x
;
2512 hashed_process_data
->x
.middle_used
= FALSE
;
2513 hashed_process_data
->x
.middle_marked
= FALSE
;
2523 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2525 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2526 Drawing_t
*drawing
= control_flow_data
->drawing
;
2528 const TimeWindowNotifyData
*time_window_nofify_data
=
2529 ((const TimeWindowNotifyData
*)call_data
);
2531 TimeWindow
*old_time_window
=
2532 time_window_nofify_data
->old_time_window
;
2533 TimeWindow
*new_time_window
=
2534 time_window_nofify_data
->new_time_window
;
2536 /* Update the ruler */
2537 drawing_update_ruler(control_flow_data
->drawing
,
2541 /* Two cases : zoom in/out or scrolling */
2543 /* In order to make sure we can reuse the old drawing, the scale must
2544 * be the same and the new time interval being partly located in the
2545 * currently shown time interval. (reuse is only for scrolling)
2548 g_info("Old time window HOOK : %u, %u to %u, %u",
2549 old_time_window
->start_time
.tv_sec
,
2550 old_time_window
->start_time
.tv_nsec
,
2551 old_time_window
->time_width
.tv_sec
,
2552 old_time_window
->time_width
.tv_nsec
);
2554 g_info("New time window HOOK : %u, %u to %u, %u",
2555 new_time_window
->start_time
.tv_sec
,
2556 new_time_window
->start_time
.tv_nsec
,
2557 new_time_window
->time_width
.tv_sec
,
2558 new_time_window
->time_width
.tv_nsec
);
2560 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2561 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2563 /* Same scale (scrolling) */
2564 g_info("scrolling");
2565 LttTime
*ns
= &new_time_window
->start_time
;
2566 LttTime
*os
= &old_time_window
->start_time
;
2567 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
2568 old_time_window
->time_width
);
2569 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
2570 new_time_window
->time_width
);
2572 //if(ns<os+w && os+w<ns+w)
2573 //if(ns<old_end && os<ns)
2574 if(ltt_time_compare(*ns
, old_end
) == -1
2575 && ltt_time_compare(*os
, *ns
) == -1)
2577 g_info("scrolling near right");
2578 /* Scroll right, keep right part of the screen */
2580 guint width
= control_flow_data
->drawing
->width
;
2581 convert_time_to_pixels(
2588 /* Copy old data to new location */
2589 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2590 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2591 control_flow_data
->drawing
->pixmap
,
2594 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2596 if(drawing
->damage_begin
== drawing
->damage_end
)
2597 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2599 drawing
->damage_begin
= 0;
2601 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2603 /* Clear the data request background, but not SAFETY */
2604 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2605 //control_flow_data->drawing->drawing_area->style->black_gc,
2606 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2608 drawing
->damage_begin
+SAFETY
, 0,
2609 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2610 control_flow_data
->drawing
->height
);
2612 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2614 control_flow_data
->drawing
->width
,
2615 control_flow_data
->drawing
->height
);
2617 /* Get new data for the rest. */
2618 drawing_data_request(control_flow_data
->drawing
,
2619 &control_flow_data
->drawing
->pixmap
,
2620 drawing
->damage_begin
, 0,
2621 drawing
->damage_end
- drawing
->damage_begin
,
2622 control_flow_data
->drawing
->height
);
2625 //if(ns<os && os<ns+w)
2626 //if(ns<os && os<new_end)
2627 if(ltt_time_compare(*ns
,*os
) == -1
2628 && ltt_time_compare(*os
,new_end
) == -1)
2630 g_info("scrolling near left");
2631 /* Scroll left, keep left part of the screen */
2633 guint width
= control_flow_data
->drawing
->width
;
2634 convert_time_to_pixels(
2642 /* Copy old data to new location */
2643 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2644 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2645 control_flow_data
->drawing
->pixmap
,
2650 if(drawing
->damage_begin
== drawing
->damage_end
)
2651 drawing
->damage_end
= x
;
2653 drawing
->damage_end
=
2654 control_flow_data
->drawing
->width
;
2656 drawing
->damage_begin
= 0;
2658 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2659 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2661 drawing
->damage_begin
, 0,
2662 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2663 control_flow_data
->drawing
->height
);
2665 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2667 control_flow_data
->drawing
->width
,
2668 control_flow_data
->drawing
->height
);
2671 /* Get new data for the rest. */
2672 drawing_data_request(control_flow_data
->drawing
,
2673 &control_flow_data
->drawing
->pixmap
,
2674 drawing
->damage_begin
, 0,
2675 drawing
->damage_end
- drawing
->damage_begin
,
2676 control_flow_data
->drawing
->height
);
2679 if(ltt_time_compare(*ns
,*os
) == 0)
2681 g_info("not scrolling");
2683 g_info("scrolling far");
2684 /* Cannot reuse any part of the screen : far jump */
2687 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2688 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2691 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2692 control_flow_data
->drawing
->height
);
2694 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2696 control_flow_data
->drawing
->width
,
2697 control_flow_data
->drawing
->height
);
2699 drawing
->damage_begin
= 0;
2700 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2702 drawing_data_request(control_flow_data
->drawing
,
2703 &control_flow_data
->drawing
->pixmap
,
2705 control_flow_data
->drawing
->width
,
2706 control_flow_data
->drawing
->height
);
2712 /* Different scale (zoom) */
2715 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2716 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2719 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2720 control_flow_data
->drawing
->height
);
2722 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2724 control_flow_data
->drawing
->width
,
2725 control_flow_data
->drawing
->height
);
2727 drawing
->damage_begin
= 0;
2728 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2730 drawing_data_request(control_flow_data
->drawing
,
2731 &control_flow_data
->drawing
->pixmap
,
2733 control_flow_data
->drawing
->width
,
2734 control_flow_data
->drawing
->height
);
2742 gint
traceset_notify(void *hook_data
, void *call_data
)
2744 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2745 Drawing_t
*drawing
= control_flow_data
->drawing
;
2746 GtkWidget
*widget
= drawing
->drawing_area
;
2749 drawing_clear(control_flow_data
->drawing
);
2750 processlist_clear(control_flow_data
->process_list
);
2751 redraw_notify(control_flow_data
, NULL
);
2753 request_background_data(control_flow_data
);
2755 drawing
->damage_begin
= 0;
2756 drawing
->damage_end
= drawing
->width
;
2757 if(drawing
->damage_begin
< drawing
->damage_end
)
2759 drawing_data_request(drawing
,
2761 drawing
->damage_begin
,
2763 drawing
->damage_end
-drawing
->damage_begin
,
2767 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2776 gint
redraw_notify(void *hook_data
, void *call_data
)
2778 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2779 Drawing_t
*drawing
= control_flow_data
->drawing
;
2780 GtkWidget
*widget
= drawing
->drawing_area
;
2782 drawing
->damage_begin
= 0;
2783 drawing
->damage_end
= drawing
->width
;
2785 /* fun feature, to be separated someday... */
2786 drawing_clear(control_flow_data
->drawing
);
2787 processlist_clear(control_flow_data
->process_list
);
2790 gdk_draw_rectangle (drawing
->pixmap
,
2791 widget
->style
->black_gc
,
2794 drawing
->width
+SAFETY
,
2798 if(drawing
->damage_begin
< drawing
->damage_end
)
2800 drawing_data_request(drawing
,
2802 drawing
->damage_begin
,
2804 drawing
->damage_end
-drawing
->damage_begin
,
2808 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2817 gint
continue_notify(void *hook_data
, void *call_data
)
2819 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2820 Drawing_t
*drawing
= control_flow_data
->drawing
;
2821 GtkWidget
*widget
= drawing
->drawing_area
;
2823 //g_assert(widget->allocation.width == drawing->damage_end);
2825 if(drawing
->damage_begin
< drawing
->damage_end
)
2827 drawing_data_request(drawing
,
2829 drawing
->damage_begin
,
2831 drawing
->damage_end
-drawing
->damage_begin
,
2839 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2841 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2842 Drawing_t
*drawing
= control_flow_data
->drawing
;
2844 LttTime current_time
= *((LttTime
*)call_data
);
2846 TimeWindow time_window
=
2847 lttvwindow_get_time_window(control_flow_data
->tab
);
2849 LttTime time_begin
= time_window
.start_time
;
2850 LttTime width
= time_window
.time_width
;
2853 guint64 time_ll
= ltt_time_to_uint64(width
);
2854 time_ll
= time_ll
>> 1; /* divide by two */
2855 half_width
= ltt_time_from_uint64(time_ll
);
2857 LttTime time_end
= ltt_time_add(time_begin
, width
);
2859 LttvTracesetContext
* tsc
=
2860 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2862 LttTime trace_start
= tsc
->time_span
.start_time
;
2863 LttTime trace_end
= tsc
->time_span
.end_time
;
2865 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2866 current_time
.tv_nsec
);
2870 /* If current time is inside time interval, just move the highlight
2873 /* Else, we have to change the time interval. We have to tell it
2874 * to the main window. */
2875 /* The time interval change will take care of placing the current
2876 * time at the center of the visible area, or nearest possible if we are
2877 * at one end of the trace. */
2880 if(ltt_time_compare(current_time
, time_begin
) == -1)
2882 TimeWindow new_time_window
;
2884 if(ltt_time_compare(current_time
,
2885 ltt_time_add(trace_start
,half_width
)) == -1)
2886 time_begin
= trace_start
;
2888 time_begin
= ltt_time_sub(current_time
,half_width
);
2890 new_time_window
.start_time
= time_begin
;
2891 new_time_window
.time_width
= width
;
2893 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2895 else if(ltt_time_compare(current_time
, time_end
) == 1)
2897 TimeWindow new_time_window
;
2899 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2900 time_begin
= ltt_time_sub(trace_end
,width
);
2902 time_begin
= ltt_time_sub(current_time
,half_width
);
2904 new_time_window
.start_time
= time_begin
;
2905 new_time_window
.time_width
= width
;
2907 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2910 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2911 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2919 typedef struct _ClosureData
{
2920 EventsRequest
*events_request
;
2921 LttvTracesetState
*tss
;
2926 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2928 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2929 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2930 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2932 EventsRequest
*events_request
= closure_data
->events_request
;
2933 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2934 Drawing_t
*drawing
= control_flow_data
->drawing
;
2936 LttvTracesetState
*tss
= closure_data
->tss
;
2937 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2939 LttTime evtime
= closure_data
->end_time
;
2940 TimeWindow time_window
=
2941 lttvwindow_get_time_window(control_flow_data
->tab
);
2943 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2944 time_window
.time_width
);
2946 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2947 || ltt_time_compare(evtime
, end_time
) == 1)
2950 guint width
= drawing
->width
;
2953 /* For the process */
2954 /* First, check if the current process is in the state computation
2955 * process list. If it is there, that means we must add it right now and
2956 * draw items from the beginning of the read for it. If it is not
2957 * present, it's a new process and it was not present : it will
2958 * be added after the state update. */
2959 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2961 /* tracefiles[0] is ok here, because we draw for every PID, and
2962 * assume CPU 0 for PID 0 //FIXME */
2963 LttvTracefileState
*tfs
=
2964 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2966 LttvProcessState
*process
;
2967 process
= lttv_state_find_process(tfs
,
2970 if(process
!= NULL
) {
2972 /* Only draw for processes that are currently in the trace states */
2974 guint y
= 0, height
= 0, pl_height
= 0;
2975 ProcessList
*process_list
= control_flow_data
->process_list
;
2976 LttTime birth
= process_info
->birth
;
2978 /* Should be alike when background info is ready */
2979 if(control_flow_data
->background_info_waiting
==0)
2980 g_assert(ltt_time_compare(process
->creation_time
,
2981 process_info
->birth
) == 0);
2982 const gchar
*name
= g_quark_to_string(process
->name
);
2984 /* process HAS to be present */
2985 g_assert(processlist_get_process_pixels(process_list
,
2989 process_info
->trace_num
,
2992 &hashed_process_data
) != 1);
2994 /* Now, the process is in the state hash and our own process hash.
2995 * We definitely can draw the items related to the ending state.
2998 /* Check if the x position is unset. In can have been left unset by
2999 * a draw closure from a after chunk hook. This should never happen,
3000 * because it must be set by before chunk hook to the damage_begin
3003 g_assert(hashed_process_data
->x
.over
!= -1);
3007 convert_time_to_pixels(
3008 time_window
.start_time
,
3014 DrawContext draw_context
;
3016 /* Now create the drawing context that will be used to draw
3017 * items related to the last state. */
3018 draw_context
.drawable
= drawing
->pixmap
;
3019 draw_context
.gc
= drawing
->gc
;
3020 draw_context
.pango_layout
= drawing
->pango_layout
;
3021 draw_context
.drawinfo
.end
.x
= x
;
3023 draw_context
.drawinfo
.y
.over
= y
+1;
3024 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3025 draw_context
.drawinfo
.y
.under
= y
+height
;
3027 draw_context
.drawinfo
.start
.offset
.over
= 0;
3028 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3029 draw_context
.drawinfo
.start
.offset
.under
= 0;
3030 draw_context
.drawinfo
.end
.offset
.over
= 0;
3031 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3032 draw_context
.drawinfo
.end
.offset
.under
= 0;
3034 /* Jump over draw if we are at the same x position */
3035 if(x
== hashed_process_data
->x
.over
)
3039 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3041 PropertiesLine prop_line
= prepare_execmode_line(process
);
3042 draw_line((void*)&prop_line
, (void*)&draw_context
);
3044 hashed_process_data
->x
.over
= x
;
3048 if(x
== hashed_process_data
->x
.middle
&&
3049 hashed_process_data
->x
.middle_used
) {
3050 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3051 /* Draw collision indicator */
3052 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3053 gdk_draw_point(drawing
->pixmap
,
3057 hashed_process_data
->x
.middle_marked
= TRUE
;
3061 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3063 PropertiesLine prop_line
= prepare_s_e_line(process
);
3064 draw_line((void*)&prop_line
, (void*)&draw_context
);
3066 /* become the last x position */
3067 if(x
!= hashed_process_data
->x
.middle
) {
3068 hashed_process_data
->x
.middle
= x
;
3069 /* but don't use the pixel */
3070 hashed_process_data
->x
.middle_used
= FALSE
;
3079 int before_chunk(void *hook_data
, void *call_data
)
3081 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3082 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3084 drawing_chunk_begin(events_request
, tss
);
3089 int before_request(void *hook_data
, void *call_data
)
3091 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3092 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3094 drawing_data_request_begin(events_request
, tss
);
3101 * after request is necessary in addition of after chunk in order to draw
3102 * lines until the end of the screen. after chunk just draws lines until
3109 int after_request(void *hook_data
, void *call_data
)
3111 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3112 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3113 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3114 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3116 ProcessList
*process_list
= control_flow_data
->process_list
;
3117 LttTime end_time
= events_request
->end_time
;
3119 ClosureData closure_data
;
3120 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3121 closure_data
.tss
= tss
;
3122 closure_data
.end_time
= end_time
;
3124 /* Draw last items */
3125 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3126 (void*)&closure_data
);
3128 /* Request expose */
3129 drawing_request_expose(events_request
, tss
, end_time
);
3138 int after_chunk(void *hook_data
, void *call_data
)
3140 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3141 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3142 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3143 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3144 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3147 ProcessList
*process_list
= control_flow_data
->process_list
;
3150 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3151 else /* end of traceset, or position now out of request : end */
3152 end_time
= events_request
->end_time
;
3154 ClosureData closure_data
;
3155 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3156 closure_data
.tss
= tss
;
3157 closure_data
.end_time
= end_time
;
3159 /* Draw last items */
3160 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3161 (void*)&closure_data
);
3163 /* Request expose */
3164 drawing_request_expose(events_request
, tss
, end_time
);