Commit | Line | Data |
---|---|---|
9e01e6d4 | 1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2003-2004 Mathieu Desnoyers | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License Version 2 as | |
6 | * published by the Free Software Foundation; | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program; if not, write to the Free Software | |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | |
16 | * MA 02111-1307, USA. | |
17 | */ | |
18 | ||
19 | ||
20 | /***************************************************************************** | |
21 | * Hooks to be called by the main window * | |
22 | *****************************************************************************/ | |
23 | ||
24 | ||
25 | /* Event hooks are the drawing hooks called during traceset read. They draw the | |
26 | * icons, text, lines and background color corresponding to the events read. | |
27 | * | |
28 | * Two hooks are used for drawing : before_schedchange and after_schedchange hooks. The | |
29 | * before_schedchange is called before the state update that occurs with an event and | |
30 | * the after_schedchange hook is called after this state update. | |
31 | * | |
32 | * The before_schedchange hooks fulfill the task of drawing the visible objects that | |
33 | * corresponds to the data accumulated by the after_schedchange hook. | |
34 | * | |
35 | * The after_schedchange hook accumulates the data that need to be shown on the screen | |
36 | * (items) into a queue. Then, the next before_schedchange hook will draw what that | |
37 | * queue contains. That's the Right Way (TM) of drawing items on the screen, | |
38 | * because we need to draw the background first (and then add icons, text, ... | |
39 | * over it), but we only know the length of a background region once the state | |
40 | * corresponding to it is over, which happens to be at the next before_schedchange | |
41 | * hook. | |
42 | * | |
43 | * We also have a hook called at the end of a chunk to draw the information left | |
44 | * undrawn in each process queue. We use the current time as end of | |
45 | * line/background. | |
46 | */ | |
47 | ||
48 | #ifdef HAVE_CONFIG_H | |
49 | #include <config.h> | |
50 | #endif | |
51 | ||
52 | //#define PANGO_ENABLE_BACKEND | |
53 | #include <gtk/gtk.h> | |
54 | #include <gdk/gdk.h> | |
55 | #include <glib.h> | |
56 | #include <assert.h> | |
57 | #include <string.h> | |
58 | #include <stdio.h> | |
43ed82b5 | 59 | #include <inttypes.h> |
9e01e6d4 | 60 | |
61 | //#include <pango/pango.h> | |
62 | ||
63 | #include <ltt/event.h> | |
64 | #include <ltt/time.h> | |
9e01e6d4 | 65 | #include <ltt/trace.h> |
66 | ||
67 | #include <lttv/lttv.h> | |
68 | #include <lttv/hook.h> | |
69 | #include <lttv/state.h> | |
70 | #include <lttvwindow/lttvwindow.h> | |
71 | #include <lttvwindow/lttvwindowtraces.h> | |
72 | #include <lttvwindow/support.h> | |
73 | ||
74 | ||
75 | #include "eventhooks.h" | |
76 | #include "cfv.h" | |
77 | #include "processlist.h" | |
78 | #include "drawing.h" | |
79 | ||
80 | ||
81 | #define MAX_PATH_LEN 256 | |
3d27be8a | 82 | #define STATE_LINE_WIDTH 6 |
9e01e6d4 | 83 | #define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3) |
84 | ||
85 | extern GSList *g_legend_list; | |
86 | ||
87 | ||
88 | /* Action to do when background computation completed. | |
89 | * | |
90 | * Wait for all the awaited computations to be over. | |
91 | */ | |
92 | ||
93 | static gint background_ready(void *hook_data, void *call_data) | |
94 | { | |
67f72973 | 95 | ControlFlowData *resourceview_data = (ControlFlowData *)hook_data; |
9e01e6d4 | 96 | |
67f72973 | 97 | resourceview_data->background_info_waiting--; |
9e01e6d4 | 98 | |
67f72973 | 99 | if(resourceview_data->background_info_waiting == 0) { |
9e01e6d4 | 100 | g_message("control flow viewer : background computation data ready."); |
101 | ||
67f72973 | 102 | drawing_clear(resourceview_data->drawing); |
103 | processlist_clear(resourceview_data->process_list); | |
9e01e6d4 | 104 | gtk_widget_set_size_request( |
67f72973 | 105 | resourceview_data->drawing->drawing_area, |
106 | -1, processlist_get_height(resourceview_data->process_list)); | |
107 | redraw_notify(resourceview_data, NULL); | |
9e01e6d4 | 108 | } |
109 | ||
110 | return 0; | |
111 | } | |
112 | ||
113 | ||
114 | /* Request background computation. Verify if it is in progress or ready first. | |
115 | * Only for each trace in the tab's traceset. | |
116 | */ | |
67f72973 | 117 | static void request_background_data(ControlFlowData *resourceview_data) |
9e01e6d4 | 118 | { |
dd47d0d8 YB |
119 | LttvTraceset* ts = |
120 | lttvwindow_get_traceset(resourceview_data->tab); | |
121 | gint num_traces = lttv_traceset_number(ts); | |
9e01e6d4 | 122 | gint i; |
123 | LttvTrace *trace; | |
124 | LttvTraceState *tstate; | |
125 | ||
126 | LttvHooks *background_ready_hook = | |
127 | lttv_hooks_new(); | |
67f72973 | 128 | lttv_hooks_add(background_ready_hook, background_ready, resourceview_data, |
9e01e6d4 | 129 | LTTV_PRIO_DEFAULT); |
67f72973 | 130 | resourceview_data->background_info_waiting = 0; |
9e01e6d4 | 131 | |
132 | for(i=0;i<num_traces;i++) { | |
dd47d0d8 YB |
133 | trace = lttv_traceset_get(ts, i); |
134 | ||
9e01e6d4 | 135 | if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE |
dd47d0d8 | 136 | && !ts->has_precomputed_states) { |
9e01e6d4 | 137 | |
138 | if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"), | |
139 | trace) == FALSE) { | |
140 | /* We first remove requests that could have been done for the same | |
141 | * information. Happens when two viewers ask for it before servicing | |
142 | * starts. | |
143 | */ | |
144 | if(!lttvwindowtraces_background_request_find(trace, "state")) | |
145 | lttvwindowtraces_background_request_queue( | |
67f72973 | 146 | main_window_get_widget(resourceview_data->tab), trace, "state"); |
147 | lttvwindowtraces_background_notify_queue(resourceview_data, | |
9e01e6d4 | 148 | trace, |
149 | ltt_time_infinite, | |
150 | NULL, | |
151 | background_ready_hook); | |
67f72973 | 152 | resourceview_data->background_info_waiting++; |
9e01e6d4 | 153 | } else { /* in progress */ |
154 | ||
67f72973 | 155 | lttvwindowtraces_background_notify_current(resourceview_data, |
9e01e6d4 | 156 | trace, |
157 | ltt_time_infinite, | |
158 | NULL, | |
159 | background_ready_hook); | |
67f72973 | 160 | resourceview_data->background_info_waiting++; |
9e01e6d4 | 161 | } |
162 | } else { | |
163 | /* Data ready. By its nature, this viewer doesn't need to have | |
164 | * its data ready hook called there, because a background | |
165 | * request is always linked with a redraw. | |
166 | */ | |
167 | } | |
9e01e6d4 | 168 | } |
169 | ||
170 | lttv_hooks_destroy(background_ready_hook); | |
171 | } | |
172 | ||
173 | ||
9e01e6d4 | 174 | /** |
175 | * Event Viewer's constructor hook | |
176 | * | |
177 | * This constructor is given as a parameter to the menuitem and toolbar button | |
178 | * registration. It creates the list. | |
179 | * @param tab A pointer to the parent tab. | |
180 | * @return The widget created. | |
181 | */ | |
182 | GtkWidget * | |
58a9b31b | 183 | h_resourceview(LttvPlugin *plugin) |
9e01e6d4 | 184 | { |
185 | LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin); | |
186 | Tab *tab = ptab->tab; | |
187 | g_info("h_guicontrolflow, %p", tab); | |
67f72973 | 188 | ControlFlowData *resourceview_data = resourceview(ptab); |
9e01e6d4 | 189 | |
67f72973 | 190 | resourceview_data->tab = tab; |
9e01e6d4 | 191 | |
192 | // Unreg done in the GuiControlFlow_Destructor | |
193 | lttvwindow_register_traceset_notify(tab, | |
194 | traceset_notify, | |
67f72973 | 195 | resourceview_data); |
9e01e6d4 | 196 | |
197 | lttvwindow_register_time_window_notify(tab, | |
198 | update_time_window_hook, | |
67f72973 | 199 | resourceview_data); |
9e01e6d4 | 200 | lttvwindow_register_current_time_notify(tab, |
201 | update_current_time_hook, | |
67f72973 | 202 | resourceview_data); |
9e01e6d4 | 203 | lttvwindow_register_redraw_notify(tab, |
204 | redraw_notify, | |
67f72973 | 205 | resourceview_data); |
9e01e6d4 | 206 | lttvwindow_register_continue_notify(tab, |
207 | continue_notify, | |
67f72973 | 208 | resourceview_data); |
209 | request_background_data(resourceview_data); | |
9e01e6d4 | 210 | |
211 | ||
67f72973 | 212 | return guicontrolflow_get_widget(resourceview_data) ; |
9e01e6d4 | 213 | |
214 | } | |
215 | ||
216 | void legend_destructor(GtkWindow *legend) | |
217 | { | |
218 | g_legend_list = g_slist_remove(g_legend_list, legend); | |
219 | } | |
220 | ||
221 | /* Create a popup legend */ | |
222 | GtkWidget * | |
223 | h_legend(LttvPlugin *plugin) | |
224 | { | |
225 | LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin); | |
226 | Tab *tab = ptab->tab; | |
227 | g_info("h_legend, %p", tab); | |
228 | ||
229 | GtkWindow *legend = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | |
230 | ||
231 | g_legend_list = g_slist_append( | |
232 | g_legend_list, | |
233 | legend); | |
234 | ||
235 | g_object_set_data_full( | |
236 | G_OBJECT(legend), | |
237 | "legend", | |
238 | legend, | |
239 | (GDestroyNotify)legend_destructor); | |
240 | ||
241 | gtk_window_set_title(legend, "Control Flow View Legend"); | |
242 | ||
243 | GtkWidget *pixmap = create_pixmap(GTK_WIDGET(legend), "lttv-color-list.png"); | |
244 | ||
9e01e6d4 | 245 | gtk_container_add(GTK_CONTAINER(legend), GTK_WIDGET(pixmap)); |
246 | ||
247 | gtk_widget_show(GTK_WIDGET(pixmap)); | |
248 | gtk_widget_show(GTK_WIDGET(legend)); | |
249 | ||
250 | ||
251 | return NULL; /* This is a popup window */ | |
252 | } | |
253 | ||
254 | ||
255 | int event_selected_hook(void *hook_data, void *call_data) | |
256 | { | |
9e01e6d4 | 257 | guint *event_number = (guint*) call_data; |
258 | ||
259 | g_debug("DEBUG : event selected by main window : %u", *event_number); | |
260 | ||
261 | return 0; | |
262 | } | |
263 | ||
d3d99fde | 264 | static void cpu_set_line_color(PropertiesLine *prop_line, LttvCPUState *s) |
598026ba | 265 | { |
1b171947 | 266 | GQuark present_state; |
267 | ||
268 | if(s->mode_stack->len == 0) | |
269 | present_state = LTTV_CPU_UNKNOWN; | |
270 | else | |
271 | present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; | |
d3d99fde | 272 | |
201fcc15 | 273 | if(present_state == LTTV_CPU_IDLE) { |
598026ba | 274 | prop_line->color = drawing_colors_cpu[COL_CPU_IDLE]; |
275 | } | |
276 | else if(present_state == LTTV_CPU_BUSY) { | |
277 | prop_line->color = drawing_colors_cpu[COL_CPU_BUSY]; | |
278 | } | |
279 | else if(present_state == LTTV_CPU_IRQ) { | |
280 | prop_line->color = drawing_colors_cpu[COL_CPU_IRQ]; | |
281 | } | |
d34141ca | 282 | else if(present_state == LTTV_CPU_SOFT_IRQ) { |
283 | prop_line->color = drawing_colors_cpu[COL_CPU_SOFT_IRQ]; | |
284 | } | |
d3d99fde | 285 | else if(present_state == LTTV_CPU_TRAP) { |
286 | prop_line->color = drawing_colors_cpu[COL_CPU_TRAP]; | |
201fcc15 | 287 | } else { |
288 | prop_line->color = drawing_colors_cpu[COL_CPU_UNKNOWN]; | |
d3d99fde | 289 | } |
598026ba | 290 | } |
9e01e6d4 | 291 | |
8743690d | 292 | static void irq_set_line_color(PropertiesLine *prop_line, LttvIRQState *s) |
293 | { | |
1b171947 | 294 | GQuark present_state; |
295 | if(s->mode_stack->len == 0) | |
296 | present_state = LTTV_IRQ_UNKNOWN; | |
297 | else | |
298 | present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; | |
8743690d | 299 | |
1b171947 | 300 | if(present_state == LTTV_IRQ_IDLE) { |
8743690d | 301 | prop_line->color = drawing_colors_irq[COL_IRQ_IDLE]; |
302 | } | |
303 | else if(present_state == LTTV_IRQ_BUSY) { | |
304 | prop_line->color = drawing_colors_irq[COL_IRQ_BUSY]; | |
305 | } | |
1b171947 | 306 | else { |
307 | prop_line->color = drawing_colors_irq[COL_IRQ_UNKNOWN]; | |
308 | } | |
8743690d | 309 | } |
310 | ||
0305fe77 | 311 | static void soft_irq_set_line_color(PropertiesLine *prop_line, LttvSoftIRQState *s) |
312 | { | |
67c73bb3 | 313 | if(s->running) |
0305fe77 | 314 | prop_line->color = drawing_colors_soft_irq[COL_SOFT_IRQ_BUSY]; |
67c73bb3 | 315 | else if(s->pending) |
316 | prop_line->color = drawing_colors_soft_irq[COL_SOFT_IRQ_PENDING]; | |
317 | else | |
318 | prop_line->color = drawing_colors_soft_irq[COL_SOFT_IRQ_IDLE]; | |
0305fe77 | 319 | } |
320 | ||
38726a78 | 321 | static void trap_set_line_color(PropertiesLine *prop_line, LttvTrapState *s) |
322 | { | |
38726a78 | 323 | if(s->running == 0) |
324 | prop_line->color = drawing_colors_trap[COL_TRAP_IDLE]; | |
325 | else | |
326 | prop_line->color = drawing_colors_trap[COL_TRAP_BUSY]; | |
327 | } | |
328 | ||
20d16f82 | 329 | static void bdev_set_line_color(PropertiesLine *prop_line, LttvBdevState *s) |
330 | { | |
1b171947 | 331 | GQuark present_state; |
23e59a12 | 332 | if(s == 0 || s->mode_stack->len == 0) |
1b171947 | 333 | present_state = LTTV_BDEV_UNKNOWN; |
334 | else | |
335 | present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; | |
20d16f82 | 336 | |
1b171947 | 337 | if(present_state == LTTV_BDEV_IDLE) { |
20d16f82 | 338 | prop_line->color = drawing_colors_bdev[COL_BDEV_IDLE]; |
339 | } | |
340 | else if(present_state == LTTV_BDEV_BUSY_READING) { | |
341 | prop_line->color = drawing_colors_bdev[COL_BDEV_BUSY_READING]; | |
342 | } | |
343 | else if(present_state == LTTV_BDEV_BUSY_WRITING) { | |
344 | prop_line->color = drawing_colors_bdev[COL_BDEV_BUSY_WRITING]; | |
345 | } | |
1b171947 | 346 | else { |
347 | prop_line->color = drawing_colors_bdev[COL_BDEV_UNKNOWN]; | |
348 | } | |
20d16f82 | 349 | } |
350 | ||
9e01e6d4 | 351 | /* before_schedchange_hook |
352 | * | |
353 | * This function basically draw lines and icons. Two types of lines are drawn : | |
354 | * one small (3 pixels?) representing the state of the process and the second | |
355 | * type is thicker (10 pixels?) representing on which CPU a process is running | |
356 | * (and this only in running state). | |
357 | * | |
358 | * Extremums of the lines : | |
359 | * x_min : time of the last event context for this process kept in memory. | |
360 | * x_max : time of the current event. | |
361 | * y : middle of the process in the process list. The process is found in the | |
362 | * list, therefore is it's position in pixels. | |
363 | * | |
364 | * The choice of lines'color is defined by the context of the last event for this | |
365 | * process. | |
366 | */ | |
367 | ||
368 | ||
369 | int before_schedchange_hook(void *hook_data, void *call_data) | |
370 | { | |
9e01e6d4 | 371 | |
dd47d0d8 YB |
372 | LttvEvent *event; |
373 | LttvTraceState *ts; | |
9e01e6d4 | 374 | |
dd47d0d8 YB |
375 | event = (LttvEvent *) call_data; |
376 | if (strcmp(lttv_traceset_get_name_from_event(event),"sched_switch") != 0) | |
377 | return FALSE; | |
9e01e6d4 | 378 | |
dd47d0d8 | 379 | ControlFlowData *resourceview_data = (ControlFlowData*)hook_data; |
9e01e6d4 | 380 | |
dd47d0d8 | 381 | LttTime evtime = lttv_event_get_timestamp(event); |
58a9b31b | 382 | |
9e01e6d4 | 383 | /* we are in a schedchange, before the state update. We must draw the |
384 | * items corresponding to the state before it changes : now is the right | |
385 | * time to do it. | |
386 | */ | |
387 | ||
388 | guint pid_out; | |
dd47d0d8 | 389 | pid_out = lttv_event_get_long(event, "prev_tid"); |
67f72973 | 390 | // TODO: can't we reenable this? pmf |
44ffb95f | 391 | // if(pid_in != 0 && pid_out != 0) { |
392 | // /* not a transition to/from idle */ | |
393 | // return 0; | |
394 | // } | |
c4e6f4dc | 395 | |
58a9b31b | 396 | |
dd47d0d8 YB |
397 | guint cpu = lttv_traceset_get_cpuid_from_event(event); |
398 | ts = event->state; | |
9e01e6d4 | 399 | |
dd47d0d8 | 400 | guint trace_num = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number |
8d8c5ea7 | 401 | /* Add process to process list (if not present) */ |
67f72973 | 402 | HashedResourceData *hashed_process_data = NULL; |
9e01e6d4 | 403 | |
67f72973 | 404 | hashed_process_data = resourcelist_obtain_cpu(resourceview_data, trace_num, cpu); |
405 | ||
406 | /* Now, the process is in the state hash and our own process hash. | |
407 | * We definitely can draw the items related to the ending state. | |
408 | */ | |
409 | ||
410 | if(ltt_time_compare(hashed_process_data->next_good_time, | |
411 | evtime) > 0) | |
412 | { | |
413 | if(hashed_process_data->x.middle_marked == FALSE) { | |
414 | ||
415 | TimeWindow time_window = | |
416 | lttvwindow_get_time_window(resourceview_data->tab); | |
9e01e6d4 | 417 | #ifdef EXTRA_CHECK |
67f72973 | 418 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
419 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
420 | return; | |
9e01e6d4 | 421 | #endif //EXTRA_CHECK |
67f72973 | 422 | Drawing_t *drawing = resourceview_data->drawing; |
423 | guint width = drawing->width; | |
424 | guint x; | |
425 | convert_time_to_pixels( | |
426 | time_window, | |
427 | evtime, | |
428 | width, | |
429 | &x); | |
430 | ||
431 | /* Draw collision indicator */ | |
432 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
433 | gdk_draw_point(hashed_process_data->pixmap, | |
434 | drawing->gc, | |
435 | x, | |
436 | COLLISION_POSITION(hashed_process_data->height)); | |
437 | hashed_process_data->x.middle_marked = TRUE; | |
438 | } | |
439 | } else { | |
440 | TimeWindow time_window = | |
441 | lttvwindow_get_time_window(resourceview_data->tab); | |
9e01e6d4 | 442 | #ifdef EXTRA_CHECK |
67f72973 | 443 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
9e01e6d4 | 444 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
67f72973 | 445 | return; |
9e01e6d4 | 446 | #endif //EXTRA_CHECK |
67f72973 | 447 | Drawing_t *drawing = resourceview_data->drawing; |
448 | guint width = drawing->width; | |
449 | guint x; | |
450 | convert_time_to_pixels( | |
451 | time_window, | |
452 | evtime, | |
453 | width, | |
454 | &x); | |
9e01e6d4 | 455 | |
67f72973 | 456 | /* Jump over draw if we are at the same x position */ |
457 | if(x == hashed_process_data->x.middle && | |
458 | hashed_process_data->x.middle_used) | |
459 | { | |
460 | if(hashed_process_data->x.middle_marked == FALSE) { | |
461 | /* Draw collision indicator */ | |
462 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
463 | gdk_draw_point(hashed_process_data->pixmap, | |
464 | drawing->gc, | |
465 | x, | |
466 | COLLISION_POSITION(hashed_process_data->height)); | |
467 | hashed_process_data->x.middle_marked = TRUE; | |
58a9b31b | 468 | } |
67f72973 | 469 | /* jump */ |
470 | } else { | |
471 | DrawContext draw_context; | |
9e01e6d4 | 472 | |
67f72973 | 473 | /* Now create the drawing context that will be used to draw |
474 | * items related to the last state. */ | |
475 | draw_context.drawable = hashed_process_data->pixmap; | |
476 | draw_context.gc = drawing->gc; | |
477 | draw_context.pango_layout = drawing->pango_layout; | |
478 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; | |
479 | draw_context.drawinfo.end.x = x; | |
9e01e6d4 | 480 | |
67f72973 | 481 | draw_context.drawinfo.y.over = 1; |
482 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); | |
483 | draw_context.drawinfo.y.under = hashed_process_data->height; | |
9e01e6d4 | 484 | |
67f72973 | 485 | draw_context.drawinfo.start.offset.over = 0; |
486 | draw_context.drawinfo.start.offset.middle = 0; | |
487 | draw_context.drawinfo.start.offset.under = 0; | |
488 | draw_context.drawinfo.end.offset.over = 0; | |
489 | draw_context.drawinfo.end.offset.middle = 0; | |
490 | draw_context.drawinfo.end.offset.under = 0; | |
9e01e6d4 | 491 | |
67f72973 | 492 | { |
493 | /* Draw the line */ | |
494 | //PropertiesLine prop_line = prepare_s_e_line(process); | |
495 | PropertiesLine prop_line; | |
496 | prop_line.line_width = STATE_LINE_WIDTH; | |
497 | prop_line.style = GDK_LINE_SOLID; | |
498 | prop_line.y = MIDDLE; | |
dd47d0d8 | 499 | cpu_set_line_color(&prop_line, &(ts->cpu_states[cpu])); |
67f72973 | 500 | draw_line((void*)&prop_line, (void*)&draw_context); |
9e01e6d4 | 501 | |
67f72973 | 502 | } |
503 | /* become the last x position */ | |
504 | hashed_process_data->x.middle = x; | |
505 | hashed_process_data->x.middle_used = TRUE; | |
506 | hashed_process_data->x.middle_marked = FALSE; | |
9e01e6d4 | 507 | |
67f72973 | 508 | /* Calculate the next good time */ |
509 | convert_pixels_to_time(width, x+1, time_window, | |
510 | &hashed_process_data->next_good_time); | |
511 | } | |
9e01e6d4 | 512 | } |
513 | ||
67f72973 | 514 | return 0; |
9e01e6d4 | 515 | } |
516 | ||
58a9b31b | 517 | /* after_schedchange_hook |
518 | * | |
519 | * The draw after hook is called by the reading API to have a | |
520 | * particular event drawn on the screen. | |
521 | * @param hook_data ControlFlowData structure of the viewer. | |
522 | * @param call_data Event context. | |
523 | * | |
524 | * This function adds items to be drawn in a queue for each process. | |
525 | * | |
526 | */ | |
527 | int after_schedchange_hook(void *hook_data, void *call_data) | |
9e01e6d4 | 528 | { |
dd47d0d8 | 529 | LttvEvent *event; |
67f72973 | 530 | |
dd47d0d8 YB |
531 | event = (LttvEvent *) call_data; |
532 | ||
533 | if (strcmp(lttv_traceset_get_name_from_event(event),"sched_switch") != 0) | |
534 | return FALSE; | |
535 | ||
536 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; | |
44ffb95f | 537 | |
dd47d0d8 YB |
538 | LttvTraceState *ts = event->state; |
539 | #ifdef BABEL_CLEANUP | |
67f72973 | 540 | LttvFilter *filter = resourceview_data->filter; |
44ffb95f | 541 | if(filter != NULL && filter->head != NULL) |
542 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
543 | tfc->t_context->t,tfc,NULL,NULL)) | |
544 | return FALSE; | |
dd47d0d8 | 545 | #endif |
44ffb95f | 546 | |
dd47d0d8 | 547 | LttTime evtime = lttv_event_get_timestamp(event); |
44ffb95f | 548 | |
44ffb95f | 549 | /* Add process to process list (if not present) */ |
550 | LttvProcessState *process_in; | |
44ffb95f | 551 | HashedResourceData *hashed_process_data_in = NULL; |
552 | ||
67f72973 | 553 | ProcessList *process_list = resourceview_data->process_list; |
44ffb95f | 554 | |
44ffb95f | 555 | /* Find process pid_in in the list... */ |
556 | //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in); | |
557 | //process_in = tfs->process; | |
dd47d0d8 YB |
558 | guint cpu = lttv_traceset_get_cpuid_from_event(event); |
559 | guint trace_num = 0; /* TODO set right trace number */ | |
44ffb95f | 560 | process_in = ts->running_process[cpu]; |
561 | /* It should exist, because we are after the state update. */ | |
562 | #ifdef EXTRA_CHECK | |
563 | g_assert(process_in != NULL); | |
564 | #endif //EXTRA_CHECK | |
44ffb95f | 565 | |
67f72973 | 566 | //hashed_process_data_in = processlist_get_process_data(process_list, cpuq, trace_num); |
567 | hashed_process_data_in = resourcelist_obtain_cpu(resourceview_data, trace_num, cpu); | |
568 | ||
44ffb95f | 569 | /* Set the current process */ |
570 | process_list->current_hash_data[trace_num][process_in->cpu] = | |
571 | hashed_process_data_in; | |
572 | ||
573 | if(ltt_time_compare(hashed_process_data_in->next_good_time, | |
574 | evtime) <= 0) | |
575 | { | |
576 | TimeWindow time_window = | |
67f72973 | 577 | lttvwindow_get_time_window(resourceview_data->tab); |
44ffb95f | 578 | |
579 | #ifdef EXTRA_CHECK | |
580 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
581 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
582 | return; | |
583 | #endif //EXTRA_CHECK | |
67f72973 | 584 | Drawing_t *drawing = resourceview_data->drawing; |
44ffb95f | 585 | guint width = drawing->width; |
586 | guint new_x; | |
587 | ||
588 | convert_time_to_pixels( | |
589 | time_window, | |
590 | evtime, | |
591 | width, | |
592 | &new_x); | |
593 | ||
594 | if(hashed_process_data_in->x.middle != new_x) { | |
595 | hashed_process_data_in->x.middle = new_x; | |
596 | hashed_process_data_in->x.middle_used = FALSE; | |
597 | hashed_process_data_in->x.middle_marked = FALSE; | |
598 | } | |
599 | } | |
58a9b31b | 600 | return 0; |
601 | } | |
9e01e6d4 | 602 | |
43ed82b5 | 603 | int before_execmode_hook_irq(void *hook_data, void *call_data); |
604 | int before_execmode_hook_soft_irq(void *hook_data, void *call_data); | |
605 | int before_execmode_hook_trap(void *hook_data, void *call_data); | |
606 | ||
58a9b31b | 607 | /* before_execmode_hook |
608 | * | |
609 | * This function basically draw lines and icons. Two types of lines are drawn : | |
610 | * one small (3 pixels?) representing the state of the process and the second | |
611 | * type is thicker (10 pixels?) representing on which CPU a process is running | |
612 | * (and this only in running state). | |
613 | * | |
614 | * Extremums of the lines : | |
615 | * x_min : time of the last event context for this process kept in memory. | |
616 | * x_max : time of the current event. | |
617 | * y : middle of the process in the process list. The process is found in the | |
618 | * list, therefore is it's position in pixels. | |
619 | * | |
620 | * The choice of lines'color is defined by the context of the last event for this | |
621 | * process. | |
622 | */ | |
9e01e6d4 | 623 | |
598026ba | 624 | int before_execmode_hook(void *hook_data, void *call_data) |
625 | { | |
dd47d0d8 YB |
626 | LttvEvent *event; |
627 | guint cpu; | |
628 | guint pid = 0; | |
629 | LttvTraceState *ts; | |
630 | LttvProcessState *process; | |
598026ba | 631 | |
8743690d | 632 | before_execmode_hook_irq(hook_data, call_data); |
0305fe77 | 633 | before_execmode_hook_soft_irq(hook_data, call_data); |
dd47d0d8 | 634 | #ifdef TRAP_NO_EXIST |
38726a78 | 635 | before_execmode_hook_trap(hook_data, call_data); |
dd47d0d8 | 636 | #endif |
598026ba | 637 | /* we are in a execmode, before the state update. We must draw the |
638 | * items corresponding to the state before it changes : now is the right | |
639 | * time to do it. | |
640 | */ | |
dd47d0d8 YB |
641 | event = (LttvEvent *) call_data; |
642 | if ((strncmp(lttv_traceset_get_name_from_event(event),"sys_", sizeof("sys_") - 1) == 0) | |
643 | ||(strcmp(lttv_traceset_get_name_from_event(event),"exit_syscall") == 0) | |
644 | ||(strncmp(lttv_traceset_get_name_from_event(event),"irq_handler_",sizeof("irq_handler_") -1) == 0) | |
645 | ||(strncmp(lttv_traceset_get_name_from_event(event),"softirq_", sizeof("softirq_") - 1) == 0)) { | |
646 | ||
647 | LttTime evtime = lttv_event_get_timestamp(event); | |
648 | ControlFlowData *resourceview_data = (ControlFlowData*)hook_data; | |
649 | ||
598026ba | 650 | /* For the pid */ |
dd47d0d8 YB |
651 | LttvTraceset *traceSet = lttvwindow_get_traceset(resourceview_data->tab); |
652 | ||
653 | cpu = lttv_traceset_get_cpuid_from_event(event); | |
654 | ts = event->state; | |
655 | ||
656 | guint trace_num = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number | |
67f72973 | 657 | |
dd47d0d8 | 658 | process = ts->running_process[cpu]; |
598026ba | 659 | g_assert(process != NULL); |
660 | ||
598026ba | 661 | /* Well, the process_out existed : we must get it in the process hash |
662 | * or add it, and draw its items. | |
663 | */ | |
8d8c5ea7 | 664 | /* Add process to process list (if not present) */ |
598026ba | 665 | HashedResourceData *hashed_process_data = NULL; |
67f72973 | 666 | ProcessList *process_list = resourceview_data->process_list; |
598026ba | 667 | |
668 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { | |
669 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; | |
670 | } else { | |
67f72973 | 671 | hashed_process_data = resourcelist_obtain_cpu(resourceview_data, trace_num, cpu); |
672 | ||
598026ba | 673 | /* Set the current process */ |
674 | process_list->current_hash_data[trace_num][process->cpu] = | |
675 | hashed_process_data; | |
676 | } | |
677 | ||
678 | /* Now, the process is in the state hash and our own process hash. | |
679 | * We definitely can draw the items related to the ending state. | |
680 | */ | |
681 | ||
682 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, | |
683 | evtime) > 0)) | |
684 | { | |
685 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
686 | TimeWindow time_window = | |
67f72973 | 687 | lttvwindow_get_time_window(resourceview_data->tab); |
598026ba | 688 | |
689 | #ifdef EXTRA_CHECK | |
690 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
691 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
692 | return; | |
693 | #endif //EXTRA_CHECK | |
67f72973 | 694 | Drawing_t *drawing = resourceview_data->drawing; |
598026ba | 695 | guint width = drawing->width; |
696 | guint x; | |
697 | convert_time_to_pixels( | |
698 | time_window, | |
699 | evtime, | |
700 | width, | |
701 | &x); | |
702 | ||
703 | /* Draw collision indicator */ | |
704 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
705 | gdk_draw_point(hashed_process_data->pixmap, | |
706 | drawing->gc, | |
707 | x, | |
708 | COLLISION_POSITION(hashed_process_data->height)); | |
709 | hashed_process_data->x.middle_marked = TRUE; | |
710 | } | |
d3d99fde | 711 | } |
712 | else { | |
598026ba | 713 | TimeWindow time_window = |
67f72973 | 714 | lttvwindow_get_time_window(resourceview_data->tab); |
598026ba | 715 | |
716 | #ifdef EXTRA_CHECK | |
717 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
718 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
719 | return; | |
720 | #endif //EXTRA_CHECK | |
67f72973 | 721 | Drawing_t *drawing = resourceview_data->drawing; |
598026ba | 722 | guint width = drawing->width; |
723 | guint x; | |
724 | ||
725 | convert_time_to_pixels( | |
726 | time_window, | |
727 | evtime, | |
728 | width, | |
729 | &x); | |
730 | ||
731 | ||
732 | /* Jump over draw if we are at the same x position */ | |
733 | if(unlikely(x == hashed_process_data->x.middle && | |
734 | hashed_process_data->x.middle_used)) | |
735 | { | |
736 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
737 | /* Draw collision indicator */ | |
738 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
739 | gdk_draw_point(hashed_process_data->pixmap, | |
740 | drawing->gc, | |
741 | x, | |
742 | COLLISION_POSITION(hashed_process_data->height)); | |
743 | hashed_process_data->x.middle_marked = TRUE; | |
744 | } | |
745 | /* jump */ | |
d3d99fde | 746 | } |
747 | else { | |
598026ba | 748 | |
749 | DrawContext draw_context; | |
750 | /* Now create the drawing context that will be used to draw | |
751 | * items related to the last state. */ | |
752 | draw_context.drawable = hashed_process_data->pixmap; | |
753 | draw_context.gc = drawing->gc; | |
754 | draw_context.pango_layout = drawing->pango_layout; | |
755 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; | |
756 | draw_context.drawinfo.end.x = x; | |
757 | ||
758 | draw_context.drawinfo.y.over = 1; | |
759 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); | |
760 | draw_context.drawinfo.y.under = hashed_process_data->height; | |
761 | ||
762 | draw_context.drawinfo.start.offset.over = 0; | |
763 | draw_context.drawinfo.start.offset.middle = 0; | |
764 | draw_context.drawinfo.start.offset.under = 0; | |
765 | draw_context.drawinfo.end.offset.over = 0; | |
766 | draw_context.drawinfo.end.offset.middle = 0; | |
767 | draw_context.drawinfo.end.offset.under = 0; | |
768 | ||
769 | { | |
770 | /* Draw the line */ | |
771 | PropertiesLine prop_line; | |
d3d99fde | 772 | prop_line.line_width = STATE_LINE_WIDTH; |
773 | prop_line.style = GDK_LINE_SOLID; | |
774 | prop_line.y = MIDDLE; | |
dd47d0d8 | 775 | cpu_set_line_color(&prop_line, &ts->cpu_states[cpu]); |
598026ba | 776 | draw_line((void*)&prop_line, (void*)&draw_context); |
777 | } | |
778 | /* become the last x position */ | |
779 | hashed_process_data->x.middle = x; | |
780 | hashed_process_data->x.middle_used = TRUE; | |
781 | hashed_process_data->x.middle_marked = FALSE; | |
782 | ||
783 | /* Calculate the next good time */ | |
784 | convert_pixels_to_time(width, x+1, time_window, | |
785 | &hashed_process_data->next_good_time); | |
786 | } | |
dd47d0d8 | 787 | } |
598026ba | 788 | } |
598026ba | 789 | return 0; |
790 | } | |
9e01e6d4 | 791 | |
8743690d | 792 | int before_execmode_hook_irq(void *hook_data, void *call_data) |
793 | { | |
dd47d0d8 | 794 | LttvEvent *event; |
8743690d | 795 | |
dd47d0d8 YB |
796 | event = (LttvEvent *) call_data; |
797 | ||
798 | LttTime evtime = lttv_event_get_timestamp(event); | |
799 | ControlFlowData *resourceview_data = (ControlFlowData*)hook_data; | |
8743690d | 800 | |
8743690d | 801 | /* we are in a execmode, before the state update. We must draw the |
802 | * items corresponding to the state before it changes : now is the right | |
803 | * time to do it. | |
804 | */ | |
805 | /* For the pid */ | |
806 | ||
807 | guint64 irq; | |
dd47d0d8 YB |
808 | guint cpu = lttv_traceset_get_cpuid_from_event(event); |
809 | LttvTraceset *traceSet = lttvwindow_get_traceset(resourceview_data->tab); | |
810 | LttvTraceState *ts = event->state;; | |
8743690d | 811 | |
750eb11a | 812 | /* |
813 | * Check for LTT_CHANNEL_KERNEL channel name and event ID | |
814 | * corresponding to LTT_EVENT_IRQ_ENTRY or LTT_EVENT_IRQ_EXIT. | |
815 | */ | |
dd47d0d8 YB |
816 | if (strncmp(lttv_traceset_get_name_from_event(event),"irq_handler_entry",sizeof("irq_handler_entry")) == 0) { |
817 | irq = lttv_event_get_long(event, "irq"); | |
818 | } else if (strncmp(lttv_traceset_get_name_from_event(event),"irq_handler_exit",sizeof("irq_handler_exit")) == 0) { | |
55a35306 | 819 | gint len = ts->cpu_states[cpu].irq_stack->len; |
820 | if(len) { | |
821 | irq = g_array_index(ts->cpu_states[cpu].irq_stack, gint, len-1); | |
822 | } | |
823 | else { | |
824 | return 0; | |
825 | } | |
750eb11a | 826 | } else |
8743690d | 827 | return 0; |
8743690d | 828 | |
dd47d0d8 | 829 | guint trace_num = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number |
8743690d | 830 | |
8743690d | 831 | /* Well, the process_out existed : we must get it in the process hash |
832 | * or add it, and draw its items. | |
833 | */ | |
8d8c5ea7 | 834 | /* Add process to process list (if not present) */ |
8743690d | 835 | HashedResourceData *hashed_process_data = NULL; |
67f72973 | 836 | |
837 | hashed_process_data = resourcelist_obtain_irq(resourceview_data, trace_num, irq); | |
671c625b | 838 | // TODO: fix this, it's ugly and slow: |
839 | GQuark name; | |
840 | { | |
841 | gchar *str; | |
1cd9058f MD |
842 | str = g_strdup_printf("IRQ %" PRIu64 " [%s]", irq, |
843 | (char*)g_quark_to_string(ts->name_tables->irq_names[irq])); | |
671c625b | 844 | name = g_quark_from_string(str); |
845 | g_free(str); | |
846 | } | |
847 | gtk_tree_store_set(resourceview_data->process_list->list_store, &hashed_process_data->y_iter, NAME_COLUMN, g_quark_to_string(name), -1); | |
8743690d | 848 | |
849 | /* Now, the process is in the state hash and our own process hash. | |
850 | * We definitely can draw the items related to the ending state. | |
851 | */ | |
852 | ||
853 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, | |
854 | evtime) > 0)) | |
855 | { | |
856 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
857 | TimeWindow time_window = | |
67f72973 | 858 | lttvwindow_get_time_window(resourceview_data->tab); |
8743690d | 859 | |
860 | #ifdef EXTRA_CHECK | |
861 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
862 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
863 | return; | |
864 | #endif //EXTRA_CHECK | |
67f72973 | 865 | Drawing_t *drawing = resourceview_data->drawing; |
8743690d | 866 | guint width = drawing->width; |
867 | guint x; | |
868 | convert_time_to_pixels( | |
869 | time_window, | |
870 | evtime, | |
871 | width, | |
872 | &x); | |
873 | ||
874 | /* Draw collision indicator */ | |
875 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
876 | gdk_draw_point(hashed_process_data->pixmap, | |
877 | drawing->gc, | |
878 | x, | |
879 | COLLISION_POSITION(hashed_process_data->height)); | |
880 | hashed_process_data->x.middle_marked = TRUE; | |
881 | } | |
882 | } | |
883 | else { | |
884 | TimeWindow time_window = | |
67f72973 | 885 | lttvwindow_get_time_window(resourceview_data->tab); |
8743690d | 886 | |
887 | #ifdef EXTRA_CHECK | |
888 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
889 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
890 | return; | |
891 | #endif //EXTRA_CHECK | |
67f72973 | 892 | Drawing_t *drawing = resourceview_data->drawing; |
8743690d | 893 | guint width = drawing->width; |
894 | guint x; | |
895 | ||
896 | convert_time_to_pixels( | |
897 | time_window, | |
898 | evtime, | |
899 | width, | |
900 | &x); | |
901 | ||
902 | ||
903 | /* Jump over draw if we are at the same x position */ | |
904 | if(unlikely(x == hashed_process_data->x.middle && | |
905 | hashed_process_data->x.middle_used)) | |
906 | { | |
907 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
908 | /* Draw collision indicator */ | |
909 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
910 | gdk_draw_point(hashed_process_data->pixmap, | |
911 | drawing->gc, | |
912 | x, | |
913 | COLLISION_POSITION(hashed_process_data->height)); | |
914 | hashed_process_data->x.middle_marked = TRUE; | |
915 | } | |
916 | /* jump */ | |
917 | } | |
918 | else { | |
919 | ||
920 | DrawContext draw_context; | |
921 | /* Now create the drawing context that will be used to draw | |
922 | * items related to the last state. */ | |
923 | draw_context.drawable = hashed_process_data->pixmap; | |
924 | draw_context.gc = drawing->gc; | |
925 | draw_context.pango_layout = drawing->pango_layout; | |
926 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; | |
927 | draw_context.drawinfo.end.x = x; | |
928 | ||
929 | draw_context.drawinfo.y.over = 1; | |
930 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); | |
931 | draw_context.drawinfo.y.under = hashed_process_data->height; | |
932 | ||
933 | draw_context.drawinfo.start.offset.over = 0; | |
934 | draw_context.drawinfo.start.offset.middle = 0; | |
935 | draw_context.drawinfo.start.offset.under = 0; | |
936 | draw_context.drawinfo.end.offset.over = 0; | |
937 | draw_context.drawinfo.end.offset.middle = 0; | |
938 | draw_context.drawinfo.end.offset.under = 0; | |
939 | ||
940 | { | |
941 | /* Draw the line */ | |
942 | PropertiesLine prop_line; | |
943 | prop_line.line_width = STATE_LINE_WIDTH; | |
944 | prop_line.style = GDK_LINE_SOLID; | |
945 | prop_line.y = MIDDLE; | |
946 | irq_set_line_color(&prop_line, &ts->irq_states[irq]); | |
947 | draw_line((void*)&prop_line, (void*)&draw_context); | |
948 | } | |
949 | /* become the last x position */ | |
950 | hashed_process_data->x.middle = x; | |
951 | hashed_process_data->x.middle_used = TRUE; | |
952 | hashed_process_data->x.middle_marked = FALSE; | |
953 | ||
954 | /* Calculate the next good time */ | |
955 | convert_pixels_to_time(width, x+1, time_window, | |
956 | &hashed_process_data->next_good_time); | |
957 | } | |
958 | } | |
959 | ||
960 | return 0; | |
961 | } | |
962 | ||
0305fe77 | 963 | int before_execmode_hook_soft_irq(void *hook_data, void *call_data) |
964 | { | |
0305fe77 | 965 | |
dd47d0d8 YB |
966 | LttvEvent *event; |
967 | LttvTraceState *ts; | |
0305fe77 | 968 | |
dd47d0d8 YB |
969 | event = (LttvEvent *) call_data; |
970 | ||
971 | ||
972 | ||
0305fe77 | 973 | |
0305fe77 | 974 | /* we are in a execmode, before the state update. We must draw the |
975 | * items corresponding to the state before it changes : now is the right | |
976 | * time to do it. | |
977 | */ | |
978 | /* For the pid */ | |
979 | ||
980 | guint64 softirq; | |
dd47d0d8 | 981 | |
0305fe77 | 982 | |
750eb11a | 983 | /* |
984 | * Check for LTT_CHANNEL_KERNEL channel name and event ID | |
985 | * corresponding to LTT_EVENT_SOFT_IRQ_RAISE, LTT_EVENT_SOFT_IRQ_ENTRY | |
986 | * or LTT_EVENT_SOFT_IRQ_EXIT. | |
987 | */ | |
dd47d0d8 YB |
988 | |
989 | if (strncmp(lttv_traceset_get_name_from_event(event),"softirq_entry",sizeof("softirq_entry")) == 0 | |
990 | || strncmp(lttv_traceset_get_name_from_event(event),"softirq_raise",sizeof("softirq_raise")) == 0) { | |
991 | softirq = lttv_event_get_long_unsigned(event, "vec"); | |
992 | } else if (strncmp(lttv_traceset_get_name_from_event(event),"softirq_exit",sizeof("softirq_exit")) == 0) { | |
993 | LttTime evtime = lttv_event_get_timestamp(event); | |
994 | ControlFlowData *resourceview_data = (ControlFlowData*)hook_data; | |
995 | LttvTraceset *traceSet = lttvwindow_get_traceset(resourceview_data->tab); | |
996 | guint cpu = lttv_traceset_get_cpuid_from_event(event); | |
997 | ts = event->state; | |
16e4e89b | 998 | gint len = ts->cpu_states[cpu].softirq_stack->len; |
999 | if(len) { | |
1000 | softirq = g_array_index(ts->cpu_states[cpu].softirq_stack, gint, len-1); | |
1001 | } | |
1002 | else { | |
1003 | return 0; | |
1004 | } | |
0305fe77 | 1005 | |
dd47d0d8 YB |
1006 | |
1007 | guint trace_num = 0;//TODO change it to the right value; | |
0305fe77 | 1008 | |
1009 | /* Well, the process_out existed : we must get it in the process hash | |
1010 | * or add it, and draw its items. | |
1011 | */ | |
8d8c5ea7 | 1012 | /* Add process to process list (if not present) */ |
0305fe77 | 1013 | HashedResourceData *hashed_process_data = NULL; |
0305fe77 | 1014 | |
1015 | hashed_process_data = resourcelist_obtain_soft_irq(resourceview_data, trace_num, softirq); | |
1016 | ||
1017 | /* Now, the process is in the state hash and our own process hash. | |
1018 | * We definitely can draw the items related to the ending state. | |
1019 | */ | |
1020 | ||
1021 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, | |
1022 | evtime) > 0)) | |
1023 | { | |
1024 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
1025 | TimeWindow time_window = | |
1026 | lttvwindow_get_time_window(resourceview_data->tab); | |
1027 | ||
1028 | #ifdef EXTRA_CHECK | |
1029 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1030 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
1031 | return; | |
1032 | #endif //EXTRA_CHECK | |
1033 | Drawing_t *drawing = resourceview_data->drawing; | |
1034 | guint width = drawing->width; | |
1035 | guint x; | |
1036 | convert_time_to_pixels( | |
1037 | time_window, | |
1038 | evtime, | |
1039 | width, | |
1040 | &x); | |
1041 | ||
1042 | /* Draw collision indicator */ | |
1043 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
1044 | gdk_draw_point(hashed_process_data->pixmap, | |
1045 | drawing->gc, | |
1046 | x, | |
1047 | COLLISION_POSITION(hashed_process_data->height)); | |
1048 | hashed_process_data->x.middle_marked = TRUE; | |
1049 | } | |
1050 | } | |
1051 | else { | |
1052 | TimeWindow time_window = | |
1053 | lttvwindow_get_time_window(resourceview_data->tab); | |
1054 | ||
1055 | #ifdef EXTRA_CHECK | |
1056 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1057 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
1058 | return; | |
1059 | #endif //EXTRA_CHECK | |
1060 | Drawing_t *drawing = resourceview_data->drawing; | |
1061 | guint width = drawing->width; | |
1062 | guint x; | |
1063 | ||
1064 | convert_time_to_pixels( | |
1065 | time_window, | |
1066 | evtime, | |
1067 | width, | |
1068 | &x); | |
1069 | ||
1070 | ||
1071 | /* Jump over draw if we are at the same x position */ | |
1072 | if(unlikely(x == hashed_process_data->x.middle && | |
1073 | hashed_process_data->x.middle_used)) | |
1074 | { | |
1075 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
1076 | /* Draw collision indicator */ | |
1077 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
1078 | gdk_draw_point(hashed_process_data->pixmap, | |
1079 | drawing->gc, | |
1080 | x, | |
1081 | COLLISION_POSITION(hashed_process_data->height)); | |
1082 | hashed_process_data->x.middle_marked = TRUE; | |
1083 | } | |
1084 | /* jump */ | |
1085 | } | |
1086 | else { | |
1087 | ||
1088 | DrawContext draw_context; | |
1089 | /* Now create the drawing context that will be used to draw | |
1090 | * items related to the last state. */ | |
1091 | draw_context.drawable = hashed_process_data->pixmap; | |
1092 | draw_context.gc = drawing->gc; | |
1093 | draw_context.pango_layout = drawing->pango_layout; | |
1094 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; | |
1095 | draw_context.drawinfo.end.x = x; | |
1096 | ||
1097 | draw_context.drawinfo.y.over = 1; | |
1098 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); | |
1099 | draw_context.drawinfo.y.under = hashed_process_data->height; | |
1100 | ||
1101 | draw_context.drawinfo.start.offset.over = 0; | |
1102 | draw_context.drawinfo.start.offset.middle = 0; | |
1103 | draw_context.drawinfo.start.offset.under = 0; | |
1104 | draw_context.drawinfo.end.offset.over = 0; | |
1105 | draw_context.drawinfo.end.offset.middle = 0; | |
1106 | draw_context.drawinfo.end.offset.under = 0; | |
1107 | ||
1108 | { | |
1109 | /* Draw the line */ | |
1110 | PropertiesLine prop_line; | |
1111 | prop_line.line_width = STATE_LINE_WIDTH; | |
1112 | prop_line.style = GDK_LINE_SOLID; | |
1113 | prop_line.y = MIDDLE; | |
1114 | soft_irq_set_line_color(&prop_line, &ts->soft_irq_states[softirq]); | |
1115 | draw_line((void*)&prop_line, (void*)&draw_context); | |
1116 | } | |
1117 | /* become the last x position */ | |
1118 | hashed_process_data->x.middle = x; | |
1119 | hashed_process_data->x.middle_used = TRUE; | |
1120 | hashed_process_data->x.middle_marked = FALSE; | |
1121 | ||
1122 | /* Calculate the next good time */ | |
1123 | convert_pixels_to_time(width, x+1, time_window, | |
1124 | &hashed_process_data->next_good_time); | |
1125 | } | |
1126 | } | |
dd47d0d8 | 1127 | } |
0305fe77 | 1128 | return 0; |
1129 | } | |
dd47d0d8 | 1130 | #ifdef TRAP_NO_EXIST |
38726a78 | 1131 | int before_execmode_hook_trap(void *hook_data, void *call_data) |
1132 | { | |
1133 | LttvTraceHook *th = (LttvTraceHook*)hook_data; | |
1134 | EventsRequest *events_request = (EventsRequest*)th->hook_data; | |
1135 | ControlFlowData *resourceview_data = events_request->viewer_data; | |
1136 | ||
1137 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; | |
1138 | ||
1139 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; | |
1140 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; | |
750eb11a | 1141 | struct marker_info *minfo; |
38726a78 | 1142 | |
1143 | LttEvent *e; | |
1144 | e = ltt_tracefile_get_event(tfc->tf); | |
1145 | ||
1146 | LttTime evtime = ltt_event_time(e); | |
1147 | ||
38726a78 | 1148 | /* we are in a execmode, before the state update. We must draw the |
1149 | * items corresponding to the state before it changes : now is the right | |
1150 | * time to do it. | |
1151 | */ | |
1152 | /* For the pid */ | |
1153 | ||
1154 | guint64 trap; | |
1155 | guint cpu = tfs->cpu; | |
1156 | ||
750eb11a | 1157 | /* |
1158 | * Check for LTT_CHANNEL_KERNEL channel name and event ID | |
4e9bbbd3 | 1159 | * corresponding to LTT_EVENT_TRAP/PAGE_FAULT_ENTRY or |
1160 | * LTT_EVENT_TRAP/PAGE_FAULT_EXIT. | |
750eb11a | 1161 | */ |
1162 | if (tfc->tf->name != LTT_CHANNEL_KERNEL) | |
1163 | return 0; | |
1164 | minfo = marker_get_info_from_id(tfc->tf->mdata, e->event_id); | |
1165 | g_assert(minfo != NULL); | |
4e9bbbd3 | 1166 | if (minfo->name == LTT_EVENT_TRAP_ENTRY |
1167 | || minfo->name == LTT_EVENT_PAGE_FAULT_ENTRY | |
1168 | || minfo->name == LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY) { | |
38726a78 | 1169 | trap = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
4e9bbbd3 | 1170 | } else if (minfo->name == LTT_EVENT_TRAP_EXIT |
1171 | || minfo->name == LTT_EVENT_PAGE_FAULT_EXIT | |
1172 | || minfo->name == LTT_EVENT_PAGE_FAULT_NOSEM_EXIT) { | |
16e4e89b | 1173 | gint len = ts->cpu_states[cpu].trap_stack->len; |
1174 | if(len) { | |
1175 | trap = g_array_index(ts->cpu_states[cpu].trap_stack, gint, len-1); | |
1176 | } | |
1177 | else { | |
1178 | return 0; | |
1179 | } | |
750eb11a | 1180 | } else |
38726a78 | 1181 | return 0; |
38726a78 | 1182 | |
1183 | guint trace_num = ts->parent.index; | |
1184 | ||
1185 | /* Well, the process_out existed : we must get it in the process hash | |
1186 | * or add it, and draw its items. | |
1187 | */ | |
8d8c5ea7 | 1188 | /* Add process to process list (if not present) */ |
38726a78 | 1189 | HashedResourceData *hashed_process_data = NULL; |
38726a78 | 1190 | |
1191 | hashed_process_data = resourcelist_obtain_trap(resourceview_data, trace_num, trap); | |
1192 | ||
1193 | /* Now, the process is in the state hash and our own process hash. | |
1194 | * We definitely can draw the items related to the ending state. | |
1195 | */ | |
1196 | ||
1197 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, | |
1198 | evtime) > 0)) | |
1199 | { | |
1200 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
1201 | TimeWindow time_window = | |
1202 | lttvwindow_get_time_window(resourceview_data->tab); | |
1203 | ||
1204 | #ifdef EXTRA_CHECK | |
1205 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1206 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
1207 | return; | |
1208 | #endif //EXTRA_CHECK | |
1209 | Drawing_t *drawing = resourceview_data->drawing; | |
1210 | guint width = drawing->width; | |
1211 | guint x; | |
1212 | convert_time_to_pixels( | |
1213 | time_window, | |
1214 | evtime, | |
1215 | width, | |
1216 | &x); | |
1217 | ||
1218 | /* Draw collision indicator */ | |
1219 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
1220 | gdk_draw_point(hashed_process_data->pixmap, | |
1221 | drawing->gc, | |
1222 | x, | |
1223 | COLLISION_POSITION(hashed_process_data->height)); | |
1224 | hashed_process_data->x.middle_marked = TRUE; | |
1225 | } | |
1226 | } | |
1227 | else { | |
1228 | TimeWindow time_window = | |
1229 | lttvwindow_get_time_window(resourceview_data->tab); | |
1230 | ||
1231 | #ifdef EXTRA_CHECK | |
1232 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1233 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
1234 | return; | |
1235 | #endif //EXTRA_CHECK | |
1236 | Drawing_t *drawing = resourceview_data->drawing; | |
1237 | guint width = drawing->width; | |
1238 | guint x; | |
1239 | ||
1240 | convert_time_to_pixels( | |
1241 | time_window, | |
1242 | evtime, | |
1243 | width, | |
1244 | &x); | |
1245 | ||
1246 | ||
1247 | /* Jump over draw if we are at the same x position */ | |
1248 | if(unlikely(x == hashed_process_data->x.middle && | |
1249 | hashed_process_data->x.middle_used)) | |
1250 | { | |
1251 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
1252 | /* Draw collision indicator */ | |
1253 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
1254 | gdk_draw_point(hashed_process_data->pixmap, | |
1255 | drawing->gc, | |
1256 | x, | |
1257 | COLLISION_POSITION(hashed_process_data->height)); | |
1258 | hashed_process_data->x.middle_marked = TRUE; | |
1259 | } | |
1260 | /* jump */ | |
1261 | } | |
1262 | else { | |
1263 | ||
1264 | DrawContext draw_context; | |
1265 | /* Now create the drawing context that will be used to draw | |
1266 | * items related to the last state. */ | |
1267 | draw_context.drawable = hashed_process_data->pixmap; | |
1268 | draw_context.gc = drawing->gc; | |
1269 | draw_context.pango_layout = drawing->pango_layout; | |
1270 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; | |
1271 | draw_context.drawinfo.end.x = x; | |
1272 | ||
1273 | draw_context.drawinfo.y.over = 1; | |
1274 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); | |
1275 | draw_context.drawinfo.y.under = hashed_process_data->height; | |
1276 | ||
1277 | draw_context.drawinfo.start.offset.over = 0; | |
1278 | draw_context.drawinfo.start.offset.middle = 0; | |
1279 | draw_context.drawinfo.start.offset.under = 0; | |
1280 | draw_context.drawinfo.end.offset.over = 0; | |
1281 | draw_context.drawinfo.end.offset.middle = 0; | |
1282 | draw_context.drawinfo.end.offset.under = 0; | |
1283 | ||
1284 | { | |
1285 | /* Draw the line */ | |
1286 | PropertiesLine prop_line; | |
1287 | prop_line.line_width = STATE_LINE_WIDTH; | |
1288 | prop_line.style = GDK_LINE_SOLID; | |
1289 | prop_line.y = MIDDLE; | |
1290 | trap_set_line_color(&prop_line, &ts->trap_states[trap]); | |
1291 | draw_line((void*)&prop_line, (void*)&draw_context); | |
1292 | } | |
1293 | /* become the last x position */ | |
1294 | hashed_process_data->x.middle = x; | |
1295 | hashed_process_data->x.middle_used = TRUE; | |
1296 | hashed_process_data->x.middle_marked = FALSE; | |
1297 | ||
1298 | /* Calculate the next good time */ | |
1299 | convert_pixels_to_time(width, x+1, time_window, | |
1300 | &hashed_process_data->next_good_time); | |
1301 | } | |
1302 | } | |
1303 | ||
1304 | return 0; | |
1305 | } | |
dd47d0d8 YB |
1306 | #endif |
1307 | #ifdef BABEL_CLEANUP | |
1308 | //TODO investigate the use of block dev resource | |
20d16f82 | 1309 | int before_bdev_event_hook(void *hook_data, void *call_data) |
1310 | { | |
dd47d0d8 YB |
1311 | LttvEvent *event; |
1312 | guint cpu; | |
1313 | guint pid = 0; | |
1314 | LttvTraceState *ts; | |
1315 | LttvProcessState *process; | |
20d16f82 | 1316 | |
20d16f82 | 1317 | |
20d16f82 | 1318 | /* we are in a execmode, before the state update. We must draw the |
1319 | * items corresponding to the state before it changes : now is the right | |
1320 | * time to do it. | |
1321 | */ | |
dd47d0d8 YB |
1322 | |
1323 | event = (LttvEvent *) call_data; | |
1324 | if (strcmp(lttv_traceset_get_name_from_event(event),"block_rq_issue") != 0 && strcmp(lttv_traceset_get_name_from_event(event),"block_rq_complete") != 0) | |
1325 | return FALSE; | |
1326 | ||
1327 | ||
1328 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; | |
1329 | ||
1330 | LttvTraceState *ts = event->state; | |
20d16f82 | 1331 | /* For the pid */ |
1332 | ||
ca5c76ed | 1333 | guint8 major = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
1334 | guint8 minor = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); | |
20d16f82 | 1335 | gint devcode_gint = MKDEV(major,minor); |
1336 | ||
dd47d0d8 | 1337 | guint trace_num = 0; //TODO put the real trace_num; |
20d16f82 | 1338 | |
1339 | LttvBdevState *bdev = g_hash_table_lookup(ts->bdev_states, &devcode_gint); | |
23e59a12 | 1340 | /* the result of the lookup might be NULL. that's ok, the rest of the function |
1341 | should understand it was not found and that its state is unknown */ | |
20d16f82 | 1342 | |
20d16f82 | 1343 | /* Well, the process_out existed : we must get it in the process hash |
1344 | * or add it, and draw its items. | |
1345 | */ | |
8d8c5ea7 | 1346 | /* Add process to process list (if not present) */ |
20d16f82 | 1347 | HashedResourceData *hashed_process_data = NULL; |
20d16f82 | 1348 | // LttTime birth = process->creation_time; |
1349 | ||
1350 | // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { | |
1351 | // hashed_process_data = process_list->current_hash_data[trace_num][cpu]; | |
1352 | // } else { | |
67f72973 | 1353 | hashed_process_data = resourcelist_obtain_bdev(resourceview_data, trace_num, devcode_gint); |
1354 | ////hashed_process_data = processlist_get_process_data(process_list, resourceq, trace_num); | |
20d16f82 | 1355 | // hashed_process_data = processlist_get_process_data(process_list, |
1356 | // pid, | |
1357 | // process->cpu, | |
1358 | // &birth, | |
1359 | // trace_num); | |
67f72973 | 1360 | // |
20d16f82 | 1361 | /* Set the current process */ |
1362 | // process_list->current_hash_data[trace_num][process->cpu] = | |
1363 | // hashed_process_data; | |
1364 | // } | |
1365 | ||
1366 | /* Now, the process is in the state hash and our own process hash. | |
1367 | * We definitely can draw the items related to the ending state. | |
1368 | */ | |
1369 | ||
1370 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, | |
1371 | evtime) > 0)) | |
1372 | { | |
1373 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
1374 | TimeWindow time_window = | |
67f72973 | 1375 | lttvwindow_get_time_window(resourceview_data->tab); |
20d16f82 | 1376 | |
1377 | #ifdef EXTRA_CHECK | |
1378 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1379 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
1380 | return; | |
1381 | #endif //EXTRA_CHECK | |
67f72973 | 1382 | Drawing_t *drawing = resourceview_data->drawing; |
20d16f82 | 1383 | guint width = drawing->width; |
1384 | guint x; | |
1385 | convert_time_to_pixels( | |
1386 | time_window, | |
1387 | evtime, | |
1388 | width, | |
1389 | &x); | |
1390 | ||
1391 | /* Draw collision indicator */ | |
1392 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
1393 | gdk_draw_point(hashed_process_data->pixmap, | |
1394 | drawing->gc, | |
1395 | x, | |
1396 | COLLISION_POSITION(hashed_process_data->height)); | |
1397 | hashed_process_data->x.middle_marked = TRUE; | |
1398 | } | |
1399 | } | |
1400 | else { | |
1401 | TimeWindow time_window = | |
67f72973 | 1402 | lttvwindow_get_time_window(resourceview_data->tab); |
20d16f82 | 1403 | |
1404 | #ifdef EXTRA_CHECK | |
1405 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1406 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
1407 | return; | |
1408 | #endif //EXTRA_CHECK | |
67f72973 | 1409 | Drawing_t *drawing = resourceview_data->drawing; |
20d16f82 | 1410 | guint width = drawing->width; |
1411 | guint x; | |
1412 | ||
1413 | convert_time_to_pixels( | |
1414 | time_window, | |
1415 | evtime, | |
1416 | width, | |
1417 | &x); | |
1418 | ||
1419 | ||
1420 | /* Jump over draw if we are at the same x position */ | |
1421 | if(unlikely(x == hashed_process_data->x.middle && | |
1422 | hashed_process_data->x.middle_used)) | |
1423 | { | |
1424 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
1425 | /* Draw collision indicator */ | |
1426 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
1427 | gdk_draw_point(hashed_process_data->pixmap, | |
1428 | drawing->gc, | |
1429 | x, | |
1430 | COLLISION_POSITION(hashed_process_data->height)); | |
1431 | hashed_process_data->x.middle_marked = TRUE; | |
1432 | } | |
1433 | /* jump */ | |
1434 | } | |
1435 | else { | |
1436 | ||
1437 | DrawContext draw_context; | |
1438 | /* Now create the drawing context that will be used to draw | |
1439 | * items related to the last state. */ | |
1440 | draw_context.drawable = hashed_process_data->pixmap; | |
1441 | draw_context.gc = drawing->gc; | |
1442 | draw_context.pango_layout = drawing->pango_layout; | |
1443 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; | |
1444 | draw_context.drawinfo.end.x = x; | |
1445 | ||
1446 | draw_context.drawinfo.y.over = 1; | |
1447 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); | |
1448 | draw_context.drawinfo.y.under = hashed_process_data->height; | |
1449 | ||
1450 | draw_context.drawinfo.start.offset.over = 0; | |
1451 | draw_context.drawinfo.start.offset.middle = 0; | |
1452 | draw_context.drawinfo.start.offset.under = 0; | |
1453 | draw_context.drawinfo.end.offset.over = 0; | |
1454 | draw_context.drawinfo.end.offset.middle = 0; | |
1455 | draw_context.drawinfo.end.offset.under = 0; | |
1456 | ||
1457 | { | |
1458 | /* Draw the line */ | |
1459 | PropertiesLine prop_line; | |
1460 | prop_line.line_width = STATE_LINE_WIDTH; | |
1461 | prop_line.style = GDK_LINE_SOLID; | |
1462 | prop_line.y = MIDDLE; | |
1463 | bdev_set_line_color(&prop_line, bdev); | |
1464 | draw_line((void*)&prop_line, (void*)&draw_context); | |
1465 | } | |
1466 | /* become the last x position */ | |
1467 | hashed_process_data->x.middle = x; | |
1468 | hashed_process_data->x.middle_used = TRUE; | |
1469 | hashed_process_data->x.middle_marked = FALSE; | |
1470 | ||
1471 | /* Calculate the next good time */ | |
1472 | convert_pixels_to_time(width, x+1, time_window, | |
1473 | &hashed_process_data->next_good_time); | |
1474 | } | |
1475 | } | |
1476 | ||
1477 | return 0; | |
1478 | } | |
dd47d0d8 | 1479 | #endif |
9e01e6d4 | 1480 | gint update_time_window_hook(void *hook_data, void *call_data) |
1481 | { | |
67f72973 | 1482 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
1483 | Drawing_t *drawing = resourceview_data->drawing; | |
1484 | ProcessList *process_list = resourceview_data->process_list; | |
9e01e6d4 | 1485 | |
1486 | const TimeWindowNotifyData *time_window_nofify_data = | |
1487 | ((const TimeWindowNotifyData *)call_data); | |
1488 | ||
1489 | TimeWindow *old_time_window = | |
1490 | time_window_nofify_data->old_time_window; | |
1491 | TimeWindow *new_time_window = | |
1492 | time_window_nofify_data->new_time_window; | |
1493 | ||
1494 | /* Update the ruler */ | |
67f72973 | 1495 | drawing_update_ruler(resourceview_data->drawing, |
9e01e6d4 | 1496 | new_time_window); |
1497 | ||
1498 | ||
1499 | /* Two cases : zoom in/out or scrolling */ | |
1500 | ||
1501 | /* In order to make sure we can reuse the old drawing, the scale must | |
1502 | * be the same and the new time interval being partly located in the | |
1503 | * currently shown time interval. (reuse is only for scrolling) | |
1504 | */ | |
1505 | ||
1506 | g_info("Old time window HOOK : %lu, %lu to %lu, %lu", | |
1507 | old_time_window->start_time.tv_sec, | |
1508 | old_time_window->start_time.tv_nsec, | |
1509 | old_time_window->time_width.tv_sec, | |
1510 | old_time_window->time_width.tv_nsec); | |
1511 | ||
1512 | g_info("New time window HOOK : %lu, %lu to %lu, %lu", | |
1513 | new_time_window->start_time.tv_sec, | |
1514 | new_time_window->start_time.tv_nsec, | |
1515 | new_time_window->time_width.tv_sec, | |
1516 | new_time_window->time_width.tv_nsec); | |
1517 | ||
1518 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec | |
1519 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) | |
1520 | { | |
1521 | /* Same scale (scrolling) */ | |
1522 | g_info("scrolling"); | |
1523 | LttTime *ns = &new_time_window->start_time; | |
9e01e6d4 | 1524 | LttTime *os = &old_time_window->start_time; |
9e01e6d4 | 1525 | LttTime old_end = old_time_window->end_time; |
1526 | LttTime new_end = new_time_window->end_time; | |
1527 | //if(ns<os+w<ns+w) | |
1528 | //if(ns<os+w && os+w<ns+w) | |
1529 | //if(ns<old_end && os<ns) | |
1530 | if(ltt_time_compare(*ns, old_end) == -1 | |
1531 | && ltt_time_compare(*os, *ns) == -1) | |
1532 | { | |
1533 | g_info("scrolling near right"); | |
1534 | /* Scroll right, keep right part of the screen */ | |
1535 | guint x = 0; | |
67f72973 | 1536 | guint width = resourceview_data->drawing->width; |
9e01e6d4 | 1537 | convert_time_to_pixels( |
1538 | *old_time_window, | |
1539 | *ns, | |
1540 | width, | |
1541 | &x); | |
1542 | ||
1543 | /* Copy old data to new location */ | |
1544 | copy_pixmap_region(process_list, | |
1545 | NULL, | |
67f72973 | 1546 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 | 1547 | NULL, |
1548 | x, 0, | |
1549 | 0, 0, | |
67f72973 | 1550 | resourceview_data->drawing->width-x+SAFETY, -1); |
9e01e6d4 | 1551 | |
1552 | if(drawing->damage_begin == drawing->damage_end) | |
67f72973 | 1553 | drawing->damage_begin = resourceview_data->drawing->width-x; |
9e01e6d4 | 1554 | else |
1555 | drawing->damage_begin = 0; | |
1556 | ||
67f72973 | 1557 | drawing->damage_end = resourceview_data->drawing->width; |
9e01e6d4 | 1558 | |
1559 | /* Clear the data request background, but not SAFETY */ | |
1560 | rectangle_pixmap(process_list, | |
67f72973 | 1561 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 | 1562 | TRUE, |
1563 | drawing->damage_begin+SAFETY, 0, | |
1564 | drawing->damage_end - drawing->damage_begin, // do not overlap | |
1565 | -1); | |
1566 | gtk_widget_queue_draw(drawing->drawing_area); | |
9e01e6d4 | 1567 | |
1568 | /* Get new data for the rest. */ | |
67f72973 | 1569 | drawing_data_request(resourceview_data->drawing, |
9e01e6d4 | 1570 | drawing->damage_begin, 0, |
1571 | drawing->damage_end - drawing->damage_begin, | |
67f72973 | 1572 | resourceview_data->drawing->height); |
9e01e6d4 | 1573 | } else { |
9e01e6d4 | 1574 | if(ltt_time_compare(*ns,*os) == -1 |
1575 | && ltt_time_compare(*os,new_end) == -1) | |
1576 | { | |
1577 | g_info("scrolling near left"); | |
1578 | /* Scroll left, keep left part of the screen */ | |
1579 | guint x = 0; | |
67f72973 | 1580 | guint width = resourceview_data->drawing->width; |
9e01e6d4 | 1581 | convert_time_to_pixels( |
1582 | *new_time_window, | |
1583 | *os, | |
1584 | width, | |
1585 | &x); | |
1586 | ||
1587 | /* Copy old data to new location */ | |
1588 | copy_pixmap_region (process_list, | |
1589 | NULL, | |
67f72973 | 1590 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 | 1591 | NULL, |
1592 | 0, 0, | |
1593 | x, 0, | |
1594 | -1, -1); | |
1595 | ||
1596 | if(drawing->damage_begin == drawing->damage_end) | |
1597 | drawing->damage_end = x; | |
1598 | else | |
1599 | drawing->damage_end = | |
67f72973 | 1600 | resourceview_data->drawing->width; |
9e01e6d4 | 1601 | |
1602 | drawing->damage_begin = 0; | |
1603 | ||
1604 | rectangle_pixmap (process_list, | |
67f72973 | 1605 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 | 1606 | TRUE, |
1607 | drawing->damage_begin, 0, | |
1608 | drawing->damage_end - drawing->damage_begin, // do not overlap | |
1609 | -1); | |
1610 | ||
1611 | gtk_widget_queue_draw(drawing->drawing_area); | |
9e01e6d4 | 1612 | |
1613 | /* Get new data for the rest. */ | |
67f72973 | 1614 | drawing_data_request(resourceview_data->drawing, |
9e01e6d4 | 1615 | drawing->damage_begin, 0, |
1616 | drawing->damage_end - drawing->damage_begin, | |
67f72973 | 1617 | resourceview_data->drawing->height); |
9e01e6d4 | 1618 | |
1619 | } else { | |
1620 | if(ltt_time_compare(*ns,*os) == 0) | |
1621 | { | |
1622 | g_info("not scrolling"); | |
1623 | } else { | |
1624 | g_info("scrolling far"); | |
1625 | /* Cannot reuse any part of the screen : far jump */ | |
1626 | ||
1627 | ||
1628 | rectangle_pixmap (process_list, | |
67f72973 | 1629 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 | 1630 | TRUE, |
1631 | 0, 0, | |
67f72973 | 1632 | resourceview_data->drawing->width+SAFETY, // do not overlap |
9e01e6d4 | 1633 | -1); |
1634 | ||
9e01e6d4 | 1635 | gtk_widget_queue_draw(drawing->drawing_area); |
1636 | ||
1637 | drawing->damage_begin = 0; | |
67f72973 | 1638 | drawing->damage_end = resourceview_data->drawing->width; |
9e01e6d4 | 1639 | |
67f72973 | 1640 | drawing_data_request(resourceview_data->drawing, |
9e01e6d4 | 1641 | 0, 0, |
67f72973 | 1642 | resourceview_data->drawing->width, |
1643 | resourceview_data->drawing->height); | |
9e01e6d4 | 1644 | |
1645 | } | |
1646 | } | |
1647 | } | |
1648 | } else { | |
1649 | /* Different scale (zoom) */ | |
1650 | g_info("zoom"); | |
1651 | ||
1652 | rectangle_pixmap (process_list, | |
67f72973 | 1653 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 | 1654 | TRUE, |
1655 | 0, 0, | |
67f72973 | 1656 | resourceview_data->drawing->width+SAFETY, // do not overlap |
9e01e6d4 | 1657 | -1); |
1658 | ||
9e01e6d4 | 1659 | gtk_widget_queue_draw(drawing->drawing_area); |
1660 | ||
1661 | drawing->damage_begin = 0; | |
67f72973 | 1662 | drawing->damage_end = resourceview_data->drawing->width; |
9e01e6d4 | 1663 | |
67f72973 | 1664 | drawing_data_request(resourceview_data->drawing, |
9e01e6d4 | 1665 | 0, 0, |
67f72973 | 1666 | resourceview_data->drawing->width, |
1667 | resourceview_data->drawing->height); | |
9e01e6d4 | 1668 | } |
1669 | ||
1670 | /* Update directly when scrolling */ | |
67f72973 | 1671 | gdk_window_process_updates(resourceview_data->drawing->drawing_area->window, |
9e01e6d4 | 1672 | TRUE); |
1673 | ||
1674 | return 0; | |
1675 | } | |
1676 | ||
1677 | gint traceset_notify(void *hook_data, void *call_data) | |
1678 | { | |
67f72973 | 1679 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
1680 | Drawing_t *drawing = resourceview_data->drawing; | |
9e01e6d4 | 1681 | |
1682 | if(unlikely(drawing->gc == NULL)) { | |
1683 | return FALSE; | |
1684 | } | |
1685 | if(drawing->dotted_gc == NULL) { | |
1686 | return FALSE; | |
1687 | } | |
1688 | ||
67f72973 | 1689 | drawing_clear(resourceview_data->drawing); |
1690 | processlist_clear(resourceview_data->process_list); | |
9e01e6d4 | 1691 | gtk_widget_set_size_request( |
67f72973 | 1692 | resourceview_data->drawing->drawing_area, |
1693 | -1, processlist_get_height(resourceview_data->process_list)); | |
1694 | redraw_notify(resourceview_data, NULL); | |
9e01e6d4 | 1695 | |
67f72973 | 1696 | request_background_data(resourceview_data); |
9e01e6d4 | 1697 | |
1698 | return FALSE; | |
1699 | } | |
1700 | ||
1701 | gint redraw_notify(void *hook_data, void *call_data) | |
1702 | { | |
67f72973 | 1703 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
1704 | Drawing_t *drawing = resourceview_data->drawing; | |
9e01e6d4 | 1705 | GtkWidget *widget = drawing->drawing_area; |
1706 | ||
1707 | drawing->damage_begin = 0; | |
1708 | drawing->damage_end = drawing->width; | |
1709 | ||
1710 | /* fun feature, to be separated someday... */ | |
67f72973 | 1711 | drawing_clear(resourceview_data->drawing); |
1712 | processlist_clear(resourceview_data->process_list); | |
9e01e6d4 | 1713 | gtk_widget_set_size_request( |
67f72973 | 1714 | resourceview_data->drawing->drawing_area, |
1715 | -1, processlist_get_height(resourceview_data->process_list)); | |
9e01e6d4 | 1716 | // Clear the images |
67f72973 | 1717 | rectangle_pixmap (resourceview_data->process_list, |
9e01e6d4 | 1718 | widget->style->black_gc, |
1719 | TRUE, | |
1720 | 0, 0, | |
1721 | drawing->alloc_width, | |
1722 | -1); | |
1723 | ||
1724 | gtk_widget_queue_draw(drawing->drawing_area); | |
1725 | ||
1726 | if(drawing->damage_begin < drawing->damage_end) | |
1727 | { | |
1728 | drawing_data_request(drawing, | |
1729 | drawing->damage_begin, | |
1730 | 0, | |
1731 | drawing->damage_end-drawing->damage_begin, | |
1732 | drawing->height); | |
1733 | } | |
1734 | ||
9e01e6d4 | 1735 | return FALSE; |
1736 | ||
1737 | } | |
1738 | ||
1739 | ||
1740 | gint continue_notify(void *hook_data, void *call_data) | |
1741 | { | |
67f72973 | 1742 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
1743 | Drawing_t *drawing = resourceview_data->drawing; | |
9e01e6d4 | 1744 | |
1745 | if(drawing->damage_begin < drawing->damage_end) | |
1746 | { | |
1747 | drawing_data_request(drawing, | |
1748 | drawing->damage_begin, | |
1749 | 0, | |
1750 | drawing->damage_end-drawing->damage_begin, | |
1751 | drawing->height); | |
1752 | } | |
1753 | ||
1754 | return FALSE; | |
1755 | } | |
1756 | ||
1757 | ||
1758 | gint update_current_time_hook(void *hook_data, void *call_data) | |
1759 | { | |
67f72973 | 1760 | ControlFlowData *resourceview_data = (ControlFlowData*)hook_data; |
9e01e6d4 | 1761 | |
1762 | LttTime current_time = *((LttTime*)call_data); | |
1763 | ||
1764 | TimeWindow time_window = | |
67f72973 | 1765 | lttvwindow_get_time_window(resourceview_data->tab); |
9e01e6d4 | 1766 | |
1767 | LttTime time_begin = time_window.start_time; | |
1768 | LttTime width = time_window.time_width; | |
1769 | LttTime half_width; | |
1770 | { | |
1771 | guint64 time_ll = ltt_time_to_uint64(width); | |
1772 | time_ll = time_ll >> 1; /* divide by two */ | |
1773 | half_width = ltt_time_from_uint64(time_ll); | |
1774 | } | |
1775 | LttTime time_end = ltt_time_add(time_begin, width); | |
1776 | ||
dd47d0d8 YB |
1777 | LttvTraceset * ts = lttvwindow_get_traceset(resourceview_data->tab); |
1778 | ||
1779 | TimeInterval time_span = lttv_traceset_get_time_span_real(ts); | |
1780 | LttTime trace_start = time_span.start_time; | |
1781 | LttTime trace_end = time_span.end_time; | |
9e01e6d4 | 1782 | |
1783 | g_info("New current time HOOK : %lu, %lu", current_time.tv_sec, | |
1784 | current_time.tv_nsec); | |
9e01e6d4 | 1785 | |
1786 | /* If current time is inside time interval, just move the highlight | |
1787 | * bar */ | |
1788 | ||
1789 | /* Else, we have to change the time interval. We have to tell it | |
1790 | * to the main window. */ | |
1791 | /* The time interval change will take care of placing the current | |
1792 | * time at the center of the visible area, or nearest possible if we are | |
1793 | * at one end of the trace. */ | |
1794 | ||
1795 | ||
1796 | if(ltt_time_compare(current_time, time_begin) < 0) | |
1797 | { | |
1798 | TimeWindow new_time_window; | |
1799 | ||
1800 | if(ltt_time_compare(current_time, | |
1801 | ltt_time_add(trace_start,half_width)) < 0) | |
1802 | time_begin = trace_start; | |
1803 | else | |
1804 | time_begin = ltt_time_sub(current_time,half_width); | |
1805 | ||
1806 | new_time_window.start_time = time_begin; | |
1807 | new_time_window.time_width = width; | |
1808 | new_time_window.time_width_double = ltt_time_to_double(width); | |
1809 | new_time_window.end_time = ltt_time_add(time_begin, width); | |
1810 | ||
67f72973 | 1811 | lttvwindow_report_time_window(resourceview_data->tab, new_time_window); |
9e01e6d4 | 1812 | } |
1813 | else if(ltt_time_compare(current_time, time_end) > 0) | |
1814 | { | |
1815 | TimeWindow new_time_window; | |
1816 | ||
1817 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0) | |
1818 | time_begin = ltt_time_sub(trace_end,width); | |
1819 | else | |
1820 | time_begin = ltt_time_sub(current_time,half_width); | |
1821 | ||
1822 | new_time_window.start_time = time_begin; | |
1823 | new_time_window.time_width = width; | |
1824 | new_time_window.time_width_double = ltt_time_to_double(width); | |
1825 | new_time_window.end_time = ltt_time_add(time_begin, width); | |
1826 | ||
67f72973 | 1827 | lttvwindow_report_time_window(resourceview_data->tab, new_time_window); |
9e01e6d4 | 1828 | |
1829 | } | |
67f72973 | 1830 | gtk_widget_queue_draw(resourceview_data->drawing->drawing_area); |
9e01e6d4 | 1831 | |
1832 | /* Update directly when scrolling */ | |
67f72973 | 1833 | gdk_window_process_updates(resourceview_data->drawing->drawing_area->window, |
9e01e6d4 | 1834 | TRUE); |
1835 | ||
1836 | return 0; | |
1837 | } | |
1838 | ||
1839 | typedef struct _ClosureData { | |
1840 | EventsRequest *events_request; | |
9e01e6d4 | 1841 | LttTime end_time; |
1842 | guint x_end; | |
1843 | } ClosureData; | |
1844 | ||
58a9b31b | 1845 | /* Draw line until end of the screen */ |
9e01e6d4 | 1846 | |
1847 | void draw_closure(gpointer key, gpointer value, gpointer user_data) | |
1848 | { | |
67f72973 | 1849 | ResourceUniqueNumeric *process_info = (ResourceUniqueNumeric*)key; |
44ffb95f | 1850 | HashedResourceData *hashed_process_data = (HashedResourceData*)value; |
1851 | ClosureData *closure_data = (ClosureData*)user_data; | |
1852 | ||
1853 | EventsRequest *events_request = closure_data->events_request; | |
67f72973 | 1854 | ControlFlowData *resourceview_data = events_request->viewer_data; |
dd47d0d8 | 1855 | LttvTraceset *ts = lttvwindow_get_traceset(resourceview_data->tab); |
44ffb95f | 1856 | |
1857 | LttTime evtime = closure_data->end_time; | |
1858 | ||
1859 | gboolean dodraw = TRUE; | |
1860 | ||
67f72973 | 1861 | if(hashed_process_data->type == RV_RESOURCE_MACHINE) |
1862 | return; | |
1863 | ||
44ffb95f | 1864 | { |
1865 | /* For the process */ | |
1866 | /* First, check if the current process is in the state computation | |
1867 | * process list. If it is there, that means we must add it right now and | |
1868 | * draw items from the beginning of the read for it. If it is not | |
1869 | * present, it's a new process and it was not present : it will | |
1870 | * be added after the state update. */ | |
1871 | #ifdef EXTRA_CHECK | |
1872 | g_assert(lttv_traceset_number(tsc->ts) > 0); | |
1873 | #endif //EXTRA_CHECK | |
dd47d0d8 YB |
1874 | //TODO Fdeslauriers 2012-07-17: adapt for multiple traces |
1875 | LttvTrace *trace = lttv_traceset_get(ts,0); | |
1876 | LttvTraceState *ts = trace->state; | |
44ffb95f | 1877 | |
67f72973 | 1878 | /* Only draw for processes that are currently in the trace states */ |
44ffb95f | 1879 | |
44ffb95f | 1880 | #ifdef EXTRA_CHECK |
67f72973 | 1881 | /* Should be alike when background info is ready */ |
1882 | if(resourceview_data->background_info_waiting==0) | |
44ffb95f | 1883 | g_assert(ltt_time_compare(process->creation_time, |
1884 | process_info->birth) == 0); | |
1885 | #endif //EXTRA_CHECK | |
1886 | ||
67f72973 | 1887 | /* Now, the process is in the state hash and our own process hash. |
1888 | * We definitely can draw the items related to the ending state. | |
1889 | */ | |
1890 | ||
1891 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, | |
1892 | evtime) <= 0)) | |
1893 | { | |
1894 | TimeWindow time_window = | |
1895 | lttvwindow_get_time_window(resourceview_data->tab); | |
44ffb95f | 1896 | |
1897 | #ifdef EXTRA_CHECK | |
67f72973 | 1898 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1899 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
1900 | return; | |
44ffb95f | 1901 | #endif //EXTRA_CHECK |
67f72973 | 1902 | Drawing_t *drawing = resourceview_data->drawing; |
1903 | guint width = drawing->width; | |
1904 | ||
1905 | guint x = closure_data->x_end; | |
1906 | ||
1907 | DrawContext draw_context; | |
1908 | ||
1909 | /* Now create the drawing context that will be used to draw | |
1910 | * items related to the last state. */ | |
1911 | draw_context.drawable = hashed_process_data->pixmap; | |
1912 | draw_context.gc = drawing->gc; | |
1913 | draw_context.pango_layout = drawing->pango_layout; | |
1914 | draw_context.drawinfo.end.x = x; | |
1915 | ||
1916 | draw_context.drawinfo.y.over = 1; | |
1917 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); | |
1918 | draw_context.drawinfo.y.under = hashed_process_data->height; | |
1919 | ||
1920 | draw_context.drawinfo.start.offset.over = 0; | |
1921 | draw_context.drawinfo.start.offset.middle = 0; | |
1922 | draw_context.drawinfo.start.offset.under = 0; | |
1923 | draw_context.drawinfo.end.offset.over = 0; | |
1924 | draw_context.drawinfo.end.offset.middle = 0; | |
1925 | draw_context.drawinfo.end.offset.under = 0; | |
44ffb95f | 1926 | #if 0 |
67f72973 | 1927 | /* Jump over draw if we are at the same x position */ |
1928 | if(x == hashed_process_data->x.over) | |
1929 | { | |
1930 | /* jump */ | |
1931 | } else { | |
1932 | draw_context.drawinfo.start.x = hashed_process_data->x.over; | |
1933 | /* Draw the line */ | |
1934 | PropertiesLine prop_line = prepare_execmode_line(process); | |
1935 | draw_line((void*)&prop_line, (void*)&draw_context); | |
44ffb95f | 1936 | |
67f72973 | 1937 | hashed_process_data->x.over = x; |
1938 | } | |
44ffb95f | 1939 | #endif //0 |
1940 | ||
67f72973 | 1941 | if(unlikely(x == hashed_process_data->x.middle && |
1942 | hashed_process_data->x.middle_used)) { | |
44ffb95f | 1943 | #if 0 /* do not mark closure : not missing information */ |
67f72973 | 1944 | if(hashed_process_data->x.middle_marked == FALSE) { |
1945 | /* Draw collision indicator */ | |
1946 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
1947 | gdk_draw_point(drawing->pixmap, | |
1948 | drawing->gc, | |
1949 | x, | |
1950 | y+(height/2)-3); | |
1951 | hashed_process_data->x.middle_marked = TRUE; | |
1952 | } | |
44ffb95f | 1953 | #endif //0 |
67f72973 | 1954 | /* Jump */ |
1955 | } else { | |
1956 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; | |
1957 | /* Draw the line */ | |
1958 | if(dodraw) { | |
1959 | PropertiesLine prop_line; | |
1960 | prop_line.line_width = STATE_LINE_WIDTH; | |
1961 | prop_line.style = GDK_LINE_SOLID; | |
1962 | prop_line.y = MIDDLE; | |
1963 | if(hashed_process_data->type == RV_RESOURCE_CPU) | |
1964 | cpu_set_line_color(&prop_line, &ts->cpu_states[process_info->id]); | |
1965 | else if(hashed_process_data->type == RV_RESOURCE_IRQ) | |
1966 | irq_set_line_color(&prop_line, &ts->irq_states[process_info->id]); | |
0305fe77 | 1967 | else if(hashed_process_data->type == RV_RESOURCE_SOFT_IRQ) |
1968 | soft_irq_set_line_color(&prop_line, &ts->soft_irq_states[process_info->id]); | |
38726a78 | 1969 | else if(hashed_process_data->type == RV_RESOURCE_TRAP) |
1970 | trap_set_line_color(&prop_line, &ts->trap_states[process_info->id]); | |
67f72973 | 1971 | else if(hashed_process_data->type == RV_RESOURCE_BDEV) { |
1972 | gint devcode_gint = process_info->id; | |
1973 | LttvBdevState *bdev = g_hash_table_lookup(ts->bdev_states, &devcode_gint); | |
1974 | // the lookup may return null; bdev_set_line_color must act appropriately | |
1975 | bdev_set_line_color(&prop_line, bdev); | |
44ffb95f | 1976 | } |
67f72973 | 1977 | |
1978 | draw_line((void*)&prop_line, (void*)&draw_context); | |
1979 | } | |
44ffb95f | 1980 | |
67f72973 | 1981 | /* become the last x position */ |
1982 | if(likely(x != hashed_process_data->x.middle)) { | |
1983 | hashed_process_data->x.middle = x; | |
1984 | /* but don't use the pixel */ | |
1985 | hashed_process_data->x.middle_used = FALSE; | |
44ffb95f | 1986 | |
67f72973 | 1987 | /* Calculate the next good time */ |
1988 | convert_pixels_to_time(width, x+1, time_window, | |
1989 | &hashed_process_data->next_good_time); | |
44ffb95f | 1990 | } |
1991 | } | |
67f72973 | 1992 | } |
44ffb95f | 1993 | } |
9e01e6d4 | 1994 | } |
1995 | ||
1996 | int before_chunk(void *hook_data, void *call_data) | |
1997 | { | |
1998 | EventsRequest *events_request = (EventsRequest*)hook_data; | |
dd47d0d8 YB |
1999 | LttvTraceset *ts = (LttvTraceset*)call_data; |
2000 | ||
9e01e6d4 | 2001 | #if 0 |
67f72973 | 2002 | /* Deactivate sort */ |
9e01e6d4 | 2003 | gtk_tree_sortable_set_sort_column_id( |
2004 | GTK_TREE_SORTABLE(cfd->process_list->list_store), | |
2005 | TRACE_COLUMN, | |
2006 | GTK_SORT_ASCENDING); | |
2007 | #endif //0 | |
dd47d0d8 | 2008 | drawing_chunk_begin(events_request, ts); |
9e01e6d4 | 2009 | |
2010 | return 0; | |
2011 | } | |
2012 | ||
d389bc8d | 2013 | /* before_request |
2014 | * | |
2015 | * This gets executed just before an events request is executed | |
2016 | */ | |
2017 | ||
9e01e6d4 | 2018 | int before_request(void *hook_data, void *call_data) |
2019 | { | |
2020 | EventsRequest *events_request = (EventsRequest*)hook_data; | |
9e01e6d4 | 2021 | |
dd47d0d8 | 2022 | drawing_data_request_begin(events_request); |
9e01e6d4 | 2023 | |
2024 | return 0; | |
2025 | } | |
2026 | ||
dd47d0d8 YB |
2027 | void draw_closing_lines(ControlFlowData *resourceview_data, |
2028 | EventsRequest* events_request) | |
9e01e6d4 | 2029 | { |
dd47d0d8 | 2030 | LttTime end_time = events_request->end_time; |
67f72973 | 2031 | ClosureData closure_data; |
dd47d0d8 | 2032 | closure_data.events_request = events_request; |
67f72973 | 2033 | closure_data.end_time = end_time; |
2034 | ||
dd47d0d8 | 2035 | |
67f72973 | 2036 | TimeWindow time_window = |
2037 | lttvwindow_get_time_window(resourceview_data->tab); | |
2038 | guint width = resourceview_data->drawing->width; | |
2039 | convert_time_to_pixels( | |
2040 | time_window, | |
2041 | end_time, | |
2042 | width, | |
2043 | &closure_data.x_end); | |
2044 | ||
dd47d0d8 | 2045 | guint i; |
67f72973 | 2046 | /* Draw last items */ |
2047 | for(i=0; i<RV_RESOURCE_COUNT; i++) { | |
2048 | g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data, i), draw_closure, | |
2049 | (void*)&closure_data); | |
2050 | } | |
2051 | ||
2052 | /* Request expose */ | |
dd47d0d8 YB |
2053 | drawing_request_expose(events_request, end_time); |
2054 | ||
2055 | } | |
2056 | /* | |
2057 | * after request is necessary in addition of after chunk in order to draw | |
2058 | * lines until the end of the screen. after chunk just draws lines until | |
2059 | * the last event. | |
2060 | * | |
2061 | * for each process | |
2062 | * draw closing line | |
2063 | * expose | |
2064 | */ | |
2065 | int after_request(void *hook_data, void *call_data) | |
2066 | { | |
2067 | ||
2068 | EventsRequest *events_request = (EventsRequest*)hook_data; | |
2069 | ControlFlowData *resourceview_data = events_request->viewer_data; | |
2070 | ||
2071 | draw_closing_lines(resourceview_data, events_request); | |
2072 | ||
9e01e6d4 | 2073 | return 0; |
2074 | } | |
2075 | ||
2076 | /* | |
2077 | * for each process | |
2078 | * draw closing line | |
2079 | * expose | |
2080 | */ | |
2081 | int after_chunk(void *hook_data, void *call_data) | |
2082 | { | |
2083 | EventsRequest *events_request = (EventsRequest*)hook_data; | |
67f72973 | 2084 | ControlFlowData *resourceview_data = events_request->viewer_data; |
dd47d0d8 YB |
2085 | LttvTraceset *ts = (LttvTraceset*)call_data; |
2086 | ||
9e01e6d4 | 2087 | LttTime end_time; |
2088 | ||
67f72973 | 2089 | ProcessList *process_list = resourceview_data->process_list; |
9e01e6d4 | 2090 | guint i; |
dd47d0d8 | 2091 | guint nb_trace = lttv_traceset_number(ts); |
9e01e6d4 | 2092 | |
2093 | /* Only execute when called for the first trace's events request */ | |
43ed82b5 | 2094 | if(!process_list->current_hash_data) |
2095 | return 0; | |
9e01e6d4 | 2096 | |
2097 | for(i = 0 ; i < nb_trace ; i++) { | |
2098 | g_free(process_list->current_hash_data[i]); | |
2099 | } | |
2100 | g_free(process_list->current_hash_data); | |
2101 | process_list->current_hash_data = NULL; | |
dd47d0d8 | 2102 | #ifdef BABEL_CLEANUP |
9e01e6d4 | 2103 | if(tfc != NULL) |
2104 | end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time); | |
2105 | else /* end of traceset, or position now out of request : end */ | |
2106 | end_time = events_request->end_time; | |
dd47d0d8 YB |
2107 | #endif |
2108 | draw_closing_lines(resourceview_data, events_request); | |
9e01e6d4 | 2109 | |
2110 | return 0; | |
2111 | } | |
2112 | ||
2113 | /* after_statedump_end | |
2114 | * | |
2115 | * @param hook_data ControlFlowData structure of the viewer. | |
2116 | * @param call_data Event context. | |
2117 | * | |
2118 | * This function adds items to be drawn in a queue for each process. | |
2119 | * | |
2120 | */ | |
2121 | int before_statedump_end(void *hook_data, void *call_data) | |
2122 | { | |
dd47d0d8 | 2123 | LttvEvent *event; |
67f72973 | 2124 | |
dd47d0d8 YB |
2125 | event = (LttvEvent *) call_data; |
2126 | ||
2127 | if (strcmp(lttv_traceset_get_name_from_event(event),"lttng_statedump_end") != 0) | |
2128 | return FALSE; | |
9e01e6d4 | 2129 | |
dd47d0d8 | 2130 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
9e01e6d4 | 2131 | |
9e01e6d4 | 2132 | |
dd47d0d8 YB |
2133 | LttvTraceState *ts = event->state; |
2134 | ||
2135 | ||
2136 | gint i; | |
2137 | ||
2138 | #ifdef BABEL_CLEANUP | |
9e01e6d4 | 2139 | |
67f72973 | 2140 | LttvFilter *filter = resourceview_data->filter; |
9e01e6d4 | 2141 | if(filter != NULL && filter->head != NULL) |
2142 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
2143 | tfc->t_context->t,tfc,NULL,NULL)) | |
2144 | return FALSE; | |
dd47d0d8 | 2145 | #endif |
9e01e6d4 | 2146 | |
dd47d0d8 | 2147 | LttTime evtime = lttv_event_get_timestamp(event); |
9e01e6d4 | 2148 | |
2149 | ClosureData closure_data; | |
dd47d0d8 YB |
2150 | //TODO ybrosseau 2013-03-27: Fake and event_request. |
2151 | // We need to change the API of drawing_request_expose to ask | |
2152 | // For and control flow data only. | |
2153 | EventsRequest events_request; | |
2154 | events_request.viewer_data = resourceview_data; | |
2155 | closure_data.events_request = &events_request; | |
9e01e6d4 | 2156 | closure_data.end_time = evtime; |
2157 | ||
2158 | TimeWindow time_window = | |
67f72973 | 2159 | lttvwindow_get_time_window(resourceview_data->tab); |
2160 | guint width = resourceview_data->drawing->width; | |
9e01e6d4 | 2161 | convert_time_to_pixels( |
2162 | time_window, | |
2163 | evtime, | |
2164 | width, | |
2165 | &closure_data.x_end); | |
2166 | ||
2167 | /* Draw last items */ | |
67f72973 | 2168 | |
2169 | for(i=0; i<RV_RESOURCE_COUNT; i++) { | |
2170 | g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data, i), draw_closure, | |
9e01e6d4 | 2171 | (void*)&closure_data); |
67f72973 | 2172 | } |
9e01e6d4 | 2173 | #if 0 |
2174 | /* Reactivate sort */ | |
2175 | gtk_tree_sortable_set_sort_column_id( | |
67f72973 | 2176 | GTK_TREE_SORTABLE(resourceview_data->process_list->list_store), |
9e01e6d4 | 2177 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
2178 | GTK_SORT_ASCENDING); | |
2179 | ||
67f72973 | 2180 | update_index_to_pixmap(resourceview_data->process_list); |
9e01e6d4 | 2181 | /* Request a full expose : drawing scrambled */ |
67f72973 | 2182 | gtk_widget_queue_draw(resourceview_data->drawing->drawing_area); |
9e01e6d4 | 2183 | #endif //0 |
2184 | /* Request expose (updates damages zone also) */ | |
dd47d0d8 | 2185 | drawing_request_expose(&events_request, evtime); |
9e01e6d4 | 2186 | |
2187 | return 0; | |
dd47d0d8 | 2188 | |
9e01e6d4 | 2189 | } |