1 /*****************************************************************************
2 * Hooks to be called by the main window *
3 *****************************************************************************/
6 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
7 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
9 //#define PANGO_ENABLE_BACKEND
16 //#include <pango/pango.h>
18 #include <ltt/event.h>
22 #include <lttv/hook.h>
23 #include <lttv/common.h>
24 #include <lttv/state.h>
27 #include "Event_Hooks.h"
29 #include "Process_List.h"
31 #include "CFV-private.h"
34 #define MAX_PATH_LEN 256
38 * Event Viewer's constructor hook
40 * This constructor is given as a parameter to the menuitem and toolbar button
41 * registration. It creates the list.
42 * @param pmParentWindow A pointer to the parent window.
43 * @return The widget created.
46 h_guicontrolflow(MainWindow
*pmParentWindow
, LttvTracesetSelector
* s
, char * key
)
48 g_info("h_guicontrolflow, %p, %p, %s", pmParentWindow
, s
, key
);
49 ControlFlowData
*Control_Flow_Data
= guicontrolflow() ;
51 Control_Flow_Data
->Parent_Window
= pmParentWindow
;
52 TimeWindow
*time_window
= guicontrolflow_get_time_window(Control_Flow_Data
);
53 time_window
->start_time
.tv_sec
= 0;
54 time_window
->start_time
.tv_nsec
= 0;
55 time_window
->time_width
.tv_sec
= 0;
56 time_window
->time_width
.tv_nsec
= 0;
58 LttTime
*current_time
= guicontrolflow_get_current_time(Control_Flow_Data
);
59 current_time
->tv_sec
= 0;
60 current_time
->tv_nsec
= 0;
62 //g_critical("time width1 : %u",time_window->time_width);
64 get_time_window(pmParentWindow
,
66 get_current_time(pmParentWindow
,
69 //g_critical("time width2 : %u",time_window->time_width);
70 // Unreg done in the GuiControlFlow_Destructor
71 reg_update_time_window(update_time_window_hook
, Control_Flow_Data
,
73 reg_update_current_time(update_current_time_hook
, Control_Flow_Data
,
75 return guicontrolflow_get_widget(Control_Flow_Data
) ;
79 int event_selected_hook(void *hook_data
, void *call_data
)
81 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
82 guint
*Event_Number
= (guint
*) call_data
;
84 g_critical("DEBUG : event selected by main window : %u", *Event_Number
);
86 // Control_Flow_Data->Currently_Selected_Event = *Event_Number;
87 // Control_Flow_Data->Selected_Event = TRUE ;
89 // tree_v_set_cursor(Control_Flow_Data);
93 /* Hook called before drawing. Gets the initial context at the beginning of the
94 * drawing interval and copy it to the context in Event_Request.
96 int draw_before_hook(void *hook_data
, void *call_data
)
98 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
99 //EventsContext Events_Context = (EventsContext*)call_data;
101 //Event_Request->Events_Context = Events_Context;
107 * The draw event hook is called by the reading API to have a
108 * particular event drawn on the screen.
109 * @param hook_data ControlFlowData structure of the viewer.
110 * @param call_data Event context.
112 * This function basically draw lines and icons. Two types of lines are drawn :
113 * one small (3 pixels?) representing the state of the process and the second
114 * type is thicker (10 pixels?) representing on which CPU a process is running
115 * (and this only in running state).
117 * Extremums of the lines :
118 * x_min : time of the last event context for this process kept in memory.
119 * x_max : time of the current event.
120 * y : middle of the process in the process list. The process is found in the
121 * list, therefore is it's position in pixels.
123 * The choice of lines'color is defined by the context of the last event for this
126 int draw_event_hook(void *hook_data
, void *call_data
)
128 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
129 ControlFlowData
*control_flow_data
= Event_Request
->Control_Flow_Data
;
131 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
133 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
139 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
141 g_critical("schedchange!");
143 /* Add process to process list (if not present) and get drawing "y" from
144 * process position */
145 guint pid_out
, pid_in
;
146 LttvProcessState
*process_out
, *process_in
;
148 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
150 ProcessList
*process_list
=
151 guicontrolflow_get_process_list(Event_Request
->Control_Flow_Data
);
154 LttField
*f
= ltt_event_field(e
);
156 element
= ltt_field_member(f
,0);
157 pid_out
= ltt_event_get_long_unsigned(e
,element
);
158 element
= ltt_field_member(f
,1);
159 pid_in
= ltt_event_get_long_unsigned(e
,element
);
160 g_critical("out : %u in : %u", pid_out
, pid_in
);
163 /* Find process pid_out in the list... */
164 process_out
= lttv_state_find_process(tfs
, pid_out
);
165 g_critical("out : %s",g_quark_to_string(process_out
->state
->s
));
167 birth
= process_out
->creation_time
;
168 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
169 HashedProcessData
*Hashed_Process_Data_out
= NULL
;
171 if(processlist_get_process_pixels(process_list
,
176 &Hashed_Process_Data_out
) == 1)
178 /* Process not present */
179 processlist_add(process_list
,
184 &Hashed_Process_Data_out
);
185 processlist_get_process_pixels(process_list
,
190 &Hashed_Process_Data_out
);
191 drawing_insert_square( Event_Request
->Control_Flow_Data
->Drawing
, y_out
, height
);
196 /* Find process pid_in in the list... */
197 process_in
= lttv_state_find_process(tfs
, pid_in
);
198 g_critical("in : %s",g_quark_to_string(process_in
->state
->s
));
200 birth
= process_in
->creation_time
;
201 name
= strdup(g_quark_to_string(process_in
->name
));
202 HashedProcessData
*Hashed_Process_Data_in
= NULL
;
204 if(processlist_get_process_pixels(process_list
,
209 &Hashed_Process_Data_in
) == 1)
211 /* Process not present */
212 processlist_add(process_list
,
217 &Hashed_Process_Data_in
);
218 processlist_get_process_pixels(process_list
,
223 &Hashed_Process_Data_in
);
225 drawing_insert_square( Event_Request
->Control_Flow_Data
->Drawing
, y_in
, height
);
230 /* Find pixels corresponding to time of the event. If the time does
231 * not fit in the window, show a warning, not supposed to happend. */
233 guint width
= control_flow_data
->Drawing
->Drawing_Area_V
->allocation
.width
;
235 LttTime time
= ltt_event_time(e
);
237 LttTime window_end
= ltt_time_add(control_flow_data
->Time_Window
.time_width
,
238 control_flow_data
->Time_Window
.start_time
);
241 convert_time_to_pixels(
242 control_flow_data
->Time_Window
.start_time
,
250 /* draw what represents the event for outgoing process. */
252 DrawContext
*draw_context_out
= Hashed_Process_Data_out
->draw_context
;
253 draw_context_out
->Current
->modify_over
->x
= x
;
254 draw_context_out
->Current
->modify_over
->y
= y_out
;
255 draw_context_out
->drawable
= control_flow_data
->Drawing
->Pixmap
;
256 draw_context_out
->pango_layout
= control_flow_data
->Drawing
->pango_layout
;
257 GtkWidget
*widget
= control_flow_data
->Drawing
->Drawing_Area_V
;
258 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
259 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->Drawing
->Pixmap
);
260 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
261 //draw_context_out->gc = widget->style->black_gc;
263 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
264 //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap);
266 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
267 GdkColor colorbg_out
= { 0, 0xffff, 0xffff, 0xffff };
268 PropertiesText prop_text_out
;
269 prop_text_out
.foreground
= &colorfg_out
;
270 prop_text_out
.background
= &colorbg_out
;
271 prop_text_out
.size
= 10;
272 prop_text_out
.position
= OVER
;
274 /* Print status of the process : U, WF, WC, E, W, R */
275 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
276 prop_text_out
.Text
= "U";
277 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
278 prop_text_out
.Text
= "WF";
279 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
280 prop_text_out
.Text
= "WC";
281 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
282 prop_text_out
.Text
= "E";
283 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
284 prop_text_out
.Text
= "W";
285 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
286 prop_text_out
.Text
= "R";
288 prop_text_out
.Text
= "U";
290 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
291 gdk_gc_unref(draw_context_out
->gc
);
293 /* Draw the line of the out process */
294 if(draw_context_out
->Previous
->middle
->x
== -1)
296 draw_context_out
->Previous
->middle
->x
= Event_Request
->x_begin
;
297 g_critical("out middle x_beg : %u",Event_Request
->x_begin
);
300 draw_context_out
->Current
->middle
->x
= x
;
301 draw_context_out
->Current
->middle
->y
= y_out
+ height
/2;
302 draw_context_out
->Previous
->middle
->y
= y_out
+ height
/2;
303 draw_context_out
->drawable
= control_flow_data
->Drawing
->Pixmap
;
304 draw_context_out
->pango_layout
= control_flow_data
->Drawing
->pango_layout
;
305 //draw_context_out->gc = widget->style->black_gc;
306 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->Drawing
->Pixmap
);
307 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
309 PropertiesLine prop_line_out
;
310 prop_line_out
.color
= g_new(GdkColor
,1);
311 prop_line_out
.line_width
= 4;
312 prop_line_out
.style
= GDK_LINE_SOLID
;
313 prop_line_out
.position
= MIDDLE
;
315 /* color of line : status of the process */
316 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
318 prop_line_out
.color
->red
= 0x0000;
319 prop_line_out
.color
->green
= 0x0000;
320 prop_line_out
.color
->blue
= 0x0000;
322 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
324 prop_line_out
.color
->red
= 0x0fff;
325 prop_line_out
.color
->green
= 0x0000;
326 prop_line_out
.color
->blue
= 0x0fff;
328 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
330 prop_line_out
.color
->red
= 0x0fff;
331 prop_line_out
.color
->green
= 0x0fff;
332 prop_line_out
.color
->blue
= 0x0000;
334 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
336 prop_line_out
.color
->red
= 0xffff;
337 prop_line_out
.color
->green
= 0x0000;
338 prop_line_out
.color
->blue
= 0xffff;
340 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
342 prop_line_out
.color
->red
= 0xffff;
343 prop_line_out
.color
->green
= 0x0000;
344 prop_line_out
.color
->blue
= 0x0000;
346 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
348 prop_line_out
.color
->red
= 0x0000;
349 prop_line_out
.color
->green
= 0xffff;
350 prop_line_out
.color
->blue
= 0x0000;
354 prop_line_out
.color
->red
= 0x0000;
355 prop_line_out
.color
->green
= 0x0000;
356 prop_line_out
.color
->blue
= 0x0000;
359 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
360 g_free(prop_line_out
.color
);
361 gdk_gc_unref(draw_context_out
->gc
);
362 /* Note : finishing line will have to be added when trace read over. */
364 /* Finally, update the drawing context of the pid_in. */
366 DrawContext
*draw_context_in
= Hashed_Process_Data_in
->draw_context
;
367 draw_context_in
->Current
->modify_over
->x
= x
;
368 draw_context_in
->Current
->modify_over
->y
= y_in
;
369 draw_context_in
->drawable
= control_flow_data
->Drawing
->Pixmap
;
370 draw_context_in
->pango_layout
= control_flow_data
->Drawing
->pango_layout
;
371 widget
= control_flow_data
->Drawing
->Drawing_Area_V
;
372 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
373 //draw_context_in->gc = widget->style->black_gc;
374 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->Drawing
->Pixmap
);
375 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
377 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
378 //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap);
380 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
381 GdkColor colorbg_in
= { 0, 0xffff, 0xffff, 0xffff };
382 PropertiesText prop_text_in
;
383 prop_text_in
.foreground
= &colorfg_in
;
384 prop_text_in
.background
= &colorbg_in
;
385 prop_text_in
.size
= 10;
386 prop_text_in
.position
= OVER
;
388 /* Print status of the process : U, WF, WC, E, W, R */
389 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
390 prop_text_in
.Text
= "U";
391 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
392 prop_text_in
.Text
= "WF";
393 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
394 prop_text_in
.Text
= "WC";
395 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
396 prop_text_in
.Text
= "E";
397 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
398 prop_text_in
.Text
= "W";
399 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
400 prop_text_in
.Text
= "R";
402 prop_text_in
.Text
= "U";
404 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
405 gdk_gc_unref(draw_context_in
->gc
);
407 /* Draw the line of the in process */
408 if(draw_context_in
->Previous
->middle
->x
== -1)
410 draw_context_in
->Previous
->middle
->x
= Event_Request
->x_begin
;
411 g_critical("in middle x_beg : %u",Event_Request
->x_begin
);
414 draw_context_in
->Current
->middle
->x
= x
;
415 draw_context_in
->Previous
->middle
->y
= y_in
+ height
/2;
416 draw_context_in
->Current
->middle
->y
= y_in
+ height
/2;
417 draw_context_in
->drawable
= control_flow_data
->Drawing
->Pixmap
;
418 draw_context_in
->pango_layout
= control_flow_data
->Drawing
->pango_layout
;
419 //draw_context_in->gc = widget->style->black_gc;
420 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->Drawing
->Pixmap
);
421 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
423 PropertiesLine prop_line_in
;
424 prop_line_in
.color
= g_new(GdkColor
,1);
425 prop_line_in
.line_width
= 4;
426 prop_line_in
.style
= GDK_LINE_SOLID
;
427 prop_line_in
.position
= MIDDLE
;
429 /* color of line : status of the process */
430 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
432 prop_line_in
.color
->red
= 0x0000;
433 prop_line_in
.color
->green
= 0x0000;
434 prop_line_in
.color
->blue
= 0x0000;
436 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
438 prop_line_in
.color
->red
= 0x0fff;
439 prop_line_in
.color
->green
= 0x0000;
440 prop_line_in
.color
->blue
= 0x0fff;
442 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
444 prop_line_in
.color
->red
= 0x0fff;
445 prop_line_in
.color
->green
= 0x0fff;
446 prop_line_in
.color
->blue
= 0x0000;
448 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
450 prop_line_in
.color
->red
= 0xffff;
451 prop_line_in
.color
->green
= 0x0000;
452 prop_line_in
.color
->blue
= 0xffff;
454 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
456 prop_line_in
.color
->red
= 0xffff;
457 prop_line_in
.color
->green
= 0x0000;
458 prop_line_in
.color
->blue
= 0x0000;
460 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
462 prop_line_in
.color
->red
= 0x0000;
463 prop_line_in
.color
->green
= 0xffff;
464 prop_line_in
.color
->blue
= 0x0000;
468 prop_line_in
.color
->red
= 0x0000;
469 prop_line_in
.color
->green
= 0x0000;
470 prop_line_in
.color
->blue
= 0x0000;
473 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
474 g_free(prop_line_in
.color
);
475 gdk_gc_unref(draw_context_in
->gc
);
482 GString
*string
= g_string_new("");;
483 gboolean field_names
= TRUE
, state
= TRUE
;
485 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
486 g_string_append_printf(string
,"\n");
489 g_string_append_printf(string
, " %s",
490 g_quark_to_string(tfs
->process
->state
->s
));
493 g_info("%s",string
->str
);
495 g_string_free(string
, TRUE
);
497 /* End of text dump */
503 int draw_after_hook(void *hook_data
, void *call_data
)
505 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
506 ControlFlowData
*control_flow_data
= Event_Request
->Control_Flow_Data
;
508 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
510 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
516 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
518 g_critical("schedchange!");
520 /* Add process to process list (if not present) and get drawing "y" from
521 * process position */
522 guint pid_out
, pid_in
;
523 LttvProcessState
*process_out
, *process_in
;
525 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
527 ProcessList
*process_list
=
528 guicontrolflow_get_process_list(Event_Request
->Control_Flow_Data
);
531 LttField
*f
= ltt_event_field(e
);
533 element
= ltt_field_member(f
,0);
534 pid_out
= ltt_event_get_long_unsigned(e
,element
);
535 element
= ltt_field_member(f
,1);
536 pid_in
= ltt_event_get_long_unsigned(e
,element
);
537 g_critical("out : %u in : %u", pid_out
, pid_in
);
540 /* Find process pid_out in the list... */
541 process_out
= lttv_state_find_process(tfs
, pid_out
);
542 g_critical("out : %s",g_quark_to_string(process_out
->state
->s
));
544 birth
= process_out
->creation_time
;
545 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
546 HashedProcessData
*Hashed_Process_Data_out
= NULL
;
548 if(processlist_get_process_pixels(process_list
,
553 &Hashed_Process_Data_out
) == 1)
555 /* Process not present */
556 processlist_add(process_list
,
561 &Hashed_Process_Data_out
);
562 processlist_get_process_pixels(process_list
,
567 &Hashed_Process_Data_out
);
568 drawing_insert_square( Event_Request
->Control_Flow_Data
->Drawing
, y_out
, height
);
573 /* Find process pid_in in the list... */
574 process_in
= lttv_state_find_process(tfs
, pid_in
);
575 g_critical("in : %s",g_quark_to_string(process_in
->state
->s
));
577 birth
= process_in
->creation_time
;
578 name
= strdup(g_quark_to_string(process_in
->name
));
579 HashedProcessData
*Hashed_Process_Data_in
= NULL
;
581 if(processlist_get_process_pixels(process_list
,
586 &Hashed_Process_Data_in
) == 1)
588 /* Process not present */
589 processlist_add(process_list
,
594 &Hashed_Process_Data_in
);
595 processlist_get_process_pixels(process_list
,
600 &Hashed_Process_Data_in
);
602 drawing_insert_square( Event_Request
->Control_Flow_Data
->Drawing
, y_in
, height
);
607 /* Find pixels corresponding to time of the event. If the time does
608 * not fit in the window, show a warning, not supposed to happend. */
610 //guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width;
612 //LttTime time = ltt_event_time(e);
614 //LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width,
615 // control_flow_data->Time_Window.start_time);
618 //convert_time_to_pixels(
619 // control_flow_data->Time_Window.start_time,
625 //assert(x <= width);
627 /* draw what represents the event for outgoing process. */
629 DrawContext
*draw_context_out
= Hashed_Process_Data_out
->draw_context
;
630 //draw_context_out->Current->modify_over->x = x;
631 draw_context_out
->Current
->modify_over
->y
= y_out
;
632 draw_context_out
->drawable
= control_flow_data
->Drawing
->Pixmap
;
633 draw_context_out
->pango_layout
= control_flow_data
->Drawing
->pango_layout
;
634 GtkWidget
*widget
= control_flow_data
->Drawing
->Drawing_Area_V
;
635 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
636 draw_context_out
->gc
= widget
->style
->black_gc
;
638 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
639 //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap);
641 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
642 GdkColor colorbg_out
= { 0, 0xffff, 0xffff, 0xffff };
643 PropertiesText prop_text_out
;
644 prop_text_out
.foreground
= &colorfg_out
;
645 prop_text_out
.background
= &colorbg_out
;
646 prop_text_out
.size
= 10;
647 prop_text_out
.position
= OVER
;
649 /* Print status of the process : U, WF, WC, E, W, R */
650 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
651 prop_text_out
.Text
= "U";
652 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
653 prop_text_out
.Text
= "WF";
654 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
655 prop_text_out
.Text
= "WC";
656 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
657 prop_text_out
.Text
= "E";
658 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
659 prop_text_out
.Text
= "W";
660 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
661 prop_text_out
.Text
= "R";
663 prop_text_out
.Text
= "U";
665 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
667 draw_context_out
->Current
->middle
->y
= y_out
+height
/2;
668 draw_context_out
->Current
->status
= process_out
->state
->s
;
670 /* for pid_out : remove Previous, Prev = Current, new Current (default) */
671 g_free(draw_context_out
->Previous
->modify_under
);
672 g_free(draw_context_out
->Previous
->modify_middle
);
673 g_free(draw_context_out
->Previous
->modify_over
);
674 g_free(draw_context_out
->Previous
->under
);
675 g_free(draw_context_out
->Previous
->middle
);
676 g_free(draw_context_out
->Previous
->over
);
677 g_free(draw_context_out
->Previous
);
679 draw_context_out
->Previous
= draw_context_out
->Current
;
681 draw_context_out
->Current
= g_new(DrawInfo
,1);
682 draw_context_out
->Current
->over
= g_new(ItemInfo
,1);
683 draw_context_out
->Current
->over
->x
= -1;
684 draw_context_out
->Current
->over
->y
= -1;
685 draw_context_out
->Current
->middle
= g_new(ItemInfo
,1);
686 draw_context_out
->Current
->middle
->x
= -1;
687 draw_context_out
->Current
->middle
->y
= -1;
688 draw_context_out
->Current
->under
= g_new(ItemInfo
,1);
689 draw_context_out
->Current
->under
->x
= -1;
690 draw_context_out
->Current
->under
->y
= -1;
691 draw_context_out
->Current
->modify_over
= g_new(ItemInfo
,1);
692 draw_context_out
->Current
->modify_over
->x
= -1;
693 draw_context_out
->Current
->modify_over
->y
= -1;
694 draw_context_out
->Current
->modify_middle
= g_new(ItemInfo
,1);
695 draw_context_out
->Current
->modify_middle
->x
= -1;
696 draw_context_out
->Current
->modify_middle
->y
= -1;
697 draw_context_out
->Current
->modify_under
= g_new(ItemInfo
,1);
698 draw_context_out
->Current
->modify_under
->x
= -1;
699 draw_context_out
->Current
->modify_under
->y
= -1;
700 draw_context_out
->Current
->status
= LTTV_STATE_UNNAMED
;
702 /* Finally, update the drawing context of the pid_in. */
704 DrawContext
*draw_context_in
= Hashed_Process_Data_in
->draw_context
;
705 //draw_context_in->Current->modify_over->x = x;
706 draw_context_in
->Current
->modify_over
->y
= y_in
;
707 draw_context_in
->drawable
= control_flow_data
->Drawing
->Pixmap
;
708 draw_context_in
->pango_layout
= control_flow_data
->Drawing
->pango_layout
;
709 widget
= control_flow_data
->Drawing
->Drawing_Area_V
;
710 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
711 draw_context_in
->gc
= widget
->style
->black_gc
;
713 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
714 //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap);
716 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
717 GdkColor colorbg_in
= { 0, 0xffff, 0xffff, 0xffff };
718 PropertiesText prop_text_in
;
719 prop_text_in
.foreground
= &colorfg_in
;
720 prop_text_in
.background
= &colorbg_in
;
721 prop_text_in
.size
= 10;
722 prop_text_in
.position
= OVER
;
724 /* Print status of the process : U, WF, WC, E, W, R */
725 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
726 prop_text_in
.Text
= "U";
727 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
728 prop_text_in
.Text
= "WF";
729 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
730 prop_text_in
.Text
= "WC";
731 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
732 prop_text_in
.Text
= "E";
733 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
734 prop_text_in
.Text
= "W";
735 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
736 prop_text_in
.Text
= "R";
738 prop_text_in
.Text
= "U";
740 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
742 draw_context_in
->Current
->middle
->y
= y_in
+height
/2;
743 draw_context_in
->Current
->status
= process_in
->state
->s
;
745 /* for pid_in : remove Previous, Prev = Current, new Current (default) */
746 g_free(draw_context_in
->Previous
->modify_under
);
747 g_free(draw_context_in
->Previous
->modify_middle
);
748 g_free(draw_context_in
->Previous
->modify_over
);
749 g_free(draw_context_in
->Previous
->under
);
750 g_free(draw_context_in
->Previous
->middle
);
751 g_free(draw_context_in
->Previous
->over
);
752 g_free(draw_context_in
->Previous
);
754 draw_context_in
->Previous
= draw_context_in
->Current
;
756 draw_context_in
->Current
= g_new(DrawInfo
,1);
757 draw_context_in
->Current
->over
= g_new(ItemInfo
,1);
758 draw_context_in
->Current
->over
->x
= -1;
759 draw_context_in
->Current
->over
->y
= -1;
760 draw_context_in
->Current
->middle
= g_new(ItemInfo
,1);
761 draw_context_in
->Current
->middle
->x
= -1;
762 draw_context_in
->Current
->middle
->y
= -1;
763 draw_context_in
->Current
->under
= g_new(ItemInfo
,1);
764 draw_context_in
->Current
->under
->x
= -1;
765 draw_context_in
->Current
->under
->y
= -1;
766 draw_context_in
->Current
->modify_over
= g_new(ItemInfo
,1);
767 draw_context_in
->Current
->modify_over
->x
= -1;
768 draw_context_in
->Current
->modify_over
->y
= -1;
769 draw_context_in
->Current
->modify_middle
= g_new(ItemInfo
,1);
770 draw_context_in
->Current
->modify_middle
->x
= -1;
771 draw_context_in
->Current
->modify_middle
->y
= -1;
772 draw_context_in
->Current
->modify_under
= g_new(ItemInfo
,1);
773 draw_context_in
->Current
->modify_under
->x
= -1;
774 draw_context_in
->Current
->modify_under
->y
= -1;
775 draw_context_in
->Current
->status
= LTTV_STATE_UNNAMED
;
785 void update_time_window_hook(void *hook_data
, void *call_data
)
787 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
788 TimeWindow
*Old_Time_Window
=
789 guicontrolflow_get_time_window(control_flow_data
);
790 TimeWindow
*New_Time_Window
= ((TimeWindow
*)call_data
);
792 /* Two cases : zoom in/out or scrolling */
794 /* In order to make sure we can reuse the old drawing, the scale must
795 * be the same and the new time interval being partly located in the
796 * currently shown time interval. (reuse is only for scrolling)
799 g_info("Old time window HOOK : %u, %u to %u, %u",
800 Old_Time_Window
->start_time
.tv_sec
,
801 Old_Time_Window
->start_time
.tv_nsec
,
802 Old_Time_Window
->time_width
.tv_sec
,
803 Old_Time_Window
->time_width
.tv_nsec
);
805 g_info("New time window HOOK : %u, %u to %u, %u",
806 New_Time_Window
->start_time
.tv_sec
,
807 New_Time_Window
->start_time
.tv_nsec
,
808 New_Time_Window
->time_width
.tv_sec
,
809 New_Time_Window
->time_width
.tv_nsec
);
811 if( New_Time_Window
->time_width
.tv_sec
== Old_Time_Window
->time_width
.tv_sec
812 && New_Time_Window
->time_width
.tv_nsec
== Old_Time_Window
->time_width
.tv_nsec
)
814 /* Same scale (scrolling) */
816 LttTime
*ns
= &New_Time_Window
->start_time
;
817 LttTime
*os
= &Old_Time_Window
->start_time
;
818 LttTime old_end
= ltt_time_add(Old_Time_Window
->start_time
,
819 Old_Time_Window
->time_width
);
820 LttTime new_end
= ltt_time_add(New_Time_Window
->start_time
,
821 New_Time_Window
->time_width
);
823 //if(ns<os+w && os+w<ns+w)
824 //if(ns<old_end && os<ns)
825 if(ltt_time_compare(*ns
, old_end
) == -1
826 && ltt_time_compare(*os
, *ns
) == -1)
828 g_info("scrolling near right");
829 /* Scroll right, keep right part of the screen */
831 guint width
= control_flow_data
->Drawing
->Drawing_Area_V
->allocation
.width
;
832 convert_time_to_pixels(
839 /* Copy old data to new location */
840 gdk_draw_drawable (control_flow_data
->Drawing
->Pixmap
,
841 control_flow_data
->Drawing
->Drawing_Area_V
->style
->white_gc
,
842 control_flow_data
->Drawing
->Pixmap
,
847 convert_time_to_pixels(
854 *Old_Time_Window
= *New_Time_Window
;
855 /* Clear the data request background, but not SAFETY */
856 gdk_draw_rectangle (control_flow_data
->Drawing
->Pixmap
,
857 control_flow_data
->Drawing
->Drawing_Area_V
->style
->white_gc
,
860 control_flow_data
->Drawing
->width
- x
, // do not overlap
861 control_flow_data
->Drawing
->height
+SAFETY
);
862 /* Get new data for the rest. */
863 drawing_data_request(control_flow_data
->Drawing
,
864 &control_flow_data
->Drawing
->Pixmap
,
866 control_flow_data
->Drawing
->width
- x
,
867 control_flow_data
->Drawing
->height
);
869 drawing_refresh(control_flow_data
->Drawing
,
871 control_flow_data
->Drawing
->width
,
872 control_flow_data
->Drawing
->height
);
877 //if(ns<os && os<ns+w)
878 //if(ns<os && os<new_end)
879 if(ltt_time_compare(*ns
,*os
) == -1
880 && ltt_time_compare(*os
,new_end
) == -1)
882 g_info("scrolling near left");
883 /* Scroll left, keep left part of the screen */
885 guint width
= control_flow_data
->Drawing
->Drawing_Area_V
->allocation
.width
;
886 convert_time_to_pixels(
893 /* Copy old data to new location */
894 gdk_draw_drawable (control_flow_data
->Drawing
->Pixmap
,
895 control_flow_data
->Drawing
->Drawing_Area_V
->style
->white_gc
,
896 control_flow_data
->Drawing
->Pixmap
,
901 *Old_Time_Window
= *New_Time_Window
;
903 /* Clean the data request background */
904 gdk_draw_rectangle (control_flow_data
->Drawing
->Pixmap
,
905 control_flow_data
->Drawing
->Drawing_Area_V
->style
->white_gc
,
909 control_flow_data
->Drawing
->height
+SAFETY
);
910 /* Get new data for the rest. */
911 drawing_data_request(control_flow_data
->Drawing
,
912 &control_flow_data
->Drawing
->Pixmap
,
915 control_flow_data
->Drawing
->height
);
917 drawing_refresh(control_flow_data
->Drawing
,
919 control_flow_data
->Drawing
->width
,
920 control_flow_data
->Drawing
->height
);
923 g_info("scrolling far");
924 /* Cannot reuse any part of the screen : far jump */
925 *Old_Time_Window
= *New_Time_Window
;
928 gdk_draw_rectangle (control_flow_data
->Drawing
->Pixmap
,
929 control_flow_data
->Drawing
->Drawing_Area_V
->style
->white_gc
,
932 control_flow_data
->Drawing
->width
+SAFETY
, // do not overlap
933 control_flow_data
->Drawing
->height
+SAFETY
);
935 drawing_data_request(control_flow_data
->Drawing
,
936 &control_flow_data
->Drawing
->Pixmap
,
938 control_flow_data
->Drawing
->width
,
939 control_flow_data
->Drawing
->height
);
941 drawing_refresh(control_flow_data
->Drawing
,
943 control_flow_data
->Drawing
->width
,
944 control_flow_data
->Drawing
->height
);
948 /* Different scale (zoom) */
951 *Old_Time_Window
= *New_Time_Window
;
953 gdk_draw_rectangle (control_flow_data
->Drawing
->Pixmap
,
954 control_flow_data
->Drawing
->Drawing_Area_V
->style
->white_gc
,
957 control_flow_data
->Drawing
->width
+SAFETY
, // do not overlap
958 control_flow_data
->Drawing
->height
+SAFETY
);
961 drawing_data_request(control_flow_data
->Drawing
,
962 &control_flow_data
->Drawing
->Pixmap
,
964 control_flow_data
->Drawing
->width
,
965 control_flow_data
->Drawing
->height
);
967 drawing_refresh(control_flow_data
->Drawing
,
969 control_flow_data
->Drawing
->width
,
970 control_flow_data
->Drawing
->height
);
976 void update_current_time_hook(void *hook_data
, void *call_data
)
978 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
979 LttTime
* Current_Time
=
980 guicontrolflow_get_current_time(Control_Flow_Data
);
981 *Current_Time
= *((LttTime
*)call_data
);
982 g_info("New Current time HOOK : %u, %u", Current_Time
->tv_sec
,
983 Current_Time
->tv_nsec
);
985 gtk_widget_queue_draw(Control_Flow_Data
->Drawing
->Drawing_Area_V
);
987 /* If current time is inside time interval, just move the highlight
990 /* Else, we have to change the time interval. We have to tell it
991 * to the main window. */
992 /* The time interval change will take care of placing the current
993 * time at the center of the visible area */
997 typedef struct _ClosureData
{
998 EventRequest
*event_request
;
1003 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1005 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
1006 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
1007 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1009 ControlFlowData
*control_flow_data
=
1010 closure_data
->event_request
->Control_Flow_Data
;
1012 GtkWidget
*widget
= control_flow_data
->Drawing
->Drawing_Area_V
;
1014 /* Get y position of process */
1017 processlist_get_pixels_from_data( control_flow_data
->Process_List
,
1019 hashed_process_data
,
1022 /* Get last state of process */
1023 LttvTraceContext
*tc
=
1024 (LttvTraceContext
*)closure_data
->ts
;
1026 LttvTraceState
*ts
= closure_data
->ts
;
1027 LttvProcessState
*process
;
1029 process
= lttv_state_find_process((LttvTracefileState
*)ts
, process_info
->pid
);
1031 /* Draw the closing line */
1032 DrawContext
*draw_context
= hashed_process_data
->draw_context
;
1033 if(draw_context
->Previous
->middle
->x
== -1)
1035 draw_context
->Previous
->middle
->x
= closure_data
->event_request
->x_begin
;
1036 g_critical("out middle x_beg : %u",closure_data
->event_request
->x_begin
);
1039 draw_context
->Current
->middle
->x
= closure_data
->event_request
->x_end
;
1040 draw_context
->Current
->middle
->y
= y
+ height
/2;
1041 draw_context
->Previous
->middle
->y
= y
+ height
/2;
1042 draw_context
->drawable
= control_flow_data
->Drawing
->Pixmap
;
1043 draw_context
->pango_layout
= control_flow_data
->Drawing
->pango_layout
;
1044 //draw_context->gc = widget->style->black_gc;
1045 draw_context
->gc
= gdk_gc_new(control_flow_data
->Drawing
->Pixmap
);
1046 gdk_gc_copy(draw_context
->gc
, widget
->style
->black_gc
);
1048 PropertiesLine prop_line
;
1049 prop_line
.color
= g_new(GdkColor
,1);
1050 prop_line
.line_width
= 6;
1051 prop_line
.style
= GDK_LINE_SOLID
;
1052 prop_line
.position
= MIDDLE
;
1054 /* color of line : status of the process */
1055 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
1057 prop_line
.color
->red
= 0x0000;
1058 prop_line
.color
->green
= 0x0000;
1059 prop_line
.color
->blue
= 0x0000;
1061 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
1063 prop_line
.color
->red
= 0x0fff;
1064 prop_line
.color
->green
= 0x0000;
1065 prop_line
.color
->blue
= 0x0fff;
1067 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
1069 prop_line
.color
->red
= 0x0fff;
1070 prop_line
.color
->green
= 0x0fff;
1071 prop_line
.color
->blue
= 0x0000;
1073 else if(process
->state
->s
== LTTV_STATE_EXIT
)
1075 prop_line
.color
->red
= 0xffff;
1076 prop_line
.color
->green
= 0x0000;
1077 prop_line
.color
->blue
= 0xffff;
1079 else if(process
->state
->s
== LTTV_STATE_WAIT
)
1081 prop_line
.color
->red
= 0xffff;
1082 prop_line
.color
->green
= 0x0000;
1083 prop_line
.color
->blue
= 0x0000;
1085 else if(process
->state
->s
== LTTV_STATE_RUN
)
1087 prop_line
.color
->red
= 0x0000;
1088 prop_line
.color
->green
= 0xffff;
1089 prop_line
.color
->blue
= 0x0000;
1093 prop_line
.color
->red
= 0x0000;
1094 prop_line
.color
->green
= 0x0000;
1095 prop_line
.color
->blue
= 0x0000;
1098 draw_line((void*)&prop_line
, (void*)draw_context
);
1099 g_free(prop_line
.color
);
1100 gdk_gc_unref(draw_context
->gc
);
1102 /* Reset draw_context of the process for next request */
1104 hashed_process_data
->draw_context
->drawable
= NULL
;
1105 hashed_process_data
->draw_context
->gc
= NULL
;
1106 hashed_process_data
->draw_context
->pango_layout
= NULL
;
1107 hashed_process_data
->draw_context
->Current
->over
->x
= -1;
1108 hashed_process_data
->draw_context
->Current
->over
->y
= -1;
1109 hashed_process_data
->draw_context
->Current
->middle
->x
= -1;
1110 hashed_process_data
->draw_context
->Current
->middle
->y
= -1;
1111 hashed_process_data
->draw_context
->Current
->under
->x
= -1;
1112 hashed_process_data
->draw_context
->Current
->under
->y
= -1;
1113 hashed_process_data
->draw_context
->Current
->modify_over
->x
= -1;
1114 hashed_process_data
->draw_context
->Current
->modify_over
->y
= -1;
1115 hashed_process_data
->draw_context
->Current
->modify_middle
->x
= -1;
1116 hashed_process_data
->draw_context
->Current
->modify_middle
->y
= -1;
1117 hashed_process_data
->draw_context
->Current
->modify_under
->x
= -1;
1118 hashed_process_data
->draw_context
->Current
->modify_under
->y
= -1;
1119 hashed_process_data
->draw_context
->Current
->status
= LTTV_STATE_UNNAMED
;
1120 hashed_process_data
->draw_context
->Previous
->over
->x
= -1;
1121 hashed_process_data
->draw_context
->Previous
->over
->y
= -1;
1122 hashed_process_data
->draw_context
->Previous
->middle
->x
= -1;
1123 hashed_process_data
->draw_context
->Previous
->middle
->y
= -1;
1124 hashed_process_data
->draw_context
->Previous
->under
->x
= -1;
1125 hashed_process_data
->draw_context
->Previous
->under
->y
= -1;
1126 hashed_process_data
->draw_context
->Previous
->modify_over
->x
= -1;
1127 hashed_process_data
->draw_context
->Previous
->modify_over
->y
= -1;
1128 hashed_process_data
->draw_context
->Previous
->modify_middle
->x
= -1;
1129 hashed_process_data
->draw_context
->Previous
->modify_middle
->y
= -1;
1130 hashed_process_data
->draw_context
->Previous
->modify_under
->x
= -1;
1131 hashed_process_data
->draw_context
->Previous
->modify_under
->y
= -1;
1132 hashed_process_data
->draw_context
->Previous
->status
= LTTV_STATE_UNNAMED
;
1140 * new default prev and current
1142 int after_data_request(void *hook_data
, void *call_data
)
1144 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
1145 ControlFlowData
*control_flow_data
= Event_Request
->Control_Flow_Data
;
1147 ProcessList
*process_list
=
1148 guicontrolflow_get_process_list(Event_Request
->Control_Flow_Data
);
1150 ClosureData closure_data
;
1151 closure_data
.event_request
= (EventRequest
*)hook_data
;
1152 closure_data
.ts
= (LttvTraceState
*)call_data
;
1154 g_hash_table_foreach(process_list
->Process_Hash
, draw_closure
,
1155 (void*)&closure_data
);