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
);
431 //process = tfs->process;
433 if(process
!= NULL
) {
434 /* Well, the process_out existed : we must get it in the process hash
435 * or add it, and draw its items.
437 /* Add process to process list (if not present) */
438 guint y
= 0, height
= 0, pl_height
= 0;
439 HashedProcessData
*hashed_process_data
= NULL
;
440 ProcessList
*process_list
= control_flow_data
->process_list
;
441 LttTime birth
= process
->creation_time
;
442 const gchar
*name
= g_quark_to_string(process
->name
);
444 if(processlist_get_process_pixels(process_list
,
448 tfc
->t_context
->index
,
451 &hashed_process_data
) == 1)
453 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
454 /* Process not present */
455 ProcessInfo
*process_info
;
456 processlist_add(process_list
,
461 tfc
->t_context
->index
,
465 &hashed_process_data
);
466 processlist_get_pixels_from_data(process_list
,
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);
484 if(ltt_time_compare(hashed_process_data
->next_good_time
,
487 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
489 convert_time_to_pixels(
495 /* Draw collision indicator */
496 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
497 gdk_draw_point(drawing
->pixmap
,
501 hashed_process_data
->x
.middle_marked
= TRUE
;
505 convert_time_to_pixels(
512 /* Jump over draw if we are at the same x position */
513 if(x
== hashed_process_data
->x
.middle
&&
514 hashed_process_data
->x
.middle_used
)
516 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
517 /* Draw collision indicator */
518 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
519 gdk_draw_point(drawing
->pixmap
,
523 hashed_process_data
->x
.middle_marked
= TRUE
;
527 DrawContext draw_context
;
529 /* Now create the drawing context that will be used to draw
530 * items related to the last state. */
531 draw_context
.drawable
= drawing
->pixmap
;
532 draw_context
.gc
= drawing
->gc
;
533 draw_context
.pango_layout
= drawing
->pango_layout
;
534 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
535 draw_context
.drawinfo
.end
.x
= x
;
537 draw_context
.drawinfo
.y
.over
= y
+1;
538 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
539 draw_context
.drawinfo
.y
.under
= y
+height
;
541 draw_context
.drawinfo
.start
.offset
.over
= 0;
542 draw_context
.drawinfo
.start
.offset
.middle
= 0;
543 draw_context
.drawinfo
.start
.offset
.under
= 0;
544 draw_context
.drawinfo
.end
.offset
.over
= 0;
545 draw_context
.drawinfo
.end
.offset
.middle
= 0;
546 draw_context
.drawinfo
.end
.offset
.under
= 0;
550 PropertiesLine prop_line
= prepare_s_e_line(process
);
551 draw_line((void*)&prop_line
, (void*)&draw_context
);
554 /* become the last x position */
555 hashed_process_data
->x
.middle
= x
;
556 hashed_process_data
->x
.middle_used
= TRUE
;
557 hashed_process_data
->x
.middle_marked
= FALSE
;
559 /* Calculate the next good time */
560 convert_pixels_to_time(width
, x
+1, time_window
,
561 &hashed_process_data
->next_good_time
);
569 /* First, check if the current process is in the state computation
570 * process list. If it is there, that means we must add it right now and
571 * draw items from the beginning of the read for it. If it is not
572 * present, it's a new process and it was not present : it will
573 * be added after the state update. */
574 LttvProcessState
*process
;
575 process
= lttv_state_find_process(tfs
, pid_in
);
577 if(process
!= NULL
) {
578 /* Well, the process_out existed : we must get it in the process hash
579 * or add it, and draw its items.
581 /* Add process to process list (if not present) */
582 guint y
= 0, height
= 0, pl_height
= 0;
583 HashedProcessData
*hashed_process_data
= NULL
;
584 ProcessList
*process_list
= control_flow_data
->process_list
;
585 LttTime birth
= process
->creation_time
;
586 const gchar
*name
= g_quark_to_string(process
->name
);
588 if(processlist_get_process_pixels(process_list
,
592 tfc
->t_context
->index
,
595 &hashed_process_data
) == 1)
597 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
598 /* Process not present */
599 ProcessInfo
*process_info
;
600 processlist_add(process_list
,
605 tfc
->t_context
->index
,
609 &hashed_process_data
);
610 processlist_get_pixels_from_data(process_list
,
615 drawing_insert_square( drawing
, y
, height
);
618 /* Now, the process is in the state hash and our own process hash.
619 * We definitely can draw the items related to the ending state.
622 /* Check if the x position is unset. In can have been left unset by
623 * a draw closure from a after chunk hook. This should never happen,
624 * because it must be set by before chunk hook to the damage_begin
627 g_assert(hashed_process_data
->x
.middle
!= -1);
629 if(ltt_time_compare(hashed_process_data
->next_good_time
,
632 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
634 convert_time_to_pixels(
640 /* Draw collision indicator */
641 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
642 gdk_draw_point(drawing
->pixmap
,
646 hashed_process_data
->x
.middle_marked
= TRUE
;
651 convert_time_to_pixels(
658 /* Jump over draw if we are at the same x position */
659 if(x
== hashed_process_data
->x
.middle
&&
660 hashed_process_data
->x
.middle_used
)
662 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
663 /* Draw collision indicator */
664 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
665 gdk_draw_point(drawing
->pixmap
,
669 hashed_process_data
->x
.middle_marked
= TRUE
;
673 DrawContext draw_context
;
675 /* Now create the drawing context that will be used to draw
676 * items related to the last state. */
677 draw_context
.drawable
= drawing
->pixmap
;
678 draw_context
.gc
= drawing
->gc
;
679 draw_context
.pango_layout
= drawing
->pango_layout
;
680 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
681 draw_context
.drawinfo
.end
.x
= x
;
683 draw_context
.drawinfo
.y
.over
= y
+1;
684 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
685 draw_context
.drawinfo
.y
.under
= y
+height
;
687 draw_context
.drawinfo
.start
.offset
.over
= 0;
688 draw_context
.drawinfo
.start
.offset
.middle
= 0;
689 draw_context
.drawinfo
.start
.offset
.under
= 0;
690 draw_context
.drawinfo
.end
.offset
.over
= 0;
691 draw_context
.drawinfo
.end
.offset
.middle
= 0;
692 draw_context
.drawinfo
.end
.offset
.under
= 0;
696 PropertiesLine prop_line
= prepare_s_e_line(process
);
697 draw_line((void*)&prop_line
, (void*)&draw_context
);
701 /* become the last x position */
702 hashed_process_data
->x
.middle
= x
;
703 hashed_process_data
->x
.middle_used
= TRUE
;
704 hashed_process_data
->x
.middle_marked
= FALSE
;
706 /* Calculate the next good time */
707 convert_pixels_to_time(width
, x
+1, time_window
,
708 &hashed_process_data
->next_good_time
);
717 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
718 ControlFlowData
*control_flow_data
=
719 (ControlFlowData
*)events_request
->viewer_data
;
720 Tab
*tab
= control_flow_data
->tab
;
722 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
724 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
725 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
730 LttTime evtime
= ltt_event_time(e
);
731 TimeWindow time_window
=
732 lttvwindow_get_time_window(tab
);
734 LttTime end_time
= time_window
.end_time
;
736 //if(time < time_beg || time > time_end) return;
737 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
738 || ltt_time_compare(evtime
, end_time
) == 1)
741 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
743 g_debug("schedchange!");
745 /* Add process to process list (if not present) and get drawing "y" from
746 * process position */
747 guint pid_out
, pid_in
;
748 LttvProcessState
*process_out
, *process_in
;
750 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
752 ProcessList
*process_list
= control_flow_data
->process_list
;
755 LttField
*f
= ltt_event_field(e
);
757 element
= ltt_field_member(f
,0);
758 pid_out
= ltt_event_get_long_unsigned(e
,element
);
759 element
= ltt_field_member(f
,1);
760 pid_in
= ltt_event_get_long_unsigned(e
,element
);
761 g_debug("out : %u in : %u", pid_out
, pid_in
);
764 /* Find process pid_out in the list... */
765 process_out
= lttv_state_find_process(tfs
, pid_out
);
766 if(process_out
== NULL
) return 0;
767 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
769 birth
= process_out
->creation_time
;
770 const gchar
*name
= g_quark_to_string(process_out
->name
);
771 HashedProcessData
*hashed_process_data_out
= NULL
;
773 if(processlist_get_process_pixels(process_list
,
776 tfc
->t_context
->index
,
779 &hashed_process_data_out
) == 1)
781 /* Process not present */
782 processlist_add(process_list
,
785 tfc
->t_context
->index
,
788 &hashed_process_data_out
);
789 g_assert(processlist_get_process_pixels(process_list
,
792 tfc
->t_context
->index
,
795 &hashed_process_data_out
)==0);
796 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
800 /* Find process pid_in in the list... */
801 process_in
= lttv_state_find_process(tfs
, pid_in
);
802 if(process_in
== NULL
) return 0;
803 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
805 birth
= process_in
->creation_time
;
806 name
= g_quark_to_string(process_in
->name
);
807 HashedProcessData
*hashed_process_data_in
= NULL
;
809 if(processlist_get_process_pixels(process_list
,
812 tfc
->t_context
->index
,
815 &hashed_process_data_in
) == 1)
817 /* Process not present */
818 processlist_add(process_list
,
821 tfc
->t_context
->index
,
824 &hashed_process_data_in
);
825 processlist_get_process_pixels(process_list
,
828 tfc
->t_context
->index
,
831 &hashed_process_data_in
);
833 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
838 /* Find pixels corresponding to time of the event. If the time does
839 * not fit in the window, show a warning, not supposed to happend. */
841 guint width
= control_flow_data
->drawing
->width
;
843 LttTime time
= ltt_event_time(e
);
845 LttTime window_end
= time_window
.end_time
;
847 convert_time_to_pixels(
852 //assert(x <= width);
854 /* draw what represents the event for outgoing process. */
856 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
857 draw_context_out
->current
->modify_over
->x
= x
;
858 draw_context_out
->current
->modify_under
->x
= x
;
859 draw_context_out
->current
->modify_over
->y
= y_out
;
860 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
861 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
862 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
863 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
864 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
865 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
866 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
867 //draw_context_out->gc = widget->style->black_gc;
869 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
870 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
872 /* Draw the line/background of the out process */
873 if(draw_context_out
->previous
->middle
->x
== -1)
875 draw_context_out
->previous
->over
->x
=
876 control_flow_data
->drawing
->damage_begin
;
877 draw_context_out
->previous
->middle
->x
=
878 control_flow_data
->drawing
->damage_begin
;
879 draw_context_out
->previous
->under
->x
=
880 control_flow_data
->drawing
->damage_begin
;
882 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
885 draw_context_out
->current
->middle
->x
= x
;
886 draw_context_out
->current
->over
->x
= x
;
887 draw_context_out
->current
->under
->x
= x
;
888 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
889 draw_context_out
->current
->over
->y
= y_out
;
890 draw_context_out
->current
->under
->y
= y_out
+ height
;
891 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
892 draw_context_out
->previous
->over
->y
= y_out
;
893 draw_context_out
->previous
->under
->y
= y_out
+ height
;
895 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
896 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
898 if(process_out
->state
->s
== LTTV_STATE_RUN
)
900 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
901 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
902 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
904 PropertiesBG prop_bg
;
905 prop_bg
.color
= g_new(GdkColor
,1);
909 prop_bg
.color
->red
= 0x1515;
910 prop_bg
.color
->green
= 0x1515;
911 prop_bg
.color
->blue
= 0x8c8c;
914 prop_bg
.color
->red
= 0x4e4e;
915 prop_bg
.color
->green
= 0xa9a9;
916 prop_bg
.color
->blue
= 0xa4a4;
919 prop_bg
.color
->red
= 0x7a7a;
920 prop_bg
.color
->green
= 0x4a4a;
921 prop_bg
.color
->blue
= 0x8b8b;
924 prop_bg
.color
->red
= 0x8080;
925 prop_bg
.color
->green
= 0x7777;
926 prop_bg
.color
->blue
= 0x4747;
929 prop_bg
.color
->red
= 0xe7e7;
930 prop_bg
.color
->green
= 0xe7e7;
931 prop_bg
.color
->blue
= 0xe7e7;
934 g_debug("calling from draw_event");
935 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
936 g_free(prop_bg
.color
);
937 //gdk_gc_unref(draw_context_out->gc);
940 draw_context_out
->gc
= widget
->style
->black_gc
;
942 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
943 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
944 PropertiesText prop_text_out
;
945 prop_text_out
.foreground
= &colorfg_out
;
946 prop_text_out
.background
= &colorbg_out
;
947 prop_text_out
.size
= 6;
948 prop_text_out
.position
= OVER
;
950 /* color of text : status of the process */
951 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
953 prop_text_out
.foreground
->red
= 0xffff;
954 prop_text_out
.foreground
->green
= 0xffff;
955 prop_text_out
.foreground
->blue
= 0xffff;
957 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
959 prop_text_out
.foreground
->red
= 0x0fff;
960 prop_text_out
.foreground
->green
= 0xffff;
961 prop_text_out
.foreground
->blue
= 0xfff0;
963 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
965 prop_text_out
.foreground
->red
= 0xffff;
966 prop_text_out
.foreground
->green
= 0xffff;
967 prop_text_out
.foreground
->blue
= 0x0000;
969 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
971 prop_text_out
.foreground
->red
= 0xffff;
972 prop_text_out
.foreground
->green
= 0x0000;
973 prop_text_out
.foreground
->blue
= 0xffff;
975 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
977 prop_text_out
.foreground
->red
= 0xffff;
978 prop_text_out
.foreground
->green
= 0x0000;
979 prop_text_out
.foreground
->blue
= 0x0000;
981 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
983 prop_text_out
.foreground
->red
= 0x0000;
984 prop_text_out
.foreground
->green
= 0xffff;
985 prop_text_out
.foreground
->blue
= 0x0000;
989 prop_text_out
.foreground
->red
= 0xffff;
990 prop_text_out
.foreground
->green
= 0xffff;
991 prop_text_out
.foreground
->blue
= 0xffff;
995 /* Print status of the process : U, WF, WC, E, W, R */
996 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
997 prop_text_out
.text
= "U->";
998 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
999 prop_text_out
.text
= "WF->";
1000 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1001 prop_text_out
.text
= "WC->";
1002 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1003 prop_text_out
.text
= "E->";
1004 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1005 prop_text_out
.text
= "W->";
1006 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1007 prop_text_out
.text
= "R->";
1009 prop_text_out
.text
= "U";
1011 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1012 //gdk_gc_unref(draw_context_out->gc);
1014 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1015 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1016 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
1018 PropertiesLine prop_line_out
;
1019 prop_line_out
.color
= g_new(GdkColor
,1);
1020 prop_line_out
.line_width
= 2;
1021 prop_line_out
.style
= GDK_LINE_SOLID
;
1022 prop_line_out
.position
= MIDDLE
;
1024 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
1026 /* color of line : status of the process */
1027 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1029 prop_line_out
.color
->red
= 0xffff;
1030 prop_line_out
.color
->green
= 0xffff;
1031 prop_line_out
.color
->blue
= 0xffff;
1033 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1035 prop_line_out
.color
->red
= 0x0fff;
1036 prop_line_out
.color
->green
= 0xffff;
1037 prop_line_out
.color
->blue
= 0xfff0;
1039 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1041 prop_line_out
.color
->red
= 0xffff;
1042 prop_line_out
.color
->green
= 0xffff;
1043 prop_line_out
.color
->blue
= 0x0000;
1045 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1047 prop_line_out
.color
->red
= 0xffff;
1048 prop_line_out
.color
->green
= 0x0000;
1049 prop_line_out
.color
->blue
= 0xffff;
1051 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1053 prop_line_out
.color
->red
= 0xffff;
1054 prop_line_out
.color
->green
= 0x0000;
1055 prop_line_out
.color
->blue
= 0x0000;
1057 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1059 prop_line_out
.color
->red
= 0x0000;
1060 prop_line_out
.color
->green
= 0xffff;
1061 prop_line_out
.color
->blue
= 0x0000;
1065 prop_line_out
.color
->red
= 0xffff;
1066 prop_line_out
.color
->green
= 0xffff;
1067 prop_line_out
.color
->blue
= 0xffff;
1070 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1071 g_free(prop_line_out
.color
);
1072 //gdk_gc_unref(draw_context_out->gc);
1073 /* Note : finishing line will have to be added when trace read over. */
1075 /* Finally, update the drawing context of the pid_in. */
1077 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1078 draw_context_in
->current
->modify_over
->x
= x
;
1079 draw_context_in
->current
->modify_under
->x
= x
;
1080 draw_context_in
->current
->modify_over
->y
= y_in
;
1081 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1082 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1083 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1084 widget
= control_flow_data
->drawing
->drawing_area
;
1085 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1086 //draw_context_in->gc = widget->style->black_gc;
1087 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1088 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1090 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1091 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1093 /* Draw the line/bg of the in process */
1094 if(draw_context_in
->previous
->middle
->x
== -1)
1096 draw_context_in
->previous
->over
->x
=
1097 control_flow_data
->drawing
->damage_begin
;
1098 draw_context_in
->previous
->middle
->x
=
1099 control_flow_data
->drawing
->damage_begin
;
1100 draw_context_in
->previous
->under
->x
=
1101 control_flow_data
->drawing
->damage_begin
;
1103 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1107 draw_context_in
->current
->middle
->x
= x
;
1108 draw_context_in
->current
->over
->x
= x
;
1109 draw_context_in
->current
->under
->x
= x
;
1110 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1111 draw_context_in
->current
->over
->y
= y_in
;
1112 draw_context_in
->current
->under
->y
= y_in
+ height
;
1113 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1114 draw_context_in
->previous
->over
->y
= y_in
;
1115 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1117 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1118 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1121 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1123 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1124 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1125 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1127 PropertiesBG prop_bg
;
1128 prop_bg
.color
= g_new(GdkColor
,1);
1130 switch(tfc
->index
) {
1132 prop_bg
.color
->red
= 0x1515;
1133 prop_bg
.color
->green
= 0x1515;
1134 prop_bg
.color
->blue
= 0x8c8c;
1137 prop_bg
.color
->red
= 0x4e4e;
1138 prop_bg
.color
->green
= 0xa9a9;
1139 prop_bg
.color
->blue
= 0xa4a4;
1142 prop_bg
.color
->red
= 0x7a7a;
1143 prop_bg
.color
->green
= 0x4a4a;
1144 prop_bg
.color
->blue
= 0x8b8b;
1147 prop_bg
.color
->red
= 0x8080;
1148 prop_bg
.color
->green
= 0x7777;
1149 prop_bg
.color
->blue
= 0x4747;
1152 prop_bg
.color
->red
= 0xe7e7;
1153 prop_bg
.color
->green
= 0xe7e7;
1154 prop_bg
.color
->blue
= 0xe7e7;
1158 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1159 g_free(prop_bg
.color
);
1160 //gdk_gc_unref(draw_context_in->gc);
1163 draw_context_in
->gc
= widget
->style
->black_gc
;
1165 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1166 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1167 PropertiesText prop_text_in
;
1168 prop_text_in
.foreground
= &colorfg_in
;
1169 prop_text_in
.background
= &colorbg_in
;
1170 prop_text_in
.size
= 6;
1171 prop_text_in
.position
= OVER
;
1173 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1174 /* foreground of text : status of the process */
1175 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1177 prop_text_in
.foreground
->red
= 0xffff;
1178 prop_text_in
.foreground
->green
= 0xffff;
1179 prop_text_in
.foreground
->blue
= 0xffff;
1181 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1183 prop_text_in
.foreground
->red
= 0x0fff;
1184 prop_text_in
.foreground
->green
= 0xffff;
1185 prop_text_in
.foreground
->blue
= 0xfff0;
1187 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1189 prop_text_in
.foreground
->red
= 0xffff;
1190 prop_text_in
.foreground
->green
= 0xffff;
1191 prop_text_in
.foreground
->blue
= 0x0000;
1193 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1195 prop_text_in
.foreground
->red
= 0xffff;
1196 prop_text_in
.foreground
->green
= 0x0000;
1197 prop_text_in
.foreground
->blue
= 0xffff;
1199 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1201 prop_text_in
.foreground
->red
= 0xffff;
1202 prop_text_in
.foreground
->green
= 0x0000;
1203 prop_text_in
.foreground
->blue
= 0x0000;
1205 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1207 prop_text_in
.foreground
->red
= 0x0000;
1208 prop_text_in
.foreground
->green
= 0xffff;
1209 prop_text_in
.foreground
->blue
= 0x0000;
1213 prop_text_in
.foreground
->red
= 0xffff;
1214 prop_text_in
.foreground
->green
= 0xffff;
1215 prop_text_in
.foreground
->blue
= 0xffff;
1220 /* Print status of the process : U, WF, WC, E, W, R */
1221 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1222 prop_text_in
.text
= "U->";
1223 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1224 prop_text_in
.text
= "WF->";
1225 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1226 prop_text_in
.text
= "WC->";
1227 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1228 prop_text_in
.text
= "E->";
1229 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1230 prop_text_in
.text
= "W->";
1231 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1232 prop_text_in
.text
= "R->";
1234 prop_text_in
.text
= "U";
1236 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1237 //gdk_gc_unref(draw_context_in->gc);
1239 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1240 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1241 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1243 PropertiesLine prop_line_in
;
1244 prop_line_in
.color
= g_new(GdkColor
,1);
1245 prop_line_in
.line_width
= 2;
1246 prop_line_in
.style
= GDK_LINE_SOLID
;
1247 prop_line_in
.position
= MIDDLE
;
1249 /* color of line : status of the process */
1250 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1252 prop_line_in
.color
->red
= 0xffff;
1253 prop_line_in
.color
->green
= 0xffff;
1254 prop_line_in
.color
->blue
= 0xffff;
1256 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1258 prop_line_in
.color
->red
= 0x0fff;
1259 prop_line_in
.color
->green
= 0xffff;
1260 prop_line_in
.color
->blue
= 0xfff0;
1262 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1264 prop_line_in
.color
->red
= 0xffff;
1265 prop_line_in
.color
->green
= 0xffff;
1266 prop_line_in
.color
->blue
= 0x0000;
1268 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1270 prop_line_in
.color
->red
= 0xffff;
1271 prop_line_in
.color
->green
= 0x0000;
1272 prop_line_in
.color
->blue
= 0xffff;
1274 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1276 prop_line_in
.color
->red
= 0xffff;
1277 prop_line_in
.color
->green
= 0x0000;
1278 prop_line_in
.color
->blue
= 0x0000;
1280 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1282 prop_line_in
.color
->red
= 0x0000;
1283 prop_line_in
.color
->green
= 0xffff;
1284 prop_line_in
.color
->blue
= 0x0000;
1288 prop_line_in
.color
->red
= 0xffff;
1289 prop_line_in
.color
->green
= 0xffff;
1290 prop_line_in
.color
->blue
= 0xffff;
1293 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1294 g_free(prop_line_in
.color
);
1295 //gdk_gc_unref(draw_context_in->gc);
1305 GString
*string
= g_string_new("");;
1306 gboolean field_names
= TRUE
, state
= TRUE
;
1308 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1309 g_string_append_printf(string
,"\n");
1312 g_string_append_printf(string
, " %s",
1313 g_quark_to_string(tfs
->process
->state
->s
));
1316 g_info("%s",string
->str
);
1318 g_string_free(string
, TRUE
);
1320 /* End of text dump */
1325 /* after_schedchange_hook
1327 * The draw after hook is called by the reading API to have a
1328 * particular event drawn on the screen.
1329 * @param hook_data ControlFlowData structure of the viewer.
1330 * @param call_data Event context.
1332 * This function adds items to be drawn in a queue for each process.
1335 int after_schedchange_hook(void *hook_data
, void *call_data
)
1337 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1338 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1340 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1342 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1343 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1348 LttTime evtime
= ltt_event_time(e
);
1349 TimeWindow time_window
=
1350 lttvwindow_get_time_window(control_flow_data
->tab
);
1352 LttTime end_time
= time_window
.end_time
;
1355 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1356 || ltt_time_compare(evtime
, end_time
) == 1)
1358 #endif //EXTRA_CHECK
1360 guint width
= control_flow_data
->drawing
->width
;
1362 /* Add process to process list (if not present) */
1363 LttvProcessState
*process_out
, *process_in
;
1365 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1366 HashedProcessData
*hashed_process_data_in
= NULL
;
1368 ProcessList
*process_list
= control_flow_data
->process_list
;
1373 LttField
*f
= ltt_event_field(e
);
1375 element
= ltt_field_member(f
,0);
1376 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1377 element
= ltt_field_member(f
,1);
1378 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1379 g_debug("out : %u in : %u", pid_out
, pid_in
);
1383 /* Find process pid_in in the list... */
1384 process_in
= lttv_state_find_process(tfs
, pid_in
);
1385 /* It should exist, because we are after the state update. */
1386 g_assert(process_in
!= NULL
);
1388 birth
= process_in
->creation_time
;
1389 const gchar
*name
= g_quark_to_string(process_in
->name
);
1391 if(processlist_get_process_pixels(process_list
,
1393 process_in
->last_cpu
,
1395 tfc
->t_context
->index
,
1398 &hashed_process_data_in
) == 1)
1400 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1401 ProcessInfo
*process_info
;
1402 /* Process not present */
1403 processlist_add(process_list
,
1405 process_in
->last_cpu
,
1408 tfc
->t_context
->index
,
1412 &hashed_process_data_in
);
1413 processlist_get_pixels_from_data(process_list
,
1415 hashed_process_data_in
,
1418 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1421 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
1426 convert_time_to_pixels(
1432 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1433 hashed_process_data_in
->x
.middle
= new_x
;
1434 hashed_process_data_in
->x
.middle_used
= FALSE
;
1435 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1445 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1446 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1448 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1450 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1451 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1457 LttTime evtime
= ltt_event_time(e
);
1458 TimeWindow time_window
=
1459 lttvwindow_get_time_window(control_flow_data
->tab
);
1461 LttTime end_time
= time_window
.end_time
;
1463 //if(time < time_beg || time > time_end) return;
1464 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1465 || ltt_time_compare(evtime
, end_time
) == 1)
1469 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1471 g_debug("schedchange!");
1473 /* Add process to process list (if not present) and get drawing "y" from
1474 * process position */
1475 guint pid_out
, pid_in
;
1476 LttvProcessState
*process_out
, *process_in
;
1478 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1480 ProcessList
*process_list
= control_flow_data
->process_list
;
1483 LttField
*f
= ltt_event_field(e
);
1485 element
= ltt_field_member(f
,0);
1486 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1487 element
= ltt_field_member(f
,1);
1488 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1489 //g_debug("out : %u in : %u", pid_out, pid_in);
1492 /* Find process pid_out in the list... */
1493 process_out
= lttv_state_find_process(tfs
, pid_out
);
1494 if(process_out
== NULL
) return 0;
1495 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1497 birth
= process_out
->creation_time
;
1498 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1499 HashedProcessData
*hashed_process_data_out
= NULL
;
1501 if(processlist_get_process_pixels(process_list
,
1504 tfc
->t_context
->index
,
1507 &hashed_process_data_out
) == 1)
1509 /* Process not present */
1510 processlist_add(process_list
,
1513 tfc
->t_context
->index
,
1516 &hashed_process_data_out
);
1517 processlist_get_process_pixels(process_list
,
1520 tfc
->t_context
->index
,
1523 &hashed_process_data_out
);
1524 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1529 /* Find process pid_in in the list... */
1530 process_in
= lttv_state_find_process(tfs
, pid_in
);
1531 if(process_in
== NULL
) return 0;
1532 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1534 birth
= process_in
->creation_time
;
1535 name
= strdup(g_quark_to_string(process_in
->name
));
1536 HashedProcessData
*hashed_process_data_in
= NULL
;
1538 if(processlist_get_process_pixels(process_list
,
1541 tfc
->t_context
->index
,
1544 &hashed_process_data_in
) == 1)
1546 /* Process not present */
1547 processlist_add(process_list
,
1550 tfc
->t_context
->index
,
1553 &hashed_process_data_in
);
1554 processlist_get_process_pixels(process_list
,
1557 tfc
->t_context
->index
,
1560 &hashed_process_data_in
);
1562 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1567 /* Find pixels corresponding to time of the event. If the time does
1568 * not fit in the window, show a warning, not supposed to happend. */
1570 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1572 //LttTime time = ltt_event_time(e);
1574 //LttTime window_end = time_window->end_time;
1577 //convert_time_to_pixels(
1583 //assert(x <= width);
1585 /* draw what represents the event for outgoing process. */
1587 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1588 //draw_context_out->current->modify_over->x = x;
1589 draw_context_out
->current
->modify_over
->y
= y_out
;
1590 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1591 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1592 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1593 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1594 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1596 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1597 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1599 /*if(process_out->state->s == LTTV_STATE_RUN)
1601 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1602 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1603 PropertiesBG prop_bg;
1604 prop_bg.color = g_new(GdkColor,1);
1606 prop_bg.color->red = 0xffff;
1607 prop_bg.color->green = 0xffff;
1608 prop_bg.color->blue = 0xffff;
1610 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1611 g_free(prop_bg.color);
1612 gdk_gc_unref(draw_context_out->gc);
1615 draw_context_out
->gc
= widget
->style
->black_gc
;
1617 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1618 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1619 PropertiesText prop_text_out
;
1620 prop_text_out
.foreground
= &colorfg_out
;
1621 prop_text_out
.background
= &colorbg_out
;
1622 prop_text_out
.size
= 6;
1623 prop_text_out
.position
= OVER
;
1625 /* color of text : status of the process */
1626 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1628 prop_text_out
.foreground
->red
= 0xffff;
1629 prop_text_out
.foreground
->green
= 0xffff;
1630 prop_text_out
.foreground
->blue
= 0xffff;
1632 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1634 prop_text_out
.foreground
->red
= 0x0fff;
1635 prop_text_out
.foreground
->green
= 0xffff;
1636 prop_text_out
.foreground
->blue
= 0xfff0;
1638 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1640 prop_text_out
.foreground
->red
= 0xffff;
1641 prop_text_out
.foreground
->green
= 0xffff;
1642 prop_text_out
.foreground
->blue
= 0x0000;
1644 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1646 prop_text_out
.foreground
->red
= 0xffff;
1647 prop_text_out
.foreground
->green
= 0x0000;
1648 prop_text_out
.foreground
->blue
= 0xffff;
1650 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1652 prop_text_out
.foreground
->red
= 0xffff;
1653 prop_text_out
.foreground
->green
= 0x0000;
1654 prop_text_out
.foreground
->blue
= 0x0000;
1656 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1658 prop_text_out
.foreground
->red
= 0x0000;
1659 prop_text_out
.foreground
->green
= 0xffff;
1660 prop_text_out
.foreground
->blue
= 0x0000;
1664 prop_text_out
.foreground
->red
= 0xffff;
1665 prop_text_out
.foreground
->green
= 0xffff;
1666 prop_text_out
.foreground
->blue
= 0xffff;
1669 /* Print status of the process : U, WF, WC, E, W, R */
1670 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1671 prop_text_out
.text
= "U";
1672 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1673 prop_text_out
.text
= "WF";
1674 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1675 prop_text_out
.text
= "WC";
1676 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1677 prop_text_out
.text
= "E";
1678 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1679 prop_text_out
.text
= "W";
1680 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1681 prop_text_out
.text
= "R";
1683 prop_text_out
.text
= "U";
1685 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1687 //gdk_gc_unref(draw_context_out->gc);
1689 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1690 draw_context_out
->current
->over
->y
= y_out
;
1691 draw_context_out
->current
->under
->y
= y_out
+height
;
1692 draw_context_out
->current
->status
= process_out
->state
->s
;
1694 /* for pid_out : remove previous, Prev = current, new current (default) */
1695 g_free(draw_context_out
->previous
->modify_under
);
1696 g_free(draw_context_out
->previous
->modify_middle
);
1697 g_free(draw_context_out
->previous
->modify_over
);
1698 g_free(draw_context_out
->previous
->under
);
1699 g_free(draw_context_out
->previous
->middle
);
1700 g_free(draw_context_out
->previous
->over
);
1701 g_free(draw_context_out
->previous
);
1703 draw_context_out
->previous
= draw_context_out
->current
;
1705 draw_context_out
->current
= g_new(DrawInfo
,1);
1706 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1707 draw_context_out
->current
->over
->x
= -1;
1708 draw_context_out
->current
->over
->y
= -1;
1709 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1710 draw_context_out
->current
->middle
->x
= -1;
1711 draw_context_out
->current
->middle
->y
= -1;
1712 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1713 draw_context_out
->current
->under
->x
= -1;
1714 draw_context_out
->current
->under
->y
= -1;
1715 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1716 draw_context_out
->current
->modify_over
->x
= -1;
1717 draw_context_out
->current
->modify_over
->y
= -1;
1718 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1719 draw_context_out
->current
->modify_middle
->x
= -1;
1720 draw_context_out
->current
->modify_middle
->y
= -1;
1721 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1722 draw_context_out
->current
->modify_under
->x
= -1;
1723 draw_context_out
->current
->modify_under
->y
= -1;
1724 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1726 /* Finally, update the drawing context of the pid_in. */
1728 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1729 //draw_context_in->current->modify_over->x = x;
1730 draw_context_in
->current
->modify_over
->y
= y_in
;
1731 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1732 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1733 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1734 widget
= control_flow_data
->drawing
->drawing_area
;
1735 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1737 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1738 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1740 /*if(process_in->state->s == LTTV_STATE_RUN)
1742 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1743 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1744 PropertiesBG prop_bg;
1745 prop_bg.color = g_new(GdkColor,1);
1747 prop_bg.color->red = 0xffff;
1748 prop_bg.color->green = 0xffff;
1749 prop_bg.color->blue = 0xffff;
1751 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1752 g_free(prop_bg.color);
1753 gdk_gc_unref(draw_context_in->gc);
1756 draw_context_in
->gc
= widget
->style
->black_gc
;
1758 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1759 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1760 PropertiesText prop_text_in
;
1761 prop_text_in
.foreground
= &colorfg_in
;
1762 prop_text_in
.background
= &colorbg_in
;
1763 prop_text_in
.size
= 6;
1764 prop_text_in
.position
= OVER
;
1766 /* foreground of text : status of the process */
1767 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1769 prop_text_in
.foreground
->red
= 0xffff;
1770 prop_text_in
.foreground
->green
= 0xffff;
1771 prop_text_in
.foreground
->blue
= 0xffff;
1773 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1775 prop_text_in
.foreground
->red
= 0x0fff;
1776 prop_text_in
.foreground
->green
= 0xffff;
1777 prop_text_in
.foreground
->blue
= 0xfff0;
1779 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1781 prop_text_in
.foreground
->red
= 0xffff;
1782 prop_text_in
.foreground
->green
= 0xffff;
1783 prop_text_in
.foreground
->blue
= 0x0000;
1785 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1787 prop_text_in
.foreground
->red
= 0xffff;
1788 prop_text_in
.foreground
->green
= 0x0000;
1789 prop_text_in
.foreground
->blue
= 0xffff;
1791 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1793 prop_text_in
.foreground
->red
= 0xffff;
1794 prop_text_in
.foreground
->green
= 0x0000;
1795 prop_text_in
.foreground
->blue
= 0x0000;
1797 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1799 prop_text_in
.foreground
->red
= 0x0000;
1800 prop_text_in
.foreground
->green
= 0xffff;
1801 prop_text_in
.foreground
->blue
= 0x0000;
1805 prop_text_in
.foreground
->red
= 0xffff;
1806 prop_text_in
.foreground
->green
= 0xffff;
1807 prop_text_in
.foreground
->blue
= 0xffff;
1811 /* Print status of the process : U, WF, WC, E, W, R */
1812 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1813 prop_text_in
.text
= "U";
1814 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1815 prop_text_in
.text
= "WF";
1816 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1817 prop_text_in
.text
= "WC";
1818 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1819 prop_text_in
.text
= "E";
1820 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1821 prop_text_in
.text
= "W";
1822 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1823 prop_text_in
.text
= "R";
1825 prop_text_in
.text
= "U";
1827 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1830 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1833 prop_text_in
.foreground
= &colorfg_in
;
1834 prop_text_in
.background
= &colorbg_in
;
1835 prop_text_in
.foreground
->red
= 0xffff;
1836 prop_text_in
.foreground
->green
= 0xffff;
1837 prop_text_in
.foreground
->blue
= 0xffff;
1838 prop_text_in
.size
= 6;
1839 prop_text_in
.position
= UNDER
;
1841 prop_text_in
.text
= g_new(gchar
, 260);
1842 strcpy(prop_text_in
.text
, "CPU ");
1843 snprintf(tmp
, 255, "%u", tfc
->index
);
1844 strcat(prop_text_in
.text
, tmp
);
1846 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1847 g_free(prop_text_in
.text
);
1851 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1852 draw_context_in
->current
->over
->y
= y_in
;
1853 draw_context_in
->current
->under
->y
= y_in
+height
;
1854 draw_context_in
->current
->status
= process_in
->state
->s
;
1856 /* for pid_in : remove previous, Prev = current, new current (default) */
1857 g_free(draw_context_in
->previous
->modify_under
);
1858 g_free(draw_context_in
->previous
->modify_middle
);
1859 g_free(draw_context_in
->previous
->modify_over
);
1860 g_free(draw_context_in
->previous
->under
);
1861 g_free(draw_context_in
->previous
->middle
);
1862 g_free(draw_context_in
->previous
->over
);
1863 g_free(draw_context_in
->previous
);
1865 draw_context_in
->previous
= draw_context_in
->current
;
1867 draw_context_in
->current
= g_new(DrawInfo
,1);
1868 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1869 draw_context_in
->current
->over
->x
= -1;
1870 draw_context_in
->current
->over
->y
= -1;
1871 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1872 draw_context_in
->current
->middle
->x
= -1;
1873 draw_context_in
->current
->middle
->y
= -1;
1874 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1875 draw_context_in
->current
->under
->x
= -1;
1876 draw_context_in
->current
->under
->y
= -1;
1877 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1878 draw_context_in
->current
->modify_over
->x
= -1;
1879 draw_context_in
->current
->modify_over
->y
= -1;
1880 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1881 draw_context_in
->current
->modify_middle
->x
= -1;
1882 draw_context_in
->current
->modify_middle
->y
= -1;
1883 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1884 draw_context_in
->current
->modify_under
->x
= -1;
1885 draw_context_in
->current
->modify_under
->y
= -1;
1886 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1895 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1897 PropertiesLine prop_line
;
1898 prop_line
.line_width
= 1;
1899 prop_line
.style
= GDK_LINE_SOLID
;
1901 //GdkColormap *colormap = gdk_colormap_get_system();
1903 /* color of line : execution mode of the process */
1904 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1905 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1906 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1907 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1908 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1909 prop_line
.color
= drawing_colors
[COL_TRAP
];
1910 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1911 prop_line
.color
= drawing_colors
[COL_IRQ
];
1912 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1913 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1915 prop_line
.color
= drawing_colors
[COL_WHITE
];
1917 //gdk_colormap_alloc_color(colormap,
1928 /* before_execmode_hook
1930 * This function basically draw lines and icons. Two types of lines are drawn :
1931 * one small (3 pixels?) representing the state of the process and the second
1932 * type is thicker (10 pixels?) representing on which CPU a process is running
1933 * (and this only in running state).
1935 * Extremums of the lines :
1936 * x_min : time of the last event context for this process kept in memory.
1937 * x_max : time of the current event.
1938 * y : middle of the process in the process list. The process is found in the
1939 * list, therefore is it's position in pixels.
1941 * The choice of lines'color is defined by the context of the last event for this
1946 int before_execmode_hook(void *hook_data
, void *call_data
)
1948 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1949 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1950 Drawing_t
*drawing
= control_flow_data
->drawing
;
1952 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1954 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1955 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1960 LttTime evtime
= ltt_event_time(e
);
1961 TimeWindow time_window
=
1962 lttvwindow_get_time_window(control_flow_data
->tab
);
1964 LttTime end_time
= time_window
.end_time
;
1967 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1968 || ltt_time_compare(evtime
, end_time
) == 1)
1970 #endif //EXTRA_CHECK
1972 guint width
= drawing
->width
;
1974 /* we are in a execmode, before the state update. We must draw the
1975 * items corresponding to the state before it changes : now is the right
1979 LttvProcessState
*process
= tfs
->process
;
1980 g_assert(process
!= NULL
);
1982 guint pid
= process
->pid
;
1984 /* Well, the process_out existed : we must get it in the process hash
1985 * or add it, and draw its items.
1987 /* Add process to process list (if not present) */
1988 guint y
= 0, height
= 0, pl_height
= 0;
1989 HashedProcessData
*hashed_process_data
= NULL
;
1990 ProcessList
*process_list
= control_flow_data
->process_list
;
1991 LttTime birth
= process
->creation_time
;
1992 const gchar
*name
= g_quark_to_string(process
->name
);
1994 if(processlist_get_process_pixels(process_list
,
1998 tfc
->t_context
->index
,
2001 &hashed_process_data
) == 1)
2003 g_assert(pid
== 0 || pid
!= process
->ppid
);
2004 ProcessInfo
*process_info
;
2005 /* Process not present */
2006 processlist_add(process_list
,
2011 tfc
->t_context
->index
,
2015 &hashed_process_data
);
2016 processlist_get_pixels_from_data(process_list
,
2018 hashed_process_data
,
2021 drawing_insert_square( drawing
, y
, height
);
2024 /* Now, the process is in the state hash and our own process hash.
2025 * We definitely can draw the items related to the ending state.
2028 /* Check if the x position is unset. In can have been left unset by
2029 * a draw closure from a after chunk hook. This should never happen,
2030 * because it must be set by before chunk hook to the damage_begin
2033 g_assert(hashed_process_data
->x
.over
!= -1);
2035 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2038 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2040 convert_time_to_pixels(
2046 /* Draw collision indicator */
2047 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2048 gdk_draw_point(drawing
->pixmap
,
2052 hashed_process_data
->x
.middle_marked
= TRUE
;
2057 convert_time_to_pixels(
2064 /* Jump over draw if we are at the same x position */
2065 if(x
== hashed_process_data
->x
.middle
&&
2066 hashed_process_data
->x
.middle_used
)
2068 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2069 /* Draw collision indicator */
2070 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2071 gdk_draw_point(drawing
->pixmap
,
2075 hashed_process_data
->x
.middle_marked
= TRUE
;
2080 DrawContext draw_context
;
2081 /* Now create the drawing context that will be used to draw
2082 * items related to the last state. */
2083 draw_context
.drawable
= drawing
->pixmap
;
2084 draw_context
.gc
= drawing
->gc
;
2085 draw_context
.pango_layout
= drawing
->pango_layout
;
2086 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2087 draw_context
.drawinfo
.end
.x
= x
;
2089 draw_context
.drawinfo
.y
.over
= y
+1;
2090 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2091 draw_context
.drawinfo
.y
.under
= y
+height
;
2093 draw_context
.drawinfo
.start
.offset
.over
= 0;
2094 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2095 draw_context
.drawinfo
.start
.offset
.under
= 0;
2096 draw_context
.drawinfo
.end
.offset
.over
= 0;
2097 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2098 draw_context
.drawinfo
.end
.offset
.under
= 0;
2102 PropertiesLine prop_line
= prepare_s_e_line(process
);
2103 draw_line((void*)&prop_line
, (void*)&draw_context
);
2106 /* become the last x position */
2107 hashed_process_data
->x
.middle
= x
;
2108 hashed_process_data
->x
.middle_used
= TRUE
;
2109 hashed_process_data
->x
.middle_marked
= FALSE
;
2111 /* Calculate the next good time */
2112 convert_pixels_to_time(width
, x
+1, time_window
,
2113 &hashed_process_data
->next_good_time
);
2120 /* after_execmode_hook
2122 * The draw after hook is called by the reading API to have a
2123 * particular event drawn on the screen.
2124 * @param hook_data ControlFlowData structure of the viewer.
2125 * @param call_data Event context.
2127 * This function adds items to be drawn in a queue for each process.
2130 int after_execmode_hook(void *hook_data
, void *call_data
)
2132 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2133 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2135 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2137 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2138 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2143 LttTime evtime
= ltt_event_time(e
);
2144 TimeWindow time_window
=
2145 lttvwindow_get_time_window(control_flow_data
->tab
);
2147 LttTime end_time
= time_window
.end_time
;
2150 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2151 || ltt_time_compare(evtime
, end_time
) == 1)
2153 #endif //EXTRA_CHECK
2155 guint width
= control_flow_data
->drawing
->width
;
2157 /* Add process to process list (if not present) */
2158 LttvProcessState
*process
;
2160 guint y
= 0, height
= 0, pl_height
= 0;
2161 HashedProcessData
*hashed_process_data
= NULL
;
2163 ProcessList
*process_list
= control_flow_data
->process_list
;
2165 /* Find process pid_in in the list... */
2166 process
= tfs
->process
;
2167 /* It should exist, because we are after the state update. */
2168 g_assert(process
!= NULL
);
2170 guint pid
= process
->pid
;
2172 birth
= process
->creation_time
;
2173 const gchar
*name
= g_quark_to_string(process
->name
);
2175 if(processlist_get_process_pixels(process_list
,
2179 tfc
->t_context
->index
,
2182 &hashed_process_data
) == 1)
2184 g_assert(pid
== 0 || pid
!= process
->ppid
);
2185 /* Process not present */
2186 ProcessInfo
*process_info
;
2187 processlist_add(process_list
,
2192 tfc
->t_context
->index
,
2196 &hashed_process_data
);
2197 processlist_get_pixels_from_data(process_list
,
2199 hashed_process_data
,
2202 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2205 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2210 convert_time_to_pixels(
2216 if(hashed_process_data
->x
.middle
!= new_x
) {
2217 hashed_process_data
->x
.middle
= new_x
;
2218 hashed_process_data
->x
.middle_used
= FALSE
;
2219 hashed_process_data
->x
.middle_marked
= FALSE
;
2227 /* before_process_hook
2229 * Draw lines for process event.
2231 * @param hook_data ControlFlowData structure of the viewer.
2232 * @param call_data Event context.
2234 * This function adds items to be drawn in a queue for each process.
2237 int before_process_hook(void *hook_data
, void *call_data
)
2239 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2240 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2241 Drawing_t
*drawing
= control_flow_data
->drawing
;
2243 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2245 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2246 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2251 LttTime evtime
= ltt_event_time(e
);
2252 TimeWindow time_window
=
2253 lttvwindow_get_time_window(control_flow_data
->tab
);
2255 LttTime end_time
= time_window
.end_time
;
2258 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2259 || ltt_time_compare(evtime
, end_time
) == 1)
2261 #endif //EXTRA_CHECK
2263 guint width
= control_flow_data
->drawing
->width
;
2267 LttField
*f
= ltt_event_field(e
);
2269 element
= ltt_field_member(f
,0);
2270 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2273 if(sub_id
== 3) { /* exit */
2275 /* Add process to process list (if not present) */
2276 LttvProcessState
*process
= tfs
->process
;
2277 guint pid
= process
->pid
;
2279 guint y
= 0, height
= 0, pl_height
= 0;
2280 HashedProcessData
*hashed_process_data
= NULL
;
2282 ProcessList
*process_list
= control_flow_data
->process_list
;
2284 g_assert(process
!= NULL
);
2286 birth
= process
->creation_time
;
2287 const gchar
*name
= g_quark_to_string(process
->name
);
2289 if(processlist_get_process_pixels(process_list
,
2293 tfc
->t_context
->index
,
2296 &hashed_process_data
) == 1)
2298 g_assert(pid
== 0 || pid
!= process
->ppid
);
2299 /* Process not present */
2300 ProcessInfo
*process_info
;
2301 processlist_add(process_list
,
2306 tfc
->t_context
->index
,
2310 &hashed_process_data
);
2311 processlist_get_pixels_from_data(process_list
,
2313 hashed_process_data
,
2316 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2319 /* Now, the process is in the state hash and our own process hash.
2320 * We definitely can draw the items related to the ending state.
2323 /* Check if the x position is unset. In can have been left unset by
2324 * a draw closure from a after chunk hook. This should never happen,
2325 * because it must be set by before chunk hook to the damage_begin
2328 g_assert(hashed_process_data
->x
.over
!= -1);
2330 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2333 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2335 convert_time_to_pixels(
2341 /* Draw collision indicator */
2342 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2343 gdk_draw_point(drawing
->pixmap
,
2347 hashed_process_data
->x
.middle_marked
= TRUE
;
2352 convert_time_to_pixels(
2359 /* Jump over draw if we are at the same x position */
2360 if(x
== hashed_process_data
->x
.middle
&&
2361 hashed_process_data
->x
.middle_used
)
2363 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
2364 /* Draw collision indicator */
2365 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2366 gdk_draw_point(drawing
->pixmap
,
2370 hashed_process_data
->x
.middle_marked
= TRUE
;
2374 DrawContext draw_context
;
2376 /* Now create the drawing context that will be used to draw
2377 * items related to the last state. */
2378 draw_context
.drawable
= drawing
->pixmap
;
2379 draw_context
.gc
= drawing
->gc
;
2380 draw_context
.pango_layout
= drawing
->pango_layout
;
2381 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2382 draw_context
.drawinfo
.end
.x
= x
;
2384 draw_context
.drawinfo
.y
.over
= y
+1;
2385 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2386 draw_context
.drawinfo
.y
.under
= y
+height
;
2388 draw_context
.drawinfo
.start
.offset
.over
= 0;
2389 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2390 draw_context
.drawinfo
.start
.offset
.under
= 0;
2391 draw_context
.drawinfo
.end
.offset
.over
= 0;
2392 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2393 draw_context
.drawinfo
.end
.offset
.under
= 0;
2397 PropertiesLine prop_line
= prepare_s_e_line(process
);
2398 draw_line((void*)&prop_line
, (void*)&draw_context
);
2401 /* become the last x position */
2402 hashed_process_data
->x
.middle
= x
;
2403 hashed_process_data
->x
.middle_used
= TRUE
;
2404 hashed_process_data
->x
.middle_marked
= FALSE
;
2406 /* Calculate the next good time */
2407 convert_pixels_to_time(width
, x
+1, time_window
,
2408 &hashed_process_data
->next_good_time
);
2422 /* after_process_hook
2424 * Create the processlist entry for the child process. Put the last
2425 * position in x at the current time value.
2427 * @param hook_data ControlFlowData structure of the viewer.
2428 * @param call_data Event context.
2430 * This function adds items to be drawn in a queue for each process.
2433 int after_process_hook(void *hook_data
, void *call_data
)
2435 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2436 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2438 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2440 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2441 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2446 LttTime evtime
= ltt_event_time(e
);
2447 TimeWindow time_window
=
2448 lttvwindow_get_time_window(control_flow_data
->tab
);
2450 LttTime end_time
= time_window
.end_time
;
2453 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2454 || ltt_time_compare(evtime
, end_time
) == 1)
2456 #endif //EXTRA_CHECK
2458 guint width
= control_flow_data
->drawing
->width
;
2463 LttField
*f
= ltt_event_field(e
);
2465 element
= ltt_field_member(f
,0);
2466 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2467 element
= ltt_field_member(f
,1);
2468 param1
= ltt_event_get_long_unsigned(e
,element
);
2471 if(sub_id
== 2) { /* fork */
2473 guint child_pid
= param1
;
2474 /* Add process to process list (if not present) */
2475 LttvProcessState
*process_child
;
2477 guint y_child
= 0, height
= 0, pl_height
= 0;
2478 HashedProcessData
*hashed_process_data_child
= NULL
;
2480 ProcessList
*process_list
= control_flow_data
->process_list
;
2482 /* Find child in the list... */
2483 process_child
= lttv_state_find_process(tfs
, child_pid
);
2484 /* It should exist, because we are after the state update. */
2485 g_assert(process_child
!= NULL
);
2487 birth
= process_child
->creation_time
;
2488 const gchar
*name
= g_quark_to_string(process_child
->name
);
2490 if(processlist_get_process_pixels(process_list
,
2492 process_child
->last_cpu
,
2494 tfc
->t_context
->index
,
2497 &hashed_process_data_child
) == 1)
2499 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2500 /* Process not present */
2501 ProcessInfo
*process_info
;
2502 processlist_add(process_list
,
2504 process_child
->last_cpu
,
2505 process_child
->ppid
,
2507 tfc
->t_context
->index
,
2511 &hashed_process_data_child
);
2512 processlist_get_pixels_from_data(process_list
,
2514 hashed_process_data_child
,
2517 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2520 if(ltt_time_compare(hashed_process_data_child
->next_good_time
,
2524 convert_time_to_pixels(
2530 if(hashed_process_data_child
->x
.over
!= new_x
) {
2531 hashed_process_data_child
->x
.over
= new_x
;
2532 hashed_process_data_child
->x
.over_used
= FALSE
;
2533 hashed_process_data_child
->x
.over_marked
= FALSE
;
2535 if(hashed_process_data_child
->x
.middle
!= new_x
) {
2536 hashed_process_data_child
->x
.middle
= new_x
;
2537 hashed_process_data_child
->x
.middle_used
= FALSE
;
2538 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2540 if(hashed_process_data_child
->x
.under
!= new_x
) {
2541 hashed_process_data_child
->x
.under
= new_x
;
2542 hashed_process_data_child
->x
.under_used
= FALSE
;
2543 hashed_process_data_child
->x
.under_marked
= FALSE
;
2547 } else if(sub_id
== 3) { /* exit */
2549 /* Add process to process list (if not present) */
2550 LttvProcessState
*process
= tfs
->process
;
2551 guint pid
= process
->pid
;
2553 guint y
= 0, height
= 0, pl_height
= 0;
2554 HashedProcessData
*hashed_process_data
= NULL
;
2556 ProcessList
*process_list
= control_flow_data
->process_list
;
2558 /* It should exist, because we are after the state update. */
2559 g_assert(process
!= NULL
);
2561 birth
= process
->creation_time
;
2562 const gchar
*name
= g_quark_to_string(process
->name
);
2564 if(processlist_get_process_pixels(process_list
,
2568 tfc
->t_context
->index
,
2571 &hashed_process_data
) == 1)
2573 g_assert(pid
== 0 || pid
!= process
->ppid
);
2574 /* Process not present */
2575 ProcessInfo
*process_info
;
2576 processlist_add(process_list
,
2581 tfc
->t_context
->index
,
2585 &hashed_process_data
);
2586 processlist_get_pixels_from_data(process_list
,
2588 hashed_process_data
,
2591 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2594 if(ltt_time_compare(hashed_process_data
->next_good_time
,
2598 convert_time_to_pixels(
2603 if(hashed_process_data
->x
.middle
!= new_x
) {
2604 hashed_process_data
->x
.middle
= new_x
;
2605 hashed_process_data
->x
.middle_used
= FALSE
;
2606 hashed_process_data
->x
.middle_marked
= FALSE
;
2616 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2618 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2619 Drawing_t
*drawing
= control_flow_data
->drawing
;
2621 const TimeWindowNotifyData
*time_window_nofify_data
=
2622 ((const TimeWindowNotifyData
*)call_data
);
2624 TimeWindow
*old_time_window
=
2625 time_window_nofify_data
->old_time_window
;
2626 TimeWindow
*new_time_window
=
2627 time_window_nofify_data
->new_time_window
;
2629 /* Update the ruler */
2630 drawing_update_ruler(control_flow_data
->drawing
,
2634 /* Two cases : zoom in/out or scrolling */
2636 /* In order to make sure we can reuse the old drawing, the scale must
2637 * be the same and the new time interval being partly located in the
2638 * currently shown time interval. (reuse is only for scrolling)
2641 g_info("Old time window HOOK : %u, %u to %u, %u",
2642 old_time_window
->start_time
.tv_sec
,
2643 old_time_window
->start_time
.tv_nsec
,
2644 old_time_window
->time_width
.tv_sec
,
2645 old_time_window
->time_width
.tv_nsec
);
2647 g_info("New time window HOOK : %u, %u to %u, %u",
2648 new_time_window
->start_time
.tv_sec
,
2649 new_time_window
->start_time
.tv_nsec
,
2650 new_time_window
->time_width
.tv_sec
,
2651 new_time_window
->time_width
.tv_nsec
);
2653 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2654 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2656 /* Same scale (scrolling) */
2657 g_info("scrolling");
2658 LttTime
*ns
= &new_time_window
->start_time
;
2659 LttTime
*nw
= &new_time_window
->time_width
;
2660 LttTime
*os
= &old_time_window
->start_time
;
2661 LttTime
*ow
= &old_time_window
->time_width
;
2662 LttTime old_end
= old_time_window
->end_time
;
2663 LttTime new_end
= new_time_window
->end_time
;
2665 //if(ns<os+w && os+w<ns+w)
2666 //if(ns<old_end && os<ns)
2667 if(ltt_time_compare(*ns
, old_end
) == -1
2668 && ltt_time_compare(*os
, *ns
) == -1)
2670 g_info("scrolling near right");
2671 /* Scroll right, keep right part of the screen */
2673 guint width
= control_flow_data
->drawing
->width
;
2674 convert_time_to_pixels(
2680 /* Copy old data to new location */
2681 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2682 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2683 control_flow_data
->drawing
->pixmap
,
2686 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2688 if(drawing
->damage_begin
== drawing
->damage_end
)
2689 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2691 drawing
->damage_begin
= 0;
2693 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2695 /* Clear the data request background, but not SAFETY */
2696 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2697 //control_flow_data->drawing->drawing_area->style->black_gc,
2698 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2700 drawing
->damage_begin
+SAFETY
, 0,
2701 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2702 control_flow_data
->drawing
->height
);
2704 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2706 control_flow_data
->drawing
->width
,
2707 control_flow_data
->drawing
->height
);
2709 /* Get new data for the rest. */
2710 drawing_data_request(control_flow_data
->drawing
,
2711 &control_flow_data
->drawing
->pixmap
,
2712 drawing
->damage_begin
, 0,
2713 drawing
->damage_end
- drawing
->damage_begin
,
2714 control_flow_data
->drawing
->height
);
2717 //if(ns<os && os<ns+w)
2718 //if(ns<os && os<new_end)
2719 if(ltt_time_compare(*ns
,*os
) == -1
2720 && ltt_time_compare(*os
,new_end
) == -1)
2722 g_info("scrolling near left");
2723 /* Scroll left, keep left part of the screen */
2725 guint width
= control_flow_data
->drawing
->width
;
2726 convert_time_to_pixels(
2733 /* Copy old data to new location */
2734 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2735 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2736 control_flow_data
->drawing
->pixmap
,
2741 if(drawing
->damage_begin
== drawing
->damage_end
)
2742 drawing
->damage_end
= x
;
2744 drawing
->damage_end
=
2745 control_flow_data
->drawing
->width
;
2747 drawing
->damage_begin
= 0;
2749 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2750 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2752 drawing
->damage_begin
, 0,
2753 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2754 control_flow_data
->drawing
->height
);
2756 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2758 control_flow_data
->drawing
->width
,
2759 control_flow_data
->drawing
->height
);
2762 /* Get new data for the rest. */
2763 drawing_data_request(control_flow_data
->drawing
,
2764 &control_flow_data
->drawing
->pixmap
,
2765 drawing
->damage_begin
, 0,
2766 drawing
->damage_end
- drawing
->damage_begin
,
2767 control_flow_data
->drawing
->height
);
2770 if(ltt_time_compare(*ns
,*os
) == 0)
2772 g_info("not scrolling");
2774 g_info("scrolling far");
2775 /* Cannot reuse any part of the screen : far jump */
2778 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2779 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2782 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2783 control_flow_data
->drawing
->height
);
2785 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2787 control_flow_data
->drawing
->width
,
2788 control_flow_data
->drawing
->height
);
2790 drawing
->damage_begin
= 0;
2791 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2793 drawing_data_request(control_flow_data
->drawing
,
2794 &control_flow_data
->drawing
->pixmap
,
2796 control_flow_data
->drawing
->width
,
2797 control_flow_data
->drawing
->height
);
2803 /* Different scale (zoom) */
2806 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2807 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2810 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2811 control_flow_data
->drawing
->height
);
2813 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2815 control_flow_data
->drawing
->width
,
2816 control_flow_data
->drawing
->height
);
2818 drawing
->damage_begin
= 0;
2819 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2821 drawing_data_request(control_flow_data
->drawing
,
2822 &control_flow_data
->drawing
->pixmap
,
2824 control_flow_data
->drawing
->width
,
2825 control_flow_data
->drawing
->height
);
2833 gint
traceset_notify(void *hook_data
, void *call_data
)
2835 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2836 Drawing_t
*drawing
= control_flow_data
->drawing
;
2837 GtkWidget
*widget
= drawing
->drawing_area
;
2840 drawing_clear(control_flow_data
->drawing
);
2841 processlist_clear(control_flow_data
->process_list
);
2842 redraw_notify(control_flow_data
, NULL
);
2844 request_background_data(control_flow_data
);
2846 drawing
->damage_begin
= 0;
2847 drawing
->damage_end
= drawing
->width
;
2848 if(drawing
->damage_begin
< drawing
->damage_end
)
2850 drawing_data_request(drawing
,
2852 drawing
->damage_begin
,
2854 drawing
->damage_end
-drawing
->damage_begin
,
2858 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2867 gint
redraw_notify(void *hook_data
, void *call_data
)
2869 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2870 Drawing_t
*drawing
= control_flow_data
->drawing
;
2871 GtkWidget
*widget
= drawing
->drawing_area
;
2873 drawing
->damage_begin
= 0;
2874 drawing
->damage_end
= drawing
->width
;
2876 /* fun feature, to be separated someday... */
2877 drawing_clear(control_flow_data
->drawing
);
2878 processlist_clear(control_flow_data
->process_list
);
2881 gdk_draw_rectangle (drawing
->pixmap
,
2882 widget
->style
->black_gc
,
2885 drawing
->width
+SAFETY
,
2889 if(drawing
->damage_begin
< drawing
->damage_end
)
2891 drawing_data_request(drawing
,
2893 drawing
->damage_begin
,
2895 drawing
->damage_end
-drawing
->damage_begin
,
2899 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2908 gint
continue_notify(void *hook_data
, void *call_data
)
2910 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2911 Drawing_t
*drawing
= control_flow_data
->drawing
;
2912 GtkWidget
*widget
= drawing
->drawing_area
;
2914 //g_assert(widget->allocation.width == drawing->damage_end);
2916 if(drawing
->damage_begin
< drawing
->damage_end
)
2918 drawing_data_request(drawing
,
2920 drawing
->damage_begin
,
2922 drawing
->damage_end
-drawing
->damage_begin
,
2930 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2932 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2933 Drawing_t
*drawing
= control_flow_data
->drawing
;
2935 LttTime current_time
= *((LttTime
*)call_data
);
2937 TimeWindow time_window
=
2938 lttvwindow_get_time_window(control_flow_data
->tab
);
2940 LttTime time_begin
= time_window
.start_time
;
2941 LttTime width
= time_window
.time_width
;
2944 guint64 time_ll
= ltt_time_to_uint64(width
);
2945 time_ll
= time_ll
>> 1; /* divide by two */
2946 half_width
= ltt_time_from_uint64(time_ll
);
2948 LttTime time_end
= ltt_time_add(time_begin
, width
);
2950 LttvTracesetContext
* tsc
=
2951 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2953 LttTime trace_start
= tsc
->time_span
.start_time
;
2954 LttTime trace_end
= tsc
->time_span
.end_time
;
2956 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2957 current_time
.tv_nsec
);
2961 /* If current time is inside time interval, just move the highlight
2964 /* Else, we have to change the time interval. We have to tell it
2965 * to the main window. */
2966 /* The time interval change will take care of placing the current
2967 * time at the center of the visible area, or nearest possible if we are
2968 * at one end of the trace. */
2971 if(ltt_time_compare(current_time
, time_begin
) == -1)
2973 TimeWindow new_time_window
;
2975 if(ltt_time_compare(current_time
,
2976 ltt_time_add(trace_start
,half_width
)) == -1)
2977 time_begin
= trace_start
;
2979 time_begin
= ltt_time_sub(current_time
,half_width
);
2981 new_time_window
.start_time
= time_begin
;
2982 new_time_window
.time_width
= width
;
2983 new_time_window
.time_width_double
= ltt_time_to_double(width
);
2984 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
2986 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2988 else if(ltt_time_compare(current_time
, time_end
) == 1)
2990 TimeWindow new_time_window
;
2992 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2993 time_begin
= ltt_time_sub(trace_end
,width
);
2995 time_begin
= ltt_time_sub(current_time
,half_width
);
2997 new_time_window
.start_time
= time_begin
;
2998 new_time_window
.time_width
= width
;
2999 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3000 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3002 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3005 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
3006 gtk_widget_queue_draw_area(drawing
->drawing_area
,
3014 typedef struct _ClosureData
{
3015 EventsRequest
*events_request
;
3016 LttvTracesetState
*tss
;
3021 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3023 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3024 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3025 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3027 EventsRequest
*events_request
= closure_data
->events_request
;
3028 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3029 Drawing_t
*drawing
= control_flow_data
->drawing
;
3031 LttvTracesetState
*tss
= closure_data
->tss
;
3032 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
3034 LttTime evtime
= closure_data
->end_time
;
3035 TimeWindow time_window
=
3036 lttvwindow_get_time_window(control_flow_data
->tab
);
3038 LttTime end_time
= time_window
.end_time
;
3041 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3042 || ltt_time_compare(evtime
, end_time
) == 1)
3044 #endif //EXTRA_CHECK
3046 guint width
= drawing
->width
;
3049 /* For the process */
3050 /* First, check if the current process is in the state computation
3051 * process list. If it is there, that means we must add it right now and
3052 * draw items from the beginning of the read for it. If it is not
3053 * present, it's a new process and it was not present : it will
3054 * be added after the state update. */
3055 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3057 /* tracefiles[0] is ok here, because we draw for every PID, and
3058 * assume CPU 0 for PID 0 //FIXME */
3059 LttvTracefileState
*tfs
=
3060 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
3062 LttvProcessState
*process
;
3063 process
= lttv_state_find_process(tfs
,
3066 if(process
!= NULL
) {
3068 /* Only draw for processes that are currently in the trace states */
3070 guint y
= 0, height
= 0, pl_height
= 0;
3071 ProcessList
*process_list
= control_flow_data
->process_list
;
3072 LttTime birth
= process_info
->birth
;
3074 /* Should be alike when background info is ready */
3075 if(control_flow_data
->background_info_waiting
==0)
3076 g_assert(ltt_time_compare(process
->creation_time
,
3077 process_info
->birth
) == 0);
3078 const gchar
*name
= g_quark_to_string(process
->name
);
3080 /* process HAS to be present */
3081 processlist_get_pixels_from_data(process_list
,
3083 hashed_process_data
,
3087 /* Now, the process is in the state hash and our own process hash.
3088 * We definitely can draw the items related to the ending state.
3091 /* Check if the x position is unset. In can have been left unset by
3092 * a draw closure from a after chunk hook. This should never happen,
3093 * because it must be set by before chunk hook to the damage_begin
3096 g_assert(hashed_process_data
->x
.over
!= -1);
3098 if(ltt_time_compare(hashed_process_data
->next_good_time
,
3103 convert_time_to_pixels(
3109 DrawContext draw_context
;
3111 /* Now create the drawing context that will be used to draw
3112 * items related to the last state. */
3113 draw_context
.drawable
= drawing
->pixmap
;
3114 draw_context
.gc
= drawing
->gc
;
3115 draw_context
.pango_layout
= drawing
->pango_layout
;
3116 draw_context
.drawinfo
.end
.x
= x
;
3118 draw_context
.drawinfo
.y
.over
= y
+1;
3119 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3120 draw_context
.drawinfo
.y
.under
= y
+height
;
3122 draw_context
.drawinfo
.start
.offset
.over
= 0;
3123 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3124 draw_context
.drawinfo
.start
.offset
.under
= 0;
3125 draw_context
.drawinfo
.end
.offset
.over
= 0;
3126 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3127 draw_context
.drawinfo
.end
.offset
.under
= 0;
3129 /* Jump over draw if we are at the same x position */
3130 if(x
== hashed_process_data
->x
.over
)
3134 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3136 PropertiesLine prop_line
= prepare_execmode_line(process
);
3137 draw_line((void*)&prop_line
, (void*)&draw_context
);
3139 hashed_process_data
->x
.over
= x
;
3143 if(x
== hashed_process_data
->x
.middle
&&
3144 hashed_process_data
->x
.middle_used
) {
3145 #if 0 /* do not mark closure : not missing information */
3146 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3147 /* Draw collision indicator */
3148 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3149 gdk_draw_point(drawing
->pixmap
,
3153 hashed_process_data
->x
.middle_marked
= TRUE
;
3158 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3160 PropertiesLine prop_line
= prepare_s_e_line(process
);
3161 draw_line((void*)&prop_line
, (void*)&draw_context
);
3163 /* become the last x position */
3164 if(x
!= hashed_process_data
->x
.middle
) {
3165 hashed_process_data
->x
.middle
= x
;
3166 /* but don't use the pixel */
3167 hashed_process_data
->x
.middle_used
= FALSE
;
3169 /* Calculate the next good time */
3170 convert_pixels_to_time(width
, x
+1, time_window
,
3171 &hashed_process_data
->next_good_time
);
3180 int before_chunk(void *hook_data
, void *call_data
)
3182 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3183 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3185 drawing_chunk_begin(events_request
, tss
);
3190 int before_request(void *hook_data
, void *call_data
)
3192 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3193 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3195 drawing_data_request_begin(events_request
, tss
);
3202 * after request is necessary in addition of after chunk in order to draw
3203 * lines until the end of the screen. after chunk just draws lines until
3210 int after_request(void *hook_data
, void *call_data
)
3212 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3213 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3214 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3215 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3217 ProcessList
*process_list
= control_flow_data
->process_list
;
3218 LttTime end_time
= events_request
->end_time
;
3220 ClosureData closure_data
;
3221 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3222 closure_data
.tss
= tss
;
3223 closure_data
.end_time
= end_time
;
3225 /* Draw last items */
3226 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3227 (void*)&closure_data
);
3229 /* Request expose */
3230 drawing_request_expose(events_request
, tss
, end_time
);
3239 int after_chunk(void *hook_data
, void *call_data
)
3241 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3242 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3243 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3244 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3245 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3248 ProcessList
*process_list
= control_flow_data
->process_list
;
3251 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3252 else /* end of traceset, or position now out of request : end */
3253 end_time
= events_request
->end_time
;
3255 ClosureData closure_data
;
3256 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3257 closure_data
.tss
= tss
;
3258 closure_data
.end_time
= end_time
;
3260 /* Draw last items */
3261 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3262 (void*)&closure_data
);
3264 /* Request expose */
3265 drawing_request_expose(events_request
, tss
, end_time
);