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 | |
cf6cb7e0 |
25 | //#define PANGO_ENABLE_BACKEND |
558aa013 |
26 | #include <gtk/gtk.h> |
27 | #include <gdk/gdk.h> |
5f16133f |
28 | #include <glib.h> |
80a52ff8 |
29 | #include <assert.h> |
50439712 |
30 | #include <string.h> |
319e9d81 |
31 | #include <stdio.h> |
5f16133f |
32 | |
cf6cb7e0 |
33 | //#include <pango/pango.h> |
34 | |
80a52ff8 |
35 | #include <ltt/event.h> |
4ba42155 |
36 | #include <ltt/time.h> |
50439712 |
37 | #include <ltt/type.h> |
80a52ff8 |
38 | |
2a2fa4f0 |
39 | #include <lttv/lttv.h> |
558aa013 |
40 | #include <lttv/hook.h> |
13f86ce2 |
41 | #include <lttvwindow/common.h> |
80a52ff8 |
42 | #include <lttv/state.h> |
5ac76b22 |
43 | #include <lttvwindow/viewer.h> |
80a52ff8 |
44 | |
f0d936c0 |
45 | |
a117e3f7 |
46 | #include "eventhooks.h" |
47 | #include "cfv.h" |
48 | #include "processlist.h" |
49 | #include "drawing.h" |
50 | #include "cfv-private.h" |
5f16133f |
51 | |
80a52ff8 |
52 | |
1a31868c |
53 | #define MAX_PATH_LEN 256 |
54 | |
f0d936c0 |
55 | |
56 | /** |
57 | * Event Viewer's constructor hook |
58 | * |
59 | * This constructor is given as a parameter to the menuitem and toolbar button |
60 | * registration. It creates the list. |
14963be0 |
61 | * @param mw A pointer to the parent window. |
f0d936c0 |
62 | * @return The widget created. |
63 | */ |
64 | GtkWidget * |
14963be0 |
65 | h_guicontrolflow(MainWindow *mw, LttvTracesetSelector * s, char * key) |
f0d936c0 |
66 | { |
14963be0 |
67 | g_info("h_guicontrolflow, %p, %p, %s", mw, s, key); |
68997a22 |
68 | ControlFlowData *control_flow_data = guicontrolflow() ; |
a56a1ba4 |
69 | |
14963be0 |
70 | control_flow_data->mw = mw; |
a56a1ba4 |
71 | |
2a2fa4f0 |
72 | //g_debug("time width2 : %u",time_window->time_width); |
a56a1ba4 |
73 | // Unreg done in the GuiControlFlow_Destructor |
224446ce |
74 | lttvwindow_register_time_window_notify(mw, |
75 | update_time_window_hook, |
76 | control_flow_data); |
77 | lttvwindow_register_current_time_notify(mw, |
78 | update_current_time_hook, |
79 | control_flow_data); |
68997a22 |
80 | return guicontrolflow_get_widget(control_flow_data) ; |
a56a1ba4 |
81 | |
f0d936c0 |
82 | } |
83 | |
3cff8cc1 |
84 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 |
85 | { |
68997a22 |
86 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
14963be0 |
87 | guint *event_number = (guint*) call_data; |
f0d936c0 |
88 | |
2a2fa4f0 |
89 | g_debug("DEBUG : event selected by main window : %u", *event_number); |
a56a1ba4 |
90 | |
14963be0 |
91 | // control_flow_data->currently_Selected_Event = *event_number; |
68997a22 |
92 | // control_flow_data->Selected_Event = TRUE ; |
a56a1ba4 |
93 | |
68997a22 |
94 | // tree_v_set_cursor(control_flow_data); |
f0d936c0 |
95 | |
96 | } |
97 | |
f0d936c0 |
98 | /* Hook called before drawing. Gets the initial context at the beginning of the |
14963be0 |
99 | * drawing interval and copy it to the context in event_request. |
f0d936c0 |
100 | */ |
4c69e0cc |
101 | int draw_before_hook(void *hook_data, void *call_data) |
f0d936c0 |
102 | { |
14963be0 |
103 | EventRequest *event_request = (EventRequest*)hook_data; |
a56a1ba4 |
104 | //EventsContext Events_Context = (EventsContext*)call_data; |
105 | |
14963be0 |
106 | //event_request->Events_Context = Events_Context; |
f0d936c0 |
107 | |
a56a1ba4 |
108 | return 0; |
f0d936c0 |
109 | } |
110 | |
111 | /* |
112 | * The draw event hook is called by the reading API to have a |
113 | * particular event drawn on the screen. |
114 | * @param hook_data ControlFlowData structure of the viewer. |
115 | * @param call_data Event context. |
116 | * |
117 | * This function basically draw lines and icons. Two types of lines are drawn : |
118 | * one small (3 pixels?) representing the state of the process and the second |
119 | * type is thicker (10 pixels?) representing on which CPU a process is running |
120 | * (and this only in running state). |
121 | * |
122 | * Extremums of the lines : |
123 | * x_min : time of the last event context for this process kept in memory. |
124 | * x_max : time of the current event. |
125 | * y : middle of the process in the process list. The process is found in the |
126 | * list, therefore is it's position in pixels. |
127 | * |
128 | * The choice of lines'color is defined by the context of the last event for this |
129 | * process. |
130 | */ |
4c69e0cc |
131 | int draw_event_hook(void *hook_data, void *call_data) |
f0d936c0 |
132 | { |
14963be0 |
133 | EventRequest *event_request = (EventRequest*)hook_data; |
134 | ControlFlowData *control_flow_data = event_request->control_flow_data; |
a43d67ba |
135 | MainWindow *mw = control_flow_data->mw; |
e9a9c513 |
136 | |
a56a1ba4 |
137 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
e9a9c513 |
138 | |
139 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1aff52a2 |
140 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
a56a1ba4 |
141 | |
e9a9c513 |
142 | LttEvent *e; |
e9a9c513 |
143 | e = tfc->e; |
144 | |
9444deae |
145 | LttTime evtime = ltt_event_time(e); |
224446ce |
146 | const TimeWindow *time_window = |
a43d67ba |
147 | lttvwindow_get_time_window(mw); |
9444deae |
148 | |
149 | LttTime end_time = ltt_time_add(time_window->start_time, |
150 | time_window->time_width); |
151 | //if(time < time_beg || time > time_end) return; |
152 | if(ltt_time_compare(evtime, time_window->start_time) == -1 |
153 | || ltt_time_compare(evtime, end_time) == 1) |
154 | return; |
155 | |
a56a1ba4 |
156 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
157 | { |
2a2fa4f0 |
158 | g_debug("schedchange!"); |
a56a1ba4 |
159 | |
160 | /* Add process to process list (if not present) and get drawing "y" from |
161 | * process position */ |
162 | guint pid_out, pid_in; |
163 | LttvProcessState *process_out, *process_in; |
164 | LttTime birth; |
165 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
166 | |
167 | ProcessList *process_list = |
14963be0 |
168 | guicontrolflow_get_process_list(event_request->control_flow_data); |
a56a1ba4 |
169 | |
170 | |
171 | LttField *f = ltt_event_field(e); |
172 | LttField *element; |
173 | element = ltt_field_member(f,0); |
174 | pid_out = ltt_event_get_long_unsigned(e,element); |
175 | element = ltt_field_member(f,1); |
176 | pid_in = ltt_event_get_long_unsigned(e,element); |
2a2fa4f0 |
177 | g_debug("out : %u in : %u", pid_out, pid_in); |
a56a1ba4 |
178 | |
179 | |
180 | /* Find process pid_out in the list... */ |
87658614 |
181 | process_out = lttv_state_find_process(tfs, pid_out); |
1aff52a2 |
182 | if(process_out == NULL) return 0; |
2a2fa4f0 |
183 | g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
1aff52a2 |
184 | |
a56a1ba4 |
185 | birth = process_out->creation_time; |
186 | gchar *name = strdup(g_quark_to_string(process_out->name)); |
14963be0 |
187 | HashedProcessData *hashed_process_data_out = NULL; |
a56a1ba4 |
188 | |
189 | if(processlist_get_process_pixels(process_list, |
190 | pid_out, |
191 | &birth, |
d0cd7f09 |
192 | tfc->t_context->index, |
a56a1ba4 |
193 | &y_out, |
194 | &height, |
14963be0 |
195 | &hashed_process_data_out) == 1) |
a56a1ba4 |
196 | { |
197 | /* Process not present */ |
198 | processlist_add(process_list, |
199 | pid_out, |
200 | &birth, |
d0cd7f09 |
201 | tfc->t_context->index, |
a56a1ba4 |
202 | name, |
203 | &pl_height, |
14963be0 |
204 | &hashed_process_data_out); |
a56a1ba4 |
205 | processlist_get_process_pixels(process_list, |
206 | pid_out, |
207 | &birth, |
d0cd7f09 |
208 | tfc->t_context->index, |
a56a1ba4 |
209 | &y_out, |
210 | &height, |
14963be0 |
211 | &hashed_process_data_out); |
501d5405 |
212 | drawing_insert_square( event_request->control_flow_data->drawing, y_out, height); |
a56a1ba4 |
213 | } |
214 | |
215 | g_free(name); |
216 | |
217 | /* Find process pid_in in the list... */ |
87658614 |
218 | process_in = lttv_state_find_process(tfs, pid_in); |
1aff52a2 |
219 | if(process_in == NULL) return 0; |
2a2fa4f0 |
220 | g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
a56a1ba4 |
221 | |
222 | birth = process_in->creation_time; |
223 | name = strdup(g_quark_to_string(process_in->name)); |
14963be0 |
224 | HashedProcessData *hashed_process_data_in = NULL; |
a56a1ba4 |
225 | |
226 | if(processlist_get_process_pixels(process_list, |
227 | pid_in, |
228 | &birth, |
d0cd7f09 |
229 | tfc->t_context->index, |
a56a1ba4 |
230 | &y_in, |
231 | &height, |
14963be0 |
232 | &hashed_process_data_in) == 1) |
a56a1ba4 |
233 | { |
234 | /* Process not present */ |
235 | processlist_add(process_list, |
236 | pid_in, |
237 | &birth, |
d0cd7f09 |
238 | tfc->t_context->index, |
a56a1ba4 |
239 | name, |
240 | &pl_height, |
14963be0 |
241 | &hashed_process_data_in); |
a56a1ba4 |
242 | processlist_get_process_pixels(process_list, |
243 | pid_in, |
244 | &birth, |
d0cd7f09 |
245 | tfc->t_context->index, |
a56a1ba4 |
246 | &y_in, |
247 | &height, |
14963be0 |
248 | &hashed_process_data_in); |
a56a1ba4 |
249 | |
501d5405 |
250 | drawing_insert_square( event_request->control_flow_data->drawing, y_in, height); |
a56a1ba4 |
251 | } |
252 | g_free(name); |
253 | |
254 | |
255 | /* Find pixels corresponding to time of the event. If the time does |
256 | * not fit in the window, show a warning, not supposed to happend. */ |
257 | guint x = 0; |
501d5405 |
258 | guint width = control_flow_data->drawing->drawing_area->allocation.width; |
a56a1ba4 |
259 | |
260 | LttTime time = ltt_event_time(e); |
261 | |
224446ce |
262 | LttTime window_end = ltt_time_add(time_window->time_width, |
263 | time_window->start_time); |
a56a1ba4 |
264 | |
265 | |
266 | convert_time_to_pixels( |
224446ce |
267 | time_window->start_time, |
a56a1ba4 |
268 | window_end, |
269 | time, |
270 | width, |
271 | &x); |
9444deae |
272 | //assert(x <= width); |
a56a1ba4 |
273 | |
274 | /* draw what represents the event for outgoing process. */ |
275 | |
14963be0 |
276 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
68997a22 |
277 | draw_context_out->current->modify_over->x = x; |
319e9d81 |
278 | draw_context_out->current->modify_under->x = x; |
68997a22 |
279 | draw_context_out->current->modify_over->y = y_out; |
319e9d81 |
280 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
501d5405 |
281 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
282 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
283 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
284 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
d0cd7f09 |
285 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
286 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
a56a1ba4 |
287 | //draw_context_out->gc = widget->style->black_gc; |
288 | |
289 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
501d5405 |
290 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
a56a1ba4 |
291 | |
d0cd7f09 |
292 | /* Draw the line/background of the out process */ |
293 | if(draw_context_out->previous->middle->x == -1) |
294 | { |
295 | draw_context_out->previous->over->x = event_request->x_begin; |
296 | draw_context_out->previous->middle->x = event_request->x_begin; |
297 | draw_context_out->previous->under->x = event_request->x_begin; |
298 | |
2a2fa4f0 |
299 | g_debug("out middle x_beg : %u",event_request->x_begin); |
d0cd7f09 |
300 | } |
301 | |
302 | draw_context_out->current->middle->x = x; |
303 | draw_context_out->current->over->x = x; |
304 | draw_context_out->current->under->x = x; |
305 | draw_context_out->current->middle->y = y_out + height/2; |
306 | draw_context_out->current->over->y = y_out; |
307 | draw_context_out->current->under->y = y_out + height; |
308 | draw_context_out->previous->middle->y = y_out + height/2; |
309 | draw_context_out->previous->over->y = y_out; |
310 | draw_context_out->previous->under->y = y_out + height; |
311 | |
312 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
313 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
314 | |
315 | if(process_out->state->s == LTTV_STATE_RUN) |
316 | { |
317 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
318 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
319 | |
320 | PropertiesBG prop_bg; |
321 | prop_bg.color = g_new(GdkColor,1); |
322 | |
323 | switch(tfc->index) { |
324 | case 0: |
325 | prop_bg.color->red = 0x1515; |
326 | prop_bg.color->green = 0x1515; |
327 | prop_bg.color->blue = 0x8c8c; |
328 | break; |
329 | case 1: |
330 | prop_bg.color->red = 0x4e4e; |
331 | prop_bg.color->green = 0xa9a9; |
332 | prop_bg.color->blue = 0xa4a4; |
333 | break; |
334 | case 2: |
335 | prop_bg.color->red = 0x7a7a; |
336 | prop_bg.color->green = 0x4a4a; |
337 | prop_bg.color->blue = 0x8b8b; |
338 | break; |
339 | case 3: |
340 | prop_bg.color->red = 0x8080; |
341 | prop_bg.color->green = 0x7777; |
342 | prop_bg.color->blue = 0x4747; |
343 | break; |
344 | default: |
345 | prop_bg.color->red = 0xe7e7; |
346 | prop_bg.color->green = 0xe7e7; |
347 | prop_bg.color->blue = 0xe7e7; |
348 | } |
349 | |
2a2fa4f0 |
350 | g_debug("calling from draw_event"); |
d0cd7f09 |
351 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
352 | g_free(prop_bg.color); |
353 | gdk_gc_unref(draw_context_out->gc); |
354 | } |
355 | |
356 | draw_context_out->gc = widget->style->black_gc; |
357 | |
a56a1ba4 |
358 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
2df6f2bd |
359 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
360 | PropertiesText prop_text_out; |
361 | prop_text_out.foreground = &colorfg_out; |
362 | prop_text_out.background = &colorbg_out; |
cfe526b1 |
363 | prop_text_out.size = 6; |
a56a1ba4 |
364 | prop_text_out.position = OVER; |
365 | |
cfe526b1 |
366 | /* color of text : status of the process */ |
367 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
368 | { |
369 | prop_text_out.foreground->red = 0xffff; |
370 | prop_text_out.foreground->green = 0xffff; |
371 | prop_text_out.foreground->blue = 0xffff; |
372 | } |
373 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
374 | { |
375 | prop_text_out.foreground->red = 0x0fff; |
d52cfc84 |
376 | prop_text_out.foreground->green = 0xffff; |
377 | prop_text_out.foreground->blue = 0xfff0; |
cfe526b1 |
378 | } |
379 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
380 | { |
2df6f2bd |
381 | prop_text_out.foreground->red = 0xffff; |
382 | prop_text_out.foreground->green = 0xffff; |
cfe526b1 |
383 | prop_text_out.foreground->blue = 0x0000; |
384 | } |
385 | else if(process_out->state->s == LTTV_STATE_EXIT) |
386 | { |
387 | prop_text_out.foreground->red = 0xffff; |
388 | prop_text_out.foreground->green = 0x0000; |
389 | prop_text_out.foreground->blue = 0xffff; |
390 | } |
391 | else if(process_out->state->s == LTTV_STATE_WAIT) |
392 | { |
393 | prop_text_out.foreground->red = 0xffff; |
394 | prop_text_out.foreground->green = 0x0000; |
395 | prop_text_out.foreground->blue = 0x0000; |
396 | } |
397 | else if(process_out->state->s == LTTV_STATE_RUN) |
398 | { |
399 | prop_text_out.foreground->red = 0x0000; |
400 | prop_text_out.foreground->green = 0xffff; |
401 | prop_text_out.foreground->blue = 0x0000; |
402 | } |
403 | else |
404 | { |
405 | prop_text_out.foreground->red = 0xffff; |
406 | prop_text_out.foreground->green = 0xffff; |
407 | prop_text_out.foreground->blue = 0xffff; |
408 | } |
409 | |
d52cfc84 |
410 | |
a56a1ba4 |
411 | /* Print status of the process : U, WF, WC, E, W, R */ |
412 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
cfe526b1 |
413 | prop_text_out.text = "U->"; |
a56a1ba4 |
414 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
cfe526b1 |
415 | prop_text_out.text = "WF->"; |
a56a1ba4 |
416 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
cfe526b1 |
417 | prop_text_out.text = "WC->"; |
a56a1ba4 |
418 | else if(process_out->state->s == LTTV_STATE_EXIT) |
cfe526b1 |
419 | prop_text_out.text = "E->"; |
a56a1ba4 |
420 | else if(process_out->state->s == LTTV_STATE_WAIT) |
cfe526b1 |
421 | prop_text_out.text = "W->"; |
a56a1ba4 |
422 | else if(process_out->state->s == LTTV_STATE_RUN) |
cfe526b1 |
423 | prop_text_out.text = "R->"; |
a56a1ba4 |
424 | else |
68997a22 |
425 | prop_text_out.text = "U"; |
a56a1ba4 |
426 | |
427 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
d0cd7f09 |
428 | //gdk_gc_unref(draw_context_out->gc); |
a56a1ba4 |
429 | |
501d5405 |
430 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
a56a1ba4 |
431 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
432 | |
433 | PropertiesLine prop_line_out; |
434 | prop_line_out.color = g_new(GdkColor,1); |
cfe526b1 |
435 | prop_line_out.line_width = 2; |
a56a1ba4 |
436 | prop_line_out.style = GDK_LINE_SOLID; |
437 | prop_line_out.position = MIDDLE; |
d52cfc84 |
438 | |
2a2fa4f0 |
439 | g_debug("out state : %s", g_quark_to_string(process_out->state->s)); |
a56a1ba4 |
440 | |
441 | /* color of line : status of the process */ |
442 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
443 | { |
cfe526b1 |
444 | prop_line_out.color->red = 0xffff; |
445 | prop_line_out.color->green = 0xffff; |
446 | prop_line_out.color->blue = 0xffff; |
a56a1ba4 |
447 | } |
448 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
449 | { |
450 | prop_line_out.color->red = 0x0fff; |
d52cfc84 |
451 | prop_line_out.color->green = 0xffff; |
452 | prop_line_out.color->blue = 0xfff0; |
a56a1ba4 |
453 | } |
454 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
455 | { |
2df6f2bd |
456 | prop_line_out.color->red = 0xffff; |
457 | prop_line_out.color->green = 0xffff; |
a56a1ba4 |
458 | prop_line_out.color->blue = 0x0000; |
459 | } |
460 | else if(process_out->state->s == LTTV_STATE_EXIT) |
461 | { |
462 | prop_line_out.color->red = 0xffff; |
463 | prop_line_out.color->green = 0x0000; |
464 | prop_line_out.color->blue = 0xffff; |
465 | } |
466 | else if(process_out->state->s == LTTV_STATE_WAIT) |
467 | { |
468 | prop_line_out.color->red = 0xffff; |
469 | prop_line_out.color->green = 0x0000; |
470 | prop_line_out.color->blue = 0x0000; |
471 | } |
472 | else if(process_out->state->s == LTTV_STATE_RUN) |
473 | { |
474 | prop_line_out.color->red = 0x0000; |
475 | prop_line_out.color->green = 0xffff; |
476 | prop_line_out.color->blue = 0x0000; |
477 | } |
478 | else |
479 | { |
cfe526b1 |
480 | prop_line_out.color->red = 0xffff; |
481 | prop_line_out.color->green = 0xffff; |
482 | prop_line_out.color->blue = 0xffff; |
a56a1ba4 |
483 | } |
484 | |
485 | draw_line((void*)&prop_line_out, (void*)draw_context_out); |
486 | g_free(prop_line_out.color); |
487 | gdk_gc_unref(draw_context_out->gc); |
488 | /* Note : finishing line will have to be added when trace read over. */ |
489 | |
490 | /* Finally, update the drawing context of the pid_in. */ |
491 | |
14963be0 |
492 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
68997a22 |
493 | draw_context_in->current->modify_over->x = x; |
319e9d81 |
494 | draw_context_in->current->modify_under->x = x; |
68997a22 |
495 | draw_context_in->current->modify_over->y = y_in; |
319e9d81 |
496 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
501d5405 |
497 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
498 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
499 | widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
500 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
501 | //draw_context_in->gc = widget->style->black_gc; |
d0cd7f09 |
502 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
503 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
a56a1ba4 |
504 | |
505 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
501d5405 |
506 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
507 | |
508 | /* Draw the line/bg of the in process */ |
509 | if(draw_context_in->previous->middle->x == -1) |
510 | { |
511 | draw_context_in->previous->middle->x = event_request->x_begin; |
512 | draw_context_in->previous->over->x = event_request->x_begin; |
513 | draw_context_in->previous->under->x = event_request->x_begin; |
2a2fa4f0 |
514 | g_debug("in middle x_beg : %u",event_request->x_begin); |
d0cd7f09 |
515 | } |
516 | |
517 | draw_context_in->current->middle->x = x; |
518 | draw_context_in->current->over->x = x; |
519 | draw_context_in->current->under->x = x; |
520 | draw_context_in->current->middle->y = y_in + height/2; |
521 | draw_context_in->current->over->y = y_in; |
522 | draw_context_in->current->under->y = y_in + height; |
523 | draw_context_in->previous->middle->y = y_in + height/2; |
524 | draw_context_in->previous->over->y = y_in; |
525 | draw_context_in->previous->under->y = y_in + height; |
a56a1ba4 |
526 | |
d0cd7f09 |
527 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
528 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
529 | |
530 | |
531 | if(process_in->state->s == LTTV_STATE_RUN) |
532 | { |
533 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
534 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
535 | |
536 | PropertiesBG prop_bg; |
537 | prop_bg.color = g_new(GdkColor,1); |
538 | |
539 | switch(tfc->index) { |
540 | case 0: |
541 | prop_bg.color->red = 0x1515; |
542 | prop_bg.color->green = 0x1515; |
543 | prop_bg.color->blue = 0x8c8c; |
544 | break; |
545 | case 1: |
546 | prop_bg.color->red = 0x4e4e; |
547 | prop_bg.color->green = 0xa9a9; |
548 | prop_bg.color->blue = 0xa4a4; |
549 | break; |
550 | case 2: |
551 | prop_bg.color->red = 0x7a7a; |
552 | prop_bg.color->green = 0x4a4a; |
553 | prop_bg.color->blue = 0x8b8b; |
554 | break; |
555 | case 3: |
556 | prop_bg.color->red = 0x8080; |
557 | prop_bg.color->green = 0x7777; |
558 | prop_bg.color->blue = 0x4747; |
559 | break; |
560 | default: |
561 | prop_bg.color->red = 0xe7e7; |
562 | prop_bg.color->green = 0xe7e7; |
563 | prop_bg.color->blue = 0xe7e7; |
564 | } |
565 | |
566 | |
567 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
568 | g_free(prop_bg.color); |
569 | gdk_gc_unref(draw_context_in->gc); |
570 | } |
571 | |
572 | draw_context_in->gc = widget->style->black_gc; |
573 | |
a56a1ba4 |
574 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
2df6f2bd |
575 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
576 | PropertiesText prop_text_in; |
577 | prop_text_in.foreground = &colorfg_in; |
578 | prop_text_in.background = &colorbg_in; |
cfe526b1 |
579 | prop_text_in.size = 6; |
a56a1ba4 |
580 | prop_text_in.position = OVER; |
581 | |
2a2fa4f0 |
582 | g_debug("in state : %s", g_quark_to_string(process_in->state->s)); |
cfe526b1 |
583 | /* foreground of text : status of the process */ |
584 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
585 | { |
586 | prop_text_in.foreground->red = 0xffff; |
587 | prop_text_in.foreground->green = 0xffff; |
588 | prop_text_in.foreground->blue = 0xffff; |
589 | } |
590 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
591 | { |
592 | prop_text_in.foreground->red = 0x0fff; |
d52cfc84 |
593 | prop_text_in.foreground->green = 0xffff; |
594 | prop_text_in.foreground->blue = 0xfff0; |
cfe526b1 |
595 | } |
596 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
597 | { |
2df6f2bd |
598 | prop_text_in.foreground->red = 0xffff; |
599 | prop_text_in.foreground->green = 0xffff; |
cfe526b1 |
600 | prop_text_in.foreground->blue = 0x0000; |
601 | } |
602 | else if(process_in->state->s == LTTV_STATE_EXIT) |
603 | { |
604 | prop_text_in.foreground->red = 0xffff; |
605 | prop_text_in.foreground->green = 0x0000; |
606 | prop_text_in.foreground->blue = 0xffff; |
607 | } |
608 | else if(process_in->state->s == LTTV_STATE_WAIT) |
609 | { |
610 | prop_text_in.foreground->red = 0xffff; |
611 | prop_text_in.foreground->green = 0x0000; |
612 | prop_text_in.foreground->blue = 0x0000; |
613 | } |
614 | else if(process_in->state->s == LTTV_STATE_RUN) |
615 | { |
616 | prop_text_in.foreground->red = 0x0000; |
617 | prop_text_in.foreground->green = 0xffff; |
618 | prop_text_in.foreground->blue = 0x0000; |
619 | } |
620 | else |
621 | { |
622 | prop_text_in.foreground->red = 0xffff; |
623 | prop_text_in.foreground->green = 0xffff; |
624 | prop_text_in.foreground->blue = 0xffff; |
625 | } |
626 | |
627 | |
628 | |
a56a1ba4 |
629 | /* Print status of the process : U, WF, WC, E, W, R */ |
630 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
cfe526b1 |
631 | prop_text_in.text = "U->"; |
a56a1ba4 |
632 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
cfe526b1 |
633 | prop_text_in.text = "WF->"; |
a56a1ba4 |
634 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
cfe526b1 |
635 | prop_text_in.text = "WC->"; |
a56a1ba4 |
636 | else if(process_in->state->s == LTTV_STATE_EXIT) |
cfe526b1 |
637 | prop_text_in.text = "E->"; |
a56a1ba4 |
638 | else if(process_in->state->s == LTTV_STATE_WAIT) |
cfe526b1 |
639 | prop_text_in.text = "W->"; |
a56a1ba4 |
640 | else if(process_in->state->s == LTTV_STATE_RUN) |
cfe526b1 |
641 | prop_text_in.text = "R->"; |
a56a1ba4 |
642 | else |
68997a22 |
643 | prop_text_in.text = "U"; |
a56a1ba4 |
644 | |
645 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
d0cd7f09 |
646 | //gdk_gc_unref(draw_context_in->gc); |
647 | |
501d5405 |
648 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
a56a1ba4 |
649 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
d0cd7f09 |
650 | |
a56a1ba4 |
651 | PropertiesLine prop_line_in; |
652 | prop_line_in.color = g_new(GdkColor,1); |
cfe526b1 |
653 | prop_line_in.line_width = 2; |
a56a1ba4 |
654 | prop_line_in.style = GDK_LINE_SOLID; |
655 | prop_line_in.position = MIDDLE; |
656 | |
657 | /* color of line : status of the process */ |
658 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
659 | { |
cfe526b1 |
660 | prop_line_in.color->red = 0xffff; |
661 | prop_line_in.color->green = 0xffff; |
662 | prop_line_in.color->blue = 0xffff; |
a56a1ba4 |
663 | } |
664 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
665 | { |
666 | prop_line_in.color->red = 0x0fff; |
d52cfc84 |
667 | prop_line_in.color->green = 0xffff; |
668 | prop_line_in.color->blue = 0xfff0; |
a56a1ba4 |
669 | } |
670 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
671 | { |
2df6f2bd |
672 | prop_line_in.color->red = 0xffff; |
673 | prop_line_in.color->green = 0xffff; |
a56a1ba4 |
674 | prop_line_in.color->blue = 0x0000; |
675 | } |
676 | else if(process_in->state->s == LTTV_STATE_EXIT) |
677 | { |
678 | prop_line_in.color->red = 0xffff; |
679 | prop_line_in.color->green = 0x0000; |
680 | prop_line_in.color->blue = 0xffff; |
681 | } |
682 | else if(process_in->state->s == LTTV_STATE_WAIT) |
683 | { |
684 | prop_line_in.color->red = 0xffff; |
685 | prop_line_in.color->green = 0x0000; |
686 | prop_line_in.color->blue = 0x0000; |
687 | } |
688 | else if(process_in->state->s == LTTV_STATE_RUN) |
689 | { |
690 | prop_line_in.color->red = 0x0000; |
691 | prop_line_in.color->green = 0xffff; |
692 | prop_line_in.color->blue = 0x0000; |
693 | } |
694 | else |
695 | { |
cfe526b1 |
696 | prop_line_in.color->red = 0xffff; |
697 | prop_line_in.color->green = 0xffff; |
698 | prop_line_in.color->blue = 0xffff; |
a56a1ba4 |
699 | } |
700 | |
701 | draw_line((void*)&prop_line_in, (void*)draw_context_in); |
702 | g_free(prop_line_in.color); |
703 | gdk_gc_unref(draw_context_in->gc); |
704 | } |
705 | |
706 | return 0; |
707 | |
708 | /* Temp dump */ |
80a52ff8 |
709 | #ifdef DONTSHOW |
a56a1ba4 |
710 | GString *string = g_string_new("");; |
711 | gboolean field_names = TRUE, state = TRUE; |
80a52ff8 |
712 | |
e9a9c513 |
713 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
714 | g_string_append_printf(string,"\n"); |
715 | |
716 | if(state) { |
717 | g_string_append_printf(string, " %s", |
718 | g_quark_to_string(tfs->process->state->s)); |
719 | } |
720 | |
721 | g_info("%s",string->str); |
722 | |
a56a1ba4 |
723 | g_string_free(string, TRUE); |
724 | |
725 | /* End of text dump */ |
80a52ff8 |
726 | #endif //DONTSHOW |
50439712 |
727 | |
f0d936c0 |
728 | } |
729 | |
730 | |
4c69e0cc |
731 | int draw_after_hook(void *hook_data, void *call_data) |
f0d936c0 |
732 | { |
14963be0 |
733 | EventRequest *event_request = (EventRequest*)hook_data; |
734 | ControlFlowData *control_flow_data = event_request->control_flow_data; |
50439712 |
735 | |
a56a1ba4 |
736 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
50439712 |
737 | |
738 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1aff52a2 |
739 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
50439712 |
740 | |
a56a1ba4 |
741 | |
50439712 |
742 | LttEvent *e; |
743 | e = tfc->e; |
744 | |
9444deae |
745 | LttTime evtime = ltt_event_time(e); |
224446ce |
746 | const TimeWindow *time_window = |
747 | lttvwindow_get_time_window(control_flow_data->mw); |
9444deae |
748 | |
749 | LttTime end_time = ltt_time_add(time_window->start_time, |
750 | time_window->time_width); |
751 | //if(time < time_beg || time > time_end) return; |
752 | if(ltt_time_compare(evtime, time_window->start_time) == -1 |
753 | || ltt_time_compare(evtime, end_time) == 1) |
754 | return; |
755 | |
756 | |
a56a1ba4 |
757 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
758 | { |
2a2fa4f0 |
759 | g_debug("schedchange!"); |
a56a1ba4 |
760 | |
761 | /* Add process to process list (if not present) and get drawing "y" from |
762 | * process position */ |
763 | guint pid_out, pid_in; |
764 | LttvProcessState *process_out, *process_in; |
765 | LttTime birth; |
766 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
767 | |
768 | ProcessList *process_list = |
14963be0 |
769 | guicontrolflow_get_process_list(event_request->control_flow_data); |
a56a1ba4 |
770 | |
771 | |
772 | LttField *f = ltt_event_field(e); |
773 | LttField *element; |
774 | element = ltt_field_member(f,0); |
775 | pid_out = ltt_event_get_long_unsigned(e,element); |
776 | element = ltt_field_member(f,1); |
777 | pid_in = ltt_event_get_long_unsigned(e,element); |
2a2fa4f0 |
778 | //g_debug("out : %u in : %u", pid_out, pid_in); |
a56a1ba4 |
779 | |
780 | |
781 | /* Find process pid_out in the list... */ |
2a2fa4f0 |
782 | process_out = lttv_state_find_process(tfs, pid_out); |
1aff52a2 |
783 | if(process_out == NULL) return 0; |
2a2fa4f0 |
784 | //g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
a56a1ba4 |
785 | |
786 | birth = process_out->creation_time; |
787 | gchar *name = strdup(g_quark_to_string(process_out->name)); |
14963be0 |
788 | HashedProcessData *hashed_process_data_out = NULL; |
a56a1ba4 |
789 | |
790 | if(processlist_get_process_pixels(process_list, |
791 | pid_out, |
792 | &birth, |
d0cd7f09 |
793 | tfc->t_context->index, |
a56a1ba4 |
794 | &y_out, |
795 | &height, |
14963be0 |
796 | &hashed_process_data_out) == 1) |
a56a1ba4 |
797 | { |
798 | /* Process not present */ |
799 | processlist_add(process_list, |
800 | pid_out, |
801 | &birth, |
d0cd7f09 |
802 | tfc->t_context->index, |
a56a1ba4 |
803 | name, |
804 | &pl_height, |
14963be0 |
805 | &hashed_process_data_out); |
a56a1ba4 |
806 | processlist_get_process_pixels(process_list, |
807 | pid_out, |
808 | &birth, |
d0cd7f09 |
809 | tfc->t_context->index, |
a56a1ba4 |
810 | &y_out, |
811 | &height, |
14963be0 |
812 | &hashed_process_data_out); |
501d5405 |
813 | drawing_insert_square( event_request->control_flow_data->drawing, y_out, height); |
a56a1ba4 |
814 | } |
815 | |
816 | g_free(name); |
817 | |
818 | /* Find process pid_in in the list... */ |
2a2fa4f0 |
819 | process_in = lttv_state_find_process(tfs, pid_in); |
1aff52a2 |
820 | if(process_in == NULL) return 0; |
2a2fa4f0 |
821 | //g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
a56a1ba4 |
822 | |
823 | birth = process_in->creation_time; |
824 | name = strdup(g_quark_to_string(process_in->name)); |
14963be0 |
825 | HashedProcessData *hashed_process_data_in = NULL; |
a56a1ba4 |
826 | |
827 | if(processlist_get_process_pixels(process_list, |
828 | pid_in, |
829 | &birth, |
d0cd7f09 |
830 | tfc->t_context->index, |
a56a1ba4 |
831 | &y_in, |
832 | &height, |
14963be0 |
833 | &hashed_process_data_in) == 1) |
a56a1ba4 |
834 | { |
835 | /* Process not present */ |
836 | processlist_add(process_list, |
837 | pid_in, |
838 | &birth, |
d0cd7f09 |
839 | tfc->t_context->index, |
a56a1ba4 |
840 | name, |
841 | &pl_height, |
14963be0 |
842 | &hashed_process_data_in); |
a56a1ba4 |
843 | processlist_get_process_pixels(process_list, |
844 | pid_in, |
845 | &birth, |
d0cd7f09 |
846 | tfc->t_context->index, |
a56a1ba4 |
847 | &y_in, |
848 | &height, |
14963be0 |
849 | &hashed_process_data_in); |
a56a1ba4 |
850 | |
501d5405 |
851 | drawing_insert_square( event_request->control_flow_data->drawing, y_in, height); |
a56a1ba4 |
852 | } |
853 | g_free(name); |
854 | |
855 | |
856 | /* Find pixels corresponding to time of the event. If the time does |
857 | * not fit in the window, show a warning, not supposed to happend. */ |
858 | //guint x = 0; |
501d5405 |
859 | //guint width = control_flow_data->drawing->drawing_area->allocation.width; |
a56a1ba4 |
860 | |
861 | //LttTime time = ltt_event_time(e); |
862 | |
224446ce |
863 | //LttTime window_end = ltt_time_add(time_window->time_width, |
864 | // time_window->start_time); |
a56a1ba4 |
865 | |
866 | |
867 | //convert_time_to_pixels( |
224446ce |
868 | // time_window->start_time, |
a56a1ba4 |
869 | // window_end, |
870 | // time, |
871 | // width, |
872 | // &x); |
873 | |
874 | //assert(x <= width); |
875 | |
876 | /* draw what represents the event for outgoing process. */ |
877 | |
14963be0 |
878 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
68997a22 |
879 | //draw_context_out->current->modify_over->x = x; |
880 | draw_context_out->current->modify_over->y = y_out; |
319e9d81 |
881 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
501d5405 |
882 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
883 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
884 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
885 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
d0cd7f09 |
886 | |
a56a1ba4 |
887 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
501d5405 |
888 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
889 | |
890 | /*if(process_out->state->s == LTTV_STATE_RUN) |
891 | { |
892 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
893 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
894 | PropertiesBG prop_bg; |
895 | prop_bg.color = g_new(GdkColor,1); |
896 | |
897 | prop_bg.color->red = 0xffff; |
898 | prop_bg.color->green = 0xffff; |
899 | prop_bg.color->blue = 0xffff; |
900 | |
901 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
902 | g_free(prop_bg.color); |
903 | gdk_gc_unref(draw_context_out->gc); |
904 | }*/ |
905 | |
906 | draw_context_out->gc = widget->style->black_gc; |
907 | |
a56a1ba4 |
908 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
2df6f2bd |
909 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
910 | PropertiesText prop_text_out; |
911 | prop_text_out.foreground = &colorfg_out; |
912 | prop_text_out.background = &colorbg_out; |
cfe526b1 |
913 | prop_text_out.size = 6; |
a56a1ba4 |
914 | prop_text_out.position = OVER; |
915 | |
cfe526b1 |
916 | /* color of text : status of the process */ |
917 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
918 | { |
919 | prop_text_out.foreground->red = 0xffff; |
920 | prop_text_out.foreground->green = 0xffff; |
921 | prop_text_out.foreground->blue = 0xffff; |
922 | } |
923 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
924 | { |
925 | prop_text_out.foreground->red = 0x0fff; |
d52cfc84 |
926 | prop_text_out.foreground->green = 0xffff; |
927 | prop_text_out.foreground->blue = 0xfff0; |
cfe526b1 |
928 | } |
929 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
930 | { |
2df6f2bd |
931 | prop_text_out.foreground->red = 0xffff; |
932 | prop_text_out.foreground->green = 0xffff; |
cfe526b1 |
933 | prop_text_out.foreground->blue = 0x0000; |
934 | } |
935 | else if(process_out->state->s == LTTV_STATE_EXIT) |
936 | { |
937 | prop_text_out.foreground->red = 0xffff; |
938 | prop_text_out.foreground->green = 0x0000; |
939 | prop_text_out.foreground->blue = 0xffff; |
940 | } |
941 | else if(process_out->state->s == LTTV_STATE_WAIT) |
942 | { |
943 | prop_text_out.foreground->red = 0xffff; |
944 | prop_text_out.foreground->green = 0x0000; |
945 | prop_text_out.foreground->blue = 0x0000; |
946 | } |
947 | else if(process_out->state->s == LTTV_STATE_RUN) |
948 | { |
949 | prop_text_out.foreground->red = 0x0000; |
950 | prop_text_out.foreground->green = 0xffff; |
951 | prop_text_out.foreground->blue = 0x0000; |
952 | } |
953 | else |
954 | { |
955 | prop_text_out.foreground->red = 0xffff; |
956 | prop_text_out.foreground->green = 0xffff; |
957 | prop_text_out.foreground->blue = 0xffff; |
958 | } |
959 | |
a56a1ba4 |
960 | /* Print status of the process : U, WF, WC, E, W, R */ |
961 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
68997a22 |
962 | prop_text_out.text = "U"; |
a56a1ba4 |
963 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
68997a22 |
964 | prop_text_out.text = "WF"; |
a56a1ba4 |
965 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
68997a22 |
966 | prop_text_out.text = "WC"; |
a56a1ba4 |
967 | else if(process_out->state->s == LTTV_STATE_EXIT) |
68997a22 |
968 | prop_text_out.text = "E"; |
a56a1ba4 |
969 | else if(process_out->state->s == LTTV_STATE_WAIT) |
68997a22 |
970 | prop_text_out.text = "W"; |
a56a1ba4 |
971 | else if(process_out->state->s == LTTV_STATE_RUN) |
68997a22 |
972 | prop_text_out.text = "R"; |
a56a1ba4 |
973 | else |
68997a22 |
974 | prop_text_out.text = "U"; |
a56a1ba4 |
975 | |
976 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
d0cd7f09 |
977 | |
978 | //gdk_gc_unref(draw_context_out->gc); |
319e9d81 |
979 | |
68997a22 |
980 | draw_context_out->current->middle->y = y_out+height/2; |
d0cd7f09 |
981 | draw_context_out->current->over->y = y_out; |
982 | draw_context_out->current->under->y = y_out+height; |
68997a22 |
983 | draw_context_out->current->status = process_out->state->s; |
a56a1ba4 |
984 | |
68997a22 |
985 | /* for pid_out : remove previous, Prev = current, new current (default) */ |
986 | g_free(draw_context_out->previous->modify_under); |
987 | g_free(draw_context_out->previous->modify_middle); |
988 | g_free(draw_context_out->previous->modify_over); |
989 | g_free(draw_context_out->previous->under); |
990 | g_free(draw_context_out->previous->middle); |
991 | g_free(draw_context_out->previous->over); |
992 | g_free(draw_context_out->previous); |
993 | |
994 | draw_context_out->previous = draw_context_out->current; |
a56a1ba4 |
995 | |
68997a22 |
996 | draw_context_out->current = g_new(DrawInfo,1); |
997 | draw_context_out->current->over = g_new(ItemInfo,1); |
998 | draw_context_out->current->over->x = -1; |
999 | draw_context_out->current->over->y = -1; |
1000 | draw_context_out->current->middle = g_new(ItemInfo,1); |
1001 | draw_context_out->current->middle->x = -1; |
1002 | draw_context_out->current->middle->y = -1; |
1003 | draw_context_out->current->under = g_new(ItemInfo,1); |
1004 | draw_context_out->current->under->x = -1; |
1005 | draw_context_out->current->under->y = -1; |
1006 | draw_context_out->current->modify_over = g_new(ItemInfo,1); |
1007 | draw_context_out->current->modify_over->x = -1; |
1008 | draw_context_out->current->modify_over->y = -1; |
1009 | draw_context_out->current->modify_middle = g_new(ItemInfo,1); |
1010 | draw_context_out->current->modify_middle->x = -1; |
1011 | draw_context_out->current->modify_middle->y = -1; |
1012 | draw_context_out->current->modify_under = g_new(ItemInfo,1); |
1013 | draw_context_out->current->modify_under->x = -1; |
1014 | draw_context_out->current->modify_under->y = -1; |
1015 | draw_context_out->current->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1016 | |
1017 | /* Finally, update the drawing context of the pid_in. */ |
1018 | |
14963be0 |
1019 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
68997a22 |
1020 | //draw_context_in->current->modify_over->x = x; |
1021 | draw_context_in->current->modify_over->y = y_in; |
319e9d81 |
1022 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
501d5405 |
1023 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
1024 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
1025 | widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1026 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
a56a1ba4 |
1027 | |
1028 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
501d5405 |
1029 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1030 | |
1031 | /*if(process_in->state->s == LTTV_STATE_RUN) |
1032 | { |
1033 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1034 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
1035 | PropertiesBG prop_bg; |
1036 | prop_bg.color = g_new(GdkColor,1); |
1037 | |
1038 | prop_bg.color->red = 0xffff; |
1039 | prop_bg.color->green = 0xffff; |
1040 | prop_bg.color->blue = 0xffff; |
1041 | |
1042 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
1043 | g_free(prop_bg.color); |
1044 | gdk_gc_unref(draw_context_in->gc); |
1045 | }*/ |
1046 | |
1047 | draw_context_in->gc = widget->style->black_gc; |
1048 | |
a56a1ba4 |
1049 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
2df6f2bd |
1050 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1051 | PropertiesText prop_text_in; |
1052 | prop_text_in.foreground = &colorfg_in; |
1053 | prop_text_in.background = &colorbg_in; |
cfe526b1 |
1054 | prop_text_in.size = 6; |
a56a1ba4 |
1055 | prop_text_in.position = OVER; |
1056 | |
cfe526b1 |
1057 | /* foreground of text : status of the process */ |
1058 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
1059 | { |
1060 | prop_text_in.foreground->red = 0xffff; |
1061 | prop_text_in.foreground->green = 0xffff; |
1062 | prop_text_in.foreground->blue = 0xffff; |
1063 | } |
1064 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
1065 | { |
1066 | prop_text_in.foreground->red = 0x0fff; |
d52cfc84 |
1067 | prop_text_in.foreground->green = 0xffff; |
1068 | prop_text_in.foreground->blue = 0xfff0; |
cfe526b1 |
1069 | } |
1070 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
1071 | { |
2df6f2bd |
1072 | prop_text_in.foreground->red = 0xffff; |
1073 | prop_text_in.foreground->green = 0xffff; |
cfe526b1 |
1074 | prop_text_in.foreground->blue = 0x0000; |
1075 | } |
1076 | else if(process_in->state->s == LTTV_STATE_EXIT) |
1077 | { |
1078 | prop_text_in.foreground->red = 0xffff; |
1079 | prop_text_in.foreground->green = 0x0000; |
1080 | prop_text_in.foreground->blue = 0xffff; |
1081 | } |
1082 | else if(process_in->state->s == LTTV_STATE_WAIT) |
1083 | { |
1084 | prop_text_in.foreground->red = 0xffff; |
1085 | prop_text_in.foreground->green = 0x0000; |
1086 | prop_text_in.foreground->blue = 0x0000; |
1087 | } |
1088 | else if(process_in->state->s == LTTV_STATE_RUN) |
1089 | { |
1090 | prop_text_in.foreground->red = 0x0000; |
1091 | prop_text_in.foreground->green = 0xffff; |
1092 | prop_text_in.foreground->blue = 0x0000; |
1093 | } |
1094 | else |
1095 | { |
1096 | prop_text_in.foreground->red = 0xffff; |
1097 | prop_text_in.foreground->green = 0xffff; |
1098 | prop_text_in.foreground->blue = 0xffff; |
1099 | } |
1100 | |
1101 | |
a56a1ba4 |
1102 | /* Print status of the process : U, WF, WC, E, W, R */ |
1103 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
68997a22 |
1104 | prop_text_in.text = "U"; |
a56a1ba4 |
1105 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
68997a22 |
1106 | prop_text_in.text = "WF"; |
a56a1ba4 |
1107 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
68997a22 |
1108 | prop_text_in.text = "WC"; |
a56a1ba4 |
1109 | else if(process_in->state->s == LTTV_STATE_EXIT) |
68997a22 |
1110 | prop_text_in.text = "E"; |
a56a1ba4 |
1111 | else if(process_in->state->s == LTTV_STATE_WAIT) |
68997a22 |
1112 | prop_text_in.text = "W"; |
a56a1ba4 |
1113 | else if(process_in->state->s == LTTV_STATE_RUN) |
68997a22 |
1114 | prop_text_in.text = "R"; |
a56a1ba4 |
1115 | else |
68997a22 |
1116 | prop_text_in.text = "U"; |
a56a1ba4 |
1117 | |
1118 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
1119 | |
d0cd7f09 |
1120 | |
319e9d81 |
1121 | if(process_in->state->s == LTTV_STATE_RUN) |
1122 | { |
1123 | gchar tmp[255]; |
1124 | prop_text_in.foreground = &colorfg_in; |
1125 | prop_text_in.background = &colorbg_in; |
1126 | prop_text_in.foreground->red = 0xffff; |
1127 | prop_text_in.foreground->green = 0xffff; |
1128 | prop_text_in.foreground->blue = 0xffff; |
1129 | prop_text_in.size = 6; |
1130 | prop_text_in.position = UNDER; |
1131 | |
1132 | prop_text_in.text = g_new(gchar, 260); |
1133 | strcpy(prop_text_in.text, "CPU "); |
1134 | snprintf(tmp, 255, "%u", tfc->index); |
1135 | strcat(prop_text_in.text, tmp); |
1136 | |
1137 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
1138 | g_free(prop_text_in.text); |
1139 | } |
1140 | |
1141 | |
68997a22 |
1142 | draw_context_in->current->middle->y = y_in+height/2; |
d0cd7f09 |
1143 | draw_context_in->current->over->y = y_in; |
1144 | draw_context_in->current->under->y = y_in+height; |
68997a22 |
1145 | draw_context_in->current->status = process_in->state->s; |
1146 | |
1147 | /* for pid_in : remove previous, Prev = current, new current (default) */ |
1148 | g_free(draw_context_in->previous->modify_under); |
1149 | g_free(draw_context_in->previous->modify_middle); |
1150 | g_free(draw_context_in->previous->modify_over); |
1151 | g_free(draw_context_in->previous->under); |
1152 | g_free(draw_context_in->previous->middle); |
1153 | g_free(draw_context_in->previous->over); |
1154 | g_free(draw_context_in->previous); |
1155 | |
1156 | draw_context_in->previous = draw_context_in->current; |
a56a1ba4 |
1157 | |
68997a22 |
1158 | draw_context_in->current = g_new(DrawInfo,1); |
1159 | draw_context_in->current->over = g_new(ItemInfo,1); |
1160 | draw_context_in->current->over->x = -1; |
1161 | draw_context_in->current->over->y = -1; |
1162 | draw_context_in->current->middle = g_new(ItemInfo,1); |
1163 | draw_context_in->current->middle->x = -1; |
1164 | draw_context_in->current->middle->y = -1; |
1165 | draw_context_in->current->under = g_new(ItemInfo,1); |
1166 | draw_context_in->current->under->x = -1; |
1167 | draw_context_in->current->under->y = -1; |
1168 | draw_context_in->current->modify_over = g_new(ItemInfo,1); |
1169 | draw_context_in->current->modify_over->x = -1; |
1170 | draw_context_in->current->modify_over->y = -1; |
1171 | draw_context_in->current->modify_middle = g_new(ItemInfo,1); |
1172 | draw_context_in->current->modify_middle->x = -1; |
1173 | draw_context_in->current->modify_middle->y = -1; |
1174 | draw_context_in->current->modify_under = g_new(ItemInfo,1); |
1175 | draw_context_in->current->modify_under->x = -1; |
1176 | draw_context_in->current->modify_under->y = -1; |
1177 | draw_context_in->current->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1178 | |
1179 | } |
1180 | |
1181 | return 0; |
f0d936c0 |
1182 | } |
f7afe191 |
1183 | |
1184 | |
1185 | |
1186 | |
1b238973 |
1187 | gint update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
1188 | { |
a56a1ba4 |
1189 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
a43d67ba |
1190 | Drawing_t *drawing = control_flow_data->drawing; |
1191 | |
224446ce |
1192 | const TimeWindowNotifyData *time_window_nofify_data = |
1193 | ((const TimeWindowNotifyData *)call_data); |
1194 | |
14963be0 |
1195 | TimeWindow *old_time_window = |
224446ce |
1196 | time_window_nofify_data->old_time_window; |
1197 | TimeWindow *new_time_window = |
1198 | time_window_nofify_data->new_time_window; |
a56a1ba4 |
1199 | |
3cb8b205 |
1200 | /* Update the ruler */ |
1201 | drawing_update_ruler(control_flow_data->drawing, |
1202 | new_time_window); |
1203 | |
1204 | |
a56a1ba4 |
1205 | /* Two cases : zoom in/out or scrolling */ |
1206 | |
1207 | /* In order to make sure we can reuse the old drawing, the scale must |
1208 | * be the same and the new time interval being partly located in the |
1209 | * currently shown time interval. (reuse is only for scrolling) |
1210 | */ |
1211 | |
1212 | g_info("Old time window HOOK : %u, %u to %u, %u", |
14963be0 |
1213 | old_time_window->start_time.tv_sec, |
1214 | old_time_window->start_time.tv_nsec, |
1215 | old_time_window->time_width.tv_sec, |
1216 | old_time_window->time_width.tv_nsec); |
a56a1ba4 |
1217 | |
1218 | g_info("New time window HOOK : %u, %u to %u, %u", |
14963be0 |
1219 | new_time_window->start_time.tv_sec, |
1220 | new_time_window->start_time.tv_nsec, |
1221 | new_time_window->time_width.tv_sec, |
1222 | new_time_window->time_width.tv_nsec); |
a56a1ba4 |
1223 | |
14963be0 |
1224 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
1225 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) |
a56a1ba4 |
1226 | { |
1227 | /* Same scale (scrolling) */ |
1228 | g_info("scrolling"); |
14963be0 |
1229 | LttTime *ns = &new_time_window->start_time; |
1230 | LttTime *os = &old_time_window->start_time; |
1231 | LttTime old_end = ltt_time_add(old_time_window->start_time, |
1232 | old_time_window->time_width); |
1233 | LttTime new_end = ltt_time_add(new_time_window->start_time, |
1234 | new_time_window->time_width); |
a56a1ba4 |
1235 | //if(ns<os+w<ns+w) |
1236 | //if(ns<os+w && os+w<ns+w) |
1237 | //if(ns<old_end && os<ns) |
1238 | if(ltt_time_compare(*ns, old_end) == -1 |
1239 | && ltt_time_compare(*os, *ns) == -1) |
1240 | { |
1241 | g_info("scrolling near right"); |
1242 | /* Scroll right, keep right part of the screen */ |
1243 | guint x = 0; |
501d5405 |
1244 | guint width = control_flow_data->drawing->drawing_area->allocation.width; |
a56a1ba4 |
1245 | convert_time_to_pixels( |
1246 | *os, |
1247 | old_end, |
1248 | *ns, |
1249 | width, |
1250 | &x); |
1251 | |
1252 | /* Copy old data to new location */ |
501d5405 |
1253 | gdk_draw_drawable (control_flow_data->drawing->pixmap, |
cfe526b1 |
1254 | control_flow_data->drawing->drawing_area->style->black_gc, |
501d5405 |
1255 | control_flow_data->drawing->pixmap, |
a56a1ba4 |
1256 | x, 0, |
1257 | 0, 0, |
1258 | -1, -1); |
1259 | |
a56a1ba4 |
1260 | /* Clear the data request background, but not SAFETY */ |
501d5405 |
1261 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
cfe526b1 |
1262 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
1263 | TRUE, |
1264 | x+SAFETY, 0, |
501d5405 |
1265 | control_flow_data->drawing->width - x, // do not overlap |
1266 | control_flow_data->drawing->height+SAFETY); |
a43d67ba |
1267 | |
1268 | gtk_widget_queue_draw_area (drawing->drawing_area, |
1269 | 0,0, |
1270 | control_flow_data->drawing->width - x, |
1271 | control_flow_data->drawing->height); |
1272 | |
a56a1ba4 |
1273 | /* Get new data for the rest. */ |
501d5405 |
1274 | drawing_data_request(control_flow_data->drawing, |
1275 | &control_flow_data->drawing->pixmap, |
a56a1ba4 |
1276 | x, 0, |
501d5405 |
1277 | control_flow_data->drawing->width - x, |
1278 | control_flow_data->drawing->height); |
a56a1ba4 |
1279 | |
a56a1ba4 |
1280 | } else { |
1281 | //if(ns<os<ns+w) |
1282 | //if(ns<os && os<ns+w) |
1283 | //if(ns<os && os<new_end) |
1284 | if(ltt_time_compare(*ns,*os) == -1 |
1285 | && ltt_time_compare(*os,new_end) == -1) |
1286 | { |
1287 | g_info("scrolling near left"); |
1288 | /* Scroll left, keep left part of the screen */ |
1289 | guint x = 0; |
501d5405 |
1290 | guint width = control_flow_data->drawing->drawing_area->allocation.width; |
a56a1ba4 |
1291 | convert_time_to_pixels( |
1292 | *ns, |
1293 | new_end, |
1294 | *os, |
1295 | width, |
1296 | &x); |
1297 | |
1298 | /* Copy old data to new location */ |
501d5405 |
1299 | gdk_draw_drawable (control_flow_data->drawing->pixmap, |
cfe526b1 |
1300 | control_flow_data->drawing->drawing_area->style->black_gc, |
501d5405 |
1301 | control_flow_data->drawing->pixmap, |
a56a1ba4 |
1302 | 0, 0, |
1303 | x, 0, |
1304 | -1, -1); |
1305 | |
a43d67ba |
1306 | *old_time_window = *new_time_window; |
a56a1ba4 |
1307 | |
1308 | /* Clean the data request background */ |
501d5405 |
1309 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
cfe526b1 |
1310 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
1311 | TRUE, |
1312 | 0, 0, |
1313 | x, // do not overlap |
501d5405 |
1314 | control_flow_data->drawing->height+SAFETY); |
a43d67ba |
1315 | |
1316 | gtk_widget_queue_draw_area (drawing->drawing_area, |
1317 | x,0, |
1318 | control_flow_data->drawing->width - x, |
1319 | control_flow_data->drawing->height); |
1320 | |
a56a1ba4 |
1321 | /* Get new data for the rest. */ |
501d5405 |
1322 | drawing_data_request(control_flow_data->drawing, |
1323 | &control_flow_data->drawing->pixmap, |
a56a1ba4 |
1324 | 0, 0, |
1325 | x, |
501d5405 |
1326 | control_flow_data->drawing->height); |
a56a1ba4 |
1327 | |
a56a1ba4 |
1328 | } else { |
a43d67ba |
1329 | if(ltt_time_compare(*ns,*os) == 0) |
1330 | { |
1331 | g_info("not scrolling"); |
1332 | } else { |
1333 | g_info("scrolling far"); |
1334 | /* Cannot reuse any part of the screen : far jump */ |
1335 | |
1336 | |
1337 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
1338 | control_flow_data->drawing->drawing_area->style->black_gc, |
1339 | TRUE, |
a56a1ba4 |
1340 | 0, 0, |
a43d67ba |
1341 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1342 | control_flow_data->drawing->height+SAFETY); |
1343 | |
1344 | gtk_widget_queue_draw_area (drawing->drawing_area, |
1345 | 0,0, |
1346 | control_flow_data->drawing->width, |
1347 | control_flow_data->drawing->height); |
1348 | |
1349 | drawing_data_request(control_flow_data->drawing, |
1350 | &control_flow_data->drawing->pixmap, |
1351 | 0, 0, |
1352 | control_flow_data->drawing->width, |
1353 | control_flow_data->drawing->height); |
1354 | |
1355 | } |
a56a1ba4 |
1356 | } |
1357 | } |
1358 | } else { |
1359 | /* Different scale (zoom) */ |
1360 | g_info("zoom"); |
1361 | |
501d5405 |
1362 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
cfe526b1 |
1363 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
1364 | TRUE, |
1365 | 0, 0, |
501d5405 |
1366 | control_flow_data->drawing->width+SAFETY, // do not overlap |
1367 | control_flow_data->drawing->height+SAFETY); |
a56a1ba4 |
1368 | |
a43d67ba |
1369 | gtk_widget_queue_draw_area (drawing->drawing_area, |
1370 | 0,0, |
1371 | control_flow_data->drawing->width, |
1372 | control_flow_data->drawing->height); |
a56a1ba4 |
1373 | |
501d5405 |
1374 | drawing_data_request(control_flow_data->drawing, |
1375 | &control_flow_data->drawing->pixmap, |
a56a1ba4 |
1376 | 0, 0, |
501d5405 |
1377 | control_flow_data->drawing->width, |
1378 | control_flow_data->drawing->height); |
a56a1ba4 |
1379 | |
a56a1ba4 |
1380 | } |
1381 | |
3cb8b205 |
1382 | |
1383 | |
a56a1ba4 |
1384 | return 0; |
f7afe191 |
1385 | } |
1386 | |
a43d67ba |
1387 | gint after_process_traceset_hook(void *hook_data, void *call_data) |
1388 | { |
1389 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
1390 | TimeRequest *time_request = (TimeRequest *)call_data; |
1391 | |
1392 | drawing_data_request_end(control_flow_data->drawing, |
1393 | time_request->time_window); |
1394 | return 0; |
1395 | } |
1396 | |
1397 | |
1398 | |
1b238973 |
1399 | gint update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
1400 | { |
14963be0 |
1401 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
a43d67ba |
1402 | Drawing_t *drawing = control_flow_data->drawing; |
a56a1ba4 |
1403 | |
224446ce |
1404 | LttTime current_time = *((LttTime*)call_data); |
a56a1ba4 |
1405 | |
224446ce |
1406 | const TimeWindow *time_window = |
1407 | lttvwindow_get_time_window(control_flow_data->mw); |
a56a1ba4 |
1408 | |
224446ce |
1409 | LttTime time_begin = time_window->start_time; |
1410 | LttTime width = time_window->time_width; |
a56a1ba4 |
1411 | LttTime half_width = ltt_time_div(width,2.0); |
1412 | LttTime time_end = ltt_time_add(time_begin, width); |
1413 | |
1414 | LttvTracesetContext * tsc = |
224446ce |
1415 | lttvwindow_get_traceset_context(control_flow_data->mw); |
a56a1ba4 |
1416 | |
1417 | LttTime trace_start = tsc->Time_Span->startTime; |
1418 | LttTime trace_end = tsc->Time_Span->endTime; |
1419 | |
224446ce |
1420 | g_info("New current time HOOK : %u, %u", current_time.tv_sec, |
1421 | current_time.tv_nsec); |
a56a1ba4 |
1422 | |
1423 | |
1424 | |
1425 | /* If current time is inside time interval, just move the highlight |
1426 | * bar */ |
1427 | |
1428 | /* Else, we have to change the time interval. We have to tell it |
1429 | * to the main window. */ |
1430 | /* The time interval change will take care of placing the current |
1431 | * time at the center of the visible area, or nearest possible if we are |
1432 | * at one end of the trace. */ |
1433 | |
1434 | |
224446ce |
1435 | if(ltt_time_compare(current_time, time_begin) == -1) |
a56a1ba4 |
1436 | { |
224446ce |
1437 | TimeWindow new_time_window; |
1438 | |
1439 | if(ltt_time_compare(current_time, |
a56a1ba4 |
1440 | ltt_time_add(trace_start,half_width)) == -1) |
1441 | time_begin = trace_start; |
1442 | else |
224446ce |
1443 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
1444 | |
224446ce |
1445 | new_time_window.start_time = time_begin; |
1446 | new_time_window.time_width = width; |
a56a1ba4 |
1447 | |
224446ce |
1448 | lttvwindow_report_time_window(control_flow_data->mw, &new_time_window); |
a56a1ba4 |
1449 | } |
224446ce |
1450 | else if(ltt_time_compare(current_time, time_end) == 1) |
a56a1ba4 |
1451 | { |
224446ce |
1452 | TimeWindow new_time_window; |
1453 | |
1454 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) == 1) |
a56a1ba4 |
1455 | time_begin = ltt_time_sub(trace_end,width); |
1456 | else |
224446ce |
1457 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
1458 | |
224446ce |
1459 | new_time_window.start_time = time_begin; |
1460 | new_time_window.time_width = width; |
a56a1ba4 |
1461 | |
224446ce |
1462 | lttvwindow_report_time_window(control_flow_data->mw, &new_time_window); |
a56a1ba4 |
1463 | |
1464 | } |
a43d67ba |
1465 | //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
1466 | gtk_widget_queue_draw_area(drawing->drawing_area, |
1467 | 0,0, |
1468 | drawing->width, |
1469 | drawing->height); |
a56a1ba4 |
1470 | |
1471 | return 0; |
f7afe191 |
1472 | } |
1473 | |
8b90e648 |
1474 | typedef struct _ClosureData { |
a56a1ba4 |
1475 | EventRequest *event_request; |
d0cd7f09 |
1476 | LttvTracesetState *tss; |
8b90e648 |
1477 | } ClosureData; |
a56a1ba4 |
1478 | |
8b90e648 |
1479 | |
1480 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
1481 | { |
a56a1ba4 |
1482 | ProcessInfo *process_info = (ProcessInfo*)key; |
1483 | HashedProcessData *hashed_process_data = (HashedProcessData*)value; |
1484 | ClosureData *closure_data = (ClosureData*)user_data; |
1485 | |
1486 | ControlFlowData *control_flow_data = |
68997a22 |
1487 | closure_data->event_request->control_flow_data; |
a56a1ba4 |
1488 | |
501d5405 |
1489 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1490 | |
1491 | /* Get y position of process */ |
1492 | gint y=0, height=0; |
1493 | |
ba90bc77 |
1494 | processlist_get_pixels_from_data( control_flow_data->process_list, |
a56a1ba4 |
1495 | process_info, |
1496 | hashed_process_data, |
1497 | &y, |
1498 | &height); |
1499 | /* Get last state of process */ |
1500 | LttvTraceContext *tc = |
d0cd7f09 |
1501 | ((LttvTracesetContext*)closure_data->tss)->traces[process_info->trace_num]; |
1502 | //LttvTracefileContext *tfc = (LttvTracefileContext *)closure_data->ts; |
8b90e648 |
1503 | |
d0cd7f09 |
1504 | LttvTraceState *ts = (LttvTraceState*)tc; |
a56a1ba4 |
1505 | LttvProcessState *process; |
1506 | |
2a2fa4f0 |
1507 | /* We do not provide a cpu_name argument assuming that this is not the |
1508 | idle job (pid 0) and thus its pid is unique across all cpus */ |
1509 | process = lttv_state_find_process_from_trace(ts, 0, process_info->pid); |
a56a1ba4 |
1510 | |
1511 | /* Draw the closing line */ |
1512 | DrawContext *draw_context = hashed_process_data->draw_context; |
68997a22 |
1513 | if(draw_context->previous->middle->x == -1) |
a56a1ba4 |
1514 | { |
68997a22 |
1515 | draw_context->previous->middle->x = closure_data->event_request->x_begin; |
d0cd7f09 |
1516 | draw_context->previous->over->x = closure_data->event_request->x_begin; |
1517 | draw_context->previous->under->x = closure_data->event_request->x_begin; |
2a2fa4f0 |
1518 | g_debug("out middle x_beg : %u",closure_data->event_request->x_begin); |
a56a1ba4 |
1519 | } |
1520 | |
68997a22 |
1521 | draw_context->current->middle->x = closure_data->event_request->x_end; |
d0cd7f09 |
1522 | draw_context->current->over->x = closure_data->event_request->x_end; |
1523 | draw_context->current->under->x = closure_data->event_request->x_end; |
68997a22 |
1524 | draw_context->current->middle->y = y + height/2; |
d0cd7f09 |
1525 | draw_context->current->over->y = y ; |
1526 | draw_context->current->under->y = y + height; |
68997a22 |
1527 | draw_context->previous->middle->y = y + height/2; |
d0cd7f09 |
1528 | draw_context->previous->over->y = y ; |
1529 | draw_context->previous->under->y = y + height; |
501d5405 |
1530 | draw_context->drawable = control_flow_data->drawing->pixmap; |
1531 | draw_context->pango_layout = control_flow_data->drawing->pango_layout; |
a56a1ba4 |
1532 | //draw_context->gc = widget->style->black_gc; |
501d5405 |
1533 | draw_context->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
a56a1ba4 |
1534 | gdk_gc_copy(draw_context->gc, widget->style->black_gc); |
d0cd7f09 |
1535 | |
ad2e83ba |
1536 | if(process != NULL && process->state->s == LTTV_STATE_RUN) |
d0cd7f09 |
1537 | { |
1538 | PropertiesBG prop_bg; |
1539 | prop_bg.color = g_new(GdkColor,1); |
1540 | |
1541 | /*switch(tfc->index) { |
1542 | case 0: |
1543 | prop_bg.color->red = 0x1515; |
1544 | prop_bg.color->green = 0x1515; |
1545 | prop_bg.color->blue = 0x8c8c; |
1546 | break; |
1547 | case 1: |
1548 | prop_bg.color->red = 0x4e4e; |
1549 | prop_bg.color->green = 0xa9a9; |
1550 | prop_bg.color->blue = 0xa4a4; |
1551 | break; |
1552 | case 2: |
1553 | prop_bg.color->red = 0x7a7a; |
1554 | prop_bg.color->green = 0x4a4a; |
1555 | prop_bg.color->blue = 0x8b8b; |
1556 | break; |
1557 | case 3: |
1558 | prop_bg.color->red = 0x8080; |
1559 | prop_bg.color->green = 0x7777; |
1560 | prop_bg.color->blue = 0x4747; |
1561 | break; |
1562 | default: |
1563 | prop_bg.color->red = 0xe7e7; |
1564 | prop_bg.color->green = 0xe7e7; |
1565 | prop_bg.color->blue = 0xe7e7; |
1566 | } |
1567 | */ |
1568 | |
2a2fa4f0 |
1569 | g_debug("calling from closure"); |
d0cd7f09 |
1570 | //FIXME : I need the cpu number in process's state to draw this. |
1571 | //draw_bg((void*)&prop_bg, (void*)draw_context); |
1572 | g_free(prop_bg.color); |
1573 | } |
1574 | |
a56a1ba4 |
1575 | |
1576 | PropertiesLine prop_line; |
1577 | prop_line.color = g_new(GdkColor,1); |
cfe526b1 |
1578 | prop_line.line_width = 2; |
a56a1ba4 |
1579 | prop_line.style = GDK_LINE_SOLID; |
1580 | prop_line.position = MIDDLE; |
1581 | |
1582 | /* color of line : status of the process */ |
ad2e83ba |
1583 | if(process != NULL) |
a56a1ba4 |
1584 | { |
ad2e83ba |
1585 | if(process->state->s == LTTV_STATE_UNNAMED) |
1586 | { |
1587 | prop_line.color->red = 0xffff; |
1588 | prop_line.color->green = 0xffff; |
1589 | prop_line.color->blue = 0xffff; |
1590 | } |
1591 | else if(process->state->s == LTTV_STATE_WAIT_FORK) |
1592 | { |
1593 | prop_line.color->red = 0x0fff; |
1594 | prop_line.color->green = 0xffff; |
1595 | prop_line.color->blue = 0xfff0; |
1596 | } |
1597 | else if(process->state->s == LTTV_STATE_WAIT_CPU) |
1598 | { |
1599 | prop_line.color->red = 0xffff; |
1600 | prop_line.color->green = 0xffff; |
1601 | prop_line.color->blue = 0x0000; |
1602 | } |
1603 | else if(process->state->s == LTTV_STATE_EXIT) |
1604 | { |
1605 | prop_line.color->red = 0xffff; |
1606 | prop_line.color->green = 0x0000; |
1607 | prop_line.color->blue = 0xffff; |
1608 | } |
1609 | else if(process->state->s == LTTV_STATE_WAIT) |
1610 | { |
1611 | prop_line.color->red = 0xffff; |
1612 | prop_line.color->green = 0x0000; |
1613 | prop_line.color->blue = 0x0000; |
1614 | } |
1615 | else if(process->state->s == LTTV_STATE_RUN) |
1616 | { |
1617 | prop_line.color->red = 0x0000; |
1618 | prop_line.color->green = 0xffff; |
1619 | prop_line.color->blue = 0x0000; |
1620 | } |
1621 | else |
1622 | { |
1623 | prop_line.color->red = 0xffff; |
1624 | prop_line.color->green = 0xffff; |
1625 | prop_line.color->blue = 0xffff; |
1626 | } |
1627 | |
a56a1ba4 |
1628 | } |
1629 | else |
1630 | { |
ad2e83ba |
1631 | prop_line.color->red = 0xffff; |
1632 | prop_line.color->green = 0xffff; |
1633 | prop_line.color->blue = 0xffff; |
a56a1ba4 |
1634 | } |
1635 | |
1636 | draw_line((void*)&prop_line, (void*)draw_context); |
1637 | g_free(prop_line.color); |
1638 | gdk_gc_unref(draw_context->gc); |
1639 | |
1640 | /* Reset draw_context of the process for next request */ |
1641 | |
1642 | hashed_process_data->draw_context->drawable = NULL; |
1643 | hashed_process_data->draw_context->gc = NULL; |
1644 | hashed_process_data->draw_context->pango_layout = NULL; |
68997a22 |
1645 | hashed_process_data->draw_context->current->over->x = -1; |
1646 | hashed_process_data->draw_context->current->over->y = -1; |
1647 | hashed_process_data->draw_context->current->middle->x = -1; |
1648 | hashed_process_data->draw_context->current->middle->y = -1; |
1649 | hashed_process_data->draw_context->current->under->x = -1; |
1650 | hashed_process_data->draw_context->current->under->y = -1; |
1651 | hashed_process_data->draw_context->current->modify_over->x = -1; |
1652 | hashed_process_data->draw_context->current->modify_over->y = -1; |
1653 | hashed_process_data->draw_context->current->modify_middle->x = -1; |
1654 | hashed_process_data->draw_context->current->modify_middle->y = -1; |
1655 | hashed_process_data->draw_context->current->modify_under->x = -1; |
1656 | hashed_process_data->draw_context->current->modify_under->y = -1; |
1657 | hashed_process_data->draw_context->current->status = LTTV_STATE_UNNAMED; |
1658 | hashed_process_data->draw_context->previous->over->x = -1; |
1659 | hashed_process_data->draw_context->previous->over->y = -1; |
1660 | hashed_process_data->draw_context->previous->middle->x = -1; |
1661 | hashed_process_data->draw_context->previous->middle->y = -1; |
1662 | hashed_process_data->draw_context->previous->under->x = -1; |
1663 | hashed_process_data->draw_context->previous->under->y = -1; |
1664 | hashed_process_data->draw_context->previous->modify_over->x = -1; |
1665 | hashed_process_data->draw_context->previous->modify_over->y = -1; |
1666 | hashed_process_data->draw_context->previous->modify_middle->x = -1; |
1667 | hashed_process_data->draw_context->previous->modify_middle->y = -1; |
1668 | hashed_process_data->draw_context->previous->modify_under->x = -1; |
1669 | hashed_process_data->draw_context->previous->modify_under->y = -1; |
1670 | hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1671 | |
8b90e648 |
1672 | |
1673 | } |
1674 | |
1675 | /* |
1676 | * for each process |
a56a1ba4 |
1677 | * draw closing line |
1678 | * new default prev and current |
a43d67ba |
1679 | * then finally remove reading hooks. |
8b90e648 |
1680 | */ |
1681 | int after_data_request(void *hook_data, void *call_data) |
1682 | { |
14963be0 |
1683 | EventRequest *event_request = (EventRequest*)hook_data; |
1684 | ControlFlowData *control_flow_data = event_request->control_flow_data; |
a56a1ba4 |
1685 | |
1686 | ProcessList *process_list = |
14963be0 |
1687 | guicontrolflow_get_process_list(event_request->control_flow_data); |
a56a1ba4 |
1688 | |
1689 | ClosureData closure_data; |
1690 | closure_data.event_request = (EventRequest*)hook_data; |
d0cd7f09 |
1691 | closure_data.tss = (LttvTracesetState*)call_data; |
a56a1ba4 |
1692 | |
14963be0 |
1693 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
a56a1ba4 |
1694 | (void*)&closure_data); |
a43d67ba |
1695 | |
1696 | /* Remove reading hooks */ |
1697 | // Cannot do this here, will break processtrace! |
1698 | //drawing_data_request_end(control_flow_data->drawing); |
a56a1ba4 |
1699 | |
8b90e648 |
1700 | } |
1701 | |