Commit | Line | Data |
---|---|---|
ce0214a6 | 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 | ||
f0d936c0 | 20 | /***************************************************************************** |
21 | * Hooks to be called by the main window * | |
22 | *****************************************************************************/ | |
23 | ||
f0d936c0 | 24 | |
b9a010a2 | 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 | * | |
e92eabaf | 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. | |
b9a010a2 | 31 | * |
e92eabaf | 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. | |
b9a010a2 | 34 | * |
e92eabaf | 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 | |
b9a010a2 | 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 | |
e92eabaf | 40 | * corresponding to it is over, which happens to be at the next before_schedchange |
b9a010a2 | 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 | ||
4e4d11b3 | 48 | #ifdef HAVE_CONFIG_H |
49 | #include <config.h> | |
50 | #endif | |
b9a010a2 | 51 | |
cf6cb7e0 | 52 | //#define PANGO_ENABLE_BACKEND |
558aa013 | 53 | #include <gtk/gtk.h> |
54 | #include <gdk/gdk.h> | |
5f16133f | 55 | #include <glib.h> |
80a52ff8 | 56 | #include <assert.h> |
50439712 | 57 | #include <string.h> |
319e9d81 | 58 | #include <stdio.h> |
5f16133f | 59 | |
cf6cb7e0 | 60 | //#include <pango/pango.h> |
61 | ||
80a52ff8 | 62 | #include <ltt/event.h> |
4ba42155 | 63 | #include <ltt/time.h> |
2c82c4dc | 64 | #include <ltt/trace.h> |
80a52ff8 | 65 | |
2a2fa4f0 | 66 | #include <lttv/lttv.h> |
558aa013 | 67 | #include <lttv/hook.h> |
80a52ff8 | 68 | #include <lttv/state.h> |
2d262115 | 69 | #include <lttvwindow/lttvwindow.h> |
6395d57c | 70 | #include <lttvwindow/lttvwindowtraces.h> |
0de51231 | 71 | #include <lttvwindow/support.h> |
80a52ff8 | 72 | |
f0d936c0 | 73 | |
a117e3f7 | 74 | #include "eventhooks.h" |
75 | #include "cfv.h" | |
76 | #include "processlist.h" | |
77 | #include "drawing.h" | |
5f16133f | 78 | |
80a52ff8 | 79 | |
1a31868c | 80 | #define MAX_PATH_LEN 256 |
98dfb302 | 81 | #define STATE_LINE_WIDTH 8 |
5bb606ce | 82 | #define COLLISION_POSITION(height) (((height - STATE_LINE_WIDTH)/2) -3) |
1a31868c | 83 | |
0de51231 | 84 | extern GSList *g_legend_list; |
85 | ||
b9a010a2 | 86 | |
6395d57c | 87 | /* Action to do when background computation completed. |
88 | * | |
e800cf84 | 89 | * Wait for all the awaited computations to be over. |
6395d57c | 90 | */ |
91 | ||
703b25fa | 92 | static gint background_ready(void *hook_data, void *call_data) |
6395d57c | 93 | { |
94 | ControlFlowData *control_flow_data = (ControlFlowData *)hook_data; | |
6395d57c | 95 | |
e800cf84 | 96 | control_flow_data->background_info_waiting--; |
97 | ||
98 | if(control_flow_data->background_info_waiting == 0) { | |
4a24fa1f | 99 | g_message("control flow viewer : background computation data ready."); |
6395d57c | 100 | |
e800cf84 | 101 | drawing_clear(control_flow_data->drawing); |
102 | processlist_clear(control_flow_data->process_list); | |
07390ec1 | 103 | gtk_widget_set_size_request( |
104 | control_flow_data->drawing->drawing_area, | |
105 | -1, processlist_get_height(control_flow_data->process_list)); | |
e800cf84 | 106 | redraw_notify(control_flow_data, NULL); |
b9a010a2 | 107 | } |
6395d57c | 108 | |
109 | return 0; | |
110 | } | |
111 | ||
112 | ||
113 | /* Request background computation. Verify if it is in progress or ready first. | |
e800cf84 | 114 | * Only for each trace in the tab's traceset. |
6395d57c | 115 | */ |
88bf15f0 | 116 | |
3f7f592e | 117 | static void request_background_data(ControlFlowData *control_flow_data) |
6395d57c | 118 | { |
88bf15f0 FD |
119 | |
120 | LttvTraceset *ts = lttvwindow_get_traceset(control_flow_data->tab); | |
121 | gint num_traces = lttv_traceset_number(ts); | |
6395d57c | 122 | gint i; |
123 | LttvTrace *trace; | |
7df20ca4 | 124 | LttvTraceState *tstate; |
6395d57c | 125 | |
88bf15f0 | 126 | LttvHooks *background_ready_hook = lttv_hooks_new(); |
6395d57c | 127 | lttv_hooks_add(background_ready_hook, background_ready, control_flow_data, |
128 | LTTV_PRIO_DEFAULT); | |
e800cf84 | 129 | control_flow_data->background_info_waiting = 0; |
6395d57c | 130 | |
131 | for(i=0;i<num_traces;i++) { | |
88bf15f0 FD |
132 | trace = lttv_traceset_get(ts, i); |
133 | tstate = trace->state; | |
6395d57c | 134 | |
7df20ca4 | 135 | if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE |
88bf15f0 | 136 | && !ts->has_precomputed_states) { |
6395d57c | 137 | |
138 | if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"), | |
139 | trace) == FALSE) { | |
140 | /* We first remove requests that could have been done for the same | |
141 | * information. Happens when two viewers ask for it before servicing | |
142 | * starts. | |
143 | */ | |
93ac601b | 144 | if(!lttvwindowtraces_background_request_find(trace, "state")) |
b5e17af5 | 145 | lttvwindowtraces_background_request_queue( |
146 | main_window_get_widget(control_flow_data->tab), trace, "state"); | |
6395d57c | 147 | lttvwindowtraces_background_notify_queue(control_flow_data, |
148 | trace, | |
149 | ltt_time_infinite, | |
150 | NULL, | |
151 | background_ready_hook); | |
e800cf84 | 152 | control_flow_data->background_info_waiting++; |
6395d57c | 153 | } else { /* in progress */ |
154 | ||
155 | lttvwindowtraces_background_notify_current(control_flow_data, | |
156 | trace, | |
157 | ltt_time_infinite, | |
158 | NULL, | |
159 | background_ready_hook); | |
e800cf84 | 160 | control_flow_data->background_info_waiting++; |
6395d57c | 161 | } |
4368b993 | 162 | } else { |
7df20ca4 | 163 | /* Data ready. By its nature, this viewer doesn't need to have |
618fbcc1 | 164 | * its data ready hook called there, because a background |
4368b993 | 165 | * request is always linked with a redraw. |
166 | */ | |
6395d57c | 167 | } |
4368b993 | 168 | |
6395d57c | 169 | } |
170 | ||
171 | lttv_hooks_destroy(background_ready_hook); | |
172 | } | |
173 | ||
174 | ||
175 | ||
176 | ||
f0d936c0 | 177 | /** |
178 | * Event Viewer's constructor hook | |
179 | * | |
180 | * This constructor is given as a parameter to the menuitem and toolbar button | |
181 | * registration. It creates the list. | |
ca0f8a8e | 182 | * @param tab A pointer to the parent tab. |
f0d936c0 | 183 | * @return The widget created. |
184 | */ | |
185 | GtkWidget * | |
e433e6d6 | 186 | h_guicontrolflow(LttvPlugin *plugin) |
f0d936c0 | 187 | { |
e433e6d6 | 188 | LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin); |
189 | Tab *tab = ptab->tab; | |
d47b33d2 | 190 | g_info("h_guicontrolflow, %p", tab); |
e433e6d6 | 191 | ControlFlowData *control_flow_data = guicontrolflow(ptab); |
a56a1ba4 | 192 | |
ca0f8a8e | 193 | control_flow_data->tab = tab; |
a56a1ba4 | 194 | |
a56a1ba4 | 195 | // Unreg done in the GuiControlFlow_Destructor |
6395d57c | 196 | lttvwindow_register_traceset_notify(tab, |
197 | traceset_notify, | |
198 | control_flow_data); | |
199 | ||
ca0f8a8e | 200 | lttvwindow_register_time_window_notify(tab, |
224446ce | 201 | update_time_window_hook, |
202 | control_flow_data); | |
ca0f8a8e | 203 | lttvwindow_register_current_time_notify(tab, |
224446ce | 204 | update_current_time_hook, |
205 | control_flow_data); | |
ca0f8a8e | 206 | lttvwindow_register_redraw_notify(tab, |
207 | redraw_notify, | |
208 | control_flow_data); | |
209 | lttvwindow_register_continue_notify(tab, | |
210 | continue_notify, | |
211 | control_flow_data); | |
667ca2a0 | 212 | request_background_data(control_flow_data); |
6395d57c | 213 | |
ca0f8a8e | 214 | |
68997a22 | 215 | return guicontrolflow_get_widget(control_flow_data) ; |
a56a1ba4 | 216 | |
f0d936c0 | 217 | } |
218 | ||
3cff8cc1 | 219 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 | 220 | { |
14963be0 | 221 | guint *event_number = (guint*) call_data; |
f0d936c0 | 222 | |
2a2fa4f0 | 223 | g_debug("DEBUG : event selected by main window : %u", *event_number); |
a56a1ba4 | 224 | |
2eef04b5 | 225 | return 0; |
f0d936c0 | 226 | } |
227 | ||
9a1ec01b | 228 | /* Function that selects the color of status&exemode line */ |
6550d711 | 229 | static inline PropertiesLine prepare_s_e_line(LttvProcessState *process) |
9a1ec01b | 230 | { |
231 | PropertiesLine prop_line; | |
5bb606ce | 232 | prop_line.line_width = STATE_LINE_WIDTH; |
9a1ec01b | 233 | prop_line.style = GDK_LINE_SOLID; |
234 | prop_line.y = MIDDLE; | |
235 | //GdkColormap *colormap = gdk_colormap_get_system(); | |
236 | ||
9a1ec01b | 237 | if(process->state->s == LTTV_STATE_RUN) { |
238 | if(process->state->t == LTTV_STATE_USER_MODE) | |
239 | prop_line.color = drawing_colors[COL_RUN_USER_MODE]; | |
240 | else if(process->state->t == LTTV_STATE_SYSCALL) | |
241 | prop_line.color = drawing_colors[COL_RUN_SYSCALL]; | |
242 | else if(process->state->t == LTTV_STATE_TRAP) | |
243 | prop_line.color = drawing_colors[COL_RUN_TRAP]; | |
244 | else if(process->state->t == LTTV_STATE_IRQ) | |
245 | prop_line.color = drawing_colors[COL_RUN_IRQ]; | |
faf074a3 | 246 | else if(process->state->t == LTTV_STATE_SOFT_IRQ) |
247 | prop_line.color = drawing_colors[COL_RUN_SOFT_IRQ]; | |
f044974e MD |
248 | else if(process->state->t == LTTV_STATE_MAYBE_SYSCALL) |
249 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; | |
250 | else if(process->state->t == LTTV_STATE_MAYBE_USER_MODE) | |
251 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; | |
252 | else if(process->state->t == LTTV_STATE_MAYBE_TRAP) | |
253 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; | |
9a1ec01b | 254 | else if(process->state->t == LTTV_STATE_MODE_UNKNOWN) |
255 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; | |
256 | else | |
257 | g_assert(FALSE); /* RUNNING MODE UNKNOWN */ | |
258 | } else if(process->state->s == LTTV_STATE_WAIT) { | |
259 | /* We don't show if we wait while in user mode, trap, irq or syscall */ | |
260 | prop_line.color = drawing_colors[COL_WAIT]; | |
261 | } else if(process->state->s == LTTV_STATE_WAIT_CPU) { | |
262 | /* We don't show if we wait for CPU while in user mode, trap, irq | |
263 | * or syscall */ | |
264 | prop_line.color = drawing_colors[COL_WAIT_CPU]; | |
265 | } else if(process->state->s == LTTV_STATE_ZOMBIE) { | |
266 | prop_line.color = drawing_colors[COL_ZOMBIE]; | |
267 | } else if(process->state->s == LTTV_STATE_WAIT_FORK) { | |
268 | prop_line.color = drawing_colors[COL_WAIT_FORK]; | |
269 | } else if(process->state->s == LTTV_STATE_EXIT) { | |
270 | prop_line.color = drawing_colors[COL_EXIT]; | |
271 | } else if(process->state->s == LTTV_STATE_UNNAMED) { | |
272 | prop_line.color = drawing_colors[COL_UNNAMED]; | |
c7620c79 | 273 | } else if(process->state->s == LTTV_STATE_DEAD) { |
274 | prop_line.color = drawing_colors[COL_DEAD]; | |
b3fd4c02 | 275 | } else { |
276 | g_critical("unknown state : %s", g_quark_to_string(process->state->s)); | |
9a1ec01b | 277 | g_assert(FALSE); /* UNKNOWN STATE */ |
b3fd4c02 | 278 | } |
9a1ec01b | 279 | |
280 | return prop_line; | |
281 | ||
282 | } | |
283 | ||
98dfb302 YB |
284 | HashedProcessData *get_hashed_process_data(ControlFlowData *control_flow_data, |
285 | LttvProcessState *process, | |
286 | guint pid, | |
287 | guint trace_num) | |
288 | { | |
289 | HashedProcessData *hashed_process_data = NULL; | |
290 | ProcessList *process_list = control_flow_data->process_list; | |
291 | LttTime birth = process->creation_time; | |
292 | guint pl_height = 0; | |
293 | ||
294 | hashed_process_data = processlist_get_process_data(process_list, | |
295 | pid, | |
296 | process->cpu, | |
297 | &birth, | |
298 | trace_num); | |
299 | if(hashed_process_data == NULL) | |
300 | { | |
301 | g_assert(pid == 0 || pid != process->ppid); | |
302 | ProcessInfo *process_info; | |
303 | Drawing_t *drawing = control_flow_data->drawing; | |
304 | /* Process not present */ | |
305 | processlist_add(process_list, | |
306 | drawing, | |
307 | pid, | |
308 | process->tgid, | |
309 | process->cpu, | |
310 | process->ppid, | |
311 | &birth, | |
312 | trace_num, | |
313 | process->name, | |
314 | process->brand, | |
315 | &pl_height, | |
316 | &process_info, | |
317 | &hashed_process_data); | |
318 | gtk_widget_set_size_request(drawing->drawing_area, | |
319 | -1, | |
320 | pl_height); | |
321 | gtk_widget_queue_draw(drawing->drawing_area); | |
322 | } | |
323 | return hashed_process_data; | |
324 | } | |
325 | ||
326 | void init_drawing_context(DrawContext *draw_context, | |
327 | HashedProcessData *hashed_process_data, | |
328 | Drawing_t *drawing, | |
329 | guint x | |
330 | ) | |
331 | { | |
332 | draw_context->drawable = hashed_process_data->pixmap; | |
333 | draw_context->gc = drawing->gc; | |
334 | draw_context->pango_layout = drawing->pango_layout; | |
335 | draw_context->drawinfo.start.x = hashed_process_data->x.middle; | |
336 | draw_context->drawinfo.end.x = x; | |
337 | ||
338 | draw_context->drawinfo.y.over = 1; | |
339 | draw_context->drawinfo.y.middle = (hashed_process_data->height/2); | |
340 | draw_context->drawinfo.y.under = hashed_process_data->height; | |
341 | ||
342 | draw_context->drawinfo.start.offset.over = 0; | |
343 | draw_context->drawinfo.start.offset.middle = 0; | |
344 | draw_context->drawinfo.start.offset.under = 0; | |
345 | draw_context->drawinfo.end.offset.over = 0; | |
346 | draw_context->drawinfo.end.offset.middle = 0; | |
347 | draw_context->drawinfo.end.offset.under = 0; | |
348 | ||
349 | } | |
350 | ||
351 | void draw_state_line(HashedProcessData *hashed_process_data, | |
352 | LttvProcessState *process, | |
353 | Drawing_t *drawing, | |
354 | guint x, | |
355 | TimeWindow time_window) | |
356 | { | |
357 | DrawContext draw_context; | |
358 | guint width = drawing->width; | |
359 | ||
360 | init_drawing_context(&draw_context, | |
361 | hashed_process_data, | |
362 | drawing, | |
363 | x); | |
364 | ||
365 | ||
366 | /* Draw the line */ | |
367 | PropertiesLine prop_line = prepare_s_e_line(process); | |
368 | draw_line((void*)&prop_line, (void*)&draw_context); | |
369 | ||
370 | /* become the last x position */ | |
371 | hashed_process_data->x.middle = x; | |
372 | hashed_process_data->x.middle_used = TRUE; | |
373 | hashed_process_data->x.middle_marked = FALSE; | |
374 | ||
375 | /* Calculate the next good time */ | |
376 | convert_pixels_to_time(width, x+1, time_window, | |
377 | &hashed_process_data->next_good_time); | |
378 | } | |
379 | ||
380 | ||
381 | void draw_state_items(ControlFlowData *control_flow_data, | |
382 | HashedProcessData *hashed_process_data, | |
383 | LttvProcessState *process, | |
384 | LttTime evtime ) | |
385 | { | |
386 | ||
387 | ||
388 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, | |
389 | evtime) > 0)) | |
390 | { | |
391 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
392 | TimeWindow time_window = | |
393 | lttvwindow_get_time_window(control_flow_data->tab); | |
394 | ||
395 | #ifdef EXTRA_CHECK | |
396 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
397 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
398 | return FALSE; | |
399 | #endif //EXTRA_CHECK | |
400 | Drawing_t *drawing = control_flow_data->drawing; | |
401 | guint width = drawing->width; | |
402 | guint x; | |
403 | convert_time_to_pixels( | |
404 | time_window, | |
405 | evtime, | |
406 | width, | |
407 | &x); | |
408 | ||
409 | /* Draw collision indicator */ | |
410 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
411 | gdk_draw_point(hashed_process_data->pixmap, | |
412 | drawing->gc, | |
413 | x, | |
414 | COLLISION_POSITION(hashed_process_data->height)); | |
415 | hashed_process_data->x.middle_marked = TRUE; | |
416 | } | |
417 | } else { | |
418 | TimeWindow time_window = | |
419 | lttvwindow_get_time_window(control_flow_data->tab); | |
420 | ||
421 | #ifdef EXTRA_CHECK | |
422 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
423 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
424 | return FALSE; | |
425 | #endif //EXTRA_CHECK | |
426 | Drawing_t *drawing = control_flow_data->drawing; | |
427 | guint width = drawing->width; | |
428 | guint x; | |
429 | ||
430 | convert_time_to_pixels( | |
431 | time_window, | |
432 | evtime, | |
433 | width, | |
434 | &x); | |
435 | ||
436 | ||
437 | /* Jump over draw if we are at the same x position */ | |
438 | if(unlikely(x == hashed_process_data->x.middle && | |
439 | hashed_process_data->x.middle_used)) | |
440 | { | |
441 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { | |
442 | /* Draw collision indicator */ | |
443 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
444 | gdk_draw_point(hashed_process_data->pixmap, | |
445 | drawing->gc, | |
446 | x, | |
447 | COLLISION_POSITION(hashed_process_data->height)); | |
448 | hashed_process_data->x.middle_marked = TRUE; | |
449 | } | |
450 | /* jump */ | |
451 | } else { | |
452 | ||
453 | draw_state_line(hashed_process_data, | |
454 | process, | |
455 | drawing, | |
456 | x, | |
457 | time_window); | |
458 | } | |
459 | } | |
460 | } | |
461 | ||
462 | ||
068572ab CS |
463 | /* Before try-wake-up hook. A process is being woken; we need to draw its line up to this point in time |
464 | in that colour. This is basically like exec-state, but the change applies to a process other than that | |
465 | which is currently running. */ | |
466 | ||
467 | int before_trywakeup_hook(void *hook_data, void *call_data) | |
468 | { | |
88bf15f0 | 469 | |
7b20eed1 | 470 | LttvEvent *event; |
068572ab | 471 | |
7b20eed1 YB |
472 | event = (LttvEvent *) call_data; |
473 | if (strcmp(lttv_traceset_get_name_from_event(event),"sched_wakeup") != 0) | |
474 | return FALSE; | |
068572ab | 475 | |
7b20eed1 | 476 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
068572ab | 477 | |
7b20eed1 | 478 | LttvTraceState *ts = event->state;; |
068572ab | 479 | |
7b20eed1 YB |
480 | |
481 | LttTime evtime = lttv_event_get_timestamp(event); | |
482 | #ifdef BABEL_CLEANUP | |
068572ab | 483 | LttvFilter *filter = control_flow_data->filter; |
7b20eed1 | 484 | #endif |
068572ab CS |
485 | |
486 | guint woken_pid; | |
487 | gint woken_cpu; | |
488 | ||
7b20eed1 YB |
489 | woken_pid = lttv_event_get_long(event, "tid"); |
490 | woken_cpu = lttv_event_get_long(event, "target_cpu"); | |
491 | ||
492 | #ifdef BABEL_CLEANUP | |
068572ab CS |
493 | if(!filter || !filter->head || |
494 | lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
495 | tfc->t_context->t,tfc,NULL,NULL)) { | |
7b20eed1 YB |
496 | #else |
497 | { | |
498 | #endif | |
068572ab CS |
499 | /* First, check if the woken process is in the state computation |
500 | * process list. If it is there, that means we must add it right now and | |
501 | * draw items from the beginning of the read for it. If it is not | |
502 | * present, it's a new process and it was not present : it will | |
503 | * be added after the state update. TOCHECK: What does that last para mean? */ | |
7b20eed1 YB |
504 | guint trace_num = 0; /*TODO ybrosseau 2012-08-23: use right number */ |
505 | LttvProcessState *process = lttv_state_find_process(ts, woken_cpu, woken_pid); | |
068572ab CS |
506 | |
507 | if(process != NULL) { | |
508 | /* Well, the woken process existed : we must get it in the process hash | |
509 | * or add it, and draw its items. | |
510 | */ | |
511 | /* Add process to process list (if not present) */ | |
068572ab | 512 | |
98dfb302 | 513 | HashedProcessData *hashed_process_data = get_hashed_process_data(control_flow_data, process, woken_pid, trace_num); |
068572ab CS |
514 | |
515 | /* Now, the process is in the state hash and our own process hash. | |
516 | * We definitely can draw the items related to the ending state. | |
517 | */ | |
068572ab | 518 | |
98dfb302 YB |
519 | draw_state_items(control_flow_data, |
520 | hashed_process_data, | |
521 | process, | |
522 | evtime ); | |
068572ab | 523 | |
068572ab CS |
524 | } |
525 | } | |
526 | ||
068572ab | 527 | |
7b20eed1 YB |
528 | |
529 | ||
10599fb9 | 530 | return 0; |
068572ab CS |
531 | |
532 | } | |
c8bba5fa | 533 | |
e92eabaf | 534 | /* before_schedchange_hook |
b9a010a2 | 535 | * |
f0d936c0 | 536 | * This function basically draw lines and icons. Two types of lines are drawn : |
537 | * one small (3 pixels?) representing the state of the process and the second | |
538 | * type is thicker (10 pixels?) representing on which CPU a process is running | |
539 | * (and this only in running state). | |
540 | * | |
541 | * Extremums of the lines : | |
542 | * x_min : time of the last event context for this process kept in memory. | |
543 | * x_max : time of the current event. | |
544 | * y : middle of the process in the process list. The process is found in the | |
545 | * list, therefore is it's position in pixels. | |
546 | * | |
547 | * The choice of lines'color is defined by the context of the last event for this | |
548 | * process. | |
549 | */ | |
b9a010a2 | 550 | |
551 | ||
e92eabaf | 552 | int before_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 | 553 | { |
88bf15f0 FD |
554 | LttvEvent *event; |
555 | guint cpu; | |
556 | LttvTraceState *ts; | |
557 | LttvProcessState *process; | |
558 | ||
559 | //LttvProcessState *old_process = ts->running_process[cpu]; | |
560 | ||
561 | guint pid_in, pid_out; | |
562 | gint64 state_out; | |
98dfb302 | 563 | LttTime evtime; |
88bf15f0 | 564 | event = (LttvEvent *) call_data; |
8924e3e4 FD |
565 | if (strcmp(lttv_traceset_get_name_from_event(event),"sched_switch") != 0) |
566 | return FALSE; | |
567 | ||
88bf15f0 | 568 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
b9a010a2 | 569 | |
fd22065b | 570 | |
10a1069a | 571 | /* we are in a schedchange, before the state update. We must draw the |
572 | * items corresponding to the state before it changes : now is the right | |
573 | * time to do it. | |
574 | */ | |
88bf15f0 FD |
575 | cpu = lttv_traceset_get_cpuid_from_event(event); |
576 | ts = event->state; | |
8924e3e4 | 577 | |
88bf15f0 FD |
578 | pid_out = lttv_event_get_long(event, "prev_tid"); |
579 | pid_in = lttv_event_get_long(event, "next_tid"); | |
580 | state_out = lttv_event_get_long(event, "prev_state"); | |
8924e3e4 | 581 | guint trace_number = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number |
88bf15f0 | 582 | |
8924e3e4 | 583 | process = lttv_state_find_process(ts,cpu,pid_out); |
98dfb302 | 584 | evtime = lttv_event_get_timestamp(event); |
10a1069a | 585 | /* For the pid_out */ |
586 | /* First, check if the current process is in the state computation | |
587 | * process list. If it is there, that means we must add it right now and | |
588 | * draw items from the beginning of the read for it. If it is not | |
589 | * present, it's a new process and it was not present : it will | |
590 | * be added after the state update. */ | |
b9a010a2 | 591 | |
88bf15f0 FD |
592 | /* unknown state, bad current pid */ |
593 | ||
10a1069a | 594 | if(process != NULL) { |
595 | /* Well, the process_out existed : we must get it in the process hash | |
596 | * or add it, and draw its items. | |
597 | */ | |
598 | /* Add process to process list (if not present) */ | |
1c736ed5 | 599 | |
98dfb302 YB |
600 | HashedProcessData *hashed_process_data = get_hashed_process_data(control_flow_data, process, pid_out, trace_number); |
601 | ||
10a1069a | 602 | /* Now, the process is in the state hash and our own process hash. |
603 | * We definitely can draw the items related to the ending state. | |
604 | */ | |
e800cf84 | 605 | |
98dfb302 YB |
606 | draw_state_items(control_flow_data, |
607 | hashed_process_data, | |
608 | process, | |
609 | evtime ); | |
e800cf84 | 610 | } |
611 | ||
10a1069a | 612 | /* For the pid_in */ |
613 | /* First, check if the current process is in the state computation | |
614 | * process list. If it is there, that means we must add it right now and | |
615 | * draw items from the beginning of the read for it. If it is not | |
616 | * present, it's a new process and it was not present : it will | |
617 | * be added after the state update. */ | |
8924e3e4 | 618 | process = lttv_state_find_process(ts,cpu,pid_in); |
10a1069a | 619 | |
620 | if(process != NULL) { | |
800aa029 | 621 | /* Well, the process existed : we must get it in the process hash |
10a1069a | 622 | * or add it, and draw its items. |
623 | */ | |
624 | /* Add process to process list (if not present) */ | |
1c736ed5 | 625 | |
98dfb302 YB |
626 | HashedProcessData *hashed_process_data = get_hashed_process_data(control_flow_data, process, pid_in, trace_number); |
627 | ||
40debf7b | 628 | //We could set the current process and hash here, but will be done |
629 | //by after schedchange hook | |
10a1069a | 630 | |
631 | /* Now, the process is in the state hash and our own process hash. | |
632 | * We definitely can draw the items related to the ending state. | |
633 | */ | |
98dfb302 YB |
634 | draw_state_items(control_flow_data, |
635 | hashed_process_data, | |
636 | process, | |
637 | evtime ); | |
10a1069a | 638 | |
8e680509 | 639 | } else |
640 | g_warning("Cannot find pin_in in schedchange %u", pid_in); | |
88bf15f0 | 641 | #ifdef BABEL_CLEANUP |
e38d9ea0 | 642 | tfc->target_pid = target_pid_saved; |
88bf15f0 | 643 | #endif //babel_cleanup |
b9a010a2 | 644 | return 0; |
645 | ||
646 | ||
b9a010a2 | 647 | |
a56a1ba4 | 648 | |
51705146 | 649 | /* Text dump */ |
80a52ff8 | 650 | #ifdef DONTSHOW |
a56a1ba4 | 651 | GString *string = g_string_new("");; |
652 | gboolean field_names = TRUE, state = TRUE; | |
80a52ff8 | 653 | |
e9a9c513 | 654 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
655 | g_string_append_printf(string,"\n"); | |
656 | ||
657 | if(state) { | |
658 | g_string_append_printf(string, " %s", | |
659 | g_quark_to_string(tfs->process->state->s)); | |
660 | } | |
661 | ||
662 | g_info("%s",string->str); | |
663 | ||
a56a1ba4 | 664 | g_string_free(string, TRUE); |
665 | ||
666 | /* End of text dump */ | |
80a52ff8 | 667 | #endif //DONTSHOW |
50439712 | 668 | |
f0d936c0 | 669 | } |
670 | ||
e92eabaf | 671 | /* after_schedchange_hook |
b9a010a2 | 672 | * |
673 | * The draw after hook is called by the reading API to have a | |
674 | * particular event drawn on the screen. | |
675 | * @param hook_data ControlFlowData structure of the viewer. | |
676 | * @param call_data Event context. | |
677 | * | |
678 | * This function adds items to be drawn in a queue for each process. | |
679 | * | |
680 | */ | |
e92eabaf | 681 | int after_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 | 682 | { |
7b20eed1 | 683 | LttvEvent *event; |
50439712 | 684 | |
7b20eed1 YB |
685 | event = (LttvEvent *) call_data; |
686 | ||
687 | if (strcmp(lttv_traceset_get_name_from_event(event),"sched_switch") != 0) | |
688 | return FALSE; | |
50439712 | 689 | |
7b20eed1 | 690 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
50439712 | 691 | |
348c6ba8 | 692 | |
7b20eed1 | 693 | LttvTraceState *ts = event->state; |
b9a010a2 | 694 | |
7b20eed1 | 695 | #ifdef BABEL_CLEANUP |
e38d9ea0 | 696 | LttvFilter *filter = control_flow_data->filter; |
7b20eed1 YB |
697 | #endif |
698 | LttTime evtime = lttv_event_get_timestamp(event); | |
b9a010a2 | 699 | |
10a1069a | 700 | /* Add process to process list (if not present) */ |
2eef04b5 | 701 | LttvProcessState *process_in; |
10a1069a | 702 | HashedProcessData *hashed_process_data_in = NULL; |
b9a010a2 | 703 | |
5c230fc4 | 704 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a | 705 | |
706 | guint pid_in; | |
707 | { | |
7b20eed1 | 708 | pid_in = lttv_event_get_long(event, "next_tid"); |
10a1069a | 709 | } |
b9a010a2 | 710 | |
7b20eed1 | 711 | #ifdef BABEL_CLEANUP |
c7620c79 | 712 | if(!filter || !filter->head || |
713 | lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
714 | tfc->t_context->t,tfc,NULL,NULL)) { | |
7b20eed1 YB |
715 | #else |
716 | { | |
717 | #endif | |
c7620c79 | 718 | /* Find process pid_in in the list... */ |
719 | //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in); | |
720 | //process_in = tfs->process; | |
7b20eed1 YB |
721 | guint cpu = lttv_traceset_get_cpuid_from_event(event); |
722 | guint trace_num = 0; /* TODO set right trace number */ | |
c7620c79 | 723 | process_in = ts->running_process[cpu]; |
724 | /* It should exist, because we are after the state update. */ | |
96947fcf | 725 | #ifdef EXTRA_CHECK |
c7620c79 | 726 | g_assert(process_in != NULL); |
96947fcf | 727 | #endif //EXTRA_CHECK |
98dfb302 YB |
728 | hashed_process_data_in = get_hashed_process_data(control_flow_data, process_in, pid_in, trace_num); |
729 | ||
c7620c79 | 730 | /* Set the current process */ |
731 | process_list->current_hash_data[trace_num][process_in->cpu] = | |
732 | hashed_process_data_in; | |
733 | ||
734 | if(ltt_time_compare(hashed_process_data_in->next_good_time, | |
735 | evtime) <= 0) | |
736 | { | |
737 | TimeWindow time_window = | |
738 | lttvwindow_get_time_window(control_flow_data->tab); | |
739 | ||
fd22065b | 740 | #ifdef EXTRA_CHECK |
c7620c79 | 741 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
742 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
743 | return FALSE; | |
fd22065b | 744 | #endif //EXTRA_CHECK |
c7620c79 | 745 | Drawing_t *drawing = control_flow_data->drawing; |
746 | guint width = drawing->width; | |
747 | guint new_x; | |
748 | ||
749 | convert_time_to_pixels( | |
750 | time_window, | |
751 | evtime, | |
752 | width, | |
753 | &new_x); | |
754 | ||
755 | if(hashed_process_data_in->x.middle != new_x) { | |
756 | hashed_process_data_in->x.middle = new_x; | |
757 | hashed_process_data_in->x.middle_used = FALSE; | |
758 | hashed_process_data_in->x.middle_marked = FALSE; | |
759 | } | |
b2743953 | 760 | } |
761 | } | |
c7620c79 | 762 | |
10599fb9 | 763 | return 0; |
4a24fa1f | 764 | } |
b9a010a2 | 765 | |
766 | ||
767 | ||
e72908ed | 768 | |
4a24fa1f | 769 | /* before_execmode_hook |
770 | * | |
771 | * This function basically draw lines and icons. Two types of lines are drawn : | |
772 | * one small (3 pixels?) representing the state of the process and the second | |
773 | * type is thicker (10 pixels?) representing on which CPU a process is running | |
774 | * (and this only in running state). | |
775 | * | |
776 | * Extremums of the lines : | |
777 | * x_min : time of the last event context for this process kept in memory. | |
778 | * x_max : time of the current event. | |
779 | * y : middle of the process in the process list. The process is found in the | |
780 | * list, therefore is it's position in pixels. | |
781 | * | |
782 | * The choice of lines'color is defined by the context of the last event for this | |
783 | * process. | |
784 | */ | |
785 | ||
e72908ed | 786 | |
4a24fa1f | 787 | int before_execmode_hook(void *hook_data, void *call_data) |
788 | { | |
88bf15f0 FD |
789 | LttvEvent *event; |
790 | guint cpu; | |
10599fb9 | 791 | guint pid = 0; |
88bf15f0 FD |
792 | LttvTraceState *ts; |
793 | LttvProcessState *process; | |
794 | ||
4a24fa1f | 795 | /* we are in a execmode, before the state update. We must draw the |
796 | * items corresponding to the state before it changes : now is the right | |
797 | * time to do it. | |
798 | */ | |
88bf15f0 FD |
799 | |
800 | event = (LttvEvent *) call_data; | |
8924e3e4 FD |
801 | if ((strncmp(lttv_traceset_get_name_from_event(event),"sys_", sizeof("sys_") - 1) == 0) |
802 | ||(strcmp(lttv_traceset_get_name_from_event(event),"exit_syscall") == 0) | |
803 | ||(strncmp(lttv_traceset_get_name_from_event(event),"irq_handler_",sizeof("irq_handler_")) == 0) | |
98dfb302 | 804 | ||(strncmp(lttv_traceset_get_name_from_event(event),"softirq_", sizeof("softirq_")) == 0)) { |
8924e3e4 | 805 | |
88bf15f0 FD |
806 | LttTime evtime = lttv_event_get_timestamp(event); |
807 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; | |
4a24fa1f | 808 | /* For the pid */ |
88bf15f0 FD |
809 | LttvTraceset *traceSet = lttvwindow_get_traceset(control_flow_data->tab); |
810 | ||
811 | cpu = lttv_traceset_get_cpuid_from_event(event); | |
812 | ts = event->state; | |
813 | ||
814 | guint trace_number = 0;//TODO fdeslauriers 2012-07-17: // Use trace handle to know trace number | |
8924e3e4 | 815 | process = lttv_state_find_process(ts ,cpu ,pid); |
4a24fa1f | 816 | g_assert(process != NULL); |
23093869 | 817 | |
10a1069a | 818 | guint pid = process->pid; |
23093869 | 819 | |
10a1069a | 820 | /* Well, the process_out existed : we must get it in the process hash |
821 | * or add it, and draw its items. | |
822 | */ | |
823 | /* Add process to process list (if not present) */ | |
10a1069a | 824 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 | 825 | ProcessList *process_list = control_flow_data->process_list; |
88bf15f0 FD |
826 | if(process_list->current_hash_data == NULL){//TODO fdeslauriers 2012-07-17 : should not be necessary |
827 | return 0; | |
828 | } | |
829 | ||
88bf15f0 FD |
830 | if(likely(process_list->current_hash_data[trace_number][cpu] != NULL)) { |
831 | hashed_process_data = process_list->current_hash_data[trace_number][cpu]; | |
40debf7b | 832 | } else { |
98dfb302 YB |
833 | hashed_process_data = get_hashed_process_data(control_flow_data, |
834 | process, pid, trace_number); | |
835 | ||
40debf7b | 836 | /* Set the current process */ |
88bf15f0 | 837 | process_list->current_hash_data[trace_number][process->cpu] = |
40debf7b | 838 | hashed_process_data; |
10a1069a | 839 | } |
23093869 | 840 | |
10a1069a | 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 | */ | |
98dfb302 YB |
844 | |
845 | draw_state_items(control_flow_data, | |
846 | hashed_process_data, | |
847 | process, | |
848 | evtime ); | |
8924e3e4 | 849 | } |
98dfb302 | 850 | |
23093869 | 851 | return 0; |
98dfb302 | 852 | |
23093869 | 853 | } |
854 | ||
4a24fa1f | 855 | /* before_process_exit_hook |
23093869 | 856 | * |
4a24fa1f | 857 | * Draw lines for process event. |
858 | * | |
23093869 | 859 | * @param hook_data ControlFlowData structure of the viewer. |
860 | * @param call_data Event context. | |
861 | * | |
862 | * This function adds items to be drawn in a queue for each process. | |
863 | * | |
864 | */ | |
8869ac08 | 865 | |
866 | ||
4a24fa1f | 867 | int before_process_exit_hook(void *hook_data, void *call_data) |
868 | { | |
23093869 | 869 | |
7b20eed1 | 870 | LttvEvent *event; |
23093869 | 871 | |
7b20eed1 YB |
872 | event = (LttvEvent *) call_data; |
873 | if (strcmp(lttv_traceset_get_name_from_event(event), | |
874 | "sched_process_exit") != 0) | |
875 | return FALSE; | |
4a24fa1f | 876 | |
7b20eed1 YB |
877 | |
878 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; | |
879 | LttvTraceState *ts = event->state; | |
23093869 | 880 | |
7b20eed1 | 881 | #ifdef BABEL_CLEANUP |
e38d9ea0 | 882 | LttvFilter *filter = control_flow_data->filter; |
883 | if(filter != NULL && filter->head != NULL) | |
98dfb302 YB |
884 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
885 | tfc->t_context->t,tfc,NULL,NULL)) | |
886 | return FALSE; | |
887 | #endif | |
dbd243b1 | 888 | |
98dfb302 | 889 | LttTime evtime = lttv_event_get_timestamp(event); |
dbd243b1 | 890 | |
98dfb302 YB |
891 | /* Add process to process list (if not present) */ |
892 | //LttvProcessState *process = tfs->process; | |
893 | guint cpu = lttv_traceset_get_cpuid_from_event(event); | |
894 | guint trace_num = 0; /* TODO set right trace number */ | |
dbd243b1 | 895 | |
98dfb302 YB |
896 | LttvProcessState *process = ts->running_process[cpu]; |
897 | guint pid = process->pid; | |
898 | HashedProcessData *hashed_process_data = NULL; | |
899 | ||
900 | ProcessList *process_list = control_flow_data->process_list; | |
901 | ||
902 | g_assert(process != NULL); | |
903 | ||
904 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { | |
905 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; | |
906 | } else { | |
907 | hashed_process_data = get_hashed_process_data(control_flow_data, | |
908 | process, pid, trace_num); | |
2c82c4dc | 909 | } |
7b20eed1 | 910 | |
98dfb302 YB |
911 | /* Now, the process is in the state hash and our own process hash. |
912 | * We definitely can draw the items related to the ending state. | |
913 | */ | |
914 | ||
915 | draw_state_items(control_flow_data, | |
916 | hashed_process_data, | |
917 | process, | |
918 | evtime); | |
919 | ||
10599fb9 | 920 | return 0; |
2c82c4dc | 921 | |
922 | } | |
923 | ||
924 | ||
925 | ||
926 | /* before_process_release_hook | |
927 | * | |
928 | * Draw lines for process event. | |
929 | * | |
930 | * @param hook_data ControlFlowData structure of the viewer. | |
931 | * @param call_data Event context. | |
932 | * | |
933 | * This function adds items to be drawn in a queue for each process. | |
934 | * | |
935 | */ | |
936 | ||
937 | ||
938 | int before_process_release_hook(void *hook_data, void *call_data) | |
939 | { | |
2c82c4dc | 940 | |
7b20eed1 | 941 | LttvEvent *event; |
2c82c4dc | 942 | |
7b20eed1 YB |
943 | event = (LttvEvent *) call_data; |
944 | ||
945 | if (strcmp(lttv_traceset_get_name_from_event(event),"sched_process_free") != 0) | |
946 | return FALSE; | |
2c82c4dc | 947 | |
7b20eed1 | 948 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
348c6ba8 | 949 | |
2c82c4dc | 950 | |
7b20eed1 YB |
951 | LttvTraceState *ts = event->state; |
952 | ||
953 | #ifdef BABEL_CLEANUP | |
e38d9ea0 | 954 | LttvFilter *filter = control_flow_data->filter; |
955 | if(filter != NULL && filter->head != NULL) | |
956 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
b6ef18af | 957 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 | 958 | return FALSE; |
7b20eed1 YB |
959 | #endif |
960 | LttTime evtime = lttv_event_get_timestamp(event); | |
e38d9ea0 | 961 | |
2c82c4dc | 962 | |
7b20eed1 | 963 | guint trace_num = 0; /* TODO set right trace number */ |
2c82c4dc | 964 | |
965 | guint pid; | |
966 | { | |
7b20eed1 | 967 | pid = lttv_event_get_long(event, "tid"); |
2c82c4dc | 968 | } |
969 | ||
970 | /* Add process to process list (if not present) */ | |
971 | /* Don't care about the process if it's not in the state hash already : | |
972 | * that means a process that has never done anything in the trace and | |
973 | * unknown suddently gets destroyed : no state meaningful to show. */ | |
348c6ba8 | 974 | LttvProcessState *process = lttv_state_find_process(ts, ANY_CPU, pid); |
2c82c4dc | 975 | |
976 | if(process != NULL) { | |
977 | LttTime birth; | |
2c82c4dc | 978 | HashedProcessData *hashed_process_data = NULL; |
979 | ||
980 | ProcessList *process_list = control_flow_data->process_list; | |
981 | ||
982 | birth = process->creation_time; | |
983 | ||
984 | /* Cannot use current process : this event happens on another process, | |
985 | * action done by the parent. */ | |
986 | hashed_process_data = processlist_get_process_data(process_list, | |
987 | pid, | |
348c6ba8 | 988 | process->cpu, |
2c82c4dc | 989 | &birth, |
0f090e21 | 990 | trace_num); |
2c82c4dc | 991 | if(unlikely(hashed_process_data == NULL)) |
3311444c | 992 | /* |
993 | * Process already been scheduled out EXIT_DEAD, not in the process list | |
994 | * anymore. Just return. | |
995 | */ | |
996 | return FALSE; | |
2c82c4dc | 997 | |
998 | /* Now, the process is in the state hash and our own process hash. | |
999 | * We definitely can draw the items related to the ending state. | |
1000 | */ | |
1001 | ||
98dfb302 YB |
1002 | draw_state_items(control_flow_data, |
1003 | hashed_process_data, | |
1004 | process, | |
1005 | evtime); | |
dbd243b1 | 1006 | } |
10599fb9 | 1007 | return 0; |
dbd243b1 | 1008 | } |
1009 | ||
4a24fa1f | 1010 | |
2c82c4dc | 1011 | |
1012 | ||
1013 | ||
1014 | /* after_process_fork_hook | |
1015 | * | |
1016 | * Create the processlist entry for the child process. Put the last | |
1017 | * position in x at the current time value. | |
1018 | * | |
1019 | * @param hook_data ControlFlowData structure of the viewer. | |
1020 | * @param call_data Event context. | |
1021 | * | |
1022 | * This function adds items to be drawn in a queue for each process. | |
1023 | * | |
1024 | */ | |
1025 | int after_process_fork_hook(void *hook_data, void *call_data) | |
1026 | { | |
7b20eed1 | 1027 | LttvEvent *event; |
2c82c4dc | 1028 | |
7b20eed1 YB |
1029 | event = (LttvEvent *) call_data; |
1030 | ||
1031 | if (strcmp(lttv_traceset_get_name_from_event(event),"sched_process_fork") != 0) | |
1032 | return FALSE; | |
2c82c4dc | 1033 | |
7b20eed1 | 1034 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
348c6ba8 | 1035 | |
2c82c4dc | 1036 | |
7b20eed1 YB |
1037 | LttvTraceState *ts = event->state; |
1038 | ||
1039 | #ifdef BABEL_CLEANUP | |
e38d9ea0 | 1040 | LttvFilter *filter = control_flow_data->filter; |
1041 | if(filter != NULL && filter->head != NULL) | |
1042 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
b6ef18af | 1043 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 | 1044 | return FALSE; |
7b20eed1 | 1045 | #endif |
e38d9ea0 | 1046 | |
7b20eed1 | 1047 | LttTime evtime = lttv_event_get_timestamp(event); |
2c82c4dc | 1048 | |
1049 | guint child_pid; | |
1050 | { | |
7b20eed1 | 1051 | child_pid = lttv_event_get_long(event, "child_tid"); |
2c82c4dc | 1052 | } |
1053 | ||
1054 | /* Add process to process list (if not present) */ | |
1055 | LttvProcessState *process_child; | |
2c82c4dc | 1056 | HashedProcessData *hashed_process_data_child = NULL; |
1057 | ||
1058 | ProcessList *process_list = control_flow_data->process_list; | |
1059 | ||
1060 | /* Find child in the list... */ | |
348c6ba8 | 1061 | process_child = lttv_state_find_process(ts, ANY_CPU, child_pid); |
2c82c4dc | 1062 | /* It should exist, because we are after the state update. */ |
1063 | g_assert(process_child != NULL); | |
1064 | ||
7b20eed1 | 1065 | guint trace_num = 0; /* TODO put right */ |
2c82c4dc | 1066 | |
1067 | /* Cannot use current process, because this action is done by the parent | |
1068 | * on its child. */ | |
98dfb302 YB |
1069 | hashed_process_data_child = get_hashed_process_data(control_flow_data, |
1070 | process_child, child_pid, trace_num); | |
1071 | ||
1072 | ||
fcc08e1e | 1073 | processlist_set_ppid(process_list, process_child->ppid, |
1074 | hashed_process_data_child); | |
1075 | processlist_set_tgid(process_list, process_child->tgid, | |
1076 | hashed_process_data_child); | |
98dfb302 | 1077 | |
2c82c4dc | 1078 | |
1079 | ||
1080 | if(likely(ltt_time_compare(hashed_process_data_child->next_good_time, | |
1081 | evtime) <= 0)) | |
1082 | { | |
1083 | TimeWindow time_window = | |
1084 | lttvwindow_get_time_window(control_flow_data->tab); | |
1085 | ||
1086 | #ifdef EXTRA_CHECK | |
1087 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1088 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
3311444c | 1089 | return FALSE; |
2c82c4dc | 1090 | #endif //EXTRA_CHECK |
1091 | Drawing_t *drawing = control_flow_data->drawing; | |
1092 | guint width = drawing->width; | |
1093 | guint new_x; | |
1094 | convert_time_to_pixels( | |
1095 | time_window, | |
1096 | evtime, | |
1097 | width, | |
1098 | &new_x); | |
1099 | ||
1100 | if(likely(hashed_process_data_child->x.over != new_x)) { | |
1101 | hashed_process_data_child->x.over = new_x; | |
1102 | hashed_process_data_child->x.over_used = FALSE; | |
1103 | hashed_process_data_child->x.over_marked = FALSE; | |
1104 | } | |
1105 | if(likely(hashed_process_data_child->x.middle != new_x)) { | |
1106 | hashed_process_data_child->x.middle = new_x; | |
1107 | hashed_process_data_child->x.middle_used = FALSE; | |
1108 | hashed_process_data_child->x.middle_marked = FALSE; | |
1109 | } | |
1110 | if(likely(hashed_process_data_child->x.under != new_x)) { | |
1111 | hashed_process_data_child->x.under = new_x; | |
1112 | hashed_process_data_child->x.under_used = FALSE; | |
1113 | hashed_process_data_child->x.under_marked = FALSE; | |
1114 | } | |
1115 | } | |
10599fb9 | 1116 | return FALSE; |
2c82c4dc | 1117 | } |
1118 | ||
1119 | ||
1120 | ||
1121 | /* after_process_exit_hook | |
1122 | * | |
1123 | * Create the processlist entry for the child process. Put the last | |
1124 | * position in x at the current time value. | |
1125 | * | |
1126 | * @param hook_data ControlFlowData structure of the viewer. | |
1127 | * @param call_data Event context. | |
1128 | * | |
1129 | * This function adds items to be drawn in a queue for each process. | |
1130 | * | |
1131 | */ | |
1132 | int after_process_exit_hook(void *hook_data, void *call_data) | |
1133 | { | |
7b20eed1 YB |
1134 | #if 0 |
1135 | LttvEvent *event; | |
2c82c4dc | 1136 | |
7b20eed1 YB |
1137 | event = (LttvEvent *) call_data; |
1138 | ||
1139 | if (strcmp(lttv_traceset_get_name_from_event(event),"sched_process_exit") != 0) | |
1140 | return FALSE; | |
2c82c4dc | 1141 | |
7b20eed1 | 1142 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
348c6ba8 | 1143 | |
7b20eed1 | 1144 | LttvTraceState *ts = event->state; |
2c82c4dc | 1145 | |
7b20eed1 | 1146 | #ifdef BABEL_CLEANUP |
e38d9ea0 | 1147 | LttvFilter *filter = control_flow_data->filter; |
1148 | if(filter != NULL && filter->head != NULL) | |
1149 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
b6ef18af | 1150 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 | 1151 | return FALSE; |
7b20eed1 | 1152 | #endif |
e38d9ea0 | 1153 | |
7b20eed1 | 1154 | LttTime evtime = lttv_event_get_timestamp(event); |
2c82c4dc | 1155 | |
1156 | /* Add process to process list (if not present) */ | |
348c6ba8 | 1157 | //LttvProcessState *process = tfs->process; |
7b20eed1 YB |
1158 | guint cpu = lttv_traceset_get_cpuid_from_event(event); |
1159 | guint trace_num = 0; /* TODO set right trace number */ | |
348c6ba8 | 1160 | LttvProcessState *process = ts->running_process[cpu]; |
1161 | ||
1162 | /* It should exist, because we are after the state update. */ | |
1163 | g_assert(process != NULL); | |
1164 | ||
2c82c4dc | 1165 | guint pid = process->pid; |
1166 | LttTime birth; | |
1167 | guint pl_height = 0; | |
1168 | HashedProcessData *hashed_process_data = NULL; | |
1169 | ||
1170 | ProcessList *process_list = control_flow_data->process_list; | |
1171 | ||
2c82c4dc | 1172 | birth = process->creation_time; |
1173 | ||
0f090e21 | 1174 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){ |
1175 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; | |
2c82c4dc | 1176 | } else { |
98dfb302 YB |
1177 | hashed_process_data = get_hashed_process_data(control_flow_data, |
1178 | process, ppid, trace_num); | |
1179 | ||
2c82c4dc | 1180 | |
1181 | /* Set the current process */ | |
0f090e21 | 1182 | process_list->current_hash_data[trace_num][process->cpu] = |
2c82c4dc | 1183 | hashed_process_data; |
1184 | } | |
1185 | ||
1186 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, | |
1187 | evtime) <= 0)) | |
1188 | { | |
1189 | TimeWindow time_window = | |
1190 | lttvwindow_get_time_window(control_flow_data->tab); | |
dbd243b1 | 1191 | |
2c82c4dc | 1192 | #ifdef EXTRA_CHECK |
1193 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1194 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
3311444c | 1195 | return FALSE; |
2c82c4dc | 1196 | #endif //EXTRA_CHECK |
1197 | Drawing_t *drawing = control_flow_data->drawing; | |
1198 | guint width = drawing->width; | |
1199 | guint new_x; | |
1200 | convert_time_to_pixels( | |
1201 | time_window, | |
1202 | evtime, | |
1203 | width, | |
1204 | &new_x); | |
1205 | if(unlikely(hashed_process_data->x.middle != new_x)) { | |
1206 | hashed_process_data->x.middle = new_x; | |
1207 | hashed_process_data->x.middle_used = FALSE; | |
1208 | hashed_process_data->x.middle_marked = FALSE; | |
1209 | } | |
1210 | } | |
7b20eed1 | 1211 | #endif |
10599fb9 | 1212 | return FALSE; |
2c82c4dc | 1213 | } |
dbd243b1 | 1214 | |
1215 | ||
f4b88a7d | 1216 | /* Get the filename of the process to print */ |
1217 | int after_fs_exec_hook(void *hook_data, void *call_data) | |
1218 | { | |
88bf15f0 | 1219 | #ifdef BABEL_CLEANUP |
dd455fb8 | 1220 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1221 | EventsRequest *events_request = (EventsRequest*)th->hook_data; | |
f4b88a7d | 1222 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1223 | ||
1224 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; | |
1225 | ||
1226 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; | |
1227 | ||
1228 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; | |
1229 | ||
e38d9ea0 | 1230 | LttEvent *e; |
1231 | e = ltt_tracefile_get_event(tfc->tf); | |
1232 | ||
1233 | LttvFilter *filter = control_flow_data->filter; | |
1234 | if(filter != NULL && filter->head != NULL) | |
1235 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
b6ef18af | 1236 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 | 1237 | return FALSE; |
1238 | ||
ae3d0f50 | 1239 | guint cpu = tfs->cpu; |
0f090e21 | 1240 | guint trace_num = ts->parent.index; |
f4b88a7d | 1241 | LttvProcessState *process = ts->running_process[cpu]; |
1242 | g_assert(process != NULL); | |
1243 | ||
1244 | guint pid = process->pid; | |
1245 | ||
1246 | /* Well, the process_out existed : we must get it in the process hash | |
1247 | * or add it, and draw its items. | |
1248 | */ | |
1249 | /* Add process to process list (if not present) */ | |
1250 | guint pl_height = 0; | |
1251 | HashedProcessData *hashed_process_data = NULL; | |
1252 | ProcessList *process_list = control_flow_data->process_list; | |
1253 | LttTime birth = process->creation_time; | |
1254 | ||
0f090e21 | 1255 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
1256 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; | |
f4b88a7d | 1257 | } else { |
98dfb302 YB |
1258 | hashed_process_data = get_hashed_process_data(control_flow_data, |
1259 | process, pid, trace_num); | |
f4b88a7d | 1260 | /* Set the current process */ |
0f090e21 | 1261 | process_list->current_hash_data[trace_num][process->cpu] = |
f4b88a7d | 1262 | hashed_process_data; |
1263 | } | |
1264 | ||
1265 | processlist_set_name(process_list, process->name, hashed_process_data); | |
1266 | ||
88bf15f0 | 1267 | #endif //babel_cleanup |
10599fb9 | 1268 | return 0; |
f4b88a7d | 1269 | |
1270 | } | |
1271 | ||
b3fd4c02 | 1272 | /* after_event_enum_process_hook |
1273 | * | |
b3fd4c02 | 1274 | * Create the processlist entry for the child process. Put the last |
1275 | * position in x at the current time value. | |
1276 | * | |
1277 | * @param hook_data ControlFlowData structure of the viewer. | |
1278 | * @param call_data Event context. | |
1279 | * | |
1280 | * This function adds items to be drawn in a queue for each process. | |
1281 | * | |
1282 | */ | |
1283 | int after_event_enum_process_hook(void *hook_data, void *call_data) | |
1284 | { | |
7b20eed1 | 1285 | LttvEvent *event; |
b3fd4c02 | 1286 | |
7b20eed1 YB |
1287 | event = (LttvEvent *) call_data; |
1288 | ||
1289 | if (strcmp(lttv_traceset_get_name_from_event(event),"lttng_statedump_process_state") != 0) | |
1290 | return FALSE; | |
b3fd4c02 | 1291 | |
7b20eed1 | 1292 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
b3fd4c02 | 1293 | |
c4a72569 | 1294 | |
7b20eed1 | 1295 | LttvTraceState *ts = event->state; |
b3fd4c02 | 1296 | |
7b20eed1 YB |
1297 | guint first_cpu, nb_cpus, cpu; |
1298 | ||
1299 | #ifdef BABEL_CLEANUP | |
e38d9ea0 | 1300 | LttvFilter *filter = control_flow_data->filter; |
1301 | if(filter != NULL && filter->head != NULL) | |
1302 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
b6ef18af | 1303 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 | 1304 | return FALSE; |
7b20eed1 | 1305 | #endif |
b3fd4c02 | 1306 | /* Add process to process list (if not present) */ |
1307 | LttvProcessState *process_in; | |
b3fd4c02 | 1308 | HashedProcessData *hashed_process_data_in = NULL; |
1309 | ||
1310 | ProcessList *process_list = control_flow_data->process_list; | |
7b20eed1 | 1311 | guint trace_num = 0; /* TODO put right trace number */ |
b3fd4c02 | 1312 | |
1313 | guint pid_in; | |
1314 | { | |
7b20eed1 | 1315 | pid_in = lttv_event_get_long(event, "tid"); |
b3fd4c02 | 1316 | } |
c4a72569 | 1317 | |
1318 | if(pid_in == 0) { | |
1319 | first_cpu = 0; | |
7b20eed1 | 1320 | nb_cpus = lttv_trace_get_num_cpu(ts->trace); |
c4a72569 | 1321 | } else { |
1322 | first_cpu = ANY_CPU; | |
1323 | nb_cpus = ANY_CPU+1; | |
1324 | } | |
b3fd4c02 | 1325 | |
c4a72569 | 1326 | for(cpu = first_cpu; cpu < nb_cpus; cpu++) { |
1327 | /* Find process pid_in in the list... */ | |
1328 | process_in = lttv_state_find_process(ts, cpu, pid_in); | |
1329 | //process_in = tfs->process; | |
1330 | //guint cpu = tfs->cpu; | |
1331 | //guint trace_num = ts->parent.index; | |
1332 | //process_in = ts->running_process[cpu]; | |
1333 | /* It should exist, because we are after the state update. */ | |
1334 | #ifdef EXTRA_CHECK | |
1335 | //g_assert(process_in != NULL); | |
1336 | #endif //EXTRA_CHECK | |
c4a72569 | 1337 | |
98dfb302 YB |
1338 | hashed_process_data_in = get_hashed_process_data(control_flow_data, |
1339 | process_in, pid_in, trace_num); | |
1340 | ||
c4a72569 | 1341 | processlist_set_name(process_list, process_in->name, |
1342 | hashed_process_data_in); | |
1343 | processlist_set_ppid(process_list, process_in->ppid, | |
1344 | hashed_process_data_in); | |
1345 | processlist_set_tgid(process_list, process_in->tgid, | |
1346 | hashed_process_data_in); | |
98dfb302 | 1347 | |
c4a72569 | 1348 | } |
10599fb9 | 1349 | return 0; |
b3fd4c02 | 1350 | } |
f4b88a7d | 1351 | |
1352 | ||
1b238973 | 1353 | gint update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 | 1354 | { |
a56a1ba4 | 1355 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
98dfb302 | 1356 | |
a43d67ba | 1357 | Drawing_t *drawing = control_flow_data->drawing; |
1c736ed5 | 1358 | ProcessList *process_list = control_flow_data->process_list; |
a43d67ba | 1359 | |
224446ce | 1360 | const TimeWindowNotifyData *time_window_nofify_data = |
1361 | ((const TimeWindowNotifyData *)call_data); | |
1362 | ||
14963be0 | 1363 | TimeWindow *old_time_window = |
224446ce | 1364 | time_window_nofify_data->old_time_window; |
1365 | TimeWindow *new_time_window = | |
1366 | time_window_nofify_data->new_time_window; | |
a56a1ba4 | 1367 | |
3cb8b205 | 1368 | /* Update the ruler */ |
1369 | drawing_update_ruler(control_flow_data->drawing, | |
1370 | new_time_window); | |
1371 | ||
1372 | ||
a56a1ba4 | 1373 | /* Two cases : zoom in/out or scrolling */ |
1374 | ||
1375 | /* In order to make sure we can reuse the old drawing, the scale must | |
1376 | * be the same and the new time interval being partly located in the | |
1377 | * currently shown time interval. (reuse is only for scrolling) | |
1378 | */ | |
1379 | ||
2eef04b5 | 1380 | g_info("Old time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 | 1381 | old_time_window->start_time.tv_sec, |
1382 | old_time_window->start_time.tv_nsec, | |
1383 | old_time_window->time_width.tv_sec, | |
1384 | old_time_window->time_width.tv_nsec); | |
a56a1ba4 | 1385 | |
2eef04b5 | 1386 | g_info("New time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 | 1387 | new_time_window->start_time.tv_sec, |
1388 | new_time_window->start_time.tv_nsec, | |
1389 | new_time_window->time_width.tv_sec, | |
1390 | new_time_window->time_width.tv_nsec); | |
a56a1ba4 | 1391 | |
14963be0 | 1392 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
1393 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) | |
a56a1ba4 | 1394 | { |
1395 | /* Same scale (scrolling) */ | |
1396 | g_info("scrolling"); | |
14963be0 | 1397 | LttTime *ns = &new_time_window->start_time; |
1398 | LttTime *os = &old_time_window->start_time; | |
6f26fc38 | 1399 | LttTime old_end = old_time_window->end_time; |
1400 | LttTime new_end = new_time_window->end_time; | |
a56a1ba4 | 1401 | //if(ns<os+w<ns+w) |
1402 | //if(ns<os+w && os+w<ns+w) | |
1403 | //if(ns<old_end && os<ns) | |
1404 | if(ltt_time_compare(*ns, old_end) == -1 | |
1405 | && ltt_time_compare(*os, *ns) == -1) | |
1406 | { | |
1407 | g_info("scrolling near right"); | |
1408 | /* Scroll right, keep right part of the screen */ | |
1409 | guint x = 0; | |
51705146 | 1410 | guint width = control_flow_data->drawing->width; |
a56a1ba4 | 1411 | convert_time_to_pixels( |
a18124ff | 1412 | *old_time_window, |
a56a1ba4 | 1413 | *ns, |
1414 | width, | |
1415 | &x); | |
1416 | ||
1417 | /* Copy old data to new location */ | |
1c736ed5 | 1418 | copy_pixmap_region(process_list, |
1419 | NULL, | |
1420 | control_flow_data->drawing->drawing_area->style->black_gc, | |
1421 | NULL, | |
1422 | x, 0, | |
1423 | 0, 0, | |
1424 | control_flow_data->drawing->width-x+SAFETY, -1); | |
1425 | ||
6395d57c | 1426 | if(drawing->damage_begin == drawing->damage_end) |
1427 | drawing->damage_begin = control_flow_data->drawing->width-x; | |
1428 | else | |
1429 | drawing->damage_begin = 0; | |
1430 | ||
1431 | drawing->damage_end = control_flow_data->drawing->width; | |
1432 | ||
a56a1ba4 | 1433 | /* Clear the data request background, but not SAFETY */ |
1c736ed5 | 1434 | rectangle_pixmap(process_list, |
cfe526b1 | 1435 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 | 1436 | TRUE, |
6395d57c | 1437 | drawing->damage_begin+SAFETY, 0, |
1438 | drawing->damage_end - drawing->damage_begin, // do not overlap | |
1c736ed5 | 1439 | -1); |
7abb23ad | 1440 | gtk_widget_queue_draw(drawing->drawing_area); |
1441 | //gtk_widget_queue_draw_area (drawing->drawing_area, | |
1442 | // 0,0, | |
1443 | // control_flow_data->drawing->width, | |
1444 | // control_flow_data->drawing->height); | |
a43d67ba | 1445 | |
a56a1ba4 | 1446 | /* Get new data for the rest. */ |
501d5405 | 1447 | drawing_data_request(control_flow_data->drawing, |
6395d57c | 1448 | drawing->damage_begin, 0, |
1449 | drawing->damage_end - drawing->damage_begin, | |
501d5405 | 1450 | control_flow_data->drawing->height); |
a56a1ba4 | 1451 | } else { |
1452 | //if(ns<os<ns+w) | |
1453 | //if(ns<os && os<ns+w) | |
1454 | //if(ns<os && os<new_end) | |
1455 | if(ltt_time_compare(*ns,*os) == -1 | |
1456 | && ltt_time_compare(*os,new_end) == -1) | |
1457 | { | |
1458 | g_info("scrolling near left"); | |
1459 | /* Scroll left, keep left part of the screen */ | |
1460 | guint x = 0; | |
51705146 | 1461 | guint width = control_flow_data->drawing->width; |
a56a1ba4 | 1462 | convert_time_to_pixels( |
a18124ff | 1463 | *new_time_window, |
a56a1ba4 | 1464 | *os, |
1465 | width, | |
1466 | &x); | |
6395d57c | 1467 | |
a56a1ba4 | 1468 | /* Copy old data to new location */ |
1c736ed5 | 1469 | copy_pixmap_region (process_list, |
1470 | NULL, | |
cfe526b1 | 1471 | control_flow_data->drawing->drawing_area->style->black_gc, |
1c736ed5 | 1472 | NULL, |
a56a1ba4 | 1473 | 0, 0, |
1474 | x, 0, | |
1475 | -1, -1); | |
1476 | ||
6395d57c | 1477 | if(drawing->damage_begin == drawing->damage_end) |
1478 | drawing->damage_end = x; | |
1479 | else | |
1480 | drawing->damage_end = | |
51705146 | 1481 | control_flow_data->drawing->width; |
6395d57c | 1482 | |
1483 | drawing->damage_begin = 0; | |
1484 | ||
1c736ed5 | 1485 | rectangle_pixmap (process_list, |
cfe526b1 | 1486 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 | 1487 | TRUE, |
6395d57c | 1488 | drawing->damage_begin, 0, |
1489 | drawing->damage_end - drawing->damage_begin, // do not overlap | |
1c736ed5 | 1490 | -1); |
a43d67ba | 1491 | |
7abb23ad | 1492 | gtk_widget_queue_draw(drawing->drawing_area); |
1493 | //gtk_widget_queue_draw_area (drawing->drawing_area, | |
1494 | // 0,0, | |
1495 | // control_flow_data->drawing->width, | |
1496 | // control_flow_data->drawing->height); | |
a43d67ba | 1497 | |
6395d57c | 1498 | |
a56a1ba4 | 1499 | /* Get new data for the rest. */ |
501d5405 | 1500 | drawing_data_request(control_flow_data->drawing, |
6395d57c | 1501 | drawing->damage_begin, 0, |
1502 | drawing->damage_end - drawing->damage_begin, | |
501d5405 | 1503 | control_flow_data->drawing->height); |
a56a1ba4 | 1504 | |
a56a1ba4 | 1505 | } else { |
a43d67ba | 1506 | if(ltt_time_compare(*ns,*os) == 0) |
1507 | { | |
1508 | g_info("not scrolling"); | |
1509 | } else { | |
1510 | g_info("scrolling far"); | |
1511 | /* Cannot reuse any part of the screen : far jump */ | |
1512 | ||
1513 | ||
1c736ed5 | 1514 | rectangle_pixmap (process_list, |
a43d67ba | 1515 | control_flow_data->drawing->drawing_area->style->black_gc, |
1516 | TRUE, | |
a56a1ba4 | 1517 | 0, 0, |
a43d67ba | 1518 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 | 1519 | -1); |
a43d67ba | 1520 | |
7abb23ad | 1521 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
1522 | // 0,0, | |
1523 | // control_flow_data->drawing->width, | |
1524 | // control_flow_data->drawing->height); | |
1525 | gtk_widget_queue_draw(drawing->drawing_area); | |
a43d67ba | 1526 | |
6395d57c | 1527 | drawing->damage_begin = 0; |
1528 | drawing->damage_end = control_flow_data->drawing->width; | |
1529 | ||
a43d67ba | 1530 | drawing_data_request(control_flow_data->drawing, |
a43d67ba | 1531 | 0, 0, |
1532 | control_flow_data->drawing->width, | |
1533 | control_flow_data->drawing->height); | |
1534 | ||
1535 | } | |
a56a1ba4 | 1536 | } |
1537 | } | |
1538 | } else { | |
1539 | /* Different scale (zoom) */ | |
1540 | g_info("zoom"); | |
1541 | ||
1c736ed5 | 1542 | rectangle_pixmap (process_list, |
cfe526b1 | 1543 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 | 1544 | TRUE, |
1545 | 0, 0, | |
501d5405 | 1546 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 | 1547 | -1); |
a56a1ba4 | 1548 | |
7abb23ad | 1549 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
1550 | // 0,0, | |
1551 | // control_flow_data->drawing->width, | |
1552 | // control_flow_data->drawing->height); | |
1553 | gtk_widget_queue_draw(drawing->drawing_area); | |
a56a1ba4 | 1554 | |
6395d57c | 1555 | drawing->damage_begin = 0; |
1556 | drawing->damage_end = control_flow_data->drawing->width; | |
1557 | ||
501d5405 | 1558 | drawing_data_request(control_flow_data->drawing, |
a56a1ba4 | 1559 | 0, 0, |
501d5405 | 1560 | control_flow_data->drawing->width, |
1561 | control_flow_data->drawing->height); | |
a56a1ba4 | 1562 | } |
1563 | ||
15f77e3b | 1564 | /* Update directly when scrolling */ |
1565 | gdk_window_process_updates(control_flow_data->drawing->drawing_area->window, | |
1566 | TRUE); | |
3cb8b205 | 1567 | |
a56a1ba4 | 1568 | return 0; |
f7afe191 | 1569 | } |
1570 | ||
6395d57c | 1571 | gint traceset_notify(void *hook_data, void *call_data) |
1572 | { | |
1573 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; | |
1574 | Drawing_t *drawing = control_flow_data->drawing; | |
6395d57c | 1575 | |
6cec4cd2 | 1576 | if(unlikely(drawing->gc == NULL)) { |
1577 | return FALSE; | |
1578 | } | |
1579 | if(drawing->dotted_gc == NULL) { | |
1580 | return FALSE; | |
1581 | } | |
6395d57c | 1582 | |
b9a010a2 | 1583 | drawing_clear(control_flow_data->drawing); |
1584 | processlist_clear(control_flow_data->process_list); | |
07390ec1 | 1585 | gtk_widget_set_size_request( |
1586 | control_flow_data->drawing->drawing_area, | |
1587 | -1, processlist_get_height(control_flow_data->process_list)); | |
d9267eec | 1588 | redraw_notify(control_flow_data, NULL); |
6395d57c | 1589 | |
d9267eec | 1590 | request_background_data(control_flow_data); |
6395d57c | 1591 | |
1592 | return FALSE; | |
1593 | } | |
1594 | ||
ca0f8a8e | 1595 | gint redraw_notify(void *hook_data, void *call_data) |
1596 | { | |
1597 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; | |
1598 | Drawing_t *drawing = control_flow_data->drawing; | |
1599 | GtkWidget *widget = drawing->drawing_area; | |
1600 | ||
1601 | drawing->damage_begin = 0; | |
51705146 | 1602 | drawing->damage_end = drawing->width; |
ca0f8a8e | 1603 | |
49217bd4 | 1604 | /* fun feature, to be separated someday... */ |
1605 | drawing_clear(control_flow_data->drawing); | |
1606 | processlist_clear(control_flow_data->process_list); | |
07390ec1 | 1607 | gtk_widget_set_size_request( |
1608 | control_flow_data->drawing->drawing_area, | |
1609 | -1, processlist_get_height(control_flow_data->process_list)); | |
1c736ed5 | 1610 | // Clear the images |
1611 | rectangle_pixmap (control_flow_data->process_list, | |
ca0f8a8e | 1612 | widget->style->black_gc, |
1613 | TRUE, | |
1614 | 0, 0, | |
f3b7430d | 1615 | drawing->alloc_width, |
1c736ed5 | 1616 | -1); |
ca0f8a8e | 1617 | |
f3b7430d | 1618 | gtk_widget_queue_draw(drawing->drawing_area); |
4a24fa1f | 1619 | |
ca0f8a8e | 1620 | if(drawing->damage_begin < drawing->damage_end) |
1621 | { | |
1622 | drawing_data_request(drawing, | |
ca0f8a8e | 1623 | drawing->damage_begin, |
1624 | 0, | |
1625 | drawing->damage_end-drawing->damage_begin, | |
51705146 | 1626 | drawing->height); |
ca0f8a8e | 1627 | } |
1628 | ||
7abb23ad | 1629 | //gtk_widget_queue_draw_area(drawing->drawing_area, |
1630 | // 0,0, | |
1631 | // drawing->width, | |
1632 | // drawing->height); | |
ca0f8a8e | 1633 | return FALSE; |
1634 | ||
1635 | } | |
1636 | ||
1637 | ||
1638 | gint continue_notify(void *hook_data, void *call_data) | |
a43d67ba | 1639 | { |
1640 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; | |
ca0f8a8e | 1641 | Drawing_t *drawing = control_flow_data->drawing; |
a43d67ba | 1642 | |
6395d57c | 1643 | //g_assert(widget->allocation.width == drawing->damage_end); |
ca0f8a8e | 1644 | |
1645 | if(drawing->damage_begin < drawing->damage_end) | |
1646 | { | |
1647 | drawing_data_request(drawing, | |
ca0f8a8e | 1648 | drawing->damage_begin, |
1649 | 0, | |
1650 | drawing->damage_end-drawing->damage_begin, | |
51705146 | 1651 | drawing->height); |
ca0f8a8e | 1652 | } |
1653 | ||
1654 | return FALSE; | |
1655 | } | |
1656 | ||
1657 | ||
1b238973 | 1658 | gint update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 | 1659 | { |
88bf15f0 | 1660 | |
14963be0 | 1661 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
a56a1ba4 | 1662 | |
224446ce | 1663 | LttTime current_time = *((LttTime*)call_data); |
88bf15f0 | 1664 | |
ca0f8a8e | 1665 | TimeWindow time_window = |
1666 | lttvwindow_get_time_window(control_flow_data->tab); | |
a56a1ba4 | 1667 | |
ca0f8a8e | 1668 | LttTime time_begin = time_window.start_time; |
1669 | LttTime width = time_window.time_width; | |
90ef7e4a | 1670 | LttTime half_width; |
1671 | { | |
1672 | guint64 time_ll = ltt_time_to_uint64(width); | |
1673 | time_ll = time_ll >> 1; /* divide by two */ | |
1674 | half_width = ltt_time_from_uint64(time_ll); | |
1675 | } | |
a56a1ba4 | 1676 | LttTime time_end = ltt_time_add(time_begin, width); |
1677 | ||
88bf15f0 | 1678 | LttvTraceset * ts = lttvwindow_get_traceset(control_flow_data->tab); |
a56a1ba4 | 1679 | |
88bf15f0 FD |
1680 | TimeInterval time_span = lttv_traceset_get_time_span_real(ts); |
1681 | LttTime trace_start = time_span.start_time; | |
1682 | LttTime trace_end = time_span.end_time; | |
a56a1ba4 | 1683 | |
2eef04b5 | 1684 | g_info("New current time HOOK : %lu, %lu", current_time.tv_sec, |
224446ce | 1685 | current_time.tv_nsec); |
a56a1ba4 | 1686 | |
1687 | ||
1688 | ||
1689 | /* If current time is inside time interval, just move the highlight | |
1690 | * bar */ | |
1691 | ||
1692 | /* Else, we have to change the time interval. We have to tell it | |
1693 | * to the main window. */ | |
1694 | /* The time interval change will take care of placing the current | |
1695 | * time at the center of the visible area, or nearest possible if we are | |
1696 | * at one end of the trace. */ | |
1697 | ||
1698 | ||
dbc0ef8a | 1699 | if(ltt_time_compare(current_time, time_begin) < 0) |
a56a1ba4 | 1700 | { |
224446ce | 1701 | TimeWindow new_time_window; |
1702 | ||
1703 | if(ltt_time_compare(current_time, | |
dbc0ef8a | 1704 | ltt_time_add(trace_start,half_width)) < 0) |
a56a1ba4 | 1705 | time_begin = trace_start; |
1706 | else | |
224446ce | 1707 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 | 1708 | |
224446ce | 1709 | new_time_window.start_time = time_begin; |
1710 | new_time_window.time_width = width; | |
a18124ff | 1711 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 | 1712 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 | 1713 | |
e800cf84 | 1714 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 | 1715 | } |
dbc0ef8a | 1716 | else if(ltt_time_compare(current_time, time_end) > 0) |
a56a1ba4 | 1717 | { |
224446ce | 1718 | TimeWindow new_time_window; |
1719 | ||
dbc0ef8a | 1720 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0) |
a56a1ba4 | 1721 | time_begin = ltt_time_sub(trace_end,width); |
1722 | else | |
224446ce | 1723 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 | 1724 | |
224446ce | 1725 | new_time_window.start_time = time_begin; |
1726 | new_time_window.time_width = width; | |
a18124ff | 1727 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 | 1728 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 | 1729 | |
e800cf84 | 1730 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 | 1731 | |
1732 | } | |
7abb23ad | 1733 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
a56a1ba4 | 1734 | |
15f77e3b | 1735 | /* Update directly when scrolling */ |
1736 | gdk_window_process_updates(control_flow_data->drawing->drawing_area->window, | |
1737 | TRUE); | |
1738 | ||
a56a1ba4 | 1739 | return 0; |
88bf15f0 | 1740 | |
f7afe191 | 1741 | } |
1742 | ||
8b90e648 | 1743 | typedef struct _ClosureData { |
ca0f8a8e | 1744 | EventsRequest *events_request; |
b9a010a2 | 1745 | LttTime end_time; |
bc8d270b | 1746 | guint x_end; |
8b90e648 | 1747 | } ClosureData; |
a56a1ba4 | 1748 | |
8b90e648 | 1749 | |
e800cf84 | 1750 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
1751 | { | |
88bf15f0 | 1752 | |
a56a1ba4 | 1753 | ProcessInfo *process_info = (ProcessInfo*)key; |
1754 | HashedProcessData *hashed_process_data = (HashedProcessData*)value; | |
1755 | ClosureData *closure_data = (ClosureData*)user_data; | |
88bf15f0 | 1756 | |
e800cf84 | 1757 | EventsRequest *events_request = closure_data->events_request; |
1758 | ControlFlowData *control_flow_data = events_request->viewer_data; | |
88bf15f0 | 1759 | LttvTraceset *ts = lttvwindow_get_traceset(control_flow_data->tab); |
a56a1ba4 | 1760 | |
a56a1ba4 | 1761 | |
e800cf84 | 1762 | LttTime evtime = closure_data->end_time; |
d0cd7f09 | 1763 | |
e3162168 | 1764 | gboolean dodraw = TRUE; |
1765 | ||
e800cf84 | 1766 | { |
1767 | /* For the process */ | |
1768 | /* First, check if the current process is in the state computation | |
1769 | * process list. If it is there, that means we must add it right now and | |
1770 | * draw items from the beginning of the read for it. If it is not | |
1771 | * present, it's a new process and it was not present : it will | |
1772 | * be added after the state update. */ | |
31b6868d | 1773 | #ifdef EXTRA_CHECK |
e800cf84 | 1774 | g_assert(lttv_traceset_number(tsc->ts) > 0); |
31b6868d | 1775 | #endif //EXTRA_CHECK |
88bf15f0 FD |
1776 | //TODO Fdeslauriers 2012-07-17: adapt for multiple traces |
1777 | LttvTrace *trace = lttv_traceset_get(ts,0); | |
1778 | LttvTraceState *trace_state = trace->state; | |
2c82c4dc | 1779 | |
348c6ba8 | 1780 | #if 0 |
2c82c4dc | 1781 | //FIXME : optimize data structures. |
1782 | LttvTracefileState *tfs; | |
1783 | LttvTracefileContext *tfc; | |
1784 | guint i; | |
1785 | for(i=0;i<tc->tracefiles->len;i++) { | |
1786 | tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i); | |
1787 | if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU | |
ae3d0f50 | 1788 | && tfs->cpu == process_info->cpu) |
2c82c4dc | 1789 | break; |
1790 | ||
1791 | } | |
1792 | g_assert(i<tc->tracefiles->len); | |
1793 | tfs = LTTV_TRACEFILE_STATE(tfc); | |
348c6ba8 | 1794 | #endif //0 |
88bf15f0 | 1795 | // LttvTracefileState *tfs =ts |
2c82c4dc | 1796 | // (LttvTracefileState*)tsc->traces[process_info->trace_num]-> |
1797 | // tracefiles[process_info->cpu]; | |
2da61677 | 1798 | |
e800cf84 | 1799 | LttvProcessState *process; |
88bf15f0 | 1800 | process = lttv_state_find_process(trace_state, process_info->cpu, |
e025a729 | 1801 | process_info->pid); |
a56a1ba4 | 1802 | |
1d1df11d | 1803 | if(unlikely(process != NULL)) { |
88bf15f0 | 1804 | #ifdef BABEL_CLEANUP |
b6ef18af | 1805 | LttvFilter *filter = control_flow_data->filter; |
1806 | if(filter != NULL && filter->head != NULL) | |
1807 | if(!lttv_filter_tree_parse(filter->head,NULL,NULL, | |
1808 | tc->t,NULL,process,tc)) | |
e3162168 | 1809 | dodraw = FALSE; |
88bf15f0 | 1810 | #endif //babel_cleanup |
e800cf84 | 1811 | /* Only draw for processes that are currently in the trace states */ |
ad2e83ba | 1812 | |
1d1df11d | 1813 | #ifdef EXTRA_CHECK |
e800cf84 | 1814 | /* Should be alike when background info is ready */ |
1815 | if(control_flow_data->background_info_waiting==0) | |
1816 | g_assert(ltt_time_compare(process->creation_time, | |
1817 | process_info->birth) == 0); | |
1d1df11d | 1818 | #endif //EXTRA_CHECK |
e800cf84 | 1819 | |
1820 | /* Now, the process is in the state hash and our own process hash. | |
1821 | * We definitely can draw the items related to the ending state. | |
1822 | */ | |
1823 | ||
1d1df11d | 1824 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
1825 | evtime) <= 0)) | |
e800cf84 | 1826 | { |
fd22065b | 1827 | TimeWindow time_window = |
1828 | lttvwindow_get_time_window(control_flow_data->tab); | |
1829 | ||
1830 | #ifdef EXTRA_CHECK | |
1831 | if(ltt_time_compare(evtime, time_window.start_time) == -1 | |
1832 | || ltt_time_compare(evtime, time_window.end_time) == 1) | |
1833 | return; | |
1834 | #endif //EXTRA_CHECK | |
d6fef890 | 1835 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf | 1836 | guint width = drawing->width; |
a56a1ba4 | 1837 | |
bc8d270b | 1838 | guint x = closure_data->x_end; |
8b90e648 | 1839 | |
4b7dc462 | 1840 | DrawContext draw_context; |
1841 | ||
98dfb302 YB |
1842 | init_drawing_context(&draw_context, |
1843 | hashed_process_data, | |
1844 | drawing, | |
1845 | x); | |
1846 | ||
9a1ec01b | 1847 | #if 0 |
4b7dc462 | 1848 | /* Jump over draw if we are at the same x position */ |
1849 | if(x == hashed_process_data->x.over) | |
e800cf84 | 1850 | { |
4b7dc462 | 1851 | /* jump */ |
1852 | } else { | |
23093869 | 1853 | draw_context.drawinfo.start.x = hashed_process_data->x.over; |
1854 | /* Draw the line */ | |
1855 | PropertiesLine prop_line = prepare_execmode_line(process); | |
1856 | draw_line((void*)&prop_line, (void*)&draw_context); | |
1857 | ||
4b7dc462 | 1858 | hashed_process_data->x.over = x; |
23093869 | 1859 | } |
9a1ec01b | 1860 | #endif //0 |
4b7dc462 | 1861 | |
1d1df11d | 1862 | if(unlikely(x == hashed_process_data->x.middle && |
1863 | hashed_process_data->x.middle_used)) { | |
b2743953 | 1864 | #if 0 /* do not mark closure : not missing information */ |
e72908ed | 1865 | if(hashed_process_data->x.middle_marked == FALSE) { |
1866 | /* Draw collision indicator */ | |
1867 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); | |
1868 | gdk_draw_point(drawing->pixmap, | |
1869 | drawing->gc, | |
1870 | x, | |
2c6618bc | 1871 | y+(height/2)-3); |
de4ea1ad | 1872 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed | 1873 | } |
b2743953 | 1874 | #endif //0 |
4b7dc462 | 1875 | /* Jump */ |
1876 | } else { | |
23093869 | 1877 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
e800cf84 | 1878 | /* Draw the line */ |
c4a72569 | 1879 | if(dodraw) { |
1880 | PropertiesLine prop_line = prepare_s_e_line(process); | |
1881 | draw_line((void*)&prop_line, (void*)&draw_context); | |
1882 | } | |
e800cf84 | 1883 | |
4b7dc462 | 1884 | /* become the last x position */ |
1d1df11d | 1885 | if(likely(x != hashed_process_data->x.middle)) { |
e72908ed | 1886 | hashed_process_data->x.middle = x; |
1887 | /* but don't use the pixel */ | |
1888 | hashed_process_data->x.middle_used = FALSE; | |
b2743953 | 1889 | |
1890 | /* Calculate the next good time */ | |
1891 | convert_pixels_to_time(width, x+1, time_window, | |
1892 | &hashed_process_data->next_good_time); | |
e72908ed | 1893 | } |
e800cf84 | 1894 | } |
e800cf84 | 1895 | } |
1896 | } | |
1897 | } | |
1898 | return; | |
8b90e648 | 1899 | } |
1900 | ||
b9a010a2 | 1901 | int before_chunk(void *hook_data, void *call_data) |
1902 | { | |
88bf15f0 | 1903 | |
b9a010a2 | 1904 | EventsRequest *events_request = (EventsRequest*)hook_data; |
88bf15f0 | 1905 | LttvTraceset *ts = (LttvTraceset*)call_data; |
cd3892fe | 1906 | #if 0 |
7c0125e0 | 1907 | /* Desactivate sort */ |
1908 | gtk_tree_sortable_set_sort_column_id( | |
1909 | GTK_TREE_SORTABLE(cfd->process_list->list_store), | |
1910 | TRACE_COLUMN, | |
1911 | GTK_SORT_ASCENDING); | |
cd3892fe | 1912 | #endif //0 |
88bf15f0 | 1913 | drawing_chunk_begin(events_request, ts); |
b9a010a2 | 1914 | |
1915 | return 0; | |
1916 | } | |
1917 | ||
1918 | int before_request(void *hook_data, void *call_data) | |
ca0f8a8e | 1919 | { |
88bf15f0 | 1920 | |
ca0f8a8e | 1921 | EventsRequest *events_request = (EventsRequest*)hook_data; |
7c0125e0 | 1922 | |
88bf15f0 | 1923 | drawing_data_request_begin(events_request); |
ca0f8a8e | 1924 | |
1925 | return 0; | |
88bf15f0 | 1926 | |
ca0f8a8e | 1927 | } |
1928 | ||
1929 | ||
98dfb302 YB |
1930 | void draw_closing_lines(ControlFlowData *control_flow_data, |
1931 | EventsRequest* events_request) | |
8b90e648 | 1932 | { |
98dfb302 | 1933 | ProcessList *process_list = control_flow_data->process_list; |
88bf15f0 | 1934 | |
b9a010a2 | 1935 | |
1936 | ClosureData closure_data; | |
98dfb302 YB |
1937 | closure_data.events_request = events_request; |
1938 | closure_data.end_time = events_request->end_time; | |
b9a010a2 | 1939 | |
bc8d270b | 1940 | TimeWindow time_window = |
1941 | lttvwindow_get_time_window(control_flow_data->tab); | |
1942 | guint width = control_flow_data->drawing->width; | |
1943 | convert_time_to_pixels( | |
1944 | time_window, | |
98dfb302 | 1945 | events_request->end_time, |
bc8d270b | 1946 | width, |
1947 | &closure_data.x_end); | |
1948 | ||
1949 | ||
b9a010a2 | 1950 | /* Draw last items */ |
1951 | g_hash_table_foreach(process_list->process_hash, draw_closure, | |
1952 | (void*)&closure_data); | |
7c0125e0 | 1953 | |
b9a010a2 | 1954 | |
1955 | /* Request expose */ | |
98dfb302 YB |
1956 | drawing_request_expose(events_request, events_request->end_time); |
1957 | } | |
1958 | ||
1959 | /* | |
1960 | * after request is necessary in addition of after chunk in order to draw | |
1961 | * lines until the end of the screen. after chunk just draws lines until | |
1962 | * the last event. | |
1963 | * | |
1964 | * for each process | |
1965 | * draw closing line | |
1966 | * expose | |
1967 | */ | |
1968 | int after_request(void *hook_data, void *call_data) | |
1969 | { | |
1970 | ||
1971 | EventsRequest *events_request = (EventsRequest*)hook_data; | |
1972 | ControlFlowData *control_flow_data = events_request->viewer_data; | |
1973 | ||
1974 | draw_closing_lines(control_flow_data, events_request); | |
1975 | ||
b9a010a2 | 1976 | return 0; |
1977 | } | |
1978 | ||
1979 | /* | |
1980 | * for each process | |
1981 | * draw closing line | |
e800cf84 | 1982 | * expose |
b9a010a2 | 1983 | */ |
1984 | int after_chunk(void *hook_data, void *call_data) | |
1985 | { | |
88bf15f0 | 1986 | |
b9a010a2 | 1987 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1988 | ControlFlowData *control_flow_data = events_request->viewer_data; | |
88bf15f0 FD |
1989 | LttvTraceset *ts = (LttvTraceset*)call_data; |
1990 | ||
b9a010a2 | 1991 | |
5c230fc4 | 1992 | ProcessList *process_list = control_flow_data->process_list; |
0f090e21 | 1993 | guint i; |
88bf15f0 | 1994 | guint nb_trace = lttv_traceset_number(ts); |
b9a010a2 | 1995 | |
0f090e21 | 1996 | /* Only execute when called for the first trace's events request */ |
43ed82b5 | 1997 | if(!process_list->current_hash_data) |
1998 | return 0; | |
0f090e21 | 1999 | |
2000 | for(i = 0 ; i < nb_trace ; i++) { | |
2001 | g_free(process_list->current_hash_data[i]); | |
2002 | } | |
40debf7b | 2003 | g_free(process_list->current_hash_data); |
2004 | process_list->current_hash_data = NULL; | |
0f090e21 | 2005 | |
98dfb302 | 2006 | draw_closing_lines(control_flow_data, events_request); |
ca0f8a8e | 2007 | |
2008 | return 0; | |
8b90e648 | 2009 | } |
2010 | ||
b70ceef8 | 2011 | /* after_statedump_end |
2012 | * | |
2013 | * @param hook_data ControlFlowData structure of the viewer. | |
2014 | * @param call_data Event context. | |
2015 | * | |
2016 | * This function adds items to be drawn in a queue for each process. | |
2017 | * | |
2018 | */ | |
2019 | int before_statedump_end(void *hook_data, void *call_data) | |
2020 | { | |
7b20eed1 | 2021 | LttvEvent *event; |
b70ceef8 | 2022 | |
7b20eed1 YB |
2023 | event = (LttvEvent *) call_data; |
2024 | ||
2025 | if (strcmp(lttv_traceset_get_name_from_event(event),"lttng_statedump_end") != 0) | |
2026 | return FALSE; | |
b70ceef8 | 2027 | |
7b20eed1 | 2028 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
b70ceef8 | 2029 | |
b70ceef8 | 2030 | |
7b20eed1 YB |
2031 | LttvTraceState *ts = event->state; |
2032 | ||
2033 | ||
2034 | ProcessList *process_list = control_flow_data->process_list; | |
2035 | ||
2036 | #ifdef BABEL_CLEANUP | |
b70ceef8 | 2037 | LttvFilter *filter = control_flow_data->filter; |
2038 | if(filter != NULL && filter->head != NULL) | |
2039 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, | |
b6ef18af | 2040 | tfc->t_context->t,tfc,NULL,NULL)) |
b70ceef8 | 2041 | return FALSE; |
7b20eed1 | 2042 | #endif |
b70ceef8 | 2043 | |
7b20eed1 YB |
2044 | LttTime evtime = lttv_event_get_timestamp(event); |
2045 | #ifdef BABEL_CLEANUP | |
b70ceef8 | 2046 | ClosureData closure_data; |
2047 | closure_data.events_request = events_request; | |
2048 | closure_data.tss = tss; | |
2049 | closure_data.end_time = evtime; | |
2050 | ||
2051 | TimeWindow time_window = | |
2052 | lttvwindow_get_time_window(control_flow_data->tab); | |
2053 | guint width = control_flow_data->drawing->width; | |
2054 | convert_time_to_pixels( | |
2055 | time_window, | |
2056 | evtime, | |
2057 | width, | |
2058 | &closure_data.x_end); | |
2059 | ||
2060 | /* Draw last items */ | |
2061 | g_hash_table_foreach(process_list->process_hash, draw_closure, | |
2062 | (void*)&closure_data); | |
7b20eed1 | 2063 | |
b70ceef8 | 2064 | #if 0 |
2065 | /* Reactivate sort */ | |
2066 | gtk_tree_sortable_set_sort_column_id( | |
2067 | GTK_TREE_SORTABLE(control_flow_data->process_list->list_store), | |
2068 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, | |
2069 | GTK_SORT_ASCENDING); | |
2070 | ||
2071 | update_index_to_pixmap(control_flow_data->process_list); | |
2072 | /* Request a full expose : drawing scrambled */ | |
2073 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); | |
2074 | #endif //0 | |
2075 | /* Request expose (updates damages zone also) */ | |
2076 | drawing_request_expose(events_request, tss, evtime); | |
7b20eed1 | 2077 | #endif |
10599fb9 | 2078 | return 0; |
b70ceef8 | 2079 | } |