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