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