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
++;
212 lttv_hooks_destroy(background_ready_hook
);
219 * Event Viewer's constructor hook
221 * This constructor is given as a parameter to the menuitem and toolbar button
222 * registration. It creates the list.
223 * @param tab A pointer to the parent tab.
224 * @return The widget created.
227 h_guicontrolflow(Tab
*tab
)
229 g_info("h_guicontrolflow, %p", tab
);
230 ControlFlowData
*control_flow_data
= guicontrolflow() ;
232 control_flow_data
->tab
= tab
;
234 //g_debug("time width2 : %u",time_window->time_width);
235 // Unreg done in the GuiControlFlow_Destructor
236 lttvwindow_register_traceset_notify(tab
,
240 lttvwindow_register_time_window_notify(tab
,
241 update_time_window_hook
,
243 lttvwindow_register_current_time_notify(tab
,
244 update_current_time_hook
,
246 lttvwindow_register_redraw_notify(tab
,
249 lttvwindow_register_continue_notify(tab
,
252 request_background_data(control_flow_data
);
255 return guicontrolflow_get_widget(control_flow_data
) ;
259 int event_selected_hook(void *hook_data
, void *call_data
)
261 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
262 guint
*event_number
= (guint
*) call_data
;
264 g_debug("DEBUG : event selected by main window : %u", *event_number
);
269 static __inline PropertiesLine
prepare_status_line(LttvProcessState
*process
)
271 PropertiesLine prop_line
;
272 prop_line
.line_width
= 2;
273 prop_line
.style
= GDK_LINE_SOLID
;
274 prop_line
.y
= MIDDLE
;
275 //GdkColormap *colormap = gdk_colormap_get_system();
277 g_debug("prepare_status_line for state : %s",
278 g_quark_to_string(process
->state
->s
));
280 /* color of line : status of the process */
281 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
282 prop_line
.color
= drawing_colors
[COL_WHITE
];
283 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
284 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
285 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
286 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
287 else if(process
->state
->s
== LTTV_STATE_EXIT
)
288 prop_line
.color
= drawing_colors
[COL_EXIT
];
289 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
290 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
291 else if(process
->state
->s
== LTTV_STATE_WAIT
)
292 prop_line
.color
= drawing_colors
[COL_WAIT
];
293 else if(process
->state
->s
== LTTV_STATE_RUN
)
294 prop_line
.color
= drawing_colors
[COL_RUN
];
296 prop_line
.color
= drawing_colors
[COL_WHITE
];
298 //gdk_colormap_alloc_color(colormap,
309 /* before_schedchange_hook
311 * This function basically draw lines and icons. Two types of lines are drawn :
312 * one small (3 pixels?) representing the state of the process and the second
313 * type is thicker (10 pixels?) representing on which CPU a process is running
314 * (and this only in running state).
316 * Extremums of the lines :
317 * x_min : time of the last event context for this process kept in memory.
318 * x_max : time of the current event.
319 * y : middle of the process in the process list. The process is found in the
320 * list, therefore is it's position in pixels.
322 * The choice of lines'color is defined by the context of the last event for this
327 int before_schedchange_hook(void *hook_data
, void *call_data
)
329 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
330 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
331 Drawing_t
*drawing
= control_flow_data
->drawing
;
333 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
335 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
336 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
341 LttTime evtime
= ltt_event_time(e
);
342 TimeWindow time_window
=
343 lttvwindow_get_time_window(control_flow_data
->tab
);
345 LttTime end_time
= ltt_time_add(time_window
.start_time
,
346 time_window
.time_width
);
348 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
349 || ltt_time_compare(evtime
, end_time
) == 1)
352 guint width
= drawing
->width
;
354 /* we are in a schedchange, before the state update. We must draw the
355 * items corresponding to the state before it changes : now is the right
362 LttField
*f
= ltt_event_field(e
);
364 element
= ltt_field_member(f
,0);
365 pid_out
= ltt_event_get_long_unsigned(e
,element
);
366 element
= ltt_field_member(f
,1);
367 pid_in
= ltt_event_get_long_unsigned(e
,element
);
368 g_debug("out : %u in : %u", pid_out
, pid_in
);
372 /* For the pid_out */
373 /* First, check if the current process is in the state computation
374 * process list. If it is there, that means we must add it right now and
375 * draw items from the beginning of the read for it. If it is not
376 * present, it's a new process and it was not present : it will
377 * be added after the state update. */
378 LttvProcessState
*process
;
379 process
= lttv_state_find_process(tfs
, pid_out
);
381 if(process
!= NULL
) {
382 /* Well, the process_out existed : we must get it in the process hash
383 * or add it, and draw its items.
385 /* Add process to process list (if not present) */
386 guint y
= 0, height
= 0, pl_height
= 0;
387 HashedProcessData
*hashed_process_data
= NULL
;
388 ProcessList
*process_list
=
389 guicontrolflow_get_process_list(control_flow_data
);
390 LttTime birth
= process
->creation_time
;
391 const gchar
*name
= g_quark_to_string(process
->name
);
393 if(processlist_get_process_pixels(process_list
,
397 tfc
->t_context
->index
,
400 &hashed_process_data
) == 1)
402 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
403 /* Process not present */
404 processlist_add(process_list
,
409 tfc
->t_context
->index
,
412 &hashed_process_data
);
413 processlist_get_process_pixels(process_list
,
417 tfc
->t_context
->index
,
420 &hashed_process_data
);
421 drawing_insert_square( drawing
, y
, height
);
424 /* Now, the process is in the state hash and our own process hash.
425 * We definitely can draw the items related to the ending state.
428 /* Check if the x position is unset. In can have been left unset by
429 * a draw closure from a after chunk hook. This should never happen,
430 * because it must be set by before chunk hook to the damage_begin
433 g_assert(hashed_process_data
->x
.middle
!= -1);
436 DrawContext draw_context
;
438 convert_time_to_pixels(
439 time_window
.start_time
,
445 /* Now create the drawing context that will be used to draw
446 * items related to the last state. */
447 draw_context
.drawable
= drawing
->pixmap
;
448 draw_context
.gc
= drawing
->gc
;
449 draw_context
.pango_layout
= drawing
->pango_layout
;
450 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
451 draw_context
.drawinfo
.end
.x
= x
;
453 draw_context
.drawinfo
.y
.over
= y
+1;
454 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
455 draw_context
.drawinfo
.y
.under
= y
+height
;
457 draw_context
.drawinfo
.start
.offset
.over
= 0;
458 draw_context
.drawinfo
.start
.offset
.middle
= 0;
459 draw_context
.drawinfo
.start
.offset
.under
= 0;
460 draw_context
.drawinfo
.end
.offset
.over
= 0;
461 draw_context
.drawinfo
.end
.offset
.middle
= 0;
462 draw_context
.drawinfo
.end
.offset
.under
= 0;
466 PropertiesLine prop_line
= prepare_status_line(process
);
467 draw_line((void*)&prop_line
, (void*)&draw_context
);
470 /* become the last x position */
471 hashed_process_data
->x
.middle
= x
;
478 /* First, check if the current process is in the state computation
479 * process list. If it is there, that means we must add it right now and
480 * draw items from the beginning of the read for it. If it is not
481 * present, it's a new process and it was not present : it will
482 * be added after the state update. */
483 LttvProcessState
*process
;
484 process
= lttv_state_find_process(tfs
, pid_in
);
486 if(process
!= NULL
) {
487 /* Well, the process_out existed : we must get it in the process hash
488 * or add it, and draw its items.
490 /* Add process to process list (if not present) */
491 guint y
= 0, height
= 0, pl_height
= 0;
492 HashedProcessData
*hashed_process_data
= NULL
;
493 ProcessList
*process_list
=
494 guicontrolflow_get_process_list(control_flow_data
);
495 LttTime birth
= process
->creation_time
;
496 const gchar
*name
= g_quark_to_string(process
->name
);
498 if(processlist_get_process_pixels(process_list
,
502 tfc
->t_context
->index
,
505 &hashed_process_data
) == 1)
507 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
508 /* Process not present */
509 processlist_add(process_list
,
514 tfc
->t_context
->index
,
517 &hashed_process_data
);
518 processlist_get_process_pixels(process_list
,
522 tfc
->t_context
->index
,
525 &hashed_process_data
);
526 drawing_insert_square( drawing
, y
, height
);
529 /* Now, the process is in the state hash and our own process hash.
530 * We definitely can draw the items related to the ending state.
533 /* Check if the x position is unset. In can have been left unset by
534 * a draw closure from a after chunk hook. This should never happen,
535 * because it must be set by before chunk hook to the damage_begin
538 g_assert(hashed_process_data
->x
.middle
!= -1);
541 DrawContext draw_context
;
543 convert_time_to_pixels(
544 time_window
.start_time
,
550 /* Now create the drawing context that will be used to draw
551 * items related to the last state. */
552 draw_context
.drawable
= drawing
->pixmap
;
553 draw_context
.gc
= drawing
->gc
;
554 draw_context
.pango_layout
= drawing
->pango_layout
;
555 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
556 draw_context
.drawinfo
.end
.x
= x
;
558 draw_context
.drawinfo
.y
.over
= y
+1;
559 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
560 draw_context
.drawinfo
.y
.under
= y
+height
;
562 draw_context
.drawinfo
.start
.offset
.over
= 0;
563 draw_context
.drawinfo
.start
.offset
.middle
= 0;
564 draw_context
.drawinfo
.start
.offset
.under
= 0;
565 draw_context
.drawinfo
.end
.offset
.over
= 0;
566 draw_context
.drawinfo
.end
.offset
.middle
= 0;
567 draw_context
.drawinfo
.end
.offset
.under
= 0;
571 PropertiesLine prop_line
= prepare_status_line(process
);
572 draw_line((void*)&prop_line
, (void*)&draw_context
);
576 /* become the last x position */
577 hashed_process_data
->x
.middle
= x
;
585 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
586 ControlFlowData
*control_flow_data
=
587 (ControlFlowData
*)events_request
->viewer_data
;
588 Tab
*tab
= control_flow_data
->tab
;
590 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
592 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
593 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
598 LttTime evtime
= ltt_event_time(e
);
599 TimeWindow time_window
=
600 lttvwindow_get_time_window(tab
);
602 LttTime end_time
= ltt_time_add(time_window
.start_time
,
603 time_window
.time_width
);
604 //if(time < time_beg || time > time_end) return;
605 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
606 || ltt_time_compare(evtime
, end_time
) == 1)
609 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
611 g_debug("schedchange!");
613 /* Add process to process list (if not present) and get drawing "y" from
614 * process position */
615 guint pid_out
, pid_in
;
616 LttvProcessState
*process_out
, *process_in
;
618 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
620 ProcessList
*process_list
=
621 guicontrolflow_get_process_list(control_flow_data
);
624 LttField
*f
= ltt_event_field(e
);
626 element
= ltt_field_member(f
,0);
627 pid_out
= ltt_event_get_long_unsigned(e
,element
);
628 element
= ltt_field_member(f
,1);
629 pid_in
= ltt_event_get_long_unsigned(e
,element
);
630 g_debug("out : %u in : %u", pid_out
, pid_in
);
633 /* Find process pid_out in the list... */
634 process_out
= lttv_state_find_process(tfs
, pid_out
);
635 if(process_out
== NULL
) return 0;
636 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
638 birth
= process_out
->creation_time
;
639 const gchar
*name
= g_quark_to_string(process_out
->name
);
640 HashedProcessData
*hashed_process_data_out
= NULL
;
642 if(processlist_get_process_pixels(process_list
,
645 tfc
->t_context
->index
,
648 &hashed_process_data_out
) == 1)
650 /* Process not present */
651 processlist_add(process_list
,
654 tfc
->t_context
->index
,
657 &hashed_process_data_out
);
658 g_assert(processlist_get_process_pixels(process_list
,
661 tfc
->t_context
->index
,
664 &hashed_process_data_out
)==0);
665 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
669 /* Find process pid_in in the list... */
670 process_in
= lttv_state_find_process(tfs
, pid_in
);
671 if(process_in
== NULL
) return 0;
672 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
674 birth
= process_in
->creation_time
;
675 name
= g_quark_to_string(process_in
->name
);
676 HashedProcessData
*hashed_process_data_in
= NULL
;
678 if(processlist_get_process_pixels(process_list
,
681 tfc
->t_context
->index
,
684 &hashed_process_data_in
) == 1)
686 /* Process not present */
687 processlist_add(process_list
,
690 tfc
->t_context
->index
,
693 &hashed_process_data_in
);
694 processlist_get_process_pixels(process_list
,
697 tfc
->t_context
->index
,
700 &hashed_process_data_in
);
702 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
707 /* Find pixels corresponding to time of the event. If the time does
708 * not fit in the window, show a warning, not supposed to happend. */
710 guint width
= control_flow_data
->drawing
->width
;
712 LttTime time
= ltt_event_time(e
);
714 LttTime window_end
= ltt_time_add(time_window
.time_width
,
715 time_window
.start_time
);
718 convert_time_to_pixels(
719 time_window
.start_time
,
724 //assert(x <= width);
726 /* draw what represents the event for outgoing process. */
728 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
729 draw_context_out
->current
->modify_over
->x
= x
;
730 draw_context_out
->current
->modify_under
->x
= x
;
731 draw_context_out
->current
->modify_over
->y
= y_out
;
732 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
733 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
734 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
735 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
736 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
737 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
738 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
739 //draw_context_out->gc = widget->style->black_gc;
741 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
742 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
744 /* Draw the line/background of the out process */
745 if(draw_context_out
->previous
->middle
->x
== -1)
747 draw_context_out
->previous
->over
->x
=
748 control_flow_data
->drawing
->damage_begin
;
749 draw_context_out
->previous
->middle
->x
=
750 control_flow_data
->drawing
->damage_begin
;
751 draw_context_out
->previous
->under
->x
=
752 control_flow_data
->drawing
->damage_begin
;
754 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
757 draw_context_out
->current
->middle
->x
= x
;
758 draw_context_out
->current
->over
->x
= x
;
759 draw_context_out
->current
->under
->x
= x
;
760 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
761 draw_context_out
->current
->over
->y
= y_out
;
762 draw_context_out
->current
->under
->y
= y_out
+ height
;
763 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
764 draw_context_out
->previous
->over
->y
= y_out
;
765 draw_context_out
->previous
->under
->y
= y_out
+ height
;
767 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
768 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
770 if(process_out
->state
->s
== LTTV_STATE_RUN
)
772 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
773 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
774 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
776 PropertiesBG prop_bg
;
777 prop_bg
.color
= g_new(GdkColor
,1);
781 prop_bg
.color
->red
= 0x1515;
782 prop_bg
.color
->green
= 0x1515;
783 prop_bg
.color
->blue
= 0x8c8c;
786 prop_bg
.color
->red
= 0x4e4e;
787 prop_bg
.color
->green
= 0xa9a9;
788 prop_bg
.color
->blue
= 0xa4a4;
791 prop_bg
.color
->red
= 0x7a7a;
792 prop_bg
.color
->green
= 0x4a4a;
793 prop_bg
.color
->blue
= 0x8b8b;
796 prop_bg
.color
->red
= 0x8080;
797 prop_bg
.color
->green
= 0x7777;
798 prop_bg
.color
->blue
= 0x4747;
801 prop_bg
.color
->red
= 0xe7e7;
802 prop_bg
.color
->green
= 0xe7e7;
803 prop_bg
.color
->blue
= 0xe7e7;
806 g_debug("calling from draw_event");
807 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
808 g_free(prop_bg
.color
);
809 //gdk_gc_unref(draw_context_out->gc);
812 draw_context_out
->gc
= widget
->style
->black_gc
;
814 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
815 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
816 PropertiesText prop_text_out
;
817 prop_text_out
.foreground
= &colorfg_out
;
818 prop_text_out
.background
= &colorbg_out
;
819 prop_text_out
.size
= 6;
820 prop_text_out
.position
= OVER
;
822 /* color of text : status of the process */
823 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
825 prop_text_out
.foreground
->red
= 0xffff;
826 prop_text_out
.foreground
->green
= 0xffff;
827 prop_text_out
.foreground
->blue
= 0xffff;
829 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
831 prop_text_out
.foreground
->red
= 0x0fff;
832 prop_text_out
.foreground
->green
= 0xffff;
833 prop_text_out
.foreground
->blue
= 0xfff0;
835 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
837 prop_text_out
.foreground
->red
= 0xffff;
838 prop_text_out
.foreground
->green
= 0xffff;
839 prop_text_out
.foreground
->blue
= 0x0000;
841 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
843 prop_text_out
.foreground
->red
= 0xffff;
844 prop_text_out
.foreground
->green
= 0x0000;
845 prop_text_out
.foreground
->blue
= 0xffff;
847 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
849 prop_text_out
.foreground
->red
= 0xffff;
850 prop_text_out
.foreground
->green
= 0x0000;
851 prop_text_out
.foreground
->blue
= 0x0000;
853 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
855 prop_text_out
.foreground
->red
= 0x0000;
856 prop_text_out
.foreground
->green
= 0xffff;
857 prop_text_out
.foreground
->blue
= 0x0000;
861 prop_text_out
.foreground
->red
= 0xffff;
862 prop_text_out
.foreground
->green
= 0xffff;
863 prop_text_out
.foreground
->blue
= 0xffff;
867 /* Print status of the process : U, WF, WC, E, W, R */
868 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
869 prop_text_out
.text
= "U->";
870 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
871 prop_text_out
.text
= "WF->";
872 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
873 prop_text_out
.text
= "WC->";
874 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
875 prop_text_out
.text
= "E->";
876 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
877 prop_text_out
.text
= "W->";
878 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
879 prop_text_out
.text
= "R->";
881 prop_text_out
.text
= "U";
883 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
884 //gdk_gc_unref(draw_context_out->gc);
886 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
887 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
888 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
890 PropertiesLine prop_line_out
;
891 prop_line_out
.color
= g_new(GdkColor
,1);
892 prop_line_out
.line_width
= 2;
893 prop_line_out
.style
= GDK_LINE_SOLID
;
894 prop_line_out
.position
= MIDDLE
;
896 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
898 /* color of line : status of the process */
899 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
901 prop_line_out
.color
->red
= 0xffff;
902 prop_line_out
.color
->green
= 0xffff;
903 prop_line_out
.color
->blue
= 0xffff;
905 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
907 prop_line_out
.color
->red
= 0x0fff;
908 prop_line_out
.color
->green
= 0xffff;
909 prop_line_out
.color
->blue
= 0xfff0;
911 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
913 prop_line_out
.color
->red
= 0xffff;
914 prop_line_out
.color
->green
= 0xffff;
915 prop_line_out
.color
->blue
= 0x0000;
917 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
919 prop_line_out
.color
->red
= 0xffff;
920 prop_line_out
.color
->green
= 0x0000;
921 prop_line_out
.color
->blue
= 0xffff;
923 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
925 prop_line_out
.color
->red
= 0xffff;
926 prop_line_out
.color
->green
= 0x0000;
927 prop_line_out
.color
->blue
= 0x0000;
929 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
931 prop_line_out
.color
->red
= 0x0000;
932 prop_line_out
.color
->green
= 0xffff;
933 prop_line_out
.color
->blue
= 0x0000;
937 prop_line_out
.color
->red
= 0xffff;
938 prop_line_out
.color
->green
= 0xffff;
939 prop_line_out
.color
->blue
= 0xffff;
942 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
943 g_free(prop_line_out
.color
);
944 //gdk_gc_unref(draw_context_out->gc);
945 /* Note : finishing line will have to be added when trace read over. */
947 /* Finally, update the drawing context of the pid_in. */
949 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
950 draw_context_in
->current
->modify_over
->x
= x
;
951 draw_context_in
->current
->modify_under
->x
= x
;
952 draw_context_in
->current
->modify_over
->y
= y_in
;
953 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
954 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
955 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
956 widget
= control_flow_data
->drawing
->drawing_area
;
957 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
958 //draw_context_in->gc = widget->style->black_gc;
959 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
960 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
962 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
963 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
965 /* Draw the line/bg of the in process */
966 if(draw_context_in
->previous
->middle
->x
== -1)
968 draw_context_in
->previous
->over
->x
=
969 control_flow_data
->drawing
->damage_begin
;
970 draw_context_in
->previous
->middle
->x
=
971 control_flow_data
->drawing
->damage_begin
;
972 draw_context_in
->previous
->under
->x
=
973 control_flow_data
->drawing
->damage_begin
;
975 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
979 draw_context_in
->current
->middle
->x
= x
;
980 draw_context_in
->current
->over
->x
= x
;
981 draw_context_in
->current
->under
->x
= x
;
982 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
983 draw_context_in
->current
->over
->y
= y_in
;
984 draw_context_in
->current
->under
->y
= y_in
+ height
;
985 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
986 draw_context_in
->previous
->over
->y
= y_in
;
987 draw_context_in
->previous
->under
->y
= y_in
+ height
;
989 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
990 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
993 if(process_in
->state
->s
== LTTV_STATE_RUN
)
995 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
996 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
997 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
999 PropertiesBG prop_bg
;
1000 prop_bg
.color
= g_new(GdkColor
,1);
1002 switch(tfc
->index
) {
1004 prop_bg
.color
->red
= 0x1515;
1005 prop_bg
.color
->green
= 0x1515;
1006 prop_bg
.color
->blue
= 0x8c8c;
1009 prop_bg
.color
->red
= 0x4e4e;
1010 prop_bg
.color
->green
= 0xa9a9;
1011 prop_bg
.color
->blue
= 0xa4a4;
1014 prop_bg
.color
->red
= 0x7a7a;
1015 prop_bg
.color
->green
= 0x4a4a;
1016 prop_bg
.color
->blue
= 0x8b8b;
1019 prop_bg
.color
->red
= 0x8080;
1020 prop_bg
.color
->green
= 0x7777;
1021 prop_bg
.color
->blue
= 0x4747;
1024 prop_bg
.color
->red
= 0xe7e7;
1025 prop_bg
.color
->green
= 0xe7e7;
1026 prop_bg
.color
->blue
= 0xe7e7;
1030 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1031 g_free(prop_bg
.color
);
1032 //gdk_gc_unref(draw_context_in->gc);
1035 draw_context_in
->gc
= widget
->style
->black_gc
;
1037 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1038 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1039 PropertiesText prop_text_in
;
1040 prop_text_in
.foreground
= &colorfg_in
;
1041 prop_text_in
.background
= &colorbg_in
;
1042 prop_text_in
.size
= 6;
1043 prop_text_in
.position
= OVER
;
1045 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1046 /* foreground of text : status of the process */
1047 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1049 prop_text_in
.foreground
->red
= 0xffff;
1050 prop_text_in
.foreground
->green
= 0xffff;
1051 prop_text_in
.foreground
->blue
= 0xffff;
1053 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1055 prop_text_in
.foreground
->red
= 0x0fff;
1056 prop_text_in
.foreground
->green
= 0xffff;
1057 prop_text_in
.foreground
->blue
= 0xfff0;
1059 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1061 prop_text_in
.foreground
->red
= 0xffff;
1062 prop_text_in
.foreground
->green
= 0xffff;
1063 prop_text_in
.foreground
->blue
= 0x0000;
1065 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1067 prop_text_in
.foreground
->red
= 0xffff;
1068 prop_text_in
.foreground
->green
= 0x0000;
1069 prop_text_in
.foreground
->blue
= 0xffff;
1071 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1073 prop_text_in
.foreground
->red
= 0xffff;
1074 prop_text_in
.foreground
->green
= 0x0000;
1075 prop_text_in
.foreground
->blue
= 0x0000;
1077 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1079 prop_text_in
.foreground
->red
= 0x0000;
1080 prop_text_in
.foreground
->green
= 0xffff;
1081 prop_text_in
.foreground
->blue
= 0x0000;
1085 prop_text_in
.foreground
->red
= 0xffff;
1086 prop_text_in
.foreground
->green
= 0xffff;
1087 prop_text_in
.foreground
->blue
= 0xffff;
1092 /* Print status of the process : U, WF, WC, E, W, R */
1093 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1094 prop_text_in
.text
= "U->";
1095 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1096 prop_text_in
.text
= "WF->";
1097 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1098 prop_text_in
.text
= "WC->";
1099 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1100 prop_text_in
.text
= "E->";
1101 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1102 prop_text_in
.text
= "W->";
1103 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1104 prop_text_in
.text
= "R->";
1106 prop_text_in
.text
= "U";
1108 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1109 //gdk_gc_unref(draw_context_in->gc);
1111 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1112 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1113 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1115 PropertiesLine prop_line_in
;
1116 prop_line_in
.color
= g_new(GdkColor
,1);
1117 prop_line_in
.line_width
= 2;
1118 prop_line_in
.style
= GDK_LINE_SOLID
;
1119 prop_line_in
.position
= MIDDLE
;
1121 /* color of line : status of the process */
1122 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1124 prop_line_in
.color
->red
= 0xffff;
1125 prop_line_in
.color
->green
= 0xffff;
1126 prop_line_in
.color
->blue
= 0xffff;
1128 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1130 prop_line_in
.color
->red
= 0x0fff;
1131 prop_line_in
.color
->green
= 0xffff;
1132 prop_line_in
.color
->blue
= 0xfff0;
1134 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1136 prop_line_in
.color
->red
= 0xffff;
1137 prop_line_in
.color
->green
= 0xffff;
1138 prop_line_in
.color
->blue
= 0x0000;
1140 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1142 prop_line_in
.color
->red
= 0xffff;
1143 prop_line_in
.color
->green
= 0x0000;
1144 prop_line_in
.color
->blue
= 0xffff;
1146 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1148 prop_line_in
.color
->red
= 0xffff;
1149 prop_line_in
.color
->green
= 0x0000;
1150 prop_line_in
.color
->blue
= 0x0000;
1152 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1154 prop_line_in
.color
->red
= 0x0000;
1155 prop_line_in
.color
->green
= 0xffff;
1156 prop_line_in
.color
->blue
= 0x0000;
1160 prop_line_in
.color
->red
= 0xffff;
1161 prop_line_in
.color
->green
= 0xffff;
1162 prop_line_in
.color
->blue
= 0xffff;
1165 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1166 g_free(prop_line_in
.color
);
1167 //gdk_gc_unref(draw_context_in->gc);
1177 GString
*string
= g_string_new("");;
1178 gboolean field_names
= TRUE
, state
= TRUE
;
1180 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1181 g_string_append_printf(string
,"\n");
1184 g_string_append_printf(string
, " %s",
1185 g_quark_to_string(tfs
->process
->state
->s
));
1188 g_info("%s",string
->str
);
1190 g_string_free(string
, TRUE
);
1192 /* End of text dump */
1197 /* after_schedchange_hook
1199 * The draw after hook is called by the reading API to have a
1200 * particular event drawn on the screen.
1201 * @param hook_data ControlFlowData structure of the viewer.
1202 * @param call_data Event context.
1204 * This function adds items to be drawn in a queue for each process.
1207 int after_schedchange_hook(void *hook_data
, void *call_data
)
1209 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1210 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1212 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1214 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1215 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1220 LttTime evtime
= ltt_event_time(e
);
1221 TimeWindow time_window
=
1222 lttvwindow_get_time_window(control_flow_data
->tab
);
1224 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1225 time_window
.time_width
);
1227 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1228 || ltt_time_compare(evtime
, end_time
) == 1)
1231 guint width
= control_flow_data
->drawing
->width
;
1233 /* Add process to process list (if not present) */
1234 LttvProcessState
*process_out
, *process_in
;
1236 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1237 HashedProcessData
*hashed_process_data_in
= NULL
;
1239 ProcessList
*process_list
=
1240 guicontrolflow_get_process_list(control_flow_data
);
1245 LttField
*f
= ltt_event_field(e
);
1247 element
= ltt_field_member(f
,0);
1248 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1249 element
= ltt_field_member(f
,1);
1250 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1251 g_debug("out : %u in : %u", pid_out
, pid_in
);
1255 /* Find process pid_in in the list... */
1256 process_in
= lttv_state_find_process(tfs
, pid_in
);
1257 /* It should exist, because we are after the state update. */
1258 g_assert(process_in
!= NULL
);
1260 birth
= process_in
->creation_time
;
1261 const gchar
*name
= g_quark_to_string(process_in
->name
);
1263 if(processlist_get_process_pixels(process_list
,
1265 process_in
->last_cpu
,
1267 tfc
->t_context
->index
,
1270 &hashed_process_data_in
) == 1)
1272 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1273 /* Process not present */
1274 processlist_add(process_list
,
1276 process_in
->last_cpu
,
1279 tfc
->t_context
->index
,
1282 &hashed_process_data_in
);
1283 processlist_get_process_pixels(process_list
,
1285 process_in
->last_cpu
,
1287 tfc
->t_context
->index
,
1290 &hashed_process_data_in
);
1291 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1294 convert_time_to_pixels(
1295 time_window
.start_time
,
1299 &hashed_process_data_in
->x
.middle
);
1305 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1306 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1308 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1310 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1311 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1317 LttTime evtime
= ltt_event_time(e
);
1318 TimeWindow time_window
=
1319 lttvwindow_get_time_window(control_flow_data
->tab
);
1321 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1322 time_window
.time_width
);
1323 //if(time < time_beg || time > time_end) return;
1324 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1325 || ltt_time_compare(evtime
, end_time
) == 1)
1329 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1331 g_debug("schedchange!");
1333 /* Add process to process list (if not present) and get drawing "y" from
1334 * process position */
1335 guint pid_out
, pid_in
;
1336 LttvProcessState
*process_out
, *process_in
;
1338 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1340 ProcessList
*process_list
=
1341 guicontrolflow_get_process_list(control_flow_data
);
1344 LttField
*f
= ltt_event_field(e
);
1346 element
= ltt_field_member(f
,0);
1347 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1348 element
= ltt_field_member(f
,1);
1349 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1350 //g_debug("out : %u in : %u", pid_out, pid_in);
1353 /* Find process pid_out in the list... */
1354 process_out
= lttv_state_find_process(tfs
, pid_out
);
1355 if(process_out
== NULL
) return 0;
1356 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1358 birth
= process_out
->creation_time
;
1359 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1360 HashedProcessData
*hashed_process_data_out
= NULL
;
1362 if(processlist_get_process_pixels(process_list
,
1365 tfc
->t_context
->index
,
1368 &hashed_process_data_out
) == 1)
1370 /* Process not present */
1371 processlist_add(process_list
,
1374 tfc
->t_context
->index
,
1377 &hashed_process_data_out
);
1378 processlist_get_process_pixels(process_list
,
1381 tfc
->t_context
->index
,
1384 &hashed_process_data_out
);
1385 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1390 /* Find process pid_in in the list... */
1391 process_in
= lttv_state_find_process(tfs
, pid_in
);
1392 if(process_in
== NULL
) return 0;
1393 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1395 birth
= process_in
->creation_time
;
1396 name
= strdup(g_quark_to_string(process_in
->name
));
1397 HashedProcessData
*hashed_process_data_in
= NULL
;
1399 if(processlist_get_process_pixels(process_list
,
1402 tfc
->t_context
->index
,
1405 &hashed_process_data_in
) == 1)
1407 /* Process not present */
1408 processlist_add(process_list
,
1411 tfc
->t_context
->index
,
1414 &hashed_process_data_in
);
1415 processlist_get_process_pixels(process_list
,
1418 tfc
->t_context
->index
,
1421 &hashed_process_data_in
);
1423 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1428 /* Find pixels corresponding to time of the event. If the time does
1429 * not fit in the window, show a warning, not supposed to happend. */
1431 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1433 //LttTime time = ltt_event_time(e);
1435 //LttTime window_end = ltt_time_add(time_window->time_width,
1436 // time_window->start_time);
1439 //convert_time_to_pixels(
1440 // time_window->start_time,
1446 //assert(x <= width);
1448 /* draw what represents the event for outgoing process. */
1450 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1451 //draw_context_out->current->modify_over->x = x;
1452 draw_context_out
->current
->modify_over
->y
= y_out
;
1453 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1454 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1455 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1456 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1457 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1459 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1460 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1462 /*if(process_out->state->s == LTTV_STATE_RUN)
1464 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1465 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1466 PropertiesBG prop_bg;
1467 prop_bg.color = g_new(GdkColor,1);
1469 prop_bg.color->red = 0xffff;
1470 prop_bg.color->green = 0xffff;
1471 prop_bg.color->blue = 0xffff;
1473 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1474 g_free(prop_bg.color);
1475 gdk_gc_unref(draw_context_out->gc);
1478 draw_context_out
->gc
= widget
->style
->black_gc
;
1480 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1481 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1482 PropertiesText prop_text_out
;
1483 prop_text_out
.foreground
= &colorfg_out
;
1484 prop_text_out
.background
= &colorbg_out
;
1485 prop_text_out
.size
= 6;
1486 prop_text_out
.position
= OVER
;
1488 /* color of text : status of the process */
1489 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1491 prop_text_out
.foreground
->red
= 0xffff;
1492 prop_text_out
.foreground
->green
= 0xffff;
1493 prop_text_out
.foreground
->blue
= 0xffff;
1495 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1497 prop_text_out
.foreground
->red
= 0x0fff;
1498 prop_text_out
.foreground
->green
= 0xffff;
1499 prop_text_out
.foreground
->blue
= 0xfff0;
1501 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1503 prop_text_out
.foreground
->red
= 0xffff;
1504 prop_text_out
.foreground
->green
= 0xffff;
1505 prop_text_out
.foreground
->blue
= 0x0000;
1507 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1509 prop_text_out
.foreground
->red
= 0xffff;
1510 prop_text_out
.foreground
->green
= 0x0000;
1511 prop_text_out
.foreground
->blue
= 0xffff;
1513 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1515 prop_text_out
.foreground
->red
= 0xffff;
1516 prop_text_out
.foreground
->green
= 0x0000;
1517 prop_text_out
.foreground
->blue
= 0x0000;
1519 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1521 prop_text_out
.foreground
->red
= 0x0000;
1522 prop_text_out
.foreground
->green
= 0xffff;
1523 prop_text_out
.foreground
->blue
= 0x0000;
1527 prop_text_out
.foreground
->red
= 0xffff;
1528 prop_text_out
.foreground
->green
= 0xffff;
1529 prop_text_out
.foreground
->blue
= 0xffff;
1532 /* Print status of the process : U, WF, WC, E, W, R */
1533 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1534 prop_text_out
.text
= "U";
1535 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1536 prop_text_out
.text
= "WF";
1537 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1538 prop_text_out
.text
= "WC";
1539 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1540 prop_text_out
.text
= "E";
1541 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1542 prop_text_out
.text
= "W";
1543 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1544 prop_text_out
.text
= "R";
1546 prop_text_out
.text
= "U";
1548 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1550 //gdk_gc_unref(draw_context_out->gc);
1552 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1553 draw_context_out
->current
->over
->y
= y_out
;
1554 draw_context_out
->current
->under
->y
= y_out
+height
;
1555 draw_context_out
->current
->status
= process_out
->state
->s
;
1557 /* for pid_out : remove previous, Prev = current, new current (default) */
1558 g_free(draw_context_out
->previous
->modify_under
);
1559 g_free(draw_context_out
->previous
->modify_middle
);
1560 g_free(draw_context_out
->previous
->modify_over
);
1561 g_free(draw_context_out
->previous
->under
);
1562 g_free(draw_context_out
->previous
->middle
);
1563 g_free(draw_context_out
->previous
->over
);
1564 g_free(draw_context_out
->previous
);
1566 draw_context_out
->previous
= draw_context_out
->current
;
1568 draw_context_out
->current
= g_new(DrawInfo
,1);
1569 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1570 draw_context_out
->current
->over
->x
= -1;
1571 draw_context_out
->current
->over
->y
= -1;
1572 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1573 draw_context_out
->current
->middle
->x
= -1;
1574 draw_context_out
->current
->middle
->y
= -1;
1575 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1576 draw_context_out
->current
->under
->x
= -1;
1577 draw_context_out
->current
->under
->y
= -1;
1578 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1579 draw_context_out
->current
->modify_over
->x
= -1;
1580 draw_context_out
->current
->modify_over
->y
= -1;
1581 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1582 draw_context_out
->current
->modify_middle
->x
= -1;
1583 draw_context_out
->current
->modify_middle
->y
= -1;
1584 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1585 draw_context_out
->current
->modify_under
->x
= -1;
1586 draw_context_out
->current
->modify_under
->y
= -1;
1587 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1589 /* Finally, update the drawing context of the pid_in. */
1591 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1592 //draw_context_in->current->modify_over->x = x;
1593 draw_context_in
->current
->modify_over
->y
= y_in
;
1594 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1595 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1596 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1597 widget
= control_flow_data
->drawing
->drawing_area
;
1598 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1600 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1601 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1603 /*if(process_in->state->s == LTTV_STATE_RUN)
1605 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1606 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1607 PropertiesBG prop_bg;
1608 prop_bg.color = g_new(GdkColor,1);
1610 prop_bg.color->red = 0xffff;
1611 prop_bg.color->green = 0xffff;
1612 prop_bg.color->blue = 0xffff;
1614 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1615 g_free(prop_bg.color);
1616 gdk_gc_unref(draw_context_in->gc);
1619 draw_context_in
->gc
= widget
->style
->black_gc
;
1621 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1622 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1623 PropertiesText prop_text_in
;
1624 prop_text_in
.foreground
= &colorfg_in
;
1625 prop_text_in
.background
= &colorbg_in
;
1626 prop_text_in
.size
= 6;
1627 prop_text_in
.position
= OVER
;
1629 /* foreground of text : status of the process */
1630 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1632 prop_text_in
.foreground
->red
= 0xffff;
1633 prop_text_in
.foreground
->green
= 0xffff;
1634 prop_text_in
.foreground
->blue
= 0xffff;
1636 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1638 prop_text_in
.foreground
->red
= 0x0fff;
1639 prop_text_in
.foreground
->green
= 0xffff;
1640 prop_text_in
.foreground
->blue
= 0xfff0;
1642 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1644 prop_text_in
.foreground
->red
= 0xffff;
1645 prop_text_in
.foreground
->green
= 0xffff;
1646 prop_text_in
.foreground
->blue
= 0x0000;
1648 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1650 prop_text_in
.foreground
->red
= 0xffff;
1651 prop_text_in
.foreground
->green
= 0x0000;
1652 prop_text_in
.foreground
->blue
= 0xffff;
1654 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1656 prop_text_in
.foreground
->red
= 0xffff;
1657 prop_text_in
.foreground
->green
= 0x0000;
1658 prop_text_in
.foreground
->blue
= 0x0000;
1660 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1662 prop_text_in
.foreground
->red
= 0x0000;
1663 prop_text_in
.foreground
->green
= 0xffff;
1664 prop_text_in
.foreground
->blue
= 0x0000;
1668 prop_text_in
.foreground
->red
= 0xffff;
1669 prop_text_in
.foreground
->green
= 0xffff;
1670 prop_text_in
.foreground
->blue
= 0xffff;
1674 /* Print status of the process : U, WF, WC, E, W, R */
1675 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1676 prop_text_in
.text
= "U";
1677 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1678 prop_text_in
.text
= "WF";
1679 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1680 prop_text_in
.text
= "WC";
1681 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1682 prop_text_in
.text
= "E";
1683 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1684 prop_text_in
.text
= "W";
1685 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1686 prop_text_in
.text
= "R";
1688 prop_text_in
.text
= "U";
1690 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1693 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1696 prop_text_in
.foreground
= &colorfg_in
;
1697 prop_text_in
.background
= &colorbg_in
;
1698 prop_text_in
.foreground
->red
= 0xffff;
1699 prop_text_in
.foreground
->green
= 0xffff;
1700 prop_text_in
.foreground
->blue
= 0xffff;
1701 prop_text_in
.size
= 6;
1702 prop_text_in
.position
= UNDER
;
1704 prop_text_in
.text
= g_new(gchar
, 260);
1705 strcpy(prop_text_in
.text
, "CPU ");
1706 snprintf(tmp
, 255, "%u", tfc
->index
);
1707 strcat(prop_text_in
.text
, tmp
);
1709 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1710 g_free(prop_text_in
.text
);
1714 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1715 draw_context_in
->current
->over
->y
= y_in
;
1716 draw_context_in
->current
->under
->y
= y_in
+height
;
1717 draw_context_in
->current
->status
= process_in
->state
->s
;
1719 /* for pid_in : remove previous, Prev = current, new current (default) */
1720 g_free(draw_context_in
->previous
->modify_under
);
1721 g_free(draw_context_in
->previous
->modify_middle
);
1722 g_free(draw_context_in
->previous
->modify_over
);
1723 g_free(draw_context_in
->previous
->under
);
1724 g_free(draw_context_in
->previous
->middle
);
1725 g_free(draw_context_in
->previous
->over
);
1726 g_free(draw_context_in
->previous
);
1728 draw_context_in
->previous
= draw_context_in
->current
;
1730 draw_context_in
->current
= g_new(DrawInfo
,1);
1731 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1732 draw_context_in
->current
->over
->x
= -1;
1733 draw_context_in
->current
->over
->y
= -1;
1734 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1735 draw_context_in
->current
->middle
->x
= -1;
1736 draw_context_in
->current
->middle
->y
= -1;
1737 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1738 draw_context_in
->current
->under
->x
= -1;
1739 draw_context_in
->current
->under
->y
= -1;
1740 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1741 draw_context_in
->current
->modify_over
->x
= -1;
1742 draw_context_in
->current
->modify_over
->y
= -1;
1743 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1744 draw_context_in
->current
->modify_middle
->x
= -1;
1745 draw_context_in
->current
->modify_middle
->y
= -1;
1746 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1747 draw_context_in
->current
->modify_under
->x
= -1;
1748 draw_context_in
->current
->modify_under
->y
= -1;
1749 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1757 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1759 PropertiesLine prop_line
;
1760 prop_line
.line_width
= 1;
1761 prop_line
.style
= GDK_LINE_SOLID
;
1763 //GdkColormap *colormap = gdk_colormap_get_system();
1765 /* color of line : execution mode of the process */
1766 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1767 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1768 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1769 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1770 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1771 prop_line
.color
= drawing_colors
[COL_TRAP
];
1772 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1773 prop_line
.color
= drawing_colors
[COL_IRQ
];
1774 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1775 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1777 prop_line
.color
= drawing_colors
[COL_WHITE
];
1779 //gdk_colormap_alloc_color(colormap,
1790 /* before_execmode_hook
1792 * This function basically draw lines and icons. Two types of lines are drawn :
1793 * one small (3 pixels?) representing the state of the process and the second
1794 * type is thicker (10 pixels?) representing on which CPU a process is running
1795 * (and this only in running state).
1797 * Extremums of the lines :
1798 * x_min : time of the last event context for this process kept in memory.
1799 * x_max : time of the current event.
1800 * y : middle of the process in the process list. The process is found in the
1801 * list, therefore is it's position in pixels.
1803 * The choice of lines'color is defined by the context of the last event for this
1808 int before_execmode_hook(void *hook_data
, void *call_data
)
1810 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1811 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1812 Drawing_t
*drawing
= control_flow_data
->drawing
;
1814 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1816 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1817 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1822 LttTime evtime
= ltt_event_time(e
);
1823 TimeWindow time_window
=
1824 lttvwindow_get_time_window(control_flow_data
->tab
);
1826 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1827 time_window
.time_width
);
1829 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1830 || ltt_time_compare(evtime
, end_time
) == 1)
1833 guint width
= drawing
->width
;
1835 /* we are in a execmode, before the state update. We must draw the
1836 * items corresponding to the state before it changes : now is the right
1840 LttvProcessState
*process
= tfs
->process
;
1841 g_assert(process
!= NULL
);
1843 guint pid
= process
->pid
;
1845 /* Well, the process_out existed : we must get it in the process hash
1846 * or add it, and draw its items.
1848 /* Add process to process list (if not present) */
1849 guint y
= 0, height
= 0, pl_height
= 0;
1850 HashedProcessData
*hashed_process_data
= NULL
;
1851 ProcessList
*process_list
=
1852 guicontrolflow_get_process_list(control_flow_data
);
1853 LttTime birth
= process
->creation_time
;
1854 const gchar
*name
= g_quark_to_string(process
->name
);
1856 if(processlist_get_process_pixels(process_list
,
1860 tfc
->t_context
->index
,
1863 &hashed_process_data
) == 1)
1865 g_assert(pid
== 0 || pid
!= process
->ppid
);
1866 /* Process not present */
1867 processlist_add(process_list
,
1872 tfc
->t_context
->index
,
1875 &hashed_process_data
);
1876 processlist_get_process_pixels(process_list
,
1880 tfc
->t_context
->index
,
1883 &hashed_process_data
);
1884 drawing_insert_square( drawing
, y
, height
);
1887 /* Now, the process is in the state hash and our own process hash.
1888 * We definitely can draw the items related to the ending state.
1891 /* Check if the x position is unset. In can have been left unset by
1892 * a draw closure from a after chunk hook. This should never happen,
1893 * because it must be set by before chunk hook to the damage_begin
1896 g_assert(hashed_process_data
->x
.over
!= -1);
1899 DrawContext draw_context
;
1901 convert_time_to_pixels(
1902 time_window
.start_time
,
1908 /* Now create the drawing context that will be used to draw
1909 * items related to the last state. */
1910 draw_context
.drawable
= drawing
->pixmap
;
1911 draw_context
.gc
= drawing
->gc
;
1912 draw_context
.pango_layout
= drawing
->pango_layout
;
1913 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
1914 draw_context
.drawinfo
.end
.x
= x
;
1916 draw_context
.drawinfo
.y
.over
= y
+1;
1917 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
1918 draw_context
.drawinfo
.y
.under
= y
+height
;
1920 draw_context
.drawinfo
.start
.offset
.over
= 0;
1921 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1922 draw_context
.drawinfo
.start
.offset
.under
= 0;
1923 draw_context
.drawinfo
.end
.offset
.over
= 0;
1924 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1925 draw_context
.drawinfo
.end
.offset
.under
= 0;
1929 PropertiesLine prop_line
= prepare_execmode_line(process
);
1930 draw_line((void*)&prop_line
, (void*)&draw_context
);
1933 /* become the last x position */
1934 hashed_process_data
->x
.over
= x
;
1940 /* after_execmode_hook
1942 * The draw after hook is called by the reading API to have a
1943 * particular event drawn on the screen.
1944 * @param hook_data ControlFlowData structure of the viewer.
1945 * @param call_data Event context.
1947 * This function adds items to be drawn in a queue for each process.
1950 int after_execmode_hook(void *hook_data
, void *call_data
)
1952 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1953 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1955 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1957 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1958 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1963 LttTime evtime
= ltt_event_time(e
);
1964 TimeWindow time_window
=
1965 lttvwindow_get_time_window(control_flow_data
->tab
);
1967 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1968 time_window
.time_width
);
1970 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1971 || ltt_time_compare(evtime
, end_time
) == 1)
1974 guint width
= control_flow_data
->drawing
->width
;
1976 /* Add process to process list (if not present) */
1977 LttvProcessState
*process
;
1979 guint y
= 0, height
= 0, pl_height
= 0;
1980 HashedProcessData
*hashed_process_data
= NULL
;
1982 ProcessList
*process_list
=
1983 guicontrolflow_get_process_list(control_flow_data
);
1986 /* Find process pid_in in the list... */
1987 process
= tfs
->process
;
1988 /* It should exist, because we are after the state update. */
1989 g_assert(process
!= NULL
);
1991 guint pid
= process
->pid
;
1993 birth
= process
->creation_time
;
1994 const gchar
*name
= g_quark_to_string(process
->name
);
1996 if(processlist_get_process_pixels(process_list
,
2000 tfc
->t_context
->index
,
2003 &hashed_process_data
) == 1)
2005 g_assert(pid
== 0 || pid
!= process
->ppid
);
2006 /* Process not present */
2007 processlist_add(process_list
,
2012 tfc
->t_context
->index
,
2015 &hashed_process_data
);
2016 processlist_get_process_pixels(process_list
,
2020 tfc
->t_context
->index
,
2023 &hashed_process_data
);
2024 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2027 convert_time_to_pixels(
2028 time_window
.start_time
,
2032 &hashed_process_data
->x
.over
);
2038 /* before_process_hook
2040 * Draw lines for process event.
2042 * @param hook_data ControlFlowData structure of the viewer.
2043 * @param call_data Event context.
2045 * This function adds items to be drawn in a queue for each process.
2048 int before_process_hook(void *hook_data
, void *call_data
)
2050 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2051 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2052 Drawing_t
*drawing
= control_flow_data
->drawing
;
2054 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2056 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2057 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2062 LttTime evtime
= ltt_event_time(e
);
2063 TimeWindow time_window
=
2064 lttvwindow_get_time_window(control_flow_data
->tab
);
2066 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2067 time_window
.time_width
);
2069 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2070 || ltt_time_compare(evtime
, end_time
) == 1)
2073 guint width
= control_flow_data
->drawing
->width
;
2077 LttField
*f
= ltt_event_field(e
);
2079 element
= ltt_field_member(f
,0);
2080 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2083 if(sub_id
== 3) { /* exit */
2085 /* Add process to process list (if not present) */
2086 LttvProcessState
*process
= tfs
->process
;
2087 guint pid
= process
->pid
;
2089 guint y
= 0, height
= 0, pl_height
= 0;
2090 HashedProcessData
*hashed_process_data
= NULL
;
2092 ProcessList
*process_list
=
2093 guicontrolflow_get_process_list(control_flow_data
);
2095 g_assert(process
!= NULL
);
2097 birth
= process
->creation_time
;
2098 const gchar
*name
= g_quark_to_string(process
->name
);
2100 if(processlist_get_process_pixels(process_list
,
2104 tfc
->t_context
->index
,
2107 &hashed_process_data
) == 1)
2109 g_assert(pid
== 0 || pid
!= process
->ppid
);
2110 /* Process not present */
2111 processlist_add(process_list
,
2116 tfc
->t_context
->index
,
2119 &hashed_process_data
);
2120 processlist_get_process_pixels(process_list
,
2124 tfc
->t_context
->index
,
2127 &hashed_process_data
);
2128 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2131 /* Now, the process is in the state hash and our own process hash.
2132 * We definitely can draw the items related to the ending state.
2135 /* Check if the x position is unset. In can have been left unset by
2136 * a draw closure from a after chunk hook. This should never happen,
2137 * because it must be set by before chunk hook to the damage_begin
2140 g_assert(hashed_process_data
->x
.over
!= -1);
2143 DrawContext draw_context
;
2145 convert_time_to_pixels(
2146 time_window
.start_time
,
2152 /* Now create the drawing context that will be used to draw
2153 * items related to the last state. */
2154 draw_context
.drawable
= drawing
->pixmap
;
2155 draw_context
.gc
= drawing
->gc
;
2156 draw_context
.pango_layout
= drawing
->pango_layout
;
2157 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2158 draw_context
.drawinfo
.end
.x
= x
;
2160 draw_context
.drawinfo
.y
.over
= y
+1;
2161 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2162 draw_context
.drawinfo
.y
.under
= y
+height
;
2164 draw_context
.drawinfo
.start
.offset
.over
= 0;
2165 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2166 draw_context
.drawinfo
.start
.offset
.under
= 0;
2167 draw_context
.drawinfo
.end
.offset
.over
= 0;
2168 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2169 draw_context
.drawinfo
.end
.offset
.under
= 0;
2173 PropertiesLine prop_line
= prepare_status_line(process
);
2174 draw_line((void*)&prop_line
, (void*)&draw_context
);
2177 /* become the last x position */
2178 hashed_process_data
->x
.middle
= x
;
2191 /* after_process_hook
2193 * Create the processlist entry for the child process. Put the last
2194 * position in x at the current time value.
2196 * @param hook_data ControlFlowData structure of the viewer.
2197 * @param call_data Event context.
2199 * This function adds items to be drawn in a queue for each process.
2202 int after_process_hook(void *hook_data
, void *call_data
)
2204 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2205 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2207 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2209 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2210 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2215 LttTime evtime
= ltt_event_time(e
);
2216 TimeWindow time_window
=
2217 lttvwindow_get_time_window(control_flow_data
->tab
);
2219 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2220 time_window
.time_width
);
2222 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2223 || ltt_time_compare(evtime
, end_time
) == 1)
2226 guint width
= control_flow_data
->drawing
->width
;
2231 LttField
*f
= ltt_event_field(e
);
2233 element
= ltt_field_member(f
,0);
2234 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2235 element
= ltt_field_member(f
,1);
2236 param1
= ltt_event_get_long_unsigned(e
,element
);
2239 if(sub_id
== 2) { /* fork */
2241 guint child_pid
= param1
;
2242 /* Add process to process list (if not present) */
2243 LttvProcessState
*process_child
;
2245 guint y_child
= 0, height
= 0, pl_height
= 0;
2246 HashedProcessData
*hashed_process_data_child
= NULL
;
2248 ProcessList
*process_list
=
2249 guicontrolflow_get_process_list(control_flow_data
);
2252 /* Find child in the list... */
2253 process_child
= lttv_state_find_process(tfs
, child_pid
);
2254 /* It should exist, because we are after the state update. */
2255 g_assert(process_child
!= NULL
);
2257 birth
= process_child
->creation_time
;
2258 const gchar
*name
= g_quark_to_string(process_child
->name
);
2260 if(processlist_get_process_pixels(process_list
,
2262 process_child
->last_cpu
,
2264 tfc
->t_context
->index
,
2267 &hashed_process_data_child
) == 1)
2269 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2270 /* Process not present */
2271 processlist_add(process_list
,
2273 process_child
->last_cpu
,
2274 process_child
->ppid
,
2276 tfc
->t_context
->index
,
2279 &hashed_process_data_child
);
2280 processlist_get_process_pixels(process_list
,
2282 process_child
->last_cpu
,
2284 tfc
->t_context
->index
,
2287 &hashed_process_data_child
);
2288 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2292 convert_time_to_pixels(
2293 time_window
.start_time
,
2298 hashed_process_data_child
->x
.over
= new_x
;
2299 hashed_process_data_child
->x
.middle
= new_x
;
2300 hashed_process_data_child
->x
.under
= new_x
;
2302 } else if(sub_id
== 3) { /* exit */
2304 /* Add process to process list (if not present) */
2305 LttvProcessState
*process
= tfs
->process
;
2306 guint pid
= process
->pid
;
2308 guint y
= 0, height
= 0, pl_height
= 0;
2309 HashedProcessData
*hashed_process_data
= NULL
;
2311 ProcessList
*process_list
=
2312 guicontrolflow_get_process_list(control_flow_data
);
2315 /* It should exist, because we are after the state update. */
2316 g_assert(process
!= NULL
);
2318 birth
= process
->creation_time
;
2319 const gchar
*name
= g_quark_to_string(process
->name
);
2321 if(processlist_get_process_pixels(process_list
,
2325 tfc
->t_context
->index
,
2328 &hashed_process_data
) == 1)
2330 g_assert(pid
== 0 || pid
!= process
->ppid
);
2331 /* Process not present */
2332 processlist_add(process_list
,
2337 tfc
->t_context
->index
,
2340 &hashed_process_data
);
2341 processlist_get_process_pixels(process_list
,
2345 tfc
->t_context
->index
,
2348 &hashed_process_data
);
2349 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2353 convert_time_to_pixels(
2354 time_window
.start_time
,
2359 hashed_process_data
->x
.middle
= new_x
;
2366 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2368 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2369 Drawing_t
*drawing
= control_flow_data
->drawing
;
2371 const TimeWindowNotifyData
*time_window_nofify_data
=
2372 ((const TimeWindowNotifyData
*)call_data
);
2374 TimeWindow
*old_time_window
=
2375 time_window_nofify_data
->old_time_window
;
2376 TimeWindow
*new_time_window
=
2377 time_window_nofify_data
->new_time_window
;
2379 /* Update the ruler */
2380 drawing_update_ruler(control_flow_data
->drawing
,
2384 /* Two cases : zoom in/out or scrolling */
2386 /* In order to make sure we can reuse the old drawing, the scale must
2387 * be the same and the new time interval being partly located in the
2388 * currently shown time interval. (reuse is only for scrolling)
2391 g_info("Old time window HOOK : %u, %u to %u, %u",
2392 old_time_window
->start_time
.tv_sec
,
2393 old_time_window
->start_time
.tv_nsec
,
2394 old_time_window
->time_width
.tv_sec
,
2395 old_time_window
->time_width
.tv_nsec
);
2397 g_info("New time window HOOK : %u, %u to %u, %u",
2398 new_time_window
->start_time
.tv_sec
,
2399 new_time_window
->start_time
.tv_nsec
,
2400 new_time_window
->time_width
.tv_sec
,
2401 new_time_window
->time_width
.tv_nsec
);
2403 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2404 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2406 /* Same scale (scrolling) */
2407 g_info("scrolling");
2408 LttTime
*ns
= &new_time_window
->start_time
;
2409 LttTime
*os
= &old_time_window
->start_time
;
2410 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
2411 old_time_window
->time_width
);
2412 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
2413 new_time_window
->time_width
);
2415 //if(ns<os+w && os+w<ns+w)
2416 //if(ns<old_end && os<ns)
2417 if(ltt_time_compare(*ns
, old_end
) == -1
2418 && ltt_time_compare(*os
, *ns
) == -1)
2420 g_info("scrolling near right");
2421 /* Scroll right, keep right part of the screen */
2423 guint width
= control_flow_data
->drawing
->width
;
2424 convert_time_to_pixels(
2431 /* Copy old data to new location */
2432 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2433 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2434 control_flow_data
->drawing
->pixmap
,
2437 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2439 if(drawing
->damage_begin
== drawing
->damage_end
)
2440 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2442 drawing
->damage_begin
= 0;
2444 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2446 /* Clear the data request background, but not SAFETY */
2447 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2448 //control_flow_data->drawing->drawing_area->style->black_gc,
2449 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2451 drawing
->damage_begin
+SAFETY
, 0,
2452 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2453 control_flow_data
->drawing
->height
);
2455 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2457 control_flow_data
->drawing
->width
,
2458 control_flow_data
->drawing
->height
);
2460 /* Get new data for the rest. */
2461 drawing_data_request(control_flow_data
->drawing
,
2462 &control_flow_data
->drawing
->pixmap
,
2463 drawing
->damage_begin
, 0,
2464 drawing
->damage_end
- drawing
->damage_begin
,
2465 control_flow_data
->drawing
->height
);
2468 //if(ns<os && os<ns+w)
2469 //if(ns<os && os<new_end)
2470 if(ltt_time_compare(*ns
,*os
) == -1
2471 && ltt_time_compare(*os
,new_end
) == -1)
2473 g_info("scrolling near left");
2474 /* Scroll left, keep left part of the screen */
2476 guint width
= control_flow_data
->drawing
->width
;
2477 convert_time_to_pixels(
2485 /* Copy old data to new location */
2486 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2487 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2488 control_flow_data
->drawing
->pixmap
,
2493 if(drawing
->damage_begin
== drawing
->damage_end
)
2494 drawing
->damage_end
= x
;
2496 drawing
->damage_end
=
2497 control_flow_data
->drawing
->width
;
2499 drawing
->damage_begin
= 0;
2501 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2502 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2504 drawing
->damage_begin
, 0,
2505 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2506 control_flow_data
->drawing
->height
);
2508 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2510 control_flow_data
->drawing
->width
,
2511 control_flow_data
->drawing
->height
);
2514 /* Get new data for the rest. */
2515 drawing_data_request(control_flow_data
->drawing
,
2516 &control_flow_data
->drawing
->pixmap
,
2517 drawing
->damage_begin
, 0,
2518 drawing
->damage_end
- drawing
->damage_begin
,
2519 control_flow_data
->drawing
->height
);
2522 if(ltt_time_compare(*ns
,*os
) == 0)
2524 g_info("not scrolling");
2526 g_info("scrolling far");
2527 /* Cannot reuse any part of the screen : far jump */
2530 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2531 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2534 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2535 control_flow_data
->drawing
->height
);
2537 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2539 control_flow_data
->drawing
->width
,
2540 control_flow_data
->drawing
->height
);
2542 drawing
->damage_begin
= 0;
2543 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2545 drawing_data_request(control_flow_data
->drawing
,
2546 &control_flow_data
->drawing
->pixmap
,
2548 control_flow_data
->drawing
->width
,
2549 control_flow_data
->drawing
->height
);
2555 /* Different scale (zoom) */
2558 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2559 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2562 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2563 control_flow_data
->drawing
->height
);
2565 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2567 control_flow_data
->drawing
->width
,
2568 control_flow_data
->drawing
->height
);
2570 drawing
->damage_begin
= 0;
2571 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2573 drawing_data_request(control_flow_data
->drawing
,
2574 &control_flow_data
->drawing
->pixmap
,
2576 control_flow_data
->drawing
->width
,
2577 control_flow_data
->drawing
->height
);
2585 gint
traceset_notify(void *hook_data
, void *call_data
)
2587 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2588 Drawing_t
*drawing
= control_flow_data
->drawing
;
2589 GtkWidget
*widget
= drawing
->drawing_area
;
2592 drawing_clear(control_flow_data
->drawing
);
2593 processlist_clear(control_flow_data
->process_list
);
2594 redraw_notify(control_flow_data
, NULL
);
2596 request_background_data(control_flow_data
);
2598 drawing
->damage_begin
= 0;
2599 drawing
->damage_end
= drawing
->width
;
2600 if(drawing
->damage_begin
< drawing
->damage_end
)
2602 drawing_data_request(drawing
,
2604 drawing
->damage_begin
,
2606 drawing
->damage_end
-drawing
->damage_begin
,
2610 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2619 gint
redraw_notify(void *hook_data
, void *call_data
)
2621 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2622 Drawing_t
*drawing
= control_flow_data
->drawing
;
2623 GtkWidget
*widget
= drawing
->drawing_area
;
2625 drawing
->damage_begin
= 0;
2626 drawing
->damage_end
= drawing
->width
;
2628 /* fun feature, to be separated someday... */
2629 drawing_clear(control_flow_data
->drawing
);
2630 processlist_clear(control_flow_data
->process_list
);
2633 gdk_draw_rectangle (drawing
->pixmap
,
2634 widget
->style
->black_gc
,
2637 drawing
->width
+SAFETY
,
2641 if(drawing
->damage_begin
< drawing
->damage_end
)
2643 drawing_data_request(drawing
,
2645 drawing
->damage_begin
,
2647 drawing
->damage_end
-drawing
->damage_begin
,
2651 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2660 gint
continue_notify(void *hook_data
, void *call_data
)
2662 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2663 Drawing_t
*drawing
= control_flow_data
->drawing
;
2664 GtkWidget
*widget
= drawing
->drawing_area
;
2666 //g_assert(widget->allocation.width == drawing->damage_end);
2668 if(drawing
->damage_begin
< drawing
->damage_end
)
2670 drawing_data_request(drawing
,
2672 drawing
->damage_begin
,
2674 drawing
->damage_end
-drawing
->damage_begin
,
2682 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2684 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2685 Drawing_t
*drawing
= control_flow_data
->drawing
;
2687 LttTime current_time
= *((LttTime
*)call_data
);
2689 TimeWindow time_window
=
2690 lttvwindow_get_time_window(control_flow_data
->tab
);
2692 LttTime time_begin
= time_window
.start_time
;
2693 LttTime width
= time_window
.time_width
;
2696 guint64 time_ll
= ltt_time_to_uint64(width
);
2697 time_ll
= time_ll
>> 1; /* divide by two */
2698 half_width
= ltt_time_from_uint64(time_ll
);
2700 LttTime time_end
= ltt_time_add(time_begin
, width
);
2702 LttvTracesetContext
* tsc
=
2703 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2705 LttTime trace_start
= tsc
->time_span
.start_time
;
2706 LttTime trace_end
= tsc
->time_span
.end_time
;
2708 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2709 current_time
.tv_nsec
);
2713 /* If current time is inside time interval, just move the highlight
2716 /* Else, we have to change the time interval. We have to tell it
2717 * to the main window. */
2718 /* The time interval change will take care of placing the current
2719 * time at the center of the visible area, or nearest possible if we are
2720 * at one end of the trace. */
2723 if(ltt_time_compare(current_time
, time_begin
) == -1)
2725 TimeWindow new_time_window
;
2727 if(ltt_time_compare(current_time
,
2728 ltt_time_add(trace_start
,half_width
)) == -1)
2729 time_begin
= trace_start
;
2731 time_begin
= ltt_time_sub(current_time
,half_width
);
2733 new_time_window
.start_time
= time_begin
;
2734 new_time_window
.time_width
= width
;
2736 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2738 else if(ltt_time_compare(current_time
, time_end
) == 1)
2740 TimeWindow new_time_window
;
2742 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2743 time_begin
= ltt_time_sub(trace_end
,width
);
2745 time_begin
= ltt_time_sub(current_time
,half_width
);
2747 new_time_window
.start_time
= time_begin
;
2748 new_time_window
.time_width
= width
;
2750 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2753 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2754 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2762 typedef struct _ClosureData
{
2763 EventsRequest
*events_request
;
2764 LttvTracesetState
*tss
;
2769 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2771 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2772 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2773 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2775 EventsRequest
*events_request
= closure_data
->events_request
;
2776 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2777 Drawing_t
*drawing
= control_flow_data
->drawing
;
2779 LttvTracesetState
*tss
= closure_data
->tss
;
2780 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2782 LttTime evtime
= closure_data
->end_time
;
2783 TimeWindow time_window
=
2784 lttvwindow_get_time_window(control_flow_data
->tab
);
2786 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2787 time_window
.time_width
);
2789 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2790 || ltt_time_compare(evtime
, end_time
) == 1)
2793 guint width
= drawing
->width
;
2796 /* For the process */
2797 /* First, check if the current process is in the state computation
2798 * process list. If it is there, that means we must add it right now and
2799 * draw items from the beginning of the read for it. If it is not
2800 * present, it's a new process and it was not present : it will
2801 * be added after the state update. */
2802 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2804 /* tracefiles[0] is ok here, because we draw for every PID, and
2805 * assume CPU 0 for PID 0 //FIXME */
2806 LttvTracefileState
*tfs
=
2807 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2809 LttvProcessState
*process
;
2810 process
= lttv_state_find_process(tfs
,
2813 if(process
!= NULL
) {
2815 /* Only draw for processes that are currently in the trace states */
2817 guint y
= 0, height
= 0, pl_height
= 0;
2818 ProcessList
*process_list
=
2819 guicontrolflow_get_process_list(control_flow_data
);
2820 LttTime birth
= process_info
->birth
;
2822 /* Should be alike when background info is ready */
2823 if(control_flow_data
->background_info_waiting
==0)
2824 g_assert(ltt_time_compare(process
->creation_time
,
2825 process_info
->birth
) == 0);
2826 const gchar
*name
= g_quark_to_string(process
->name
);
2828 /* process HAS to be present */
2829 g_assert(processlist_get_process_pixels(process_list
,
2833 process_info
->trace_num
,
2836 &hashed_process_data
) != 1);
2838 /* Now, the process is in the state hash and our own process hash.
2839 * We definitely can draw the items related to the ending state.
2842 /* Check if the x position is unset. In can have been left unset by
2843 * a draw closure from a after chunk hook. This should never happen,
2844 * because it must be set by before chunk hook to the damage_begin
2847 g_assert(hashed_process_data
->x
.over
!= -1);
2850 DrawContext draw_context
;
2852 convert_time_to_pixels(
2853 time_window
.start_time
,
2859 /* Now create the drawing context that will be used to draw
2860 * items related to the last state. */
2861 draw_context
.drawable
= drawing
->pixmap
;
2862 draw_context
.gc
= drawing
->gc
;
2863 draw_context
.pango_layout
= drawing
->pango_layout
;
2864 draw_context
.drawinfo
.end
.x
= x
;
2866 draw_context
.drawinfo
.y
.over
= y
+1;
2867 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2868 draw_context
.drawinfo
.y
.under
= y
+height
;
2870 draw_context
.drawinfo
.start
.offset
.over
= 0;
2871 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2872 draw_context
.drawinfo
.start
.offset
.under
= 0;
2873 draw_context
.drawinfo
.end
.offset
.over
= 0;
2874 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2875 draw_context
.drawinfo
.end
.offset
.under
= 0;
2878 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
2880 PropertiesLine prop_line
= prepare_execmode_line(process
);
2881 draw_line((void*)&prop_line
, (void*)&draw_context
);
2884 hashed_process_data
->x
.over
= x
;
2886 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2888 PropertiesLine prop_line
= prepare_status_line(process
);
2889 draw_line((void*)&prop_line
, (void*)&draw_context
);
2893 /* become the last x position */
2894 hashed_process_data
->x
.middle
= x
;
2901 int before_chunk(void *hook_data
, void *call_data
)
2903 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2904 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2906 drawing_chunk_begin(events_request
, tss
);
2911 int before_request(void *hook_data
, void *call_data
)
2913 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2914 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2916 drawing_data_request_begin(events_request
, tss
);
2923 * after request is necessary in addition of after chunk in order to draw
2924 * lines until the end of the screen. after chunk just draws lines until
2931 int after_request(void *hook_data
, void *call_data
)
2933 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2934 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2935 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2936 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2938 ProcessList
*process_list
=
2939 guicontrolflow_get_process_list(control_flow_data
);
2940 LttTime end_time
= events_request
->end_time
;
2942 ClosureData closure_data
;
2943 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2944 closure_data
.tss
= tss
;
2945 closure_data
.end_time
= end_time
;
2947 /* Draw last items */
2948 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2949 (void*)&closure_data
);
2951 /* Request expose */
2952 drawing_request_expose(events_request
, tss
, end_time
);
2961 int after_chunk(void *hook_data
, void *call_data
)
2963 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2964 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2965 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2966 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2967 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
2970 ProcessList
*process_list
=
2971 guicontrolflow_get_process_list(control_flow_data
);
2974 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
2975 else /* end of traceset, or position now out of request : end */
2976 end_time
= events_request
->end_time
;
2978 ClosureData closure_data
;
2979 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2980 closure_data
.tss
= tss
;
2981 closure_data
.end_time
= end_time
;
2983 /* Draw last items */
2984 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2985 (void*)&closure_data
);
2987 /* Request expose */
2988 drawing_request_expose(events_request
, tss
, end_time
);