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 process_out
= lttv_state_find_process(tfs
, pid_out
);
198 if(process_out
== NULL
) return 0;
199 g_critical("out : %s",g_quark_to_string(process_out
->state
->s
));
201 birth
= process_out
->creation_time
;
202 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
203 HashedProcessData
*hashed_process_data_out
= NULL
;
205 if(processlist_get_process_pixels(process_list
,
208 tfc
->t_context
->index
,
211 &hashed_process_data_out
) == 1)
213 /* Process not present */
214 processlist_add(process_list
,
217 tfc
->t_context
->index
,
220 &hashed_process_data_out
);
221 processlist_get_process_pixels(process_list
,
224 tfc
->t_context
->index
,
227 &hashed_process_data_out
);
228 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
233 /* Find process pid_in in the list... */
234 //process_in = lttv_state_find_process_from_trace(ts, pid_in);
235 process_in
= lttv_state_find_process(tfs
, pid_in
);
236 if(process_in
== NULL
) return 0;
237 g_critical("in : %s",g_quark_to_string(process_in
->state
->s
));
239 birth
= process_in
->creation_time
;
240 name
= strdup(g_quark_to_string(process_in
->name
));
241 HashedProcessData
*hashed_process_data_in
= NULL
;
243 if(processlist_get_process_pixels(process_list
,
246 tfc
->t_context
->index
,
249 &hashed_process_data_in
) == 1)
251 /* Process not present */
252 processlist_add(process_list
,
255 tfc
->t_context
->index
,
258 &hashed_process_data_in
);
259 processlist_get_process_pixels(process_list
,
262 tfc
->t_context
->index
,
265 &hashed_process_data_in
);
267 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
272 /* Find pixels corresponding to time of the event. If the time does
273 * not fit in the window, show a warning, not supposed to happend. */
275 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
277 LttTime time
= ltt_event_time(e
);
279 LttTime window_end
= ltt_time_add(control_flow_data
->time_window
.time_width
,
280 control_flow_data
->time_window
.start_time
);
283 convert_time_to_pixels(
284 control_flow_data
->time_window
.start_time
,
289 //assert(x <= width);
291 /* draw what represents the event for outgoing process. */
293 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
294 draw_context_out
->current
->modify_over
->x
= x
;
295 draw_context_out
->current
->modify_under
->x
= x
;
296 draw_context_out
->current
->modify_over
->y
= y_out
;
297 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
298 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
299 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
300 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
301 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
302 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
303 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
304 //draw_context_out->gc = widget->style->black_gc;
306 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
307 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
309 /* Draw the line/background of the out process */
310 if(draw_context_out
->previous
->middle
->x
== -1)
312 draw_context_out
->previous
->over
->x
= event_request
->x_begin
;
313 draw_context_out
->previous
->middle
->x
= event_request
->x_begin
;
314 draw_context_out
->previous
->under
->x
= event_request
->x_begin
;
316 g_critical("out middle x_beg : %u",event_request
->x_begin
);
319 draw_context_out
->current
->middle
->x
= x
;
320 draw_context_out
->current
->over
->x
= x
;
321 draw_context_out
->current
->under
->x
= x
;
322 draw_context_out
->current
->middle
->y
= y_out
+ height
/2;
323 draw_context_out
->current
->over
->y
= y_out
;
324 draw_context_out
->current
->under
->y
= y_out
+ height
;
325 draw_context_out
->previous
->middle
->y
= y_out
+ height
/2;
326 draw_context_out
->previous
->over
->y
= y_out
;
327 draw_context_out
->previous
->under
->y
= y_out
+ height
;
329 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
330 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
332 if(process_out
->state
->s
== LTTV_STATE_RUN
)
334 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
335 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
337 PropertiesBG prop_bg
;
338 prop_bg
.color
= g_new(GdkColor
,1);
342 prop_bg
.color
->red
= 0x1515;
343 prop_bg
.color
->green
= 0x1515;
344 prop_bg
.color
->blue
= 0x8c8c;
347 prop_bg
.color
->red
= 0x4e4e;
348 prop_bg
.color
->green
= 0xa9a9;
349 prop_bg
.color
->blue
= 0xa4a4;
352 prop_bg
.color
->red
= 0x7a7a;
353 prop_bg
.color
->green
= 0x4a4a;
354 prop_bg
.color
->blue
= 0x8b8b;
357 prop_bg
.color
->red
= 0x8080;
358 prop_bg
.color
->green
= 0x7777;
359 prop_bg
.color
->blue
= 0x4747;
362 prop_bg
.color
->red
= 0xe7e7;
363 prop_bg
.color
->green
= 0xe7e7;
364 prop_bg
.color
->blue
= 0xe7e7;
367 g_critical("calling from draw_event");
368 draw_bg((void*)&prop_bg
, (void*)draw_context_out
);
369 g_free(prop_bg
.color
);
370 gdk_gc_unref(draw_context_out
->gc
);
373 draw_context_out
->gc
= widget
->style
->black_gc
;
375 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
376 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
377 PropertiesText prop_text_out
;
378 prop_text_out
.foreground
= &colorfg_out
;
379 prop_text_out
.background
= &colorbg_out
;
380 prop_text_out
.size
= 6;
381 prop_text_out
.position
= OVER
;
383 /* color of text : status of the process */
384 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
386 prop_text_out
.foreground
->red
= 0xffff;
387 prop_text_out
.foreground
->green
= 0xffff;
388 prop_text_out
.foreground
->blue
= 0xffff;
390 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
392 prop_text_out
.foreground
->red
= 0x0fff;
393 prop_text_out
.foreground
->green
= 0xffff;
394 prop_text_out
.foreground
->blue
= 0xfff0;
396 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
398 prop_text_out
.foreground
->red
= 0xffff;
399 prop_text_out
.foreground
->green
= 0xffff;
400 prop_text_out
.foreground
->blue
= 0x0000;
402 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
404 prop_text_out
.foreground
->red
= 0xffff;
405 prop_text_out
.foreground
->green
= 0x0000;
406 prop_text_out
.foreground
->blue
= 0xffff;
408 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
410 prop_text_out
.foreground
->red
= 0xffff;
411 prop_text_out
.foreground
->green
= 0x0000;
412 prop_text_out
.foreground
->blue
= 0x0000;
414 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
416 prop_text_out
.foreground
->red
= 0x0000;
417 prop_text_out
.foreground
->green
= 0xffff;
418 prop_text_out
.foreground
->blue
= 0x0000;
422 prop_text_out
.foreground
->red
= 0xffff;
423 prop_text_out
.foreground
->green
= 0xffff;
424 prop_text_out
.foreground
->blue
= 0xffff;
428 /* Print status of the process : U, WF, WC, E, W, R */
429 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
430 prop_text_out
.text
= "U->";
431 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
432 prop_text_out
.text
= "WF->";
433 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
434 prop_text_out
.text
= "WC->";
435 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
436 prop_text_out
.text
= "E->";
437 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
438 prop_text_out
.text
= "W->";
439 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
440 prop_text_out
.text
= "R->";
442 prop_text_out
.text
= "U";
444 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
445 //gdk_gc_unref(draw_context_out->gc);
447 draw_context_out
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
448 gdk_gc_copy(draw_context_out
->gc
, widget
->style
->black_gc
);
450 PropertiesLine prop_line_out
;
451 prop_line_out
.color
= g_new(GdkColor
,1);
452 prop_line_out
.line_width
= 2;
453 prop_line_out
.style
= GDK_LINE_SOLID
;
454 prop_line_out
.position
= MIDDLE
;
456 g_critical("out state : %s", g_quark_to_string(process_out
->state
->s
));
458 /* color of line : status of the process */
459 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
461 prop_line_out
.color
->red
= 0xffff;
462 prop_line_out
.color
->green
= 0xffff;
463 prop_line_out
.color
->blue
= 0xffff;
465 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
467 prop_line_out
.color
->red
= 0x0fff;
468 prop_line_out
.color
->green
= 0xffff;
469 prop_line_out
.color
->blue
= 0xfff0;
471 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
473 prop_line_out
.color
->red
= 0xffff;
474 prop_line_out
.color
->green
= 0xffff;
475 prop_line_out
.color
->blue
= 0x0000;
477 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
479 prop_line_out
.color
->red
= 0xffff;
480 prop_line_out
.color
->green
= 0x0000;
481 prop_line_out
.color
->blue
= 0xffff;
483 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
485 prop_line_out
.color
->red
= 0xffff;
486 prop_line_out
.color
->green
= 0x0000;
487 prop_line_out
.color
->blue
= 0x0000;
489 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
491 prop_line_out
.color
->red
= 0x0000;
492 prop_line_out
.color
->green
= 0xffff;
493 prop_line_out
.color
->blue
= 0x0000;
497 prop_line_out
.color
->red
= 0xffff;
498 prop_line_out
.color
->green
= 0xffff;
499 prop_line_out
.color
->blue
= 0xffff;
502 draw_line((void*)&prop_line_out
, (void*)draw_context_out
);
503 g_free(prop_line_out
.color
);
504 gdk_gc_unref(draw_context_out
->gc
);
505 /* Note : finishing line will have to be added when trace read over. */
507 /* Finally, update the drawing context of the pid_in. */
509 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
510 draw_context_in
->current
->modify_over
->x
= x
;
511 draw_context_in
->current
->modify_under
->x
= x
;
512 draw_context_in
->current
->modify_over
->y
= y_in
;
513 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
514 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
515 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
516 widget
= control_flow_data
->drawing
->drawing_area
;
517 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
518 //draw_context_in->gc = widget->style->black_gc;
519 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
520 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
522 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
523 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
525 /* Draw the line/bg of the in process */
526 if(draw_context_in
->previous
->middle
->x
== -1)
528 draw_context_in
->previous
->middle
->x
= event_request
->x_begin
;
529 draw_context_in
->previous
->over
->x
= event_request
->x_begin
;
530 draw_context_in
->previous
->under
->x
= event_request
->x_begin
;
531 g_critical("in middle x_beg : %u",event_request
->x_begin
);
534 draw_context_in
->current
->middle
->x
= x
;
535 draw_context_in
->current
->over
->x
= x
;
536 draw_context_in
->current
->under
->x
= x
;
537 draw_context_in
->current
->middle
->y
= y_in
+ height
/2;
538 draw_context_in
->current
->over
->y
= y_in
;
539 draw_context_in
->current
->under
->y
= y_in
+ height
;
540 draw_context_in
->previous
->middle
->y
= y_in
+ height
/2;
541 draw_context_in
->previous
->over
->y
= y_in
;
542 draw_context_in
->previous
->under
->y
= y_in
+ height
;
544 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
545 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
548 if(process_in
->state
->s
== LTTV_STATE_RUN
)
550 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
551 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
553 PropertiesBG prop_bg
;
554 prop_bg
.color
= g_new(GdkColor
,1);
558 prop_bg
.color
->red
= 0x1515;
559 prop_bg
.color
->green
= 0x1515;
560 prop_bg
.color
->blue
= 0x8c8c;
563 prop_bg
.color
->red
= 0x4e4e;
564 prop_bg
.color
->green
= 0xa9a9;
565 prop_bg
.color
->blue
= 0xa4a4;
568 prop_bg
.color
->red
= 0x7a7a;
569 prop_bg
.color
->green
= 0x4a4a;
570 prop_bg
.color
->blue
= 0x8b8b;
573 prop_bg
.color
->red
= 0x8080;
574 prop_bg
.color
->green
= 0x7777;
575 prop_bg
.color
->blue
= 0x4747;
578 prop_bg
.color
->red
= 0xe7e7;
579 prop_bg
.color
->green
= 0xe7e7;
580 prop_bg
.color
->blue
= 0xe7e7;
584 draw_bg((void*)&prop_bg
, (void*)draw_context_in
);
585 g_free(prop_bg
.color
);
586 gdk_gc_unref(draw_context_in
->gc
);
589 draw_context_in
->gc
= widget
->style
->black_gc
;
591 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
592 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
593 PropertiesText prop_text_in
;
594 prop_text_in
.foreground
= &colorfg_in
;
595 prop_text_in
.background
= &colorbg_in
;
596 prop_text_in
.size
= 6;
597 prop_text_in
.position
= OVER
;
599 g_critical("in state : %s", g_quark_to_string(process_in
->state
->s
));
600 /* foreground of text : status of the process */
601 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
603 prop_text_in
.foreground
->red
= 0xffff;
604 prop_text_in
.foreground
->green
= 0xffff;
605 prop_text_in
.foreground
->blue
= 0xffff;
607 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
609 prop_text_in
.foreground
->red
= 0x0fff;
610 prop_text_in
.foreground
->green
= 0xffff;
611 prop_text_in
.foreground
->blue
= 0xfff0;
613 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
615 prop_text_in
.foreground
->red
= 0xffff;
616 prop_text_in
.foreground
->green
= 0xffff;
617 prop_text_in
.foreground
->blue
= 0x0000;
619 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
621 prop_text_in
.foreground
->red
= 0xffff;
622 prop_text_in
.foreground
->green
= 0x0000;
623 prop_text_in
.foreground
->blue
= 0xffff;
625 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
627 prop_text_in
.foreground
->red
= 0xffff;
628 prop_text_in
.foreground
->green
= 0x0000;
629 prop_text_in
.foreground
->blue
= 0x0000;
631 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
633 prop_text_in
.foreground
->red
= 0x0000;
634 prop_text_in
.foreground
->green
= 0xffff;
635 prop_text_in
.foreground
->blue
= 0x0000;
639 prop_text_in
.foreground
->red
= 0xffff;
640 prop_text_in
.foreground
->green
= 0xffff;
641 prop_text_in
.foreground
->blue
= 0xffff;
646 /* Print status of the process : U, WF, WC, E, W, R */
647 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
648 prop_text_in
.text
= "U->";
649 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
650 prop_text_in
.text
= "WF->";
651 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
652 prop_text_in
.text
= "WC->";
653 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
654 prop_text_in
.text
= "E->";
655 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
656 prop_text_in
.text
= "W->";
657 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
658 prop_text_in
.text
= "R->";
660 prop_text_in
.text
= "U";
662 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
663 //gdk_gc_unref(draw_context_in->gc);
665 draw_context_in
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
666 gdk_gc_copy(draw_context_in
->gc
, widget
->style
->black_gc
);
668 PropertiesLine prop_line_in
;
669 prop_line_in
.color
= g_new(GdkColor
,1);
670 prop_line_in
.line_width
= 2;
671 prop_line_in
.style
= GDK_LINE_SOLID
;
672 prop_line_in
.position
= MIDDLE
;
674 /* color of line : status of the process */
675 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
677 prop_line_in
.color
->red
= 0xffff;
678 prop_line_in
.color
->green
= 0xffff;
679 prop_line_in
.color
->blue
= 0xffff;
681 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
683 prop_line_in
.color
->red
= 0x0fff;
684 prop_line_in
.color
->green
= 0xffff;
685 prop_line_in
.color
->blue
= 0xfff0;
687 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
689 prop_line_in
.color
->red
= 0xffff;
690 prop_line_in
.color
->green
= 0xffff;
691 prop_line_in
.color
->blue
= 0x0000;
693 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
695 prop_line_in
.color
->red
= 0xffff;
696 prop_line_in
.color
->green
= 0x0000;
697 prop_line_in
.color
->blue
= 0xffff;
699 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
701 prop_line_in
.color
->red
= 0xffff;
702 prop_line_in
.color
->green
= 0x0000;
703 prop_line_in
.color
->blue
= 0x0000;
705 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
707 prop_line_in
.color
->red
= 0x0000;
708 prop_line_in
.color
->green
= 0xffff;
709 prop_line_in
.color
->blue
= 0x0000;
713 prop_line_in
.color
->red
= 0xffff;
714 prop_line_in
.color
->green
= 0xffff;
715 prop_line_in
.color
->blue
= 0xffff;
718 draw_line((void*)&prop_line_in
, (void*)draw_context_in
);
719 g_free(prop_line_in
.color
);
720 gdk_gc_unref(draw_context_in
->gc
);
727 GString
*string
= g_string_new("");;
728 gboolean field_names
= TRUE
, state
= TRUE
;
730 lttv_event_to_string(e
, tfc
->tf
, string
, TRUE
, field_names
, tfs
);
731 g_string_append_printf(string
,"\n");
734 g_string_append_printf(string
, " %s",
735 g_quark_to_string(tfs
->process
->state
->s
));
738 g_info("%s",string
->str
);
740 g_string_free(string
, TRUE
);
742 /* End of text dump */
748 int draw_after_hook(void *hook_data
, void *call_data
)
750 EventRequest
*event_request
= (EventRequest
*)hook_data
;
751 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
753 LttvTracefileContext
*tfc
= (LttvTracefileContext
*)call_data
;
755 LttvTracefileState
*tfs
= (LttvTracefileState
*)call_data
;
756 LttvTraceState
*ts
=(LttvTraceState
*)LTTV_TRACEFILE_CONTEXT(tfs
)->t_context
;
762 LttTime evtime
= ltt_event_time(e
);
763 TimeWindow
*time_window
=
764 guicontrolflow_get_time_window(control_flow_data
);
766 LttTime end_time
= ltt_time_add(time_window
->start_time
,
767 time_window
->time_width
);
768 //if(time < time_beg || time > time_end) return;
769 if(ltt_time_compare(evtime
, time_window
->start_time
) == -1
770 || ltt_time_compare(evtime
, end_time
) == 1)
774 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e
)),"schedchange") == 0)
776 g_critical("schedchange!");
778 /* Add process to process list (if not present) and get drawing "y" from
779 * process position */
780 guint pid_out
, pid_in
;
781 LttvProcessState
*process_out
, *process_in
;
783 guint y_in
= 0, y_out
= 0, height
= 0, pl_height
= 0;
785 ProcessList
*process_list
=
786 guicontrolflow_get_process_list(event_request
->control_flow_data
);
789 LttField
*f
= ltt_event_field(e
);
791 element
= ltt_field_member(f
,0);
792 pid_out
= ltt_event_get_long_unsigned(e
,element
);
793 element
= ltt_field_member(f
,1);
794 pid_in
= ltt_event_get_long_unsigned(e
,element
);
795 //g_critical("out : %u in : %u", pid_out, pid_in);
798 /* Find process pid_out in the list... */
799 process_out
= lttv_state_find_process_from_trace(ts
, pid_out
);
800 if(process_out
== NULL
) return 0;
801 //g_critical("out : %s",g_quark_to_string(process_out->state->s));
803 birth
= process_out
->creation_time
;
804 gchar
*name
= strdup(g_quark_to_string(process_out
->name
));
805 HashedProcessData
*hashed_process_data_out
= NULL
;
807 if(processlist_get_process_pixels(process_list
,
810 tfc
->t_context
->index
,
813 &hashed_process_data_out
) == 1)
815 /* Process not present */
816 processlist_add(process_list
,
819 tfc
->t_context
->index
,
822 &hashed_process_data_out
);
823 processlist_get_process_pixels(process_list
,
826 tfc
->t_context
->index
,
829 &hashed_process_data_out
);
830 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_out
, height
);
835 /* Find process pid_in in the list... */
836 process_in
= lttv_state_find_process_from_trace(ts
, pid_in
);
837 if(process_in
== NULL
) return 0;
838 //g_critical("in : %s",g_quark_to_string(process_in->state->s));
840 birth
= process_in
->creation_time
;
841 name
= strdup(g_quark_to_string(process_in
->name
));
842 HashedProcessData
*hashed_process_data_in
= NULL
;
844 if(processlist_get_process_pixels(process_list
,
847 tfc
->t_context
->index
,
850 &hashed_process_data_in
) == 1)
852 /* Process not present */
853 processlist_add(process_list
,
856 tfc
->t_context
->index
,
859 &hashed_process_data_in
);
860 processlist_get_process_pixels(process_list
,
863 tfc
->t_context
->index
,
866 &hashed_process_data_in
);
868 drawing_insert_square( event_request
->control_flow_data
->drawing
, y_in
, height
);
873 /* Find pixels corresponding to time of the event. If the time does
874 * not fit in the window, show a warning, not supposed to happend. */
876 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
878 //LttTime time = ltt_event_time(e);
880 //LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
881 // control_flow_data->time_window.start_time);
884 //convert_time_to_pixels(
885 // control_flow_data->time_window.start_time,
891 //assert(x <= width);
893 /* draw what represents the event for outgoing process. */
895 DrawContext
*draw_context_out
= hashed_process_data_out
->draw_context
;
896 //draw_context_out->current->modify_over->x = x;
897 draw_context_out
->current
->modify_over
->y
= y_out
;
898 draw_context_out
->current
->modify_under
->y
= y_out
+(height
/2)+2;
899 draw_context_out
->drawable
= control_flow_data
->drawing
->pixmap
;
900 draw_context_out
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
901 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
902 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
904 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
905 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
907 /*if(process_out->state->s == LTTV_STATE_RUN)
909 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
910 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
911 PropertiesBG prop_bg;
912 prop_bg.color = g_new(GdkColor,1);
914 prop_bg.color->red = 0xffff;
915 prop_bg.color->green = 0xffff;
916 prop_bg.color->blue = 0xffff;
918 draw_bg((void*)&prop_bg, (void*)draw_context_out);
919 g_free(prop_bg.color);
920 gdk_gc_unref(draw_context_out->gc);
923 draw_context_out
->gc
= widget
->style
->black_gc
;
925 GdkColor colorfg_out
= { 0, 0xffff, 0x0000, 0x0000 };
926 GdkColor colorbg_out
= { 0, 0x0000, 0x0000, 0x0000 };
927 PropertiesText prop_text_out
;
928 prop_text_out
.foreground
= &colorfg_out
;
929 prop_text_out
.background
= &colorbg_out
;
930 prop_text_out
.size
= 6;
931 prop_text_out
.position
= OVER
;
933 /* color of text : status of the process */
934 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
936 prop_text_out
.foreground
->red
= 0xffff;
937 prop_text_out
.foreground
->green
= 0xffff;
938 prop_text_out
.foreground
->blue
= 0xffff;
940 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
942 prop_text_out
.foreground
->red
= 0x0fff;
943 prop_text_out
.foreground
->green
= 0xffff;
944 prop_text_out
.foreground
->blue
= 0xfff0;
946 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
948 prop_text_out
.foreground
->red
= 0xffff;
949 prop_text_out
.foreground
->green
= 0xffff;
950 prop_text_out
.foreground
->blue
= 0x0000;
952 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
954 prop_text_out
.foreground
->red
= 0xffff;
955 prop_text_out
.foreground
->green
= 0x0000;
956 prop_text_out
.foreground
->blue
= 0xffff;
958 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
960 prop_text_out
.foreground
->red
= 0xffff;
961 prop_text_out
.foreground
->green
= 0x0000;
962 prop_text_out
.foreground
->blue
= 0x0000;
964 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
966 prop_text_out
.foreground
->red
= 0x0000;
967 prop_text_out
.foreground
->green
= 0xffff;
968 prop_text_out
.foreground
->blue
= 0x0000;
972 prop_text_out
.foreground
->red
= 0xffff;
973 prop_text_out
.foreground
->green
= 0xffff;
974 prop_text_out
.foreground
->blue
= 0xffff;
977 /* Print status of the process : U, WF, WC, E, W, R */
978 if(process_out
->state
->s
== LTTV_STATE_UNNAMED
)
979 prop_text_out
.text
= "U";
980 else if(process_out
->state
->s
== LTTV_STATE_WAIT_FORK
)
981 prop_text_out
.text
= "WF";
982 else if(process_out
->state
->s
== LTTV_STATE_WAIT_CPU
)
983 prop_text_out
.text
= "WC";
984 else if(process_out
->state
->s
== LTTV_STATE_EXIT
)
985 prop_text_out
.text
= "E";
986 else if(process_out
->state
->s
== LTTV_STATE_WAIT
)
987 prop_text_out
.text
= "W";
988 else if(process_out
->state
->s
== LTTV_STATE_RUN
)
989 prop_text_out
.text
= "R";
991 prop_text_out
.text
= "U";
993 draw_text((void*)&prop_text_out
, (void*)draw_context_out
);
995 //gdk_gc_unref(draw_context_out->gc);
997 draw_context_out
->current
->middle
->y
= y_out
+height
/2;
998 draw_context_out
->current
->over
->y
= y_out
;
999 draw_context_out
->current
->under
->y
= y_out
+height
;
1000 draw_context_out
->current
->status
= process_out
->state
->s
;
1002 /* for pid_out : remove previous, Prev = current, new current (default) */
1003 g_free(draw_context_out
->previous
->modify_under
);
1004 g_free(draw_context_out
->previous
->modify_middle
);
1005 g_free(draw_context_out
->previous
->modify_over
);
1006 g_free(draw_context_out
->previous
->under
);
1007 g_free(draw_context_out
->previous
->middle
);
1008 g_free(draw_context_out
->previous
->over
);
1009 g_free(draw_context_out
->previous
);
1011 draw_context_out
->previous
= draw_context_out
->current
;
1013 draw_context_out
->current
= g_new(DrawInfo
,1);
1014 draw_context_out
->current
->over
= g_new(ItemInfo
,1);
1015 draw_context_out
->current
->over
->x
= -1;
1016 draw_context_out
->current
->over
->y
= -1;
1017 draw_context_out
->current
->middle
= g_new(ItemInfo
,1);
1018 draw_context_out
->current
->middle
->x
= -1;
1019 draw_context_out
->current
->middle
->y
= -1;
1020 draw_context_out
->current
->under
= g_new(ItemInfo
,1);
1021 draw_context_out
->current
->under
->x
= -1;
1022 draw_context_out
->current
->under
->y
= -1;
1023 draw_context_out
->current
->modify_over
= g_new(ItemInfo
,1);
1024 draw_context_out
->current
->modify_over
->x
= -1;
1025 draw_context_out
->current
->modify_over
->y
= -1;
1026 draw_context_out
->current
->modify_middle
= g_new(ItemInfo
,1);
1027 draw_context_out
->current
->modify_middle
->x
= -1;
1028 draw_context_out
->current
->modify_middle
->y
= -1;
1029 draw_context_out
->current
->modify_under
= g_new(ItemInfo
,1);
1030 draw_context_out
->current
->modify_under
->x
= -1;
1031 draw_context_out
->current
->modify_under
->y
= -1;
1032 draw_context_out
->current
->status
= LTTV_STATE_UNNAMED
;
1034 /* Finally, update the drawing context of the pid_in. */
1036 DrawContext
*draw_context_in
= hashed_process_data_in
->draw_context
;
1037 //draw_context_in->current->modify_over->x = x;
1038 draw_context_in
->current
->modify_over
->y
= y_in
;
1039 draw_context_in
->current
->modify_under
->y
= y_in
+(height
/2)+2;
1040 draw_context_in
->drawable
= control_flow_data
->drawing
->pixmap
;
1041 draw_context_in
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1042 widget
= control_flow_data
->drawing
->drawing_area
;
1043 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1045 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1046 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1048 /*if(process_in->state->s == LTTV_STATE_RUN)
1050 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1051 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1052 PropertiesBG prop_bg;
1053 prop_bg.color = g_new(GdkColor,1);
1055 prop_bg.color->red = 0xffff;
1056 prop_bg.color->green = 0xffff;
1057 prop_bg.color->blue = 0xffff;
1059 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1060 g_free(prop_bg.color);
1061 gdk_gc_unref(draw_context_in->gc);
1064 draw_context_in
->gc
= widget
->style
->black_gc
;
1066 GdkColor colorfg_in
= { 0, 0x0000, 0xffff, 0x0000 };
1067 GdkColor colorbg_in
= { 0, 0x0000, 0x0000, 0x0000 };
1068 PropertiesText prop_text_in
;
1069 prop_text_in
.foreground
= &colorfg_in
;
1070 prop_text_in
.background
= &colorbg_in
;
1071 prop_text_in
.size
= 6;
1072 prop_text_in
.position
= OVER
;
1074 /* foreground of text : status of the process */
1075 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1077 prop_text_in
.foreground
->red
= 0xffff;
1078 prop_text_in
.foreground
->green
= 0xffff;
1079 prop_text_in
.foreground
->blue
= 0xffff;
1081 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1083 prop_text_in
.foreground
->red
= 0x0fff;
1084 prop_text_in
.foreground
->green
= 0xffff;
1085 prop_text_in
.foreground
->blue
= 0xfff0;
1087 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1089 prop_text_in
.foreground
->red
= 0xffff;
1090 prop_text_in
.foreground
->green
= 0xffff;
1091 prop_text_in
.foreground
->blue
= 0x0000;
1093 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1095 prop_text_in
.foreground
->red
= 0xffff;
1096 prop_text_in
.foreground
->green
= 0x0000;
1097 prop_text_in
.foreground
->blue
= 0xffff;
1099 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1101 prop_text_in
.foreground
->red
= 0xffff;
1102 prop_text_in
.foreground
->green
= 0x0000;
1103 prop_text_in
.foreground
->blue
= 0x0000;
1105 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1107 prop_text_in
.foreground
->red
= 0x0000;
1108 prop_text_in
.foreground
->green
= 0xffff;
1109 prop_text_in
.foreground
->blue
= 0x0000;
1113 prop_text_in
.foreground
->red
= 0xffff;
1114 prop_text_in
.foreground
->green
= 0xffff;
1115 prop_text_in
.foreground
->blue
= 0xffff;
1119 /* Print status of the process : U, WF, WC, E, W, R */
1120 if(process_in
->state
->s
== LTTV_STATE_UNNAMED
)
1121 prop_text_in
.text
= "U";
1122 else if(process_in
->state
->s
== LTTV_STATE_WAIT_FORK
)
1123 prop_text_in
.text
= "WF";
1124 else if(process_in
->state
->s
== LTTV_STATE_WAIT_CPU
)
1125 prop_text_in
.text
= "WC";
1126 else if(process_in
->state
->s
== LTTV_STATE_EXIT
)
1127 prop_text_in
.text
= "E";
1128 else if(process_in
->state
->s
== LTTV_STATE_WAIT
)
1129 prop_text_in
.text
= "W";
1130 else if(process_in
->state
->s
== LTTV_STATE_RUN
)
1131 prop_text_in
.text
= "R";
1133 prop_text_in
.text
= "U";
1135 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1138 if(process_in
->state
->s
== LTTV_STATE_RUN
)
1141 prop_text_in
.foreground
= &colorfg_in
;
1142 prop_text_in
.background
= &colorbg_in
;
1143 prop_text_in
.foreground
->red
= 0xffff;
1144 prop_text_in
.foreground
->green
= 0xffff;
1145 prop_text_in
.foreground
->blue
= 0xffff;
1146 prop_text_in
.size
= 6;
1147 prop_text_in
.position
= UNDER
;
1149 prop_text_in
.text
= g_new(gchar
, 260);
1150 strcpy(prop_text_in
.text
, "CPU ");
1151 snprintf(tmp
, 255, "%u", tfc
->index
);
1152 strcat(prop_text_in
.text
, tmp
);
1154 draw_text((void*)&prop_text_in
, (void*)draw_context_in
);
1155 g_free(prop_text_in
.text
);
1159 draw_context_in
->current
->middle
->y
= y_in
+height
/2;
1160 draw_context_in
->current
->over
->y
= y_in
;
1161 draw_context_in
->current
->under
->y
= y_in
+height
;
1162 draw_context_in
->current
->status
= process_in
->state
->s
;
1164 /* for pid_in : remove previous, Prev = current, new current (default) */
1165 g_free(draw_context_in
->previous
->modify_under
);
1166 g_free(draw_context_in
->previous
->modify_middle
);
1167 g_free(draw_context_in
->previous
->modify_over
);
1168 g_free(draw_context_in
->previous
->under
);
1169 g_free(draw_context_in
->previous
->middle
);
1170 g_free(draw_context_in
->previous
->over
);
1171 g_free(draw_context_in
->previous
);
1173 draw_context_in
->previous
= draw_context_in
->current
;
1175 draw_context_in
->current
= g_new(DrawInfo
,1);
1176 draw_context_in
->current
->over
= g_new(ItemInfo
,1);
1177 draw_context_in
->current
->over
->x
= -1;
1178 draw_context_in
->current
->over
->y
= -1;
1179 draw_context_in
->current
->middle
= g_new(ItemInfo
,1);
1180 draw_context_in
->current
->middle
->x
= -1;
1181 draw_context_in
->current
->middle
->y
= -1;
1182 draw_context_in
->current
->under
= g_new(ItemInfo
,1);
1183 draw_context_in
->current
->under
->x
= -1;
1184 draw_context_in
->current
->under
->y
= -1;
1185 draw_context_in
->current
->modify_over
= g_new(ItemInfo
,1);
1186 draw_context_in
->current
->modify_over
->x
= -1;
1187 draw_context_in
->current
->modify_over
->y
= -1;
1188 draw_context_in
->current
->modify_middle
= g_new(ItemInfo
,1);
1189 draw_context_in
->current
->modify_middle
->x
= -1;
1190 draw_context_in
->current
->modify_middle
->y
= -1;
1191 draw_context_in
->current
->modify_under
= g_new(ItemInfo
,1);
1192 draw_context_in
->current
->modify_under
->x
= -1;
1193 draw_context_in
->current
->modify_under
->y
= -1;
1194 draw_context_in
->current
->status
= LTTV_STATE_UNNAMED
;
1204 gint
update_time_window_hook(void *hook_data
, void *call_data
)
1206 ControlFlowData
*control_flow_data
= (ControlFlowData
*) hook_data
;
1207 TimeWindow
*old_time_window
=
1208 guicontrolflow_get_time_window(control_flow_data
);
1209 TimeWindow
*new_time_window
= ((TimeWindow
*)call_data
);
1211 /* Update the ruler */
1212 drawing_update_ruler(control_flow_data
->drawing
,
1216 /* Two cases : zoom in/out or scrolling */
1218 /* In order to make sure we can reuse the old drawing, the scale must
1219 * be the same and the new time interval being partly located in the
1220 * currently shown time interval. (reuse is only for scrolling)
1223 g_info("Old time window HOOK : %u, %u to %u, %u",
1224 old_time_window
->start_time
.tv_sec
,
1225 old_time_window
->start_time
.tv_nsec
,
1226 old_time_window
->time_width
.tv_sec
,
1227 old_time_window
->time_width
.tv_nsec
);
1229 g_info("New time window HOOK : %u, %u to %u, %u",
1230 new_time_window
->start_time
.tv_sec
,
1231 new_time_window
->start_time
.tv_nsec
,
1232 new_time_window
->time_width
.tv_sec
,
1233 new_time_window
->time_width
.tv_nsec
);
1235 if( new_time_window
->time_width
.tv_sec
== old_time_window
->time_width
.tv_sec
1236 && new_time_window
->time_width
.tv_nsec
== old_time_window
->time_width
.tv_nsec
)
1238 /* Same scale (scrolling) */
1239 g_info("scrolling");
1240 LttTime
*ns
= &new_time_window
->start_time
;
1241 LttTime
*os
= &old_time_window
->start_time
;
1242 LttTime old_end
= ltt_time_add(old_time_window
->start_time
,
1243 old_time_window
->time_width
);
1244 LttTime new_end
= ltt_time_add(new_time_window
->start_time
,
1245 new_time_window
->time_width
);
1247 //if(ns<os+w && os+w<ns+w)
1248 //if(ns<old_end && os<ns)
1249 if(ltt_time_compare(*ns
, old_end
) == -1
1250 && ltt_time_compare(*os
, *ns
) == -1)
1252 g_info("scrolling near right");
1253 /* Scroll right, keep right part of the screen */
1255 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1256 convert_time_to_pixels(
1263 /* Copy old data to new location */
1264 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1265 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1266 control_flow_data
->drawing
->pixmap
,
1271 convert_time_to_pixels(
1278 *old_time_window
= *new_time_window
;
1279 /* Clear the data request background, but not SAFETY */
1280 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1281 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1284 control_flow_data
->drawing
->width
- x
, // do not overlap
1285 control_flow_data
->drawing
->height
+SAFETY
);
1286 /* Get new data for the rest. */
1287 drawing_data_request(control_flow_data
->drawing
,
1288 &control_flow_data
->drawing
->pixmap
,
1290 control_flow_data
->drawing
->width
- x
,
1291 control_flow_data
->drawing
->height
);
1293 drawing_refresh(control_flow_data
->drawing
,
1295 control_flow_data
->drawing
->width
,
1296 control_flow_data
->drawing
->height
);
1301 //if(ns<os && os<ns+w)
1302 //if(ns<os && os<new_end)
1303 if(ltt_time_compare(*ns
,*os
) == -1
1304 && ltt_time_compare(*os
,new_end
) == -1)
1306 g_info("scrolling near left");
1307 /* Scroll left, keep left part of the screen */
1309 guint width
= control_flow_data
->drawing
->drawing_area
->allocation
.width
;
1310 convert_time_to_pixels(
1317 /* Copy old data to new location */
1318 gdk_draw_drawable (control_flow_data
->drawing
->pixmap
,
1319 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1320 control_flow_data
->drawing
->pixmap
,
1325 *old_time_window
= *new_time_window
;
1327 /* Clean the data request background */
1328 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1329 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1332 x
, // do not overlap
1333 control_flow_data
->drawing
->height
+SAFETY
);
1334 /* Get new data for the rest. */
1335 drawing_data_request(control_flow_data
->drawing
,
1336 &control_flow_data
->drawing
->pixmap
,
1339 control_flow_data
->drawing
->height
);
1341 drawing_refresh(control_flow_data
->drawing
,
1343 control_flow_data
->drawing
->width
,
1344 control_flow_data
->drawing
->height
);
1347 g_info("scrolling far");
1348 /* Cannot reuse any part of the screen : far jump */
1349 *old_time_window
= *new_time_window
;
1352 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1353 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1356 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1357 control_flow_data
->drawing
->height
+SAFETY
);
1359 drawing_data_request(control_flow_data
->drawing
,
1360 &control_flow_data
->drawing
->pixmap
,
1362 control_flow_data
->drawing
->width
,
1363 control_flow_data
->drawing
->height
);
1365 drawing_refresh(control_flow_data
->drawing
,
1367 control_flow_data
->drawing
->width
,
1368 control_flow_data
->drawing
->height
);
1372 /* Different scale (zoom) */
1375 *old_time_window
= *new_time_window
;
1377 gdk_draw_rectangle (control_flow_data
->drawing
->pixmap
,
1378 control_flow_data
->drawing
->drawing_area
->style
->black_gc
,
1381 control_flow_data
->drawing
->width
+SAFETY
, // do not overlap
1382 control_flow_data
->drawing
->height
+SAFETY
);
1385 drawing_data_request(control_flow_data
->drawing
,
1386 &control_flow_data
->drawing
->pixmap
,
1388 control_flow_data
->drawing
->width
,
1389 control_flow_data
->drawing
->height
);
1391 drawing_refresh(control_flow_data
->drawing
,
1393 control_flow_data
->drawing
->width
,
1394 control_flow_data
->drawing
->height
);
1402 gint
update_current_time_hook(void *hook_data
, void *call_data
)
1404 ControlFlowData
*control_flow_data
= (ControlFlowData
*)hook_data
;
1406 LttTime
* current_time
=
1407 guicontrolflow_get_current_time(control_flow_data
);
1408 *current_time
= *((LttTime
*)call_data
);
1410 TimeWindow time_window
;
1412 LttTime time_begin
= control_flow_data
->time_window
.start_time
;
1413 LttTime width
= control_flow_data
->time_window
.time_width
;
1414 LttTime half_width
= ltt_time_div(width
,2.0);
1415 LttTime time_end
= ltt_time_add(time_begin
, width
);
1417 LttvTracesetContext
* tsc
=
1418 get_traceset_context(control_flow_data
->mw
);
1420 LttTime trace_start
= tsc
->Time_Span
->startTime
;
1421 LttTime trace_end
= tsc
->Time_Span
->endTime
;
1423 g_info("New current time HOOK : %u, %u", current_time
->tv_sec
,
1424 current_time
->tv_nsec
);
1428 /* If current time is inside time interval, just move the highlight
1431 /* Else, we have to change the time interval. We have to tell it
1432 * to the main window. */
1433 /* The time interval change will take care of placing the current
1434 * time at the center of the visible area, or nearest possible if we are
1435 * at one end of the trace. */
1438 if(ltt_time_compare(*current_time
, time_begin
) == -1)
1440 if(ltt_time_compare(*current_time
,
1441 ltt_time_add(trace_start
,half_width
)) == -1)
1442 time_begin
= trace_start
;
1444 time_begin
= ltt_time_sub(*current_time
,half_width
);
1446 time_window
.start_time
= time_begin
;
1447 time_window
.time_width
= width
;
1449 set_time_window(control_flow_data
->mw
, &time_window
);
1451 else if(ltt_time_compare(*current_time
, time_end
) == 1)
1453 if(ltt_time_compare(*current_time
, ltt_time_sub(trace_end
, half_width
)) == 1)
1454 time_begin
= ltt_time_sub(trace_end
,width
);
1456 time_begin
= ltt_time_sub(*current_time
,half_width
);
1458 time_window
.start_time
= time_begin
;
1459 time_window
.time_width
= width
;
1461 set_time_window(control_flow_data
->mw
, &time_window
);
1464 gtk_widget_queue_draw(control_flow_data
->drawing
->drawing_area
);
1469 typedef struct _ClosureData
{
1470 EventRequest
*event_request
;
1471 LttvTracesetState
*tss
;
1475 void draw_closure(gpointer key
, gpointer value
, gpointer user_data
)
1477 ProcessInfo
*process_info
= (ProcessInfo
*)key
;
1478 HashedProcessData
*hashed_process_data
= (HashedProcessData
*)value
;
1479 ClosureData
*closure_data
= (ClosureData
*)user_data
;
1481 ControlFlowData
*control_flow_data
=
1482 closure_data
->event_request
->control_flow_data
;
1484 GtkWidget
*widget
= control_flow_data
->drawing
->drawing_area
;
1486 /* Get y position of process */
1489 processlist_get_pixels_from_data( control_flow_data
->process_list
,
1491 hashed_process_data
,
1494 /* Get last state of process */
1495 LttvTraceContext
*tc
=
1496 ((LttvTracesetContext
*)closure_data
->tss
)->traces
[process_info
->trace_num
];
1497 //LttvTracefileContext *tfc = (LttvTracefileContext *)closure_data->ts;
1499 LttvTraceState
*ts
= (LttvTraceState
*)tc
;
1500 LttvProcessState
*process
;
1502 process
= lttv_state_find_process_from_trace(ts
, process_info
->pid
);
1504 /* Draw the closing line */
1505 DrawContext
*draw_context
= hashed_process_data
->draw_context
;
1506 if(draw_context
->previous
->middle
->x
== -1)
1508 draw_context
->previous
->middle
->x
= closure_data
->event_request
->x_begin
;
1509 draw_context
->previous
->over
->x
= closure_data
->event_request
->x_begin
;
1510 draw_context
->previous
->under
->x
= closure_data
->event_request
->x_begin
;
1511 g_critical("out middle x_beg : %u",closure_data
->event_request
->x_begin
);
1514 draw_context
->current
->middle
->x
= closure_data
->event_request
->x_end
;
1515 draw_context
->current
->over
->x
= closure_data
->event_request
->x_end
;
1516 draw_context
->current
->under
->x
= closure_data
->event_request
->x_end
;
1517 draw_context
->current
->middle
->y
= y
+ height
/2;
1518 draw_context
->current
->over
->y
= y
;
1519 draw_context
->current
->under
->y
= y
+ height
;
1520 draw_context
->previous
->middle
->y
= y
+ height
/2;
1521 draw_context
->previous
->over
->y
= y
;
1522 draw_context
->previous
->under
->y
= y
+ height
;
1523 draw_context
->drawable
= control_flow_data
->drawing
->pixmap
;
1524 draw_context
->pango_layout
= control_flow_data
->drawing
->pango_layout
;
1525 //draw_context->gc = widget->style->black_gc;
1526 draw_context
->gc
= gdk_gc_new(control_flow_data
->drawing
->pixmap
);
1527 gdk_gc_copy(draw_context
->gc
, widget
->style
->black_gc
);
1529 if(process
!= NULL
&& process
->state
->s
== LTTV_STATE_RUN
)
1531 PropertiesBG prop_bg
;
1532 prop_bg
.color
= g_new(GdkColor
,1);
1534 /*switch(tfc->index) {
1536 prop_bg.color->red = 0x1515;
1537 prop_bg.color->green = 0x1515;
1538 prop_bg.color->blue = 0x8c8c;
1541 prop_bg.color->red = 0x4e4e;
1542 prop_bg.color->green = 0xa9a9;
1543 prop_bg.color->blue = 0xa4a4;
1546 prop_bg.color->red = 0x7a7a;
1547 prop_bg.color->green = 0x4a4a;
1548 prop_bg.color->blue = 0x8b8b;
1551 prop_bg.color->red = 0x8080;
1552 prop_bg.color->green = 0x7777;
1553 prop_bg.color->blue = 0x4747;
1556 prop_bg.color->red = 0xe7e7;
1557 prop_bg.color->green = 0xe7e7;
1558 prop_bg.color->blue = 0xe7e7;
1562 g_critical("calling from closure");
1563 //FIXME : I need the cpu number in process's state to draw this.
1564 //draw_bg((void*)&prop_bg, (void*)draw_context);
1565 g_free(prop_bg
.color
);
1569 PropertiesLine prop_line
;
1570 prop_line
.color
= g_new(GdkColor
,1);
1571 prop_line
.line_width
= 2;
1572 prop_line
.style
= GDK_LINE_SOLID
;
1573 prop_line
.position
= MIDDLE
;
1575 /* color of line : status of the process */
1578 if(process
->state
->s
== LTTV_STATE_UNNAMED
)
1580 prop_line
.color
->red
= 0xffff;
1581 prop_line
.color
->green
= 0xffff;
1582 prop_line
.color
->blue
= 0xffff;
1584 else if(process
->state
->s
== LTTV_STATE_WAIT_FORK
)
1586 prop_line
.color
->red
= 0x0fff;
1587 prop_line
.color
->green
= 0xffff;
1588 prop_line
.color
->blue
= 0xfff0;
1590 else if(process
->state
->s
== LTTV_STATE_WAIT_CPU
)
1592 prop_line
.color
->red
= 0xffff;
1593 prop_line
.color
->green
= 0xffff;
1594 prop_line
.color
->blue
= 0x0000;
1596 else if(process
->state
->s
== LTTV_STATE_EXIT
)
1598 prop_line
.color
->red
= 0xffff;
1599 prop_line
.color
->green
= 0x0000;
1600 prop_line
.color
->blue
= 0xffff;
1602 else if(process
->state
->s
== LTTV_STATE_WAIT
)
1604 prop_line
.color
->red
= 0xffff;
1605 prop_line
.color
->green
= 0x0000;
1606 prop_line
.color
->blue
= 0x0000;
1608 else if(process
->state
->s
== LTTV_STATE_RUN
)
1610 prop_line
.color
->red
= 0x0000;
1611 prop_line
.color
->green
= 0xffff;
1612 prop_line
.color
->blue
= 0x0000;
1616 prop_line
.color
->red
= 0xffff;
1617 prop_line
.color
->green
= 0xffff;
1618 prop_line
.color
->blue
= 0xffff;
1624 prop_line
.color
->red
= 0xffff;
1625 prop_line
.color
->green
= 0xffff;
1626 prop_line
.color
->blue
= 0xffff;
1629 draw_line((void*)&prop_line
, (void*)draw_context
);
1630 g_free(prop_line
.color
);
1631 gdk_gc_unref(draw_context
->gc
);
1633 /* Reset draw_context of the process for next request */
1635 hashed_process_data
->draw_context
->drawable
= NULL
;
1636 hashed_process_data
->draw_context
->gc
= NULL
;
1637 hashed_process_data
->draw_context
->pango_layout
= NULL
;
1638 hashed_process_data
->draw_context
->current
->over
->x
= -1;
1639 hashed_process_data
->draw_context
->current
->over
->y
= -1;
1640 hashed_process_data
->draw_context
->current
->middle
->x
= -1;
1641 hashed_process_data
->draw_context
->current
->middle
->y
= -1;
1642 hashed_process_data
->draw_context
->current
->under
->x
= -1;
1643 hashed_process_data
->draw_context
->current
->under
->y
= -1;
1644 hashed_process_data
->draw_context
->current
->modify_over
->x
= -1;
1645 hashed_process_data
->draw_context
->current
->modify_over
->y
= -1;
1646 hashed_process_data
->draw_context
->current
->modify_middle
->x
= -1;
1647 hashed_process_data
->draw_context
->current
->modify_middle
->y
= -1;
1648 hashed_process_data
->draw_context
->current
->modify_under
->x
= -1;
1649 hashed_process_data
->draw_context
->current
->modify_under
->y
= -1;
1650 hashed_process_data
->draw_context
->current
->status
= LTTV_STATE_UNNAMED
;
1651 hashed_process_data
->draw_context
->previous
->over
->x
= -1;
1652 hashed_process_data
->draw_context
->previous
->over
->y
= -1;
1653 hashed_process_data
->draw_context
->previous
->middle
->x
= -1;
1654 hashed_process_data
->draw_context
->previous
->middle
->y
= -1;
1655 hashed_process_data
->draw_context
->previous
->under
->x
= -1;
1656 hashed_process_data
->draw_context
->previous
->under
->y
= -1;
1657 hashed_process_data
->draw_context
->previous
->modify_over
->x
= -1;
1658 hashed_process_data
->draw_context
->previous
->modify_over
->y
= -1;
1659 hashed_process_data
->draw_context
->previous
->modify_middle
->x
= -1;
1660 hashed_process_data
->draw_context
->previous
->modify_middle
->y
= -1;
1661 hashed_process_data
->draw_context
->previous
->modify_under
->x
= -1;
1662 hashed_process_data
->draw_context
->previous
->modify_under
->y
= -1;
1663 hashed_process_data
->draw_context
->previous
->status
= LTTV_STATE_UNNAMED
;
1671 * new default prev and current
1673 int after_data_request(void *hook_data
, void *call_data
)
1675 EventRequest
*event_request
= (EventRequest
*)hook_data
;
1676 ControlFlowData
*control_flow_data
= event_request
->control_flow_data
;
1678 ProcessList
*process_list
=
1679 guicontrolflow_get_process_list(event_request
->control_flow_data
);
1681 ClosureData closure_data
;
1682 closure_data
.event_request
= (EventRequest
*)hook_data
;
1683 closure_data
.tss
= (LttvTracesetState
*)call_data
;
1685 g_hash_table_foreach(process_list
->process_hash
, draw_closure
,
1686 (void*)&closure_data
);