Fix state.c handling of state dump thread state
[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 guint state_out;
520 {
521 pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
522 pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
523 state_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 2));
524 }
525
526 tfc->target_pid = pid_out;
527 if(!filter || !filter->head ||
528 lttv_filter_tree_parse(filter->head,e,tfc->tf,
529 tfc->t_context->t,tfc,NULL,NULL)) {
530 /* For the pid_out */
531 /* First, check if the current process is in the state computation
532 * process list. If it is there, that means we must add it right now and
533 * draw items from the beginning of the read for it. If it is not
534 * present, it's a new process and it was not present : it will
535 * be added after the state update. */
536 guint cpu = tfs->cpu;
537 guint trace_num = ts->parent.index;
538 LttvProcessState *process = ts->running_process[cpu];
539 /* unknown state, bad current pid */
540 if(process->pid != pid_out)
541 process = lttv_state_find_process(ts,
542 tfs->cpu, pid_out);
543
544 if(process != NULL) {
545 /* Well, the process_out existed : we must get it in the process hash
546 * or add it, and draw its items.
547 */
548 /* Add process to process list (if not present) */
549 guint pl_height = 0;
550 HashedProcessData *hashed_process_data = NULL;
551 ProcessList *process_list = control_flow_data->process_list;
552 LttTime birth = process->creation_time;
553
554 hashed_process_data = processlist_get_process_data(process_list,
555 pid_out,
556 process->cpu,
557 &birth,
558 trace_num);
559 if(hashed_process_data == NULL)
560 {
561 g_assert(pid_out == 0 || pid_out != process->ppid);
562 /* Process not present */
563 ProcessInfo *process_info;
564 Drawing_t *drawing = control_flow_data->drawing;
565 processlist_add(process_list,
566 drawing,
567 pid_out,
568 process->tgid,
569 process->cpu,
570 process->ppid,
571 &birth,
572 trace_num,
573 process->name,
574 process->brand,
575 &pl_height,
576 &process_info,
577 &hashed_process_data);
578 gtk_widget_set_size_request(drawing->drawing_area,
579 -1,
580 pl_height);
581 gtk_widget_queue_draw(drawing->drawing_area);
582
583 }
584
585 /* Now, the process is in the state hash and our own process hash.
586 * We definitely can draw the items related to the ending state.
587 */
588
589 if(ltt_time_compare(hashed_process_data->next_good_time,
590 evtime) > 0)
591 {
592 if(hashed_process_data->x.middle_marked == FALSE) {
593
594 TimeWindow time_window =
595 lttvwindow_get_time_window(control_flow_data->tab);
596 #ifdef EXTRA_CHECK
597 if(ltt_time_compare(evtime, time_window.start_time) == -1
598 || ltt_time_compare(evtime, time_window.end_time) == 1)
599 return FALSE;
600 #endif //EXTRA_CHECK
601 Drawing_t *drawing = control_flow_data->drawing;
602 guint width = drawing->width;
603 guint x;
604 convert_time_to_pixels(
605 time_window,
606 evtime,
607 width,
608 &x);
609
610 /* Draw collision indicator */
611 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
612 gdk_draw_point(hashed_process_data->pixmap,
613 drawing->gc,
614 x,
615 COLLISION_POSITION(hashed_process_data->height));
616 hashed_process_data->x.middle_marked = TRUE;
617 }
618 } else {
619 TimeWindow time_window =
620 lttvwindow_get_time_window(control_flow_data->tab);
621 #ifdef EXTRA_CHECK
622 if(ltt_time_compare(evtime, time_window.start_time) == -1
623 || ltt_time_compare(evtime, time_window.end_time) == 1)
624 return FALSE;
625 #endif //EXTRA_CHECK
626 Drawing_t *drawing = control_flow_data->drawing;
627 guint width = drawing->width;
628 guint x;
629 convert_time_to_pixels(
630 time_window,
631 evtime,
632 width,
633 &x);
634
635
636 /* Jump over draw if we are at the same x position */
637 if(x == hashed_process_data->x.middle &&
638 hashed_process_data->x.middle_used)
639 {
640 if(hashed_process_data->x.middle_marked == FALSE) {
641 /* Draw collision indicator */
642 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
643 gdk_draw_point(hashed_process_data->pixmap,
644 drawing->gc,
645 x,
646 COLLISION_POSITION(hashed_process_data->height));
647 hashed_process_data->x.middle_marked = TRUE;
648 }
649 /* jump */
650 } else {
651 DrawContext draw_context;
652
653 /* Now create the drawing context that will be used to draw
654 * items related to the last state. */
655 draw_context.drawable = hashed_process_data->pixmap;
656 draw_context.gc = drawing->gc;
657 draw_context.pango_layout = drawing->pango_layout;
658 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
659 draw_context.drawinfo.end.x = x;
660
661 draw_context.drawinfo.y.over = 1;
662 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
663 draw_context.drawinfo.y.under = hashed_process_data->height;
664
665 draw_context.drawinfo.start.offset.over = 0;
666 draw_context.drawinfo.start.offset.middle = 0;
667 draw_context.drawinfo.start.offset.under = 0;
668 draw_context.drawinfo.end.offset.over = 0;
669 draw_context.drawinfo.end.offset.middle = 0;
670 draw_context.drawinfo.end.offset.under = 0;
671
672 {
673 /* Draw the line */
674 PropertiesLine prop_line = prepare_s_e_line(process);
675 draw_line((void*)&prop_line, (void*)&draw_context);
676
677 }
678 /* become the last x position */
679 hashed_process_data->x.middle = x;
680 hashed_process_data->x.middle_used = TRUE;
681 hashed_process_data->x.middle_marked = FALSE;
682
683 /* Calculate the next good time */
684 convert_pixels_to_time(width, x+1, time_window,
685 &hashed_process_data->next_good_time);
686 }
687 }
688 }
689 }
690
691 tfc->target_pid = pid_in;
692 if(!filter || !filter->head ||
693 lttv_filter_tree_parse(filter->head,e,tfc->tf,
694 tfc->t_context->t,tfc,NULL,NULL)) {
695 /* For the pid_in */
696 /* First, check if the current process is in the state computation
697 * process list. If it is there, that means we must add it right now and
698 * draw items from the beginning of the read for it. If it is not
699 * present, it's a new process and it was not present : it will
700 * be added after the state update. */
701 LttvProcessState *process;
702 process = lttv_state_find_process(ts,
703 tfs->cpu, pid_in);
704 guint trace_num = ts->parent.index;
705
706 if(process != NULL) {
707 /* Well, the process existed : we must get it in the process hash
708 * or add it, and draw its items.
709 */
710 /* Add process to process list (if not present) */
711 guint pl_height = 0;
712 HashedProcessData *hashed_process_data = NULL;
713 ProcessList *process_list = control_flow_data->process_list;
714 LttTime birth = process->creation_time;
715
716 hashed_process_data = processlist_get_process_data(process_list,
717 pid_in,
718 tfs->cpu,
719 &birth,
720 trace_num);
721 if(hashed_process_data == NULL)
722 {
723 g_assert(pid_in == 0 || pid_in != process->ppid);
724 /* Process not present */
725 ProcessInfo *process_info;
726 Drawing_t *drawing = control_flow_data->drawing;
727 processlist_add(process_list,
728 drawing,
729 pid_in,
730 process->tgid,
731 tfs->cpu,
732 process->ppid,
733 &birth,
734 trace_num,
735 process->name,
736 process->brand,
737 &pl_height,
738 &process_info,
739 &hashed_process_data);
740 gtk_widget_set_size_request(drawing->drawing_area,
741 -1,
742 pl_height);
743 gtk_widget_queue_draw(drawing->drawing_area);
744
745 }
746 //We could set the current process and hash here, but will be done
747 //by after schedchange hook
748
749 /* Now, the process is in the state hash and our own process hash.
750 * We definitely can draw the items related to the ending state.
751 */
752
753 if(ltt_time_compare(hashed_process_data->next_good_time,
754 evtime) > 0)
755 {
756 if(hashed_process_data->x.middle_marked == FALSE) {
757
758 TimeWindow time_window =
759 lttvwindow_get_time_window(control_flow_data->tab);
760 #ifdef EXTRA_CHECK
761 if(ltt_time_compare(evtime, time_window.start_time) == -1
762 || ltt_time_compare(evtime, time_window.end_time) == 1)
763 return FALSE;
764 #endif //EXTRA_CHECK
765 Drawing_t *drawing = control_flow_data->drawing;
766 guint width = drawing->width;
767 guint x;
768 convert_time_to_pixels(
769 time_window,
770 evtime,
771 width,
772 &x);
773
774 /* Draw collision indicator */
775 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
776 gdk_draw_point(hashed_process_data->pixmap,
777 drawing->gc,
778 x,
779 COLLISION_POSITION(hashed_process_data->height));
780 hashed_process_data->x.middle_marked = TRUE;
781 }
782 } else {
783 TimeWindow time_window =
784 lttvwindow_get_time_window(control_flow_data->tab);
785 #ifdef EXTRA_CHECK
786 if(ltt_time_compare(evtime, time_window.start_time) == -1
787 || ltt_time_compare(evtime, time_window.end_time) == 1)
788 return FALSE;
789 #endif //EXTRA_CHECK
790 Drawing_t *drawing = control_flow_data->drawing;
791 guint width = drawing->width;
792 guint x;
793
794 convert_time_to_pixels(
795 time_window,
796 evtime,
797 width,
798 &x);
799
800
801 /* Jump over draw if we are at the same x position */
802 if(x == hashed_process_data->x.middle &&
803 hashed_process_data->x.middle_used)
804 {
805 if(hashed_process_data->x.middle_marked == FALSE) {
806 /* Draw collision indicator */
807 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
808 gdk_draw_point(hashed_process_data->pixmap,
809 drawing->gc,
810 x,
811 COLLISION_POSITION(hashed_process_data->height));
812 hashed_process_data->x.middle_marked = TRUE;
813 }
814 /* jump */
815 } else {
816 DrawContext draw_context;
817
818 /* Now create the drawing context that will be used to draw
819 * items related to the last state. */
820 draw_context.drawable = hashed_process_data->pixmap;
821 draw_context.gc = drawing->gc;
822 draw_context.pango_layout = drawing->pango_layout;
823 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
824 draw_context.drawinfo.end.x = x;
825
826 draw_context.drawinfo.y.over = 1;
827 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
828 draw_context.drawinfo.y.under = hashed_process_data->height;
829
830 draw_context.drawinfo.start.offset.over = 0;
831 draw_context.drawinfo.start.offset.middle = 0;
832 draw_context.drawinfo.start.offset.under = 0;
833 draw_context.drawinfo.end.offset.over = 0;
834 draw_context.drawinfo.end.offset.middle = 0;
835 draw_context.drawinfo.end.offset.under = 0;
836
837 {
838 /* Draw the line */
839 PropertiesLine prop_line = prepare_s_e_line(process);
840 draw_line((void*)&prop_line, (void*)&draw_context);
841 }
842
843
844 /* become the last x position */
845 hashed_process_data->x.middle = x;
846 hashed_process_data->x.middle_used = TRUE;
847 hashed_process_data->x.middle_marked = FALSE;
848
849 /* Calculate the next good time */
850 convert_pixels_to_time(width, x+1, time_window,
851 &hashed_process_data->next_good_time);
852 }
853 }
854 } else
855 g_warning("Cannot find pin_in in schedchange %u", pid_in);
856 }
857 tfc->target_pid = target_pid_saved;
858 return 0;
859
860
861
862
863 /* Text dump */
864 #ifdef DONTSHOW
865 GString *string = g_string_new("");;
866 gboolean field_names = TRUE, state = TRUE;
867
868 lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs);
869 g_string_append_printf(string,"\n");
870
871 if(state) {
872 g_string_append_printf(string, " %s",
873 g_quark_to_string(tfs->process->state->s));
874 }
875
876 g_info("%s",string->str);
877
878 g_string_free(string, TRUE);
879
880 /* End of text dump */
881 #endif //DONTSHOW
882
883 }
884
885 /* after_schedchange_hook
886 *
887 * The draw after hook is called by the reading API to have a
888 * particular event drawn on the screen.
889 * @param hook_data ControlFlowData structure of the viewer.
890 * @param call_data Event context.
891 *
892 * This function adds items to be drawn in a queue for each process.
893 *
894 */
895 int after_schedchange_hook(void *hook_data, void *call_data)
896 {
897 LttvTraceHook *th = (LttvTraceHook*)hook_data;
898 EventsRequest *events_request = (EventsRequest*)th->hook_data;
899 ControlFlowData *control_flow_data = events_request->viewer_data;
900
901 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
902
903 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
904
905 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
906
907 LttEvent *e;
908 e = ltt_tracefile_get_event(tfc->tf);
909
910 LttvFilter *filter = control_flow_data->filter;
911 LttTime evtime = ltt_event_time(e);
912
913 /* Add process to process list (if not present) */
914 LttvProcessState *process_in;
915 LttTime birth;
916 guint pl_height = 0;
917 HashedProcessData *hashed_process_data_in = NULL;
918
919 ProcessList *process_list = control_flow_data->process_list;
920
921 guint pid_in;
922 {
923 guint pid_out;
924 pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
925 pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
926 }
927
928 tfc->target_pid = pid_in;
929 if(!filter || !filter->head ||
930 lttv_filter_tree_parse(filter->head,e,tfc->tf,
931 tfc->t_context->t,tfc,NULL,NULL)) {
932 /* Find process pid_in in the list... */
933 //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
934 //process_in = tfs->process;
935 guint cpu = tfs->cpu;
936 guint trace_num = ts->parent.index;
937 process_in = ts->running_process[cpu];
938 /* It should exist, because we are after the state update. */
939 #ifdef EXTRA_CHECK
940 g_assert(process_in != NULL);
941 #endif //EXTRA_CHECK
942 birth = process_in->creation_time;
943
944 hashed_process_data_in = processlist_get_process_data(process_list,
945 pid_in,
946 process_in->cpu,
947 &birth,
948 trace_num);
949 if(hashed_process_data_in == NULL)
950 {
951 g_assert(pid_in == 0 || pid_in != process_in->ppid);
952 ProcessInfo *process_info;
953 Drawing_t *drawing = control_flow_data->drawing;
954 /* Process not present */
955 processlist_add(process_list,
956 drawing,
957 pid_in,
958 process_in->tgid,
959 process_in->cpu,
960 process_in->ppid,
961 &birth,
962 trace_num,
963 process_in->name,
964 process_in->brand,
965 &pl_height,
966 &process_info,
967 &hashed_process_data_in);
968 gtk_widget_set_size_request(drawing->drawing_area,
969 -1,
970 pl_height);
971 gtk_widget_queue_draw(drawing->drawing_area);
972 }
973 /* Set the current process */
974 process_list->current_hash_data[trace_num][process_in->cpu] =
975 hashed_process_data_in;
976
977 if(ltt_time_compare(hashed_process_data_in->next_good_time,
978 evtime) <= 0)
979 {
980 TimeWindow time_window =
981 lttvwindow_get_time_window(control_flow_data->tab);
982
983 #ifdef EXTRA_CHECK
984 if(ltt_time_compare(evtime, time_window.start_time) == -1
985 || ltt_time_compare(evtime, time_window.end_time) == 1)
986 return FALSE;
987 #endif //EXTRA_CHECK
988 Drawing_t *drawing = control_flow_data->drawing;
989 guint width = drawing->width;
990 guint new_x;
991
992 convert_time_to_pixels(
993 time_window,
994 evtime,
995 width,
996 &new_x);
997
998 if(hashed_process_data_in->x.middle != new_x) {
999 hashed_process_data_in->x.middle = new_x;
1000 hashed_process_data_in->x.middle_used = FALSE;
1001 hashed_process_data_in->x.middle_marked = FALSE;
1002 }
1003 }
1004 }
1005
1006 return 0;
1007 }
1008
1009
1010
1011
1012 /* before_execmode_hook
1013 *
1014 * This function basically draw lines and icons. Two types of lines are drawn :
1015 * one small (3 pixels?) representing the state of the process and the second
1016 * type is thicker (10 pixels?) representing on which CPU a process is running
1017 * (and this only in running state).
1018 *
1019 * Extremums of the lines :
1020 * x_min : time of the last event context for this process kept in memory.
1021 * x_max : time of the current event.
1022 * y : middle of the process in the process list. The process is found in the
1023 * list, therefore is it's position in pixels.
1024 *
1025 * The choice of lines'color is defined by the context of the last event for this
1026 * process.
1027 */
1028
1029
1030 int before_execmode_hook(void *hook_data, void *call_data)
1031 {
1032 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1033 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1034 ControlFlowData *control_flow_data = events_request->viewer_data;
1035
1036 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1037
1038 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1039
1040 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1041
1042 LttEvent *e;
1043 e = ltt_tracefile_get_event(tfc->tf);
1044
1045 LttvFilter *filter = control_flow_data->filter;
1046 if(filter != NULL && filter->head != NULL)
1047 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1048 tfc->t_context->t,tfc,NULL,NULL))
1049 return FALSE;
1050
1051 LttTime evtime = ltt_event_time(e);
1052
1053 /* we are in a execmode, before the state update. We must draw the
1054 * items corresponding to the state before it changes : now is the right
1055 * time to do it.
1056 */
1057 /* For the pid */
1058 //LttvProcessState *process = tfs->process;
1059 guint cpu = tfs->cpu;
1060 guint trace_num = ts->parent.index;
1061 LttvProcessState *process = ts->running_process[cpu];
1062 g_assert(process != NULL);
1063
1064 guint pid = process->pid;
1065
1066 /* Well, the process_out existed : we must get it in the process hash
1067 * or add it, and draw its items.
1068 */
1069 /* Add process to process list (if not present) */
1070 guint pl_height = 0;
1071 HashedProcessData *hashed_process_data = NULL;
1072 ProcessList *process_list = control_flow_data->process_list;
1073 LttTime birth = process->creation_time;
1074
1075 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1076 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1077 } else {
1078 hashed_process_data = processlist_get_process_data(process_list,
1079 pid,
1080 process->cpu,
1081 &birth,
1082 trace_num);
1083 if(unlikely(hashed_process_data == NULL))
1084 {
1085 g_assert(pid == 0 || pid != process->ppid);
1086 ProcessInfo *process_info;
1087 /* Process not present */
1088 Drawing_t *drawing = control_flow_data->drawing;
1089 processlist_add(process_list,
1090 drawing,
1091 pid,
1092 process->tgid,
1093 process->cpu,
1094 process->ppid,
1095 &birth,
1096 trace_num,
1097 process->name,
1098 process->brand,
1099 &pl_height,
1100 &process_info,
1101 &hashed_process_data);
1102 gtk_widget_set_size_request(drawing->drawing_area,
1103 -1,
1104 pl_height);
1105 gtk_widget_queue_draw(drawing->drawing_area);
1106 }
1107 /* Set the current process */
1108 process_list->current_hash_data[trace_num][process->cpu] =
1109 hashed_process_data;
1110 }
1111
1112 /* Now, the process is in the state hash and our own process hash.
1113 * We definitely can draw the items related to the ending state.
1114 */
1115
1116 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1117 evtime) > 0))
1118 {
1119 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1120 TimeWindow time_window =
1121 lttvwindow_get_time_window(control_flow_data->tab);
1122
1123 #ifdef EXTRA_CHECK
1124 if(ltt_time_compare(evtime, time_window.start_time) == -1
1125 || ltt_time_compare(evtime, time_window.end_time) == 1)
1126 return FALSE;
1127 #endif //EXTRA_CHECK
1128 Drawing_t *drawing = control_flow_data->drawing;
1129 guint width = drawing->width;
1130 guint x;
1131 convert_time_to_pixels(
1132 time_window,
1133 evtime,
1134 width,
1135 &x);
1136
1137 /* Draw collision indicator */
1138 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1139 gdk_draw_point(hashed_process_data->pixmap,
1140 drawing->gc,
1141 x,
1142 COLLISION_POSITION(hashed_process_data->height));
1143 hashed_process_data->x.middle_marked = TRUE;
1144 }
1145 } else {
1146 TimeWindow time_window =
1147 lttvwindow_get_time_window(control_flow_data->tab);
1148
1149 #ifdef EXTRA_CHECK
1150 if(ltt_time_compare(evtime, time_window.start_time) == -1
1151 || ltt_time_compare(evtime, time_window.end_time) == 1)
1152 return FALSE;
1153 #endif //EXTRA_CHECK
1154 Drawing_t *drawing = control_flow_data->drawing;
1155 guint width = drawing->width;
1156 guint x;
1157
1158 convert_time_to_pixels(
1159 time_window,
1160 evtime,
1161 width,
1162 &x);
1163
1164
1165 /* Jump over draw if we are at the same x position */
1166 if(unlikely(x == hashed_process_data->x.middle &&
1167 hashed_process_data->x.middle_used))
1168 {
1169 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1170 /* Draw collision indicator */
1171 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1172 gdk_draw_point(hashed_process_data->pixmap,
1173 drawing->gc,
1174 x,
1175 COLLISION_POSITION(hashed_process_data->height));
1176 hashed_process_data->x.middle_marked = TRUE;
1177 }
1178 /* jump */
1179 } else {
1180
1181 DrawContext draw_context;
1182 /* Now create the drawing context that will be used to draw
1183 * items related to the last state. */
1184 draw_context.drawable = hashed_process_data->pixmap;
1185 draw_context.gc = drawing->gc;
1186 draw_context.pango_layout = drawing->pango_layout;
1187 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1188 draw_context.drawinfo.end.x = x;
1189
1190 draw_context.drawinfo.y.over = 1;
1191 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1192 draw_context.drawinfo.y.under = hashed_process_data->height;
1193
1194 draw_context.drawinfo.start.offset.over = 0;
1195 draw_context.drawinfo.start.offset.middle = 0;
1196 draw_context.drawinfo.start.offset.under = 0;
1197 draw_context.drawinfo.end.offset.over = 0;
1198 draw_context.drawinfo.end.offset.middle = 0;
1199 draw_context.drawinfo.end.offset.under = 0;
1200
1201 {
1202 /* Draw the line */
1203 PropertiesLine prop_line = prepare_s_e_line(process);
1204 draw_line((void*)&prop_line, (void*)&draw_context);
1205
1206 }
1207 /* become the last x position */
1208 hashed_process_data->x.middle = x;
1209 hashed_process_data->x.middle_used = TRUE;
1210 hashed_process_data->x.middle_marked = FALSE;
1211
1212 /* Calculate the next good time */
1213 convert_pixels_to_time(width, x+1, time_window,
1214 &hashed_process_data->next_good_time);
1215 }
1216 }
1217
1218 return 0;
1219 }
1220
1221 /* before_process_exit_hook
1222 *
1223 * Draw lines for process event.
1224 *
1225 * @param hook_data ControlFlowData structure of the viewer.
1226 * @param call_data Event context.
1227 *
1228 * This function adds items to be drawn in a queue for each process.
1229 *
1230 */
1231
1232
1233 int before_process_exit_hook(void *hook_data, void *call_data)
1234 {
1235 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1236 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1237
1238 ControlFlowData *control_flow_data = events_request->viewer_data;
1239
1240 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1241
1242 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1243
1244 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1245
1246 LttEvent *e;
1247 e = ltt_tracefile_get_event(tfc->tf);
1248
1249 LttvFilter *filter = control_flow_data->filter;
1250 if(filter != NULL && filter->head != NULL)
1251 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1252 tfc->t_context->t,tfc,NULL,NULL))
1253 return FALSE;
1254
1255 LttTime evtime = ltt_event_time(e);
1256
1257 /* Add process to process list (if not present) */
1258 //LttvProcessState *process = tfs->process;
1259 guint cpu = tfs->cpu;
1260 guint trace_num = ts->parent.index;
1261 LttvProcessState *process = ts->running_process[cpu];
1262 guint pid = process->pid;
1263 LttTime birth;
1264 guint pl_height = 0;
1265 HashedProcessData *hashed_process_data = NULL;
1266
1267 ProcessList *process_list = control_flow_data->process_list;
1268
1269 g_assert(process != NULL);
1270
1271 birth = process->creation_time;
1272
1273 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1274 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1275 } else {
1276 hashed_process_data = processlist_get_process_data(process_list,
1277 pid,
1278 process->cpu,
1279 &birth,
1280 trace_num);
1281 if(unlikely(hashed_process_data == NULL))
1282 {
1283 g_assert(pid == 0 || pid != process->ppid);
1284 /* Process not present */
1285 Drawing_t *drawing = control_flow_data->drawing;
1286 ProcessInfo *process_info;
1287 processlist_add(process_list,
1288 drawing,
1289 pid,
1290 process->tgid,
1291 process->cpu,
1292 process->ppid,
1293 &birth,
1294 trace_num,
1295 process->name,
1296 process->brand,
1297 &pl_height,
1298 &process_info,
1299 &hashed_process_data);
1300 gtk_widget_set_size_request(drawing->drawing_area,
1301 -1,
1302 pl_height);
1303 gtk_widget_queue_draw(drawing->drawing_area);
1304 }
1305 }
1306
1307 /* Now, the process is in the state hash and our own process hash.
1308 * We definitely can draw the items related to the ending state.
1309 */
1310
1311 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1312 evtime) > 0))
1313 {
1314 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1315 TimeWindow time_window =
1316 lttvwindow_get_time_window(control_flow_data->tab);
1317
1318 #ifdef EXTRA_CHECK
1319 if(ltt_time_compare(evtime, time_window.start_time) == -1
1320 || ltt_time_compare(evtime, time_window.end_time) == 1)
1321 return FALSE;
1322 #endif //EXTRA_CHECK
1323 Drawing_t *drawing = control_flow_data->drawing;
1324 guint width = drawing->width;
1325 guint x;
1326 convert_time_to_pixels(
1327 time_window,
1328 evtime,
1329 width,
1330 &x);
1331
1332 /* Draw collision indicator */
1333 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1334 gdk_draw_point(hashed_process_data->pixmap,
1335 drawing->gc,
1336 x,
1337 COLLISION_POSITION(hashed_process_data->height));
1338 hashed_process_data->x.middle_marked = TRUE;
1339 }
1340 } else {
1341 TimeWindow time_window =
1342 lttvwindow_get_time_window(control_flow_data->tab);
1343
1344 #ifdef EXTRA_CHECK
1345 if(ltt_time_compare(evtime, time_window.start_time) == -1
1346 || ltt_time_compare(evtime, time_window.end_time) == 1)
1347 return FALSE;
1348 #endif //EXTRA_CHECK
1349 Drawing_t *drawing = control_flow_data->drawing;
1350 guint width = drawing->width;
1351 guint x;
1352
1353 convert_time_to_pixels(
1354 time_window,
1355 evtime,
1356 width,
1357 &x);
1358
1359
1360 /* Jump over draw if we are at the same x position */
1361 if(unlikely(x == hashed_process_data->x.middle &&
1362 hashed_process_data->x.middle_used))
1363 {
1364 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1365 /* Draw collision indicator */
1366 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1367 gdk_draw_point(hashed_process_data->pixmap,
1368 drawing->gc,
1369 x,
1370 COLLISION_POSITION(hashed_process_data->height));
1371 hashed_process_data->x.middle_marked = TRUE;
1372 }
1373 /* jump */
1374 } else {
1375 DrawContext draw_context;
1376
1377 /* Now create the drawing context that will be used to draw
1378 * items related to the last state. */
1379 draw_context.drawable = hashed_process_data->pixmap;
1380 draw_context.gc = drawing->gc;
1381 draw_context.pango_layout = drawing->pango_layout;
1382 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1383 draw_context.drawinfo.end.x = x;
1384
1385 draw_context.drawinfo.y.over = 1;
1386 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1387 draw_context.drawinfo.y.under = hashed_process_data->height;
1388
1389 draw_context.drawinfo.start.offset.over = 0;
1390 draw_context.drawinfo.start.offset.middle = 0;
1391 draw_context.drawinfo.start.offset.under = 0;
1392 draw_context.drawinfo.end.offset.over = 0;
1393 draw_context.drawinfo.end.offset.middle = 0;
1394 draw_context.drawinfo.end.offset.under = 0;
1395
1396 {
1397 /* Draw the line */
1398 PropertiesLine prop_line = prepare_s_e_line(process);
1399 draw_line((void*)&prop_line, (void*)&draw_context);
1400
1401 }
1402 /* become the last x position */
1403 hashed_process_data->x.middle = x;
1404 hashed_process_data->x.middle_used = TRUE;
1405 hashed_process_data->x.middle_marked = FALSE;
1406
1407 /* Calculate the next good time */
1408 convert_pixels_to_time(width, x+1, time_window,
1409 &hashed_process_data->next_good_time);
1410 }
1411 }
1412
1413 return 0;
1414
1415 }
1416
1417
1418
1419 /* before_process_release_hook
1420 *
1421 * Draw lines for process event.
1422 *
1423 * @param hook_data ControlFlowData structure of the viewer.
1424 * @param call_data Event context.
1425 *
1426 * This function adds items to be drawn in a queue for each process.
1427 *
1428 */
1429
1430
1431 int before_process_release_hook(void *hook_data, void *call_data)
1432 {
1433 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1434 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1435
1436 ControlFlowData *control_flow_data = events_request->viewer_data;
1437
1438 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1439
1440 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1441
1442 LttEvent *e;
1443 e = ltt_tracefile_get_event(tfc->tf);
1444
1445 LttvFilter *filter = control_flow_data->filter;
1446 if(filter != NULL && filter->head != NULL)
1447 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1448 tfc->t_context->t,tfc,NULL,NULL))
1449 return FALSE;
1450
1451 LttTime evtime = ltt_event_time(e);
1452
1453 guint trace_num = ts->parent.index;
1454
1455 guint pid;
1456 {
1457 pid = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
1458 }
1459
1460 /* Add process to process list (if not present) */
1461 /* Don't care about the process if it's not in the state hash already :
1462 * that means a process that has never done anything in the trace and
1463 * unknown suddently gets destroyed : no state meaningful to show. */
1464 LttvProcessState *process = lttv_state_find_process(ts, ANY_CPU, pid);
1465
1466 if(process != NULL) {
1467 LttTime birth;
1468 HashedProcessData *hashed_process_data = NULL;
1469
1470 ProcessList *process_list = control_flow_data->process_list;
1471
1472 birth = process->creation_time;
1473
1474 /* Cannot use current process : this event happens on another process,
1475 * action done by the parent. */
1476 hashed_process_data = processlist_get_process_data(process_list,
1477 pid,
1478 process->cpu,
1479 &birth,
1480 trace_num);
1481 if(unlikely(hashed_process_data == NULL))
1482 /*
1483 * Process already been scheduled out EXIT_DEAD, not in the process list
1484 * anymore. Just return.
1485 */
1486 return FALSE;
1487
1488 /* Now, the process is in the state hash and our own process hash.
1489 * We definitely can draw the items related to the ending state.
1490 */
1491
1492 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1493 evtime) > 0))
1494 {
1495 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1496 TimeWindow time_window =
1497 lttvwindow_get_time_window(control_flow_data->tab);
1498
1499 #ifdef EXTRA_CHECK
1500 if(ltt_time_compare(evtime, time_window.start_time) == -1
1501 || ltt_time_compare(evtime, time_window.end_time) == 1)
1502 return FALSE;
1503 #endif //EXTRA_CHECK
1504 Drawing_t *drawing = control_flow_data->drawing;
1505 guint width = drawing->width;
1506 guint x;
1507 convert_time_to_pixels(
1508 time_window,
1509 evtime,
1510 width,
1511 &x);
1512
1513 /* Draw collision indicator */
1514 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1515 gdk_draw_point(hashed_process_data->pixmap,
1516 drawing->gc,
1517 x,
1518 COLLISION_POSITION(hashed_process_data->height));
1519 hashed_process_data->x.middle_marked = TRUE;
1520 }
1521 } else {
1522 TimeWindow time_window =
1523 lttvwindow_get_time_window(control_flow_data->tab);
1524
1525 #ifdef EXTRA_CHECK
1526 if(ltt_time_compare(evtime, time_window.start_time) == -1
1527 || ltt_time_compare(evtime, time_window.end_time) == 1)
1528 return FALSE;
1529 #endif //EXTRA_CHECK
1530 Drawing_t *drawing = control_flow_data->drawing;
1531 guint width = drawing->width;
1532 guint x;
1533
1534 convert_time_to_pixels(
1535 time_window,
1536 evtime,
1537 width,
1538 &x);
1539
1540
1541 /* Jump over draw if we are at the same x position */
1542 if(unlikely(x == hashed_process_data->x.middle &&
1543 hashed_process_data->x.middle_used))
1544 {
1545 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1546 /* Draw collision indicator */
1547 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1548 gdk_draw_point(hashed_process_data->pixmap,
1549 drawing->gc,
1550 x,
1551 COLLISION_POSITION(hashed_process_data->height));
1552 hashed_process_data->x.middle_marked = TRUE;
1553 }
1554 /* jump */
1555 } else {
1556 DrawContext draw_context;
1557
1558 /* Now create the drawing context that will be used to draw
1559 * items related to the last state. */
1560 draw_context.drawable = hashed_process_data->pixmap;
1561 draw_context.gc = drawing->gc;
1562 draw_context.pango_layout = drawing->pango_layout;
1563 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1564 draw_context.drawinfo.end.x = x;
1565
1566 draw_context.drawinfo.y.over = 1;
1567 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1568 draw_context.drawinfo.y.under = hashed_process_data->height;
1569
1570 draw_context.drawinfo.start.offset.over = 0;
1571 draw_context.drawinfo.start.offset.middle = 0;
1572 draw_context.drawinfo.start.offset.under = 0;
1573 draw_context.drawinfo.end.offset.over = 0;
1574 draw_context.drawinfo.end.offset.middle = 0;
1575 draw_context.drawinfo.end.offset.under = 0;
1576
1577 {
1578 /* Draw the line */
1579 PropertiesLine prop_line = prepare_s_e_line(process);
1580 draw_line((void*)&prop_line, (void*)&draw_context);
1581
1582 }
1583 /* become the last x position */
1584 hashed_process_data->x.middle = x;
1585 hashed_process_data->x.middle_used = TRUE;
1586 hashed_process_data->x.middle_marked = FALSE;
1587
1588 /* Calculate the next good time */
1589 convert_pixels_to_time(width, x+1, time_window,
1590 &hashed_process_data->next_good_time);
1591 }
1592 }
1593 }
1594
1595 return 0;
1596 }
1597
1598
1599
1600
1601
1602 /* after_process_fork_hook
1603 *
1604 * Create the processlist entry for the child process. Put the last
1605 * position in x at the current time value.
1606 *
1607 * @param hook_data ControlFlowData structure of the viewer.
1608 * @param call_data Event context.
1609 *
1610 * This function adds items to be drawn in a queue for each process.
1611 *
1612 */
1613 int after_process_fork_hook(void *hook_data, void *call_data)
1614 {
1615 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1616 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1617 ControlFlowData *control_flow_data = events_request->viewer_data;
1618
1619 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1620
1621 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1622
1623 LttEvent *e;
1624 e = ltt_tracefile_get_event(tfc->tf);
1625
1626 LttvFilter *filter = control_flow_data->filter;
1627 if(filter != NULL && filter->head != NULL)
1628 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1629 tfc->t_context->t,tfc,NULL,NULL))
1630 return FALSE;
1631
1632 LttTime evtime = ltt_event_time(e);
1633
1634 guint child_pid;
1635 {
1636 child_pid = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1));
1637 }
1638
1639 /* Add process to process list (if not present) */
1640 LttvProcessState *process_child;
1641 LttTime birth;
1642 guint pl_height = 0;
1643 HashedProcessData *hashed_process_data_child = NULL;
1644
1645 ProcessList *process_list = control_flow_data->process_list;
1646
1647 /* Find child in the list... */
1648 process_child = lttv_state_find_process(ts, ANY_CPU, child_pid);
1649 /* It should exist, because we are after the state update. */
1650 g_assert(process_child != NULL);
1651
1652 birth = process_child->creation_time;
1653 guint trace_num = ts->parent.index;
1654
1655 /* Cannot use current process, because this action is done by the parent
1656 * on its child. */
1657 hashed_process_data_child = processlist_get_process_data(process_list,
1658 child_pid,
1659 process_child->cpu,
1660 &birth,
1661 trace_num);
1662 if(likely(hashed_process_data_child == NULL))
1663 {
1664 g_assert(child_pid == 0 || child_pid != process_child->ppid);
1665 /* Process not present */
1666 Drawing_t *drawing = control_flow_data->drawing;
1667 ProcessInfo *process_info;
1668 processlist_add(process_list,
1669 drawing,
1670 child_pid,
1671 process_child->tgid,
1672 process_child->cpu,
1673 process_child->ppid,
1674 &birth,
1675 trace_num,
1676 process_child->name,
1677 process_child->brand,
1678 &pl_height,
1679 &process_info,
1680 &hashed_process_data_child);
1681 gtk_widget_set_size_request(drawing->drawing_area,
1682 -1,
1683 pl_height);
1684 gtk_widget_queue_draw(drawing->drawing_area);
1685 } else {
1686 processlist_set_ppid(process_list, process_child->ppid,
1687 hashed_process_data_child);
1688 processlist_set_tgid(process_list, process_child->tgid,
1689 hashed_process_data_child);
1690 }
1691
1692
1693 if(likely(ltt_time_compare(hashed_process_data_child->next_good_time,
1694 evtime) <= 0))
1695 {
1696 TimeWindow time_window =
1697 lttvwindow_get_time_window(control_flow_data->tab);
1698
1699 #ifdef EXTRA_CHECK
1700 if(ltt_time_compare(evtime, time_window.start_time) == -1
1701 || ltt_time_compare(evtime, time_window.end_time) == 1)
1702 return FALSE;
1703 #endif //EXTRA_CHECK
1704 Drawing_t *drawing = control_flow_data->drawing;
1705 guint width = drawing->width;
1706 guint new_x;
1707 convert_time_to_pixels(
1708 time_window,
1709 evtime,
1710 width,
1711 &new_x);
1712
1713 if(likely(hashed_process_data_child->x.over != new_x)) {
1714 hashed_process_data_child->x.over = new_x;
1715 hashed_process_data_child->x.over_used = FALSE;
1716 hashed_process_data_child->x.over_marked = FALSE;
1717 }
1718 if(likely(hashed_process_data_child->x.middle != new_x)) {
1719 hashed_process_data_child->x.middle = new_x;
1720 hashed_process_data_child->x.middle_used = FALSE;
1721 hashed_process_data_child->x.middle_marked = FALSE;
1722 }
1723 if(likely(hashed_process_data_child->x.under != new_x)) {
1724 hashed_process_data_child->x.under = new_x;
1725 hashed_process_data_child->x.under_used = FALSE;
1726 hashed_process_data_child->x.under_marked = FALSE;
1727 }
1728 }
1729 return FALSE;
1730 }
1731
1732
1733
1734 /* after_process_exit_hook
1735 *
1736 * Create the processlist entry for the child process. Put the last
1737 * position in x at the current time value.
1738 *
1739 * @param hook_data ControlFlowData structure of the viewer.
1740 * @param call_data Event context.
1741 *
1742 * This function adds items to be drawn in a queue for each process.
1743 *
1744 */
1745 int after_process_exit_hook(void *hook_data, void *call_data)
1746 {
1747 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1748 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1749 ControlFlowData *control_flow_data = events_request->viewer_data;
1750
1751 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1752
1753 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1754
1755 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1756
1757 LttEvent *e;
1758 e = ltt_tracefile_get_event(tfc->tf);
1759
1760 LttvFilter *filter = control_flow_data->filter;
1761 if(filter != NULL && filter->head != NULL)
1762 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1763 tfc->t_context->t,tfc,NULL,NULL))
1764 return FALSE;
1765
1766 LttTime evtime = ltt_event_time(e);
1767
1768 /* Add process to process list (if not present) */
1769 //LttvProcessState *process = tfs->process;
1770 guint cpu = tfs->cpu;
1771 guint trace_num = ts->parent.index;
1772 LttvProcessState *process = ts->running_process[cpu];
1773
1774 /* It should exist, because we are after the state update. */
1775 g_assert(process != NULL);
1776
1777 guint pid = process->pid;
1778 LttTime birth;
1779 guint pl_height = 0;
1780 HashedProcessData *hashed_process_data = NULL;
1781
1782 ProcessList *process_list = control_flow_data->process_list;
1783
1784 birth = process->creation_time;
1785
1786 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){
1787 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1788 } else {
1789 hashed_process_data = processlist_get_process_data(process_list,
1790 pid,
1791 process->cpu,
1792 &birth,
1793 trace_num);
1794 if(unlikely(hashed_process_data == NULL))
1795 {
1796 g_assert(pid == 0 || pid != process->ppid);
1797 /* Process not present */
1798 Drawing_t *drawing = control_flow_data->drawing;
1799 ProcessInfo *process_info;
1800 processlist_add(process_list,
1801 drawing,
1802 pid,
1803 process->tgid,
1804 process->cpu,
1805 process->ppid,
1806 &birth,
1807 trace_num,
1808 process->name,
1809 process->brand,
1810 &pl_height,
1811 &process_info,
1812 &hashed_process_data);
1813 gtk_widget_set_size_request(drawing->drawing_area,
1814 -1,
1815 pl_height);
1816 gtk_widget_queue_draw(drawing->drawing_area);
1817 }
1818
1819 /* Set the current process */
1820 process_list->current_hash_data[trace_num][process->cpu] =
1821 hashed_process_data;
1822 }
1823
1824 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
1825 evtime) <= 0))
1826 {
1827 TimeWindow time_window =
1828 lttvwindow_get_time_window(control_flow_data->tab);
1829
1830 #ifdef EXTRA_CHECK
1831 if(ltt_time_compare(evtime, time_window.start_time) == -1
1832 || ltt_time_compare(evtime, time_window.end_time) == 1)
1833 return FALSE;
1834 #endif //EXTRA_CHECK
1835 Drawing_t *drawing = control_flow_data->drawing;
1836 guint width = drawing->width;
1837 guint new_x;
1838 convert_time_to_pixels(
1839 time_window,
1840 evtime,
1841 width,
1842 &new_x);
1843 if(unlikely(hashed_process_data->x.middle != new_x)) {
1844 hashed_process_data->x.middle = new_x;
1845 hashed_process_data->x.middle_used = FALSE;
1846 hashed_process_data->x.middle_marked = FALSE;
1847 }
1848 }
1849
1850 return FALSE;
1851 }
1852
1853
1854 /* Get the filename of the process to print */
1855 int after_fs_exec_hook(void *hook_data, void *call_data)
1856 {
1857 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1858 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1859 ControlFlowData *control_flow_data = events_request->viewer_data;
1860
1861 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1862
1863 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1864
1865 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1866
1867 LttEvent *e;
1868 e = ltt_tracefile_get_event(tfc->tf);
1869
1870 LttvFilter *filter = control_flow_data->filter;
1871 if(filter != NULL && filter->head != NULL)
1872 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1873 tfc->t_context->t,tfc,NULL,NULL))
1874 return FALSE;
1875
1876 guint cpu = tfs->cpu;
1877 guint trace_num = ts->parent.index;
1878 LttvProcessState *process = ts->running_process[cpu];
1879 g_assert(process != NULL);
1880
1881 guint pid = process->pid;
1882
1883 /* Well, the process_out existed : we must get it in the process hash
1884 * or add it, and draw its items.
1885 */
1886 /* Add process to process list (if not present) */
1887 guint pl_height = 0;
1888 HashedProcessData *hashed_process_data = NULL;
1889 ProcessList *process_list = control_flow_data->process_list;
1890 LttTime birth = process->creation_time;
1891
1892 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1893 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1894 } else {
1895 hashed_process_data = processlist_get_process_data(process_list,
1896 pid,
1897 process->cpu,
1898 &birth,
1899 trace_num);
1900 if(unlikely(hashed_process_data == NULL))
1901 {
1902 g_assert(pid == 0 || pid != process->ppid);
1903 ProcessInfo *process_info;
1904 /* Process not present */
1905 Drawing_t *drawing = control_flow_data->drawing;
1906 processlist_add(process_list,
1907 drawing,
1908 pid,
1909 process->tgid,
1910 process->cpu,
1911 process->ppid,
1912 &birth,
1913 trace_num,
1914 process->name,
1915 process->brand,
1916 &pl_height,
1917 &process_info,
1918 &hashed_process_data);
1919 gtk_widget_set_size_request(drawing->drawing_area,
1920 -1,
1921 pl_height);
1922 gtk_widget_queue_draw(drawing->drawing_area);
1923 }
1924 /* Set the current process */
1925 process_list->current_hash_data[trace_num][process->cpu] =
1926 hashed_process_data;
1927 }
1928
1929 processlist_set_name(process_list, process->name, hashed_process_data);
1930
1931 return 0;
1932
1933 }
1934
1935 /* Get the filename of the process to print */
1936 int after_user_generic_thread_brand_hook(void *hook_data, void *call_data)
1937 {
1938 LttvTraceHook *th = (LttvTraceHook*)hook_data;
1939 EventsRequest *events_request = (EventsRequest*)th->hook_data;
1940 ControlFlowData *control_flow_data = events_request->viewer_data;
1941
1942 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1943
1944 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1945
1946 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1947
1948 LttEvent *e;
1949 e = ltt_tracefile_get_event(tfc->tf);
1950
1951 LttvFilter *filter = control_flow_data->filter;
1952 if(filter != NULL && filter->head != NULL)
1953 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1954 tfc->t_context->t,tfc,NULL,NULL))
1955 return FALSE;
1956
1957 guint cpu = tfs->cpu;
1958 guint trace_num = ts->parent.index;
1959 LttvProcessState *process = ts->running_process[cpu];
1960 g_assert(process != NULL);
1961
1962 guint pid = process->pid;
1963
1964 /* Well, the process_out existed : we must get it in the process hash
1965 * or add it, and draw its items.
1966 */
1967 /* Add process to process list (if not present) */
1968 guint pl_height = 0;
1969 HashedProcessData *hashed_process_data = NULL;
1970 ProcessList *process_list = control_flow_data->process_list;
1971 LttTime birth = process->creation_time;
1972
1973 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1974 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1975 } else {
1976 hashed_process_data = processlist_get_process_data(process_list,
1977 pid,
1978 process->cpu,
1979 &birth,
1980 trace_num);
1981 if(unlikely(hashed_process_data == NULL))
1982 {
1983 g_assert(pid == 0 || pid != process->ppid);
1984 ProcessInfo *process_info;
1985 /* Process not present */
1986 Drawing_t *drawing = control_flow_data->drawing;
1987 processlist_add(process_list,
1988 drawing,
1989 pid,
1990 process->tgid,
1991 process->cpu,
1992 process->ppid,
1993 &birth,
1994 trace_num,
1995 process->name,
1996 process->brand,
1997 &pl_height,
1998 &process_info,
1999 &hashed_process_data);
2000 gtk_widget_set_size_request(drawing->drawing_area,
2001 -1,
2002 pl_height);
2003 gtk_widget_queue_draw(drawing->drawing_area);
2004 }
2005 /* Set the current process */
2006 process_list->current_hash_data[trace_num][process->cpu] =
2007 hashed_process_data;
2008 }
2009
2010 processlist_set_brand(process_list, process->brand, hashed_process_data);
2011
2012 return 0;
2013
2014 }
2015
2016
2017 /* after_event_enum_process_hook
2018 *
2019 * Create the processlist entry for the child process. Put the last
2020 * position in x at the current time value.
2021 *
2022 * @param hook_data ControlFlowData structure of the viewer.
2023 * @param call_data Event context.
2024 *
2025 * This function adds items to be drawn in a queue for each process.
2026 *
2027 */
2028 int after_event_enum_process_hook(void *hook_data, void *call_data)
2029 {
2030 LttvTraceHook *th = (LttvTraceHook*)hook_data;
2031 EventsRequest *events_request = (EventsRequest*)th->hook_data;
2032 ControlFlowData *control_flow_data = events_request->viewer_data;
2033
2034 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2035
2036 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
2037
2038 guint first_cpu, nb_cpus, cpu;
2039
2040 LttEvent *e;
2041 e = ltt_tracefile_get_event(tfc->tf);
2042
2043 LttvFilter *filter = control_flow_data->filter;
2044 if(filter != NULL && filter->head != NULL)
2045 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
2046 tfc->t_context->t,tfc,NULL,NULL))
2047 return FALSE;
2048
2049 /* Add process to process list (if not present) */
2050 LttvProcessState *process_in;
2051 LttTime birth;
2052 guint pl_height = 0;
2053 HashedProcessData *hashed_process_data_in = NULL;
2054
2055 ProcessList *process_list = control_flow_data->process_list;
2056 guint trace_num = ts->parent.index;
2057
2058 guint pid_in;
2059 {
2060 pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0));
2061 }
2062
2063 if(pid_in == 0) {
2064 first_cpu = 0;
2065 nb_cpus = ltt_trace_get_num_cpu(ts->parent.t);
2066 } else {
2067 first_cpu = ANY_CPU;
2068 nb_cpus = ANY_CPU+1;
2069 }
2070
2071 for(cpu = first_cpu; cpu < nb_cpus; cpu++) {
2072 /* Find process pid_in in the list... */
2073 process_in = lttv_state_find_process(ts, cpu, pid_in);
2074 //process_in = tfs->process;
2075 //guint cpu = tfs->cpu;
2076 //guint trace_num = ts->parent.index;
2077 //process_in = ts->running_process[cpu];
2078 /* It should exist, because we are after the state update. */
2079 #ifdef EXTRA_CHECK
2080 //g_assert(process_in != NULL);
2081 #endif //EXTRA_CHECK
2082 birth = process_in->creation_time;
2083
2084 hashed_process_data_in = processlist_get_process_data(process_list,
2085 pid_in,
2086 process_in->cpu,
2087 &birth,
2088 trace_num);
2089 if(hashed_process_data_in == NULL)
2090 {
2091 if(pid_in != 0 && pid_in == process_in->ppid)
2092 g_critical("TEST %u , %u", pid_in, process_in->ppid);
2093 g_assert(pid_in == 0 || pid_in != process_in->ppid);
2094 ProcessInfo *process_info;
2095 Drawing_t *drawing = control_flow_data->drawing;
2096 /* Process not present */
2097 processlist_add(process_list,
2098 drawing,
2099 pid_in,
2100 process_in->tgid,
2101 process_in->cpu,
2102 process_in->ppid,
2103 &birth,
2104 trace_num,
2105 process_in->name,
2106 process_in->brand,
2107 &pl_height,
2108 &process_info,
2109 &hashed_process_data_in);
2110 gtk_widget_set_size_request(drawing->drawing_area,
2111 -1,
2112 pl_height);
2113 gtk_widget_queue_draw(drawing->drawing_area);
2114 } else {
2115 processlist_set_name(process_list, process_in->name,
2116 hashed_process_data_in);
2117 processlist_set_ppid(process_list, process_in->ppid,
2118 hashed_process_data_in);
2119 processlist_set_tgid(process_list, process_in->tgid,
2120 hashed_process_data_in);
2121 }
2122 }
2123 return 0;
2124 }
2125
2126
2127 gint update_time_window_hook(void *hook_data, void *call_data)
2128 {
2129 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2130 Drawing_t *drawing = control_flow_data->drawing;
2131 ProcessList *process_list = control_flow_data->process_list;
2132
2133 const TimeWindowNotifyData *time_window_nofify_data =
2134 ((const TimeWindowNotifyData *)call_data);
2135
2136 TimeWindow *old_time_window =
2137 time_window_nofify_data->old_time_window;
2138 TimeWindow *new_time_window =
2139 time_window_nofify_data->new_time_window;
2140
2141 /* Update the ruler */
2142 drawing_update_ruler(control_flow_data->drawing,
2143 new_time_window);
2144
2145
2146 /* Two cases : zoom in/out or scrolling */
2147
2148 /* In order to make sure we can reuse the old drawing, the scale must
2149 * be the same and the new time interval being partly located in the
2150 * currently shown time interval. (reuse is only for scrolling)
2151 */
2152
2153 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
2154 old_time_window->start_time.tv_sec,
2155 old_time_window->start_time.tv_nsec,
2156 old_time_window->time_width.tv_sec,
2157 old_time_window->time_width.tv_nsec);
2158
2159 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
2160 new_time_window->start_time.tv_sec,
2161 new_time_window->start_time.tv_nsec,
2162 new_time_window->time_width.tv_sec,
2163 new_time_window->time_width.tv_nsec);
2164
2165 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
2166 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
2167 {
2168 /* Same scale (scrolling) */
2169 g_info("scrolling");
2170 LttTime *ns = &new_time_window->start_time;
2171 LttTime *os = &old_time_window->start_time;
2172 LttTime old_end = old_time_window->end_time;
2173 LttTime new_end = new_time_window->end_time;
2174 //if(ns<os+w<ns+w)
2175 //if(ns<os+w && os+w<ns+w)
2176 //if(ns<old_end && os<ns)
2177 if(ltt_time_compare(*ns, old_end) == -1
2178 && ltt_time_compare(*os, *ns) == -1)
2179 {
2180 g_info("scrolling near right");
2181 /* Scroll right, keep right part of the screen */
2182 guint x = 0;
2183 guint width = control_flow_data->drawing->width;
2184 convert_time_to_pixels(
2185 *old_time_window,
2186 *ns,
2187 width,
2188 &x);
2189
2190 /* Copy old data to new location */
2191 copy_pixmap_region(process_list,
2192 NULL,
2193 control_flow_data->drawing->drawing_area->style->black_gc,
2194 NULL,
2195 x, 0,
2196 0, 0,
2197 control_flow_data->drawing->width-x+SAFETY, -1);
2198
2199 if(drawing->damage_begin == drawing->damage_end)
2200 drawing->damage_begin = control_flow_data->drawing->width-x;
2201 else
2202 drawing->damage_begin = 0;
2203
2204 drawing->damage_end = control_flow_data->drawing->width;
2205
2206 /* Clear the data request background, but not SAFETY */
2207 rectangle_pixmap(process_list,
2208 control_flow_data->drawing->drawing_area->style->black_gc,
2209 TRUE,
2210 drawing->damage_begin+SAFETY, 0,
2211 drawing->damage_end - drawing->damage_begin, // do not overlap
2212 -1);
2213 gtk_widget_queue_draw(drawing->drawing_area);
2214 //gtk_widget_queue_draw_area (drawing->drawing_area,
2215 // 0,0,
2216 // control_flow_data->drawing->width,
2217 // control_flow_data->drawing->height);
2218
2219 /* Get new data for the rest. */
2220 drawing_data_request(control_flow_data->drawing,
2221 drawing->damage_begin, 0,
2222 drawing->damage_end - drawing->damage_begin,
2223 control_flow_data->drawing->height);
2224 } else {
2225 //if(ns<os<ns+w)
2226 //if(ns<os && os<ns+w)
2227 //if(ns<os && os<new_end)
2228 if(ltt_time_compare(*ns,*os) == -1
2229 && ltt_time_compare(*os,new_end) == -1)
2230 {
2231 g_info("scrolling near left");
2232 /* Scroll left, keep left part of the screen */
2233 guint x = 0;
2234 guint width = control_flow_data->drawing->width;
2235 convert_time_to_pixels(
2236 *new_time_window,
2237 *os,
2238 width,
2239 &x);
2240
2241 /* Copy old data to new location */
2242 copy_pixmap_region (process_list,
2243 NULL,
2244 control_flow_data->drawing->drawing_area->style->black_gc,
2245 NULL,
2246 0, 0,
2247 x, 0,
2248 -1, -1);
2249
2250 if(drawing->damage_begin == drawing->damage_end)
2251 drawing->damage_end = x;
2252 else
2253 drawing->damage_end =
2254 control_flow_data->drawing->width;
2255
2256 drawing->damage_begin = 0;
2257
2258 rectangle_pixmap (process_list,
2259 control_flow_data->drawing->drawing_area->style->black_gc,
2260 TRUE,
2261 drawing->damage_begin, 0,
2262 drawing->damage_end - drawing->damage_begin, // do not overlap
2263 -1);
2264
2265 gtk_widget_queue_draw(drawing->drawing_area);
2266 //gtk_widget_queue_draw_area (drawing->drawing_area,
2267 // 0,0,
2268 // control_flow_data->drawing->width,
2269 // control_flow_data->drawing->height);
2270
2271
2272 /* Get new data for the rest. */
2273 drawing_data_request(control_flow_data->drawing,
2274 drawing->damage_begin, 0,
2275 drawing->damage_end - drawing->damage_begin,
2276 control_flow_data->drawing->height);
2277
2278 } else {
2279 if(ltt_time_compare(*ns,*os) == 0)
2280 {
2281 g_info("not scrolling");
2282 } else {
2283 g_info("scrolling far");
2284 /* Cannot reuse any part of the screen : far jump */
2285
2286
2287 rectangle_pixmap (process_list,
2288 control_flow_data->drawing->drawing_area->style->black_gc,
2289 TRUE,
2290 0, 0,
2291 control_flow_data->drawing->width+SAFETY, // do not overlap
2292 -1);
2293
2294 //gtk_widget_queue_draw_area (drawing->drawing_area,
2295 // 0,0,
2296 // control_flow_data->drawing->width,
2297 // control_flow_data->drawing->height);
2298 gtk_widget_queue_draw(drawing->drawing_area);
2299
2300 drawing->damage_begin = 0;
2301 drawing->damage_end = control_flow_data->drawing->width;
2302
2303 drawing_data_request(control_flow_data->drawing,
2304 0, 0,
2305 control_flow_data->drawing->width,
2306 control_flow_data->drawing->height);
2307
2308 }
2309 }
2310 }
2311 } else {
2312 /* Different scale (zoom) */
2313 g_info("zoom");
2314
2315 rectangle_pixmap (process_list,
2316 control_flow_data->drawing->drawing_area->style->black_gc,
2317 TRUE,
2318 0, 0,
2319 control_flow_data->drawing->width+SAFETY, // do not overlap
2320 -1);
2321
2322 //gtk_widget_queue_draw_area (drawing->drawing_area,
2323 // 0,0,
2324 // control_flow_data->drawing->width,
2325 // control_flow_data->drawing->height);
2326 gtk_widget_queue_draw(drawing->drawing_area);
2327
2328 drawing->damage_begin = 0;
2329 drawing->damage_end = control_flow_data->drawing->width;
2330
2331 drawing_data_request(control_flow_data->drawing,
2332 0, 0,
2333 control_flow_data->drawing->width,
2334 control_flow_data->drawing->height);
2335 }
2336
2337 /* Update directly when scrolling */
2338 gdk_window_process_updates(control_flow_data->drawing->drawing_area->window,
2339 TRUE);
2340
2341 return 0;
2342 }
2343
2344 gint traceset_notify(void *hook_data, void *call_data)
2345 {
2346 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2347 Drawing_t *drawing = control_flow_data->drawing;
2348
2349 if(unlikely(drawing->gc == NULL)) {
2350 return FALSE;
2351 }
2352 if(drawing->dotted_gc == NULL) {
2353 return FALSE;
2354 }
2355
2356 drawing_clear(control_flow_data->drawing);
2357 processlist_clear(control_flow_data->process_list);
2358 gtk_widget_set_size_request(
2359 control_flow_data->drawing->drawing_area,
2360 -1, processlist_get_height(control_flow_data->process_list));
2361 redraw_notify(control_flow_data, NULL);
2362
2363 request_background_data(control_flow_data);
2364
2365 return FALSE;
2366 }
2367
2368 gint redraw_notify(void *hook_data, void *call_data)
2369 {
2370 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2371 Drawing_t *drawing = control_flow_data->drawing;
2372 GtkWidget *widget = drawing->drawing_area;
2373
2374 drawing->damage_begin = 0;
2375 drawing->damage_end = drawing->width;
2376
2377 /* fun feature, to be separated someday... */
2378 drawing_clear(control_flow_data->drawing);
2379 processlist_clear(control_flow_data->process_list);
2380 gtk_widget_set_size_request(
2381 control_flow_data->drawing->drawing_area,
2382 -1, processlist_get_height(control_flow_data->process_list));
2383 // Clear the images
2384 rectangle_pixmap (control_flow_data->process_list,
2385 widget->style->black_gc,
2386 TRUE,
2387 0, 0,
2388 drawing->alloc_width,
2389 -1);
2390
2391 gtk_widget_queue_draw(drawing->drawing_area);
2392
2393 if(drawing->damage_begin < drawing->damage_end)
2394 {
2395 drawing_data_request(drawing,
2396 drawing->damage_begin,
2397 0,
2398 drawing->damage_end-drawing->damage_begin,
2399 drawing->height);
2400 }
2401
2402 //gtk_widget_queue_draw_area(drawing->drawing_area,
2403 // 0,0,
2404 // drawing->width,
2405 // drawing->height);
2406 return FALSE;
2407
2408 }
2409
2410
2411 gint continue_notify(void *hook_data, void *call_data)
2412 {
2413 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2414 Drawing_t *drawing = control_flow_data->drawing;
2415
2416 //g_assert(widget->allocation.width == drawing->damage_end);
2417
2418 if(drawing->damage_begin < drawing->damage_end)
2419 {
2420 drawing_data_request(drawing,
2421 drawing->damage_begin,
2422 0,
2423 drawing->damage_end-drawing->damage_begin,
2424 drawing->height);
2425 }
2426
2427 return FALSE;
2428 }
2429
2430
2431 gint update_current_time_hook(void *hook_data, void *call_data)
2432 {
2433 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
2434
2435 LttTime current_time = *((LttTime*)call_data);
2436
2437 TimeWindow time_window =
2438 lttvwindow_get_time_window(control_flow_data->tab);
2439
2440 LttTime time_begin = time_window.start_time;
2441 LttTime width = time_window.time_width;
2442 LttTime half_width;
2443 {
2444 guint64 time_ll = ltt_time_to_uint64(width);
2445 time_ll = time_ll >> 1; /* divide by two */
2446 half_width = ltt_time_from_uint64(time_ll);
2447 }
2448 LttTime time_end = ltt_time_add(time_begin, width);
2449
2450 LttvTracesetContext * tsc =
2451 lttvwindow_get_traceset_context(control_flow_data->tab);
2452
2453 LttTime trace_start = tsc->time_span.start_time;
2454 LttTime trace_end = tsc->time_span.end_time;
2455
2456 g_info("New current time HOOK : %lu, %lu", current_time.tv_sec,
2457 current_time.tv_nsec);
2458
2459
2460
2461 /* If current time is inside time interval, just move the highlight
2462 * bar */
2463
2464 /* Else, we have to change the time interval. We have to tell it
2465 * to the main window. */
2466 /* The time interval change will take care of placing the current
2467 * time at the center of the visible area, or nearest possible if we are
2468 * at one end of the trace. */
2469
2470
2471 if(ltt_time_compare(current_time, time_begin) < 0)
2472 {
2473 TimeWindow new_time_window;
2474
2475 if(ltt_time_compare(current_time,
2476 ltt_time_add(trace_start,half_width)) < 0)
2477 time_begin = trace_start;
2478 else
2479 time_begin = ltt_time_sub(current_time,half_width);
2480
2481 new_time_window.start_time = time_begin;
2482 new_time_window.time_width = width;
2483 new_time_window.time_width_double = ltt_time_to_double(width);
2484 new_time_window.end_time = ltt_time_add(time_begin, width);
2485
2486 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
2487 }
2488 else if(ltt_time_compare(current_time, time_end) > 0)
2489 {
2490 TimeWindow new_time_window;
2491
2492 if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0)
2493 time_begin = ltt_time_sub(trace_end,width);
2494 else
2495 time_begin = ltt_time_sub(current_time,half_width);
2496
2497 new_time_window.start_time = time_begin;
2498 new_time_window.time_width = width;
2499 new_time_window.time_width_double = ltt_time_to_double(width);
2500 new_time_window.end_time = ltt_time_add(time_begin, width);
2501
2502 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
2503
2504 }
2505 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2506
2507 /* Update directly when scrolling */
2508 gdk_window_process_updates(control_flow_data->drawing->drawing_area->window,
2509 TRUE);
2510
2511 return 0;
2512 }
2513
2514 typedef struct _ClosureData {
2515 EventsRequest *events_request;
2516 LttvTracesetState *tss;
2517 LttTime end_time;
2518 guint x_end;
2519 } ClosureData;
2520
2521
2522 void draw_closure(gpointer key, gpointer value, gpointer user_data)
2523 {
2524 ProcessInfo *process_info = (ProcessInfo*)key;
2525 HashedProcessData *hashed_process_data = (HashedProcessData*)value;
2526 ClosureData *closure_data = (ClosureData*)user_data;
2527
2528 EventsRequest *events_request = closure_data->events_request;
2529 ControlFlowData *control_flow_data = events_request->viewer_data;
2530
2531 LttvTracesetState *tss = closure_data->tss;
2532 LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
2533
2534 LttTime evtime = closure_data->end_time;
2535
2536 gboolean dodraw = TRUE;
2537
2538 {
2539 /* For the process */
2540 /* First, check if the current process is in the state computation
2541 * process list. If it is there, that means we must add it right now and
2542 * draw items from the beginning of the read for it. If it is not
2543 * present, it's a new process and it was not present : it will
2544 * be added after the state update. */
2545 #ifdef EXTRA_CHECK
2546 g_assert(lttv_traceset_number(tsc->ts) > 0);
2547 #endif //EXTRA_CHECK
2548 LttvTraceContext *tc = tsc->traces[process_info->trace_num];
2549 LttvTraceState *ts = (LttvTraceState*)tc;
2550
2551 #if 0
2552 //FIXME : optimize data structures.
2553 LttvTracefileState *tfs;
2554 LttvTracefileContext *tfc;
2555 guint i;
2556 for(i=0;i<tc->tracefiles->len;i++) {
2557 tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i);
2558 if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU
2559 && tfs->cpu == process_info->cpu)
2560 break;
2561
2562 }
2563 g_assert(i<tc->tracefiles->len);
2564 tfs = LTTV_TRACEFILE_STATE(tfc);
2565 #endif //0
2566 // LttvTracefileState *tfs =
2567 // (LttvTracefileState*)tsc->traces[process_info->trace_num]->
2568 // tracefiles[process_info->cpu];
2569
2570 LttvProcessState *process;
2571 process = lttv_state_find_process(ts, process_info->cpu,
2572 process_info->pid);
2573
2574 if(unlikely(process != NULL)) {
2575
2576 LttvFilter *filter = control_flow_data->filter;
2577 if(filter != NULL && filter->head != NULL)
2578 if(!lttv_filter_tree_parse(filter->head,NULL,NULL,
2579 tc->t,NULL,process,tc))
2580 dodraw = FALSE;
2581
2582 /* Only draw for processes that are currently in the trace states */
2583
2584 #ifdef EXTRA_CHECK
2585 /* Should be alike when background info is ready */
2586 if(control_flow_data->background_info_waiting==0)
2587 g_assert(ltt_time_compare(process->creation_time,
2588 process_info->birth) == 0);
2589 #endif //EXTRA_CHECK
2590
2591 /* Now, the process is in the state hash and our own process hash.
2592 * We definitely can draw the items related to the ending state.
2593 */
2594
2595 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
2596 evtime) <= 0))
2597 {
2598 TimeWindow time_window =
2599 lttvwindow_get_time_window(control_flow_data->tab);
2600
2601 #ifdef EXTRA_CHECK
2602 if(ltt_time_compare(evtime, time_window.start_time) == -1
2603 || ltt_time_compare(evtime, time_window.end_time) == 1)
2604 return;
2605 #endif //EXTRA_CHECK
2606 Drawing_t *drawing = control_flow_data->drawing;
2607 guint width = drawing->width;
2608
2609 guint x = closure_data->x_end;
2610
2611 DrawContext draw_context;
2612
2613 /* Now create the drawing context that will be used to draw
2614 * items related to the last state. */
2615 draw_context.drawable = hashed_process_data->pixmap;
2616 draw_context.gc = drawing->gc;
2617 draw_context.pango_layout = drawing->pango_layout;
2618 draw_context.drawinfo.end.x = x;
2619
2620 draw_context.drawinfo.y.over = 1;
2621 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
2622 draw_context.drawinfo.y.under = hashed_process_data->height;
2623
2624 draw_context.drawinfo.start.offset.over = 0;
2625 draw_context.drawinfo.start.offset.middle = 0;
2626 draw_context.drawinfo.start.offset.under = 0;
2627 draw_context.drawinfo.end.offset.over = 0;
2628 draw_context.drawinfo.end.offset.middle = 0;
2629 draw_context.drawinfo.end.offset.under = 0;
2630 #if 0
2631 /* Jump over draw if we are at the same x position */
2632 if(x == hashed_process_data->x.over)
2633 {
2634 /* jump */
2635 } else {
2636 draw_context.drawinfo.start.x = hashed_process_data->x.over;
2637 /* Draw the line */
2638 PropertiesLine prop_line = prepare_execmode_line(process);
2639 draw_line((void*)&prop_line, (void*)&draw_context);
2640
2641 hashed_process_data->x.over = x;
2642 }
2643 #endif //0
2644
2645 if(unlikely(x == hashed_process_data->x.middle &&
2646 hashed_process_data->x.middle_used)) {
2647 #if 0 /* do not mark closure : not missing information */
2648 if(hashed_process_data->x.middle_marked == FALSE) {
2649 /* Draw collision indicator */
2650 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
2651 gdk_draw_point(drawing->pixmap,
2652 drawing->gc,
2653 x,
2654 y+(height/2)-3);
2655 hashed_process_data->x.middle_marked = TRUE;
2656 }
2657 #endif //0
2658 /* Jump */
2659 } else {
2660 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
2661 /* Draw the line */
2662 if(dodraw) {
2663 PropertiesLine prop_line = prepare_s_e_line(process);
2664 draw_line((void*)&prop_line, (void*)&draw_context);
2665 }
2666
2667 /* become the last x position */
2668 if(likely(x != hashed_process_data->x.middle)) {
2669 hashed_process_data->x.middle = x;
2670 /* but don't use the pixel */
2671 hashed_process_data->x.middle_used = FALSE;
2672
2673 /* Calculate the next good time */
2674 convert_pixels_to_time(width, x+1, time_window,
2675 &hashed_process_data->next_good_time);
2676 }
2677 }
2678 }
2679 }
2680 }
2681 return;
2682 }
2683
2684 int before_chunk(void *hook_data, void *call_data)
2685 {
2686 EventsRequest *events_request = (EventsRequest*)hook_data;
2687 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2688 #if 0
2689 /* Desactivate sort */
2690 gtk_tree_sortable_set_sort_column_id(
2691 GTK_TREE_SORTABLE(cfd->process_list->list_store),
2692 TRACE_COLUMN,
2693 GTK_SORT_ASCENDING);
2694 #endif //0
2695 drawing_chunk_begin(events_request, tss);
2696
2697 return 0;
2698 }
2699
2700 int before_request(void *hook_data, void *call_data)
2701 {
2702 EventsRequest *events_request = (EventsRequest*)hook_data;
2703 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2704
2705 drawing_data_request_begin(events_request, tss);
2706
2707 return 0;
2708 }
2709
2710
2711 /*
2712 * after request is necessary in addition of after chunk in order to draw
2713 * lines until the end of the screen. after chunk just draws lines until
2714 * the last event.
2715 *
2716 * for each process
2717 * draw closing line
2718 * expose
2719 */
2720 int after_request(void *hook_data, void *call_data)
2721 {
2722 EventsRequest *events_request = (EventsRequest*)hook_data;
2723 ControlFlowData *control_flow_data = events_request->viewer_data;
2724 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2725
2726 ProcessList *process_list = control_flow_data->process_list;
2727 LttTime end_time = events_request->end_time;
2728
2729 ClosureData closure_data;
2730 closure_data.events_request = (EventsRequest*)hook_data;
2731 closure_data.tss = tss;
2732 closure_data.end_time = end_time;
2733
2734 TimeWindow time_window =
2735 lttvwindow_get_time_window(control_flow_data->tab);
2736 guint width = control_flow_data->drawing->width;
2737 convert_time_to_pixels(
2738 time_window,
2739 end_time,
2740 width,
2741 &closure_data.x_end);
2742
2743
2744 /* Draw last items */
2745 g_hash_table_foreach(process_list->process_hash, draw_closure,
2746 (void*)&closure_data);
2747
2748
2749 /* Request expose */
2750 drawing_request_expose(events_request, tss, end_time);
2751 return 0;
2752 }
2753
2754 /*
2755 * for each process
2756 * draw closing line
2757 * expose
2758 */
2759 int after_chunk(void *hook_data, void *call_data)
2760 {
2761 EventsRequest *events_request = (EventsRequest*)hook_data;
2762 ControlFlowData *control_flow_data = events_request->viewer_data;
2763 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2764 LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
2765 LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
2766 LttTime end_time;
2767
2768 ProcessList *process_list = control_flow_data->process_list;
2769 guint i;
2770 LttvTraceset *traceset = tsc->ts;
2771 guint nb_trace = lttv_traceset_number(traceset);
2772
2773 /* Only execute when called for the first trace's events request */
2774 if(!process_list->current_hash_data)
2775 return 0;
2776
2777 for(i = 0 ; i < nb_trace ; i++) {
2778 g_free(process_list->current_hash_data[i]);
2779 }
2780 g_free(process_list->current_hash_data);
2781 process_list->current_hash_data = NULL;
2782
2783 if(tfc != NULL)
2784 end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
2785 else /* end of traceset, or position now out of request : end */
2786 end_time = events_request->end_time;
2787
2788 ClosureData closure_data;
2789 closure_data.events_request = (EventsRequest*)hook_data;
2790 closure_data.tss = tss;
2791 closure_data.end_time = end_time;
2792
2793 TimeWindow time_window =
2794 lttvwindow_get_time_window(control_flow_data->tab);
2795 guint width = control_flow_data->drawing->width;
2796 convert_time_to_pixels(
2797 time_window,
2798 end_time,
2799 width,
2800 &closure_data.x_end);
2801
2802 /* Draw last items */
2803 g_hash_table_foreach(process_list->process_hash, draw_closure,
2804 (void*)&closure_data);
2805 #if 0
2806 /* Reactivate sort */
2807 gtk_tree_sortable_set_sort_column_id(
2808 GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
2809 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
2810 GTK_SORT_ASCENDING);
2811
2812 update_index_to_pixmap(control_flow_data->process_list);
2813 /* Request a full expose : drawing scrambled */
2814 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2815 #endif //0
2816 /* Request expose (updates damages zone also) */
2817 drawing_request_expose(events_request, tss, end_time);
2818
2819 return 0;
2820 }
2821
2822 /* after_statedump_end
2823 *
2824 * @param hook_data ControlFlowData structure of the viewer.
2825 * @param call_data Event context.
2826 *
2827 * This function adds items to be drawn in a queue for each process.
2828 *
2829 */
2830 int before_statedump_end(void *hook_data, void *call_data)
2831 {
2832 LttvTraceHook *th = (LttvTraceHook*)hook_data;
2833 EventsRequest *events_request = (EventsRequest*)th->hook_data;
2834 ControlFlowData *control_flow_data = events_request->viewer_data;
2835
2836 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2837
2838 LttvTracesetState *tss = (LttvTracesetState*)tfc->t_context->ts_context;
2839 ProcessList *process_list = control_flow_data->process_list;
2840
2841 LttEvent *e;
2842 e = ltt_tracefile_get_event(tfc->tf);
2843
2844 LttvFilter *filter = control_flow_data->filter;
2845 if(filter != NULL && filter->head != NULL)
2846 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
2847 tfc->t_context->t,tfc,NULL,NULL))
2848 return FALSE;
2849
2850 LttTime evtime = ltt_event_time(e);
2851
2852 ClosureData closure_data;
2853 closure_data.events_request = events_request;
2854 closure_data.tss = tss;
2855 closure_data.end_time = evtime;
2856
2857 TimeWindow time_window =
2858 lttvwindow_get_time_window(control_flow_data->tab);
2859 guint width = control_flow_data->drawing->width;
2860 convert_time_to_pixels(
2861 time_window,
2862 evtime,
2863 width,
2864 &closure_data.x_end);
2865
2866 /* Draw last items */
2867 g_hash_table_foreach(process_list->process_hash, draw_closure,
2868 (void*)&closure_data);
2869 #if 0
2870 /* Reactivate sort */
2871 gtk_tree_sortable_set_sort_column_id(
2872 GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
2873 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
2874 GTK_SORT_ASCENDING);
2875
2876 update_index_to_pixmap(control_flow_data->process_list);
2877 /* Request a full expose : drawing scrambled */
2878 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2879 #endif //0
2880 /* Request expose (updates damages zone also) */
2881 drawing_request_expose(events_request, tss, evtime);
2882
2883 return 0;
2884 }
This page took 0.117871 seconds and 5 git commands to generate.