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