STATE_EXIT -> STATE_ZOMBIE
[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
b9a010a2 25/* Event hooks are the drawing hooks called during traceset read. They draw the
26 * icons, text, lines and background color corresponding to the events read.
27 *
28 * Two hooks are used for drawing : draw_before and draw_after hooks. The
29 * draw_before is called before the state update that occurs with an event and
30 * the draw_after hook is called after this state update.
31 *
32 * The draw_before hooks fulfill the task of drawing the visible objects that
33 * corresponds to the data accumulated by the draw_after hook.
34 *
35 * The draw_after hook accumulates the data that need to be shown on the screen
36 * (items) into a queue. Then, the next draw_before hook will draw what that
37 * queue contains. That's the Right Way (TM) of drawing items on the screen,
38 * because we need to draw the background first (and then add icons, text, ...
39 * over it), but we only know the length of a background region once the state
40 * corresponding to it is over, which happens to be at the next draw_before
41 * hook.
42 *
43 * We also have a hook called at the end of a chunk to draw the information left
44 * undrawn in each process queue. We use the current time as end of
45 * line/background.
46 */
47
48
cf6cb7e0 49//#define PANGO_ENABLE_BACKEND
558aa013 50#include <gtk/gtk.h>
51#include <gdk/gdk.h>
5f16133f 52#include <glib.h>
80a52ff8 53#include <assert.h>
50439712 54#include <string.h>
319e9d81 55#include <stdio.h>
5f16133f 56
cf6cb7e0 57//#include <pango/pango.h>
58
80a52ff8 59#include <ltt/event.h>
4ba42155 60#include <ltt/time.h>
50439712 61#include <ltt/type.h>
80a52ff8 62
2a2fa4f0 63#include <lttv/lttv.h>
558aa013 64#include <lttv/hook.h>
80a52ff8 65#include <lttv/state.h>
2d262115 66#include <lttvwindow/lttvwindow.h>
6395d57c 67#include <lttvwindow/lttvwindowtraces.h>
80a52ff8 68
f0d936c0 69
a117e3f7 70#include "eventhooks.h"
71#include "cfv.h"
72#include "processlist.h"
73#include "drawing.h"
74#include "cfv-private.h"
5f16133f 75
80a52ff8 76
1a31868c 77#define MAX_PATH_LEN 256
78
f0d936c0 79
b9a010a2 80#if 0
81typedef struct _ProcessAddClosure {
82 ControlFlowData *cfd;
83 guint trace_num;
84} ProcessAddClosure;
85
86static void process_add(gpointer key,
87 gpointer value,
88 gpointer user_data)
89{
90 LttvProcessState *process = (LttvProcessState*)value;
91 ProcessAddClosure *closure = (ProcessAddClosure*)user_data;
92 ControlFlowData *control_flow_data = closure->cfd;
93 guint trace_num = closure->trace_num;
94
95 /* Add process to process list (if not present) */
96 guint pid;
97 LttTime birth;
98 guint y = 0, height = 0, pl_height = 0;
99
100 ProcessList *process_list =
101 guicontrolflow_get_process_list(control_flow_data);
102
103 pid = process->pid;
104 birth = process->creation_time;
105 const gchar *name = g_quark_to_string(process->name);
106 HashedProcessData *hashed_process_data = NULL;
107
108 if(processlist_get_process_pixels(process_list,
109 pid,
110 &birth,
111 trace_num,
112 &y,
113 &height,
114 &hashed_process_data) == 1)
115 {
116 /* Process not present */
117 processlist_add(process_list,
118 pid,
119 &birth,
120 trace_num,
121 name,
122 &pl_height,
123 &hashed_process_data);
124 processlist_get_process_pixels(process_list,
125 pid,
126 &birth,
127 trace_num,
128 &y,
129 &height,
130 &hashed_process_data);
131 drawing_insert_square( control_flow_data->drawing, y, height);
132 }
133}
134#endif //0
135
136
6395d57c 137/* Action to do when background computation completed.
138 *
e800cf84 139 * Wait for all the awaited computations to be over.
6395d57c 140 */
141
142gint background_ready(void *hook_data, void *call_data)
143{
144 ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
145 LttvTrace *trace = (LttvTrace*)call_data;
b9a010a2 146 LttvTracesetContext *tsc =
147 lttvwindow_get_traceset_context(control_flow_data->tab);
6395d57c 148
e800cf84 149 control_flow_data->background_info_waiting--;
150
151 if(control_flow_data->background_info_waiting == 0) {
152 g_debug("control flow viewer : background computation data ready.");
6395d57c 153
e800cf84 154 drawing_clear(control_flow_data->drawing);
155 processlist_clear(control_flow_data->process_list);
156 redraw_notify(control_flow_data, NULL);
b9a010a2 157 }
6395d57c 158
159 return 0;
160}
161
162
163/* Request background computation. Verify if it is in progress or ready first.
e800cf84 164 * Only for each trace in the tab's traceset.
6395d57c 165 */
166void request_background_data(ControlFlowData *control_flow_data)
167{
e800cf84 168 LttvTracesetContext * tsc =
169 lttvwindow_get_traceset_context(control_flow_data->tab);
170 gint num_traces = lttv_traceset_number(tsc->ts);
6395d57c 171 gint i;
172 LttvTrace *trace;
173
174 LttvHooks *background_ready_hook =
175 lttv_hooks_new();
176 lttv_hooks_add(background_ready_hook, background_ready, control_flow_data,
177 LTTV_PRIO_DEFAULT);
e800cf84 178 control_flow_data->background_info_waiting = 0;
6395d57c 179
180 for(i=0;i<num_traces;i++) {
e800cf84 181 trace = lttv_traceset_get(tsc->ts, i);
6395d57c 182
183 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE) {
184
185 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
186 trace) == FALSE) {
187 /* We first remove requests that could have been done for the same
188 * information. Happens when two viewers ask for it before servicing
189 * starts.
190 */
191 lttvwindowtraces_background_request_remove(trace, "state");
192 lttvwindowtraces_background_request_queue(trace,
193 "state");
194 lttvwindowtraces_background_notify_queue(control_flow_data,
195 trace,
196 ltt_time_infinite,
197 NULL,
198 background_ready_hook);
e800cf84 199 control_flow_data->background_info_waiting++;
6395d57c 200 } else { /* in progress */
201
202 lttvwindowtraces_background_notify_current(control_flow_data,
203 trace,
204 ltt_time_infinite,
205 NULL,
206 background_ready_hook);
e800cf84 207 control_flow_data->background_info_waiting++;
6395d57c 208 }
209 }
210 }
211
212 lttv_hooks_destroy(background_ready_hook);
213}
214
215
216
217
f0d936c0 218/**
219 * Event Viewer's constructor hook
220 *
221 * This constructor is given as a parameter to the menuitem and toolbar button
222 * registration. It creates the list.
ca0f8a8e 223 * @param tab A pointer to the parent tab.
f0d936c0 224 * @return The widget created.
225 */
226GtkWidget *
d47b33d2 227h_guicontrolflow(Tab *tab)
f0d936c0 228{
d47b33d2 229 g_info("h_guicontrolflow, %p", tab);
68997a22 230 ControlFlowData *control_flow_data = guicontrolflow() ;
a56a1ba4 231
ca0f8a8e 232 control_flow_data->tab = tab;
a56a1ba4 233
2a2fa4f0 234 //g_debug("time width2 : %u",time_window->time_width);
a56a1ba4 235 // Unreg done in the GuiControlFlow_Destructor
6395d57c 236 lttvwindow_register_traceset_notify(tab,
237 traceset_notify,
238 control_flow_data);
239
ca0f8a8e 240 lttvwindow_register_time_window_notify(tab,
224446ce 241 update_time_window_hook,
242 control_flow_data);
ca0f8a8e 243 lttvwindow_register_current_time_notify(tab,
224446ce 244 update_current_time_hook,
245 control_flow_data);
ca0f8a8e 246 lttvwindow_register_redraw_notify(tab,
247 redraw_notify,
248 control_flow_data);
249 lttvwindow_register_continue_notify(tab,
250 continue_notify,
251 control_flow_data);
6395d57c 252 request_background_data(control_flow_data);
253
ca0f8a8e 254
68997a22 255 return guicontrolflow_get_widget(control_flow_data) ;
a56a1ba4 256
f0d936c0 257}
258
3cff8cc1 259int event_selected_hook(void *hook_data, void *call_data)
f0d936c0 260{
68997a22 261 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
14963be0 262 guint *event_number = (guint*) call_data;
f0d936c0 263
2a2fa4f0 264 g_debug("DEBUG : event selected by main window : %u", *event_number);
a56a1ba4 265
f0d936c0 266}
267
c8bba5fa 268
269static __inline PropertiesLine prepare_line(LttvProcessState *process)
270{
271 PropertiesLine prop_line;
272 prop_line.line_width = 2;
273 prop_line.style = GDK_LINE_SOLID;
e800cf84 274 prop_line.y = MIDDLE;
275 //GdkColormap *colormap = gdk_colormap_get_system();
c8bba5fa 276
277 g_debug("prepare_line for state : %s", g_quark_to_string(process->state->s));
278
279 /* color of line : status of the process */
280 if(process->state->s == LTTV_STATE_UNNAMED)
e800cf84 281 prop_line.color = drawing_colors[COL_WHITE];
c8bba5fa 282 else if(process->state->s == LTTV_STATE_WAIT_FORK)
e800cf84 283 prop_line.color = drawing_colors[COL_WAIT_FORK];
c8bba5fa 284 else if(process->state->s == LTTV_STATE_WAIT_CPU)
e800cf84 285 prop_line.color = drawing_colors[COL_WAIT_CPU];
0828099d 286 else if(process->state->s == LTTV_STATE_ZOMBIE)
287 prop_line.color = drawing_colors[COL_ZOMBIE];
c8bba5fa 288 else if(process->state->s == LTTV_STATE_WAIT)
e800cf84 289 prop_line.color = drawing_colors[COL_WAIT];
c8bba5fa 290 else if(process->state->s == LTTV_STATE_RUN)
e800cf84 291 prop_line.color = drawing_colors[COL_RUN];
c8bba5fa 292 else
e800cf84 293 prop_line.color = drawing_colors[COL_WHITE];
294
295 //gdk_colormap_alloc_color(colormap,
296 // prop_line.color,
297 // FALSE,
298 // TRUE);
c8bba5fa 299
300 return prop_line;
301
302}
303
304
305
b9a010a2 306/* draw_before_hook
307 *
f0d936c0 308 * This function basically draw lines and icons. Two types of lines are drawn :
309 * one small (3 pixels?) representing the state of the process and the second
310 * type is thicker (10 pixels?) representing on which CPU a process is running
311 * (and this only in running state).
312 *
313 * Extremums of the lines :
314 * x_min : time of the last event context for this process kept in memory.
315 * x_max : time of the current event.
316 * y : middle of the process in the process list. The process is found in the
317 * list, therefore is it's position in pixels.
318 *
319 * The choice of lines'color is defined by the context of the last event for this
320 * process.
321 */
b9a010a2 322
323
324int draw_before_hook(void *hook_data, void *call_data)
f0d936c0 325{
b9a010a2 326 EventsRequest *events_request = (EventsRequest*)hook_data;
327 ControlFlowData *control_flow_data = events_request->viewer_data;
c8bba5fa 328 Drawing_t *drawing = control_flow_data->drawing;
b9a010a2 329
330 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
331
332 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
333 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
334
335 LttEvent *e;
336 e = tfc->e;
337
338 LttTime evtime = ltt_event_time(e);
339 TimeWindow time_window =
340 lttvwindow_get_time_window(control_flow_data->tab);
341
342 LttTime end_time = ltt_time_add(time_window.start_time,
343 time_window.time_width);
344
345 if(ltt_time_compare(evtime, time_window.start_time) == -1
346 || ltt_time_compare(evtime, end_time) == 1)
347 return;
348
c8bba5fa 349 guint width = drawing->width;
b9a010a2 350
351 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) {
352
353 /* we are in a schedchange, before the state update. We must draw the
354 * items corresponding to the state before it changes : now is the right
355 * time to do it.
356 */
357
358 guint pid_out;
e800cf84 359 guint pid_in;
b9a010a2 360 {
b9a010a2 361 LttField *f = ltt_event_field(e);
362 LttField *element;
363 element = ltt_field_member(f,0);
364 pid_out = ltt_event_get_long_unsigned(e,element);
365 element = ltt_field_member(f,1);
366 pid_in = ltt_event_get_long_unsigned(e,element);
367 g_debug("out : %u in : %u", pid_out, pid_in);
368 }
b9a010a2 369
e800cf84 370 {
371 /* For the pid_out */
372 /* First, check if the current process is in the state computation
373 * process list. If it is there, that means we must add it right now and
374 * draw items from the beginning of the read for it. If it is not
375 * present, it's a new process and it was not present : it will
376 * be added after the state update. */
377 LttvProcessState *process;
378 process = lttv_state_find_process(tfs, pid_out);
b9a010a2 379
e800cf84 380 if(process != NULL) {
381 /* Well, the process_out existed : we must get it in the process hash
382 * or add it, and draw its items.
383 */
384 /* Add process to process list (if not present) */
385 guint y = 0, height = 0, pl_height = 0;
386 HashedProcessData *hashed_process_data = NULL;
387 ProcessList *process_list =
388 guicontrolflow_get_process_list(control_flow_data);
389 LttTime birth = process->creation_time;
390 const gchar *name = g_quark_to_string(process->name);
391
392 if(processlist_get_process_pixels(process_list,
393 pid_out,
394 &birth,
395 tfc->t_context->index,
396 &y,
397 &height,
398 &hashed_process_data) == 1)
399 {
e025a729 400 g_assert(!(process->pid == 432 &&
401 ltt_time_compare(process->creation_time,
402 ltt_time_zero)==0));
403
404 g_assert(!(process->pid == 432 &&
405 process->creation_time.tv_nsec == 47797905));
e800cf84 406 /* Process not present */
407 processlist_add(process_list,
b9a010a2 408 pid_out,
409 &birth,
410 tfc->t_context->index,
e800cf84 411 name,
412 &pl_height,
413 &hashed_process_data);
414 processlist_get_process_pixels(process_list,
415 pid_out,
416 &birth,
417 tfc->t_context->index,
418 &y,
419 &height,
420 &hashed_process_data);
421 drawing_insert_square( drawing, y, height);
422 }
423
424 /* Now, the process is in the state hash and our own process hash.
425 * We definitely can draw the items related to the ending state.
426 */
427
428 /* Check if the x position is unset. In can have been left unset by
429 * a draw closure from a after chunk hook. This should never happen,
430 * because it must be set by before chunk hook to the damage_begin
431 * value.
432 */
433 g_assert(hashed_process_data->x != -1);
434 {
435 guint x;
436 DrawContext draw_context;
437
438 convert_time_to_pixels(
439 time_window.start_time,
440 end_time,
441 evtime,
442 width,
443 &x);
444
445 /* Now create the drawing context that will be used to draw
446 * items related to the last state. */
447 draw_context.drawable = drawing->pixmap;
448 draw_context.gc = drawing->gc;
449 draw_context.pango_layout = drawing->pango_layout;
450 draw_context.drawinfo.start.x = hashed_process_data->x;
451 draw_context.drawinfo.end.x = x;
452
453 draw_context.drawinfo.y.over = y;
454 draw_context.drawinfo.y.middle = y+(height/4);
455 draw_context.drawinfo.y.under = y+(height/2)+2;
456
457 draw_context.drawinfo.start.offset.over = 0;
458 draw_context.drawinfo.start.offset.middle = 0;
459 draw_context.drawinfo.start.offset.under = 0;
460 draw_context.drawinfo.end.offset.over = 0;
461 draw_context.drawinfo.end.offset.middle = 0;
462 draw_context.drawinfo.end.offset.under = 0;
463
464 {
465 /* Draw the line */
466 PropertiesLine prop_line = prepare_line(process);
467 draw_line((void*)&prop_line, (void*)&draw_context);
468
469 }
470 /* become the last x position */
471 hashed_process_data->x = x;
472 }
473 }
474 }
475
476 {
477 /* For the pid_in */
478 /* First, check if the current process is in the state computation
479 * process list. If it is there, that means we must add it right now and
480 * draw items from the beginning of the read for it. If it is not
481 * present, it's a new process and it was not present : it will
482 * be added after the state update. */
483 LttvProcessState *process;
484 process = lttv_state_find_process(tfs, pid_in);
485
486 if(process != NULL) {
487 /* Well, the process_out existed : we must get it in the process hash
488 * or add it, and draw its items.
489 */
490 /* Add process to process list (if not present) */
491 guint y = 0, height = 0, pl_height = 0;
492 HashedProcessData *hashed_process_data = NULL;
493 ProcessList *process_list =
494 guicontrolflow_get_process_list(control_flow_data);
495 LttTime birth = process->creation_time;
496 const gchar *name = g_quark_to_string(process->name);
497
498 if(processlist_get_process_pixels(process_list,
499 pid_in,
b9a010a2 500 &birth,
501 tfc->t_context->index,
c8bba5fa 502 &y,
b9a010a2 503 &height,
e800cf84 504 &hashed_process_data) == 1)
505 {
506 /* Process not present */
507 processlist_add(process_list,
508 pid_in,
509 &birth,
510 tfc->t_context->index,
511 name,
512 &pl_height,
513 &hashed_process_data);
514 processlist_get_process_pixels(process_list,
515 pid_in,
516 &birth,
517 tfc->t_context->index,
518 &y,
519 &height,
520 &hashed_process_data);
521 drawing_insert_square( drawing, y, height);
522 }
b9a010a2 523
e800cf84 524 /* Now, the process is in the state hash and our own process hash.
525 * We definitely can draw the items related to the ending state.
526 */
527
528 /* Check if the x position is unset. In can have been left unset by
529 * a draw closure from a after chunk hook. This should never happen,
530 * because it must be set by before chunk hook to the damage_begin
531 * value.
532 */
533 g_assert(hashed_process_data->x != -1);
c8bba5fa 534 {
e800cf84 535 guint x;
536 DrawContext draw_context;
537
538 convert_time_to_pixels(
539 time_window.start_time,
540 end_time,
541 evtime,
542 width,
543 &x);
544
545 /* Now create the drawing context that will be used to draw
546 * items related to the last state. */
547 draw_context.drawable = drawing->pixmap;
548 draw_context.gc = drawing->gc;
549 draw_context.pango_layout = drawing->pango_layout;
550 draw_context.drawinfo.start.x = hashed_process_data->x;
551 draw_context.drawinfo.end.x = x;
552
553 draw_context.drawinfo.y.over = y;
554 draw_context.drawinfo.y.middle = y+(height/4);
555 draw_context.drawinfo.y.under = y+(height/2)+2;
556
557 draw_context.drawinfo.start.offset.over = 0;
558 draw_context.drawinfo.start.offset.middle = 0;
559 draw_context.drawinfo.start.offset.under = 0;
560 draw_context.drawinfo.end.offset.over = 0;
561 draw_context.drawinfo.end.offset.middle = 0;
562 draw_context.drawinfo.end.offset.under = 0;
563
564 {
565 /* Draw the line */
566 PropertiesLine prop_line = prepare_line(process);
567 draw_line((void*)&prop_line, (void*)&draw_context);
568 }
569
570
571 /* become the last x position */
572 hashed_process_data->x = x;
c8bba5fa 573 }
574 }
b9a010a2 575 }
f37a2002 576 } else if(strcmp(
577 ltt_eventtype_name(ltt_event_eventtype(e)),"process") == 0) {
578 /* We are in a fork or exit event */
579
580
b9a010a2 581 }
582
583
584 return 0;
585
586
b9a010a2 587#if 0
ca0f8a8e 588 EventsRequest *events_request = (EventsRequest*)hook_data;
589 ControlFlowData *control_flow_data =
590 (ControlFlowData*)events_request->viewer_data;
591 Tab *tab = control_flow_data->tab;
e9a9c513 592
a56a1ba4 593 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
e9a9c513 594
595 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1aff52a2 596 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
a56a1ba4 597
e9a9c513 598 LttEvent *e;
e9a9c513 599 e = tfc->e;
600
9444deae 601 LttTime evtime = ltt_event_time(e);
ca0f8a8e 602 TimeWindow time_window =
603 lttvwindow_get_time_window(tab);
9444deae 604
ca0f8a8e 605 LttTime end_time = ltt_time_add(time_window.start_time,
606 time_window.time_width);
9444deae 607 //if(time < time_beg || time > time_end) return;
ca0f8a8e 608 if(ltt_time_compare(evtime, time_window.start_time) == -1
9444deae 609 || ltt_time_compare(evtime, end_time) == 1)
610 return;
611
a56a1ba4 612 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
613 {
2a2fa4f0 614 g_debug("schedchange!");
a56a1ba4 615
616 /* Add process to process list (if not present) and get drawing "y" from
617 * process position */
618 guint pid_out, pid_in;
619 LttvProcessState *process_out, *process_in;
620 LttTime birth;
621 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
622
623 ProcessList *process_list =
ca0f8a8e 624 guicontrolflow_get_process_list(control_flow_data);
a56a1ba4 625
626
627 LttField *f = ltt_event_field(e);
628 LttField *element;
629 element = ltt_field_member(f,0);
630 pid_out = ltt_event_get_long_unsigned(e,element);
631 element = ltt_field_member(f,1);
632 pid_in = ltt_event_get_long_unsigned(e,element);
2a2fa4f0 633 g_debug("out : %u in : %u", pid_out, pid_in);
a56a1ba4 634
635
636 /* Find process pid_out in the list... */
87658614 637 process_out = lttv_state_find_process(tfs, pid_out);
1aff52a2 638 if(process_out == NULL) return 0;
2a2fa4f0 639 g_debug("out : %s",g_quark_to_string(process_out->state->s));
1aff52a2 640
a56a1ba4 641 birth = process_out->creation_time;
51705146 642 const gchar *name = g_quark_to_string(process_out->name);
14963be0 643 HashedProcessData *hashed_process_data_out = NULL;
a56a1ba4 644
645 if(processlist_get_process_pixels(process_list,
646 pid_out,
647 &birth,
d0cd7f09 648 tfc->t_context->index,
a56a1ba4 649 &y_out,
650 &height,
14963be0 651 &hashed_process_data_out) == 1)
a56a1ba4 652 {
51705146 653 /* Process not present */
654 processlist_add(process_list,
655 pid_out,
656 &birth,
657 tfc->t_context->index,
658 name,
659 &pl_height,
660 &hashed_process_data_out);
661 g_assert(processlist_get_process_pixels(process_list,
662 pid_out,
663 &birth,
664 tfc->t_context->index,
665 &y_out,
666 &height,
667 &hashed_process_data_out)==0);
668 drawing_insert_square( control_flow_data->drawing, y_out, height);
a56a1ba4 669 }
51705146 670 //g_free(name);
a56a1ba4 671
672 /* Find process pid_in in the list... */
87658614 673 process_in = lttv_state_find_process(tfs, pid_in);
1aff52a2 674 if(process_in == NULL) return 0;
2a2fa4f0 675 g_debug("in : %s",g_quark_to_string(process_in->state->s));
a56a1ba4 676
677 birth = process_in->creation_time;
51705146 678 name = g_quark_to_string(process_in->name);
14963be0 679 HashedProcessData *hashed_process_data_in = NULL;
a56a1ba4 680
681 if(processlist_get_process_pixels(process_list,
682 pid_in,
683 &birth,
d0cd7f09 684 tfc->t_context->index,
a56a1ba4 685 &y_in,
686 &height,
14963be0 687 &hashed_process_data_in) == 1)
a56a1ba4 688 {
51705146 689 /* Process not present */
a56a1ba4 690 processlist_add(process_list,
691 pid_in,
692 &birth,
d0cd7f09 693 tfc->t_context->index,
a56a1ba4 694 name,
695 &pl_height,
14963be0 696 &hashed_process_data_in);
a56a1ba4 697 processlist_get_process_pixels(process_list,
698 pid_in,
699 &birth,
d0cd7f09 700 tfc->t_context->index,
a56a1ba4 701 &y_in,
702 &height,
14963be0 703 &hashed_process_data_in);
a56a1ba4 704
ca0f8a8e 705 drawing_insert_square( control_flow_data->drawing, y_in, height);
a56a1ba4 706 }
51705146 707 //g_free(name);
a56a1ba4 708
709
710 /* Find pixels corresponding to time of the event. If the time does
711 * not fit in the window, show a warning, not supposed to happend. */
712 guint x = 0;
51705146 713 guint width = control_flow_data->drawing->width;
a56a1ba4 714
715 LttTime time = ltt_event_time(e);
716
ca0f8a8e 717 LttTime window_end = ltt_time_add(time_window.time_width,
718 time_window.start_time);
a56a1ba4 719
720
721 convert_time_to_pixels(
ca0f8a8e 722 time_window.start_time,
a56a1ba4 723 window_end,
724 time,
725 width,
726 &x);
9444deae 727 //assert(x <= width);
51705146 728 //
a56a1ba4 729 /* draw what represents the event for outgoing process. */
730
14963be0 731 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
68997a22 732 draw_context_out->current->modify_over->x = x;
319e9d81 733 draw_context_out->current->modify_under->x = x;
68997a22 734 draw_context_out->current->modify_over->y = y_out;
319e9d81 735 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
501d5405 736 draw_context_out->drawable = control_flow_data->drawing->pixmap;
737 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
738 GtkWidget *widget = control_flow_data->drawing->drawing_area;
a56a1ba4 739 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
d0cd7f09 740 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
741 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
a56a1ba4 742 //draw_context_out->gc = widget->style->black_gc;
743
744 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
501d5405 745 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
a56a1ba4 746
d0cd7f09 747 /* Draw the line/background of the out process */
748 if(draw_context_out->previous->middle->x == -1)
749 {
ca0f8a8e 750 draw_context_out->previous->over->x =
751 control_flow_data->drawing->damage_begin;
752 draw_context_out->previous->middle->x =
753 control_flow_data->drawing->damage_begin;
754 draw_context_out->previous->under->x =
755 control_flow_data->drawing->damage_begin;
756
757 g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin);
d0cd7f09 758 }
759
760 draw_context_out->current->middle->x = x;
761 draw_context_out->current->over->x = x;
762 draw_context_out->current->under->x = x;
763 draw_context_out->current->middle->y = y_out + height/2;
764 draw_context_out->current->over->y = y_out;
765 draw_context_out->current->under->y = y_out + height;
766 draw_context_out->previous->middle->y = y_out + height/2;
767 draw_context_out->previous->over->y = y_out;
768 draw_context_out->previous->under->y = y_out + height;
769
770 draw_context_out->drawable = control_flow_data->drawing->pixmap;
771 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
772
773 if(process_out->state->s == LTTV_STATE_RUN)
774 {
51705146 775 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
776 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
777 draw_context_out->gc = control_flow_data->drawing->gc;
d0cd7f09 778
779 PropertiesBG prop_bg;
780 prop_bg.color = g_new(GdkColor,1);
781
782 switch(tfc->index) {
783 case 0:
784 prop_bg.color->red = 0x1515;
785 prop_bg.color->green = 0x1515;
786 prop_bg.color->blue = 0x8c8c;
787 break;
788 case 1:
789 prop_bg.color->red = 0x4e4e;
790 prop_bg.color->green = 0xa9a9;
791 prop_bg.color->blue = 0xa4a4;
792 break;
793 case 2:
794 prop_bg.color->red = 0x7a7a;
795 prop_bg.color->green = 0x4a4a;
796 prop_bg.color->blue = 0x8b8b;
797 break;
798 case 3:
799 prop_bg.color->red = 0x8080;
800 prop_bg.color->green = 0x7777;
801 prop_bg.color->blue = 0x4747;
802 break;
803 default:
804 prop_bg.color->red = 0xe7e7;
805 prop_bg.color->green = 0xe7e7;
806 prop_bg.color->blue = 0xe7e7;
807 }
808
2a2fa4f0 809 g_debug("calling from draw_event");
d0cd7f09 810 draw_bg((void*)&prop_bg, (void*)draw_context_out);
811 g_free(prop_bg.color);
51705146 812 //gdk_gc_unref(draw_context_out->gc);
d0cd7f09 813 }
814
815 draw_context_out->gc = widget->style->black_gc;
816
a56a1ba4 817 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
2df6f2bd 818 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 819 PropertiesText prop_text_out;
820 prop_text_out.foreground = &colorfg_out;
821 prop_text_out.background = &colorbg_out;
cfe526b1 822 prop_text_out.size = 6;
a56a1ba4 823 prop_text_out.position = OVER;
824
cfe526b1 825 /* color of text : status of the process */
826 if(process_out->state->s == LTTV_STATE_UNNAMED)
827 {
828 prop_text_out.foreground->red = 0xffff;
829 prop_text_out.foreground->green = 0xffff;
830 prop_text_out.foreground->blue = 0xffff;
831 }
832 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
833 {
834 prop_text_out.foreground->red = 0x0fff;
d52cfc84 835 prop_text_out.foreground->green = 0xffff;
836 prop_text_out.foreground->blue = 0xfff0;
cfe526b1 837 }
838 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
839 {
2df6f2bd 840 prop_text_out.foreground->red = 0xffff;
841 prop_text_out.foreground->green = 0xffff;
cfe526b1 842 prop_text_out.foreground->blue = 0x0000;
843 }
0828099d 844 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 845 {
846 prop_text_out.foreground->red = 0xffff;
847 prop_text_out.foreground->green = 0x0000;
848 prop_text_out.foreground->blue = 0xffff;
849 }
850 else if(process_out->state->s == LTTV_STATE_WAIT)
851 {
852 prop_text_out.foreground->red = 0xffff;
853 prop_text_out.foreground->green = 0x0000;
854 prop_text_out.foreground->blue = 0x0000;
855 }
856 else if(process_out->state->s == LTTV_STATE_RUN)
857 {
858 prop_text_out.foreground->red = 0x0000;
859 prop_text_out.foreground->green = 0xffff;
860 prop_text_out.foreground->blue = 0x0000;
861 }
862 else
863 {
864 prop_text_out.foreground->red = 0xffff;
865 prop_text_out.foreground->green = 0xffff;
866 prop_text_out.foreground->blue = 0xffff;
867 }
868
d52cfc84 869
a56a1ba4 870 /* Print status of the process : U, WF, WC, E, W, R */
871 if(process_out->state->s == LTTV_STATE_UNNAMED)
cfe526b1 872 prop_text_out.text = "U->";
a56a1ba4 873 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
cfe526b1 874 prop_text_out.text = "WF->";
a56a1ba4 875 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
cfe526b1 876 prop_text_out.text = "WC->";
0828099d 877 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 878 prop_text_out.text = "E->";
a56a1ba4 879 else if(process_out->state->s == LTTV_STATE_WAIT)
cfe526b1 880 prop_text_out.text = "W->";
a56a1ba4 881 else if(process_out->state->s == LTTV_STATE_RUN)
cfe526b1 882 prop_text_out.text = "R->";
a56a1ba4 883 else
68997a22 884 prop_text_out.text = "U";
a56a1ba4 885
886 draw_text((void*)&prop_text_out, (void*)draw_context_out);
d0cd7f09 887 //gdk_gc_unref(draw_context_out->gc);
a56a1ba4 888
51705146 889 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
890 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
891 draw_context_out->gc = control_flow_data->drawing->gc;
a56a1ba4 892
893 PropertiesLine prop_line_out;
894 prop_line_out.color = g_new(GdkColor,1);
cfe526b1 895 prop_line_out.line_width = 2;
a56a1ba4 896 prop_line_out.style = GDK_LINE_SOLID;
897 prop_line_out.position = MIDDLE;
d52cfc84 898
2a2fa4f0 899 g_debug("out state : %s", g_quark_to_string(process_out->state->s));
a56a1ba4 900
901 /* color of line : status of the process */
902 if(process_out->state->s == LTTV_STATE_UNNAMED)
903 {
cfe526b1 904 prop_line_out.color->red = 0xffff;
905 prop_line_out.color->green = 0xffff;
906 prop_line_out.color->blue = 0xffff;
a56a1ba4 907 }
908 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
909 {
910 prop_line_out.color->red = 0x0fff;
d52cfc84 911 prop_line_out.color->green = 0xffff;
912 prop_line_out.color->blue = 0xfff0;
a56a1ba4 913 }
914 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
915 {
2df6f2bd 916 prop_line_out.color->red = 0xffff;
917 prop_line_out.color->green = 0xffff;
a56a1ba4 918 prop_line_out.color->blue = 0x0000;
919 }
0828099d 920 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
a56a1ba4 921 {
922 prop_line_out.color->red = 0xffff;
923 prop_line_out.color->green = 0x0000;
924 prop_line_out.color->blue = 0xffff;
925 }
926 else if(process_out->state->s == LTTV_STATE_WAIT)
927 {
928 prop_line_out.color->red = 0xffff;
929 prop_line_out.color->green = 0x0000;
930 prop_line_out.color->blue = 0x0000;
931 }
932 else if(process_out->state->s == LTTV_STATE_RUN)
933 {
934 prop_line_out.color->red = 0x0000;
935 prop_line_out.color->green = 0xffff;
936 prop_line_out.color->blue = 0x0000;
937 }
938 else
939 {
cfe526b1 940 prop_line_out.color->red = 0xffff;
941 prop_line_out.color->green = 0xffff;
942 prop_line_out.color->blue = 0xffff;
a56a1ba4 943 }
944
945 draw_line((void*)&prop_line_out, (void*)draw_context_out);
946 g_free(prop_line_out.color);
51705146 947 //gdk_gc_unref(draw_context_out->gc);
a56a1ba4 948 /* Note : finishing line will have to be added when trace read over. */
949
950 /* Finally, update the drawing context of the pid_in. */
951
14963be0 952 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
68997a22 953 draw_context_in->current->modify_over->x = x;
319e9d81 954 draw_context_in->current->modify_under->x = x;
68997a22 955 draw_context_in->current->modify_over->y = y_in;
319e9d81 956 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
501d5405 957 draw_context_in->drawable = control_flow_data->drawing->pixmap;
958 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
959 widget = control_flow_data->drawing->drawing_area;
a56a1ba4 960 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
961 //draw_context_in->gc = widget->style->black_gc;
d0cd7f09 962 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
963 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
a56a1ba4 964
965 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
501d5405 966 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 967
968 /* Draw the line/bg of the in process */
969 if(draw_context_in->previous->middle->x == -1)
970 {
ca0f8a8e 971 draw_context_in->previous->over->x =
972 control_flow_data->drawing->damage_begin;
973 draw_context_in->previous->middle->x =
974 control_flow_data->drawing->damage_begin;
975 draw_context_in->previous->under->x =
976 control_flow_data->drawing->damage_begin;
977
978 g_debug("in middle x_beg : %u",control_flow_data->drawing->damage_begin);
979
d0cd7f09 980 }
981
982 draw_context_in->current->middle->x = x;
983 draw_context_in->current->over->x = x;
984 draw_context_in->current->under->x = x;
985 draw_context_in->current->middle->y = y_in + height/2;
986 draw_context_in->current->over->y = y_in;
987 draw_context_in->current->under->y = y_in + height;
988 draw_context_in->previous->middle->y = y_in + height/2;
989 draw_context_in->previous->over->y = y_in;
990 draw_context_in->previous->under->y = y_in + height;
a56a1ba4 991
d0cd7f09 992 draw_context_in->drawable = control_flow_data->drawing->pixmap;
993 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
994
995
996 if(process_in->state->s == LTTV_STATE_RUN)
997 {
51705146 998 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
999 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1000 draw_context_in->gc = control_flow_data->drawing->gc;
d0cd7f09 1001
1002 PropertiesBG prop_bg;
1003 prop_bg.color = g_new(GdkColor,1);
1004
1005 switch(tfc->index) {
1006 case 0:
1007 prop_bg.color->red = 0x1515;
1008 prop_bg.color->green = 0x1515;
1009 prop_bg.color->blue = 0x8c8c;
1010 break;
1011 case 1:
1012 prop_bg.color->red = 0x4e4e;
1013 prop_bg.color->green = 0xa9a9;
1014 prop_bg.color->blue = 0xa4a4;
1015 break;
1016 case 2:
1017 prop_bg.color->red = 0x7a7a;
1018 prop_bg.color->green = 0x4a4a;
1019 prop_bg.color->blue = 0x8b8b;
1020 break;
1021 case 3:
1022 prop_bg.color->red = 0x8080;
1023 prop_bg.color->green = 0x7777;
1024 prop_bg.color->blue = 0x4747;
1025 break;
1026 default:
1027 prop_bg.color->red = 0xe7e7;
1028 prop_bg.color->green = 0xe7e7;
1029 prop_bg.color->blue = 0xe7e7;
1030 }
1031
1032
1033 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1034 g_free(prop_bg.color);
51705146 1035 //gdk_gc_unref(draw_context_in->gc);
d0cd7f09 1036 }
1037
1038 draw_context_in->gc = widget->style->black_gc;
1039
a56a1ba4 1040 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
2df6f2bd 1041 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 1042 PropertiesText prop_text_in;
1043 prop_text_in.foreground = &colorfg_in;
1044 prop_text_in.background = &colorbg_in;
cfe526b1 1045 prop_text_in.size = 6;
a56a1ba4 1046 prop_text_in.position = OVER;
1047
2a2fa4f0 1048 g_debug("in state : %s", g_quark_to_string(process_in->state->s));
cfe526b1 1049 /* foreground of text : status of the process */
1050 if(process_in->state->s == LTTV_STATE_UNNAMED)
1051 {
1052 prop_text_in.foreground->red = 0xffff;
1053 prop_text_in.foreground->green = 0xffff;
1054 prop_text_in.foreground->blue = 0xffff;
1055 }
1056 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1057 {
1058 prop_text_in.foreground->red = 0x0fff;
d52cfc84 1059 prop_text_in.foreground->green = 0xffff;
1060 prop_text_in.foreground->blue = 0xfff0;
cfe526b1 1061 }
1062 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1063 {
2df6f2bd 1064 prop_text_in.foreground->red = 0xffff;
1065 prop_text_in.foreground->green = 0xffff;
cfe526b1 1066 prop_text_in.foreground->blue = 0x0000;
1067 }
0828099d 1068 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 1069 {
1070 prop_text_in.foreground->red = 0xffff;
1071 prop_text_in.foreground->green = 0x0000;
1072 prop_text_in.foreground->blue = 0xffff;
1073 }
1074 else if(process_in->state->s == LTTV_STATE_WAIT)
1075 {
1076 prop_text_in.foreground->red = 0xffff;
1077 prop_text_in.foreground->green = 0x0000;
1078 prop_text_in.foreground->blue = 0x0000;
1079 }
1080 else if(process_in->state->s == LTTV_STATE_RUN)
1081 {
1082 prop_text_in.foreground->red = 0x0000;
1083 prop_text_in.foreground->green = 0xffff;
1084 prop_text_in.foreground->blue = 0x0000;
1085 }
1086 else
1087 {
1088 prop_text_in.foreground->red = 0xffff;
1089 prop_text_in.foreground->green = 0xffff;
1090 prop_text_in.foreground->blue = 0xffff;
1091 }
1092
1093
1094
a56a1ba4 1095 /* Print status of the process : U, WF, WC, E, W, R */
1096 if(process_in->state->s == LTTV_STATE_UNNAMED)
cfe526b1 1097 prop_text_in.text = "U->";
a56a1ba4 1098 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
cfe526b1 1099 prop_text_in.text = "WF->";
a56a1ba4 1100 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
cfe526b1 1101 prop_text_in.text = "WC->";
0828099d 1102 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 1103 prop_text_in.text = "E->";
a56a1ba4 1104 else if(process_in->state->s == LTTV_STATE_WAIT)
cfe526b1 1105 prop_text_in.text = "W->";
a56a1ba4 1106 else if(process_in->state->s == LTTV_STATE_RUN)
cfe526b1 1107 prop_text_in.text = "R->";
a56a1ba4 1108 else
68997a22 1109 prop_text_in.text = "U";
a56a1ba4 1110
1111 draw_text((void*)&prop_text_in, (void*)draw_context_in);
d0cd7f09 1112 //gdk_gc_unref(draw_context_in->gc);
1113
51705146 1114 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1115 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1116 draw_context_in->gc = control_flow_data->drawing->gc;
d0cd7f09 1117
a56a1ba4 1118 PropertiesLine prop_line_in;
1119 prop_line_in.color = g_new(GdkColor,1);
cfe526b1 1120 prop_line_in.line_width = 2;
a56a1ba4 1121 prop_line_in.style = GDK_LINE_SOLID;
1122 prop_line_in.position = MIDDLE;
1123
1124 /* color of line : status of the process */
1125 if(process_in->state->s == LTTV_STATE_UNNAMED)
1126 {
cfe526b1 1127 prop_line_in.color->red = 0xffff;
1128 prop_line_in.color->green = 0xffff;
1129 prop_line_in.color->blue = 0xffff;
a56a1ba4 1130 }
1131 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1132 {
1133 prop_line_in.color->red = 0x0fff;
d52cfc84 1134 prop_line_in.color->green = 0xffff;
1135 prop_line_in.color->blue = 0xfff0;
a56a1ba4 1136 }
1137 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1138 {
2df6f2bd 1139 prop_line_in.color->red = 0xffff;
1140 prop_line_in.color->green = 0xffff;
a56a1ba4 1141 prop_line_in.color->blue = 0x0000;
1142 }
0828099d 1143 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
a56a1ba4 1144 {
1145 prop_line_in.color->red = 0xffff;
1146 prop_line_in.color->green = 0x0000;
1147 prop_line_in.color->blue = 0xffff;
1148 }
1149 else if(process_in->state->s == LTTV_STATE_WAIT)
1150 {
1151 prop_line_in.color->red = 0xffff;
1152 prop_line_in.color->green = 0x0000;
1153 prop_line_in.color->blue = 0x0000;
1154 }
1155 else if(process_in->state->s == LTTV_STATE_RUN)
1156 {
1157 prop_line_in.color->red = 0x0000;
1158 prop_line_in.color->green = 0xffff;
1159 prop_line_in.color->blue = 0x0000;
1160 }
1161 else
1162 {
cfe526b1 1163 prop_line_in.color->red = 0xffff;
1164 prop_line_in.color->green = 0xffff;
1165 prop_line_in.color->blue = 0xffff;
a56a1ba4 1166 }
1167
1168 draw_line((void*)&prop_line_in, (void*)draw_context_in);
1169 g_free(prop_line_in.color);
51705146 1170 //gdk_gc_unref(draw_context_in->gc);
a56a1ba4 1171 }
1172
1173 return 0;
b9a010a2 1174#endif //0
1175
1176
a56a1ba4 1177
51705146 1178 /* Text dump */
80a52ff8 1179#ifdef DONTSHOW
a56a1ba4 1180 GString *string = g_string_new("");;
1181 gboolean field_names = TRUE, state = TRUE;
80a52ff8 1182
e9a9c513 1183 lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs);
1184 g_string_append_printf(string,"\n");
1185
1186 if(state) {
1187 g_string_append_printf(string, " %s",
1188 g_quark_to_string(tfs->process->state->s));
1189 }
1190
1191 g_info("%s",string->str);
1192
a56a1ba4 1193 g_string_free(string, TRUE);
1194
1195 /* End of text dump */
80a52ff8 1196#endif //DONTSHOW
50439712 1197
f0d936c0 1198}
1199
b9a010a2 1200/* draw_after_hook
1201 *
1202 * The draw after hook is called by the reading API to have a
1203 * particular event drawn on the screen.
1204 * @param hook_data ControlFlowData structure of the viewer.
1205 * @param call_data Event context.
1206 *
1207 * This function adds items to be drawn in a queue for each process.
1208 *
1209 */
4c69e0cc 1210int draw_after_hook(void *hook_data, void *call_data)
f0d936c0 1211{
ca0f8a8e 1212 EventsRequest *events_request = (EventsRequest*)hook_data;
1213 ControlFlowData *control_flow_data = events_request->viewer_data;
50439712 1214
a56a1ba4 1215 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
50439712 1216
1217 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1aff52a2 1218 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
50439712 1219
b9a010a2 1220 LttEvent *e;
1221 e = tfc->e;
1222
1223 LttTime evtime = ltt_event_time(e);
1224 TimeWindow time_window =
1225 lttvwindow_get_time_window(control_flow_data->tab);
1226
1227 LttTime end_time = ltt_time_add(time_window.start_time,
1228 time_window.time_width);
1229
1230 if(ltt_time_compare(evtime, time_window.start_time) == -1
1231 || ltt_time_compare(evtime, end_time) == 1)
1232 return;
1233
1234 guint width = control_flow_data->drawing->width;
1235
1236 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) {
1237
1238 g_debug("schedchange!");
1239
1240 {
1241 /* Add process to process list (if not present) */
1242 LttvProcessState *process_out, *process_in;
1243 LttTime birth;
1244 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
1245 HashedProcessData *hashed_process_data_in = NULL;
1246
1247 ProcessList *process_list =
1248 guicontrolflow_get_process_list(control_flow_data);
1249
1250 guint pid_in;
1251 {
1252 guint pid_out;
1253 LttField *f = ltt_event_field(e);
1254 LttField *element;
1255 element = ltt_field_member(f,0);
1256 pid_out = ltt_event_get_long_unsigned(e,element);
1257 element = ltt_field_member(f,1);
1258 pid_in = ltt_event_get_long_unsigned(e,element);
1259 g_debug("out : %u in : %u", pid_out, pid_in);
1260 }
1261
1262
1263 /* Find process pid_in in the list... */
1264 process_in = lttv_state_find_process(tfs, pid_in);
1265 /* It should exist, because we are after the state update. */
1266 g_assert(process_in != NULL);
1267
1268 birth = process_in->creation_time;
1269 const gchar *name = g_quark_to_string(process_in->name);
1270
1271 if(processlist_get_process_pixels(process_list,
1272 pid_in,
1273 &birth,
1274 tfc->t_context->index,
1275 &y_in,
1276 &height,
1277 &hashed_process_data_in) == 1)
1278 {
e025a729 1279 g_assert(!(process_in->pid == 432 &&
1280 ltt_time_compare(process_in->creation_time,
1281 ltt_time_zero)==0));
1282
1283 g_assert(!(process_in->pid == 432 &&
1284 process_in->creation_time.tv_nsec == 47797905));
1285
b9a010a2 1286 /* Process not present */
1287 processlist_add(process_list,
1288 pid_in,
1289 &birth,
1290 tfc->t_context->index,
1291 name,
1292 &pl_height,
1293 &hashed_process_data_in);
1294 processlist_get_process_pixels(process_list,
1295 pid_in,
1296 &birth,
1297 tfc->t_context->index,
1298 &y_in,
1299 &height,
1300 &hashed_process_data_in);
1301 drawing_insert_square( control_flow_data->drawing, y_in, height);
1302 }
1303
1304 convert_time_to_pixels(
1305 time_window.start_time,
1306 end_time,
1307 evtime,
1308 width,
1309 &hashed_process_data_in->x);
1310 }
f37a2002 1311 } else if(strcmp(
1312 ltt_eventtype_name(ltt_event_eventtype(e)),"process") == 0) {
1313 /* We are in a fork or exit event */
1314
1315
b9a010a2 1316 }
f37a2002 1317
b9a010a2 1318 return 0;
1319
1320
1321
1322#if 0
1323 EventsRequest *events_request = (EventsRequest*)hook_data;
1324 ControlFlowData *control_flow_data = events_request->viewer_data;
1325
1326 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1327
1328 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1329 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
1330
a56a1ba4 1331
50439712 1332 LttEvent *e;
1333 e = tfc->e;
1334
9444deae 1335 LttTime evtime = ltt_event_time(e);
ca0f8a8e 1336 TimeWindow time_window =
1337 lttvwindow_get_time_window(control_flow_data->tab);
9444deae 1338
ca0f8a8e 1339 LttTime end_time = ltt_time_add(time_window.start_time,
1340 time_window.time_width);
9444deae 1341 //if(time < time_beg || time > time_end) return;
ca0f8a8e 1342 if(ltt_time_compare(evtime, time_window.start_time) == -1
9444deae 1343 || ltt_time_compare(evtime, end_time) == 1)
1344 return;
1345
1346
a56a1ba4 1347 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
1348 {
2a2fa4f0 1349 g_debug("schedchange!");
a56a1ba4 1350
1351 /* Add process to process list (if not present) and get drawing "y" from
1352 * process position */
1353 guint pid_out, pid_in;
1354 LttvProcessState *process_out, *process_in;
1355 LttTime birth;
1356 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
1357
1358 ProcessList *process_list =
ca0f8a8e 1359 guicontrolflow_get_process_list(control_flow_data);
a56a1ba4 1360
1361
1362 LttField *f = ltt_event_field(e);
1363 LttField *element;
1364 element = ltt_field_member(f,0);
1365 pid_out = ltt_event_get_long_unsigned(e,element);
1366 element = ltt_field_member(f,1);
1367 pid_in = ltt_event_get_long_unsigned(e,element);
2a2fa4f0 1368 //g_debug("out : %u in : %u", pid_out, pid_in);
a56a1ba4 1369
1370
1371 /* Find process pid_out in the list... */
2a2fa4f0 1372 process_out = lttv_state_find_process(tfs, pid_out);
1aff52a2 1373 if(process_out == NULL) return 0;
2a2fa4f0 1374 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
a56a1ba4 1375
1376 birth = process_out->creation_time;
1377 gchar *name = strdup(g_quark_to_string(process_out->name));
14963be0 1378 HashedProcessData *hashed_process_data_out = NULL;
a56a1ba4 1379
1380 if(processlist_get_process_pixels(process_list,
1381 pid_out,
1382 &birth,
d0cd7f09 1383 tfc->t_context->index,
a56a1ba4 1384 &y_out,
1385 &height,
14963be0 1386 &hashed_process_data_out) == 1)
a56a1ba4 1387 {
51705146 1388 /* Process not present */
1389 processlist_add(process_list,
1390 pid_out,
1391 &birth,
1392 tfc->t_context->index,
1393 name,
1394 &pl_height,
1395 &hashed_process_data_out);
1396 processlist_get_process_pixels(process_list,
1397 pid_out,
1398 &birth,
1399 tfc->t_context->index,
1400 &y_out,
1401 &height,
1402 &hashed_process_data_out);
1403 drawing_insert_square( control_flow_data->drawing, y_out, height);
a56a1ba4 1404 }
1405
1406 g_free(name);
1407
1408 /* Find process pid_in in the list... */
2a2fa4f0 1409 process_in = lttv_state_find_process(tfs, pid_in);
1aff52a2 1410 if(process_in == NULL) return 0;
2a2fa4f0 1411 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
a56a1ba4 1412
1413 birth = process_in->creation_time;
1414 name = strdup(g_quark_to_string(process_in->name));
14963be0 1415 HashedProcessData *hashed_process_data_in = NULL;
a56a1ba4 1416
1417 if(processlist_get_process_pixels(process_list,
1418 pid_in,
1419 &birth,
d0cd7f09 1420 tfc->t_context->index,
a56a1ba4 1421 &y_in,
1422 &height,
14963be0 1423 &hashed_process_data_in) == 1)
a56a1ba4 1424 {
1425 /* Process not present */
1426 processlist_add(process_list,
1427 pid_in,
1428 &birth,
d0cd7f09 1429 tfc->t_context->index,
a56a1ba4 1430 name,
1431 &pl_height,
14963be0 1432 &hashed_process_data_in);
a56a1ba4 1433 processlist_get_process_pixels(process_list,
1434 pid_in,
1435 &birth,
d0cd7f09 1436 tfc->t_context->index,
a56a1ba4 1437 &y_in,
1438 &height,
14963be0 1439 &hashed_process_data_in);
a56a1ba4 1440
ca0f8a8e 1441 drawing_insert_square( control_flow_data->drawing, y_in, height);
a56a1ba4 1442 }
1443 g_free(name);
1444
1445
1446 /* Find pixels corresponding to time of the event. If the time does
1447 * not fit in the window, show a warning, not supposed to happend. */
1448 //guint x = 0;
501d5405 1449 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
a56a1ba4 1450
1451 //LttTime time = ltt_event_time(e);
1452
224446ce 1453 //LttTime window_end = ltt_time_add(time_window->time_width,
1454 // time_window->start_time);
a56a1ba4 1455
1456
1457 //convert_time_to_pixels(
224446ce 1458 // time_window->start_time,
a56a1ba4 1459 // window_end,
1460 // time,
1461 // width,
1462 // &x);
1463
1464 //assert(x <= width);
1465
1466 /* draw what represents the event for outgoing process. */
1467
14963be0 1468 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
68997a22 1469 //draw_context_out->current->modify_over->x = x;
1470 draw_context_out->current->modify_over->y = y_out;
319e9d81 1471 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
501d5405 1472 draw_context_out->drawable = control_flow_data->drawing->pixmap;
1473 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
1474 GtkWidget *widget = control_flow_data->drawing->drawing_area;
a56a1ba4 1475 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
d0cd7f09 1476
a56a1ba4 1477 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
501d5405 1478 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 1479
1480 /*if(process_out->state->s == LTTV_STATE_RUN)
1481 {
1482 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1483 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1484 PropertiesBG prop_bg;
1485 prop_bg.color = g_new(GdkColor,1);
1486
1487 prop_bg.color->red = 0xffff;
1488 prop_bg.color->green = 0xffff;
1489 prop_bg.color->blue = 0xffff;
1490
1491 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1492 g_free(prop_bg.color);
1493 gdk_gc_unref(draw_context_out->gc);
1494 }*/
1495
1496 draw_context_out->gc = widget->style->black_gc;
1497
a56a1ba4 1498 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
2df6f2bd 1499 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 1500 PropertiesText prop_text_out;
1501 prop_text_out.foreground = &colorfg_out;
1502 prop_text_out.background = &colorbg_out;
cfe526b1 1503 prop_text_out.size = 6;
a56a1ba4 1504 prop_text_out.position = OVER;
1505
cfe526b1 1506 /* color of text : status of the process */
1507 if(process_out->state->s == LTTV_STATE_UNNAMED)
1508 {
1509 prop_text_out.foreground->red = 0xffff;
1510 prop_text_out.foreground->green = 0xffff;
1511 prop_text_out.foreground->blue = 0xffff;
1512 }
1513 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
1514 {
1515 prop_text_out.foreground->red = 0x0fff;
d52cfc84 1516 prop_text_out.foreground->green = 0xffff;
1517 prop_text_out.foreground->blue = 0xfff0;
cfe526b1 1518 }
1519 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
1520 {
2df6f2bd 1521 prop_text_out.foreground->red = 0xffff;
1522 prop_text_out.foreground->green = 0xffff;
cfe526b1 1523 prop_text_out.foreground->blue = 0x0000;
1524 }
0828099d 1525 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 1526 {
1527 prop_text_out.foreground->red = 0xffff;
1528 prop_text_out.foreground->green = 0x0000;
1529 prop_text_out.foreground->blue = 0xffff;
1530 }
1531 else if(process_out->state->s == LTTV_STATE_WAIT)
1532 {
1533 prop_text_out.foreground->red = 0xffff;
1534 prop_text_out.foreground->green = 0x0000;
1535 prop_text_out.foreground->blue = 0x0000;
1536 }
1537 else if(process_out->state->s == LTTV_STATE_RUN)
1538 {
1539 prop_text_out.foreground->red = 0x0000;
1540 prop_text_out.foreground->green = 0xffff;
1541 prop_text_out.foreground->blue = 0x0000;
1542 }
1543 else
1544 {
1545 prop_text_out.foreground->red = 0xffff;
1546 prop_text_out.foreground->green = 0xffff;
1547 prop_text_out.foreground->blue = 0xffff;
1548 }
1549
a56a1ba4 1550 /* Print status of the process : U, WF, WC, E, W, R */
1551 if(process_out->state->s == LTTV_STATE_UNNAMED)
68997a22 1552 prop_text_out.text = "U";
a56a1ba4 1553 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
68997a22 1554 prop_text_out.text = "WF";
a56a1ba4 1555 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
68997a22 1556 prop_text_out.text = "WC";
0828099d 1557 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
68997a22 1558 prop_text_out.text = "E";
a56a1ba4 1559 else if(process_out->state->s == LTTV_STATE_WAIT)
68997a22 1560 prop_text_out.text = "W";
a56a1ba4 1561 else if(process_out->state->s == LTTV_STATE_RUN)
68997a22 1562 prop_text_out.text = "R";
a56a1ba4 1563 else
68997a22 1564 prop_text_out.text = "U";
a56a1ba4 1565
1566 draw_text((void*)&prop_text_out, (void*)draw_context_out);
d0cd7f09 1567
1568 //gdk_gc_unref(draw_context_out->gc);
319e9d81 1569
68997a22 1570 draw_context_out->current->middle->y = y_out+height/2;
d0cd7f09 1571 draw_context_out->current->over->y = y_out;
1572 draw_context_out->current->under->y = y_out+height;
68997a22 1573 draw_context_out->current->status = process_out->state->s;
a56a1ba4 1574
68997a22 1575 /* for pid_out : remove previous, Prev = current, new current (default) */
1576 g_free(draw_context_out->previous->modify_under);
1577 g_free(draw_context_out->previous->modify_middle);
1578 g_free(draw_context_out->previous->modify_over);
1579 g_free(draw_context_out->previous->under);
1580 g_free(draw_context_out->previous->middle);
1581 g_free(draw_context_out->previous->over);
1582 g_free(draw_context_out->previous);
1583
1584 draw_context_out->previous = draw_context_out->current;
a56a1ba4 1585
68997a22 1586 draw_context_out->current = g_new(DrawInfo,1);
1587 draw_context_out->current->over = g_new(ItemInfo,1);
1588 draw_context_out->current->over->x = -1;
1589 draw_context_out->current->over->y = -1;
1590 draw_context_out->current->middle = g_new(ItemInfo,1);
1591 draw_context_out->current->middle->x = -1;
1592 draw_context_out->current->middle->y = -1;
1593 draw_context_out->current->under = g_new(ItemInfo,1);
1594 draw_context_out->current->under->x = -1;
1595 draw_context_out->current->under->y = -1;
1596 draw_context_out->current->modify_over = g_new(ItemInfo,1);
1597 draw_context_out->current->modify_over->x = -1;
1598 draw_context_out->current->modify_over->y = -1;
1599 draw_context_out->current->modify_middle = g_new(ItemInfo,1);
1600 draw_context_out->current->modify_middle->x = -1;
1601 draw_context_out->current->modify_middle->y = -1;
1602 draw_context_out->current->modify_under = g_new(ItemInfo,1);
1603 draw_context_out->current->modify_under->x = -1;
1604 draw_context_out->current->modify_under->y = -1;
1605 draw_context_out->current->status = LTTV_STATE_UNNAMED;
a56a1ba4 1606
1607 /* Finally, update the drawing context of the pid_in. */
1608
14963be0 1609 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
68997a22 1610 //draw_context_in->current->modify_over->x = x;
1611 draw_context_in->current->modify_over->y = y_in;
319e9d81 1612 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
501d5405 1613 draw_context_in->drawable = control_flow_data->drawing->pixmap;
1614 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
1615 widget = control_flow_data->drawing->drawing_area;
a56a1ba4 1616 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
a56a1ba4 1617
1618 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
501d5405 1619 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 1620
1621 /*if(process_in->state->s == LTTV_STATE_RUN)
1622 {
1623 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1624 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1625 PropertiesBG prop_bg;
1626 prop_bg.color = g_new(GdkColor,1);
1627
1628 prop_bg.color->red = 0xffff;
1629 prop_bg.color->green = 0xffff;
1630 prop_bg.color->blue = 0xffff;
1631
1632 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1633 g_free(prop_bg.color);
1634 gdk_gc_unref(draw_context_in->gc);
1635 }*/
1636
1637 draw_context_in->gc = widget->style->black_gc;
1638
a56a1ba4 1639 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
2df6f2bd 1640 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 1641 PropertiesText prop_text_in;
1642 prop_text_in.foreground = &colorfg_in;
1643 prop_text_in.background = &colorbg_in;
cfe526b1 1644 prop_text_in.size = 6;
a56a1ba4 1645 prop_text_in.position = OVER;
1646
cfe526b1 1647 /* foreground of text : status of the process */
1648 if(process_in->state->s == LTTV_STATE_UNNAMED)
1649 {
1650 prop_text_in.foreground->red = 0xffff;
1651 prop_text_in.foreground->green = 0xffff;
1652 prop_text_in.foreground->blue = 0xffff;
1653 }
1654 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1655 {
1656 prop_text_in.foreground->red = 0x0fff;
d52cfc84 1657 prop_text_in.foreground->green = 0xffff;
1658 prop_text_in.foreground->blue = 0xfff0;
cfe526b1 1659 }
1660 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1661 {
2df6f2bd 1662 prop_text_in.foreground->red = 0xffff;
1663 prop_text_in.foreground->green = 0xffff;
cfe526b1 1664 prop_text_in.foreground->blue = 0x0000;
1665 }
0828099d 1666 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 1667 {
1668 prop_text_in.foreground->red = 0xffff;
1669 prop_text_in.foreground->green = 0x0000;
1670 prop_text_in.foreground->blue = 0xffff;
1671 }
1672 else if(process_in->state->s == LTTV_STATE_WAIT)
1673 {
1674 prop_text_in.foreground->red = 0xffff;
1675 prop_text_in.foreground->green = 0x0000;
1676 prop_text_in.foreground->blue = 0x0000;
1677 }
1678 else if(process_in->state->s == LTTV_STATE_RUN)
1679 {
1680 prop_text_in.foreground->red = 0x0000;
1681 prop_text_in.foreground->green = 0xffff;
1682 prop_text_in.foreground->blue = 0x0000;
1683 }
1684 else
1685 {
1686 prop_text_in.foreground->red = 0xffff;
1687 prop_text_in.foreground->green = 0xffff;
1688 prop_text_in.foreground->blue = 0xffff;
1689 }
1690
1691
a56a1ba4 1692 /* Print status of the process : U, WF, WC, E, W, R */
1693 if(process_in->state->s == LTTV_STATE_UNNAMED)
68997a22 1694 prop_text_in.text = "U";
a56a1ba4 1695 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
68997a22 1696 prop_text_in.text = "WF";
a56a1ba4 1697 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
68997a22 1698 prop_text_in.text = "WC";
0828099d 1699 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
68997a22 1700 prop_text_in.text = "E";
a56a1ba4 1701 else if(process_in->state->s == LTTV_STATE_WAIT)
68997a22 1702 prop_text_in.text = "W";
a56a1ba4 1703 else if(process_in->state->s == LTTV_STATE_RUN)
68997a22 1704 prop_text_in.text = "R";
a56a1ba4 1705 else
68997a22 1706 prop_text_in.text = "U";
a56a1ba4 1707
1708 draw_text((void*)&prop_text_in, (void*)draw_context_in);
1709
d0cd7f09 1710
319e9d81 1711 if(process_in->state->s == LTTV_STATE_RUN)
1712 {
1713 gchar tmp[255];
1714 prop_text_in.foreground = &colorfg_in;
1715 prop_text_in.background = &colorbg_in;
1716 prop_text_in.foreground->red = 0xffff;
1717 prop_text_in.foreground->green = 0xffff;
1718 prop_text_in.foreground->blue = 0xffff;
1719 prop_text_in.size = 6;
1720 prop_text_in.position = UNDER;
1721
1722 prop_text_in.text = g_new(gchar, 260);
1723 strcpy(prop_text_in.text, "CPU ");
1724 snprintf(tmp, 255, "%u", tfc->index);
1725 strcat(prop_text_in.text, tmp);
1726
1727 draw_text((void*)&prop_text_in, (void*)draw_context_in);
1728 g_free(prop_text_in.text);
1729 }
1730
1731
68997a22 1732 draw_context_in->current->middle->y = y_in+height/2;
d0cd7f09 1733 draw_context_in->current->over->y = y_in;
1734 draw_context_in->current->under->y = y_in+height;
68997a22 1735 draw_context_in->current->status = process_in->state->s;
1736
1737 /* for pid_in : remove previous, Prev = current, new current (default) */
1738 g_free(draw_context_in->previous->modify_under);
1739 g_free(draw_context_in->previous->modify_middle);
1740 g_free(draw_context_in->previous->modify_over);
1741 g_free(draw_context_in->previous->under);
1742 g_free(draw_context_in->previous->middle);
1743 g_free(draw_context_in->previous->over);
1744 g_free(draw_context_in->previous);
1745
1746 draw_context_in->previous = draw_context_in->current;
a56a1ba4 1747
68997a22 1748 draw_context_in->current = g_new(DrawInfo,1);
1749 draw_context_in->current->over = g_new(ItemInfo,1);
1750 draw_context_in->current->over->x = -1;
1751 draw_context_in->current->over->y = -1;
1752 draw_context_in->current->middle = g_new(ItemInfo,1);
1753 draw_context_in->current->middle->x = -1;
1754 draw_context_in->current->middle->y = -1;
1755 draw_context_in->current->under = g_new(ItemInfo,1);
1756 draw_context_in->current->under->x = -1;
1757 draw_context_in->current->under->y = -1;
1758 draw_context_in->current->modify_over = g_new(ItemInfo,1);
1759 draw_context_in->current->modify_over->x = -1;
1760 draw_context_in->current->modify_over->y = -1;
1761 draw_context_in->current->modify_middle = g_new(ItemInfo,1);
1762 draw_context_in->current->modify_middle->x = -1;
1763 draw_context_in->current->modify_middle->y = -1;
1764 draw_context_in->current->modify_under = g_new(ItemInfo,1);
1765 draw_context_in->current->modify_under->x = -1;
1766 draw_context_in->current->modify_under->y = -1;
1767 draw_context_in->current->status = LTTV_STATE_UNNAMED;
a56a1ba4 1768
1769 }
1770
1771 return 0;
b9a010a2 1772#endif //0
f0d936c0 1773}
f7afe191 1774
1775
1776
1777
1b238973 1778gint update_time_window_hook(void *hook_data, void *call_data)
f7afe191 1779{
a56a1ba4 1780 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
a43d67ba 1781 Drawing_t *drawing = control_flow_data->drawing;
1782
224446ce 1783 const TimeWindowNotifyData *time_window_nofify_data =
1784 ((const TimeWindowNotifyData *)call_data);
1785
14963be0 1786 TimeWindow *old_time_window =
224446ce 1787 time_window_nofify_data->old_time_window;
1788 TimeWindow *new_time_window =
1789 time_window_nofify_data->new_time_window;
a56a1ba4 1790
3cb8b205 1791 /* Update the ruler */
1792 drawing_update_ruler(control_flow_data->drawing,
1793 new_time_window);
1794
1795
a56a1ba4 1796 /* Two cases : zoom in/out or scrolling */
1797
1798 /* In order to make sure we can reuse the old drawing, the scale must
1799 * be the same and the new time interval being partly located in the
1800 * currently shown time interval. (reuse is only for scrolling)
1801 */
1802
1803 g_info("Old time window HOOK : %u, %u to %u, %u",
14963be0 1804 old_time_window->start_time.tv_sec,
1805 old_time_window->start_time.tv_nsec,
1806 old_time_window->time_width.tv_sec,
1807 old_time_window->time_width.tv_nsec);
a56a1ba4 1808
1809 g_info("New time window HOOK : %u, %u to %u, %u",
14963be0 1810 new_time_window->start_time.tv_sec,
1811 new_time_window->start_time.tv_nsec,
1812 new_time_window->time_width.tv_sec,
1813 new_time_window->time_width.tv_nsec);
a56a1ba4 1814
14963be0 1815 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
1816 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
a56a1ba4 1817 {
1818 /* Same scale (scrolling) */
1819 g_info("scrolling");
14963be0 1820 LttTime *ns = &new_time_window->start_time;
1821 LttTime *os = &old_time_window->start_time;
1822 LttTime old_end = ltt_time_add(old_time_window->start_time,
1823 old_time_window->time_width);
1824 LttTime new_end = ltt_time_add(new_time_window->start_time,
1825 new_time_window->time_width);
a56a1ba4 1826 //if(ns<os+w<ns+w)
1827 //if(ns<os+w && os+w<ns+w)
1828 //if(ns<old_end && os<ns)
1829 if(ltt_time_compare(*ns, old_end) == -1
1830 && ltt_time_compare(*os, *ns) == -1)
1831 {
1832 g_info("scrolling near right");
1833 /* Scroll right, keep right part of the screen */
1834 guint x = 0;
51705146 1835 guint width = control_flow_data->drawing->width;
a56a1ba4 1836 convert_time_to_pixels(
1837 *os,
1838 old_end,
1839 *ns,
1840 width,
1841 &x);
1842
1843 /* Copy old data to new location */
501d5405 1844 gdk_draw_drawable (control_flow_data->drawing->pixmap,
cfe526b1 1845 control_flow_data->drawing->drawing_area->style->black_gc,
501d5405 1846 control_flow_data->drawing->pixmap,
a56a1ba4 1847 x, 0,
1848 0, 0,
6395d57c 1849 control_flow_data->drawing->width-x+SAFETY, -1);
1850
1851 if(drawing->damage_begin == drawing->damage_end)
1852 drawing->damage_begin = control_flow_data->drawing->width-x;
1853 else
1854 drawing->damage_begin = 0;
1855
1856 drawing->damage_end = control_flow_data->drawing->width;
1857
a56a1ba4 1858 /* Clear the data request background, but not SAFETY */
501d5405 1859 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
6395d57c 1860 //control_flow_data->drawing->drawing_area->style->black_gc,
cfe526b1 1861 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1862 TRUE,
6395d57c 1863 drawing->damage_begin+SAFETY, 0,
1864 drawing->damage_end - drawing->damage_begin, // do not overlap
51705146 1865 control_flow_data->drawing->height);
a43d67ba 1866
51705146 1867 gtk_widget_queue_draw_area (drawing->drawing_area,
a43d67ba 1868 0,0,
6395d57c 1869 control_flow_data->drawing->width,
a43d67ba 1870 control_flow_data->drawing->height);
1871
a56a1ba4 1872 /* Get new data for the rest. */
501d5405 1873 drawing_data_request(control_flow_data->drawing,
1874 &control_flow_data->drawing->pixmap,
6395d57c 1875 drawing->damage_begin, 0,
1876 drawing->damage_end - drawing->damage_begin,
501d5405 1877 control_flow_data->drawing->height);
a56a1ba4 1878 } else {
1879 //if(ns<os<ns+w)
1880 //if(ns<os && os<ns+w)
1881 //if(ns<os && os<new_end)
1882 if(ltt_time_compare(*ns,*os) == -1
1883 && ltt_time_compare(*os,new_end) == -1)
1884 {
1885 g_info("scrolling near left");
1886 /* Scroll left, keep left part of the screen */
1887 guint x = 0;
51705146 1888 guint width = control_flow_data->drawing->width;
a56a1ba4 1889 convert_time_to_pixels(
1890 *ns,
1891 new_end,
1892 *os,
1893 width,
1894 &x);
6395d57c 1895
1896
a56a1ba4 1897 /* Copy old data to new location */
501d5405 1898 gdk_draw_drawable (control_flow_data->drawing->pixmap,
cfe526b1 1899 control_flow_data->drawing->drawing_area->style->black_gc,
501d5405 1900 control_flow_data->drawing->pixmap,
a56a1ba4 1901 0, 0,
1902 x, 0,
1903 -1, -1);
1904
6395d57c 1905 if(drawing->damage_begin == drawing->damage_end)
1906 drawing->damage_end = x;
1907 else
1908 drawing->damage_end =
51705146 1909 control_flow_data->drawing->width;
6395d57c 1910
1911 drawing->damage_begin = 0;
1912
501d5405 1913 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
cfe526b1 1914 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1915 TRUE,
6395d57c 1916 drawing->damage_begin, 0,
1917 drawing->damage_end - drawing->damage_begin, // do not overlap
51705146 1918 control_flow_data->drawing->height);
a43d67ba 1919
6395d57c 1920 gtk_widget_queue_draw_area (drawing->drawing_area,
1921 0,0,
1922 control_flow_data->drawing->width,
a43d67ba 1923 control_flow_data->drawing->height);
1924
6395d57c 1925
a56a1ba4 1926 /* Get new data for the rest. */
501d5405 1927 drawing_data_request(control_flow_data->drawing,
1928 &control_flow_data->drawing->pixmap,
6395d57c 1929 drawing->damage_begin, 0,
1930 drawing->damage_end - drawing->damage_begin,
501d5405 1931 control_flow_data->drawing->height);
a56a1ba4 1932
a56a1ba4 1933 } else {
a43d67ba 1934 if(ltt_time_compare(*ns,*os) == 0)
1935 {
1936 g_info("not scrolling");
1937 } else {
1938 g_info("scrolling far");
1939 /* Cannot reuse any part of the screen : far jump */
1940
1941
1942 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
1943 control_flow_data->drawing->drawing_area->style->black_gc,
1944 TRUE,
a56a1ba4 1945 0, 0,
a43d67ba 1946 control_flow_data->drawing->width+SAFETY, // do not overlap
51705146 1947 control_flow_data->drawing->height);
a43d67ba 1948
1949 gtk_widget_queue_draw_area (drawing->drawing_area,
1950 0,0,
1951 control_flow_data->drawing->width,
1952 control_flow_data->drawing->height);
1953
6395d57c 1954 drawing->damage_begin = 0;
1955 drawing->damage_end = control_flow_data->drawing->width;
1956
a43d67ba 1957 drawing_data_request(control_flow_data->drawing,
1958 &control_flow_data->drawing->pixmap,
1959 0, 0,
1960 control_flow_data->drawing->width,
1961 control_flow_data->drawing->height);
1962
1963 }
a56a1ba4 1964 }
1965 }
1966 } else {
1967 /* Different scale (zoom) */
1968 g_info("zoom");
1969
501d5405 1970 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
cfe526b1 1971 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1972 TRUE,
1973 0, 0,
501d5405 1974 control_flow_data->drawing->width+SAFETY, // do not overlap
51705146 1975 control_flow_data->drawing->height);
a56a1ba4 1976
a43d67ba 1977 gtk_widget_queue_draw_area (drawing->drawing_area,
1978 0,0,
1979 control_flow_data->drawing->width,
1980 control_flow_data->drawing->height);
a56a1ba4 1981
6395d57c 1982 drawing->damage_begin = 0;
1983 drawing->damage_end = control_flow_data->drawing->width;
1984
501d5405 1985 drawing_data_request(control_flow_data->drawing,
1986 &control_flow_data->drawing->pixmap,
a56a1ba4 1987 0, 0,
501d5405 1988 control_flow_data->drawing->width,
1989 control_flow_data->drawing->height);
a56a1ba4 1990 }
1991
3cb8b205 1992
1993
a56a1ba4 1994 return 0;
f7afe191 1995}
1996
6395d57c 1997gint traceset_notify(void *hook_data, void *call_data)
1998{
1999 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2000 Drawing_t *drawing = control_flow_data->drawing;
2001 GtkWidget *widget = drawing->drawing_area;
2002
6395d57c 2003
b9a010a2 2004 drawing_clear(control_flow_data->drawing);
2005 processlist_clear(control_flow_data->process_list);
d9267eec 2006 redraw_notify(control_flow_data, NULL);
6395d57c 2007
d9267eec 2008 request_background_data(control_flow_data);
2009#if 0
2010 drawing->damage_begin = 0;
2011 drawing->damage_end = drawing->width;
6395d57c 2012 if(drawing->damage_begin < drawing->damage_end)
2013 {
2014 drawing_data_request(drawing,
2015 &drawing->pixmap,
2016 drawing->damage_begin,
2017 0,
2018 drawing->damage_end-drawing->damage_begin,
51705146 2019 drawing->height);
6395d57c 2020 }
2021
2022 gtk_widget_queue_draw_area(drawing->drawing_area,
2023 0,0,
2024 drawing->width,
2025 drawing->height);
d9267eec 2026#endif //0
6395d57c 2027
2028 return FALSE;
2029}
2030
ca0f8a8e 2031gint redraw_notify(void *hook_data, void *call_data)
2032{
2033 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2034 Drawing_t *drawing = control_flow_data->drawing;
2035 GtkWidget *widget = drawing->drawing_area;
2036
2037 drawing->damage_begin = 0;
51705146 2038 drawing->damage_end = drawing->width;
ca0f8a8e 2039
2040
2041 // Clear the image
2042 gdk_draw_rectangle (drawing->pixmap,
2043 widget->style->black_gc,
2044 TRUE,
2045 0, 0,
51705146 2046 drawing->width+SAFETY,
2047 drawing->height);
ca0f8a8e 2048
2049
2050 if(drawing->damage_begin < drawing->damage_end)
2051 {
2052 drawing_data_request(drawing,
2053 &drawing->pixmap,
2054 drawing->damage_begin,
2055 0,
2056 drawing->damage_end-drawing->damage_begin,
51705146 2057 drawing->height);
ca0f8a8e 2058 }
2059
2060 gtk_widget_queue_draw_area(drawing->drawing_area,
2061 0,0,
2062 drawing->width,
2063 drawing->height);
2064
2065 return FALSE;
2066
2067}
2068
2069
2070gint continue_notify(void *hook_data, void *call_data)
a43d67ba 2071{
2072 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
ca0f8a8e 2073 Drawing_t *drawing = control_flow_data->drawing;
2074 GtkWidget *widget = drawing->drawing_area;
a43d67ba 2075
6395d57c 2076 //g_assert(widget->allocation.width == drawing->damage_end);
ca0f8a8e 2077
2078 if(drawing->damage_begin < drawing->damage_end)
2079 {
2080 drawing_data_request(drawing,
2081 &drawing->pixmap,
2082 drawing->damage_begin,
2083 0,
2084 drawing->damage_end-drawing->damage_begin,
51705146 2085 drawing->height);
ca0f8a8e 2086 }
2087
2088 return FALSE;
2089}
2090
2091
1b238973 2092gint update_current_time_hook(void *hook_data, void *call_data)
f7afe191 2093{
14963be0 2094 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
a43d67ba 2095 Drawing_t *drawing = control_flow_data->drawing;
a56a1ba4 2096
224446ce 2097 LttTime current_time = *((LttTime*)call_data);
a56a1ba4 2098
ca0f8a8e 2099 TimeWindow time_window =
2100 lttvwindow_get_time_window(control_flow_data->tab);
a56a1ba4 2101
ca0f8a8e 2102 LttTime time_begin = time_window.start_time;
2103 LttTime width = time_window.time_width;
a56a1ba4 2104 LttTime half_width = ltt_time_div(width,2.0);
2105 LttTime time_end = ltt_time_add(time_begin, width);
2106
2107 LttvTracesetContext * tsc =
ca0f8a8e 2108 lttvwindow_get_traceset_context(control_flow_data->tab);
a56a1ba4 2109
ca0f8a8e 2110 LttTime trace_start = tsc->time_span.start_time;
2111 LttTime trace_end = tsc->time_span.end_time;
a56a1ba4 2112
224446ce 2113 g_info("New current time HOOK : %u, %u", current_time.tv_sec,
2114 current_time.tv_nsec);
a56a1ba4 2115
2116
2117
2118 /* If current time is inside time interval, just move the highlight
2119 * bar */
2120
2121 /* Else, we have to change the time interval. We have to tell it
2122 * to the main window. */
2123 /* The time interval change will take care of placing the current
2124 * time at the center of the visible area, or nearest possible if we are
2125 * at one end of the trace. */
2126
2127
224446ce 2128 if(ltt_time_compare(current_time, time_begin) == -1)
a56a1ba4 2129 {
224446ce 2130 TimeWindow new_time_window;
2131
2132 if(ltt_time_compare(current_time,
a56a1ba4 2133 ltt_time_add(trace_start,half_width)) == -1)
2134 time_begin = trace_start;
2135 else
224446ce 2136 time_begin = ltt_time_sub(current_time,half_width);
a56a1ba4 2137
224446ce 2138 new_time_window.start_time = time_begin;
2139 new_time_window.time_width = width;
a56a1ba4 2140
e800cf84 2141 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
a56a1ba4 2142 }
224446ce 2143 else if(ltt_time_compare(current_time, time_end) == 1)
a56a1ba4 2144 {
224446ce 2145 TimeWindow new_time_window;
2146
2147 if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) == 1)
a56a1ba4 2148 time_begin = ltt_time_sub(trace_end,width);
2149 else
224446ce 2150 time_begin = ltt_time_sub(current_time,half_width);
a56a1ba4 2151
224446ce 2152 new_time_window.start_time = time_begin;
2153 new_time_window.time_width = width;
a56a1ba4 2154
e800cf84 2155 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
a56a1ba4 2156
2157 }
a43d67ba 2158 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2159 gtk_widget_queue_draw_area(drawing->drawing_area,
2160 0,0,
2161 drawing->width,
2162 drawing->height);
a56a1ba4 2163
2164 return 0;
f7afe191 2165}
2166
8b90e648 2167typedef struct _ClosureData {
ca0f8a8e 2168 EventsRequest *events_request;
d0cd7f09 2169 LttvTracesetState *tss;
b9a010a2 2170 LttTime end_time;
8b90e648 2171} ClosureData;
a56a1ba4 2172
8b90e648 2173
e800cf84 2174void draw_closure(gpointer key, gpointer value, gpointer user_data)
2175{
a56a1ba4 2176 ProcessInfo *process_info = (ProcessInfo*)key;
2177 HashedProcessData *hashed_process_data = (HashedProcessData*)value;
2178 ClosureData *closure_data = (ClosureData*)user_data;
2179
e800cf84 2180 EventsRequest *events_request = closure_data->events_request;
2181 ControlFlowData *control_flow_data = events_request->viewer_data;
2182 Drawing_t *drawing = control_flow_data->drawing;
a56a1ba4 2183
e800cf84 2184 LttvTracesetState *tss = closure_data->tss;
2185 LttvTracesetContext *tsc = (LttvTracesetContext*)closure_data->tss;
a56a1ba4 2186
e800cf84 2187 LttTime evtime = closure_data->end_time;
2188 TimeWindow time_window =
2189 lttvwindow_get_time_window(control_flow_data->tab);
ca0f8a8e 2190
e800cf84 2191 LttTime end_time = ltt_time_add(time_window.start_time,
2192 time_window.time_width);
ca0f8a8e 2193
e800cf84 2194 if(ltt_time_compare(evtime, time_window.start_time) == -1
2195 || ltt_time_compare(evtime, end_time) == 1)
2196 return;
ca0f8a8e 2197
e800cf84 2198 guint width = drawing->width;
d0cd7f09 2199
e800cf84 2200 {
2201 /* For the process */
2202 /* First, check if the current process is in the state computation
2203 * process list. If it is there, that means we must add it right now and
2204 * draw items from the beginning of the read for it. If it is not
2205 * present, it's a new process and it was not present : it will
2206 * be added after the state update. */
2207 g_assert(lttv_traceset_number(tsc->ts) > 0);
d0cd7f09 2208
e025a729 2209 /* tracefiles[0] is ok here, because we draw for every PID, and
2210 * assume CPU 0 for PID 0 //FIXME */
2211 LttvTracefileState *tfs =
2212 (LttvTracefileState*)tsc->traces[process_info->trace_num]->tracefiles[0];
a56a1ba4 2213
e800cf84 2214 LttvProcessState *process;
e025a729 2215 process = lttv_state_find_process(tfs,
2216 process_info->pid);
a56a1ba4 2217
e800cf84 2218 if(process != NULL) {
2219
2220 /* Only draw for processes that are currently in the trace states */
ad2e83ba 2221
e800cf84 2222 guint y = 0, height = 0, pl_height = 0;
2223 ProcessList *process_list =
2224 guicontrolflow_get_process_list(control_flow_data);
2225 LttTime birth = process_info->birth;
2226
2227 /* Should be alike when background info is ready */
2228 if(control_flow_data->background_info_waiting==0)
2229 g_assert(ltt_time_compare(process->creation_time,
2230 process_info->birth) == 0);
2231 const gchar *name = g_quark_to_string(process->name);
2232
2233 /* process HAS to be present */
2234 g_assert(processlist_get_process_pixels(process_list,
2235 process_info->pid,
2236 &birth,
2237 process_info->trace_num,
2238 &y,
2239 &height,
2240 &hashed_process_data) != 1);
2241
2242 /* Now, the process is in the state hash and our own process hash.
2243 * We definitely can draw the items related to the ending state.
2244 */
2245
2246 /* Check if the x position is unset. In can have been left unset by
2247 * a draw closure from a after chunk hook. This should never happen,
2248 * because it must be set by before chunk hook to the damage_begin
2249 * value.
2250 */
2251 g_assert(hashed_process_data->x != -1);
2252 {
2253 guint x;
2254 DrawContext draw_context;
a56a1ba4 2255
e800cf84 2256 convert_time_to_pixels(
2257 time_window.start_time,
2258 end_time,
2259 evtime,
2260 width,
2261 &x);
8b90e648 2262
e800cf84 2263 /* Now create the drawing context that will be used to draw
2264 * items related to the last state. */
2265 draw_context.drawable = drawing->pixmap;
2266 draw_context.gc = drawing->gc;
2267 draw_context.pango_layout = drawing->pango_layout;
2268 draw_context.drawinfo.start.x = hashed_process_data->x;
2269 draw_context.drawinfo.end.x = x;
2270
2271 draw_context.drawinfo.y.over = y;
2272 draw_context.drawinfo.y.middle = y+(height/4);
2273 draw_context.drawinfo.y.under = y+(height/2)+2;
2274
2275 draw_context.drawinfo.start.offset.over = 0;
2276 draw_context.drawinfo.start.offset.middle = 0;
2277 draw_context.drawinfo.start.offset.under = 0;
2278 draw_context.drawinfo.end.offset.over = 0;
2279 draw_context.drawinfo.end.offset.middle = 0;
2280 draw_context.drawinfo.end.offset.under = 0;
2281
2282 {
2283 /* Draw the line */
2284 PropertiesLine prop_line = prepare_line(process);
2285 draw_line((void*)&prop_line, (void*)&draw_context);
2286
2287 }
2288
2289 /* special case LTTV_STATE_WAIT : CPU is unknown. */
2290
2291 /* become the last x position */
2292 hashed_process_data->x = x;
2293 }
2294 }
2295 }
2296 return;
8b90e648 2297}
2298
b9a010a2 2299int before_chunk(void *hook_data, void *call_data)
2300{
2301 EventsRequest *events_request = (EventsRequest*)hook_data;
2302 LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
2303
2304 drawing_chunk_begin(events_request, tss);
2305
2306 return 0;
2307}
2308
2309int before_request(void *hook_data, void *call_data)
ca0f8a8e 2310{
2311 EventsRequest *events_request = (EventsRequest*)hook_data;
2312 LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
2313
2314 drawing_data_request_begin(events_request, tss);
2315
2316 return 0;
2317}
2318
2319
8b90e648 2320/*
b9a010a2 2321 * after request is necessary in addition of after chunk in order to draw
2322 * lines until the end of the screen. after chunk just draws lines until
2323 * the last event.
2324 *
8b90e648 2325 * for each process
a56a1ba4 2326 * draw closing line
b9a010a2 2327 * expose
8b90e648 2328 */
b9a010a2 2329int after_request(void *hook_data, void *call_data)
8b90e648 2330{
ca0f8a8e 2331 EventsRequest *events_request = (EventsRequest*)hook_data;
2332 ControlFlowData *control_flow_data = events_request->viewer_data;
2333 LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
b9a010a2 2334 LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(call_data);
a56a1ba4 2335
2336 ProcessList *process_list =
ca0f8a8e 2337 guicontrolflow_get_process_list(control_flow_data);
b9a010a2 2338 LttTime end_time = events_request->end_time;
2339
2340 ClosureData closure_data;
2341 closure_data.events_request = (EventsRequest*)hook_data;
2342 closure_data.tss = tss;
2343 closure_data.end_time = end_time;
2344
2345 /* Draw last items */
2346 g_hash_table_foreach(process_list->process_hash, draw_closure,
2347 (void*)&closure_data);
2348
2349 /* Request expose */
2350 drawing_request_expose(events_request, tss, end_time);
2351 return 0;
2352}
2353
2354/*
2355 * for each process
2356 * draw closing line
e800cf84 2357 * expose
b9a010a2 2358 */
2359int after_chunk(void *hook_data, void *call_data)
2360{
2361 EventsRequest *events_request = (EventsRequest*)hook_data;
2362 ControlFlowData *control_flow_data = events_request->viewer_data;
2363 LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data);
2364 LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(call_data);
2365 LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
2366 LttTime end_time;
2367
2368 ProcessList *process_list =
2369 guicontrolflow_get_process_list(control_flow_data);
2370
e800cf84 2371 if(tfc != NULL)
2372 end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
0c5dbe3b 2373 else /* end of traceset, or position now out of request : end */
2374 end_time = events_request->end_time;
2375
a56a1ba4 2376 ClosureData closure_data;
ca0f8a8e 2377 closure_data.events_request = (EventsRequest*)hook_data;
2378 closure_data.tss = tss;
b9a010a2 2379 closure_data.end_time = end_time;
a56a1ba4 2380
b9a010a2 2381 /* Draw last items */
14963be0 2382 g_hash_table_foreach(process_list->process_hash, draw_closure,
a56a1ba4 2383 (void*)&closure_data);
a43d67ba 2384
ca0f8a8e 2385 /* Request expose */
b9a010a2 2386 drawing_request_expose(events_request, tss, end_time);
ca0f8a8e 2387
2388 return 0;
8b90e648 2389}
2390
This page took 0.145083 seconds and 4 git commands to generate.