correct currect time bar
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / eventhooks.c
CommitLineData
ce0214a6 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
f0d936c0 20/*****************************************************************************
21 * Hooks to be called by the main window *
22 *****************************************************************************/
23
f0d936c0 24
b9a010a2 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 *
e92eabaf 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.
b9a010a2 31 *
e92eabaf 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.
b9a010a2 34 *
e92eabaf 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
b9a010a2 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
e92eabaf 40 * corresponding to it is over, which happens to be at the next before_schedchange
b9a010a2 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
cf6cb7e0 49//#define PANGO_ENABLE_BACKEND
558aa013 50#include <gtk/gtk.h>
51#include <gdk/gdk.h>
5f16133f 52#include <glib.h>
80a52ff8 53#include <assert.h>
50439712 54#include <string.h>
319e9d81 55#include <stdio.h>
5f16133f 56
cf6cb7e0 57//#include <pango/pango.h>
58
80a52ff8 59#include <ltt/event.h>
4ba42155 60#include <ltt/time.h>
50439712 61#include <ltt/type.h>
80a52ff8 62
2a2fa4f0 63#include <lttv/lttv.h>
558aa013 64#include <lttv/hook.h>
80a52ff8 65#include <lttv/state.h>
2d262115 66#include <lttvwindow/lttvwindow.h>
6395d57c 67#include <lttvwindow/lttvwindowtraces.h>
80a52ff8 68
f0d936c0 69
a117e3f7 70#include "eventhooks.h"
71#include "cfv.h"
72#include "processlist.h"
73#include "drawing.h"
5f16133f 74
80a52ff8 75
1a31868c 76#define MAX_PATH_LEN 256
77
f0d936c0 78
b9a010a2 79#if 0
80typedef struct _ProcessAddClosure {
81 ControlFlowData *cfd;
82 guint trace_num;
83} ProcessAddClosure;
84
85static 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
5c230fc4 99 ProcessList *process_list = control_flow_data->process_list;
b9a010a2 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
6395d57c 135/* Action to do when background computation completed.
136 *
e800cf84 137 * Wait for all the awaited computations to be over.
6395d57c 138 */
139
140gint background_ready(void *hook_data, void *call_data)
141{
142 ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
143 LttvTrace *trace = (LttvTrace*)call_data;
144
e800cf84 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.");
6395d57c 149
e800cf84 150 drawing_clear(control_flow_data->drawing);
151 processlist_clear(control_flow_data->process_list);
07390ec1 152 gtk_widget_set_size_request(
153 control_flow_data->drawing->drawing_area,
154 -1, processlist_get_height(control_flow_data->process_list));
e800cf84 155 redraw_notify(control_flow_data, NULL);
b9a010a2 156 }
6395d57c 157
158 return 0;
159}
160
161
162/* Request background computation. Verify if it is in progress or ready first.
e800cf84 163 * Only for each trace in the tab's traceset.
6395d57c 164 */
165void request_background_data(ControlFlowData *control_flow_data)
166{
e800cf84 167 LttvTracesetContext * tsc =
168 lttvwindow_get_traceset_context(control_flow_data->tab);
169 gint num_traces = lttv_traceset_number(tsc->ts);
6395d57c 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);
e800cf84 177 control_flow_data->background_info_waiting = 0;
6395d57c 178
179 for(i=0;i<num_traces;i++) {
e800cf84 180 trace = lttv_traceset_get(tsc->ts, i);
6395d57c 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);
e800cf84 198 control_flow_data->background_info_waiting++;
6395d57c 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);
e800cf84 206 control_flow_data->background_info_waiting++;
6395d57c 207 }
4368b993 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 */
6395d57c 213 }
4368b993 214
6395d57c 215 }
216
217 lttv_hooks_destroy(background_ready_hook);
218}
219
220
221
222
f0d936c0 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.
ca0f8a8e 228 * @param tab A pointer to the parent tab.
f0d936c0 229 * @return The widget created.
230 */
231GtkWidget *
d47b33d2 232h_guicontrolflow(Tab *tab)
f0d936c0 233{
d47b33d2 234 g_info("h_guicontrolflow, %p", tab);
68997a22 235 ControlFlowData *control_flow_data = guicontrolflow() ;
a56a1ba4 236
ca0f8a8e 237 control_flow_data->tab = tab;
a56a1ba4 238
a56a1ba4 239 // Unreg done in the GuiControlFlow_Destructor
6395d57c 240 lttvwindow_register_traceset_notify(tab,
241 traceset_notify,
242 control_flow_data);
243
ca0f8a8e 244 lttvwindow_register_time_window_notify(tab,
224446ce 245 update_time_window_hook,
246 control_flow_data);
ca0f8a8e 247 lttvwindow_register_current_time_notify(tab,
224446ce 248 update_current_time_hook,
249 control_flow_data);
ca0f8a8e 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);
6395d57c 256 request_background_data(control_flow_data);
257
ca0f8a8e 258
68997a22 259 return guicontrolflow_get_widget(control_flow_data) ;
a56a1ba4 260
f0d936c0 261}
262
3cff8cc1 263int event_selected_hook(void *hook_data, void *call_data)
f0d936c0 264{
68997a22 265 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
14963be0 266 guint *event_number = (guint*) call_data;
f0d936c0 267
2a2fa4f0 268 g_debug("DEBUG : event selected by main window : %u", *event_number);
a56a1ba4 269
2eef04b5 270 return 0;
f0d936c0 271}
272
9a1ec01b 273/* Function that selects the color of status&exemode line */
6550d711 274static inline PropertiesLine prepare_s_e_line(LttvProcessState *process)
9a1ec01b 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
9a1ec01b 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
6550d711 318static inline PropertiesLine prepare_status_line(LttvProcessState *process)
c8bba5fa 319{
320 PropertiesLine prop_line;
321 prop_line.line_width = 2;
322 prop_line.style = GDK_LINE_SOLID;
e800cf84 323 prop_line.y = MIDDLE;
324 //GdkColormap *colormap = gdk_colormap_get_system();
c8bba5fa 325
23093869 326 g_debug("prepare_status_line for state : %s",
327 g_quark_to_string(process->state->s));
c8bba5fa 328
329 /* color of line : status of the process */
330 if(process->state->s == LTTV_STATE_UNNAMED)
e800cf84 331 prop_line.color = drawing_colors[COL_WHITE];
c8bba5fa 332 else if(process->state->s == LTTV_STATE_WAIT_FORK)
e800cf84 333 prop_line.color = drawing_colors[COL_WAIT_FORK];
c8bba5fa 334 else if(process->state->s == LTTV_STATE_WAIT_CPU)
e800cf84 335 prop_line.color = drawing_colors[COL_WAIT_CPU];
dbd243b1 336 else if(process->state->s == LTTV_STATE_EXIT)
337 prop_line.color = drawing_colors[COL_EXIT];
0828099d 338 else if(process->state->s == LTTV_STATE_ZOMBIE)
339 prop_line.color = drawing_colors[COL_ZOMBIE];
c8bba5fa 340 else if(process->state->s == LTTV_STATE_WAIT)
e800cf84 341 prop_line.color = drawing_colors[COL_WAIT];
c8bba5fa 342 else if(process->state->s == LTTV_STATE_RUN)
e800cf84 343 prop_line.color = drawing_colors[COL_RUN];
c8bba5fa 344 else
23093869 345 prop_line.color = drawing_colors[COL_WHITE];
e800cf84 346
347 //gdk_colormap_alloc_color(colormap,
348 // prop_line.color,
349 // FALSE,
350 // TRUE);
c8bba5fa 351
352 return prop_line;
353
354}
9a1ec01b 355#endif //0
c8bba5fa 356
357
e92eabaf 358/* before_schedchange_hook
b9a010a2 359 *
f0d936c0 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 */
b9a010a2 374
375
e92eabaf 376int before_schedchange_hook(void *hook_data, void *call_data)
f0d936c0 377{
b9a010a2 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;
b9a010a2 384
385 LttEvent *e;
386 e = tfc->e;
387
388 LttTime evtime = ltt_event_time(e);
fd22065b 389
10a1069a 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 */
b9a010a2 394
10a1069a 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);
10a1069a 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;
40debf7b 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;
b9a010a2 419
10a1069a 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) */
1c736ed5 425 guint pl_height = 0;
10a1069a 426 HashedProcessData *hashed_process_data = NULL;
5c230fc4 427 ProcessList *process_list = control_flow_data->process_list;
10a1069a 428 LttTime birth = process->creation_time;
b9a010a2 429
ac4e21cf 430 hashed_process_data = processlist_get_process_data(process_list,
10a1069a 431 pid_out,
40debf7b 432 process->last_cpu_index,
10a1069a 433 &birth,
ac4e21cf 434 tfc->t_context->index);
435 if(hashed_process_data == NULL)
10a1069a 436 {
437 g_assert(pid_out == 0 || pid_out != process->ppid);
aac69e70 438 const gchar *name = g_quark_to_string(process->name);
10a1069a 439 /* Process not present */
4e86ae2e 440 ProcessInfo *process_info;
1c736ed5 441 Drawing_t *drawing = control_flow_data->drawing;
10a1069a 442 processlist_add(process_list,
1c736ed5 443 drawing,
10a1069a 444 pid_out,
40debf7b 445 process->last_cpu_index,
10a1069a 446 process->ppid,
447 &birth,
448 tfc->t_context->index,
449 name,
450 &pl_height,
4e86ae2e 451 &process_info,
10a1069a 452 &hashed_process_data);
1c736ed5 453 gtk_widget_set_size_request(drawing->drawing_area,
454 -1,
455 pl_height);
456 gtk_widget_queue_draw(drawing->drawing_area);
457
10a1069a 458 }
ac4e21cf 459
10a1069a 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 */
e800cf84 463
b2743953 464 if(ltt_time_compare(hashed_process_data->next_good_time,
465 evtime) > 0)
10a1069a 466 {
b2743953 467 if(hashed_process_data->x.middle_marked == FALSE) {
ac4e21cf 468
fd22065b 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
d6fef890 476 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 477 guint width = drawing->width;
b2743953 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]);
1c736ed5 487 gdk_draw_point(hashed_process_data->pixmap,
b2743953 488 drawing->gc,
489 x,
1c736ed5 490 (hashed_process_data->height/2)-3);
b2743953 491 hashed_process_data->x.middle_marked = TRUE;
492 }
493 } else {
ac4e21cf 494 TimeWindow time_window =
495 lttvwindow_get_time_window(control_flow_data->tab);
fd22065b 496#ifdef EXTRA_CHECK
ac4e21cf 497 if(ltt_time_compare(evtime, time_window.start_time) == -1
498 || ltt_time_compare(evtime, time_window.end_time) == 1)
499 return;
fd22065b 500#endif //EXTRA_CHECK
d6fef890 501 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 502 guint width = drawing->width;
10a1069a 503 guint x;
10a1069a 504 convert_time_to_pixels(
a18124ff 505 time_window,
4b7dc462 506 evtime,
507 width,
508 &x);
10a1069a 509
10a1069a 510
4b7dc462 511 /* Jump over draw if we are at the same x position */
e72908ed 512 if(x == hashed_process_data->x.middle &&
513 hashed_process_data->x.middle_used)
e800cf84 514 {
e72908ed 515 if(hashed_process_data->x.middle_marked == FALSE) {
516 /* Draw collision indicator */
517 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 518 gdk_draw_point(hashed_process_data->pixmap,
e72908ed 519 drawing->gc,
520 x,
1c736ed5 521 (hashed_process_data->height/2)-3);
de4ea1ad 522 hashed_process_data->x.middle_marked = TRUE;
e72908ed 523 }
4b7dc462 524 /* jump */
525 } else {
526 DrawContext draw_context;
10a1069a 527
4b7dc462 528 /* Now create the drawing context that will be used to draw
529 * items related to the last state. */
1c736ed5 530 draw_context.drawable = hashed_process_data->pixmap;
4b7dc462 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
1c736ed5 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;
4b7dc462 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 */
9a1ec01b 549 PropertiesLine prop_line = prepare_s_e_line(process);
4b7dc462 550 draw_line((void*)&prop_line, (void*)&draw_context);
551
552 }
553 /* become the last x position */
554 hashed_process_data->x.middle = x;
e72908ed 555 hashed_process_data->x.middle_used = TRUE;
556 hashed_process_data->x.middle_marked = FALSE;
b2743953 557
558 /* Calculate the next good time */
559 convert_pixels_to_time(width, x+1, time_window,
560 &hashed_process_data->next_good_time);
e800cf84 561 }
562 }
563 }
10a1069a 564 }
e800cf84 565
10a1069a 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) */
1c736ed5 581 guint pl_height = 0;
10a1069a 582 HashedProcessData *hashed_process_data = NULL;
5c230fc4 583 ProcessList *process_list = control_flow_data->process_list;
10a1069a 584 LttTime birth = process->creation_time;
e800cf84 585
ac4e21cf 586 hashed_process_data = processlist_get_process_data(process_list,
10a1069a 587 pid_in,
40debf7b 588 process->last_cpu_index,
10a1069a 589 &birth,
ac4e21cf 590 tfc->t_context->index);
591 if(hashed_process_data == NULL)
10a1069a 592 {
593 g_assert(pid_in == 0 || pid_in != process->ppid);
aac69e70 594 const gchar *name = g_quark_to_string(process->name);
10a1069a 595 /* Process not present */
4e86ae2e 596 ProcessInfo *process_info;
1c736ed5 597 Drawing_t *drawing = control_flow_data->drawing;
10a1069a 598 processlist_add(process_list,
1c736ed5 599 drawing,
10a1069a 600 pid_in,
40debf7b 601 process->last_cpu_index,
10a1069a 602 process->ppid,
603 &birth,
604 tfc->t_context->index,
605 name,
606 &pl_height,
4e86ae2e 607 &process_info,
10a1069a 608 &hashed_process_data);
1c736ed5 609 gtk_widget_set_size_request(drawing->drawing_area,
610 -1,
611 pl_height);
612 gtk_widget_queue_draw(drawing->drawing_area);
613
10a1069a 614 }
40debf7b 615 //We could set the current process and hash here, but will be done
616 //by after schedchange hook
10a1069a 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 */
b9a010a2 621
b2743953 622 if(ltt_time_compare(hashed_process_data->next_good_time,
623 evtime) > 0)
10a1069a 624 {
b2743953 625 if(hashed_process_data->x.middle_marked == FALSE) {
ac4e21cf 626
fd22065b 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
d6fef890 634 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 635 guint width = drawing->width;
b2743953 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]);
1c736ed5 645 gdk_draw_point(hashed_process_data->pixmap,
b2743953 646 drawing->gc,
647 x,
1c736ed5 648 (hashed_process_data->height/2)-3);
b2743953 649 hashed_process_data->x.middle_marked = TRUE;
650 }
651 } else {
fd22065b 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
d6fef890 659 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 660 guint width = drawing->width;
10a1069a 661 guint x;
10a1069a 662
663 convert_time_to_pixels(
a18124ff 664 time_window,
4b7dc462 665 evtime,
666 width,
667 &x);
10a1069a 668
10a1069a 669
4b7dc462 670 /* Jump over draw if we are at the same x position */
e72908ed 671 if(x == hashed_process_data->x.middle &&
672 hashed_process_data->x.middle_used)
4b7dc462 673 {
e72908ed 674 if(hashed_process_data->x.middle_marked == FALSE) {
675 /* Draw collision indicator */
676 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 677 gdk_draw_point(hashed_process_data->pixmap,
e72908ed 678 drawing->gc,
679 x,
1c736ed5 680 (hashed_process_data->height/2)-3);
de4ea1ad 681 hashed_process_data->x.middle_marked = TRUE;
e72908ed 682 }
4b7dc462 683 /* jump */
684 } else {
685 DrawContext draw_context;
10a1069a 686
4b7dc462 687 /* Now create the drawing context that will be used to draw
688 * items related to the last state. */
1c736ed5 689 draw_context.drawable = hashed_process_data->pixmap;
4b7dc462 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;
10a1069a 694
1c736ed5 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;
10a1069a 698
4b7dc462 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 */
9a1ec01b 708 PropertiesLine prop_line = prepare_s_e_line(process);
4b7dc462 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;
e72908ed 715 hashed_process_data->x.middle_used = TRUE;
716 hashed_process_data->x.middle_marked = FALSE;
b2743953 717
718 /* Calculate the next good time */
719 convert_pixels_to_time(width, x+1, time_window,
720 &hashed_process_data->next_good_time);
4b7dc462 721 }
c8bba5fa 722 }
b9a010a2 723 }
724 }
b9a010a2 725 return 0;
726
727
b9a010a2 728#if 0
ca0f8a8e 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;
e9a9c513 733
a56a1ba4 734 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
e9a9c513 735
736 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1aff52a2 737 LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context;
a56a1ba4 738
e9a9c513 739 LttEvent *e;
e9a9c513 740 e = tfc->e;
741
9444deae 742 LttTime evtime = ltt_event_time(e);
ca0f8a8e 743 TimeWindow time_window =
744 lttvwindow_get_time_window(tab);
9444deae 745
a2aab3a3 746 LttTime time_window.end_time = time_window.time_window.end_time;
6f26fc38 747
9444deae 748 //if(time < time_beg || time > time_end) return;
ca0f8a8e 749 if(ltt_time_compare(evtime, time_window.start_time) == -1
a2aab3a3 750 || ltt_time_compare(evtime, time_window.end_time) == 1)
9444deae 751 return;
752
a56a1ba4 753 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
754 {
2a2fa4f0 755 g_debug("schedchange!");
a56a1ba4 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
5c230fc4 764 ProcessList *process_list = control_flow_data->process_list;
a56a1ba4 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);
2a2fa4f0 773 g_debug("out : %u in : %u", pid_out, pid_in);
a56a1ba4 774
775
776 /* Find process pid_out in the list... */
87658614 777 process_out = lttv_state_find_process(tfs, pid_out);
1aff52a2 778 if(process_out == NULL) return 0;
2a2fa4f0 779 g_debug("out : %s",g_quark_to_string(process_out->state->s));
1aff52a2 780
a56a1ba4 781 birth = process_out->creation_time;
51705146 782 const gchar *name = g_quark_to_string(process_out->name);
14963be0 783 HashedProcessData *hashed_process_data_out = NULL;
a56a1ba4 784
785 if(processlist_get_process_pixels(process_list,
786 pid_out,
787 &birth,
d0cd7f09 788 tfc->t_context->index,
a56a1ba4 789 &y_out,
790 &height,
14963be0 791 &hashed_process_data_out) == 1)
a56a1ba4 792 {
51705146 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);
a56a1ba4 809 }
51705146 810 //g_free(name);
a56a1ba4 811
812 /* Find process pid_in in the list... */
87658614 813 process_in = lttv_state_find_process(tfs, pid_in);
1aff52a2 814 if(process_in == NULL) return 0;
2a2fa4f0 815 g_debug("in : %s",g_quark_to_string(process_in->state->s));
a56a1ba4 816
817 birth = process_in->creation_time;
51705146 818 name = g_quark_to_string(process_in->name);
14963be0 819 HashedProcessData *hashed_process_data_in = NULL;
a56a1ba4 820
821 if(processlist_get_process_pixels(process_list,
822 pid_in,
823 &birth,
d0cd7f09 824 tfc->t_context->index,
a56a1ba4 825 &y_in,
826 &height,
14963be0 827 &hashed_process_data_in) == 1)
a56a1ba4 828 {
51705146 829 /* Process not present */
a56a1ba4 830 processlist_add(process_list,
831 pid_in,
832 &birth,
d0cd7f09 833 tfc->t_context->index,
a56a1ba4 834 name,
835 &pl_height,
14963be0 836 &hashed_process_data_in);
a56a1ba4 837 processlist_get_process_pixels(process_list,
838 pid_in,
839 &birth,
d0cd7f09 840 tfc->t_context->index,
a56a1ba4 841 &y_in,
842 &height,
14963be0 843 &hashed_process_data_in);
a56a1ba4 844
ca0f8a8e 845 drawing_insert_square( control_flow_data->drawing, y_in, height);
a56a1ba4 846 }
51705146 847 //g_free(name);
a56a1ba4 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;
51705146 853 guint width = control_flow_data->drawing->width;
a56a1ba4 854
855 LttTime time = ltt_event_time(e);
856
a2aab3a3 857 LttTime window_end = time_window.time_window.end_time;
a56a1ba4 858
859 convert_time_to_pixels(
a18124ff 860 time_window,
a56a1ba4 861 time,
862 width,
863 &x);
9444deae 864 //assert(x <= width);
51705146 865 //
a56a1ba4 866 /* draw what represents the event for outgoing process. */
867
14963be0 868 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
68997a22 869 draw_context_out->current->modify_over->x = x;
319e9d81 870 draw_context_out->current->modify_under->x = x;
68997a22 871 draw_context_out->current->modify_over->y = y_out;
319e9d81 872 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
501d5405 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;
a56a1ba4 876 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
d0cd7f09 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);
a56a1ba4 879 //draw_context_out->gc = widget->style->black_gc;
880
881 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
501d5405 882 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
a56a1ba4 883
d0cd7f09 884 /* Draw the line/background of the out process */
885 if(draw_context_out->previous->middle->x == -1)
886 {
ca0f8a8e 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;
ca0f8a8e 893 g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin);
d0cd7f09 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 {
51705146 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;
d0cd7f09 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
2a2fa4f0 945 g_debug("calling from draw_event");
d0cd7f09 946 draw_bg((void*)&prop_bg, (void*)draw_context_out);
947 g_free(prop_bg.color);
51705146 948 //gdk_gc_unref(draw_context_out->gc);
d0cd7f09 949 }
950
951 draw_context_out->gc = widget->style->black_gc;
952
a56a1ba4 953 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
2df6f2bd 954 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 955 PropertiesText prop_text_out;
956 prop_text_out.foreground = &colorfg_out;
957 prop_text_out.background = &colorbg_out;
cfe526b1 958 prop_text_out.size = 6;
a56a1ba4 959 prop_text_out.position = OVER;
960
cfe526b1 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;
d52cfc84 971 prop_text_out.foreground->green = 0xffff;
972 prop_text_out.foreground->blue = 0xfff0;
cfe526b1 973 }
974 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
975 {
2df6f2bd 976 prop_text_out.foreground->red = 0xffff;
977 prop_text_out.foreground->green = 0xffff;
cfe526b1 978 prop_text_out.foreground->blue = 0x0000;
979 }
0828099d 980 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 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
d52cfc84 1005
a56a1ba4 1006 /* Print status of the process : U, WF, WC, E, W, R */
1007 if(process_out->state->s == LTTV_STATE_UNNAMED)
cfe526b1 1008 prop_text_out.text = "U->";
a56a1ba4 1009 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
cfe526b1 1010 prop_text_out.text = "WF->";
a56a1ba4 1011 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
cfe526b1 1012 prop_text_out.text = "WC->";
0828099d 1013 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 1014 prop_text_out.text = "E->";
a56a1ba4 1015 else if(process_out->state->s == LTTV_STATE_WAIT)
cfe526b1 1016 prop_text_out.text = "W->";
a56a1ba4 1017 else if(process_out->state->s == LTTV_STATE_RUN)
cfe526b1 1018 prop_text_out.text = "R->";
a56a1ba4 1019 else
68997a22 1020 prop_text_out.text = "U";
a56a1ba4 1021
1022 draw_text((void*)&prop_text_out, (void*)draw_context_out);
d0cd7f09 1023 //gdk_gc_unref(draw_context_out->gc);
a56a1ba4 1024
51705146 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;
a56a1ba4 1028
1029 PropertiesLine prop_line_out;
1030 prop_line_out.color = g_new(GdkColor,1);
cfe526b1 1031 prop_line_out.line_width = 2;
a56a1ba4 1032 prop_line_out.style = GDK_LINE_SOLID;
1033 prop_line_out.position = MIDDLE;
d52cfc84 1034
2a2fa4f0 1035 g_debug("out state : %s", g_quark_to_string(process_out->state->s));
a56a1ba4 1036
1037 /* color of line : status of the process */
1038 if(process_out->state->s == LTTV_STATE_UNNAMED)
1039 {
cfe526b1 1040 prop_line_out.color->red = 0xffff;
1041 prop_line_out.color->green = 0xffff;
1042 prop_line_out.color->blue = 0xffff;
a56a1ba4 1043 }
1044 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
1045 {
1046 prop_line_out.color->red = 0x0fff;
d52cfc84 1047 prop_line_out.color->green = 0xffff;
1048 prop_line_out.color->blue = 0xfff0;
a56a1ba4 1049 }
1050 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
1051 {
2df6f2bd 1052 prop_line_out.color->red = 0xffff;
1053 prop_line_out.color->green = 0xffff;
a56a1ba4 1054 prop_line_out.color->blue = 0x0000;
1055 }
0828099d 1056 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
a56a1ba4 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 {
cfe526b1 1076 prop_line_out.color->red = 0xffff;
1077 prop_line_out.color->green = 0xffff;
1078 prop_line_out.color->blue = 0xffff;
a56a1ba4 1079 }
1080
1081 draw_line((void*)&prop_line_out, (void*)draw_context_out);
1082 g_free(prop_line_out.color);
51705146 1083 //gdk_gc_unref(draw_context_out->gc);
a56a1ba4 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
14963be0 1088 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
68997a22 1089 draw_context_in->current->modify_over->x = x;
319e9d81 1090 draw_context_in->current->modify_under->x = x;
68997a22 1091 draw_context_in->current->modify_over->y = y_in;
319e9d81 1092 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
501d5405 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;
a56a1ba4 1096 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
1097 //draw_context_in->gc = widget->style->black_gc;
d0cd7f09 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);
a56a1ba4 1100
1101 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
501d5405 1102 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 1103
1104 /* Draw the line/bg of the in process */
1105 if(draw_context_in->previous->middle->x == -1)
1106 {
ca0f8a8e 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
d0cd7f09 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;
a56a1ba4 1127
d0cd7f09 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 {
51705146 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;
d0cd7f09 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);
51705146 1171 //gdk_gc_unref(draw_context_in->gc);
d0cd7f09 1172 }
1173
1174 draw_context_in->gc = widget->style->black_gc;
1175
a56a1ba4 1176 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
2df6f2bd 1177 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 1178 PropertiesText prop_text_in;
1179 prop_text_in.foreground = &colorfg_in;
1180 prop_text_in.background = &colorbg_in;
cfe526b1 1181 prop_text_in.size = 6;
a56a1ba4 1182 prop_text_in.position = OVER;
1183
2a2fa4f0 1184 g_debug("in state : %s", g_quark_to_string(process_in->state->s));
cfe526b1 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;
d52cfc84 1195 prop_text_in.foreground->green = 0xffff;
1196 prop_text_in.foreground->blue = 0xfff0;
cfe526b1 1197 }
1198 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1199 {
2df6f2bd 1200 prop_text_in.foreground->red = 0xffff;
1201 prop_text_in.foreground->green = 0xffff;
cfe526b1 1202 prop_text_in.foreground->blue = 0x0000;
1203 }
0828099d 1204 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 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
a56a1ba4 1231 /* Print status of the process : U, WF, WC, E, W, R */
1232 if(process_in->state->s == LTTV_STATE_UNNAMED)
cfe526b1 1233 prop_text_in.text = "U->";
a56a1ba4 1234 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
cfe526b1 1235 prop_text_in.text = "WF->";
a56a1ba4 1236 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
cfe526b1 1237 prop_text_in.text = "WC->";
0828099d 1238 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 1239 prop_text_in.text = "E->";
a56a1ba4 1240 else if(process_in->state->s == LTTV_STATE_WAIT)
cfe526b1 1241 prop_text_in.text = "W->";
a56a1ba4 1242 else if(process_in->state->s == LTTV_STATE_RUN)
cfe526b1 1243 prop_text_in.text = "R->";
a56a1ba4 1244 else
68997a22 1245 prop_text_in.text = "U";
a56a1ba4 1246
1247 draw_text((void*)&prop_text_in, (void*)draw_context_in);
d0cd7f09 1248 //gdk_gc_unref(draw_context_in->gc);
1249
51705146 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;
d0cd7f09 1253
a56a1ba4 1254 PropertiesLine prop_line_in;
1255 prop_line_in.color = g_new(GdkColor,1);
cfe526b1 1256 prop_line_in.line_width = 2;
a56a1ba4 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 {
cfe526b1 1263 prop_line_in.color->red = 0xffff;
1264 prop_line_in.color->green = 0xffff;
1265 prop_line_in.color->blue = 0xffff;
a56a1ba4 1266 }
1267 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
1268 {
1269 prop_line_in.color->red = 0x0fff;
d52cfc84 1270 prop_line_in.color->green = 0xffff;
1271 prop_line_in.color->blue = 0xfff0;
a56a1ba4 1272 }
1273 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1274 {
2df6f2bd 1275 prop_line_in.color->red = 0xffff;
1276 prop_line_in.color->green = 0xffff;
a56a1ba4 1277 prop_line_in.color->blue = 0x0000;
1278 }
0828099d 1279 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
a56a1ba4 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 {
cfe526b1 1299 prop_line_in.color->red = 0xffff;
1300 prop_line_in.color->green = 0xffff;
1301 prop_line_in.color->blue = 0xffff;
a56a1ba4 1302 }
1303
1304 draw_line((void*)&prop_line_in, (void*)draw_context_in);
1305 g_free(prop_line_in.color);
51705146 1306 //gdk_gc_unref(draw_context_in->gc);
a56a1ba4 1307 }
1308
1309 return 0;
b9a010a2 1310#endif //0
1311
1312
a56a1ba4 1313
51705146 1314 /* Text dump */
80a52ff8 1315#ifdef DONTSHOW
a56a1ba4 1316 GString *string = g_string_new("");;
1317 gboolean field_names = TRUE, state = TRUE;
80a52ff8 1318
e9a9c513 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
a56a1ba4 1329 g_string_free(string, TRUE);
1330
1331 /* End of text dump */
80a52ff8 1332#endif //DONTSHOW
50439712 1333
f0d936c0 1334}
1335
e92eabaf 1336/* after_schedchange_hook
b9a010a2 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 */
e92eabaf 1346int after_schedchange_hook(void *hook_data, void *call_data)
f0d936c0 1347{
ca0f8a8e 1348 EventsRequest *events_request = (EventsRequest*)hook_data;
1349 ControlFlowData *control_flow_data = events_request->viewer_data;
50439712 1350
a56a1ba4 1351 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
50439712 1352
1353 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1354
b9a010a2 1355 LttEvent *e;
1356 e = tfc->e;
1357
1358 LttTime evtime = ltt_event_time(e);
b9a010a2 1359
10a1069a 1360 /* Add process to process list (if not present) */
2eef04b5 1361 LttvProcessState *process_in;
10a1069a 1362 LttTime birth;
1c736ed5 1363 guint pl_height = 0;
10a1069a 1364 HashedProcessData *hashed_process_data_in = NULL;
b9a010a2 1365
5c230fc4 1366 ProcessList *process_list = control_flow_data->process_list;
10a1069a 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);
10a1069a 1377 }
b9a010a2 1378
1379
10a1069a 1380 /* Find process pid_in in the list... */
40debf7b 1381 //process_in = lttv_state_find_process(tfs, pid_in);
1382 process_in = tfs->process;
10a1069a 1383 /* It should exist, because we are after the state update. */
96947fcf 1384#ifdef EXTRA_CHECK
10a1069a 1385 g_assert(process_in != NULL);
96947fcf 1386#endif //EXTRA_CHECK
10a1069a 1387 birth = process_in->creation_time;
b9a010a2 1388
ac4e21cf 1389 hashed_process_data_in = processlist_get_process_data(process_list,
10a1069a 1390 pid_in,
40debf7b 1391 process_in->last_cpu_index,
10a1069a 1392 &birth,
ac4e21cf 1393 tfc->t_context->index);
1394 if(hashed_process_data_in == NULL)
10a1069a 1395 {
1396 g_assert(pid_in == 0 || pid_in != process_in->ppid);
aac69e70 1397 const gchar *name = g_quark_to_string(process_in->name);
4e86ae2e 1398 ProcessInfo *process_info;
1c736ed5 1399 Drawing_t *drawing = control_flow_data->drawing;
10a1069a 1400 /* Process not present */
1401 processlist_add(process_list,
1c736ed5 1402 drawing,
10a1069a 1403 pid_in,
40debf7b 1404 process_in->last_cpu_index,
10a1069a 1405 process_in->ppid,
1406 &birth,
1407 tfc->t_context->index,
1408 name,
1409 &pl_height,
4e86ae2e 1410 &process_info,
10a1069a 1411 &hashed_process_data_in);
1c736ed5 1412 gtk_widget_set_size_request(drawing->drawing_area,
1413 -1,
1414 pl_height);
1415 gtk_widget_queue_draw(drawing->drawing_area);
b9a010a2 1416 }
40debf7b 1417 /* Set the current process */
1418 process_list->current_hash_data[process_in->last_cpu_index] =
1419 hashed_process_data_in;
10a1069a 1420
b2743953 1421 if(ltt_time_compare(hashed_process_data_in->next_good_time,
1422 evtime) <= 0)
1423 {
fd22065b 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
d6fef890 1432 Drawing_t *drawing = control_flow_data->drawing;
1433 guint width = drawing->width;
b2743953 1434 guint new_x;
1435
1436 convert_time_to_pixels(
1437 time_window,
1438 evtime,
1439 width,
1440 &new_x);
e72908ed 1441
b2743953 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 }
b9a010a2 1448 return 0;
1449
1450
1451
e72908ed 1452
1453
b9a010a2 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
a56a1ba4 1463
50439712 1464 LttEvent *e;
1465 e = tfc->e;
1466
9444deae 1467 LttTime evtime = ltt_event_time(e);
ca0f8a8e 1468 TimeWindow time_window =
1469 lttvwindow_get_time_window(control_flow_data->tab);
9444deae 1470
a2aab3a3 1471 LttTime time_window.end_time = time_window.time_window.end_time;
6f26fc38 1472
9444deae 1473 //if(time < time_beg || time > time_end) return;
ca0f8a8e 1474 if(ltt_time_compare(evtime, time_window.start_time) == -1
a2aab3a3 1475 || ltt_time_compare(evtime, time_window.end_time) == 1)
9444deae 1476 return;
1477
1478
a56a1ba4 1479 if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0)
1480 {
2a2fa4f0 1481 g_debug("schedchange!");
a56a1ba4 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
5c230fc4 1490 ProcessList *process_list = control_flow_data->process_list;
a56a1ba4 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);
2a2fa4f0 1499 //g_debug("out : %u in : %u", pid_out, pid_in);
a56a1ba4 1500
1501
1502 /* Find process pid_out in the list... */
2a2fa4f0 1503 process_out = lttv_state_find_process(tfs, pid_out);
1aff52a2 1504 if(process_out == NULL) return 0;
2a2fa4f0 1505 //g_debug("out : %s",g_quark_to_string(process_out->state->s));
a56a1ba4 1506
1507 birth = process_out->creation_time;
1508 gchar *name = strdup(g_quark_to_string(process_out->name));
14963be0 1509 HashedProcessData *hashed_process_data_out = NULL;
a56a1ba4 1510
1511 if(processlist_get_process_pixels(process_list,
1512 pid_out,
1513 &birth,
d0cd7f09 1514 tfc->t_context->index,
a56a1ba4 1515 &y_out,
1516 &height,
14963be0 1517 &hashed_process_data_out) == 1)
a56a1ba4 1518 {
51705146 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);
a56a1ba4 1535 }
1536
1537 g_free(name);
1538
1539 /* Find process pid_in in the list... */
2a2fa4f0 1540 process_in = lttv_state_find_process(tfs, pid_in);
1aff52a2 1541 if(process_in == NULL) return 0;
2a2fa4f0 1542 //g_debug("in : %s",g_quark_to_string(process_in->state->s));
a56a1ba4 1543
1544 birth = process_in->creation_time;
1545 name = strdup(g_quark_to_string(process_in->name));
14963be0 1546 HashedProcessData *hashed_process_data_in = NULL;
a56a1ba4 1547
1548 if(processlist_get_process_pixels(process_list,
1549 pid_in,
1550 &birth,
d0cd7f09 1551 tfc->t_context->index,
a56a1ba4 1552 &y_in,
1553 &height,
14963be0 1554 &hashed_process_data_in) == 1)
a56a1ba4 1555 {
1556 /* Process not present */
1557 processlist_add(process_list,
1558 pid_in,
1559 &birth,
d0cd7f09 1560 tfc->t_context->index,
a56a1ba4 1561 name,
1562 &pl_height,
14963be0 1563 &hashed_process_data_in);
a56a1ba4 1564 processlist_get_process_pixels(process_list,
1565 pid_in,
1566 &birth,
d0cd7f09 1567 tfc->t_context->index,
a56a1ba4 1568 &y_in,
1569 &height,
14963be0 1570 &hashed_process_data_in);
a56a1ba4 1571
ca0f8a8e 1572 drawing_insert_square( control_flow_data->drawing, y_in, height);
a56a1ba4 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;
501d5405 1580 //guint width = control_flow_data->drawing->drawing_area->allocation.width;
a56a1ba4 1581
1582 //LttTime time = ltt_event_time(e);
1583
a2aab3a3 1584 //LttTime window_end = time_window->time_window.end_time;
a56a1ba4 1585
1586
1587 //convert_time_to_pixels(
a18124ff 1588 // *time_window,
a56a1ba4 1589 // time,
1590 // width,
1591 // &x);
1592
1593 //assert(x <= width);
1594
1595 /* draw what represents the event for outgoing process. */
1596
14963be0 1597 DrawContext *draw_context_out = hashed_process_data_out->draw_context;
68997a22 1598 //draw_context_out->current->modify_over->x = x;
1599 draw_context_out->current->modify_over->y = y_out;
319e9d81 1600 draw_context_out->current->modify_under->y = y_out+(height/2)+2;
501d5405 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;
a56a1ba4 1604 //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
d0cd7f09 1605
a56a1ba4 1606 //draw_arc((void*)&prop_arc, (void*)draw_context_out);
501d5405 1607 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 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
a56a1ba4 1627 GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 };
2df6f2bd 1628 GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 1629 PropertiesText prop_text_out;
1630 prop_text_out.foreground = &colorfg_out;
1631 prop_text_out.background = &colorbg_out;
cfe526b1 1632 prop_text_out.size = 6;
a56a1ba4 1633 prop_text_out.position = OVER;
1634
cfe526b1 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;
d52cfc84 1645 prop_text_out.foreground->green = 0xffff;
1646 prop_text_out.foreground->blue = 0xfff0;
cfe526b1 1647 }
1648 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
1649 {
2df6f2bd 1650 prop_text_out.foreground->red = 0xffff;
1651 prop_text_out.foreground->green = 0xffff;
cfe526b1 1652 prop_text_out.foreground->blue = 0x0000;
1653 }
0828099d 1654 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 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
a56a1ba4 1679 /* Print status of the process : U, WF, WC, E, W, R */
1680 if(process_out->state->s == LTTV_STATE_UNNAMED)
68997a22 1681 prop_text_out.text = "U";
a56a1ba4 1682 else if(process_out->state->s == LTTV_STATE_WAIT_FORK)
68997a22 1683 prop_text_out.text = "WF";
a56a1ba4 1684 else if(process_out->state->s == LTTV_STATE_WAIT_CPU)
68997a22 1685 prop_text_out.text = "WC";
0828099d 1686 else if(process_out->state->s == LTTV_STATE_ZOMBIE)
68997a22 1687 prop_text_out.text = "E";
a56a1ba4 1688 else if(process_out->state->s == LTTV_STATE_WAIT)
68997a22 1689 prop_text_out.text = "W";
a56a1ba4 1690 else if(process_out->state->s == LTTV_STATE_RUN)
68997a22 1691 prop_text_out.text = "R";
a56a1ba4 1692 else
68997a22 1693 prop_text_out.text = "U";
a56a1ba4 1694
1695 draw_text((void*)&prop_text_out, (void*)draw_context_out);
d0cd7f09 1696
1697 //gdk_gc_unref(draw_context_out->gc);
319e9d81 1698
68997a22 1699 draw_context_out->current->middle->y = y_out+height/2;
d0cd7f09 1700 draw_context_out->current->over->y = y_out;
1701 draw_context_out->current->under->y = y_out+height;
68997a22 1702 draw_context_out->current->status = process_out->state->s;
a56a1ba4 1703
68997a22 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;
a56a1ba4 1714
68997a22 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;
a56a1ba4 1735
1736 /* Finally, update the drawing context of the pid_in. */
1737
14963be0 1738 DrawContext *draw_context_in = hashed_process_data_in->draw_context;
68997a22 1739 //draw_context_in->current->modify_over->x = x;
1740 draw_context_in->current->modify_over->y = y_in;
319e9d81 1741 draw_context_in->current->modify_under->y = y_in+(height/2)+2;
501d5405 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;
a56a1ba4 1745 //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)];
a56a1ba4 1746
1747 //draw_arc((void*)&prop_arc, (void*)draw_context_in);
501d5405 1748 //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap);
d0cd7f09 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
a56a1ba4 1768 GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 };
2df6f2bd 1769 GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 };
a56a1ba4 1770 PropertiesText prop_text_in;
1771 prop_text_in.foreground = &colorfg_in;
1772 prop_text_in.background = &colorbg_in;
cfe526b1 1773 prop_text_in.size = 6;
a56a1ba4 1774 prop_text_in.position = OVER;
1775
cfe526b1 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;
d52cfc84 1786 prop_text_in.foreground->green = 0xffff;
1787 prop_text_in.foreground->blue = 0xfff0;
cfe526b1 1788 }
1789 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
1790 {
2df6f2bd 1791 prop_text_in.foreground->red = 0xffff;
1792 prop_text_in.foreground->green = 0xffff;
cfe526b1 1793 prop_text_in.foreground->blue = 0x0000;
1794 }
0828099d 1795 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
cfe526b1 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
a56a1ba4 1821 /* Print status of the process : U, WF, WC, E, W, R */
1822 if(process_in->state->s == LTTV_STATE_UNNAMED)
68997a22 1823 prop_text_in.text = "U";
a56a1ba4 1824 else if(process_in->state->s == LTTV_STATE_WAIT_FORK)
68997a22 1825 prop_text_in.text = "WF";
a56a1ba4 1826 else if(process_in->state->s == LTTV_STATE_WAIT_CPU)
68997a22 1827 prop_text_in.text = "WC";
0828099d 1828 else if(process_in->state->s == LTTV_STATE_ZOMBIE)
68997a22 1829 prop_text_in.text = "E";
a56a1ba4 1830 else if(process_in->state->s == LTTV_STATE_WAIT)
68997a22 1831 prop_text_in.text = "W";
a56a1ba4 1832 else if(process_in->state->s == LTTV_STATE_RUN)
68997a22 1833 prop_text_in.text = "R";
a56a1ba4 1834 else
68997a22 1835 prop_text_in.text = "U";
a56a1ba4 1836
1837 draw_text((void*)&prop_text_in, (void*)draw_context_in);
1838
d0cd7f09 1839
319e9d81 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
68997a22 1861 draw_context_in->current->middle->y = y_in+height/2;
d0cd7f09 1862 draw_context_in->current->over->y = y_in;
1863 draw_context_in->current->under->y = y_in+height;
68997a22 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;
a56a1ba4 1876
68997a22 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;
a56a1ba4 1897
1898 }
1899
1900 return 0;
b9a010a2 1901#endif //0
f0d936c0 1902}
f7afe191 1903
9a1ec01b 1904#if 0
6550d711 1905static inline PropertiesLine prepare_execmode_line(LttvProcessState *process)
23093869 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}
9a1ec01b 1935#endif //0
23093869 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
1956int 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;
23093869 1960
1961 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1962
1963 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
23093869 1964
1965 LttEvent *e;
1966 e = tfc->e;
1967
1968 LttTime evtime = ltt_event_time(e);
23093869 1969
10a1069a 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);
23093869 1977
10a1069a 1978 guint pid = process->pid;
23093869 1979
10a1069a 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) */
1c736ed5 1984 guint pl_height = 0;
10a1069a 1985 HashedProcessData *hashed_process_data = NULL;
5c230fc4 1986 ProcessList *process_list = control_flow_data->process_list;
10a1069a 1987 LttTime birth = process->creation_time;
40debf7b 1988
1d1df11d 1989 if(likely(process_list->current_hash_data[tfc->index] != NULL)) {
40debf7b 1990 hashed_process_data = process_list->current_hash_data[tfc->index];
40debf7b 1991 } else {
ac4e21cf 1992 hashed_process_data = processlist_get_process_data(process_list,
40debf7b 1993 pid,
1994 process->last_cpu_index,
1995 &birth,
ac4e21cf 1996 tfc->t_context->index);
1d1df11d 1997 if(unlikely(hashed_process_data == NULL))
40debf7b 1998 {
1999 g_assert(pid == 0 || pid != process->ppid);
2000 ProcessInfo *process_info;
2001 /* Process not present */
1c736ed5 2002 Drawing_t *drawing = control_flow_data->drawing;
40debf7b 2003 const gchar *name = g_quark_to_string(process->name);
2004 processlist_add(process_list,
1c736ed5 2005 drawing,
40debf7b 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);
1c736ed5 2015 gtk_widget_set_size_request(drawing->drawing_area,
2016 -1,
2017 pl_height);
2018 gtk_widget_queue_draw(drawing->drawing_area);
40debf7b 2019 }
2020 /* Set the current process */
2021 process_list->current_hash_data[process->last_cpu_index] =
2022 hashed_process_data;
10a1069a 2023 }
23093869 2024
10a1069a 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 */
b2743953 2028
1d1df11d 2029 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
2030 evtime) > 0))
10a1069a 2031 {
1d1df11d 2032 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
fd22065b 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
d6fef890 2041 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 2042 guint width = drawing->width;
b2743953 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]);
1c736ed5 2052 gdk_draw_point(hashed_process_data->pixmap,
b2743953 2053 drawing->gc,
2054 x,
1c736ed5 2055 (hashed_process_data->height/2)-3);
b2743953 2056 hashed_process_data->x.middle_marked = TRUE;
2057 }
2058 } else {
fd22065b 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
d6fef890 2067 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 2068 guint width = drawing->width;
10a1069a 2069 guint x;
dbd243b1 2070
10a1069a 2071 convert_time_to_pixels(
a18124ff 2072 time_window,
10a1069a 2073 evtime,
2074 width,
2075 &x);
dbd243b1 2076
23093869 2077
4b7dc462 2078 /* Jump over draw if we are at the same x position */
1d1df11d 2079 if(unlikely(x == hashed_process_data->x.middle &&
2080 hashed_process_data->x.middle_used))
10a1069a 2081 {
1d1df11d 2082 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
e72908ed 2083 /* Draw collision indicator */
2084 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 2085 gdk_draw_point(hashed_process_data->pixmap,
e72908ed 2086 drawing->gc,
2087 x,
1c736ed5 2088 (hashed_process_data->height/2)-3);
de4ea1ad 2089 hashed_process_data->x.middle_marked = TRUE;
e72908ed 2090 }
4b7dc462 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. */
1c736ed5 2097 draw_context.drawable = hashed_process_data->pixmap;
4b7dc462 2098 draw_context.gc = drawing->gc;
2099 draw_context.pango_layout = drawing->pango_layout;
9a1ec01b 2100 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
4b7dc462 2101 draw_context.drawinfo.end.x = x;
2102
1c736ed5 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;
4b7dc462 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 */
9a1ec01b 2116 PropertiesLine prop_line = prepare_s_e_line(process);
4b7dc462 2117 draw_line((void*)&prop_line, (void*)&draw_context);
23093869 2118
4b7dc462 2119 }
2120 /* become the last x position */
9a1ec01b 2121 hashed_process_data->x.middle = x;
e72908ed 2122 hashed_process_data->x.middle_used = TRUE;
2123 hashed_process_data->x.middle_marked = FALSE;
b2743953 2124
2125 /* Calculate the next good time */
2126 convert_pixels_to_time(width, x+1, time_window,
2127 &hashed_process_data->next_good_time);
23093869 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 */
2144int after_execmode_hook(void *hook_data, void *call_data)
2145{
8869ac08 2146 /**************** DOES NOTHING!! *************/
2147 /* hook desactivated in drawing.c */
2148 return 0;
2149
2150
2151
23093869 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;
23093869 2158
2159 LttEvent *e;
2160 e = tfc->e;
2161
2162 LttTime evtime = ltt_event_time(e);
23093869 2163
10a1069a 2164 /* Add process to process list (if not present) */
2165 LttvProcessState *process;
2166 LttTime birth;
1c736ed5 2167 guint pl_height = 0;
10a1069a 2168 HashedProcessData *hashed_process_data = NULL;
23093869 2169
5c230fc4 2170 ProcessList *process_list = control_flow_data->process_list;
23093869 2171
10a1069a 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);
23093869 2176
10a1069a 2177 guint pid = process->pid;
23093869 2178
10a1069a 2179 birth = process->creation_time;
23093869 2180
1d1df11d 2181 if(likely(process_list->current_hash_data[tfc->index] != NULL)) {
40debf7b 2182 hashed_process_data = process_list->current_hash_data[tfc->index];
40debf7b 2183 } else {
ac4e21cf 2184 hashed_process_data = processlist_get_process_data(process_list,
40debf7b 2185 pid,
2186 process->last_cpu_index,
2187 &birth,
ac4e21cf 2188 tfc->t_context->index);
1d1df11d 2189 if(unlikely(hashed_process_data == NULL))
40debf7b 2190 {
2191 g_assert(pid == 0 || pid != process->ppid);
2192 /* Process not present */
1c736ed5 2193 Drawing_t *drawing = control_flow_data->drawing;
40debf7b 2194 const gchar *name = g_quark_to_string(process->name);
2195 ProcessInfo *process_info;
2196 processlist_add(process_list,
1c736ed5 2197 drawing,
40debf7b 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);
1c736ed5 2207 gtk_widget_set_size_request(drawing->drawing_area,
2208 -1,
2209 pl_height);
2210 gtk_widget_queue_draw(drawing->drawing_area);
40debf7b 2211 }
2212 /* Set the current process */
2213 process_list->current_hash_data[process->last_cpu_index] =
2214 hashed_process_data;
23093869 2215 }
40debf7b 2216
1d1df11d 2217 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
2218 evtime) <= 0))
b2743953 2219 {
fd22065b 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
d6fef890 2228 Drawing_t *drawing = control_flow_data->drawing;
2229 guint width = drawing->width;
b2743953 2230 guint new_x;
2231
2232 convert_time_to_pixels(
2233 time_window,
2234 evtime,
2235 width,
2236 &new_x);
e72908ed 2237
b2743953 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 }
23093869 2244 return 0;
2245}
2246
2247
dbd243b1 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 */
2259int 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;
dbd243b1 2263
2264 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2265
2266 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
dbd243b1 2267
2268 LttEvent *e;
2269 e = tfc->e;
2270
2271 LttTime evtime = ltt_event_time(e);
dbd243b1 2272
10a1069a 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 }
dbd243b1 2280
10a1069a 2281 if(sub_id == 3) { /* exit */
dbd243b1 2282
10a1069a 2283 /* Add process to process list (if not present) */
2284 LttvProcessState *process = tfs->process;
2285 guint pid = process->pid;
2286 LttTime birth;
1c736ed5 2287 guint pl_height = 0;
10a1069a 2288 HashedProcessData *hashed_process_data = NULL;
dbd243b1 2289
5c230fc4 2290 ProcessList *process_list = control_flow_data->process_list;
10a1069a 2291
2292 g_assert(process != NULL);
dbd243b1 2293
10a1069a 2294 birth = process->creation_time;
dbd243b1 2295
1d1df11d 2296 if(likely(process_list->current_hash_data[tfc->index] != NULL)) {
40debf7b 2297 hashed_process_data = process_list->current_hash_data[tfc->index];
ac4e21cf 2298 } else {
2299 hashed_process_data = processlist_get_process_data(process_list,
10a1069a 2300 pid,
40debf7b 2301 process->last_cpu_index,
10a1069a 2302 &birth,
ac4e21cf 2303 tfc->t_context->index);
1d1df11d 2304 if(unlikely(hashed_process_data == NULL))
ac4e21cf 2305 {
2306 g_assert(pid == 0 || pid != process->ppid);
2307 /* Process not present */
1c736ed5 2308 Drawing_t *drawing = control_flow_data->drawing;
ac4e21cf 2309 const gchar *name = g_quark_to_string(process->name);
2310 ProcessInfo *process_info;
2311 processlist_add(process_list,
1c736ed5 2312 drawing,
ac4e21cf 2313 pid,
2314 process->last_cpu_index,
2315 process->ppid,
2316 &birth,
10a1069a 2317 tfc->t_context->index,
ac4e21cf 2318 name,
2319 &pl_height,
2320 &process_info,
2321 &hashed_process_data);
1c736ed5 2322 gtk_widget_set_size_request(drawing->drawing_area,
2323 -1,
2324 pl_height);
2325 gtk_widget_queue_draw(drawing->drawing_area);
ac4e21cf 2326 }
10a1069a 2327 }
dbd243b1 2328
10a1069a 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
1d1df11d 2333 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
2334 evtime) > 0))
10a1069a 2335 {
1d1df11d 2336 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
fd22065b 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
d6fef890 2345 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 2346 guint width = drawing->width;
b2743953 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]);
1c736ed5 2356 gdk_draw_point(hashed_process_data->pixmap,
b2743953 2357 drawing->gc,
2358 x,
1c736ed5 2359 (hashed_process_data->height/2)-3);
b2743953 2360 hashed_process_data->x.middle_marked = TRUE;
2361 }
2362 } else {
ac4e21cf 2363 TimeWindow time_window =
2364 lttvwindow_get_time_window(control_flow_data->tab);
fd22065b 2365
2366#ifdef EXTRA_CHECK
ac4e21cf 2367 if(ltt_time_compare(evtime, time_window.start_time) == -1
2368 || ltt_time_compare(evtime, time_window.end_time) == 1)
2369 return;
fd22065b 2370#endif //EXTRA_CHECK
d6fef890 2371 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 2372 guint width = drawing->width;
10a1069a 2373 guint x;
dbd243b1 2374
10a1069a 2375 convert_time_to_pixels(
a18124ff 2376 time_window,
10a1069a 2377 evtime,
2378 width,
2379 &x);
dbd243b1 2380
dbd243b1 2381
4b7dc462 2382 /* Jump over draw if we are at the same x position */
1d1df11d 2383 if(unlikely(x == hashed_process_data->x.middle &&
2384 hashed_process_data->x.middle_used))
e72908ed 2385 {
1d1df11d 2386 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
e72908ed 2387 /* Draw collision indicator */
2388 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 2389 gdk_draw_point(hashed_process_data->pixmap,
e72908ed 2390 drawing->gc,
2391 x,
1c736ed5 2392 (hashed_process_data->height/2)-3);
de4ea1ad 2393 hashed_process_data->x.middle_marked = TRUE;
e72908ed 2394 }
4b7dc462 2395 /* jump */
2396 } else {
2397 DrawContext draw_context;
dbd243b1 2398
4b7dc462 2399 /* Now create the drawing context that will be used to draw
2400 * items related to the last state. */
1c736ed5 2401 draw_context.drawable = hashed_process_data->pixmap;
4b7dc462 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;
dbd243b1 2406
1c736ed5 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;
4b7dc462 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;
dbd243b1 2417
4b7dc462 2418 {
2419 /* Draw the line */
9a1ec01b 2420 PropertiesLine prop_line = prepare_s_e_line(process);
4b7dc462 2421 draw_line((void*)&prop_line, (void*)&draw_context);
2422
2423 }
2424 /* become the last x position */
2425 hashed_process_data->x.middle = x;
e72908ed 2426 hashed_process_data->x.middle_used = TRUE;
2427 hashed_process_data->x.middle_marked = FALSE;
b2743953 2428
2429 /* Calculate the next good time */
2430 convert_pixels_to_time(width, x+1, time_window,
2431 &hashed_process_data->next_good_time);
dbd243b1 2432 }
dbd243b1 2433 }
2434
dbd243b1 2435 }
2436 return 0;
2437
2438}
2439
2440
2441
2442
2443
2444
2445/* after_process_hook
e92eabaf 2446 *
2447 * Create the processlist entry for the child process. Put the last
2448 * position in x at the current time value.
2449 *
2450 * @param hook_data ControlFlowData structure of the viewer.
2451 * @param call_data Event context.
2452 *
2453 * This function adds items to be drawn in a queue for each process.
2454 *
2455 */
dbd243b1 2456int after_process_hook(void *hook_data, void *call_data)
e92eabaf 2457{
2458 EventsRequest *events_request = (EventsRequest*)hook_data;
2459 ControlFlowData *control_flow_data = events_request->viewer_data;
2460
2461 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
2462
2463 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
e92eabaf 2464
2465 LttEvent *e;
2466 e = tfc->e;
2467
2468 LttTime evtime = ltt_event_time(e);
e92eabaf 2469
10a1069a 2470 guint sub_id;
2471 guint param1;
2472 {
2473 LttField *f = ltt_event_field(e);
2474 LttField *element;
2475 element = ltt_field_member(f,0);
2476 sub_id = ltt_event_get_long_unsigned(e,element);
2477 element = ltt_field_member(f,1);
2478 param1 = ltt_event_get_long_unsigned(e,element);
2479 }
e92eabaf 2480
10a1069a 2481 if(sub_id == 2) { /* fork */
2482
2483 guint child_pid = param1;
2484 /* Add process to process list (if not present) */
2485 LttvProcessState *process_child;
2486 LttTime birth;
1c736ed5 2487 guint pl_height = 0;
10a1069a 2488 HashedProcessData *hashed_process_data_child = NULL;
e92eabaf 2489
5c230fc4 2490 ProcessList *process_list = control_flow_data->process_list;
e92eabaf 2491
10a1069a 2492 /* Find child in the list... */
2493 process_child = lttv_state_find_process(tfs, child_pid);
2494 /* It should exist, because we are after the state update. */
2495 g_assert(process_child != NULL);
e92eabaf 2496
10a1069a 2497 birth = process_child->creation_time;
e92eabaf 2498
ac4e21cf 2499 hashed_process_data_child = processlist_get_process_data(process_list,
10a1069a 2500 child_pid,
40debf7b 2501 process_child->last_cpu_index,
10a1069a 2502 &birth,
ac4e21cf 2503 tfc->t_context->index);
1d1df11d 2504 if(likely(hashed_process_data_child == NULL))
10a1069a 2505 {
2506 g_assert(child_pid == 0 || child_pid != process_child->ppid);
2507 /* Process not present */
1c736ed5 2508 Drawing_t *drawing = control_flow_data->drawing;
aac69e70 2509 const gchar *name = g_quark_to_string(process_child->name);
4e86ae2e 2510 ProcessInfo *process_info;
10a1069a 2511 processlist_add(process_list,
1c736ed5 2512 drawing,
10a1069a 2513 child_pid,
40debf7b 2514 process_child->last_cpu_index,
10a1069a 2515 process_child->ppid,
2516 &birth,
2517 tfc->t_context->index,
2518 name,
2519 &pl_height,
4e86ae2e 2520 &process_info,
10a1069a 2521 &hashed_process_data_child);
1c736ed5 2522 gtk_widget_set_size_request(drawing->drawing_area,
2523 -1,
2524 pl_height);
2525 gtk_widget_queue_draw(drawing->drawing_area);
10a1069a 2526 }
e92eabaf 2527
40debf7b 2528
1d1df11d 2529 if(likely(ltt_time_compare(hashed_process_data_child->next_good_time,
2530 evtime) <= 0))
b2743953 2531 {
fd22065b 2532 TimeWindow time_window =
2533 lttvwindow_get_time_window(control_flow_data->tab);
2534
2535#ifdef EXTRA_CHECK
2536 if(ltt_time_compare(evtime, time_window.start_time) == -1
2537 || ltt_time_compare(evtime, time_window.end_time) == 1)
2538 return;
2539#endif //EXTRA_CHECK
d6fef890 2540 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 2541 guint width = drawing->width;
b2743953 2542 guint new_x;
2543 convert_time_to_pixels(
2544 time_window,
2545 evtime,
2546 width,
2547 &new_x);
e72908ed 2548
1d1df11d 2549 if(likely(hashed_process_data_child->x.over != new_x)) {
b2743953 2550 hashed_process_data_child->x.over = new_x;
2551 hashed_process_data_child->x.over_used = FALSE;
2552 hashed_process_data_child->x.over_marked = FALSE;
2553 }
1d1df11d 2554 if(likely(hashed_process_data_child->x.middle != new_x)) {
b2743953 2555 hashed_process_data_child->x.middle = new_x;
2556 hashed_process_data_child->x.middle_used = FALSE;
2557 hashed_process_data_child->x.middle_marked = FALSE;
2558 }
1d1df11d 2559 if(likely(hashed_process_data_child->x.under != new_x)) {
b2743953 2560 hashed_process_data_child->x.under = new_x;
2561 hashed_process_data_child->x.under_used = FALSE;
2562 hashed_process_data_child->x.under_marked = FALSE;
2563 }
e72908ed 2564 }
23093869 2565
10a1069a 2566 } else if(sub_id == 3) { /* exit */
dbd243b1 2567
10a1069a 2568 /* Add process to process list (if not present) */
2569 LttvProcessState *process = tfs->process;
2570 guint pid = process->pid;
2571 LttTime birth;
1c736ed5 2572 guint pl_height = 0;
10a1069a 2573 HashedProcessData *hashed_process_data = NULL;
dbd243b1 2574
5c230fc4 2575 ProcessList *process_list = control_flow_data->process_list;
dbd243b1 2576
10a1069a 2577 /* It should exist, because we are after the state update. */
2578 g_assert(process != NULL);
dbd243b1 2579
10a1069a 2580 birth = process->creation_time;
dbd243b1 2581
1d1df11d 2582 if(likely(process_list->current_hash_data[tfc->index] != NULL) ){
40debf7b 2583 hashed_process_data = process_list->current_hash_data[tfc->index];
40debf7b 2584 } else {
ac4e21cf 2585 hashed_process_data = processlist_get_process_data(process_list,
40debf7b 2586 pid,
2587 process->last_cpu_index,
2588 &birth,
ac4e21cf 2589 tfc->t_context->index);
1d1df11d 2590 if(unlikely(hashed_process_data == NULL))
40debf7b 2591 {
2592 g_assert(pid == 0 || pid != process->ppid);
2593 /* Process not present */
1c736ed5 2594 Drawing_t *drawing = control_flow_data->drawing;
40debf7b 2595 const gchar *name = g_quark_to_string(process->name);
2596 ProcessInfo *process_info;
2597 processlist_add(process_list,
1c736ed5 2598 drawing,
40debf7b 2599 pid,
2600 process->last_cpu_index,
2601 process->ppid,
2602 &birth,
2603 tfc->t_context->index,
2604 name,
2605 &pl_height,
2606 &process_info,
2607 &hashed_process_data);
1c736ed5 2608 gtk_widget_set_size_request(drawing->drawing_area,
2609 -1,
2610 pl_height);
2611 gtk_widget_queue_draw(drawing->drawing_area);
40debf7b 2612 }
2613
2614 /* Set the current process */
2615 process_list->current_hash_data[process->last_cpu_index] =
2616 hashed_process_data;
e92eabaf 2617 }
dbd243b1 2618
1d1df11d 2619 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
2620 evtime) <= 0))
b2743953 2621 {
fd22065b 2622 TimeWindow time_window =
2623 lttvwindow_get_time_window(control_flow_data->tab);
2624
2625#ifdef EXTRA_CHECK
2626 if(ltt_time_compare(evtime, time_window.start_time) == -1
2627 || ltt_time_compare(evtime, time_window.end_time) == 1)
2628 return;
2629#endif //EXTRA_CHECK
d6fef890 2630 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 2631 guint width = drawing->width;
b2743953 2632 guint new_x;
2633 convert_time_to_pixels(
2634 time_window,
2635 evtime,
2636 width,
2637 &new_x);
1d1df11d 2638 if(unlikely(hashed_process_data->x.middle != new_x)) {
b2743953 2639 hashed_process_data->x.middle = new_x;
2640 hashed_process_data->x.middle_used = FALSE;
2641 hashed_process_data->x.middle_marked = FALSE;
2642 }
e72908ed 2643 }
2644
e92eabaf 2645 }
2646 return 0;
2647
2648}
f7afe191 2649
2650
1b238973 2651gint update_time_window_hook(void *hook_data, void *call_data)
f7afe191 2652{
a56a1ba4 2653 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
a43d67ba 2654 Drawing_t *drawing = control_flow_data->drawing;
1c736ed5 2655 ProcessList *process_list = control_flow_data->process_list;
a43d67ba 2656
224446ce 2657 const TimeWindowNotifyData *time_window_nofify_data =
2658 ((const TimeWindowNotifyData *)call_data);
2659
14963be0 2660 TimeWindow *old_time_window =
224446ce 2661 time_window_nofify_data->old_time_window;
2662 TimeWindow *new_time_window =
2663 time_window_nofify_data->new_time_window;
a56a1ba4 2664
3cb8b205 2665 /* Update the ruler */
2666 drawing_update_ruler(control_flow_data->drawing,
2667 new_time_window);
2668
2669
a56a1ba4 2670 /* Two cases : zoom in/out or scrolling */
2671
2672 /* In order to make sure we can reuse the old drawing, the scale must
2673 * be the same and the new time interval being partly located in the
2674 * currently shown time interval. (reuse is only for scrolling)
2675 */
2676
2eef04b5 2677 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
14963be0 2678 old_time_window->start_time.tv_sec,
2679 old_time_window->start_time.tv_nsec,
2680 old_time_window->time_width.tv_sec,
2681 old_time_window->time_width.tv_nsec);
a56a1ba4 2682
2eef04b5 2683 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
14963be0 2684 new_time_window->start_time.tv_sec,
2685 new_time_window->start_time.tv_nsec,
2686 new_time_window->time_width.tv_sec,
2687 new_time_window->time_width.tv_nsec);
a56a1ba4 2688
14963be0 2689 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
2690 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
a56a1ba4 2691 {
2692 /* Same scale (scrolling) */
2693 g_info("scrolling");
14963be0 2694 LttTime *ns = &new_time_window->start_time;
20640e70 2695 LttTime *nw = &new_time_window->time_width;
14963be0 2696 LttTime *os = &old_time_window->start_time;
20640e70 2697 LttTime *ow = &old_time_window->time_width;
6f26fc38 2698 LttTime old_end = old_time_window->end_time;
2699 LttTime new_end = new_time_window->end_time;
a56a1ba4 2700 //if(ns<os+w<ns+w)
2701 //if(ns<os+w && os+w<ns+w)
2702 //if(ns<old_end && os<ns)
2703 if(ltt_time_compare(*ns, old_end) == -1
2704 && ltt_time_compare(*os, *ns) == -1)
2705 {
2706 g_info("scrolling near right");
2707 /* Scroll right, keep right part of the screen */
2708 guint x = 0;
51705146 2709 guint width = control_flow_data->drawing->width;
a56a1ba4 2710 convert_time_to_pixels(
a18124ff 2711 *old_time_window,
a56a1ba4 2712 *ns,
2713 width,
2714 &x);
2715
2716 /* Copy old data to new location */
1c736ed5 2717 copy_pixmap_region(process_list,
2718 NULL,
2719 control_flow_data->drawing->drawing_area->style->black_gc,
2720 NULL,
2721 x, 0,
2722 0, 0,
2723 control_flow_data->drawing->width-x+SAFETY, -1);
2724
6395d57c 2725 if(drawing->damage_begin == drawing->damage_end)
2726 drawing->damage_begin = control_flow_data->drawing->width-x;
2727 else
2728 drawing->damage_begin = 0;
2729
2730 drawing->damage_end = control_flow_data->drawing->width;
2731
a56a1ba4 2732 /* Clear the data request background, but not SAFETY */
1c736ed5 2733 rectangle_pixmap(process_list,
cfe526b1 2734 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 2735 TRUE,
6395d57c 2736 drawing->damage_begin+SAFETY, 0,
2737 drawing->damage_end - drawing->damage_begin, // do not overlap
1c736ed5 2738 -1);
7abb23ad 2739 gtk_widget_queue_draw(drawing->drawing_area);
2740 //gtk_widget_queue_draw_area (drawing->drawing_area,
2741 // 0,0,
2742 // control_flow_data->drawing->width,
2743 // control_flow_data->drawing->height);
a43d67ba 2744
a56a1ba4 2745 /* Get new data for the rest. */
501d5405 2746 drawing_data_request(control_flow_data->drawing,
6395d57c 2747 drawing->damage_begin, 0,
2748 drawing->damage_end - drawing->damage_begin,
501d5405 2749 control_flow_data->drawing->height);
a56a1ba4 2750 } else {
2751 //if(ns<os<ns+w)
2752 //if(ns<os && os<ns+w)
2753 //if(ns<os && os<new_end)
2754 if(ltt_time_compare(*ns,*os) == -1
2755 && ltt_time_compare(*os,new_end) == -1)
2756 {
2757 g_info("scrolling near left");
2758 /* Scroll left, keep left part of the screen */
2759 guint x = 0;
51705146 2760 guint width = control_flow_data->drawing->width;
a56a1ba4 2761 convert_time_to_pixels(
a18124ff 2762 *new_time_window,
a56a1ba4 2763 *os,
2764 width,
2765 &x);
6395d57c 2766
a56a1ba4 2767 /* Copy old data to new location */
1c736ed5 2768 copy_pixmap_region (process_list,
2769 NULL,
cfe526b1 2770 control_flow_data->drawing->drawing_area->style->black_gc,
1c736ed5 2771 NULL,
a56a1ba4 2772 0, 0,
2773 x, 0,
2774 -1, -1);
2775
6395d57c 2776 if(drawing->damage_begin == drawing->damage_end)
2777 drawing->damage_end = x;
2778 else
2779 drawing->damage_end =
51705146 2780 control_flow_data->drawing->width;
6395d57c 2781
2782 drawing->damage_begin = 0;
2783
1c736ed5 2784 rectangle_pixmap (process_list,
cfe526b1 2785 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 2786 TRUE,
6395d57c 2787 drawing->damage_begin, 0,
2788 drawing->damage_end - drawing->damage_begin, // do not overlap
1c736ed5 2789 -1);
a43d67ba 2790
7abb23ad 2791 gtk_widget_queue_draw(drawing->drawing_area);
2792 //gtk_widget_queue_draw_area (drawing->drawing_area,
2793 // 0,0,
2794 // control_flow_data->drawing->width,
2795 // control_flow_data->drawing->height);
a43d67ba 2796
6395d57c 2797
a56a1ba4 2798 /* Get new data for the rest. */
501d5405 2799 drawing_data_request(control_flow_data->drawing,
6395d57c 2800 drawing->damage_begin, 0,
2801 drawing->damage_end - drawing->damage_begin,
501d5405 2802 control_flow_data->drawing->height);
a56a1ba4 2803
a56a1ba4 2804 } else {
a43d67ba 2805 if(ltt_time_compare(*ns,*os) == 0)
2806 {
2807 g_info("not scrolling");
2808 } else {
2809 g_info("scrolling far");
2810 /* Cannot reuse any part of the screen : far jump */
2811
2812
1c736ed5 2813 rectangle_pixmap (process_list,
a43d67ba 2814 control_flow_data->drawing->drawing_area->style->black_gc,
2815 TRUE,
a56a1ba4 2816 0, 0,
a43d67ba 2817 control_flow_data->drawing->width+SAFETY, // do not overlap
1c736ed5 2818 -1);
a43d67ba 2819
7abb23ad 2820 //gtk_widget_queue_draw_area (drawing->drawing_area,
2821 // 0,0,
2822 // control_flow_data->drawing->width,
2823 // control_flow_data->drawing->height);
2824 gtk_widget_queue_draw(drawing->drawing_area);
a43d67ba 2825
6395d57c 2826 drawing->damage_begin = 0;
2827 drawing->damage_end = control_flow_data->drawing->width;
2828
a43d67ba 2829 drawing_data_request(control_flow_data->drawing,
a43d67ba 2830 0, 0,
2831 control_flow_data->drawing->width,
2832 control_flow_data->drawing->height);
2833
2834 }
a56a1ba4 2835 }
2836 }
2837 } else {
2838 /* Different scale (zoom) */
2839 g_info("zoom");
2840
1c736ed5 2841 rectangle_pixmap (process_list,
cfe526b1 2842 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 2843 TRUE,
2844 0, 0,
501d5405 2845 control_flow_data->drawing->width+SAFETY, // do not overlap
1c736ed5 2846 -1);
a56a1ba4 2847
7abb23ad 2848 //gtk_widget_queue_draw_area (drawing->drawing_area,
2849 // 0,0,
2850 // control_flow_data->drawing->width,
2851 // control_flow_data->drawing->height);
2852 gtk_widget_queue_draw(drawing->drawing_area);
a56a1ba4 2853
6395d57c 2854 drawing->damage_begin = 0;
2855 drawing->damage_end = control_flow_data->drawing->width;
2856
501d5405 2857 drawing_data_request(control_flow_data->drawing,
a56a1ba4 2858 0, 0,
501d5405 2859 control_flow_data->drawing->width,
2860 control_flow_data->drawing->height);
a56a1ba4 2861 }
2862
3cb8b205 2863
2864
a56a1ba4 2865 return 0;
f7afe191 2866}
2867
6395d57c 2868gint traceset_notify(void *hook_data, void *call_data)
2869{
2870 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2871 Drawing_t *drawing = control_flow_data->drawing;
6395d57c 2872
6395d57c 2873
b9a010a2 2874 drawing_clear(control_flow_data->drawing);
2875 processlist_clear(control_flow_data->process_list);
07390ec1 2876 gtk_widget_set_size_request(
2877 control_flow_data->drawing->drawing_area,
2878 -1, processlist_get_height(control_flow_data->process_list));
d9267eec 2879 redraw_notify(control_flow_data, NULL);
6395d57c 2880
d9267eec 2881 request_background_data(control_flow_data);
6395d57c 2882
2883 return FALSE;
2884}
2885
ca0f8a8e 2886gint redraw_notify(void *hook_data, void *call_data)
2887{
2888 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2889 Drawing_t *drawing = control_flow_data->drawing;
2890 GtkWidget *widget = drawing->drawing_area;
2891
2892 drawing->damage_begin = 0;
51705146 2893 drawing->damage_end = drawing->width;
ca0f8a8e 2894
49217bd4 2895 /* fun feature, to be separated someday... */
2896 drawing_clear(control_flow_data->drawing);
2897 processlist_clear(control_flow_data->process_list);
07390ec1 2898 gtk_widget_set_size_request(
2899 control_flow_data->drawing->drawing_area,
2900 -1, processlist_get_height(control_flow_data->process_list));
1c736ed5 2901 // Clear the images
2902 rectangle_pixmap (control_flow_data->process_list,
ca0f8a8e 2903 widget->style->black_gc,
2904 TRUE,
2905 0, 0,
f3b7430d 2906 drawing->alloc_width,
1c736ed5 2907 -1);
ca0f8a8e 2908
f3b7430d 2909 gtk_widget_queue_draw(drawing->drawing_area);
ca0f8a8e 2910
2911 if(drawing->damage_begin < drawing->damage_end)
2912 {
2913 drawing_data_request(drawing,
ca0f8a8e 2914 drawing->damage_begin,
2915 0,
2916 drawing->damage_end-drawing->damage_begin,
51705146 2917 drawing->height);
ca0f8a8e 2918 }
2919
7abb23ad 2920 //gtk_widget_queue_draw_area(drawing->drawing_area,
2921 // 0,0,
2922 // drawing->width,
2923 // drawing->height);
ca0f8a8e 2924 return FALSE;
2925
2926}
2927
2928
2929gint continue_notify(void *hook_data, void *call_data)
a43d67ba 2930{
2931 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
ca0f8a8e 2932 Drawing_t *drawing = control_flow_data->drawing;
a43d67ba 2933
6395d57c 2934 //g_assert(widget->allocation.width == drawing->damage_end);
ca0f8a8e 2935
2936 if(drawing->damage_begin < drawing->damage_end)
2937 {
2938 drawing_data_request(drawing,
ca0f8a8e 2939 drawing->damage_begin,
2940 0,
2941 drawing->damage_end-drawing->damage_begin,
51705146 2942 drawing->height);
ca0f8a8e 2943 }
2944
2945 return FALSE;
2946}
2947
2948
1b238973 2949gint update_current_time_hook(void *hook_data, void *call_data)
f7afe191 2950{
14963be0 2951 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
a43d67ba 2952 Drawing_t *drawing = control_flow_data->drawing;
a56a1ba4 2953
224446ce 2954 LttTime current_time = *((LttTime*)call_data);
a56a1ba4 2955
ca0f8a8e 2956 TimeWindow time_window =
2957 lttvwindow_get_time_window(control_flow_data->tab);
a56a1ba4 2958
ca0f8a8e 2959 LttTime time_begin = time_window.start_time;
2960 LttTime width = time_window.time_width;
90ef7e4a 2961 LttTime half_width;
2962 {
2963 guint64 time_ll = ltt_time_to_uint64(width);
2964 time_ll = time_ll >> 1; /* divide by two */
2965 half_width = ltt_time_from_uint64(time_ll);
2966 }
a56a1ba4 2967 LttTime time_end = ltt_time_add(time_begin, width);
2968
2969 LttvTracesetContext * tsc =
ca0f8a8e 2970 lttvwindow_get_traceset_context(control_flow_data->tab);
a56a1ba4 2971
ca0f8a8e 2972 LttTime trace_start = tsc->time_span.start_time;
2973 LttTime trace_end = tsc->time_span.end_time;
a56a1ba4 2974
2eef04b5 2975 g_info("New current time HOOK : %lu, %lu", current_time.tv_sec,
224446ce 2976 current_time.tv_nsec);
a56a1ba4 2977
2978
2979
2980 /* If current time is inside time interval, just move the highlight
2981 * bar */
2982
2983 /* Else, we have to change the time interval. We have to tell it
2984 * to the main window. */
2985 /* The time interval change will take care of placing the current
2986 * time at the center of the visible area, or nearest possible if we are
2987 * at one end of the trace. */
2988
2989
224446ce 2990 if(ltt_time_compare(current_time, time_begin) == -1)
a56a1ba4 2991 {
224446ce 2992 TimeWindow new_time_window;
2993
2994 if(ltt_time_compare(current_time,
a56a1ba4 2995 ltt_time_add(trace_start,half_width)) == -1)
2996 time_begin = trace_start;
2997 else
224446ce 2998 time_begin = ltt_time_sub(current_time,half_width);
a56a1ba4 2999
224446ce 3000 new_time_window.start_time = time_begin;
3001 new_time_window.time_width = width;
a18124ff 3002 new_time_window.time_width_double = ltt_time_to_double(width);
6f26fc38 3003 new_time_window.end_time = ltt_time_add(time_begin, width);
a56a1ba4 3004
e800cf84 3005 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
a56a1ba4 3006 }
224446ce 3007 else if(ltt_time_compare(current_time, time_end) == 1)
a56a1ba4 3008 {
224446ce 3009 TimeWindow new_time_window;
3010
3011 if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) == 1)
a56a1ba4 3012 time_begin = ltt_time_sub(trace_end,width);
3013 else
224446ce 3014 time_begin = ltt_time_sub(current_time,half_width);
a56a1ba4 3015
224446ce 3016 new_time_window.start_time = time_begin;
3017 new_time_window.time_width = width;
a18124ff 3018 new_time_window.time_width_double = ltt_time_to_double(width);
6f26fc38 3019 new_time_window.end_time = ltt_time_add(time_begin, width);
a56a1ba4 3020
e800cf84 3021 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
a56a1ba4 3022
3023 }
7abb23ad 3024 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
3025
a56a1ba4 3026
3027 return 0;
f7afe191 3028}
3029
8b90e648 3030typedef struct _ClosureData {
ca0f8a8e 3031 EventsRequest *events_request;
d0cd7f09 3032 LttvTracesetState *tss;
b9a010a2 3033 LttTime end_time;
bc8d270b 3034 guint x_end;
8b90e648 3035} ClosureData;
a56a1ba4 3036
8b90e648 3037
e800cf84 3038void draw_closure(gpointer key, gpointer value, gpointer user_data)
3039{
a56a1ba4 3040 ProcessInfo *process_info = (ProcessInfo*)key;
3041 HashedProcessData *hashed_process_data = (HashedProcessData*)value;
3042 ClosureData *closure_data = (ClosureData*)user_data;
3043
e800cf84 3044 EventsRequest *events_request = closure_data->events_request;
3045 ControlFlowData *control_flow_data = events_request->viewer_data;
a56a1ba4 3046
e800cf84 3047 LttvTracesetState *tss = closure_data->tss;
d6fef890 3048 LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
a56a1ba4 3049
e800cf84 3050 LttTime evtime = closure_data->end_time;
d0cd7f09 3051
e800cf84 3052 {
3053 /* For the process */
3054 /* First, check if the current process is in the state computation
3055 * process list. If it is there, that means we must add it right now and
3056 * draw items from the beginning of the read for it. If it is not
3057 * present, it's a new process and it was not present : it will
3058 * be added after the state update. */
31b6868d 3059#ifdef EXTRA_CHECK
e800cf84 3060 g_assert(lttv_traceset_number(tsc->ts) > 0);
31b6868d 3061#endif //EXTRA_CHECK
e025a729 3062 /* tracefiles[0] is ok here, because we draw for every PID, and
3063 * assume CPU 0 for PID 0 //FIXME */
3064 LttvTracefileState *tfs =
3065 (LttvTracefileState*)tsc->traces[process_info->trace_num]->tracefiles[0];
a56a1ba4 3066
e800cf84 3067 LttvProcessState *process;
e025a729 3068 process = lttv_state_find_process(tfs,
3069 process_info->pid);
a56a1ba4 3070
1d1df11d 3071 if(unlikely(process != NULL)) {
e800cf84 3072
3073 /* Only draw for processes that are currently in the trace states */
ad2e83ba 3074
5c230fc4 3075 ProcessList *process_list = control_flow_data->process_list;
1d1df11d 3076#ifdef EXTRA_CHECK
e800cf84 3077 /* Should be alike when background info is ready */
3078 if(control_flow_data->background_info_waiting==0)
3079 g_assert(ltt_time_compare(process->creation_time,
3080 process_info->birth) == 0);
1d1df11d 3081#endif //EXTRA_CHECK
e800cf84 3082
3083 /* Now, the process is in the state hash and our own process hash.
3084 * We definitely can draw the items related to the ending state.
3085 */
3086
1d1df11d 3087 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
3088 evtime) <= 0))
e800cf84 3089 {
fd22065b 3090 TimeWindow time_window =
3091 lttvwindow_get_time_window(control_flow_data->tab);
3092
3093#ifdef EXTRA_CHECK
3094 if(ltt_time_compare(evtime, time_window.start_time) == -1
3095 || ltt_time_compare(evtime, time_window.end_time) == 1)
3096 return;
3097#endif //EXTRA_CHECK
d6fef890 3098 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 3099 guint width = drawing->width;
a56a1ba4 3100
bc8d270b 3101 guint x = closure_data->x_end;
8b90e648 3102
4b7dc462 3103 DrawContext draw_context;
3104
e800cf84 3105 /* Now create the drawing context that will be used to draw
3106 * items related to the last state. */
1c736ed5 3107 draw_context.drawable = hashed_process_data->pixmap;
e800cf84 3108 draw_context.gc = drawing->gc;
3109 draw_context.pango_layout = drawing->pango_layout;
e800cf84 3110 draw_context.drawinfo.end.x = x;
3111
1c736ed5 3112 draw_context.drawinfo.y.over = 1;
3113 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
3114 draw_context.drawinfo.y.under = hashed_process_data->height;
e800cf84 3115
3116 draw_context.drawinfo.start.offset.over = 0;
3117 draw_context.drawinfo.start.offset.middle = 0;
3118 draw_context.drawinfo.start.offset.under = 0;
3119 draw_context.drawinfo.end.offset.over = 0;
3120 draw_context.drawinfo.end.offset.middle = 0;
3121 draw_context.drawinfo.end.offset.under = 0;
9a1ec01b 3122#if 0
4b7dc462 3123 /* Jump over draw if we are at the same x position */
3124 if(x == hashed_process_data->x.over)
e800cf84 3125 {
4b7dc462 3126 /* jump */
3127 } else {
23093869 3128 draw_context.drawinfo.start.x = hashed_process_data->x.over;
3129 /* Draw the line */
3130 PropertiesLine prop_line = prepare_execmode_line(process);
3131 draw_line((void*)&prop_line, (void*)&draw_context);
3132
4b7dc462 3133 hashed_process_data->x.over = x;
23093869 3134 }
9a1ec01b 3135#endif //0
4b7dc462 3136
1d1df11d 3137 if(unlikely(x == hashed_process_data->x.middle &&
3138 hashed_process_data->x.middle_used)) {
b2743953 3139#if 0 /* do not mark closure : not missing information */
e72908ed 3140 if(hashed_process_data->x.middle_marked == FALSE) {
3141 /* Draw collision indicator */
3142 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
3143 gdk_draw_point(drawing->pixmap,
3144 drawing->gc,
3145 x,
2c6618bc 3146 y+(height/2)-3);
de4ea1ad 3147 hashed_process_data->x.middle_marked = TRUE;
e72908ed 3148 }
b2743953 3149#endif //0
4b7dc462 3150 /* Jump */
3151 } else {
23093869 3152 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
e800cf84 3153 /* Draw the line */
9a1ec01b 3154 PropertiesLine prop_line = prepare_s_e_line(process);
e800cf84 3155 draw_line((void*)&prop_line, (void*)&draw_context);
3156
4b7dc462 3157 /* become the last x position */
1d1df11d 3158 if(likely(x != hashed_process_data->x.middle)) {
e72908ed 3159 hashed_process_data->x.middle = x;
3160 /* but don't use the pixel */
3161 hashed_process_data->x.middle_used = FALSE;
b2743953 3162
3163 /* Calculate the next good time */
3164 convert_pixels_to_time(width, x+1, time_window,
3165 &hashed_process_data->next_good_time);
e72908ed 3166 }
e800cf84 3167 }
e800cf84 3168 }
3169 }
3170 }
3171 return;
8b90e648 3172}
3173
b9a010a2 3174int before_chunk(void *hook_data, void *call_data)
3175{
3176 EventsRequest *events_request = (EventsRequest*)hook_data;
16b9cadb 3177 LttvTracesetState *tss = (LttvTracesetState*)call_data;
7c0125e0 3178 ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data;
cd3892fe 3179#if 0
7c0125e0 3180 /* Desactivate sort */
3181 gtk_tree_sortable_set_sort_column_id(
3182 GTK_TREE_SORTABLE(cfd->process_list->list_store),
3183 TRACE_COLUMN,
3184 GTK_SORT_ASCENDING);
cd3892fe 3185#endif //0
b9a010a2 3186 drawing_chunk_begin(events_request, tss);
3187
3188 return 0;
3189}
3190
3191int before_request(void *hook_data, void *call_data)
ca0f8a8e 3192{
3193 EventsRequest *events_request = (EventsRequest*)hook_data;
16b9cadb 3194 LttvTracesetState *tss = (LttvTracesetState*)call_data;
7c0125e0 3195
ca0f8a8e 3196 drawing_data_request_begin(events_request, tss);
3197
3198 return 0;
3199}
3200
3201
8b90e648 3202/*
b9a010a2 3203 * after request is necessary in addition of after chunk in order to draw
3204 * lines until the end of the screen. after chunk just draws lines until
3205 * the last event.
3206 *
8b90e648 3207 * for each process
a56a1ba4 3208 * draw closing line
b9a010a2 3209 * expose
8b90e648 3210 */
b9a010a2 3211int after_request(void *hook_data, void *call_data)
8b90e648 3212{
ca0f8a8e 3213 EventsRequest *events_request = (EventsRequest*)hook_data;
3214 ControlFlowData *control_flow_data = events_request->viewer_data;
16b9cadb 3215 LttvTracesetState *tss = (LttvTracesetState*)call_data;
a56a1ba4 3216
5c230fc4 3217 ProcessList *process_list = control_flow_data->process_list;
b9a010a2 3218 LttTime end_time = events_request->end_time;
3219
3220 ClosureData closure_data;
3221 closure_data.events_request = (EventsRequest*)hook_data;
3222 closure_data.tss = tss;
3223 closure_data.end_time = end_time;
3224
bc8d270b 3225 TimeWindow time_window =
3226 lttvwindow_get_time_window(control_flow_data->tab);
3227 guint width = control_flow_data->drawing->width;
3228 convert_time_to_pixels(
3229 time_window,
3230 end_time,
3231 width,
3232 &closure_data.x_end);
3233
3234
b9a010a2 3235 /* Draw last items */
3236 g_hash_table_foreach(process_list->process_hash, draw_closure,
3237 (void*)&closure_data);
7c0125e0 3238
b9a010a2 3239
3240 /* Request expose */
3241 drawing_request_expose(events_request, tss, end_time);
3242 return 0;
3243}
3244
3245/*
3246 * for each process
3247 * draw closing line
e800cf84 3248 * expose
b9a010a2 3249 */
3250int after_chunk(void *hook_data, void *call_data)
3251{
3252 EventsRequest *events_request = (EventsRequest*)hook_data;
3253 ControlFlowData *control_flow_data = events_request->viewer_data;
16b9cadb 3254 LttvTracesetState *tss = (LttvTracesetState*)call_data;
3255 LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
b9a010a2 3256 LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
3257 LttTime end_time;
3258
5c230fc4 3259 ProcessList *process_list = control_flow_data->process_list;
b9a010a2 3260
40debf7b 3261 g_free(process_list->current_hash_data);
3262 process_list->current_hash_data = NULL;
3263
e800cf84 3264 if(tfc != NULL)
3265 end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
0c5dbe3b 3266 else /* end of traceset, or position now out of request : end */
3267 end_time = events_request->end_time;
3268
a56a1ba4 3269 ClosureData closure_data;
ca0f8a8e 3270 closure_data.events_request = (EventsRequest*)hook_data;
3271 closure_data.tss = tss;
b9a010a2 3272 closure_data.end_time = end_time;
a56a1ba4 3273
bc8d270b 3274 TimeWindow time_window =
3275 lttvwindow_get_time_window(control_flow_data->tab);
3276 guint width = control_flow_data->drawing->width;
3277 convert_time_to_pixels(
3278 time_window,
3279 end_time,
3280 width,
3281 &closure_data.x_end);
3282
b9a010a2 3283 /* Draw last items */
14963be0 3284 g_hash_table_foreach(process_list->process_hash, draw_closure,
a56a1ba4 3285 (void*)&closure_data);
cd3892fe 3286#if 0
7c0125e0 3287 /* Reactivate sort */
3288 gtk_tree_sortable_set_sort_column_id(
3289 GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
3290 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
3291 GTK_SORT_ASCENDING);
3292
3293 update_index_to_pixmap(control_flow_data->process_list);
cd3892fe 3294 /* Request a full expose : drawing scrambled */
3295 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
3296#endif //0
3297 /* Request expose (updates damages zone also) */
b9a010a2 3298 drawing_request_expose(events_request, tss, end_time);
ca0f8a8e 3299
3300 return 0;
8b90e648 3301}
3302
This page took 0.215517 seconds and 4 git commands to generate.