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
= time_window
.end_time
;
399 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
400 || ltt_time_compare(evtime
, end_time
) == 1)
402 guint width
= drawing
->width
;
404 /* we are in a schedchange, before the state update. We must draw the
405 * items corresponding to the state before it changes : now is the right
412 LttField
*f
= ltt_event_field(e
);
414 element
= ltt_field_member(f
,0);
415 pid_out
= ltt_event_get_long_unsigned(e
,element
);
416 element
= ltt_field_member(f
,1);
417 pid_in
= ltt_event_get_long_unsigned(e
,element
);
418 g_debug("out : %u in : %u", pid_out
, pid_in
);
422 /* For the pid_out */
423 /* First, check if the current process is in the state computation
424 * process list. If it is there, that means we must add it right now and
425 * draw items from the beginning of the read for it. If it is not
426 * present, it's a new process and it was not present : it will
427 * be added after the state update. */
428 LttvProcessState
*process
;
429 process
= lttv_state_find_process(tfs
, pid_out
);
431 if(process
!= NULL
) {
432 /* Well, the process_out existed : we must get it in the process hash
433 * or add it, and draw its items.
435 /* Add process to process list (if not present) */
436 guint y
= 0, height
= 0, pl_height
= 0;
437 HashedProcessData
*hashed_process_data
= NULL
;
438 ProcessList
*process_list
= control_flow_data
->process_list
;
439 LttTime birth
= process
->creation_time
;
440 const gchar
*name
= g_quark_to_string(process
->name
);
442 if(processlist_get_process_pixels(process_list
,
446 tfc
->t_context
->index
,
449 &hashed_process_data
) == 1)
451 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
452 /* Process not present */
453 processlist_add(process_list
,
458 tfc
->t_context
->index
,
461 &hashed_process_data
);
462 processlist_get_process_pixels(process_list
,
466 tfc
->t_context
->index
,
469 &hashed_process_data
);
470 drawing_insert_square( drawing
, y
, height
);
473 /* Now, the process is in the state hash and our own process hash.
474 * We definitely can draw the items related to the ending state.
477 /* Check if the x position is unset. In can have been left unset by
478 * a draw closure from a after chunk hook. This should never happen,
479 * because it must be set by before chunk hook to the damage_begin
482 g_assert(hashed_process_data
->x
.middle
!= -1);
485 convert_time_to_pixels(
486 time_window
.start_time
,
493 /* Jump over draw if we are at the same x position */
494 if(x
== hashed_process_data
->x
.middle
&&
495 hashed_process_data
->x
.middle_used
)
497 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
498 /* Draw collision indicator */
499 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
500 gdk_draw_point(drawing
->pixmap
,
504 hashed_process_data
->x
.middle_marked
= TRUE
;
508 DrawContext draw_context
;
510 /* Now create the drawing context that will be used to draw
511 * items related to the last state. */
512 draw_context
.drawable
= drawing
->pixmap
;
513 draw_context
.gc
= drawing
->gc
;
514 draw_context
.pango_layout
= drawing
->pango_layout
;
515 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
516 draw_context
.drawinfo
.end
.x
= x
;
518 draw_context
.drawinfo
.y
.over
= y
+1;
519 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
520 draw_context
.drawinfo
.y
.under
= y
+height
;
522 draw_context
.drawinfo
.start
.offset
.over
= 0;
523 draw_context
.drawinfo
.start
.offset
.middle
= 0;
524 draw_context
.drawinfo
.start
.offset
.under
= 0;
525 draw_context
.drawinfo
.end
.offset
.over
= 0;
526 draw_context
.drawinfo
.end
.offset
.middle
= 0;
527 draw_context
.drawinfo
.end
.offset
.under
= 0;
531 PropertiesLine prop_line
= prepare_s_e_line(process
);
532 draw_line((void*)&prop_line
, (void*)&draw_context
);
535 /* become the last x position */
536 hashed_process_data
->x
.middle
= x
;
537 hashed_process_data
->x
.middle_used
= TRUE
;
538 hashed_process_data
->x
.middle_marked
= FALSE
;
546 /* First, check if the current process is in the state computation
547 * process list. If it is there, that means we must add it right now and
548 * draw items from the beginning of the read for it. If it is not
549 * present, it's a new process and it was not present : it will
550 * be added after the state update. */
551 LttvProcessState
*process
;
552 process
= lttv_state_find_process(tfs
, pid_in
);
554 if(process
!= NULL
) {
555 /* Well, the process_out existed : we must get it in the process hash
556 * or add it, and draw its items.
558 /* Add process to process list (if not present) */
559 guint y
= 0, height
= 0, pl_height
= 0;
560 HashedProcessData
*hashed_process_data
= NULL
;
561 ProcessList
*process_list
= control_flow_data
->process_list
;
562 LttTime birth
= process
->creation_time
;
563 const gchar
*name
= g_quark_to_string(process
->name
);
565 if(processlist_get_process_pixels(process_list
,
569 tfc
->t_context
->index
,
572 &hashed_process_data
) == 1)
574 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
575 /* Process not present */
576 processlist_add(process_list
,
581 tfc
->t_context
->index
,
584 &hashed_process_data
);
585 processlist_get_process_pixels(process_list
,
589 tfc
->t_context
->index
,
592 &hashed_process_data
);
593 drawing_insert_square( drawing
, y
, height
);
596 /* Now, the process is in the state hash and our own process hash.
597 * We definitely can draw the items related to the ending state.
600 /* Check if the x position is unset. In can have been left unset by
601 * a draw closure from a after chunk hook. This should never happen,
602 * because it must be set by before chunk hook to the damage_begin
605 g_assert(hashed_process_data
->x
.middle
!= -1);
609 convert_time_to_pixels(
610 time_window
.start_time
,
617 /* Jump over draw if we are at the same x position */
618 if(x
== hashed_process_data
->x
.middle
&&
619 hashed_process_data
->x
.middle_used
)
621 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
622 /* Draw collision indicator */
623 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
624 gdk_draw_point(drawing
->pixmap
,
628 hashed_process_data
->x
.middle_marked
= TRUE
;
632 DrawContext draw_context
;
634 /* Now create the drawing context that will be used to draw
635 * items related to the last state. */
636 draw_context
.drawable
= drawing
->pixmap
;
637 draw_context
.gc
= drawing
->gc
;
638 draw_context
.pango_layout
= drawing
->pango_layout
;
639 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
640 draw_context
.drawinfo
.end
.x
= x
;
642 draw_context
.drawinfo
.y
.over
= y
+1;
643 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
644 draw_context
.drawinfo
.y
.under
= y
+height
;
646 draw_context
.drawinfo
.start
.offset
.over
= 0;
647 draw_context
.drawinfo
.start
.offset
.middle
= 0;
648 draw_context
.drawinfo
.start
.offset
.under
= 0;
649 draw_context
.drawinfo
.end
.offset
.over
= 0;
650 draw_context
.drawinfo
.end
.offset
.middle
= 0;
651 draw_context
.drawinfo
.end
.offset
.under
= 0;
655 PropertiesLine prop_line
= prepare_s_e_line(process
);
656 draw_line((void*)&prop_line
, (void*)&draw_context
);
660 /* become the last x position */
661 hashed_process_data
->x
.middle
= x
;
662 hashed_process_data
->x
.middle_used
= TRUE
;
663 hashed_process_data
->x
.middle_marked
= FALSE
;
672 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
673 ControlFlowData
*control_flow_data
=
674 (ControlFlowData
*)events_request
->viewer_data
;
675 Tab
*tab
= control_flow_data
->tab
;
677 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
679 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
680 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
685 LttTime evtime
= ltt_event_time(e
);
686 TimeWindow time_window
=
687 lttvwindow_get_time_window(tab
);
689 LttTime end_time
= time_window
.end_time
;
691 //if(time < time_beg || time > time_end) return;
692 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
693 || ltt_time_compare(evtime
, end_time
) == 1)
696 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
698 g_debug("schedchange!");
700 /* Add process to process list (if not present) and get drawing "y" from
701 * process position */
702 guint pid_out
, pid_in
;
703 LttvProcessState
*process_out
, *process_in
;
705 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
707 ProcessList
*process_list
= control_flow_data
->process_list
;
710 LttField
*f
= ltt_event_field(e
);
712 element
= ltt_field_member(f
,0);
713 pid_out
= ltt_event_get_long_unsigned(e
,element
);
714 element
= ltt_field_member(f
,1);
715 pid_in
= ltt_event_get_long_unsigned(e
,element
);
716 g_debug("out : %u in : %u", pid_out
, pid_in
);
719 /* Find process pid_out in the list... */
720 process_out
= lttv_state_find_process(tfs
, pid_out
);
721 if(process_out
== NULL
) return 0;
722 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
724 birth
= process_out
->creation_time
;
725 const gchar
*name
= g_quark_to_string(process_out
->name
);
726 HashedProcessData
*hashed_process_data_out
= NULL
;
728 if(processlist_get_process_pixels(process_list
,
731 tfc
->t_context
->index
,
734 &hashed_process_data_out
) == 1)
736 /* Process not present */
737 processlist_add(process_list
,
740 tfc
->t_context
->index
,
743 &hashed_process_data_out
);
744 g_assert(processlist_get_process_pixels(process_list
,
747 tfc
->t_context
->index
,
750 &hashed_process_data_out
)==0);
751 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
755 /* Find process pid_in in the list... */
756 process_in
= lttv_state_find_process(tfs
, pid_in
);
757 if(process_in
== NULL
) return 0;
758 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
760 birth
= process_in
->creation_time
;
761 name
= g_quark_to_string(process_in
->name
);
762 HashedProcessData
*hashed_process_data_in
= NULL
;
764 if(processlist_get_process_pixels(process_list
,
767 tfc
->t_context
->index
,
770 &hashed_process_data_in
) == 1)
772 /* Process not present */
773 processlist_add(process_list
,
776 tfc
->t_context
->index
,
779 &hashed_process_data_in
);
780 processlist_get_process_pixels(process_list
,
783 tfc
->t_context
->index
,
786 &hashed_process_data_in
);
788 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
793 /* Find pixels corresponding to time of the event. If the time does
794 * not fit in the window, show a warning, not supposed to happend. */
796 guint width
= control_flow_data
->drawing
->width
;
798 LttTime time
= ltt_event_time(e
);
800 LttTime window_end
= ltt_time_add(time_window
.time_width
,
801 time_window
.start_time
);
804 convert_time_to_pixels(
805 time_window
.start_time
,
810 //assert(x <= width);
812 /* draw what represents the event for outgoing process. */
814 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
815 draw_context_out
->current
->modify_over
->x
= x
;
816 draw_context_out
->current
->modify_under
->x
= x
;
817 draw_context_out
->current
->modify_over
->y
= y_out
;
818 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
819 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
820 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
821 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
822 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
823 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
824 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
825 //draw_context_out->gc = widget->style->black_gc;
827 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
828 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
830 /* Draw the line/background of the out process */
831 if(draw_context_out
->previous
->middle
->x
== -1)
833 draw_context_out
->previous
->over
->x
=
834 control_flow_data
->drawing
->damage_begin
;
835 draw_context_out
->previous
->middle
->x
=
836 control_flow_data
->drawing
->damage_begin
;
837 draw_context_out
->previous
->under
->x
=
838 control_flow_data
->drawing
->damage_begin
;
840 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
843 draw_context_out
->current
->middle
->x
= x
;
844 draw_context_out
->current
->over
->x
= x
;
845 draw_context_out
->current
->under
->x
= x
;
846 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
847 draw_context_out
->current
->over
->y
= y_out
;
848 draw_context_out
->current
->under
->y
= y_out
+ height
;
849 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
850 draw_context_out
->previous
->over
->y
= y_out
;
851 draw_context_out
->previous
->under
->y
= y_out
+ height
;
853 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
854 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
856 if(process_out
->state
->s
== LTTV_STATE_RUN
)
858 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
859 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
860 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
862 PropertiesBG prop_bg
;
863 prop_bg
.color
= g_new(GdkColor
,1);
867 prop_bg
.color
->red
= 0x1515;
868 prop_bg
.color
->green
= 0x1515;
869 prop_bg
.color
->blue
= 0x8c8c;
872 prop_bg
.color
->red
= 0x4e4e;
873 prop_bg
.color
->green
= 0xa9a9;
874 prop_bg
.color
->blue
= 0xa4a4;
877 prop_bg
.color
->red
= 0x7a7a;
878 prop_bg
.color
->green
= 0x4a4a;
879 prop_bg
.color
->blue
= 0x8b8b;
882 prop_bg
.color
->red
= 0x8080;
883 prop_bg
.color
->green
= 0x7777;
884 prop_bg
.color
->blue
= 0x4747;
887 prop_bg
.color
->red
= 0xe7e7;
888 prop_bg
.color
->green
= 0xe7e7;
889 prop_bg
.color
->blue
= 0xe7e7;
892 g_debug("calling from draw_event");
893 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
894 g_free(prop_bg
.color
);
895 //gdk_gc_unref(draw_context_out->gc);
898 draw_context_out
->gc
= widget
->style
->black_gc
;
900 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
901 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
902 PropertiesText prop_text_out
;
903 prop_text_out
.foreground
= &colorfg_out
;
904 prop_text_out
.background
= &colorbg_out
;
905 prop_text_out
.size
= 6;
906 prop_text_out
.position
= OVER
;
908 /* color of text : status of the process */
909 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
911 prop_text_out
.foreground
->red
= 0xffff;
912 prop_text_out
.foreground
->green
= 0xffff;
913 prop_text_out
.foreground
->blue
= 0xffff;
915 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
917 prop_text_out
.foreground
->red
= 0x0fff;
918 prop_text_out
.foreground
->green
= 0xffff;
919 prop_text_out
.foreground
->blue
= 0xfff0;
921 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
923 prop_text_out
.foreground
->red
= 0xffff;
924 prop_text_out
.foreground
->green
= 0xffff;
925 prop_text_out
.foreground
->blue
= 0x0000;
927 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
929 prop_text_out
.foreground
->red
= 0xffff;
930 prop_text_out
.foreground
->green
= 0x0000;
931 prop_text_out
.foreground
->blue
= 0xffff;
933 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
935 prop_text_out
.foreground
->red
= 0xffff;
936 prop_text_out
.foreground
->green
= 0x0000;
937 prop_text_out
.foreground
->blue
= 0x0000;
939 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
941 prop_text_out
.foreground
->red
= 0x0000;
942 prop_text_out
.foreground
->green
= 0xffff;
943 prop_text_out
.foreground
->blue
= 0x0000;
947 prop_text_out
.foreground
->red
= 0xffff;
948 prop_text_out
.foreground
->green
= 0xffff;
949 prop_text_out
.foreground
->blue
= 0xffff;
953 /* Print status of the process : U, WF, WC, E, W, R */
954 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
955 prop_text_out
.text
= "U->";
956 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
957 prop_text_out
.text
= "WF->";
958 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
959 prop_text_out
.text
= "WC->";
960 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
961 prop_text_out
.text
= "E->";
962 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
963 prop_text_out
.text
= "W->";
964 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
965 prop_text_out
.text
= "R->";
967 prop_text_out
.text
= "U";
969 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
970 //gdk_gc_unref(draw_context_out->gc);
972 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
973 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
974 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
976 PropertiesLine prop_line_out
;
977 prop_line_out
.color
= g_new(GdkColor
,1);
978 prop_line_out
.line_width
= 2;
979 prop_line_out
.style
= GDK_LINE_SOLID
;
980 prop_line_out
.position
= MIDDLE
;
982 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
984 /* color of line : status of the process */
985 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
987 prop_line_out
.color
->red
= 0xffff;
988 prop_line_out
.color
->green
= 0xffff;
989 prop_line_out
.color
->blue
= 0xffff;
991 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
993 prop_line_out
.color
->red
= 0x0fff;
994 prop_line_out
.color
->green
= 0xffff;
995 prop_line_out
.color
->blue
= 0xfff0;
997 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
999 prop_line_out
.color
->red
= 0xffff;
1000 prop_line_out
.color
->green
= 0xffff;
1001 prop_line_out
.color
->blue
= 0x0000;
1003 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1005 prop_line_out
.color
->red
= 0xffff;
1006 prop_line_out
.color
->green
= 0x0000;
1007 prop_line_out
.color
->blue
= 0xffff;
1009 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1011 prop_line_out
.color
->red
= 0xffff;
1012 prop_line_out
.color
->green
= 0x0000;
1013 prop_line_out
.color
->blue
= 0x0000;
1015 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1017 prop_line_out
.color
->red
= 0x0000;
1018 prop_line_out
.color
->green
= 0xffff;
1019 prop_line_out
.color
->blue
= 0x0000;
1023 prop_line_out
.color
->red
= 0xffff;
1024 prop_line_out
.color
->green
= 0xffff;
1025 prop_line_out
.color
->blue
= 0xffff;
1028 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1029 g_free(prop_line_out
.color
);
1030 //gdk_gc_unref(draw_context_out->gc);
1031 /* Note : finishing line will have to be added when trace read over. */
1033 /* Finally, update the drawing context of the pid_in. */
1035 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1036 draw_context_in
->current
->modify_over
->x
= x
;
1037 draw_context_in
->current
->modify_under
->x
= x
;
1038 draw_context_in
->current
->modify_over
->y
= y_in
;
1039 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1040 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1041 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1042 widget
= control_flow_data
->drawing
->drawing_area
;
1043 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1044 //draw_context_in->gc = widget->style->black_gc;
1045 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1046 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1048 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1049 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1051 /* Draw the line/bg of the in process */
1052 if(draw_context_in
->previous
->middle
->x
== -1)
1054 draw_context_in
->previous
->over
->x
=
1055 control_flow_data
->drawing
->damage_begin
;
1056 draw_context_in
->previous
->middle
->x
=
1057 control_flow_data
->drawing
->damage_begin
;
1058 draw_context_in
->previous
->under
->x
=
1059 control_flow_data
->drawing
->damage_begin
;
1061 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1065 draw_context_in
->current
->middle
->x
= x
;
1066 draw_context_in
->current
->over
->x
= x
;
1067 draw_context_in
->current
->under
->x
= x
;
1068 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1069 draw_context_in
->current
->over
->y
= y_in
;
1070 draw_context_in
->current
->under
->y
= y_in
+ height
;
1071 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1072 draw_context_in
->previous
->over
->y
= y_in
;
1073 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1075 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1076 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1079 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1081 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1082 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1083 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1085 PropertiesBG prop_bg
;
1086 prop_bg
.color
= g_new(GdkColor
,1);
1088 switch(tfc
->index
) {
1090 prop_bg
.color
->red
= 0x1515;
1091 prop_bg
.color
->green
= 0x1515;
1092 prop_bg
.color
->blue
= 0x8c8c;
1095 prop_bg
.color
->red
= 0x4e4e;
1096 prop_bg
.color
->green
= 0xa9a9;
1097 prop_bg
.color
->blue
= 0xa4a4;
1100 prop_bg
.color
->red
= 0x7a7a;
1101 prop_bg
.color
->green
= 0x4a4a;
1102 prop_bg
.color
->blue
= 0x8b8b;
1105 prop_bg
.color
->red
= 0x8080;
1106 prop_bg
.color
->green
= 0x7777;
1107 prop_bg
.color
->blue
= 0x4747;
1110 prop_bg
.color
->red
= 0xe7e7;
1111 prop_bg
.color
->green
= 0xe7e7;
1112 prop_bg
.color
->blue
= 0xe7e7;
1116 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1117 g_free(prop_bg
.color
);
1118 //gdk_gc_unref(draw_context_in->gc);
1121 draw_context_in
->gc
= widget
->style
->black_gc
;
1123 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1124 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1125 PropertiesText prop_text_in
;
1126 prop_text_in
.foreground
= &colorfg_in
;
1127 prop_text_in
.background
= &colorbg_in
;
1128 prop_text_in
.size
= 6;
1129 prop_text_in
.position
= OVER
;
1131 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1132 /* foreground of text : status of the process */
1133 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1135 prop_text_in
.foreground
->red
= 0xffff;
1136 prop_text_in
.foreground
->green
= 0xffff;
1137 prop_text_in
.foreground
->blue
= 0xffff;
1139 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1141 prop_text_in
.foreground
->red
= 0x0fff;
1142 prop_text_in
.foreground
->green
= 0xffff;
1143 prop_text_in
.foreground
->blue
= 0xfff0;
1145 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1147 prop_text_in
.foreground
->red
= 0xffff;
1148 prop_text_in
.foreground
->green
= 0xffff;
1149 prop_text_in
.foreground
->blue
= 0x0000;
1151 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1153 prop_text_in
.foreground
->red
= 0xffff;
1154 prop_text_in
.foreground
->green
= 0x0000;
1155 prop_text_in
.foreground
->blue
= 0xffff;
1157 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1159 prop_text_in
.foreground
->red
= 0xffff;
1160 prop_text_in
.foreground
->green
= 0x0000;
1161 prop_text_in
.foreground
->blue
= 0x0000;
1163 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1165 prop_text_in
.foreground
->red
= 0x0000;
1166 prop_text_in
.foreground
->green
= 0xffff;
1167 prop_text_in
.foreground
->blue
= 0x0000;
1171 prop_text_in
.foreground
->red
= 0xffff;
1172 prop_text_in
.foreground
->green
= 0xffff;
1173 prop_text_in
.foreground
->blue
= 0xffff;
1178 /* Print status of the process : U, WF, WC, E, W, R */
1179 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1180 prop_text_in
.text
= "U->";
1181 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1182 prop_text_in
.text
= "WF->";
1183 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1184 prop_text_in
.text
= "WC->";
1185 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1186 prop_text_in
.text
= "E->";
1187 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1188 prop_text_in
.text
= "W->";
1189 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1190 prop_text_in
.text
= "R->";
1192 prop_text_in
.text
= "U";
1194 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1195 //gdk_gc_unref(draw_context_in->gc);
1197 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1198 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1199 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1201 PropertiesLine prop_line_in
;
1202 prop_line_in
.color
= g_new(GdkColor
,1);
1203 prop_line_in
.line_width
= 2;
1204 prop_line_in
.style
= GDK_LINE_SOLID
;
1205 prop_line_in
.position
= MIDDLE
;
1207 /* color of line : status of the process */
1208 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1210 prop_line_in
.color
->red
= 0xffff;
1211 prop_line_in
.color
->green
= 0xffff;
1212 prop_line_in
.color
->blue
= 0xffff;
1214 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1216 prop_line_in
.color
->red
= 0x0fff;
1217 prop_line_in
.color
->green
= 0xffff;
1218 prop_line_in
.color
->blue
= 0xfff0;
1220 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1222 prop_line_in
.color
->red
= 0xffff;
1223 prop_line_in
.color
->green
= 0xffff;
1224 prop_line_in
.color
->blue
= 0x0000;
1226 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1228 prop_line_in
.color
->red
= 0xffff;
1229 prop_line_in
.color
->green
= 0x0000;
1230 prop_line_in
.color
->blue
= 0xffff;
1232 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1234 prop_line_in
.color
->red
= 0xffff;
1235 prop_line_in
.color
->green
= 0x0000;
1236 prop_line_in
.color
->blue
= 0x0000;
1238 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1240 prop_line_in
.color
->red
= 0x0000;
1241 prop_line_in
.color
->green
= 0xffff;
1242 prop_line_in
.color
->blue
= 0x0000;
1246 prop_line_in
.color
->red
= 0xffff;
1247 prop_line_in
.color
->green
= 0xffff;
1248 prop_line_in
.color
->blue
= 0xffff;
1251 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1252 g_free(prop_line_in
.color
);
1253 //gdk_gc_unref(draw_context_in->gc);
1263 GString
*string
= g_string_new("");;
1264 gboolean field_names
= TRUE
, state
= TRUE
;
1266 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1267 g_string_append_printf(string
,"\n");
1270 g_string_append_printf(string
, " %s",
1271 g_quark_to_string(tfs
->process
->state
->s
));
1274 g_info("%s",string
->str
);
1276 g_string_free(string
, TRUE
);
1278 /* End of text dump */
1283 /* after_schedchange_hook
1285 * The draw after hook is called by the reading API to have a
1286 * particular event drawn on the screen.
1287 * @param hook_data ControlFlowData structure of the viewer.
1288 * @param call_data Event context.
1290 * This function adds items to be drawn in a queue for each process.
1293 int after_schedchange_hook(void *hook_data
, void *call_data
)
1295 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1296 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1298 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1300 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1301 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1306 LttTime evtime
= ltt_event_time(e
);
1307 TimeWindow time_window
=
1308 lttvwindow_get_time_window(control_flow_data
->tab
);
1310 LttTime end_time
= time_window
.end_time
;
1312 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1313 || ltt_time_compare(evtime
, end_time
) == 1)
1316 guint width
= control_flow_data
->drawing
->width
;
1318 /* Add process to process list (if not present) */
1319 LttvProcessState
*process_out
, *process_in
;
1321 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1322 HashedProcessData
*hashed_process_data_in
= NULL
;
1324 ProcessList
*process_list
= control_flow_data
->process_list
;
1329 LttField
*f
= ltt_event_field(e
);
1331 element
= ltt_field_member(f
,0);
1332 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1333 element
= ltt_field_member(f
,1);
1334 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1335 g_debug("out : %u in : %u", pid_out
, pid_in
);
1339 /* Find process pid_in in the list... */
1340 process_in
= lttv_state_find_process(tfs
, pid_in
);
1341 /* It should exist, because we are after the state update. */
1342 g_assert(process_in
!= NULL
);
1344 birth
= process_in
->creation_time
;
1345 const gchar
*name
= g_quark_to_string(process_in
->name
);
1347 if(processlist_get_process_pixels(process_list
,
1349 process_in
->last_cpu
,
1351 tfc
->t_context
->index
,
1354 &hashed_process_data_in
) == 1)
1356 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1357 /* Process not present */
1358 processlist_add(process_list
,
1360 process_in
->last_cpu
,
1363 tfc
->t_context
->index
,
1366 &hashed_process_data_in
);
1367 processlist_get_process_pixels(process_list
,
1369 process_in
->last_cpu
,
1371 tfc
->t_context
->index
,
1374 &hashed_process_data_in
);
1375 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1380 convert_time_to_pixels(
1381 time_window
.start_time
,
1387 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1388 hashed_process_data_in
->x
.middle
= new_x
;
1389 hashed_process_data_in
->x
.middle_used
= FALSE
;
1390 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1400 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1401 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1403 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1405 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1406 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1412 LttTime evtime
= ltt_event_time(e
);
1413 TimeWindow time_window
=
1414 lttvwindow_get_time_window(control_flow_data
->tab
);
1416 LttTime end_time
= time_window
.end_time
;
1418 //if(time < time_beg || time > time_end) return;
1419 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1420 || ltt_time_compare(evtime
, end_time
) == 1)
1424 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1426 g_debug("schedchange!");
1428 /* Add process to process list (if not present) and get drawing "y" from
1429 * process position */
1430 guint pid_out
, pid_in
;
1431 LttvProcessState
*process_out
, *process_in
;
1433 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1435 ProcessList
*process_list
= control_flow_data
->process_list
;
1438 LttField
*f
= ltt_event_field(e
);
1440 element
= ltt_field_member(f
,0);
1441 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1442 element
= ltt_field_member(f
,1);
1443 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1444 //g_debug("out : %u in : %u", pid_out, pid_in);
1447 /* Find process pid_out in the list... */
1448 process_out
= lttv_state_find_process(tfs
, pid_out
);
1449 if(process_out
== NULL
) return 0;
1450 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1452 birth
= process_out
->creation_time
;
1453 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1454 HashedProcessData
*hashed_process_data_out
= NULL
;
1456 if(processlist_get_process_pixels(process_list
,
1459 tfc
->t_context
->index
,
1462 &hashed_process_data_out
) == 1)
1464 /* Process not present */
1465 processlist_add(process_list
,
1468 tfc
->t_context
->index
,
1471 &hashed_process_data_out
);
1472 processlist_get_process_pixels(process_list
,
1475 tfc
->t_context
->index
,
1478 &hashed_process_data_out
);
1479 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1484 /* Find process pid_in in the list... */
1485 process_in
= lttv_state_find_process(tfs
, pid_in
);
1486 if(process_in
== NULL
) return 0;
1487 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1489 birth
= process_in
->creation_time
;
1490 name
= strdup(g_quark_to_string(process_in
->name
));
1491 HashedProcessData
*hashed_process_data_in
= NULL
;
1493 if(processlist_get_process_pixels(process_list
,
1496 tfc
->t_context
->index
,
1499 &hashed_process_data_in
) == 1)
1501 /* Process not present */
1502 processlist_add(process_list
,
1505 tfc
->t_context
->index
,
1508 &hashed_process_data_in
);
1509 processlist_get_process_pixels(process_list
,
1512 tfc
->t_context
->index
,
1515 &hashed_process_data_in
);
1517 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1522 /* Find pixels corresponding to time of the event. If the time does
1523 * not fit in the window, show a warning, not supposed to happend. */
1525 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1527 //LttTime time = ltt_event_time(e);
1529 //LttTime window_end = ltt_time_add(time_window->time_width,
1530 // time_window->start_time);
1533 //convert_time_to_pixels(
1534 // time_window->start_time,
1540 //assert(x <= width);
1542 /* draw what represents the event for outgoing process. */
1544 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1545 //draw_context_out->current->modify_over->x = x;
1546 draw_context_out
->current
->modify_over
->y
= y_out
;
1547 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1548 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1549 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1550 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1551 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1553 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1554 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1556 /*if(process_out->state->s == LTTV_STATE_RUN)
1558 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1559 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1560 PropertiesBG prop_bg;
1561 prop_bg.color = g_new(GdkColor,1);
1563 prop_bg.color->red = 0xffff;
1564 prop_bg.color->green = 0xffff;
1565 prop_bg.color->blue = 0xffff;
1567 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1568 g_free(prop_bg.color);
1569 gdk_gc_unref(draw_context_out->gc);
1572 draw_context_out
->gc
= widget
->style
->black_gc
;
1574 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1575 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1576 PropertiesText prop_text_out
;
1577 prop_text_out
.foreground
= &colorfg_out
;
1578 prop_text_out
.background
= &colorbg_out
;
1579 prop_text_out
.size
= 6;
1580 prop_text_out
.position
= OVER
;
1582 /* color of text : status of the process */
1583 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1585 prop_text_out
.foreground
->red
= 0xffff;
1586 prop_text_out
.foreground
->green
= 0xffff;
1587 prop_text_out
.foreground
->blue
= 0xffff;
1589 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1591 prop_text_out
.foreground
->red
= 0x0fff;
1592 prop_text_out
.foreground
->green
= 0xffff;
1593 prop_text_out
.foreground
->blue
= 0xfff0;
1595 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1597 prop_text_out
.foreground
->red
= 0xffff;
1598 prop_text_out
.foreground
->green
= 0xffff;
1599 prop_text_out
.foreground
->blue
= 0x0000;
1601 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1603 prop_text_out
.foreground
->red
= 0xffff;
1604 prop_text_out
.foreground
->green
= 0x0000;
1605 prop_text_out
.foreground
->blue
= 0xffff;
1607 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1609 prop_text_out
.foreground
->red
= 0xffff;
1610 prop_text_out
.foreground
->green
= 0x0000;
1611 prop_text_out
.foreground
->blue
= 0x0000;
1613 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1615 prop_text_out
.foreground
->red
= 0x0000;
1616 prop_text_out
.foreground
->green
= 0xffff;
1617 prop_text_out
.foreground
->blue
= 0x0000;
1621 prop_text_out
.foreground
->red
= 0xffff;
1622 prop_text_out
.foreground
->green
= 0xffff;
1623 prop_text_out
.foreground
->blue
= 0xffff;
1626 /* Print status of the process : U, WF, WC, E, W, R */
1627 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1628 prop_text_out
.text
= "U";
1629 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1630 prop_text_out
.text
= "WF";
1631 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1632 prop_text_out
.text
= "WC";
1633 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1634 prop_text_out
.text
= "E";
1635 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1636 prop_text_out
.text
= "W";
1637 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1638 prop_text_out
.text
= "R";
1640 prop_text_out
.text
= "U";
1642 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1644 //gdk_gc_unref(draw_context_out->gc);
1646 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1647 draw_context_out
->current
->over
->y
= y_out
;
1648 draw_context_out
->current
->under
->y
= y_out
+height
;
1649 draw_context_out
->current
->status
= process_out
->state
->s
;
1651 /* for pid_out : remove previous, Prev = current, new current (default) */
1652 g_free(draw_context_out
->previous
->modify_under
);
1653 g_free(draw_context_out
->previous
->modify_middle
);
1654 g_free(draw_context_out
->previous
->modify_over
);
1655 g_free(draw_context_out
->previous
->under
);
1656 g_free(draw_context_out
->previous
->middle
);
1657 g_free(draw_context_out
->previous
->over
);
1658 g_free(draw_context_out
->previous
);
1660 draw_context_out
->previous
= draw_context_out
->current
;
1662 draw_context_out
->current
= g_new(DrawInfo
,1);
1663 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1664 draw_context_out
->current
->over
->x
= -1;
1665 draw_context_out
->current
->over
->y
= -1;
1666 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1667 draw_context_out
->current
->middle
->x
= -1;
1668 draw_context_out
->current
->middle
->y
= -1;
1669 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1670 draw_context_out
->current
->under
->x
= -1;
1671 draw_context_out
->current
->under
->y
= -1;
1672 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1673 draw_context_out
->current
->modify_over
->x
= -1;
1674 draw_context_out
->current
->modify_over
->y
= -1;
1675 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1676 draw_context_out
->current
->modify_middle
->x
= -1;
1677 draw_context_out
->current
->modify_middle
->y
= -1;
1678 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1679 draw_context_out
->current
->modify_under
->x
= -1;
1680 draw_context_out
->current
->modify_under
->y
= -1;
1681 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1683 /* Finally, update the drawing context of the pid_in. */
1685 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1686 //draw_context_in->current->modify_over->x = x;
1687 draw_context_in
->current
->modify_over
->y
= y_in
;
1688 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1689 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1690 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1691 widget
= control_flow_data
->drawing
->drawing_area
;
1692 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1694 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1695 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1697 /*if(process_in->state->s == LTTV_STATE_RUN)
1699 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1700 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1701 PropertiesBG prop_bg;
1702 prop_bg.color = g_new(GdkColor,1);
1704 prop_bg.color->red = 0xffff;
1705 prop_bg.color->green = 0xffff;
1706 prop_bg.color->blue = 0xffff;
1708 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1709 g_free(prop_bg.color);
1710 gdk_gc_unref(draw_context_in->gc);
1713 draw_context_in
->gc
= widget
->style
->black_gc
;
1715 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1716 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1717 PropertiesText prop_text_in
;
1718 prop_text_in
.foreground
= &colorfg_in
;
1719 prop_text_in
.background
= &colorbg_in
;
1720 prop_text_in
.size
= 6;
1721 prop_text_in
.position
= OVER
;
1723 /* foreground of text : status of the process */
1724 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1726 prop_text_in
.foreground
->red
= 0xffff;
1727 prop_text_in
.foreground
->green
= 0xffff;
1728 prop_text_in
.foreground
->blue
= 0xffff;
1730 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1732 prop_text_in
.foreground
->red
= 0x0fff;
1733 prop_text_in
.foreground
->green
= 0xffff;
1734 prop_text_in
.foreground
->blue
= 0xfff0;
1736 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1738 prop_text_in
.foreground
->red
= 0xffff;
1739 prop_text_in
.foreground
->green
= 0xffff;
1740 prop_text_in
.foreground
->blue
= 0x0000;
1742 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1744 prop_text_in
.foreground
->red
= 0xffff;
1745 prop_text_in
.foreground
->green
= 0x0000;
1746 prop_text_in
.foreground
->blue
= 0xffff;
1748 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1750 prop_text_in
.foreground
->red
= 0xffff;
1751 prop_text_in
.foreground
->green
= 0x0000;
1752 prop_text_in
.foreground
->blue
= 0x0000;
1754 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1756 prop_text_in
.foreground
->red
= 0x0000;
1757 prop_text_in
.foreground
->green
= 0xffff;
1758 prop_text_in
.foreground
->blue
= 0x0000;
1762 prop_text_in
.foreground
->red
= 0xffff;
1763 prop_text_in
.foreground
->green
= 0xffff;
1764 prop_text_in
.foreground
->blue
= 0xffff;
1768 /* Print status of the process : U, WF, WC, E, W, R */
1769 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1770 prop_text_in
.text
= "U";
1771 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1772 prop_text_in
.text
= "WF";
1773 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1774 prop_text_in
.text
= "WC";
1775 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1776 prop_text_in
.text
= "E";
1777 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1778 prop_text_in
.text
= "W";
1779 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1780 prop_text_in
.text
= "R";
1782 prop_text_in
.text
= "U";
1784 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1787 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1790 prop_text_in
.foreground
= &colorfg_in
;
1791 prop_text_in
.background
= &colorbg_in
;
1792 prop_text_in
.foreground
->red
= 0xffff;
1793 prop_text_in
.foreground
->green
= 0xffff;
1794 prop_text_in
.foreground
->blue
= 0xffff;
1795 prop_text_in
.size
= 6;
1796 prop_text_in
.position
= UNDER
;
1798 prop_text_in
.text
= g_new(gchar
, 260);
1799 strcpy(prop_text_in
.text
, "CPU ");
1800 snprintf(tmp
, 255, "%u", tfc
->index
);
1801 strcat(prop_text_in
.text
, tmp
);
1803 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1804 g_free(prop_text_in
.text
);
1808 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1809 draw_context_in
->current
->over
->y
= y_in
;
1810 draw_context_in
->current
->under
->y
= y_in
+height
;
1811 draw_context_in
->current
->status
= process_in
->state
->s
;
1813 /* for pid_in : remove previous, Prev = current, new current (default) */
1814 g_free(draw_context_in
->previous
->modify_under
);
1815 g_free(draw_context_in
->previous
->modify_middle
);
1816 g_free(draw_context_in
->previous
->modify_over
);
1817 g_free(draw_context_in
->previous
->under
);
1818 g_free(draw_context_in
->previous
->middle
);
1819 g_free(draw_context_in
->previous
->over
);
1820 g_free(draw_context_in
->previous
);
1822 draw_context_in
->previous
= draw_context_in
->current
;
1824 draw_context_in
->current
= g_new(DrawInfo
,1);
1825 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1826 draw_context_in
->current
->over
->x
= -1;
1827 draw_context_in
->current
->over
->y
= -1;
1828 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1829 draw_context_in
->current
->middle
->x
= -1;
1830 draw_context_in
->current
->middle
->y
= -1;
1831 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1832 draw_context_in
->current
->under
->x
= -1;
1833 draw_context_in
->current
->under
->y
= -1;
1834 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1835 draw_context_in
->current
->modify_over
->x
= -1;
1836 draw_context_in
->current
->modify_over
->y
= -1;
1837 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1838 draw_context_in
->current
->modify_middle
->x
= -1;
1839 draw_context_in
->current
->modify_middle
->y
= -1;
1840 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1841 draw_context_in
->current
->modify_under
->x
= -1;
1842 draw_context_in
->current
->modify_under
->y
= -1;
1843 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1852 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1854 PropertiesLine prop_line
;
1855 prop_line
.line_width
= 1;
1856 prop_line
.style
= GDK_LINE_SOLID
;
1858 //GdkColormap *colormap = gdk_colormap_get_system();
1860 /* color of line : execution mode of the process */
1861 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1862 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1863 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1864 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1865 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1866 prop_line
.color
= drawing_colors
[COL_TRAP
];
1867 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1868 prop_line
.color
= drawing_colors
[COL_IRQ
];
1869 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1870 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1872 prop_line
.color
= drawing_colors
[COL_WHITE
];
1874 //gdk_colormap_alloc_color(colormap,
1885 /* before_execmode_hook
1887 * This function basically draw lines and icons. Two types of lines are drawn :
1888 * one small (3 pixels?) representing the state of the process and the second
1889 * type is thicker (10 pixels?) representing on which CPU a process is running
1890 * (and this only in running state).
1892 * Extremums of the lines :
1893 * x_min : time of the last event context for this process kept in memory.
1894 * x_max : time of the current event.
1895 * y : middle of the process in the process list. The process is found in the
1896 * list, therefore is it's position in pixels.
1898 * The choice of lines'color is defined by the context of the last event for this
1903 int before_execmode_hook(void *hook_data
, void *call_data
)
1905 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1906 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1907 Drawing_t
*drawing
= control_flow_data
->drawing
;
1909 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1911 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1912 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1917 LttTime evtime
= ltt_event_time(e
);
1918 TimeWindow time_window
=
1919 lttvwindow_get_time_window(control_flow_data
->tab
);
1921 LttTime end_time
= time_window
.end_time
;
1923 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1924 || ltt_time_compare(evtime
, end_time
) == 1)
1927 guint width
= drawing
->width
;
1929 /* we are in a execmode, before the state update. We must draw the
1930 * items corresponding to the state before it changes : now is the right
1934 LttvProcessState
*process
= tfs
->process
;
1935 g_assert(process
!= NULL
);
1937 guint pid
= process
->pid
;
1939 /* Well, the process_out existed : we must get it in the process hash
1940 * or add it, and draw its items.
1942 /* Add process to process list (if not present) */
1943 guint y
= 0, height
= 0, pl_height
= 0;
1944 HashedProcessData
*hashed_process_data
= NULL
;
1945 ProcessList
*process_list
= control_flow_data
->process_list
;
1946 LttTime birth
= process
->creation_time
;
1947 const gchar
*name
= g_quark_to_string(process
->name
);
1949 if(processlist_get_process_pixels(process_list
,
1953 tfc
->t_context
->index
,
1956 &hashed_process_data
) == 1)
1958 g_assert(pid
== 0 || pid
!= process
->ppid
);
1959 /* Process not present */
1960 processlist_add(process_list
,
1965 tfc
->t_context
->index
,
1968 &hashed_process_data
);
1969 processlist_get_process_pixels(process_list
,
1973 tfc
->t_context
->index
,
1976 &hashed_process_data
);
1977 drawing_insert_square( drawing
, y
, height
);
1980 /* Now, the process is in the state hash and our own process hash.
1981 * We definitely can draw the items related to the ending state.
1984 /* Check if the x position is unset. In can have been left unset by
1985 * a draw closure from a after chunk hook. This should never happen,
1986 * because it must be set by before chunk hook to the damage_begin
1989 g_assert(hashed_process_data
->x
.over
!= -1);
1993 convert_time_to_pixels(
1994 time_window
.start_time
,
2001 /* Jump over draw if we are at the same x position */
2002 if(x
== hashed_process_data
->x
.middle
&&
2003 hashed_process_data
->x
.middle_used
)
2005 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2006 /* Draw collision indicator */
2007 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2008 gdk_draw_point(drawing
->pixmap
,
2012 hashed_process_data
->x
.middle_marked
= TRUE
;
2017 DrawContext draw_context
;
2018 /* Now create the drawing context that will be used to draw
2019 * items related to the last state. */
2020 draw_context
.drawable
= drawing
->pixmap
;
2021 draw_context
.gc
= drawing
->gc
;
2022 draw_context
.pango_layout
= drawing
->pango_layout
;
2023 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2024 draw_context
.drawinfo
.end
.x
= x
;
2026 draw_context
.drawinfo
.y
.over
= y
+1;
2027 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2028 draw_context
.drawinfo
.y
.under
= y
+height
;
2030 draw_context
.drawinfo
.start
.offset
.over
= 0;
2031 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2032 draw_context
.drawinfo
.start
.offset
.under
= 0;
2033 draw_context
.drawinfo
.end
.offset
.over
= 0;
2034 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2035 draw_context
.drawinfo
.end
.offset
.under
= 0;
2039 PropertiesLine prop_line
= prepare_s_e_line(process
);
2040 draw_line((void*)&prop_line
, (void*)&draw_context
);
2043 /* become the last x position */
2044 hashed_process_data
->x
.middle
= x
;
2045 hashed_process_data
->x
.middle_used
= TRUE
;
2046 hashed_process_data
->x
.middle_marked
= FALSE
;
2053 /* after_execmode_hook
2055 * The draw after hook is called by the reading API to have a
2056 * particular event drawn on the screen.
2057 * @param hook_data ControlFlowData structure of the viewer.
2058 * @param call_data Event context.
2060 * This function adds items to be drawn in a queue for each process.
2063 int after_execmode_hook(void *hook_data
, void *call_data
)
2065 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2066 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2068 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2070 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2071 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2076 LttTime evtime
= ltt_event_time(e
);
2077 TimeWindow time_window
=
2078 lttvwindow_get_time_window(control_flow_data
->tab
);
2080 LttTime end_time
= time_window
.end_time
;
2082 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2083 || ltt_time_compare(evtime
, end_time
) == 1)
2086 guint width
= control_flow_data
->drawing
->width
;
2088 /* Add process to process list (if not present) */
2089 LttvProcessState
*process
;
2091 guint y
= 0, height
= 0, pl_height
= 0;
2092 HashedProcessData
*hashed_process_data
= NULL
;
2094 ProcessList
*process_list
= control_flow_data
->process_list
;
2096 /* Find process pid_in in the list... */
2097 process
= tfs
->process
;
2098 /* It should exist, because we are after the state update. */
2099 g_assert(process
!= NULL
);
2101 guint pid
= process
->pid
;
2103 birth
= process
->creation_time
;
2104 const gchar
*name
= g_quark_to_string(process
->name
);
2106 if(processlist_get_process_pixels(process_list
,
2110 tfc
->t_context
->index
,
2113 &hashed_process_data
) == 1)
2115 g_assert(pid
== 0 || pid
!= process
->ppid
);
2116 /* Process not present */
2117 processlist_add(process_list
,
2122 tfc
->t_context
->index
,
2125 &hashed_process_data
);
2126 processlist_get_process_pixels(process_list
,
2130 tfc
->t_context
->index
,
2133 &hashed_process_data
);
2134 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2139 convert_time_to_pixels(
2140 time_window
.start_time
,
2146 if(hashed_process_data
->x
.middle
!= new_x
) {
2147 hashed_process_data
->x
.middle
= new_x
;
2148 hashed_process_data
->x
.middle_used
= FALSE
;
2149 hashed_process_data
->x
.middle_marked
= FALSE
;
2157 /* before_process_hook
2159 * Draw lines for process event.
2161 * @param hook_data ControlFlowData structure of the viewer.
2162 * @param call_data Event context.
2164 * This function adds items to be drawn in a queue for each process.
2167 int before_process_hook(void *hook_data
, void *call_data
)
2169 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2170 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2171 Drawing_t
*drawing
= control_flow_data
->drawing
;
2173 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2175 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2176 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2181 LttTime evtime
= ltt_event_time(e
);
2182 TimeWindow time_window
=
2183 lttvwindow_get_time_window(control_flow_data
->tab
);
2185 LttTime end_time
= time_window
.end_time
;
2187 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2188 || ltt_time_compare(evtime
, end_time
) == 1)
2191 guint width
= control_flow_data
->drawing
->width
;
2195 LttField
*f
= ltt_event_field(e
);
2197 element
= ltt_field_member(f
,0);
2198 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2201 if(sub_id
== 3) { /* exit */
2203 /* Add process to process list (if not present) */
2204 LttvProcessState
*process
= tfs
->process
;
2205 guint pid
= process
->pid
;
2207 guint y
= 0, height
= 0, pl_height
= 0;
2208 HashedProcessData
*hashed_process_data
= NULL
;
2210 ProcessList
*process_list
= control_flow_data
->process_list
;
2212 g_assert(process
!= NULL
);
2214 birth
= process
->creation_time
;
2215 const gchar
*name
= g_quark_to_string(process
->name
);
2217 if(processlist_get_process_pixels(process_list
,
2221 tfc
->t_context
->index
,
2224 &hashed_process_data
) == 1)
2226 g_assert(pid
== 0 || pid
!= process
->ppid
);
2227 /* Process not present */
2228 processlist_add(process_list
,
2233 tfc
->t_context
->index
,
2236 &hashed_process_data
);
2237 processlist_get_process_pixels(process_list
,
2241 tfc
->t_context
->index
,
2244 &hashed_process_data
);
2245 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2248 /* Now, the process is in the state hash and our own process hash.
2249 * We definitely can draw the items related to the ending state.
2252 /* Check if the x position is unset. In can have been left unset by
2253 * a draw closure from a after chunk hook. This should never happen,
2254 * because it must be set by before chunk hook to the damage_begin
2257 g_assert(hashed_process_data
->x
.over
!= -1);
2261 convert_time_to_pixels(
2262 time_window
.start_time
,
2269 /* Jump over draw if we are at the same x position */
2270 if(x
== hashed_process_data
->x
.middle
&&
2271 hashed_process_data
->x
.middle_used
)
2273 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2274 /* Draw collision indicator */
2275 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2276 gdk_draw_point(drawing
->pixmap
,
2280 hashed_process_data
->x
.middle_marked
= TRUE
;
2284 DrawContext draw_context
;
2286 /* Now create the drawing context that will be used to draw
2287 * items related to the last state. */
2288 draw_context
.drawable
= drawing
->pixmap
;
2289 draw_context
.gc
= drawing
->gc
;
2290 draw_context
.pango_layout
= drawing
->pango_layout
;
2291 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2292 draw_context
.drawinfo
.end
.x
= x
;
2294 draw_context
.drawinfo
.y
.over
= y
+1;
2295 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2296 draw_context
.drawinfo
.y
.under
= y
+height
;
2298 draw_context
.drawinfo
.start
.offset
.over
= 0;
2299 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2300 draw_context
.drawinfo
.start
.offset
.under
= 0;
2301 draw_context
.drawinfo
.end
.offset
.over
= 0;
2302 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2303 draw_context
.drawinfo
.end
.offset
.under
= 0;
2307 PropertiesLine prop_line
= prepare_s_e_line(process
);
2308 draw_line((void*)&prop_line
, (void*)&draw_context
);
2311 /* become the last x position */
2312 hashed_process_data
->x
.middle
= x
;
2313 hashed_process_data
->x
.middle_used
= TRUE
;
2314 hashed_process_data
->x
.middle_marked
= FALSE
;
2328 /* after_process_hook
2330 * Create the processlist entry for the child process. Put the last
2331 * position in x at the current time value.
2333 * @param hook_data ControlFlowData structure of the viewer.
2334 * @param call_data Event context.
2336 * This function adds items to be drawn in a queue for each process.
2339 int after_process_hook(void *hook_data
, void *call_data
)
2341 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2342 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2344 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2346 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2347 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2352 LttTime evtime
= ltt_event_time(e
);
2353 TimeWindow time_window
=
2354 lttvwindow_get_time_window(control_flow_data
->tab
);
2356 LttTime end_time
= time_window
.end_time
;
2358 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2359 || ltt_time_compare(evtime
, end_time
) == 1)
2362 guint width
= control_flow_data
->drawing
->width
;
2367 LttField
*f
= ltt_event_field(e
);
2369 element
= ltt_field_member(f
,0);
2370 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2371 element
= ltt_field_member(f
,1);
2372 param1
= ltt_event_get_long_unsigned(e
,element
);
2375 if(sub_id
== 2) { /* fork */
2377 guint child_pid
= param1
;
2378 /* Add process to process list (if not present) */
2379 LttvProcessState
*process_child
;
2381 guint y_child
= 0, height
= 0, pl_height
= 0;
2382 HashedProcessData
*hashed_process_data_child
= NULL
;
2384 ProcessList
*process_list
= control_flow_data
->process_list
;
2386 /* Find child in the list... */
2387 process_child
= lttv_state_find_process(tfs
, child_pid
);
2388 /* It should exist, because we are after the state update. */
2389 g_assert(process_child
!= NULL
);
2391 birth
= process_child
->creation_time
;
2392 const gchar
*name
= g_quark_to_string(process_child
->name
);
2394 if(processlist_get_process_pixels(process_list
,
2396 process_child
->last_cpu
,
2398 tfc
->t_context
->index
,
2401 &hashed_process_data_child
) == 1)
2403 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2404 /* Process not present */
2405 processlist_add(process_list
,
2407 process_child
->last_cpu
,
2408 process_child
->ppid
,
2410 tfc
->t_context
->index
,
2413 &hashed_process_data_child
);
2414 processlist_get_process_pixels(process_list
,
2416 process_child
->last_cpu
,
2418 tfc
->t_context
->index
,
2421 &hashed_process_data_child
);
2422 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2426 convert_time_to_pixels(
2427 time_window
.start_time
,
2433 if(hashed_process_data_child
->x
.over
!= new_x
) {
2434 hashed_process_data_child
->x
.over
= new_x
;
2435 hashed_process_data_child
->x
.over_used
= FALSE
;
2436 hashed_process_data_child
->x
.over_marked
= FALSE
;
2438 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2439 hashed_process_data_child
->x
.middle
= new_x
;
2440 hashed_process_data_child
->x
.middle_used
= FALSE
;
2441 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2443 if(hashed_process_data_child
->x
.under
!= new_x
) {
2444 hashed_process_data_child
->x
.under
= new_x
;
2445 hashed_process_data_child
->x
.under_used
= FALSE
;
2446 hashed_process_data_child
->x
.under_marked
= FALSE
;
2449 } else if(sub_id
== 3) { /* exit */
2451 /* Add process to process list (if not present) */
2452 LttvProcessState
*process
= tfs
->process
;
2453 guint pid
= process
->pid
;
2455 guint y
= 0, height
= 0, pl_height
= 0;
2456 HashedProcessData
*hashed_process_data
= NULL
;
2458 ProcessList
*process_list
= control_flow_data
->process_list
;
2460 /* It should exist, because we are after the state update. */
2461 g_assert(process
!= NULL
);
2463 birth
= process
->creation_time
;
2464 const gchar
*name
= g_quark_to_string(process
->name
);
2466 if(processlist_get_process_pixels(process_list
,
2470 tfc
->t_context
->index
,
2473 &hashed_process_data
) == 1)
2475 g_assert(pid
== 0 || pid
!= process
->ppid
);
2476 /* Process not present */
2477 processlist_add(process_list
,
2482 tfc
->t_context
->index
,
2485 &hashed_process_data
);
2486 processlist_get_process_pixels(process_list
,
2490 tfc
->t_context
->index
,
2493 &hashed_process_data
);
2494 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2498 convert_time_to_pixels(
2499 time_window
.start_time
,
2504 if(hashed_process_data
->x
.middle
!= new_x
) {
2505 hashed_process_data
->x
.middle
= new_x
;
2506 hashed_process_data
->x
.middle_used
= FALSE
;
2507 hashed_process_data
->x
.middle_marked
= FALSE
;
2517 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2519 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2520 Drawing_t
*drawing
= control_flow_data
->drawing
;
2522 const TimeWindowNotifyData
*time_window_nofify_data
=
2523 ((const TimeWindowNotifyData
*)call_data
);
2525 TimeWindow
*old_time_window
=
2526 time_window_nofify_data
->old_time_window
;
2527 TimeWindow
*new_time_window
=
2528 time_window_nofify_data
->new_time_window
;
2530 /* Update the ruler */
2531 drawing_update_ruler(control_flow_data
->drawing
,
2535 /* Two cases : zoom in/out or scrolling */
2537 /* In order to make sure we can reuse the old drawing, the scale must
2538 * be the same and the new time interval being partly located in the
2539 * currently shown time interval. (reuse is only for scrolling)
2542 g_info("Old time window HOOK : %u, %u to %u, %u",
2543 old_time_window
->start_time
.tv_sec
,
2544 old_time_window
->start_time
.tv_nsec
,
2545 old_time_window
->time_width
.tv_sec
,
2546 old_time_window
->time_width
.tv_nsec
);
2548 g_info("New time window HOOK : %u, %u to %u, %u",
2549 new_time_window
->start_time
.tv_sec
,
2550 new_time_window
->start_time
.tv_nsec
,
2551 new_time_window
->time_width
.tv_sec
,
2552 new_time_window
->time_width
.tv_nsec
);
2554 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2555 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2557 /* Same scale (scrolling) */
2558 g_info("scrolling");
2559 LttTime
*ns
= &new_time_window
->start_time
;
2560 LttTime
*os
= &old_time_window
->start_time
;
2561 LttTime old_end
= old_time_window
->end_time
;
2562 LttTime new_end
= new_time_window
->end_time
;
2564 //if(ns<os+w && os+w<ns+w)
2565 //if(ns<old_end && os<ns)
2566 if(ltt_time_compare(*ns
, old_end
) == -1
2567 && ltt_time_compare(*os
, *ns
) == -1)
2569 g_info("scrolling near right");
2570 /* Scroll right, keep right part of the screen */
2572 guint width
= control_flow_data
->drawing
->width
;
2573 convert_time_to_pixels(
2580 /* Copy old data to new location */
2581 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2582 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2583 control_flow_data
->drawing
->pixmap
,
2586 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2588 if(drawing
->damage_begin
== drawing
->damage_end
)
2589 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2591 drawing
->damage_begin
= 0;
2593 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2595 /* Clear the data request background, but not SAFETY */
2596 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2597 //control_flow_data->drawing->drawing_area->style->black_gc,
2598 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2600 drawing
->damage_begin
+SAFETY
, 0,
2601 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2602 control_flow_data
->drawing
->height
);
2604 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2606 control_flow_data
->drawing
->width
,
2607 control_flow_data
->drawing
->height
);
2609 /* Get new data for the rest. */
2610 drawing_data_request(control_flow_data
->drawing
,
2611 &control_flow_data
->drawing
->pixmap
,
2612 drawing
->damage_begin
, 0,
2613 drawing
->damage_end
- drawing
->damage_begin
,
2614 control_flow_data
->drawing
->height
);
2617 //if(ns<os && os<ns+w)
2618 //if(ns<os && os<new_end)
2619 if(ltt_time_compare(*ns
,*os
) == -1
2620 && ltt_time_compare(*os
,new_end
) == -1)
2622 g_info("scrolling near left");
2623 /* Scroll left, keep left part of the screen */
2625 guint width
= control_flow_data
->drawing
->width
;
2626 convert_time_to_pixels(
2634 /* Copy old data to new location */
2635 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2636 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2637 control_flow_data
->drawing
->pixmap
,
2642 if(drawing
->damage_begin
== drawing
->damage_end
)
2643 drawing
->damage_end
= x
;
2645 drawing
->damage_end
=
2646 control_flow_data
->drawing
->width
;
2648 drawing
->damage_begin
= 0;
2650 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2651 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2653 drawing
->damage_begin
, 0,
2654 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2655 control_flow_data
->drawing
->height
);
2657 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2659 control_flow_data
->drawing
->width
,
2660 control_flow_data
->drawing
->height
);
2663 /* Get new data for the rest. */
2664 drawing_data_request(control_flow_data
->drawing
,
2665 &control_flow_data
->drawing
->pixmap
,
2666 drawing
->damage_begin
, 0,
2667 drawing
->damage_end
- drawing
->damage_begin
,
2668 control_flow_data
->drawing
->height
);
2671 if(ltt_time_compare(*ns
,*os
) == 0)
2673 g_info("not scrolling");
2675 g_info("scrolling far");
2676 /* Cannot reuse any part of the screen : far jump */
2679 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2680 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2683 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2684 control_flow_data
->drawing
->height
);
2686 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2688 control_flow_data
->drawing
->width
,
2689 control_flow_data
->drawing
->height
);
2691 drawing
->damage_begin
= 0;
2692 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2694 drawing_data_request(control_flow_data
->drawing
,
2695 &control_flow_data
->drawing
->pixmap
,
2697 control_flow_data
->drawing
->width
,
2698 control_flow_data
->drawing
->height
);
2704 /* Different scale (zoom) */
2707 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2708 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2711 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2712 control_flow_data
->drawing
->height
);
2714 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2716 control_flow_data
->drawing
->width
,
2717 control_flow_data
->drawing
->height
);
2719 drawing
->damage_begin
= 0;
2720 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2722 drawing_data_request(control_flow_data
->drawing
,
2723 &control_flow_data
->drawing
->pixmap
,
2725 control_flow_data
->drawing
->width
,
2726 control_flow_data
->drawing
->height
);
2734 gint
traceset_notify(void *hook_data
, void *call_data
)
2736 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2737 Drawing_t
*drawing
= control_flow_data
->drawing
;
2738 GtkWidget
*widget
= drawing
->drawing_area
;
2741 drawing_clear(control_flow_data
->drawing
);
2742 processlist_clear(control_flow_data
->process_list
);
2743 redraw_notify(control_flow_data
, NULL
);
2745 request_background_data(control_flow_data
);
2747 drawing
->damage_begin
= 0;
2748 drawing
->damage_end
= drawing
->width
;
2749 if(drawing
->damage_begin
< drawing
->damage_end
)
2751 drawing_data_request(drawing
,
2753 drawing
->damage_begin
,
2755 drawing
->damage_end
-drawing
->damage_begin
,
2759 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2768 gint
redraw_notify(void *hook_data
, void *call_data
)
2770 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2771 Drawing_t
*drawing
= control_flow_data
->drawing
;
2772 GtkWidget
*widget
= drawing
->drawing_area
;
2774 drawing
->damage_begin
= 0;
2775 drawing
->damage_end
= drawing
->width
;
2777 /* fun feature, to be separated someday... */
2778 drawing_clear(control_flow_data
->drawing
);
2779 processlist_clear(control_flow_data
->process_list
);
2782 gdk_draw_rectangle (drawing
->pixmap
,
2783 widget
->style
->black_gc
,
2786 drawing
->width
+SAFETY
,
2790 if(drawing
->damage_begin
< drawing
->damage_end
)
2792 drawing_data_request(drawing
,
2794 drawing
->damage_begin
,
2796 drawing
->damage_end
-drawing
->damage_begin
,
2800 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2809 gint
continue_notify(void *hook_data
, void *call_data
)
2811 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2812 Drawing_t
*drawing
= control_flow_data
->drawing
;
2813 GtkWidget
*widget
= drawing
->drawing_area
;
2815 //g_assert(widget->allocation.width == drawing->damage_end);
2817 if(drawing
->damage_begin
< drawing
->damage_end
)
2819 drawing_data_request(drawing
,
2821 drawing
->damage_begin
,
2823 drawing
->damage_end
-drawing
->damage_begin
,
2831 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2833 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2834 Drawing_t
*drawing
= control_flow_data
->drawing
;
2836 LttTime current_time
= *((LttTime
*)call_data
);
2838 TimeWindow time_window
=
2839 lttvwindow_get_time_window(control_flow_data
->tab
);
2841 LttTime time_begin
= time_window
.start_time
;
2842 LttTime width
= time_window
.time_width
;
2845 guint64 time_ll
= ltt_time_to_uint64(width
);
2846 time_ll
= time_ll
>> 1; /* divide by two */
2847 half_width
= ltt_time_from_uint64(time_ll
);
2849 LttTime time_end
= ltt_time_add(time_begin
, width
);
2851 LttvTracesetContext
* tsc
=
2852 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2854 LttTime trace_start
= tsc
->time_span
.start_time
;
2855 LttTime trace_end
= tsc
->time_span
.end_time
;
2857 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2858 current_time
.tv_nsec
);
2862 /* If current time is inside time interval, just move the highlight
2865 /* Else, we have to change the time interval. We have to tell it
2866 * to the main window. */
2867 /* The time interval change will take care of placing the current
2868 * time at the center of the visible area, or nearest possible if we are
2869 * at one end of the trace. */
2872 if(ltt_time_compare(current_time
, time_begin
) == -1)
2874 TimeWindow new_time_window
;
2876 if(ltt_time_compare(current_time
,
2877 ltt_time_add(trace_start
,half_width
)) == -1)
2878 time_begin
= trace_start
;
2880 time_begin
= ltt_time_sub(current_time
,half_width
);
2882 new_time_window
.start_time
= time_begin
;
2883 new_time_window
.time_width
= width
;
2884 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2886 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2888 else if(ltt_time_compare(current_time
, time_end
) == 1)
2890 TimeWindow new_time_window
;
2892 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2893 time_begin
= ltt_time_sub(trace_end
,width
);
2895 time_begin
= ltt_time_sub(current_time
,half_width
);
2897 new_time_window
.start_time
= time_begin
;
2898 new_time_window
.time_width
= width
;
2899 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2901 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2904 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2905 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2913 typedef struct _ClosureData
{
2914 EventsRequest
*events_request
;
2915 LttvTracesetState
*tss
;
2920 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2922 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2923 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2924 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2926 EventsRequest
*events_request
= closure_data
->events_request
;
2927 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2928 Drawing_t
*drawing
= control_flow_data
->drawing
;
2930 LttvTracesetState
*tss
= closure_data
->tss
;
2931 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2933 LttTime evtime
= closure_data
->end_time
;
2934 TimeWindow time_window
=
2935 lttvwindow_get_time_window(control_flow_data
->tab
);
2937 LttTime end_time
= time_window
.end_time
;
2939 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2940 || ltt_time_compare(evtime
, end_time
) == 1)
2943 guint width
= drawing
->width
;
2946 /* For the process */
2947 /* First, check if the current process is in the state computation
2948 * process list. If it is there, that means we must add it right now and
2949 * draw items from the beginning of the read for it. If it is not
2950 * present, it's a new process and it was not present : it will
2951 * be added after the state update. */
2952 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2954 /* tracefiles[0] is ok here, because we draw for every PID, and
2955 * assume CPU 0 for PID 0 //FIXME */
2956 LttvTracefileState
*tfs
=
2957 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2959 LttvProcessState
*process
;
2960 process
= lttv_state_find_process(tfs
,
2963 if(process
!= NULL
) {
2965 /* Only draw for processes that are currently in the trace states */
2967 guint y
= 0, height
= 0, pl_height
= 0;
2968 ProcessList
*process_list
= control_flow_data
->process_list
;
2969 LttTime birth
= process_info
->birth
;
2971 /* Should be alike when background info is ready */
2972 if(control_flow_data
->background_info_waiting
==0)
2973 g_assert(ltt_time_compare(process
->creation_time
,
2974 process_info
->birth
) == 0);
2975 const gchar
*name
= g_quark_to_string(process
->name
);
2977 /* process HAS to be present */
2978 g_assert(processlist_get_process_pixels(process_list
,
2982 process_info
->trace_num
,
2985 &hashed_process_data
) != 1);
2987 /* Now, the process is in the state hash and our own process hash.
2988 * We definitely can draw the items related to the ending state.
2991 /* Check if the x position is unset. In can have been left unset by
2992 * a draw closure from a after chunk hook. This should never happen,
2993 * because it must be set by before chunk hook to the damage_begin
2996 g_assert(hashed_process_data
->x
.over
!= -1);
3000 convert_time_to_pixels(
3001 time_window
.start_time
,
3007 DrawContext draw_context
;
3009 /* Now create the drawing context that will be used to draw
3010 * items related to the last state. */
3011 draw_context
.drawable
= drawing
->pixmap
;
3012 draw_context
.gc
= drawing
->gc
;
3013 draw_context
.pango_layout
= drawing
->pango_layout
;
3014 draw_context
.drawinfo
.end
.x
= x
;
3016 draw_context
.drawinfo
.y
.over
= y
+1;
3017 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3018 draw_context
.drawinfo
.y
.under
= y
+height
;
3020 draw_context
.drawinfo
.start
.offset
.over
= 0;
3021 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3022 draw_context
.drawinfo
.start
.offset
.under
= 0;
3023 draw_context
.drawinfo
.end
.offset
.over
= 0;
3024 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3025 draw_context
.drawinfo
.end
.offset
.under
= 0;
3027 /* Jump over draw if we are at the same x position */
3028 if(x
== hashed_process_data
->x
.over
)
3032 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3034 PropertiesLine prop_line
= prepare_execmode_line(process
);
3035 draw_line((void*)&prop_line
, (void*)&draw_context
);
3037 hashed_process_data
->x
.over
= x
;
3041 if(x
== hashed_process_data
->x
.middle
&&
3042 hashed_process_data
->x
.middle_used
) {
3043 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3044 /* Draw collision indicator */
3045 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3046 gdk_draw_point(drawing
->pixmap
,
3050 hashed_process_data
->x
.middle_marked
= TRUE
;
3054 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3056 PropertiesLine prop_line
= prepare_s_e_line(process
);
3057 draw_line((void*)&prop_line
, (void*)&draw_context
);
3059 /* become the last x position */
3060 if(x
!= hashed_process_data
->x
.middle
) {
3061 hashed_process_data
->x
.middle
= x
;
3062 /* but don't use the pixel */
3063 hashed_process_data
->x
.middle_used
= FALSE
;
3072 int before_chunk(void *hook_data
, void *call_data
)
3074 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3075 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3077 drawing_chunk_begin(events_request
, tss
);
3082 int before_request(void *hook_data
, void *call_data
)
3084 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3085 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3087 drawing_data_request_begin(events_request
, tss
);
3094 * after request is necessary in addition of after chunk in order to draw
3095 * lines until the end of the screen. after chunk just draws lines until
3102 int after_request(void *hook_data
, void *call_data
)
3104 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3105 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3106 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3107 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3109 ProcessList
*process_list
= control_flow_data
->process_list
;
3110 LttTime end_time
= events_request
->end_time
;
3112 ClosureData closure_data
;
3113 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3114 closure_data
.tss
= tss
;
3115 closure_data
.end_time
= end_time
;
3117 /* Draw last items */
3118 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3119 (void*)&closure_data
);
3121 /* Request expose */
3122 drawing_request_expose(events_request
, tss
, end_time
);
3131 int after_chunk(void *hook_data
, void *call_data
)
3133 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3134 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3135 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3136 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3137 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3140 ProcessList
*process_list
= control_flow_data
->process_list
;
3143 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3144 else /* end of traceset, or position now out of request : end */
3145 end_time
= events_request
->end_time
;
3147 ClosureData closure_data
;
3148 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3149 closure_data
.tss
= tss
;
3150 closure_data
.end_time
= end_time
;
3152 /* Draw last items */
3153 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3154 (void*)&closure_data
);
3156 /* Request expose */
3157 drawing_request_expose(events_request
, tss
, end_time
);