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 |
5bb606ce |
81 | #define STATE_LINE_WIDTH 4 |
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; |
95 | LttvTrace *trace = (LttvTrace*)call_data; |
96 | |
e800cf84 |
97 | control_flow_data->background_info_waiting--; |
98 | |
99 | if(control_flow_data->background_info_waiting == 0) { |
4a24fa1f |
100 | g_message("control flow viewer : background computation data ready."); |
6395d57c |
101 | |
e800cf84 |
102 | drawing_clear(control_flow_data->drawing); |
103 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
104 | gtk_widget_set_size_request( |
105 | control_flow_data->drawing->drawing_area, |
106 | -1, processlist_get_height(control_flow_data->process_list)); |
e800cf84 |
107 | redraw_notify(control_flow_data, NULL); |
b9a010a2 |
108 | } |
6395d57c |
109 | |
110 | return 0; |
111 | } |
112 | |
113 | |
114 | /* Request background computation. Verify if it is in progress or ready first. |
e800cf84 |
115 | * Only for each trace in the tab's traceset. |
6395d57c |
116 | */ |
3f7f592e |
117 | static void request_background_data(ControlFlowData *control_flow_data) |
6395d57c |
118 | { |
e800cf84 |
119 | LttvTracesetContext * tsc = |
120 | lttvwindow_get_traceset_context(control_flow_data->tab); |
121 | gint num_traces = lttv_traceset_number(tsc->ts); |
6395d57c |
122 | gint i; |
123 | LttvTrace *trace; |
7df20ca4 |
124 | LttvTraceState *tstate; |
6395d57c |
125 | |
126 | LttvHooks *background_ready_hook = |
127 | lttv_hooks_new(); |
128 | lttv_hooks_add(background_ready_hook, background_ready, control_flow_data, |
129 | LTTV_PRIO_DEFAULT); |
e800cf84 |
130 | control_flow_data->background_info_waiting = 0; |
6395d57c |
131 | |
132 | for(i=0;i<num_traces;i++) { |
e800cf84 |
133 | trace = lttv_traceset_get(tsc->ts, i); |
7df20ca4 |
134 | tstate = LTTV_TRACE_STATE(tsc->traces[i]); |
6395d57c |
135 | |
7df20ca4 |
136 | if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE |
137 | && !tstate->has_precomputed_states) { |
6395d57c |
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 | */ |
93ac601b |
145 | if(!lttvwindowtraces_background_request_find(trace, "state")) |
b5e17af5 |
146 | lttvwindowtraces_background_request_queue( |
147 | main_window_get_widget(control_flow_data->tab), trace, "state"); |
6395d57c |
148 | lttvwindowtraces_background_notify_queue(control_flow_data, |
149 | trace, |
150 | ltt_time_infinite, |
151 | NULL, |
152 | background_ready_hook); |
e800cf84 |
153 | control_flow_data->background_info_waiting++; |
6395d57c |
154 | } else { /* in progress */ |
155 | |
156 | lttvwindowtraces_background_notify_current(control_flow_data, |
157 | trace, |
158 | ltt_time_infinite, |
159 | NULL, |
160 | background_ready_hook); |
e800cf84 |
161 | control_flow_data->background_info_waiting++; |
6395d57c |
162 | } |
4368b993 |
163 | } else { |
7df20ca4 |
164 | /* Data ready. By its nature, this viewer doesn't need to have |
618fbcc1 |
165 | * its data ready hook called there, because a background |
4368b993 |
166 | * request is always linked with a redraw. |
167 | */ |
6395d57c |
168 | } |
4368b993 |
169 | |
6395d57c |
170 | } |
171 | |
172 | lttv_hooks_destroy(background_ready_hook); |
173 | } |
174 | |
175 | |
176 | |
177 | |
f0d936c0 |
178 | /** |
179 | * Event Viewer's constructor hook |
180 | * |
181 | * This constructor is given as a parameter to the menuitem and toolbar button |
182 | * registration. It creates the list. |
ca0f8a8e |
183 | * @param tab A pointer to the parent tab. |
f0d936c0 |
184 | * @return The widget created. |
185 | */ |
186 | GtkWidget * |
e433e6d6 |
187 | h_guicontrolflow(LttvPlugin *plugin) |
f0d936c0 |
188 | { |
e433e6d6 |
189 | LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin); |
190 | Tab *tab = ptab->tab; |
d47b33d2 |
191 | g_info("h_guicontrolflow, %p", tab); |
e433e6d6 |
192 | ControlFlowData *control_flow_data = guicontrolflow(ptab); |
a56a1ba4 |
193 | |
ca0f8a8e |
194 | control_flow_data->tab = tab; |
a56a1ba4 |
195 | |
a56a1ba4 |
196 | // Unreg done in the GuiControlFlow_Destructor |
6395d57c |
197 | lttvwindow_register_traceset_notify(tab, |
198 | traceset_notify, |
199 | control_flow_data); |
200 | |
ca0f8a8e |
201 | lttvwindow_register_time_window_notify(tab, |
224446ce |
202 | update_time_window_hook, |
203 | control_flow_data); |
ca0f8a8e |
204 | lttvwindow_register_current_time_notify(tab, |
224446ce |
205 | update_current_time_hook, |
206 | control_flow_data); |
ca0f8a8e |
207 | lttvwindow_register_redraw_notify(tab, |
208 | redraw_notify, |
209 | control_flow_data); |
210 | lttvwindow_register_continue_notify(tab, |
211 | continue_notify, |
212 | control_flow_data); |
667ca2a0 |
213 | request_background_data(control_flow_data); |
6395d57c |
214 | |
ca0f8a8e |
215 | |
68997a22 |
216 | return guicontrolflow_get_widget(control_flow_data) ; |
a56a1ba4 |
217 | |
f0d936c0 |
218 | } |
219 | |
3cff8cc1 |
220 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 |
221 | { |
68997a22 |
222 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
14963be0 |
223 | guint *event_number = (guint*) call_data; |
f0d936c0 |
224 | |
2a2fa4f0 |
225 | g_debug("DEBUG : event selected by main window : %u", *event_number); |
a56a1ba4 |
226 | |
2eef04b5 |
227 | return 0; |
f0d936c0 |
228 | } |
229 | |
9a1ec01b |
230 | /* Function that selects the color of status&exemode line */ |
6550d711 |
231 | static inline PropertiesLine prepare_s_e_line(LttvProcessState *process) |
9a1ec01b |
232 | { |
233 | PropertiesLine prop_line; |
5bb606ce |
234 | prop_line.line_width = STATE_LINE_WIDTH; |
9a1ec01b |
235 | prop_line.style = GDK_LINE_SOLID; |
236 | prop_line.y = MIDDLE; |
237 | //GdkColormap *colormap = gdk_colormap_get_system(); |
238 | |
9a1ec01b |
239 | if(process->state->s == LTTV_STATE_RUN) { |
240 | if(process->state->t == LTTV_STATE_USER_MODE) |
241 | prop_line.color = drawing_colors[COL_RUN_USER_MODE]; |
242 | else if(process->state->t == LTTV_STATE_SYSCALL) |
243 | prop_line.color = drawing_colors[COL_RUN_SYSCALL]; |
244 | else if(process->state->t == LTTV_STATE_TRAP) |
245 | prop_line.color = drawing_colors[COL_RUN_TRAP]; |
246 | else if(process->state->t == LTTV_STATE_IRQ) |
247 | prop_line.color = drawing_colors[COL_RUN_IRQ]; |
faf074a3 |
248 | else if(process->state->t == LTTV_STATE_SOFT_IRQ) |
249 | prop_line.color = drawing_colors[COL_RUN_SOFT_IRQ]; |
9a1ec01b |
250 | else if(process->state->t == LTTV_STATE_MODE_UNKNOWN) |
251 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; |
252 | else |
253 | g_assert(FALSE); /* RUNNING MODE UNKNOWN */ |
254 | } else if(process->state->s == LTTV_STATE_WAIT) { |
255 | /* We don't show if we wait while in user mode, trap, irq or syscall */ |
256 | prop_line.color = drawing_colors[COL_WAIT]; |
257 | } else if(process->state->s == LTTV_STATE_WAIT_CPU) { |
258 | /* We don't show if we wait for CPU while in user mode, trap, irq |
259 | * or syscall */ |
260 | prop_line.color = drawing_colors[COL_WAIT_CPU]; |
261 | } else if(process->state->s == LTTV_STATE_ZOMBIE) { |
262 | prop_line.color = drawing_colors[COL_ZOMBIE]; |
263 | } else if(process->state->s == LTTV_STATE_WAIT_FORK) { |
264 | prop_line.color = drawing_colors[COL_WAIT_FORK]; |
265 | } else if(process->state->s == LTTV_STATE_EXIT) { |
266 | prop_line.color = drawing_colors[COL_EXIT]; |
267 | } else if(process->state->s == LTTV_STATE_UNNAMED) { |
268 | prop_line.color = drawing_colors[COL_UNNAMED]; |
b3fd4c02 |
269 | } else { |
270 | g_critical("unknown state : %s", g_quark_to_string(process->state->s)); |
9a1ec01b |
271 | g_assert(FALSE); /* UNKNOWN STATE */ |
b3fd4c02 |
272 | } |
9a1ec01b |
273 | |
274 | return prop_line; |
275 | |
276 | } |
277 | |
c8bba5fa |
278 | |
e92eabaf |
279 | /* before_schedchange_hook |
b9a010a2 |
280 | * |
f0d936c0 |
281 | * This function basically draw lines and icons. Two types of lines are drawn : |
282 | * one small (3 pixels?) representing the state of the process and the second |
283 | * type is thicker (10 pixels?) representing on which CPU a process is running |
284 | * (and this only in running state). |
285 | * |
286 | * Extremums of the lines : |
287 | * x_min : time of the last event context for this process kept in memory. |
288 | * x_max : time of the current event. |
289 | * y : middle of the process in the process list. The process is found in the |
290 | * list, therefore is it's position in pixels. |
291 | * |
292 | * The choice of lines'color is defined by the context of the last event for this |
293 | * process. |
294 | */ |
b9a010a2 |
295 | |
296 | |
e92eabaf |
297 | int before_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 |
298 | { |
dd455fb8 |
299 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
300 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
b9a010a2 |
301 | ControlFlowData *control_flow_data = events_request->viewer_data; |
302 | |
303 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
304 | |
305 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
348c6ba8 |
306 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
b9a010a2 |
307 | |
308 | LttEvent *e; |
2c82c4dc |
309 | e = ltt_tracefile_get_event(tfc->tf); |
e38d9ea0 |
310 | gint target_pid_saved = tfc->target_pid; |
b9a010a2 |
311 | |
312 | LttTime evtime = ltt_event_time(e); |
e38d9ea0 |
313 | LttvFilter *filter = control_flow_data->filter; |
fd22065b |
314 | |
10a1069a |
315 | /* we are in a schedchange, before the state update. We must draw the |
316 | * items corresponding to the state before it changes : now is the right |
317 | * time to do it. |
318 | */ |
b9a010a2 |
319 | |
10a1069a |
320 | guint pid_out; |
321 | guint pid_in; |
322 | { |
04348950 |
323 | pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
324 | pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); |
10a1069a |
325 | } |
326 | |
e38d9ea0 |
327 | tfc->target_pid = pid_out; |
328 | if(!filter || !filter->head || |
329 | lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
330 | tfc->t_context->t,tfc,NULL,NULL)) { |
10a1069a |
331 | /* For the pid_out */ |
332 | /* First, check if the current process is in the state computation |
333 | * process list. If it is there, that means we must add it right now and |
334 | * draw items from the beginning of the read for it. If it is not |
335 | * present, it's a new process and it was not present : it will |
336 | * be added after the state update. */ |
ae3d0f50 |
337 | guint cpu = tfs->cpu; |
0f090e21 |
338 | guint trace_num = ts->parent.index; |
348c6ba8 |
339 | LttvProcessState *process = ts->running_process[cpu]; |
40debf7b |
340 | /* unknown state, bad current pid */ |
348c6ba8 |
341 | if(process->pid != pid_out) |
800aa029 |
342 | process = lttv_state_find_process(ts, |
ae3d0f50 |
343 | tfs->cpu, pid_out); |
b9a010a2 |
344 | |
10a1069a |
345 | if(process != NULL) { |
346 | /* Well, the process_out existed : we must get it in the process hash |
347 | * or add it, and draw its items. |
348 | */ |
349 | /* Add process to process list (if not present) */ |
1c736ed5 |
350 | guint pl_height = 0; |
10a1069a |
351 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
352 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
353 | LttTime birth = process->creation_time; |
b9a010a2 |
354 | |
ac4e21cf |
355 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
356 | pid_out, |
348c6ba8 |
357 | process->cpu, |
10a1069a |
358 | &birth, |
0f090e21 |
359 | trace_num); |
ac4e21cf |
360 | if(hashed_process_data == NULL) |
10a1069a |
361 | { |
362 | g_assert(pid_out == 0 || pid_out != process->ppid); |
363 | /* Process not present */ |
4e86ae2e |
364 | ProcessInfo *process_info; |
1c736ed5 |
365 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
366 | processlist_add(process_list, |
1c736ed5 |
367 | drawing, |
10a1069a |
368 | pid_out, |
fcc08e1e |
369 | process->tgid, |
348c6ba8 |
370 | process->cpu, |
10a1069a |
371 | process->ppid, |
372 | &birth, |
0f090e21 |
373 | trace_num, |
f4b88a7d |
374 | process->name, |
7b5f6cf1 |
375 | process->brand, |
10a1069a |
376 | &pl_height, |
4e86ae2e |
377 | &process_info, |
10a1069a |
378 | &hashed_process_data); |
1c736ed5 |
379 | gtk_widget_set_size_request(drawing->drawing_area, |
380 | -1, |
381 | pl_height); |
382 | gtk_widget_queue_draw(drawing->drawing_area); |
383 | |
10a1069a |
384 | } |
ac4e21cf |
385 | |
10a1069a |
386 | /* Now, the process is in the state hash and our own process hash. |
387 | * We definitely can draw the items related to the ending state. |
388 | */ |
e800cf84 |
389 | |
b2743953 |
390 | if(ltt_time_compare(hashed_process_data->next_good_time, |
391 | evtime) > 0) |
10a1069a |
392 | { |
b2743953 |
393 | if(hashed_process_data->x.middle_marked == FALSE) { |
ac4e21cf |
394 | |
fd22065b |
395 | TimeWindow time_window = |
396 | lttvwindow_get_time_window(control_flow_data->tab); |
397 | #ifdef EXTRA_CHECK |
398 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
399 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
400 | return FALSE; |
fd22065b |
401 | #endif //EXTRA_CHECK |
d6fef890 |
402 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
403 | guint width = drawing->width; |
b2743953 |
404 | guint x; |
405 | convert_time_to_pixels( |
406 | time_window, |
407 | evtime, |
408 | width, |
409 | &x); |
410 | |
411 | /* Draw collision indicator */ |
412 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
413 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
414 | drawing->gc, |
415 | x, |
5bb606ce |
416 | COLLISION_POSITION(hashed_process_data->height)); |
b2743953 |
417 | hashed_process_data->x.middle_marked = TRUE; |
418 | } |
419 | } else { |
ac4e21cf |
420 | TimeWindow time_window = |
421 | lttvwindow_get_time_window(control_flow_data->tab); |
fd22065b |
422 | #ifdef EXTRA_CHECK |
ac4e21cf |
423 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
424 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
425 | return FALSE; |
fd22065b |
426 | #endif //EXTRA_CHECK |
d6fef890 |
427 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
428 | guint width = drawing->width; |
10a1069a |
429 | guint x; |
10a1069a |
430 | convert_time_to_pixels( |
a18124ff |
431 | time_window, |
4b7dc462 |
432 | evtime, |
433 | width, |
434 | &x); |
10a1069a |
435 | |
10a1069a |
436 | |
4b7dc462 |
437 | /* Jump over draw if we are at the same x position */ |
e72908ed |
438 | if(x == hashed_process_data->x.middle && |
439 | hashed_process_data->x.middle_used) |
e800cf84 |
440 | { |
e72908ed |
441 | if(hashed_process_data->x.middle_marked == FALSE) { |
442 | /* Draw collision indicator */ |
443 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
444 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
445 | drawing->gc, |
446 | x, |
5bb606ce |
447 | COLLISION_POSITION(hashed_process_data->height)); |
de4ea1ad |
448 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
449 | } |
4b7dc462 |
450 | /* jump */ |
451 | } else { |
452 | DrawContext draw_context; |
10a1069a |
453 | |
4b7dc462 |
454 | /* Now create the drawing context that will be used to draw |
455 | * items related to the last state. */ |
1c736ed5 |
456 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
457 | draw_context.gc = drawing->gc; |
458 | draw_context.pango_layout = drawing->pango_layout; |
459 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
460 | draw_context.drawinfo.end.x = x; |
461 | |
1c736ed5 |
462 | draw_context.drawinfo.y.over = 1; |
463 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
464 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
465 | |
466 | draw_context.drawinfo.start.offset.over = 0; |
467 | draw_context.drawinfo.start.offset.middle = 0; |
468 | draw_context.drawinfo.start.offset.under = 0; |
469 | draw_context.drawinfo.end.offset.over = 0; |
470 | draw_context.drawinfo.end.offset.middle = 0; |
471 | draw_context.drawinfo.end.offset.under = 0; |
472 | |
473 | { |
474 | /* Draw the line */ |
9a1ec01b |
475 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
476 | draw_line((void*)&prop_line, (void*)&draw_context); |
477 | |
478 | } |
479 | /* become the last x position */ |
480 | hashed_process_data->x.middle = x; |
e72908ed |
481 | hashed_process_data->x.middle_used = TRUE; |
482 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
483 | |
484 | /* Calculate the next good time */ |
485 | convert_pixels_to_time(width, x+1, time_window, |
486 | &hashed_process_data->next_good_time); |
e800cf84 |
487 | } |
488 | } |
489 | } |
10a1069a |
490 | } |
e800cf84 |
491 | |
e38d9ea0 |
492 | tfc->target_pid = pid_in; |
493 | if(!filter || !filter->head || |
494 | lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
495 | tfc->t_context->t,tfc,NULL,NULL)) { |
10a1069a |
496 | /* For the pid_in */ |
497 | /* First, check if the current process is in the state computation |
498 | * process list. If it is there, that means we must add it right now and |
499 | * draw items from the beginning of the read for it. If it is not |
500 | * present, it's a new process and it was not present : it will |
501 | * be added after the state update. */ |
502 | LttvProcessState *process; |
800aa029 |
503 | process = lttv_state_find_process(ts, |
ae3d0f50 |
504 | tfs->cpu, pid_in); |
0f090e21 |
505 | guint trace_num = ts->parent.index; |
10a1069a |
506 | |
507 | if(process != NULL) { |
800aa029 |
508 | /* Well, the process existed : we must get it in the process hash |
10a1069a |
509 | * or add it, and draw its items. |
510 | */ |
511 | /* Add process to process list (if not present) */ |
1c736ed5 |
512 | guint pl_height = 0; |
10a1069a |
513 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
514 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
515 | LttTime birth = process->creation_time; |
e800cf84 |
516 | |
ac4e21cf |
517 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
518 | pid_in, |
ae3d0f50 |
519 | tfs->cpu, |
10a1069a |
520 | &birth, |
0f090e21 |
521 | trace_num); |
ac4e21cf |
522 | if(hashed_process_data == NULL) |
10a1069a |
523 | { |
524 | g_assert(pid_in == 0 || pid_in != process->ppid); |
525 | /* Process not present */ |
4e86ae2e |
526 | ProcessInfo *process_info; |
1c736ed5 |
527 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
528 | processlist_add(process_list, |
1c736ed5 |
529 | drawing, |
10a1069a |
530 | pid_in, |
fcc08e1e |
531 | process->tgid, |
ae3d0f50 |
532 | tfs->cpu, |
10a1069a |
533 | process->ppid, |
534 | &birth, |
0f090e21 |
535 | trace_num, |
f4b88a7d |
536 | process->name, |
7b5f6cf1 |
537 | process->brand, |
10a1069a |
538 | &pl_height, |
4e86ae2e |
539 | &process_info, |
10a1069a |
540 | &hashed_process_data); |
1c736ed5 |
541 | gtk_widget_set_size_request(drawing->drawing_area, |
542 | -1, |
543 | pl_height); |
544 | gtk_widget_queue_draw(drawing->drawing_area); |
545 | |
10a1069a |
546 | } |
40debf7b |
547 | //We could set the current process and hash here, but will be done |
548 | //by after schedchange hook |
10a1069a |
549 | |
550 | /* Now, the process is in the state hash and our own process hash. |
551 | * We definitely can draw the items related to the ending state. |
552 | */ |
b9a010a2 |
553 | |
b2743953 |
554 | if(ltt_time_compare(hashed_process_data->next_good_time, |
555 | evtime) > 0) |
10a1069a |
556 | { |
b2743953 |
557 | if(hashed_process_data->x.middle_marked == FALSE) { |
ac4e21cf |
558 | |
fd22065b |
559 | TimeWindow time_window = |
560 | lttvwindow_get_time_window(control_flow_data->tab); |
561 | #ifdef EXTRA_CHECK |
562 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
563 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
564 | return FALSE; |
fd22065b |
565 | #endif //EXTRA_CHECK |
d6fef890 |
566 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
567 | guint width = drawing->width; |
b2743953 |
568 | guint x; |
569 | convert_time_to_pixels( |
570 | time_window, |
571 | evtime, |
572 | width, |
573 | &x); |
574 | |
575 | /* Draw collision indicator */ |
576 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
577 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
578 | drawing->gc, |
579 | x, |
5bb606ce |
580 | COLLISION_POSITION(hashed_process_data->height)); |
b2743953 |
581 | hashed_process_data->x.middle_marked = TRUE; |
582 | } |
583 | } else { |
fd22065b |
584 | TimeWindow time_window = |
585 | lttvwindow_get_time_window(control_flow_data->tab); |
586 | #ifdef EXTRA_CHECK |
587 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
588 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
589 | return FALSE; |
fd22065b |
590 | #endif //EXTRA_CHECK |
d6fef890 |
591 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
592 | guint width = drawing->width; |
10a1069a |
593 | guint x; |
10a1069a |
594 | |
595 | convert_time_to_pixels( |
a18124ff |
596 | time_window, |
4b7dc462 |
597 | evtime, |
598 | width, |
599 | &x); |
10a1069a |
600 | |
10a1069a |
601 | |
4b7dc462 |
602 | /* Jump over draw if we are at the same x position */ |
e72908ed |
603 | if(x == hashed_process_data->x.middle && |
604 | hashed_process_data->x.middle_used) |
4b7dc462 |
605 | { |
e72908ed |
606 | if(hashed_process_data->x.middle_marked == FALSE) { |
607 | /* Draw collision indicator */ |
608 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
609 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
610 | drawing->gc, |
611 | x, |
5bb606ce |
612 | COLLISION_POSITION(hashed_process_data->height)); |
de4ea1ad |
613 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
614 | } |
4b7dc462 |
615 | /* jump */ |
616 | } else { |
617 | DrawContext draw_context; |
10a1069a |
618 | |
4b7dc462 |
619 | /* Now create the drawing context that will be used to draw |
620 | * items related to the last state. */ |
1c736ed5 |
621 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
622 | draw_context.gc = drawing->gc; |
623 | draw_context.pango_layout = drawing->pango_layout; |
624 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
625 | draw_context.drawinfo.end.x = x; |
10a1069a |
626 | |
1c736ed5 |
627 | draw_context.drawinfo.y.over = 1; |
628 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
629 | draw_context.drawinfo.y.under = hashed_process_data->height; |
10a1069a |
630 | |
4b7dc462 |
631 | draw_context.drawinfo.start.offset.over = 0; |
632 | draw_context.drawinfo.start.offset.middle = 0; |
633 | draw_context.drawinfo.start.offset.under = 0; |
634 | draw_context.drawinfo.end.offset.over = 0; |
635 | draw_context.drawinfo.end.offset.middle = 0; |
636 | draw_context.drawinfo.end.offset.under = 0; |
637 | |
638 | { |
639 | /* Draw the line */ |
9a1ec01b |
640 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
641 | draw_line((void*)&prop_line, (void*)&draw_context); |
642 | } |
643 | |
644 | |
645 | /* become the last x position */ |
646 | hashed_process_data->x.middle = x; |
e72908ed |
647 | hashed_process_data->x.middle_used = TRUE; |
648 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
649 | |
650 | /* Calculate the next good time */ |
651 | convert_pixels_to_time(width, x+1, time_window, |
652 | &hashed_process_data->next_good_time); |
4b7dc462 |
653 | } |
c8bba5fa |
654 | } |
8e680509 |
655 | } else |
656 | g_warning("Cannot find pin_in in schedchange %u", pid_in); |
b9a010a2 |
657 | } |
e38d9ea0 |
658 | tfc->target_pid = target_pid_saved; |
b9a010a2 |
659 | return 0; |
660 | |
661 | |
b9a010a2 |
662 | |
a56a1ba4 |
663 | |
51705146 |
664 | /* Text dump */ |
80a52ff8 |
665 | #ifdef DONTSHOW |
a56a1ba4 |
666 | GString *string = g_string_new("");; |
667 | gboolean field_names = TRUE, state = TRUE; |
80a52ff8 |
668 | |
e9a9c513 |
669 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
670 | g_string_append_printf(string,"\n"); |
671 | |
672 | if(state) { |
673 | g_string_append_printf(string, " %s", |
674 | g_quark_to_string(tfs->process->state->s)); |
675 | } |
676 | |
677 | g_info("%s",string->str); |
678 | |
a56a1ba4 |
679 | g_string_free(string, TRUE); |
680 | |
681 | /* End of text dump */ |
80a52ff8 |
682 | #endif //DONTSHOW |
50439712 |
683 | |
f0d936c0 |
684 | } |
685 | |
e92eabaf |
686 | /* after_schedchange_hook |
b9a010a2 |
687 | * |
688 | * The draw after hook is called by the reading API to have a |
689 | * particular event drawn on the screen. |
690 | * @param hook_data ControlFlowData structure of the viewer. |
691 | * @param call_data Event context. |
692 | * |
693 | * This function adds items to be drawn in a queue for each process. |
694 | * |
695 | */ |
e92eabaf |
696 | int after_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 |
697 | { |
dd455fb8 |
698 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
699 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
ca0f8a8e |
700 | ControlFlowData *control_flow_data = events_request->viewer_data; |
50439712 |
701 | |
a56a1ba4 |
702 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
50439712 |
703 | |
704 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
705 | |
348c6ba8 |
706 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
707 | |
b9a010a2 |
708 | LttEvent *e; |
2c82c4dc |
709 | e = ltt_tracefile_get_event(tfc->tf); |
b9a010a2 |
710 | |
e38d9ea0 |
711 | LttvFilter *filter = control_flow_data->filter; |
712 | if(filter != NULL && filter->head != NULL) |
713 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
714 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
715 | return FALSE; |
716 | |
b9a010a2 |
717 | LttTime evtime = ltt_event_time(e); |
b9a010a2 |
718 | |
10a1069a |
719 | /* Add process to process list (if not present) */ |
2eef04b5 |
720 | LttvProcessState *process_in; |
10a1069a |
721 | LttTime birth; |
1c736ed5 |
722 | guint pl_height = 0; |
10a1069a |
723 | HashedProcessData *hashed_process_data_in = NULL; |
b9a010a2 |
724 | |
5c230fc4 |
725 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
726 | |
727 | guint pid_in; |
728 | { |
729 | guint pid_out; |
04348950 |
730 | pid_out = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
731 | pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); |
10a1069a |
732 | } |
b9a010a2 |
733 | |
734 | |
10a1069a |
735 | /* Find process pid_in in the list... */ |
348c6ba8 |
736 | //process_in = lttv_state_find_process(ts, ANY_CPU, pid_in); |
737 | //process_in = tfs->process; |
ae3d0f50 |
738 | guint cpu = tfs->cpu; |
0f090e21 |
739 | guint trace_num = ts->parent.index; |
348c6ba8 |
740 | process_in = ts->running_process[cpu]; |
10a1069a |
741 | /* It should exist, because we are after the state update. */ |
96947fcf |
742 | #ifdef EXTRA_CHECK |
10a1069a |
743 | g_assert(process_in != NULL); |
96947fcf |
744 | #endif //EXTRA_CHECK |
10a1069a |
745 | birth = process_in->creation_time; |
b9a010a2 |
746 | |
ac4e21cf |
747 | hashed_process_data_in = processlist_get_process_data(process_list, |
10a1069a |
748 | pid_in, |
348c6ba8 |
749 | process_in->cpu, |
10a1069a |
750 | &birth, |
0f090e21 |
751 | trace_num); |
ac4e21cf |
752 | if(hashed_process_data_in == NULL) |
10a1069a |
753 | { |
754 | g_assert(pid_in == 0 || pid_in != process_in->ppid); |
4e86ae2e |
755 | ProcessInfo *process_info; |
1c736ed5 |
756 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
757 | /* Process not present */ |
758 | processlist_add(process_list, |
1c736ed5 |
759 | drawing, |
10a1069a |
760 | pid_in, |
fcc08e1e |
761 | process_in->tgid, |
348c6ba8 |
762 | process_in->cpu, |
10a1069a |
763 | process_in->ppid, |
764 | &birth, |
0f090e21 |
765 | trace_num, |
f4b88a7d |
766 | process_in->name, |
7b5f6cf1 |
767 | process_in->brand, |
10a1069a |
768 | &pl_height, |
4e86ae2e |
769 | &process_info, |
10a1069a |
770 | &hashed_process_data_in); |
1c736ed5 |
771 | gtk_widget_set_size_request(drawing->drawing_area, |
772 | -1, |
773 | pl_height); |
774 | gtk_widget_queue_draw(drawing->drawing_area); |
b9a010a2 |
775 | } |
40debf7b |
776 | /* Set the current process */ |
0f090e21 |
777 | process_list->current_hash_data[trace_num][process_in->cpu] = |
40debf7b |
778 | hashed_process_data_in; |
10a1069a |
779 | |
b2743953 |
780 | if(ltt_time_compare(hashed_process_data_in->next_good_time, |
781 | evtime) <= 0) |
782 | { |
fd22065b |
783 | TimeWindow time_window = |
784 | lttvwindow_get_time_window(control_flow_data->tab); |
785 | |
786 | #ifdef EXTRA_CHECK |
787 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
788 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
789 | return FALSE; |
fd22065b |
790 | #endif //EXTRA_CHECK |
d6fef890 |
791 | Drawing_t *drawing = control_flow_data->drawing; |
792 | guint width = drawing->width; |
b2743953 |
793 | guint new_x; |
794 | |
795 | convert_time_to_pixels( |
796 | time_window, |
797 | evtime, |
798 | width, |
799 | &new_x); |
e72908ed |
800 | |
b2743953 |
801 | if(hashed_process_data_in->x.middle != new_x) { |
802 | hashed_process_data_in->x.middle = new_x; |
803 | hashed_process_data_in->x.middle_used = FALSE; |
804 | hashed_process_data_in->x.middle_marked = FALSE; |
805 | } |
806 | } |
b9a010a2 |
807 | return 0; |
4a24fa1f |
808 | } |
b9a010a2 |
809 | |
810 | |
811 | |
e72908ed |
812 | |
4a24fa1f |
813 | /* before_execmode_hook |
814 | * |
815 | * This function basically draw lines and icons. Two types of lines are drawn : |
816 | * one small (3 pixels?) representing the state of the process and the second |
817 | * type is thicker (10 pixels?) representing on which CPU a process is running |
818 | * (and this only in running state). |
819 | * |
820 | * Extremums of the lines : |
821 | * x_min : time of the last event context for this process kept in memory. |
822 | * x_max : time of the current event. |
823 | * y : middle of the process in the process list. The process is found in the |
824 | * list, therefore is it's position in pixels. |
825 | * |
826 | * The choice of lines'color is defined by the context of the last event for this |
827 | * process. |
828 | */ |
829 | |
e72908ed |
830 | |
4a24fa1f |
831 | int before_execmode_hook(void *hook_data, void *call_data) |
832 | { |
dd455fb8 |
833 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
834 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
b9a010a2 |
835 | ControlFlowData *control_flow_data = events_request->viewer_data; |
836 | |
837 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
838 | |
839 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
b9a010a2 |
840 | |
4a24fa1f |
841 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
842 | |
50439712 |
843 | LttEvent *e; |
4a24fa1f |
844 | e = ltt_tracefile_get_event(tfc->tf); |
50439712 |
845 | |
e38d9ea0 |
846 | LttvFilter *filter = control_flow_data->filter; |
847 | if(filter != NULL && filter->head != NULL) |
848 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
849 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
850 | return FALSE; |
851 | |
9444deae |
852 | LttTime evtime = ltt_event_time(e); |
9444deae |
853 | |
4a24fa1f |
854 | /* we are in a execmode, before the state update. We must draw the |
855 | * items corresponding to the state before it changes : now is the right |
856 | * time to do it. |
857 | */ |
858 | /* For the pid */ |
859 | //LttvProcessState *process = tfs->process; |
ae3d0f50 |
860 | guint cpu = tfs->cpu; |
0f090e21 |
861 | guint trace_num = ts->parent.index; |
4a24fa1f |
862 | LttvProcessState *process = ts->running_process[cpu]; |
863 | g_assert(process != NULL); |
23093869 |
864 | |
10a1069a |
865 | guint pid = process->pid; |
23093869 |
866 | |
10a1069a |
867 | /* Well, the process_out existed : we must get it in the process hash |
868 | * or add it, and draw its items. |
869 | */ |
870 | /* Add process to process list (if not present) */ |
1c736ed5 |
871 | guint pl_height = 0; |
10a1069a |
872 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
873 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
874 | LttTime birth = process->creation_time; |
40debf7b |
875 | |
0f090e21 |
876 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
877 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
40debf7b |
878 | } else { |
ac4e21cf |
879 | hashed_process_data = processlist_get_process_data(process_list, |
40debf7b |
880 | pid, |
348c6ba8 |
881 | process->cpu, |
40debf7b |
882 | &birth, |
0f090e21 |
883 | trace_num); |
1d1df11d |
884 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
885 | { |
886 | g_assert(pid == 0 || pid != process->ppid); |
887 | ProcessInfo *process_info; |
888 | /* Process not present */ |
1c736ed5 |
889 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
890 | processlist_add(process_list, |
1c736ed5 |
891 | drawing, |
40debf7b |
892 | pid, |
fcc08e1e |
893 | process->tgid, |
348c6ba8 |
894 | process->cpu, |
40debf7b |
895 | process->ppid, |
896 | &birth, |
0f090e21 |
897 | trace_num, |
f4b88a7d |
898 | process->name, |
7b5f6cf1 |
899 | process->brand, |
40debf7b |
900 | &pl_height, |
901 | &process_info, |
902 | &hashed_process_data); |
1c736ed5 |
903 | gtk_widget_set_size_request(drawing->drawing_area, |
904 | -1, |
905 | pl_height); |
906 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
907 | } |
908 | /* Set the current process */ |
0f090e21 |
909 | process_list->current_hash_data[trace_num][process->cpu] = |
40debf7b |
910 | hashed_process_data; |
10a1069a |
911 | } |
23093869 |
912 | |
10a1069a |
913 | /* Now, the process is in the state hash and our own process hash. |
914 | * We definitely can draw the items related to the ending state. |
915 | */ |
b2743953 |
916 | |
1d1df11d |
917 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
918 | evtime) > 0)) |
10a1069a |
919 | { |
1d1df11d |
920 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
fd22065b |
921 | TimeWindow time_window = |
922 | lttvwindow_get_time_window(control_flow_data->tab); |
923 | |
924 | #ifdef EXTRA_CHECK |
925 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
926 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
927 | return FALSE; |
fd22065b |
928 | #endif //EXTRA_CHECK |
d6fef890 |
929 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
930 | guint width = drawing->width; |
b2743953 |
931 | guint x; |
932 | convert_time_to_pixels( |
933 | time_window, |
934 | evtime, |
935 | width, |
936 | &x); |
937 | |
938 | /* Draw collision indicator */ |
939 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
940 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
941 | drawing->gc, |
942 | x, |
5bb606ce |
943 | COLLISION_POSITION(hashed_process_data->height)); |
b2743953 |
944 | hashed_process_data->x.middle_marked = TRUE; |
945 | } |
946 | } else { |
fd22065b |
947 | TimeWindow time_window = |
948 | lttvwindow_get_time_window(control_flow_data->tab); |
949 | |
950 | #ifdef EXTRA_CHECK |
951 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
952 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
953 | return FALSE; |
fd22065b |
954 | #endif //EXTRA_CHECK |
d6fef890 |
955 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
956 | guint width = drawing->width; |
10a1069a |
957 | guint x; |
dbd243b1 |
958 | |
10a1069a |
959 | convert_time_to_pixels( |
a18124ff |
960 | time_window, |
10a1069a |
961 | evtime, |
962 | width, |
963 | &x); |
dbd243b1 |
964 | |
23093869 |
965 | |
4b7dc462 |
966 | /* Jump over draw if we are at the same x position */ |
1d1df11d |
967 | if(unlikely(x == hashed_process_data->x.middle && |
968 | hashed_process_data->x.middle_used)) |
10a1069a |
969 | { |
1d1df11d |
970 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
e72908ed |
971 | /* Draw collision indicator */ |
972 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
973 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
974 | drawing->gc, |
975 | x, |
5bb606ce |
976 | COLLISION_POSITION(hashed_process_data->height)); |
de4ea1ad |
977 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
978 | } |
4b7dc462 |
979 | /* jump */ |
980 | } else { |
981 | |
982 | DrawContext draw_context; |
983 | /* Now create the drawing context that will be used to draw |
984 | * items related to the last state. */ |
1c736ed5 |
985 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
986 | draw_context.gc = drawing->gc; |
987 | draw_context.pango_layout = drawing->pango_layout; |
9a1ec01b |
988 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
4b7dc462 |
989 | draw_context.drawinfo.end.x = x; |
990 | |
1c736ed5 |
991 | draw_context.drawinfo.y.over = 1; |
992 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
993 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
994 | |
995 | draw_context.drawinfo.start.offset.over = 0; |
996 | draw_context.drawinfo.start.offset.middle = 0; |
997 | draw_context.drawinfo.start.offset.under = 0; |
998 | draw_context.drawinfo.end.offset.over = 0; |
999 | draw_context.drawinfo.end.offset.middle = 0; |
1000 | draw_context.drawinfo.end.offset.under = 0; |
1001 | |
1002 | { |
1003 | /* Draw the line */ |
9a1ec01b |
1004 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
1005 | draw_line((void*)&prop_line, (void*)&draw_context); |
23093869 |
1006 | |
4b7dc462 |
1007 | } |
1008 | /* become the last x position */ |
9a1ec01b |
1009 | hashed_process_data->x.middle = x; |
e72908ed |
1010 | hashed_process_data->x.middle_used = TRUE; |
1011 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
1012 | |
1013 | /* Calculate the next good time */ |
1014 | convert_pixels_to_time(width, x+1, time_window, |
1015 | &hashed_process_data->next_good_time); |
23093869 |
1016 | } |
1017 | } |
1018 | |
1019 | return 0; |
1020 | } |
1021 | |
4a24fa1f |
1022 | /* before_process_exit_hook |
23093869 |
1023 | * |
4a24fa1f |
1024 | * Draw lines for process event. |
1025 | * |
23093869 |
1026 | * @param hook_data ControlFlowData structure of the viewer. |
1027 | * @param call_data Event context. |
1028 | * |
1029 | * This function adds items to be drawn in a queue for each process. |
1030 | * |
1031 | */ |
8869ac08 |
1032 | |
1033 | |
4a24fa1f |
1034 | int before_process_exit_hook(void *hook_data, void *call_data) |
1035 | { |
dd455fb8 |
1036 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1037 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
4a24fa1f |
1038 | |
23093869 |
1039 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1040 | |
1041 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1042 | |
1043 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
23093869 |
1044 | |
4a24fa1f |
1045 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1046 | |
23093869 |
1047 | LttEvent *e; |
2c82c4dc |
1048 | e = ltt_tracefile_get_event(tfc->tf); |
23093869 |
1049 | |
e38d9ea0 |
1050 | LttvFilter *filter = control_flow_data->filter; |
1051 | if(filter != NULL && filter->head != NULL) |
1052 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1053 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1054 | return FALSE; |
1055 | |
23093869 |
1056 | LttTime evtime = ltt_event_time(e); |
23093869 |
1057 | |
10a1069a |
1058 | /* Add process to process list (if not present) */ |
4a24fa1f |
1059 | //LttvProcessState *process = tfs->process; |
ae3d0f50 |
1060 | guint cpu = tfs->cpu; |
0f090e21 |
1061 | guint trace_num = ts->parent.index; |
4a24fa1f |
1062 | LttvProcessState *process = ts->running_process[cpu]; |
1063 | guint pid = process->pid; |
10a1069a |
1064 | LttTime birth; |
1c736ed5 |
1065 | guint pl_height = 0; |
10a1069a |
1066 | HashedProcessData *hashed_process_data = NULL; |
23093869 |
1067 | |
5c230fc4 |
1068 | ProcessList *process_list = control_flow_data->process_list; |
4a24fa1f |
1069 | |
10a1069a |
1070 | g_assert(process != NULL); |
23093869 |
1071 | |
10a1069a |
1072 | birth = process->creation_time; |
23093869 |
1073 | |
0f090e21 |
1074 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
1075 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
40debf7b |
1076 | } else { |
ac4e21cf |
1077 | hashed_process_data = processlist_get_process_data(process_list, |
4a24fa1f |
1078 | pid, |
1079 | process->cpu, |
1080 | &birth, |
0f090e21 |
1081 | trace_num); |
1d1df11d |
1082 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
1083 | { |
1084 | g_assert(pid == 0 || pid != process->ppid); |
1085 | /* Process not present */ |
1c736ed5 |
1086 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
1087 | ProcessInfo *process_info; |
1088 | processlist_add(process_list, |
1c736ed5 |
1089 | drawing, |
40debf7b |
1090 | pid, |
fcc08e1e |
1091 | process->tgid, |
4a24fa1f |
1092 | process->cpu, |
40debf7b |
1093 | process->ppid, |
1094 | &birth, |
0f090e21 |
1095 | trace_num, |
4a24fa1f |
1096 | process->name, |
7b5f6cf1 |
1097 | process->brand, |
40debf7b |
1098 | &pl_height, |
1099 | &process_info, |
1100 | &hashed_process_data); |
4a24fa1f |
1101 | gtk_widget_set_size_request(drawing->drawing_area, |
1102 | -1, |
1103 | pl_height); |
1104 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
1105 | } |
23093869 |
1106 | } |
40debf7b |
1107 | |
4a24fa1f |
1108 | /* Now, the process is in the state hash and our own process hash. |
1109 | * We definitely can draw the items related to the ending state. |
1110 | */ |
1111 | |
1112 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
1113 | evtime) > 0)) |
b2743953 |
1114 | { |
4a24fa1f |
1115 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
1116 | TimeWindow time_window = |
1117 | lttvwindow_get_time_window(control_flow_data->tab); |
1118 | |
1119 | #ifdef EXTRA_CHECK |
1120 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1121 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
1122 | return FALSE; |
4a24fa1f |
1123 | #endif //EXTRA_CHECK |
1124 | Drawing_t *drawing = control_flow_data->drawing; |
1125 | guint width = drawing->width; |
1126 | guint x; |
1127 | convert_time_to_pixels( |
1128 | time_window, |
1129 | evtime, |
1130 | width, |
1131 | &x); |
1132 | |
1133 | /* Draw collision indicator */ |
1134 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1135 | gdk_draw_point(hashed_process_data->pixmap, |
1136 | drawing->gc, |
1137 | x, |
5bb606ce |
1138 | COLLISION_POSITION(hashed_process_data->height)); |
4a24fa1f |
1139 | hashed_process_data->x.middle_marked = TRUE; |
1140 | } |
1141 | } else { |
fd22065b |
1142 | TimeWindow time_window = |
1143 | lttvwindow_get_time_window(control_flow_data->tab); |
1144 | |
1145 | #ifdef EXTRA_CHECK |
1146 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1147 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
1148 | return FALSE; |
fd22065b |
1149 | #endif //EXTRA_CHECK |
d6fef890 |
1150 | Drawing_t *drawing = control_flow_data->drawing; |
1151 | guint width = drawing->width; |
4a24fa1f |
1152 | guint x; |
1153 | |
2c82c4dc |
1154 | convert_time_to_pixels( |
1155 | time_window, |
1156 | evtime, |
1157 | width, |
1158 | &x); |
1159 | |
b2743953 |
1160 | |
2c82c4dc |
1161 | /* Jump over draw if we are at the same x position */ |
1162 | if(unlikely(x == hashed_process_data->x.middle && |
1163 | hashed_process_data->x.middle_used)) |
1164 | { |
1165 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
b2743953 |
1166 | /* Draw collision indicator */ |
1167 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
1168 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
1169 | drawing->gc, |
1170 | x, |
5bb606ce |
1171 | COLLISION_POSITION(hashed_process_data->height)); |
b2743953 |
1172 | hashed_process_data->x.middle_marked = TRUE; |
1173 | } |
2c82c4dc |
1174 | /* jump */ |
b2743953 |
1175 | } else { |
2c82c4dc |
1176 | DrawContext draw_context; |
fd22065b |
1177 | |
2c82c4dc |
1178 | /* Now create the drawing context that will be used to draw |
1179 | * items related to the last state. */ |
1180 | draw_context.drawable = hashed_process_data->pixmap; |
1181 | draw_context.gc = drawing->gc; |
1182 | draw_context.pango_layout = drawing->pango_layout; |
1183 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
1184 | draw_context.drawinfo.end.x = x; |
dbd243b1 |
1185 | |
2c82c4dc |
1186 | draw_context.drawinfo.y.over = 1; |
1187 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
1188 | draw_context.drawinfo.y.under = hashed_process_data->height; |
dbd243b1 |
1189 | |
2c82c4dc |
1190 | draw_context.drawinfo.start.offset.over = 0; |
1191 | draw_context.drawinfo.start.offset.middle = 0; |
1192 | draw_context.drawinfo.start.offset.under = 0; |
1193 | draw_context.drawinfo.end.offset.over = 0; |
1194 | draw_context.drawinfo.end.offset.middle = 0; |
1195 | draw_context.drawinfo.end.offset.under = 0; |
dbd243b1 |
1196 | |
2c82c4dc |
1197 | { |
1198 | /* Draw the line */ |
1199 | PropertiesLine prop_line = prepare_s_e_line(process); |
1200 | draw_line((void*)&prop_line, (void*)&draw_context); |
dbd243b1 |
1201 | |
2c82c4dc |
1202 | } |
1203 | /* become the last x position */ |
1204 | hashed_process_data->x.middle = x; |
1205 | hashed_process_data->x.middle_used = TRUE; |
1206 | hashed_process_data->x.middle_marked = FALSE; |
dbd243b1 |
1207 | |
2c82c4dc |
1208 | /* Calculate the next good time */ |
1209 | convert_pixels_to_time(width, x+1, time_window, |
1210 | &hashed_process_data->next_good_time); |
1211 | } |
1212 | } |
1213 | |
1214 | return 0; |
1215 | |
1216 | } |
1217 | |
1218 | |
1219 | |
1220 | /* before_process_release_hook |
1221 | * |
1222 | * Draw lines for process event. |
1223 | * |
1224 | * @param hook_data ControlFlowData structure of the viewer. |
1225 | * @param call_data Event context. |
1226 | * |
1227 | * This function adds items to be drawn in a queue for each process. |
1228 | * |
1229 | */ |
1230 | |
1231 | |
1232 | int before_process_release_hook(void *hook_data, void *call_data) |
1233 | { |
dd455fb8 |
1234 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1235 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
2c82c4dc |
1236 | |
1237 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1238 | |
1239 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1240 | |
1241 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1242 | |
348c6ba8 |
1243 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1244 | |
2c82c4dc |
1245 | LttEvent *e; |
1246 | e = ltt_tracefile_get_event(tfc->tf); |
1247 | |
e38d9ea0 |
1248 | LttvFilter *filter = control_flow_data->filter; |
1249 | if(filter != NULL && filter->head != NULL) |
1250 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1251 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1252 | return FALSE; |
1253 | |
2c82c4dc |
1254 | LttTime evtime = ltt_event_time(e); |
1255 | |
0f090e21 |
1256 | guint trace_num = ts->parent.index; |
2c82c4dc |
1257 | |
1258 | guint pid; |
1259 | { |
04348950 |
1260 | pid = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
2c82c4dc |
1261 | } |
1262 | |
1263 | /* Add process to process list (if not present) */ |
1264 | /* Don't care about the process if it's not in the state hash already : |
1265 | * that means a process that has never done anything in the trace and |
1266 | * unknown suddently gets destroyed : no state meaningful to show. */ |
348c6ba8 |
1267 | LttvProcessState *process = lttv_state_find_process(ts, ANY_CPU, pid); |
2c82c4dc |
1268 | |
1269 | if(process != NULL) { |
1270 | LttTime birth; |
1271 | guint pl_height = 0; |
1272 | HashedProcessData *hashed_process_data = NULL; |
1273 | |
1274 | ProcessList *process_list = control_flow_data->process_list; |
1275 | |
1276 | birth = process->creation_time; |
1277 | |
1278 | /* Cannot use current process : this event happens on another process, |
1279 | * action done by the parent. */ |
1280 | hashed_process_data = processlist_get_process_data(process_list, |
1281 | pid, |
348c6ba8 |
1282 | process->cpu, |
2c82c4dc |
1283 | &birth, |
0f090e21 |
1284 | trace_num); |
2c82c4dc |
1285 | if(unlikely(hashed_process_data == NULL)) |
3311444c |
1286 | /* |
1287 | * Process already been scheduled out EXIT_DEAD, not in the process list |
1288 | * anymore. Just return. |
1289 | */ |
1290 | return FALSE; |
2c82c4dc |
1291 | |
1292 | /* Now, the process is in the state hash and our own process hash. |
1293 | * We definitely can draw the items related to the ending state. |
1294 | */ |
1295 | |
1296 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
1297 | evtime) > 0)) |
1298 | { |
1299 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
1300 | TimeWindow time_window = |
1301 | lttvwindow_get_time_window(control_flow_data->tab); |
1302 | |
1303 | #ifdef EXTRA_CHECK |
1304 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1305 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
1306 | return FALSE; |
2c82c4dc |
1307 | #endif //EXTRA_CHECK |
1308 | Drawing_t *drawing = control_flow_data->drawing; |
1309 | guint width = drawing->width; |
1310 | guint x; |
1311 | convert_time_to_pixels( |
1312 | time_window, |
1313 | evtime, |
1314 | width, |
1315 | &x); |
1316 | |
1317 | /* Draw collision indicator */ |
1318 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1319 | gdk_draw_point(hashed_process_data->pixmap, |
1320 | drawing->gc, |
1321 | x, |
5bb606ce |
1322 | COLLISION_POSITION(hashed_process_data->height)); |
2c82c4dc |
1323 | hashed_process_data->x.middle_marked = TRUE; |
1324 | } |
1325 | } else { |
1326 | TimeWindow time_window = |
1327 | lttvwindow_get_time_window(control_flow_data->tab); |
1328 | |
1329 | #ifdef EXTRA_CHECK |
1330 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
4a24fa1f |
1331 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
1332 | return FALSE; |
2da61677 |
1333 | #endif //EXTRA_CHECK |
4a24fa1f |
1334 | Drawing_t *drawing = control_flow_data->drawing; |
1335 | guint width = drawing->width; |
1336 | guint x; |
1337 | |
1338 | convert_time_to_pixels( |
1339 | time_window, |
1340 | evtime, |
1341 | width, |
1342 | &x); |
1343 | |
2da61677 |
1344 | |
4a24fa1f |
1345 | /* Jump over draw if we are at the same x position */ |
1346 | if(unlikely(x == hashed_process_data->x.middle && |
1347 | hashed_process_data->x.middle_used)) |
1348 | { |
1349 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2da61677 |
1350 | /* Draw collision indicator */ |
1351 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1352 | gdk_draw_point(hashed_process_data->pixmap, |
1353 | drawing->gc, |
1354 | x, |
5bb606ce |
1355 | COLLISION_POSITION(hashed_process_data->height)); |
2da61677 |
1356 | hashed_process_data->x.middle_marked = TRUE; |
1357 | } |
4a24fa1f |
1358 | /* jump */ |
2da61677 |
1359 | } else { |
4a24fa1f |
1360 | DrawContext draw_context; |
2da61677 |
1361 | |
4a24fa1f |
1362 | /* Now create the drawing context that will be used to draw |
1363 | * items related to the last state. */ |
1364 | draw_context.drawable = hashed_process_data->pixmap; |
1365 | draw_context.gc = drawing->gc; |
1366 | draw_context.pango_layout = drawing->pango_layout; |
1367 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
1368 | draw_context.drawinfo.end.x = x; |
2da61677 |
1369 | |
4a24fa1f |
1370 | draw_context.drawinfo.y.over = 1; |
1371 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
1372 | draw_context.drawinfo.y.under = hashed_process_data->height; |
2da61677 |
1373 | |
4a24fa1f |
1374 | draw_context.drawinfo.start.offset.over = 0; |
1375 | draw_context.drawinfo.start.offset.middle = 0; |
1376 | draw_context.drawinfo.start.offset.under = 0; |
1377 | draw_context.drawinfo.end.offset.over = 0; |
1378 | draw_context.drawinfo.end.offset.middle = 0; |
1379 | draw_context.drawinfo.end.offset.under = 0; |
2da61677 |
1380 | |
4a24fa1f |
1381 | { |
1382 | /* Draw the line */ |
1383 | PropertiesLine prop_line = prepare_s_e_line(process); |
1384 | draw_line((void*)&prop_line, (void*)&draw_context); |
2da61677 |
1385 | |
2da61677 |
1386 | } |
4a24fa1f |
1387 | /* become the last x position */ |
1388 | hashed_process_data->x.middle = x; |
1389 | hashed_process_data->x.middle_used = TRUE; |
1390 | hashed_process_data->x.middle_marked = FALSE; |
1391 | |
1392 | /* Calculate the next good time */ |
1393 | convert_pixels_to_time(width, x+1, time_window, |
1394 | &hashed_process_data->next_good_time); |
2da61677 |
1395 | } |
1396 | } |
dbd243b1 |
1397 | } |
dbd243b1 |
1398 | |
4a24fa1f |
1399 | return 0; |
dbd243b1 |
1400 | } |
1401 | |
4a24fa1f |
1402 | |
2c82c4dc |
1403 | |
1404 | |
1405 | |
1406 | /* after_process_fork_hook |
1407 | * |
1408 | * Create the processlist entry for the child process. Put the last |
1409 | * position in x at the current time value. |
1410 | * |
1411 | * @param hook_data ControlFlowData structure of the viewer. |
1412 | * @param call_data Event context. |
1413 | * |
1414 | * This function adds items to be drawn in a queue for each process. |
1415 | * |
1416 | */ |
1417 | int after_process_fork_hook(void *hook_data, void *call_data) |
1418 | { |
dd455fb8 |
1419 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1420 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
2c82c4dc |
1421 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1422 | |
1423 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1424 | |
1425 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1426 | |
348c6ba8 |
1427 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1428 | |
2c82c4dc |
1429 | LttEvent *e; |
1430 | e = ltt_tracefile_get_event(tfc->tf); |
1431 | |
e38d9ea0 |
1432 | LttvFilter *filter = control_flow_data->filter; |
1433 | if(filter != NULL && filter->head != NULL) |
1434 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1435 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1436 | return FALSE; |
1437 | |
2c82c4dc |
1438 | LttTime evtime = ltt_event_time(e); |
1439 | |
1440 | guint child_pid; |
1441 | { |
04348950 |
1442 | child_pid = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); |
2c82c4dc |
1443 | } |
1444 | |
1445 | /* Add process to process list (if not present) */ |
1446 | LttvProcessState *process_child; |
1447 | LttTime birth; |
1448 | guint pl_height = 0; |
1449 | HashedProcessData *hashed_process_data_child = NULL; |
1450 | |
1451 | ProcessList *process_list = control_flow_data->process_list; |
1452 | |
1453 | /* Find child in the list... */ |
348c6ba8 |
1454 | process_child = lttv_state_find_process(ts, ANY_CPU, child_pid); |
2c82c4dc |
1455 | /* It should exist, because we are after the state update. */ |
1456 | g_assert(process_child != NULL); |
1457 | |
1458 | birth = process_child->creation_time; |
0f090e21 |
1459 | guint trace_num = ts->parent.index; |
2c82c4dc |
1460 | |
1461 | /* Cannot use current process, because this action is done by the parent |
1462 | * on its child. */ |
1463 | hashed_process_data_child = processlist_get_process_data(process_list, |
1464 | child_pid, |
348c6ba8 |
1465 | process_child->cpu, |
2c82c4dc |
1466 | &birth, |
0f090e21 |
1467 | trace_num); |
2c82c4dc |
1468 | if(likely(hashed_process_data_child == NULL)) |
1469 | { |
1470 | g_assert(child_pid == 0 || child_pid != process_child->ppid); |
1471 | /* Process not present */ |
1472 | Drawing_t *drawing = control_flow_data->drawing; |
2c82c4dc |
1473 | ProcessInfo *process_info; |
1474 | processlist_add(process_list, |
1475 | drawing, |
1476 | child_pid, |
fcc08e1e |
1477 | process_child->tgid, |
348c6ba8 |
1478 | process_child->cpu, |
2c82c4dc |
1479 | process_child->ppid, |
1480 | &birth, |
0f090e21 |
1481 | trace_num, |
f4b88a7d |
1482 | process_child->name, |
7b5f6cf1 |
1483 | process_child->brand, |
2c82c4dc |
1484 | &pl_height, |
1485 | &process_info, |
1486 | &hashed_process_data_child); |
1487 | gtk_widget_set_size_request(drawing->drawing_area, |
1488 | -1, |
1489 | pl_height); |
1490 | gtk_widget_queue_draw(drawing->drawing_area); |
fcc08e1e |
1491 | } else { |
1492 | processlist_set_ppid(process_list, process_child->ppid, |
1493 | hashed_process_data_child); |
1494 | processlist_set_tgid(process_list, process_child->tgid, |
1495 | hashed_process_data_child); |
2c82c4dc |
1496 | } |
1497 | |
1498 | |
1499 | if(likely(ltt_time_compare(hashed_process_data_child->next_good_time, |
1500 | evtime) <= 0)) |
1501 | { |
1502 | TimeWindow time_window = |
1503 | lttvwindow_get_time_window(control_flow_data->tab); |
1504 | |
1505 | #ifdef EXTRA_CHECK |
1506 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1507 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
1508 | return FALSE; |
2c82c4dc |
1509 | #endif //EXTRA_CHECK |
1510 | Drawing_t *drawing = control_flow_data->drawing; |
1511 | guint width = drawing->width; |
1512 | guint new_x; |
1513 | convert_time_to_pixels( |
1514 | time_window, |
1515 | evtime, |
1516 | width, |
1517 | &new_x); |
1518 | |
1519 | if(likely(hashed_process_data_child->x.over != new_x)) { |
1520 | hashed_process_data_child->x.over = new_x; |
1521 | hashed_process_data_child->x.over_used = FALSE; |
1522 | hashed_process_data_child->x.over_marked = FALSE; |
1523 | } |
1524 | if(likely(hashed_process_data_child->x.middle != new_x)) { |
1525 | hashed_process_data_child->x.middle = new_x; |
1526 | hashed_process_data_child->x.middle_used = FALSE; |
1527 | hashed_process_data_child->x.middle_marked = FALSE; |
1528 | } |
1529 | if(likely(hashed_process_data_child->x.under != new_x)) { |
1530 | hashed_process_data_child->x.under = new_x; |
1531 | hashed_process_data_child->x.under_used = FALSE; |
1532 | hashed_process_data_child->x.under_marked = FALSE; |
1533 | } |
1534 | } |
3311444c |
1535 | return FALSE; |
2c82c4dc |
1536 | } |
1537 | |
1538 | |
1539 | |
1540 | /* after_process_exit_hook |
1541 | * |
1542 | * Create the processlist entry for the child process. Put the last |
1543 | * position in x at the current time value. |
1544 | * |
1545 | * @param hook_data ControlFlowData structure of the viewer. |
1546 | * @param call_data Event context. |
1547 | * |
1548 | * This function adds items to be drawn in a queue for each process. |
1549 | * |
1550 | */ |
1551 | int after_process_exit_hook(void *hook_data, void *call_data) |
1552 | { |
dd455fb8 |
1553 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1554 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
2c82c4dc |
1555 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1556 | |
1557 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1558 | |
1559 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1560 | |
348c6ba8 |
1561 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1562 | |
2c82c4dc |
1563 | LttEvent *e; |
1564 | e = ltt_tracefile_get_event(tfc->tf); |
1565 | |
e38d9ea0 |
1566 | LttvFilter *filter = control_flow_data->filter; |
1567 | if(filter != NULL && filter->head != NULL) |
1568 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1569 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1570 | return FALSE; |
1571 | |
2c82c4dc |
1572 | LttTime evtime = ltt_event_time(e); |
1573 | |
1574 | /* Add process to process list (if not present) */ |
348c6ba8 |
1575 | //LttvProcessState *process = tfs->process; |
ae3d0f50 |
1576 | guint cpu = tfs->cpu; |
0f090e21 |
1577 | guint trace_num = ts->parent.index; |
348c6ba8 |
1578 | LttvProcessState *process = ts->running_process[cpu]; |
1579 | |
1580 | /* It should exist, because we are after the state update. */ |
1581 | g_assert(process != NULL); |
1582 | |
2c82c4dc |
1583 | guint pid = process->pid; |
1584 | LttTime birth; |
1585 | guint pl_height = 0; |
1586 | HashedProcessData *hashed_process_data = NULL; |
1587 | |
1588 | ProcessList *process_list = control_flow_data->process_list; |
1589 | |
2c82c4dc |
1590 | birth = process->creation_time; |
1591 | |
0f090e21 |
1592 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){ |
1593 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
2c82c4dc |
1594 | } else { |
1595 | hashed_process_data = processlist_get_process_data(process_list, |
1596 | pid, |
348c6ba8 |
1597 | process->cpu, |
2c82c4dc |
1598 | &birth, |
0f090e21 |
1599 | trace_num); |
2c82c4dc |
1600 | if(unlikely(hashed_process_data == NULL)) |
1601 | { |
1602 | g_assert(pid == 0 || pid != process->ppid); |
1603 | /* Process not present */ |
1604 | Drawing_t *drawing = control_flow_data->drawing; |
2c82c4dc |
1605 | ProcessInfo *process_info; |
1606 | processlist_add(process_list, |
1607 | drawing, |
1608 | pid, |
fcc08e1e |
1609 | process->tgid, |
348c6ba8 |
1610 | process->cpu, |
2c82c4dc |
1611 | process->ppid, |
1612 | &birth, |
0f090e21 |
1613 | trace_num, |
f4b88a7d |
1614 | process->name, |
7b5f6cf1 |
1615 | process->brand, |
2c82c4dc |
1616 | &pl_height, |
1617 | &process_info, |
1618 | &hashed_process_data); |
1619 | gtk_widget_set_size_request(drawing->drawing_area, |
1620 | -1, |
1621 | pl_height); |
1622 | gtk_widget_queue_draw(drawing->drawing_area); |
1623 | } |
1624 | |
1625 | /* Set the current process */ |
0f090e21 |
1626 | process_list->current_hash_data[trace_num][process->cpu] = |
2c82c4dc |
1627 | hashed_process_data; |
1628 | } |
1629 | |
1630 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
1631 | evtime) <= 0)) |
1632 | { |
1633 | TimeWindow time_window = |
1634 | lttvwindow_get_time_window(control_flow_data->tab); |
dbd243b1 |
1635 | |
2c82c4dc |
1636 | #ifdef EXTRA_CHECK |
1637 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1638 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3311444c |
1639 | return FALSE; |
2c82c4dc |
1640 | #endif //EXTRA_CHECK |
1641 | Drawing_t *drawing = control_flow_data->drawing; |
1642 | guint width = drawing->width; |
1643 | guint new_x; |
1644 | convert_time_to_pixels( |
1645 | time_window, |
1646 | evtime, |
1647 | width, |
1648 | &new_x); |
1649 | if(unlikely(hashed_process_data->x.middle != new_x)) { |
1650 | hashed_process_data->x.middle = new_x; |
1651 | hashed_process_data->x.middle_used = FALSE; |
1652 | hashed_process_data->x.middle_marked = FALSE; |
1653 | } |
1654 | } |
dbd243b1 |
1655 | |
3311444c |
1656 | return FALSE; |
2c82c4dc |
1657 | } |
dbd243b1 |
1658 | |
1659 | |
f4b88a7d |
1660 | /* Get the filename of the process to print */ |
1661 | int after_fs_exec_hook(void *hook_data, void *call_data) |
1662 | { |
dd455fb8 |
1663 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1664 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
f4b88a7d |
1665 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1666 | |
1667 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1668 | |
1669 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1670 | |
1671 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1672 | |
e38d9ea0 |
1673 | LttEvent *e; |
1674 | e = ltt_tracefile_get_event(tfc->tf); |
1675 | |
1676 | LttvFilter *filter = control_flow_data->filter; |
1677 | if(filter != NULL && filter->head != NULL) |
1678 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1679 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1680 | return FALSE; |
1681 | |
ae3d0f50 |
1682 | guint cpu = tfs->cpu; |
0f090e21 |
1683 | guint trace_num = ts->parent.index; |
f4b88a7d |
1684 | LttvProcessState *process = ts->running_process[cpu]; |
1685 | g_assert(process != NULL); |
1686 | |
1687 | guint pid = process->pid; |
1688 | |
1689 | /* Well, the process_out existed : we must get it in the process hash |
1690 | * or add it, and draw its items. |
1691 | */ |
1692 | /* Add process to process list (if not present) */ |
1693 | guint pl_height = 0; |
1694 | HashedProcessData *hashed_process_data = NULL; |
1695 | ProcessList *process_list = control_flow_data->process_list; |
1696 | LttTime birth = process->creation_time; |
1697 | |
0f090e21 |
1698 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
1699 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
f4b88a7d |
1700 | } else { |
1701 | hashed_process_data = processlist_get_process_data(process_list, |
1702 | pid, |
1703 | process->cpu, |
1704 | &birth, |
0f090e21 |
1705 | trace_num); |
f4b88a7d |
1706 | if(unlikely(hashed_process_data == NULL)) |
1707 | { |
1708 | g_assert(pid == 0 || pid != process->ppid); |
1709 | ProcessInfo *process_info; |
1710 | /* Process not present */ |
1711 | Drawing_t *drawing = control_flow_data->drawing; |
1712 | processlist_add(process_list, |
1713 | drawing, |
1714 | pid, |
fcc08e1e |
1715 | process->tgid, |
f4b88a7d |
1716 | process->cpu, |
1717 | process->ppid, |
1718 | &birth, |
0f090e21 |
1719 | trace_num, |
f4b88a7d |
1720 | process->name, |
7b5f6cf1 |
1721 | process->brand, |
f4b88a7d |
1722 | &pl_height, |
1723 | &process_info, |
1724 | &hashed_process_data); |
1725 | gtk_widget_set_size_request(drawing->drawing_area, |
1726 | -1, |
1727 | pl_height); |
1728 | gtk_widget_queue_draw(drawing->drawing_area); |
1729 | } |
1730 | /* Set the current process */ |
0f090e21 |
1731 | process_list->current_hash_data[trace_num][process->cpu] = |
f4b88a7d |
1732 | hashed_process_data; |
1733 | } |
1734 | |
1735 | processlist_set_name(process_list, process->name, hashed_process_data); |
1736 | |
1737 | return 0; |
1738 | |
1739 | } |
1740 | |
7b5f6cf1 |
1741 | /* Get the filename of the process to print */ |
1742 | int after_user_generic_thread_brand_hook(void *hook_data, void *call_data) |
1743 | { |
dd455fb8 |
1744 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1745 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
7b5f6cf1 |
1746 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1747 | |
1748 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1749 | |
1750 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1751 | |
1752 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1753 | |
e38d9ea0 |
1754 | LttEvent *e; |
1755 | e = ltt_tracefile_get_event(tfc->tf); |
1756 | |
1757 | LttvFilter *filter = control_flow_data->filter; |
1758 | if(filter != NULL && filter->head != NULL) |
1759 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1760 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1761 | return FALSE; |
1762 | |
7b5f6cf1 |
1763 | guint cpu = tfs->cpu; |
0f090e21 |
1764 | guint trace_num = ts->parent.index; |
7b5f6cf1 |
1765 | LttvProcessState *process = ts->running_process[cpu]; |
1766 | g_assert(process != NULL); |
1767 | |
1768 | guint pid = process->pid; |
1769 | |
1770 | /* Well, the process_out existed : we must get it in the process hash |
1771 | * or add it, and draw its items. |
1772 | */ |
1773 | /* Add process to process list (if not present) */ |
1774 | guint pl_height = 0; |
1775 | HashedProcessData *hashed_process_data = NULL; |
1776 | ProcessList *process_list = control_flow_data->process_list; |
1777 | LttTime birth = process->creation_time; |
1778 | |
0f090e21 |
1779 | if(likely(process_list->current_hash_data[trace_num][cpu] != NULL)) { |
1780 | hashed_process_data = process_list->current_hash_data[trace_num][cpu]; |
7b5f6cf1 |
1781 | } else { |
1782 | hashed_process_data = processlist_get_process_data(process_list, |
1783 | pid, |
1784 | process->cpu, |
1785 | &birth, |
0f090e21 |
1786 | trace_num); |
7b5f6cf1 |
1787 | if(unlikely(hashed_process_data == NULL)) |
1788 | { |
1789 | g_assert(pid == 0 || pid != process->ppid); |
1790 | ProcessInfo *process_info; |
1791 | /* Process not present */ |
1792 | Drawing_t *drawing = control_flow_data->drawing; |
1793 | processlist_add(process_list, |
1794 | drawing, |
1795 | pid, |
fcc08e1e |
1796 | process->tgid, |
7b5f6cf1 |
1797 | process->cpu, |
1798 | process->ppid, |
1799 | &birth, |
0f090e21 |
1800 | trace_num, |
7b5f6cf1 |
1801 | process->name, |
1802 | process->brand, |
1803 | &pl_height, |
1804 | &process_info, |
1805 | &hashed_process_data); |
1806 | gtk_widget_set_size_request(drawing->drawing_area, |
1807 | -1, |
1808 | pl_height); |
1809 | gtk_widget_queue_draw(drawing->drawing_area); |
1810 | } |
1811 | /* Set the current process */ |
0f090e21 |
1812 | process_list->current_hash_data[trace_num][process->cpu] = |
7b5f6cf1 |
1813 | hashed_process_data; |
1814 | } |
1815 | |
1816 | processlist_set_brand(process_list, process->brand, hashed_process_data); |
1817 | |
1818 | return 0; |
1819 | |
1820 | } |
1821 | |
1822 | |
b3fd4c02 |
1823 | /* after_event_enum_process_hook |
1824 | * |
b3fd4c02 |
1825 | * Create the processlist entry for the child process. Put the last |
1826 | * position in x at the current time value. |
1827 | * |
1828 | * @param hook_data ControlFlowData structure of the viewer. |
1829 | * @param call_data Event context. |
1830 | * |
1831 | * This function adds items to be drawn in a queue for each process. |
1832 | * |
1833 | */ |
1834 | int after_event_enum_process_hook(void *hook_data, void *call_data) |
1835 | { |
dd455fb8 |
1836 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
1837 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
b3fd4c02 |
1838 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1839 | |
1840 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1841 | |
1842 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1843 | |
1844 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
1845 | |
c4a72569 |
1846 | guint first_cpu, nb_cpus, cpu; |
1847 | |
b3fd4c02 |
1848 | LttEvent *e; |
1849 | e = ltt_tracefile_get_event(tfc->tf); |
1850 | |
e38d9ea0 |
1851 | LttvFilter *filter = control_flow_data->filter; |
1852 | if(filter != NULL && filter->head != NULL) |
1853 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
1854 | tfc->t_context->t,tfc,NULL,NULL)) |
e38d9ea0 |
1855 | return FALSE; |
1856 | |
b3fd4c02 |
1857 | LttTime evtime = ltt_event_time(e); |
1858 | |
1859 | /* Add process to process list (if not present) */ |
1860 | LttvProcessState *process_in; |
1861 | LttTime birth; |
1862 | guint pl_height = 0; |
1863 | HashedProcessData *hashed_process_data_in = NULL; |
1864 | |
1865 | ProcessList *process_list = control_flow_data->process_list; |
0f090e21 |
1866 | guint trace_num = ts->parent.index; |
b3fd4c02 |
1867 | |
1868 | guint pid_in; |
1869 | { |
04348950 |
1870 | pid_in = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); |
b3fd4c02 |
1871 | } |
c4a72569 |
1872 | |
1873 | if(pid_in == 0) { |
1874 | first_cpu = 0; |
1875 | nb_cpus = ltt_trace_get_num_cpu(ts->parent.t); |
1876 | } else { |
1877 | first_cpu = ANY_CPU; |
1878 | nb_cpus = ANY_CPU+1; |
1879 | } |
b3fd4c02 |
1880 | |
c4a72569 |
1881 | for(cpu = first_cpu; cpu < nb_cpus; cpu++) { |
1882 | /* Find process pid_in in the list... */ |
1883 | process_in = lttv_state_find_process(ts, cpu, pid_in); |
1884 | //process_in = tfs->process; |
1885 | //guint cpu = tfs->cpu; |
1886 | //guint trace_num = ts->parent.index; |
1887 | //process_in = ts->running_process[cpu]; |
1888 | /* It should exist, because we are after the state update. */ |
1889 | #ifdef EXTRA_CHECK |
1890 | //g_assert(process_in != NULL); |
1891 | #endif //EXTRA_CHECK |
1892 | birth = process_in->creation_time; |
1893 | |
1894 | hashed_process_data_in = processlist_get_process_data(process_list, |
1895 | pid_in, |
1896 | process_in->cpu, |
1897 | &birth, |
1898 | trace_num); |
1899 | if(hashed_process_data_in == NULL) |
1900 | { |
1901 | if(pid_in != 0 && pid_in == process_in->ppid) |
1902 | g_critical("TEST %u , %u", pid_in, process_in->ppid); |
1903 | g_assert(pid_in == 0 || pid_in != process_in->ppid); |
1904 | ProcessInfo *process_info; |
1905 | Drawing_t *drawing = control_flow_data->drawing; |
1906 | /* Process not present */ |
1907 | processlist_add(process_list, |
1908 | drawing, |
b3fd4c02 |
1909 | pid_in, |
c4a72569 |
1910 | process_in->tgid, |
b3fd4c02 |
1911 | process_in->cpu, |
c4a72569 |
1912 | process_in->ppid, |
b3fd4c02 |
1913 | &birth, |
c4a72569 |
1914 | trace_num, |
1915 | process_in->name, |
1916 | process_in->brand, |
1917 | &pl_height, |
1918 | &process_info, |
1919 | &hashed_process_data_in); |
1920 | gtk_widget_set_size_request(drawing->drawing_area, |
1921 | -1, |
1922 | pl_height); |
1923 | gtk_widget_queue_draw(drawing->drawing_area); |
1924 | } else { |
1925 | processlist_set_name(process_list, process_in->name, |
1926 | hashed_process_data_in); |
1927 | processlist_set_ppid(process_list, process_in->ppid, |
1928 | hashed_process_data_in); |
1929 | processlist_set_tgid(process_list, process_in->tgid, |
1930 | hashed_process_data_in); |
1931 | } |
1932 | } |
b3fd4c02 |
1933 | return 0; |
1934 | } |
f4b88a7d |
1935 | |
1936 | |
1b238973 |
1937 | gint update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
1938 | { |
a56a1ba4 |
1939 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
a43d67ba |
1940 | Drawing_t *drawing = control_flow_data->drawing; |
1c736ed5 |
1941 | ProcessList *process_list = control_flow_data->process_list; |
a43d67ba |
1942 | |
224446ce |
1943 | const TimeWindowNotifyData *time_window_nofify_data = |
1944 | ((const TimeWindowNotifyData *)call_data); |
1945 | |
14963be0 |
1946 | TimeWindow *old_time_window = |
224446ce |
1947 | time_window_nofify_data->old_time_window; |
1948 | TimeWindow *new_time_window = |
1949 | time_window_nofify_data->new_time_window; |
a56a1ba4 |
1950 | |
3cb8b205 |
1951 | /* Update the ruler */ |
1952 | drawing_update_ruler(control_flow_data->drawing, |
1953 | new_time_window); |
1954 | |
1955 | |
a56a1ba4 |
1956 | /* Two cases : zoom in/out or scrolling */ |
1957 | |
1958 | /* In order to make sure we can reuse the old drawing, the scale must |
1959 | * be the same and the new time interval being partly located in the |
1960 | * currently shown time interval. (reuse is only for scrolling) |
1961 | */ |
1962 | |
2eef04b5 |
1963 | g_info("Old time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 |
1964 | old_time_window->start_time.tv_sec, |
1965 | old_time_window->start_time.tv_nsec, |
1966 | old_time_window->time_width.tv_sec, |
1967 | old_time_window->time_width.tv_nsec); |
a56a1ba4 |
1968 | |
2eef04b5 |
1969 | g_info("New time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 |
1970 | new_time_window->start_time.tv_sec, |
1971 | new_time_window->start_time.tv_nsec, |
1972 | new_time_window->time_width.tv_sec, |
1973 | new_time_window->time_width.tv_nsec); |
a56a1ba4 |
1974 | |
14963be0 |
1975 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
1976 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) |
a56a1ba4 |
1977 | { |
1978 | /* Same scale (scrolling) */ |
1979 | g_info("scrolling"); |
14963be0 |
1980 | LttTime *ns = &new_time_window->start_time; |
20640e70 |
1981 | LttTime *nw = &new_time_window->time_width; |
14963be0 |
1982 | LttTime *os = &old_time_window->start_time; |
20640e70 |
1983 | LttTime *ow = &old_time_window->time_width; |
6f26fc38 |
1984 | LttTime old_end = old_time_window->end_time; |
1985 | LttTime new_end = new_time_window->end_time; |
a56a1ba4 |
1986 | //if(ns<os+w<ns+w) |
1987 | //if(ns<os+w && os+w<ns+w) |
1988 | //if(ns<old_end && os<ns) |
1989 | if(ltt_time_compare(*ns, old_end) == -1 |
1990 | && ltt_time_compare(*os, *ns) == -1) |
1991 | { |
1992 | g_info("scrolling near right"); |
1993 | /* Scroll right, keep right part of the screen */ |
1994 | guint x = 0; |
51705146 |
1995 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
1996 | convert_time_to_pixels( |
a18124ff |
1997 | *old_time_window, |
a56a1ba4 |
1998 | *ns, |
1999 | width, |
2000 | &x); |
2001 | |
2002 | /* Copy old data to new location */ |
1c736ed5 |
2003 | copy_pixmap_region(process_list, |
2004 | NULL, |
2005 | control_flow_data->drawing->drawing_area->style->black_gc, |
2006 | NULL, |
2007 | x, 0, |
2008 | 0, 0, |
2009 | control_flow_data->drawing->width-x+SAFETY, -1); |
2010 | |
6395d57c |
2011 | if(drawing->damage_begin == drawing->damage_end) |
2012 | drawing->damage_begin = control_flow_data->drawing->width-x; |
2013 | else |
2014 | drawing->damage_begin = 0; |
2015 | |
2016 | drawing->damage_end = control_flow_data->drawing->width; |
2017 | |
a56a1ba4 |
2018 | /* Clear the data request background, but not SAFETY */ |
1c736ed5 |
2019 | rectangle_pixmap(process_list, |
cfe526b1 |
2020 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
2021 | TRUE, |
6395d57c |
2022 | drawing->damage_begin+SAFETY, 0, |
2023 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1c736ed5 |
2024 | -1); |
7abb23ad |
2025 | gtk_widget_queue_draw(drawing->drawing_area); |
2026 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2027 | // 0,0, |
2028 | // control_flow_data->drawing->width, |
2029 | // control_flow_data->drawing->height); |
a43d67ba |
2030 | |
a56a1ba4 |
2031 | /* Get new data for the rest. */ |
501d5405 |
2032 | drawing_data_request(control_flow_data->drawing, |
6395d57c |
2033 | drawing->damage_begin, 0, |
2034 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
2035 | control_flow_data->drawing->height); |
a56a1ba4 |
2036 | } else { |
2037 | //if(ns<os<ns+w) |
2038 | //if(ns<os && os<ns+w) |
2039 | //if(ns<os && os<new_end) |
2040 | if(ltt_time_compare(*ns,*os) == -1 |
2041 | && ltt_time_compare(*os,new_end) == -1) |
2042 | { |
2043 | g_info("scrolling near left"); |
2044 | /* Scroll left, keep left part of the screen */ |
2045 | guint x = 0; |
51705146 |
2046 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
2047 | convert_time_to_pixels( |
a18124ff |
2048 | *new_time_window, |
a56a1ba4 |
2049 | *os, |
2050 | width, |
2051 | &x); |
6395d57c |
2052 | |
a56a1ba4 |
2053 | /* Copy old data to new location */ |
1c736ed5 |
2054 | copy_pixmap_region (process_list, |
2055 | NULL, |
cfe526b1 |
2056 | control_flow_data->drawing->drawing_area->style->black_gc, |
1c736ed5 |
2057 | NULL, |
a56a1ba4 |
2058 | 0, 0, |
2059 | x, 0, |
2060 | -1, -1); |
2061 | |
6395d57c |
2062 | if(drawing->damage_begin == drawing->damage_end) |
2063 | drawing->damage_end = x; |
2064 | else |
2065 | drawing->damage_end = |
51705146 |
2066 | control_flow_data->drawing->width; |
6395d57c |
2067 | |
2068 | drawing->damage_begin = 0; |
2069 | |
1c736ed5 |
2070 | rectangle_pixmap (process_list, |
cfe526b1 |
2071 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
2072 | TRUE, |
6395d57c |
2073 | drawing->damage_begin, 0, |
2074 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1c736ed5 |
2075 | -1); |
a43d67ba |
2076 | |
7abb23ad |
2077 | gtk_widget_queue_draw(drawing->drawing_area); |
2078 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2079 | // 0,0, |
2080 | // control_flow_data->drawing->width, |
2081 | // control_flow_data->drawing->height); |
a43d67ba |
2082 | |
6395d57c |
2083 | |
a56a1ba4 |
2084 | /* Get new data for the rest. */ |
501d5405 |
2085 | drawing_data_request(control_flow_data->drawing, |
6395d57c |
2086 | drawing->damage_begin, 0, |
2087 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
2088 | control_flow_data->drawing->height); |
a56a1ba4 |
2089 | |
a56a1ba4 |
2090 | } else { |
a43d67ba |
2091 | if(ltt_time_compare(*ns,*os) == 0) |
2092 | { |
2093 | g_info("not scrolling"); |
2094 | } else { |
2095 | g_info("scrolling far"); |
2096 | /* Cannot reuse any part of the screen : far jump */ |
2097 | |
2098 | |
1c736ed5 |
2099 | rectangle_pixmap (process_list, |
a43d67ba |
2100 | control_flow_data->drawing->drawing_area->style->black_gc, |
2101 | TRUE, |
a56a1ba4 |
2102 | 0, 0, |
a43d67ba |
2103 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 |
2104 | -1); |
a43d67ba |
2105 | |
7abb23ad |
2106 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2107 | // 0,0, |
2108 | // control_flow_data->drawing->width, |
2109 | // control_flow_data->drawing->height); |
2110 | gtk_widget_queue_draw(drawing->drawing_area); |
a43d67ba |
2111 | |
6395d57c |
2112 | drawing->damage_begin = 0; |
2113 | drawing->damage_end = control_flow_data->drawing->width; |
2114 | |
a43d67ba |
2115 | drawing_data_request(control_flow_data->drawing, |
a43d67ba |
2116 | 0, 0, |
2117 | control_flow_data->drawing->width, |
2118 | control_flow_data->drawing->height); |
2119 | |
2120 | } |
a56a1ba4 |
2121 | } |
2122 | } |
2123 | } else { |
2124 | /* Different scale (zoom) */ |
2125 | g_info("zoom"); |
2126 | |
1c736ed5 |
2127 | rectangle_pixmap (process_list, |
cfe526b1 |
2128 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
2129 | TRUE, |
2130 | 0, 0, |
501d5405 |
2131 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 |
2132 | -1); |
a56a1ba4 |
2133 | |
7abb23ad |
2134 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2135 | // 0,0, |
2136 | // control_flow_data->drawing->width, |
2137 | // control_flow_data->drawing->height); |
2138 | gtk_widget_queue_draw(drawing->drawing_area); |
a56a1ba4 |
2139 | |
6395d57c |
2140 | drawing->damage_begin = 0; |
2141 | drawing->damage_end = control_flow_data->drawing->width; |
2142 | |
501d5405 |
2143 | drawing_data_request(control_flow_data->drawing, |
a56a1ba4 |
2144 | 0, 0, |
501d5405 |
2145 | control_flow_data->drawing->width, |
2146 | control_flow_data->drawing->height); |
a56a1ba4 |
2147 | } |
2148 | |
15f77e3b |
2149 | /* Update directly when scrolling */ |
2150 | gdk_window_process_updates(control_flow_data->drawing->drawing_area->window, |
2151 | TRUE); |
3cb8b205 |
2152 | |
a56a1ba4 |
2153 | return 0; |
f7afe191 |
2154 | } |
2155 | |
6395d57c |
2156 | gint traceset_notify(void *hook_data, void *call_data) |
2157 | { |
2158 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
2159 | Drawing_t *drawing = control_flow_data->drawing; |
6395d57c |
2160 | |
6cec4cd2 |
2161 | if(unlikely(drawing->gc == NULL)) { |
2162 | return FALSE; |
2163 | } |
2164 | if(drawing->dotted_gc == NULL) { |
2165 | return FALSE; |
2166 | } |
6395d57c |
2167 | |
b9a010a2 |
2168 | drawing_clear(control_flow_data->drawing); |
2169 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
2170 | gtk_widget_set_size_request( |
2171 | control_flow_data->drawing->drawing_area, |
2172 | -1, processlist_get_height(control_flow_data->process_list)); |
d9267eec |
2173 | redraw_notify(control_flow_data, NULL); |
6395d57c |
2174 | |
d9267eec |
2175 | request_background_data(control_flow_data); |
6395d57c |
2176 | |
2177 | return FALSE; |
2178 | } |
2179 | |
ca0f8a8e |
2180 | gint redraw_notify(void *hook_data, void *call_data) |
2181 | { |
2182 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
2183 | Drawing_t *drawing = control_flow_data->drawing; |
2184 | GtkWidget *widget = drawing->drawing_area; |
2185 | |
2186 | drawing->damage_begin = 0; |
51705146 |
2187 | drawing->damage_end = drawing->width; |
ca0f8a8e |
2188 | |
49217bd4 |
2189 | /* fun feature, to be separated someday... */ |
2190 | drawing_clear(control_flow_data->drawing); |
2191 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
2192 | gtk_widget_set_size_request( |
2193 | control_flow_data->drawing->drawing_area, |
2194 | -1, processlist_get_height(control_flow_data->process_list)); |
1c736ed5 |
2195 | // Clear the images |
2196 | rectangle_pixmap (control_flow_data->process_list, |
ca0f8a8e |
2197 | widget->style->black_gc, |
2198 | TRUE, |
2199 | 0, 0, |
f3b7430d |
2200 | drawing->alloc_width, |
1c736ed5 |
2201 | -1); |
ca0f8a8e |
2202 | |
f3b7430d |
2203 | gtk_widget_queue_draw(drawing->drawing_area); |
4a24fa1f |
2204 | |
ca0f8a8e |
2205 | if(drawing->damage_begin < drawing->damage_end) |
2206 | { |
2207 | drawing_data_request(drawing, |
ca0f8a8e |
2208 | drawing->damage_begin, |
2209 | 0, |
2210 | drawing->damage_end-drawing->damage_begin, |
51705146 |
2211 | drawing->height); |
ca0f8a8e |
2212 | } |
2213 | |
7abb23ad |
2214 | //gtk_widget_queue_draw_area(drawing->drawing_area, |
2215 | // 0,0, |
2216 | // drawing->width, |
2217 | // drawing->height); |
ca0f8a8e |
2218 | return FALSE; |
2219 | |
2220 | } |
2221 | |
2222 | |
2223 | gint continue_notify(void *hook_data, void *call_data) |
a43d67ba |
2224 | { |
2225 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
ca0f8a8e |
2226 | Drawing_t *drawing = control_flow_data->drawing; |
a43d67ba |
2227 | |
6395d57c |
2228 | //g_assert(widget->allocation.width == drawing->damage_end); |
ca0f8a8e |
2229 | |
2230 | if(drawing->damage_begin < drawing->damage_end) |
2231 | { |
2232 | drawing_data_request(drawing, |
ca0f8a8e |
2233 | drawing->damage_begin, |
2234 | 0, |
2235 | drawing->damage_end-drawing->damage_begin, |
51705146 |
2236 | drawing->height); |
ca0f8a8e |
2237 | } |
2238 | |
2239 | return FALSE; |
2240 | } |
2241 | |
2242 | |
1b238973 |
2243 | gint update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
2244 | { |
14963be0 |
2245 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
a43d67ba |
2246 | Drawing_t *drawing = control_flow_data->drawing; |
a56a1ba4 |
2247 | |
224446ce |
2248 | LttTime current_time = *((LttTime*)call_data); |
a56a1ba4 |
2249 | |
ca0f8a8e |
2250 | TimeWindow time_window = |
2251 | lttvwindow_get_time_window(control_flow_data->tab); |
a56a1ba4 |
2252 | |
ca0f8a8e |
2253 | LttTime time_begin = time_window.start_time; |
2254 | LttTime width = time_window.time_width; |
90ef7e4a |
2255 | LttTime half_width; |
2256 | { |
2257 | guint64 time_ll = ltt_time_to_uint64(width); |
2258 | time_ll = time_ll >> 1; /* divide by two */ |
2259 | half_width = ltt_time_from_uint64(time_ll); |
2260 | } |
a56a1ba4 |
2261 | LttTime time_end = ltt_time_add(time_begin, width); |
2262 | |
2263 | LttvTracesetContext * tsc = |
ca0f8a8e |
2264 | lttvwindow_get_traceset_context(control_flow_data->tab); |
a56a1ba4 |
2265 | |
ca0f8a8e |
2266 | LttTime trace_start = tsc->time_span.start_time; |
2267 | LttTime trace_end = tsc->time_span.end_time; |
a56a1ba4 |
2268 | |
2eef04b5 |
2269 | g_info("New current time HOOK : %lu, %lu", current_time.tv_sec, |
224446ce |
2270 | current_time.tv_nsec); |
a56a1ba4 |
2271 | |
2272 | |
2273 | |
2274 | /* If current time is inside time interval, just move the highlight |
2275 | * bar */ |
2276 | |
2277 | /* Else, we have to change the time interval. We have to tell it |
2278 | * to the main window. */ |
2279 | /* The time interval change will take care of placing the current |
2280 | * time at the center of the visible area, or nearest possible if we are |
2281 | * at one end of the trace. */ |
2282 | |
2283 | |
dbc0ef8a |
2284 | if(ltt_time_compare(current_time, time_begin) < 0) |
a56a1ba4 |
2285 | { |
224446ce |
2286 | TimeWindow new_time_window; |
2287 | |
2288 | if(ltt_time_compare(current_time, |
dbc0ef8a |
2289 | ltt_time_add(trace_start,half_width)) < 0) |
a56a1ba4 |
2290 | time_begin = trace_start; |
2291 | else |
224446ce |
2292 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
2293 | |
224446ce |
2294 | new_time_window.start_time = time_begin; |
2295 | new_time_window.time_width = width; |
a18124ff |
2296 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 |
2297 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 |
2298 | |
e800cf84 |
2299 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 |
2300 | } |
dbc0ef8a |
2301 | else if(ltt_time_compare(current_time, time_end) > 0) |
a56a1ba4 |
2302 | { |
224446ce |
2303 | TimeWindow new_time_window; |
2304 | |
dbc0ef8a |
2305 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0) |
a56a1ba4 |
2306 | time_begin = ltt_time_sub(trace_end,width); |
2307 | else |
224446ce |
2308 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
2309 | |
224446ce |
2310 | new_time_window.start_time = time_begin; |
2311 | new_time_window.time_width = width; |
a18124ff |
2312 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 |
2313 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 |
2314 | |
e800cf84 |
2315 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 |
2316 | |
2317 | } |
7abb23ad |
2318 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
a56a1ba4 |
2319 | |
15f77e3b |
2320 | /* Update directly when scrolling */ |
2321 | gdk_window_process_updates(control_flow_data->drawing->drawing_area->window, |
2322 | TRUE); |
2323 | |
a56a1ba4 |
2324 | return 0; |
f7afe191 |
2325 | } |
2326 | |
8b90e648 |
2327 | typedef struct _ClosureData { |
ca0f8a8e |
2328 | EventsRequest *events_request; |
d0cd7f09 |
2329 | LttvTracesetState *tss; |
b9a010a2 |
2330 | LttTime end_time; |
bc8d270b |
2331 | guint x_end; |
8b90e648 |
2332 | } ClosureData; |
a56a1ba4 |
2333 | |
8b90e648 |
2334 | |
e800cf84 |
2335 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
2336 | { |
a56a1ba4 |
2337 | ProcessInfo *process_info = (ProcessInfo*)key; |
2338 | HashedProcessData *hashed_process_data = (HashedProcessData*)value; |
2339 | ClosureData *closure_data = (ClosureData*)user_data; |
2340 | |
e800cf84 |
2341 | EventsRequest *events_request = closure_data->events_request; |
2342 | ControlFlowData *control_flow_data = events_request->viewer_data; |
a56a1ba4 |
2343 | |
e800cf84 |
2344 | LttvTracesetState *tss = closure_data->tss; |
d6fef890 |
2345 | LttvTracesetContext *tsc = (LttvTracesetContext*)tss; |
a56a1ba4 |
2346 | |
e800cf84 |
2347 | LttTime evtime = closure_data->end_time; |
d0cd7f09 |
2348 | |
e3162168 |
2349 | gboolean dodraw = TRUE; |
2350 | |
e800cf84 |
2351 | { |
2352 | /* For the process */ |
2353 | /* First, check if the current process is in the state computation |
2354 | * process list. If it is there, that means we must add it right now and |
2355 | * draw items from the beginning of the read for it. If it is not |
2356 | * present, it's a new process and it was not present : it will |
2357 | * be added after the state update. */ |
31b6868d |
2358 | #ifdef EXTRA_CHECK |
e800cf84 |
2359 | g_assert(lttv_traceset_number(tsc->ts) > 0); |
31b6868d |
2360 | #endif //EXTRA_CHECK |
2c82c4dc |
2361 | LttvTraceContext *tc = tsc->traces[process_info->trace_num]; |
348c6ba8 |
2362 | LttvTraceState *ts = (LttvTraceState*)tc; |
2c82c4dc |
2363 | |
348c6ba8 |
2364 | #if 0 |
2c82c4dc |
2365 | //FIXME : optimize data structures. |
2366 | LttvTracefileState *tfs; |
2367 | LttvTracefileContext *tfc; |
2368 | guint i; |
2369 | for(i=0;i<tc->tracefiles->len;i++) { |
2370 | tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i); |
2371 | if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU |
ae3d0f50 |
2372 | && tfs->cpu == process_info->cpu) |
2c82c4dc |
2373 | break; |
2374 | |
2375 | } |
2376 | g_assert(i<tc->tracefiles->len); |
2377 | tfs = LTTV_TRACEFILE_STATE(tfc); |
348c6ba8 |
2378 | #endif //0 |
2c82c4dc |
2379 | // LttvTracefileState *tfs = |
2380 | // (LttvTracefileState*)tsc->traces[process_info->trace_num]-> |
2381 | // tracefiles[process_info->cpu]; |
2da61677 |
2382 | |
e800cf84 |
2383 | LttvProcessState *process; |
348c6ba8 |
2384 | process = lttv_state_find_process(ts, process_info->cpu, |
e025a729 |
2385 | process_info->pid); |
a56a1ba4 |
2386 | |
1d1df11d |
2387 | if(unlikely(process != NULL)) { |
e800cf84 |
2388 | |
b6ef18af |
2389 | LttvFilter *filter = control_flow_data->filter; |
2390 | if(filter != NULL && filter->head != NULL) |
2391 | if(!lttv_filter_tree_parse(filter->head,NULL,NULL, |
2392 | tc->t,NULL,process,tc)) |
e3162168 |
2393 | dodraw = FALSE; |
b6ef18af |
2394 | |
e800cf84 |
2395 | /* Only draw for processes that are currently in the trace states */ |
ad2e83ba |
2396 | |
5c230fc4 |
2397 | ProcessList *process_list = control_flow_data->process_list; |
1d1df11d |
2398 | #ifdef EXTRA_CHECK |
e800cf84 |
2399 | /* Should be alike when background info is ready */ |
2400 | if(control_flow_data->background_info_waiting==0) |
2401 | g_assert(ltt_time_compare(process->creation_time, |
2402 | process_info->birth) == 0); |
1d1df11d |
2403 | #endif //EXTRA_CHECK |
e800cf84 |
2404 | |
2405 | /* Now, the process is in the state hash and our own process hash. |
2406 | * We definitely can draw the items related to the ending state. |
2407 | */ |
2408 | |
1d1df11d |
2409 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
2410 | evtime) <= 0)) |
e800cf84 |
2411 | { |
fd22065b |
2412 | TimeWindow time_window = |
2413 | lttvwindow_get_time_window(control_flow_data->tab); |
2414 | |
2415 | #ifdef EXTRA_CHECK |
2416 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2417 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2418 | return; |
2419 | #endif //EXTRA_CHECK |
d6fef890 |
2420 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2421 | guint width = drawing->width; |
a56a1ba4 |
2422 | |
bc8d270b |
2423 | guint x = closure_data->x_end; |
8b90e648 |
2424 | |
4b7dc462 |
2425 | DrawContext draw_context; |
2426 | |
e800cf84 |
2427 | /* Now create the drawing context that will be used to draw |
2428 | * items related to the last state. */ |
1c736ed5 |
2429 | draw_context.drawable = hashed_process_data->pixmap; |
e800cf84 |
2430 | draw_context.gc = drawing->gc; |
2431 | draw_context.pango_layout = drawing->pango_layout; |
e800cf84 |
2432 | draw_context.drawinfo.end.x = x; |
2433 | |
1c736ed5 |
2434 | draw_context.drawinfo.y.over = 1; |
2435 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2436 | draw_context.drawinfo.y.under = hashed_process_data->height; |
e800cf84 |
2437 | |
2438 | draw_context.drawinfo.start.offset.over = 0; |
2439 | draw_context.drawinfo.start.offset.middle = 0; |
2440 | draw_context.drawinfo.start.offset.under = 0; |
2441 | draw_context.drawinfo.end.offset.over = 0; |
2442 | draw_context.drawinfo.end.offset.middle = 0; |
2443 | draw_context.drawinfo.end.offset.under = 0; |
9a1ec01b |
2444 | #if 0 |
4b7dc462 |
2445 | /* Jump over draw if we are at the same x position */ |
2446 | if(x == hashed_process_data->x.over) |
e800cf84 |
2447 | { |
4b7dc462 |
2448 | /* jump */ |
2449 | } else { |
23093869 |
2450 | draw_context.drawinfo.start.x = hashed_process_data->x.over; |
2451 | /* Draw the line */ |
2452 | PropertiesLine prop_line = prepare_execmode_line(process); |
2453 | draw_line((void*)&prop_line, (void*)&draw_context); |
2454 | |
4b7dc462 |
2455 | hashed_process_data->x.over = x; |
23093869 |
2456 | } |
9a1ec01b |
2457 | #endif //0 |
4b7dc462 |
2458 | |
1d1df11d |
2459 | if(unlikely(x == hashed_process_data->x.middle && |
2460 | hashed_process_data->x.middle_used)) { |
b2743953 |
2461 | #if 0 /* do not mark closure : not missing information */ |
e72908ed |
2462 | if(hashed_process_data->x.middle_marked == FALSE) { |
2463 | /* Draw collision indicator */ |
2464 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2465 | gdk_draw_point(drawing->pixmap, |
2466 | drawing->gc, |
2467 | x, |
2c6618bc |
2468 | y+(height/2)-3); |
de4ea1ad |
2469 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
2470 | } |
b2743953 |
2471 | #endif //0 |
4b7dc462 |
2472 | /* Jump */ |
2473 | } else { |
23093869 |
2474 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
e800cf84 |
2475 | /* Draw the line */ |
c4a72569 |
2476 | if(dodraw) { |
2477 | PropertiesLine prop_line = prepare_s_e_line(process); |
2478 | draw_line((void*)&prop_line, (void*)&draw_context); |
2479 | } |
e800cf84 |
2480 | |
4b7dc462 |
2481 | /* become the last x position */ |
1d1df11d |
2482 | if(likely(x != hashed_process_data->x.middle)) { |
e72908ed |
2483 | hashed_process_data->x.middle = x; |
2484 | /* but don't use the pixel */ |
2485 | hashed_process_data->x.middle_used = FALSE; |
b2743953 |
2486 | |
2487 | /* Calculate the next good time */ |
2488 | convert_pixels_to_time(width, x+1, time_window, |
2489 | &hashed_process_data->next_good_time); |
e72908ed |
2490 | } |
e800cf84 |
2491 | } |
e800cf84 |
2492 | } |
2493 | } |
2494 | } |
2495 | return; |
8b90e648 |
2496 | } |
2497 | |
b9a010a2 |
2498 | int before_chunk(void *hook_data, void *call_data) |
2499 | { |
2500 | EventsRequest *events_request = (EventsRequest*)hook_data; |
16b9cadb |
2501 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
7c0125e0 |
2502 | ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data; |
cd3892fe |
2503 | #if 0 |
7c0125e0 |
2504 | /* Desactivate sort */ |
2505 | gtk_tree_sortable_set_sort_column_id( |
2506 | GTK_TREE_SORTABLE(cfd->process_list->list_store), |
2507 | TRACE_COLUMN, |
2508 | GTK_SORT_ASCENDING); |
cd3892fe |
2509 | #endif //0 |
b9a010a2 |
2510 | drawing_chunk_begin(events_request, tss); |
2511 | |
2512 | return 0; |
2513 | } |
2514 | |
2515 | int before_request(void *hook_data, void *call_data) |
ca0f8a8e |
2516 | { |
2517 | EventsRequest *events_request = (EventsRequest*)hook_data; |
16b9cadb |
2518 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
7c0125e0 |
2519 | |
ca0f8a8e |
2520 | drawing_data_request_begin(events_request, tss); |
2521 | |
2522 | return 0; |
2523 | } |
2524 | |
2525 | |
8b90e648 |
2526 | /* |
b9a010a2 |
2527 | * after request is necessary in addition of after chunk in order to draw |
2528 | * lines until the end of the screen. after chunk just draws lines until |
2529 | * the last event. |
2530 | * |
8b90e648 |
2531 | * for each process |
a56a1ba4 |
2532 | * draw closing line |
b9a010a2 |
2533 | * expose |
8b90e648 |
2534 | */ |
b9a010a2 |
2535 | int after_request(void *hook_data, void *call_data) |
8b90e648 |
2536 | { |
ca0f8a8e |
2537 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2538 | ControlFlowData *control_flow_data = events_request->viewer_data; |
16b9cadb |
2539 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
a56a1ba4 |
2540 | |
5c230fc4 |
2541 | ProcessList *process_list = control_flow_data->process_list; |
b9a010a2 |
2542 | LttTime end_time = events_request->end_time; |
2543 | |
2544 | ClosureData closure_data; |
2545 | closure_data.events_request = (EventsRequest*)hook_data; |
2546 | closure_data.tss = tss; |
2547 | closure_data.end_time = end_time; |
2548 | |
bc8d270b |
2549 | TimeWindow time_window = |
2550 | lttvwindow_get_time_window(control_flow_data->tab); |
2551 | guint width = control_flow_data->drawing->width; |
2552 | convert_time_to_pixels( |
2553 | time_window, |
2554 | end_time, |
2555 | width, |
2556 | &closure_data.x_end); |
2557 | |
2558 | |
b9a010a2 |
2559 | /* Draw last items */ |
2560 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
2561 | (void*)&closure_data); |
7c0125e0 |
2562 | |
b9a010a2 |
2563 | |
2564 | /* Request expose */ |
2565 | drawing_request_expose(events_request, tss, end_time); |
2566 | return 0; |
2567 | } |
2568 | |
2569 | /* |
2570 | * for each process |
2571 | * draw closing line |
e800cf84 |
2572 | * expose |
b9a010a2 |
2573 | */ |
2574 | int after_chunk(void *hook_data, void *call_data) |
2575 | { |
2576 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2577 | ControlFlowData *control_flow_data = events_request->viewer_data; |
16b9cadb |
2578 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
2579 | LttvTracesetContext *tsc = (LttvTracesetContext*)call_data; |
b9a010a2 |
2580 | LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc); |
2581 | LttTime end_time; |
2582 | |
5c230fc4 |
2583 | ProcessList *process_list = control_flow_data->process_list; |
0f090e21 |
2584 | guint i; |
2585 | LttvTraceset *traceset = tsc->ts; |
2586 | guint nb_trace = lttv_traceset_number(traceset); |
b9a010a2 |
2587 | |
0f090e21 |
2588 | /* Only execute when called for the first trace's events request */ |
2589 | if(!process_list->current_hash_data) return; |
2590 | |
2591 | for(i = 0 ; i < nb_trace ; i++) { |
2592 | g_free(process_list->current_hash_data[i]); |
2593 | } |
40debf7b |
2594 | g_free(process_list->current_hash_data); |
2595 | process_list->current_hash_data = NULL; |
0f090e21 |
2596 | |
e800cf84 |
2597 | if(tfc != NULL) |
2598 | end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time); |
0c5dbe3b |
2599 | else /* end of traceset, or position now out of request : end */ |
2600 | end_time = events_request->end_time; |
2601 | |
a56a1ba4 |
2602 | ClosureData closure_data; |
ca0f8a8e |
2603 | closure_data.events_request = (EventsRequest*)hook_data; |
2604 | closure_data.tss = tss; |
b9a010a2 |
2605 | closure_data.end_time = end_time; |
a56a1ba4 |
2606 | |
bc8d270b |
2607 | TimeWindow time_window = |
2608 | lttvwindow_get_time_window(control_flow_data->tab); |
2609 | guint width = control_flow_data->drawing->width; |
2610 | convert_time_to_pixels( |
2611 | time_window, |
2612 | end_time, |
2613 | width, |
2614 | &closure_data.x_end); |
2615 | |
b9a010a2 |
2616 | /* Draw last items */ |
14963be0 |
2617 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
a56a1ba4 |
2618 | (void*)&closure_data); |
cd3892fe |
2619 | #if 0 |
7c0125e0 |
2620 | /* Reactivate sort */ |
2621 | gtk_tree_sortable_set_sort_column_id( |
2622 | GTK_TREE_SORTABLE(control_flow_data->process_list->list_store), |
2623 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
2624 | GTK_SORT_ASCENDING); |
2625 | |
2626 | update_index_to_pixmap(control_flow_data->process_list); |
cd3892fe |
2627 | /* Request a full expose : drawing scrambled */ |
2628 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
2629 | #endif //0 |
2630 | /* Request expose (updates damages zone also) */ |
b9a010a2 |
2631 | drawing_request_expose(events_request, tss, end_time); |
ca0f8a8e |
2632 | |
2633 | return 0; |
8b90e648 |
2634 | } |
2635 | |
b70ceef8 |
2636 | /* after_statedump_end |
2637 | * |
2638 | * @param hook_data ControlFlowData structure of the viewer. |
2639 | * @param call_data Event context. |
2640 | * |
2641 | * This function adds items to be drawn in a queue for each process. |
2642 | * |
2643 | */ |
2644 | int before_statedump_end(void *hook_data, void *call_data) |
2645 | { |
dd455fb8 |
2646 | LttvTraceHook *th = (LttvTraceHook*)hook_data; |
2647 | EventsRequest *events_request = (EventsRequest*)th->hook_data; |
b70ceef8 |
2648 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2649 | |
2650 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
2651 | |
2652 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
2653 | |
2654 | LttvTraceState *ts = (LttvTraceState *)tfc->t_context; |
2655 | |
2656 | LttvTracesetState *tss = (LttvTracesetState*)tfc->t_context->ts_context; |
2657 | ProcessList *process_list = control_flow_data->process_list; |
2658 | |
2659 | LttEvent *e; |
2660 | e = ltt_tracefile_get_event(tfc->tf); |
2661 | |
2662 | LttvFilter *filter = control_flow_data->filter; |
2663 | if(filter != NULL && filter->head != NULL) |
2664 | if(!lttv_filter_tree_parse(filter->head,e,tfc->tf, |
b6ef18af |
2665 | tfc->t_context->t,tfc,NULL,NULL)) |
b70ceef8 |
2666 | return FALSE; |
2667 | |
2668 | LttTime evtime = ltt_event_time(e); |
2669 | |
2670 | ClosureData closure_data; |
2671 | closure_data.events_request = events_request; |
2672 | closure_data.tss = tss; |
2673 | closure_data.end_time = evtime; |
2674 | |
2675 | TimeWindow time_window = |
2676 | lttvwindow_get_time_window(control_flow_data->tab); |
2677 | guint width = control_flow_data->drawing->width; |
2678 | convert_time_to_pixels( |
2679 | time_window, |
2680 | evtime, |
2681 | width, |
2682 | &closure_data.x_end); |
2683 | |
2684 | /* Draw last items */ |
2685 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
2686 | (void*)&closure_data); |
2687 | #if 0 |
2688 | /* Reactivate sort */ |
2689 | gtk_tree_sortable_set_sort_column_id( |
2690 | GTK_TREE_SORTABLE(control_flow_data->process_list->list_store), |
2691 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
2692 | GTK_SORT_ASCENDING); |
2693 | |
2694 | update_index_to_pixmap(control_flow_data->process_list); |
2695 | /* Request a full expose : drawing scrambled */ |
2696 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
2697 | #endif //0 |
2698 | /* Request expose (updates damages zone also) */ |
2699 | drawing_request_expose(events_request, tss, evtime); |
2700 | |
2701 | return 0; |
2702 | } |