blob: 2a45c6b39c7a930a95abb0db8cdf9d6eac6cd900 [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
sewardjb3a1e4b2015-08-21 11:32:26 +000010 Copyright (C) 2000-2015 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//--------------------------------------------------------------------
njn20242342005-05-16 23:31:24 +000039#include "pub_tool_options.h"
florian79316272014-10-07 18:36:28 +000040#include "pub_core_xarray.h"
sewardj14cdbf82010-10-12 00:44:05 +000041
njn20242342005-05-16 23:31:24 +000042/* Should we stop collecting errors if too many appear? default: YES */
43extern Bool VG_(clo_error_limit);
sewardjb9779082006-05-12 23:50:15 +000044/* Alternative exit code to hand to parent if errors were found.
45 default: 0 (no, return the application's exit code in the normal
46 way. */
47extern Int VG_(clo_error_exitcode);
sewardj3b290482011-05-06 21:02:55 +000048
philippe7b3d3562014-11-12 19:43:29 +000049/* Markers used to mark the begin/end of an error, when errors are
50 printed in textual (non xml) format.
51 [0] is the error begin marker, [1] is the error end marker.
52 default: no markers. */
53extern HChar *VG_(clo_error_markers)[2];
54
sewardj3b290482011-05-06 21:02:55 +000055typedef
56 enum {
57 Vg_VgdbNo, // Do not activate gdbserver.
58 Vg_VgdbYes, // Activate gdbserver (default).
59 Vg_VgdbFull, // ACtivate gdbserver in full mode, allowing
60 // a precise handling of watchpoints and single stepping
61 // at any moment.
62 }
63 VgVgdb;
64/* if != Vg_VgdbNo, allows valgrind to serve vgdb/gdb. */
65extern VgVgdb VG_(clo_vgdb);
66/* if > 0, checks every VG_(clo_vgdb_poll) BBS if vgdb wants to be served. */
67extern Int VG_(clo_vgdb_poll);
philippecffe2a52014-01-11 13:56:48 +000068
philippe180a7502014-04-20 13:41:10 +000069/* Specify when Valgrind gdbserver stops the execution and wait
70 for a GDB to connect. */
71typedef
72 enum { // Stop :
73 VgdbStopAt_Startup, // just before the client starts to execute.
74 VgdbStopAt_Exit, // just before the client exits.
75 VgdbStopAt_ValgrindAbExit // on abnormal valgrind exit.
76 }
77 VgdbStopAt;
78// Build mask to check or set VgdbStop_At a membership
79#define VgdbStopAt2S(a) (1 << (a))
80// VgdbStopAt a is member of the Set s ?
81#define VgdbStopAtiS(a,s) ((s) & VgdbStopAt2S(a))
philippe180a7502014-04-20 13:41:10 +000082extern UInt VG_(clo_vgdb_stop_at); // A set of VgdbStopAt reasons.
83
sewardj3b290482011-05-06 21:02:55 +000084/* prefix for the named pipes (FIFOs) used by vgdb/gdb to communicate with valgrind */
philippecffe2a52014-01-11 13:56:48 +000085extern const HChar *VG_(clo_vgdb_prefix);
86
sewardj3b290482011-05-06 21:02:55 +000087/* if True, gdbserver in valgrind will expose a target description containing
88 shadow registers */
89extern Bool VG_(clo_vgdb_shadow_registers);
sewardj3b290482011-05-06 21:02:55 +000090
njn20242342005-05-16 23:31:24 +000091/* Generating a suppression for each error? default: 0 (NO)
92 Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */
sewardjb9779082006-05-12 23:50:15 +000093extern Int VG_(clo_gen_suppressions);
njn20242342005-05-16 23:31:24 +000094/* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
95extern Int VG_(clo_sanity_level);
96/* Automatically attempt to demangle C++ names? default: YES */
97extern Bool VG_(clo_demangle);
philippe1e470b52012-05-11 19:33:46 +000098/* Soname synonyms : a string containing a list of pairs
99 xxxxx=yyyyy separated by commas.
100 E.g. --soname-synonyms=somalloc=libtcmalloc*.so*,solibtruc=NONE */
florian19f91bb2012-11-10 22:29:54 +0000101extern const HChar* VG_(clo_soname_synonyms);
philippeb314d102014-11-07 22:16:27 +0000102/* Valgrind-ise child processes (follow execve)? default : NO */
njn20242342005-05-16 23:31:24 +0000103extern Bool VG_(clo_trace_children);
sewardj06421272009-11-05 08:55:13 +0000104/* String containing comma-separated patterns for executable names
105 that should not be traced into even when --trace-children=yes */
florian19f91bb2012-11-10 22:29:54 +0000106extern const HChar* VG_(clo_trace_children_skip);
sewardj9ab64a42010-12-06 11:40:04 +0000107/* The same as VG_(clo_trace_children), except that these patterns are
108 tested against the arguments for child processes, rather than the
109 executable name. */
florian19f91bb2012-11-10 22:29:54 +0000110extern const HChar* VG_(clo_trace_children_skip_by_arg);
sewardj6e31f802007-11-17 22:29:25 +0000111/* After a fork, the child's output can become confusingly
112 intermingled with the parent's output. This is especially
113 problematic when VG_(clo_xml) is True. Setting
114 VG_(clo_child_silent_after_fork) causes children to fall silent
sewardj738856f2009-07-15 14:48:32 +0000115 after fork() calls. Although note they become un-silent again
116 after the subsequent exec(). */
sewardj6e31f802007-11-17 22:29:25 +0000117extern Bool VG_(clo_child_silent_after_fork);
njn20242342005-05-16 23:31:24 +0000118
sewardj738856f2009-07-15 14:48:32 +0000119/* If the user specified --log-file=STR and/or --xml-file=STR, these
120 hold STR after expansion of the %p and %q templates. */
florian518850b2014-10-22 22:25:30 +0000121extern const HChar* VG_(clo_log_fname_expanded);
122extern const HChar* VG_(clo_xml_fname_expanded);
njn20242342005-05-16 23:31:24 +0000123
124/* Add timestamps to log messages? default: NO */
125extern Bool VG_(clo_time_stamp);
126
127/* The file descriptor to read for input. default: 0 == stdin */
128extern Int VG_(clo_input_fd);
sewardjf9ebc392010-05-09 22:30:43 +0000129
bart2c68e3e2014-06-22 10:11:59 +0000130/* Whether or not to load the default suppressions. */
131extern Bool VG_(clo_default_supp);
florian79316272014-10-07 18:36:28 +0000132
njn20242342005-05-16 23:31:24 +0000133/* The names of the suppression files. */
florian79316272014-10-07 18:36:28 +0000134extern XArray *VG_(clo_suppressions);
njn20242342005-05-16 23:31:24 +0000135
sewardj14cdbf82010-10-12 00:44:05 +0000136/* An array of strings harvested from --fullpath-after= flags. */
florian79316272014-10-07 18:36:28 +0000137extern XArray *VG_(clo_fullpath_after);
sewardj14cdbf82010-10-12 00:44:05 +0000138
sewardj8b6573d2012-12-05 22:15:14 +0000139/* Full path to additional path to search for debug symbols */
sewardj71826f72012-12-06 18:23:20 +0000140extern const HChar* VG_(clo_extra_debuginfo_path);
sewardj8b6573d2012-12-05 22:15:14 +0000141
sewardj5d616df2013-07-02 08:07:15 +0000142/* Address of a debuginfo server to use. Either an IPv4 address of
143 the form "d.d.d.d" or that plus a port spec, hence of the form
144 "d.d.d.d:d", where d is one or more digits. */
145extern const HChar* VG_(clo_debuginfo_server);
146
147/* Do we allow reading debuginfo from debuginfo objects that don't
148 match (in some sense) the main object? This is dangerous, so the
149 default is NO (False). In any case it applies only to objects
150 found either in _extra_debuginfo_path or via the
151 _debuginfo_server. */
152extern Bool VG_(clo_allow_mismatched_debuginfo);
njn20242342005-05-16 23:31:24 +0000153
154/* DEBUG: print generated code? default: 00000000 ( == NO ) */
155extern UChar VG_(clo_trace_flags);
sewardj17c5e2e2012-12-28 09:12:14 +0000156
157/* DEBUG: do SB profiling? default: False (== NO). NOTE: does not
158 have an associated command line flag. Is set to True whenever
159 --profile-flags= is specified. */
160extern Bool VG_(clo_profyle_sbs);
161/* DEBUG: if doing SB profiling, provides bits for which JIT stages
162 are shown. Same meaning as for clo_trace_flags. default: zero (==
163 show block counts only) */
164extern UChar VG_(clo_profyle_flags);
165/* DEBUG: if doing SB profiling, dump blocks and zero counters after
166 this-many back edges (event checks). default: zero (== show
167 profiling results only at the end of the run. */
168extern ULong VG_(clo_profyle_interval);
169
florian29e022d2012-07-02 21:13:34 +0000170/* DEBUG: if tracing codegen, be quiet until after this bb */
njn20242342005-05-16 23:31:24 +0000171extern Int VG_(clo_trace_notbelow);
florian29e022d2012-07-02 21:13:34 +0000172/* DEBUG: if tracing codegen, be quiet after this bb */
173extern Int VG_(clo_trace_notabove);
njn20242342005-05-16 23:31:24 +0000174/* DEBUG: print system calls? default: NO */
175extern Bool VG_(clo_trace_syscalls);
176/* DEBUG: print signal details? default: NO */
177extern Bool VG_(clo_trace_signals);
178/* DEBUG: print symtab details? default: NO */
179extern Bool VG_(clo_trace_symtab);
sewardjf767d962007-02-12 17:47:14 +0000180/* DEBUG: restrict symtab etc details to object name pattern. Default: "*" */
florian19f91bb2012-11-10 22:29:54 +0000181extern const HChar* VG_(clo_trace_symtab_patt);
njn20242342005-05-16 23:31:24 +0000182/* DEBUG: print call-frame-info details? default: NO */
183extern Bool VG_(clo_trace_cfi);
sewardjf767d962007-02-12 17:47:14 +0000184/* DEBUG: mimic /usr/bin/readelf --syms? default: NO */
185extern Bool VG_(clo_debug_dump_syms);
186/* DEBUG: mimic /usr/bin/readelf --debug-dump=line? default: NO */
187extern Bool VG_(clo_debug_dump_line);
188/* DEBUG: mimic /usr/bin/readelf --debug-dump=frames? default: NO */
189extern Bool VG_(clo_debug_dump_frames);
njn20242342005-05-16 23:31:24 +0000190/* DEBUG: print redirection details? default: NO */
191extern Bool VG_(clo_trace_redir);
bart78bfc712011-12-08 16:14:59 +0000192/* Enable fair scheduling on multicore systems? default: NO */
193enum FairSchedType { disable_fair_sched, enable_fair_sched, try_fair_sched };
194extern enum FairSchedType VG_(clo_fair_sched);
njn20242342005-05-16 23:31:24 +0000195/* DEBUG: print thread scheduling events? default: NO */
196extern Bool VG_(clo_trace_sched);
sewardj9c606bd2008-09-18 18:12:50 +0000197/* DEBUG: do heap profiling? default: NO */
198extern Bool VG_(clo_profile_heap);
philipped99c26a2012-07-31 22:17:28 +0000199#define MAX_REDZONE_SZB 128
200// Maximum for the default values for core arenas and for client
201// arena given by the tool.
202// 128 is no special figure, just something not too big
203#define MAX_CLO_REDZONE_SZB 4096
204// We allow the user to increase the redzone size to 4Kb :
205// This allows "off by one" in an array of pages to be detected.
206#define CORE_REDZONE_DEFAULT_SZB 4
207extern Int VG_(clo_core_redzone_size);
208// VG_(clo_redzone_size) has default value -1, indicating to keep
209// the tool provided value.
210extern Int VG_(clo_redzone_size);
sewardj9c606bd2008-09-18 18:12:50 +0000211/* DEBUG: display gory details for the k'th most popular error.
212 default: Infinity. */
njn20242342005-05-16 23:31:24 +0000213extern Int VG_(clo_dump_error);
philippeec905f72014-08-17 20:03:51 +0000214
njn20242342005-05-16 23:31:24 +0000215/* Engage miscellaneous weird hacks needed for some progs. */
philippeec905f72014-08-17 20:03:51 +0000216typedef
217 enum {
philippeec905f72014-08-17 20:03:51 +0000218 SimHint_lax_ioctls,
sewardj8eb8bab2015-07-21 14:44:28 +0000219 SimHint_lax_doors,
philippe98486902014-08-19 22:46:44 +0000220 SimHint_fuse_compatible,
221 SimHint_enable_outer,
222 SimHint_no_inner_prefix,
223 SimHint_no_nptl_pthread_stackcache
philippeec905f72014-08-17 20:03:51 +0000224 }
225 SimHint;
226
227// Build mask to check or set SimHint a membership
228#define SimHint2S(a) (1 << (a))
229// SimHint h is member of the Set s ?
230#define SimHintiS(h,s) ((s) & SimHint2S(h))
231extern UInt VG_(clo_sim_hints);
232
sewardj41ded2c2006-10-17 01:34:57 +0000233/* Show symbols in the form 'name+offset' ? Default: NO */
234extern Bool VG_(clo_sym_offsets);
philippea0a73932014-06-15 15:42:20 +0000235/* Read DWARF3 inline info ? */
236extern Bool VG_(clo_read_inline_info);
sewardjb8b79ad2008-03-03 01:35:41 +0000237/* Read DWARF3 variable info even if tool doesn't ask for it? */
238extern Bool VG_(clo_read_var_info);
bart5dd01902010-08-31 15:18:32 +0000239/* Which prefix to strip from full source file paths, if any. */
florian19f91bb2012-11-10 22:29:54 +0000240extern const HChar* VG_(clo_prefix_to_strip);
njn20242342005-05-16 23:31:24 +0000241
sewardjf9ebc392010-05-09 22:30:43 +0000242/* An array of strings harvested from --require-text-symbol=
243 flags.
244
245 Each string specifies a pair: a soname pattern and a text symbol
246 name pattern, separated by a colon. The patterns can be written
247 using the normal "?" and "*" wildcards. For example:
248 ":*libc.so*:foo?bar".
249
250 These flags take effect when reading debuginfo from objects. If an
251 object is loaded and the object's soname matches the soname
252 component of one of the specified pairs, then Valgrind will examine
253 all the text symbol names in the object. If none of them match the
254 symbol name component of that same specification, then the run is
255 aborted, with an error message.
256
257 The purpose of this is to support reliable usage of marked-up
258 libraries. For example, suppose we have a version of GCC's
259 libgomp.so which has been marked up with annotations to support
260 Helgrind. It is only too easy and confusing to load the 'wrong'
261 libgomp.so into the application. So the idea is: add a text symbol
262 in the marked-up library (eg), "annotated_for_helgrind_3_6", and
263 then give the flag
264
265 --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
266
267 so that when libgomp.so is loaded, we scan the symbol table, and if
268 the symbol isn't present the run is aborted, rather than continuing
269 silently with the un-marked-up library. Note that you should put
270 the entire flag in quotes to stop shells messing up the * and ?
271 wildcards. */
florian79316272014-10-07 18:36:28 +0000272extern XArray *VG_(clo_req_tsyms);
sewardjf9ebc392010-05-09 22:30:43 +0000273
njn20242342005-05-16 23:31:24 +0000274/* Track open file descriptors? */
275extern Bool VG_(clo_track_fds);
276
277/* Should we run __libc_freeres at exit? Sometimes causes crashes.
278 Default: YES. Note this is subservient to VG_(needs).libc_freeres;
sewardj19617ae2005-10-20 01:09:57 +0000279 if the latter says False, then the setting of VG_(clo_run_libc_freeres)
njn20242342005-05-16 23:31:24 +0000280 is ignored. Ie if a tool says no, I don't want this to run, that
281 cannot be overridden from the command line. */
282extern Bool VG_(clo_run_libc_freeres);
njn20242342005-05-16 23:31:24 +0000283
njn20242342005-05-16 23:31:24 +0000284/* Should we show VEX emulation warnings? Default: NO */
285extern Bool VG_(clo_show_emwarns);
286
287/* How much does the stack pointer have to change before tools
sewardj91b470c2007-08-28 17:03:01 +0000288 consider a stack switch to have happened? Default: 2000000 bytes
289 NB: must be host-word-sized to be correct (hence Word). */
290extern Word VG_(clo_max_stackframe);
sewardj95d86c02007-12-18 01:49:23 +0000291/* How large should Valgrind allow the primary thread's guest stack to
292 be? */
293extern Word VG_(clo_main_stacksize);
njn20242342005-05-16 23:31:24 +0000294
florian1e802b62015-02-13 19:08:26 +0000295/* The maximum number of threads we support. */
296#define MAX_THREADS_DEFAULT 500
297extern UInt VG_(clo_max_threads);
298
philippe46207652013-01-20 17:11:58 +0000299/* If the same IP is found twice in a backtrace in a sequence of max
300 VG_(clo_merge_recursive_frames) frames, then the recursive call
301 is merged in the backtrace.
302 Note also that the merge is done during unwinding, to obtain
303 an much as possible significant backtrace.
304 Note that the value is changeable by a gdbsrv command. */
305extern Int VG_(clo_merge_recursive_frames);
306
philippe8e1bee42013-10-18 00:08:20 +0000307/* Max number of sectors that will be used by the translation code cache. */
308extern UInt VG_(clo_num_transtab_sectors);
309
philippe924c8522015-03-15 12:24:19 +0000310/* Average size of a transtab code entry. 0 means to use the tool
311 provided default. */
312extern UInt VG_(clo_avg_transtab_entry_size);
313
philippee4d78122014-04-20 14:20:37 +0000314/* Only client requested fixed mapping can be done below
315 VG_(clo_aspacem_minAddr). */
316extern Addr VG_(clo_aspacem_minAddr);
317
philipped0720e42015-03-12 20:43:46 +0000318/* How large the Valgrind thread stacks should be.
319 Will be rounded up to a page.. */
320extern Word VG_(clo_valgrind_stacksize);
321
njn20242342005-05-16 23:31:24 +0000322/* Delay startup to allow GDB to be attached? Default: NO */
323extern Bool VG_(clo_wait_for_gdb);
324
sewardj26412bd2005-07-07 10:05:05 +0000325/* To what extent should self-checking translations be made? These
326 are needed to deal with self-modifying code on uncooperative
327 platforms. */
328typedef
329 enum {
330 Vg_SmcNone, // never generate self-checking translations
331 Vg_SmcStack, // generate s-c-t's for code found in stacks
sewardj26412bd2005-07-07 10:05:05 +0000332 // (this is the default)
sewardj6dbcc632011-06-07 21:39:28 +0000333 Vg_SmcAll, // make all translations self-checking.
334 Vg_SmcAllNonFile // make all translations derived from
335 // non-file-backed memory self checking
sewardj26412bd2005-07-07 10:05:05 +0000336 }
337 VgSmc;
338
sewardjce5a5662005-10-06 03:19:49 +0000339/* Describe extent to which self-modifying-code should be
340 auto-detected. */
sewardj6c3a2192005-07-24 07:00:45 +0000341extern VgSmc VG_(clo_smc_check);
sewardj26412bd2005-07-07 10:05:05 +0000342
philippeec905f72014-08-17 20:03:51 +0000343/* A set of minor kernel variants,
sewardjce5a5662005-10-06 03:19:49 +0000344 so they can be properly handled by m_syswrap. */
sewardj4450a0e2014-09-03 15:19:25 +0000345typedef
346 enum {
347 KernelVariant_bproc,
sewardj124e56d2014-09-06 14:45:12 +0000348 KernelVariant_android_no_hw_tls,
sewardj4450a0e2014-09-03 15:19:25 +0000349 KernelVariant_android_gpu_sgx5xx,
350 KernelVariant_android_gpu_adreno3xx
philippeec905f72014-08-17 20:03:51 +0000351 }
352 KernelVariant;
353// Build mask to check or set KernelVariant a membership
354#define KernelVariant2S(v) (1 << (v))
355// KernelVariant v is member of the Set s ?
356#define KernelVariantiS(v,s) ((s) & KernelVariant2S(v))
357extern UInt VG_(clo_kernel_variant);
sewardj26412bd2005-07-07 10:05:05 +0000358
njnf76d27a2009-05-28 01:53:07 +0000359/* Darwin-specific: automatically run /usr/bin/dsymutil to update
360 .dSYM directories as necessary? */
njn97db7612009-08-04 02:32:55 +0000361extern Bool VG_(clo_dsymutil);
njnf76d27a2009-05-28 01:53:07 +0000362
sewardj06421272009-11-05 08:55:13 +0000363/* Should we trace into this child executable (across execve etc) ?
sewardj9ab64a42010-12-06 11:40:04 +0000364 This involves considering --trace-children=,
365 --trace-children-skip=, --trace-children-skip-by-arg=, and the name
366 of the executable. 'child_argv' must not include the name of the
367 executable itself; iow child_argv[0] must be the first arg, if any,
368 for the child. */
florian518850b2014-10-22 22:25:30 +0000369extern Bool VG_(should_we_trace_this_child) ( const HChar* child_exe_name,
370 const HChar** child_argv );
sewardj63d1c002006-10-19 17:31:37 +0000371
sewardjc30cd9b2012-12-06 18:08:54 +0000372/* Whether illegal instructions should be reported/diagnosed.
373 Can be explicitly set through --sigill-diagnostics otherwise
374 depends on verbosity (False if -q). */
375extern Bool VG_(clo_sigill_diag);
376
sewardj49984ea2013-10-18 13:21:26 +0000377/* Unwind using stack scanning (a nasty hack at the best of times)
378 when the normal CFI/FP-chain scan fails. If the number of
379 "normally" recovered frames is below this number, stack scanning
380 will be used (on platforms on which it is supported, currently only
381 arm-linux). The default value of zero has the effect of disabling
382 stack scanning. Default: zero*/
383extern UInt VG_(clo_unw_stack_scan_thresh);
384
385/* If stack scanning is used, this is how many frames it may recover.
386 Since it tends to pick up a lot of junk, this value is set pretty
387 low by default. Default: 5 */
388extern UInt VG_(clo_unw_stack_scan_frames);
389
sewardj67f7c032014-10-23 19:48:01 +0000390/* Controls the resync-filter on MacOS. Has no effect on Linux.
391 0=disabled [default on Linux] "no"
392 1=enabled [default on MacOS] "yes"
393 2=enabled and verbose. "verbose" */
394extern UInt VG_(clo_resync_filter);
395
njn20242342005-05-16 23:31:24 +0000396#endif // __PUB_CORE_OPTIONS_H
397
398/*--------------------------------------------------------------------*/
399/*--- end ---*/
400/*--------------------------------------------------------------------*/