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
)
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_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 g_assert(!(process
->pid
== 432 &&
401 ltt_time_compare(process
->creation_time
,
404 g_assert(!(process
->pid
== 432 &&
405 process
->creation_time
.tv_nsec
== 47797905));
406 /* Process not present */
407 processlist_add(process_list
,
410 tfc
->t_context
->index
,
413 &hashed_process_data
);
414 processlist_get_process_pixels(process_list
,
417 tfc
->t_context
->index
,
420 &hashed_process_data
);
421 drawing_insert_square( drawing
, y
, height
);
424 /* Now, the process is in the state hash and our own process hash.
425 * We definitely can draw the items related to the ending state.
428 /* Check if the x position is unset. In can have been left unset by
429 * a draw closure from a after chunk hook. This should never happen,
430 * because it must be set by before chunk hook to the damage_begin
433 g_assert(hashed_process_data
->x
!= -1);
436 DrawContext draw_context
;
438 convert_time_to_pixels(
439 time_window
.start_time
,
445 /* Now create the drawing context that will be used to draw
446 * items related to the last state. */
447 draw_context
.drawable
= drawing
->pixmap
;
448 draw_context
.gc
= drawing
->gc
;
449 draw_context
.pango_layout
= drawing
->pango_layout
;
450 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
;
451 draw_context
.drawinfo
.end
.x
= x
;
453 draw_context
.drawinfo
.y
.over
= y
;
454 draw_context
.drawinfo
.y
.middle
= y
+(height
/4);
455 draw_context
.drawinfo
.y
.under
= y
+(height
/2)+2;
457 draw_context
.drawinfo
.start
.offset
.over
= 0;
458 draw_context
.drawinfo
.start
.offset
.middle
= 0;
459 draw_context
.drawinfo
.start
.offset
.under
= 0;
460 draw_context
.drawinfo
.end
.offset
.over
= 0;
461 draw_context
.drawinfo
.end
.offset
.middle
= 0;
462 draw_context
.drawinfo
.end
.offset
.under
= 0;
466 PropertiesLine prop_line
= prepare_line(process
);
467 draw_line((void*)&prop_line
, (void*)&draw_context
);
470 /* become the last x position */
471 hashed_process_data
->x
= x
;
478 /* First, check if the current process is in the state computation
479 * process list. If it is there, that means we must add it right now and
480 * draw items from the beginning of the read for it. If it is not
481 * present, it's a new process and it was not present : it will
482 * be added after the state update. */
483 LttvProcessState
*process
;
484 process
= lttv_state_find_process(tfs
, pid_in
);
486 if(process
!= NULL
) {
487 /* Well, the process_out existed : we must get it in the process hash
488 * or add it, and draw its items.
490 /* Add process to process list (if not present) */
491 guint y
= 0, height
= 0, pl_height
= 0;
492 HashedProcessData
*hashed_process_data
= NULL
;
493 ProcessList
*process_list
=
494 guicontrolflow_get_process_list(control_flow_data
);
495 LttTime birth
= process
->creation_time
;
496 const gchar
*name
= g_quark_to_string(process
->name
);
498 if(processlist_get_process_pixels(process_list
,
501 tfc
->t_context
->index
,
504 &hashed_process_data
) == 1)
506 /* Process not present */
507 processlist_add(process_list
,
510 tfc
->t_context
->index
,
513 &hashed_process_data
);
514 processlist_get_process_pixels(process_list
,
517 tfc
->t_context
->index
,
520 &hashed_process_data
);
521 drawing_insert_square( drawing
, y
, height
);
524 /* Now, the process is in the state hash and our own process hash.
525 * We definitely can draw the items related to the ending state.
528 /* Check if the x position is unset. In can have been left unset by
529 * a draw closure from a after chunk hook. This should never happen,
530 * because it must be set by before chunk hook to the damage_begin
533 g_assert(hashed_process_data
->x
!= -1);
536 DrawContext draw_context
;
538 convert_time_to_pixels(
539 time_window
.start_time
,
545 /* Now create the drawing context that will be used to draw
546 * items related to the last state. */
547 draw_context
.drawable
= drawing
->pixmap
;
548 draw_context
.gc
= drawing
->gc
;
549 draw_context
.pango_layout
= drawing
->pango_layout
;
550 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
;
551 draw_context
.drawinfo
.end
.x
= x
;
553 draw_context
.drawinfo
.y
.over
= y
;
554 draw_context
.drawinfo
.y
.middle
= y
+(height
/4);
555 draw_context
.drawinfo
.y
.under
= y
+(height
/2)+2;
557 draw_context
.drawinfo
.start
.offset
.over
= 0;
558 draw_context
.drawinfo
.start
.offset
.middle
= 0;
559 draw_context
.drawinfo
.start
.offset
.under
= 0;
560 draw_context
.drawinfo
.end
.offset
.over
= 0;
561 draw_context
.drawinfo
.end
.offset
.middle
= 0;
562 draw_context
.drawinfo
.end
.offset
.under
= 0;
566 PropertiesLine prop_line
= prepare_line(process
);
567 draw_line((void*)&prop_line
, (void*)&draw_context
);
571 /* become the last x position */
572 hashed_process_data
->x
= x
;
577 ltt_eventtype_name(ltt_event_eventtype(e
)),"process") == 0) {
578 /* We are in a fork or exit event */
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_EXIT
)
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_EXIT
)
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_EXIT
)
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_EXIT
)
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_EXIT
)
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_EXIT
)
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 */
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 draw_after_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
,
1274 tfc
->t_context
->index
,
1277 &hashed_process_data_in
) == 1)
1279 g_assert(!(process_in
->pid
== 432 &&
1280 ltt_time_compare(process_in
->creation_time
,
1281 ltt_time_zero
)==0));
1283 g_assert(!(process_in
->pid
== 432 &&
1284 process_in
->creation_time
.tv_nsec
== 47797905));
1286 /* Process not present */
1287 processlist_add(process_list
,
1290 tfc
->t_context
->index
,
1293 &hashed_process_data_in
);
1294 processlist_get_process_pixels(process_list
,
1297 tfc
->t_context
->index
,
1300 &hashed_process_data_in
);
1301 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1304 convert_time_to_pixels(
1305 time_window
.start_time
,
1309 &hashed_process_data_in
->x
);
1312 ltt_eventtype_name(ltt_event_eventtype(e
)),"process") == 0) {
1313 /* We are in a fork or exit event */
1323 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1324 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1326 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1328 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1329 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1335 LttTime evtime
= ltt_event_time(e
);
1336 TimeWindow time_window
=
1337 lttvwindow_get_time_window(control_flow_data
->tab
);
1339 LttTime end_time
= ltt_time_add(time_window
.start_time
,
1340 time_window
.time_width
);
1341 //if(time < time_beg || time > time_end) return;
1342 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1343 || ltt_time_compare(evtime
, end_time
) == 1)
1347 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1349 g_debug("schedchange!");
1351 /* Add process to process list (if not present) and get drawing "y" from
1352 * process position */
1353 guint pid_out
, pid_in
;
1354 LttvProcessState
*process_out
, *process_in
;
1356 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1358 ProcessList
*process_list
=
1359 guicontrolflow_get_process_list(control_flow_data
);
1362 LttField
*f
= ltt_event_field(e
);
1364 element
= ltt_field_member(f
,0);
1365 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1366 element
= ltt_field_member(f
,1);
1367 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1368 //g_debug("out : %u in : %u", pid_out, pid_in);
1371 /* Find process pid_out in the list... */
1372 process_out
= lttv_state_find_process(tfs
, pid_out
);
1373 if(process_out
== NULL
) return 0;
1374 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1376 birth
= process_out
->creation_time
;
1377 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1378 HashedProcessData
*hashed_process_data_out
= NULL
;
1380 if(processlist_get_process_pixels(process_list
,
1383 tfc
->t_context
->index
,
1386 &hashed_process_data_out
) == 1)
1388 /* Process not present */
1389 processlist_add(process_list
,
1392 tfc
->t_context
->index
,
1395 &hashed_process_data_out
);
1396 processlist_get_process_pixels(process_list
,
1399 tfc
->t_context
->index
,
1402 &hashed_process_data_out
);
1403 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1408 /* Find process pid_in in the list... */
1409 process_in
= lttv_state_find_process(tfs
, pid_in
);
1410 if(process_in
== NULL
) return 0;
1411 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1413 birth
= process_in
->creation_time
;
1414 name
= strdup(g_quark_to_string(process_in
->name
));
1415 HashedProcessData
*hashed_process_data_in
= NULL
;
1417 if(processlist_get_process_pixels(process_list
,
1420 tfc
->t_context
->index
,
1423 &hashed_process_data_in
) == 1)
1425 /* Process not present */
1426 processlist_add(process_list
,
1429 tfc
->t_context
->index
,
1432 &hashed_process_data_in
);
1433 processlist_get_process_pixels(process_list
,
1436 tfc
->t_context
->index
,
1439 &hashed_process_data_in
);
1441 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1446 /* Find pixels corresponding to time of the event. If the time does
1447 * not fit in the window, show a warning, not supposed to happend. */
1449 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1451 //LttTime time = ltt_event_time(e);
1453 //LttTime window_end = ltt_time_add(time_window->time_width,
1454 // time_window->start_time);
1457 //convert_time_to_pixels(
1458 // time_window->start_time,
1464 //assert(x <= width);
1466 /* draw what represents the event for outgoing process. */
1468 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1469 //draw_context_out->current->modify_over->x = x;
1470 draw_context_out
->current
->modify_over
->y
= y_out
;
1471 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1472 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1473 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1474 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1475 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1477 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1478 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1480 /*if(process_out->state->s == LTTV_STATE_RUN)
1482 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1483 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1484 PropertiesBG prop_bg;
1485 prop_bg.color = g_new(GdkColor,1);
1487 prop_bg.color->red = 0xffff;
1488 prop_bg.color->green = 0xffff;
1489 prop_bg.color->blue = 0xffff;
1491 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1492 g_free(prop_bg.color);
1493 gdk_gc_unref(draw_context_out->gc);
1496 draw_context_out
->gc
= widget
->style
->black_gc
;
1498 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1499 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1500 PropertiesText prop_text_out
;
1501 prop_text_out
.foreground
= &colorfg_out
;
1502 prop_text_out
.background
= &colorbg_out
;
1503 prop_text_out
.size
= 6;
1504 prop_text_out
.position
= OVER
;
1506 /* color of text : status of the process */
1507 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1509 prop_text_out
.foreground
->red
= 0xffff;
1510 prop_text_out
.foreground
->green
= 0xffff;
1511 prop_text_out
.foreground
->blue
= 0xffff;
1513 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1515 prop_text_out
.foreground
->red
= 0x0fff;
1516 prop_text_out
.foreground
->green
= 0xffff;
1517 prop_text_out
.foreground
->blue
= 0xfff0;
1519 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1521 prop_text_out
.foreground
->red
= 0xffff;
1522 prop_text_out
.foreground
->green
= 0xffff;
1523 prop_text_out
.foreground
->blue
= 0x0000;
1525 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
1527 prop_text_out
.foreground
->red
= 0xffff;
1528 prop_text_out
.foreground
->green
= 0x0000;
1529 prop_text_out
.foreground
->blue
= 0xffff;
1531 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1533 prop_text_out
.foreground
->red
= 0xffff;
1534 prop_text_out
.foreground
->green
= 0x0000;
1535 prop_text_out
.foreground
->blue
= 0x0000;
1537 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1539 prop_text_out
.foreground
->red
= 0x0000;
1540 prop_text_out
.foreground
->green
= 0xffff;
1541 prop_text_out
.foreground
->blue
= 0x0000;
1545 prop_text_out
.foreground
->red
= 0xffff;
1546 prop_text_out
.foreground
->green
= 0xffff;
1547 prop_text_out
.foreground
->blue
= 0xffff;
1550 /* Print status of the process : U, WF, WC, E, W, R */
1551 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1552 prop_text_out
.text
= "U";
1553 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1554 prop_text_out
.text
= "WF";
1555 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1556 prop_text_out
.text
= "WC";
1557 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
1558 prop_text_out
.text
= "E";
1559 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1560 prop_text_out
.text
= "W";
1561 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1562 prop_text_out
.text
= "R";
1564 prop_text_out
.text
= "U";
1566 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1568 //gdk_gc_unref(draw_context_out->gc);
1570 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1571 draw_context_out
->current
->over
->y
= y_out
;
1572 draw_context_out
->current
->under
->y
= y_out
+height
;
1573 draw_context_out
->current
->status
= process_out
->state
->s
;
1575 /* for pid_out : remove previous, Prev = current, new current (default) */
1576 g_free(draw_context_out
->previous
->modify_under
);
1577 g_free(draw_context_out
->previous
->modify_middle
);
1578 g_free(draw_context_out
->previous
->modify_over
);
1579 g_free(draw_context_out
->previous
->under
);
1580 g_free(draw_context_out
->previous
->middle
);
1581 g_free(draw_context_out
->previous
->over
);
1582 g_free(draw_context_out
->previous
);
1584 draw_context_out
->previous
= draw_context_out
->current
;
1586 draw_context_out
->current
= g_new(DrawInfo
,1);
1587 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1588 draw_context_out
->current
->over
->x
= -1;
1589 draw_context_out
->current
->over
->y
= -1;
1590 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1591 draw_context_out
->current
->middle
->x
= -1;
1592 draw_context_out
->current
->middle
->y
= -1;
1593 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1594 draw_context_out
->current
->under
->x
= -1;
1595 draw_context_out
->current
->under
->y
= -1;
1596 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1597 draw_context_out
->current
->modify_over
->x
= -1;
1598 draw_context_out
->current
->modify_over
->y
= -1;
1599 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1600 draw_context_out
->current
->modify_middle
->x
= -1;
1601 draw_context_out
->current
->modify_middle
->y
= -1;
1602 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1603 draw_context_out
->current
->modify_under
->x
= -1;
1604 draw_context_out
->current
->modify_under
->y
= -1;
1605 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1607 /* Finally, update the drawing context of the pid_in. */
1609 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1610 //draw_context_in->current->modify_over->x = x;
1611 draw_context_in
->current
->modify_over
->y
= y_in
;
1612 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1613 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1614 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1615 widget
= control_flow_data
->drawing
->drawing_area
;
1616 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1618 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1619 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1621 /*if(process_in->state->s == LTTV_STATE_RUN)
1623 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1624 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1625 PropertiesBG prop_bg;
1626 prop_bg.color = g_new(GdkColor,1);
1628 prop_bg.color->red = 0xffff;
1629 prop_bg.color->green = 0xffff;
1630 prop_bg.color->blue = 0xffff;
1632 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1633 g_free(prop_bg.color);
1634 gdk_gc_unref(draw_context_in->gc);
1637 draw_context_in
->gc
= widget
->style
->black_gc
;
1639 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1640 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1641 PropertiesText prop_text_in
;
1642 prop_text_in
.foreground
= &colorfg_in
;
1643 prop_text_in
.background
= &colorbg_in
;
1644 prop_text_in
.size
= 6;
1645 prop_text_in
.position
= OVER
;
1647 /* foreground of text : status of the process */
1648 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1650 prop_text_in
.foreground
->red
= 0xffff;
1651 prop_text_in
.foreground
->green
= 0xffff;
1652 prop_text_in
.foreground
->blue
= 0xffff;
1654 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1656 prop_text_in
.foreground
->red
= 0x0fff;
1657 prop_text_in
.foreground
->green
= 0xffff;
1658 prop_text_in
.foreground
->blue
= 0xfff0;
1660 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1662 prop_text_in
.foreground
->red
= 0xffff;
1663 prop_text_in
.foreground
->green
= 0xffff;
1664 prop_text_in
.foreground
->blue
= 0x0000;
1666 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1668 prop_text_in
.foreground
->red
= 0xffff;
1669 prop_text_in
.foreground
->green
= 0x0000;
1670 prop_text_in
.foreground
->blue
= 0xffff;
1672 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1674 prop_text_in
.foreground
->red
= 0xffff;
1675 prop_text_in
.foreground
->green
= 0x0000;
1676 prop_text_in
.foreground
->blue
= 0x0000;
1678 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1680 prop_text_in
.foreground
->red
= 0x0000;
1681 prop_text_in
.foreground
->green
= 0xffff;
1682 prop_text_in
.foreground
->blue
= 0x0000;
1686 prop_text_in
.foreground
->red
= 0xffff;
1687 prop_text_in
.foreground
->green
= 0xffff;
1688 prop_text_in
.foreground
->blue
= 0xffff;
1692 /* Print status of the process : U, WF, WC, E, W, R */
1693 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1694 prop_text_in
.text
= "U";
1695 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1696 prop_text_in
.text
= "WF";
1697 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1698 prop_text_in
.text
= "WC";
1699 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1700 prop_text_in
.text
= "E";
1701 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1702 prop_text_in
.text
= "W";
1703 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1704 prop_text_in
.text
= "R";
1706 prop_text_in
.text
= "U";
1708 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1711 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1714 prop_text_in
.foreground
= &colorfg_in
;
1715 prop_text_in
.background
= &colorbg_in
;
1716 prop_text_in
.foreground
->red
= 0xffff;
1717 prop_text_in
.foreground
->green
= 0xffff;
1718 prop_text_in
.foreground
->blue
= 0xffff;
1719 prop_text_in
.size
= 6;
1720 prop_text_in
.position
= UNDER
;
1722 prop_text_in
.text
= g_new(gchar
, 260);
1723 strcpy(prop_text_in
.text
, "CPU ");
1724 snprintf(tmp
, 255, "%u", tfc
->index
);
1725 strcat(prop_text_in
.text
, tmp
);
1727 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1728 g_free(prop_text_in
.text
);
1732 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1733 draw_context_in
->current
->over
->y
= y_in
;
1734 draw_context_in
->current
->under
->y
= y_in
+height
;
1735 draw_context_in
->current
->status
= process_in
->state
->s
;
1737 /* for pid_in : remove previous, Prev = current, new current (default) */
1738 g_free(draw_context_in
->previous
->modify_under
);
1739 g_free(draw_context_in
->previous
->modify_middle
);
1740 g_free(draw_context_in
->previous
->modify_over
);
1741 g_free(draw_context_in
->previous
->under
);
1742 g_free(draw_context_in
->previous
->middle
);
1743 g_free(draw_context_in
->previous
->over
);
1744 g_free(draw_context_in
->previous
);
1746 draw_context_in
->previous
= draw_context_in
->current
;
1748 draw_context_in
->current
= g_new(DrawInfo
,1);
1749 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1750 draw_context_in
->current
->over
->x
= -1;
1751 draw_context_in
->current
->over
->y
= -1;
1752 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1753 draw_context_in
->current
->middle
->x
= -1;
1754 draw_context_in
->current
->middle
->y
= -1;
1755 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1756 draw_context_in
->current
->under
->x
= -1;
1757 draw_context_in
->current
->under
->y
= -1;
1758 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1759 draw_context_in
->current
->modify_over
->x
= -1;
1760 draw_context_in
->current
->modify_over
->y
= -1;
1761 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1762 draw_context_in
->current
->modify_middle
->x
= -1;
1763 draw_context_in
->current
->modify_middle
->y
= -1;
1764 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1765 draw_context_in
->current
->modify_under
->x
= -1;
1766 draw_context_in
->current
->modify_under
->y
= -1;
1767 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1778 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1780 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1781 Drawing_t
*drawing
= control_flow_data
->drawing
;
1783 const TimeWindowNotifyData
*time_window_nofify_data
=
1784 ((const TimeWindowNotifyData
*)call_data
);
1786 TimeWindow
*old_time_window
=
1787 time_window_nofify_data
->old_time_window
;
1788 TimeWindow
*new_time_window
=
1789 time_window_nofify_data
->new_time_window
;
1791 /* Update the ruler */
1792 drawing_update_ruler(control_flow_data
->drawing
,
1796 /* Two cases : zoom in/out or scrolling */
1798 /* In order to make sure we can reuse the old drawing, the scale must
1799 * be the same and the new time interval being partly located in the
1800 * currently shown time interval. (reuse is only for scrolling)
1803 g_info("Old time window HOOK : %u, %u to %u, %u",
1804 old_time_window
->start_time
.tv_sec
,
1805 old_time_window
->start_time
.tv_nsec
,
1806 old_time_window
->time_width
.tv_sec
,
1807 old_time_window
->time_width
.tv_nsec
);
1809 g_info("New time window HOOK : %u, %u to %u, %u",
1810 new_time_window
->start_time
.tv_sec
,
1811 new_time_window
->start_time
.tv_nsec
,
1812 new_time_window
->time_width
.tv_sec
,
1813 new_time_window
->time_width
.tv_nsec
);
1815 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1816 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1818 /* Same scale (scrolling) */
1819 g_info("scrolling");
1820 LttTime
*ns
= &new_time_window
->start_time
;
1821 LttTime
*os
= &old_time_window
->start_time
;
1822 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
1823 old_time_window
->time_width
);
1824 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
1825 new_time_window
->time_width
);
1827 //if(ns<os+w && os+w<ns+w)
1828 //if(ns<old_end && os<ns)
1829 if(ltt_time_compare(*ns
, old_end
) == -1
1830 && ltt_time_compare(*os
, *ns
) == -1)
1832 g_info("scrolling near right");
1833 /* Scroll right, keep right part of the screen */
1835 guint width
= control_flow_data
->drawing
->width
;
1836 convert_time_to_pixels(
1843 /* Copy old data to new location */
1844 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1845 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1846 control_flow_data
->drawing
->pixmap
,
1849 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
1851 if(drawing
->damage_begin
== drawing
->damage_end
)
1852 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
1854 drawing
->damage_begin
= 0;
1856 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1858 /* Clear the data request background, but not SAFETY */
1859 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1860 //control_flow_data->drawing->drawing_area->style->black_gc,
1861 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1863 drawing
->damage_begin
+SAFETY
, 0,
1864 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1865 control_flow_data
->drawing
->height
);
1867 gtk_widget_queue_draw_area (drawing
->drawing_area
,
1869 control_flow_data
->drawing
->width
,
1870 control_flow_data
->drawing
->height
);
1872 /* Get new data for the rest. */
1873 drawing_data_request(control_flow_data
->drawing
,
1874 &control_flow_data
->drawing
->pixmap
,
1875 drawing
->damage_begin
, 0,
1876 drawing
->damage_end
- drawing
->damage_begin
,
1877 control_flow_data
->drawing
->height
);
1880 //if(ns<os && os<ns+w)
1881 //if(ns<os && os<new_end)
1882 if(ltt_time_compare(*ns
,*os
) == -1
1883 && ltt_time_compare(*os
,new_end
) == -1)
1885 g_info("scrolling near left");
1886 /* Scroll left, keep left part of the screen */
1888 guint width
= control_flow_data
->drawing
->width
;
1889 convert_time_to_pixels(
1897 /* Copy old data to new location */
1898 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1899 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1900 control_flow_data
->drawing
->pixmap
,
1905 if(drawing
->damage_begin
== drawing
->damage_end
)
1906 drawing
->damage_end
= x
;
1908 drawing
->damage_end
=
1909 control_flow_data
->drawing
->width
;
1911 drawing
->damage_begin
= 0;
1913 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1914 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1916 drawing
->damage_begin
, 0,
1917 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
1918 control_flow_data
->drawing
->height
);
1920 gtk_widget_queue_draw_area (drawing
->drawing_area
,
1922 control_flow_data
->drawing
->width
,
1923 control_flow_data
->drawing
->height
);
1926 /* Get new data for the rest. */
1927 drawing_data_request(control_flow_data
->drawing
,
1928 &control_flow_data
->drawing
->pixmap
,
1929 drawing
->damage_begin
, 0,
1930 drawing
->damage_end
- drawing
->damage_begin
,
1931 control_flow_data
->drawing
->height
);
1934 if(ltt_time_compare(*ns
,*os
) == 0)
1936 g_info("not scrolling");
1938 g_info("scrolling far");
1939 /* Cannot reuse any part of the screen : far jump */
1942 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1943 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1946 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1947 control_flow_data
->drawing
->height
);
1949 gtk_widget_queue_draw_area (drawing
->drawing_area
,
1951 control_flow_data
->drawing
->width
,
1952 control_flow_data
->drawing
->height
);
1954 drawing
->damage_begin
= 0;
1955 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1957 drawing_data_request(control_flow_data
->drawing
,
1958 &control_flow_data
->drawing
->pixmap
,
1960 control_flow_data
->drawing
->width
,
1961 control_flow_data
->drawing
->height
);
1967 /* Different scale (zoom) */
1970 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1971 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1974 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1975 control_flow_data
->drawing
->height
);
1977 gtk_widget_queue_draw_area (drawing
->drawing_area
,
1979 control_flow_data
->drawing
->width
,
1980 control_flow_data
->drawing
->height
);
1982 drawing
->damage_begin
= 0;
1983 drawing
->damage_end
= control_flow_data
->drawing
->width
;
1985 drawing_data_request(control_flow_data
->drawing
,
1986 &control_flow_data
->drawing
->pixmap
,
1988 control_flow_data
->drawing
->width
,
1989 control_flow_data
->drawing
->height
);
1997 gint
traceset_notify(void *hook_data
, void *call_data
)
1999 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2000 Drawing_t
*drawing
= control_flow_data
->drawing
;
2001 GtkWidget
*widget
= drawing
->drawing_area
;
2004 drawing_clear(control_flow_data
->drawing
);
2005 processlist_clear(control_flow_data
->process_list
);
2006 redraw_notify(control_flow_data
, NULL
);
2008 request_background_data(control_flow_data
);
2010 drawing
->damage_begin
= 0;
2011 drawing
->damage_end
= drawing
->width
;
2012 if(drawing
->damage_begin
< drawing
->damage_end
)
2014 drawing_data_request(drawing
,
2016 drawing
->damage_begin
,
2018 drawing
->damage_end
-drawing
->damage_begin
,
2022 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2031 gint
redraw_notify(void *hook_data
, void *call_data
)
2033 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2034 Drawing_t
*drawing
= control_flow_data
->drawing
;
2035 GtkWidget
*widget
= drawing
->drawing_area
;
2037 drawing
->damage_begin
= 0;
2038 drawing
->damage_end
= drawing
->width
;
2042 gdk_draw_rectangle (drawing
->pixmap
,
2043 widget
->style
->black_gc
,
2046 drawing
->width
+SAFETY
,
2050 if(drawing
->damage_begin
< drawing
->damage_end
)
2052 drawing_data_request(drawing
,
2054 drawing
->damage_begin
,
2056 drawing
->damage_end
-drawing
->damage_begin
,
2060 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2070 gint
continue_notify(void *hook_data
, void *call_data
)
2072 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2073 Drawing_t
*drawing
= control_flow_data
->drawing
;
2074 GtkWidget
*widget
= drawing
->drawing_area
;
2076 //g_assert(widget->allocation.width == drawing->damage_end);
2078 if(drawing
->damage_begin
< drawing
->damage_end
)
2080 drawing_data_request(drawing
,
2082 drawing
->damage_begin
,
2084 drawing
->damage_end
-drawing
->damage_begin
,
2092 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2094 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2095 Drawing_t
*drawing
= control_flow_data
->drawing
;
2097 LttTime current_time
= *((LttTime
*)call_data
);
2099 TimeWindow time_window
=
2100 lttvwindow_get_time_window(control_flow_data
->tab
);
2102 LttTime time_begin
= time_window
.start_time
;
2103 LttTime width
= time_window
.time_width
;
2104 LttTime half_width
= ltt_time_div(width
,2.0);
2105 LttTime time_end
= ltt_time_add(time_begin
, width
);
2107 LttvTracesetContext
* tsc
=
2108 lttvwindow_get_traceset_context(control_flow_data
->tab
);
2110 LttTime trace_start
= tsc
->time_span
.start_time
;
2111 LttTime trace_end
= tsc
->time_span
.end_time
;
2113 g_info("New current time HOOK : %u, %u", current_time
.tv_sec
,
2114 current_time
.tv_nsec
);
2118 /* If current time is inside time interval, just move the highlight
2121 /* Else, we have to change the time interval. We have to tell it
2122 * to the main window. */
2123 /* The time interval change will take care of placing the current
2124 * time at the center of the visible area, or nearest possible if we are
2125 * at one end of the trace. */
2128 if(ltt_time_compare(current_time
, time_begin
) == -1)
2130 TimeWindow new_time_window
;
2132 if(ltt_time_compare(current_time
,
2133 ltt_time_add(trace_start
,half_width
)) == -1)
2134 time_begin
= trace_start
;
2136 time_begin
= ltt_time_sub(current_time
,half_width
);
2138 new_time_window
.start_time
= time_begin
;
2139 new_time_window
.time_width
= width
;
2141 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2143 else if(ltt_time_compare(current_time
, time_end
) == 1)
2145 TimeWindow new_time_window
;
2147 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
2148 time_begin
= ltt_time_sub(trace_end
,width
);
2150 time_begin
= ltt_time_sub(current_time
,half_width
);
2152 new_time_window
.start_time
= time_begin
;
2153 new_time_window
.time_width
= width
;
2155 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
2158 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2159 gtk_widget_queue_draw_area(drawing
->drawing_area
,
2167 typedef struct _ClosureData
{
2168 EventsRequest
*events_request
;
2169 LttvTracesetState
*tss
;
2174 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
2176 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
2177 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
2178 ClosureData
*closure_data
= (ClosureData
*)user_data
;
2180 EventsRequest
*events_request
= closure_data
->events_request
;
2181 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2182 Drawing_t
*drawing
= control_flow_data
->drawing
;
2184 LttvTracesetState
*tss
= closure_data
->tss
;
2185 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)closure_data
->tss
;
2187 LttTime evtime
= closure_data
->end_time
;
2188 TimeWindow time_window
=
2189 lttvwindow_get_time_window(control_flow_data
->tab
);
2191 LttTime end_time
= ltt_time_add(time_window
.start_time
,
2192 time_window
.time_width
);
2194 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2195 || ltt_time_compare(evtime
, end_time
) == 1)
2198 guint width
= drawing
->width
;
2201 /* For the process */
2202 /* First, check if the current process is in the state computation
2203 * process list. If it is there, that means we must add it right now and
2204 * draw items from the beginning of the read for it. If it is not
2205 * present, it's a new process and it was not present : it will
2206 * be added after the state update. */
2207 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
2209 /* tracefiles[0] is ok here, because we draw for every PID, and
2210 * assume CPU 0 for PID 0 //FIXME */
2211 LttvTracefileState
*tfs
=
2212 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
2214 LttvProcessState
*process
;
2215 process
= lttv_state_find_process(tfs
,
2218 if(process
!= NULL
) {
2220 /* Only draw for processes that are currently in the trace states */
2222 guint y
= 0, height
= 0, pl_height
= 0;
2223 ProcessList
*process_list
=
2224 guicontrolflow_get_process_list(control_flow_data
);
2225 LttTime birth
= process_info
->birth
;
2227 /* Should be alike when background info is ready */
2228 if(control_flow_data
->background_info_waiting
==0)
2229 g_assert(ltt_time_compare(process
->creation_time
,
2230 process_info
->birth
) == 0);
2231 const gchar
*name
= g_quark_to_string(process
->name
);
2233 /* process HAS to be present */
2234 g_assert(processlist_get_process_pixels(process_list
,
2237 process_info
->trace_num
,
2240 &hashed_process_data
) != 1);
2242 /* Now, the process is in the state hash and our own process hash.
2243 * We definitely can draw the items related to the ending state.
2246 /* Check if the x position is unset. In can have been left unset by
2247 * a draw closure from a after chunk hook. This should never happen,
2248 * because it must be set by before chunk hook to the damage_begin
2251 g_assert(hashed_process_data
->x
!= -1);
2254 DrawContext draw_context
;
2256 convert_time_to_pixels(
2257 time_window
.start_time
,
2263 /* Now create the drawing context that will be used to draw
2264 * items related to the last state. */
2265 draw_context
.drawable
= drawing
->pixmap
;
2266 draw_context
.gc
= drawing
->gc
;
2267 draw_context
.pango_layout
= drawing
->pango_layout
;
2268 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
;
2269 draw_context
.drawinfo
.end
.x
= x
;
2271 draw_context
.drawinfo
.y
.over
= y
;
2272 draw_context
.drawinfo
.y
.middle
= y
+(height
/4);
2273 draw_context
.drawinfo
.y
.under
= y
+(height
/2)+2;
2275 draw_context
.drawinfo
.start
.offset
.over
= 0;
2276 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2277 draw_context
.drawinfo
.start
.offset
.under
= 0;
2278 draw_context
.drawinfo
.end
.offset
.over
= 0;
2279 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2280 draw_context
.drawinfo
.end
.offset
.under
= 0;
2284 PropertiesLine prop_line
= prepare_line(process
);
2285 draw_line((void*)&prop_line
, (void*)&draw_context
);
2289 /* special case LTTV_STATE_WAIT : CPU is unknown. */
2291 /* become the last x position */
2292 hashed_process_data
->x
= x
;
2299 int before_chunk(void *hook_data
, void *call_data
)
2301 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2302 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2304 drawing_chunk_begin(events_request
, tss
);
2309 int before_request(void *hook_data
, void *call_data
)
2311 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2312 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2314 drawing_data_request_begin(events_request
, tss
);
2321 * after request is necessary in addition of after chunk in order to draw
2322 * lines until the end of the screen. after chunk just draws lines until
2329 int after_request(void *hook_data
, void *call_data
)
2331 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2332 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2333 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2334 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2336 ProcessList
*process_list
=
2337 guicontrolflow_get_process_list(control_flow_data
);
2338 LttTime end_time
= events_request
->end_time
;
2340 ClosureData closure_data
;
2341 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2342 closure_data
.tss
= tss
;
2343 closure_data
.end_time
= end_time
;
2345 /* Draw last items */
2346 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2347 (void*)&closure_data
);
2349 /* Request expose */
2350 drawing_request_expose(events_request
, tss
, end_time
);
2359 int after_chunk(void *hook_data
, void *call_data
)
2361 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2362 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2363 LttvTracesetState
*tss
= LTTV_TRACESET_STATE(call_data
);
2364 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(call_data
);
2365 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
2368 ProcessList
*process_list
=
2369 guicontrolflow_get_process_list(control_flow_data
);
2372 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
2373 else /* end of traceset, or position now out of request : end */
2374 end_time
= events_request
->end_time
;
2376 ClosureData closure_data
;
2377 closure_data
.events_request
= (EventsRequest
*)hook_data
;
2378 closure_data
.tss
= tss
;
2379 closure_data
.end_time
= end_time
;
2381 /* Draw last items */
2382 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
2383 (void*)&closure_data
);
2385 /* Request expose */
2386 drawing_request_expose(events_request
, tss
, end_time
);