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