blob: 238d872fdabf7b2a34239f9f38df8362d4ed1739 [file] [log] [blame]
weidendoa17f2a32006-03-20 10:27:30 +00001/*
njn9a0cba42007-04-15 22:15:57 +00002 This file is part of Callgrind, a Valgrind tool for call graph
weidendoa17f2a32006-03-20 10:27:30 +00003 profiling programs.
4
sewardj4d474d02008-02-11 11:34:59 +00005 Copyright (C) 2002-2008, Josef Weidendorfer (Josef.Weidendorfer@gmx.de)
weidendoa17f2a32006-03-20 10:27:30 +00006
njn9a0cba42007-04-15 22:15:57 +00007 This tool is derived from and contains lot of code from Cachegrind
8 Copyright (C) 2002 Nicholas Nethercote (njn@valgrind.org)
weidendoa17f2a32006-03-20 10:27:30 +00009
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 02111-1307, USA.
24
25 The GNU General Public License is contained in the file COPYING.
26*/
27
28#include "config.h" // for VG_PREFIX
29
30#include "global.h"
31
32
33
34/*------------------------------------------------------------*/
35/*--- Function specific configuration options ---*/
36/*------------------------------------------------------------*/
37
38/* Special value for separate_callers: automatic = adaptive */
39#define CONFIG_AUTO -1
40
41#define CONFIG_DEFAULT -1
42#define CONFIG_FALSE 0
43#define CONFIG_TRUE 1
44
45/* Logging configuration for a function */
46struct _fn_config {
47 Int dump_before;
48 Int dump_after;
49 Int zero_before;
50 Int toggle_collect;
51
52 Int skip; /* Handle CALL to this function as JMP (= Skip)? */
53 Int group; /* don't change caller dependency inside group !=0 */
54 Int pop_on_jump;
55
56 Int separate_callers; /* separate logging dependent on caller */
57 Int separate_recursions; /* separate logging of rec. levels */
58
59#if CLG_ENABLE_DEBUG
60 Int verbosity; /* Change debug verbosity level while in function */
61#endif
62};
63
64/* Configurations for function name prefix patterns.
65 * Currently, only very limit patterns are possible:
66 * Exact prefix patterns and "*::" are allowed.
67 * E.g.
68 * - "abc" matches all functions starting with "abc".
69 * - "abc*::def" matches all functions starting with "abc" and
70 * starting with "def" after the first "::" separator.
71 * - "*::print(" matches C++ methods "print" in all classes
72 * without namespace. I.e. "*" doesn't match a "::".
73 *
74 * We build a trie from patterns, and for a given function, we
75 * go down the tree and apply all non-default configurations.
76 */
77
78
79#define NODE_DEGREE 30
80
81/* node of compressed trie search structure */
82typedef struct _config_node config_node;
83struct _config_node {
84 Int length;
85
86 fn_config* config;
87 config_node* sub_node[NODE_DEGREE];
88 config_node* next;
89 config_node* wild_star;
90 config_node* wild_char;
91
92 Char name[1];
93};
94
95/* root of trie */
96static config_node* fn_configs = 0;
97
98static __inline__
99fn_config* new_fnc(void)
100{
sewardj9c606bd2008-09-18 18:12:50 +0000101 fn_config* new = (fn_config*) CLG_MALLOC("cl.clo.nf.1",
102 sizeof(fn_config));
weidendoa17f2a32006-03-20 10:27:30 +0000103
104 new->dump_before = CONFIG_DEFAULT;
105 new->dump_after = CONFIG_DEFAULT;
106 new->zero_before = CONFIG_DEFAULT;
107 new->toggle_collect = CONFIG_DEFAULT;
108 new->skip = CONFIG_DEFAULT;
109 new->pop_on_jump = CONFIG_DEFAULT;
110 new->group = CONFIG_DEFAULT;
111 new->separate_callers = CONFIG_DEFAULT;
112 new->separate_recursions = CONFIG_DEFAULT;
113
114#if CLG_ENABLE_DEBUG
115 new->verbosity = CONFIG_DEFAULT;
116#endif
117
118 return new;
119}
120
121
122static config_node* new_config(Char* name, int length)
123{
124 int i;
sewardj9c606bd2008-09-18 18:12:50 +0000125 config_node* node = (config_node*) CLG_MALLOC("cl.clo.nc.1",
126 sizeof(config_node) + length);
weidendoa17f2a32006-03-20 10:27:30 +0000127
128 for(i=0;i<length;i++) {
129 if (name[i] == 0) break;
130 node->name[i] = name[i];
131 }
132 node->name[i] = 0;
133
134 node->length = length;
135 node->config = 0;
136 for(i=0;i<NODE_DEGREE;i++)
137 node->sub_node[i] = 0;
138 node->next = 0;
139 node->wild_char = 0;
140 node->wild_star = 0;
141
142 CLG_DEBUG(3, " new_config('%s', len %d)\n", node->name, length);
143
144 return node;
145}
146
147static __inline__
148Bool is_wild(Char n)
149{
150 return (n == '*') || (n == '?');
151}
152
153/* Recursively build up function matching tree (prefix tree).
154 * Returns function config object for pattern <name>
155 * and starting at tree node <*pnode>.
156 *
157 * Tree nodes (config_node) are created as needed,
158 * tree root is stored into <*pnode>, and the created
159 * leaf (fn_config) for the given pattern is returned.
160 */
161static fn_config* get_fnc2(config_node* node, Char* name)
162{
163 config_node *new_sub, *n, *nprev;
164 int offset, len;
165
166 CLG_DEBUG(3, " get_fnc2(%p, '%s')\n", node, name);
167
168 if (name[0] == 0) {
169 if (!node->config) node->config = new_fnc();
170 return node->config;
171 }
172
173 if (is_wild(*name)) {
174 if (*name == '*') {
175 while(name[1] == '*') name++;
176 new_sub = node->wild_star;
177 }
178 else
179 new_sub = node->wild_char;
180
181 if (!new_sub) {
182 new_sub = new_config(name, 1);
183 if (*name == '*')
184 node->wild_star = new_sub;
185 else
186 node->wild_char = new_sub;
187 }
188
189 return get_fnc2( new_sub, name+1);
190 }
191
192 n = node->sub_node[ name[0]%NODE_DEGREE ];
193 nprev = 0;
194 len = 0;
195 while(n) {
196 for(len=0; name[len] == n->name[len]; len++);
197 if (len>0) break;
198 nprev = n;
199 n = n->next;
200 }
201
202 if (!n) {
203 len = 1;
204 while(name[len] && (!is_wild(name[len]))) len++;
205 new_sub = new_config(name, len);
206 new_sub->next = node->sub_node[ name[0]%NODE_DEGREE ];
207 node->sub_node[ name[0]%NODE_DEGREE ] = new_sub;
208
209 if (name[len] == 0) {
210 new_sub->config = new_fnc();
211 return new_sub->config;
212 }
213
214 /* recurse on wildcard */
215 return get_fnc2( new_sub, name+len);
216 }
217
218 if (len < n->length) {
219
220 /* split up the subnode <n> */
221 config_node *new_node;
222 int i;
223
224 new_node = new_config(n->name, len);
225 if (nprev)
226 nprev->next = new_node;
227 else
228 node->sub_node[ n->name[0]%NODE_DEGREE ] = new_node;
229 new_node->next = n->next;
230
231 new_node->sub_node[ n->name[len]%NODE_DEGREE ] = n;
232
233 for(i=0, offset=len; offset < n->length; i++, offset++)
234 n->name[i] = n->name[offset];
235 n->name[i] = 0;
236 n->length = i;
237
238 name += len;
239 offset = 0;
240 while(name[offset] && (!is_wild(name[offset]))) offset++;
241 new_sub = new_config(name, offset);
242 /* this sub_node of new_node could already be set: chain! */
243 new_sub->next = new_node->sub_node[ name[0]%NODE_DEGREE ];
244 new_node->sub_node[ name[0]%NODE_DEGREE ] = new_sub;
245
246 if (name[offset]==0) {
247 new_sub->config = new_fnc();
248 return new_sub->config;
249 }
250
251 /* recurse on wildcard */
252 return get_fnc2( new_sub, name+offset);
253 }
254
255 name += n->length;
256
257 if (name[0] == 0) {
258 /* name and node name are the same */
259 if (!n->config) n->config = new_fnc();
260 return n->config;
261 }
262
263 offset = 1;
264 while(name[offset] && (!is_wild(name[offset]))) offset++;
265
266 new_sub = new_config(name, offset);
267 new_sub->next = n->sub_node[ name[offset]%NODE_DEGREE ];
268 n->sub_node[ name[offset]%NODE_DEGREE ] = new_sub;
269
270 return get_fnc2(new_sub, name+offset);
271}
272
273static void print_config_node(int s, config_node* node)
274{
275 config_node* n;
276 int i;
277
278 if (node != fn_configs) {
279 char sp[] = " ";
280
281 if (s>40) s=40;
sewardjbbaef872008-11-01 23:55:32 +0000282 VG_(printf)("%s", sp+40-s);
weidendoa17f2a32006-03-20 10:27:30 +0000283 VG_(printf)("'%s'/%d\n", node->name, node->length);
284 }
285 for(i=0;i<NODE_DEGREE;i++) {
286 n = node->sub_node[i];
287 while(n) {
288 print_config_node(s+1, n);
289 n = n->next;
290 }
291 }
292 if (node->wild_char) print_config_node(s+1, node->wild_char);
293 if (node->wild_star) print_config_node(s+1, node->wild_star);
294}
295
296/* get a function config for a name pattern (from command line) */
297static fn_config* get_fnc(Char* name)
298{
299 fn_config* fnc;
300
301 CLG_DEBUG(3, " +get_fnc(%s)\n", name);
302 if (fn_configs == 0)
303 fn_configs = new_config(name, 0);
304 fnc = get_fnc2(fn_configs, name);
305
306 CLG_DEBUGIF(3) {
307 CLG_DEBUG(3, " -get_fnc(%s):\n", name);
308 print_config_node(3, fn_configs);
309 }
310 return fnc;
311}
312
313
314
315static void update_fn_config1(fn_node* fn, fn_config* fnc)
316{
317 if (fnc->dump_before != CONFIG_DEFAULT)
318 fn->dump_before = (fnc->dump_before == CONFIG_TRUE);
319
320 if (fnc->dump_after != CONFIG_DEFAULT)
321 fn->dump_after = (fnc->dump_after == CONFIG_TRUE);
322
323 if (fnc->zero_before != CONFIG_DEFAULT)
324 fn->zero_before = (fnc->zero_before == CONFIG_TRUE);
325
326 if (fnc->toggle_collect != CONFIG_DEFAULT)
327 fn->toggle_collect = (fnc->toggle_collect == CONFIG_TRUE);
328
329 if (fnc->skip != CONFIG_DEFAULT)
330 fn->skip = (fnc->skip == CONFIG_TRUE);
331
332 if (fnc->pop_on_jump != CONFIG_DEFAULT)
333 fn->pop_on_jump = (fnc->pop_on_jump == CONFIG_TRUE);
334
335 if (fnc->group != CONFIG_DEFAULT)
336 fn->group = fnc->group;
337
338 if (fnc->separate_callers != CONFIG_DEFAULT)
339 fn->separate_callers = fnc->separate_callers;
340
341 if (fnc->separate_recursions != CONFIG_DEFAULT)
342 fn->separate_recursions = fnc->separate_recursions;
343
344#if CLG_ENABLE_DEBUG
345 if (fnc->verbosity != CONFIG_DEFAULT)
346 fn->verbosity = fnc->verbosity;
347#endif
348}
349
350/* Recursively go down the function matching tree,
351 * looking for a match to <name>. For every matching leaf,
352 * <fn> is updated with the pattern config.
353 */
354static void update_fn_config2(fn_node* fn, Char* name, config_node* node)
355{
356 config_node* n;
357
358 CLG_DEBUG(3, " update_fn_config2('%s', node '%s'): \n",
359 name, node->name);
360 if ((*name == 0) && node->config) {
361 CLG_DEBUG(3, "Found!\n");
362 update_fn_config1(fn, node->config);
363 return;
364 }
365
366 n = node->sub_node[ name[0]%NODE_DEGREE ];
367 while(n) {
368 if (VG_(strncmp)(name, n->name, n->length)==0) break;
369 n = n->next;
370 }
371 if (n) update_fn_config2(fn, name+n->length, n);
372
373 if (node->wild_char)
374 update_fn_config2(fn, name+1, node->wild_char);
375
376 if (node->wild_star) {
377 while(*name) {
378 update_fn_config2(fn, name, node->wild_star);
379 name++;
380 }
381 update_fn_config2(fn, name, node->wild_star);
382 }
383}
384
385/* Update function config according to configs of name prefixes */
386void CLG_(update_fn_config)(fn_node* fn)
387{
388 CLG_DEBUG(3, " update_fn_config('%s')\n", fn->name);
389 if (fn_configs)
390 update_fn_config2(fn, fn->name, fn_configs);
391}
392
393
394/*--------------------------------------------------------------------*/
395/*--- Command line processing ---*/
396/*--------------------------------------------------------------------*/
397
398static Char* getUInt(Char* s, UInt* pn)
399{
400 UInt n = 0;
401 while((*s >='0') && (*s <='9')) {
402 n = 10*n + (*s-'0');
403 s++;
404 }
405 if (pn) *pn = n;
406 return s;
407}
408
409__attribute__((unused))
410static UWord getUWord(Char* s)
411{
412 UWord n = 0;
413 Bool isHex = False;
414
415 if ((s[0] == '0') && (s[1] == 'x')) {
416 isHex = True;
417 s += 2;
418 }
419
420 if (!isHex) {
421 while((*s >='0') && (*s <='9')) {
422 n = 10*n + (*s-'0');
423 s++;
424 }
425 }
426 else {
427 while(1) {
428 if ((*s >='0') && (*s <='9')) {
429 n = 16*n + (*s-'0');
430 s++;
431 continue;
432 }
433 if ((*s >='a') && (*s <='f')) {
434 n = 16*n + (*s-'a'+10);
435 s++;
436 continue;
437 }
438 if ((*s >='A') && (*s <='F')) {
439 n = 16*n + (*s-'A'+10);
440 s++;
441 continue;
442 }
443 break;
444 }
445 }
446
447 return n;
448}
449
450Bool CLG_(process_cmd_line_option)(Char* arg)
451{
452 if (0 == VG_(strcmp)(arg, "--skip-plt=yes"))
453 CLG_(clo).skip_plt = True;
454 else if (0 == VG_(strcmp)(arg, "--skip-plt=no"))
455 CLG_(clo).skip_plt = False;
456
457 else if (0 == VG_(strcmp)(arg, "--collect-jumps=yes"))
458 CLG_(clo).collect_jumps = True;
459 else if (0 == VG_(strcmp)(arg, "--collect-jumps=no"))
460 CLG_(clo).collect_jumps = False;
461 /* compatibility alias, deprecated option */
462 else if (0 == VG_(strcmp)(arg, "--trace-jump=yes"))
463 CLG_(clo).collect_jumps = True;
464 else if (0 == VG_(strcmp)(arg, "--trace-jump=no"))
465 CLG_(clo).collect_jumps = False;
466
467 else if (0 == VG_(strcmp)(arg, "--combine-dumps=yes"))
468 CLG_(clo).combine_dumps = True;
469 else if (0 == VG_(strcmp)(arg, "--combine-dumps=no"))
470 CLG_(clo).combine_dumps = False;
471
472 else if (0 == VG_(strcmp)(arg, "--collect-atstart=yes"))
473 CLG_(clo).collect_atstart = True;
474 else if (0 == VG_(strcmp)(arg, "--collect-atstart=no"))
475 CLG_(clo).collect_atstart = False;
476
477 else if (0 == VG_(strcmp)(arg, "--instr-atstart=yes"))
478 CLG_(clo).instrument_atstart = True;
479 else if (0 == VG_(strcmp)(arg, "--instr-atstart=no"))
480 CLG_(clo).instrument_atstart = False;
481
482 else if (0 == VG_(strcmp)(arg, "--separate-threads=yes"))
483 CLG_(clo).separate_threads = True;
484 else if (0 == VG_(strcmp)(arg, "--separate-threads=no"))
485 CLG_(clo).separate_threads = False;
486
487 else if (0 == VG_(strcmp)(arg, "--compress-strings=yes"))
488 CLG_(clo).compress_strings = True;
489 else if (0 == VG_(strcmp)(arg, "--compress-strings=no"))
490 CLG_(clo).compress_strings = False;
491
492 else if (0 == VG_(strcmp)(arg, "--compress-mangled=yes"))
493 CLG_(clo).compress_mangled = True;
494 else if (0 == VG_(strcmp)(arg, "--compress-mangled=no"))
495 CLG_(clo).compress_mangled = False;
496
497 else if (0 == VG_(strcmp)(arg, "--compress-pos=yes"))
498 CLG_(clo).compress_pos = True;
499 else if (0 == VG_(strcmp)(arg, "--compress-pos=no"))
500 CLG_(clo).compress_pos = False;
501
502 else if (0 == VG_(strncmp)(arg, "--fn-skip=", 10)) {
503 fn_config* fnc = get_fnc(arg+10);
504 fnc->skip = CONFIG_TRUE;
505 }
506
507 else if (0 == VG_(strncmp)(arg, "--dump-before=", 14)) {
508 fn_config* fnc = get_fnc(arg+14);
509 fnc->dump_before = CONFIG_TRUE;
510 }
511
512 else if (0 == VG_(strncmp)(arg, "--zero-before=", 14)) {
513 fn_config* fnc = get_fnc(arg+14);
514 fnc->zero_before = CONFIG_TRUE;
515 }
516
517 else if (0 == VG_(strncmp)(arg, "--dump-after=", 13)) {
518 fn_config* fnc = get_fnc(arg+13);
519 fnc->dump_after = CONFIG_TRUE;
520 }
521
522 else if (0 == VG_(strncmp)(arg, "--toggle-collect=", 17)) {
523 fn_config* fnc = get_fnc(arg+17);
524 fnc->toggle_collect = CONFIG_TRUE;
525 /* defaults to initial collection off */
526 CLG_(clo).collect_atstart = False;
527 }
528
529 else if (0 == VG_(strncmp)(arg, "--separate-recs=", 16))
530 CLG_(clo).separate_recursions = (Int)VG_(atoll)(&arg[16]);
531
weidendoa762b0f2006-05-01 00:55:54 +0000532 /* change handling of a jump between functions to ret+call */
533 else if (0 == VG_(strcmp)(arg, "--pop-on-jump")) {
534 CLG_(clo).pop_on_jump = True;
535 }
weidendoa17f2a32006-03-20 10:27:30 +0000536 else if (0 == VG_(strncmp)(arg, "--pop-on-jump=", 14)) {
537 fn_config* fnc = get_fnc(arg+14);
538 fnc->pop_on_jump = CONFIG_TRUE;
539 }
540
541#if CLG_ENABLE_DEBUG
542 else if (0 == VG_(strncmp)(arg, "--ct-verbose=", 13))
543 CLG_(clo).verbose = (Int)VG_(atoll)(&arg[13]);
544
545 else if (0 == VG_(strncmp)(arg, "--ct-vstart=", 12))
546 CLG_(clo).verbose_start = (ULong)VG_(atoll)(&arg[12]);
547
548 else if (0 == VG_(strncmp)(arg, "--ct-verbose", 12)) {
549 UInt n;
550 fn_config* fnc;
551 Char* s = getUInt(arg+12, &n);
552 if ((n == 0) || *s != '=') return False;
553 fnc = get_fnc(s+1);
554 fnc->verbosity = n;
555 }
556#endif
557
558 else if (0 == VG_(strncmp)(arg, "--separate-callers=", 19)) {
559 if (0 == VG_(strcmp)(arg+19, "auto"))
560 CLG_(clo).separate_callers = CONFIG_AUTO;
561 else
562 CLG_(clo).separate_callers = (Int)VG_(atoll)(&arg[19]);
563 }
564
565 else if (0 == VG_(strncmp)(arg, "--fn-group", 10)) {
566 UInt n;
567 fn_config* fnc;
568 Char* s = getUInt(arg+10, &n);
569 if ((n == 0) || *s != '=') return False;
570 fnc = get_fnc(s+1);
571 fnc->group = n;
572 }
573
574 else if (0 == VG_(strncmp)(arg, "--separate-callers", 18)) {
575 UInt n;
576 fn_config* fnc;
577 Char* s = getUInt(arg+18, &n);
578 if ((n == 0) || *s != '=') return False;
579 fnc = get_fnc(s+1);
580 fnc->separate_callers = n;
581 }
582
583 else if (0 == VG_(strncmp)(arg, "--separate-recs", 15)) {
584 UInt n;
585 fn_config* fnc;
586 Char* s = getUInt(arg+15, &n);
587 if ((n == 0) || *s != '=') return False;
588 fnc = get_fnc(s+1);
589 fnc->separate_recursions = n;
590 }
591
weidendocbf4e192007-11-27 01:27:12 +0000592 else if (0 == VG_(strncmp)(arg, "--callgrind-out-file=", 21))
sewardj9c606bd2008-09-18 18:12:50 +0000593 CLG_(clo).out_format = VG_(strdup)("cl.clo.pclo.1", arg+21);
weidendoa17f2a32006-03-20 10:27:30 +0000594
595 else if (0 == VG_(strcmp)(arg, "--mangle-names=yes"))
596 CLG_(clo).mangle_names = True;
597 else if (0 == VG_(strcmp)(arg, "--mangle-names=no"))
598 CLG_(clo).mangle_names = False;
599
600 else if (0 == VG_(strcmp)(arg, "--skip-direct-rec=yes"))
601 CLG_(clo).skip_direct_recursion = True;
602 else if (0 == VG_(strcmp)(arg, "--skip-direct-rec=no"))
603 CLG_(clo).skip_direct_recursion = False;
604
605 else if (0 == VG_(strcmp)(arg, "--dump-bbs=yes"))
606 CLG_(clo).dump_bbs = True;
607 else if (0 == VG_(strcmp)(arg, "--dump-bbs=no"))
608 CLG_(clo).dump_bbs = False;
609
610 else if (0 == VG_(strcmp)(arg, "--dump-line=yes"))
611 CLG_(clo).dump_line = True;
612 else if (0 == VG_(strcmp)(arg, "--dump-line=no"))
613 CLG_(clo).dump_line = False;
614
615 else if (0 == VG_(strcmp)(arg, "--dump-instr=yes"))
616 CLG_(clo).dump_instr = True;
617 else if (0 == VG_(strcmp)(arg, "--dump-instr=no"))
618 CLG_(clo).dump_instr = False;
619
620 else if (0 == VG_(strcmp)(arg, "--dump-bb=yes"))
621 CLG_(clo).dump_bb = True;
622 else if (0 == VG_(strcmp)(arg, "--dump-bb=no"))
623 CLG_(clo).dump_bb = False;
624
625 else if (0 == VG_(strncmp)(arg, "--dump-every-bb=", 16))
weidendo9e326b72006-03-31 13:16:15 +0000626 CLG_(clo).dump_every_bb = (ULong)VG_(atoll)(&arg[16]);
weidendoa17f2a32006-03-20 10:27:30 +0000627
628
629 else if (0 == VG_(strcmp)(arg, "--collect-alloc=yes"))
630 CLG_(clo).collect_alloc = True;
631 else if (0 == VG_(strcmp)(arg, "--collect-alloc=no"))
632 CLG_(clo).collect_alloc = False;
633
634 else if (0 == VG_(strcmp)(arg, "--collect-systime=yes"))
635 CLG_(clo).collect_systime = True;
636 else if (0 == VG_(strcmp)(arg, "--collect-systime=no"))
637 CLG_(clo).collect_systime = False;
638
639 else if (0 == VG_(strcmp)(arg, "--simulate-cache=yes"))
640 CLG_(clo).simulate_cache = True;
641 else if (0 == VG_(strcmp)(arg, "--simulate-cache=no"))
642 CLG_(clo).simulate_cache = False;
643
644 else {
645 Bool isCachesimOption = (*CLG_(cachesim).parse_opt)(arg);
646
647 /* cache simulator is used if a simulator option is given */
648 if (isCachesimOption)
649 CLG_(clo).simulate_cache = True;
650
651 return isCachesimOption;
652 }
653
654 return True;
655}
656
657void CLG_(print_usage)(void)
658{
659 VG_(printf)(
660"\n dump creation options:\n"
weidendocbf4e192007-11-27 01:27:12 +0000661" --callgrind-out-file=<f> Output file name [callgrind.out.%%p]\n"
weidendoa17f2a32006-03-20 10:27:30 +0000662" --dump-line=no|yes Dump source lines of costs? [yes]\n"
663" --dump-instr=no|yes Dump instruction address of costs? [no]\n"
664" --compress-strings=no|yes Compress strings in profile dump? [yes]\n"
665" --compress-pos=no|yes Compress positions in profile dump? [yes]\n"
666" --combine-dumps=no|yes Concat all dumps into same file [no]\n"
667#if CLG_EXPERIMENTAL
668" --compress-events=no|yes Compress events in profile dump? [no]\n"
669" --dump-bb=no|yes Dump basic block address of costs? [no]\n"
670" --dump-bbs=no|yes Dump basic block info? [no]\n"
671" --dump-skipped=no|yes Dump info on skipped functions in calls? [no]\n"
672" --mangle-names=no|yes Mangle separation into names? [yes]\n"
673#endif
674
675"\n activity options (for interactivity use callgrind_control):\n"
676" --dump-every-bb=<count> Dump every <count> basic blocks [0=never]\n"
677" --dump-before=<func> Dump when entering function\n"
678" --zero-before=<func> Zero all costs when entering function\n"
679" --dump-after=<func> Dump when leaving function\n"
680#if CLG_EXPERIMENTAL
681" --dump-objs=no|yes Dump static object information [no]\n"
682#endif
683
684"\n data collection options:\n"
685" --instr-atstart=no|yes Do instrumentation at callgrind start [yes]\n"
686" --collect-atstart=no|yes Collect at process/thread start [yes]\n"
687" --toggle-collect=<func> Toggle collection on enter/leave function\n"
688" --collect-jumps=no|yes Collect jumps? [no]\n"
689#if CLG_EXPERIMENTAL
690" --collect-alloc=no|yes Collect memory allocation info? [no]\n"
691#endif
692" --collect-systime=no|yes Collect system call time info? [no]\n"
693
694"\n cost entity separation options:\n"
695" --separate-threads=no|yes Separate data per thread [no]\n"
696" --separate-callers=<n> Separate functions by call chain length [0]\n"
697" --separate-recs=<n> Separate function recursions upto level [2]\n"
698" --skip-plt=no|yes Ignore calls to/from PLT sections? [yes]\n"
699" --separate-recs<n>=<f> Separate <n> recursions for function <f>\n"
700" --separate-callers<n>=<f> Separate <n> callers for function <f>\n"
701" --skip-direct-rec=no|yes Ignore direct recursions? [yes]\n"
702" --fn-skip=<function> Ignore calls to/from function?\n"
703#if CLG_EXPERIMENTAL
704" --fn-group<no>=<func> Put function into separation group <no>\n"
705#endif
706 );
707
708 (*CLG_(cachesim).print_opts)();
709
710// VG_(printf)("\n"
711// " For full callgrind documentation, see\n"
712// " "VG_PREFIX"/share/doc/callgrind/html/callgrind.html\n\n");
713}
714
715void CLG_(print_debug_usage)(void)
716{
717 VG_(printf)(
718
719#if CLG_ENABLE_DEBUG
720" --ct-verbose=<level> Verbosity of standard debug output [0]\n"
721" --ct-vstart=<BB number> Only be verbose after basic block [0]\n"
722" --ct-verbose<level>=<func> Verbosity while in <func>\n"
723#else
724" (none)\n"
725#endif
726
727 );
728}
729
730
731void CLG_(set_clo_defaults)(void)
732{
733 /* Default values for command line arguments */
734
735 /* dump options */
weidendocbf4e192007-11-27 01:27:12 +0000736 CLG_(clo).out_format = 0;
weidendoa17f2a32006-03-20 10:27:30 +0000737 CLG_(clo).combine_dumps = False;
738 CLG_(clo).compress_strings = True;
739 CLG_(clo).compress_mangled = False;
740 CLG_(clo).compress_events = False;
741 CLG_(clo).compress_pos = True;
742 CLG_(clo).mangle_names = True;
743 CLG_(clo).dump_line = True;
744 CLG_(clo).dump_instr = False;
745 CLG_(clo).dump_bb = False;
746 CLG_(clo).dump_bbs = False;
747
748 CLG_(clo).dump_every_bb = 0;
749
750 /* Collection */
751 CLG_(clo).separate_threads = False;
752 CLG_(clo).collect_atstart = True;
753 CLG_(clo).collect_jumps = False;
754 CLG_(clo).collect_alloc = False;
755 CLG_(clo).collect_systime = False;
756
757 CLG_(clo).skip_plt = True;
758 CLG_(clo).separate_callers = 0;
759 CLG_(clo).separate_recursions = 2;
760 CLG_(clo).skip_direct_recursion = False;
761
762 /* Instrumentation */
763 CLG_(clo).instrument_atstart = True;
764 CLG_(clo).simulate_cache = False;
765
weidendoa762b0f2006-05-01 00:55:54 +0000766 /* Call graph */
767 CLG_(clo).pop_on_jump = False;
768
weidendoa17f2a32006-03-20 10:27:30 +0000769#if CLG_ENABLE_DEBUG
770 CLG_(clo).verbose = 0;
771 CLG_(clo).verbose_start = 0;
772#endif
773}