continue, redraw, stop, ok
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / eventhooks.c
CommitLineData
ce0214a6 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
f0d936c0 20/*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
23
f0d936c0 24
cf6cb7e0 25//#define PANGO_ENABLE_BACKEND
558aa013 26#include <gtk/gtk.h>
27#include <gdk/gdk.h>
5f16133f 28#include <glib.h>
80a52ff8 29#include <assert.h>
50439712 30#include <string.h>
319e9d81 31#include <stdio.h>
5f16133f 32
cf6cb7e0 33//#include <pango/pango.h>
34
80a52ff8 35#include <ltt/event.h>
4ba42155 36#include <ltt/time.h>
50439712 37#include <ltt/type.h>
80a52ff8 38
2a2fa4f0 39#include <lttv/lttv.h>
558aa013 40#include <lttv/hook.h>
80a52ff8 41#include <lttv/state.h>
2d262115 42#include <lttvwindow/lttvwindow.h>
80a52ff8 43
f0d936c0 44
a117e3f7 45#include "eventhooks.h"
46#include "cfv.h"
47#include "processlist.h"
48#include "drawing.h"
49#include "cfv-private.h"
5f16133f 50
80a52ff8 51
1a31868c 52#define MAX_PATH_LEN 256
53
f0d936c0 54
55/**
56 * Event Viewer's constructor hook
57 *
58 * This constructor is given as a parameter to the menuitem and toolbar button
59 * registration. It creates the list.
ca0f8a8e 60 * @param tab A pointer to the parent tab.
f0d936c0 61 * @return The widget created.
62 */
63GtkWidget *
ca0f8a8e 64h_guicontrolflow(Tab *tab, LttvTracesetSelector * s, char * key)
f0d936c0 65{
ca0f8a8e 66 g_info("h_guicontrolflow, %p, %p, %s", tab, s, key);
68997a22 67 ControlFlowData *control_flow_data = guicontrolflow() ;
a56a1ba4 68
ca0f8a8e 69 control_flow_data->tab = tab;
a56a1ba4 70
2a2fa4f0 71 //g_debug("time width2 : %u",time_window->time_width);
a56a1ba4 72 // Unreg done in the GuiControlFlow_Destructor
ca0f8a8e 73 lttvwindow_register_time_window_notify(tab,
224446ce 74 update_time_window_hook,
75 control_flow_data);
ca0f8a8e 76 lttvwindow_register_current_time_notify(tab,
224446ce 77 update_current_time_hook,
78 control_flow_data);
ca0f8a8e 79 lttvwindow_register_redraw_notify(tab,
80 redraw_notify,
81 control_flow_data);
82 lttvwindow_register_continue_notify(tab,
83 continue_notify,
84 control_flow_data);
85
86
68997a22 87 return guicontrolflow_get_widget(control_flow_data) ;
a56a1ba4 88
f0d936c0 89}
90
3cff8cc1 91int event_selected_hook(void *hook_data, void *call_data)
f0d936c0 92{
68997a22 93 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
14963be0 94 guint *event_number = (guint*) call_data;
f0d936c0 95
2a2fa4f0 96 g_debug("DEBUG : event selected by main window : %u", *event_number);
a56a1ba4 97
14963be0 98// control_flow_data->currently_Selected_Event = *event_number;
68997a22 99// control_flow_data->Selected_Event = TRUE ;
a56a1ba4 100
68997a22 101// tree_v_set_cursor(control_flow_data);
f0d936c0 102
103}
104
f0d936c0 105/* Hook called before drawing. Gets the initial context at the beginning of the
14963be0 106 * drawing interval and copy it to the context in event_request.
f0d936c0 107 */
4c69e0cc 108int draw_before_hook(void *hook_data, void *call_data)
f0d936c0 109{
ca0f8a8e 110 EventsRequest *events_request = (EventsRequest*)hook_data;
a56a1ba4 111 //EventsContext Events_Context = (EventsContext*)call_data;
112
14963be0 113 //event_request->Events_Context = Events_Context;
f0d936c0 114
a56a1ba4 115 return 0;
f0d936c0 116}
117
118/*
119 * The draw event hook is called by the reading API to have a
120 * particular event drawn on the screen.
121 * @param hook_data ControlFlowData structure of the viewer.
122 * @param call_data Event context.
123 *
124 * This function basically draw lines and icons. Two types of lines are drawn :
125 * one small (3 pixels?) representing the state of the process and the second
126 * type is thicker (10 pixels?) representing on which CPU a process is running
127 * (and this only in running state).
128 *
129 * Extremums of the lines :
130 * x_min : time of the last event context for this process kept in memory.
131 * x_max : time of the current event.
132 * y : middle of the process in the process list. The process is found in the
133 * list, therefore is it's position in pixels.
134 *
135 * The choice of lines'color is defined by the context of the last event for this
136 * process.
137 */
4c69e0cc 138int draw_event_hook(void *hook_data, void *call_data)
f0d936c0 139{
ca0f8a8e 140 EventsRequest *events_request = (EventsRequest*)hook_data;
141 ControlFlowData *control_flow_data =
142 (ControlFlowData*)events_request->viewer_data;
143 Tab *tab = control_flow_data->tab;
e9a9c513 144
a56a1ba4 145 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
e9a9c513 146
147 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1aff52a2 148 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
a56a1ba4 149
e9a9c513 150 LttEvent *e;
e9a9c513 151 e = tfc->e;
152
9444deae 153 LttTime evtime = ltt_event_time(e);
ca0f8a8e 154 TimeWindow time_window =
155 lttvwindow_get_time_window(tab);
9444deae 156
ca0f8a8e 157 LttTime end_time = ltt_time_add(time_window.start_time,
158 time_window.time_width);
9444deae 159 //if(time < time_beg || time > time_end) return;
ca0f8a8e 160 if(ltt_time_compare(evtime, time_window.start_time) == -1
9444deae 161 || ltt_time_compare(evtime, end_time) == 1)
162 return;
163
a56a1ba4 164 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
165 {
2a2fa4f0 166 g_debug("schedchange!");
a56a1ba4 167
168 /* Add process to process list (if not present) and get drawing "y" from
169 * process position */
170 guint pid_out, pid_in;
171 LttvProcessState *process_out, *process_in;
172 LttTime birth;
173 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
174
175 ProcessList *process_list =
ca0f8a8e 176 guicontrolflow_get_process_list(control_flow_data);
a56a1ba4 177
178
179 LttField *f = ltt_event_field(e);
180 LttField *element;
181 element = ltt_field_member(f,0);
182 pid_out = ltt_event_get_long_unsigned(e,element);
183 element = ltt_field_member(f,1);
184 pid_in = ltt_event_get_long_unsigned(e,element);
2a2fa4f0 185 g_debug("out : %u in : %u", pid_out, pid_in);
a56a1ba4 186
187
188 /* Find process pid_out in the list... */
87658614 189 process_out = lttv_state_find_process(tfs, pid_out);
1aff52a2 190 if(process_out == NULL) return 0;
2a2fa4f0 191 g_debug("out : %s",g_quark_to_string(process_out->state->s));
1aff52a2 192
a56a1ba4 193 birth = process_out->creation_time;
194 gchar *name = strdup(g_quark_to_string(process_out->name));
14963be0 195 HashedProcessData *hashed_process_data_out = NULL;
a56a1ba4 196
197 if(processlist_get_process_pixels(process_list,
198 pid_out,
199 &birth,
d0cd7f09 200 tfc->t_context->index,
a56a1ba4 201 &y_out,
202 &height,
14963be0 203 &hashed_process_data_out) == 1)
a56a1ba4 204 {
205 /* Process not present */
206 processlist_add(process_list,
207 pid_out,
208 &birth,
d0cd7f09 209 tfc->t_context->index,
a56a1ba4 210 name,
211 &pl_height,
14963be0 212 &hashed_process_data_out);
a56a1ba4 213 processlist_get_process_pixels(process_list,
214 pid_out,
215 &birth,
d0cd7f09 216 tfc->t_context->index,
a56a1ba4 217 &y_out,
218 &height,
14963be0 219 &hashed_process_data_out);
ca0f8a8e 220 drawing_insert_square( control_flow_data->drawing, y_out, height);
a56a1ba4 221 }
222
223 g_free(name);
224
225 /* Find process pid_in in the list... */
87658614 226 process_in = lttv_state_find_process(tfs, pid_in);
1aff52a2 227 if(process_in == NULL) return 0;
2a2fa4f0 228 g_debug("in : %s",g_quark_to_string(process_in->state->s));
a56a1ba4 229
230 birth = process_in->creation_time;
231 name = strdup(g_quark_to_string(process_in->name));
14963be0 232 HashedProcessData *hashed_process_data_in = NULL;
a56a1ba4 233
234 if(processlist_get_process_pixels(process_list,
235 pid_in,
236 &birth,
d0cd7f09 237 tfc->t_context->index,
a56a1ba4 238 &y_in,
239 &height,
14963be0 240 &hashed_process_data_in) == 1)
a56a1ba4 241 {
242 /* Process not present */
243 processlist_add(process_list,
244 pid_in,
245 &birth,
d0cd7f09 246 tfc->t_context->index,
a56a1ba4 247 name,
248 &pl_height,
14963be0 249 &hashed_process_data_in);
a56a1ba4 250 processlist_get_process_pixels(process_list,
251 pid_in,
252 &birth,
d0cd7f09 253 tfc->t_context->index,
a56a1ba4 254 &y_in,
255 &height,
14963be0 256 &hashed_process_data_in);
a56a1ba4 257
ca0f8a8e 258 drawing_insert_square( control_flow_data->drawing, y_in, height);
a56a1ba4 259 }
260 g_free(name);
261
262
263 /* Find pixels corresponding to time of the event. If the time does
264 * not fit in the window, show a warning, not supposed to happend. */
265 guint x = 0;
501d5405 266 guint width = control_flow_data->drawing->drawing_area->allocation.width;
a56a1ba4 267
268 LttTime time = ltt_event_time(e);
269
ca0f8a8e 270 LttTime window_end = ltt_time_add(time_window.time_width,
271 time_window.start_time);
a56a1ba4 272
273
274 convert_time_to_pixels(
ca0f8a8e 275 time_window.start_time,
a56a1ba4 276 window_end,
277 time,
278 width,
279 &x);
9444deae 280 //assert(x <= width);
a56a1ba4 281
282 /* draw what represents the event for outgoing process. */
283
14963be0 284 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
68997a22 285 draw_context_out->current->modify_over->x = x;
319e9d81 286 draw_context_out->current->modify_under->x = x;
68997a22 287 draw_context_out->current->modify_over->y = y_out;
319e9d81 288 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
501d5405 289 draw_context_out->drawable = control_flow_data->drawing->pixmap;
290 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
291 GtkWidget *widget = control_flow_data->drawing->drawing_area;
a56a1ba4 292 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
d0cd7f09 293 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
294 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
a56a1ba4 295 //draw_context_out->gc = widget->style->black_gc;
296
297 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
501d5405 298 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
a56a1ba4 299
d0cd7f09 300 /* Draw the line/background of the out process */
301 if(draw_context_out->previous->middle->x == -1)
302 {
ca0f8a8e 303 draw_context_out->previous->over->x =
304 control_flow_data->drawing->damage_begin;
305 draw_context_out->previous->middle->x =
306 control_flow_data->drawing->damage_begin;
307 draw_context_out->previous->under->x =
308 control_flow_data->drawing->damage_begin;
309
310 g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin);
d0cd7f09 311 }
312
313 draw_context_out->current->middle->x = x;
314 draw_context_out->current->over->x = x;
315 draw_context_out->current->under->x = x;
316 draw_context_out->current->middle->y = y_out + height/2;
317 draw_context_out->current->over->y = y_out;
318 draw_context_out->current->under->y = y_out + height;
319 draw_context_out->previous->middle->y = y_out + height/2;
320 draw_context_out->previous->over->y = y_out;
321 draw_context_out->previous->under->y = y_out + height;
322
323 draw_context_out->drawable = control_flow_data->drawing->pixmap;
324 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
325
326 if(process_out->state->s == LTTV_STATE_RUN)
327 {
328 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
329 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
330
331 PropertiesBG prop_bg;
332 prop_bg.color = g_new(GdkColor,1);
333
334 switch(tfc->index) {
335 case 0:
336 prop_bg.color->red = 0x1515;
337 prop_bg.color->green = 0x1515;
338 prop_bg.color->blue = 0x8c8c;
339 break;
340 case 1:
341 prop_bg.color->red = 0x4e4e;
342 prop_bg.color->green = 0xa9a9;
343 prop_bg.color->blue = 0xa4a4;
344 break;
345 case 2:
346 prop_bg.color->red = 0x7a7a;
347 prop_bg.color->green = 0x4a4a;
348 prop_bg.color->blue = 0x8b8b;
349 break;
350 case 3:
351 prop_bg.color->red = 0x8080;
352 prop_bg.color->green = 0x7777;
353 prop_bg.color->blue = 0x4747;
354 break;
355 default:
356 prop_bg.color->red = 0xe7e7;
357 prop_bg.color->green = 0xe7e7;
358 prop_bg.color->blue = 0xe7e7;
359 }
360
2a2fa4f0 361 g_debug("calling from draw_event");
d0cd7f09 362 draw_bg((void*)&prop_bg, (void*)draw_context_out);
363 g_free(prop_bg.color);
364 gdk_gc_unref(draw_context_out->gc);
365 }
366
367 draw_context_out->gc = widget->style->black_gc;
368
a56a1ba4 369 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
2df6f2bd 370 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 371 PropertiesText prop_text_out;
372 prop_text_out.foreground = &colorfg_out;
373 prop_text_out.background = &colorbg_out;
cfe526b1 374 prop_text_out.size = 6;
a56a1ba4 375 prop_text_out.position = OVER;
376
cfe526b1 377 /* color of text : status of the process */
378 if(process_out->state->s == LTTV_STATE_UNNAMED)
379 {
380 prop_text_out.foreground->red = 0xffff;
381 prop_text_out.foreground->green = 0xffff;
382 prop_text_out.foreground->blue = 0xffff;
383 }
384 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
385 {
386 prop_text_out.foreground->red = 0x0fff;
d52cfc84 387 prop_text_out.foreground->green = 0xffff;
388 prop_text_out.foreground->blue = 0xfff0;
cfe526b1 389 }
390 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
391 {
2df6f2bd 392 prop_text_out.foreground->red = 0xffff;
393 prop_text_out.foreground->green = 0xffff;
cfe526b1 394 prop_text_out.foreground->blue = 0x0000;
395 }
396 else if(process_out->state->s == LTTV_STATE_EXIT)
397 {
398 prop_text_out.foreground->red = 0xffff;
399 prop_text_out.foreground->green = 0x0000;
400 prop_text_out.foreground->blue = 0xffff;
401 }
402 else if(process_out->state->s == LTTV_STATE_WAIT)
403 {
404 prop_text_out.foreground->red = 0xffff;
405 prop_text_out.foreground->green = 0x0000;
406 prop_text_out.foreground->blue = 0x0000;
407 }
408 else if(process_out->state->s == LTTV_STATE_RUN)
409 {
410 prop_text_out.foreground->red = 0x0000;
411 prop_text_out.foreground->green = 0xffff;
412 prop_text_out.foreground->blue = 0x0000;
413 }
414 else
415 {
416 prop_text_out.foreground->red = 0xffff;
417 prop_text_out.foreground->green = 0xffff;
418 prop_text_out.foreground->blue = 0xffff;
419 }
420
d52cfc84 421
a56a1ba4 422 /* Print status of the process : U, WF, WC, E, W, R */
423 if(process_out->state->s == LTTV_STATE_UNNAMED)
cfe526b1 424 prop_text_out.text = "U->";
a56a1ba4 425 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
cfe526b1 426 prop_text_out.text = "WF->";
a56a1ba4 427 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
cfe526b1 428 prop_text_out.text = "WC->";
a56a1ba4 429 else if(process_out->state->s == LTTV_STATE_EXIT)
cfe526b1 430 prop_text_out.text = "E->";
a56a1ba4 431 else if(process_out->state->s == LTTV_STATE_WAIT)
cfe526b1 432 prop_text_out.text = "W->";
a56a1ba4 433 else if(process_out->state->s == LTTV_STATE_RUN)
cfe526b1 434 prop_text_out.text = "R->";
a56a1ba4 435 else
68997a22 436 prop_text_out.text = "U";
a56a1ba4 437
438 draw_text((void*)&prop_text_out, (void*)draw_context_out);
d0cd7f09 439 //gdk_gc_unref(draw_context_out->gc);
a56a1ba4 440
501d5405 441 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
a56a1ba4 442 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
443
444 PropertiesLine prop_line_out;
445 prop_line_out.color = g_new(GdkColor,1);
cfe526b1 446 prop_line_out.line_width = 2;
a56a1ba4 447 prop_line_out.style = GDK_LINE_SOLID;
448 prop_line_out.position = MIDDLE;
d52cfc84 449
2a2fa4f0 450 g_debug("out state : %s", g_quark_to_string(process_out->state->s));
a56a1ba4 451
452 /* color of line : status of the process */
453 if(process_out->state->s == LTTV_STATE_UNNAMED)
454 {
cfe526b1 455 prop_line_out.color->red = 0xffff;
456 prop_line_out.color->green = 0xffff;
457 prop_line_out.color->blue = 0xffff;
a56a1ba4 458 }
459 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
460 {
461 prop_line_out.color->red = 0x0fff;
d52cfc84 462 prop_line_out.color->green = 0xffff;
463 prop_line_out.color->blue = 0xfff0;
a56a1ba4 464 }
465 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
466 {
2df6f2bd 467 prop_line_out.color->red = 0xffff;
468 prop_line_out.color->green = 0xffff;
a56a1ba4 469 prop_line_out.color->blue = 0x0000;
470 }
471 else if(process_out->state->s == LTTV_STATE_EXIT)
472 {
473 prop_line_out.color->red = 0xffff;
474 prop_line_out.color->green = 0x0000;
475 prop_line_out.color->blue = 0xffff;
476 }
477 else if(process_out->state->s == LTTV_STATE_WAIT)
478 {
479 prop_line_out.color->red = 0xffff;
480 prop_line_out.color->green = 0x0000;
481 prop_line_out.color->blue = 0x0000;
482 }
483 else if(process_out->state->s == LTTV_STATE_RUN)
484 {
485 prop_line_out.color->red = 0x0000;
486 prop_line_out.color->green = 0xffff;
487 prop_line_out.color->blue = 0x0000;
488 }
489 else
490 {
cfe526b1 491 prop_line_out.color->red = 0xffff;
492 prop_line_out.color->green = 0xffff;
493 prop_line_out.color->blue = 0xffff;
a56a1ba4 494 }
495
496 draw_line((void*)&prop_line_out, (void*)draw_context_out);
497 g_free(prop_line_out.color);
498 gdk_gc_unref(draw_context_out->gc);
499 /* Note : finishing line will have to be added when trace read over. */
500
501 /* Finally, update the drawing context of the pid_in. */
502
14963be0 503 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
68997a22 504 draw_context_in->current->modify_over->x = x;
319e9d81 505 draw_context_in->current->modify_under->x = x;
68997a22 506 draw_context_in->current->modify_over->y = y_in;
319e9d81 507 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
501d5405 508 draw_context_in->drawable = control_flow_data->drawing->pixmap;
509 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
510 widget = control_flow_data->drawing->drawing_area;
a56a1ba4 511 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
512 //draw_context_in->gc = widget->style->black_gc;
d0cd7f09 513 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
514 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
a56a1ba4 515
516 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
501d5405 517 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 518
519 /* Draw the line/bg of the in process */
520 if(draw_context_in->previous->middle->x == -1)
521 {
ca0f8a8e 522 draw_context_in->previous->over->x =
523 control_flow_data->drawing->damage_begin;
524 draw_context_in->previous->middle->x =
525 control_flow_data->drawing->damage_begin;
526 draw_context_in->previous->under->x =
527 control_flow_data->drawing->damage_begin;
528
529 g_debug("in middle x_beg : %u",control_flow_data->drawing->damage_begin);
530
d0cd7f09 531 }
532
533 draw_context_in->current->middle->x = x;
534 draw_context_in->current->over->x = x;
535 draw_context_in->current->under->x = x;
536 draw_context_in->current->middle->y = y_in + height/2;
537 draw_context_in->current->over->y = y_in;
538 draw_context_in->current->under->y = y_in + height;
539 draw_context_in->previous->middle->y = y_in + height/2;
540 draw_context_in->previous->over->y = y_in;
541 draw_context_in->previous->under->y = y_in + height;
a56a1ba4 542
d0cd7f09 543 draw_context_in->drawable = control_flow_data->drawing->pixmap;
544 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
545
546
547 if(process_in->state->s == LTTV_STATE_RUN)
548 {
549 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
550 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
551
552 PropertiesBG prop_bg;
553 prop_bg.color = g_new(GdkColor,1);
554
555 switch(tfc->index) {
556 case 0:
557 prop_bg.color->red = 0x1515;
558 prop_bg.color->green = 0x1515;
559 prop_bg.color->blue = 0x8c8c;
560 break;
561 case 1:
562 prop_bg.color->red = 0x4e4e;
563 prop_bg.color->green = 0xa9a9;
564 prop_bg.color->blue = 0xa4a4;
565 break;
566 case 2:
567 prop_bg.color->red = 0x7a7a;
568 prop_bg.color->green = 0x4a4a;
569 prop_bg.color->blue = 0x8b8b;
570 break;
571 case 3:
572 prop_bg.color->red = 0x8080;
573 prop_bg.color->green = 0x7777;
574 prop_bg.color->blue = 0x4747;
575 break;
576 default:
577 prop_bg.color->red = 0xe7e7;
578 prop_bg.color->green = 0xe7e7;
579 prop_bg.color->blue = 0xe7e7;
580 }
581
582
583 draw_bg((void*)&prop_bg, (void*)draw_context_in);
584 g_free(prop_bg.color);
585 gdk_gc_unref(draw_context_in->gc);
586 }
587
588 draw_context_in->gc = widget->style->black_gc;
589
a56a1ba4 590 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
2df6f2bd 591 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 592 PropertiesText prop_text_in;
593 prop_text_in.foreground = &colorfg_in;
594 prop_text_in.background = &colorbg_in;
cfe526b1 595 prop_text_in.size = 6;
a56a1ba4 596 prop_text_in.position = OVER;
597
2a2fa4f0 598 g_debug("in state : %s", g_quark_to_string(process_in->state->s));
cfe526b1 599 /* foreground of text : status of the process */
600 if(process_in->state->s == LTTV_STATE_UNNAMED)
601 {
602 prop_text_in.foreground->red = 0xffff;
603 prop_text_in.foreground->green = 0xffff;
604 prop_text_in.foreground->blue = 0xffff;
605 }
606 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
607 {
608 prop_text_in.foreground->red = 0x0fff;
d52cfc84 609 prop_text_in.foreground->green = 0xffff;
610 prop_text_in.foreground->blue = 0xfff0;
cfe526b1 611 }
612 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
613 {
2df6f2bd 614 prop_text_in.foreground->red = 0xffff;
615 prop_text_in.foreground->green = 0xffff;
cfe526b1 616 prop_text_in.foreground->blue = 0x0000;
617 }
618 else if(process_in->state->s == LTTV_STATE_EXIT)
619 {
620 prop_text_in.foreground->red = 0xffff;
621 prop_text_in.foreground->green = 0x0000;
622 prop_text_in.foreground->blue = 0xffff;
623 }
624 else if(process_in->state->s == LTTV_STATE_WAIT)
625 {
626 prop_text_in.foreground->red = 0xffff;
627 prop_text_in.foreground->green = 0x0000;
628 prop_text_in.foreground->blue = 0x0000;
629 }
630 else if(process_in->state->s == LTTV_STATE_RUN)
631 {
632 prop_text_in.foreground->red = 0x0000;
633 prop_text_in.foreground->green = 0xffff;
634 prop_text_in.foreground->blue = 0x0000;
635 }
636 else
637 {
638 prop_text_in.foreground->red = 0xffff;
639 prop_text_in.foreground->green = 0xffff;
640 prop_text_in.foreground->blue = 0xffff;
641 }
642
643
644
a56a1ba4 645 /* Print status of the process : U, WF, WC, E, W, R */
646 if(process_in->state->s == LTTV_STATE_UNNAMED)
cfe526b1 647 prop_text_in.text = "U->";
a56a1ba4 648 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
cfe526b1 649 prop_text_in.text = "WF->";
a56a1ba4 650 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
cfe526b1 651 prop_text_in.text = "WC->";
a56a1ba4 652 else if(process_in->state->s == LTTV_STATE_EXIT)
cfe526b1 653 prop_text_in.text = "E->";
a56a1ba4 654 else if(process_in->state->s == LTTV_STATE_WAIT)
cfe526b1 655 prop_text_in.text = "W->";
a56a1ba4 656 else if(process_in->state->s == LTTV_STATE_RUN)
cfe526b1 657 prop_text_in.text = "R->";
a56a1ba4 658 else
68997a22 659 prop_text_in.text = "U";
a56a1ba4 660
661 draw_text((void*)&prop_text_in, (void*)draw_context_in);
d0cd7f09 662 //gdk_gc_unref(draw_context_in->gc);
663
501d5405 664 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
a56a1ba4 665 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
d0cd7f09 666
a56a1ba4 667 PropertiesLine prop_line_in;
668 prop_line_in.color = g_new(GdkColor,1);
cfe526b1 669 prop_line_in.line_width = 2;
a56a1ba4 670 prop_line_in.style = GDK_LINE_SOLID;
671 prop_line_in.position = MIDDLE;
672
673 /* color of line : status of the process */
674 if(process_in->state->s == LTTV_STATE_UNNAMED)
675 {
cfe526b1 676 prop_line_in.color->red = 0xffff;
677 prop_line_in.color->green = 0xffff;
678 prop_line_in.color->blue = 0xffff;
a56a1ba4 679 }
680 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
681 {
682 prop_line_in.color->red = 0x0fff;
d52cfc84 683 prop_line_in.color->green = 0xffff;
684 prop_line_in.color->blue = 0xfff0;
a56a1ba4 685 }
686 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
687 {
2df6f2bd 688 prop_line_in.color->red = 0xffff;
689 prop_line_in.color->green = 0xffff;
a56a1ba4 690 prop_line_in.color->blue = 0x0000;
691 }
692 else if(process_in->state->s == LTTV_STATE_EXIT)
693 {
694 prop_line_in.color->red = 0xffff;
695 prop_line_in.color->green = 0x0000;
696 prop_line_in.color->blue = 0xffff;
697 }
698 else if(process_in->state->s == LTTV_STATE_WAIT)
699 {
700 prop_line_in.color->red = 0xffff;
701 prop_line_in.color->green = 0x0000;
702 prop_line_in.color->blue = 0x0000;
703 }
704 else if(process_in->state->s == LTTV_STATE_RUN)
705 {
706 prop_line_in.color->red = 0x0000;
707 prop_line_in.color->green = 0xffff;
708 prop_line_in.color->blue = 0x0000;
709 }
710 else
711 {
cfe526b1 712 prop_line_in.color->red = 0xffff;
713 prop_line_in.color->green = 0xffff;
714 prop_line_in.color->blue = 0xffff;
a56a1ba4 715 }
716
717 draw_line((void*)&prop_line_in, (void*)draw_context_in);
718 g_free(prop_line_in.color);
719 gdk_gc_unref(draw_context_in->gc);
720 }
721
722 return 0;
723
724 /* Temp dump */
80a52ff8 725#ifdef DONTSHOW
a56a1ba4 726 GString *string = g_string_new("");;
727 gboolean field_names = TRUE, state = TRUE;
80a52ff8 728
e9a9c513 729 lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs);
730 g_string_append_printf(string,"\n");
731
732 if(state) {
733 g_string_append_printf(string, " %s",
734 g_quark_to_string(tfs->process->state->s));
735 }
736
737 g_info("%s",string->str);
738
a56a1ba4 739 g_string_free(string, TRUE);
740
741 /* End of text dump */
80a52ff8 742#endif //DONTSHOW
50439712 743
f0d936c0 744}
745
746
4c69e0cc 747int draw_after_hook(void *hook_data, void *call_data)
f0d936c0 748{
ca0f8a8e 749 EventsRequest *events_request = (EventsRequest*)hook_data;
750 ControlFlowData *control_flow_data = events_request->viewer_data;
50439712 751
a56a1ba4 752 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
50439712 753
754 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1aff52a2 755 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
50439712 756
a56a1ba4 757
50439712 758 LttEvent *e;
759 e = tfc->e;
760
9444deae 761 LttTime evtime = ltt_event_time(e);
ca0f8a8e 762 TimeWindow time_window =
763 lttvwindow_get_time_window(control_flow_data->tab);
9444deae 764
ca0f8a8e 765 LttTime end_time = ltt_time_add(time_window.start_time,
766 time_window.time_width);
9444deae 767 //if(time < time_beg || time > time_end) return;
ca0f8a8e 768 if(ltt_time_compare(evtime, time_window.start_time) == -1
9444deae 769 || ltt_time_compare(evtime, end_time) == 1)
770 return;
771
772
a56a1ba4 773 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
774 {
2a2fa4f0 775 g_debug("schedchange!");
a56a1ba4 776
777 /* Add process to process list (if not present) and get drawing "y" from
778 * process position */
779 guint pid_out, pid_in;
780 LttvProcessState *process_out, *process_in;
781 LttTime birth;
782 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
783
784 ProcessList *process_list =
ca0f8a8e 785 guicontrolflow_get_process_list(control_flow_data);
a56a1ba4 786
787
788 LttField *f = ltt_event_field(e);
789 LttField *element;
790 element = ltt_field_member(f,0);
791 pid_out = ltt_event_get_long_unsigned(e,element);
792 element = ltt_field_member(f,1);
793 pid_in = ltt_event_get_long_unsigned(e,element);
2a2fa4f0 794 //g_debug("out : %u in : %u", pid_out, pid_in);
a56a1ba4 795
796
797 /* Find process pid_out in the list... */
2a2fa4f0 798 process_out = lttv_state_find_process(tfs, pid_out);
1aff52a2 799 if(process_out == NULL) return 0;
2a2fa4f0 800 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
a56a1ba4 801
802 birth = process_out->creation_time;
803 gchar *name = strdup(g_quark_to_string(process_out->name));
14963be0 804 HashedProcessData *hashed_process_data_out = NULL;
a56a1ba4 805
806 if(processlist_get_process_pixels(process_list,
807 pid_out,
808 &birth,
d0cd7f09 809 tfc->t_context->index,
a56a1ba4 810 &y_out,
811 &height,
14963be0 812 &hashed_process_data_out) == 1)
a56a1ba4 813 {
814 /* Process not present */
815 processlist_add(process_list,
816 pid_out,
817 &birth,
d0cd7f09 818 tfc->t_context->index,
a56a1ba4 819 name,
820 &pl_height,
14963be0 821 &hashed_process_data_out);
a56a1ba4 822 processlist_get_process_pixels(process_list,
823 pid_out,
824 &birth,
d0cd7f09 825 tfc->t_context->index,
a56a1ba4 826 &y_out,
827 &height,
14963be0 828 &hashed_process_data_out);
ca0f8a8e 829 drawing_insert_square( control_flow_data->drawing, y_out, height);
a56a1ba4 830 }
831
832 g_free(name);
833
834 /* Find process pid_in in the list... */
2a2fa4f0 835 process_in = lttv_state_find_process(tfs, pid_in);
1aff52a2 836 if(process_in == NULL) return 0;
2a2fa4f0 837 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
a56a1ba4 838
839 birth = process_in->creation_time;
840 name = strdup(g_quark_to_string(process_in->name));
14963be0 841 HashedProcessData *hashed_process_data_in = NULL;
a56a1ba4 842
843 if(processlist_get_process_pixels(process_list,
844 pid_in,
845 &birth,
d0cd7f09 846 tfc->t_context->index,
a56a1ba4 847 &y_in,
848 &height,
14963be0 849 &hashed_process_data_in) == 1)
a56a1ba4 850 {
851 /* Process not present */
852 processlist_add(process_list,
853 pid_in,
854 &birth,
d0cd7f09 855 tfc->t_context->index,
a56a1ba4 856 name,
857 &pl_height,
14963be0 858 &hashed_process_data_in);
a56a1ba4 859 processlist_get_process_pixels(process_list,
860 pid_in,
861 &birth,
d0cd7f09 862 tfc->t_context->index,
a56a1ba4 863 &y_in,
864 &height,
14963be0 865 &hashed_process_data_in);
a56a1ba4 866
ca0f8a8e 867 drawing_insert_square( control_flow_data->drawing, y_in, height);
a56a1ba4 868 }
869 g_free(name);
870
871
872 /* Find pixels corresponding to time of the event. If the time does
873 * not fit in the window, show a warning, not supposed to happend. */
874 //guint x = 0;
501d5405 875 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
a56a1ba4 876
877 //LttTime time = ltt_event_time(e);
878
224446ce 879 //LttTime window_end = ltt_time_add(time_window->time_width,
880 // time_window->start_time);
a56a1ba4 881
882
883 //convert_time_to_pixels(
224446ce 884 // time_window->start_time,
a56a1ba4 885 // window_end,
886 // time,
887 // width,
888 // &x);
889
890 //assert(x <= width);
891
892 /* draw what represents the event for outgoing process. */
893
14963be0 894 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
68997a22 895 //draw_context_out->current->modify_over->x = x;
896 draw_context_out->current->modify_over->y = y_out;
319e9d81 897 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
501d5405 898 draw_context_out->drawable = control_flow_data->drawing->pixmap;
899 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
900 GtkWidget *widget = control_flow_data->drawing->drawing_area;
a56a1ba4 901 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
d0cd7f09 902
a56a1ba4 903 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
501d5405 904 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 905
906 /*if(process_out->state->s == LTTV_STATE_RUN)
907 {
908 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
909 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
910 PropertiesBG prop_bg;
911 prop_bg.color = g_new(GdkColor,1);
912
913 prop_bg.color->red = 0xffff;
914 prop_bg.color->green = 0xffff;
915 prop_bg.color->blue = 0xffff;
916
917 draw_bg((void*)&prop_bg, (void*)draw_context_out);
918 g_free(prop_bg.color);
919 gdk_gc_unref(draw_context_out->gc);
920 }*/
921
922 draw_context_out->gc = widget->style->black_gc;
923
a56a1ba4 924 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
2df6f2bd 925 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 926 PropertiesText prop_text_out;
927 prop_text_out.foreground = &colorfg_out;
928 prop_text_out.background = &colorbg_out;
cfe526b1 929 prop_text_out.size = 6;
a56a1ba4 930 prop_text_out.position = OVER;
931
cfe526b1 932 /* color of text : status of the process */
933 if(process_out->state->s == LTTV_STATE_UNNAMED)
934 {
935 prop_text_out.foreground->red = 0xffff;
936 prop_text_out.foreground->green = 0xffff;
937 prop_text_out.foreground->blue = 0xffff;
938 }
939 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
940 {
941 prop_text_out.foreground->red = 0x0fff;
d52cfc84 942 prop_text_out.foreground->green = 0xffff;
943 prop_text_out.foreground->blue = 0xfff0;
cfe526b1 944 }
945 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
946 {
2df6f2bd 947 prop_text_out.foreground->red = 0xffff;
948 prop_text_out.foreground->green = 0xffff;
cfe526b1 949 prop_text_out.foreground->blue = 0x0000;
950 }
951 else if(process_out->state->s == LTTV_STATE_EXIT)
952 {
953 prop_text_out.foreground->red = 0xffff;
954 prop_text_out.foreground->green = 0x0000;
955 prop_text_out.foreground->blue = 0xffff;
956 }
957 else if(process_out->state->s == LTTV_STATE_WAIT)
958 {
959 prop_text_out.foreground->red = 0xffff;
960 prop_text_out.foreground->green = 0x0000;
961 prop_text_out.foreground->blue = 0x0000;
962 }
963 else if(process_out->state->s == LTTV_STATE_RUN)
964 {
965 prop_text_out.foreground->red = 0x0000;
966 prop_text_out.foreground->green = 0xffff;
967 prop_text_out.foreground->blue = 0x0000;
968 }
969 else
970 {
971 prop_text_out.foreground->red = 0xffff;
972 prop_text_out.foreground->green = 0xffff;
973 prop_text_out.foreground->blue = 0xffff;
974 }
975
a56a1ba4 976 /* Print status of the process : U, WF, WC, E, W, R */
977 if(process_out->state->s == LTTV_STATE_UNNAMED)
68997a22 978 prop_text_out.text = "U";
a56a1ba4 979 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
68997a22 980 prop_text_out.text = "WF";
a56a1ba4 981 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
68997a22 982 prop_text_out.text = "WC";
a56a1ba4 983 else if(process_out->state->s == LTTV_STATE_EXIT)
68997a22 984 prop_text_out.text = "E";
a56a1ba4 985 else if(process_out->state->s == LTTV_STATE_WAIT)
68997a22 986 prop_text_out.text = "W";
a56a1ba4 987 else if(process_out->state->s == LTTV_STATE_RUN)
68997a22 988 prop_text_out.text = "R";
a56a1ba4 989 else
68997a22 990 prop_text_out.text = "U";
a56a1ba4 991
992 draw_text((void*)&prop_text_out, (void*)draw_context_out);
d0cd7f09 993
994 //gdk_gc_unref(draw_context_out->gc);
319e9d81 995
68997a22 996 draw_context_out->current->middle->y = y_out+height/2;
d0cd7f09 997 draw_context_out->current->over->y = y_out;
998 draw_context_out->current->under->y = y_out+height;
68997a22 999 draw_context_out->current->status = process_out->state->s;
a56a1ba4 1000
68997a22 1001 /* for pid_out : remove previous, Prev = current, new current (default) */
1002 g_free(draw_context_out->previous->modify_under);
1003 g_free(draw_context_out->previous->modify_middle);
1004 g_free(draw_context_out->previous->modify_over);
1005 g_free(draw_context_out->previous->under);
1006 g_free(draw_context_out->previous->middle);
1007 g_free(draw_context_out->previous->over);
1008 g_free(draw_context_out->previous);
1009
1010 draw_context_out->previous = draw_context_out->current;
a56a1ba4 1011
68997a22 1012 draw_context_out->current = g_new(DrawInfo,1);
1013 draw_context_out->current->over = g_new(ItemInfo,1);
1014 draw_context_out->current->over->x = -1;
1015 draw_context_out->current->over->y = -1;
1016 draw_context_out->current->middle = g_new(ItemInfo,1);
1017 draw_context_out->current->middle->x = -1;
1018 draw_context_out->current->middle->y = -1;
1019 draw_context_out->current->under = g_new(ItemInfo,1);
1020 draw_context_out->current->under->x = -1;
1021 draw_context_out->current->under->y = -1;
1022 draw_context_out->current->modify_over = g_new(ItemInfo,1);
1023 draw_context_out->current->modify_over->x = -1;
1024 draw_context_out->current->modify_over->y = -1;
1025 draw_context_out->current->modify_middle = g_new(ItemInfo,1);
1026 draw_context_out->current->modify_middle->x = -1;
1027 draw_context_out->current->modify_middle->y = -1;
1028 draw_context_out->current->modify_under = g_new(ItemInfo,1);
1029 draw_context_out->current->modify_under->x = -1;
1030 draw_context_out->current->modify_under->y = -1;
1031 draw_context_out->current->status = LTTV_STATE_UNNAMED;
a56a1ba4 1032
1033 /* Finally, update the drawing context of the pid_in. */
1034
14963be0 1035 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
68997a22 1036 //draw_context_in->current->modify_over->x = x;
1037 draw_context_in->current->modify_over->y = y_in;
319e9d81 1038 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
501d5405 1039 draw_context_in->drawable = control_flow_data->drawing->pixmap;
1040 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
1041 widget = control_flow_data->drawing->drawing_area;
a56a1ba4 1042 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
a56a1ba4 1043
1044 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
501d5405 1045 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 1046
1047 /*if(process_in->state->s == LTTV_STATE_RUN)
1048 {
1049 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1050 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1051 PropertiesBG prop_bg;
1052 prop_bg.color = g_new(GdkColor,1);
1053
1054 prop_bg.color->red = 0xffff;
1055 prop_bg.color->green = 0xffff;
1056 prop_bg.color->blue = 0xffff;
1057
1058 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1059 g_free(prop_bg.color);
1060 gdk_gc_unref(draw_context_in->gc);
1061 }*/
1062
1063 draw_context_in->gc = widget->style->black_gc;
1064
a56a1ba4 1065 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
2df6f2bd 1066 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 1067 PropertiesText prop_text_in;
1068 prop_text_in.foreground = &colorfg_in;
1069 prop_text_in.background = &colorbg_in;
cfe526b1 1070 prop_text_in.size = 6;
a56a1ba4 1071 prop_text_in.position = OVER;
1072
cfe526b1 1073 /* foreground of text : status of the process */
1074 if(process_in->state->s == LTTV_STATE_UNNAMED)
1075 {
1076 prop_text_in.foreground->red = 0xffff;
1077 prop_text_in.foreground->green = 0xffff;
1078 prop_text_in.foreground->blue = 0xffff;
1079 }
1080 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1081 {
1082 prop_text_in.foreground->red = 0x0fff;
d52cfc84 1083 prop_text_in.foreground->green = 0xffff;
1084 prop_text_in.foreground->blue = 0xfff0;
cfe526b1 1085 }
1086 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1087 {
2df6f2bd 1088 prop_text_in.foreground->red = 0xffff;
1089 prop_text_in.foreground->green = 0xffff;
cfe526b1 1090 prop_text_in.foreground->blue = 0x0000;
1091 }
1092 else if(process_in->state->s == LTTV_STATE_EXIT)
1093 {
1094 prop_text_in.foreground->red = 0xffff;
1095 prop_text_in.foreground->green = 0x0000;
1096 prop_text_in.foreground->blue = 0xffff;
1097 }
1098 else if(process_in->state->s == LTTV_STATE_WAIT)
1099 {
1100 prop_text_in.foreground->red = 0xffff;
1101 prop_text_in.foreground->green = 0x0000;
1102 prop_text_in.foreground->blue = 0x0000;
1103 }
1104 else if(process_in->state->s == LTTV_STATE_RUN)
1105 {
1106 prop_text_in.foreground->red = 0x0000;
1107 prop_text_in.foreground->green = 0xffff;
1108 prop_text_in.foreground->blue = 0x0000;
1109 }
1110 else
1111 {
1112 prop_text_in.foreground->red = 0xffff;
1113 prop_text_in.foreground->green = 0xffff;
1114 prop_text_in.foreground->blue = 0xffff;
1115 }
1116
1117
a56a1ba4 1118 /* Print status of the process : U, WF, WC, E, W, R */
1119 if(process_in->state->s == LTTV_STATE_UNNAMED)
68997a22 1120 prop_text_in.text = "U";
a56a1ba4 1121 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
68997a22 1122 prop_text_in.text = "WF";
a56a1ba4 1123 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
68997a22 1124 prop_text_in.text = "WC";
a56a1ba4 1125 else if(process_in->state->s == LTTV_STATE_EXIT)
68997a22 1126 prop_text_in.text = "E";
a56a1ba4 1127 else if(process_in->state->s == LTTV_STATE_WAIT)
68997a22 1128 prop_text_in.text = "W";
a56a1ba4 1129 else if(process_in->state->s == LTTV_STATE_RUN)
68997a22 1130 prop_text_in.text = "R";
a56a1ba4 1131 else
68997a22 1132 prop_text_in.text = "U";
a56a1ba4 1133
1134 draw_text((void*)&prop_text_in, (void*)draw_context_in);
1135
d0cd7f09 1136
319e9d81 1137 if(process_in->state->s == LTTV_STATE_RUN)
1138 {
1139 gchar tmp[255];
1140 prop_text_in.foreground = &colorfg_in;
1141 prop_text_in.background = &colorbg_in;
1142 prop_text_in.foreground->red = 0xffff;
1143 prop_text_in.foreground->green = 0xffff;
1144 prop_text_in.foreground->blue = 0xffff;
1145 prop_text_in.size = 6;
1146 prop_text_in.position = UNDER;
1147
1148 prop_text_in.text = g_new(gchar, 260);
1149 strcpy(prop_text_in.text, "CPU ");
1150 snprintf(tmp, 255, "%u", tfc->index);
1151 strcat(prop_text_in.text, tmp);
1152
1153 draw_text((void*)&prop_text_in, (void*)draw_context_in);
1154 g_free(prop_text_in.text);
1155 }
1156
1157
68997a22 1158 draw_context_in->current->middle->y = y_in+height/2;
d0cd7f09 1159 draw_context_in->current->over->y = y_in;
1160 draw_context_in->current->under->y = y_in+height;
68997a22 1161 draw_context_in->current->status = process_in->state->s;
1162
1163 /* for pid_in : remove previous, Prev = current, new current (default) */
1164 g_free(draw_context_in->previous->modify_under);
1165 g_free(draw_context_in->previous->modify_middle);
1166 g_free(draw_context_in->previous->modify_over);
1167 g_free(draw_context_in->previous->under);
1168 g_free(draw_context_in->previous->middle);
1169 g_free(draw_context_in->previous->over);
1170 g_free(draw_context_in->previous);
1171
1172 draw_context_in->previous = draw_context_in->current;
a56a1ba4 1173
68997a22 1174 draw_context_in->current = g_new(DrawInfo,1);
1175 draw_context_in->current->over = g_new(ItemInfo,1);
1176 draw_context_in->current->over->x = -1;
1177 draw_context_in->current->over->y = -1;
1178 draw_context_in->current->middle = g_new(ItemInfo,1);
1179 draw_context_in->current->middle->x = -1;
1180 draw_context_in->current->middle->y = -1;
1181 draw_context_in->current->under = g_new(ItemInfo,1);
1182 draw_context_in->current->under->x = -1;
1183 draw_context_in->current->under->y = -1;
1184 draw_context_in->current->modify_over = g_new(ItemInfo,1);
1185 draw_context_in->current->modify_over->x = -1;
1186 draw_context_in->current->modify_over->y = -1;
1187 draw_context_in->current->modify_middle = g_new(ItemInfo,1);
1188 draw_context_in->current->modify_middle->x = -1;
1189 draw_context_in->current->modify_middle->y = -1;
1190 draw_context_in->current->modify_under = g_new(ItemInfo,1);
1191 draw_context_in->current->modify_under->x = -1;
1192 draw_context_in->current->modify_under->y = -1;
1193 draw_context_in->current->status = LTTV_STATE_UNNAMED;
a56a1ba4 1194
1195 }
1196
1197 return 0;
f0d936c0 1198}
f7afe191 1199
1200
1201
1202
1b238973 1203gint update_time_window_hook(void *hook_data, void *call_data)
f7afe191 1204{
a56a1ba4 1205 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
a43d67ba 1206 Drawing_t *drawing = control_flow_data->drawing;
1207
224446ce 1208 const TimeWindowNotifyData *time_window_nofify_data =
1209 ((const TimeWindowNotifyData *)call_data);
1210
14963be0 1211 TimeWindow *old_time_window =
224446ce 1212 time_window_nofify_data->old_time_window;
1213 TimeWindow *new_time_window =
1214 time_window_nofify_data->new_time_window;
a56a1ba4 1215
3cb8b205 1216 /* Update the ruler */
1217 drawing_update_ruler(control_flow_data->drawing,
1218 new_time_window);
1219
1220
a56a1ba4 1221 /* Two cases : zoom in/out or scrolling */
1222
1223 /* In order to make sure we can reuse the old drawing, the scale must
1224 * be the same and the new time interval being partly located in the
1225 * currently shown time interval. (reuse is only for scrolling)
1226 */
1227
1228 g_info("Old time window HOOK : %u, %u to %u, %u",
14963be0 1229 old_time_window->start_time.tv_sec,
1230 old_time_window->start_time.tv_nsec,
1231 old_time_window->time_width.tv_sec,
1232 old_time_window->time_width.tv_nsec);
a56a1ba4 1233
1234 g_info("New time window HOOK : %u, %u to %u, %u",
14963be0 1235 new_time_window->start_time.tv_sec,
1236 new_time_window->start_time.tv_nsec,
1237 new_time_window->time_width.tv_sec,
1238 new_time_window->time_width.tv_nsec);
a56a1ba4 1239
14963be0 1240 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
1241 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
a56a1ba4 1242 {
1243 /* Same scale (scrolling) */
1244 g_info("scrolling");
14963be0 1245 LttTime *ns = &new_time_window->start_time;
1246 LttTime *os = &old_time_window->start_time;
1247 LttTime old_end = ltt_time_add(old_time_window->start_time,
1248 old_time_window->time_width);
1249 LttTime new_end = ltt_time_add(new_time_window->start_time,
1250 new_time_window->time_width);
a56a1ba4 1251 //if(ns<os+w<ns+w)
1252 //if(ns<os+w && os+w<ns+w)
1253 //if(ns<old_end && os<ns)
1254 if(ltt_time_compare(*ns, old_end) == -1
1255 && ltt_time_compare(*os, *ns) == -1)
1256 {
1257 g_info("scrolling near right");
1258 /* Scroll right, keep right part of the screen */
1259 guint x = 0;
501d5405 1260 guint width = control_flow_data->drawing->drawing_area->allocation.width;
a56a1ba4 1261 convert_time_to_pixels(
1262 *os,
1263 old_end,
1264 *ns,
1265 width,
1266 &x);
1267
1268 /* Copy old data to new location */
501d5405 1269 gdk_draw_drawable (control_flow_data->drawing->pixmap,
cfe526b1 1270 control_flow_data->drawing->drawing_area->style->black_gc,
501d5405 1271 control_flow_data->drawing->pixmap,
a56a1ba4 1272 x, 0,
1273 0, 0,
1274 -1, -1);
1275
a56a1ba4 1276 /* Clear the data request background, but not SAFETY */
501d5405 1277 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
cfe526b1 1278 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1279 TRUE,
1280 x+SAFETY, 0,
501d5405 1281 control_flow_data->drawing->width - x, // do not overlap
1282 control_flow_data->drawing->height+SAFETY);
a43d67ba 1283
1284 gtk_widget_queue_draw_area (drawing->drawing_area,
1285 0,0,
1286 control_flow_data->drawing->width - x,
1287 control_flow_data->drawing->height);
1288
a56a1ba4 1289 /* Get new data for the rest. */
501d5405 1290 drawing_data_request(control_flow_data->drawing,
1291 &control_flow_data->drawing->pixmap,
a56a1ba4 1292 x, 0,
501d5405 1293 control_flow_data->drawing->width - x,
1294 control_flow_data->drawing->height);
a56a1ba4 1295
a56a1ba4 1296 } else {
1297 //if(ns<os<ns+w)
1298 //if(ns<os && os<ns+w)
1299 //if(ns<os && os<new_end)
1300 if(ltt_time_compare(*ns,*os) == -1
1301 && ltt_time_compare(*os,new_end) == -1)
1302 {
1303 g_info("scrolling near left");
1304 /* Scroll left, keep left part of the screen */
1305 guint x = 0;
501d5405 1306 guint width = control_flow_data->drawing->drawing_area->allocation.width;
a56a1ba4 1307 convert_time_to_pixels(
1308 *ns,
1309 new_end,
1310 *os,
1311 width,
1312 &x);
1313
1314 /* Copy old data to new location */
501d5405 1315 gdk_draw_drawable (control_flow_data->drawing->pixmap,
cfe526b1 1316 control_flow_data->drawing->drawing_area->style->black_gc,
501d5405 1317 control_flow_data->drawing->pixmap,
a56a1ba4 1318 0, 0,
1319 x, 0,
1320 -1, -1);
1321
a43d67ba 1322 *old_time_window = *new_time_window;
a56a1ba4 1323
1324 /* Clean the data request background */
501d5405 1325 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
cfe526b1 1326 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1327 TRUE,
1328 0, 0,
1329 x, // do not overlap
501d5405 1330 control_flow_data->drawing->height+SAFETY);
a43d67ba 1331
1332 gtk_widget_queue_draw_area (drawing->drawing_area,
1333 x,0,
1334 control_flow_data->drawing->width - x,
1335 control_flow_data->drawing->height);
1336
a56a1ba4 1337 /* Get new data for the rest. */
501d5405 1338 drawing_data_request(control_flow_data->drawing,
1339 &control_flow_data->drawing->pixmap,
a56a1ba4 1340 0, 0,
1341 x,
501d5405 1342 control_flow_data->drawing->height);
a56a1ba4 1343
a56a1ba4 1344 } else {
a43d67ba 1345 if(ltt_time_compare(*ns,*os) == 0)
1346 {
1347 g_info("not scrolling");
1348 } else {
1349 g_info("scrolling far");
1350 /* Cannot reuse any part of the screen : far jump */
1351
1352
1353 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
1354 control_flow_data->drawing->drawing_area->style->black_gc,
1355 TRUE,
a56a1ba4 1356 0, 0,
a43d67ba 1357 control_flow_data->drawing->width+SAFETY, // do not overlap
1358 control_flow_data->drawing->height+SAFETY);
1359
1360 gtk_widget_queue_draw_area (drawing->drawing_area,
1361 0,0,
1362 control_flow_data->drawing->width,
1363 control_flow_data->drawing->height);
1364
1365 drawing_data_request(control_flow_data->drawing,
1366 &control_flow_data->drawing->pixmap,
1367 0, 0,
1368 control_flow_data->drawing->width,
1369 control_flow_data->drawing->height);
1370
1371 }
a56a1ba4 1372 }
1373 }
1374 } else {
1375 /* Different scale (zoom) */
1376 g_info("zoom");
1377
501d5405 1378 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
cfe526b1 1379 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1380 TRUE,
1381 0, 0,
501d5405 1382 control_flow_data->drawing->width+SAFETY, // do not overlap
1383 control_flow_data->drawing->height+SAFETY);
a56a1ba4 1384
a43d67ba 1385 gtk_widget_queue_draw_area (drawing->drawing_area,
1386 0,0,
1387 control_flow_data->drawing->width,
1388 control_flow_data->drawing->height);
a56a1ba4 1389
501d5405 1390 drawing_data_request(control_flow_data->drawing,
1391 &control_flow_data->drawing->pixmap,
a56a1ba4 1392 0, 0,
501d5405 1393 control_flow_data->drawing->width,
1394 control_flow_data->drawing->height);
a56a1ba4 1395
a56a1ba4 1396 }
1397
3cb8b205 1398
1399
a56a1ba4 1400 return 0;
f7afe191 1401}
1402
ca0f8a8e 1403gint redraw_notify(void *hook_data, void *call_data)
1404{
1405 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
1406 Drawing_t *drawing = control_flow_data->drawing;
1407 GtkWidget *widget = drawing->drawing_area;
1408
1409 drawing->damage_begin = 0;
1410 drawing->damage_end = widget->allocation.width;
1411
1412
1413 // Clear the image
1414 gdk_draw_rectangle (drawing->pixmap,
1415 widget->style->black_gc,
1416 TRUE,
1417 0, 0,
1418 widget->allocation.width+SAFETY,
1419 widget->allocation.height+SAFETY);
1420
1421
1422 if(drawing->damage_begin < drawing->damage_end)
1423 {
1424 drawing_data_request(drawing,
1425 &drawing->pixmap,
1426 drawing->damage_begin,
1427 0,
1428 drawing->damage_end-drawing->damage_begin,
1429 widget->allocation.height);
1430 }
1431
1432 gtk_widget_queue_draw_area(drawing->drawing_area,
1433 0,0,
1434 drawing->width,
1435 drawing->height);
1436
1437 return FALSE;
1438
1439}
1440
1441
1442gint continue_notify(void *hook_data, void *call_data)
a43d67ba 1443{
1444 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
ca0f8a8e 1445 Drawing_t *drawing = control_flow_data->drawing;
1446 GtkWidget *widget = drawing->drawing_area;
a43d67ba 1447
ca0f8a8e 1448 g_assert(widget->allocation.width == drawing->damage_end);
1449
1450 if(drawing->damage_begin < drawing->damage_end)
1451 {
1452 drawing_data_request(drawing,
1453 &drawing->pixmap,
1454 drawing->damage_begin,
1455 0,
1456 drawing->damage_end-drawing->damage_begin,
1457 widget->allocation.height);
1458 }
1459
1460 return FALSE;
1461}
1462
1463
1464gint after_process_traceset_hook(void *hook_data, void *call_data)
1465{
1466 //ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
1467 EventsRequest *events_request = (EventsRequest *)hook_data;
1468
1469 ControlFlowData *control_flow_data =
1470 (ControlFlowData*)events_request->viewer_data;
1471
1472
1473 drawing_data_request_end(events_request,
1474 (LttvTracesetState*)call_data);
a43d67ba 1475 return 0;
1476}
1477
1478
1479
1b238973 1480gint update_current_time_hook(void *hook_data, void *call_data)
f7afe191 1481{
14963be0 1482 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
a43d67ba 1483 Drawing_t *drawing = control_flow_data->drawing;
a56a1ba4 1484
224446ce 1485 LttTime current_time = *((LttTime*)call_data);
a56a1ba4 1486
ca0f8a8e 1487 TimeWindow time_window =
1488 lttvwindow_get_time_window(control_flow_data->tab);
a56a1ba4 1489
ca0f8a8e 1490 LttTime time_begin = time_window.start_time;
1491 LttTime width = time_window.time_width;
a56a1ba4 1492 LttTime half_width = ltt_time_div(width,2.0);
1493 LttTime time_end = ltt_time_add(time_begin, width);
1494
1495 LttvTracesetContext * tsc =
ca0f8a8e 1496 lttvwindow_get_traceset_context(control_flow_data->tab);
a56a1ba4 1497
ca0f8a8e 1498 LttTime trace_start = tsc->time_span.start_time;
1499 LttTime trace_end = tsc->time_span.end_time;
a56a1ba4 1500
224446ce 1501 g_info("New current time HOOK : %u, %u", current_time.tv_sec,
1502 current_time.tv_nsec);
a56a1ba4 1503
1504
1505
1506 /* If current time is inside time interval, just move the highlight
1507 * bar */
1508
1509 /* Else, we have to change the time interval. We have to tell it
1510 * to the main window. */
1511 /* The time interval change will take care of placing the current
1512 * time at the center of the visible area, or nearest possible if we are
1513 * at one end of the trace. */
1514
1515
224446ce 1516 if(ltt_time_compare(current_time, time_begin) == -1)
a56a1ba4 1517 {
224446ce 1518 TimeWindow new_time_window;
1519
1520 if(ltt_time_compare(current_time,
a56a1ba4 1521 ltt_time_add(trace_start,half_width)) == -1)
1522 time_begin = trace_start;
1523 else
224446ce 1524 time_begin = ltt_time_sub(current_time,half_width);
a56a1ba4 1525
224446ce 1526 new_time_window.start_time = time_begin;
1527 new_time_window.time_width = width;
a56a1ba4 1528
ca0f8a8e 1529 lttvwindow_report_time_window(control_flow_data->tab, &new_time_window);
a56a1ba4 1530 }
224446ce 1531 else if(ltt_time_compare(current_time, time_end) == 1)
a56a1ba4 1532 {
224446ce 1533 TimeWindow new_time_window;
1534
1535 if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) == 1)
a56a1ba4 1536 time_begin = ltt_time_sub(trace_end,width);
1537 else
224446ce 1538 time_begin = ltt_time_sub(current_time,half_width);
a56a1ba4 1539
224446ce 1540 new_time_window.start_time = time_begin;
1541 new_time_window.time_width = width;
a56a1ba4 1542
ca0f8a8e 1543 lttvwindow_report_time_window(control_flow_data->tab, &new_time_window);
a56a1ba4 1544
1545 }
a43d67ba 1546 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
1547 gtk_widget_queue_draw_area(drawing->drawing_area,
1548 0,0,
1549 drawing->width,
1550 drawing->height);
a56a1ba4 1551
1552 return 0;
f7afe191 1553}
1554
8b90e648 1555typedef struct _ClosureData {
ca0f8a8e 1556 EventsRequest *events_request;
d0cd7f09 1557 LttvTracesetState *tss;
8b90e648 1558} ClosureData;
a56a1ba4 1559
8b90e648 1560
1561void draw_closure(gpointer key, gpointer value, gpointer user_data)
1562{
a56a1ba4 1563 ProcessInfo *process_info = (ProcessInfo*)key;
1564 HashedProcessData *hashed_process_data = (HashedProcessData*)value;
1565 ClosureData *closure_data = (ClosureData*)user_data;
1566
1567 ControlFlowData *control_flow_data =
ca0f8a8e 1568 closure_data->events_request->viewer_data;
a56a1ba4 1569
501d5405 1570 GtkWidget *widget = control_flow_data->drawing->drawing_area;
a56a1ba4 1571
1572 /* Get y position of process */
1573 gint y=0, height=0;
1574
ba90bc77 1575 processlist_get_pixels_from_data( control_flow_data->process_list,
a56a1ba4 1576 process_info,
1577 hashed_process_data,
1578 &y,
1579 &height);
1580 /* Get last state of process */
1581 LttvTraceContext *tc =
d0cd7f09 1582 ((LttvTracesetContext*)closure_data->tss)->traces[process_info->trace_num];
ca0f8a8e 1583 LttvTracesetContext *tsc = (LttvTracesetContext *)closure_data->tss;
8b90e648 1584
d0cd7f09 1585 LttvTraceState *ts = (LttvTraceState*)tc;
a56a1ba4 1586 LttvProcessState *process;
1587
2a2fa4f0 1588 /* We do not provide a cpu_name argument assuming that this is not the
1589 idle job (pid 0) and thus its pid is unique across all cpus */
1590 process = lttv_state_find_process_from_trace(ts, 0, process_info->pid);
a56a1ba4 1591
1592 /* Draw the closing line */
1593 DrawContext *draw_context = hashed_process_data->draw_context;
68997a22 1594 if(draw_context->previous->middle->x == -1)
a56a1ba4 1595 {
ca0f8a8e 1596 draw_context->previous->over->x =
1597 control_flow_data->drawing->damage_begin;
1598 draw_context->previous->middle->x =
1599 control_flow_data->drawing->damage_begin;
1600 draw_context->previous->under->x =
1601 control_flow_data->drawing->damage_begin;
1602
1603 g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin);
a56a1ba4 1604 }
1605
ca0f8a8e 1606 /* Find pixels corresponding to current time . If the time does
1607 * not fit in the window, show a warning, not supposed to happend. */
1608 guint x = 0;
1609 guint width = control_flow_data->drawing->drawing_area->allocation.width;
1610
1611 TimeWindow time_window =
1612 lttvwindow_get_time_window(control_flow_data->tab);
1613
1614 LttTime time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
1615
1616 LttTime window_end = ltt_time_add(time_window.time_width,
1617 time_window.start_time);
1618
1619 convert_time_to_pixels(
1620 time_window.start_time,
1621 window_end,
1622 time,
1623 width,
1624 &x);
1625
1626 draw_context->current->middle->x = x;
1627 draw_context->current->over->x = x;
1628 draw_context->current->under->x = x;
68997a22 1629 draw_context->current->middle->y = y + height/2;
d0cd7f09 1630 draw_context->current->over->y = y ;
1631 draw_context->current->under->y = y + height;
68997a22 1632 draw_context->previous->middle->y = y + height/2;
d0cd7f09 1633 draw_context->previous->over->y = y ;
1634 draw_context->previous->under->y = y + height;
501d5405 1635 draw_context->drawable = control_flow_data->drawing->pixmap;
1636 draw_context->pango_layout = control_flow_data->drawing->pango_layout;
a56a1ba4 1637 //draw_context->gc = widget->style->black_gc;
501d5405 1638 draw_context->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
a56a1ba4 1639 gdk_gc_copy(draw_context->gc, widget->style->black_gc);
d0cd7f09 1640
ad2e83ba 1641 if(process != NULL && process->state->s == LTTV_STATE_RUN)
d0cd7f09 1642 {
1643 PropertiesBG prop_bg;
1644 prop_bg.color = g_new(GdkColor,1);
1645
1646 /*switch(tfc->index) {
1647 case 0:
1648 prop_bg.color->red = 0x1515;
1649 prop_bg.color->green = 0x1515;
1650 prop_bg.color->blue = 0x8c8c;
1651 break;
1652 case 1:
1653 prop_bg.color->red = 0x4e4e;
1654 prop_bg.color->green = 0xa9a9;
1655 prop_bg.color->blue = 0xa4a4;
1656 break;
1657 case 2:
1658 prop_bg.color->red = 0x7a7a;
1659 prop_bg.color->green = 0x4a4a;
1660 prop_bg.color->blue = 0x8b8b;
1661 break;
1662 case 3:
1663 prop_bg.color->red = 0x8080;
1664 prop_bg.color->green = 0x7777;
1665 prop_bg.color->blue = 0x4747;
1666 break;
1667 default:
1668 prop_bg.color->red = 0xe7e7;
1669 prop_bg.color->green = 0xe7e7;
1670 prop_bg.color->blue = 0xe7e7;
1671 }
1672 */
1673
2a2fa4f0 1674 g_debug("calling from closure");
d0cd7f09 1675 //FIXME : I need the cpu number in process's state to draw this.
1676 //draw_bg((void*)&prop_bg, (void*)draw_context);
1677 g_free(prop_bg.color);
1678 }
1679
a56a1ba4 1680
1681 PropertiesLine prop_line;
1682 prop_line.color = g_new(GdkColor,1);
cfe526b1 1683 prop_line.line_width = 2;
a56a1ba4 1684 prop_line.style = GDK_LINE_SOLID;
1685 prop_line.position = MIDDLE;
1686
1687 /* color of line : status of the process */
ad2e83ba 1688 if(process != NULL)
a56a1ba4 1689 {
ad2e83ba 1690 if(process->state->s == LTTV_STATE_UNNAMED)
1691 {
1692 prop_line.color->red = 0xffff;
1693 prop_line.color->green = 0xffff;
1694 prop_line.color->blue = 0xffff;
1695 }
1696 else if(process->state->s == LTTV_STATE_WAIT_FORK)
1697 {
1698 prop_line.color->red = 0x0fff;
1699 prop_line.color->green = 0xffff;
1700 prop_line.color->blue = 0xfff0;
1701 }
1702 else if(process->state->s == LTTV_STATE_WAIT_CPU)
1703 {
1704 prop_line.color->red = 0xffff;
1705 prop_line.color->green = 0xffff;
1706 prop_line.color->blue = 0x0000;
1707 }
1708 else if(process->state->s == LTTV_STATE_EXIT)
1709 {
1710 prop_line.color->red = 0xffff;
1711 prop_line.color->green = 0x0000;
1712 prop_line.color->blue = 0xffff;
1713 }
1714 else if(process->state->s == LTTV_STATE_WAIT)
1715 {
1716 prop_line.color->red = 0xffff;
1717 prop_line.color->green = 0x0000;
1718 prop_line.color->blue = 0x0000;
1719 }
1720 else if(process->state->s == LTTV_STATE_RUN)
1721 {
1722 prop_line.color->red = 0x0000;
1723 prop_line.color->green = 0xffff;
1724 prop_line.color->blue = 0x0000;
1725 }
1726 else
1727 {
1728 prop_line.color->red = 0xffff;
1729 prop_line.color->green = 0xffff;
1730 prop_line.color->blue = 0xffff;
1731 }
1732
a56a1ba4 1733 }
1734 else
1735 {
ad2e83ba 1736 prop_line.color->red = 0xffff;
1737 prop_line.color->green = 0xffff;
1738 prop_line.color->blue = 0xffff;
a56a1ba4 1739 }
1740
1741 draw_line((void*)&prop_line, (void*)draw_context);
1742 g_free(prop_line.color);
1743 gdk_gc_unref(draw_context->gc);
1744
1745 /* Reset draw_context of the process for next request */
1746
1747 hashed_process_data->draw_context->drawable = NULL;
1748 hashed_process_data->draw_context->gc = NULL;
1749 hashed_process_data->draw_context->pango_layout = NULL;
68997a22 1750 hashed_process_data->draw_context->current->over->x = -1;
1751 hashed_process_data->draw_context->current->over->y = -1;
1752 hashed_process_data->draw_context->current->middle->x = -1;
1753 hashed_process_data->draw_context->current->middle->y = -1;
1754 hashed_process_data->draw_context->current->under->x = -1;
1755 hashed_process_data->draw_context->current->under->y = -1;
1756 hashed_process_data->draw_context->current->modify_over->x = -1;
1757 hashed_process_data->draw_context->current->modify_over->y = -1;
1758 hashed_process_data->draw_context->current->modify_middle->x = -1;
1759 hashed_process_data->draw_context->current->modify_middle->y = -1;
1760 hashed_process_data->draw_context->current->modify_under->x = -1;
1761 hashed_process_data->draw_context->current->modify_under->y = -1;
1762 hashed_process_data->draw_context->current->status = LTTV_STATE_UNNAMED;
1763 hashed_process_data->draw_context->previous->over->x = -1;
1764 hashed_process_data->draw_context->previous->over->y = -1;
1765 hashed_process_data->draw_context->previous->middle->x = -1;
1766 hashed_process_data->draw_context->previous->middle->y = -1;
1767 hashed_process_data->draw_context->previous->under->x = -1;
1768 hashed_process_data->draw_context->previous->under->y = -1;
1769 hashed_process_data->draw_context->previous->modify_over->x = -1;
1770 hashed_process_data->draw_context->previous->modify_over->y = -1;
1771 hashed_process_data->draw_context->previous->modify_middle->x = -1;
1772 hashed_process_data->draw_context->previous->modify_middle->y = -1;
1773 hashed_process_data->draw_context->previous->modify_under->x = -1;
1774 hashed_process_data->draw_context->previous->modify_under->y = -1;
1775 hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED;
8b90e648 1776
1777}
1778
ca0f8a8e 1779int before_data_request(void *hook_data, void *call_data)
1780{
1781 EventsRequest *events_request = (EventsRequest*)hook_data;
1782 LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
1783
1784 drawing_data_request_begin(events_request, tss);
1785
1786 return 0;
1787}
1788
1789
8b90e648 1790/*
1791 * for each process
a56a1ba4 1792 * draw closing line
1793 * new default prev and current
a43d67ba 1794 * then finally remove reading hooks.
8b90e648 1795 */
1796int after_data_request(void *hook_data, void *call_data)
1797{
ca0f8a8e 1798 EventsRequest *events_request = (EventsRequest*)hook_data;
1799 ControlFlowData *control_flow_data = events_request->viewer_data;
1800 LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
a56a1ba4 1801
1802 ProcessList *process_list =
ca0f8a8e 1803 guicontrolflow_get_process_list(control_flow_data);
a56a1ba4 1804
1805 ClosureData closure_data;
ca0f8a8e 1806 closure_data.events_request = (EventsRequest*)hook_data;
1807 closure_data.tss = tss;
a56a1ba4 1808
14963be0 1809 g_hash_table_foreach(process_list->process_hash, draw_closure,
a56a1ba4 1810 (void*)&closure_data);
a43d67ba 1811
ca0f8a8e 1812 /* Request expose */
1813 drawing_data_request_end(events_request, tss);
1814
1815 return 0;
8b90e648 1816}
1817
This page took 0.117194 seconds and 4 git commands to generate.