git-svn-id: http://ltt.polymtl.ca/svn@462 04897980-b3bd-0310-b5e0-8ef037075253
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / eventhooks.c
... / ...
CommitLineData
1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
19
20/*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
23
24
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)
27
28//#define PANGO_ENABLE_BACKEND
29#include <gtk/gtk.h>
30#include <gdk/gdk.h>
31#include <glib.h>
32#include <assert.h>
33#include <string.h>
34#include <stdio.h>
35
36//#include <pango/pango.h>
37
38#include <ltt/event.h>
39#include <ltt/time.h>
40#include <ltt/type.h>
41
42#include <lttv/hook.h>
43#include <lttv/common.h>
44#include <lttv/state.h>
45#include <lttv/gtktraceset.h>
46
47
48#include "eventhooks.h"
49#include "cfv.h"
50#include "processlist.h"
51#include "drawing.h"
52#include "cfv-private.h"
53
54
55#define MAX_PATH_LEN 256
56
57
58/**
59 * Event Viewer's constructor hook
60 *
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.
65 */
66GtkWidget *
67h_guicontrolflow(MainWindow *mw, LttvTracesetSelector * s, char * key)
68{
69 g_info("h_guicontrolflow, %p, %p, %s", mw, s, key);
70 ControlFlowData *control_flow_data = guicontrolflow() ;
71
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;
78
79 LttTime *current_time = guicontrolflow_get_current_time(control_flow_data);
80 current_time->tv_sec = 0;
81 current_time->tv_nsec = 0;
82
83 //g_critical("time width1 : %u",time_window->time_width);
84
85 get_time_window(mw,
86 time_window);
87 get_current_time(mw,
88 current_time);
89
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,
93 mw);
94 reg_update_current_time(update_current_time_hook, control_flow_data,
95 mw);
96 return guicontrolflow_get_widget(control_flow_data) ;
97
98}
99
100int event_selected_hook(void *hook_data, void *call_data)
101{
102 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
103 guint *event_number = (guint*) call_data;
104
105 g_critical("DEBUG : event selected by main window : %u", *event_number);
106
107// control_flow_data->currently_Selected_Event = *event_number;
108// control_flow_data->Selected_Event = TRUE ;
109
110// tree_v_set_cursor(control_flow_data);
111
112}
113
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.
116 */
117int draw_before_hook(void *hook_data, void *call_data)
118{
119 EventRequest *event_request = (EventRequest*)hook_data;
120 //EventsContext Events_Context = (EventsContext*)call_data;
121
122 //event_request->Events_Context = Events_Context;
123
124 return 0;
125}
126
127/*
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.
132 *
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).
137 *
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.
143 *
144 * The choice of lines'color is defined by the context of the last event for this
145 * process.
146 */
147int draw_event_hook(void *hook_data, void *call_data)
148{
149 EventRequest *event_request = (EventRequest*)hook_data;
150 ControlFlowData *control_flow_data = event_request->control_flow_data;
151
152 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
153
154 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
155
156
157 LttEvent *e;
158 e = tfc->e;
159
160 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
161 {
162 g_critical("schedchange!");
163
164 /* Add process to process list (if not present) and get drawing "y" from
165 * process position */
166 guint pid_out, pid_in;
167 LttvProcessState *process_out, *process_in;
168 LttTime birth;
169 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
170
171 ProcessList *process_list =
172 guicontrolflow_get_process_list(event_request->control_flow_data);
173
174
175 LttField *f = ltt_event_field(e);
176 LttField *element;
177 element = ltt_field_member(f,0);
178 pid_out = ltt_event_get_long_unsigned(e,element);
179 element = ltt_field_member(f,1);
180 pid_in = ltt_event_get_long_unsigned(e,element);
181 g_critical("out : %u in : %u", pid_out, pid_in);
182
183
184 /* Find process pid_out in the list... */
185 process_out = lttv_state_find_process(tfs, pid_out);
186 g_critical("out : %s",g_quark_to_string(process_out->state->s));
187
188 birth = process_out->creation_time;
189 gchar *name = strdup(g_quark_to_string(process_out->name));
190 HashedProcessData *hashed_process_data_out = NULL;
191
192 if(processlist_get_process_pixels(process_list,
193 pid_out,
194 &birth,
195 &y_out,
196 &height,
197 &hashed_process_data_out) == 1)
198 {
199 /* Process not present */
200 processlist_add(process_list,
201 pid_out,
202 &birth,
203 name,
204 &pl_height,
205 &hashed_process_data_out);
206 processlist_get_process_pixels(process_list,
207 pid_out,
208 &birth,
209 &y_out,
210 &height,
211 &hashed_process_data_out);
212 drawing_insert_square( event_request->control_flow_data->drawing, y_out, height);
213 }
214
215 g_free(name);
216
217 /* Find process pid_in in the list... */
218 process_in = lttv_state_find_process(tfs, pid_in);
219 g_critical("in : %s",g_quark_to_string(process_in->state->s));
220
221 birth = process_in->creation_time;
222 name = strdup(g_quark_to_string(process_in->name));
223 HashedProcessData *hashed_process_data_in = NULL;
224
225 if(processlist_get_process_pixels(process_list,
226 pid_in,
227 &birth,
228 &y_in,
229 &height,
230 &hashed_process_data_in) == 1)
231 {
232 /* Process not present */
233 processlist_add(process_list,
234 pid_in,
235 &birth,
236 name,
237 &pl_height,
238 &hashed_process_data_in);
239 processlist_get_process_pixels(process_list,
240 pid_in,
241 &birth,
242 &y_in,
243 &height,
244 &hashed_process_data_in);
245
246 drawing_insert_square( event_request->control_flow_data->drawing, y_in, height);
247 }
248 g_free(name);
249
250
251 /* Find pixels corresponding to time of the event. If the time does
252 * not fit in the window, show a warning, not supposed to happend. */
253 guint x = 0;
254 guint width = control_flow_data->drawing->drawing_area->allocation.width;
255
256 LttTime time = ltt_event_time(e);
257
258 LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
259 control_flow_data->time_window.start_time);
260
261
262 convert_time_to_pixels(
263 control_flow_data->time_window.start_time,
264 window_end,
265 time,
266 width,
267 &x);
268
269 assert(x <= width);
270
271 /* draw what represents the event for outgoing process. */
272
273 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
274 draw_context_out->current->modify_over->x = x;
275 draw_context_out->current->modify_under->x = x;
276 draw_context_out->current->modify_over->y = y_out;
277 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
278 draw_context_out->drawable = control_flow_data->drawing->pixmap;
279 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
280 GtkWidget *widget = control_flow_data->drawing->drawing_area;
281 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
282 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
283 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
284 //draw_context_out->gc = widget->style->black_gc;
285
286 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
287 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
288
289 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
290 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
291 PropertiesText prop_text_out;
292 prop_text_out.foreground = &colorfg_out;
293 prop_text_out.background = &colorbg_out;
294 prop_text_out.size = 6;
295 prop_text_out.position = OVER;
296
297 /* color of text : status of the process */
298 if(process_out->state->s == LTTV_STATE_UNNAMED)
299 {
300 prop_text_out.foreground->red = 0xffff;
301 prop_text_out.foreground->green = 0xffff;
302 prop_text_out.foreground->blue = 0xffff;
303 }
304 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
305 {
306 prop_text_out.foreground->red = 0x0fff;
307 prop_text_out.foreground->green = 0x0000;
308 prop_text_out.foreground->blue = 0x0fff;
309 }
310 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
311 {
312 prop_text_out.foreground->red = 0xffff;
313 prop_text_out.foreground->green = 0xffff;
314 prop_text_out.foreground->blue = 0x0000;
315 }
316 else if(process_out->state->s == LTTV_STATE_EXIT)
317 {
318 prop_text_out.foreground->red = 0xffff;
319 prop_text_out.foreground->green = 0x0000;
320 prop_text_out.foreground->blue = 0xffff;
321 }
322 else if(process_out->state->s == LTTV_STATE_WAIT)
323 {
324 prop_text_out.foreground->red = 0xffff;
325 prop_text_out.foreground->green = 0x0000;
326 prop_text_out.foreground->blue = 0x0000;
327 }
328 else if(process_out->state->s == LTTV_STATE_RUN)
329 {
330 prop_text_out.foreground->red = 0x0000;
331 prop_text_out.foreground->green = 0xffff;
332 prop_text_out.foreground->blue = 0x0000;
333 }
334 else
335 {
336 prop_text_out.foreground->red = 0xffff;
337 prop_text_out.foreground->green = 0xffff;
338 prop_text_out.foreground->blue = 0xffff;
339 }
340
341 /* Print status of the process : U, WF, WC, E, W, R */
342 if(process_out->state->s == LTTV_STATE_UNNAMED)
343 prop_text_out.text = "U->";
344 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
345 prop_text_out.text = "WF->";
346 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
347 prop_text_out.text = "WC->";
348 else if(process_out->state->s == LTTV_STATE_EXIT)
349 prop_text_out.text = "E->";
350 else if(process_out->state->s == LTTV_STATE_WAIT)
351 prop_text_out.text = "W->";
352 else if(process_out->state->s == LTTV_STATE_RUN)
353 prop_text_out.text = "R->";
354 else
355 prop_text_out.text = "U";
356
357 draw_text((void*)&prop_text_out, (void*)draw_context_out);
358 gdk_gc_unref(draw_context_out->gc);
359
360 /* Draw the line of the out process */
361 if(draw_context_out->previous->middle->x == -1)
362 {
363 draw_context_out->previous->middle->x = event_request->x_begin;
364 g_critical("out middle x_beg : %u",event_request->x_begin);
365 }
366
367 draw_context_out->current->middle->x = x;
368 draw_context_out->current->middle->y = y_out + height/2;
369 draw_context_out->previous->middle->y = y_out + height/2;
370 draw_context_out->drawable = control_flow_data->drawing->pixmap;
371 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
372 //draw_context_out->gc = widget->style->black_gc;
373 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
374 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
375
376 PropertiesLine prop_line_out;
377 prop_line_out.color = g_new(GdkColor,1);
378 prop_line_out.line_width = 2;
379 prop_line_out.style = GDK_LINE_SOLID;
380 prop_line_out.position = MIDDLE;
381
382 /* color of line : status of the process */
383 if(process_out->state->s == LTTV_STATE_UNNAMED)
384 {
385 prop_line_out.color->red = 0xffff;
386 prop_line_out.color->green = 0xffff;
387 prop_line_out.color->blue = 0xffff;
388 }
389 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
390 {
391 prop_line_out.color->red = 0x0fff;
392 prop_line_out.color->green = 0x0000;
393 prop_line_out.color->blue = 0x0fff;
394 }
395 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
396 {
397 prop_line_out.color->red = 0xffff;
398 prop_line_out.color->green = 0xffff;
399 prop_line_out.color->blue = 0x0000;
400 }
401 else if(process_out->state->s == LTTV_STATE_EXIT)
402 {
403 prop_line_out.color->red = 0xffff;
404 prop_line_out.color->green = 0x0000;
405 prop_line_out.color->blue = 0xffff;
406 }
407 else if(process_out->state->s == LTTV_STATE_WAIT)
408 {
409 prop_line_out.color->red = 0xffff;
410 prop_line_out.color->green = 0x0000;
411 prop_line_out.color->blue = 0x0000;
412 }
413 else if(process_out->state->s == LTTV_STATE_RUN)
414 {
415 prop_line_out.color->red = 0x0000;
416 prop_line_out.color->green = 0xffff;
417 prop_line_out.color->blue = 0x0000;
418 }
419 else
420 {
421 prop_line_out.color->red = 0xffff;
422 prop_line_out.color->green = 0xffff;
423 prop_line_out.color->blue = 0xffff;
424 }
425
426 draw_line((void*)&prop_line_out, (void*)draw_context_out);
427 g_free(prop_line_out.color);
428 gdk_gc_unref(draw_context_out->gc);
429 /* Note : finishing line will have to be added when trace read over. */
430
431 /* Finally, update the drawing context of the pid_in. */
432
433 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
434 draw_context_in->current->modify_over->x = x;
435 draw_context_in->current->modify_under->x = x;
436 draw_context_in->current->modify_over->y = y_in;
437 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
438 draw_context_in->drawable = control_flow_data->drawing->pixmap;
439 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
440 widget = control_flow_data->drawing->drawing_area;
441 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
442 //draw_context_in->gc = widget->style->black_gc;
443 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
444 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
445
446 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
447 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
448
449 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
450 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
451 PropertiesText prop_text_in;
452 prop_text_in.foreground = &colorfg_in;
453 prop_text_in.background = &colorbg_in;
454 prop_text_in.size = 6;
455 prop_text_in.position = OVER;
456
457 /* foreground of text : status of the process */
458 if(process_in->state->s == LTTV_STATE_UNNAMED)
459 {
460 prop_text_in.foreground->red = 0xffff;
461 prop_text_in.foreground->green = 0xffff;
462 prop_text_in.foreground->blue = 0xffff;
463 }
464 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
465 {
466 prop_text_in.foreground->red = 0x0fff;
467 prop_text_in.foreground->green = 0x0000;
468 prop_text_in.foreground->blue = 0x0fff;
469 }
470 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
471 {
472 prop_text_in.foreground->red = 0xffff;
473 prop_text_in.foreground->green = 0xffff;
474 prop_text_in.foreground->blue = 0x0000;
475 }
476 else if(process_in->state->s == LTTV_STATE_EXIT)
477 {
478 prop_text_in.foreground->red = 0xffff;
479 prop_text_in.foreground->green = 0x0000;
480 prop_text_in.foreground->blue = 0xffff;
481 }
482 else if(process_in->state->s == LTTV_STATE_WAIT)
483 {
484 prop_text_in.foreground->red = 0xffff;
485 prop_text_in.foreground->green = 0x0000;
486 prop_text_in.foreground->blue = 0x0000;
487 }
488 else if(process_in->state->s == LTTV_STATE_RUN)
489 {
490 prop_text_in.foreground->red = 0x0000;
491 prop_text_in.foreground->green = 0xffff;
492 prop_text_in.foreground->blue = 0x0000;
493 }
494 else
495 {
496 prop_text_in.foreground->red = 0xffff;
497 prop_text_in.foreground->green = 0xffff;
498 prop_text_in.foreground->blue = 0xffff;
499 }
500
501
502
503 /* Print status of the process : U, WF, WC, E, W, R */
504 if(process_in->state->s == LTTV_STATE_UNNAMED)
505 prop_text_in.text = "U->";
506 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
507 prop_text_in.text = "WF->";
508 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
509 prop_text_in.text = "WC->";
510 else if(process_in->state->s == LTTV_STATE_EXIT)
511 prop_text_in.text = "E->";
512 else if(process_in->state->s == LTTV_STATE_WAIT)
513 prop_text_in.text = "W->";
514 else if(process_in->state->s == LTTV_STATE_RUN)
515 prop_text_in.text = "R->";
516 else
517 prop_text_in.text = "U";
518
519 draw_text((void*)&prop_text_in, (void*)draw_context_in);
520 gdk_gc_unref(draw_context_in->gc);
521
522 /* Draw the line of the in process */
523 if(draw_context_in->previous->middle->x == -1)
524 {
525 draw_context_in->previous->middle->x = event_request->x_begin;
526 g_critical("in middle x_beg : %u",event_request->x_begin);
527 }
528
529 draw_context_in->current->middle->x = x;
530 draw_context_in->previous->middle->y = y_in + height/2;
531 draw_context_in->current->middle->y = y_in + height/2;
532 draw_context_in->drawable = control_flow_data->drawing->pixmap;
533 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
534 //draw_context_in->gc = widget->style->black_gc;
535 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
536 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
537
538 PropertiesLine prop_line_in;
539 prop_line_in.color = g_new(GdkColor,1);
540 prop_line_in.line_width = 2;
541 prop_line_in.style = GDK_LINE_SOLID;
542 prop_line_in.position = MIDDLE;
543
544 /* color of line : status of the process */
545 if(process_in->state->s == LTTV_STATE_UNNAMED)
546 {
547 prop_line_in.color->red = 0xffff;
548 prop_line_in.color->green = 0xffff;
549 prop_line_in.color->blue = 0xffff;
550 }
551 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
552 {
553 prop_line_in.color->red = 0x0fff;
554 prop_line_in.color->green = 0x0000;
555 prop_line_in.color->blue = 0x0fff;
556 }
557 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
558 {
559 prop_line_in.color->red = 0xffff;
560 prop_line_in.color->green = 0xffff;
561 prop_line_in.color->blue = 0x0000;
562 }
563 else if(process_in->state->s == LTTV_STATE_EXIT)
564 {
565 prop_line_in.color->red = 0xffff;
566 prop_line_in.color->green = 0x0000;
567 prop_line_in.color->blue = 0xffff;
568 }
569 else if(process_in->state->s == LTTV_STATE_WAIT)
570 {
571 prop_line_in.color->red = 0xffff;
572 prop_line_in.color->green = 0x0000;
573 prop_line_in.color->blue = 0x0000;
574 }
575 else if(process_in->state->s == LTTV_STATE_RUN)
576 {
577 prop_line_in.color->red = 0x0000;
578 prop_line_in.color->green = 0xffff;
579 prop_line_in.color->blue = 0x0000;
580 }
581 else
582 {
583 prop_line_in.color->red = 0xffff;
584 prop_line_in.color->green = 0xffff;
585 prop_line_in.color->blue = 0xffff;
586 }
587
588 draw_line((void*)&prop_line_in, (void*)draw_context_in);
589 g_free(prop_line_in.color);
590 gdk_gc_unref(draw_context_in->gc);
591 }
592
593 return 0;
594
595 /* Temp dump */
596#ifdef DONTSHOW
597 GString *string = g_string_new("");;
598 gboolean field_names = TRUE, state = TRUE;
599
600 lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs);
601 g_string_append_printf(string,"\n");
602
603 if(state) {
604 g_string_append_printf(string, " %s",
605 g_quark_to_string(tfs->process->state->s));
606 }
607
608 g_info("%s",string->str);
609
610 g_string_free(string, TRUE);
611
612 /* End of text dump */
613#endif //DONTSHOW
614
615}
616
617
618int draw_after_hook(void *hook_data, void *call_data)
619{
620 EventRequest *event_request = (EventRequest*)hook_data;
621 ControlFlowData *control_flow_data = event_request->control_flow_data;
622
623 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
624
625 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
626
627
628 LttEvent *e;
629 e = tfc->e;
630
631 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
632 {
633 g_critical("schedchange!");
634
635 /* Add process to process list (if not present) and get drawing "y" from
636 * process position */
637 guint pid_out, pid_in;
638 LttvProcessState *process_out, *process_in;
639 LttTime birth;
640 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
641
642 ProcessList *process_list =
643 guicontrolflow_get_process_list(event_request->control_flow_data);
644
645
646 LttField *f = ltt_event_field(e);
647 LttField *element;
648 element = ltt_field_member(f,0);
649 pid_out = ltt_event_get_long_unsigned(e,element);
650 element = ltt_field_member(f,1);
651 pid_in = ltt_event_get_long_unsigned(e,element);
652 //g_critical("out : %u in : %u", pid_out, pid_in);
653
654
655 /* Find process pid_out in the list... */
656 process_out = lttv_state_find_process(tfs, pid_out);
657 //g_critical("out : %s",g_quark_to_string(process_out->state->s));
658
659 birth = process_out->creation_time;
660 gchar *name = strdup(g_quark_to_string(process_out->name));
661 HashedProcessData *hashed_process_data_out = NULL;
662
663 if(processlist_get_process_pixels(process_list,
664 pid_out,
665 &birth,
666 &y_out,
667 &height,
668 &hashed_process_data_out) == 1)
669 {
670 /* Process not present */
671 processlist_add(process_list,
672 pid_out,
673 &birth,
674 name,
675 &pl_height,
676 &hashed_process_data_out);
677 processlist_get_process_pixels(process_list,
678 pid_out,
679 &birth,
680 &y_out,
681 &height,
682 &hashed_process_data_out);
683 drawing_insert_square( event_request->control_flow_data->drawing, y_out, height);
684 }
685
686 g_free(name);
687
688 /* Find process pid_in in the list... */
689 process_in = lttv_state_find_process(tfs, pid_in);
690 //g_critical("in : %s",g_quark_to_string(process_in->state->s));
691
692 birth = process_in->creation_time;
693 name = strdup(g_quark_to_string(process_in->name));
694 HashedProcessData *hashed_process_data_in = NULL;
695
696 if(processlist_get_process_pixels(process_list,
697 pid_in,
698 &birth,
699 &y_in,
700 &height,
701 &hashed_process_data_in) == 1)
702 {
703 /* Process not present */
704 processlist_add(process_list,
705 pid_in,
706 &birth,
707 name,
708 &pl_height,
709 &hashed_process_data_in);
710 processlist_get_process_pixels(process_list,
711 pid_in,
712 &birth,
713 &y_in,
714 &height,
715 &hashed_process_data_in);
716
717 drawing_insert_square( event_request->control_flow_data->drawing, y_in, height);
718 }
719 g_free(name);
720
721
722 /* Find pixels corresponding to time of the event. If the time does
723 * not fit in the window, show a warning, not supposed to happend. */
724 //guint x = 0;
725 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
726
727 //LttTime time = ltt_event_time(e);
728
729 //LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
730 // control_flow_data->time_window.start_time);
731
732
733 //convert_time_to_pixels(
734 // control_flow_data->time_window.start_time,
735 // window_end,
736 // time,
737 // width,
738 // &x);
739
740 //assert(x <= width);
741
742 /* draw what represents the event for outgoing process. */
743
744 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
745 //draw_context_out->current->modify_over->x = x;
746 draw_context_out->current->modify_over->y = y_out;
747 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
748 draw_context_out->drawable = control_flow_data->drawing->pixmap;
749 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
750 GtkWidget *widget = control_flow_data->drawing->drawing_area;
751 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
752 draw_context_out->gc = widget->style->black_gc;
753
754 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
755 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
756
757 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
758 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
759 PropertiesText prop_text_out;
760 prop_text_out.foreground = &colorfg_out;
761 prop_text_out.background = &colorbg_out;
762 prop_text_out.size = 6;
763 prop_text_out.position = OVER;
764
765 /* color of text : status of the process */
766 if(process_out->state->s == LTTV_STATE_UNNAMED)
767 {
768 prop_text_out.foreground->red = 0xffff;
769 prop_text_out.foreground->green = 0xffff;
770 prop_text_out.foreground->blue = 0xffff;
771 }
772 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
773 {
774 prop_text_out.foreground->red = 0x0fff;
775 prop_text_out.foreground->green = 0x0000;
776 prop_text_out.foreground->blue = 0x0fff;
777 }
778 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
779 {
780 prop_text_out.foreground->red = 0xffff;
781 prop_text_out.foreground->green = 0xffff;
782 prop_text_out.foreground->blue = 0x0000;
783 }
784 else if(process_out->state->s == LTTV_STATE_EXIT)
785 {
786 prop_text_out.foreground->red = 0xffff;
787 prop_text_out.foreground->green = 0x0000;
788 prop_text_out.foreground->blue = 0xffff;
789 }
790 else if(process_out->state->s == LTTV_STATE_WAIT)
791 {
792 prop_text_out.foreground->red = 0xffff;
793 prop_text_out.foreground->green = 0x0000;
794 prop_text_out.foreground->blue = 0x0000;
795 }
796 else if(process_out->state->s == LTTV_STATE_RUN)
797 {
798 prop_text_out.foreground->red = 0x0000;
799 prop_text_out.foreground->green = 0xffff;
800 prop_text_out.foreground->blue = 0x0000;
801 }
802 else
803 {
804 prop_text_out.foreground->red = 0xffff;
805 prop_text_out.foreground->green = 0xffff;
806 prop_text_out.foreground->blue = 0xffff;
807 }
808
809 /* Print status of the process : U, WF, WC, E, W, R */
810 if(process_out->state->s == LTTV_STATE_UNNAMED)
811 prop_text_out.text = "U";
812 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
813 prop_text_out.text = "WF";
814 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
815 prop_text_out.text = "WC";
816 else if(process_out->state->s == LTTV_STATE_EXIT)
817 prop_text_out.text = "E";
818 else if(process_out->state->s == LTTV_STATE_WAIT)
819 prop_text_out.text = "W";
820 else if(process_out->state->s == LTTV_STATE_RUN)
821 prop_text_out.text = "R";
822 else
823 prop_text_out.text = "U";
824
825 draw_text((void*)&prop_text_out, (void*)draw_context_out);
826
827 draw_context_out->current->middle->y = y_out+height/2;
828 draw_context_out->current->status = process_out->state->s;
829
830 /* for pid_out : remove previous, Prev = current, new current (default) */
831 g_free(draw_context_out->previous->modify_under);
832 g_free(draw_context_out->previous->modify_middle);
833 g_free(draw_context_out->previous->modify_over);
834 g_free(draw_context_out->previous->under);
835 g_free(draw_context_out->previous->middle);
836 g_free(draw_context_out->previous->over);
837 g_free(draw_context_out->previous);
838
839 draw_context_out->previous = draw_context_out->current;
840
841 draw_context_out->current = g_new(DrawInfo,1);
842 draw_context_out->current->over = g_new(ItemInfo,1);
843 draw_context_out->current->over->x = -1;
844 draw_context_out->current->over->y = -1;
845 draw_context_out->current->middle = g_new(ItemInfo,1);
846 draw_context_out->current->middle->x = -1;
847 draw_context_out->current->middle->y = -1;
848 draw_context_out->current->under = g_new(ItemInfo,1);
849 draw_context_out->current->under->x = -1;
850 draw_context_out->current->under->y = -1;
851 draw_context_out->current->modify_over = g_new(ItemInfo,1);
852 draw_context_out->current->modify_over->x = -1;
853 draw_context_out->current->modify_over->y = -1;
854 draw_context_out->current->modify_middle = g_new(ItemInfo,1);
855 draw_context_out->current->modify_middle->x = -1;
856 draw_context_out->current->modify_middle->y = -1;
857 draw_context_out->current->modify_under = g_new(ItemInfo,1);
858 draw_context_out->current->modify_under->x = -1;
859 draw_context_out->current->modify_under->y = -1;
860 draw_context_out->current->status = LTTV_STATE_UNNAMED;
861
862 /* Finally, update the drawing context of the pid_in. */
863
864 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
865 //draw_context_in->current->modify_over->x = x;
866 draw_context_in->current->modify_over->y = y_in;
867 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
868 draw_context_in->drawable = control_flow_data->drawing->pixmap;
869 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
870 widget = control_flow_data->drawing->drawing_area;
871 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
872 draw_context_in->gc = widget->style->black_gc;
873
874 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
875 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
876
877 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
878 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
879 PropertiesText prop_text_in;
880 prop_text_in.foreground = &colorfg_in;
881 prop_text_in.background = &colorbg_in;
882 prop_text_in.size = 6;
883 prop_text_in.position = OVER;
884
885 /* foreground of text : status of the process */
886 if(process_in->state->s == LTTV_STATE_UNNAMED)
887 {
888 prop_text_in.foreground->red = 0xffff;
889 prop_text_in.foreground->green = 0xffff;
890 prop_text_in.foreground->blue = 0xffff;
891 }
892 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
893 {
894 prop_text_in.foreground->red = 0x0fff;
895 prop_text_in.foreground->green = 0x0000;
896 prop_text_in.foreground->blue = 0x0fff;
897 }
898 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
899 {
900 prop_text_in.foreground->red = 0xffff;
901 prop_text_in.foreground->green = 0xffff;
902 prop_text_in.foreground->blue = 0x0000;
903 }
904 else if(process_in->state->s == LTTV_STATE_EXIT)
905 {
906 prop_text_in.foreground->red = 0xffff;
907 prop_text_in.foreground->green = 0x0000;
908 prop_text_in.foreground->blue = 0xffff;
909 }
910 else if(process_in->state->s == LTTV_STATE_WAIT)
911 {
912 prop_text_in.foreground->red = 0xffff;
913 prop_text_in.foreground->green = 0x0000;
914 prop_text_in.foreground->blue = 0x0000;
915 }
916 else if(process_in->state->s == LTTV_STATE_RUN)
917 {
918 prop_text_in.foreground->red = 0x0000;
919 prop_text_in.foreground->green = 0xffff;
920 prop_text_in.foreground->blue = 0x0000;
921 }
922 else
923 {
924 prop_text_in.foreground->red = 0xffff;
925 prop_text_in.foreground->green = 0xffff;
926 prop_text_in.foreground->blue = 0xffff;
927 }
928
929
930 /* Print status of the process : U, WF, WC, E, W, R */
931 if(process_in->state->s == LTTV_STATE_UNNAMED)
932 prop_text_in.text = "U";
933 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
934 prop_text_in.text = "WF";
935 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
936 prop_text_in.text = "WC";
937 else if(process_in->state->s == LTTV_STATE_EXIT)
938 prop_text_in.text = "E";
939 else if(process_in->state->s == LTTV_STATE_WAIT)
940 prop_text_in.text = "W";
941 else if(process_in->state->s == LTTV_STATE_RUN)
942 prop_text_in.text = "R";
943 else
944 prop_text_in.text = "U";
945
946 draw_text((void*)&prop_text_in, (void*)draw_context_in);
947
948 if(process_in->state->s == LTTV_STATE_RUN)
949 {
950 gchar tmp[255];
951 prop_text_in.foreground = &colorfg_in;
952 prop_text_in.background = &colorbg_in;
953 prop_text_in.foreground->red = 0xffff;
954 prop_text_in.foreground->green = 0xffff;
955 prop_text_in.foreground->blue = 0xffff;
956 prop_text_in.size = 6;
957 prop_text_in.position = UNDER;
958
959 prop_text_in.text = g_new(gchar, 260);
960 strcpy(prop_text_in.text, "CPU ");
961 snprintf(tmp, 255, "%u", tfc->index);
962 strcat(prop_text_in.text, tmp);
963
964 draw_text((void*)&prop_text_in, (void*)draw_context_in);
965 g_free(prop_text_in.text);
966 }
967
968
969 draw_context_in->current->middle->y = y_in+height/2;
970 draw_context_in->current->status = process_in->state->s;
971
972 /* for pid_in : remove previous, Prev = current, new current (default) */
973 g_free(draw_context_in->previous->modify_under);
974 g_free(draw_context_in->previous->modify_middle);
975 g_free(draw_context_in->previous->modify_over);
976 g_free(draw_context_in->previous->under);
977 g_free(draw_context_in->previous->middle);
978 g_free(draw_context_in->previous->over);
979 g_free(draw_context_in->previous);
980
981 draw_context_in->previous = draw_context_in->current;
982
983 draw_context_in->current = g_new(DrawInfo,1);
984 draw_context_in->current->over = g_new(ItemInfo,1);
985 draw_context_in->current->over->x = -1;
986 draw_context_in->current->over->y = -1;
987 draw_context_in->current->middle = g_new(ItemInfo,1);
988 draw_context_in->current->middle->x = -1;
989 draw_context_in->current->middle->y = -1;
990 draw_context_in->current->under = g_new(ItemInfo,1);
991 draw_context_in->current->under->x = -1;
992 draw_context_in->current->under->y = -1;
993 draw_context_in->current->modify_over = g_new(ItemInfo,1);
994 draw_context_in->current->modify_over->x = -1;
995 draw_context_in->current->modify_over->y = -1;
996 draw_context_in->current->modify_middle = g_new(ItemInfo,1);
997 draw_context_in->current->modify_middle->x = -1;
998 draw_context_in->current->modify_middle->y = -1;
999 draw_context_in->current->modify_under = g_new(ItemInfo,1);
1000 draw_context_in->current->modify_under->x = -1;
1001 draw_context_in->current->modify_under->y = -1;
1002 draw_context_in->current->status = LTTV_STATE_UNNAMED;
1003
1004 }
1005
1006 return 0;
1007}
1008
1009
1010
1011
1012gint update_time_window_hook(void *hook_data, void *call_data)
1013{
1014 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
1015 TimeWindow *old_time_window =
1016 guicontrolflow_get_time_window(control_flow_data);
1017 TimeWindow *new_time_window = ((TimeWindow*)call_data);
1018
1019 /* Two cases : zoom in/out or scrolling */
1020
1021 /* In order to make sure we can reuse the old drawing, the scale must
1022 * be the same and the new time interval being partly located in the
1023 * currently shown time interval. (reuse is only for scrolling)
1024 */
1025
1026 g_info("Old time window HOOK : %u, %u to %u, %u",
1027 old_time_window->start_time.tv_sec,
1028 old_time_window->start_time.tv_nsec,
1029 old_time_window->time_width.tv_sec,
1030 old_time_window->time_width.tv_nsec);
1031
1032 g_info("New time window HOOK : %u, %u to %u, %u",
1033 new_time_window->start_time.tv_sec,
1034 new_time_window->start_time.tv_nsec,
1035 new_time_window->time_width.tv_sec,
1036 new_time_window->time_width.tv_nsec);
1037
1038 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
1039 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
1040 {
1041 /* Same scale (scrolling) */
1042 g_info("scrolling");
1043 LttTime *ns = &new_time_window->start_time;
1044 LttTime *os = &old_time_window->start_time;
1045 LttTime old_end = ltt_time_add(old_time_window->start_time,
1046 old_time_window->time_width);
1047 LttTime new_end = ltt_time_add(new_time_window->start_time,
1048 new_time_window->time_width);
1049 //if(ns<os+w<ns+w)
1050 //if(ns<os+w && os+w<ns+w)
1051 //if(ns<old_end && os<ns)
1052 if(ltt_time_compare(*ns, old_end) == -1
1053 && ltt_time_compare(*os, *ns) == -1)
1054 {
1055 g_info("scrolling near right");
1056 /* Scroll right, keep right part of the screen */
1057 guint x = 0;
1058 guint width = control_flow_data->drawing->drawing_area->allocation.width;
1059 convert_time_to_pixels(
1060 *os,
1061 old_end,
1062 *ns,
1063 width,
1064 &x);
1065
1066 /* Copy old data to new location */
1067 gdk_draw_drawable (control_flow_data->drawing->pixmap,
1068 control_flow_data->drawing->drawing_area->style->black_gc,
1069 control_flow_data->drawing->pixmap,
1070 x, 0,
1071 0, 0,
1072 -1, -1);
1073
1074 convert_time_to_pixels(
1075 *ns,
1076 new_end,
1077 old_end,
1078 width,
1079 &x);
1080
1081 *old_time_window = *new_time_window;
1082 /* Clear the data request background, but not SAFETY */
1083 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
1084 control_flow_data->drawing->drawing_area->style->black_gc,
1085 TRUE,
1086 x+SAFETY, 0,
1087 control_flow_data->drawing->width - x, // do not overlap
1088 control_flow_data->drawing->height+SAFETY);
1089 /* Get new data for the rest. */
1090 drawing_data_request(control_flow_data->drawing,
1091 &control_flow_data->drawing->pixmap,
1092 x, 0,
1093 control_flow_data->drawing->width - x,
1094 control_flow_data->drawing->height);
1095
1096 drawing_refresh(control_flow_data->drawing,
1097 0, 0,
1098 control_flow_data->drawing->width,
1099 control_flow_data->drawing->height);
1100
1101
1102 } else {
1103 //if(ns<os<ns+w)
1104 //if(ns<os && os<ns+w)
1105 //if(ns<os && os<new_end)
1106 if(ltt_time_compare(*ns,*os) == -1
1107 && ltt_time_compare(*os,new_end) == -1)
1108 {
1109 g_info("scrolling near left");
1110 /* Scroll left, keep left part of the screen */
1111 guint x = 0;
1112 guint width = control_flow_data->drawing->drawing_area->allocation.width;
1113 convert_time_to_pixels(
1114 *ns,
1115 new_end,
1116 *os,
1117 width,
1118 &x);
1119
1120 /* Copy old data to new location */
1121 gdk_draw_drawable (control_flow_data->drawing->pixmap,
1122 control_flow_data->drawing->drawing_area->style->black_gc,
1123 control_flow_data->drawing->pixmap,
1124 0, 0,
1125 x, 0,
1126 -1, -1);
1127
1128 *old_time_window = *new_time_window;
1129
1130 /* Clean the data request background */
1131 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
1132 control_flow_data->drawing->drawing_area->style->black_gc,
1133 TRUE,
1134 0, 0,
1135 x, // do not overlap
1136 control_flow_data->drawing->height+SAFETY);
1137 /* Get new data for the rest. */
1138 drawing_data_request(control_flow_data->drawing,
1139 &control_flow_data->drawing->pixmap,
1140 0, 0,
1141 x,
1142 control_flow_data->drawing->height);
1143
1144 drawing_refresh(control_flow_data->drawing,
1145 0, 0,
1146 control_flow_data->drawing->width,
1147 control_flow_data->drawing->height);
1148
1149 } else {
1150 g_info("scrolling far");
1151 /* Cannot reuse any part of the screen : far jump */
1152 *old_time_window = *new_time_window;
1153
1154
1155 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
1156 control_flow_data->drawing->drawing_area->style->black_gc,
1157 TRUE,
1158 0, 0,
1159 control_flow_data->drawing->width+SAFETY, // do not overlap
1160 control_flow_data->drawing->height+SAFETY);
1161
1162 drawing_data_request(control_flow_data->drawing,
1163 &control_flow_data->drawing->pixmap,
1164 0, 0,
1165 control_flow_data->drawing->width,
1166 control_flow_data->drawing->height);
1167
1168 drawing_refresh(control_flow_data->drawing,
1169 0, 0,
1170 control_flow_data->drawing->width,
1171 control_flow_data->drawing->height);
1172 }
1173 }
1174 } else {
1175 /* Different scale (zoom) */
1176 g_info("zoom");
1177
1178 *old_time_window = *new_time_window;
1179
1180 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
1181 control_flow_data->drawing->drawing_area->style->black_gc,
1182 TRUE,
1183 0, 0,
1184 control_flow_data->drawing->width+SAFETY, // do not overlap
1185 control_flow_data->drawing->height+SAFETY);
1186
1187
1188 drawing_data_request(control_flow_data->drawing,
1189 &control_flow_data->drawing->pixmap,
1190 0, 0,
1191 control_flow_data->drawing->width,
1192 control_flow_data->drawing->height);
1193
1194 drawing_refresh(control_flow_data->drawing,
1195 0, 0,
1196 control_flow_data->drawing->width,
1197 control_flow_data->drawing->height);
1198 }
1199
1200 return 0;
1201}
1202
1203gint update_current_time_hook(void *hook_data, void *call_data)
1204{
1205 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
1206
1207 LttTime* current_time =
1208 guicontrolflow_get_current_time(control_flow_data);
1209 *current_time = *((LttTime*)call_data);
1210
1211 TimeWindow time_window;
1212
1213 LttTime time_begin = control_flow_data->time_window.start_time;
1214 LttTime width = control_flow_data->time_window.time_width;
1215 LttTime half_width = ltt_time_div(width,2.0);
1216 LttTime time_end = ltt_time_add(time_begin, width);
1217
1218 LttvTracesetContext * tsc =
1219 get_traceset_context(control_flow_data->mw);
1220
1221 LttTime trace_start = tsc->Time_Span->startTime;
1222 LttTime trace_end = tsc->Time_Span->endTime;
1223
1224 g_info("New current time HOOK : %u, %u", current_time->tv_sec,
1225 current_time->tv_nsec);
1226
1227
1228
1229 /* If current time is inside time interval, just move the highlight
1230 * bar */
1231
1232 /* Else, we have to change the time interval. We have to tell it
1233 * to the main window. */
1234 /* The time interval change will take care of placing the current
1235 * time at the center of the visible area, or nearest possible if we are
1236 * at one end of the trace. */
1237
1238
1239 if(ltt_time_compare(*current_time, time_begin) == -1)
1240 {
1241 if(ltt_time_compare(*current_time,
1242 ltt_time_add(trace_start,half_width)) == -1)
1243 time_begin = trace_start;
1244 else
1245 time_begin = ltt_time_sub(*current_time,half_width);
1246
1247 time_window.start_time = time_begin;
1248 time_window.time_width = width;
1249
1250 set_time_window(control_flow_data->mw, &time_window);
1251 }
1252 else if(ltt_time_compare(*current_time, time_end) == 1)
1253 {
1254 if(ltt_time_compare(*current_time, ltt_time_sub(trace_end, half_width)) == 1)
1255 time_begin = ltt_time_sub(trace_end,width);
1256 else
1257 time_begin = ltt_time_sub(*current_time,half_width);
1258
1259 time_window.start_time = time_begin;
1260 time_window.time_width = width;
1261
1262 set_time_window(control_flow_data->mw, &time_window);
1263
1264 }
1265 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
1266
1267 return 0;
1268}
1269
1270typedef struct _ClosureData {
1271 EventRequest *event_request;
1272 LttvTraceState *ts;
1273} ClosureData;
1274
1275
1276void draw_closure(gpointer key, gpointer value, gpointer user_data)
1277{
1278 ProcessInfo *process_info = (ProcessInfo*)key;
1279 HashedProcessData *hashed_process_data = (HashedProcessData*)value;
1280 ClosureData *closure_data = (ClosureData*)user_data;
1281
1282 ControlFlowData *control_flow_data =
1283 closure_data->event_request->control_flow_data;
1284
1285 GtkWidget *widget = control_flow_data->drawing->drawing_area;
1286
1287 /* Get y position of process */
1288 gint y=0, height=0;
1289
1290 processlist_get_pixels_from_data( control_flow_data->process_list,
1291 process_info,
1292 hashed_process_data,
1293 &y,
1294 &height);
1295 /* Get last state of process */
1296 LttvTraceContext *tc =
1297 (LttvTraceContext *)closure_data->ts;
1298
1299 LttvTraceState *ts = closure_data->ts;
1300 LttvProcessState *process;
1301
1302 process = lttv_state_find_process((LttvTracefileState*)ts, process_info->pid);
1303
1304 /* Draw the closing line */
1305 DrawContext *draw_context = hashed_process_data->draw_context;
1306 if(draw_context->previous->middle->x == -1)
1307 {
1308 draw_context->previous->middle->x = closure_data->event_request->x_begin;
1309 g_critical("out middle x_beg : %u",closure_data->event_request->x_begin);
1310 }
1311
1312 draw_context->current->middle->x = closure_data->event_request->x_end;
1313 draw_context->current->middle->y = y + height/2;
1314 draw_context->previous->middle->y = y + height/2;
1315 draw_context->drawable = control_flow_data->drawing->pixmap;
1316 draw_context->pango_layout = control_flow_data->drawing->pango_layout;
1317 //draw_context->gc = widget->style->black_gc;
1318 draw_context->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1319 gdk_gc_copy(draw_context->gc, widget->style->black_gc);
1320
1321 PropertiesLine prop_line;
1322 prop_line.color = g_new(GdkColor,1);
1323 prop_line.line_width = 2;
1324 prop_line.style = GDK_LINE_SOLID;
1325 prop_line.position = MIDDLE;
1326
1327 /* color of line : status of the process */
1328 if(process->state->s == LTTV_STATE_UNNAMED)
1329 {
1330 prop_line.color->red = 0xffff;
1331 prop_line.color->green = 0xffff;
1332 prop_line.color->blue = 0xffff;
1333 }
1334 else if(process->state->s == LTTV_STATE_WAIT_FORK)
1335 {
1336 prop_line.color->red = 0x0fff;
1337 prop_line.color->green = 0x0000;
1338 prop_line.color->blue = 0x0fff;
1339 }
1340 else if(process->state->s == LTTV_STATE_WAIT_CPU)
1341 {
1342 prop_line.color->red = 0xffff;
1343 prop_line.color->green = 0xffff;
1344 prop_line.color->blue = 0x0000;
1345 }
1346 else if(process->state->s == LTTV_STATE_EXIT)
1347 {
1348 prop_line.color->red = 0xffff;
1349 prop_line.color->green = 0x0000;
1350 prop_line.color->blue = 0xffff;
1351 }
1352 else if(process->state->s == LTTV_STATE_WAIT)
1353 {
1354 prop_line.color->red = 0xffff;
1355 prop_line.color->green = 0x0000;
1356 prop_line.color->blue = 0x0000;
1357 }
1358 else if(process->state->s == LTTV_STATE_RUN)
1359 {
1360 prop_line.color->red = 0x0000;
1361 prop_line.color->green = 0xffff;
1362 prop_line.color->blue = 0x0000;
1363 }
1364 else
1365 {
1366 prop_line.color->red = 0xffff;
1367 prop_line.color->green = 0xffff;
1368 prop_line.color->blue = 0xffff;
1369 }
1370
1371 draw_line((void*)&prop_line, (void*)draw_context);
1372 g_free(prop_line.color);
1373 gdk_gc_unref(draw_context->gc);
1374
1375 /* Reset draw_context of the process for next request */
1376
1377 hashed_process_data->draw_context->drawable = NULL;
1378 hashed_process_data->draw_context->gc = NULL;
1379 hashed_process_data->draw_context->pango_layout = NULL;
1380 hashed_process_data->draw_context->current->over->x = -1;
1381 hashed_process_data->draw_context->current->over->y = -1;
1382 hashed_process_data->draw_context->current->middle->x = -1;
1383 hashed_process_data->draw_context->current->middle->y = -1;
1384 hashed_process_data->draw_context->current->under->x = -1;
1385 hashed_process_data->draw_context->current->under->y = -1;
1386 hashed_process_data->draw_context->current->modify_over->x = -1;
1387 hashed_process_data->draw_context->current->modify_over->y = -1;
1388 hashed_process_data->draw_context->current->modify_middle->x = -1;
1389 hashed_process_data->draw_context->current->modify_middle->y = -1;
1390 hashed_process_data->draw_context->current->modify_under->x = -1;
1391 hashed_process_data->draw_context->current->modify_under->y = -1;
1392 hashed_process_data->draw_context->current->status = LTTV_STATE_UNNAMED;
1393 hashed_process_data->draw_context->previous->over->x = -1;
1394 hashed_process_data->draw_context->previous->over->y = -1;
1395 hashed_process_data->draw_context->previous->middle->x = -1;
1396 hashed_process_data->draw_context->previous->middle->y = -1;
1397 hashed_process_data->draw_context->previous->under->x = -1;
1398 hashed_process_data->draw_context->previous->under->y = -1;
1399 hashed_process_data->draw_context->previous->modify_over->x = -1;
1400 hashed_process_data->draw_context->previous->modify_over->y = -1;
1401 hashed_process_data->draw_context->previous->modify_middle->x = -1;
1402 hashed_process_data->draw_context->previous->modify_middle->y = -1;
1403 hashed_process_data->draw_context->previous->modify_under->x = -1;
1404 hashed_process_data->draw_context->previous->modify_under->y = -1;
1405 hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED;
1406
1407
1408}
1409
1410/*
1411 * for each process
1412 * draw closing line
1413 * new default prev and current
1414 */
1415int after_data_request(void *hook_data, void *call_data)
1416{
1417 EventRequest *event_request = (EventRequest*)hook_data;
1418 ControlFlowData *control_flow_data = event_request->control_flow_data;
1419
1420 ProcessList *process_list =
1421 guicontrolflow_get_process_list(event_request->control_flow_data);
1422
1423 ClosureData closure_data;
1424 closure_data.event_request = (EventRequest*)hook_data;
1425 closure_data.ts = (LttvTraceState*)call_data;
1426
1427 g_hash_table_foreach(process_list->process_hash, draw_closure,
1428 (void*)&closure_data);
1429
1430}
1431
This page took 0.026142 seconds and 4 git commands to generate.