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