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)
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(
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(
616 /* Jump over draw if we are at the same x position */
617 if(x
== hashed_process_data
->x
.middle
&&
618 hashed_process_data
->x
.middle_used
)
620 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
621 /* Draw collision indicator */
622 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
623 gdk_draw_point(drawing
->pixmap
,
627 hashed_process_data
->x
.middle_marked
= TRUE
;
631 DrawContext draw_context
;
633 /* Now create the drawing context that will be used to draw
634 * items related to the last state. */
635 draw_context
.drawable
= drawing
->pixmap
;
636 draw_context
.gc
= drawing
->gc
;
637 draw_context
.pango_layout
= drawing
->pango_layout
;
638 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
639 draw_context
.drawinfo
.end
.x
= x
;
641 draw_context
.drawinfo
.y
.over
= y
+1;
642 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
643 draw_context
.drawinfo
.y
.under
= y
+height
;
645 draw_context
.drawinfo
.start
.offset
.over
= 0;
646 draw_context
.drawinfo
.start
.offset
.middle
= 0;
647 draw_context
.drawinfo
.start
.offset
.under
= 0;
648 draw_context
.drawinfo
.end
.offset
.over
= 0;
649 draw_context
.drawinfo
.end
.offset
.middle
= 0;
650 draw_context
.drawinfo
.end
.offset
.under
= 0;
654 PropertiesLine prop_line
= prepare_s_e_line(process
);
655 draw_line((void*)&prop_line
, (void*)&draw_context
);
659 /* become the last x position */
660 hashed_process_data
->x
.middle
= x
;
661 hashed_process_data
->x
.middle_used
= TRUE
;
662 hashed_process_data
->x
.middle_marked
= FALSE
;
671 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
672 ControlFlowData
*control_flow_data
=
673 (ControlFlowData
*)events_request
->viewer_data
;
674 Tab
*tab
= control_flow_data
->tab
;
676 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
678 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
679 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
684 LttTime evtime
= ltt_event_time(e
);
685 TimeWindow time_window
=
686 lttvwindow_get_time_window(tab
);
688 LttTime end_time
= time_window
.end_time
;
690 //if(time < time_beg || time > time_end) return;
691 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
692 || ltt_time_compare(evtime
, end_time
) == 1)
695 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
697 g_debug("schedchange!");
699 /* Add process to process list (if not present) and get drawing "y" from
700 * process position */
701 guint pid_out
, pid_in
;
702 LttvProcessState
*process_out
, *process_in
;
704 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
706 ProcessList
*process_list
= control_flow_data
->process_list
;
709 LttField
*f
= ltt_event_field(e
);
711 element
= ltt_field_member(f
,0);
712 pid_out
= ltt_event_get_long_unsigned(e
,element
);
713 element
= ltt_field_member(f
,1);
714 pid_in
= ltt_event_get_long_unsigned(e
,element
);
715 g_debug("out : %u in : %u", pid_out
, pid_in
);
718 /* Find process pid_out in the list... */
719 process_out
= lttv_state_find_process(tfs
, pid_out
);
720 if(process_out
== NULL
) return 0;
721 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
723 birth
= process_out
->creation_time
;
724 const gchar
*name
= g_quark_to_string(process_out
->name
);
725 HashedProcessData
*hashed_process_data_out
= NULL
;
727 if(processlist_get_process_pixels(process_list
,
730 tfc
->t_context
->index
,
733 &hashed_process_data_out
) == 1)
735 /* Process not present */
736 processlist_add(process_list
,
739 tfc
->t_context
->index
,
742 &hashed_process_data_out
);
743 g_assert(processlist_get_process_pixels(process_list
,
746 tfc
->t_context
->index
,
749 &hashed_process_data_out
)==0);
750 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
754 /* Find process pid_in in the list... */
755 process_in
= lttv_state_find_process(tfs
, pid_in
);
756 if(process_in
== NULL
) return 0;
757 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
759 birth
= process_in
->creation_time
;
760 name
= g_quark_to_string(process_in
->name
);
761 HashedProcessData
*hashed_process_data_in
= NULL
;
763 if(processlist_get_process_pixels(process_list
,
766 tfc
->t_context
->index
,
769 &hashed_process_data_in
) == 1)
771 /* Process not present */
772 processlist_add(process_list
,
775 tfc
->t_context
->index
,
778 &hashed_process_data_in
);
779 processlist_get_process_pixels(process_list
,
782 tfc
->t_context
->index
,
785 &hashed_process_data_in
);
787 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
792 /* Find pixels corresponding to time of the event. If the time does
793 * not fit in the window, show a warning, not supposed to happend. */
795 guint width
= control_flow_data
->drawing
->width
;
797 LttTime time
= ltt_event_time(e
);
799 LttTime window_end
= time_window
.end_time
;
801 convert_time_to_pixels(
806 //assert(x <= width);
808 /* draw what represents the event for outgoing process. */
810 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
811 draw_context_out
->current
->modify_over
->x
= x
;
812 draw_context_out
->current
->modify_under
->x
= x
;
813 draw_context_out
->current
->modify_over
->y
= y_out
;
814 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
815 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
816 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
817 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
818 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
819 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
820 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
821 //draw_context_out->gc = widget->style->black_gc;
823 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
824 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
826 /* Draw the line/background of the out process */
827 if(draw_context_out
->previous
->middle
->x
== -1)
829 draw_context_out
->previous
->over
->x
=
830 control_flow_data
->drawing
->damage_begin
;
831 draw_context_out
->previous
->middle
->x
=
832 control_flow_data
->drawing
->damage_begin
;
833 draw_context_out
->previous
->under
->x
=
834 control_flow_data
->drawing
->damage_begin
;
836 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
839 draw_context_out
->current
->middle
->x
= x
;
840 draw_context_out
->current
->over
->x
= x
;
841 draw_context_out
->current
->under
->x
= x
;
842 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
843 draw_context_out
->current
->over
->y
= y_out
;
844 draw_context_out
->current
->under
->y
= y_out
+ height
;
845 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
846 draw_context_out
->previous
->over
->y
= y_out
;
847 draw_context_out
->previous
->under
->y
= y_out
+ height
;
849 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
850 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
852 if(process_out
->state
->s
== LTTV_STATE_RUN
)
854 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
855 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
856 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
858 PropertiesBG prop_bg
;
859 prop_bg
.color
= g_new(GdkColor
,1);
863 prop_bg
.color
->red
= 0x1515;
864 prop_bg
.color
->green
= 0x1515;
865 prop_bg
.color
->blue
= 0x8c8c;
868 prop_bg
.color
->red
= 0x4e4e;
869 prop_bg
.color
->green
= 0xa9a9;
870 prop_bg
.color
->blue
= 0xa4a4;
873 prop_bg
.color
->red
= 0x7a7a;
874 prop_bg
.color
->green
= 0x4a4a;
875 prop_bg
.color
->blue
= 0x8b8b;
878 prop_bg
.color
->red
= 0x8080;
879 prop_bg
.color
->green
= 0x7777;
880 prop_bg
.color
->blue
= 0x4747;
883 prop_bg
.color
->red
= 0xe7e7;
884 prop_bg
.color
->green
= 0xe7e7;
885 prop_bg
.color
->blue
= 0xe7e7;
888 g_debug("calling from draw_event");
889 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
890 g_free(prop_bg
.color
);
891 //gdk_gc_unref(draw_context_out->gc);
894 draw_context_out
->gc
= widget
->style
->black_gc
;
896 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
897 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
898 PropertiesText prop_text_out
;
899 prop_text_out
.foreground
= &colorfg_out
;
900 prop_text_out
.background
= &colorbg_out
;
901 prop_text_out
.size
= 6;
902 prop_text_out
.position
= OVER
;
904 /* color of text : status of the process */
905 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
907 prop_text_out
.foreground
->red
= 0xffff;
908 prop_text_out
.foreground
->green
= 0xffff;
909 prop_text_out
.foreground
->blue
= 0xffff;
911 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
913 prop_text_out
.foreground
->red
= 0x0fff;
914 prop_text_out
.foreground
->green
= 0xffff;
915 prop_text_out
.foreground
->blue
= 0xfff0;
917 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
919 prop_text_out
.foreground
->red
= 0xffff;
920 prop_text_out
.foreground
->green
= 0xffff;
921 prop_text_out
.foreground
->blue
= 0x0000;
923 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
925 prop_text_out
.foreground
->red
= 0xffff;
926 prop_text_out
.foreground
->green
= 0x0000;
927 prop_text_out
.foreground
->blue
= 0xffff;
929 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
931 prop_text_out
.foreground
->red
= 0xffff;
932 prop_text_out
.foreground
->green
= 0x0000;
933 prop_text_out
.foreground
->blue
= 0x0000;
935 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
937 prop_text_out
.foreground
->red
= 0x0000;
938 prop_text_out
.foreground
->green
= 0xffff;
939 prop_text_out
.foreground
->blue
= 0x0000;
943 prop_text_out
.foreground
->red
= 0xffff;
944 prop_text_out
.foreground
->green
= 0xffff;
945 prop_text_out
.foreground
->blue
= 0xffff;
949 /* Print status of the process : U, WF, WC, E, W, R */
950 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
951 prop_text_out
.text
= "U->";
952 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
953 prop_text_out
.text
= "WF->";
954 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
955 prop_text_out
.text
= "WC->";
956 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
957 prop_text_out
.text
= "E->";
958 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
959 prop_text_out
.text
= "W->";
960 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
961 prop_text_out
.text
= "R->";
963 prop_text_out
.text
= "U";
965 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
966 //gdk_gc_unref(draw_context_out->gc);
968 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
969 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
970 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
972 PropertiesLine prop_line_out
;
973 prop_line_out
.color
= g_new(GdkColor
,1);
974 prop_line_out
.line_width
= 2;
975 prop_line_out
.style
= GDK_LINE_SOLID
;
976 prop_line_out
.position
= MIDDLE
;
978 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
980 /* color of line : status of the process */
981 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
983 prop_line_out
.color
->red
= 0xffff;
984 prop_line_out
.color
->green
= 0xffff;
985 prop_line_out
.color
->blue
= 0xffff;
987 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
989 prop_line_out
.color
->red
= 0x0fff;
990 prop_line_out
.color
->green
= 0xffff;
991 prop_line_out
.color
->blue
= 0xfff0;
993 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
995 prop_line_out
.color
->red
= 0xffff;
996 prop_line_out
.color
->green
= 0xffff;
997 prop_line_out
.color
->blue
= 0x0000;
999 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1001 prop_line_out
.color
->red
= 0xffff;
1002 prop_line_out
.color
->green
= 0x0000;
1003 prop_line_out
.color
->blue
= 0xffff;
1005 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1007 prop_line_out
.color
->red
= 0xffff;
1008 prop_line_out
.color
->green
= 0x0000;
1009 prop_line_out
.color
->blue
= 0x0000;
1011 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1013 prop_line_out
.color
->red
= 0x0000;
1014 prop_line_out
.color
->green
= 0xffff;
1015 prop_line_out
.color
->blue
= 0x0000;
1019 prop_line_out
.color
->red
= 0xffff;
1020 prop_line_out
.color
->green
= 0xffff;
1021 prop_line_out
.color
->blue
= 0xffff;
1024 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1025 g_free(prop_line_out
.color
);
1026 //gdk_gc_unref(draw_context_out->gc);
1027 /* Note : finishing line will have to be added when trace read over. */
1029 /* Finally, update the drawing context of the pid_in. */
1031 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1032 draw_context_in
->current
->modify_over
->x
= x
;
1033 draw_context_in
->current
->modify_under
->x
= x
;
1034 draw_context_in
->current
->modify_over
->y
= y_in
;
1035 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1036 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1037 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1038 widget
= control_flow_data
->drawing
->drawing_area
;
1039 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1040 //draw_context_in->gc = widget->style->black_gc;
1041 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1042 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1044 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1045 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1047 /* Draw the line/bg of the in process */
1048 if(draw_context_in
->previous
->middle
->x
== -1)
1050 draw_context_in
->previous
->over
->x
=
1051 control_flow_data
->drawing
->damage_begin
;
1052 draw_context_in
->previous
->middle
->x
=
1053 control_flow_data
->drawing
->damage_begin
;
1054 draw_context_in
->previous
->under
->x
=
1055 control_flow_data
->drawing
->damage_begin
;
1057 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1061 draw_context_in
->current
->middle
->x
= x
;
1062 draw_context_in
->current
->over
->x
= x
;
1063 draw_context_in
->current
->under
->x
= x
;
1064 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1065 draw_context_in
->current
->over
->y
= y_in
;
1066 draw_context_in
->current
->under
->y
= y_in
+ height
;
1067 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1068 draw_context_in
->previous
->over
->y
= y_in
;
1069 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1071 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1072 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1075 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1077 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1078 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1079 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1081 PropertiesBG prop_bg
;
1082 prop_bg
.color
= g_new(GdkColor
,1);
1084 switch(tfc
->index
) {
1086 prop_bg
.color
->red
= 0x1515;
1087 prop_bg
.color
->green
= 0x1515;
1088 prop_bg
.color
->blue
= 0x8c8c;
1091 prop_bg
.color
->red
= 0x4e4e;
1092 prop_bg
.color
->green
= 0xa9a9;
1093 prop_bg
.color
->blue
= 0xa4a4;
1096 prop_bg
.color
->red
= 0x7a7a;
1097 prop_bg
.color
->green
= 0x4a4a;
1098 prop_bg
.color
->blue
= 0x8b8b;
1101 prop_bg
.color
->red
= 0x8080;
1102 prop_bg
.color
->green
= 0x7777;
1103 prop_bg
.color
->blue
= 0x4747;
1106 prop_bg
.color
->red
= 0xe7e7;
1107 prop_bg
.color
->green
= 0xe7e7;
1108 prop_bg
.color
->blue
= 0xe7e7;
1112 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1113 g_free(prop_bg
.color
);
1114 //gdk_gc_unref(draw_context_in->gc);
1117 draw_context_in
->gc
= widget
->style
->black_gc
;
1119 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1120 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1121 PropertiesText prop_text_in
;
1122 prop_text_in
.foreground
= &colorfg_in
;
1123 prop_text_in
.background
= &colorbg_in
;
1124 prop_text_in
.size
= 6;
1125 prop_text_in
.position
= OVER
;
1127 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1128 /* foreground of text : status of the process */
1129 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1131 prop_text_in
.foreground
->red
= 0xffff;
1132 prop_text_in
.foreground
->green
= 0xffff;
1133 prop_text_in
.foreground
->blue
= 0xffff;
1135 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1137 prop_text_in
.foreground
->red
= 0x0fff;
1138 prop_text_in
.foreground
->green
= 0xffff;
1139 prop_text_in
.foreground
->blue
= 0xfff0;
1141 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1143 prop_text_in
.foreground
->red
= 0xffff;
1144 prop_text_in
.foreground
->green
= 0xffff;
1145 prop_text_in
.foreground
->blue
= 0x0000;
1147 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1149 prop_text_in
.foreground
->red
= 0xffff;
1150 prop_text_in
.foreground
->green
= 0x0000;
1151 prop_text_in
.foreground
->blue
= 0xffff;
1153 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1155 prop_text_in
.foreground
->red
= 0xffff;
1156 prop_text_in
.foreground
->green
= 0x0000;
1157 prop_text_in
.foreground
->blue
= 0x0000;
1159 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1161 prop_text_in
.foreground
->red
= 0x0000;
1162 prop_text_in
.foreground
->green
= 0xffff;
1163 prop_text_in
.foreground
->blue
= 0x0000;
1167 prop_text_in
.foreground
->red
= 0xffff;
1168 prop_text_in
.foreground
->green
= 0xffff;
1169 prop_text_in
.foreground
->blue
= 0xffff;
1174 /* Print status of the process : U, WF, WC, E, W, R */
1175 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1176 prop_text_in
.text
= "U->";
1177 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1178 prop_text_in
.text
= "WF->";
1179 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1180 prop_text_in
.text
= "WC->";
1181 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1182 prop_text_in
.text
= "E->";
1183 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1184 prop_text_in
.text
= "W->";
1185 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1186 prop_text_in
.text
= "R->";
1188 prop_text_in
.text
= "U";
1190 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1191 //gdk_gc_unref(draw_context_in->gc);
1193 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1194 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1195 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1197 PropertiesLine prop_line_in
;
1198 prop_line_in
.color
= g_new(GdkColor
,1);
1199 prop_line_in
.line_width
= 2;
1200 prop_line_in
.style
= GDK_LINE_SOLID
;
1201 prop_line_in
.position
= MIDDLE
;
1203 /* color of line : status of the process */
1204 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1206 prop_line_in
.color
->red
= 0xffff;
1207 prop_line_in
.color
->green
= 0xffff;
1208 prop_line_in
.color
->blue
= 0xffff;
1210 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1212 prop_line_in
.color
->red
= 0x0fff;
1213 prop_line_in
.color
->green
= 0xffff;
1214 prop_line_in
.color
->blue
= 0xfff0;
1216 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1218 prop_line_in
.color
->red
= 0xffff;
1219 prop_line_in
.color
->green
= 0xffff;
1220 prop_line_in
.color
->blue
= 0x0000;
1222 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1224 prop_line_in
.color
->red
= 0xffff;
1225 prop_line_in
.color
->green
= 0x0000;
1226 prop_line_in
.color
->blue
= 0xffff;
1228 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1230 prop_line_in
.color
->red
= 0xffff;
1231 prop_line_in
.color
->green
= 0x0000;
1232 prop_line_in
.color
->blue
= 0x0000;
1234 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1236 prop_line_in
.color
->red
= 0x0000;
1237 prop_line_in
.color
->green
= 0xffff;
1238 prop_line_in
.color
->blue
= 0x0000;
1242 prop_line_in
.color
->red
= 0xffff;
1243 prop_line_in
.color
->green
= 0xffff;
1244 prop_line_in
.color
->blue
= 0xffff;
1247 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1248 g_free(prop_line_in
.color
);
1249 //gdk_gc_unref(draw_context_in->gc);
1259 GString
*string
= g_string_new("");;
1260 gboolean field_names
= TRUE
, state
= TRUE
;
1262 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1263 g_string_append_printf(string
,"\n");
1266 g_string_append_printf(string
, " %s",
1267 g_quark_to_string(tfs
->process
->state
->s
));
1270 g_info("%s",string
->str
);
1272 g_string_free(string
, TRUE
);
1274 /* End of text dump */
1279 /* after_schedchange_hook
1281 * The draw after hook is called by the reading API to have a
1282 * particular event drawn on the screen.
1283 * @param hook_data ControlFlowData structure of the viewer.
1284 * @param call_data Event context.
1286 * This function adds items to be drawn in a queue for each process.
1289 int after_schedchange_hook(void *hook_data
, void *call_data
)
1291 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1292 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1294 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1296 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1297 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1302 LttTime evtime
= ltt_event_time(e
);
1303 TimeWindow time_window
=
1304 lttvwindow_get_time_window(control_flow_data
->tab
);
1306 LttTime end_time
= time_window
.end_time
;
1309 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1310 || ltt_time_compare(evtime
, end_time
) == 1)
1312 #endif //EXTRA_CHECK
1314 guint width
= control_flow_data
->drawing
->width
;
1316 /* Add process to process list (if not present) */
1317 LttvProcessState
*process_out
, *process_in
;
1319 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1320 HashedProcessData
*hashed_process_data_in
= NULL
;
1322 ProcessList
*process_list
= control_flow_data
->process_list
;
1327 LttField
*f
= ltt_event_field(e
);
1329 element
= ltt_field_member(f
,0);
1330 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1331 element
= ltt_field_member(f
,1);
1332 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1333 g_debug("out : %u in : %u", pid_out
, pid_in
);
1337 /* Find process pid_in in the list... */
1338 process_in
= lttv_state_find_process(tfs
, pid_in
);
1339 /* It should exist, because we are after the state update. */
1340 g_assert(process_in
!= NULL
);
1342 birth
= process_in
->creation_time
;
1343 const gchar
*name
= g_quark_to_string(process_in
->name
);
1345 if(processlist_get_process_pixels(process_list
,
1347 process_in
->last_cpu
,
1349 tfc
->t_context
->index
,
1352 &hashed_process_data_in
) == 1)
1354 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1355 /* Process not present */
1356 processlist_add(process_list
,
1358 process_in
->last_cpu
,
1361 tfc
->t_context
->index
,
1364 &hashed_process_data_in
);
1365 processlist_get_process_pixels(process_list
,
1367 process_in
->last_cpu
,
1369 tfc
->t_context
->index
,
1372 &hashed_process_data_in
);
1373 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1378 convert_time_to_pixels(
1384 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1385 hashed_process_data_in
->x
.middle
= new_x
;
1386 hashed_process_data_in
->x
.middle_used
= FALSE
;
1387 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1397 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1398 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1400 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1402 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1403 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1409 LttTime evtime
= ltt_event_time(e
);
1410 TimeWindow time_window
=
1411 lttvwindow_get_time_window(control_flow_data
->tab
);
1413 LttTime end_time
= time_window
.end_time
;
1415 //if(time < time_beg || time > time_end) return;
1416 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1417 || ltt_time_compare(evtime
, end_time
) == 1)
1421 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1423 g_debug("schedchange!");
1425 /* Add process to process list (if not present) and get drawing "y" from
1426 * process position */
1427 guint pid_out
, pid_in
;
1428 LttvProcessState
*process_out
, *process_in
;
1430 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1432 ProcessList
*process_list
= control_flow_data
->process_list
;
1435 LttField
*f
= ltt_event_field(e
);
1437 element
= ltt_field_member(f
,0);
1438 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1439 element
= ltt_field_member(f
,1);
1440 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1441 //g_debug("out : %u in : %u", pid_out, pid_in);
1444 /* Find process pid_out in the list... */
1445 process_out
= lttv_state_find_process(tfs
, pid_out
);
1446 if(process_out
== NULL
) return 0;
1447 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1449 birth
= process_out
->creation_time
;
1450 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1451 HashedProcessData
*hashed_process_data_out
= NULL
;
1453 if(processlist_get_process_pixels(process_list
,
1456 tfc
->t_context
->index
,
1459 &hashed_process_data_out
) == 1)
1461 /* Process not present */
1462 processlist_add(process_list
,
1465 tfc
->t_context
->index
,
1468 &hashed_process_data_out
);
1469 processlist_get_process_pixels(process_list
,
1472 tfc
->t_context
->index
,
1475 &hashed_process_data_out
);
1476 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1481 /* Find process pid_in in the list... */
1482 process_in
= lttv_state_find_process(tfs
, pid_in
);
1483 if(process_in
== NULL
) return 0;
1484 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1486 birth
= process_in
->creation_time
;
1487 name
= strdup(g_quark_to_string(process_in
->name
));
1488 HashedProcessData
*hashed_process_data_in
= NULL
;
1490 if(processlist_get_process_pixels(process_list
,
1493 tfc
->t_context
->index
,
1496 &hashed_process_data_in
) == 1)
1498 /* Process not present */
1499 processlist_add(process_list
,
1502 tfc
->t_context
->index
,
1505 &hashed_process_data_in
);
1506 processlist_get_process_pixels(process_list
,
1509 tfc
->t_context
->index
,
1512 &hashed_process_data_in
);
1514 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1519 /* Find pixels corresponding to time of the event. If the time does
1520 * not fit in the window, show a warning, not supposed to happend. */
1522 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1524 //LttTime time = ltt_event_time(e);
1526 //LttTime window_end = time_window->end_time;
1529 //convert_time_to_pixels(
1535 //assert(x <= width);
1537 /* draw what represents the event for outgoing process. */
1539 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1540 //draw_context_out->current->modify_over->x = x;
1541 draw_context_out
->current
->modify_over
->y
= y_out
;
1542 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1543 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1544 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1545 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1546 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1548 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1549 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1551 /*if(process_out->state->s == LTTV_STATE_RUN)
1553 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1554 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1555 PropertiesBG prop_bg;
1556 prop_bg.color = g_new(GdkColor,1);
1558 prop_bg.color->red = 0xffff;
1559 prop_bg.color->green = 0xffff;
1560 prop_bg.color->blue = 0xffff;
1562 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1563 g_free(prop_bg.color);
1564 gdk_gc_unref(draw_context_out->gc);
1567 draw_context_out
->gc
= widget
->style
->black_gc
;
1569 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1570 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1571 PropertiesText prop_text_out
;
1572 prop_text_out
.foreground
= &colorfg_out
;
1573 prop_text_out
.background
= &colorbg_out
;
1574 prop_text_out
.size
= 6;
1575 prop_text_out
.position
= OVER
;
1577 /* color of text : status of the process */
1578 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1580 prop_text_out
.foreground
->red
= 0xffff;
1581 prop_text_out
.foreground
->green
= 0xffff;
1582 prop_text_out
.foreground
->blue
= 0xffff;
1584 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1586 prop_text_out
.foreground
->red
= 0x0fff;
1587 prop_text_out
.foreground
->green
= 0xffff;
1588 prop_text_out
.foreground
->blue
= 0xfff0;
1590 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1592 prop_text_out
.foreground
->red
= 0xffff;
1593 prop_text_out
.foreground
->green
= 0xffff;
1594 prop_text_out
.foreground
->blue
= 0x0000;
1596 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1598 prop_text_out
.foreground
->red
= 0xffff;
1599 prop_text_out
.foreground
->green
= 0x0000;
1600 prop_text_out
.foreground
->blue
= 0xffff;
1602 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1604 prop_text_out
.foreground
->red
= 0xffff;
1605 prop_text_out
.foreground
->green
= 0x0000;
1606 prop_text_out
.foreground
->blue
= 0x0000;
1608 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1610 prop_text_out
.foreground
->red
= 0x0000;
1611 prop_text_out
.foreground
->green
= 0xffff;
1612 prop_text_out
.foreground
->blue
= 0x0000;
1616 prop_text_out
.foreground
->red
= 0xffff;
1617 prop_text_out
.foreground
->green
= 0xffff;
1618 prop_text_out
.foreground
->blue
= 0xffff;
1621 /* Print status of the process : U, WF, WC, E, W, R */
1622 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1623 prop_text_out
.text
= "U";
1624 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1625 prop_text_out
.text
= "WF";
1626 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1627 prop_text_out
.text
= "WC";
1628 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1629 prop_text_out
.text
= "E";
1630 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1631 prop_text_out
.text
= "W";
1632 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1633 prop_text_out
.text
= "R";
1635 prop_text_out
.text
= "U";
1637 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1639 //gdk_gc_unref(draw_context_out->gc);
1641 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1642 draw_context_out
->current
->over
->y
= y_out
;
1643 draw_context_out
->current
->under
->y
= y_out
+height
;
1644 draw_context_out
->current
->status
= process_out
->state
->s
;
1646 /* for pid_out : remove previous, Prev = current, new current (default) */
1647 g_free(draw_context_out
->previous
->modify_under
);
1648 g_free(draw_context_out
->previous
->modify_middle
);
1649 g_free(draw_context_out
->previous
->modify_over
);
1650 g_free(draw_context_out
->previous
->under
);
1651 g_free(draw_context_out
->previous
->middle
);
1652 g_free(draw_context_out
->previous
->over
);
1653 g_free(draw_context_out
->previous
);
1655 draw_context_out
->previous
= draw_context_out
->current
;
1657 draw_context_out
->current
= g_new(DrawInfo
,1);
1658 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1659 draw_context_out
->current
->over
->x
= -1;
1660 draw_context_out
->current
->over
->y
= -1;
1661 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1662 draw_context_out
->current
->middle
->x
= -1;
1663 draw_context_out
->current
->middle
->y
= -1;
1664 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1665 draw_context_out
->current
->under
->x
= -1;
1666 draw_context_out
->current
->under
->y
= -1;
1667 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1668 draw_context_out
->current
->modify_over
->x
= -1;
1669 draw_context_out
->current
->modify_over
->y
= -1;
1670 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1671 draw_context_out
->current
->modify_middle
->x
= -1;
1672 draw_context_out
->current
->modify_middle
->y
= -1;
1673 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1674 draw_context_out
->current
->modify_under
->x
= -1;
1675 draw_context_out
->current
->modify_under
->y
= -1;
1676 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1678 /* Finally, update the drawing context of the pid_in. */
1680 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1681 //draw_context_in->current->modify_over->x = x;
1682 draw_context_in
->current
->modify_over
->y
= y_in
;
1683 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1684 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1685 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1686 widget
= control_flow_data
->drawing
->drawing_area
;
1687 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1689 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1690 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1692 /*if(process_in->state->s == LTTV_STATE_RUN)
1694 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1695 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1696 PropertiesBG prop_bg;
1697 prop_bg.color = g_new(GdkColor,1);
1699 prop_bg.color->red = 0xffff;
1700 prop_bg.color->green = 0xffff;
1701 prop_bg.color->blue = 0xffff;
1703 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1704 g_free(prop_bg.color);
1705 gdk_gc_unref(draw_context_in->gc);
1708 draw_context_in
->gc
= widget
->style
->black_gc
;
1710 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1711 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1712 PropertiesText prop_text_in
;
1713 prop_text_in
.foreground
= &colorfg_in
;
1714 prop_text_in
.background
= &colorbg_in
;
1715 prop_text_in
.size
= 6;
1716 prop_text_in
.position
= OVER
;
1718 /* foreground of text : status of the process */
1719 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1721 prop_text_in
.foreground
->red
= 0xffff;
1722 prop_text_in
.foreground
->green
= 0xffff;
1723 prop_text_in
.foreground
->blue
= 0xffff;
1725 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1727 prop_text_in
.foreground
->red
= 0x0fff;
1728 prop_text_in
.foreground
->green
= 0xffff;
1729 prop_text_in
.foreground
->blue
= 0xfff0;
1731 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1733 prop_text_in
.foreground
->red
= 0xffff;
1734 prop_text_in
.foreground
->green
= 0xffff;
1735 prop_text_in
.foreground
->blue
= 0x0000;
1737 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1739 prop_text_in
.foreground
->red
= 0xffff;
1740 prop_text_in
.foreground
->green
= 0x0000;
1741 prop_text_in
.foreground
->blue
= 0xffff;
1743 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1745 prop_text_in
.foreground
->red
= 0xffff;
1746 prop_text_in
.foreground
->green
= 0x0000;
1747 prop_text_in
.foreground
->blue
= 0x0000;
1749 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1751 prop_text_in
.foreground
->red
= 0x0000;
1752 prop_text_in
.foreground
->green
= 0xffff;
1753 prop_text_in
.foreground
->blue
= 0x0000;
1757 prop_text_in
.foreground
->red
= 0xffff;
1758 prop_text_in
.foreground
->green
= 0xffff;
1759 prop_text_in
.foreground
->blue
= 0xffff;
1763 /* Print status of the process : U, WF, WC, E, W, R */
1764 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1765 prop_text_in
.text
= "U";
1766 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1767 prop_text_in
.text
= "WF";
1768 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1769 prop_text_in
.text
= "WC";
1770 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1771 prop_text_in
.text
= "E";
1772 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1773 prop_text_in
.text
= "W";
1774 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1775 prop_text_in
.text
= "R";
1777 prop_text_in
.text
= "U";
1779 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1782 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1785 prop_text_in
.foreground
= &colorfg_in
;
1786 prop_text_in
.background
= &colorbg_in
;
1787 prop_text_in
.foreground
->red
= 0xffff;
1788 prop_text_in
.foreground
->green
= 0xffff;
1789 prop_text_in
.foreground
->blue
= 0xffff;
1790 prop_text_in
.size
= 6;
1791 prop_text_in
.position
= UNDER
;
1793 prop_text_in
.text
= g_new(gchar
, 260);
1794 strcpy(prop_text_in
.text
, "CPU ");
1795 snprintf(tmp
, 255, "%u", tfc
->index
);
1796 strcat(prop_text_in
.text
, tmp
);
1798 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1799 g_free(prop_text_in
.text
);
1803 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1804 draw_context_in
->current
->over
->y
= y_in
;
1805 draw_context_in
->current
->under
->y
= y_in
+height
;
1806 draw_context_in
->current
->status
= process_in
->state
->s
;
1808 /* for pid_in : remove previous, Prev = current, new current (default) */
1809 g_free(draw_context_in
->previous
->modify_under
);
1810 g_free(draw_context_in
->previous
->modify_middle
);
1811 g_free(draw_context_in
->previous
->modify_over
);
1812 g_free(draw_context_in
->previous
->under
);
1813 g_free(draw_context_in
->previous
->middle
);
1814 g_free(draw_context_in
->previous
->over
);
1815 g_free(draw_context_in
->previous
);
1817 draw_context_in
->previous
= draw_context_in
->current
;
1819 draw_context_in
->current
= g_new(DrawInfo
,1);
1820 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1821 draw_context_in
->current
->over
->x
= -1;
1822 draw_context_in
->current
->over
->y
= -1;
1823 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1824 draw_context_in
->current
->middle
->x
= -1;
1825 draw_context_in
->current
->middle
->y
= -1;
1826 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1827 draw_context_in
->current
->under
->x
= -1;
1828 draw_context_in
->current
->under
->y
= -1;
1829 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1830 draw_context_in
->current
->modify_over
->x
= -1;
1831 draw_context_in
->current
->modify_over
->y
= -1;
1832 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1833 draw_context_in
->current
->modify_middle
->x
= -1;
1834 draw_context_in
->current
->modify_middle
->y
= -1;
1835 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1836 draw_context_in
->current
->modify_under
->x
= -1;
1837 draw_context_in
->current
->modify_under
->y
= -1;
1838 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1847 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1849 PropertiesLine prop_line
;
1850 prop_line
.line_width
= 1;
1851 prop_line
.style
= GDK_LINE_SOLID
;
1853 //GdkColormap *colormap = gdk_colormap_get_system();
1855 /* color of line : execution mode of the process */
1856 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1857 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1858 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1859 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1860 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1861 prop_line
.color
= drawing_colors
[COL_TRAP
];
1862 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1863 prop_line
.color
= drawing_colors
[COL_IRQ
];
1864 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1865 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1867 prop_line
.color
= drawing_colors
[COL_WHITE
];
1869 //gdk_colormap_alloc_color(colormap,
1880 /* before_execmode_hook
1882 * This function basically draw lines and icons. Two types of lines are drawn :
1883 * one small (3 pixels?) representing the state of the process and the second
1884 * type is thicker (10 pixels?) representing on which CPU a process is running
1885 * (and this only in running state).
1887 * Extremums of the lines :
1888 * x_min : time of the last event context for this process kept in memory.
1889 * x_max : time of the current event.
1890 * y : middle of the process in the process list. The process is found in the
1891 * list, therefore is it's position in pixels.
1893 * The choice of lines'color is defined by the context of the last event for this
1898 int before_execmode_hook(void *hook_data
, void *call_data
)
1900 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1901 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1902 Drawing_t
*drawing
= control_flow_data
->drawing
;
1904 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1906 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1907 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1912 LttTime evtime
= ltt_event_time(e
);
1913 TimeWindow time_window
=
1914 lttvwindow_get_time_window(control_flow_data
->tab
);
1916 LttTime end_time
= time_window
.end_time
;
1919 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1920 || ltt_time_compare(evtime
, end_time
) == 1)
1922 #endif //EXTRA_CHECK
1924 guint width
= drawing
->width
;
1926 /* we are in a execmode, before the state update. We must draw the
1927 * items corresponding to the state before it changes : now is the right
1931 LttvProcessState
*process
= tfs
->process
;
1932 g_assert(process
!= NULL
);
1934 guint pid
= process
->pid
;
1936 /* Well, the process_out existed : we must get it in the process hash
1937 * or add it, and draw its items.
1939 /* Add process to process list (if not present) */
1940 guint y
= 0, height
= 0, pl_height
= 0;
1941 HashedProcessData
*hashed_process_data
= NULL
;
1942 ProcessList
*process_list
= control_flow_data
->process_list
;
1943 LttTime birth
= process
->creation_time
;
1944 const gchar
*name
= g_quark_to_string(process
->name
);
1946 if(processlist_get_process_pixels(process_list
,
1950 tfc
->t_context
->index
,
1953 &hashed_process_data
) == 1)
1955 g_assert(pid
== 0 || pid
!= process
->ppid
);
1956 /* Process not present */
1957 processlist_add(process_list
,
1962 tfc
->t_context
->index
,
1965 &hashed_process_data
);
1966 processlist_get_process_pixels(process_list
,
1970 tfc
->t_context
->index
,
1973 &hashed_process_data
);
1974 drawing_insert_square( drawing
, y
, height
);
1977 /* Now, the process is in the state hash and our own process hash.
1978 * We definitely can draw the items related to the ending state.
1981 /* Check if the x position is unset. In can have been left unset by
1982 * a draw closure from a after chunk hook. This should never happen,
1983 * because it must be set by before chunk hook to the damage_begin
1986 g_assert(hashed_process_data
->x
.over
!= -1);
1990 convert_time_to_pixels(
1997 /* Jump over draw if we are at the same x position */
1998 if(x
== hashed_process_data
->x
.middle
&&
1999 hashed_process_data
->x
.middle_used
)
2001 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2002 /* Draw collision indicator */
2003 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2004 gdk_draw_point(drawing
->pixmap
,
2008 hashed_process_data
->x
.middle_marked
= TRUE
;
2013 DrawContext draw_context
;
2014 /* Now create the drawing context that will be used to draw
2015 * items related to the last state. */
2016 draw_context
.drawable
= drawing
->pixmap
;
2017 draw_context
.gc
= drawing
->gc
;
2018 draw_context
.pango_layout
= drawing
->pango_layout
;
2019 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2020 draw_context
.drawinfo
.end
.x
= x
;
2022 draw_context
.drawinfo
.y
.over
= y
+1;
2023 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2024 draw_context
.drawinfo
.y
.under
= y
+height
;
2026 draw_context
.drawinfo
.start
.offset
.over
= 0;
2027 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2028 draw_context
.drawinfo
.start
.offset
.under
= 0;
2029 draw_context
.drawinfo
.end
.offset
.over
= 0;
2030 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2031 draw_context
.drawinfo
.end
.offset
.under
= 0;
2035 PropertiesLine prop_line
= prepare_s_e_line(process
);
2036 draw_line((void*)&prop_line
, (void*)&draw_context
);
2039 /* become the last x position */
2040 hashed_process_data
->x
.middle
= x
;
2041 hashed_process_data
->x
.middle_used
= TRUE
;
2042 hashed_process_data
->x
.middle_marked
= FALSE
;
2049 /* after_execmode_hook
2051 * The draw after hook is called by the reading API to have a
2052 * particular event drawn on the screen.
2053 * @param hook_data ControlFlowData structure of the viewer.
2054 * @param call_data Event context.
2056 * This function adds items to be drawn in a queue for each process.
2059 int after_execmode_hook(void *hook_data
, void *call_data
)
2061 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2062 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2064 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2066 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2067 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2072 LttTime evtime
= ltt_event_time(e
);
2073 TimeWindow time_window
=
2074 lttvwindow_get_time_window(control_flow_data
->tab
);
2076 LttTime end_time
= time_window
.end_time
;
2079 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2080 || ltt_time_compare(evtime
, end_time
) == 1)
2082 #endif //EXTRA_CHECK
2084 guint width
= control_flow_data
->drawing
->width
;
2086 /* Add process to process list (if not present) */
2087 LttvProcessState
*process
;
2089 guint y
= 0, height
= 0, pl_height
= 0;
2090 HashedProcessData
*hashed_process_data
= NULL
;
2092 ProcessList
*process_list
= control_flow_data
->process_list
;
2094 /* Find process pid_in in the list... */
2095 process
= tfs
->process
;
2096 /* It should exist, because we are after the state update. */
2097 g_assert(process
!= NULL
);
2099 guint pid
= process
->pid
;
2101 birth
= process
->creation_time
;
2102 const gchar
*name
= g_quark_to_string(process
->name
);
2104 if(processlist_get_process_pixels(process_list
,
2108 tfc
->t_context
->index
,
2111 &hashed_process_data
) == 1)
2113 g_assert(pid
== 0 || pid
!= process
->ppid
);
2114 /* Process not present */
2115 processlist_add(process_list
,
2120 tfc
->t_context
->index
,
2123 &hashed_process_data
);
2124 processlist_get_process_pixels(process_list
,
2128 tfc
->t_context
->index
,
2131 &hashed_process_data
);
2132 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2137 convert_time_to_pixels(
2143 if(hashed_process_data
->x
.middle
!= new_x
) {
2144 hashed_process_data
->x
.middle
= new_x
;
2145 hashed_process_data
->x
.middle_used
= FALSE
;
2146 hashed_process_data
->x
.middle_marked
= FALSE
;
2154 /* before_process_hook
2156 * Draw lines for process event.
2158 * @param hook_data ControlFlowData structure of the viewer.
2159 * @param call_data Event context.
2161 * This function adds items to be drawn in a queue for each process.
2164 int before_process_hook(void *hook_data
, void *call_data
)
2166 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2167 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2168 Drawing_t
*drawing
= control_flow_data
->drawing
;
2170 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2172 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2173 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2178 LttTime evtime
= ltt_event_time(e
);
2179 TimeWindow time_window
=
2180 lttvwindow_get_time_window(control_flow_data
->tab
);
2182 LttTime end_time
= time_window
.end_time
;
2185 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2186 || ltt_time_compare(evtime
, end_time
) == 1)
2188 #endif //EXTRA_CHECK
2190 guint width
= control_flow_data
->drawing
->width
;
2194 LttField
*f
= ltt_event_field(e
);
2196 element
= ltt_field_member(f
,0);
2197 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2200 if(sub_id
== 3) { /* exit */
2202 /* Add process to process list (if not present) */
2203 LttvProcessState
*process
= tfs
->process
;
2204 guint pid
= process
->pid
;
2206 guint y
= 0, height
= 0, pl_height
= 0;
2207 HashedProcessData
*hashed_process_data
= NULL
;
2209 ProcessList
*process_list
= control_flow_data
->process_list
;
2211 g_assert(process
!= NULL
);
2213 birth
= process
->creation_time
;
2214 const gchar
*name
= g_quark_to_string(process
->name
);
2216 if(processlist_get_process_pixels(process_list
,
2220 tfc
->t_context
->index
,
2223 &hashed_process_data
) == 1)
2225 g_assert(pid
== 0 || pid
!= process
->ppid
);
2226 /* Process not present */
2227 processlist_add(process_list
,
2232 tfc
->t_context
->index
,
2235 &hashed_process_data
);
2236 processlist_get_process_pixels(process_list
,
2240 tfc
->t_context
->index
,
2243 &hashed_process_data
);
2244 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2247 /* Now, the process is in the state hash and our own process hash.
2248 * We definitely can draw the items related to the ending state.
2251 /* Check if the x position is unset. In can have been left unset by
2252 * a draw closure from a after chunk hook. This should never happen,
2253 * because it must be set by before chunk hook to the damage_begin
2256 g_assert(hashed_process_data
->x
.over
!= -1);
2260 convert_time_to_pixels(
2267 /* Jump over draw if we are at the same x position */
2268 if(x
== hashed_process_data
->x
.middle
&&
2269 hashed_process_data
->x
.middle_used
)
2271 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2272 /* Draw collision indicator */
2273 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2274 gdk_draw_point(drawing
->pixmap
,
2278 hashed_process_data
->x
.middle_marked
= TRUE
;
2282 DrawContext draw_context
;
2284 /* Now create the drawing context that will be used to draw
2285 * items related to the last state. */
2286 draw_context
.drawable
= drawing
->pixmap
;
2287 draw_context
.gc
= drawing
->gc
;
2288 draw_context
.pango_layout
= drawing
->pango_layout
;
2289 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2290 draw_context
.drawinfo
.end
.x
= x
;
2292 draw_context
.drawinfo
.y
.over
= y
+1;
2293 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2294 draw_context
.drawinfo
.y
.under
= y
+height
;
2296 draw_context
.drawinfo
.start
.offset
.over
= 0;
2297 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2298 draw_context
.drawinfo
.start
.offset
.under
= 0;
2299 draw_context
.drawinfo
.end
.offset
.over
= 0;
2300 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2301 draw_context
.drawinfo
.end
.offset
.under
= 0;
2305 PropertiesLine prop_line
= prepare_s_e_line(process
);
2306 draw_line((void*)&prop_line
, (void*)&draw_context
);
2309 /* become the last x position */
2310 hashed_process_data
->x
.middle
= x
;
2311 hashed_process_data
->x
.middle_used
= TRUE
;
2312 hashed_process_data
->x
.middle_marked
= FALSE
;
2326 /* after_process_hook
2328 * Create the processlist entry for the child process. Put the last
2329 * position in x at the current time value.
2331 * @param hook_data ControlFlowData structure of the viewer.
2332 * @param call_data Event context.
2334 * This function adds items to be drawn in a queue for each process.
2337 int after_process_hook(void *hook_data
, void *call_data
)
2339 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2340 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2342 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2344 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2345 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2350 LttTime evtime
= ltt_event_time(e
);
2351 TimeWindow time_window
=
2352 lttvwindow_get_time_window(control_flow_data
->tab
);
2354 LttTime end_time
= time_window
.end_time
;
2357 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2358 || ltt_time_compare(evtime
, end_time
) == 1)
2360 #endif //EXTRA_CHECK
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(
2432 if(hashed_process_data_child
->x
.over
!= new_x
) {
2433 hashed_process_data_child
->x
.over
= new_x
;
2434 hashed_process_data_child
->x
.over_used
= FALSE
;
2435 hashed_process_data_child
->x
.over_marked
= FALSE
;
2437 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2438 hashed_process_data_child
->x
.middle
= new_x
;
2439 hashed_process_data_child
->x
.middle_used
= FALSE
;
2440 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2442 if(hashed_process_data_child
->x
.under
!= new_x
) {
2443 hashed_process_data_child
->x
.under
= new_x
;
2444 hashed_process_data_child
->x
.under_used
= FALSE
;
2445 hashed_process_data_child
->x
.under_marked
= FALSE
;
2448 } else if(sub_id
== 3) { /* exit */
2450 /* Add process to process list (if not present) */
2451 LttvProcessState
*process
= tfs
->process
;
2452 guint pid
= process
->pid
;
2454 guint y
= 0, height
= 0, pl_height
= 0;
2455 HashedProcessData
*hashed_process_data
= NULL
;
2457 ProcessList
*process_list
= control_flow_data
->process_list
;
2459 /* It should exist, because we are after the state update. */
2460 g_assert(process
!= NULL
);
2462 birth
= process
->creation_time
;
2463 const gchar
*name
= g_quark_to_string(process
->name
);
2465 if(processlist_get_process_pixels(process_list
,
2469 tfc
->t_context
->index
,
2472 &hashed_process_data
) == 1)
2474 g_assert(pid
== 0 || pid
!= process
->ppid
);
2475 /* Process not present */
2476 processlist_add(process_list
,
2481 tfc
->t_context
->index
,
2484 &hashed_process_data
);
2485 processlist_get_process_pixels(process_list
,
2489 tfc
->t_context
->index
,
2492 &hashed_process_data
);
2493 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2497 convert_time_to_pixels(
2502 if(hashed_process_data
->x
.middle
!= new_x
) {
2503 hashed_process_data
->x
.middle
= new_x
;
2504 hashed_process_data
->x
.middle_used
= FALSE
;
2505 hashed_process_data
->x
.middle_marked
= FALSE
;
2515 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2517 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2518 Drawing_t
*drawing
= control_flow_data
->drawing
;
2520 const TimeWindowNotifyData
*time_window_nofify_data
=
2521 ((const TimeWindowNotifyData
*)call_data
);
2523 TimeWindow
*old_time_window
=
2524 time_window_nofify_data
->old_time_window
;
2525 TimeWindow
*new_time_window
=
2526 time_window_nofify_data
->new_time_window
;
2528 /* Update the ruler */
2529 drawing_update_ruler(control_flow_data
->drawing
,
2533 /* Two cases : zoom in/out or scrolling */
2535 /* In order to make sure we can reuse the old drawing, the scale must
2536 * be the same and the new time interval being partly located in the
2537 * currently shown time interval. (reuse is only for scrolling)
2540 g_info("Old time window HOOK : %u, %u to %u, %u",
2541 old_time_window
->start_time
.tv_sec
,
2542 old_time_window
->start_time
.tv_nsec
,
2543 old_time_window
->time_width
.tv_sec
,
2544 old_time_window
->time_width
.tv_nsec
);
2546 g_info("New time window HOOK : %u, %u to %u, %u",
2547 new_time_window
->start_time
.tv_sec
,
2548 new_time_window
->start_time
.tv_nsec
,
2549 new_time_window
->time_width
.tv_sec
,
2550 new_time_window
->time_width
.tv_nsec
);
2552 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2553 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2555 /* Same scale (scrolling) */
2556 g_info("scrolling");
2557 LttTime
*ns
= &new_time_window
->start_time
;
2558 LttTime
*nw
= &new_time_window
->time_width
;
2559 LttTime
*os
= &old_time_window
->start_time
;
2560 LttTime
*ow
= &old_time_window
->time_width
;
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(
2579 /* Copy old data to new location */
2580 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2581 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2582 control_flow_data
->drawing
->pixmap
,
2585 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2587 if(drawing
->damage_begin
== drawing
->damage_end
)
2588 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2590 drawing
->damage_begin
= 0;
2592 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2594 /* Clear the data request background, but not SAFETY */
2595 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2596 //control_flow_data->drawing->drawing_area->style->black_gc,
2597 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2599 drawing
->damage_begin
+SAFETY
, 0,
2600 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2601 control_flow_data
->drawing
->height
);
2603 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2605 control_flow_data
->drawing
->width
,
2606 control_flow_data
->drawing
->height
);
2608 /* Get new data for the rest. */
2609 drawing_data_request(control_flow_data
->drawing
,
2610 &control_flow_data
->drawing
->pixmap
,
2611 drawing
->damage_begin
, 0,
2612 drawing
->damage_end
- drawing
->damage_begin
,
2613 control_flow_data
->drawing
->height
);
2616 //if(ns<os && os<ns+w)
2617 //if(ns<os && os<new_end)
2618 if(ltt_time_compare(*ns
,*os
) == -1
2619 && ltt_time_compare(*os
,new_end
) == -1)
2621 g_info("scrolling near left");
2622 /* Scroll left, keep left part of the screen */
2624 guint width
= control_flow_data
->drawing
->width
;
2625 convert_time_to_pixels(
2632 /* Copy old data to new location */
2633 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2634 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2635 control_flow_data
->drawing
->pixmap
,
2640 if(drawing
->damage_begin
== drawing
->damage_end
)
2641 drawing
->damage_end
= x
;
2643 drawing
->damage_end
=
2644 control_flow_data
->drawing
->width
;
2646 drawing
->damage_begin
= 0;
2648 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2649 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2651 drawing
->damage_begin
, 0,
2652 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2653 control_flow_data
->drawing
->height
);
2655 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2657 control_flow_data
->drawing
->width
,
2658 control_flow_data
->drawing
->height
);
2661 /* Get new data for the rest. */
2662 drawing_data_request(control_flow_data
->drawing
,
2663 &control_flow_data
->drawing
->pixmap
,
2664 drawing
->damage_begin
, 0,
2665 drawing
->damage_end
- drawing
->damage_begin
,
2666 control_flow_data
->drawing
->height
);
2669 if(ltt_time_compare(*ns
,*os
) == 0)
2671 g_info("not scrolling");
2673 g_info("scrolling far");
2674 /* Cannot reuse any part of the screen : far jump */
2677 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2678 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2681 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2682 control_flow_data
->drawing
->height
);
2684 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2686 control_flow_data
->drawing
->width
,
2687 control_flow_data
->drawing
->height
);
2689 drawing
->damage_begin
= 0;
2690 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2692 drawing_data_request(control_flow_data
->drawing
,
2693 &control_flow_data
->drawing
->pixmap
,
2695 control_flow_data
->drawing
->width
,
2696 control_flow_data
->drawing
->height
);
2702 /* Different scale (zoom) */
2705 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2706 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2709 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2710 control_flow_data
->drawing
->height
);
2712 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2714 control_flow_data
->drawing
->width
,
2715 control_flow_data
->drawing
->height
);
2717 drawing
->damage_begin
= 0;
2718 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2720 drawing_data_request(control_flow_data
->drawing
,
2721 &control_flow_data
->drawing
->pixmap
,
2723 control_flow_data
->drawing
->width
,
2724 control_flow_data
->drawing
->height
);
2732 gint
traceset_notify(void *hook_data
, void *call_data
)
2734 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2735 Drawing_t
*drawing
= control_flow_data
->drawing
;
2736 GtkWidget
*widget
= drawing
->drawing_area
;
2739 drawing_clear(control_flow_data
->drawing
);
2740 processlist_clear(control_flow_data
->process_list
);
2741 redraw_notify(control_flow_data
, NULL
);
2743 request_background_data(control_flow_data
);
2745 drawing
->damage_begin
= 0;
2746 drawing
->damage_end
= drawing
->width
;
2747 if(drawing
->damage_begin
< drawing
->damage_end
)
2749 drawing_data_request(drawing
,
2751 drawing
->damage_begin
,
2753 drawing
->damage_end
-drawing
->damage_begin
,
2757 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2766 gint
redraw_notify(void *hook_data
, void *call_data
)
2768 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2769 Drawing_t
*drawing
= control_flow_data
->drawing
;
2770 GtkWidget
*widget
= drawing
->drawing_area
;
2772 drawing
->damage_begin
= 0;
2773 drawing
->damage_end
= drawing
->width
;
2775 /* fun feature, to be separated someday... */
2776 drawing_clear(control_flow_data
->drawing
);
2777 processlist_clear(control_flow_data
->process_list
);
2780 gdk_draw_rectangle (drawing
->pixmap
,
2781 widget
->style
->black_gc
,
2784 drawing
->width
+SAFETY
,
2788 if(drawing
->damage_begin
< drawing
->damage_end
)
2790 drawing_data_request(drawing
,
2792 drawing
->damage_begin
,
2794 drawing
->damage_end
-drawing
->damage_begin
,
2798 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2807 gint
continue_notify(void *hook_data
, void *call_data
)
2809 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2810 Drawing_t
*drawing
= control_flow_data
->drawing
;
2811 GtkWidget
*widget
= drawing
->drawing_area
;
2813 //g_assert(widget->allocation.width == drawing->damage_end);
2815 if(drawing
->damage_begin
< drawing
->damage_end
)
2817 drawing_data_request(drawing
,
2819 drawing
->damage_begin
,
2821 drawing
->damage_end
-drawing
->damage_begin
,
2829 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2831 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2832 Drawing_t
*drawing
= control_flow_data
->drawing
;
2834 LttTime current_time
= *((LttTime
*)call_data
);
2836 TimeWindow time_window
=
2837 lttvwindow_get_time_window(control_flow_data
->tab
);
2839 LttTime time_begin
= time_window
.start_time
;
2840 LttTime width
= time_window
.time_width
;
2843 guint64 time_ll
= ltt_time_to_uint64(width
);
2844 time_ll
= time_ll
>> 1; /* divide by two */
2845 half_width
= ltt_time_from_uint64(time_ll
);
2847 LttTime time_end
= ltt_time_add(time_begin
, width
);
2849 LttvTracesetContext
* tsc
=
2850 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2852 LttTime trace_start
= tsc
->time_span
.start_time
;
2853 LttTime trace_end
= tsc
->time_span
.end_time
;
2855 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2856 current_time
.tv_nsec
);
2860 /* If current time is inside time interval, just move the highlight
2863 /* Else, we have to change the time interval. We have to tell it
2864 * to the main window. */
2865 /* The time interval change will take care of placing the current
2866 * time at the center of the visible area, or nearest possible if we are
2867 * at one end of the trace. */
2870 if(ltt_time_compare(current_time
, time_begin
) == -1)
2872 TimeWindow new_time_window
;
2874 if(ltt_time_compare(current_time
,
2875 ltt_time_add(trace_start
,half_width
)) == -1)
2876 time_begin
= trace_start
;
2878 time_begin
= ltt_time_sub(current_time
,half_width
);
2880 new_time_window
.start_time
= time_begin
;
2881 new_time_window
.time_width
= width
;
2882 new_time_window
.time_width_double
= ltt_time_to_double(width
);
2883 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2885 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2887 else if(ltt_time_compare(current_time
, time_end
) == 1)
2889 TimeWindow new_time_window
;
2891 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2892 time_begin
= ltt_time_sub(trace_end
,width
);
2894 time_begin
= ltt_time_sub(current_time
,half_width
);
2896 new_time_window
.start_time
= time_begin
;
2897 new_time_window
.time_width
= width
;
2898 new_time_window
.time_width_double
= ltt_time_to_double(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
;
2940 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2941 || ltt_time_compare(evtime
, end_time
) == 1)
2943 #endif //EXTRA_CHECK
2945 guint width
= drawing
->width
;
2948 /* For the process */
2949 /* First, check if the current process is in the state computation
2950 * process list. If it is there, that means we must add it right now and
2951 * draw items from the beginning of the read for it. If it is not
2952 * present, it's a new process and it was not present : it will
2953 * be added after the state update. */
2954 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2956 /* tracefiles[0] is ok here, because we draw for every PID, and
2957 * assume CPU 0 for PID 0 //FIXME */
2958 LttvTracefileState
*tfs
=
2959 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2961 LttvProcessState
*process
;
2962 process
= lttv_state_find_process(tfs
,
2965 if(process
!= NULL
) {
2967 /* Only draw for processes that are currently in the trace states */
2969 guint y
= 0, height
= 0, pl_height
= 0;
2970 ProcessList
*process_list
= control_flow_data
->process_list
;
2971 LttTime birth
= process_info
->birth
;
2973 /* Should be alike when background info is ready */
2974 if(control_flow_data
->background_info_waiting
==0)
2975 g_assert(ltt_time_compare(process
->creation_time
,
2976 process_info
->birth
) == 0);
2977 const gchar
*name
= g_quark_to_string(process
->name
);
2979 /* process HAS to be present */
2980 g_assert(processlist_get_process_pixels(process_list
,
2984 process_info
->trace_num
,
2987 &hashed_process_data
) != 1);
2989 /* Now, the process is in the state hash and our own process hash.
2990 * We definitely can draw the items related to the ending state.
2993 /* Check if the x position is unset. In can have been left unset by
2994 * a draw closure from a after chunk hook. This should never happen,
2995 * because it must be set by before chunk hook to the damage_begin
2998 g_assert(hashed_process_data
->x
.over
!= -1);
3002 convert_time_to_pixels(
3008 DrawContext draw_context
;
3010 /* Now create the drawing context that will be used to draw
3011 * items related to the last state. */
3012 draw_context
.drawable
= drawing
->pixmap
;
3013 draw_context
.gc
= drawing
->gc
;
3014 draw_context
.pango_layout
= drawing
->pango_layout
;
3015 draw_context
.drawinfo
.end
.x
= x
;
3017 draw_context
.drawinfo
.y
.over
= y
+1;
3018 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3019 draw_context
.drawinfo
.y
.under
= y
+height
;
3021 draw_context
.drawinfo
.start
.offset
.over
= 0;
3022 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3023 draw_context
.drawinfo
.start
.offset
.under
= 0;
3024 draw_context
.drawinfo
.end
.offset
.over
= 0;
3025 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3026 draw_context
.drawinfo
.end
.offset
.under
= 0;
3028 /* Jump over draw if we are at the same x position */
3029 if(x
== hashed_process_data
->x
.over
)
3033 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3035 PropertiesLine prop_line
= prepare_execmode_line(process
);
3036 draw_line((void*)&prop_line
, (void*)&draw_context
);
3038 hashed_process_data
->x
.over
= x
;
3042 if(x
== hashed_process_data
->x
.middle
&&
3043 hashed_process_data
->x
.middle_used
) {
3044 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3045 /* Draw collision indicator */
3046 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3047 gdk_draw_point(drawing
->pixmap
,
3051 hashed_process_data
->x
.middle_marked
= TRUE
;
3055 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3057 PropertiesLine prop_line
= prepare_s_e_line(process
);
3058 draw_line((void*)&prop_line
, (void*)&draw_context
);
3060 /* become the last x position */
3061 if(x
!= hashed_process_data
->x
.middle
) {
3062 hashed_process_data
->x
.middle
= x
;
3063 /* but don't use the pixel */
3064 hashed_process_data
->x
.middle_used
= FALSE
;
3073 int before_chunk(void *hook_data
, void *call_data
)
3075 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3076 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3078 drawing_chunk_begin(events_request
, tss
);
3083 int before_request(void *hook_data
, void *call_data
)
3085 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3086 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3088 drawing_data_request_begin(events_request
, tss
);
3095 * after request is necessary in addition of after chunk in order to draw
3096 * lines until the end of the screen. after chunk just draws lines until
3103 int after_request(void *hook_data
, void *call_data
)
3105 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3106 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3107 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3108 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3110 ProcessList
*process_list
= control_flow_data
->process_list
;
3111 LttTime end_time
= events_request
->end_time
;
3113 ClosureData closure_data
;
3114 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3115 closure_data
.tss
= tss
;
3116 closure_data
.end_time
= end_time
;
3118 /* Draw last items */
3119 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3120 (void*)&closure_data
);
3122 /* Request expose */
3123 drawing_request_expose(events_request
, tss
, end_time
);
3132 int after_chunk(void *hook_data
, void *call_data
)
3134 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3135 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3136 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3137 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3138 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3141 ProcessList
*process_list
= control_flow_data
->process_list
;
3144 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3145 else /* end of traceset, or position now out of request : end */
3146 end_time
= events_request
->end_time
;
3148 ClosureData closure_data
;
3149 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3150 closure_data
.tss
= tss
;
3151 closure_data
.end_time
= end_time
;
3153 /* Draw last items */
3154 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3155 (void*)&closure_data
);
3157 /* Request expose */
3158 drawing_request_expose(events_request
, tss
, end_time
);