Commit | Line | Data |
---|---|---|
8c108c1c PMF |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2008 Pierre-Marc Fournier | |
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 | #ifdef HAVE_CONFIG_H | |
20 | #include <config.h> | |
21 | #endif | |
c7cb53d7 YB |
22 | #define _GNU_SOURCE |
23 | #include <stdio.h> | |
8c108c1c PMF |
24 | |
25 | #include <lttv/lttv.h> | |
26 | #include <lttv/option.h> | |
27 | #include <lttv/module.h> | |
28 | #include <lttv/hook.h> | |
29 | #include <lttv/attribute.h> | |
30 | #include <lttv/iattribute.h> | |
31 | #include <lttv/stats.h> | |
32 | #include <lttv/filter.h> | |
33 | #include <lttv/print.h> | |
34 | #include <ltt/ltt.h> | |
35 | #include <ltt/event.h> | |
36 | #include <ltt/trace.h> | |
c7cb53d7 | 37 | |
8c108c1c PMF |
38 | #include <glib.h> |
39 | #include <stdlib.h> | |
40 | ||
41 | #include "sstack.h" | |
42 | ||
43 | static LttvHooks | |
44 | *before_traceset, | |
45 | *after_traceset, | |
8c108c1c PMF |
46 | *event_hook; |
47 | ||
48 | static int depanalysis_range_pid = -1; | |
49 | static int depanalysis_range_pid_searching = -1; | |
50 | static int depanalysis_use_time=0; | |
51 | static int depanalysis_event_limit = -1; | |
55cd92ee | 52 | static int a_print_simple_summary = 0; |
8c108c1c PMF |
53 | static LttTime depanalysis_time1, depanalysis_time2; |
54 | static char *arg_t1_str,*arg_t2_str; | |
55 | static int statedump_finished = 0; | |
56 | ||
57 | ||
58 | struct llev_state_info_irq { | |
59 | int irq; | |
60 | }; | |
61 | ||
62 | struct llev_state_info_softirq { | |
63 | int softirq; | |
64 | }; | |
65 | ||
66 | struct llev_state_info_syscall { | |
67 | int syscall_id; | |
68 | ||
69 | int substate; | |
70 | ||
71 | void *private; | |
72 | }; | |
73 | ||
74 | struct llev_state_info_syscall__open { | |
75 | GQuark filename; | |
76 | }; | |
77 | ||
78 | struct llev_state_info_syscall__read { | |
79 | GQuark filename; | |
80 | }; | |
81 | ||
82 | struct llev_state_info_syscall__poll { | |
83 | GQuark filename; | |
84 | }; | |
85 | ||
86 | struct llev_state_info_preempted { | |
87 | int prev_state; | |
88 | }; | |
89 | ||
90 | struct hlev_state_info_blocked { | |
91 | int syscall_id; | |
92 | unsigned char trap; /* flag */ | |
93 | int substate; | |
94 | ||
95 | /* Garray of pointers to struct process_state that reflect the | |
96 | * low-level state stack when respectively entering and exiting the blocked | |
97 | * state. | |
98 | */ | |
99 | GArray *llev_state_entry; | |
100 | GArray *llev_state_exit; | |
101 | ||
102 | int pid_exit; /* FIXME: it's not pretty to have this here; find this info elsewhere */ | |
103 | LttTime time_woken; | |
104 | ||
105 | void *private; | |
106 | }; | |
107 | ||
108 | struct hlev_state_info_blocked__open { | |
109 | GQuark filename; | |
110 | }; | |
111 | ||
112 | struct hlev_state_info_blocked__read { | |
113 | GQuark filename; | |
114 | }; | |
115 | ||
116 | struct hlev_state_info_blocked__poll { | |
117 | GQuark filename; | |
118 | }; | |
119 | ||
120 | struct hlev_state_info_interrupted_irq { | |
121 | int irq; | |
122 | }; | |
123 | ||
124 | struct hlev_state_info_interrupted_softirq { | |
125 | int softirq; | |
126 | }; | |
127 | ||
128 | struct summary_tree_node { | |
129 | char *name; | |
130 | GHashTable *children; | |
131 | LttTime duration; | |
132 | GArray *episodes; | |
133 | int id_for_episodes; | |
134 | }; | |
135 | ||
136 | struct state_info { | |
137 | char name[40]; | |
138 | int size_priv; | |
139 | char *tree_path[6]; | |
140 | }; | |
141 | ||
142 | struct state_info llev_state_infos[] = { | |
143 | { "UNKNOWN", 0, { NULL } }, | |
144 | { "RUNNING", 0, { NULL } }, | |
145 | { "SYSCALL", sizeof(struct llev_state_info_syscall), { NULL } }, | |
146 | { "IRQ", sizeof(struct llev_state_info_irq), { NULL } }, | |
147 | { "SOFTIRQ", sizeof(struct llev_state_info_softirq), { NULL } }, | |
148 | { "TRAP", 0, { NULL } }, | |
149 | { "PREEMPTED", sizeof(struct llev_state_info_preempted), { NULL } }, | |
150 | }; | |
151 | ||
152 | struct state_info hlev_state_infos[] = { | |
153 | { "UNKNOWN", 0, { "Total", "Unknown", NULL } }, | |
154 | { "RUNNING", 0, { "Total", "Working", NULL } }, | |
155 | { "BLOCKED", sizeof(struct hlev_state_info_blocked), { "Total", "Blocked", NULL } }, | |
156 | { "INTERRUPTED_IRQ", sizeof(struct hlev_state_info_interrupted_irq), { "Total", "Interrupted", "IRQ", NULL } }, | |
157 | { "INTERRUPTED_SOFTIRQ", sizeof(struct hlev_state_info_interrupted_softirq), { "Total", "Interrupted", "SoftIRQ", NULL } }, | |
158 | { "INTERRUPTED_CPU", 0, { "Total", "Interrupted", "Preempted", NULL } }, | |
159 | { "INTERRUPTED_POST_BLOCK", 0, { "Total", "Interrupted", "Waiting schedule after blocking", NULL } }, | |
160 | }; | |
161 | ||
162 | enum llev_state { | |
163 | LLEV_UNKNOWN=0, | |
164 | LLEV_RUNNING, | |
165 | LLEV_SYSCALL, | |
166 | LLEV_IRQ, | |
167 | LLEV_SOFTIRQ, | |
168 | LLEV_TRAP, | |
169 | LLEV_PREEMPTED, | |
170 | }; | |
171 | ||
172 | enum llev_syscall_substate { | |
173 | LLEV_SYSCALL__UNDEFINED, | |
174 | LLEV_SYSCALL__OPEN, | |
175 | LLEV_SYSCALL__READ, | |
176 | LLEV_SYSCALL__POLL, | |
177 | }; | |
178 | ||
179 | enum hlev_event { | |
180 | HLEV_EVENT_TRY_WAKEUP=0, | |
181 | }; | |
182 | ||
183 | enum hlev_state { | |
184 | HLEV_UNKNOWN=0, | |
185 | HLEV_RUNNING, | |
186 | HLEV_BLOCKED, | |
187 | HLEV_INTERRUPTED_IRQ, | |
188 | HLEV_INTERRUPTED_SOFTIRQ, | |
189 | HLEV_INTERRUPTED_CPU, | |
190 | HLEV_INTERRUPTED_POST_BLOCK, | |
191 | }; | |
192 | ||
193 | enum hlev_state_blocked { | |
194 | HLEV_BLOCKED__UNDEFINED, | |
195 | HLEV_BLOCKED__OPEN, | |
196 | HLEV_BLOCKED__READ, | |
197 | HLEV_BLOCKED__POLL, | |
198 | }; | |
199 | ||
200 | struct sstack_event { | |
201 | int event_type; | |
202 | void *private; | |
203 | }; | |
204 | ||
205 | struct try_wakeup_event { | |
206 | int pid; /* this sould be more precise avec pid may be reused */ | |
207 | LttTime time; | |
208 | struct process *waker; | |
209 | }; | |
210 | ||
211 | struct process_state { | |
212 | int bstate; | |
213 | int cause_type; | |
214 | void *private; | |
215 | ||
216 | LttTime time_begin; | |
217 | LttTime time_end; | |
218 | }; | |
219 | ||
220 | struct process_with_state { | |
221 | struct process *process; | |
222 | struct process_state state; | |
223 | }; | |
224 | ||
225 | #define PROCESS_STATE_STACK_SIZE 10 | |
226 | struct process { | |
227 | int pid; | |
228 | GQuark name; | |
229 | int parent; | |
230 | ||
231 | struct sstack *stack; | |
232 | struct process_state *llev_state_stack[PROCESS_STATE_STACK_SIZE]; | |
233 | int stack_current; | |
234 | struct process_state *hlev_state; | |
235 | GArray *hlev_history; | |
236 | }; | |
237 | ||
238 | static inline void *old_process_state_private_data(struct process *p) | |
239 | { | |
240 | return p->llev_state_stack[p->stack_current]->private; | |
241 | } | |
242 | ||
243 | static inline struct process_state *process_find_state(struct process *p, enum llev_state st) | |
244 | { | |
245 | int i; | |
246 | ||
247 | for(i=p->stack->array->len-1; i>=0; i--) { | |
248 | struct sstack_item *item = g_array_index(p->stack->array, struct sstack_item *, i); | |
249 | ||
250 | struct process_with_state *pwstate = item->data_val; | |
251 | if(pwstate->state.bstate == st) { | |
252 | return &pwstate->state; | |
253 | } | |
254 | } | |
255 | ||
256 | return NULL; | |
257 | } | |
258 | ||
259 | static int find_pos_in_stack(enum llev_state lls, struct process *p) | |
260 | { | |
261 | int i; | |
262 | for(i=p->stack_current; i>=0; i--) { | |
263 | if(p->llev_state_stack[i]->bstate == lls) | |
264 | return i; | |
265 | } | |
266 | ||
267 | return -1; | |
268 | } | |
269 | ||
270 | static struct process_state *find_in_stack(enum llev_state lls, struct process *p) | |
271 | { | |
272 | int result; | |
273 | ||
274 | result = find_pos_in_stack(lls, p); | |
275 | ||
276 | if(result >= 0) | |
277 | return p->llev_state_stack[result]; | |
278 | else | |
279 | return NULL; | |
280 | ||
281 | } | |
282 | ||
283 | /* called back from sstack on deletion of a data_val which is | |
284 | * a struct process_with_state | |
285 | */ | |
286 | ||
287 | static void delete_data_val(struct process_with_state *pwstate) | |
288 | { | |
289 | // FIXME: Free this also | |
290 | //g_free(pwstate->state.private); | |
291 | ||
292 | // FIXME: this is really ugly. Don't free the pwstate if the state is LLEV_RUNNING. | |
293 | // LLEV_RUNNING is a special case that's being processed and deleted immediately after | |
294 | // being inserted on the sstack, to prevent state begin accumulated because it couldn't | |
295 | // be processed before the end of the trace. If we free the state, we get invalid memory | |
296 | // reads when looking at it on the state_stack. | |
297 | //if(pwstate->state.bstate != LLEV_RUNNING) | |
298 | // g_free(pwstate); | |
299 | } | |
300 | ||
b1d18041 PMF |
301 | inline void print_time(LttTime t) |
302 | { | |
303 | //printf("%lu.%lu", t.tv_sec, t.tv_nsec); | |
304 | double f; | |
305 | f = (double)t.tv_sec + ((double)t.tv_nsec)/1000000000.0; | |
306 | printf("%.9f", f); | |
307 | } | |
308 | ||
8c108c1c PMF |
309 | static struct sstack_item *prepare_push_item(struct process *p, enum llev_state st, LttTime t) |
310 | { | |
311 | struct process_with_state *pwstate = g_malloc(sizeof(struct process_with_state)); | |
312 | struct sstack_item *item; | |
313 | ||
314 | int wait_for_pop = 0; | |
315 | ||
316 | if(st == LLEV_SYSCALL) { | |
317 | /* We need to push LLEV_SYSCALL as wait_for_pop because it depends on some of | |
318 | * its children. If we don't do this, it's going to get processed immediately | |
319 | * by the sstack and we might miss some details about it that will come later. | |
320 | */ | |
321 | wait_for_pop = 1; | |
322 | } | |
323 | ||
324 | item = sstack_item_new_push(wait_for_pop); | |
325 | ||
326 | //printf("pushing in context of %d\n", p->pid); | |
327 | ||
328 | pwstate->process = p; | |
329 | pwstate->state.bstate = st; | |
330 | pwstate->state.time_begin = t; | |
331 | pwstate->state.private = g_malloc(llev_state_infos[st].size_priv); | |
332 | ||
333 | item->data_val = pwstate; | |
b1d18041 PMF |
334 | item->delete_data_val = (void (*)(void*))delete_data_val; |
335 | ||
336 | return item; | |
8c108c1c PMF |
337 | } |
338 | ||
339 | static void *item_private(struct sstack_item *item) | |
340 | { | |
341 | struct process_with_state *pwstate = item->data_val; | |
342 | return pwstate->state.private; | |
343 | } | |
344 | ||
345 | static void commit_item(struct process *p, struct sstack_item *item) | |
346 | { | |
347 | sstack_add_item(p->stack, item); | |
348 | } | |
349 | ||
350 | static void old_process_push_llev_state(struct process *p, struct process_state *pstate) | |
351 | { | |
352 | if(++p->stack_current >= PROCESS_STATE_STACK_SIZE) { | |
353 | fprintf(stderr, "depanalysis: internal process stack overflow\n"); | |
354 | abort(); | |
355 | } | |
356 | ||
357 | p->llev_state_stack[p->stack_current] = pstate; | |
358 | } | |
359 | ||
360 | static void live_complete_process_push_llev_state(struct process *p, enum llev_state st, LttTime t) | |
361 | { | |
362 | struct process_state *pstate = g_malloc(sizeof(struct process_state)); | |
363 | ||
364 | pstate->bstate = st; | |
365 | pstate->time_begin = t; | |
366 | pstate->private = g_malloc(llev_state_infos[st].size_priv); | |
367 | ||
368 | old_process_push_llev_state(p, pstate); | |
369 | } | |
370 | ||
371 | static void prepare_pop_item_commit_nocheck(struct process *p, enum llev_state st, LttTime t) | |
372 | { | |
373 | struct process_with_state *pwstate; | |
374 | struct sstack_item *item = sstack_item_new_pop(); | |
375 | ||
376 | int push_idx; | |
377 | ||
378 | if(p->stack->pushes->len > 0) | |
379 | push_idx = g_array_index(p->stack->pushes, int, p->stack->pushes->len-1); | |
380 | else | |
381 | push_idx = -1; | |
382 | ||
383 | if(push_idx >= 0) { | |
384 | pwstate = g_array_index(p->stack->array, struct sstack_item *, push_idx)->data_val; | |
385 | pwstate->process = p; | |
386 | pwstate->state.time_end = t; | |
387 | item->data_val = pwstate; | |
388 | /* don't set delete_data_val because we use the same pwstate as push, and we don't want to free it twice */ | |
389 | } | |
390 | else { | |
391 | ||
392 | pwstate = g_malloc(sizeof(struct process_with_state)); | |
393 | pwstate->process = p; | |
394 | item->data_val = pwstate; | |
395 | pwstate->state.time_end = t; | |
396 | pwstate->state.bstate = st; | |
397 | } | |
398 | ||
399 | sstack_add_item(p->stack, item); | |
400 | ||
401 | } | |
402 | ||
403 | static void prepare_pop_item_commit(struct process *p, enum llev_state st, LttTime t) | |
404 | { | |
405 | struct process_with_state *pwstate; | |
8c108c1c PMF |
406 | |
407 | int push_idx; | |
408 | ||
409 | if(p->stack->pushes->len > 0) | |
410 | push_idx = g_array_index(p->stack->pushes, int, p->stack->pushes->len-1); | |
411 | else | |
412 | push_idx = -1; | |
413 | ||
414 | if(push_idx >= 0) { | |
415 | /* FIXME: ugly workaround for kernel bug that generates two kernel_arch_syscall_exit on fork. | |
416 | * The bug only occurs upon creation of new processes. But these processes always have | |
417 | * a LLEV_RUNNING at index 0. */ | |
418 | if(push_idx >= p->stack->array->len) | |
419 | return; | |
420 | ||
421 | pwstate = g_array_index(p->stack->array, struct sstack_item *, push_idx)->data_val; | |
422 | ||
423 | if(pwstate->state.bstate != st) { | |
424 | /* FIXME: ugly workaround for kernel bug that generates two kernel_arch_syscall_exit on fork */ | |
425 | if(st != LLEV_SYSCALL) { | |
426 | printf("bad pop! at "); | |
427 | print_time(t); | |
428 | printf("\n"); | |
429 | print_stack(p->stack); | |
430 | abort(); | |
431 | } | |
432 | else { | |
433 | /* case where we have a double syscall_exit */ | |
434 | return; | |
435 | } | |
436 | } | |
437 | } | |
438 | ||
439 | prepare_pop_item_commit_nocheck(p, st, t); | |
440 | } | |
441 | ||
442 | ||
443 | static int try_pop_blocked_llev_preempted(struct process *p, LttTime t) | |
444 | { | |
445 | int push_idx; | |
446 | struct process_with_state *pwstate; | |
447 | ||
448 | if(p->stack->pushes->len > 0) | |
449 | push_idx = g_array_index(p->stack->pushes, int, p->stack->pushes->len-1); | |
450 | else | |
451 | push_idx = -1; | |
452 | ||
453 | if(push_idx >= 0) { | |
454 | pwstate = g_array_index(p->stack->array, struct sstack_item *, push_idx)->data_val; | |
455 | ||
456 | if(!(pwstate->state.bstate == LLEV_PREEMPTED && ((struct llev_state_info_preempted *)pwstate->state.private)->prev_state > 0)) { | |
55cd92ee | 457 | //printf("double try wake up\n"); |
8c108c1c PMF |
458 | return 0; |
459 | } | |
460 | } | |
461 | ||
462 | prepare_pop_item_commit_nocheck(p, LLEV_PREEMPTED, t); | |
463 | return 1; | |
464 | } | |
465 | ||
466 | static void old_process_pop_llev_state(struct process *p, struct process_state *pstate) | |
467 | { | |
468 | /* Ensure we are really popping the current state */ | |
469 | /* FIXME: pstate->bstate is uninitialized? */ | |
470 | // Commenting because it does not work. The way things work now, this check cannot work. | |
471 | //if(p->llev_state_stack[p->stack_current]->bstate != LLEV_UNKNOWN && p->llev_state_stack[p->stack_current]->bstate != pstate->bstate) { | |
472 | // printf("ERROR! bad pop!\n"); | |
473 | // abort(); | |
474 | //} | |
475 | ||
476 | /* Actually change the that position */ | |
477 | if(p->stack_current >= 0) | |
478 | p->stack_current--; | |
479 | ||
480 | /* If stack empty, we must put something in it */ | |
481 | if(p->stack_current == -1) { | |
482 | if(pstate->bstate == LLEV_SYSCALL) { | |
483 | //process_push_llev_state(p, LLEV_RUNNING, pstate->time_end); | |
484 | live_complete_process_push_llev_state(p, LLEV_RUNNING, pstate->time_end); | |
485 | } | |
486 | else { | |
487 | live_complete_process_push_llev_state(p, LLEV_UNKNOWN, pstate->time_end); | |
488 | } | |
489 | } | |
490 | } | |
491 | ||
492 | static GHashTable *process_hash_table; | |
493 | static GHashTable *syscall_table; | |
494 | static GHashTable *irq_table; | |
495 | static GHashTable *softirq_table; | |
496 | ||
497 | /* Insert the hooks before and after each trace and tracefile, and for each | |
498 | event. Print a global header. */ | |
499 | ||
500 | static FILE *a_file; | |
501 | ||
502 | static GString *a_string; | |
503 | ||
504 | static gboolean write_traceset_header(void *hook_data, void *call_data) | |
505 | { | |
8c108c1c | 506 | g_info("Traceset header"); |
c7cb53d7 | 507 | |
8c108c1c PMF |
508 | return FALSE; |
509 | } | |
510 | ||
b1d18041 | 511 | GArray *oldstyle_stack_to_garray(struct process_state **oldstyle_stack, int current) |
8c108c1c PMF |
512 | { |
513 | GArray *retval; | |
514 | int i; | |
515 | ||
b1d18041 | 516 | retval = g_array_new(FALSE, FALSE, sizeof(struct process_state *)); |
8c108c1c PMF |
517 | |
518 | for(i=0; i<current; i++) { | |
519 | g_array_append_val(retval, oldstyle_stack[i]); | |
520 | } | |
521 | ||
522 | return retval; | |
523 | } | |
524 | ||
525 | static void update_hlev_state(struct process *p, LttTime t) | |
526 | { | |
527 | int i; | |
528 | ||
c7cb53d7 | 529 | enum hlev_state new_hlev = 0; |
8c108c1c PMF |
530 | |
531 | for(i=p->stack_current; i>=0; i--) { | |
532 | enum llev_state st; | |
533 | st = p->llev_state_stack[i]->bstate; | |
534 | ||
535 | if(st == LLEV_RUNNING || st == LLEV_TRAP || st == LLEV_SYSCALL) { | |
536 | new_hlev = HLEV_RUNNING; | |
537 | break; | |
538 | } | |
539 | else if(st == LLEV_IRQ) { | |
540 | new_hlev = HLEV_INTERRUPTED_IRQ; | |
541 | break; | |
542 | } | |
543 | else if(st == LLEV_SOFTIRQ) { | |
544 | new_hlev = HLEV_INTERRUPTED_SOFTIRQ; | |
545 | break; | |
546 | } | |
547 | else if(st == LLEV_PREEMPTED) { | |
548 | int prev_state = ((struct llev_state_info_preempted *) old_process_state_private_data(p))->prev_state; | |
549 | ||
550 | if(prev_state == 0) { | |
551 | new_hlev = HLEV_INTERRUPTED_CPU; | |
552 | } | |
553 | else if(prev_state == -1) { | |
554 | new_hlev = HLEV_INTERRUPTED_POST_BLOCK; | |
555 | } | |
556 | else { | |
557 | new_hlev = HLEV_BLOCKED; | |
558 | } | |
559 | break; | |
560 | } | |
561 | else if(st == LLEV_UNKNOWN) { | |
562 | new_hlev = HLEV_UNKNOWN; | |
563 | break; | |
564 | } | |
565 | else { | |
566 | abort(); | |
567 | } | |
568 | } | |
569 | ||
570 | /* If no state change, do nothing */ | |
571 | if(p->hlev_state != NULL && new_hlev == p->hlev_state->bstate) { | |
572 | return; | |
573 | } | |
574 | ||
575 | p->hlev_state->time_end = t; | |
576 | /* This check is here because we initially put HLEV_UNKNOWN as hlev state, but in the case | |
577 | * of processes newly created, it is immediately replaced by HLEV_BLOCKED. In order to avoid | |
578 | * having a UNKNOWN state of duration 0 in the summary, we don't add it. This isn't as elegant | |
579 | * as it ought to be. | |
580 | */ | |
581 | if(ltt_time_compare(p->hlev_state->time_begin, p->hlev_state->time_end) != 0) | |
582 | g_array_append_val(p->hlev_history, p->hlev_state); | |
583 | p->hlev_state = g_malloc(sizeof(struct process_state)); | |
584 | p->hlev_state->bstate = new_hlev; | |
585 | p->hlev_state->time_begin = t; | |
586 | p->hlev_state->private = g_malloc(hlev_state_infos[new_hlev].size_priv); | |
587 | ||
588 | //printf("depanalysis: now at hlev state %s\n", hlev_state_infos[new_hlev].name); | |
589 | ||
590 | /* Set private data */ | |
591 | switch(p->hlev_state->bstate) { | |
592 | case HLEV_UNKNOWN: | |
593 | break; | |
594 | case HLEV_RUNNING: | |
595 | break; | |
596 | case HLEV_BLOCKED: { | |
597 | struct hlev_state_info_blocked *hlev_blocked_private = p->hlev_state->private; | |
8c108c1c PMF |
598 | int syscall_pos = find_pos_in_stack(LLEV_SYSCALL, p); |
599 | int trap_pos = find_pos_in_stack(LLEV_TRAP, p); | |
600 | ||
601 | /* init vals */ | |
602 | hlev_blocked_private->syscall_id = 1; | |
603 | hlev_blocked_private->trap = 0; | |
c7cb53d7 | 604 | hlev_blocked_private->pid_exit = 0; |
8c108c1c PMF |
605 | hlev_blocked_private->substate = HLEV_BLOCKED__UNDEFINED; |
606 | hlev_blocked_private->private = NULL; | |
607 | hlev_blocked_private->llev_state_entry = oldstyle_stack_to_garray(p->llev_state_stack, p->stack_current); | |
608 | hlev_blocked_private->llev_state_exit = NULL; | |
609 | ||
610 | //g_assert(syscall_pos >= 0 || trap_pos >= 0); | |
611 | ||
612 | if(trap_pos > syscall_pos) { | |
613 | hlev_blocked_private->trap = 1; | |
614 | } | |
615 | ||
616 | /* initial value, may be changed below */ | |
617 | hlev_blocked_private->substate = HLEV_BLOCKED__UNDEFINED; | |
618 | ||
619 | if(syscall_pos >= 0) { | |
620 | struct process_state *ps = p->llev_state_stack[syscall_pos]; | |
621 | struct llev_state_info_syscall *llev_syscall_private = (struct llev_state_info_syscall *) ps->private; | |
622 | hlev_blocked_private->syscall_id = llev_syscall_private->syscall_id; | |
623 | ||
624 | if(llev_syscall_private->substate == LLEV_SYSCALL__OPEN) { | |
625 | struct llev_state_info_syscall__open *llev_syscall_open_private; | |
626 | struct hlev_state_info_blocked__open *hlev_blocked_open_private; | |
627 | llev_syscall_open_private = llev_syscall_private->private; | |
628 | hlev_blocked_private->substate = HLEV_BLOCKED__OPEN; | |
629 | hlev_blocked_open_private = g_malloc(sizeof(struct hlev_state_info_blocked__open)); | |
630 | hlev_blocked_private->private = hlev_blocked_open_private; | |
631 | hlev_blocked_open_private->filename = llev_syscall_open_private->filename; | |
632 | ||
633 | //printf("depanalysis: blocked in an open!\n"); | |
634 | } | |
635 | else if(llev_syscall_private->substate == LLEV_SYSCALL__READ) { | |
636 | struct llev_state_info_syscall__read *llev_syscall_read_private; | |
637 | struct hlev_state_info_blocked__read *hlev_blocked_read_private; | |
638 | llev_syscall_read_private = llev_syscall_private->private; | |
639 | hlev_blocked_private->substate = HLEV_BLOCKED__READ; | |
640 | hlev_blocked_read_private = g_malloc(sizeof(struct hlev_state_info_blocked__read)); | |
641 | hlev_blocked_private->private = hlev_blocked_read_private; | |
642 | hlev_blocked_read_private->filename = llev_syscall_read_private->filename; | |
643 | ||
644 | //printf("depanalysis: blocked in a read!\n"); | |
645 | } | |
646 | else if(llev_syscall_private->substate == LLEV_SYSCALL__POLL) { | |
647 | struct llev_state_info_syscall__poll *llev_syscall_poll_private; | |
648 | struct hlev_state_info_blocked__poll *hlev_blocked_poll_private; | |
649 | llev_syscall_poll_private = llev_syscall_private->private; | |
650 | hlev_blocked_private->substate = HLEV_BLOCKED__POLL; | |
651 | hlev_blocked_poll_private = g_malloc(sizeof(struct hlev_state_info_blocked__poll)); | |
652 | hlev_blocked_private->private = hlev_blocked_poll_private; | |
653 | hlev_blocked_poll_private->filename = llev_syscall_poll_private->filename; | |
654 | ||
655 | //printf("depanalysis: blocked in a read!\n"); | |
656 | } | |
657 | } | |
658 | else { | |
659 | hlev_blocked_private->syscall_id = -1; | |
660 | } | |
661 | ||
662 | break; | |
663 | } | |
664 | case HLEV_INTERRUPTED_IRQ: { | |
665 | struct hlev_state_info_interrupted_irq *sinfo = p->hlev_state->private; | |
666 | struct process_state *ps = find_in_stack(LLEV_IRQ, p); | |
667 | if(ps == NULL) | |
668 | abort(); | |
669 | else | |
670 | sinfo->irq = ((struct llev_state_info_irq *) ps->private)->irq; | |
671 | break; | |
672 | } | |
673 | case HLEV_INTERRUPTED_SOFTIRQ: { | |
674 | struct hlev_state_info_interrupted_softirq *sinfo = p->hlev_state->private; | |
675 | struct process_state *ps = find_in_stack(LLEV_SOFTIRQ, p); | |
676 | if(ps == NULL) | |
677 | abort(); | |
678 | else | |
679 | sinfo->softirq = ((struct llev_state_info_softirq *) ps->private)->softirq; | |
680 | break; | |
681 | } | |
682 | default: | |
683 | break; | |
684 | }; | |
685 | } | |
686 | ||
687 | static gint compare_summary_tree_node_times(gconstpointer a, gconstpointer b) | |
688 | { | |
689 | struct summary_tree_node *n1 = (struct summary_tree_node *) a; | |
690 | struct summary_tree_node *n2 = (struct summary_tree_node *) b; | |
691 | ||
692 | return ltt_time_compare(n2->duration, n1->duration); | |
693 | } | |
694 | ||
695 | /* Print an item of the simple summary tree, and recurse, printing its children. | |
696 | * | |
697 | * If depth == -1, this is the root: we don't print a label, we only recurse into | |
698 | * the children. | |
699 | */ | |
700 | ||
701 | static void print_summary_item(struct summary_tree_node *node, int depth) | |
702 | { | |
703 | GList *vals; | |
704 | ||
705 | if(depth >= 0) { | |
c7cb53d7 YB |
706 | printf("\t%*s (", |
707 | (unsigned int)strlen(node->name)+2*depth, | |
708 | node->name); | |
8c108c1c PMF |
709 | print_time(node->duration); |
710 | printf(") <%d>\n", node->id_for_episodes); | |
711 | } | |
712 | ||
713 | if(!node->children) | |
714 | return; | |
715 | ||
716 | vals = g_hash_table_get_values(node->children); | |
717 | ||
718 | /* sort the values */ | |
719 | vals = g_list_sort(vals, compare_summary_tree_node_times); | |
720 | ||
721 | while(vals) { | |
722 | print_summary_item((struct summary_tree_node *)vals->data, depth+1); | |
723 | vals = vals->next; | |
724 | } | |
725 | ||
726 | /* we must free the list returned by g_hash_table_get_values() */ | |
727 | g_list_free(vals); | |
728 | } | |
729 | ||
730 | static inline void print_irq(int irq) | |
731 | { | |
c7cb53d7 | 732 | printf("IRQ %d [%s]", irq, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(irq_table, &irq))); |
8c108c1c PMF |
733 | } |
734 | ||
735 | static inline void print_softirq(int softirq) | |
736 | { | |
c7cb53d7 | 737 | printf("SoftIRQ %d [%s]", softirq, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(softirq_table, &softirq))); |
8c108c1c PMF |
738 | } |
739 | ||
740 | static inline void print_pid(int pid) | |
741 | { | |
742 | struct process *event_process_info = g_hash_table_lookup(process_hash_table, &pid); | |
743 | ||
c7cb53d7 | 744 | const char *pname; |
8c108c1c PMF |
745 | |
746 | if(event_process_info == NULL) | |
747 | pname = "?"; | |
748 | else | |
749 | pname = g_quark_to_string(event_process_info->name); | |
750 | printf("%d [%s]", pid, pname); | |
751 | } | |
752 | ||
753 | static void modify_path_with_private(GArray *path, struct process_state *pstate) | |
754 | { | |
8c108c1c | 755 | char *tmps; |
bdddf3f5 | 756 | int res; |
8c108c1c PMF |
757 | |
758 | // FIXME: fix this leak | |
759 | switch(pstate->bstate) { | |
760 | case HLEV_INTERRUPTED_IRQ: | |
bdddf3f5 AM |
761 | res = asprintf(&tmps, "IRQ %d [%s]", ((struct hlev_state_info_interrupted_irq *)pstate->private)->irq, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(irq_table, &((struct hlev_state_info_interrupted_irq *)pstate->private)->irq))); |
762 | g_assert(res > 0); | |
8c108c1c PMF |
763 | g_array_append_val(path, tmps); |
764 | break; | |
765 | case HLEV_INTERRUPTED_SOFTIRQ: | |
bdddf3f5 AM |
766 | res = asprintf(&tmps, "SoftIRQ %d [%s]", ((struct hlev_state_info_interrupted_softirq *)pstate->private)->softirq, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(softirq_table, &((struct hlev_state_info_interrupted_softirq *)pstate->private)->softirq))); |
767 | g_assert(res > 0); | |
8c108c1c PMF |
768 | g_array_append_val(path, tmps); |
769 | break; | |
770 | case HLEV_BLOCKED: { | |
771 | struct hlev_state_info_blocked *hlev_blocked_private = (struct hlev_state_info_blocked *)pstate->private; | |
772 | ||
773 | if(hlev_blocked_private->trap) { | |
774 | char *ptr = "Trap"; | |
775 | g_array_append_val(path, ptr); | |
776 | } | |
777 | ||
778 | if(hlev_blocked_private->syscall_id == -1) { | |
779 | char *ptr = "Userspace"; | |
780 | g_array_append_val(path, ptr); | |
781 | } | |
782 | else { | |
bdddf3f5 AM |
783 | res = asprintf(&tmps, "Syscall %d [%s]", hlev_blocked_private->syscall_id, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(syscall_table, &hlev_blocked_private->syscall_id))); |
784 | g_assert(res > 0); | |
8c108c1c PMF |
785 | g_array_append_val(path, tmps); |
786 | } | |
787 | ||
788 | if(((struct hlev_state_info_blocked *)pstate->private)->substate == HLEV_BLOCKED__OPEN) { | |
c7cb53d7 | 789 | const char *str = g_quark_to_string(((struct hlev_state_info_blocked__open *)((struct hlev_state_info_blocked *)pstate->private)->private)->filename); |
8c108c1c PMF |
790 | g_array_append_val(path, str); |
791 | } | |
792 | else if(((struct hlev_state_info_blocked *)pstate->private)->substate == HLEV_BLOCKED__READ) { | |
793 | char *str; | |
bdddf3f5 AM |
794 | res = asprintf(&str, "%s", g_quark_to_string(((struct hlev_state_info_blocked__read *)((struct hlev_state_info_blocked *)pstate->private)->private)->filename)); |
795 | g_assert(res > 0); | |
8c108c1c PMF |
796 | g_array_append_val(path, str); |
797 | /* FIXME: this must be freed at some point */ | |
798 | //free(str); | |
799 | } | |
800 | else if(((struct hlev_state_info_blocked *)pstate->private)->substate == HLEV_BLOCKED__POLL) { | |
801 | char *str; | |
bdddf3f5 AM |
802 | res = asprintf(&str, "%s", g_quark_to_string(((struct hlev_state_info_blocked__poll *)((struct hlev_state_info_blocked *)pstate->private)->private)->filename)); |
803 | g_assert(res > 0); | |
8c108c1c PMF |
804 | g_array_append_val(path, str); |
805 | /* FIXME: this must be freed at some point */ | |
806 | //free(str); | |
807 | } | |
808 | break; | |
809 | } | |
810 | }; | |
811 | } | |
812 | ||
813 | void print_stack_garray_horizontal(GArray *stack) | |
814 | { | |
815 | /* FIXME: this function doesn't work if we delete the states as we process them because we | |
816 | * try to read those states here to print the low level stack. | |
817 | */ | |
818 | int i; | |
819 | ||
820 | for(i=0; i<stack->len; i++) { | |
821 | struct process_state *pstate = g_array_index(stack, struct process_state *, i); | |
822 | printf("%s", llev_state_infos[pstate->bstate].name); | |
823 | ||
824 | if(pstate->bstate == LLEV_SYSCALL) { | |
825 | struct llev_state_info_syscall *llev_syscall_private = pstate->private; | |
c7cb53d7 | 826 | printf(" %d [%s]", llev_syscall_private->syscall_id, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(syscall_table, &llev_syscall_private->syscall_id))); |
8c108c1c PMF |
827 | } |
828 | ||
829 | printf(", "); | |
830 | ||
831 | } | |
832 | } | |
833 | ||
834 | static int dicho_search_state_ending_after(struct process *p, LttTime t) | |
835 | { | |
836 | int under = 0; | |
837 | int over = p->hlev_history->len-1; | |
838 | struct process_state *pstate; | |
839 | int result; | |
840 | ||
841 | if(over < 1) | |
842 | return -1; | |
843 | ||
844 | /* If the last element is smaller or equal than the time we are searching for, | |
845 | * no match | |
846 | */ | |
847 | pstate = g_array_index(p->hlev_history, struct process_state *, over); | |
848 | if(ltt_time_compare(pstate->time_end, t) <= 0) { | |
849 | return -1; | |
850 | } | |
851 | /* no need to check for the equal case */ | |
852 | ||
853 | pstate = g_array_index(p->hlev_history, struct process_state *, under); | |
854 | result = ltt_time_compare(pstate->time_end, t); | |
855 | if(result >= 1) { | |
856 | /* trivial match at the first element if it is greater or equal | |
857 | * than the time we want | |
858 | */ | |
859 | return under; | |
860 | } | |
861 | ||
862 | while(1) { | |
863 | int dicho; | |
864 | ||
865 | dicho = (under+over)/2; | |
866 | pstate = g_array_index(p->hlev_history, struct process_state *, dicho); | |
867 | result = ltt_time_compare(pstate->time_end, t); | |
868 | ||
869 | if(result == -1) { | |
870 | under = dicho; | |
871 | } | |
872 | else if(result == 1) { | |
873 | over = dicho; | |
874 | } | |
875 | else { | |
876 | /* exact match */ | |
877 | return dicho+1; | |
878 | } | |
879 | ||
880 | if(over-under == 1) { | |
881 | /* we have converged */ | |
882 | return over; | |
883 | } | |
884 | } | |
885 | ||
886 | } | |
887 | ||
888 | /* FIXME: this shouldn't be based on pids in case of reuse | |
889 | * FIXME: should add a list of processes used to avoid loops | |
890 | */ | |
891 | ||
892 | static struct process_state *find_state_ending_after(int pid, LttTime t) | |
893 | { | |
894 | struct process *p; | |
895 | int result; | |
896 | ||
897 | ||
898 | p = g_hash_table_lookup(process_hash_table, &pid); | |
899 | if(!p) | |
900 | return NULL; | |
901 | ||
902 | result = dicho_search_state_ending_after(p, t); | |
903 | ||
904 | if(result == -1) | |
905 | return NULL; | |
906 | else | |
907 | return g_array_index(p->hlev_history, struct process_state *, result); | |
908 | } | |
909 | ||
8d308134 MD |
910 | static void print_indent(int offset) |
911 | { | |
912 | if (offset > 2) { | |
913 | int i; | |
914 | ||
915 | printf("%*s", 8, ""); | |
916 | for (i = 3; i < offset; i++) { | |
917 | printf("|"); | |
918 | printf("%*s", 4, ""); | |
919 | } | |
920 | } else | |
921 | printf("%*s", 4*offset, ""); | |
922 | } | |
923 | ||
8c108c1c PMF |
924 | static void print_delay_pid(int pid, LttTime t1, LttTime t2, int offset) |
925 | { | |
926 | struct process *p; | |
927 | int i; | |
928 | ||
929 | p = g_hash_table_lookup(process_hash_table, &pid); | |
930 | if(!p) | |
931 | return; | |
932 | ||
933 | i = dicho_search_state_ending_after(p, t1); | |
934 | for(; i<p->hlev_history->len; i++) { | |
935 | struct process_state *pstate = g_array_index(p->hlev_history, struct process_state *, i); | |
936 | if(ltt_time_compare(pstate->time_end, t2) > 0) | |
937 | break; | |
938 | ||
939 | if(pstate->bstate == HLEV_BLOCKED) { | |
940 | struct hlev_state_info_blocked *state_private_blocked; | |
941 | state_private_blocked = pstate->private; | |
942 | struct process_state *state_unblocked; | |
943 | ||
8d308134 MD |
944 | print_indent(offset); |
945 | printf("--> Blocked in "); | |
8c108c1c PMF |
946 | print_stack_garray_horizontal(state_private_blocked->llev_state_entry); |
947 | ||
948 | printf("(times: "); | |
949 | print_time(pstate->time_begin); | |
950 | printf("-"); | |
951 | print_time(pstate->time_end); | |
952 | ||
953 | printf(", dur: %f)\n", 1e-9*ltt_time_to_double(ltt_time_sub(pstate->time_end, pstate->time_begin))); | |
954 | ||
955 | state_unblocked = find_state_ending_after(state_private_blocked->pid_exit, state_private_blocked->time_woken); | |
956 | if(state_unblocked) { | |
957 | if(state_unblocked->bstate == HLEV_INTERRUPTED_IRQ) { | |
958 | struct hlev_state_info_interrupted_irq *priv = state_unblocked->private; | |
959 | /* if in irq or softirq, we don't care what the waking process was doing because they are asynchroneous events */ | |
8d308134 MD |
960 | print_indent(offset); |
961 | printf("--- Woken up by an IRQ: "); | |
8c108c1c PMF |
962 | print_irq(priv->irq); |
963 | printf("\n"); | |
964 | } | |
965 | else if(state_unblocked->bstate == HLEV_INTERRUPTED_SOFTIRQ) { | |
966 | struct hlev_state_info_interrupted_softirq *priv = state_unblocked->private; | |
8d308134 MD |
967 | print_indent(offset); |
968 | printf("--- Woken up by a SoftIRQ: "); | |
8c108c1c PMF |
969 | print_softirq(priv->softirq); |
970 | printf("\n"); | |
971 | } | |
972 | else { | |
973 | LttTime t1prime=t1; | |
974 | LttTime t2prime=t2; | |
975 | ||
976 | if(ltt_time_compare(t1prime, pstate->time_begin) < 0) | |
977 | t1prime = pstate->time_begin; | |
978 | if(ltt_time_compare(t2prime, pstate->time_end) > 0) | |
979 | t2prime = pstate->time_end; | |
980 | ||
981 | print_delay_pid(state_private_blocked->pid_exit, t1prime, t2prime, offset+1); | |
8d308134 MD |
982 | print_indent(offset); |
983 | printf("--- Woken up in context of "); | |
8c108c1c PMF |
984 | print_pid(state_private_blocked->pid_exit); |
985 | if(state_private_blocked->llev_state_exit) { | |
986 | print_stack_garray_horizontal(state_private_blocked->llev_state_exit); | |
987 | } | |
988 | else { | |
989 | } | |
990 | printf(" in high-level state %s", hlev_state_infos[state_unblocked->bstate].name); | |
991 | printf("\n"); | |
992 | } | |
993 | } | |
994 | else { | |
8d308134 | 995 | print_indent(offset); |
8c108c1c PMF |
996 | printf("Weird... cannot find in what state the waker (%d) was\n", state_private_blocked->pid_exit); |
997 | } | |
998 | ||
999 | ||
1000 | //print_delay_pid(state_private_blocked->pid_exit, pstate->time_start, pstate->time_end); | |
1001 | //printf("\t\t Woken up in context of %d: ", state_private_blocked->pid_exit); | |
1002 | //if(state_private_blocked->llev_state_exit) { | |
1003 | // print_stack_garray_horizontal(state_private_blocked->llev_state_exit); | |
1004 | // printf("here3 (%d)\n", state_private_blocked->llev_state_exit->len); | |
1005 | //} | |
1006 | //else | |
1007 | // printf("the private_blocked %p had a null exit stack\n", state_private_blocked); | |
1008 | //printf("\n"); | |
1009 | } | |
1010 | } | |
1011 | } | |
1012 | ||
1013 | static void print_range_critical_path(int process, LttTime t1, LttTime t2) | |
1014 | { | |
1015 | printf("Critical path for requested range:\n"); | |
1016 | printf("Final process is %d\n", process); | |
1017 | print_delay_pid(process, t1, t2, 2); | |
1018 | } | |
1019 | ||
8d308134 MD |
1020 | /* |
1021 | * output legend example: | |
1022 | * | |
1023 | * --> Blocked in RUNNING, SYSCALL NNN [syscall_name] | |
1024 | * | ---> Blocked in RUNNING, SYSCALL NNN [syscall_name] | |
1025 | * | | --> Blocked in RUNNING, SYSCALL [syscall_name] | |
1026 | * | | --- Woken up by an IRQ: IRQ 0 [timer] | |
1027 | * | --- Woken up in context of PID [appname] in high-level state RUNNING | |
1028 | * --- Woken up in context of PID [appname] in high-level state RUNNING | |
1029 | */ | |
1030 | ||
8c108c1c PMF |
1031 | static void print_process_critical_path_summary() |
1032 | { | |
1033 | struct process *pinfo; | |
1034 | GList *pinfos; | |
8c108c1c PMF |
1035 | |
1036 | pinfos = g_hash_table_get_values(process_hash_table); | |
1037 | if(pinfos == NULL) { | |
1038 | fprintf(stderr, "error: no process found\n"); | |
1039 | return; | |
1040 | } | |
1041 | ||
1042 | printf("Process Critical Path Summary:\n"); | |
1043 | ||
1044 | for(;;) { | |
8c108c1c PMF |
1045 | |
1046 | pinfo = (struct process *)pinfos->data; | |
55cd92ee MD |
1047 | if (depanalysis_range_pid_searching != -1 && pinfo->pid != depanalysis_range_pid_searching) |
1048 | goto next_iter; | |
8c108c1c PMF |
1049 | printf("\tProcess %d [%s]\n", pinfo->pid, g_quark_to_string(pinfo->name)); |
1050 | ||
1051 | if(pinfo->hlev_history->len < 1) | |
1052 | goto next_iter; | |
1053 | ||
1054 | print_delay_pid(pinfo->pid, g_array_index(pinfo->hlev_history, struct process_state *, 0)->time_begin, g_array_index(pinfo->hlev_history, struct process_state *, pinfo->hlev_history->len - 1)->time_end, 2); | |
1055 | ||
1056 | next_iter: | |
1057 | ||
1058 | if(pinfos->next) | |
1059 | pinfos = pinfos->next; | |
1060 | else | |
1061 | break; | |
1062 | } | |
1063 | } | |
1064 | ||
1065 | gint compare_states_length(gconstpointer a, gconstpointer b) | |
1066 | { | |
1067 | struct process_state **s1 = (struct process_state **)a; | |
1068 | struct process_state **s2 = (struct process_state **)b; | |
1069 | gint val; | |
1070 | ||
1071 | val = ltt_time_compare(ltt_time_sub((*s2)->time_end, (*s2)->time_begin), ltt_time_sub((*s1)->time_end, (*s1)->time_begin)); | |
1072 | return val; | |
1073 | } | |
1074 | ||
55cd92ee | 1075 | static void print_simple_summary(void) |
8c108c1c PMF |
1076 | { |
1077 | struct process *pinfo; | |
1078 | GList *pinfos; | |
1079 | GList *pinfos_first; | |
1080 | int i,j; | |
1081 | int id_for_episodes = 0; | |
1082 | ||
55cd92ee MD |
1083 | if (!a_print_simple_summary) |
1084 | return; | |
1085 | ||
8c108c1c PMF |
1086 | /* we save all the nodes here to print the episodes table quickly */ |
1087 | GArray *all_nodes = g_array_new(FALSE, FALSE, sizeof(struct summary_tree_node *)); | |
1088 | ||
1089 | pinfos_first = g_hash_table_get_values(process_hash_table); | |
1090 | if(pinfos_first == NULL) { | |
1091 | fprintf(stderr, "error: no processes found\n"); | |
1092 | return; | |
1093 | } | |
1094 | pinfos = pinfos_first; | |
1095 | ||
1096 | printf("Simple summary:\n"); | |
1097 | ||
1098 | /* For each process */ | |
1099 | for(;;) { | |
1100 | struct summary_tree_node base_node = { children: NULL, name: "Root" }; | |
1101 | ||
8c108c1c PMF |
1102 | pinfo = (struct process *)pinfos->data; |
1103 | printf("\tProcess %d [%s]\n", pinfo->pid, g_quark_to_string(pinfo->name)); | |
1104 | ||
1105 | /* For each state in the process history */ | |
1106 | for(i=0; i<pinfo->hlev_history->len; i++) { | |
1107 | struct process_state *pstate = g_array_index(pinfo->hlev_history, struct process_state *, i); | |
1108 | struct summary_tree_node *node_cur = &base_node; | |
1109 | GArray *tree_path_garray; | |
1110 | ||
1111 | /* Modify the path based on private data */ | |
1112 | tree_path_garray = g_array_new(FALSE, FALSE, sizeof(char *)); | |
1113 | { | |
1114 | int count=0; | |
1115 | char **tree_path_cur2 = hlev_state_infos[pstate->bstate].tree_path; | |
1116 | while(*tree_path_cur2) { | |
1117 | count++; | |
1118 | tree_path_cur2++; | |
1119 | } | |
1120 | g_array_append_vals(tree_path_garray, hlev_state_infos[pstate->bstate].tree_path, count); | |
1121 | } | |
1122 | modify_path_with_private(tree_path_garray, pstate); | |
1123 | ||
1124 | /* Walk the path, adding the nodes to the summary */ | |
1125 | for(j=0; j<tree_path_garray->len; j++) { | |
1126 | struct summary_tree_node *newnode; | |
1127 | GQuark componentquark; | |
1128 | ||
1129 | /* Have a path component we must follow */ | |
1130 | if(!node_cur->children) { | |
1131 | /* must create the hash table for the children */ | |
1132 | node_cur->children = g_hash_table_new(g_int_hash, g_int_equal); | |
1133 | } | |
1134 | ||
1135 | /* try to get the node for the next component */ | |
1136 | componentquark = g_quark_from_string(g_array_index(tree_path_garray, char *, j)); | |
1137 | newnode = g_hash_table_lookup(node_cur->children, &componentquark); | |
1138 | if(newnode == NULL) { | |
1139 | newnode = g_malloc(sizeof(struct summary_tree_node)); | |
1140 | newnode->children = NULL; | |
1141 | newnode->name = g_array_index(tree_path_garray, char *, j); | |
1142 | newnode->duration = ltt_time_zero; | |
1143 | newnode->id_for_episodes = id_for_episodes++; | |
1144 | newnode->episodes = g_array_new(FALSE, FALSE, sizeof(struct process_state *)); | |
1145 | g_hash_table_insert(node_cur->children, &componentquark, newnode); | |
1146 | ||
1147 | g_array_append_val(all_nodes, newnode); | |
1148 | } | |
1149 | node_cur = newnode; | |
1150 | ||
1151 | node_cur->duration = ltt_time_add(node_cur->duration, ltt_time_sub(pstate->time_end, pstate->time_begin)); | |
1152 | g_array_append_val(node_cur->episodes, pstate); | |
1153 | } | |
1154 | } | |
1155 | ||
1156 | /* print the summary */ | |
1157 | print_summary_item(&base_node, -1); | |
1158 | ||
1159 | printf("\n"); | |
1160 | ||
1161 | if(pinfos->next) | |
1162 | pinfos = pinfos->next; | |
1163 | else | |
1164 | break; | |
1165 | } | |
1166 | ||
1167 | printf("\n"); | |
1168 | ||
1169 | printf("Episode list\n"); | |
1170 | pinfos = pinfos_first; | |
1171 | ||
1172 | /* For all the nodes of the Simple summary tree */ | |
1173 | for(i=0; i<all_nodes->len; i++) { | |
1174 | struct summary_tree_node *node = (struct summary_tree_node *)g_array_index(all_nodes, struct summary_tree_node *, i); | |
1175 | ||
1176 | /* Sort the episodes from longest to shortest */ | |
1177 | g_array_sort(node->episodes, compare_states_length); | |
1178 | ||
1179 | printf("\tNode id: <%d>\n", node->id_for_episodes); | |
1180 | /* For each episode of the node */ | |
1181 | for(j=0; j<node->episodes->len; j++) { | |
1182 | struct process_state *st = g_array_index(node->episodes, struct process_state *, j); | |
1183 | ||
1184 | printf("\t\t"); | |
1185 | print_time(st->time_begin); | |
1186 | printf("-"); | |
1187 | print_time(st->time_end); | |
1188 | printf(" (%f)\n", 1e-9*ltt_time_to_double(ltt_time_sub(st->time_end,st->time_begin))); | |
1189 | } | |
1190 | } | |
1191 | } | |
1192 | ||
1193 | static void print_simple_summary_pid_range(int pid, LttTime t1, LttTime t2) | |
1194 | { | |
1195 | struct process *pinfo; | |
1196 | int i,j; | |
1197 | int id_for_episodes = 0; | |
1198 | ||
1199 | /* we save all the nodes here to print the episodes table quickly */ | |
1200 | GArray *all_nodes = g_array_new(FALSE, FALSE, sizeof(struct summary_tree_node *)); | |
1201 | ||
1202 | pinfo = g_hash_table_lookup(process_hash_table, &pid); | |
1203 | ||
1204 | { | |
1205 | struct summary_tree_node base_node = { children: NULL, name: "Root" }; | |
1206 | ||
8c108c1c PMF |
1207 | printf("\tProcess %d [%s]\n", pinfo->pid, g_quark_to_string(pinfo->name)); |
1208 | ||
1209 | /* For each state in the process history */ | |
1210 | for(i=0; i<pinfo->hlev_history->len; i++) { | |
1211 | struct process_state *pstate = g_array_index(pinfo->hlev_history, struct process_state *, i); | |
1212 | struct summary_tree_node *node_cur = &base_node; | |
1213 | GArray *tree_path_garray; | |
1214 | ||
1215 | if(ltt_time_compare(pstate->time_end, t1) < 0) | |
1216 | continue; | |
1217 | ||
1218 | if(ltt_time_compare(pstate->time_end, t2) > 0) | |
1219 | break; | |
1220 | ||
1221 | /* Modify the path based on private data */ | |
1222 | tree_path_garray = g_array_new(FALSE, FALSE, sizeof(char *)); | |
1223 | { | |
1224 | int count=0; | |
1225 | char **tree_path_cur2 = hlev_state_infos[pstate->bstate].tree_path; | |
1226 | while(*tree_path_cur2) { | |
1227 | count++; | |
1228 | tree_path_cur2++; | |
1229 | } | |
1230 | g_array_append_vals(tree_path_garray, hlev_state_infos[pstate->bstate].tree_path, count); | |
1231 | } | |
1232 | modify_path_with_private(tree_path_garray, pstate); | |
1233 | ||
1234 | /* Walk the path, adding the nodes to the summary */ | |
1235 | for(j=0; j<tree_path_garray->len; j++) { | |
1236 | struct summary_tree_node *newnode; | |
1237 | GQuark componentquark; | |
1238 | ||
1239 | /* Have a path component we must follow */ | |
1240 | if(!node_cur->children) { | |
1241 | /* must create the hash table for the children */ | |
1242 | node_cur->children = g_hash_table_new(g_int_hash, g_int_equal); | |
1243 | } | |
1244 | ||
1245 | /* try to get the node for the next component */ | |
1246 | componentquark = g_quark_from_string(g_array_index(tree_path_garray, char *, j)); | |
1247 | newnode = g_hash_table_lookup(node_cur->children, &componentquark); | |
1248 | if(newnode == NULL) { | |
1249 | newnode = g_malloc(sizeof(struct summary_tree_node)); | |
1250 | newnode->children = NULL; | |
1251 | newnode->name = g_array_index(tree_path_garray, char *, j); | |
1252 | newnode->duration = ltt_time_zero; | |
1253 | newnode->id_for_episodes = id_for_episodes++; | |
1254 | newnode->episodes = g_array_new(FALSE, FALSE, sizeof(struct process_state *)); | |
1255 | g_hash_table_insert(node_cur->children, &componentquark, newnode); | |
1256 | ||
1257 | g_array_append_val(all_nodes, newnode); | |
1258 | } | |
1259 | node_cur = newnode; | |
1260 | ||
1261 | node_cur->duration = ltt_time_add(node_cur->duration, ltt_time_sub(pstate->time_end, pstate->time_begin)); | |
1262 | g_array_append_val(node_cur->episodes, pstate); | |
1263 | } | |
1264 | } | |
1265 | ||
1266 | /* print the summary */ | |
1267 | print_summary_item(&base_node, -1); | |
1268 | ||
1269 | printf("\n"); | |
1270 | } | |
1271 | ||
1272 | printf("\n"); | |
1273 | ||
1274 | printf("Episode list\n"); | |
1275 | ||
1276 | /* For all the nodes of the Simple summary tree */ | |
1277 | for(i=0; i<all_nodes->len; i++) { | |
1278 | struct summary_tree_node *node = (struct summary_tree_node *)g_array_index(all_nodes, struct summary_tree_node *, i); | |
1279 | ||
1280 | /* Sort the episodes from longest to shortest */ | |
1281 | g_array_sort(node->episodes, compare_states_length); | |
1282 | ||
1283 | printf("\tNode id: <%d>\n", node->id_for_episodes); | |
1284 | /* For each episode of the node */ | |
1285 | for(j=0; j<node->episodes->len; j++) { | |
1286 | struct process_state *st = g_array_index(node->episodes, struct process_state *, j); | |
1287 | ||
1288 | printf("\t\t"); | |
1289 | print_time(st->time_begin); | |
1290 | printf("-"); | |
1291 | print_time(st->time_end); | |
1292 | printf(" (%f)\n", 1e-9*ltt_time_to_double(ltt_time_sub(st->time_end,st->time_begin))); | |
1293 | } | |
1294 | } | |
1295 | } | |
1296 | ||
1297 | static void flush_process_sstacks(void) | |
1298 | { | |
1299 | GList *pinfos; | |
1300 | ||
1301 | pinfos = g_hash_table_get_values(process_hash_table); | |
1302 | while(pinfos) { | |
1303 | struct process *pinfo = (struct process *)pinfos->data; | |
1304 | ||
1305 | sstack_force_flush(pinfo->stack); | |
1306 | ||
1307 | pinfos = pinfos->next; | |
1308 | } | |
1309 | ||
1310 | g_list_free(pinfos); | |
1311 | } | |
1312 | ||
1313 | struct family_item { | |
1314 | int pid; | |
1315 | LttTime creation; | |
1316 | }; | |
1317 | ||
1318 | void print_range_reports(int pid, LttTime t1, LttTime t2) | |
1319 | { | |
1320 | GArray *family = g_array_new(FALSE, FALSE, sizeof(struct family_item)); | |
1321 | int i; | |
1322 | ||
1323 | /* reconstruct the parental sequence */ | |
1324 | for(;;) { | |
1325 | struct process *pinfo; | |
1326 | struct family_item fi; | |
1327 | LttTime cur_beg; | |
1328 | ||
1329 | pinfo = g_hash_table_lookup(process_hash_table, &pid); | |
1330 | if(pinfo == NULL) | |
1331 | abort(); | |
1332 | ||
1333 | fi.pid = pid; | |
1334 | cur_beg = g_array_index(pinfo->hlev_history, struct process_state *, 0)->time_begin; | |
1335 | fi.creation = cur_beg; | |
1336 | g_array_append_val(family, fi); | |
1337 | ||
1338 | if(ltt_time_compare(cur_beg, t1) == -1) { | |
1339 | /* current pid starts before the interesting time */ | |
1340 | break; | |
1341 | } | |
1342 | if(pinfo->parent == -1) { | |
1343 | printf("unable to go back, we don't know the parent of %d\n", fi.pid); | |
1344 | abort(); | |
1345 | } | |
1346 | /* else, we go on */ | |
1347 | pid = pinfo->parent; | |
1348 | ||
1349 | } | |
1350 | ||
1351 | printf("Simple summary for range:\n"); | |
1352 | for(i=family->len-1; i>=0; i--) { | |
1353 | LttTime iter_t1, iter_t2; | |
1354 | int iter_pid = g_array_index(family, struct family_item, i).pid; | |
1355 | ||
1356 | if(i == family->len-1) | |
1357 | iter_t1 = t1; | |
1358 | else | |
1359 | iter_t1 = g_array_index(family, struct family_item, i).creation; | |
1360 | ||
1361 | if(i == 0) | |
1362 | iter_t2 = t2; | |
1363 | else | |
1364 | iter_t2 = g_array_index(family, struct family_item, i-1).creation; | |
1365 | ||
c7cb53d7 | 1366 | printf("This section of summary concerns pid %d between ", iter_pid); |
8c108c1c PMF |
1367 | print_time(iter_t1); |
1368 | printf(" and "); | |
1369 | print_time(iter_t2); | |
1370 | printf(".\n"); | |
1371 | print_simple_summary_pid_range(iter_pid, iter_t1, iter_t2); | |
1372 | } | |
1373 | print_range_critical_path(depanalysis_range_pid, t1, t2); | |
1374 | } | |
1375 | ||
1376 | static gboolean write_traceset_footer(void *hook_data, void *call_data) | |
1377 | { | |
c7cb53d7 | 1378 | g_info("depanalysis traceset footer"); |
8c108c1c PMF |
1379 | |
1380 | /* After processing all the events, we need to flush the sstacks | |
1381 | * because some unfinished states may remain in them. We want them | |
1382 | * event though there are incomplete. | |
1383 | */ | |
1384 | flush_process_sstacks(); | |
1385 | ||
1386 | /* print the reports */ | |
1387 | print_simple_summary(); | |
1388 | print_process_critical_path_summary(); | |
8c108c1c | 1389 | if(depanalysis_use_time == 3) { |
55cd92ee | 1390 | printf("depanalysis_use_time = %d\n", depanalysis_use_time); |
8c108c1c PMF |
1391 | if(depanalysis_range_pid == -1 && depanalysis_range_pid_searching >= 0) |
1392 | depanalysis_range_pid = depanalysis_range_pid_searching; | |
1393 | ||
1394 | if(depanalysis_range_pid >= 0) { | |
1395 | print_range_reports(depanalysis_range_pid, depanalysis_time1, depanalysis_time2); | |
1396 | } | |
1397 | else | |
1398 | printf("range critical path: could not find the end of the range\n"); | |
1399 | } | |
1400 | ||
1401 | return FALSE; | |
1402 | } | |
1403 | ||
8c108c1c PMF |
1404 | |
1405 | static int write_event_content(void *hook_data, void *call_data) | |
1406 | { | |
8c108c1c PMF |
1407 | |
1408 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; | |
1409 | ||
1410 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; | |
1411 | ||
1412 | LttEvent *e; | |
1413 | ||
1414 | guint cpu = tfs->cpu; | |
1415 | LttvTraceState *ts = (LttvTraceState*)tfc->t_context; | |
1416 | LttvProcessState *process = ts->running_process[cpu]; | |
1417 | ||
1418 | e = ltt_tracefile_get_event(tfc->tf); | |
1419 | ||
1420 | lttv_event_to_string(e, a_string, TRUE, 1, tfs); | |
1421 | ||
1422 | // if(a_state) { | |
1423 | g_string_append_printf(a_string, " %s ", | |
1424 | g_quark_to_string(process->state->s)); | |
1425 | // } | |
1426 | ||
1427 | g_string_append_printf(a_string,"\n"); | |
1428 | ||
1429 | fputs(a_string->str, a_file); | |
1430 | return FALSE; | |
1431 | } | |
1432 | ||
1433 | static int field_get_value_int(struct LttEvent *e, struct marker_info *info, GQuark f) | |
1434 | { | |
1435 | struct marker_field *marker_field; | |
1436 | int found=0; | |
1437 | ||
1438 | for_each_marker_field(marker_field, info) { | |
1439 | if (marker_field->name == f) { | |
1440 | found = 1; | |
1441 | break; | |
1442 | } | |
1443 | } | |
1444 | g_assert(found); | |
1445 | return ltt_event_get_long_unsigned(e, marker_field); | |
1446 | } | |
1447 | ||
1448 | static char *field_get_value_string(struct LttEvent *e, struct marker_info *info, GQuark f) | |
1449 | { | |
1450 | struct marker_field *marker_field; | |
1451 | int found=0; | |
1452 | ||
1453 | for_each_marker_field(marker_field, info) { | |
1454 | if (marker_field->name == f) { | |
1455 | found = 1; | |
1456 | break; | |
1457 | } | |
1458 | } | |
1459 | g_assert(found); | |
1460 | return ltt_event_get_string(e, marker_field); | |
1461 | } | |
1462 | ||
c7cb53d7 | 1463 | void process_delayed_stack_action(void *arg, struct sstack_item *item) |
8c108c1c | 1464 | { |
c7cb53d7 | 1465 | struct process *pinfo = (struct process *)arg; |
8c108c1c PMF |
1466 | //printf("processing delayed stack action on pid %d at ", pinfo->pid); |
1467 | //if(((struct process_with_state *) item->data_val)->state.time_begin.tv_nsec == 987799696) | |
1468 | // printf("HERE!!!\n"); | |
1469 | //print_time(((struct process_with_state *) item->data_val)->state.time_begin); | |
1470 | //printf("\n"); | |
1471 | //printf("stack before:\n"); | |
1472 | //print_stack(pinfo->stack); | |
1473 | ||
1474 | if(item->data_type == SSTACK_TYPE_PUSH) { | |
1475 | struct process_with_state *pwstate = item->data_val; | |
1476 | //printf("pushing\n"); | |
1477 | old_process_push_llev_state(pinfo, &pwstate->state); | |
1478 | update_hlev_state(pinfo, pwstate->state.time_begin); | |
1479 | } | |
1480 | else if(item->data_type == SSTACK_TYPE_POP) { | |
1481 | struct process_with_state *pwstate = item->data_val; | |
1482 | //printf("popping\n"); | |
1483 | old_process_pop_llev_state(pinfo, &pwstate->state); | |
1484 | update_hlev_state(pinfo, pwstate->state.time_end); | |
1485 | } | |
1486 | else if(item->data_type == SSTACK_TYPE_EVENT) { | |
1487 | struct sstack_event *se = item->data_val; | |
1488 | if(se->event_type == HLEV_EVENT_TRY_WAKEUP) { | |
1489 | /* FIXME: should change hlev event from BLOCKED to INTERRUPTED CPU when receiving TRY_WAKEUP */ | |
1490 | struct try_wakeup_event *twe = se->private; | |
1491 | ||
1492 | /* FIXME: maybe do some more rigorous checking here */ | |
1493 | if(pinfo->hlev_state->bstate == HLEV_BLOCKED) { | |
1494 | struct hlev_state_info_blocked *hlev_blocked_private = pinfo->hlev_state->private; | |
1495 | ||
1496 | hlev_blocked_private->pid_exit = twe->pid; | |
1497 | hlev_blocked_private->time_woken = twe->time; | |
1498 | hlev_blocked_private->llev_state_exit = oldstyle_stack_to_garray(twe->waker->llev_state_stack, twe->waker->stack_current); | |
1499 | //printf("set a non null exit stack on %p, and stack size is %d\n", hlev_blocked_private, hlev_blocked_private->llev_state_exit->len); | |
1500 | ||
1501 | /* | |
1502 | if(p->stack_current >= 0 && p->llev_state_stack[p->stack_current]->bstate == LLEV_PREEMPTED) { | |
1503 | old_process_pop_llev_state(pinfo, p->llev_state_stack[p->stack_current]); | |
1504 | update_hlev_state(pinfo | |
1505 | old_process_push_llev_state | |
1506 | }*/ | |
1507 | ||
1508 | } | |
1509 | } | |
1510 | } | |
1511 | ||
1512 | //printf("stack after:\n"); | |
1513 | //print_stack(pinfo->stack); | |
1514 | } | |
1515 | ||
1516 | static struct process *get_or_init_process_info(struct LttEvent *e, GQuark name, int pid, int *new) | |
1517 | { | |
c7cb53d7 YB |
1518 | //gconstpointer val; |
1519 | gpointer val; | |
8c108c1c PMF |
1520 | |
1521 | val = g_hash_table_lookup(process_hash_table, &pid); | |
1522 | if(val == NULL) { | |
1523 | struct process *pinfo; | |
1524 | int i; | |
1525 | ||
1526 | /* Initialize new pinfo for newly discovered process */ | |
1527 | pinfo = g_malloc(sizeof(struct process)); | |
1528 | pinfo->pid = pid; | |
1529 | pinfo->parent = -1; /* unknown parent */ | |
1530 | pinfo->hlev_history = g_array_new(FALSE, FALSE, sizeof(struct process_state *)); | |
1531 | pinfo->stack = sstack_new(); | |
1532 | pinfo->stack_current=-1; | |
1533 | pinfo->stack->process_func = process_delayed_stack_action; | |
1534 | pinfo->stack->process_func_arg = pinfo; | |
1535 | for(i=0; i<PROCESS_STATE_STACK_SIZE; i++) { | |
1536 | pinfo->llev_state_stack[i] = g_malloc(sizeof(struct process_state)); | |
1537 | } | |
1538 | ||
1539 | pinfo->hlev_state = g_malloc(sizeof(struct process_state)); | |
1540 | pinfo->hlev_state->bstate = HLEV_UNKNOWN; | |
1541 | pinfo->hlev_state->time_begin = e->event_time; | |
1542 | pinfo->hlev_state->private = NULL; | |
1543 | ||
1544 | /* set the name */ | |
1545 | pinfo->name = name; | |
1546 | ||
1547 | g_hash_table_insert(process_hash_table, &pinfo->pid, pinfo); | |
1548 | if(new) | |
1549 | *new = 1; | |
1550 | return pinfo; | |
1551 | } | |
1552 | else { | |
1553 | if(new) | |
1554 | *new = 0; | |
1555 | return val; | |
1556 | ||
1557 | } | |
1558 | } | |
1559 | ||
1560 | static int differentiate_swappers(int pid, LttEvent *e) | |
1561 | { | |
1562 | if(pid == 0) | |
1563 | return pid+e->tracefile->cpu_num+2000000; | |
1564 | else | |
1565 | return pid; | |
1566 | } | |
1567 | ||
1568 | static int process_event(void *hook_data, void *call_data) | |
1569 | { | |
1570 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; | |
1571 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; | |
1572 | LttEvent *e; | |
1573 | struct marker_info *info; | |
bdddf3f5 | 1574 | int res; |
8c108c1c PMF |
1575 | |
1576 | /* Extract data from event structures and state */ | |
1577 | guint cpu = tfs->cpu; | |
1578 | LttvTraceState *ts = (LttvTraceState*)tfc->t_context; | |
1579 | LttvProcessState *process = ts->running_process[cpu]; | |
8c108c1c PMF |
1580 | struct process *pinfo; |
1581 | ||
1582 | e = ltt_tracefile_get_event(tfs->parent.tf); | |
1583 | ||
1584 | info = marker_get_info_from_id(tfc->tf->mdata, e->event_id); | |
1585 | ||
1586 | //if(depanalysis_use_time && (ltt_time_compare(e->timestamp, arg_t1) == -1 || ltt_time_compare(e->timestamp, arg_t2) == 1)) { | |
1587 | // return; | |
1588 | //} | |
1589 | /* Set the pid for the dependency analysis at each event, until we are passed the range. */ | |
1590 | if(depanalysis_use_time == 3) { | |
1591 | if(ltt_time_compare(e->event_time, depanalysis_time2) <= 0) { | |
1592 | depanalysis_range_pid = process->pid; | |
1593 | } | |
1594 | else { | |
1595 | /* Should stop processing and print results */ | |
1596 | } | |
1597 | } | |
1598 | ||
1599 | /* Code to limit the event count */ | |
1600 | if(depanalysis_event_limit > 0) { | |
1601 | depanalysis_event_limit--; | |
1602 | } | |
1603 | else if(depanalysis_event_limit == 0) { | |
1604 | write_traceset_footer(hook_data, call_data); | |
1605 | printf("exit due to event limit reached\n"); | |
1606 | exit(0); | |
1607 | } | |
1608 | ||
1609 | /* write event like textDump for now, for debugging purposes */ | |
1610 | //write_event_content(hook_data, call_data); | |
1611 | ||
1612 | if(tfc->tf->name == LTT_CHANNEL_SYSCALL_STATE && info->name == LTT_EVENT_SYS_CALL_TABLE) { | |
1613 | GQuark q; | |
1614 | int *pint = g_malloc(sizeof(int)); | |
1615 | ||
1616 | *pint = field_get_value_int(e, info, LTT_FIELD_ID); | |
1617 | q = g_quark_from_string(field_get_value_string(e, info, LTT_FIELD_SYMBOL)); | |
c7cb53d7 | 1618 | g_hash_table_insert(syscall_table, pint, (gpointer)(unsigned long)q); |
8c108c1c PMF |
1619 | } |
1620 | else if(tfc->tf->name == LTT_CHANNEL_IRQ_STATE && info->name == LTT_EVENT_LIST_INTERRUPT) { | |
1621 | GQuark q; | |
1622 | int *pint = g_malloc(sizeof(int)); | |
1623 | ||
1624 | *pint = field_get_value_int(e, info, LTT_FIELD_IRQ_ID); | |
1625 | q = g_quark_from_string(field_get_value_string(e, info, LTT_FIELD_ACTION)); | |
c7cb53d7 | 1626 | g_hash_table_insert(irq_table, pint, (gpointer)(unsigned long)q); |
8c108c1c PMF |
1627 | } |
1628 | else if(tfc->tf->name == LTT_CHANNEL_SOFTIRQ_STATE && info->name == LTT_EVENT_SOFTIRQ_VEC) { | |
1629 | GQuark q; | |
1630 | int *pint = g_malloc(sizeof(int)); | |
1631 | ||
1632 | *pint = field_get_value_int(e, info, LTT_FIELD_ID); | |
1633 | q = g_quark_from_string(field_get_value_string(e, info, LTT_FIELD_SYMBOL)); | |
c7cb53d7 | 1634 | g_hash_table_insert(softirq_table, pint, (gpointer)(unsigned long)q); |
8c108c1c PMF |
1635 | } |
1636 | ||
1637 | ||
1638 | /* Only look at events after the statedump is finished. | |
1639 | * Before that, the pids in the LttvProcessState are not reliable | |
1640 | */ | |
1641 | if(statedump_finished == 0) { | |
1642 | if(tfc->tf->name == LTT_CHANNEL_GLOBAL_STATE && info->name == LTT_EVENT_STATEDUMP_END) | |
1643 | statedump_finished = 1; | |
1644 | else | |
1645 | return FALSE; | |
1646 | ||
1647 | } | |
1648 | ||
1649 | pinfo = get_or_init_process_info(e, process->name, differentiate_swappers(process->pid, e), NULL); | |
1650 | ||
1651 | /* the state machine | |
1652 | * Process the event in the context of each process | |
1653 | */ | |
1654 | ||
1655 | if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_IRQ_ENTRY) { | |
1656 | struct process *event_process_info = pinfo; | |
1657 | struct sstack_item *item; | |
1658 | ||
1659 | item = prepare_push_item(event_process_info, LLEV_IRQ, e->event_time); | |
1660 | ((struct llev_state_info_irq *) item_private(item))->irq = field_get_value_int(e, info, LTT_FIELD_IRQ_ID); | |
1661 | commit_item(event_process_info, item); | |
1662 | } | |
1663 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_IRQ_EXIT) { | |
1664 | struct process *event_process_info = pinfo; | |
1665 | ||
1666 | prepare_pop_item_commit(event_process_info, LLEV_IRQ, e->event_time); | |
1667 | } | |
1668 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_SCHED_SCHEDULE) { | |
1669 | int next_pid = field_get_value_int(e, info, LTT_FIELD_NEXT_PID); | |
1670 | int prev_pid = field_get_value_int(e, info, LTT_FIELD_PREV_PID); | |
1671 | if(next_pid != 0) { | |
1672 | struct process *event_process_info = get_or_init_process_info(e, process->name, differentiate_swappers(next_pid, e), NULL); | |
1673 | prepare_pop_item_commit(event_process_info, LLEV_PREEMPTED, e->event_time); | |
1674 | } | |
1675 | if(prev_pid != 0) { | |
1676 | struct sstack_item *item; | |
1677 | struct process *event_process_info = get_or_init_process_info(e, process->name, differentiate_swappers(prev_pid, e), NULL); | |
1678 | ||
1679 | item = prepare_push_item(event_process_info, LLEV_PREEMPTED, e->event_time); | |
1680 | ((struct llev_state_info_preempted *) item_private(item))->prev_state = field_get_value_int(e, info, LTT_FIELD_PREV_STATE); | |
1681 | commit_item(event_process_info, item); | |
1682 | } | |
1683 | } | |
1684 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_TRAP_ENTRY) { | |
1685 | struct process *event_process_info = pinfo; | |
1686 | struct sstack_item *item; | |
1687 | ||
1688 | item = prepare_push_item(event_process_info, LLEV_TRAP, e->event_time); | |
1689 | commit_item(event_process_info, item); | |
1690 | } | |
1691 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_TRAP_EXIT) { | |
1692 | struct process *event_process_info = pinfo; | |
1693 | ||
1694 | prepare_pop_item_commit(event_process_info, LLEV_TRAP, e->event_time); | |
1695 | } | |
1696 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_SYSCALL_ENTRY) { | |
1697 | struct process *event_process_info = pinfo; | |
1698 | struct sstack_item *item; | |
1699 | ||
1700 | item = prepare_push_item(event_process_info, LLEV_SYSCALL, e->event_time); | |
1701 | ((struct llev_state_info_syscall *) item_private(item))->syscall_id = field_get_value_int(e, info, LTT_FIELD_SYSCALL_ID); | |
1702 | ((struct llev_state_info_syscall *) item_private(item))->substate = LLEV_SYSCALL__UNDEFINED; | |
1703 | commit_item(event_process_info, item); | |
1704 | } | |
1705 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_SYSCALL_EXIT) { | |
1706 | struct process *event_process_info = pinfo; | |
1707 | ||
1708 | prepare_pop_item_commit(event_process_info, LLEV_SYSCALL, e->event_time); | |
1709 | } | |
1710 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_SOFT_IRQ_ENTRY) { | |
1711 | struct process *event_process_info = pinfo; | |
1712 | struct sstack_item *item; | |
1713 | ||
1714 | item = prepare_push_item(event_process_info, LLEV_SOFTIRQ, e->event_time); | |
1715 | ((struct llev_state_info_softirq *) item_private(item))->softirq = field_get_value_int(e, info, LTT_FIELD_SOFT_IRQ_ID); | |
1716 | commit_item(event_process_info, item); | |
1717 | } | |
1718 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_SOFT_IRQ_EXIT) { | |
1719 | struct process *event_process_info = pinfo; | |
1720 | ||
1721 | prepare_pop_item_commit(event_process_info, LLEV_SOFTIRQ, e->event_time); | |
1722 | } | |
1723 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_PROCESS_FORK) { | |
1724 | int pid = differentiate_swappers(field_get_value_int(e, info, LTT_FIELD_CHILD_PID), e); | |
c7cb53d7 | 1725 | struct process *event_process_info = get_or_init_process_info(e, process->name, pid, NULL); |
8c108c1c PMF |
1726 | struct sstack_item *item; |
1727 | ||
1728 | event_process_info->parent = process->pid; | |
1729 | //printf("At "); | |
1730 | //print_time(e->event_time); | |
1731 | //printf(", fork in process %d (%s), creating child %d\n", differentiate_swappers(process->pid, e), g_quark_to_string(process->name), pid); | |
1732 | ||
1733 | item = prepare_push_item(event_process_info, LLEV_RUNNING, e->event_time); | |
1734 | commit_item(event_process_info, item); | |
1735 | item = prepare_push_item(event_process_info, LLEV_SYSCALL, e->event_time); | |
1736 | /* FIXME: this sets fork() as syscall, it's pretty inelegant */ | |
1737 | ((struct llev_state_info_syscall *) item_private(item))->syscall_id = 57; | |
1738 | ((struct llev_state_info_syscall *) item_private(item))->substate = LLEV_SYSCALL__UNDEFINED; | |
1739 | commit_item(event_process_info, item); | |
1740 | ||
1741 | item = prepare_push_item(event_process_info, LLEV_PREEMPTED, e->event_time); | |
1742 | /* Consider fork as BLOCKED */ | |
1743 | ((struct llev_state_info_preempted *) item_private(item))->prev_state = 1; | |
1744 | commit_item(event_process_info, item); | |
1745 | ||
1746 | //printf("process %d now has a stack of height %d\n", differentiate_swappers(process->pid, e), get_or_init_process_info(e, process->name, differentiate_swappers(process->pid, cpu), NULL)->stack_current-1); | |
1747 | ||
1748 | } | |
1749 | else if(tfc->tf->name == LTT_CHANNEL_FS && info->name == LTT_EVENT_EXEC) { | |
1750 | struct process *event_process_info = pinfo; | |
1751 | ||
1752 | guint cpu = tfs->cpu; | |
1753 | LttvProcessState *process_state = ts->running_process[cpu]; | |
1754 | event_process_info->name = process_state->name; | |
1755 | } | |
1756 | else if(tfc->tf->name == LTT_CHANNEL_FS && info->name == LTT_EVENT_OPEN) { | |
1757 | struct process_state *pstate = process_find_state(pinfo, LLEV_SYSCALL); | |
1758 | struct llev_state_info_syscall *llev_syscall_private; | |
1759 | struct llev_state_info_syscall__open *llev_syscall_open_private; | |
1760 | ||
1761 | /* TODO: this is too easy */ | |
1762 | if(pstate == NULL) | |
1763 | goto next_iter; | |
1764 | ||
1765 | llev_syscall_private = (struct llev_state_info_syscall *)pstate->private; | |
1766 | ||
1767 | //printf("depanalysis: found an open with state %d in pid %d\n", pstate->bstate, process->pid); | |
1768 | if(pstate->bstate == LLEV_UNKNOWN) | |
1769 | goto next_iter; | |
1770 | ||
1771 | g_assert(pstate->bstate == LLEV_SYSCALL); | |
1772 | g_assert(llev_syscall_private->substate == LLEV_SYSCALL__UNDEFINED); | |
1773 | ||
1774 | llev_syscall_private->substate = LLEV_SYSCALL__OPEN; | |
1775 | //printf("setting substate LLEV_SYSCALL__OPEN on syscall_private %p\n", llev_syscall_private); | |
1776 | llev_syscall_private->private = g_malloc(sizeof(struct llev_state_info_syscall__open)); | |
1777 | llev_syscall_open_private = llev_syscall_private->private; | |
1778 | ||
1779 | llev_syscall_open_private->filename = g_quark_from_string(field_get_value_string(e, info, LTT_FIELD_FILENAME)); | |
1780 | ||
1781 | } | |
1782 | else if(tfc->tf->name == LTT_CHANNEL_FS && info->name == LTT_EVENT_READ) { | |
1783 | struct process_state *pstate = process_find_state(pinfo, LLEV_SYSCALL); | |
1784 | struct llev_state_info_syscall *llev_syscall_private; | |
1785 | struct llev_state_info_syscall__read *llev_syscall_read_private; | |
1786 | GQuark pfileq; | |
1787 | int fd; | |
1788 | ||
1789 | /* TODO: this is too easy */ | |
1790 | if(pstate == NULL) | |
1791 | goto next_iter; | |
1792 | ||
1793 | llev_syscall_private = (struct llev_state_info_syscall *)pstate->private; | |
1794 | ||
1795 | //printf("depanalysis: found an read with state %d in pid %d\n", pstate->bstate, process->pid); | |
1796 | if(pstate->bstate == LLEV_UNKNOWN) | |
1797 | goto next_iter; | |
1798 | ||
1799 | g_assert(pstate->bstate == LLEV_SYSCALL); | |
1800 | g_assert(llev_syscall_private->substate == LLEV_SYSCALL__UNDEFINED); | |
1801 | ||
1802 | llev_syscall_private->substate = LLEV_SYSCALL__READ; | |
1803 | //printf("setting substate LLEV_SYSCALL__READ on syscall_private %p\n", llev_syscall_private); | |
1804 | llev_syscall_private->private = g_malloc(sizeof(struct llev_state_info_syscall__read)); | |
1805 | llev_syscall_read_private = llev_syscall_private->private; | |
1806 | ||
1807 | fd = field_get_value_int(e, info, LTT_FIELD_FD); | |
c7cb53d7 | 1808 | pfileq = (GQuark)(unsigned long)g_hash_table_lookup(process->fds, &fd); |
8c108c1c PMF |
1809 | if(pfileq) { |
1810 | llev_syscall_read_private->filename = pfileq; | |
1811 | } | |
1812 | else { | |
1813 | char *tmp; | |
bdddf3f5 AM |
1814 | res = asprintf(&tmp, "Unknown filename, fd %d", fd); |
1815 | g_assert(res > 0); | |
8c108c1c PMF |
1816 | llev_syscall_read_private->filename = g_quark_from_string(tmp); |
1817 | free(tmp); | |
1818 | } | |
1819 | } | |
1820 | else if(tfc->tf->name == LTT_CHANNEL_FS && info->name == LTT_EVENT_POLL_EVENT) { | |
1821 | struct process_state *pstate = process_find_state(pinfo, LLEV_SYSCALL); | |
1822 | struct llev_state_info_syscall *llev_syscall_private; | |
1823 | struct llev_state_info_syscall__poll *llev_syscall_poll_private; | |
1824 | GQuark pfileq; | |
1825 | int fd; | |
1826 | ||
1827 | /* TODO: this is too easy */ | |
1828 | if(pstate == NULL) | |
1829 | goto next_iter; | |
1830 | ||
1831 | llev_syscall_private = (struct llev_state_info_syscall *)pstate->private; | |
1832 | ||
1833 | //printf("depanalysis: found an poll with state %d in pid %d\n", pstate->bstate, process->pid); | |
1834 | if(pstate->bstate == LLEV_UNKNOWN) | |
1835 | goto next_iter; | |
1836 | ||
1837 | /* poll doesn't have a single event that gives the syscall args. instead, there can be an arbitrary | |
1838 | * number of fs_pollfd or fd_poll_event events | |
1839 | * We use the fd_poll_event event, which occurs for each fd that had activity causing a return of the poll() | |
1840 | * For now we only use the first. | |
1841 | * We should do something about this. FIXME | |
1842 | */ | |
1843 | if(llev_syscall_private->substate == LLEV_SYSCALL__POLL) | |
1844 | goto next_iter; | |
1845 | ||
1846 | g_assert(pstate->bstate == LLEV_SYSCALL); | |
1847 | g_assert(llev_syscall_private->substate == LLEV_SYSCALL__UNDEFINED); | |
1848 | ||
1849 | llev_syscall_private->substate = LLEV_SYSCALL__POLL; | |
1850 | //printf("setting substate LLEV_SYSCALL__POLL on syscall_private %p\n", llev_syscall_private); | |
1851 | llev_syscall_private->private = g_malloc(sizeof(struct llev_state_info_syscall__poll)); | |
1852 | llev_syscall_poll_private = llev_syscall_private->private; | |
1853 | ||
1854 | fd = field_get_value_int(e, info, LTT_FIELD_FD); | |
c7cb53d7 | 1855 | pfileq = (GQuark)(unsigned long)g_hash_table_lookup(process->fds, &fd); |
8c108c1c PMF |
1856 | if(pfileq) { |
1857 | llev_syscall_poll_private->filename = pfileq; | |
1858 | } | |
1859 | else { | |
1860 | char *tmp; | |
bdddf3f5 AM |
1861 | res = asprintf(&tmp, "Unknown filename, fd %d", fd); |
1862 | g_assert(res > 0); | |
8c108c1c PMF |
1863 | llev_syscall_poll_private->filename = g_quark_from_string(tmp); |
1864 | free(tmp); | |
1865 | } | |
1866 | } | |
1867 | else if(tfc->tf->name == LTT_CHANNEL_KERNEL && info->name == LTT_EVENT_SCHED_TRY_WAKEUP) { | |
1868 | struct sstack_event *se = g_malloc(sizeof(struct sstack_event)); | |
1869 | struct try_wakeup_event *twe = g_malloc(sizeof(struct try_wakeup_event)); | |
1870 | struct sstack_item *item = sstack_item_new_event(); | |
1871 | int target = field_get_value_int(e, info, LTT_FIELD_PID); | |
1872 | struct process *target_pinfo; | |
1873 | int result; | |
1874 | ||
1875 | se->event_type = HLEV_EVENT_TRY_WAKEUP; | |
1876 | se->private = twe; | |
1877 | //printf("pushing try wake up event in context of %d\n", pinfo->pid); | |
1878 | ||
1879 | twe->pid = differentiate_swappers(process->pid, e); | |
1880 | twe->time = e->event_time; | |
1881 | twe->waker = pinfo; | |
1882 | ||
1883 | /* FIXME: the target could not yet have an entry in the hash table, we would then lose data */ | |
1884 | target_pinfo = g_hash_table_lookup(process_hash_table, &target); | |
1885 | if(!target_pinfo) | |
1886 | goto next_iter; | |
1887 | ||
1888 | item->data_val = se; | |
b1d18041 | 1889 | item->delete_data_val = (void (*)(void *))delete_data_val; |
8c108c1c PMF |
1890 | |
1891 | sstack_add_item(target_pinfo->stack, item); | |
1892 | ||
1893 | /* Now pop the blocked schedule out of the target */ | |
1894 | result = try_pop_blocked_llev_preempted(target_pinfo, e->event_time); | |
1895 | ||
1896 | if(result) { | |
1897 | struct sstack_item *item; | |
1898 | struct process *event_process_info = target_pinfo; | |
1899 | ||
1900 | item = prepare_push_item(event_process_info, LLEV_PREEMPTED, e->event_time); | |
1901 | ((struct llev_state_info_preempted *) item_private(item))->prev_state = -1; /* special value meaning post-block sched out */ | |
1902 | commit_item(event_process_info, item); | |
1903 | } | |
1904 | ||
1905 | } | |
1906 | ||
1907 | next_iter: | |
8c108c1c PMF |
1908 | return FALSE; |
1909 | } | |
1910 | ||
1911 | void print_sstack_private(struct sstack_item *item) | |
1912 | { | |
1913 | struct process_with_state *pwstate = item->data_val; | |
1914 | ||
1915 | if(pwstate && item->data_type == SSTACK_TYPE_PUSH) | |
1916 | printf("\tstate: %s", llev_state_infos[pwstate->state.bstate].name); | |
1917 | ||
1918 | printf(" ("); | |
1919 | print_time(pwstate->state.time_begin); | |
1920 | printf("-"); | |
1921 | print_time(pwstate->state.time_end); | |
1922 | printf("\n"); | |
1923 | ||
1924 | } | |
1925 | ||
1926 | static LttTime ltt_time_from_string(const char *str) | |
1927 | { | |
1928 | LttTime retval; | |
1929 | ||
1930 | char *decdot = strchr(str, '.'); | |
1931 | ||
1932 | if(decdot) { | |
1933 | *decdot = '\0'; | |
1934 | retval.tv_nsec = atol(decdot+1); | |
1935 | } | |
1936 | else { | |
1937 | retval.tv_nsec = 0; | |
1938 | } | |
1939 | ||
1940 | retval.tv_sec = atol(str); | |
1941 | ||
1942 | return retval; | |
1943 | } | |
1944 | ||
1945 | static void arg_t1(void *hook_data) | |
1946 | { | |
1947 | printf("arg_t1\n"); | |
1948 | depanalysis_use_time |= 1; | |
1949 | depanalysis_time1 = ltt_time_from_string(arg_t1_str); | |
1950 | } | |
1951 | ||
1952 | static void arg_t2(void *hook_data) | |
1953 | { | |
1954 | depanalysis_use_time |= 2; | |
1955 | depanalysis_time2 = ltt_time_from_string(arg_t2_str); | |
1956 | } | |
1957 | ||
1958 | static void arg_pid(void *hook_data) | |
1959 | { | |
1960 | } | |
1961 | ||
1962 | static void arg_limit(void *hook_data) | |
1963 | { | |
1964 | } | |
1965 | ||
55cd92ee MD |
1966 | static void arg_sum(void *hook_data) |
1967 | { | |
1968 | } | |
1969 | ||
8c108c1c PMF |
1970 | static void init() |
1971 | { | |
1972 | gboolean result; | |
1973 | ||
1974 | print_sstack_item_data = print_sstack_private; | |
1975 | ||
1976 | LttvAttributeValue value; | |
1977 | ||
1978 | LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); | |
1979 | ||
1980 | a_file = stdout; | |
1981 | ||
1982 | lttv_option_add("dep-time-start", 0, "dependency analysis time of analysis start", "time", | |
1983 | LTTV_OPT_STRING, &arg_t1_str, arg_t1, NULL); | |
1984 | lttv_option_add("dep-time-end", 0, "dependency analysis time of analysis end", "time", | |
1985 | LTTV_OPT_STRING, &arg_t2_str, arg_t2, NULL); | |
1986 | lttv_option_add("dep-pid", 0, "dependency analysis pid", "pid", | |
1987 | LTTV_OPT_INT, &depanalysis_range_pid_searching, arg_pid, NULL); | |
1988 | lttv_option_add("limit-events", 0, "dependency limit event count", "count", | |
1989 | LTTV_OPT_INT, &depanalysis_event_limit, arg_limit, NULL); | |
55cd92ee MD |
1990 | lttv_option_add("print-summary", 0, "print simple summary", "sum", |
1991 | LTTV_OPT_INT, &a_print_simple_summary, arg_sum, NULL); | |
8c108c1c PMF |
1992 | |
1993 | process_hash_table = g_hash_table_new(g_int_hash, g_int_equal); | |
1994 | syscall_table = g_hash_table_new(g_int_hash, g_int_equal); | |
1995 | irq_table = g_hash_table_new(g_int_hash, g_int_equal); | |
1996 | softirq_table = g_hash_table_new(g_int_hash, g_int_equal); | |
1997 | ||
1998 | a_string = g_string_new(""); | |
1999 | ||
2000 | result = lttv_iattribute_find_by_path(attributes, "hooks/event", | |
2001 | LTTV_POINTER, &value); | |
2002 | g_assert(result); | |
2003 | event_hook = *(value.v_pointer); | |
2004 | g_assert(event_hook); | |
2005 | lttv_hooks_add(event_hook, process_event, NULL, LTTV_PRIO_DEFAULT); | |
2006 | ||
8c108c1c PMF |
2007 | result = lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", |
2008 | LTTV_POINTER, &value); | |
2009 | g_assert(result); | |
2010 | before_traceset = *(value.v_pointer); | |
2011 | g_assert(before_traceset); | |
2012 | lttv_hooks_add(before_traceset, write_traceset_header, NULL, | |
2013 | LTTV_PRIO_DEFAULT); | |
2014 | ||
2015 | result = lttv_iattribute_find_by_path(attributes, "hooks/traceset/after", | |
2016 | LTTV_POINTER, &value); | |
2017 | g_assert(result); | |
2018 | after_traceset = *(value.v_pointer); | |
2019 | g_assert(after_traceset); | |
2020 | lttv_hooks_add(after_traceset, write_traceset_footer, NULL, | |
2021 | LTTV_PRIO_DEFAULT); | |
2022 | } | |
2023 | ||
2024 | static void destroy() | |
2025 | { | |
2026 | lttv_option_remove("dep-time-start"); | |
2027 | lttv_option_remove("dep-time-end"); | |
2028 | lttv_option_remove("dep-pid"); | |
2029 | lttv_option_remove("limit-events"); | |
55cd92ee | 2030 | lttv_option_remove("print-summary"); |
8c108c1c PMF |
2031 | |
2032 | g_hash_table_destroy(process_hash_table); | |
2033 | g_hash_table_destroy(syscall_table); | |
2034 | g_hash_table_destroy(irq_table); | |
2035 | g_hash_table_destroy(softirq_table); | |
2036 | ||
2037 | g_string_free(a_string, TRUE); | |
2038 | ||
2039 | lttv_hooks_remove_data(event_hook, write_event_content, NULL); | |
c7cb53d7 | 2040 | |
8c108c1c PMF |
2041 | lttv_hooks_remove_data(before_traceset, write_traceset_header, NULL); |
2042 | lttv_hooks_remove_data(after_traceset, write_traceset_footer, NULL); | |
2043 | } | |
2044 | ||
2045 | LTTV_MODULE("depanalysis", "Dependency analysis test", \ | |
2046 | "Produce a dependency analysis of a trace", \ | |
2047 | init, destroy, "stats", "batchAnalysis", "option", "print") | |
2048 |