1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 /*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
25 /* Event hooks are the drawing hooks called during traceset read. They draw the
26 * icons, text, lines and background color corresponding to the events read.
28 * Two hooks are used for drawing : before_schedchange and after_schedchange hooks. The
29 * before_schedchange is called before the state update that occurs with an event and
30 * the after_schedchange hook is called after this state update.
32 * The before_schedchange hooks fulfill the task of drawing the visible objects that
33 * corresponds to the data accumulated by the after_schedchange hook.
35 * The after_schedchange hook accumulates the data that need to be shown on the screen
36 * (items) into a queue. Then, the next before_schedchange hook will draw what that
37 * queue contains. That's the Right Way (TM) of drawing items on the screen,
38 * because we need to draw the background first (and then add icons, text, ...
39 * over it), but we only know the length of a background region once the state
40 * corresponding to it is over, which happens to be at the next before_schedchange
43 * We also have a hook called at the end of a chunk to draw the information left
44 * undrawn in each process queue. We use the current time as end of
49 //#define PANGO_ENABLE_BACKEND
57 //#include <pango/pango.h>
59 #include <ltt/event.h>
63 #include <lttv/lttv.h>
64 #include <lttv/hook.h>
65 #include <lttv/state.h>
66 #include <lttvwindow/lttvwindow.h>
67 #include <lttvwindow/lttvwindowtraces.h>
70 #include "eventhooks.h"
72 #include "processlist.h"
76 #define MAX_PATH_LEN 256
80 typedef struct _ProcessAddClosure
{
85 static void process_add(gpointer key
,
89 LttvProcessState
*process
= (LttvProcessState
*)value
;
90 ProcessAddClosure
*closure
= (ProcessAddClosure
*)user_data
;
91 ControlFlowData
*control_flow_data
= closure
->cfd
;
92 guint trace_num
= closure
->trace_num
;
94 /* Add process to process list (if not present) */
97 guint y
= 0, height
= 0, pl_height
= 0;
99 ProcessList
*process_list
= control_flow_data
->process_list
;
102 birth
= process
->creation_time
;
103 const gchar
*name
= g_quark_to_string(process
->name
);
104 HashedProcessData
*hashed_process_data
= NULL
;
106 if(processlist_get_process_pixels(process_list
,
112 &hashed_process_data
) == 1)
114 /* Process not present */
115 processlist_add(process_list
,
121 &hashed_process_data
);
122 processlist_get_process_pixels(process_list
,
128 &hashed_process_data
);
129 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
135 /* Action to do when background computation completed.
137 * Wait for all the awaited computations to be over.
140 gint
background_ready(void *hook_data
, void *call_data
)
142 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
143 LttvTrace
*trace
= (LttvTrace
*)call_data
;
145 control_flow_data
->background_info_waiting
--;
147 if(control_flow_data
->background_info_waiting
== 0) {
148 g_debug("control flow viewer : background computation data ready.");
150 drawing_clear(control_flow_data
->drawing
);
151 processlist_clear(control_flow_data
->process_list
);
152 redraw_notify(control_flow_data
, NULL
);
159 /* Request background computation. Verify if it is in progress or ready first.
160 * Only for each trace in the tab's traceset.
162 void request_background_data(ControlFlowData
*control_flow_data
)
164 LttvTracesetContext
* tsc
=
165 lttvwindow_get_traceset_context(control_flow_data
->tab
);
166 gint num_traces
= lttv_traceset_number(tsc
->ts
);
170 LttvHooks
*background_ready_hook
=
172 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
174 control_flow_data
->background_info_waiting
= 0;
176 for(i
=0;i
<num_traces
;i
++) {
177 trace
= lttv_traceset_get(tsc
->ts
, i
);
179 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
181 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
183 /* We first remove requests that could have been done for the same
184 * information. Happens when two viewers ask for it before servicing
187 lttvwindowtraces_background_request_remove(trace
, "state");
188 lttvwindowtraces_background_request_queue(trace
,
190 lttvwindowtraces_background_notify_queue(control_flow_data
,
194 background_ready_hook
);
195 control_flow_data
->background_info_waiting
++;
196 } else { /* in progress */
198 lttvwindowtraces_background_notify_current(control_flow_data
,
202 background_ready_hook
);
203 control_flow_data
->background_info_waiting
++;
206 /* Data ready. Be its nature, this viewer doesn't need to have
207 * its data ready hook called htere, because a background
208 * request is always linked with a redraw.
214 lttv_hooks_destroy(background_ready_hook
);
221 * Event Viewer's constructor hook
223 * This constructor is given as a parameter to the menuitem and toolbar button
224 * registration. It creates the list.
225 * @param tab A pointer to the parent tab.
226 * @return The widget created.
229 h_guicontrolflow(Tab
*tab
)
231 g_info("h_guicontrolflow, %p", tab
);
232 ControlFlowData
*control_flow_data
= guicontrolflow() ;
234 control_flow_data
->tab
= tab
;
236 // Unreg done in the GuiControlFlow_Destructor
237 lttvwindow_register_traceset_notify(tab
,
241 lttvwindow_register_time_window_notify(tab
,
242 update_time_window_hook
,
244 lttvwindow_register_current_time_notify(tab
,
245 update_current_time_hook
,
247 lttvwindow_register_redraw_notify(tab
,
250 lttvwindow_register_continue_notify(tab
,
253 request_background_data(control_flow_data
);
256 return guicontrolflow_get_widget(control_flow_data
) ;
260 int event_selected_hook(void *hook_data
, void *call_data
)
262 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
263 guint
*event_number
= (guint
*) call_data
;
265 g_debug("DEBUG : event selected by main window : %u", *event_number
);
270 /* Function that selects the color of status&exemode line */
271 static inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
273 PropertiesLine prop_line
;
274 prop_line
.line_width
= 2;
275 prop_line
.style
= GDK_LINE_SOLID
;
276 prop_line
.y
= MIDDLE
;
277 //GdkColormap *colormap = gdk_colormap_get_system();
279 if(process
->state
->s
== LTTV_STATE_RUN
) {
280 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
281 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
282 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
283 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
284 else if(process
->state
->t
== LTTV_STATE_TRAP
)
285 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
286 else if(process
->state
->t
== LTTV_STATE_IRQ
)
287 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
288 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
289 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
291 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
292 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
293 /* We don't show if we wait while in user mode, trap, irq or syscall */
294 prop_line
.color
= drawing_colors
[COL_WAIT
];
295 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
296 /* We don't show if we wait for CPU while in user mode, trap, irq
298 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
299 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
300 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
301 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
302 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
303 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
304 prop_line
.color
= drawing_colors
[COL_EXIT
];
305 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
306 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
308 g_assert(FALSE
); /* UNKNOWN STATE */
315 static inline PropertiesLine
prepare_status_line(LttvProcessState
*process
)
317 PropertiesLine prop_line
;
318 prop_line
.line_width
= 2;
319 prop_line
.style
= GDK_LINE_SOLID
;
320 prop_line
.y
= MIDDLE
;
321 //GdkColormap *colormap = gdk_colormap_get_system();
323 g_debug("prepare_status_line for state : %s",
324 g_quark_to_string(process
->state
->s
));
326 /* color of line : status of the process */
327 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
328 prop_line
.color
= drawing_colors
[COL_WHITE
];
329 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
330 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
331 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
332 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
333 else if(process
->state
->s
== LTTV_STATE_EXIT
)
334 prop_line
.color
= drawing_colors
[COL_EXIT
];
335 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
336 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
337 else if(process
->state
->s
== LTTV_STATE_WAIT
)
338 prop_line
.color
= drawing_colors
[COL_WAIT
];
339 else if(process
->state
->s
== LTTV_STATE_RUN
)
340 prop_line
.color
= drawing_colors
[COL_RUN
];
342 prop_line
.color
= drawing_colors
[COL_WHITE
];
344 //gdk_colormap_alloc_color(colormap,
355 /* before_schedchange_hook
357 * This function basically draw lines and icons. Two types of lines are drawn :
358 * one small (3 pixels?) representing the state of the process and the second
359 * type is thicker (10 pixels?) representing on which CPU a process is running
360 * (and this only in running state).
362 * Extremums of the lines :
363 * x_min : time of the last event context for this process kept in memory.
364 * x_max : time of the current event.
365 * y : middle of the process in the process list. The process is found in the
366 * list, therefore is it's position in pixels.
368 * The choice of lines'color is defined by the context of the last event for this
373 int before_schedchange_hook(void *hook_data
, void *call_data
)
375 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
376 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
378 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
380 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
385 LttTime evtime
= ltt_event_time(e
);
387 /* we are in a schedchange, before the state update. We must draw the
388 * items corresponding to the state before it changes : now is the right
395 LttField
*f
= ltt_event_field(e
);
397 element
= ltt_field_member(f
,0);
398 pid_out
= ltt_event_get_long_unsigned(e
,element
);
399 element
= ltt_field_member(f
,1);
400 pid_in
= ltt_event_get_long_unsigned(e
,element
);
404 /* For the pid_out */
405 /* First, check if the current process is in the state computation
406 * process list. If it is there, that means we must add it right now and
407 * draw items from the beginning of the read for it. If it is not
408 * present, it's a new process and it was not present : it will
409 * be added after the state update. */
410 LttvProcessState
*process
;
411 /* unknown state, bad current pid */
412 if(tfs
->process
->pid
!= pid_out
)
413 process
= lttv_state_find_process(tfs
, pid_out
);
415 process
= tfs
->process
;
417 if(process
!= NULL
) {
418 /* Well, the process_out existed : we must get it in the process hash
419 * or add it, and draw its items.
421 /* Add process to process list (if not present) */
422 guint y
= 0, height
= 0, pl_height
= 0;
423 HashedProcessData
*hashed_process_data
= NULL
;
424 ProcessList
*process_list
= control_flow_data
->process_list
;
425 LttTime birth
= process
->creation_time
;
427 hashed_process_data
= processlist_get_process_data(process_list
,
429 process
->last_cpu_index
,
431 tfc
->t_context
->index
);
432 if(hashed_process_data
== NULL
)
434 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
435 const gchar
*name
= g_quark_to_string(process
->name
);
436 /* Process not present */
437 ProcessInfo
*process_info
;
438 processlist_add(process_list
,
440 process
->last_cpu_index
,
443 tfc
->t_context
->index
,
447 &hashed_process_data
);
448 processlist_get_pixels_from_data(process_list
,
452 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
455 /* Now, the process is in the state hash and our own process hash.
456 * We definitely can draw the items related to the ending state.
459 if(ltt_time_compare(hashed_process_data
->next_good_time
,
462 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
463 processlist_get_pixels_from_data(process_list
,
468 TimeWindow time_window
=
469 lttvwindow_get_time_window(control_flow_data
->tab
);
471 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
472 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
475 Drawing_t
*drawing
= control_flow_data
->drawing
;
476 guint width
= drawing
->width
;
478 convert_time_to_pixels(
484 /* Draw collision indicator */
485 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
486 gdk_draw_point(drawing
->pixmap
,
490 hashed_process_data
->x
.middle_marked
= TRUE
;
493 processlist_get_pixels_from_data(process_list
,
499 TimeWindow time_window
=
500 lttvwindow_get_time_window(control_flow_data
->tab
);
502 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
503 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
506 Drawing_t
*drawing
= control_flow_data
->drawing
;
507 guint width
= drawing
->width
;
509 convert_time_to_pixels(
516 /* Jump over draw if we are at the same x position */
517 if(x
== hashed_process_data
->x
.middle
&&
518 hashed_process_data
->x
.middle_used
)
520 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
521 /* Draw collision indicator */
522 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
523 gdk_draw_point(drawing
->pixmap
,
527 hashed_process_data
->x
.middle_marked
= TRUE
;
531 DrawContext draw_context
;
533 /* Now create the drawing context that will be used to draw
534 * items related to the last state. */
535 draw_context
.drawable
= drawing
->pixmap
;
536 draw_context
.gc
= drawing
->gc
;
537 draw_context
.pango_layout
= drawing
->pango_layout
;
538 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
539 draw_context
.drawinfo
.end
.x
= x
;
541 draw_context
.drawinfo
.y
.over
= y
+1;
542 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
543 draw_context
.drawinfo
.y
.under
= y
+height
;
545 draw_context
.drawinfo
.start
.offset
.over
= 0;
546 draw_context
.drawinfo
.start
.offset
.middle
= 0;
547 draw_context
.drawinfo
.start
.offset
.under
= 0;
548 draw_context
.drawinfo
.end
.offset
.over
= 0;
549 draw_context
.drawinfo
.end
.offset
.middle
= 0;
550 draw_context
.drawinfo
.end
.offset
.under
= 0;
554 PropertiesLine prop_line
= prepare_s_e_line(process
);
555 draw_line((void*)&prop_line
, (void*)&draw_context
);
558 /* become the last x position */
559 hashed_process_data
->x
.middle
= x
;
560 hashed_process_data
->x
.middle_used
= TRUE
;
561 hashed_process_data
->x
.middle_marked
= FALSE
;
563 /* Calculate the next good time */
564 convert_pixels_to_time(width
, x
+1, time_window
,
565 &hashed_process_data
->next_good_time
);
573 /* First, check if the current process is in the state computation
574 * process list. If it is there, that means we must add it right now and
575 * draw items from the beginning of the read for it. If it is not
576 * present, it's a new process and it was not present : it will
577 * be added after the state update. */
578 LttvProcessState
*process
;
579 process
= lttv_state_find_process(tfs
, pid_in
);
581 if(process
!= NULL
) {
582 /* Well, the process_out existed : we must get it in the process hash
583 * or add it, and draw its items.
585 /* Add process to process list (if not present) */
586 guint y
= 0, height
= 0, pl_height
= 0;
587 HashedProcessData
*hashed_process_data
= NULL
;
588 ProcessList
*process_list
= control_flow_data
->process_list
;
589 LttTime birth
= process
->creation_time
;
591 hashed_process_data
= processlist_get_process_data(process_list
,
593 process
->last_cpu_index
,
595 tfc
->t_context
->index
);
596 if(hashed_process_data
== NULL
)
598 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
599 const gchar
*name
= g_quark_to_string(process
->name
);
600 /* Process not present */
601 ProcessInfo
*process_info
;
602 processlist_add(process_list
,
604 process
->last_cpu_index
,
607 tfc
->t_context
->index
,
611 &hashed_process_data
);
612 processlist_get_pixels_from_data(process_list
,
616 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
618 //We could set the current process and hash here, but will be done
619 //by after schedchange hook
621 /* Now, the process is in the state hash and our own process hash.
622 * We definitely can draw the items related to the ending state.
625 if(ltt_time_compare(hashed_process_data
->next_good_time
,
628 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
630 processlist_get_pixels_from_data(process_list
,
634 TimeWindow time_window
=
635 lttvwindow_get_time_window(control_flow_data
->tab
);
637 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
638 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
641 Drawing_t
*drawing
= control_flow_data
->drawing
;
642 guint width
= drawing
->width
;
644 convert_time_to_pixels(
650 /* Draw collision indicator */
651 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
652 gdk_draw_point(drawing
->pixmap
,
656 hashed_process_data
->x
.middle_marked
= TRUE
;
659 processlist_get_pixels_from_data(process_list
,
663 TimeWindow time_window
=
664 lttvwindow_get_time_window(control_flow_data
->tab
);
666 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
667 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
670 Drawing_t
*drawing
= control_flow_data
->drawing
;
671 guint width
= drawing
->width
;
674 convert_time_to_pixels(
681 /* Jump over draw if we are at the same x position */
682 if(x
== hashed_process_data
->x
.middle
&&
683 hashed_process_data
->x
.middle_used
)
685 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
686 /* Draw collision indicator */
687 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
688 gdk_draw_point(drawing
->pixmap
,
692 hashed_process_data
->x
.middle_marked
= TRUE
;
696 DrawContext draw_context
;
698 /* Now create the drawing context that will be used to draw
699 * items related to the last state. */
700 draw_context
.drawable
= drawing
->pixmap
;
701 draw_context
.gc
= drawing
->gc
;
702 draw_context
.pango_layout
= drawing
->pango_layout
;
703 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
704 draw_context
.drawinfo
.end
.x
= x
;
706 draw_context
.drawinfo
.y
.over
= y
+1;
707 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
708 draw_context
.drawinfo
.y
.under
= y
+height
;
710 draw_context
.drawinfo
.start
.offset
.over
= 0;
711 draw_context
.drawinfo
.start
.offset
.middle
= 0;
712 draw_context
.drawinfo
.start
.offset
.under
= 0;
713 draw_context
.drawinfo
.end
.offset
.over
= 0;
714 draw_context
.drawinfo
.end
.offset
.middle
= 0;
715 draw_context
.drawinfo
.end
.offset
.under
= 0;
719 PropertiesLine prop_line
= prepare_s_e_line(process
);
720 draw_line((void*)&prop_line
, (void*)&draw_context
);
724 /* become the last x position */
725 hashed_process_data
->x
.middle
= x
;
726 hashed_process_data
->x
.middle_used
= TRUE
;
727 hashed_process_data
->x
.middle_marked
= FALSE
;
729 /* Calculate the next good time */
730 convert_pixels_to_time(width
, x
+1, time_window
,
731 &hashed_process_data
->next_good_time
);
740 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
741 ControlFlowData
*control_flow_data
=
742 (ControlFlowData
*)events_request
->viewer_data
;
743 Tab
*tab
= control_flow_data
->tab
;
745 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
747 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
748 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
753 LttTime evtime
= ltt_event_time(e
);
754 TimeWindow time_window
=
755 lttvwindow_get_time_window(tab
);
757 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
759 //if(time < time_beg || time > time_end) return;
760 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
761 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
764 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
766 g_debug("schedchange!");
768 /* Add process to process list (if not present) and get drawing "y" from
769 * process position */
770 guint pid_out
, pid_in
;
771 LttvProcessState
*process_out
, *process_in
;
773 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
775 ProcessList
*process_list
= control_flow_data
->process_list
;
778 LttField
*f
= ltt_event_field(e
);
780 element
= ltt_field_member(f
,0);
781 pid_out
= ltt_event_get_long_unsigned(e
,element
);
782 element
= ltt_field_member(f
,1);
783 pid_in
= ltt_event_get_long_unsigned(e
,element
);
784 g_debug("out : %u in : %u", pid_out
, pid_in
);
787 /* Find process pid_out in the list... */
788 process_out
= lttv_state_find_process(tfs
, pid_out
);
789 if(process_out
== NULL
) return 0;
790 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
792 birth
= process_out
->creation_time
;
793 const gchar
*name
= g_quark_to_string(process_out
->name
);
794 HashedProcessData
*hashed_process_data_out
= NULL
;
796 if(processlist_get_process_pixels(process_list
,
799 tfc
->t_context
->index
,
802 &hashed_process_data_out
) == 1)
804 /* Process not present */
805 processlist_add(process_list
,
808 tfc
->t_context
->index
,
811 &hashed_process_data_out
);
812 g_assert(processlist_get_process_pixels(process_list
,
815 tfc
->t_context
->index
,
818 &hashed_process_data_out
)==0);
819 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
823 /* Find process pid_in in the list... */
824 process_in
= lttv_state_find_process(tfs
, pid_in
);
825 if(process_in
== NULL
) return 0;
826 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
828 birth
= process_in
->creation_time
;
829 name
= g_quark_to_string(process_in
->name
);
830 HashedProcessData
*hashed_process_data_in
= NULL
;
832 if(processlist_get_process_pixels(process_list
,
835 tfc
->t_context
->index
,
838 &hashed_process_data_in
) == 1)
840 /* Process not present */
841 processlist_add(process_list
,
844 tfc
->t_context
->index
,
847 &hashed_process_data_in
);
848 processlist_get_process_pixels(process_list
,
851 tfc
->t_context
->index
,
854 &hashed_process_data_in
);
856 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
861 /* Find pixels corresponding to time of the event. If the time does
862 * not fit in the window, show a warning, not supposed to happend. */
864 guint width
= control_flow_data
->drawing
->width
;
866 LttTime time
= ltt_event_time(e
);
868 LttTime window_end
= time_window
.time_window
.end_time
;
870 convert_time_to_pixels(
875 //assert(x <= width);
877 /* draw what represents the event for outgoing process. */
879 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
880 draw_context_out
->current
->modify_over
->x
= x
;
881 draw_context_out
->current
->modify_under
->x
= x
;
882 draw_context_out
->current
->modify_over
->y
= y_out
;
883 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
884 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
885 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
886 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
887 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
888 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
889 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
890 //draw_context_out->gc = widget->style->black_gc;
892 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
893 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
895 /* Draw the line/background of the out process */
896 if(draw_context_out
->previous
->middle
->x
== -1)
898 draw_context_out
->previous
->over
->x
=
899 control_flow_data
->drawing
->damage_begin
;
900 draw_context_out
->previous
->middle
->x
=
901 control_flow_data
->drawing
->damage_begin
;
902 draw_context_out
->previous
->under
->x
=
903 control_flow_data
->drawing
->damage_begin
;
904 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
907 draw_context_out
->current
->middle
->x
= x
;
908 draw_context_out
->current
->over
->x
= x
;
909 draw_context_out
->current
->under
->x
= x
;
910 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
911 draw_context_out
->current
->over
->y
= y_out
;
912 draw_context_out
->current
->under
->y
= y_out
+ height
;
913 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
914 draw_context_out
->previous
->over
->y
= y_out
;
915 draw_context_out
->previous
->under
->y
= y_out
+ height
;
917 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
918 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
920 if(process_out
->state
->s
== LTTV_STATE_RUN
)
922 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
923 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
924 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
926 PropertiesBG prop_bg
;
927 prop_bg
.color
= g_new(GdkColor
,1);
931 prop_bg
.color
->red
= 0x1515;
932 prop_bg
.color
->green
= 0x1515;
933 prop_bg
.color
->blue
= 0x8c8c;
936 prop_bg
.color
->red
= 0x4e4e;
937 prop_bg
.color
->green
= 0xa9a9;
938 prop_bg
.color
->blue
= 0xa4a4;
941 prop_bg
.color
->red
= 0x7a7a;
942 prop_bg
.color
->green
= 0x4a4a;
943 prop_bg
.color
->blue
= 0x8b8b;
946 prop_bg
.color
->red
= 0x8080;
947 prop_bg
.color
->green
= 0x7777;
948 prop_bg
.color
->blue
= 0x4747;
951 prop_bg
.color
->red
= 0xe7e7;
952 prop_bg
.color
->green
= 0xe7e7;
953 prop_bg
.color
->blue
= 0xe7e7;
956 g_debug("calling from draw_event");
957 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
958 g_free(prop_bg
.color
);
959 //gdk_gc_unref(draw_context_out->gc);
962 draw_context_out
->gc
= widget
->style
->black_gc
;
964 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
965 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
966 PropertiesText prop_text_out
;
967 prop_text_out
.foreground
= &colorfg_out
;
968 prop_text_out
.background
= &colorbg_out
;
969 prop_text_out
.size
= 6;
970 prop_text_out
.position
= OVER
;
972 /* color of text : status of the process */
973 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
975 prop_text_out
.foreground
->red
= 0xffff;
976 prop_text_out
.foreground
->green
= 0xffff;
977 prop_text_out
.foreground
->blue
= 0xffff;
979 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
981 prop_text_out
.foreground
->red
= 0x0fff;
982 prop_text_out
.foreground
->green
= 0xffff;
983 prop_text_out
.foreground
->blue
= 0xfff0;
985 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
987 prop_text_out
.foreground
->red
= 0xffff;
988 prop_text_out
.foreground
->green
= 0xffff;
989 prop_text_out
.foreground
->blue
= 0x0000;
991 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
993 prop_text_out
.foreground
->red
= 0xffff;
994 prop_text_out
.foreground
->green
= 0x0000;
995 prop_text_out
.foreground
->blue
= 0xffff;
997 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
999 prop_text_out
.foreground
->red
= 0xffff;
1000 prop_text_out
.foreground
->green
= 0x0000;
1001 prop_text_out
.foreground
->blue
= 0x0000;
1003 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1005 prop_text_out
.foreground
->red
= 0x0000;
1006 prop_text_out
.foreground
->green
= 0xffff;
1007 prop_text_out
.foreground
->blue
= 0x0000;
1011 prop_text_out
.foreground
->red
= 0xffff;
1012 prop_text_out
.foreground
->green
= 0xffff;
1013 prop_text_out
.foreground
->blue
= 0xffff;
1017 /* Print status of the process : U, WF, WC, E, W, R */
1018 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1019 prop_text_out
.text
= "U->";
1020 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1021 prop_text_out
.text
= "WF->";
1022 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1023 prop_text_out
.text
= "WC->";
1024 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1025 prop_text_out
.text
= "E->";
1026 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1027 prop_text_out
.text
= "W->";
1028 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1029 prop_text_out
.text
= "R->";
1031 prop_text_out
.text
= "U";
1033 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1034 //gdk_gc_unref(draw_context_out->gc);
1036 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1037 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1038 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
1040 PropertiesLine prop_line_out
;
1041 prop_line_out
.color
= g_new(GdkColor
,1);
1042 prop_line_out
.line_width
= 2;
1043 prop_line_out
.style
= GDK_LINE_SOLID
;
1044 prop_line_out
.position
= MIDDLE
;
1046 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
1048 /* color of line : status of the process */
1049 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1051 prop_line_out
.color
->red
= 0xffff;
1052 prop_line_out
.color
->green
= 0xffff;
1053 prop_line_out
.color
->blue
= 0xffff;
1055 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1057 prop_line_out
.color
->red
= 0x0fff;
1058 prop_line_out
.color
->green
= 0xffff;
1059 prop_line_out
.color
->blue
= 0xfff0;
1061 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1063 prop_line_out
.color
->red
= 0xffff;
1064 prop_line_out
.color
->green
= 0xffff;
1065 prop_line_out
.color
->blue
= 0x0000;
1067 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1069 prop_line_out
.color
->red
= 0xffff;
1070 prop_line_out
.color
->green
= 0x0000;
1071 prop_line_out
.color
->blue
= 0xffff;
1073 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1075 prop_line_out
.color
->red
= 0xffff;
1076 prop_line_out
.color
->green
= 0x0000;
1077 prop_line_out
.color
->blue
= 0x0000;
1079 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1081 prop_line_out
.color
->red
= 0x0000;
1082 prop_line_out
.color
->green
= 0xffff;
1083 prop_line_out
.color
->blue
= 0x0000;
1087 prop_line_out
.color
->red
= 0xffff;
1088 prop_line_out
.color
->green
= 0xffff;
1089 prop_line_out
.color
->blue
= 0xffff;
1092 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1093 g_free(prop_line_out
.color
);
1094 //gdk_gc_unref(draw_context_out->gc);
1095 /* Note : finishing line will have to be added when trace read over. */
1097 /* Finally, update the drawing context of the pid_in. */
1099 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1100 draw_context_in
->current
->modify_over
->x
= x
;
1101 draw_context_in
->current
->modify_under
->x
= x
;
1102 draw_context_in
->current
->modify_over
->y
= y_in
;
1103 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1104 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1105 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1106 widget
= control_flow_data
->drawing
->drawing_area
;
1107 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1108 //draw_context_in->gc = widget->style->black_gc;
1109 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1110 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1112 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1113 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1115 /* Draw the line/bg of the in process */
1116 if(draw_context_in
->previous
->middle
->x
== -1)
1118 draw_context_in
->previous
->over
->x
=
1119 control_flow_data
->drawing
->damage_begin
;
1120 draw_context_in
->previous
->middle
->x
=
1121 control_flow_data
->drawing
->damage_begin
;
1122 draw_context_in
->previous
->under
->x
=
1123 control_flow_data
->drawing
->damage_begin
;
1125 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1129 draw_context_in
->current
->middle
->x
= x
;
1130 draw_context_in
->current
->over
->x
= x
;
1131 draw_context_in
->current
->under
->x
= x
;
1132 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1133 draw_context_in
->current
->over
->y
= y_in
;
1134 draw_context_in
->current
->under
->y
= y_in
+ height
;
1135 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1136 draw_context_in
->previous
->over
->y
= y_in
;
1137 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1139 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1140 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1143 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1145 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1146 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1147 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1149 PropertiesBG prop_bg
;
1150 prop_bg
.color
= g_new(GdkColor
,1);
1152 switch(tfc
->index
) {
1154 prop_bg
.color
->red
= 0x1515;
1155 prop_bg
.color
->green
= 0x1515;
1156 prop_bg
.color
->blue
= 0x8c8c;
1159 prop_bg
.color
->red
= 0x4e4e;
1160 prop_bg
.color
->green
= 0xa9a9;
1161 prop_bg
.color
->blue
= 0xa4a4;
1164 prop_bg
.color
->red
= 0x7a7a;
1165 prop_bg
.color
->green
= 0x4a4a;
1166 prop_bg
.color
->blue
= 0x8b8b;
1169 prop_bg
.color
->red
= 0x8080;
1170 prop_bg
.color
->green
= 0x7777;
1171 prop_bg
.color
->blue
= 0x4747;
1174 prop_bg
.color
->red
= 0xe7e7;
1175 prop_bg
.color
->green
= 0xe7e7;
1176 prop_bg
.color
->blue
= 0xe7e7;
1180 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1181 g_free(prop_bg
.color
);
1182 //gdk_gc_unref(draw_context_in->gc);
1185 draw_context_in
->gc
= widget
->style
->black_gc
;
1187 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1188 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1189 PropertiesText prop_text_in
;
1190 prop_text_in
.foreground
= &colorfg_in
;
1191 prop_text_in
.background
= &colorbg_in
;
1192 prop_text_in
.size
= 6;
1193 prop_text_in
.position
= OVER
;
1195 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1196 /* foreground of text : status of the process */
1197 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1199 prop_text_in
.foreground
->red
= 0xffff;
1200 prop_text_in
.foreground
->green
= 0xffff;
1201 prop_text_in
.foreground
->blue
= 0xffff;
1203 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1205 prop_text_in
.foreground
->red
= 0x0fff;
1206 prop_text_in
.foreground
->green
= 0xffff;
1207 prop_text_in
.foreground
->blue
= 0xfff0;
1209 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1211 prop_text_in
.foreground
->red
= 0xffff;
1212 prop_text_in
.foreground
->green
= 0xffff;
1213 prop_text_in
.foreground
->blue
= 0x0000;
1215 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1217 prop_text_in
.foreground
->red
= 0xffff;
1218 prop_text_in
.foreground
->green
= 0x0000;
1219 prop_text_in
.foreground
->blue
= 0xffff;
1221 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1223 prop_text_in
.foreground
->red
= 0xffff;
1224 prop_text_in
.foreground
->green
= 0x0000;
1225 prop_text_in
.foreground
->blue
= 0x0000;
1227 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1229 prop_text_in
.foreground
->red
= 0x0000;
1230 prop_text_in
.foreground
->green
= 0xffff;
1231 prop_text_in
.foreground
->blue
= 0x0000;
1235 prop_text_in
.foreground
->red
= 0xffff;
1236 prop_text_in
.foreground
->green
= 0xffff;
1237 prop_text_in
.foreground
->blue
= 0xffff;
1242 /* Print status of the process : U, WF, WC, E, W, R */
1243 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1244 prop_text_in
.text
= "U->";
1245 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1246 prop_text_in
.text
= "WF->";
1247 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1248 prop_text_in
.text
= "WC->";
1249 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1250 prop_text_in
.text
= "E->";
1251 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1252 prop_text_in
.text
= "W->";
1253 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1254 prop_text_in
.text
= "R->";
1256 prop_text_in
.text
= "U";
1258 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1259 //gdk_gc_unref(draw_context_in->gc);
1261 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1262 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1263 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1265 PropertiesLine prop_line_in
;
1266 prop_line_in
.color
= g_new(GdkColor
,1);
1267 prop_line_in
.line_width
= 2;
1268 prop_line_in
.style
= GDK_LINE_SOLID
;
1269 prop_line_in
.position
= MIDDLE
;
1271 /* color of line : status of the process */
1272 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1274 prop_line_in
.color
->red
= 0xffff;
1275 prop_line_in
.color
->green
= 0xffff;
1276 prop_line_in
.color
->blue
= 0xffff;
1278 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1280 prop_line_in
.color
->red
= 0x0fff;
1281 prop_line_in
.color
->green
= 0xffff;
1282 prop_line_in
.color
->blue
= 0xfff0;
1284 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1286 prop_line_in
.color
->red
= 0xffff;
1287 prop_line_in
.color
->green
= 0xffff;
1288 prop_line_in
.color
->blue
= 0x0000;
1290 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1292 prop_line_in
.color
->red
= 0xffff;
1293 prop_line_in
.color
->green
= 0x0000;
1294 prop_line_in
.color
->blue
= 0xffff;
1296 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1298 prop_line_in
.color
->red
= 0xffff;
1299 prop_line_in
.color
->green
= 0x0000;
1300 prop_line_in
.color
->blue
= 0x0000;
1302 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1304 prop_line_in
.color
->red
= 0x0000;
1305 prop_line_in
.color
->green
= 0xffff;
1306 prop_line_in
.color
->blue
= 0x0000;
1310 prop_line_in
.color
->red
= 0xffff;
1311 prop_line_in
.color
->green
= 0xffff;
1312 prop_line_in
.color
->blue
= 0xffff;
1315 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1316 g_free(prop_line_in
.color
);
1317 //gdk_gc_unref(draw_context_in->gc);
1327 GString
*string
= g_string_new("");;
1328 gboolean field_names
= TRUE
, state
= TRUE
;
1330 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1331 g_string_append_printf(string
,"\n");
1334 g_string_append_printf(string
, " %s",
1335 g_quark_to_string(tfs
->process
->state
->s
));
1338 g_info("%s",string
->str
);
1340 g_string_free(string
, TRUE
);
1342 /* End of text dump */
1347 /* after_schedchange_hook
1349 * The draw after hook is called by the reading API to have a
1350 * particular event drawn on the screen.
1351 * @param hook_data ControlFlowData structure of the viewer.
1352 * @param call_data Event context.
1354 * This function adds items to be drawn in a queue for each process.
1357 int after_schedchange_hook(void *hook_data
, void *call_data
)
1359 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1360 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1362 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1364 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1369 LttTime evtime
= ltt_event_time(e
);
1371 /* Add process to process list (if not present) */
1372 LttvProcessState
*process_in
;
1374 guint y_in
= 0, height
= 0, pl_height
= 0;
1375 HashedProcessData
*hashed_process_data_in
= NULL
;
1377 ProcessList
*process_list
= control_flow_data
->process_list
;
1382 LttField
*f
= ltt_event_field(e
);
1384 element
= ltt_field_member(f
,0);
1385 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1386 element
= ltt_field_member(f
,1);
1387 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1391 /* Find process pid_in in the list... */
1392 //process_in = lttv_state_find_process(tfs, pid_in);
1393 process_in
= tfs
->process
;
1394 /* It should exist, because we are after the state update. */
1396 g_assert(process_in
!= NULL
);
1397 #endif //EXTRA_CHECK
1398 birth
= process_in
->creation_time
;
1400 hashed_process_data_in
= processlist_get_process_data(process_list
,
1402 process_in
->last_cpu_index
,
1404 tfc
->t_context
->index
);
1405 if(hashed_process_data_in
== NULL
)
1407 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1408 const gchar
*name
= g_quark_to_string(process_in
->name
);
1409 ProcessInfo
*process_info
;
1410 /* Process not present */
1411 processlist_add(process_list
,
1413 process_in
->last_cpu_index
,
1416 tfc
->t_context
->index
,
1420 &hashed_process_data_in
);
1421 processlist_get_pixels_from_data(process_list
,
1422 hashed_process_data_in
,
1425 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1427 /* Set the current process */
1428 process_list
->current_hash_data
[process_in
->last_cpu_index
] =
1429 hashed_process_data_in
;
1431 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
1434 processlist_get_pixels_from_data(process_list
,
1435 hashed_process_data_in
,
1438 TimeWindow time_window
=
1439 lttvwindow_get_time_window(control_flow_data
->tab
);
1442 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1443 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1445 #endif //EXTRA_CHECK
1446 Drawing_t
*drawing
= control_flow_data
->drawing
;
1447 guint width
= drawing
->width
;
1450 convert_time_to_pixels(
1456 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1457 hashed_process_data_in
->x
.middle
= new_x
;
1458 hashed_process_data_in
->x
.middle_used
= FALSE
;
1459 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1469 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1470 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1472 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1474 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1475 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1481 LttTime evtime
= ltt_event_time(e
);
1482 TimeWindow time_window
=
1483 lttvwindow_get_time_window(control_flow_data
->tab
);
1485 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
1487 //if(time < time_beg || time > time_end) return;
1488 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1489 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1493 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1495 g_debug("schedchange!");
1497 /* Add process to process list (if not present) and get drawing "y" from
1498 * process position */
1499 guint pid_out
, pid_in
;
1500 LttvProcessState
*process_out
, *process_in
;
1502 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1504 ProcessList
*process_list
= control_flow_data
->process_list
;
1507 LttField
*f
= ltt_event_field(e
);
1509 element
= ltt_field_member(f
,0);
1510 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1511 element
= ltt_field_member(f
,1);
1512 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1513 //g_debug("out : %u in : %u", pid_out, pid_in);
1516 /* Find process pid_out in the list... */
1517 process_out
= lttv_state_find_process(tfs
, pid_out
);
1518 if(process_out
== NULL
) return 0;
1519 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1521 birth
= process_out
->creation_time
;
1522 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1523 HashedProcessData
*hashed_process_data_out
= NULL
;
1525 if(processlist_get_process_pixels(process_list
,
1528 tfc
->t_context
->index
,
1531 &hashed_process_data_out
) == 1)
1533 /* Process not present */
1534 processlist_add(process_list
,
1537 tfc
->t_context
->index
,
1540 &hashed_process_data_out
);
1541 processlist_get_process_pixels(process_list
,
1544 tfc
->t_context
->index
,
1547 &hashed_process_data_out
);
1548 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1553 /* Find process pid_in in the list... */
1554 process_in
= lttv_state_find_process(tfs
, pid_in
);
1555 if(process_in
== NULL
) return 0;
1556 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1558 birth
= process_in
->creation_time
;
1559 name
= strdup(g_quark_to_string(process_in
->name
));
1560 HashedProcessData
*hashed_process_data_in
= NULL
;
1562 if(processlist_get_process_pixels(process_list
,
1565 tfc
->t_context
->index
,
1568 &hashed_process_data_in
) == 1)
1570 /* Process not present */
1571 processlist_add(process_list
,
1574 tfc
->t_context
->index
,
1577 &hashed_process_data_in
);
1578 processlist_get_process_pixels(process_list
,
1581 tfc
->t_context
->index
,
1584 &hashed_process_data_in
);
1586 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1591 /* Find pixels corresponding to time of the event. If the time does
1592 * not fit in the window, show a warning, not supposed to happend. */
1594 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1596 //LttTime time = ltt_event_time(e);
1598 //LttTime window_end = time_window->time_window.end_time;
1601 //convert_time_to_pixels(
1607 //assert(x <= width);
1609 /* draw what represents the event for outgoing process. */
1611 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1612 //draw_context_out->current->modify_over->x = x;
1613 draw_context_out
->current
->modify_over
->y
= y_out
;
1614 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1615 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1616 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1617 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1618 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1620 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1621 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1623 /*if(process_out->state->s == LTTV_STATE_RUN)
1625 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1626 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1627 PropertiesBG prop_bg;
1628 prop_bg.color = g_new(GdkColor,1);
1630 prop_bg.color->red = 0xffff;
1631 prop_bg.color->green = 0xffff;
1632 prop_bg.color->blue = 0xffff;
1634 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1635 g_free(prop_bg.color);
1636 gdk_gc_unref(draw_context_out->gc);
1639 draw_context_out
->gc
= widget
->style
->black_gc
;
1641 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1642 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1643 PropertiesText prop_text_out
;
1644 prop_text_out
.foreground
= &colorfg_out
;
1645 prop_text_out
.background
= &colorbg_out
;
1646 prop_text_out
.size
= 6;
1647 prop_text_out
.position
= OVER
;
1649 /* color of text : status of the process */
1650 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1652 prop_text_out
.foreground
->red
= 0xffff;
1653 prop_text_out
.foreground
->green
= 0xffff;
1654 prop_text_out
.foreground
->blue
= 0xffff;
1656 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1658 prop_text_out
.foreground
->red
= 0x0fff;
1659 prop_text_out
.foreground
->green
= 0xffff;
1660 prop_text_out
.foreground
->blue
= 0xfff0;
1662 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1664 prop_text_out
.foreground
->red
= 0xffff;
1665 prop_text_out
.foreground
->green
= 0xffff;
1666 prop_text_out
.foreground
->blue
= 0x0000;
1668 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1670 prop_text_out
.foreground
->red
= 0xffff;
1671 prop_text_out
.foreground
->green
= 0x0000;
1672 prop_text_out
.foreground
->blue
= 0xffff;
1674 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1676 prop_text_out
.foreground
->red
= 0xffff;
1677 prop_text_out
.foreground
->green
= 0x0000;
1678 prop_text_out
.foreground
->blue
= 0x0000;
1680 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1682 prop_text_out
.foreground
->red
= 0x0000;
1683 prop_text_out
.foreground
->green
= 0xffff;
1684 prop_text_out
.foreground
->blue
= 0x0000;
1688 prop_text_out
.foreground
->red
= 0xffff;
1689 prop_text_out
.foreground
->green
= 0xffff;
1690 prop_text_out
.foreground
->blue
= 0xffff;
1693 /* Print status of the process : U, WF, WC, E, W, R */
1694 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1695 prop_text_out
.text
= "U";
1696 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1697 prop_text_out
.text
= "WF";
1698 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1699 prop_text_out
.text
= "WC";
1700 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1701 prop_text_out
.text
= "E";
1702 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1703 prop_text_out
.text
= "W";
1704 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1705 prop_text_out
.text
= "R";
1707 prop_text_out
.text
= "U";
1709 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1711 //gdk_gc_unref(draw_context_out->gc);
1713 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1714 draw_context_out
->current
->over
->y
= y_out
;
1715 draw_context_out
->current
->under
->y
= y_out
+height
;
1716 draw_context_out
->current
->status
= process_out
->state
->s
;
1718 /* for pid_out : remove previous, Prev = current, new current (default) */
1719 g_free(draw_context_out
->previous
->modify_under
);
1720 g_free(draw_context_out
->previous
->modify_middle
);
1721 g_free(draw_context_out
->previous
->modify_over
);
1722 g_free(draw_context_out
->previous
->under
);
1723 g_free(draw_context_out
->previous
->middle
);
1724 g_free(draw_context_out
->previous
->over
);
1725 g_free(draw_context_out
->previous
);
1727 draw_context_out
->previous
= draw_context_out
->current
;
1729 draw_context_out
->current
= g_new(DrawInfo
,1);
1730 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1731 draw_context_out
->current
->over
->x
= -1;
1732 draw_context_out
->current
->over
->y
= -1;
1733 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1734 draw_context_out
->current
->middle
->x
= -1;
1735 draw_context_out
->current
->middle
->y
= -1;
1736 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1737 draw_context_out
->current
->under
->x
= -1;
1738 draw_context_out
->current
->under
->y
= -1;
1739 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1740 draw_context_out
->current
->modify_over
->x
= -1;
1741 draw_context_out
->current
->modify_over
->y
= -1;
1742 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1743 draw_context_out
->current
->modify_middle
->x
= -1;
1744 draw_context_out
->current
->modify_middle
->y
= -1;
1745 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1746 draw_context_out
->current
->modify_under
->x
= -1;
1747 draw_context_out
->current
->modify_under
->y
= -1;
1748 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1750 /* Finally, update the drawing context of the pid_in. */
1752 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1753 //draw_context_in->current->modify_over->x = x;
1754 draw_context_in
->current
->modify_over
->y
= y_in
;
1755 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1756 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1757 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1758 widget
= control_flow_data
->drawing
->drawing_area
;
1759 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1761 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1762 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1764 /*if(process_in->state->s == LTTV_STATE_RUN)
1766 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1767 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1768 PropertiesBG prop_bg;
1769 prop_bg.color = g_new(GdkColor,1);
1771 prop_bg.color->red = 0xffff;
1772 prop_bg.color->green = 0xffff;
1773 prop_bg.color->blue = 0xffff;
1775 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1776 g_free(prop_bg.color);
1777 gdk_gc_unref(draw_context_in->gc);
1780 draw_context_in
->gc
= widget
->style
->black_gc
;
1782 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1783 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1784 PropertiesText prop_text_in
;
1785 prop_text_in
.foreground
= &colorfg_in
;
1786 prop_text_in
.background
= &colorbg_in
;
1787 prop_text_in
.size
= 6;
1788 prop_text_in
.position
= OVER
;
1790 /* foreground of text : status of the process */
1791 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1793 prop_text_in
.foreground
->red
= 0xffff;
1794 prop_text_in
.foreground
->green
= 0xffff;
1795 prop_text_in
.foreground
->blue
= 0xffff;
1797 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1799 prop_text_in
.foreground
->red
= 0x0fff;
1800 prop_text_in
.foreground
->green
= 0xffff;
1801 prop_text_in
.foreground
->blue
= 0xfff0;
1803 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1805 prop_text_in
.foreground
->red
= 0xffff;
1806 prop_text_in
.foreground
->green
= 0xffff;
1807 prop_text_in
.foreground
->blue
= 0x0000;
1809 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1811 prop_text_in
.foreground
->red
= 0xffff;
1812 prop_text_in
.foreground
->green
= 0x0000;
1813 prop_text_in
.foreground
->blue
= 0xffff;
1815 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1817 prop_text_in
.foreground
->red
= 0xffff;
1818 prop_text_in
.foreground
->green
= 0x0000;
1819 prop_text_in
.foreground
->blue
= 0x0000;
1821 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1823 prop_text_in
.foreground
->red
= 0x0000;
1824 prop_text_in
.foreground
->green
= 0xffff;
1825 prop_text_in
.foreground
->blue
= 0x0000;
1829 prop_text_in
.foreground
->red
= 0xffff;
1830 prop_text_in
.foreground
->green
= 0xffff;
1831 prop_text_in
.foreground
->blue
= 0xffff;
1835 /* Print status of the process : U, WF, WC, E, W, R */
1836 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1837 prop_text_in
.text
= "U";
1838 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1839 prop_text_in
.text
= "WF";
1840 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1841 prop_text_in
.text
= "WC";
1842 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1843 prop_text_in
.text
= "E";
1844 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1845 prop_text_in
.text
= "W";
1846 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1847 prop_text_in
.text
= "R";
1849 prop_text_in
.text
= "U";
1851 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1854 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1857 prop_text_in
.foreground
= &colorfg_in
;
1858 prop_text_in
.background
= &colorbg_in
;
1859 prop_text_in
.foreground
->red
= 0xffff;
1860 prop_text_in
.foreground
->green
= 0xffff;
1861 prop_text_in
.foreground
->blue
= 0xffff;
1862 prop_text_in
.size
= 6;
1863 prop_text_in
.position
= UNDER
;
1865 prop_text_in
.text
= g_new(gchar
, 260);
1866 strcpy(prop_text_in
.text
, "CPU ");
1867 snprintf(tmp
, 255, "%u", tfc
->index
);
1868 strcat(prop_text_in
.text
, tmp
);
1870 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1871 g_free(prop_text_in
.text
);
1875 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1876 draw_context_in
->current
->over
->y
= y_in
;
1877 draw_context_in
->current
->under
->y
= y_in
+height
;
1878 draw_context_in
->current
->status
= process_in
->state
->s
;
1880 /* for pid_in : remove previous, Prev = current, new current (default) */
1881 g_free(draw_context_in
->previous
->modify_under
);
1882 g_free(draw_context_in
->previous
->modify_middle
);
1883 g_free(draw_context_in
->previous
->modify_over
);
1884 g_free(draw_context_in
->previous
->under
);
1885 g_free(draw_context_in
->previous
->middle
);
1886 g_free(draw_context_in
->previous
->over
);
1887 g_free(draw_context_in
->previous
);
1889 draw_context_in
->previous
= draw_context_in
->current
;
1891 draw_context_in
->current
= g_new(DrawInfo
,1);
1892 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1893 draw_context_in
->current
->over
->x
= -1;
1894 draw_context_in
->current
->over
->y
= -1;
1895 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1896 draw_context_in
->current
->middle
->x
= -1;
1897 draw_context_in
->current
->middle
->y
= -1;
1898 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1899 draw_context_in
->current
->under
->x
= -1;
1900 draw_context_in
->current
->under
->y
= -1;
1901 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1902 draw_context_in
->current
->modify_over
->x
= -1;
1903 draw_context_in
->current
->modify_over
->y
= -1;
1904 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1905 draw_context_in
->current
->modify_middle
->x
= -1;
1906 draw_context_in
->current
->modify_middle
->y
= -1;
1907 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1908 draw_context_in
->current
->modify_under
->x
= -1;
1909 draw_context_in
->current
->modify_under
->y
= -1;
1910 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1919 static inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1921 PropertiesLine prop_line
;
1922 prop_line
.line_width
= 1;
1923 prop_line
.style
= GDK_LINE_SOLID
;
1925 //GdkColormap *colormap = gdk_colormap_get_system();
1927 /* color of line : execution mode of the process */
1928 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1929 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1930 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1931 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1932 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1933 prop_line
.color
= drawing_colors
[COL_TRAP
];
1934 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1935 prop_line
.color
= drawing_colors
[COL_IRQ
];
1936 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1937 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1939 prop_line
.color
= drawing_colors
[COL_WHITE
];
1941 //gdk_colormap_alloc_color(colormap,
1952 /* before_execmode_hook
1954 * This function basically draw lines and icons. Two types of lines are drawn :
1955 * one small (3 pixels?) representing the state of the process and the second
1956 * type is thicker (10 pixels?) representing on which CPU a process is running
1957 * (and this only in running state).
1959 * Extremums of the lines :
1960 * x_min : time of the last event context for this process kept in memory.
1961 * x_max : time of the current event.
1962 * y : middle of the process in the process list. The process is found in the
1963 * list, therefore is it's position in pixels.
1965 * The choice of lines'color is defined by the context of the last event for this
1970 int before_execmode_hook(void *hook_data
, void *call_data
)
1972 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1973 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1975 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1977 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1982 LttTime evtime
= ltt_event_time(e
);
1984 /* we are in a execmode, before the state update. We must draw the
1985 * items corresponding to the state before it changes : now is the right
1989 LttvProcessState
*process
= tfs
->process
;
1990 g_assert(process
!= NULL
);
1992 guint pid
= process
->pid
;
1994 /* Well, the process_out existed : we must get it in the process hash
1995 * or add it, and draw its items.
1997 /* Add process to process list (if not present) */
1998 guint y
= 0, height
= 0, pl_height
= 0;
1999 HashedProcessData
*hashed_process_data
= NULL
;
2000 ProcessList
*process_list
= control_flow_data
->process_list
;
2001 LttTime birth
= process
->creation_time
;
2003 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
2004 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2006 hashed_process_data
= processlist_get_process_data(process_list
,
2008 process
->last_cpu_index
,
2010 tfc
->t_context
->index
);
2011 if(unlikely(hashed_process_data
== NULL
))
2013 g_assert(pid
== 0 || pid
!= process
->ppid
);
2014 ProcessInfo
*process_info
;
2015 /* Process not present */
2016 const gchar
*name
= g_quark_to_string(process
->name
);
2017 processlist_add(process_list
,
2019 process
->last_cpu_index
,
2022 tfc
->t_context
->index
,
2026 &hashed_process_data
);
2027 processlist_get_pixels_from_data(process_list
,
2028 hashed_process_data
,
2031 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2033 /* Set the current process */
2034 process_list
->current_hash_data
[process
->last_cpu_index
] =
2035 hashed_process_data
;
2038 /* Now, the process is in the state hash and our own process hash.
2039 * We definitely can draw the items related to the ending state.
2042 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2045 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2046 processlist_get_pixels_from_data(process_list
,
2047 hashed_process_data
,
2050 TimeWindow time_window
=
2051 lttvwindow_get_time_window(control_flow_data
->tab
);
2054 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2055 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2057 #endif //EXTRA_CHECK
2058 Drawing_t
*drawing
= control_flow_data
->drawing
;
2059 guint width
= drawing
->width
;
2061 convert_time_to_pixels(
2067 /* Draw collision indicator */
2068 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2069 gdk_draw_point(drawing
->pixmap
,
2073 hashed_process_data
->x
.middle_marked
= TRUE
;
2076 processlist_get_pixels_from_data(process_list
,
2077 hashed_process_data
,
2080 TimeWindow time_window
=
2081 lttvwindow_get_time_window(control_flow_data
->tab
);
2084 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2085 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2087 #endif //EXTRA_CHECK
2088 Drawing_t
*drawing
= control_flow_data
->drawing
;
2089 guint width
= drawing
->width
;
2092 convert_time_to_pixels(
2099 /* Jump over draw if we are at the same x position */
2100 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2101 hashed_process_data
->x
.middle_used
))
2103 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2104 /* Draw collision indicator */
2105 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2106 gdk_draw_point(drawing
->pixmap
,
2110 hashed_process_data
->x
.middle_marked
= TRUE
;
2115 DrawContext draw_context
;
2116 /* Now create the drawing context that will be used to draw
2117 * items related to the last state. */
2118 draw_context
.drawable
= drawing
->pixmap
;
2119 draw_context
.gc
= drawing
->gc
;
2120 draw_context
.pango_layout
= drawing
->pango_layout
;
2121 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2122 draw_context
.drawinfo
.end
.x
= x
;
2124 draw_context
.drawinfo
.y
.over
= y
+1;
2125 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2126 draw_context
.drawinfo
.y
.under
= y
+height
;
2128 draw_context
.drawinfo
.start
.offset
.over
= 0;
2129 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2130 draw_context
.drawinfo
.start
.offset
.under
= 0;
2131 draw_context
.drawinfo
.end
.offset
.over
= 0;
2132 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2133 draw_context
.drawinfo
.end
.offset
.under
= 0;
2137 PropertiesLine prop_line
= prepare_s_e_line(process
);
2138 draw_line((void*)&prop_line
, (void*)&draw_context
);
2141 /* become the last x position */
2142 hashed_process_data
->x
.middle
= x
;
2143 hashed_process_data
->x
.middle_used
= TRUE
;
2144 hashed_process_data
->x
.middle_marked
= FALSE
;
2146 /* Calculate the next good time */
2147 convert_pixels_to_time(width
, x
+1, time_window
,
2148 &hashed_process_data
->next_good_time
);
2155 /* after_execmode_hook
2157 * The draw after hook is called by the reading API to have a
2158 * particular event drawn on the screen.
2159 * @param hook_data ControlFlowData structure of the viewer.
2160 * @param call_data Event context.
2162 * This function adds items to be drawn in a queue for each process.
2165 int after_execmode_hook(void *hook_data
, void *call_data
)
2167 /**************** DOES NOTHING!! *************/
2168 /* hook desactivated in drawing.c */
2173 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2174 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2176 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2178 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2183 LttTime evtime
= ltt_event_time(e
);
2185 /* Add process to process list (if not present) */
2186 LttvProcessState
*process
;
2188 guint y
= 0, height
= 0, pl_height
= 0;
2189 HashedProcessData
*hashed_process_data
= NULL
;
2191 ProcessList
*process_list
= control_flow_data
->process_list
;
2193 /* Find process pid_in in the list... */
2194 process
= tfs
->process
;
2195 /* It should exist, because we are after the state update. */
2196 g_assert(process
!= NULL
);
2198 guint pid
= process
->pid
;
2200 birth
= process
->creation_time
;
2202 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
2203 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2205 hashed_process_data
= processlist_get_process_data(process_list
,
2207 process
->last_cpu_index
,
2209 tfc
->t_context
->index
);
2210 if(unlikely(hashed_process_data
== NULL
))
2212 g_assert(pid
== 0 || pid
!= process
->ppid
);
2213 /* Process not present */
2214 const gchar
*name
= g_quark_to_string(process
->name
);
2215 ProcessInfo
*process_info
;
2216 processlist_add(process_list
,
2218 process
->last_cpu_index
,
2221 tfc
->t_context
->index
,
2225 &hashed_process_data
);
2226 processlist_get_pixels_from_data(process_list
,
2227 hashed_process_data
,
2230 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2232 /* Set the current process */
2233 process_list
->current_hash_data
[process
->last_cpu_index
] =
2234 hashed_process_data
;
2237 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2241 processlist_get_pixels_from_data(process_list
,
2242 hashed_process_data
,
2246 TimeWindow time_window
=
2247 lttvwindow_get_time_window(control_flow_data
->tab
);
2250 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2251 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2253 #endif //EXTRA_CHECK
2254 Drawing_t
*drawing
= control_flow_data
->drawing
;
2255 guint width
= drawing
->width
;
2258 convert_time_to_pixels(
2264 if(hashed_process_data
->x
.middle
!= new_x
) {
2265 hashed_process_data
->x
.middle
= new_x
;
2266 hashed_process_data
->x
.middle_used
= FALSE
;
2267 hashed_process_data
->x
.middle_marked
= FALSE
;
2275 /* before_process_hook
2277 * Draw lines for process event.
2279 * @param hook_data ControlFlowData structure of the viewer.
2280 * @param call_data Event context.
2282 * This function adds items to be drawn in a queue for each process.
2285 int before_process_hook(void *hook_data
, void *call_data
)
2287 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2288 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2290 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2292 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2297 LttTime evtime
= ltt_event_time(e
);
2301 LttField
*f
= ltt_event_field(e
);
2303 element
= ltt_field_member(f
,0);
2304 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2307 if(sub_id
== 3) { /* exit */
2309 /* Add process to process list (if not present) */
2310 LttvProcessState
*process
= tfs
->process
;
2311 guint pid
= process
->pid
;
2313 guint y
= 0, height
= 0, pl_height
= 0;
2314 HashedProcessData
*hashed_process_data
= NULL
;
2316 ProcessList
*process_list
= control_flow_data
->process_list
;
2318 g_assert(process
!= NULL
);
2320 birth
= process
->creation_time
;
2322 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
2323 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2325 hashed_process_data
= processlist_get_process_data(process_list
,
2327 process
->last_cpu_index
,
2329 tfc
->t_context
->index
);
2330 if(unlikely(hashed_process_data
== NULL
))
2332 g_assert(pid
== 0 || pid
!= process
->ppid
);
2333 /* Process not present */
2334 const gchar
*name
= g_quark_to_string(process
->name
);
2335 ProcessInfo
*process_info
;
2336 processlist_add(process_list
,
2338 process
->last_cpu_index
,
2341 tfc
->t_context
->index
,
2345 &hashed_process_data
);
2346 processlist_get_pixels_from_data(process_list
,
2347 hashed_process_data
,
2350 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2354 /* Now, the process is in the state hash and our own process hash.
2355 * We definitely can draw the items related to the ending state.
2358 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2361 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2362 processlist_get_pixels_from_data(process_list
,
2363 hashed_process_data
,
2366 TimeWindow time_window
=
2367 lttvwindow_get_time_window(control_flow_data
->tab
);
2370 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2371 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2373 #endif //EXTRA_CHECK
2374 Drawing_t
*drawing
= control_flow_data
->drawing
;
2375 guint width
= drawing
->width
;
2377 convert_time_to_pixels(
2383 /* Draw collision indicator */
2384 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2385 gdk_draw_point(drawing
->pixmap
,
2389 hashed_process_data
->x
.middle_marked
= TRUE
;
2392 processlist_get_pixels_from_data(process_list
,
2393 hashed_process_data
,
2396 TimeWindow time_window
=
2397 lttvwindow_get_time_window(control_flow_data
->tab
);
2400 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2401 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2403 #endif //EXTRA_CHECK
2404 Drawing_t
*drawing
= control_flow_data
->drawing
;
2405 guint width
= drawing
->width
;
2408 convert_time_to_pixels(
2415 /* Jump over draw if we are at the same x position */
2416 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2417 hashed_process_data
->x
.middle_used
))
2419 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2420 /* Draw collision indicator */
2421 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2422 gdk_draw_point(drawing
->pixmap
,
2426 hashed_process_data
->x
.middle_marked
= TRUE
;
2430 DrawContext draw_context
;
2432 /* Now create the drawing context that will be used to draw
2433 * items related to the last state. */
2434 draw_context
.drawable
= drawing
->pixmap
;
2435 draw_context
.gc
= drawing
->gc
;
2436 draw_context
.pango_layout
= drawing
->pango_layout
;
2437 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2438 draw_context
.drawinfo
.end
.x
= x
;
2440 draw_context
.drawinfo
.y
.over
= y
+1;
2441 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
2442 draw_context
.drawinfo
.y
.under
= y
+height
;
2444 draw_context
.drawinfo
.start
.offset
.over
= 0;
2445 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2446 draw_context
.drawinfo
.start
.offset
.under
= 0;
2447 draw_context
.drawinfo
.end
.offset
.over
= 0;
2448 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2449 draw_context
.drawinfo
.end
.offset
.under
= 0;
2453 PropertiesLine prop_line
= prepare_s_e_line(process
);
2454 draw_line((void*)&prop_line
, (void*)&draw_context
);
2457 /* become the last x position */
2458 hashed_process_data
->x
.middle
= x
;
2459 hashed_process_data
->x
.middle_used
= TRUE
;
2460 hashed_process_data
->x
.middle_marked
= FALSE
;
2462 /* Calculate the next good time */
2463 convert_pixels_to_time(width
, x
+1, time_window
,
2464 &hashed_process_data
->next_good_time
);
2478 /* after_process_hook
2480 * Create the processlist entry for the child process. Put the last
2481 * position in x at the current time value.
2483 * @param hook_data ControlFlowData structure of the viewer.
2484 * @param call_data Event context.
2486 * This function adds items to be drawn in a queue for each process.
2489 int after_process_hook(void *hook_data
, void *call_data
)
2491 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
2492 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2494 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2496 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2501 LttTime evtime
= ltt_event_time(e
);
2506 LttField
*f
= ltt_event_field(e
);
2508 element
= ltt_field_member(f
,0);
2509 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2510 element
= ltt_field_member(f
,1);
2511 param1
= ltt_event_get_long_unsigned(e
,element
);
2514 if(sub_id
== 2) { /* fork */
2516 guint child_pid
= param1
;
2517 /* Add process to process list (if not present) */
2518 LttvProcessState
*process_child
;
2520 guint y_child
= 0, height
= 0, pl_height
= 0;
2521 HashedProcessData
*hashed_process_data_child
= NULL
;
2523 ProcessList
*process_list
= control_flow_data
->process_list
;
2525 /* Find child in the list... */
2526 process_child
= lttv_state_find_process(tfs
, child_pid
);
2527 /* It should exist, because we are after the state update. */
2528 g_assert(process_child
!= NULL
);
2530 birth
= process_child
->creation_time
;
2532 hashed_process_data_child
= processlist_get_process_data(process_list
,
2534 process_child
->last_cpu_index
,
2536 tfc
->t_context
->index
);
2537 if(likely(hashed_process_data_child
== NULL
))
2539 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
2540 /* Process not present */
2541 const gchar
*name
= g_quark_to_string(process_child
->name
);
2542 ProcessInfo
*process_info
;
2543 processlist_add(process_list
,
2545 process_child
->last_cpu_index
,
2546 process_child
->ppid
,
2548 tfc
->t_context
->index
,
2552 &hashed_process_data_child
);
2553 processlist_get_pixels_from_data(process_list
,
2554 hashed_process_data_child
,
2557 drawing_insert_square( control_flow_data
->drawing
, y_child
, height
);
2561 if(likely(ltt_time_compare(hashed_process_data_child
->next_good_time
,
2565 processlist_get_pixels_from_data(process_list
,
2566 hashed_process_data_child
,
2570 TimeWindow time_window
=
2571 lttvwindow_get_time_window(control_flow_data
->tab
);
2574 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2575 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2577 #endif //EXTRA_CHECK
2578 Drawing_t
*drawing
= control_flow_data
->drawing
;
2579 guint width
= drawing
->width
;
2581 convert_time_to_pixels(
2587 if(likely(hashed_process_data_child
->x
.over
!= new_x
)) {
2588 hashed_process_data_child
->x
.over
= new_x
;
2589 hashed_process_data_child
->x
.over_used
= FALSE
;
2590 hashed_process_data_child
->x
.over_marked
= FALSE
;
2592 if(likely(hashed_process_data_child
->x
.middle
!= new_x
)) {
2593 hashed_process_data_child
->x
.middle
= new_x
;
2594 hashed_process_data_child
->x
.middle_used
= FALSE
;
2595 hashed_process_data_child
->x
.middle_marked
= FALSE
;
2597 if(likely(hashed_process_data_child
->x
.under
!= new_x
)) {
2598 hashed_process_data_child
->x
.under
= new_x
;
2599 hashed_process_data_child
->x
.under_used
= FALSE
;
2600 hashed_process_data_child
->x
.under_marked
= FALSE
;
2604 } else if(sub_id
== 3) { /* exit */
2606 /* Add process to process list (if not present) */
2607 LttvProcessState
*process
= tfs
->process
;
2608 guint pid
= process
->pid
;
2610 guint y
= 0, height
= 0, pl_height
= 0;
2611 HashedProcessData
*hashed_process_data
= NULL
;
2613 ProcessList
*process_list
= control_flow_data
->process_list
;
2615 /* It should exist, because we are after the state update. */
2616 g_assert(process
!= NULL
);
2618 birth
= process
->creation_time
;
2620 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
) ){
2621 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2623 hashed_process_data
= processlist_get_process_data(process_list
,
2625 process
->last_cpu_index
,
2627 tfc
->t_context
->index
);
2628 if(unlikely(hashed_process_data
== NULL
))
2630 g_assert(pid
== 0 || pid
!= process
->ppid
);
2631 /* Process not present */
2632 const gchar
*name
= g_quark_to_string(process
->name
);
2633 ProcessInfo
*process_info
;
2634 processlist_add(process_list
,
2636 process
->last_cpu_index
,
2639 tfc
->t_context
->index
,
2643 &hashed_process_data
);
2644 processlist_get_pixels_from_data(process_list
,
2645 hashed_process_data
,
2648 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
2651 /* Set the current process */
2652 process_list
->current_hash_data
[process
->last_cpu_index
] =
2653 hashed_process_data
;
2656 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2660 processlist_get_pixels_from_data(process_list
,
2661 hashed_process_data
,
2665 TimeWindow time_window
=
2666 lttvwindow_get_time_window(control_flow_data
->tab
);
2669 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2670 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2672 #endif //EXTRA_CHECK
2673 Drawing_t
*drawing
= control_flow_data
->drawing
;
2674 guint width
= drawing
->width
;
2676 convert_time_to_pixels(
2681 if(unlikely(hashed_process_data
->x
.middle
!= new_x
)) {
2682 hashed_process_data
->x
.middle
= new_x
;
2683 hashed_process_data
->x
.middle_used
= FALSE
;
2684 hashed_process_data
->x
.middle_marked
= FALSE
;
2694 gint
update_time_window_hook(void *hook_data
, void *call_data
)
2696 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2697 Drawing_t
*drawing
= control_flow_data
->drawing
;
2699 const TimeWindowNotifyData
*time_window_nofify_data
=
2700 ((const TimeWindowNotifyData
*)call_data
);
2702 TimeWindow
*old_time_window
=
2703 time_window_nofify_data
->old_time_window
;
2704 TimeWindow
*new_time_window
=
2705 time_window_nofify_data
->new_time_window
;
2707 /* Update the ruler */
2708 drawing_update_ruler(control_flow_data
->drawing
,
2712 /* Two cases : zoom in/out or scrolling */
2714 /* In order to make sure we can reuse the old drawing, the scale must
2715 * be the same and the new time interval being partly located in the
2716 * currently shown time interval. (reuse is only for scrolling)
2719 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
2720 old_time_window
->start_time
.tv_sec
,
2721 old_time_window
->start_time
.tv_nsec
,
2722 old_time_window
->time_width
.tv_sec
,
2723 old_time_window
->time_width
.tv_nsec
);
2725 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
2726 new_time_window
->start_time
.tv_sec
,
2727 new_time_window
->start_time
.tv_nsec
,
2728 new_time_window
->time_width
.tv_sec
,
2729 new_time_window
->time_width
.tv_nsec
);
2731 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
2732 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
2734 /* Same scale (scrolling) */
2735 g_info("scrolling");
2736 LttTime
*ns
= &new_time_window
->start_time
;
2737 LttTime
*nw
= &new_time_window
->time_width
;
2738 LttTime
*os
= &old_time_window
->start_time
;
2739 LttTime
*ow
= &old_time_window
->time_width
;
2740 LttTime old_end
= old_time_window
->end_time
;
2741 LttTime new_end
= new_time_window
->end_time
;
2743 //if(ns<os+w && os+w<ns+w)
2744 //if(ns<old_end && os<ns)
2745 if(ltt_time_compare(*ns
, old_end
) == -1
2746 && ltt_time_compare(*os
, *ns
) == -1)
2748 g_info("scrolling near right");
2749 /* Scroll right, keep right part of the screen */
2751 guint width
= control_flow_data
->drawing
->width
;
2752 convert_time_to_pixels(
2758 /* Copy old data to new location */
2759 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2760 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2761 control_flow_data
->drawing
->pixmap
,
2764 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
2766 if(drawing
->damage_begin
== drawing
->damage_end
)
2767 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
2769 drawing
->damage_begin
= 0;
2771 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2773 /* Clear the data request background, but not SAFETY */
2774 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2775 //control_flow_data->drawing->drawing_area->style->black_gc,
2776 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2778 drawing
->damage_begin
+SAFETY
, 0,
2779 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2780 control_flow_data
->drawing
->height
);
2781 gtk_widget_queue_draw(drawing
->drawing_area
);
2782 //gtk_widget_queue_draw_area (drawing->drawing_area,
2784 // control_flow_data->drawing->width,
2785 // control_flow_data->drawing->height);
2787 /* Get new data for the rest. */
2788 drawing_data_request(control_flow_data
->drawing
,
2789 &control_flow_data
->drawing
->pixmap
,
2790 drawing
->damage_begin
, 0,
2791 drawing
->damage_end
- drawing
->damage_begin
,
2792 control_flow_data
->drawing
->height
);
2795 //if(ns<os && os<ns+w)
2796 //if(ns<os && os<new_end)
2797 if(ltt_time_compare(*ns
,*os
) == -1
2798 && ltt_time_compare(*os
,new_end
) == -1)
2800 g_info("scrolling near left");
2801 /* Scroll left, keep left part of the screen */
2803 guint width
= control_flow_data
->drawing
->width
;
2804 convert_time_to_pixels(
2811 /* Copy old data to new location */
2812 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
2813 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2814 control_flow_data
->drawing
->pixmap
,
2819 if(drawing
->damage_begin
== drawing
->damage_end
)
2820 drawing
->damage_end
= x
;
2822 drawing
->damage_end
=
2823 control_flow_data
->drawing
->width
;
2825 drawing
->damage_begin
= 0;
2827 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2828 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2830 drawing
->damage_begin
, 0,
2831 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
2832 control_flow_data
->drawing
->height
);
2834 gtk_widget_queue_draw(drawing
->drawing_area
);
2835 //gtk_widget_queue_draw_area (drawing->drawing_area,
2837 // control_flow_data->drawing->width,
2838 // control_flow_data->drawing->height);
2841 /* Get new data for the rest. */
2842 drawing_data_request(control_flow_data
->drawing
,
2843 &control_flow_data
->drawing
->pixmap
,
2844 drawing
->damage_begin
, 0,
2845 drawing
->damage_end
- drawing
->damage_begin
,
2846 control_flow_data
->drawing
->height
);
2849 if(ltt_time_compare(*ns
,*os
) == 0)
2851 g_info("not scrolling");
2853 g_info("scrolling far");
2854 /* Cannot reuse any part of the screen : far jump */
2857 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2858 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2861 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2862 control_flow_data
->drawing
->height
);
2864 //gtk_widget_queue_draw_area (drawing->drawing_area,
2866 // control_flow_data->drawing->width,
2867 // control_flow_data->drawing->height);
2868 gtk_widget_queue_draw(drawing
->drawing_area
);
2870 drawing
->damage_begin
= 0;
2871 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2873 drawing_data_request(control_flow_data
->drawing
,
2874 &control_flow_data
->drawing
->pixmap
,
2876 control_flow_data
->drawing
->width
,
2877 control_flow_data
->drawing
->height
);
2883 /* Different scale (zoom) */
2886 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
2887 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
2890 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
2891 control_flow_data
->drawing
->height
);
2893 //gtk_widget_queue_draw_area (drawing->drawing_area,
2895 // control_flow_data->drawing->width,
2896 // control_flow_data->drawing->height);
2897 gtk_widget_queue_draw(drawing
->drawing_area
);
2899 drawing
->damage_begin
= 0;
2900 drawing
->damage_end
= control_flow_data
->drawing
->width
;
2902 drawing_data_request(control_flow_data
->drawing
,
2903 &control_flow_data
->drawing
->pixmap
,
2905 control_flow_data
->drawing
->width
,
2906 control_flow_data
->drawing
->height
);
2914 gint
traceset_notify(void *hook_data
, void *call_data
)
2916 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2917 Drawing_t
*drawing
= control_flow_data
->drawing
;
2920 drawing_clear(control_flow_data
->drawing
);
2921 processlist_clear(control_flow_data
->process_list
);
2922 redraw_notify(control_flow_data
, NULL
);
2924 request_background_data(control_flow_data
);
2929 gint
redraw_notify(void *hook_data
, void *call_data
)
2931 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2932 Drawing_t
*drawing
= control_flow_data
->drawing
;
2933 GtkWidget
*widget
= drawing
->drawing_area
;
2935 drawing
->damage_begin
= 0;
2936 drawing
->damage_end
= drawing
->width
;
2938 /* fun feature, to be separated someday... */
2939 drawing_clear(control_flow_data
->drawing
);
2940 processlist_clear(control_flow_data
->process_list
);
2943 gdk_draw_rectangle (drawing
->pixmap
,
2944 widget
->style
->black_gc
,
2947 drawing
->width
+SAFETY
,
2951 if(drawing
->damage_begin
< drawing
->damage_end
)
2953 drawing_data_request(drawing
,
2955 drawing
->damage_begin
,
2957 drawing
->damage_end
-drawing
->damage_begin
,
2961 gtk_widget_queue_draw(drawing
->drawing_area
);
2962 //gtk_widget_queue_draw_area(drawing->drawing_area,
2965 // drawing->height);
2971 gint
continue_notify(void *hook_data
, void *call_data
)
2973 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
2974 Drawing_t
*drawing
= control_flow_data
->drawing
;
2976 //g_assert(widget->allocation.width == drawing->damage_end);
2978 if(drawing
->damage_begin
< drawing
->damage_end
)
2980 drawing_data_request(drawing
,
2982 drawing
->damage_begin
,
2984 drawing
->damage_end
-drawing
->damage_begin
,
2992 gint
update_current_time_hook(void *hook_data
, void *call_data
)
2994 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
2995 Drawing_t
*drawing
= control_flow_data
->drawing
;
2997 LttTime current_time
= *((LttTime
*)call_data
);
2999 TimeWindow time_window
=
3000 lttvwindow_get_time_window(control_flow_data
->tab
);
3002 LttTime time_begin
= time_window
.start_time
;
3003 LttTime width
= time_window
.time_width
;
3006 guint64 time_ll
= ltt_time_to_uint64(width
);
3007 time_ll
= time_ll
>> 1; /* divide by two */
3008 half_width
= ltt_time_from_uint64(time_ll
);
3010 LttTime time_end
= ltt_time_add(time_begin
, width
);
3012 LttvTracesetContext
* tsc
=
3013 lttvwindow_get_traceset_context(control_flow_data
->tab
);
3015 LttTime trace_start
= tsc
->time_span
.start_time
;
3016 LttTime trace_end
= tsc
->time_span
.end_time
;
3018 g_info("New current time HOOK : %lu, %lu", current_time
.tv_sec
,
3019 current_time
.tv_nsec
);
3023 /* If current time is inside time interval, just move the highlight
3026 /* Else, we have to change the time interval. We have to tell it
3027 * to the main window. */
3028 /* The time interval change will take care of placing the current
3029 * time at the center of the visible area, or nearest possible if we are
3030 * at one end of the trace. */
3033 if(ltt_time_compare(current_time
, time_begin
) == -1)
3035 TimeWindow new_time_window
;
3037 if(ltt_time_compare(current_time
,
3038 ltt_time_add(trace_start
,half_width
)) == -1)
3039 time_begin
= trace_start
;
3041 time_begin
= ltt_time_sub(current_time
,half_width
);
3043 new_time_window
.start_time
= time_begin
;
3044 new_time_window
.time_width
= width
;
3045 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3046 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3048 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3050 else if(ltt_time_compare(current_time
, time_end
) == 1)
3052 TimeWindow new_time_window
;
3054 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
3055 time_begin
= ltt_time_sub(trace_end
,width
);
3057 time_begin
= ltt_time_sub(current_time
,half_width
);
3059 new_time_window
.start_time
= time_begin
;
3060 new_time_window
.time_width
= width
;
3061 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3062 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3064 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3067 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
3073 typedef struct _ClosureData
{
3074 EventsRequest
*events_request
;
3075 LttvTracesetState
*tss
;
3081 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3083 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3084 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3085 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3087 EventsRequest
*events_request
= closure_data
->events_request
;
3088 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3090 LttvTracesetState
*tss
= closure_data
->tss
;
3091 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
3093 LttTime evtime
= closure_data
->end_time
;
3096 /* For the process */
3097 /* First, check if the current process is in the state computation
3098 * process list. If it is there, that means we must add it right now and
3099 * draw items from the beginning of the read for it. If it is not
3100 * present, it's a new process and it was not present : it will
3101 * be added after the state update. */
3103 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3104 #endif //EXTRA_CHECK
3105 /* tracefiles[0] is ok here, because we draw for every PID, and
3106 * assume CPU 0 for PID 0 //FIXME */
3107 LttvTracefileState
*tfs
=
3108 (LttvTracefileState
*)tsc
->traces
[process_info
->trace_num
]->tracefiles
[0];
3110 LttvProcessState
*process
;
3111 process
= lttv_state_find_process(tfs
,
3114 if(unlikely(process
!= NULL
)) {
3116 /* Only draw for processes that are currently in the trace states */
3118 guint y
= 0, height
= 0;
3119 ProcessList
*process_list
= control_flow_data
->process_list
;
3121 /* Should be alike when background info is ready */
3122 if(control_flow_data
->background_info_waiting
==0)
3123 g_assert(ltt_time_compare(process
->creation_time
,
3124 process_info
->birth
) == 0);
3125 #endif //EXTRA_CHECK
3126 /* process HAS to be present */
3127 processlist_get_pixels_from_data(process_list
,
3128 hashed_process_data
,
3132 /* Now, the process is in the state hash and our own process hash.
3133 * We definitely can draw the items related to the ending state.
3136 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
3139 TimeWindow time_window
=
3140 lttvwindow_get_time_window(control_flow_data
->tab
);
3143 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3144 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3146 #endif //EXTRA_CHECK
3147 Drawing_t
*drawing
= control_flow_data
->drawing
;
3148 guint width
= drawing
->width
;
3150 guint x
= closure_data
->x_end
;
3152 DrawContext draw_context
;
3154 /* Now create the drawing context that will be used to draw
3155 * items related to the last state. */
3156 draw_context
.drawable
= drawing
->pixmap
;
3157 draw_context
.gc
= drawing
->gc
;
3158 draw_context
.pango_layout
= drawing
->pango_layout
;
3159 draw_context
.drawinfo
.end
.x
= x
;
3161 draw_context
.drawinfo
.y
.over
= y
+1;
3162 draw_context
.drawinfo
.y
.middle
= y
+(height
/2);
3163 draw_context
.drawinfo
.y
.under
= y
+height
;
3165 draw_context
.drawinfo
.start
.offset
.over
= 0;
3166 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3167 draw_context
.drawinfo
.start
.offset
.under
= 0;
3168 draw_context
.drawinfo
.end
.offset
.over
= 0;
3169 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3170 draw_context
.drawinfo
.end
.offset
.under
= 0;
3172 /* Jump over draw if we are at the same x position */
3173 if(x
== hashed_process_data
->x
.over
)
3177 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3179 PropertiesLine prop_line
= prepare_execmode_line(process
);
3180 draw_line((void*)&prop_line
, (void*)&draw_context
);
3182 hashed_process_data
->x
.over
= x
;
3186 if(unlikely(x
== hashed_process_data
->x
.middle
&&
3187 hashed_process_data
->x
.middle_used
)) {
3188 #if 0 /* do not mark closure : not missing information */
3189 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3190 /* Draw collision indicator */
3191 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3192 gdk_draw_point(drawing
->pixmap
,
3196 hashed_process_data
->x
.middle_marked
= TRUE
;
3201 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3203 PropertiesLine prop_line
= prepare_s_e_line(process
);
3204 draw_line((void*)&prop_line
, (void*)&draw_context
);
3206 /* become the last x position */
3207 if(likely(x
!= hashed_process_data
->x
.middle
)) {
3208 hashed_process_data
->x
.middle
= x
;
3209 /* but don't use the pixel */
3210 hashed_process_data
->x
.middle_used
= FALSE
;
3212 /* Calculate the next good time */
3213 convert_pixels_to_time(width
, x
+1, time_window
,
3214 &hashed_process_data
->next_good_time
);
3223 int before_chunk(void *hook_data
, void *call_data
)
3225 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3226 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3228 drawing_chunk_begin(events_request
, tss
);
3233 int before_request(void *hook_data
, void *call_data
)
3235 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3236 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3238 drawing_data_request_begin(events_request
, tss
);
3245 * after request is necessary in addition of after chunk in order to draw
3246 * lines until the end of the screen. after chunk just draws lines until
3253 int after_request(void *hook_data
, void *call_data
)
3255 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3256 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3257 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3259 ProcessList
*process_list
= control_flow_data
->process_list
;
3260 LttTime end_time
= events_request
->end_time
;
3262 ClosureData closure_data
;
3263 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3264 closure_data
.tss
= tss
;
3265 closure_data
.end_time
= end_time
;
3267 TimeWindow time_window
=
3268 lttvwindow_get_time_window(control_flow_data
->tab
);
3269 guint width
= control_flow_data
->drawing
->width
;
3270 convert_time_to_pixels(
3274 &closure_data
.x_end
);
3277 /* Draw last items */
3278 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3279 (void*)&closure_data
);
3281 /* Request expose */
3282 drawing_request_expose(events_request
, tss
, end_time
);
3291 int after_chunk(void *hook_data
, void *call_data
)
3293 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3294 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3295 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3296 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
3297 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
3300 ProcessList
*process_list
= control_flow_data
->process_list
;
3302 g_free(process_list
->current_hash_data
);
3303 process_list
->current_hash_data
= NULL
;
3306 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
3307 else /* end of traceset, or position now out of request : end */
3308 end_time
= events_request
->end_time
;
3310 ClosureData closure_data
;
3311 closure_data
.events_request
= (EventsRequest
*)hook_data
;
3312 closure_data
.tss
= tss
;
3313 closure_data
.end_time
= end_time
;
3315 TimeWindow time_window
=
3316 lttvwindow_get_time_window(control_flow_data
->tab
);
3317 guint width
= control_flow_data
->drawing
->width
;
3318 convert_time_to_pixels(
3322 &closure_data
.x_end
);
3324 /* Draw last items */
3325 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
3326 (void*)&closure_data
);
3328 /* Request expose */
3329 drawing_request_expose(events_request
, tss
, end_time
);