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
= 0xffff;
308 prop_text_out
.foreground
->blue
= 0xfff0;
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;
342 /* Print status of the process : U, WF, WC, E, W, R */
343 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
344 prop_text_out
.text
= "U->";
345 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
346 prop_text_out
.text
= "WF->";
347 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
348 prop_text_out
.text
= "WC->";
349 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
350 prop_text_out
.text
= "E->";
351 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
352 prop_text_out
.text
= "W->";
353 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
354 prop_text_out
.text
= "R->";
356 prop_text_out
.text
= "U";
358 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
359 gdk_gc_unref(draw_context_out
->gc
);
361 /* Draw the line of the out process */
362 if(draw_context_out
->previous
->middle
->x
== -1)
364 draw_context_out
->previous
->middle
->x
= event_request
->x_begin
;
365 g_critical("out middle x_beg : %u",event_request
->x_begin
);
368 draw_context_out
->current
->middle
->x
= x
;
369 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
370 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
371 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
372 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
373 //draw_context_out->gc = widget->style->black_gc;
374 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
375 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
377 PropertiesLine prop_line_out
;
378 prop_line_out
.color
= g_new(GdkColor
,1);
379 prop_line_out
.line_width
= 2;
380 prop_line_out
.style
= GDK_LINE_SOLID
;
381 prop_line_out
.position
= MIDDLE
;
383 g_critical("out state : %s", g_quark_to_string(process_out
->state
->s
));
385 /* color of line : status of the process */
386 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
388 prop_line_out
.color
->red
= 0xffff;
389 prop_line_out
.color
->green
= 0xffff;
390 prop_line_out
.color
->blue
= 0xffff;
392 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
394 prop_line_out
.color
->red
= 0x0fff;
395 prop_line_out
.color
->green
= 0xffff;
396 prop_line_out
.color
->blue
= 0xfff0;
398 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
400 prop_line_out
.color
->red
= 0xffff;
401 prop_line_out
.color
->green
= 0xffff;
402 prop_line_out
.color
->blue
= 0x0000;
404 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
406 prop_line_out
.color
->red
= 0xffff;
407 prop_line_out
.color
->green
= 0x0000;
408 prop_line_out
.color
->blue
= 0xffff;
410 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
412 prop_line_out
.color
->red
= 0xffff;
413 prop_line_out
.color
->green
= 0x0000;
414 prop_line_out
.color
->blue
= 0x0000;
416 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
418 prop_line_out
.color
->red
= 0x0000;
419 prop_line_out
.color
->green
= 0xffff;
420 prop_line_out
.color
->blue
= 0x0000;
424 prop_line_out
.color
->red
= 0xffff;
425 prop_line_out
.color
->green
= 0xffff;
426 prop_line_out
.color
->blue
= 0xffff;
429 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
430 g_free(prop_line_out
.color
);
431 gdk_gc_unref(draw_context_out
->gc
);
432 /* Note : finishing line will have to be added when trace read over. */
434 /* Finally, update the drawing context of the pid_in. */
436 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
437 draw_context_in
->current
->modify_over
->x
= x
;
438 draw_context_in
->current
->modify_under
->x
= x
;
439 draw_context_in
->current
->modify_over
->y
= y_in
;
440 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
441 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
442 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
443 widget
= control_flow_data
->drawing
->drawing_area
;
444 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
445 //draw_context_in->gc = widget->style->black_gc;
446 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
447 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
449 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
450 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
452 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
453 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
454 PropertiesText prop_text_in
;
455 prop_text_in
.foreground
= &colorfg_in
;
456 prop_text_in
.background
= &colorbg_in
;
457 prop_text_in
.size
= 6;
458 prop_text_in
.position
= OVER
;
460 g_critical("in state : %s", g_quark_to_string(process_in
->state
->s
));
461 /* foreground of text : status of the process */
462 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
464 prop_text_in
.foreground
->red
= 0xffff;
465 prop_text_in
.foreground
->green
= 0xffff;
466 prop_text_in
.foreground
->blue
= 0xffff;
468 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
470 prop_text_in
.foreground
->red
= 0x0fff;
471 prop_text_in
.foreground
->green
= 0xffff;
472 prop_text_in
.foreground
->blue
= 0xfff0;
474 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
476 prop_text_in
.foreground
->red
= 0xffff;
477 prop_text_in
.foreground
->green
= 0xffff;
478 prop_text_in
.foreground
->blue
= 0x0000;
480 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
482 prop_text_in
.foreground
->red
= 0xffff;
483 prop_text_in
.foreground
->green
= 0x0000;
484 prop_text_in
.foreground
->blue
= 0xffff;
486 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
488 prop_text_in
.foreground
->red
= 0xffff;
489 prop_text_in
.foreground
->green
= 0x0000;
490 prop_text_in
.foreground
->blue
= 0x0000;
492 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
494 prop_text_in
.foreground
->red
= 0x0000;
495 prop_text_in
.foreground
->green
= 0xffff;
496 prop_text_in
.foreground
->blue
= 0x0000;
500 prop_text_in
.foreground
->red
= 0xffff;
501 prop_text_in
.foreground
->green
= 0xffff;
502 prop_text_in
.foreground
->blue
= 0xffff;
507 /* Print status of the process : U, WF, WC, E, W, R */
508 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
509 prop_text_in
.text
= "U->";
510 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
511 prop_text_in
.text
= "WF->";
512 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
513 prop_text_in
.text
= "WC->";
514 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
515 prop_text_in
.text
= "E->";
516 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
517 prop_text_in
.text
= "W->";
518 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
519 prop_text_in
.text
= "R->";
521 prop_text_in
.text
= "U";
523 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
524 gdk_gc_unref(draw_context_in
->gc
);
526 /* Draw the line of the in process */
527 if(draw_context_in
->previous
->middle
->x
== -1)
529 draw_context_in
->previous
->middle
->x
= event_request
->x_begin
;
530 g_critical("in middle x_beg : %u",event_request
->x_begin
);
533 draw_context_in
->current
->middle
->x
= x
;
534 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
535 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
536 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
537 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
538 //draw_context_in->gc = widget->style->black_gc;
539 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
540 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
542 PropertiesLine prop_line_in
;
543 prop_line_in
.color
= g_new(GdkColor
,1);
544 prop_line_in
.line_width
= 2;
545 prop_line_in
.style
= GDK_LINE_SOLID
;
546 prop_line_in
.position
= MIDDLE
;
548 /* color of line : status of the process */
549 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
551 prop_line_in
.color
->red
= 0xffff;
552 prop_line_in
.color
->green
= 0xffff;
553 prop_line_in
.color
->blue
= 0xffff;
555 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
557 prop_line_in
.color
->red
= 0x0fff;
558 prop_line_in
.color
->green
= 0xffff;
559 prop_line_in
.color
->blue
= 0xfff0;
561 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
563 prop_line_in
.color
->red
= 0xffff;
564 prop_line_in
.color
->green
= 0xffff;
565 prop_line_in
.color
->blue
= 0x0000;
567 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
569 prop_line_in
.color
->red
= 0xffff;
570 prop_line_in
.color
->green
= 0x0000;
571 prop_line_in
.color
->blue
= 0xffff;
573 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
575 prop_line_in
.color
->red
= 0xffff;
576 prop_line_in
.color
->green
= 0x0000;
577 prop_line_in
.color
->blue
= 0x0000;
579 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
581 prop_line_in
.color
->red
= 0x0000;
582 prop_line_in
.color
->green
= 0xffff;
583 prop_line_in
.color
->blue
= 0x0000;
587 prop_line_in
.color
->red
= 0xffff;
588 prop_line_in
.color
->green
= 0xffff;
589 prop_line_in
.color
->blue
= 0xffff;
592 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
593 g_free(prop_line_in
.color
);
594 gdk_gc_unref(draw_context_in
->gc
);
601 GString
*string
= g_string_new("");;
602 gboolean field_names
= TRUE
, state
= TRUE
;
604 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
605 g_string_append_printf(string
,"\n");
608 g_string_append_printf(string
, " %s",
609 g_quark_to_string(tfs
->process
->state
->s
));
612 g_info("%s",string
->str
);
614 g_string_free(string
, TRUE
);
616 /* End of text dump */
622 int draw_after_hook(void *hook_data
, void *call_data
)
624 EventRequest
*event_request
= (EventRequest
*)hook_data
;
625 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
627 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
629 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
635 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
637 g_critical("schedchange!");
639 /* Add process to process list (if not present) and get drawing "y" from
640 * process position */
641 guint pid_out
, pid_in
;
642 LttvProcessState
*process_out
, *process_in
;
644 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
646 ProcessList
*process_list
=
647 guicontrolflow_get_process_list(event_request
->control_flow_data
);
650 LttField
*f
= ltt_event_field(e
);
652 element
= ltt_field_member(f
,0);
653 pid_out
= ltt_event_get_long_unsigned(e
,element
);
654 element
= ltt_field_member(f
,1);
655 pid_in
= ltt_event_get_long_unsigned(e
,element
);
656 //g_critical("out : %u in : %u", pid_out, pid_in);
659 /* Find process pid_out in the list... */
660 process_out
= lttv_state_find_process(tfs
, pid_out
);
661 //g_critical("out : %s",g_quark_to_string(process_out->state->s));
663 birth
= process_out
->creation_time
;
664 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
665 HashedProcessData
*hashed_process_data_out
= NULL
;
667 if(processlist_get_process_pixels(process_list
,
672 &hashed_process_data_out
) == 1)
674 /* Process not present */
675 processlist_add(process_list
,
680 &hashed_process_data_out
);
681 processlist_get_process_pixels(process_list
,
686 &hashed_process_data_out
);
687 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
692 /* Find process pid_in in the list... */
693 process_in
= lttv_state_find_process(tfs
, pid_in
);
694 //g_critical("in : %s",g_quark_to_string(process_in->state->s));
696 birth
= process_in
->creation_time
;
697 name
= strdup(g_quark_to_string(process_in
->name
));
698 HashedProcessData
*hashed_process_data_in
= NULL
;
700 if(processlist_get_process_pixels(process_list
,
705 &hashed_process_data_in
) == 1)
707 /* Process not present */
708 processlist_add(process_list
,
713 &hashed_process_data_in
);
714 processlist_get_process_pixels(process_list
,
719 &hashed_process_data_in
);
721 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
726 /* Find pixels corresponding to time of the event. If the time does
727 * not fit in the window, show a warning, not supposed to happend. */
729 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
731 //LttTime time = ltt_event_time(e);
733 //LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
734 // control_flow_data->time_window.start_time);
737 //convert_time_to_pixels(
738 // control_flow_data->time_window.start_time,
744 //assert(x <= width);
746 /* draw what represents the event for outgoing process. */
748 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
749 //draw_context_out->current->modify_over->x = x;
750 draw_context_out
->current
->modify_over
->y
= y_out
;
751 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
752 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
753 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
754 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
755 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
756 draw_context_out
->gc
= widget
->style
->black_gc
;
758 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
759 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
761 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
762 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
763 PropertiesText prop_text_out
;
764 prop_text_out
.foreground
= &colorfg_out
;
765 prop_text_out
.background
= &colorbg_out
;
766 prop_text_out
.size
= 6;
767 prop_text_out
.position
= OVER
;
769 /* color of text : status of the process */
770 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
772 prop_text_out
.foreground
->red
= 0xffff;
773 prop_text_out
.foreground
->green
= 0xffff;
774 prop_text_out
.foreground
->blue
= 0xffff;
776 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
778 prop_text_out
.foreground
->red
= 0x0fff;
779 prop_text_out
.foreground
->green
= 0xffff;
780 prop_text_out
.foreground
->blue
= 0xfff0;
782 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
784 prop_text_out
.foreground
->red
= 0xffff;
785 prop_text_out
.foreground
->green
= 0xffff;
786 prop_text_out
.foreground
->blue
= 0x0000;
788 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
790 prop_text_out
.foreground
->red
= 0xffff;
791 prop_text_out
.foreground
->green
= 0x0000;
792 prop_text_out
.foreground
->blue
= 0xffff;
794 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
796 prop_text_out
.foreground
->red
= 0xffff;
797 prop_text_out
.foreground
->green
= 0x0000;
798 prop_text_out
.foreground
->blue
= 0x0000;
800 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
802 prop_text_out
.foreground
->red
= 0x0000;
803 prop_text_out
.foreground
->green
= 0xffff;
804 prop_text_out
.foreground
->blue
= 0x0000;
808 prop_text_out
.foreground
->red
= 0xffff;
809 prop_text_out
.foreground
->green
= 0xffff;
810 prop_text_out
.foreground
->blue
= 0xffff;
813 /* Print status of the process : U, WF, WC, E, W, R */
814 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
815 prop_text_out
.text
= "U";
816 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
817 prop_text_out
.text
= "WF";
818 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
819 prop_text_out
.text
= "WC";
820 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
821 prop_text_out
.text
= "E";
822 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
823 prop_text_out
.text
= "W";
824 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
825 prop_text_out
.text
= "R";
827 prop_text_out
.text
= "U";
829 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
831 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
832 draw_context_out
->current
->status
= process_out
->state
->s
;
834 /* for pid_out : remove previous, Prev = current, new current (default) */
835 g_free(draw_context_out
->previous
->modify_under
);
836 g_free(draw_context_out
->previous
->modify_middle
);
837 g_free(draw_context_out
->previous
->modify_over
);
838 g_free(draw_context_out
->previous
->under
);
839 g_free(draw_context_out
->previous
->middle
);
840 g_free(draw_context_out
->previous
->over
);
841 g_free(draw_context_out
->previous
);
843 draw_context_out
->previous
= draw_context_out
->current
;
845 draw_context_out
->current
= g_new(DrawInfo
,1);
846 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
847 draw_context_out
->current
->over
->x
= -1;
848 draw_context_out
->current
->over
->y
= -1;
849 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
850 draw_context_out
->current
->middle
->x
= -1;
851 draw_context_out
->current
->middle
->y
= -1;
852 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
853 draw_context_out
->current
->under
->x
= -1;
854 draw_context_out
->current
->under
->y
= -1;
855 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
856 draw_context_out
->current
->modify_over
->x
= -1;
857 draw_context_out
->current
->modify_over
->y
= -1;
858 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
859 draw_context_out
->current
->modify_middle
->x
= -1;
860 draw_context_out
->current
->modify_middle
->y
= -1;
861 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
862 draw_context_out
->current
->modify_under
->x
= -1;
863 draw_context_out
->current
->modify_under
->y
= -1;
864 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
866 /* Finally, update the drawing context of the pid_in. */
868 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
869 //draw_context_in->current->modify_over->x = x;
870 draw_context_in
->current
->modify_over
->y
= y_in
;
871 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
872 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
873 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
874 widget
= control_flow_data
->drawing
->drawing_area
;
875 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
876 draw_context_in
->gc
= widget
->style
->black_gc
;
878 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
879 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
881 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
882 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
883 PropertiesText prop_text_in
;
884 prop_text_in
.foreground
= &colorfg_in
;
885 prop_text_in
.background
= &colorbg_in
;
886 prop_text_in
.size
= 6;
887 prop_text_in
.position
= OVER
;
889 /* foreground of text : status of the process */
890 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
892 prop_text_in
.foreground
->red
= 0xffff;
893 prop_text_in
.foreground
->green
= 0xffff;
894 prop_text_in
.foreground
->blue
= 0xffff;
896 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
898 prop_text_in
.foreground
->red
= 0x0fff;
899 prop_text_in
.foreground
->green
= 0xffff;
900 prop_text_in
.foreground
->blue
= 0xfff0;
902 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
904 prop_text_in
.foreground
->red
= 0xffff;
905 prop_text_in
.foreground
->green
= 0xffff;
906 prop_text_in
.foreground
->blue
= 0x0000;
908 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
910 prop_text_in
.foreground
->red
= 0xffff;
911 prop_text_in
.foreground
->green
= 0x0000;
912 prop_text_in
.foreground
->blue
= 0xffff;
914 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
916 prop_text_in
.foreground
->red
= 0xffff;
917 prop_text_in
.foreground
->green
= 0x0000;
918 prop_text_in
.foreground
->blue
= 0x0000;
920 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
922 prop_text_in
.foreground
->red
= 0x0000;
923 prop_text_in
.foreground
->green
= 0xffff;
924 prop_text_in
.foreground
->blue
= 0x0000;
928 prop_text_in
.foreground
->red
= 0xffff;
929 prop_text_in
.foreground
->green
= 0xffff;
930 prop_text_in
.foreground
->blue
= 0xffff;
934 /* Print status of the process : U, WF, WC, E, W, R */
935 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
936 prop_text_in
.text
= "U";
937 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
938 prop_text_in
.text
= "WF";
939 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
940 prop_text_in
.text
= "WC";
941 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
942 prop_text_in
.text
= "E";
943 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
944 prop_text_in
.text
= "W";
945 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
946 prop_text_in
.text
= "R";
948 prop_text_in
.text
= "U";
950 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
952 if(process_in
->state
->s
== LTTV_STATE_RUN
)
955 prop_text_in
.foreground
= &colorfg_in
;
956 prop_text_in
.background
= &colorbg_in
;
957 prop_text_in
.foreground
->red
= 0xffff;
958 prop_text_in
.foreground
->green
= 0xffff;
959 prop_text_in
.foreground
->blue
= 0xffff;
960 prop_text_in
.size
= 6;
961 prop_text_in
.position
= UNDER
;
963 prop_text_in
.text
= g_new(gchar
, 260);
964 strcpy(prop_text_in
.text
, "CPU ");
965 snprintf(tmp
, 255, "%u", tfc
->index
);
966 strcat(prop_text_in
.text
, tmp
);
968 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
969 g_free(prop_text_in
.text
);
973 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
974 draw_context_in
->current
->status
= process_in
->state
->s
;
976 /* for pid_in : remove previous, Prev = current, new current (default) */
977 g_free(draw_context_in
->previous
->modify_under
);
978 g_free(draw_context_in
->previous
->modify_middle
);
979 g_free(draw_context_in
->previous
->modify_over
);
980 g_free(draw_context_in
->previous
->under
);
981 g_free(draw_context_in
->previous
->middle
);
982 g_free(draw_context_in
->previous
->over
);
983 g_free(draw_context_in
->previous
);
985 draw_context_in
->previous
= draw_context_in
->current
;
987 draw_context_in
->current
= g_new(DrawInfo
,1);
988 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
989 draw_context_in
->current
->over
->x
= -1;
990 draw_context_in
->current
->over
->y
= -1;
991 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
992 draw_context_in
->current
->middle
->x
= -1;
993 draw_context_in
->current
->middle
->y
= -1;
994 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
995 draw_context_in
->current
->under
->x
= -1;
996 draw_context_in
->current
->under
->y
= -1;
997 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
998 draw_context_in
->current
->modify_over
->x
= -1;
999 draw_context_in
->current
->modify_over
->y
= -1;
1000 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1001 draw_context_in
->current
->modify_middle
->x
= -1;
1002 draw_context_in
->current
->modify_middle
->y
= -1;
1003 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1004 draw_context_in
->current
->modify_under
->x
= -1;
1005 draw_context_in
->current
->modify_under
->y
= -1;
1006 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1016 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1018 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1019 TimeWindow
*old_time_window
=
1020 guicontrolflow_get_time_window(control_flow_data
);
1021 TimeWindow
*new_time_window
= ((TimeWindow
*)call_data
);
1023 /* Update the ruler */
1024 drawing_update_ruler(control_flow_data
->drawing
,
1028 /* Two cases : zoom in/out or scrolling */
1030 /* In order to make sure we can reuse the old drawing, the scale must
1031 * be the same and the new time interval being partly located in the
1032 * currently shown time interval. (reuse is only for scrolling)
1035 g_info("Old time window HOOK : %u, %u to %u, %u",
1036 old_time_window
->start_time
.tv_sec
,
1037 old_time_window
->start_time
.tv_nsec
,
1038 old_time_window
->time_width
.tv_sec
,
1039 old_time_window
->time_width
.tv_nsec
);
1041 g_info("New time window HOOK : %u, %u to %u, %u",
1042 new_time_window
->start_time
.tv_sec
,
1043 new_time_window
->start_time
.tv_nsec
,
1044 new_time_window
->time_width
.tv_sec
,
1045 new_time_window
->time_width
.tv_nsec
);
1047 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1048 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1050 /* Same scale (scrolling) */
1051 g_info("scrolling");
1052 LttTime
*ns
= &new_time_window
->start_time
;
1053 LttTime
*os
= &old_time_window
->start_time
;
1054 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
1055 old_time_window
->time_width
);
1056 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
1057 new_time_window
->time_width
);
1059 //if(ns<os+w && os+w<ns+w)
1060 //if(ns<old_end && os<ns)
1061 if(ltt_time_compare(*ns
, old_end
) == -1
1062 && ltt_time_compare(*os
, *ns
) == -1)
1064 g_info("scrolling near right");
1065 /* Scroll right, keep right part of the screen */
1067 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1068 convert_time_to_pixels(
1075 /* Copy old data to new location */
1076 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1077 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1078 control_flow_data
->drawing
->pixmap
,
1083 convert_time_to_pixels(
1090 *old_time_window
= *new_time_window
;
1091 /* Clear the data request background, but not SAFETY */
1092 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1093 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1096 control_flow_data
->drawing
->width
- x
, // do not overlap
1097 control_flow_data
->drawing
->height
+SAFETY
);
1098 /* Get new data for the rest. */
1099 drawing_data_request(control_flow_data
->drawing
,
1100 &control_flow_data
->drawing
->pixmap
,
1102 control_flow_data
->drawing
->width
- x
,
1103 control_flow_data
->drawing
->height
);
1105 drawing_refresh(control_flow_data
->drawing
,
1107 control_flow_data
->drawing
->width
,
1108 control_flow_data
->drawing
->height
);
1113 //if(ns<os && os<ns+w)
1114 //if(ns<os && os<new_end)
1115 if(ltt_time_compare(*ns
,*os
) == -1
1116 && ltt_time_compare(*os
,new_end
) == -1)
1118 g_info("scrolling near left");
1119 /* Scroll left, keep left part of the screen */
1121 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1122 convert_time_to_pixels(
1129 /* Copy old data to new location */
1130 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1131 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1132 control_flow_data
->drawing
->pixmap
,
1137 *old_time_window
= *new_time_window
;
1139 /* Clean the data request background */
1140 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1141 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1144 x
, // do not overlap
1145 control_flow_data
->drawing
->height
+SAFETY
);
1146 /* Get new data for the rest. */
1147 drawing_data_request(control_flow_data
->drawing
,
1148 &control_flow_data
->drawing
->pixmap
,
1151 control_flow_data
->drawing
->height
);
1153 drawing_refresh(control_flow_data
->drawing
,
1155 control_flow_data
->drawing
->width
,
1156 control_flow_data
->drawing
->height
);
1159 g_info("scrolling far");
1160 /* Cannot reuse any part of the screen : far jump */
1161 *old_time_window
= *new_time_window
;
1164 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1165 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1168 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1169 control_flow_data
->drawing
->height
+SAFETY
);
1171 drawing_data_request(control_flow_data
->drawing
,
1172 &control_flow_data
->drawing
->pixmap
,
1174 control_flow_data
->drawing
->width
,
1175 control_flow_data
->drawing
->height
);
1177 drawing_refresh(control_flow_data
->drawing
,
1179 control_flow_data
->drawing
->width
,
1180 control_flow_data
->drawing
->height
);
1184 /* Different scale (zoom) */
1187 *old_time_window
= *new_time_window
;
1189 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1190 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1193 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1194 control_flow_data
->drawing
->height
+SAFETY
);
1197 drawing_data_request(control_flow_data
->drawing
,
1198 &control_flow_data
->drawing
->pixmap
,
1200 control_flow_data
->drawing
->width
,
1201 control_flow_data
->drawing
->height
);
1203 drawing_refresh(control_flow_data
->drawing
,
1205 control_flow_data
->drawing
->width
,
1206 control_flow_data
->drawing
->height
);
1214 gint
update_current_time_hook(void *hook_data
, void *call_data
)
1216 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
1218 LttTime
* current_time
=
1219 guicontrolflow_get_current_time(control_flow_data
);
1220 *current_time
= *((LttTime
*)call_data
);
1222 TimeWindow time_window
;
1224 LttTime time_begin
= control_flow_data
->time_window
.start_time
;
1225 LttTime width
= control_flow_data
->time_window
.time_width
;
1226 LttTime half_width
= ltt_time_div(width
,2.0);
1227 LttTime time_end
= ltt_time_add(time_begin
, width
);
1229 LttvTracesetContext
* tsc
=
1230 get_traceset_context(control_flow_data
->mw
);
1232 LttTime trace_start
= tsc
->Time_Span
->startTime
;
1233 LttTime trace_end
= tsc
->Time_Span
->endTime
;
1235 g_info("New current time HOOK : %u, %u", current_time
->tv_sec
,
1236 current_time
->tv_nsec
);
1240 /* If current time is inside time interval, just move the highlight
1243 /* Else, we have to change the time interval. We have to tell it
1244 * to the main window. */
1245 /* The time interval change will take care of placing the current
1246 * time at the center of the visible area, or nearest possible if we are
1247 * at one end of the trace. */
1250 if(ltt_time_compare(*current_time
, time_begin
) == -1)
1252 if(ltt_time_compare(*current_time
,
1253 ltt_time_add(trace_start
,half_width
)) == -1)
1254 time_begin
= trace_start
;
1256 time_begin
= ltt_time_sub(*current_time
,half_width
);
1258 time_window
.start_time
= time_begin
;
1259 time_window
.time_width
= width
;
1261 set_time_window(control_flow_data
->mw
, &time_window
);
1263 else if(ltt_time_compare(*current_time
, time_end
) == 1)
1265 if(ltt_time_compare(*current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
1266 time_begin
= ltt_time_sub(trace_end
,width
);
1268 time_begin
= ltt_time_sub(*current_time
,half_width
);
1270 time_window
.start_time
= time_begin
;
1271 time_window
.time_width
= width
;
1273 set_time_window(control_flow_data
->mw
, &time_window
);
1276 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
1281 typedef struct _ClosureData
{
1282 EventRequest
*event_request
;
1287 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1289 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
1290 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
1291 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1293 ControlFlowData
*control_flow_data
=
1294 closure_data
->event_request
->control_flow_data
;
1296 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1298 /* Get y position of process */
1301 processlist_get_pixels_from_data( control_flow_data
->process_list
,
1303 hashed_process_data
,
1306 /* Get last state of process */
1307 LttvTraceContext
*tc
=
1308 (LttvTraceContext
*)closure_data
->ts
;
1310 LttvTraceState
*ts
= closure_data
->ts
;
1311 LttvProcessState
*process
;
1313 process
= lttv_state_find_process((LttvTracefileState
*)ts
, process_info
->pid
);
1315 /* Draw the closing line */
1316 DrawContext
*draw_context
= hashed_process_data
->draw_context
;
1317 if(draw_context
->previous
->middle
->x
== -1)
1319 draw_context
->previous
->middle
->x
= closure_data
->event_request
->x_begin
;
1320 g_critical("out middle x_beg : %u",closure_data
->event_request
->x_begin
);
1323 draw_context
->current
->middle
->x
= closure_data
->event_request
->x_end
;
1324 draw_context
->current
->middle
->y
= y
+ height
/2;
1325 draw_context
->previous
->middle
->y
= y
+ height
/2;
1326 draw_context
->drawable
= control_flow_data
->drawing
->pixmap
;
1327 draw_context
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1328 //draw_context->gc = widget->style->black_gc;
1329 draw_context
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
1330 gdk_gc_copy(draw_context
->gc
, widget
->style
->black_gc
);
1332 PropertiesLine prop_line
;
1333 prop_line
.color
= g_new(GdkColor
,1);
1334 prop_line
.line_width
= 2;
1335 prop_line
.style
= GDK_LINE_SOLID
;
1336 prop_line
.position
= MIDDLE
;
1338 /* color of line : status of the process */
1339 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
1341 prop_line
.color
->red
= 0xffff;
1342 prop_line
.color
->green
= 0xffff;
1343 prop_line
.color
->blue
= 0xffff;
1345 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
1347 prop_line
.color
->red
= 0x0fff;
1348 prop_line
.color
->green
= 0xffff;
1349 prop_line
.color
->blue
= 0xfff0;
1351 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
1353 prop_line
.color
->red
= 0xffff;
1354 prop_line
.color
->green
= 0xffff;
1355 prop_line
.color
->blue
= 0x0000;
1357 else if(process
->state
->s
== LTTV_STATE_EXIT
)
1359 prop_line
.color
->red
= 0xffff;
1360 prop_line
.color
->green
= 0x0000;
1361 prop_line
.color
->blue
= 0xffff;
1363 else if(process
->state
->s
== LTTV_STATE_WAIT
)
1365 prop_line
.color
->red
= 0xffff;
1366 prop_line
.color
->green
= 0x0000;
1367 prop_line
.color
->blue
= 0x0000;
1369 else if(process
->state
->s
== LTTV_STATE_RUN
)
1371 prop_line
.color
->red
= 0x0000;
1372 prop_line
.color
->green
= 0xffff;
1373 prop_line
.color
->blue
= 0x0000;
1377 prop_line
.color
->red
= 0xffff;
1378 prop_line
.color
->green
= 0xffff;
1379 prop_line
.color
->blue
= 0xffff;
1382 draw_line((void*)&prop_line
, (void*)draw_context
);
1383 g_free(prop_line
.color
);
1384 gdk_gc_unref(draw_context
->gc
);
1386 /* Reset draw_context of the process for next request */
1388 hashed_process_data
->draw_context
->drawable
= NULL
;
1389 hashed_process_data
->draw_context
->gc
= NULL
;
1390 hashed_process_data
->draw_context
->pango_layout
= NULL
;
1391 hashed_process_data
->draw_context
->current
->over
->x
= -1;
1392 hashed_process_data
->draw_context
->current
->over
->y
= -1;
1393 hashed_process_data
->draw_context
->current
->middle
->x
= -1;
1394 hashed_process_data
->draw_context
->current
->middle
->y
= -1;
1395 hashed_process_data
->draw_context
->current
->under
->x
= -1;
1396 hashed_process_data
->draw_context
->current
->under
->y
= -1;
1397 hashed_process_data
->draw_context
->current
->modify_over
->x
= -1;
1398 hashed_process_data
->draw_context
->current
->modify_over
->y
= -1;
1399 hashed_process_data
->draw_context
->current
->modify_middle
->x
= -1;
1400 hashed_process_data
->draw_context
->current
->modify_middle
->y
= -1;
1401 hashed_process_data
->draw_context
->current
->modify_under
->x
= -1;
1402 hashed_process_data
->draw_context
->current
->modify_under
->y
= -1;
1403 hashed_process_data
->draw_context
->current
->status
= LTTV_STATE_UNNAMED
;
1404 hashed_process_data
->draw_context
->previous
->over
->x
= -1;
1405 hashed_process_data
->draw_context
->previous
->over
->y
= -1;
1406 hashed_process_data
->draw_context
->previous
->middle
->x
= -1;
1407 hashed_process_data
->draw_context
->previous
->middle
->y
= -1;
1408 hashed_process_data
->draw_context
->previous
->under
->x
= -1;
1409 hashed_process_data
->draw_context
->previous
->under
->y
= -1;
1410 hashed_process_data
->draw_context
->previous
->modify_over
->x
= -1;
1411 hashed_process_data
->draw_context
->previous
->modify_over
->y
= -1;
1412 hashed_process_data
->draw_context
->previous
->modify_middle
->x
= -1;
1413 hashed_process_data
->draw_context
->previous
->modify_middle
->y
= -1;
1414 hashed_process_data
->draw_context
->previous
->modify_under
->x
= -1;
1415 hashed_process_data
->draw_context
->previous
->modify_under
->y
= -1;
1416 hashed_process_data
->draw_context
->previous
->status
= LTTV_STATE_UNNAMED
;
1424 * new default prev and current
1426 int after_data_request(void *hook_data
, void *call_data
)
1428 EventRequest
*event_request
= (EventRequest
*)hook_data
;
1429 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
1431 ProcessList
*process_list
=
1432 guicontrolflow_get_process_list(event_request
->control_flow_data
);
1434 ClosureData closure_data
;
1435 closure_data
.event_request
= (EventRequest
*)hook_data
;
1436 closure_data
.ts
= (LttvTraceState
*)call_data
;
1438 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
1439 (void*)&closure_data
);