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 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
162 g_critical("schedchange!");
164 /* Add process to process list (if not present) and get drawing "y" from
165 * process position */
166 guint pid_out
, pid_in
;
167 LttvProcessState
*process_out
, *process_in
;
169 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
171 ProcessList
*process_list
=
172 guicontrolflow_get_process_list(event_request
->control_flow_data
);
175 LttField
*f
= ltt_event_field(e
);
177 element
= ltt_field_member(f
,0);
178 pid_out
= ltt_event_get_long_unsigned(e
,element
);
179 element
= ltt_field_member(f
,1);
180 pid_in
= ltt_event_get_long_unsigned(e
,element
);
181 g_critical("out : %u in : %u", pid_out
, pid_in
);
184 /* Find process pid_out in the list... */
185 process_out
= lttv_state_find_process(tfs
, pid_out
);
186 g_critical("out : %s",g_quark_to_string(process_out
->state
->s
));
188 birth
= process_out
->creation_time
;
189 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
190 HashedProcessData
*hashed_process_data_out
= NULL
;
192 if(processlist_get_process_pixels(process_list
,
197 &hashed_process_data_out
) == 1)
199 /* Process not present */
200 processlist_add(process_list
,
205 &hashed_process_data_out
);
206 processlist_get_process_pixels(process_list
,
211 &hashed_process_data_out
);
212 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
217 /* Find process pid_in in the list... */
218 process_in
= lttv_state_find_process(tfs
, pid_in
);
219 g_critical("in : %s",g_quark_to_string(process_in
->state
->s
));
221 birth
= process_in
->creation_time
;
222 name
= strdup(g_quark_to_string(process_in
->name
));
223 HashedProcessData
*hashed_process_data_in
= NULL
;
225 if(processlist_get_process_pixels(process_list
,
230 &hashed_process_data_in
) == 1)
232 /* Process not present */
233 processlist_add(process_list
,
238 &hashed_process_data_in
);
239 processlist_get_process_pixels(process_list
,
244 &hashed_process_data_in
);
246 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
251 /* Find pixels corresponding to time of the event. If the time does
252 * not fit in the window, show a warning, not supposed to happend. */
254 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
256 LttTime time
= ltt_event_time(e
);
258 LttTime window_end
= ltt_time_add(control_flow_data
->time_window
.time_width
,
259 control_flow_data
->time_window
.start_time
);
262 convert_time_to_pixels(
263 control_flow_data
->time_window
.start_time
,
271 /* draw what represents the event for outgoing process. */
273 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
274 draw_context_out
->current
->modify_over
->x
= x
;
275 draw_context_out
->current
->modify_under
->x
= x
;
276 draw_context_out
->current
->modify_over
->y
= y_out
;
277 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
278 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
279 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
280 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
281 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
282 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
283 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
284 //draw_context_out->gc = widget->style->black_gc;
286 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
287 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
289 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
290 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
291 PropertiesText prop_text_out
;
292 prop_text_out
.foreground
= &colorfg_out
;
293 prop_text_out
.background
= &colorbg_out
;
294 prop_text_out
.size
= 6;
295 prop_text_out
.position
= OVER
;
297 /* color of text : status of the process */
298 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
300 prop_text_out
.foreground
->red
= 0xffff;
301 prop_text_out
.foreground
->green
= 0xffff;
302 prop_text_out
.foreground
->blue
= 0xffff;
304 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
306 prop_text_out
.foreground
->red
= 0x0fff;
307 prop_text_out
.foreground
->green
= 0x0000;
308 prop_text_out
.foreground
->blue
= 0x0fff;
310 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
312 prop_text_out
.foreground
->red
= 0xffff;
313 prop_text_out
.foreground
->green
= 0xffff;
314 prop_text_out
.foreground
->blue
= 0x0000;
316 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
318 prop_text_out
.foreground
->red
= 0xffff;
319 prop_text_out
.foreground
->green
= 0x0000;
320 prop_text_out
.foreground
->blue
= 0xffff;
322 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
324 prop_text_out
.foreground
->red
= 0xffff;
325 prop_text_out
.foreground
->green
= 0x0000;
326 prop_text_out
.foreground
->blue
= 0x0000;
328 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
330 prop_text_out
.foreground
->red
= 0x0000;
331 prop_text_out
.foreground
->green
= 0xffff;
332 prop_text_out
.foreground
->blue
= 0x0000;
336 prop_text_out
.foreground
->red
= 0xffff;
337 prop_text_out
.foreground
->green
= 0xffff;
338 prop_text_out
.foreground
->blue
= 0xffff;
341 /* Print status of the process : U, WF, WC, E, W, R */
342 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
343 prop_text_out
.text
= "U->";
344 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
345 prop_text_out
.text
= "WF->";
346 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
347 prop_text_out
.text
= "WC->";
348 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
349 prop_text_out
.text
= "E->";
350 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
351 prop_text_out
.text
= "W->";
352 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
353 prop_text_out
.text
= "R->";
355 prop_text_out
.text
= "U";
357 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
358 gdk_gc_unref(draw_context_out
->gc
);
360 /* Draw the line of the out process */
361 if(draw_context_out
->previous
->middle
->x
== -1)
363 draw_context_out
->previous
->middle
->x
= event_request
->x_begin
;
364 g_critical("out middle x_beg : %u",event_request
->x_begin
);
367 draw_context_out
->current
->middle
->x
= x
;
368 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
369 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
370 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
371 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
372 //draw_context_out->gc = widget->style->black_gc;
373 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
374 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
376 PropertiesLine prop_line_out
;
377 prop_line_out
.color
= g_new(GdkColor
,1);
378 prop_line_out
.line_width
= 2;
379 prop_line_out
.style
= GDK_LINE_SOLID
;
380 prop_line_out
.position
= MIDDLE
;
382 /* color of line : status of the process */
383 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
385 prop_line_out
.color
->red
= 0xffff;
386 prop_line_out
.color
->green
= 0xffff;
387 prop_line_out
.color
->blue
= 0xffff;
389 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
391 prop_line_out
.color
->red
= 0x0fff;
392 prop_line_out
.color
->green
= 0x0000;
393 prop_line_out
.color
->blue
= 0x0fff;
395 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
397 prop_line_out
.color
->red
= 0xffff;
398 prop_line_out
.color
->green
= 0xffff;
399 prop_line_out
.color
->blue
= 0x0000;
401 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
403 prop_line_out
.color
->red
= 0xffff;
404 prop_line_out
.color
->green
= 0x0000;
405 prop_line_out
.color
->blue
= 0xffff;
407 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
409 prop_line_out
.color
->red
= 0xffff;
410 prop_line_out
.color
->green
= 0x0000;
411 prop_line_out
.color
->blue
= 0x0000;
413 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
415 prop_line_out
.color
->red
= 0x0000;
416 prop_line_out
.color
->green
= 0xffff;
417 prop_line_out
.color
->blue
= 0x0000;
421 prop_line_out
.color
->red
= 0xffff;
422 prop_line_out
.color
->green
= 0xffff;
423 prop_line_out
.color
->blue
= 0xffff;
426 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
427 g_free(prop_line_out
.color
);
428 gdk_gc_unref(draw_context_out
->gc
);
429 /* Note : finishing line will have to be added when trace read over. */
431 /* Finally, update the drawing context of the pid_in. */
433 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
434 draw_context_in
->current
->modify_over
->x
= x
;
435 draw_context_in
->current
->modify_under
->x
= x
;
436 draw_context_in
->current
->modify_over
->y
= y_in
;
437 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
438 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
439 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
440 widget
= control_flow_data
->drawing
->drawing_area
;
441 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
442 //draw_context_in->gc = widget->style->black_gc;
443 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
444 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
446 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
447 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
449 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
450 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
451 PropertiesText prop_text_in
;
452 prop_text_in
.foreground
= &colorfg_in
;
453 prop_text_in
.background
= &colorbg_in
;
454 prop_text_in
.size
= 6;
455 prop_text_in
.position
= OVER
;
457 /* foreground of text : status of the process */
458 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
460 prop_text_in
.foreground
->red
= 0xffff;
461 prop_text_in
.foreground
->green
= 0xffff;
462 prop_text_in
.foreground
->blue
= 0xffff;
464 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
466 prop_text_in
.foreground
->red
= 0x0fff;
467 prop_text_in
.foreground
->green
= 0x0000;
468 prop_text_in
.foreground
->blue
= 0x0fff;
470 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
472 prop_text_in
.foreground
->red
= 0xffff;
473 prop_text_in
.foreground
->green
= 0xffff;
474 prop_text_in
.foreground
->blue
= 0x0000;
476 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
478 prop_text_in
.foreground
->red
= 0xffff;
479 prop_text_in
.foreground
->green
= 0x0000;
480 prop_text_in
.foreground
->blue
= 0xffff;
482 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
484 prop_text_in
.foreground
->red
= 0xffff;
485 prop_text_in
.foreground
->green
= 0x0000;
486 prop_text_in
.foreground
->blue
= 0x0000;
488 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
490 prop_text_in
.foreground
->red
= 0x0000;
491 prop_text_in
.foreground
->green
= 0xffff;
492 prop_text_in
.foreground
->blue
= 0x0000;
496 prop_text_in
.foreground
->red
= 0xffff;
497 prop_text_in
.foreground
->green
= 0xffff;
498 prop_text_in
.foreground
->blue
= 0xffff;
503 /* Print status of the process : U, WF, WC, E, W, R */
504 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
505 prop_text_in
.text
= "U->";
506 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
507 prop_text_in
.text
= "WF->";
508 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
509 prop_text_in
.text
= "WC->";
510 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
511 prop_text_in
.text
= "E->";
512 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
513 prop_text_in
.text
= "W->";
514 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
515 prop_text_in
.text
= "R->";
517 prop_text_in
.text
= "U";
519 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
520 gdk_gc_unref(draw_context_in
->gc
);
522 /* Draw the line of the in process */
523 if(draw_context_in
->previous
->middle
->x
== -1)
525 draw_context_in
->previous
->middle
->x
= event_request
->x_begin
;
526 g_critical("in middle x_beg : %u",event_request
->x_begin
);
529 draw_context_in
->current
->middle
->x
= x
;
530 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
531 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
532 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
533 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
534 //draw_context_in->gc = widget->style->black_gc;
535 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
536 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
538 PropertiesLine prop_line_in
;
539 prop_line_in
.color
= g_new(GdkColor
,1);
540 prop_line_in
.line_width
= 2;
541 prop_line_in
.style
= GDK_LINE_SOLID
;
542 prop_line_in
.position
= MIDDLE
;
544 /* color of line : status of the process */
545 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
547 prop_line_in
.color
->red
= 0xffff;
548 prop_line_in
.color
->green
= 0xffff;
549 prop_line_in
.color
->blue
= 0xffff;
551 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
553 prop_line_in
.color
->red
= 0x0fff;
554 prop_line_in
.color
->green
= 0x0000;
555 prop_line_in
.color
->blue
= 0x0fff;
557 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
559 prop_line_in
.color
->red
= 0xffff;
560 prop_line_in
.color
->green
= 0xffff;
561 prop_line_in
.color
->blue
= 0x0000;
563 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
565 prop_line_in
.color
->red
= 0xffff;
566 prop_line_in
.color
->green
= 0x0000;
567 prop_line_in
.color
->blue
= 0xffff;
569 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
571 prop_line_in
.color
->red
= 0xffff;
572 prop_line_in
.color
->green
= 0x0000;
573 prop_line_in
.color
->blue
= 0x0000;
575 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
577 prop_line_in
.color
->red
= 0x0000;
578 prop_line_in
.color
->green
= 0xffff;
579 prop_line_in
.color
->blue
= 0x0000;
583 prop_line_in
.color
->red
= 0xffff;
584 prop_line_in
.color
->green
= 0xffff;
585 prop_line_in
.color
->blue
= 0xffff;
588 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
589 g_free(prop_line_in
.color
);
590 gdk_gc_unref(draw_context_in
->gc
);
597 GString
*string
= g_string_new("");;
598 gboolean field_names
= TRUE
, state
= TRUE
;
600 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
601 g_string_append_printf(string
,"\n");
604 g_string_append_printf(string
, " %s",
605 g_quark_to_string(tfs
->process
->state
->s
));
608 g_info("%s",string
->str
);
610 g_string_free(string
, TRUE
);
612 /* End of text dump */
618 int draw_after_hook(void *hook_data
, void *call_data
)
620 EventRequest
*event_request
= (EventRequest
*)hook_data
;
621 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
623 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
625 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
631 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
633 g_critical("schedchange!");
635 /* Add process to process list (if not present) and get drawing "y" from
636 * process position */
637 guint pid_out
, pid_in
;
638 LttvProcessState
*process_out
, *process_in
;
640 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
642 ProcessList
*process_list
=
643 guicontrolflow_get_process_list(event_request
->control_flow_data
);
646 LttField
*f
= ltt_event_field(e
);
648 element
= ltt_field_member(f
,0);
649 pid_out
= ltt_event_get_long_unsigned(e
,element
);
650 element
= ltt_field_member(f
,1);
651 pid_in
= ltt_event_get_long_unsigned(e
,element
);
652 //g_critical("out : %u in : %u", pid_out, pid_in);
655 /* Find process pid_out in the list... */
656 process_out
= lttv_state_find_process(tfs
, pid_out
);
657 //g_critical("out : %s",g_quark_to_string(process_out->state->s));
659 birth
= process_out
->creation_time
;
660 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
661 HashedProcessData
*hashed_process_data_out
= NULL
;
663 if(processlist_get_process_pixels(process_list
,
668 &hashed_process_data_out
) == 1)
670 /* Process not present */
671 processlist_add(process_list
,
676 &hashed_process_data_out
);
677 processlist_get_process_pixels(process_list
,
682 &hashed_process_data_out
);
683 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
688 /* Find process pid_in in the list... */
689 process_in
= lttv_state_find_process(tfs
, pid_in
);
690 //g_critical("in : %s",g_quark_to_string(process_in->state->s));
692 birth
= process_in
->creation_time
;
693 name
= strdup(g_quark_to_string(process_in
->name
));
694 HashedProcessData
*hashed_process_data_in
= NULL
;
696 if(processlist_get_process_pixels(process_list
,
701 &hashed_process_data_in
) == 1)
703 /* Process not present */
704 processlist_add(process_list
,
709 &hashed_process_data_in
);
710 processlist_get_process_pixels(process_list
,
715 &hashed_process_data_in
);
717 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
722 /* Find pixels corresponding to time of the event. If the time does
723 * not fit in the window, show a warning, not supposed to happend. */
725 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
727 //LttTime time = ltt_event_time(e);
729 //LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
730 // control_flow_data->time_window.start_time);
733 //convert_time_to_pixels(
734 // control_flow_data->time_window.start_time,
740 //assert(x <= width);
742 /* draw what represents the event for outgoing process. */
744 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
745 //draw_context_out->current->modify_over->x = x;
746 draw_context_out
->current
->modify_over
->y
= y_out
;
747 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
748 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
749 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
750 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
751 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
752 draw_context_out
->gc
= widget
->style
->black_gc
;
754 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
755 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
757 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
758 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
759 PropertiesText prop_text_out
;
760 prop_text_out
.foreground
= &colorfg_out
;
761 prop_text_out
.background
= &colorbg_out
;
762 prop_text_out
.size
= 6;
763 prop_text_out
.position
= OVER
;
765 /* color of text : status of the process */
766 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
768 prop_text_out
.foreground
->red
= 0xffff;
769 prop_text_out
.foreground
->green
= 0xffff;
770 prop_text_out
.foreground
->blue
= 0xffff;
772 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
774 prop_text_out
.foreground
->red
= 0x0fff;
775 prop_text_out
.foreground
->green
= 0x0000;
776 prop_text_out
.foreground
->blue
= 0x0fff;
778 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
780 prop_text_out
.foreground
->red
= 0xffff;
781 prop_text_out
.foreground
->green
= 0xffff;
782 prop_text_out
.foreground
->blue
= 0x0000;
784 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
786 prop_text_out
.foreground
->red
= 0xffff;
787 prop_text_out
.foreground
->green
= 0x0000;
788 prop_text_out
.foreground
->blue
= 0xffff;
790 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
792 prop_text_out
.foreground
->red
= 0xffff;
793 prop_text_out
.foreground
->green
= 0x0000;
794 prop_text_out
.foreground
->blue
= 0x0000;
796 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
798 prop_text_out
.foreground
->red
= 0x0000;
799 prop_text_out
.foreground
->green
= 0xffff;
800 prop_text_out
.foreground
->blue
= 0x0000;
804 prop_text_out
.foreground
->red
= 0xffff;
805 prop_text_out
.foreground
->green
= 0xffff;
806 prop_text_out
.foreground
->blue
= 0xffff;
809 /* Print status of the process : U, WF, WC, E, W, R */
810 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
811 prop_text_out
.text
= "U";
812 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
813 prop_text_out
.text
= "WF";
814 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
815 prop_text_out
.text
= "WC";
816 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
817 prop_text_out
.text
= "E";
818 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
819 prop_text_out
.text
= "W";
820 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
821 prop_text_out
.text
= "R";
823 prop_text_out
.text
= "U";
825 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
827 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
828 draw_context_out
->current
->status
= process_out
->state
->s
;
830 /* for pid_out : remove previous, Prev = current, new current (default) */
831 g_free(draw_context_out
->previous
->modify_under
);
832 g_free(draw_context_out
->previous
->modify_middle
);
833 g_free(draw_context_out
->previous
->modify_over
);
834 g_free(draw_context_out
->previous
->under
);
835 g_free(draw_context_out
->previous
->middle
);
836 g_free(draw_context_out
->previous
->over
);
837 g_free(draw_context_out
->previous
);
839 draw_context_out
->previous
= draw_context_out
->current
;
841 draw_context_out
->current
= g_new(DrawInfo
,1);
842 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
843 draw_context_out
->current
->over
->x
= -1;
844 draw_context_out
->current
->over
->y
= -1;
845 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
846 draw_context_out
->current
->middle
->x
= -1;
847 draw_context_out
->current
->middle
->y
= -1;
848 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
849 draw_context_out
->current
->under
->x
= -1;
850 draw_context_out
->current
->under
->y
= -1;
851 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
852 draw_context_out
->current
->modify_over
->x
= -1;
853 draw_context_out
->current
->modify_over
->y
= -1;
854 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
855 draw_context_out
->current
->modify_middle
->x
= -1;
856 draw_context_out
->current
->modify_middle
->y
= -1;
857 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
858 draw_context_out
->current
->modify_under
->x
= -1;
859 draw_context_out
->current
->modify_under
->y
= -1;
860 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
862 /* Finally, update the drawing context of the pid_in. */
864 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
865 //draw_context_in->current->modify_over->x = x;
866 draw_context_in
->current
->modify_over
->y
= y_in
;
867 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
868 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
869 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
870 widget
= control_flow_data
->drawing
->drawing_area
;
871 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
872 draw_context_in
->gc
= widget
->style
->black_gc
;
874 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
875 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
877 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
878 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
879 PropertiesText prop_text_in
;
880 prop_text_in
.foreground
= &colorfg_in
;
881 prop_text_in
.background
= &colorbg_in
;
882 prop_text_in
.size
= 6;
883 prop_text_in
.position
= OVER
;
885 /* foreground of text : status of the process */
886 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
888 prop_text_in
.foreground
->red
= 0xffff;
889 prop_text_in
.foreground
->green
= 0xffff;
890 prop_text_in
.foreground
->blue
= 0xffff;
892 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
894 prop_text_in
.foreground
->red
= 0x0fff;
895 prop_text_in
.foreground
->green
= 0x0000;
896 prop_text_in
.foreground
->blue
= 0x0fff;
898 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
900 prop_text_in
.foreground
->red
= 0xffff;
901 prop_text_in
.foreground
->green
= 0xffff;
902 prop_text_in
.foreground
->blue
= 0x0000;
904 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
906 prop_text_in
.foreground
->red
= 0xffff;
907 prop_text_in
.foreground
->green
= 0x0000;
908 prop_text_in
.foreground
->blue
= 0xffff;
910 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
912 prop_text_in
.foreground
->red
= 0xffff;
913 prop_text_in
.foreground
->green
= 0x0000;
914 prop_text_in
.foreground
->blue
= 0x0000;
916 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
918 prop_text_in
.foreground
->red
= 0x0000;
919 prop_text_in
.foreground
->green
= 0xffff;
920 prop_text_in
.foreground
->blue
= 0x0000;
924 prop_text_in
.foreground
->red
= 0xffff;
925 prop_text_in
.foreground
->green
= 0xffff;
926 prop_text_in
.foreground
->blue
= 0xffff;
930 /* Print status of the process : U, WF, WC, E, W, R */
931 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
932 prop_text_in
.text
= "U";
933 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
934 prop_text_in
.text
= "WF";
935 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
936 prop_text_in
.text
= "WC";
937 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
938 prop_text_in
.text
= "E";
939 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
940 prop_text_in
.text
= "W";
941 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
942 prop_text_in
.text
= "R";
944 prop_text_in
.text
= "U";
946 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
948 if(process_in
->state
->s
== LTTV_STATE_RUN
)
951 prop_text_in
.foreground
= &colorfg_in
;
952 prop_text_in
.background
= &colorbg_in
;
953 prop_text_in
.foreground
->red
= 0xffff;
954 prop_text_in
.foreground
->green
= 0xffff;
955 prop_text_in
.foreground
->blue
= 0xffff;
956 prop_text_in
.size
= 6;
957 prop_text_in
.position
= UNDER
;
959 prop_text_in
.text
= g_new(gchar
, 260);
960 strcpy(prop_text_in
.text
, "CPU ");
961 snprintf(tmp
, 255, "%u", tfc
->index
);
962 strcat(prop_text_in
.text
, tmp
);
964 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
965 g_free(prop_text_in
.text
);
969 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
970 draw_context_in
->current
->status
= process_in
->state
->s
;
972 /* for pid_in : remove previous, Prev = current, new current (default) */
973 g_free(draw_context_in
->previous
->modify_under
);
974 g_free(draw_context_in
->previous
->modify_middle
);
975 g_free(draw_context_in
->previous
->modify_over
);
976 g_free(draw_context_in
->previous
->under
);
977 g_free(draw_context_in
->previous
->middle
);
978 g_free(draw_context_in
->previous
->over
);
979 g_free(draw_context_in
->previous
);
981 draw_context_in
->previous
= draw_context_in
->current
;
983 draw_context_in
->current
= g_new(DrawInfo
,1);
984 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
985 draw_context_in
->current
->over
->x
= -1;
986 draw_context_in
->current
->over
->y
= -1;
987 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
988 draw_context_in
->current
->middle
->x
= -1;
989 draw_context_in
->current
->middle
->y
= -1;
990 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
991 draw_context_in
->current
->under
->x
= -1;
992 draw_context_in
->current
->under
->y
= -1;
993 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
994 draw_context_in
->current
->modify_over
->x
= -1;
995 draw_context_in
->current
->modify_over
->y
= -1;
996 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
997 draw_context_in
->current
->modify_middle
->x
= -1;
998 draw_context_in
->current
->modify_middle
->y
= -1;
999 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1000 draw_context_in
->current
->modify_under
->x
= -1;
1001 draw_context_in
->current
->modify_under
->y
= -1;
1002 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1012 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1014 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1015 TimeWindow
*old_time_window
=
1016 guicontrolflow_get_time_window(control_flow_data
);
1017 TimeWindow
*new_time_window
= ((TimeWindow
*)call_data
);
1019 /* Two cases : zoom in/out or scrolling */
1021 /* In order to make sure we can reuse the old drawing, the scale must
1022 * be the same and the new time interval being partly located in the
1023 * currently shown time interval. (reuse is only for scrolling)
1026 g_info("Old time window HOOK : %u, %u to %u, %u",
1027 old_time_window
->start_time
.tv_sec
,
1028 old_time_window
->start_time
.tv_nsec
,
1029 old_time_window
->time_width
.tv_sec
,
1030 old_time_window
->time_width
.tv_nsec
);
1032 g_info("New time window HOOK : %u, %u to %u, %u",
1033 new_time_window
->start_time
.tv_sec
,
1034 new_time_window
->start_time
.tv_nsec
,
1035 new_time_window
->time_width
.tv_sec
,
1036 new_time_window
->time_width
.tv_nsec
);
1038 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1039 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1041 /* Same scale (scrolling) */
1042 g_info("scrolling");
1043 LttTime
*ns
= &new_time_window
->start_time
;
1044 LttTime
*os
= &old_time_window
->start_time
;
1045 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
1046 old_time_window
->time_width
);
1047 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
1048 new_time_window
->time_width
);
1050 //if(ns<os+w && os+w<ns+w)
1051 //if(ns<old_end && os<ns)
1052 if(ltt_time_compare(*ns
, old_end
) == -1
1053 && ltt_time_compare(*os
, *ns
) == -1)
1055 g_info("scrolling near right");
1056 /* Scroll right, keep right part of the screen */
1058 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1059 convert_time_to_pixels(
1066 /* Copy old data to new location */
1067 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1068 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1069 control_flow_data
->drawing
->pixmap
,
1074 convert_time_to_pixels(
1081 *old_time_window
= *new_time_window
;
1082 /* Clear the data request background, but not SAFETY */
1083 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1084 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1087 control_flow_data
->drawing
->width
- x
, // do not overlap
1088 control_flow_data
->drawing
->height
+SAFETY
);
1089 /* Get new data for the rest. */
1090 drawing_data_request(control_flow_data
->drawing
,
1091 &control_flow_data
->drawing
->pixmap
,
1093 control_flow_data
->drawing
->width
- x
,
1094 control_flow_data
->drawing
->height
);
1096 drawing_refresh(control_flow_data
->drawing
,
1098 control_flow_data
->drawing
->width
,
1099 control_flow_data
->drawing
->height
);
1104 //if(ns<os && os<ns+w)
1105 //if(ns<os && os<new_end)
1106 if(ltt_time_compare(*ns
,*os
) == -1
1107 && ltt_time_compare(*os
,new_end
) == -1)
1109 g_info("scrolling near left");
1110 /* Scroll left, keep left part of the screen */
1112 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1113 convert_time_to_pixels(
1120 /* Copy old data to new location */
1121 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1122 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1123 control_flow_data
->drawing
->pixmap
,
1128 *old_time_window
= *new_time_window
;
1130 /* Clean the data request background */
1131 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1132 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1135 x
, // do not overlap
1136 control_flow_data
->drawing
->height
+SAFETY
);
1137 /* Get new data for the rest. */
1138 drawing_data_request(control_flow_data
->drawing
,
1139 &control_flow_data
->drawing
->pixmap
,
1142 control_flow_data
->drawing
->height
);
1144 drawing_refresh(control_flow_data
->drawing
,
1146 control_flow_data
->drawing
->width
,
1147 control_flow_data
->drawing
->height
);
1150 g_info("scrolling far");
1151 /* Cannot reuse any part of the screen : far jump */
1152 *old_time_window
= *new_time_window
;
1155 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1156 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1159 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1160 control_flow_data
->drawing
->height
+SAFETY
);
1162 drawing_data_request(control_flow_data
->drawing
,
1163 &control_flow_data
->drawing
->pixmap
,
1165 control_flow_data
->drawing
->width
,
1166 control_flow_data
->drawing
->height
);
1168 drawing_refresh(control_flow_data
->drawing
,
1170 control_flow_data
->drawing
->width
,
1171 control_flow_data
->drawing
->height
);
1175 /* Different scale (zoom) */
1178 *old_time_window
= *new_time_window
;
1180 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1181 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1184 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1185 control_flow_data
->drawing
->height
+SAFETY
);
1188 drawing_data_request(control_flow_data
->drawing
,
1189 &control_flow_data
->drawing
->pixmap
,
1191 control_flow_data
->drawing
->width
,
1192 control_flow_data
->drawing
->height
);
1194 drawing_refresh(control_flow_data
->drawing
,
1196 control_flow_data
->drawing
->width
,
1197 control_flow_data
->drawing
->height
);
1203 gint
update_current_time_hook(void *hook_data
, void *call_data
)
1205 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
1207 LttTime
* current_time
=
1208 guicontrolflow_get_current_time(control_flow_data
);
1209 *current_time
= *((LttTime
*)call_data
);
1211 TimeWindow time_window
;
1213 LttTime time_begin
= control_flow_data
->time_window
.start_time
;
1214 LttTime width
= control_flow_data
->time_window
.time_width
;
1215 LttTime half_width
= ltt_time_div(width
,2.0);
1216 LttTime time_end
= ltt_time_add(time_begin
, width
);
1218 LttvTracesetContext
* tsc
=
1219 get_traceset_context(control_flow_data
->mw
);
1221 LttTime trace_start
= tsc
->Time_Span
->startTime
;
1222 LttTime trace_end
= tsc
->Time_Span
->endTime
;
1224 g_info("New current time HOOK : %u, %u", current_time
->tv_sec
,
1225 current_time
->tv_nsec
);
1229 /* If current time is inside time interval, just move the highlight
1232 /* Else, we have to change the time interval. We have to tell it
1233 * to the main window. */
1234 /* The time interval change will take care of placing the current
1235 * time at the center of the visible area, or nearest possible if we are
1236 * at one end of the trace. */
1239 if(ltt_time_compare(*current_time
, time_begin
) == -1)
1241 if(ltt_time_compare(*current_time
,
1242 ltt_time_add(trace_start
,half_width
)) == -1)
1243 time_begin
= trace_start
;
1245 time_begin
= ltt_time_sub(*current_time
,half_width
);
1247 time_window
.start_time
= time_begin
;
1248 time_window
.time_width
= width
;
1250 set_time_window(control_flow_data
->mw
, &time_window
);
1252 else if(ltt_time_compare(*current_time
, time_end
) == 1)
1254 if(ltt_time_compare(*current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
1255 time_begin
= ltt_time_sub(trace_end
,width
);
1257 time_begin
= ltt_time_sub(*current_time
,half_width
);
1259 time_window
.start_time
= time_begin
;
1260 time_window
.time_width
= width
;
1262 set_time_window(control_flow_data
->mw
, &time_window
);
1265 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
1270 typedef struct _ClosureData
{
1271 EventRequest
*event_request
;
1276 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1278 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
1279 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
1280 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1282 ControlFlowData
*control_flow_data
=
1283 closure_data
->event_request
->control_flow_data
;
1285 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1287 /* Get y position of process */
1290 processlist_get_pixels_from_data( control_flow_data
->process_list
,
1292 hashed_process_data
,
1295 /* Get last state of process */
1296 LttvTraceContext
*tc
=
1297 (LttvTraceContext
*)closure_data
->ts
;
1299 LttvTraceState
*ts
= closure_data
->ts
;
1300 LttvProcessState
*process
;
1302 process
= lttv_state_find_process((LttvTracefileState
*)ts
, process_info
->pid
);
1304 /* Draw the closing line */
1305 DrawContext
*draw_context
= hashed_process_data
->draw_context
;
1306 if(draw_context
->previous
->middle
->x
== -1)
1308 draw_context
->previous
->middle
->x
= closure_data
->event_request
->x_begin
;
1309 g_critical("out middle x_beg : %u",closure_data
->event_request
->x_begin
);
1312 draw_context
->current
->middle
->x
= closure_data
->event_request
->x_end
;
1313 draw_context
->current
->middle
->y
= y
+ height
/2;
1314 draw_context
->previous
->middle
->y
= y
+ height
/2;
1315 draw_context
->drawable
= control_flow_data
->drawing
->pixmap
;
1316 draw_context
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1317 //draw_context->gc = widget->style->black_gc;
1318 draw_context
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
1319 gdk_gc_copy(draw_context
->gc
, widget
->style
->black_gc
);
1321 PropertiesLine prop_line
;
1322 prop_line
.color
= g_new(GdkColor
,1);
1323 prop_line
.line_width
= 2;
1324 prop_line
.style
= GDK_LINE_SOLID
;
1325 prop_line
.position
= MIDDLE
;
1327 /* color of line : status of the process */
1328 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
1330 prop_line
.color
->red
= 0xffff;
1331 prop_line
.color
->green
= 0xffff;
1332 prop_line
.color
->blue
= 0xffff;
1334 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
1336 prop_line
.color
->red
= 0x0fff;
1337 prop_line
.color
->green
= 0x0000;
1338 prop_line
.color
->blue
= 0x0fff;
1340 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
1342 prop_line
.color
->red
= 0xffff;
1343 prop_line
.color
->green
= 0xffff;
1344 prop_line
.color
->blue
= 0x0000;
1346 else if(process
->state
->s
== LTTV_STATE_EXIT
)
1348 prop_line
.color
->red
= 0xffff;
1349 prop_line
.color
->green
= 0x0000;
1350 prop_line
.color
->blue
= 0xffff;
1352 else if(process
->state
->s
== LTTV_STATE_WAIT
)
1354 prop_line
.color
->red
= 0xffff;
1355 prop_line
.color
->green
= 0x0000;
1356 prop_line
.color
->blue
= 0x0000;
1358 else if(process
->state
->s
== LTTV_STATE_RUN
)
1360 prop_line
.color
->red
= 0x0000;
1361 prop_line
.color
->green
= 0xffff;
1362 prop_line
.color
->blue
= 0x0000;
1366 prop_line
.color
->red
= 0xffff;
1367 prop_line
.color
->green
= 0xffff;
1368 prop_line
.color
->blue
= 0xffff;
1371 draw_line((void*)&prop_line
, (void*)draw_context
);
1372 g_free(prop_line
.color
);
1373 gdk_gc_unref(draw_context
->gc
);
1375 /* Reset draw_context of the process for next request */
1377 hashed_process_data
->draw_context
->drawable
= NULL
;
1378 hashed_process_data
->draw_context
->gc
= NULL
;
1379 hashed_process_data
->draw_context
->pango_layout
= NULL
;
1380 hashed_process_data
->draw_context
->current
->over
->x
= -1;
1381 hashed_process_data
->draw_context
->current
->over
->y
= -1;
1382 hashed_process_data
->draw_context
->current
->middle
->x
= -1;
1383 hashed_process_data
->draw_context
->current
->middle
->y
= -1;
1384 hashed_process_data
->draw_context
->current
->under
->x
= -1;
1385 hashed_process_data
->draw_context
->current
->under
->y
= -1;
1386 hashed_process_data
->draw_context
->current
->modify_over
->x
= -1;
1387 hashed_process_data
->draw_context
->current
->modify_over
->y
= -1;
1388 hashed_process_data
->draw_context
->current
->modify_middle
->x
= -1;
1389 hashed_process_data
->draw_context
->current
->modify_middle
->y
= -1;
1390 hashed_process_data
->draw_context
->current
->modify_under
->x
= -1;
1391 hashed_process_data
->draw_context
->current
->modify_under
->y
= -1;
1392 hashed_process_data
->draw_context
->current
->status
= LTTV_STATE_UNNAMED
;
1393 hashed_process_data
->draw_context
->previous
->over
->x
= -1;
1394 hashed_process_data
->draw_context
->previous
->over
->y
= -1;
1395 hashed_process_data
->draw_context
->previous
->middle
->x
= -1;
1396 hashed_process_data
->draw_context
->previous
->middle
->y
= -1;
1397 hashed_process_data
->draw_context
->previous
->under
->x
= -1;
1398 hashed_process_data
->draw_context
->previous
->under
->y
= -1;
1399 hashed_process_data
->draw_context
->previous
->modify_over
->x
= -1;
1400 hashed_process_data
->draw_context
->previous
->modify_over
->y
= -1;
1401 hashed_process_data
->draw_context
->previous
->modify_middle
->x
= -1;
1402 hashed_process_data
->draw_context
->previous
->modify_middle
->y
= -1;
1403 hashed_process_data
->draw_context
->previous
->modify_under
->x
= -1;
1404 hashed_process_data
->draw_context
->previous
->modify_under
->y
= -1;
1405 hashed_process_data
->draw_context
->previous
->status
= LTTV_STATE_UNNAMED
;
1413 * new default prev and current
1415 int after_data_request(void *hook_data
, void *call_data
)
1417 EventRequest
*event_request
= (EventRequest
*)hook_data
;
1418 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
1420 ProcessList
*process_list
=
1421 guicontrolflow_get_process_list(event_request
->control_flow_data
);
1423 ClosureData closure_data
;
1424 closure_data
.event_request
= (EventRequest
*)hook_data
;
1425 closure_data
.ts
= (LttvTraceState
*)call_data
;
1427 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
1428 (void*)&closure_data
);