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