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