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 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0) {
356 /* we are in a schedchange, before the state update. We must draw the
357 * items corresponding to the state before it changes : now is the right
364 LttField
*f
= ltt_event_field(e
);
366 element
= ltt_field_member(f
,0);
367 pid_out
= ltt_event_get_long_unsigned(e
,element
);
368 element
= ltt_field_member(f
,1);
369 pid_in
= ltt_event_get_long_unsigned(e
,element
);
370 g_debug("out : %u in : %u", pid_out
, pid_in
);
374 /* For the pid_out */
375 /* First, check if the current process is in the state computation
376 * process list. If it is there, that means we must add it right now and
377 * draw items from the beginning of the read for it. If it is not
378 * present, it's a new process and it was not present : it will
379 * be added after the state update. */
380 LttvProcessState
*process
;
381 process
= lttv_state_find_process(tfs
, pid_out
);
383 if(process
!= NULL
) {
384 /* Well, the process_out existed : we must get it in the process hash
385 * or add it, and draw its items.
387 /* Add process to process list (if not present) */
388 guint y
= 0, height
= 0, pl_height
= 0;
389 HashedProcessData
*hashed_process_data
= NULL
;
390 ProcessList
*process_list
=
391 guicontrolflow_get_process_list(control_flow_data
);
392 LttTime birth
= process
->creation_time
;
393 const gchar
*name
= g_quark_to_string(process
->name
);
395 if(processlist_get_process_pixels(process_list
,
399 tfc
->t_context
->index
,
402 &hashed_process_data
) == 1)
404 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
405 /* Process not present */
406 processlist_add(process_list
,
411 tfc
->t_context
->index
,
414 &hashed_process_data
);
415 processlist_get_process_pixels(process_list
,
419 tfc
->t_context
->index
,
422 &hashed_process_data
);
423 drawing_insert_square( drawing
, y
, height
);
426 /* Now, the process is in the state hash and our own process hash.
427 * We definitely can draw the items related to the ending state.
430 /* Check if the x position is unset. In can have been left unset by
431 * a draw closure from a after chunk hook. This should never happen,
432 * because it must be set by before chunk hook to the damage_begin
435 g_assert(hashed_process_data
->x
.middle
!= -1);
438 DrawContext draw_context
;
440 convert_time_to_pixels(
441 time_window
.start_time
,
447 /* Now create the drawing context that will be used to draw
448 * items related to the last state. */
449 draw_context
.drawable
= drawing
->pixmap
;
450 draw_context
.gc
= drawing
->gc
;
451 draw_context
.pango_layout
= drawing
->pango_layout
;
452 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
453 draw_context
.drawinfo
.end
.x
= x
;
455 draw_context
.drawinfo
.y
.over
= y
+1;
456 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
457 draw_context
.drawinfo
.y
.under
= y
+height
;
459 draw_context
.drawinfo
.start
.offset
.over
= 0;
460 draw_context
.drawinfo
.start
.offset
.middle
= 0;
461 draw_context
.drawinfo
.start
.offset
.under
= 0;
462 draw_context
.drawinfo
.end
.offset
.over
= 0;
463 draw_context
.drawinfo
.end
.offset
.middle
= 0;
464 draw_context
.drawinfo
.end
.offset
.under
= 0;
468 PropertiesLine prop_line
= prepare_status_line(process
);
469 draw_line((void*)&prop_line
, (void*)&draw_context
);
472 /* become the last x position */
473 hashed_process_data
->x
.middle
= x
;
480 /* First, check if the current process is in the state computation
481 * process list. If it is there, that means we must add it right now and
482 * draw items from the beginning of the read for it. If it is not
483 * present, it's a new process and it was not present : it will
484 * be added after the state update. */
485 LttvProcessState
*process
;
486 process
= lttv_state_find_process(tfs
, pid_in
);
488 if(process
!= NULL
) {
489 /* Well, the process_out existed : we must get it in the process hash
490 * or add it, and draw its items.
492 /* Add process to process list (if not present) */
493 guint y
= 0, height
= 0, pl_height
= 0;
494 HashedProcessData
*hashed_process_data
= NULL
;
495 ProcessList
*process_list
=
496 guicontrolflow_get_process_list(control_flow_data
);
497 LttTime birth
= process
->creation_time
;
498 const gchar
*name
= g_quark_to_string(process
->name
);
500 if(processlist_get_process_pixels(process_list
,
504 tfc
->t_context
->index
,
507 &hashed_process_data
) == 1)
509 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
510 /* Process not present */
511 processlist_add(process_list
,
516 tfc
->t_context
->index
,
519 &hashed_process_data
);
520 processlist_get_process_pixels(process_list
,
524 tfc
->t_context
->index
,
527 &hashed_process_data
);
528 drawing_insert_square( drawing
, y
, height
);
531 /* Now, the process is in the state hash and our own process hash.
532 * We definitely can draw the items related to the ending state.
535 /* Check if the x position is unset. In can have been left unset by
536 * a draw closure from a after chunk hook. This should never happen,
537 * because it must be set by before chunk hook to the damage_begin
540 g_assert(hashed_process_data
->x
.middle
!= -1);
543 DrawContext draw_context
;
545 convert_time_to_pixels(
546 time_window
.start_time
,
552 /* Now create the drawing context that will be used to draw
553 * items related to the last state. */
554 draw_context
.drawable
= drawing
->pixmap
;
555 draw_context
.gc
= drawing
->gc
;
556 draw_context
.pango_layout
= drawing
->pango_layout
;
557 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
558 draw_context
.drawinfo
.end
.x
= x
;
560 draw_context
.drawinfo
.y
.over
= y
+1;
561 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
562 draw_context
.drawinfo
.y
.under
= y
+height
;
564 draw_context
.drawinfo
.start
.offset
.over
= 0;
565 draw_context
.drawinfo
.start
.offset
.middle
= 0;
566 draw_context
.drawinfo
.start
.offset
.under
= 0;
567 draw_context
.drawinfo
.end
.offset
.over
= 0;
568 draw_context
.drawinfo
.end
.offset
.middle
= 0;
569 draw_context
.drawinfo
.end
.offset
.under
= 0;
573 PropertiesLine prop_line
= prepare_status_line(process
);
574 draw_line((void*)&prop_line
, (void*)&draw_context
);
578 /* become the last x position */
579 hashed_process_data
->x
.middle
= x
;
588 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
589 ControlFlowData
*control_flow_data
=
590 (ControlFlowData
*)events_request
->viewer_data
;
591 Tab
*tab
= control_flow_data
->tab
;
593 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
595 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
596 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
601 LttTime evtime
= ltt_event_time(e
);
602 TimeWindow time_window
=
603 lttvwindow_get_time_window(tab
);
605 LttTime end_time
= ltt_time_add(time_window
.start_time
,
606 time_window
.time_width
);
607 //if(time < time_beg || time > time_end) return;
608 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
609 || ltt_time_compare(evtime
, end_time
) == 1)
612 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
614 g_debug("schedchange!");
616 /* Add process to process list (if not present) and get drawing "y" from
617 * process position */
618 guint pid_out
, pid_in
;
619 LttvProcessState
*process_out
, *process_in
;
621 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
623 ProcessList
*process_list
=
624 guicontrolflow_get_process_list(control_flow_data
);
627 LttField
*f
= ltt_event_field(e
);
629 element
= ltt_field_member(f
,0);
630 pid_out
= ltt_event_get_long_unsigned(e
,element
);
631 element
= ltt_field_member(f
,1);
632 pid_in
= ltt_event_get_long_unsigned(e
,element
);
633 g_debug("out : %u in : %u", pid_out
, pid_in
);
636 /* Find process pid_out in the list... */
637 process_out
= lttv_state_find_process(tfs
, pid_out
);
638 if(process_out
== NULL
) return 0;
639 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
641 birth
= process_out
->creation_time
;
642 const gchar
*name
= g_quark_to_string(process_out
->name
);
643 HashedProcessData
*hashed_process_data_out
= NULL
;
645 if(processlist_get_process_pixels(process_list
,
648 tfc
->t_context
->index
,
651 &hashed_process_data_out
) == 1)
653 /* Process not present */
654 processlist_add(process_list
,
657 tfc
->t_context
->index
,
660 &hashed_process_data_out
);
661 g_assert(processlist_get_process_pixels(process_list
,
664 tfc
->t_context
->index
,
667 &hashed_process_data_out
)==0);
668 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
672 /* Find process pid_in in the list... */
673 process_in
= lttv_state_find_process(tfs
, pid_in
);
674 if(process_in
== NULL
) return 0;
675 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
677 birth
= process_in
->creation_time
;
678 name
= g_quark_to_string(process_in
->name
);
679 HashedProcessData
*hashed_process_data_in
= NULL
;
681 if(processlist_get_process_pixels(process_list
,
684 tfc
->t_context
->index
,
687 &hashed_process_data_in
) == 1)
689 /* Process not present */
690 processlist_add(process_list
,
693 tfc
->t_context
->index
,
696 &hashed_process_data_in
);
697 processlist_get_process_pixels(process_list
,
700 tfc
->t_context
->index
,
703 &hashed_process_data_in
);
705 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
710 /* Find pixels corresponding to time of the event. If the time does
711 * not fit in the window, show a warning, not supposed to happend. */
713 guint width
= control_flow_data
->drawing
->width
;
715 LttTime time
= ltt_event_time(e
);
717 LttTime window_end
= ltt_time_add(time_window
.time_width
,
718 time_window
.start_time
);
721 convert_time_to_pixels(
722 time_window
.start_time
,
727 //assert(x <= width);
729 /* draw what represents the event for outgoing process. */
731 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
732 draw_context_out
->current
->modify_over
->x
= x
;
733 draw_context_out
->current
->modify_under
->x
= x
;
734 draw_context_out
->current
->modify_over
->y
= y_out
;
735 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
736 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
737 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
738 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
739 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
740 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
741 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
742 //draw_context_out->gc = widget->style->black_gc;
744 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
745 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
747 /* Draw the line/background of the out process */
748 if(draw_context_out
->previous
->middle
->x
== -1)
750 draw_context_out
->previous
->over
->x
=
751 control_flow_data
->drawing
->damage_begin
;
752 draw_context_out
->previous
->middle
->x
=
753 control_flow_data
->drawing
->damage_begin
;
754 draw_context_out
->previous
->under
->x
=
755 control_flow_data
->drawing
->damage_begin
;
757 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
760 draw_context_out
->current
->middle
->x
= x
;
761 draw_context_out
->current
->over
->x
= x
;
762 draw_context_out
->current
->under
->x
= x
;
763 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
764 draw_context_out
->current
->over
->y
= y_out
;
765 draw_context_out
->current
->under
->y
= y_out
+ height
;
766 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
767 draw_context_out
->previous
->over
->y
= y_out
;
768 draw_context_out
->previous
->under
->y
= y_out
+ height
;
770 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
771 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
773 if(process_out
->state
->s
== LTTV_STATE_RUN
)
775 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
776 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
777 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
779 PropertiesBG prop_bg
;
780 prop_bg
.color
= g_new(GdkColor
,1);
784 prop_bg
.color
->red
= 0x1515;
785 prop_bg
.color
->green
= 0x1515;
786 prop_bg
.color
->blue
= 0x8c8c;
789 prop_bg
.color
->red
= 0x4e4e;
790 prop_bg
.color
->green
= 0xa9a9;
791 prop_bg
.color
->blue
= 0xa4a4;
794 prop_bg
.color
->red
= 0x7a7a;
795 prop_bg
.color
->green
= 0x4a4a;
796 prop_bg
.color
->blue
= 0x8b8b;
799 prop_bg
.color
->red
= 0x8080;
800 prop_bg
.color
->green
= 0x7777;
801 prop_bg
.color
->blue
= 0x4747;
804 prop_bg
.color
->red
= 0xe7e7;
805 prop_bg
.color
->green
= 0xe7e7;
806 prop_bg
.color
->blue
= 0xe7e7;
809 g_debug("calling from draw_event");
810 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
811 g_free(prop_bg
.color
);
812 //gdk_gc_unref(draw_context_out->gc);
815 draw_context_out
->gc
= widget
->style
->black_gc
;
817 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
818 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
819 PropertiesText prop_text_out
;
820 prop_text_out
.foreground
= &colorfg_out
;
821 prop_text_out
.background
= &colorbg_out
;
822 prop_text_out
.size
= 6;
823 prop_text_out
.position
= OVER
;
825 /* color of text : status of the process */
826 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
828 prop_text_out
.foreground
->red
= 0xffff;
829 prop_text_out
.foreground
->green
= 0xffff;
830 prop_text_out
.foreground
->blue
= 0xffff;
832 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
834 prop_text_out
.foreground
->red
= 0x0fff;
835 prop_text_out
.foreground
->green
= 0xffff;
836 prop_text_out
.foreground
->blue
= 0xfff0;
838 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
840 prop_text_out
.foreground
->red
= 0xffff;
841 prop_text_out
.foreground
->green
= 0xffff;
842 prop_text_out
.foreground
->blue
= 0x0000;
844 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
846 prop_text_out
.foreground
->red
= 0xffff;
847 prop_text_out
.foreground
->green
= 0x0000;
848 prop_text_out
.foreground
->blue
= 0xffff;
850 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
852 prop_text_out
.foreground
->red
= 0xffff;
853 prop_text_out
.foreground
->green
= 0x0000;
854 prop_text_out
.foreground
->blue
= 0x0000;
856 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
858 prop_text_out
.foreground
->red
= 0x0000;
859 prop_text_out
.foreground
->green
= 0xffff;
860 prop_text_out
.foreground
->blue
= 0x0000;
864 prop_text_out
.foreground
->red
= 0xffff;
865 prop_text_out
.foreground
->green
= 0xffff;
866 prop_text_out
.foreground
->blue
= 0xffff;
870 /* Print status of the process : U, WF, WC, E, W, R */
871 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
872 prop_text_out
.text
= "U->";
873 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
874 prop_text_out
.text
= "WF->";
875 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
876 prop_text_out
.text
= "WC->";
877 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
878 prop_text_out
.text
= "E->";
879 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
880 prop_text_out
.text
= "W->";
881 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
882 prop_text_out
.text
= "R->";
884 prop_text_out
.text
= "U";
886 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
887 //gdk_gc_unref(draw_context_out->gc);
889 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
890 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
891 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
893 PropertiesLine prop_line_out
;
894 prop_line_out
.color
= g_new(GdkColor
,1);
895 prop_line_out
.line_width
= 2;
896 prop_line_out
.style
= GDK_LINE_SOLID
;
897 prop_line_out
.position
= MIDDLE
;
899 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
901 /* color of line : status of the process */
902 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
904 prop_line_out
.color
->red
= 0xffff;
905 prop_line_out
.color
->green
= 0xffff;
906 prop_line_out
.color
->blue
= 0xffff;
908 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
910 prop_line_out
.color
->red
= 0x0fff;
911 prop_line_out
.color
->green
= 0xffff;
912 prop_line_out
.color
->blue
= 0xfff0;
914 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
916 prop_line_out
.color
->red
= 0xffff;
917 prop_line_out
.color
->green
= 0xffff;
918 prop_line_out
.color
->blue
= 0x0000;
920 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
922 prop_line_out
.color
->red
= 0xffff;
923 prop_line_out
.color
->green
= 0x0000;
924 prop_line_out
.color
->blue
= 0xffff;
926 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
928 prop_line_out
.color
->red
= 0xffff;
929 prop_line_out
.color
->green
= 0x0000;
930 prop_line_out
.color
->blue
= 0x0000;
932 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
934 prop_line_out
.color
->red
= 0x0000;
935 prop_line_out
.color
->green
= 0xffff;
936 prop_line_out
.color
->blue
= 0x0000;
940 prop_line_out
.color
->red
= 0xffff;
941 prop_line_out
.color
->green
= 0xffff;
942 prop_line_out
.color
->blue
= 0xffff;
945 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
946 g_free(prop_line_out
.color
);
947 //gdk_gc_unref(draw_context_out->gc);
948 /* Note : finishing line will have to be added when trace read over. */
950 /* Finally, update the drawing context of the pid_in. */
952 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
953 draw_context_in
->current
->modify_over
->x
= x
;
954 draw_context_in
->current
->modify_under
->x
= x
;
955 draw_context_in
->current
->modify_over
->y
= y_in
;
956 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
957 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
958 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
959 widget
= control_flow_data
->drawing
->drawing_area
;
960 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
961 //draw_context_in->gc = widget->style->black_gc;
962 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
963 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
965 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
966 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
968 /* Draw the line/bg of the in process */
969 if(draw_context_in
->previous
->middle
->x
== -1)
971 draw_context_in
->previous
->over
->x
=
972 control_flow_data
->drawing
->damage_begin
;
973 draw_context_in
->previous
->middle
->x
=
974 control_flow_data
->drawing
->damage_begin
;
975 draw_context_in
->previous
->under
->x
=
976 control_flow_data
->drawing
->damage_begin
;
978 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
982 draw_context_in
->current
->middle
->x
= x
;
983 draw_context_in
->current
->over
->x
= x
;
984 draw_context_in
->current
->under
->x
= x
;
985 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
986 draw_context_in
->current
->over
->y
= y_in
;
987 draw_context_in
->current
->under
->y
= y_in
+ height
;
988 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
989 draw_context_in
->previous
->over
->y
= y_in
;
990 draw_context_in
->previous
->under
->y
= y_in
+ height
;
992 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
993 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
996 if(process_in
->state
->s
== LTTV_STATE_RUN
)
998 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
999 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1000 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1002 PropertiesBG prop_bg
;
1003 prop_bg
.color
= g_new(GdkColor
,1);
1005 switch(tfc
->index
) {
1007 prop_bg
.color
->red
= 0x1515;
1008 prop_bg
.color
->green
= 0x1515;
1009 prop_bg
.color
->blue
= 0x8c8c;
1012 prop_bg
.color
->red
= 0x4e4e;
1013 prop_bg
.color
->green
= 0xa9a9;
1014 prop_bg
.color
->blue
= 0xa4a4;
1017 prop_bg
.color
->red
= 0x7a7a;
1018 prop_bg
.color
->green
= 0x4a4a;
1019 prop_bg
.color
->blue
= 0x8b8b;
1022 prop_bg
.color
->red
= 0x8080;
1023 prop_bg
.color
->green
= 0x7777;
1024 prop_bg
.color
->blue
= 0x4747;
1027 prop_bg
.color
->red
= 0xe7e7;
1028 prop_bg
.color
->green
= 0xe7e7;
1029 prop_bg
.color
->blue
= 0xe7e7;
1033 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1034 g_free(prop_bg
.color
);
1035 //gdk_gc_unref(draw_context_in->gc);
1038 draw_context_in
->gc
= widget
->style
->black_gc
;
1040 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1041 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1042 PropertiesText prop_text_in
;
1043 prop_text_in
.foreground
= &colorfg_in
;
1044 prop_text_in
.background
= &colorbg_in
;
1045 prop_text_in
.size
= 6;
1046 prop_text_in
.position
= OVER
;
1048 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1049 /* foreground of text : status of the process */
1050 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1052 prop_text_in
.foreground
->red
= 0xffff;
1053 prop_text_in
.foreground
->green
= 0xffff;
1054 prop_text_in
.foreground
->blue
= 0xffff;
1056 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1058 prop_text_in
.foreground
->red
= 0x0fff;
1059 prop_text_in
.foreground
->green
= 0xffff;
1060 prop_text_in
.foreground
->blue
= 0xfff0;
1062 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1064 prop_text_in
.foreground
->red
= 0xffff;
1065 prop_text_in
.foreground
->green
= 0xffff;
1066 prop_text_in
.foreground
->blue
= 0x0000;
1068 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1070 prop_text_in
.foreground
->red
= 0xffff;
1071 prop_text_in
.foreground
->green
= 0x0000;
1072 prop_text_in
.foreground
->blue
= 0xffff;
1074 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1076 prop_text_in
.foreground
->red
= 0xffff;
1077 prop_text_in
.foreground
->green
= 0x0000;
1078 prop_text_in
.foreground
->blue
= 0x0000;
1080 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1082 prop_text_in
.foreground
->red
= 0x0000;
1083 prop_text_in
.foreground
->green
= 0xffff;
1084 prop_text_in
.foreground
->blue
= 0x0000;
1088 prop_text_in
.foreground
->red
= 0xffff;
1089 prop_text_in
.foreground
->green
= 0xffff;
1090 prop_text_in
.foreground
->blue
= 0xffff;
1095 /* Print status of the process : U, WF, WC, E, W, R */
1096 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1097 prop_text_in
.text
= "U->";
1098 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1099 prop_text_in
.text
= "WF->";
1100 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1101 prop_text_in
.text
= "WC->";
1102 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1103 prop_text_in
.text
= "E->";
1104 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1105 prop_text_in
.text
= "W->";
1106 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1107 prop_text_in
.text
= "R->";
1109 prop_text_in
.text
= "U";
1111 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1112 //gdk_gc_unref(draw_context_in->gc);
1114 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1115 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1116 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1118 PropertiesLine prop_line_in
;
1119 prop_line_in
.color
= g_new(GdkColor
,1);
1120 prop_line_in
.line_width
= 2;
1121 prop_line_in
.style
= GDK_LINE_SOLID
;
1122 prop_line_in
.position
= MIDDLE
;
1124 /* color of line : status of the process */
1125 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1127 prop_line_in
.color
->red
= 0xffff;
1128 prop_line_in
.color
->green
= 0xffff;
1129 prop_line_in
.color
->blue
= 0xffff;
1131 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1133 prop_line_in
.color
->red
= 0x0fff;
1134 prop_line_in
.color
->green
= 0xffff;
1135 prop_line_in
.color
->blue
= 0xfff0;
1137 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1139 prop_line_in
.color
->red
= 0xffff;
1140 prop_line_in
.color
->green
= 0xffff;
1141 prop_line_in
.color
->blue
= 0x0000;
1143 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1145 prop_line_in
.color
->red
= 0xffff;
1146 prop_line_in
.color
->green
= 0x0000;
1147 prop_line_in
.color
->blue
= 0xffff;
1149 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1151 prop_line_in
.color
->red
= 0xffff;
1152 prop_line_in
.color
->green
= 0x0000;
1153 prop_line_in
.color
->blue
= 0x0000;
1155 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1157 prop_line_in
.color
->red
= 0x0000;
1158 prop_line_in
.color
->green
= 0xffff;
1159 prop_line_in
.color
->blue
= 0x0000;
1163 prop_line_in
.color
->red
= 0xffff;
1164 prop_line_in
.color
->green
= 0xffff;
1165 prop_line_in
.color
->blue
= 0xffff;
1168 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1169 g_free(prop_line_in
.color
);
1170 //gdk_gc_unref(draw_context_in->gc);
1180 GString
*string
= g_string_new("");;
1181 gboolean field_names
= TRUE
, state
= TRUE
;
1183 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1184 g_string_append_printf(string
,"\n");
1187 g_string_append_printf(string
, " %s",
1188 g_quark_to_string(tfs
->process
->state
->s
));
1191 g_info("%s",string
->str
);
1193 g_string_free(string
, TRUE
);
1195 /* End of text dump */
1200 /* after_schedchange_hook
1202 * The draw after hook is called by the reading API to have a
1203 * particular event drawn on the screen.
1204 * @param hook_data ControlFlowData structure of the viewer.
1205 * @param call_data Event context.
1207 * This function adds items to be drawn in a queue for each process.
1210 int after_schedchange_hook(void *hook_data
, void *call_data
)
1212 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1213 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1215 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1217 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1218 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1223 LttTime evtime
= ltt_event_time(e
);
1224 TimeWindow time_window
=
1225 lttvwindow_get_time_window(control_flow_data
->tab
);
1227 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1228 time_window
.time_width
);
1230 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1231 || ltt_time_compare(evtime
, end_time
) == 1)
1234 guint width
= control_flow_data
->drawing
->width
;
1236 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0) {
1238 g_debug("schedchange!");
1241 /* Add process to process list (if not present) */
1242 LttvProcessState
*process_out
, *process_in
;
1244 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1245 HashedProcessData
*hashed_process_data_in
= NULL
;
1247 ProcessList
*process_list
=
1248 guicontrolflow_get_process_list(control_flow_data
);
1253 LttField
*f
= ltt_event_field(e
);
1255 element
= ltt_field_member(f
,0);
1256 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1257 element
= ltt_field_member(f
,1);
1258 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1259 g_debug("out : %u in : %u", pid_out
, pid_in
);
1263 /* Find process pid_in in the list... */
1264 process_in
= lttv_state_find_process(tfs
, pid_in
);
1265 /* It should exist, because we are after the state update. */
1266 g_assert(process_in
!= NULL
);
1268 birth
= process_in
->creation_time
;
1269 const gchar
*name
= g_quark_to_string(process_in
->name
);
1271 if(processlist_get_process_pixels(process_list
,
1273 process_in
->last_cpu
,
1275 tfc
->t_context
->index
,
1278 &hashed_process_data_in
) == 1)
1280 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1281 /* Process not present */
1282 processlist_add(process_list
,
1284 process_in
->last_cpu
,
1287 tfc
->t_context
->index
,
1290 &hashed_process_data_in
);
1291 processlist_get_process_pixels(process_list
,
1293 process_in
->last_cpu
,
1295 tfc
->t_context
->index
,
1298 &hashed_process_data_in
);
1299 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1302 convert_time_to_pixels(
1303 time_window
.start_time
,
1307 &hashed_process_data_in
->x
.middle
);
1315 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1316 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1318 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1320 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1321 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1327 LttTime evtime
= ltt_event_time(e
);
1328 TimeWindow time_window
=
1329 lttvwindow_get_time_window(control_flow_data
->tab
);
1331 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1332 time_window
.time_width
);
1333 //if(time < time_beg || time > time_end) return;
1334 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1335 || ltt_time_compare(evtime
, end_time
) == 1)
1339 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1341 g_debug("schedchange!");
1343 /* Add process to process list (if not present) and get drawing "y" from
1344 * process position */
1345 guint pid_out
, pid_in
;
1346 LttvProcessState
*process_out
, *process_in
;
1348 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1350 ProcessList
*process_list
=
1351 guicontrolflow_get_process_list(control_flow_data
);
1354 LttField
*f
= ltt_event_field(e
);
1356 element
= ltt_field_member(f
,0);
1357 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1358 element
= ltt_field_member(f
,1);
1359 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1360 //g_debug("out : %u in : %u", pid_out, pid_in);
1363 /* Find process pid_out in the list... */
1364 process_out
= lttv_state_find_process(tfs
, pid_out
);
1365 if(process_out
== NULL
) return 0;
1366 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1368 birth
= process_out
->creation_time
;
1369 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1370 HashedProcessData
*hashed_process_data_out
= NULL
;
1372 if(processlist_get_process_pixels(process_list
,
1375 tfc
->t_context
->index
,
1378 &hashed_process_data_out
) == 1)
1380 /* Process not present */
1381 processlist_add(process_list
,
1384 tfc
->t_context
->index
,
1387 &hashed_process_data_out
);
1388 processlist_get_process_pixels(process_list
,
1391 tfc
->t_context
->index
,
1394 &hashed_process_data_out
);
1395 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1400 /* Find process pid_in in the list... */
1401 process_in
= lttv_state_find_process(tfs
, pid_in
);
1402 if(process_in
== NULL
) return 0;
1403 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1405 birth
= process_in
->creation_time
;
1406 name
= strdup(g_quark_to_string(process_in
->name
));
1407 HashedProcessData
*hashed_process_data_in
= NULL
;
1409 if(processlist_get_process_pixels(process_list
,
1412 tfc
->t_context
->index
,
1415 &hashed_process_data_in
) == 1)
1417 /* Process not present */
1418 processlist_add(process_list
,
1421 tfc
->t_context
->index
,
1424 &hashed_process_data_in
);
1425 processlist_get_process_pixels(process_list
,
1428 tfc
->t_context
->index
,
1431 &hashed_process_data_in
);
1433 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1438 /* Find pixels corresponding to time of the event. If the time does
1439 * not fit in the window, show a warning, not supposed to happend. */
1441 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1443 //LttTime time = ltt_event_time(e);
1445 //LttTime window_end = ltt_time_add(time_window->time_width,
1446 // time_window->start_time);
1449 //convert_time_to_pixels(
1450 // time_window->start_time,
1456 //assert(x <= width);
1458 /* draw what represents the event for outgoing process. */
1460 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1461 //draw_context_out->current->modify_over->x = x;
1462 draw_context_out
->current
->modify_over
->y
= y_out
;
1463 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1464 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1465 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1466 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1467 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1469 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1470 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1472 /*if(process_out->state->s == LTTV_STATE_RUN)
1474 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1475 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1476 PropertiesBG prop_bg;
1477 prop_bg.color = g_new(GdkColor,1);
1479 prop_bg.color->red = 0xffff;
1480 prop_bg.color->green = 0xffff;
1481 prop_bg.color->blue = 0xffff;
1483 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1484 g_free(prop_bg.color);
1485 gdk_gc_unref(draw_context_out->gc);
1488 draw_context_out
->gc
= widget
->style
->black_gc
;
1490 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1491 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1492 PropertiesText prop_text_out
;
1493 prop_text_out
.foreground
= &colorfg_out
;
1494 prop_text_out
.background
= &colorbg_out
;
1495 prop_text_out
.size
= 6;
1496 prop_text_out
.position
= OVER
;
1498 /* color of text : status of the process */
1499 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1501 prop_text_out
.foreground
->red
= 0xffff;
1502 prop_text_out
.foreground
->green
= 0xffff;
1503 prop_text_out
.foreground
->blue
= 0xffff;
1505 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1507 prop_text_out
.foreground
->red
= 0x0fff;
1508 prop_text_out
.foreground
->green
= 0xffff;
1509 prop_text_out
.foreground
->blue
= 0xfff0;
1511 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1513 prop_text_out
.foreground
->red
= 0xffff;
1514 prop_text_out
.foreground
->green
= 0xffff;
1515 prop_text_out
.foreground
->blue
= 0x0000;
1517 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1519 prop_text_out
.foreground
->red
= 0xffff;
1520 prop_text_out
.foreground
->green
= 0x0000;
1521 prop_text_out
.foreground
->blue
= 0xffff;
1523 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1525 prop_text_out
.foreground
->red
= 0xffff;
1526 prop_text_out
.foreground
->green
= 0x0000;
1527 prop_text_out
.foreground
->blue
= 0x0000;
1529 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1531 prop_text_out
.foreground
->red
= 0x0000;
1532 prop_text_out
.foreground
->green
= 0xffff;
1533 prop_text_out
.foreground
->blue
= 0x0000;
1537 prop_text_out
.foreground
->red
= 0xffff;
1538 prop_text_out
.foreground
->green
= 0xffff;
1539 prop_text_out
.foreground
->blue
= 0xffff;
1542 /* Print status of the process : U, WF, WC, E, W, R */
1543 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1544 prop_text_out
.text
= "U";
1545 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1546 prop_text_out
.text
= "WF";
1547 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1548 prop_text_out
.text
= "WC";
1549 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1550 prop_text_out
.text
= "E";
1551 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1552 prop_text_out
.text
= "W";
1553 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1554 prop_text_out
.text
= "R";
1556 prop_text_out
.text
= "U";
1558 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1560 //gdk_gc_unref(draw_context_out->gc);
1562 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1563 draw_context_out
->current
->over
->y
= y_out
;
1564 draw_context_out
->current
->under
->y
= y_out
+height
;
1565 draw_context_out
->current
->status
= process_out
->state
->s
;
1567 /* for pid_out : remove previous, Prev = current, new current (default) */
1568 g_free(draw_context_out
->previous
->modify_under
);
1569 g_free(draw_context_out
->previous
->modify_middle
);
1570 g_free(draw_context_out
->previous
->modify_over
);
1571 g_free(draw_context_out
->previous
->under
);
1572 g_free(draw_context_out
->previous
->middle
);
1573 g_free(draw_context_out
->previous
->over
);
1574 g_free(draw_context_out
->previous
);
1576 draw_context_out
->previous
= draw_context_out
->current
;
1578 draw_context_out
->current
= g_new(DrawInfo
,1);
1579 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1580 draw_context_out
->current
->over
->x
= -1;
1581 draw_context_out
->current
->over
->y
= -1;
1582 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1583 draw_context_out
->current
->middle
->x
= -1;
1584 draw_context_out
->current
->middle
->y
= -1;
1585 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1586 draw_context_out
->current
->under
->x
= -1;
1587 draw_context_out
->current
->under
->y
= -1;
1588 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1589 draw_context_out
->current
->modify_over
->x
= -1;
1590 draw_context_out
->current
->modify_over
->y
= -1;
1591 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1592 draw_context_out
->current
->modify_middle
->x
= -1;
1593 draw_context_out
->current
->modify_middle
->y
= -1;
1594 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1595 draw_context_out
->current
->modify_under
->x
= -1;
1596 draw_context_out
->current
->modify_under
->y
= -1;
1597 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1599 /* Finally, update the drawing context of the pid_in. */
1601 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1602 //draw_context_in->current->modify_over->x = x;
1603 draw_context_in
->current
->modify_over
->y
= y_in
;
1604 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1605 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1606 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1607 widget
= control_flow_data
->drawing
->drawing_area
;
1608 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1610 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1611 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1613 /*if(process_in->state->s == LTTV_STATE_RUN)
1615 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1616 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1617 PropertiesBG prop_bg;
1618 prop_bg.color = g_new(GdkColor,1);
1620 prop_bg.color->red = 0xffff;
1621 prop_bg.color->green = 0xffff;
1622 prop_bg.color->blue = 0xffff;
1624 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1625 g_free(prop_bg.color);
1626 gdk_gc_unref(draw_context_in->gc);
1629 draw_context_in
->gc
= widget
->style
->black_gc
;
1631 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1632 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1633 PropertiesText prop_text_in
;
1634 prop_text_in
.foreground
= &colorfg_in
;
1635 prop_text_in
.background
= &colorbg_in
;
1636 prop_text_in
.size
= 6;
1637 prop_text_in
.position
= OVER
;
1639 /* foreground of text : status of the process */
1640 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1642 prop_text_in
.foreground
->red
= 0xffff;
1643 prop_text_in
.foreground
->green
= 0xffff;
1644 prop_text_in
.foreground
->blue
= 0xffff;
1646 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1648 prop_text_in
.foreground
->red
= 0x0fff;
1649 prop_text_in
.foreground
->green
= 0xffff;
1650 prop_text_in
.foreground
->blue
= 0xfff0;
1652 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1654 prop_text_in
.foreground
->red
= 0xffff;
1655 prop_text_in
.foreground
->green
= 0xffff;
1656 prop_text_in
.foreground
->blue
= 0x0000;
1658 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1660 prop_text_in
.foreground
->red
= 0xffff;
1661 prop_text_in
.foreground
->green
= 0x0000;
1662 prop_text_in
.foreground
->blue
= 0xffff;
1664 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1666 prop_text_in
.foreground
->red
= 0xffff;
1667 prop_text_in
.foreground
->green
= 0x0000;
1668 prop_text_in
.foreground
->blue
= 0x0000;
1670 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1672 prop_text_in
.foreground
->red
= 0x0000;
1673 prop_text_in
.foreground
->green
= 0xffff;
1674 prop_text_in
.foreground
->blue
= 0x0000;
1678 prop_text_in
.foreground
->red
= 0xffff;
1679 prop_text_in
.foreground
->green
= 0xffff;
1680 prop_text_in
.foreground
->blue
= 0xffff;
1684 /* Print status of the process : U, WF, WC, E, W, R */
1685 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1686 prop_text_in
.text
= "U";
1687 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1688 prop_text_in
.text
= "WF";
1689 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1690 prop_text_in
.text
= "WC";
1691 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1692 prop_text_in
.text
= "E";
1693 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1694 prop_text_in
.text
= "W";
1695 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1696 prop_text_in
.text
= "R";
1698 prop_text_in
.text
= "U";
1700 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1703 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1706 prop_text_in
.foreground
= &colorfg_in
;
1707 prop_text_in
.background
= &colorbg_in
;
1708 prop_text_in
.foreground
->red
= 0xffff;
1709 prop_text_in
.foreground
->green
= 0xffff;
1710 prop_text_in
.foreground
->blue
= 0xffff;
1711 prop_text_in
.size
= 6;
1712 prop_text_in
.position
= UNDER
;
1714 prop_text_in
.text
= g_new(gchar
, 260);
1715 strcpy(prop_text_in
.text
, "CPU ");
1716 snprintf(tmp
, 255, "%u", tfc
->index
);
1717 strcat(prop_text_in
.text
, tmp
);
1719 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1720 g_free(prop_text_in
.text
);
1724 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1725 draw_context_in
->current
->over
->y
= y_in
;
1726 draw_context_in
->current
->under
->y
= y_in
+height
;
1727 draw_context_in
->current
->status
= process_in
->state
->s
;
1729 /* for pid_in : remove previous, Prev = current, new current (default) */
1730 g_free(draw_context_in
->previous
->modify_under
);
1731 g_free(draw_context_in
->previous
->modify_middle
);
1732 g_free(draw_context_in
->previous
->modify_over
);
1733 g_free(draw_context_in
->previous
->under
);
1734 g_free(draw_context_in
->previous
->middle
);
1735 g_free(draw_context_in
->previous
->over
);
1736 g_free(draw_context_in
->previous
);
1738 draw_context_in
->previous
= draw_context_in
->current
;
1740 draw_context_in
->current
= g_new(DrawInfo
,1);
1741 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1742 draw_context_in
->current
->over
->x
= -1;
1743 draw_context_in
->current
->over
->y
= -1;
1744 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1745 draw_context_in
->current
->middle
->x
= -1;
1746 draw_context_in
->current
->middle
->y
= -1;
1747 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1748 draw_context_in
->current
->under
->x
= -1;
1749 draw_context_in
->current
->under
->y
= -1;
1750 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1751 draw_context_in
->current
->modify_over
->x
= -1;
1752 draw_context_in
->current
->modify_over
->y
= -1;
1753 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1754 draw_context_in
->current
->modify_middle
->x
= -1;
1755 draw_context_in
->current
->modify_middle
->y
= -1;
1756 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1757 draw_context_in
->current
->modify_under
->x
= -1;
1758 draw_context_in
->current
->modify_under
->y
= -1;
1759 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1767 static __inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1769 PropertiesLine prop_line
;
1770 prop_line
.line_width
= 1;
1771 prop_line
.style
= GDK_LINE_SOLID
;
1773 //GdkColormap *colormap = gdk_colormap_get_system();
1775 /* color of line : execution mode of the process */
1776 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1777 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1778 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1779 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1780 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1781 prop_line
.color
= drawing_colors
[COL_TRAP
];
1782 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1783 prop_line
.color
= drawing_colors
[COL_IRQ
];
1784 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1785 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1787 prop_line
.color
= drawing_colors
[COL_WHITE
];
1789 //gdk_colormap_alloc_color(colormap,
1800 /* before_execmode_hook
1802 * This function basically draw lines and icons. Two types of lines are drawn :
1803 * one small (3 pixels?) representing the state of the process and the second
1804 * type is thicker (10 pixels?) representing on which CPU a process is running
1805 * (and this only in running state).
1807 * Extremums of the lines :
1808 * x_min : time of the last event context for this process kept in memory.
1809 * x_max : time of the current event.
1810 * y : middle of the process in the process list. The process is found in the
1811 * list, therefore is it's position in pixels.
1813 * The choice of lines'color is defined by the context of the last event for this
1818 int before_execmode_hook(void *hook_data
, void *call_data
)
1820 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1821 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1822 Drawing_t
*drawing
= control_flow_data
->drawing
;
1824 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1826 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1827 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1832 LttTime evtime
= ltt_event_time(e
);
1833 TimeWindow time_window
=
1834 lttvwindow_get_time_window(control_flow_data
->tab
);
1836 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1837 time_window
.time_width
);
1839 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1840 || ltt_time_compare(evtime
, end_time
) == 1)
1843 guint width
= drawing
->width
;
1845 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"syscall_entry") == 0
1846 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"syscall_exit") == 0
1847 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"trap_entry") == 0
1848 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"trap_exit") == 0
1849 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"irq_entry") == 0
1850 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"irq_exit") == 0
1853 /* we are in a execmode, before the state update. We must draw the
1854 * items corresponding to the state before it changes : now is the right
1858 LttvProcessState
*process
= tfs
->process
;
1859 g_assert(process
!= NULL
);
1861 guint pid
= process
->pid
;
1863 /* Well, the process_out existed : we must get it in the process hash
1864 * or add it, and draw its items.
1866 /* Add process to process list (if not present) */
1867 guint y
= 0, height
= 0, pl_height
= 0;
1868 HashedProcessData
*hashed_process_data
= NULL
;
1869 ProcessList
*process_list
=
1870 guicontrolflow_get_process_list(control_flow_data
);
1871 LttTime birth
= process
->creation_time
;
1872 const gchar
*name
= g_quark_to_string(process
->name
);
1874 if(processlist_get_process_pixels(process_list
,
1878 tfc
->t_context
->index
,
1881 &hashed_process_data
) == 1)
1883 g_assert(pid
== 0 || pid
!= process
->ppid
);
1884 /* Process not present */
1885 processlist_add(process_list
,
1890 tfc
->t_context
->index
,
1893 &hashed_process_data
);
1894 processlist_get_process_pixels(process_list
,
1898 tfc
->t_context
->index
,
1901 &hashed_process_data
);
1902 drawing_insert_square( drawing
, y
, height
);
1905 /* Now, the process is in the state hash and our own process hash.
1906 * We definitely can draw the items related to the ending state.
1909 /* Check if the x position is unset. In can have been left unset by
1910 * a draw closure from a after chunk hook. This should never happen,
1911 * because it must be set by before chunk hook to the damage_begin
1914 g_assert(hashed_process_data
->x
.over
!= -1);
1917 DrawContext draw_context
;
1919 convert_time_to_pixels(
1920 time_window
.start_time
,
1926 /* Now create the drawing context that will be used to draw
1927 * items related to the last state. */
1928 draw_context
.drawable
= drawing
->pixmap
;
1929 draw_context
.gc
= drawing
->gc
;
1930 draw_context
.pango_layout
= drawing
->pango_layout
;
1931 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
1932 draw_context
.drawinfo
.end
.x
= x
;
1934 draw_context
.drawinfo
.y
.over
= y
+1;
1935 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
1936 draw_context
.drawinfo
.y
.under
= y
+height
;
1938 draw_context
.drawinfo
.start
.offset
.over
= 0;
1939 draw_context
.drawinfo
.start
.offset
.middle
= 0;
1940 draw_context
.drawinfo
.start
.offset
.under
= 0;
1941 draw_context
.drawinfo
.end
.offset
.over
= 0;
1942 draw_context
.drawinfo
.end
.offset
.middle
= 0;
1943 draw_context
.drawinfo
.end
.offset
.under
= 0;
1947 PropertiesLine prop_line
= prepare_execmode_line(process
);
1948 draw_line((void*)&prop_line
, (void*)&draw_context
);
1951 /* become the last x position */
1952 hashed_process_data
->x
.over
= x
;
1959 /* after_execmode_hook
1961 * The draw after hook is called by the reading API to have a
1962 * particular event drawn on the screen.
1963 * @param hook_data ControlFlowData structure of the viewer.
1964 * @param call_data Event context.
1966 * This function adds items to be drawn in a queue for each process.
1969 int after_execmode_hook(void *hook_data
, void *call_data
)
1971 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1972 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1974 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1976 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1977 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1982 LttTime evtime
= ltt_event_time(e
);
1983 TimeWindow time_window
=
1984 lttvwindow_get_time_window(control_flow_data
->tab
);
1986 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1987 time_window
.time_width
);
1989 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1990 || ltt_time_compare(evtime
, end_time
) == 1)
1993 guint width
= control_flow_data
->drawing
->width
;
1995 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"syscall_entry") == 0
1996 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"syscall_exit") == 0
1997 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"trap_entry") == 0
1998 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"trap_exit") == 0
1999 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"irq_entry") == 0
2000 ||strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"irq_exit") == 0
2003 g_debug("execmode!");
2006 /* Add process to process list (if not present) */
2007 LttvProcessState
*process
;
2009 guint y
= 0, height
= 0, pl_height
= 0;
2010 HashedProcessData
*hashed_process_data
= NULL
;
2012 ProcessList
*process_list
=
2013 guicontrolflow_get_process_list(control_flow_data
);
2016 /* Find process pid_in in the list... */
2017 process
= tfs
->process
;
2018 /* It should exist, because we are after the state update. */
2019 g_assert(process
!= NULL
);
2021 guint pid
= process
->pid
;
2023 birth
= process
->creation_time
;
2024 const gchar
*name
= g_quark_to_string(process
->name
);
2026 if(processlist_get_process_pixels(process_list
,
2030 tfc
->t_context
->index
,
2033 &hashed_process_data
) == 1)
2035 g_assert(pid
== 0 || pid
!= process
->ppid
);
2036 /* Process not present */
2037 processlist_add(process_list
,
2042 tfc
->t_context
->index
,
2045 &hashed_process_data
);
2046 processlist_get_process_pixels(process_list
,
2050 tfc
->t_context
->index
,
2053 &hashed_process_data
);
2054 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2057 convert_time_to_pixels(
2058 time_window
.start_time
,
2062 &hashed_process_data
->x
.over
);
2070 /* before_process_hook
2072 * Draw lines for process event.
2074 * @param hook_data ControlFlowData structure of the viewer.
2075 * @param call_data Event context.
2077 * This function adds items to be drawn in a queue for each process.
2080 int before_process_hook(void *hook_data
, void *call_data
)
2082 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2083 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2084 Drawing_t
*drawing
= control_flow_data
->drawing
;
2086 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2088 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2089 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2094 LttTime evtime
= ltt_event_time(e
);
2095 TimeWindow time_window
=
2096 lttvwindow_get_time_window(control_flow_data
->tab
);
2098 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2099 time_window
.time_width
);
2101 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2102 || ltt_time_compare(evtime
, end_time
) == 1)
2105 guint width
= control_flow_data
->drawing
->width
;
2107 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"process") == 0) {
2111 LttField
*f
= ltt_event_field(e
);
2113 element
= ltt_field_member(f
,0);
2114 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2117 if(sub_id
== 3) { /* exit */
2119 /* Add process to process list (if not present) */
2120 LttvProcessState
*process
= tfs
->process
;
2121 guint pid
= process
->pid
;
2123 guint y
= 0, height
= 0, pl_height
= 0;
2124 HashedProcessData
*hashed_process_data
= NULL
;
2126 ProcessList
*process_list
=
2127 guicontrolflow_get_process_list(control_flow_data
);
2129 g_assert(process
!= NULL
);
2131 birth
= process
->creation_time
;
2132 const gchar
*name
= g_quark_to_string(process
->name
);
2134 if(processlist_get_process_pixels(process_list
,
2138 tfc
->t_context
->index
,
2141 &hashed_process_data
) == 1)
2143 g_assert(pid
== 0 || pid
!= process
->ppid
);
2144 /* Process not present */
2145 processlist_add(process_list
,
2150 tfc
->t_context
->index
,
2153 &hashed_process_data
);
2154 processlist_get_process_pixels(process_list
,
2158 tfc
->t_context
->index
,
2161 &hashed_process_data
);
2162 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2165 /* Now, the process is in the state hash and our own process hash.
2166 * We definitely can draw the items related to the ending state.
2169 /* Check if the x position is unset. In can have been left unset by
2170 * a draw closure from a after chunk hook. This should never happen,
2171 * because it must be set by before chunk hook to the damage_begin
2174 g_assert(hashed_process_data
->x
.over
!= -1);
2177 DrawContext draw_context
;
2179 convert_time_to_pixels(
2180 time_window
.start_time
,
2186 /* Now create the drawing context that will be used to draw
2187 * items related to the last state. */
2188 draw_context
.drawable
= drawing
->pixmap
;
2189 draw_context
.gc
= drawing
->gc
;
2190 draw_context
.pango_layout
= drawing
->pango_layout
;
2191 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2192 draw_context
.drawinfo
.end
.x
= x
;
2194 draw_context
.drawinfo
.y
.over
= y
+1;
2195 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2196 draw_context
.drawinfo
.y
.under
= y
+height
;
2198 draw_context
.drawinfo
.start
.offset
.over
= 0;
2199 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2200 draw_context
.drawinfo
.start
.offset
.under
= 0;
2201 draw_context
.drawinfo
.end
.offset
.over
= 0;
2202 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2203 draw_context
.drawinfo
.end
.offset
.under
= 0;
2207 PropertiesLine prop_line
= prepare_status_line(process
);
2208 draw_line((void*)&prop_line
, (void*)&draw_context
);
2211 /* become the last x position */
2212 hashed_process_data
->x
.middle
= x
;
2228 /* after_process_hook
2230 * Create the processlist entry for the child process. Put the last
2231 * position in x at the current time value.
2233 * @param hook_data ControlFlowData structure of the viewer.
2234 * @param call_data Event context.
2236 * This function adds items to be drawn in a queue for each process.
2239 int after_process_hook(void *hook_data
, void *call_data
)
2241 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2242 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2244 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2246 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2247 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
2252 LttTime evtime
= ltt_event_time(e
);
2253 TimeWindow time_window
=
2254 lttvwindow_get_time_window(control_flow_data
->tab
);
2256 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2257 time_window
.time_width
);
2259 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2260 || ltt_time_compare(evtime
, end_time
) == 1)
2263 guint width
= control_flow_data
->drawing
->width
;
2265 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"process") == 0) {
2270 LttField
*f
= ltt_event_field(e
);
2272 element
= ltt_field_member(f
,0);
2273 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2274 element
= ltt_field_member(f
,1);
2275 param1
= ltt_event_get_long_unsigned(e
,element
);
2278 if(sub_id
== 2) { /* fork */
2280 guint child_pid
= param1
;
2281 /* Add process to process list (if not present) */
2282 LttvProcessState
*process_child
;
2284 guint y_child
= 0, height
= 0, pl_height
= 0;
2285 HashedProcessData
*hashed_process_data_child
= NULL
;
2287 ProcessList
*process_list
=
2288 guicontrolflow_get_process_list(control_flow_data
);
2291 /* Find child in the list... */
2292 process_child
= lttv_state_find_process(tfs
, child_pid
);
2293 /* It should exist, because we are after the state update. */
2294 g_assert(process_child
!= NULL
);
2296 birth
= process_child
->creation_time
;
2297 const gchar
*name
= g_quark_to_string(process_child
->name
);
2299 if(processlist_get_process_pixels(process_list
,
2301 process_child
->last_cpu
,
2303 tfc
->t_context
->index
,
2306 &hashed_process_data_child
) == 1)
2308 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2309 /* Process not present */
2310 processlist_add(process_list
,
2312 process_child
->last_cpu
,
2313 process_child
->ppid
,
2315 tfc
->t_context
->index
,
2318 &hashed_process_data_child
);
2319 processlist_get_process_pixels(process_list
,
2321 process_child
->last_cpu
,
2323 tfc
->t_context
->index
,
2326 &hashed_process_data_child
);
2327 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2331 convert_time_to_pixels(
2332 time_window
.start_time
,
2337 hashed_process_data_child
->x
.over
= new_x
;
2338 hashed_process_data_child
->x
.middle
= new_x
;
2339 hashed_process_data_child
->x
.under
= new_x
;
2341 } else if(sub_id
== 3) { /* exit */
2343 /* Add process to process list (if not present) */
2344 LttvProcessState
*process
= tfs
->process
;
2345 guint pid
= process
->pid
;
2347 guint y
= 0, height
= 0, pl_height
= 0;
2348 HashedProcessData
*hashed_process_data
= NULL
;
2350 ProcessList
*process_list
=
2351 guicontrolflow_get_process_list(control_flow_data
);
2354 /* It should exist, because we are after the state update. */
2355 g_assert(process
!= NULL
);
2357 birth
= process
->creation_time
;
2358 const gchar
*name
= g_quark_to_string(process
->name
);
2360 if(processlist_get_process_pixels(process_list
,
2364 tfc
->t_context
->index
,
2367 &hashed_process_data
) == 1)
2369 g_assert(pid
== 0 || pid
!= process
->ppid
);
2370 /* Process not present */
2371 processlist_add(process_list
,
2376 tfc
->t_context
->index
,
2379 &hashed_process_data
);
2380 processlist_get_process_pixels(process_list
,
2384 tfc
->t_context
->index
,
2387 &hashed_process_data
);
2388 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2392 convert_time_to_pixels(
2393 time_window
.start_time
,
2398 hashed_process_data
->x
.middle
= new_x
;
2408 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2410 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2411 Drawing_t
*drawing
= control_flow_data
->drawing
;
2413 const TimeWindowNotifyData
*time_window_nofify_data
=
2414 ((const TimeWindowNotifyData
*)call_data
);
2416 TimeWindow
*old_time_window
=
2417 time_window_nofify_data
->old_time_window
;
2418 TimeWindow
*new_time_window
=
2419 time_window_nofify_data
->new_time_window
;
2421 /* Update the ruler */
2422 drawing_update_ruler(control_flow_data
->drawing
,
2426 /* Two cases : zoom in/out or scrolling */
2428 /* In order to make sure we can reuse the old drawing, the scale must
2429 * be the same and the new time interval being partly located in the
2430 * currently shown time interval. (reuse is only for scrolling)
2433 g_info("Old time window HOOK : %u, %u to %u, %u",
2434 old_time_window
->start_time
.tv_sec
,
2435 old_time_window
->start_time
.tv_nsec
,
2436 old_time_window
->time_width
.tv_sec
,
2437 old_time_window
->time_width
.tv_nsec
);
2439 g_info("New time window HOOK : %u, %u to %u, %u",
2440 new_time_window
->start_time
.tv_sec
,
2441 new_time_window
->start_time
.tv_nsec
,
2442 new_time_window
->time_width
.tv_sec
,
2443 new_time_window
->time_width
.tv_nsec
);
2445 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2446 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2448 /* Same scale (scrolling) */
2449 g_info("scrolling");
2450 LttTime
*ns
= &new_time_window
->start_time
;
2451 LttTime
*os
= &old_time_window
->start_time
;
2452 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
2453 old_time_window
->time_width
);
2454 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
2455 new_time_window
->time_width
);
2457 //if(ns<os+w && os+w<ns+w)
2458 //if(ns<old_end && os<ns)
2459 if(ltt_time_compare(*ns
, old_end
) == -1
2460 && ltt_time_compare(*os
, *ns
) == -1)
2462 g_info("scrolling near right");
2463 /* Scroll right, keep right part of the screen */
2465 guint width
= control_flow_data
->drawing
->width
;
2466 convert_time_to_pixels(
2473 /* Copy old data to new location */
2474 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2475 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2476 control_flow_data
->drawing
->pixmap
,
2479 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2481 if(drawing
->damage_begin
== drawing
->damage_end
)
2482 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2484 drawing
->damage_begin
= 0;
2486 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2488 /* Clear the data request background, but not SAFETY */
2489 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2490 //control_flow_data->drawing->drawing_area->style->black_gc,
2491 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2493 drawing
->damage_begin
+SAFETY
, 0,
2494 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2495 control_flow_data
->drawing
->height
);
2497 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2499 control_flow_data
->drawing
->width
,
2500 control_flow_data
->drawing
->height
);
2502 /* Get new data for the rest. */
2503 drawing_data_request(control_flow_data
->drawing
,
2504 &control_flow_data
->drawing
->pixmap
,
2505 drawing
->damage_begin
, 0,
2506 drawing
->damage_end
- drawing
->damage_begin
,
2507 control_flow_data
->drawing
->height
);
2510 //if(ns<os && os<ns+w)
2511 //if(ns<os && os<new_end)
2512 if(ltt_time_compare(*ns
,*os
) == -1
2513 && ltt_time_compare(*os
,new_end
) == -1)
2515 g_info("scrolling near left");
2516 /* Scroll left, keep left part of the screen */
2518 guint width
= control_flow_data
->drawing
->width
;
2519 convert_time_to_pixels(
2527 /* Copy old data to new location */
2528 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2529 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2530 control_flow_data
->drawing
->pixmap
,
2535 if(drawing
->damage_begin
== drawing
->damage_end
)
2536 drawing
->damage_end
= x
;
2538 drawing
->damage_end
=
2539 control_flow_data
->drawing
->width
;
2541 drawing
->damage_begin
= 0;
2543 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2544 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2546 drawing
->damage_begin
, 0,
2547 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2548 control_flow_data
->drawing
->height
);
2550 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2552 control_flow_data
->drawing
->width
,
2553 control_flow_data
->drawing
->height
);
2556 /* Get new data for the rest. */
2557 drawing_data_request(control_flow_data
->drawing
,
2558 &control_flow_data
->drawing
->pixmap
,
2559 drawing
->damage_begin
, 0,
2560 drawing
->damage_end
- drawing
->damage_begin
,
2561 control_flow_data
->drawing
->height
);
2564 if(ltt_time_compare(*ns
,*os
) == 0)
2566 g_info("not scrolling");
2568 g_info("scrolling far");
2569 /* Cannot reuse any part of the screen : far jump */
2572 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2573 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2576 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2577 control_flow_data
->drawing
->height
);
2579 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2581 control_flow_data
->drawing
->width
,
2582 control_flow_data
->drawing
->height
);
2584 drawing
->damage_begin
= 0;
2585 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2587 drawing_data_request(control_flow_data
->drawing
,
2588 &control_flow_data
->drawing
->pixmap
,
2590 control_flow_data
->drawing
->width
,
2591 control_flow_data
->drawing
->height
);
2597 /* Different scale (zoom) */
2600 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2601 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2604 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2605 control_flow_data
->drawing
->height
);
2607 gtk_widget_queue_draw_area (drawing
->drawing_area
,
2609 control_flow_data
->drawing
->width
,
2610 control_flow_data
->drawing
->height
);
2612 drawing
->damage_begin
= 0;
2613 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2615 drawing_data_request(control_flow_data
->drawing
,
2616 &control_flow_data
->drawing
->pixmap
,
2618 control_flow_data
->drawing
->width
,
2619 control_flow_data
->drawing
->height
);
2627 gint
traceset_notify(void *hook_data
, void *call_data
)
2629 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2630 Drawing_t
*drawing
= control_flow_data
->drawing
;
2631 GtkWidget
*widget
= drawing
->drawing_area
;
2634 drawing_clear(control_flow_data
->drawing
);
2635 processlist_clear(control_flow_data
->process_list
);
2636 redraw_notify(control_flow_data
, NULL
);
2638 request_background_data(control_flow_data
);
2640 drawing
->damage_begin
= 0;
2641 drawing
->damage_end
= drawing
->width
;
2642 if(drawing
->damage_begin
< drawing
->damage_end
)
2644 drawing_data_request(drawing
,
2646 drawing
->damage_begin
,
2648 drawing
->damage_end
-drawing
->damage_begin
,
2652 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2661 gint
redraw_notify(void *hook_data
, void *call_data
)
2663 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2664 Drawing_t
*drawing
= control_flow_data
->drawing
;
2665 GtkWidget
*widget
= drawing
->drawing_area
;
2667 drawing
->damage_begin
= 0;
2668 drawing
->damage_end
= drawing
->width
;
2670 /* fun feature, to be separated someday... */
2671 drawing_clear(control_flow_data
->drawing
);
2672 processlist_clear(control_flow_data
->process_list
);
2675 gdk_draw_rectangle (drawing
->pixmap
,
2676 widget
->style
->black_gc
,
2679 drawing
->width
+SAFETY
,
2683 if(drawing
->damage_begin
< drawing
->damage_end
)
2685 drawing_data_request(drawing
,
2687 drawing
->damage_begin
,
2689 drawing
->damage_end
-drawing
->damage_begin
,
2693 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2702 gint
continue_notify(void *hook_data
, void *call_data
)
2704 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2705 Drawing_t
*drawing
= control_flow_data
->drawing
;
2706 GtkWidget
*widget
= drawing
->drawing_area
;
2708 //g_assert(widget->allocation.width == drawing->damage_end);
2710 if(drawing
->damage_begin
< drawing
->damage_end
)
2712 drawing_data_request(drawing
,
2714 drawing
->damage_begin
,
2716 drawing
->damage_end
-drawing
->damage_begin
,
2724 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2726 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2727 Drawing_t
*drawing
= control_flow_data
->drawing
;
2729 LttTime current_time
= *((LttTime
*)call_data
);
2731 TimeWindow time_window
=
2732 lttvwindow_get_time_window(control_flow_data
->tab
);
2734 LttTime time_begin
= time_window
.start_time
;
2735 LttTime width
= time_window
.time_width
;
2736 LttTime half_width
= ltt_time_div(width
,2.0);
2737 LttTime time_end
= ltt_time_add(time_begin
, width
);
2739 LttvTracesetContext
* tsc
=
2740 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2742 LttTime trace_start
= tsc
->time_span
.start_time
;
2743 LttTime trace_end
= tsc
->time_span
.end_time
;
2745 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2746 current_time
.tv_nsec
);
2750 /* If current time is inside time interval, just move the highlight
2753 /* Else, we have to change the time interval. We have to tell it
2754 * to the main window. */
2755 /* The time interval change will take care of placing the current
2756 * time at the center of the visible area, or nearest possible if we are
2757 * at one end of the trace. */
2760 if(ltt_time_compare(current_time
, time_begin
) == -1)
2762 TimeWindow new_time_window
;
2764 if(ltt_time_compare(current_time
,
2765 ltt_time_add(trace_start
,half_width
)) == -1)
2766 time_begin
= trace_start
;
2768 time_begin
= ltt_time_sub(current_time
,half_width
);
2770 new_time_window
.start_time
= time_begin
;
2771 new_time_window
.time_width
= width
;
2773 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2775 else if(ltt_time_compare(current_time
, time_end
) == 1)
2777 TimeWindow new_time_window
;
2779 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2780 time_begin
= ltt_time_sub(trace_end
,width
);
2782 time_begin
= ltt_time_sub(current_time
,half_width
);
2784 new_time_window
.start_time
= time_begin
;
2785 new_time_window
.time_width
= width
;
2787 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2790 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2791 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2799 typedef struct _ClosureData
{
2800 EventsRequest
*events_request
;
2801 LttvTracesetState
*tss
;
2806 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2808 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2809 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2810 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2812 EventsRequest
*events_request
= closure_data
->events_request
;
2813 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2814 Drawing_t
*drawing
= control_flow_data
->drawing
;
2816 LttvTracesetState
*tss
= closure_data
->tss
;
2817 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2819 LttTime evtime
= closure_data
->end_time
;
2820 TimeWindow time_window
=
2821 lttvwindow_get_time_window(control_flow_data
->tab
);
2823 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2824 time_window
.time_width
);
2826 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2827 || ltt_time_compare(evtime
, end_time
) == 1)
2830 guint width
= drawing
->width
;
2833 /* For the process */
2834 /* First, check if the current process is in the state computation
2835 * process list. If it is there, that means we must add it right now and
2836 * draw items from the beginning of the read for it. If it is not
2837 * present, it's a new process and it was not present : it will
2838 * be added after the state update. */
2839 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2841 /* tracefiles[0] is ok here, because we draw for every PID, and
2842 * assume CPU 0 for PID 0 //FIXME */
2843 LttvTracefileState
*tfs
=
2844 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2846 LttvProcessState
*process
;
2847 process
= lttv_state_find_process(tfs
,
2850 if(process
!= NULL
) {
2852 /* Only draw for processes that are currently in the trace states */
2854 guint y
= 0, height
= 0, pl_height
= 0;
2855 ProcessList
*process_list
=
2856 guicontrolflow_get_process_list(control_flow_data
);
2857 LttTime birth
= process_info
->birth
;
2859 /* Should be alike when background info is ready */
2860 if(control_flow_data
->background_info_waiting
==0)
2861 g_assert(ltt_time_compare(process
->creation_time
,
2862 process_info
->birth
) == 0);
2863 const gchar
*name
= g_quark_to_string(process
->name
);
2865 /* process HAS to be present */
2866 g_assert(processlist_get_process_pixels(process_list
,
2870 process_info
->trace_num
,
2873 &hashed_process_data
) != 1);
2875 /* Now, the process is in the state hash and our own process hash.
2876 * We definitely can draw the items related to the ending state.
2879 /* Check if the x position is unset. In can have been left unset by
2880 * a draw closure from a after chunk hook. This should never happen,
2881 * because it must be set by before chunk hook to the damage_begin
2884 g_assert(hashed_process_data
->x
.over
!= -1);
2887 DrawContext draw_context
;
2889 convert_time_to_pixels(
2890 time_window
.start_time
,
2896 /* Now create the drawing context that will be used to draw
2897 * items related to the last state. */
2898 draw_context
.drawable
= drawing
->pixmap
;
2899 draw_context
.gc
= drawing
->gc
;
2900 draw_context
.pango_layout
= drawing
->pango_layout
;
2901 draw_context
.drawinfo
.end
.x
= x
;
2903 draw_context
.drawinfo
.y
.over
= y
+1;
2904 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2905 draw_context
.drawinfo
.y
.under
= y
+height
;
2907 draw_context
.drawinfo
.start
.offset
.over
= 0;
2908 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2909 draw_context
.drawinfo
.start
.offset
.under
= 0;
2910 draw_context
.drawinfo
.end
.offset
.over
= 0;
2911 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2912 draw_context
.drawinfo
.end
.offset
.under
= 0;
2915 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
2917 PropertiesLine prop_line
= prepare_execmode_line(process
);
2918 draw_line((void*)&prop_line
, (void*)&draw_context
);
2921 hashed_process_data
->x
.over
= x
;
2923 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2925 PropertiesLine prop_line
= prepare_status_line(process
);
2926 draw_line((void*)&prop_line
, (void*)&draw_context
);
2930 /* become the last x position */
2931 hashed_process_data
->x
.middle
= x
;
2938 int before_chunk(void *hook_data
, void *call_data
)
2940 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2941 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2943 drawing_chunk_begin(events_request
, tss
);
2948 int before_request(void *hook_data
, void *call_data
)
2950 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2951 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2953 drawing_data_request_begin(events_request
, tss
);
2960 * after request is necessary in addition of after chunk in order to draw
2961 * lines until the end of the screen. after chunk just draws lines until
2968 int after_request(void *hook_data
, void *call_data
)
2970 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2971 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2972 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2973 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2975 ProcessList
*process_list
=
2976 guicontrolflow_get_process_list(control_flow_data
);
2977 LttTime end_time
= events_request
->end_time
;
2979 ClosureData closure_data
;
2980 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2981 closure_data
.tss
= tss
;
2982 closure_data
.end_time
= end_time
;
2984 /* Draw last items */
2985 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2986 (void*)&closure_data
);
2988 /* Request expose */
2989 drawing_request_expose(events_request
, tss
, end_time
);
2998 int after_chunk(void *hook_data
, void *call_data
)
3000 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3001 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3002 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
3003 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
3004 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3007 ProcessList
*process_list
=
3008 guicontrolflow_get_process_list(control_flow_data
);
3011 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3012 else /* end of traceset, or position now out of request : end */
3013 end_time
= events_request
->end_time
;
3015 ClosureData closure_data
;
3016 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3017 closure_data
.tss
= tss
;
3018 closure_data
.end_time
= end_time
;
3020 /* Draw last items */
3021 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3022 (void*)&closure_data
);
3024 /* Request expose */
3025 drawing_request_expose(events_request
, tss
, end_time
);