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
=
101 guicontrolflow_get_process_list(control_flow_data
);
104 birth
= process
->creation_time
;
105 const gchar
*name
= g_quark_to_string(process
->name
);
106 HashedProcessData
*hashed_process_data
= NULL
;
108 if(processlist_get_process_pixels(process_list
,
114 &hashed_process_data
) == 1)
116 /* Process not present */
117 processlist_add(process_list
,
123 &hashed_process_data
);
124 processlist_get_process_pixels(process_list
,
130 &hashed_process_data
);
131 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
137 /* Action to do when background computation completed.
139 * Wait for all the awaited computations to be over.
142 gint
background_ready(void *hook_data
, void *call_data
)
144 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
145 LttvTrace
*trace
= (LttvTrace
*)call_data
;
146 LttvTracesetContext
*tsc
=
147 lttvwindow_get_traceset_context(control_flow_data
->tab
);
149 control_flow_data
->background_info_waiting
--;
151 if(control_flow_data
->background_info_waiting
== 0) {
152 g_debug("control flow viewer : background computation data ready.");
154 drawing_clear(control_flow_data
->drawing
);
155 processlist_clear(control_flow_data
->process_list
);
156 redraw_notify(control_flow_data
, NULL
);
163 /* Request background computation. Verify if it is in progress or ready first.
164 * Only for each trace in the tab's traceset.
166 void request_background_data(ControlFlowData
*control_flow_data
)
168 LttvTracesetContext
* tsc
=
169 lttvwindow_get_traceset_context(control_flow_data
->tab
);
170 gint num_traces
= lttv_traceset_number(tsc
->ts
);
174 LttvHooks
*background_ready_hook
=
176 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
178 control_flow_data
->background_info_waiting
= 0;
180 for(i
=0;i
<num_traces
;i
++) {
181 trace
= lttv_traceset_get(tsc
->ts
, i
);
183 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
185 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
187 /* We first remove requests that could have been done for the same
188 * information. Happens when two viewers ask for it before servicing
191 lttvwindowtraces_background_request_remove(trace
, "state");
192 lttvwindowtraces_background_request_queue(trace
,
194 lttvwindowtraces_background_notify_queue(control_flow_data
,
198 background_ready_hook
);
199 control_flow_data
->background_info_waiting
++;
200 } else { /* in progress */
202 lttvwindowtraces_background_notify_current(control_flow_data
,
206 background_ready_hook
);
207 control_flow_data
->background_info_waiting
++;
210 /* Data ready. Be its nature, this viewer doesn't need to have
211 * its data ready hook called htere, because a background
212 * request is always linked with a redraw.
218 lttv_hooks_destroy(background_ready_hook
);
225 * Event Viewer's constructor hook
227 * This constructor is given as a parameter to the menuitem and toolbar button
228 * registration. It creates the list.
229 * @param tab A pointer to the parent tab.
230 * @return The widget created.
233 h_guicontrolflow(Tab
*tab
)
235 g_info("h_guicontrolflow, %p", tab
);
236 ControlFlowData
*control_flow_data
= guicontrolflow() ;
238 control_flow_data
->tab
= tab
;
240 //g_debug("time width2 : %u",time_window->time_width);
241 // Unreg done in the GuiControlFlow_Destructor
242 lttvwindow_register_traceset_notify(tab
,
246 lttvwindow_register_time_window_notify(tab
,
247 update_time_window_hook
,
249 lttvwindow_register_current_time_notify(tab
,
250 update_current_time_hook
,
252 lttvwindow_register_redraw_notify(tab
,
255 lttvwindow_register_continue_notify(tab
,
258 request_background_data(control_flow_data
);
261 return guicontrolflow_get_widget(control_flow_data
) ;
265 int event_selected_hook(void *hook_data
, void *call_data
)
267 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
268 guint
*event_number
= (guint
*) call_data
;
270 g_debug("DEBUG : event selected by main window : %u", *event_number
);
274 /* Function that selects the color of status&exemode line */
275 static __inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
277 PropertiesLine prop_line
;
278 prop_line
.line_width
= 2;
279 prop_line
.style
= GDK_LINE_SOLID
;
280 prop_line
.y
= MIDDLE
;
281 //GdkColormap *colormap = gdk_colormap_get_system();
283 g_debug("prepare_status_line for state : %s",
284 g_quark_to_string(process
->state
->s
));
286 if(process
->state
->s
== LTTV_STATE_RUN
) {
287 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
288 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
289 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
290 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
291 else if(process
->state
->t
== LTTV_STATE_TRAP
)
292 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
293 else if(process
->state
->t
== LTTV_STATE_IRQ
)
294 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
295 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
296 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
298 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
299 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
300 /* We don't show if we wait while in user mode, trap, irq or syscall */
301 prop_line
.color
= drawing_colors
[COL_WAIT
];
302 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
303 /* We don't show if we wait for CPU while in user mode, trap, irq
305 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
306 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
307 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
308 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
309 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
310 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
311 prop_line
.color
= drawing_colors
[COL_EXIT
];
312 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
313 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
315 g_assert(FALSE
); /* UNKNOWN STATE */
322 static __inline PropertiesLine
prepare_status_line(LttvProcessState
*process
)
324 PropertiesLine prop_line
;
325 prop_line
.line_width
= 2;
326 prop_line
.style
= GDK_LINE_SOLID
;
327 prop_line
.y
= MIDDLE
;
328 //GdkColormap *colormap = gdk_colormap_get_system();
330 g_debug("prepare_status_line for state : %s",
331 g_quark_to_string(process
->state
->s
));
333 /* color of line : status of the process */
334 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
335 prop_line
.color
= drawing_colors
[COL_WHITE
];
336 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
337 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
338 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
339 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
340 else if(process
->state
->s
== LTTV_STATE_EXIT
)
341 prop_line
.color
= drawing_colors
[COL_EXIT
];
342 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
343 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
344 else if(process
->state
->s
== LTTV_STATE_WAIT
)
345 prop_line
.color
= drawing_colors
[COL_WAIT
];
346 else if(process
->state
->s
== LTTV_STATE_RUN
)
347 prop_line
.color
= drawing_colors
[COL_RUN
];
349 prop_line
.color
= drawing_colors
[COL_WHITE
];
351 //gdk_colormap_alloc_color(colormap,
362 /* before_schedchange_hook
364 * This function basically draw lines and icons. Two types of lines are drawn :
365 * one small (3 pixels?) representing the state of the process and the second
366 * type is thicker (10 pixels?) representing on which CPU a process is running
367 * (and this only in running state).
369 * Extremums of the lines :
370 * x_min : time of the last event context for this process kept in memory.
371 * x_max : time of the current event.
372 * y : middle of the process in the process list. The process is found in the
373 * list, therefore is it's position in pixels.
375 * The choice of lines'color is defined by the context of the last event for this
380 int before_schedchange_hook(void *hook_data
, void *call_data
)
382 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
383 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
384 Drawing_t
*drawing
= control_flow_data
->drawing
;
386 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
388 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
389 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
394 LttTime evtime
= ltt_event_time(e
);
395 TimeWindow time_window
=
396 lttvwindow_get_time_window(control_flow_data
->tab
);
398 LttTime end_time
= ltt_time_add(time_window
.start_time
,
399 time_window
.time_width
);
401 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
402 || ltt_time_compare(evtime
, end_time
) == 1)
404 guint width
= drawing
->width
;
406 /* we are in a schedchange, before the state update. We must draw the
407 * items corresponding to the state before it changes : now is the right
414 LttField
*f
= ltt_event_field(e
);
416 element
= ltt_field_member(f
,0);
417 pid_out
= ltt_event_get_long_unsigned(e
,element
);
418 element
= ltt_field_member(f
,1);
419 pid_in
= ltt_event_get_long_unsigned(e
,element
);
420 g_debug("out : %u in : %u", pid_out
, pid_in
);
424 /* For the pid_out */
425 /* First, check if the current process is in the state computation
426 * process list. If it is there, that means we must add it right now and
427 * draw items from the beginning of the read for it. If it is not
428 * present, it's a new process and it was not present : it will
429 * be added after the state update. */
430 LttvProcessState
*process
;
431 process
= lttv_state_find_process(tfs
, pid_out
);
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
=
441 guicontrolflow_get_process_list(control_flow_data
);
442 LttTime birth
= process
->creation_time
;
443 const gchar
*name
= g_quark_to_string(process
->name
);
445 if(processlist_get_process_pixels(process_list
,
449 tfc
->t_context
->index
,
452 &hashed_process_data
) == 1)
454 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
455 /* Process not present */
456 processlist_add(process_list
,
461 tfc
->t_context
->index
,
464 &hashed_process_data
);
465 processlist_get_process_pixels(process_list
,
469 tfc
->t_context
->index
,
472 &hashed_process_data
);
473 drawing_insert_square( drawing
, y
, height
);
476 /* Now, the process is in the state hash and our own process hash.
477 * We definitely can draw the items related to the ending state.
480 /* Check if the x position is unset. In can have been left unset by
481 * a draw closure from a after chunk hook. This should never happen,
482 * because it must be set by before chunk hook to the damage_begin
485 g_assert(hashed_process_data
->x
.middle
!= -1);
488 convert_time_to_pixels(
489 time_window
.start_time
,
496 /* Jump over draw if we are at the same x position */
497 if(x
== hashed_process_data
->x
.middle
)
501 DrawContext draw_context
;
503 /* Now create the drawing context that will be used to draw
504 * items related to the last state. */
505 draw_context
.drawable
= drawing
->pixmap
;
506 draw_context
.gc
= drawing
->gc
;
507 draw_context
.pango_layout
= drawing
->pango_layout
;
508 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
509 draw_context
.drawinfo
.end
.x
= x
;
511 draw_context
.drawinfo
.y
.over
= y
+1;
512 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
513 draw_context
.drawinfo
.y
.under
= y
+height
;
515 draw_context
.drawinfo
.start
.offset
.over
= 0;
516 draw_context
.drawinfo
.start
.offset
.middle
= 0;
517 draw_context
.drawinfo
.start
.offset
.under
= 0;
518 draw_context
.drawinfo
.end
.offset
.over
= 0;
519 draw_context
.drawinfo
.end
.offset
.middle
= 0;
520 draw_context
.drawinfo
.end
.offset
.under
= 0;
524 PropertiesLine prop_line
= prepare_s_e_line(process
);
525 draw_line((void*)&prop_line
, (void*)&draw_context
);
528 /* become the last x position */
529 hashed_process_data
->x
.middle
= x
;
537 /* First, check if the current process is in the state computation
538 * process list. If it is there, that means we must add it right now and
539 * draw items from the beginning of the read for it. If it is not
540 * present, it's a new process and it was not present : it will
541 * be added after the state update. */
542 LttvProcessState
*process
;
543 process
= lttv_state_find_process(tfs
, pid_in
);
545 if(process
!= NULL
) {
546 /* Well, the process_out existed : we must get it in the process hash
547 * or add it, and draw its items.
549 /* Add process to process list (if not present) */
550 guint y
= 0, height
= 0, pl_height
= 0;
551 HashedProcessData
*hashed_process_data
= NULL
;
552 ProcessList
*process_list
=
553 guicontrolflow_get_process_list(control_flow_data
);
554 LttTime birth
= process
->creation_time
;
555 const gchar
*name
= g_quark_to_string(process
->name
);
557 if(processlist_get_process_pixels(process_list
,
561 tfc
->t_context
->index
,
564 &hashed_process_data
) == 1)
566 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
567 /* Process not present */
568 processlist_add(process_list
,
573 tfc
->t_context
->index
,
576 &hashed_process_data
);
577 processlist_get_process_pixels(process_list
,
581 tfc
->t_context
->index
,
584 &hashed_process_data
);
585 drawing_insert_square( drawing
, y
, height
);
588 /* Now, the process is in the state hash and our own process hash.
589 * We definitely can draw the items related to the ending state.
592 /* Check if the x position is unset. In can have been left unset by
593 * a draw closure from a after chunk hook. This should never happen,
594 * because it must be set by before chunk hook to the damage_begin
597 g_assert(hashed_process_data
->x
.middle
!= -1);
601 convert_time_to_pixels(
602 time_window
.start_time
,
609 /* Jump over draw if we are at the same x position */
610 if(x
== hashed_process_data
->x
.middle
)
614 DrawContext draw_context
;
616 /* Now create the drawing context that will be used to draw
617 * items related to the last state. */
618 draw_context
.drawable
= drawing
->pixmap
;
619 draw_context
.gc
= drawing
->gc
;
620 draw_context
.pango_layout
= drawing
->pango_layout
;
621 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
622 draw_context
.drawinfo
.end
.x
= x
;
624 draw_context
.drawinfo
.y
.over
= y
+1;
625 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
626 draw_context
.drawinfo
.y
.under
= y
+height
;
628 draw_context
.drawinfo
.start
.offset
.over
= 0;
629 draw_context
.drawinfo
.start
.offset
.middle
= 0;
630 draw_context
.drawinfo
.start
.offset
.under
= 0;
631 draw_context
.drawinfo
.end
.offset
.over
= 0;
632 draw_context
.drawinfo
.end
.offset
.middle
= 0;
633 draw_context
.drawinfo
.end
.offset
.under
= 0;
637 PropertiesLine prop_line
= prepare_s_e_line(process
);
638 draw_line((void*)&prop_line
, (void*)&draw_context
);
642 /* become the last x position */
643 hashed_process_data
->x
.middle
= x
;
652 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
653 ControlFlowData
*control_flow_data
=
654 (ControlFlowData
*)events_request
->viewer_data
;
655 Tab
*tab
= control_flow_data
->tab
;
657 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
659 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
660 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
665 LttTime evtime
= ltt_event_time(e
);
666 TimeWindow time_window
=
667 lttvwindow_get_time_window(tab
);
669 LttTime end_time
= ltt_time_add(time_window
.start_time
,
670 time_window
.time_width
);
671 //if(time < time_beg || time > time_end) return;
672 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
673 || ltt_time_compare(evtime
, end_time
) == 1)
676 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
678 g_debug("schedchange!");
680 /* Add process to process list (if not present) and get drawing "y" from
681 * process position */
682 guint pid_out
, pid_in
;
683 LttvProcessState
*process_out
, *process_in
;
685 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
687 ProcessList
*process_list
=
688 guicontrolflow_get_process_list(control_flow_data
);
691 LttField
*f
= ltt_event_field(e
);
693 element
= ltt_field_member(f
,0);
694 pid_out
= ltt_event_get_long_unsigned(e
,element
);
695 element
= ltt_field_member(f
,1);
696 pid_in
= ltt_event_get_long_unsigned(e
,element
);
697 g_debug("out : %u in : %u", pid_out
, pid_in
);
700 /* Find process pid_out in the list... */
701 process_out
= lttv_state_find_process(tfs
, pid_out
);
702 if(process_out
== NULL
) return 0;
703 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
705 birth
= process_out
->creation_time
;
706 const gchar
*name
= g_quark_to_string(process_out
->name
);
707 HashedProcessData
*hashed_process_data_out
= NULL
;
709 if(processlist_get_process_pixels(process_list
,
712 tfc
->t_context
->index
,
715 &hashed_process_data_out
) == 1)
717 /* Process not present */
718 processlist_add(process_list
,
721 tfc
->t_context
->index
,
724 &hashed_process_data_out
);
725 g_assert(processlist_get_process_pixels(process_list
,
728 tfc
->t_context
->index
,
731 &hashed_process_data_out
)==0);
732 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
736 /* Find process pid_in in the list... */
737 process_in
= lttv_state_find_process(tfs
, pid_in
);
738 if(process_in
== NULL
) return 0;
739 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
741 birth
= process_in
->creation_time
;
742 name
= g_quark_to_string(process_in
->name
);
743 HashedProcessData
*hashed_process_data_in
= NULL
;
745 if(processlist_get_process_pixels(process_list
,
748 tfc
->t_context
->index
,
751 &hashed_process_data_in
) == 1)
753 /* Process not present */
754 processlist_add(process_list
,
757 tfc
->t_context
->index
,
760 &hashed_process_data_in
);
761 processlist_get_process_pixels(process_list
,
764 tfc
->t_context
->index
,
767 &hashed_process_data_in
);
769 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
774 /* Find pixels corresponding to time of the event. If the time does
775 * not fit in the window, show a warning, not supposed to happend. */
777 guint width
= control_flow_data
->drawing
->width
;
779 LttTime time
= ltt_event_time(e
);
781 LttTime window_end
= ltt_time_add(time_window
.time_width
,
782 time_window
.start_time
);
785 convert_time_to_pixels(
786 time_window
.start_time
,
791 //assert(x <= width);
793 /* draw what represents the event for outgoing process. */
795 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
796 draw_context_out
->current
->modify_over
->x
= x
;
797 draw_context_out
->current
->modify_under
->x
= x
;
798 draw_context_out
->current
->modify_over
->y
= y_out
;
799 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
800 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
801 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
802 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
803 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
804 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
805 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
806 //draw_context_out->gc = widget->style->black_gc;
808 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
809 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
811 /* Draw the line/background of the out process */
812 if(draw_context_out
->previous
->middle
->x
== -1)
814 draw_context_out
->previous
->over
->x
=
815 control_flow_data
->drawing
->damage_begin
;
816 draw_context_out
->previous
->middle
->x
=
817 control_flow_data
->drawing
->damage_begin
;
818 draw_context_out
->previous
->under
->x
=
819 control_flow_data
->drawing
->damage_begin
;
821 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
824 draw_context_out
->current
->middle
->x
= x
;
825 draw_context_out
->current
->over
->x
= x
;
826 draw_context_out
->current
->under
->x
= x
;
827 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
828 draw_context_out
->current
->over
->y
= y_out
;
829 draw_context_out
->current
->under
->y
= y_out
+ height
;
830 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
831 draw_context_out
->previous
->over
->y
= y_out
;
832 draw_context_out
->previous
->under
->y
= y_out
+ height
;
834 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
835 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
837 if(process_out
->state
->s
== LTTV_STATE_RUN
)
839 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
840 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
841 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
843 PropertiesBG prop_bg
;
844 prop_bg
.color
= g_new(GdkColor
,1);
848 prop_bg
.color
->red
= 0x1515;
849 prop_bg
.color
->green
= 0x1515;
850 prop_bg
.color
->blue
= 0x8c8c;
853 prop_bg
.color
->red
= 0x4e4e;
854 prop_bg
.color
->green
= 0xa9a9;
855 prop_bg
.color
->blue
= 0xa4a4;
858 prop_bg
.color
->red
= 0x7a7a;
859 prop_bg
.color
->green
= 0x4a4a;
860 prop_bg
.color
->blue
= 0x8b8b;
863 prop_bg
.color
->red
= 0x8080;
864 prop_bg
.color
->green
= 0x7777;
865 prop_bg
.color
->blue
= 0x4747;
868 prop_bg
.color
->red
= 0xe7e7;
869 prop_bg
.color
->green
= 0xe7e7;
870 prop_bg
.color
->blue
= 0xe7e7;
873 g_debug("calling from draw_event");
874 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
875 g_free(prop_bg
.color
);
876 //gdk_gc_unref(draw_context_out->gc);
879 draw_context_out
->gc
= widget
->style
->black_gc
;
881 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
882 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
883 PropertiesText prop_text_out
;
884 prop_text_out
.foreground
= &colorfg_out
;
885 prop_text_out
.background
= &colorbg_out
;
886 prop_text_out
.size
= 6;
887 prop_text_out
.position
= OVER
;
889 /* color of text : status of the process */
890 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
892 prop_text_out
.foreground
->red
= 0xffff;
893 prop_text_out
.foreground
->green
= 0xffff;
894 prop_text_out
.foreground
->blue
= 0xffff;
896 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
898 prop_text_out
.foreground
->red
= 0x0fff;
899 prop_text_out
.foreground
->green
= 0xffff;
900 prop_text_out
.foreground
->blue
= 0xfff0;
902 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
904 prop_text_out
.foreground
->red
= 0xffff;
905 prop_text_out
.foreground
->green
= 0xffff;
906 prop_text_out
.foreground
->blue
= 0x0000;
908 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
910 prop_text_out
.foreground
->red
= 0xffff;
911 prop_text_out
.foreground
->green
= 0x0000;
912 prop_text_out
.foreground
->blue
= 0xffff;
914 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
916 prop_text_out
.foreground
->red
= 0xffff;
917 prop_text_out
.foreground
->green
= 0x0000;
918 prop_text_out
.foreground
->blue
= 0x0000;
920 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
922 prop_text_out
.foreground
->red
= 0x0000;
923 prop_text_out
.foreground
->green
= 0xffff;
924 prop_text_out
.foreground
->blue
= 0x0000;
928 prop_text_out
.foreground
->red
= 0xffff;
929 prop_text_out
.foreground
->green
= 0xffff;
930 prop_text_out
.foreground
->blue
= 0xffff;
934 /* Print status of the process : U, WF, WC, E, W, R */
935 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
936 prop_text_out
.text
= "U->";
937 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
938 prop_text_out
.text
= "WF->";
939 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
940 prop_text_out
.text
= "WC->";
941 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
942 prop_text_out
.text
= "E->";
943 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
944 prop_text_out
.text
= "W->";
945 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
946 prop_text_out
.text
= "R->";
948 prop_text_out
.text
= "U";
950 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
951 //gdk_gc_unref(draw_context_out->gc);
953 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
954 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
955 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
957 PropertiesLine prop_line_out
;
958 prop_line_out
.color
= g_new(GdkColor
,1);
959 prop_line_out
.line_width
= 2;
960 prop_line_out
.style
= GDK_LINE_SOLID
;
961 prop_line_out
.position
= MIDDLE
;
963 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
965 /* color of line : status of the process */
966 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
968 prop_line_out
.color
->red
= 0xffff;
969 prop_line_out
.color
->green
= 0xffff;
970 prop_line_out
.color
->blue
= 0xffff;
972 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
974 prop_line_out
.color
->red
= 0x0fff;
975 prop_line_out
.color
->green
= 0xffff;
976 prop_line_out
.color
->blue
= 0xfff0;
978 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
980 prop_line_out
.color
->red
= 0xffff;
981 prop_line_out
.color
->green
= 0xffff;
982 prop_line_out
.color
->blue
= 0x0000;
984 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
986 prop_line_out
.color
->red
= 0xffff;
987 prop_line_out
.color
->green
= 0x0000;
988 prop_line_out
.color
->blue
= 0xffff;
990 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
992 prop_line_out
.color
->red
= 0xffff;
993 prop_line_out
.color
->green
= 0x0000;
994 prop_line_out
.color
->blue
= 0x0000;
996 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
998 prop_line_out
.color
->red
= 0x0000;
999 prop_line_out
.color
->green
= 0xffff;
1000 prop_line_out
.color
->blue
= 0x0000;
1004 prop_line_out
.color
->red
= 0xffff;
1005 prop_line_out
.color
->green
= 0xffff;
1006 prop_line_out
.color
->blue
= 0xffff;
1009 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1010 g_free(prop_line_out
.color
);
1011 //gdk_gc_unref(draw_context_out->gc);
1012 /* Note : finishing line will have to be added when trace read over. */
1014 /* Finally, update the drawing context of the pid_in. */
1016 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1017 draw_context_in
->current
->modify_over
->x
= x
;
1018 draw_context_in
->current
->modify_under
->x
= x
;
1019 draw_context_in
->current
->modify_over
->y
= y_in
;
1020 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1021 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1022 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1023 widget
= control_flow_data
->drawing
->drawing_area
;
1024 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1025 //draw_context_in->gc = widget->style->black_gc;
1026 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1027 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1029 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1030 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1032 /* Draw the line/bg of the in process */
1033 if(draw_context_in
->previous
->middle
->x
== -1)
1035 draw_context_in
->previous
->over
->x
=
1036 control_flow_data
->drawing
->damage_begin
;
1037 draw_context_in
->previous
->middle
->x
=
1038 control_flow_data
->drawing
->damage_begin
;
1039 draw_context_in
->previous
->under
->x
=
1040 control_flow_data
->drawing
->damage_begin
;
1042 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1046 draw_context_in
->current
->middle
->x
= x
;
1047 draw_context_in
->current
->over
->x
= x
;
1048 draw_context_in
->current
->under
->x
= x
;
1049 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1050 draw_context_in
->current
->over
->y
= y_in
;
1051 draw_context_in
->current
->under
->y
= y_in
+ height
;
1052 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1053 draw_context_in
->previous
->over
->y
= y_in
;
1054 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1056 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1057 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1060 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1062 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1063 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1064 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1066 PropertiesBG prop_bg
;
1067 prop_bg
.color
= g_new(GdkColor
,1);
1069 switch(tfc
->index
) {
1071 prop_bg
.color
->red
= 0x1515;
1072 prop_bg
.color
->green
= 0x1515;
1073 prop_bg
.color
->blue
= 0x8c8c;
1076 prop_bg
.color
->red
= 0x4e4e;
1077 prop_bg
.color
->green
= 0xa9a9;
1078 prop_bg
.color
->blue
= 0xa4a4;
1081 prop_bg
.color
->red
= 0x7a7a;
1082 prop_bg
.color
->green
= 0x4a4a;
1083 prop_bg
.color
->blue
= 0x8b8b;
1086 prop_bg
.color
->red
= 0x8080;
1087 prop_bg
.color
->green
= 0x7777;
1088 prop_bg
.color
->blue
= 0x4747;
1091 prop_bg
.color
->red
= 0xe7e7;
1092 prop_bg
.color
->green
= 0xe7e7;
1093 prop_bg
.color
->blue
= 0xe7e7;
1097 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1098 g_free(prop_bg
.color
);
1099 //gdk_gc_unref(draw_context_in->gc);
1102 draw_context_in
->gc
= widget
->style
->black_gc
;
1104 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1105 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1106 PropertiesText prop_text_in
;
1107 prop_text_in
.foreground
= &colorfg_in
;
1108 prop_text_in
.background
= &colorbg_in
;
1109 prop_text_in
.size
= 6;
1110 prop_text_in
.position
= OVER
;
1112 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1113 /* foreground of text : status of the process */
1114 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1116 prop_text_in
.foreground
->red
= 0xffff;
1117 prop_text_in
.foreground
->green
= 0xffff;
1118 prop_text_in
.foreground
->blue
= 0xffff;
1120 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1122 prop_text_in
.foreground
->red
= 0x0fff;
1123 prop_text_in
.foreground
->green
= 0xffff;
1124 prop_text_in
.foreground
->blue
= 0xfff0;
1126 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1128 prop_text_in
.foreground
->red
= 0xffff;
1129 prop_text_in
.foreground
->green
= 0xffff;
1130 prop_text_in
.foreground
->blue
= 0x0000;
1132 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1134 prop_text_in
.foreground
->red
= 0xffff;
1135 prop_text_in
.foreground
->green
= 0x0000;
1136 prop_text_in
.foreground
->blue
= 0xffff;
1138 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1140 prop_text_in
.foreground
->red
= 0xffff;
1141 prop_text_in
.foreground
->green
= 0x0000;
1142 prop_text_in
.foreground
->blue
= 0x0000;
1144 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1146 prop_text_in
.foreground
->red
= 0x0000;
1147 prop_text_in
.foreground
->green
= 0xffff;
1148 prop_text_in
.foreground
->blue
= 0x0000;
1152 prop_text_in
.foreground
->red
= 0xffff;
1153 prop_text_in
.foreground
->green
= 0xffff;
1154 prop_text_in
.foreground
->blue
= 0xffff;
1159 /* Print status of the process : U, WF, WC, E, W, R */
1160 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1161 prop_text_in
.text
= "U->";
1162 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1163 prop_text_in
.text
= "WF->";
1164 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1165 prop_text_in
.text
= "WC->";
1166 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1167 prop_text_in
.text
= "E->";
1168 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1169 prop_text_in
.text
= "W->";
1170 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1171 prop_text_in
.text
= "R->";
1173 prop_text_in
.text
= "U";
1175 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1176 //gdk_gc_unref(draw_context_in->gc);
1178 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1179 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1180 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1182 PropertiesLine prop_line_in
;
1183 prop_line_in
.color
= g_new(GdkColor
,1);
1184 prop_line_in
.line_width
= 2;
1185 prop_line_in
.style
= GDK_LINE_SOLID
;
1186 prop_line_in
.position
= MIDDLE
;
1188 /* color of line : status of the process */
1189 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1191 prop_line_in
.color
->red
= 0xffff;
1192 prop_line_in
.color
->green
= 0xffff;
1193 prop_line_in
.color
->blue
= 0xffff;
1195 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1197 prop_line_in
.color
->red
= 0x0fff;
1198 prop_line_in
.color
->green
= 0xffff;
1199 prop_line_in
.color
->blue
= 0xfff0;
1201 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1203 prop_line_in
.color
->red
= 0xffff;
1204 prop_line_in
.color
->green
= 0xffff;
1205 prop_line_in
.color
->blue
= 0x0000;
1207 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1209 prop_line_in
.color
->red
= 0xffff;
1210 prop_line_in
.color
->green
= 0x0000;
1211 prop_line_in
.color
->blue
= 0xffff;
1213 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1215 prop_line_in
.color
->red
= 0xffff;
1216 prop_line_in
.color
->green
= 0x0000;
1217 prop_line_in
.color
->blue
= 0x0000;
1219 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1221 prop_line_in
.color
->red
= 0x0000;
1222 prop_line_in
.color
->green
= 0xffff;
1223 prop_line_in
.color
->blue
= 0x0000;
1227 prop_line_in
.color
->red
= 0xffff;
1228 prop_line_in
.color
->green
= 0xffff;
1229 prop_line_in
.color
->blue
= 0xffff;
1232 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1233 g_free(prop_line_in
.color
);
1234 //gdk_gc_unref(draw_context_in->gc);
1244 GString
*string
= g_string_new("");;
1245 gboolean field_names
= TRUE
, state
= TRUE
;
1247 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1248 g_string_append_printf(string
,"\n");
1251 g_string_append_printf(string
, " %s",
1252 g_quark_to_string(tfs
->process
->state
->s
));
1255 g_info("%s",string
->str
);
1257 g_string_free(string
, TRUE
);
1259 /* End of text dump */
1264 /* after_schedchange_hook
1266 * The draw after hook is called by the reading API to have a
1267 * particular event drawn on the screen.
1268 * @param hook_data ControlFlowData structure of the viewer.
1269 * @param call_data Event context.
1271 * This function adds items to be drawn in a queue for each process.
1274 int after_schedchange_hook(void *hook_data
, void *call_data
)
1276 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1277 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1279 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1281 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1282 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1287 LttTime evtime
= ltt_event_time(e
);
1288 TimeWindow time_window
=
1289 lttvwindow_get_time_window(control_flow_data
->tab
);
1291 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1292 time_window
.time_width
);
1294 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1295 || ltt_time_compare(evtime
, end_time
) == 1)
1298 guint width
= control_flow_data
->drawing
->width
;
1300 /* Add process to process list (if not present) */
1301 LttvProcessState
*process_out
, *process_in
;
1303 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1304 HashedProcessData
*hashed_process_data_in
= NULL
;
1306 ProcessList
*process_list
=
1307 guicontrolflow_get_process_list(control_flow_data
);
1312 LttField
*f
= ltt_event_field(e
);
1314 element
= ltt_field_member(f
,0);
1315 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1316 element
= ltt_field_member(f
,1);
1317 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1318 g_debug("out : %u in : %u", pid_out
, pid_in
);
1322 /* Find process pid_in in the list... */
1323 process_in
= lttv_state_find_process(tfs
, pid_in
);
1324 /* It should exist, because we are after the state update. */
1325 g_assert(process_in
!= NULL
);
1327 birth
= process_in
->creation_time
;
1328 const gchar
*name
= g_quark_to_string(process_in
->name
);
1330 if(processlist_get_process_pixels(process_list
,
1332 process_in
->last_cpu
,
1334 tfc
->t_context
->index
,
1337 &hashed_process_data_in
) == 1)
1339 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1340 /* Process not present */
1341 processlist_add(process_list
,
1343 process_in
->last_cpu
,
1346 tfc
->t_context
->index
,
1349 &hashed_process_data_in
);
1350 processlist_get_process_pixels(process_list
,
1352 process_in
->last_cpu
,
1354 tfc
->t_context
->index
,
1357 &hashed_process_data_in
);
1358 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1361 convert_time_to_pixels(
1362 time_window
.start_time
,
1366 &hashed_process_data_in
->x
.middle
);
1372 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1373 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1375 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1377 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1378 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1384 LttTime evtime
= ltt_event_time(e
);
1385 TimeWindow time_window
=
1386 lttvwindow_get_time_window(control_flow_data
->tab
);
1388 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1389 time_window
.time_width
);
1390 //if(time < time_beg || time > time_end) return;
1391 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1392 || ltt_time_compare(evtime
, end_time
) == 1)
1396 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1398 g_debug("schedchange!");
1400 /* Add process to process list (if not present) and get drawing "y" from
1401 * process position */
1402 guint pid_out
, pid_in
;
1403 LttvProcessState
*process_out
, *process_in
;
1405 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1407 ProcessList
*process_list
=
1408 guicontrolflow_get_process_list(control_flow_data
);
1411 LttField
*f
= ltt_event_field(e
);
1413 element
= ltt_field_member(f
,0);
1414 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1415 element
= ltt_field_member(f
,1);
1416 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1417 //g_debug("out : %u in : %u", pid_out, pid_in);
1420 /* Find process pid_out in the list... */
1421 process_out
= lttv_state_find_process(tfs
, pid_out
);
1422 if(process_out
== NULL
) return 0;
1423 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1425 birth
= process_out
->creation_time
;
1426 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1427 HashedProcessData
*hashed_process_data_out
= NULL
;
1429 if(processlist_get_process_pixels(process_list
,
1432 tfc
->t_context
->index
,
1435 &hashed_process_data_out
) == 1)
1437 /* Process not present */
1438 processlist_add(process_list
,
1441 tfc
->t_context
->index
,
1444 &hashed_process_data_out
);
1445 processlist_get_process_pixels(process_list
,
1448 tfc
->t_context
->index
,
1451 &hashed_process_data_out
);
1452 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1457 /* Find process pid_in in the list... */
1458 process_in
= lttv_state_find_process(tfs
, pid_in
);
1459 if(process_in
== NULL
) return 0;
1460 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1462 birth
= process_in
->creation_time
;
1463 name
= strdup(g_quark_to_string(process_in
->name
));
1464 HashedProcessData
*hashed_process_data_in
= NULL
;
1466 if(processlist_get_process_pixels(process_list
,
1469 tfc
->t_context
->index
,
1472 &hashed_process_data_in
) == 1)
1474 /* Process not present */
1475 processlist_add(process_list
,
1478 tfc
->t_context
->index
,
1481 &hashed_process_data_in
);
1482 processlist_get_process_pixels(process_list
,
1485 tfc
->t_context
->index
,
1488 &hashed_process_data_in
);
1490 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1495 /* Find pixels corresponding to time of the event. If the time does
1496 * not fit in the window, show a warning, not supposed to happend. */
1498 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1500 //LttTime time = ltt_event_time(e);
1502 //LttTime window_end = ltt_time_add(time_window->time_width,
1503 // time_window->start_time);
1506 //convert_time_to_pixels(
1507 // time_window->start_time,
1513 //assert(x <= width);
1515 /* draw what represents the event for outgoing process. */
1517 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1518 //draw_context_out->current->modify_over->x = x;
1519 draw_context_out
->current
->modify_over
->y
= y_out
;
1520 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1521 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1522 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1523 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1524 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1526 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1527 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1529 /*if(process_out->state->s == LTTV_STATE_RUN)
1531 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1532 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1533 PropertiesBG prop_bg;
1534 prop_bg.color = g_new(GdkColor,1);
1536 prop_bg.color->red = 0xffff;
1537 prop_bg.color->green = 0xffff;
1538 prop_bg.color->blue = 0xffff;
1540 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1541 g_free(prop_bg.color);
1542 gdk_gc_unref(draw_context_out->gc);
1545 draw_context_out
->gc
= widget
->style
->black_gc
;
1547 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1548 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1549 PropertiesText prop_text_out
;
1550 prop_text_out
.foreground
= &colorfg_out
;
1551 prop_text_out
.background
= &colorbg_out
;
1552 prop_text_out
.size
= 6;
1553 prop_text_out
.position
= OVER
;
1555 /* color of text : status of the process */
1556 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1558 prop_text_out
.foreground
->red
= 0xffff;
1559 prop_text_out
.foreground
->green
= 0xffff;
1560 prop_text_out
.foreground
->blue
= 0xffff;
1562 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1564 prop_text_out
.foreground
->red
= 0x0fff;
1565 prop_text_out
.foreground
->green
= 0xffff;
1566 prop_text_out
.foreground
->blue
= 0xfff0;
1568 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1570 prop_text_out
.foreground
->red
= 0xffff;
1571 prop_text_out
.foreground
->green
= 0xffff;
1572 prop_text_out
.foreground
->blue
= 0x0000;
1574 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1576 prop_text_out
.foreground
->red
= 0xffff;
1577 prop_text_out
.foreground
->green
= 0x0000;
1578 prop_text_out
.foreground
->blue
= 0xffff;
1580 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1582 prop_text_out
.foreground
->red
= 0xffff;
1583 prop_text_out
.foreground
->green
= 0x0000;
1584 prop_text_out
.foreground
->blue
= 0x0000;
1586 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1588 prop_text_out
.foreground
->red
= 0x0000;
1589 prop_text_out
.foreground
->green
= 0xffff;
1590 prop_text_out
.foreground
->blue
= 0x0000;
1594 prop_text_out
.foreground
->red
= 0xffff;
1595 prop_text_out
.foreground
->green
= 0xffff;
1596 prop_text_out
.foreground
->blue
= 0xffff;
1599 /* Print status of the process : U, WF, WC, E, W, R */
1600 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1601 prop_text_out
.text
= "U";
1602 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1603 prop_text_out
.text
= "WF";
1604 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1605 prop_text_out
.text
= "WC";
1606 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1607 prop_text_out
.text
= "E";
1608 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1609 prop_text_out
.text
= "W";
1610 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1611 prop_text_out
.text
= "R";
1613 prop_text_out
.text
= "U";
1615 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1617 //gdk_gc_unref(draw_context_out->gc);
1619 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1620 draw_context_out
->current
->over
->y
= y_out
;
1621 draw_context_out
->current
->under
->y
= y_out
+height
;
1622 draw_context_out
->current
->status
= process_out
->state
->s
;
1624 /* for pid_out : remove previous, Prev = current, new current (default) */
1625 g_free(draw_context_out
->previous
->modify_under
);
1626 g_free(draw_context_out
->previous
->modify_middle
);
1627 g_free(draw_context_out
->previous
->modify_over
);
1628 g_free(draw_context_out
->previous
->under
);
1629 g_free(draw_context_out
->previous
->middle
);
1630 g_free(draw_context_out
->previous
->over
);
1631 g_free(draw_context_out
->previous
);
1633 draw_context_out
->previous
= draw_context_out
->current
;
1635 draw_context_out
->current
= g_new(DrawInfo
,1);
1636 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1637 draw_context_out
->current
->over
->x
= -1;
1638 draw_context_out
->current
->over
->y
= -1;
1639 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1640 draw_context_out
->current
->middle
->x
= -1;
1641 draw_context_out
->current
->middle
->y
= -1;
1642 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1643 draw_context_out
->current
->under
->x
= -1;
1644 draw_context_out
->current
->under
->y
= -1;
1645 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1646 draw_context_out
->current
->modify_over
->x
= -1;
1647 draw_context_out
->current
->modify_over
->y
= -1;
1648 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1649 draw_context_out
->current
->modify_middle
->x
= -1;
1650 draw_context_out
->current
->modify_middle
->y
= -1;
1651 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1652 draw_context_out
->current
->modify_under
->x
= -1;
1653 draw_context_out
->current
->modify_under
->y
= -1;
1654 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1656 /* Finally, update the drawing context of the pid_in. */
1658 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1659 //draw_context_in->current->modify_over->x = x;
1660 draw_context_in
->current
->modify_over
->y
= y_in
;
1661 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1662 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1663 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1664 widget
= control_flow_data
->drawing
->drawing_area
;
1665 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1667 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1668 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1670 /*if(process_in->state->s == LTTV_STATE_RUN)
1672 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1673 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1674 PropertiesBG prop_bg;
1675 prop_bg.color = g_new(GdkColor,1);
1677 prop_bg.color->red = 0xffff;
1678 prop_bg.color->green = 0xffff;
1679 prop_bg.color->blue = 0xffff;
1681 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1682 g_free(prop_bg.color);
1683 gdk_gc_unref(draw_context_in->gc);
1686 draw_context_in
->gc
= widget
->style
->black_gc
;
1688 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1689 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1690 PropertiesText prop_text_in
;
1691 prop_text_in
.foreground
= &colorfg_in
;
1692 prop_text_in
.background
= &colorbg_in
;
1693 prop_text_in
.size
= 6;
1694 prop_text_in
.position
= OVER
;
1696 /* foreground of text : status of the process */
1697 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1699 prop_text_in
.foreground
->red
= 0xffff;
1700 prop_text_in
.foreground
->green
= 0xffff;
1701 prop_text_in
.foreground
->blue
= 0xffff;
1703 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1705 prop_text_in
.foreground
->red
= 0x0fff;
1706 prop_text_in
.foreground
->green
= 0xffff;
1707 prop_text_in
.foreground
->blue
= 0xfff0;
1709 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1711 prop_text_in
.foreground
->red
= 0xffff;
1712 prop_text_in
.foreground
->green
= 0xffff;
1713 prop_text_in
.foreground
->blue
= 0x0000;
1715 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1717 prop_text_in
.foreground
->red
= 0xffff;
1718 prop_text_in
.foreground
->green
= 0x0000;
1719 prop_text_in
.foreground
->blue
= 0xffff;
1721 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1723 prop_text_in
.foreground
->red
= 0xffff;
1724 prop_text_in
.foreground
->green
= 0x0000;
1725 prop_text_in
.foreground
->blue
= 0x0000;
1727 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1729 prop_text_in
.foreground
->red
= 0x0000;
1730 prop_text_in
.foreground
->green
= 0xffff;
1731 prop_text_in
.foreground
->blue
= 0x0000;
1735 prop_text_in
.foreground
->red
= 0xffff;
1736 prop_text_in
.foreground
->green
= 0xffff;
1737 prop_text_in
.foreground
->blue
= 0xffff;
1741 /* Print status of the process : U, WF, WC, E, W, R */
1742 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1743 prop_text_in
.text
= "U";
1744 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1745 prop_text_in
.text
= "WF";
1746 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1747 prop_text_in
.text
= "WC";
1748 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1749 prop_text_in
.text
= "E";
1750 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1751 prop_text_in
.text
= "W";
1752 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1753 prop_text_in
.text
= "R";
1755 prop_text_in
.text
= "U";
1757 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1760 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1763 prop_text_in
.foreground
= &colorfg_in
;
1764 prop_text_in
.background
= &colorbg_in
;
1765 prop_text_in
.foreground
->red
= 0xffff;
1766 prop_text_in
.foreground
->green
= 0xffff;
1767 prop_text_in
.foreground
->blue
= 0xffff;
1768 prop_text_in
.size
= 6;
1769 prop_text_in
.position
= UNDER
;
1771 prop_text_in
.text
= g_new(gchar
, 260);
1772 strcpy(prop_text_in
.text
, "CPU ");
1773 snprintf(tmp
, 255, "%u", tfc
->index
);
1774 strcat(prop_text_in
.text
, tmp
);
1776 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1777 g_free(prop_text_in
.text
);
1781 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1782 draw_context_in
->current
->over
->y
= y_in
;
1783 draw_context_in
->current
->under
->y
= y_in
+height
;
1784 draw_context_in
->current
->status
= process_in
->state
->s
;
1786 /* for pid_in : remove previous, Prev = current, new current (default) */
1787 g_free(draw_context_in
->previous
->modify_under
);
1788 g_free(draw_context_in
->previous
->modify_middle
);
1789 g_free(draw_context_in
->previous
->modify_over
);
1790 g_free(draw_context_in
->previous
->under
);
1791 g_free(draw_context_in
->previous
->middle
);
1792 g_free(draw_context_in
->previous
->over
);
1793 g_free(draw_context_in
->previous
);
1795 draw_context_in
->previous
= draw_context_in
->current
;
1797 draw_context_in
->current
= g_new(DrawInfo
,1);
1798 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1799 draw_context_in
->current
->over
->x
= -1;
1800 draw_context_in
->current
->over
->y
= -1;
1801 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1802 draw_context_in
->current
->middle
->x
= -1;
1803 draw_context_in
->current
->middle
->y
= -1;
1804 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1805 draw_context_in
->current
->under
->x
= -1;
1806 draw_context_in
->current
->under
->y
= -1;
1807 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1808 draw_context_in
->current
->modify_over
->x
= -1;
1809 draw_context_in
->current
->modify_over
->y
= -1;
1810 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1811 draw_context_in
->current
->modify_middle
->x
= -1;
1812 draw_context_in
->current
->modify_middle
->y
= -1;
1813 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1814 draw_context_in
->current
->modify_under
->x
= -1;
1815 draw_context_in
->current
->modify_under
->y
= -1;
1816 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1825 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1827 PropertiesLine prop_line
;
1828 prop_line
.line_width
= 1;
1829 prop_line
.style
= GDK_LINE_SOLID
;
1831 //GdkColormap *colormap = gdk_colormap_get_system();
1833 /* color of line : execution mode of the process */
1834 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1835 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1836 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1837 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1838 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1839 prop_line
.color
= drawing_colors
[COL_TRAP
];
1840 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1841 prop_line
.color
= drawing_colors
[COL_IRQ
];
1842 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1843 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1845 prop_line
.color
= drawing_colors
[COL_WHITE
];
1847 //gdk_colormap_alloc_color(colormap,
1858 /* before_execmode_hook
1860 * This function basically draw lines and icons. Two types of lines are drawn :
1861 * one small (3 pixels?) representing the state of the process and the second
1862 * type is thicker (10 pixels?) representing on which CPU a process is running
1863 * (and this only in running state).
1865 * Extremums of the lines :
1866 * x_min : time of the last event context for this process kept in memory.
1867 * x_max : time of the current event.
1868 * y : middle of the process in the process list. The process is found in the
1869 * list, therefore is it's position in pixels.
1871 * The choice of lines'color is defined by the context of the last event for this
1876 int before_execmode_hook(void *hook_data
, void *call_data
)
1878 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1879 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1880 Drawing_t
*drawing
= control_flow_data
->drawing
;
1882 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1884 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1885 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1890 LttTime evtime
= ltt_event_time(e
);
1891 TimeWindow time_window
=
1892 lttvwindow_get_time_window(control_flow_data
->tab
);
1894 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1895 time_window
.time_width
);
1897 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1898 || ltt_time_compare(evtime
, end_time
) == 1)
1901 guint width
= drawing
->width
;
1903 /* we are in a execmode, before the state update. We must draw the
1904 * items corresponding to the state before it changes : now is the right
1908 LttvProcessState
*process
= tfs
->process
;
1909 g_assert(process
!= NULL
);
1911 guint pid
= process
->pid
;
1913 /* Well, the process_out existed : we must get it in the process hash
1914 * or add it, and draw its items.
1916 /* Add process to process list (if not present) */
1917 guint y
= 0, height
= 0, pl_height
= 0;
1918 HashedProcessData
*hashed_process_data
= NULL
;
1919 ProcessList
*process_list
=
1920 guicontrolflow_get_process_list(control_flow_data
);
1921 LttTime birth
= process
->creation_time
;
1922 const gchar
*name
= g_quark_to_string(process
->name
);
1924 if(processlist_get_process_pixels(process_list
,
1928 tfc
->t_context
->index
,
1931 &hashed_process_data
) == 1)
1933 g_assert(pid
== 0 || pid
!= process
->ppid
);
1934 /* Process not present */
1935 processlist_add(process_list
,
1940 tfc
->t_context
->index
,
1943 &hashed_process_data
);
1944 processlist_get_process_pixels(process_list
,
1948 tfc
->t_context
->index
,
1951 &hashed_process_data
);
1952 drawing_insert_square( drawing
, y
, height
);
1955 /* Now, the process is in the state hash and our own process hash.
1956 * We definitely can draw the items related to the ending state.
1959 /* Check if the x position is unset. In can have been left unset by
1960 * a draw closure from a after chunk hook. This should never happen,
1961 * because it must be set by before chunk hook to the damage_begin
1964 g_assert(hashed_process_data
->x
.over
!= -1);
1968 convert_time_to_pixels(
1969 time_window
.start_time
,
1976 /* Jump over draw if we are at the same x position */
1977 if(x
== hashed_process_data
->x
.middle
)
1982 DrawContext draw_context
;
1983 /* Now create the drawing context that will be used to draw
1984 * items related to the last state. */
1985 draw_context
.drawable
= drawing
->pixmap
;
1986 draw_context
.gc
= drawing
->gc
;
1987 draw_context
.pango_layout
= drawing
->pango_layout
;
1988 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
1989 draw_context
.drawinfo
.end
.x
= x
;
1991 draw_context
.drawinfo
.y
.over
= y
+1;
1992 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
1993 draw_context
.drawinfo
.y
.under
= y
+height
;
1995 draw_context
.drawinfo
.start
.offset
.over
= 0;
1996 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1997 draw_context
.drawinfo
.start
.offset
.under
= 0;
1998 draw_context
.drawinfo
.end
.offset
.over
= 0;
1999 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2000 draw_context
.drawinfo
.end
.offset
.under
= 0;
2004 PropertiesLine prop_line
= prepare_s_e_line(process
);
2005 draw_line((void*)&prop_line
, (void*)&draw_context
);
2008 /* become the last x position */
2009 hashed_process_data
->x
.middle
= x
;
2016 /* after_execmode_hook
2018 * The draw after hook is called by the reading API to have a
2019 * particular event drawn on the screen.
2020 * @param hook_data ControlFlowData structure of the viewer.
2021 * @param call_data Event context.
2023 * This function adds items to be drawn in a queue for each process.
2026 int after_execmode_hook(void *hook_data
, void *call_data
)
2028 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2029 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2031 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2033 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2034 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2039 LttTime evtime
= ltt_event_time(e
);
2040 TimeWindow time_window
=
2041 lttvwindow_get_time_window(control_flow_data
->tab
);
2043 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2044 time_window
.time_width
);
2046 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2047 || ltt_time_compare(evtime
, end_time
) == 1)
2050 guint width
= control_flow_data
->drawing
->width
;
2052 /* Add process to process list (if not present) */
2053 LttvProcessState
*process
;
2055 guint y
= 0, height
= 0, pl_height
= 0;
2056 HashedProcessData
*hashed_process_data
= NULL
;
2058 ProcessList
*process_list
=
2059 guicontrolflow_get_process_list(control_flow_data
);
2062 /* Find process pid_in in the list... */
2063 process
= tfs
->process
;
2064 /* It should exist, because we are after the state update. */
2065 g_assert(process
!= NULL
);
2067 guint pid
= process
->pid
;
2069 birth
= process
->creation_time
;
2070 const gchar
*name
= g_quark_to_string(process
->name
);
2072 if(processlist_get_process_pixels(process_list
,
2076 tfc
->t_context
->index
,
2079 &hashed_process_data
) == 1)
2081 g_assert(pid
== 0 || pid
!= process
->ppid
);
2082 /* Process not present */
2083 processlist_add(process_list
,
2088 tfc
->t_context
->index
,
2091 &hashed_process_data
);
2092 processlist_get_process_pixels(process_list
,
2096 tfc
->t_context
->index
,
2099 &hashed_process_data
);
2100 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2103 convert_time_to_pixels(
2104 time_window
.start_time
,
2108 &hashed_process_data
->x
.over
);
2114 /* before_process_hook
2116 * Draw lines for process event.
2118 * @param hook_data ControlFlowData structure of the viewer.
2119 * @param call_data Event context.
2121 * This function adds items to be drawn in a queue for each process.
2124 int before_process_hook(void *hook_data
, void *call_data
)
2126 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2127 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2128 Drawing_t
*drawing
= control_flow_data
->drawing
;
2130 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2132 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2133 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2138 LttTime evtime
= ltt_event_time(e
);
2139 TimeWindow time_window
=
2140 lttvwindow_get_time_window(control_flow_data
->tab
);
2142 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2143 time_window
.time_width
);
2145 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2146 || ltt_time_compare(evtime
, end_time
) == 1)
2149 guint width
= control_flow_data
->drawing
->width
;
2153 LttField
*f
= ltt_event_field(e
);
2155 element
= ltt_field_member(f
,0);
2156 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2159 if(sub_id
== 3) { /* exit */
2161 /* Add process to process list (if not present) */
2162 LttvProcessState
*process
= tfs
->process
;
2163 guint pid
= process
->pid
;
2165 guint y
= 0, height
= 0, pl_height
= 0;
2166 HashedProcessData
*hashed_process_data
= NULL
;
2168 ProcessList
*process_list
=
2169 guicontrolflow_get_process_list(control_flow_data
);
2171 g_assert(process
!= NULL
);
2173 birth
= process
->creation_time
;
2174 const gchar
*name
= g_quark_to_string(process
->name
);
2176 if(processlist_get_process_pixels(process_list
,
2180 tfc
->t_context
->index
,
2183 &hashed_process_data
) == 1)
2185 g_assert(pid
== 0 || pid
!= process
->ppid
);
2186 /* Process not present */
2187 processlist_add(process_list
,
2192 tfc
->t_context
->index
,
2195 &hashed_process_data
);
2196 processlist_get_process_pixels(process_list
,
2200 tfc
->t_context
->index
,
2203 &hashed_process_data
);
2204 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2207 /* Now, the process is in the state hash and our own process hash.
2208 * We definitely can draw the items related to the ending state.
2211 /* Check if the x position is unset. In can have been left unset by
2212 * a draw closure from a after chunk hook. This should never happen,
2213 * because it must be set by before chunk hook to the damage_begin
2216 g_assert(hashed_process_data
->x
.over
!= -1);
2220 convert_time_to_pixels(
2221 time_window
.start_time
,
2228 /* Jump over draw if we are at the same x position */
2229 if(x
== hashed_process_data
->x
.middle
)
2233 DrawContext draw_context
;
2235 /* Now create the drawing context that will be used to draw
2236 * items related to the last state. */
2237 draw_context
.drawable
= drawing
->pixmap
;
2238 draw_context
.gc
= drawing
->gc
;
2239 draw_context
.pango_layout
= drawing
->pango_layout
;
2240 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2241 draw_context
.drawinfo
.end
.x
= x
;
2243 draw_context
.drawinfo
.y
.over
= y
+1;
2244 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2245 draw_context
.drawinfo
.y
.under
= y
+height
;
2247 draw_context
.drawinfo
.start
.offset
.over
= 0;
2248 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2249 draw_context
.drawinfo
.start
.offset
.under
= 0;
2250 draw_context
.drawinfo
.end
.offset
.over
= 0;
2251 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2252 draw_context
.drawinfo
.end
.offset
.under
= 0;
2256 PropertiesLine prop_line
= prepare_s_e_line(process
);
2257 draw_line((void*)&prop_line
, (void*)&draw_context
);
2260 /* become the last x position */
2261 hashed_process_data
->x
.middle
= x
;
2275 /* after_process_hook
2277 * Create the processlist entry for the child process. Put the last
2278 * position in x at the current time value.
2280 * @param hook_data ControlFlowData structure of the viewer.
2281 * @param call_data Event context.
2283 * This function adds items to be drawn in a queue for each process.
2286 int after_process_hook(void *hook_data
, void *call_data
)
2288 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2289 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2291 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2293 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2294 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2299 LttTime evtime
= ltt_event_time(e
);
2300 TimeWindow time_window
=
2301 lttvwindow_get_time_window(control_flow_data
->tab
);
2303 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2304 time_window
.time_width
);
2306 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2307 || ltt_time_compare(evtime
, end_time
) == 1)
2310 guint width
= control_flow_data
->drawing
->width
;
2315 LttField
*f
= ltt_event_field(e
);
2317 element
= ltt_field_member(f
,0);
2318 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2319 element
= ltt_field_member(f
,1);
2320 param1
= ltt_event_get_long_unsigned(e
,element
);
2323 if(sub_id
== 2) { /* fork */
2325 guint child_pid
= param1
;
2326 /* Add process to process list (if not present) */
2327 LttvProcessState
*process_child
;
2329 guint y_child
= 0, height
= 0, pl_height
= 0;
2330 HashedProcessData
*hashed_process_data_child
= NULL
;
2332 ProcessList
*process_list
=
2333 guicontrolflow_get_process_list(control_flow_data
);
2336 /* Find child in the list... */
2337 process_child
= lttv_state_find_process(tfs
, child_pid
);
2338 /* It should exist, because we are after the state update. */
2339 g_assert(process_child
!= NULL
);
2341 birth
= process_child
->creation_time
;
2342 const gchar
*name
= g_quark_to_string(process_child
->name
);
2344 if(processlist_get_process_pixels(process_list
,
2346 process_child
->last_cpu
,
2348 tfc
->t_context
->index
,
2351 &hashed_process_data_child
) == 1)
2353 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2354 /* Process not present */
2355 processlist_add(process_list
,
2357 process_child
->last_cpu
,
2358 process_child
->ppid
,
2360 tfc
->t_context
->index
,
2363 &hashed_process_data_child
);
2364 processlist_get_process_pixels(process_list
,
2366 process_child
->last_cpu
,
2368 tfc
->t_context
->index
,
2371 &hashed_process_data_child
);
2372 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2376 convert_time_to_pixels(
2377 time_window
.start_time
,
2382 hashed_process_data_child
->x
.over
= new_x
;
2383 hashed_process_data_child
->x
.middle
= new_x
;
2384 hashed_process_data_child
->x
.under
= new_x
;
2386 } else if(sub_id
== 3) { /* exit */
2388 /* Add process to process list (if not present) */
2389 LttvProcessState
*process
= tfs
->process
;
2390 guint pid
= process
->pid
;
2392 guint y
= 0, height
= 0, pl_height
= 0;
2393 HashedProcessData
*hashed_process_data
= NULL
;
2395 ProcessList
*process_list
=
2396 guicontrolflow_get_process_list(control_flow_data
);
2399 /* It should exist, because we are after the state update. */
2400 g_assert(process
!= NULL
);
2402 birth
= process
->creation_time
;
2403 const gchar
*name
= g_quark_to_string(process
->name
);
2405 if(processlist_get_process_pixels(process_list
,
2409 tfc
->t_context
->index
,
2412 &hashed_process_data
) == 1)
2414 g_assert(pid
== 0 || pid
!= process
->ppid
);
2415 /* Process not present */
2416 processlist_add(process_list
,
2421 tfc
->t_context
->index
,
2424 &hashed_process_data
);
2425 processlist_get_process_pixels(process_list
,
2429 tfc
->t_context
->index
,
2432 &hashed_process_data
);
2433 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2437 convert_time_to_pixels(
2438 time_window
.start_time
,
2443 hashed_process_data
->x
.middle
= new_x
;
2450 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2452 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2453 Drawing_t
*drawing
= control_flow_data
->drawing
;
2455 const TimeWindowNotifyData
*time_window_nofify_data
=
2456 ((const TimeWindowNotifyData
*)call_data
);
2458 TimeWindow
*old_time_window
=
2459 time_window_nofify_data
->old_time_window
;
2460 TimeWindow
*new_time_window
=
2461 time_window_nofify_data
->new_time_window
;
2463 /* Update the ruler */
2464 drawing_update_ruler(control_flow_data
->drawing
,
2468 /* Two cases : zoom in/out or scrolling */
2470 /* In order to make sure we can reuse the old drawing, the scale must
2471 * be the same and the new time interval being partly located in the
2472 * currently shown time interval. (reuse is only for scrolling)
2475 g_info("Old time window HOOK : %u, %u to %u, %u",
2476 old_time_window
->start_time
.tv_sec
,
2477 old_time_window
->start_time
.tv_nsec
,
2478 old_time_window
->time_width
.tv_sec
,
2479 old_time_window
->time_width
.tv_nsec
);
2481 g_info("New time window HOOK : %u, %u to %u, %u",
2482 new_time_window
->start_time
.tv_sec
,
2483 new_time_window
->start_time
.tv_nsec
,
2484 new_time_window
->time_width
.tv_sec
,
2485 new_time_window
->time_width
.tv_nsec
);
2487 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2488 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2490 /* Same scale (scrolling) */
2491 g_info("scrolling");
2492 LttTime
*ns
= &new_time_window
->start_time
;
2493 LttTime
*os
= &old_time_window
->start_time
;
2494 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
2495 old_time_window
->time_width
);
2496 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
2497 new_time_window
->time_width
);
2499 //if(ns<os+w && os+w<ns+w)
2500 //if(ns<old_end && os<ns)
2501 if(ltt_time_compare(*ns
, old_end
) == -1
2502 && ltt_time_compare(*os
, *ns
) == -1)
2504 g_info("scrolling near right");
2505 /* Scroll right, keep right part of the screen */
2507 guint width
= control_flow_data
->drawing
->width
;
2508 convert_time_to_pixels(
2515 /* Copy old data to new location */
2516 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2517 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2518 control_flow_data
->drawing
->pixmap
,
2521 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2523 if(drawing
->damage_begin
== drawing
->damage_end
)
2524 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2526 drawing
->damage_begin
= 0;
2528 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2530 /* Clear the data request background, but not SAFETY */
2531 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2532 //control_flow_data->drawing->drawing_area->style->black_gc,
2533 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2535 drawing
->damage_begin
+SAFETY
, 0,
2536 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2537 control_flow_data
->drawing
->height
);
2539 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2541 control_flow_data
->drawing
->width
,
2542 control_flow_data
->drawing
->height
);
2544 /* Get new data for the rest. */
2545 drawing_data_request(control_flow_data
->drawing
,
2546 &control_flow_data
->drawing
->pixmap
,
2547 drawing
->damage_begin
, 0,
2548 drawing
->damage_end
- drawing
->damage_begin
,
2549 control_flow_data
->drawing
->height
);
2552 //if(ns<os && os<ns+w)
2553 //if(ns<os && os<new_end)
2554 if(ltt_time_compare(*ns
,*os
) == -1
2555 && ltt_time_compare(*os
,new_end
) == -1)
2557 g_info("scrolling near left");
2558 /* Scroll left, keep left part of the screen */
2560 guint width
= control_flow_data
->drawing
->width
;
2561 convert_time_to_pixels(
2569 /* Copy old data to new location */
2570 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2571 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2572 control_flow_data
->drawing
->pixmap
,
2577 if(drawing
->damage_begin
== drawing
->damage_end
)
2578 drawing
->damage_end
= x
;
2580 drawing
->damage_end
=
2581 control_flow_data
->drawing
->width
;
2583 drawing
->damage_begin
= 0;
2585 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2586 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2588 drawing
->damage_begin
, 0,
2589 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2590 control_flow_data
->drawing
->height
);
2592 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2594 control_flow_data
->drawing
->width
,
2595 control_flow_data
->drawing
->height
);
2598 /* Get new data for the rest. */
2599 drawing_data_request(control_flow_data
->drawing
,
2600 &control_flow_data
->drawing
->pixmap
,
2601 drawing
->damage_begin
, 0,
2602 drawing
->damage_end
- drawing
->damage_begin
,
2603 control_flow_data
->drawing
->height
);
2606 if(ltt_time_compare(*ns
,*os
) == 0)
2608 g_info("not scrolling");
2610 g_info("scrolling far");
2611 /* Cannot reuse any part of the screen : far jump */
2614 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2615 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2618 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2619 control_flow_data
->drawing
->height
);
2621 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2623 control_flow_data
->drawing
->width
,
2624 control_flow_data
->drawing
->height
);
2626 drawing
->damage_begin
= 0;
2627 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2629 drawing_data_request(control_flow_data
->drawing
,
2630 &control_flow_data
->drawing
->pixmap
,
2632 control_flow_data
->drawing
->width
,
2633 control_flow_data
->drawing
->height
);
2639 /* Different scale (zoom) */
2642 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2643 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2646 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2647 control_flow_data
->drawing
->height
);
2649 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2651 control_flow_data
->drawing
->width
,
2652 control_flow_data
->drawing
->height
);
2654 drawing
->damage_begin
= 0;
2655 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2657 drawing_data_request(control_flow_data
->drawing
,
2658 &control_flow_data
->drawing
->pixmap
,
2660 control_flow_data
->drawing
->width
,
2661 control_flow_data
->drawing
->height
);
2669 gint
traceset_notify(void *hook_data
, void *call_data
)
2671 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2672 Drawing_t
*drawing
= control_flow_data
->drawing
;
2673 GtkWidget
*widget
= drawing
->drawing_area
;
2676 drawing_clear(control_flow_data
->drawing
);
2677 processlist_clear(control_flow_data
->process_list
);
2678 redraw_notify(control_flow_data
, NULL
);
2680 request_background_data(control_flow_data
);
2682 drawing
->damage_begin
= 0;
2683 drawing
->damage_end
= drawing
->width
;
2684 if(drawing
->damage_begin
< drawing
->damage_end
)
2686 drawing_data_request(drawing
,
2688 drawing
->damage_begin
,
2690 drawing
->damage_end
-drawing
->damage_begin
,
2694 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2703 gint
redraw_notify(void *hook_data
, void *call_data
)
2705 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2706 Drawing_t
*drawing
= control_flow_data
->drawing
;
2707 GtkWidget
*widget
= drawing
->drawing_area
;
2709 drawing
->damage_begin
= 0;
2710 drawing
->damage_end
= drawing
->width
;
2712 /* fun feature, to be separated someday... */
2713 drawing_clear(control_flow_data
->drawing
);
2714 processlist_clear(control_flow_data
->process_list
);
2717 gdk_draw_rectangle (drawing
->pixmap
,
2718 widget
->style
->black_gc
,
2721 drawing
->width
+SAFETY
,
2725 if(drawing
->damage_begin
< drawing
->damage_end
)
2727 drawing_data_request(drawing
,
2729 drawing
->damage_begin
,
2731 drawing
->damage_end
-drawing
->damage_begin
,
2735 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2744 gint
continue_notify(void *hook_data
, void *call_data
)
2746 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2747 Drawing_t
*drawing
= control_flow_data
->drawing
;
2748 GtkWidget
*widget
= drawing
->drawing_area
;
2750 //g_assert(widget->allocation.width == drawing->damage_end);
2752 if(drawing
->damage_begin
< drawing
->damage_end
)
2754 drawing_data_request(drawing
,
2756 drawing
->damage_begin
,
2758 drawing
->damage_end
-drawing
->damage_begin
,
2766 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2768 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2769 Drawing_t
*drawing
= control_flow_data
->drawing
;
2771 LttTime current_time
= *((LttTime
*)call_data
);
2773 TimeWindow time_window
=
2774 lttvwindow_get_time_window(control_flow_data
->tab
);
2776 LttTime time_begin
= time_window
.start_time
;
2777 LttTime width
= time_window
.time_width
;
2780 guint64 time_ll
= ltt_time_to_uint64(width
);
2781 time_ll
= time_ll
>> 1; /* divide by two */
2782 half_width
= ltt_time_from_uint64(time_ll
);
2784 LttTime time_end
= ltt_time_add(time_begin
, width
);
2786 LttvTracesetContext
* tsc
=
2787 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2789 LttTime trace_start
= tsc
->time_span
.start_time
;
2790 LttTime trace_end
= tsc
->time_span
.end_time
;
2792 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2793 current_time
.tv_nsec
);
2797 /* If current time is inside time interval, just move the highlight
2800 /* Else, we have to change the time interval. We have to tell it
2801 * to the main window. */
2802 /* The time interval change will take care of placing the current
2803 * time at the center of the visible area, or nearest possible if we are
2804 * at one end of the trace. */
2807 if(ltt_time_compare(current_time
, time_begin
) == -1)
2809 TimeWindow new_time_window
;
2811 if(ltt_time_compare(current_time
,
2812 ltt_time_add(trace_start
,half_width
)) == -1)
2813 time_begin
= trace_start
;
2815 time_begin
= ltt_time_sub(current_time
,half_width
);
2817 new_time_window
.start_time
= time_begin
;
2818 new_time_window
.time_width
= width
;
2820 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2822 else if(ltt_time_compare(current_time
, time_end
) == 1)
2824 TimeWindow new_time_window
;
2826 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2827 time_begin
= ltt_time_sub(trace_end
,width
);
2829 time_begin
= ltt_time_sub(current_time
,half_width
);
2831 new_time_window
.start_time
= time_begin
;
2832 new_time_window
.time_width
= width
;
2834 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2837 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2838 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2846 typedef struct _ClosureData
{
2847 EventsRequest
*events_request
;
2848 LttvTracesetState
*tss
;
2853 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2855 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2856 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2857 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2859 EventsRequest
*events_request
= closure_data
->events_request
;
2860 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2861 Drawing_t
*drawing
= control_flow_data
->drawing
;
2863 LttvTracesetState
*tss
= closure_data
->tss
;
2864 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2866 LttTime evtime
= closure_data
->end_time
;
2867 TimeWindow time_window
=
2868 lttvwindow_get_time_window(control_flow_data
->tab
);
2870 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2871 time_window
.time_width
);
2873 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2874 || ltt_time_compare(evtime
, end_time
) == 1)
2877 guint width
= drawing
->width
;
2880 /* For the process */
2881 /* First, check if the current process is in the state computation
2882 * process list. If it is there, that means we must add it right now and
2883 * draw items from the beginning of the read for it. If it is not
2884 * present, it's a new process and it was not present : it will
2885 * be added after the state update. */
2886 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2888 /* tracefiles[0] is ok here, because we draw for every PID, and
2889 * assume CPU 0 for PID 0 //FIXME */
2890 LttvTracefileState
*tfs
=
2891 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2893 LttvProcessState
*process
;
2894 process
= lttv_state_find_process(tfs
,
2897 if(process
!= NULL
) {
2899 /* Only draw for processes that are currently in the trace states */
2901 guint y
= 0, height
= 0, pl_height
= 0;
2902 ProcessList
*process_list
=
2903 guicontrolflow_get_process_list(control_flow_data
);
2904 LttTime birth
= process_info
->birth
;
2906 /* Should be alike when background info is ready */
2907 if(control_flow_data
->background_info_waiting
==0)
2908 g_assert(ltt_time_compare(process
->creation_time
,
2909 process_info
->birth
) == 0);
2910 const gchar
*name
= g_quark_to_string(process
->name
);
2912 /* process HAS to be present */
2913 g_assert(processlist_get_process_pixels(process_list
,
2917 process_info
->trace_num
,
2920 &hashed_process_data
) != 1);
2922 /* Now, the process is in the state hash and our own process hash.
2923 * We definitely can draw the items related to the ending state.
2926 /* Check if the x position is unset. In can have been left unset by
2927 * a draw closure from a after chunk hook. This should never happen,
2928 * because it must be set by before chunk hook to the damage_begin
2931 g_assert(hashed_process_data
->x
.over
!= -1);
2935 convert_time_to_pixels(
2936 time_window
.start_time
,
2942 DrawContext draw_context
;
2944 /* Now create the drawing context that will be used to draw
2945 * items related to the last state. */
2946 draw_context
.drawable
= drawing
->pixmap
;
2947 draw_context
.gc
= drawing
->gc
;
2948 draw_context
.pango_layout
= drawing
->pango_layout
;
2949 draw_context
.drawinfo
.end
.x
= x
;
2951 draw_context
.drawinfo
.y
.over
= y
+1;
2952 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2953 draw_context
.drawinfo
.y
.under
= y
+height
;
2955 draw_context
.drawinfo
.start
.offset
.over
= 0;
2956 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2957 draw_context
.drawinfo
.start
.offset
.under
= 0;
2958 draw_context
.drawinfo
.end
.offset
.over
= 0;
2959 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2960 draw_context
.drawinfo
.end
.offset
.under
= 0;
2962 /* Jump over draw if we are at the same x position */
2963 if(x
== hashed_process_data
->x
.over
)
2967 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
2969 PropertiesLine prop_line
= prepare_execmode_line(process
);
2970 draw_line((void*)&prop_line
, (void*)&draw_context
);
2972 hashed_process_data
->x
.over
= x
;
2976 if(x
== hashed_process_data
->x
.middle
) {
2979 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2981 PropertiesLine prop_line
= prepare_s_e_line(process
);
2982 draw_line((void*)&prop_line
, (void*)&draw_context
);
2984 /* become the last x position */
2985 hashed_process_data
->x
.middle
= x
;
2993 int before_chunk(void *hook_data
, void *call_data
)
2995 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2996 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2998 drawing_chunk_begin(events_request
, tss
);
3003 int before_request(void *hook_data
, void *call_data
)
3005 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3006 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3008 drawing_data_request_begin(events_request
, tss
);
3015 * after request is necessary in addition of after chunk in order to draw
3016 * lines until the end of the screen. after chunk just draws lines until
3023 int after_request(void *hook_data
, void *call_data
)
3025 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3026 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3027 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3028 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3030 ProcessList
*process_list
=
3031 guicontrolflow_get_process_list(control_flow_data
);
3032 LttTime end_time
= events_request
->end_time
;
3034 ClosureData closure_data
;
3035 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3036 closure_data
.tss
= tss
;
3037 closure_data
.end_time
= end_time
;
3039 /* Draw last items */
3040 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3041 (void*)&closure_data
);
3043 /* Request expose */
3044 drawing_request_expose(events_request
, tss
, end_time
);
3053 int after_chunk(void *hook_data
, void *call_data
)
3055 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3056 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3057 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3058 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3059 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3062 ProcessList
*process_list
=
3063 guicontrolflow_get_process_list(control_flow_data
);
3066 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3067 else /* end of traceset, or position now out of request : end */
3068 end_time
= events_request
->end_time
;
3070 ClosureData closure_data
;
3071 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3072 closure_data
.tss
= tss
;
3073 closure_data
.end_time
= end_time
;
3075 /* Draw last items */
3076 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3077 (void*)&closure_data
);
3079 /* Request expose */
3080 drawing_request_expose(events_request
, tss
, end_time
);