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