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
;
155 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
160 LttTime evtime
= ltt_event_time(e
);
161 TimeWindow
*time_window
=
162 guicontrolflow_get_time_window(control_flow_data
);
164 LttTime end_time
= ltt_time_add(time_window
->start_time
,
165 time_window
->time_width
);
166 //if(time < time_beg || time > time_end) return;
167 if(ltt_time_compare(evtime
, time_window
->start_time
) == -1
168 || ltt_time_compare(evtime
, end_time
) == 1)
171 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
173 g_critical("schedchange!");
175 /* Add process to process list (if not present) and get drawing "y" from
176 * process position */
177 guint pid_out
, pid_in
;
178 LttvProcessState
*process_out
, *process_in
;
180 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
182 ProcessList
*process_list
=
183 guicontrolflow_get_process_list(event_request
->control_flow_data
);
186 LttField
*f
= ltt_event_field(e
);
188 element
= ltt_field_member(f
,0);
189 pid_out
= ltt_event_get_long_unsigned(e
,element
);
190 element
= ltt_field_member(f
,1);
191 pid_in
= ltt_event_get_long_unsigned(e
,element
);
192 g_critical("out : %u in : %u", pid_out
, pid_in
);
195 /* Find process pid_out in the list... */
196 process_out
= lttv_state_find_process_from_trace(ts
, pid_out
);
197 if(process_out
== NULL
) return 0;
198 g_critical("out : %s",g_quark_to_string(process_out
->state
->s
));
200 birth
= process_out
->creation_time
;
201 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
202 HashedProcessData
*hashed_process_data_out
= NULL
;
204 if(processlist_get_process_pixels(process_list
,
207 tfc
->t_context
->index
,
210 &hashed_process_data_out
) == 1)
212 /* Process not present */
213 processlist_add(process_list
,
216 tfc
->t_context
->index
,
219 &hashed_process_data_out
);
220 processlist_get_process_pixels(process_list
,
223 tfc
->t_context
->index
,
226 &hashed_process_data_out
);
227 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
232 /* Find process pid_in in the list... */
233 process_in
= lttv_state_find_process_from_trace(ts
, pid_in
);
234 if(process_in
== NULL
) return 0;
235 g_critical("in : %s",g_quark_to_string(process_in
->state
->s
));
237 birth
= process_in
->creation_time
;
238 name
= strdup(g_quark_to_string(process_in
->name
));
239 HashedProcessData
*hashed_process_data_in
= NULL
;
241 if(processlist_get_process_pixels(process_list
,
244 tfc
->t_context
->index
,
247 &hashed_process_data_in
) == 1)
249 /* Process not present */
250 processlist_add(process_list
,
253 tfc
->t_context
->index
,
256 &hashed_process_data_in
);
257 processlist_get_process_pixels(process_list
,
260 tfc
->t_context
->index
,
263 &hashed_process_data_in
);
265 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
270 /* Find pixels corresponding to time of the event. If the time does
271 * not fit in the window, show a warning, not supposed to happend. */
273 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
275 LttTime time
= ltt_event_time(e
);
277 LttTime window_end
= ltt_time_add(control_flow_data
->time_window
.time_width
,
278 control_flow_data
->time_window
.start_time
);
281 convert_time_to_pixels(
282 control_flow_data
->time_window
.start_time
,
287 //assert(x <= width);
289 /* draw what represents the event for outgoing process. */
291 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
292 draw_context_out
->current
->modify_over
->x
= x
;
293 draw_context_out
->current
->modify_under
->x
= x
;
294 draw_context_out
->current
->modify_over
->y
= y_out
;
295 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
296 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
297 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
298 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
299 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
300 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
301 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
302 //draw_context_out->gc = widget->style->black_gc;
304 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
305 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
307 /* Draw the line/background of the out process */
308 if(draw_context_out
->previous
->middle
->x
== -1)
310 draw_context_out
->previous
->over
->x
= event_request
->x_begin
;
311 draw_context_out
->previous
->middle
->x
= event_request
->x_begin
;
312 draw_context_out
->previous
->under
->x
= event_request
->x_begin
;
314 g_critical("out middle x_beg : %u",event_request
->x_begin
);
317 draw_context_out
->current
->middle
->x
= x
;
318 draw_context_out
->current
->over
->x
= x
;
319 draw_context_out
->current
->under
->x
= x
;
320 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
321 draw_context_out
->current
->over
->y
= y_out
;
322 draw_context_out
->current
->under
->y
= y_out
+ height
;
323 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
324 draw_context_out
->previous
->over
->y
= y_out
;
325 draw_context_out
->previous
->under
->y
= y_out
+ height
;
327 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
328 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
330 if(process_out
->state
->s
== LTTV_STATE_RUN
)
332 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
333 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
335 PropertiesBG prop_bg
;
336 prop_bg
.color
= g_new(GdkColor
,1);
340 prop_bg
.color
->red
= 0x1515;
341 prop_bg
.color
->green
= 0x1515;
342 prop_bg
.color
->blue
= 0x8c8c;
345 prop_bg
.color
->red
= 0x4e4e;
346 prop_bg
.color
->green
= 0xa9a9;
347 prop_bg
.color
->blue
= 0xa4a4;
350 prop_bg
.color
->red
= 0x7a7a;
351 prop_bg
.color
->green
= 0x4a4a;
352 prop_bg
.color
->blue
= 0x8b8b;
355 prop_bg
.color
->red
= 0x8080;
356 prop_bg
.color
->green
= 0x7777;
357 prop_bg
.color
->blue
= 0x4747;
360 prop_bg
.color
->red
= 0xe7e7;
361 prop_bg
.color
->green
= 0xe7e7;
362 prop_bg
.color
->blue
= 0xe7e7;
365 g_critical("calling from draw_event");
366 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
367 g_free(prop_bg
.color
);
368 gdk_gc_unref(draw_context_out
->gc
);
371 draw_context_out
->gc
= widget
->style
->black_gc
;
373 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
374 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
375 PropertiesText prop_text_out
;
376 prop_text_out
.foreground
= &colorfg_out
;
377 prop_text_out
.background
= &colorbg_out
;
378 prop_text_out
.size
= 6;
379 prop_text_out
.position
= OVER
;
381 /* color of text : status of the process */
382 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
384 prop_text_out
.foreground
->red
= 0xffff;
385 prop_text_out
.foreground
->green
= 0xffff;
386 prop_text_out
.foreground
->blue
= 0xffff;
388 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
390 prop_text_out
.foreground
->red
= 0x0fff;
391 prop_text_out
.foreground
->green
= 0xffff;
392 prop_text_out
.foreground
->blue
= 0xfff0;
394 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
396 prop_text_out
.foreground
->red
= 0xffff;
397 prop_text_out
.foreground
->green
= 0xffff;
398 prop_text_out
.foreground
->blue
= 0x0000;
400 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
402 prop_text_out
.foreground
->red
= 0xffff;
403 prop_text_out
.foreground
->green
= 0x0000;
404 prop_text_out
.foreground
->blue
= 0xffff;
406 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
408 prop_text_out
.foreground
->red
= 0xffff;
409 prop_text_out
.foreground
->green
= 0x0000;
410 prop_text_out
.foreground
->blue
= 0x0000;
412 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
414 prop_text_out
.foreground
->red
= 0x0000;
415 prop_text_out
.foreground
->green
= 0xffff;
416 prop_text_out
.foreground
->blue
= 0x0000;
420 prop_text_out
.foreground
->red
= 0xffff;
421 prop_text_out
.foreground
->green
= 0xffff;
422 prop_text_out
.foreground
->blue
= 0xffff;
426 /* Print status of the process : U, WF, WC, E, W, R */
427 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
428 prop_text_out
.text
= "U->";
429 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
430 prop_text_out
.text
= "WF->";
431 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
432 prop_text_out
.text
= "WC->";
433 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
434 prop_text_out
.text
= "E->";
435 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
436 prop_text_out
.text
= "W->";
437 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
438 prop_text_out
.text
= "R->";
440 prop_text_out
.text
= "U";
442 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
443 //gdk_gc_unref(draw_context_out->gc);
445 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
446 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
448 PropertiesLine prop_line_out
;
449 prop_line_out
.color
= g_new(GdkColor
,1);
450 prop_line_out
.line_width
= 2;
451 prop_line_out
.style
= GDK_LINE_SOLID
;
452 prop_line_out
.position
= MIDDLE
;
454 g_critical("out state : %s", g_quark_to_string(process_out
->state
->s
));
456 /* color of line : status of the process */
457 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
459 prop_line_out
.color
->red
= 0xffff;
460 prop_line_out
.color
->green
= 0xffff;
461 prop_line_out
.color
->blue
= 0xffff;
463 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
465 prop_line_out
.color
->red
= 0x0fff;
466 prop_line_out
.color
->green
= 0xffff;
467 prop_line_out
.color
->blue
= 0xfff0;
469 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
471 prop_line_out
.color
->red
= 0xffff;
472 prop_line_out
.color
->green
= 0xffff;
473 prop_line_out
.color
->blue
= 0x0000;
475 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
477 prop_line_out
.color
->red
= 0xffff;
478 prop_line_out
.color
->green
= 0x0000;
479 prop_line_out
.color
->blue
= 0xffff;
481 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
483 prop_line_out
.color
->red
= 0xffff;
484 prop_line_out
.color
->green
= 0x0000;
485 prop_line_out
.color
->blue
= 0x0000;
487 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
489 prop_line_out
.color
->red
= 0x0000;
490 prop_line_out
.color
->green
= 0xffff;
491 prop_line_out
.color
->blue
= 0x0000;
495 prop_line_out
.color
->red
= 0xffff;
496 prop_line_out
.color
->green
= 0xffff;
497 prop_line_out
.color
->blue
= 0xffff;
500 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
501 g_free(prop_line_out
.color
);
502 gdk_gc_unref(draw_context_out
->gc
);
503 /* Note : finishing line will have to be added when trace read over. */
505 /* Finally, update the drawing context of the pid_in. */
507 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
508 draw_context_in
->current
->modify_over
->x
= x
;
509 draw_context_in
->current
->modify_under
->x
= x
;
510 draw_context_in
->current
->modify_over
->y
= y_in
;
511 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
512 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
513 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
514 widget
= control_flow_data
->drawing
->drawing_area
;
515 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
516 //draw_context_in->gc = widget->style->black_gc;
517 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
518 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
520 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
521 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
523 /* Draw the line/bg of the in process */
524 if(draw_context_in
->previous
->middle
->x
== -1)
526 draw_context_in
->previous
->middle
->x
= event_request
->x_begin
;
527 draw_context_in
->previous
->over
->x
= event_request
->x_begin
;
528 draw_context_in
->previous
->under
->x
= event_request
->x_begin
;
529 g_critical("in middle x_beg : %u",event_request
->x_begin
);
532 draw_context_in
->current
->middle
->x
= x
;
533 draw_context_in
->current
->over
->x
= x
;
534 draw_context_in
->current
->under
->x
= x
;
535 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
536 draw_context_in
->current
->over
->y
= y_in
;
537 draw_context_in
->current
->under
->y
= y_in
+ height
;
538 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
539 draw_context_in
->previous
->over
->y
= y_in
;
540 draw_context_in
->previous
->under
->y
= y_in
+ height
;
542 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
543 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
546 if(process_in
->state
->s
== LTTV_STATE_RUN
)
548 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
549 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
551 PropertiesBG prop_bg
;
552 prop_bg
.color
= g_new(GdkColor
,1);
556 prop_bg
.color
->red
= 0x1515;
557 prop_bg
.color
->green
= 0x1515;
558 prop_bg
.color
->blue
= 0x8c8c;
561 prop_bg
.color
->red
= 0x4e4e;
562 prop_bg
.color
->green
= 0xa9a9;
563 prop_bg
.color
->blue
= 0xa4a4;
566 prop_bg
.color
->red
= 0x7a7a;
567 prop_bg
.color
->green
= 0x4a4a;
568 prop_bg
.color
->blue
= 0x8b8b;
571 prop_bg
.color
->red
= 0x8080;
572 prop_bg
.color
->green
= 0x7777;
573 prop_bg
.color
->blue
= 0x4747;
576 prop_bg
.color
->red
= 0xe7e7;
577 prop_bg
.color
->green
= 0xe7e7;
578 prop_bg
.color
->blue
= 0xe7e7;
582 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
583 g_free(prop_bg
.color
);
584 gdk_gc_unref(draw_context_in
->gc
);
587 draw_context_in
->gc
= widget
->style
->black_gc
;
589 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
590 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
591 PropertiesText prop_text_in
;
592 prop_text_in
.foreground
= &colorfg_in
;
593 prop_text_in
.background
= &colorbg_in
;
594 prop_text_in
.size
= 6;
595 prop_text_in
.position
= OVER
;
597 g_critical("in state : %s", g_quark_to_string(process_in
->state
->s
));
598 /* foreground of text : status of the process */
599 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
601 prop_text_in
.foreground
->red
= 0xffff;
602 prop_text_in
.foreground
->green
= 0xffff;
603 prop_text_in
.foreground
->blue
= 0xffff;
605 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
607 prop_text_in
.foreground
->red
= 0x0fff;
608 prop_text_in
.foreground
->green
= 0xffff;
609 prop_text_in
.foreground
->blue
= 0xfff0;
611 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
613 prop_text_in
.foreground
->red
= 0xffff;
614 prop_text_in
.foreground
->green
= 0xffff;
615 prop_text_in
.foreground
->blue
= 0x0000;
617 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
619 prop_text_in
.foreground
->red
= 0xffff;
620 prop_text_in
.foreground
->green
= 0x0000;
621 prop_text_in
.foreground
->blue
= 0xffff;
623 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
625 prop_text_in
.foreground
->red
= 0xffff;
626 prop_text_in
.foreground
->green
= 0x0000;
627 prop_text_in
.foreground
->blue
= 0x0000;
629 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
631 prop_text_in
.foreground
->red
= 0x0000;
632 prop_text_in
.foreground
->green
= 0xffff;
633 prop_text_in
.foreground
->blue
= 0x0000;
637 prop_text_in
.foreground
->red
= 0xffff;
638 prop_text_in
.foreground
->green
= 0xffff;
639 prop_text_in
.foreground
->blue
= 0xffff;
644 /* Print status of the process : U, WF, WC, E, W, R */
645 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
646 prop_text_in
.text
= "U->";
647 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
648 prop_text_in
.text
= "WF->";
649 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
650 prop_text_in
.text
= "WC->";
651 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
652 prop_text_in
.text
= "E->";
653 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
654 prop_text_in
.text
= "W->";
655 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
656 prop_text_in
.text
= "R->";
658 prop_text_in
.text
= "U";
660 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
661 //gdk_gc_unref(draw_context_in->gc);
663 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
664 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
666 PropertiesLine prop_line_in
;
667 prop_line_in
.color
= g_new(GdkColor
,1);
668 prop_line_in
.line_width
= 2;
669 prop_line_in
.style
= GDK_LINE_SOLID
;
670 prop_line_in
.position
= MIDDLE
;
672 /* color of line : status of the process */
673 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
675 prop_line_in
.color
->red
= 0xffff;
676 prop_line_in
.color
->green
= 0xffff;
677 prop_line_in
.color
->blue
= 0xffff;
679 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
681 prop_line_in
.color
->red
= 0x0fff;
682 prop_line_in
.color
->green
= 0xffff;
683 prop_line_in
.color
->blue
= 0xfff0;
685 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
687 prop_line_in
.color
->red
= 0xffff;
688 prop_line_in
.color
->green
= 0xffff;
689 prop_line_in
.color
->blue
= 0x0000;
691 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
693 prop_line_in
.color
->red
= 0xffff;
694 prop_line_in
.color
->green
= 0x0000;
695 prop_line_in
.color
->blue
= 0xffff;
697 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
699 prop_line_in
.color
->red
= 0xffff;
700 prop_line_in
.color
->green
= 0x0000;
701 prop_line_in
.color
->blue
= 0x0000;
703 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
705 prop_line_in
.color
->red
= 0x0000;
706 prop_line_in
.color
->green
= 0xffff;
707 prop_line_in
.color
->blue
= 0x0000;
711 prop_line_in
.color
->red
= 0xffff;
712 prop_line_in
.color
->green
= 0xffff;
713 prop_line_in
.color
->blue
= 0xffff;
716 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
717 g_free(prop_line_in
.color
);
718 gdk_gc_unref(draw_context_in
->gc
);
725 GString
*string
= g_string_new("");;
726 gboolean field_names
= TRUE
, state
= TRUE
;
728 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
729 g_string_append_printf(string
,"\n");
732 g_string_append_printf(string
, " %s",
733 g_quark_to_string(tfs
->process
->state
->s
));
736 g_info("%s",string
->str
);
738 g_string_free(string
, TRUE
);
740 /* End of text dump */
746 int draw_after_hook(void *hook_data
, void *call_data
)
748 EventRequest
*event_request
= (EventRequest
*)hook_data
;
749 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
751 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
753 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
754 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
760 LttTime evtime
= ltt_event_time(e
);
761 TimeWindow
*time_window
=
762 guicontrolflow_get_time_window(control_flow_data
);
764 LttTime end_time
= ltt_time_add(time_window
->start_time
,
765 time_window
->time_width
);
766 //if(time < time_beg || time > time_end) return;
767 if(ltt_time_compare(evtime
, time_window
->start_time
) == -1
768 || ltt_time_compare(evtime
, end_time
) == 1)
772 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
774 g_critical("schedchange!");
776 /* Add process to process list (if not present) and get drawing "y" from
777 * process position */
778 guint pid_out
, pid_in
;
779 LttvProcessState
*process_out
, *process_in
;
781 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
783 ProcessList
*process_list
=
784 guicontrolflow_get_process_list(event_request
->control_flow_data
);
787 LttField
*f
= ltt_event_field(e
);
789 element
= ltt_field_member(f
,0);
790 pid_out
= ltt_event_get_long_unsigned(e
,element
);
791 element
= ltt_field_member(f
,1);
792 pid_in
= ltt_event_get_long_unsigned(e
,element
);
793 //g_critical("out : %u in : %u", pid_out, pid_in);
796 /* Find process pid_out in the list... */
797 process_out
= lttv_state_find_process_from_trace(ts
, pid_out
);
798 if(process_out
== NULL
) return 0;
799 //g_critical("out : %s",g_quark_to_string(process_out->state->s));
801 birth
= process_out
->creation_time
;
802 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
803 HashedProcessData
*hashed_process_data_out
= NULL
;
805 if(processlist_get_process_pixels(process_list
,
808 tfc
->t_context
->index
,
811 &hashed_process_data_out
) == 1)
813 /* Process not present */
814 processlist_add(process_list
,
817 tfc
->t_context
->index
,
820 &hashed_process_data_out
);
821 processlist_get_process_pixels(process_list
,
824 tfc
->t_context
->index
,
827 &hashed_process_data_out
);
828 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
833 /* Find process pid_in in the list... */
834 process_in
= lttv_state_find_process_from_trace(ts
, pid_in
);
835 if(process_in
== NULL
) return 0;
836 //g_critical("in : %s",g_quark_to_string(process_in->state->s));
838 birth
= process_in
->creation_time
;
839 name
= strdup(g_quark_to_string(process_in
->name
));
840 HashedProcessData
*hashed_process_data_in
= NULL
;
842 if(processlist_get_process_pixels(process_list
,
845 tfc
->t_context
->index
,
848 &hashed_process_data_in
) == 1)
850 /* Process not present */
851 processlist_add(process_list
,
854 tfc
->t_context
->index
,
857 &hashed_process_data_in
);
858 processlist_get_process_pixels(process_list
,
861 tfc
->t_context
->index
,
864 &hashed_process_data_in
);
866 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
871 /* Find pixels corresponding to time of the event. If the time does
872 * not fit in the window, show a warning, not supposed to happend. */
874 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
876 //LttTime time = ltt_event_time(e);
878 //LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
879 // control_flow_data->time_window.start_time);
882 //convert_time_to_pixels(
883 // control_flow_data->time_window.start_time,
889 //assert(x <= width);
891 /* draw what represents the event for outgoing process. */
893 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
894 //draw_context_out->current->modify_over->x = x;
895 draw_context_out
->current
->modify_over
->y
= y_out
;
896 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
897 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
898 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
899 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
900 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
902 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
903 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
905 /*if(process_out->state->s == LTTV_STATE_RUN)
907 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
908 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
909 PropertiesBG prop_bg;
910 prop_bg.color = g_new(GdkColor,1);
912 prop_bg.color->red = 0xffff;
913 prop_bg.color->green = 0xffff;
914 prop_bg.color->blue = 0xffff;
916 draw_bg((void*)&prop_bg, (void*)draw_context_out);
917 g_free(prop_bg.color);
918 gdk_gc_unref(draw_context_out->gc);
921 draw_context_out
->gc
= widget
->style
->black_gc
;
923 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
924 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
925 PropertiesText prop_text_out
;
926 prop_text_out
.foreground
= &colorfg_out
;
927 prop_text_out
.background
= &colorbg_out
;
928 prop_text_out
.size
= 6;
929 prop_text_out
.position
= OVER
;
931 /* color of text : status of the process */
932 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
934 prop_text_out
.foreground
->red
= 0xffff;
935 prop_text_out
.foreground
->green
= 0xffff;
936 prop_text_out
.foreground
->blue
= 0xffff;
938 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
940 prop_text_out
.foreground
->red
= 0x0fff;
941 prop_text_out
.foreground
->green
= 0xffff;
942 prop_text_out
.foreground
->blue
= 0xfff0;
944 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
946 prop_text_out
.foreground
->red
= 0xffff;
947 prop_text_out
.foreground
->green
= 0xffff;
948 prop_text_out
.foreground
->blue
= 0x0000;
950 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
952 prop_text_out
.foreground
->red
= 0xffff;
953 prop_text_out
.foreground
->green
= 0x0000;
954 prop_text_out
.foreground
->blue
= 0xffff;
956 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
958 prop_text_out
.foreground
->red
= 0xffff;
959 prop_text_out
.foreground
->green
= 0x0000;
960 prop_text_out
.foreground
->blue
= 0x0000;
962 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
964 prop_text_out
.foreground
->red
= 0x0000;
965 prop_text_out
.foreground
->green
= 0xffff;
966 prop_text_out
.foreground
->blue
= 0x0000;
970 prop_text_out
.foreground
->red
= 0xffff;
971 prop_text_out
.foreground
->green
= 0xffff;
972 prop_text_out
.foreground
->blue
= 0xffff;
975 /* Print status of the process : U, WF, WC, E, W, R */
976 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
977 prop_text_out
.text
= "U";
978 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
979 prop_text_out
.text
= "WF";
980 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
981 prop_text_out
.text
= "WC";
982 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
983 prop_text_out
.text
= "E";
984 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
985 prop_text_out
.text
= "W";
986 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
987 prop_text_out
.text
= "R";
989 prop_text_out
.text
= "U";
991 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
993 //gdk_gc_unref(draw_context_out->gc);
995 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
996 draw_context_out
->current
->over
->y
= y_out
;
997 draw_context_out
->current
->under
->y
= y_out
+height
;
998 draw_context_out
->current
->status
= process_out
->state
->s
;
1000 /* for pid_out : remove previous, Prev = current, new current (default) */
1001 g_free(draw_context_out
->previous
->modify_under
);
1002 g_free(draw_context_out
->previous
->modify_middle
);
1003 g_free(draw_context_out
->previous
->modify_over
);
1004 g_free(draw_context_out
->previous
->under
);
1005 g_free(draw_context_out
->previous
->middle
);
1006 g_free(draw_context_out
->previous
->over
);
1007 g_free(draw_context_out
->previous
);
1009 draw_context_out
->previous
= draw_context_out
->current
;
1011 draw_context_out
->current
= g_new(DrawInfo
,1);
1012 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1013 draw_context_out
->current
->over
->x
= -1;
1014 draw_context_out
->current
->over
->y
= -1;
1015 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1016 draw_context_out
->current
->middle
->x
= -1;
1017 draw_context_out
->current
->middle
->y
= -1;
1018 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1019 draw_context_out
->current
->under
->x
= -1;
1020 draw_context_out
->current
->under
->y
= -1;
1021 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1022 draw_context_out
->current
->modify_over
->x
= -1;
1023 draw_context_out
->current
->modify_over
->y
= -1;
1024 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1025 draw_context_out
->current
->modify_middle
->x
= -1;
1026 draw_context_out
->current
->modify_middle
->y
= -1;
1027 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1028 draw_context_out
->current
->modify_under
->x
= -1;
1029 draw_context_out
->current
->modify_under
->y
= -1;
1030 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1032 /* Finally, update the drawing context of the pid_in. */
1034 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1035 //draw_context_in->current->modify_over->x = x;
1036 draw_context_in
->current
->modify_over
->y
= y_in
;
1037 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1038 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1039 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1040 widget
= control_flow_data
->drawing
->drawing_area
;
1041 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1043 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1044 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1046 /*if(process_in->state->s == LTTV_STATE_RUN)
1048 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1049 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1050 PropertiesBG prop_bg;
1051 prop_bg.color = g_new(GdkColor,1);
1053 prop_bg.color->red = 0xffff;
1054 prop_bg.color->green = 0xffff;
1055 prop_bg.color->blue = 0xffff;
1057 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1058 g_free(prop_bg.color);
1059 gdk_gc_unref(draw_context_in->gc);
1062 draw_context_in
->gc
= widget
->style
->black_gc
;
1064 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1065 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1066 PropertiesText prop_text_in
;
1067 prop_text_in
.foreground
= &colorfg_in
;
1068 prop_text_in
.background
= &colorbg_in
;
1069 prop_text_in
.size
= 6;
1070 prop_text_in
.position
= OVER
;
1072 /* foreground of text : status of the process */
1073 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1075 prop_text_in
.foreground
->red
= 0xffff;
1076 prop_text_in
.foreground
->green
= 0xffff;
1077 prop_text_in
.foreground
->blue
= 0xffff;
1079 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1081 prop_text_in
.foreground
->red
= 0x0fff;
1082 prop_text_in
.foreground
->green
= 0xffff;
1083 prop_text_in
.foreground
->blue
= 0xfff0;
1085 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1087 prop_text_in
.foreground
->red
= 0xffff;
1088 prop_text_in
.foreground
->green
= 0xffff;
1089 prop_text_in
.foreground
->blue
= 0x0000;
1091 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1093 prop_text_in
.foreground
->red
= 0xffff;
1094 prop_text_in
.foreground
->green
= 0x0000;
1095 prop_text_in
.foreground
->blue
= 0xffff;
1097 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1099 prop_text_in
.foreground
->red
= 0xffff;
1100 prop_text_in
.foreground
->green
= 0x0000;
1101 prop_text_in
.foreground
->blue
= 0x0000;
1103 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1105 prop_text_in
.foreground
->red
= 0x0000;
1106 prop_text_in
.foreground
->green
= 0xffff;
1107 prop_text_in
.foreground
->blue
= 0x0000;
1111 prop_text_in
.foreground
->red
= 0xffff;
1112 prop_text_in
.foreground
->green
= 0xffff;
1113 prop_text_in
.foreground
->blue
= 0xffff;
1117 /* Print status of the process : U, WF, WC, E, W, R */
1118 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1119 prop_text_in
.text
= "U";
1120 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1121 prop_text_in
.text
= "WF";
1122 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1123 prop_text_in
.text
= "WC";
1124 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1125 prop_text_in
.text
= "E";
1126 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1127 prop_text_in
.text
= "W";
1128 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1129 prop_text_in
.text
= "R";
1131 prop_text_in
.text
= "U";
1133 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1136 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1139 prop_text_in
.foreground
= &colorfg_in
;
1140 prop_text_in
.background
= &colorbg_in
;
1141 prop_text_in
.foreground
->red
= 0xffff;
1142 prop_text_in
.foreground
->green
= 0xffff;
1143 prop_text_in
.foreground
->blue
= 0xffff;
1144 prop_text_in
.size
= 6;
1145 prop_text_in
.position
= UNDER
;
1147 prop_text_in
.text
= g_new(gchar
, 260);
1148 strcpy(prop_text_in
.text
, "CPU ");
1149 snprintf(tmp
, 255, "%u", tfc
->index
);
1150 strcat(prop_text_in
.text
, tmp
);
1152 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1153 g_free(prop_text_in
.text
);
1157 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1158 draw_context_in
->current
->over
->y
= y_in
;
1159 draw_context_in
->current
->under
->y
= y_in
+height
;
1160 draw_context_in
->current
->status
= process_in
->state
->s
;
1162 /* for pid_in : remove previous, Prev = current, new current (default) */
1163 g_free(draw_context_in
->previous
->modify_under
);
1164 g_free(draw_context_in
->previous
->modify_middle
);
1165 g_free(draw_context_in
->previous
->modify_over
);
1166 g_free(draw_context_in
->previous
->under
);
1167 g_free(draw_context_in
->previous
->middle
);
1168 g_free(draw_context_in
->previous
->over
);
1169 g_free(draw_context_in
->previous
);
1171 draw_context_in
->previous
= draw_context_in
->current
;
1173 draw_context_in
->current
= g_new(DrawInfo
,1);
1174 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1175 draw_context_in
->current
->over
->x
= -1;
1176 draw_context_in
->current
->over
->y
= -1;
1177 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1178 draw_context_in
->current
->middle
->x
= -1;
1179 draw_context_in
->current
->middle
->y
= -1;
1180 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1181 draw_context_in
->current
->under
->x
= -1;
1182 draw_context_in
->current
->under
->y
= -1;
1183 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1184 draw_context_in
->current
->modify_over
->x
= -1;
1185 draw_context_in
->current
->modify_over
->y
= -1;
1186 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1187 draw_context_in
->current
->modify_middle
->x
= -1;
1188 draw_context_in
->current
->modify_middle
->y
= -1;
1189 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1190 draw_context_in
->current
->modify_under
->x
= -1;
1191 draw_context_in
->current
->modify_under
->y
= -1;
1192 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1202 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1204 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1205 TimeWindow
*old_time_window
=
1206 guicontrolflow_get_time_window(control_flow_data
);
1207 TimeWindow
*new_time_window
= ((TimeWindow
*)call_data
);
1209 /* Update the ruler */
1210 drawing_update_ruler(control_flow_data
->drawing
,
1214 /* Two cases : zoom in/out or scrolling */
1216 /* In order to make sure we can reuse the old drawing, the scale must
1217 * be the same and the new time interval being partly located in the
1218 * currently shown time interval. (reuse is only for scrolling)
1221 g_info("Old time window HOOK : %u, %u to %u, %u",
1222 old_time_window
->start_time
.tv_sec
,
1223 old_time_window
->start_time
.tv_nsec
,
1224 old_time_window
->time_width
.tv_sec
,
1225 old_time_window
->time_width
.tv_nsec
);
1227 g_info("New time window HOOK : %u, %u to %u, %u",
1228 new_time_window
->start_time
.tv_sec
,
1229 new_time_window
->start_time
.tv_nsec
,
1230 new_time_window
->time_width
.tv_sec
,
1231 new_time_window
->time_width
.tv_nsec
);
1233 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1234 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1236 /* Same scale (scrolling) */
1237 g_info("scrolling");
1238 LttTime
*ns
= &new_time_window
->start_time
;
1239 LttTime
*os
= &old_time_window
->start_time
;
1240 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
1241 old_time_window
->time_width
);
1242 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
1243 new_time_window
->time_width
);
1245 //if(ns<os+w && os+w<ns+w)
1246 //if(ns<old_end && os<ns)
1247 if(ltt_time_compare(*ns
, old_end
) == -1
1248 && ltt_time_compare(*os
, *ns
) == -1)
1250 g_info("scrolling near right");
1251 /* Scroll right, keep right part of the screen */
1253 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1254 convert_time_to_pixels(
1261 /* Copy old data to new location */
1262 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1263 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1264 control_flow_data
->drawing
->pixmap
,
1269 convert_time_to_pixels(
1276 *old_time_window
= *new_time_window
;
1277 /* Clear the data request background, but not SAFETY */
1278 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1279 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1282 control_flow_data
->drawing
->width
- x
, // do not overlap
1283 control_flow_data
->drawing
->height
+SAFETY
);
1284 /* Get new data for the rest. */
1285 drawing_data_request(control_flow_data
->drawing
,
1286 &control_flow_data
->drawing
->pixmap
,
1288 control_flow_data
->drawing
->width
- x
,
1289 control_flow_data
->drawing
->height
);
1291 drawing_refresh(control_flow_data
->drawing
,
1293 control_flow_data
->drawing
->width
,
1294 control_flow_data
->drawing
->height
);
1299 //if(ns<os && os<ns+w)
1300 //if(ns<os && os<new_end)
1301 if(ltt_time_compare(*ns
,*os
) == -1
1302 && ltt_time_compare(*os
,new_end
) == -1)
1304 g_info("scrolling near left");
1305 /* Scroll left, keep left part of the screen */
1307 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1308 convert_time_to_pixels(
1315 /* Copy old data to new location */
1316 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1317 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1318 control_flow_data
->drawing
->pixmap
,
1323 *old_time_window
= *new_time_window
;
1325 /* Clean the data request background */
1326 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1327 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1330 x
, // do not overlap
1331 control_flow_data
->drawing
->height
+SAFETY
);
1332 /* Get new data for the rest. */
1333 drawing_data_request(control_flow_data
->drawing
,
1334 &control_flow_data
->drawing
->pixmap
,
1337 control_flow_data
->drawing
->height
);
1339 drawing_refresh(control_flow_data
->drawing
,
1341 control_flow_data
->drawing
->width
,
1342 control_flow_data
->drawing
->height
);
1345 g_info("scrolling far");
1346 /* Cannot reuse any part of the screen : far jump */
1347 *old_time_window
= *new_time_window
;
1350 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1351 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1354 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1355 control_flow_data
->drawing
->height
+SAFETY
);
1357 drawing_data_request(control_flow_data
->drawing
,
1358 &control_flow_data
->drawing
->pixmap
,
1360 control_flow_data
->drawing
->width
,
1361 control_flow_data
->drawing
->height
);
1363 drawing_refresh(control_flow_data
->drawing
,
1365 control_flow_data
->drawing
->width
,
1366 control_flow_data
->drawing
->height
);
1370 /* Different scale (zoom) */
1373 *old_time_window
= *new_time_window
;
1375 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1376 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1379 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1380 control_flow_data
->drawing
->height
+SAFETY
);
1383 drawing_data_request(control_flow_data
->drawing
,
1384 &control_flow_data
->drawing
->pixmap
,
1386 control_flow_data
->drawing
->width
,
1387 control_flow_data
->drawing
->height
);
1389 drawing_refresh(control_flow_data
->drawing
,
1391 control_flow_data
->drawing
->width
,
1392 control_flow_data
->drawing
->height
);
1400 gint
update_current_time_hook(void *hook_data
, void *call_data
)
1402 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
1404 LttTime
* current_time
=
1405 guicontrolflow_get_current_time(control_flow_data
);
1406 *current_time
= *((LttTime
*)call_data
);
1408 TimeWindow time_window
;
1410 LttTime time_begin
= control_flow_data
->time_window
.start_time
;
1411 LttTime width
= control_flow_data
->time_window
.time_width
;
1412 LttTime half_width
= ltt_time_div(width
,2.0);
1413 LttTime time_end
= ltt_time_add(time_begin
, width
);
1415 LttvTracesetContext
* tsc
=
1416 get_traceset_context(control_flow_data
->mw
);
1418 LttTime trace_start
= tsc
->Time_Span
->startTime
;
1419 LttTime trace_end
= tsc
->Time_Span
->endTime
;
1421 g_info("New current time HOOK : %u, %u", current_time
->tv_sec
,
1422 current_time
->tv_nsec
);
1426 /* If current time is inside time interval, just move the highlight
1429 /* Else, we have to change the time interval. We have to tell it
1430 * to the main window. */
1431 /* The time interval change will take care of placing the current
1432 * time at the center of the visible area, or nearest possible if we are
1433 * at one end of the trace. */
1436 if(ltt_time_compare(*current_time
, time_begin
) == -1)
1438 if(ltt_time_compare(*current_time
,
1439 ltt_time_add(trace_start
,half_width
)) == -1)
1440 time_begin
= trace_start
;
1442 time_begin
= ltt_time_sub(*current_time
,half_width
);
1444 time_window
.start_time
= time_begin
;
1445 time_window
.time_width
= width
;
1447 set_time_window(control_flow_data
->mw
, &time_window
);
1449 else if(ltt_time_compare(*current_time
, time_end
) == 1)
1451 if(ltt_time_compare(*current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
1452 time_begin
= ltt_time_sub(trace_end
,width
);
1454 time_begin
= ltt_time_sub(*current_time
,half_width
);
1456 time_window
.start_time
= time_begin
;
1457 time_window
.time_width
= width
;
1459 set_time_window(control_flow_data
->mw
, &time_window
);
1462 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
1467 typedef struct _ClosureData
{
1468 EventRequest
*event_request
;
1469 LttvTracesetState
*tss
;
1473 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1475 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
1476 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
1477 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1479 ControlFlowData
*control_flow_data
=
1480 closure_data
->event_request
->control_flow_data
;
1482 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1484 /* Get y position of process */
1487 processlist_get_pixels_from_data( control_flow_data
->process_list
,
1489 hashed_process_data
,
1492 /* Get last state of process */
1493 LttvTraceContext
*tc
=
1494 ((LttvTracesetContext
*)closure_data
->tss
)->traces
[process_info
->trace_num
];
1495 //LttvTracefileContext *tfc = (LttvTracefileContext *)closure_data->ts;
1497 LttvTraceState
*ts
= (LttvTraceState
*)tc
;
1498 LttvProcessState
*process
;
1500 process
= lttv_state_find_process_from_trace(ts
, process_info
->pid
);
1502 /* Draw the closing line */
1503 DrawContext
*draw_context
= hashed_process_data
->draw_context
;
1504 if(draw_context
->previous
->middle
->x
== -1)
1506 draw_context
->previous
->middle
->x
= closure_data
->event_request
->x_begin
;
1507 draw_context
->previous
->over
->x
= closure_data
->event_request
->x_begin
;
1508 draw_context
->previous
->under
->x
= closure_data
->event_request
->x_begin
;
1509 g_critical("out middle x_beg : %u",closure_data
->event_request
->x_begin
);
1512 draw_context
->current
->middle
->x
= closure_data
->event_request
->x_end
;
1513 draw_context
->current
->over
->x
= closure_data
->event_request
->x_end
;
1514 draw_context
->current
->under
->x
= closure_data
->event_request
->x_end
;
1515 draw_context
->current
->middle
->y
= y
+ height
/2;
1516 draw_context
->current
->over
->y
= y
;
1517 draw_context
->current
->under
->y
= y
+ height
;
1518 draw_context
->previous
->middle
->y
= y
+ height
/2;
1519 draw_context
->previous
->over
->y
= y
;
1520 draw_context
->previous
->under
->y
= y
+ height
;
1521 draw_context
->drawable
= control_flow_data
->drawing
->pixmap
;
1522 draw_context
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1523 //draw_context->gc = widget->style->black_gc;
1524 draw_context
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
1525 gdk_gc_copy(draw_context
->gc
, widget
->style
->black_gc
);
1527 if(process
!= NULL
&& process
->state
->s
== LTTV_STATE_RUN
)
1529 PropertiesBG prop_bg
;
1530 prop_bg
.color
= g_new(GdkColor
,1);
1532 /*switch(tfc->index) {
1534 prop_bg.color->red = 0x1515;
1535 prop_bg.color->green = 0x1515;
1536 prop_bg.color->blue = 0x8c8c;
1539 prop_bg.color->red = 0x4e4e;
1540 prop_bg.color->green = 0xa9a9;
1541 prop_bg.color->blue = 0xa4a4;
1544 prop_bg.color->red = 0x7a7a;
1545 prop_bg.color->green = 0x4a4a;
1546 prop_bg.color->blue = 0x8b8b;
1549 prop_bg.color->red = 0x8080;
1550 prop_bg.color->green = 0x7777;
1551 prop_bg.color->blue = 0x4747;
1554 prop_bg.color->red = 0xe7e7;
1555 prop_bg.color->green = 0xe7e7;
1556 prop_bg.color->blue = 0xe7e7;
1560 g_critical("calling from closure");
1561 //FIXME : I need the cpu number in process's state to draw this.
1562 //draw_bg((void*)&prop_bg, (void*)draw_context);
1563 g_free(prop_bg
.color
);
1567 PropertiesLine prop_line
;
1568 prop_line
.color
= g_new(GdkColor
,1);
1569 prop_line
.line_width
= 2;
1570 prop_line
.style
= GDK_LINE_SOLID
;
1571 prop_line
.position
= MIDDLE
;
1573 /* color of line : status of the process */
1576 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
1578 prop_line
.color
->red
= 0xffff;
1579 prop_line
.color
->green
= 0xffff;
1580 prop_line
.color
->blue
= 0xffff;
1582 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
1584 prop_line
.color
->red
= 0x0fff;
1585 prop_line
.color
->green
= 0xffff;
1586 prop_line
.color
->blue
= 0xfff0;
1588 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
1590 prop_line
.color
->red
= 0xffff;
1591 prop_line
.color
->green
= 0xffff;
1592 prop_line
.color
->blue
= 0x0000;
1594 else if(process
->state
->s
== LTTV_STATE_EXIT
)
1596 prop_line
.color
->red
= 0xffff;
1597 prop_line
.color
->green
= 0x0000;
1598 prop_line
.color
->blue
= 0xffff;
1600 else if(process
->state
->s
== LTTV_STATE_WAIT
)
1602 prop_line
.color
->red
= 0xffff;
1603 prop_line
.color
->green
= 0x0000;
1604 prop_line
.color
->blue
= 0x0000;
1606 else if(process
->state
->s
== LTTV_STATE_RUN
)
1608 prop_line
.color
->red
= 0x0000;
1609 prop_line
.color
->green
= 0xffff;
1610 prop_line
.color
->blue
= 0x0000;
1614 prop_line
.color
->red
= 0xffff;
1615 prop_line
.color
->green
= 0xffff;
1616 prop_line
.color
->blue
= 0xffff;
1622 prop_line
.color
->red
= 0xffff;
1623 prop_line
.color
->green
= 0xffff;
1624 prop_line
.color
->blue
= 0xffff;
1627 draw_line((void*)&prop_line
, (void*)draw_context
);
1628 g_free(prop_line
.color
);
1629 gdk_gc_unref(draw_context
->gc
);
1631 /* Reset draw_context of the process for next request */
1633 hashed_process_data
->draw_context
->drawable
= NULL
;
1634 hashed_process_data
->draw_context
->gc
= NULL
;
1635 hashed_process_data
->draw_context
->pango_layout
= NULL
;
1636 hashed_process_data
->draw_context
->current
->over
->x
= -1;
1637 hashed_process_data
->draw_context
->current
->over
->y
= -1;
1638 hashed_process_data
->draw_context
->current
->middle
->x
= -1;
1639 hashed_process_data
->draw_context
->current
->middle
->y
= -1;
1640 hashed_process_data
->draw_context
->current
->under
->x
= -1;
1641 hashed_process_data
->draw_context
->current
->under
->y
= -1;
1642 hashed_process_data
->draw_context
->current
->modify_over
->x
= -1;
1643 hashed_process_data
->draw_context
->current
->modify_over
->y
= -1;
1644 hashed_process_data
->draw_context
->current
->modify_middle
->x
= -1;
1645 hashed_process_data
->draw_context
->current
->modify_middle
->y
= -1;
1646 hashed_process_data
->draw_context
->current
->modify_under
->x
= -1;
1647 hashed_process_data
->draw_context
->current
->modify_under
->y
= -1;
1648 hashed_process_data
->draw_context
->current
->status
= LTTV_STATE_UNNAMED
;
1649 hashed_process_data
->draw_context
->previous
->over
->x
= -1;
1650 hashed_process_data
->draw_context
->previous
->over
->y
= -1;
1651 hashed_process_data
->draw_context
->previous
->middle
->x
= -1;
1652 hashed_process_data
->draw_context
->previous
->middle
->y
= -1;
1653 hashed_process_data
->draw_context
->previous
->under
->x
= -1;
1654 hashed_process_data
->draw_context
->previous
->under
->y
= -1;
1655 hashed_process_data
->draw_context
->previous
->modify_over
->x
= -1;
1656 hashed_process_data
->draw_context
->previous
->modify_over
->y
= -1;
1657 hashed_process_data
->draw_context
->previous
->modify_middle
->x
= -1;
1658 hashed_process_data
->draw_context
->previous
->modify_middle
->y
= -1;
1659 hashed_process_data
->draw_context
->previous
->modify_under
->x
= -1;
1660 hashed_process_data
->draw_context
->previous
->modify_under
->y
= -1;
1661 hashed_process_data
->draw_context
->previous
->status
= LTTV_STATE_UNNAMED
;
1669 * new default prev and current
1671 int after_data_request(void *hook_data
, void *call_data
)
1673 EventRequest
*event_request
= (EventRequest
*)hook_data
;
1674 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
1676 ProcessList
*process_list
=
1677 guicontrolflow_get_process_list(event_request
->control_flow_data
);
1679 ClosureData closure_data
;
1680 closure_data
.event_request
= (EventRequest
*)hook_data
;
1681 closure_data
.tss
= (LttvTracesetState
*)call_data
;
1683 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
1684 (void*)&closure_data
);