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