blob: 36c5755b193327b5f5af42e5a807d1895e69194d [file] [log] [blame]
njn20242342005-05-16 23:31:24 +00001
2/*--------------------------------------------------------------------*/
3/*--- Command line options. pub_core_options.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
sewardj03f8d3f2012-08-05 15:46:46 +000010 Copyright (C) 2000-2012 Julian Seward
njn20242342005-05-16 23:31:24 +000011 jseward@acm.org
12
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
31#ifndef __PUB_CORE_OPTIONS_H
32#define __PUB_CORE_OPTIONS_H
33
34//--------------------------------------------------------------------
35// PURPOSE: This module holds the variables for all command line options,
36// plus some functions and macros for manipulating them. Almost every
37// other module imports this one, if only for VG_(clo_verbosity).
38//--------------------------------------------------------------------
39
40#include "pub_tool_options.h"
41
njn20242342005-05-16 23:31:24 +000042/* The max number of suppression files. */
bartb000d782008-05-13 17:45:28 +000043#define VG_CLO_MAX_SFILES 100
njn20242342005-05-16 23:31:24 +000044
sewardjf9ebc392010-05-09 22:30:43 +000045/* The max number of --require-text-symbol= specification strings. */
46#define VG_CLO_MAX_REQ_TSYMS 100
47
sewardj14cdbf82010-10-12 00:44:05 +000048/* The max number of --fullpath-after= parameters. */
49#define VG_CLO_MAX_FULLPATH_AFTER 100
50
njn20242342005-05-16 23:31:24 +000051/* Should we stop collecting errors if too many appear? default: YES */
52extern Bool VG_(clo_error_limit);
sewardjb9779082006-05-12 23:50:15 +000053/* Alternative exit code to hand to parent if errors were found.
54 default: 0 (no, return the application's exit code in the normal
55 way. */
56extern Int VG_(clo_error_exitcode);
sewardj3b290482011-05-06 21:02:55 +000057
58typedef
59 enum {
60 Vg_VgdbNo, // Do not activate gdbserver.
61 Vg_VgdbYes, // Activate gdbserver (default).
62 Vg_VgdbFull, // ACtivate gdbserver in full mode, allowing
63 // a precise handling of watchpoints and single stepping
64 // at any moment.
65 }
66 VgVgdb;
67/* if != Vg_VgdbNo, allows valgrind to serve vgdb/gdb. */
68extern VgVgdb VG_(clo_vgdb);
69/* if > 0, checks every VG_(clo_vgdb_poll) BBS if vgdb wants to be served. */
70extern Int VG_(clo_vgdb_poll);
71/* prefix for the named pipes (FIFOs) used by vgdb/gdb to communicate with valgrind */
florian19f91bb2012-11-10 22:29:54 +000072extern const HChar* VG_(clo_vgdb_prefix);
sewardj3b290482011-05-06 21:02:55 +000073/* if True, gdbserver in valgrind will expose a target description containing
74 shadow registers */
75extern Bool VG_(clo_vgdb_shadow_registers);
sewardj3b290482011-05-06 21:02:55 +000076
njn20242342005-05-16 23:31:24 +000077/* Enquire about whether to attach to a debugger at errors? default: NO */
78extern Bool VG_(clo_db_attach);
79/* The debugger command? default: whatever gdb ./configure found */
florian19f91bb2012-11-10 22:29:54 +000080extern const HChar* VG_(clo_db_command);
njn20242342005-05-16 23:31:24 +000081/* Generating a suppression for each error? default: 0 (NO)
82 Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */
sewardjb9779082006-05-12 23:50:15 +000083extern Int VG_(clo_gen_suppressions);
njn20242342005-05-16 23:31:24 +000084/* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
85extern Int VG_(clo_sanity_level);
86/* Automatically attempt to demangle C++ names? default: YES */
87extern Bool VG_(clo_demangle);
88/* Simulate child processes? default: NO */
philippe1e470b52012-05-11 19:33:46 +000089/* Soname synonyms : a string containing a list of pairs
90 xxxxx=yyyyy separated by commas.
91 E.g. --soname-synonyms=somalloc=libtcmalloc*.so*,solibtruc=NONE */
florian19f91bb2012-11-10 22:29:54 +000092extern const HChar* VG_(clo_soname_synonyms);
njn20242342005-05-16 23:31:24 +000093extern Bool VG_(clo_trace_children);
sewardj06421272009-11-05 08:55:13 +000094/* String containing comma-separated patterns for executable names
95 that should not be traced into even when --trace-children=yes */
florian19f91bb2012-11-10 22:29:54 +000096extern const HChar* VG_(clo_trace_children_skip);
sewardj9ab64a42010-12-06 11:40:04 +000097/* The same as VG_(clo_trace_children), except that these patterns are
98 tested against the arguments for child processes, rather than the
99 executable name. */
florian19f91bb2012-11-10 22:29:54 +0000100extern const HChar* VG_(clo_trace_children_skip_by_arg);
sewardj6e31f802007-11-17 22:29:25 +0000101/* After a fork, the child's output can become confusingly
102 intermingled with the parent's output. This is especially
103 problematic when VG_(clo_xml) is True. Setting
104 VG_(clo_child_silent_after_fork) causes children to fall silent
sewardj738856f2009-07-15 14:48:32 +0000105 after fork() calls. Although note they become un-silent again
106 after the subsequent exec(). */
sewardj6e31f802007-11-17 22:29:25 +0000107extern Bool VG_(clo_child_silent_after_fork);
njn20242342005-05-16 23:31:24 +0000108
sewardj738856f2009-07-15 14:48:32 +0000109/* If the user specified --log-file=STR and/or --xml-file=STR, these
110 hold STR after expansion of the %p and %q templates. */
florian19f91bb2012-11-10 22:29:54 +0000111extern HChar* VG_(clo_log_fname_expanded);
112extern HChar* VG_(clo_xml_fname_expanded);
njn20242342005-05-16 23:31:24 +0000113
114/* Add timestamps to log messages? default: NO */
115extern Bool VG_(clo_time_stamp);
116
117/* The file descriptor to read for input. default: 0 == stdin */
118extern Int VG_(clo_input_fd);
sewardjf9ebc392010-05-09 22:30:43 +0000119
njn20242342005-05-16 23:31:24 +0000120/* The number of suppression files specified. */
121extern Int VG_(clo_n_suppressions);
122/* The names of the suppression files. */
florian19f91bb2012-11-10 22:29:54 +0000123extern const HChar* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
njn20242342005-05-16 23:31:24 +0000124
sewardj14cdbf82010-10-12 00:44:05 +0000125/* An array of strings harvested from --fullpath-after= flags. */
126extern Int VG_(clo_n_fullpath_after);
florian19f91bb2012-11-10 22:29:54 +0000127extern const HChar* VG_(clo_fullpath_after)[VG_CLO_MAX_FULLPATH_AFTER];
sewardj14cdbf82010-10-12 00:44:05 +0000128
sewardj8b6573d2012-12-05 22:15:14 +0000129/* Full path to additional path to search for debug symbols */
sewardj71826f72012-12-06 18:23:20 +0000130extern const HChar* VG_(clo_extra_debuginfo_path);
sewardj8b6573d2012-12-05 22:15:14 +0000131
njn20242342005-05-16 23:31:24 +0000132/* DEBUG: print generated code? default: 00000000 ( == NO ) */
sewardjb224a482007-02-09 17:45:09 +0000133extern UChar VG_(clo_trace_flags);
njn20242342005-05-16 23:31:24 +0000134/* DEBUG: do bb profiling? default: 00000000 ( == NO ) */
sewardjb224a482007-02-09 17:45:09 +0000135extern UChar VG_(clo_profile_flags);
florian29e022d2012-07-02 21:13:34 +0000136/* DEBUG: if tracing codegen, be quiet until after this bb */
njn20242342005-05-16 23:31:24 +0000137extern Int VG_(clo_trace_notbelow);
florian29e022d2012-07-02 21:13:34 +0000138/* DEBUG: if tracing codegen, be quiet after this bb */
139extern Int VG_(clo_trace_notabove);
njn20242342005-05-16 23:31:24 +0000140/* DEBUG: print system calls? default: NO */
141extern Bool VG_(clo_trace_syscalls);
142/* DEBUG: print signal details? default: NO */
143extern Bool VG_(clo_trace_signals);
144/* DEBUG: print symtab details? default: NO */
145extern Bool VG_(clo_trace_symtab);
sewardjf767d962007-02-12 17:47:14 +0000146/* DEBUG: restrict symtab etc details to object name pattern. Default: "*" */
florian19f91bb2012-11-10 22:29:54 +0000147extern const HChar* VG_(clo_trace_symtab_patt);
njn20242342005-05-16 23:31:24 +0000148/* DEBUG: print call-frame-info details? default: NO */
149extern Bool VG_(clo_trace_cfi);
sewardjf767d962007-02-12 17:47:14 +0000150/* DEBUG: mimic /usr/bin/readelf --syms? default: NO */
151extern Bool VG_(clo_debug_dump_syms);
152/* DEBUG: mimic /usr/bin/readelf --debug-dump=line? default: NO */
153extern Bool VG_(clo_debug_dump_line);
154/* DEBUG: mimic /usr/bin/readelf --debug-dump=frames? default: NO */
155extern Bool VG_(clo_debug_dump_frames);
njn20242342005-05-16 23:31:24 +0000156/* DEBUG: print redirection details? default: NO */
157extern Bool VG_(clo_trace_redir);
bart78bfc712011-12-08 16:14:59 +0000158/* Enable fair scheduling on multicore systems? default: NO */
159enum FairSchedType { disable_fair_sched, enable_fair_sched, try_fair_sched };
160extern enum FairSchedType VG_(clo_fair_sched);
njn20242342005-05-16 23:31:24 +0000161/* DEBUG: print thread scheduling events? default: NO */
162extern Bool VG_(clo_trace_sched);
sewardj9c606bd2008-09-18 18:12:50 +0000163/* DEBUG: do heap profiling? default: NO */
164extern Bool VG_(clo_profile_heap);
philipped99c26a2012-07-31 22:17:28 +0000165#define MAX_REDZONE_SZB 128
166// Maximum for the default values for core arenas and for client
167// arena given by the tool.
168// 128 is no special figure, just something not too big
169#define MAX_CLO_REDZONE_SZB 4096
170// We allow the user to increase the redzone size to 4Kb :
171// This allows "off by one" in an array of pages to be detected.
172#define CORE_REDZONE_DEFAULT_SZB 4
173extern Int VG_(clo_core_redzone_size);
174// VG_(clo_redzone_size) has default value -1, indicating to keep
175// the tool provided value.
176extern Int VG_(clo_redzone_size);
sewardj9c606bd2008-09-18 18:12:50 +0000177/* DEBUG: display gory details for the k'th most popular error.
178 default: Infinity. */
njn20242342005-05-16 23:31:24 +0000179extern Int VG_(clo_dump_error);
njn20242342005-05-16 23:31:24 +0000180/* Engage miscellaneous weird hacks needed for some progs. */
florian19f91bb2012-11-10 22:29:54 +0000181extern const HChar* VG_(clo_sim_hints);
sewardj41ded2c2006-10-17 01:34:57 +0000182/* Show symbols in the form 'name+offset' ? Default: NO */
183extern Bool VG_(clo_sym_offsets);
sewardjb8b79ad2008-03-03 01:35:41 +0000184/* Read DWARF3 variable info even if tool doesn't ask for it? */
185extern Bool VG_(clo_read_var_info);
bart5dd01902010-08-31 15:18:32 +0000186/* Which prefix to strip from full source file paths, if any. */
florian19f91bb2012-11-10 22:29:54 +0000187extern const HChar* VG_(clo_prefix_to_strip);
njn20242342005-05-16 23:31:24 +0000188
sewardjf9ebc392010-05-09 22:30:43 +0000189/* An array of strings harvested from --require-text-symbol=
190 flags.
191
192 Each string specifies a pair: a soname pattern and a text symbol
193 name pattern, separated by a colon. The patterns can be written
194 using the normal "?" and "*" wildcards. For example:
195 ":*libc.so*:foo?bar".
196
197 These flags take effect when reading debuginfo from objects. If an
198 object is loaded and the object's soname matches the soname
199 component of one of the specified pairs, then Valgrind will examine
200 all the text symbol names in the object. If none of them match the
201 symbol name component of that same specification, then the run is
202 aborted, with an error message.
203
204 The purpose of this is to support reliable usage of marked-up
205 libraries. For example, suppose we have a version of GCC's
206 libgomp.so which has been marked up with annotations to support
207 Helgrind. It is only too easy and confusing to load the 'wrong'
208 libgomp.so into the application. So the idea is: add a text symbol
209 in the marked-up library (eg), "annotated_for_helgrind_3_6", and
210 then give the flag
211
212 --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
213
214 so that when libgomp.so is loaded, we scan the symbol table, and if
215 the symbol isn't present the run is aborted, rather than continuing
216 silently with the un-marked-up library. Note that you should put
217 the entire flag in quotes to stop shells messing up the * and ?
218 wildcards. */
219extern Int VG_(clo_n_req_tsyms);
florian19f91bb2012-11-10 22:29:54 +0000220extern const HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
sewardjf9ebc392010-05-09 22:30:43 +0000221
njn20242342005-05-16 23:31:24 +0000222/* Track open file descriptors? */
223extern Bool VG_(clo_track_fds);
224
225/* Should we run __libc_freeres at exit? Sometimes causes crashes.
226 Default: YES. Note this is subservient to VG_(needs).libc_freeres;
sewardj19617ae2005-10-20 01:09:57 +0000227 if the latter says False, then the setting of VG_(clo_run_libc_freeres)
njn20242342005-05-16 23:31:24 +0000228 is ignored. Ie if a tool says no, I don't want this to run, that
229 cannot be overridden from the command line. */
230extern Bool VG_(clo_run_libc_freeres);
njn20242342005-05-16 23:31:24 +0000231
njn20242342005-05-16 23:31:24 +0000232/* Should we show VEX emulation warnings? Default: NO */
233extern Bool VG_(clo_show_emwarns);
234
235/* How much does the stack pointer have to change before tools
sewardj91b470c2007-08-28 17:03:01 +0000236 consider a stack switch to have happened? Default: 2000000 bytes
237 NB: must be host-word-sized to be correct (hence Word). */
238extern Word VG_(clo_max_stackframe);
sewardj95d86c02007-12-18 01:49:23 +0000239/* How large should Valgrind allow the primary thread's guest stack to
240 be? */
241extern Word VG_(clo_main_stacksize);
njn20242342005-05-16 23:31:24 +0000242
243/* Delay startup to allow GDB to be attached? Default: NO */
244extern Bool VG_(clo_wait_for_gdb);
245
sewardj26412bd2005-07-07 10:05:05 +0000246/* To what extent should self-checking translations be made? These
247 are needed to deal with self-modifying code on uncooperative
248 platforms. */
249typedef
250 enum {
251 Vg_SmcNone, // never generate self-checking translations
252 Vg_SmcStack, // generate s-c-t's for code found in stacks
sewardj26412bd2005-07-07 10:05:05 +0000253 // (this is the default)
sewardj6dbcc632011-06-07 21:39:28 +0000254 Vg_SmcAll, // make all translations self-checking.
255 Vg_SmcAllNonFile // make all translations derived from
256 // non-file-backed memory self checking
sewardj26412bd2005-07-07 10:05:05 +0000257 }
258 VgSmc;
259
sewardjce5a5662005-10-06 03:19:49 +0000260/* Describe extent to which self-modifying-code should be
261 auto-detected. */
sewardj6c3a2192005-07-24 07:00:45 +0000262extern VgSmc VG_(clo_smc_check);
sewardj26412bd2005-07-07 10:05:05 +0000263
sewardjce5a5662005-10-06 03:19:49 +0000264/* String containing comma-separated names of minor kernel variants,
265 so they can be properly handled by m_syswrap. */
florian19f91bb2012-11-10 22:29:54 +0000266extern const HChar* VG_(clo_kernel_variant);
sewardj26412bd2005-07-07 10:05:05 +0000267
njnf76d27a2009-05-28 01:53:07 +0000268/* Darwin-specific: automatically run /usr/bin/dsymutil to update
269 .dSYM directories as necessary? */
njn97db7612009-08-04 02:32:55 +0000270extern Bool VG_(clo_dsymutil);
njnf76d27a2009-05-28 01:53:07 +0000271
sewardj06421272009-11-05 08:55:13 +0000272/* Should we trace into this child executable (across execve etc) ?
sewardj9ab64a42010-12-06 11:40:04 +0000273 This involves considering --trace-children=,
274 --trace-children-skip=, --trace-children-skip-by-arg=, and the name
275 of the executable. 'child_argv' must not include the name of the
276 executable itself; iow child_argv[0] must be the first arg, if any,
277 for the child. */
278extern Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name,
279 HChar** child_argv );
sewardj63d1c002006-10-19 17:31:37 +0000280
sewardjc30cd9b2012-12-06 18:08:54 +0000281/* Whether illegal instructions should be reported/diagnosed.
282 Can be explicitly set through --sigill-diagnostics otherwise
283 depends on verbosity (False if -q). */
284extern Bool VG_(clo_sigill_diag);
285
njn20242342005-05-16 23:31:24 +0000286#endif // __PUB_CORE_OPTIONS_H
287
288/*--------------------------------------------------------------------*/
289/*--- end ---*/
290/*--------------------------------------------------------------------*/