thread fix
[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
4e4d11b3 48#ifdef HAVE_CONFIG_H
49#include <config.h>
50#endif
b9a010a2 51
cf6cb7e0 52//#define PANGO_ENABLE_BACKEND
558aa013 53#include <gtk/gtk.h>
54#include <gdk/gdk.h>
5f16133f 55#include <glib.h>
80a52ff8 56#include <assert.h>
50439712 57#include <string.h>
319e9d81 58#include <stdio.h>
5f16133f 59
cf6cb7e0 60//#include <pango/pango.h>
61
80a52ff8 62#include <ltt/event.h>
4ba42155 63#include <ltt/time.h>
50439712 64#include <ltt/type.h>
2c82c4dc 65#include <ltt/trace.h>
80a52ff8 66
2a2fa4f0 67#include <lttv/lttv.h>
558aa013 68#include <lttv/hook.h>
80a52ff8 69#include <lttv/state.h>
2d262115 70#include <lttvwindow/lttvwindow.h>
6395d57c 71#include <lttvwindow/lttvwindowtraces.h>
0de51231 72#include <lttvwindow/support.h>
80a52ff8 73
f0d936c0 74
a117e3f7 75#include "eventhooks.h"
76#include "cfv.h"
77#include "processlist.h"
78#include "drawing.h"
5f16133f 79
80a52ff8 80
1a31868c 81#define MAX_PATH_LEN 256
82
0de51231 83extern GSList *g_legend_list;
84
b9a010a2 85
6395d57c 86/* Action to do when background computation completed.
87 *
e800cf84 88 * Wait for all the awaited computations to be over.
6395d57c 89 */
90
703b25fa 91static gint background_ready(void *hook_data, void *call_data)
6395d57c 92{
93 ControlFlowData *control_flow_data = (ControlFlowData *)hook_data;
94 LttvTrace *trace = (LttvTrace*)call_data;
95
e800cf84 96 control_flow_data->background_info_waiting--;
97
98 if(control_flow_data->background_info_waiting == 0) {
4a24fa1f 99 g_message("control flow viewer : background computation data ready.");
6395d57c 100
e800cf84 101 drawing_clear(control_flow_data->drawing);
102 processlist_clear(control_flow_data->process_list);
07390ec1 103 gtk_widget_set_size_request(
104 control_flow_data->drawing->drawing_area,
105 -1, processlist_get_height(control_flow_data->process_list));
e800cf84 106 redraw_notify(control_flow_data, NULL);
b9a010a2 107 }
6395d57c 108
109 return 0;
110}
111
112
113/* Request background computation. Verify if it is in progress or ready first.
e800cf84 114 * Only for each trace in the tab's traceset.
6395d57c 115 */
3f7f592e 116static void request_background_data(ControlFlowData *control_flow_data)
6395d57c 117{
e800cf84 118 LttvTracesetContext * tsc =
119 lttvwindow_get_traceset_context(control_flow_data->tab);
120 gint num_traces = lttv_traceset_number(tsc->ts);
6395d57c 121 gint i;
122 LttvTrace *trace;
123
124 LttvHooks *background_ready_hook =
125 lttv_hooks_new();
126 lttv_hooks_add(background_ready_hook, background_ready, control_flow_data,
127 LTTV_PRIO_DEFAULT);
e800cf84 128 control_flow_data->background_info_waiting = 0;
6395d57c 129
130 for(i=0;i<num_traces;i++) {
e800cf84 131 trace = lttv_traceset_get(tsc->ts, i);
6395d57c 132
133 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE) {
134
135 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
136 trace) == FALSE) {
137 /* We first remove requests that could have been done for the same
138 * information. Happens when two viewers ask for it before servicing
139 * starts.
140 */
93ac601b 141 if(!lttvwindowtraces_background_request_find(trace, "state"))
b5e17af5 142 lttvwindowtraces_background_request_queue(
143 main_window_get_widget(control_flow_data->tab), trace, "state");
6395d57c 144 lttvwindowtraces_background_notify_queue(control_flow_data,
145 trace,
146 ltt_time_infinite,
147 NULL,
148 background_ready_hook);
e800cf84 149 control_flow_data->background_info_waiting++;
6395d57c 150 } else { /* in progress */
151
152 lttvwindowtraces_background_notify_current(control_flow_data,
153 trace,
154 ltt_time_infinite,
155 NULL,
156 background_ready_hook);
e800cf84 157 control_flow_data->background_info_waiting++;
6395d57c 158 }
4368b993 159 } else {
160 /* Data ready. Be its nature, this viewer doesn't need to have
618fbcc1 161 * its data ready hook called there, because a background
4368b993 162 * request is always linked with a redraw.
163 */
6395d57c 164 }
4368b993 165
6395d57c 166 }
167
168 lttv_hooks_destroy(background_ready_hook);
169}
170
171
172
173
f0d936c0 174/**
175 * Event Viewer's constructor hook
176 *
177 * This constructor is given as a parameter to the menuitem and toolbar button
178 * registration. It creates the list.
ca0f8a8e 179 * @param tab A pointer to the parent tab.
f0d936c0 180 * @return The widget created.
181 */
182GtkWidget *
d47b33d2 183h_guicontrolflow(Tab *tab)
f0d936c0 184{
d47b33d2 185 g_info("h_guicontrolflow, %p", tab);
6cec4cd2 186 ControlFlowData *control_flow_data = guicontrolflow(tab) ;
a56a1ba4 187
ca0f8a8e 188 control_flow_data->tab = tab;
a56a1ba4 189
a56a1ba4 190 // Unreg done in the GuiControlFlow_Destructor
6395d57c 191 lttvwindow_register_traceset_notify(tab,
192 traceset_notify,
193 control_flow_data);
194
ca0f8a8e 195 lttvwindow_register_time_window_notify(tab,
224446ce 196 update_time_window_hook,
197 control_flow_data);
ca0f8a8e 198 lttvwindow_register_current_time_notify(tab,
224446ce 199 update_current_time_hook,
200 control_flow_data);
ca0f8a8e 201 lttvwindow_register_redraw_notify(tab,
202 redraw_notify,
203 control_flow_data);
204 lttvwindow_register_continue_notify(tab,
205 continue_notify,
206 control_flow_data);
667ca2a0 207 request_background_data(control_flow_data);
6395d57c 208
ca0f8a8e 209
68997a22 210 return guicontrolflow_get_widget(control_flow_data) ;
a56a1ba4 211
f0d936c0 212}
213
0de51231 214void legend_destructor(GtkWindow *legend)
215{
216 g_legend_list = g_slist_remove(g_legend_list, legend);
217}
218
219/* Create a popup legend */
220GtkWidget *
221h_legend(Tab *tab)
222{
223 g_info("h_legend, %p", tab);
224
225 GtkWindow *legend = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
226
227 g_legend_list = g_slist_append(
228 g_legend_list,
229 legend);
230
231 g_object_set_data_full(
232 G_OBJECT(legend),
233 "legend",
234 legend,
235 (GDestroyNotify)legend_destructor);
236
237 gtk_window_set_title(legend, "Control Flow View Legend");
238
239 GtkWidget *pixmap = create_pixmap(GTK_WIDGET(legend), "lttv-color-list.png");
240
241 // GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixmap(
242 // GDK_PIXMAP(pixmap), NULL));
243
244 gtk_container_add(GTK_CONTAINER(legend), GTK_WIDGET(pixmap));
245
246 gtk_widget_show(GTK_WIDGET(pixmap));
247 gtk_widget_show(GTK_WIDGET(legend));
248
249
250 return NULL; /* This is a popup window */
251}
252
253
3cff8cc1 254int event_selected_hook(void *hook_data, void *call_data)
f0d936c0 255{
68997a22 256 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
14963be0 257 guint *event_number = (guint*) call_data;
f0d936c0 258
2a2fa4f0 259 g_debug("DEBUG : event selected by main window : %u", *event_number);
a56a1ba4 260
2eef04b5 261 return 0;
f0d936c0 262}
263
9a1ec01b 264/* Function that selects the color of status&exemode line */
6550d711 265static inline PropertiesLine prepare_s_e_line(LttvProcessState *process)
9a1ec01b 266{
267 PropertiesLine prop_line;
268 prop_line.line_width = 2;
269 prop_line.style = GDK_LINE_SOLID;
270 prop_line.y = MIDDLE;
271 //GdkColormap *colormap = gdk_colormap_get_system();
272
9a1ec01b 273 if(process->state->s == LTTV_STATE_RUN) {
274 if(process->state->t == LTTV_STATE_USER_MODE)
275 prop_line.color = drawing_colors[COL_RUN_USER_MODE];
276 else if(process->state->t == LTTV_STATE_SYSCALL)
277 prop_line.color = drawing_colors[COL_RUN_SYSCALL];
278 else if(process->state->t == LTTV_STATE_TRAP)
279 prop_line.color = drawing_colors[COL_RUN_TRAP];
280 else if(process->state->t == LTTV_STATE_IRQ)
281 prop_line.color = drawing_colors[COL_RUN_IRQ];
faf074a3 282 else if(process->state->t == LTTV_STATE_SOFT_IRQ)
283 prop_line.color = drawing_colors[COL_RUN_SOFT_IRQ];
9a1ec01b 284 else if(process->state->t == LTTV_STATE_MODE_UNKNOWN)
285 prop_line.color = drawing_colors[COL_MODE_UNKNOWN];
286 else
287 g_assert(FALSE); /* RUNNING MODE UNKNOWN */
288 } else if(process->state->s == LTTV_STATE_WAIT) {
289 /* We don't show if we wait while in user mode, trap, irq or syscall */
290 prop_line.color = drawing_colors[COL_WAIT];
291 } else if(process->state->s == LTTV_STATE_WAIT_CPU) {
292 /* We don't show if we wait for CPU while in user mode, trap, irq
293 * or syscall */
294 prop_line.color = drawing_colors[COL_WAIT_CPU];
295 } else if(process->state->s == LTTV_STATE_ZOMBIE) {
296 prop_line.color = drawing_colors[COL_ZOMBIE];
297 } else if(process->state->s == LTTV_STATE_WAIT_FORK) {
298 prop_line.color = drawing_colors[COL_WAIT_FORK];
299 } else if(process->state->s == LTTV_STATE_EXIT) {
300 prop_line.color = drawing_colors[COL_EXIT];
301 } else if(process->state->s == LTTV_STATE_UNNAMED) {
302 prop_line.color = drawing_colors[COL_UNNAMED];
b3fd4c02 303 } else {
304 g_critical("unknown state : %s", g_quark_to_string(process->state->s));
9a1ec01b 305 g_assert(FALSE); /* UNKNOWN STATE */
b3fd4c02 306 }
9a1ec01b 307
308 return prop_line;
309
310}
311
c8bba5fa 312
e92eabaf 313/* before_schedchange_hook
b9a010a2 314 *
f0d936c0 315 * This function basically draw lines and icons. Two types of lines are drawn :
316 * one small (3 pixels?) representing the state of the process and the second
317 * type is thicker (10 pixels?) representing on which CPU a process is running
318 * (and this only in running state).
319 *
320 * Extremums of the lines :
321 * x_min : time of the last event context for this process kept in memory.
322 * x_max : time of the current event.
323 * y : middle of the process in the process list. The process is found in the
324 * list, therefore is it's position in pixels.
325 *
326 * The choice of lines'color is defined by the context of the last event for this
327 * process.
328 */
b9a010a2 329
330
e92eabaf 331int before_schedchange_hook(void *hook_data, void *call_data)
f0d936c0 332{
2c82c4dc 333 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
334 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
b9a010a2 335 ControlFlowData *control_flow_data = events_request->viewer_data;
336
337 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
338
339 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
348c6ba8 340 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
b9a010a2 341
342 LttEvent *e;
2c82c4dc 343 e = ltt_tracefile_get_event(tfc->tf);
b9a010a2 344
345 LttTime evtime = ltt_event_time(e);
fd22065b 346
10a1069a 347 /* we are in a schedchange, before the state update. We must draw the
348 * items corresponding to the state before it changes : now is the right
349 * time to do it.
350 */
b9a010a2 351
10a1069a 352 guint pid_out;
353 guint pid_in;
354 {
2c82c4dc 355 pid_out = ltt_event_get_long_unsigned(e, thf->f1);
356 pid_in = ltt_event_get_long_unsigned(e, thf->f2);
10a1069a 357 }
358
359 {
360 /* For the pid_out */
361 /* First, check if the current process is in the state computation
362 * process list. If it is there, that means we must add it right now and
363 * draw items from the beginning of the read for it. If it is not
364 * present, it's a new process and it was not present : it will
365 * be added after the state update. */
348c6ba8 366 guint cpu = ltt_tracefile_num(tfc->tf);
367 LttvProcessState *process = ts->running_process[cpu];
40debf7b 368 /* unknown state, bad current pid */
348c6ba8 369 if(process->pid != pid_out)
800aa029 370 process = lttv_state_find_process(ts,
371 ltt_tracefile_num(tfc->tf), pid_out);
b9a010a2 372
10a1069a 373 if(process != NULL) {
374 /* Well, the process_out existed : we must get it in the process hash
375 * or add it, and draw its items.
376 */
377 /* Add process to process list (if not present) */
1c736ed5 378 guint pl_height = 0;
10a1069a 379 HashedProcessData *hashed_process_data = NULL;
5c230fc4 380 ProcessList *process_list = control_flow_data->process_list;
10a1069a 381 LttTime birth = process->creation_time;
b9a010a2 382
ac4e21cf 383 hashed_process_data = processlist_get_process_data(process_list,
10a1069a 384 pid_out,
348c6ba8 385 process->cpu,
10a1069a 386 &birth,
ac4e21cf 387 tfc->t_context->index);
388 if(hashed_process_data == NULL)
10a1069a 389 {
390 g_assert(pid_out == 0 || pid_out != process->ppid);
391 /* Process not present */
4e86ae2e 392 ProcessInfo *process_info;
1c736ed5 393 Drawing_t *drawing = control_flow_data->drawing;
10a1069a 394 processlist_add(process_list,
1c736ed5 395 drawing,
10a1069a 396 pid_out,
348c6ba8 397 process->cpu,
10a1069a 398 process->ppid,
399 &birth,
400 tfc->t_context->index,
f4b88a7d 401 process->name,
10a1069a 402 &pl_height,
4e86ae2e 403 &process_info,
10a1069a 404 &hashed_process_data);
1c736ed5 405 gtk_widget_set_size_request(drawing->drawing_area,
406 -1,
407 pl_height);
408 gtk_widget_queue_draw(drawing->drawing_area);
409
10a1069a 410 }
ac4e21cf 411
10a1069a 412 /* Now, the process is in the state hash and our own process hash.
413 * We definitely can draw the items related to the ending state.
414 */
e800cf84 415
b2743953 416 if(ltt_time_compare(hashed_process_data->next_good_time,
417 evtime) > 0)
10a1069a 418 {
b2743953 419 if(hashed_process_data->x.middle_marked == FALSE) {
ac4e21cf 420
fd22065b 421 TimeWindow time_window =
422 lttvwindow_get_time_window(control_flow_data->tab);
423#ifdef EXTRA_CHECK
424 if(ltt_time_compare(evtime, time_window.start_time) == -1
425 || ltt_time_compare(evtime, time_window.end_time) == 1)
426 return;
427#endif //EXTRA_CHECK
d6fef890 428 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 429 guint width = drawing->width;
b2743953 430 guint x;
431 convert_time_to_pixels(
432 time_window,
433 evtime,
434 width,
435 &x);
436
437 /* Draw collision indicator */
438 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 439 gdk_draw_point(hashed_process_data->pixmap,
b2743953 440 drawing->gc,
441 x,
1c736ed5 442 (hashed_process_data->height/2)-3);
b2743953 443 hashed_process_data->x.middle_marked = TRUE;
444 }
445 } else {
ac4e21cf 446 TimeWindow time_window =
447 lttvwindow_get_time_window(control_flow_data->tab);
fd22065b 448#ifdef EXTRA_CHECK
ac4e21cf 449 if(ltt_time_compare(evtime, time_window.start_time) == -1
450 || ltt_time_compare(evtime, time_window.end_time) == 1)
451 return;
fd22065b 452#endif //EXTRA_CHECK
d6fef890 453 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 454 guint width = drawing->width;
10a1069a 455 guint x;
10a1069a 456 convert_time_to_pixels(
a18124ff 457 time_window,
4b7dc462 458 evtime,
459 width,
460 &x);
10a1069a 461
10a1069a 462
4b7dc462 463 /* Jump over draw if we are at the same x position */
e72908ed 464 if(x == hashed_process_data->x.middle &&
465 hashed_process_data->x.middle_used)
e800cf84 466 {
e72908ed 467 if(hashed_process_data->x.middle_marked == FALSE) {
468 /* Draw collision indicator */
469 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 470 gdk_draw_point(hashed_process_data->pixmap,
e72908ed 471 drawing->gc,
472 x,
1c736ed5 473 (hashed_process_data->height/2)-3);
de4ea1ad 474 hashed_process_data->x.middle_marked = TRUE;
e72908ed 475 }
4b7dc462 476 /* jump */
477 } else {
478 DrawContext draw_context;
10a1069a 479
4b7dc462 480 /* Now create the drawing context that will be used to draw
481 * items related to the last state. */
1c736ed5 482 draw_context.drawable = hashed_process_data->pixmap;
4b7dc462 483 draw_context.gc = drawing->gc;
484 draw_context.pango_layout = drawing->pango_layout;
485 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
486 draw_context.drawinfo.end.x = x;
487
1c736ed5 488 draw_context.drawinfo.y.over = 1;
489 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
490 draw_context.drawinfo.y.under = hashed_process_data->height;
4b7dc462 491
492 draw_context.drawinfo.start.offset.over = 0;
493 draw_context.drawinfo.start.offset.middle = 0;
494 draw_context.drawinfo.start.offset.under = 0;
495 draw_context.drawinfo.end.offset.over = 0;
496 draw_context.drawinfo.end.offset.middle = 0;
497 draw_context.drawinfo.end.offset.under = 0;
498
499 {
500 /* Draw the line */
9a1ec01b 501 PropertiesLine prop_line = prepare_s_e_line(process);
4b7dc462 502 draw_line((void*)&prop_line, (void*)&draw_context);
503
504 }
505 /* become the last x position */
506 hashed_process_data->x.middle = x;
e72908ed 507 hashed_process_data->x.middle_used = TRUE;
508 hashed_process_data->x.middle_marked = FALSE;
b2743953 509
510 /* Calculate the next good time */
511 convert_pixels_to_time(width, x+1, time_window,
512 &hashed_process_data->next_good_time);
e800cf84 513 }
514 }
515 }
10a1069a 516 }
e800cf84 517
10a1069a 518 {
519 /* For the pid_in */
520 /* First, check if the current process is in the state computation
521 * process list. If it is there, that means we must add it right now and
522 * draw items from the beginning of the read for it. If it is not
523 * present, it's a new process and it was not present : it will
524 * be added after the state update. */
525 LttvProcessState *process;
800aa029 526 process = lttv_state_find_process(ts,
527 ltt_tracefile_num(tfc->tf), pid_in);
10a1069a 528
529 if(process != NULL) {
800aa029 530 /* Well, the process existed : we must get it in the process hash
10a1069a 531 * or add it, and draw its items.
532 */
533 /* Add process to process list (if not present) */
1c736ed5 534 guint pl_height = 0;
10a1069a 535 HashedProcessData *hashed_process_data = NULL;
5c230fc4 536 ProcessList *process_list = control_flow_data->process_list;
10a1069a 537 LttTime birth = process->creation_time;
e800cf84 538
ac4e21cf 539 hashed_process_data = processlist_get_process_data(process_list,
10a1069a 540 pid_in,
8e680509 541 ltt_tracefile_num(tfc->tf),
10a1069a 542 &birth,
ac4e21cf 543 tfc->t_context->index);
544 if(hashed_process_data == NULL)
10a1069a 545 {
546 g_assert(pid_in == 0 || pid_in != process->ppid);
547 /* Process not present */
4e86ae2e 548 ProcessInfo *process_info;
1c736ed5 549 Drawing_t *drawing = control_flow_data->drawing;
10a1069a 550 processlist_add(process_list,
1c736ed5 551 drawing,
10a1069a 552 pid_in,
8e680509 553 ltt_tracefile_num(tfc->tf),
10a1069a 554 process->ppid,
555 &birth,
556 tfc->t_context->index,
f4b88a7d 557 process->name,
10a1069a 558 &pl_height,
4e86ae2e 559 &process_info,
10a1069a 560 &hashed_process_data);
1c736ed5 561 gtk_widget_set_size_request(drawing->drawing_area,
562 -1,
563 pl_height);
564 gtk_widget_queue_draw(drawing->drawing_area);
565
10a1069a 566 }
40debf7b 567 //We could set the current process and hash here, but will be done
568 //by after schedchange hook
10a1069a 569
570 /* Now, the process is in the state hash and our own process hash.
571 * We definitely can draw the items related to the ending state.
572 */
b9a010a2 573
b2743953 574 if(ltt_time_compare(hashed_process_data->next_good_time,
575 evtime) > 0)
10a1069a 576 {
b2743953 577 if(hashed_process_data->x.middle_marked == FALSE) {
ac4e21cf 578
fd22065b 579 TimeWindow time_window =
580 lttvwindow_get_time_window(control_flow_data->tab);
581#ifdef EXTRA_CHECK
582 if(ltt_time_compare(evtime, time_window.start_time) == -1
583 || ltt_time_compare(evtime, time_window.end_time) == 1)
584 return;
585#endif //EXTRA_CHECK
d6fef890 586 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 587 guint width = drawing->width;
b2743953 588 guint x;
589 convert_time_to_pixels(
590 time_window,
591 evtime,
592 width,
593 &x);
594
595 /* Draw collision indicator */
596 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 597 gdk_draw_point(hashed_process_data->pixmap,
b2743953 598 drawing->gc,
599 x,
1c736ed5 600 (hashed_process_data->height/2)-3);
b2743953 601 hashed_process_data->x.middle_marked = TRUE;
602 }
603 } else {
fd22065b 604 TimeWindow time_window =
605 lttvwindow_get_time_window(control_flow_data->tab);
606#ifdef EXTRA_CHECK
607 if(ltt_time_compare(evtime, time_window.start_time) == -1
608 || ltt_time_compare(evtime, time_window.end_time) == 1)
609 return;
610#endif //EXTRA_CHECK
d6fef890 611 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 612 guint width = drawing->width;
10a1069a 613 guint x;
10a1069a 614
615 convert_time_to_pixels(
a18124ff 616 time_window,
4b7dc462 617 evtime,
618 width,
619 &x);
10a1069a 620
10a1069a 621
4b7dc462 622 /* Jump over draw if we are at the same x position */
e72908ed 623 if(x == hashed_process_data->x.middle &&
624 hashed_process_data->x.middle_used)
4b7dc462 625 {
e72908ed 626 if(hashed_process_data->x.middle_marked == FALSE) {
627 /* Draw collision indicator */
628 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 629 gdk_draw_point(hashed_process_data->pixmap,
e72908ed 630 drawing->gc,
631 x,
1c736ed5 632 (hashed_process_data->height/2)-3);
de4ea1ad 633 hashed_process_data->x.middle_marked = TRUE;
e72908ed 634 }
4b7dc462 635 /* jump */
636 } else {
637 DrawContext draw_context;
10a1069a 638
4b7dc462 639 /* Now create the drawing context that will be used to draw
640 * items related to the last state. */
1c736ed5 641 draw_context.drawable = hashed_process_data->pixmap;
4b7dc462 642 draw_context.gc = drawing->gc;
643 draw_context.pango_layout = drawing->pango_layout;
644 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
645 draw_context.drawinfo.end.x = x;
10a1069a 646
1c736ed5 647 draw_context.drawinfo.y.over = 1;
648 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
649 draw_context.drawinfo.y.under = hashed_process_data->height;
10a1069a 650
4b7dc462 651 draw_context.drawinfo.start.offset.over = 0;
652 draw_context.drawinfo.start.offset.middle = 0;
653 draw_context.drawinfo.start.offset.under = 0;
654 draw_context.drawinfo.end.offset.over = 0;
655 draw_context.drawinfo.end.offset.middle = 0;
656 draw_context.drawinfo.end.offset.under = 0;
657
658 {
659 /* Draw the line */
9a1ec01b 660 PropertiesLine prop_line = prepare_s_e_line(process);
4b7dc462 661 draw_line((void*)&prop_line, (void*)&draw_context);
662 }
663
664
665 /* become the last x position */
666 hashed_process_data->x.middle = x;
e72908ed 667 hashed_process_data->x.middle_used = TRUE;
668 hashed_process_data->x.middle_marked = FALSE;
b2743953 669
670 /* Calculate the next good time */
671 convert_pixels_to_time(width, x+1, time_window,
672 &hashed_process_data->next_good_time);
4b7dc462 673 }
c8bba5fa 674 }
8e680509 675 } else
676 g_warning("Cannot find pin_in in schedchange %u", pid_in);
b9a010a2 677 }
b9a010a2 678 return 0;
679
680
b9a010a2 681
a56a1ba4 682
51705146 683 /* Text dump */
80a52ff8 684#ifdef DONTSHOW
a56a1ba4 685 GString *string = g_string_new("");;
686 gboolean field_names = TRUE, state = TRUE;
80a52ff8 687
e9a9c513 688 lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs);
689 g_string_append_printf(string,"\n");
690
691 if(state) {
692 g_string_append_printf(string, " %s",
693 g_quark_to_string(tfs->process->state->s));
694 }
695
696 g_info("%s",string->str);
697
a56a1ba4 698 g_string_free(string, TRUE);
699
700 /* End of text dump */
80a52ff8 701#endif //DONTSHOW
50439712 702
f0d936c0 703}
704
e92eabaf 705/* after_schedchange_hook
b9a010a2 706 *
707 * The draw after hook is called by the reading API to have a
708 * particular event drawn on the screen.
709 * @param hook_data ControlFlowData structure of the viewer.
710 * @param call_data Event context.
711 *
712 * This function adds items to be drawn in a queue for each process.
713 *
714 */
e92eabaf 715int after_schedchange_hook(void *hook_data, void *call_data)
f0d936c0 716{
2c82c4dc 717 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
718 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
ca0f8a8e 719 ControlFlowData *control_flow_data = events_request->viewer_data;
50439712 720
a56a1ba4 721 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
50439712 722
723 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
724
348c6ba8 725 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
726
b9a010a2 727 LttEvent *e;
2c82c4dc 728 e = ltt_tracefile_get_event(tfc->tf);
b9a010a2 729
730 LttTime evtime = ltt_event_time(e);
b9a010a2 731
10a1069a 732 /* Add process to process list (if not present) */
2eef04b5 733 LttvProcessState *process_in;
10a1069a 734 LttTime birth;
1c736ed5 735 guint pl_height = 0;
10a1069a 736 HashedProcessData *hashed_process_data_in = NULL;
b9a010a2 737
5c230fc4 738 ProcessList *process_list = control_flow_data->process_list;
10a1069a 739
740 guint pid_in;
741 {
742 guint pid_out;
2c82c4dc 743 pid_out = ltt_event_get_long_unsigned(e, thf->f1);
744 pid_in = ltt_event_get_long_unsigned(e, thf->f2);
10a1069a 745 }
b9a010a2 746
747
10a1069a 748 /* Find process pid_in in the list... */
348c6ba8 749 //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
750 //process_in = tfs->process;
751 guint cpu = ltt_tracefile_num(tfc->tf);
752 process_in = ts->running_process[cpu];
10a1069a 753 /* It should exist, because we are after the state update. */
96947fcf 754#ifdef EXTRA_CHECK
10a1069a 755 g_assert(process_in != NULL);
96947fcf 756#endif //EXTRA_CHECK
10a1069a 757 birth = process_in->creation_time;
b9a010a2 758
ac4e21cf 759 hashed_process_data_in = processlist_get_process_data(process_list,
10a1069a 760 pid_in,
348c6ba8 761 process_in->cpu,
10a1069a 762 &birth,
ac4e21cf 763 tfc->t_context->index);
764 if(hashed_process_data_in == NULL)
10a1069a 765 {
766 g_assert(pid_in == 0 || pid_in != process_in->ppid);
4e86ae2e 767 ProcessInfo *process_info;
1c736ed5 768 Drawing_t *drawing = control_flow_data->drawing;
10a1069a 769 /* Process not present */
770 processlist_add(process_list,
1c736ed5 771 drawing,
10a1069a 772 pid_in,
348c6ba8 773 process_in->cpu,
10a1069a 774 process_in->ppid,
775 &birth,
776 tfc->t_context->index,
f4b88a7d 777 process_in->name,
10a1069a 778 &pl_height,
4e86ae2e 779 &process_info,
10a1069a 780 &hashed_process_data_in);
1c736ed5 781 gtk_widget_set_size_request(drawing->drawing_area,
782 -1,
783 pl_height);
784 gtk_widget_queue_draw(drawing->drawing_area);
b9a010a2 785 }
40debf7b 786 /* Set the current process */
348c6ba8 787 process_list->current_hash_data[process_in->cpu] =
40debf7b 788 hashed_process_data_in;
10a1069a 789
b2743953 790 if(ltt_time_compare(hashed_process_data_in->next_good_time,
791 evtime) <= 0)
792 {
fd22065b 793 TimeWindow time_window =
794 lttvwindow_get_time_window(control_flow_data->tab);
795
796#ifdef EXTRA_CHECK
797 if(ltt_time_compare(evtime, time_window.start_time) == -1
798 || ltt_time_compare(evtime, time_window.end_time) == 1)
799 return;
800#endif //EXTRA_CHECK
d6fef890 801 Drawing_t *drawing = control_flow_data->drawing;
802 guint width = drawing->width;
b2743953 803 guint new_x;
804
805 convert_time_to_pixels(
806 time_window,
807 evtime,
808 width,
809 &new_x);
e72908ed 810
b2743953 811 if(hashed_process_data_in->x.middle != new_x) {
812 hashed_process_data_in->x.middle = new_x;
813 hashed_process_data_in->x.middle_used = FALSE;
814 hashed_process_data_in->x.middle_marked = FALSE;
815 }
816 }
b9a010a2 817 return 0;
4a24fa1f 818}
b9a010a2 819
820
821
e72908ed 822
4a24fa1f 823/* before_execmode_hook
824 *
825 * This function basically draw lines and icons. Two types of lines are drawn :
826 * one small (3 pixels?) representing the state of the process and the second
827 * type is thicker (10 pixels?) representing on which CPU a process is running
828 * (and this only in running state).
829 *
830 * Extremums of the lines :
831 * x_min : time of the last event context for this process kept in memory.
832 * x_max : time of the current event.
833 * y : middle of the process in the process list. The process is found in the
834 * list, therefore is it's position in pixels.
835 *
836 * The choice of lines'color is defined by the context of the last event for this
837 * process.
838 */
839
e72908ed 840
4a24fa1f 841int before_execmode_hook(void *hook_data, void *call_data)
842{
843 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
844 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
b9a010a2 845 ControlFlowData *control_flow_data = events_request->viewer_data;
846
847 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
848
849 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
b9a010a2 850
4a24fa1f 851 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
852
50439712 853 LttEvent *e;
4a24fa1f 854 e = ltt_tracefile_get_event(tfc->tf);
50439712 855
9444deae 856 LttTime evtime = ltt_event_time(e);
9444deae 857
4a24fa1f 858 /* we are in a execmode, before the state update. We must draw the
859 * items corresponding to the state before it changes : now is the right
860 * time to do it.
861 */
862 /* For the pid */
863 //LttvProcessState *process = tfs->process;
864 guint cpu = ltt_tracefile_num(tfc->tf);
865 LttvProcessState *process = ts->running_process[cpu];
866 g_assert(process != NULL);
23093869 867
10a1069a 868 guint pid = process->pid;
23093869 869
10a1069a 870 /* Well, the process_out existed : we must get it in the process hash
871 * or add it, and draw its items.
872 */
873 /* Add process to process list (if not present) */
1c736ed5 874 guint pl_height = 0;
10a1069a 875 HashedProcessData *hashed_process_data = NULL;
5c230fc4 876 ProcessList *process_list = control_flow_data->process_list;
10a1069a 877 LttTime birth = process->creation_time;
40debf7b 878
348c6ba8 879 if(likely(process_list->current_hash_data[cpu] != NULL)) {
880 hashed_process_data = process_list->current_hash_data[cpu];
40debf7b 881 } else {
ac4e21cf 882 hashed_process_data = processlist_get_process_data(process_list,
40debf7b 883 pid,
348c6ba8 884 process->cpu,
40debf7b 885 &birth,
ac4e21cf 886 tfc->t_context->index);
1d1df11d 887 if(unlikely(hashed_process_data == NULL))
40debf7b 888 {
889 g_assert(pid == 0 || pid != process->ppid);
890 ProcessInfo *process_info;
891 /* Process not present */
1c736ed5 892 Drawing_t *drawing = control_flow_data->drawing;
40debf7b 893 processlist_add(process_list,
1c736ed5 894 drawing,
40debf7b 895 pid,
348c6ba8 896 process->cpu,
40debf7b 897 process->ppid,
898 &birth,
899 tfc->t_context->index,
f4b88a7d 900 process->name,
40debf7b 901 &pl_height,
902 &process_info,
903 &hashed_process_data);
1c736ed5 904 gtk_widget_set_size_request(drawing->drawing_area,
905 -1,
906 pl_height);
907 gtk_widget_queue_draw(drawing->drawing_area);
40debf7b 908 }
909 /* Set the current process */
348c6ba8 910 process_list->current_hash_data[process->cpu] =
40debf7b 911 hashed_process_data;
10a1069a 912 }
23093869 913
10a1069a 914 /* Now, the process is in the state hash and our own process hash.
915 * We definitely can draw the items related to the ending state.
916 */
b2743953 917
1d1df11d 918 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
919 evtime) > 0))
10a1069a 920 {
1d1df11d 921 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
fd22065b 922 TimeWindow time_window =
923 lttvwindow_get_time_window(control_flow_data->tab);
924
925#ifdef EXTRA_CHECK
926 if(ltt_time_compare(evtime, time_window.start_time) == -1
927 || ltt_time_compare(evtime, time_window.end_time) == 1)
928 return;
929#endif //EXTRA_CHECK
d6fef890 930 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 931 guint width = drawing->width;
b2743953 932 guint x;
933 convert_time_to_pixels(
934 time_window,
935 evtime,
936 width,
937 &x);
938
939 /* Draw collision indicator */
940 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 941 gdk_draw_point(hashed_process_data->pixmap,
b2743953 942 drawing->gc,
943 x,
1c736ed5 944 (hashed_process_data->height/2)-3);
b2743953 945 hashed_process_data->x.middle_marked = TRUE;
946 }
947 } else {
fd22065b 948 TimeWindow time_window =
949 lttvwindow_get_time_window(control_flow_data->tab);
950
951#ifdef EXTRA_CHECK
952 if(ltt_time_compare(evtime, time_window.start_time) == -1
953 || ltt_time_compare(evtime, time_window.end_time) == 1)
954 return;
955#endif //EXTRA_CHECK
d6fef890 956 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 957 guint width = drawing->width;
10a1069a 958 guint x;
dbd243b1 959
10a1069a 960 convert_time_to_pixels(
a18124ff 961 time_window,
10a1069a 962 evtime,
963 width,
964 &x);
dbd243b1 965
23093869 966
4b7dc462 967 /* Jump over draw if we are at the same x position */
1d1df11d 968 if(unlikely(x == hashed_process_data->x.middle &&
969 hashed_process_data->x.middle_used))
10a1069a 970 {
1d1df11d 971 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
e72908ed 972 /* Draw collision indicator */
973 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 974 gdk_draw_point(hashed_process_data->pixmap,
e72908ed 975 drawing->gc,
976 x,
1c736ed5 977 (hashed_process_data->height/2)-3);
de4ea1ad 978 hashed_process_data->x.middle_marked = TRUE;
e72908ed 979 }
4b7dc462 980 /* jump */
981 } else {
982
983 DrawContext draw_context;
984 /* Now create the drawing context that will be used to draw
985 * items related to the last state. */
1c736ed5 986 draw_context.drawable = hashed_process_data->pixmap;
4b7dc462 987 draw_context.gc = drawing->gc;
988 draw_context.pango_layout = drawing->pango_layout;
9a1ec01b 989 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
4b7dc462 990 draw_context.drawinfo.end.x = x;
991
1c736ed5 992 draw_context.drawinfo.y.over = 1;
993 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
994 draw_context.drawinfo.y.under = hashed_process_data->height;
4b7dc462 995
996 draw_context.drawinfo.start.offset.over = 0;
997 draw_context.drawinfo.start.offset.middle = 0;
998 draw_context.drawinfo.start.offset.under = 0;
999 draw_context.drawinfo.end.offset.over = 0;
1000 draw_context.drawinfo.end.offset.middle = 0;
1001 draw_context.drawinfo.end.offset.under = 0;
1002
1003 {
1004 /* Draw the line */
9a1ec01b 1005 PropertiesLine prop_line = prepare_s_e_line(process);
4b7dc462 1006 draw_line((void*)&prop_line, (void*)&draw_context);
23093869 1007
4b7dc462 1008 }
1009 /* become the last x position */
9a1ec01b 1010 hashed_process_data->x.middle = x;
e72908ed 1011 hashed_process_data->x.middle_used = TRUE;
1012 hashed_process_data->x.middle_marked = FALSE;
b2743953 1013
1014 /* Calculate the next good time */
1015 convert_pixels_to_time(width, x+1, time_window,
1016 &hashed_process_data->next_good_time);
23093869 1017 }
1018 }
1019
1020 return 0;
1021}
1022
4a24fa1f 1023/* before_process_exit_hook
23093869 1024 *
4a24fa1f 1025 * Draw lines for process event.
1026 *
23093869 1027 * @param hook_data ControlFlowData structure of the viewer.
1028 * @param call_data Event context.
1029 *
1030 * This function adds items to be drawn in a queue for each process.
1031 *
1032 */
8869ac08 1033
1034
4a24fa1f 1035int before_process_exit_hook(void *hook_data, void *call_data)
1036{
2c82c4dc 1037 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
1038 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
4a24fa1f 1039
23093869 1040 ControlFlowData *control_flow_data = events_request->viewer_data;
1041
1042 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1043
1044 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
23093869 1045
4a24fa1f 1046 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1047
23093869 1048 LttEvent *e;
2c82c4dc 1049 e = ltt_tracefile_get_event(tfc->tf);
23093869 1050
1051 LttTime evtime = ltt_event_time(e);
23093869 1052
10a1069a 1053 /* Add process to process list (if not present) */
4a24fa1f 1054 //LttvProcessState *process = tfs->process;
1055 guint cpu = ltt_tracefile_num(tfc->tf);
1056 LttvProcessState *process = ts->running_process[cpu];
1057 guint pid = process->pid;
10a1069a 1058 LttTime birth;
1c736ed5 1059 guint pl_height = 0;
10a1069a 1060 HashedProcessData *hashed_process_data = NULL;
23093869 1061
5c230fc4 1062 ProcessList *process_list = control_flow_data->process_list;
4a24fa1f 1063
10a1069a 1064 g_assert(process != NULL);
23093869 1065
10a1069a 1066 birth = process->creation_time;
23093869 1067
4a24fa1f 1068 if(likely(process_list->current_hash_data[cpu] != NULL)) {
1069 hashed_process_data = process_list->current_hash_data[cpu];
40debf7b 1070 } else {
ac4e21cf 1071 hashed_process_data = processlist_get_process_data(process_list,
4a24fa1f 1072 pid,
1073 process->cpu,
1074 &birth,
1075 tfc->t_context->index);
1d1df11d 1076 if(unlikely(hashed_process_data == NULL))
40debf7b 1077 {
1078 g_assert(pid == 0 || pid != process->ppid);
1079 /* Process not present */
1c736ed5 1080 Drawing_t *drawing = control_flow_data->drawing;
40debf7b 1081 ProcessInfo *process_info;
1082 processlist_add(process_list,
1c736ed5 1083 drawing,
40debf7b 1084 pid,
4a24fa1f 1085 process->cpu,
40debf7b 1086 process->ppid,
1087 &birth,
1088 tfc->t_context->index,
4a24fa1f 1089 process->name,
40debf7b 1090 &pl_height,
1091 &process_info,
1092 &hashed_process_data);
4a24fa1f 1093 gtk_widget_set_size_request(drawing->drawing_area,
1094 -1,
1095 pl_height);
1096 gtk_widget_queue_draw(drawing->drawing_area);
40debf7b 1097 }
23093869 1098 }
40debf7b 1099
4a24fa1f 1100 /* Now, the process is in the state hash and our own process hash.
1101 * We definitely can draw the items related to the ending state.
1102 */
1103
1104 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1105 evtime) > 0))
b2743953 1106 {
4a24fa1f 1107 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1108 TimeWindow time_window =
1109 lttvwindow_get_time_window(control_flow_data->tab);
1110
1111#ifdef EXTRA_CHECK
1112 if(ltt_time_compare(evtime, time_window.start_time) == -1
1113 || ltt_time_compare(evtime, time_window.end_time) == 1)
1114 return;
1115#endif //EXTRA_CHECK
1116 Drawing_t *drawing = control_flow_data->drawing;
1117 guint width = drawing->width;
1118 guint x;
1119 convert_time_to_pixels(
1120 time_window,
1121 evtime,
1122 width,
1123 &x);
1124
1125 /* Draw collision indicator */
1126 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1127 gdk_draw_point(hashed_process_data->pixmap,
1128 drawing->gc,
1129 x,
1130 (hashed_process_data->height/2)-3);
1131 hashed_process_data->x.middle_marked = TRUE;
1132 }
1133 } else {
fd22065b 1134 TimeWindow time_window =
1135 lttvwindow_get_time_window(control_flow_data->tab);
1136
1137#ifdef EXTRA_CHECK
1138 if(ltt_time_compare(evtime, time_window.start_time) == -1
1139 || ltt_time_compare(evtime, time_window.end_time) == 1)
1140 return;
1141#endif //EXTRA_CHECK
d6fef890 1142 Drawing_t *drawing = control_flow_data->drawing;
1143 guint width = drawing->width;
4a24fa1f 1144 guint x;
1145
2c82c4dc 1146 convert_time_to_pixels(
1147 time_window,
1148 evtime,
1149 width,
1150 &x);
1151
b2743953 1152
2c82c4dc 1153 /* Jump over draw if we are at the same x position */
1154 if(unlikely(x == hashed_process_data->x.middle &&
1155 hashed_process_data->x.middle_used))
1156 {
1157 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
b2743953 1158 /* Draw collision indicator */
1159 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1c736ed5 1160 gdk_draw_point(hashed_process_data->pixmap,
b2743953 1161 drawing->gc,
1162 x,
1c736ed5 1163 (hashed_process_data->height/2)-3);
b2743953 1164 hashed_process_data->x.middle_marked = TRUE;
1165 }
2c82c4dc 1166 /* jump */
b2743953 1167 } else {
2c82c4dc 1168 DrawContext draw_context;
fd22065b 1169
2c82c4dc 1170 /* Now create the drawing context that will be used to draw
1171 * items related to the last state. */
1172 draw_context.drawable = hashed_process_data->pixmap;
1173 draw_context.gc = drawing->gc;
1174 draw_context.pango_layout = drawing->pango_layout;
1175 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1176 draw_context.drawinfo.end.x = x;
dbd243b1 1177
2c82c4dc 1178 draw_context.drawinfo.y.over = 1;
1179 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1180 draw_context.drawinfo.y.under = hashed_process_data->height;
dbd243b1 1181
2c82c4dc 1182 draw_context.drawinfo.start.offset.over = 0;
1183 draw_context.drawinfo.start.offset.middle = 0;
1184 draw_context.drawinfo.start.offset.under = 0;
1185 draw_context.drawinfo.end.offset.over = 0;
1186 draw_context.drawinfo.end.offset.middle = 0;
1187 draw_context.drawinfo.end.offset.under = 0;
dbd243b1 1188
2c82c4dc 1189 {
1190 /* Draw the line */
1191 PropertiesLine prop_line = prepare_s_e_line(process);
1192 draw_line((void*)&prop_line, (void*)&draw_context);
dbd243b1 1193
2c82c4dc 1194 }
1195 /* become the last x position */
1196 hashed_process_data->x.middle = x;
1197 hashed_process_data->x.middle_used = TRUE;
1198 hashed_process_data->x.middle_marked = FALSE;
dbd243b1 1199
2c82c4dc 1200 /* Calculate the next good time */
1201 convert_pixels_to_time(width, x+1, time_window,
1202 &hashed_process_data->next_good_time);
1203 }
1204 }
1205
1206 return 0;
1207
1208}
1209
1210
1211
1212/* before_process_release_hook
1213 *
1214 * Draw lines for process event.
1215 *
1216 * @param hook_data ControlFlowData structure of the viewer.
1217 * @param call_data Event context.
1218 *
1219 * This function adds items to be drawn in a queue for each process.
1220 *
1221 */
1222
1223
1224int before_process_release_hook(void *hook_data, void *call_data)
1225{
1226 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
1227 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
1228
1229 ControlFlowData *control_flow_data = events_request->viewer_data;
1230
1231 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1232
1233 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1234
348c6ba8 1235 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1236
2c82c4dc 1237 LttEvent *e;
1238 e = ltt_tracefile_get_event(tfc->tf);
1239
1240 LttTime evtime = ltt_event_time(e);
1241
1242
1243 guint pid;
1244 {
1245 pid = ltt_event_get_long_unsigned(e, thf->f1);
1246 }
1247
1248 /* Add process to process list (if not present) */
1249 /* Don't care about the process if it's not in the state hash already :
1250 * that means a process that has never done anything in the trace and
1251 * unknown suddently gets destroyed : no state meaningful to show. */
348c6ba8 1252 LttvProcessState *process = lttv_state_find_process(ts, ANY_CPU, pid);
2c82c4dc 1253
1254 if(process != NULL) {
1255 LttTime birth;
1256 guint pl_height = 0;
1257 HashedProcessData *hashed_process_data = NULL;
1258
1259 ProcessList *process_list = control_flow_data->process_list;
1260
1261 birth = process->creation_time;
1262
1263 /* Cannot use current process : this event happens on another process,
1264 * action done by the parent. */
1265 hashed_process_data = processlist_get_process_data(process_list,
1266 pid,
348c6ba8 1267 process->cpu,
2c82c4dc 1268 &birth,
1269 tfc->t_context->index);
1270 if(unlikely(hashed_process_data == NULL))
1271 {
1272 g_assert(pid == 0 || pid != process->ppid);
1273 /* Process not present */
1274 Drawing_t *drawing = control_flow_data->drawing;
2c82c4dc 1275 ProcessInfo *process_info;
1276 processlist_add(process_list,
1277 drawing,
1278 pid,
348c6ba8 1279 process->cpu,
2c82c4dc 1280 process->ppid,
1281 &birth,
1282 tfc->t_context->index,
f4b88a7d 1283 process->name,
2c82c4dc 1284 &pl_height,
1285 &process_info,
1286 &hashed_process_data);
1287 gtk_widget_set_size_request(drawing->drawing_area,
1288 -1,
1289 pl_height);
1290 gtk_widget_queue_draw(drawing->drawing_area);
1291 }
1292
1293 /* Now, the process is in the state hash and our own process hash.
1294 * We definitely can draw the items related to the ending state.
1295 */
1296
1297 if(likely(ltt_time_compare(hashed_process_data->next_good_time,
1298 evtime) > 0))
1299 {
1300 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
1301 TimeWindow time_window =
1302 lttvwindow_get_time_window(control_flow_data->tab);
1303
1304#ifdef EXTRA_CHECK
1305 if(ltt_time_compare(evtime, time_window.start_time) == -1
1306 || ltt_time_compare(evtime, time_window.end_time) == 1)
1307 return;
1308#endif //EXTRA_CHECK
1309 Drawing_t *drawing = control_flow_data->drawing;
1310 guint width = drawing->width;
1311 guint x;
1312 convert_time_to_pixels(
1313 time_window,
1314 evtime,
1315 width,
1316 &x);
1317
1318 /* Draw collision indicator */
1319 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1320 gdk_draw_point(hashed_process_data->pixmap,
1321 drawing->gc,
1322 x,
1323 (hashed_process_data->height/2)-3);
1324 hashed_process_data->x.middle_marked = TRUE;
1325 }
1326 } else {
1327 TimeWindow time_window =
1328 lttvwindow_get_time_window(control_flow_data->tab);
1329
1330#ifdef EXTRA_CHECK
1331 if(ltt_time_compare(evtime, time_window.start_time) == -1
4a24fa1f 1332 || ltt_time_compare(evtime, time_window.end_time) == 1)
1333 return;
2da61677 1334#endif //EXTRA_CHECK
4a24fa1f 1335 Drawing_t *drawing = control_flow_data->drawing;
1336 guint width = drawing->width;
1337 guint x;
1338
1339 convert_time_to_pixels(
1340 time_window,
1341 evtime,
1342 width,
1343 &x);
1344
2da61677 1345
4a24fa1f 1346 /* Jump over draw if we are at the same x position */
1347 if(unlikely(x == hashed_process_data->x.middle &&
1348 hashed_process_data->x.middle_used))
1349 {
1350 if(unlikely(hashed_process_data->x.middle_marked == FALSE)) {
2da61677 1351 /* Draw collision indicator */
1352 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
1353 gdk_draw_point(hashed_process_data->pixmap,
1354 drawing->gc,
1355 x,
1356 (hashed_process_data->height/2)-3);
1357 hashed_process_data->x.middle_marked = TRUE;
1358 }
4a24fa1f 1359 /* jump */
2da61677 1360 } else {
4a24fa1f 1361 DrawContext draw_context;
2da61677 1362
4a24fa1f 1363 /* Now create the drawing context that will be used to draw
1364 * items related to the last state. */
1365 draw_context.drawable = hashed_process_data->pixmap;
1366 draw_context.gc = drawing->gc;
1367 draw_context.pango_layout = drawing->pango_layout;
1368 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
1369 draw_context.drawinfo.end.x = x;
2da61677 1370
4a24fa1f 1371 draw_context.drawinfo.y.over = 1;
1372 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
1373 draw_context.drawinfo.y.under = hashed_process_data->height;
2da61677 1374
4a24fa1f 1375 draw_context.drawinfo.start.offset.over = 0;
1376 draw_context.drawinfo.start.offset.middle = 0;
1377 draw_context.drawinfo.start.offset.under = 0;
1378 draw_context.drawinfo.end.offset.over = 0;
1379 draw_context.drawinfo.end.offset.middle = 0;
1380 draw_context.drawinfo.end.offset.under = 0;
2da61677 1381
4a24fa1f 1382 {
1383 /* Draw the line */
1384 PropertiesLine prop_line = prepare_s_e_line(process);
1385 draw_line((void*)&prop_line, (void*)&draw_context);
2da61677 1386
2da61677 1387 }
4a24fa1f 1388 /* become the last x position */
1389 hashed_process_data->x.middle = x;
1390 hashed_process_data->x.middle_used = TRUE;
1391 hashed_process_data->x.middle_marked = FALSE;
1392
1393 /* Calculate the next good time */
1394 convert_pixels_to_time(width, x+1, time_window,
1395 &hashed_process_data->next_good_time);
2da61677 1396 }
1397 }
dbd243b1 1398 }
dbd243b1 1399
4a24fa1f 1400 return 0;
dbd243b1 1401}
1402
4a24fa1f 1403
2c82c4dc 1404
1405
1406
1407/* after_process_fork_hook
1408 *
1409 * Create the processlist entry for the child process. Put the last
1410 * position in x at the current time value.
1411 *
1412 * @param hook_data ControlFlowData structure of the viewer.
1413 * @param call_data Event context.
1414 *
1415 * This function adds items to be drawn in a queue for each process.
1416 *
1417 */
1418int after_process_fork_hook(void *hook_data, void *call_data)
1419{
1420 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
1421 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
1422 ControlFlowData *control_flow_data = events_request->viewer_data;
1423
1424 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1425
1426 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1427
348c6ba8 1428 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1429
2c82c4dc 1430 LttEvent *e;
1431 e = ltt_tracefile_get_event(tfc->tf);
1432
1433 LttTime evtime = ltt_event_time(e);
1434
1435 guint child_pid;
1436 {
1437 child_pid = ltt_event_get_long_unsigned(e, thf->f2);
1438 }
1439
1440 /* Add process to process list (if not present) */
1441 LttvProcessState *process_child;
1442 LttTime birth;
1443 guint pl_height = 0;
1444 HashedProcessData *hashed_process_data_child = NULL;
1445
1446 ProcessList *process_list = control_flow_data->process_list;
1447
1448 /* Find child in the list... */
348c6ba8 1449 process_child = lttv_state_find_process(ts, ANY_CPU, child_pid);
2c82c4dc 1450 /* It should exist, because we are after the state update. */
1451 g_assert(process_child != NULL);
1452
1453 birth = process_child->creation_time;
1454
1455 /* Cannot use current process, because this action is done by the parent
1456 * on its child. */
1457 hashed_process_data_child = processlist_get_process_data(process_list,
1458 child_pid,
348c6ba8 1459 process_child->cpu,
2c82c4dc 1460 &birth,
1461 tfc->t_context->index);
1462 if(likely(hashed_process_data_child == NULL))
1463 {
1464 g_assert(child_pid == 0 || child_pid != process_child->ppid);
1465 /* Process not present */
1466 Drawing_t *drawing = control_flow_data->drawing;
2c82c4dc 1467 ProcessInfo *process_info;
1468 processlist_add(process_list,
1469 drawing,
1470 child_pid,
348c6ba8 1471 process_child->cpu,
2c82c4dc 1472 process_child->ppid,
1473 &birth,
1474 tfc->t_context->index,
f4b88a7d 1475 process_child->name,
2c82c4dc 1476 &pl_height,
1477 &process_info,
1478 &hashed_process_data_child);
1479 gtk_widget_set_size_request(drawing->drawing_area,
1480 -1,
1481 pl_height);
1482 gtk_widget_queue_draw(drawing->drawing_area);
1483 }
1484
1485
1486 if(likely(ltt_time_compare(hashed_process_data_child->next_good_time,
1487 evtime) <= 0))
1488 {
1489 TimeWindow time_window =
1490 lttvwindow_get_time_window(control_flow_data->tab);
1491
1492#ifdef EXTRA_CHECK
1493 if(ltt_time_compare(evtime, time_window.start_time) == -1
1494 || ltt_time_compare(evtime, time_window.end_time) == 1)
1495 return;
1496#endif //EXTRA_CHECK
1497 Drawing_t *drawing = control_flow_data->drawing;
1498 guint width = drawing->width;
1499 guint new_x;
1500 convert_time_to_pixels(
1501 time_window,
1502 evtime,
1503 width,
1504 &new_x);
1505
1506 if(likely(hashed_process_data_child->x.over != new_x)) {
1507 hashed_process_data_child->x.over = new_x;
1508 hashed_process_data_child->x.over_used = FALSE;
1509 hashed_process_data_child->x.over_marked = FALSE;
1510 }
1511 if(likely(hashed_process_data_child->x.middle != new_x)) {
1512 hashed_process_data_child->x.middle = new_x;
1513 hashed_process_data_child->x.middle_used = FALSE;
1514 hashed_process_data_child->x.middle_marked = FALSE;
1515 }
1516 if(likely(hashed_process_data_child->x.under != new_x)) {
1517 hashed_process_data_child->x.under = new_x;
1518 hashed_process_data_child->x.under_used = FALSE;
1519 hashed_process_data_child->x.under_marked = FALSE;
1520 }
1521 }
1522 return 0;
1523}
1524
1525
1526
1527/* after_process_exit_hook
1528 *
1529 * Create the processlist entry for the child process. Put the last
1530 * position in x at the current time value.
1531 *
1532 * @param hook_data ControlFlowData structure of the viewer.
1533 * @param call_data Event context.
1534 *
1535 * This function adds items to be drawn in a queue for each process.
1536 *
1537 */
1538int after_process_exit_hook(void *hook_data, void *call_data)
1539{
1540 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
1541 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
1542 ControlFlowData *control_flow_data = events_request->viewer_data;
1543
1544 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1545
1546 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1547
348c6ba8 1548 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1549
2c82c4dc 1550 LttEvent *e;
1551 e = ltt_tracefile_get_event(tfc->tf);
1552
1553 LttTime evtime = ltt_event_time(e);
1554
1555 /* Add process to process list (if not present) */
348c6ba8 1556 //LttvProcessState *process = tfs->process;
1557 guint cpu = ltt_tracefile_num(tfc->tf);
1558 LttvProcessState *process = ts->running_process[cpu];
1559
1560 /* It should exist, because we are after the state update. */
1561 g_assert(process != NULL);
1562
2c82c4dc 1563 guint pid = process->pid;
1564 LttTime birth;
1565 guint pl_height = 0;
1566 HashedProcessData *hashed_process_data = NULL;
1567
1568 ProcessList *process_list = control_flow_data->process_list;
1569
2c82c4dc 1570 birth = process->creation_time;
1571
348c6ba8 1572 if(likely(process_list->current_hash_data[cpu] != NULL) ){
1573 hashed_process_data = process_list->current_hash_data[cpu];
2c82c4dc 1574 } else {
1575 hashed_process_data = processlist_get_process_data(process_list,
1576 pid,
348c6ba8 1577 process->cpu,
2c82c4dc 1578 &birth,
1579 tfc->t_context->index);
1580 if(unlikely(hashed_process_data == NULL))
1581 {
1582 g_assert(pid == 0 || pid != process->ppid);
1583 /* Process not present */
1584 Drawing_t *drawing = control_flow_data->drawing;
2c82c4dc 1585 ProcessInfo *process_info;
1586 processlist_add(process_list,
1587 drawing,
1588 pid,
348c6ba8 1589 process->cpu,
2c82c4dc 1590 process->ppid,
1591 &birth,
1592 tfc->t_context->index,
f4b88a7d 1593 process->name,
2c82c4dc 1594 &pl_height,
1595 &process_info,
1596 &hashed_process_data);
1597 gtk_widget_set_size_request(drawing->drawing_area,
1598 -1,
1599 pl_height);
1600 gtk_widget_queue_draw(drawing->drawing_area);
1601 }
1602
1603 /* Set the current process */
348c6ba8 1604 process_list->current_hash_data[process->cpu] =
2c82c4dc 1605 hashed_process_data;
1606 }
1607
1608 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
1609 evtime) <= 0))
1610 {
1611 TimeWindow time_window =
1612 lttvwindow_get_time_window(control_flow_data->tab);
dbd243b1 1613
2c82c4dc 1614#ifdef EXTRA_CHECK
1615 if(ltt_time_compare(evtime, time_window.start_time) == -1
1616 || ltt_time_compare(evtime, time_window.end_time) == 1)
1617 return;
1618#endif //EXTRA_CHECK
1619 Drawing_t *drawing = control_flow_data->drawing;
1620 guint width = drawing->width;
1621 guint new_x;
1622 convert_time_to_pixels(
1623 time_window,
1624 evtime,
1625 width,
1626 &new_x);
1627 if(unlikely(hashed_process_data->x.middle != new_x)) {
1628 hashed_process_data->x.middle = new_x;
1629 hashed_process_data->x.middle_used = FALSE;
1630 hashed_process_data->x.middle_marked = FALSE;
1631 }
1632 }
dbd243b1 1633
2c82c4dc 1634 return 0;
1635}
dbd243b1 1636
1637
f4b88a7d 1638/* Get the filename of the process to print */
1639int after_fs_exec_hook(void *hook_data, void *call_data)
1640{
1641 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
1642 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
1643 ControlFlowData *control_flow_data = events_request->viewer_data;
1644
1645 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1646
1647 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1648
1649 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1650
1651 guint cpu = ltt_tracefile_num(tfc->tf);
1652 LttvProcessState *process = ts->running_process[cpu];
1653 g_assert(process != NULL);
1654
1655 guint pid = process->pid;
1656
1657 /* Well, the process_out existed : we must get it in the process hash
1658 * or add it, and draw its items.
1659 */
1660 /* Add process to process list (if not present) */
1661 guint pl_height = 0;
1662 HashedProcessData *hashed_process_data = NULL;
1663 ProcessList *process_list = control_flow_data->process_list;
1664 LttTime birth = process->creation_time;
1665
1666 if(likely(process_list->current_hash_data[cpu] != NULL)) {
1667 hashed_process_data = process_list->current_hash_data[cpu];
1668 } else {
1669 hashed_process_data = processlist_get_process_data(process_list,
1670 pid,
1671 process->cpu,
1672 &birth,
1673 tfc->t_context->index);
1674 if(unlikely(hashed_process_data == NULL))
1675 {
1676 g_assert(pid == 0 || pid != process->ppid);
1677 ProcessInfo *process_info;
1678 /* Process not present */
1679 Drawing_t *drawing = control_flow_data->drawing;
1680 processlist_add(process_list,
1681 drawing,
1682 pid,
1683 process->cpu,
1684 process->ppid,
1685 &birth,
1686 tfc->t_context->index,
1687 process->name,
1688 &pl_height,
1689 &process_info,
1690 &hashed_process_data);
1691 gtk_widget_set_size_request(drawing->drawing_area,
1692 -1,
1693 pl_height);
1694 gtk_widget_queue_draw(drawing->drawing_area);
1695 }
1696 /* Set the current process */
1697 process_list->current_hash_data[process->cpu] =
1698 hashed_process_data;
1699 }
1700
1701 processlist_set_name(process_list, process->name, hashed_process_data);
1702
1703 return 0;
1704
1705}
1706
b3fd4c02 1707/* after_event_enum_process_hook
1708 *
b3fd4c02 1709 * Create the processlist entry for the child process. Put the last
1710 * position in x at the current time value.
1711 *
1712 * @param hook_data ControlFlowData structure of the viewer.
1713 * @param call_data Event context.
1714 *
1715 * This function adds items to be drawn in a queue for each process.
1716 *
1717 */
1718int after_event_enum_process_hook(void *hook_data, void *call_data)
1719{
1720 LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data;
1721 EventsRequest *events_request = (EventsRequest*)thf->hook_data;
1722 ControlFlowData *control_flow_data = events_request->viewer_data;
1723
1724 LttvTracefileContext *tfc = (LttvTracefileContext *)call_data;
1725
1726 LttvTracefileState *tfs = (LttvTracefileState *)call_data;
1727
1728 LttvTraceState *ts = (LttvTraceState *)tfc->t_context;
1729
1730 LttEvent *e;
1731 e = ltt_tracefile_get_event(tfc->tf);
1732
1733 LttTime evtime = ltt_event_time(e);
1734
1735 /* Add process to process list (if not present) */
1736 LttvProcessState *process_in;
1737 LttTime birth;
1738 guint pl_height = 0;
1739 HashedProcessData *hashed_process_data_in = NULL;
1740
1741 ProcessList *process_list = control_flow_data->process_list;
1742
1743 guint pid_in;
1744 {
1745 pid_in = ltt_event_get_long_unsigned(e, thf->f1);
1746 }
1747
1748
1749 /* Find process pid_in in the list... */
1750 process_in = lttv_state_find_process(ts, ANY_CPU, pid_in);
1751 //process_in = tfs->process;
1752 //guint cpu = ltt_tracefile_num(tfc->tf);
1753 //process_in = ts->running_process[cpu];
1754 /* It should exist, because we are after the state update. */
1755#ifdef EXTRA_CHECK
1756 //g_assert(process_in != NULL);
1757#endif //EXTRA_CHECK
1758 birth = process_in->creation_time;
1759
1760 hashed_process_data_in = processlist_get_process_data(process_list,
1761 pid_in,
1762 process_in->cpu,
1763 &birth,
1764 tfc->t_context->index);
1765 if(hashed_process_data_in == NULL)
1766 {
1767 if(pid_in != 0 && pid_in == process_in->ppid)
1768 g_critical("TEST %u , %u", pid_in, process_in->ppid);
1769 g_assert(pid_in == 0 || pid_in != process_in->ppid);
1770 ProcessInfo *process_info;
1771 Drawing_t *drawing = control_flow_data->drawing;
1772 /* Process not present */
1773 processlist_add(process_list,
1774 drawing,
1775 pid_in,
1776 process_in->cpu,
1777 process_in->ppid,
1778 &birth,
1779 tfc->t_context->index,
1780 process_in->name,
1781 &pl_height,
1782 &process_info,
1783 &hashed_process_data_in);
1784 gtk_widget_set_size_request(drawing->drawing_area,
1785 -1,
1786 pl_height);
1787 gtk_widget_queue_draw(drawing->drawing_area);
1fc7847f 1788 } else {
1789 processlist_set_name(process_list, process_in->name,
1790 hashed_process_data_in);
1791 processlist_set_ppid(process_list, process_in->ppid,
1792 hashed_process_data_in);
1793 }
b3fd4c02 1794 return 0;
1795}
f4b88a7d 1796
1797
1b238973 1798gint update_time_window_hook(void *hook_data, void *call_data)
f7afe191 1799{
a56a1ba4 1800 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
a43d67ba 1801 Drawing_t *drawing = control_flow_data->drawing;
1c736ed5 1802 ProcessList *process_list = control_flow_data->process_list;
a43d67ba 1803
224446ce 1804 const TimeWindowNotifyData *time_window_nofify_data =
1805 ((const TimeWindowNotifyData *)call_data);
1806
14963be0 1807 TimeWindow *old_time_window =
224446ce 1808 time_window_nofify_data->old_time_window;
1809 TimeWindow *new_time_window =
1810 time_window_nofify_data->new_time_window;
a56a1ba4 1811
3cb8b205 1812 /* Update the ruler */
1813 drawing_update_ruler(control_flow_data->drawing,
1814 new_time_window);
1815
1816
a56a1ba4 1817 /* Two cases : zoom in/out or scrolling */
1818
1819 /* In order to make sure we can reuse the old drawing, the scale must
1820 * be the same and the new time interval being partly located in the
1821 * currently shown time interval. (reuse is only for scrolling)
1822 */
1823
2eef04b5 1824 g_info("Old time window HOOK : %lu, %lu to %lu, %lu",
14963be0 1825 old_time_window->start_time.tv_sec,
1826 old_time_window->start_time.tv_nsec,
1827 old_time_window->time_width.tv_sec,
1828 old_time_window->time_width.tv_nsec);
a56a1ba4 1829
2eef04b5 1830 g_info("New time window HOOK : %lu, %lu to %lu, %lu",
14963be0 1831 new_time_window->start_time.tv_sec,
1832 new_time_window->start_time.tv_nsec,
1833 new_time_window->time_width.tv_sec,
1834 new_time_window->time_width.tv_nsec);
a56a1ba4 1835
14963be0 1836 if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec
1837 && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec)
a56a1ba4 1838 {
1839 /* Same scale (scrolling) */
1840 g_info("scrolling");
14963be0 1841 LttTime *ns = &new_time_window->start_time;
20640e70 1842 LttTime *nw = &new_time_window->time_width;
14963be0 1843 LttTime *os = &old_time_window->start_time;
20640e70 1844 LttTime *ow = &old_time_window->time_width;
6f26fc38 1845 LttTime old_end = old_time_window->end_time;
1846 LttTime new_end = new_time_window->end_time;
a56a1ba4 1847 //if(ns<os+w<ns+w)
1848 //if(ns<os+w && os+w<ns+w)
1849 //if(ns<old_end && os<ns)
1850 if(ltt_time_compare(*ns, old_end) == -1
1851 && ltt_time_compare(*os, *ns) == -1)
1852 {
1853 g_info("scrolling near right");
1854 /* Scroll right, keep right part of the screen */
1855 guint x = 0;
51705146 1856 guint width = control_flow_data->drawing->width;
a56a1ba4 1857 convert_time_to_pixels(
a18124ff 1858 *old_time_window,
a56a1ba4 1859 *ns,
1860 width,
1861 &x);
1862
1863 /* Copy old data to new location */
1c736ed5 1864 copy_pixmap_region(process_list,
1865 NULL,
1866 control_flow_data->drawing->drawing_area->style->black_gc,
1867 NULL,
1868 x, 0,
1869 0, 0,
1870 control_flow_data->drawing->width-x+SAFETY, -1);
1871
6395d57c 1872 if(drawing->damage_begin == drawing->damage_end)
1873 drawing->damage_begin = control_flow_data->drawing->width-x;
1874 else
1875 drawing->damage_begin = 0;
1876
1877 drawing->damage_end = control_flow_data->drawing->width;
1878
a56a1ba4 1879 /* Clear the data request background, but not SAFETY */
1c736ed5 1880 rectangle_pixmap(process_list,
cfe526b1 1881 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1882 TRUE,
6395d57c 1883 drawing->damage_begin+SAFETY, 0,
1884 drawing->damage_end - drawing->damage_begin, // do not overlap
1c736ed5 1885 -1);
7abb23ad 1886 gtk_widget_queue_draw(drawing->drawing_area);
1887 //gtk_widget_queue_draw_area (drawing->drawing_area,
1888 // 0,0,
1889 // control_flow_data->drawing->width,
1890 // control_flow_data->drawing->height);
a43d67ba 1891
a56a1ba4 1892 /* Get new data for the rest. */
501d5405 1893 drawing_data_request(control_flow_data->drawing,
6395d57c 1894 drawing->damage_begin, 0,
1895 drawing->damage_end - drawing->damage_begin,
501d5405 1896 control_flow_data->drawing->height);
a56a1ba4 1897 } else {
1898 //if(ns<os<ns+w)
1899 //if(ns<os && os<ns+w)
1900 //if(ns<os && os<new_end)
1901 if(ltt_time_compare(*ns,*os) == -1
1902 && ltt_time_compare(*os,new_end) == -1)
1903 {
1904 g_info("scrolling near left");
1905 /* Scroll left, keep left part of the screen */
1906 guint x = 0;
51705146 1907 guint width = control_flow_data->drawing->width;
a56a1ba4 1908 convert_time_to_pixels(
a18124ff 1909 *new_time_window,
a56a1ba4 1910 *os,
1911 width,
1912 &x);
6395d57c 1913
a56a1ba4 1914 /* Copy old data to new location */
1c736ed5 1915 copy_pixmap_region (process_list,
1916 NULL,
cfe526b1 1917 control_flow_data->drawing->drawing_area->style->black_gc,
1c736ed5 1918 NULL,
a56a1ba4 1919 0, 0,
1920 x, 0,
1921 -1, -1);
1922
6395d57c 1923 if(drawing->damage_begin == drawing->damage_end)
1924 drawing->damage_end = x;
1925 else
1926 drawing->damage_end =
51705146 1927 control_flow_data->drawing->width;
6395d57c 1928
1929 drawing->damage_begin = 0;
1930
1c736ed5 1931 rectangle_pixmap (process_list,
cfe526b1 1932 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1933 TRUE,
6395d57c 1934 drawing->damage_begin, 0,
1935 drawing->damage_end - drawing->damage_begin, // do not overlap
1c736ed5 1936 -1);
a43d67ba 1937
7abb23ad 1938 gtk_widget_queue_draw(drawing->drawing_area);
1939 //gtk_widget_queue_draw_area (drawing->drawing_area,
1940 // 0,0,
1941 // control_flow_data->drawing->width,
1942 // control_flow_data->drawing->height);
a43d67ba 1943
6395d57c 1944
a56a1ba4 1945 /* Get new data for the rest. */
501d5405 1946 drawing_data_request(control_flow_data->drawing,
6395d57c 1947 drawing->damage_begin, 0,
1948 drawing->damage_end - drawing->damage_begin,
501d5405 1949 control_flow_data->drawing->height);
a56a1ba4 1950
a56a1ba4 1951 } else {
a43d67ba 1952 if(ltt_time_compare(*ns,*os) == 0)
1953 {
1954 g_info("not scrolling");
1955 } else {
1956 g_info("scrolling far");
1957 /* Cannot reuse any part of the screen : far jump */
1958
1959
1c736ed5 1960 rectangle_pixmap (process_list,
a43d67ba 1961 control_flow_data->drawing->drawing_area->style->black_gc,
1962 TRUE,
a56a1ba4 1963 0, 0,
a43d67ba 1964 control_flow_data->drawing->width+SAFETY, // do not overlap
1c736ed5 1965 -1);
a43d67ba 1966
7abb23ad 1967 //gtk_widget_queue_draw_area (drawing->drawing_area,
1968 // 0,0,
1969 // control_flow_data->drawing->width,
1970 // control_flow_data->drawing->height);
1971 gtk_widget_queue_draw(drawing->drawing_area);
a43d67ba 1972
6395d57c 1973 drawing->damage_begin = 0;
1974 drawing->damage_end = control_flow_data->drawing->width;
1975
a43d67ba 1976 drawing_data_request(control_flow_data->drawing,
a43d67ba 1977 0, 0,
1978 control_flow_data->drawing->width,
1979 control_flow_data->drawing->height);
1980
1981 }
a56a1ba4 1982 }
1983 }
1984 } else {
1985 /* Different scale (zoom) */
1986 g_info("zoom");
1987
1c736ed5 1988 rectangle_pixmap (process_list,
cfe526b1 1989 control_flow_data->drawing->drawing_area->style->black_gc,
a56a1ba4 1990 TRUE,
1991 0, 0,
501d5405 1992 control_flow_data->drawing->width+SAFETY, // do not overlap
1c736ed5 1993 -1);
a56a1ba4 1994
7abb23ad 1995 //gtk_widget_queue_draw_area (drawing->drawing_area,
1996 // 0,0,
1997 // control_flow_data->drawing->width,
1998 // control_flow_data->drawing->height);
1999 gtk_widget_queue_draw(drawing->drawing_area);
a56a1ba4 2000
6395d57c 2001 drawing->damage_begin = 0;
2002 drawing->damage_end = control_flow_data->drawing->width;
2003
501d5405 2004 drawing_data_request(control_flow_data->drawing,
a56a1ba4 2005 0, 0,
501d5405 2006 control_flow_data->drawing->width,
2007 control_flow_data->drawing->height);
a56a1ba4 2008 }
2009
15f77e3b 2010 /* Update directly when scrolling */
2011 gdk_window_process_updates(control_flow_data->drawing->drawing_area->window,
2012 TRUE);
3cb8b205 2013
a56a1ba4 2014 return 0;
f7afe191 2015}
2016
6395d57c 2017gint traceset_notify(void *hook_data, void *call_data)
2018{
2019 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2020 Drawing_t *drawing = control_flow_data->drawing;
6395d57c 2021
6cec4cd2 2022 if(unlikely(drawing->gc == NULL)) {
2023 return FALSE;
2024 }
2025 if(drawing->dotted_gc == NULL) {
2026 return FALSE;
2027 }
6395d57c 2028
b9a010a2 2029 drawing_clear(control_flow_data->drawing);
2030 processlist_clear(control_flow_data->process_list);
07390ec1 2031 gtk_widget_set_size_request(
2032 control_flow_data->drawing->drawing_area,
2033 -1, processlist_get_height(control_flow_data->process_list));
d9267eec 2034 redraw_notify(control_flow_data, NULL);
6395d57c 2035
d9267eec 2036 request_background_data(control_flow_data);
6395d57c 2037
2038 return FALSE;
2039}
2040
ca0f8a8e 2041gint redraw_notify(void *hook_data, void *call_data)
2042{
2043 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
2044 Drawing_t *drawing = control_flow_data->drawing;
2045 GtkWidget *widget = drawing->drawing_area;
2046
2047 drawing->damage_begin = 0;
51705146 2048 drawing->damage_end = drawing->width;
ca0f8a8e 2049
49217bd4 2050 /* fun feature, to be separated someday... */
2051 drawing_clear(control_flow_data->drawing);
2052 processlist_clear(control_flow_data->process_list);
07390ec1 2053 gtk_widget_set_size_request(
2054 control_flow_data->drawing->drawing_area,
2055 -1, processlist_get_height(control_flow_data->process_list));
1c736ed5 2056 // Clear the images
2057 rectangle_pixmap (control_flow_data->process_list,
ca0f8a8e 2058 widget->style->black_gc,
2059 TRUE,
2060 0, 0,
f3b7430d 2061 drawing->alloc_width,
1c736ed5 2062 -1);
ca0f8a8e 2063
f3b7430d 2064 gtk_widget_queue_draw(drawing->drawing_area);
4a24fa1f 2065
ca0f8a8e 2066 if(drawing->damage_begin < drawing->damage_end)
2067 {
2068 drawing_data_request(drawing,
ca0f8a8e 2069 drawing->damage_begin,
2070 0,
2071 drawing->damage_end-drawing->damage_begin,
51705146 2072 drawing->height);
ca0f8a8e 2073 }
2074
7abb23ad 2075 //gtk_widget_queue_draw_area(drawing->drawing_area,
2076 // 0,0,
2077 // drawing->width,
2078 // drawing->height);
ca0f8a8e 2079 return FALSE;
2080
2081}
2082
2083
2084gint continue_notify(void *hook_data, void *call_data)
a43d67ba 2085{
2086 ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
ca0f8a8e 2087 Drawing_t *drawing = control_flow_data->drawing;
a43d67ba 2088
6395d57c 2089 //g_assert(widget->allocation.width == drawing->damage_end);
ca0f8a8e 2090
2091 if(drawing->damage_begin < drawing->damage_end)
2092 {
2093 drawing_data_request(drawing,
ca0f8a8e 2094 drawing->damage_begin,
2095 0,
2096 drawing->damage_end-drawing->damage_begin,
51705146 2097 drawing->height);
ca0f8a8e 2098 }
2099
2100 return FALSE;
2101}
2102
2103
1b238973 2104gint update_current_time_hook(void *hook_data, void *call_data)
f7afe191 2105{
14963be0 2106 ControlFlowData *control_flow_data = (ControlFlowData*)hook_data;
a43d67ba 2107 Drawing_t *drawing = control_flow_data->drawing;
a56a1ba4 2108
224446ce 2109 LttTime current_time = *((LttTime*)call_data);
a56a1ba4 2110
ca0f8a8e 2111 TimeWindow time_window =
2112 lttvwindow_get_time_window(control_flow_data->tab);
a56a1ba4 2113
ca0f8a8e 2114 LttTime time_begin = time_window.start_time;
2115 LttTime width = time_window.time_width;
90ef7e4a 2116 LttTime half_width;
2117 {
2118 guint64 time_ll = ltt_time_to_uint64(width);
2119 time_ll = time_ll >> 1; /* divide by two */
2120 half_width = ltt_time_from_uint64(time_ll);
2121 }
a56a1ba4 2122 LttTime time_end = ltt_time_add(time_begin, width);
2123
2124 LttvTracesetContext * tsc =
ca0f8a8e 2125 lttvwindow_get_traceset_context(control_flow_data->tab);
a56a1ba4 2126
ca0f8a8e 2127 LttTime trace_start = tsc->time_span.start_time;
2128 LttTime trace_end = tsc->time_span.end_time;
a56a1ba4 2129
2eef04b5 2130 g_info("New current time HOOK : %lu, %lu", current_time.tv_sec,
224446ce 2131 current_time.tv_nsec);
a56a1ba4 2132
2133
2134
2135 /* If current time is inside time interval, just move the highlight
2136 * bar */
2137
2138 /* Else, we have to change the time interval. We have to tell it
2139 * to the main window. */
2140 /* The time interval change will take care of placing the current
2141 * time at the center of the visible area, or nearest possible if we are
2142 * at one end of the trace. */
2143
2144
dbc0ef8a 2145 if(ltt_time_compare(current_time, time_begin) < 0)
a56a1ba4 2146 {
224446ce 2147 TimeWindow new_time_window;
2148
2149 if(ltt_time_compare(current_time,
dbc0ef8a 2150 ltt_time_add(trace_start,half_width)) < 0)
a56a1ba4 2151 time_begin = trace_start;
2152 else
224446ce 2153 time_begin = ltt_time_sub(current_time,half_width);
a56a1ba4 2154
224446ce 2155 new_time_window.start_time = time_begin;
2156 new_time_window.time_width = width;
a18124ff 2157 new_time_window.time_width_double = ltt_time_to_double(width);
6f26fc38 2158 new_time_window.end_time = ltt_time_add(time_begin, width);
a56a1ba4 2159
e800cf84 2160 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
a56a1ba4 2161 }
dbc0ef8a 2162 else if(ltt_time_compare(current_time, time_end) > 0)
a56a1ba4 2163 {
224446ce 2164 TimeWindow new_time_window;
2165
dbc0ef8a 2166 if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0)
a56a1ba4 2167 time_begin = ltt_time_sub(trace_end,width);
2168 else
224446ce 2169 time_begin = ltt_time_sub(current_time,half_width);
a56a1ba4 2170
224446ce 2171 new_time_window.start_time = time_begin;
2172 new_time_window.time_width = width;
a18124ff 2173 new_time_window.time_width_double = ltt_time_to_double(width);
6f26fc38 2174 new_time_window.end_time = ltt_time_add(time_begin, width);
a56a1ba4 2175
e800cf84 2176 lttvwindow_report_time_window(control_flow_data->tab, new_time_window);
a56a1ba4 2177
2178 }
7abb23ad 2179 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
a56a1ba4 2180
15f77e3b 2181 /* Update directly when scrolling */
2182 gdk_window_process_updates(control_flow_data->drawing->drawing_area->window,
2183 TRUE);
2184
a56a1ba4 2185 return 0;
f7afe191 2186}
2187
8b90e648 2188typedef struct _ClosureData {
ca0f8a8e 2189 EventsRequest *events_request;
d0cd7f09 2190 LttvTracesetState *tss;
b9a010a2 2191 LttTime end_time;
bc8d270b 2192 guint x_end;
8b90e648 2193} ClosureData;
a56a1ba4 2194
8b90e648 2195
e800cf84 2196void draw_closure(gpointer key, gpointer value, gpointer user_data)
2197{
a56a1ba4 2198 ProcessInfo *process_info = (ProcessInfo*)key;
2199 HashedProcessData *hashed_process_data = (HashedProcessData*)value;
2200 ClosureData *closure_data = (ClosureData*)user_data;
2201
e800cf84 2202 EventsRequest *events_request = closure_data->events_request;
2203 ControlFlowData *control_flow_data = events_request->viewer_data;
a56a1ba4 2204
e800cf84 2205 LttvTracesetState *tss = closure_data->tss;
d6fef890 2206 LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
a56a1ba4 2207
e800cf84 2208 LttTime evtime = closure_data->end_time;
d0cd7f09 2209
e800cf84 2210 {
2211 /* For the process */
2212 /* First, check if the current process is in the state computation
2213 * process list. If it is there, that means we must add it right now and
2214 * draw items from the beginning of the read for it. If it is not
2215 * present, it's a new process and it was not present : it will
2216 * be added after the state update. */
31b6868d 2217#ifdef EXTRA_CHECK
e800cf84 2218 g_assert(lttv_traceset_number(tsc->ts) > 0);
31b6868d 2219#endif //EXTRA_CHECK
2c82c4dc 2220 LttvTraceContext *tc = tsc->traces[process_info->trace_num];
348c6ba8 2221 LttvTraceState *ts = (LttvTraceState*)tc;
2c82c4dc 2222
348c6ba8 2223#if 0
2c82c4dc 2224 //FIXME : optimize data structures.
2225 LttvTracefileState *tfs;
2226 LttvTracefileContext *tfc;
2227 guint i;
2228 for(i=0;i<tc->tracefiles->len;i++) {
2229 tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i);
2230 if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU
2231 && ltt_tracefile_num(tfc->tf) == process_info->cpu)
2232 break;
2233
2234 }
2235 g_assert(i<tc->tracefiles->len);
2236 tfs = LTTV_TRACEFILE_STATE(tfc);
348c6ba8 2237#endif //0
2c82c4dc 2238 // LttvTracefileState *tfs =
2239 // (LttvTracefileState*)tsc->traces[process_info->trace_num]->
2240 // tracefiles[process_info->cpu];
2da61677 2241
e800cf84 2242 LttvProcessState *process;
348c6ba8 2243 process = lttv_state_find_process(ts, process_info->cpu,
e025a729 2244 process_info->pid);
a56a1ba4 2245
1d1df11d 2246 if(unlikely(process != NULL)) {
e800cf84 2247
2248 /* Only draw for processes that are currently in the trace states */
ad2e83ba 2249
5c230fc4 2250 ProcessList *process_list = control_flow_data->process_list;
1d1df11d 2251#ifdef EXTRA_CHECK
e800cf84 2252 /* Should be alike when background info is ready */
2253 if(control_flow_data->background_info_waiting==0)
2254 g_assert(ltt_time_compare(process->creation_time,
2255 process_info->birth) == 0);
1d1df11d 2256#endif //EXTRA_CHECK
e800cf84 2257
2258 /* Now, the process is in the state hash and our own process hash.
2259 * We definitely can draw the items related to the ending state.
2260 */
2261
1d1df11d 2262 if(unlikely(ltt_time_compare(hashed_process_data->next_good_time,
2263 evtime) <= 0))
e800cf84 2264 {
fd22065b 2265 TimeWindow time_window =
2266 lttvwindow_get_time_window(control_flow_data->tab);
2267
2268#ifdef EXTRA_CHECK
2269 if(ltt_time_compare(evtime, time_window.start_time) == -1
2270 || ltt_time_compare(evtime, time_window.end_time) == 1)
2271 return;
2272#endif //EXTRA_CHECK
d6fef890 2273 Drawing_t *drawing = control_flow_data->drawing;
96947fcf 2274 guint width = drawing->width;
a56a1ba4 2275
bc8d270b 2276 guint x = closure_data->x_end;
8b90e648 2277
4b7dc462 2278 DrawContext draw_context;
2279
e800cf84 2280 /* Now create the drawing context that will be used to draw
2281 * items related to the last state. */
1c736ed5 2282 draw_context.drawable = hashed_process_data->pixmap;
e800cf84 2283 draw_context.gc = drawing->gc;
2284 draw_context.pango_layout = drawing->pango_layout;
e800cf84 2285 draw_context.drawinfo.end.x = x;
2286
1c736ed5 2287 draw_context.drawinfo.y.over = 1;
2288 draw_context.drawinfo.y.middle = (hashed_process_data->height/2);
2289 draw_context.drawinfo.y.under = hashed_process_data->height;
e800cf84 2290
2291 draw_context.drawinfo.start.offset.over = 0;
2292 draw_context.drawinfo.start.offset.middle = 0;
2293 draw_context.drawinfo.start.offset.under = 0;
2294 draw_context.drawinfo.end.offset.over = 0;
2295 draw_context.drawinfo.end.offset.middle = 0;
2296 draw_context.drawinfo.end.offset.under = 0;
9a1ec01b 2297#if 0
4b7dc462 2298 /* Jump over draw if we are at the same x position */
2299 if(x == hashed_process_data->x.over)
e800cf84 2300 {
4b7dc462 2301 /* jump */
2302 } else {
23093869 2303 draw_context.drawinfo.start.x = hashed_process_data->x.over;
2304 /* Draw the line */
2305 PropertiesLine prop_line = prepare_execmode_line(process);
2306 draw_line((void*)&prop_line, (void*)&draw_context);
2307
4b7dc462 2308 hashed_process_data->x.over = x;
23093869 2309 }
9a1ec01b 2310#endif //0
4b7dc462 2311
1d1df11d 2312 if(unlikely(x == hashed_process_data->x.middle &&
2313 hashed_process_data->x.middle_used)) {
b2743953 2314#if 0 /* do not mark closure : not missing information */
e72908ed 2315 if(hashed_process_data->x.middle_marked == FALSE) {
2316 /* Draw collision indicator */
2317 gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]);
2318 gdk_draw_point(drawing->pixmap,
2319 drawing->gc,
2320 x,
2c6618bc 2321 y+(height/2)-3);
de4ea1ad 2322 hashed_process_data->x.middle_marked = TRUE;
e72908ed 2323 }
b2743953 2324#endif //0
4b7dc462 2325 /* Jump */
2326 } else {
23093869 2327 draw_context.drawinfo.start.x = hashed_process_data->x.middle;
e800cf84 2328 /* Draw the line */
9a1ec01b 2329 PropertiesLine prop_line = prepare_s_e_line(process);
e800cf84 2330 draw_line((void*)&prop_line, (void*)&draw_context);
2331
4b7dc462 2332 /* become the last x position */
1d1df11d 2333 if(likely(x != hashed_process_data->x.middle)) {
e72908ed 2334 hashed_process_data->x.middle = x;
2335 /* but don't use the pixel */
2336 hashed_process_data->x.middle_used = FALSE;
b2743953 2337
2338 /* Calculate the next good time */
2339 convert_pixels_to_time(width, x+1, time_window,
2340 &hashed_process_data->next_good_time);
e72908ed 2341 }
e800cf84 2342 }
e800cf84 2343 }
2344 }
2345 }
2346 return;
8b90e648 2347}
2348
b9a010a2 2349int before_chunk(void *hook_data, void *call_data)
2350{
2351 EventsRequest *events_request = (EventsRequest*)hook_data;
16b9cadb 2352 LttvTracesetState *tss = (LttvTracesetState*)call_data;
7c0125e0 2353 ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data;
cd3892fe 2354#if 0
7c0125e0 2355 /* Desactivate sort */
2356 gtk_tree_sortable_set_sort_column_id(
2357 GTK_TREE_SORTABLE(cfd->process_list->list_store),
2358 TRACE_COLUMN,
2359 GTK_SORT_ASCENDING);
cd3892fe 2360#endif //0
b9a010a2 2361 drawing_chunk_begin(events_request, tss);
2362
2363 return 0;
2364}
2365
2366int before_request(void *hook_data, void *call_data)
ca0f8a8e 2367{
2368 EventsRequest *events_request = (EventsRequest*)hook_data;
16b9cadb 2369 LttvTracesetState *tss = (LttvTracesetState*)call_data;
7c0125e0 2370
ca0f8a8e 2371 drawing_data_request_begin(events_request, tss);
2372
2373 return 0;
2374}
2375
2376
8b90e648 2377/*
b9a010a2 2378 * after request is necessary in addition of after chunk in order to draw
2379 * lines until the end of the screen. after chunk just draws lines until
2380 * the last event.
2381 *
8b90e648 2382 * for each process
a56a1ba4 2383 * draw closing line
b9a010a2 2384 * expose
8b90e648 2385 */
b9a010a2 2386int after_request(void *hook_data, void *call_data)
8b90e648 2387{
ca0f8a8e 2388 EventsRequest *events_request = (EventsRequest*)hook_data;
2389 ControlFlowData *control_flow_data = events_request->viewer_data;
16b9cadb 2390 LttvTracesetState *tss = (LttvTracesetState*)call_data;
a56a1ba4 2391
5c230fc4 2392 ProcessList *process_list = control_flow_data->process_list;
b9a010a2 2393 LttTime end_time = events_request->end_time;
2394
2395 ClosureData closure_data;
2396 closure_data.events_request = (EventsRequest*)hook_data;
2397 closure_data.tss = tss;
2398 closure_data.end_time = end_time;
2399
bc8d270b 2400 TimeWindow time_window =
2401 lttvwindow_get_time_window(control_flow_data->tab);
2402 guint width = control_flow_data->drawing->width;
2403 convert_time_to_pixels(
2404 time_window,
2405 end_time,
2406 width,
2407 &closure_data.x_end);
2408
2409
b9a010a2 2410 /* Draw last items */
2411 g_hash_table_foreach(process_list->process_hash, draw_closure,
2412 (void*)&closure_data);
7c0125e0 2413
b9a010a2 2414
2415 /* Request expose */
2416 drawing_request_expose(events_request, tss, end_time);
2417 return 0;
2418}
2419
2420/*
2421 * for each process
2422 * draw closing line
e800cf84 2423 * expose
b9a010a2 2424 */
2425int after_chunk(void *hook_data, void *call_data)
2426{
2427 EventsRequest *events_request = (EventsRequest*)hook_data;
2428 ControlFlowData *control_flow_data = events_request->viewer_data;
16b9cadb 2429 LttvTracesetState *tss = (LttvTracesetState*)call_data;
2430 LttvTracesetContext *tsc = (LttvTracesetContext*)call_data;
b9a010a2 2431 LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc);
2432 LttTime end_time;
2433
5c230fc4 2434 ProcessList *process_list = control_flow_data->process_list;
b9a010a2 2435
40debf7b 2436 g_free(process_list->current_hash_data);
2437 process_list->current_hash_data = NULL;
2438
e800cf84 2439 if(tfc != NULL)
2440 end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time);
0c5dbe3b 2441 else /* end of traceset, or position now out of request : end */
2442 end_time = events_request->end_time;
2443
a56a1ba4 2444 ClosureData closure_data;
ca0f8a8e 2445 closure_data.events_request = (EventsRequest*)hook_data;
2446 closure_data.tss = tss;
b9a010a2 2447 closure_data.end_time = end_time;
a56a1ba4 2448
bc8d270b 2449 TimeWindow time_window =
2450 lttvwindow_get_time_window(control_flow_data->tab);
2451 guint width = control_flow_data->drawing->width;
2452 convert_time_to_pixels(
2453 time_window,
2454 end_time,
2455 width,
2456 &closure_data.x_end);
2457
b9a010a2 2458 /* Draw last items */
14963be0 2459 g_hash_table_foreach(process_list->process_hash, draw_closure,
a56a1ba4 2460 (void*)&closure_data);
cd3892fe 2461#if 0
7c0125e0 2462 /* Reactivate sort */
2463 gtk_tree_sortable_set_sort_column_id(
2464 GTK_TREE_SORTABLE(control_flow_data->process_list->list_store),
2465 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
2466 GTK_SORT_ASCENDING);
2467
2468 update_index_to_pixmap(control_flow_data->process_list);
cd3892fe 2469 /* Request a full expose : drawing scrambled */
2470 gtk_widget_queue_draw(control_flow_data->drawing->drawing_area);
2471#endif //0
2472 /* Request expose (updates damages zone also) */
b9a010a2 2473 drawing_request_expose(events_request, tss, end_time);
ca0f8a8e 2474
2475 return 0;
8b90e648 2476}
2477
This page took 0.189763 seconds and 4 git commands to generate.