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> |
50439712 |
64 | #include <ltt/type.h> |
2c82c4dc |
65 | #include <ltt/trace.h> |
80a52ff8 |
66 | |
2a2fa4f0 |
67 | #include <lttv/lttv.h> |
558aa013 |
68 | #include <lttv/hook.h> |
80a52ff8 |
69 | #include <lttv/state.h> |
2d262115 |
70 | #include <lttvwindow/lttvwindow.h> |
6395d57c |
71 | #include <lttvwindow/lttvwindowtraces.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 |
81 | |
b9a010a2 |
82 | #if 0 |
83 | typedef struct _ProcessAddClosure { |
84 | ControlFlowData *cfd; |
85 | guint trace_num; |
86 | } ProcessAddClosure; |
87 | |
88 | static void process_add(gpointer key, |
89 | gpointer value, |
90 | gpointer user_data) |
91 | { |
92 | LttvProcessState *process = (LttvProcessState*)value; |
93 | ProcessAddClosure *closure = (ProcessAddClosure*)user_data; |
94 | ControlFlowData *control_flow_data = closure->cfd; |
95 | guint trace_num = closure->trace_num; |
96 | |
97 | /* Add process to process list (if not present) */ |
98 | guint pid; |
99 | LttTime birth; |
100 | guint y = 0, height = 0, pl_height = 0; |
101 | |
5c230fc4 |
102 | ProcessList *process_list = control_flow_data->process_list; |
b9a010a2 |
103 | |
104 | pid = process->pid; |
105 | birth = process->creation_time; |
106 | const gchar *name = g_quark_to_string(process->name); |
107 | HashedProcessData *hashed_process_data = NULL; |
108 | |
109 | if(processlist_get_process_pixels(process_list, |
110 | pid, |
111 | &birth, |
112 | trace_num, |
113 | &y, |
114 | &height, |
115 | &hashed_process_data) == 1) |
116 | { |
117 | /* Process not present */ |
118 | processlist_add(process_list, |
119 | pid, |
120 | &birth, |
121 | trace_num, |
122 | name, |
123 | &pl_height, |
124 | &hashed_process_data); |
125 | processlist_get_process_pixels(process_list, |
126 | pid, |
127 | &birth, |
128 | trace_num, |
129 | &y, |
130 | &height, |
131 | &hashed_process_data); |
132 | drawing_insert_square( control_flow_data->drawing, y, height); |
133 | } |
134 | } |
135 | #endif //0 |
136 | |
137 | |
6395d57c |
138 | /* Action to do when background computation completed. |
139 | * |
e800cf84 |
140 | * Wait for all the awaited computations to be over. |
6395d57c |
141 | */ |
142 | |
143 | gint background_ready(void *hook_data, void *call_data) |
144 | { |
145 | ControlFlowData *control_flow_data = (ControlFlowData *)hook_data; |
146 | LttvTrace *trace = (LttvTrace*)call_data; |
147 | |
e800cf84 |
148 | control_flow_data->background_info_waiting--; |
149 | |
150 | if(control_flow_data->background_info_waiting == 0) { |
151 | g_debug("control flow viewer : background computation data ready."); |
6395d57c |
152 | |
e800cf84 |
153 | drawing_clear(control_flow_data->drawing); |
154 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
155 | gtk_widget_set_size_request( |
156 | control_flow_data->drawing->drawing_area, |
157 | -1, processlist_get_height(control_flow_data->process_list)); |
e800cf84 |
158 | redraw_notify(control_flow_data, NULL); |
b9a010a2 |
159 | } |
6395d57c |
160 | |
161 | return 0; |
162 | } |
163 | |
164 | |
165 | /* Request background computation. Verify if it is in progress or ready first. |
e800cf84 |
166 | * Only for each trace in the tab's traceset. |
6395d57c |
167 | */ |
168 | void request_background_data(ControlFlowData *control_flow_data) |
169 | { |
e800cf84 |
170 | LttvTracesetContext * tsc = |
171 | lttvwindow_get_traceset_context(control_flow_data->tab); |
172 | gint num_traces = lttv_traceset_number(tsc->ts); |
6395d57c |
173 | gint i; |
174 | LttvTrace *trace; |
175 | |
176 | LttvHooks *background_ready_hook = |
177 | lttv_hooks_new(); |
178 | lttv_hooks_add(background_ready_hook, background_ready, control_flow_data, |
179 | LTTV_PRIO_DEFAULT); |
e800cf84 |
180 | control_flow_data->background_info_waiting = 0; |
6395d57c |
181 | |
182 | for(i=0;i<num_traces;i++) { |
e800cf84 |
183 | trace = lttv_traceset_get(tsc->ts, i); |
6395d57c |
184 | |
185 | if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE) { |
186 | |
187 | if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"), |
188 | trace) == FALSE) { |
189 | /* We first remove requests that could have been done for the same |
190 | * information. Happens when two viewers ask for it before servicing |
191 | * starts. |
192 | */ |
193 | lttvwindowtraces_background_request_remove(trace, "state"); |
194 | lttvwindowtraces_background_request_queue(trace, |
195 | "state"); |
196 | lttvwindowtraces_background_notify_queue(control_flow_data, |
197 | trace, |
198 | ltt_time_infinite, |
199 | NULL, |
200 | background_ready_hook); |
e800cf84 |
201 | control_flow_data->background_info_waiting++; |
6395d57c |
202 | } else { /* in progress */ |
203 | |
204 | lttvwindowtraces_background_notify_current(control_flow_data, |
205 | trace, |
206 | ltt_time_infinite, |
207 | NULL, |
208 | background_ready_hook); |
e800cf84 |
209 | control_flow_data->background_info_waiting++; |
6395d57c |
210 | } |
4368b993 |
211 | } else { |
212 | /* Data ready. Be its nature, this viewer doesn't need to have |
213 | * its data ready hook called htere, because a background |
214 | * request is always linked with a redraw. |
215 | */ |
6395d57c |
216 | } |
4368b993 |
217 | |
6395d57c |
218 | } |
219 | |
220 | lttv_hooks_destroy(background_ready_hook); |
221 | } |
222 | |
223 | |
224 | |
225 | |
f0d936c0 |
226 | /** |
227 | * Event Viewer's constructor hook |
228 | * |
229 | * This constructor is given as a parameter to the menuitem and toolbar button |
230 | * registration. It creates the list. |
ca0f8a8e |
231 | * @param tab A pointer to the parent tab. |
f0d936c0 |
232 | * @return The widget created. |
233 | */ |
234 | GtkWidget * |
d47b33d2 |
235 | h_guicontrolflow(Tab *tab) |
f0d936c0 |
236 | { |
d47b33d2 |
237 | g_info("h_guicontrolflow, %p", tab); |
68997a22 |
238 | ControlFlowData *control_flow_data = guicontrolflow() ; |
a56a1ba4 |
239 | |
ca0f8a8e |
240 | control_flow_data->tab = tab; |
a56a1ba4 |
241 | |
a56a1ba4 |
242 | // Unreg done in the GuiControlFlow_Destructor |
6395d57c |
243 | lttvwindow_register_traceset_notify(tab, |
244 | traceset_notify, |
245 | control_flow_data); |
246 | |
ca0f8a8e |
247 | lttvwindow_register_time_window_notify(tab, |
224446ce |
248 | update_time_window_hook, |
249 | control_flow_data); |
ca0f8a8e |
250 | lttvwindow_register_current_time_notify(tab, |
224446ce |
251 | update_current_time_hook, |
252 | control_flow_data); |
ca0f8a8e |
253 | lttvwindow_register_redraw_notify(tab, |
254 | redraw_notify, |
255 | control_flow_data); |
256 | lttvwindow_register_continue_notify(tab, |
257 | continue_notify, |
258 | control_flow_data); |
2c82c4dc |
259 | //request_background_data(control_flow_data); |
6395d57c |
260 | |
ca0f8a8e |
261 | |
68997a22 |
262 | return guicontrolflow_get_widget(control_flow_data) ; |
a56a1ba4 |
263 | |
f0d936c0 |
264 | } |
265 | |
3cff8cc1 |
266 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 |
267 | { |
68997a22 |
268 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
14963be0 |
269 | guint *event_number = (guint*) call_data; |
f0d936c0 |
270 | |
2a2fa4f0 |
271 | g_debug("DEBUG : event selected by main window : %u", *event_number); |
a56a1ba4 |
272 | |
2eef04b5 |
273 | return 0; |
f0d936c0 |
274 | } |
275 | |
9a1ec01b |
276 | /* Function that selects the color of status&exemode line */ |
6550d711 |
277 | static inline PropertiesLine prepare_s_e_line(LttvProcessState *process) |
9a1ec01b |
278 | { |
279 | PropertiesLine prop_line; |
280 | prop_line.line_width = 2; |
281 | prop_line.style = GDK_LINE_SOLID; |
282 | prop_line.y = MIDDLE; |
283 | //GdkColormap *colormap = gdk_colormap_get_system(); |
284 | |
9a1ec01b |
285 | if(process->state->s == LTTV_STATE_RUN) { |
286 | if(process->state->t == LTTV_STATE_USER_MODE) |
287 | prop_line.color = drawing_colors[COL_RUN_USER_MODE]; |
288 | else if(process->state->t == LTTV_STATE_SYSCALL) |
289 | prop_line.color = drawing_colors[COL_RUN_SYSCALL]; |
290 | else if(process->state->t == LTTV_STATE_TRAP) |
291 | prop_line.color = drawing_colors[COL_RUN_TRAP]; |
292 | else if(process->state->t == LTTV_STATE_IRQ) |
293 | prop_line.color = drawing_colors[COL_RUN_IRQ]; |
294 | else if(process->state->t == LTTV_STATE_MODE_UNKNOWN) |
295 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; |
296 | else |
297 | g_assert(FALSE); /* RUNNING MODE UNKNOWN */ |
298 | } else if(process->state->s == LTTV_STATE_WAIT) { |
299 | /* We don't show if we wait while in user mode, trap, irq or syscall */ |
300 | prop_line.color = drawing_colors[COL_WAIT]; |
301 | } else if(process->state->s == LTTV_STATE_WAIT_CPU) { |
302 | /* We don't show if we wait for CPU while in user mode, trap, irq |
303 | * or syscall */ |
304 | prop_line.color = drawing_colors[COL_WAIT_CPU]; |
305 | } else if(process->state->s == LTTV_STATE_ZOMBIE) { |
306 | prop_line.color = drawing_colors[COL_ZOMBIE]; |
307 | } else if(process->state->s == LTTV_STATE_WAIT_FORK) { |
308 | prop_line.color = drawing_colors[COL_WAIT_FORK]; |
309 | } else if(process->state->s == LTTV_STATE_EXIT) { |
310 | prop_line.color = drawing_colors[COL_EXIT]; |
311 | } else if(process->state->s == LTTV_STATE_UNNAMED) { |
312 | prop_line.color = drawing_colors[COL_UNNAMED]; |
313 | } else |
314 | g_assert(FALSE); /* UNKNOWN STATE */ |
315 | |
316 | return prop_line; |
317 | |
318 | } |
319 | |
320 | #if 0 |
6550d711 |
321 | static inline PropertiesLine prepare_status_line(LttvProcessState *process) |
c8bba5fa |
322 | { |
323 | PropertiesLine prop_line; |
324 | prop_line.line_width = 2; |
325 | prop_line.style = GDK_LINE_SOLID; |
e800cf84 |
326 | prop_line.y = MIDDLE; |
327 | //GdkColormap *colormap = gdk_colormap_get_system(); |
c8bba5fa |
328 | |
23093869 |
329 | g_debug("prepare_status_line for state : %s", |
330 | g_quark_to_string(process->state->s)); |
c8bba5fa |
331 | |
332 | /* color of line : status of the process */ |
333 | if(process->state->s == LTTV_STATE_UNNAMED) |
e800cf84 |
334 | prop_line.color = drawing_colors[COL_WHITE]; |
c8bba5fa |
335 | else if(process->state->s == LTTV_STATE_WAIT_FORK) |
e800cf84 |
336 | prop_line.color = drawing_colors[COL_WAIT_FORK]; |
c8bba5fa |
337 | else if(process->state->s == LTTV_STATE_WAIT_CPU) |
e800cf84 |
338 | prop_line.color = drawing_colors[COL_WAIT_CPU]; |
dbd243b1 |
339 | else if(process->state->s == LTTV_STATE_EXIT) |
340 | prop_line.color = drawing_colors[COL_EXIT]; |
0828099d |
341 | else if(process->state->s == LTTV_STATE_ZOMBIE) |
342 | prop_line.color = drawing_colors[COL_ZOMBIE]; |
c8bba5fa |
343 | else if(process->state->s == LTTV_STATE_WAIT) |
e800cf84 |
344 | prop_line.color = drawing_colors[COL_WAIT]; |
c8bba5fa |
345 | else if(process->state->s == LTTV_STATE_RUN) |
e800cf84 |
346 | prop_line.color = drawing_colors[COL_RUN]; |
c8bba5fa |
347 | else |
23093869 |
348 | prop_line.color = drawing_colors[COL_WHITE]; |
e800cf84 |
349 | |
350 | //gdk_colormap_alloc_color(colormap, |
351 | // prop_line.color, |
352 | // FALSE, |
353 | // TRUE); |
c8bba5fa |
354 | |
355 | return prop_line; |
356 | |
357 | } |
9a1ec01b |
358 | #endif //0 |
c8bba5fa |
359 | |
360 | |
e92eabaf |
361 | /* before_schedchange_hook |
b9a010a2 |
362 | * |
f0d936c0 |
363 | * This function basically draw lines and icons. Two types of lines are drawn : |
364 | * one small (3 pixels?) representing the state of the process and the second |
365 | * type is thicker (10 pixels?) representing on which CPU a process is running |
366 | * (and this only in running state). |
367 | * |
368 | * Extremums of the lines : |
369 | * x_min : time of the last event context for this process kept in memory. |
370 | * x_max : time of the current event. |
371 | * y : middle of the process in the process list. The process is found in the |
372 | * list, therefore is it's position in pixels. |
373 | * |
374 | * The choice of lines'color is defined by the context of the last event for this |
375 | * process. |
376 | */ |
b9a010a2 |
377 | |
378 | |
e92eabaf |
379 | int before_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 |
380 | { |
2c82c4dc |
381 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
382 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
b9a010a2 |
383 | ControlFlowData *control_flow_data = events_request->viewer_data; |
384 | |
385 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
386 | |
387 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
b9a010a2 |
388 | |
389 | LttEvent *e; |
2c82c4dc |
390 | e = ltt_tracefile_get_event(tfc->tf); |
b9a010a2 |
391 | |
392 | LttTime evtime = ltt_event_time(e); |
fd22065b |
393 | |
10a1069a |
394 | /* we are in a schedchange, before the state update. We must draw the |
395 | * items corresponding to the state before it changes : now is the right |
396 | * time to do it. |
397 | */ |
b9a010a2 |
398 | |
10a1069a |
399 | guint pid_out; |
400 | guint pid_in; |
401 | { |
2c82c4dc |
402 | pid_out = ltt_event_get_long_unsigned(e, thf->f1); |
403 | pid_in = ltt_event_get_long_unsigned(e, thf->f2); |
10a1069a |
404 | } |
405 | |
406 | { |
407 | /* For the pid_out */ |
408 | /* First, check if the current process is in the state computation |
409 | * process list. If it is there, that means we must add it right now and |
410 | * draw items from the beginning of the read for it. If it is not |
411 | * present, it's a new process and it was not present : it will |
412 | * be added after the state update. */ |
413 | LttvProcessState *process; |
40debf7b |
414 | /* unknown state, bad current pid */ |
415 | if(tfs->process->pid != pid_out) |
416 | process = lttv_state_find_process(tfs, pid_out); |
417 | else |
418 | process = tfs->process; |
b9a010a2 |
419 | |
10a1069a |
420 | if(process != NULL) { |
421 | /* Well, the process_out existed : we must get it in the process hash |
422 | * or add it, and draw its items. |
423 | */ |
424 | /* Add process to process list (if not present) */ |
1c736ed5 |
425 | guint pl_height = 0; |
10a1069a |
426 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
427 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
428 | LttTime birth = process->creation_time; |
b9a010a2 |
429 | |
ac4e21cf |
430 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
431 | pid_out, |
40debf7b |
432 | process->last_cpu_index, |
10a1069a |
433 | &birth, |
ac4e21cf |
434 | tfc->t_context->index); |
435 | if(hashed_process_data == NULL) |
10a1069a |
436 | { |
437 | g_assert(pid_out == 0 || pid_out != process->ppid); |
aac69e70 |
438 | const gchar *name = g_quark_to_string(process->name); |
10a1069a |
439 | /* Process not present */ |
4e86ae2e |
440 | ProcessInfo *process_info; |
1c736ed5 |
441 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
442 | processlist_add(process_list, |
1c736ed5 |
443 | drawing, |
10a1069a |
444 | pid_out, |
40debf7b |
445 | process->last_cpu_index, |
10a1069a |
446 | process->ppid, |
447 | &birth, |
448 | tfc->t_context->index, |
449 | name, |
450 | &pl_height, |
4e86ae2e |
451 | &process_info, |
10a1069a |
452 | &hashed_process_data); |
1c736ed5 |
453 | gtk_widget_set_size_request(drawing->drawing_area, |
454 | -1, |
455 | pl_height); |
456 | gtk_widget_queue_draw(drawing->drawing_area); |
457 | |
10a1069a |
458 | } |
ac4e21cf |
459 | |
10a1069a |
460 | /* Now, the process is in the state hash and our own process hash. |
461 | * We definitely can draw the items related to the ending state. |
462 | */ |
e800cf84 |
463 | |
b2743953 |
464 | if(ltt_time_compare(hashed_process_data->next_good_time, |
465 | evtime) > 0) |
10a1069a |
466 | { |
b2743953 |
467 | if(hashed_process_data->x.middle_marked == FALSE) { |
ac4e21cf |
468 | |
fd22065b |
469 | TimeWindow time_window = |
470 | lttvwindow_get_time_window(control_flow_data->tab); |
471 | #ifdef EXTRA_CHECK |
472 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
473 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
474 | return; |
475 | #endif //EXTRA_CHECK |
d6fef890 |
476 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
477 | guint width = drawing->width; |
b2743953 |
478 | guint x; |
479 | convert_time_to_pixels( |
480 | time_window, |
481 | evtime, |
482 | width, |
483 | &x); |
484 | |
485 | /* Draw collision indicator */ |
486 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
487 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
488 | drawing->gc, |
489 | x, |
1c736ed5 |
490 | (hashed_process_data->height/2)-3); |
b2743953 |
491 | hashed_process_data->x.middle_marked = TRUE; |
492 | } |
493 | } else { |
ac4e21cf |
494 | TimeWindow time_window = |
495 | lttvwindow_get_time_window(control_flow_data->tab); |
fd22065b |
496 | #ifdef EXTRA_CHECK |
ac4e21cf |
497 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
498 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
499 | return; |
fd22065b |
500 | #endif //EXTRA_CHECK |
d6fef890 |
501 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
502 | guint width = drawing->width; |
10a1069a |
503 | guint x; |
10a1069a |
504 | convert_time_to_pixels( |
a18124ff |
505 | time_window, |
4b7dc462 |
506 | evtime, |
507 | width, |
508 | &x); |
10a1069a |
509 | |
10a1069a |
510 | |
4b7dc462 |
511 | /* Jump over draw if we are at the same x position */ |
e72908ed |
512 | if(x == hashed_process_data->x.middle && |
513 | hashed_process_data->x.middle_used) |
e800cf84 |
514 | { |
e72908ed |
515 | if(hashed_process_data->x.middle_marked == FALSE) { |
516 | /* Draw collision indicator */ |
517 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
518 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
519 | drawing->gc, |
520 | x, |
1c736ed5 |
521 | (hashed_process_data->height/2)-3); |
de4ea1ad |
522 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
523 | } |
4b7dc462 |
524 | /* jump */ |
525 | } else { |
526 | DrawContext draw_context; |
10a1069a |
527 | |
4b7dc462 |
528 | /* Now create the drawing context that will be used to draw |
529 | * items related to the last state. */ |
1c736ed5 |
530 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
531 | draw_context.gc = drawing->gc; |
532 | draw_context.pango_layout = drawing->pango_layout; |
533 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
534 | draw_context.drawinfo.end.x = x; |
535 | |
1c736ed5 |
536 | draw_context.drawinfo.y.over = 1; |
537 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
538 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
539 | |
540 | draw_context.drawinfo.start.offset.over = 0; |
541 | draw_context.drawinfo.start.offset.middle = 0; |
542 | draw_context.drawinfo.start.offset.under = 0; |
543 | draw_context.drawinfo.end.offset.over = 0; |
544 | draw_context.drawinfo.end.offset.middle = 0; |
545 | draw_context.drawinfo.end.offset.under = 0; |
546 | |
547 | { |
548 | /* Draw the line */ |
9a1ec01b |
549 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
550 | draw_line((void*)&prop_line, (void*)&draw_context); |
551 | |
552 | } |
553 | /* become the last x position */ |
554 | hashed_process_data->x.middle = x; |
e72908ed |
555 | hashed_process_data->x.middle_used = TRUE; |
556 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
557 | |
558 | /* Calculate the next good time */ |
559 | convert_pixels_to_time(width, x+1, time_window, |
560 | &hashed_process_data->next_good_time); |
e800cf84 |
561 | } |
562 | } |
563 | } |
10a1069a |
564 | } |
e800cf84 |
565 | |
10a1069a |
566 | { |
567 | /* For the pid_in */ |
568 | /* First, check if the current process is in the state computation |
569 | * process list. If it is there, that means we must add it right now and |
570 | * draw items from the beginning of the read for it. If it is not |
571 | * present, it's a new process and it was not present : it will |
572 | * be added after the state update. */ |
573 | LttvProcessState *process; |
574 | process = lttv_state_find_process(tfs, pid_in); |
575 | |
576 | if(process != NULL) { |
577 | /* Well, the process_out existed : we must get it in the process hash |
578 | * or add it, and draw its items. |
579 | */ |
580 | /* Add process to process list (if not present) */ |
1c736ed5 |
581 | guint pl_height = 0; |
10a1069a |
582 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
583 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
584 | LttTime birth = process->creation_time; |
e800cf84 |
585 | |
ac4e21cf |
586 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
587 | pid_in, |
40debf7b |
588 | process->last_cpu_index, |
10a1069a |
589 | &birth, |
ac4e21cf |
590 | tfc->t_context->index); |
591 | if(hashed_process_data == NULL) |
10a1069a |
592 | { |
593 | g_assert(pid_in == 0 || pid_in != process->ppid); |
aac69e70 |
594 | const gchar *name = g_quark_to_string(process->name); |
10a1069a |
595 | /* Process not present */ |
4e86ae2e |
596 | ProcessInfo *process_info; |
1c736ed5 |
597 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
598 | processlist_add(process_list, |
1c736ed5 |
599 | drawing, |
10a1069a |
600 | pid_in, |
40debf7b |
601 | process->last_cpu_index, |
10a1069a |
602 | process->ppid, |
603 | &birth, |
604 | tfc->t_context->index, |
605 | name, |
606 | &pl_height, |
4e86ae2e |
607 | &process_info, |
10a1069a |
608 | &hashed_process_data); |
1c736ed5 |
609 | gtk_widget_set_size_request(drawing->drawing_area, |
610 | -1, |
611 | pl_height); |
612 | gtk_widget_queue_draw(drawing->drawing_area); |
613 | |
10a1069a |
614 | } |
40debf7b |
615 | //We could set the current process and hash here, but will be done |
616 | //by after schedchange hook |
10a1069a |
617 | |
618 | /* Now, the process is in the state hash and our own process hash. |
619 | * We definitely can draw the items related to the ending state. |
620 | */ |
b9a010a2 |
621 | |
b2743953 |
622 | if(ltt_time_compare(hashed_process_data->next_good_time, |
623 | evtime) > 0) |
10a1069a |
624 | { |
b2743953 |
625 | if(hashed_process_data->x.middle_marked == FALSE) { |
ac4e21cf |
626 | |
fd22065b |
627 | TimeWindow time_window = |
628 | lttvwindow_get_time_window(control_flow_data->tab); |
629 | #ifdef EXTRA_CHECK |
630 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
631 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
632 | return; |
633 | #endif //EXTRA_CHECK |
d6fef890 |
634 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
635 | guint width = drawing->width; |
b2743953 |
636 | guint x; |
637 | convert_time_to_pixels( |
638 | time_window, |
639 | evtime, |
640 | width, |
641 | &x); |
642 | |
643 | /* Draw collision indicator */ |
644 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
645 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
646 | drawing->gc, |
647 | x, |
1c736ed5 |
648 | (hashed_process_data->height/2)-3); |
b2743953 |
649 | hashed_process_data->x.middle_marked = TRUE; |
650 | } |
651 | } else { |
fd22065b |
652 | TimeWindow time_window = |
653 | lttvwindow_get_time_window(control_flow_data->tab); |
654 | #ifdef EXTRA_CHECK |
655 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
656 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
657 | return; |
658 | #endif //EXTRA_CHECK |
d6fef890 |
659 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
660 | guint width = drawing->width; |
10a1069a |
661 | guint x; |
10a1069a |
662 | |
663 | convert_time_to_pixels( |
a18124ff |
664 | time_window, |
4b7dc462 |
665 | evtime, |
666 | width, |
667 | &x); |
10a1069a |
668 | |
10a1069a |
669 | |
4b7dc462 |
670 | /* Jump over draw if we are at the same x position */ |
e72908ed |
671 | if(x == hashed_process_data->x.middle && |
672 | hashed_process_data->x.middle_used) |
4b7dc462 |
673 | { |
e72908ed |
674 | if(hashed_process_data->x.middle_marked == FALSE) { |
675 | /* Draw collision indicator */ |
676 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
677 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
678 | drawing->gc, |
679 | x, |
1c736ed5 |
680 | (hashed_process_data->height/2)-3); |
de4ea1ad |
681 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
682 | } |
4b7dc462 |
683 | /* jump */ |
684 | } else { |
685 | DrawContext draw_context; |
10a1069a |
686 | |
4b7dc462 |
687 | /* Now create the drawing context that will be used to draw |
688 | * items related to the last state. */ |
1c736ed5 |
689 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
690 | draw_context.gc = drawing->gc; |
691 | draw_context.pango_layout = drawing->pango_layout; |
692 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
693 | draw_context.drawinfo.end.x = x; |
10a1069a |
694 | |
1c736ed5 |
695 | draw_context.drawinfo.y.over = 1; |
696 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
697 | draw_context.drawinfo.y.under = hashed_process_data->height; |
10a1069a |
698 | |
4b7dc462 |
699 | draw_context.drawinfo.start.offset.over = 0; |
700 | draw_context.drawinfo.start.offset.middle = 0; |
701 | draw_context.drawinfo.start.offset.under = 0; |
702 | draw_context.drawinfo.end.offset.over = 0; |
703 | draw_context.drawinfo.end.offset.middle = 0; |
704 | draw_context.drawinfo.end.offset.under = 0; |
705 | |
706 | { |
707 | /* Draw the line */ |
9a1ec01b |
708 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
709 | draw_line((void*)&prop_line, (void*)&draw_context); |
710 | } |
711 | |
712 | |
713 | /* become the last x position */ |
714 | hashed_process_data->x.middle = x; |
e72908ed |
715 | hashed_process_data->x.middle_used = TRUE; |
716 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
717 | |
718 | /* Calculate the next good time */ |
719 | convert_pixels_to_time(width, x+1, time_window, |
720 | &hashed_process_data->next_good_time); |
4b7dc462 |
721 | } |
c8bba5fa |
722 | } |
b9a010a2 |
723 | } |
724 | } |
b9a010a2 |
725 | return 0; |
726 | |
727 | |
b9a010a2 |
728 | #if 0 |
ca0f8a8e |
729 | EventsRequest *events_request = (EventsRequest*)hook_data; |
730 | ControlFlowData *control_flow_data = |
731 | (ControlFlowData*)events_request->viewer_data; |
732 | Tab *tab = control_flow_data->tab; |
e9a9c513 |
733 | |
a56a1ba4 |
734 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
e9a9c513 |
735 | |
736 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1aff52a2 |
737 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
a56a1ba4 |
738 | |
e9a9c513 |
739 | LttEvent *e; |
e9a9c513 |
740 | e = tfc->e; |
741 | |
9444deae |
742 | LttTime evtime = ltt_event_time(e); |
ca0f8a8e |
743 | TimeWindow time_window = |
744 | lttvwindow_get_time_window(tab); |
9444deae |
745 | |
a2aab3a3 |
746 | LttTime time_window.end_time = time_window.time_window.end_time; |
6f26fc38 |
747 | |
9444deae |
748 | //if(time < time_beg || time > time_end) return; |
ca0f8a8e |
749 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
a2aab3a3 |
750 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
9444deae |
751 | return; |
752 | |
a56a1ba4 |
753 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
754 | { |
2a2fa4f0 |
755 | g_debug("schedchange!"); |
a56a1ba4 |
756 | |
757 | /* Add process to process list (if not present) and get drawing "y" from |
758 | * process position */ |
759 | guint pid_out, pid_in; |
760 | LttvProcessState *process_out, *process_in; |
761 | LttTime birth; |
762 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
763 | |
5c230fc4 |
764 | ProcessList *process_list = control_flow_data->process_list; |
a56a1ba4 |
765 | |
766 | |
767 | LttField *f = ltt_event_field(e); |
768 | LttField *element; |
769 | element = ltt_field_member(f,0); |
770 | pid_out = ltt_event_get_long_unsigned(e,element); |
771 | element = ltt_field_member(f,1); |
772 | pid_in = ltt_event_get_long_unsigned(e,element); |
2a2fa4f0 |
773 | g_debug("out : %u in : %u", pid_out, pid_in); |
a56a1ba4 |
774 | |
775 | |
776 | /* Find process pid_out in the list... */ |
87658614 |
777 | process_out = lttv_state_find_process(tfs, pid_out); |
1aff52a2 |
778 | if(process_out == NULL) return 0; |
2a2fa4f0 |
779 | g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
1aff52a2 |
780 | |
a56a1ba4 |
781 | birth = process_out->creation_time; |
51705146 |
782 | const gchar *name = g_quark_to_string(process_out->name); |
14963be0 |
783 | HashedProcessData *hashed_process_data_out = NULL; |
a56a1ba4 |
784 | |
785 | if(processlist_get_process_pixels(process_list, |
786 | pid_out, |
787 | &birth, |
d0cd7f09 |
788 | tfc->t_context->index, |
a56a1ba4 |
789 | &y_out, |
790 | &height, |
14963be0 |
791 | &hashed_process_data_out) == 1) |
a56a1ba4 |
792 | { |
51705146 |
793 | /* Process not present */ |
794 | processlist_add(process_list, |
795 | pid_out, |
796 | &birth, |
797 | tfc->t_context->index, |
798 | name, |
799 | &pl_height, |
800 | &hashed_process_data_out); |
801 | g_assert(processlist_get_process_pixels(process_list, |
802 | pid_out, |
803 | &birth, |
804 | tfc->t_context->index, |
805 | &y_out, |
806 | &height, |
807 | &hashed_process_data_out)==0); |
808 | drawing_insert_square( control_flow_data->drawing, y_out, height); |
a56a1ba4 |
809 | } |
51705146 |
810 | //g_free(name); |
a56a1ba4 |
811 | |
812 | /* Find process pid_in in the list... */ |
87658614 |
813 | process_in = lttv_state_find_process(tfs, pid_in); |
1aff52a2 |
814 | if(process_in == NULL) return 0; |
2a2fa4f0 |
815 | g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
a56a1ba4 |
816 | |
817 | birth = process_in->creation_time; |
51705146 |
818 | name = g_quark_to_string(process_in->name); |
14963be0 |
819 | HashedProcessData *hashed_process_data_in = NULL; |
a56a1ba4 |
820 | |
821 | if(processlist_get_process_pixels(process_list, |
822 | pid_in, |
823 | &birth, |
d0cd7f09 |
824 | tfc->t_context->index, |
a56a1ba4 |
825 | &y_in, |
826 | &height, |
14963be0 |
827 | &hashed_process_data_in) == 1) |
a56a1ba4 |
828 | { |
51705146 |
829 | /* Process not present */ |
a56a1ba4 |
830 | processlist_add(process_list, |
831 | pid_in, |
832 | &birth, |
d0cd7f09 |
833 | tfc->t_context->index, |
a56a1ba4 |
834 | name, |
835 | &pl_height, |
14963be0 |
836 | &hashed_process_data_in); |
a56a1ba4 |
837 | processlist_get_process_pixels(process_list, |
838 | pid_in, |
839 | &birth, |
d0cd7f09 |
840 | tfc->t_context->index, |
a56a1ba4 |
841 | &y_in, |
842 | &height, |
14963be0 |
843 | &hashed_process_data_in); |
a56a1ba4 |
844 | |
ca0f8a8e |
845 | drawing_insert_square( control_flow_data->drawing, y_in, height); |
a56a1ba4 |
846 | } |
51705146 |
847 | //g_free(name); |
a56a1ba4 |
848 | |
849 | |
850 | /* Find pixels corresponding to time of the event. If the time does |
851 | * not fit in the window, show a warning, not supposed to happend. */ |
852 | guint x = 0; |
51705146 |
853 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
854 | |
855 | LttTime time = ltt_event_time(e); |
856 | |
a2aab3a3 |
857 | LttTime window_end = time_window.time_window.end_time; |
a56a1ba4 |
858 | |
859 | convert_time_to_pixels( |
a18124ff |
860 | time_window, |
a56a1ba4 |
861 | time, |
862 | width, |
863 | &x); |
9444deae |
864 | //assert(x <= width); |
51705146 |
865 | // |
a56a1ba4 |
866 | /* draw what represents the event for outgoing process. */ |
867 | |
14963be0 |
868 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
68997a22 |
869 | draw_context_out->current->modify_over->x = x; |
319e9d81 |
870 | draw_context_out->current->modify_under->x = x; |
68997a22 |
871 | draw_context_out->current->modify_over->y = y_out; |
319e9d81 |
872 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
501d5405 |
873 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
874 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
875 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
876 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
d0cd7f09 |
877 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
878 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
a56a1ba4 |
879 | //draw_context_out->gc = widget->style->black_gc; |
880 | |
881 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
501d5405 |
882 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
a56a1ba4 |
883 | |
d0cd7f09 |
884 | /* Draw the line/background of the out process */ |
885 | if(draw_context_out->previous->middle->x == -1) |
886 | { |
ca0f8a8e |
887 | draw_context_out->previous->over->x = |
888 | control_flow_data->drawing->damage_begin; |
889 | draw_context_out->previous->middle->x = |
890 | control_flow_data->drawing->damage_begin; |
891 | draw_context_out->previous->under->x = |
892 | control_flow_data->drawing->damage_begin; |
ca0f8a8e |
893 | g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin); |
d0cd7f09 |
894 | } |
895 | |
896 | draw_context_out->current->middle->x = x; |
897 | draw_context_out->current->over->x = x; |
898 | draw_context_out->current->under->x = x; |
899 | draw_context_out->current->middle->y = y_out + height/2; |
900 | draw_context_out->current->over->y = y_out; |
901 | draw_context_out->current->under->y = y_out + height; |
902 | draw_context_out->previous->middle->y = y_out + height/2; |
903 | draw_context_out->previous->over->y = y_out; |
904 | draw_context_out->previous->under->y = y_out + height; |
905 | |
906 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
907 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
908 | |
909 | if(process_out->state->s == LTTV_STATE_RUN) |
910 | { |
51705146 |
911 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
912 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
913 | draw_context_out->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
914 | |
915 | PropertiesBG prop_bg; |
916 | prop_bg.color = g_new(GdkColor,1); |
917 | |
2c82c4dc |
918 | switch(ltt_tracefile_num(tfc->tf)) { |
d0cd7f09 |
919 | case 0: |
920 | prop_bg.color->red = 0x1515; |
921 | prop_bg.color->green = 0x1515; |
922 | prop_bg.color->blue = 0x8c8c; |
923 | break; |
924 | case 1: |
925 | prop_bg.color->red = 0x4e4e; |
926 | prop_bg.color->green = 0xa9a9; |
927 | prop_bg.color->blue = 0xa4a4; |
928 | break; |
929 | case 2: |
930 | prop_bg.color->red = 0x7a7a; |
931 | prop_bg.color->green = 0x4a4a; |
932 | prop_bg.color->blue = 0x8b8b; |
933 | break; |
934 | case 3: |
935 | prop_bg.color->red = 0x8080; |
936 | prop_bg.color->green = 0x7777; |
937 | prop_bg.color->blue = 0x4747; |
938 | break; |
939 | default: |
940 | prop_bg.color->red = 0xe7e7; |
941 | prop_bg.color->green = 0xe7e7; |
942 | prop_bg.color->blue = 0xe7e7; |
943 | } |
944 | |
2a2fa4f0 |
945 | g_debug("calling from draw_event"); |
d0cd7f09 |
946 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
947 | g_free(prop_bg.color); |
51705146 |
948 | //gdk_gc_unref(draw_context_out->gc); |
d0cd7f09 |
949 | } |
950 | |
951 | draw_context_out->gc = widget->style->black_gc; |
952 | |
a56a1ba4 |
953 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
2df6f2bd |
954 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
955 | PropertiesText prop_text_out; |
956 | prop_text_out.foreground = &colorfg_out; |
957 | prop_text_out.background = &colorbg_out; |
cfe526b1 |
958 | prop_text_out.size = 6; |
a56a1ba4 |
959 | prop_text_out.position = OVER; |
960 | |
cfe526b1 |
961 | /* color of text : status of the process */ |
962 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
963 | { |
964 | prop_text_out.foreground->red = 0xffff; |
965 | prop_text_out.foreground->green = 0xffff; |
966 | prop_text_out.foreground->blue = 0xffff; |
967 | } |
968 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
969 | { |
970 | prop_text_out.foreground->red = 0x0fff; |
d52cfc84 |
971 | prop_text_out.foreground->green = 0xffff; |
972 | prop_text_out.foreground->blue = 0xfff0; |
cfe526b1 |
973 | } |
974 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
975 | { |
2df6f2bd |
976 | prop_text_out.foreground->red = 0xffff; |
977 | prop_text_out.foreground->green = 0xffff; |
cfe526b1 |
978 | prop_text_out.foreground->blue = 0x0000; |
979 | } |
0828099d |
980 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
981 | { |
982 | prop_text_out.foreground->red = 0xffff; |
983 | prop_text_out.foreground->green = 0x0000; |
984 | prop_text_out.foreground->blue = 0xffff; |
985 | } |
986 | else if(process_out->state->s == LTTV_STATE_WAIT) |
987 | { |
988 | prop_text_out.foreground->red = 0xffff; |
989 | prop_text_out.foreground->green = 0x0000; |
990 | prop_text_out.foreground->blue = 0x0000; |
991 | } |
992 | else if(process_out->state->s == LTTV_STATE_RUN) |
993 | { |
994 | prop_text_out.foreground->red = 0x0000; |
995 | prop_text_out.foreground->green = 0xffff; |
996 | prop_text_out.foreground->blue = 0x0000; |
997 | } |
998 | else |
999 | { |
1000 | prop_text_out.foreground->red = 0xffff; |
1001 | prop_text_out.foreground->green = 0xffff; |
1002 | prop_text_out.foreground->blue = 0xffff; |
1003 | } |
1004 | |
d52cfc84 |
1005 | |
a56a1ba4 |
1006 | /* Print status of the process : U, WF, WC, E, W, R */ |
1007 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
cfe526b1 |
1008 | prop_text_out.text = "U->"; |
a56a1ba4 |
1009 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
cfe526b1 |
1010 | prop_text_out.text = "WF->"; |
a56a1ba4 |
1011 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
cfe526b1 |
1012 | prop_text_out.text = "WC->"; |
0828099d |
1013 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1014 | prop_text_out.text = "E->"; |
a56a1ba4 |
1015 | else if(process_out->state->s == LTTV_STATE_WAIT) |
cfe526b1 |
1016 | prop_text_out.text = "W->"; |
a56a1ba4 |
1017 | else if(process_out->state->s == LTTV_STATE_RUN) |
cfe526b1 |
1018 | prop_text_out.text = "R->"; |
a56a1ba4 |
1019 | else |
68997a22 |
1020 | prop_text_out.text = "U"; |
a56a1ba4 |
1021 | |
1022 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
d0cd7f09 |
1023 | //gdk_gc_unref(draw_context_out->gc); |
a56a1ba4 |
1024 | |
51705146 |
1025 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1026 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
1027 | draw_context_out->gc = control_flow_data->drawing->gc; |
a56a1ba4 |
1028 | |
1029 | PropertiesLine prop_line_out; |
1030 | prop_line_out.color = g_new(GdkColor,1); |
cfe526b1 |
1031 | prop_line_out.line_width = 2; |
a56a1ba4 |
1032 | prop_line_out.style = GDK_LINE_SOLID; |
1033 | prop_line_out.position = MIDDLE; |
d52cfc84 |
1034 | |
2a2fa4f0 |
1035 | g_debug("out state : %s", g_quark_to_string(process_out->state->s)); |
a56a1ba4 |
1036 | |
1037 | /* color of line : status of the process */ |
1038 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
1039 | { |
cfe526b1 |
1040 | prop_line_out.color->red = 0xffff; |
1041 | prop_line_out.color->green = 0xffff; |
1042 | prop_line_out.color->blue = 0xffff; |
a56a1ba4 |
1043 | } |
1044 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
1045 | { |
1046 | prop_line_out.color->red = 0x0fff; |
d52cfc84 |
1047 | prop_line_out.color->green = 0xffff; |
1048 | prop_line_out.color->blue = 0xfff0; |
a56a1ba4 |
1049 | } |
1050 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
1051 | { |
2df6f2bd |
1052 | prop_line_out.color->red = 0xffff; |
1053 | prop_line_out.color->green = 0xffff; |
a56a1ba4 |
1054 | prop_line_out.color->blue = 0x0000; |
1055 | } |
0828099d |
1056 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
a56a1ba4 |
1057 | { |
1058 | prop_line_out.color->red = 0xffff; |
1059 | prop_line_out.color->green = 0x0000; |
1060 | prop_line_out.color->blue = 0xffff; |
1061 | } |
1062 | else if(process_out->state->s == LTTV_STATE_WAIT) |
1063 | { |
1064 | prop_line_out.color->red = 0xffff; |
1065 | prop_line_out.color->green = 0x0000; |
1066 | prop_line_out.color->blue = 0x0000; |
1067 | } |
1068 | else if(process_out->state->s == LTTV_STATE_RUN) |
1069 | { |
1070 | prop_line_out.color->red = 0x0000; |
1071 | prop_line_out.color->green = 0xffff; |
1072 | prop_line_out.color->blue = 0x0000; |
1073 | } |
1074 | else |
1075 | { |
cfe526b1 |
1076 | prop_line_out.color->red = 0xffff; |
1077 | prop_line_out.color->green = 0xffff; |
1078 | prop_line_out.color->blue = 0xffff; |
a56a1ba4 |
1079 | } |
1080 | |
1081 | draw_line((void*)&prop_line_out, (void*)draw_context_out); |
1082 | g_free(prop_line_out.color); |
51705146 |
1083 | //gdk_gc_unref(draw_context_out->gc); |
a56a1ba4 |
1084 | /* Note : finishing line will have to be added when trace read over. */ |
1085 | |
1086 | /* Finally, update the drawing context of the pid_in. */ |
1087 | |
14963be0 |
1088 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
68997a22 |
1089 | draw_context_in->current->modify_over->x = x; |
319e9d81 |
1090 | draw_context_in->current->modify_under->x = x; |
68997a22 |
1091 | draw_context_in->current->modify_over->y = y_in; |
319e9d81 |
1092 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
501d5405 |
1093 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
1094 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
1095 | widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1096 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
1097 | //draw_context_in->gc = widget->style->black_gc; |
d0cd7f09 |
1098 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1099 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
a56a1ba4 |
1100 | |
1101 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
501d5405 |
1102 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1103 | |
1104 | /* Draw the line/bg of the in process */ |
1105 | if(draw_context_in->previous->middle->x == -1) |
1106 | { |
ca0f8a8e |
1107 | draw_context_in->previous->over->x = |
1108 | control_flow_data->drawing->damage_begin; |
1109 | draw_context_in->previous->middle->x = |
1110 | control_flow_data->drawing->damage_begin; |
1111 | draw_context_in->previous->under->x = |
1112 | control_flow_data->drawing->damage_begin; |
1113 | |
1114 | g_debug("in middle x_beg : %u",control_flow_data->drawing->damage_begin); |
1115 | |
d0cd7f09 |
1116 | } |
1117 | |
1118 | draw_context_in->current->middle->x = x; |
1119 | draw_context_in->current->over->x = x; |
1120 | draw_context_in->current->under->x = x; |
1121 | draw_context_in->current->middle->y = y_in + height/2; |
1122 | draw_context_in->current->over->y = y_in; |
1123 | draw_context_in->current->under->y = y_in + height; |
1124 | draw_context_in->previous->middle->y = y_in + height/2; |
1125 | draw_context_in->previous->over->y = y_in; |
1126 | draw_context_in->previous->under->y = y_in + height; |
a56a1ba4 |
1127 | |
d0cd7f09 |
1128 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
1129 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
1130 | |
1131 | |
1132 | if(process_in->state->s == LTTV_STATE_RUN) |
1133 | { |
51705146 |
1134 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1135 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
1136 | draw_context_in->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
1137 | |
1138 | PropertiesBG prop_bg; |
1139 | prop_bg.color = g_new(GdkColor,1); |
1140 | |
2c82c4dc |
1141 | switcht(ltt_tracefile_num(tfc->tf)) { |
d0cd7f09 |
1142 | case 0: |
1143 | prop_bg.color->red = 0x1515; |
1144 | prop_bg.color->green = 0x1515; |
1145 | prop_bg.color->blue = 0x8c8c; |
1146 | break; |
1147 | case 1: |
1148 | prop_bg.color->red = 0x4e4e; |
1149 | prop_bg.color->green = 0xa9a9; |
1150 | prop_bg.color->blue = 0xa4a4; |
1151 | break; |
1152 | case 2: |
1153 | prop_bg.color->red = 0x7a7a; |
1154 | prop_bg.color->green = 0x4a4a; |
1155 | prop_bg.color->blue = 0x8b8b; |
1156 | break; |
1157 | case 3: |
1158 | prop_bg.color->red = 0x8080; |
1159 | prop_bg.color->green = 0x7777; |
1160 | prop_bg.color->blue = 0x4747; |
1161 | break; |
1162 | default: |
1163 | prop_bg.color->red = 0xe7e7; |
1164 | prop_bg.color->green = 0xe7e7; |
1165 | prop_bg.color->blue = 0xe7e7; |
1166 | } |
1167 | |
1168 | |
1169 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
1170 | g_free(prop_bg.color); |
51705146 |
1171 | //gdk_gc_unref(draw_context_in->gc); |
d0cd7f09 |
1172 | } |
1173 | |
1174 | draw_context_in->gc = widget->style->black_gc; |
1175 | |
a56a1ba4 |
1176 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
2df6f2bd |
1177 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1178 | PropertiesText prop_text_in; |
1179 | prop_text_in.foreground = &colorfg_in; |
1180 | prop_text_in.background = &colorbg_in; |
cfe526b1 |
1181 | prop_text_in.size = 6; |
a56a1ba4 |
1182 | prop_text_in.position = OVER; |
1183 | |
2a2fa4f0 |
1184 | g_debug("in state : %s", g_quark_to_string(process_in->state->s)); |
cfe526b1 |
1185 | /* foreground of text : status of the process */ |
1186 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
1187 | { |
1188 | prop_text_in.foreground->red = 0xffff; |
1189 | prop_text_in.foreground->green = 0xffff; |
1190 | prop_text_in.foreground->blue = 0xffff; |
1191 | } |
1192 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
1193 | { |
1194 | prop_text_in.foreground->red = 0x0fff; |
d52cfc84 |
1195 | prop_text_in.foreground->green = 0xffff; |
1196 | prop_text_in.foreground->blue = 0xfff0; |
cfe526b1 |
1197 | } |
1198 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
1199 | { |
2df6f2bd |
1200 | prop_text_in.foreground->red = 0xffff; |
1201 | prop_text_in.foreground->green = 0xffff; |
cfe526b1 |
1202 | prop_text_in.foreground->blue = 0x0000; |
1203 | } |
0828099d |
1204 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1205 | { |
1206 | prop_text_in.foreground->red = 0xffff; |
1207 | prop_text_in.foreground->green = 0x0000; |
1208 | prop_text_in.foreground->blue = 0xffff; |
1209 | } |
1210 | else if(process_in->state->s == LTTV_STATE_WAIT) |
1211 | { |
1212 | prop_text_in.foreground->red = 0xffff; |
1213 | prop_text_in.foreground->green = 0x0000; |
1214 | prop_text_in.foreground->blue = 0x0000; |
1215 | } |
1216 | else if(process_in->state->s == LTTV_STATE_RUN) |
1217 | { |
1218 | prop_text_in.foreground->red = 0x0000; |
1219 | prop_text_in.foreground->green = 0xffff; |
1220 | prop_text_in.foreground->blue = 0x0000; |
1221 | } |
1222 | else |
1223 | { |
1224 | prop_text_in.foreground->red = 0xffff; |
1225 | prop_text_in.foreground->green = 0xffff; |
1226 | prop_text_in.foreground->blue = 0xffff; |
1227 | } |
1228 | |
1229 | |
1230 | |
a56a1ba4 |
1231 | /* Print status of the process : U, WF, WC, E, W, R */ |
1232 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
cfe526b1 |
1233 | prop_text_in.text = "U->"; |
a56a1ba4 |
1234 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
cfe526b1 |
1235 | prop_text_in.text = "WF->"; |
a56a1ba4 |
1236 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
cfe526b1 |
1237 | prop_text_in.text = "WC->"; |
0828099d |
1238 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1239 | prop_text_in.text = "E->"; |
a56a1ba4 |
1240 | else if(process_in->state->s == LTTV_STATE_WAIT) |
cfe526b1 |
1241 | prop_text_in.text = "W->"; |
a56a1ba4 |
1242 | else if(process_in->state->s == LTTV_STATE_RUN) |
cfe526b1 |
1243 | prop_text_in.text = "R->"; |
a56a1ba4 |
1244 | else |
68997a22 |
1245 | prop_text_in.text = "U"; |
a56a1ba4 |
1246 | |
1247 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
d0cd7f09 |
1248 | //gdk_gc_unref(draw_context_in->gc); |
1249 | |
51705146 |
1250 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1251 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
1252 | draw_context_in->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
1253 | |
a56a1ba4 |
1254 | PropertiesLine prop_line_in; |
1255 | prop_line_in.color = g_new(GdkColor,1); |
cfe526b1 |
1256 | prop_line_in.line_width = 2; |
a56a1ba4 |
1257 | prop_line_in.style = GDK_LINE_SOLID; |
1258 | prop_line_in.position = MIDDLE; |
1259 | |
1260 | /* color of line : status of the process */ |
1261 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
1262 | { |
cfe526b1 |
1263 | prop_line_in.color->red = 0xffff; |
1264 | prop_line_in.color->green = 0xffff; |
1265 | prop_line_in.color->blue = 0xffff; |
a56a1ba4 |
1266 | } |
1267 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
1268 | { |
1269 | prop_line_in.color->red = 0x0fff; |
d52cfc84 |
1270 | prop_line_in.color->green = 0xffff; |
1271 | prop_line_in.color->blue = 0xfff0; |
a56a1ba4 |
1272 | } |
1273 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
1274 | { |
2df6f2bd |
1275 | prop_line_in.color->red = 0xffff; |
1276 | prop_line_in.color->green = 0xffff; |
a56a1ba4 |
1277 | prop_line_in.color->blue = 0x0000; |
1278 | } |
0828099d |
1279 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
a56a1ba4 |
1280 | { |
1281 | prop_line_in.color->red = 0xffff; |
1282 | prop_line_in.color->green = 0x0000; |
1283 | prop_line_in.color->blue = 0xffff; |
1284 | } |
1285 | else if(process_in->state->s == LTTV_STATE_WAIT) |
1286 | { |
1287 | prop_line_in.color->red = 0xffff; |
1288 | prop_line_in.color->green = 0x0000; |
1289 | prop_line_in.color->blue = 0x0000; |
1290 | } |
1291 | else if(process_in->state->s == LTTV_STATE_RUN) |
1292 | { |
1293 | prop_line_in.color->red = 0x0000; |
1294 | prop_line_in.color->green = 0xffff; |
1295 | prop_line_in.color->blue = 0x0000; |
1296 | } |
1297 | else |
1298 | { |
cfe526b1 |
1299 | prop_line_in.color->red = 0xffff; |
1300 | prop_line_in.color->green = 0xffff; |
1301 | prop_line_in.color->blue = 0xffff; |
a56a1ba4 |
1302 | } |
1303 | |
1304 | draw_line((void*)&prop_line_in, (void*)draw_context_in); |
1305 | g_free(prop_line_in.color); |
51705146 |
1306 | //gdk_gc_unref(draw_context_in->gc); |
a56a1ba4 |
1307 | } |
1308 | |
1309 | return 0; |
b9a010a2 |
1310 | #endif //0 |
1311 | |
1312 | |
a56a1ba4 |
1313 | |
51705146 |
1314 | /* Text dump */ |
80a52ff8 |
1315 | #ifdef DONTSHOW |
a56a1ba4 |
1316 | GString *string = g_string_new("");; |
1317 | gboolean field_names = TRUE, state = TRUE; |
80a52ff8 |
1318 | |
e9a9c513 |
1319 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
1320 | g_string_append_printf(string,"\n"); |
1321 | |
1322 | if(state) { |
1323 | g_string_append_printf(string, " %s", |
1324 | g_quark_to_string(tfs->process->state->s)); |
1325 | } |
1326 | |
1327 | g_info("%s",string->str); |
1328 | |
a56a1ba4 |
1329 | g_string_free(string, TRUE); |
1330 | |
1331 | /* End of text dump */ |
80a52ff8 |
1332 | #endif //DONTSHOW |
50439712 |
1333 | |
f0d936c0 |
1334 | } |
1335 | |
e92eabaf |
1336 | /* after_schedchange_hook |
b9a010a2 |
1337 | * |
1338 | * The draw after hook is called by the reading API to have a |
1339 | * particular event drawn on the screen. |
1340 | * @param hook_data ControlFlowData structure of the viewer. |
1341 | * @param call_data Event context. |
1342 | * |
1343 | * This function adds items to be drawn in a queue for each process. |
1344 | * |
1345 | */ |
e92eabaf |
1346 | int after_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 |
1347 | { |
2c82c4dc |
1348 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
1349 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
ca0f8a8e |
1350 | ControlFlowData *control_flow_data = events_request->viewer_data; |
50439712 |
1351 | |
a56a1ba4 |
1352 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
50439712 |
1353 | |
1354 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1355 | |
b9a010a2 |
1356 | LttEvent *e; |
2c82c4dc |
1357 | e = ltt_tracefile_get_event(tfc->tf); |
b9a010a2 |
1358 | |
1359 | LttTime evtime = ltt_event_time(e); |
b9a010a2 |
1360 | |
10a1069a |
1361 | /* Add process to process list (if not present) */ |
2eef04b5 |
1362 | LttvProcessState *process_in; |
10a1069a |
1363 | LttTime birth; |
1c736ed5 |
1364 | guint pl_height = 0; |
10a1069a |
1365 | HashedProcessData *hashed_process_data_in = NULL; |
b9a010a2 |
1366 | |
5c230fc4 |
1367 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
1368 | |
1369 | guint pid_in; |
1370 | { |
1371 | guint pid_out; |
2c82c4dc |
1372 | pid_out = ltt_event_get_long_unsigned(e, thf->f1); |
1373 | pid_in = ltt_event_get_long_unsigned(e, thf->f2); |
10a1069a |
1374 | } |
b9a010a2 |
1375 | |
1376 | |
10a1069a |
1377 | /* Find process pid_in in the list... */ |
40debf7b |
1378 | //process_in = lttv_state_find_process(tfs, pid_in); |
1379 | process_in = tfs->process; |
10a1069a |
1380 | /* It should exist, because we are after the state update. */ |
96947fcf |
1381 | #ifdef EXTRA_CHECK |
10a1069a |
1382 | g_assert(process_in != NULL); |
96947fcf |
1383 | #endif //EXTRA_CHECK |
10a1069a |
1384 | birth = process_in->creation_time; |
b9a010a2 |
1385 | |
ac4e21cf |
1386 | hashed_process_data_in = processlist_get_process_data(process_list, |
10a1069a |
1387 | pid_in, |
40debf7b |
1388 | process_in->last_cpu_index, |
10a1069a |
1389 | &birth, |
ac4e21cf |
1390 | tfc->t_context->index); |
1391 | if(hashed_process_data_in == NULL) |
10a1069a |
1392 | { |
1393 | g_assert(pid_in == 0 || pid_in != process_in->ppid); |
aac69e70 |
1394 | const gchar *name = g_quark_to_string(process_in->name); |
4e86ae2e |
1395 | ProcessInfo *process_info; |
1c736ed5 |
1396 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
1397 | /* Process not present */ |
1398 | processlist_add(process_list, |
1c736ed5 |
1399 | drawing, |
10a1069a |
1400 | pid_in, |
40debf7b |
1401 | process_in->last_cpu_index, |
10a1069a |
1402 | process_in->ppid, |
1403 | &birth, |
1404 | tfc->t_context->index, |
1405 | name, |
1406 | &pl_height, |
4e86ae2e |
1407 | &process_info, |
10a1069a |
1408 | &hashed_process_data_in); |
1c736ed5 |
1409 | gtk_widget_set_size_request(drawing->drawing_area, |
1410 | -1, |
1411 | pl_height); |
1412 | gtk_widget_queue_draw(drawing->drawing_area); |
b9a010a2 |
1413 | } |
40debf7b |
1414 | /* Set the current process */ |
1415 | process_list->current_hash_data[process_in->last_cpu_index] = |
1416 | hashed_process_data_in; |
10a1069a |
1417 | |
b2743953 |
1418 | if(ltt_time_compare(hashed_process_data_in->next_good_time, |
1419 | evtime) <= 0) |
1420 | { |
fd22065b |
1421 | TimeWindow time_window = |
1422 | lttvwindow_get_time_window(control_flow_data->tab); |
1423 | |
1424 | #ifdef EXTRA_CHECK |
1425 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1426 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1427 | return; |
1428 | #endif //EXTRA_CHECK |
d6fef890 |
1429 | Drawing_t *drawing = control_flow_data->drawing; |
1430 | guint width = drawing->width; |
b2743953 |
1431 | guint new_x; |
1432 | |
1433 | convert_time_to_pixels( |
1434 | time_window, |
1435 | evtime, |
1436 | width, |
1437 | &new_x); |
e72908ed |
1438 | |
b2743953 |
1439 | if(hashed_process_data_in->x.middle != new_x) { |
1440 | hashed_process_data_in->x.middle = new_x; |
1441 | hashed_process_data_in->x.middle_used = FALSE; |
1442 | hashed_process_data_in->x.middle_marked = FALSE; |
1443 | } |
1444 | } |
b9a010a2 |
1445 | return 0; |
1446 | |
1447 | |
1448 | |
e72908ed |
1449 | |
1450 | |
b9a010a2 |
1451 | #if 0 |
1452 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1453 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1454 | |
1455 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1456 | |
1457 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1458 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
1459 | |
a56a1ba4 |
1460 | |
50439712 |
1461 | LttEvent *e; |
1462 | e = tfc->e; |
1463 | |
9444deae |
1464 | LttTime evtime = ltt_event_time(e); |
ca0f8a8e |
1465 | TimeWindow time_window = |
1466 | lttvwindow_get_time_window(control_flow_data->tab); |
9444deae |
1467 | |
a2aab3a3 |
1468 | LttTime time_window.end_time = time_window.time_window.end_time; |
6f26fc38 |
1469 | |
9444deae |
1470 | //if(time < time_beg || time > time_end) return; |
ca0f8a8e |
1471 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
a2aab3a3 |
1472 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
9444deae |
1473 | return; |
1474 | |
1475 | |
a56a1ba4 |
1476 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
1477 | { |
2a2fa4f0 |
1478 | g_debug("schedchange!"); |
a56a1ba4 |
1479 | |
1480 | /* Add process to process list (if not present) and get drawing "y" from |
1481 | * process position */ |
1482 | guint pid_out, pid_in; |
1483 | LttvProcessState *process_out, *process_in; |
1484 | LttTime birth; |
1485 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
1486 | |
5c230fc4 |
1487 | ProcessList *process_list = control_flow_data->process_list; |
a56a1ba4 |
1488 | |
1489 | |
1490 | LttField *f = ltt_event_field(e); |
1491 | LttField *element; |
1492 | element = ltt_field_member(f,0); |
1493 | pid_out = ltt_event_get_long_unsigned(e,element); |
1494 | element = ltt_field_member(f,1); |
1495 | pid_in = ltt_event_get_long_unsigned(e,element); |
2a2fa4f0 |
1496 | //g_debug("out : %u in : %u", pid_out, pid_in); |
a56a1ba4 |
1497 | |
1498 | |
1499 | /* Find process pid_out in the list... */ |
2a2fa4f0 |
1500 | process_out = lttv_state_find_process(tfs, pid_out); |
1aff52a2 |
1501 | if(process_out == NULL) return 0; |
2a2fa4f0 |
1502 | //g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
a56a1ba4 |
1503 | |
1504 | birth = process_out->creation_time; |
1505 | gchar *name = strdup(g_quark_to_string(process_out->name)); |
14963be0 |
1506 | HashedProcessData *hashed_process_data_out = NULL; |
a56a1ba4 |
1507 | |
1508 | if(processlist_get_process_pixels(process_list, |
1509 | pid_out, |
1510 | &birth, |
d0cd7f09 |
1511 | tfc->t_context->index, |
a56a1ba4 |
1512 | &y_out, |
1513 | &height, |
14963be0 |
1514 | &hashed_process_data_out) == 1) |
a56a1ba4 |
1515 | { |
51705146 |
1516 | /* Process not present */ |
1517 | processlist_add(process_list, |
1518 | pid_out, |
1519 | &birth, |
1520 | tfc->t_context->index, |
1521 | name, |
1522 | &pl_height, |
1523 | &hashed_process_data_out); |
1524 | processlist_get_process_pixels(process_list, |
1525 | pid_out, |
1526 | &birth, |
1527 | tfc->t_context->index, |
1528 | &y_out, |
1529 | &height, |
1530 | &hashed_process_data_out); |
1531 | drawing_insert_square( control_flow_data->drawing, y_out, height); |
a56a1ba4 |
1532 | } |
1533 | |
1534 | g_free(name); |
1535 | |
1536 | /* Find process pid_in in the list... */ |
2a2fa4f0 |
1537 | process_in = lttv_state_find_process(tfs, pid_in); |
1aff52a2 |
1538 | if(process_in == NULL) return 0; |
2a2fa4f0 |
1539 | //g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
a56a1ba4 |
1540 | |
1541 | birth = process_in->creation_time; |
1542 | name = strdup(g_quark_to_string(process_in->name)); |
14963be0 |
1543 | HashedProcessData *hashed_process_data_in = NULL; |
a56a1ba4 |
1544 | |
1545 | if(processlist_get_process_pixels(process_list, |
1546 | pid_in, |
1547 | &birth, |
d0cd7f09 |
1548 | tfc->t_context->index, |
a56a1ba4 |
1549 | &y_in, |
1550 | &height, |
14963be0 |
1551 | &hashed_process_data_in) == 1) |
a56a1ba4 |
1552 | { |
1553 | /* Process not present */ |
1554 | processlist_add(process_list, |
1555 | pid_in, |
1556 | &birth, |
d0cd7f09 |
1557 | tfc->t_context->index, |
a56a1ba4 |
1558 | name, |
1559 | &pl_height, |
14963be0 |
1560 | &hashed_process_data_in); |
a56a1ba4 |
1561 | processlist_get_process_pixels(process_list, |
1562 | pid_in, |
1563 | &birth, |
d0cd7f09 |
1564 | tfc->t_context->index, |
a56a1ba4 |
1565 | &y_in, |
1566 | &height, |
14963be0 |
1567 | &hashed_process_data_in); |
a56a1ba4 |
1568 | |
ca0f8a8e |
1569 | drawing_insert_square( control_flow_data->drawing, y_in, height); |
a56a1ba4 |
1570 | } |
1571 | g_free(name); |
1572 | |
1573 | |
1574 | /* Find pixels corresponding to time of the event. If the time does |
1575 | * not fit in the window, show a warning, not supposed to happend. */ |
1576 | //guint x = 0; |
501d5405 |
1577 | //guint width = control_flow_data->drawing->drawing_area->allocation.width; |
a56a1ba4 |
1578 | |
1579 | //LttTime time = ltt_event_time(e); |
1580 | |
a2aab3a3 |
1581 | //LttTime window_end = time_window->time_window.end_time; |
a56a1ba4 |
1582 | |
1583 | |
1584 | //convert_time_to_pixels( |
a18124ff |
1585 | // *time_window, |
a56a1ba4 |
1586 | // time, |
1587 | // width, |
1588 | // &x); |
1589 | |
1590 | //assert(x <= width); |
1591 | |
1592 | /* draw what represents the event for outgoing process. */ |
1593 | |
14963be0 |
1594 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
68997a22 |
1595 | //draw_context_out->current->modify_over->x = x; |
1596 | draw_context_out->current->modify_over->y = y_out; |
319e9d81 |
1597 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
501d5405 |
1598 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
1599 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
1600 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1601 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
d0cd7f09 |
1602 | |
a56a1ba4 |
1603 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
501d5405 |
1604 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1605 | |
1606 | /*if(process_out->state->s == LTTV_STATE_RUN) |
1607 | { |
1608 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1609 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
1610 | PropertiesBG prop_bg; |
1611 | prop_bg.color = g_new(GdkColor,1); |
1612 | |
1613 | prop_bg.color->red = 0xffff; |
1614 | prop_bg.color->green = 0xffff; |
1615 | prop_bg.color->blue = 0xffff; |
1616 | |
1617 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
1618 | g_free(prop_bg.color); |
1619 | gdk_gc_unref(draw_context_out->gc); |
1620 | }*/ |
1621 | |
1622 | draw_context_out->gc = widget->style->black_gc; |
1623 | |
a56a1ba4 |
1624 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
2df6f2bd |
1625 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1626 | PropertiesText prop_text_out; |
1627 | prop_text_out.foreground = &colorfg_out; |
1628 | prop_text_out.background = &colorbg_out; |
cfe526b1 |
1629 | prop_text_out.size = 6; |
a56a1ba4 |
1630 | prop_text_out.position = OVER; |
1631 | |
cfe526b1 |
1632 | /* color of text : status of the process */ |
1633 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
1634 | { |
1635 | prop_text_out.foreground->red = 0xffff; |
1636 | prop_text_out.foreground->green = 0xffff; |
1637 | prop_text_out.foreground->blue = 0xffff; |
1638 | } |
1639 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
1640 | { |
1641 | prop_text_out.foreground->red = 0x0fff; |
d52cfc84 |
1642 | prop_text_out.foreground->green = 0xffff; |
1643 | prop_text_out.foreground->blue = 0xfff0; |
cfe526b1 |
1644 | } |
1645 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
1646 | { |
2df6f2bd |
1647 | prop_text_out.foreground->red = 0xffff; |
1648 | prop_text_out.foreground->green = 0xffff; |
cfe526b1 |
1649 | prop_text_out.foreground->blue = 0x0000; |
1650 | } |
0828099d |
1651 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1652 | { |
1653 | prop_text_out.foreground->red = 0xffff; |
1654 | prop_text_out.foreground->green = 0x0000; |
1655 | prop_text_out.foreground->blue = 0xffff; |
1656 | } |
1657 | else if(process_out->state->s == LTTV_STATE_WAIT) |
1658 | { |
1659 | prop_text_out.foreground->red = 0xffff; |
1660 | prop_text_out.foreground->green = 0x0000; |
1661 | prop_text_out.foreground->blue = 0x0000; |
1662 | } |
1663 | else if(process_out->state->s == LTTV_STATE_RUN) |
1664 | { |
1665 | prop_text_out.foreground->red = 0x0000; |
1666 | prop_text_out.foreground->green = 0xffff; |
1667 | prop_text_out.foreground->blue = 0x0000; |
1668 | } |
1669 | else |
1670 | { |
1671 | prop_text_out.foreground->red = 0xffff; |
1672 | prop_text_out.foreground->green = 0xffff; |
1673 | prop_text_out.foreground->blue = 0xffff; |
1674 | } |
1675 | |
a56a1ba4 |
1676 | /* Print status of the process : U, WF, WC, E, W, R */ |
1677 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
68997a22 |
1678 | prop_text_out.text = "U"; |
a56a1ba4 |
1679 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
68997a22 |
1680 | prop_text_out.text = "WF"; |
a56a1ba4 |
1681 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
68997a22 |
1682 | prop_text_out.text = "WC"; |
0828099d |
1683 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
68997a22 |
1684 | prop_text_out.text = "E"; |
a56a1ba4 |
1685 | else if(process_out->state->s == LTTV_STATE_WAIT) |
68997a22 |
1686 | prop_text_out.text = "W"; |
a56a1ba4 |
1687 | else if(process_out->state->s == LTTV_STATE_RUN) |
68997a22 |
1688 | prop_text_out.text = "R"; |
a56a1ba4 |
1689 | else |
68997a22 |
1690 | prop_text_out.text = "U"; |
a56a1ba4 |
1691 | |
1692 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
d0cd7f09 |
1693 | |
1694 | //gdk_gc_unref(draw_context_out->gc); |
319e9d81 |
1695 | |
68997a22 |
1696 | draw_context_out->current->middle->y = y_out+height/2; |
d0cd7f09 |
1697 | draw_context_out->current->over->y = y_out; |
1698 | draw_context_out->current->under->y = y_out+height; |
68997a22 |
1699 | draw_context_out->current->status = process_out->state->s; |
a56a1ba4 |
1700 | |
68997a22 |
1701 | /* for pid_out : remove previous, Prev = current, new current (default) */ |
1702 | g_free(draw_context_out->previous->modify_under); |
1703 | g_free(draw_context_out->previous->modify_middle); |
1704 | g_free(draw_context_out->previous->modify_over); |
1705 | g_free(draw_context_out->previous->under); |
1706 | g_free(draw_context_out->previous->middle); |
1707 | g_free(draw_context_out->previous->over); |
1708 | g_free(draw_context_out->previous); |
1709 | |
1710 | draw_context_out->previous = draw_context_out->current; |
a56a1ba4 |
1711 | |
68997a22 |
1712 | draw_context_out->current = g_new(DrawInfo,1); |
1713 | draw_context_out->current->over = g_new(ItemInfo,1); |
1714 | draw_context_out->current->over->x = -1; |
1715 | draw_context_out->current->over->y = -1; |
1716 | draw_context_out->current->middle = g_new(ItemInfo,1); |
1717 | draw_context_out->current->middle->x = -1; |
1718 | draw_context_out->current->middle->y = -1; |
1719 | draw_context_out->current->under = g_new(ItemInfo,1); |
1720 | draw_context_out->current->under->x = -1; |
1721 | draw_context_out->current->under->y = -1; |
1722 | draw_context_out->current->modify_over = g_new(ItemInfo,1); |
1723 | draw_context_out->current->modify_over->x = -1; |
1724 | draw_context_out->current->modify_over->y = -1; |
1725 | draw_context_out->current->modify_middle = g_new(ItemInfo,1); |
1726 | draw_context_out->current->modify_middle->x = -1; |
1727 | draw_context_out->current->modify_middle->y = -1; |
1728 | draw_context_out->current->modify_under = g_new(ItemInfo,1); |
1729 | draw_context_out->current->modify_under->x = -1; |
1730 | draw_context_out->current->modify_under->y = -1; |
1731 | draw_context_out->current->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1732 | |
1733 | /* Finally, update the drawing context of the pid_in. */ |
1734 | |
14963be0 |
1735 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
68997a22 |
1736 | //draw_context_in->current->modify_over->x = x; |
1737 | draw_context_in->current->modify_over->y = y_in; |
319e9d81 |
1738 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
501d5405 |
1739 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
1740 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
1741 | widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1742 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
a56a1ba4 |
1743 | |
1744 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
501d5405 |
1745 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1746 | |
1747 | /*if(process_in->state->s == LTTV_STATE_RUN) |
1748 | { |
1749 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1750 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
1751 | PropertiesBG prop_bg; |
1752 | prop_bg.color = g_new(GdkColor,1); |
1753 | |
1754 | prop_bg.color->red = 0xffff; |
1755 | prop_bg.color->green = 0xffff; |
1756 | prop_bg.color->blue = 0xffff; |
1757 | |
1758 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
1759 | g_free(prop_bg.color); |
1760 | gdk_gc_unref(draw_context_in->gc); |
1761 | }*/ |
1762 | |
1763 | draw_context_in->gc = widget->style->black_gc; |
1764 | |
a56a1ba4 |
1765 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
2df6f2bd |
1766 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1767 | PropertiesText prop_text_in; |
1768 | prop_text_in.foreground = &colorfg_in; |
1769 | prop_text_in.background = &colorbg_in; |
cfe526b1 |
1770 | prop_text_in.size = 6; |
a56a1ba4 |
1771 | prop_text_in.position = OVER; |
1772 | |
cfe526b1 |
1773 | /* foreground of text : status of the process */ |
1774 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
1775 | { |
1776 | prop_text_in.foreground->red = 0xffff; |
1777 | prop_text_in.foreground->green = 0xffff; |
1778 | prop_text_in.foreground->blue = 0xffff; |
1779 | } |
1780 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
1781 | { |
1782 | prop_text_in.foreground->red = 0x0fff; |
d52cfc84 |
1783 | prop_text_in.foreground->green = 0xffff; |
1784 | prop_text_in.foreground->blue = 0xfff0; |
cfe526b1 |
1785 | } |
1786 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
1787 | { |
2df6f2bd |
1788 | prop_text_in.foreground->red = 0xffff; |
1789 | prop_text_in.foreground->green = 0xffff; |
cfe526b1 |
1790 | prop_text_in.foreground->blue = 0x0000; |
1791 | } |
0828099d |
1792 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1793 | { |
1794 | prop_text_in.foreground->red = 0xffff; |
1795 | prop_text_in.foreground->green = 0x0000; |
1796 | prop_text_in.foreground->blue = 0xffff; |
1797 | } |
1798 | else if(process_in->state->s == LTTV_STATE_WAIT) |
1799 | { |
1800 | prop_text_in.foreground->red = 0xffff; |
1801 | prop_text_in.foreground->green = 0x0000; |
1802 | prop_text_in.foreground->blue = 0x0000; |
1803 | } |
1804 | else if(process_in->state->s == LTTV_STATE_RUN) |
1805 | { |
1806 | prop_text_in.foreground->red = 0x0000; |
1807 | prop_text_in.foreground->green = 0xffff; |
1808 | prop_text_in.foreground->blue = 0x0000; |
1809 | } |
1810 | else |
1811 | { |
1812 | prop_text_in.foreground->red = 0xffff; |
1813 | prop_text_in.foreground->green = 0xffff; |
1814 | prop_text_in.foreground->blue = 0xffff; |
1815 | } |
1816 | |
1817 | |
a56a1ba4 |
1818 | /* Print status of the process : U, WF, WC, E, W, R */ |
1819 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
68997a22 |
1820 | prop_text_in.text = "U"; |
a56a1ba4 |
1821 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
68997a22 |
1822 | prop_text_in.text = "WF"; |
a56a1ba4 |
1823 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
68997a22 |
1824 | prop_text_in.text = "WC"; |
0828099d |
1825 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
68997a22 |
1826 | prop_text_in.text = "E"; |
a56a1ba4 |
1827 | else if(process_in->state->s == LTTV_STATE_WAIT) |
68997a22 |
1828 | prop_text_in.text = "W"; |
a56a1ba4 |
1829 | else if(process_in->state->s == LTTV_STATE_RUN) |
68997a22 |
1830 | prop_text_in.text = "R"; |
a56a1ba4 |
1831 | else |
68997a22 |
1832 | prop_text_in.text = "U"; |
a56a1ba4 |
1833 | |
1834 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
1835 | |
d0cd7f09 |
1836 | |
319e9d81 |
1837 | if(process_in->state->s == LTTV_STATE_RUN) |
1838 | { |
1839 | gchar tmp[255]; |
1840 | prop_text_in.foreground = &colorfg_in; |
1841 | prop_text_in.background = &colorbg_in; |
1842 | prop_text_in.foreground->red = 0xffff; |
1843 | prop_text_in.foreground->green = 0xffff; |
1844 | prop_text_in.foreground->blue = 0xffff; |
1845 | prop_text_in.size = 6; |
1846 | prop_text_in.position = UNDER; |
1847 | |
1848 | prop_text_in.text = g_new(gchar, 260); |
1849 | strcpy(prop_text_in.text, "CPU "); |
2c82c4dc |
1850 | snprintf(tmp, 255, "%u", ltt_tracefile_num(tfc->tf)); |
319e9d81 |
1851 | strcat(prop_text_in.text, tmp); |
1852 | |
1853 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
1854 | g_free(prop_text_in.text); |
1855 | } |
1856 | |
1857 | |
68997a22 |
1858 | draw_context_in->current->middle->y = y_in+height/2; |
d0cd7f09 |
1859 | draw_context_in->current->over->y = y_in; |
1860 | draw_context_in->current->under->y = y_in+height; |
68997a22 |
1861 | draw_context_in->current->status = process_in->state->s; |
1862 | |
1863 | /* for pid_in : remove previous, Prev = current, new current (default) */ |
1864 | g_free(draw_context_in->previous->modify_under); |
1865 | g_free(draw_context_in->previous->modify_middle); |
1866 | g_free(draw_context_in->previous->modify_over); |
1867 | g_free(draw_context_in->previous->under); |
1868 | g_free(draw_context_in->previous->middle); |
1869 | g_free(draw_context_in->previous->over); |
1870 | g_free(draw_context_in->previous); |
1871 | |
1872 | draw_context_in->previous = draw_context_in->current; |
a56a1ba4 |
1873 | |
68997a22 |
1874 | draw_context_in->current = g_new(DrawInfo,1); |
1875 | draw_context_in->current->over = g_new(ItemInfo,1); |
1876 | draw_context_in->current->over->x = -1; |
1877 | draw_context_in->current->over->y = -1; |
1878 | draw_context_in->current->middle = g_new(ItemInfo,1); |
1879 | draw_context_in->current->middle->x = -1; |
1880 | draw_context_in->current->middle->y = -1; |
1881 | draw_context_in->current->under = g_new(ItemInfo,1); |
1882 | draw_context_in->current->under->x = -1; |
1883 | draw_context_in->current->under->y = -1; |
1884 | draw_context_in->current->modify_over = g_new(ItemInfo,1); |
1885 | draw_context_in->current->modify_over->x = -1; |
1886 | draw_context_in->current->modify_over->y = -1; |
1887 | draw_context_in->current->modify_middle = g_new(ItemInfo,1); |
1888 | draw_context_in->current->modify_middle->x = -1; |
1889 | draw_context_in->current->modify_middle->y = -1; |
1890 | draw_context_in->current->modify_under = g_new(ItemInfo,1); |
1891 | draw_context_in->current->modify_under->x = -1; |
1892 | draw_context_in->current->modify_under->y = -1; |
1893 | draw_context_in->current->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1894 | |
1895 | } |
1896 | |
1897 | return 0; |
b9a010a2 |
1898 | #endif //0 |
f0d936c0 |
1899 | } |
f7afe191 |
1900 | |
9a1ec01b |
1901 | #if 0 |
6550d711 |
1902 | static inline PropertiesLine prepare_execmode_line(LttvProcessState *process) |
23093869 |
1903 | { |
1904 | PropertiesLine prop_line; |
1905 | prop_line.line_width = 1; |
1906 | prop_line.style = GDK_LINE_SOLID; |
1907 | prop_line.y = OVER; |
1908 | //GdkColormap *colormap = gdk_colormap_get_system(); |
1909 | |
1910 | /* color of line : execution mode of the process */ |
1911 | if(process->state->t == LTTV_STATE_USER_MODE) |
1912 | prop_line.color = drawing_colors[COL_USER_MODE]; |
1913 | else if(process->state->t == LTTV_STATE_SYSCALL) |
1914 | prop_line.color = drawing_colors[COL_SYSCALL]; |
1915 | else if(process->state->t == LTTV_STATE_TRAP) |
1916 | prop_line.color = drawing_colors[COL_TRAP]; |
1917 | else if(process->state->t == LTTV_STATE_IRQ) |
1918 | prop_line.color = drawing_colors[COL_IRQ]; |
1919 | else if(process->state->t == LTTV_STATE_MODE_UNKNOWN) |
1920 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; |
1921 | else |
1922 | prop_line.color = drawing_colors[COL_WHITE]; |
1923 | |
1924 | //gdk_colormap_alloc_color(colormap, |
1925 | // prop_line.color, |
1926 | // FALSE, |
1927 | // TRUE); |
1928 | |
1929 | return prop_line; |
1930 | |
1931 | } |
9a1ec01b |
1932 | #endif //0 |
23093869 |
1933 | |
1934 | |
1935 | /* before_execmode_hook |
1936 | * |
1937 | * This function basically draw lines and icons. Two types of lines are drawn : |
1938 | * one small (3 pixels?) representing the state of the process and the second |
1939 | * type is thicker (10 pixels?) representing on which CPU a process is running |
1940 | * (and this only in running state). |
1941 | * |
1942 | * Extremums of the lines : |
1943 | * x_min : time of the last event context for this process kept in memory. |
1944 | * x_max : time of the current event. |
1945 | * y : middle of the process in the process list. The process is found in the |
1946 | * list, therefore is it's position in pixels. |
1947 | * |
1948 | * The choice of lines'color is defined by the context of the last event for this |
1949 | * process. |
1950 | */ |
1951 | |
1952 | |
1953 | int before_execmode_hook(void *hook_data, void *call_data) |
1954 | { |
2c82c4dc |
1955 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
1956 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
23093869 |
1957 | ControlFlowData *control_flow_data = events_request->viewer_data; |
23093869 |
1958 | |
1959 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1960 | |
1961 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
23093869 |
1962 | |
1963 | LttEvent *e; |
2c82c4dc |
1964 | e = ltt_tracefile_get_event(tfc->tf); |
23093869 |
1965 | |
1966 | LttTime evtime = ltt_event_time(e); |
23093869 |
1967 | |
10a1069a |
1968 | /* we are in a execmode, before the state update. We must draw the |
1969 | * items corresponding to the state before it changes : now is the right |
1970 | * time to do it. |
1971 | */ |
1972 | /* For the pid */ |
1973 | LttvProcessState *process = tfs->process; |
1974 | g_assert(process != NULL); |
23093869 |
1975 | |
10a1069a |
1976 | guint pid = process->pid; |
23093869 |
1977 | |
10a1069a |
1978 | /* Well, the process_out existed : we must get it in the process hash |
1979 | * or add it, and draw its items. |
1980 | */ |
1981 | /* Add process to process list (if not present) */ |
1c736ed5 |
1982 | guint pl_height = 0; |
10a1069a |
1983 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
1984 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
1985 | LttTime birth = process->creation_time; |
40debf7b |
1986 | |
2c82c4dc |
1987 | if(likely(process_list->current_hash_data[ltt_tracefile_num(tfc->tf)] != NULL)) { |
1988 | hashed_process_data = process_list->current_hash_data[ltt_tracefile_num(tfc->tf)]; |
40debf7b |
1989 | } else { |
ac4e21cf |
1990 | hashed_process_data = processlist_get_process_data(process_list, |
40debf7b |
1991 | pid, |
1992 | process->last_cpu_index, |
1993 | &birth, |
ac4e21cf |
1994 | tfc->t_context->index); |
1d1df11d |
1995 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
1996 | { |
1997 | g_assert(pid == 0 || pid != process->ppid); |
1998 | ProcessInfo *process_info; |
1999 | /* Process not present */ |
1c736ed5 |
2000 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
2001 | const gchar *name = g_quark_to_string(process->name); |
2002 | processlist_add(process_list, |
1c736ed5 |
2003 | drawing, |
40debf7b |
2004 | pid, |
2005 | process->last_cpu_index, |
2006 | process->ppid, |
2007 | &birth, |
2008 | tfc->t_context->index, |
2009 | name, |
2010 | &pl_height, |
2011 | &process_info, |
2012 | &hashed_process_data); |
1c736ed5 |
2013 | gtk_widget_set_size_request(drawing->drawing_area, |
2014 | -1, |
2015 | pl_height); |
2016 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
2017 | } |
2018 | /* Set the current process */ |
2019 | process_list->current_hash_data[process->last_cpu_index] = |
2020 | hashed_process_data; |
10a1069a |
2021 | } |
23093869 |
2022 | |
10a1069a |
2023 | /* Now, the process is in the state hash and our own process hash. |
2024 | * We definitely can draw the items related to the ending state. |
2025 | */ |
b2743953 |
2026 | |
1d1df11d |
2027 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
2028 | evtime) > 0)) |
10a1069a |
2029 | { |
1d1df11d |
2030 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
fd22065b |
2031 | TimeWindow time_window = |
2032 | lttvwindow_get_time_window(control_flow_data->tab); |
2033 | |
2034 | #ifdef EXTRA_CHECK |
2035 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2036 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2037 | return; |
2038 | #endif //EXTRA_CHECK |
d6fef890 |
2039 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2040 | guint width = drawing->width; |
b2743953 |
2041 | guint x; |
2042 | convert_time_to_pixels( |
2043 | time_window, |
2044 | evtime, |
2045 | width, |
2046 | &x); |
2047 | |
2048 | /* Draw collision indicator */ |
2049 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
2050 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
2051 | drawing->gc, |
2052 | x, |
1c736ed5 |
2053 | (hashed_process_data->height/2)-3); |
b2743953 |
2054 | hashed_process_data->x.middle_marked = TRUE; |
2055 | } |
2056 | } else { |
fd22065b |
2057 | TimeWindow time_window = |
2058 | lttvwindow_get_time_window(control_flow_data->tab); |
2059 | |
2060 | #ifdef EXTRA_CHECK |
2061 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2062 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2063 | return; |
2064 | #endif //EXTRA_CHECK |
d6fef890 |
2065 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2066 | guint width = drawing->width; |
10a1069a |
2067 | guint x; |
dbd243b1 |
2068 | |
10a1069a |
2069 | convert_time_to_pixels( |
a18124ff |
2070 | time_window, |
10a1069a |
2071 | evtime, |
2072 | width, |
2073 | &x); |
dbd243b1 |
2074 | |
23093869 |
2075 | |
4b7dc462 |
2076 | /* Jump over draw if we are at the same x position */ |
1d1df11d |
2077 | if(unlikely(x == hashed_process_data->x.middle && |
2078 | hashed_process_data->x.middle_used)) |
10a1069a |
2079 | { |
1d1df11d |
2080 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
e72908ed |
2081 | /* Draw collision indicator */ |
2082 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
2083 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
2084 | drawing->gc, |
2085 | x, |
1c736ed5 |
2086 | (hashed_process_data->height/2)-3); |
de4ea1ad |
2087 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
2088 | } |
4b7dc462 |
2089 | /* jump */ |
2090 | } else { |
2091 | |
2092 | DrawContext draw_context; |
2093 | /* Now create the drawing context that will be used to draw |
2094 | * items related to the last state. */ |
1c736ed5 |
2095 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
2096 | draw_context.gc = drawing->gc; |
2097 | draw_context.pango_layout = drawing->pango_layout; |
9a1ec01b |
2098 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
4b7dc462 |
2099 | draw_context.drawinfo.end.x = x; |
2100 | |
1c736ed5 |
2101 | draw_context.drawinfo.y.over = 1; |
2102 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2103 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
2104 | |
2105 | draw_context.drawinfo.start.offset.over = 0; |
2106 | draw_context.drawinfo.start.offset.middle = 0; |
2107 | draw_context.drawinfo.start.offset.under = 0; |
2108 | draw_context.drawinfo.end.offset.over = 0; |
2109 | draw_context.drawinfo.end.offset.middle = 0; |
2110 | draw_context.drawinfo.end.offset.under = 0; |
2111 | |
2112 | { |
2113 | /* Draw the line */ |
9a1ec01b |
2114 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
2115 | draw_line((void*)&prop_line, (void*)&draw_context); |
23093869 |
2116 | |
4b7dc462 |
2117 | } |
2118 | /* become the last x position */ |
9a1ec01b |
2119 | hashed_process_data->x.middle = x; |
e72908ed |
2120 | hashed_process_data->x.middle_used = TRUE; |
2121 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
2122 | |
2123 | /* Calculate the next good time */ |
2124 | convert_pixels_to_time(width, x+1, time_window, |
2125 | &hashed_process_data->next_good_time); |
23093869 |
2126 | } |
2127 | } |
2128 | |
2129 | return 0; |
2130 | } |
2131 | |
2132 | /* after_execmode_hook |
2133 | * |
2134 | * The draw after hook is called by the reading API to have a |
2135 | * particular event drawn on the screen. |
2136 | * @param hook_data ControlFlowData structure of the viewer. |
2137 | * @param call_data Event context. |
2138 | * |
2139 | * This function adds items to be drawn in a queue for each process. |
2140 | * |
2141 | */ |
2142 | int after_execmode_hook(void *hook_data, void *call_data) |
2143 | { |
8869ac08 |
2144 | /**************** DOES NOTHING!! *************/ |
2145 | /* hook desactivated in drawing.c */ |
2146 | return 0; |
2147 | |
2148 | |
2c82c4dc |
2149 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
2150 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
23093869 |
2151 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2152 | |
2153 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
2154 | |
2155 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
23093869 |
2156 | |
2157 | LttEvent *e; |
2c82c4dc |
2158 | e = ltt_tracefile_get_event(tfc->tf); |
23093869 |
2159 | |
2160 | LttTime evtime = ltt_event_time(e); |
23093869 |
2161 | |
10a1069a |
2162 | /* Add process to process list (if not present) */ |
2163 | LttvProcessState *process; |
2164 | LttTime birth; |
1c736ed5 |
2165 | guint pl_height = 0; |
10a1069a |
2166 | HashedProcessData *hashed_process_data = NULL; |
23093869 |
2167 | |
5c230fc4 |
2168 | ProcessList *process_list = control_flow_data->process_list; |
23093869 |
2169 | |
10a1069a |
2170 | /* Find process pid_in in the list... */ |
2171 | process = tfs->process; |
2172 | /* It should exist, because we are after the state update. */ |
2173 | g_assert(process != NULL); |
23093869 |
2174 | |
10a1069a |
2175 | guint pid = process->pid; |
23093869 |
2176 | |
10a1069a |
2177 | birth = process->creation_time; |
23093869 |
2178 | |
2c82c4dc |
2179 | if(likely(process_list->current_hash_data[ltt_tracefile_num(tfc->tf)] != NULL)) { |
2180 | hashed_process_data = process_list->current_hash_data[ltt_tracefile_num(tfc->tf)]; |
40debf7b |
2181 | } else { |
ac4e21cf |
2182 | hashed_process_data = processlist_get_process_data(process_list, |
40debf7b |
2183 | pid, |
2184 | process->last_cpu_index, |
2185 | &birth, |
ac4e21cf |
2186 | tfc->t_context->index); |
1d1df11d |
2187 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
2188 | { |
2189 | g_assert(pid == 0 || pid != process->ppid); |
2190 | /* Process not present */ |
1c736ed5 |
2191 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
2192 | const gchar *name = g_quark_to_string(process->name); |
2193 | ProcessInfo *process_info; |
2194 | processlist_add(process_list, |
1c736ed5 |
2195 | drawing, |
40debf7b |
2196 | pid, |
2197 | process->last_cpu_index, |
2198 | process->ppid, |
2199 | &birth, |
2200 | tfc->t_context->index, |
2201 | name, |
2202 | &pl_height, |
2203 | &process_info, |
2204 | &hashed_process_data); |
1c736ed5 |
2205 | gtk_widget_set_size_request(drawing->drawing_area, |
2206 | -1, |
2207 | pl_height); |
2208 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
2209 | } |
2210 | /* Set the current process */ |
2211 | process_list->current_hash_data[process->last_cpu_index] = |
2212 | hashed_process_data; |
23093869 |
2213 | } |
40debf7b |
2214 | |
1d1df11d |
2215 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
2216 | evtime) <= 0)) |
b2743953 |
2217 | { |
fd22065b |
2218 | TimeWindow time_window = |
2219 | lttvwindow_get_time_window(control_flow_data->tab); |
2220 | |
2221 | #ifdef EXTRA_CHECK |
2222 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2223 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2224 | return; |
2225 | #endif //EXTRA_CHECK |
d6fef890 |
2226 | Drawing_t *drawing = control_flow_data->drawing; |
2227 | guint width = drawing->width; |
b2743953 |
2228 | guint new_x; |
2229 | |
2230 | convert_time_to_pixels( |
2231 | time_window, |
2232 | evtime, |
2233 | width, |
2234 | &new_x); |
e72908ed |
2235 | |
b2743953 |
2236 | if(hashed_process_data->x.middle != new_x) { |
2237 | hashed_process_data->x.middle = new_x; |
2238 | hashed_process_data->x.middle_used = FALSE; |
2239 | hashed_process_data->x.middle_marked = FALSE; |
2240 | } |
2241 | } |
23093869 |
2242 | return 0; |
2243 | } |
2244 | |
2245 | |
dbd243b1 |
2246 | |
2c82c4dc |
2247 | |
2248 | /* before_process_exit_hook |
dbd243b1 |
2249 | * |
2250 | * Draw lines for process event. |
2251 | * |
2252 | * @param hook_data ControlFlowData structure of the viewer. |
2253 | * @param call_data Event context. |
2254 | * |
2255 | * This function adds items to be drawn in a queue for each process. |
2256 | * |
2257 | */ |
2c82c4dc |
2258 | |
2259 | |
2260 | int before_process_exit_hook(void *hook_data, void *call_data) |
dbd243b1 |
2261 | { |
2c82c4dc |
2262 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
2263 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
2264 | |
dbd243b1 |
2265 | ControlFlowData *control_flow_data = events_request->viewer_data; |
dbd243b1 |
2266 | |
2267 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
2268 | |
2269 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
dbd243b1 |
2270 | |
2271 | LttEvent *e; |
2c82c4dc |
2272 | e = ltt_tracefile_get_event(tfc->tf); |
dbd243b1 |
2273 | |
2274 | LttTime evtime = ltt_event_time(e); |
dbd243b1 |
2275 | |
2c82c4dc |
2276 | /* Add process to process list (if not present) */ |
2277 | LttvProcessState *process = tfs->process; |
2278 | guint pid = process->pid; |
2279 | LttTime birth; |
2280 | guint pl_height = 0; |
2281 | HashedProcessData *hashed_process_data = NULL; |
dbd243b1 |
2282 | |
2c82c4dc |
2283 | ProcessList *process_list = control_flow_data->process_list; |
2284 | |
2285 | g_assert(process != NULL); |
dbd243b1 |
2286 | |
2c82c4dc |
2287 | birth = process->creation_time; |
dbd243b1 |
2288 | |
2c82c4dc |
2289 | if(likely(process_list->current_hash_data[ltt_tracefile_num(tfc->tf)] != NULL)) { |
2290 | hashed_process_data = process_list->current_hash_data[ltt_tracefile_num(tfc->tf)]; |
2291 | } else { |
2292 | hashed_process_data = processlist_get_process_data(process_list, |
2293 | pid, |
2294 | process->last_cpu_index, |
2295 | &birth, |
2296 | tfc->t_context->index); |
2297 | if(unlikely(hashed_process_data == NULL)) |
2298 | { |
2299 | g_assert(pid == 0 || pid != process->ppid); |
2300 | /* Process not present */ |
2301 | Drawing_t *drawing = control_flow_data->drawing; |
2302 | const gchar *name = g_quark_to_string(process->name); |
2303 | ProcessInfo *process_info; |
2304 | processlist_add(process_list, |
2305 | drawing, |
2306 | pid, |
2307 | process->last_cpu_index, |
2308 | process->ppid, |
2309 | &birth, |
2310 | tfc->t_context->index, |
2311 | name, |
2312 | &pl_height, |
2313 | &process_info, |
2314 | &hashed_process_data); |
2315 | gtk_widget_set_size_request(drawing->drawing_area, |
2316 | -1, |
2317 | pl_height); |
2318 | gtk_widget_queue_draw(drawing->drawing_area); |
2319 | } |
2320 | } |
dbd243b1 |
2321 | |
2c82c4dc |
2322 | /* Now, the process is in the state hash and our own process hash. |
2323 | * We definitely can draw the items related to the ending state. |
2324 | */ |
2325 | |
2326 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
2327 | evtime) > 0)) |
2328 | { |
2329 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2330 | TimeWindow time_window = |
2331 | lttvwindow_get_time_window(control_flow_data->tab); |
dbd243b1 |
2332 | |
2c82c4dc |
2333 | #ifdef EXTRA_CHECK |
2334 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2335 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2336 | return; |
2337 | #endif //EXTRA_CHECK |
2338 | Drawing_t *drawing = control_flow_data->drawing; |
2339 | guint width = drawing->width; |
2340 | guint x; |
2341 | convert_time_to_pixels( |
2342 | time_window, |
2343 | evtime, |
2344 | width, |
2345 | &x); |
dbd243b1 |
2346 | |
2c82c4dc |
2347 | /* Draw collision indicator */ |
2348 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2349 | gdk_draw_point(hashed_process_data->pixmap, |
2350 | drawing->gc, |
2351 | x, |
2352 | (hashed_process_data->height/2)-3); |
2353 | hashed_process_data->x.middle_marked = TRUE; |
2354 | } |
2355 | } else { |
2356 | TimeWindow time_window = |
2357 | lttvwindow_get_time_window(control_flow_data->tab); |
fd22065b |
2358 | |
2359 | #ifdef EXTRA_CHECK |
2c82c4dc |
2360 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2361 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2362 | return; |
fd22065b |
2363 | #endif //EXTRA_CHECK |
2c82c4dc |
2364 | Drawing_t *drawing = control_flow_data->drawing; |
2365 | guint width = drawing->width; |
2366 | guint x; |
2367 | |
2368 | convert_time_to_pixels( |
2369 | time_window, |
2370 | evtime, |
2371 | width, |
2372 | &x); |
2373 | |
b2743953 |
2374 | |
2c82c4dc |
2375 | /* Jump over draw if we are at the same x position */ |
2376 | if(unlikely(x == hashed_process_data->x.middle && |
2377 | hashed_process_data->x.middle_used)) |
2378 | { |
2379 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
b2743953 |
2380 | /* Draw collision indicator */ |
2381 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
2382 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
2383 | drawing->gc, |
2384 | x, |
1c736ed5 |
2385 | (hashed_process_data->height/2)-3); |
b2743953 |
2386 | hashed_process_data->x.middle_marked = TRUE; |
2387 | } |
2c82c4dc |
2388 | /* jump */ |
b2743953 |
2389 | } else { |
2c82c4dc |
2390 | DrawContext draw_context; |
fd22065b |
2391 | |
2c82c4dc |
2392 | /* Now create the drawing context that will be used to draw |
2393 | * items related to the last state. */ |
2394 | draw_context.drawable = hashed_process_data->pixmap; |
2395 | draw_context.gc = drawing->gc; |
2396 | draw_context.pango_layout = drawing->pango_layout; |
2397 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
2398 | draw_context.drawinfo.end.x = x; |
dbd243b1 |
2399 | |
2c82c4dc |
2400 | draw_context.drawinfo.y.over = 1; |
2401 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2402 | draw_context.drawinfo.y.under = hashed_process_data->height; |
dbd243b1 |
2403 | |
2c82c4dc |
2404 | draw_context.drawinfo.start.offset.over = 0; |
2405 | draw_context.drawinfo.start.offset.middle = 0; |
2406 | draw_context.drawinfo.start.offset.under = 0; |
2407 | draw_context.drawinfo.end.offset.over = 0; |
2408 | draw_context.drawinfo.end.offset.middle = 0; |
2409 | draw_context.drawinfo.end.offset.under = 0; |
dbd243b1 |
2410 | |
2c82c4dc |
2411 | { |
2412 | /* Draw the line */ |
2413 | PropertiesLine prop_line = prepare_s_e_line(process); |
2414 | draw_line((void*)&prop_line, (void*)&draw_context); |
dbd243b1 |
2415 | |
2c82c4dc |
2416 | } |
2417 | /* become the last x position */ |
2418 | hashed_process_data->x.middle = x; |
2419 | hashed_process_data->x.middle_used = TRUE; |
2420 | hashed_process_data->x.middle_marked = FALSE; |
dbd243b1 |
2421 | |
2c82c4dc |
2422 | /* Calculate the next good time */ |
2423 | convert_pixels_to_time(width, x+1, time_window, |
2424 | &hashed_process_data->next_good_time); |
2425 | } |
2426 | } |
2427 | |
2428 | return 0; |
2429 | |
2430 | } |
2431 | |
2432 | |
2433 | |
2434 | /* before_process_release_hook |
2435 | * |
2436 | * Draw lines for process event. |
2437 | * |
2438 | * @param hook_data ControlFlowData structure of the viewer. |
2439 | * @param call_data Event context. |
2440 | * |
2441 | * This function adds items to be drawn in a queue for each process. |
2442 | * |
2443 | */ |
2444 | |
2445 | |
2446 | int before_process_release_hook(void *hook_data, void *call_data) |
2447 | { |
2448 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
2449 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
2450 | |
2451 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2452 | |
2453 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
2454 | |
2455 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
2456 | |
2457 | LttEvent *e; |
2458 | e = ltt_tracefile_get_event(tfc->tf); |
2459 | |
2460 | LttTime evtime = ltt_event_time(e); |
2461 | |
2462 | |
2463 | guint pid; |
2464 | { |
2465 | pid = ltt_event_get_long_unsigned(e, thf->f1); |
2466 | } |
2467 | |
2468 | /* Add process to process list (if not present) */ |
2469 | /* Don't care about the process if it's not in the state hash already : |
2470 | * that means a process that has never done anything in the trace and |
2471 | * unknown suddently gets destroyed : no state meaningful to show. */ |
2472 | LttvProcessState *process = lttv_state_find_process(tfs, pid); |
2473 | |
2474 | if(process != NULL) { |
2475 | LttTime birth; |
2476 | guint pl_height = 0; |
2477 | HashedProcessData *hashed_process_data = NULL; |
2478 | |
2479 | ProcessList *process_list = control_flow_data->process_list; |
2480 | |
2481 | birth = process->creation_time; |
2482 | |
2483 | /* Cannot use current process : this event happens on another process, |
2484 | * action done by the parent. */ |
2485 | hashed_process_data = processlist_get_process_data(process_list, |
2486 | pid, |
2487 | process->last_cpu_index, |
2488 | &birth, |
2489 | tfc->t_context->index); |
2490 | if(unlikely(hashed_process_data == NULL)) |
2491 | { |
2492 | g_assert(pid == 0 || pid != process->ppid); |
2493 | /* Process not present */ |
2494 | Drawing_t *drawing = control_flow_data->drawing; |
2495 | const gchar *name = g_quark_to_string(process->name); |
2496 | ProcessInfo *process_info; |
2497 | processlist_add(process_list, |
2498 | drawing, |
2499 | pid, |
2500 | process->last_cpu_index, |
2501 | process->ppid, |
2502 | &birth, |
2503 | tfc->t_context->index, |
2504 | name, |
2505 | &pl_height, |
2506 | &process_info, |
2507 | &hashed_process_data); |
2508 | gtk_widget_set_size_request(drawing->drawing_area, |
2509 | -1, |
2510 | pl_height); |
2511 | gtk_widget_queue_draw(drawing->drawing_area); |
2512 | } |
2513 | |
2514 | /* Now, the process is in the state hash and our own process hash. |
2515 | * We definitely can draw the items related to the ending state. |
2516 | */ |
2517 | |
2518 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
2519 | evtime) > 0)) |
2520 | { |
2521 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2522 | TimeWindow time_window = |
2523 | lttvwindow_get_time_window(control_flow_data->tab); |
2524 | |
2525 | #ifdef EXTRA_CHECK |
2526 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2527 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2528 | return; |
2529 | #endif //EXTRA_CHECK |
2530 | Drawing_t *drawing = control_flow_data->drawing; |
2531 | guint width = drawing->width; |
2532 | guint x; |
2533 | convert_time_to_pixels( |
2534 | time_window, |
2535 | evtime, |
2536 | width, |
2537 | &x); |
2538 | |
2539 | /* Draw collision indicator */ |
2540 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2541 | gdk_draw_point(hashed_process_data->pixmap, |
2542 | drawing->gc, |
2543 | x, |
2544 | (hashed_process_data->height/2)-3); |
2545 | hashed_process_data->x.middle_marked = TRUE; |
2546 | } |
2547 | } else { |
2548 | TimeWindow time_window = |
2549 | lttvwindow_get_time_window(control_flow_data->tab); |
2550 | |
2551 | #ifdef EXTRA_CHECK |
2552 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2553 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2554 | return; |
2555 | #endif //EXTRA_CHECK |
2556 | Drawing_t *drawing = control_flow_data->drawing; |
2557 | guint width = drawing->width; |
2558 | guint x; |
2559 | |
2560 | convert_time_to_pixels( |
2561 | time_window, |
2562 | evtime, |
2563 | width, |
2564 | &x); |
2565 | |
2566 | |
2567 | /* Jump over draw if we are at the same x position */ |
2568 | if(unlikely(x == hashed_process_data->x.middle && |
2569 | hashed_process_data->x.middle_used)) |
2570 | { |
2571 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2572 | /* Draw collision indicator */ |
2573 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2574 | gdk_draw_point(hashed_process_data->pixmap, |
2575 | drawing->gc, |
2576 | x, |
2577 | (hashed_process_data->height/2)-3); |
2578 | hashed_process_data->x.middle_marked = TRUE; |
2579 | } |
2580 | /* jump */ |
2581 | } else { |
2582 | DrawContext draw_context; |
2583 | |
2584 | /* Now create the drawing context that will be used to draw |
2585 | * items related to the last state. */ |
2586 | draw_context.drawable = hashed_process_data->pixmap; |
2587 | draw_context.gc = drawing->gc; |
2588 | draw_context.pango_layout = drawing->pango_layout; |
2589 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
2590 | draw_context.drawinfo.end.x = x; |
2591 | |
2592 | draw_context.drawinfo.y.over = 1; |
2593 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2594 | draw_context.drawinfo.y.under = hashed_process_data->height; |
2595 | |
2596 | draw_context.drawinfo.start.offset.over = 0; |
2597 | draw_context.drawinfo.start.offset.middle = 0; |
2598 | draw_context.drawinfo.start.offset.under = 0; |
2599 | draw_context.drawinfo.end.offset.over = 0; |
2600 | draw_context.drawinfo.end.offset.middle = 0; |
2601 | draw_context.drawinfo.end.offset.under = 0; |
2602 | |
2603 | { |
2604 | /* Draw the line */ |
2605 | PropertiesLine prop_line = prepare_s_e_line(process); |
2606 | draw_line((void*)&prop_line, (void*)&draw_context); |
2607 | |
2608 | } |
2609 | /* become the last x position */ |
2610 | hashed_process_data->x.middle = x; |
2611 | hashed_process_data->x.middle_used = TRUE; |
2612 | hashed_process_data->x.middle_marked = FALSE; |
2613 | |
2614 | /* Calculate the next good time */ |
2615 | convert_pixels_to_time(width, x+1, time_window, |
2616 | &hashed_process_data->next_good_time); |
2617 | } |
2618 | } |
2619 | } |
2620 | |
2621 | return 0; |
2622 | } |
2623 | |
2624 | |
2625 | |
2626 | |
2627 | |
2628 | |
2629 | |
2630 | |
2631 | #if 0 |
2632 | /* before_process_hook |
2633 | * |
2634 | * Draw lines for process event. |
2635 | * |
2636 | * @param hook_data ControlFlowData structure of the viewer. |
2637 | * @param call_data Event context. |
2638 | * |
2639 | * This function adds items to be drawn in a queue for each process. |
2640 | * |
2641 | */ |
2642 | int before_process_hook(void *hook_data, void *call_data) |
2643 | { |
2644 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
2645 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
2646 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2647 | |
2648 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
2649 | |
2650 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
2651 | |
2652 | LttEvent *e; |
2653 | e = ltt_tracefile_get_event(tfc->tf); |
2654 | |
2655 | LttTime evtime = ltt_event_time(e); |
2656 | |
2657 | guint sub_id; |
2658 | { |
2659 | LttField *f = ltt_event_field(e); |
2660 | LttField *element; |
2661 | element = ltt_field_member(f,0); |
2662 | sub_id = ltt_event_get_long_unsigned(e,element); |
2663 | } |
2664 | |
2665 | if(sub_id == 3) { /* exit */ |
2666 | |
2667 | /* Add process to process list (if not present) */ |
2668 | LttvProcessState *process = tfs->process; |
2669 | guint pid = process->pid; |
2670 | LttTime birth; |
2671 | guint pl_height = 0; |
2672 | HashedProcessData *hashed_process_data = NULL; |
2673 | |
2674 | ProcessList *process_list = control_flow_data->process_list; |
2675 | |
2676 | g_assert(process != NULL); |
2677 | |
2678 | birth = process->creation_time; |
2679 | |
2680 | if(likely(process_list->current_hash_data[tfc->index] != NULL)) { |
2681 | hashed_process_data = process_list->current_hash_data[tfc->index]; |
2682 | } else { |
2683 | hashed_process_data = processlist_get_process_data(process_list, |
2684 | pid, |
2685 | process->last_cpu_index, |
2686 | &birth, |
2687 | tfc->t_context->index); |
2688 | if(unlikely(hashed_process_data == NULL)) |
2689 | { |
2690 | g_assert(pid == 0 || pid != process->ppid); |
2691 | /* Process not present */ |
2692 | Drawing_t *drawing = control_flow_data->drawing; |
2693 | const gchar *name = g_quark_to_string(process->name); |
2694 | ProcessInfo *process_info; |
2695 | processlist_add(process_list, |
2696 | drawing, |
2697 | pid, |
2698 | process->last_cpu_index, |
2699 | process->ppid, |
2700 | &birth, |
2701 | tfc->t_context->index, |
2702 | name, |
2703 | &pl_height, |
2704 | &process_info, |
2705 | &hashed_process_data); |
2706 | gtk_widget_set_size_request(drawing->drawing_area, |
2707 | -1, |
2708 | pl_height); |
2709 | gtk_widget_queue_draw(drawing->drawing_area); |
2710 | } |
2711 | } |
2712 | |
2713 | /* Now, the process is in the state hash and our own process hash. |
2714 | * We definitely can draw the items related to the ending state. |
2715 | */ |
2716 | |
2717 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
2718 | evtime) > 0)) |
2719 | { |
2720 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2721 | TimeWindow time_window = |
2722 | lttvwindow_get_time_window(control_flow_data->tab); |
2723 | |
2724 | #ifdef EXTRA_CHECK |
2725 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2726 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2727 | return; |
2728 | #endif //EXTRA_CHECK |
2729 | Drawing_t *drawing = control_flow_data->drawing; |
2730 | guint width = drawing->width; |
2731 | guint x; |
2732 | convert_time_to_pixels( |
2733 | time_window, |
2734 | evtime, |
2735 | width, |
2736 | &x); |
2737 | |
2738 | /* Draw collision indicator */ |
2739 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2740 | gdk_draw_point(hashed_process_data->pixmap, |
2741 | drawing->gc, |
2742 | x, |
2743 | (hashed_process_data->height/2)-3); |
2744 | hashed_process_data->x.middle_marked = TRUE; |
2745 | } |
2746 | } else { |
2747 | TimeWindow time_window = |
2748 | lttvwindow_get_time_window(control_flow_data->tab); |
2749 | |
2750 | #ifdef EXTRA_CHECK |
2751 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2752 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2753 | return; |
2754 | #endif //EXTRA_CHECK |
2755 | Drawing_t *drawing = control_flow_data->drawing; |
2756 | guint width = drawing->width; |
2757 | guint x; |
2758 | |
2759 | convert_time_to_pixels( |
2760 | time_window, |
2761 | evtime, |
2762 | width, |
2763 | &x); |
2764 | |
2765 | |
2766 | /* Jump over draw if we are at the same x position */ |
2767 | if(unlikely(x == hashed_process_data->x.middle && |
2768 | hashed_process_data->x.middle_used)) |
2769 | { |
2770 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2771 | /* Draw collision indicator */ |
2772 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2773 | gdk_draw_point(hashed_process_data->pixmap, |
2774 | drawing->gc, |
2775 | x, |
2776 | (hashed_process_data->height/2)-3); |
2777 | hashed_process_data->x.middle_marked = TRUE; |
2778 | } |
2779 | /* jump */ |
2780 | } else { |
2781 | DrawContext draw_context; |
2782 | |
2783 | /* Now create the drawing context that will be used to draw |
2784 | * items related to the last state. */ |
2785 | draw_context.drawable = hashed_process_data->pixmap; |
2786 | draw_context.gc = drawing->gc; |
2787 | draw_context.pango_layout = drawing->pango_layout; |
2788 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
2789 | draw_context.drawinfo.end.x = x; |
2790 | |
2791 | draw_context.drawinfo.y.over = 1; |
1c736ed5 |
2792 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2793 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
2794 | |
2795 | draw_context.drawinfo.start.offset.over = 0; |
2796 | draw_context.drawinfo.start.offset.middle = 0; |
2797 | draw_context.drawinfo.start.offset.under = 0; |
2798 | draw_context.drawinfo.end.offset.over = 0; |
2799 | draw_context.drawinfo.end.offset.middle = 0; |
2800 | draw_context.drawinfo.end.offset.under = 0; |
dbd243b1 |
2801 | |
4b7dc462 |
2802 | { |
2803 | /* Draw the line */ |
9a1ec01b |
2804 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
2805 | draw_line((void*)&prop_line, (void*)&draw_context); |
2806 | |
2807 | } |
2808 | /* become the last x position */ |
2809 | hashed_process_data->x.middle = x; |
e72908ed |
2810 | hashed_process_data->x.middle_used = TRUE; |
2811 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
2812 | |
2813 | /* Calculate the next good time */ |
2814 | convert_pixels_to_time(width, x+1, time_window, |
2815 | &hashed_process_data->next_good_time); |
dbd243b1 |
2816 | } |
dbd243b1 |
2817 | } |
2818 | |
2da61677 |
2819 | } else if(sub_id == 7) /* release */ { |
2820 | |
2821 | guint pid; |
2822 | { |
2823 | LttField *f = ltt_event_field(e); |
2824 | LttField *element; |
2825 | element = ltt_field_member(f,1); |
2826 | pid = ltt_event_get_long_unsigned(e,element); |
2827 | } |
2828 | |
2829 | /* Add process to process list (if not present) */ |
2830 | /* Don't care about the process if it's not in the state hash already : |
2831 | * that means a process that has never done anything in the trace and |
2832 | * unknown suddently gets destroyed : no state meaningful to show. */ |
2833 | LttvProcessState *process = lttv_state_find_process(tfs, pid); |
2834 | |
2835 | if(process != NULL) { |
2836 | LttTime birth; |
2837 | guint pl_height = 0; |
2838 | HashedProcessData *hashed_process_data = NULL; |
2839 | |
2840 | ProcessList *process_list = control_flow_data->process_list; |
2841 | |
2842 | birth = process->creation_time; |
2843 | |
2844 | /* Cannot use current process : this event happens on another process, |
2845 | * action done by the parent. */ |
2846 | hashed_process_data = processlist_get_process_data(process_list, |
2847 | pid, |
2848 | process->last_cpu_index, |
2849 | &birth, |
2850 | tfc->t_context->index); |
2851 | if(unlikely(hashed_process_data == NULL)) |
2852 | { |
2853 | g_assert(pid == 0 || pid != process->ppid); |
2854 | /* Process not present */ |
2855 | Drawing_t *drawing = control_flow_data->drawing; |
2856 | const gchar *name = g_quark_to_string(process->name); |
2857 | ProcessInfo *process_info; |
2858 | processlist_add(process_list, |
2859 | drawing, |
2860 | pid, |
2861 | process->last_cpu_index, |
2862 | process->ppid, |
2863 | &birth, |
2864 | tfc->t_context->index, |
2865 | name, |
2866 | &pl_height, |
2867 | &process_info, |
2868 | &hashed_process_data); |
2869 | gtk_widget_set_size_request(drawing->drawing_area, |
2870 | -1, |
2871 | pl_height); |
2872 | gtk_widget_queue_draw(drawing->drawing_area); |
2873 | } |
2874 | |
2875 | /* Now, the process is in the state hash and our own process hash. |
2876 | * We definitely can draw the items related to the ending state. |
2877 | */ |
2878 | |
2879 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
2880 | evtime) > 0)) |
2881 | { |
2882 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2883 | TimeWindow time_window = |
2884 | lttvwindow_get_time_window(control_flow_data->tab); |
2885 | |
2886 | #ifdef EXTRA_CHECK |
2887 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2888 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2889 | return; |
2890 | #endif //EXTRA_CHECK |
2891 | Drawing_t *drawing = control_flow_data->drawing; |
2892 | guint width = drawing->width; |
2893 | guint x; |
2894 | convert_time_to_pixels( |
2895 | time_window, |
2896 | evtime, |
2897 | width, |
2898 | &x); |
2899 | |
2900 | /* Draw collision indicator */ |
2901 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2902 | gdk_draw_point(hashed_process_data->pixmap, |
2903 | drawing->gc, |
2904 | x, |
2905 | (hashed_process_data->height/2)-3); |
2906 | hashed_process_data->x.middle_marked = TRUE; |
2907 | } |
2908 | } else { |
2909 | TimeWindow time_window = |
2910 | lttvwindow_get_time_window(control_flow_data->tab); |
2911 | |
2912 | #ifdef EXTRA_CHECK |
2913 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2914 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2915 | return; |
2916 | #endif //EXTRA_CHECK |
2917 | Drawing_t *drawing = control_flow_data->drawing; |
2918 | guint width = drawing->width; |
2919 | guint x; |
2920 | |
2921 | convert_time_to_pixels( |
2922 | time_window, |
2923 | evtime, |
2924 | width, |
2925 | &x); |
2926 | |
2927 | |
2928 | /* Jump over draw if we are at the same x position */ |
2929 | if(unlikely(x == hashed_process_data->x.middle && |
2930 | hashed_process_data->x.middle_used)) |
2931 | { |
2932 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2933 | /* Draw collision indicator */ |
2934 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2935 | gdk_draw_point(hashed_process_data->pixmap, |
2936 | drawing->gc, |
2937 | x, |
2938 | (hashed_process_data->height/2)-3); |
2939 | hashed_process_data->x.middle_marked = TRUE; |
2940 | } |
2941 | /* jump */ |
2942 | } else { |
2943 | DrawContext draw_context; |
2944 | |
2945 | /* Now create the drawing context that will be used to draw |
2946 | * items related to the last state. */ |
2947 | draw_context.drawable = hashed_process_data->pixmap; |
2948 | draw_context.gc = drawing->gc; |
2949 | draw_context.pango_layout = drawing->pango_layout; |
2950 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
2951 | draw_context.drawinfo.end.x = x; |
2952 | |
2953 | draw_context.drawinfo.y.over = 1; |
2954 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2955 | draw_context.drawinfo.y.under = hashed_process_data->height; |
2956 | |
2957 | draw_context.drawinfo.start.offset.over = 0; |
2958 | draw_context.drawinfo.start.offset.middle = 0; |
2959 | draw_context.drawinfo.start.offset.under = 0; |
2960 | draw_context.drawinfo.end.offset.over = 0; |
2961 | draw_context.drawinfo.end.offset.middle = 0; |
2962 | draw_context.drawinfo.end.offset.under = 0; |
2963 | |
2964 | { |
2965 | /* Draw the line */ |
2966 | PropertiesLine prop_line = prepare_s_e_line(process); |
2967 | draw_line((void*)&prop_line, (void*)&draw_context); |
2968 | |
2969 | } |
2970 | /* become the last x position */ |
2971 | hashed_process_data->x.middle = x; |
2972 | hashed_process_data->x.middle_used = TRUE; |
2973 | hashed_process_data->x.middle_marked = FALSE; |
2974 | |
2975 | /* Calculate the next good time */ |
2976 | convert_pixels_to_time(width, x+1, time_window, |
2977 | &hashed_process_data->next_good_time); |
2978 | } |
2979 | } |
2980 | } |
2981 | |
dbd243b1 |
2982 | } |
2983 | return 0; |
2984 | |
2985 | } |
2986 | |
2c82c4dc |
2987 | #endif //0 |
2988 | |
2989 | |
2990 | |
2991 | /* after_process_fork_hook |
2992 | * |
2993 | * Create the processlist entry for the child process. Put the last |
2994 | * position in x at the current time value. |
2995 | * |
2996 | * @param hook_data ControlFlowData structure of the viewer. |
2997 | * @param call_data Event context. |
2998 | * |
2999 | * This function adds items to be drawn in a queue for each process. |
3000 | * |
3001 | */ |
3002 | int after_process_fork_hook(void *hook_data, void *call_data) |
3003 | { |
3004 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
3005 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
3006 | ControlFlowData *control_flow_data = events_request->viewer_data; |
3007 | |
3008 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
3009 | |
3010 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
3011 | |
3012 | LttEvent *e; |
3013 | e = ltt_tracefile_get_event(tfc->tf); |
3014 | |
3015 | LttTime evtime = ltt_event_time(e); |
3016 | |
3017 | guint child_pid; |
3018 | { |
3019 | child_pid = ltt_event_get_long_unsigned(e, thf->f2); |
3020 | } |
3021 | |
3022 | /* Add process to process list (if not present) */ |
3023 | LttvProcessState *process_child; |
3024 | LttTime birth; |
3025 | guint pl_height = 0; |
3026 | HashedProcessData *hashed_process_data_child = NULL; |
3027 | |
3028 | ProcessList *process_list = control_flow_data->process_list; |
3029 | |
3030 | /* Find child in the list... */ |
3031 | process_child = lttv_state_find_process(tfs, child_pid); |
3032 | /* It should exist, because we are after the state update. */ |
3033 | g_assert(process_child != NULL); |
3034 | |
3035 | birth = process_child->creation_time; |
3036 | |
3037 | /* Cannot use current process, because this action is done by the parent |
3038 | * on its child. */ |
3039 | hashed_process_data_child = processlist_get_process_data(process_list, |
3040 | child_pid, |
3041 | process_child->last_cpu_index, |
3042 | &birth, |
3043 | tfc->t_context->index); |
3044 | if(likely(hashed_process_data_child == NULL)) |
3045 | { |
3046 | g_assert(child_pid == 0 || child_pid != process_child->ppid); |
3047 | /* Process not present */ |
3048 | Drawing_t *drawing = control_flow_data->drawing; |
3049 | const gchar *name = g_quark_to_string(process_child->name); |
3050 | ProcessInfo *process_info; |
3051 | processlist_add(process_list, |
3052 | drawing, |
3053 | child_pid, |
3054 | process_child->last_cpu_index, |
3055 | process_child->ppid, |
3056 | &birth, |
3057 | tfc->t_context->index, |
3058 | name, |
3059 | &pl_height, |
3060 | &process_info, |
3061 | &hashed_process_data_child); |
3062 | gtk_widget_set_size_request(drawing->drawing_area, |
3063 | -1, |
3064 | pl_height); |
3065 | gtk_widget_queue_draw(drawing->drawing_area); |
3066 | } |
3067 | |
3068 | |
3069 | if(likely(ltt_time_compare(hashed_process_data_child->next_good_time, |
3070 | evtime) <= 0)) |
3071 | { |
3072 | TimeWindow time_window = |
3073 | lttvwindow_get_time_window(control_flow_data->tab); |
3074 | |
3075 | #ifdef EXTRA_CHECK |
3076 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
3077 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3078 | return; |
3079 | #endif //EXTRA_CHECK |
3080 | Drawing_t *drawing = control_flow_data->drawing; |
3081 | guint width = drawing->width; |
3082 | guint new_x; |
3083 | convert_time_to_pixels( |
3084 | time_window, |
3085 | evtime, |
3086 | width, |
3087 | &new_x); |
3088 | |
3089 | if(likely(hashed_process_data_child->x.over != new_x)) { |
3090 | hashed_process_data_child->x.over = new_x; |
3091 | hashed_process_data_child->x.over_used = FALSE; |
3092 | hashed_process_data_child->x.over_marked = FALSE; |
3093 | } |
3094 | if(likely(hashed_process_data_child->x.middle != new_x)) { |
3095 | hashed_process_data_child->x.middle = new_x; |
3096 | hashed_process_data_child->x.middle_used = FALSE; |
3097 | hashed_process_data_child->x.middle_marked = FALSE; |
3098 | } |
3099 | if(likely(hashed_process_data_child->x.under != new_x)) { |
3100 | hashed_process_data_child->x.under = new_x; |
3101 | hashed_process_data_child->x.under_used = FALSE; |
3102 | hashed_process_data_child->x.under_marked = FALSE; |
3103 | } |
3104 | } |
3105 | return 0; |
3106 | } |
3107 | |
3108 | |
3109 | |
3110 | /* after_process_exit_hook |
3111 | * |
3112 | * Create the processlist entry for the child process. Put the last |
3113 | * position in x at the current time value. |
3114 | * |
3115 | * @param hook_data ControlFlowData structure of the viewer. |
3116 | * @param call_data Event context. |
3117 | * |
3118 | * This function adds items to be drawn in a queue for each process. |
3119 | * |
3120 | */ |
3121 | int after_process_exit_hook(void *hook_data, void *call_data) |
3122 | { |
3123 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
3124 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
3125 | ControlFlowData *control_flow_data = events_request->viewer_data; |
3126 | |
3127 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
3128 | |
3129 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
3130 | |
3131 | LttEvent *e; |
3132 | e = ltt_tracefile_get_event(tfc->tf); |
3133 | |
3134 | LttTime evtime = ltt_event_time(e); |
3135 | |
3136 | /* Add process to process list (if not present) */ |
3137 | LttvProcessState *process = tfs->process; |
3138 | guint pid = process->pid; |
3139 | LttTime birth; |
3140 | guint pl_height = 0; |
3141 | HashedProcessData *hashed_process_data = NULL; |
3142 | |
3143 | ProcessList *process_list = control_flow_data->process_list; |
3144 | |
3145 | /* It should exist, because we are after the state update. */ |
3146 | g_assert(process != NULL); |
3147 | |
3148 | birth = process->creation_time; |
3149 | |
3150 | if(likely(process_list->current_hash_data[ltt_tracefile_num(tfc->tf)] != NULL) ){ |
3151 | hashed_process_data = process_list->current_hash_data[ltt_tracefile_num(tfc->tf)]; |
3152 | } else { |
3153 | hashed_process_data = processlist_get_process_data(process_list, |
3154 | pid, |
3155 | process->last_cpu_index, |
3156 | &birth, |
3157 | tfc->t_context->index); |
3158 | if(unlikely(hashed_process_data == NULL)) |
3159 | { |
3160 | g_assert(pid == 0 || pid != process->ppid); |
3161 | /* Process not present */ |
3162 | Drawing_t *drawing = control_flow_data->drawing; |
3163 | const gchar *name = g_quark_to_string(process->name); |
3164 | ProcessInfo *process_info; |
3165 | processlist_add(process_list, |
3166 | drawing, |
3167 | pid, |
3168 | process->last_cpu_index, |
3169 | process->ppid, |
3170 | &birth, |
3171 | tfc->t_context->index, |
3172 | name, |
3173 | &pl_height, |
3174 | &process_info, |
3175 | &hashed_process_data); |
3176 | gtk_widget_set_size_request(drawing->drawing_area, |
3177 | -1, |
3178 | pl_height); |
3179 | gtk_widget_queue_draw(drawing->drawing_area); |
3180 | } |
3181 | |
3182 | /* Set the current process */ |
3183 | process_list->current_hash_data[process->last_cpu_index] = |
3184 | hashed_process_data; |
3185 | } |
3186 | |
3187 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
3188 | evtime) <= 0)) |
3189 | { |
3190 | TimeWindow time_window = |
3191 | lttvwindow_get_time_window(control_flow_data->tab); |
dbd243b1 |
3192 | |
2c82c4dc |
3193 | #ifdef EXTRA_CHECK |
3194 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
3195 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3196 | return; |
3197 | #endif //EXTRA_CHECK |
3198 | Drawing_t *drawing = control_flow_data->drawing; |
3199 | guint width = drawing->width; |
3200 | guint new_x; |
3201 | convert_time_to_pixels( |
3202 | time_window, |
3203 | evtime, |
3204 | width, |
3205 | &new_x); |
3206 | if(unlikely(hashed_process_data->x.middle != new_x)) { |
3207 | hashed_process_data->x.middle = new_x; |
3208 | hashed_process_data->x.middle_used = FALSE; |
3209 | hashed_process_data->x.middle_marked = FALSE; |
3210 | } |
3211 | } |
dbd243b1 |
3212 | |
2c82c4dc |
3213 | return 0; |
3214 | } |
dbd243b1 |
3215 | |
3216 | |
2c82c4dc |
3217 | #if 0 |
dbd243b1 |
3218 | |
3219 | /* after_process_hook |
e92eabaf |
3220 | * |
3221 | * Create the processlist entry for the child process. Put the last |
3222 | * position in x at the current time value. |
3223 | * |
3224 | * @param hook_data ControlFlowData structure of the viewer. |
3225 | * @param call_data Event context. |
3226 | * |
3227 | * This function adds items to be drawn in a queue for each process. |
3228 | * |
3229 | */ |
dbd243b1 |
3230 | int after_process_hook(void *hook_data, void *call_data) |
e92eabaf |
3231 | { |
2c82c4dc |
3232 | LttvTraceHookByFacility *thf = (LttvTraceHookByFacility*)hook_data; |
3233 | EventsRequest *events_request = (EventsRequest*)thf->hook_data; |
e92eabaf |
3234 | ControlFlowData *control_flow_data = events_request->viewer_data; |
3235 | |
3236 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
3237 | |
3238 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
e92eabaf |
3239 | |
3240 | LttEvent *e; |
2c82c4dc |
3241 | e = ltt_tracefile_get_event(tfc->tf); |
e92eabaf |
3242 | |
3243 | LttTime evtime = ltt_event_time(e); |
e92eabaf |
3244 | |
10a1069a |
3245 | guint sub_id; |
3246 | guint param1; |
3247 | { |
3248 | LttField *f = ltt_event_field(e); |
3249 | LttField *element; |
3250 | element = ltt_field_member(f,0); |
3251 | sub_id = ltt_event_get_long_unsigned(e,element); |
3252 | element = ltt_field_member(f,1); |
3253 | param1 = ltt_event_get_long_unsigned(e,element); |
3254 | } |
e92eabaf |
3255 | |
10a1069a |
3256 | if(sub_id == 2) { /* fork */ |
3257 | |
3258 | guint child_pid = param1; |
3259 | /* Add process to process list (if not present) */ |
3260 | LttvProcessState *process_child; |
3261 | LttTime birth; |
1c736ed5 |
3262 | guint pl_height = 0; |
10a1069a |
3263 | HashedProcessData *hashed_process_data_child = NULL; |
e92eabaf |
3264 | |
5c230fc4 |
3265 | ProcessList *process_list = control_flow_data->process_list; |
e92eabaf |
3266 | |
10a1069a |
3267 | /* Find child in the list... */ |
3268 | process_child = lttv_state_find_process(tfs, child_pid); |
3269 | /* It should exist, because we are after the state update. */ |
3270 | g_assert(process_child != NULL); |
e92eabaf |
3271 | |
10a1069a |
3272 | birth = process_child->creation_time; |
e92eabaf |
3273 | |
2da61677 |
3274 | /* Cannot use current process, because this action is done by the parent |
3275 | * on its child. */ |
ac4e21cf |
3276 | hashed_process_data_child = processlist_get_process_data(process_list, |
10a1069a |
3277 | child_pid, |
40debf7b |
3278 | process_child->last_cpu_index, |
10a1069a |
3279 | &birth, |
ac4e21cf |
3280 | tfc->t_context->index); |
1d1df11d |
3281 | if(likely(hashed_process_data_child == NULL)) |
10a1069a |
3282 | { |
3283 | g_assert(child_pid == 0 || child_pid != process_child->ppid); |
3284 | /* Process not present */ |
1c736ed5 |
3285 | Drawing_t *drawing = control_flow_data->drawing; |
aac69e70 |
3286 | const gchar *name = g_quark_to_string(process_child->name); |
4e86ae2e |
3287 | ProcessInfo *process_info; |
10a1069a |
3288 | processlist_add(process_list, |
1c736ed5 |
3289 | drawing, |
10a1069a |
3290 | child_pid, |
40debf7b |
3291 | process_child->last_cpu_index, |
10a1069a |
3292 | process_child->ppid, |
3293 | &birth, |
3294 | tfc->t_context->index, |
3295 | name, |
3296 | &pl_height, |
4e86ae2e |
3297 | &process_info, |
10a1069a |
3298 | &hashed_process_data_child); |
1c736ed5 |
3299 | gtk_widget_set_size_request(drawing->drawing_area, |
3300 | -1, |
3301 | pl_height); |
3302 | gtk_widget_queue_draw(drawing->drawing_area); |
10a1069a |
3303 | } |
e92eabaf |
3304 | |
40debf7b |
3305 | |
1d1df11d |
3306 | if(likely(ltt_time_compare(hashed_process_data_child->next_good_time, |
3307 | evtime) <= 0)) |
b2743953 |
3308 | { |
fd22065b |
3309 | TimeWindow time_window = |
3310 | lttvwindow_get_time_window(control_flow_data->tab); |
3311 | |
3312 | #ifdef EXTRA_CHECK |
3313 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
3314 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3315 | return; |
3316 | #endif //EXTRA_CHECK |
d6fef890 |
3317 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
3318 | guint width = drawing->width; |
b2743953 |
3319 | guint new_x; |
3320 | convert_time_to_pixels( |
3321 | time_window, |
3322 | evtime, |
3323 | width, |
3324 | &new_x); |
e72908ed |
3325 | |
1d1df11d |
3326 | if(likely(hashed_process_data_child->x.over != new_x)) { |
b2743953 |
3327 | hashed_process_data_child->x.over = new_x; |
3328 | hashed_process_data_child->x.over_used = FALSE; |
3329 | hashed_process_data_child->x.over_marked = FALSE; |
3330 | } |
1d1df11d |
3331 | if(likely(hashed_process_data_child->x.middle != new_x)) { |
b2743953 |
3332 | hashed_process_data_child->x.middle = new_x; |
3333 | hashed_process_data_child->x.middle_used = FALSE; |
3334 | hashed_process_data_child->x.middle_marked = FALSE; |
3335 | } |
1d1df11d |
3336 | if(likely(hashed_process_data_child->x.under != new_x)) { |
b2743953 |
3337 | hashed_process_data_child->x.under = new_x; |
3338 | hashed_process_data_child->x.under_used = FALSE; |
3339 | hashed_process_data_child->x.under_marked = FALSE; |
3340 | } |
e72908ed |
3341 | } |
23093869 |
3342 | |
10a1069a |
3343 | } else if(sub_id == 3) { /* exit */ |
dbd243b1 |
3344 | |
10a1069a |
3345 | /* Add process to process list (if not present) */ |
3346 | LttvProcessState *process = tfs->process; |
3347 | guint pid = process->pid; |
3348 | LttTime birth; |
1c736ed5 |
3349 | guint pl_height = 0; |
10a1069a |
3350 | HashedProcessData *hashed_process_data = NULL; |
dbd243b1 |
3351 | |
5c230fc4 |
3352 | ProcessList *process_list = control_flow_data->process_list; |
dbd243b1 |
3353 | |
10a1069a |
3354 | /* It should exist, because we are after the state update. */ |
3355 | g_assert(process != NULL); |
dbd243b1 |
3356 | |
10a1069a |
3357 | birth = process->creation_time; |
dbd243b1 |
3358 | |
2c82c4dc |
3359 | if(likely(process_list->current_hash_data[ltt_tracefile_num(tfc->tf)] != NULL) ){ |
3360 | hashed_process_data = process_list->current_hash_data[ltt_tracefile_num(tfc->tf)]; |
40debf7b |
3361 | } else { |
ac4e21cf |
3362 | hashed_process_data = processlist_get_process_data(process_list, |
40debf7b |
3363 | pid, |
3364 | process->last_cpu_index, |
3365 | &birth, |
ac4e21cf |
3366 | tfc->t_context->index); |
1d1df11d |
3367 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
3368 | { |
3369 | g_assert(pid == 0 || pid != process->ppid); |
3370 | /* Process not present */ |
1c736ed5 |
3371 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
3372 | const gchar *name = g_quark_to_string(process->name); |
3373 | ProcessInfo *process_info; |
3374 | processlist_add(process_list, |
1c736ed5 |
3375 | drawing, |
40debf7b |
3376 | pid, |
3377 | process->last_cpu_index, |
3378 | process->ppid, |
3379 | &birth, |
3380 | tfc->t_context->index, |
3381 | name, |
3382 | &pl_height, |
3383 | &process_info, |
3384 | &hashed_process_data); |
1c736ed5 |
3385 | gtk_widget_set_size_request(drawing->drawing_area, |
3386 | -1, |
3387 | pl_height); |
3388 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
3389 | } |
3390 | |
3391 | /* Set the current process */ |
3392 | process_list->current_hash_data[process->last_cpu_index] = |
3393 | hashed_process_data; |
e92eabaf |
3394 | } |
dbd243b1 |
3395 | |
1d1df11d |
3396 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
3397 | evtime) <= 0)) |
b2743953 |
3398 | { |
fd22065b |
3399 | TimeWindow time_window = |
3400 | lttvwindow_get_time_window(control_flow_data->tab); |
3401 | |
3402 | #ifdef EXTRA_CHECK |
3403 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
3404 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3405 | return; |
3406 | #endif //EXTRA_CHECK |
d6fef890 |
3407 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
3408 | guint width = drawing->width; |
b2743953 |
3409 | guint new_x; |
3410 | convert_time_to_pixels( |
3411 | time_window, |
3412 | evtime, |
3413 | width, |
3414 | &new_x); |
1d1df11d |
3415 | if(unlikely(hashed_process_data->x.middle != new_x)) { |
b2743953 |
3416 | hashed_process_data->x.middle = new_x; |
3417 | hashed_process_data->x.middle_used = FALSE; |
3418 | hashed_process_data->x.middle_marked = FALSE; |
3419 | } |
e72908ed |
3420 | } |
3421 | |
e92eabaf |
3422 | } |
3423 | return 0; |
3424 | |
3425 | } |
2c82c4dc |
3426 | #endif //0 |
f7afe191 |
3427 | |
1b238973 |
3428 | gint update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
3429 | { |
a56a1ba4 |
3430 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
a43d67ba |
3431 | Drawing_t *drawing = control_flow_data->drawing; |
1c736ed5 |
3432 | ProcessList *process_list = control_flow_data->process_list; |
a43d67ba |
3433 | |
224446ce |
3434 | const TimeWindowNotifyData *time_window_nofify_data = |
3435 | ((const TimeWindowNotifyData *)call_data); |
3436 | |
14963be0 |
3437 | TimeWindow *old_time_window = |
224446ce |
3438 | time_window_nofify_data->old_time_window; |
3439 | TimeWindow *new_time_window = |
3440 | time_window_nofify_data->new_time_window; |
a56a1ba4 |
3441 | |
3cb8b205 |
3442 | /* Update the ruler */ |
3443 | drawing_update_ruler(control_flow_data->drawing, |
3444 | new_time_window); |
3445 | |
3446 | |
a56a1ba4 |
3447 | /* Two cases : zoom in/out or scrolling */ |
3448 | |
3449 | /* In order to make sure we can reuse the old drawing, the scale must |
3450 | * be the same and the new time interval being partly located in the |
3451 | * currently shown time interval. (reuse is only for scrolling) |
3452 | */ |
3453 | |
2eef04b5 |
3454 | g_info("Old time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 |
3455 | old_time_window->start_time.tv_sec, |
3456 | old_time_window->start_time.tv_nsec, |
3457 | old_time_window->time_width.tv_sec, |
3458 | old_time_window->time_width.tv_nsec); |
a56a1ba4 |
3459 | |
2eef04b5 |
3460 | g_info("New time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 |
3461 | new_time_window->start_time.tv_sec, |
3462 | new_time_window->start_time.tv_nsec, |
3463 | new_time_window->time_width.tv_sec, |
3464 | new_time_window->time_width.tv_nsec); |
a56a1ba4 |
3465 | |
14963be0 |
3466 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
3467 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) |
a56a1ba4 |
3468 | { |
3469 | /* Same scale (scrolling) */ |
3470 | g_info("scrolling"); |
14963be0 |
3471 | LttTime *ns = &new_time_window->start_time; |
20640e70 |
3472 | LttTime *nw = &new_time_window->time_width; |
14963be0 |
3473 | LttTime *os = &old_time_window->start_time; |
20640e70 |
3474 | LttTime *ow = &old_time_window->time_width; |
6f26fc38 |
3475 | LttTime old_end = old_time_window->end_time; |
3476 | LttTime new_end = new_time_window->end_time; |
a56a1ba4 |
3477 | //if(ns<os+w<ns+w) |
3478 | //if(ns<os+w && os+w<ns+w) |
3479 | //if(ns<old_end && os<ns) |
3480 | if(ltt_time_compare(*ns, old_end) == -1 |
3481 | && ltt_time_compare(*os, *ns) == -1) |
3482 | { |
3483 | g_info("scrolling near right"); |
3484 | /* Scroll right, keep right part of the screen */ |
3485 | guint x = 0; |
51705146 |
3486 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
3487 | convert_time_to_pixels( |
a18124ff |
3488 | *old_time_window, |
a56a1ba4 |
3489 | *ns, |
3490 | width, |
3491 | &x); |
3492 | |
3493 | /* Copy old data to new location */ |
1c736ed5 |
3494 | copy_pixmap_region(process_list, |
3495 | NULL, |
3496 | control_flow_data->drawing->drawing_area->style->black_gc, |
3497 | NULL, |
3498 | x, 0, |
3499 | 0, 0, |
3500 | control_flow_data->drawing->width-x+SAFETY, -1); |
3501 | |
6395d57c |
3502 | if(drawing->damage_begin == drawing->damage_end) |
3503 | drawing->damage_begin = control_flow_data->drawing->width-x; |
3504 | else |
3505 | drawing->damage_begin = 0; |
3506 | |
3507 | drawing->damage_end = control_flow_data->drawing->width; |
3508 | |
a56a1ba4 |
3509 | /* Clear the data request background, but not SAFETY */ |
1c736ed5 |
3510 | rectangle_pixmap(process_list, |
cfe526b1 |
3511 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
3512 | TRUE, |
6395d57c |
3513 | drawing->damage_begin+SAFETY, 0, |
3514 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1c736ed5 |
3515 | -1); |
7abb23ad |
3516 | gtk_widget_queue_draw(drawing->drawing_area); |
3517 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
3518 | // 0,0, |
3519 | // control_flow_data->drawing->width, |
3520 | // control_flow_data->drawing->height); |
a43d67ba |
3521 | |
a56a1ba4 |
3522 | /* Get new data for the rest. */ |
501d5405 |
3523 | drawing_data_request(control_flow_data->drawing, |
6395d57c |
3524 | drawing->damage_begin, 0, |
3525 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
3526 | control_flow_data->drawing->height); |
a56a1ba4 |
3527 | } else { |
3528 | //if(ns<os<ns+w) |
3529 | //if(ns<os && os<ns+w) |
3530 | //if(ns<os && os<new_end) |
3531 | if(ltt_time_compare(*ns,*os) == -1 |
3532 | && ltt_time_compare(*os,new_end) == -1) |
3533 | { |
3534 | g_info("scrolling near left"); |
3535 | /* Scroll left, keep left part of the screen */ |
3536 | guint x = 0; |
51705146 |
3537 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
3538 | convert_time_to_pixels( |
a18124ff |
3539 | *new_time_window, |
a56a1ba4 |
3540 | *os, |
3541 | width, |
3542 | &x); |
6395d57c |
3543 | |
a56a1ba4 |
3544 | /* Copy old data to new location */ |
1c736ed5 |
3545 | copy_pixmap_region (process_list, |
3546 | NULL, |
cfe526b1 |
3547 | control_flow_data->drawing->drawing_area->style->black_gc, |
1c736ed5 |
3548 | NULL, |
a56a1ba4 |
3549 | 0, 0, |
3550 | x, 0, |
3551 | -1, -1); |
3552 | |
6395d57c |
3553 | if(drawing->damage_begin == drawing->damage_end) |
3554 | drawing->damage_end = x; |
3555 | else |
3556 | drawing->damage_end = |
51705146 |
3557 | control_flow_data->drawing->width; |
6395d57c |
3558 | |
3559 | drawing->damage_begin = 0; |
3560 | |
1c736ed5 |
3561 | rectangle_pixmap (process_list, |
cfe526b1 |
3562 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
3563 | TRUE, |
6395d57c |
3564 | drawing->damage_begin, 0, |
3565 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1c736ed5 |
3566 | -1); |
a43d67ba |
3567 | |
7abb23ad |
3568 | gtk_widget_queue_draw(drawing->drawing_area); |
3569 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
3570 | // 0,0, |
3571 | // control_flow_data->drawing->width, |
3572 | // control_flow_data->drawing->height); |
a43d67ba |
3573 | |
6395d57c |
3574 | |
a56a1ba4 |
3575 | /* Get new data for the rest. */ |
501d5405 |
3576 | drawing_data_request(control_flow_data->drawing, |
6395d57c |
3577 | drawing->damage_begin, 0, |
3578 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
3579 | control_flow_data->drawing->height); |
a56a1ba4 |
3580 | |
a56a1ba4 |
3581 | } else { |
a43d67ba |
3582 | if(ltt_time_compare(*ns,*os) == 0) |
3583 | { |
3584 | g_info("not scrolling"); |
3585 | } else { |
3586 | g_info("scrolling far"); |
3587 | /* Cannot reuse any part of the screen : far jump */ |
3588 | |
3589 | |
1c736ed5 |
3590 | rectangle_pixmap (process_list, |
a43d67ba |
3591 | control_flow_data->drawing->drawing_area->style->black_gc, |
3592 | TRUE, |
a56a1ba4 |
3593 | 0, 0, |
a43d67ba |
3594 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 |
3595 | -1); |
a43d67ba |
3596 | |
7abb23ad |
3597 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
3598 | // 0,0, |
3599 | // control_flow_data->drawing->width, |
3600 | // control_flow_data->drawing->height); |
3601 | gtk_widget_queue_draw(drawing->drawing_area); |
a43d67ba |
3602 | |
6395d57c |
3603 | drawing->damage_begin = 0; |
3604 | drawing->damage_end = control_flow_data->drawing->width; |
3605 | |
a43d67ba |
3606 | drawing_data_request(control_flow_data->drawing, |
a43d67ba |
3607 | 0, 0, |
3608 | control_flow_data->drawing->width, |
3609 | control_flow_data->drawing->height); |
3610 | |
3611 | } |
a56a1ba4 |
3612 | } |
3613 | } |
3614 | } else { |
3615 | /* Different scale (zoom) */ |
3616 | g_info("zoom"); |
3617 | |
1c736ed5 |
3618 | rectangle_pixmap (process_list, |
cfe526b1 |
3619 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
3620 | TRUE, |
3621 | 0, 0, |
501d5405 |
3622 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 |
3623 | -1); |
a56a1ba4 |
3624 | |
7abb23ad |
3625 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
3626 | // 0,0, |
3627 | // control_flow_data->drawing->width, |
3628 | // control_flow_data->drawing->height); |
3629 | gtk_widget_queue_draw(drawing->drawing_area); |
a56a1ba4 |
3630 | |
6395d57c |
3631 | drawing->damage_begin = 0; |
3632 | drawing->damage_end = control_flow_data->drawing->width; |
3633 | |
501d5405 |
3634 | drawing_data_request(control_flow_data->drawing, |
a56a1ba4 |
3635 | 0, 0, |
501d5405 |
3636 | control_flow_data->drawing->width, |
3637 | control_flow_data->drawing->height); |
a56a1ba4 |
3638 | } |
3639 | |
3cb8b205 |
3640 | |
3641 | |
a56a1ba4 |
3642 | return 0; |
f7afe191 |
3643 | } |
3644 | |
6395d57c |
3645 | gint traceset_notify(void *hook_data, void *call_data) |
3646 | { |
3647 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
3648 | Drawing_t *drawing = control_flow_data->drawing; |
6395d57c |
3649 | |
6395d57c |
3650 | |
b9a010a2 |
3651 | drawing_clear(control_flow_data->drawing); |
3652 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
3653 | gtk_widget_set_size_request( |
3654 | control_flow_data->drawing->drawing_area, |
3655 | -1, processlist_get_height(control_flow_data->process_list)); |
d9267eec |
3656 | redraw_notify(control_flow_data, NULL); |
6395d57c |
3657 | |
d9267eec |
3658 | request_background_data(control_flow_data); |
6395d57c |
3659 | |
3660 | return FALSE; |
3661 | } |
3662 | |
ca0f8a8e |
3663 | gint redraw_notify(void *hook_data, void *call_data) |
3664 | { |
3665 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
3666 | Drawing_t *drawing = control_flow_data->drawing; |
3667 | GtkWidget *widget = drawing->drawing_area; |
3668 | |
3669 | drawing->damage_begin = 0; |
51705146 |
3670 | drawing->damage_end = drawing->width; |
ca0f8a8e |
3671 | |
49217bd4 |
3672 | /* fun feature, to be separated someday... */ |
3673 | drawing_clear(control_flow_data->drawing); |
3674 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
3675 | gtk_widget_set_size_request( |
3676 | control_flow_data->drawing->drawing_area, |
3677 | -1, processlist_get_height(control_flow_data->process_list)); |
1c736ed5 |
3678 | // Clear the images |
3679 | rectangle_pixmap (control_flow_data->process_list, |
ca0f8a8e |
3680 | widget->style->black_gc, |
3681 | TRUE, |
3682 | 0, 0, |
f3b7430d |
3683 | drawing->alloc_width, |
1c736ed5 |
3684 | -1); |
ca0f8a8e |
3685 | |
f3b7430d |
3686 | gtk_widget_queue_draw(drawing->drawing_area); |
ca0f8a8e |
3687 | |
3688 | if(drawing->damage_begin < drawing->damage_end) |
3689 | { |
3690 | drawing_data_request(drawing, |
ca0f8a8e |
3691 | drawing->damage_begin, |
3692 | 0, |
3693 | drawing->damage_end-drawing->damage_begin, |
51705146 |
3694 | drawing->height); |
ca0f8a8e |
3695 | } |
3696 | |
7abb23ad |
3697 | //gtk_widget_queue_draw_area(drawing->drawing_area, |
3698 | // 0,0, |
3699 | // drawing->width, |
3700 | // drawing->height); |
ca0f8a8e |
3701 | return FALSE; |
3702 | |
3703 | } |
3704 | |
3705 | |
3706 | gint continue_notify(void *hook_data, void *call_data) |
a43d67ba |
3707 | { |
3708 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
ca0f8a8e |
3709 | Drawing_t *drawing = control_flow_data->drawing; |
a43d67ba |
3710 | |
6395d57c |
3711 | //g_assert(widget->allocation.width == drawing->damage_end); |
ca0f8a8e |
3712 | |
3713 | if(drawing->damage_begin < drawing->damage_end) |
3714 | { |
3715 | drawing_data_request(drawing, |
ca0f8a8e |
3716 | drawing->damage_begin, |
3717 | 0, |
3718 | drawing->damage_end-drawing->damage_begin, |
51705146 |
3719 | drawing->height); |
ca0f8a8e |
3720 | } |
3721 | |
3722 | return FALSE; |
3723 | } |
3724 | |
3725 | |
1b238973 |
3726 | gint update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
3727 | { |
14963be0 |
3728 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
a43d67ba |
3729 | Drawing_t *drawing = control_flow_data->drawing; |
a56a1ba4 |
3730 | |
224446ce |
3731 | LttTime current_time = *((LttTime*)call_data); |
a56a1ba4 |
3732 | |
ca0f8a8e |
3733 | TimeWindow time_window = |
3734 | lttvwindow_get_time_window(control_flow_data->tab); |
a56a1ba4 |
3735 | |
ca0f8a8e |
3736 | LttTime time_begin = time_window.start_time; |
3737 | LttTime width = time_window.time_width; |
90ef7e4a |
3738 | LttTime half_width; |
3739 | { |
3740 | guint64 time_ll = ltt_time_to_uint64(width); |
3741 | time_ll = time_ll >> 1; /* divide by two */ |
3742 | half_width = ltt_time_from_uint64(time_ll); |
3743 | } |
a56a1ba4 |
3744 | LttTime time_end = ltt_time_add(time_begin, width); |
3745 | |
3746 | LttvTracesetContext * tsc = |
ca0f8a8e |
3747 | lttvwindow_get_traceset_context(control_flow_data->tab); |
a56a1ba4 |
3748 | |
ca0f8a8e |
3749 | LttTime trace_start = tsc->time_span.start_time; |
3750 | LttTime trace_end = tsc->time_span.end_time; |
a56a1ba4 |
3751 | |
2eef04b5 |
3752 | g_info("New current time HOOK : %lu, %lu", current_time.tv_sec, |
224446ce |
3753 | current_time.tv_nsec); |
a56a1ba4 |
3754 | |
3755 | |
3756 | |
3757 | /* If current time is inside time interval, just move the highlight |
3758 | * bar */ |
3759 | |
3760 | /* Else, we have to change the time interval. We have to tell it |
3761 | * to the main window. */ |
3762 | /* The time interval change will take care of placing the current |
3763 | * time at the center of the visible area, or nearest possible if we are |
3764 | * at one end of the trace. */ |
3765 | |
3766 | |
dbc0ef8a |
3767 | if(ltt_time_compare(current_time, time_begin) < 0) |
a56a1ba4 |
3768 | { |
224446ce |
3769 | TimeWindow new_time_window; |
3770 | |
3771 | if(ltt_time_compare(current_time, |
dbc0ef8a |
3772 | ltt_time_add(trace_start,half_width)) < 0) |
a56a1ba4 |
3773 | time_begin = trace_start; |
3774 | else |
224446ce |
3775 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
3776 | |
224446ce |
3777 | new_time_window.start_time = time_begin; |
3778 | new_time_window.time_width = width; |
a18124ff |
3779 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 |
3780 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 |
3781 | |
e800cf84 |
3782 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 |
3783 | } |
dbc0ef8a |
3784 | else if(ltt_time_compare(current_time, time_end) > 0) |
a56a1ba4 |
3785 | { |
224446ce |
3786 | TimeWindow new_time_window; |
3787 | |
dbc0ef8a |
3788 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0) |
a56a1ba4 |
3789 | time_begin = ltt_time_sub(trace_end,width); |
3790 | else |
224446ce |
3791 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
3792 | |
224446ce |
3793 | new_time_window.start_time = time_begin; |
3794 | new_time_window.time_width = width; |
a18124ff |
3795 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 |
3796 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 |
3797 | |
e800cf84 |
3798 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 |
3799 | |
3800 | } |
7abb23ad |
3801 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
3802 | |
a56a1ba4 |
3803 | |
3804 | return 0; |
f7afe191 |
3805 | } |
3806 | |
8b90e648 |
3807 | typedef struct _ClosureData { |
ca0f8a8e |
3808 | EventsRequest *events_request; |
d0cd7f09 |
3809 | LttvTracesetState *tss; |
b9a010a2 |
3810 | LttTime end_time; |
bc8d270b |
3811 | guint x_end; |
8b90e648 |
3812 | } ClosureData; |
a56a1ba4 |
3813 | |
8b90e648 |
3814 | |
e800cf84 |
3815 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
3816 | { |
a56a1ba4 |
3817 | ProcessInfo *process_info = (ProcessInfo*)key; |
3818 | HashedProcessData *hashed_process_data = (HashedProcessData*)value; |
3819 | ClosureData *closure_data = (ClosureData*)user_data; |
3820 | |
e800cf84 |
3821 | EventsRequest *events_request = closure_data->events_request; |
3822 | ControlFlowData *control_flow_data = events_request->viewer_data; |
a56a1ba4 |
3823 | |
e800cf84 |
3824 | LttvTracesetState *tss = closure_data->tss; |
d6fef890 |
3825 | LttvTracesetContext *tsc = (LttvTracesetContext*)tss; |
a56a1ba4 |
3826 | |
e800cf84 |
3827 | LttTime evtime = closure_data->end_time; |
d0cd7f09 |
3828 | |
e800cf84 |
3829 | { |
3830 | /* For the process */ |
3831 | /* First, check if the current process is in the state computation |
3832 | * process list. If it is there, that means we must add it right now and |
3833 | * draw items from the beginning of the read for it. If it is not |
3834 | * present, it's a new process and it was not present : it will |
3835 | * be added after the state update. */ |
31b6868d |
3836 | #ifdef EXTRA_CHECK |
e800cf84 |
3837 | g_assert(lttv_traceset_number(tsc->ts) > 0); |
31b6868d |
3838 | #endif //EXTRA_CHECK |
2c82c4dc |
3839 | LttvTraceContext *tc = tsc->traces[process_info->trace_num]; |
3840 | |
3841 | //FIXME : optimize data structures. |
3842 | LttvTracefileState *tfs; |
3843 | LttvTracefileContext *tfc; |
3844 | guint i; |
3845 | for(i=0;i<tc->tracefiles->len;i++) { |
3846 | tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, i); |
3847 | if(ltt_tracefile_name(tfc->tf) == LTT_NAME_CPU |
3848 | && ltt_tracefile_num(tfc->tf) == process_info->cpu) |
3849 | break; |
3850 | |
3851 | } |
3852 | g_assert(i<tc->tracefiles->len); |
3853 | tfs = LTTV_TRACEFILE_STATE(tfc); |
a56a1ba4 |
3854 | |
2c82c4dc |
3855 | // LttvTracefileState *tfs = |
3856 | // (LttvTracefileState*)tsc->traces[process_info->trace_num]-> |
3857 | // tracefiles[process_info->cpu]; |
2da61677 |
3858 | |
e800cf84 |
3859 | LttvProcessState *process; |
e025a729 |
3860 | process = lttv_state_find_process(tfs, |
3861 | process_info->pid); |
a56a1ba4 |
3862 | |
1d1df11d |
3863 | if(unlikely(process != NULL)) { |
e800cf84 |
3864 | |
3865 | /* Only draw for processes that are currently in the trace states */ |
ad2e83ba |
3866 | |
5c230fc4 |
3867 | ProcessList *process_list = control_flow_data->process_list; |
1d1df11d |
3868 | #ifdef EXTRA_CHECK |
e800cf84 |
3869 | /* Should be alike when background info is ready */ |
3870 | if(control_flow_data->background_info_waiting==0) |
3871 | g_assert(ltt_time_compare(process->creation_time, |
3872 | process_info->birth) == 0); |
1d1df11d |
3873 | #endif //EXTRA_CHECK |
e800cf84 |
3874 | |
3875 | /* Now, the process is in the state hash and our own process hash. |
3876 | * We definitely can draw the items related to the ending state. |
3877 | */ |
3878 | |
1d1df11d |
3879 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
3880 | evtime) <= 0)) |
e800cf84 |
3881 | { |
fd22065b |
3882 | TimeWindow time_window = |
3883 | lttvwindow_get_time_window(control_flow_data->tab); |
3884 | |
3885 | #ifdef EXTRA_CHECK |
3886 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
3887 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3888 | return; |
3889 | #endif //EXTRA_CHECK |
d6fef890 |
3890 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
3891 | guint width = drawing->width; |
a56a1ba4 |
3892 | |
bc8d270b |
3893 | guint x = closure_data->x_end; |
8b90e648 |
3894 | |
4b7dc462 |
3895 | DrawContext draw_context; |
3896 | |
e800cf84 |
3897 | /* Now create the drawing context that will be used to draw |
3898 | * items related to the last state. */ |
1c736ed5 |
3899 | draw_context.drawable = hashed_process_data->pixmap; |
e800cf84 |
3900 | draw_context.gc = drawing->gc; |
3901 | draw_context.pango_layout = drawing->pango_layout; |
e800cf84 |
3902 | draw_context.drawinfo.end.x = x; |
3903 | |
1c736ed5 |
3904 | draw_context.drawinfo.y.over = 1; |
3905 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
3906 | draw_context.drawinfo.y.under = hashed_process_data->height; |
e800cf84 |
3907 | |
3908 | draw_context.drawinfo.start.offset.over = 0; |
3909 | draw_context.drawinfo.start.offset.middle = 0; |
3910 | draw_context.drawinfo.start.offset.under = 0; |
3911 | draw_context.drawinfo.end.offset.over = 0; |
3912 | draw_context.drawinfo.end.offset.middle = 0; |
3913 | draw_context.drawinfo.end.offset.under = 0; |
9a1ec01b |
3914 | #if 0 |
4b7dc462 |
3915 | /* Jump over draw if we are at the same x position */ |
3916 | if(x == hashed_process_data->x.over) |
e800cf84 |
3917 | { |
4b7dc462 |
3918 | /* jump */ |
3919 | } else { |
23093869 |
3920 | draw_context.drawinfo.start.x = hashed_process_data->x.over; |
3921 | /* Draw the line */ |
3922 | PropertiesLine prop_line = prepare_execmode_line(process); |
3923 | draw_line((void*)&prop_line, (void*)&draw_context); |
3924 | |
4b7dc462 |
3925 | hashed_process_data->x.over = x; |
23093869 |
3926 | } |
9a1ec01b |
3927 | #endif //0 |
4b7dc462 |
3928 | |
1d1df11d |
3929 | if(unlikely(x == hashed_process_data->x.middle && |
3930 | hashed_process_data->x.middle_used)) { |
b2743953 |
3931 | #if 0 /* do not mark closure : not missing information */ |
e72908ed |
3932 | if(hashed_process_data->x.middle_marked == FALSE) { |
3933 | /* Draw collision indicator */ |
3934 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
3935 | gdk_draw_point(drawing->pixmap, |
3936 | drawing->gc, |
3937 | x, |
2c6618bc |
3938 | y+(height/2)-3); |
de4ea1ad |
3939 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
3940 | } |
b2743953 |
3941 | #endif //0 |
4b7dc462 |
3942 | /* Jump */ |
3943 | } else { |
23093869 |
3944 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
e800cf84 |
3945 | /* Draw the line */ |
9a1ec01b |
3946 | PropertiesLine prop_line = prepare_s_e_line(process); |
e800cf84 |
3947 | draw_line((void*)&prop_line, (void*)&draw_context); |
3948 | |
4b7dc462 |
3949 | /* become the last x position */ |
1d1df11d |
3950 | if(likely(x != hashed_process_data->x.middle)) { |
e72908ed |
3951 | hashed_process_data->x.middle = x; |
3952 | /* but don't use the pixel */ |
3953 | hashed_process_data->x.middle_used = FALSE; |
b2743953 |
3954 | |
3955 | /* Calculate the next good time */ |
3956 | convert_pixels_to_time(width, x+1, time_window, |
3957 | &hashed_process_data->next_good_time); |
e72908ed |
3958 | } |
e800cf84 |
3959 | } |
e800cf84 |
3960 | } |
3961 | } |
3962 | } |
3963 | return; |
8b90e648 |
3964 | } |
3965 | |
b9a010a2 |
3966 | int before_chunk(void *hook_data, void *call_data) |
3967 | { |
3968 | EventsRequest *events_request = (EventsRequest*)hook_data; |
16b9cadb |
3969 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
7c0125e0 |
3970 | ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data; |
cd3892fe |
3971 | #if 0 |
7c0125e0 |
3972 | /* Desactivate sort */ |
3973 | gtk_tree_sortable_set_sort_column_id( |
3974 | GTK_TREE_SORTABLE(cfd->process_list->list_store), |
3975 | TRACE_COLUMN, |
3976 | GTK_SORT_ASCENDING); |
cd3892fe |
3977 | #endif //0 |
b9a010a2 |
3978 | drawing_chunk_begin(events_request, tss); |
3979 | |
3980 | return 0; |
3981 | } |
3982 | |
3983 | int before_request(void *hook_data, void *call_data) |
ca0f8a8e |
3984 | { |
3985 | EventsRequest *events_request = (EventsRequest*)hook_data; |
16b9cadb |
3986 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
7c0125e0 |
3987 | |
ca0f8a8e |
3988 | drawing_data_request_begin(events_request, tss); |
3989 | |
3990 | return 0; |
3991 | } |
3992 | |
3993 | |
8b90e648 |
3994 | /* |
b9a010a2 |
3995 | * after request is necessary in addition of after chunk in order to draw |
3996 | * lines until the end of the screen. after chunk just draws lines until |
3997 | * the last event. |
3998 | * |
8b90e648 |
3999 | * for each process |
a56a1ba4 |
4000 | * draw closing line |
b9a010a2 |
4001 | * expose |
8b90e648 |
4002 | */ |
b9a010a2 |
4003 | int after_request(void *hook_data, void *call_data) |
8b90e648 |
4004 | { |
ca0f8a8e |
4005 | EventsRequest *events_request = (EventsRequest*)hook_data; |
4006 | ControlFlowData *control_flow_data = events_request->viewer_data; |
16b9cadb |
4007 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
a56a1ba4 |
4008 | |
5c230fc4 |
4009 | ProcessList *process_list = control_flow_data->process_list; |
b9a010a2 |
4010 | LttTime end_time = events_request->end_time; |
4011 | |
4012 | ClosureData closure_data; |
4013 | closure_data.events_request = (EventsRequest*)hook_data; |
4014 | closure_data.tss = tss; |
4015 | closure_data.end_time = end_time; |
4016 | |
bc8d270b |
4017 | TimeWindow time_window = |
4018 | lttvwindow_get_time_window(control_flow_data->tab); |
4019 | guint width = control_flow_data->drawing->width; |
4020 | convert_time_to_pixels( |
4021 | time_window, |
4022 | end_time, |
4023 | width, |
4024 | &closure_data.x_end); |
4025 | |
4026 | |
b9a010a2 |
4027 | /* Draw last items */ |
4028 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
4029 | (void*)&closure_data); |
7c0125e0 |
4030 | |
b9a010a2 |
4031 | |
4032 | /* Request expose */ |
4033 | drawing_request_expose(events_request, tss, end_time); |
4034 | return 0; |
4035 | } |
4036 | |
4037 | /* |
4038 | * for each process |
4039 | * draw closing line |
e800cf84 |
4040 | * expose |
b9a010a2 |
4041 | */ |
4042 | int after_chunk(void *hook_data, void *call_data) |
4043 | { |
4044 | EventsRequest *events_request = (EventsRequest*)hook_data; |
4045 | ControlFlowData *control_flow_data = events_request->viewer_data; |
16b9cadb |
4046 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
4047 | LttvTracesetContext *tsc = (LttvTracesetContext*)call_data; |
b9a010a2 |
4048 | LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc); |
4049 | LttTime end_time; |
4050 | |
5c230fc4 |
4051 | ProcessList *process_list = control_flow_data->process_list; |
b9a010a2 |
4052 | |
40debf7b |
4053 | g_free(process_list->current_hash_data); |
4054 | process_list->current_hash_data = NULL; |
4055 | |
e800cf84 |
4056 | if(tfc != NULL) |
4057 | end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time); |
0c5dbe3b |
4058 | else /* end of traceset, or position now out of request : end */ |
4059 | end_time = events_request->end_time; |
4060 | |
a56a1ba4 |
4061 | ClosureData closure_data; |
ca0f8a8e |
4062 | closure_data.events_request = (EventsRequest*)hook_data; |
4063 | closure_data.tss = tss; |
b9a010a2 |
4064 | closure_data.end_time = end_time; |
a56a1ba4 |
4065 | |
bc8d270b |
4066 | TimeWindow time_window = |
4067 | lttvwindow_get_time_window(control_flow_data->tab); |
4068 | guint width = control_flow_data->drawing->width; |
4069 | convert_time_to_pixels( |
4070 | time_window, |
4071 | end_time, |
4072 | width, |
4073 | &closure_data.x_end); |
4074 | |
b9a010a2 |
4075 | /* Draw last items */ |
14963be0 |
4076 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
a56a1ba4 |
4077 | (void*)&closure_data); |
cd3892fe |
4078 | #if 0 |
7c0125e0 |
4079 | /* Reactivate sort */ |
4080 | gtk_tree_sortable_set_sort_column_id( |
4081 | GTK_TREE_SORTABLE(control_flow_data->process_list->list_store), |
4082 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
4083 | GTK_SORT_ASCENDING); |
4084 | |
4085 | update_index_to_pixmap(control_flow_data->process_list); |
cd3892fe |
4086 | /* Request a full expose : drawing scrambled */ |
4087 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
4088 | #endif //0 |
4089 | /* Request expose (updates damages zone also) */ |
b9a010a2 |
4090 | drawing_request_expose(events_request, tss, end_time); |
ca0f8a8e |
4091 | |
4092 | return 0; |
8b90e648 |
4093 | } |
4094 | |