ce0214a6 |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2003-2004 Mathieu Desnoyers |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License Version 2 as |
6 | * published by the Free Software Foundation; |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
16 | * MA 02111-1307, USA. |
17 | */ |
18 | |
19 | |
f0d936c0 |
20 | /***************************************************************************** |
21 | * Hooks to be called by the main window * |
22 | *****************************************************************************/ |
23 | |
f0d936c0 |
24 | |
b9a010a2 |
25 | /* Event hooks are the drawing hooks called during traceset read. They draw the |
26 | * icons, text, lines and background color corresponding to the events read. |
27 | * |
28 | * Two hooks are used for drawing : draw_before and draw_after hooks. The |
29 | * draw_before is called before the state update that occurs with an event and |
30 | * the draw_after hook is called after this state update. |
31 | * |
32 | * The draw_before hooks fulfill the task of drawing the visible objects that |
33 | * corresponds to the data accumulated by the draw_after hook. |
34 | * |
35 | * The draw_after hook accumulates the data that need to be shown on the screen |
36 | * (items) into a queue. Then, the next draw_before hook will draw what that |
37 | * queue contains. That's the Right Way (TM) of drawing items on the screen, |
38 | * because we need to draw the background first (and then add icons, text, ... |
39 | * over it), but we only know the length of a background region once the state |
40 | * corresponding to it is over, which happens to be at the next draw_before |
41 | * hook. |
42 | * |
43 | * We also have a hook called at the end of a chunk to draw the information left |
44 | * undrawn in each process queue. We use the current time as end of |
45 | * line/background. |
46 | */ |
47 | |
48 | |
cf6cb7e0 |
49 | //#define PANGO_ENABLE_BACKEND |
558aa013 |
50 | #include <gtk/gtk.h> |
51 | #include <gdk/gdk.h> |
5f16133f |
52 | #include <glib.h> |
80a52ff8 |
53 | #include <assert.h> |
50439712 |
54 | #include <string.h> |
319e9d81 |
55 | #include <stdio.h> |
5f16133f |
56 | |
cf6cb7e0 |
57 | //#include <pango/pango.h> |
58 | |
80a52ff8 |
59 | #include <ltt/event.h> |
4ba42155 |
60 | #include <ltt/time.h> |
50439712 |
61 | #include <ltt/type.h> |
80a52ff8 |
62 | |
2a2fa4f0 |
63 | #include <lttv/lttv.h> |
558aa013 |
64 | #include <lttv/hook.h> |
80a52ff8 |
65 | #include <lttv/state.h> |
2d262115 |
66 | #include <lttvwindow/lttvwindow.h> |
6395d57c |
67 | #include <lttvwindow/lttvwindowtraces.h> |
80a52ff8 |
68 | |
f0d936c0 |
69 | |
a117e3f7 |
70 | #include "eventhooks.h" |
71 | #include "cfv.h" |
72 | #include "processlist.h" |
73 | #include "drawing.h" |
74 | #include "cfv-private.h" |
5f16133f |
75 | |
80a52ff8 |
76 | |
1a31868c |
77 | #define MAX_PATH_LEN 256 |
78 | |
f0d936c0 |
79 | |
b9a010a2 |
80 | #if 0 |
81 | typedef struct _ProcessAddClosure { |
82 | ControlFlowData *cfd; |
83 | guint trace_num; |
84 | } ProcessAddClosure; |
85 | |
86 | static void process_add(gpointer key, |
87 | gpointer value, |
88 | gpointer user_data) |
89 | { |
90 | LttvProcessState *process = (LttvProcessState*)value; |
91 | ProcessAddClosure *closure = (ProcessAddClosure*)user_data; |
92 | ControlFlowData *control_flow_data = closure->cfd; |
93 | guint trace_num = closure->trace_num; |
94 | |
95 | /* Add process to process list (if not present) */ |
96 | guint pid; |
97 | LttTime birth; |
98 | guint y = 0, height = 0, pl_height = 0; |
99 | |
100 | ProcessList *process_list = |
101 | guicontrolflow_get_process_list(control_flow_data); |
102 | |
103 | pid = process->pid; |
104 | birth = process->creation_time; |
105 | const gchar *name = g_quark_to_string(process->name); |
106 | HashedProcessData *hashed_process_data = NULL; |
107 | |
108 | if(processlist_get_process_pixels(process_list, |
109 | pid, |
110 | &birth, |
111 | trace_num, |
112 | &y, |
113 | &height, |
114 | &hashed_process_data) == 1) |
115 | { |
116 | /* Process not present */ |
117 | processlist_add(process_list, |
118 | pid, |
119 | &birth, |
120 | trace_num, |
121 | name, |
122 | &pl_height, |
123 | &hashed_process_data); |
124 | processlist_get_process_pixels(process_list, |
125 | pid, |
126 | &birth, |
127 | trace_num, |
128 | &y, |
129 | &height, |
130 | &hashed_process_data); |
131 | drawing_insert_square( control_flow_data->drawing, y, height); |
132 | } |
133 | } |
134 | #endif //0 |
135 | |
136 | |
6395d57c |
137 | /* Action to do when background computation completed. |
138 | * |
139 | * Eventually, will have to check that every requested traces are finished |
b9a010a2 |
140 | * before doing the redraw. It will save unnecessary processor usage. |
6395d57c |
141 | */ |
142 | |
143 | gint background_ready(void *hook_data, void *call_data) |
144 | { |
145 | ControlFlowData *control_flow_data = (ControlFlowData *)hook_data; |
146 | LttvTrace *trace = (LttvTrace*)call_data; |
b9a010a2 |
147 | LttvTracesetContext *tsc = |
148 | lttvwindow_get_traceset_context(control_flow_data->tab); |
6395d57c |
149 | |
150 | g_debug("control flow viewer : background computation data ready."); |
151 | |
b9a010a2 |
152 | drawing_clear(control_flow_data->drawing); |
153 | processlist_clear(control_flow_data->process_list); |
154 | #if 0 |
155 | { |
156 | gint num_traces = lttv_traceset_number(tsc->ts); |
157 | gint i; |
158 | LttvTraceState *ts; |
159 | ProcessAddClosure closure; |
160 | closure.cfd = control_flow_data; |
161 | |
162 | for(i=0;i<num_traces;i++) { |
163 | ts = (LttvTraceState*)tsc->traces[i]; |
164 | |
165 | closure.trace_num = i; |
166 | |
167 | /* add all the processes to the list */ |
168 | lttv_state_for_each_process(ts, (GHFunc)process_add, &closure); |
169 | } |
170 | } |
171 | #endif //0 |
6395d57c |
172 | redraw_notify(control_flow_data, NULL); |
173 | |
174 | return 0; |
175 | } |
176 | |
177 | |
178 | /* Request background computation. Verify if it is in progress or ready first. |
179 | * |
180 | * Right now, for all loaded traces. |
181 | * |
182 | * Later : must be only for each trace in the tab's traceset. |
183 | */ |
184 | void request_background_data(ControlFlowData *control_flow_data) |
185 | { |
186 | gint num_traces = lttvwindowtraces_get_number(); |
187 | gint i; |
188 | LttvTrace *trace; |
189 | |
190 | LttvHooks *background_ready_hook = |
191 | lttv_hooks_new(); |
192 | lttv_hooks_add(background_ready_hook, background_ready, control_flow_data, |
193 | LTTV_PRIO_DEFAULT); |
194 | |
195 | for(i=0;i<num_traces;i++) { |
196 | trace = lttvwindowtraces_get_trace(i); |
197 | |
198 | if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE) { |
199 | |
200 | if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"), |
201 | trace) == FALSE) { |
202 | /* We first remove requests that could have been done for the same |
203 | * information. Happens when two viewers ask for it before servicing |
204 | * starts. |
205 | */ |
206 | lttvwindowtraces_background_request_remove(trace, "state"); |
207 | lttvwindowtraces_background_request_queue(trace, |
208 | "state"); |
209 | lttvwindowtraces_background_notify_queue(control_flow_data, |
210 | trace, |
211 | ltt_time_infinite, |
212 | NULL, |
213 | background_ready_hook); |
214 | } else { /* in progress */ |
215 | |
216 | lttvwindowtraces_background_notify_current(control_flow_data, |
217 | trace, |
218 | ltt_time_infinite, |
219 | NULL, |
220 | background_ready_hook); |
221 | |
222 | } |
223 | } |
224 | } |
225 | |
226 | lttv_hooks_destroy(background_ready_hook); |
227 | } |
228 | |
229 | |
230 | |
231 | |
f0d936c0 |
232 | /** |
233 | * Event Viewer's constructor hook |
234 | * |
235 | * This constructor is given as a parameter to the menuitem and toolbar button |
236 | * registration. It creates the list. |
ca0f8a8e |
237 | * @param tab A pointer to the parent tab. |
f0d936c0 |
238 | * @return The widget created. |
239 | */ |
240 | GtkWidget * |
ca0f8a8e |
241 | h_guicontrolflow(Tab *tab, LttvTracesetSelector * s, char * key) |
f0d936c0 |
242 | { |
ca0f8a8e |
243 | g_info("h_guicontrolflow, %p, %p, %s", tab, s, key); |
68997a22 |
244 | ControlFlowData *control_flow_data = guicontrolflow() ; |
a56a1ba4 |
245 | |
ca0f8a8e |
246 | control_flow_data->tab = tab; |
a56a1ba4 |
247 | |
2a2fa4f0 |
248 | //g_debug("time width2 : %u",time_window->time_width); |
a56a1ba4 |
249 | // Unreg done in the GuiControlFlow_Destructor |
6395d57c |
250 | lttvwindow_register_traceset_notify(tab, |
251 | traceset_notify, |
252 | control_flow_data); |
253 | |
ca0f8a8e |
254 | lttvwindow_register_time_window_notify(tab, |
224446ce |
255 | update_time_window_hook, |
256 | control_flow_data); |
ca0f8a8e |
257 | lttvwindow_register_current_time_notify(tab, |
224446ce |
258 | update_current_time_hook, |
259 | control_flow_data); |
ca0f8a8e |
260 | lttvwindow_register_redraw_notify(tab, |
261 | redraw_notify, |
262 | control_flow_data); |
263 | lttvwindow_register_continue_notify(tab, |
264 | continue_notify, |
265 | control_flow_data); |
6395d57c |
266 | request_background_data(control_flow_data); |
267 | |
ca0f8a8e |
268 | |
68997a22 |
269 | return guicontrolflow_get_widget(control_flow_data) ; |
a56a1ba4 |
270 | |
f0d936c0 |
271 | } |
272 | |
3cff8cc1 |
273 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 |
274 | { |
68997a22 |
275 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
14963be0 |
276 | guint *event_number = (guint*) call_data; |
f0d936c0 |
277 | |
2a2fa4f0 |
278 | g_debug("DEBUG : event selected by main window : %u", *event_number); |
a56a1ba4 |
279 | |
f0d936c0 |
280 | } |
281 | |
b9a010a2 |
282 | /* draw_before_hook |
283 | * |
f0d936c0 |
284 | * This function basically draw lines and icons. Two types of lines are drawn : |
285 | * one small (3 pixels?) representing the state of the process and the second |
286 | * type is thicker (10 pixels?) representing on which CPU a process is running |
287 | * (and this only in running state). |
288 | * |
289 | * Extremums of the lines : |
290 | * x_min : time of the last event context for this process kept in memory. |
291 | * x_max : time of the current event. |
292 | * y : middle of the process in the process list. The process is found in the |
293 | * list, therefore is it's position in pixels. |
294 | * |
295 | * The choice of lines'color is defined by the context of the last event for this |
296 | * process. |
297 | */ |
b9a010a2 |
298 | |
299 | |
300 | int draw_before_hook(void *hook_data, void *call_data) |
f0d936c0 |
301 | { |
b9a010a2 |
302 | EventsRequest *events_request = (EventsRequest*)hook_data; |
303 | ControlFlowData *control_flow_data = events_request->viewer_data; |
304 | |
305 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
306 | |
307 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
308 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
309 | |
310 | LttEvent *e; |
311 | e = tfc->e; |
312 | |
313 | LttTime evtime = ltt_event_time(e); |
314 | TimeWindow time_window = |
315 | lttvwindow_get_time_window(control_flow_data->tab); |
316 | |
317 | LttTime end_time = ltt_time_add(time_window.start_time, |
318 | time_window.time_width); |
319 | |
320 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
321 | || ltt_time_compare(evtime, end_time) == 1) |
322 | return; |
323 | |
324 | guint width = control_flow_data->drawing->width; |
325 | |
326 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) { |
327 | |
328 | /* we are in a schedchange, before the state update. We must draw the |
329 | * items corresponding to the state before it changes : now is the right |
330 | * time to do it. |
331 | */ |
332 | |
333 | guint pid_out; |
334 | { |
335 | guint pid_in; |
336 | LttField *f = ltt_event_field(e); |
337 | LttField *element; |
338 | element = ltt_field_member(f,0); |
339 | pid_out = ltt_event_get_long_unsigned(e,element); |
340 | element = ltt_field_member(f,1); |
341 | pid_in = ltt_event_get_long_unsigned(e,element); |
342 | g_debug("out : %u in : %u", pid_out, pid_in); |
343 | } |
344 | |
345 | /* First, check if the current process is in the state computation process |
346 | * list. If it is there, that means we must add it right now and draw items |
347 | * from the beginning of the read for it. If it is not present, it's a new |
348 | * process and it was not present : it will be added after the state update. |
349 | */ |
350 | LttvProcessState *process; |
351 | process = lttv_state_find_process(tfs, pid_out); |
352 | |
353 | if(process != NULL) { |
354 | /* Well, the process_out existed : we must get it in the process hash |
355 | * or add it, and draw its items. |
356 | */ |
357 | /* Add process to process list (if not present) */ |
358 | guint y_out = 0, height = 0, pl_height = 0; |
359 | HashedProcessData *hashed_process_data = NULL; |
360 | ProcessList *process_list = |
361 | guicontrolflow_get_process_list(control_flow_data); |
362 | LttTime birth = process->creation_time; |
363 | const gchar *name = g_quark_to_string(process->name); |
364 | |
365 | if(processlist_get_process_pixels(process_list, |
366 | pid_out, |
367 | &birth, |
368 | tfc->t_context->index, |
369 | &y_out, |
370 | &height, |
371 | &hashed_process_data) == 1) |
372 | { |
373 | /* Process not present */ |
374 | processlist_add(process_list, |
375 | pid_out, |
376 | &birth, |
377 | tfc->t_context->index, |
378 | name, |
379 | &pl_height, |
380 | &hashed_process_data); |
381 | processlist_get_process_pixels(process_list, |
382 | pid_out, |
383 | &birth, |
384 | tfc->t_context->index, |
385 | &y_out, |
386 | &height, |
387 | &hashed_process_data); |
388 | drawing_insert_square( control_flow_data->drawing, y_out, height); |
389 | } |
390 | |
391 | /* Now, the process is in the state hash and our own process hash. |
392 | * We definitely can draw the items related to the ending state. |
393 | */ |
394 | |
395 | /* Check if the x position is unset. In can have been left unset by |
396 | * a draw closure from a after chunk hook. This should never happen, |
397 | * because it must be set by before chunk hook to the damage_begin |
398 | * value. |
399 | */ |
400 | g_assert(hashed_process_data->x != -1); |
401 | |
402 | |
403 | } |
404 | } |
405 | |
406 | |
407 | return 0; |
408 | |
409 | |
410 | |
411 | #if 0 |
ca0f8a8e |
412 | EventsRequest *events_request = (EventsRequest*)hook_data; |
413 | ControlFlowData *control_flow_data = |
414 | (ControlFlowData*)events_request->viewer_data; |
415 | Tab *tab = control_flow_data->tab; |
e9a9c513 |
416 | |
a56a1ba4 |
417 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
e9a9c513 |
418 | |
419 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1aff52a2 |
420 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
a56a1ba4 |
421 | |
e9a9c513 |
422 | LttEvent *e; |
e9a9c513 |
423 | e = tfc->e; |
424 | |
9444deae |
425 | LttTime evtime = ltt_event_time(e); |
ca0f8a8e |
426 | TimeWindow time_window = |
427 | lttvwindow_get_time_window(tab); |
9444deae |
428 | |
ca0f8a8e |
429 | LttTime end_time = ltt_time_add(time_window.start_time, |
430 | time_window.time_width); |
9444deae |
431 | //if(time < time_beg || time > time_end) return; |
ca0f8a8e |
432 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
9444deae |
433 | || ltt_time_compare(evtime, end_time) == 1) |
434 | return; |
435 | |
a56a1ba4 |
436 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
437 | { |
2a2fa4f0 |
438 | g_debug("schedchange!"); |
a56a1ba4 |
439 | |
440 | /* Add process to process list (if not present) and get drawing "y" from |
441 | * process position */ |
442 | guint pid_out, pid_in; |
443 | LttvProcessState *process_out, *process_in; |
444 | LttTime birth; |
445 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
446 | |
447 | ProcessList *process_list = |
ca0f8a8e |
448 | guicontrolflow_get_process_list(control_flow_data); |
a56a1ba4 |
449 | |
450 | |
451 | LttField *f = ltt_event_field(e); |
452 | LttField *element; |
453 | element = ltt_field_member(f,0); |
454 | pid_out = ltt_event_get_long_unsigned(e,element); |
455 | element = ltt_field_member(f,1); |
456 | pid_in = ltt_event_get_long_unsigned(e,element); |
2a2fa4f0 |
457 | g_debug("out : %u in : %u", pid_out, pid_in); |
a56a1ba4 |
458 | |
459 | |
460 | /* Find process pid_out in the list... */ |
87658614 |
461 | process_out = lttv_state_find_process(tfs, pid_out); |
1aff52a2 |
462 | if(process_out == NULL) return 0; |
2a2fa4f0 |
463 | g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
1aff52a2 |
464 | |
a56a1ba4 |
465 | birth = process_out->creation_time; |
51705146 |
466 | const gchar *name = g_quark_to_string(process_out->name); |
14963be0 |
467 | HashedProcessData *hashed_process_data_out = NULL; |
a56a1ba4 |
468 | |
469 | if(processlist_get_process_pixels(process_list, |
470 | pid_out, |
471 | &birth, |
d0cd7f09 |
472 | tfc->t_context->index, |
a56a1ba4 |
473 | &y_out, |
474 | &height, |
14963be0 |
475 | &hashed_process_data_out) == 1) |
a56a1ba4 |
476 | { |
51705146 |
477 | /* Process not present */ |
478 | processlist_add(process_list, |
479 | pid_out, |
480 | &birth, |
481 | tfc->t_context->index, |
482 | name, |
483 | &pl_height, |
484 | &hashed_process_data_out); |
485 | g_assert(processlist_get_process_pixels(process_list, |
486 | pid_out, |
487 | &birth, |
488 | tfc->t_context->index, |
489 | &y_out, |
490 | &height, |
491 | &hashed_process_data_out)==0); |
492 | drawing_insert_square( control_flow_data->drawing, y_out, height); |
a56a1ba4 |
493 | } |
51705146 |
494 | //g_free(name); |
a56a1ba4 |
495 | |
496 | /* Find process pid_in in the list... */ |
87658614 |
497 | process_in = lttv_state_find_process(tfs, pid_in); |
1aff52a2 |
498 | if(process_in == NULL) return 0; |
2a2fa4f0 |
499 | g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
a56a1ba4 |
500 | |
501 | birth = process_in->creation_time; |
51705146 |
502 | name = g_quark_to_string(process_in->name); |
14963be0 |
503 | HashedProcessData *hashed_process_data_in = NULL; |
a56a1ba4 |
504 | |
505 | if(processlist_get_process_pixels(process_list, |
506 | pid_in, |
507 | &birth, |
d0cd7f09 |
508 | tfc->t_context->index, |
a56a1ba4 |
509 | &y_in, |
510 | &height, |
14963be0 |
511 | &hashed_process_data_in) == 1) |
a56a1ba4 |
512 | { |
51705146 |
513 | /* Process not present */ |
a56a1ba4 |
514 | processlist_add(process_list, |
515 | pid_in, |
516 | &birth, |
d0cd7f09 |
517 | tfc->t_context->index, |
a56a1ba4 |
518 | name, |
519 | &pl_height, |
14963be0 |
520 | &hashed_process_data_in); |
a56a1ba4 |
521 | processlist_get_process_pixels(process_list, |
522 | pid_in, |
523 | &birth, |
d0cd7f09 |
524 | tfc->t_context->index, |
a56a1ba4 |
525 | &y_in, |
526 | &height, |
14963be0 |
527 | &hashed_process_data_in); |
a56a1ba4 |
528 | |
ca0f8a8e |
529 | drawing_insert_square( control_flow_data->drawing, y_in, height); |
a56a1ba4 |
530 | } |
51705146 |
531 | //g_free(name); |
a56a1ba4 |
532 | |
533 | |
534 | /* Find pixels corresponding to time of the event. If the time does |
535 | * not fit in the window, show a warning, not supposed to happend. */ |
536 | guint x = 0; |
51705146 |
537 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
538 | |
539 | LttTime time = ltt_event_time(e); |
540 | |
ca0f8a8e |
541 | LttTime window_end = ltt_time_add(time_window.time_width, |
542 | time_window.start_time); |
a56a1ba4 |
543 | |
544 | |
545 | convert_time_to_pixels( |
ca0f8a8e |
546 | time_window.start_time, |
a56a1ba4 |
547 | window_end, |
548 | time, |
549 | width, |
550 | &x); |
9444deae |
551 | //assert(x <= width); |
51705146 |
552 | // |
a56a1ba4 |
553 | /* draw what represents the event for outgoing process. */ |
554 | |
14963be0 |
555 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
68997a22 |
556 | draw_context_out->current->modify_over->x = x; |
319e9d81 |
557 | draw_context_out->current->modify_under->x = x; |
68997a22 |
558 | draw_context_out->current->modify_over->y = y_out; |
319e9d81 |
559 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
501d5405 |
560 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
561 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
562 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
563 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
d0cd7f09 |
564 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
565 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
a56a1ba4 |
566 | //draw_context_out->gc = widget->style->black_gc; |
567 | |
568 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
501d5405 |
569 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
a56a1ba4 |
570 | |
d0cd7f09 |
571 | /* Draw the line/background of the out process */ |
572 | if(draw_context_out->previous->middle->x == -1) |
573 | { |
ca0f8a8e |
574 | draw_context_out->previous->over->x = |
575 | control_flow_data->drawing->damage_begin; |
576 | draw_context_out->previous->middle->x = |
577 | control_flow_data->drawing->damage_begin; |
578 | draw_context_out->previous->under->x = |
579 | control_flow_data->drawing->damage_begin; |
580 | |
581 | g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin); |
d0cd7f09 |
582 | } |
583 | |
584 | draw_context_out->current->middle->x = x; |
585 | draw_context_out->current->over->x = x; |
586 | draw_context_out->current->under->x = x; |
587 | draw_context_out->current->middle->y = y_out + height/2; |
588 | draw_context_out->current->over->y = y_out; |
589 | draw_context_out->current->under->y = y_out + height; |
590 | draw_context_out->previous->middle->y = y_out + height/2; |
591 | draw_context_out->previous->over->y = y_out; |
592 | draw_context_out->previous->under->y = y_out + height; |
593 | |
594 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
595 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
596 | |
597 | if(process_out->state->s == LTTV_STATE_RUN) |
598 | { |
51705146 |
599 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
600 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
601 | draw_context_out->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
602 | |
603 | PropertiesBG prop_bg; |
604 | prop_bg.color = g_new(GdkColor,1); |
605 | |
606 | switch(tfc->index) { |
607 | case 0: |
608 | prop_bg.color->red = 0x1515; |
609 | prop_bg.color->green = 0x1515; |
610 | prop_bg.color->blue = 0x8c8c; |
611 | break; |
612 | case 1: |
613 | prop_bg.color->red = 0x4e4e; |
614 | prop_bg.color->green = 0xa9a9; |
615 | prop_bg.color->blue = 0xa4a4; |
616 | break; |
617 | case 2: |
618 | prop_bg.color->red = 0x7a7a; |
619 | prop_bg.color->green = 0x4a4a; |
620 | prop_bg.color->blue = 0x8b8b; |
621 | break; |
622 | case 3: |
623 | prop_bg.color->red = 0x8080; |
624 | prop_bg.color->green = 0x7777; |
625 | prop_bg.color->blue = 0x4747; |
626 | break; |
627 | default: |
628 | prop_bg.color->red = 0xe7e7; |
629 | prop_bg.color->green = 0xe7e7; |
630 | prop_bg.color->blue = 0xe7e7; |
631 | } |
632 | |
2a2fa4f0 |
633 | g_debug("calling from draw_event"); |
d0cd7f09 |
634 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
635 | g_free(prop_bg.color); |
51705146 |
636 | //gdk_gc_unref(draw_context_out->gc); |
d0cd7f09 |
637 | } |
638 | |
639 | draw_context_out->gc = widget->style->black_gc; |
640 | |
a56a1ba4 |
641 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
2df6f2bd |
642 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
643 | PropertiesText prop_text_out; |
644 | prop_text_out.foreground = &colorfg_out; |
645 | prop_text_out.background = &colorbg_out; |
cfe526b1 |
646 | prop_text_out.size = 6; |
a56a1ba4 |
647 | prop_text_out.position = OVER; |
648 | |
cfe526b1 |
649 | /* color of text : status of the process */ |
650 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
651 | { |
652 | prop_text_out.foreground->red = 0xffff; |
653 | prop_text_out.foreground->green = 0xffff; |
654 | prop_text_out.foreground->blue = 0xffff; |
655 | } |
656 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
657 | { |
658 | prop_text_out.foreground->red = 0x0fff; |
d52cfc84 |
659 | prop_text_out.foreground->green = 0xffff; |
660 | prop_text_out.foreground->blue = 0xfff0; |
cfe526b1 |
661 | } |
662 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
663 | { |
2df6f2bd |
664 | prop_text_out.foreground->red = 0xffff; |
665 | prop_text_out.foreground->green = 0xffff; |
cfe526b1 |
666 | prop_text_out.foreground->blue = 0x0000; |
667 | } |
668 | else if(process_out->state->s == LTTV_STATE_EXIT) |
669 | { |
670 | prop_text_out.foreground->red = 0xffff; |
671 | prop_text_out.foreground->green = 0x0000; |
672 | prop_text_out.foreground->blue = 0xffff; |
673 | } |
674 | else if(process_out->state->s == LTTV_STATE_WAIT) |
675 | { |
676 | prop_text_out.foreground->red = 0xffff; |
677 | prop_text_out.foreground->green = 0x0000; |
678 | prop_text_out.foreground->blue = 0x0000; |
679 | } |
680 | else if(process_out->state->s == LTTV_STATE_RUN) |
681 | { |
682 | prop_text_out.foreground->red = 0x0000; |
683 | prop_text_out.foreground->green = 0xffff; |
684 | prop_text_out.foreground->blue = 0x0000; |
685 | } |
686 | else |
687 | { |
688 | prop_text_out.foreground->red = 0xffff; |
689 | prop_text_out.foreground->green = 0xffff; |
690 | prop_text_out.foreground->blue = 0xffff; |
691 | } |
692 | |
d52cfc84 |
693 | |
a56a1ba4 |
694 | /* Print status of the process : U, WF, WC, E, W, R */ |
695 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
cfe526b1 |
696 | prop_text_out.text = "U->"; |
a56a1ba4 |
697 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
cfe526b1 |
698 | prop_text_out.text = "WF->"; |
a56a1ba4 |
699 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
cfe526b1 |
700 | prop_text_out.text = "WC->"; |
a56a1ba4 |
701 | else if(process_out->state->s == LTTV_STATE_EXIT) |
cfe526b1 |
702 | prop_text_out.text = "E->"; |
a56a1ba4 |
703 | else if(process_out->state->s == LTTV_STATE_WAIT) |
cfe526b1 |
704 | prop_text_out.text = "W->"; |
a56a1ba4 |
705 | else if(process_out->state->s == LTTV_STATE_RUN) |
cfe526b1 |
706 | prop_text_out.text = "R->"; |
a56a1ba4 |
707 | else |
68997a22 |
708 | prop_text_out.text = "U"; |
a56a1ba4 |
709 | |
710 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
d0cd7f09 |
711 | //gdk_gc_unref(draw_context_out->gc); |
a56a1ba4 |
712 | |
51705146 |
713 | //draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
714 | //gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
715 | draw_context_out->gc = control_flow_data->drawing->gc; |
a56a1ba4 |
716 | |
717 | PropertiesLine prop_line_out; |
718 | prop_line_out.color = g_new(GdkColor,1); |
cfe526b1 |
719 | prop_line_out.line_width = 2; |
a56a1ba4 |
720 | prop_line_out.style = GDK_LINE_SOLID; |
721 | prop_line_out.position = MIDDLE; |
d52cfc84 |
722 | |
2a2fa4f0 |
723 | g_debug("out state : %s", g_quark_to_string(process_out->state->s)); |
a56a1ba4 |
724 | |
725 | /* color of line : status of the process */ |
726 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
727 | { |
cfe526b1 |
728 | prop_line_out.color->red = 0xffff; |
729 | prop_line_out.color->green = 0xffff; |
730 | prop_line_out.color->blue = 0xffff; |
a56a1ba4 |
731 | } |
732 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
733 | { |
734 | prop_line_out.color->red = 0x0fff; |
d52cfc84 |
735 | prop_line_out.color->green = 0xffff; |
736 | prop_line_out.color->blue = 0xfff0; |
a56a1ba4 |
737 | } |
738 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
739 | { |
2df6f2bd |
740 | prop_line_out.color->red = 0xffff; |
741 | prop_line_out.color->green = 0xffff; |
a56a1ba4 |
742 | prop_line_out.color->blue = 0x0000; |
743 | } |
744 | else if(process_out->state->s == LTTV_STATE_EXIT) |
745 | { |
746 | prop_line_out.color->red = 0xffff; |
747 | prop_line_out.color->green = 0x0000; |
748 | prop_line_out.color->blue = 0xffff; |
749 | } |
750 | else if(process_out->state->s == LTTV_STATE_WAIT) |
751 | { |
752 | prop_line_out.color->red = 0xffff; |
753 | prop_line_out.color->green = 0x0000; |
754 | prop_line_out.color->blue = 0x0000; |
755 | } |
756 | else if(process_out->state->s == LTTV_STATE_RUN) |
757 | { |
758 | prop_line_out.color->red = 0x0000; |
759 | prop_line_out.color->green = 0xffff; |
760 | prop_line_out.color->blue = 0x0000; |
761 | } |
762 | else |
763 | { |
cfe526b1 |
764 | prop_line_out.color->red = 0xffff; |
765 | prop_line_out.color->green = 0xffff; |
766 | prop_line_out.color->blue = 0xffff; |
a56a1ba4 |
767 | } |
768 | |
769 | draw_line((void*)&prop_line_out, (void*)draw_context_out); |
770 | g_free(prop_line_out.color); |
51705146 |
771 | //gdk_gc_unref(draw_context_out->gc); |
a56a1ba4 |
772 | /* Note : finishing line will have to be added when trace read over. */ |
773 | |
774 | /* Finally, update the drawing context of the pid_in. */ |
775 | |
14963be0 |
776 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
68997a22 |
777 | draw_context_in->current->modify_over->x = x; |
319e9d81 |
778 | draw_context_in->current->modify_under->x = x; |
68997a22 |
779 | draw_context_in->current->modify_over->y = y_in; |
319e9d81 |
780 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
501d5405 |
781 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
782 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
783 | widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
784 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
785 | //draw_context_in->gc = widget->style->black_gc; |
d0cd7f09 |
786 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
787 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
a56a1ba4 |
788 | |
789 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
501d5405 |
790 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
791 | |
792 | /* Draw the line/bg of the in process */ |
793 | if(draw_context_in->previous->middle->x == -1) |
794 | { |
ca0f8a8e |
795 | draw_context_in->previous->over->x = |
796 | control_flow_data->drawing->damage_begin; |
797 | draw_context_in->previous->middle->x = |
798 | control_flow_data->drawing->damage_begin; |
799 | draw_context_in->previous->under->x = |
800 | control_flow_data->drawing->damage_begin; |
801 | |
802 | g_debug("in middle x_beg : %u",control_flow_data->drawing->damage_begin); |
803 | |
d0cd7f09 |
804 | } |
805 | |
806 | draw_context_in->current->middle->x = x; |
807 | draw_context_in->current->over->x = x; |
808 | draw_context_in->current->under->x = x; |
809 | draw_context_in->current->middle->y = y_in + height/2; |
810 | draw_context_in->current->over->y = y_in; |
811 | draw_context_in->current->under->y = y_in + height; |
812 | draw_context_in->previous->middle->y = y_in + height/2; |
813 | draw_context_in->previous->over->y = y_in; |
814 | draw_context_in->previous->under->y = y_in + height; |
a56a1ba4 |
815 | |
d0cd7f09 |
816 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
817 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
818 | |
819 | |
820 | if(process_in->state->s == LTTV_STATE_RUN) |
821 | { |
51705146 |
822 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
823 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
824 | draw_context_in->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
825 | |
826 | PropertiesBG prop_bg; |
827 | prop_bg.color = g_new(GdkColor,1); |
828 | |
829 | switch(tfc->index) { |
830 | case 0: |
831 | prop_bg.color->red = 0x1515; |
832 | prop_bg.color->green = 0x1515; |
833 | prop_bg.color->blue = 0x8c8c; |
834 | break; |
835 | case 1: |
836 | prop_bg.color->red = 0x4e4e; |
837 | prop_bg.color->green = 0xa9a9; |
838 | prop_bg.color->blue = 0xa4a4; |
839 | break; |
840 | case 2: |
841 | prop_bg.color->red = 0x7a7a; |
842 | prop_bg.color->green = 0x4a4a; |
843 | prop_bg.color->blue = 0x8b8b; |
844 | break; |
845 | case 3: |
846 | prop_bg.color->red = 0x8080; |
847 | prop_bg.color->green = 0x7777; |
848 | prop_bg.color->blue = 0x4747; |
849 | break; |
850 | default: |
851 | prop_bg.color->red = 0xe7e7; |
852 | prop_bg.color->green = 0xe7e7; |
853 | prop_bg.color->blue = 0xe7e7; |
854 | } |
855 | |
856 | |
857 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
858 | g_free(prop_bg.color); |
51705146 |
859 | //gdk_gc_unref(draw_context_in->gc); |
d0cd7f09 |
860 | } |
861 | |
862 | draw_context_in->gc = widget->style->black_gc; |
863 | |
a56a1ba4 |
864 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
2df6f2bd |
865 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
866 | PropertiesText prop_text_in; |
867 | prop_text_in.foreground = &colorfg_in; |
868 | prop_text_in.background = &colorbg_in; |
cfe526b1 |
869 | prop_text_in.size = 6; |
a56a1ba4 |
870 | prop_text_in.position = OVER; |
871 | |
2a2fa4f0 |
872 | g_debug("in state : %s", g_quark_to_string(process_in->state->s)); |
cfe526b1 |
873 | /* foreground of text : status of the process */ |
874 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
875 | { |
876 | prop_text_in.foreground->red = 0xffff; |
877 | prop_text_in.foreground->green = 0xffff; |
878 | prop_text_in.foreground->blue = 0xffff; |
879 | } |
880 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
881 | { |
882 | prop_text_in.foreground->red = 0x0fff; |
d52cfc84 |
883 | prop_text_in.foreground->green = 0xffff; |
884 | prop_text_in.foreground->blue = 0xfff0; |
cfe526b1 |
885 | } |
886 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
887 | { |
2df6f2bd |
888 | prop_text_in.foreground->red = 0xffff; |
889 | prop_text_in.foreground->green = 0xffff; |
cfe526b1 |
890 | prop_text_in.foreground->blue = 0x0000; |
891 | } |
892 | else if(process_in->state->s == LTTV_STATE_EXIT) |
893 | { |
894 | prop_text_in.foreground->red = 0xffff; |
895 | prop_text_in.foreground->green = 0x0000; |
896 | prop_text_in.foreground->blue = 0xffff; |
897 | } |
898 | else if(process_in->state->s == LTTV_STATE_WAIT) |
899 | { |
900 | prop_text_in.foreground->red = 0xffff; |
901 | prop_text_in.foreground->green = 0x0000; |
902 | prop_text_in.foreground->blue = 0x0000; |
903 | } |
904 | else if(process_in->state->s == LTTV_STATE_RUN) |
905 | { |
906 | prop_text_in.foreground->red = 0x0000; |
907 | prop_text_in.foreground->green = 0xffff; |
908 | prop_text_in.foreground->blue = 0x0000; |
909 | } |
910 | else |
911 | { |
912 | prop_text_in.foreground->red = 0xffff; |
913 | prop_text_in.foreground->green = 0xffff; |
914 | prop_text_in.foreground->blue = 0xffff; |
915 | } |
916 | |
917 | |
918 | |
a56a1ba4 |
919 | /* Print status of the process : U, WF, WC, E, W, R */ |
920 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
cfe526b1 |
921 | prop_text_in.text = "U->"; |
a56a1ba4 |
922 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
cfe526b1 |
923 | prop_text_in.text = "WF->"; |
a56a1ba4 |
924 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
cfe526b1 |
925 | prop_text_in.text = "WC->"; |
a56a1ba4 |
926 | else if(process_in->state->s == LTTV_STATE_EXIT) |
cfe526b1 |
927 | prop_text_in.text = "E->"; |
a56a1ba4 |
928 | else if(process_in->state->s == LTTV_STATE_WAIT) |
cfe526b1 |
929 | prop_text_in.text = "W->"; |
a56a1ba4 |
930 | else if(process_in->state->s == LTTV_STATE_RUN) |
cfe526b1 |
931 | prop_text_in.text = "R->"; |
a56a1ba4 |
932 | else |
68997a22 |
933 | prop_text_in.text = "U"; |
a56a1ba4 |
934 | |
935 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
d0cd7f09 |
936 | //gdk_gc_unref(draw_context_in->gc); |
937 | |
51705146 |
938 | //draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
939 | //gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
940 | draw_context_in->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
941 | |
a56a1ba4 |
942 | PropertiesLine prop_line_in; |
943 | prop_line_in.color = g_new(GdkColor,1); |
cfe526b1 |
944 | prop_line_in.line_width = 2; |
a56a1ba4 |
945 | prop_line_in.style = GDK_LINE_SOLID; |
946 | prop_line_in.position = MIDDLE; |
947 | |
948 | /* color of line : status of the process */ |
949 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
950 | { |
cfe526b1 |
951 | prop_line_in.color->red = 0xffff; |
952 | prop_line_in.color->green = 0xffff; |
953 | prop_line_in.color->blue = 0xffff; |
a56a1ba4 |
954 | } |
955 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
956 | { |
957 | prop_line_in.color->red = 0x0fff; |
d52cfc84 |
958 | prop_line_in.color->green = 0xffff; |
959 | prop_line_in.color->blue = 0xfff0; |
a56a1ba4 |
960 | } |
961 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
962 | { |
2df6f2bd |
963 | prop_line_in.color->red = 0xffff; |
964 | prop_line_in.color->green = 0xffff; |
a56a1ba4 |
965 | prop_line_in.color->blue = 0x0000; |
966 | } |
967 | else if(process_in->state->s == LTTV_STATE_EXIT) |
968 | { |
969 | prop_line_in.color->red = 0xffff; |
970 | prop_line_in.color->green = 0x0000; |
971 | prop_line_in.color->blue = 0xffff; |
972 | } |
973 | else if(process_in->state->s == LTTV_STATE_WAIT) |
974 | { |
975 | prop_line_in.color->red = 0xffff; |
976 | prop_line_in.color->green = 0x0000; |
977 | prop_line_in.color->blue = 0x0000; |
978 | } |
979 | else if(process_in->state->s == LTTV_STATE_RUN) |
980 | { |
981 | prop_line_in.color->red = 0x0000; |
982 | prop_line_in.color->green = 0xffff; |
983 | prop_line_in.color->blue = 0x0000; |
984 | } |
985 | else |
986 | { |
cfe526b1 |
987 | prop_line_in.color->red = 0xffff; |
988 | prop_line_in.color->green = 0xffff; |
989 | prop_line_in.color->blue = 0xffff; |
a56a1ba4 |
990 | } |
991 | |
992 | draw_line((void*)&prop_line_in, (void*)draw_context_in); |
993 | g_free(prop_line_in.color); |
51705146 |
994 | //gdk_gc_unref(draw_context_in->gc); |
a56a1ba4 |
995 | } |
996 | |
997 | return 0; |
b9a010a2 |
998 | #endif //0 |
999 | |
1000 | |
a56a1ba4 |
1001 | |
51705146 |
1002 | /* Text dump */ |
80a52ff8 |
1003 | #ifdef DONTSHOW |
a56a1ba4 |
1004 | GString *string = g_string_new("");; |
1005 | gboolean field_names = TRUE, state = TRUE; |
80a52ff8 |
1006 | |
e9a9c513 |
1007 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
1008 | g_string_append_printf(string,"\n"); |
1009 | |
1010 | if(state) { |
1011 | g_string_append_printf(string, " %s", |
1012 | g_quark_to_string(tfs->process->state->s)); |
1013 | } |
1014 | |
1015 | g_info("%s",string->str); |
1016 | |
a56a1ba4 |
1017 | g_string_free(string, TRUE); |
1018 | |
1019 | /* End of text dump */ |
80a52ff8 |
1020 | #endif //DONTSHOW |
50439712 |
1021 | |
f0d936c0 |
1022 | } |
1023 | |
b9a010a2 |
1024 | /* draw_after_hook |
1025 | * |
1026 | * The draw after hook is called by the reading API to have a |
1027 | * particular event drawn on the screen. |
1028 | * @param hook_data ControlFlowData structure of the viewer. |
1029 | * @param call_data Event context. |
1030 | * |
1031 | * This function adds items to be drawn in a queue for each process. |
1032 | * |
1033 | */ |
4c69e0cc |
1034 | int draw_after_hook(void *hook_data, void *call_data) |
f0d936c0 |
1035 | { |
ca0f8a8e |
1036 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1037 | ControlFlowData *control_flow_data = events_request->viewer_data; |
50439712 |
1038 | |
a56a1ba4 |
1039 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
50439712 |
1040 | |
1041 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1aff52a2 |
1042 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
50439712 |
1043 | |
b9a010a2 |
1044 | LttEvent *e; |
1045 | e = tfc->e; |
1046 | |
1047 | LttTime evtime = ltt_event_time(e); |
1048 | TimeWindow time_window = |
1049 | lttvwindow_get_time_window(control_flow_data->tab); |
1050 | |
1051 | LttTime end_time = ltt_time_add(time_window.start_time, |
1052 | time_window.time_width); |
1053 | |
1054 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
1055 | || ltt_time_compare(evtime, end_time) == 1) |
1056 | return; |
1057 | |
1058 | guint width = control_flow_data->drawing->width; |
1059 | |
1060 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) { |
1061 | |
1062 | g_debug("schedchange!"); |
1063 | |
1064 | { |
1065 | /* Add process to process list (if not present) */ |
1066 | LttvProcessState *process_out, *process_in; |
1067 | LttTime birth; |
1068 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
1069 | HashedProcessData *hashed_process_data_in = NULL; |
1070 | |
1071 | ProcessList *process_list = |
1072 | guicontrolflow_get_process_list(control_flow_data); |
1073 | |
1074 | guint pid_in; |
1075 | { |
1076 | guint pid_out; |
1077 | LttField *f = ltt_event_field(e); |
1078 | LttField *element; |
1079 | element = ltt_field_member(f,0); |
1080 | pid_out = ltt_event_get_long_unsigned(e,element); |
1081 | element = ltt_field_member(f,1); |
1082 | pid_in = ltt_event_get_long_unsigned(e,element); |
1083 | g_debug("out : %u in : %u", pid_out, pid_in); |
1084 | } |
1085 | |
1086 | |
1087 | /* Find process pid_in in the list... */ |
1088 | process_in = lttv_state_find_process(tfs, pid_in); |
1089 | /* It should exist, because we are after the state update. */ |
1090 | g_assert(process_in != NULL); |
1091 | |
1092 | birth = process_in->creation_time; |
1093 | const gchar *name = g_quark_to_string(process_in->name); |
1094 | |
1095 | if(processlist_get_process_pixels(process_list, |
1096 | pid_in, |
1097 | &birth, |
1098 | tfc->t_context->index, |
1099 | &y_in, |
1100 | &height, |
1101 | &hashed_process_data_in) == 1) |
1102 | { |
1103 | /* Process not present */ |
1104 | processlist_add(process_list, |
1105 | pid_in, |
1106 | &birth, |
1107 | tfc->t_context->index, |
1108 | name, |
1109 | &pl_height, |
1110 | &hashed_process_data_in); |
1111 | processlist_get_process_pixels(process_list, |
1112 | pid_in, |
1113 | &birth, |
1114 | tfc->t_context->index, |
1115 | &y_in, |
1116 | &height, |
1117 | &hashed_process_data_in); |
1118 | drawing_insert_square( control_flow_data->drawing, y_in, height); |
1119 | } |
1120 | |
1121 | convert_time_to_pixels( |
1122 | time_window.start_time, |
1123 | end_time, |
1124 | evtime, |
1125 | width, |
1126 | &hashed_process_data_in->x); |
1127 | } |
1128 | } |
1129 | return 0; |
1130 | |
1131 | |
1132 | |
1133 | #if 0 |
1134 | EventsRequest *events_request = (EventsRequest*)hook_data; |
1135 | ControlFlowData *control_flow_data = events_request->viewer_data; |
1136 | |
1137 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
1138 | |
1139 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
1140 | LttvTraceState *ts =(LttvTraceState *)LTTV_TRACEFILE_CONTEXT(tfs)->t_context; |
1141 | |
a56a1ba4 |
1142 | |
50439712 |
1143 | LttEvent *e; |
1144 | e = tfc->e; |
1145 | |
9444deae |
1146 | LttTime evtime = ltt_event_time(e); |
ca0f8a8e |
1147 | TimeWindow time_window = |
1148 | lttvwindow_get_time_window(control_flow_data->tab); |
9444deae |
1149 | |
ca0f8a8e |
1150 | LttTime end_time = ltt_time_add(time_window.start_time, |
1151 | time_window.time_width); |
9444deae |
1152 | //if(time < time_beg || time > time_end) return; |
ca0f8a8e |
1153 | if(ltt_time_compare(evtime, time_window.start_time) == -1 |
9444deae |
1154 | || ltt_time_compare(evtime, end_time) == 1) |
1155 | return; |
1156 | |
1157 | |
a56a1ba4 |
1158 | if(strcmp(ltt_eventtype_name(ltt_event_eventtype(e)),"schedchange") == 0) |
1159 | { |
2a2fa4f0 |
1160 | g_debug("schedchange!"); |
a56a1ba4 |
1161 | |
1162 | /* Add process to process list (if not present) and get drawing "y" from |
1163 | * process position */ |
1164 | guint pid_out, pid_in; |
1165 | LttvProcessState *process_out, *process_in; |
1166 | LttTime birth; |
1167 | guint y_in = 0, y_out = 0, height = 0, pl_height = 0; |
1168 | |
1169 | ProcessList *process_list = |
ca0f8a8e |
1170 | guicontrolflow_get_process_list(control_flow_data); |
a56a1ba4 |
1171 | |
1172 | |
1173 | LttField *f = ltt_event_field(e); |
1174 | LttField *element; |
1175 | element = ltt_field_member(f,0); |
1176 | pid_out = ltt_event_get_long_unsigned(e,element); |
1177 | element = ltt_field_member(f,1); |
1178 | pid_in = ltt_event_get_long_unsigned(e,element); |
2a2fa4f0 |
1179 | //g_debug("out : %u in : %u", pid_out, pid_in); |
a56a1ba4 |
1180 | |
1181 | |
1182 | /* Find process pid_out in the list... */ |
2a2fa4f0 |
1183 | process_out = lttv_state_find_process(tfs, pid_out); |
1aff52a2 |
1184 | if(process_out == NULL) return 0; |
2a2fa4f0 |
1185 | //g_debug("out : %s",g_quark_to_string(process_out->state->s)); |
a56a1ba4 |
1186 | |
1187 | birth = process_out->creation_time; |
1188 | gchar *name = strdup(g_quark_to_string(process_out->name)); |
14963be0 |
1189 | HashedProcessData *hashed_process_data_out = NULL; |
a56a1ba4 |
1190 | |
1191 | if(processlist_get_process_pixels(process_list, |
1192 | pid_out, |
1193 | &birth, |
d0cd7f09 |
1194 | tfc->t_context->index, |
a56a1ba4 |
1195 | &y_out, |
1196 | &height, |
14963be0 |
1197 | &hashed_process_data_out) == 1) |
a56a1ba4 |
1198 | { |
51705146 |
1199 | /* Process not present */ |
1200 | processlist_add(process_list, |
1201 | pid_out, |
1202 | &birth, |
1203 | tfc->t_context->index, |
1204 | name, |
1205 | &pl_height, |
1206 | &hashed_process_data_out); |
1207 | processlist_get_process_pixels(process_list, |
1208 | pid_out, |
1209 | &birth, |
1210 | tfc->t_context->index, |
1211 | &y_out, |
1212 | &height, |
1213 | &hashed_process_data_out); |
1214 | drawing_insert_square( control_flow_data->drawing, y_out, height); |
a56a1ba4 |
1215 | } |
1216 | |
1217 | g_free(name); |
1218 | |
1219 | /* Find process pid_in in the list... */ |
2a2fa4f0 |
1220 | process_in = lttv_state_find_process(tfs, pid_in); |
1aff52a2 |
1221 | if(process_in == NULL) return 0; |
2a2fa4f0 |
1222 | //g_debug("in : %s",g_quark_to_string(process_in->state->s)); |
a56a1ba4 |
1223 | |
1224 | birth = process_in->creation_time; |
1225 | name = strdup(g_quark_to_string(process_in->name)); |
14963be0 |
1226 | HashedProcessData *hashed_process_data_in = NULL; |
a56a1ba4 |
1227 | |
1228 | if(processlist_get_process_pixels(process_list, |
1229 | pid_in, |
1230 | &birth, |
d0cd7f09 |
1231 | tfc->t_context->index, |
a56a1ba4 |
1232 | &y_in, |
1233 | &height, |
14963be0 |
1234 | &hashed_process_data_in) == 1) |
a56a1ba4 |
1235 | { |
1236 | /* Process not present */ |
1237 | processlist_add(process_list, |
1238 | pid_in, |
1239 | &birth, |
d0cd7f09 |
1240 | tfc->t_context->index, |
a56a1ba4 |
1241 | name, |
1242 | &pl_height, |
14963be0 |
1243 | &hashed_process_data_in); |
a56a1ba4 |
1244 | processlist_get_process_pixels(process_list, |
1245 | pid_in, |
1246 | &birth, |
d0cd7f09 |
1247 | tfc->t_context->index, |
a56a1ba4 |
1248 | &y_in, |
1249 | &height, |
14963be0 |
1250 | &hashed_process_data_in); |
a56a1ba4 |
1251 | |
ca0f8a8e |
1252 | drawing_insert_square( control_flow_data->drawing, y_in, height); |
a56a1ba4 |
1253 | } |
1254 | g_free(name); |
1255 | |
1256 | |
1257 | /* Find pixels corresponding to time of the event. If the time does |
1258 | * not fit in the window, show a warning, not supposed to happend. */ |
1259 | //guint x = 0; |
501d5405 |
1260 | //guint width = control_flow_data->drawing->drawing_area->allocation.width; |
a56a1ba4 |
1261 | |
1262 | //LttTime time = ltt_event_time(e); |
1263 | |
224446ce |
1264 | //LttTime window_end = ltt_time_add(time_window->time_width, |
1265 | // time_window->start_time); |
a56a1ba4 |
1266 | |
1267 | |
1268 | //convert_time_to_pixels( |
224446ce |
1269 | // time_window->start_time, |
a56a1ba4 |
1270 | // window_end, |
1271 | // time, |
1272 | // width, |
1273 | // &x); |
1274 | |
1275 | //assert(x <= width); |
1276 | |
1277 | /* draw what represents the event for outgoing process. */ |
1278 | |
14963be0 |
1279 | DrawContext *draw_context_out = hashed_process_data_out->draw_context; |
68997a22 |
1280 | //draw_context_out->current->modify_over->x = x; |
1281 | draw_context_out->current->modify_over->y = y_out; |
319e9d81 |
1282 | draw_context_out->current->modify_under->y = y_out+(height/2)+2; |
501d5405 |
1283 | draw_context_out->drawable = control_flow_data->drawing->pixmap; |
1284 | draw_context_out->pango_layout = control_flow_data->drawing->pango_layout; |
1285 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1286 | //draw_context_out->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
d0cd7f09 |
1287 | |
a56a1ba4 |
1288 | //draw_arc((void*)&prop_arc, (void*)draw_context_out); |
501d5405 |
1289 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1290 | |
1291 | /*if(process_out->state->s == LTTV_STATE_RUN) |
1292 | { |
1293 | draw_context_out->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1294 | gdk_gc_copy(draw_context_out->gc, widget->style->black_gc); |
1295 | PropertiesBG prop_bg; |
1296 | prop_bg.color = g_new(GdkColor,1); |
1297 | |
1298 | prop_bg.color->red = 0xffff; |
1299 | prop_bg.color->green = 0xffff; |
1300 | prop_bg.color->blue = 0xffff; |
1301 | |
1302 | draw_bg((void*)&prop_bg, (void*)draw_context_out); |
1303 | g_free(prop_bg.color); |
1304 | gdk_gc_unref(draw_context_out->gc); |
1305 | }*/ |
1306 | |
1307 | draw_context_out->gc = widget->style->black_gc; |
1308 | |
a56a1ba4 |
1309 | GdkColor colorfg_out = { 0, 0xffff, 0x0000, 0x0000 }; |
2df6f2bd |
1310 | GdkColor colorbg_out = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1311 | PropertiesText prop_text_out; |
1312 | prop_text_out.foreground = &colorfg_out; |
1313 | prop_text_out.background = &colorbg_out; |
cfe526b1 |
1314 | prop_text_out.size = 6; |
a56a1ba4 |
1315 | prop_text_out.position = OVER; |
1316 | |
cfe526b1 |
1317 | /* color of text : status of the process */ |
1318 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
1319 | { |
1320 | prop_text_out.foreground->red = 0xffff; |
1321 | prop_text_out.foreground->green = 0xffff; |
1322 | prop_text_out.foreground->blue = 0xffff; |
1323 | } |
1324 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
1325 | { |
1326 | prop_text_out.foreground->red = 0x0fff; |
d52cfc84 |
1327 | prop_text_out.foreground->green = 0xffff; |
1328 | prop_text_out.foreground->blue = 0xfff0; |
cfe526b1 |
1329 | } |
1330 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
1331 | { |
2df6f2bd |
1332 | prop_text_out.foreground->red = 0xffff; |
1333 | prop_text_out.foreground->green = 0xffff; |
cfe526b1 |
1334 | prop_text_out.foreground->blue = 0x0000; |
1335 | } |
1336 | else if(process_out->state->s == LTTV_STATE_EXIT) |
1337 | { |
1338 | prop_text_out.foreground->red = 0xffff; |
1339 | prop_text_out.foreground->green = 0x0000; |
1340 | prop_text_out.foreground->blue = 0xffff; |
1341 | } |
1342 | else if(process_out->state->s == LTTV_STATE_WAIT) |
1343 | { |
1344 | prop_text_out.foreground->red = 0xffff; |
1345 | prop_text_out.foreground->green = 0x0000; |
1346 | prop_text_out.foreground->blue = 0x0000; |
1347 | } |
1348 | else if(process_out->state->s == LTTV_STATE_RUN) |
1349 | { |
1350 | prop_text_out.foreground->red = 0x0000; |
1351 | prop_text_out.foreground->green = 0xffff; |
1352 | prop_text_out.foreground->blue = 0x0000; |
1353 | } |
1354 | else |
1355 | { |
1356 | prop_text_out.foreground->red = 0xffff; |
1357 | prop_text_out.foreground->green = 0xffff; |
1358 | prop_text_out.foreground->blue = 0xffff; |
1359 | } |
1360 | |
a56a1ba4 |
1361 | /* Print status of the process : U, WF, WC, E, W, R */ |
1362 | if(process_out->state->s == LTTV_STATE_UNNAMED) |
68997a22 |
1363 | prop_text_out.text = "U"; |
a56a1ba4 |
1364 | else if(process_out->state->s == LTTV_STATE_WAIT_FORK) |
68997a22 |
1365 | prop_text_out.text = "WF"; |
a56a1ba4 |
1366 | else if(process_out->state->s == LTTV_STATE_WAIT_CPU) |
68997a22 |
1367 | prop_text_out.text = "WC"; |
a56a1ba4 |
1368 | else if(process_out->state->s == LTTV_STATE_EXIT) |
68997a22 |
1369 | prop_text_out.text = "E"; |
a56a1ba4 |
1370 | else if(process_out->state->s == LTTV_STATE_WAIT) |
68997a22 |
1371 | prop_text_out.text = "W"; |
a56a1ba4 |
1372 | else if(process_out->state->s == LTTV_STATE_RUN) |
68997a22 |
1373 | prop_text_out.text = "R"; |
a56a1ba4 |
1374 | else |
68997a22 |
1375 | prop_text_out.text = "U"; |
a56a1ba4 |
1376 | |
1377 | draw_text((void*)&prop_text_out, (void*)draw_context_out); |
d0cd7f09 |
1378 | |
1379 | //gdk_gc_unref(draw_context_out->gc); |
319e9d81 |
1380 | |
68997a22 |
1381 | draw_context_out->current->middle->y = y_out+height/2; |
d0cd7f09 |
1382 | draw_context_out->current->over->y = y_out; |
1383 | draw_context_out->current->under->y = y_out+height; |
68997a22 |
1384 | draw_context_out->current->status = process_out->state->s; |
a56a1ba4 |
1385 | |
68997a22 |
1386 | /* for pid_out : remove previous, Prev = current, new current (default) */ |
1387 | g_free(draw_context_out->previous->modify_under); |
1388 | g_free(draw_context_out->previous->modify_middle); |
1389 | g_free(draw_context_out->previous->modify_over); |
1390 | g_free(draw_context_out->previous->under); |
1391 | g_free(draw_context_out->previous->middle); |
1392 | g_free(draw_context_out->previous->over); |
1393 | g_free(draw_context_out->previous); |
1394 | |
1395 | draw_context_out->previous = draw_context_out->current; |
a56a1ba4 |
1396 | |
68997a22 |
1397 | draw_context_out->current = g_new(DrawInfo,1); |
1398 | draw_context_out->current->over = g_new(ItemInfo,1); |
1399 | draw_context_out->current->over->x = -1; |
1400 | draw_context_out->current->over->y = -1; |
1401 | draw_context_out->current->middle = g_new(ItemInfo,1); |
1402 | draw_context_out->current->middle->x = -1; |
1403 | draw_context_out->current->middle->y = -1; |
1404 | draw_context_out->current->under = g_new(ItemInfo,1); |
1405 | draw_context_out->current->under->x = -1; |
1406 | draw_context_out->current->under->y = -1; |
1407 | draw_context_out->current->modify_over = g_new(ItemInfo,1); |
1408 | draw_context_out->current->modify_over->x = -1; |
1409 | draw_context_out->current->modify_over->y = -1; |
1410 | draw_context_out->current->modify_middle = g_new(ItemInfo,1); |
1411 | draw_context_out->current->modify_middle->x = -1; |
1412 | draw_context_out->current->modify_middle->y = -1; |
1413 | draw_context_out->current->modify_under = g_new(ItemInfo,1); |
1414 | draw_context_out->current->modify_under->x = -1; |
1415 | draw_context_out->current->modify_under->y = -1; |
1416 | draw_context_out->current->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1417 | |
1418 | /* Finally, update the drawing context of the pid_in. */ |
1419 | |
14963be0 |
1420 | DrawContext *draw_context_in = hashed_process_data_in->draw_context; |
68997a22 |
1421 | //draw_context_in->current->modify_over->x = x; |
1422 | draw_context_in->current->modify_over->y = y_in; |
319e9d81 |
1423 | draw_context_in->current->modify_under->y = y_in+(height/2)+2; |
501d5405 |
1424 | draw_context_in->drawable = control_flow_data->drawing->pixmap; |
1425 | draw_context_in->pango_layout = control_flow_data->drawing->pango_layout; |
1426 | widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1427 | //draw_context_in->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
a56a1ba4 |
1428 | |
1429 | //draw_arc((void*)&prop_arc, (void*)draw_context_in); |
501d5405 |
1430 | //test_draw_item(control_flow_data->drawing, control_flow_data->drawing->pixmap); |
d0cd7f09 |
1431 | |
1432 | /*if(process_in->state->s == LTTV_STATE_RUN) |
1433 | { |
1434 | draw_context_in->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
1435 | gdk_gc_copy(draw_context_in->gc, widget->style->black_gc); |
1436 | PropertiesBG prop_bg; |
1437 | prop_bg.color = g_new(GdkColor,1); |
1438 | |
1439 | prop_bg.color->red = 0xffff; |
1440 | prop_bg.color->green = 0xffff; |
1441 | prop_bg.color->blue = 0xffff; |
1442 | |
1443 | draw_bg((void*)&prop_bg, (void*)draw_context_in); |
1444 | g_free(prop_bg.color); |
1445 | gdk_gc_unref(draw_context_in->gc); |
1446 | }*/ |
1447 | |
1448 | draw_context_in->gc = widget->style->black_gc; |
1449 | |
a56a1ba4 |
1450 | GdkColor colorfg_in = { 0, 0x0000, 0xffff, 0x0000 }; |
2df6f2bd |
1451 | GdkColor colorbg_in = { 0, 0x0000, 0x0000, 0x0000 }; |
a56a1ba4 |
1452 | PropertiesText prop_text_in; |
1453 | prop_text_in.foreground = &colorfg_in; |
1454 | prop_text_in.background = &colorbg_in; |
cfe526b1 |
1455 | prop_text_in.size = 6; |
a56a1ba4 |
1456 | prop_text_in.position = OVER; |
1457 | |
cfe526b1 |
1458 | /* foreground of text : status of the process */ |
1459 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
1460 | { |
1461 | prop_text_in.foreground->red = 0xffff; |
1462 | prop_text_in.foreground->green = 0xffff; |
1463 | prop_text_in.foreground->blue = 0xffff; |
1464 | } |
1465 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
1466 | { |
1467 | prop_text_in.foreground->red = 0x0fff; |
d52cfc84 |
1468 | prop_text_in.foreground->green = 0xffff; |
1469 | prop_text_in.foreground->blue = 0xfff0; |
cfe526b1 |
1470 | } |
1471 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
1472 | { |
2df6f2bd |
1473 | prop_text_in.foreground->red = 0xffff; |
1474 | prop_text_in.foreground->green = 0xffff; |
cfe526b1 |
1475 | prop_text_in.foreground->blue = 0x0000; |
1476 | } |
1477 | else if(process_in->state->s == LTTV_STATE_EXIT) |
1478 | { |
1479 | prop_text_in.foreground->red = 0xffff; |
1480 | prop_text_in.foreground->green = 0x0000; |
1481 | prop_text_in.foreground->blue = 0xffff; |
1482 | } |
1483 | else if(process_in->state->s == LTTV_STATE_WAIT) |
1484 | { |
1485 | prop_text_in.foreground->red = 0xffff; |
1486 | prop_text_in.foreground->green = 0x0000; |
1487 | prop_text_in.foreground->blue = 0x0000; |
1488 | } |
1489 | else if(process_in->state->s == LTTV_STATE_RUN) |
1490 | { |
1491 | prop_text_in.foreground->red = 0x0000; |
1492 | prop_text_in.foreground->green = 0xffff; |
1493 | prop_text_in.foreground->blue = 0x0000; |
1494 | } |
1495 | else |
1496 | { |
1497 | prop_text_in.foreground->red = 0xffff; |
1498 | prop_text_in.foreground->green = 0xffff; |
1499 | prop_text_in.foreground->blue = 0xffff; |
1500 | } |
1501 | |
1502 | |
a56a1ba4 |
1503 | /* Print status of the process : U, WF, WC, E, W, R */ |
1504 | if(process_in->state->s == LTTV_STATE_UNNAMED) |
68997a22 |
1505 | prop_text_in.text = "U"; |
a56a1ba4 |
1506 | else if(process_in->state->s == LTTV_STATE_WAIT_FORK) |
68997a22 |
1507 | prop_text_in.text = "WF"; |
a56a1ba4 |
1508 | else if(process_in->state->s == LTTV_STATE_WAIT_CPU) |
68997a22 |
1509 | prop_text_in.text = "WC"; |
a56a1ba4 |
1510 | else if(process_in->state->s == LTTV_STATE_EXIT) |
68997a22 |
1511 | prop_text_in.text = "E"; |
a56a1ba4 |
1512 | else if(process_in->state->s == LTTV_STATE_WAIT) |
68997a22 |
1513 | prop_text_in.text = "W"; |
a56a1ba4 |
1514 | else if(process_in->state->s == LTTV_STATE_RUN) |
68997a22 |
1515 | prop_text_in.text = "R"; |
a56a1ba4 |
1516 | else |
68997a22 |
1517 | prop_text_in.text = "U"; |
a56a1ba4 |
1518 | |
1519 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
1520 | |
d0cd7f09 |
1521 | |
319e9d81 |
1522 | if(process_in->state->s == LTTV_STATE_RUN) |
1523 | { |
1524 | gchar tmp[255]; |
1525 | prop_text_in.foreground = &colorfg_in; |
1526 | prop_text_in.background = &colorbg_in; |
1527 | prop_text_in.foreground->red = 0xffff; |
1528 | prop_text_in.foreground->green = 0xffff; |
1529 | prop_text_in.foreground->blue = 0xffff; |
1530 | prop_text_in.size = 6; |
1531 | prop_text_in.position = UNDER; |
1532 | |
1533 | prop_text_in.text = g_new(gchar, 260); |
1534 | strcpy(prop_text_in.text, "CPU "); |
1535 | snprintf(tmp, 255, "%u", tfc->index); |
1536 | strcat(prop_text_in.text, tmp); |
1537 | |
1538 | draw_text((void*)&prop_text_in, (void*)draw_context_in); |
1539 | g_free(prop_text_in.text); |
1540 | } |
1541 | |
1542 | |
68997a22 |
1543 | draw_context_in->current->middle->y = y_in+height/2; |
d0cd7f09 |
1544 | draw_context_in->current->over->y = y_in; |
1545 | draw_context_in->current->under->y = y_in+height; |
68997a22 |
1546 | draw_context_in->current->status = process_in->state->s; |
1547 | |
1548 | /* for pid_in : remove previous, Prev = current, new current (default) */ |
1549 | g_free(draw_context_in->previous->modify_under); |
1550 | g_free(draw_context_in->previous->modify_middle); |
1551 | g_free(draw_context_in->previous->modify_over); |
1552 | g_free(draw_context_in->previous->under); |
1553 | g_free(draw_context_in->previous->middle); |
1554 | g_free(draw_context_in->previous->over); |
1555 | g_free(draw_context_in->previous); |
1556 | |
1557 | draw_context_in->previous = draw_context_in->current; |
a56a1ba4 |
1558 | |
68997a22 |
1559 | draw_context_in->current = g_new(DrawInfo,1); |
1560 | draw_context_in->current->over = g_new(ItemInfo,1); |
1561 | draw_context_in->current->over->x = -1; |
1562 | draw_context_in->current->over->y = -1; |
1563 | draw_context_in->current->middle = g_new(ItemInfo,1); |
1564 | draw_context_in->current->middle->x = -1; |
1565 | draw_context_in->current->middle->y = -1; |
1566 | draw_context_in->current->under = g_new(ItemInfo,1); |
1567 | draw_context_in->current->under->x = -1; |
1568 | draw_context_in->current->under->y = -1; |
1569 | draw_context_in->current->modify_over = g_new(ItemInfo,1); |
1570 | draw_context_in->current->modify_over->x = -1; |
1571 | draw_context_in->current->modify_over->y = -1; |
1572 | draw_context_in->current->modify_middle = g_new(ItemInfo,1); |
1573 | draw_context_in->current->modify_middle->x = -1; |
1574 | draw_context_in->current->modify_middle->y = -1; |
1575 | draw_context_in->current->modify_under = g_new(ItemInfo,1); |
1576 | draw_context_in->current->modify_under->x = -1; |
1577 | draw_context_in->current->modify_under->y = -1; |
1578 | draw_context_in->current->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
1579 | |
1580 | } |
1581 | |
1582 | return 0; |
b9a010a2 |
1583 | #endif //0 |
f0d936c0 |
1584 | } |
f7afe191 |
1585 | |
1586 | |
1587 | |
1588 | |
1b238973 |
1589 | gint update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
1590 | { |
a56a1ba4 |
1591 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
a43d67ba |
1592 | Drawing_t *drawing = control_flow_data->drawing; |
1593 | |
224446ce |
1594 | const TimeWindowNotifyData *time_window_nofify_data = |
1595 | ((const TimeWindowNotifyData *)call_data); |
1596 | |
14963be0 |
1597 | TimeWindow *old_time_window = |
224446ce |
1598 | time_window_nofify_data->old_time_window; |
1599 | TimeWindow *new_time_window = |
1600 | time_window_nofify_data->new_time_window; |
a56a1ba4 |
1601 | |
3cb8b205 |
1602 | /* Update the ruler */ |
1603 | drawing_update_ruler(control_flow_data->drawing, |
1604 | new_time_window); |
1605 | |
1606 | |
a56a1ba4 |
1607 | /* Two cases : zoom in/out or scrolling */ |
1608 | |
1609 | /* In order to make sure we can reuse the old drawing, the scale must |
1610 | * be the same and the new time interval being partly located in the |
1611 | * currently shown time interval. (reuse is only for scrolling) |
1612 | */ |
1613 | |
1614 | g_info("Old time window HOOK : %u, %u to %u, %u", |
14963be0 |
1615 | old_time_window->start_time.tv_sec, |
1616 | old_time_window->start_time.tv_nsec, |
1617 | old_time_window->time_width.tv_sec, |
1618 | old_time_window->time_width.tv_nsec); |
a56a1ba4 |
1619 | |
1620 | g_info("New time window HOOK : %u, %u to %u, %u", |
14963be0 |
1621 | new_time_window->start_time.tv_sec, |
1622 | new_time_window->start_time.tv_nsec, |
1623 | new_time_window->time_width.tv_sec, |
1624 | new_time_window->time_width.tv_nsec); |
a56a1ba4 |
1625 | |
14963be0 |
1626 | if( new_time_window->time_width.tv_sec == old_time_window->time_width.tv_sec |
1627 | && new_time_window->time_width.tv_nsec == old_time_window->time_width.tv_nsec) |
a56a1ba4 |
1628 | { |
1629 | /* Same scale (scrolling) */ |
1630 | g_info("scrolling"); |
14963be0 |
1631 | LttTime *ns = &new_time_window->start_time; |
1632 | LttTime *os = &old_time_window->start_time; |
1633 | LttTime old_end = ltt_time_add(old_time_window->start_time, |
1634 | old_time_window->time_width); |
1635 | LttTime new_end = ltt_time_add(new_time_window->start_time, |
1636 | new_time_window->time_width); |
a56a1ba4 |
1637 | //if(ns<os+w<ns+w) |
1638 | //if(ns<os+w && os+w<ns+w) |
1639 | //if(ns<old_end && os<ns) |
1640 | if(ltt_time_compare(*ns, old_end) == -1 |
1641 | && ltt_time_compare(*os, *ns) == -1) |
1642 | { |
1643 | g_info("scrolling near right"); |
1644 | /* Scroll right, keep right part of the screen */ |
1645 | guint x = 0; |
51705146 |
1646 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
1647 | convert_time_to_pixels( |
1648 | *os, |
1649 | old_end, |
1650 | *ns, |
1651 | width, |
1652 | &x); |
1653 | |
1654 | /* Copy old data to new location */ |
501d5405 |
1655 | gdk_draw_drawable (control_flow_data->drawing->pixmap, |
cfe526b1 |
1656 | control_flow_data->drawing->drawing_area->style->black_gc, |
501d5405 |
1657 | control_flow_data->drawing->pixmap, |
a56a1ba4 |
1658 | x, 0, |
1659 | 0, 0, |
6395d57c |
1660 | control_flow_data->drawing->width-x+SAFETY, -1); |
1661 | |
1662 | if(drawing->damage_begin == drawing->damage_end) |
1663 | drawing->damage_begin = control_flow_data->drawing->width-x; |
1664 | else |
1665 | drawing->damage_begin = 0; |
1666 | |
1667 | drawing->damage_end = control_flow_data->drawing->width; |
1668 | |
a56a1ba4 |
1669 | /* Clear the data request background, but not SAFETY */ |
501d5405 |
1670 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
6395d57c |
1671 | //control_flow_data->drawing->drawing_area->style->black_gc, |
cfe526b1 |
1672 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
1673 | TRUE, |
6395d57c |
1674 | drawing->damage_begin+SAFETY, 0, |
1675 | drawing->damage_end - drawing->damage_begin, // do not overlap |
51705146 |
1676 | control_flow_data->drawing->height); |
a43d67ba |
1677 | |
51705146 |
1678 | gtk_widget_queue_draw_area (drawing->drawing_area, |
a43d67ba |
1679 | 0,0, |
6395d57c |
1680 | control_flow_data->drawing->width, |
a43d67ba |
1681 | control_flow_data->drawing->height); |
1682 | |
a56a1ba4 |
1683 | /* Get new data for the rest. */ |
501d5405 |
1684 | drawing_data_request(control_flow_data->drawing, |
1685 | &control_flow_data->drawing->pixmap, |
6395d57c |
1686 | drawing->damage_begin, 0, |
1687 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
1688 | control_flow_data->drawing->height); |
a56a1ba4 |
1689 | } else { |
1690 | //if(ns<os<ns+w) |
1691 | //if(ns<os && os<ns+w) |
1692 | //if(ns<os && os<new_end) |
1693 | if(ltt_time_compare(*ns,*os) == -1 |
1694 | && ltt_time_compare(*os,new_end) == -1) |
1695 | { |
1696 | g_info("scrolling near left"); |
1697 | /* Scroll left, keep left part of the screen */ |
1698 | guint x = 0; |
51705146 |
1699 | guint width = control_flow_data->drawing->width; |
a56a1ba4 |
1700 | convert_time_to_pixels( |
1701 | *ns, |
1702 | new_end, |
1703 | *os, |
1704 | width, |
1705 | &x); |
6395d57c |
1706 | |
1707 | |
a56a1ba4 |
1708 | /* Copy old data to new location */ |
501d5405 |
1709 | gdk_draw_drawable (control_flow_data->drawing->pixmap, |
cfe526b1 |
1710 | control_flow_data->drawing->drawing_area->style->black_gc, |
501d5405 |
1711 | control_flow_data->drawing->pixmap, |
a56a1ba4 |
1712 | 0, 0, |
1713 | x, 0, |
1714 | -1, -1); |
1715 | |
6395d57c |
1716 | if(drawing->damage_begin == drawing->damage_end) |
1717 | drawing->damage_end = x; |
1718 | else |
1719 | drawing->damage_end = |
51705146 |
1720 | control_flow_data->drawing->width; |
6395d57c |
1721 | |
1722 | drawing->damage_begin = 0; |
1723 | |
501d5405 |
1724 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
cfe526b1 |
1725 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
1726 | TRUE, |
6395d57c |
1727 | drawing->damage_begin, 0, |
1728 | drawing->damage_end - drawing->damage_begin, // do not overlap |
51705146 |
1729 | control_flow_data->drawing->height); |
a43d67ba |
1730 | |
6395d57c |
1731 | gtk_widget_queue_draw_area (drawing->drawing_area, |
1732 | 0,0, |
1733 | control_flow_data->drawing->width, |
a43d67ba |
1734 | control_flow_data->drawing->height); |
1735 | |
6395d57c |
1736 | |
a56a1ba4 |
1737 | /* Get new data for the rest. */ |
501d5405 |
1738 | drawing_data_request(control_flow_data->drawing, |
1739 | &control_flow_data->drawing->pixmap, |
6395d57c |
1740 | drawing->damage_begin, 0, |
1741 | drawing->damage_end - drawing->damage_begin, |
501d5405 |
1742 | control_flow_data->drawing->height); |
a56a1ba4 |
1743 | |
a56a1ba4 |
1744 | } else { |
a43d67ba |
1745 | if(ltt_time_compare(*ns,*os) == 0) |
1746 | { |
1747 | g_info("not scrolling"); |
1748 | } else { |
1749 | g_info("scrolling far"); |
1750 | /* Cannot reuse any part of the screen : far jump */ |
1751 | |
1752 | |
1753 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
1754 | control_flow_data->drawing->drawing_area->style->black_gc, |
1755 | TRUE, |
a56a1ba4 |
1756 | 0, 0, |
a43d67ba |
1757 | control_flow_data->drawing->width+SAFETY, // do not overlap |
51705146 |
1758 | control_flow_data->drawing->height); |
a43d67ba |
1759 | |
1760 | gtk_widget_queue_draw_area (drawing->drawing_area, |
1761 | 0,0, |
1762 | control_flow_data->drawing->width, |
1763 | control_flow_data->drawing->height); |
1764 | |
6395d57c |
1765 | drawing->damage_begin = 0; |
1766 | drawing->damage_end = control_flow_data->drawing->width; |
1767 | |
a43d67ba |
1768 | drawing_data_request(control_flow_data->drawing, |
1769 | &control_flow_data->drawing->pixmap, |
1770 | 0, 0, |
1771 | control_flow_data->drawing->width, |
1772 | control_flow_data->drawing->height); |
1773 | |
1774 | } |
a56a1ba4 |
1775 | } |
1776 | } |
1777 | } else { |
1778 | /* Different scale (zoom) */ |
1779 | g_info("zoom"); |
1780 | |
501d5405 |
1781 | gdk_draw_rectangle (control_flow_data->drawing->pixmap, |
cfe526b1 |
1782 | control_flow_data->drawing->drawing_area->style->black_gc, |
a56a1ba4 |
1783 | TRUE, |
1784 | 0, 0, |
501d5405 |
1785 | control_flow_data->drawing->width+SAFETY, // do not overlap |
51705146 |
1786 | control_flow_data->drawing->height); |
a56a1ba4 |
1787 | |
a43d67ba |
1788 | gtk_widget_queue_draw_area (drawing->drawing_area, |
1789 | 0,0, |
1790 | control_flow_data->drawing->width, |
1791 | control_flow_data->drawing->height); |
a56a1ba4 |
1792 | |
6395d57c |
1793 | drawing->damage_begin = 0; |
1794 | drawing->damage_end = control_flow_data->drawing->width; |
1795 | |
501d5405 |
1796 | drawing_data_request(control_flow_data->drawing, |
1797 | &control_flow_data->drawing->pixmap, |
a56a1ba4 |
1798 | 0, 0, |
501d5405 |
1799 | control_flow_data->drawing->width, |
1800 | control_flow_data->drawing->height); |
a56a1ba4 |
1801 | } |
1802 | |
3cb8b205 |
1803 | |
1804 | |
a56a1ba4 |
1805 | return 0; |
f7afe191 |
1806 | } |
1807 | |
6395d57c |
1808 | gint traceset_notify(void *hook_data, void *call_data) |
1809 | { |
1810 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
1811 | Drawing_t *drawing = control_flow_data->drawing; |
1812 | GtkWidget *widget = drawing->drawing_area; |
1813 | |
1814 | drawing->damage_begin = 0; |
51705146 |
1815 | drawing->damage_end = drawing->width; |
6395d57c |
1816 | |
b9a010a2 |
1817 | drawing_clear(control_flow_data->drawing); |
1818 | processlist_clear(control_flow_data->process_list); |
6395d57c |
1819 | |
1820 | if(drawing->damage_begin < drawing->damage_end) |
1821 | { |
1822 | drawing_data_request(drawing, |
1823 | &drawing->pixmap, |
1824 | drawing->damage_begin, |
1825 | 0, |
1826 | drawing->damage_end-drawing->damage_begin, |
51705146 |
1827 | drawing->height); |
6395d57c |
1828 | } |
1829 | |
1830 | gtk_widget_queue_draw_area(drawing->drawing_area, |
1831 | 0,0, |
1832 | drawing->width, |
1833 | drawing->height); |
1834 | |
1835 | request_background_data(control_flow_data); |
1836 | |
1837 | return FALSE; |
1838 | } |
1839 | |
ca0f8a8e |
1840 | gint redraw_notify(void *hook_data, void *call_data) |
1841 | { |
1842 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
1843 | Drawing_t *drawing = control_flow_data->drawing; |
1844 | GtkWidget *widget = drawing->drawing_area; |
1845 | |
1846 | drawing->damage_begin = 0; |
51705146 |
1847 | drawing->damage_end = drawing->width; |
ca0f8a8e |
1848 | |
1849 | |
1850 | // Clear the image |
1851 | gdk_draw_rectangle (drawing->pixmap, |
1852 | widget->style->black_gc, |
1853 | TRUE, |
1854 | 0, 0, |
51705146 |
1855 | drawing->width+SAFETY, |
1856 | drawing->height); |
ca0f8a8e |
1857 | |
1858 | |
1859 | if(drawing->damage_begin < drawing->damage_end) |
1860 | { |
1861 | drawing_data_request(drawing, |
1862 | &drawing->pixmap, |
1863 | drawing->damage_begin, |
1864 | 0, |
1865 | drawing->damage_end-drawing->damage_begin, |
51705146 |
1866 | drawing->height); |
ca0f8a8e |
1867 | } |
1868 | |
1869 | gtk_widget_queue_draw_area(drawing->drawing_area, |
1870 | 0,0, |
1871 | drawing->width, |
1872 | drawing->height); |
1873 | |
1874 | return FALSE; |
1875 | |
1876 | } |
1877 | |
1878 | |
1879 | gint continue_notify(void *hook_data, void *call_data) |
a43d67ba |
1880 | { |
1881 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
ca0f8a8e |
1882 | Drawing_t *drawing = control_flow_data->drawing; |
1883 | GtkWidget *widget = drawing->drawing_area; |
a43d67ba |
1884 | |
6395d57c |
1885 | //g_assert(widget->allocation.width == drawing->damage_end); |
ca0f8a8e |
1886 | |
1887 | if(drawing->damage_begin < drawing->damage_end) |
1888 | { |
1889 | drawing_data_request(drawing, |
1890 | &drawing->pixmap, |
1891 | drawing->damage_begin, |
1892 | 0, |
1893 | drawing->damage_end-drawing->damage_begin, |
51705146 |
1894 | drawing->height); |
ca0f8a8e |
1895 | } |
1896 | |
1897 | return FALSE; |
1898 | } |
1899 | |
1900 | |
1b238973 |
1901 | gint update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
1902 | { |
14963be0 |
1903 | ControlFlowData *control_flow_data = (ControlFlowData*)hook_data; |
a43d67ba |
1904 | Drawing_t *drawing = control_flow_data->drawing; |
a56a1ba4 |
1905 | |
224446ce |
1906 | LttTime current_time = *((LttTime*)call_data); |
a56a1ba4 |
1907 | |
ca0f8a8e |
1908 | TimeWindow time_window = |
1909 | lttvwindow_get_time_window(control_flow_data->tab); |
a56a1ba4 |
1910 | |
ca0f8a8e |
1911 | LttTime time_begin = time_window.start_time; |
1912 | LttTime width = time_window.time_width; |
a56a1ba4 |
1913 | LttTime half_width = ltt_time_div(width,2.0); |
1914 | LttTime time_end = ltt_time_add(time_begin, width); |
1915 | |
1916 | LttvTracesetContext * tsc = |
ca0f8a8e |
1917 | lttvwindow_get_traceset_context(control_flow_data->tab); |
a56a1ba4 |
1918 | |
ca0f8a8e |
1919 | LttTime trace_start = tsc->time_span.start_time; |
1920 | LttTime trace_end = tsc->time_span.end_time; |
a56a1ba4 |
1921 | |
224446ce |
1922 | g_info("New current time HOOK : %u, %u", current_time.tv_sec, |
1923 | current_time.tv_nsec); |
a56a1ba4 |
1924 | |
1925 | |
1926 | |
1927 | /* If current time is inside time interval, just move the highlight |
1928 | * bar */ |
1929 | |
1930 | /* Else, we have to change the time interval. We have to tell it |
1931 | * to the main window. */ |
1932 | /* The time interval change will take care of placing the current |
1933 | * time at the center of the visible area, or nearest possible if we are |
1934 | * at one end of the trace. */ |
1935 | |
1936 | |
224446ce |
1937 | if(ltt_time_compare(current_time, time_begin) == -1) |
a56a1ba4 |
1938 | { |
224446ce |
1939 | TimeWindow new_time_window; |
1940 | |
1941 | if(ltt_time_compare(current_time, |
a56a1ba4 |
1942 | ltt_time_add(trace_start,half_width)) == -1) |
1943 | time_begin = trace_start; |
1944 | else |
224446ce |
1945 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
1946 | |
224446ce |
1947 | new_time_window.start_time = time_begin; |
1948 | new_time_window.time_width = width; |
a56a1ba4 |
1949 | |
ca0f8a8e |
1950 | lttvwindow_report_time_window(control_flow_data->tab, &new_time_window); |
a56a1ba4 |
1951 | } |
224446ce |
1952 | else if(ltt_time_compare(current_time, time_end) == 1) |
a56a1ba4 |
1953 | { |
224446ce |
1954 | TimeWindow new_time_window; |
1955 | |
1956 | if(ltt_time_compare(current_time, ltt_time_sub(trace_end, half_width)) == 1) |
a56a1ba4 |
1957 | time_begin = ltt_time_sub(trace_end,width); |
1958 | else |
224446ce |
1959 | time_begin = ltt_time_sub(current_time,half_width); |
a56a1ba4 |
1960 | |
224446ce |
1961 | new_time_window.start_time = time_begin; |
1962 | new_time_window.time_width = width; |
a56a1ba4 |
1963 | |
ca0f8a8e |
1964 | lttvwindow_report_time_window(control_flow_data->tab, &new_time_window); |
a56a1ba4 |
1965 | |
1966 | } |
a43d67ba |
1967 | //gtk_widget_queue_draw(control_flow_data->drawing->drawing_area); |
1968 | gtk_widget_queue_draw_area(drawing->drawing_area, |
1969 | 0,0, |
1970 | drawing->width, |
1971 | drawing->height); |
a56a1ba4 |
1972 | |
1973 | return 0; |
f7afe191 |
1974 | } |
1975 | |
8b90e648 |
1976 | typedef struct _ClosureData { |
ca0f8a8e |
1977 | EventsRequest *events_request; |
d0cd7f09 |
1978 | LttvTracesetState *tss; |
b9a010a2 |
1979 | LttTime end_time; |
8b90e648 |
1980 | } ClosureData; |
a56a1ba4 |
1981 | |
8b90e648 |
1982 | |
1983 | void draw_closure(gpointer key, gpointer value, gpointer user_data) |
1984 | { |
b9a010a2 |
1985 | |
1986 | return; |
1987 | |
1988 | |
1989 | #if 0 |
a56a1ba4 |
1990 | ProcessInfo *process_info = (ProcessInfo*)key; |
1991 | HashedProcessData *hashed_process_data = (HashedProcessData*)value; |
1992 | ClosureData *closure_data = (ClosureData*)user_data; |
1993 | |
1994 | ControlFlowData *control_flow_data = |
ca0f8a8e |
1995 | closure_data->events_request->viewer_data; |
a56a1ba4 |
1996 | |
501d5405 |
1997 | GtkWidget *widget = control_flow_data->drawing->drawing_area; |
a56a1ba4 |
1998 | |
1999 | /* Get y position of process */ |
2000 | gint y=0, height=0; |
2001 | |
ba90bc77 |
2002 | processlist_get_pixels_from_data( control_flow_data->process_list, |
a56a1ba4 |
2003 | process_info, |
2004 | hashed_process_data, |
2005 | &y, |
2006 | &height); |
2007 | /* Get last state of process */ |
2008 | LttvTraceContext *tc = |
d0cd7f09 |
2009 | ((LttvTracesetContext*)closure_data->tss)->traces[process_info->trace_num]; |
ca0f8a8e |
2010 | LttvTracesetContext *tsc = (LttvTracesetContext *)closure_data->tss; |
8b90e648 |
2011 | |
d0cd7f09 |
2012 | LttvTraceState *ts = (LttvTraceState*)tc; |
a56a1ba4 |
2013 | LttvProcessState *process; |
2014 | |
2a2fa4f0 |
2015 | /* We do not provide a cpu_name argument assuming that this is not the |
2016 | idle job (pid 0) and thus its pid is unique across all cpus */ |
2017 | process = lttv_state_find_process_from_trace(ts, 0, process_info->pid); |
a56a1ba4 |
2018 | |
2019 | /* Draw the closing line */ |
2020 | DrawContext *draw_context = hashed_process_data->draw_context; |
68997a22 |
2021 | if(draw_context->previous->middle->x == -1) |
a56a1ba4 |
2022 | { |
ca0f8a8e |
2023 | draw_context->previous->over->x = |
2024 | control_flow_data->drawing->damage_begin; |
2025 | draw_context->previous->middle->x = |
2026 | control_flow_data->drawing->damage_begin; |
2027 | draw_context->previous->under->x = |
2028 | control_flow_data->drawing->damage_begin; |
2029 | |
2030 | g_debug("out middle x_beg : %u",control_flow_data->drawing->damage_begin); |
a56a1ba4 |
2031 | } |
2032 | |
ca0f8a8e |
2033 | /* Find pixels corresponding to current time . If the time does |
2034 | * not fit in the window, show a warning, not supposed to happend. */ |
2035 | guint x = 0; |
51705146 |
2036 | guint width = control_flow_data->drawing->width; |
ca0f8a8e |
2037 | |
2038 | TimeWindow time_window = |
2039 | lttvwindow_get_time_window(control_flow_data->tab); |
2040 | |
2041 | LttTime time = lttv_traceset_context_get_current_tfc(tsc)->timestamp; |
2042 | |
2043 | LttTime window_end = ltt_time_add(time_window.time_width, |
2044 | time_window.start_time); |
2045 | |
2046 | convert_time_to_pixels( |
2047 | time_window.start_time, |
2048 | window_end, |
2049 | time, |
2050 | width, |
2051 | &x); |
2052 | |
2053 | draw_context->current->middle->x = x; |
2054 | draw_context->current->over->x = x; |
2055 | draw_context->current->under->x = x; |
68997a22 |
2056 | draw_context->current->middle->y = y + height/2; |
d0cd7f09 |
2057 | draw_context->current->over->y = y ; |
2058 | draw_context->current->under->y = y + height; |
68997a22 |
2059 | draw_context->previous->middle->y = y + height/2; |
d0cd7f09 |
2060 | draw_context->previous->over->y = y ; |
2061 | draw_context->previous->under->y = y + height; |
501d5405 |
2062 | draw_context->drawable = control_flow_data->drawing->pixmap; |
2063 | draw_context->pango_layout = control_flow_data->drawing->pango_layout; |
a56a1ba4 |
2064 | //draw_context->gc = widget->style->black_gc; |
51705146 |
2065 | //draw_context->gc = gdk_gc_new(control_flow_data->drawing->pixmap); |
2066 | //gdk_gc_copy(draw_context->gc, widget->style->black_gc); |
2067 | draw_context->gc = control_flow_data->drawing->gc; |
d0cd7f09 |
2068 | |
ad2e83ba |
2069 | if(process != NULL && process->state->s == LTTV_STATE_RUN) |
d0cd7f09 |
2070 | { |
2071 | PropertiesBG prop_bg; |
2072 | prop_bg.color = g_new(GdkColor,1); |
2073 | |
2074 | /*switch(tfc->index) { |
2075 | case 0: |
2076 | prop_bg.color->red = 0x1515; |
2077 | prop_bg.color->green = 0x1515; |
2078 | prop_bg.color->blue = 0x8c8c; |
2079 | break; |
2080 | case 1: |
2081 | prop_bg.color->red = 0x4e4e; |
2082 | prop_bg.color->green = 0xa9a9; |
2083 | prop_bg.color->blue = 0xa4a4; |
2084 | break; |
2085 | case 2: |
2086 | prop_bg.color->red = 0x7a7a; |
2087 | prop_bg.color->green = 0x4a4a; |
2088 | prop_bg.color->blue = 0x8b8b; |
2089 | break; |
2090 | case 3: |
2091 | prop_bg.color->red = 0x8080; |
2092 | prop_bg.color->green = 0x7777; |
2093 | prop_bg.color->blue = 0x4747; |
2094 | break; |
2095 | default: |
2096 | prop_bg.color->red = 0xe7e7; |
2097 | prop_bg.color->green = 0xe7e7; |
2098 | prop_bg.color->blue = 0xe7e7; |
2099 | } |
2100 | */ |
2101 | |
2a2fa4f0 |
2102 | g_debug("calling from closure"); |
d0cd7f09 |
2103 | //FIXME : I need the cpu number in process's state to draw this. |
2104 | //draw_bg((void*)&prop_bg, (void*)draw_context); |
2105 | g_free(prop_bg.color); |
2106 | } |
2107 | |
a56a1ba4 |
2108 | |
2109 | PropertiesLine prop_line; |
2110 | prop_line.color = g_new(GdkColor,1); |
cfe526b1 |
2111 | prop_line.line_width = 2; |
a56a1ba4 |
2112 | prop_line.style = GDK_LINE_SOLID; |
2113 | prop_line.position = MIDDLE; |
2114 | |
2115 | /* color of line : status of the process */ |
ad2e83ba |
2116 | if(process != NULL) |
a56a1ba4 |
2117 | { |
ad2e83ba |
2118 | if(process->state->s == LTTV_STATE_UNNAMED) |
2119 | { |
2120 | prop_line.color->red = 0xffff; |
2121 | prop_line.color->green = 0xffff; |
2122 | prop_line.color->blue = 0xffff; |
2123 | } |
2124 | else if(process->state->s == LTTV_STATE_WAIT_FORK) |
2125 | { |
2126 | prop_line.color->red = 0x0fff; |
2127 | prop_line.color->green = 0xffff; |
2128 | prop_line.color->blue = 0xfff0; |
2129 | } |
2130 | else if(process->state->s == LTTV_STATE_WAIT_CPU) |
2131 | { |
2132 | prop_line.color->red = 0xffff; |
2133 | prop_line.color->green = 0xffff; |
2134 | prop_line.color->blue = 0x0000; |
2135 | } |
2136 | else if(process->state->s == LTTV_STATE_EXIT) |
2137 | { |
2138 | prop_line.color->red = 0xffff; |
2139 | prop_line.color->green = 0x0000; |
2140 | prop_line.color->blue = 0xffff; |
2141 | } |
2142 | else if(process->state->s == LTTV_STATE_WAIT) |
2143 | { |
2144 | prop_line.color->red = 0xffff; |
2145 | prop_line.color->green = 0x0000; |
2146 | prop_line.color->blue = 0x0000; |
2147 | } |
2148 | else if(process->state->s == LTTV_STATE_RUN) |
2149 | { |
2150 | prop_line.color->red = 0x0000; |
2151 | prop_line.color->green = 0xffff; |
2152 | prop_line.color->blue = 0x0000; |
2153 | } |
2154 | else |
2155 | { |
2156 | prop_line.color->red = 0xffff; |
2157 | prop_line.color->green = 0xffff; |
2158 | prop_line.color->blue = 0xffff; |
2159 | } |
2160 | |
a56a1ba4 |
2161 | } |
2162 | else |
2163 | { |
ad2e83ba |
2164 | prop_line.color->red = 0xffff; |
2165 | prop_line.color->green = 0xffff; |
2166 | prop_line.color->blue = 0xffff; |
a56a1ba4 |
2167 | } |
2168 | |
2169 | draw_line((void*)&prop_line, (void*)draw_context); |
2170 | g_free(prop_line.color); |
51705146 |
2171 | //gdk_gc_unref(draw_context->gc); |
a56a1ba4 |
2172 | |
2173 | /* Reset draw_context of the process for next request */ |
2174 | |
2175 | hashed_process_data->draw_context->drawable = NULL; |
2176 | hashed_process_data->draw_context->gc = NULL; |
2177 | hashed_process_data->draw_context->pango_layout = NULL; |
68997a22 |
2178 | hashed_process_data->draw_context->current->over->x = -1; |
2179 | hashed_process_data->draw_context->current->over->y = -1; |
2180 | hashed_process_data->draw_context->current->middle->x = -1; |
2181 | hashed_process_data->draw_context->current->middle->y = -1; |
2182 | hashed_process_data->draw_context->current->under->x = -1; |
2183 | hashed_process_data->draw_context->current->under->y = -1; |
2184 | hashed_process_data->draw_context->current->modify_over->x = -1; |
2185 | hashed_process_data->draw_context->current->modify_over->y = -1; |
2186 | hashed_process_data->draw_context->current->modify_middle->x = -1; |
2187 | hashed_process_data->draw_context->current->modify_middle->y = -1; |
2188 | hashed_process_data->draw_context->current->modify_under->x = -1; |
2189 | hashed_process_data->draw_context->current->modify_under->y = -1; |
2190 | hashed_process_data->draw_context->current->status = LTTV_STATE_UNNAMED; |
2191 | hashed_process_data->draw_context->previous->over->x = -1; |
2192 | hashed_process_data->draw_context->previous->over->y = -1; |
2193 | hashed_process_data->draw_context->previous->middle->x = -1; |
2194 | hashed_process_data->draw_context->previous->middle->y = -1; |
2195 | hashed_process_data->draw_context->previous->under->x = -1; |
2196 | hashed_process_data->draw_context->previous->under->y = -1; |
2197 | hashed_process_data->draw_context->previous->modify_over->x = -1; |
2198 | hashed_process_data->draw_context->previous->modify_over->y = -1; |
2199 | hashed_process_data->draw_context->previous->modify_middle->x = -1; |
2200 | hashed_process_data->draw_context->previous->modify_middle->y = -1; |
2201 | hashed_process_data->draw_context->previous->modify_under->x = -1; |
2202 | hashed_process_data->draw_context->previous->modify_under->y = -1; |
2203 | hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED; |
8b90e648 |
2204 | |
b9a010a2 |
2205 | #endif //0 |
8b90e648 |
2206 | } |
2207 | |
b9a010a2 |
2208 | int before_chunk(void *hook_data, void *call_data) |
2209 | { |
2210 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2211 | LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data); |
2212 | |
2213 | drawing_chunk_begin(events_request, tss); |
2214 | |
2215 | return 0; |
2216 | } |
2217 | |
2218 | int before_request(void *hook_data, void *call_data) |
ca0f8a8e |
2219 | { |
2220 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2221 | LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data); |
2222 | |
2223 | drawing_data_request_begin(events_request, tss); |
2224 | |
2225 | return 0; |
2226 | } |
2227 | |
2228 | |
8b90e648 |
2229 | /* |
b9a010a2 |
2230 | * after request is necessary in addition of after chunk in order to draw |
2231 | * lines until the end of the screen. after chunk just draws lines until |
2232 | * the last event. |
2233 | * |
8b90e648 |
2234 | * for each process |
a56a1ba4 |
2235 | * draw closing line |
b9a010a2 |
2236 | * expose |
8b90e648 |
2237 | */ |
b9a010a2 |
2238 | int after_request(void *hook_data, void *call_data) |
8b90e648 |
2239 | { |
ca0f8a8e |
2240 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2241 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2242 | LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data); |
b9a010a2 |
2243 | LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(call_data); |
a56a1ba4 |
2244 | |
2245 | ProcessList *process_list = |
ca0f8a8e |
2246 | guicontrolflow_get_process_list(control_flow_data); |
b9a010a2 |
2247 | LttTime end_time = events_request->end_time; |
2248 | |
2249 | ClosureData closure_data; |
2250 | closure_data.events_request = (EventsRequest*)hook_data; |
2251 | closure_data.tss = tss; |
2252 | closure_data.end_time = end_time; |
2253 | |
2254 | /* Draw last items */ |
2255 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
2256 | (void*)&closure_data); |
2257 | |
2258 | /* Request expose */ |
2259 | drawing_request_expose(events_request, tss, end_time); |
2260 | return 0; |
2261 | } |
2262 | |
2263 | /* |
2264 | * for each process |
2265 | * draw closing line |
2266 | * expose |
2267 | */ |
2268 | int after_chunk(void *hook_data, void *call_data) |
2269 | { |
2270 | EventsRequest *events_request = (EventsRequest*)hook_data; |
2271 | ControlFlowData *control_flow_data = events_request->viewer_data; |
2272 | LttvTracesetState *tss = LTTV_TRACESET_STATE(call_data); |
2273 | LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(call_data); |
2274 | LttvTracefileContext *tfc = lttv_traceset_context_get_current_tfc(tsc); |
2275 | LttTime end_time; |
2276 | |
2277 | ProcessList *process_list = |
2278 | guicontrolflow_get_process_list(control_flow_data); |
2279 | |
0c5dbe3b |
2280 | if(tfc != NULL |
2281 | && ltt_time_compare(tfc->timestamp, events_request->end_time) <= 0) |
b9a010a2 |
2282 | end_time = tfc->timestamp; |
0c5dbe3b |
2283 | else /* end of traceset, or position now out of request : end */ |
2284 | end_time = events_request->end_time; |
2285 | |
a56a1ba4 |
2286 | ClosureData closure_data; |
ca0f8a8e |
2287 | closure_data.events_request = (EventsRequest*)hook_data; |
2288 | closure_data.tss = tss; |
b9a010a2 |
2289 | closure_data.end_time = end_time; |
a56a1ba4 |
2290 | |
b9a010a2 |
2291 | /* Draw last items */ |
14963be0 |
2292 | g_hash_table_foreach(process_list->process_hash, draw_closure, |
a56a1ba4 |
2293 | (void*)&closure_data); |
a43d67ba |
2294 | |
ca0f8a8e |
2295 | /* Request expose */ |
b9a010a2 |
2296 | drawing_request_expose(events_request, tss, end_time); |
ca0f8a8e |
2297 | |
2298 | return 0; |
8b90e648 |
2299 | } |
2300 | |