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