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 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
26 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
28 //#define PANGO_ENABLE_BACKEND
36 //#include <pango/pango.h>
38 #include <ltt/event.h>
42 #include <lttv/hook.h>
43 #include <lttv/common.h>
44 #include <lttv/state.h>
45 #include <lttv/gtktraceset.h>
48 #include "eventhooks.h"
50 #include "processlist.h"
52 #include "cfv-private.h"
55 #define MAX_PATH_LEN 256
59 * Event Viewer's constructor hook
61 * This constructor is given as a parameter to the menuitem and toolbar button
62 * registration. It creates the list.
63 * @param mw A pointer to the parent window.
64 * @return The widget created.
67 h_guicontrolflow(MainWindow
*mw
, LttvTracesetSelector
* s
, char * key
)
69 g_info("h_guicontrolflow, %p, %p, %s", mw
, s
, key
);
70 ControlFlowData
*control_flow_data
= guicontrolflow() ;
72 control_flow_data
->mw
= mw
;
73 TimeWindow
*time_window
= guicontrolflow_get_time_window(control_flow_data
);
74 time_window
->start_time
.tv_sec
= 0;
75 time_window
->start_time
.tv_nsec
= 0;
76 time_window
->time_width
.tv_sec
= 0;
77 time_window
->time_width
.tv_nsec
= 0;
79 LttTime
*current_time
= guicontrolflow_get_current_time(control_flow_data
);
80 current_time
->tv_sec
= 0;
81 current_time
->tv_nsec
= 0;
83 //g_critical("time width1 : %u",time_window->time_width);
90 //g_critical("time width2 : %u",time_window->time_width);
91 // Unreg done in the GuiControlFlow_Destructor
92 reg_update_time_window(update_time_window_hook
, control_flow_data
,
94 reg_update_current_time(update_current_time_hook
, control_flow_data
,
96 return guicontrolflow_get_widget(control_flow_data
) ;
100 int event_selected_hook(void *hook_data
, void *call_data
)
102 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
103 guint
*event_number
= (guint
*) call_data
;
105 g_critical("DEBUG : event selected by main window : %u", *event_number
);
107 // control_flow_data->currently_Selected_Event = *event_number;
108 // control_flow_data->Selected_Event = TRUE ;
110 // tree_v_set_cursor(control_flow_data);
114 /* Hook called before drawing. Gets the initial context at the beginning of the
115 * drawing interval and copy it to the context in event_request.
117 int draw_before_hook(void *hook_data
, void *call_data
)
119 EventRequest
*event_request
= (EventRequest
*)hook_data
;
120 //EventsContext Events_Context = (EventsContext*)call_data;
122 //event_request->Events_Context = Events_Context;
128 * The draw event hook is called by the reading API to have a
129 * particular event drawn on the screen.
130 * @param hook_data ControlFlowData structure of the viewer.
131 * @param call_data Event context.
133 * This function basically draw lines and icons. Two types of lines are drawn :
134 * one small (3 pixels?) representing the state of the process and the second
135 * type is thicker (10 pixels?) representing on which CPU a process is running
136 * (and this only in running state).
138 * Extremums of the lines :
139 * x_min : time of the last event context for this process kept in memory.
140 * x_max : time of the current event.
141 * y : middle of the process in the process list. The process is found in the
142 * list, therefore is it's position in pixels.
144 * The choice of lines'color is defined by the context of the last event for this
147 int draw_event_hook(void *hook_data
, void *call_data
)
149 EventRequest
*event_request
= (EventRequest
*)hook_data
;
150 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
152 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
154 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
160 LttTime evtime
= ltt_event_time(e
);
161 TimeWindow
*time_window
=
162 guicontrolflow_get_time_window(control_flow_data
);
164 LttTime end_time
= ltt_time_add(time_window
->start_time
,
165 time_window
->time_width
);
166 //if(time < time_beg || time > time_end) return;
167 if(ltt_time_compare(evtime
, time_window
->start_time
) == -1
168 || ltt_time_compare(evtime
, end_time
) == 1)
171 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
173 g_critical("schedchange!");
175 /* Add process to process list (if not present) and get drawing "y" from
176 * process position */
177 guint pid_out
, pid_in
;
178 LttvProcessState
*process_out
, *process_in
;
180 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
182 ProcessList
*process_list
=
183 guicontrolflow_get_process_list(event_request
->control_flow_data
);
186 LttField
*f
= ltt_event_field(e
);
188 element
= ltt_field_member(f
,0);
189 pid_out
= ltt_event_get_long_unsigned(e
,element
);
190 element
= ltt_field_member(f
,1);
191 pid_in
= ltt_event_get_long_unsigned(e
,element
);
192 g_critical("out : %u in : %u", pid_out
, pid_in
);
195 /* Find process pid_out in the list... */
196 process_out
= lttv_state_find_process(tfs
, pid_out
);
197 g_critical("out : %s",g_quark_to_string(process_out
->state
->s
));
199 birth
= process_out
->creation_time
;
200 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
201 HashedProcessData
*hashed_process_data_out
= NULL
;
203 if(processlist_get_process_pixels(process_list
,
208 &hashed_process_data_out
) == 1)
210 /* Process not present */
211 processlist_add(process_list
,
216 &hashed_process_data_out
);
217 processlist_get_process_pixels(process_list
,
222 &hashed_process_data_out
);
223 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
228 /* Find process pid_in in the list... */
229 process_in
= lttv_state_find_process(tfs
, pid_in
);
230 g_critical("in : %s",g_quark_to_string(process_in
->state
->s
));
232 birth
= process_in
->creation_time
;
233 name
= strdup(g_quark_to_string(process_in
->name
));
234 HashedProcessData
*hashed_process_data_in
= NULL
;
236 if(processlist_get_process_pixels(process_list
,
241 &hashed_process_data_in
) == 1)
243 /* Process not present */
244 processlist_add(process_list
,
249 &hashed_process_data_in
);
250 processlist_get_process_pixels(process_list
,
255 &hashed_process_data_in
);
257 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
262 /* Find pixels corresponding to time of the event. If the time does
263 * not fit in the window, show a warning, not supposed to happend. */
265 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
267 LttTime time
= ltt_event_time(e
);
269 LttTime window_end
= ltt_time_add(control_flow_data
->time_window
.time_width
,
270 control_flow_data
->time_window
.start_time
);
273 convert_time_to_pixels(
274 control_flow_data
->time_window
.start_time
,
279 //assert(x <= width);
281 /* draw what represents the event for outgoing process. */
283 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
284 draw_context_out
->current
->modify_over
->x
= x
;
285 draw_context_out
->current
->modify_under
->x
= x
;
286 draw_context_out
->current
->modify_over
->y
= y_out
;
287 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
288 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
289 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
290 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
291 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
292 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
293 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
294 //draw_context_out->gc = widget->style->black_gc;
296 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
297 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
299 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
300 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
301 PropertiesText prop_text_out
;
302 prop_text_out
.foreground
= &colorfg_out
;
303 prop_text_out
.background
= &colorbg_out
;
304 prop_text_out
.size
= 6;
305 prop_text_out
.position
= OVER
;
307 /* color of text : status of the process */
308 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
310 prop_text_out
.foreground
->red
= 0xffff;
311 prop_text_out
.foreground
->green
= 0xffff;
312 prop_text_out
.foreground
->blue
= 0xffff;
314 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
316 prop_text_out
.foreground
->red
= 0x0fff;
317 prop_text_out
.foreground
->green
= 0xffff;
318 prop_text_out
.foreground
->blue
= 0xfff0;
320 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
322 prop_text_out
.foreground
->red
= 0xffff;
323 prop_text_out
.foreground
->green
= 0xffff;
324 prop_text_out
.foreground
->blue
= 0x0000;
326 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
328 prop_text_out
.foreground
->red
= 0xffff;
329 prop_text_out
.foreground
->green
= 0x0000;
330 prop_text_out
.foreground
->blue
= 0xffff;
332 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
334 prop_text_out
.foreground
->red
= 0xffff;
335 prop_text_out
.foreground
->green
= 0x0000;
336 prop_text_out
.foreground
->blue
= 0x0000;
338 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
340 prop_text_out
.foreground
->red
= 0x0000;
341 prop_text_out
.foreground
->green
= 0xffff;
342 prop_text_out
.foreground
->blue
= 0x0000;
346 prop_text_out
.foreground
->red
= 0xffff;
347 prop_text_out
.foreground
->green
= 0xffff;
348 prop_text_out
.foreground
->blue
= 0xffff;
352 /* Print status of the process : U, WF, WC, E, W, R */
353 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
354 prop_text_out
.text
= "U->";
355 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
356 prop_text_out
.text
= "WF->";
357 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
358 prop_text_out
.text
= "WC->";
359 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
360 prop_text_out
.text
= "E->";
361 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
362 prop_text_out
.text
= "W->";
363 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
364 prop_text_out
.text
= "R->";
366 prop_text_out
.text
= "U";
368 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
369 gdk_gc_unref(draw_context_out
->gc
);
371 /* Draw the line of the out process */
372 if(draw_context_out
->previous
->middle
->x
== -1)
374 draw_context_out
->previous
->middle
->x
= event_request
->x_begin
;
375 g_critical("out middle x_beg : %u",event_request
->x_begin
);
378 draw_context_out
->current
->middle
->x
= x
;
379 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
380 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
381 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
382 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
383 //draw_context_out->gc = widget->style->black_gc;
384 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
385 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
387 PropertiesLine prop_line_out
;
388 prop_line_out
.color
= g_new(GdkColor
,1);
389 prop_line_out
.line_width
= 2;
390 prop_line_out
.style
= GDK_LINE_SOLID
;
391 prop_line_out
.position
= MIDDLE
;
393 g_critical("out state : %s", g_quark_to_string(process_out
->state
->s
));
395 /* color of line : status of the process */
396 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
398 prop_line_out
.color
->red
= 0xffff;
399 prop_line_out
.color
->green
= 0xffff;
400 prop_line_out
.color
->blue
= 0xffff;
402 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
404 prop_line_out
.color
->red
= 0x0fff;
405 prop_line_out
.color
->green
= 0xffff;
406 prop_line_out
.color
->blue
= 0xfff0;
408 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
410 prop_line_out
.color
->red
= 0xffff;
411 prop_line_out
.color
->green
= 0xffff;
412 prop_line_out
.color
->blue
= 0x0000;
414 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
416 prop_line_out
.color
->red
= 0xffff;
417 prop_line_out
.color
->green
= 0x0000;
418 prop_line_out
.color
->blue
= 0xffff;
420 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
422 prop_line_out
.color
->red
= 0xffff;
423 prop_line_out
.color
->green
= 0x0000;
424 prop_line_out
.color
->blue
= 0x0000;
426 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
428 prop_line_out
.color
->red
= 0x0000;
429 prop_line_out
.color
->green
= 0xffff;
430 prop_line_out
.color
->blue
= 0x0000;
434 prop_line_out
.color
->red
= 0xffff;
435 prop_line_out
.color
->green
= 0xffff;
436 prop_line_out
.color
->blue
= 0xffff;
439 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
440 g_free(prop_line_out
.color
);
441 gdk_gc_unref(draw_context_out
->gc
);
442 /* Note : finishing line will have to be added when trace read over. */
444 /* Finally, update the drawing context of the pid_in. */
446 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
447 draw_context_in
->current
->modify_over
->x
= x
;
448 draw_context_in
->current
->modify_under
->x
= x
;
449 draw_context_in
->current
->modify_over
->y
= y_in
;
450 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
451 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
452 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
453 widget
= control_flow_data
->drawing
->drawing_area
;
454 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
455 //draw_context_in->gc = widget->style->black_gc;
456 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
457 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
459 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
460 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
462 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
463 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
464 PropertiesText prop_text_in
;
465 prop_text_in
.foreground
= &colorfg_in
;
466 prop_text_in
.background
= &colorbg_in
;
467 prop_text_in
.size
= 6;
468 prop_text_in
.position
= OVER
;
470 g_critical("in state : %s", g_quark_to_string(process_in
->state
->s
));
471 /* foreground of text : status of the process */
472 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
474 prop_text_in
.foreground
->red
= 0xffff;
475 prop_text_in
.foreground
->green
= 0xffff;
476 prop_text_in
.foreground
->blue
= 0xffff;
478 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
480 prop_text_in
.foreground
->red
= 0x0fff;
481 prop_text_in
.foreground
->green
= 0xffff;
482 prop_text_in
.foreground
->blue
= 0xfff0;
484 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
486 prop_text_in
.foreground
->red
= 0xffff;
487 prop_text_in
.foreground
->green
= 0xffff;
488 prop_text_in
.foreground
->blue
= 0x0000;
490 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
492 prop_text_in
.foreground
->red
= 0xffff;
493 prop_text_in
.foreground
->green
= 0x0000;
494 prop_text_in
.foreground
->blue
= 0xffff;
496 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
498 prop_text_in
.foreground
->red
= 0xffff;
499 prop_text_in
.foreground
->green
= 0x0000;
500 prop_text_in
.foreground
->blue
= 0x0000;
502 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
504 prop_text_in
.foreground
->red
= 0x0000;
505 prop_text_in
.foreground
->green
= 0xffff;
506 prop_text_in
.foreground
->blue
= 0x0000;
510 prop_text_in
.foreground
->red
= 0xffff;
511 prop_text_in
.foreground
->green
= 0xffff;
512 prop_text_in
.foreground
->blue
= 0xffff;
517 /* Print status of the process : U, WF, WC, E, W, R */
518 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
519 prop_text_in
.text
= "U->";
520 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
521 prop_text_in
.text
= "WF->";
522 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
523 prop_text_in
.text
= "WC->";
524 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
525 prop_text_in
.text
= "E->";
526 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
527 prop_text_in
.text
= "W->";
528 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
529 prop_text_in
.text
= "R->";
531 prop_text_in
.text
= "U";
533 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
534 gdk_gc_unref(draw_context_in
->gc
);
536 /* Draw the line of the in process */
537 if(draw_context_in
->previous
->middle
->x
== -1)
539 draw_context_in
->previous
->middle
->x
= event_request
->x_begin
;
540 g_critical("in middle x_beg : %u",event_request
->x_begin
);
543 draw_context_in
->current
->middle
->x
= x
;
544 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
545 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
546 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
547 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
548 //draw_context_in->gc = widget->style->black_gc;
549 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
550 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
552 PropertiesLine prop_line_in
;
553 prop_line_in
.color
= g_new(GdkColor
,1);
554 prop_line_in
.line_width
= 2;
555 prop_line_in
.style
= GDK_LINE_SOLID
;
556 prop_line_in
.position
= MIDDLE
;
558 /* color of line : status of the process */
559 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
561 prop_line_in
.color
->red
= 0xffff;
562 prop_line_in
.color
->green
= 0xffff;
563 prop_line_in
.color
->blue
= 0xffff;
565 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
567 prop_line_in
.color
->red
= 0x0fff;
568 prop_line_in
.color
->green
= 0xffff;
569 prop_line_in
.color
->blue
= 0xfff0;
571 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
573 prop_line_in
.color
->red
= 0xffff;
574 prop_line_in
.color
->green
= 0xffff;
575 prop_line_in
.color
->blue
= 0x0000;
577 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
579 prop_line_in
.color
->red
= 0xffff;
580 prop_line_in
.color
->green
= 0x0000;
581 prop_line_in
.color
->blue
= 0xffff;
583 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
585 prop_line_in
.color
->red
= 0xffff;
586 prop_line_in
.color
->green
= 0x0000;
587 prop_line_in
.color
->blue
= 0x0000;
589 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
591 prop_line_in
.color
->red
= 0x0000;
592 prop_line_in
.color
->green
= 0xffff;
593 prop_line_in
.color
->blue
= 0x0000;
597 prop_line_in
.color
->red
= 0xffff;
598 prop_line_in
.color
->green
= 0xffff;
599 prop_line_in
.color
->blue
= 0xffff;
602 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
603 g_free(prop_line_in
.color
);
604 gdk_gc_unref(draw_context_in
->gc
);
611 GString
*string
= g_string_new("");;
612 gboolean field_names
= TRUE
, state
= TRUE
;
614 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
615 g_string_append_printf(string
,"\n");
618 g_string_append_printf(string
, " %s",
619 g_quark_to_string(tfs
->process
->state
->s
));
622 g_info("%s",string
->str
);
624 g_string_free(string
, TRUE
);
626 /* End of text dump */
632 int draw_after_hook(void *hook_data
, void *call_data
)
634 EventRequest
*event_request
= (EventRequest
*)hook_data
;
635 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
637 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
639 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
645 LttTime evtime
= ltt_event_time(e
);
646 TimeWindow
*time_window
=
647 guicontrolflow_get_time_window(control_flow_data
);
649 LttTime end_time
= ltt_time_add(time_window
->start_time
,
650 time_window
->time_width
);
651 //if(time < time_beg || time > time_end) return;
652 if(ltt_time_compare(evtime
, time_window
->start_time
) == -1
653 || ltt_time_compare(evtime
, end_time
) == 1)
657 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
659 g_critical("schedchange!");
661 /* Add process to process list (if not present) and get drawing "y" from
662 * process position */
663 guint pid_out
, pid_in
;
664 LttvProcessState
*process_out
, *process_in
;
666 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
668 ProcessList
*process_list
=
669 guicontrolflow_get_process_list(event_request
->control_flow_data
);
672 LttField
*f
= ltt_event_field(e
);
674 element
= ltt_field_member(f
,0);
675 pid_out
= ltt_event_get_long_unsigned(e
,element
);
676 element
= ltt_field_member(f
,1);
677 pid_in
= ltt_event_get_long_unsigned(e
,element
);
678 //g_critical("out : %u in : %u", pid_out, pid_in);
681 /* Find process pid_out in the list... */
682 process_out
= lttv_state_find_process(tfs
, pid_out
);
683 //g_critical("out : %s",g_quark_to_string(process_out->state->s));
685 birth
= process_out
->creation_time
;
686 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
687 HashedProcessData
*hashed_process_data_out
= NULL
;
689 if(processlist_get_process_pixels(process_list
,
694 &hashed_process_data_out
) == 1)
696 /* Process not present */
697 processlist_add(process_list
,
702 &hashed_process_data_out
);
703 processlist_get_process_pixels(process_list
,
708 &hashed_process_data_out
);
709 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
714 /* Find process pid_in in the list... */
715 process_in
= lttv_state_find_process(tfs
, pid_in
);
716 //g_critical("in : %s",g_quark_to_string(process_in->state->s));
718 birth
= process_in
->creation_time
;
719 name
= strdup(g_quark_to_string(process_in
->name
));
720 HashedProcessData
*hashed_process_data_in
= NULL
;
722 if(processlist_get_process_pixels(process_list
,
727 &hashed_process_data_in
) == 1)
729 /* Process not present */
730 processlist_add(process_list
,
735 &hashed_process_data_in
);
736 processlist_get_process_pixels(process_list
,
741 &hashed_process_data_in
);
743 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
748 /* Find pixels corresponding to time of the event. If the time does
749 * not fit in the window, show a warning, not supposed to happend. */
751 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
753 //LttTime time = ltt_event_time(e);
755 //LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
756 // control_flow_data->time_window.start_time);
759 //convert_time_to_pixels(
760 // control_flow_data->time_window.start_time,
766 //assert(x <= width);
768 /* draw what represents the event for outgoing process. */
770 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
771 //draw_context_out->current->modify_over->x = x;
772 draw_context_out
->current
->modify_over
->y
= y_out
;
773 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
774 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
775 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
776 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
777 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
778 draw_context_out
->gc
= widget
->style
->black_gc
;
780 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
781 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
783 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
784 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
785 PropertiesText prop_text_out
;
786 prop_text_out
.foreground
= &colorfg_out
;
787 prop_text_out
.background
= &colorbg_out
;
788 prop_text_out
.size
= 6;
789 prop_text_out
.position
= OVER
;
791 /* color of text : status of the process */
792 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
794 prop_text_out
.foreground
->red
= 0xffff;
795 prop_text_out
.foreground
->green
= 0xffff;
796 prop_text_out
.foreground
->blue
= 0xffff;
798 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
800 prop_text_out
.foreground
->red
= 0x0fff;
801 prop_text_out
.foreground
->green
= 0xffff;
802 prop_text_out
.foreground
->blue
= 0xfff0;
804 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
806 prop_text_out
.foreground
->red
= 0xffff;
807 prop_text_out
.foreground
->green
= 0xffff;
808 prop_text_out
.foreground
->blue
= 0x0000;
810 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
812 prop_text_out
.foreground
->red
= 0xffff;
813 prop_text_out
.foreground
->green
= 0x0000;
814 prop_text_out
.foreground
->blue
= 0xffff;
816 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
818 prop_text_out
.foreground
->red
= 0xffff;
819 prop_text_out
.foreground
->green
= 0x0000;
820 prop_text_out
.foreground
->blue
= 0x0000;
822 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
824 prop_text_out
.foreground
->red
= 0x0000;
825 prop_text_out
.foreground
->green
= 0xffff;
826 prop_text_out
.foreground
->blue
= 0x0000;
830 prop_text_out
.foreground
->red
= 0xffff;
831 prop_text_out
.foreground
->green
= 0xffff;
832 prop_text_out
.foreground
->blue
= 0xffff;
835 /* Print status of the process : U, WF, WC, E, W, R */
836 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
837 prop_text_out
.text
= "U";
838 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
839 prop_text_out
.text
= "WF";
840 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
841 prop_text_out
.text
= "WC";
842 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
843 prop_text_out
.text
= "E";
844 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
845 prop_text_out
.text
= "W";
846 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
847 prop_text_out
.text
= "R";
849 prop_text_out
.text
= "U";
851 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
853 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
854 draw_context_out
->current
->status
= process_out
->state
->s
;
856 /* for pid_out : remove previous, Prev = current, new current (default) */
857 g_free(draw_context_out
->previous
->modify_under
);
858 g_free(draw_context_out
->previous
->modify_middle
);
859 g_free(draw_context_out
->previous
->modify_over
);
860 g_free(draw_context_out
->previous
->under
);
861 g_free(draw_context_out
->previous
->middle
);
862 g_free(draw_context_out
->previous
->over
);
863 g_free(draw_context_out
->previous
);
865 draw_context_out
->previous
= draw_context_out
->current
;
867 draw_context_out
->current
= g_new(DrawInfo
,1);
868 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
869 draw_context_out
->current
->over
->x
= -1;
870 draw_context_out
->current
->over
->y
= -1;
871 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
872 draw_context_out
->current
->middle
->x
= -1;
873 draw_context_out
->current
->middle
->y
= -1;
874 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
875 draw_context_out
->current
->under
->x
= -1;
876 draw_context_out
->current
->under
->y
= -1;
877 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
878 draw_context_out
->current
->modify_over
->x
= -1;
879 draw_context_out
->current
->modify_over
->y
= -1;
880 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
881 draw_context_out
->current
->modify_middle
->x
= -1;
882 draw_context_out
->current
->modify_middle
->y
= -1;
883 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
884 draw_context_out
->current
->modify_under
->x
= -1;
885 draw_context_out
->current
->modify_under
->y
= -1;
886 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
888 /* Finally, update the drawing context of the pid_in. */
890 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
891 //draw_context_in->current->modify_over->x = x;
892 draw_context_in
->current
->modify_over
->y
= y_in
;
893 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
894 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
895 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
896 widget
= control_flow_data
->drawing
->drawing_area
;
897 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
898 draw_context_in
->gc
= widget
->style
->black_gc
;
900 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
901 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
903 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
904 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
905 PropertiesText prop_text_in
;
906 prop_text_in
.foreground
= &colorfg_in
;
907 prop_text_in
.background
= &colorbg_in
;
908 prop_text_in
.size
= 6;
909 prop_text_in
.position
= OVER
;
911 /* foreground of text : status of the process */
912 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
914 prop_text_in
.foreground
->red
= 0xffff;
915 prop_text_in
.foreground
->green
= 0xffff;
916 prop_text_in
.foreground
->blue
= 0xffff;
918 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
920 prop_text_in
.foreground
->red
= 0x0fff;
921 prop_text_in
.foreground
->green
= 0xffff;
922 prop_text_in
.foreground
->blue
= 0xfff0;
924 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
926 prop_text_in
.foreground
->red
= 0xffff;
927 prop_text_in
.foreground
->green
= 0xffff;
928 prop_text_in
.foreground
->blue
= 0x0000;
930 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
932 prop_text_in
.foreground
->red
= 0xffff;
933 prop_text_in
.foreground
->green
= 0x0000;
934 prop_text_in
.foreground
->blue
= 0xffff;
936 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
938 prop_text_in
.foreground
->red
= 0xffff;
939 prop_text_in
.foreground
->green
= 0x0000;
940 prop_text_in
.foreground
->blue
= 0x0000;
942 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
944 prop_text_in
.foreground
->red
= 0x0000;
945 prop_text_in
.foreground
->green
= 0xffff;
946 prop_text_in
.foreground
->blue
= 0x0000;
950 prop_text_in
.foreground
->red
= 0xffff;
951 prop_text_in
.foreground
->green
= 0xffff;
952 prop_text_in
.foreground
->blue
= 0xffff;
956 /* Print status of the process : U, WF, WC, E, W, R */
957 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
958 prop_text_in
.text
= "U";
959 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
960 prop_text_in
.text
= "WF";
961 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
962 prop_text_in
.text
= "WC";
963 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
964 prop_text_in
.text
= "E";
965 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
966 prop_text_in
.text
= "W";
967 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
968 prop_text_in
.text
= "R";
970 prop_text_in
.text
= "U";
972 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
974 if(process_in
->state
->s
== LTTV_STATE_RUN
)
977 prop_text_in
.foreground
= &colorfg_in
;
978 prop_text_in
.background
= &colorbg_in
;
979 prop_text_in
.foreground
->red
= 0xffff;
980 prop_text_in
.foreground
->green
= 0xffff;
981 prop_text_in
.foreground
->blue
= 0xffff;
982 prop_text_in
.size
= 6;
983 prop_text_in
.position
= UNDER
;
985 prop_text_in
.text
= g_new(gchar
, 260);
986 strcpy(prop_text_in
.text
, "CPU ");
987 snprintf(tmp
, 255, "%u", tfc
->index
);
988 strcat(prop_text_in
.text
, tmp
);
990 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
991 g_free(prop_text_in
.text
);
995 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
996 draw_context_in
->current
->status
= process_in
->state
->s
;
998 /* for pid_in : remove previous, Prev = current, new current (default) */
999 g_free(draw_context_in
->previous
->modify_under
);
1000 g_free(draw_context_in
->previous
->modify_middle
);
1001 g_free(draw_context_in
->previous
->modify_over
);
1002 g_free(draw_context_in
->previous
->under
);
1003 g_free(draw_context_in
->previous
->middle
);
1004 g_free(draw_context_in
->previous
->over
);
1005 g_free(draw_context_in
->previous
);
1007 draw_context_in
->previous
= draw_context_in
->current
;
1009 draw_context_in
->current
= g_new(DrawInfo
,1);
1010 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1011 draw_context_in
->current
->over
->x
= -1;
1012 draw_context_in
->current
->over
->y
= -1;
1013 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1014 draw_context_in
->current
->middle
->x
= -1;
1015 draw_context_in
->current
->middle
->y
= -1;
1016 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1017 draw_context_in
->current
->under
->x
= -1;
1018 draw_context_in
->current
->under
->y
= -1;
1019 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1020 draw_context_in
->current
->modify_over
->x
= -1;
1021 draw_context_in
->current
->modify_over
->y
= -1;
1022 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1023 draw_context_in
->current
->modify_middle
->x
= -1;
1024 draw_context_in
->current
->modify_middle
->y
= -1;
1025 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1026 draw_context_in
->current
->modify_under
->x
= -1;
1027 draw_context_in
->current
->modify_under
->y
= -1;
1028 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1038 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1040 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1041 TimeWindow
*old_time_window
=
1042 guicontrolflow_get_time_window(control_flow_data
);
1043 TimeWindow
*new_time_window
= ((TimeWindow
*)call_data
);
1045 /* Update the ruler */
1046 drawing_update_ruler(control_flow_data
->drawing
,
1050 /* Two cases : zoom in/out or scrolling */
1052 /* In order to make sure we can reuse the old drawing, the scale must
1053 * be the same and the new time interval being partly located in the
1054 * currently shown time interval. (reuse is only for scrolling)
1057 g_info("Old time window HOOK : %u, %u to %u, %u",
1058 old_time_window
->start_time
.tv_sec
,
1059 old_time_window
->start_time
.tv_nsec
,
1060 old_time_window
->time_width
.tv_sec
,
1061 old_time_window
->time_width
.tv_nsec
);
1063 g_info("New time window HOOK : %u, %u to %u, %u",
1064 new_time_window
->start_time
.tv_sec
,
1065 new_time_window
->start_time
.tv_nsec
,
1066 new_time_window
->time_width
.tv_sec
,
1067 new_time_window
->time_width
.tv_nsec
);
1069 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1070 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1072 /* Same scale (scrolling) */
1073 g_info("scrolling");
1074 LttTime
*ns
= &new_time_window
->start_time
;
1075 LttTime
*os
= &old_time_window
->start_time
;
1076 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
1077 old_time_window
->time_width
);
1078 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
1079 new_time_window
->time_width
);
1081 //if(ns<os+w && os+w<ns+w)
1082 //if(ns<old_end && os<ns)
1083 if(ltt_time_compare(*ns
, old_end
) == -1
1084 && ltt_time_compare(*os
, *ns
) == -1)
1086 g_info("scrolling near right");
1087 /* Scroll right, keep right part of the screen */
1089 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1090 convert_time_to_pixels(
1097 /* Copy old data to new location */
1098 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1099 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1100 control_flow_data
->drawing
->pixmap
,
1105 convert_time_to_pixels(
1112 *old_time_window
= *new_time_window
;
1113 /* Clear the data request background, but not SAFETY */
1114 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1115 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1118 control_flow_data
->drawing
->width
- x
, // do not overlap
1119 control_flow_data
->drawing
->height
+SAFETY
);
1120 /* Get new data for the rest. */
1121 drawing_data_request(control_flow_data
->drawing
,
1122 &control_flow_data
->drawing
->pixmap
,
1124 control_flow_data
->drawing
->width
- x
,
1125 control_flow_data
->drawing
->height
);
1127 drawing_refresh(control_flow_data
->drawing
,
1129 control_flow_data
->drawing
->width
,
1130 control_flow_data
->drawing
->height
);
1135 //if(ns<os && os<ns+w)
1136 //if(ns<os && os<new_end)
1137 if(ltt_time_compare(*ns
,*os
) == -1
1138 && ltt_time_compare(*os
,new_end
) == -1)
1140 g_info("scrolling near left");
1141 /* Scroll left, keep left part of the screen */
1143 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1144 convert_time_to_pixels(
1151 /* Copy old data to new location */
1152 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1153 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1154 control_flow_data
->drawing
->pixmap
,
1159 *old_time_window
= *new_time_window
;
1161 /* Clean the data request background */
1162 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1163 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1166 x
, // do not overlap
1167 control_flow_data
->drawing
->height
+SAFETY
);
1168 /* Get new data for the rest. */
1169 drawing_data_request(control_flow_data
->drawing
,
1170 &control_flow_data
->drawing
->pixmap
,
1173 control_flow_data
->drawing
->height
);
1175 drawing_refresh(control_flow_data
->drawing
,
1177 control_flow_data
->drawing
->width
,
1178 control_flow_data
->drawing
->height
);
1181 g_info("scrolling far");
1182 /* Cannot reuse any part of the screen : far jump */
1183 *old_time_window
= *new_time_window
;
1186 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1187 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1190 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1191 control_flow_data
->drawing
->height
+SAFETY
);
1193 drawing_data_request(control_flow_data
->drawing
,
1194 &control_flow_data
->drawing
->pixmap
,
1196 control_flow_data
->drawing
->width
,
1197 control_flow_data
->drawing
->height
);
1199 drawing_refresh(control_flow_data
->drawing
,
1201 control_flow_data
->drawing
->width
,
1202 control_flow_data
->drawing
->height
);
1206 /* Different scale (zoom) */
1209 *old_time_window
= *new_time_window
;
1211 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1212 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1215 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1216 control_flow_data
->drawing
->height
+SAFETY
);
1219 drawing_data_request(control_flow_data
->drawing
,
1220 &control_flow_data
->drawing
->pixmap
,
1222 control_flow_data
->drawing
->width
,
1223 control_flow_data
->drawing
->height
);
1225 drawing_refresh(control_flow_data
->drawing
,
1227 control_flow_data
->drawing
->width
,
1228 control_flow_data
->drawing
->height
);
1236 gint
update_current_time_hook(void *hook_data
, void *call_data
)
1238 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
1240 LttTime
* current_time
=
1241 guicontrolflow_get_current_time(control_flow_data
);
1242 *current_time
= *((LttTime
*)call_data
);
1244 TimeWindow time_window
;
1246 LttTime time_begin
= control_flow_data
->time_window
.start_time
;
1247 LttTime width
= control_flow_data
->time_window
.time_width
;
1248 LttTime half_width
= ltt_time_div(width
,2.0);
1249 LttTime time_end
= ltt_time_add(time_begin
, width
);
1251 LttvTracesetContext
* tsc
=
1252 get_traceset_context(control_flow_data
->mw
);
1254 LttTime trace_start
= tsc
->Time_Span
->startTime
;
1255 LttTime trace_end
= tsc
->Time_Span
->endTime
;
1257 g_info("New current time HOOK : %u, %u", current_time
->tv_sec
,
1258 current_time
->tv_nsec
);
1262 /* If current time is inside time interval, just move the highlight
1265 /* Else, we have to change the time interval. We have to tell it
1266 * to the main window. */
1267 /* The time interval change will take care of placing the current
1268 * time at the center of the visible area, or nearest possible if we are
1269 * at one end of the trace. */
1272 if(ltt_time_compare(*current_time
, time_begin
) == -1)
1274 if(ltt_time_compare(*current_time
,
1275 ltt_time_add(trace_start
,half_width
)) == -1)
1276 time_begin
= trace_start
;
1278 time_begin
= ltt_time_sub(*current_time
,half_width
);
1280 time_window
.start_time
= time_begin
;
1281 time_window
.time_width
= width
;
1283 set_time_window(control_flow_data
->mw
, &time_window
);
1285 else if(ltt_time_compare(*current_time
, time_end
) == 1)
1287 if(ltt_time_compare(*current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
1288 time_begin
= ltt_time_sub(trace_end
,width
);
1290 time_begin
= ltt_time_sub(*current_time
,half_width
);
1292 time_window
.start_time
= time_begin
;
1293 time_window
.time_width
= width
;
1295 set_time_window(control_flow_data
->mw
, &time_window
);
1298 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
1303 typedef struct _ClosureData
{
1304 EventRequest
*event_request
;
1309 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1311 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
1312 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
1313 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1315 ControlFlowData
*control_flow_data
=
1316 closure_data
->event_request
->control_flow_data
;
1318 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1320 /* Get y position of process */
1323 processlist_get_pixels_from_data( control_flow_data
->process_list
,
1325 hashed_process_data
,
1328 /* Get last state of process */
1329 LttvTraceContext
*tc
=
1330 (LttvTraceContext
*)closure_data
->ts
;
1332 LttvTraceState
*ts
= closure_data
->ts
;
1333 LttvProcessState
*process
;
1335 process
= lttv_state_find_process((LttvTracefileState
*)ts
, process_info
->pid
);
1337 /* Draw the closing line */
1338 DrawContext
*draw_context
= hashed_process_data
->draw_context
;
1339 if(draw_context
->previous
->middle
->x
== -1)
1341 draw_context
->previous
->middle
->x
= closure_data
->event_request
->x_begin
;
1342 g_critical("out middle x_beg : %u",closure_data
->event_request
->x_begin
);
1345 draw_context
->current
->middle
->x
= closure_data
->event_request
->x_end
;
1346 draw_context
->current
->middle
->y
= y
+ height
/2;
1347 draw_context
->previous
->middle
->y
= y
+ height
/2;
1348 draw_context
->drawable
= control_flow_data
->drawing
->pixmap
;
1349 draw_context
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1350 //draw_context->gc = widget->style->black_gc;
1351 draw_context
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
1352 gdk_gc_copy(draw_context
->gc
, widget
->style
->black_gc
);
1354 PropertiesLine prop_line
;
1355 prop_line
.color
= g_new(GdkColor
,1);
1356 prop_line
.line_width
= 2;
1357 prop_line
.style
= GDK_LINE_SOLID
;
1358 prop_line
.position
= MIDDLE
;
1360 /* color of line : status of the process */
1361 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
1363 prop_line
.color
->red
= 0xffff;
1364 prop_line
.color
->green
= 0xffff;
1365 prop_line
.color
->blue
= 0xffff;
1367 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
1369 prop_line
.color
->red
= 0x0fff;
1370 prop_line
.color
->green
= 0xffff;
1371 prop_line
.color
->blue
= 0xfff0;
1373 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
1375 prop_line
.color
->red
= 0xffff;
1376 prop_line
.color
->green
= 0xffff;
1377 prop_line
.color
->blue
= 0x0000;
1379 else if(process
->state
->s
== LTTV_STATE_EXIT
)
1381 prop_line
.color
->red
= 0xffff;
1382 prop_line
.color
->green
= 0x0000;
1383 prop_line
.color
->blue
= 0xffff;
1385 else if(process
->state
->s
== LTTV_STATE_WAIT
)
1387 prop_line
.color
->red
= 0xffff;
1388 prop_line
.color
->green
= 0x0000;
1389 prop_line
.color
->blue
= 0x0000;
1391 else if(process
->state
->s
== LTTV_STATE_RUN
)
1393 prop_line
.color
->red
= 0x0000;
1394 prop_line
.color
->green
= 0xffff;
1395 prop_line
.color
->blue
= 0x0000;
1399 prop_line
.color
->red
= 0xffff;
1400 prop_line
.color
->green
= 0xffff;
1401 prop_line
.color
->blue
= 0xffff;
1404 draw_line((void*)&prop_line
, (void*)draw_context
);
1405 g_free(prop_line
.color
);
1406 gdk_gc_unref(draw_context
->gc
);
1408 /* Reset draw_context of the process for next request */
1410 hashed_process_data
->draw_context
->drawable
= NULL
;
1411 hashed_process_data
->draw_context
->gc
= NULL
;
1412 hashed_process_data
->draw_context
->pango_layout
= NULL
;
1413 hashed_process_data
->draw_context
->current
->over
->x
= -1;
1414 hashed_process_data
->draw_context
->current
->over
->y
= -1;
1415 hashed_process_data
->draw_context
->current
->middle
->x
= -1;
1416 hashed_process_data
->draw_context
->current
->middle
->y
= -1;
1417 hashed_process_data
->draw_context
->current
->under
->x
= -1;
1418 hashed_process_data
->draw_context
->current
->under
->y
= -1;
1419 hashed_process_data
->draw_context
->current
->modify_over
->x
= -1;
1420 hashed_process_data
->draw_context
->current
->modify_over
->y
= -1;
1421 hashed_process_data
->draw_context
->current
->modify_middle
->x
= -1;
1422 hashed_process_data
->draw_context
->current
->modify_middle
->y
= -1;
1423 hashed_process_data
->draw_context
->current
->modify_under
->x
= -1;
1424 hashed_process_data
->draw_context
->current
->modify_under
->y
= -1;
1425 hashed_process_data
->draw_context
->current
->status
= LTTV_STATE_UNNAMED
;
1426 hashed_process_data
->draw_context
->previous
->over
->x
= -1;
1427 hashed_process_data
->draw_context
->previous
->over
->y
= -1;
1428 hashed_process_data
->draw_context
->previous
->middle
->x
= -1;
1429 hashed_process_data
->draw_context
->previous
->middle
->y
= -1;
1430 hashed_process_data
->draw_context
->previous
->under
->x
= -1;
1431 hashed_process_data
->draw_context
->previous
->under
->y
= -1;
1432 hashed_process_data
->draw_context
->previous
->modify_over
->x
= -1;
1433 hashed_process_data
->draw_context
->previous
->modify_over
->y
= -1;
1434 hashed_process_data
->draw_context
->previous
->modify_middle
->x
= -1;
1435 hashed_process_data
->draw_context
->previous
->modify_middle
->y
= -1;
1436 hashed_process_data
->draw_context
->previous
->modify_under
->x
= -1;
1437 hashed_process_data
->draw_context
->previous
->modify_under
->y
= -1;
1438 hashed_process_data
->draw_context
->previous
->status
= LTTV_STATE_UNNAMED
;
1446 * new default prev and current
1448 int after_data_request(void *hook_data
, void *call_data
)
1450 EventRequest
*event_request
= (EventRequest
*)hook_data
;
1451 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
1453 ProcessList
*process_list
=
1454 guicontrolflow_get_process_list(event_request
->control_flow_data
);
1456 ClosureData closure_data
;
1457 closure_data
.event_request
= (EventRequest
*)hook_data
;
1458 closure_data
.ts
= (LttvTraceState
*)call_data
;
1460 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
1461 (void*)&closure_data
);