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> |
59 | |
60 | //#include <pango/pango.h> |
61 | |
62 | #include <ltt/event.h> |
63 | #include <ltt/time.h> |
9e01e6d4 |
64 | #include <ltt/trace.h> |
65 | |
66 | #include <lttv/lttv.h> |
67 | #include <lttv/hook.h> |
68 | #include <lttv/state.h> |
69 | #include <lttvwindow/lttvwindow.h> |
70 | #include <lttvwindow/lttvwindowtraces.h> |
71 | #include <lttvwindow/support.h> |
72 | |
73 | |
74 | #include "eventhooks.h" |
75 | #include "cfv.h" |
76 | #include "processlist.h" |
77 | #include "drawing.h" |
78 | |
79 | |
80 | #define MAX_PATH_LEN 256 |
81 | #define STATE_LINE_WIDTH 4 |
82 | #define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3) |
83 | |
84 | extern GSList *g_legend_list; |
85 | |
86 | |
87 | /* Action to do when background computation completed. |
88 | * |
89 | * Wait for all the awaited computations to be over. |
90 | */ |
91 | |
92 | static gint background_ready(void *hook_data, void *call_data) |
93 | { |
67f72973 |
94 | ControlFlowData *resourceview_data = (ControlFlowData *)hook_data; |
9e01e6d4 |
95 | LttvTrace *trace = (LttvTrace*)call_data; |
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 | { |
67f72973 |
258 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
9e01e6d4 |
259 | guint *event_number = (guint*) call_data; |
260 | |
261 | g_debug("DEBUG : event selected by main window : %u", *event_number); |
262 | |
263 | return 0; |
264 | } |
265 | |
d3d99fde |
266 | static void cpu_set_line_color(PropertiesLine *prop_line, LttvCPUState *s) |
598026ba |
267 | { |
1b171947 |
268 | GQuark present_state; |
269 | |
270 | if(s->mode_stack->len == 0) |
271 | present_state = LTTV_CPU_UNKNOWN; |
272 | else |
273 | present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; |
d3d99fde |
274 | |
201fcc15 |
275 | if(present_state == LTTV_CPU_IDLE) { |
598026ba |
276 | prop_line->color = drawing_colors_cpu[COL_CPU_IDLE]; |
277 | } |
278 | else if(present_state == LTTV_CPU_BUSY) { |
279 | prop_line->color = drawing_colors_cpu[COL_CPU_BUSY]; |
280 | } |
281 | else if(present_state == LTTV_CPU_IRQ) { |
282 | prop_line->color = drawing_colors_cpu[COL_CPU_IRQ]; |
283 | } |
d3d99fde |
284 | else if(present_state == LTTV_CPU_TRAP) { |
285 | prop_line->color = drawing_colors_cpu[COL_CPU_TRAP]; |
201fcc15 |
286 | } else { |
287 | prop_line->color = drawing_colors_cpu[COL_CPU_UNKNOWN]; |
d3d99fde |
288 | } |
598026ba |
289 | } |
9e01e6d4 |
290 | |
8743690d |
291 | static void irq_set_line_color(PropertiesLine *prop_line, LttvIRQState *s) |
292 | { |
1b171947 |
293 | GQuark present_state; |
294 | if(s->mode_stack->len == 0) |
295 | present_state = LTTV_IRQ_UNKNOWN; |
296 | else |
297 | present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; |
8743690d |
298 | |
1b171947 |
299 | if(present_state == LTTV_IRQ_IDLE) { |
8743690d |
300 | prop_line->color = drawing_colors_irq[COL_IRQ_IDLE]; |
301 | } |
302 | else if(present_state == LTTV_IRQ_BUSY) { |
303 | prop_line->color = drawing_colors_irq[COL_IRQ_BUSY]; |
304 | } |
1b171947 |
305 | else { |
306 | prop_line->color = drawing_colors_irq[COL_IRQ_UNKNOWN]; |
307 | } |
8743690d |
308 | } |
309 | |
20d16f82 |
310 | static void bdev_set_line_color(PropertiesLine *prop_line, LttvBdevState *s) |
311 | { |
1b171947 |
312 | GQuark present_state; |
23e59a12 |
313 | if(s == 0 || s->mode_stack->len == 0) |
1b171947 |
314 | present_state = LTTV_BDEV_UNKNOWN; |
315 | else |
316 | present_state = ((GQuark*)s->mode_stack->data)[s->mode_stack->len-1]; |
20d16f82 |
317 | |
1b171947 |
318 | if(present_state == LTTV_BDEV_IDLE) { |
20d16f82 |
319 | prop_line->color = drawing_colors_bdev[COL_BDEV_IDLE]; |
320 | } |
321 | else if(present_state == LTTV_BDEV_BUSY_READING) { |
322 | prop_line->color = drawing_colors_bdev[COL_BDEV_BUSY_READING]; |
323 | } |
324 | else if(present_state == LTTV_BDEV_BUSY_WRITING) { |
325 | prop_line->color = drawing_colors_bdev[COL_BDEV_BUSY_WRITING]; |
326 | } |
1b171947 |
327 | else { |
328 | prop_line->color = drawing_colors_bdev[COL_BDEV_UNKNOWN]; |
329 | } |
20d16f82 |
330 | } |
331 | |
9e01e6d4 |
332 | /* before_schedchange_hook |
333 | * |
334 | * This function basically draw lines and icons. Two types of lines are drawn : |
335 | * one small (3 pixels?) representing the state of the process and the second |
336 | * type is thicker (10 pixels?) representing on which CPU a process is running |
337 | * (and this only in running state). |
338 | * |
339 | * Extremums of the lines : |
340 | * x_min : time of the last event context for this process kept in memory. |
341 | * x_max : time of the current event. |
342 | * y : middle of the process in the process list. The process is found in the |
343 | * list, therefore is it's position in pixels. |
344 | * |
345 | * The choice of lines'color is defined by the context of the last event for this |
346 | * process. |
347 | */ |
348 | |
349 | |
350 | int before_schedchange_hook(void *hook_data, void *call_data) |
351 | { |
dd455fb8 |
352 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
353 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
67f72973 |
354 | ControlFlowData *resourceview_data = events_request->viewer_data; |
9e01e6d4 |
355 | |
356 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
357 | |
358 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
359 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
360 | |
361 | LttEvent *e; |
362 | e = ltt_tracefile_get_event(tfc->tf); |
363 | gint target_pid_saved = tfc->target_pid; |
364 | |
365 | LttTime evtime = ltt_event_time(e); |
67f72973 |
366 | LttvFilter *filter = resourceview_data->filter; |
58a9b31b |
367 | |
9e01e6d4 |
368 | /* we are in a schedchange, before the state update. We must draw the |
369 | * items corresponding to the state before it changes : now is the right |
370 | * time to do it. |
371 | */ |
372 | |
373 | guint pid_out; |
374 | guint pid_in; |
ca5c76ed |
375 | pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
376 | pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); |
67f72973 |
377 | // TODO: can't we reenable this? pmf |
44ffb95f |
378 | // if(pid_in != 0 && pid_out != 0) { |
379 | // /* not a transition to/from idle */ |
380 | // return 0; |
381 | // } |
c4e6f4dc |
382 | |
9e01e6d4 |
383 | tfc->target_pid = pid_out; |
58a9b31b |
384 | |
67f72973 |
385 | guint cpu = tfs->cpu; |
9e01e6d4 |
386 | |
67f72973 |
387 | guint trace_num = ts->parent.index; |
388 | /* Add process to process list (if not present) */ |
389 | guint pl_height = 0; |
390 | HashedResourceData *hashed_process_data = NULL; |
391 | ProcessList *process_list = resourceview_data->process_list; |
9e01e6d4 |
392 | |
67f72973 |
393 | hashed_process_data = resourcelist_obtain_cpu(resourceview_data, trace_num, cpu); |
394 | |
395 | /* Now, the process is in the state hash and our own process hash. |
396 | * We definitely can draw the items related to the ending state. |
397 | */ |
398 | |
399 | if(ltt_time_compare(hashed_process_data->next_good_time, |
400 | evtime) > 0) |
401 | { |
402 | if(hashed_process_data->x.middle_marked == FALSE) { |
403 | |
404 | TimeWindow time_window = |
405 | lttvwindow_get_time_window(resourceview_data->tab); |
9e01e6d4 |
406 | #ifdef EXTRA_CHECK |
67f72973 |
407 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
408 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
409 | return; |
9e01e6d4 |
410 | #endif //EXTRA_CHECK |
67f72973 |
411 | Drawing_t *drawing = resourceview_data->drawing; |
412 | guint width = drawing->width; |
413 | guint x; |
414 | convert_time_to_pixels( |
415 | time_window, |
416 | evtime, |
417 | width, |
418 | &x); |
419 | |
420 | /* Draw collision indicator */ |
421 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
422 | gdk_draw_point(hashed_process_data->pixmap, |
423 | drawing->gc, |
424 | x, |
425 | COLLISION_POSITION(hashed_process_data->height)); |
426 | hashed_process_data->x.middle_marked = TRUE; |
427 | } |
428 | } else { |
429 | TimeWindow time_window = |
430 | lttvwindow_get_time_window(resourceview_data->tab); |
9e01e6d4 |
431 | #ifdef EXTRA_CHECK |
67f72973 |
432 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
9e01e6d4 |
433 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
67f72973 |
434 | return; |
9e01e6d4 |
435 | #endif //EXTRA_CHECK |
67f72973 |
436 | Drawing_t *drawing = resourceview_data->drawing; |
437 | guint width = drawing->width; |
438 | guint x; |
439 | convert_time_to_pixels( |
440 | time_window, |
441 | evtime, |
442 | width, |
443 | &x); |
9e01e6d4 |
444 | |
67f72973 |
445 | /* Jump over draw if we are at the same x position */ |
446 | if(x == hashed_process_data->x.middle && |
447 | hashed_process_data->x.middle_used) |
448 | { |
449 | if(hashed_process_data->x.middle_marked == FALSE) { |
450 | /* Draw collision indicator */ |
451 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
452 | gdk_draw_point(hashed_process_data->pixmap, |
453 | drawing->gc, |
454 | x, |
455 | COLLISION_POSITION(hashed_process_data->height)); |
456 | hashed_process_data->x.middle_marked = TRUE; |
58a9b31b |
457 | } |
67f72973 |
458 | /* jump */ |
459 | } else { |
460 | DrawContext draw_context; |
9e01e6d4 |
461 | |
67f72973 |
462 | /* Now create the drawing context that will be used to draw |
463 | * items related to the last state. */ |
464 | draw_context.drawable = hashed_process_data->pixmap; |
465 | draw_context.gc = drawing->gc; |
466 | draw_context.pango_layout = drawing->pango_layout; |
467 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
468 | draw_context.drawinfo.end.x = x; |
9e01e6d4 |
469 | |
67f72973 |
470 | draw_context.drawinfo.y.over = 1; |
471 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
472 | draw_context.drawinfo.y.under = hashed_process_data->height; |
9e01e6d4 |
473 | |
67f72973 |
474 | draw_context.drawinfo.start.offset.over = 0; |
475 | draw_context.drawinfo.start.offset.middle = 0; |
476 | draw_context.drawinfo.start.offset.under = 0; |
477 | draw_context.drawinfo.end.offset.over = 0; |
478 | draw_context.drawinfo.end.offset.middle = 0; |
479 | draw_context.drawinfo.end.offset.under = 0; |
9e01e6d4 |
480 | |
67f72973 |
481 | { |
482 | /* Draw the line */ |
483 | //PropertiesLine prop_line = prepare_s_e_line(process); |
484 | PropertiesLine prop_line; |
485 | prop_line.line_width = STATE_LINE_WIDTH; |
486 | prop_line.style = GDK_LINE_SOLID; |
487 | prop_line.y = MIDDLE; |
488 | cpu_set_line_color(&prop_line, tfs->cpu_state); |
489 | draw_line((void*)&prop_line, (void*)&draw_context); |
9e01e6d4 |
490 | |
67f72973 |
491 | } |
492 | /* become the last x position */ |
493 | hashed_process_data->x.middle = x; |
494 | hashed_process_data->x.middle_used = TRUE; |
495 | hashed_process_data->x.middle_marked = FALSE; |
9e01e6d4 |
496 | |
67f72973 |
497 | /* Calculate the next good time */ |
498 | convert_pixels_to_time(width, x+1, time_window, |
499 | &hashed_process_data->next_good_time); |
500 | } |
9e01e6d4 |
501 | } |
502 | |
67f72973 |
503 | return 0; |
9e01e6d4 |
504 | } |
505 | |
58a9b31b |
506 | /* after_schedchange_hook |
507 | * |
508 | * The draw after hook is called by the reading API to have a |
509 | * particular event drawn on the screen. |
510 | * @param hook_data ControlFlowData structure of the viewer. |
511 | * @param call_data Event context. |
512 | * |
513 | * This function adds items to be drawn in a queue for each process. |
514 | * |
515 | */ |
516 | int after_schedchange_hook(void *hook_data, void *call_data) |
9e01e6d4 |
517 | { |
dd455fb8 |
518 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
519 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
67f72973 |
520 | ControlFlowData *resourceview_data = events_request->viewer_data; |
44ffb95f |
521 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
44ffb95f |
522 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
44ffb95f |
523 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
44ffb95f |
524 | LttEvent *e; |
67f72973 |
525 | |
44ffb95f |
526 | e = ltt_tracefile_get_event(tfc->tf); |
527 | |
67f72973 |
528 | LttvFilter *filter = resourceview_data->filter; |
44ffb95f |
529 | if(filter != NULL && filter->head != NULL) |
530 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
531 | tfc->t_context->t,tfc,NULL,NULL)) |
532 | return FALSE; |
533 | |
534 | LttTime evtime = ltt_event_time(e); |
535 | |
44ffb95f |
536 | /* Add process to process list (if not present) */ |
537 | LttvProcessState *process_in; |
538 | LttTime birth; |
539 | guint pl_height = 0; |
540 | HashedResourceData *hashed_process_data_in = NULL; |
541 | |
67f72973 |
542 | ProcessList *process_list = resourceview_data->process_list; |
44ffb95f |
543 | |
544 | guint pid_in; |
545 | { |
546 | guint pid_out; |
ca5c76ed |
547 | pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
548 | pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); |
44ffb95f |
549 | } |
550 | |
551 | |
552 | /* Find process pid_in in the list... */ |
553 | //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in); |
554 | //process_in = tfs->process; |
555 | guint cpu = tfs->cpu; |
44ffb95f |
556 | guint trace_num = ts->parent.index; |
557 | process_in = ts->running_process[cpu]; |
558 | /* It should exist, because we are after the state update. */ |
559 | #ifdef EXTRA_CHECK |
560 | g_assert(process_in != NULL); |
561 | #endif //EXTRA_CHECK |
562 | birth = process_in->creation_time; |
563 | |
67f72973 |
564 | //hashed_process_data_in = processlist_get_process_data(process_list, cpuq, trace_num); |
565 | hashed_process_data_in = resourcelist_obtain_cpu(resourceview_data, trace_num, cpu); |
566 | |
44ffb95f |
567 | /* Set the current process */ |
568 | process_list->current_hash_data[trace_num][process_in->cpu] = |
569 | hashed_process_data_in; |
570 | |
571 | if(ltt_time_compare(hashed_process_data_in->next_good_time, |
572 | evtime) <= 0) |
573 | { |
574 | TimeWindow time_window = |
67f72973 |
575 | lttvwindow_get_time_window(resourceview_data->tab); |
44ffb95f |
576 | |
577 | #ifdef EXTRA_CHECK |
578 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
579 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
580 | return; |
581 | #endif //EXTRA_CHECK |
67f72973 |
582 | Drawing_t *drawing = resourceview_data->drawing; |
44ffb95f |
583 | guint width = drawing->width; |
584 | guint new_x; |
585 | |
586 | convert_time_to_pixels( |
587 | time_window, |
588 | evtime, |
589 | width, |
590 | &new_x); |
591 | |
592 | if(hashed_process_data_in->x.middle != new_x) { |
593 | hashed_process_data_in->x.middle = new_x; |
594 | hashed_process_data_in->x.middle_used = FALSE; |
595 | hashed_process_data_in->x.middle_marked = FALSE; |
596 | } |
597 | } |
58a9b31b |
598 | return 0; |
599 | } |
9e01e6d4 |
600 | |
58a9b31b |
601 | /* before_execmode_hook |
602 | * |
603 | * This function basically draw lines and icons. Two types of lines are drawn : |
604 | * one small (3 pixels?) representing the state of the process and the second |
605 | * type is thicker (10 pixels?) representing on which CPU a process is running |
606 | * (and this only in running state). |
607 | * |
608 | * Extremums of the lines : |
609 | * x_min : time of the last event context for this process kept in memory. |
610 | * x_max : time of the current event. |
611 | * y : middle of the process in the process list. The process is found in the |
612 | * list, therefore is it's position in pixels. |
613 | * |
614 | * The choice of lines'color is defined by the context of the last event for this |
615 | * process. |
616 | */ |
9e01e6d4 |
617 | |
598026ba |
618 | int before_execmode_hook(void *hook_data, void *call_data) |
619 | { |
dd455fb8 |
620 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
621 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
67f72973 |
622 | ControlFlowData *resourceview_data = events_request->viewer_data; |
598026ba |
623 | |
624 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
625 | |
626 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
627 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
628 | |
629 | LttEvent *e; |
630 | e = ltt_tracefile_get_event(tfc->tf); |
631 | |
632 | LttTime evtime = ltt_event_time(e); |
633 | |
8743690d |
634 | before_execmode_hook_irq(hook_data, call_data); |
635 | |
598026ba |
636 | /* we are in a execmode, before the state update. We must draw the |
637 | * items corresponding to the state before it changes : now is the right |
638 | * time to do it. |
639 | */ |
640 | /* For the pid */ |
598026ba |
641 | guint cpu = tfs->cpu; |
67f72973 |
642 | |
598026ba |
643 | guint trace_num = ts->parent.index; |
644 | LttvProcessState *process = ts->running_process[cpu]; |
645 | g_assert(process != NULL); |
646 | |
598026ba |
647 | /* Well, the process_out existed : we must get it in the process hash |
648 | * or add it, and draw its items. |
649 | */ |
650 | /* Add process to process list (if not present) */ |
651 | guint pl_height = 0; |
652 | HashedResourceData *hashed_process_data = NULL; |
67f72973 |
653 | ProcessList *process_list = resourceview_data->process_list; |
654 | |
598026ba |
655 | LttTime birth = process->creation_time; |
656 | |
657 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
658 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
659 | } else { |
67f72973 |
660 | hashed_process_data = resourcelist_obtain_cpu(resourceview_data, trace_num, cpu); |
661 | |
598026ba |
662 | /* Set the current process */ |
663 | process_list->current_hash_data[trace_num][process->cpu] = |
664 | hashed_process_data; |
665 | } |
666 | |
667 | /* Now, the process is in the state hash and our own process hash. |
668 | * We definitely can draw the items related to the ending state. |
669 | */ |
670 | |
671 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
672 | evtime) > 0)) |
673 | { |
674 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
675 | TimeWindow time_window = |
67f72973 |
676 | lttvwindow_get_time_window(resourceview_data->tab); |
598026ba |
677 | |
678 | #ifdef EXTRA_CHECK |
679 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
680 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
681 | return; |
682 | #endif //EXTRA_CHECK |
67f72973 |
683 | Drawing_t *drawing = resourceview_data->drawing; |
598026ba |
684 | guint width = drawing->width; |
685 | guint x; |
686 | convert_time_to_pixels( |
687 | time_window, |
688 | evtime, |
689 | width, |
690 | &x); |
691 | |
692 | /* Draw collision indicator */ |
693 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
694 | gdk_draw_point(hashed_process_data->pixmap, |
695 | drawing->gc, |
696 | x, |
697 | COLLISION_POSITION(hashed_process_data->height)); |
698 | hashed_process_data->x.middle_marked = TRUE; |
699 | } |
d3d99fde |
700 | } |
701 | else { |
598026ba |
702 | TimeWindow time_window = |
67f72973 |
703 | lttvwindow_get_time_window(resourceview_data->tab); |
598026ba |
704 | |
705 | #ifdef EXTRA_CHECK |
706 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
707 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
708 | return; |
709 | #endif //EXTRA_CHECK |
67f72973 |
710 | Drawing_t *drawing = resourceview_data->drawing; |
598026ba |
711 | guint width = drawing->width; |
712 | guint x; |
713 | |
714 | convert_time_to_pixels( |
715 | time_window, |
716 | evtime, |
717 | width, |
718 | &x); |
719 | |
720 | |
721 | /* Jump over draw if we are at the same x position */ |
722 | if(unlikely(x == hashed_process_data->x.middle && |
723 | hashed_process_data->x.middle_used)) |
724 | { |
725 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
726 | /* Draw collision indicator */ |
727 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
728 | gdk_draw_point(hashed_process_data->pixmap, |
729 | drawing->gc, |
730 | x, |
731 | COLLISION_POSITION(hashed_process_data->height)); |
732 | hashed_process_data->x.middle_marked = TRUE; |
733 | } |
734 | /* jump */ |
d3d99fde |
735 | } |
736 | else { |
598026ba |
737 | |
738 | DrawContext draw_context; |
739 | /* Now create the drawing context that will be used to draw |
740 | * items related to the last state. */ |
741 | draw_context.drawable = hashed_process_data->pixmap; |
742 | draw_context.gc = drawing->gc; |
743 | draw_context.pango_layout = drawing->pango_layout; |
744 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
745 | draw_context.drawinfo.end.x = x; |
746 | |
747 | draw_context.drawinfo.y.over = 1; |
748 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
749 | draw_context.drawinfo.y.under = hashed_process_data->height; |
750 | |
751 | draw_context.drawinfo.start.offset.over = 0; |
752 | draw_context.drawinfo.start.offset.middle = 0; |
753 | draw_context.drawinfo.start.offset.under = 0; |
754 | draw_context.drawinfo.end.offset.over = 0; |
755 | draw_context.drawinfo.end.offset.middle = 0; |
756 | draw_context.drawinfo.end.offset.under = 0; |
757 | |
758 | { |
759 | /* Draw the line */ |
760 | PropertiesLine prop_line; |
d3d99fde |
761 | prop_line.line_width = STATE_LINE_WIDTH; |
762 | prop_line.style = GDK_LINE_SOLID; |
763 | prop_line.y = MIDDLE; |
764 | cpu_set_line_color(&prop_line, tfs->cpu_state); |
598026ba |
765 | draw_line((void*)&prop_line, (void*)&draw_context); |
766 | } |
767 | /* become the last x position */ |
768 | hashed_process_data->x.middle = x; |
769 | hashed_process_data->x.middle_used = TRUE; |
770 | hashed_process_data->x.middle_marked = FALSE; |
771 | |
772 | /* Calculate the next good time */ |
773 | convert_pixels_to_time(width, x+1, time_window, |
774 | &hashed_process_data->next_good_time); |
775 | } |
776 | } |
777 | |
778 | return 0; |
779 | } |
9e01e6d4 |
780 | |
8743690d |
781 | int before_execmode_hook_irq(void *hook_data, void *call_data) |
782 | { |
dd455fb8 |
783 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
784 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
67f72973 |
785 | ControlFlowData *resourceview_data = events_request->viewer_data; |
8743690d |
786 | |
787 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
788 | |
789 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
790 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
791 | |
792 | LttEvent *e; |
793 | e = ltt_tracefile_get_event(tfc->tf); |
794 | |
795 | LttTime evtime = ltt_event_time(e); |
796 | |
ca5c76ed |
797 | LttTrace *trace = tfc->t_context->t; |
798 | |
8743690d |
799 | /* we are in a execmode, before the state update. We must draw the |
800 | * items corresponding to the state before it changes : now is the right |
801 | * time to do it. |
802 | */ |
803 | /* For the pid */ |
804 | |
805 | guint64 irq; |
806 | guint cpu = tfs->cpu; |
807 | |
ca5c76ed |
808 | guint16 ev_id_entry = marker_get_id_from_info(trace, marker_get_info_from_name(trace, lttv_merge_facility_event_name(LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY))); |
809 | guint16 ev_id_exit = marker_get_id_from_info(trace, marker_get_info_from_name(trace, lttv_merge_facility_event_name(LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT))); |
810 | if(ev_id_entry == e->event_id) { |
811 | irq = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
8743690d |
812 | } |
ca5c76ed |
813 | else if(ev_id_exit == e->event_id) { |
8743690d |
814 | irq = ts->cpu_states[cpu].last_irq; |
815 | } |
816 | else { |
817 | return 0; |
818 | } |
819 | |
8743690d |
820 | guint trace_num = ts->parent.index; |
821 | |
8743690d |
822 | /* Well, the process_out existed : we must get it in the process hash |
823 | * or add it, and draw its items. |
824 | */ |
825 | /* Add process to process list (if not present) */ |
826 | guint pl_height = 0; |
827 | HashedResourceData *hashed_process_data = NULL; |
67f72973 |
828 | ProcessList *process_list = resourceview_data->process_list; |
829 | |
830 | hashed_process_data = resourcelist_obtain_irq(resourceview_data, trace_num, irq); |
671c625b |
831 | // TODO: fix this, it's ugly and slow: |
832 | GQuark name; |
833 | { |
834 | gchar *str; |
835 | str = g_strdup_printf("IRQ %llu [%s]", irq, (char*)g_quark_to_string(ts->irq_names[irq])); |
836 | name = g_quark_from_string(str); |
837 | g_free(str); |
838 | } |
839 | gtk_tree_store_set(resourceview_data->process_list->list_store, &hashed_process_data->y_iter, NAME_COLUMN, g_quark_to_string(name), -1); |
8743690d |
840 | |
841 | /* Now, the process is in the state hash and our own process hash. |
842 | * We definitely can draw the items related to the ending state. |
843 | */ |
844 | |
845 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
846 | evtime) > 0)) |
847 | { |
848 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
849 | TimeWindow time_window = |
67f72973 |
850 | lttvwindow_get_time_window(resourceview_data->tab); |
8743690d |
851 | |
852 | #ifdef EXTRA_CHECK |
853 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
854 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
855 | return; |
856 | #endif //EXTRA_CHECK |
67f72973 |
857 | Drawing_t *drawing = resourceview_data->drawing; |
8743690d |
858 | guint width = drawing->width; |
859 | guint x; |
860 | convert_time_to_pixels( |
861 | time_window, |
862 | evtime, |
863 | width, |
864 | &x); |
865 | |
866 | /* Draw collision indicator */ |
867 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
868 | gdk_draw_point(hashed_process_data->pixmap, |
869 | drawing->gc, |
870 | x, |
871 | COLLISION_POSITION(hashed_process_data->height)); |
872 | hashed_process_data->x.middle_marked = TRUE; |
873 | } |
874 | } |
875 | else { |
876 | TimeWindow time_window = |
67f72973 |
877 | lttvwindow_get_time_window(resourceview_data->tab); |
8743690d |
878 | |
879 | #ifdef EXTRA_CHECK |
880 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
881 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
882 | return; |
883 | #endif //EXTRA_CHECK |
67f72973 |
884 | Drawing_t *drawing = resourceview_data->drawing; |
8743690d |
885 | guint width = drawing->width; |
886 | guint x; |
887 | |
888 | convert_time_to_pixels( |
889 | time_window, |
890 | evtime, |
891 | width, |
892 | &x); |
893 | |
894 | |
895 | /* Jump over draw if we are at the same x position */ |
896 | if(unlikely(x == hashed_process_data->x.middle && |
897 | hashed_process_data->x.middle_used)) |
898 | { |
899 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
900 | /* Draw collision indicator */ |
901 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
902 | gdk_draw_point(hashed_process_data->pixmap, |
903 | drawing->gc, |
904 | x, |
905 | COLLISION_POSITION(hashed_process_data->height)); |
906 | hashed_process_data->x.middle_marked = TRUE; |
907 | } |
908 | /* jump */ |
909 | } |
910 | else { |
911 | |
912 | DrawContext draw_context; |
913 | /* Now create the drawing context that will be used to draw |
914 | * items related to the last state. */ |
915 | draw_context.drawable = hashed_process_data->pixmap; |
916 | draw_context.gc = drawing->gc; |
917 | draw_context.pango_layout = drawing->pango_layout; |
918 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
919 | draw_context.drawinfo.end.x = x; |
920 | |
921 | draw_context.drawinfo.y.over = 1; |
922 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
923 | draw_context.drawinfo.y.under = hashed_process_data->height; |
924 | |
925 | draw_context.drawinfo.start.offset.over = 0; |
926 | draw_context.drawinfo.start.offset.middle = 0; |
927 | draw_context.drawinfo.start.offset.under = 0; |
928 | draw_context.drawinfo.end.offset.over = 0; |
929 | draw_context.drawinfo.end.offset.middle = 0; |
930 | draw_context.drawinfo.end.offset.under = 0; |
931 | |
932 | { |
933 | /* Draw the line */ |
934 | PropertiesLine prop_line; |
935 | prop_line.line_width = STATE_LINE_WIDTH; |
936 | prop_line.style = GDK_LINE_SOLID; |
937 | prop_line.y = MIDDLE; |
938 | irq_set_line_color(&prop_line, &ts->irq_states[irq]); |
939 | draw_line((void*)&prop_line, (void*)&draw_context); |
940 | } |
941 | /* become the last x position */ |
942 | hashed_process_data->x.middle = x; |
943 | hashed_process_data->x.middle_used = TRUE; |
944 | hashed_process_data->x.middle_marked = FALSE; |
945 | |
946 | /* Calculate the next good time */ |
947 | convert_pixels_to_time(width, x+1, time_window, |
948 | &hashed_process_data->next_good_time); |
949 | } |
950 | } |
951 | |
952 | return 0; |
953 | } |
954 | |
20d16f82 |
955 | int before_bdev_event_hook(void *hook_data, void *call_data) |
956 | { |
dd455fb8 |
957 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
958 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
67f72973 |
959 | ControlFlowData *resourceview_data = events_request->viewer_data; |
20d16f82 |
960 | |
961 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
962 | |
963 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
964 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
965 | |
966 | LttEvent *e; |
967 | e = ltt_tracefile_get_event(tfc->tf); |
968 | |
969 | LttTime evtime = ltt_event_time(e); |
970 | |
20d16f82 |
971 | /* we are in a execmode, before the state update. We must draw the |
972 | * items corresponding to the state before it changes : now is the right |
973 | * time to do it. |
974 | */ |
975 | /* For the pid */ |
976 | |
977 | guint cpu = tfs->cpu; |
ca5c76ed |
978 | guint8 major = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
979 | guint8 minor = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); |
980 | guint oper = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 2)); |
20d16f82 |
981 | gint devcode_gint = MKDEV(major,minor); |
982 | |
20d16f82 |
983 | guint trace_num = ts->parent.index; |
984 | |
985 | LttvBdevState *bdev = g_hash_table_lookup(ts->bdev_states, &devcode_gint); |
23e59a12 |
986 | /* the result of the lookup might be NULL. that's ok, the rest of the function |
987 | should understand it was not found and that its state is unknown */ |
20d16f82 |
988 | |
20d16f82 |
989 | /* Well, the process_out existed : we must get it in the process hash |
990 | * or add it, and draw its items. |
991 | */ |
992 | /* Add process to process list (if not present) */ |
993 | guint pl_height = 0; |
994 | HashedResourceData *hashed_process_data = NULL; |
67f72973 |
995 | ProcessList *process_list = resourceview_data->process_list; |
20d16f82 |
996 | // LttTime birth = process->creation_time; |
997 | |
998 | // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
999 | // hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
1000 | // } else { |
67f72973 |
1001 | hashed_process_data = resourcelist_obtain_bdev(resourceview_data, trace_num, devcode_gint); |
1002 | ////hashed_process_data = processlist_get_process_data(process_list, resourceq, trace_num); |
20d16f82 |
1003 | // hashed_process_data = processlist_get_process_data(process_list, |
1004 | // pid, |
1005 | // process->cpu, |
1006 | // &birth, |
1007 | // trace_num); |
67f72973 |
1008 | // |
20d16f82 |
1009 | /* Set the current process */ |
1010 | // process_list->current_hash_data[trace_num][process->cpu] = |
1011 | // hashed_process_data; |
1012 | // } |
1013 | |
1014 | /* Now, the process is in the state hash and our own process hash. |
1015 | * We definitely can draw the items related to the ending state. |
1016 | */ |
1017 | |
1018 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
1019 | evtime) > 0)) |
1020 | { |
1021 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
1022 | TimeWindow time_window = |
67f72973 |
1023 | lttvwindow_get_time_window(resourceview_data->tab); |
20d16f82 |
1024 | |
1025 | #ifdef EXTRA_CHECK |
1026 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1027 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1028 | return; |
1029 | #endif //EXTRA_CHECK |
67f72973 |
1030 | Drawing_t *drawing = resourceview_data->drawing; |
20d16f82 |
1031 | guint width = drawing->width; |
1032 | guint x; |
1033 | convert_time_to_pixels( |
1034 | time_window, |
1035 | evtime, |
1036 | width, |
1037 | &x); |
1038 | |
1039 | /* Draw collision indicator */ |
1040 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1041 | gdk_draw_point(hashed_process_data->pixmap, |
1042 | drawing->gc, |
1043 | x, |
1044 | COLLISION_POSITION(hashed_process_data->height)); |
1045 | hashed_process_data->x.middle_marked = TRUE; |
1046 | } |
1047 | } |
1048 | else { |
1049 | TimeWindow time_window = |
67f72973 |
1050 | lttvwindow_get_time_window(resourceview_data->tab); |
20d16f82 |
1051 | |
1052 | #ifdef EXTRA_CHECK |
1053 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1054 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1055 | return; |
1056 | #endif //EXTRA_CHECK |
67f72973 |
1057 | Drawing_t *drawing = resourceview_data->drawing; |
20d16f82 |
1058 | guint width = drawing->width; |
1059 | guint x; |
1060 | |
1061 | convert_time_to_pixels( |
1062 | time_window, |
1063 | evtime, |
1064 | width, |
1065 | &x); |
1066 | |
1067 | |
1068 | /* Jump over draw if we are at the same x position */ |
1069 | if(unlikely(x == hashed_process_data->x.middle && |
1070 | hashed_process_data->x.middle_used)) |
1071 | { |
1072 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
1073 | /* Draw collision indicator */ |
1074 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1075 | gdk_draw_point(hashed_process_data->pixmap, |
1076 | drawing->gc, |
1077 | x, |
1078 | COLLISION_POSITION(hashed_process_data->height)); |
1079 | hashed_process_data->x.middle_marked = TRUE; |
1080 | } |
1081 | /* jump */ |
1082 | } |
1083 | else { |
1084 | |
1085 | DrawContext draw_context; |
1086 | /* Now create the drawing context that will be used to draw |
1087 | * items related to the last state. */ |
1088 | draw_context.drawable = hashed_process_data->pixmap; |
1089 | draw_context.gc = drawing->gc; |
1090 | draw_context.pango_layout = drawing->pango_layout; |
1091 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
1092 | draw_context.drawinfo.end.x = x; |
1093 | |
1094 | draw_context.drawinfo.y.over = 1; |
1095 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
1096 | draw_context.drawinfo.y.under = hashed_process_data->height; |
1097 | |
1098 | draw_context.drawinfo.start.offset.over = 0; |
1099 | draw_context.drawinfo.start.offset.middle = 0; |
1100 | draw_context.drawinfo.start.offset.under = 0; |
1101 | draw_context.drawinfo.end.offset.over = 0; |
1102 | draw_context.drawinfo.end.offset.middle = 0; |
1103 | draw_context.drawinfo.end.offset.under = 0; |
1104 | |
1105 | { |
1106 | /* Draw the line */ |
1107 | PropertiesLine prop_line; |
1108 | prop_line.line_width = STATE_LINE_WIDTH; |
1109 | prop_line.style = GDK_LINE_SOLID; |
1110 | prop_line.y = MIDDLE; |
1111 | bdev_set_line_color(&prop_line, bdev); |
1112 | draw_line((void*)&prop_line, (void*)&draw_context); |
1113 | } |
1114 | /* become the last x position */ |
1115 | hashed_process_data->x.middle = x; |
1116 | hashed_process_data->x.middle_used = TRUE; |
1117 | hashed_process_data->x.middle_marked = FALSE; |
1118 | |
1119 | /* Calculate the next good time */ |
1120 | convert_pixels_to_time(width, x+1, time_window, |
1121 | &hashed_process_data->next_good_time); |
1122 | } |
1123 | } |
1124 | |
1125 | return 0; |
1126 | } |
1127 | |
9e01e6d4 |
1128 | gint update_time_window_hook(void *hook_data, void *call_data) |
1129 | { |
67f72973 |
1130 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
1131 | Drawing_t *drawing = resourceview_data->drawing; |
1132 | ProcessList *process_list = resourceview_data->process_list; |
9e01e6d4 |
1133 | |
1134 | const TimeWindowNotifyData *time_window_nofify_data = |
1135 | ((const TimeWindowNotifyData *)call_data); |
1136 | |
1137 | TimeWindow *old_time_window = |
1138 | time_window_nofify_data->old_time_window; |
1139 | TimeWindow *new_time_window = |
1140 | time_window_nofify_data->new_time_window; |
1141 | |
1142 | /* Update the ruler */ |
67f72973 |
1143 | drawing_update_ruler(resourceview_data->drawing, |
9e01e6d4 |
1144 | new_time_window); |
1145 | |
1146 | |
1147 | /* Two cases : zoom in/out or scrolling */ |
1148 | |
1149 | /* In order to make sure we can reuse the old drawing, the scale must |
1150 | * be the same and the new time interval being partly located in the |
1151 | * currently shown time interval. (reuse is only for scrolling) |
1152 | */ |
1153 | |
1154 | g_info("Old time window HOOK : %lu, %lu to %lu, %lu", |
1155 | old_time_window->start_time.tv_sec, |
1156 | old_time_window->start_time.tv_nsec, |
1157 | old_time_window->time_width.tv_sec, |
1158 | old_time_window->time_width.tv_nsec); |
1159 | |
1160 | g_info("New time window HOOK : %lu, %lu to %lu, %lu", |
1161 | new_time_window->start_time.tv_sec, |
1162 | new_time_window->start_time.tv_nsec, |
1163 | new_time_window->time_width.tv_sec, |
1164 | new_time_window->time_width.tv_nsec); |
1165 | |
1166 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
1167 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) |
1168 | { |
1169 | /* Same scale (scrolling) */ |
1170 | g_info("scrolling"); |
1171 | LttTime *ns = &new_time_window->start_time; |
1172 | LttTime *nw = &new_time_window->time_width; |
1173 | LttTime *os = &old_time_window->start_time; |
1174 | LttTime *ow = &old_time_window->time_width; |
1175 | LttTime old_end = old_time_window->end_time; |
1176 | LttTime new_end = new_time_window->end_time; |
1177 | //if(ns<os+w<ns+w) |
1178 | //if(ns<os+w && os+w<ns+w) |
1179 | //if(ns<old_end && os<ns) |
1180 | if(ltt_time_compare(*ns, old_end) == -1 |
1181 | && ltt_time_compare(*os, *ns) == -1) |
1182 | { |
1183 | g_info("scrolling near right"); |
1184 | /* Scroll right, keep right part of the screen */ |
1185 | guint x = 0; |
67f72973 |
1186 | guint width = resourceview_data->drawing->width; |
9e01e6d4 |
1187 | convert_time_to_pixels( |
1188 | *old_time_window, |
1189 | *ns, |
1190 | width, |
1191 | &x); |
1192 | |
1193 | /* Copy old data to new location */ |
1194 | copy_pixmap_region(process_list, |
1195 | NULL, |
67f72973 |
1196 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 |
1197 | NULL, |
1198 | x, 0, |
1199 | 0, 0, |
67f72973 |
1200 | resourceview_data->drawing->width-x+SAFETY, -1); |
9e01e6d4 |
1201 | |
1202 | if(drawing->damage_begin == drawing->damage_end) |
67f72973 |
1203 | drawing->damage_begin = resourceview_data->drawing->width-x; |
9e01e6d4 |
1204 | else |
1205 | drawing->damage_begin = 0; |
1206 | |
67f72973 |
1207 | drawing->damage_end = resourceview_data->drawing->width; |
9e01e6d4 |
1208 | |
1209 | /* Clear the data request background, but not SAFETY */ |
1210 | rectangle_pixmap(process_list, |
67f72973 |
1211 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 |
1212 | TRUE, |
1213 | drawing->damage_begin+SAFETY, 0, |
1214 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1215 | -1); |
1216 | gtk_widget_queue_draw(drawing->drawing_area); |
9e01e6d4 |
1217 | |
1218 | /* Get new data for the rest. */ |
67f72973 |
1219 | drawing_data_request(resourceview_data->drawing, |
9e01e6d4 |
1220 | drawing->damage_begin, 0, |
1221 | drawing->damage_end - drawing->damage_begin, |
67f72973 |
1222 | resourceview_data->drawing->height); |
9e01e6d4 |
1223 | } else { |
9e01e6d4 |
1224 | if(ltt_time_compare(*ns,*os) == -1 |
1225 | && ltt_time_compare(*os,new_end) == -1) |
1226 | { |
1227 | g_info("scrolling near left"); |
1228 | /* Scroll left, keep left part of the screen */ |
1229 | guint x = 0; |
67f72973 |
1230 | guint width = resourceview_data->drawing->width; |
9e01e6d4 |
1231 | convert_time_to_pixels( |
1232 | *new_time_window, |
1233 | *os, |
1234 | width, |
1235 | &x); |
1236 | |
1237 | /* Copy old data to new location */ |
1238 | copy_pixmap_region (process_list, |
1239 | NULL, |
67f72973 |
1240 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 |
1241 | NULL, |
1242 | 0, 0, |
1243 | x, 0, |
1244 | -1, -1); |
1245 | |
1246 | if(drawing->damage_begin == drawing->damage_end) |
1247 | drawing->damage_end = x; |
1248 | else |
1249 | drawing->damage_end = |
67f72973 |
1250 | resourceview_data->drawing->width; |
9e01e6d4 |
1251 | |
1252 | drawing->damage_begin = 0; |
1253 | |
1254 | rectangle_pixmap (process_list, |
67f72973 |
1255 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 |
1256 | TRUE, |
1257 | drawing->damage_begin, 0, |
1258 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1259 | -1); |
1260 | |
1261 | gtk_widget_queue_draw(drawing->drawing_area); |
9e01e6d4 |
1262 | |
1263 | /* Get new data for the rest. */ |
67f72973 |
1264 | drawing_data_request(resourceview_data->drawing, |
9e01e6d4 |
1265 | drawing->damage_begin, 0, |
1266 | drawing->damage_end - drawing->damage_begin, |
67f72973 |
1267 | resourceview_data->drawing->height); |
9e01e6d4 |
1268 | |
1269 | } else { |
1270 | if(ltt_time_compare(*ns,*os) == 0) |
1271 | { |
1272 | g_info("not scrolling"); |
1273 | } else { |
1274 | g_info("scrolling far"); |
1275 | /* Cannot reuse any part of the screen : far jump */ |
1276 | |
1277 | |
1278 | rectangle_pixmap (process_list, |
67f72973 |
1279 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 |
1280 | TRUE, |
1281 | 0, 0, |
67f72973 |
1282 | resourceview_data->drawing->width+SAFETY, // do not overlap |
9e01e6d4 |
1283 | -1); |
1284 | |
9e01e6d4 |
1285 | gtk_widget_queue_draw(drawing->drawing_area); |
1286 | |
1287 | drawing->damage_begin = 0; |
67f72973 |
1288 | drawing->damage_end = resourceview_data->drawing->width; |
9e01e6d4 |
1289 | |
67f72973 |
1290 | drawing_data_request(resourceview_data->drawing, |
9e01e6d4 |
1291 | 0, 0, |
67f72973 |
1292 | resourceview_data->drawing->width, |
1293 | resourceview_data->drawing->height); |
9e01e6d4 |
1294 | |
1295 | } |
1296 | } |
1297 | } |
1298 | } else { |
1299 | /* Different scale (zoom) */ |
1300 | g_info("zoom"); |
1301 | |
1302 | rectangle_pixmap (process_list, |
67f72973 |
1303 | resourceview_data->drawing->drawing_area->style->black_gc, |
9e01e6d4 |
1304 | TRUE, |
1305 | 0, 0, |
67f72973 |
1306 | resourceview_data->drawing->width+SAFETY, // do not overlap |
9e01e6d4 |
1307 | -1); |
1308 | |
9e01e6d4 |
1309 | gtk_widget_queue_draw(drawing->drawing_area); |
1310 | |
1311 | drawing->damage_begin = 0; |
67f72973 |
1312 | drawing->damage_end = resourceview_data->drawing->width; |
9e01e6d4 |
1313 | |
67f72973 |
1314 | drawing_data_request(resourceview_data->drawing, |
9e01e6d4 |
1315 | 0, 0, |
67f72973 |
1316 | resourceview_data->drawing->width, |
1317 | resourceview_data->drawing->height); |
9e01e6d4 |
1318 | } |
1319 | |
1320 | /* Update directly when scrolling */ |
67f72973 |
1321 | gdk_window_process_updates(resourceview_data->drawing->drawing_area->window, |
9e01e6d4 |
1322 | TRUE); |
1323 | |
1324 | return 0; |
1325 | } |
1326 | |
1327 | gint traceset_notify(void *hook_data, void *call_data) |
1328 | { |
67f72973 |
1329 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
1330 | Drawing_t *drawing = resourceview_data->drawing; |
9e01e6d4 |
1331 | |
1332 | if(unlikely(drawing->gc == NULL)) { |
1333 | return FALSE; |
1334 | } |
1335 | if(drawing->dotted_gc == NULL) { |
1336 | return FALSE; |
1337 | } |
1338 | |
67f72973 |
1339 | drawing_clear(resourceview_data->drawing); |
1340 | processlist_clear(resourceview_data->process_list); |
9e01e6d4 |
1341 | gtk_widget_set_size_request( |
67f72973 |
1342 | resourceview_data->drawing->drawing_area, |
1343 | -1, processlist_get_height(resourceview_data->process_list)); |
1344 | redraw_notify(resourceview_data, NULL); |
9e01e6d4 |
1345 | |
67f72973 |
1346 | request_background_data(resourceview_data); |
9e01e6d4 |
1347 | |
1348 | return FALSE; |
1349 | } |
1350 | |
1351 | gint redraw_notify(void *hook_data, void *call_data) |
1352 | { |
67f72973 |
1353 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
1354 | Drawing_t *drawing = resourceview_data->drawing; |
9e01e6d4 |
1355 | GtkWidget *widget = drawing->drawing_area; |
1356 | |
1357 | drawing->damage_begin = 0; |
1358 | drawing->damage_end = drawing->width; |
1359 | |
1360 | /* fun feature, to be separated someday... */ |
67f72973 |
1361 | drawing_clear(resourceview_data->drawing); |
1362 | processlist_clear(resourceview_data->process_list); |
9e01e6d4 |
1363 | gtk_widget_set_size_request( |
67f72973 |
1364 | resourceview_data->drawing->drawing_area, |
1365 | -1, processlist_get_height(resourceview_data->process_list)); |
9e01e6d4 |
1366 | // Clear the images |
67f72973 |
1367 | rectangle_pixmap (resourceview_data->process_list, |
9e01e6d4 |
1368 | widget->style->black_gc, |
1369 | TRUE, |
1370 | 0, 0, |
1371 | drawing->alloc_width, |
1372 | -1); |
1373 | |
1374 | gtk_widget_queue_draw(drawing->drawing_area); |
1375 | |
1376 | if(drawing->damage_begin < drawing->damage_end) |
1377 | { |
1378 | drawing_data_request(drawing, |
1379 | drawing->damage_begin, |
1380 | 0, |
1381 | drawing->damage_end-drawing->damage_begin, |
1382 | drawing->height); |
1383 | } |
1384 | |
9e01e6d4 |
1385 | return FALSE; |
1386 | |
1387 | } |
1388 | |
1389 | |
1390 | gint continue_notify(void *hook_data, void *call_data) |
1391 | { |
67f72973 |
1392 | ControlFlowData *resourceview_data = (ControlFlowData*) hook_data; |
1393 | Drawing_t *drawing = resourceview_data->drawing; |
9e01e6d4 |
1394 | |
1395 | if(drawing->damage_begin < drawing->damage_end) |
1396 | { |
1397 | drawing_data_request(drawing, |
1398 | drawing->damage_begin, |
1399 | 0, |
1400 | drawing->damage_end-drawing->damage_begin, |
1401 | drawing->height); |
1402 | } |
1403 | |
1404 | return FALSE; |
1405 | } |
1406 | |
1407 | |
1408 | gint update_current_time_hook(void *hook_data, void *call_data) |
1409 | { |
67f72973 |
1410 | ControlFlowData *resourceview_data = (ControlFlowData*)hook_data; |
1411 | Drawing_t *drawing = resourceview_data->drawing; |
9e01e6d4 |
1412 | |
1413 | LttTime current_time = *((LttTime*)call_data); |
1414 | |
1415 | TimeWindow time_window = |
67f72973 |
1416 | lttvwindow_get_time_window(resourceview_data->tab); |
9e01e6d4 |
1417 | |
1418 | LttTime time_begin = time_window.start_time; |
1419 | LttTime width = time_window.time_width; |
1420 | LttTime half_width; |
1421 | { |
1422 | guint64 time_ll = ltt_time_to_uint64(width); |
1423 | time_ll = time_ll >> 1; /* divide by two */ |
1424 | half_width = ltt_time_from_uint64(time_ll); |
1425 | } |
1426 | LttTime time_end = ltt_time_add(time_begin, width); |
1427 | |
1428 | LttvTracesetContext * tsc = |
67f72973 |
1429 | lttvwindow_get_traceset_context(resourceview_data->tab); |
9e01e6d4 |
1430 | |
1431 | LttTime trace_start = tsc->time_span.start_time; |
1432 | LttTime trace_end = tsc->time_span.end_time; |
1433 | |
1434 | g_info("New current time HOOK : %lu, %lu", current_time.tv_sec, |
1435 | current_time.tv_nsec); |
9e01e6d4 |
1436 | |
1437 | /* If current time is inside time interval, just move the highlight |
1438 | * bar */ |
1439 | |
1440 | /* Else, we have to change the time interval. We have to tell it |
1441 | * to the main window. */ |
1442 | /* The time interval change will take care of placing the current |
1443 | * time at the center of the visible area, or nearest possible if we are |
1444 | * at one end of the trace. */ |
1445 | |
1446 | |
1447 | if(ltt_time_compare(current_time, time_begin) < 0) |
1448 | { |
1449 | TimeWindow new_time_window; |
1450 | |
1451 | if(ltt_time_compare(current_time, |
1452 | ltt_time_add(trace_start,half_width)) < 0) |
1453 | time_begin = trace_start; |
1454 | else |
1455 | time_begin = ltt_time_sub(current_time,half_width); |
1456 | |
1457 | new_time_window.start_time = time_begin; |
1458 | new_time_window.time_width = width; |
1459 | new_time_window.time_width_double = ltt_time_to_double(width); |
1460 | new_time_window.end_time = ltt_time_add(time_begin, width); |
1461 | |
67f72973 |
1462 | lttvwindow_report_time_window(resourceview_data->tab, new_time_window); |
9e01e6d4 |
1463 | } |
1464 | else if(ltt_time_compare(current_time, time_end) > 0) |
1465 | { |
1466 | TimeWindow new_time_window; |
1467 | |
1468 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0) |
1469 | time_begin = ltt_time_sub(trace_end,width); |
1470 | else |
1471 | time_begin = ltt_time_sub(current_time,half_width); |
1472 | |
1473 | new_time_window.start_time = time_begin; |
1474 | new_time_window.time_width = width; |
1475 | new_time_window.time_width_double = ltt_time_to_double(width); |
1476 | new_time_window.end_time = ltt_time_add(time_begin, width); |
1477 | |
67f72973 |
1478 | lttvwindow_report_time_window(resourceview_data->tab, new_time_window); |
9e01e6d4 |
1479 | |
1480 | } |
67f72973 |
1481 | gtk_widget_queue_draw(resourceview_data->drawing->drawing_area); |
9e01e6d4 |
1482 | |
1483 | /* Update directly when scrolling */ |
67f72973 |
1484 | gdk_window_process_updates(resourceview_data->drawing->drawing_area->window, |
9e01e6d4 |
1485 | TRUE); |
1486 | |
1487 | return 0; |
1488 | } |
1489 | |
1490 | typedef struct _ClosureData { |
1491 | EventsRequest *events_request; |
1492 | LttvTracesetState *tss; |
1493 | LttTime end_time; |
1494 | guint x_end; |
1495 | } ClosureData; |
1496 | |
58a9b31b |
1497 | /* Draw line until end of the screen */ |
9e01e6d4 |
1498 | |
1499 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
1500 | { |
67f72973 |
1501 | ResourceUniqueNumeric *process_info = (ResourceUniqueNumeric*)key; |
44ffb95f |
1502 | HashedResourceData *hashed_process_data = (HashedResourceData*)value; |
1503 | ClosureData *closure_data = (ClosureData*)user_data; |
1504 | |
1505 | EventsRequest *events_request = closure_data->events_request; |
67f72973 |
1506 | ControlFlowData *resourceview_data = events_request->viewer_data; |
44ffb95f |
1507 | |
1508 | LttvTracesetState *tss = closure_data->tss; |
1509 | LttvTracesetContext *tsc = (LttvTracesetContext*)tss; |
1510 | |
1511 | LttTime evtime = closure_data->end_time; |
1512 | |
1513 | gboolean dodraw = TRUE; |
1514 | |
67f72973 |
1515 | if(hashed_process_data->type == RV_RESOURCE_MACHINE) |
1516 | return; |
1517 | |
44ffb95f |
1518 | { |
1519 | /* For the process */ |
1520 | /* First, check if the current process is in the state computation |
1521 | * process list. If it is there, that means we must add it right now and |
1522 | * draw items from the beginning of the read for it. If it is not |
1523 | * present, it's a new process and it was not present : it will |
1524 | * be added after the state update. */ |
1525 | #ifdef EXTRA_CHECK |
1526 | g_assert(lttv_traceset_number(tsc->ts) > 0); |
1527 | #endif //EXTRA_CHECK |
1528 | LttvTraceContext *tc = tsc->traces[process_info->trace_num]; |
1529 | LttvTraceState *ts = (LttvTraceState*)tc; |
1530 | |
67f72973 |
1531 | /* Only draw for processes that are currently in the trace states */ |
44ffb95f |
1532 | |
67f72973 |
1533 | ProcessList *process_list = resourceview_data->process_list; |
44ffb95f |
1534 | #ifdef EXTRA_CHECK |
67f72973 |
1535 | /* Should be alike when background info is ready */ |
1536 | if(resourceview_data->background_info_waiting==0) |
44ffb95f |
1537 | g_assert(ltt_time_compare(process->creation_time, |
1538 | process_info->birth) == 0); |
1539 | #endif //EXTRA_CHECK |
1540 | |
67f72973 |
1541 | /* Now, the process is in the state hash and our own process hash. |
1542 | * We definitely can draw the items related to the ending state. |
1543 | */ |
1544 | |
1545 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
1546 | evtime) <= 0)) |
1547 | { |
1548 | TimeWindow time_window = |
1549 | lttvwindow_get_time_window(resourceview_data->tab); |
44ffb95f |
1550 | |
1551 | #ifdef EXTRA_CHECK |
67f72973 |
1552 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1553 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1554 | return; |
44ffb95f |
1555 | #endif //EXTRA_CHECK |
67f72973 |
1556 | Drawing_t *drawing = resourceview_data->drawing; |
1557 | guint width = drawing->width; |
1558 | |
1559 | guint x = closure_data->x_end; |
1560 | |
1561 | DrawContext draw_context; |
1562 | |
1563 | /* Now create the drawing context that will be used to draw |
1564 | * items related to the last state. */ |
1565 | draw_context.drawable = hashed_process_data->pixmap; |
1566 | draw_context.gc = drawing->gc; |
1567 | draw_context.pango_layout = drawing->pango_layout; |
1568 | draw_context.drawinfo.end.x = x; |
1569 | |
1570 | draw_context.drawinfo.y.over = 1; |
1571 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
1572 | draw_context.drawinfo.y.under = hashed_process_data->height; |
1573 | |
1574 | draw_context.drawinfo.start.offset.over = 0; |
1575 | draw_context.drawinfo.start.offset.middle = 0; |
1576 | draw_context.drawinfo.start.offset.under = 0; |
1577 | draw_context.drawinfo.end.offset.over = 0; |
1578 | draw_context.drawinfo.end.offset.middle = 0; |
1579 | draw_context.drawinfo.end.offset.under = 0; |
44ffb95f |
1580 | #if 0 |
67f72973 |
1581 | /* Jump over draw if we are at the same x position */ |
1582 | if(x == hashed_process_data->x.over) |
1583 | { |
1584 | /* jump */ |
1585 | } else { |
1586 | draw_context.drawinfo.start.x = hashed_process_data->x.over; |
1587 | /* Draw the line */ |
1588 | PropertiesLine prop_line = prepare_execmode_line(process); |
1589 | draw_line((void*)&prop_line, (void*)&draw_context); |
44ffb95f |
1590 | |
67f72973 |
1591 | hashed_process_data->x.over = x; |
1592 | } |
44ffb95f |
1593 | #endif //0 |
1594 | |
67f72973 |
1595 | if(unlikely(x == hashed_process_data->x.middle && |
1596 | hashed_process_data->x.middle_used)) { |
44ffb95f |
1597 | #if 0 /* do not mark closure : not missing information */ |
67f72973 |
1598 | if(hashed_process_data->x.middle_marked == FALSE) { |
1599 | /* Draw collision indicator */ |
1600 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1601 | gdk_draw_point(drawing->pixmap, |
1602 | drawing->gc, |
1603 | x, |
1604 | y+(height/2)-3); |
1605 | hashed_process_data->x.middle_marked = TRUE; |
1606 | } |
44ffb95f |
1607 | #endif //0 |
67f72973 |
1608 | /* Jump */ |
1609 | } else { |
1610 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
1611 | /* Draw the line */ |
1612 | if(dodraw) { |
1613 | PropertiesLine prop_line; |
1614 | prop_line.line_width = STATE_LINE_WIDTH; |
1615 | prop_line.style = GDK_LINE_SOLID; |
1616 | prop_line.y = MIDDLE; |
1617 | if(hashed_process_data->type == RV_RESOURCE_CPU) |
1618 | cpu_set_line_color(&prop_line, &ts->cpu_states[process_info->id]); |
1619 | else if(hashed_process_data->type == RV_RESOURCE_IRQ) |
1620 | irq_set_line_color(&prop_line, &ts->irq_states[process_info->id]); |
1621 | else if(hashed_process_data->type == RV_RESOURCE_BDEV) { |
1622 | gint devcode_gint = process_info->id; |
1623 | LttvBdevState *bdev = g_hash_table_lookup(ts->bdev_states, &devcode_gint); |
1624 | // the lookup may return null; bdev_set_line_color must act appropriately |
1625 | bdev_set_line_color(&prop_line, bdev); |
44ffb95f |
1626 | } |
67f72973 |
1627 | |
1628 | draw_line((void*)&prop_line, (void*)&draw_context); |
1629 | } |
44ffb95f |
1630 | |
67f72973 |
1631 | /* become the last x position */ |
1632 | if(likely(x != hashed_process_data->x.middle)) { |
1633 | hashed_process_data->x.middle = x; |
1634 | /* but don't use the pixel */ |
1635 | hashed_process_data->x.middle_used = FALSE; |
44ffb95f |
1636 | |
67f72973 |
1637 | /* Calculate the next good time */ |
1638 | convert_pixels_to_time(width, x+1, time_window, |
1639 | &hashed_process_data->next_good_time); |
44ffb95f |
1640 | } |
1641 | } |
67f72973 |
1642 | } |
44ffb95f |
1643 | } |
9e01e6d4 |
1644 | } |
1645 | |
1646 | int before_chunk(void *hook_data, void *call_data) |
1647 | { |
1648 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1649 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
1650 | ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data; |
1651 | #if 0 |
67f72973 |
1652 | /* Deactivate sort */ |
9e01e6d4 |
1653 | gtk_tree_sortable_set_sort_column_id( |
1654 | GTK_TREE_SORTABLE(cfd->process_list->list_store), |
1655 | TRACE_COLUMN, |
1656 | GTK_SORT_ASCENDING); |
1657 | #endif //0 |
1658 | drawing_chunk_begin(events_request, tss); |
1659 | |
1660 | return 0; |
1661 | } |
1662 | |
1663 | int before_request(void *hook_data, void *call_data) |
1664 | { |
1665 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1666 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
1667 | |
1668 | drawing_data_request_begin(events_request, tss); |
1669 | |
1670 | return 0; |
1671 | } |
1672 | |
1673 | |
1674 | /* |
1675 | * after request is necessary in addition of after chunk in order to draw |
1676 | * lines until the end of the screen. after chunk just draws lines until |
1677 | * the last event. |
1678 | * |
1679 | * for each process |
1680 | * draw closing line |
1681 | * expose |
1682 | */ |
1683 | int after_request(void *hook_data, void *call_data) |
1684 | { |
67f72973 |
1685 | guint i; |
1686 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1687 | ControlFlowData *resourceview_data = events_request->viewer_data; |
1688 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
1689 | |
1690 | ProcessList *process_list = resourceview_data->process_list; |
1691 | LttTime end_time = events_request->end_time; |
1692 | |
1693 | ClosureData closure_data; |
1694 | closure_data.events_request = (EventsRequest*)hook_data; |
1695 | closure_data.tss = tss; |
1696 | closure_data.end_time = end_time; |
1697 | |
1698 | TimeWindow time_window = |
1699 | lttvwindow_get_time_window(resourceview_data->tab); |
1700 | guint width = resourceview_data->drawing->width; |
1701 | convert_time_to_pixels( |
1702 | time_window, |
1703 | end_time, |
1704 | width, |
1705 | &closure_data.x_end); |
1706 | |
1707 | |
1708 | /* Draw last items */ |
1709 | for(i=0; i<RV_RESOURCE_COUNT; i++) { |
1710 | g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data, i), draw_closure, |
1711 | (void*)&closure_data); |
1712 | } |
1713 | |
1714 | /* Request expose */ |
1715 | drawing_request_expose(events_request, tss, end_time); |
9e01e6d4 |
1716 | return 0; |
1717 | } |
1718 | |
1719 | /* |
1720 | * for each process |
1721 | * draw closing line |
1722 | * expose |
1723 | */ |
1724 | int after_chunk(void *hook_data, void *call_data) |
1725 | { |
1726 | EventsRequest *events_request = (EventsRequest*)hook_data; |
67f72973 |
1727 | ControlFlowData *resourceview_data = events_request->viewer_data; |
9e01e6d4 |
1728 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
1729 | LttvTracesetContext *tsc = (LttvTracesetContext*)call_data; |
1730 | LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc); |
1731 | LttTime end_time; |
1732 | |
67f72973 |
1733 | ProcessList *process_list = resourceview_data->process_list; |
9e01e6d4 |
1734 | guint i; |
1735 | LttvTraceset *traceset = tsc->ts; |
1736 | guint nb_trace = lttv_traceset_number(traceset); |
1737 | |
1738 | /* Only execute when called for the first trace's events request */ |
1739 | if(!process_list->current_hash_data) return; |
1740 | |
1741 | for(i = 0 ; i < nb_trace ; i++) { |
1742 | g_free(process_list->current_hash_data[i]); |
1743 | } |
1744 | g_free(process_list->current_hash_data); |
1745 | process_list->current_hash_data = NULL; |
1746 | |
1747 | if(tfc != NULL) |
1748 | end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time); |
1749 | else /* end of traceset, or position now out of request : end */ |
1750 | end_time = events_request->end_time; |
1751 | |
1752 | ClosureData closure_data; |
1753 | closure_data.events_request = (EventsRequest*)hook_data; |
1754 | closure_data.tss = tss; |
1755 | closure_data.end_time = end_time; |
1756 | |
1757 | TimeWindow time_window = |
67f72973 |
1758 | lttvwindow_get_time_window(resourceview_data->tab); |
1759 | guint width = resourceview_data->drawing->width; |
9e01e6d4 |
1760 | convert_time_to_pixels( |
1761 | time_window, |
1762 | end_time, |
1763 | width, |
1764 | &closure_data.x_end); |
1765 | |
1766 | /* Draw last items */ |
67f72973 |
1767 | for(i=0; i<RV_RESOURCE_COUNT; i++) { |
1768 | g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data, i), draw_closure, |
9e01e6d4 |
1769 | (void*)&closure_data); |
67f72973 |
1770 | } |
9e01e6d4 |
1771 | #if 0 |
1772 | /* Reactivate sort */ |
1773 | gtk_tree_sortable_set_sort_column_id( |
67f72973 |
1774 | GTK_TREE_SORTABLE(resourceview_data->process_list->list_store), |
9e01e6d4 |
1775 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
1776 | GTK_SORT_ASCENDING); |
1777 | |
67f72973 |
1778 | update_index_to_pixmap(resourceview_data->process_list); |
9e01e6d4 |
1779 | /* Request a full expose : drawing scrambled */ |
67f72973 |
1780 | gtk_widget_queue_draw(resourceview_data->drawing->drawing_area); |
9e01e6d4 |
1781 | #endif //0 |
1782 | /* Request expose (updates damages zone also) */ |
1783 | drawing_request_expose(events_request, tss, end_time); |
1784 | |
1785 | return 0; |
1786 | } |
1787 | |
1788 | /* after_statedump_end |
1789 | * |
1790 | * @param hook_data ControlFlowData structure of the viewer. |
1791 | * @param call_data Event context. |
1792 | * |
1793 | * This function adds items to be drawn in a queue for each process. |
1794 | * |
1795 | */ |
1796 | int before_statedump_end(void *hook_data, void *call_data) |
1797 | { |
67f72973 |
1798 | gint i; |
1799 | |
dd455fb8 |
1800 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1801 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
67f72973 |
1802 | ControlFlowData *resourceview_data = events_request->viewer_data; |
9e01e6d4 |
1803 | |
1804 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1805 | |
1806 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1807 | |
1808 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1809 | |
1810 | LttvTracesetState *tss = (LttvTracesetState*)tfc->t_context->ts_context; |
67f72973 |
1811 | ProcessList *process_list = resourceview_data->process_list; |
9e01e6d4 |
1812 | |
1813 | LttEvent *e; |
1814 | e = ltt_tracefile_get_event(tfc->tf); |
1815 | |
67f72973 |
1816 | LttvFilter *filter = resourceview_data->filter; |
9e01e6d4 |
1817 | if(filter != NULL && filter->head != NULL) |
1818 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
1819 | tfc->t_context->t,tfc,NULL,NULL)) |
1820 | return FALSE; |
1821 | |
1822 | LttTime evtime = ltt_event_time(e); |
1823 | |
1824 | ClosureData closure_data; |
1825 | closure_data.events_request = events_request; |
1826 | closure_data.tss = tss; |
1827 | closure_data.end_time = evtime; |
1828 | |
1829 | TimeWindow time_window = |
67f72973 |
1830 | lttvwindow_get_time_window(resourceview_data->tab); |
1831 | guint width = resourceview_data->drawing->width; |
9e01e6d4 |
1832 | convert_time_to_pixels( |
1833 | time_window, |
1834 | evtime, |
1835 | width, |
1836 | &closure_data.x_end); |
1837 | |
1838 | /* Draw last items */ |
67f72973 |
1839 | |
1840 | for(i=0; i<RV_RESOURCE_COUNT; i++) { |
1841 | g_hash_table_foreach(resourcelist_get_resource_hash_table(resourceview_data, i), draw_closure, |
9e01e6d4 |
1842 | (void*)&closure_data); |
67f72973 |
1843 | } |
9e01e6d4 |
1844 | #if 0 |
1845 | /* Reactivate sort */ |
1846 | gtk_tree_sortable_set_sort_column_id( |
67f72973 |
1847 | GTK_TREE_SORTABLE(resourceview_data->process_list->list_store), |
9e01e6d4 |
1848 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
1849 | GTK_SORT_ASCENDING); |
1850 | |
67f72973 |
1851 | update_index_to_pixmap(resourceview_data->process_list); |
9e01e6d4 |
1852 | /* Request a full expose : drawing scrambled */ |
67f72973 |
1853 | gtk_widget_queue_draw(resourceview_data->drawing->drawing_area); |
9e01e6d4 |
1854 | #endif //0 |
1855 | /* Request expose (updates damages zone also) */ |
1856 | drawing_request_expose(events_request, tss, evtime); |
1857 | |
1858 | return 0; |
1859 | } |