| 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 | //#define PANGO_ENABLE_BACKEND |
| 26 | #include <gtk/gtk.h> |
| 27 | #include <gdk/gdk.h> |
| 28 | #include <glib.h> |
| 29 | #include <assert.h> |
| 30 | #include <string.h> |
| 31 | #include <stdio.h> |
| 32 | |
| 33 | //#include <pango/pango.h> |
| 34 | |
| 35 | #include <ltt/event.h> |
| 36 | #include <ltt/time.h> |
| 37 | #include <ltt/type.h> |
| 38 | |
| 39 | #include <lttv/lttv.h> |
| 40 | #include <lttv/hook.h> |
| 41 | #include <lttvwindow/common.h> |
| 42 | #include <lttv/state.h> |
| 43 | #include <lttvwindow/viewer.h> |
| 44 | |
| 45 | |
| 46 | #include "eventhooks.h" |
| 47 | #include "cfv.h" |
| 48 | #include "processlist.h" |
| 49 | #include "drawing.h" |
| 50 | #include "cfv-private.h" |
| 51 | |
| 52 | |
| 53 | #define MAX_PATH_LEN 256 |
| 54 | |
| 55 | |
| 56 | /** |
| 57 | * Event Viewer's constructor hook |
| 58 | * |
| 59 | * This constructor is given as a parameter to the menuitem and toolbar button |
| 60 | * registration. It creates the list. |
| 61 | * @param mw A pointer to the parent window. |
| 62 | * @return The widget created. |
| 63 | */ |
| 64 | GtkWidget * |
| 65 | h_guicontrolflow(MainWindow *mw, LttvTracesetSelector * s, char * key) |
| 66 | { |
| 67 | g_info("h_guicontrolflow, %p, %p, %s", mw, s, key); |
| 68 | ControlFlowData *control_flow_data = guicontrolflow() ; |
| 69 | |
| 70 | control_flow_data->mw = mw; |
| 71 | TimeWindow *time_window = guicontrolflow_get_time_window(control_flow_data); |
| 72 | time_window->start_time.tv_sec = 0; |
| 73 | time_window->start_time.tv_nsec = 0; |
| 74 | time_window->time_width.tv_sec = 0; |
| 75 | time_window->time_width.tv_nsec = 0; |
| 76 | |
| 77 | LttTime *current_time = guicontrolflow_get_current_time(control_flow_data); |
| 78 | current_time->tv_sec = 0; |
| 79 | current_time->tv_nsec = 0; |
| 80 | |
| 81 | //g_debug("time width1 : %u",time_window->time_width); |
| 82 | |
| 83 | get_time_window(mw, |
| 84 | time_window); |
| 85 | get_current_time(mw, |
| 86 | current_time); |
| 87 | |
| 88 | //g_debug("time width2 : %u",time_window->time_width); |
| 89 | // Unreg done in the GuiControlFlow_Destructor |
| 90 | reg_update_time_window(update_time_window_hook, control_flow_data, |
| 91 | mw); |
| 92 | reg_update_current_time(update_current_time_hook, control_flow_data, |
| 93 | mw); |
| 94 | return guicontrolflow_get_widget(control_flow_data) ; |
| 95 | |
| 96 | } |
| 97 | |
| 98 | int event_selected_hook(void *hook_data, void *call_data) |
| 99 | { |
| 100 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
| 101 | guint *event_number = (guint*) call_data; |
| 102 | |
| 103 | g_debug("DEBUG : event selected by main window : %u", *event_number); |
| 104 | |
| 105 | // control_flow_data->currently_Selected_Event = *event_number; |
| 106 | // control_flow_data->Selected_Event = TRUE ; |
| 107 | |
| 108 | // tree_v_set_cursor(control_flow_data); |
| 109 | |
| 110 | } |
| 111 | |
| 112 | /* Hook called before drawing. Gets the initial context at the beginning of the |
| 113 | * drawing interval and copy it to the context in event_request. |
| 114 | */ |
| 115 | int draw_before_hook(void *hook_data, void *call_data) |
| 116 | { |
| 117 | EventRequest *event_request = (EventRequest*)hook_data; |
| 118 | //EventsContext Events_Context = (EventsContext*)call_data; |
| 119 | |
| 120 | //event_request->Events_Context = Events_Context; |
| 121 | |
| 122 | return 0; |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | * The draw event hook is called by the reading API to have a |
| 127 | * particular event drawn on the screen. |
| 128 | * @param hook_data ControlFlowData structure of the viewer. |
| 129 | * @param call_data Event context. |
| 130 | * |
| 131 | * This function basically draw lines and icons. Two types of lines are drawn : |
| 132 | * one small (3 pixels?) representing the state of the process and the second |
| 133 | * type is thicker (10 pixels?) representing on which CPU a process is running |
| 134 | * (and this only in running state). |
| 135 | * |
| 136 | * Extremums of the lines : |
| 137 | * x_min : time of the last event context for this process kept in memory. |
| 138 | * x_max : time of the current event. |
| 139 | * y : middle of the process in the process list. The process is found in the |
| 140 | * list, therefore is it's position in pixels. |
| 141 | * |
| 142 | * The choice of lines'color is defined by the context of the last event for this |
| 143 | * process. |
| 144 | */ |
| 145 | int draw_event_hook(void *hook_data, void *call_data) |
| 146 | { |
| 147 | EventRequest *event_request = (EventRequest*)hook_data; |
| 148 | ControlFlowData *control_flow_data = event_request->control_flow_data; |
| 149 | |
| 150 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
| 151 | |
| 152 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
| 153 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
| 154 | |
| 155 | LttEvent *e; |
| 156 | e = tfc->e; |
| 157 | |
| 158 | LttTime evtime = ltt_event_time(e); |
| 159 | TimeWindow *time_window = |
| 160 | guicontrolflow_get_time_window(control_flow_data); |
| 161 | |
| 162 | LttTime end_time = ltt_time_add(time_window->start_time, |
| 163 | time_window->time_width); |
| 164 | //if(time < time_beg || time > time_end) return; |
| 165 | if(ltt_time_compare(evtime, time_window->start_time) == -1 |
| 166 | || ltt_time_compare(evtime, end_time) == 1) |
| 167 | return; |
| 168 | |
| 169 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
| 170 | { |
| 171 | g_debug("schedchange!"); |
| 172 | |
| 173 | /* Add process to process list (if not present) and get drawing "y" from |
| 174 | * process position */ |
| 175 | guint pid_out, pid_in; |
| 176 | LttvProcessState *process_out, *process_in; |
| 177 | LttTime birth; |
| 178 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
| 179 | |
| 180 | ProcessList *process_list = |
| 181 | guicontrolflow_get_process_list(event_request->control_flow_data); |
| 182 | |
| 183 | |
| 184 | LttField *f = ltt_event_field(e); |
| 185 | LttField *element; |
| 186 | element = ltt_field_member(f,0); |
| 187 | pid_out = ltt_event_get_long_unsigned(e,element); |
| 188 | element = ltt_field_member(f,1); |
| 189 | pid_in = ltt_event_get_long_unsigned(e,element); |
| 190 | g_debug("out : %u in : %u", pid_out, pid_in); |
| 191 | |
| 192 | |
| 193 | /* Find process pid_out in the list... */ |
| 194 | process_out = lttv_state_find_process(tfs, pid_out); |
| 195 | if(process_out == NULL) return 0; |
| 196 | g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
| 197 | |
| 198 | birth = process_out->creation_time; |
| 199 | gchar *name = strdup(g_quark_to_string(process_out->name)); |
| 200 | HashedProcessData *hashed_process_data_out = NULL; |
| 201 | |
| 202 | if(processlist_get_process_pixels(process_list, |
| 203 | pid_out, |
| 204 | &birth, |
| 205 | tfc->t_context->index, |
| 206 | &y_out, |
| 207 | &height, |
| 208 | &hashed_process_data_out) == 1) |
| 209 | { |
| 210 | /* Process not present */ |
| 211 | processlist_add(process_list, |
| 212 | pid_out, |
| 213 | &birth, |
| 214 | tfc->t_context->index, |
| 215 | name, |
| 216 | &pl_height, |
| 217 | &hashed_process_data_out); |
| 218 | processlist_get_process_pixels(process_list, |
| 219 | pid_out, |
| 220 | &birth, |
| 221 | tfc->t_context->index, |
| 222 | &y_out, |
| 223 | &height, |
| 224 | &hashed_process_data_out); |
| 225 | drawing_insert_square( event_request->control_flow_data->drawing, y_out, height); |
| 226 | } |
| 227 | |
| 228 | g_free(name); |
| 229 | |
| 230 | /* Find process pid_in in the list... */ |
| 231 | process_in = lttv_state_find_process(tfs, pid_in); |
| 232 | if(process_in == NULL) return 0; |
| 233 | g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
| 234 | |
| 235 | birth = process_in->creation_time; |
| 236 | name = strdup(g_quark_to_string(process_in->name)); |
| 237 | HashedProcessData *hashed_process_data_in = NULL; |
| 238 | |
| 239 | if(processlist_get_process_pixels(process_list, |
| 240 | pid_in, |
| 241 | &birth, |
| 242 | tfc->t_context->index, |
| 243 | &y_in, |
| 244 | &height, |
| 245 | &hashed_process_data_in) == 1) |
| 246 | { |
| 247 | /* Process not present */ |
| 248 | processlist_add(process_list, |
| 249 | pid_in, |
| 250 | &birth, |
| 251 | tfc->t_context->index, |
| 252 | name, |
| 253 | &pl_height, |
| 254 | &hashed_process_data_in); |
| 255 | processlist_get_process_pixels(process_list, |
| 256 | pid_in, |
| 257 | &birth, |
| 258 | tfc->t_context->index, |
| 259 | &y_in, |
| 260 | &height, |
| 261 | &hashed_process_data_in); |
| 262 | |
| 263 | drawing_insert_square( event_request->control_flow_data->drawing, y_in, height); |
| 264 | } |
| 265 | g_free(name); |
| 266 | |
| 267 | |
| 268 | /* Find pixels corresponding to time of the event. If the time does |
| 269 | * not fit in the window, show a warning, not supposed to happend. */ |
| 270 | guint x = 0; |
| 271 | guint width = control_flow_data->drawing->drawing_area->allocation.width; |
| 272 | |
| 273 | LttTime time = ltt_event_time(e); |
| 274 | |
| 275 | LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width, |
| 276 | control_flow_data->time_window.start_time); |
| 277 | |
| 278 | |
| 279 | convert_time_to_pixels( |
| 280 | control_flow_data->time_window.start_time, |
| 281 | window_end, |
| 282 | time, |
| 283 | width, |
| 284 | &x); |
| 285 | //assert(x <= width); |
| 286 | |
| 287 | /* draw what represents the event for outgoing process. */ |
| 288 | |
| 289 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
| 290 | draw_context_out->current->modify_over->x = x; |
| 291 | draw_context_out->current->modify_under->x = x; |
| 292 | draw_context_out->current->modify_over->y = y_out; |
| 293 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
| 294 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
| 295 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
| 296 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
| 297 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
| 298 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 299 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
| 300 | //draw_context_out->gc = widget->style->black_gc; |
| 301 | |
| 302 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
| 303 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
| 304 | |
| 305 | /* Draw the line/background of the out process */ |
| 306 | if(draw_context_out->previous->middle->x == -1) |
| 307 | { |
| 308 | draw_context_out->previous->over->x = event_request->x_begin; |
| 309 | draw_context_out->previous->middle->x = event_request->x_begin; |
| 310 | draw_context_out->previous->under->x = event_request->x_begin; |
| 311 | |
| 312 | g_debug("out middle x_beg : %u",event_request->x_begin); |
| 313 | } |
| 314 | |
| 315 | draw_context_out->current->middle->x = x; |
| 316 | draw_context_out->current->over->x = x; |
| 317 | draw_context_out->current->under->x = x; |
| 318 | draw_context_out->current->middle->y = y_out + height/2; |
| 319 | draw_context_out->current->over->y = y_out; |
| 320 | draw_context_out->current->under->y = y_out + height; |
| 321 | draw_context_out->previous->middle->y = y_out + height/2; |
| 322 | draw_context_out->previous->over->y = y_out; |
| 323 | draw_context_out->previous->under->y = y_out + height; |
| 324 | |
| 325 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
| 326 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
| 327 | |
| 328 | if(process_out->state->s == LTTV_STATE_RUN) |
| 329 | { |
| 330 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 331 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
| 332 | |
| 333 | PropertiesBG prop_bg; |
| 334 | prop_bg.color = g_new(GdkColor,1); |
| 335 | |
| 336 | switch(tfc->index) { |
| 337 | case 0: |
| 338 | prop_bg.color->red = 0x1515; |
| 339 | prop_bg.color->green = 0x1515; |
| 340 | prop_bg.color->blue = 0x8c8c; |
| 341 | break; |
| 342 | case 1: |
| 343 | prop_bg.color->red = 0x4e4e; |
| 344 | prop_bg.color->green = 0xa9a9; |
| 345 | prop_bg.color->blue = 0xa4a4; |
| 346 | break; |
| 347 | case 2: |
| 348 | prop_bg.color->red = 0x7a7a; |
| 349 | prop_bg.color->green = 0x4a4a; |
| 350 | prop_bg.color->blue = 0x8b8b; |
| 351 | break; |
| 352 | case 3: |
| 353 | prop_bg.color->red = 0x8080; |
| 354 | prop_bg.color->green = 0x7777; |
| 355 | prop_bg.color->blue = 0x4747; |
| 356 | break; |
| 357 | default: |
| 358 | prop_bg.color->red = 0xe7e7; |
| 359 | prop_bg.color->green = 0xe7e7; |
| 360 | prop_bg.color->blue = 0xe7e7; |
| 361 | } |
| 362 | |
| 363 | g_debug("calling from draw_event"); |
| 364 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
| 365 | g_free(prop_bg.color); |
| 366 | gdk_gc_unref(draw_context_out->gc); |
| 367 | } |
| 368 | |
| 369 | draw_context_out->gc = widget->style->black_gc; |
| 370 | |
| 371 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
| 372 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
| 373 | PropertiesText prop_text_out; |
| 374 | prop_text_out.foreground = &colorfg_out; |
| 375 | prop_text_out.background = &colorbg_out; |
| 376 | prop_text_out.size = 6; |
| 377 | prop_text_out.position = OVER; |
| 378 | |
| 379 | /* color of text : status of the process */ |
| 380 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
| 381 | { |
| 382 | prop_text_out.foreground->red = 0xffff; |
| 383 | prop_text_out.foreground->green = 0xffff; |
| 384 | prop_text_out.foreground->blue = 0xffff; |
| 385 | } |
| 386 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
| 387 | { |
| 388 | prop_text_out.foreground->red = 0x0fff; |
| 389 | prop_text_out.foreground->green = 0xffff; |
| 390 | prop_text_out.foreground->blue = 0xfff0; |
| 391 | } |
| 392 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
| 393 | { |
| 394 | prop_text_out.foreground->red = 0xffff; |
| 395 | prop_text_out.foreground->green = 0xffff; |
| 396 | prop_text_out.foreground->blue = 0x0000; |
| 397 | } |
| 398 | else if(process_out->state->s == LTTV_STATE_EXIT) |
| 399 | { |
| 400 | prop_text_out.foreground->red = 0xffff; |
| 401 | prop_text_out.foreground->green = 0x0000; |
| 402 | prop_text_out.foreground->blue = 0xffff; |
| 403 | } |
| 404 | else if(process_out->state->s == LTTV_STATE_WAIT) |
| 405 | { |
| 406 | prop_text_out.foreground->red = 0xffff; |
| 407 | prop_text_out.foreground->green = 0x0000; |
| 408 | prop_text_out.foreground->blue = 0x0000; |
| 409 | } |
| 410 | else if(process_out->state->s == LTTV_STATE_RUN) |
| 411 | { |
| 412 | prop_text_out.foreground->red = 0x0000; |
| 413 | prop_text_out.foreground->green = 0xffff; |
| 414 | prop_text_out.foreground->blue = 0x0000; |
| 415 | } |
| 416 | else |
| 417 | { |
| 418 | prop_text_out.foreground->red = 0xffff; |
| 419 | prop_text_out.foreground->green = 0xffff; |
| 420 | prop_text_out.foreground->blue = 0xffff; |
| 421 | } |
| 422 | |
| 423 | |
| 424 | /* Print status of the process : U, WF, WC, E, W, R */ |
| 425 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
| 426 | prop_text_out.text = "U->"; |
| 427 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
| 428 | prop_text_out.text = "WF->"; |
| 429 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
| 430 | prop_text_out.text = "WC->"; |
| 431 | else if(process_out->state->s == LTTV_STATE_EXIT) |
| 432 | prop_text_out.text = "E->"; |
| 433 | else if(process_out->state->s == LTTV_STATE_WAIT) |
| 434 | prop_text_out.text = "W->"; |
| 435 | else if(process_out->state->s == LTTV_STATE_RUN) |
| 436 | prop_text_out.text = "R->"; |
| 437 | else |
| 438 | prop_text_out.text = "U"; |
| 439 | |
| 440 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
| 441 | //gdk_gc_unref(draw_context_out->gc); |
| 442 | |
| 443 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 444 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
| 445 | |
| 446 | PropertiesLine prop_line_out; |
| 447 | prop_line_out.color = g_new(GdkColor,1); |
| 448 | prop_line_out.line_width = 2; |
| 449 | prop_line_out.style = GDK_LINE_SOLID; |
| 450 | prop_line_out.position = MIDDLE; |
| 451 | |
| 452 | g_debug("out state : %s", g_quark_to_string(process_out->state->s)); |
| 453 | |
| 454 | /* color of line : status of the process */ |
| 455 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
| 456 | { |
| 457 | prop_line_out.color->red = 0xffff; |
| 458 | prop_line_out.color->green = 0xffff; |
| 459 | prop_line_out.color->blue = 0xffff; |
| 460 | } |
| 461 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
| 462 | { |
| 463 | prop_line_out.color->red = 0x0fff; |
| 464 | prop_line_out.color->green = 0xffff; |
| 465 | prop_line_out.color->blue = 0xfff0; |
| 466 | } |
| 467 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
| 468 | { |
| 469 | prop_line_out.color->red = 0xffff; |
| 470 | prop_line_out.color->green = 0xffff; |
| 471 | prop_line_out.color->blue = 0x0000; |
| 472 | } |
| 473 | else if(process_out->state->s == LTTV_STATE_EXIT) |
| 474 | { |
| 475 | prop_line_out.color->red = 0xffff; |
| 476 | prop_line_out.color->green = 0x0000; |
| 477 | prop_line_out.color->blue = 0xffff; |
| 478 | } |
| 479 | else if(process_out->state->s == LTTV_STATE_WAIT) |
| 480 | { |
| 481 | prop_line_out.color->red = 0xffff; |
| 482 | prop_line_out.color->green = 0x0000; |
| 483 | prop_line_out.color->blue = 0x0000; |
| 484 | } |
| 485 | else if(process_out->state->s == LTTV_STATE_RUN) |
| 486 | { |
| 487 | prop_line_out.color->red = 0x0000; |
| 488 | prop_line_out.color->green = 0xffff; |
| 489 | prop_line_out.color->blue = 0x0000; |
| 490 | } |
| 491 | else |
| 492 | { |
| 493 | prop_line_out.color->red = 0xffff; |
| 494 | prop_line_out.color->green = 0xffff; |
| 495 | prop_line_out.color->blue = 0xffff; |
| 496 | } |
| 497 | |
| 498 | draw_line((void*)&prop_line_out, (void*)draw_context_out); |
| 499 | g_free(prop_line_out.color); |
| 500 | gdk_gc_unref(draw_context_out->gc); |
| 501 | /* Note : finishing line will have to be added when trace read over. */ |
| 502 | |
| 503 | /* Finally, update the drawing context of the pid_in. */ |
| 504 | |
| 505 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
| 506 | draw_context_in->current->modify_over->x = x; |
| 507 | draw_context_in->current->modify_under->x = x; |
| 508 | draw_context_in->current->modify_over->y = y_in; |
| 509 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
| 510 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
| 511 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
| 512 | widget = control_flow_data->drawing->drawing_area; |
| 513 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
| 514 | //draw_context_in->gc = widget->style->black_gc; |
| 515 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 516 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
| 517 | |
| 518 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
| 519 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
| 520 | |
| 521 | /* Draw the line/bg of the in process */ |
| 522 | if(draw_context_in->previous->middle->x == -1) |
| 523 | { |
| 524 | draw_context_in->previous->middle->x = event_request->x_begin; |
| 525 | draw_context_in->previous->over->x = event_request->x_begin; |
| 526 | draw_context_in->previous->under->x = event_request->x_begin; |
| 527 | g_debug("in middle x_beg : %u",event_request->x_begin); |
| 528 | } |
| 529 | |
| 530 | draw_context_in->current->middle->x = x; |
| 531 | draw_context_in->current->over->x = x; |
| 532 | draw_context_in->current->under->x = x; |
| 533 | draw_context_in->current->middle->y = y_in + height/2; |
| 534 | draw_context_in->current->over->y = y_in; |
| 535 | draw_context_in->current->under->y = y_in + height; |
| 536 | draw_context_in->previous->middle->y = y_in + height/2; |
| 537 | draw_context_in->previous->over->y = y_in; |
| 538 | draw_context_in->previous->under->y = y_in + height; |
| 539 | |
| 540 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
| 541 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
| 542 | |
| 543 | |
| 544 | if(process_in->state->s == LTTV_STATE_RUN) |
| 545 | { |
| 546 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 547 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
| 548 | |
| 549 | PropertiesBG prop_bg; |
| 550 | prop_bg.color = g_new(GdkColor,1); |
| 551 | |
| 552 | switch(tfc->index) { |
| 553 | case 0: |
| 554 | prop_bg.color->red = 0x1515; |
| 555 | prop_bg.color->green = 0x1515; |
| 556 | prop_bg.color->blue = 0x8c8c; |
| 557 | break; |
| 558 | case 1: |
| 559 | prop_bg.color->red = 0x4e4e; |
| 560 | prop_bg.color->green = 0xa9a9; |
| 561 | prop_bg.color->blue = 0xa4a4; |
| 562 | break; |
| 563 | case 2: |
| 564 | prop_bg.color->red = 0x7a7a; |
| 565 | prop_bg.color->green = 0x4a4a; |
| 566 | prop_bg.color->blue = 0x8b8b; |
| 567 | break; |
| 568 | case 3: |
| 569 | prop_bg.color->red = 0x8080; |
| 570 | prop_bg.color->green = 0x7777; |
| 571 | prop_bg.color->blue = 0x4747; |
| 572 | break; |
| 573 | default: |
| 574 | prop_bg.color->red = 0xe7e7; |
| 575 | prop_bg.color->green = 0xe7e7; |
| 576 | prop_bg.color->blue = 0xe7e7; |
| 577 | } |
| 578 | |
| 579 | |
| 580 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
| 581 | g_free(prop_bg.color); |
| 582 | gdk_gc_unref(draw_context_in->gc); |
| 583 | } |
| 584 | |
| 585 | draw_context_in->gc = widget->style->black_gc; |
| 586 | |
| 587 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
| 588 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
| 589 | PropertiesText prop_text_in; |
| 590 | prop_text_in.foreground = &colorfg_in; |
| 591 | prop_text_in.background = &colorbg_in; |
| 592 | prop_text_in.size = 6; |
| 593 | prop_text_in.position = OVER; |
| 594 | |
| 595 | g_debug("in state : %s", g_quark_to_string(process_in->state->s)); |
| 596 | /* foreground of text : status of the process */ |
| 597 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
| 598 | { |
| 599 | prop_text_in.foreground->red = 0xffff; |
| 600 | prop_text_in.foreground->green = 0xffff; |
| 601 | prop_text_in.foreground->blue = 0xffff; |
| 602 | } |
| 603 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
| 604 | { |
| 605 | prop_text_in.foreground->red = 0x0fff; |
| 606 | prop_text_in.foreground->green = 0xffff; |
| 607 | prop_text_in.foreground->blue = 0xfff0; |
| 608 | } |
| 609 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
| 610 | { |
| 611 | prop_text_in.foreground->red = 0xffff; |
| 612 | prop_text_in.foreground->green = 0xffff; |
| 613 | prop_text_in.foreground->blue = 0x0000; |
| 614 | } |
| 615 | else if(process_in->state->s == LTTV_STATE_EXIT) |
| 616 | { |
| 617 | prop_text_in.foreground->red = 0xffff; |
| 618 | prop_text_in.foreground->green = 0x0000; |
| 619 | prop_text_in.foreground->blue = 0xffff; |
| 620 | } |
| 621 | else if(process_in->state->s == LTTV_STATE_WAIT) |
| 622 | { |
| 623 | prop_text_in.foreground->red = 0xffff; |
| 624 | prop_text_in.foreground->green = 0x0000; |
| 625 | prop_text_in.foreground->blue = 0x0000; |
| 626 | } |
| 627 | else if(process_in->state->s == LTTV_STATE_RUN) |
| 628 | { |
| 629 | prop_text_in.foreground->red = 0x0000; |
| 630 | prop_text_in.foreground->green = 0xffff; |
| 631 | prop_text_in.foreground->blue = 0x0000; |
| 632 | } |
| 633 | else |
| 634 | { |
| 635 | prop_text_in.foreground->red = 0xffff; |
| 636 | prop_text_in.foreground->green = 0xffff; |
| 637 | prop_text_in.foreground->blue = 0xffff; |
| 638 | } |
| 639 | |
| 640 | |
| 641 | |
| 642 | /* Print status of the process : U, WF, WC, E, W, R */ |
| 643 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
| 644 | prop_text_in.text = "U->"; |
| 645 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
| 646 | prop_text_in.text = "WF->"; |
| 647 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
| 648 | prop_text_in.text = "WC->"; |
| 649 | else if(process_in->state->s == LTTV_STATE_EXIT) |
| 650 | prop_text_in.text = "E->"; |
| 651 | else if(process_in->state->s == LTTV_STATE_WAIT) |
| 652 | prop_text_in.text = "W->"; |
| 653 | else if(process_in->state->s == LTTV_STATE_RUN) |
| 654 | prop_text_in.text = "R->"; |
| 655 | else |
| 656 | prop_text_in.text = "U"; |
| 657 | |
| 658 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
| 659 | //gdk_gc_unref(draw_context_in->gc); |
| 660 | |
| 661 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 662 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
| 663 | |
| 664 | PropertiesLine prop_line_in; |
| 665 | prop_line_in.color = g_new(GdkColor,1); |
| 666 | prop_line_in.line_width = 2; |
| 667 | prop_line_in.style = GDK_LINE_SOLID; |
| 668 | prop_line_in.position = MIDDLE; |
| 669 | |
| 670 | /* color of line : status of the process */ |
| 671 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
| 672 | { |
| 673 | prop_line_in.color->red = 0xffff; |
| 674 | prop_line_in.color->green = 0xffff; |
| 675 | prop_line_in.color->blue = 0xffff; |
| 676 | } |
| 677 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
| 678 | { |
| 679 | prop_line_in.color->red = 0x0fff; |
| 680 | prop_line_in.color->green = 0xffff; |
| 681 | prop_line_in.color->blue = 0xfff0; |
| 682 | } |
| 683 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
| 684 | { |
| 685 | prop_line_in.color->red = 0xffff; |
| 686 | prop_line_in.color->green = 0xffff; |
| 687 | prop_line_in.color->blue = 0x0000; |
| 688 | } |
| 689 | else if(process_in->state->s == LTTV_STATE_EXIT) |
| 690 | { |
| 691 | prop_line_in.color->red = 0xffff; |
| 692 | prop_line_in.color->green = 0x0000; |
| 693 | prop_line_in.color->blue = 0xffff; |
| 694 | } |
| 695 | else if(process_in->state->s == LTTV_STATE_WAIT) |
| 696 | { |
| 697 | prop_line_in.color->red = 0xffff; |
| 698 | prop_line_in.color->green = 0x0000; |
| 699 | prop_line_in.color->blue = 0x0000; |
| 700 | } |
| 701 | else if(process_in->state->s == LTTV_STATE_RUN) |
| 702 | { |
| 703 | prop_line_in.color->red = 0x0000; |
| 704 | prop_line_in.color->green = 0xffff; |
| 705 | prop_line_in.color->blue = 0x0000; |
| 706 | } |
| 707 | else |
| 708 | { |
| 709 | prop_line_in.color->red = 0xffff; |
| 710 | prop_line_in.color->green = 0xffff; |
| 711 | prop_line_in.color->blue = 0xffff; |
| 712 | } |
| 713 | |
| 714 | draw_line((void*)&prop_line_in, (void*)draw_context_in); |
| 715 | g_free(prop_line_in.color); |
| 716 | gdk_gc_unref(draw_context_in->gc); |
| 717 | } |
| 718 | |
| 719 | return 0; |
| 720 | |
| 721 | /* Temp dump */ |
| 722 | #ifdef DONTSHOW |
| 723 | GString *string = g_string_new("");; |
| 724 | gboolean field_names = TRUE, state = TRUE; |
| 725 | |
| 726 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
| 727 | g_string_append_printf(string,"\n"); |
| 728 | |
| 729 | if(state) { |
| 730 | g_string_append_printf(string, " %s", |
| 731 | g_quark_to_string(tfs->process->state->s)); |
| 732 | } |
| 733 | |
| 734 | g_info("%s",string->str); |
| 735 | |
| 736 | g_string_free(string, TRUE); |
| 737 | |
| 738 | /* End of text dump */ |
| 739 | #endif //DONTSHOW |
| 740 | |
| 741 | } |
| 742 | |
| 743 | |
| 744 | int draw_after_hook(void *hook_data, void *call_data) |
| 745 | { |
| 746 | EventRequest *event_request = (EventRequest*)hook_data; |
| 747 | ControlFlowData *control_flow_data = event_request->control_flow_data; |
| 748 | |
| 749 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
| 750 | |
| 751 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
| 752 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
| 753 | |
| 754 | |
| 755 | LttEvent *e; |
| 756 | e = tfc->e; |
| 757 | |
| 758 | LttTime evtime = ltt_event_time(e); |
| 759 | TimeWindow *time_window = |
| 760 | guicontrolflow_get_time_window(control_flow_data); |
| 761 | |
| 762 | LttTime end_time = ltt_time_add(time_window->start_time, |
| 763 | time_window->time_width); |
| 764 | //if(time < time_beg || time > time_end) return; |
| 765 | if(ltt_time_compare(evtime, time_window->start_time) == -1 |
| 766 | || ltt_time_compare(evtime, end_time) == 1) |
| 767 | return; |
| 768 | |
| 769 | |
| 770 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
| 771 | { |
| 772 | g_debug("schedchange!"); |
| 773 | |
| 774 | /* Add process to process list (if not present) and get drawing "y" from |
| 775 | * process position */ |
| 776 | guint pid_out, pid_in; |
| 777 | LttvProcessState *process_out, *process_in; |
| 778 | LttTime birth; |
| 779 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
| 780 | |
| 781 | ProcessList *process_list = |
| 782 | guicontrolflow_get_process_list(event_request->control_flow_data); |
| 783 | |
| 784 | |
| 785 | LttField *f = ltt_event_field(e); |
| 786 | LttField *element; |
| 787 | element = ltt_field_member(f,0); |
| 788 | pid_out = ltt_event_get_long_unsigned(e,element); |
| 789 | element = ltt_field_member(f,1); |
| 790 | pid_in = ltt_event_get_long_unsigned(e,element); |
| 791 | //g_debug("out : %u in : %u", pid_out, pid_in); |
| 792 | |
| 793 | |
| 794 | /* Find process pid_out in the list... */ |
| 795 | process_out = lttv_state_find_process(tfs, pid_out); |
| 796 | if(process_out == NULL) return 0; |
| 797 | //g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
| 798 | |
| 799 | birth = process_out->creation_time; |
| 800 | gchar *name = strdup(g_quark_to_string(process_out->name)); |
| 801 | HashedProcessData *hashed_process_data_out = NULL; |
| 802 | |
| 803 | if(processlist_get_process_pixels(process_list, |
| 804 | pid_out, |
| 805 | &birth, |
| 806 | tfc->t_context->index, |
| 807 | &y_out, |
| 808 | &height, |
| 809 | &hashed_process_data_out) == 1) |
| 810 | { |
| 811 | /* Process not present */ |
| 812 | processlist_add(process_list, |
| 813 | pid_out, |
| 814 | &birth, |
| 815 | tfc->t_context->index, |
| 816 | name, |
| 817 | &pl_height, |
| 818 | &hashed_process_data_out); |
| 819 | processlist_get_process_pixels(process_list, |
| 820 | pid_out, |
| 821 | &birth, |
| 822 | tfc->t_context->index, |
| 823 | &y_out, |
| 824 | &height, |
| 825 | &hashed_process_data_out); |
| 826 | drawing_insert_square( event_request->control_flow_data->drawing, y_out, height); |
| 827 | } |
| 828 | |
| 829 | g_free(name); |
| 830 | |
| 831 | /* Find process pid_in in the list... */ |
| 832 | process_in = lttv_state_find_process(tfs, pid_in); |
| 833 | if(process_in == NULL) return 0; |
| 834 | //g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
| 835 | |
| 836 | birth = process_in->creation_time; |
| 837 | name = strdup(g_quark_to_string(process_in->name)); |
| 838 | HashedProcessData *hashed_process_data_in = NULL; |
| 839 | |
| 840 | if(processlist_get_process_pixels(process_list, |
| 841 | pid_in, |
| 842 | &birth, |
| 843 | tfc->t_context->index, |
| 844 | &y_in, |
| 845 | &height, |
| 846 | &hashed_process_data_in) == 1) |
| 847 | { |
| 848 | /* Process not present */ |
| 849 | processlist_add(process_list, |
| 850 | pid_in, |
| 851 | &birth, |
| 852 | tfc->t_context->index, |
| 853 | name, |
| 854 | &pl_height, |
| 855 | &hashed_process_data_in); |
| 856 | processlist_get_process_pixels(process_list, |
| 857 | pid_in, |
| 858 | &birth, |
| 859 | tfc->t_context->index, |
| 860 | &y_in, |
| 861 | &height, |
| 862 | &hashed_process_data_in); |
| 863 | |
| 864 | drawing_insert_square( event_request->control_flow_data->drawing, y_in, height); |
| 865 | } |
| 866 | g_free(name); |
| 867 | |
| 868 | |
| 869 | /* Find pixels corresponding to time of the event. If the time does |
| 870 | * not fit in the window, show a warning, not supposed to happend. */ |
| 871 | //guint x = 0; |
| 872 | //guint width = control_flow_data->drawing->drawing_area->allocation.width; |
| 873 | |
| 874 | //LttTime time = ltt_event_time(e); |
| 875 | |
| 876 | //LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width, |
| 877 | // control_flow_data->time_window.start_time); |
| 878 | |
| 879 | |
| 880 | //convert_time_to_pixels( |
| 881 | // control_flow_data->time_window.start_time, |
| 882 | // window_end, |
| 883 | // time, |
| 884 | // width, |
| 885 | // &x); |
| 886 | |
| 887 | //assert(x <= width); |
| 888 | |
| 889 | /* draw what represents the event for outgoing process. */ |
| 890 | |
| 891 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
| 892 | //draw_context_out->current->modify_over->x = x; |
| 893 | draw_context_out->current->modify_over->y = y_out; |
| 894 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
| 895 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
| 896 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
| 897 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
| 898 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
| 899 | |
| 900 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
| 901 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
| 902 | |
| 903 | /*if(process_out->state->s == LTTV_STATE_RUN) |
| 904 | { |
| 905 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 906 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
| 907 | PropertiesBG prop_bg; |
| 908 | prop_bg.color = g_new(GdkColor,1); |
| 909 | |
| 910 | prop_bg.color->red = 0xffff; |
| 911 | prop_bg.color->green = 0xffff; |
| 912 | prop_bg.color->blue = 0xffff; |
| 913 | |
| 914 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
| 915 | g_free(prop_bg.color); |
| 916 | gdk_gc_unref(draw_context_out->gc); |
| 917 | }*/ |
| 918 | |
| 919 | draw_context_out->gc = widget->style->black_gc; |
| 920 | |
| 921 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
| 922 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
| 923 | PropertiesText prop_text_out; |
| 924 | prop_text_out.foreground = &colorfg_out; |
| 925 | prop_text_out.background = &colorbg_out; |
| 926 | prop_text_out.size = 6; |
| 927 | prop_text_out.position = OVER; |
| 928 | |
| 929 | /* color of text : status of the process */ |
| 930 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
| 931 | { |
| 932 | prop_text_out.foreground->red = 0xffff; |
| 933 | prop_text_out.foreground->green = 0xffff; |
| 934 | prop_text_out.foreground->blue = 0xffff; |
| 935 | } |
| 936 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
| 937 | { |
| 938 | prop_text_out.foreground->red = 0x0fff; |
| 939 | prop_text_out.foreground->green = 0xffff; |
| 940 | prop_text_out.foreground->blue = 0xfff0; |
| 941 | } |
| 942 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
| 943 | { |
| 944 | prop_text_out.foreground->red = 0xffff; |
| 945 | prop_text_out.foreground->green = 0xffff; |
| 946 | prop_text_out.foreground->blue = 0x0000; |
| 947 | } |
| 948 | else if(process_out->state->s == LTTV_STATE_EXIT) |
| 949 | { |
| 950 | prop_text_out.foreground->red = 0xffff; |
| 951 | prop_text_out.foreground->green = 0x0000; |
| 952 | prop_text_out.foreground->blue = 0xffff; |
| 953 | } |
| 954 | else if(process_out->state->s == LTTV_STATE_WAIT) |
| 955 | { |
| 956 | prop_text_out.foreground->red = 0xffff; |
| 957 | prop_text_out.foreground->green = 0x0000; |
| 958 | prop_text_out.foreground->blue = 0x0000; |
| 959 | } |
| 960 | else if(process_out->state->s == LTTV_STATE_RUN) |
| 961 | { |
| 962 | prop_text_out.foreground->red = 0x0000; |
| 963 | prop_text_out.foreground->green = 0xffff; |
| 964 | prop_text_out.foreground->blue = 0x0000; |
| 965 | } |
| 966 | else |
| 967 | { |
| 968 | prop_text_out.foreground->red = 0xffff; |
| 969 | prop_text_out.foreground->green = 0xffff; |
| 970 | prop_text_out.foreground->blue = 0xffff; |
| 971 | } |
| 972 | |
| 973 | /* Print status of the process : U, WF, WC, E, W, R */ |
| 974 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
| 975 | prop_text_out.text = "U"; |
| 976 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
| 977 | prop_text_out.text = "WF"; |
| 978 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
| 979 | prop_text_out.text = "WC"; |
| 980 | else if(process_out->state->s == LTTV_STATE_EXIT) |
| 981 | prop_text_out.text = "E"; |
| 982 | else if(process_out->state->s == LTTV_STATE_WAIT) |
| 983 | prop_text_out.text = "W"; |
| 984 | else if(process_out->state->s == LTTV_STATE_RUN) |
| 985 | prop_text_out.text = "R"; |
| 986 | else |
| 987 | prop_text_out.text = "U"; |
| 988 | |
| 989 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
| 990 | |
| 991 | //gdk_gc_unref(draw_context_out->gc); |
| 992 | |
| 993 | draw_context_out->current->middle->y = y_out+height/2; |
| 994 | draw_context_out->current->over->y = y_out; |
| 995 | draw_context_out->current->under->y = y_out+height; |
| 996 | draw_context_out->current->status = process_out->state->s; |
| 997 | |
| 998 | /* for pid_out : remove previous, Prev = current, new current (default) */ |
| 999 | g_free(draw_context_out->previous->modify_under); |
| 1000 | g_free(draw_context_out->previous->modify_middle); |
| 1001 | g_free(draw_context_out->previous->modify_over); |
| 1002 | g_free(draw_context_out->previous->under); |
| 1003 | g_free(draw_context_out->previous->middle); |
| 1004 | g_free(draw_context_out->previous->over); |
| 1005 | g_free(draw_context_out->previous); |
| 1006 | |
| 1007 | draw_context_out->previous = draw_context_out->current; |
| 1008 | |
| 1009 | draw_context_out->current = g_new(DrawInfo,1); |
| 1010 | draw_context_out->current->over = g_new(ItemInfo,1); |
| 1011 | draw_context_out->current->over->x = -1; |
| 1012 | draw_context_out->current->over->y = -1; |
| 1013 | draw_context_out->current->middle = g_new(ItemInfo,1); |
| 1014 | draw_context_out->current->middle->x = -1; |
| 1015 | draw_context_out->current->middle->y = -1; |
| 1016 | draw_context_out->current->under = g_new(ItemInfo,1); |
| 1017 | draw_context_out->current->under->x = -1; |
| 1018 | draw_context_out->current->under->y = -1; |
| 1019 | draw_context_out->current->modify_over = g_new(ItemInfo,1); |
| 1020 | draw_context_out->current->modify_over->x = -1; |
| 1021 | draw_context_out->current->modify_over->y = -1; |
| 1022 | draw_context_out->current->modify_middle = g_new(ItemInfo,1); |
| 1023 | draw_context_out->current->modify_middle->x = -1; |
| 1024 | draw_context_out->current->modify_middle->y = -1; |
| 1025 | draw_context_out->current->modify_under = g_new(ItemInfo,1); |
| 1026 | draw_context_out->current->modify_under->x = -1; |
| 1027 | draw_context_out->current->modify_under->y = -1; |
| 1028 | draw_context_out->current->status = LTTV_STATE_UNNAMED; |
| 1029 | |
| 1030 | /* Finally, update the drawing context of the pid_in. */ |
| 1031 | |
| 1032 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
| 1033 | //draw_context_in->current->modify_over->x = x; |
| 1034 | draw_context_in->current->modify_over->y = y_in; |
| 1035 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
| 1036 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
| 1037 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
| 1038 | widget = control_flow_data->drawing->drawing_area; |
| 1039 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
| 1040 | |
| 1041 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
| 1042 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
| 1043 | |
| 1044 | /*if(process_in->state->s == LTTV_STATE_RUN) |
| 1045 | { |
| 1046 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 1047 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
| 1048 | PropertiesBG prop_bg; |
| 1049 | prop_bg.color = g_new(GdkColor,1); |
| 1050 | |
| 1051 | prop_bg.color->red = 0xffff; |
| 1052 | prop_bg.color->green = 0xffff; |
| 1053 | prop_bg.color->blue = 0xffff; |
| 1054 | |
| 1055 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
| 1056 | g_free(prop_bg.color); |
| 1057 | gdk_gc_unref(draw_context_in->gc); |
| 1058 | }*/ |
| 1059 | |
| 1060 | draw_context_in->gc = widget->style->black_gc; |
| 1061 | |
| 1062 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
| 1063 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
| 1064 | PropertiesText prop_text_in; |
| 1065 | prop_text_in.foreground = &colorfg_in; |
| 1066 | prop_text_in.background = &colorbg_in; |
| 1067 | prop_text_in.size = 6; |
| 1068 | prop_text_in.position = OVER; |
| 1069 | |
| 1070 | /* foreground of text : status of the process */ |
| 1071 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
| 1072 | { |
| 1073 | prop_text_in.foreground->red = 0xffff; |
| 1074 | prop_text_in.foreground->green = 0xffff; |
| 1075 | prop_text_in.foreground->blue = 0xffff; |
| 1076 | } |
| 1077 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
| 1078 | { |
| 1079 | prop_text_in.foreground->red = 0x0fff; |
| 1080 | prop_text_in.foreground->green = 0xffff; |
| 1081 | prop_text_in.foreground->blue = 0xfff0; |
| 1082 | } |
| 1083 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
| 1084 | { |
| 1085 | prop_text_in.foreground->red = 0xffff; |
| 1086 | prop_text_in.foreground->green = 0xffff; |
| 1087 | prop_text_in.foreground->blue = 0x0000; |
| 1088 | } |
| 1089 | else if(process_in->state->s == LTTV_STATE_EXIT) |
| 1090 | { |
| 1091 | prop_text_in.foreground->red = 0xffff; |
| 1092 | prop_text_in.foreground->green = 0x0000; |
| 1093 | prop_text_in.foreground->blue = 0xffff; |
| 1094 | } |
| 1095 | else if(process_in->state->s == LTTV_STATE_WAIT) |
| 1096 | { |
| 1097 | prop_text_in.foreground->red = 0xffff; |
| 1098 | prop_text_in.foreground->green = 0x0000; |
| 1099 | prop_text_in.foreground->blue = 0x0000; |
| 1100 | } |
| 1101 | else if(process_in->state->s == LTTV_STATE_RUN) |
| 1102 | { |
| 1103 | prop_text_in.foreground->red = 0x0000; |
| 1104 | prop_text_in.foreground->green = 0xffff; |
| 1105 | prop_text_in.foreground->blue = 0x0000; |
| 1106 | } |
| 1107 | else |
| 1108 | { |
| 1109 | prop_text_in.foreground->red = 0xffff; |
| 1110 | prop_text_in.foreground->green = 0xffff; |
| 1111 | prop_text_in.foreground->blue = 0xffff; |
| 1112 | } |
| 1113 | |
| 1114 | |
| 1115 | /* Print status of the process : U, WF, WC, E, W, R */ |
| 1116 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
| 1117 | prop_text_in.text = "U"; |
| 1118 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
| 1119 | prop_text_in.text = "WF"; |
| 1120 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
| 1121 | prop_text_in.text = "WC"; |
| 1122 | else if(process_in->state->s == LTTV_STATE_EXIT) |
| 1123 | prop_text_in.text = "E"; |
| 1124 | else if(process_in->state->s == LTTV_STATE_WAIT) |
| 1125 | prop_text_in.text = "W"; |
| 1126 | else if(process_in->state->s == LTTV_STATE_RUN) |
| 1127 | prop_text_in.text = "R"; |
| 1128 | else |
| 1129 | prop_text_in.text = "U"; |
| 1130 | |
| 1131 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
| 1132 | |
| 1133 | |
| 1134 | if(process_in->state->s == LTTV_STATE_RUN) |
| 1135 | { |
| 1136 | gchar tmp[255]; |
| 1137 | prop_text_in.foreground = &colorfg_in; |
| 1138 | prop_text_in.background = &colorbg_in; |
| 1139 | prop_text_in.foreground->red = 0xffff; |
| 1140 | prop_text_in.foreground->green = 0xffff; |
| 1141 | prop_text_in.foreground->blue = 0xffff; |
| 1142 | prop_text_in.size = 6; |
| 1143 | prop_text_in.position = UNDER; |
| 1144 | |
| 1145 | prop_text_in.text = g_new(gchar, 260); |
| 1146 | strcpy(prop_text_in.text, "CPU "); |
| 1147 | snprintf(tmp, 255, "%u", tfc->index); |
| 1148 | strcat(prop_text_in.text, tmp); |
| 1149 | |
| 1150 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
| 1151 | g_free(prop_text_in.text); |
| 1152 | } |
| 1153 | |
| 1154 | |
| 1155 | draw_context_in->current->middle->y = y_in+height/2; |
| 1156 | draw_context_in->current->over->y = y_in; |
| 1157 | draw_context_in->current->under->y = y_in+height; |
| 1158 | draw_context_in->current->status = process_in->state->s; |
| 1159 | |
| 1160 | /* for pid_in : remove previous, Prev = current, new current (default) */ |
| 1161 | g_free(draw_context_in->previous->modify_under); |
| 1162 | g_free(draw_context_in->previous->modify_middle); |
| 1163 | g_free(draw_context_in->previous->modify_over); |
| 1164 | g_free(draw_context_in->previous->under); |
| 1165 | g_free(draw_context_in->previous->middle); |
| 1166 | g_free(draw_context_in->previous->over); |
| 1167 | g_free(draw_context_in->previous); |
| 1168 | |
| 1169 | draw_context_in->previous = draw_context_in->current; |
| 1170 | |
| 1171 | draw_context_in->current = g_new(DrawInfo,1); |
| 1172 | draw_context_in->current->over = g_new(ItemInfo,1); |
| 1173 | draw_context_in->current->over->x = -1; |
| 1174 | draw_context_in->current->over->y = -1; |
| 1175 | draw_context_in->current->middle = g_new(ItemInfo,1); |
| 1176 | draw_context_in->current->middle->x = -1; |
| 1177 | draw_context_in->current->middle->y = -1; |
| 1178 | draw_context_in->current->under = g_new(ItemInfo,1); |
| 1179 | draw_context_in->current->under->x = -1; |
| 1180 | draw_context_in->current->under->y = -1; |
| 1181 | draw_context_in->current->modify_over = g_new(ItemInfo,1); |
| 1182 | draw_context_in->current->modify_over->x = -1; |
| 1183 | draw_context_in->current->modify_over->y = -1; |
| 1184 | draw_context_in->current->modify_middle = g_new(ItemInfo,1); |
| 1185 | draw_context_in->current->modify_middle->x = -1; |
| 1186 | draw_context_in->current->modify_middle->y = -1; |
| 1187 | draw_context_in->current->modify_under = g_new(ItemInfo,1); |
| 1188 | draw_context_in->current->modify_under->x = -1; |
| 1189 | draw_context_in->current->modify_under->y = -1; |
| 1190 | draw_context_in->current->status = LTTV_STATE_UNNAMED; |
| 1191 | |
| 1192 | } |
| 1193 | |
| 1194 | return 0; |
| 1195 | } |
| 1196 | |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | gint update_time_window_hook(void *hook_data, void *call_data) |
| 1201 | { |
| 1202 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
| 1203 | TimeWindow *old_time_window = |
| 1204 | guicontrolflow_get_time_window(control_flow_data); |
| 1205 | TimeWindow *new_time_window = ((TimeWindow*)call_data); |
| 1206 | |
| 1207 | /* Update the ruler */ |
| 1208 | drawing_update_ruler(control_flow_data->drawing, |
| 1209 | new_time_window); |
| 1210 | |
| 1211 | |
| 1212 | /* Two cases : zoom in/out or scrolling */ |
| 1213 | |
| 1214 | /* In order to make sure we can reuse the old drawing, the scale must |
| 1215 | * be the same and the new time interval being partly located in the |
| 1216 | * currently shown time interval. (reuse is only for scrolling) |
| 1217 | */ |
| 1218 | |
| 1219 | g_info("Old time window HOOK : %u, %u to %u, %u", |
| 1220 | old_time_window->start_time.tv_sec, |
| 1221 | old_time_window->start_time.tv_nsec, |
| 1222 | old_time_window->time_width.tv_sec, |
| 1223 | old_time_window->time_width.tv_nsec); |
| 1224 | |
| 1225 | g_info("New time window HOOK : %u, %u to %u, %u", |
| 1226 | new_time_window->start_time.tv_sec, |
| 1227 | new_time_window->start_time.tv_nsec, |
| 1228 | new_time_window->time_width.tv_sec, |
| 1229 | new_time_window->time_width.tv_nsec); |
| 1230 | |
| 1231 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
| 1232 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) |
| 1233 | { |
| 1234 | /* Same scale (scrolling) */ |
| 1235 | g_info("scrolling"); |
| 1236 | LttTime *ns = &new_time_window->start_time; |
| 1237 | LttTime *os = &old_time_window->start_time; |
| 1238 | LttTime old_end = ltt_time_add(old_time_window->start_time, |
| 1239 | old_time_window->time_width); |
| 1240 | LttTime new_end = ltt_time_add(new_time_window->start_time, |
| 1241 | new_time_window->time_width); |
| 1242 | //if(ns<os+w<ns+w) |
| 1243 | //if(ns<os+w && os+w<ns+w) |
| 1244 | //if(ns<old_end && os<ns) |
| 1245 | if(ltt_time_compare(*ns, old_end) == -1 |
| 1246 | && ltt_time_compare(*os, *ns) == -1) |
| 1247 | { |
| 1248 | g_info("scrolling near right"); |
| 1249 | /* Scroll right, keep right part of the screen */ |
| 1250 | guint x = 0; |
| 1251 | guint width = control_flow_data->drawing->drawing_area->allocation.width; |
| 1252 | convert_time_to_pixels( |
| 1253 | *os, |
| 1254 | old_end, |
| 1255 | *ns, |
| 1256 | width, |
| 1257 | &x); |
| 1258 | |
| 1259 | /* Copy old data to new location */ |
| 1260 | gdk_draw_drawable (control_flow_data->drawing->pixmap, |
| 1261 | control_flow_data->drawing->drawing_area->style->black_gc, |
| 1262 | control_flow_data->drawing->pixmap, |
| 1263 | x, 0, |
| 1264 | 0, 0, |
| 1265 | -1, -1); |
| 1266 | |
| 1267 | convert_time_to_pixels( |
| 1268 | *ns, |
| 1269 | new_end, |
| 1270 | old_end, |
| 1271 | width, |
| 1272 | &x); |
| 1273 | |
| 1274 | *old_time_window = *new_time_window; |
| 1275 | /* Clear the data request background, but not SAFETY */ |
| 1276 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
| 1277 | control_flow_data->drawing->drawing_area->style->black_gc, |
| 1278 | TRUE, |
| 1279 | x+SAFETY, 0, |
| 1280 | control_flow_data->drawing->width - x, // do not overlap |
| 1281 | control_flow_data->drawing->height+SAFETY); |
| 1282 | /* Get new data for the rest. */ |
| 1283 | drawing_data_request(control_flow_data->drawing, |
| 1284 | &control_flow_data->drawing->pixmap, |
| 1285 | x, 0, |
| 1286 | control_flow_data->drawing->width - x, |
| 1287 | control_flow_data->drawing->height); |
| 1288 | |
| 1289 | drawing_refresh(control_flow_data->drawing, |
| 1290 | 0, 0, |
| 1291 | control_flow_data->drawing->width, |
| 1292 | control_flow_data->drawing->height); |
| 1293 | |
| 1294 | |
| 1295 | } else { |
| 1296 | //if(ns<os<ns+w) |
| 1297 | //if(ns<os && os<ns+w) |
| 1298 | //if(ns<os && os<new_end) |
| 1299 | if(ltt_time_compare(*ns,*os) == -1 |
| 1300 | && ltt_time_compare(*os,new_end) == -1) |
| 1301 | { |
| 1302 | g_info("scrolling near left"); |
| 1303 | /* Scroll left, keep left part of the screen */ |
| 1304 | guint x = 0; |
| 1305 | guint width = control_flow_data->drawing->drawing_area->allocation.width; |
| 1306 | convert_time_to_pixels( |
| 1307 | *ns, |
| 1308 | new_end, |
| 1309 | *os, |
| 1310 | width, |
| 1311 | &x); |
| 1312 | |
| 1313 | /* Copy old data to new location */ |
| 1314 | gdk_draw_drawable (control_flow_data->drawing->pixmap, |
| 1315 | control_flow_data->drawing->drawing_area->style->black_gc, |
| 1316 | control_flow_data->drawing->pixmap, |
| 1317 | 0, 0, |
| 1318 | x, 0, |
| 1319 | -1, -1); |
| 1320 | |
| 1321 | *old_time_window = *new_time_window; |
| 1322 | |
| 1323 | /* Clean the data request background */ |
| 1324 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
| 1325 | control_flow_data->drawing->drawing_area->style->black_gc, |
| 1326 | TRUE, |
| 1327 | 0, 0, |
| 1328 | x, // do not overlap |
| 1329 | control_flow_data->drawing->height+SAFETY); |
| 1330 | /* Get new data for the rest. */ |
| 1331 | drawing_data_request(control_flow_data->drawing, |
| 1332 | &control_flow_data->drawing->pixmap, |
| 1333 | 0, 0, |
| 1334 | x, |
| 1335 | control_flow_data->drawing->height); |
| 1336 | |
| 1337 | drawing_refresh(control_flow_data->drawing, |
| 1338 | 0, 0, |
| 1339 | control_flow_data->drawing->width, |
| 1340 | control_flow_data->drawing->height); |
| 1341 | |
| 1342 | } else { |
| 1343 | g_info("scrolling far"); |
| 1344 | /* Cannot reuse any part of the screen : far jump */ |
| 1345 | *old_time_window = *new_time_window; |
| 1346 | |
| 1347 | |
| 1348 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
| 1349 | control_flow_data->drawing->drawing_area->style->black_gc, |
| 1350 | TRUE, |
| 1351 | 0, 0, |
| 1352 | control_flow_data->drawing->width+SAFETY, // do not overlap |
| 1353 | control_flow_data->drawing->height+SAFETY); |
| 1354 | |
| 1355 | drawing_data_request(control_flow_data->drawing, |
| 1356 | &control_flow_data->drawing->pixmap, |
| 1357 | 0, 0, |
| 1358 | control_flow_data->drawing->width, |
| 1359 | control_flow_data->drawing->height); |
| 1360 | |
| 1361 | drawing_refresh(control_flow_data->drawing, |
| 1362 | 0, 0, |
| 1363 | control_flow_data->drawing->width, |
| 1364 | control_flow_data->drawing->height); |
| 1365 | } |
| 1366 | } |
| 1367 | } else { |
| 1368 | /* Different scale (zoom) */ |
| 1369 | g_info("zoom"); |
| 1370 | |
| 1371 | *old_time_window = *new_time_window; |
| 1372 | |
| 1373 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
| 1374 | control_flow_data->drawing->drawing_area->style->black_gc, |
| 1375 | TRUE, |
| 1376 | 0, 0, |
| 1377 | control_flow_data->drawing->width+SAFETY, // do not overlap |
| 1378 | control_flow_data->drawing->height+SAFETY); |
| 1379 | |
| 1380 | |
| 1381 | drawing_data_request(control_flow_data->drawing, |
| 1382 | &control_flow_data->drawing->pixmap, |
| 1383 | 0, 0, |
| 1384 | control_flow_data->drawing->width, |
| 1385 | control_flow_data->drawing->height); |
| 1386 | |
| 1387 | drawing_refresh(control_flow_data->drawing, |
| 1388 | 0, 0, |
| 1389 | control_flow_data->drawing->width, |
| 1390 | control_flow_data->drawing->height); |
| 1391 | } |
| 1392 | |
| 1393 | |
| 1394 | |
| 1395 | return 0; |
| 1396 | } |
| 1397 | |
| 1398 | gint update_current_time_hook(void *hook_data, void *call_data) |
| 1399 | { |
| 1400 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
| 1401 | |
| 1402 | LttTime* current_time = |
| 1403 | guicontrolflow_get_current_time(control_flow_data); |
| 1404 | *current_time = *((LttTime*)call_data); |
| 1405 | |
| 1406 | TimeWindow time_window; |
| 1407 | |
| 1408 | LttTime time_begin = control_flow_data->time_window.start_time; |
| 1409 | LttTime width = control_flow_data->time_window.time_width; |
| 1410 | LttTime half_width = ltt_time_div(width,2.0); |
| 1411 | LttTime time_end = ltt_time_add(time_begin, width); |
| 1412 | |
| 1413 | LttvTracesetContext * tsc = |
| 1414 | get_traceset_context(control_flow_data->mw); |
| 1415 | |
| 1416 | LttTime trace_start = tsc->Time_Span->startTime; |
| 1417 | LttTime trace_end = tsc->Time_Span->endTime; |
| 1418 | |
| 1419 | g_info("New current time HOOK : %u, %u", current_time->tv_sec, |
| 1420 | current_time->tv_nsec); |
| 1421 | |
| 1422 | |
| 1423 | |
| 1424 | /* If current time is inside time interval, just move the highlight |
| 1425 | * bar */ |
| 1426 | |
| 1427 | /* Else, we have to change the time interval. We have to tell it |
| 1428 | * to the main window. */ |
| 1429 | /* The time interval change will take care of placing the current |
| 1430 | * time at the center of the visible area, or nearest possible if we are |
| 1431 | * at one end of the trace. */ |
| 1432 | |
| 1433 | |
| 1434 | if(ltt_time_compare(*current_time, time_begin) == -1) |
| 1435 | { |
| 1436 | if(ltt_time_compare(*current_time, |
| 1437 | ltt_time_add(trace_start,half_width)) == -1) |
| 1438 | time_begin = trace_start; |
| 1439 | else |
| 1440 | time_begin = ltt_time_sub(*current_time,half_width); |
| 1441 | |
| 1442 | time_window.start_time = time_begin; |
| 1443 | time_window.time_width = width; |
| 1444 | |
| 1445 | set_time_window(control_flow_data->mw, &time_window); |
| 1446 | } |
| 1447 | else if(ltt_time_compare(*current_time, time_end) == 1) |
| 1448 | { |
| 1449 | if(ltt_time_compare(*current_time, ltt_time_sub(trace_end, half_width)) == 1) |
| 1450 | time_begin = ltt_time_sub(trace_end,width); |
| 1451 | else |
| 1452 | time_begin = ltt_time_sub(*current_time,half_width); |
| 1453 | |
| 1454 | time_window.start_time = time_begin; |
| 1455 | time_window.time_width = width; |
| 1456 | |
| 1457 | set_time_window(control_flow_data->mw, &time_window); |
| 1458 | |
| 1459 | } |
| 1460 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
| 1461 | |
| 1462 | return 0; |
| 1463 | } |
| 1464 | |
| 1465 | typedef struct _ClosureData { |
| 1466 | EventRequest *event_request; |
| 1467 | LttvTracesetState *tss; |
| 1468 | } ClosureData; |
| 1469 | |
| 1470 | |
| 1471 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
| 1472 | { |
| 1473 | ProcessInfo *process_info = (ProcessInfo*)key; |
| 1474 | HashedProcessData *hashed_process_data = (HashedProcessData*)value; |
| 1475 | ClosureData *closure_data = (ClosureData*)user_data; |
| 1476 | |
| 1477 | ControlFlowData *control_flow_data = |
| 1478 | closure_data->event_request->control_flow_data; |
| 1479 | |
| 1480 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
| 1481 | |
| 1482 | /* Get y position of process */ |
| 1483 | gint y=0, height=0; |
| 1484 | |
| 1485 | processlist_get_pixels_from_data( control_flow_data->process_list, |
| 1486 | process_info, |
| 1487 | hashed_process_data, |
| 1488 | &y, |
| 1489 | &height); |
| 1490 | /* Get last state of process */ |
| 1491 | LttvTraceContext *tc = |
| 1492 | ((LttvTracesetContext*)closure_data->tss)->traces[process_info->trace_num]; |
| 1493 | //LttvTracefileContext *tfc = (LttvTracefileContext *)closure_data->ts; |
| 1494 | |
| 1495 | LttvTraceState *ts = (LttvTraceState*)tc; |
| 1496 | LttvProcessState *process; |
| 1497 | |
| 1498 | /* We do not provide a cpu_name argument assuming that this is not the |
| 1499 | idle job (pid 0) and thus its pid is unique across all cpus */ |
| 1500 | process = lttv_state_find_process_from_trace(ts, 0, process_info->pid); |
| 1501 | |
| 1502 | /* Draw the closing line */ |
| 1503 | DrawContext *draw_context = hashed_process_data->draw_context; |
| 1504 | if(draw_context->previous->middle->x == -1) |
| 1505 | { |
| 1506 | draw_context->previous->middle->x = closure_data->event_request->x_begin; |
| 1507 | draw_context->previous->over->x = closure_data->event_request->x_begin; |
| 1508 | draw_context->previous->under->x = closure_data->event_request->x_begin; |
| 1509 | g_debug("out middle x_beg : %u",closure_data->event_request->x_begin); |
| 1510 | } |
| 1511 | |
| 1512 | draw_context->current->middle->x = closure_data->event_request->x_end; |
| 1513 | draw_context->current->over->x = closure_data->event_request->x_end; |
| 1514 | draw_context->current->under->x = closure_data->event_request->x_end; |
| 1515 | draw_context->current->middle->y = y + height/2; |
| 1516 | draw_context->current->over->y = y ; |
| 1517 | draw_context->current->under->y = y + height; |
| 1518 | draw_context->previous->middle->y = y + height/2; |
| 1519 | draw_context->previous->over->y = y ; |
| 1520 | draw_context->previous->under->y = y + height; |
| 1521 | draw_context->drawable = control_flow_data->drawing->pixmap; |
| 1522 | draw_context->pango_layout = control_flow_data->drawing->pango_layout; |
| 1523 | //draw_context->gc = widget->style->black_gc; |
| 1524 | draw_context->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
| 1525 | gdk_gc_copy(draw_context->gc, widget->style->black_gc); |
| 1526 | |
| 1527 | if(process != NULL && process->state->s == LTTV_STATE_RUN) |
| 1528 | { |
| 1529 | PropertiesBG prop_bg; |
| 1530 | prop_bg.color = g_new(GdkColor,1); |
| 1531 | |
| 1532 | /*switch(tfc->index) { |
| 1533 | case 0: |
| 1534 | prop_bg.color->red = 0x1515; |
| 1535 | prop_bg.color->green = 0x1515; |
| 1536 | prop_bg.color->blue = 0x8c8c; |
| 1537 | break; |
| 1538 | case 1: |
| 1539 | prop_bg.color->red = 0x4e4e; |
| 1540 | prop_bg.color->green = 0xa9a9; |
| 1541 | prop_bg.color->blue = 0xa4a4; |
| 1542 | break; |
| 1543 | case 2: |
| 1544 | prop_bg.color->red = 0x7a7a; |
| 1545 | prop_bg.color->green = 0x4a4a; |
| 1546 | prop_bg.color->blue = 0x8b8b; |
| 1547 | break; |
| 1548 | case 3: |
| 1549 | prop_bg.color->red = 0x8080; |
| 1550 | prop_bg.color->green = 0x7777; |
| 1551 | prop_bg.color->blue = 0x4747; |
| 1552 | break; |
| 1553 | default: |
| 1554 | prop_bg.color->red = 0xe7e7; |
| 1555 | prop_bg.color->green = 0xe7e7; |
| 1556 | prop_bg.color->blue = 0xe7e7; |
| 1557 | } |
| 1558 | */ |
| 1559 | |
| 1560 | g_debug("calling from closure"); |
| 1561 | //FIXME : I need the cpu number in process's state to draw this. |
| 1562 | //draw_bg((void*)&prop_bg, (void*)draw_context); |
| 1563 | g_free(prop_bg.color); |
| 1564 | } |
| 1565 | |
| 1566 | |
| 1567 | PropertiesLine prop_line; |
| 1568 | prop_line.color = g_new(GdkColor,1); |
| 1569 | prop_line.line_width = 2; |
| 1570 | prop_line.style = GDK_LINE_SOLID; |
| 1571 | prop_line.position = MIDDLE; |
| 1572 | |
| 1573 | /* color of line : status of the process */ |
| 1574 | if(process != NULL) |
| 1575 | { |
| 1576 | if(process->state->s == LTTV_STATE_UNNAMED) |
| 1577 | { |
| 1578 | prop_line.color->red = 0xffff; |
| 1579 | prop_line.color->green = 0xffff; |
| 1580 | prop_line.color->blue = 0xffff; |
| 1581 | } |
| 1582 | else if(process->state->s == LTTV_STATE_WAIT_FORK) |
| 1583 | { |
| 1584 | prop_line.color->red = 0x0fff; |
| 1585 | prop_line.color->green = 0xffff; |
| 1586 | prop_line.color->blue = 0xfff0; |
| 1587 | } |
| 1588 | else if(process->state->s == LTTV_STATE_WAIT_CPU) |
| 1589 | { |
| 1590 | prop_line.color->red = 0xffff; |
| 1591 | prop_line.color->green = 0xffff; |
| 1592 | prop_line.color->blue = 0x0000; |
| 1593 | } |
| 1594 | else if(process->state->s == LTTV_STATE_EXIT) |
| 1595 | { |
| 1596 | prop_line.color->red = 0xffff; |
| 1597 | prop_line.color->green = 0x0000; |
| 1598 | prop_line.color->blue = 0xffff; |
| 1599 | } |
| 1600 | else if(process->state->s == LTTV_STATE_WAIT) |
| 1601 | { |
| 1602 | prop_line.color->red = 0xffff; |
| 1603 | prop_line.color->green = 0x0000; |
| 1604 | prop_line.color->blue = 0x0000; |
| 1605 | } |
| 1606 | else if(process->state->s == LTTV_STATE_RUN) |
| 1607 | { |
| 1608 | prop_line.color->red = 0x0000; |
| 1609 | prop_line.color->green = 0xffff; |
| 1610 | prop_line.color->blue = 0x0000; |
| 1611 | } |
| 1612 | else |
| 1613 | { |
| 1614 | prop_line.color->red = 0xffff; |
| 1615 | prop_line.color->green = 0xffff; |
| 1616 | prop_line.color->blue = 0xffff; |
| 1617 | } |
| 1618 | |
| 1619 | } |
| 1620 | else |
| 1621 | { |
| 1622 | prop_line.color->red = 0xffff; |
| 1623 | prop_line.color->green = 0xffff; |
| 1624 | prop_line.color->blue = 0xffff; |
| 1625 | } |
| 1626 | |
| 1627 | draw_line((void*)&prop_line, (void*)draw_context); |
| 1628 | g_free(prop_line.color); |
| 1629 | gdk_gc_unref(draw_context->gc); |
| 1630 | |
| 1631 | /* Reset draw_context of the process for next request */ |
| 1632 | |
| 1633 | hashed_process_data->draw_context->drawable = NULL; |
| 1634 | hashed_process_data->draw_context->gc = NULL; |
| 1635 | hashed_process_data->draw_context->pango_layout = NULL; |
| 1636 | hashed_process_data->draw_context->current->over->x = -1; |
| 1637 | hashed_process_data->draw_context->current->over->y = -1; |
| 1638 | hashed_process_data->draw_context->current->middle->x = -1; |
| 1639 | hashed_process_data->draw_context->current->middle->y = -1; |
| 1640 | hashed_process_data->draw_context->current->under->x = -1; |
| 1641 | hashed_process_data->draw_context->current->under->y = -1; |
| 1642 | hashed_process_data->draw_context->current->modify_over->x = -1; |
| 1643 | hashed_process_data->draw_context->current->modify_over->y = -1; |
| 1644 | hashed_process_data->draw_context->current->modify_middle->x = -1; |
| 1645 | hashed_process_data->draw_context->current->modify_middle->y = -1; |
| 1646 | hashed_process_data->draw_context->current->modify_under->x = -1; |
| 1647 | hashed_process_data->draw_context->current->modify_under->y = -1; |
| 1648 | hashed_process_data->draw_context->current->status = LTTV_STATE_UNNAMED; |
| 1649 | hashed_process_data->draw_context->previous->over->x = -1; |
| 1650 | hashed_process_data->draw_context->previous->over->y = -1; |
| 1651 | hashed_process_data->draw_context->previous->middle->x = -1; |
| 1652 | hashed_process_data->draw_context->previous->middle->y = -1; |
| 1653 | hashed_process_data->draw_context->previous->under->x = -1; |
| 1654 | hashed_process_data->draw_context->previous->under->y = -1; |
| 1655 | hashed_process_data->draw_context->previous->modify_over->x = -1; |
| 1656 | hashed_process_data->draw_context->previous->modify_over->y = -1; |
| 1657 | hashed_process_data->draw_context->previous->modify_middle->x = -1; |
| 1658 | hashed_process_data->draw_context->previous->modify_middle->y = -1; |
| 1659 | hashed_process_data->draw_context->previous->modify_under->x = -1; |
| 1660 | hashed_process_data->draw_context->previous->modify_under->y = -1; |
| 1661 | hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED; |
| 1662 | |
| 1663 | |
| 1664 | } |
| 1665 | |
| 1666 | /* |
| 1667 | * for each process |
| 1668 | * draw closing line |
| 1669 | * new default prev and current |
| 1670 | */ |
| 1671 | int after_data_request(void *hook_data, void *call_data) |
| 1672 | { |
| 1673 | EventRequest *event_request = (EventRequest*)hook_data; |
| 1674 | ControlFlowData *control_flow_data = event_request->control_flow_data; |
| 1675 | |
| 1676 | ProcessList *process_list = |
| 1677 | guicontrolflow_get_process_list(event_request->control_flow_data); |
| 1678 | |
| 1679 | ClosureData closure_data; |
| 1680 | closure_data.event_request = (EventRequest*)hook_data; |
| 1681 | closure_data.tss = (LttvTracesetState*)call_data; |
| 1682 | |
| 1683 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
| 1684 | (void*)&closure_data); |
| 1685 | |
| 1686 | } |
| 1687 | |