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 : draw_before and draw_after hooks. The
29 * draw_before is called before the state update that occurs with an event and
30 * the draw_after hook is called after this state update.
32 * The draw_before hooks fulfill the task of drawing the visible objects that
33 * corresponds to the data accumulated by the draw_after hook.
35 * The draw_after hook accumulates the data that need to be shown on the screen
36 * (items) into a queue. Then, the next draw_before 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 draw_before
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
, LttvTracesetSelector
* s
, char * key
)
229 g_info("h_guicontrolflow, %p, %p, %s", tab
, s
, key
);
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_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_line for state : %s", g_quark_to_string(process
->state
->s
));
279 /* color of line : status of the process */
280 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
281 prop_line
.color
= drawing_colors
[COL_WHITE
];
282 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
283 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
284 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
285 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
286 else if(process
->state
->s
== LTTV_STATE_EXIT
)
287 prop_line
.color
= drawing_colors
[COL_EXIT
];
288 else if(process
->state
->s
== LTTV_STATE_WAIT
)
289 prop_line
.color
= drawing_colors
[COL_WAIT
];
290 else if(process
->state
->s
== LTTV_STATE_RUN
)
291 prop_line
.color
= drawing_colors
[COL_RUN
];
293 prop_line
.color
= drawing_colors
[COL_WHITE
];
295 //gdk_colormap_alloc_color(colormap,
308 * This function basically draw lines and icons. Two types of lines are drawn :
309 * one small (3 pixels?) representing the state of the process and the second
310 * type is thicker (10 pixels?) representing on which CPU a process is running
311 * (and this only in running state).
313 * Extremums of the lines :
314 * x_min : time of the last event context for this process kept in memory.
315 * x_max : time of the current event.
316 * y : middle of the process in the process list. The process is found in the
317 * list, therefore is it's position in pixels.
319 * The choice of lines'color is defined by the context of the last event for this
324 int draw_before_hook(void *hook_data
, void *call_data
)
326 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
327 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
328 Drawing_t
*drawing
= control_flow_data
->drawing
;
330 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
332 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
333 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
338 LttTime evtime
= ltt_event_time(e
);
339 TimeWindow time_window
=
340 lttvwindow_get_time_window(control_flow_data
->tab
);
342 LttTime end_time
= ltt_time_add(time_window
.start_time
,
343 time_window
.time_width
);
345 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
346 || ltt_time_compare(evtime
, end_time
) == 1)
349 guint width
= drawing
->width
;
351 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0) {
353 /* we are in a schedchange, before the state update. We must draw the
354 * items corresponding to the state before it changes : now is the right
361 LttField
*f
= ltt_event_field(e
);
363 element
= ltt_field_member(f
,0);
364 pid_out
= ltt_event_get_long_unsigned(e
,element
);
365 element
= ltt_field_member(f
,1);
366 pid_in
= ltt_event_get_long_unsigned(e
,element
);
367 g_debug("out : %u in : %u", pid_out
, pid_in
);
371 /* For the pid_out */
372 /* First, check if the current process is in the state computation
373 * process list. If it is there, that means we must add it right now and
374 * draw items from the beginning of the read for it. If it is not
375 * present, it's a new process and it was not present : it will
376 * be added after the state update. */
377 LttvProcessState
*process
;
378 process
= lttv_state_find_process(tfs
, pid_out
);
380 if(process
!= NULL
) {
381 /* Well, the process_out existed : we must get it in the process hash
382 * or add it, and draw its items.
384 /* Add process to process list (if not present) */
385 guint y
= 0, height
= 0, pl_height
= 0;
386 HashedProcessData
*hashed_process_data
= NULL
;
387 ProcessList
*process_list
=
388 guicontrolflow_get_process_list(control_flow_data
);
389 LttTime birth
= process
->creation_time
;
390 const gchar
*name
= g_quark_to_string(process
->name
);
392 if(processlist_get_process_pixels(process_list
,
395 tfc
->t_context
->index
,
398 &hashed_process_data
) == 1)
400 /* Process not present */
401 processlist_add(process_list
,
404 tfc
->t_context
->index
,
407 &hashed_process_data
);
408 processlist_get_process_pixels(process_list
,
411 tfc
->t_context
->index
,
414 &hashed_process_data
);
415 drawing_insert_square( drawing
, y
, height
);
418 /* Now, the process is in the state hash and our own process hash.
419 * We definitely can draw the items related to the ending state.
422 /* Check if the x position is unset. In can have been left unset by
423 * a draw closure from a after chunk hook. This should never happen,
424 * because it must be set by before chunk hook to the damage_begin
427 g_assert(hashed_process_data
->x
!= -1);
430 DrawContext draw_context
;
432 convert_time_to_pixels(
433 time_window
.start_time
,
439 /* Now create the drawing context that will be used to draw
440 * items related to the last state. */
441 draw_context
.drawable
= drawing
->pixmap
;
442 draw_context
.gc
= drawing
->gc
;
443 draw_context
.pango_layout
= drawing
->pango_layout
;
444 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
;
445 draw_context
.drawinfo
.end
.x
= x
;
447 draw_context
.drawinfo
.y
.over
= y
;
448 draw_context
.drawinfo
.y
.middle
= y
+(height
/4);
449 draw_context
.drawinfo
.y
.under
= y
+(height
/2)+2;
451 draw_context
.drawinfo
.start
.offset
.over
= 0;
452 draw_context
.drawinfo
.start
.offset
.middle
= 0;
453 draw_context
.drawinfo
.start
.offset
.under
= 0;
454 draw_context
.drawinfo
.end
.offset
.over
= 0;
455 draw_context
.drawinfo
.end
.offset
.middle
= 0;
456 draw_context
.drawinfo
.end
.offset
.under
= 0;
460 PropertiesLine prop_line
= prepare_line(process
);
461 draw_line((void*)&prop_line
, (void*)&draw_context
);
464 /* become the last x position */
465 hashed_process_data
->x
= x
;
472 /* First, check if the current process is in the state computation
473 * process list. If it is there, that means we must add it right now and
474 * draw items from the beginning of the read for it. If it is not
475 * present, it's a new process and it was not present : it will
476 * be added after the state update. */
477 LttvProcessState
*process
;
478 process
= lttv_state_find_process(tfs
, pid_in
);
480 if(process
!= NULL
) {
481 /* Well, the process_out existed : we must get it in the process hash
482 * or add it, and draw its items.
484 /* Add process to process list (if not present) */
485 guint y
= 0, height
= 0, pl_height
= 0;
486 HashedProcessData
*hashed_process_data
= NULL
;
487 ProcessList
*process_list
=
488 guicontrolflow_get_process_list(control_flow_data
);
489 LttTime birth
= process
->creation_time
;
490 const gchar
*name
= g_quark_to_string(process
->name
);
492 if(processlist_get_process_pixels(process_list
,
495 tfc
->t_context
->index
,
498 &hashed_process_data
) == 1)
500 /* Process not present */
501 processlist_add(process_list
,
504 tfc
->t_context
->index
,
507 &hashed_process_data
);
508 processlist_get_process_pixels(process_list
,
511 tfc
->t_context
->index
,
514 &hashed_process_data
);
515 drawing_insert_square( drawing
, y
, height
);
518 /* Now, the process is in the state hash and our own process hash.
519 * We definitely can draw the items related to the ending state.
522 /* Check if the x position is unset. In can have been left unset by
523 * a draw closure from a after chunk hook. This should never happen,
524 * because it must be set by before chunk hook to the damage_begin
527 g_assert(hashed_process_data
->x
!= -1);
530 DrawContext draw_context
;
532 convert_time_to_pixels(
533 time_window
.start_time
,
539 /* Now create the drawing context that will be used to draw
540 * items related to the last state. */
541 draw_context
.drawable
= drawing
->pixmap
;
542 draw_context
.gc
= drawing
->gc
;
543 draw_context
.pango_layout
= drawing
->pango_layout
;
544 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
;
545 draw_context
.drawinfo
.end
.x
= x
;
547 draw_context
.drawinfo
.y
.over
= y
;
548 draw_context
.drawinfo
.y
.middle
= y
+(height
/4);
549 draw_context
.drawinfo
.y
.under
= y
+(height
/2)+2;
551 draw_context
.drawinfo
.start
.offset
.over
= 0;
552 draw_context
.drawinfo
.start
.offset
.middle
= 0;
553 draw_context
.drawinfo
.start
.offset
.under
= 0;
554 draw_context
.drawinfo
.end
.offset
.over
= 0;
555 draw_context
.drawinfo
.end
.offset
.middle
= 0;
556 draw_context
.drawinfo
.end
.offset
.under
= 0;
560 PropertiesLine prop_line
= prepare_line(process
);
561 draw_line((void*)&prop_line
, (void*)&draw_context
);
565 /* become the last x position */
566 hashed_process_data
->x
= x
;
577 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
578 ControlFlowData
*control_flow_data
=
579 (ControlFlowData
*)events_request
->viewer_data
;
580 Tab
*tab
= control_flow_data
->tab
;
582 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
584 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
585 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
590 LttTime evtime
= ltt_event_time(e
);
591 TimeWindow time_window
=
592 lttvwindow_get_time_window(tab
);
594 LttTime end_time
= ltt_time_add(time_window
.start_time
,
595 time_window
.time_width
);
596 //if(time < time_beg || time > time_end) return;
597 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
598 || ltt_time_compare(evtime
, end_time
) == 1)
601 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
603 g_debug("schedchange!");
605 /* Add process to process list (if not present) and get drawing "y" from
606 * process position */
607 guint pid_out
, pid_in
;
608 LttvProcessState
*process_out
, *process_in
;
610 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
612 ProcessList
*process_list
=
613 guicontrolflow_get_process_list(control_flow_data
);
616 LttField
*f
= ltt_event_field(e
);
618 element
= ltt_field_member(f
,0);
619 pid_out
= ltt_event_get_long_unsigned(e
,element
);
620 element
= ltt_field_member(f
,1);
621 pid_in
= ltt_event_get_long_unsigned(e
,element
);
622 g_debug("out : %u in : %u", pid_out
, pid_in
);
625 /* Find process pid_out in the list... */
626 process_out
= lttv_state_find_process(tfs
, pid_out
);
627 if(process_out
== NULL
) return 0;
628 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
630 birth
= process_out
->creation_time
;
631 const gchar
*name
= g_quark_to_string(process_out
->name
);
632 HashedProcessData
*hashed_process_data_out
= NULL
;
634 if(processlist_get_process_pixels(process_list
,
637 tfc
->t_context
->index
,
640 &hashed_process_data_out
) == 1)
642 /* Process not present */
643 processlist_add(process_list
,
646 tfc
->t_context
->index
,
649 &hashed_process_data_out
);
650 g_assert(processlist_get_process_pixels(process_list
,
653 tfc
->t_context
->index
,
656 &hashed_process_data_out
)==0);
657 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
661 /* Find process pid_in in the list... */
662 process_in
= lttv_state_find_process(tfs
, pid_in
);
663 if(process_in
== NULL
) return 0;
664 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
666 birth
= process_in
->creation_time
;
667 name
= g_quark_to_string(process_in
->name
);
668 HashedProcessData
*hashed_process_data_in
= NULL
;
670 if(processlist_get_process_pixels(process_list
,
673 tfc
->t_context
->index
,
676 &hashed_process_data_in
) == 1)
678 /* Process not present */
679 processlist_add(process_list
,
682 tfc
->t_context
->index
,
685 &hashed_process_data_in
);
686 processlist_get_process_pixels(process_list
,
689 tfc
->t_context
->index
,
692 &hashed_process_data_in
);
694 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
699 /* Find pixels corresponding to time of the event. If the time does
700 * not fit in the window, show a warning, not supposed to happend. */
702 guint width
= control_flow_data
->drawing
->width
;
704 LttTime time
= ltt_event_time(e
);
706 LttTime window_end
= ltt_time_add(time_window
.time_width
,
707 time_window
.start_time
);
710 convert_time_to_pixels(
711 time_window
.start_time
,
716 //assert(x <= width);
718 /* draw what represents the event for outgoing process. */
720 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
721 draw_context_out
->current
->modify_over
->x
= x
;
722 draw_context_out
->current
->modify_under
->x
= x
;
723 draw_context_out
->current
->modify_over
->y
= y_out
;
724 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
725 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
726 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
727 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
728 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
729 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
730 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
731 //draw_context_out->gc = widget->style->black_gc;
733 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
734 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
736 /* Draw the line/background of the out process */
737 if(draw_context_out
->previous
->middle
->x
== -1)
739 draw_context_out
->previous
->over
->x
=
740 control_flow_data
->drawing
->damage_begin
;
741 draw_context_out
->previous
->middle
->x
=
742 control_flow_data
->drawing
->damage_begin
;
743 draw_context_out
->previous
->under
->x
=
744 control_flow_data
->drawing
->damage_begin
;
746 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
749 draw_context_out
->current
->middle
->x
= x
;
750 draw_context_out
->current
->over
->x
= x
;
751 draw_context_out
->current
->under
->x
= x
;
752 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
753 draw_context_out
->current
->over
->y
= y_out
;
754 draw_context_out
->current
->under
->y
= y_out
+ height
;
755 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
756 draw_context_out
->previous
->over
->y
= y_out
;
757 draw_context_out
->previous
->under
->y
= y_out
+ height
;
759 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
760 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
762 if(process_out
->state
->s
== LTTV_STATE_RUN
)
764 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
765 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
766 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
768 PropertiesBG prop_bg
;
769 prop_bg
.color
= g_new(GdkColor
,1);
773 prop_bg
.color
->red
= 0x1515;
774 prop_bg
.color
->green
= 0x1515;
775 prop_bg
.color
->blue
= 0x8c8c;
778 prop_bg
.color
->red
= 0x4e4e;
779 prop_bg
.color
->green
= 0xa9a9;
780 prop_bg
.color
->blue
= 0xa4a4;
783 prop_bg
.color
->red
= 0x7a7a;
784 prop_bg
.color
->green
= 0x4a4a;
785 prop_bg
.color
->blue
= 0x8b8b;
788 prop_bg
.color
->red
= 0x8080;
789 prop_bg
.color
->green
= 0x7777;
790 prop_bg
.color
->blue
= 0x4747;
793 prop_bg
.color
->red
= 0xe7e7;
794 prop_bg
.color
->green
= 0xe7e7;
795 prop_bg
.color
->blue
= 0xe7e7;
798 g_debug("calling from draw_event");
799 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
800 g_free(prop_bg
.color
);
801 //gdk_gc_unref(draw_context_out->gc);
804 draw_context_out
->gc
= widget
->style
->black_gc
;
806 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
807 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
808 PropertiesText prop_text_out
;
809 prop_text_out
.foreground
= &colorfg_out
;
810 prop_text_out
.background
= &colorbg_out
;
811 prop_text_out
.size
= 6;
812 prop_text_out
.position
= OVER
;
814 /* color of text : status of the process */
815 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
817 prop_text_out
.foreground
->red
= 0xffff;
818 prop_text_out
.foreground
->green
= 0xffff;
819 prop_text_out
.foreground
->blue
= 0xffff;
821 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
823 prop_text_out
.foreground
->red
= 0x0fff;
824 prop_text_out
.foreground
->green
= 0xffff;
825 prop_text_out
.foreground
->blue
= 0xfff0;
827 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
829 prop_text_out
.foreground
->red
= 0xffff;
830 prop_text_out
.foreground
->green
= 0xffff;
831 prop_text_out
.foreground
->blue
= 0x0000;
833 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
835 prop_text_out
.foreground
->red
= 0xffff;
836 prop_text_out
.foreground
->green
= 0x0000;
837 prop_text_out
.foreground
->blue
= 0xffff;
839 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
841 prop_text_out
.foreground
->red
= 0xffff;
842 prop_text_out
.foreground
->green
= 0x0000;
843 prop_text_out
.foreground
->blue
= 0x0000;
845 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
847 prop_text_out
.foreground
->red
= 0x0000;
848 prop_text_out
.foreground
->green
= 0xffff;
849 prop_text_out
.foreground
->blue
= 0x0000;
853 prop_text_out
.foreground
->red
= 0xffff;
854 prop_text_out
.foreground
->green
= 0xffff;
855 prop_text_out
.foreground
->blue
= 0xffff;
859 /* Print status of the process : U, WF, WC, E, W, R */
860 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
861 prop_text_out
.text
= "U->";
862 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
863 prop_text_out
.text
= "WF->";
864 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
865 prop_text_out
.text
= "WC->";
866 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
867 prop_text_out
.text
= "E->";
868 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
869 prop_text_out
.text
= "W->";
870 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
871 prop_text_out
.text
= "R->";
873 prop_text_out
.text
= "U";
875 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
876 //gdk_gc_unref(draw_context_out->gc);
878 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
879 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
880 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
882 PropertiesLine prop_line_out
;
883 prop_line_out
.color
= g_new(GdkColor
,1);
884 prop_line_out
.line_width
= 2;
885 prop_line_out
.style
= GDK_LINE_SOLID
;
886 prop_line_out
.position
= MIDDLE
;
888 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
890 /* color of line : status of the process */
891 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
893 prop_line_out
.color
->red
= 0xffff;
894 prop_line_out
.color
->green
= 0xffff;
895 prop_line_out
.color
->blue
= 0xffff;
897 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
899 prop_line_out
.color
->red
= 0x0fff;
900 prop_line_out
.color
->green
= 0xffff;
901 prop_line_out
.color
->blue
= 0xfff0;
903 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
905 prop_line_out
.color
->red
= 0xffff;
906 prop_line_out
.color
->green
= 0xffff;
907 prop_line_out
.color
->blue
= 0x0000;
909 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
911 prop_line_out
.color
->red
= 0xffff;
912 prop_line_out
.color
->green
= 0x0000;
913 prop_line_out
.color
->blue
= 0xffff;
915 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
917 prop_line_out
.color
->red
= 0xffff;
918 prop_line_out
.color
->green
= 0x0000;
919 prop_line_out
.color
->blue
= 0x0000;
921 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
923 prop_line_out
.color
->red
= 0x0000;
924 prop_line_out
.color
->green
= 0xffff;
925 prop_line_out
.color
->blue
= 0x0000;
929 prop_line_out
.color
->red
= 0xffff;
930 prop_line_out
.color
->green
= 0xffff;
931 prop_line_out
.color
->blue
= 0xffff;
934 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
935 g_free(prop_line_out
.color
);
936 //gdk_gc_unref(draw_context_out->gc);
937 /* Note : finishing line will have to be added when trace read over. */
939 /* Finally, update the drawing context of the pid_in. */
941 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
942 draw_context_in
->current
->modify_over
->x
= x
;
943 draw_context_in
->current
->modify_under
->x
= x
;
944 draw_context_in
->current
->modify_over
->y
= y_in
;
945 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
946 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
947 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
948 widget
= control_flow_data
->drawing
->drawing_area
;
949 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
950 //draw_context_in->gc = widget->style->black_gc;
951 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
952 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
954 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
955 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
957 /* Draw the line/bg of the in process */
958 if(draw_context_in
->previous
->middle
->x
== -1)
960 draw_context_in
->previous
->over
->x
=
961 control_flow_data
->drawing
->damage_begin
;
962 draw_context_in
->previous
->middle
->x
=
963 control_flow_data
->drawing
->damage_begin
;
964 draw_context_in
->previous
->under
->x
=
965 control_flow_data
->drawing
->damage_begin
;
967 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
971 draw_context_in
->current
->middle
->x
= x
;
972 draw_context_in
->current
->over
->x
= x
;
973 draw_context_in
->current
->under
->x
= x
;
974 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
975 draw_context_in
->current
->over
->y
= y_in
;
976 draw_context_in
->current
->under
->y
= y_in
+ height
;
977 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
978 draw_context_in
->previous
->over
->y
= y_in
;
979 draw_context_in
->previous
->under
->y
= y_in
+ height
;
981 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
982 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
985 if(process_in
->state
->s
== LTTV_STATE_RUN
)
987 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
988 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
989 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
991 PropertiesBG prop_bg
;
992 prop_bg
.color
= g_new(GdkColor
,1);
996 prop_bg
.color
->red
= 0x1515;
997 prop_bg
.color
->green
= 0x1515;
998 prop_bg
.color
->blue
= 0x8c8c;
1001 prop_bg
.color
->red
= 0x4e4e;
1002 prop_bg
.color
->green
= 0xa9a9;
1003 prop_bg
.color
->blue
= 0xa4a4;
1006 prop_bg
.color
->red
= 0x7a7a;
1007 prop_bg
.color
->green
= 0x4a4a;
1008 prop_bg
.color
->blue
= 0x8b8b;
1011 prop_bg
.color
->red
= 0x8080;
1012 prop_bg
.color
->green
= 0x7777;
1013 prop_bg
.color
->blue
= 0x4747;
1016 prop_bg
.color
->red
= 0xe7e7;
1017 prop_bg
.color
->green
= 0xe7e7;
1018 prop_bg
.color
->blue
= 0xe7e7;
1022 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1023 g_free(prop_bg
.color
);
1024 //gdk_gc_unref(draw_context_in->gc);
1027 draw_context_in
->gc
= widget
->style
->black_gc
;
1029 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1030 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1031 PropertiesText prop_text_in
;
1032 prop_text_in
.foreground
= &colorfg_in
;
1033 prop_text_in
.background
= &colorbg_in
;
1034 prop_text_in
.size
= 6;
1035 prop_text_in
.position
= OVER
;
1037 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1038 /* foreground of text : status of the process */
1039 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1041 prop_text_in
.foreground
->red
= 0xffff;
1042 prop_text_in
.foreground
->green
= 0xffff;
1043 prop_text_in
.foreground
->blue
= 0xffff;
1045 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1047 prop_text_in
.foreground
->red
= 0x0fff;
1048 prop_text_in
.foreground
->green
= 0xffff;
1049 prop_text_in
.foreground
->blue
= 0xfff0;
1051 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1053 prop_text_in
.foreground
->red
= 0xffff;
1054 prop_text_in
.foreground
->green
= 0xffff;
1055 prop_text_in
.foreground
->blue
= 0x0000;
1057 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1059 prop_text_in
.foreground
->red
= 0xffff;
1060 prop_text_in
.foreground
->green
= 0x0000;
1061 prop_text_in
.foreground
->blue
= 0xffff;
1063 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1065 prop_text_in
.foreground
->red
= 0xffff;
1066 prop_text_in
.foreground
->green
= 0x0000;
1067 prop_text_in
.foreground
->blue
= 0x0000;
1069 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1071 prop_text_in
.foreground
->red
= 0x0000;
1072 prop_text_in
.foreground
->green
= 0xffff;
1073 prop_text_in
.foreground
->blue
= 0x0000;
1077 prop_text_in
.foreground
->red
= 0xffff;
1078 prop_text_in
.foreground
->green
= 0xffff;
1079 prop_text_in
.foreground
->blue
= 0xffff;
1084 /* Print status of the process : U, WF, WC, E, W, R */
1085 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1086 prop_text_in
.text
= "U->";
1087 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1088 prop_text_in
.text
= "WF->";
1089 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1090 prop_text_in
.text
= "WC->";
1091 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1092 prop_text_in
.text
= "E->";
1093 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1094 prop_text_in
.text
= "W->";
1095 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1096 prop_text_in
.text
= "R->";
1098 prop_text_in
.text
= "U";
1100 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1101 //gdk_gc_unref(draw_context_in->gc);
1103 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1104 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1105 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1107 PropertiesLine prop_line_in
;
1108 prop_line_in
.color
= g_new(GdkColor
,1);
1109 prop_line_in
.line_width
= 2;
1110 prop_line_in
.style
= GDK_LINE_SOLID
;
1111 prop_line_in
.position
= MIDDLE
;
1113 /* color of line : status of the process */
1114 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1116 prop_line_in
.color
->red
= 0xffff;
1117 prop_line_in
.color
->green
= 0xffff;
1118 prop_line_in
.color
->blue
= 0xffff;
1120 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1122 prop_line_in
.color
->red
= 0x0fff;
1123 prop_line_in
.color
->green
= 0xffff;
1124 prop_line_in
.color
->blue
= 0xfff0;
1126 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1128 prop_line_in
.color
->red
= 0xffff;
1129 prop_line_in
.color
->green
= 0xffff;
1130 prop_line_in
.color
->blue
= 0x0000;
1132 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1134 prop_line_in
.color
->red
= 0xffff;
1135 prop_line_in
.color
->green
= 0x0000;
1136 prop_line_in
.color
->blue
= 0xffff;
1138 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1140 prop_line_in
.color
->red
= 0xffff;
1141 prop_line_in
.color
->green
= 0x0000;
1142 prop_line_in
.color
->blue
= 0x0000;
1144 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1146 prop_line_in
.color
->red
= 0x0000;
1147 prop_line_in
.color
->green
= 0xffff;
1148 prop_line_in
.color
->blue
= 0x0000;
1152 prop_line_in
.color
->red
= 0xffff;
1153 prop_line_in
.color
->green
= 0xffff;
1154 prop_line_in
.color
->blue
= 0xffff;
1157 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1158 g_free(prop_line_in
.color
);
1159 //gdk_gc_unref(draw_context_in->gc);
1169 GString
*string
= g_string_new("");;
1170 gboolean field_names
= TRUE
, state
= TRUE
;
1172 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1173 g_string_append_printf(string
,"\n");
1176 g_string_append_printf(string
, " %s",
1177 g_quark_to_string(tfs
->process
->state
->s
));
1180 g_info("%s",string
->str
);
1182 g_string_free(string
, TRUE
);
1184 /* End of text dump */
1191 * The draw after hook is called by the reading API to have a
1192 * particular event drawn on the screen.
1193 * @param hook_data ControlFlowData structure of the viewer.
1194 * @param call_data Event context.
1196 * This function adds items to be drawn in a queue for each process.
1199 int draw_after_hook(void *hook_data
, void *call_data
)
1201 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1202 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1204 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1206 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1207 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1212 LttTime evtime
= ltt_event_time(e
);
1213 TimeWindow time_window
=
1214 lttvwindow_get_time_window(control_flow_data
->tab
);
1216 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1217 time_window
.time_width
);
1219 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1220 || ltt_time_compare(evtime
, end_time
) == 1)
1223 guint width
= control_flow_data
->drawing
->width
;
1225 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0) {
1227 g_debug("schedchange!");
1230 /* Add process to process list (if not present) */
1231 LttvProcessState
*process_out
, *process_in
;
1233 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1234 HashedProcessData
*hashed_process_data_in
= NULL
;
1236 ProcessList
*process_list
=
1237 guicontrolflow_get_process_list(control_flow_data
);
1242 LttField
*f
= ltt_event_field(e
);
1244 element
= ltt_field_member(f
,0);
1245 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1246 element
= ltt_field_member(f
,1);
1247 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1248 g_debug("out : %u in : %u", pid_out
, pid_in
);
1252 /* Find process pid_in in the list... */
1253 process_in
= lttv_state_find_process(tfs
, pid_in
);
1254 /* It should exist, because we are after the state update. */
1255 g_assert(process_in
!= NULL
);
1257 birth
= process_in
->creation_time
;
1258 const gchar
*name
= g_quark_to_string(process_in
->name
);
1260 if(processlist_get_process_pixels(process_list
,
1263 tfc
->t_context
->index
,
1266 &hashed_process_data_in
) == 1)
1268 /* Process not present */
1269 processlist_add(process_list
,
1272 tfc
->t_context
->index
,
1275 &hashed_process_data_in
);
1276 processlist_get_process_pixels(process_list
,
1279 tfc
->t_context
->index
,
1282 &hashed_process_data_in
);
1283 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1286 convert_time_to_pixels(
1287 time_window
.start_time
,
1291 &hashed_process_data_in
->x
);
1299 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1300 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1302 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1304 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1305 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1311 LttTime evtime
= ltt_event_time(e
);
1312 TimeWindow time_window
=
1313 lttvwindow_get_time_window(control_flow_data
->tab
);
1315 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1316 time_window
.time_width
);
1317 //if(time < time_beg || time > time_end) return;
1318 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1319 || ltt_time_compare(evtime
, end_time
) == 1)
1323 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1325 g_debug("schedchange!");
1327 /* Add process to process list (if not present) and get drawing "y" from
1328 * process position */
1329 guint pid_out
, pid_in
;
1330 LttvProcessState
*process_out
, *process_in
;
1332 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1334 ProcessList
*process_list
=
1335 guicontrolflow_get_process_list(control_flow_data
);
1338 LttField
*f
= ltt_event_field(e
);
1340 element
= ltt_field_member(f
,0);
1341 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1342 element
= ltt_field_member(f
,1);
1343 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1344 //g_debug("out : %u in : %u", pid_out, pid_in);
1347 /* Find process pid_out in the list... */
1348 process_out
= lttv_state_find_process(tfs
, pid_out
);
1349 if(process_out
== NULL
) return 0;
1350 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1352 birth
= process_out
->creation_time
;
1353 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1354 HashedProcessData
*hashed_process_data_out
= NULL
;
1356 if(processlist_get_process_pixels(process_list
,
1359 tfc
->t_context
->index
,
1362 &hashed_process_data_out
) == 1)
1364 /* Process not present */
1365 processlist_add(process_list
,
1368 tfc
->t_context
->index
,
1371 &hashed_process_data_out
);
1372 processlist_get_process_pixels(process_list
,
1375 tfc
->t_context
->index
,
1378 &hashed_process_data_out
);
1379 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1384 /* Find process pid_in in the list... */
1385 process_in
= lttv_state_find_process(tfs
, pid_in
);
1386 if(process_in
== NULL
) return 0;
1387 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1389 birth
= process_in
->creation_time
;
1390 name
= strdup(g_quark_to_string(process_in
->name
));
1391 HashedProcessData
*hashed_process_data_in
= NULL
;
1393 if(processlist_get_process_pixels(process_list
,
1396 tfc
->t_context
->index
,
1399 &hashed_process_data_in
) == 1)
1401 /* Process not present */
1402 processlist_add(process_list
,
1405 tfc
->t_context
->index
,
1408 &hashed_process_data_in
);
1409 processlist_get_process_pixels(process_list
,
1412 tfc
->t_context
->index
,
1415 &hashed_process_data_in
);
1417 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1422 /* Find pixels corresponding to time of the event. If the time does
1423 * not fit in the window, show a warning, not supposed to happend. */
1425 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1427 //LttTime time = ltt_event_time(e);
1429 //LttTime window_end = ltt_time_add(time_window->time_width,
1430 // time_window->start_time);
1433 //convert_time_to_pixels(
1434 // time_window->start_time,
1440 //assert(x <= width);
1442 /* draw what represents the event for outgoing process. */
1444 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1445 //draw_context_out->current->modify_over->x = x;
1446 draw_context_out
->current
->modify_over
->y
= y_out
;
1447 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1448 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1449 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1450 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1451 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1453 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1454 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1456 /*if(process_out->state->s == LTTV_STATE_RUN)
1458 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1459 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1460 PropertiesBG prop_bg;
1461 prop_bg.color = g_new(GdkColor,1);
1463 prop_bg.color->red = 0xffff;
1464 prop_bg.color->green = 0xffff;
1465 prop_bg.color->blue = 0xffff;
1467 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1468 g_free(prop_bg.color);
1469 gdk_gc_unref(draw_context_out->gc);
1472 draw_context_out
->gc
= widget
->style
->black_gc
;
1474 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1475 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1476 PropertiesText prop_text_out
;
1477 prop_text_out
.foreground
= &colorfg_out
;
1478 prop_text_out
.background
= &colorbg_out
;
1479 prop_text_out
.size
= 6;
1480 prop_text_out
.position
= OVER
;
1482 /* color of text : status of the process */
1483 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1485 prop_text_out
.foreground
->red
= 0xffff;
1486 prop_text_out
.foreground
->green
= 0xffff;
1487 prop_text_out
.foreground
->blue
= 0xffff;
1489 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1491 prop_text_out
.foreground
->red
= 0x0fff;
1492 prop_text_out
.foreground
->green
= 0xffff;
1493 prop_text_out
.foreground
->blue
= 0xfff0;
1495 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1497 prop_text_out
.foreground
->red
= 0xffff;
1498 prop_text_out
.foreground
->green
= 0xffff;
1499 prop_text_out
.foreground
->blue
= 0x0000;
1501 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
1503 prop_text_out
.foreground
->red
= 0xffff;
1504 prop_text_out
.foreground
->green
= 0x0000;
1505 prop_text_out
.foreground
->blue
= 0xffff;
1507 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1509 prop_text_out
.foreground
->red
= 0xffff;
1510 prop_text_out
.foreground
->green
= 0x0000;
1511 prop_text_out
.foreground
->blue
= 0x0000;
1513 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1515 prop_text_out
.foreground
->red
= 0x0000;
1516 prop_text_out
.foreground
->green
= 0xffff;
1517 prop_text_out
.foreground
->blue
= 0x0000;
1521 prop_text_out
.foreground
->red
= 0xffff;
1522 prop_text_out
.foreground
->green
= 0xffff;
1523 prop_text_out
.foreground
->blue
= 0xffff;
1526 /* Print status of the process : U, WF, WC, E, W, R */
1527 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1528 prop_text_out
.text
= "U";
1529 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1530 prop_text_out
.text
= "WF";
1531 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1532 prop_text_out
.text
= "WC";
1533 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
1534 prop_text_out
.text
= "E";
1535 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1536 prop_text_out
.text
= "W";
1537 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1538 prop_text_out
.text
= "R";
1540 prop_text_out
.text
= "U";
1542 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1544 //gdk_gc_unref(draw_context_out->gc);
1546 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1547 draw_context_out
->current
->over
->y
= y_out
;
1548 draw_context_out
->current
->under
->y
= y_out
+height
;
1549 draw_context_out
->current
->status
= process_out
->state
->s
;
1551 /* for pid_out : remove previous, Prev = current, new current (default) */
1552 g_free(draw_context_out
->previous
->modify_under
);
1553 g_free(draw_context_out
->previous
->modify_middle
);
1554 g_free(draw_context_out
->previous
->modify_over
);
1555 g_free(draw_context_out
->previous
->under
);
1556 g_free(draw_context_out
->previous
->middle
);
1557 g_free(draw_context_out
->previous
->over
);
1558 g_free(draw_context_out
->previous
);
1560 draw_context_out
->previous
= draw_context_out
->current
;
1562 draw_context_out
->current
= g_new(DrawInfo
,1);
1563 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1564 draw_context_out
->current
->over
->x
= -1;
1565 draw_context_out
->current
->over
->y
= -1;
1566 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1567 draw_context_out
->current
->middle
->x
= -1;
1568 draw_context_out
->current
->middle
->y
= -1;
1569 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1570 draw_context_out
->current
->under
->x
= -1;
1571 draw_context_out
->current
->under
->y
= -1;
1572 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1573 draw_context_out
->current
->modify_over
->x
= -1;
1574 draw_context_out
->current
->modify_over
->y
= -1;
1575 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1576 draw_context_out
->current
->modify_middle
->x
= -1;
1577 draw_context_out
->current
->modify_middle
->y
= -1;
1578 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1579 draw_context_out
->current
->modify_under
->x
= -1;
1580 draw_context_out
->current
->modify_under
->y
= -1;
1581 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1583 /* Finally, update the drawing context of the pid_in. */
1585 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1586 //draw_context_in->current->modify_over->x = x;
1587 draw_context_in
->current
->modify_over
->y
= y_in
;
1588 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1589 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1590 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1591 widget
= control_flow_data
->drawing
->drawing_area
;
1592 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1594 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1595 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1597 /*if(process_in->state->s == LTTV_STATE_RUN)
1599 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1600 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1601 PropertiesBG prop_bg;
1602 prop_bg.color = g_new(GdkColor,1);
1604 prop_bg.color->red = 0xffff;
1605 prop_bg.color->green = 0xffff;
1606 prop_bg.color->blue = 0xffff;
1608 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1609 g_free(prop_bg.color);
1610 gdk_gc_unref(draw_context_in->gc);
1613 draw_context_in
->gc
= widget
->style
->black_gc
;
1615 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1616 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1617 PropertiesText prop_text_in
;
1618 prop_text_in
.foreground
= &colorfg_in
;
1619 prop_text_in
.background
= &colorbg_in
;
1620 prop_text_in
.size
= 6;
1621 prop_text_in
.position
= OVER
;
1623 /* foreground of text : status of the process */
1624 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1626 prop_text_in
.foreground
->red
= 0xffff;
1627 prop_text_in
.foreground
->green
= 0xffff;
1628 prop_text_in
.foreground
->blue
= 0xffff;
1630 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1632 prop_text_in
.foreground
->red
= 0x0fff;
1633 prop_text_in
.foreground
->green
= 0xffff;
1634 prop_text_in
.foreground
->blue
= 0xfff0;
1636 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1638 prop_text_in
.foreground
->red
= 0xffff;
1639 prop_text_in
.foreground
->green
= 0xffff;
1640 prop_text_in
.foreground
->blue
= 0x0000;
1642 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1644 prop_text_in
.foreground
->red
= 0xffff;
1645 prop_text_in
.foreground
->green
= 0x0000;
1646 prop_text_in
.foreground
->blue
= 0xffff;
1648 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1650 prop_text_in
.foreground
->red
= 0xffff;
1651 prop_text_in
.foreground
->green
= 0x0000;
1652 prop_text_in
.foreground
->blue
= 0x0000;
1654 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1656 prop_text_in
.foreground
->red
= 0x0000;
1657 prop_text_in
.foreground
->green
= 0xffff;
1658 prop_text_in
.foreground
->blue
= 0x0000;
1662 prop_text_in
.foreground
->red
= 0xffff;
1663 prop_text_in
.foreground
->green
= 0xffff;
1664 prop_text_in
.foreground
->blue
= 0xffff;
1668 /* Print status of the process : U, WF, WC, E, W, R */
1669 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1670 prop_text_in
.text
= "U";
1671 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1672 prop_text_in
.text
= "WF";
1673 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1674 prop_text_in
.text
= "WC";
1675 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1676 prop_text_in
.text
= "E";
1677 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1678 prop_text_in
.text
= "W";
1679 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1680 prop_text_in
.text
= "R";
1682 prop_text_in
.text
= "U";
1684 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1687 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1690 prop_text_in
.foreground
= &colorfg_in
;
1691 prop_text_in
.background
= &colorbg_in
;
1692 prop_text_in
.foreground
->red
= 0xffff;
1693 prop_text_in
.foreground
->green
= 0xffff;
1694 prop_text_in
.foreground
->blue
= 0xffff;
1695 prop_text_in
.size
= 6;
1696 prop_text_in
.position
= UNDER
;
1698 prop_text_in
.text
= g_new(gchar
, 260);
1699 strcpy(prop_text_in
.text
, "CPU ");
1700 snprintf(tmp
, 255, "%u", tfc
->index
);
1701 strcat(prop_text_in
.text
, tmp
);
1703 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1704 g_free(prop_text_in
.text
);
1708 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1709 draw_context_in
->current
->over
->y
= y_in
;
1710 draw_context_in
->current
->under
->y
= y_in
+height
;
1711 draw_context_in
->current
->status
= process_in
->state
->s
;
1713 /* for pid_in : remove previous, Prev = current, new current (default) */
1714 g_free(draw_context_in
->previous
->modify_under
);
1715 g_free(draw_context_in
->previous
->modify_middle
);
1716 g_free(draw_context_in
->previous
->modify_over
);
1717 g_free(draw_context_in
->previous
->under
);
1718 g_free(draw_context_in
->previous
->middle
);
1719 g_free(draw_context_in
->previous
->over
);
1720 g_free(draw_context_in
->previous
);
1722 draw_context_in
->previous
= draw_context_in
->current
;
1724 draw_context_in
->current
= g_new(DrawInfo
,1);
1725 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1726 draw_context_in
->current
->over
->x
= -1;
1727 draw_context_in
->current
->over
->y
= -1;
1728 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1729 draw_context_in
->current
->middle
->x
= -1;
1730 draw_context_in
->current
->middle
->y
= -1;
1731 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1732 draw_context_in
->current
->under
->x
= -1;
1733 draw_context_in
->current
->under
->y
= -1;
1734 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1735 draw_context_in
->current
->modify_over
->x
= -1;
1736 draw_context_in
->current
->modify_over
->y
= -1;
1737 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1738 draw_context_in
->current
->modify_middle
->x
= -1;
1739 draw_context_in
->current
->modify_middle
->y
= -1;
1740 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1741 draw_context_in
->current
->modify_under
->x
= -1;
1742 draw_context_in
->current
->modify_under
->y
= -1;
1743 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1754 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1756 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1757 Drawing_t
*drawing
= control_flow_data
->drawing
;
1759 const TimeWindowNotifyData
*time_window_nofify_data
=
1760 ((const TimeWindowNotifyData
*)call_data
);
1762 TimeWindow
*old_time_window
=
1763 time_window_nofify_data
->old_time_window
;
1764 TimeWindow
*new_time_window
=
1765 time_window_nofify_data
->new_time_window
;
1767 /* Update the ruler */
1768 drawing_update_ruler(control_flow_data
->drawing
,
1772 /* Two cases : zoom in/out or scrolling */
1774 /* In order to make sure we can reuse the old drawing, the scale must
1775 * be the same and the new time interval being partly located in the
1776 * currently shown time interval. (reuse is only for scrolling)
1779 g_info("Old time window HOOK : %u, %u to %u, %u",
1780 old_time_window
->start_time
.tv_sec
,
1781 old_time_window
->start_time
.tv_nsec
,
1782 old_time_window
->time_width
.tv_sec
,
1783 old_time_window
->time_width
.tv_nsec
);
1785 g_info("New time window HOOK : %u, %u to %u, %u",
1786 new_time_window
->start_time
.tv_sec
,
1787 new_time_window
->start_time
.tv_nsec
,
1788 new_time_window
->time_width
.tv_sec
,
1789 new_time_window
->time_width
.tv_nsec
);
1791 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1792 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1794 /* Same scale (scrolling) */
1795 g_info("scrolling");
1796 LttTime
*ns
= &new_time_window
->start_time
;
1797 LttTime
*os
= &old_time_window
->start_time
;
1798 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
1799 old_time_window
->time_width
);
1800 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
1801 new_time_window
->time_width
);
1803 //if(ns<os+w && os+w<ns+w)
1804 //if(ns<old_end && os<ns)
1805 if(ltt_time_compare(*ns
, old_end
) == -1
1806 && ltt_time_compare(*os
, *ns
) == -1)
1808 g_info("scrolling near right");
1809 /* Scroll right, keep right part of the screen */
1811 guint width
= control_flow_data
->drawing
->width
;
1812 convert_time_to_pixels(
1819 /* Copy old data to new location */
1820 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1821 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1822 control_flow_data
->drawing
->pixmap
,
1825 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
1827 if(drawing
->damage_begin
== drawing
->damage_end
)
1828 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
1830 drawing
->damage_begin
= 0;
1832 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1834 /* Clear the data request background, but not SAFETY */
1835 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1836 //control_flow_data->drawing->drawing_area->style->black_gc,
1837 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1839 drawing
->damage_begin
+SAFETY
, 0,
1840 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1841 control_flow_data
->drawing
->height
);
1843 gtk_widget_queue_draw_area (drawing
->drawing_area
,
1845 control_flow_data
->drawing
->width
,
1846 control_flow_data
->drawing
->height
);
1848 /* Get new data for the rest. */
1849 drawing_data_request(control_flow_data
->drawing
,
1850 &control_flow_data
->drawing
->pixmap
,
1851 drawing
->damage_begin
, 0,
1852 drawing
->damage_end
- drawing
->damage_begin
,
1853 control_flow_data
->drawing
->height
);
1856 //if(ns<os && os<ns+w)
1857 //if(ns<os && os<new_end)
1858 if(ltt_time_compare(*ns
,*os
) == -1
1859 && ltt_time_compare(*os
,new_end
) == -1)
1861 g_info("scrolling near left");
1862 /* Scroll left, keep left part of the screen */
1864 guint width
= control_flow_data
->drawing
->width
;
1865 convert_time_to_pixels(
1873 /* Copy old data to new location */
1874 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1875 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1876 control_flow_data
->drawing
->pixmap
,
1881 if(drawing
->damage_begin
== drawing
->damage_end
)
1882 drawing
->damage_end
= x
;
1884 drawing
->damage_end
=
1885 control_flow_data
->drawing
->width
;
1887 drawing
->damage_begin
= 0;
1889 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1890 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1892 drawing
->damage_begin
, 0,
1893 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1894 control_flow_data
->drawing
->height
);
1896 gtk_widget_queue_draw_area (drawing
->drawing_area
,
1898 control_flow_data
->drawing
->width
,
1899 control_flow_data
->drawing
->height
);
1902 /* Get new data for the rest. */
1903 drawing_data_request(control_flow_data
->drawing
,
1904 &control_flow_data
->drawing
->pixmap
,
1905 drawing
->damage_begin
, 0,
1906 drawing
->damage_end
- drawing
->damage_begin
,
1907 control_flow_data
->drawing
->height
);
1910 if(ltt_time_compare(*ns
,*os
) == 0)
1912 g_info("not scrolling");
1914 g_info("scrolling far");
1915 /* Cannot reuse any part of the screen : far jump */
1918 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1919 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1922 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1923 control_flow_data
->drawing
->height
);
1925 gtk_widget_queue_draw_area (drawing
->drawing_area
,
1927 control_flow_data
->drawing
->width
,
1928 control_flow_data
->drawing
->height
);
1930 drawing
->damage_begin
= 0;
1931 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1933 drawing_data_request(control_flow_data
->drawing
,
1934 &control_flow_data
->drawing
->pixmap
,
1936 control_flow_data
->drawing
->width
,
1937 control_flow_data
->drawing
->height
);
1943 /* Different scale (zoom) */
1946 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1947 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1950 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1951 control_flow_data
->drawing
->height
);
1953 gtk_widget_queue_draw_area (drawing
->drawing_area
,
1955 control_flow_data
->drawing
->width
,
1956 control_flow_data
->drawing
->height
);
1958 drawing
->damage_begin
= 0;
1959 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1961 drawing_data_request(control_flow_data
->drawing
,
1962 &control_flow_data
->drawing
->pixmap
,
1964 control_flow_data
->drawing
->width
,
1965 control_flow_data
->drawing
->height
);
1973 gint
traceset_notify(void *hook_data
, void *call_data
)
1975 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1976 Drawing_t
*drawing
= control_flow_data
->drawing
;
1977 GtkWidget
*widget
= drawing
->drawing_area
;
1979 drawing
->damage_begin
= 0;
1980 drawing
->damage_end
= drawing
->width
;
1982 drawing_clear(control_flow_data
->drawing
);
1983 processlist_clear(control_flow_data
->process_list
);
1985 if(drawing
->damage_begin
< drawing
->damage_end
)
1987 drawing_data_request(drawing
,
1989 drawing
->damage_begin
,
1991 drawing
->damage_end
-drawing
->damage_begin
,
1995 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2000 request_background_data(control_flow_data
);
2005 gint
redraw_notify(void *hook_data
, void *call_data
)
2007 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2008 Drawing_t
*drawing
= control_flow_data
->drawing
;
2009 GtkWidget
*widget
= drawing
->drawing_area
;
2011 drawing
->damage_begin
= 0;
2012 drawing
->damage_end
= drawing
->width
;
2016 gdk_draw_rectangle (drawing
->pixmap
,
2017 widget
->style
->black_gc
,
2020 drawing
->width
+SAFETY
,
2024 if(drawing
->damage_begin
< drawing
->damage_end
)
2026 drawing_data_request(drawing
,
2028 drawing
->damage_begin
,
2030 drawing
->damage_end
-drawing
->damage_begin
,
2034 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2044 gint
continue_notify(void *hook_data
, void *call_data
)
2046 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2047 Drawing_t
*drawing
= control_flow_data
->drawing
;
2048 GtkWidget
*widget
= drawing
->drawing_area
;
2050 //g_assert(widget->allocation.width == drawing->damage_end);
2052 if(drawing
->damage_begin
< drawing
->damage_end
)
2054 drawing_data_request(drawing
,
2056 drawing
->damage_begin
,
2058 drawing
->damage_end
-drawing
->damage_begin
,
2066 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2068 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2069 Drawing_t
*drawing
= control_flow_data
->drawing
;
2071 LttTime current_time
= *((LttTime
*)call_data
);
2073 TimeWindow time_window
=
2074 lttvwindow_get_time_window(control_flow_data
->tab
);
2076 LttTime time_begin
= time_window
.start_time
;
2077 LttTime width
= time_window
.time_width
;
2078 LttTime half_width
= ltt_time_div(width
,2.0);
2079 LttTime time_end
= ltt_time_add(time_begin
, width
);
2081 LttvTracesetContext
* tsc
=
2082 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2084 LttTime trace_start
= tsc
->time_span
.start_time
;
2085 LttTime trace_end
= tsc
->time_span
.end_time
;
2087 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2088 current_time
.tv_nsec
);
2092 /* If current time is inside time interval, just move the highlight
2095 /* Else, we have to change the time interval. We have to tell it
2096 * to the main window. */
2097 /* The time interval change will take care of placing the current
2098 * time at the center of the visible area, or nearest possible if we are
2099 * at one end of the trace. */
2102 if(ltt_time_compare(current_time
, time_begin
) == -1)
2104 TimeWindow new_time_window
;
2106 if(ltt_time_compare(current_time
,
2107 ltt_time_add(trace_start
,half_width
)) == -1)
2108 time_begin
= trace_start
;
2110 time_begin
= ltt_time_sub(current_time
,half_width
);
2112 new_time_window
.start_time
= time_begin
;
2113 new_time_window
.time_width
= width
;
2115 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2117 else if(ltt_time_compare(current_time
, time_end
) == 1)
2119 TimeWindow new_time_window
;
2121 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2122 time_begin
= ltt_time_sub(trace_end
,width
);
2124 time_begin
= ltt_time_sub(current_time
,half_width
);
2126 new_time_window
.start_time
= time_begin
;
2127 new_time_window
.time_width
= width
;
2129 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2132 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2133 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2141 typedef struct _ClosureData
{
2142 EventsRequest
*events_request
;
2143 LttvTracesetState
*tss
;
2149 * Input : A trace and a PID.
2151 * - For each CPU of the trace
2152 * - Search in trace states by PID and CPU key
2153 * - For each ProcessState found
2154 * - If state is not LTTV_STATE_WAIT
2155 * - Then this process state is the current one for this PID.
2157 * - If no ProcessState found, return NULL.
2158 * - If all ProcessState were in LTTV_STATE_WAIT state, return one of
2160 * Than means state is LTTV_STATE_WAIT, CPU unknown.
2162 static LttvProcessState
*find_process(LttvTraceState
*tstate
, guint pid
)
2164 guint cpu_num
= ltt_trace_per_cpu_tracefile_number(tstate
->parent
.t
);
2168 LttvProcessState
*real_state
= NULL
;
2170 for(i
=0;i
<cpu_num
;i
++) {
2171 cpu_name
= ((LttvTracefileState
*)tstate
->parent
.tracefiles
[i
])->cpu_name
;
2172 LttvProcessState
*state
= lttv_state_find_process_from_trace(tstate
,
2178 if(state
->state
->s
!= LTTV_STATE_WAIT
)
2186 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2188 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2189 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2190 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2192 EventsRequest
*events_request
= closure_data
->events_request
;
2193 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2194 Drawing_t
*drawing
= control_flow_data
->drawing
;
2196 LttvTracesetState
*tss
= closure_data
->tss
;
2197 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2199 LttTime evtime
= closure_data
->end_time
;
2200 TimeWindow time_window
=
2201 lttvwindow_get_time_window(control_flow_data
->tab
);
2203 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2204 time_window
.time_width
);
2206 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2207 || ltt_time_compare(evtime
, end_time
) == 1)
2210 guint width
= drawing
->width
;
2213 /* For the process */
2214 /* First, check if the current process is in the state computation
2215 * process list. If it is there, that means we must add it right now and
2216 * draw items from the beginning of the read for it. If it is not
2217 * present, it's a new process and it was not present : it will
2218 * be added after the state update. */
2219 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2221 LttvTraceState
*trace_state
=
2222 (LttvTraceState
*)tsc
->traces
[process_info
->trace_num
];
2224 LttvProcessState
*process
;
2225 process
= find_process(trace_state
, process_info
->pid
);
2227 if(process
!= NULL
) {
2229 /* Only draw for processes that are currently in the trace states */
2231 guint y
= 0, height
= 0, pl_height
= 0;
2232 ProcessList
*process_list
=
2233 guicontrolflow_get_process_list(control_flow_data
);
2234 LttTime birth
= process_info
->birth
;
2236 /* Should be alike when background info is ready */
2237 if(control_flow_data
->background_info_waiting
==0)
2238 g_assert(ltt_time_compare(process
->creation_time
,
2239 process_info
->birth
) == 0);
2240 const gchar
*name
= g_quark_to_string(process
->name
);
2242 /* process HAS to be present */
2243 g_assert(processlist_get_process_pixels(process_list
,
2246 process_info
->trace_num
,
2249 &hashed_process_data
) != 1);
2251 /* Now, the process is in the state hash and our own process hash.
2252 * We definitely can draw the items related to the ending state.
2255 /* Check if the x position is unset. In can have been left unset by
2256 * a draw closure from a after chunk hook. This should never happen,
2257 * because it must be set by before chunk hook to the damage_begin
2260 g_assert(hashed_process_data
->x
!= -1);
2263 DrawContext draw_context
;
2265 convert_time_to_pixels(
2266 time_window
.start_time
,
2272 /* Now create the drawing context that will be used to draw
2273 * items related to the last state. */
2274 draw_context
.drawable
= drawing
->pixmap
;
2275 draw_context
.gc
= drawing
->gc
;
2276 draw_context
.pango_layout
= drawing
->pango_layout
;
2277 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
;
2278 draw_context
.drawinfo
.end
.x
= x
;
2280 draw_context
.drawinfo
.y
.over
= y
;
2281 draw_context
.drawinfo
.y
.middle
= y
+(height
/4);
2282 draw_context
.drawinfo
.y
.under
= y
+(height
/2)+2;
2284 draw_context
.drawinfo
.start
.offset
.over
= 0;
2285 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2286 draw_context
.drawinfo
.start
.offset
.under
= 0;
2287 draw_context
.drawinfo
.end
.offset
.over
= 0;
2288 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2289 draw_context
.drawinfo
.end
.offset
.under
= 0;
2293 PropertiesLine prop_line
= prepare_line(process
);
2294 draw_line((void*)&prop_line
, (void*)&draw_context
);
2298 /* special case LTTV_STATE_WAIT : CPU is unknown. */
2300 /* become the last x position */
2301 hashed_process_data
->x
= x
;
2308 int before_chunk(void *hook_data
, void *call_data
)
2310 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2311 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2313 drawing_chunk_begin(events_request
, tss
);
2318 int before_request(void *hook_data
, void *call_data
)
2320 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2321 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2323 drawing_data_request_begin(events_request
, tss
);
2330 * after request is necessary in addition of after chunk in order to draw
2331 * lines until the end of the screen. after chunk just draws lines until
2338 int after_request(void *hook_data
, void *call_data
)
2340 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2341 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2342 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2343 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2345 ProcessList
*process_list
=
2346 guicontrolflow_get_process_list(control_flow_data
);
2347 LttTime end_time
= events_request
->end_time
;
2349 ClosureData closure_data
;
2350 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2351 closure_data
.tss
= tss
;
2352 closure_data
.end_time
= end_time
;
2354 /* Draw last items */
2355 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2356 (void*)&closure_data
);
2358 /* Request expose */
2359 drawing_request_expose(events_request
, tss
, end_time
);
2368 int after_chunk(void *hook_data
, void *call_data
)
2370 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2371 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2372 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2373 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2374 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
2377 ProcessList
*process_list
=
2378 guicontrolflow_get_process_list(control_flow_data
);
2381 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
2382 else /* end of traceset, or position now out of request : end */
2383 end_time
= events_request
->end_time
;
2385 ClosureData closure_data
;
2386 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2387 closure_data
.tss
= tss
;
2388 closure_data
.end_time
= end_time
;
2390 /* Draw last items */
2391 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2392 (void*)&closure_data
);
2394 /* Request expose */
2395 drawing_request_expose(events_request
, tss
, end_time
);