cleanups
[lttv.git] / ltt / branches / poly / lttv / modules / gui / resourceview / 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/type.h>
65 #include <ltt/trace.h>
66
67 #include <lttv/lttv.h>
68 #include <lttv/hook.h>
69 #include <lttv/state.h>
70 #include <lttvwindow/lttvwindow.h>
71 #include <lttvwindow/lttvwindowtraces.h>
72 #include <lttvwindow/support.h>
73
74
75 #include "eventhooks.h"
76 #include "cfv.h"
77 #include "processlist.h"
78 #include "drawing.h"
79
80
81 #define MAX_PATH_LEN 256
82 #define STATE_LINE_WIDTH 4
83 #define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3)
84
85 extern GSList *g_legend_list;
86
87
88 /* Action to do when background computation completed.
89 *
90 * Wait for all the awaited computations to be over.
91 */
92
93 static gint background_ready(void *hook_data, void *call_data)
94 {
95 ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
96 LttvTrace *trace = (LttvTrace*)call_data;
97
98 control_flow_data->background_info_waiting--;
99
100 if(control_flow_data->background_info_waiting == 0) {
101 g_message("control flow viewer : background computation data ready.");
102
103 drawing_clear(control_flow_data->drawing);
104 processlist_clear(control_flow_data->process_list);
105 gtk_widget_set_size_request(
106 control_flow_data->drawing->drawing_area,
107 -1, processlist_get_height(control_flow_data->process_list));
108 redraw_notify(control_flow_data, NULL);
109 }
110
111 return 0;
112 }
113
114
115 /* Request background computation. Verify if it is in progress or ready first.
116 * Only for each trace in the tab's traceset.
117 */
118 static void request_background_data(ControlFlowData *control_flow_data)
119 {
120 LttvTracesetContext * tsc =
121 lttvwindow_get_traceset_context(control_flow_data->tab);
122 gint num_traces = lttv_traceset_number(tsc->ts);
123 gint i;
124 LttvTrace *trace;
125 LttvTraceState *tstate;
126
127 LttvHooks *background_ready_hook =
128 lttv_hooks_new();
129 lttv_hooks_add(background_ready_hook, background_ready, control_flow_data,
130 LTTV_PRIO_DEFAULT);
131 control_flow_data->background_info_waiting = 0;
132
133 for(i=0;i<num_traces;i++) {
134 trace = lttv_traceset_get(tsc->ts, i);
135 tstate = LTTV_TRACE_STATE(tsc->traces[i]);
136
137 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE
138 && !tstate->has_precomputed_states) {
139
140 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
141 trace) == FALSE) {
142 /* We first remove requests that could have been done for the same
143 * information. Happens when two viewers ask for it before servicing
144 * starts.
145 */
146 if(!lttvwindowtraces_background_request_find(trace, "state"))
147 lttvwindowtraces_background_request_queue(
148 main_window_get_widget(control_flow_data->tab), trace, "state");
149 lttvwindowtraces_background_notify_queue(control_flow_data,
150 trace,
151 ltt_time_infinite,
152 NULL,
153 background_ready_hook);
154 control_flow_data->background_info_waiting++;
155 } else { /* in progress */
156
157 lttvwindowtraces_background_notify_current(control_flow_data,
158 trace,
159 ltt_time_infinite,
160 NULL,
161 background_ready_hook);
162 control_flow_data->background_info_waiting++;
163 }
164 } else {
165 /* Data ready. By its nature, this viewer doesn't need to have
166 * its data ready hook called there, because a background
167 * request is always linked with a redraw.
168 */
169 }
170
171 }
172
173 lttv_hooks_destroy(background_ready_hook);
174 }
175
176
177
178
179 /**
180 * Event Viewer's constructor hook
181 *
182 * This constructor is given as a parameter to the menuitem and toolbar button
183 * registration. It creates the list.
184 * @param tab A pointer to the parent tab.
185 * @return The widget created.
186 */
187 GtkWidget *
188 h_resourceview(LttvPlugin *plugin)
189 {
190 LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin);
191 Tab *tab = ptab->tab;
192 g_info("h_guicontrolflow, %p", tab);
193 ControlFlowData *control_flow_data = resourceview(ptab);
194
195 control_flow_data->tab = tab;
196
197 // Unreg done in the GuiControlFlow_Destructor
198 lttvwindow_register_traceset_notify(tab,
199 traceset_notify,
200 control_flow_data);
201
202 lttvwindow_register_time_window_notify(tab,
203 update_time_window_hook,
204 control_flow_data);
205 lttvwindow_register_current_time_notify(tab,
206 update_current_time_hook,
207 control_flow_data);
208 lttvwindow_register_redraw_notify(tab,
209 redraw_notify,
210 control_flow_data);
211 lttvwindow_register_continue_notify(tab,
212 continue_notify,
213 control_flow_data);
214 request_background_data(control_flow_data);
215
216
217 return guicontrolflow_get_widget(control_flow_data) ;
218
219 }
220
221 void legend_destructor(GtkWindow *legend)
222 {
223 g_legend_list = g_slist_remove(g_legend_list, legend);
224 }
225
226 /* Create a popup legend */
227 GtkWidget *
228 h_legend(LttvPlugin *plugin)
229 {
230 LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin);
231 Tab *tab = ptab->tab;
232 g_info("h_legend, %p", tab);
233
234 GtkWindow *legend = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
235
236 g_legend_list = g_slist_append(
237 g_legend_list,
238 legend);
239
240 g_object_set_data_full(
241 G_OBJECT(legend),
242 "legend",
243 legend,
244 (GDestroyNotify)legend_destructor);
245
246 gtk_window_set_title(legend, "Control Flow View Legend");
247
248 GtkWidget *pixmap = create_pixmap(GTK_WIDGET(legend), "lttv-color-list.png");
249
250 // GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixmap(
251 // GDK_PIXMAP(pixmap), NULL));
252
253 gtk_container_add(GTK_CONTAINER(legend), GTK_WIDGET(pixmap));
254
255 gtk_widget_show(GTK_WIDGET(pixmap));
256 gtk_widget_show(GTK_WIDGET(legend));
257
258
259 return NULL; /* This is a popup window */
260 }
261
262
263 int event_selected_hook(void *hook_data, void *call_data)
264 {
265 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
266 guint *event_number = (guint*) call_data;
267
268 g_debug("DEBUG : event selected by main window : %u", *event_number);
269
270 return 0;
271 }
272
273 /* Function that selects the color of status&exemode line */
274 static inline PropertiesLine prepare_s_e_line(LttvProcessState *process)
275 {
276 PropertiesLine prop_line;
277 prop_line.line_width = STATE_LINE_WIDTH;
278 prop_line.style = GDK_LINE_SOLID;
279 prop_line.y = MIDDLE;
280
281 if(process->state->s == LTTV_STATE_RUN) {
282 if(process->state->t == LTTV_STATE_USER_MODE)
283 prop_line.color = drawing_colors[COL_RUN_USER_MODE];
284 else if(process->state->t == LTTV_STATE_SYSCALL)
285 prop_line.color = drawing_colors[COL_RUN_SYSCALL];
286 else if(process->state->t == LTTV_STATE_TRAP)
287 prop_line.color = drawing_colors[COL_RUN_TRAP];
288 else if(process->state->t == LTTV_STATE_IRQ)
289 prop_line.color = drawing_colors[COL_RUN_IRQ];
290 else if(process->state->t == LTTV_STATE_SOFT_IRQ)
291 prop_line.color = drawing_colors[COL_RUN_SOFT_IRQ];
292 else if(process->state->t == LTTV_STATE_MODE_UNKNOWN)
293 prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
294 else
295 g_assert(FALSE); /* RUNNING MODE UNKNOWN */
296 } else if(process->state->s == LTTV_STATE_WAIT) {
297 /* We don't show if we wait while in user mode, trap, irq or syscall */
298 prop_line.color = drawing_colors[COL_WAIT];
299 } else if(process->state->s == LTTV_STATE_WAIT_CPU) {
300 /* We don't show if we wait for CPU while in user mode, trap, irq
301 * or syscall */
302 prop_line.color = drawing_colors[COL_WAIT_CPU];
303 } else if(process->state->s == LTTV_STATE_ZOMBIE) {
304 prop_line.color = drawing_colors[COL_ZOMBIE];
305 } else if(process->state->s == LTTV_STATE_WAIT_FORK) {
306 prop_line.color = drawing_colors[COL_WAIT_FORK];
307 } else if(process->state->s == LTTV_STATE_EXIT) {
308 prop_line.color = drawing_colors[COL_EXIT];
309 } else if(process->state->s == LTTV_STATE_UNNAMED) {
310 prop_line.color = drawing_colors[COL_UNNAMED];
311 } else {
312 g_critical("unknown state : %s", g_quark_to_string(process->state->s));
313 g_assert(FALSE); /* UNKNOWN STATE */
314 }
315
316 return prop_line;
317
318 }
319
320 static void cpu_set_line_color(PropertiesLine *prop_line, LttvCPUState *s)
321 {
322 GQuark present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1];
323
324 if(present_state == LTTV_CPU_IDLE) {
325 prop_line->color = drawing_colors_cpu[COL_CPU_IDLE];
326 }
327 else if(present_state == LTTV_CPU_BUSY) {
328 prop_line->color = drawing_colors_cpu[COL_CPU_BUSY];
329 }
330 else if(present_state == LTTV_CPU_IRQ) {
331 prop_line->color = drawing_colors_cpu[COL_CPU_IRQ];
332 }
333 else if(present_state == LTTV_CPU_TRAP) {
334 prop_line->color = drawing_colors_cpu[COL_CPU_TRAP];
335 } else {
336 prop_line->color = drawing_colors_cpu[COL_CPU_UNKNOWN];
337 }
338 }
339
340 static void irq_set_line_color(PropertiesLine *prop_line, LttvIRQState *s)
341 {
342 GQuark present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1];
343
344 if(present_state == LTTV_IRQ_UNKNOWN) {
345 prop_line->color = drawing_colors_irq[COL_IRQ_UNKNOWN];
346 }
347 else if(present_state == LTTV_IRQ_IDLE) {
348 prop_line->color = drawing_colors_irq[COL_IRQ_IDLE];
349 }
350 else if(present_state == LTTV_IRQ_BUSY) {
351 prop_line->color = drawing_colors_irq[COL_IRQ_BUSY];
352 }
353 }
354
355 /* before_schedchange_hook
356 *
357 * This function basically draw lines and icons. Two types of lines are drawn :
358 * one small (3 pixels?) representing the state of the process and the second
359 * type is thicker (10 pixels?) representing on which CPU a process is running
360 * (and this only in running state).
361 *
362 * Extremums of the lines :
363 * x_min : time of the last event context for this process kept in memory.
364 * x_max : time of the current event.
365 * y : middle of the process in the process list. The process is found in the
366 * list, therefore is it's position in pixels.
367 *
368 * The choice of lines'color is defined by the context of the last event for this
369 * process.
370 */
371
372
373 int before_schedchange_hook(void *hook_data, void *call_data)
374 {
375 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
376 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
377 ControlFlowData *control_flow_data = events_request->viewer_data;
378
379 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
380
381 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
382 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
383
384 LttEvent *e;
385 e = ltt_tracefile_get_event(tfc->tf);
386 gint target_pid_saved = tfc->target_pid;
387
388 LttTime evtime = ltt_event_time(e);
389 LttvFilter *filter = control_flow_data->filter;
390
391 GQuark cpuq;
392
393 /* we are in a schedchange, before the state update. We must draw the
394 * items corresponding to the state before it changes : now is the right
395 * time to do it.
396 */
397
398 guint pid_out;
399 guint pid_in;
400 pid_out = ltt_event_get_long_unsigned(e, thf->f1);
401 pid_in = ltt_event_get_long_unsigned(e, thf->f2);
402 // if(pid_in != 0 && pid_out != 0) {
403 // /* not a transition to/from idle */
404 // return 0;
405 // }
406
407 tfc->target_pid = pid_out;
408 // if(!filter || !filter->head ||
409 // lttv_filter_tree_parse(filter->head,e,tfc->tf,
410 // tfc->t_context->t,tfc,NULL,NULL)) {
411 /* For the pid_out */
412 /* First, check if the current process is in the state computation
413 * process list. If it is there, that means we must add it right now and
414 * draw items from the beginning of the read for it. If it is not
415 * present, it's a new process and it was not present : it will
416 * be added after the state update. */
417 guint cpu = tfs->cpu;
418 {
419 gchar *cpustr;
420 cpustr = g_strdup_printf("CPU%u", cpu);
421 cpuq = g_quark_from_string(cpustr);
422 g_free(cpustr);
423 }
424
425 guint trace_num = ts->parent.index;
426 // LttvProcessState *process = ts->running_process[cpu];
427 /* unknown state, bad current pid */
428 // if(process->pid != pid_out)
429 // process = lttv_state_find_process(ts,
430 // tfs->cpu, pid_out);
431
432 // if(process != NULL) {
433 /* Well, the process_out existed : we must get it in the process hash
434 * or add it, and draw its items.
435 */
436 /* Add process to process list (if not present) */
437 guint pl_height = 0;
438 HashedResourceData *hashed_process_data = NULL;
439 ProcessList *process_list = control_flow_data->process_list;
440 // LttTime birth = process->creation_time;
441
442 hashed_process_data = processlist_get_process_data(process_list, cpuq, trace_num);
443 // hashed_process_data = processlist_get_process_data(process_list,
444 // pid_out,
445 // process->cpu,
446 // &birth,
447 // trace_num);
448 if(hashed_process_data == NULL)
449 {
450 // g_assert(pid_out == 0 || pid_out != process->ppid);
451 /* Process not present */
452 ResourceInfo *process_info;
453 Drawing_t *drawing = control_flow_data->drawing;
454 resourcelist_add(process_list,
455 drawing,
456 trace_num,
457 cpuq, //process->name,
458 0, //cpu
459 cpu,
460 &pl_height,
461 &process_info,
462 &hashed_process_data);
463 gtk_widget_set_size_request(drawing->drawing_area,
464 -1,
465 pl_height);
466 gtk_widget_queue_draw(drawing->drawing_area);
467
468 }
469
470 /* Now, the process is in the state hash and our own process hash.
471 * We definitely can draw the items related to the ending state.
472 */
473
474 if(ltt_time_compare(hashed_process_data->next_good_time,
475 evtime) > 0)
476 {
477 if(hashed_process_data->x.middle_marked == FALSE) {
478
479 TimeWindow time_window =
480 lttvwindow_get_time_window(control_flow_data->tab);
481 #ifdef EXTRA_CHECK
482 if(ltt_time_compare(evtime, time_window.start_time) == -1
483 || ltt_time_compare(evtime, time_window.end_time) == 1)
484 return;
485 #endif //EXTRA_CHECK
486 Drawing_t *drawing = control_flow_data->drawing;
487 guint width = drawing->width;
488 guint x;
489 convert_time_to_pixels(
490 time_window,
491 evtime,
492 width,
493 &x);
494
495 /* Draw collision indicator */
496 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
497 gdk_draw_point(hashed_process_data->pixmap,
498 drawing->gc,
499 x,
500 COLLISION_POSITION(hashed_process_data->height));
501 hashed_process_data->x.middle_marked = TRUE;
502 }
503 } else {
504 TimeWindow time_window =
505 lttvwindow_get_time_window(control_flow_data->tab);
506 #ifdef EXTRA_CHECK
507 if(ltt_time_compare(evtime, time_window.start_time) == -1
508 || ltt_time_compare(evtime, time_window.end_time) == 1)
509 return;
510 #endif //EXTRA_CHECK
511 Drawing_t *drawing = control_flow_data->drawing;
512 guint width = drawing->width;
513 guint x;
514 convert_time_to_pixels(
515 time_window,
516 evtime,
517 width,
518 &x);
519
520
521 /* Jump over draw if we are at the same x position */
522 if(x == hashed_process_data->x.middle &&
523 hashed_process_data->x.middle_used)
524 {
525 if(hashed_process_data->x.middle_marked == FALSE) {
526 /* Draw collision indicator */
527 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
528 gdk_draw_point(hashed_process_data->pixmap,
529 drawing->gc,
530 x,
531 COLLISION_POSITION(hashed_process_data->height));
532 hashed_process_data->x.middle_marked = TRUE;
533 }
534 /* jump */
535 } else {
536 DrawContext draw_context;
537
538 /* Now create the drawing context that will be used to draw
539 * items related to the last state. */
540 draw_context.drawable = hashed_process_data->pixmap;
541 draw_context.gc = drawing->gc;
542 draw_context.pango_layout = drawing->pango_layout;
543 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
544 draw_context.drawinfo.end.x = x;
545
546 draw_context.drawinfo.y.over = 1;
547 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
548 draw_context.drawinfo.y.under = hashed_process_data->height;
549
550 draw_context.drawinfo.start.offset.over = 0;
551 draw_context.drawinfo.start.offset.middle = 0;
552 draw_context.drawinfo.start.offset.under = 0;
553 draw_context.drawinfo.end.offset.over = 0;
554 draw_context.drawinfo.end.offset.middle = 0;
555 draw_context.drawinfo.end.offset.under = 0;
556
557 {
558 /* Draw the line */
559 //PropertiesLine prop_line = prepare_s_e_line(process);
560 PropertiesLine prop_line;
561 prop_line.line_width = STATE_LINE_WIDTH;
562 prop_line.style = GDK_LINE_SOLID;
563 prop_line.y = MIDDLE;
564 cpu_set_line_color(&prop_line, tfs->cpu_state);
565 draw_line((void*)&prop_line, (void*)&draw_context);
566
567 }
568 /* become the last x position */
569 hashed_process_data->x.middle = x;
570 hashed_process_data->x.middle_used = TRUE;
571 hashed_process_data->x.middle_marked = FALSE;
572
573 /* Calculate the next good time */
574 convert_pixels_to_time(width, x+1, time_window,
575 &hashed_process_data->next_good_time);
576 }
577 }
578 // }
579 // }
580
581 // tfc->target_pid = pid_in;
582 // if(!filter || !filter->head ||
583 // lttv_filter_tree_parse(filter->head,e,tfc->tf,
584 // tfc->t_context->t,tfc,NULL,NULL)) {
585 // /* For the pid_in */
586 // /* First, check if the current process is in the state computation
587 // * process list. If it is there, that means we must add it right now and
588 // * draw items from the beginning of the read for it. If it is not
589 // * present, it's a new process and it was not present : it will
590 // * be added after the state update. */
591 // LttvProcessState *process;
592 // process = lttv_state_find_process(ts,
593 // tfs->cpu, pid_in);
594 // guint trace_num = ts->parent.index;
595 //
596 // if(process != NULL) {
597 // /* Well, the process existed : we must get it in the process hash
598 // * or add it, and draw its items.
599 // */
600 // /* Add process to process list (if not present) */
601 // guint pl_height = 0;
602 // HashedResourceData *hashed_process_data = NULL;
603 // ProcessList *process_list = control_flow_data->process_list;
604 // LttTime birth = process->creation_time;
605 //
606 // hashed_process_data = processlist_get_process_data(process_list, cpuq);
607 //// hashed_process_data = processlist_get_process_data(process_list,
608 //// pid_in,
609 //// tfs->cpu,
610 //// &birth,
611 //// trace_num);
612 // if(hashed_process_data == NULL)
613 // {
614 // g_assert(pid_in == 0 || pid_in != process->ppid);
615 // /* Process not present */
616 // ResourceInfo *process_info;
617 // Drawing_t *drawing = control_flow_data->drawing;
618 // resourcelist_add(process_list,
619 // drawing,
620 //// pid_in,
621 //// process->tgid,
622 //// tfs->cpu,
623 //// process->ppid,
624 //// &birth,
625 //// trace_num,
626 // process->name,
627 //// process->brand,
628 // &pl_height,
629 // &process_info,
630 // &hashed_process_data);
631 // gtk_widget_set_size_request(drawing->drawing_area,
632 // -1,
633 // pl_height);
634 // gtk_widget_queue_draw(drawing->drawing_area);
635 //
636 // }
637 // //We could set the current process and hash here, but will be done
638 // //by after schedchange hook
639 //
640 // /* Now, the process is in the state hash and our own process hash.
641 // * We definitely can draw the items related to the ending state.
642 // */
643 //
644 // if(ltt_time_compare(hashed_process_data->next_good_time,
645 // evtime) > 0)
646 // {
647 // if(hashed_process_data->x.middle_marked == FALSE) {
648 //
649 // TimeWindow time_window =
650 // lttvwindow_get_time_window(control_flow_data->tab);
651 //#ifdef EXTRA_CHECK
652 // if(ltt_time_compare(evtime, time_window.start_time) == -1
653 // || ltt_time_compare(evtime, time_window.end_time) == 1)
654 // return;
655 //#endif //EXTRA_CHECK
656 // Drawing_t *drawing = control_flow_data->drawing;
657 // guint width = drawing->width;
658 // guint x;
659 // convert_time_to_pixels(
660 // time_window,
661 // evtime,
662 // width,
663 // &x);
664 //
665 // /* Draw collision indicator */
666 // gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
667 // gdk_draw_point(hashed_process_data->pixmap,
668 // drawing->gc,
669 // x,
670 // COLLISION_POSITION(hashed_process_data->height));
671 // hashed_process_data->x.middle_marked = TRUE;
672 // }
673 // } else {
674 // TimeWindow time_window =
675 // lttvwindow_get_time_window(control_flow_data->tab);
676 //#ifdef EXTRA_CHECK
677 // if(ltt_time_compare(evtime, time_window.start_time) == -1
678 // || ltt_time_compare(evtime, time_window.end_time) == 1)
679 // return;
680 //#endif //EXTRA_CHECK
681 // Drawing_t *drawing = control_flow_data->drawing;
682 // guint width = drawing->width;
683 // guint x;
684 //
685 // convert_time_to_pixels(
686 // time_window,
687 // evtime,
688 // width,
689 // &x);
690 //
691 //
692 // /* Jump over draw if we are at the same x position */
693 // if(x == hashed_process_data->x.middle &&
694 // hashed_process_data->x.middle_used)
695 // {
696 // if(hashed_process_data->x.middle_marked == FALSE) {
697 // /* Draw collision indicator */
698 // gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
699 // gdk_draw_point(hashed_process_data->pixmap,
700 // drawing->gc,
701 // x,
702 // COLLISION_POSITION(hashed_process_data->height));
703 // hashed_process_data->x.middle_marked = TRUE;
704 // }
705 // /* jump */
706 // } else {
707 // DrawContext draw_context;
708 //
709 // /* Now create the drawing context that will be used to draw
710 // * items related to the last state. */
711 // draw_context.drawable = hashed_process_data->pixmap;
712 // draw_context.gc = drawing->gc;
713 // draw_context.pango_layout = drawing->pango_layout;
714 // draw_context.drawinfo.start.x = hashed_process_data->x.middle;
715 // draw_context.drawinfo.end.x = x;
716 //
717 // draw_context.drawinfo.y.over = 1;
718 // draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
719 // draw_context.drawinfo.y.under = hashed_process_data->height;
720 //
721 // draw_context.drawinfo.start.offset.over = 0;
722 // draw_context.drawinfo.start.offset.middle = 0;
723 // draw_context.drawinfo.start.offset.under = 0;
724 // draw_context.drawinfo.end.offset.over = 0;
725 // draw_context.drawinfo.end.offset.middle = 0;
726 // draw_context.drawinfo.end.offset.under = 0;
727 //
728 // {
729 // /* Draw the line */
730 // PropertiesLine prop_line = prepare_s_e_line(process);
731 // draw_line((void*)&prop_line, (void*)&draw_context);
732 // }
733 //
734 //
735 // /* become the last x position */
736 // hashed_process_data->x.middle = x;
737 // hashed_process_data->x.middle_used = TRUE;
738 // hashed_process_data->x.middle_marked = FALSE;
739 //
740 // /* Calculate the next good time */
741 // convert_pixels_to_time(width, x+1, time_window,
742 // &hashed_process_data->next_good_time);
743 // }
744 // }
745 // } else
746 // g_warning("Cannot find pin_in in schedchange %u", pid_in);
747 // }
748 // tfc->target_pid = target_pid_saved;
749 return 0;
750
751
752
753
754 /* Text dump */
755 #ifdef DONTSHOW
756 GString *string = g_string_new("");;
757 gboolean field_names = TRUE, state = TRUE;
758
759 lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs);
760 g_string_append_printf(string,"\n");
761
762 if(state) {
763 g_string_append_printf(string, " %s",
764 g_quark_to_string(tfs->process->state->s));
765 }
766
767 g_info("%s",string->str);
768
769 g_string_free(string, TRUE);
770
771 /* End of text dump */
772 #endif //DONTSHOW
773
774 }
775
776 /* after_schedchange_hook
777 *
778 * The draw after hook is called by the reading API to have a
779 * particular event drawn on the screen.
780 * @param hook_data ControlFlowData structure of the viewer.
781 * @param call_data Event context.
782 *
783 * This function adds items to be drawn in a queue for each process.
784 *
785 */
786 int after_schedchange_hook(void *hook_data, void *call_data)
787 {
788 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
789 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
790 ControlFlowData *control_flow_data = events_request->viewer_data;
791
792 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
793
794 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
795
796 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
797
798 LttEvent *e;
799 e = ltt_tracefile_get_event(tfc->tf);
800
801 LttvFilter *filter = control_flow_data->filter;
802 if(filter != NULL && filter->head != NULL)
803 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
804 tfc->t_context->t,tfc,NULL,NULL))
805 return FALSE;
806
807 LttTime evtime = ltt_event_time(e);
808
809 GQuark cpuq;
810
811 /* Add process to process list (if not present) */
812 LttvProcessState *process_in;
813 LttTime birth;
814 guint pl_height = 0;
815 HashedResourceData *hashed_process_data_in = NULL;
816
817 ProcessList *process_list = control_flow_data->process_list;
818
819 guint pid_in;
820 {
821 guint pid_out;
822 pid_out = ltt_event_get_long_unsigned(e, thf->f1);
823 pid_in = ltt_event_get_long_unsigned(e, thf->f2);
824 }
825
826
827 /* Find process pid_in in the list... */
828 //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
829 //process_in = tfs->process;
830 guint cpu = tfs->cpu;
831 {
832 gchar *cpustr;
833 cpustr = g_strdup_printf("CPU%u", cpu);
834 cpuq = g_quark_from_string(cpustr);
835 g_free(cpustr);
836 }
837 guint trace_num = ts->parent.index;
838 process_in = ts->running_process[cpu];
839 /* It should exist, because we are after the state update. */
840 #ifdef EXTRA_CHECK
841 g_assert(process_in != NULL);
842 #endif //EXTRA_CHECK
843 birth = process_in->creation_time;
844
845 hashed_process_data_in = processlist_get_process_data(process_list, cpuq, trace_num);
846 // hashed_process_data_in = processlist_get_process_data(process_list,
847 // pid_in,
848 // process_in->cpu,
849 // &birth,
850 // trace_num);
851 if(hashed_process_data_in == NULL)
852 {
853 g_assert(pid_in == 0 || pid_in != process_in->ppid);
854 ResourceInfo *process_info;
855 Drawing_t *drawing = control_flow_data->drawing;
856 /* Process not present */
857 resourcelist_add(process_list,
858 drawing,
859 trace_num,
860 cpuq,
861 0,
862 cpu,
863 &pl_height,
864 &process_info,
865 &hashed_process_data_in);
866 gtk_widget_set_size_request(drawing->drawing_area,
867 -1,
868 pl_height);
869 gtk_widget_queue_draw(drawing->drawing_area);
870 }
871 /* Set the current process */
872 process_list->current_hash_data[trace_num][process_in->cpu] =
873 hashed_process_data_in;
874
875 if(ltt_time_compare(hashed_process_data_in->next_good_time,
876 evtime) <= 0)
877 {
878 TimeWindow time_window =
879 lttvwindow_get_time_window(control_flow_data->tab);
880
881 #ifdef EXTRA_CHECK
882 if(ltt_time_compare(evtime, time_window.start_time) == -1
883 || ltt_time_compare(evtime, time_window.end_time) == 1)
884 return;
885 #endif //EXTRA_CHECK
886 Drawing_t *drawing = control_flow_data->drawing;
887 guint width = drawing->width;
888 guint new_x;
889
890 convert_time_to_pixels(
891 time_window,
892 evtime,
893 width,
894 &new_x);
895
896 if(hashed_process_data_in->x.middle != new_x) {
897 hashed_process_data_in->x.middle = new_x;
898 hashed_process_data_in->x.middle_used = FALSE;
899 hashed_process_data_in->x.middle_marked = FALSE;
900 }
901 }
902 return 0;
903 }
904
905 /* before_execmode_hook
906 *
907 * This function basically draw lines and icons. Two types of lines are drawn :
908 * one small (3 pixels?) representing the state of the process and the second
909 * type is thicker (10 pixels?) representing on which CPU a process is running
910 * (and this only in running state).
911 *
912 * Extremums of the lines :
913 * x_min : time of the last event context for this process kept in memory.
914 * x_max : time of the current event.
915 * y : middle of the process in the process list. The process is found in the
916 * list, therefore is it's position in pixels.
917 *
918 * The choice of lines'color is defined by the context of the last event for this
919 * process.
920 */
921
922 int before_execmode_hook(void *hook_data, void *call_data)
923 {
924 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
925 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
926 ControlFlowData *control_flow_data = events_request->viewer_data;
927
928 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
929
930 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
931 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
932
933 LttEvent *e;
934 e = ltt_tracefile_get_event(tfc->tf);
935
936 LttTime evtime = ltt_event_time(e);
937
938 GQuark cpuq;
939
940 before_execmode_hook_irq(hook_data, call_data);
941
942 /* we are in a execmode, before the state update. We must draw the
943 * items corresponding to the state before it changes : now is the right
944 * time to do it.
945 */
946 /* For the pid */
947 //LttvProcessState *process = tfs->process;
948 guint cpu = tfs->cpu;
949 {
950 gchar *cpustr;
951 cpustr = g_strdup_printf("CPU%u", cpu);
952 cpuq = g_quark_from_string(cpustr);
953 g_free(cpustr);
954 }
955 guint trace_num = ts->parent.index;
956 LttvProcessState *process = ts->running_process[cpu];
957 g_assert(process != NULL);
958
959 // guint pid = process->pid;
960
961 /* Well, the process_out existed : we must get it in the process hash
962 * or add it, and draw its items.
963 */
964 /* Add process to process list (if not present) */
965 guint pl_height = 0;
966 HashedResourceData *hashed_process_data = NULL;
967 ProcessList *process_list = control_flow_data->process_list;
968 LttTime birth = process->creation_time;
969
970 if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
971 hashed_process_data = process_list->current_hash_data[trace_num][cpu];
972 } else {
973 hashed_process_data = processlist_get_process_data(process_list, cpuq, trace_num);
974 // hashed_process_data = processlist_get_process_data(process_list,
975 // pid,
976 // process->cpu,
977 // &birth,
978 // trace_num);
979 if(unlikely(hashed_process_data == NULL))
980 {
981 //g_assert(pid == 0 || pid != process->ppid);
982 ResourceInfo *process_info;
983 /* Process not present */
984 Drawing_t *drawing = control_flow_data->drawing;
985 resourcelist_add(process_list,
986 drawing,
987 trace_num,
988 cpuq, //process->name,
989 0, //cpu
990 cpu,
991 &pl_height,
992 &process_info,
993 &hashed_process_data);
994 gtk_widget_set_size_request(drawing->drawing_area,
995 -1,
996 pl_height);
997 gtk_widget_queue_draw(drawing->drawing_area);
998 }
999 /* Set the current process */
1000 process_list->current_hash_data[trace_num][process->cpu] =
1001 hashed_process_data;
1002 }
1003
1004 /* Now, the process is in the state hash and our own process hash.
1005 * We definitely can draw the items related to the ending state.
1006 */
1007
1008 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1009 evtime) > 0))
1010 {
1011 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1012 TimeWindow time_window =
1013 lttvwindow_get_time_window(control_flow_data->tab);
1014
1015 #ifdef EXTRA_CHECK
1016 if(ltt_time_compare(evtime, time_window.start_time) == -1
1017 || ltt_time_compare(evtime, time_window.end_time) == 1)
1018 return;
1019 #endif //EXTRA_CHECK
1020 Drawing_t *drawing = control_flow_data->drawing;
1021 guint width = drawing->width;
1022 guint x;
1023 convert_time_to_pixels(
1024 time_window,
1025 evtime,
1026 width,
1027 &x);
1028
1029 /* Draw collision indicator */
1030 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1031 gdk_draw_point(hashed_process_data->pixmap,
1032 drawing->gc,
1033 x,
1034 COLLISION_POSITION(hashed_process_data->height));
1035 hashed_process_data->x.middle_marked = TRUE;
1036 }
1037 }
1038 else {
1039 TimeWindow time_window =
1040 lttvwindow_get_time_window(control_flow_data->tab);
1041
1042 #ifdef EXTRA_CHECK
1043 if(ltt_time_compare(evtime, time_window.start_time) == -1
1044 || ltt_time_compare(evtime, time_window.end_time) == 1)
1045 return;
1046 #endif //EXTRA_CHECK
1047 Drawing_t *drawing = control_flow_data->drawing;
1048 guint width = drawing->width;
1049 guint x;
1050
1051 convert_time_to_pixels(
1052 time_window,
1053 evtime,
1054 width,
1055 &x);
1056
1057
1058 /* Jump over draw if we are at the same x position */
1059 if(unlikely(x == hashed_process_data->x.middle &&
1060 hashed_process_data->x.middle_used))
1061 {
1062 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1063 /* Draw collision indicator */
1064 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1065 gdk_draw_point(hashed_process_data->pixmap,
1066 drawing->gc,
1067 x,
1068 COLLISION_POSITION(hashed_process_data->height));
1069 hashed_process_data->x.middle_marked = TRUE;
1070 }
1071 /* jump */
1072 }
1073 else {
1074
1075 DrawContext draw_context;
1076 /* Now create the drawing context that will be used to draw
1077 * items related to the last state. */
1078 draw_context.drawable = hashed_process_data->pixmap;
1079 draw_context.gc = drawing->gc;
1080 draw_context.pango_layout = drawing->pango_layout;
1081 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1082 draw_context.drawinfo.end.x = x;
1083
1084 draw_context.drawinfo.y.over = 1;
1085 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1086 draw_context.drawinfo.y.under = hashed_process_data->height;
1087
1088 draw_context.drawinfo.start.offset.over = 0;
1089 draw_context.drawinfo.start.offset.middle = 0;
1090 draw_context.drawinfo.start.offset.under = 0;
1091 draw_context.drawinfo.end.offset.over = 0;
1092 draw_context.drawinfo.end.offset.middle = 0;
1093 draw_context.drawinfo.end.offset.under = 0;
1094
1095 {
1096 /* Draw the line */
1097 PropertiesLine prop_line;
1098 prop_line.line_width = STATE_LINE_WIDTH;
1099 prop_line.style = GDK_LINE_SOLID;
1100 prop_line.y = MIDDLE;
1101 cpu_set_line_color(&prop_line, tfs->cpu_state);
1102 draw_line((void*)&prop_line, (void*)&draw_context);
1103 }
1104 /* become the last x position */
1105 hashed_process_data->x.middle = x;
1106 hashed_process_data->x.middle_used = TRUE;
1107 hashed_process_data->x.middle_marked = FALSE;
1108
1109 /* Calculate the next good time */
1110 convert_pixels_to_time(width, x+1, time_window,
1111 &hashed_process_data->next_good_time);
1112 }
1113 }
1114
1115 return 0;
1116 }
1117
1118 int before_execmode_hook_irq(void *hook_data, void *call_data)
1119 {
1120 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
1121 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
1122 ControlFlowData *control_flow_data = events_request->viewer_data;
1123
1124 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1125
1126 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1127 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1128
1129 LttEvent *e;
1130 e = ltt_tracefile_get_event(tfc->tf);
1131
1132 LttTime evtime = ltt_event_time(e);
1133
1134 GQuark resourceq;
1135
1136 /* we are in a execmode, before the state update. We must draw the
1137 * items corresponding to the state before it changes : now is the right
1138 * time to do it.
1139 */
1140 /* For the pid */
1141
1142 guint64 irq;
1143 guint cpu = tfs->cpu;
1144
1145 LttFacility *ev_facility = ltt_event_facility(e);
1146 if(ltt_facility_name(ev_facility) != LTT_FACILITY_KERNEL)
1147 return 0;
1148 guint8 ev_id_entry = ltt_eventtype_id(ltt_facility_eventtype_get_by_name(ev_facility, LTT_EVENT_IRQ_ENTRY));
1149 guint8 ev_id_exit = ltt_eventtype_id(ltt_facility_eventtype_get_by_name(ev_facility, LTT_EVENT_IRQ_EXIT));
1150 if(ltt_facility_name(ev_facility) == LTT_FACILITY_KERNEL &&
1151 ev_id_entry == ltt_event_eventtype_id(e)) {
1152 irq = ltt_event_get_long_unsigned(e, thf->f1);
1153 }
1154 else if(ltt_facility_name(ev_facility) == LTT_FACILITY_KERNEL &&
1155 ev_id_exit == ltt_event_eventtype_id(e)) {
1156 irq = ts->cpu_states[cpu].last_irq;
1157 }
1158 else {
1159 return 0;
1160 }
1161
1162 {
1163 gchar *irqstr;
1164 irqstr = g_strdup_printf("IRQ %u", irq);
1165 resourceq = g_quark_from_string(irqstr);
1166 g_free(irqstr);
1167 }
1168 guint trace_num = ts->parent.index;
1169
1170 // guint pid = process->pid;
1171
1172 /* Well, the process_out existed : we must get it in the process hash
1173 * or add it, and draw its items.
1174 */
1175 /* Add process to process list (if not present) */
1176 guint pl_height = 0;
1177 HashedResourceData *hashed_process_data = NULL;
1178 ProcessList *process_list = control_flow_data->process_list;
1179 // LttTime birth = process->creation_time;
1180
1181 // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) {
1182 // hashed_process_data = process_list->current_hash_data[trace_num][cpu];
1183 // } else {
1184 hashed_process_data = processlist_get_process_data(process_list, resourceq, trace_num);
1185 // hashed_process_data = processlist_get_process_data(process_list,
1186 // pid,
1187 // process->cpu,
1188 // &birth,
1189 // trace_num);
1190 if(unlikely(hashed_process_data == NULL))
1191 {
1192 //g_assert(pid == 0 || pid != process->ppid);
1193 ResourceInfo *process_info;
1194 /* Process not present */
1195 Drawing_t *drawing = control_flow_data->drawing;
1196 resourcelist_add(process_list,
1197 drawing,
1198 trace_num,
1199 resourceq, //process->name,
1200 1, //irq
1201 irq,
1202 &pl_height,
1203 &process_info,
1204 &hashed_process_data);
1205 gtk_widget_set_size_request(drawing->drawing_area,
1206 -1,
1207 pl_height);
1208 gtk_widget_queue_draw(drawing->drawing_area);
1209 }
1210 /* Set the current process */
1211 // process_list->current_hash_data[trace_num][process->cpu] =
1212 // hashed_process_data;
1213 // }
1214
1215 /* Now, the process is in the state hash and our own process hash.
1216 * We definitely can draw the items related to the ending state.
1217 */
1218
1219 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1220 evtime) > 0))
1221 {
1222 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1223 TimeWindow time_window =
1224 lttvwindow_get_time_window(control_flow_data->tab);
1225
1226 #ifdef EXTRA_CHECK
1227 if(ltt_time_compare(evtime, time_window.start_time) == -1
1228 || ltt_time_compare(evtime, time_window.end_time) == 1)
1229 return;
1230 #endif //EXTRA_CHECK
1231 Drawing_t *drawing = control_flow_data->drawing;
1232 guint width = drawing->width;
1233 guint x;
1234 convert_time_to_pixels(
1235 time_window,
1236 evtime,
1237 width,
1238 &x);
1239
1240 /* Draw collision indicator */
1241 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1242 gdk_draw_point(hashed_process_data->pixmap,
1243 drawing->gc,
1244 x,
1245 COLLISION_POSITION(hashed_process_data->height));
1246 hashed_process_data->x.middle_marked = TRUE;
1247 }
1248 }
1249 else {
1250 TimeWindow time_window =
1251 lttvwindow_get_time_window(control_flow_data->tab);
1252
1253 #ifdef EXTRA_CHECK
1254 if(ltt_time_compare(evtime, time_window.start_time) == -1
1255 || ltt_time_compare(evtime, time_window.end_time) == 1)
1256 return;
1257 #endif //EXTRA_CHECK
1258 Drawing_t *drawing = control_flow_data->drawing;
1259 guint width = drawing->width;
1260 guint x;
1261
1262 convert_time_to_pixels(
1263 time_window,
1264 evtime,
1265 width,
1266 &x);
1267
1268
1269 /* Jump over draw if we are at the same x position */
1270 if(unlikely(x == hashed_process_data->x.middle &&
1271 hashed_process_data->x.middle_used))
1272 {
1273 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1274 /* Draw collision indicator */
1275 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1276 gdk_draw_point(hashed_process_data->pixmap,
1277 drawing->gc,
1278 x,
1279 COLLISION_POSITION(hashed_process_data->height));
1280 hashed_process_data->x.middle_marked = TRUE;
1281 }
1282 /* jump */
1283 }
1284 else {
1285
1286 DrawContext draw_context;
1287 /* Now create the drawing context that will be used to draw
1288 * items related to the last state. */
1289 draw_context.drawable = hashed_process_data->pixmap;
1290 draw_context.gc = drawing->gc;
1291 draw_context.pango_layout = drawing->pango_layout;
1292 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1293 draw_context.drawinfo.end.x = x;
1294
1295 draw_context.drawinfo.y.over = 1;
1296 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1297 draw_context.drawinfo.y.under = hashed_process_data->height;
1298
1299 draw_context.drawinfo.start.offset.over = 0;
1300 draw_context.drawinfo.start.offset.middle = 0;
1301 draw_context.drawinfo.start.offset.under = 0;
1302 draw_context.drawinfo.end.offset.over = 0;
1303 draw_context.drawinfo.end.offset.middle = 0;
1304 draw_context.drawinfo.end.offset.under = 0;
1305
1306 {
1307 /* Draw the line */
1308 PropertiesLine prop_line;
1309 prop_line.line_width = STATE_LINE_WIDTH;
1310 prop_line.style = GDK_LINE_SOLID;
1311 prop_line.y = MIDDLE;
1312 irq_set_line_color(&prop_line, &ts->irq_states[irq]);
1313 draw_line((void*)&prop_line, (void*)&draw_context);
1314 }
1315 /* become the last x position */
1316 hashed_process_data->x.middle = x;
1317 hashed_process_data->x.middle_used = TRUE;
1318 hashed_process_data->x.middle_marked = FALSE;
1319
1320 /* Calculate the next good time */
1321 convert_pixels_to_time(width, x+1, time_window,
1322 &hashed_process_data->next_good_time);
1323 }
1324 }
1325
1326 return 0;
1327 }
1328
1329 gint update_time_window_hook(void *hook_data, void *call_data)
1330 {
1331 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
1332 Drawing_t *drawing = control_flow_data->drawing;
1333 ProcessList *process_list = control_flow_data->process_list;
1334
1335 const TimeWindowNotifyData *time_window_nofify_data =
1336 ((const TimeWindowNotifyData *)call_data);
1337
1338 TimeWindow *old_time_window =
1339 time_window_nofify_data->old_time_window;
1340 TimeWindow *new_time_window =
1341 time_window_nofify_data->new_time_window;
1342
1343 /* Update the ruler */
1344 drawing_update_ruler(control_flow_data->drawing,
1345 new_time_window);
1346
1347
1348 /* Two cases : zoom in/out or scrolling */
1349
1350 /* In order to make sure we can reuse the old drawing, the scale must
1351 * be the same and the new time interval being partly located in the
1352 * currently shown time interval. (reuse is only for scrolling)
1353 */
1354
1355 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
1356 old_time_window->start_time.tv_sec,
1357 old_time_window->start_time.tv_nsec,
1358 old_time_window->time_width.tv_sec,
1359 old_time_window->time_width.tv_nsec);
1360
1361 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
1362 new_time_window->start_time.tv_sec,
1363 new_time_window->start_time.tv_nsec,
1364 new_time_window->time_width.tv_sec,
1365 new_time_window->time_width.tv_nsec);
1366
1367 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
1368 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
1369 {
1370 /* Same scale (scrolling) */
1371 g_info("scrolling");
1372 LttTime *ns = &new_time_window->start_time;
1373 LttTime *nw = &new_time_window->time_width;
1374 LttTime *os = &old_time_window->start_time;
1375 LttTime *ow = &old_time_window->time_width;
1376 LttTime old_end = old_time_window->end_time;
1377 LttTime new_end = new_time_window->end_time;
1378 //if(ns<os+w<ns+w)
1379 //if(ns<os+w && os+w<ns+w)
1380 //if(ns<old_end && os<ns)
1381 if(ltt_time_compare(*ns, old_end) == -1
1382 && ltt_time_compare(*os, *ns) == -1)
1383 {
1384 g_info("scrolling near right");
1385 /* Scroll right, keep right part of the screen */
1386 guint x = 0;
1387 guint width = control_flow_data->drawing->width;
1388 convert_time_to_pixels(
1389 *old_time_window,
1390 *ns,
1391 width,
1392 &x);
1393
1394 /* Copy old data to new location */
1395 copy_pixmap_region(process_list,
1396 NULL,
1397 control_flow_data->drawing->drawing_area->style->black_gc,
1398 NULL,
1399 x, 0,
1400 0, 0,
1401 control_flow_data->drawing->width-x+SAFETY, -1);
1402
1403 if(drawing->damage_begin == drawing->damage_end)
1404 drawing->damage_begin = control_flow_data->drawing->width-x;
1405 else
1406 drawing->damage_begin = 0;
1407
1408 drawing->damage_end = control_flow_data->drawing->width;
1409
1410 /* Clear the data request background, but not SAFETY */
1411 rectangle_pixmap(process_list,
1412 control_flow_data->drawing->drawing_area->style->black_gc,
1413 TRUE,
1414 drawing->damage_begin+SAFETY, 0,
1415 drawing->damage_end - drawing->damage_begin, // do not overlap
1416 -1);
1417 gtk_widget_queue_draw(drawing->drawing_area);
1418 //gtk_widget_queue_draw_area (drawing->drawing_area,
1419 // 0,0,
1420 // control_flow_data->drawing->width,
1421 // control_flow_data->drawing->height);
1422
1423 /* Get new data for the rest. */
1424 drawing_data_request(control_flow_data->drawing,
1425 drawing->damage_begin, 0,
1426 drawing->damage_end - drawing->damage_begin,
1427 control_flow_data->drawing->height);
1428 } else {
1429 //if(ns<os<ns+w)
1430 //if(ns<os && os<ns+w)
1431 //if(ns<os && os<new_end)
1432 if(ltt_time_compare(*ns,*os) == -1
1433 && ltt_time_compare(*os,new_end) == -1)
1434 {
1435 g_info("scrolling near left");
1436 /* Scroll left, keep left part of the screen */
1437 guint x = 0;
1438 guint width = control_flow_data->drawing->width;
1439 convert_time_to_pixels(
1440 *new_time_window,
1441 *os,
1442 width,
1443 &x);
1444
1445 /* Copy old data to new location */
1446 copy_pixmap_region (process_list,
1447 NULL,
1448 control_flow_data->drawing->drawing_area->style->black_gc,
1449 NULL,
1450 0, 0,
1451 x, 0,
1452 -1, -1);
1453
1454 if(drawing->damage_begin == drawing->damage_end)
1455 drawing->damage_end = x;
1456 else
1457 drawing->damage_end =
1458 control_flow_data->drawing->width;
1459
1460 drawing->damage_begin = 0;
1461
1462 rectangle_pixmap (process_list,
1463 control_flow_data->drawing->drawing_area->style->black_gc,
1464 TRUE,
1465 drawing->damage_begin, 0,
1466 drawing->damage_end - drawing->damage_begin, // do not overlap
1467 -1);
1468
1469 gtk_widget_queue_draw(drawing->drawing_area);
1470 //gtk_widget_queue_draw_area (drawing->drawing_area,
1471 // 0,0,
1472 // control_flow_data->drawing->width,
1473 // control_flow_data->drawing->height);
1474
1475
1476 /* Get new data for the rest. */
1477 drawing_data_request(control_flow_data->drawing,
1478 drawing->damage_begin, 0,
1479 drawing->damage_end - drawing->damage_begin,
1480 control_flow_data->drawing->height);
1481
1482 } else {
1483 if(ltt_time_compare(*ns,*os) == 0)
1484 {
1485 g_info("not scrolling");
1486 } else {
1487 g_info("scrolling far");
1488 /* Cannot reuse any part of the screen : far jump */
1489
1490
1491 rectangle_pixmap (process_list,
1492 control_flow_data->drawing->drawing_area->style->black_gc,
1493 TRUE,
1494 0, 0,
1495 control_flow_data->drawing->width+SAFETY, // do not overlap
1496 -1);
1497
1498 //gtk_widget_queue_draw_area (drawing->drawing_area,
1499 // 0,0,
1500 // control_flow_data->drawing->width,
1501 // control_flow_data->drawing->height);
1502 gtk_widget_queue_draw(drawing->drawing_area);
1503
1504 drawing->damage_begin = 0;
1505 drawing->damage_end = control_flow_data->drawing->width;
1506
1507 drawing_data_request(control_flow_data->drawing,
1508 0, 0,
1509 control_flow_data->drawing->width,
1510 control_flow_data->drawing->height);
1511
1512 }
1513 }
1514 }
1515 } else {
1516 /* Different scale (zoom) */
1517 g_info("zoom");
1518
1519 rectangle_pixmap (process_list,
1520 control_flow_data->drawing->drawing_area->style->black_gc,
1521 TRUE,
1522 0, 0,
1523 control_flow_data->drawing->width+SAFETY, // do not overlap
1524 -1);
1525
1526 //gtk_widget_queue_draw_area (drawing->drawing_area,
1527 // 0,0,
1528 // control_flow_data->drawing->width,
1529 // control_flow_data->drawing->height);
1530 gtk_widget_queue_draw(drawing->drawing_area);
1531
1532 drawing->damage_begin = 0;
1533 drawing->damage_end = control_flow_data->drawing->width;
1534
1535 drawing_data_request(control_flow_data->drawing,
1536 0, 0,
1537 control_flow_data->drawing->width,
1538 control_flow_data->drawing->height);
1539 }
1540
1541 /* Update directly when scrolling */
1542 gdk_window_process_updates(control_flow_data->drawing->drawing_area->window,
1543 TRUE);
1544
1545 return 0;
1546 }
1547
1548 gint traceset_notify(void *hook_data, void *call_data)
1549 {
1550 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
1551 Drawing_t *drawing = control_flow_data->drawing;
1552
1553 if(unlikely(drawing->gc == NULL)) {
1554 return FALSE;
1555 }
1556 if(drawing->dotted_gc == NULL) {
1557 return FALSE;
1558 }
1559
1560 drawing_clear(control_flow_data->drawing);
1561 processlist_clear(control_flow_data->process_list);
1562 gtk_widget_set_size_request(
1563 control_flow_data->drawing->drawing_area,
1564 -1, processlist_get_height(control_flow_data->process_list));
1565 redraw_notify(control_flow_data, NULL);
1566
1567 request_background_data(control_flow_data);
1568
1569 return FALSE;
1570 }
1571
1572 gint redraw_notify(void *hook_data, void *call_data)
1573 {
1574 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
1575 Drawing_t *drawing = control_flow_data->drawing;
1576 GtkWidget *widget = drawing->drawing_area;
1577
1578 drawing->damage_begin = 0;
1579 drawing->damage_end = drawing->width;
1580
1581 /* fun feature, to be separated someday... */
1582 drawing_clear(control_flow_data->drawing);
1583 processlist_clear(control_flow_data->process_list);
1584 gtk_widget_set_size_request(
1585 control_flow_data->drawing->drawing_area,
1586 -1, processlist_get_height(control_flow_data->process_list));
1587 // Clear the images
1588 rectangle_pixmap (control_flow_data->process_list,
1589 widget->style->black_gc,
1590 TRUE,
1591 0, 0,
1592 drawing->alloc_width,
1593 -1);
1594
1595 gtk_widget_queue_draw(drawing->drawing_area);
1596
1597 if(drawing->damage_begin < drawing->damage_end)
1598 {
1599 drawing_data_request(drawing,
1600 drawing->damage_begin,
1601 0,
1602 drawing->damage_end-drawing->damage_begin,
1603 drawing->height);
1604 }
1605
1606 //gtk_widget_queue_draw_area(drawing->drawing_area,
1607 // 0,0,
1608 // drawing->width,
1609 // drawing->height);
1610 return FALSE;
1611
1612 }
1613
1614
1615 gint continue_notify(void *hook_data, void *call_data)
1616 {
1617 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
1618 Drawing_t *drawing = control_flow_data->drawing;
1619
1620 //g_assert(widget->allocation.width == drawing->damage_end);
1621
1622 if(drawing->damage_begin < drawing->damage_end)
1623 {
1624 drawing_data_request(drawing,
1625 drawing->damage_begin,
1626 0,
1627 drawing->damage_end-drawing->damage_begin,
1628 drawing->height);
1629 }
1630
1631 return FALSE;
1632 }
1633
1634
1635 gint update_current_time_hook(void *hook_data, void *call_data)
1636 {
1637 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
1638 Drawing_t *drawing = control_flow_data->drawing;
1639
1640 LttTime current_time = *((LttTime*)call_data);
1641
1642 TimeWindow time_window =
1643 lttvwindow_get_time_window(control_flow_data->tab);
1644
1645 LttTime time_begin = time_window.start_time;
1646 LttTime width = time_window.time_width;
1647 LttTime half_width;
1648 {
1649 guint64 time_ll = ltt_time_to_uint64(width);
1650 time_ll = time_ll >> 1; /* divide by two */
1651 half_width = ltt_time_from_uint64(time_ll);
1652 }
1653 LttTime time_end = ltt_time_add(time_begin, width);
1654
1655 LttvTracesetContext * tsc =
1656 lttvwindow_get_traceset_context(control_flow_data->tab);
1657
1658 LttTime trace_start = tsc->time_span.start_time;
1659 LttTime trace_end = tsc->time_span.end_time;
1660
1661 g_info("New current time HOOK : %lu, %lu", current_time.tv_sec,
1662 current_time.tv_nsec);
1663
1664
1665
1666 /* If current time is inside time interval, just move the highlight
1667 * bar */
1668
1669 /* Else, we have to change the time interval. We have to tell it
1670 * to the main window. */
1671 /* The time interval change will take care of placing the current
1672 * time at the center of the visible area, or nearest possible if we are
1673 * at one end of the trace. */
1674
1675
1676 if(ltt_time_compare(current_time, time_begin) < 0)
1677 {
1678 TimeWindow new_time_window;
1679
1680 if(ltt_time_compare(current_time,
1681 ltt_time_add(trace_start,half_width)) < 0)
1682 time_begin = trace_start;
1683 else
1684 time_begin = ltt_time_sub(current_time,half_width);
1685
1686 new_time_window.start_time = time_begin;
1687 new_time_window.time_width = width;
1688 new_time_window.time_width_double = ltt_time_to_double(width);
1689 new_time_window.end_time = ltt_time_add(time_begin, width);
1690
1691 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
1692 }
1693 else if(ltt_time_compare(current_time, time_end) > 0)
1694 {
1695 TimeWindow new_time_window;
1696
1697 if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0)
1698 time_begin = ltt_time_sub(trace_end,width);
1699 else
1700 time_begin = ltt_time_sub(current_time,half_width);
1701
1702 new_time_window.start_time = time_begin;
1703 new_time_window.time_width = width;
1704 new_time_window.time_width_double = ltt_time_to_double(width);
1705 new_time_window.end_time = ltt_time_add(time_begin, width);
1706
1707 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
1708
1709 }
1710 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
1711
1712 /* Update directly when scrolling */
1713 gdk_window_process_updates(control_flow_data->drawing->drawing_area->window,
1714 TRUE);
1715
1716 return 0;
1717 }
1718
1719 typedef struct _ClosureData {
1720 EventsRequest *events_request;
1721 LttvTracesetState *tss;
1722 LttTime end_time;
1723 guint x_end;
1724 } ClosureData;
1725
1726 /* Draw line until end of the screen */
1727
1728 void draw_closure(gpointer key, gpointer value, gpointer user_data)
1729 {
1730 ResourceInfo *process_info = (ResourceInfo*)key;
1731 HashedResourceData *hashed_process_data = (HashedResourceData*)value;
1732 ClosureData *closure_data = (ClosureData*)user_data;
1733
1734 EventsRequest *events_request = closure_data->events_request;
1735 ControlFlowData *control_flow_data = events_request->viewer_data;
1736
1737 LttvTracesetState *tss = closure_data->tss;
1738 LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
1739
1740 LttTime evtime = closure_data->end_time;
1741
1742 gboolean dodraw = TRUE;
1743
1744 {
1745 /* For the process */
1746 /* First, check if the current process is in the state computation
1747 * process list. If it is there, that means we must add it right now and
1748 * draw items from the beginning of the read for it. If it is not
1749 * present, it's a new process and it was not present : it will
1750 * be added after the state update. */
1751 #ifdef EXTRA_CHECK
1752 g_assert(lttv_traceset_number(tsc->ts) > 0);
1753 #endif //EXTRA_CHECK
1754 LttvTraceContext *tc = tsc->traces[process_info->trace_num];
1755 LttvTraceState *ts = (LttvTraceState*)tc;
1756
1757 #if 0
1758 //FIXME : optimize data structures.
1759 LttvTracefileState *tfs;
1760 LttvTracefileContext *tfc;
1761 guint i;
1762 for(i=0;i<tc->tracefiles->len;i++) {
1763 tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i);
1764 if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU
1765 && tfs->cpu == process_info->cpu)
1766 break;
1767
1768 }
1769 g_assert(i<tc->tracefiles->len);
1770 tfs = LTTV_TRACEFILE_STATE(tfc);
1771 #endif //0
1772 // LttvTracefileState *tfs =
1773 // (LttvTracefileState*)tsc->traces[process_info->trace_num]->
1774 // tracefiles[process_info->cpu];
1775
1776 // LttvProcessState *process;
1777 // process = lttv_state_find_process(ts, process_info->cpu,
1778 // process_info->pid);
1779
1780 // if(unlikely(process != NULL)) {
1781
1782 // LttvFilter *filter = control_flow_data->filter;
1783 // if(filter != NULL && filter->head != NULL)
1784 // if(!lttv_filter_tree_parse(filter->head,NULL,NULL,
1785 // tc->t,NULL,process,tc))
1786 // dodraw = FALSE;
1787
1788 /* Only draw for processes that are currently in the trace states */
1789
1790 ProcessList *process_list = control_flow_data->process_list;
1791 #ifdef EXTRA_CHECK
1792 /* Should be alike when background info is ready */
1793 if(control_flow_data->background_info_waiting==0)
1794 g_assert(ltt_time_compare(process->creation_time,
1795 process_info->birth) == 0);
1796 #endif //EXTRA_CHECK
1797
1798 /* Now, the process is in the state hash and our own process hash.
1799 * We definitely can draw the items related to the ending state.
1800 */
1801
1802 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
1803 evtime) <= 0))
1804 {
1805 TimeWindow time_window =
1806 lttvwindow_get_time_window(control_flow_data->tab);
1807
1808 #ifdef EXTRA_CHECK
1809 if(ltt_time_compare(evtime, time_window.start_time) == -1
1810 || ltt_time_compare(evtime, time_window.end_time) == 1)
1811 return;
1812 #endif //EXTRA_CHECK
1813 Drawing_t *drawing = control_flow_data->drawing;
1814 guint width = drawing->width;
1815
1816 guint x = closure_data->x_end;
1817
1818 DrawContext draw_context;
1819
1820 /* Now create the drawing context that will be used to draw
1821 * items related to the last state. */
1822 draw_context.drawable = hashed_process_data->pixmap;
1823 draw_context.gc = drawing->gc;
1824 draw_context.pango_layout = drawing->pango_layout;
1825 draw_context.drawinfo.end.x = x;
1826
1827 draw_context.drawinfo.y.over = 1;
1828 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1829 draw_context.drawinfo.y.under = hashed_process_data->height;
1830
1831 draw_context.drawinfo.start.offset.over = 0;
1832 draw_context.drawinfo.start.offset.middle = 0;
1833 draw_context.drawinfo.start.offset.under = 0;
1834 draw_context.drawinfo.end.offset.over = 0;
1835 draw_context.drawinfo.end.offset.middle = 0;
1836 draw_context.drawinfo.end.offset.under = 0;
1837 #if 0
1838 /* Jump over draw if we are at the same x position */
1839 if(x == hashed_process_data->x.over)
1840 {
1841 /* jump */
1842 } else {
1843 draw_context.drawinfo.start.x = hashed_process_data->x.over;
1844 /* Draw the line */
1845 PropertiesLine prop_line = prepare_execmode_line(process);
1846 draw_line((void*)&prop_line, (void*)&draw_context);
1847
1848 hashed_process_data->x.over = x;
1849 }
1850 #endif //0
1851
1852 if(unlikely(x == hashed_process_data->x.middle &&
1853 hashed_process_data->x.middle_used)) {
1854 #if 0 /* do not mark closure : not missing information */
1855 if(hashed_process_data->x.middle_marked == FALSE) {
1856 /* Draw collision indicator */
1857 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1858 gdk_draw_point(drawing->pixmap,
1859 drawing->gc,
1860 x,
1861 y+(height/2)-3);
1862 hashed_process_data->x.middle_marked = TRUE;
1863 }
1864 #endif //0
1865 /* Jump */
1866 } else {
1867 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1868 /* Draw the line */
1869 if(dodraw) {
1870 PropertiesLine prop_line;
1871 prop_line.line_width = STATE_LINE_WIDTH;
1872 prop_line.style = GDK_LINE_SOLID;
1873 prop_line.y = MIDDLE;
1874 if(process_info->type == 0)
1875 cpu_set_line_color(&prop_line, &ts->cpu_states[process_info->id]);
1876 else if(process_info->type == 1)
1877 irq_set_line_color(&prop_line, &ts->irq_states[process_info->id]);
1878
1879 draw_line((void*)&prop_line, (void*)&draw_context);
1880 }
1881
1882 /* become the last x position */
1883 if(likely(x != hashed_process_data->x.middle)) {
1884 hashed_process_data->x.middle = x;
1885 /* but don't use the pixel */
1886 hashed_process_data->x.middle_used = FALSE;
1887
1888 /* Calculate the next good time */
1889 convert_pixels_to_time(width, x+1, time_window,
1890 &hashed_process_data->next_good_time);
1891 }
1892 }
1893 }
1894 // }
1895 }
1896 return;
1897 }
1898
1899 int before_chunk(void *hook_data, void *call_data)
1900 {
1901 EventsRequest *events_request = (EventsRequest*)hook_data;
1902 LttvTracesetState *tss = (LttvTracesetState*)call_data;
1903 ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data;
1904 #if 0
1905 /* Desactivate sort */
1906 gtk_tree_sortable_set_sort_column_id(
1907 GTK_TREE_SORTABLE(cfd->process_list->list_store),
1908 TRACE_COLUMN,
1909 GTK_SORT_ASCENDING);
1910 #endif //0
1911 drawing_chunk_begin(events_request, tss);
1912
1913 return 0;
1914 }
1915
1916 int before_request(void *hook_data, void *call_data)
1917 {
1918 EventsRequest *events_request = (EventsRequest*)hook_data;
1919 LttvTracesetState *tss = (LttvTracesetState*)call_data;
1920
1921 drawing_data_request_begin(events_request, tss);
1922
1923 return 0;
1924 }
1925
1926
1927 /*
1928 * after request is necessary in addition of after chunk in order to draw
1929 * lines until the end of the screen. after chunk just draws lines until
1930 * the last event.
1931 *
1932 * for each process
1933 * draw closing line
1934 * expose
1935 */
1936 // TODO pmf: reenable this
1937 int after_request(void *hook_data, void *call_data)
1938 {
1939 // EventsRequest *events_request = (EventsRequest*)hook_data;
1940 // ControlFlowData *control_flow_data = events_request->viewer_data;
1941 // LttvTracesetState *tss = (LttvTracesetState*)call_data;
1942 //
1943 // ProcessList *process_list = control_flow_data->process_list;
1944 // LttTime end_time = events_request->end_time;
1945 //
1946 // ClosureData closure_data;
1947 // closure_data.events_request = (EventsRequest*)hook_data;
1948 // closure_data.tss = tss;
1949 // closure_data.end_time = end_time;
1950 //
1951 // TimeWindow time_window =
1952 // lttvwindow_get_time_window(control_flow_data->tab);
1953 // guint width = control_flow_data->drawing->width;
1954 // convert_time_to_pixels(
1955 // time_window,
1956 // end_time,
1957 // width,
1958 // &closure_data.x_end);
1959 //
1960 //
1961 // /* Draw last items */
1962 // g_hash_table_foreach(process_list->process_hash, draw_closure,
1963 // (void*)&closure_data);
1964 //
1965 //
1966 // /* Request expose */
1967 // drawing_request_expose(events_request, tss, end_time);
1968 return 0;
1969 }
1970
1971 /*
1972 * for each process
1973 * draw closing line
1974 * expose
1975 */
1976 int after_chunk(void *hook_data, void *call_data)
1977 {
1978 EventsRequest *events_request = (EventsRequest*)hook_data;
1979 ControlFlowData *control_flow_data = events_request->viewer_data;
1980 LttvTracesetState *tss = (LttvTracesetState*)call_data;
1981 LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
1982 LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
1983 LttTime end_time;
1984
1985 ProcessList *process_list = control_flow_data->process_list;
1986 guint i;
1987 LttvTraceset *traceset = tsc->ts;
1988 guint nb_trace = lttv_traceset_number(traceset);
1989
1990 /* Only execute when called for the first trace's events request */
1991 if(!process_list->current_hash_data) return;
1992
1993 for(i = 0 ; i < nb_trace ; i++) {
1994 g_free(process_list->current_hash_data[i]);
1995 }
1996 g_free(process_list->current_hash_data);
1997 process_list->current_hash_data = NULL;
1998
1999 if(tfc != NULL)
2000 end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
2001 else /* end of traceset, or position now out of request : end */
2002 end_time = events_request->end_time;
2003
2004 ClosureData closure_data;
2005 closure_data.events_request = (EventsRequest*)hook_data;
2006 closure_data.tss = tss;
2007 closure_data.end_time = end_time;
2008
2009 TimeWindow time_window =
2010 lttvwindow_get_time_window(control_flow_data->tab);
2011 guint width = control_flow_data->drawing->width;
2012 convert_time_to_pixels(
2013 time_window,
2014 end_time,
2015 width,
2016 &closure_data.x_end);
2017
2018 /* Draw last items */
2019 g_hash_table_foreach(process_list->process_hash, draw_closure,
2020 (void*)&closure_data);
2021 #if 0
2022 /* Reactivate sort */
2023 gtk_tree_sortable_set_sort_column_id(
2024 GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
2025 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
2026 GTK_SORT_ASCENDING);
2027
2028 update_index_to_pixmap(control_flow_data->process_list);
2029 /* Request a full expose : drawing scrambled */
2030 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2031 #endif //0
2032 /* Request expose (updates damages zone also) */
2033 drawing_request_expose(events_request, tss, end_time);
2034
2035 return 0;
2036 }
2037
2038 /* after_statedump_end
2039 *
2040 * @param hook_data ControlFlowData structure of the viewer.
2041 * @param call_data Event context.
2042 *
2043 * This function adds items to be drawn in a queue for each process.
2044 *
2045 */
2046 int before_statedump_end(void *hook_data, void *call_data)
2047 {
2048 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
2049 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
2050 ControlFlowData *control_flow_data = events_request->viewer_data;
2051
2052 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2053
2054 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
2055
2056 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
2057
2058 LttvTracesetState *tss = (LttvTracesetState*)tfc->t_context->ts_context;
2059 ProcessList *process_list = control_flow_data->process_list;
2060
2061 LttEvent *e;
2062 e = ltt_tracefile_get_event(tfc->tf);
2063
2064 LttvFilter *filter = control_flow_data->filter;
2065 if(filter != NULL && filter->head != NULL)
2066 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
2067 tfc->t_context->t,tfc,NULL,NULL))
2068 return FALSE;
2069
2070 LttTime evtime = ltt_event_time(e);
2071
2072 ClosureData closure_data;
2073 closure_data.events_request = events_request;
2074 closure_data.tss = tss;
2075 closure_data.end_time = evtime;
2076
2077 TimeWindow time_window =
2078 lttvwindow_get_time_window(control_flow_data->tab);
2079 guint width = control_flow_data->drawing->width;
2080 convert_time_to_pixels(
2081 time_window,
2082 evtime,
2083 width,
2084 &closure_data.x_end);
2085
2086 /* Draw last items */
2087 g_hash_table_foreach(process_list->process_hash, draw_closure,
2088 (void*)&closure_data);
2089 #if 0
2090 /* Reactivate sort */
2091 gtk_tree_sortable_set_sort_column_id(
2092 GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
2093 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
2094 GTK_SORT_ASCENDING);
2095
2096 update_index_to_pixmap(control_flow_data->process_list);
2097 /* Request a full expose : drawing scrambled */
2098 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2099 #endif //0
2100 /* Request expose (updates damages zone also) */
2101 drawing_request_expose(events_request, tss, evtime);
2102
2103 return 0;
2104 }
This page took 0.101862 seconds and 5 git commands to generate.