eb86a20f171e35958c75a2d70fde376cc566ea9d
[lttv.git] / lttv / modules / gui / controlflow / eventhooks.c
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19
20 /*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
23
24
25 /* 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 : before_schedchange and after_schedchange hooks. The
29 * before_schedchange is called before the state update that occurs with an event and
30 * the after_schedchange hook is called after this state update.
31 *
32 * The before_schedchange hooks fulfill the task of drawing the visible objects that
33 * corresponds to the data accumulated by the after_schedchange hook.
34 *
35 * The after_schedchange hook accumulates the data that need to be shown on the screen
36 * (items) into a queue. Then, the next before_schedchange 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 before_schedchange
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 #ifdef HAVE_CONFIG_H
49 #include <config.h>
50 #endif
51
52 //#define PANGO_ENABLE_BACKEND
53 #include <gtk/gtk.h>
54 #include <gdk/gdk.h>
55 #include <glib.h>
56 #include <assert.h>
57 #include <string.h>
58 #include <stdio.h>
59
60 //#include <pango/pango.h>
61
62 #include <ltt/event.h>
63 #include <ltt/time.h>
64 #include <ltt/trace.h>
65
66 #include <lttv/lttv.h>
67 #include <lttv/hook.h>
68 #include <lttv/state.h>
69 #include <lttvwindow/lttvwindow.h>
70 #include <lttvwindow/lttvwindowtraces.h>
71 #include <lttvwindow/support.h>
72
73
74 #include "eventhooks.h"
75 #include "cfv.h"
76 #include "processlist.h"
77 #include "drawing.h"
78
79
80 #define MAX_PATH_LEN 256
81 #define STATE_LINE_WIDTH 6
82 #define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3)
83
84 extern GSList *g_legend_list;
85
86
87 /* Action to do when background computation completed.
88 *
89 * Wait for all the awaited computations to be over.
90 */
91
92 static gint background_ready(void *hook_data, void *call_data)
93 {
94 ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
95
96 control_flow_data->background_info_waiting--;
97
98 if(control_flow_data->background_info_waiting == 0) {
99 g_message("control flow viewer : background computation data ready.");
100
101 drawing_clear(control_flow_data->drawing);
102 processlist_clear(control_flow_data->process_list);
103 gtk_widget_set_size_request(
104 control_flow_data->drawing->drawing_area,
105 -1, processlist_get_height(control_flow_data->process_list));
106 redraw_notify(control_flow_data, NULL);
107 }
108
109 return 0;
110 }
111
112
113 /* Request background computation. Verify if it is in progress or ready first.
114 * Only for each trace in the tab's traceset.
115 */
116 static void request_background_data(ControlFlowData *control_flow_data)
117 {
118 LttvTracesetContext * tsc =
119 lttvwindow_get_traceset_context(control_flow_data->tab);
120 gint num_traces = lttv_traceset_number(tsc->ts);
121 gint i;
122 LttvTrace *trace;
123 LttvTraceState *tstate;
124
125 LttvHooks *background_ready_hook =
126 lttv_hooks_new();
127 lttv_hooks_add(background_ready_hook, background_ready, control_flow_data,
128 LTTV_PRIO_DEFAULT);
129 control_flow_data->background_info_waiting = 0;
130
131 for(i=0;i<num_traces;i++) {
132 trace = lttv_traceset_get(tsc->ts, i);
133 tstate = LTTV_TRACE_STATE(tsc->traces[i]);
134
135 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE
136 && !tstate->has_precomputed_states) {
137
138 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
139 trace) == FALSE) {
140 /* We first remove requests that could have been done for the same
141 * information. Happens when two viewers ask for it before servicing
142 * starts.
143 */
144 if(!lttvwindowtraces_background_request_find(trace, "state"))
145 lttvwindowtraces_background_request_queue(
146 main_window_get_widget(control_flow_data->tab), trace, "state");
147 lttvwindowtraces_background_notify_queue(control_flow_data,
148 trace,
149 ltt_time_infinite,
150 NULL,
151 background_ready_hook);
152 control_flow_data->background_info_waiting++;
153 } else { /* in progress */
154
155 lttvwindowtraces_background_notify_current(control_flow_data,
156 trace,
157 ltt_time_infinite,
158 NULL,
159 background_ready_hook);
160 control_flow_data->background_info_waiting++;
161 }
162 } else {
163 /* Data ready. By its nature, this viewer doesn't need to have
164 * its data ready hook called there, because a background
165 * request is always linked with a redraw.
166 */
167 }
168
169 }
170
171 lttv_hooks_destroy(background_ready_hook);
172 }
173
174
175
176
177 /**
178 * Event Viewer's constructor hook
179 *
180 * This constructor is given as a parameter to the menuitem and toolbar button
181 * registration. It creates the list.
182 * @param tab A pointer to the parent tab.
183 * @return The widget created.
184 */
185 GtkWidget *
186 h_guicontrolflow(LttvPlugin *plugin)
187 {
188 LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin);
189 Tab *tab = ptab->tab;
190 g_info("h_guicontrolflow, %p", tab);
191 ControlFlowData *control_flow_data = guicontrolflow(ptab);
192
193 control_flow_data->tab = tab;
194
195 // Unreg done in the GuiControlFlow_Destructor
196 lttvwindow_register_traceset_notify(tab,
197 traceset_notify,
198 control_flow_data);
199
200 lttvwindow_register_time_window_notify(tab,
201 update_time_window_hook,
202 control_flow_data);
203 lttvwindow_register_current_time_notify(tab,
204 update_current_time_hook,
205 control_flow_data);
206 lttvwindow_register_redraw_notify(tab,
207 redraw_notify,
208 control_flow_data);
209 lttvwindow_register_continue_notify(tab,
210 continue_notify,
211 control_flow_data);
212 request_background_data(control_flow_data);
213
214
215 return guicontrolflow_get_widget(control_flow_data) ;
216
217 }
218
219 int event_selected_hook(void *hook_data, void *call_data)
220 {
221 guint *event_number = (guint*) call_data;
222
223 g_debug("DEBUG : event selected by main window : %u", *event_number);
224
225 return 0;
226 }
227
228 /* Function that selects the color of status&exemode line */
229 static inline PropertiesLine prepare_s_e_line(LttvProcessState *process)
230 {
231 PropertiesLine prop_line;
232 prop_line.line_width = STATE_LINE_WIDTH;
233 prop_line.style = GDK_LINE_SOLID;
234 prop_line.y = MIDDLE;
235 //GdkColormap *colormap = gdk_colormap_get_system();
236
237 if(process->state->s == LTTV_STATE_RUN) {
238 if(process->state->t == LTTV_STATE_USER_MODE)
239 prop_line.color = drawing_colors[COL_RUN_USER_MODE];
240 else if(process->state->t == LTTV_STATE_SYSCALL)
241 prop_line.color = drawing_colors[COL_RUN_SYSCALL];
242 else if(process->state->t == LTTV_STATE_TRAP)
243 prop_line.color = drawing_colors[COL_RUN_TRAP];
244 else if(process->state->t == LTTV_STATE_IRQ)
245 prop_line.color = drawing_colors[COL_RUN_IRQ];
246 else if(process->state->t == LTTV_STATE_SOFT_IRQ)
247 prop_line.color = drawing_colors[COL_RUN_SOFT_IRQ];
248 else if(process->state->t == LTTV_STATE_MAYBE_SYSCALL)
249 prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
250 else if(process->state->t == LTTV_STATE_MAYBE_USER_MODE)
251 prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
252 else if(process->state->t == LTTV_STATE_MAYBE_TRAP)
253 prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
254 else if(process->state->t == LTTV_STATE_MODE_UNKNOWN)
255 prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
256 else
257 g_assert(FALSE); /* RUNNING MODE UNKNOWN */
258 } else if(process->state->s == LTTV_STATE_WAIT) {
259 /* We don't show if we wait while in user mode, trap, irq or syscall */
260 prop_line.color = drawing_colors[COL_WAIT];
261 } else if(process->state->s == LTTV_STATE_WAIT_CPU) {
262 /* We don't show if we wait for CPU while in user mode, trap, irq
263 * or syscall */
264 prop_line.color = drawing_colors[COL_WAIT_CPU];
265 } else if(process->state->s == LTTV_STATE_ZOMBIE) {
266 prop_line.color = drawing_colors[COL_ZOMBIE];
267 } else if(process->state->s == LTTV_STATE_WAIT_FORK) {
268 prop_line.color = drawing_colors[COL_WAIT_FORK];
269 } else if(process->state->s == LTTV_STATE_EXIT) {
270 prop_line.color = drawing_colors[COL_EXIT];
271 } else if(process->state->s == LTTV_STATE_UNNAMED) {
272 prop_line.color = drawing_colors[COL_UNNAMED];
273 } else if(process->state->s == LTTV_STATE_DEAD) {
274 prop_line.color = drawing_colors[COL_DEAD];
275 } else {
276 g_critical("unknown state : %s", g_quark_to_string(process->state->s));
277 g_assert(FALSE); /* UNKNOWN STATE */
278 }
279
280 return prop_line;
281
282 }
283
284 /* Before try-wake-up hook. A process is being woken; we need to draw its line up to this point in time
285 in that colour. This is basically like exec-state, but the change applies to a process other than that
286 which is currently running. */
287
288 int before_trywakeup_hook(void *hook_data, void *call_data)
289 {
290 LttvTraceHook *th = (LttvTraceHook*)hook_data;
291 EventsRequest *events_request = (EventsRequest*)th->hook_data;
292 ControlFlowData *control_flow_data = events_request->viewer_data;
293
294 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
295
296 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
297
298 LttEvent *e = ltt_tracefile_get_event(tfc->tf);
299 gint target_pid_saved = tfc->target_pid;
300
301 LttTime evtime = ltt_event_time(e);
302 LttvFilter *filter = control_flow_data->filter;
303
304 guint woken_pid;
305 gint woken_cpu;
306
307 woken_pid = ltt_event_get_int(e, lttv_trace_get_hook_field(th, 0));
308 woken_cpu = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 1));
309
310 tfc->target_pid = woken_pid;
311 if(!filter || !filter->head ||
312 lttv_filter_tree_parse(filter->head,e,tfc->tf,
313 tfc->t_context->t,tfc,NULL,NULL)) {
314
315 /* First, check if the woken process is in the state computation
316 * process list. If it is there, that means we must add it right now and
317 * draw items from the beginning of the read for it. If it is not
318 * present, it's a new process and it was not present : it will
319 * be added after the state update. TOCHECK: What does that last para mean? */
320 guint trace_num = ts->parent.index;
321 LttvProcessState *process = lttv_state_find_process(ts, woken_cpu, woken_pid);
322
323 if(process != NULL) {
324 /* Well, the woken process existed : we must get it in the process hash
325 * or add it, and draw its items.
326 */
327 /* Add process to process list (if not present) */
328 guint pl_height = 0;
329 HashedProcessData *hashed_process_data = NULL;
330 ProcessList *process_list = control_flow_data->process_list;
331 LttTime birth = process->creation_time;
332
333 hashed_process_data = processlist_get_process_data(process_list,
334 woken_pid,
335 process->cpu,
336 &birth,
337 trace_num);
338 if(hashed_process_data == NULL)
339 {
340 g_assert(woken_pid != process->ppid);
341 /* Process not present */
342 ProcessInfo *process_info;
343 Drawing_t *drawing = control_flow_data->drawing;
344 processlist_add(process_list,
345 drawing,
346 woken_pid,
347 process->tgid,
348 process->cpu,
349 process->ppid,
350 &birth,
351 trace_num,
352 process->name,
353 process->brand,
354 &pl_height,
355 &process_info,
356 &hashed_process_data);
357 gtk_widget_set_size_request(drawing->drawing_area,
358 -1,
359 pl_height);
360 gtk_widget_queue_draw(drawing->drawing_area);
361
362 }
363
364 /* Now, the process is in the state hash and our own process hash.
365 * We definitely can draw the items related to the ending state.
366 */
367
368 if(ltt_time_compare(hashed_process_data->next_good_time,
369 evtime) > 0)
370 {
371 if(hashed_process_data->x.middle_marked == FALSE) {
372
373 TimeWindow time_window =
374 lttvwindow_get_time_window(control_flow_data->tab);
375 #ifdef EXTRA_CHECK
376 if(ltt_time_compare(evtime, time_window.start_time) == -1
377 || ltt_time_compare(evtime, time_window.end_time) == 1)
378 return FALSE;
379 #endif //EXTRA_CHECK
380 Drawing_t *drawing = control_flow_data->drawing;
381 guint width = drawing->width;
382 guint x;
383 convert_time_to_pixels(
384 time_window,
385 evtime,
386 width,
387 &x);
388
389 /* Draw collision indicator */
390 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
391 gdk_draw_point(hashed_process_data->pixmap,
392 drawing->gc,
393 x,
394 COLLISION_POSITION(hashed_process_data->height));
395 hashed_process_data->x.middle_marked = TRUE;
396 }
397 } else {
398 TimeWindow time_window =
399 lttvwindow_get_time_window(control_flow_data->tab);
400 #ifdef EXTRA_CHECK
401 if(ltt_time_compare(evtime, time_window.start_time) == -1
402 || ltt_time_compare(evtime, time_window.end_time) == 1)
403 return FALSE;
404 #endif //EXTRA_CHECK
405 Drawing_t *drawing = control_flow_data->drawing;
406 guint width = drawing->width;
407 guint x;
408 convert_time_to_pixels(
409 time_window,
410 evtime,
411 width,
412 &x);
413
414
415 /* Jump over draw if we are at the same x position */
416 if(x == hashed_process_data->x.middle &&
417 hashed_process_data->x.middle_used)
418 {
419 if(hashed_process_data->x.middle_marked == FALSE) {
420 /* Draw collision indicator */
421 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
422 gdk_draw_point(hashed_process_data->pixmap,
423 drawing->gc,
424 x,
425 COLLISION_POSITION(hashed_process_data->height));
426 hashed_process_data->x.middle_marked = TRUE;
427 }
428 /* jump */
429 } else {
430 DrawContext draw_context;
431
432 /* Now create the drawing context that will be used to draw
433 * items related to the last state. */
434 draw_context.drawable = hashed_process_data->pixmap;
435 draw_context.gc = drawing->gc;
436 draw_context.pango_layout = drawing->pango_layout;
437 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
438 draw_context.drawinfo.end.x = x;
439
440 draw_context.drawinfo.y.over = 1;
441 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
442 draw_context.drawinfo.y.under = hashed_process_data->height;
443
444 draw_context.drawinfo.start.offset.over = 0;
445 draw_context.drawinfo.start.offset.middle = 0;
446 draw_context.drawinfo.start.offset.under = 0;
447 draw_context.drawinfo.end.offset.over = 0;
448 draw_context.drawinfo.end.offset.middle = 0;
449 draw_context.drawinfo.end.offset.under = 0;
450
451 {
452 /* Draw the line */
453 PropertiesLine prop_line = prepare_s_e_line(process);
454 draw_line((void*)&prop_line, (void*)&draw_context);
455
456 }
457 /* become the last x position */
458 hashed_process_data->x.middle = x;
459 hashed_process_data->x.middle_used = TRUE;
460 hashed_process_data->x.middle_marked = FALSE;
461
462 /* Calculate the next good time */
463 convert_pixels_to_time(width, x+1, time_window,
464 &hashed_process_data->next_good_time);
465 }
466 }
467 }
468 }
469
470 tfc->target_pid = target_pid_saved;
471
472 return 0;
473
474 }
475
476 /* before_schedchange_hook
477 *
478 * This function basically draw lines and icons. Two types of lines are drawn :
479 * one small (3 pixels?) representing the state of the process and the second
480 * type is thicker (10 pixels?) representing on which CPU a process is running
481 * (and this only in running state).
482 *
483 * Extremums of the lines :
484 * x_min : time of the last event context for this process kept in memory.
485 * x_max : time of the current event.
486 * y : middle of the process in the process list. The process is found in the
487 * list, therefore is it's position in pixels.
488 *
489 * The choice of lines'color is defined by the context of the last event for this
490 * process.
491 */
492
493
494 int before_schedchange_hook(void *hook_data, void *call_data)
495 {
496 LttvTraceHook *th = (LttvTraceHook*)hook_data;
497 EventsRequest *events_request = (EventsRequest*)th->hook_data;
498 ControlFlowData *control_flow_data = events_request->viewer_data;
499
500 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
501
502 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
503 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
504
505 LttEvent *e;
506 e = ltt_tracefile_get_event(tfc->tf);
507 gint target_pid_saved = tfc->target_pid;
508
509 LttTime evtime = ltt_event_time(e);
510 LttvFilter *filter = control_flow_data->filter;
511
512 /* we are in a schedchange, before the state update. We must draw the
513 * items corresponding to the state before it changes : now is the right
514 * time to do it.
515 */
516
517 guint pid_out;
518 guint pid_in;
519 {
520 pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
521 pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
522 }
523
524 tfc->target_pid = pid_out;
525 if(!filter || !filter->head ||
526 lttv_filter_tree_parse(filter->head,e,tfc->tf,
527 tfc->t_context->t,tfc,NULL,NULL)) {
528 /* For the pid_out */
529 /* First, check if the current process is in the state computation
530 * process list. If it is there, that means we must add it right now and
531 * draw items from the beginning of the read for it. If it is not
532 * present, it's a new process and it was not present : it will
533 * be added after the state update. */
534 guint cpu = tfs->cpu;
535 guint trace_num = ts->parent.index;
536 LttvProcessState *process = ts->running_process[cpu];
537 /* unknown state, bad current pid */
538 if(process->pid != pid_out)
539 process = lttv_state_find_process(ts,
540 tfs->cpu, pid_out);
541
542 if(process != NULL) {
543 /* Well, the process_out existed : we must get it in the process hash
544 * or add it, and draw its items.
545 */
546 /* Add process to process list (if not present) */
547 guint pl_height = 0;
548 HashedProcessData *hashed_process_data = NULL;
549 ProcessList *process_list = control_flow_data->process_list;
550 LttTime birth = process->creation_time;
551
552 hashed_process_data = processlist_get_process_data(process_list,
553 pid_out,
554 process->cpu,
555 &birth,
556 trace_num);
557 if(hashed_process_data == NULL)
558 {
559 g_assert(pid_out == 0 || pid_out != process->ppid);
560 /* Process not present */
561 ProcessInfo *process_info;
562 Drawing_t *drawing = control_flow_data->drawing;
563 processlist_add(process_list,
564 drawing,
565 pid_out,
566 process->tgid,
567 process->cpu,
568 process->ppid,
569 &birth,
570 trace_num,
571 process->name,
572 process->brand,
573 &pl_height,
574 &process_info,
575 &hashed_process_data);
576 gtk_widget_set_size_request(drawing->drawing_area,
577 -1,
578 pl_height);
579 gtk_widget_queue_draw(drawing->drawing_area);
580
581 }
582
583 /* Now, the process is in the state hash and our own process hash.
584 * We definitely can draw the items related to the ending state.
585 */
586
587 if(ltt_time_compare(hashed_process_data->next_good_time,
588 evtime) > 0)
589 {
590 if(hashed_process_data->x.middle_marked == FALSE) {
591
592 TimeWindow time_window =
593 lttvwindow_get_time_window(control_flow_data->tab);
594 #ifdef EXTRA_CHECK
595 if(ltt_time_compare(evtime, time_window.start_time) == -1
596 || ltt_time_compare(evtime, time_window.end_time) == 1)
597 return FALSE;
598 #endif //EXTRA_CHECK
599 Drawing_t *drawing = control_flow_data->drawing;
600 guint width = drawing->width;
601 guint x;
602 convert_time_to_pixels(
603 time_window,
604 evtime,
605 width,
606 &x);
607
608 /* Draw collision indicator */
609 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
610 gdk_draw_point(hashed_process_data->pixmap,
611 drawing->gc,
612 x,
613 COLLISION_POSITION(hashed_process_data->height));
614 hashed_process_data->x.middle_marked = TRUE;
615 }
616 } else {
617 TimeWindow time_window =
618 lttvwindow_get_time_window(control_flow_data->tab);
619 #ifdef EXTRA_CHECK
620 if(ltt_time_compare(evtime, time_window.start_time) == -1
621 || ltt_time_compare(evtime, time_window.end_time) == 1)
622 return FALSE;
623 #endif //EXTRA_CHECK
624 Drawing_t *drawing = control_flow_data->drawing;
625 guint width = drawing->width;
626 guint x;
627 convert_time_to_pixels(
628 time_window,
629 evtime,
630 width,
631 &x);
632
633
634 /* Jump over draw if we are at the same x position */
635 if(x == hashed_process_data->x.middle &&
636 hashed_process_data->x.middle_used)
637 {
638 if(hashed_process_data->x.middle_marked == FALSE) {
639 /* Draw collision indicator */
640 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
641 gdk_draw_point(hashed_process_data->pixmap,
642 drawing->gc,
643 x,
644 COLLISION_POSITION(hashed_process_data->height));
645 hashed_process_data->x.middle_marked = TRUE;
646 }
647 /* jump */
648 } else {
649 DrawContext draw_context;
650
651 /* Now create the drawing context that will be used to draw
652 * items related to the last state. */
653 draw_context.drawable = hashed_process_data->pixmap;
654 draw_context.gc = drawing->gc;
655 draw_context.pango_layout = drawing->pango_layout;
656 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
657 draw_context.drawinfo.end.x = x;
658
659 draw_context.drawinfo.y.over = 1;
660 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
661 draw_context.drawinfo.y.under = hashed_process_data->height;
662
663 draw_context.drawinfo.start.offset.over = 0;
664 draw_context.drawinfo.start.offset.middle = 0;
665 draw_context.drawinfo.start.offset.under = 0;
666 draw_context.drawinfo.end.offset.over = 0;
667 draw_context.drawinfo.end.offset.middle = 0;
668 draw_context.drawinfo.end.offset.under = 0;
669
670 {
671 /* Draw the line */
672 PropertiesLine prop_line = prepare_s_e_line(process);
673 draw_line((void*)&prop_line, (void*)&draw_context);
674
675 }
676 /* become the last x position */
677 hashed_process_data->x.middle = x;
678 hashed_process_data->x.middle_used = TRUE;
679 hashed_process_data->x.middle_marked = FALSE;
680
681 /* Calculate the next good time */
682 convert_pixels_to_time(width, x+1, time_window,
683 &hashed_process_data->next_good_time);
684 }
685 }
686 }
687 }
688
689 tfc->target_pid = pid_in;
690 if(!filter || !filter->head ||
691 lttv_filter_tree_parse(filter->head,e,tfc->tf,
692 tfc->t_context->t,tfc,NULL,NULL)) {
693 /* For the pid_in */
694 /* First, check if the current process is in the state computation
695 * process list. If it is there, that means we must add it right now and
696 * draw items from the beginning of the read for it. If it is not
697 * present, it's a new process and it was not present : it will
698 * be added after the state update. */
699 LttvProcessState *process;
700 process = lttv_state_find_process(ts,
701 tfs->cpu, pid_in);
702 guint trace_num = ts->parent.index;
703
704 if(process != NULL) {
705 /* Well, the process existed : we must get it in the process hash
706 * or add it, and draw its items.
707 */
708 /* Add process to process list (if not present) */
709 guint pl_height = 0;
710 HashedProcessData *hashed_process_data = NULL;
711 ProcessList *process_list = control_flow_data->process_list;
712 LttTime birth = process->creation_time;
713
714 hashed_process_data = processlist_get_process_data(process_list,
715 pid_in,
716 tfs->cpu,
717 &birth,
718 trace_num);
719 if(hashed_process_data == NULL)
720 {
721 g_assert(pid_in == 0 || pid_in != process->ppid);
722 /* Process not present */
723 ProcessInfo *process_info;
724 Drawing_t *drawing = control_flow_data->drawing;
725 processlist_add(process_list,
726 drawing,
727 pid_in,
728 process->tgid,
729 tfs->cpu,
730 process->ppid,
731 &birth,
732 trace_num,
733 process->name,
734 process->brand,
735 &pl_height,
736 &process_info,
737 &hashed_process_data);
738 gtk_widget_set_size_request(drawing->drawing_area,
739 -1,
740 pl_height);
741 gtk_widget_queue_draw(drawing->drawing_area);
742
743 }
744 //We could set the current process and hash here, but will be done
745 //by after schedchange hook
746
747 /* Now, the process is in the state hash and our own process hash.
748 * We definitely can draw the items related to the ending state.
749 */
750
751 if(ltt_time_compare(hashed_process_data->next_good_time,
752 evtime) > 0)
753 {
754 if(hashed_process_data->x.middle_marked == FALSE) {
755
756 TimeWindow time_window =
757 lttvwindow_get_time_window(control_flow_data->tab);
758 #ifdef EXTRA_CHECK
759 if(ltt_time_compare(evtime, time_window.start_time) == -1
760 || ltt_time_compare(evtime, time_window.end_time) == 1)
761 return FALSE;
762 #endif //EXTRA_CHECK
763 Drawing_t *drawing = control_flow_data->drawing;
764 guint width = drawing->width;
765 guint x;
766 convert_time_to_pixels(
767 time_window,
768 evtime,
769 width,
770 &x);
771
772 /* Draw collision indicator */
773 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
774 gdk_draw_point(hashed_process_data->pixmap,
775 drawing->gc,
776 x,
777 COLLISION_POSITION(hashed_process_data->height));
778 hashed_process_data->x.middle_marked = TRUE;
779 }
780 } else {
781 TimeWindow time_window =
782 lttvwindow_get_time_window(control_flow_data->tab);
783 #ifdef EXTRA_CHECK
784 if(ltt_time_compare(evtime, time_window.start_time) == -1
785 || ltt_time_compare(evtime, time_window.end_time) == 1)
786 return FALSE;
787 #endif //EXTRA_CHECK
788 Drawing_t *drawing = control_flow_data->drawing;
789 guint width = drawing->width;
790 guint x;
791
792 convert_time_to_pixels(
793 time_window,
794 evtime,
795 width,
796 &x);
797
798
799 /* Jump over draw if we are at the same x position */
800 if(x == hashed_process_data->x.middle &&
801 hashed_process_data->x.middle_used)
802 {
803 if(hashed_process_data->x.middle_marked == FALSE) {
804 /* Draw collision indicator */
805 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
806 gdk_draw_point(hashed_process_data->pixmap,
807 drawing->gc,
808 x,
809 COLLISION_POSITION(hashed_process_data->height));
810 hashed_process_data->x.middle_marked = TRUE;
811 }
812 /* jump */
813 } else {
814 DrawContext draw_context;
815
816 /* Now create the drawing context that will be used to draw
817 * items related to the last state. */
818 draw_context.drawable = hashed_process_data->pixmap;
819 draw_context.gc = drawing->gc;
820 draw_context.pango_layout = drawing->pango_layout;
821 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
822 draw_context.drawinfo.end.x = x;
823
824 draw_context.drawinfo.y.over = 1;
825 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
826 draw_context.drawinfo.y.under = hashed_process_data->height;
827
828 draw_context.drawinfo.start.offset.over = 0;
829 draw_context.drawinfo.start.offset.middle = 0;
830 draw_context.drawinfo.start.offset.under = 0;
831 draw_context.drawinfo.end.offset.over = 0;
832 draw_context.drawinfo.end.offset.middle = 0;
833 draw_context.drawinfo.end.offset.under = 0;
834
835 {
836 /* Draw the line */
837 PropertiesLine prop_line = prepare_s_e_line(process);
838 draw_line((void*)&prop_line, (void*)&draw_context);
839 }
840
841
842 /* become the last x position */
843 hashed_process_data->x.middle = x;
844 hashed_process_data->x.middle_used = TRUE;
845 hashed_process_data->x.middle_marked = FALSE;
846
847 /* Calculate the next good time */
848 convert_pixels_to_time(width, x+1, time_window,
849 &hashed_process_data->next_good_time);
850 }
851 }
852 } else
853 g_warning("Cannot find pin_in in schedchange %u", pid_in);
854 }
855 tfc->target_pid = target_pid_saved;
856 return 0;
857
858
859
860
861 /* Text dump */
862 #ifdef DONTSHOW
863 GString *string = g_string_new("");;
864 gboolean field_names = TRUE, state = TRUE;
865
866 lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs);
867 g_string_append_printf(string,"\n");
868
869 if(state) {
870 g_string_append_printf(string, " %s",
871 g_quark_to_string(tfs->process->state->s));
872 }
873
874 g_info("%s",string->str);
875
876 g_string_free(string, TRUE);
877
878 /* End of text dump */
879 #endif //DONTSHOW
880
881 }
882
883 /* after_schedchange_hook
884 *
885 * The draw after hook is called by the reading API to have a
886 * particular event drawn on the screen.
887 * @param hook_data ControlFlowData structure of the viewer.
888 * @param call_data Event context.
889 *
890 * This function adds items to be drawn in a queue for each process.
891 *
892 */
893 int after_schedchange_hook(void *hook_data, void *call_data)
894 {
895 LttvTraceHook *th = (LttvTraceHook*)hook_data;
896 EventsRequest *events_request = (EventsRequest*)th->hook_data;
897 ControlFlowData *control_flow_data = events_request->viewer_data;
898
899 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
900
901 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
902
903 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
904
905 LttEvent *e;
906 e = ltt_tracefile_get_event(tfc->tf);
907
908 LttvFilter *filter = control_flow_data->filter;
909 LttTime evtime = ltt_event_time(e);
910
911 /* Add process to process list (if not present) */
912 LttvProcessState *process_in;
913 LttTime birth;
914 guint pl_height = 0;
915 HashedProcessData *hashed_process_data_in = NULL;
916
917 ProcessList *process_list = control_flow_data->process_list;
918
919 guint pid_in;
920 {
921 pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
922 }
923
924 tfc->target_pid = pid_in;
925 if(!filter || !filter->head ||
926 lttv_filter_tree_parse(filter->head,e,tfc->tf,
927 tfc->t_context->t,tfc,NULL,NULL)) {
928 /* Find process pid_in in the list... */
929 //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
930 //process_in = tfs->process;
931 guint cpu = tfs->cpu;
932 guint trace_num = ts->parent.index;
933 process_in = ts->running_process[cpu];
934 /* It should exist, because we are after the state update. */
935 #ifdef EXTRA_CHECK
936 g_assert(process_in != NULL);
937 #endif //EXTRA_CHECK
938 birth = process_in->creation_time;
939
940 hashed_process_data_in = processlist_get_process_data(process_list,
941 pid_in,
942 process_in->cpu,
943 &birth,
944 trace_num);
945 if(hashed_process_data_in == NULL)
946 {
947 g_assert(pid_in == 0 || pid_in != process_in->ppid);
948 ProcessInfo *process_info;
949 Drawing_t *drawing = control_flow_data->drawing;
950 /* Process not present */
951 processlist_add(process_list,
952 drawing,
953 pid_in,
954 process_in->tgid,
955 process_in->cpu,
956 process_in->ppid,
957 &birth,
958 trace_num,
959 process_in->name,
960 process_in->brand,
961 &pl_height,
962 &process_info,
963 &hashed_process_data_in);
964 gtk_widget_set_size_request(drawing->drawing_area,
965 -1,
966 pl_height);
967 gtk_widget_queue_draw(drawing->drawing_area);
968 }
969 /* Set the current process */
970 process_list->current_hash_data[trace_num][process_in->cpu] =
971 hashed_process_data_in;
972
973 if(ltt_time_compare(hashed_process_data_in->next_good_time,
974 evtime) <= 0)
975 {
976 TimeWindow time_window =
977 lttvwindow_get_time_window(control_flow_data->tab);
978
979 #ifdef EXTRA_CHECK
980 if(ltt_time_compare(evtime, time_window.start_time) == -1
981 || ltt_time_compare(evtime, time_window.end_time) == 1)
982 return FALSE;
983 #endif //EXTRA_CHECK
984 Drawing_t *drawing = control_flow_data->drawing;
985 guint width = drawing->width;
986 guint new_x;
987
988 convert_time_to_pixels(
989 time_window,
990 evtime,
991 width,
992 &new_x);
993
994 if(hashed_process_data_in->x.middle != new_x) {
995 hashed_process_data_in->x.middle = new_x;
996 hashed_process_data_in->x.middle_used = FALSE;
997 hashed_process_data_in->x.middle_marked = FALSE;
998 }
999 }
1000 }
1001
1002 return 0;
1003 }
1004
1005
1006
1007
1008 /* before_execmode_hook
1009 *
1010 * This function basically draw lines and icons. Two types of lines are drawn :
1011 * one small (3 pixels?) representing the state of the process and the second
1012 * type is thicker (10 pixels?) representing on which CPU a process is running
1013 * (and this only in running state).
1014 *
1015 * Extremums of the lines :
1016 * x_min : time of the last event context for this process kept in memory.
1017 * x_max : time of the current event.
1018 * y : middle of the process in the process list. The process is found in the
1019 * list, therefore is it's position in pixels.
1020 *
1021 * The choice of lines'color is defined by the context of the last event for this
1022 * process.
1023 */
1024
1025
1026 int before_execmode_hook(void *hook_data, void *call_data)
1027 {
1028 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1029 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1030 ControlFlowData *control_flow_data = events_request->viewer_data;
1031
1032 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1033
1034 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1035
1036 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1037
1038 LttEvent *e;
1039 e = ltt_tracefile_get_event(tfc->tf);
1040
1041 LttvFilter *filter = control_flow_data->filter;
1042 if(filter != NULL && filter->head != NULL)
1043 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1044 tfc->t_context->t,tfc,NULL,NULL))
1045 return FALSE;
1046
1047 LttTime evtime = ltt_event_time(e);
1048
1049 /* we are in a execmode, before the state update. We must draw the
1050 * items corresponding to the state before it changes : now is the right
1051 * time to do it.
1052 */
1053 /* For the pid */
1054 //LttvProcessState *process = tfs->process;
1055 guint cpu = tfs->cpu;
1056 guint trace_num = ts->parent.index;
1057 LttvProcessState *process = ts->running_process[cpu];
1058 g_assert(process != NULL);
1059
1060 guint pid = process->pid;
1061
1062 /* Well, the process_out existed : we must get it in the process hash
1063 * or add it, and draw its items.
1064 */
1065 /* Add process to process list (if not present) */
1066 guint pl_height = 0;
1067 HashedProcessData *hashed_process_data = NULL;
1068 ProcessList *process_list = control_flow_data->process_list;
1069 LttTime birth = process->creation_time;
1070
1071 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1072 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1073 } else {
1074 hashed_process_data = processlist_get_process_data(process_list,
1075 pid,
1076 process->cpu,
1077 &birth,
1078 trace_num);
1079 if(unlikely(hashed_process_data == NULL))
1080 {
1081 g_assert(pid == 0 || pid != process->ppid);
1082 ProcessInfo *process_info;
1083 /* Process not present */
1084 Drawing_t *drawing = control_flow_data->drawing;
1085 processlist_add(process_list,
1086 drawing,
1087 pid,
1088 process->tgid,
1089 process->cpu,
1090 process->ppid,
1091 &birth,
1092 trace_num,
1093 process->name,
1094 process->brand,
1095 &pl_height,
1096 &process_info,
1097 &hashed_process_data);
1098 gtk_widget_set_size_request(drawing->drawing_area,
1099 -1,
1100 pl_height);
1101 gtk_widget_queue_draw(drawing->drawing_area);
1102 }
1103 /* Set the current process */
1104 process_list->current_hash_data[trace_num][process->cpu] =
1105 hashed_process_data;
1106 }
1107
1108 /* Now, the process is in the state hash and our own process hash.
1109 * We definitely can draw the items related to the ending state.
1110 */
1111
1112 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1113 evtime) > 0))
1114 {
1115 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1116 TimeWindow time_window =
1117 lttvwindow_get_time_window(control_flow_data->tab);
1118
1119 #ifdef EXTRA_CHECK
1120 if(ltt_time_compare(evtime, time_window.start_time) == -1
1121 || ltt_time_compare(evtime, time_window.end_time) == 1)
1122 return FALSE;
1123 #endif //EXTRA_CHECK
1124 Drawing_t *drawing = control_flow_data->drawing;
1125 guint width = drawing->width;
1126 guint x;
1127 convert_time_to_pixels(
1128 time_window,
1129 evtime,
1130 width,
1131 &x);
1132
1133 /* Draw collision indicator */
1134 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1135 gdk_draw_point(hashed_process_data->pixmap,
1136 drawing->gc,
1137 x,
1138 COLLISION_POSITION(hashed_process_data->height));
1139 hashed_process_data->x.middle_marked = TRUE;
1140 }
1141 } else {
1142 TimeWindow time_window =
1143 lttvwindow_get_time_window(control_flow_data->tab);
1144
1145 #ifdef EXTRA_CHECK
1146 if(ltt_time_compare(evtime, time_window.start_time) == -1
1147 || ltt_time_compare(evtime, time_window.end_time) == 1)
1148 return FALSE;
1149 #endif //EXTRA_CHECK
1150 Drawing_t *drawing = control_flow_data->drawing;
1151 guint width = drawing->width;
1152 guint x;
1153
1154 convert_time_to_pixels(
1155 time_window,
1156 evtime,
1157 width,
1158 &x);
1159
1160
1161 /* Jump over draw if we are at the same x position */
1162 if(unlikely(x == hashed_process_data->x.middle &&
1163 hashed_process_data->x.middle_used))
1164 {
1165 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1166 /* Draw collision indicator */
1167 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1168 gdk_draw_point(hashed_process_data->pixmap,
1169 drawing->gc,
1170 x,
1171 COLLISION_POSITION(hashed_process_data->height));
1172 hashed_process_data->x.middle_marked = TRUE;
1173 }
1174 /* jump */
1175 } else {
1176
1177 DrawContext draw_context;
1178 /* Now create the drawing context that will be used to draw
1179 * items related to the last state. */
1180 draw_context.drawable = hashed_process_data->pixmap;
1181 draw_context.gc = drawing->gc;
1182 draw_context.pango_layout = drawing->pango_layout;
1183 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1184 draw_context.drawinfo.end.x = x;
1185
1186 draw_context.drawinfo.y.over = 1;
1187 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1188 draw_context.drawinfo.y.under = hashed_process_data->height;
1189
1190 draw_context.drawinfo.start.offset.over = 0;
1191 draw_context.drawinfo.start.offset.middle = 0;
1192 draw_context.drawinfo.start.offset.under = 0;
1193 draw_context.drawinfo.end.offset.over = 0;
1194 draw_context.drawinfo.end.offset.middle = 0;
1195 draw_context.drawinfo.end.offset.under = 0;
1196
1197 {
1198 /* Draw the line */
1199 PropertiesLine prop_line = prepare_s_e_line(process);
1200 draw_line((void*)&prop_line, (void*)&draw_context);
1201
1202 }
1203 /* become the last x position */
1204 hashed_process_data->x.middle = x;
1205 hashed_process_data->x.middle_used = TRUE;
1206 hashed_process_data->x.middle_marked = FALSE;
1207
1208 /* Calculate the next good time */
1209 convert_pixels_to_time(width, x+1, time_window,
1210 &hashed_process_data->next_good_time);
1211 }
1212 }
1213
1214 return 0;
1215 }
1216
1217 /* before_process_exit_hook
1218 *
1219 * Draw lines for process event.
1220 *
1221 * @param hook_data ControlFlowData structure of the viewer.
1222 * @param call_data Event context.
1223 *
1224 * This function adds items to be drawn in a queue for each process.
1225 *
1226 */
1227
1228
1229 int before_process_exit_hook(void *hook_data, void *call_data)
1230 {
1231 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1232 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1233
1234 ControlFlowData *control_flow_data = events_request->viewer_data;
1235
1236 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1237
1238 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1239
1240 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1241
1242 LttEvent *e;
1243 e = ltt_tracefile_get_event(tfc->tf);
1244
1245 LttvFilter *filter = control_flow_data->filter;
1246 if(filter != NULL && filter->head != NULL)
1247 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1248 tfc->t_context->t,tfc,NULL,NULL))
1249 return FALSE;
1250
1251 LttTime evtime = ltt_event_time(e);
1252
1253 /* Add process to process list (if not present) */
1254 //LttvProcessState *process = tfs->process;
1255 guint cpu = tfs->cpu;
1256 guint trace_num = ts->parent.index;
1257 LttvProcessState *process = ts->running_process[cpu];
1258 guint pid = process->pid;
1259 LttTime birth;
1260 guint pl_height = 0;
1261 HashedProcessData *hashed_process_data = NULL;
1262
1263 ProcessList *process_list = control_flow_data->process_list;
1264
1265 g_assert(process != NULL);
1266
1267 birth = process->creation_time;
1268
1269 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1270 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1271 } else {
1272 hashed_process_data = processlist_get_process_data(process_list,
1273 pid,
1274 process->cpu,
1275 &birth,
1276 trace_num);
1277 if(unlikely(hashed_process_data == NULL))
1278 {
1279 g_assert(pid == 0 || pid != process->ppid);
1280 /* Process not present */
1281 Drawing_t *drawing = control_flow_data->drawing;
1282 ProcessInfo *process_info;
1283 processlist_add(process_list,
1284 drawing,
1285 pid,
1286 process->tgid,
1287 process->cpu,
1288 process->ppid,
1289 &birth,
1290 trace_num,
1291 process->name,
1292 process->brand,
1293 &pl_height,
1294 &process_info,
1295 &hashed_process_data);
1296 gtk_widget_set_size_request(drawing->drawing_area,
1297 -1,
1298 pl_height);
1299 gtk_widget_queue_draw(drawing->drawing_area);
1300 }
1301 }
1302
1303 /* Now, the process is in the state hash and our own process hash.
1304 * We definitely can draw the items related to the ending state.
1305 */
1306
1307 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1308 evtime) > 0))
1309 {
1310 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1311 TimeWindow time_window =
1312 lttvwindow_get_time_window(control_flow_data->tab);
1313
1314 #ifdef EXTRA_CHECK
1315 if(ltt_time_compare(evtime, time_window.start_time) == -1
1316 || ltt_time_compare(evtime, time_window.end_time) == 1)
1317 return FALSE;
1318 #endif //EXTRA_CHECK
1319 Drawing_t *drawing = control_flow_data->drawing;
1320 guint width = drawing->width;
1321 guint x;
1322 convert_time_to_pixels(
1323 time_window,
1324 evtime,
1325 width,
1326 &x);
1327
1328 /* Draw collision indicator */
1329 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1330 gdk_draw_point(hashed_process_data->pixmap,
1331 drawing->gc,
1332 x,
1333 COLLISION_POSITION(hashed_process_data->height));
1334 hashed_process_data->x.middle_marked = TRUE;
1335 }
1336 } else {
1337 TimeWindow time_window =
1338 lttvwindow_get_time_window(control_flow_data->tab);
1339
1340 #ifdef EXTRA_CHECK
1341 if(ltt_time_compare(evtime, time_window.start_time) == -1
1342 || ltt_time_compare(evtime, time_window.end_time) == 1)
1343 return FALSE;
1344 #endif //EXTRA_CHECK
1345 Drawing_t *drawing = control_flow_data->drawing;
1346 guint width = drawing->width;
1347 guint x;
1348
1349 convert_time_to_pixels(
1350 time_window,
1351 evtime,
1352 width,
1353 &x);
1354
1355
1356 /* Jump over draw if we are at the same x position */
1357 if(unlikely(x == hashed_process_data->x.middle &&
1358 hashed_process_data->x.middle_used))
1359 {
1360 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1361 /* Draw collision indicator */
1362 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1363 gdk_draw_point(hashed_process_data->pixmap,
1364 drawing->gc,
1365 x,
1366 COLLISION_POSITION(hashed_process_data->height));
1367 hashed_process_data->x.middle_marked = TRUE;
1368 }
1369 /* jump */
1370 } else {
1371 DrawContext draw_context;
1372
1373 /* Now create the drawing context that will be used to draw
1374 * items related to the last state. */
1375 draw_context.drawable = hashed_process_data->pixmap;
1376 draw_context.gc = drawing->gc;
1377 draw_context.pango_layout = drawing->pango_layout;
1378 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1379 draw_context.drawinfo.end.x = x;
1380
1381 draw_context.drawinfo.y.over = 1;
1382 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1383 draw_context.drawinfo.y.under = hashed_process_data->height;
1384
1385 draw_context.drawinfo.start.offset.over = 0;
1386 draw_context.drawinfo.start.offset.middle = 0;
1387 draw_context.drawinfo.start.offset.under = 0;
1388 draw_context.drawinfo.end.offset.over = 0;
1389 draw_context.drawinfo.end.offset.middle = 0;
1390 draw_context.drawinfo.end.offset.under = 0;
1391
1392 {
1393 /* Draw the line */
1394 PropertiesLine prop_line = prepare_s_e_line(process);
1395 draw_line((void*)&prop_line, (void*)&draw_context);
1396
1397 }
1398 /* become the last x position */
1399 hashed_process_data->x.middle = x;
1400 hashed_process_data->x.middle_used = TRUE;
1401 hashed_process_data->x.middle_marked = FALSE;
1402
1403 /* Calculate the next good time */
1404 convert_pixels_to_time(width, x+1, time_window,
1405 &hashed_process_data->next_good_time);
1406 }
1407 }
1408
1409 return 0;
1410
1411 }
1412
1413
1414
1415 /* before_process_release_hook
1416 *
1417 * Draw lines for process event.
1418 *
1419 * @param hook_data ControlFlowData structure of the viewer.
1420 * @param call_data Event context.
1421 *
1422 * This function adds items to be drawn in a queue for each process.
1423 *
1424 */
1425
1426
1427 int before_process_release_hook(void *hook_data, void *call_data)
1428 {
1429 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1430 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1431
1432 ControlFlowData *control_flow_data = events_request->viewer_data;
1433
1434 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1435
1436 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1437
1438 LttEvent *e;
1439 e = ltt_tracefile_get_event(tfc->tf);
1440
1441 LttvFilter *filter = control_flow_data->filter;
1442 if(filter != NULL && filter->head != NULL)
1443 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1444 tfc->t_context->t,tfc,NULL,NULL))
1445 return FALSE;
1446
1447 LttTime evtime = ltt_event_time(e);
1448
1449 guint trace_num = ts->parent.index;
1450
1451 guint pid;
1452 {
1453 pid = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
1454 }
1455
1456 /* Add process to process list (if not present) */
1457 /* Don't care about the process if it's not in the state hash already :
1458 * that means a process that has never done anything in the trace and
1459 * unknown suddently gets destroyed : no state meaningful to show. */
1460 LttvProcessState *process = lttv_state_find_process(ts, ANY_CPU, pid);
1461
1462 if(process != NULL) {
1463 LttTime birth;
1464 HashedProcessData *hashed_process_data = NULL;
1465
1466 ProcessList *process_list = control_flow_data->process_list;
1467
1468 birth = process->creation_time;
1469
1470 /* Cannot use current process : this event happens on another process,
1471 * action done by the parent. */
1472 hashed_process_data = processlist_get_process_data(process_list,
1473 pid,
1474 process->cpu,
1475 &birth,
1476 trace_num);
1477 if(unlikely(hashed_process_data == NULL))
1478 /*
1479 * Process already been scheduled out EXIT_DEAD, not in the process list
1480 * anymore. Just return.
1481 */
1482 return FALSE;
1483
1484 /* Now, the process is in the state hash and our own process hash.
1485 * We definitely can draw the items related to the ending state.
1486 */
1487
1488 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1489 evtime) > 0))
1490 {
1491 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1492 TimeWindow time_window =
1493 lttvwindow_get_time_window(control_flow_data->tab);
1494
1495 #ifdef EXTRA_CHECK
1496 if(ltt_time_compare(evtime, time_window.start_time) == -1
1497 || ltt_time_compare(evtime, time_window.end_time) == 1)
1498 return FALSE;
1499 #endif //EXTRA_CHECK
1500 Drawing_t *drawing = control_flow_data->drawing;
1501 guint width = drawing->width;
1502 guint x;
1503 convert_time_to_pixels(
1504 time_window,
1505 evtime,
1506 width,
1507 &x);
1508
1509 /* Draw collision indicator */
1510 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1511 gdk_draw_point(hashed_process_data->pixmap,
1512 drawing->gc,
1513 x,
1514 COLLISION_POSITION(hashed_process_data->height));
1515 hashed_process_data->x.middle_marked = TRUE;
1516 }
1517 } else {
1518 TimeWindow time_window =
1519 lttvwindow_get_time_window(control_flow_data->tab);
1520
1521 #ifdef EXTRA_CHECK
1522 if(ltt_time_compare(evtime, time_window.start_time) == -1
1523 || ltt_time_compare(evtime, time_window.end_time) == 1)
1524 return FALSE;
1525 #endif //EXTRA_CHECK
1526 Drawing_t *drawing = control_flow_data->drawing;
1527 guint width = drawing->width;
1528 guint x;
1529
1530 convert_time_to_pixels(
1531 time_window,
1532 evtime,
1533 width,
1534 &x);
1535
1536
1537 /* Jump over draw if we are at the same x position */
1538 if(unlikely(x == hashed_process_data->x.middle &&
1539 hashed_process_data->x.middle_used))
1540 {
1541 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1542 /* Draw collision indicator */
1543 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1544 gdk_draw_point(hashed_process_data->pixmap,
1545 drawing->gc,
1546 x,
1547 COLLISION_POSITION(hashed_process_data->height));
1548 hashed_process_data->x.middle_marked = TRUE;
1549 }
1550 /* jump */
1551 } else {
1552 DrawContext draw_context;
1553
1554 /* Now create the drawing context that will be used to draw
1555 * items related to the last state. */
1556 draw_context.drawable = hashed_process_data->pixmap;
1557 draw_context.gc = drawing->gc;
1558 draw_context.pango_layout = drawing->pango_layout;
1559 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1560 draw_context.drawinfo.end.x = x;
1561
1562 draw_context.drawinfo.y.over = 1;
1563 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1564 draw_context.drawinfo.y.under = hashed_process_data->height;
1565
1566 draw_context.drawinfo.start.offset.over = 0;
1567 draw_context.drawinfo.start.offset.middle = 0;
1568 draw_context.drawinfo.start.offset.under = 0;
1569 draw_context.drawinfo.end.offset.over = 0;
1570 draw_context.drawinfo.end.offset.middle = 0;
1571 draw_context.drawinfo.end.offset.under = 0;
1572
1573 {
1574 /* Draw the line */
1575 PropertiesLine prop_line = prepare_s_e_line(process);
1576 draw_line((void*)&prop_line, (void*)&draw_context);
1577
1578 }
1579 /* become the last x position */
1580 hashed_process_data->x.middle = x;
1581 hashed_process_data->x.middle_used = TRUE;
1582 hashed_process_data->x.middle_marked = FALSE;
1583
1584 /* Calculate the next good time */
1585 convert_pixels_to_time(width, x+1, time_window,
1586 &hashed_process_data->next_good_time);
1587 }
1588 }
1589 }
1590
1591 return 0;
1592 }
1593
1594
1595
1596
1597
1598 /* after_process_fork_hook
1599 *
1600 * Create the processlist entry for the child process. Put the last
1601 * position in x at the current time value.
1602 *
1603 * @param hook_data ControlFlowData structure of the viewer.
1604 * @param call_data Event context.
1605 *
1606 * This function adds items to be drawn in a queue for each process.
1607 *
1608 */
1609 int after_process_fork_hook(void *hook_data, void *call_data)
1610 {
1611 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1612 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1613 ControlFlowData *control_flow_data = events_request->viewer_data;
1614
1615 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1616
1617 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1618
1619 LttEvent *e;
1620 e = ltt_tracefile_get_event(tfc->tf);
1621
1622 LttvFilter *filter = control_flow_data->filter;
1623 if(filter != NULL && filter->head != NULL)
1624 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1625 tfc->t_context->t,tfc,NULL,NULL))
1626 return FALSE;
1627
1628 LttTime evtime = ltt_event_time(e);
1629
1630 guint child_pid;
1631 {
1632 child_pid = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
1633 }
1634
1635 /* Add process to process list (if not present) */
1636 LttvProcessState *process_child;
1637 LttTime birth;
1638 guint pl_height = 0;
1639 HashedProcessData *hashed_process_data_child = NULL;
1640
1641 ProcessList *process_list = control_flow_data->process_list;
1642
1643 /* Find child in the list... */
1644 process_child = lttv_state_find_process(ts, ANY_CPU, child_pid);
1645 /* It should exist, because we are after the state update. */
1646 g_assert(process_child != NULL);
1647
1648 birth = process_child->creation_time;
1649 guint trace_num = ts->parent.index;
1650
1651 /* Cannot use current process, because this action is done by the parent
1652 * on its child. */
1653 hashed_process_data_child = processlist_get_process_data(process_list,
1654 child_pid,
1655 process_child->cpu,
1656 &birth,
1657 trace_num);
1658 if(likely(hashed_process_data_child == NULL))
1659 {
1660 g_assert(child_pid == 0 || child_pid != process_child->ppid);
1661 /* Process not present */
1662 Drawing_t *drawing = control_flow_data->drawing;
1663 ProcessInfo *process_info;
1664 processlist_add(process_list,
1665 drawing,
1666 child_pid,
1667 process_child->tgid,
1668 process_child->cpu,
1669 process_child->ppid,
1670 &birth,
1671 trace_num,
1672 process_child->name,
1673 process_child->brand,
1674 &pl_height,
1675 &process_info,
1676 &hashed_process_data_child);
1677 gtk_widget_set_size_request(drawing->drawing_area,
1678 -1,
1679 pl_height);
1680 gtk_widget_queue_draw(drawing->drawing_area);
1681 } else {
1682 processlist_set_ppid(process_list, process_child->ppid,
1683 hashed_process_data_child);
1684 processlist_set_tgid(process_list, process_child->tgid,
1685 hashed_process_data_child);
1686 }
1687
1688
1689 if(likely(ltt_time_compare(hashed_process_data_child->next_good_time,
1690 evtime) <= 0))
1691 {
1692 TimeWindow time_window =
1693 lttvwindow_get_time_window(control_flow_data->tab);
1694
1695 #ifdef EXTRA_CHECK
1696 if(ltt_time_compare(evtime, time_window.start_time) == -1
1697 || ltt_time_compare(evtime, time_window.end_time) == 1)
1698 return FALSE;
1699 #endif //EXTRA_CHECK
1700 Drawing_t *drawing = control_flow_data->drawing;
1701 guint width = drawing->width;
1702 guint new_x;
1703 convert_time_to_pixels(
1704 time_window,
1705 evtime,
1706 width,
1707 &new_x);
1708
1709 if(likely(hashed_process_data_child->x.over != new_x)) {
1710 hashed_process_data_child->x.over = new_x;
1711 hashed_process_data_child->x.over_used = FALSE;
1712 hashed_process_data_child->x.over_marked = FALSE;
1713 }
1714 if(likely(hashed_process_data_child->x.middle != new_x)) {
1715 hashed_process_data_child->x.middle = new_x;
1716 hashed_process_data_child->x.middle_used = FALSE;
1717 hashed_process_data_child->x.middle_marked = FALSE;
1718 }
1719 if(likely(hashed_process_data_child->x.under != new_x)) {
1720 hashed_process_data_child->x.under = new_x;
1721 hashed_process_data_child->x.under_used = FALSE;
1722 hashed_process_data_child->x.under_marked = FALSE;
1723 }
1724 }
1725 return FALSE;
1726 }
1727
1728
1729
1730 /* after_process_exit_hook
1731 *
1732 * Create the processlist entry for the child process. Put the last
1733 * position in x at the current time value.
1734 *
1735 * @param hook_data ControlFlowData structure of the viewer.
1736 * @param call_data Event context.
1737 *
1738 * This function adds items to be drawn in a queue for each process.
1739 *
1740 */
1741 int after_process_exit_hook(void *hook_data, void *call_data)
1742 {
1743 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1744 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1745 ControlFlowData *control_flow_data = events_request->viewer_data;
1746
1747 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1748
1749 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1750
1751 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1752
1753 LttEvent *e;
1754 e = ltt_tracefile_get_event(tfc->tf);
1755
1756 LttvFilter *filter = control_flow_data->filter;
1757 if(filter != NULL && filter->head != NULL)
1758 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1759 tfc->t_context->t,tfc,NULL,NULL))
1760 return FALSE;
1761
1762 LttTime evtime = ltt_event_time(e);
1763
1764 /* Add process to process list (if not present) */
1765 //LttvProcessState *process = tfs->process;
1766 guint cpu = tfs->cpu;
1767 guint trace_num = ts->parent.index;
1768 LttvProcessState *process = ts->running_process[cpu];
1769
1770 /* It should exist, because we are after the state update. */
1771 g_assert(process != NULL);
1772
1773 guint pid = process->pid;
1774 LttTime birth;
1775 guint pl_height = 0;
1776 HashedProcessData *hashed_process_data = NULL;
1777
1778 ProcessList *process_list = control_flow_data->process_list;
1779
1780 birth = process->creation_time;
1781
1782 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){
1783 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1784 } else {
1785 hashed_process_data = processlist_get_process_data(process_list,
1786 pid,
1787 process->cpu,
1788 &birth,
1789 trace_num);
1790 if(unlikely(hashed_process_data == NULL))
1791 {
1792 g_assert(pid == 0 || pid != process->ppid);
1793 /* Process not present */
1794 Drawing_t *drawing = control_flow_data->drawing;
1795 ProcessInfo *process_info;
1796 processlist_add(process_list,
1797 drawing,
1798 pid,
1799 process->tgid,
1800 process->cpu,
1801 process->ppid,
1802 &birth,
1803 trace_num,
1804 process->name,
1805 process->brand,
1806 &pl_height,
1807 &process_info,
1808 &hashed_process_data);
1809 gtk_widget_set_size_request(drawing->drawing_area,
1810 -1,
1811 pl_height);
1812 gtk_widget_queue_draw(drawing->drawing_area);
1813 }
1814
1815 /* Set the current process */
1816 process_list->current_hash_data[trace_num][process->cpu] =
1817 hashed_process_data;
1818 }
1819
1820 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
1821 evtime) <= 0))
1822 {
1823 TimeWindow time_window =
1824 lttvwindow_get_time_window(control_flow_data->tab);
1825
1826 #ifdef EXTRA_CHECK
1827 if(ltt_time_compare(evtime, time_window.start_time) == -1
1828 || ltt_time_compare(evtime, time_window.end_time) == 1)
1829 return FALSE;
1830 #endif //EXTRA_CHECK
1831 Drawing_t *drawing = control_flow_data->drawing;
1832 guint width = drawing->width;
1833 guint new_x;
1834 convert_time_to_pixels(
1835 time_window,
1836 evtime,
1837 width,
1838 &new_x);
1839 if(unlikely(hashed_process_data->x.middle != new_x)) {
1840 hashed_process_data->x.middle = new_x;
1841 hashed_process_data->x.middle_used = FALSE;
1842 hashed_process_data->x.middle_marked = FALSE;
1843 }
1844 }
1845
1846 return FALSE;
1847 }
1848
1849
1850 /* Get the filename of the process to print */
1851 int after_fs_exec_hook(void *hook_data, void *call_data)
1852 {
1853 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1854 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1855 ControlFlowData *control_flow_data = events_request->viewer_data;
1856
1857 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1858
1859 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1860
1861 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1862
1863 LttEvent *e;
1864 e = ltt_tracefile_get_event(tfc->tf);
1865
1866 LttvFilter *filter = control_flow_data->filter;
1867 if(filter != NULL && filter->head != NULL)
1868 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1869 tfc->t_context->t,tfc,NULL,NULL))
1870 return FALSE;
1871
1872 guint cpu = tfs->cpu;
1873 guint trace_num = ts->parent.index;
1874 LttvProcessState *process = ts->running_process[cpu];
1875 g_assert(process != NULL);
1876
1877 guint pid = process->pid;
1878
1879 /* Well, the process_out existed : we must get it in the process hash
1880 * or add it, and draw its items.
1881 */
1882 /* Add process to process list (if not present) */
1883 guint pl_height = 0;
1884 HashedProcessData *hashed_process_data = NULL;
1885 ProcessList *process_list = control_flow_data->process_list;
1886 LttTime birth = process->creation_time;
1887
1888 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1889 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1890 } else {
1891 hashed_process_data = processlist_get_process_data(process_list,
1892 pid,
1893 process->cpu,
1894 &birth,
1895 trace_num);
1896 if(unlikely(hashed_process_data == NULL))
1897 {
1898 g_assert(pid == 0 || pid != process->ppid);
1899 ProcessInfo *process_info;
1900 /* Process not present */
1901 Drawing_t *drawing = control_flow_data->drawing;
1902 processlist_add(process_list,
1903 drawing,
1904 pid,
1905 process->tgid,
1906 process->cpu,
1907 process->ppid,
1908 &birth,
1909 trace_num,
1910 process->name,
1911 process->brand,
1912 &pl_height,
1913 &process_info,
1914 &hashed_process_data);
1915 gtk_widget_set_size_request(drawing->drawing_area,
1916 -1,
1917 pl_height);
1918 gtk_widget_queue_draw(drawing->drawing_area);
1919 }
1920 /* Set the current process */
1921 process_list->current_hash_data[trace_num][process->cpu] =
1922 hashed_process_data;
1923 }
1924
1925 processlist_set_name(process_list, process->name, hashed_process_data);
1926
1927 return 0;
1928
1929 }
1930
1931 /* Get the filename of the process to print */
1932 int after_user_generic_thread_brand_hook(void *hook_data, void *call_data)
1933 {
1934 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1935 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1936 ControlFlowData *control_flow_data = events_request->viewer_data;
1937
1938 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1939
1940 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1941
1942 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1943
1944 LttEvent *e;
1945 e = ltt_tracefile_get_event(tfc->tf);
1946
1947 LttvFilter *filter = control_flow_data->filter;
1948 if(filter != NULL && filter->head != NULL)
1949 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1950 tfc->t_context->t,tfc,NULL,NULL))
1951 return FALSE;
1952
1953 guint cpu = tfs->cpu;
1954 guint trace_num = ts->parent.index;
1955 LttvProcessState *process = ts->running_process[cpu];
1956 g_assert(process != NULL);
1957
1958 guint pid = process->pid;
1959
1960 /* Well, the process_out existed : we must get it in the process hash
1961 * or add it, and draw its items.
1962 */
1963 /* Add process to process list (if not present) */
1964 guint pl_height = 0;
1965 HashedProcessData *hashed_process_data = NULL;
1966 ProcessList *process_list = control_flow_data->process_list;
1967 LttTime birth = process->creation_time;
1968
1969 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1970 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1971 } else {
1972 hashed_process_data = processlist_get_process_data(process_list,
1973 pid,
1974 process->cpu,
1975 &birth,
1976 trace_num);
1977 if(unlikely(hashed_process_data == NULL))
1978 {
1979 g_assert(pid == 0 || pid != process->ppid);
1980 ProcessInfo *process_info;
1981 /* Process not present */
1982 Drawing_t *drawing = control_flow_data->drawing;
1983 processlist_add(process_list,
1984 drawing,
1985 pid,
1986 process->tgid,
1987 process->cpu,
1988 process->ppid,
1989 &birth,
1990 trace_num,
1991 process->name,
1992 process->brand,
1993 &pl_height,
1994 &process_info,
1995 &hashed_process_data);
1996 gtk_widget_set_size_request(drawing->drawing_area,
1997 -1,
1998 pl_height);
1999 gtk_widget_queue_draw(drawing->drawing_area);
2000 }
2001 /* Set the current process */
2002 process_list->current_hash_data[trace_num][process->cpu] =
2003 hashed_process_data;
2004 }
2005
2006 processlist_set_brand(process_list, process->brand, hashed_process_data);
2007
2008 return 0;
2009
2010 }
2011
2012
2013 /* after_event_enum_process_hook
2014 *
2015 * Create the processlist entry for the child process. Put the last
2016 * position in x at the current time value.
2017 *
2018 * @param hook_data ControlFlowData structure of the viewer.
2019 * @param call_data Event context.
2020 *
2021 * This function adds items to be drawn in a queue for each process.
2022 *
2023 */
2024 int after_event_enum_process_hook(void *hook_data, void *call_data)
2025 {
2026 LttvTraceHook *th = (LttvTraceHook*)hook_data;
2027 EventsRequest *events_request = (EventsRequest*)th->hook_data;
2028 ControlFlowData *control_flow_data = events_request->viewer_data;
2029
2030 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2031
2032 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
2033
2034 guint first_cpu, nb_cpus, cpu;
2035
2036 LttEvent *e;
2037 e = ltt_tracefile_get_event(tfc->tf);
2038
2039 LttvFilter *filter = control_flow_data->filter;
2040 if(filter != NULL && filter->head != NULL)
2041 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
2042 tfc->t_context->t,tfc,NULL,NULL))
2043 return FALSE;
2044
2045 /* Add process to process list (if not present) */
2046 LttvProcessState *process_in;
2047 LttTime birth;
2048 guint pl_height = 0;
2049 HashedProcessData *hashed_process_data_in = NULL;
2050
2051 ProcessList *process_list = control_flow_data->process_list;
2052 guint trace_num = ts->parent.index;
2053
2054 guint pid_in;
2055 {
2056 pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
2057 }
2058
2059 if(pid_in == 0) {
2060 first_cpu = 0;
2061 nb_cpus = ltt_trace_get_num_cpu(ts->parent.t);
2062 } else {
2063 first_cpu = ANY_CPU;
2064 nb_cpus = ANY_CPU+1;
2065 }
2066
2067 for(cpu = first_cpu; cpu < nb_cpus; cpu++) {
2068 /* Find process pid_in in the list... */
2069 process_in = lttv_state_find_process(ts, cpu, pid_in);
2070 //process_in = tfs->process;
2071 //guint cpu = tfs->cpu;
2072 //guint trace_num = ts->parent.index;
2073 //process_in = ts->running_process[cpu];
2074 /* It should exist, because we are after the state update. */
2075 #ifdef EXTRA_CHECK
2076 //g_assert(process_in != NULL);
2077 #endif //EXTRA_CHECK
2078 birth = process_in->creation_time;
2079
2080 hashed_process_data_in = processlist_get_process_data(process_list,
2081 pid_in,
2082 process_in->cpu,
2083 &birth,
2084 trace_num);
2085 if(hashed_process_data_in == NULL)
2086 {
2087 if(pid_in != 0 && pid_in == process_in->ppid)
2088 g_critical("TEST %u , %u", pid_in, process_in->ppid);
2089 g_assert(pid_in == 0 || pid_in != process_in->ppid);
2090 ProcessInfo *process_info;
2091 Drawing_t *drawing = control_flow_data->drawing;
2092 /* Process not present */
2093 processlist_add(process_list,
2094 drawing,
2095 pid_in,
2096 process_in->tgid,
2097 process_in->cpu,
2098 process_in->ppid,
2099 &birth,
2100 trace_num,
2101 process_in->name,
2102 process_in->brand,
2103 &pl_height,
2104 &process_info,
2105 &hashed_process_data_in);
2106 gtk_widget_set_size_request(drawing->drawing_area,
2107 -1,
2108 pl_height);
2109 gtk_widget_queue_draw(drawing->drawing_area);
2110 } else {
2111 processlist_set_name(process_list, process_in->name,
2112 hashed_process_data_in);
2113 processlist_set_ppid(process_list, process_in->ppid,
2114 hashed_process_data_in);
2115 processlist_set_tgid(process_list, process_in->tgid,
2116 hashed_process_data_in);
2117 }
2118 }
2119 return 0;
2120 }
2121
2122
2123 gint update_time_window_hook(void *hook_data, void *call_data)
2124 {
2125 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2126 Drawing_t *drawing = control_flow_data->drawing;
2127 ProcessList *process_list = control_flow_data->process_list;
2128
2129 const TimeWindowNotifyData *time_window_nofify_data =
2130 ((const TimeWindowNotifyData *)call_data);
2131
2132 TimeWindow *old_time_window =
2133 time_window_nofify_data->old_time_window;
2134 TimeWindow *new_time_window =
2135 time_window_nofify_data->new_time_window;
2136
2137 /* Update the ruler */
2138 drawing_update_ruler(control_flow_data->drawing,
2139 new_time_window);
2140
2141
2142 /* Two cases : zoom in/out or scrolling */
2143
2144 /* In order to make sure we can reuse the old drawing, the scale must
2145 * be the same and the new time interval being partly located in the
2146 * currently shown time interval. (reuse is only for scrolling)
2147 */
2148
2149 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
2150 old_time_window->start_time.tv_sec,
2151 old_time_window->start_time.tv_nsec,
2152 old_time_window->time_width.tv_sec,
2153 old_time_window->time_width.tv_nsec);
2154
2155 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
2156 new_time_window->start_time.tv_sec,
2157 new_time_window->start_time.tv_nsec,
2158 new_time_window->time_width.tv_sec,
2159 new_time_window->time_width.tv_nsec);
2160
2161 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
2162 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
2163 {
2164 /* Same scale (scrolling) */
2165 g_info("scrolling");
2166 LttTime *ns = &new_time_window->start_time;
2167 LttTime *os = &old_time_window->start_time;
2168 LttTime old_end = old_time_window->end_time;
2169 LttTime new_end = new_time_window->end_time;
2170 //if(ns<os+w<ns+w)
2171 //if(ns<os+w && os+w<ns+w)
2172 //if(ns<old_end && os<ns)
2173 if(ltt_time_compare(*ns, old_end) == -1
2174 && ltt_time_compare(*os, *ns) == -1)
2175 {
2176 g_info("scrolling near right");
2177 /* Scroll right, keep right part of the screen */
2178 guint x = 0;
2179 guint width = control_flow_data->drawing->width;
2180 convert_time_to_pixels(
2181 *old_time_window,
2182 *ns,
2183 width,
2184 &x);
2185
2186 /* Copy old data to new location */
2187 copy_pixmap_region(process_list,
2188 NULL,
2189 control_flow_data->drawing->drawing_area->style->black_gc,
2190 NULL,
2191 x, 0,
2192 0, 0,
2193 control_flow_data->drawing->width-x+SAFETY, -1);
2194
2195 if(drawing->damage_begin == drawing->damage_end)
2196 drawing->damage_begin = control_flow_data->drawing->width-x;
2197 else
2198 drawing->damage_begin = 0;
2199
2200 drawing->damage_end = control_flow_data->drawing->width;
2201
2202 /* Clear the data request background, but not SAFETY */
2203 rectangle_pixmap(process_list,
2204 control_flow_data->drawing->drawing_area->style->black_gc,
2205 TRUE,
2206 drawing->damage_begin+SAFETY, 0,
2207 drawing->damage_end - drawing->damage_begin, // do not overlap
2208 -1);
2209 gtk_widget_queue_draw(drawing->drawing_area);
2210 //gtk_widget_queue_draw_area (drawing->drawing_area,
2211 // 0,0,
2212 // control_flow_data->drawing->width,
2213 // control_flow_data->drawing->height);
2214
2215 /* Get new data for the rest. */
2216 drawing_data_request(control_flow_data->drawing,
2217 drawing->damage_begin, 0,
2218 drawing->damage_end - drawing->damage_begin,
2219 control_flow_data->drawing->height);
2220 } else {
2221 //if(ns<os<ns+w)
2222 //if(ns<os && os<ns+w)
2223 //if(ns<os && os<new_end)
2224 if(ltt_time_compare(*ns,*os) == -1
2225 && ltt_time_compare(*os,new_end) == -1)
2226 {
2227 g_info("scrolling near left");
2228 /* Scroll left, keep left part of the screen */
2229 guint x = 0;
2230 guint width = control_flow_data->drawing->width;
2231 convert_time_to_pixels(
2232 *new_time_window,
2233 *os,
2234 width,
2235 &x);
2236
2237 /* Copy old data to new location */
2238 copy_pixmap_region (process_list,
2239 NULL,
2240 control_flow_data->drawing->drawing_area->style->black_gc,
2241 NULL,
2242 0, 0,
2243 x, 0,
2244 -1, -1);
2245
2246 if(drawing->damage_begin == drawing->damage_end)
2247 drawing->damage_end = x;
2248 else
2249 drawing->damage_end =
2250 control_flow_data->drawing->width;
2251
2252 drawing->damage_begin = 0;
2253
2254 rectangle_pixmap (process_list,
2255 control_flow_data->drawing->drawing_area->style->black_gc,
2256 TRUE,
2257 drawing->damage_begin, 0,
2258 drawing->damage_end - drawing->damage_begin, // do not overlap
2259 -1);
2260
2261 gtk_widget_queue_draw(drawing->drawing_area);
2262 //gtk_widget_queue_draw_area (drawing->drawing_area,
2263 // 0,0,
2264 // control_flow_data->drawing->width,
2265 // control_flow_data->drawing->height);
2266
2267
2268 /* Get new data for the rest. */
2269 drawing_data_request(control_flow_data->drawing,
2270 drawing->damage_begin, 0,
2271 drawing->damage_end - drawing->damage_begin,
2272 control_flow_data->drawing->height);
2273
2274 } else {
2275 if(ltt_time_compare(*ns,*os) == 0)
2276 {
2277 g_info("not scrolling");
2278 } else {
2279 g_info("scrolling far");
2280 /* Cannot reuse any part of the screen : far jump */
2281
2282
2283 rectangle_pixmap (process_list,
2284 control_flow_data->drawing->drawing_area->style->black_gc,
2285 TRUE,
2286 0, 0,
2287 control_flow_data->drawing->width+SAFETY, // do not overlap
2288 -1);
2289
2290 //gtk_widget_queue_draw_area (drawing->drawing_area,
2291 // 0,0,
2292 // control_flow_data->drawing->width,
2293 // control_flow_data->drawing->height);
2294 gtk_widget_queue_draw(drawing->drawing_area);
2295
2296 drawing->damage_begin = 0;
2297 drawing->damage_end = control_flow_data->drawing->width;
2298
2299 drawing_data_request(control_flow_data->drawing,
2300 0, 0,
2301 control_flow_data->drawing->width,
2302 control_flow_data->drawing->height);
2303
2304 }
2305 }
2306 }
2307 } else {
2308 /* Different scale (zoom) */
2309 g_info("zoom");
2310
2311 rectangle_pixmap (process_list,
2312 control_flow_data->drawing->drawing_area->style->black_gc,
2313 TRUE,
2314 0, 0,
2315 control_flow_data->drawing->width+SAFETY, // do not overlap
2316 -1);
2317
2318 //gtk_widget_queue_draw_area (drawing->drawing_area,
2319 // 0,0,
2320 // control_flow_data->drawing->width,
2321 // control_flow_data->drawing->height);
2322 gtk_widget_queue_draw(drawing->drawing_area);
2323
2324 drawing->damage_begin = 0;
2325 drawing->damage_end = control_flow_data->drawing->width;
2326
2327 drawing_data_request(control_flow_data->drawing,
2328 0, 0,
2329 control_flow_data->drawing->width,
2330 control_flow_data->drawing->height);
2331 }
2332
2333 /* Update directly when scrolling */
2334 gdk_window_process_updates(control_flow_data->drawing->drawing_area->window,
2335 TRUE);
2336
2337 return 0;
2338 }
2339
2340 gint traceset_notify(void *hook_data, void *call_data)
2341 {
2342 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2343 Drawing_t *drawing = control_flow_data->drawing;
2344
2345 if(unlikely(drawing->gc == NULL)) {
2346 return FALSE;
2347 }
2348 if(drawing->dotted_gc == NULL) {
2349 return FALSE;
2350 }
2351
2352 drawing_clear(control_flow_data->drawing);
2353 processlist_clear(control_flow_data->process_list);
2354 gtk_widget_set_size_request(
2355 control_flow_data->drawing->drawing_area,
2356 -1, processlist_get_height(control_flow_data->process_list));
2357 redraw_notify(control_flow_data, NULL);
2358
2359 request_background_data(control_flow_data);
2360
2361 return FALSE;
2362 }
2363
2364 gint redraw_notify(void *hook_data, void *call_data)
2365 {
2366 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2367 Drawing_t *drawing = control_flow_data->drawing;
2368 GtkWidget *widget = drawing->drawing_area;
2369
2370 drawing->damage_begin = 0;
2371 drawing->damage_end = drawing->width;
2372
2373 /* fun feature, to be separated someday... */
2374 drawing_clear(control_flow_data->drawing);
2375 processlist_clear(control_flow_data->process_list);
2376 gtk_widget_set_size_request(
2377 control_flow_data->drawing->drawing_area,
2378 -1, processlist_get_height(control_flow_data->process_list));
2379 // Clear the images
2380 rectangle_pixmap (control_flow_data->process_list,
2381 widget->style->black_gc,
2382 TRUE,
2383 0, 0,
2384 drawing->alloc_width,
2385 -1);
2386
2387 gtk_widget_queue_draw(drawing->drawing_area);
2388
2389 if(drawing->damage_begin < drawing->damage_end)
2390 {
2391 drawing_data_request(drawing,
2392 drawing->damage_begin,
2393 0,
2394 drawing->damage_end-drawing->damage_begin,
2395 drawing->height);
2396 }
2397
2398 //gtk_widget_queue_draw_area(drawing->drawing_area,
2399 // 0,0,
2400 // drawing->width,
2401 // drawing->height);
2402 return FALSE;
2403
2404 }
2405
2406
2407 gint continue_notify(void *hook_data, void *call_data)
2408 {
2409 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2410 Drawing_t *drawing = control_flow_data->drawing;
2411
2412 //g_assert(widget->allocation.width == drawing->damage_end);
2413
2414 if(drawing->damage_begin < drawing->damage_end)
2415 {
2416 drawing_data_request(drawing,
2417 drawing->damage_begin,
2418 0,
2419 drawing->damage_end-drawing->damage_begin,
2420 drawing->height);
2421 }
2422
2423 return FALSE;
2424 }
2425
2426
2427 gint update_current_time_hook(void *hook_data, void *call_data)
2428 {
2429 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
2430
2431 LttTime current_time = *((LttTime*)call_data);
2432
2433 TimeWindow time_window =
2434 lttvwindow_get_time_window(control_flow_data->tab);
2435
2436 LttTime time_begin = time_window.start_time;
2437 LttTime width = time_window.time_width;
2438 LttTime half_width;
2439 {
2440 guint64 time_ll = ltt_time_to_uint64(width);
2441 time_ll = time_ll >> 1; /* divide by two */
2442 half_width = ltt_time_from_uint64(time_ll);
2443 }
2444 LttTime time_end = ltt_time_add(time_begin, width);
2445
2446 LttvTracesetContext * tsc =
2447 lttvwindow_get_traceset_context(control_flow_data->tab);
2448
2449 LttTime trace_start = tsc->time_span.start_time;
2450 LttTime trace_end = tsc->time_span.end_time;
2451
2452 g_info("New current time HOOK : %lu, %lu", current_time.tv_sec,
2453 current_time.tv_nsec);
2454
2455
2456
2457 /* If current time is inside time interval, just move the highlight
2458 * bar */
2459
2460 /* Else, we have to change the time interval. We have to tell it
2461 * to the main window. */
2462 /* The time interval change will take care of placing the current
2463 * time at the center of the visible area, or nearest possible if we are
2464 * at one end of the trace. */
2465
2466
2467 if(ltt_time_compare(current_time, time_begin) < 0)
2468 {
2469 TimeWindow new_time_window;
2470
2471 if(ltt_time_compare(current_time,
2472 ltt_time_add(trace_start,half_width)) < 0)
2473 time_begin = trace_start;
2474 else
2475 time_begin = ltt_time_sub(current_time,half_width);
2476
2477 new_time_window.start_time = time_begin;
2478 new_time_window.time_width = width;
2479 new_time_window.time_width_double = ltt_time_to_double(width);
2480 new_time_window.end_time = ltt_time_add(time_begin, width);
2481
2482 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
2483 }
2484 else if(ltt_time_compare(current_time, time_end) > 0)
2485 {
2486 TimeWindow new_time_window;
2487
2488 if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0)
2489 time_begin = ltt_time_sub(trace_end,width);
2490 else
2491 time_begin = ltt_time_sub(current_time,half_width);
2492
2493 new_time_window.start_time = time_begin;
2494 new_time_window.time_width = width;
2495 new_time_window.time_width_double = ltt_time_to_double(width);
2496 new_time_window.end_time = ltt_time_add(time_begin, width);
2497
2498 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
2499
2500 }
2501 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2502
2503 /* Update directly when scrolling */
2504 gdk_window_process_updates(control_flow_data->drawing->drawing_area->window,
2505 TRUE);
2506
2507 return 0;
2508 }
2509
2510 typedef struct _ClosureData {
2511 EventsRequest *events_request;
2512 LttvTracesetState *tss;
2513 LttTime end_time;
2514 guint x_end;
2515 } ClosureData;
2516
2517
2518 void draw_closure(gpointer key, gpointer value, gpointer user_data)
2519 {
2520 ProcessInfo *process_info = (ProcessInfo*)key;
2521 HashedProcessData *hashed_process_data = (HashedProcessData*)value;
2522 ClosureData *closure_data = (ClosureData*)user_data;
2523
2524 EventsRequest *events_request = closure_data->events_request;
2525 ControlFlowData *control_flow_data = events_request->viewer_data;
2526
2527 LttvTracesetState *tss = closure_data->tss;
2528 LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
2529
2530 LttTime evtime = closure_data->end_time;
2531
2532 gboolean dodraw = TRUE;
2533
2534 {
2535 /* For the process */
2536 /* First, check if the current process is in the state computation
2537 * process list. If it is there, that means we must add it right now and
2538 * draw items from the beginning of the read for it. If it is not
2539 * present, it's a new process and it was not present : it will
2540 * be added after the state update. */
2541 #ifdef EXTRA_CHECK
2542 g_assert(lttv_traceset_number(tsc->ts) > 0);
2543 #endif //EXTRA_CHECK
2544 LttvTraceContext *tc = tsc->traces[process_info->trace_num];
2545 LttvTraceState *ts = (LttvTraceState*)tc;
2546
2547 #if 0
2548 //FIXME : optimize data structures.
2549 LttvTracefileState *tfs;
2550 LttvTracefileContext *tfc;
2551 guint i;
2552 for(i=0;i<tc->tracefiles->len;i++) {
2553 tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i);
2554 if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU
2555 && tfs->cpu == process_info->cpu)
2556 break;
2557
2558 }
2559 g_assert(i<tc->tracefiles->len);
2560 tfs = LTTV_TRACEFILE_STATE(tfc);
2561 #endif //0
2562 // LttvTracefileState *tfs =
2563 // (LttvTracefileState*)tsc->traces[process_info->trace_num]->
2564 // tracefiles[process_info->cpu];
2565
2566 LttvProcessState *process;
2567 process = lttv_state_find_process(ts, process_info->cpu,
2568 process_info->pid);
2569
2570 if(unlikely(process != NULL)) {
2571
2572 LttvFilter *filter = control_flow_data->filter;
2573 if(filter != NULL && filter->head != NULL)
2574 if(!lttv_filter_tree_parse(filter->head,NULL,NULL,
2575 tc->t,NULL,process,tc))
2576 dodraw = FALSE;
2577
2578 /* Only draw for processes that are currently in the trace states */
2579
2580 #ifdef EXTRA_CHECK
2581 /* Should be alike when background info is ready */
2582 if(control_flow_data->background_info_waiting==0)
2583 g_assert(ltt_time_compare(process->creation_time,
2584 process_info->birth) == 0);
2585 #endif //EXTRA_CHECK
2586
2587 /* Now, the process is in the state hash and our own process hash.
2588 * We definitely can draw the items related to the ending state.
2589 */
2590
2591 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
2592 evtime) <= 0))
2593 {
2594 TimeWindow time_window =
2595 lttvwindow_get_time_window(control_flow_data->tab);
2596
2597 #ifdef EXTRA_CHECK
2598 if(ltt_time_compare(evtime, time_window.start_time) == -1
2599 || ltt_time_compare(evtime, time_window.end_time) == 1)
2600 return;
2601 #endif //EXTRA_CHECK
2602 Drawing_t *drawing = control_flow_data->drawing;
2603 guint width = drawing->width;
2604
2605 guint x = closure_data->x_end;
2606
2607 DrawContext draw_context;
2608
2609 /* Now create the drawing context that will be used to draw
2610 * items related to the last state. */
2611 draw_context.drawable = hashed_process_data->pixmap;
2612 draw_context.gc = drawing->gc;
2613 draw_context.pango_layout = drawing->pango_layout;
2614 draw_context.drawinfo.end.x = x;
2615
2616 draw_context.drawinfo.y.over = 1;
2617 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
2618 draw_context.drawinfo.y.under = hashed_process_data->height;
2619
2620 draw_context.drawinfo.start.offset.over = 0;
2621 draw_context.drawinfo.start.offset.middle = 0;
2622 draw_context.drawinfo.start.offset.under = 0;
2623 draw_context.drawinfo.end.offset.over = 0;
2624 draw_context.drawinfo.end.offset.middle = 0;
2625 draw_context.drawinfo.end.offset.under = 0;
2626 #if 0
2627 /* Jump over draw if we are at the same x position */
2628 if(x == hashed_process_data->x.over)
2629 {
2630 /* jump */
2631 } else {
2632 draw_context.drawinfo.start.x = hashed_process_data->x.over;
2633 /* Draw the line */
2634 PropertiesLine prop_line = prepare_execmode_line(process);
2635 draw_line((void*)&prop_line, (void*)&draw_context);
2636
2637 hashed_process_data->x.over = x;
2638 }
2639 #endif //0
2640
2641 if(unlikely(x == hashed_process_data->x.middle &&
2642 hashed_process_data->x.middle_used)) {
2643 #if 0 /* do not mark closure : not missing information */
2644 if(hashed_process_data->x.middle_marked == FALSE) {
2645 /* Draw collision indicator */
2646 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
2647 gdk_draw_point(drawing->pixmap,
2648 drawing->gc,
2649 x,
2650 y+(height/2)-3);
2651 hashed_process_data->x.middle_marked = TRUE;
2652 }
2653 #endif //0
2654 /* Jump */
2655 } else {
2656 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
2657 /* Draw the line */
2658 if(dodraw) {
2659 PropertiesLine prop_line = prepare_s_e_line(process);
2660 draw_line((void*)&prop_line, (void*)&draw_context);
2661 }
2662
2663 /* become the last x position */
2664 if(likely(x != hashed_process_data->x.middle)) {
2665 hashed_process_data->x.middle = x;
2666 /* but don't use the pixel */
2667 hashed_process_data->x.middle_used = FALSE;
2668
2669 /* Calculate the next good time */
2670 convert_pixels_to_time(width, x+1, time_window,
2671 &hashed_process_data->next_good_time);
2672 }
2673 }
2674 }
2675 }
2676 }
2677 return;
2678 }
2679
2680 int before_chunk(void *hook_data, void *call_data)
2681 {
2682 EventsRequest *events_request = (EventsRequest*)hook_data;
2683 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2684 #if 0
2685 /* Desactivate sort */
2686 gtk_tree_sortable_set_sort_column_id(
2687 GTK_TREE_SORTABLE(cfd->process_list->list_store),
2688 TRACE_COLUMN,
2689 GTK_SORT_ASCENDING);
2690 #endif //0
2691 drawing_chunk_begin(events_request, tss);
2692
2693 return 0;
2694 }
2695
2696 int before_request(void *hook_data, void *call_data)
2697 {
2698 EventsRequest *events_request = (EventsRequest*)hook_data;
2699 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2700
2701 drawing_data_request_begin(events_request, tss);
2702
2703 return 0;
2704 }
2705
2706
2707 /*
2708 * after request is necessary in addition of after chunk in order to draw
2709 * lines until the end of the screen. after chunk just draws lines until
2710 * the last event.
2711 *
2712 * for each process
2713 * draw closing line
2714 * expose
2715 */
2716 int after_request(void *hook_data, void *call_data)
2717 {
2718 EventsRequest *events_request = (EventsRequest*)hook_data;
2719 ControlFlowData *control_flow_data = events_request->viewer_data;
2720 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2721
2722 ProcessList *process_list = control_flow_data->process_list;
2723 LttTime end_time = events_request->end_time;
2724
2725 ClosureData closure_data;
2726 closure_data.events_request = (EventsRequest*)hook_data;
2727 closure_data.tss = tss;
2728 closure_data.end_time = end_time;
2729
2730 TimeWindow time_window =
2731 lttvwindow_get_time_window(control_flow_data->tab);
2732 guint width = control_flow_data->drawing->width;
2733 convert_time_to_pixels(
2734 time_window,
2735 end_time,
2736 width,
2737 &closure_data.x_end);
2738
2739
2740 /* Draw last items */
2741 g_hash_table_foreach(process_list->process_hash, draw_closure,
2742 (void*)&closure_data);
2743
2744
2745 /* Request expose */
2746 drawing_request_expose(events_request, tss, end_time);
2747 return 0;
2748 }
2749
2750 /*
2751 * for each process
2752 * draw closing line
2753 * expose
2754 */
2755 int after_chunk(void *hook_data, void *call_data)
2756 {
2757 EventsRequest *events_request = (EventsRequest*)hook_data;
2758 ControlFlowData *control_flow_data = events_request->viewer_data;
2759 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2760 LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
2761 LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
2762 LttTime end_time;
2763
2764 ProcessList *process_list = control_flow_data->process_list;
2765 guint i;
2766 LttvTraceset *traceset = tsc->ts;
2767 guint nb_trace = lttv_traceset_number(traceset);
2768
2769 /* Only execute when called for the first trace's events request */
2770 if(!process_list->current_hash_data)
2771 return 0;
2772
2773 for(i = 0 ; i < nb_trace ; i++) {
2774 g_free(process_list->current_hash_data[i]);
2775 }
2776 g_free(process_list->current_hash_data);
2777 process_list->current_hash_data = NULL;
2778
2779 if(tfc != NULL)
2780 end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
2781 else /* end of traceset, or position now out of request : end */
2782 end_time = events_request->end_time;
2783
2784 ClosureData closure_data;
2785 closure_data.events_request = (EventsRequest*)hook_data;
2786 closure_data.tss = tss;
2787 closure_data.end_time = end_time;
2788
2789 TimeWindow time_window =
2790 lttvwindow_get_time_window(control_flow_data->tab);
2791 guint width = control_flow_data->drawing->width;
2792 convert_time_to_pixels(
2793 time_window,
2794 end_time,
2795 width,
2796 &closure_data.x_end);
2797
2798 /* Draw last items */
2799 g_hash_table_foreach(process_list->process_hash, draw_closure,
2800 (void*)&closure_data);
2801 #if 0
2802 /* Reactivate sort */
2803 gtk_tree_sortable_set_sort_column_id(
2804 GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
2805 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
2806 GTK_SORT_ASCENDING);
2807
2808 update_index_to_pixmap(control_flow_data->process_list);
2809 /* Request a full expose : drawing scrambled */
2810 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2811 #endif //0
2812 /* Request expose (updates damages zone also) */
2813 drawing_request_expose(events_request, tss, end_time);
2814
2815 return 0;
2816 }
2817
2818 /* after_statedump_end
2819 *
2820 * @param hook_data ControlFlowData structure of the viewer.
2821 * @param call_data Event context.
2822 *
2823 * This function adds items to be drawn in a queue for each process.
2824 *
2825 */
2826 int before_statedump_end(void *hook_data, void *call_data)
2827 {
2828 LttvTraceHook *th = (LttvTraceHook*)hook_data;
2829 EventsRequest *events_request = (EventsRequest*)th->hook_data;
2830 ControlFlowData *control_flow_data = events_request->viewer_data;
2831
2832 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2833
2834 LttvTracesetState *tss = (LttvTracesetState*)tfc->t_context->ts_context;
2835 ProcessList *process_list = control_flow_data->process_list;
2836
2837 LttEvent *e;
2838 e = ltt_tracefile_get_event(tfc->tf);
2839
2840 LttvFilter *filter = control_flow_data->filter;
2841 if(filter != NULL && filter->head != NULL)
2842 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
2843 tfc->t_context->t,tfc,NULL,NULL))
2844 return FALSE;
2845
2846 LttTime evtime = ltt_event_time(e);
2847
2848 ClosureData closure_data;
2849 closure_data.events_request = events_request;
2850 closure_data.tss = tss;
2851 closure_data.end_time = evtime;
2852
2853 TimeWindow time_window =
2854 lttvwindow_get_time_window(control_flow_data->tab);
2855 guint width = control_flow_data->drawing->width;
2856 convert_time_to_pixels(
2857 time_window,
2858 evtime,
2859 width,
2860 &closure_data.x_end);
2861
2862 /* Draw last items */
2863 g_hash_table_foreach(process_list->process_hash, draw_closure,
2864 (void*)&closure_data);
2865 #if 0
2866 /* Reactivate sort */
2867 gtk_tree_sortable_set_sort_column_id(
2868 GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
2869 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
2870 GTK_SORT_ASCENDING);
2871
2872 update_index_to_pixmap(control_flow_data->process_list);
2873 /* Request a full expose : drawing scrambled */
2874 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2875 #endif //0
2876 /* Request expose (updates damages zone also) */
2877 drawing_request_expose(events_request, tss, evtime);
2878
2879 return 0;
2880 }
This page took 0.139156 seconds and 3 git commands to generate.