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> |
80a52ff8 |
65 | |
2a2fa4f0 |
66 | #include <lttv/lttv.h> |
558aa013 |
67 | #include <lttv/hook.h> |
80a52ff8 |
68 | #include <lttv/state.h> |
2d262115 |
69 | #include <lttvwindow/lttvwindow.h> |
6395d57c |
70 | #include <lttvwindow/lttvwindowtraces.h> |
80a52ff8 |
71 | |
f0d936c0 |
72 | |
a117e3f7 |
73 | #include "eventhooks.h" |
74 | #include "cfv.h" |
75 | #include "processlist.h" |
76 | #include "drawing.h" |
5f16133f |
77 | |
80a52ff8 |
78 | |
1a31868c |
79 | #define MAX_PATH_LEN 256 |
80 | |
f0d936c0 |
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); |
6395d57c |
259 | request_background_data(control_flow_data); |
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 | { |
b9a010a2 |
381 | EventsRequest *events_request = (EventsRequest*)hook_data; |
382 | ControlFlowData *control_flow_data = events_request->viewer_data; |
383 | |
384 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
385 | |
386 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
b9a010a2 |
387 | |
388 | LttEvent *e; |
389 | e = tfc->e; |
390 | |
391 | LttTime evtime = ltt_event_time(e); |
fd22065b |
392 | |
10a1069a |
393 | /* we are in a schedchange, before the state update. We must draw the |
394 | * items corresponding to the state before it changes : now is the right |
395 | * time to do it. |
396 | */ |
b9a010a2 |
397 | |
10a1069a |
398 | guint pid_out; |
399 | guint pid_in; |
400 | { |
401 | LttField *f = ltt_event_field(e); |
402 | LttField *element; |
403 | element = ltt_field_member(f,0); |
404 | pid_out = ltt_event_get_long_unsigned(e,element); |
405 | element = ltt_field_member(f,1); |
406 | pid_in = ltt_event_get_long_unsigned(e,element); |
10a1069a |
407 | } |
408 | |
409 | { |
410 | /* For the pid_out */ |
411 | /* First, check if the current process is in the state computation |
412 | * process list. If it is there, that means we must add it right now and |
413 | * draw items from the beginning of the read for it. If it is not |
414 | * present, it's a new process and it was not present : it will |
415 | * be added after the state update. */ |
416 | LttvProcessState *process; |
40debf7b |
417 | /* unknown state, bad current pid */ |
418 | if(tfs->process->pid != pid_out) |
419 | process = lttv_state_find_process(tfs, pid_out); |
420 | else |
421 | process = tfs->process; |
b9a010a2 |
422 | |
10a1069a |
423 | if(process != NULL) { |
424 | /* Well, the process_out existed : we must get it in the process hash |
425 | * or add it, and draw its items. |
426 | */ |
427 | /* Add process to process list (if not present) */ |
1c736ed5 |
428 | guint pl_height = 0; |
10a1069a |
429 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
430 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
431 | LttTime birth = process->creation_time; |
b9a010a2 |
432 | |
ac4e21cf |
433 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
434 | pid_out, |
40debf7b |
435 | process->last_cpu_index, |
10a1069a |
436 | &birth, |
ac4e21cf |
437 | tfc->t_context->index); |
438 | if(hashed_process_data == NULL) |
10a1069a |
439 | { |
440 | g_assert(pid_out == 0 || pid_out != process->ppid); |
aac69e70 |
441 | const gchar *name = g_quark_to_string(process->name); |
10a1069a |
442 | /* Process not present */ |
4e86ae2e |
443 | ProcessInfo *process_info; |
1c736ed5 |
444 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
445 | processlist_add(process_list, |
1c736ed5 |
446 | drawing, |
10a1069a |
447 | pid_out, |
40debf7b |
448 | process->last_cpu_index, |
10a1069a |
449 | process->ppid, |
450 | &birth, |
451 | tfc->t_context->index, |
452 | name, |
453 | &pl_height, |
4e86ae2e |
454 | &process_info, |
10a1069a |
455 | &hashed_process_data); |
1c736ed5 |
456 | gtk_widget_set_size_request(drawing->drawing_area, |
457 | -1, |
458 | pl_height); |
459 | gtk_widget_queue_draw(drawing->drawing_area); |
460 | |
10a1069a |
461 | } |
ac4e21cf |
462 | |
10a1069a |
463 | /* Now, the process is in the state hash and our own process hash. |
464 | * We definitely can draw the items related to the ending state. |
465 | */ |
e800cf84 |
466 | |
b2743953 |
467 | if(ltt_time_compare(hashed_process_data->next_good_time, |
468 | evtime) > 0) |
10a1069a |
469 | { |
b2743953 |
470 | if(hashed_process_data->x.middle_marked == FALSE) { |
ac4e21cf |
471 | |
fd22065b |
472 | TimeWindow time_window = |
473 | lttvwindow_get_time_window(control_flow_data->tab); |
474 | #ifdef EXTRA_CHECK |
475 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
476 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
477 | return; |
478 | #endif //EXTRA_CHECK |
d6fef890 |
479 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
480 | guint width = drawing->width; |
b2743953 |
481 | guint x; |
482 | convert_time_to_pixels( |
483 | time_window, |
484 | evtime, |
485 | width, |
486 | &x); |
487 | |
488 | /* Draw collision indicator */ |
489 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
490 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
491 | drawing->gc, |
492 | x, |
1c736ed5 |
493 | (hashed_process_data->height/2)-3); |
b2743953 |
494 | hashed_process_data->x.middle_marked = TRUE; |
495 | } |
496 | } else { |
ac4e21cf |
497 | TimeWindow time_window = |
498 | lttvwindow_get_time_window(control_flow_data->tab); |
fd22065b |
499 | #ifdef EXTRA_CHECK |
ac4e21cf |
500 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
501 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
502 | return; |
fd22065b |
503 | #endif //EXTRA_CHECK |
d6fef890 |
504 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
505 | guint width = drawing->width; |
10a1069a |
506 | guint x; |
10a1069a |
507 | convert_time_to_pixels( |
a18124ff |
508 | time_window, |
4b7dc462 |
509 | evtime, |
510 | width, |
511 | &x); |
10a1069a |
512 | |
10a1069a |
513 | |
4b7dc462 |
514 | /* Jump over draw if we are at the same x position */ |
e72908ed |
515 | if(x == hashed_process_data->x.middle && |
516 | hashed_process_data->x.middle_used) |
e800cf84 |
517 | { |
e72908ed |
518 | if(hashed_process_data->x.middle_marked == FALSE) { |
519 | /* Draw collision indicator */ |
520 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
521 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
522 | drawing->gc, |
523 | x, |
1c736ed5 |
524 | (hashed_process_data->height/2)-3); |
de4ea1ad |
525 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
526 | } |
4b7dc462 |
527 | /* jump */ |
528 | } else { |
529 | DrawContext draw_context; |
10a1069a |
530 | |
4b7dc462 |
531 | /* Now create the drawing context that will be used to draw |
532 | * items related to the last state. */ |
1c736ed5 |
533 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
534 | draw_context.gc = drawing->gc; |
535 | draw_context.pango_layout = drawing->pango_layout; |
536 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
537 | draw_context.drawinfo.end.x = x; |
538 | |
1c736ed5 |
539 | draw_context.drawinfo.y.over = 1; |
540 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
541 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
542 | |
543 | draw_context.drawinfo.start.offset.over = 0; |
544 | draw_context.drawinfo.start.offset.middle = 0; |
545 | draw_context.drawinfo.start.offset.under = 0; |
546 | draw_context.drawinfo.end.offset.over = 0; |
547 | draw_context.drawinfo.end.offset.middle = 0; |
548 | draw_context.drawinfo.end.offset.under = 0; |
549 | |
550 | { |
551 | /* Draw the line */ |
9a1ec01b |
552 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
553 | draw_line((void*)&prop_line, (void*)&draw_context); |
554 | |
555 | } |
556 | /* become the last x position */ |
557 | hashed_process_data->x.middle = x; |
e72908ed |
558 | hashed_process_data->x.middle_used = TRUE; |
559 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
560 | |
561 | /* Calculate the next good time */ |
562 | convert_pixels_to_time(width, x+1, time_window, |
563 | &hashed_process_data->next_good_time); |
e800cf84 |
564 | } |
565 | } |
566 | } |
10a1069a |
567 | } |
e800cf84 |
568 | |
10a1069a |
569 | { |
570 | /* For the pid_in */ |
571 | /* First, check if the current process is in the state computation |
572 | * process list. If it is there, that means we must add it right now and |
573 | * draw items from the beginning of the read for it. If it is not |
574 | * present, it's a new process and it was not present : it will |
575 | * be added after the state update. */ |
576 | LttvProcessState *process; |
577 | process = lttv_state_find_process(tfs, pid_in); |
578 | |
579 | if(process != NULL) { |
580 | /* Well, the process_out existed : we must get it in the process hash |
581 | * or add it, and draw its items. |
582 | */ |
583 | /* Add process to process list (if not present) */ |
1c736ed5 |
584 | guint pl_height = 0; |
10a1069a |
585 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
586 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
587 | LttTime birth = process->creation_time; |
e800cf84 |
588 | |
ac4e21cf |
589 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
590 | pid_in, |
40debf7b |
591 | process->last_cpu_index, |
10a1069a |
592 | &birth, |
ac4e21cf |
593 | tfc->t_context->index); |
594 | if(hashed_process_data == NULL) |
10a1069a |
595 | { |
596 | g_assert(pid_in == 0 || pid_in != process->ppid); |
aac69e70 |
597 | const gchar *name = g_quark_to_string(process->name); |
10a1069a |
598 | /* Process not present */ |
4e86ae2e |
599 | ProcessInfo *process_info; |
1c736ed5 |
600 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
601 | processlist_add(process_list, |
1c736ed5 |
602 | drawing, |
10a1069a |
603 | pid_in, |
40debf7b |
604 | process->last_cpu_index, |
10a1069a |
605 | process->ppid, |
606 | &birth, |
607 | tfc->t_context->index, |
608 | name, |
609 | &pl_height, |
4e86ae2e |
610 | &process_info, |
10a1069a |
611 | &hashed_process_data); |
1c736ed5 |
612 | gtk_widget_set_size_request(drawing->drawing_area, |
613 | -1, |
614 | pl_height); |
615 | gtk_widget_queue_draw(drawing->drawing_area); |
616 | |
10a1069a |
617 | } |
40debf7b |
618 | //We could set the current process and hash here, but will be done |
619 | //by after schedchange hook |
10a1069a |
620 | |
621 | /* Now, the process is in the state hash and our own process hash. |
622 | * We definitely can draw the items related to the ending state. |
623 | */ |
b9a010a2 |
624 | |
b2743953 |
625 | if(ltt_time_compare(hashed_process_data->next_good_time, |
626 | evtime) > 0) |
10a1069a |
627 | { |
b2743953 |
628 | if(hashed_process_data->x.middle_marked == FALSE) { |
ac4e21cf |
629 | |
fd22065b |
630 | TimeWindow time_window = |
631 | lttvwindow_get_time_window(control_flow_data->tab); |
632 | #ifdef EXTRA_CHECK |
633 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
634 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
635 | return; |
636 | #endif //EXTRA_CHECK |
d6fef890 |
637 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
638 | guint width = drawing->width; |
b2743953 |
639 | guint x; |
640 | convert_time_to_pixels( |
641 | time_window, |
642 | evtime, |
643 | width, |
644 | &x); |
645 | |
646 | /* Draw collision indicator */ |
647 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
648 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
649 | drawing->gc, |
650 | x, |
1c736ed5 |
651 | (hashed_process_data->height/2)-3); |
b2743953 |
652 | hashed_process_data->x.middle_marked = TRUE; |
653 | } |
654 | } else { |
fd22065b |
655 | TimeWindow time_window = |
656 | lttvwindow_get_time_window(control_flow_data->tab); |
657 | #ifdef EXTRA_CHECK |
658 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
659 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
660 | return; |
661 | #endif //EXTRA_CHECK |
d6fef890 |
662 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
663 | guint width = drawing->width; |
10a1069a |
664 | guint x; |
10a1069a |
665 | |
666 | convert_time_to_pixels( |
a18124ff |
667 | time_window, |
4b7dc462 |
668 | evtime, |
669 | width, |
670 | &x); |
10a1069a |
671 | |
10a1069a |
672 | |
4b7dc462 |
673 | /* Jump over draw if we are at the same x position */ |
e72908ed |
674 | if(x == hashed_process_data->x.middle && |
675 | hashed_process_data->x.middle_used) |
4b7dc462 |
676 | { |
e72908ed |
677 | if(hashed_process_data->x.middle_marked == FALSE) { |
678 | /* Draw collision indicator */ |
679 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
680 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
681 | drawing->gc, |
682 | x, |
1c736ed5 |
683 | (hashed_process_data->height/2)-3); |
de4ea1ad |
684 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
685 | } |
4b7dc462 |
686 | /* jump */ |
687 | } else { |
688 | DrawContext draw_context; |
10a1069a |
689 | |
4b7dc462 |
690 | /* Now create the drawing context that will be used to draw |
691 | * items related to the last state. */ |
1c736ed5 |
692 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
693 | draw_context.gc = drawing->gc; |
694 | draw_context.pango_layout = drawing->pango_layout; |
695 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
696 | draw_context.drawinfo.end.x = x; |
10a1069a |
697 | |
1c736ed5 |
698 | draw_context.drawinfo.y.over = 1; |
699 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
700 | draw_context.drawinfo.y.under = hashed_process_data->height; |
10a1069a |
701 | |
4b7dc462 |
702 | draw_context.drawinfo.start.offset.over = 0; |
703 | draw_context.drawinfo.start.offset.middle = 0; |
704 | draw_context.drawinfo.start.offset.under = 0; |
705 | draw_context.drawinfo.end.offset.over = 0; |
706 | draw_context.drawinfo.end.offset.middle = 0; |
707 | draw_context.drawinfo.end.offset.under = 0; |
708 | |
709 | { |
710 | /* Draw the line */ |
9a1ec01b |
711 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
712 | draw_line((void*)&prop_line, (void*)&draw_context); |
713 | } |
714 | |
715 | |
716 | /* become the last x position */ |
717 | hashed_process_data->x.middle = x; |
e72908ed |
718 | hashed_process_data->x.middle_used = TRUE; |
719 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
720 | |
721 | /* Calculate the next good time */ |
722 | convert_pixels_to_time(width, x+1, time_window, |
723 | &hashed_process_data->next_good_time); |
4b7dc462 |
724 | } |
c8bba5fa |
725 | } |
b9a010a2 |
726 | } |
727 | } |
b9a010a2 |
728 | return 0; |
729 | |
730 | |
b9a010a2 |
731 | #if 0 |
ca0f8a8e |
732 | EventsRequest *events_request = (EventsRequest*)hook_data; |
733 | ControlFlowData *control_flow_data = |
734 | (ControlFlowData*)events_request->viewer_data; |
735 | Tab *tab = control_flow_data->tab; |
e9a9c513 |
736 | |
a56a1ba4 |
737 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
e9a9c513 |
738 | |
739 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1aff52a2 |
740 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
a56a1ba4 |
741 | |
e9a9c513 |
742 | LttEvent *e; |
e9a9c513 |
743 | e = tfc->e; |
744 | |
9444deae |
745 | LttTime evtime = ltt_event_time(e); |
ca0f8a8e |
746 | TimeWindow time_window = |
747 | lttvwindow_get_time_window(tab); |
9444deae |
748 | |
a2aab3a3 |
749 | LttTime time_window.end_time = time_window.time_window.end_time; |
6f26fc38 |
750 | |
9444deae |
751 | //if(time < time_beg || time > time_end) return; |
ca0f8a8e |
752 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
a2aab3a3 |
753 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
9444deae |
754 | return; |
755 | |
a56a1ba4 |
756 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
757 | { |
2a2fa4f0 |
758 | g_debug("schedchange!"); |
a56a1ba4 |
759 | |
760 | /* Add process to process list (if not present) and get drawing "y" from |
761 | * process position */ |
762 | guint pid_out, pid_in; |
763 | LttvProcessState *process_out, *process_in; |
764 | LttTime birth; |
765 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
766 | |
5c230fc4 |
767 | ProcessList *process_list = control_flow_data->process_list; |
a56a1ba4 |
768 | |
769 | |
770 | LttField *f = ltt_event_field(e); |
771 | LttField *element; |
772 | element = ltt_field_member(f,0); |
773 | pid_out = ltt_event_get_long_unsigned(e,element); |
774 | element = ltt_field_member(f,1); |
775 | pid_in = ltt_event_get_long_unsigned(e,element); |
2a2fa4f0 |
776 | g_debug("out : %u in : %u", pid_out, pid_in); |
a56a1ba4 |
777 | |
778 | |
779 | /* Find process pid_out in the list... */ |
87658614 |
780 | process_out = lttv_state_find_process(tfs, pid_out); |
1aff52a2 |
781 | if(process_out == NULL) return 0; |
2a2fa4f0 |
782 | g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
1aff52a2 |
783 | |
a56a1ba4 |
784 | birth = process_out->creation_time; |
51705146 |
785 | const gchar *name = g_quark_to_string(process_out->name); |
14963be0 |
786 | HashedProcessData *hashed_process_data_out = NULL; |
a56a1ba4 |
787 | |
788 | if(processlist_get_process_pixels(process_list, |
789 | pid_out, |
790 | &birth, |
d0cd7f09 |
791 | tfc->t_context->index, |
a56a1ba4 |
792 | &y_out, |
793 | &height, |
14963be0 |
794 | &hashed_process_data_out) == 1) |
a56a1ba4 |
795 | { |
51705146 |
796 | /* Process not present */ |
797 | processlist_add(process_list, |
798 | pid_out, |
799 | &birth, |
800 | tfc->t_context->index, |
801 | name, |
802 | &pl_height, |
803 | &hashed_process_data_out); |
804 | g_assert(processlist_get_process_pixels(process_list, |
805 | pid_out, |
806 | &birth, |
807 | tfc->t_context->index, |
808 | &y_out, |
809 | &height, |
810 | &hashed_process_data_out)==0); |
811 | drawing_insert_square( control_flow_data->drawing, y_out, height); |
a56a1ba4 |
812 | } |
51705146 |
813 | //g_free(name); |
a56a1ba4 |
814 | |
815 | /* Find process pid_in in the list... */ |
87658614 |
816 | process_in = lttv_state_find_process(tfs, pid_in); |
1aff52a2 |
817 | if(process_in == NULL) return 0; |
2a2fa4f0 |
818 | g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
a56a1ba4 |
819 | |
820 | birth = process_in->creation_time; |
51705146 |
821 | name = g_quark_to_string(process_in->name); |
14963be0 |
822 | HashedProcessData *hashed_process_data_in = NULL; |
a56a1ba4 |
823 | |
824 | if(processlist_get_process_pixels(process_list, |
825 | pid_in, |
826 | &birth, |
d0cd7f09 |
827 | tfc->t_context->index, |
a56a1ba4 |
828 | &y_in, |
829 | &height, |
14963be0 |
830 | &hashed_process_data_in) == 1) |
a56a1ba4 |
831 | { |
51705146 |
832 | /* Process not present */ |
a56a1ba4 |
833 | processlist_add(process_list, |
834 | pid_in, |
835 | &birth, |
d0cd7f09 |
836 | tfc->t_context->index, |
a56a1ba4 |
837 | name, |
838 | &pl_height, |
14963be0 |
839 | &hashed_process_data_in); |
a56a1ba4 |
840 | processlist_get_process_pixels(process_list, |
841 | pid_in, |
842 | &birth, |
d0cd7f09 |
843 | tfc->t_context->index, |
a56a1ba4 |
844 | &y_in, |
845 | &height, |
14963be0 |
846 | &hashed_process_data_in); |
a56a1ba4 |
847 | |
ca0f8a8e |
848 | drawing_insert_square( control_flow_data->drawing, y_in, height); |
a56a1ba4 |
849 | } |
51705146 |
850 | //g_free(name); |
a56a1ba4 |
851 | |
852 | |
853 | /* Find pixels corresponding to time of the event. If the time does |
854 | * not fit in the window, show a warning, not supposed to happend. */ |
855 | guint x = 0; |
51705146 |
856 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
857 | |
858 | LttTime time = ltt_event_time(e); |
859 | |
a2aab3a3 |
860 | LttTime window_end = time_window.time_window.end_time; |
a56a1ba4 |
861 | |
862 | convert_time_to_pixels( |
a18124ff |
863 | time_window, |
a56a1ba4 |
864 | time, |
865 | width, |
866 | &x); |
9444deae |
867 | //assert(x <= width); |
51705146 |
868 | // |
a56a1ba4 |
869 | /* draw what represents the event for outgoing process. */ |
870 | |
14963be0 |
871 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
68997a22 |
872 | draw_context_out->current->modify_over->x = x; |
319e9d81 |
873 | draw_context_out->current->modify_under->x = x; |
68997a22 |
874 | draw_context_out->current->modify_over->y = y_out; |
319e9d81 |
875 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
501d5405 |
876 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
877 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
878 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
879 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
d0cd7f09 |
880 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
881 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
a56a1ba4 |
882 | //draw_context_out->gc = widget->style->black_gc; |
883 | |
884 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
501d5405 |
885 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
a56a1ba4 |
886 | |
d0cd7f09 |
887 | /* Draw the line/background of the out process */ |
888 | if(draw_context_out->previous->middle->x == -1) |
889 | { |
ca0f8a8e |
890 | draw_context_out->previous->over->x = |
891 | control_flow_data->drawing->damage_begin; |
892 | draw_context_out->previous->middle->x = |
893 | control_flow_data->drawing->damage_begin; |
894 | draw_context_out->previous->under->x = |
895 | control_flow_data->drawing->damage_begin; |
ca0f8a8e |
896 | g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin); |
d0cd7f09 |
897 | } |
898 | |
899 | draw_context_out->current->middle->x = x; |
900 | draw_context_out->current->over->x = x; |
901 | draw_context_out->current->under->x = x; |
902 | draw_context_out->current->middle->y = y_out + height/2; |
903 | draw_context_out->current->over->y = y_out; |
904 | draw_context_out->current->under->y = y_out + height; |
905 | draw_context_out->previous->middle->y = y_out + height/2; |
906 | draw_context_out->previous->over->y = y_out; |
907 | draw_context_out->previous->under->y = y_out + height; |
908 | |
909 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
910 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
911 | |
912 | if(process_out->state->s == LTTV_STATE_RUN) |
913 | { |
51705146 |
914 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
915 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
916 | draw_context_out->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
917 | |
918 | PropertiesBG prop_bg; |
919 | prop_bg.color = g_new(GdkColor,1); |
920 | |
921 | switch(tfc->index) { |
922 | case 0: |
923 | prop_bg.color->red = 0x1515; |
924 | prop_bg.color->green = 0x1515; |
925 | prop_bg.color->blue = 0x8c8c; |
926 | break; |
927 | case 1: |
928 | prop_bg.color->red = 0x4e4e; |
929 | prop_bg.color->green = 0xa9a9; |
930 | prop_bg.color->blue = 0xa4a4; |
931 | break; |
932 | case 2: |
933 | prop_bg.color->red = 0x7a7a; |
934 | prop_bg.color->green = 0x4a4a; |
935 | prop_bg.color->blue = 0x8b8b; |
936 | break; |
937 | case 3: |
938 | prop_bg.color->red = 0x8080; |
939 | prop_bg.color->green = 0x7777; |
940 | prop_bg.color->blue = 0x4747; |
941 | break; |
942 | default: |
943 | prop_bg.color->red = 0xe7e7; |
944 | prop_bg.color->green = 0xe7e7; |
945 | prop_bg.color->blue = 0xe7e7; |
946 | } |
947 | |
2a2fa4f0 |
948 | g_debug("calling from draw_event"); |
d0cd7f09 |
949 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
950 | g_free(prop_bg.color); |
51705146 |
951 | //gdk_gc_unref(draw_context_out->gc); |
d0cd7f09 |
952 | } |
953 | |
954 | draw_context_out->gc = widget->style->black_gc; |
955 | |
a56a1ba4 |
956 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
2df6f2bd |
957 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
958 | PropertiesText prop_text_out; |
959 | prop_text_out.foreground = &colorfg_out; |
960 | prop_text_out.background = &colorbg_out; |
cfe526b1 |
961 | prop_text_out.size = 6; |
a56a1ba4 |
962 | prop_text_out.position = OVER; |
963 | |
cfe526b1 |
964 | /* color of text : status of the process */ |
965 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
966 | { |
967 | prop_text_out.foreground->red = 0xffff; |
968 | prop_text_out.foreground->green = 0xffff; |
969 | prop_text_out.foreground->blue = 0xffff; |
970 | } |
971 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
972 | { |
973 | prop_text_out.foreground->red = 0x0fff; |
d52cfc84 |
974 | prop_text_out.foreground->green = 0xffff; |
975 | prop_text_out.foreground->blue = 0xfff0; |
cfe526b1 |
976 | } |
977 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
978 | { |
2df6f2bd |
979 | prop_text_out.foreground->red = 0xffff; |
980 | prop_text_out.foreground->green = 0xffff; |
cfe526b1 |
981 | prop_text_out.foreground->blue = 0x0000; |
982 | } |
0828099d |
983 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
984 | { |
985 | prop_text_out.foreground->red = 0xffff; |
986 | prop_text_out.foreground->green = 0x0000; |
987 | prop_text_out.foreground->blue = 0xffff; |
988 | } |
989 | else if(process_out->state->s == LTTV_STATE_WAIT) |
990 | { |
991 | prop_text_out.foreground->red = 0xffff; |
992 | prop_text_out.foreground->green = 0x0000; |
993 | prop_text_out.foreground->blue = 0x0000; |
994 | } |
995 | else if(process_out->state->s == LTTV_STATE_RUN) |
996 | { |
997 | prop_text_out.foreground->red = 0x0000; |
998 | prop_text_out.foreground->green = 0xffff; |
999 | prop_text_out.foreground->blue = 0x0000; |
1000 | } |
1001 | else |
1002 | { |
1003 | prop_text_out.foreground->red = 0xffff; |
1004 | prop_text_out.foreground->green = 0xffff; |
1005 | prop_text_out.foreground->blue = 0xffff; |
1006 | } |
1007 | |
d52cfc84 |
1008 | |
a56a1ba4 |
1009 | /* Print status of the process : U, WF, WC, E, W, R */ |
1010 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
cfe526b1 |
1011 | prop_text_out.text = "U->"; |
a56a1ba4 |
1012 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
cfe526b1 |
1013 | prop_text_out.text = "WF->"; |
a56a1ba4 |
1014 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
cfe526b1 |
1015 | prop_text_out.text = "WC->"; |
0828099d |
1016 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1017 | prop_text_out.text = "E->"; |
a56a1ba4 |
1018 | else if(process_out->state->s == LTTV_STATE_WAIT) |
cfe526b1 |
1019 | prop_text_out.text = "W->"; |
a56a1ba4 |
1020 | else if(process_out->state->s == LTTV_STATE_RUN) |
cfe526b1 |
1021 | prop_text_out.text = "R->"; |
a56a1ba4 |
1022 | else |
68997a22 |
1023 | prop_text_out.text = "U"; |
a56a1ba4 |
1024 | |
1025 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
d0cd7f09 |
1026 | //gdk_gc_unref(draw_context_out->gc); |
a56a1ba4 |
1027 | |
51705146 |
1028 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1029 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
1030 | draw_context_out->gc = control_flow_data->drawing->gc; |
a56a1ba4 |
1031 | |
1032 | PropertiesLine prop_line_out; |
1033 | prop_line_out.color = g_new(GdkColor,1); |
cfe526b1 |
1034 | prop_line_out.line_width = 2; |
a56a1ba4 |
1035 | prop_line_out.style = GDK_LINE_SOLID; |
1036 | prop_line_out.position = MIDDLE; |
d52cfc84 |
1037 | |
2a2fa4f0 |
1038 | g_debug("out state : %s", g_quark_to_string(process_out->state->s)); |
a56a1ba4 |
1039 | |
1040 | /* color of line : status of the process */ |
1041 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
1042 | { |
cfe526b1 |
1043 | prop_line_out.color->red = 0xffff; |
1044 | prop_line_out.color->green = 0xffff; |
1045 | prop_line_out.color->blue = 0xffff; |
a56a1ba4 |
1046 | } |
1047 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
1048 | { |
1049 | prop_line_out.color->red = 0x0fff; |
d52cfc84 |
1050 | prop_line_out.color->green = 0xffff; |
1051 | prop_line_out.color->blue = 0xfff0; |
a56a1ba4 |
1052 | } |
1053 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
1054 | { |
2df6f2bd |
1055 | prop_line_out.color->red = 0xffff; |
1056 | prop_line_out.color->green = 0xffff; |
a56a1ba4 |
1057 | prop_line_out.color->blue = 0x0000; |
1058 | } |
0828099d |
1059 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
a56a1ba4 |
1060 | { |
1061 | prop_line_out.color->red = 0xffff; |
1062 | prop_line_out.color->green = 0x0000; |
1063 | prop_line_out.color->blue = 0xffff; |
1064 | } |
1065 | else if(process_out->state->s == LTTV_STATE_WAIT) |
1066 | { |
1067 | prop_line_out.color->red = 0xffff; |
1068 | prop_line_out.color->green = 0x0000; |
1069 | prop_line_out.color->blue = 0x0000; |
1070 | } |
1071 | else if(process_out->state->s == LTTV_STATE_RUN) |
1072 | { |
1073 | prop_line_out.color->red = 0x0000; |
1074 | prop_line_out.color->green = 0xffff; |
1075 | prop_line_out.color->blue = 0x0000; |
1076 | } |
1077 | else |
1078 | { |
cfe526b1 |
1079 | prop_line_out.color->red = 0xffff; |
1080 | prop_line_out.color->green = 0xffff; |
1081 | prop_line_out.color->blue = 0xffff; |
a56a1ba4 |
1082 | } |
1083 | |
1084 | draw_line((void*)&prop_line_out, (void*)draw_context_out); |
1085 | g_free(prop_line_out.color); |
51705146 |
1086 | //gdk_gc_unref(draw_context_out->gc); |
a56a1ba4 |
1087 | /* Note : finishing line will have to be added when trace read over. */ |
1088 | |
1089 | /* Finally, update the drawing context of the pid_in. */ |
1090 | |
14963be0 |
1091 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
68997a22 |
1092 | draw_context_in->current->modify_over->x = x; |
319e9d81 |
1093 | draw_context_in->current->modify_under->x = x; |
68997a22 |
1094 | draw_context_in->current->modify_over->y = y_in; |
319e9d81 |
1095 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
501d5405 |
1096 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
1097 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
1098 | widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1099 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
1100 | //draw_context_in->gc = widget->style->black_gc; |
d0cd7f09 |
1101 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1102 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
a56a1ba4 |
1103 | |
1104 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
501d5405 |
1105 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1106 | |
1107 | /* Draw the line/bg of the in process */ |
1108 | if(draw_context_in->previous->middle->x == -1) |
1109 | { |
ca0f8a8e |
1110 | draw_context_in->previous->over->x = |
1111 | control_flow_data->drawing->damage_begin; |
1112 | draw_context_in->previous->middle->x = |
1113 | control_flow_data->drawing->damage_begin; |
1114 | draw_context_in->previous->under->x = |
1115 | control_flow_data->drawing->damage_begin; |
1116 | |
1117 | g_debug("in middle x_beg : %u",control_flow_data->drawing->damage_begin); |
1118 | |
d0cd7f09 |
1119 | } |
1120 | |
1121 | draw_context_in->current->middle->x = x; |
1122 | draw_context_in->current->over->x = x; |
1123 | draw_context_in->current->under->x = x; |
1124 | draw_context_in->current->middle->y = y_in + height/2; |
1125 | draw_context_in->current->over->y = y_in; |
1126 | draw_context_in->current->under->y = y_in + height; |
1127 | draw_context_in->previous->middle->y = y_in + height/2; |
1128 | draw_context_in->previous->over->y = y_in; |
1129 | draw_context_in->previous->under->y = y_in + height; |
a56a1ba4 |
1130 | |
d0cd7f09 |
1131 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
1132 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
1133 | |
1134 | |
1135 | if(process_in->state->s == LTTV_STATE_RUN) |
1136 | { |
51705146 |
1137 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1138 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
1139 | draw_context_in->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
1140 | |
1141 | PropertiesBG prop_bg; |
1142 | prop_bg.color = g_new(GdkColor,1); |
1143 | |
1144 | switch(tfc->index) { |
1145 | case 0: |
1146 | prop_bg.color->red = 0x1515; |
1147 | prop_bg.color->green = 0x1515; |
1148 | prop_bg.color->blue = 0x8c8c; |
1149 | break; |
1150 | case 1: |
1151 | prop_bg.color->red = 0x4e4e; |
1152 | prop_bg.color->green = 0xa9a9; |
1153 | prop_bg.color->blue = 0xa4a4; |
1154 | break; |
1155 | case 2: |
1156 | prop_bg.color->red = 0x7a7a; |
1157 | prop_bg.color->green = 0x4a4a; |
1158 | prop_bg.color->blue = 0x8b8b; |
1159 | break; |
1160 | case 3: |
1161 | prop_bg.color->red = 0x8080; |
1162 | prop_bg.color->green = 0x7777; |
1163 | prop_bg.color->blue = 0x4747; |
1164 | break; |
1165 | default: |
1166 | prop_bg.color->red = 0xe7e7; |
1167 | prop_bg.color->green = 0xe7e7; |
1168 | prop_bg.color->blue = 0xe7e7; |
1169 | } |
1170 | |
1171 | |
1172 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
1173 | g_free(prop_bg.color); |
51705146 |
1174 | //gdk_gc_unref(draw_context_in->gc); |
d0cd7f09 |
1175 | } |
1176 | |
1177 | draw_context_in->gc = widget->style->black_gc; |
1178 | |
a56a1ba4 |
1179 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
2df6f2bd |
1180 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1181 | PropertiesText prop_text_in; |
1182 | prop_text_in.foreground = &colorfg_in; |
1183 | prop_text_in.background = &colorbg_in; |
cfe526b1 |
1184 | prop_text_in.size = 6; |
a56a1ba4 |
1185 | prop_text_in.position = OVER; |
1186 | |
2a2fa4f0 |
1187 | g_debug("in state : %s", g_quark_to_string(process_in->state->s)); |
cfe526b1 |
1188 | /* foreground of text : status of the process */ |
1189 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
1190 | { |
1191 | prop_text_in.foreground->red = 0xffff; |
1192 | prop_text_in.foreground->green = 0xffff; |
1193 | prop_text_in.foreground->blue = 0xffff; |
1194 | } |
1195 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
1196 | { |
1197 | prop_text_in.foreground->red = 0x0fff; |
d52cfc84 |
1198 | prop_text_in.foreground->green = 0xffff; |
1199 | prop_text_in.foreground->blue = 0xfff0; |
cfe526b1 |
1200 | } |
1201 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
1202 | { |
2df6f2bd |
1203 | prop_text_in.foreground->red = 0xffff; |
1204 | prop_text_in.foreground->green = 0xffff; |
cfe526b1 |
1205 | prop_text_in.foreground->blue = 0x0000; |
1206 | } |
0828099d |
1207 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1208 | { |
1209 | prop_text_in.foreground->red = 0xffff; |
1210 | prop_text_in.foreground->green = 0x0000; |
1211 | prop_text_in.foreground->blue = 0xffff; |
1212 | } |
1213 | else if(process_in->state->s == LTTV_STATE_WAIT) |
1214 | { |
1215 | prop_text_in.foreground->red = 0xffff; |
1216 | prop_text_in.foreground->green = 0x0000; |
1217 | prop_text_in.foreground->blue = 0x0000; |
1218 | } |
1219 | else if(process_in->state->s == LTTV_STATE_RUN) |
1220 | { |
1221 | prop_text_in.foreground->red = 0x0000; |
1222 | prop_text_in.foreground->green = 0xffff; |
1223 | prop_text_in.foreground->blue = 0x0000; |
1224 | } |
1225 | else |
1226 | { |
1227 | prop_text_in.foreground->red = 0xffff; |
1228 | prop_text_in.foreground->green = 0xffff; |
1229 | prop_text_in.foreground->blue = 0xffff; |
1230 | } |
1231 | |
1232 | |
1233 | |
a56a1ba4 |
1234 | /* Print status of the process : U, WF, WC, E, W, R */ |
1235 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
cfe526b1 |
1236 | prop_text_in.text = "U->"; |
a56a1ba4 |
1237 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
cfe526b1 |
1238 | prop_text_in.text = "WF->"; |
a56a1ba4 |
1239 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
cfe526b1 |
1240 | prop_text_in.text = "WC->"; |
0828099d |
1241 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1242 | prop_text_in.text = "E->"; |
a56a1ba4 |
1243 | else if(process_in->state->s == LTTV_STATE_WAIT) |
cfe526b1 |
1244 | prop_text_in.text = "W->"; |
a56a1ba4 |
1245 | else if(process_in->state->s == LTTV_STATE_RUN) |
cfe526b1 |
1246 | prop_text_in.text = "R->"; |
a56a1ba4 |
1247 | else |
68997a22 |
1248 | prop_text_in.text = "U"; |
a56a1ba4 |
1249 | |
1250 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
d0cd7f09 |
1251 | //gdk_gc_unref(draw_context_in->gc); |
1252 | |
51705146 |
1253 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1254 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
1255 | draw_context_in->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
1256 | |
a56a1ba4 |
1257 | PropertiesLine prop_line_in; |
1258 | prop_line_in.color = g_new(GdkColor,1); |
cfe526b1 |
1259 | prop_line_in.line_width = 2; |
a56a1ba4 |
1260 | prop_line_in.style = GDK_LINE_SOLID; |
1261 | prop_line_in.position = MIDDLE; |
1262 | |
1263 | /* color of line : status of the process */ |
1264 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
1265 | { |
cfe526b1 |
1266 | prop_line_in.color->red = 0xffff; |
1267 | prop_line_in.color->green = 0xffff; |
1268 | prop_line_in.color->blue = 0xffff; |
a56a1ba4 |
1269 | } |
1270 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
1271 | { |
1272 | prop_line_in.color->red = 0x0fff; |
d52cfc84 |
1273 | prop_line_in.color->green = 0xffff; |
1274 | prop_line_in.color->blue = 0xfff0; |
a56a1ba4 |
1275 | } |
1276 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
1277 | { |
2df6f2bd |
1278 | prop_line_in.color->red = 0xffff; |
1279 | prop_line_in.color->green = 0xffff; |
a56a1ba4 |
1280 | prop_line_in.color->blue = 0x0000; |
1281 | } |
0828099d |
1282 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
a56a1ba4 |
1283 | { |
1284 | prop_line_in.color->red = 0xffff; |
1285 | prop_line_in.color->green = 0x0000; |
1286 | prop_line_in.color->blue = 0xffff; |
1287 | } |
1288 | else if(process_in->state->s == LTTV_STATE_WAIT) |
1289 | { |
1290 | prop_line_in.color->red = 0xffff; |
1291 | prop_line_in.color->green = 0x0000; |
1292 | prop_line_in.color->blue = 0x0000; |
1293 | } |
1294 | else if(process_in->state->s == LTTV_STATE_RUN) |
1295 | { |
1296 | prop_line_in.color->red = 0x0000; |
1297 | prop_line_in.color->green = 0xffff; |
1298 | prop_line_in.color->blue = 0x0000; |
1299 | } |
1300 | else |
1301 | { |
cfe526b1 |
1302 | prop_line_in.color->red = 0xffff; |
1303 | prop_line_in.color->green = 0xffff; |
1304 | prop_line_in.color->blue = 0xffff; |
a56a1ba4 |
1305 | } |
1306 | |
1307 | draw_line((void*)&prop_line_in, (void*)draw_context_in); |
1308 | g_free(prop_line_in.color); |
51705146 |
1309 | //gdk_gc_unref(draw_context_in->gc); |
a56a1ba4 |
1310 | } |
1311 | |
1312 | return 0; |
b9a010a2 |
1313 | #endif //0 |
1314 | |
1315 | |
a56a1ba4 |
1316 | |
51705146 |
1317 | /* Text dump */ |
80a52ff8 |
1318 | #ifdef DONTSHOW |
a56a1ba4 |
1319 | GString *string = g_string_new("");; |
1320 | gboolean field_names = TRUE, state = TRUE; |
80a52ff8 |
1321 | |
e9a9c513 |
1322 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
1323 | g_string_append_printf(string,"\n"); |
1324 | |
1325 | if(state) { |
1326 | g_string_append_printf(string, " %s", |
1327 | g_quark_to_string(tfs->process->state->s)); |
1328 | } |
1329 | |
1330 | g_info("%s",string->str); |
1331 | |
a56a1ba4 |
1332 | g_string_free(string, TRUE); |
1333 | |
1334 | /* End of text dump */ |
80a52ff8 |
1335 | #endif //DONTSHOW |
50439712 |
1336 | |
f0d936c0 |
1337 | } |
1338 | |
e92eabaf |
1339 | /* after_schedchange_hook |
b9a010a2 |
1340 | * |
1341 | * The draw after hook is called by the reading API to have a |
1342 | * particular event drawn on the screen. |
1343 | * @param hook_data ControlFlowData structure of the viewer. |
1344 | * @param call_data Event context. |
1345 | * |
1346 | * This function adds items to be drawn in a queue for each process. |
1347 | * |
1348 | */ |
e92eabaf |
1349 | int after_schedchange_hook(void *hook_data, void *call_data) |
f0d936c0 |
1350 | { |
ca0f8a8e |
1351 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1352 | ControlFlowData *control_flow_data = events_request->viewer_data; |
50439712 |
1353 | |
a56a1ba4 |
1354 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
50439712 |
1355 | |
1356 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1357 | |
b9a010a2 |
1358 | LttEvent *e; |
1359 | e = tfc->e; |
1360 | |
1361 | LttTime evtime = ltt_event_time(e); |
b9a010a2 |
1362 | |
10a1069a |
1363 | /* Add process to process list (if not present) */ |
2eef04b5 |
1364 | LttvProcessState *process_in; |
10a1069a |
1365 | LttTime birth; |
1c736ed5 |
1366 | guint pl_height = 0; |
10a1069a |
1367 | HashedProcessData *hashed_process_data_in = NULL; |
b9a010a2 |
1368 | |
5c230fc4 |
1369 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
1370 | |
1371 | guint pid_in; |
1372 | { |
1373 | guint pid_out; |
1374 | LttField *f = ltt_event_field(e); |
1375 | LttField *element; |
1376 | element = ltt_field_member(f,0); |
1377 | pid_out = ltt_event_get_long_unsigned(e,element); |
1378 | element = ltt_field_member(f,1); |
1379 | pid_in = ltt_event_get_long_unsigned(e,element); |
10a1069a |
1380 | } |
b9a010a2 |
1381 | |
1382 | |
10a1069a |
1383 | /* Find process pid_in in the list... */ |
40debf7b |
1384 | //process_in = lttv_state_find_process(tfs, pid_in); |
1385 | process_in = tfs->process; |
10a1069a |
1386 | /* It should exist, because we are after the state update. */ |
96947fcf |
1387 | #ifdef EXTRA_CHECK |
10a1069a |
1388 | g_assert(process_in != NULL); |
96947fcf |
1389 | #endif //EXTRA_CHECK |
10a1069a |
1390 | birth = process_in->creation_time; |
b9a010a2 |
1391 | |
ac4e21cf |
1392 | hashed_process_data_in = processlist_get_process_data(process_list, |
10a1069a |
1393 | pid_in, |
40debf7b |
1394 | process_in->last_cpu_index, |
10a1069a |
1395 | &birth, |
ac4e21cf |
1396 | tfc->t_context->index); |
1397 | if(hashed_process_data_in == NULL) |
10a1069a |
1398 | { |
1399 | g_assert(pid_in == 0 || pid_in != process_in->ppid); |
aac69e70 |
1400 | const gchar *name = g_quark_to_string(process_in->name); |
4e86ae2e |
1401 | ProcessInfo *process_info; |
1c736ed5 |
1402 | Drawing_t *drawing = control_flow_data->drawing; |
10a1069a |
1403 | /* Process not present */ |
1404 | processlist_add(process_list, |
1c736ed5 |
1405 | drawing, |
10a1069a |
1406 | pid_in, |
40debf7b |
1407 | process_in->last_cpu_index, |
10a1069a |
1408 | process_in->ppid, |
1409 | &birth, |
1410 | tfc->t_context->index, |
1411 | name, |
1412 | &pl_height, |
4e86ae2e |
1413 | &process_info, |
10a1069a |
1414 | &hashed_process_data_in); |
1c736ed5 |
1415 | gtk_widget_set_size_request(drawing->drawing_area, |
1416 | -1, |
1417 | pl_height); |
1418 | gtk_widget_queue_draw(drawing->drawing_area); |
b9a010a2 |
1419 | } |
40debf7b |
1420 | /* Set the current process */ |
1421 | process_list->current_hash_data[process_in->last_cpu_index] = |
1422 | hashed_process_data_in; |
10a1069a |
1423 | |
b2743953 |
1424 | if(ltt_time_compare(hashed_process_data_in->next_good_time, |
1425 | evtime) <= 0) |
1426 | { |
fd22065b |
1427 | TimeWindow time_window = |
1428 | lttvwindow_get_time_window(control_flow_data->tab); |
1429 | |
1430 | #ifdef EXTRA_CHECK |
1431 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1432 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
1433 | return; |
1434 | #endif //EXTRA_CHECK |
d6fef890 |
1435 | Drawing_t *drawing = control_flow_data->drawing; |
1436 | guint width = drawing->width; |
b2743953 |
1437 | guint new_x; |
1438 | |
1439 | convert_time_to_pixels( |
1440 | time_window, |
1441 | evtime, |
1442 | width, |
1443 | &new_x); |
e72908ed |
1444 | |
b2743953 |
1445 | if(hashed_process_data_in->x.middle != new_x) { |
1446 | hashed_process_data_in->x.middle = new_x; |
1447 | hashed_process_data_in->x.middle_used = FALSE; |
1448 | hashed_process_data_in->x.middle_marked = FALSE; |
1449 | } |
1450 | } |
b9a010a2 |
1451 | return 0; |
1452 | |
1453 | |
1454 | |
e72908ed |
1455 | |
1456 | |
b9a010a2 |
1457 | #if 0 |
1458 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1459 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1460 | |
1461 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1462 | |
1463 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1464 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
1465 | |
a56a1ba4 |
1466 | |
50439712 |
1467 | LttEvent *e; |
1468 | e = tfc->e; |
1469 | |
9444deae |
1470 | LttTime evtime = ltt_event_time(e); |
ca0f8a8e |
1471 | TimeWindow time_window = |
1472 | lttvwindow_get_time_window(control_flow_data->tab); |
9444deae |
1473 | |
a2aab3a3 |
1474 | LttTime time_window.end_time = time_window.time_window.end_time; |
6f26fc38 |
1475 | |
9444deae |
1476 | //if(time < time_beg || time > time_end) return; |
ca0f8a8e |
1477 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
a2aab3a3 |
1478 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
9444deae |
1479 | return; |
1480 | |
1481 | |
a56a1ba4 |
1482 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
1483 | { |
2a2fa4f0 |
1484 | g_debug("schedchange!"); |
a56a1ba4 |
1485 | |
1486 | /* Add process to process list (if not present) and get drawing "y" from |
1487 | * process position */ |
1488 | guint pid_out, pid_in; |
1489 | LttvProcessState *process_out, *process_in; |
1490 | LttTime birth; |
1491 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
1492 | |
5c230fc4 |
1493 | ProcessList *process_list = control_flow_data->process_list; |
a56a1ba4 |
1494 | |
1495 | |
1496 | LttField *f = ltt_event_field(e); |
1497 | LttField *element; |
1498 | element = ltt_field_member(f,0); |
1499 | pid_out = ltt_event_get_long_unsigned(e,element); |
1500 | element = ltt_field_member(f,1); |
1501 | pid_in = ltt_event_get_long_unsigned(e,element); |
2a2fa4f0 |
1502 | //g_debug("out : %u in : %u", pid_out, pid_in); |
a56a1ba4 |
1503 | |
1504 | |
1505 | /* Find process pid_out in the list... */ |
2a2fa4f0 |
1506 | process_out = lttv_state_find_process(tfs, pid_out); |
1aff52a2 |
1507 | if(process_out == NULL) return 0; |
2a2fa4f0 |
1508 | //g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
a56a1ba4 |
1509 | |
1510 | birth = process_out->creation_time; |
1511 | gchar *name = strdup(g_quark_to_string(process_out->name)); |
14963be0 |
1512 | HashedProcessData *hashed_process_data_out = NULL; |
a56a1ba4 |
1513 | |
1514 | if(processlist_get_process_pixels(process_list, |
1515 | pid_out, |
1516 | &birth, |
d0cd7f09 |
1517 | tfc->t_context->index, |
a56a1ba4 |
1518 | &y_out, |
1519 | &height, |
14963be0 |
1520 | &hashed_process_data_out) == 1) |
a56a1ba4 |
1521 | { |
51705146 |
1522 | /* Process not present */ |
1523 | processlist_add(process_list, |
1524 | pid_out, |
1525 | &birth, |
1526 | tfc->t_context->index, |
1527 | name, |
1528 | &pl_height, |
1529 | &hashed_process_data_out); |
1530 | processlist_get_process_pixels(process_list, |
1531 | pid_out, |
1532 | &birth, |
1533 | tfc->t_context->index, |
1534 | &y_out, |
1535 | &height, |
1536 | &hashed_process_data_out); |
1537 | drawing_insert_square( control_flow_data->drawing, y_out, height); |
a56a1ba4 |
1538 | } |
1539 | |
1540 | g_free(name); |
1541 | |
1542 | /* Find process pid_in in the list... */ |
2a2fa4f0 |
1543 | process_in = lttv_state_find_process(tfs, pid_in); |
1aff52a2 |
1544 | if(process_in == NULL) return 0; |
2a2fa4f0 |
1545 | //g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
a56a1ba4 |
1546 | |
1547 | birth = process_in->creation_time; |
1548 | name = strdup(g_quark_to_string(process_in->name)); |
14963be0 |
1549 | HashedProcessData *hashed_process_data_in = NULL; |
a56a1ba4 |
1550 | |
1551 | if(processlist_get_process_pixels(process_list, |
1552 | pid_in, |
1553 | &birth, |
d0cd7f09 |
1554 | tfc->t_context->index, |
a56a1ba4 |
1555 | &y_in, |
1556 | &height, |
14963be0 |
1557 | &hashed_process_data_in) == 1) |
a56a1ba4 |
1558 | { |
1559 | /* Process not present */ |
1560 | processlist_add(process_list, |
1561 | pid_in, |
1562 | &birth, |
d0cd7f09 |
1563 | tfc->t_context->index, |
a56a1ba4 |
1564 | name, |
1565 | &pl_height, |
14963be0 |
1566 | &hashed_process_data_in); |
a56a1ba4 |
1567 | processlist_get_process_pixels(process_list, |
1568 | pid_in, |
1569 | &birth, |
d0cd7f09 |
1570 | tfc->t_context->index, |
a56a1ba4 |
1571 | &y_in, |
1572 | &height, |
14963be0 |
1573 | &hashed_process_data_in); |
a56a1ba4 |
1574 | |
ca0f8a8e |
1575 | drawing_insert_square( control_flow_data->drawing, y_in, height); |
a56a1ba4 |
1576 | } |
1577 | g_free(name); |
1578 | |
1579 | |
1580 | /* Find pixels corresponding to time of the event. If the time does |
1581 | * not fit in the window, show a warning, not supposed to happend. */ |
1582 | //guint x = 0; |
501d5405 |
1583 | //guint width = control_flow_data->drawing->drawing_area->allocation.width; |
a56a1ba4 |
1584 | |
1585 | //LttTime time = ltt_event_time(e); |
1586 | |
a2aab3a3 |
1587 | //LttTime window_end = time_window->time_window.end_time; |
a56a1ba4 |
1588 | |
1589 | |
1590 | //convert_time_to_pixels( |
a18124ff |
1591 | // *time_window, |
a56a1ba4 |
1592 | // time, |
1593 | // width, |
1594 | // &x); |
1595 | |
1596 | //assert(x <= width); |
1597 | |
1598 | /* draw what represents the event for outgoing process. */ |
1599 | |
14963be0 |
1600 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
68997a22 |
1601 | //draw_context_out->current->modify_over->x = x; |
1602 | draw_context_out->current->modify_over->y = y_out; |
319e9d81 |
1603 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
501d5405 |
1604 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
1605 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
1606 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1607 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
d0cd7f09 |
1608 | |
a56a1ba4 |
1609 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
501d5405 |
1610 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1611 | |
1612 | /*if(process_out->state->s == LTTV_STATE_RUN) |
1613 | { |
1614 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1615 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
1616 | PropertiesBG prop_bg; |
1617 | prop_bg.color = g_new(GdkColor,1); |
1618 | |
1619 | prop_bg.color->red = 0xffff; |
1620 | prop_bg.color->green = 0xffff; |
1621 | prop_bg.color->blue = 0xffff; |
1622 | |
1623 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
1624 | g_free(prop_bg.color); |
1625 | gdk_gc_unref(draw_context_out->gc); |
1626 | }*/ |
1627 | |
1628 | draw_context_out->gc = widget->style->black_gc; |
1629 | |
a56a1ba4 |
1630 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
2df6f2bd |
1631 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1632 | PropertiesText prop_text_out; |
1633 | prop_text_out.foreground = &colorfg_out; |
1634 | prop_text_out.background = &colorbg_out; |
cfe526b1 |
1635 | prop_text_out.size = 6; |
a56a1ba4 |
1636 | prop_text_out.position = OVER; |
1637 | |
cfe526b1 |
1638 | /* color of text : status of the process */ |
1639 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
1640 | { |
1641 | prop_text_out.foreground->red = 0xffff; |
1642 | prop_text_out.foreground->green = 0xffff; |
1643 | prop_text_out.foreground->blue = 0xffff; |
1644 | } |
1645 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
1646 | { |
1647 | prop_text_out.foreground->red = 0x0fff; |
d52cfc84 |
1648 | prop_text_out.foreground->green = 0xffff; |
1649 | prop_text_out.foreground->blue = 0xfff0; |
cfe526b1 |
1650 | } |
1651 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
1652 | { |
2df6f2bd |
1653 | prop_text_out.foreground->red = 0xffff; |
1654 | prop_text_out.foreground->green = 0xffff; |
cfe526b1 |
1655 | prop_text_out.foreground->blue = 0x0000; |
1656 | } |
0828099d |
1657 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1658 | { |
1659 | prop_text_out.foreground->red = 0xffff; |
1660 | prop_text_out.foreground->green = 0x0000; |
1661 | prop_text_out.foreground->blue = 0xffff; |
1662 | } |
1663 | else if(process_out->state->s == LTTV_STATE_WAIT) |
1664 | { |
1665 | prop_text_out.foreground->red = 0xffff; |
1666 | prop_text_out.foreground->green = 0x0000; |
1667 | prop_text_out.foreground->blue = 0x0000; |
1668 | } |
1669 | else if(process_out->state->s == LTTV_STATE_RUN) |
1670 | { |
1671 | prop_text_out.foreground->red = 0x0000; |
1672 | prop_text_out.foreground->green = 0xffff; |
1673 | prop_text_out.foreground->blue = 0x0000; |
1674 | } |
1675 | else |
1676 | { |
1677 | prop_text_out.foreground->red = 0xffff; |
1678 | prop_text_out.foreground->green = 0xffff; |
1679 | prop_text_out.foreground->blue = 0xffff; |
1680 | } |
1681 | |
a56a1ba4 |
1682 | /* Print status of the process : U, WF, WC, E, W, R */ |
1683 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
68997a22 |
1684 | prop_text_out.text = "U"; |
a56a1ba4 |
1685 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
68997a22 |
1686 | prop_text_out.text = "WF"; |
a56a1ba4 |
1687 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
68997a22 |
1688 | prop_text_out.text = "WC"; |
0828099d |
1689 | else if(process_out->state->s == LTTV_STATE_ZOMBIE) |
68997a22 |
1690 | prop_text_out.text = "E"; |
a56a1ba4 |
1691 | else if(process_out->state->s == LTTV_STATE_WAIT) |
68997a22 |
1692 | prop_text_out.text = "W"; |
a56a1ba4 |
1693 | else if(process_out->state->s == LTTV_STATE_RUN) |
68997a22 |
1694 | prop_text_out.text = "R"; |
a56a1ba4 |
1695 | else |
68997a22 |
1696 | prop_text_out.text = "U"; |
a56a1ba4 |
1697 | |
1698 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
d0cd7f09 |
1699 | |
1700 | //gdk_gc_unref(draw_context_out->gc); |
319e9d81 |
1701 | |
68997a22 |
1702 | draw_context_out->current->middle->y = y_out+height/2; |
d0cd7f09 |
1703 | draw_context_out->current->over->y = y_out; |
1704 | draw_context_out->current->under->y = y_out+height; |
68997a22 |
1705 | draw_context_out->current->status = process_out->state->s; |
a56a1ba4 |
1706 | |
68997a22 |
1707 | /* for pid_out : remove previous, Prev = current, new current (default) */ |
1708 | g_free(draw_context_out->previous->modify_under); |
1709 | g_free(draw_context_out->previous->modify_middle); |
1710 | g_free(draw_context_out->previous->modify_over); |
1711 | g_free(draw_context_out->previous->under); |
1712 | g_free(draw_context_out->previous->middle); |
1713 | g_free(draw_context_out->previous->over); |
1714 | g_free(draw_context_out->previous); |
1715 | |
1716 | draw_context_out->previous = draw_context_out->current; |
a56a1ba4 |
1717 | |
68997a22 |
1718 | draw_context_out->current = g_new(DrawInfo,1); |
1719 | draw_context_out->current->over = g_new(ItemInfo,1); |
1720 | draw_context_out->current->over->x = -1; |
1721 | draw_context_out->current->over->y = -1; |
1722 | draw_context_out->current->middle = g_new(ItemInfo,1); |
1723 | draw_context_out->current->middle->x = -1; |
1724 | draw_context_out->current->middle->y = -1; |
1725 | draw_context_out->current->under = g_new(ItemInfo,1); |
1726 | draw_context_out->current->under->x = -1; |
1727 | draw_context_out->current->under->y = -1; |
1728 | draw_context_out->current->modify_over = g_new(ItemInfo,1); |
1729 | draw_context_out->current->modify_over->x = -1; |
1730 | draw_context_out->current->modify_over->y = -1; |
1731 | draw_context_out->current->modify_middle = g_new(ItemInfo,1); |
1732 | draw_context_out->current->modify_middle->x = -1; |
1733 | draw_context_out->current->modify_middle->y = -1; |
1734 | draw_context_out->current->modify_under = g_new(ItemInfo,1); |
1735 | draw_context_out->current->modify_under->x = -1; |
1736 | draw_context_out->current->modify_under->y = -1; |
1737 | draw_context_out->current->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1738 | |
1739 | /* Finally, update the drawing context of the pid_in. */ |
1740 | |
14963be0 |
1741 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
68997a22 |
1742 | //draw_context_in->current->modify_over->x = x; |
1743 | draw_context_in->current->modify_over->y = y_in; |
319e9d81 |
1744 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
501d5405 |
1745 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
1746 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
1747 | widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1748 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
a56a1ba4 |
1749 | |
1750 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
501d5405 |
1751 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1752 | |
1753 | /*if(process_in->state->s == LTTV_STATE_RUN) |
1754 | { |
1755 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1756 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
1757 | PropertiesBG prop_bg; |
1758 | prop_bg.color = g_new(GdkColor,1); |
1759 | |
1760 | prop_bg.color->red = 0xffff; |
1761 | prop_bg.color->green = 0xffff; |
1762 | prop_bg.color->blue = 0xffff; |
1763 | |
1764 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
1765 | g_free(prop_bg.color); |
1766 | gdk_gc_unref(draw_context_in->gc); |
1767 | }*/ |
1768 | |
1769 | draw_context_in->gc = widget->style->black_gc; |
1770 | |
a56a1ba4 |
1771 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
2df6f2bd |
1772 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1773 | PropertiesText prop_text_in; |
1774 | prop_text_in.foreground = &colorfg_in; |
1775 | prop_text_in.background = &colorbg_in; |
cfe526b1 |
1776 | prop_text_in.size = 6; |
a56a1ba4 |
1777 | prop_text_in.position = OVER; |
1778 | |
cfe526b1 |
1779 | /* foreground of text : status of the process */ |
1780 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
1781 | { |
1782 | prop_text_in.foreground->red = 0xffff; |
1783 | prop_text_in.foreground->green = 0xffff; |
1784 | prop_text_in.foreground->blue = 0xffff; |
1785 | } |
1786 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
1787 | { |
1788 | prop_text_in.foreground->red = 0x0fff; |
d52cfc84 |
1789 | prop_text_in.foreground->green = 0xffff; |
1790 | prop_text_in.foreground->blue = 0xfff0; |
cfe526b1 |
1791 | } |
1792 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
1793 | { |
2df6f2bd |
1794 | prop_text_in.foreground->red = 0xffff; |
1795 | prop_text_in.foreground->green = 0xffff; |
cfe526b1 |
1796 | prop_text_in.foreground->blue = 0x0000; |
1797 | } |
0828099d |
1798 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
cfe526b1 |
1799 | { |
1800 | prop_text_in.foreground->red = 0xffff; |
1801 | prop_text_in.foreground->green = 0x0000; |
1802 | prop_text_in.foreground->blue = 0xffff; |
1803 | } |
1804 | else if(process_in->state->s == LTTV_STATE_WAIT) |
1805 | { |
1806 | prop_text_in.foreground->red = 0xffff; |
1807 | prop_text_in.foreground->green = 0x0000; |
1808 | prop_text_in.foreground->blue = 0x0000; |
1809 | } |
1810 | else if(process_in->state->s == LTTV_STATE_RUN) |
1811 | { |
1812 | prop_text_in.foreground->red = 0x0000; |
1813 | prop_text_in.foreground->green = 0xffff; |
1814 | prop_text_in.foreground->blue = 0x0000; |
1815 | } |
1816 | else |
1817 | { |
1818 | prop_text_in.foreground->red = 0xffff; |
1819 | prop_text_in.foreground->green = 0xffff; |
1820 | prop_text_in.foreground->blue = 0xffff; |
1821 | } |
1822 | |
1823 | |
a56a1ba4 |
1824 | /* Print status of the process : U, WF, WC, E, W, R */ |
1825 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
68997a22 |
1826 | prop_text_in.text = "U"; |
a56a1ba4 |
1827 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
68997a22 |
1828 | prop_text_in.text = "WF"; |
a56a1ba4 |
1829 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
68997a22 |
1830 | prop_text_in.text = "WC"; |
0828099d |
1831 | else if(process_in->state->s == LTTV_STATE_ZOMBIE) |
68997a22 |
1832 | prop_text_in.text = "E"; |
a56a1ba4 |
1833 | else if(process_in->state->s == LTTV_STATE_WAIT) |
68997a22 |
1834 | prop_text_in.text = "W"; |
a56a1ba4 |
1835 | else if(process_in->state->s == LTTV_STATE_RUN) |
68997a22 |
1836 | prop_text_in.text = "R"; |
a56a1ba4 |
1837 | else |
68997a22 |
1838 | prop_text_in.text = "U"; |
a56a1ba4 |
1839 | |
1840 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
1841 | |
d0cd7f09 |
1842 | |
319e9d81 |
1843 | if(process_in->state->s == LTTV_STATE_RUN) |
1844 | { |
1845 | gchar tmp[255]; |
1846 | prop_text_in.foreground = &colorfg_in; |
1847 | prop_text_in.background = &colorbg_in; |
1848 | prop_text_in.foreground->red = 0xffff; |
1849 | prop_text_in.foreground->green = 0xffff; |
1850 | prop_text_in.foreground->blue = 0xffff; |
1851 | prop_text_in.size = 6; |
1852 | prop_text_in.position = UNDER; |
1853 | |
1854 | prop_text_in.text = g_new(gchar, 260); |
1855 | strcpy(prop_text_in.text, "CPU "); |
1856 | snprintf(tmp, 255, "%u", tfc->index); |
1857 | strcat(prop_text_in.text, tmp); |
1858 | |
1859 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
1860 | g_free(prop_text_in.text); |
1861 | } |
1862 | |
1863 | |
68997a22 |
1864 | draw_context_in->current->middle->y = y_in+height/2; |
d0cd7f09 |
1865 | draw_context_in->current->over->y = y_in; |
1866 | draw_context_in->current->under->y = y_in+height; |
68997a22 |
1867 | draw_context_in->current->status = process_in->state->s; |
1868 | |
1869 | /* for pid_in : remove previous, Prev = current, new current (default) */ |
1870 | g_free(draw_context_in->previous->modify_under); |
1871 | g_free(draw_context_in->previous->modify_middle); |
1872 | g_free(draw_context_in->previous->modify_over); |
1873 | g_free(draw_context_in->previous->under); |
1874 | g_free(draw_context_in->previous->middle); |
1875 | g_free(draw_context_in->previous->over); |
1876 | g_free(draw_context_in->previous); |
1877 | |
1878 | draw_context_in->previous = draw_context_in->current; |
a56a1ba4 |
1879 | |
68997a22 |
1880 | draw_context_in->current = g_new(DrawInfo,1); |
1881 | draw_context_in->current->over = g_new(ItemInfo,1); |
1882 | draw_context_in->current->over->x = -1; |
1883 | draw_context_in->current->over->y = -1; |
1884 | draw_context_in->current->middle = g_new(ItemInfo,1); |
1885 | draw_context_in->current->middle->x = -1; |
1886 | draw_context_in->current->middle->y = -1; |
1887 | draw_context_in->current->under = g_new(ItemInfo,1); |
1888 | draw_context_in->current->under->x = -1; |
1889 | draw_context_in->current->under->y = -1; |
1890 | draw_context_in->current->modify_over = g_new(ItemInfo,1); |
1891 | draw_context_in->current->modify_over->x = -1; |
1892 | draw_context_in->current->modify_over->y = -1; |
1893 | draw_context_in->current->modify_middle = g_new(ItemInfo,1); |
1894 | draw_context_in->current->modify_middle->x = -1; |
1895 | draw_context_in->current->modify_middle->y = -1; |
1896 | draw_context_in->current->modify_under = g_new(ItemInfo,1); |
1897 | draw_context_in->current->modify_under->x = -1; |
1898 | draw_context_in->current->modify_under->y = -1; |
1899 | draw_context_in->current->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1900 | |
1901 | } |
1902 | |
1903 | return 0; |
b9a010a2 |
1904 | #endif //0 |
f0d936c0 |
1905 | } |
f7afe191 |
1906 | |
9a1ec01b |
1907 | #if 0 |
6550d711 |
1908 | static inline PropertiesLine prepare_execmode_line(LttvProcessState *process) |
23093869 |
1909 | { |
1910 | PropertiesLine prop_line; |
1911 | prop_line.line_width = 1; |
1912 | prop_line.style = GDK_LINE_SOLID; |
1913 | prop_line.y = OVER; |
1914 | //GdkColormap *colormap = gdk_colormap_get_system(); |
1915 | |
1916 | /* color of line : execution mode of the process */ |
1917 | if(process->state->t == LTTV_STATE_USER_MODE) |
1918 | prop_line.color = drawing_colors[COL_USER_MODE]; |
1919 | else if(process->state->t == LTTV_STATE_SYSCALL) |
1920 | prop_line.color = drawing_colors[COL_SYSCALL]; |
1921 | else if(process->state->t == LTTV_STATE_TRAP) |
1922 | prop_line.color = drawing_colors[COL_TRAP]; |
1923 | else if(process->state->t == LTTV_STATE_IRQ) |
1924 | prop_line.color = drawing_colors[COL_IRQ]; |
1925 | else if(process->state->t == LTTV_STATE_MODE_UNKNOWN) |
1926 | prop_line.color = drawing_colors[COL_MODE_UNKNOWN]; |
1927 | else |
1928 | prop_line.color = drawing_colors[COL_WHITE]; |
1929 | |
1930 | //gdk_colormap_alloc_color(colormap, |
1931 | // prop_line.color, |
1932 | // FALSE, |
1933 | // TRUE); |
1934 | |
1935 | return prop_line; |
1936 | |
1937 | } |
9a1ec01b |
1938 | #endif //0 |
23093869 |
1939 | |
1940 | |
1941 | /* before_execmode_hook |
1942 | * |
1943 | * This function basically draw lines and icons. Two types of lines are drawn : |
1944 | * one small (3 pixels?) representing the state of the process and the second |
1945 | * type is thicker (10 pixels?) representing on which CPU a process is running |
1946 | * (and this only in running state). |
1947 | * |
1948 | * Extremums of the lines : |
1949 | * x_min : time of the last event context for this process kept in memory. |
1950 | * x_max : time of the current event. |
1951 | * y : middle of the process in the process list. The process is found in the |
1952 | * list, therefore is it's position in pixels. |
1953 | * |
1954 | * The choice of lines'color is defined by the context of the last event for this |
1955 | * process. |
1956 | */ |
1957 | |
1958 | |
1959 | int before_execmode_hook(void *hook_data, void *call_data) |
1960 | { |
1961 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1962 | ControlFlowData *control_flow_data = events_request->viewer_data; |
23093869 |
1963 | |
1964 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1965 | |
1966 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
23093869 |
1967 | |
1968 | LttEvent *e; |
1969 | e = tfc->e; |
1970 | |
1971 | LttTime evtime = ltt_event_time(e); |
23093869 |
1972 | |
10a1069a |
1973 | /* we are in a execmode, before the state update. We must draw the |
1974 | * items corresponding to the state before it changes : now is the right |
1975 | * time to do it. |
1976 | */ |
1977 | /* For the pid */ |
1978 | LttvProcessState *process = tfs->process; |
1979 | g_assert(process != NULL); |
23093869 |
1980 | |
10a1069a |
1981 | guint pid = process->pid; |
23093869 |
1982 | |
10a1069a |
1983 | /* Well, the process_out existed : we must get it in the process hash |
1984 | * or add it, and draw its items. |
1985 | */ |
1986 | /* Add process to process list (if not present) */ |
1c736ed5 |
1987 | guint pl_height = 0; |
10a1069a |
1988 | HashedProcessData *hashed_process_data = NULL; |
5c230fc4 |
1989 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
1990 | LttTime birth = process->creation_time; |
40debf7b |
1991 | |
1d1df11d |
1992 | if(likely(process_list->current_hash_data[tfc->index] != NULL)) { |
40debf7b |
1993 | hashed_process_data = process_list->current_hash_data[tfc->index]; |
40debf7b |
1994 | } else { |
ac4e21cf |
1995 | hashed_process_data = processlist_get_process_data(process_list, |
40debf7b |
1996 | pid, |
1997 | process->last_cpu_index, |
1998 | &birth, |
ac4e21cf |
1999 | tfc->t_context->index); |
1d1df11d |
2000 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
2001 | { |
2002 | g_assert(pid == 0 || pid != process->ppid); |
2003 | ProcessInfo *process_info; |
2004 | /* Process not present */ |
1c736ed5 |
2005 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
2006 | const gchar *name = g_quark_to_string(process->name); |
2007 | processlist_add(process_list, |
1c736ed5 |
2008 | drawing, |
40debf7b |
2009 | pid, |
2010 | process->last_cpu_index, |
2011 | process->ppid, |
2012 | &birth, |
2013 | tfc->t_context->index, |
2014 | name, |
2015 | &pl_height, |
2016 | &process_info, |
2017 | &hashed_process_data); |
1c736ed5 |
2018 | gtk_widget_set_size_request(drawing->drawing_area, |
2019 | -1, |
2020 | pl_height); |
2021 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
2022 | } |
2023 | /* Set the current process */ |
2024 | process_list->current_hash_data[process->last_cpu_index] = |
2025 | hashed_process_data; |
10a1069a |
2026 | } |
23093869 |
2027 | |
10a1069a |
2028 | /* Now, the process is in the state hash and our own process hash. |
2029 | * We definitely can draw the items related to the ending state. |
2030 | */ |
b2743953 |
2031 | |
1d1df11d |
2032 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
2033 | evtime) > 0)) |
10a1069a |
2034 | { |
1d1df11d |
2035 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
fd22065b |
2036 | TimeWindow time_window = |
2037 | lttvwindow_get_time_window(control_flow_data->tab); |
2038 | |
2039 | #ifdef EXTRA_CHECK |
2040 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2041 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2042 | return; |
2043 | #endif //EXTRA_CHECK |
d6fef890 |
2044 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2045 | guint width = drawing->width; |
b2743953 |
2046 | guint x; |
2047 | convert_time_to_pixels( |
2048 | time_window, |
2049 | evtime, |
2050 | width, |
2051 | &x); |
2052 | |
2053 | /* Draw collision indicator */ |
2054 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
2055 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
2056 | drawing->gc, |
2057 | x, |
1c736ed5 |
2058 | (hashed_process_data->height/2)-3); |
b2743953 |
2059 | hashed_process_data->x.middle_marked = TRUE; |
2060 | } |
2061 | } else { |
fd22065b |
2062 | TimeWindow time_window = |
2063 | lttvwindow_get_time_window(control_flow_data->tab); |
2064 | |
2065 | #ifdef EXTRA_CHECK |
2066 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2067 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2068 | return; |
2069 | #endif //EXTRA_CHECK |
d6fef890 |
2070 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2071 | guint width = drawing->width; |
10a1069a |
2072 | guint x; |
dbd243b1 |
2073 | |
10a1069a |
2074 | convert_time_to_pixels( |
a18124ff |
2075 | time_window, |
10a1069a |
2076 | evtime, |
2077 | width, |
2078 | &x); |
dbd243b1 |
2079 | |
23093869 |
2080 | |
4b7dc462 |
2081 | /* Jump over draw if we are at the same x position */ |
1d1df11d |
2082 | if(unlikely(x == hashed_process_data->x.middle && |
2083 | hashed_process_data->x.middle_used)) |
10a1069a |
2084 | { |
1d1df11d |
2085 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
e72908ed |
2086 | /* Draw collision indicator */ |
2087 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
2088 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
2089 | drawing->gc, |
2090 | x, |
1c736ed5 |
2091 | (hashed_process_data->height/2)-3); |
de4ea1ad |
2092 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
2093 | } |
4b7dc462 |
2094 | /* jump */ |
2095 | } else { |
2096 | |
2097 | DrawContext draw_context; |
2098 | /* Now create the drawing context that will be used to draw |
2099 | * items related to the last state. */ |
1c736ed5 |
2100 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
2101 | draw_context.gc = drawing->gc; |
2102 | draw_context.pango_layout = drawing->pango_layout; |
9a1ec01b |
2103 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
4b7dc462 |
2104 | draw_context.drawinfo.end.x = x; |
2105 | |
1c736ed5 |
2106 | draw_context.drawinfo.y.over = 1; |
2107 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2108 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
2109 | |
2110 | draw_context.drawinfo.start.offset.over = 0; |
2111 | draw_context.drawinfo.start.offset.middle = 0; |
2112 | draw_context.drawinfo.start.offset.under = 0; |
2113 | draw_context.drawinfo.end.offset.over = 0; |
2114 | draw_context.drawinfo.end.offset.middle = 0; |
2115 | draw_context.drawinfo.end.offset.under = 0; |
2116 | |
2117 | { |
2118 | /* Draw the line */ |
9a1ec01b |
2119 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
2120 | draw_line((void*)&prop_line, (void*)&draw_context); |
23093869 |
2121 | |
4b7dc462 |
2122 | } |
2123 | /* become the last x position */ |
9a1ec01b |
2124 | hashed_process_data->x.middle = x; |
e72908ed |
2125 | hashed_process_data->x.middle_used = TRUE; |
2126 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
2127 | |
2128 | /* Calculate the next good time */ |
2129 | convert_pixels_to_time(width, x+1, time_window, |
2130 | &hashed_process_data->next_good_time); |
23093869 |
2131 | } |
2132 | } |
2133 | |
2134 | return 0; |
2135 | } |
2136 | |
2137 | /* after_execmode_hook |
2138 | * |
2139 | * The draw after hook is called by the reading API to have a |
2140 | * particular event drawn on the screen. |
2141 | * @param hook_data ControlFlowData structure of the viewer. |
2142 | * @param call_data Event context. |
2143 | * |
2144 | * This function adds items to be drawn in a queue for each process. |
2145 | * |
2146 | */ |
2147 | int after_execmode_hook(void *hook_data, void *call_data) |
2148 | { |
8869ac08 |
2149 | /**************** DOES NOTHING!! *************/ |
2150 | /* hook desactivated in drawing.c */ |
2151 | return 0; |
2152 | |
2153 | |
2154 | |
23093869 |
2155 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2156 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2157 | |
2158 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
2159 | |
2160 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
23093869 |
2161 | |
2162 | LttEvent *e; |
2163 | e = tfc->e; |
2164 | |
2165 | LttTime evtime = ltt_event_time(e); |
23093869 |
2166 | |
10a1069a |
2167 | /* Add process to process list (if not present) */ |
2168 | LttvProcessState *process; |
2169 | LttTime birth; |
1c736ed5 |
2170 | guint pl_height = 0; |
10a1069a |
2171 | HashedProcessData *hashed_process_data = NULL; |
23093869 |
2172 | |
5c230fc4 |
2173 | ProcessList *process_list = control_flow_data->process_list; |
23093869 |
2174 | |
10a1069a |
2175 | /* Find process pid_in in the list... */ |
2176 | process = tfs->process; |
2177 | /* It should exist, because we are after the state update. */ |
2178 | g_assert(process != NULL); |
23093869 |
2179 | |
10a1069a |
2180 | guint pid = process->pid; |
23093869 |
2181 | |
10a1069a |
2182 | birth = process->creation_time; |
23093869 |
2183 | |
1d1df11d |
2184 | if(likely(process_list->current_hash_data[tfc->index] != NULL)) { |
40debf7b |
2185 | hashed_process_data = process_list->current_hash_data[tfc->index]; |
40debf7b |
2186 | } else { |
ac4e21cf |
2187 | hashed_process_data = processlist_get_process_data(process_list, |
40debf7b |
2188 | pid, |
2189 | process->last_cpu_index, |
2190 | &birth, |
ac4e21cf |
2191 | tfc->t_context->index); |
1d1df11d |
2192 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
2193 | { |
2194 | g_assert(pid == 0 || pid != process->ppid); |
2195 | /* Process not present */ |
1c736ed5 |
2196 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
2197 | const gchar *name = g_quark_to_string(process->name); |
2198 | ProcessInfo *process_info; |
2199 | processlist_add(process_list, |
1c736ed5 |
2200 | drawing, |
40debf7b |
2201 | pid, |
2202 | process->last_cpu_index, |
2203 | process->ppid, |
2204 | &birth, |
2205 | tfc->t_context->index, |
2206 | name, |
2207 | &pl_height, |
2208 | &process_info, |
2209 | &hashed_process_data); |
1c736ed5 |
2210 | gtk_widget_set_size_request(drawing->drawing_area, |
2211 | -1, |
2212 | pl_height); |
2213 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
2214 | } |
2215 | /* Set the current process */ |
2216 | process_list->current_hash_data[process->last_cpu_index] = |
2217 | hashed_process_data; |
23093869 |
2218 | } |
40debf7b |
2219 | |
1d1df11d |
2220 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
2221 | evtime) <= 0)) |
b2743953 |
2222 | { |
fd22065b |
2223 | TimeWindow time_window = |
2224 | lttvwindow_get_time_window(control_flow_data->tab); |
2225 | |
2226 | #ifdef EXTRA_CHECK |
2227 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2228 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2229 | return; |
2230 | #endif //EXTRA_CHECK |
d6fef890 |
2231 | Drawing_t *drawing = control_flow_data->drawing; |
2232 | guint width = drawing->width; |
b2743953 |
2233 | guint new_x; |
2234 | |
2235 | convert_time_to_pixels( |
2236 | time_window, |
2237 | evtime, |
2238 | width, |
2239 | &new_x); |
e72908ed |
2240 | |
b2743953 |
2241 | if(hashed_process_data->x.middle != new_x) { |
2242 | hashed_process_data->x.middle = new_x; |
2243 | hashed_process_data->x.middle_used = FALSE; |
2244 | hashed_process_data->x.middle_marked = FALSE; |
2245 | } |
2246 | } |
23093869 |
2247 | return 0; |
2248 | } |
2249 | |
2250 | |
dbd243b1 |
2251 | |
2252 | /* before_process_hook |
2253 | * |
2254 | * Draw lines for process event. |
2255 | * |
2256 | * @param hook_data ControlFlowData structure of the viewer. |
2257 | * @param call_data Event context. |
2258 | * |
2259 | * This function adds items to be drawn in a queue for each process. |
2260 | * |
2261 | */ |
2262 | int before_process_hook(void *hook_data, void *call_data) |
2263 | { |
2264 | EventsRequest *events_request = (EventsRequest*)hook_data; |
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; |
2272 | e = tfc->e; |
2273 | |
2274 | LttTime evtime = ltt_event_time(e); |
dbd243b1 |
2275 | |
10a1069a |
2276 | guint sub_id; |
2277 | { |
2278 | LttField *f = ltt_event_field(e); |
2279 | LttField *element; |
2280 | element = ltt_field_member(f,0); |
2281 | sub_id = ltt_event_get_long_unsigned(e,element); |
2282 | } |
dbd243b1 |
2283 | |
10a1069a |
2284 | if(sub_id == 3) { /* exit */ |
dbd243b1 |
2285 | |
10a1069a |
2286 | /* Add process to process list (if not present) */ |
2287 | LttvProcessState *process = tfs->process; |
2288 | guint pid = process->pid; |
2289 | LttTime birth; |
1c736ed5 |
2290 | guint pl_height = 0; |
10a1069a |
2291 | HashedProcessData *hashed_process_data = NULL; |
dbd243b1 |
2292 | |
5c230fc4 |
2293 | ProcessList *process_list = control_flow_data->process_list; |
10a1069a |
2294 | |
2295 | g_assert(process != NULL); |
dbd243b1 |
2296 | |
10a1069a |
2297 | birth = process->creation_time; |
dbd243b1 |
2298 | |
1d1df11d |
2299 | if(likely(process_list->current_hash_data[tfc->index] != NULL)) { |
40debf7b |
2300 | hashed_process_data = process_list->current_hash_data[tfc->index]; |
ac4e21cf |
2301 | } else { |
2302 | hashed_process_data = processlist_get_process_data(process_list, |
10a1069a |
2303 | pid, |
40debf7b |
2304 | process->last_cpu_index, |
10a1069a |
2305 | &birth, |
ac4e21cf |
2306 | tfc->t_context->index); |
1d1df11d |
2307 | if(unlikely(hashed_process_data == NULL)) |
ac4e21cf |
2308 | { |
2309 | g_assert(pid == 0 || pid != process->ppid); |
2310 | /* Process not present */ |
1c736ed5 |
2311 | Drawing_t *drawing = control_flow_data->drawing; |
ac4e21cf |
2312 | const gchar *name = g_quark_to_string(process->name); |
2313 | ProcessInfo *process_info; |
2314 | processlist_add(process_list, |
1c736ed5 |
2315 | drawing, |
ac4e21cf |
2316 | pid, |
2317 | process->last_cpu_index, |
2318 | process->ppid, |
2319 | &birth, |
10a1069a |
2320 | tfc->t_context->index, |
ac4e21cf |
2321 | name, |
2322 | &pl_height, |
2323 | &process_info, |
2324 | &hashed_process_data); |
1c736ed5 |
2325 | gtk_widget_set_size_request(drawing->drawing_area, |
2326 | -1, |
2327 | pl_height); |
2328 | gtk_widget_queue_draw(drawing->drawing_area); |
ac4e21cf |
2329 | } |
10a1069a |
2330 | } |
dbd243b1 |
2331 | |
10a1069a |
2332 | /* Now, the process is in the state hash and our own process hash. |
2333 | * We definitely can draw the items related to the ending state. |
2334 | */ |
2335 | |
1d1df11d |
2336 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
2337 | evtime) > 0)) |
10a1069a |
2338 | { |
1d1df11d |
2339 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
fd22065b |
2340 | TimeWindow time_window = |
2341 | lttvwindow_get_time_window(control_flow_data->tab); |
2342 | |
2343 | #ifdef EXTRA_CHECK |
2344 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2345 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2346 | return; |
2347 | #endif //EXTRA_CHECK |
d6fef890 |
2348 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2349 | guint width = drawing->width; |
b2743953 |
2350 | guint x; |
2351 | convert_time_to_pixels( |
2352 | time_window, |
2353 | evtime, |
2354 | width, |
2355 | &x); |
2356 | |
2357 | /* Draw collision indicator */ |
2358 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
2359 | gdk_draw_point(hashed_process_data->pixmap, |
b2743953 |
2360 | drawing->gc, |
2361 | x, |
1c736ed5 |
2362 | (hashed_process_data->height/2)-3); |
b2743953 |
2363 | hashed_process_data->x.middle_marked = TRUE; |
2364 | } |
2365 | } else { |
ac4e21cf |
2366 | TimeWindow time_window = |
2367 | lttvwindow_get_time_window(control_flow_data->tab); |
fd22065b |
2368 | |
2369 | #ifdef EXTRA_CHECK |
ac4e21cf |
2370 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2371 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2372 | return; |
fd22065b |
2373 | #endif //EXTRA_CHECK |
d6fef890 |
2374 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2375 | guint width = drawing->width; |
10a1069a |
2376 | guint x; |
dbd243b1 |
2377 | |
10a1069a |
2378 | convert_time_to_pixels( |
a18124ff |
2379 | time_window, |
10a1069a |
2380 | evtime, |
2381 | width, |
2382 | &x); |
dbd243b1 |
2383 | |
dbd243b1 |
2384 | |
4b7dc462 |
2385 | /* Jump over draw if we are at the same x position */ |
1d1df11d |
2386 | if(unlikely(x == hashed_process_data->x.middle && |
2387 | hashed_process_data->x.middle_used)) |
e72908ed |
2388 | { |
1d1df11d |
2389 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
e72908ed |
2390 | /* Draw collision indicator */ |
2391 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
1c736ed5 |
2392 | gdk_draw_point(hashed_process_data->pixmap, |
e72908ed |
2393 | drawing->gc, |
2394 | x, |
1c736ed5 |
2395 | (hashed_process_data->height/2)-3); |
de4ea1ad |
2396 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
2397 | } |
4b7dc462 |
2398 | /* jump */ |
2399 | } else { |
2400 | DrawContext draw_context; |
dbd243b1 |
2401 | |
4b7dc462 |
2402 | /* Now create the drawing context that will be used to draw |
2403 | * items related to the last state. */ |
1c736ed5 |
2404 | draw_context.drawable = hashed_process_data->pixmap; |
4b7dc462 |
2405 | draw_context.gc = drawing->gc; |
2406 | draw_context.pango_layout = drawing->pango_layout; |
2407 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
2408 | draw_context.drawinfo.end.x = x; |
dbd243b1 |
2409 | |
1c736ed5 |
2410 | draw_context.drawinfo.y.over = 1; |
2411 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2412 | draw_context.drawinfo.y.under = hashed_process_data->height; |
4b7dc462 |
2413 | |
2414 | draw_context.drawinfo.start.offset.over = 0; |
2415 | draw_context.drawinfo.start.offset.middle = 0; |
2416 | draw_context.drawinfo.start.offset.under = 0; |
2417 | draw_context.drawinfo.end.offset.over = 0; |
2418 | draw_context.drawinfo.end.offset.middle = 0; |
2419 | draw_context.drawinfo.end.offset.under = 0; |
dbd243b1 |
2420 | |
4b7dc462 |
2421 | { |
2422 | /* Draw the line */ |
9a1ec01b |
2423 | PropertiesLine prop_line = prepare_s_e_line(process); |
4b7dc462 |
2424 | draw_line((void*)&prop_line, (void*)&draw_context); |
2425 | |
2426 | } |
2427 | /* become the last x position */ |
2428 | hashed_process_data->x.middle = x; |
e72908ed |
2429 | hashed_process_data->x.middle_used = TRUE; |
2430 | hashed_process_data->x.middle_marked = FALSE; |
b2743953 |
2431 | |
2432 | /* Calculate the next good time */ |
2433 | convert_pixels_to_time(width, x+1, time_window, |
2434 | &hashed_process_data->next_good_time); |
dbd243b1 |
2435 | } |
dbd243b1 |
2436 | } |
2437 | |
2da61677 |
2438 | } else if(sub_id == 7) /* release */ { |
2439 | |
2440 | guint pid; |
2441 | { |
2442 | LttField *f = ltt_event_field(e); |
2443 | LttField *element; |
2444 | element = ltt_field_member(f,1); |
2445 | pid = ltt_event_get_long_unsigned(e,element); |
2446 | } |
2447 | |
2448 | /* Add process to process list (if not present) */ |
2449 | /* Don't care about the process if it's not in the state hash already : |
2450 | * that means a process that has never done anything in the trace and |
2451 | * unknown suddently gets destroyed : no state meaningful to show. */ |
2452 | LttvProcessState *process = lttv_state_find_process(tfs, pid); |
2453 | |
2454 | if(process != NULL) { |
2455 | LttTime birth; |
2456 | guint pl_height = 0; |
2457 | HashedProcessData *hashed_process_data = NULL; |
2458 | |
2459 | ProcessList *process_list = control_flow_data->process_list; |
2460 | |
2461 | birth = process->creation_time; |
2462 | |
2463 | /* Cannot use current process : this event happens on another process, |
2464 | * action done by the parent. */ |
2465 | hashed_process_data = processlist_get_process_data(process_list, |
2466 | pid, |
2467 | process->last_cpu_index, |
2468 | &birth, |
2469 | tfc->t_context->index); |
2470 | if(unlikely(hashed_process_data == NULL)) |
2471 | { |
2472 | g_assert(pid == 0 || pid != process->ppid); |
2473 | /* Process not present */ |
2474 | Drawing_t *drawing = control_flow_data->drawing; |
2475 | const gchar *name = g_quark_to_string(process->name); |
2476 | ProcessInfo *process_info; |
2477 | processlist_add(process_list, |
2478 | drawing, |
2479 | pid, |
2480 | process->last_cpu_index, |
2481 | process->ppid, |
2482 | &birth, |
2483 | tfc->t_context->index, |
2484 | name, |
2485 | &pl_height, |
2486 | &process_info, |
2487 | &hashed_process_data); |
2488 | gtk_widget_set_size_request(drawing->drawing_area, |
2489 | -1, |
2490 | pl_height); |
2491 | gtk_widget_queue_draw(drawing->drawing_area); |
2492 | } |
2493 | |
2494 | /* Now, the process is in the state hash and our own process hash. |
2495 | * We definitely can draw the items related to the ending state. |
2496 | */ |
2497 | |
2498 | if(likely(ltt_time_compare(hashed_process_data->next_good_time, |
2499 | evtime) > 0)) |
2500 | { |
2501 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2502 | TimeWindow time_window = |
2503 | lttvwindow_get_time_window(control_flow_data->tab); |
2504 | |
2505 | #ifdef EXTRA_CHECK |
2506 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2507 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2508 | return; |
2509 | #endif //EXTRA_CHECK |
2510 | Drawing_t *drawing = control_flow_data->drawing; |
2511 | guint width = drawing->width; |
2512 | guint x; |
2513 | convert_time_to_pixels( |
2514 | time_window, |
2515 | evtime, |
2516 | width, |
2517 | &x); |
2518 | |
2519 | /* Draw collision indicator */ |
2520 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2521 | gdk_draw_point(hashed_process_data->pixmap, |
2522 | drawing->gc, |
2523 | x, |
2524 | (hashed_process_data->height/2)-3); |
2525 | hashed_process_data->x.middle_marked = TRUE; |
2526 | } |
2527 | } else { |
2528 | TimeWindow time_window = |
2529 | lttvwindow_get_time_window(control_flow_data->tab); |
2530 | |
2531 | #ifdef EXTRA_CHECK |
2532 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2533 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2534 | return; |
2535 | #endif //EXTRA_CHECK |
2536 | Drawing_t *drawing = control_flow_data->drawing; |
2537 | guint width = drawing->width; |
2538 | guint x; |
2539 | |
2540 | convert_time_to_pixels( |
2541 | time_window, |
2542 | evtime, |
2543 | width, |
2544 | &x); |
2545 | |
2546 | |
2547 | /* Jump over draw if we are at the same x position */ |
2548 | if(unlikely(x == hashed_process_data->x.middle && |
2549 | hashed_process_data->x.middle_used)) |
2550 | { |
2551 | if(unlikely(hashed_process_data->x.middle_marked == FALSE)) { |
2552 | /* Draw collision indicator */ |
2553 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
2554 | gdk_draw_point(hashed_process_data->pixmap, |
2555 | drawing->gc, |
2556 | x, |
2557 | (hashed_process_data->height/2)-3); |
2558 | hashed_process_data->x.middle_marked = TRUE; |
2559 | } |
2560 | /* jump */ |
2561 | } else { |
2562 | DrawContext draw_context; |
2563 | |
2564 | /* Now create the drawing context that will be used to draw |
2565 | * items related to the last state. */ |
2566 | draw_context.drawable = hashed_process_data->pixmap; |
2567 | draw_context.gc = drawing->gc; |
2568 | draw_context.pango_layout = drawing->pango_layout; |
2569 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
2570 | draw_context.drawinfo.end.x = x; |
2571 | |
2572 | draw_context.drawinfo.y.over = 1; |
2573 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
2574 | draw_context.drawinfo.y.under = hashed_process_data->height; |
2575 | |
2576 | draw_context.drawinfo.start.offset.over = 0; |
2577 | draw_context.drawinfo.start.offset.middle = 0; |
2578 | draw_context.drawinfo.start.offset.under = 0; |
2579 | draw_context.drawinfo.end.offset.over = 0; |
2580 | draw_context.drawinfo.end.offset.middle = 0; |
2581 | draw_context.drawinfo.end.offset.under = 0; |
2582 | |
2583 | { |
2584 | /* Draw the line */ |
2585 | PropertiesLine prop_line = prepare_s_e_line(process); |
2586 | draw_line((void*)&prop_line, (void*)&draw_context); |
2587 | |
2588 | } |
2589 | /* become the last x position */ |
2590 | hashed_process_data->x.middle = x; |
2591 | hashed_process_data->x.middle_used = TRUE; |
2592 | hashed_process_data->x.middle_marked = FALSE; |
2593 | |
2594 | /* Calculate the next good time */ |
2595 | convert_pixels_to_time(width, x+1, time_window, |
2596 | &hashed_process_data->next_good_time); |
2597 | } |
2598 | } |
2599 | } |
2600 | |
dbd243b1 |
2601 | } |
2602 | return 0; |
2603 | |
2604 | } |
2605 | |
2606 | |
2607 | |
2608 | |
2609 | |
2610 | |
2611 | /* after_process_hook |
e92eabaf |
2612 | * |
2613 | * Create the processlist entry for the child process. Put the last |
2614 | * position in x at the current time value. |
2615 | * |
2616 | * @param hook_data ControlFlowData structure of the viewer. |
2617 | * @param call_data Event context. |
2618 | * |
2619 | * This function adds items to be drawn in a queue for each process. |
2620 | * |
2621 | */ |
dbd243b1 |
2622 | int after_process_hook(void *hook_data, void *call_data) |
e92eabaf |
2623 | { |
2624 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2625 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2626 | |
2627 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
2628 | |
2629 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
e92eabaf |
2630 | |
2631 | LttEvent *e; |
2632 | e = tfc->e; |
2633 | |
2634 | LttTime evtime = ltt_event_time(e); |
e92eabaf |
2635 | |
10a1069a |
2636 | guint sub_id; |
2637 | guint param1; |
2638 | { |
2639 | LttField *f = ltt_event_field(e); |
2640 | LttField *element; |
2641 | element = ltt_field_member(f,0); |
2642 | sub_id = ltt_event_get_long_unsigned(e,element); |
2643 | element = ltt_field_member(f,1); |
2644 | param1 = ltt_event_get_long_unsigned(e,element); |
2645 | } |
e92eabaf |
2646 | |
10a1069a |
2647 | if(sub_id == 2) { /* fork */ |
2648 | |
2649 | guint child_pid = param1; |
2650 | /* Add process to process list (if not present) */ |
2651 | LttvProcessState *process_child; |
2652 | LttTime birth; |
1c736ed5 |
2653 | guint pl_height = 0; |
10a1069a |
2654 | HashedProcessData *hashed_process_data_child = NULL; |
e92eabaf |
2655 | |
5c230fc4 |
2656 | ProcessList *process_list = control_flow_data->process_list; |
e92eabaf |
2657 | |
10a1069a |
2658 | /* Find child in the list... */ |
2659 | process_child = lttv_state_find_process(tfs, child_pid); |
2660 | /* It should exist, because we are after the state update. */ |
2661 | g_assert(process_child != NULL); |
e92eabaf |
2662 | |
10a1069a |
2663 | birth = process_child->creation_time; |
e92eabaf |
2664 | |
2da61677 |
2665 | /* Cannot use current process, because this action is done by the parent |
2666 | * on its child. */ |
ac4e21cf |
2667 | hashed_process_data_child = processlist_get_process_data(process_list, |
10a1069a |
2668 | child_pid, |
40debf7b |
2669 | process_child->last_cpu_index, |
10a1069a |
2670 | &birth, |
ac4e21cf |
2671 | tfc->t_context->index); |
1d1df11d |
2672 | if(likely(hashed_process_data_child == NULL)) |
10a1069a |
2673 | { |
2674 | g_assert(child_pid == 0 || child_pid != process_child->ppid); |
2675 | /* Process not present */ |
1c736ed5 |
2676 | Drawing_t *drawing = control_flow_data->drawing; |
aac69e70 |
2677 | const gchar *name = g_quark_to_string(process_child->name); |
4e86ae2e |
2678 | ProcessInfo *process_info; |
10a1069a |
2679 | processlist_add(process_list, |
1c736ed5 |
2680 | drawing, |
10a1069a |
2681 | child_pid, |
40debf7b |
2682 | process_child->last_cpu_index, |
10a1069a |
2683 | process_child->ppid, |
2684 | &birth, |
2685 | tfc->t_context->index, |
2686 | name, |
2687 | &pl_height, |
4e86ae2e |
2688 | &process_info, |
10a1069a |
2689 | &hashed_process_data_child); |
1c736ed5 |
2690 | gtk_widget_set_size_request(drawing->drawing_area, |
2691 | -1, |
2692 | pl_height); |
2693 | gtk_widget_queue_draw(drawing->drawing_area); |
10a1069a |
2694 | } |
e92eabaf |
2695 | |
40debf7b |
2696 | |
1d1df11d |
2697 | if(likely(ltt_time_compare(hashed_process_data_child->next_good_time, |
2698 | evtime) <= 0)) |
b2743953 |
2699 | { |
fd22065b |
2700 | TimeWindow time_window = |
2701 | lttvwindow_get_time_window(control_flow_data->tab); |
2702 | |
2703 | #ifdef EXTRA_CHECK |
2704 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2705 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2706 | return; |
2707 | #endif //EXTRA_CHECK |
d6fef890 |
2708 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2709 | guint width = drawing->width; |
b2743953 |
2710 | guint new_x; |
2711 | convert_time_to_pixels( |
2712 | time_window, |
2713 | evtime, |
2714 | width, |
2715 | &new_x); |
e72908ed |
2716 | |
1d1df11d |
2717 | if(likely(hashed_process_data_child->x.over != new_x)) { |
b2743953 |
2718 | hashed_process_data_child->x.over = new_x; |
2719 | hashed_process_data_child->x.over_used = FALSE; |
2720 | hashed_process_data_child->x.over_marked = FALSE; |
2721 | } |
1d1df11d |
2722 | if(likely(hashed_process_data_child->x.middle != new_x)) { |
b2743953 |
2723 | hashed_process_data_child->x.middle = new_x; |
2724 | hashed_process_data_child->x.middle_used = FALSE; |
2725 | hashed_process_data_child->x.middle_marked = FALSE; |
2726 | } |
1d1df11d |
2727 | if(likely(hashed_process_data_child->x.under != new_x)) { |
b2743953 |
2728 | hashed_process_data_child->x.under = new_x; |
2729 | hashed_process_data_child->x.under_used = FALSE; |
2730 | hashed_process_data_child->x.under_marked = FALSE; |
2731 | } |
e72908ed |
2732 | } |
23093869 |
2733 | |
10a1069a |
2734 | } else if(sub_id == 3) { /* exit */ |
dbd243b1 |
2735 | |
10a1069a |
2736 | /* Add process to process list (if not present) */ |
2737 | LttvProcessState *process = tfs->process; |
2738 | guint pid = process->pid; |
2739 | LttTime birth; |
1c736ed5 |
2740 | guint pl_height = 0; |
10a1069a |
2741 | HashedProcessData *hashed_process_data = NULL; |
dbd243b1 |
2742 | |
5c230fc4 |
2743 | ProcessList *process_list = control_flow_data->process_list; |
dbd243b1 |
2744 | |
10a1069a |
2745 | /* It should exist, because we are after the state update. */ |
2746 | g_assert(process != NULL); |
dbd243b1 |
2747 | |
10a1069a |
2748 | birth = process->creation_time; |
dbd243b1 |
2749 | |
1d1df11d |
2750 | if(likely(process_list->current_hash_data[tfc->index] != NULL) ){ |
40debf7b |
2751 | hashed_process_data = process_list->current_hash_data[tfc->index]; |
40debf7b |
2752 | } else { |
ac4e21cf |
2753 | hashed_process_data = processlist_get_process_data(process_list, |
40debf7b |
2754 | pid, |
2755 | process->last_cpu_index, |
2756 | &birth, |
ac4e21cf |
2757 | tfc->t_context->index); |
1d1df11d |
2758 | if(unlikely(hashed_process_data == NULL)) |
40debf7b |
2759 | { |
2760 | g_assert(pid == 0 || pid != process->ppid); |
2761 | /* Process not present */ |
1c736ed5 |
2762 | Drawing_t *drawing = control_flow_data->drawing; |
40debf7b |
2763 | const gchar *name = g_quark_to_string(process->name); |
2764 | ProcessInfo *process_info; |
2765 | processlist_add(process_list, |
1c736ed5 |
2766 | drawing, |
40debf7b |
2767 | pid, |
2768 | process->last_cpu_index, |
2769 | process->ppid, |
2770 | &birth, |
2771 | tfc->t_context->index, |
2772 | name, |
2773 | &pl_height, |
2774 | &process_info, |
2775 | &hashed_process_data); |
1c736ed5 |
2776 | gtk_widget_set_size_request(drawing->drawing_area, |
2777 | -1, |
2778 | pl_height); |
2779 | gtk_widget_queue_draw(drawing->drawing_area); |
40debf7b |
2780 | } |
2781 | |
2782 | /* Set the current process */ |
2783 | process_list->current_hash_data[process->last_cpu_index] = |
2784 | hashed_process_data; |
e92eabaf |
2785 | } |
dbd243b1 |
2786 | |
1d1df11d |
2787 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
2788 | evtime) <= 0)) |
b2743953 |
2789 | { |
fd22065b |
2790 | TimeWindow time_window = |
2791 | lttvwindow_get_time_window(control_flow_data->tab); |
2792 | |
2793 | #ifdef EXTRA_CHECK |
2794 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
2795 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
2796 | return; |
2797 | #endif //EXTRA_CHECK |
d6fef890 |
2798 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
2799 | guint width = drawing->width; |
b2743953 |
2800 | guint new_x; |
2801 | convert_time_to_pixels( |
2802 | time_window, |
2803 | evtime, |
2804 | width, |
2805 | &new_x); |
1d1df11d |
2806 | if(unlikely(hashed_process_data->x.middle != new_x)) { |
b2743953 |
2807 | hashed_process_data->x.middle = new_x; |
2808 | hashed_process_data->x.middle_used = FALSE; |
2809 | hashed_process_data->x.middle_marked = FALSE; |
2810 | } |
e72908ed |
2811 | } |
2812 | |
e92eabaf |
2813 | } |
2814 | return 0; |
2815 | |
2816 | } |
f7afe191 |
2817 | |
2818 | |
1b238973 |
2819 | gint update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
2820 | { |
a56a1ba4 |
2821 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
a43d67ba |
2822 | Drawing_t *drawing = control_flow_data->drawing; |
1c736ed5 |
2823 | ProcessList *process_list = control_flow_data->process_list; |
a43d67ba |
2824 | |
224446ce |
2825 | const TimeWindowNotifyData *time_window_nofify_data = |
2826 | ((const TimeWindowNotifyData *)call_data); |
2827 | |
14963be0 |
2828 | TimeWindow *old_time_window = |
224446ce |
2829 | time_window_nofify_data->old_time_window; |
2830 | TimeWindow *new_time_window = |
2831 | time_window_nofify_data->new_time_window; |
a56a1ba4 |
2832 | |
3cb8b205 |
2833 | /* Update the ruler */ |
2834 | drawing_update_ruler(control_flow_data->drawing, |
2835 | new_time_window); |
2836 | |
2837 | |
a56a1ba4 |
2838 | /* Two cases : zoom in/out or scrolling */ |
2839 | |
2840 | /* In order to make sure we can reuse the old drawing, the scale must |
2841 | * be the same and the new time interval being partly located in the |
2842 | * currently shown time interval. (reuse is only for scrolling) |
2843 | */ |
2844 | |
2eef04b5 |
2845 | g_info("Old time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 |
2846 | old_time_window->start_time.tv_sec, |
2847 | old_time_window->start_time.tv_nsec, |
2848 | old_time_window->time_width.tv_sec, |
2849 | old_time_window->time_width.tv_nsec); |
a56a1ba4 |
2850 | |
2eef04b5 |
2851 | g_info("New time window HOOK : %lu, %lu to %lu, %lu", |
14963be0 |
2852 | new_time_window->start_time.tv_sec, |
2853 | new_time_window->start_time.tv_nsec, |
2854 | new_time_window->time_width.tv_sec, |
2855 | new_time_window->time_width.tv_nsec); |
a56a1ba4 |
2856 | |
14963be0 |
2857 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
2858 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) |
a56a1ba4 |
2859 | { |
2860 | /* Same scale (scrolling) */ |
2861 | g_info("scrolling"); |
14963be0 |
2862 | LttTime *ns = &new_time_window->start_time; |
20640e70 |
2863 | LttTime *nw = &new_time_window->time_width; |
14963be0 |
2864 | LttTime *os = &old_time_window->start_time; |
20640e70 |
2865 | LttTime *ow = &old_time_window->time_width; |
6f26fc38 |
2866 | LttTime old_end = old_time_window->end_time; |
2867 | LttTime new_end = new_time_window->end_time; |
a56a1ba4 |
2868 | //if(ns<os+w<ns+w) |
2869 | //if(ns<os+w && os+w<ns+w) |
2870 | //if(ns<old_end && os<ns) |
2871 | if(ltt_time_compare(*ns, old_end) == -1 |
2872 | && ltt_time_compare(*os, *ns) == -1) |
2873 | { |
2874 | g_info("scrolling near right"); |
2875 | /* Scroll right, keep right part of the screen */ |
2876 | guint x = 0; |
51705146 |
2877 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
2878 | convert_time_to_pixels( |
a18124ff |
2879 | *old_time_window, |
a56a1ba4 |
2880 | *ns, |
2881 | width, |
2882 | &x); |
2883 | |
2884 | /* Copy old data to new location */ |
1c736ed5 |
2885 | copy_pixmap_region(process_list, |
2886 | NULL, |
2887 | control_flow_data->drawing->drawing_area->style->black_gc, |
2888 | NULL, |
2889 | x, 0, |
2890 | 0, 0, |
2891 | control_flow_data->drawing->width-x+SAFETY, -1); |
2892 | |
6395d57c |
2893 | if(drawing->damage_begin == drawing->damage_end) |
2894 | drawing->damage_begin = control_flow_data->drawing->width-x; |
2895 | else |
2896 | drawing->damage_begin = 0; |
2897 | |
2898 | drawing->damage_end = control_flow_data->drawing->width; |
2899 | |
a56a1ba4 |
2900 | /* Clear the data request background, but not SAFETY */ |
1c736ed5 |
2901 | rectangle_pixmap(process_list, |
cfe526b1 |
2902 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
2903 | TRUE, |
6395d57c |
2904 | drawing->damage_begin+SAFETY, 0, |
2905 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1c736ed5 |
2906 | -1); |
7abb23ad |
2907 | gtk_widget_queue_draw(drawing->drawing_area); |
2908 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2909 | // 0,0, |
2910 | // control_flow_data->drawing->width, |
2911 | // control_flow_data->drawing->height); |
a43d67ba |
2912 | |
a56a1ba4 |
2913 | /* Get new data for the rest. */ |
501d5405 |
2914 | drawing_data_request(control_flow_data->drawing, |
6395d57c |
2915 | drawing->damage_begin, 0, |
2916 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
2917 | control_flow_data->drawing->height); |
a56a1ba4 |
2918 | } else { |
2919 | //if(ns<os<ns+w) |
2920 | //if(ns<os && os<ns+w) |
2921 | //if(ns<os && os<new_end) |
2922 | if(ltt_time_compare(*ns,*os) == -1 |
2923 | && ltt_time_compare(*os,new_end) == -1) |
2924 | { |
2925 | g_info("scrolling near left"); |
2926 | /* Scroll left, keep left part of the screen */ |
2927 | guint x = 0; |
51705146 |
2928 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
2929 | convert_time_to_pixels( |
a18124ff |
2930 | *new_time_window, |
a56a1ba4 |
2931 | *os, |
2932 | width, |
2933 | &x); |
6395d57c |
2934 | |
a56a1ba4 |
2935 | /* Copy old data to new location */ |
1c736ed5 |
2936 | copy_pixmap_region (process_list, |
2937 | NULL, |
cfe526b1 |
2938 | control_flow_data->drawing->drawing_area->style->black_gc, |
1c736ed5 |
2939 | NULL, |
a56a1ba4 |
2940 | 0, 0, |
2941 | x, 0, |
2942 | -1, -1); |
2943 | |
6395d57c |
2944 | if(drawing->damage_begin == drawing->damage_end) |
2945 | drawing->damage_end = x; |
2946 | else |
2947 | drawing->damage_end = |
51705146 |
2948 | control_flow_data->drawing->width; |
6395d57c |
2949 | |
2950 | drawing->damage_begin = 0; |
2951 | |
1c736ed5 |
2952 | rectangle_pixmap (process_list, |
cfe526b1 |
2953 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
2954 | TRUE, |
6395d57c |
2955 | drawing->damage_begin, 0, |
2956 | drawing->damage_end - drawing->damage_begin, // do not overlap |
1c736ed5 |
2957 | -1); |
a43d67ba |
2958 | |
7abb23ad |
2959 | gtk_widget_queue_draw(drawing->drawing_area); |
2960 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2961 | // 0,0, |
2962 | // control_flow_data->drawing->width, |
2963 | // control_flow_data->drawing->height); |
a43d67ba |
2964 | |
6395d57c |
2965 | |
a56a1ba4 |
2966 | /* Get new data for the rest. */ |
501d5405 |
2967 | drawing_data_request(control_flow_data->drawing, |
6395d57c |
2968 | drawing->damage_begin, 0, |
2969 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
2970 | control_flow_data->drawing->height); |
a56a1ba4 |
2971 | |
a56a1ba4 |
2972 | } else { |
a43d67ba |
2973 | if(ltt_time_compare(*ns,*os) == 0) |
2974 | { |
2975 | g_info("not scrolling"); |
2976 | } else { |
2977 | g_info("scrolling far"); |
2978 | /* Cannot reuse any part of the screen : far jump */ |
2979 | |
2980 | |
1c736ed5 |
2981 | rectangle_pixmap (process_list, |
a43d67ba |
2982 | control_flow_data->drawing->drawing_area->style->black_gc, |
2983 | TRUE, |
a56a1ba4 |
2984 | 0, 0, |
a43d67ba |
2985 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 |
2986 | -1); |
a43d67ba |
2987 | |
7abb23ad |
2988 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
2989 | // 0,0, |
2990 | // control_flow_data->drawing->width, |
2991 | // control_flow_data->drawing->height); |
2992 | gtk_widget_queue_draw(drawing->drawing_area); |
a43d67ba |
2993 | |
6395d57c |
2994 | drawing->damage_begin = 0; |
2995 | drawing->damage_end = control_flow_data->drawing->width; |
2996 | |
a43d67ba |
2997 | drawing_data_request(control_flow_data->drawing, |
a43d67ba |
2998 | 0, 0, |
2999 | control_flow_data->drawing->width, |
3000 | control_flow_data->drawing->height); |
3001 | |
3002 | } |
a56a1ba4 |
3003 | } |
3004 | } |
3005 | } else { |
3006 | /* Different scale (zoom) */ |
3007 | g_info("zoom"); |
3008 | |
1c736ed5 |
3009 | rectangle_pixmap (process_list, |
cfe526b1 |
3010 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
3011 | TRUE, |
3012 | 0, 0, |
501d5405 |
3013 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1c736ed5 |
3014 | -1); |
a56a1ba4 |
3015 | |
7abb23ad |
3016 | //gtk_widget_queue_draw_area (drawing->drawing_area, |
3017 | // 0,0, |
3018 | // control_flow_data->drawing->width, |
3019 | // control_flow_data->drawing->height); |
3020 | gtk_widget_queue_draw(drawing->drawing_area); |
a56a1ba4 |
3021 | |
6395d57c |
3022 | drawing->damage_begin = 0; |
3023 | drawing->damage_end = control_flow_data->drawing->width; |
3024 | |
501d5405 |
3025 | drawing_data_request(control_flow_data->drawing, |
a56a1ba4 |
3026 | 0, 0, |
501d5405 |
3027 | control_flow_data->drawing->width, |
3028 | control_flow_data->drawing->height); |
a56a1ba4 |
3029 | } |
3030 | |
3cb8b205 |
3031 | |
3032 | |
a56a1ba4 |
3033 | return 0; |
f7afe191 |
3034 | } |
3035 | |
6395d57c |
3036 | gint traceset_notify(void *hook_data, void *call_data) |
3037 | { |
3038 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
3039 | Drawing_t *drawing = control_flow_data->drawing; |
6395d57c |
3040 | |
6395d57c |
3041 | |
b9a010a2 |
3042 | drawing_clear(control_flow_data->drawing); |
3043 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
3044 | gtk_widget_set_size_request( |
3045 | control_flow_data->drawing->drawing_area, |
3046 | -1, processlist_get_height(control_flow_data->process_list)); |
d9267eec |
3047 | redraw_notify(control_flow_data, NULL); |
6395d57c |
3048 | |
d9267eec |
3049 | request_background_data(control_flow_data); |
6395d57c |
3050 | |
3051 | return FALSE; |
3052 | } |
3053 | |
ca0f8a8e |
3054 | gint redraw_notify(void *hook_data, void *call_data) |
3055 | { |
3056 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
3057 | Drawing_t *drawing = control_flow_data->drawing; |
3058 | GtkWidget *widget = drawing->drawing_area; |
3059 | |
3060 | drawing->damage_begin = 0; |
51705146 |
3061 | drawing->damage_end = drawing->width; |
ca0f8a8e |
3062 | |
49217bd4 |
3063 | /* fun feature, to be separated someday... */ |
3064 | drawing_clear(control_flow_data->drawing); |
3065 | processlist_clear(control_flow_data->process_list); |
07390ec1 |
3066 | gtk_widget_set_size_request( |
3067 | control_flow_data->drawing->drawing_area, |
3068 | -1, processlist_get_height(control_flow_data->process_list)); |
1c736ed5 |
3069 | // Clear the images |
3070 | rectangle_pixmap (control_flow_data->process_list, |
ca0f8a8e |
3071 | widget->style->black_gc, |
3072 | TRUE, |
3073 | 0, 0, |
f3b7430d |
3074 | drawing->alloc_width, |
1c736ed5 |
3075 | -1); |
ca0f8a8e |
3076 | |
f3b7430d |
3077 | gtk_widget_queue_draw(drawing->drawing_area); |
ca0f8a8e |
3078 | |
3079 | if(drawing->damage_begin < drawing->damage_end) |
3080 | { |
3081 | drawing_data_request(drawing, |
ca0f8a8e |
3082 | drawing->damage_begin, |
3083 | 0, |
3084 | drawing->damage_end-drawing->damage_begin, |
51705146 |
3085 | drawing->height); |
ca0f8a8e |
3086 | } |
3087 | |
7abb23ad |
3088 | //gtk_widget_queue_draw_area(drawing->drawing_area, |
3089 | // 0,0, |
3090 | // drawing->width, |
3091 | // drawing->height); |
ca0f8a8e |
3092 | return FALSE; |
3093 | |
3094 | } |
3095 | |
3096 | |
3097 | gint continue_notify(void *hook_data, void *call_data) |
a43d67ba |
3098 | { |
3099 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
ca0f8a8e |
3100 | Drawing_t *drawing = control_flow_data->drawing; |
a43d67ba |
3101 | |
6395d57c |
3102 | //g_assert(widget->allocation.width == drawing->damage_end); |
ca0f8a8e |
3103 | |
3104 | if(drawing->damage_begin < drawing->damage_end) |
3105 | { |
3106 | drawing_data_request(drawing, |
ca0f8a8e |
3107 | drawing->damage_begin, |
3108 | 0, |
3109 | drawing->damage_end-drawing->damage_begin, |
51705146 |
3110 | drawing->height); |
ca0f8a8e |
3111 | } |
3112 | |
3113 | return FALSE; |
3114 | } |
3115 | |
3116 | |
1b238973 |
3117 | gint update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
3118 | { |
14963be0 |
3119 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
a43d67ba |
3120 | Drawing_t *drawing = control_flow_data->drawing; |
a56a1ba4 |
3121 | |
224446ce |
3122 | LttTime current_time = *((LttTime*)call_data); |
a56a1ba4 |
3123 | |
ca0f8a8e |
3124 | TimeWindow time_window = |
3125 | lttvwindow_get_time_window(control_flow_data->tab); |
a56a1ba4 |
3126 | |
ca0f8a8e |
3127 | LttTime time_begin = time_window.start_time; |
3128 | LttTime width = time_window.time_width; |
90ef7e4a |
3129 | LttTime half_width; |
3130 | { |
3131 | guint64 time_ll = ltt_time_to_uint64(width); |
3132 | time_ll = time_ll >> 1; /* divide by two */ |
3133 | half_width = ltt_time_from_uint64(time_ll); |
3134 | } |
a56a1ba4 |
3135 | LttTime time_end = ltt_time_add(time_begin, width); |
3136 | |
3137 | LttvTracesetContext * tsc = |
ca0f8a8e |
3138 | lttvwindow_get_traceset_context(control_flow_data->tab); |
a56a1ba4 |
3139 | |
ca0f8a8e |
3140 | LttTime trace_start = tsc->time_span.start_time; |
3141 | LttTime trace_end = tsc->time_span.end_time; |
a56a1ba4 |
3142 | |
2eef04b5 |
3143 | g_info("New current time HOOK : %lu, %lu", current_time.tv_sec, |
224446ce |
3144 | current_time.tv_nsec); |
a56a1ba4 |
3145 | |
3146 | |
3147 | |
3148 | /* If current time is inside time interval, just move the highlight |
3149 | * bar */ |
3150 | |
3151 | /* Else, we have to change the time interval. We have to tell it |
3152 | * to the main window. */ |
3153 | /* The time interval change will take care of placing the current |
3154 | * time at the center of the visible area, or nearest possible if we are |
3155 | * at one end of the trace. */ |
3156 | |
3157 | |
dbc0ef8a |
3158 | if(ltt_time_compare(current_time, time_begin) < 0) |
a56a1ba4 |
3159 | { |
224446ce |
3160 | TimeWindow new_time_window; |
3161 | |
3162 | if(ltt_time_compare(current_time, |
dbc0ef8a |
3163 | ltt_time_add(trace_start,half_width)) < 0) |
a56a1ba4 |
3164 | time_begin = trace_start; |
3165 | else |
224446ce |
3166 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
3167 | |
224446ce |
3168 | new_time_window.start_time = time_begin; |
3169 | new_time_window.time_width = width; |
a18124ff |
3170 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 |
3171 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 |
3172 | |
e800cf84 |
3173 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 |
3174 | } |
dbc0ef8a |
3175 | else if(ltt_time_compare(current_time, time_end) > 0) |
a56a1ba4 |
3176 | { |
224446ce |
3177 | TimeWindow new_time_window; |
3178 | |
dbc0ef8a |
3179 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) > 0) |
a56a1ba4 |
3180 | time_begin = ltt_time_sub(trace_end,width); |
3181 | else |
224446ce |
3182 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
3183 | |
224446ce |
3184 | new_time_window.start_time = time_begin; |
3185 | new_time_window.time_width = width; |
a18124ff |
3186 | new_time_window.time_width_double = ltt_time_to_double(width); |
6f26fc38 |
3187 | new_time_window.end_time = ltt_time_add(time_begin, width); |
a56a1ba4 |
3188 | |
e800cf84 |
3189 | lttvwindow_report_time_window(control_flow_data->tab, new_time_window); |
a56a1ba4 |
3190 | |
3191 | } |
7abb23ad |
3192 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
3193 | |
a56a1ba4 |
3194 | |
3195 | return 0; |
f7afe191 |
3196 | } |
3197 | |
8b90e648 |
3198 | typedef struct _ClosureData { |
ca0f8a8e |
3199 | EventsRequest *events_request; |
d0cd7f09 |
3200 | LttvTracesetState *tss; |
b9a010a2 |
3201 | LttTime end_time; |
bc8d270b |
3202 | guint x_end; |
8b90e648 |
3203 | } ClosureData; |
a56a1ba4 |
3204 | |
8b90e648 |
3205 | |
e800cf84 |
3206 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
3207 | { |
a56a1ba4 |
3208 | ProcessInfo *process_info = (ProcessInfo*)key; |
3209 | HashedProcessData *hashed_process_data = (HashedProcessData*)value; |
3210 | ClosureData *closure_data = (ClosureData*)user_data; |
3211 | |
e800cf84 |
3212 | EventsRequest *events_request = closure_data->events_request; |
3213 | ControlFlowData *control_flow_data = events_request->viewer_data; |
a56a1ba4 |
3214 | |
e800cf84 |
3215 | LttvTracesetState *tss = closure_data->tss; |
d6fef890 |
3216 | LttvTracesetContext *tsc = (LttvTracesetContext*)tss; |
a56a1ba4 |
3217 | |
e800cf84 |
3218 | LttTime evtime = closure_data->end_time; |
d0cd7f09 |
3219 | |
e800cf84 |
3220 | { |
3221 | /* For the process */ |
3222 | /* First, check if the current process is in the state computation |
3223 | * process list. If it is there, that means we must add it right now and |
3224 | * draw items from the beginning of the read for it. If it is not |
3225 | * present, it's a new process and it was not present : it will |
3226 | * be added after the state update. */ |
31b6868d |
3227 | #ifdef EXTRA_CHECK |
e800cf84 |
3228 | g_assert(lttv_traceset_number(tsc->ts) > 0); |
31b6868d |
3229 | #endif //EXTRA_CHECK |
a56a1ba4 |
3230 | |
2da61677 |
3231 | LttvTracefileState *tfs = |
3232 | (LttvTracefileState*)tsc->traces[process_info->trace_num]-> |
3233 | tracefiles[process_info->cpu]; |
3234 | |
e800cf84 |
3235 | LttvProcessState *process; |
e025a729 |
3236 | process = lttv_state_find_process(tfs, |
3237 | process_info->pid); |
a56a1ba4 |
3238 | |
1d1df11d |
3239 | if(unlikely(process != NULL)) { |
e800cf84 |
3240 | |
3241 | /* Only draw for processes that are currently in the trace states */ |
ad2e83ba |
3242 | |
5c230fc4 |
3243 | ProcessList *process_list = control_flow_data->process_list; |
1d1df11d |
3244 | #ifdef EXTRA_CHECK |
e800cf84 |
3245 | /* Should be alike when background info is ready */ |
3246 | if(control_flow_data->background_info_waiting==0) |
3247 | g_assert(ltt_time_compare(process->creation_time, |
3248 | process_info->birth) == 0); |
1d1df11d |
3249 | #endif //EXTRA_CHECK |
e800cf84 |
3250 | |
3251 | /* Now, the process is in the state hash and our own process hash. |
3252 | * We definitely can draw the items related to the ending state. |
3253 | */ |
3254 | |
1d1df11d |
3255 | if(unlikely(ltt_time_compare(hashed_process_data->next_good_time, |
3256 | evtime) <= 0)) |
e800cf84 |
3257 | { |
fd22065b |
3258 | TimeWindow time_window = |
3259 | lttvwindow_get_time_window(control_flow_data->tab); |
3260 | |
3261 | #ifdef EXTRA_CHECK |
3262 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
3263 | || ltt_time_compare(evtime, time_window.end_time) == 1) |
3264 | return; |
3265 | #endif //EXTRA_CHECK |
d6fef890 |
3266 | Drawing_t *drawing = control_flow_data->drawing; |
96947fcf |
3267 | guint width = drawing->width; |
a56a1ba4 |
3268 | |
bc8d270b |
3269 | guint x = closure_data->x_end; |
8b90e648 |
3270 | |
4b7dc462 |
3271 | DrawContext draw_context; |
3272 | |
e800cf84 |
3273 | /* Now create the drawing context that will be used to draw |
3274 | * items related to the last state. */ |
1c736ed5 |
3275 | draw_context.drawable = hashed_process_data->pixmap; |
e800cf84 |
3276 | draw_context.gc = drawing->gc; |
3277 | draw_context.pango_layout = drawing->pango_layout; |
e800cf84 |
3278 | draw_context.drawinfo.end.x = x; |
3279 | |
1c736ed5 |
3280 | draw_context.drawinfo.y.over = 1; |
3281 | draw_context.drawinfo.y.middle = (hashed_process_data->height/2); |
3282 | draw_context.drawinfo.y.under = hashed_process_data->height; |
e800cf84 |
3283 | |
3284 | draw_context.drawinfo.start.offset.over = 0; |
3285 | draw_context.drawinfo.start.offset.middle = 0; |
3286 | draw_context.drawinfo.start.offset.under = 0; |
3287 | draw_context.drawinfo.end.offset.over = 0; |
3288 | draw_context.drawinfo.end.offset.middle = 0; |
3289 | draw_context.drawinfo.end.offset.under = 0; |
9a1ec01b |
3290 | #if 0 |
4b7dc462 |
3291 | /* Jump over draw if we are at the same x position */ |
3292 | if(x == hashed_process_data->x.over) |
e800cf84 |
3293 | { |
4b7dc462 |
3294 | /* jump */ |
3295 | } else { |
23093869 |
3296 | draw_context.drawinfo.start.x = hashed_process_data->x.over; |
3297 | /* Draw the line */ |
3298 | PropertiesLine prop_line = prepare_execmode_line(process); |
3299 | draw_line((void*)&prop_line, (void*)&draw_context); |
3300 | |
4b7dc462 |
3301 | hashed_process_data->x.over = x; |
23093869 |
3302 | } |
9a1ec01b |
3303 | #endif //0 |
4b7dc462 |
3304 | |
1d1df11d |
3305 | if(unlikely(x == hashed_process_data->x.middle && |
3306 | hashed_process_data->x.middle_used)) { |
b2743953 |
3307 | #if 0 /* do not mark closure : not missing information */ |
e72908ed |
3308 | if(hashed_process_data->x.middle_marked == FALSE) { |
3309 | /* Draw collision indicator */ |
3310 | gdk_gc_set_foreground(drawing->gc, &drawing_colors[COL_WHITE]); |
3311 | gdk_draw_point(drawing->pixmap, |
3312 | drawing->gc, |
3313 | x, |
2c6618bc |
3314 | y+(height/2)-3); |
de4ea1ad |
3315 | hashed_process_data->x.middle_marked = TRUE; |
e72908ed |
3316 | } |
b2743953 |
3317 | #endif //0 |
4b7dc462 |
3318 | /* Jump */ |
3319 | } else { |
23093869 |
3320 | draw_context.drawinfo.start.x = hashed_process_data->x.middle; |
e800cf84 |
3321 | /* Draw the line */ |
9a1ec01b |
3322 | PropertiesLine prop_line = prepare_s_e_line(process); |
e800cf84 |
3323 | draw_line((void*)&prop_line, (void*)&draw_context); |
3324 | |
4b7dc462 |
3325 | /* become the last x position */ |
1d1df11d |
3326 | if(likely(x != hashed_process_data->x.middle)) { |
e72908ed |
3327 | hashed_process_data->x.middle = x; |
3328 | /* but don't use the pixel */ |
3329 | hashed_process_data->x.middle_used = FALSE; |
b2743953 |
3330 | |
3331 | /* Calculate the next good time */ |
3332 | convert_pixels_to_time(width, x+1, time_window, |
3333 | &hashed_process_data->next_good_time); |
e72908ed |
3334 | } |
e800cf84 |
3335 | } |
e800cf84 |
3336 | } |
3337 | } |
3338 | } |
3339 | return; |
8b90e648 |
3340 | } |
3341 | |
b9a010a2 |
3342 | int before_chunk(void *hook_data, void *call_data) |
3343 | { |
3344 | EventsRequest *events_request = (EventsRequest*)hook_data; |
16b9cadb |
3345 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
7c0125e0 |
3346 | ControlFlowData *cfd = (ControlFlowData*)events_request->viewer_data; |
cd3892fe |
3347 | #if 0 |
7c0125e0 |
3348 | /* Desactivate sort */ |
3349 | gtk_tree_sortable_set_sort_column_id( |
3350 | GTK_TREE_SORTABLE(cfd->process_list->list_store), |
3351 | TRACE_COLUMN, |
3352 | GTK_SORT_ASCENDING); |
cd3892fe |
3353 | #endif //0 |
b9a010a2 |
3354 | drawing_chunk_begin(events_request, tss); |
3355 | |
3356 | return 0; |
3357 | } |
3358 | |
3359 | int before_request(void *hook_data, void *call_data) |
ca0f8a8e |
3360 | { |
3361 | EventsRequest *events_request = (EventsRequest*)hook_data; |
16b9cadb |
3362 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
7c0125e0 |
3363 | |
ca0f8a8e |
3364 | drawing_data_request_begin(events_request, tss); |
3365 | |
3366 | return 0; |
3367 | } |
3368 | |
3369 | |
8b90e648 |
3370 | /* |
b9a010a2 |
3371 | * after request is necessary in addition of after chunk in order to draw |
3372 | * lines until the end of the screen. after chunk just draws lines until |
3373 | * the last event. |
3374 | * |
8b90e648 |
3375 | * for each process |
a56a1ba4 |
3376 | * draw closing line |
b9a010a2 |
3377 | * expose |
8b90e648 |
3378 | */ |
b9a010a2 |
3379 | int after_request(void *hook_data, void *call_data) |
8b90e648 |
3380 | { |
ca0f8a8e |
3381 | EventsRequest *events_request = (EventsRequest*)hook_data; |
3382 | ControlFlowData *control_flow_data = events_request->viewer_data; |
16b9cadb |
3383 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
a56a1ba4 |
3384 | |
5c230fc4 |
3385 | ProcessList *process_list = control_flow_data->process_list; |
b9a010a2 |
3386 | LttTime end_time = events_request->end_time; |
3387 | |
3388 | ClosureData closure_data; |
3389 | closure_data.events_request = (EventsRequest*)hook_data; |
3390 | closure_data.tss = tss; |
3391 | closure_data.end_time = end_time; |
3392 | |
bc8d270b |
3393 | TimeWindow time_window = |
3394 | lttvwindow_get_time_window(control_flow_data->tab); |
3395 | guint width = control_flow_data->drawing->width; |
3396 | convert_time_to_pixels( |
3397 | time_window, |
3398 | end_time, |
3399 | width, |
3400 | &closure_data.x_end); |
3401 | |
3402 | |
b9a010a2 |
3403 | /* Draw last items */ |
3404 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
3405 | (void*)&closure_data); |
7c0125e0 |
3406 | |
b9a010a2 |
3407 | |
3408 | /* Request expose */ |
3409 | drawing_request_expose(events_request, tss, end_time); |
3410 | return 0; |
3411 | } |
3412 | |
3413 | /* |
3414 | * for each process |
3415 | * draw closing line |
e800cf84 |
3416 | * expose |
b9a010a2 |
3417 | */ |
3418 | int after_chunk(void *hook_data, void *call_data) |
3419 | { |
3420 | EventsRequest *events_request = (EventsRequest*)hook_data; |
3421 | ControlFlowData *control_flow_data = events_request->viewer_data; |
16b9cadb |
3422 | LttvTracesetState *tss = (LttvTracesetState*)call_data; |
3423 | LttvTracesetContext *tsc = (LttvTracesetContext*)call_data; |
b9a010a2 |
3424 | LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc); |
3425 | LttTime end_time; |
3426 | |
5c230fc4 |
3427 | ProcessList *process_list = control_flow_data->process_list; |
b9a010a2 |
3428 | |
40debf7b |
3429 | g_free(process_list->current_hash_data); |
3430 | process_list->current_hash_data = NULL; |
3431 | |
e800cf84 |
3432 | if(tfc != NULL) |
3433 | end_time = LTT_TIME_MIN(tfc->timestamp, events_request->end_time); |
0c5dbe3b |
3434 | else /* end of traceset, or position now out of request : end */ |
3435 | end_time = events_request->end_time; |
3436 | |
a56a1ba4 |
3437 | ClosureData closure_data; |
ca0f8a8e |
3438 | closure_data.events_request = (EventsRequest*)hook_data; |
3439 | closure_data.tss = tss; |
b9a010a2 |
3440 | closure_data.end_time = end_time; |
a56a1ba4 |
3441 | |
bc8d270b |
3442 | TimeWindow time_window = |
3443 | lttvwindow_get_time_window(control_flow_data->tab); |
3444 | guint width = control_flow_data->drawing->width; |
3445 | convert_time_to_pixels( |
3446 | time_window, |
3447 | end_time, |
3448 | width, |
3449 | &closure_data.x_end); |
3450 | |
b9a010a2 |
3451 | /* Draw last items */ |
14963be0 |
3452 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
a56a1ba4 |
3453 | (void*)&closure_data); |
cd3892fe |
3454 | #if 0 |
7c0125e0 |
3455 | /* Reactivate sort */ |
3456 | gtk_tree_sortable_set_sort_column_id( |
3457 | GTK_TREE_SORTABLE(control_flow_data->process_list->list_store), |
3458 | GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, |
3459 | GTK_SORT_ASCENDING); |
3460 | |
3461 | update_index_to_pixmap(control_flow_data->process_list); |
cd3892fe |
3462 | /* Request a full expose : drawing scrambled */ |
3463 | gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
3464 | #endif //0 |
3465 | /* Request expose (updates damages zone also) */ |
b9a010a2 |
3466 | drawing_request_expose(events_request, tss, end_time); |
ca0f8a8e |
3467 | |
3468 | return 0; |
8b90e648 |
3469 | } |
3470 | |