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
52 //#define PANGO_ENABLE_BACKEND
60 //#include <pango/pango.h>
62 #include <ltt/event.h>
65 #include <ltt/trace.h>
67 #include <lttv/lttv.h>
68 #include <lttv/hook.h>
69 #include <lttv/state.h>
70 #include <lttvwindow/lttvwindow.h>
71 #include <lttvwindow/lttvwindowtraces.h>
74 #include "eventhooks.h"
76 #include "processlist.h"
80 #define MAX_PATH_LEN 256
83 typedef struct _ProcessAddClosure
{
88 static void process_add(gpointer key
,
92 LttvProcessState
*process
= (LttvProcessState
*)value
;
93 ProcessAddClosure
*closure
= (ProcessAddClosure
*)user_data
;
94 ControlFlowData
*control_flow_data
= closure
->cfd
;
95 guint trace_num
= closure
->trace_num
;
97 /* Add process to process list (if not present) */
100 guint y
= 0, height
= 0, pl_height
= 0;
102 ProcessList
*process_list
= control_flow_data
->process_list
;
105 birth
= process
->creation_time
;
106 const gchar
*name
= g_quark_to_string(process
->name
);
107 HashedProcessData
*hashed_process_data
= NULL
;
109 if(processlist_get_process_pixels(process_list
,
115 &hashed_process_data
) == 1)
117 /* Process not present */
118 processlist_add(process_list
,
124 &hashed_process_data
);
125 processlist_get_process_pixels(process_list
,
131 &hashed_process_data
);
132 drawing_insert_square( control_flow_data
->drawing
, y
, height
);
138 /* Action to do when background computation completed.
140 * Wait for all the awaited computations to be over.
143 gint
background_ready(void *hook_data
, void *call_data
)
145 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
146 LttvTrace
*trace
= (LttvTrace
*)call_data
;
148 control_flow_data
->background_info_waiting
--;
150 if(control_flow_data
->background_info_waiting
== 0) {
151 g_debug("control flow viewer : background computation data ready.");
153 drawing_clear(control_flow_data
->drawing
);
154 processlist_clear(control_flow_data
->process_list
);
155 gtk_widget_set_size_request(
156 control_flow_data
->drawing
->drawing_area
,
157 -1, processlist_get_height(control_flow_data
->process_list
));
158 redraw_notify(control_flow_data
, NULL
);
165 /* Request background computation. Verify if it is in progress or ready first.
166 * Only for each trace in the tab's traceset.
168 void request_background_data(ControlFlowData
*control_flow_data
)
170 LttvTracesetContext
* tsc
=
171 lttvwindow_get_traceset_context(control_flow_data
->tab
);
172 gint num_traces
= lttv_traceset_number(tsc
->ts
);
176 LttvHooks
*background_ready_hook
=
178 lttv_hooks_add(background_ready_hook
, background_ready
, control_flow_data
,
180 control_flow_data
->background_info_waiting
= 0;
182 for(i
=0;i
<num_traces
;i
++) {
183 trace
= lttv_traceset_get(tsc
->ts
, i
);
185 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace
)==FALSE
) {
187 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
189 /* We first remove requests that could have been done for the same
190 * information. Happens when two viewers ask for it before servicing
193 lttvwindowtraces_background_request_remove(trace
, "state");
194 lttvwindowtraces_background_request_queue(trace
,
196 lttvwindowtraces_background_notify_queue(control_flow_data
,
200 background_ready_hook
);
201 control_flow_data
->background_info_waiting
++;
202 } else { /* in progress */
204 lttvwindowtraces_background_notify_current(control_flow_data
,
208 background_ready_hook
);
209 control_flow_data
->background_info_waiting
++;
212 /* Data ready. Be its nature, this viewer doesn't need to have
213 * its data ready hook called htere, because a background
214 * request is always linked with a redraw.
220 lttv_hooks_destroy(background_ready_hook
);
227 * Event Viewer's constructor hook
229 * This constructor is given as a parameter to the menuitem and toolbar button
230 * registration. It creates the list.
231 * @param tab A pointer to the parent tab.
232 * @return The widget created.
235 h_guicontrolflow(Tab
*tab
)
237 g_info("h_guicontrolflow, %p", tab
);
238 ControlFlowData
*control_flow_data
= guicontrolflow() ;
240 control_flow_data
->tab
= tab
;
242 // Unreg done in the GuiControlFlow_Destructor
243 lttvwindow_register_traceset_notify(tab
,
247 lttvwindow_register_time_window_notify(tab
,
248 update_time_window_hook
,
250 lttvwindow_register_current_time_notify(tab
,
251 update_current_time_hook
,
253 lttvwindow_register_redraw_notify(tab
,
256 lttvwindow_register_continue_notify(tab
,
259 request_background_data(control_flow_data
);
262 return guicontrolflow_get_widget(control_flow_data
) ;
266 int event_selected_hook(void *hook_data
, void *call_data
)
268 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
269 guint
*event_number
= (guint
*) call_data
;
271 g_debug("DEBUG : event selected by main window : %u", *event_number
);
276 /* Function that selects the color of status&exemode line */
277 static inline PropertiesLine
prepare_s_e_line(LttvProcessState
*process
)
279 PropertiesLine prop_line
;
280 prop_line
.line_width
= 2;
281 prop_line
.style
= GDK_LINE_SOLID
;
282 prop_line
.y
= MIDDLE
;
283 //GdkColormap *colormap = gdk_colormap_get_system();
285 if(process
->state
->s
== LTTV_STATE_RUN
) {
286 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
287 prop_line
.color
= drawing_colors
[COL_RUN_USER_MODE
];
288 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
289 prop_line
.color
= drawing_colors
[COL_RUN_SYSCALL
];
290 else if(process
->state
->t
== LTTV_STATE_TRAP
)
291 prop_line
.color
= drawing_colors
[COL_RUN_TRAP
];
292 else if(process
->state
->t
== LTTV_STATE_IRQ
)
293 prop_line
.color
= drawing_colors
[COL_RUN_IRQ
];
294 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
295 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
297 g_assert(FALSE
); /* RUNNING MODE UNKNOWN */
298 } else if(process
->state
->s
== LTTV_STATE_WAIT
) {
299 /* We don't show if we wait while in user mode, trap, irq or syscall */
300 prop_line
.color
= drawing_colors
[COL_WAIT
];
301 } else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
) {
302 /* We don't show if we wait for CPU while in user mode, trap, irq
304 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
305 } else if(process
->state
->s
== LTTV_STATE_ZOMBIE
) {
306 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
307 } else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
) {
308 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
309 } else if(process
->state
->s
== LTTV_STATE_EXIT
) {
310 prop_line
.color
= drawing_colors
[COL_EXIT
];
311 } else if(process
->state
->s
== LTTV_STATE_UNNAMED
) {
312 prop_line
.color
= drawing_colors
[COL_UNNAMED
];
314 g_assert(FALSE
); /* UNKNOWN STATE */
321 static inline PropertiesLine
prepare_status_line(LttvProcessState
*process
)
323 PropertiesLine prop_line
;
324 prop_line
.line_width
= 2;
325 prop_line
.style
= GDK_LINE_SOLID
;
326 prop_line
.y
= MIDDLE
;
327 //GdkColormap *colormap = gdk_colormap_get_system();
329 g_debug("prepare_status_line for state : %s",
330 g_quark_to_string(process
->state
->s
));
332 /* color of line : status of the process */
333 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
334 prop_line
.color
= drawing_colors
[COL_WHITE
];
335 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
336 prop_line
.color
= drawing_colors
[COL_WAIT_FORK
];
337 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
338 prop_line
.color
= drawing_colors
[COL_WAIT_CPU
];
339 else if(process
->state
->s
== LTTV_STATE_EXIT
)
340 prop_line
.color
= drawing_colors
[COL_EXIT
];
341 else if(process
->state
->s
== LTTV_STATE_ZOMBIE
)
342 prop_line
.color
= drawing_colors
[COL_ZOMBIE
];
343 else if(process
->state
->s
== LTTV_STATE_WAIT
)
344 prop_line
.color
= drawing_colors
[COL_WAIT
];
345 else if(process
->state
->s
== LTTV_STATE_RUN
)
346 prop_line
.color
= drawing_colors
[COL_RUN
];
348 prop_line
.color
= drawing_colors
[COL_WHITE
];
350 //gdk_colormap_alloc_color(colormap,
361 /* before_schedchange_hook
363 * This function basically draw lines and icons. Two types of lines are drawn :
364 * one small (3 pixels?) representing the state of the process and the second
365 * type is thicker (10 pixels?) representing on which CPU a process is running
366 * (and this only in running state).
368 * Extremums of the lines :
369 * x_min : time of the last event context for this process kept in memory.
370 * x_max : time of the current event.
371 * y : middle of the process in the process list. The process is found in the
372 * list, therefore is it's position in pixels.
374 * The choice of lines'color is defined by the context of the last event for this
379 int before_schedchange_hook(void *hook_data
, void *call_data
)
381 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
382 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
383 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
385 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
387 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
388 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
391 e
= ltt_tracefile_get_event(tfc
->tf
);
393 LttTime evtime
= ltt_event_time(e
);
395 /* we are in a schedchange, before the state update. We must draw the
396 * items corresponding to the state before it changes : now is the right
403 pid_out
= ltt_event_get_long_unsigned(e
, thf
->f1
);
404 pid_in
= ltt_event_get_long_unsigned(e
, thf
->f2
);
408 /* For the pid_out */
409 /* First, check if the current process is in the state computation
410 * process list. If it is there, that means we must add it right now and
411 * draw items from the beginning of the read for it. If it is not
412 * present, it's a new process and it was not present : it will
413 * be added after the state update. */
414 guint cpu
= ltt_tracefile_num(tfc
->tf
);
415 LttvProcessState
*process
= ts
->running_process
[cpu
];
416 /* unknown state, bad current pid */
417 if(process
->pid
!= pid_out
)
418 process
= lttv_state_find_process(ts
, ANY_CPU
, pid_out
);
420 if(process
!= NULL
) {
421 /* Well, the process_out existed : we must get it in the process hash
422 * or add it, and draw its items.
424 /* Add process to process list (if not present) */
426 HashedProcessData
*hashed_process_data
= NULL
;
427 ProcessList
*process_list
= control_flow_data
->process_list
;
428 LttTime birth
= process
->creation_time
;
430 hashed_process_data
= processlist_get_process_data(process_list
,
434 tfc
->t_context
->index
);
435 if(hashed_process_data
== NULL
)
437 g_assert(pid_out
== 0 || pid_out
!= process
->ppid
);
438 const gchar
*name
= g_quark_to_string(process
->name
);
439 /* Process not present */
440 ProcessInfo
*process_info
;
441 Drawing_t
*drawing
= control_flow_data
->drawing
;
442 processlist_add(process_list
,
448 tfc
->t_context
->index
,
452 &hashed_process_data
);
453 gtk_widget_set_size_request(drawing
->drawing_area
,
456 gtk_widget_queue_draw(drawing
->drawing_area
);
460 /* Now, the process is in the state hash and our own process hash.
461 * We definitely can draw the items related to the ending state.
464 if(ltt_time_compare(hashed_process_data
->next_good_time
,
467 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
469 TimeWindow time_window
=
470 lttvwindow_get_time_window(control_flow_data
->tab
);
472 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
473 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
476 Drawing_t
*drawing
= control_flow_data
->drawing
;
477 guint width
= drawing
->width
;
479 convert_time_to_pixels(
485 /* Draw collision indicator */
486 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
487 gdk_draw_point(hashed_process_data
->pixmap
,
490 (hashed_process_data
->height
/2)-3);
491 hashed_process_data
->x
.middle_marked
= TRUE
;
494 TimeWindow time_window
=
495 lttvwindow_get_time_window(control_flow_data
->tab
);
497 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
498 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
501 Drawing_t
*drawing
= control_flow_data
->drawing
;
502 guint width
= drawing
->width
;
504 convert_time_to_pixels(
511 /* Jump over draw if we are at the same x position */
512 if(x
== hashed_process_data
->x
.middle
&&
513 hashed_process_data
->x
.middle_used
)
515 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
516 /* Draw collision indicator */
517 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
518 gdk_draw_point(hashed_process_data
->pixmap
,
521 (hashed_process_data
->height
/2)-3);
522 hashed_process_data
->x
.middle_marked
= TRUE
;
526 DrawContext draw_context
;
528 /* Now create the drawing context that will be used to draw
529 * items related to the last state. */
530 draw_context
.drawable
= hashed_process_data
->pixmap
;
531 draw_context
.gc
= drawing
->gc
;
532 draw_context
.pango_layout
= drawing
->pango_layout
;
533 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
534 draw_context
.drawinfo
.end
.x
= x
;
536 draw_context
.drawinfo
.y
.over
= 1;
537 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
538 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
540 draw_context
.drawinfo
.start
.offset
.over
= 0;
541 draw_context
.drawinfo
.start
.offset
.middle
= 0;
542 draw_context
.drawinfo
.start
.offset
.under
= 0;
543 draw_context
.drawinfo
.end
.offset
.over
= 0;
544 draw_context
.drawinfo
.end
.offset
.middle
= 0;
545 draw_context
.drawinfo
.end
.offset
.under
= 0;
549 PropertiesLine prop_line
= prepare_s_e_line(process
);
550 draw_line((void*)&prop_line
, (void*)&draw_context
);
553 /* become the last x position */
554 hashed_process_data
->x
.middle
= x
;
555 hashed_process_data
->x
.middle_used
= TRUE
;
556 hashed_process_data
->x
.middle_marked
= FALSE
;
558 /* Calculate the next good time */
559 convert_pixels_to_time(width
, x
+1, time_window
,
560 &hashed_process_data
->next_good_time
);
568 /* First, check if the current process is in the state computation
569 * process list. If it is there, that means we must add it right now and
570 * draw items from the beginning of the read for it. If it is not
571 * present, it's a new process and it was not present : it will
572 * be added after the state update. */
573 LttvProcessState
*process
;
574 process
= lttv_state_find_process(ts
, ANY_CPU
, pid_in
);
576 if(process
!= NULL
) {
577 /* Well, the process_out existed : we must get it in the process hash
578 * or add it, and draw its items.
580 /* Add process to process list (if not present) */
582 HashedProcessData
*hashed_process_data
= NULL
;
583 ProcessList
*process_list
= control_flow_data
->process_list
;
584 LttTime birth
= process
->creation_time
;
586 hashed_process_data
= processlist_get_process_data(process_list
,
590 tfc
->t_context
->index
);
591 if(hashed_process_data
== NULL
)
593 g_assert(pid_in
== 0 || pid_in
!= process
->ppid
);
594 const gchar
*name
= g_quark_to_string(process
->name
);
595 /* Process not present */
596 ProcessInfo
*process_info
;
597 Drawing_t
*drawing
= control_flow_data
->drawing
;
598 processlist_add(process_list
,
604 tfc
->t_context
->index
,
608 &hashed_process_data
);
609 gtk_widget_set_size_request(drawing
->drawing_area
,
612 gtk_widget_queue_draw(drawing
->drawing_area
);
615 //We could set the current process and hash here, but will be done
616 //by after schedchange hook
618 /* Now, the process is in the state hash and our own process hash.
619 * We definitely can draw the items related to the ending state.
622 if(ltt_time_compare(hashed_process_data
->next_good_time
,
625 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
627 TimeWindow time_window
=
628 lttvwindow_get_time_window(control_flow_data
->tab
);
630 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
631 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
634 Drawing_t
*drawing
= control_flow_data
->drawing
;
635 guint width
= drawing
->width
;
637 convert_time_to_pixels(
643 /* Draw collision indicator */
644 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
645 gdk_draw_point(hashed_process_data
->pixmap
,
648 (hashed_process_data
->height
/2)-3);
649 hashed_process_data
->x
.middle_marked
= TRUE
;
652 TimeWindow time_window
=
653 lttvwindow_get_time_window(control_flow_data
->tab
);
655 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
656 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
659 Drawing_t
*drawing
= control_flow_data
->drawing
;
660 guint width
= drawing
->width
;
663 convert_time_to_pixels(
670 /* Jump over draw if we are at the same x position */
671 if(x
== hashed_process_data
->x
.middle
&&
672 hashed_process_data
->x
.middle_used
)
674 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
675 /* Draw collision indicator */
676 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
677 gdk_draw_point(hashed_process_data
->pixmap
,
680 (hashed_process_data
->height
/2)-3);
681 hashed_process_data
->x
.middle_marked
= TRUE
;
685 DrawContext draw_context
;
687 /* Now create the drawing context that will be used to draw
688 * items related to the last state. */
689 draw_context
.drawable
= hashed_process_data
->pixmap
;
690 draw_context
.gc
= drawing
->gc
;
691 draw_context
.pango_layout
= drawing
->pango_layout
;
692 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
693 draw_context
.drawinfo
.end
.x
= x
;
695 draw_context
.drawinfo
.y
.over
= 1;
696 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
697 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
699 draw_context
.drawinfo
.start
.offset
.over
= 0;
700 draw_context
.drawinfo
.start
.offset
.middle
= 0;
701 draw_context
.drawinfo
.start
.offset
.under
= 0;
702 draw_context
.drawinfo
.end
.offset
.over
= 0;
703 draw_context
.drawinfo
.end
.offset
.middle
= 0;
704 draw_context
.drawinfo
.end
.offset
.under
= 0;
708 PropertiesLine prop_line
= prepare_s_e_line(process
);
709 draw_line((void*)&prop_line
, (void*)&draw_context
);
713 /* become the last x position */
714 hashed_process_data
->x
.middle
= x
;
715 hashed_process_data
->x
.middle_used
= TRUE
;
716 hashed_process_data
->x
.middle_marked
= FALSE
;
718 /* Calculate the next good time */
719 convert_pixels_to_time(width
, x
+1, time_window
,
720 &hashed_process_data
->next_good_time
);
729 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
730 ControlFlowData
*control_flow_data
=
731 (ControlFlowData
*)events_request
->viewer_data
;
732 Tab
*tab
= control_flow_data
->tab
;
734 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
736 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
737 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
742 LttTime evtime
= ltt_event_time(e
);
743 TimeWindow time_window
=
744 lttvwindow_get_time_window(tab
);
746 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
748 //if(time < time_beg || time > time_end) return;
749 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
750 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
753 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
755 g_debug("schedchange!");
757 /* Add process to process list (if not present) and get drawing "y" from
758 * process position */
759 guint pid_out
, pid_in
;
760 LttvProcessState
*process_out
, *process_in
;
762 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
764 ProcessList
*process_list
= control_flow_data
->process_list
;
767 LttField
*f
= ltt_event_field(e
);
769 element
= ltt_field_member(f
,0);
770 pid_out
= ltt_event_get_long_unsigned(e
,element
);
771 element
= ltt_field_member(f
,1);
772 pid_in
= ltt_event_get_long_unsigned(e
,element
);
773 g_debug("out : %u in : %u", pid_out
, pid_in
);
776 /* Find process pid_out in the list... */
777 process_out
= lttv_state_find_process(tfs
, pid_out
);
778 if(process_out
== NULL
) return 0;
779 g_debug("out : %s",g_quark_to_string(process_out
->state
->s
));
781 birth
= process_out
->creation_time
;
782 const gchar
*name
= g_quark_to_string(process_out
->name
);
783 HashedProcessData
*hashed_process_data_out
= NULL
;
785 if(processlist_get_process_pixels(process_list
,
788 tfc
->t_context
->index
,
791 &hashed_process_data_out
) == 1)
793 /* Process not present */
794 processlist_add(process_list
,
797 tfc
->t_context
->index
,
800 &hashed_process_data_out
);
801 g_assert(processlist_get_process_pixels(process_list
,
804 tfc
->t_context
->index
,
807 &hashed_process_data_out
)==0);
808 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
812 /* Find process pid_in in the list... */
813 process_in
= lttv_state_find_process(tfs
, pid_in
);
814 if(process_in
== NULL
) return 0;
815 g_debug("in : %s",g_quark_to_string(process_in
->state
->s
));
817 birth
= process_in
->creation_time
;
818 name
= g_quark_to_string(process_in
->name
);
819 HashedProcessData
*hashed_process_data_in
= NULL
;
821 if(processlist_get_process_pixels(process_list
,
824 tfc
->t_context
->index
,
827 &hashed_process_data_in
) == 1)
829 /* Process not present */
830 processlist_add(process_list
,
833 tfc
->t_context
->index
,
836 &hashed_process_data_in
);
837 processlist_get_process_pixels(process_list
,
840 tfc
->t_context
->index
,
843 &hashed_process_data_in
);
845 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
850 /* Find pixels corresponding to time of the event. If the time does
851 * not fit in the window, show a warning, not supposed to happend. */
853 guint width
= control_flow_data
->drawing
->width
;
855 LttTime time
= ltt_event_time(e
);
857 LttTime window_end
= time_window
.time_window
.end_time
;
859 convert_time_to_pixels(
864 //assert(x <= width);
866 /* draw what represents the event for outgoing process. */
868 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
869 draw_context_out
->current
->modify_over
->x
= x
;
870 draw_context_out
->current
->modify_under
->x
= x
;
871 draw_context_out
->current
->modify_over
->y
= y_out
;
872 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
873 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
874 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
875 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
876 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
877 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
878 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
879 //draw_context_out->gc = widget->style->black_gc;
881 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
882 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
884 /* Draw the line/background of the out process */
885 if(draw_context_out
->previous
->middle
->x
== -1)
887 draw_context_out
->previous
->over
->x
=
888 control_flow_data
->drawing
->damage_begin
;
889 draw_context_out
->previous
->middle
->x
=
890 control_flow_data
->drawing
->damage_begin
;
891 draw_context_out
->previous
->under
->x
=
892 control_flow_data
->drawing
->damage_begin
;
893 g_debug("out middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
896 draw_context_out
->current
->middle
->x
= x
;
897 draw_context_out
->current
->over
->x
= x
;
898 draw_context_out
->current
->under
->x
= x
;
899 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
900 draw_context_out
->current
->over
->y
= y_out
;
901 draw_context_out
->current
->under
->y
= y_out
+ height
;
902 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
903 draw_context_out
->previous
->over
->y
= y_out
;
904 draw_context_out
->previous
->under
->y
= y_out
+ height
;
906 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
907 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
909 if(process_out
->state
->s
== LTTV_STATE_RUN
)
911 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
912 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
913 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
915 PropertiesBG prop_bg
;
916 prop_bg
.color
= g_new(GdkColor
,1);
918 switch(ltt_tracefile_num(tfc
->tf
)) {
920 prop_bg
.color
->red
= 0x1515;
921 prop_bg
.color
->green
= 0x1515;
922 prop_bg
.color
->blue
= 0x8c8c;
925 prop_bg
.color
->red
= 0x4e4e;
926 prop_bg
.color
->green
= 0xa9a9;
927 prop_bg
.color
->blue
= 0xa4a4;
930 prop_bg
.color
->red
= 0x7a7a;
931 prop_bg
.color
->green
= 0x4a4a;
932 prop_bg
.color
->blue
= 0x8b8b;
935 prop_bg
.color
->red
= 0x8080;
936 prop_bg
.color
->green
= 0x7777;
937 prop_bg
.color
->blue
= 0x4747;
940 prop_bg
.color
->red
= 0xe7e7;
941 prop_bg
.color
->green
= 0xe7e7;
942 prop_bg
.color
->blue
= 0xe7e7;
945 g_debug("calling from draw_event");
946 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
947 g_free(prop_bg
.color
);
948 //gdk_gc_unref(draw_context_out->gc);
951 draw_context_out
->gc
= widget
->style
->black_gc
;
953 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
954 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
955 PropertiesText prop_text_out
;
956 prop_text_out
.foreground
= &colorfg_out
;
957 prop_text_out
.background
= &colorbg_out
;
958 prop_text_out
.size
= 6;
959 prop_text_out
.position
= OVER
;
961 /* color of text : status of the process */
962 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
964 prop_text_out
.foreground
->red
= 0xffff;
965 prop_text_out
.foreground
->green
= 0xffff;
966 prop_text_out
.foreground
->blue
= 0xffff;
968 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
970 prop_text_out
.foreground
->red
= 0x0fff;
971 prop_text_out
.foreground
->green
= 0xffff;
972 prop_text_out
.foreground
->blue
= 0xfff0;
974 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
976 prop_text_out
.foreground
->red
= 0xffff;
977 prop_text_out
.foreground
->green
= 0xffff;
978 prop_text_out
.foreground
->blue
= 0x0000;
980 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
982 prop_text_out
.foreground
->red
= 0xffff;
983 prop_text_out
.foreground
->green
= 0x0000;
984 prop_text_out
.foreground
->blue
= 0xffff;
986 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
988 prop_text_out
.foreground
->red
= 0xffff;
989 prop_text_out
.foreground
->green
= 0x0000;
990 prop_text_out
.foreground
->blue
= 0x0000;
992 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
994 prop_text_out
.foreground
->red
= 0x0000;
995 prop_text_out
.foreground
->green
= 0xffff;
996 prop_text_out
.foreground
->blue
= 0x0000;
1000 prop_text_out
.foreground
->red
= 0xffff;
1001 prop_text_out
.foreground
->green
= 0xffff;
1002 prop_text_out
.foreground
->blue
= 0xffff;
1006 /* Print status of the process : U, WF, WC, E, W, R */
1007 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1008 prop_text_out
.text
= "U->";
1009 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1010 prop_text_out
.text
= "WF->";
1011 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1012 prop_text_out
.text
= "WC->";
1013 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1014 prop_text_out
.text
= "E->";
1015 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1016 prop_text_out
.text
= "W->";
1017 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1018 prop_text_out
.text
= "R->";
1020 prop_text_out
.text
= "U";
1022 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1023 //gdk_gc_unref(draw_context_out->gc);
1025 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1026 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1027 draw_context_out
->gc
= control_flow_data
->drawing
->gc
;
1029 PropertiesLine prop_line_out
;
1030 prop_line_out
.color
= g_new(GdkColor
,1);
1031 prop_line_out
.line_width
= 2;
1032 prop_line_out
.style
= GDK_LINE_SOLID
;
1033 prop_line_out
.position
= MIDDLE
;
1035 g_debug("out state : %s", g_quark_to_string(process_out
->state
->s
));
1037 /* color of line : status of the process */
1038 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1040 prop_line_out
.color
->red
= 0xffff;
1041 prop_line_out
.color
->green
= 0xffff;
1042 prop_line_out
.color
->blue
= 0xffff;
1044 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1046 prop_line_out
.color
->red
= 0x0fff;
1047 prop_line_out
.color
->green
= 0xffff;
1048 prop_line_out
.color
->blue
= 0xfff0;
1050 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1052 prop_line_out
.color
->red
= 0xffff;
1053 prop_line_out
.color
->green
= 0xffff;
1054 prop_line_out
.color
->blue
= 0x0000;
1056 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1058 prop_line_out
.color
->red
= 0xffff;
1059 prop_line_out
.color
->green
= 0x0000;
1060 prop_line_out
.color
->blue
= 0xffff;
1062 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1064 prop_line_out
.color
->red
= 0xffff;
1065 prop_line_out
.color
->green
= 0x0000;
1066 prop_line_out
.color
->blue
= 0x0000;
1068 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1070 prop_line_out
.color
->red
= 0x0000;
1071 prop_line_out
.color
->green
= 0xffff;
1072 prop_line_out
.color
->blue
= 0x0000;
1076 prop_line_out
.color
->red
= 0xffff;
1077 prop_line_out
.color
->green
= 0xffff;
1078 prop_line_out
.color
->blue
= 0xffff;
1081 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
1082 g_free(prop_line_out
.color
);
1083 //gdk_gc_unref(draw_context_out->gc);
1084 /* Note : finishing line will have to be added when trace read over. */
1086 /* Finally, update the drawing context of the pid_in. */
1088 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1089 draw_context_in
->current
->modify_over
->x
= x
;
1090 draw_context_in
->current
->modify_under
->x
= x
;
1091 draw_context_in
->current
->modify_over
->y
= y_in
;
1092 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1093 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1094 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1095 widget
= control_flow_data
->drawing
->drawing_area
;
1096 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1097 //draw_context_in->gc = widget->style->black_gc;
1098 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1099 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1101 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1102 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1104 /* Draw the line/bg of the in process */
1105 if(draw_context_in
->previous
->middle
->x
== -1)
1107 draw_context_in
->previous
->over
->x
=
1108 control_flow_data
->drawing
->damage_begin
;
1109 draw_context_in
->previous
->middle
->x
=
1110 control_flow_data
->drawing
->damage_begin
;
1111 draw_context_in
->previous
->under
->x
=
1112 control_flow_data
->drawing
->damage_begin
;
1114 g_debug("in middle x_beg : %u",control_flow_data
->drawing
->damage_begin
);
1118 draw_context_in
->current
->middle
->x
= x
;
1119 draw_context_in
->current
->over
->x
= x
;
1120 draw_context_in
->current
->under
->x
= x
;
1121 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
1122 draw_context_in
->current
->over
->y
= y_in
;
1123 draw_context_in
->current
->under
->y
= y_in
+ height
;
1124 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
1125 draw_context_in
->previous
->over
->y
= y_in
;
1126 draw_context_in
->previous
->under
->y
= y_in
+ height
;
1128 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1129 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1132 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1134 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1135 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1136 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1138 PropertiesBG prop_bg
;
1139 prop_bg
.color
= g_new(GdkColor
,1);
1141 switcht(ltt_tracefile_num(tfc
->tf
)) {
1143 prop_bg
.color
->red
= 0x1515;
1144 prop_bg
.color
->green
= 0x1515;
1145 prop_bg
.color
->blue
= 0x8c8c;
1148 prop_bg
.color
->red
= 0x4e4e;
1149 prop_bg
.color
->green
= 0xa9a9;
1150 prop_bg
.color
->blue
= 0xa4a4;
1153 prop_bg
.color
->red
= 0x7a7a;
1154 prop_bg
.color
->green
= 0x4a4a;
1155 prop_bg
.color
->blue
= 0x8b8b;
1158 prop_bg
.color
->red
= 0x8080;
1159 prop_bg
.color
->green
= 0x7777;
1160 prop_bg
.color
->blue
= 0x4747;
1163 prop_bg
.color
->red
= 0xe7e7;
1164 prop_bg
.color
->green
= 0xe7e7;
1165 prop_bg
.color
->blue
= 0xe7e7;
1169 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
1170 g_free(prop_bg
.color
);
1171 //gdk_gc_unref(draw_context_in->gc);
1174 draw_context_in
->gc
= widget
->style
->black_gc
;
1176 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1177 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1178 PropertiesText prop_text_in
;
1179 prop_text_in
.foreground
= &colorfg_in
;
1180 prop_text_in
.background
= &colorbg_in
;
1181 prop_text_in
.size
= 6;
1182 prop_text_in
.position
= OVER
;
1184 g_debug("in state : %s", g_quark_to_string(process_in
->state
->s
));
1185 /* foreground of text : status of the process */
1186 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1188 prop_text_in
.foreground
->red
= 0xffff;
1189 prop_text_in
.foreground
->green
= 0xffff;
1190 prop_text_in
.foreground
->blue
= 0xffff;
1192 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1194 prop_text_in
.foreground
->red
= 0x0fff;
1195 prop_text_in
.foreground
->green
= 0xffff;
1196 prop_text_in
.foreground
->blue
= 0xfff0;
1198 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1200 prop_text_in
.foreground
->red
= 0xffff;
1201 prop_text_in
.foreground
->green
= 0xffff;
1202 prop_text_in
.foreground
->blue
= 0x0000;
1204 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1206 prop_text_in
.foreground
->red
= 0xffff;
1207 prop_text_in
.foreground
->green
= 0x0000;
1208 prop_text_in
.foreground
->blue
= 0xffff;
1210 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1212 prop_text_in
.foreground
->red
= 0xffff;
1213 prop_text_in
.foreground
->green
= 0x0000;
1214 prop_text_in
.foreground
->blue
= 0x0000;
1216 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1218 prop_text_in
.foreground
->red
= 0x0000;
1219 prop_text_in
.foreground
->green
= 0xffff;
1220 prop_text_in
.foreground
->blue
= 0x0000;
1224 prop_text_in
.foreground
->red
= 0xffff;
1225 prop_text_in
.foreground
->green
= 0xffff;
1226 prop_text_in
.foreground
->blue
= 0xffff;
1231 /* Print status of the process : U, WF, WC, E, W, R */
1232 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1233 prop_text_in
.text
= "U->";
1234 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1235 prop_text_in
.text
= "WF->";
1236 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1237 prop_text_in
.text
= "WC->";
1238 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1239 prop_text_in
.text
= "E->";
1240 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1241 prop_text_in
.text
= "W->";
1242 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1243 prop_text_in
.text
= "R->";
1245 prop_text_in
.text
= "U";
1247 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1248 //gdk_gc_unref(draw_context_in->gc);
1250 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1251 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1252 draw_context_in
->gc
= control_flow_data
->drawing
->gc
;
1254 PropertiesLine prop_line_in
;
1255 prop_line_in
.color
= g_new(GdkColor
,1);
1256 prop_line_in
.line_width
= 2;
1257 prop_line_in
.style
= GDK_LINE_SOLID
;
1258 prop_line_in
.position
= MIDDLE
;
1260 /* color of line : status of the process */
1261 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1263 prop_line_in
.color
->red
= 0xffff;
1264 prop_line_in
.color
->green
= 0xffff;
1265 prop_line_in
.color
->blue
= 0xffff;
1267 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1269 prop_line_in
.color
->red
= 0x0fff;
1270 prop_line_in
.color
->green
= 0xffff;
1271 prop_line_in
.color
->blue
= 0xfff0;
1273 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1275 prop_line_in
.color
->red
= 0xffff;
1276 prop_line_in
.color
->green
= 0xffff;
1277 prop_line_in
.color
->blue
= 0x0000;
1279 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1281 prop_line_in
.color
->red
= 0xffff;
1282 prop_line_in
.color
->green
= 0x0000;
1283 prop_line_in
.color
->blue
= 0xffff;
1285 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1287 prop_line_in
.color
->red
= 0xffff;
1288 prop_line_in
.color
->green
= 0x0000;
1289 prop_line_in
.color
->blue
= 0x0000;
1291 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1293 prop_line_in
.color
->red
= 0x0000;
1294 prop_line_in
.color
->green
= 0xffff;
1295 prop_line_in
.color
->blue
= 0x0000;
1299 prop_line_in
.color
->red
= 0xffff;
1300 prop_line_in
.color
->green
= 0xffff;
1301 prop_line_in
.color
->blue
= 0xffff;
1304 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
1305 g_free(prop_line_in
.color
);
1306 //gdk_gc_unref(draw_context_in->gc);
1316 GString
*string
= g_string_new("");;
1317 gboolean field_names
= TRUE
, state
= TRUE
;
1319 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
1320 g_string_append_printf(string
,"\n");
1323 g_string_append_printf(string
, " %s",
1324 g_quark_to_string(tfs
->process
->state
->s
));
1327 g_info("%s",string
->str
);
1329 g_string_free(string
, TRUE
);
1331 /* End of text dump */
1336 /* after_schedchange_hook
1338 * The draw after hook is called by the reading API to have a
1339 * particular event drawn on the screen.
1340 * @param hook_data ControlFlowData structure of the viewer.
1341 * @param call_data Event context.
1343 * This function adds items to be drawn in a queue for each process.
1346 int after_schedchange_hook(void *hook_data
, void *call_data
)
1348 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1349 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1350 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1352 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1354 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1356 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1359 e
= ltt_tracefile_get_event(tfc
->tf
);
1361 LttTime evtime
= ltt_event_time(e
);
1363 /* Add process to process list (if not present) */
1364 LttvProcessState
*process_in
;
1366 guint pl_height
= 0;
1367 HashedProcessData
*hashed_process_data_in
= NULL
;
1369 ProcessList
*process_list
= control_flow_data
->process_list
;
1374 pid_out
= ltt_event_get_long_unsigned(e
, thf
->f1
);
1375 pid_in
= ltt_event_get_long_unsigned(e
, thf
->f2
);
1379 /* Find process pid_in in the list... */
1380 //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
1381 //process_in = tfs->process;
1382 guint cpu
= ltt_tracefile_num(tfc
->tf
);
1383 process_in
= ts
->running_process
[cpu
];
1384 /* It should exist, because we are after the state update. */
1386 g_assert(process_in
!= NULL
);
1387 #endif //EXTRA_CHECK
1388 birth
= process_in
->creation_time
;
1390 hashed_process_data_in
= processlist_get_process_data(process_list
,
1394 tfc
->t_context
->index
);
1395 if(hashed_process_data_in
== NULL
)
1397 g_assert(pid_in
== 0 || pid_in
!= process_in
->ppid
);
1398 const gchar
*name
= g_quark_to_string(process_in
->name
);
1399 ProcessInfo
*process_info
;
1400 Drawing_t
*drawing
= control_flow_data
->drawing
;
1401 /* Process not present */
1402 processlist_add(process_list
,
1408 tfc
->t_context
->index
,
1412 &hashed_process_data_in
);
1413 gtk_widget_set_size_request(drawing
->drawing_area
,
1416 gtk_widget_queue_draw(drawing
->drawing_area
);
1418 /* Set the current process */
1419 process_list
->current_hash_data
[process_in
->cpu
] =
1420 hashed_process_data_in
;
1422 if(ltt_time_compare(hashed_process_data_in
->next_good_time
,
1425 TimeWindow time_window
=
1426 lttvwindow_get_time_window(control_flow_data
->tab
);
1429 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1430 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1432 #endif //EXTRA_CHECK
1433 Drawing_t
*drawing
= control_flow_data
->drawing
;
1434 guint width
= drawing
->width
;
1437 convert_time_to_pixels(
1443 if(hashed_process_data_in
->x
.middle
!= new_x
) {
1444 hashed_process_data_in
->x
.middle
= new_x
;
1445 hashed_process_data_in
->x
.middle_used
= FALSE
;
1446 hashed_process_data_in
->x
.middle_marked
= FALSE
;
1456 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
1457 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1459 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1461 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1462 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
1468 LttTime evtime
= ltt_event_time(e
);
1469 TimeWindow time_window
=
1470 lttvwindow_get_time_window(control_flow_data
->tab
);
1472 LttTime time_window
.end_time
= time_window
.time_window
.end_time
;
1474 //if(time < time_beg || time > time_end) return;
1475 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
1476 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
1480 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
1482 g_debug("schedchange!");
1484 /* Add process to process list (if not present) and get drawing "y" from
1485 * process position */
1486 guint pid_out
, pid_in
;
1487 LttvProcessState
*process_out
, *process_in
;
1489 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
1491 ProcessList
*process_list
= control_flow_data
->process_list
;
1494 LttField
*f
= ltt_event_field(e
);
1496 element
= ltt_field_member(f
,0);
1497 pid_out
= ltt_event_get_long_unsigned(e
,element
);
1498 element
= ltt_field_member(f
,1);
1499 pid_in
= ltt_event_get_long_unsigned(e
,element
);
1500 //g_debug("out : %u in : %u", pid_out, pid_in);
1503 /* Find process pid_out in the list... */
1504 process_out
= lttv_state_find_process(tfs
, pid_out
);
1505 if(process_out
== NULL
) return 0;
1506 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1508 birth
= process_out
->creation_time
;
1509 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
1510 HashedProcessData
*hashed_process_data_out
= NULL
;
1512 if(processlist_get_process_pixels(process_list
,
1515 tfc
->t_context
->index
,
1518 &hashed_process_data_out
) == 1)
1520 /* Process not present */
1521 processlist_add(process_list
,
1524 tfc
->t_context
->index
,
1527 &hashed_process_data_out
);
1528 processlist_get_process_pixels(process_list
,
1531 tfc
->t_context
->index
,
1534 &hashed_process_data_out
);
1535 drawing_insert_square( control_flow_data
->drawing
, y_out
, height
);
1540 /* Find process pid_in in the list... */
1541 process_in
= lttv_state_find_process(tfs
, pid_in
);
1542 if(process_in
== NULL
) return 0;
1543 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1545 birth
= process_in
->creation_time
;
1546 name
= strdup(g_quark_to_string(process_in
->name
));
1547 HashedProcessData
*hashed_process_data_in
= NULL
;
1549 if(processlist_get_process_pixels(process_list
,
1552 tfc
->t_context
->index
,
1555 &hashed_process_data_in
) == 1)
1557 /* Process not present */
1558 processlist_add(process_list
,
1561 tfc
->t_context
->index
,
1564 &hashed_process_data_in
);
1565 processlist_get_process_pixels(process_list
,
1568 tfc
->t_context
->index
,
1571 &hashed_process_data_in
);
1573 drawing_insert_square( control_flow_data
->drawing
, y_in
, height
);
1578 /* Find pixels corresponding to time of the event. If the time does
1579 * not fit in the window, show a warning, not supposed to happend. */
1581 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1583 //LttTime time = ltt_event_time(e);
1585 //LttTime window_end = time_window->time_window.end_time;
1588 //convert_time_to_pixels(
1594 //assert(x <= width);
1596 /* draw what represents the event for outgoing process. */
1598 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
1599 //draw_context_out->current->modify_over->x = x;
1600 draw_context_out
->current
->modify_over
->y
= y_out
;
1601 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
1602 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
1603 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1604 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1605 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1607 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1608 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1610 /*if(process_out->state->s == LTTV_STATE_RUN)
1612 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1613 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1614 PropertiesBG prop_bg;
1615 prop_bg.color = g_new(GdkColor,1);
1617 prop_bg.color->red = 0xffff;
1618 prop_bg.color->green = 0xffff;
1619 prop_bg.color->blue = 0xffff;
1621 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1622 g_free(prop_bg.color);
1623 gdk_gc_unref(draw_context_out->gc);
1626 draw_context_out
->gc
= widget
->style
->black_gc
;
1628 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
1629 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
1630 PropertiesText prop_text_out
;
1631 prop_text_out
.foreground
= &colorfg_out
;
1632 prop_text_out
.background
= &colorbg_out
;
1633 prop_text_out
.size
= 6;
1634 prop_text_out
.position
= OVER
;
1636 /* color of text : status of the process */
1637 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1639 prop_text_out
.foreground
->red
= 0xffff;
1640 prop_text_out
.foreground
->green
= 0xffff;
1641 prop_text_out
.foreground
->blue
= 0xffff;
1643 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1645 prop_text_out
.foreground
->red
= 0x0fff;
1646 prop_text_out
.foreground
->green
= 0xffff;
1647 prop_text_out
.foreground
->blue
= 0xfff0;
1649 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1651 prop_text_out
.foreground
->red
= 0xffff;
1652 prop_text_out
.foreground
->green
= 0xffff;
1653 prop_text_out
.foreground
->blue
= 0x0000;
1655 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1657 prop_text_out
.foreground
->red
= 0xffff;
1658 prop_text_out
.foreground
->green
= 0x0000;
1659 prop_text_out
.foreground
->blue
= 0xffff;
1661 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1663 prop_text_out
.foreground
->red
= 0xffff;
1664 prop_text_out
.foreground
->green
= 0x0000;
1665 prop_text_out
.foreground
->blue
= 0x0000;
1667 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1669 prop_text_out
.foreground
->red
= 0x0000;
1670 prop_text_out
.foreground
->green
= 0xffff;
1671 prop_text_out
.foreground
->blue
= 0x0000;
1675 prop_text_out
.foreground
->red
= 0xffff;
1676 prop_text_out
.foreground
->green
= 0xffff;
1677 prop_text_out
.foreground
->blue
= 0xffff;
1680 /* Print status of the process : U, WF, WC, E, W, R */
1681 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
1682 prop_text_out
.text
= "U";
1683 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
1684 prop_text_out
.text
= "WF";
1685 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
1686 prop_text_out
.text
= "WC";
1687 else if(process_out
->state
->s
== LTTV_STATE_ZOMBIE
)
1688 prop_text_out
.text
= "E";
1689 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
1690 prop_text_out
.text
= "W";
1691 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
1692 prop_text_out
.text
= "R";
1694 prop_text_out
.text
= "U";
1696 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
1698 //gdk_gc_unref(draw_context_out->gc);
1700 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
1701 draw_context_out
->current
->over
->y
= y_out
;
1702 draw_context_out
->current
->under
->y
= y_out
+height
;
1703 draw_context_out
->current
->status
= process_out
->state
->s
;
1705 /* for pid_out : remove previous, Prev = current, new current (default) */
1706 g_free(draw_context_out
->previous
->modify_under
);
1707 g_free(draw_context_out
->previous
->modify_middle
);
1708 g_free(draw_context_out
->previous
->modify_over
);
1709 g_free(draw_context_out
->previous
->under
);
1710 g_free(draw_context_out
->previous
->middle
);
1711 g_free(draw_context_out
->previous
->over
);
1712 g_free(draw_context_out
->previous
);
1714 draw_context_out
->previous
= draw_context_out
->current
;
1716 draw_context_out
->current
= g_new(DrawInfo
,1);
1717 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1718 draw_context_out
->current
->over
->x
= -1;
1719 draw_context_out
->current
->over
->y
= -1;
1720 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1721 draw_context_out
->current
->middle
->x
= -1;
1722 draw_context_out
->current
->middle
->y
= -1;
1723 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1724 draw_context_out
->current
->under
->x
= -1;
1725 draw_context_out
->current
->under
->y
= -1;
1726 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1727 draw_context_out
->current
->modify_over
->x
= -1;
1728 draw_context_out
->current
->modify_over
->y
= -1;
1729 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1730 draw_context_out
->current
->modify_middle
->x
= -1;
1731 draw_context_out
->current
->modify_middle
->y
= -1;
1732 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1733 draw_context_out
->current
->modify_under
->x
= -1;
1734 draw_context_out
->current
->modify_under
->y
= -1;
1735 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1737 /* Finally, update the drawing context of the pid_in. */
1739 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1740 //draw_context_in->current->modify_over->x = x;
1741 draw_context_in
->current
->modify_over
->y
= y_in
;
1742 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1743 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1744 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1745 widget
= control_flow_data
->drawing
->drawing_area
;
1746 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1748 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1749 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1751 /*if(process_in->state->s == LTTV_STATE_RUN)
1753 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1754 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1755 PropertiesBG prop_bg;
1756 prop_bg.color = g_new(GdkColor,1);
1758 prop_bg.color->red = 0xffff;
1759 prop_bg.color->green = 0xffff;
1760 prop_bg.color->blue = 0xffff;
1762 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1763 g_free(prop_bg.color);
1764 gdk_gc_unref(draw_context_in->gc);
1767 draw_context_in
->gc
= widget
->style
->black_gc
;
1769 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1770 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1771 PropertiesText prop_text_in
;
1772 prop_text_in
.foreground
= &colorfg_in
;
1773 prop_text_in
.background
= &colorbg_in
;
1774 prop_text_in
.size
= 6;
1775 prop_text_in
.position
= OVER
;
1777 /* foreground of text : status of the process */
1778 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1780 prop_text_in
.foreground
->red
= 0xffff;
1781 prop_text_in
.foreground
->green
= 0xffff;
1782 prop_text_in
.foreground
->blue
= 0xffff;
1784 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1786 prop_text_in
.foreground
->red
= 0x0fff;
1787 prop_text_in
.foreground
->green
= 0xffff;
1788 prop_text_in
.foreground
->blue
= 0xfff0;
1790 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1792 prop_text_in
.foreground
->red
= 0xffff;
1793 prop_text_in
.foreground
->green
= 0xffff;
1794 prop_text_in
.foreground
->blue
= 0x0000;
1796 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1798 prop_text_in
.foreground
->red
= 0xffff;
1799 prop_text_in
.foreground
->green
= 0x0000;
1800 prop_text_in
.foreground
->blue
= 0xffff;
1802 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1804 prop_text_in
.foreground
->red
= 0xffff;
1805 prop_text_in
.foreground
->green
= 0x0000;
1806 prop_text_in
.foreground
->blue
= 0x0000;
1808 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1810 prop_text_in
.foreground
->red
= 0x0000;
1811 prop_text_in
.foreground
->green
= 0xffff;
1812 prop_text_in
.foreground
->blue
= 0x0000;
1816 prop_text_in
.foreground
->red
= 0xffff;
1817 prop_text_in
.foreground
->green
= 0xffff;
1818 prop_text_in
.foreground
->blue
= 0xffff;
1822 /* Print status of the process : U, WF, WC, E, W, R */
1823 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1824 prop_text_in
.text
= "U";
1825 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1826 prop_text_in
.text
= "WF";
1827 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1828 prop_text_in
.text
= "WC";
1829 else if(process_in
->state
->s
== LTTV_STATE_ZOMBIE
)
1830 prop_text_in
.text
= "E";
1831 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1832 prop_text_in
.text
= "W";
1833 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1834 prop_text_in
.text
= "R";
1836 prop_text_in
.text
= "U";
1838 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1841 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1844 prop_text_in
.foreground
= &colorfg_in
;
1845 prop_text_in
.background
= &colorbg_in
;
1846 prop_text_in
.foreground
->red
= 0xffff;
1847 prop_text_in
.foreground
->green
= 0xffff;
1848 prop_text_in
.foreground
->blue
= 0xffff;
1849 prop_text_in
.size
= 6;
1850 prop_text_in
.position
= UNDER
;
1852 prop_text_in
.text
= g_new(gchar
, 260);
1853 strcpy(prop_text_in
.text
, "CPU ");
1854 snprintf(tmp
, 255, "%u", ltt_tracefile_num(tfc
->tf
));
1855 strcat(prop_text_in
.text
, tmp
);
1857 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1858 g_free(prop_text_in
.text
);
1862 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1863 draw_context_in
->current
->over
->y
= y_in
;
1864 draw_context_in
->current
->under
->y
= y_in
+height
;
1865 draw_context_in
->current
->status
= process_in
->state
->s
;
1867 /* for pid_in : remove previous, Prev = current, new current (default) */
1868 g_free(draw_context_in
->previous
->modify_under
);
1869 g_free(draw_context_in
->previous
->modify_middle
);
1870 g_free(draw_context_in
->previous
->modify_over
);
1871 g_free(draw_context_in
->previous
->under
);
1872 g_free(draw_context_in
->previous
->middle
);
1873 g_free(draw_context_in
->previous
->over
);
1874 g_free(draw_context_in
->previous
);
1876 draw_context_in
->previous
= draw_context_in
->current
;
1878 draw_context_in
->current
= g_new(DrawInfo
,1);
1879 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1880 draw_context_in
->current
->over
->x
= -1;
1881 draw_context_in
->current
->over
->y
= -1;
1882 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1883 draw_context_in
->current
->middle
->x
= -1;
1884 draw_context_in
->current
->middle
->y
= -1;
1885 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1886 draw_context_in
->current
->under
->x
= -1;
1887 draw_context_in
->current
->under
->y
= -1;
1888 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1889 draw_context_in
->current
->modify_over
->x
= -1;
1890 draw_context_in
->current
->modify_over
->y
= -1;
1891 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1892 draw_context_in
->current
->modify_middle
->x
= -1;
1893 draw_context_in
->current
->modify_middle
->y
= -1;
1894 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1895 draw_context_in
->current
->modify_under
->x
= -1;
1896 draw_context_in
->current
->modify_under
->y
= -1;
1897 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1906 static inline PropertiesLine
prepare_execmode_line(LttvProcessState
*process
)
1908 PropertiesLine prop_line
;
1909 prop_line
.line_width
= 1;
1910 prop_line
.style
= GDK_LINE_SOLID
;
1912 //GdkColormap *colormap = gdk_colormap_get_system();
1914 /* color of line : execution mode of the process */
1915 if(process
->state
->t
== LTTV_STATE_USER_MODE
)
1916 prop_line
.color
= drawing_colors
[COL_USER_MODE
];
1917 else if(process
->state
->t
== LTTV_STATE_SYSCALL
)
1918 prop_line
.color
= drawing_colors
[COL_SYSCALL
];
1919 else if(process
->state
->t
== LTTV_STATE_TRAP
)
1920 prop_line
.color
= drawing_colors
[COL_TRAP
];
1921 else if(process
->state
->t
== LTTV_STATE_IRQ
)
1922 prop_line
.color
= drawing_colors
[COL_IRQ
];
1923 else if(process
->state
->t
== LTTV_STATE_MODE_UNKNOWN
)
1924 prop_line
.color
= drawing_colors
[COL_MODE_UNKNOWN
];
1926 prop_line
.color
= drawing_colors
[COL_WHITE
];
1928 //gdk_colormap_alloc_color(colormap,
1939 /* before_execmode_hook
1941 * This function basically draw lines and icons. Two types of lines are drawn :
1942 * one small (3 pixels?) representing the state of the process and the second
1943 * type is thicker (10 pixels?) representing on which CPU a process is running
1944 * (and this only in running state).
1946 * Extremums of the lines :
1947 * x_min : time of the last event context for this process kept in memory.
1948 * x_max : time of the current event.
1949 * y : middle of the process in the process list. The process is found in the
1950 * list, therefore is it's position in pixels.
1952 * The choice of lines'color is defined by the context of the last event for this
1957 int before_execmode_hook(void *hook_data
, void *call_data
)
1959 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
1960 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
1961 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
1963 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
1965 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
1967 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
1970 e
= ltt_tracefile_get_event(tfc
->tf
);
1972 LttTime evtime
= ltt_event_time(e
);
1974 /* we are in a execmode, before the state update. We must draw the
1975 * items corresponding to the state before it changes : now is the right
1979 //LttvProcessState *process = tfs->process;
1980 guint cpu
= ltt_tracefile_num(tfc
->tf
);
1981 LttvProcessState
*process
= ts
->running_process
[cpu
];
1982 g_assert(process
!= NULL
);
1984 guint pid
= process
->pid
;
1986 /* Well, the process_out existed : we must get it in the process hash
1987 * or add it, and draw its items.
1989 /* Add process to process list (if not present) */
1990 guint pl_height
= 0;
1991 HashedProcessData
*hashed_process_data
= NULL
;
1992 ProcessList
*process_list
= control_flow_data
->process_list
;
1993 LttTime birth
= process
->creation_time
;
1995 if(likely(process_list
->current_hash_data
[cpu
] != NULL
)) {
1996 hashed_process_data
= process_list
->current_hash_data
[cpu
];
1998 hashed_process_data
= processlist_get_process_data(process_list
,
2002 tfc
->t_context
->index
);
2003 if(unlikely(hashed_process_data
== NULL
))
2005 g_assert(pid
== 0 || pid
!= process
->ppid
);
2006 ProcessInfo
*process_info
;
2007 /* Process not present */
2008 Drawing_t
*drawing
= control_flow_data
->drawing
;
2009 const gchar
*name
= g_quark_to_string(process
->name
);
2010 processlist_add(process_list
,
2016 tfc
->t_context
->index
,
2020 &hashed_process_data
);
2021 gtk_widget_set_size_request(drawing
->drawing_area
,
2024 gtk_widget_queue_draw(drawing
->drawing_area
);
2026 /* Set the current process */
2027 process_list
->current_hash_data
[process
->cpu
] =
2028 hashed_process_data
;
2031 /* Now, the process is in the state hash and our own process hash.
2032 * We definitely can draw the items related to the ending state.
2035 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2038 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2039 TimeWindow time_window
=
2040 lttvwindow_get_time_window(control_flow_data
->tab
);
2043 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2044 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2046 #endif //EXTRA_CHECK
2047 Drawing_t
*drawing
= control_flow_data
->drawing
;
2048 guint width
= drawing
->width
;
2050 convert_time_to_pixels(
2056 /* Draw collision indicator */
2057 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2058 gdk_draw_point(hashed_process_data
->pixmap
,
2061 (hashed_process_data
->height
/2)-3);
2062 hashed_process_data
->x
.middle_marked
= TRUE
;
2065 TimeWindow time_window
=
2066 lttvwindow_get_time_window(control_flow_data
->tab
);
2069 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2070 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2072 #endif //EXTRA_CHECK
2073 Drawing_t
*drawing
= control_flow_data
->drawing
;
2074 guint width
= drawing
->width
;
2077 convert_time_to_pixels(
2084 /* Jump over draw if we are at the same x position */
2085 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2086 hashed_process_data
->x
.middle_used
))
2088 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2089 /* Draw collision indicator */
2090 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2091 gdk_draw_point(hashed_process_data
->pixmap
,
2094 (hashed_process_data
->height
/2)-3);
2095 hashed_process_data
->x
.middle_marked
= TRUE
;
2100 DrawContext draw_context
;
2101 /* Now create the drawing context that will be used to draw
2102 * items related to the last state. */
2103 draw_context
.drawable
= hashed_process_data
->pixmap
;
2104 draw_context
.gc
= drawing
->gc
;
2105 draw_context
.pango_layout
= drawing
->pango_layout
;
2106 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2107 draw_context
.drawinfo
.end
.x
= x
;
2109 draw_context
.drawinfo
.y
.over
= 1;
2110 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2111 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2113 draw_context
.drawinfo
.start
.offset
.over
= 0;
2114 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2115 draw_context
.drawinfo
.start
.offset
.under
= 0;
2116 draw_context
.drawinfo
.end
.offset
.over
= 0;
2117 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2118 draw_context
.drawinfo
.end
.offset
.under
= 0;
2122 PropertiesLine prop_line
= prepare_s_e_line(process
);
2123 draw_line((void*)&prop_line
, (void*)&draw_context
);
2126 /* become the last x position */
2127 hashed_process_data
->x
.middle
= x
;
2128 hashed_process_data
->x
.middle_used
= TRUE
;
2129 hashed_process_data
->x
.middle_marked
= FALSE
;
2131 /* Calculate the next good time */
2132 convert_pixels_to_time(width
, x
+1, time_window
,
2133 &hashed_process_data
->next_good_time
);
2140 /* after_execmode_hook
2142 * The draw after hook is called by the reading API to have a
2143 * particular event drawn on the screen.
2144 * @param hook_data ControlFlowData structure of the viewer.
2145 * @param call_data Event context.
2147 * This function adds items to be drawn in a queue for each process.
2151 int after_execmode_hook(void *hook_data
, void *call_data
)
2153 /**************** DOES NOTHING!! *************/
2154 /* hook desactivated in drawing.c */
2158 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
2159 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
2160 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2162 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2164 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2167 e
= ltt_tracefile_get_event(tfc
->tf
);
2169 LttTime evtime
= ltt_event_time(e
);
2171 /* Add process to process list (if not present) */
2172 LttvProcessState
*process
;
2174 guint pl_height
= 0;
2175 HashedProcessData
*hashed_process_data
= NULL
;
2177 ProcessList
*process_list
= control_flow_data
->process_list
;
2179 /* Find process pid_in in the list... */
2180 process
= tfs
->process
;
2181 /* It should exist, because we are after the state update. */
2182 g_assert(process
!= NULL
);
2184 guint pid
= process
->pid
;
2186 birth
= process
->creation_time
;
2188 if(likely(process_list
->current_hash_data
[ltt_tracefile_num(tfc
->tf
)] != NULL
)) {
2189 hashed_process_data
= process_list
->current_hash_data
[ltt_tracefile_num(tfc
->tf
)];
2191 hashed_process_data
= processlist_get_process_data(process_list
,
2193 process
->last_cpu_index
,
2195 tfc
->t_context
->index
);
2196 if(unlikely(hashed_process_data
== NULL
))
2198 g_assert(pid
== 0 || pid
!= process
->ppid
);
2199 /* Process not present */
2200 Drawing_t
*drawing
= control_flow_data
->drawing
;
2201 const gchar
*name
= g_quark_to_string(process
->name
);
2202 ProcessInfo
*process_info
;
2203 processlist_add(process_list
,
2206 process
->last_cpu_index
,
2209 tfc
->t_context
->index
,
2213 &hashed_process_data
);
2214 gtk_widget_set_size_request(drawing
->drawing_area
,
2217 gtk_widget_queue_draw(drawing
->drawing_area
);
2219 /* Set the current process */
2220 process_list
->current_hash_data
[process
->last_cpu_index
] =
2221 hashed_process_data
;
2224 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
2227 TimeWindow time_window
=
2228 lttvwindow_get_time_window(control_flow_data
->tab
);
2231 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2232 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2234 #endif //EXTRA_CHECK
2235 Drawing_t
*drawing
= control_flow_data
->drawing
;
2236 guint width
= drawing
->width
;
2239 convert_time_to_pixels(
2245 if(hashed_process_data
->x
.middle
!= new_x
) {
2246 hashed_process_data
->x
.middle
= new_x
;
2247 hashed_process_data
->x
.middle_used
= FALSE
;
2248 hashed_process_data
->x
.middle_marked
= FALSE
;
2257 /* before_process_exit_hook
2259 * Draw lines for process event.
2261 * @param hook_data ControlFlowData structure of the viewer.
2262 * @param call_data Event context.
2264 * This function adds items to be drawn in a queue for each process.
2269 int before_process_exit_hook(void *hook_data
, void *call_data
)
2271 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
2272 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
2274 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2276 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2278 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2280 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
2283 e
= ltt_tracefile_get_event(tfc
->tf
);
2285 LttTime evtime
= ltt_event_time(e
);
2287 /* Add process to process list (if not present) */
2288 //LttvProcessState *process = tfs->process;
2289 guint cpu
= ltt_tracefile_num(tfc
->tf
);
2290 LttvProcessState
*process
= ts
->running_process
[cpu
];
2291 guint pid
= process
->pid
;
2293 guint pl_height
= 0;
2294 HashedProcessData
*hashed_process_data
= NULL
;
2296 ProcessList
*process_list
= control_flow_data
->process_list
;
2298 g_assert(process
!= NULL
);
2300 birth
= process
->creation_time
;
2302 if(likely(process_list
->current_hash_data
[cpu
] != NULL
)) {
2303 hashed_process_data
= process_list
->current_hash_data
[cpu
];
2305 hashed_process_data
= processlist_get_process_data(process_list
,
2309 tfc
->t_context
->index
);
2310 if(unlikely(hashed_process_data
== NULL
))
2312 g_assert(pid
== 0 || pid
!= process
->ppid
);
2313 /* Process not present */
2314 Drawing_t
*drawing
= control_flow_data
->drawing
;
2315 const gchar
*name
= g_quark_to_string(process
->name
);
2316 ProcessInfo
*process_info
;
2317 processlist_add(process_list
,
2323 tfc
->t_context
->index
,
2327 &hashed_process_data
);
2328 gtk_widget_set_size_request(drawing
->drawing_area
,
2331 gtk_widget_queue_draw(drawing
->drawing_area
);
2335 /* Now, the process is in the state hash and our own process hash.
2336 * We definitely can draw the items related to the ending state.
2339 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2342 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2343 TimeWindow time_window
=
2344 lttvwindow_get_time_window(control_flow_data
->tab
);
2347 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2348 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2350 #endif //EXTRA_CHECK
2351 Drawing_t
*drawing
= control_flow_data
->drawing
;
2352 guint width
= drawing
->width
;
2354 convert_time_to_pixels(
2360 /* Draw collision indicator */
2361 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2362 gdk_draw_point(hashed_process_data
->pixmap
,
2365 (hashed_process_data
->height
/2)-3);
2366 hashed_process_data
->x
.middle_marked
= TRUE
;
2369 TimeWindow time_window
=
2370 lttvwindow_get_time_window(control_flow_data
->tab
);
2373 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2374 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2376 #endif //EXTRA_CHECK
2377 Drawing_t
*drawing
= control_flow_data
->drawing
;
2378 guint width
= drawing
->width
;
2381 convert_time_to_pixels(
2388 /* Jump over draw if we are at the same x position */
2389 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2390 hashed_process_data
->x
.middle_used
))
2392 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2393 /* Draw collision indicator */
2394 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2395 gdk_draw_point(hashed_process_data
->pixmap
,
2398 (hashed_process_data
->height
/2)-3);
2399 hashed_process_data
->x
.middle_marked
= TRUE
;
2403 DrawContext draw_context
;
2405 /* Now create the drawing context that will be used to draw
2406 * items related to the last state. */
2407 draw_context
.drawable
= hashed_process_data
->pixmap
;
2408 draw_context
.gc
= drawing
->gc
;
2409 draw_context
.pango_layout
= drawing
->pango_layout
;
2410 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2411 draw_context
.drawinfo
.end
.x
= x
;
2413 draw_context
.drawinfo
.y
.over
= 1;
2414 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2415 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2417 draw_context
.drawinfo
.start
.offset
.over
= 0;
2418 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2419 draw_context
.drawinfo
.start
.offset
.under
= 0;
2420 draw_context
.drawinfo
.end
.offset
.over
= 0;
2421 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2422 draw_context
.drawinfo
.end
.offset
.under
= 0;
2426 PropertiesLine prop_line
= prepare_s_e_line(process
);
2427 draw_line((void*)&prop_line
, (void*)&draw_context
);
2430 /* become the last x position */
2431 hashed_process_data
->x
.middle
= x
;
2432 hashed_process_data
->x
.middle_used
= TRUE
;
2433 hashed_process_data
->x
.middle_marked
= FALSE
;
2435 /* Calculate the next good time */
2436 convert_pixels_to_time(width
, x
+1, time_window
,
2437 &hashed_process_data
->next_good_time
);
2447 /* before_process_release_hook
2449 * Draw lines for process event.
2451 * @param hook_data ControlFlowData structure of the viewer.
2452 * @param call_data Event context.
2454 * This function adds items to be drawn in a queue for each process.
2459 int before_process_release_hook(void *hook_data
, void *call_data
)
2461 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
2462 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
2464 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2466 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2468 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2470 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
2473 e
= ltt_tracefile_get_event(tfc
->tf
);
2475 LttTime evtime
= ltt_event_time(e
);
2480 pid
= ltt_event_get_long_unsigned(e
, thf
->f1
);
2483 /* Add process to process list (if not present) */
2484 /* Don't care about the process if it's not in the state hash already :
2485 * that means a process that has never done anything in the trace and
2486 * unknown suddently gets destroyed : no state meaningful to show. */
2487 LttvProcessState
*process
= lttv_state_find_process(ts
, ANY_CPU
, pid
);
2489 if(process
!= NULL
) {
2491 guint pl_height
= 0;
2492 HashedProcessData
*hashed_process_data
= NULL
;
2494 ProcessList
*process_list
= control_flow_data
->process_list
;
2496 birth
= process
->creation_time
;
2498 /* Cannot use current process : this event happens on another process,
2499 * action done by the parent. */
2500 hashed_process_data
= processlist_get_process_data(process_list
,
2504 tfc
->t_context
->index
);
2505 if(unlikely(hashed_process_data
== NULL
))
2507 g_assert(pid
== 0 || pid
!= process
->ppid
);
2508 /* Process not present */
2509 Drawing_t
*drawing
= control_flow_data
->drawing
;
2510 const gchar
*name
= g_quark_to_string(process
->name
);
2511 ProcessInfo
*process_info
;
2512 processlist_add(process_list
,
2518 tfc
->t_context
->index
,
2522 &hashed_process_data
);
2523 gtk_widget_set_size_request(drawing
->drawing_area
,
2526 gtk_widget_queue_draw(drawing
->drawing_area
);
2529 /* Now, the process is in the state hash and our own process hash.
2530 * We definitely can draw the items related to the ending state.
2533 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2536 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2537 TimeWindow time_window
=
2538 lttvwindow_get_time_window(control_flow_data
->tab
);
2541 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2542 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2544 #endif //EXTRA_CHECK
2545 Drawing_t
*drawing
= control_flow_data
->drawing
;
2546 guint width
= drawing
->width
;
2548 convert_time_to_pixels(
2554 /* Draw collision indicator */
2555 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2556 gdk_draw_point(hashed_process_data
->pixmap
,
2559 (hashed_process_data
->height
/2)-3);
2560 hashed_process_data
->x
.middle_marked
= TRUE
;
2563 TimeWindow time_window
=
2564 lttvwindow_get_time_window(control_flow_data
->tab
);
2567 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2568 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2570 #endif //EXTRA_CHECK
2571 Drawing_t
*drawing
= control_flow_data
->drawing
;
2572 guint width
= drawing
->width
;
2575 convert_time_to_pixels(
2582 /* Jump over draw if we are at the same x position */
2583 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2584 hashed_process_data
->x
.middle_used
))
2586 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2587 /* Draw collision indicator */
2588 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2589 gdk_draw_point(hashed_process_data
->pixmap
,
2592 (hashed_process_data
->height
/2)-3);
2593 hashed_process_data
->x
.middle_marked
= TRUE
;
2597 DrawContext draw_context
;
2599 /* Now create the drawing context that will be used to draw
2600 * items related to the last state. */
2601 draw_context
.drawable
= hashed_process_data
->pixmap
;
2602 draw_context
.gc
= drawing
->gc
;
2603 draw_context
.pango_layout
= drawing
->pango_layout
;
2604 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2605 draw_context
.drawinfo
.end
.x
= x
;
2607 draw_context
.drawinfo
.y
.over
= 1;
2608 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2609 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2611 draw_context
.drawinfo
.start
.offset
.over
= 0;
2612 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2613 draw_context
.drawinfo
.start
.offset
.under
= 0;
2614 draw_context
.drawinfo
.end
.offset
.over
= 0;
2615 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2616 draw_context
.drawinfo
.end
.offset
.under
= 0;
2620 PropertiesLine prop_line
= prepare_s_e_line(process
);
2621 draw_line((void*)&prop_line
, (void*)&draw_context
);
2624 /* become the last x position */
2625 hashed_process_data
->x
.middle
= x
;
2626 hashed_process_data
->x
.middle_used
= TRUE
;
2627 hashed_process_data
->x
.middle_marked
= FALSE
;
2629 /* Calculate the next good time */
2630 convert_pixels_to_time(width
, x
+1, time_window
,
2631 &hashed_process_data
->next_good_time
);
2647 /* before_process_hook
2649 * Draw lines for process event.
2651 * @param hook_data ControlFlowData structure of the viewer.
2652 * @param call_data Event context.
2654 * This function adds items to be drawn in a queue for each process.
2657 int before_process_hook(void *hook_data
, void *call_data
)
2659 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
2660 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
2661 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
2663 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
2665 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
2668 e
= ltt_tracefile_get_event(tfc
->tf
);
2670 LttTime evtime
= ltt_event_time(e
);
2674 LttField
*f
= ltt_event_field(e
);
2676 element
= ltt_field_member(f
,0);
2677 sub_id
= ltt_event_get_long_unsigned(e
,element
);
2680 if(sub_id
== 3) { /* exit */
2682 /* Add process to process list (if not present) */
2683 LttvProcessState
*process
= tfs
->process
;
2684 guint pid
= process
->pid
;
2686 guint pl_height
= 0;
2687 HashedProcessData
*hashed_process_data
= NULL
;
2689 ProcessList
*process_list
= control_flow_data
->process_list
;
2691 g_assert(process
!= NULL
);
2693 birth
= process
->creation_time
;
2695 if(likely(process_list
->current_hash_data
[tfc
->index
] != NULL
)) {
2696 hashed_process_data
= process_list
->current_hash_data
[tfc
->index
];
2698 hashed_process_data
= processlist_get_process_data(process_list
,
2700 process
->last_cpu_index
,
2702 tfc
->t_context
->index
);
2703 if(unlikely(hashed_process_data
== NULL
))
2705 g_assert(pid
== 0 || pid
!= process
->ppid
);
2706 /* Process not present */
2707 Drawing_t
*drawing
= control_flow_data
->drawing
;
2708 const gchar
*name
= g_quark_to_string(process
->name
);
2709 ProcessInfo
*process_info
;
2710 processlist_add(process_list
,
2713 process
->last_cpu_index
,
2716 tfc
->t_context
->index
,
2720 &hashed_process_data
);
2721 gtk_widget_set_size_request(drawing
->drawing_area
,
2724 gtk_widget_queue_draw(drawing
->drawing_area
);
2728 /* Now, the process is in the state hash and our own process hash.
2729 * We definitely can draw the items related to the ending state.
2732 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2735 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2736 TimeWindow time_window
=
2737 lttvwindow_get_time_window(control_flow_data
->tab
);
2740 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2741 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2743 #endif //EXTRA_CHECK
2744 Drawing_t
*drawing
= control_flow_data
->drawing
;
2745 guint width
= drawing
->width
;
2747 convert_time_to_pixels(
2753 /* Draw collision indicator */
2754 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2755 gdk_draw_point(hashed_process_data
->pixmap
,
2758 (hashed_process_data
->height
/2)-3);
2759 hashed_process_data
->x
.middle_marked
= TRUE
;
2762 TimeWindow time_window
=
2763 lttvwindow_get_time_window(control_flow_data
->tab
);
2766 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2767 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2769 #endif //EXTRA_CHECK
2770 Drawing_t
*drawing
= control_flow_data
->drawing
;
2771 guint width
= drawing
->width
;
2774 convert_time_to_pixels(
2781 /* Jump over draw if we are at the same x position */
2782 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2783 hashed_process_data
->x
.middle_used
))
2785 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2786 /* Draw collision indicator */
2787 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2788 gdk_draw_point(hashed_process_data
->pixmap
,
2791 (hashed_process_data
->height
/2)-3);
2792 hashed_process_data
->x
.middle_marked
= TRUE
;
2796 DrawContext draw_context
;
2798 /* Now create the drawing context that will be used to draw
2799 * items related to the last state. */
2800 draw_context
.drawable
= hashed_process_data
->pixmap
;
2801 draw_context
.gc
= drawing
->gc
;
2802 draw_context
.pango_layout
= drawing
->pango_layout
;
2803 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2804 draw_context
.drawinfo
.end
.x
= x
;
2806 draw_context
.drawinfo
.y
.over
= 1;
2807 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2808 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2810 draw_context
.drawinfo
.start
.offset
.over
= 0;
2811 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2812 draw_context
.drawinfo
.start
.offset
.under
= 0;
2813 draw_context
.drawinfo
.end
.offset
.over
= 0;
2814 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2815 draw_context
.drawinfo
.end
.offset
.under
= 0;
2819 PropertiesLine prop_line
= prepare_s_e_line(process
);
2820 draw_line((void*)&prop_line
, (void*)&draw_context
);
2823 /* become the last x position */
2824 hashed_process_data
->x
.middle
= x
;
2825 hashed_process_data
->x
.middle_used
= TRUE
;
2826 hashed_process_data
->x
.middle_marked
= FALSE
;
2828 /* Calculate the next good time */
2829 convert_pixels_to_time(width
, x
+1, time_window
,
2830 &hashed_process_data
->next_good_time
);
2834 } else if(sub_id
== 7) /* release */ {
2838 LttField
*f
= ltt_event_field(e
);
2840 element
= ltt_field_member(f
,1);
2841 pid
= ltt_event_get_long_unsigned(e
,element
);
2844 /* Add process to process list (if not present) */
2845 /* Don't care about the process if it's not in the state hash already :
2846 * that means a process that has never done anything in the trace and
2847 * unknown suddently gets destroyed : no state meaningful to show. */
2848 LttvProcessState
*process
= lttv_state_find_process(tfs
, pid
);
2850 if(process
!= NULL
) {
2852 guint pl_height
= 0;
2853 HashedProcessData
*hashed_process_data
= NULL
;
2855 ProcessList
*process_list
= control_flow_data
->process_list
;
2857 birth
= process
->creation_time
;
2859 /* Cannot use current process : this event happens on another process,
2860 * action done by the parent. */
2861 hashed_process_data
= processlist_get_process_data(process_list
,
2863 process
->last_cpu_index
,
2865 tfc
->t_context
->index
);
2866 if(unlikely(hashed_process_data
== NULL
))
2868 g_assert(pid
== 0 || pid
!= process
->ppid
);
2869 /* Process not present */
2870 Drawing_t
*drawing
= control_flow_data
->drawing
;
2871 const gchar
*name
= g_quark_to_string(process
->name
);
2872 ProcessInfo
*process_info
;
2873 processlist_add(process_list
,
2876 process
->last_cpu_index
,
2879 tfc
->t_context
->index
,
2883 &hashed_process_data
);
2884 gtk_widget_set_size_request(drawing
->drawing_area
,
2887 gtk_widget_queue_draw(drawing
->drawing_area
);
2890 /* Now, the process is in the state hash and our own process hash.
2891 * We definitely can draw the items related to the ending state.
2894 if(likely(ltt_time_compare(hashed_process_data
->next_good_time
,
2897 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2898 TimeWindow time_window
=
2899 lttvwindow_get_time_window(control_flow_data
->tab
);
2902 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2903 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2905 #endif //EXTRA_CHECK
2906 Drawing_t
*drawing
= control_flow_data
->drawing
;
2907 guint width
= drawing
->width
;
2909 convert_time_to_pixels(
2915 /* Draw collision indicator */
2916 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2917 gdk_draw_point(hashed_process_data
->pixmap
,
2920 (hashed_process_data
->height
/2)-3);
2921 hashed_process_data
->x
.middle_marked
= TRUE
;
2924 TimeWindow time_window
=
2925 lttvwindow_get_time_window(control_flow_data
->tab
);
2928 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
2929 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
2931 #endif //EXTRA_CHECK
2932 Drawing_t
*drawing
= control_flow_data
->drawing
;
2933 guint width
= drawing
->width
;
2936 convert_time_to_pixels(
2943 /* Jump over draw if we are at the same x position */
2944 if(unlikely(x
== hashed_process_data
->x
.middle
&&
2945 hashed_process_data
->x
.middle_used
))
2947 if(unlikely(hashed_process_data
->x
.middle_marked
== FALSE
)) {
2948 /* Draw collision indicator */
2949 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
2950 gdk_draw_point(hashed_process_data
->pixmap
,
2953 (hashed_process_data
->height
/2)-3);
2954 hashed_process_data
->x
.middle_marked
= TRUE
;
2958 DrawContext draw_context
;
2960 /* Now create the drawing context that will be used to draw
2961 * items related to the last state. */
2962 draw_context
.drawable
= hashed_process_data
->pixmap
;
2963 draw_context
.gc
= drawing
->gc
;
2964 draw_context
.pango_layout
= drawing
->pango_layout
;
2965 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
2966 draw_context
.drawinfo
.end
.x
= x
;
2968 draw_context
.drawinfo
.y
.over
= 1;
2969 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
2970 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
2972 draw_context
.drawinfo
.start
.offset
.over
= 0;
2973 draw_context
.drawinfo
.start
.offset
.middle
= 0;
2974 draw_context
.drawinfo
.start
.offset
.under
= 0;
2975 draw_context
.drawinfo
.end
.offset
.over
= 0;
2976 draw_context
.drawinfo
.end
.offset
.middle
= 0;
2977 draw_context
.drawinfo
.end
.offset
.under
= 0;
2981 PropertiesLine prop_line
= prepare_s_e_line(process
);
2982 draw_line((void*)&prop_line
, (void*)&draw_context
);
2985 /* become the last x position */
2986 hashed_process_data
->x
.middle
= x
;
2987 hashed_process_data
->x
.middle_used
= TRUE
;
2988 hashed_process_data
->x
.middle_marked
= FALSE
;
2990 /* Calculate the next good time */
2991 convert_pixels_to_time(width
, x
+1, time_window
,
2992 &hashed_process_data
->next_good_time
);
3006 /* after_process_fork_hook
3008 * Create the processlist entry for the child process. Put the last
3009 * position in x at the current time value.
3011 * @param hook_data ControlFlowData structure of the viewer.
3012 * @param call_data Event context.
3014 * This function adds items to be drawn in a queue for each process.
3017 int after_process_fork_hook(void *hook_data
, void *call_data
)
3019 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
3020 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
3021 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3023 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
3025 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
3027 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
3030 e
= ltt_tracefile_get_event(tfc
->tf
);
3032 LttTime evtime
= ltt_event_time(e
);
3036 child_pid
= ltt_event_get_long_unsigned(e
, thf
->f2
);
3039 /* Add process to process list (if not present) */
3040 LttvProcessState
*process_child
;
3042 guint pl_height
= 0;
3043 HashedProcessData
*hashed_process_data_child
= NULL
;
3045 ProcessList
*process_list
= control_flow_data
->process_list
;
3047 /* Find child in the list... */
3048 process_child
= lttv_state_find_process(ts
, ANY_CPU
, child_pid
);
3049 /* It should exist, because we are after the state update. */
3050 g_assert(process_child
!= NULL
);
3052 birth
= process_child
->creation_time
;
3054 /* Cannot use current process, because this action is done by the parent
3056 hashed_process_data_child
= processlist_get_process_data(process_list
,
3060 tfc
->t_context
->index
);
3061 if(likely(hashed_process_data_child
== NULL
))
3063 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
3064 /* Process not present */
3065 Drawing_t
*drawing
= control_flow_data
->drawing
;
3066 const gchar
*name
= g_quark_to_string(process_child
->name
);
3067 ProcessInfo
*process_info
;
3068 processlist_add(process_list
,
3072 process_child
->ppid
,
3074 tfc
->t_context
->index
,
3078 &hashed_process_data_child
);
3079 gtk_widget_set_size_request(drawing
->drawing_area
,
3082 gtk_widget_queue_draw(drawing
->drawing_area
);
3086 if(likely(ltt_time_compare(hashed_process_data_child
->next_good_time
,
3089 TimeWindow time_window
=
3090 lttvwindow_get_time_window(control_flow_data
->tab
);
3093 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3094 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3096 #endif //EXTRA_CHECK
3097 Drawing_t
*drawing
= control_flow_data
->drawing
;
3098 guint width
= drawing
->width
;
3100 convert_time_to_pixels(
3106 if(likely(hashed_process_data_child
->x
.over
!= new_x
)) {
3107 hashed_process_data_child
->x
.over
= new_x
;
3108 hashed_process_data_child
->x
.over_used
= FALSE
;
3109 hashed_process_data_child
->x
.over_marked
= FALSE
;
3111 if(likely(hashed_process_data_child
->x
.middle
!= new_x
)) {
3112 hashed_process_data_child
->x
.middle
= new_x
;
3113 hashed_process_data_child
->x
.middle_used
= FALSE
;
3114 hashed_process_data_child
->x
.middle_marked
= FALSE
;
3116 if(likely(hashed_process_data_child
->x
.under
!= new_x
)) {
3117 hashed_process_data_child
->x
.under
= new_x
;
3118 hashed_process_data_child
->x
.under_used
= FALSE
;
3119 hashed_process_data_child
->x
.under_marked
= FALSE
;
3127 /* after_process_exit_hook
3129 * Create the processlist entry for the child process. Put the last
3130 * position in x at the current time value.
3132 * @param hook_data ControlFlowData structure of the viewer.
3133 * @param call_data Event context.
3135 * This function adds items to be drawn in a queue for each process.
3138 int after_process_exit_hook(void *hook_data
, void *call_data
)
3140 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
3141 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
3142 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3144 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
3146 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
3148 LttvTraceState
*ts
= (LttvTraceState
*)tfc
->t_context
;
3151 e
= ltt_tracefile_get_event(tfc
->tf
);
3153 LttTime evtime
= ltt_event_time(e
);
3155 /* Add process to process list (if not present) */
3156 //LttvProcessState *process = tfs->process;
3157 guint cpu
= ltt_tracefile_num(tfc
->tf
);
3158 LttvProcessState
*process
= ts
->running_process
[cpu
];
3160 /* It should exist, because we are after the state update. */
3161 g_assert(process
!= NULL
);
3163 guint pid
= process
->pid
;
3165 guint pl_height
= 0;
3166 HashedProcessData
*hashed_process_data
= NULL
;
3168 ProcessList
*process_list
= control_flow_data
->process_list
;
3170 birth
= process
->creation_time
;
3172 if(likely(process_list
->current_hash_data
[cpu
] != NULL
) ){
3173 hashed_process_data
= process_list
->current_hash_data
[cpu
];
3175 hashed_process_data
= processlist_get_process_data(process_list
,
3179 tfc
->t_context
->index
);
3180 if(unlikely(hashed_process_data
== NULL
))
3182 g_assert(pid
== 0 || pid
!= process
->ppid
);
3183 /* Process not present */
3184 Drawing_t
*drawing
= control_flow_data
->drawing
;
3185 const gchar
*name
= g_quark_to_string(process
->name
);
3186 ProcessInfo
*process_info
;
3187 processlist_add(process_list
,
3193 tfc
->t_context
->index
,
3197 &hashed_process_data
);
3198 gtk_widget_set_size_request(drawing
->drawing_area
,
3201 gtk_widget_queue_draw(drawing
->drawing_area
);
3204 /* Set the current process */
3205 process_list
->current_hash_data
[process
->cpu
] =
3206 hashed_process_data
;
3209 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
3212 TimeWindow time_window
=
3213 lttvwindow_get_time_window(control_flow_data
->tab
);
3216 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3217 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3219 #endif //EXTRA_CHECK
3220 Drawing_t
*drawing
= control_flow_data
->drawing
;
3221 guint width
= drawing
->width
;
3223 convert_time_to_pixels(
3228 if(unlikely(hashed_process_data
->x
.middle
!= new_x
)) {
3229 hashed_process_data
->x
.middle
= new_x
;
3230 hashed_process_data
->x
.middle_used
= FALSE
;
3231 hashed_process_data
->x
.middle_marked
= FALSE
;
3241 /* after_process_hook
3243 * Create the processlist entry for the child process. Put the last
3244 * position in x at the current time value.
3246 * @param hook_data ControlFlowData structure of the viewer.
3247 * @param call_data Event context.
3249 * This function adds items to be drawn in a queue for each process.
3252 int after_process_hook(void *hook_data
, void *call_data
)
3254 LttvTraceHookByFacility
*thf
= (LttvTraceHookByFacility
*)hook_data
;
3255 EventsRequest
*events_request
= (EventsRequest
*)thf
->hook_data
;
3256 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3258 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
3260 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
3263 e
= ltt_tracefile_get_event(tfc
->tf
);
3265 LttTime evtime
= ltt_event_time(e
);
3270 LttField
*f
= ltt_event_field(e
);
3272 element
= ltt_field_member(f
,0);
3273 sub_id
= ltt_event_get_long_unsigned(e
,element
);
3274 element
= ltt_field_member(f
,1);
3275 param1
= ltt_event_get_long_unsigned(e
,element
);
3278 if(sub_id
== 2) { /* fork */
3280 guint child_pid
= param1
;
3281 /* Add process to process list (if not present) */
3282 LttvProcessState
*process_child
;
3284 guint pl_height
= 0;
3285 HashedProcessData
*hashed_process_data_child
= NULL
;
3287 ProcessList
*process_list
= control_flow_data
->process_list
;
3289 /* Find child in the list... */
3290 process_child
= lttv_state_find_process(tfs
, child_pid
);
3291 /* It should exist, because we are after the state update. */
3292 g_assert(process_child
!= NULL
);
3294 birth
= process_child
->creation_time
;
3296 /* Cannot use current process, because this action is done by the parent
3298 hashed_process_data_child
= processlist_get_process_data(process_list
,
3300 process_child
->last_cpu_index
,
3302 tfc
->t_context
->index
);
3303 if(likely(hashed_process_data_child
== NULL
))
3305 g_assert(child_pid
== 0 || child_pid
!= process_child
->ppid
);
3306 /* Process not present */
3307 Drawing_t
*drawing
= control_flow_data
->drawing
;
3308 const gchar
*name
= g_quark_to_string(process_child
->name
);
3309 ProcessInfo
*process_info
;
3310 processlist_add(process_list
,
3313 process_child
->last_cpu_index
,
3314 process_child
->ppid
,
3316 tfc
->t_context
->index
,
3320 &hashed_process_data_child
);
3321 gtk_widget_set_size_request(drawing
->drawing_area
,
3324 gtk_widget_queue_draw(drawing
->drawing_area
);
3328 if(likely(ltt_time_compare(hashed_process_data_child
->next_good_time
,
3331 TimeWindow time_window
=
3332 lttvwindow_get_time_window(control_flow_data
->tab
);
3335 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3336 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3338 #endif //EXTRA_CHECK
3339 Drawing_t
*drawing
= control_flow_data
->drawing
;
3340 guint width
= drawing
->width
;
3342 convert_time_to_pixels(
3348 if(likely(hashed_process_data_child
->x
.over
!= new_x
)) {
3349 hashed_process_data_child
->x
.over
= new_x
;
3350 hashed_process_data_child
->x
.over_used
= FALSE
;
3351 hashed_process_data_child
->x
.over_marked
= FALSE
;
3353 if(likely(hashed_process_data_child
->x
.middle
!= new_x
)) {
3354 hashed_process_data_child
->x
.middle
= new_x
;
3355 hashed_process_data_child
->x
.middle_used
= FALSE
;
3356 hashed_process_data_child
->x
.middle_marked
= FALSE
;
3358 if(likely(hashed_process_data_child
->x
.under
!= new_x
)) {
3359 hashed_process_data_child
->x
.under
= new_x
;
3360 hashed_process_data_child
->x
.under_used
= FALSE
;
3361 hashed_process_data_child
->x
.under_marked
= FALSE
;
3365 } else if(sub_id
== 3) { /* exit */
3367 /* Add process to process list (if not present) */
3368 LttvProcessState
*process
= tfs
->process
;
3369 guint pid
= process
->pid
;
3371 guint pl_height
= 0;
3372 HashedProcessData
*hashed_process_data
= NULL
;
3374 ProcessList
*process_list
= control_flow_data
->process_list
;
3376 /* It should exist, because we are after the state update. */
3377 g_assert(process
!= NULL
);
3379 birth
= process
->creation_time
;
3381 if(likely(process_list
->current_hash_data
[ltt_tracefile_num(tfc
->tf
)] != NULL
) ){
3382 hashed_process_data
= process_list
->current_hash_data
[ltt_tracefile_num(tfc
->tf
)];
3384 hashed_process_data
= processlist_get_process_data(process_list
,
3386 process
->last_cpu_index
,
3388 tfc
->t_context
->index
);
3389 if(unlikely(hashed_process_data
== NULL
))
3391 g_assert(pid
== 0 || pid
!= process
->ppid
);
3392 /* Process not present */
3393 Drawing_t
*drawing
= control_flow_data
->drawing
;
3394 const gchar
*name
= g_quark_to_string(process
->name
);
3395 ProcessInfo
*process_info
;
3396 processlist_add(process_list
,
3399 process
->last_cpu_index
,
3402 tfc
->t_context
->index
,
3406 &hashed_process_data
);
3407 gtk_widget_set_size_request(drawing
->drawing_area
,
3410 gtk_widget_queue_draw(drawing
->drawing_area
);
3413 /* Set the current process */
3414 process_list
->current_hash_data
[process
->last_cpu_index
] =
3415 hashed_process_data
;
3418 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
3421 TimeWindow time_window
=
3422 lttvwindow_get_time_window(control_flow_data
->tab
);
3425 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3426 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3428 #endif //EXTRA_CHECK
3429 Drawing_t
*drawing
= control_flow_data
->drawing
;
3430 guint width
= drawing
->width
;
3432 convert_time_to_pixels(
3437 if(unlikely(hashed_process_data
->x
.middle
!= new_x
)) {
3438 hashed_process_data
->x
.middle
= new_x
;
3439 hashed_process_data
->x
.middle_used
= FALSE
;
3440 hashed_process_data
->x
.middle_marked
= FALSE
;
3450 gint
update_time_window_hook(void *hook_data
, void *call_data
)
3452 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3453 Drawing_t
*drawing
= control_flow_data
->drawing
;
3454 ProcessList
*process_list
= control_flow_data
->process_list
;
3456 const TimeWindowNotifyData
*time_window_nofify_data
=
3457 ((const TimeWindowNotifyData
*)call_data
);
3459 TimeWindow
*old_time_window
=
3460 time_window_nofify_data
->old_time_window
;
3461 TimeWindow
*new_time_window
=
3462 time_window_nofify_data
->new_time_window
;
3464 /* Update the ruler */
3465 drawing_update_ruler(control_flow_data
->drawing
,
3469 /* Two cases : zoom in/out or scrolling */
3471 /* In order to make sure we can reuse the old drawing, the scale must
3472 * be the same and the new time interval being partly located in the
3473 * currently shown time interval. (reuse is only for scrolling)
3476 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
3477 old_time_window
->start_time
.tv_sec
,
3478 old_time_window
->start_time
.tv_nsec
,
3479 old_time_window
->time_width
.tv_sec
,
3480 old_time_window
->time_width
.tv_nsec
);
3482 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
3483 new_time_window
->start_time
.tv_sec
,
3484 new_time_window
->start_time
.tv_nsec
,
3485 new_time_window
->time_width
.tv_sec
,
3486 new_time_window
->time_width
.tv_nsec
);
3488 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
3489 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
3491 /* Same scale (scrolling) */
3492 g_info("scrolling");
3493 LttTime
*ns
= &new_time_window
->start_time
;
3494 LttTime
*nw
= &new_time_window
->time_width
;
3495 LttTime
*os
= &old_time_window
->start_time
;
3496 LttTime
*ow
= &old_time_window
->time_width
;
3497 LttTime old_end
= old_time_window
->end_time
;
3498 LttTime new_end
= new_time_window
->end_time
;
3500 //if(ns<os+w && os+w<ns+w)
3501 //if(ns<old_end && os<ns)
3502 if(ltt_time_compare(*ns
, old_end
) == -1
3503 && ltt_time_compare(*os
, *ns
) == -1)
3505 g_info("scrolling near right");
3506 /* Scroll right, keep right part of the screen */
3508 guint width
= control_flow_data
->drawing
->width
;
3509 convert_time_to_pixels(
3515 /* Copy old data to new location */
3516 copy_pixmap_region(process_list
,
3518 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
3522 control_flow_data
->drawing
->width
-x
+SAFETY
, -1);
3524 if(drawing
->damage_begin
== drawing
->damage_end
)
3525 drawing
->damage_begin
= control_flow_data
->drawing
->width
-x
;
3527 drawing
->damage_begin
= 0;
3529 drawing
->damage_end
= control_flow_data
->drawing
->width
;
3531 /* Clear the data request background, but not SAFETY */
3532 rectangle_pixmap(process_list
,
3533 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
3535 drawing
->damage_begin
+SAFETY
, 0,
3536 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
3538 gtk_widget_queue_draw(drawing
->drawing_area
);
3539 //gtk_widget_queue_draw_area (drawing->drawing_area,
3541 // control_flow_data->drawing->width,
3542 // control_flow_data->drawing->height);
3544 /* Get new data for the rest. */
3545 drawing_data_request(control_flow_data
->drawing
,
3546 drawing
->damage_begin
, 0,
3547 drawing
->damage_end
- drawing
->damage_begin
,
3548 control_flow_data
->drawing
->height
);
3551 //if(ns<os && os<ns+w)
3552 //if(ns<os && os<new_end)
3553 if(ltt_time_compare(*ns
,*os
) == -1
3554 && ltt_time_compare(*os
,new_end
) == -1)
3556 g_info("scrolling near left");
3557 /* Scroll left, keep left part of the screen */
3559 guint width
= control_flow_data
->drawing
->width
;
3560 convert_time_to_pixels(
3566 /* Copy old data to new location */
3567 copy_pixmap_region (process_list
,
3569 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
3575 if(drawing
->damage_begin
== drawing
->damage_end
)
3576 drawing
->damage_end
= x
;
3578 drawing
->damage_end
=
3579 control_flow_data
->drawing
->width
;
3581 drawing
->damage_begin
= 0;
3583 rectangle_pixmap (process_list
,
3584 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
3586 drawing
->damage_begin
, 0,
3587 drawing
->damage_end
- drawing
->damage_begin
, // do not overlap
3590 gtk_widget_queue_draw(drawing
->drawing_area
);
3591 //gtk_widget_queue_draw_area (drawing->drawing_area,
3593 // control_flow_data->drawing->width,
3594 // control_flow_data->drawing->height);
3597 /* Get new data for the rest. */
3598 drawing_data_request(control_flow_data
->drawing
,
3599 drawing
->damage_begin
, 0,
3600 drawing
->damage_end
- drawing
->damage_begin
,
3601 control_flow_data
->drawing
->height
);
3604 if(ltt_time_compare(*ns
,*os
) == 0)
3606 g_info("not scrolling");
3608 g_info("scrolling far");
3609 /* Cannot reuse any part of the screen : far jump */
3612 rectangle_pixmap (process_list
,
3613 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
3616 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
3619 //gtk_widget_queue_draw_area (drawing->drawing_area,
3621 // control_flow_data->drawing->width,
3622 // control_flow_data->drawing->height);
3623 gtk_widget_queue_draw(drawing
->drawing_area
);
3625 drawing
->damage_begin
= 0;
3626 drawing
->damage_end
= control_flow_data
->drawing
->width
;
3628 drawing_data_request(control_flow_data
->drawing
,
3630 control_flow_data
->drawing
->width
,
3631 control_flow_data
->drawing
->height
);
3637 /* Different scale (zoom) */
3640 rectangle_pixmap (process_list
,
3641 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
3644 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
3647 //gtk_widget_queue_draw_area (drawing->drawing_area,
3649 // control_flow_data->drawing->width,
3650 // control_flow_data->drawing->height);
3651 gtk_widget_queue_draw(drawing
->drawing_area
);
3653 drawing
->damage_begin
= 0;
3654 drawing
->damage_end
= control_flow_data
->drawing
->width
;
3656 drawing_data_request(control_flow_data
->drawing
,
3658 control_flow_data
->drawing
->width
,
3659 control_flow_data
->drawing
->height
);
3667 gint
traceset_notify(void *hook_data
, void *call_data
)
3669 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3670 Drawing_t
*drawing
= control_flow_data
->drawing
;
3673 drawing_clear(control_flow_data
->drawing
);
3674 processlist_clear(control_flow_data
->process_list
);
3675 gtk_widget_set_size_request(
3676 control_flow_data
->drawing
->drawing_area
,
3677 -1, processlist_get_height(control_flow_data
->process_list
));
3678 redraw_notify(control_flow_data
, NULL
);
3680 request_background_data(control_flow_data
);
3685 gint
redraw_notify(void *hook_data
, void *call_data
)
3687 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3688 Drawing_t
*drawing
= control_flow_data
->drawing
;
3689 GtkWidget
*widget
= drawing
->drawing_area
;
3691 drawing
->damage_begin
= 0;
3692 drawing
->damage_end
= drawing
->width
;
3694 /* fun feature, to be separated someday... */
3695 drawing_clear(control_flow_data
->drawing
);
3696 processlist_clear(control_flow_data
->process_list
);
3697 gtk_widget_set_size_request(
3698 control_flow_data
->drawing
->drawing_area
,
3699 -1, processlist_get_height(control_flow_data
->process_list
));
3701 rectangle_pixmap (control_flow_data
->process_list
,
3702 widget
->style
->black_gc
,
3705 drawing
->alloc_width
,
3708 gtk_widget_queue_draw(drawing
->drawing_area
);
3710 if(drawing
->damage_begin
< drawing
->damage_end
)
3712 drawing_data_request(drawing
,
3713 drawing
->damage_begin
,
3715 drawing
->damage_end
-drawing
->damage_begin
,
3719 //gtk_widget_queue_draw_area(drawing->drawing_area,
3722 // drawing->height);
3728 gint
continue_notify(void *hook_data
, void *call_data
)
3730 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
3731 Drawing_t
*drawing
= control_flow_data
->drawing
;
3733 //g_assert(widget->allocation.width == drawing->damage_end);
3735 if(drawing
->damage_begin
< drawing
->damage_end
)
3737 drawing_data_request(drawing
,
3738 drawing
->damage_begin
,
3740 drawing
->damage_end
-drawing
->damage_begin
,
3748 gint
update_current_time_hook(void *hook_data
, void *call_data
)
3750 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
3751 Drawing_t
*drawing
= control_flow_data
->drawing
;
3753 LttTime current_time
= *((LttTime
*)call_data
);
3755 TimeWindow time_window
=
3756 lttvwindow_get_time_window(control_flow_data
->tab
);
3758 LttTime time_begin
= time_window
.start_time
;
3759 LttTime width
= time_window
.time_width
;
3762 guint64 time_ll
= ltt_time_to_uint64(width
);
3763 time_ll
= time_ll
>> 1; /* divide by two */
3764 half_width
= ltt_time_from_uint64(time_ll
);
3766 LttTime time_end
= ltt_time_add(time_begin
, width
);
3768 LttvTracesetContext
* tsc
=
3769 lttvwindow_get_traceset_context(control_flow_data
->tab
);
3771 LttTime trace_start
= tsc
->time_span
.start_time
;
3772 LttTime trace_end
= tsc
->time_span
.end_time
;
3774 g_info("New current time HOOK : %lu, %lu", current_time
.tv_sec
,
3775 current_time
.tv_nsec
);
3779 /* If current time is inside time interval, just move the highlight
3782 /* Else, we have to change the time interval. We have to tell it
3783 * to the main window. */
3784 /* The time interval change will take care of placing the current
3785 * time at the center of the visible area, or nearest possible if we are
3786 * at one end of the trace. */
3789 if(ltt_time_compare(current_time
, time_begin
) < 0)
3791 TimeWindow new_time_window
;
3793 if(ltt_time_compare(current_time
,
3794 ltt_time_add(trace_start
,half_width
)) < 0)
3795 time_begin
= trace_start
;
3797 time_begin
= ltt_time_sub(current_time
,half_width
);
3799 new_time_window
.start_time
= time_begin
;
3800 new_time_window
.time_width
= width
;
3801 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3802 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3804 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3806 else if(ltt_time_compare(current_time
, time_end
) > 0)
3808 TimeWindow new_time_window
;
3810 if(ltt_time_compare(current_time
, ltt_time_sub(trace_end
, half_width
)) > 0)
3811 time_begin
= ltt_time_sub(trace_end
,width
);
3813 time_begin
= ltt_time_sub(current_time
,half_width
);
3815 new_time_window
.start_time
= time_begin
;
3816 new_time_window
.time_width
= width
;
3817 new_time_window
.time_width_double
= ltt_time_to_double(width
);
3818 new_time_window
.end_time
= ltt_time_add(time_begin
, width
);
3820 lttvwindow_report_time_window(control_flow_data
->tab
, new_time_window
);
3823 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
3829 typedef struct _ClosureData
{
3830 EventsRequest
*events_request
;
3831 LttvTracesetState
*tss
;
3837 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
3839 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
3840 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
3841 ClosureData
*closure_data
= (ClosureData
*)user_data
;
3843 EventsRequest
*events_request
= closure_data
->events_request
;
3844 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
3846 LttvTracesetState
*tss
= closure_data
->tss
;
3847 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
3849 LttTime evtime
= closure_data
->end_time
;
3852 /* For the process */
3853 /* First, check if the current process is in the state computation
3854 * process list. If it is there, that means we must add it right now and
3855 * draw items from the beginning of the read for it. If it is not
3856 * present, it's a new process and it was not present : it will
3857 * be added after the state update. */
3859 g_assert(lttv_traceset_number(tsc
->ts
) > 0);
3860 #endif //EXTRA_CHECK
3861 LttvTraceContext
*tc
= tsc
->traces
[process_info
->trace_num
];
3862 LttvTraceState
*ts
= (LttvTraceState
*)tc
;
3865 //FIXME : optimize data structures.
3866 LttvTracefileState
*tfs
;
3867 LttvTracefileContext
*tfc
;
3869 for(i
=0;i
<tc
->tracefiles
->len
;i
++) {
3870 tfc
= g_array_index(tc
->tracefiles
, LttvTracefileContext
*, i
);
3871 if(ltt_tracefile_name(tfc
->tf
) == LTT_NAME_CPU
3872 && ltt_tracefile_num(tfc
->tf
) == process_info
->cpu
)
3876 g_assert(i
<tc
->tracefiles
->len
);
3877 tfs
= LTTV_TRACEFILE_STATE(tfc
);
3879 // LttvTracefileState *tfs =
3880 // (LttvTracefileState*)tsc->traces[process_info->trace_num]->
3881 // tracefiles[process_info->cpu];
3883 LttvProcessState
*process
;
3884 process
= lttv_state_find_process(ts
, process_info
->cpu
,
3887 if(unlikely(process
!= NULL
)) {
3889 /* Only draw for processes that are currently in the trace states */
3891 ProcessList
*process_list
= control_flow_data
->process_list
;
3893 /* Should be alike when background info is ready */
3894 if(control_flow_data
->background_info_waiting
==0)
3895 g_assert(ltt_time_compare(process
->creation_time
,
3896 process_info
->birth
) == 0);
3897 #endif //EXTRA_CHECK
3899 /* Now, the process is in the state hash and our own process hash.
3900 * We definitely can draw the items related to the ending state.
3903 if(unlikely(ltt_time_compare(hashed_process_data
->next_good_time
,
3906 TimeWindow time_window
=
3907 lttvwindow_get_time_window(control_flow_data
->tab
);
3910 if(ltt_time_compare(evtime
, time_window
.start_time
) == -1
3911 || ltt_time_compare(evtime
, time_window
.end_time
) == 1)
3913 #endif //EXTRA_CHECK
3914 Drawing_t
*drawing
= control_flow_data
->drawing
;
3915 guint width
= drawing
->width
;
3917 guint x
= closure_data
->x_end
;
3919 DrawContext draw_context
;
3921 /* Now create the drawing context that will be used to draw
3922 * items related to the last state. */
3923 draw_context
.drawable
= hashed_process_data
->pixmap
;
3924 draw_context
.gc
= drawing
->gc
;
3925 draw_context
.pango_layout
= drawing
->pango_layout
;
3926 draw_context
.drawinfo
.end
.x
= x
;
3928 draw_context
.drawinfo
.y
.over
= 1;
3929 draw_context
.drawinfo
.y
.middle
= (hashed_process_data
->height
/2);
3930 draw_context
.drawinfo
.y
.under
= hashed_process_data
->height
;
3932 draw_context
.drawinfo
.start
.offset
.over
= 0;
3933 draw_context
.drawinfo
.start
.offset
.middle
= 0;
3934 draw_context
.drawinfo
.start
.offset
.under
= 0;
3935 draw_context
.drawinfo
.end
.offset
.over
= 0;
3936 draw_context
.drawinfo
.end
.offset
.middle
= 0;
3937 draw_context
.drawinfo
.end
.offset
.under
= 0;
3939 /* Jump over draw if we are at the same x position */
3940 if(x
== hashed_process_data
->x
.over
)
3944 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.over
;
3946 PropertiesLine prop_line
= prepare_execmode_line(process
);
3947 draw_line((void*)&prop_line
, (void*)&draw_context
);
3949 hashed_process_data
->x
.over
= x
;
3953 if(unlikely(x
== hashed_process_data
->x
.middle
&&
3954 hashed_process_data
->x
.middle_used
)) {
3955 #if 0 /* do not mark closure : not missing information */
3956 if(hashed_process_data
->x
.middle_marked
== FALSE
) {
3957 /* Draw collision indicator */
3958 gdk_gc_set_foreground(drawing
->gc
, &drawing_colors
[COL_WHITE
]);
3959 gdk_draw_point(drawing
->pixmap
,
3963 hashed_process_data
->x
.middle_marked
= TRUE
;
3968 draw_context
.drawinfo
.start
.x
= hashed_process_data
->x
.middle
;
3970 PropertiesLine prop_line
= prepare_s_e_line(process
);
3971 draw_line((void*)&prop_line
, (void*)&draw_context
);
3973 /* become the last x position */
3974 if(likely(x
!= hashed_process_data
->x
.middle
)) {
3975 hashed_process_data
->x
.middle
= x
;
3976 /* but don't use the pixel */
3977 hashed_process_data
->x
.middle_used
= FALSE
;
3979 /* Calculate the next good time */
3980 convert_pixels_to_time(width
, x
+1, time_window
,
3981 &hashed_process_data
->next_good_time
);
3990 int before_chunk(void *hook_data
, void *call_data
)
3992 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
3993 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
3994 ControlFlowData
*cfd
= (ControlFlowData
*)events_request
->viewer_data
;
3996 /* Desactivate sort */
3997 gtk_tree_sortable_set_sort_column_id(
3998 GTK_TREE_SORTABLE(cfd
->process_list
->list_store
),
4000 GTK_SORT_ASCENDING
);
4002 drawing_chunk_begin(events_request
, tss
);
4007 int before_request(void *hook_data
, void *call_data
)
4009 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
4010 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
4012 drawing_data_request_begin(events_request
, tss
);
4019 * after request is necessary in addition of after chunk in order to draw
4020 * lines until the end of the screen. after chunk just draws lines until
4027 int after_request(void *hook_data
, void *call_data
)
4029 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
4030 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
4031 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
4033 ProcessList
*process_list
= control_flow_data
->process_list
;
4034 LttTime end_time
= events_request
->end_time
;
4036 ClosureData closure_data
;
4037 closure_data
.events_request
= (EventsRequest
*)hook_data
;
4038 closure_data
.tss
= tss
;
4039 closure_data
.end_time
= end_time
;
4041 TimeWindow time_window
=
4042 lttvwindow_get_time_window(control_flow_data
->tab
);
4043 guint width
= control_flow_data
->drawing
->width
;
4044 convert_time_to_pixels(
4048 &closure_data
.x_end
);
4051 /* Draw last items */
4052 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
4053 (void*)&closure_data
);
4056 /* Request expose */
4057 drawing_request_expose(events_request
, tss
, end_time
);
4066 int after_chunk(void *hook_data
, void *call_data
)
4068 EventsRequest
*events_request
= (EventsRequest
*)hook_data
;
4069 ControlFlowData
*control_flow_data
= events_request
->viewer_data
;
4070 LttvTracesetState
*tss
= (LttvTracesetState
*)call_data
;
4071 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)call_data
;
4072 LttvTracefileContext
*tfc
= lttv_traceset_context_get_current_tfc(tsc
);
4075 ProcessList
*process_list
= control_flow_data
->process_list
;
4077 g_free(process_list
->current_hash_data
);
4078 process_list
->current_hash_data
= NULL
;
4081 end_time
= LTT_TIME_MIN(tfc
->timestamp
, events_request
->end_time
);
4082 else /* end of traceset, or position now out of request : end */
4083 end_time
= events_request
->end_time
;
4085 ClosureData closure_data
;
4086 closure_data
.events_request
= (EventsRequest
*)hook_data
;
4087 closure_data
.tss
= tss
;
4088 closure_data
.end_time
= end_time
;
4090 TimeWindow time_window
=
4091 lttvwindow_get_time_window(control_flow_data
->tab
);
4092 guint width
= control_flow_data
->drawing
->width
;
4093 convert_time_to_pixels(
4097 &closure_data
.x_end
);
4099 /* Draw last items */
4100 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
4101 (void*)&closure_data
);
4103 /* Reactivate sort */
4104 gtk_tree_sortable_set_sort_column_id(
4105 GTK_TREE_SORTABLE(control_flow_data
->process_list
->list_store
),
4106 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID
,
4107 GTK_SORT_ASCENDING
);
4109 update_index_to_pixmap(control_flow_data
->process_list
);
4110 /* Request a full expose : drawing scrambled */
4111 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
4113 /* Request expose (updates damages zone also) */
4114 drawing_request_expose(events_request
, tss
, end_time
);