make inline correct
[lttv.git] / ltt / branches / poly / 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
49 //#define PANGO_ENABLE_BACKEND
50 #include <gtk/gtk.h>
51 #include <gdk/gdk.h>
52 #include <glib.h>
53 #include <assert.h>
54 #include <string.h>
55 #include <stdio.h>
56
57 //#include <pango/pango.h>
58
59 #include <ltt/event.h>
60 #include <ltt/time.h>
61 #include <ltt/type.h>
62
63 #include <lttv/lttv.h>
64 #include <lttv/hook.h>
65 #include <lttv/state.h>
66 #include <lttvwindow/lttvwindow.h>
67 #include <lttvwindow/lttvwindowtraces.h>
68
69
70 #include "eventhooks.h"
71 #include "cfv.h"
72 #include "processlist.h"
73 #include "drawing.h"
74 #include "cfv-private.h"
75
76
77 #define MAX_PATH_LEN 256
78
79
80 #if 0
81 typedef struct _ProcessAddClosure {
82 ControlFlowData *cfd;
83 guint trace_num;
84 } ProcessAddClosure;
85
86 static void process_add(gpointer key,
87 gpointer value,
88 gpointer user_data)
89 {
90 LttvProcessState *process = (LttvProcessState*)value;
91 ProcessAddClosure *closure = (ProcessAddClosure*)user_data;
92 ControlFlowData *control_flow_data = closure->cfd;
93 guint trace_num = closure->trace_num;
94
95 /* Add process to process list (if not present) */
96 guint pid;
97 LttTime birth;
98 guint y = 0, height = 0, pl_height = 0;
99
100 ProcessList *process_list = control_flow_data->process_list;
101
102 pid = process->pid;
103 birth = process->creation_time;
104 const gchar *name = g_quark_to_string(process->name);
105 HashedProcessData *hashed_process_data = NULL;
106
107 if(processlist_get_process_pixels(process_list,
108 pid,
109 &birth,
110 trace_num,
111 &y,
112 &height,
113 &hashed_process_data) == 1)
114 {
115 /* Process not present */
116 processlist_add(process_list,
117 pid,
118 &birth,
119 trace_num,
120 name,
121 &pl_height,
122 &hashed_process_data);
123 processlist_get_process_pixels(process_list,
124 pid,
125 &birth,
126 trace_num,
127 &y,
128 &height,
129 &hashed_process_data);
130 drawing_insert_square( control_flow_data->drawing, y, height);
131 }
132 }
133 #endif //0
134
135
136 /* Action to do when background computation completed.
137 *
138 * Wait for all the awaited computations to be over.
139 */
140
141 gint background_ready(void *hook_data, void *call_data)
142 {
143 ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
144 LttvTrace *trace = (LttvTrace*)call_data;
145 LttvTracesetContext *tsc =
146 lttvwindow_get_traceset_context(control_flow_data->tab);
147
148 control_flow_data->background_info_waiting--;
149
150 if(control_flow_data->background_info_waiting == 0) {
151 g_debug("control flow viewer : background computation data ready.");
152
153 drawing_clear(control_flow_data->drawing);
154 processlist_clear(control_flow_data->process_list);
155 redraw_notify(control_flow_data, NULL);
156 }
157
158 return 0;
159 }
160
161
162 /* Request background computation. Verify if it is in progress or ready first.
163 * Only for each trace in the tab's traceset.
164 */
165 void request_background_data(ControlFlowData *control_flow_data)
166 {
167 LttvTracesetContext * tsc =
168 lttvwindow_get_traceset_context(control_flow_data->tab);
169 gint num_traces = lttv_traceset_number(tsc->ts);
170 gint i;
171 LttvTrace *trace;
172
173 LttvHooks *background_ready_hook =
174 lttv_hooks_new();
175 lttv_hooks_add(background_ready_hook, background_ready, control_flow_data,
176 LTTV_PRIO_DEFAULT);
177 control_flow_data->background_info_waiting = 0;
178
179 for(i=0;i<num_traces;i++) {
180 trace = lttv_traceset_get(tsc->ts, i);
181
182 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE) {
183
184 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
185 trace) == FALSE) {
186 /* We first remove requests that could have been done for the same
187 * information. Happens when two viewers ask for it before servicing
188 * starts.
189 */
190 lttvwindowtraces_background_request_remove(trace, "state");
191 lttvwindowtraces_background_request_queue(trace,
192 "state");
193 lttvwindowtraces_background_notify_queue(control_flow_data,
194 trace,
195 ltt_time_infinite,
196 NULL,
197 background_ready_hook);
198 control_flow_data->background_info_waiting++;
199 } else { /* in progress */
200
201 lttvwindowtraces_background_notify_current(control_flow_data,
202 trace,
203 ltt_time_infinite,
204 NULL,
205 background_ready_hook);
206 control_flow_data->background_info_waiting++;
207 }
208 } else {
209 /* Data ready. Be its nature, this viewer doesn't need to have
210 * its data ready hook called htere, because a background
211 * request is always linked with a redraw.
212 */
213 }
214
215 }
216
217 lttv_hooks_destroy(background_ready_hook);
218 }
219
220
221
222
223 /**
224 * Event Viewer's constructor hook
225 *
226 * This constructor is given as a parameter to the menuitem and toolbar button
227 * registration. It creates the list.
228 * @param tab A pointer to the parent tab.
229 * @return The widget created.
230 */
231 GtkWidget *
232 h_guicontrolflow(Tab *tab)
233 {
234 g_info("h_guicontrolflow, %p", tab);
235 ControlFlowData *control_flow_data = guicontrolflow() ;
236
237 control_flow_data->tab = tab;
238
239 //g_debug("time width2 : %u",time_window->time_width);
240 // Unreg done in the GuiControlFlow_Destructor
241 lttvwindow_register_traceset_notify(tab,
242 traceset_notify,
243 control_flow_data);
244
245 lttvwindow_register_time_window_notify(tab,
246 update_time_window_hook,
247 control_flow_data);
248 lttvwindow_register_current_time_notify(tab,
249 update_current_time_hook,
250 control_flow_data);
251 lttvwindow_register_redraw_notify(tab,
252 redraw_notify,
253 control_flow_data);
254 lttvwindow_register_continue_notify(tab,
255 continue_notify,
256 control_flow_data);
257 request_background_data(control_flow_data);
258
259
260 return guicontrolflow_get_widget(control_flow_data) ;
261
262 }
263
264 int event_selected_hook(void *hook_data, void *call_data)
265 {
266 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
267 guint *event_number = (guint*) call_data;
268
269 g_debug("DEBUG : event selected by main window : %u", *event_number);
270
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 = 2;
278 prop_line.style = GDK_LINE_SOLID;
279 prop_line.y = MIDDLE;
280 //GdkColormap *colormap = gdk_colormap_get_system();
281
282 g_debug("prepare_status_line for state : %s",
283 g_quark_to_string(process->state->s));
284
285 if(process->state->s == LTTV_STATE_RUN) {
286 if(process->state->t == LTTV_STATE_USER_MODE)
287 prop_line.color = drawing_colors[COL_RUN_USER_MODE];
288 else if(process->state->t == LTTV_STATE_SYSCALL)
289 prop_line.color = drawing_colors[COL_RUN_SYSCALL];
290 else if(process->state->t == LTTV_STATE_TRAP)
291 prop_line.color = drawing_colors[COL_RUN_TRAP];
292 else if(process->state->t == LTTV_STATE_IRQ)
293 prop_line.color = drawing_colors[COL_RUN_IRQ];
294 else if(process->state->t == LTTV_STATE_MODE_UNKNOWN)
295 prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
296 else
297 g_assert(FALSE); /* RUNNING MODE UNKNOWN */
298 } else if(process->state->s == LTTV_STATE_WAIT) {
299 /* We don't show if we wait while in user mode, trap, irq or syscall */
300 prop_line.color = drawing_colors[COL_WAIT];
301 } else if(process->state->s == LTTV_STATE_WAIT_CPU) {
302 /* We don't show if we wait for CPU while in user mode, trap, irq
303 * or syscall */
304 prop_line.color = drawing_colors[COL_WAIT_CPU];
305 } else if(process->state->s == LTTV_STATE_ZOMBIE) {
306 prop_line.color = drawing_colors[COL_ZOMBIE];
307 } else if(process->state->s == LTTV_STATE_WAIT_FORK) {
308 prop_line.color = drawing_colors[COL_WAIT_FORK];
309 } else if(process->state->s == LTTV_STATE_EXIT) {
310 prop_line.color = drawing_colors[COL_EXIT];
311 } else if(process->state->s == LTTV_STATE_UNNAMED) {
312 prop_line.color = drawing_colors[COL_UNNAMED];
313 } else
314 g_assert(FALSE); /* UNKNOWN STATE */
315
316 return prop_line;
317
318 }
319
320 #if 0
321 static inline PropertiesLine prepare_status_line(LttvProcessState *process)
322 {
323 PropertiesLine prop_line;
324 prop_line.line_width = 2;
325 prop_line.style = GDK_LINE_SOLID;
326 prop_line.y = MIDDLE;
327 //GdkColormap *colormap = gdk_colormap_get_system();
328
329 g_debug("prepare_status_line for state : %s",
330 g_quark_to_string(process->state->s));
331
332 /* color of line : status of the process */
333 if(process->state->s == LTTV_STATE_UNNAMED)
334 prop_line.color = drawing_colors[COL_WHITE];
335 else if(process->state->s == LTTV_STATE_WAIT_FORK)
336 prop_line.color = drawing_colors[COL_WAIT_FORK];
337 else if(process->state->s == LTTV_STATE_WAIT_CPU)
338 prop_line.color = drawing_colors[COL_WAIT_CPU];
339 else if(process->state->s == LTTV_STATE_EXIT)
340 prop_line.color = drawing_colors[COL_EXIT];
341 else if(process->state->s == LTTV_STATE_ZOMBIE)
342 prop_line.color = drawing_colors[COL_ZOMBIE];
343 else if(process->state->s == LTTV_STATE_WAIT)
344 prop_line.color = drawing_colors[COL_WAIT];
345 else if(process->state->s == LTTV_STATE_RUN)
346 prop_line.color = drawing_colors[COL_RUN];
347 else
348 prop_line.color = drawing_colors[COL_WHITE];
349
350 //gdk_colormap_alloc_color(colormap,
351 // prop_line.color,
352 // FALSE,
353 // TRUE);
354
355 return prop_line;
356
357 }
358 #endif //0
359
360
361 /* before_schedchange_hook
362 *
363 * This function basically draw lines and icons. Two types of lines are drawn :
364 * one small (3 pixels?) representing the state of the process and the second
365 * type is thicker (10 pixels?) representing on which CPU a process is running
366 * (and this only in running state).
367 *
368 * Extremums of the lines :
369 * x_min : time of the last event context for this process kept in memory.
370 * x_max : time of the current event.
371 * y : middle of the process in the process list. The process is found in the
372 * list, therefore is it's position in pixels.
373 *
374 * The choice of lines'color is defined by the context of the last event for this
375 * process.
376 */
377
378
379 int before_schedchange_hook(void *hook_data, void *call_data)
380 {
381 EventsRequest *events_request = (EventsRequest*)hook_data;
382 ControlFlowData *control_flow_data = events_request->viewer_data;
383 Drawing_t *drawing = control_flow_data->drawing;
384
385 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
386
387 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
388 LttvTraceState *ts =(LttvTraceState *)((LttvTracefileContext*)tfs)->t_context;
389
390 LttEvent *e;
391 e = tfc->e;
392
393 LttTime evtime = ltt_event_time(e);
394
395 guint width = drawing->width;
396
397 /* we are in a schedchange, before the state update. We must draw the
398 * items corresponding to the state before it changes : now is the right
399 * time to do it.
400 */
401
402 guint pid_out;
403 guint pid_in;
404 {
405 LttField *f = ltt_event_field(e);
406 LttField *element;
407 element = ltt_field_member(f,0);
408 pid_out = ltt_event_get_long_unsigned(e,element);
409 element = ltt_field_member(f,1);
410 pid_in = ltt_event_get_long_unsigned(e,element);
411 g_debug("out : %u in : %u", pid_out, pid_in);
412 }
413
414 {
415 /* For the pid_out */
416 /* First, check if the current process is in the state computation
417 * process list. If it is there, that means we must add it right now and
418 * draw items from the beginning of the read for it. If it is not
419 * present, it's a new process and it was not present : it will
420 * be added after the state update. */
421 LttvProcessState *process;
422 /* unknown state, bad current pid */
423 if(tfs->process->pid != pid_out)
424 process = lttv_state_find_process(tfs, pid_out);
425 else
426 process = tfs->process;
427
428 if(process != NULL) {
429 /* Well, the process_out existed : we must get it in the process hash
430 * or add it, and draw its items.
431 */
432 /* Add process to process list (if not present) */
433 guint y = 0, height = 0, pl_height = 0;
434 HashedProcessData *hashed_process_data = NULL;
435 ProcessList *process_list = control_flow_data->process_list;
436 LttTime birth = process->creation_time;
437
438 hashed_process_data = processlist_get_process_data(process_list,
439 pid_out,
440 process->last_cpu_index,
441 &birth,
442 tfc->t_context->index);
443 if(hashed_process_data == NULL)
444 {
445 g_assert(pid_out == 0 || pid_out != process->ppid);
446 const gchar *name = g_quark_to_string(process->name);
447 /* Process not present */
448 ProcessInfo *process_info;
449 processlist_add(process_list,
450 pid_out,
451 process->last_cpu_index,
452 process->ppid,
453 &birth,
454 tfc->t_context->index,
455 name,
456 &pl_height,
457 &process_info,
458 &hashed_process_data);
459 processlist_get_pixels_from_data(process_list,
460 hashed_process_data,
461 &y,
462 &height);
463 drawing_insert_square( drawing, y, height);
464 }
465
466 /* Now, the process is in the state hash and our own process hash.
467 * We definitely can draw the items related to the ending state.
468 */
469
470 /* Check if the x position is unset. In can have been left unset by
471 * a draw closure from a after chunk hook. This should never happen,
472 * because it must be set by before chunk hook to the damage_begin
473 * value.
474 */
475 g_assert(hashed_process_data->x.middle != -1);
476 if(ltt_time_compare(hashed_process_data->next_good_time,
477 evtime) > 0)
478 {
479 if(hashed_process_data->x.middle_marked == FALSE) {
480 processlist_get_pixels_from_data(process_list,
481 hashed_process_data,
482 &y,
483 &height);
484
485 TimeWindow time_window =
486 lttvwindow_get_time_window(control_flow_data->tab);
487 #ifdef EXTRA_CHECK
488 if(ltt_time_compare(evtime, time_window.start_time) == -1
489 || ltt_time_compare(evtime, time_window.end_time) == 1)
490 return;
491 #endif //EXTRA_CHECK
492
493 guint x;
494 convert_time_to_pixels(
495 time_window,
496 evtime,
497 width,
498 &x);
499
500 /* Draw collision indicator */
501 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
502 gdk_draw_point(drawing->pixmap,
503 drawing->gc,
504 x,
505 y+(height/2)-3);
506 hashed_process_data->x.middle_marked = TRUE;
507 }
508 } else {
509 processlist_get_pixels_from_data(process_list,
510 hashed_process_data,
511 &y,
512 &height);
513
514
515 TimeWindow time_window =
516 lttvwindow_get_time_window(control_flow_data->tab);
517 #ifdef EXTRA_CHECK
518 if(ltt_time_compare(evtime, time_window.start_time) == -1
519 || ltt_time_compare(evtime, time_window.end_time) == 1)
520 return;
521 #endif //EXTRA_CHECK
522
523 guint x;
524 convert_time_to_pixels(
525 time_window,
526 evtime,
527 width,
528 &x);
529
530
531 /* Jump over draw if we are at the same x position */
532 if(x == hashed_process_data->x.middle &&
533 hashed_process_data->x.middle_used)
534 {
535 if(hashed_process_data->x.middle_marked == FALSE) {
536 /* Draw collision indicator */
537 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
538 gdk_draw_point(drawing->pixmap,
539 drawing->gc,
540 x,
541 y+(height/2)-3);
542 hashed_process_data->x.middle_marked = TRUE;
543 }
544 /* jump */
545 } else {
546 DrawContext draw_context;
547
548 /* Now create the drawing context that will be used to draw
549 * items related to the last state. */
550 draw_context.drawable = drawing->pixmap;
551 draw_context.gc = drawing->gc;
552 draw_context.pango_layout = drawing->pango_layout;
553 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
554 draw_context.drawinfo.end.x = x;
555
556 draw_context.drawinfo.y.over = y+1;
557 draw_context.drawinfo.y.middle = y+(height/2);
558 draw_context.drawinfo.y.under = y+height;
559
560 draw_context.drawinfo.start.offset.over = 0;
561 draw_context.drawinfo.start.offset.middle = 0;
562 draw_context.drawinfo.start.offset.under = 0;
563 draw_context.drawinfo.end.offset.over = 0;
564 draw_context.drawinfo.end.offset.middle = 0;
565 draw_context.drawinfo.end.offset.under = 0;
566
567 {
568 /* Draw the line */
569 PropertiesLine prop_line = prepare_s_e_line(process);
570 draw_line((void*)&prop_line, (void*)&draw_context);
571
572 }
573 /* become the last x position */
574 hashed_process_data->x.middle = x;
575 hashed_process_data->x.middle_used = TRUE;
576 hashed_process_data->x.middle_marked = FALSE;
577
578 /* Calculate the next good time */
579 convert_pixels_to_time(width, x+1, time_window,
580 &hashed_process_data->next_good_time);
581 }
582 }
583 }
584 }
585
586 {
587 /* For the pid_in */
588 /* First, check if the current process is in the state computation
589 * process list. If it is there, that means we must add it right now and
590 * draw items from the beginning of the read for it. If it is not
591 * present, it's a new process and it was not present : it will
592 * be added after the state update. */
593 LttvProcessState *process;
594 process = lttv_state_find_process(tfs, pid_in);
595
596 if(process != NULL) {
597 /* Well, the process_out 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 y = 0, height = 0, pl_height = 0;
602 HashedProcessData *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,
607 pid_in,
608 process->last_cpu_index,
609 &birth,
610 tfc->t_context->index);
611 if(hashed_process_data == NULL)
612 {
613 g_assert(pid_in == 0 || pid_in != process->ppid);
614 const gchar *name = g_quark_to_string(process->name);
615 /* Process not present */
616 ProcessInfo *process_info;
617 processlist_add(process_list,
618 pid_in,
619 process->last_cpu_index,
620 process->ppid,
621 &birth,
622 tfc->t_context->index,
623 name,
624 &pl_height,
625 &process_info,
626 &hashed_process_data);
627 processlist_get_pixels_from_data(process_list,
628 hashed_process_data,
629 &y,
630 &height);
631 drawing_insert_square( drawing, y, height);
632 }
633 //We could set the current process and hash here, but will be done
634 //by after schedchange hook
635
636 /* Now, the process is in the state hash and our own process hash.
637 * We definitely can draw the items related to the ending state.
638 */
639
640 /* Check if the x position is unset. In can have been left unset by
641 * a draw closure from a after chunk hook. This should never happen,
642 * because it must be set by before chunk hook to the damage_begin
643 * value.
644 */
645 g_assert(hashed_process_data->x.middle != -1);
646
647 if(ltt_time_compare(hashed_process_data->next_good_time,
648 evtime) > 0)
649 {
650 if(hashed_process_data->x.middle_marked == FALSE) {
651
652 processlist_get_pixels_from_data(process_list,
653 hashed_process_data,
654 &y,
655 &height);
656 TimeWindow time_window =
657 lttvwindow_get_time_window(control_flow_data->tab);
658 #ifdef EXTRA_CHECK
659 if(ltt_time_compare(evtime, time_window.start_time) == -1
660 || ltt_time_compare(evtime, time_window.end_time) == 1)
661 return;
662 #endif //EXTRA_CHECK
663 guint x;
664 convert_time_to_pixels(
665 time_window,
666 evtime,
667 width,
668 &x);
669
670 /* Draw collision indicator */
671 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
672 gdk_draw_point(drawing->pixmap,
673 drawing->gc,
674 x,
675 y+(height/2)-3);
676 hashed_process_data->x.middle_marked = TRUE;
677 }
678 } else {
679 processlist_get_pixels_from_data(process_list,
680 hashed_process_data,
681 &y,
682 &height);
683 TimeWindow time_window =
684 lttvwindow_get_time_window(control_flow_data->tab);
685 #ifdef EXTRA_CHECK
686 if(ltt_time_compare(evtime, time_window.start_time) == -1
687 || ltt_time_compare(evtime, time_window.end_time) == 1)
688 return;
689 #endif //EXTRA_CHECK
690 guint x;
691
692 convert_time_to_pixels(
693 time_window,
694 evtime,
695 width,
696 &x);
697
698
699 /* Jump over draw if we are at the same x position */
700 if(x == hashed_process_data->x.middle &&
701 hashed_process_data->x.middle_used)
702 {
703 if(hashed_process_data->x.middle_marked == FALSE) {
704 /* Draw collision indicator */
705 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
706 gdk_draw_point(drawing->pixmap,
707 drawing->gc,
708 x,
709 y+(height/2)-3);
710 hashed_process_data->x.middle_marked = TRUE;
711 }
712 /* jump */
713 } else {
714 DrawContext draw_context;
715
716 /* Now create the drawing context that will be used to draw
717 * items related to the last state. */
718 draw_context.drawable = drawing->pixmap;
719 draw_context.gc = drawing->gc;
720 draw_context.pango_layout = drawing->pango_layout;
721 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
722 draw_context.drawinfo.end.x = x;
723
724 draw_context.drawinfo.y.over = y+1;
725 draw_context.drawinfo.y.middle = y+(height/2);
726 draw_context.drawinfo.y.under = y+height;
727
728 draw_context.drawinfo.start.offset.over = 0;
729 draw_context.drawinfo.start.offset.middle = 0;
730 draw_context.drawinfo.start.offset.under = 0;
731 draw_context.drawinfo.end.offset.over = 0;
732 draw_context.drawinfo.end.offset.middle = 0;
733 draw_context.drawinfo.end.offset.under = 0;
734
735 {
736 /* Draw the line */
737 PropertiesLine prop_line = prepare_s_e_line(process);
738 draw_line((void*)&prop_line, (void*)&draw_context);
739 }
740
741
742 /* become the last x position */
743 hashed_process_data->x.middle = x;
744 hashed_process_data->x.middle_used = TRUE;
745 hashed_process_data->x.middle_marked = FALSE;
746
747 /* Calculate the next good time */
748 convert_pixels_to_time(width, x+1, time_window,
749 &hashed_process_data->next_good_time);
750 }
751 }
752 }
753 }
754 return 0;
755
756
757 #if 0
758 EventsRequest *events_request = (EventsRequest*)hook_data;
759 ControlFlowData *control_flow_data =
760 (ControlFlowData*)events_request->viewer_data;
761 Tab *tab = control_flow_data->tab;
762
763 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
764
765 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
766 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
767
768 LttEvent *e;
769 e = tfc->e;
770
771 LttTime evtime = ltt_event_time(e);
772 TimeWindow time_window =
773 lttvwindow_get_time_window(tab);
774
775 LttTime time_window.end_time = time_window.time_window.end_time;
776
777 //if(time < time_beg || time > time_end) return;
778 if(ltt_time_compare(evtime, time_window.start_time) == -1
779 || ltt_time_compare(evtime, time_window.end_time) == 1)
780 return;
781
782 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
783 {
784 g_debug("schedchange!");
785
786 /* Add process to process list (if not present) and get drawing "y" from
787 * process position */
788 guint pid_out, pid_in;
789 LttvProcessState *process_out, *process_in;
790 LttTime birth;
791 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
792
793 ProcessList *process_list = control_flow_data->process_list;
794
795
796 LttField *f = ltt_event_field(e);
797 LttField *element;
798 element = ltt_field_member(f,0);
799 pid_out = ltt_event_get_long_unsigned(e,element);
800 element = ltt_field_member(f,1);
801 pid_in = ltt_event_get_long_unsigned(e,element);
802 g_debug("out : %u in : %u", pid_out, pid_in);
803
804
805 /* Find process pid_out in the list... */
806 process_out = lttv_state_find_process(tfs, pid_out);
807 if(process_out == NULL) return 0;
808 g_debug("out : %s",g_quark_to_string(process_out->state->s));
809
810 birth = process_out->creation_time;
811 const gchar *name = g_quark_to_string(process_out->name);
812 HashedProcessData *hashed_process_data_out = NULL;
813
814 if(processlist_get_process_pixels(process_list,
815 pid_out,
816 &birth,
817 tfc->t_context->index,
818 &y_out,
819 &height,
820 &hashed_process_data_out) == 1)
821 {
822 /* Process not present */
823 processlist_add(process_list,
824 pid_out,
825 &birth,
826 tfc->t_context->index,
827 name,
828 &pl_height,
829 &hashed_process_data_out);
830 g_assert(processlist_get_process_pixels(process_list,
831 pid_out,
832 &birth,
833 tfc->t_context->index,
834 &y_out,
835 &height,
836 &hashed_process_data_out)==0);
837 drawing_insert_square( control_flow_data->drawing, y_out, height);
838 }
839 //g_free(name);
840
841 /* Find process pid_in in the list... */
842 process_in = lttv_state_find_process(tfs, pid_in);
843 if(process_in == NULL) return 0;
844 g_debug("in : %s",g_quark_to_string(process_in->state->s));
845
846 birth = process_in->creation_time;
847 name = g_quark_to_string(process_in->name);
848 HashedProcessData *hashed_process_data_in = NULL;
849
850 if(processlist_get_process_pixels(process_list,
851 pid_in,
852 &birth,
853 tfc->t_context->index,
854 &y_in,
855 &height,
856 &hashed_process_data_in) == 1)
857 {
858 /* Process not present */
859 processlist_add(process_list,
860 pid_in,
861 &birth,
862 tfc->t_context->index,
863 name,
864 &pl_height,
865 &hashed_process_data_in);
866 processlist_get_process_pixels(process_list,
867 pid_in,
868 &birth,
869 tfc->t_context->index,
870 &y_in,
871 &height,
872 &hashed_process_data_in);
873
874 drawing_insert_square( control_flow_data->drawing, y_in, height);
875 }
876 //g_free(name);
877
878
879 /* Find pixels corresponding to time of the event. If the time does
880 * not fit in the window, show a warning, not supposed to happend. */
881 guint x = 0;
882 guint width = control_flow_data->drawing->width;
883
884 LttTime time = ltt_event_time(e);
885
886 LttTime window_end = time_window.time_window.end_time;
887
888 convert_time_to_pixels(
889 time_window,
890 time,
891 width,
892 &x);
893 //assert(x <= width);
894 //
895 /* draw what represents the event for outgoing process. */
896
897 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
898 draw_context_out->current->modify_over->x = x;
899 draw_context_out->current->modify_under->x = x;
900 draw_context_out->current->modify_over->y = y_out;
901 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
902 draw_context_out->drawable = control_flow_data->drawing->pixmap;
903 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
904 GtkWidget *widget = control_flow_data->drawing->drawing_area;
905 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
906 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
907 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
908 //draw_context_out->gc = widget->style->black_gc;
909
910 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
911 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
912
913 /* Draw the line/background of the out process */
914 if(draw_context_out->previous->middle->x == -1)
915 {
916 draw_context_out->previous->over->x =
917 control_flow_data->drawing->damage_begin;
918 draw_context_out->previous->middle->x =
919 control_flow_data->drawing->damage_begin;
920 draw_context_out->previous->under->x =
921 control_flow_data->drawing->damage_begin;
922
923 g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin);
924 }
925
926 draw_context_out->current->middle->x = x;
927 draw_context_out->current->over->x = x;
928 draw_context_out->current->under->x = x;
929 draw_context_out->current->middle->y = y_out + height/2;
930 draw_context_out->current->over->y = y_out;
931 draw_context_out->current->under->y = y_out + height;
932 draw_context_out->previous->middle->y = y_out + height/2;
933 draw_context_out->previous->over->y = y_out;
934 draw_context_out->previous->under->y = y_out + height;
935
936 draw_context_out->drawable = control_flow_data->drawing->pixmap;
937 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
938
939 if(process_out->state->s == LTTV_STATE_RUN)
940 {
941 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
942 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
943 draw_context_out->gc = control_flow_data->drawing->gc;
944
945 PropertiesBG prop_bg;
946 prop_bg.color = g_new(GdkColor,1);
947
948 switch(tfc->index) {
949 case 0:
950 prop_bg.color->red = 0x1515;
951 prop_bg.color->green = 0x1515;
952 prop_bg.color->blue = 0x8c8c;
953 break;
954 case 1:
955 prop_bg.color->red = 0x4e4e;
956 prop_bg.color->green = 0xa9a9;
957 prop_bg.color->blue = 0xa4a4;
958 break;
959 case 2:
960 prop_bg.color->red = 0x7a7a;
961 prop_bg.color->green = 0x4a4a;
962 prop_bg.color->blue = 0x8b8b;
963 break;
964 case 3:
965 prop_bg.color->red = 0x8080;
966 prop_bg.color->green = 0x7777;
967 prop_bg.color->blue = 0x4747;
968 break;
969 default:
970 prop_bg.color->red = 0xe7e7;
971 prop_bg.color->green = 0xe7e7;
972 prop_bg.color->blue = 0xe7e7;
973 }
974
975 g_debug("calling from draw_event");
976 draw_bg((void*)&prop_bg, (void*)draw_context_out);
977 g_free(prop_bg.color);
978 //gdk_gc_unref(draw_context_out->gc);
979 }
980
981 draw_context_out->gc = widget->style->black_gc;
982
983 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
984 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
985 PropertiesText prop_text_out;
986 prop_text_out.foreground = &colorfg_out;
987 prop_text_out.background = &colorbg_out;
988 prop_text_out.size = 6;
989 prop_text_out.position = OVER;
990
991 /* color of text : status of the process */
992 if(process_out->state->s == LTTV_STATE_UNNAMED)
993 {
994 prop_text_out.foreground->red = 0xffff;
995 prop_text_out.foreground->green = 0xffff;
996 prop_text_out.foreground->blue = 0xffff;
997 }
998 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
999 {
1000 prop_text_out.foreground->red = 0x0fff;
1001 prop_text_out.foreground->green = 0xffff;
1002 prop_text_out.foreground->blue = 0xfff0;
1003 }
1004 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
1005 {
1006 prop_text_out.foreground->red = 0xffff;
1007 prop_text_out.foreground->green = 0xffff;
1008 prop_text_out.foreground->blue = 0x0000;
1009 }
1010 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
1011 {
1012 prop_text_out.foreground->red = 0xffff;
1013 prop_text_out.foreground->green = 0x0000;
1014 prop_text_out.foreground->blue = 0xffff;
1015 }
1016 else if(process_out->state->s == LTTV_STATE_WAIT)
1017 {
1018 prop_text_out.foreground->red = 0xffff;
1019 prop_text_out.foreground->green = 0x0000;
1020 prop_text_out.foreground->blue = 0x0000;
1021 }
1022 else if(process_out->state->s == LTTV_STATE_RUN)
1023 {
1024 prop_text_out.foreground->red = 0x0000;
1025 prop_text_out.foreground->green = 0xffff;
1026 prop_text_out.foreground->blue = 0x0000;
1027 }
1028 else
1029 {
1030 prop_text_out.foreground->red = 0xffff;
1031 prop_text_out.foreground->green = 0xffff;
1032 prop_text_out.foreground->blue = 0xffff;
1033 }
1034
1035
1036 /* Print status of the process : U, WF, WC, E, W, R */
1037 if(process_out->state->s == LTTV_STATE_UNNAMED)
1038 prop_text_out.text = "U->";
1039 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
1040 prop_text_out.text = "WF->";
1041 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
1042 prop_text_out.text = "WC->";
1043 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
1044 prop_text_out.text = "E->";
1045 else if(process_out->state->s == LTTV_STATE_WAIT)
1046 prop_text_out.text = "W->";
1047 else if(process_out->state->s == LTTV_STATE_RUN)
1048 prop_text_out.text = "R->";
1049 else
1050 prop_text_out.text = "U";
1051
1052 draw_text((void*)&prop_text_out, (void*)draw_context_out);
1053 //gdk_gc_unref(draw_context_out->gc);
1054
1055 //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1056 //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1057 draw_context_out->gc = control_flow_data->drawing->gc;
1058
1059 PropertiesLine prop_line_out;
1060 prop_line_out.color = g_new(GdkColor,1);
1061 prop_line_out.line_width = 2;
1062 prop_line_out.style = GDK_LINE_SOLID;
1063 prop_line_out.position = MIDDLE;
1064
1065 g_debug("out state : %s", g_quark_to_string(process_out->state->s));
1066
1067 /* color of line : status of the process */
1068 if(process_out->state->s == LTTV_STATE_UNNAMED)
1069 {
1070 prop_line_out.color->red = 0xffff;
1071 prop_line_out.color->green = 0xffff;
1072 prop_line_out.color->blue = 0xffff;
1073 }
1074 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
1075 {
1076 prop_line_out.color->red = 0x0fff;
1077 prop_line_out.color->green = 0xffff;
1078 prop_line_out.color->blue = 0xfff0;
1079 }
1080 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
1081 {
1082 prop_line_out.color->red = 0xffff;
1083 prop_line_out.color->green = 0xffff;
1084 prop_line_out.color->blue = 0x0000;
1085 }
1086 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
1087 {
1088 prop_line_out.color->red = 0xffff;
1089 prop_line_out.color->green = 0x0000;
1090 prop_line_out.color->blue = 0xffff;
1091 }
1092 else if(process_out->state->s == LTTV_STATE_WAIT)
1093 {
1094 prop_line_out.color->red = 0xffff;
1095 prop_line_out.color->green = 0x0000;
1096 prop_line_out.color->blue = 0x0000;
1097 }
1098 else if(process_out->state->s == LTTV_STATE_RUN)
1099 {
1100 prop_line_out.color->red = 0x0000;
1101 prop_line_out.color->green = 0xffff;
1102 prop_line_out.color->blue = 0x0000;
1103 }
1104 else
1105 {
1106 prop_line_out.color->red = 0xffff;
1107 prop_line_out.color->green = 0xffff;
1108 prop_line_out.color->blue = 0xffff;
1109 }
1110
1111 draw_line((void*)&prop_line_out, (void*)draw_context_out);
1112 g_free(prop_line_out.color);
1113 //gdk_gc_unref(draw_context_out->gc);
1114 /* Note : finishing line will have to be added when trace read over. */
1115
1116 /* Finally, update the drawing context of the pid_in. */
1117
1118 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
1119 draw_context_in->current->modify_over->x = x;
1120 draw_context_in->current->modify_under->x = x;
1121 draw_context_in->current->modify_over->y = y_in;
1122 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
1123 draw_context_in->drawable = control_flow_data->drawing->pixmap;
1124 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
1125 widget = control_flow_data->drawing->drawing_area;
1126 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1127 //draw_context_in->gc = widget->style->black_gc;
1128 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1129 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1130
1131 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1132 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1133
1134 /* Draw the line/bg of the in process */
1135 if(draw_context_in->previous->middle->x == -1)
1136 {
1137 draw_context_in->previous->over->x =
1138 control_flow_data->drawing->damage_begin;
1139 draw_context_in->previous->middle->x =
1140 control_flow_data->drawing->damage_begin;
1141 draw_context_in->previous->under->x =
1142 control_flow_data->drawing->damage_begin;
1143
1144 g_debug("in middle x_beg : %u",control_flow_data->drawing->damage_begin);
1145
1146 }
1147
1148 draw_context_in->current->middle->x = x;
1149 draw_context_in->current->over->x = x;
1150 draw_context_in->current->under->x = x;
1151 draw_context_in->current->middle->y = y_in + height/2;
1152 draw_context_in->current->over->y = y_in;
1153 draw_context_in->current->under->y = y_in + height;
1154 draw_context_in->previous->middle->y = y_in + height/2;
1155 draw_context_in->previous->over->y = y_in;
1156 draw_context_in->previous->under->y = y_in + height;
1157
1158 draw_context_in->drawable = control_flow_data->drawing->pixmap;
1159 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
1160
1161
1162 if(process_in->state->s == LTTV_STATE_RUN)
1163 {
1164 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1165 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1166 draw_context_in->gc = control_flow_data->drawing->gc;
1167
1168 PropertiesBG prop_bg;
1169 prop_bg.color = g_new(GdkColor,1);
1170
1171 switch(tfc->index) {
1172 case 0:
1173 prop_bg.color->red = 0x1515;
1174 prop_bg.color->green = 0x1515;
1175 prop_bg.color->blue = 0x8c8c;
1176 break;
1177 case 1:
1178 prop_bg.color->red = 0x4e4e;
1179 prop_bg.color->green = 0xa9a9;
1180 prop_bg.color->blue = 0xa4a4;
1181 break;
1182 case 2:
1183 prop_bg.color->red = 0x7a7a;
1184 prop_bg.color->green = 0x4a4a;
1185 prop_bg.color->blue = 0x8b8b;
1186 break;
1187 case 3:
1188 prop_bg.color->red = 0x8080;
1189 prop_bg.color->green = 0x7777;
1190 prop_bg.color->blue = 0x4747;
1191 break;
1192 default:
1193 prop_bg.color->red = 0xe7e7;
1194 prop_bg.color->green = 0xe7e7;
1195 prop_bg.color->blue = 0xe7e7;
1196 }
1197
1198
1199 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1200 g_free(prop_bg.color);
1201 //gdk_gc_unref(draw_context_in->gc);
1202 }
1203
1204 draw_context_in->gc = widget->style->black_gc;
1205
1206 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
1207 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
1208 PropertiesText prop_text_in;
1209 prop_text_in.foreground = &colorfg_in;
1210 prop_text_in.background = &colorbg_in;
1211 prop_text_in.size = 6;
1212 prop_text_in.position = OVER;
1213
1214 g_debug("in state : %s", g_quark_to_string(process_in->state->s));
1215 /* foreground of text : status of the process */
1216 if(process_in->state->s == LTTV_STATE_UNNAMED)
1217 {
1218 prop_text_in.foreground->red = 0xffff;
1219 prop_text_in.foreground->green = 0xffff;
1220 prop_text_in.foreground->blue = 0xffff;
1221 }
1222 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1223 {
1224 prop_text_in.foreground->red = 0x0fff;
1225 prop_text_in.foreground->green = 0xffff;
1226 prop_text_in.foreground->blue = 0xfff0;
1227 }
1228 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1229 {
1230 prop_text_in.foreground->red = 0xffff;
1231 prop_text_in.foreground->green = 0xffff;
1232 prop_text_in.foreground->blue = 0x0000;
1233 }
1234 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
1235 {
1236 prop_text_in.foreground->red = 0xffff;
1237 prop_text_in.foreground->green = 0x0000;
1238 prop_text_in.foreground->blue = 0xffff;
1239 }
1240 else if(process_in->state->s == LTTV_STATE_WAIT)
1241 {
1242 prop_text_in.foreground->red = 0xffff;
1243 prop_text_in.foreground->green = 0x0000;
1244 prop_text_in.foreground->blue = 0x0000;
1245 }
1246 else if(process_in->state->s == LTTV_STATE_RUN)
1247 {
1248 prop_text_in.foreground->red = 0x0000;
1249 prop_text_in.foreground->green = 0xffff;
1250 prop_text_in.foreground->blue = 0x0000;
1251 }
1252 else
1253 {
1254 prop_text_in.foreground->red = 0xffff;
1255 prop_text_in.foreground->green = 0xffff;
1256 prop_text_in.foreground->blue = 0xffff;
1257 }
1258
1259
1260
1261 /* Print status of the process : U, WF, WC, E, W, R */
1262 if(process_in->state->s == LTTV_STATE_UNNAMED)
1263 prop_text_in.text = "U->";
1264 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1265 prop_text_in.text = "WF->";
1266 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1267 prop_text_in.text = "WC->";
1268 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
1269 prop_text_in.text = "E->";
1270 else if(process_in->state->s == LTTV_STATE_WAIT)
1271 prop_text_in.text = "W->";
1272 else if(process_in->state->s == LTTV_STATE_RUN)
1273 prop_text_in.text = "R->";
1274 else
1275 prop_text_in.text = "U";
1276
1277 draw_text((void*)&prop_text_in, (void*)draw_context_in);
1278 //gdk_gc_unref(draw_context_in->gc);
1279
1280 //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1281 //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1282 draw_context_in->gc = control_flow_data->drawing->gc;
1283
1284 PropertiesLine prop_line_in;
1285 prop_line_in.color = g_new(GdkColor,1);
1286 prop_line_in.line_width = 2;
1287 prop_line_in.style = GDK_LINE_SOLID;
1288 prop_line_in.position = MIDDLE;
1289
1290 /* color of line : status of the process */
1291 if(process_in->state->s == LTTV_STATE_UNNAMED)
1292 {
1293 prop_line_in.color->red = 0xffff;
1294 prop_line_in.color->green = 0xffff;
1295 prop_line_in.color->blue = 0xffff;
1296 }
1297 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1298 {
1299 prop_line_in.color->red = 0x0fff;
1300 prop_line_in.color->green = 0xffff;
1301 prop_line_in.color->blue = 0xfff0;
1302 }
1303 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1304 {
1305 prop_line_in.color->red = 0xffff;
1306 prop_line_in.color->green = 0xffff;
1307 prop_line_in.color->blue = 0x0000;
1308 }
1309 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
1310 {
1311 prop_line_in.color->red = 0xffff;
1312 prop_line_in.color->green = 0x0000;
1313 prop_line_in.color->blue = 0xffff;
1314 }
1315 else if(process_in->state->s == LTTV_STATE_WAIT)
1316 {
1317 prop_line_in.color->red = 0xffff;
1318 prop_line_in.color->green = 0x0000;
1319 prop_line_in.color->blue = 0x0000;
1320 }
1321 else if(process_in->state->s == LTTV_STATE_RUN)
1322 {
1323 prop_line_in.color->red = 0x0000;
1324 prop_line_in.color->green = 0xffff;
1325 prop_line_in.color->blue = 0x0000;
1326 }
1327 else
1328 {
1329 prop_line_in.color->red = 0xffff;
1330 prop_line_in.color->green = 0xffff;
1331 prop_line_in.color->blue = 0xffff;
1332 }
1333
1334 draw_line((void*)&prop_line_in, (void*)draw_context_in);
1335 g_free(prop_line_in.color);
1336 //gdk_gc_unref(draw_context_in->gc);
1337 }
1338
1339 return 0;
1340 #endif //0
1341
1342
1343
1344 /* Text dump */
1345 #ifdef DONTSHOW
1346 GString *string = g_string_new("");;
1347 gboolean field_names = TRUE, state = TRUE;
1348
1349 lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs);
1350 g_string_append_printf(string,"\n");
1351
1352 if(state) {
1353 g_string_append_printf(string, " %s",
1354 g_quark_to_string(tfs->process->state->s));
1355 }
1356
1357 g_info("%s",string->str);
1358
1359 g_string_free(string, TRUE);
1360
1361 /* End of text dump */
1362 #endif //DONTSHOW
1363
1364 }
1365
1366 /* after_schedchange_hook
1367 *
1368 * The draw after hook is called by the reading API to have a
1369 * particular event drawn on the screen.
1370 * @param hook_data ControlFlowData structure of the viewer.
1371 * @param call_data Event context.
1372 *
1373 * This function adds items to be drawn in a queue for each process.
1374 *
1375 */
1376 int after_schedchange_hook(void *hook_data, void *call_data)
1377 {
1378 EventsRequest *events_request = (EventsRequest*)hook_data;
1379 ControlFlowData *control_flow_data = events_request->viewer_data;
1380
1381 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1382
1383 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1384 LttvTraceState *ts =(LttvTraceState *)((LttvTracefileContext*)tfs)->t_context;
1385
1386 LttEvent *e;
1387 e = tfc->e;
1388
1389 LttTime evtime = ltt_event_time(e);
1390
1391 guint width = control_flow_data->drawing->width;
1392
1393 /* Add process to process list (if not present) */
1394 LttvProcessState *process_out, *process_in;
1395 LttTime birth;
1396 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
1397 HashedProcessData *hashed_process_data_in = NULL;
1398
1399 ProcessList *process_list = control_flow_data->process_list;
1400
1401 guint pid_in;
1402 {
1403 guint pid_out;
1404 LttField *f = ltt_event_field(e);
1405 LttField *element;
1406 element = ltt_field_member(f,0);
1407 pid_out = ltt_event_get_long_unsigned(e,element);
1408 element = ltt_field_member(f,1);
1409 pid_in = ltt_event_get_long_unsigned(e,element);
1410 g_debug("out : %u in : %u", pid_out, pid_in);
1411 }
1412
1413
1414 /* Find process pid_in in the list... */
1415 //process_in = lttv_state_find_process(tfs, pid_in);
1416 process_in = tfs->process;
1417 /* It should exist, because we are after the state update. */
1418 g_assert(process_in != NULL);
1419
1420 birth = process_in->creation_time;
1421
1422 hashed_process_data_in = processlist_get_process_data(process_list,
1423 pid_in,
1424 process_in->last_cpu_index,
1425 &birth,
1426 tfc->t_context->index);
1427 if(hashed_process_data_in == NULL)
1428 {
1429 g_assert(pid_in == 0 || pid_in != process_in->ppid);
1430 const gchar *name = g_quark_to_string(process_in->name);
1431 ProcessInfo *process_info;
1432 /* Process not present */
1433 processlist_add(process_list,
1434 pid_in,
1435 process_in->last_cpu_index,
1436 process_in->ppid,
1437 &birth,
1438 tfc->t_context->index,
1439 name,
1440 &pl_height,
1441 &process_info,
1442 &hashed_process_data_in);
1443 processlist_get_pixels_from_data(process_list,
1444 hashed_process_data_in,
1445 &y_in,
1446 &height);
1447 drawing_insert_square( control_flow_data->drawing, y_in, height);
1448 }
1449 /* Set the current process */
1450 process_list->current_hash_data[process_in->last_cpu_index] =
1451 hashed_process_data_in;
1452
1453 if(ltt_time_compare(hashed_process_data_in->next_good_time,
1454 evtime) <= 0)
1455 {
1456 processlist_get_pixels_from_data(process_list,
1457 hashed_process_data_in,
1458 &y_in,
1459 &height);
1460 TimeWindow time_window =
1461 lttvwindow_get_time_window(control_flow_data->tab);
1462
1463 #ifdef EXTRA_CHECK
1464 if(ltt_time_compare(evtime, time_window.start_time) == -1
1465 || ltt_time_compare(evtime, time_window.end_time) == 1)
1466 return;
1467 #endif //EXTRA_CHECK
1468
1469 guint new_x;
1470
1471 convert_time_to_pixels(
1472 time_window,
1473 evtime,
1474 width,
1475 &new_x);
1476
1477 if(hashed_process_data_in->x.middle != new_x) {
1478 hashed_process_data_in->x.middle = new_x;
1479 hashed_process_data_in->x.middle_used = FALSE;
1480 hashed_process_data_in->x.middle_marked = FALSE;
1481 }
1482 }
1483 return 0;
1484
1485
1486
1487
1488
1489 #if 0
1490 EventsRequest *events_request = (EventsRequest*)hook_data;
1491 ControlFlowData *control_flow_data = events_request->viewer_data;
1492
1493 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1494
1495 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1496 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
1497
1498
1499 LttEvent *e;
1500 e = tfc->e;
1501
1502 LttTime evtime = ltt_event_time(e);
1503 TimeWindow time_window =
1504 lttvwindow_get_time_window(control_flow_data->tab);
1505
1506 LttTime time_window.end_time = time_window.time_window.end_time;
1507
1508 //if(time < time_beg || time > time_end) return;
1509 if(ltt_time_compare(evtime, time_window.start_time) == -1
1510 || ltt_time_compare(evtime, time_window.end_time) == 1)
1511 return;
1512
1513
1514 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
1515 {
1516 g_debug("schedchange!");
1517
1518 /* Add process to process list (if not present) and get drawing "y" from
1519 * process position */
1520 guint pid_out, pid_in;
1521 LttvProcessState *process_out, *process_in;
1522 LttTime birth;
1523 guint y_in = 0, y_out = 0, height = 0, pl_height = 0;
1524
1525 ProcessList *process_list = control_flow_data->process_list;
1526
1527
1528 LttField *f = ltt_event_field(e);
1529 LttField *element;
1530 element = ltt_field_member(f,0);
1531 pid_out = ltt_event_get_long_unsigned(e,element);
1532 element = ltt_field_member(f,1);
1533 pid_in = ltt_event_get_long_unsigned(e,element);
1534 //g_debug("out : %u in : %u", pid_out, pid_in);
1535
1536
1537 /* Find process pid_out in the list... */
1538 process_out = lttv_state_find_process(tfs, pid_out);
1539 if(process_out == NULL) return 0;
1540 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
1541
1542 birth = process_out->creation_time;
1543 gchar *name = strdup(g_quark_to_string(process_out->name));
1544 HashedProcessData *hashed_process_data_out = NULL;
1545
1546 if(processlist_get_process_pixels(process_list,
1547 pid_out,
1548 &birth,
1549 tfc->t_context->index,
1550 &y_out,
1551 &height,
1552 &hashed_process_data_out) == 1)
1553 {
1554 /* Process not present */
1555 processlist_add(process_list,
1556 pid_out,
1557 &birth,
1558 tfc->t_context->index,
1559 name,
1560 &pl_height,
1561 &hashed_process_data_out);
1562 processlist_get_process_pixels(process_list,
1563 pid_out,
1564 &birth,
1565 tfc->t_context->index,
1566 &y_out,
1567 &height,
1568 &hashed_process_data_out);
1569 drawing_insert_square( control_flow_data->drawing, y_out, height);
1570 }
1571
1572 g_free(name);
1573
1574 /* Find process pid_in in the list... */
1575 process_in = lttv_state_find_process(tfs, pid_in);
1576 if(process_in == NULL) return 0;
1577 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
1578
1579 birth = process_in->creation_time;
1580 name = strdup(g_quark_to_string(process_in->name));
1581 HashedProcessData *hashed_process_data_in = NULL;
1582
1583 if(processlist_get_process_pixels(process_list,
1584 pid_in,
1585 &birth,
1586 tfc->t_context->index,
1587 &y_in,
1588 &height,
1589 &hashed_process_data_in) == 1)
1590 {
1591 /* Process not present */
1592 processlist_add(process_list,
1593 pid_in,
1594 &birth,
1595 tfc->t_context->index,
1596 name,
1597 &pl_height,
1598 &hashed_process_data_in);
1599 processlist_get_process_pixels(process_list,
1600 pid_in,
1601 &birth,
1602 tfc->t_context->index,
1603 &y_in,
1604 &height,
1605 &hashed_process_data_in);
1606
1607 drawing_insert_square( control_flow_data->drawing, y_in, height);
1608 }
1609 g_free(name);
1610
1611
1612 /* Find pixels corresponding to time of the event. If the time does
1613 * not fit in the window, show a warning, not supposed to happend. */
1614 //guint x = 0;
1615 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
1616
1617 //LttTime time = ltt_event_time(e);
1618
1619 //LttTime window_end = time_window->time_window.end_time;
1620
1621
1622 //convert_time_to_pixels(
1623 // *time_window,
1624 // time,
1625 // width,
1626 // &x);
1627
1628 //assert(x <= width);
1629
1630 /* draw what represents the event for outgoing process. */
1631
1632 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
1633 //draw_context_out->current->modify_over->x = x;
1634 draw_context_out->current->modify_over->y = y_out;
1635 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
1636 draw_context_out->drawable = control_flow_data->drawing->pixmap;
1637 draw_context_out->pango_layout = control_flow_data->drawing->pango_layout;
1638 GtkWidget *widget = control_flow_data->drawing->drawing_area;
1639 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1640
1641 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
1642 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1643
1644 /*if(process_out->state->s == LTTV_STATE_RUN)
1645 {
1646 draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1647 gdk_gc_copy(draw_context_out->gc, widget->style->black_gc);
1648 PropertiesBG prop_bg;
1649 prop_bg.color = g_new(GdkColor,1);
1650
1651 prop_bg.color->red = 0xffff;
1652 prop_bg.color->green = 0xffff;
1653 prop_bg.color->blue = 0xffff;
1654
1655 draw_bg((void*)&prop_bg, (void*)draw_context_out);
1656 g_free(prop_bg.color);
1657 gdk_gc_unref(draw_context_out->gc);
1658 }*/
1659
1660 draw_context_out->gc = widget->style->black_gc;
1661
1662 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
1663 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
1664 PropertiesText prop_text_out;
1665 prop_text_out.foreground = &colorfg_out;
1666 prop_text_out.background = &colorbg_out;
1667 prop_text_out.size = 6;
1668 prop_text_out.position = OVER;
1669
1670 /* color of text : status of the process */
1671 if(process_out->state->s == LTTV_STATE_UNNAMED)
1672 {
1673 prop_text_out.foreground->red = 0xffff;
1674 prop_text_out.foreground->green = 0xffff;
1675 prop_text_out.foreground->blue = 0xffff;
1676 }
1677 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
1678 {
1679 prop_text_out.foreground->red = 0x0fff;
1680 prop_text_out.foreground->green = 0xffff;
1681 prop_text_out.foreground->blue = 0xfff0;
1682 }
1683 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
1684 {
1685 prop_text_out.foreground->red = 0xffff;
1686 prop_text_out.foreground->green = 0xffff;
1687 prop_text_out.foreground->blue = 0x0000;
1688 }
1689 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
1690 {
1691 prop_text_out.foreground->red = 0xffff;
1692 prop_text_out.foreground->green = 0x0000;
1693 prop_text_out.foreground->blue = 0xffff;
1694 }
1695 else if(process_out->state->s == LTTV_STATE_WAIT)
1696 {
1697 prop_text_out.foreground->red = 0xffff;
1698 prop_text_out.foreground->green = 0x0000;
1699 prop_text_out.foreground->blue = 0x0000;
1700 }
1701 else if(process_out->state->s == LTTV_STATE_RUN)
1702 {
1703 prop_text_out.foreground->red = 0x0000;
1704 prop_text_out.foreground->green = 0xffff;
1705 prop_text_out.foreground->blue = 0x0000;
1706 }
1707 else
1708 {
1709 prop_text_out.foreground->red = 0xffff;
1710 prop_text_out.foreground->green = 0xffff;
1711 prop_text_out.foreground->blue = 0xffff;
1712 }
1713
1714 /* Print status of the process : U, WF, WC, E, W, R */
1715 if(process_out->state->s == LTTV_STATE_UNNAMED)
1716 prop_text_out.text = "U";
1717 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
1718 prop_text_out.text = "WF";
1719 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
1720 prop_text_out.text = "WC";
1721 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
1722 prop_text_out.text = "E";
1723 else if(process_out->state->s == LTTV_STATE_WAIT)
1724 prop_text_out.text = "W";
1725 else if(process_out->state->s == LTTV_STATE_RUN)
1726 prop_text_out.text = "R";
1727 else
1728 prop_text_out.text = "U";
1729
1730 draw_text((void*)&prop_text_out, (void*)draw_context_out);
1731
1732 //gdk_gc_unref(draw_context_out->gc);
1733
1734 draw_context_out->current->middle->y = y_out+height/2;
1735 draw_context_out->current->over->y = y_out;
1736 draw_context_out->current->under->y = y_out+height;
1737 draw_context_out->current->status = process_out->state->s;
1738
1739 /* for pid_out : remove previous, Prev = current, new current (default) */
1740 g_free(draw_context_out->previous->modify_under);
1741 g_free(draw_context_out->previous->modify_middle);
1742 g_free(draw_context_out->previous->modify_over);
1743 g_free(draw_context_out->previous->under);
1744 g_free(draw_context_out->previous->middle);
1745 g_free(draw_context_out->previous->over);
1746 g_free(draw_context_out->previous);
1747
1748 draw_context_out->previous = draw_context_out->current;
1749
1750 draw_context_out->current = g_new(DrawInfo,1);
1751 draw_context_out->current->over = g_new(ItemInfo,1);
1752 draw_context_out->current->over->x = -1;
1753 draw_context_out->current->over->y = -1;
1754 draw_context_out->current->middle = g_new(ItemInfo,1);
1755 draw_context_out->current->middle->x = -1;
1756 draw_context_out->current->middle->y = -1;
1757 draw_context_out->current->under = g_new(ItemInfo,1);
1758 draw_context_out->current->under->x = -1;
1759 draw_context_out->current->under->y = -1;
1760 draw_context_out->current->modify_over = g_new(ItemInfo,1);
1761 draw_context_out->current->modify_over->x = -1;
1762 draw_context_out->current->modify_over->y = -1;
1763 draw_context_out->current->modify_middle = g_new(ItemInfo,1);
1764 draw_context_out->current->modify_middle->x = -1;
1765 draw_context_out->current->modify_middle->y = -1;
1766 draw_context_out->current->modify_under = g_new(ItemInfo,1);
1767 draw_context_out->current->modify_under->x = -1;
1768 draw_context_out->current->modify_under->y = -1;
1769 draw_context_out->current->status = LTTV_STATE_UNNAMED;
1770
1771 /* Finally, update the drawing context of the pid_in. */
1772
1773 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
1774 //draw_context_in->current->modify_over->x = x;
1775 draw_context_in->current->modify_over->y = y_in;
1776 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
1777 draw_context_in->drawable = control_flow_data->drawing->pixmap;
1778 draw_context_in->pango_layout = control_flow_data->drawing->pango_layout;
1779 widget = control_flow_data->drawing->drawing_area;
1780 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1781
1782 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
1783 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
1784
1785 /*if(process_in->state->s == LTTV_STATE_RUN)
1786 {
1787 draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap);
1788 gdk_gc_copy(draw_context_in->gc, widget->style->black_gc);
1789 PropertiesBG prop_bg;
1790 prop_bg.color = g_new(GdkColor,1);
1791
1792 prop_bg.color->red = 0xffff;
1793 prop_bg.color->green = 0xffff;
1794 prop_bg.color->blue = 0xffff;
1795
1796 draw_bg((void*)&prop_bg, (void*)draw_context_in);
1797 g_free(prop_bg.color);
1798 gdk_gc_unref(draw_context_in->gc);
1799 }*/
1800
1801 draw_context_in->gc = widget->style->black_gc;
1802
1803 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
1804 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
1805 PropertiesText prop_text_in;
1806 prop_text_in.foreground = &colorfg_in;
1807 prop_text_in.background = &colorbg_in;
1808 prop_text_in.size = 6;
1809 prop_text_in.position = OVER;
1810
1811 /* foreground of text : status of the process */
1812 if(process_in->state->s == LTTV_STATE_UNNAMED)
1813 {
1814 prop_text_in.foreground->red = 0xffff;
1815 prop_text_in.foreground->green = 0xffff;
1816 prop_text_in.foreground->blue = 0xffff;
1817 }
1818 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1819 {
1820 prop_text_in.foreground->red = 0x0fff;
1821 prop_text_in.foreground->green = 0xffff;
1822 prop_text_in.foreground->blue = 0xfff0;
1823 }
1824 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1825 {
1826 prop_text_in.foreground->red = 0xffff;
1827 prop_text_in.foreground->green = 0xffff;
1828 prop_text_in.foreground->blue = 0x0000;
1829 }
1830 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
1831 {
1832 prop_text_in.foreground->red = 0xffff;
1833 prop_text_in.foreground->green = 0x0000;
1834 prop_text_in.foreground->blue = 0xffff;
1835 }
1836 else if(process_in->state->s == LTTV_STATE_WAIT)
1837 {
1838 prop_text_in.foreground->red = 0xffff;
1839 prop_text_in.foreground->green = 0x0000;
1840 prop_text_in.foreground->blue = 0x0000;
1841 }
1842 else if(process_in->state->s == LTTV_STATE_RUN)
1843 {
1844 prop_text_in.foreground->red = 0x0000;
1845 prop_text_in.foreground->green = 0xffff;
1846 prop_text_in.foreground->blue = 0x0000;
1847 }
1848 else
1849 {
1850 prop_text_in.foreground->red = 0xffff;
1851 prop_text_in.foreground->green = 0xffff;
1852 prop_text_in.foreground->blue = 0xffff;
1853 }
1854
1855
1856 /* Print status of the process : U, WF, WC, E, W, R */
1857 if(process_in->state->s == LTTV_STATE_UNNAMED)
1858 prop_text_in.text = "U";
1859 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1860 prop_text_in.text = "WF";
1861 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1862 prop_text_in.text = "WC";
1863 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
1864 prop_text_in.text = "E";
1865 else if(process_in->state->s == LTTV_STATE_WAIT)
1866 prop_text_in.text = "W";
1867 else if(process_in->state->s == LTTV_STATE_RUN)
1868 prop_text_in.text = "R";
1869 else
1870 prop_text_in.text = "U";
1871
1872 draw_text((void*)&prop_text_in, (void*)draw_context_in);
1873
1874
1875 if(process_in->state->s == LTTV_STATE_RUN)
1876 {
1877 gchar tmp[255];
1878 prop_text_in.foreground = &colorfg_in;
1879 prop_text_in.background = &colorbg_in;
1880 prop_text_in.foreground->red = 0xffff;
1881 prop_text_in.foreground->green = 0xffff;
1882 prop_text_in.foreground->blue = 0xffff;
1883 prop_text_in.size = 6;
1884 prop_text_in.position = UNDER;
1885
1886 prop_text_in.text = g_new(gchar, 260);
1887 strcpy(prop_text_in.text, "CPU ");
1888 snprintf(tmp, 255, "%u", tfc->index);
1889 strcat(prop_text_in.text, tmp);
1890
1891 draw_text((void*)&prop_text_in, (void*)draw_context_in);
1892 g_free(prop_text_in.text);
1893 }
1894
1895
1896 draw_context_in->current->middle->y = y_in+height/2;
1897 draw_context_in->current->over->y = y_in;
1898 draw_context_in->current->under->y = y_in+height;
1899 draw_context_in->current->status = process_in->state->s;
1900
1901 /* for pid_in : remove previous, Prev = current, new current (default) */
1902 g_free(draw_context_in->previous->modify_under);
1903 g_free(draw_context_in->previous->modify_middle);
1904 g_free(draw_context_in->previous->modify_over);
1905 g_free(draw_context_in->previous->under);
1906 g_free(draw_context_in->previous->middle);
1907 g_free(draw_context_in->previous->over);
1908 g_free(draw_context_in->previous);
1909
1910 draw_context_in->previous = draw_context_in->current;
1911
1912 draw_context_in->current = g_new(DrawInfo,1);
1913 draw_context_in->current->over = g_new(ItemInfo,1);
1914 draw_context_in->current->over->x = -1;
1915 draw_context_in->current->over->y = -1;
1916 draw_context_in->current->middle = g_new(ItemInfo,1);
1917 draw_context_in->current->middle->x = -1;
1918 draw_context_in->current->middle->y = -1;
1919 draw_context_in->current->under = g_new(ItemInfo,1);
1920 draw_context_in->current->under->x = -1;
1921 draw_context_in->current->under->y = -1;
1922 draw_context_in->current->modify_over = g_new(ItemInfo,1);
1923 draw_context_in->current->modify_over->x = -1;
1924 draw_context_in->current->modify_over->y = -1;
1925 draw_context_in->current->modify_middle = g_new(ItemInfo,1);
1926 draw_context_in->current->modify_middle->x = -1;
1927 draw_context_in->current->modify_middle->y = -1;
1928 draw_context_in->current->modify_under = g_new(ItemInfo,1);
1929 draw_context_in->current->modify_under->x = -1;
1930 draw_context_in->current->modify_under->y = -1;
1931 draw_context_in->current->status = LTTV_STATE_UNNAMED;
1932
1933 }
1934
1935 return 0;
1936 #endif //0
1937 }
1938
1939 #if 0
1940 static inline PropertiesLine prepare_execmode_line(LttvProcessState *process)
1941 {
1942 PropertiesLine prop_line;
1943 prop_line.line_width = 1;
1944 prop_line.style = GDK_LINE_SOLID;
1945 prop_line.y = OVER;
1946 //GdkColormap *colormap = gdk_colormap_get_system();
1947
1948 /* color of line : execution mode of the process */
1949 if(process->state->t == LTTV_STATE_USER_MODE)
1950 prop_line.color = drawing_colors[COL_USER_MODE];
1951 else if(process->state->t == LTTV_STATE_SYSCALL)
1952 prop_line.color = drawing_colors[COL_SYSCALL];
1953 else if(process->state->t == LTTV_STATE_TRAP)
1954 prop_line.color = drawing_colors[COL_TRAP];
1955 else if(process->state->t == LTTV_STATE_IRQ)
1956 prop_line.color = drawing_colors[COL_IRQ];
1957 else if(process->state->t == LTTV_STATE_MODE_UNKNOWN)
1958 prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
1959 else
1960 prop_line.color = drawing_colors[COL_WHITE];
1961
1962 //gdk_colormap_alloc_color(colormap,
1963 // prop_line.color,
1964 // FALSE,
1965 // TRUE);
1966
1967 return prop_line;
1968
1969 }
1970 #endif //0
1971
1972
1973 /* before_execmode_hook
1974 *
1975 * This function basically draw lines and icons. Two types of lines are drawn :
1976 * one small (3 pixels?) representing the state of the process and the second
1977 * type is thicker (10 pixels?) representing on which CPU a process is running
1978 * (and this only in running state).
1979 *
1980 * Extremums of the lines :
1981 * x_min : time of the last event context for this process kept in memory.
1982 * x_max : time of the current event.
1983 * y : middle of the process in the process list. The process is found in the
1984 * list, therefore is it's position in pixels.
1985 *
1986 * The choice of lines'color is defined by the context of the last event for this
1987 * process.
1988 */
1989
1990
1991 int before_execmode_hook(void *hook_data, void *call_data)
1992 {
1993 EventsRequest *events_request = (EventsRequest*)hook_data;
1994 ControlFlowData *control_flow_data = events_request->viewer_data;
1995 Drawing_t *drawing = control_flow_data->drawing;
1996
1997 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1998
1999 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
2000 LttvTraceState *ts =(LttvTraceState *)((LttvTracefileContext*)tfs)->t_context;
2001
2002 LttEvent *e;
2003 e = tfc->e;
2004
2005 LttTime evtime = ltt_event_time(e);
2006 guint width = drawing->width;
2007
2008 /* we are in a execmode, before the state update. We must draw the
2009 * items corresponding to the state before it changes : now is the right
2010 * time to do it.
2011 */
2012 /* For the pid */
2013 LttvProcessState *process = tfs->process;
2014 g_assert(process != NULL);
2015
2016 guint pid = process->pid;
2017
2018 /* Well, the process_out existed : we must get it in the process hash
2019 * or add it, and draw its items.
2020 */
2021 /* Add process to process list (if not present) */
2022 guint y = 0, height = 0, pl_height = 0;
2023 HashedProcessData *hashed_process_data = NULL;
2024 ProcessList *process_list = control_flow_data->process_list;
2025 LttTime birth = process->creation_time;
2026
2027 if(process_list->current_hash_data[tfc->index] != NULL) {
2028 hashed_process_data = process_list->current_hash_data[tfc->index];
2029 } else {
2030 hashed_process_data = processlist_get_process_data(process_list,
2031 pid,
2032 process->last_cpu_index,
2033 &birth,
2034 tfc->t_context->index);
2035 if(hashed_process_data == NULL)
2036 {
2037 g_assert(pid == 0 || pid != process->ppid);
2038 ProcessInfo *process_info;
2039 /* Process not present */
2040 const gchar *name = g_quark_to_string(process->name);
2041 processlist_add(process_list,
2042 pid,
2043 process->last_cpu_index,
2044 process->ppid,
2045 &birth,
2046 tfc->t_context->index,
2047 name,
2048 &pl_height,
2049 &process_info,
2050 &hashed_process_data);
2051 processlist_get_pixels_from_data(process_list,
2052 hashed_process_data,
2053 &y,
2054 &height);
2055 drawing_insert_square( drawing, y, height);
2056 }
2057 /* Set the current process */
2058 process_list->current_hash_data[process->last_cpu_index] =
2059 hashed_process_data;
2060 }
2061
2062 /* Now, the process is in the state hash and our own process hash.
2063 * We definitely can draw the items related to the ending state.
2064 */
2065
2066 /* Check if the x position is unset. In can have been left unset by
2067 * a draw closure from a after chunk hook. This should never happen,
2068 * because it must be set by before chunk hook to the damage_begin
2069 * value.
2070 */
2071 g_assert(hashed_process_data->x.over != -1);
2072
2073 if(ltt_time_compare(hashed_process_data->next_good_time,
2074 evtime) > 0)
2075 {
2076 if(hashed_process_data->x.middle_marked == FALSE) {
2077 processlist_get_pixels_from_data(process_list,
2078 hashed_process_data,
2079 &y,
2080 &height);
2081 TimeWindow time_window =
2082 lttvwindow_get_time_window(control_flow_data->tab);
2083
2084 #ifdef EXTRA_CHECK
2085 if(ltt_time_compare(evtime, time_window.start_time) == -1
2086 || ltt_time_compare(evtime, time_window.end_time) == 1)
2087 return;
2088 #endif //EXTRA_CHECK
2089 guint x;
2090 convert_time_to_pixels(
2091 time_window,
2092 evtime,
2093 width,
2094 &x);
2095
2096 /* Draw collision indicator */
2097 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
2098 gdk_draw_point(drawing->pixmap,
2099 drawing->gc,
2100 x,
2101 y+(height/2)-3);
2102 hashed_process_data->x.middle_marked = TRUE;
2103 }
2104 } else {
2105 processlist_get_pixels_from_data(process_list,
2106 hashed_process_data,
2107 &y,
2108 &height);
2109 TimeWindow time_window =
2110 lttvwindow_get_time_window(control_flow_data->tab);
2111
2112 #ifdef EXTRA_CHECK
2113 if(ltt_time_compare(evtime, time_window.start_time) == -1
2114 || ltt_time_compare(evtime, time_window.end_time) == 1)
2115 return;
2116 #endif //EXTRA_CHECK
2117 guint x;
2118
2119 convert_time_to_pixels(
2120 time_window,
2121 evtime,
2122 width,
2123 &x);
2124
2125
2126 /* Jump over draw if we are at the same x position */
2127 if(x == hashed_process_data->x.middle &&
2128 hashed_process_data->x.middle_used)
2129 {
2130 if(hashed_process_data->x.middle_marked == FALSE) {
2131 /* Draw collision indicator */
2132 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
2133 gdk_draw_point(drawing->pixmap,
2134 drawing->gc,
2135 x,
2136 y+(height/2)-3);
2137 hashed_process_data->x.middle_marked = TRUE;
2138 }
2139 /* jump */
2140 } else {
2141
2142 DrawContext draw_context;
2143 /* Now create the drawing context that will be used to draw
2144 * items related to the last state. */
2145 draw_context.drawable = drawing->pixmap;
2146 draw_context.gc = drawing->gc;
2147 draw_context.pango_layout = drawing->pango_layout;
2148 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
2149 draw_context.drawinfo.end.x = x;
2150
2151 draw_context.drawinfo.y.over = y+1;
2152 draw_context.drawinfo.y.middle = y+(height/2);
2153 draw_context.drawinfo.y.under = y+height;
2154
2155 draw_context.drawinfo.start.offset.over = 0;
2156 draw_context.drawinfo.start.offset.middle = 0;
2157 draw_context.drawinfo.start.offset.under = 0;
2158 draw_context.drawinfo.end.offset.over = 0;
2159 draw_context.drawinfo.end.offset.middle = 0;
2160 draw_context.drawinfo.end.offset.under = 0;
2161
2162 {
2163 /* Draw the line */
2164 PropertiesLine prop_line = prepare_s_e_line(process);
2165 draw_line((void*)&prop_line, (void*)&draw_context);
2166
2167 }
2168 /* become the last x position */
2169 hashed_process_data->x.middle = x;
2170 hashed_process_data->x.middle_used = TRUE;
2171 hashed_process_data->x.middle_marked = FALSE;
2172
2173 /* Calculate the next good time */
2174 convert_pixels_to_time(width, x+1, time_window,
2175 &hashed_process_data->next_good_time);
2176 }
2177 }
2178
2179 return 0;
2180 }
2181
2182 /* after_execmode_hook
2183 *
2184 * The draw after hook is called by the reading API to have a
2185 * particular event drawn on the screen.
2186 * @param hook_data ControlFlowData structure of the viewer.
2187 * @param call_data Event context.
2188 *
2189 * This function adds items to be drawn in a queue for each process.
2190 *
2191 */
2192 int after_execmode_hook(void *hook_data, void *call_data)
2193 {
2194 /**************** DOES NOTHING!! *************/
2195 /* hook desactivated in drawing.c */
2196 return 0;
2197
2198
2199
2200 EventsRequest *events_request = (EventsRequest*)hook_data;
2201 ControlFlowData *control_flow_data = events_request->viewer_data;
2202
2203 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2204
2205 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
2206 LttvTraceState *ts =(LttvTraceState *)((LttvTracefileContext*)tfs)->t_context;
2207
2208 LttEvent *e;
2209 e = tfc->e;
2210
2211 LttTime evtime = ltt_event_time(e);
2212 guint width = control_flow_data->drawing->width;
2213
2214 /* Add process to process list (if not present) */
2215 LttvProcessState *process;
2216 LttTime birth;
2217 guint y = 0, height = 0, pl_height = 0;
2218 HashedProcessData *hashed_process_data = NULL;
2219
2220 ProcessList *process_list = control_flow_data->process_list;
2221
2222 /* Find process pid_in in the list... */
2223 process = tfs->process;
2224 /* It should exist, because we are after the state update. */
2225 g_assert(process != NULL);
2226
2227 guint pid = process->pid;
2228
2229 birth = process->creation_time;
2230
2231 if(process_list->current_hash_data[tfc->index] != NULL) {
2232 hashed_process_data = process_list->current_hash_data[tfc->index];
2233 } else {
2234 hashed_process_data = processlist_get_process_data(process_list,
2235 pid,
2236 process->last_cpu_index,
2237 &birth,
2238 tfc->t_context->index);
2239 if(hashed_process_data == NULL)
2240 {
2241 g_assert(pid == 0 || pid != process->ppid);
2242 /* Process not present */
2243 const gchar *name = g_quark_to_string(process->name);
2244 ProcessInfo *process_info;
2245 processlist_add(process_list,
2246 pid,
2247 process->last_cpu_index,
2248 process->ppid,
2249 &birth,
2250 tfc->t_context->index,
2251 name,
2252 &pl_height,
2253 &process_info,
2254 &hashed_process_data);
2255 processlist_get_pixels_from_data(process_list,
2256 hashed_process_data,
2257 &y,
2258 &height);
2259 drawing_insert_square( control_flow_data->drawing, y, height);
2260 }
2261 /* Set the current process */
2262 process_list->current_hash_data[process->last_cpu_index] =
2263 hashed_process_data;
2264 }
2265
2266 if(ltt_time_compare(hashed_process_data->next_good_time,
2267 evtime) <= 0)
2268 {
2269 #if 0
2270 processlist_get_pixels_from_data(process_list,
2271 hashed_process_data,
2272 &y,
2273 &height);
2274 #endif //0
2275 TimeWindow time_window =
2276 lttvwindow_get_time_window(control_flow_data->tab);
2277
2278 #ifdef EXTRA_CHECK
2279 if(ltt_time_compare(evtime, time_window.start_time) == -1
2280 || ltt_time_compare(evtime, time_window.end_time) == 1)
2281 return;
2282 #endif //EXTRA_CHECK
2283
2284
2285 guint new_x;
2286
2287 convert_time_to_pixels(
2288 time_window,
2289 evtime,
2290 width,
2291 &new_x);
2292
2293 if(hashed_process_data->x.middle != new_x) {
2294 hashed_process_data->x.middle = new_x;
2295 hashed_process_data->x.middle_used = FALSE;
2296 hashed_process_data->x.middle_marked = FALSE;
2297 }
2298 }
2299 return 0;
2300 }
2301
2302
2303
2304 /* before_process_hook
2305 *
2306 * Draw lines for process event.
2307 *
2308 * @param hook_data ControlFlowData structure of the viewer.
2309 * @param call_data Event context.
2310 *
2311 * This function adds items to be drawn in a queue for each process.
2312 *
2313 */
2314 int before_process_hook(void *hook_data, void *call_data)
2315 {
2316 EventsRequest *events_request = (EventsRequest*)hook_data;
2317 ControlFlowData *control_flow_data = events_request->viewer_data;
2318 Drawing_t *drawing = control_flow_data->drawing;
2319
2320 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2321
2322 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
2323 LttvTraceState *ts =(LttvTraceState *)((LttvTracefileContext*)tfs)->t_context;
2324
2325 LttEvent *e;
2326 e = tfc->e;
2327
2328 LttTime evtime = ltt_event_time(e);
2329 guint width = control_flow_data->drawing->width;
2330
2331 guint sub_id;
2332 {
2333 LttField *f = ltt_event_field(e);
2334 LttField *element;
2335 element = ltt_field_member(f,0);
2336 sub_id = ltt_event_get_long_unsigned(e,element);
2337 }
2338
2339 if(sub_id == 3) { /* exit */
2340
2341 /* Add process to process list (if not present) */
2342 LttvProcessState *process = tfs->process;
2343 guint pid = process->pid;
2344 LttTime birth;
2345 guint y = 0, height = 0, pl_height = 0;
2346 HashedProcessData *hashed_process_data = NULL;
2347
2348 ProcessList *process_list = control_flow_data->process_list;
2349
2350 g_assert(process != NULL);
2351
2352 birth = process->creation_time;
2353
2354 if(process_list->current_hash_data[tfc->index] != NULL) {
2355 hashed_process_data = process_list->current_hash_data[tfc->index];
2356 } else {
2357 hashed_process_data = processlist_get_process_data(process_list,
2358 pid,
2359 process->last_cpu_index,
2360 &birth,
2361 tfc->t_context->index);
2362 if(hashed_process_data == NULL)
2363 {
2364 g_assert(pid == 0 || pid != process->ppid);
2365 /* Process not present */
2366 const gchar *name = g_quark_to_string(process->name);
2367 ProcessInfo *process_info;
2368 processlist_add(process_list,
2369 pid,
2370 process->last_cpu_index,
2371 process->ppid,
2372 &birth,
2373 tfc->t_context->index,
2374 name,
2375 &pl_height,
2376 &process_info,
2377 &hashed_process_data);
2378 processlist_get_pixels_from_data(process_list,
2379 hashed_process_data,
2380 &y,
2381 &height);
2382 drawing_insert_square( control_flow_data->drawing, y, height);
2383 }
2384 }
2385
2386 /* Now, the process is in the state hash and our own process hash.
2387 * We definitely can draw the items related to the ending state.
2388 */
2389
2390 /* Check if the x position is unset. In can have been left unset by
2391 * a draw closure from a after chunk hook. This should never happen,
2392 * because it must be set by before chunk hook to the damage_begin
2393 * value.
2394 */
2395 g_assert(hashed_process_data->x.over != -1);
2396
2397 if(ltt_time_compare(hashed_process_data->next_good_time,
2398 evtime) > 0)
2399 {
2400 if(hashed_process_data->x.middle_marked == FALSE) {
2401 processlist_get_pixels_from_data(process_list,
2402 hashed_process_data,
2403 &y,
2404 &height);
2405 TimeWindow time_window =
2406 lttvwindow_get_time_window(control_flow_data->tab);
2407
2408 #ifdef EXTRA_CHECK
2409 if(ltt_time_compare(evtime, time_window.start_time) == -1
2410 || ltt_time_compare(evtime, time_window.end_time) == 1)
2411 return;
2412 #endif //EXTRA_CHECK
2413
2414 guint x;
2415 convert_time_to_pixels(
2416 time_window,
2417 evtime,
2418 width,
2419 &x);
2420
2421 /* Draw collision indicator */
2422 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
2423 gdk_draw_point(drawing->pixmap,
2424 drawing->gc,
2425 x,
2426 y+(height/2)-3);
2427 hashed_process_data->x.middle_marked = TRUE;
2428 }
2429 } else {
2430 processlist_get_pixels_from_data(process_list,
2431 hashed_process_data,
2432 &y,
2433 &height);
2434 TimeWindow time_window =
2435 lttvwindow_get_time_window(control_flow_data->tab);
2436
2437 #ifdef EXTRA_CHECK
2438 if(ltt_time_compare(evtime, time_window.start_time) == -1
2439 || ltt_time_compare(evtime, time_window.end_time) == 1)
2440 return;
2441 #endif //EXTRA_CHECK
2442
2443 guint x;
2444
2445 convert_time_to_pixels(
2446 time_window,
2447 evtime,
2448 width,
2449 &x);
2450
2451
2452 /* Jump over draw if we are at the same x position */
2453 if(x == hashed_process_data->x.middle &&
2454 hashed_process_data->x.middle_used)
2455 {
2456 if(hashed_process_data->x.middle_marked == FALSE) {
2457 /* Draw collision indicator */
2458 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
2459 gdk_draw_point(drawing->pixmap,
2460 drawing->gc,
2461 x,
2462 y+(height/2)-3);
2463 hashed_process_data->x.middle_marked = TRUE;
2464 }
2465 /* jump */
2466 } else {
2467 DrawContext draw_context;
2468
2469 /* Now create the drawing context that will be used to draw
2470 * items related to the last state. */
2471 draw_context.drawable = drawing->pixmap;
2472 draw_context.gc = drawing->gc;
2473 draw_context.pango_layout = drawing->pango_layout;
2474 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
2475 draw_context.drawinfo.end.x = x;
2476
2477 draw_context.drawinfo.y.over = y+1;
2478 draw_context.drawinfo.y.middle = y+(height/2);
2479 draw_context.drawinfo.y.under = y+height;
2480
2481 draw_context.drawinfo.start.offset.over = 0;
2482 draw_context.drawinfo.start.offset.middle = 0;
2483 draw_context.drawinfo.start.offset.under = 0;
2484 draw_context.drawinfo.end.offset.over = 0;
2485 draw_context.drawinfo.end.offset.middle = 0;
2486 draw_context.drawinfo.end.offset.under = 0;
2487
2488 {
2489 /* Draw the line */
2490 PropertiesLine prop_line = prepare_s_e_line(process);
2491 draw_line((void*)&prop_line, (void*)&draw_context);
2492
2493 }
2494 /* become the last x position */
2495 hashed_process_data->x.middle = x;
2496 hashed_process_data->x.middle_used = TRUE;
2497 hashed_process_data->x.middle_marked = FALSE;
2498
2499 /* Calculate the next good time */
2500 convert_pixels_to_time(width, x+1, time_window,
2501 &hashed_process_data->next_good_time);
2502 }
2503 }
2504
2505 }
2506 return 0;
2507
2508 }
2509
2510
2511
2512
2513
2514
2515 /* after_process_hook
2516 *
2517 * Create the processlist entry for the child process. Put the last
2518 * position in x at the current time value.
2519 *
2520 * @param hook_data ControlFlowData structure of the viewer.
2521 * @param call_data Event context.
2522 *
2523 * This function adds items to be drawn in a queue for each process.
2524 *
2525 */
2526 int after_process_hook(void *hook_data, void *call_data)
2527 {
2528 EventsRequest *events_request = (EventsRequest*)hook_data;
2529 ControlFlowData *control_flow_data = events_request->viewer_data;
2530
2531 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2532
2533 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
2534 LttvTraceState *ts =(LttvTraceState *)((LttvTracefileContext*)tfs)->t_context;
2535
2536 LttEvent *e;
2537 e = tfc->e;
2538
2539 LttTime evtime = ltt_event_time(e);
2540 guint width = control_flow_data->drawing->width;
2541
2542 guint sub_id;
2543 guint param1;
2544 {
2545 LttField *f = ltt_event_field(e);
2546 LttField *element;
2547 element = ltt_field_member(f,0);
2548 sub_id = ltt_event_get_long_unsigned(e,element);
2549 element = ltt_field_member(f,1);
2550 param1 = ltt_event_get_long_unsigned(e,element);
2551 }
2552
2553 if(sub_id == 2) { /* fork */
2554
2555 guint child_pid = param1;
2556 /* Add process to process list (if not present) */
2557 LttvProcessState *process_child;
2558 LttTime birth;
2559 guint y_child = 0, height = 0, pl_height = 0;
2560 HashedProcessData *hashed_process_data_child = NULL;
2561
2562 ProcessList *process_list = control_flow_data->process_list;
2563
2564 /* Find child in the list... */
2565 process_child = lttv_state_find_process(tfs, child_pid);
2566 /* It should exist, because we are after the state update. */
2567 g_assert(process_child != NULL);
2568
2569 birth = process_child->creation_time;
2570
2571 hashed_process_data_child = processlist_get_process_data(process_list,
2572 child_pid,
2573 process_child->last_cpu_index,
2574 &birth,
2575 tfc->t_context->index);
2576 if(hashed_process_data_child == NULL)
2577 {
2578 g_assert(child_pid == 0 || child_pid != process_child->ppid);
2579 /* Process not present */
2580 const gchar *name = g_quark_to_string(process_child->name);
2581 ProcessInfo *process_info;
2582 processlist_add(process_list,
2583 child_pid,
2584 process_child->last_cpu_index,
2585 process_child->ppid,
2586 &birth,
2587 tfc->t_context->index,
2588 name,
2589 &pl_height,
2590 &process_info,
2591 &hashed_process_data_child);
2592 processlist_get_pixels_from_data(process_list,
2593 hashed_process_data_child,
2594 &y_child,
2595 &height);
2596 drawing_insert_square( control_flow_data->drawing, y_child, height);
2597 }
2598
2599
2600 if(ltt_time_compare(hashed_process_data_child->next_good_time,
2601 evtime) <= 0)
2602 {
2603 #if 0
2604 processlist_get_pixels_from_data(process_list,
2605 hashed_process_data_child,
2606 &y_child,
2607 &height);
2608 #endif //0
2609 TimeWindow time_window =
2610 lttvwindow_get_time_window(control_flow_data->tab);
2611
2612 #ifdef EXTRA_CHECK
2613 if(ltt_time_compare(evtime, time_window.start_time) == -1
2614 || ltt_time_compare(evtime, time_window.end_time) == 1)
2615 return;
2616 #endif //EXTRA_CHECK
2617
2618 guint new_x;
2619 convert_time_to_pixels(
2620 time_window,
2621 evtime,
2622 width,
2623 &new_x);
2624
2625 if(hashed_process_data_child->x.over != new_x) {
2626 hashed_process_data_child->x.over = new_x;
2627 hashed_process_data_child->x.over_used = FALSE;
2628 hashed_process_data_child->x.over_marked = FALSE;
2629 }
2630 if(hashed_process_data_child->x.middle != new_x) {
2631 hashed_process_data_child->x.middle = new_x;
2632 hashed_process_data_child->x.middle_used = FALSE;
2633 hashed_process_data_child->x.middle_marked = FALSE;
2634 }
2635 if(hashed_process_data_child->x.under != new_x) {
2636 hashed_process_data_child->x.under = new_x;
2637 hashed_process_data_child->x.under_used = FALSE;
2638 hashed_process_data_child->x.under_marked = FALSE;
2639 }
2640 }
2641
2642 } else if(sub_id == 3) { /* exit */
2643
2644 /* Add process to process list (if not present) */
2645 LttvProcessState *process = tfs->process;
2646 guint pid = process->pid;
2647 LttTime birth;
2648 guint y = 0, height = 0, pl_height = 0;
2649 HashedProcessData *hashed_process_data = NULL;
2650
2651 ProcessList *process_list = control_flow_data->process_list;
2652
2653 /* It should exist, because we are after the state update. */
2654 g_assert(process != NULL);
2655
2656 birth = process->creation_time;
2657
2658 if(process_list->current_hash_data[tfc->index] != NULL) {
2659 hashed_process_data = process_list->current_hash_data[tfc->index];
2660 } else {
2661 hashed_process_data = processlist_get_process_data(process_list,
2662 pid,
2663 process->last_cpu_index,
2664 &birth,
2665 tfc->t_context->index);
2666 if(hashed_process_data == NULL)
2667 {
2668 g_assert(pid == 0 || pid != process->ppid);
2669 /* Process not present */
2670 const gchar *name = g_quark_to_string(process->name);
2671 ProcessInfo *process_info;
2672 processlist_add(process_list,
2673 pid,
2674 process->last_cpu_index,
2675 process->ppid,
2676 &birth,
2677 tfc->t_context->index,
2678 name,
2679 &pl_height,
2680 &process_info,
2681 &hashed_process_data);
2682 processlist_get_pixels_from_data(process_list,
2683 hashed_process_data,
2684 &y,
2685 &height);
2686 drawing_insert_square( control_flow_data->drawing, y, height);
2687 }
2688
2689 /* Set the current process */
2690 process_list->current_hash_data[process->last_cpu_index] =
2691 hashed_process_data;
2692 }
2693
2694 if(ltt_time_compare(hashed_process_data->next_good_time,
2695 evtime) <= 0)
2696 {
2697 #if 0
2698 processlist_get_pixels_from_data(process_list,
2699 hashed_process_data,
2700 &y,
2701 &height);
2702 #endif //0
2703 TimeWindow time_window =
2704 lttvwindow_get_time_window(control_flow_data->tab);
2705
2706 #ifdef EXTRA_CHECK
2707 if(ltt_time_compare(evtime, time_window.start_time) == -1
2708 || ltt_time_compare(evtime, time_window.end_time) == 1)
2709 return;
2710 #endif //EXTRA_CHECK
2711
2712 guint new_x;
2713 convert_time_to_pixels(
2714 time_window,
2715 evtime,
2716 width,
2717 &new_x);
2718 if(hashed_process_data->x.middle != new_x) {
2719 hashed_process_data->x.middle = new_x;
2720 hashed_process_data->x.middle_used = FALSE;
2721 hashed_process_data->x.middle_marked = FALSE;
2722 }
2723 }
2724
2725 }
2726 return 0;
2727
2728 }
2729
2730
2731 gint update_time_window_hook(void *hook_data, void *call_data)
2732 {
2733 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2734 Drawing_t *drawing = control_flow_data->drawing;
2735
2736 const TimeWindowNotifyData *time_window_nofify_data =
2737 ((const TimeWindowNotifyData *)call_data);
2738
2739 TimeWindow *old_time_window =
2740 time_window_nofify_data->old_time_window;
2741 TimeWindow *new_time_window =
2742 time_window_nofify_data->new_time_window;
2743
2744 /* Update the ruler */
2745 drawing_update_ruler(control_flow_data->drawing,
2746 new_time_window);
2747
2748
2749 /* Two cases : zoom in/out or scrolling */
2750
2751 /* In order to make sure we can reuse the old drawing, the scale must
2752 * be the same and the new time interval being partly located in the
2753 * currently shown time interval. (reuse is only for scrolling)
2754 */
2755
2756 g_info("Old time window HOOK : %u, %u to %u, %u",
2757 old_time_window->start_time.tv_sec,
2758 old_time_window->start_time.tv_nsec,
2759 old_time_window->time_width.tv_sec,
2760 old_time_window->time_width.tv_nsec);
2761
2762 g_info("New time window HOOK : %u, %u to %u, %u",
2763 new_time_window->start_time.tv_sec,
2764 new_time_window->start_time.tv_nsec,
2765 new_time_window->time_width.tv_sec,
2766 new_time_window->time_width.tv_nsec);
2767
2768 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
2769 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
2770 {
2771 /* Same scale (scrolling) */
2772 g_info("scrolling");
2773 LttTime *ns = &new_time_window->start_time;
2774 LttTime *nw = &new_time_window->time_width;
2775 LttTime *os = &old_time_window->start_time;
2776 LttTime *ow = &old_time_window->time_width;
2777 LttTime old_end = old_time_window->end_time;
2778 LttTime new_end = new_time_window->end_time;
2779 //if(ns<os+w<ns+w)
2780 //if(ns<os+w && os+w<ns+w)
2781 //if(ns<old_end && os<ns)
2782 if(ltt_time_compare(*ns, old_end) == -1
2783 && ltt_time_compare(*os, *ns) == -1)
2784 {
2785 g_info("scrolling near right");
2786 /* Scroll right, keep right part of the screen */
2787 guint x = 0;
2788 guint width = control_flow_data->drawing->width;
2789 convert_time_to_pixels(
2790 *old_time_window,
2791 *ns,
2792 width,
2793 &x);
2794
2795 /* Copy old data to new location */
2796 gdk_draw_drawable (control_flow_data->drawing->pixmap,
2797 control_flow_data->drawing->drawing_area->style->black_gc,
2798 control_flow_data->drawing->pixmap,
2799 x, 0,
2800 0, 0,
2801 control_flow_data->drawing->width-x+SAFETY, -1);
2802
2803 if(drawing->damage_begin == drawing->damage_end)
2804 drawing->damage_begin = control_flow_data->drawing->width-x;
2805 else
2806 drawing->damage_begin = 0;
2807
2808 drawing->damage_end = control_flow_data->drawing->width;
2809
2810 /* Clear the data request background, but not SAFETY */
2811 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
2812 //control_flow_data->drawing->drawing_area->style->black_gc,
2813 control_flow_data->drawing->drawing_area->style->black_gc,
2814 TRUE,
2815 drawing->damage_begin+SAFETY, 0,
2816 drawing->damage_end - drawing->damage_begin, // do not overlap
2817 control_flow_data->drawing->height);
2818
2819 gtk_widget_queue_draw_area (drawing->drawing_area,
2820 0,0,
2821 control_flow_data->drawing->width,
2822 control_flow_data->drawing->height);
2823
2824 /* Get new data for the rest. */
2825 drawing_data_request(control_flow_data->drawing,
2826 &control_flow_data->drawing->pixmap,
2827 drawing->damage_begin, 0,
2828 drawing->damage_end - drawing->damage_begin,
2829 control_flow_data->drawing->height);
2830 } else {
2831 //if(ns<os<ns+w)
2832 //if(ns<os && os<ns+w)
2833 //if(ns<os && os<new_end)
2834 if(ltt_time_compare(*ns,*os) == -1
2835 && ltt_time_compare(*os,new_end) == -1)
2836 {
2837 g_info("scrolling near left");
2838 /* Scroll left, keep left part of the screen */
2839 guint x = 0;
2840 guint width = control_flow_data->drawing->width;
2841 convert_time_to_pixels(
2842 *new_time_window,
2843 *os,
2844 width,
2845 &x);
2846
2847
2848 /* Copy old data to new location */
2849 gdk_draw_drawable (control_flow_data->drawing->pixmap,
2850 control_flow_data->drawing->drawing_area->style->black_gc,
2851 control_flow_data->drawing->pixmap,
2852 0, 0,
2853 x, 0,
2854 -1, -1);
2855
2856 if(drawing->damage_begin == drawing->damage_end)
2857 drawing->damage_end = x;
2858 else
2859 drawing->damage_end =
2860 control_flow_data->drawing->width;
2861
2862 drawing->damage_begin = 0;
2863
2864 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
2865 control_flow_data->drawing->drawing_area->style->black_gc,
2866 TRUE,
2867 drawing->damage_begin, 0,
2868 drawing->damage_end - drawing->damage_begin, // do not overlap
2869 control_flow_data->drawing->height);
2870
2871 gtk_widget_queue_draw_area (drawing->drawing_area,
2872 0,0,
2873 control_flow_data->drawing->width,
2874 control_flow_data->drawing->height);
2875
2876
2877 /* Get new data for the rest. */
2878 drawing_data_request(control_flow_data->drawing,
2879 &control_flow_data->drawing->pixmap,
2880 drawing->damage_begin, 0,
2881 drawing->damage_end - drawing->damage_begin,
2882 control_flow_data->drawing->height);
2883
2884 } else {
2885 if(ltt_time_compare(*ns,*os) == 0)
2886 {
2887 g_info("not scrolling");
2888 } else {
2889 g_info("scrolling far");
2890 /* Cannot reuse any part of the screen : far jump */
2891
2892
2893 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
2894 control_flow_data->drawing->drawing_area->style->black_gc,
2895 TRUE,
2896 0, 0,
2897 control_flow_data->drawing->width+SAFETY, // do not overlap
2898 control_flow_data->drawing->height);
2899
2900 gtk_widget_queue_draw_area (drawing->drawing_area,
2901 0,0,
2902 control_flow_data->drawing->width,
2903 control_flow_data->drawing->height);
2904
2905 drawing->damage_begin = 0;
2906 drawing->damage_end = control_flow_data->drawing->width;
2907
2908 drawing_data_request(control_flow_data->drawing,
2909 &control_flow_data->drawing->pixmap,
2910 0, 0,
2911 control_flow_data->drawing->width,
2912 control_flow_data->drawing->height);
2913
2914 }
2915 }
2916 }
2917 } else {
2918 /* Different scale (zoom) */
2919 g_info("zoom");
2920
2921 gdk_draw_rectangle (control_flow_data->drawing->pixmap,
2922 control_flow_data->drawing->drawing_area->style->black_gc,
2923 TRUE,
2924 0, 0,
2925 control_flow_data->drawing->width+SAFETY, // do not overlap
2926 control_flow_data->drawing->height);
2927
2928 gtk_widget_queue_draw_area (drawing->drawing_area,
2929 0,0,
2930 control_flow_data->drawing->width,
2931 control_flow_data->drawing->height);
2932
2933 drawing->damage_begin = 0;
2934 drawing->damage_end = control_flow_data->drawing->width;
2935
2936 drawing_data_request(control_flow_data->drawing,
2937 &control_flow_data->drawing->pixmap,
2938 0, 0,
2939 control_flow_data->drawing->width,
2940 control_flow_data->drawing->height);
2941 }
2942
2943
2944
2945 return 0;
2946 }
2947
2948 gint traceset_notify(void *hook_data, void *call_data)
2949 {
2950 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2951 Drawing_t *drawing = control_flow_data->drawing;
2952 GtkWidget *widget = drawing->drawing_area;
2953
2954
2955 drawing_clear(control_flow_data->drawing);
2956 processlist_clear(control_flow_data->process_list);
2957 redraw_notify(control_flow_data, NULL);
2958
2959 request_background_data(control_flow_data);
2960 #if 0
2961 drawing->damage_begin = 0;
2962 drawing->damage_end = drawing->width;
2963 if(drawing->damage_begin < drawing->damage_end)
2964 {
2965 drawing_data_request(drawing,
2966 &drawing->pixmap,
2967 drawing->damage_begin,
2968 0,
2969 drawing->damage_end-drawing->damage_begin,
2970 drawing->height);
2971 }
2972
2973 gtk_widget_queue_draw_area(drawing->drawing_area,
2974 0,0,
2975 drawing->width,
2976 drawing->height);
2977 #endif //0
2978
2979 return FALSE;
2980 }
2981
2982 gint redraw_notify(void *hook_data, void *call_data)
2983 {
2984 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2985 Drawing_t *drawing = control_flow_data->drawing;
2986 GtkWidget *widget = drawing->drawing_area;
2987
2988 drawing->damage_begin = 0;
2989 drawing->damage_end = drawing->width;
2990
2991 /* fun feature, to be separated someday... */
2992 drawing_clear(control_flow_data->drawing);
2993 processlist_clear(control_flow_data->process_list);
2994
2995 // Clear the image
2996 gdk_draw_rectangle (drawing->pixmap,
2997 widget->style->black_gc,
2998 TRUE,
2999 0, 0,
3000 drawing->width+SAFETY,
3001 drawing->height);
3002
3003
3004 if(drawing->damage_begin < drawing->damage_end)
3005 {
3006 drawing_data_request(drawing,
3007 &drawing->pixmap,
3008 drawing->damage_begin,
3009 0,
3010 drawing->damage_end-drawing->damage_begin,
3011 drawing->height);
3012 }
3013
3014 gtk_widget_queue_draw_area(drawing->drawing_area,
3015 0,0,
3016 drawing->width,
3017 drawing->height);
3018 return FALSE;
3019
3020 }
3021
3022
3023 gint continue_notify(void *hook_data, void *call_data)
3024 {
3025 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
3026 Drawing_t *drawing = control_flow_data->drawing;
3027 GtkWidget *widget = drawing->drawing_area;
3028
3029 //g_assert(widget->allocation.width == drawing->damage_end);
3030
3031 if(drawing->damage_begin < drawing->damage_end)
3032 {
3033 drawing_data_request(drawing,
3034 &drawing->pixmap,
3035 drawing->damage_begin,
3036 0,
3037 drawing->damage_end-drawing->damage_begin,
3038 drawing->height);
3039 }
3040
3041 return FALSE;
3042 }
3043
3044
3045 gint update_current_time_hook(void *hook_data, void *call_data)
3046 {
3047 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
3048 Drawing_t *drawing = control_flow_data->drawing;
3049
3050 LttTime current_time = *((LttTime*)call_data);
3051
3052 TimeWindow time_window =
3053 lttvwindow_get_time_window(control_flow_data->tab);
3054
3055 LttTime time_begin = time_window.start_time;
3056 LttTime width = time_window.time_width;
3057 LttTime half_width;
3058 {
3059 guint64 time_ll = ltt_time_to_uint64(width);
3060 time_ll = time_ll >> 1; /* divide by two */
3061 half_width = ltt_time_from_uint64(time_ll);
3062 }
3063 LttTime time_end = ltt_time_add(time_begin, width);
3064
3065 LttvTracesetContext * tsc =
3066 lttvwindow_get_traceset_context(control_flow_data->tab);
3067
3068 LttTime trace_start = tsc->time_span.start_time;
3069 LttTime trace_end = tsc->time_span.end_time;
3070
3071 g_info("New current time HOOK : %u, %u", current_time.tv_sec,
3072 current_time.tv_nsec);
3073
3074
3075
3076 /* If current time is inside time interval, just move the highlight
3077 * bar */
3078
3079 /* Else, we have to change the time interval. We have to tell it
3080 * to the main window. */
3081 /* The time interval change will take care of placing the current
3082 * time at the center of the visible area, or nearest possible if we are
3083 * at one end of the trace. */
3084
3085
3086 if(ltt_time_compare(current_time, time_begin) == -1)
3087 {
3088 TimeWindow new_time_window;
3089
3090 if(ltt_time_compare(current_time,
3091 ltt_time_add(trace_start,half_width)) == -1)
3092 time_begin = trace_start;
3093 else
3094 time_begin = ltt_time_sub(current_time,half_width);
3095
3096 new_time_window.start_time = time_begin;
3097 new_time_window.time_width = width;
3098 new_time_window.time_width_double = ltt_time_to_double(width);
3099 new_time_window.end_time = ltt_time_add(time_begin, width);
3100
3101 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
3102 }
3103 else if(ltt_time_compare(current_time, time_end) == 1)
3104 {
3105 TimeWindow new_time_window;
3106
3107 if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) == 1)
3108 time_begin = ltt_time_sub(trace_end,width);
3109 else
3110 time_begin = ltt_time_sub(current_time,half_width);
3111
3112 new_time_window.start_time = time_begin;
3113 new_time_window.time_width = width;
3114 new_time_window.time_width_double = ltt_time_to_double(width);
3115 new_time_window.end_time = ltt_time_add(time_begin, width);
3116
3117 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
3118
3119 }
3120 //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
3121 gtk_widget_queue_draw_area(drawing->drawing_area,
3122 0,0,
3123 drawing->width,
3124 drawing->height);
3125
3126 return 0;
3127 }
3128
3129 typedef struct _ClosureData {
3130 EventsRequest *events_request;
3131 LttvTracesetState *tss;
3132 LttTime end_time;
3133 } ClosureData;
3134
3135
3136 void draw_closure(gpointer key, gpointer value, gpointer user_data)
3137 {
3138 ProcessInfo *process_info = (ProcessInfo*)key;
3139 HashedProcessData *hashed_process_data = (HashedProcessData*)value;
3140 ClosureData *closure_data = (ClosureData*)user_data;
3141
3142 EventsRequest *events_request = closure_data->events_request;
3143 ControlFlowData *control_flow_data = events_request->viewer_data;
3144 Drawing_t *drawing = control_flow_data->drawing;
3145
3146 LttvTracesetState *tss = closure_data->tss;
3147 LttvTracesetContext *tsc = (LttvTracesetContext*)closure_data->tss;
3148
3149 LttTime evtime = closure_data->end_time;
3150 guint width = drawing->width;
3151
3152 {
3153 /* For the process */
3154 /* First, check if the current process is in the state computation
3155 * process list. If it is there, that means we must add it right now and
3156 * draw items from the beginning of the read for it. If it is not
3157 * present, it's a new process and it was not present : it will
3158 * be added after the state update. */
3159 #ifdef EXTRA_CHECK
3160 g_assert(lttv_traceset_number(tsc->ts) > 0);
3161 #endif //EXTRA_CHECK
3162 /* tracefiles[0] is ok here, because we draw for every PID, and
3163 * assume CPU 0 for PID 0 //FIXME */
3164 LttvTracefileState *tfs =
3165 (LttvTracefileState*)tsc->traces[process_info->trace_num]->tracefiles[0];
3166
3167 LttvProcessState *process;
3168 process = lttv_state_find_process(tfs,
3169 process_info->pid);
3170
3171 if(process != NULL) {
3172
3173 /* Only draw for processes that are currently in the trace states */
3174
3175 guint y = 0, height = 0, pl_height = 0;
3176 ProcessList *process_list = control_flow_data->process_list;
3177 LttTime birth = process_info->birth;
3178
3179 /* Should be alike when background info is ready */
3180 if(control_flow_data->background_info_waiting==0)
3181 g_assert(ltt_time_compare(process->creation_time,
3182 process_info->birth) == 0);
3183 /* process HAS to be present */
3184 processlist_get_pixels_from_data(process_list,
3185 hashed_process_data,
3186 &y,
3187 &height);
3188
3189 /* Now, the process is in the state hash and our own process hash.
3190 * We definitely can draw the items related to the ending state.
3191 */
3192
3193 /* Check if the x position is unset. In can have been left unset by
3194 * a draw closure from a after chunk hook. This should never happen,
3195 * because it must be set by before chunk hook to the damage_begin
3196 * value.
3197 */
3198 g_assert(hashed_process_data->x.over != -1);
3199
3200 if(ltt_time_compare(hashed_process_data->next_good_time,
3201 evtime) <= 0)
3202 {
3203 TimeWindow time_window =
3204 lttvwindow_get_time_window(control_flow_data->tab);
3205
3206 #ifdef EXTRA_CHECK
3207 if(ltt_time_compare(evtime, time_window.start_time) == -1
3208 || ltt_time_compare(evtime, time_window.end_time) == 1)
3209 return;
3210 #endif //EXTRA_CHECK
3211 guint x;
3212
3213 convert_time_to_pixels(
3214 time_window,
3215 evtime,
3216 width,
3217 &x);
3218
3219 DrawContext draw_context;
3220
3221 /* Now create the drawing context that will be used to draw
3222 * items related to the last state. */
3223 draw_context.drawable = drawing->pixmap;
3224 draw_context.gc = drawing->gc;
3225 draw_context.pango_layout = drawing->pango_layout;
3226 draw_context.drawinfo.end.x = x;
3227
3228 draw_context.drawinfo.y.over = y+1;
3229 draw_context.drawinfo.y.middle = y+(height/2);
3230 draw_context.drawinfo.y.under = y+height;
3231
3232 draw_context.drawinfo.start.offset.over = 0;
3233 draw_context.drawinfo.start.offset.middle = 0;
3234 draw_context.drawinfo.start.offset.under = 0;
3235 draw_context.drawinfo.end.offset.over = 0;
3236 draw_context.drawinfo.end.offset.middle = 0;
3237 draw_context.drawinfo.end.offset.under = 0;
3238 #if 0
3239 /* Jump over draw if we are at the same x position */
3240 if(x == hashed_process_data->x.over)
3241 {
3242 /* jump */
3243 } else {
3244 draw_context.drawinfo.start.x = hashed_process_data->x.over;
3245 /* Draw the line */
3246 PropertiesLine prop_line = prepare_execmode_line(process);
3247 draw_line((void*)&prop_line, (void*)&draw_context);
3248
3249 hashed_process_data->x.over = x;
3250 }
3251 #endif //0
3252
3253 if(x == hashed_process_data->x.middle &&
3254 hashed_process_data->x.middle_used) {
3255 #if 0 /* do not mark closure : not missing information */
3256 if(hashed_process_data->x.middle_marked == FALSE) {
3257 /* Draw collision indicator */
3258 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
3259 gdk_draw_point(drawing->pixmap,
3260 drawing->gc,
3261 x,
3262 y+(height/2)-3);
3263 hashed_process_data->x.middle_marked = TRUE;
3264 }
3265 #endif //0
3266 /* Jump */
3267 } else {
3268 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
3269 /* Draw the line */
3270 PropertiesLine prop_line = prepare_s_e_line(process);
3271 draw_line((void*)&prop_line, (void*)&draw_context);
3272
3273 /* become the last x position */
3274 if(x != hashed_process_data->x.middle) {
3275 hashed_process_data->x.middle = x;
3276 /* but don't use the pixel */
3277 hashed_process_data->x.middle_used = FALSE;
3278
3279 /* Calculate the next good time */
3280 convert_pixels_to_time(width, x+1, time_window,
3281 &hashed_process_data->next_good_time);
3282 }
3283 }
3284 }
3285 }
3286 }
3287 return;
3288 }
3289
3290 int before_chunk(void *hook_data, void *call_data)
3291 {
3292 EventsRequest *events_request = (EventsRequest*)hook_data;
3293 LttvTracesetState *tss = (LttvTracesetState*)call_data;
3294
3295 drawing_chunk_begin(events_request, tss);
3296
3297 return 0;
3298 }
3299
3300 int before_request(void *hook_data, void *call_data)
3301 {
3302 EventsRequest *events_request = (EventsRequest*)hook_data;
3303 LttvTracesetState *tss = (LttvTracesetState*)call_data;
3304
3305 drawing_data_request_begin(events_request, tss);
3306
3307 return 0;
3308 }
3309
3310
3311 /*
3312 * after request is necessary in addition of after chunk in order to draw
3313 * lines until the end of the screen. after chunk just draws lines until
3314 * the last event.
3315 *
3316 * for each process
3317 * draw closing line
3318 * expose
3319 */
3320 int after_request(void *hook_data, void *call_data)
3321 {
3322 EventsRequest *events_request = (EventsRequest*)hook_data;
3323 ControlFlowData *control_flow_data = events_request->viewer_data;
3324 LttvTracesetState *tss = (LttvTracesetState*)call_data;
3325 LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
3326
3327 ProcessList *process_list = control_flow_data->process_list;
3328 LttTime end_time = events_request->end_time;
3329
3330 ClosureData closure_data;
3331 closure_data.events_request = (EventsRequest*)hook_data;
3332 closure_data.tss = tss;
3333 closure_data.end_time = end_time;
3334
3335 /* Draw last items */
3336 g_hash_table_foreach(process_list->process_hash, draw_closure,
3337 (void*)&closure_data);
3338
3339 /* Request expose */
3340 drawing_request_expose(events_request, tss, end_time);
3341 return 0;
3342 }
3343
3344 /*
3345 * for each process
3346 * draw closing line
3347 * expose
3348 */
3349 int after_chunk(void *hook_data, void *call_data)
3350 {
3351 EventsRequest *events_request = (EventsRequest*)hook_data;
3352 ControlFlowData *control_flow_data = events_request->viewer_data;
3353 LttvTracesetState *tss = (LttvTracesetState*)call_data;
3354 LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
3355 LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
3356 LttTime end_time;
3357
3358 ProcessList *process_list = control_flow_data->process_list;
3359
3360 g_free(process_list->current_hash_data);
3361 process_list->current_hash_data = NULL;
3362
3363 if(tfc != NULL)
3364 end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
3365 else /* end of traceset, or position now out of request : end */
3366 end_time = events_request->end_time;
3367
3368 ClosureData closure_data;
3369 closure_data.events_request = (EventsRequest*)hook_data;
3370 closure_data.tss = tss;
3371 closure_data.end_time = end_time;
3372
3373 /* Draw last items */
3374 g_hash_table_foreach(process_list->process_hash, draw_closure,
3375 (void*)&closure_data);
3376
3377 /* Request expose */
3378 drawing_request_expose(events_request, tss, end_time);
3379
3380 return 0;
3381 }
3382
This page took 0.102751 seconds and 4 git commands to generate.