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
);
275 static __inline PropertiesLine
prepare_status_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 /* color of line : status of the process */
287 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
288 prop_line
.color
= drawing_colors
[COL_WHITE
];
289 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
290 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
291 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
292 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
293 else if(process
->state
->s
== LTTV_STATE_EXIT
)
294 prop_line
.color
= drawing_colors
[COL_EXIT
];
295 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
296 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
297 else if(process
->state
->s
== LTTV_STATE_WAIT
)
298 prop_line
.color
= drawing_colors
[COL_WAIT
];
299 else if(process
->state
->s
== LTTV_STATE_RUN
)
300 prop_line
.color
= drawing_colors
[COL_RUN
];
302 prop_line
.color
= drawing_colors
[COL_WHITE
];
304 //gdk_colormap_alloc_color(colormap,
315 /* before_schedchange_hook
317 * This function basically draw lines and icons. Two types of lines are drawn :
318 * one small (3 pixels?) representing the state of the process and the second
319 * type is thicker (10 pixels?) representing on which CPU a process is running
320 * (and this only in running state).
322 * Extremums of the lines :
323 * x_min : time of the last event context for this process kept in memory.
324 * x_max : time of the current event.
325 * y : middle of the process in the process list. The process is found in the
326 * list, therefore is it's position in pixels.
328 * The choice of lines'color is defined by the context of the last event for this
333 int before_schedchange_hook(void *hook_data
, void *call_data
)
335 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
336 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
337 Drawing_t
*drawing
= control_flow_data
->drawing
;
339 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
341 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
342 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
347 LttTime evtime
= ltt_event_time(e
);
348 TimeWindow time_window
=
349 lttvwindow_get_time_window(control_flow_data
->tab
);
351 LttTime end_time
= ltt_time_add(time_window
.start_time
,
352 time_window
.time_width
);
354 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
355 || ltt_time_compare(evtime
, end_time
) == 1)
358 guint width
= drawing
->width
;
360 /* we are in a schedchange, before the state update. We must draw the
361 * items corresponding to the state before it changes : now is the right
368 LttField
*f
= ltt_event_field(e
);
370 element
= ltt_field_member(f
,0);
371 pid_out
= ltt_event_get_long_unsigned(e
,element
);
372 element
= ltt_field_member(f
,1);
373 pid_in
= ltt_event_get_long_unsigned(e
,element
);
374 g_debug("out : %u in : %u", pid_out
, pid_in
);
378 /* For the pid_out */
379 /* First, check if the current process is in the state computation
380 * process list. If it is there, that means we must add it right now and
381 * draw items from the beginning of the read for it. If it is not
382 * present, it's a new process and it was not present : it will
383 * be added after the state update. */
384 LttvProcessState
*process
;
385 process
= lttv_state_find_process(tfs
, pid_out
);
387 if(process
!= NULL
) {
388 /* Well, the process_out existed : we must get it in the process hash
389 * or add it, and draw its items.
391 /* Add process to process list (if not present) */
392 guint y
= 0, height
= 0, pl_height
= 0;
393 HashedProcessData
*hashed_process_data
= NULL
;
394 ProcessList
*process_list
=
395 guicontrolflow_get_process_list(control_flow_data
);
396 LttTime birth
= process
->creation_time
;
397 const gchar
*name
= g_quark_to_string(process
->name
);
399 if(processlist_get_process_pixels(process_list
,
403 tfc
->t_context
->index
,
406 &hashed_process_data
) == 1)
408 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
409 /* Process not present */
410 processlist_add(process_list
,
415 tfc
->t_context
->index
,
418 &hashed_process_data
);
419 processlist_get_process_pixels(process_list
,
423 tfc
->t_context
->index
,
426 &hashed_process_data
);
427 drawing_insert_square( drawing
, y
, height
);
430 /* Now, the process is in the state hash and our own process hash.
431 * We definitely can draw the items related to the ending state.
434 /* Check if the x position is unset. In can have been left unset by
435 * a draw closure from a after chunk hook. This should never happen,
436 * because it must be set by before chunk hook to the damage_begin
439 g_assert(hashed_process_data
->x
.middle
!= -1);
442 DrawContext draw_context
;
444 convert_time_to_pixels(
445 time_window
.start_time
,
451 /* Now create the drawing context that will be used to draw
452 * items related to the last state. */
453 draw_context
.drawable
= drawing
->pixmap
;
454 draw_context
.gc
= drawing
->gc
;
455 draw_context
.pango_layout
= drawing
->pango_layout
;
456 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
457 draw_context
.drawinfo
.end
.x
= x
;
459 draw_context
.drawinfo
.y
.over
= y
+1;
460 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
461 draw_context
.drawinfo
.y
.under
= y
+height
;
463 draw_context
.drawinfo
.start
.offset
.over
= 0;
464 draw_context
.drawinfo
.start
.offset
.middle
= 0;
465 draw_context
.drawinfo
.start
.offset
.under
= 0;
466 draw_context
.drawinfo
.end
.offset
.over
= 0;
467 draw_context
.drawinfo
.end
.offset
.middle
= 0;
468 draw_context
.drawinfo
.end
.offset
.under
= 0;
472 PropertiesLine prop_line
= prepare_status_line(process
);
473 draw_line((void*)&prop_line
, (void*)&draw_context
);
476 /* become the last x position */
477 hashed_process_data
->x
.middle
= x
;
484 /* First, check if the current process is in the state computation
485 * process list. If it is there, that means we must add it right now and
486 * draw items from the beginning of the read for it. If it is not
487 * present, it's a new process and it was not present : it will
488 * be added after the state update. */
489 LttvProcessState
*process
;
490 process
= lttv_state_find_process(tfs
, pid_in
);
492 if(process
!= NULL
) {
493 /* Well, the process_out existed : we must get it in the process hash
494 * or add it, and draw its items.
496 /* Add process to process list (if not present) */
497 guint y
= 0, height
= 0, pl_height
= 0;
498 HashedProcessData
*hashed_process_data
= NULL
;
499 ProcessList
*process_list
=
500 guicontrolflow_get_process_list(control_flow_data
);
501 LttTime birth
= process
->creation_time
;
502 const gchar
*name
= g_quark_to_string(process
->name
);
504 if(processlist_get_process_pixels(process_list
,
508 tfc
->t_context
->index
,
511 &hashed_process_data
) == 1)
513 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
514 /* Process not present */
515 processlist_add(process_list
,
520 tfc
->t_context
->index
,
523 &hashed_process_data
);
524 processlist_get_process_pixels(process_list
,
528 tfc
->t_context
->index
,
531 &hashed_process_data
);
532 drawing_insert_square( drawing
, y
, height
);
535 /* Now, the process is in the state hash and our own process hash.
536 * We definitely can draw the items related to the ending state.
539 /* Check if the x position is unset. In can have been left unset by
540 * a draw closure from a after chunk hook. This should never happen,
541 * because it must be set by before chunk hook to the damage_begin
544 g_assert(hashed_process_data
->x
.middle
!= -1);
547 DrawContext draw_context
;
549 convert_time_to_pixels(
550 time_window
.start_time
,
556 /* Now create the drawing context that will be used to draw
557 * items related to the last state. */
558 draw_context
.drawable
= drawing
->pixmap
;
559 draw_context
.gc
= drawing
->gc
;
560 draw_context
.pango_layout
= drawing
->pango_layout
;
561 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
562 draw_context
.drawinfo
.end
.x
= x
;
564 draw_context
.drawinfo
.y
.over
= y
+1;
565 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
566 draw_context
.drawinfo
.y
.under
= y
+height
;
568 draw_context
.drawinfo
.start
.offset
.over
= 0;
569 draw_context
.drawinfo
.start
.offset
.middle
= 0;
570 draw_context
.drawinfo
.start
.offset
.under
= 0;
571 draw_context
.drawinfo
.end
.offset
.over
= 0;
572 draw_context
.drawinfo
.end
.offset
.middle
= 0;
573 draw_context
.drawinfo
.end
.offset
.under
= 0;
577 PropertiesLine prop_line
= prepare_status_line(process
);
578 draw_line((void*)&prop_line
, (void*)&draw_context
);
582 /* become the last x position */
583 hashed_process_data
->x
.middle
= x
;
591 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
592 ControlFlowData
*control_flow_data
=
593 (ControlFlowData
*)events_request
->viewer_data
;
594 Tab
*tab
= control_flow_data
->tab
;
596 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
598 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
599 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
604 LttTime evtime
= ltt_event_time(e
);
605 TimeWindow time_window
=
606 lttvwindow_get_time_window(tab
);
608 LttTime end_time
= ltt_time_add(time_window
.start_time
,
609 time_window
.time_width
);
610 //if(time < time_beg || time > time_end) return;
611 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
612 || ltt_time_compare(evtime
, end_time
) == 1)
615 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
617 g_debug("schedchange!");
619 /* Add process to process list (if not present) and get drawing "y" from
620 * process position */
621 guint pid_out
, pid_in
;
622 LttvProcessState
*process_out
, *process_in
;
624 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
626 ProcessList
*process_list
=
627 guicontrolflow_get_process_list(control_flow_data
);
630 LttField
*f
= ltt_event_field(e
);
632 element
= ltt_field_member(f
,0);
633 pid_out
= ltt_event_get_long_unsigned(e
,element
);
634 element
= ltt_field_member(f
,1);
635 pid_in
= ltt_event_get_long_unsigned(e
,element
);
636 g_debug("out : %u in : %u", pid_out
, pid_in
);
639 /* Find process pid_out in the list... */
640 process_out
= lttv_state_find_process(tfs
, pid_out
);
641 if(process_out
== NULL
) return 0;
642 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
644 birth
= process_out
->creation_time
;
645 const gchar
*name
= g_quark_to_string(process_out
->name
);
646 HashedProcessData
*hashed_process_data_out
= NULL
;
648 if(processlist_get_process_pixels(process_list
,
651 tfc
->t_context
->index
,
654 &hashed_process_data_out
) == 1)
656 /* Process not present */
657 processlist_add(process_list
,
660 tfc
->t_context
->index
,
663 &hashed_process_data_out
);
664 g_assert(processlist_get_process_pixels(process_list
,
667 tfc
->t_context
->index
,
670 &hashed_process_data_out
)==0);
671 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
675 /* Find process pid_in in the list... */
676 process_in
= lttv_state_find_process(tfs
, pid_in
);
677 if(process_in
== NULL
) return 0;
678 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
680 birth
= process_in
->creation_time
;
681 name
= g_quark_to_string(process_in
->name
);
682 HashedProcessData
*hashed_process_data_in
= NULL
;
684 if(processlist_get_process_pixels(process_list
,
687 tfc
->t_context
->index
,
690 &hashed_process_data_in
) == 1)
692 /* Process not present */
693 processlist_add(process_list
,
696 tfc
->t_context
->index
,
699 &hashed_process_data_in
);
700 processlist_get_process_pixels(process_list
,
703 tfc
->t_context
->index
,
706 &hashed_process_data_in
);
708 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
713 /* Find pixels corresponding to time of the event. If the time does
714 * not fit in the window, show a warning, not supposed to happend. */
716 guint width
= control_flow_data
->drawing
->width
;
718 LttTime time
= ltt_event_time(e
);
720 LttTime window_end
= ltt_time_add(time_window
.time_width
,
721 time_window
.start_time
);
724 convert_time_to_pixels(
725 time_window
.start_time
,
730 //assert(x <= width);
732 /* draw what represents the event for outgoing process. */
734 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
735 draw_context_out
->current
->modify_over
->x
= x
;
736 draw_context_out
->current
->modify_under
->x
= x
;
737 draw_context_out
->current
->modify_over
->y
= y_out
;
738 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
739 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
740 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
741 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
742 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
743 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
744 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
745 //draw_context_out->gc = widget->style->black_gc;
747 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
748 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
750 /* Draw the line/background of the out process */
751 if(draw_context_out
->previous
->middle
->x
== -1)
753 draw_context_out
->previous
->over
->x
=
754 control_flow_data
->drawing
->damage_begin
;
755 draw_context_out
->previous
->middle
->x
=
756 control_flow_data
->drawing
->damage_begin
;
757 draw_context_out
->previous
->under
->x
=
758 control_flow_data
->drawing
->damage_begin
;
760 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
763 draw_context_out
->current
->middle
->x
= x
;
764 draw_context_out
->current
->over
->x
= x
;
765 draw_context_out
->current
->under
->x
= x
;
766 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
767 draw_context_out
->current
->over
->y
= y_out
;
768 draw_context_out
->current
->under
->y
= y_out
+ height
;
769 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
770 draw_context_out
->previous
->over
->y
= y_out
;
771 draw_context_out
->previous
->under
->y
= y_out
+ height
;
773 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
774 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
776 if(process_out
->state
->s
== LTTV_STATE_RUN
)
778 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
779 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
780 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
782 PropertiesBG prop_bg
;
783 prop_bg
.color
= g_new(GdkColor
,1);
787 prop_bg
.color
->red
= 0x1515;
788 prop_bg
.color
->green
= 0x1515;
789 prop_bg
.color
->blue
= 0x8c8c;
792 prop_bg
.color
->red
= 0x4e4e;
793 prop_bg
.color
->green
= 0xa9a9;
794 prop_bg
.color
->blue
= 0xa4a4;
797 prop_bg
.color
->red
= 0x7a7a;
798 prop_bg
.color
->green
= 0x4a4a;
799 prop_bg
.color
->blue
= 0x8b8b;
802 prop_bg
.color
->red
= 0x8080;
803 prop_bg
.color
->green
= 0x7777;
804 prop_bg
.color
->blue
= 0x4747;
807 prop_bg
.color
->red
= 0xe7e7;
808 prop_bg
.color
->green
= 0xe7e7;
809 prop_bg
.color
->blue
= 0xe7e7;
812 g_debug("calling from draw_event");
813 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
814 g_free(prop_bg
.color
);
815 //gdk_gc_unref(draw_context_out->gc);
818 draw_context_out
->gc
= widget
->style
->black_gc
;
820 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
821 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
822 PropertiesText prop_text_out
;
823 prop_text_out
.foreground
= &colorfg_out
;
824 prop_text_out
.background
= &colorbg_out
;
825 prop_text_out
.size
= 6;
826 prop_text_out
.position
= OVER
;
828 /* color of text : status of the process */
829 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
831 prop_text_out
.foreground
->red
= 0xffff;
832 prop_text_out
.foreground
->green
= 0xffff;
833 prop_text_out
.foreground
->blue
= 0xffff;
835 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
837 prop_text_out
.foreground
->red
= 0x0fff;
838 prop_text_out
.foreground
->green
= 0xffff;
839 prop_text_out
.foreground
->blue
= 0xfff0;
841 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
843 prop_text_out
.foreground
->red
= 0xffff;
844 prop_text_out
.foreground
->green
= 0xffff;
845 prop_text_out
.foreground
->blue
= 0x0000;
847 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
849 prop_text_out
.foreground
->red
= 0xffff;
850 prop_text_out
.foreground
->green
= 0x0000;
851 prop_text_out
.foreground
->blue
= 0xffff;
853 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
855 prop_text_out
.foreground
->red
= 0xffff;
856 prop_text_out
.foreground
->green
= 0x0000;
857 prop_text_out
.foreground
->blue
= 0x0000;
859 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
861 prop_text_out
.foreground
->red
= 0x0000;
862 prop_text_out
.foreground
->green
= 0xffff;
863 prop_text_out
.foreground
->blue
= 0x0000;
867 prop_text_out
.foreground
->red
= 0xffff;
868 prop_text_out
.foreground
->green
= 0xffff;
869 prop_text_out
.foreground
->blue
= 0xffff;
873 /* Print status of the process : U, WF, WC, E, W, R */
874 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
875 prop_text_out
.text
= "U->";
876 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
877 prop_text_out
.text
= "WF->";
878 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
879 prop_text_out
.text
= "WC->";
880 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
881 prop_text_out
.text
= "E->";
882 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
883 prop_text_out
.text
= "W->";
884 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
885 prop_text_out
.text
= "R->";
887 prop_text_out
.text
= "U";
889 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
890 //gdk_gc_unref(draw_context_out->gc);
892 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
893 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
894 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
896 PropertiesLine prop_line_out
;
897 prop_line_out
.color
= g_new(GdkColor
,1);
898 prop_line_out
.line_width
= 2;
899 prop_line_out
.style
= GDK_LINE_SOLID
;
900 prop_line_out
.position
= MIDDLE
;
902 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
904 /* color of line : status of the process */
905 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
907 prop_line_out
.color
->red
= 0xffff;
908 prop_line_out
.color
->green
= 0xffff;
909 prop_line_out
.color
->blue
= 0xffff;
911 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
913 prop_line_out
.color
->red
= 0x0fff;
914 prop_line_out
.color
->green
= 0xffff;
915 prop_line_out
.color
->blue
= 0xfff0;
917 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
919 prop_line_out
.color
->red
= 0xffff;
920 prop_line_out
.color
->green
= 0xffff;
921 prop_line_out
.color
->blue
= 0x0000;
923 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
925 prop_line_out
.color
->red
= 0xffff;
926 prop_line_out
.color
->green
= 0x0000;
927 prop_line_out
.color
->blue
= 0xffff;
929 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
931 prop_line_out
.color
->red
= 0xffff;
932 prop_line_out
.color
->green
= 0x0000;
933 prop_line_out
.color
->blue
= 0x0000;
935 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
937 prop_line_out
.color
->red
= 0x0000;
938 prop_line_out
.color
->green
= 0xffff;
939 prop_line_out
.color
->blue
= 0x0000;
943 prop_line_out
.color
->red
= 0xffff;
944 prop_line_out
.color
->green
= 0xffff;
945 prop_line_out
.color
->blue
= 0xffff;
948 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
949 g_free(prop_line_out
.color
);
950 //gdk_gc_unref(draw_context_out->gc);
951 /* Note : finishing line will have to be added when trace read over. */
953 /* Finally, update the drawing context of the pid_in. */
955 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
956 draw_context_in
->current
->modify_over
->x
= x
;
957 draw_context_in
->current
->modify_under
->x
= x
;
958 draw_context_in
->current
->modify_over
->y
= y_in
;
959 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
960 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
961 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
962 widget
= control_flow_data
->drawing
->drawing_area
;
963 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
964 //draw_context_in->gc = widget->style->black_gc;
965 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
966 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
968 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
969 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
971 /* Draw the line/bg of the in process */
972 if(draw_context_in
->previous
->middle
->x
== -1)
974 draw_context_in
->previous
->over
->x
=
975 control_flow_data
->drawing
->damage_begin
;
976 draw_context_in
->previous
->middle
->x
=
977 control_flow_data
->drawing
->damage_begin
;
978 draw_context_in
->previous
->under
->x
=
979 control_flow_data
->drawing
->damage_begin
;
981 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
985 draw_context_in
->current
->middle
->x
= x
;
986 draw_context_in
->current
->over
->x
= x
;
987 draw_context_in
->current
->under
->x
= x
;
988 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
989 draw_context_in
->current
->over
->y
= y_in
;
990 draw_context_in
->current
->under
->y
= y_in
+ height
;
991 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
992 draw_context_in
->previous
->over
->y
= y_in
;
993 draw_context_in
->previous
->under
->y
= y_in
+ height
;
995 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
996 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
999 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1001 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1002 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1003 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1005 PropertiesBG prop_bg
;
1006 prop_bg
.color
= g_new(GdkColor
,1);
1008 switch(tfc
->index
) {
1010 prop_bg
.color
->red
= 0x1515;
1011 prop_bg
.color
->green
= 0x1515;
1012 prop_bg
.color
->blue
= 0x8c8c;
1015 prop_bg
.color
->red
= 0x4e4e;
1016 prop_bg
.color
->green
= 0xa9a9;
1017 prop_bg
.color
->blue
= 0xa4a4;
1020 prop_bg
.color
->red
= 0x7a7a;
1021 prop_bg
.color
->green
= 0x4a4a;
1022 prop_bg
.color
->blue
= 0x8b8b;
1025 prop_bg
.color
->red
= 0x8080;
1026 prop_bg
.color
->green
= 0x7777;
1027 prop_bg
.color
->blue
= 0x4747;
1030 prop_bg
.color
->red
= 0xe7e7;
1031 prop_bg
.color
->green
= 0xe7e7;
1032 prop_bg
.color
->blue
= 0xe7e7;
1036 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1037 g_free(prop_bg
.color
);
1038 //gdk_gc_unref(draw_context_in->gc);
1041 draw_context_in
->gc
= widget
->style
->black_gc
;
1043 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1044 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1045 PropertiesText prop_text_in
;
1046 prop_text_in
.foreground
= &colorfg_in
;
1047 prop_text_in
.background
= &colorbg_in
;
1048 prop_text_in
.size
= 6;
1049 prop_text_in
.position
= OVER
;
1051 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1052 /* foreground of text : status of the process */
1053 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1055 prop_text_in
.foreground
->red
= 0xffff;
1056 prop_text_in
.foreground
->green
= 0xffff;
1057 prop_text_in
.foreground
->blue
= 0xffff;
1059 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1061 prop_text_in
.foreground
->red
= 0x0fff;
1062 prop_text_in
.foreground
->green
= 0xffff;
1063 prop_text_in
.foreground
->blue
= 0xfff0;
1065 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1067 prop_text_in
.foreground
->red
= 0xffff;
1068 prop_text_in
.foreground
->green
= 0xffff;
1069 prop_text_in
.foreground
->blue
= 0x0000;
1071 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1073 prop_text_in
.foreground
->red
= 0xffff;
1074 prop_text_in
.foreground
->green
= 0x0000;
1075 prop_text_in
.foreground
->blue
= 0xffff;
1077 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1079 prop_text_in
.foreground
->red
= 0xffff;
1080 prop_text_in
.foreground
->green
= 0x0000;
1081 prop_text_in
.foreground
->blue
= 0x0000;
1083 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1085 prop_text_in
.foreground
->red
= 0x0000;
1086 prop_text_in
.foreground
->green
= 0xffff;
1087 prop_text_in
.foreground
->blue
= 0x0000;
1091 prop_text_in
.foreground
->red
= 0xffff;
1092 prop_text_in
.foreground
->green
= 0xffff;
1093 prop_text_in
.foreground
->blue
= 0xffff;
1098 /* Print status of the process : U, WF, WC, E, W, R */
1099 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1100 prop_text_in
.text
= "U->";
1101 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1102 prop_text_in
.text
= "WF->";
1103 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1104 prop_text_in
.text
= "WC->";
1105 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1106 prop_text_in
.text
= "E->";
1107 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1108 prop_text_in
.text
= "W->";
1109 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1110 prop_text_in
.text
= "R->";
1112 prop_text_in
.text
= "U";
1114 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1115 //gdk_gc_unref(draw_context_in->gc);
1117 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1118 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1119 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1121 PropertiesLine prop_line_in
;
1122 prop_line_in
.color
= g_new(GdkColor
,1);
1123 prop_line_in
.line_width
= 2;
1124 prop_line_in
.style
= GDK_LINE_SOLID
;
1125 prop_line_in
.position
= MIDDLE
;
1127 /* color of line : status of the process */
1128 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1130 prop_line_in
.color
->red
= 0xffff;
1131 prop_line_in
.color
->green
= 0xffff;
1132 prop_line_in
.color
->blue
= 0xffff;
1134 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1136 prop_line_in
.color
->red
= 0x0fff;
1137 prop_line_in
.color
->green
= 0xffff;
1138 prop_line_in
.color
->blue
= 0xfff0;
1140 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1142 prop_line_in
.color
->red
= 0xffff;
1143 prop_line_in
.color
->green
= 0xffff;
1144 prop_line_in
.color
->blue
= 0x0000;
1146 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1148 prop_line_in
.color
->red
= 0xffff;
1149 prop_line_in
.color
->green
= 0x0000;
1150 prop_line_in
.color
->blue
= 0xffff;
1152 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1154 prop_line_in
.color
->red
= 0xffff;
1155 prop_line_in
.color
->green
= 0x0000;
1156 prop_line_in
.color
->blue
= 0x0000;
1158 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1160 prop_line_in
.color
->red
= 0x0000;
1161 prop_line_in
.color
->green
= 0xffff;
1162 prop_line_in
.color
->blue
= 0x0000;
1166 prop_line_in
.color
->red
= 0xffff;
1167 prop_line_in
.color
->green
= 0xffff;
1168 prop_line_in
.color
->blue
= 0xffff;
1171 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1172 g_free(prop_line_in
.color
);
1173 //gdk_gc_unref(draw_context_in->gc);
1183 GString
*string
= g_string_new("");;
1184 gboolean field_names
= TRUE
, state
= TRUE
;
1186 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1187 g_string_append_printf(string
,"\n");
1190 g_string_append_printf(string
, " %s",
1191 g_quark_to_string(tfs
->process
->state
->s
));
1194 g_info("%s",string
->str
);
1196 g_string_free(string
, TRUE
);
1198 /* End of text dump */
1203 /* after_schedchange_hook
1205 * The draw after hook is called by the reading API to have a
1206 * particular event drawn on the screen.
1207 * @param hook_data ControlFlowData structure of the viewer.
1208 * @param call_data Event context.
1210 * This function adds items to be drawn in a queue for each process.
1213 int after_schedchange_hook(void *hook_data
, void *call_data
)
1215 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1216 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1218 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1220 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1221 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1226 LttTime evtime
= ltt_event_time(e
);
1227 TimeWindow time_window
=
1228 lttvwindow_get_time_window(control_flow_data
->tab
);
1230 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1231 time_window
.time_width
);
1233 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1234 || ltt_time_compare(evtime
, end_time
) == 1)
1237 guint width
= control_flow_data
->drawing
->width
;
1239 /* Add process to process list (if not present) */
1240 LttvProcessState
*process_out
, *process_in
;
1242 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1243 HashedProcessData
*hashed_process_data_in
= NULL
;
1245 ProcessList
*process_list
=
1246 guicontrolflow_get_process_list(control_flow_data
);
1251 LttField
*f
= ltt_event_field(e
);
1253 element
= ltt_field_member(f
,0);
1254 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1255 element
= ltt_field_member(f
,1);
1256 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1257 g_debug("out : %u in : %u", pid_out
, pid_in
);
1261 /* Find process pid_in in the list... */
1262 process_in
= lttv_state_find_process(tfs
, pid_in
);
1263 /* It should exist, because we are after the state update. */
1264 g_assert(process_in
!= NULL
);
1266 birth
= process_in
->creation_time
;
1267 const gchar
*name
= g_quark_to_string(process_in
->name
);
1269 if(processlist_get_process_pixels(process_list
,
1271 process_in
->last_cpu
,
1273 tfc
->t_context
->index
,
1276 &hashed_process_data_in
) == 1)
1278 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1279 /* Process not present */
1280 processlist_add(process_list
,
1282 process_in
->last_cpu
,
1285 tfc
->t_context
->index
,
1288 &hashed_process_data_in
);
1289 processlist_get_process_pixels(process_list
,
1291 process_in
->last_cpu
,
1293 tfc
->t_context
->index
,
1296 &hashed_process_data_in
);
1297 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1300 convert_time_to_pixels(
1301 time_window
.start_time
,
1305 &hashed_process_data_in
->x
.middle
);
1311 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1312 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1314 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1316 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1317 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1323 LttTime evtime
= ltt_event_time(e
);
1324 TimeWindow time_window
=
1325 lttvwindow_get_time_window(control_flow_data
->tab
);
1327 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1328 time_window
.time_width
);
1329 //if(time < time_beg || time > time_end) return;
1330 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1331 || ltt_time_compare(evtime
, end_time
) == 1)
1335 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1337 g_debug("schedchange!");
1339 /* Add process to process list (if not present) and get drawing "y" from
1340 * process position */
1341 guint pid_out
, pid_in
;
1342 LttvProcessState
*process_out
, *process_in
;
1344 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1346 ProcessList
*process_list
=
1347 guicontrolflow_get_process_list(control_flow_data
);
1350 LttField
*f
= ltt_event_field(e
);
1352 element
= ltt_field_member(f
,0);
1353 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1354 element
= ltt_field_member(f
,1);
1355 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1356 //g_debug("out : %u in : %u", pid_out, pid_in);
1359 /* Find process pid_out in the list... */
1360 process_out
= lttv_state_find_process(tfs
, pid_out
);
1361 if(process_out
== NULL
) return 0;
1362 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1364 birth
= process_out
->creation_time
;
1365 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1366 HashedProcessData
*hashed_process_data_out
= NULL
;
1368 if(processlist_get_process_pixels(process_list
,
1371 tfc
->t_context
->index
,
1374 &hashed_process_data_out
) == 1)
1376 /* Process not present */
1377 processlist_add(process_list
,
1380 tfc
->t_context
->index
,
1383 &hashed_process_data_out
);
1384 processlist_get_process_pixels(process_list
,
1387 tfc
->t_context
->index
,
1390 &hashed_process_data_out
);
1391 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1396 /* Find process pid_in in the list... */
1397 process_in
= lttv_state_find_process(tfs
, pid_in
);
1398 if(process_in
== NULL
) return 0;
1399 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1401 birth
= process_in
->creation_time
;
1402 name
= strdup(g_quark_to_string(process_in
->name
));
1403 HashedProcessData
*hashed_process_data_in
= NULL
;
1405 if(processlist_get_process_pixels(process_list
,
1408 tfc
->t_context
->index
,
1411 &hashed_process_data_in
) == 1)
1413 /* Process not present */
1414 processlist_add(process_list
,
1417 tfc
->t_context
->index
,
1420 &hashed_process_data_in
);
1421 processlist_get_process_pixels(process_list
,
1424 tfc
->t_context
->index
,
1427 &hashed_process_data_in
);
1429 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1434 /* Find pixels corresponding to time of the event. If the time does
1435 * not fit in the window, show a warning, not supposed to happend. */
1437 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1439 //LttTime time = ltt_event_time(e);
1441 //LttTime window_end = ltt_time_add(time_window->time_width,
1442 // time_window->start_time);
1445 //convert_time_to_pixels(
1446 // time_window->start_time,
1452 //assert(x <= width);
1454 /* draw what represents the event for outgoing process. */
1456 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1457 //draw_context_out->current->modify_over->x = x;
1458 draw_context_out
->current
->modify_over
->y
= y_out
;
1459 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1460 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1461 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1462 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1463 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1465 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1466 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1468 /*if(process_out->state->s == LTTV_STATE_RUN)
1470 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1471 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1472 PropertiesBG prop_bg;
1473 prop_bg.color = g_new(GdkColor,1);
1475 prop_bg.color->red = 0xffff;
1476 prop_bg.color->green = 0xffff;
1477 prop_bg.color->blue = 0xffff;
1479 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1480 g_free(prop_bg.color);
1481 gdk_gc_unref(draw_context_out->gc);
1484 draw_context_out
->gc
= widget
->style
->black_gc
;
1486 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1487 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1488 PropertiesText prop_text_out
;
1489 prop_text_out
.foreground
= &colorfg_out
;
1490 prop_text_out
.background
= &colorbg_out
;
1491 prop_text_out
.size
= 6;
1492 prop_text_out
.position
= OVER
;
1494 /* color of text : status of the process */
1495 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1497 prop_text_out
.foreground
->red
= 0xffff;
1498 prop_text_out
.foreground
->green
= 0xffff;
1499 prop_text_out
.foreground
->blue
= 0xffff;
1501 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1503 prop_text_out
.foreground
->red
= 0x0fff;
1504 prop_text_out
.foreground
->green
= 0xffff;
1505 prop_text_out
.foreground
->blue
= 0xfff0;
1507 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1509 prop_text_out
.foreground
->red
= 0xffff;
1510 prop_text_out
.foreground
->green
= 0xffff;
1511 prop_text_out
.foreground
->blue
= 0x0000;
1513 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1515 prop_text_out
.foreground
->red
= 0xffff;
1516 prop_text_out
.foreground
->green
= 0x0000;
1517 prop_text_out
.foreground
->blue
= 0xffff;
1519 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1521 prop_text_out
.foreground
->red
= 0xffff;
1522 prop_text_out
.foreground
->green
= 0x0000;
1523 prop_text_out
.foreground
->blue
= 0x0000;
1525 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1527 prop_text_out
.foreground
->red
= 0x0000;
1528 prop_text_out
.foreground
->green
= 0xffff;
1529 prop_text_out
.foreground
->blue
= 0x0000;
1533 prop_text_out
.foreground
->red
= 0xffff;
1534 prop_text_out
.foreground
->green
= 0xffff;
1535 prop_text_out
.foreground
->blue
= 0xffff;
1538 /* Print status of the process : U, WF, WC, E, W, R */
1539 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1540 prop_text_out
.text
= "U";
1541 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1542 prop_text_out
.text
= "WF";
1543 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1544 prop_text_out
.text
= "WC";
1545 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1546 prop_text_out
.text
= "E";
1547 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1548 prop_text_out
.text
= "W";
1549 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1550 prop_text_out
.text
= "R";
1552 prop_text_out
.text
= "U";
1554 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1556 //gdk_gc_unref(draw_context_out->gc);
1558 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1559 draw_context_out
->current
->over
->y
= y_out
;
1560 draw_context_out
->current
->under
->y
= y_out
+height
;
1561 draw_context_out
->current
->status
= process_out
->state
->s
;
1563 /* for pid_out : remove previous, Prev = current, new current (default) */
1564 g_free(draw_context_out
->previous
->modify_under
);
1565 g_free(draw_context_out
->previous
->modify_middle
);
1566 g_free(draw_context_out
->previous
->modify_over
);
1567 g_free(draw_context_out
->previous
->under
);
1568 g_free(draw_context_out
->previous
->middle
);
1569 g_free(draw_context_out
->previous
->over
);
1570 g_free(draw_context_out
->previous
);
1572 draw_context_out
->previous
= draw_context_out
->current
;
1574 draw_context_out
->current
= g_new(DrawInfo
,1);
1575 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1576 draw_context_out
->current
->over
->x
= -1;
1577 draw_context_out
->current
->over
->y
= -1;
1578 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1579 draw_context_out
->current
->middle
->x
= -1;
1580 draw_context_out
->current
->middle
->y
= -1;
1581 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1582 draw_context_out
->current
->under
->x
= -1;
1583 draw_context_out
->current
->under
->y
= -1;
1584 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1585 draw_context_out
->current
->modify_over
->x
= -1;
1586 draw_context_out
->current
->modify_over
->y
= -1;
1587 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1588 draw_context_out
->current
->modify_middle
->x
= -1;
1589 draw_context_out
->current
->modify_middle
->y
= -1;
1590 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1591 draw_context_out
->current
->modify_under
->x
= -1;
1592 draw_context_out
->current
->modify_under
->y
= -1;
1593 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1595 /* Finally, update the drawing context of the pid_in. */
1597 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1598 //draw_context_in->current->modify_over->x = x;
1599 draw_context_in
->current
->modify_over
->y
= y_in
;
1600 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1601 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1602 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1603 widget
= control_flow_data
->drawing
->drawing_area
;
1604 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1606 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1607 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1609 /*if(process_in->state->s == LTTV_STATE_RUN)
1611 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1612 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1613 PropertiesBG prop_bg;
1614 prop_bg.color = g_new(GdkColor,1);
1616 prop_bg.color->red = 0xffff;
1617 prop_bg.color->green = 0xffff;
1618 prop_bg.color->blue = 0xffff;
1620 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1621 g_free(prop_bg.color);
1622 gdk_gc_unref(draw_context_in->gc);
1625 draw_context_in
->gc
= widget
->style
->black_gc
;
1627 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1628 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1629 PropertiesText prop_text_in
;
1630 prop_text_in
.foreground
= &colorfg_in
;
1631 prop_text_in
.background
= &colorbg_in
;
1632 prop_text_in
.size
= 6;
1633 prop_text_in
.position
= OVER
;
1635 /* foreground of text : status of the process */
1636 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1638 prop_text_in
.foreground
->red
= 0xffff;
1639 prop_text_in
.foreground
->green
= 0xffff;
1640 prop_text_in
.foreground
->blue
= 0xffff;
1642 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1644 prop_text_in
.foreground
->red
= 0x0fff;
1645 prop_text_in
.foreground
->green
= 0xffff;
1646 prop_text_in
.foreground
->blue
= 0xfff0;
1648 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1650 prop_text_in
.foreground
->red
= 0xffff;
1651 prop_text_in
.foreground
->green
= 0xffff;
1652 prop_text_in
.foreground
->blue
= 0x0000;
1654 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1656 prop_text_in
.foreground
->red
= 0xffff;
1657 prop_text_in
.foreground
->green
= 0x0000;
1658 prop_text_in
.foreground
->blue
= 0xffff;
1660 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1662 prop_text_in
.foreground
->red
= 0xffff;
1663 prop_text_in
.foreground
->green
= 0x0000;
1664 prop_text_in
.foreground
->blue
= 0x0000;
1666 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1668 prop_text_in
.foreground
->red
= 0x0000;
1669 prop_text_in
.foreground
->green
= 0xffff;
1670 prop_text_in
.foreground
->blue
= 0x0000;
1674 prop_text_in
.foreground
->red
= 0xffff;
1675 prop_text_in
.foreground
->green
= 0xffff;
1676 prop_text_in
.foreground
->blue
= 0xffff;
1680 /* Print status of the process : U, WF, WC, E, W, R */
1681 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1682 prop_text_in
.text
= "U";
1683 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1684 prop_text_in
.text
= "WF";
1685 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1686 prop_text_in
.text
= "WC";
1687 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1688 prop_text_in
.text
= "E";
1689 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1690 prop_text_in
.text
= "W";
1691 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1692 prop_text_in
.text
= "R";
1694 prop_text_in
.text
= "U";
1696 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1699 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1702 prop_text_in
.foreground
= &colorfg_in
;
1703 prop_text_in
.background
= &colorbg_in
;
1704 prop_text_in
.foreground
->red
= 0xffff;
1705 prop_text_in
.foreground
->green
= 0xffff;
1706 prop_text_in
.foreground
->blue
= 0xffff;
1707 prop_text_in
.size
= 6;
1708 prop_text_in
.position
= UNDER
;
1710 prop_text_in
.text
= g_new(gchar
, 260);
1711 strcpy(prop_text_in
.text
, "CPU ");
1712 snprintf(tmp
, 255, "%u", tfc
->index
);
1713 strcat(prop_text_in
.text
, tmp
);
1715 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1716 g_free(prop_text_in
.text
);
1720 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1721 draw_context_in
->current
->over
->y
= y_in
;
1722 draw_context_in
->current
->under
->y
= y_in
+height
;
1723 draw_context_in
->current
->status
= process_in
->state
->s
;
1725 /* for pid_in : remove previous, Prev = current, new current (default) */
1726 g_free(draw_context_in
->previous
->modify_under
);
1727 g_free(draw_context_in
->previous
->modify_middle
);
1728 g_free(draw_context_in
->previous
->modify_over
);
1729 g_free(draw_context_in
->previous
->under
);
1730 g_free(draw_context_in
->previous
->middle
);
1731 g_free(draw_context_in
->previous
->over
);
1732 g_free(draw_context_in
->previous
);
1734 draw_context_in
->previous
= draw_context_in
->current
;
1736 draw_context_in
->current
= g_new(DrawInfo
,1);
1737 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1738 draw_context_in
->current
->over
->x
= -1;
1739 draw_context_in
->current
->over
->y
= -1;
1740 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1741 draw_context_in
->current
->middle
->x
= -1;
1742 draw_context_in
->current
->middle
->y
= -1;
1743 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1744 draw_context_in
->current
->under
->x
= -1;
1745 draw_context_in
->current
->under
->y
= -1;
1746 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1747 draw_context_in
->current
->modify_over
->x
= -1;
1748 draw_context_in
->current
->modify_over
->y
= -1;
1749 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1750 draw_context_in
->current
->modify_middle
->x
= -1;
1751 draw_context_in
->current
->modify_middle
->y
= -1;
1752 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1753 draw_context_in
->current
->modify_under
->x
= -1;
1754 draw_context_in
->current
->modify_under
->y
= -1;
1755 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1763 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1765 PropertiesLine prop_line
;
1766 prop_line
.line_width
= 1;
1767 prop_line
.style
= GDK_LINE_SOLID
;
1769 //GdkColormap *colormap = gdk_colormap_get_system();
1771 /* color of line : execution mode of the process */
1772 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1773 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1774 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1775 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1776 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1777 prop_line
.color
= drawing_colors
[COL_TRAP
];
1778 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1779 prop_line
.color
= drawing_colors
[COL_IRQ
];
1780 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1781 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1783 prop_line
.color
= drawing_colors
[COL_WHITE
];
1785 //gdk_colormap_alloc_color(colormap,
1796 /* before_execmode_hook
1798 * This function basically draw lines and icons. Two types of lines are drawn :
1799 * one small (3 pixels?) representing the state of the process and the second
1800 * type is thicker (10 pixels?) representing on which CPU a process is running
1801 * (and this only in running state).
1803 * Extremums of the lines :
1804 * x_min : time of the last event context for this process kept in memory.
1805 * x_max : time of the current event.
1806 * y : middle of the process in the process list. The process is found in the
1807 * list, therefore is it's position in pixels.
1809 * The choice of lines'color is defined by the context of the last event for this
1814 int before_execmode_hook(void *hook_data
, void *call_data
)
1816 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1817 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1818 Drawing_t
*drawing
= control_flow_data
->drawing
;
1820 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1822 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1823 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1828 LttTime evtime
= ltt_event_time(e
);
1829 TimeWindow time_window
=
1830 lttvwindow_get_time_window(control_flow_data
->tab
);
1832 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1833 time_window
.time_width
);
1835 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1836 || ltt_time_compare(evtime
, end_time
) == 1)
1839 guint width
= drawing
->width
;
1841 /* we are in a execmode, before the state update. We must draw the
1842 * items corresponding to the state before it changes : now is the right
1846 LttvProcessState
*process
= tfs
->process
;
1847 g_assert(process
!= NULL
);
1849 guint pid
= process
->pid
;
1851 /* Well, the process_out existed : we must get it in the process hash
1852 * or add it, and draw its items.
1854 /* Add process to process list (if not present) */
1855 guint y
= 0, height
= 0, pl_height
= 0;
1856 HashedProcessData
*hashed_process_data
= NULL
;
1857 ProcessList
*process_list
=
1858 guicontrolflow_get_process_list(control_flow_data
);
1859 LttTime birth
= process
->creation_time
;
1860 const gchar
*name
= g_quark_to_string(process
->name
);
1862 if(processlist_get_process_pixels(process_list
,
1866 tfc
->t_context
->index
,
1869 &hashed_process_data
) == 1)
1871 g_assert(pid
== 0 || pid
!= process
->ppid
);
1872 /* Process not present */
1873 processlist_add(process_list
,
1878 tfc
->t_context
->index
,
1881 &hashed_process_data
);
1882 processlist_get_process_pixels(process_list
,
1886 tfc
->t_context
->index
,
1889 &hashed_process_data
);
1890 drawing_insert_square( drawing
, y
, height
);
1893 /* Now, the process is in the state hash and our own process hash.
1894 * We definitely can draw the items related to the ending state.
1897 /* Check if the x position is unset. In can have been left unset by
1898 * a draw closure from a after chunk hook. This should never happen,
1899 * because it must be set by before chunk hook to the damage_begin
1902 g_assert(hashed_process_data
->x
.over
!= -1);
1905 DrawContext draw_context
;
1907 convert_time_to_pixels(
1908 time_window
.start_time
,
1914 /* Now create the drawing context that will be used to draw
1915 * items related to the last state. */
1916 draw_context
.drawable
= drawing
->pixmap
;
1917 draw_context
.gc
= drawing
->gc
;
1918 draw_context
.pango_layout
= drawing
->pango_layout
;
1919 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
1920 draw_context
.drawinfo
.end
.x
= x
;
1922 draw_context
.drawinfo
.y
.over
= y
+1;
1923 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
1924 draw_context
.drawinfo
.y
.under
= y
+height
;
1926 draw_context
.drawinfo
.start
.offset
.over
= 0;
1927 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1928 draw_context
.drawinfo
.start
.offset
.under
= 0;
1929 draw_context
.drawinfo
.end
.offset
.over
= 0;
1930 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1931 draw_context
.drawinfo
.end
.offset
.under
= 0;
1935 PropertiesLine prop_line
= prepare_execmode_line(process
);
1936 draw_line((void*)&prop_line
, (void*)&draw_context
);
1939 /* become the last x position */
1940 hashed_process_data
->x
.over
= x
;
1946 /* after_execmode_hook
1948 * The draw after hook is called by the reading API to have a
1949 * particular event drawn on the screen.
1950 * @param hook_data ControlFlowData structure of the viewer.
1951 * @param call_data Event context.
1953 * This function adds items to be drawn in a queue for each process.
1956 int after_execmode_hook(void *hook_data
, void *call_data
)
1958 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1959 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1961 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1963 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1964 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1969 LttTime evtime
= ltt_event_time(e
);
1970 TimeWindow time_window
=
1971 lttvwindow_get_time_window(control_flow_data
->tab
);
1973 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1974 time_window
.time_width
);
1976 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1977 || ltt_time_compare(evtime
, end_time
) == 1)
1980 guint width
= control_flow_data
->drawing
->width
;
1982 /* Add process to process list (if not present) */
1983 LttvProcessState
*process
;
1985 guint y
= 0, height
= 0, pl_height
= 0;
1986 HashedProcessData
*hashed_process_data
= NULL
;
1988 ProcessList
*process_list
=
1989 guicontrolflow_get_process_list(control_flow_data
);
1992 /* Find process pid_in in the list... */
1993 process
= tfs
->process
;
1994 /* It should exist, because we are after the state update. */
1995 g_assert(process
!= NULL
);
1997 guint pid
= process
->pid
;
1999 birth
= process
->creation_time
;
2000 const gchar
*name
= g_quark_to_string(process
->name
);
2002 if(processlist_get_process_pixels(process_list
,
2006 tfc
->t_context
->index
,
2009 &hashed_process_data
) == 1)
2011 g_assert(pid
== 0 || pid
!= process
->ppid
);
2012 /* Process not present */
2013 processlist_add(process_list
,
2018 tfc
->t_context
->index
,
2021 &hashed_process_data
);
2022 processlist_get_process_pixels(process_list
,
2026 tfc
->t_context
->index
,
2029 &hashed_process_data
);
2030 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2033 convert_time_to_pixels(
2034 time_window
.start_time
,
2038 &hashed_process_data
->x
.over
);
2044 /* before_process_hook
2046 * Draw lines for process event.
2048 * @param hook_data ControlFlowData structure of the viewer.
2049 * @param call_data Event context.
2051 * This function adds items to be drawn in a queue for each process.
2054 int before_process_hook(void *hook_data
, void *call_data
)
2056 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2057 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2058 Drawing_t
*drawing
= control_flow_data
->drawing
;
2060 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2062 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2063 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2068 LttTime evtime
= ltt_event_time(e
);
2069 TimeWindow time_window
=
2070 lttvwindow_get_time_window(control_flow_data
->tab
);
2072 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2073 time_window
.time_width
);
2075 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2076 || ltt_time_compare(evtime
, end_time
) == 1)
2079 guint width
= control_flow_data
->drawing
->width
;
2083 LttField
*f
= ltt_event_field(e
);
2085 element
= ltt_field_member(f
,0);
2086 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2089 if(sub_id
== 3) { /* exit */
2091 /* Add process to process list (if not present) */
2092 LttvProcessState
*process
= tfs
->process
;
2093 guint pid
= process
->pid
;
2095 guint y
= 0, height
= 0, pl_height
= 0;
2096 HashedProcessData
*hashed_process_data
= NULL
;
2098 ProcessList
*process_list
=
2099 guicontrolflow_get_process_list(control_flow_data
);
2101 g_assert(process
!= NULL
);
2103 birth
= process
->creation_time
;
2104 const gchar
*name
= g_quark_to_string(process
->name
);
2106 if(processlist_get_process_pixels(process_list
,
2110 tfc
->t_context
->index
,
2113 &hashed_process_data
) == 1)
2115 g_assert(pid
== 0 || pid
!= process
->ppid
);
2116 /* Process not present */
2117 processlist_add(process_list
,
2122 tfc
->t_context
->index
,
2125 &hashed_process_data
);
2126 processlist_get_process_pixels(process_list
,
2130 tfc
->t_context
->index
,
2133 &hashed_process_data
);
2134 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2137 /* Now, the process is in the state hash and our own process hash.
2138 * We definitely can draw the items related to the ending state.
2141 /* Check if the x position is unset. In can have been left unset by
2142 * a draw closure from a after chunk hook. This should never happen,
2143 * because it must be set by before chunk hook to the damage_begin
2146 g_assert(hashed_process_data
->x
.over
!= -1);
2149 DrawContext draw_context
;
2151 convert_time_to_pixels(
2152 time_window
.start_time
,
2158 /* Now create the drawing context that will be used to draw
2159 * items related to the last state. */
2160 draw_context
.drawable
= drawing
->pixmap
;
2161 draw_context
.gc
= drawing
->gc
;
2162 draw_context
.pango_layout
= drawing
->pango_layout
;
2163 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2164 draw_context
.drawinfo
.end
.x
= x
;
2166 draw_context
.drawinfo
.y
.over
= y
+1;
2167 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2168 draw_context
.drawinfo
.y
.under
= y
+height
;
2170 draw_context
.drawinfo
.start
.offset
.over
= 0;
2171 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2172 draw_context
.drawinfo
.start
.offset
.under
= 0;
2173 draw_context
.drawinfo
.end
.offset
.over
= 0;
2174 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2175 draw_context
.drawinfo
.end
.offset
.under
= 0;
2179 PropertiesLine prop_line
= prepare_status_line(process
);
2180 draw_line((void*)&prop_line
, (void*)&draw_context
);
2183 /* become the last x position */
2184 hashed_process_data
->x
.middle
= x
;
2197 /* after_process_hook
2199 * Create the processlist entry for the child process. Put the last
2200 * position in x at the current time value.
2202 * @param hook_data ControlFlowData structure of the viewer.
2203 * @param call_data Event context.
2205 * This function adds items to be drawn in a queue for each process.
2208 int after_process_hook(void *hook_data
, void *call_data
)
2210 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2211 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2213 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2215 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2216 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2221 LttTime evtime
= ltt_event_time(e
);
2222 TimeWindow time_window
=
2223 lttvwindow_get_time_window(control_flow_data
->tab
);
2225 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2226 time_window
.time_width
);
2228 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2229 || ltt_time_compare(evtime
, end_time
) == 1)
2232 guint width
= control_flow_data
->drawing
->width
;
2237 LttField
*f
= ltt_event_field(e
);
2239 element
= ltt_field_member(f
,0);
2240 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2241 element
= ltt_field_member(f
,1);
2242 param1
= ltt_event_get_long_unsigned(e
,element
);
2245 if(sub_id
== 2) { /* fork */
2247 guint child_pid
= param1
;
2248 /* Add process to process list (if not present) */
2249 LttvProcessState
*process_child
;
2251 guint y_child
= 0, height
= 0, pl_height
= 0;
2252 HashedProcessData
*hashed_process_data_child
= NULL
;
2254 ProcessList
*process_list
=
2255 guicontrolflow_get_process_list(control_flow_data
);
2258 /* Find child in the list... */
2259 process_child
= lttv_state_find_process(tfs
, child_pid
);
2260 /* It should exist, because we are after the state update. */
2261 g_assert(process_child
!= NULL
);
2263 birth
= process_child
->creation_time
;
2264 const gchar
*name
= g_quark_to_string(process_child
->name
);
2266 if(processlist_get_process_pixels(process_list
,
2268 process_child
->last_cpu
,
2270 tfc
->t_context
->index
,
2273 &hashed_process_data_child
) == 1)
2275 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2276 /* Process not present */
2277 processlist_add(process_list
,
2279 process_child
->last_cpu
,
2280 process_child
->ppid
,
2282 tfc
->t_context
->index
,
2285 &hashed_process_data_child
);
2286 processlist_get_process_pixels(process_list
,
2288 process_child
->last_cpu
,
2290 tfc
->t_context
->index
,
2293 &hashed_process_data_child
);
2294 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2298 convert_time_to_pixels(
2299 time_window
.start_time
,
2304 hashed_process_data_child
->x
.over
= new_x
;
2305 hashed_process_data_child
->x
.middle
= new_x
;
2306 hashed_process_data_child
->x
.under
= new_x
;
2308 } else if(sub_id
== 3) { /* exit */
2310 /* Add process to process list (if not present) */
2311 LttvProcessState
*process
= tfs
->process
;
2312 guint pid
= process
->pid
;
2314 guint y
= 0, height
= 0, pl_height
= 0;
2315 HashedProcessData
*hashed_process_data
= NULL
;
2317 ProcessList
*process_list
=
2318 guicontrolflow_get_process_list(control_flow_data
);
2321 /* It should exist, because we are after the state update. */
2322 g_assert(process
!= NULL
);
2324 birth
= process
->creation_time
;
2325 const gchar
*name
= g_quark_to_string(process
->name
);
2327 if(processlist_get_process_pixels(process_list
,
2331 tfc
->t_context
->index
,
2334 &hashed_process_data
) == 1)
2336 g_assert(pid
== 0 || pid
!= process
->ppid
);
2337 /* Process not present */
2338 processlist_add(process_list
,
2343 tfc
->t_context
->index
,
2346 &hashed_process_data
);
2347 processlist_get_process_pixels(process_list
,
2351 tfc
->t_context
->index
,
2354 &hashed_process_data
);
2355 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2359 convert_time_to_pixels(
2360 time_window
.start_time
,
2365 hashed_process_data
->x
.middle
= new_x
;
2372 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2374 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2375 Drawing_t
*drawing
= control_flow_data
->drawing
;
2377 const TimeWindowNotifyData
*time_window_nofify_data
=
2378 ((const TimeWindowNotifyData
*)call_data
);
2380 TimeWindow
*old_time_window
=
2381 time_window_nofify_data
->old_time_window
;
2382 TimeWindow
*new_time_window
=
2383 time_window_nofify_data
->new_time_window
;
2385 /* Update the ruler */
2386 drawing_update_ruler(control_flow_data
->drawing
,
2390 /* Two cases : zoom in/out or scrolling */
2392 /* In order to make sure we can reuse the old drawing, the scale must
2393 * be the same and the new time interval being partly located in the
2394 * currently shown time interval. (reuse is only for scrolling)
2397 g_info("Old time window HOOK : %u, %u to %u, %u",
2398 old_time_window
->start_time
.tv_sec
,
2399 old_time_window
->start_time
.tv_nsec
,
2400 old_time_window
->time_width
.tv_sec
,
2401 old_time_window
->time_width
.tv_nsec
);
2403 g_info("New time window HOOK : %u, %u to %u, %u",
2404 new_time_window
->start_time
.tv_sec
,
2405 new_time_window
->start_time
.tv_nsec
,
2406 new_time_window
->time_width
.tv_sec
,
2407 new_time_window
->time_width
.tv_nsec
);
2409 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2410 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2412 /* Same scale (scrolling) */
2413 g_info("scrolling");
2414 LttTime
*ns
= &new_time_window
->start_time
;
2415 LttTime
*os
= &old_time_window
->start_time
;
2416 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
2417 old_time_window
->time_width
);
2418 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
2419 new_time_window
->time_width
);
2421 //if(ns<os+w && os+w<ns+w)
2422 //if(ns<old_end && os<ns)
2423 if(ltt_time_compare(*ns
, old_end
) == -1
2424 && ltt_time_compare(*os
, *ns
) == -1)
2426 g_info("scrolling near right");
2427 /* Scroll right, keep right part of the screen */
2429 guint width
= control_flow_data
->drawing
->width
;
2430 convert_time_to_pixels(
2437 /* Copy old data to new location */
2438 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2439 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2440 control_flow_data
->drawing
->pixmap
,
2443 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2445 if(drawing
->damage_begin
== drawing
->damage_end
)
2446 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2448 drawing
->damage_begin
= 0;
2450 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2452 /* Clear the data request background, but not SAFETY */
2453 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2454 //control_flow_data->drawing->drawing_area->style->black_gc,
2455 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2457 drawing
->damage_begin
+SAFETY
, 0,
2458 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2459 control_flow_data
->drawing
->height
);
2461 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2463 control_flow_data
->drawing
->width
,
2464 control_flow_data
->drawing
->height
);
2466 /* Get new data for the rest. */
2467 drawing_data_request(control_flow_data
->drawing
,
2468 &control_flow_data
->drawing
->pixmap
,
2469 drawing
->damage_begin
, 0,
2470 drawing
->damage_end
- drawing
->damage_begin
,
2471 control_flow_data
->drawing
->height
);
2474 //if(ns<os && os<ns+w)
2475 //if(ns<os && os<new_end)
2476 if(ltt_time_compare(*ns
,*os
) == -1
2477 && ltt_time_compare(*os
,new_end
) == -1)
2479 g_info("scrolling near left");
2480 /* Scroll left, keep left part of the screen */
2482 guint width
= control_flow_data
->drawing
->width
;
2483 convert_time_to_pixels(
2491 /* Copy old data to new location */
2492 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2493 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2494 control_flow_data
->drawing
->pixmap
,
2499 if(drawing
->damage_begin
== drawing
->damage_end
)
2500 drawing
->damage_end
= x
;
2502 drawing
->damage_end
=
2503 control_flow_data
->drawing
->width
;
2505 drawing
->damage_begin
= 0;
2507 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2508 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2510 drawing
->damage_begin
, 0,
2511 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2512 control_flow_data
->drawing
->height
);
2514 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2516 control_flow_data
->drawing
->width
,
2517 control_flow_data
->drawing
->height
);
2520 /* Get new data for the rest. */
2521 drawing_data_request(control_flow_data
->drawing
,
2522 &control_flow_data
->drawing
->pixmap
,
2523 drawing
->damage_begin
, 0,
2524 drawing
->damage_end
- drawing
->damage_begin
,
2525 control_flow_data
->drawing
->height
);
2528 if(ltt_time_compare(*ns
,*os
) == 0)
2530 g_info("not scrolling");
2532 g_info("scrolling far");
2533 /* Cannot reuse any part of the screen : far jump */
2536 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2537 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2540 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2541 control_flow_data
->drawing
->height
);
2543 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2545 control_flow_data
->drawing
->width
,
2546 control_flow_data
->drawing
->height
);
2548 drawing
->damage_begin
= 0;
2549 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2551 drawing_data_request(control_flow_data
->drawing
,
2552 &control_flow_data
->drawing
->pixmap
,
2554 control_flow_data
->drawing
->width
,
2555 control_flow_data
->drawing
->height
);
2561 /* Different scale (zoom) */
2564 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2565 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2568 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2569 control_flow_data
->drawing
->height
);
2571 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2573 control_flow_data
->drawing
->width
,
2574 control_flow_data
->drawing
->height
);
2576 drawing
->damage_begin
= 0;
2577 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2579 drawing_data_request(control_flow_data
->drawing
,
2580 &control_flow_data
->drawing
->pixmap
,
2582 control_flow_data
->drawing
->width
,
2583 control_flow_data
->drawing
->height
);
2591 gint
traceset_notify(void *hook_data
, void *call_data
)
2593 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2594 Drawing_t
*drawing
= control_flow_data
->drawing
;
2595 GtkWidget
*widget
= drawing
->drawing_area
;
2598 drawing_clear(control_flow_data
->drawing
);
2599 processlist_clear(control_flow_data
->process_list
);
2600 redraw_notify(control_flow_data
, NULL
);
2602 request_background_data(control_flow_data
);
2604 drawing
->damage_begin
= 0;
2605 drawing
->damage_end
= drawing
->width
;
2606 if(drawing
->damage_begin
< drawing
->damage_end
)
2608 drawing_data_request(drawing
,
2610 drawing
->damage_begin
,
2612 drawing
->damage_end
-drawing
->damage_begin
,
2616 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2625 gint
redraw_notify(void *hook_data
, void *call_data
)
2627 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2628 Drawing_t
*drawing
= control_flow_data
->drawing
;
2629 GtkWidget
*widget
= drawing
->drawing_area
;
2631 drawing
->damage_begin
= 0;
2632 drawing
->damage_end
= drawing
->width
;
2634 /* fun feature, to be separated someday... */
2635 drawing_clear(control_flow_data
->drawing
);
2636 processlist_clear(control_flow_data
->process_list
);
2639 gdk_draw_rectangle (drawing
->pixmap
,
2640 widget
->style
->black_gc
,
2643 drawing
->width
+SAFETY
,
2647 if(drawing
->damage_begin
< drawing
->damage_end
)
2649 drawing_data_request(drawing
,
2651 drawing
->damage_begin
,
2653 drawing
->damage_end
-drawing
->damage_begin
,
2657 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2666 gint
continue_notify(void *hook_data
, void *call_data
)
2668 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2669 Drawing_t
*drawing
= control_flow_data
->drawing
;
2670 GtkWidget
*widget
= drawing
->drawing_area
;
2672 //g_assert(widget->allocation.width == drawing->damage_end);
2674 if(drawing
->damage_begin
< drawing
->damage_end
)
2676 drawing_data_request(drawing
,
2678 drawing
->damage_begin
,
2680 drawing
->damage_end
-drawing
->damage_begin
,
2688 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2690 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2691 Drawing_t
*drawing
= control_flow_data
->drawing
;
2693 LttTime current_time
= *((LttTime
*)call_data
);
2695 TimeWindow time_window
=
2696 lttvwindow_get_time_window(control_flow_data
->tab
);
2698 LttTime time_begin
= time_window
.start_time
;
2699 LttTime width
= time_window
.time_width
;
2702 guint64 time_ll
= ltt_time_to_uint64(width
);
2703 time_ll
= time_ll
>> 1; /* divide by two */
2704 half_width
= ltt_time_from_uint64(time_ll
);
2706 LttTime time_end
= ltt_time_add(time_begin
, width
);
2708 LttvTracesetContext
* tsc
=
2709 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2711 LttTime trace_start
= tsc
->time_span
.start_time
;
2712 LttTime trace_end
= tsc
->time_span
.end_time
;
2714 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2715 current_time
.tv_nsec
);
2719 /* If current time is inside time interval, just move the highlight
2722 /* Else, we have to change the time interval. We have to tell it
2723 * to the main window. */
2724 /* The time interval change will take care of placing the current
2725 * time at the center of the visible area, or nearest possible if we are
2726 * at one end of the trace. */
2729 if(ltt_time_compare(current_time
, time_begin
) == -1)
2731 TimeWindow new_time_window
;
2733 if(ltt_time_compare(current_time
,
2734 ltt_time_add(trace_start
,half_width
)) == -1)
2735 time_begin
= trace_start
;
2737 time_begin
= ltt_time_sub(current_time
,half_width
);
2739 new_time_window
.start_time
= time_begin
;
2740 new_time_window
.time_width
= width
;
2742 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2744 else if(ltt_time_compare(current_time
, time_end
) == 1)
2746 TimeWindow new_time_window
;
2748 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2749 time_begin
= ltt_time_sub(trace_end
,width
);
2751 time_begin
= ltt_time_sub(current_time
,half_width
);
2753 new_time_window
.start_time
= time_begin
;
2754 new_time_window
.time_width
= width
;
2756 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2759 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2760 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2768 typedef struct _ClosureData
{
2769 EventsRequest
*events_request
;
2770 LttvTracesetState
*tss
;
2775 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2777 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2778 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2779 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2781 EventsRequest
*events_request
= closure_data
->events_request
;
2782 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2783 Drawing_t
*drawing
= control_flow_data
->drawing
;
2785 LttvTracesetState
*tss
= closure_data
->tss
;
2786 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2788 LttTime evtime
= closure_data
->end_time
;
2789 TimeWindow time_window
=
2790 lttvwindow_get_time_window(control_flow_data
->tab
);
2792 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2793 time_window
.time_width
);
2795 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2796 || ltt_time_compare(evtime
, end_time
) == 1)
2799 guint width
= drawing
->width
;
2802 /* For the process */
2803 /* First, check if the current process is in the state computation
2804 * process list. If it is there, that means we must add it right now and
2805 * draw items from the beginning of the read for it. If it is not
2806 * present, it's a new process and it was not present : it will
2807 * be added after the state update. */
2808 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2810 /* tracefiles[0] is ok here, because we draw for every PID, and
2811 * assume CPU 0 for PID 0 //FIXME */
2812 LttvTracefileState
*tfs
=
2813 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2815 LttvProcessState
*process
;
2816 process
= lttv_state_find_process(tfs
,
2819 if(process
!= NULL
) {
2821 /* Only draw for processes that are currently in the trace states */
2823 guint y
= 0, height
= 0, pl_height
= 0;
2824 ProcessList
*process_list
=
2825 guicontrolflow_get_process_list(control_flow_data
);
2826 LttTime birth
= process_info
->birth
;
2828 /* Should be alike when background info is ready */
2829 if(control_flow_data
->background_info_waiting
==0)
2830 g_assert(ltt_time_compare(process
->creation_time
,
2831 process_info
->birth
) == 0);
2832 const gchar
*name
= g_quark_to_string(process
->name
);
2834 /* process HAS to be present */
2835 g_assert(processlist_get_process_pixels(process_list
,
2839 process_info
->trace_num
,
2842 &hashed_process_data
) != 1);
2844 /* Now, the process is in the state hash and our own process hash.
2845 * We definitely can draw the items related to the ending state.
2848 /* Check if the x position is unset. In can have been left unset by
2849 * a draw closure from a after chunk hook. This should never happen,
2850 * because it must be set by before chunk hook to the damage_begin
2853 g_assert(hashed_process_data
->x
.over
!= -1);
2856 DrawContext draw_context
;
2858 convert_time_to_pixels(
2859 time_window
.start_time
,
2865 /* Now create the drawing context that will be used to draw
2866 * items related to the last state. */
2867 draw_context
.drawable
= drawing
->pixmap
;
2868 draw_context
.gc
= drawing
->gc
;
2869 draw_context
.pango_layout
= drawing
->pango_layout
;
2870 draw_context
.drawinfo
.end
.x
= x
;
2872 draw_context
.drawinfo
.y
.over
= y
+1;
2873 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2874 draw_context
.drawinfo
.y
.under
= y
+height
;
2876 draw_context
.drawinfo
.start
.offset
.over
= 0;
2877 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2878 draw_context
.drawinfo
.start
.offset
.under
= 0;
2879 draw_context
.drawinfo
.end
.offset
.over
= 0;
2880 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2881 draw_context
.drawinfo
.end
.offset
.under
= 0;
2884 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
2886 PropertiesLine prop_line
= prepare_execmode_line(process
);
2887 draw_line((void*)&prop_line
, (void*)&draw_context
);
2890 hashed_process_data
->x
.over
= x
;
2892 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2894 PropertiesLine prop_line
= prepare_status_line(process
);
2895 draw_line((void*)&prop_line
, (void*)&draw_context
);
2899 /* become the last x position */
2900 hashed_process_data
->x
.middle
= x
;
2907 int before_chunk(void *hook_data
, void *call_data
)
2909 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2910 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2912 drawing_chunk_begin(events_request
, tss
);
2917 int before_request(void *hook_data
, void *call_data
)
2919 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2920 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2922 drawing_data_request_begin(events_request
, tss
);
2929 * after request is necessary in addition of after chunk in order to draw
2930 * lines until the end of the screen. after chunk just draws lines until
2937 int after_request(void *hook_data
, void *call_data
)
2939 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2940 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2941 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2942 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2944 ProcessList
*process_list
=
2945 guicontrolflow_get_process_list(control_flow_data
);
2946 LttTime end_time
= events_request
->end_time
;
2948 ClosureData closure_data
;
2949 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2950 closure_data
.tss
= tss
;
2951 closure_data
.end_time
= end_time
;
2953 /* Draw last items */
2954 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2955 (void*)&closure_data
);
2957 /* Request expose */
2958 drawing_request_expose(events_request
, tss
, end_time
);
2967 int after_chunk(void *hook_data
, void *call_data
)
2969 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2970 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2971 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2972 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2973 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
2976 ProcessList
*process_list
=
2977 guicontrolflow_get_process_list(control_flow_data
);
2980 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
2981 else /* end of traceset, or position now out of request : end */
2982 end_time
= events_request
->end_time
;
2984 ClosureData closure_data
;
2985 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2986 closure_data
.tss
= tss
;
2987 closure_data
.end_time
= end_time
;
2989 /* Draw last items */
2990 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2991 (void*)&closure_data
);
2993 /* Request expose */
2994 drawing_request_expose(events_request
, tss
, end_time
);