2 /*--------------------------------------------------------------------*/
3 /*--- Command line options. pub_core_options.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2017 Julian Seward
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.
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.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __PUB_CORE_OPTIONS_H
30 #define __PUB_CORE_OPTIONS_H
32 //--------------------------------------------------------------------
33 // PURPOSE: This module holds the variables for all command line options,
34 // plus some functions and macros for manipulating them. Almost every
35 // other module imports this one, if only for VG_(clo_verbosity).
36 //--------------------------------------------------------------------
37 #include "pub_tool_options.h"
38 #include "pub_core_xarray.h"
40 /* Valgrind tool name. Defaults to "memcheck". */
41 extern const HChar
*VG_(clo_toolname
);
43 /* Should we stop collecting errors if too many appear? default: YES */
44 extern Bool
VG_(clo_error_limit
);
45 /* Should we exit if an error appears? default: NO */
46 extern Bool
VG_(clo_exit_on_first_error
);
47 /* Alternative exit code to hand to parent if errors were found.
48 default: 0 (no, return the application's exit code in the normal
50 extern Int
VG_(clo_error_exitcode
);
52 /* For tools that report errors, list detected errors and show suppression
53 usage counts at exit. Default: No.
54 Unless set explicitly by the user, the option is automatically
55 considered as set to yes for verbosity > 1.
56 Note that in xml mode, errors are automatically printed as part of
57 the xml output. This option then only controls printing the used suppressions.
60 2 (all meaning also print suppressed errors). */
61 extern Int
VG_(clo_show_error_list
);
64 /* Markers used to mark the begin/end of an error, when errors are
65 printed in textual (non xml) format.
66 [0] is the error begin marker, [1] is the error end marker.
67 default: no markers. */
68 extern HChar
*VG_(clo_error_markers
)[2];
72 Vg_VgdbNo
, // Do not activate gdbserver.
73 Vg_VgdbYes
, // Activate gdbserver (default).
74 Vg_VgdbFull
, // ACtivate gdbserver in full mode, allowing
75 // a precise handling of watchpoints and single stepping
79 /* if != Vg_VgdbNo, allows valgrind to serve vgdb/gdb. */
80 extern VgVgdb
VG_(clo_vgdb
);
81 /* if > 0, checks every VG_(clo_vgdb_poll) BBS if vgdb wants to be served. */
82 extern Int
VG_(clo_vgdb_poll
);
84 /* Specify when Valgrind gdbserver stops the execution and wait
85 for a GDB to connect. */
87 enum { // Stop just before ...
88 VgdbStopAt_Startup
, // ... the client starts to execute.
89 VgdbStopAt_Exit
, // ... the client exits with any exit code..
90 VgdbStopAt_Abexit
, // ... the client exits with a non 0 exit code.
91 VgdbStopAt_ValgrindAbExit
// ... an abnormal valgrind exit.
94 // Build mask to check or set VgdbStop_At a membership
95 #define VgdbStopAt2S(a) (1 << (a))
96 // VgdbStopAt a is member of the Set s ?
97 #define VgdbStopAtiS(a,s) ((s) & VgdbStopAt2S(a))
98 extern UInt
VG_(clo_vgdb_stop_at
); // A set of VgdbStopAt reasons.
100 /* prefix for the named pipes (FIFOs) used by vgdb/gdb to communicate with valgrind */
101 extern const HChar
*VG_(clo_vgdb_prefix
);
103 /* if True, gdbserver in valgrind will expose a target description containing
105 extern Bool
VG_(clo_vgdb_shadow_registers
);
107 /* Generating a suppression for each error? default: 0 (NO)
108 Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */
109 extern Int
VG_(clo_gen_suppressions
);
110 /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
111 extern Int
VG_(clo_sanity_level
);
112 /* Automatically attempt to demangle C++ names? default: YES */
113 extern Bool
VG_(clo_demangle
);
114 /* Soname synonyms : a string containing a list of pairs
115 xxxxx=yyyyy separated by commas.
116 E.g. --soname-synonyms=somalloc=libtcmalloc*.so*,solibtruc=NONE */
117 extern const HChar
* VG_(clo_soname_synonyms
);
118 /* Valgrind-ise child processes (follow execve)? default : NO */
119 extern Bool
VG_(clo_trace_children
);
120 /* String containing comma-separated patterns for executable names
121 that should not be traced into even when --trace-children=yes */
122 extern const HChar
* VG_(clo_trace_children_skip
);
123 /* The same as VG_(clo_trace_children), except that these patterns are
124 tested against the arguments for child processes, rather than the
126 extern const HChar
* VG_(clo_trace_children_skip_by_arg
);
127 /* After a fork, the child's output can become confusingly
128 intermingled with the parent's output. This is especially
129 problematic when VG_(clo_xml) is True. Setting
130 VG_(clo_child_silent_after_fork) causes children to fall silent
131 after fork() calls. Although note they become un-silent again
132 after the subsequent exec(). */
133 extern Bool
VG_(clo_child_silent_after_fork
);
135 #if defined(VGO_linux)
136 /* If True, valgrind will attempt to query debuginfod servers for
137 any missing debuginfo. */
138 extern Bool
VG_(clo_enable_debuginfod
);
141 /* If the user specified --log-file=STR and/or --xml-file=STR, these
142 hold STR before expansion. */
143 extern const HChar
*VG_(clo_log_fname_unexpanded
);
144 extern const HChar
*VG_(clo_xml_fname_unexpanded
);
146 /* Add timestamps to log messages? default: NO */
147 extern Bool
VG_(clo_time_stamp
);
149 /* The file descriptor to read for input. default: 0 == stdin */
150 extern Int
VG_(clo_input_fd
);
152 /* Whether or not to load the default suppressions. */
153 extern Bool
VG_(clo_default_supp
);
155 /* The names of the suppression files. */
156 extern XArray
*VG_(clo_suppressions
);
158 /* An array of strings harvested from --fullpath-after= flags. */
159 extern XArray
*VG_(clo_fullpath_after
);
161 /* Full path to additional path to search for debug symbols */
162 extern const HChar
* VG_(clo_extra_debuginfo_path
);
164 /* Address of a debuginfo server to use. Either an IPv4 address of
165 the form "d.d.d.d" or that plus a port spec, hence of the form
166 "d.d.d.d:d", where d is one or more digits. */
167 extern const HChar
* VG_(clo_debuginfo_server
);
169 /* Do we allow reading debuginfo from debuginfo objects that don't
170 match (in some sense) the main object? This is dangerous, so the
171 default is NO (False). In any case it applies only to objects
172 found either in _extra_debuginfo_path or via the
173 _debuginfo_server. */
174 extern Bool
VG_(clo_allow_mismatched_debuginfo
);
176 /* DEBUG: print generated code? default: 00000000 ( == NO ) */
177 extern UChar
VG_(clo_trace_flags
);
179 /* DEBUG: do SB profiling? default: False (== NO). NOTE: does not
180 have an associated command line flag. Is set to True whenever
181 --profile-flags= is specified. */
182 extern Bool
VG_(clo_profyle_sbs
);
183 /* DEBUG: if doing SB profiling, provides bits for which JIT stages
184 are shown. Same meaning as for clo_trace_flags. default: zero (==
185 show block counts only) */
186 extern UChar
VG_(clo_profyle_flags
);
187 /* DEBUG: if doing SB profiling, dump blocks and zero counters after
188 this-many back edges (event checks). default: zero (== show
189 profiling results only at the end of the run. */
190 extern ULong
VG_(clo_profyle_interval
);
192 /* DEBUG: if tracing codegen, be quiet until after this bb */
193 extern Int
VG_(clo_trace_notbelow
);
194 /* DEBUG: if tracing codegen, be quiet after this bb */
195 extern Int
VG_(clo_trace_notabove
);
196 /* DEBUG: print system calls? default: NO */
197 extern Bool
VG_(clo_trace_syscalls
);
198 /* DEBUG: print signal details? default: NO */
199 extern Bool
VG_(clo_trace_signals
);
200 /* DEBUG: print symtab details? default: NO */
201 extern Bool
VG_(clo_trace_symtab
);
202 /* DEBUG: restrict symtab etc details to object name pattern. Default: "*" */
203 extern const HChar
* VG_(clo_trace_symtab_patt
);
204 /* DEBUG: print call-frame-info details? default: NO */
205 extern Bool
VG_(clo_trace_cfi
);
206 /* DEBUG: mimic /usr/bin/readelf --syms? default: NO */
207 extern Bool
VG_(clo_debug_dump_syms
);
208 /* DEBUG: mimic /usr/bin/readelf --debug-dump=line? default: NO */
209 extern Bool
VG_(clo_debug_dump_line
);
210 /* DEBUG: mimic /usr/bin/readelf --debug-dump=frames? default: NO */
211 extern Bool
VG_(clo_debug_dump_frames
);
212 /* DEBUG: print redirection details? default: NO */
213 extern Bool
VG_(clo_trace_redir
);
214 /* Enable fair scheduling on multicore systems? default: NO */
215 enum FairSchedType
{ disable_fair_sched
, enable_fair_sched
, try_fair_sched
};
216 extern enum FairSchedType
VG_(clo_fair_sched
);
217 /* thread-scheduling timeslice. */
218 extern Word
VG_(clo_scheduling_quantum
);
219 /* DEBUG: print thread scheduling events? default: NO */
220 extern Bool
VG_(clo_trace_sched
);
221 /* DEBUG: do heap profiling? default: NO */
222 extern Bool
VG_(clo_profile_heap
);
223 // DEBUG: report progress every N seconds (1 .. 3600)
224 extern UInt
VG_(clo_progress_interval
);
225 #define MAX_REDZONE_SZB 128
226 // Maximum for the default values for core arenas and for client
227 // arena given by the tool.
228 // 128 is no special figure, just something not too big
229 #define MAX_CLO_REDZONE_SZB 4096
230 // We allow the user to increase the redzone size to 4Kb :
231 // This allows "off by one" in an array of pages to be detected.
232 #define CORE_REDZONE_DEFAULT_SZB 4
233 extern Int
VG_(clo_core_redzone_size
);
234 // VG_(clo_redzone_size) has default value -1, indicating to keep
235 // the tool provided value.
236 /* DEBUG: display gory details for the k'th most popular error.
237 default: Infinity. */
238 extern Int
VG_(clo_dump_error
);
240 /* Engage miscellaneous weird hacks needed for some progs. */
245 SimHint_fuse_compatible
,
246 SimHint_enable_outer
,
247 SimHint_no_inner_prefix
,
248 SimHint_no_nptl_pthread_stackcache
,
249 SimHint_fallback_llsc
253 // Build mask to check or set SimHint a membership
254 #define SimHint2S(a) (1 << (a))
255 // SimHint h is member of the Set s ?
256 #define SimHintiS(h,s) (((s) & SimHint2S(h)) != 0)
257 extern UInt
VG_(clo_sim_hints
);
259 /* Show symbols in the form 'name+offset' ? Default: NO */
260 extern Bool
VG_(clo_sym_offsets
);
261 /* Read DWARF3 inline info ? */
262 extern Bool
VG_(clo_read_inline_info
);
263 /* Read DWARF3 variable info even if tool doesn't ask for it? */
264 extern Bool
VG_(clo_read_var_info
);
265 /* Which prefix to strip from full source file paths, if any. */
266 extern const HChar
* VG_(clo_prefix_to_strip
);
268 /* An array of strings harvested from --require-text-symbol=
271 Each string specifies a pair: a soname pattern and a text symbol
272 name pattern, separated by a colon. The patterns can be written
273 using the normal "?" and "*" wildcards. For example:
274 ":*libc.so*:foo?bar".
276 These flags take effect when reading debuginfo from objects. If an
277 object is loaded and the object's soname matches the soname
278 component of one of the specified pairs, then Valgrind will examine
279 all the text symbol names in the object. If none of them match the
280 symbol name component of that same specification, then the run is
281 aborted, with an error message.
283 The purpose of this is to support reliable usage of marked-up
284 libraries. For example, suppose we have a version of GCC's
285 libgomp.so which has been marked up with annotations to support
286 Helgrind. It is only too easy and confusing to load the 'wrong'
287 libgomp.so into the application. So the idea is: add a text symbol
288 in the marked-up library (eg), "annotated_for_helgrind_3_6", and
291 --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
293 so that when libgomp.so is loaded, we scan the symbol table, and if
294 the symbol isn't present the run is aborted, rather than continuing
295 silently with the un-marked-up library. Note that you should put
296 the entire flag in quotes to stop shells messing up the * and ?
298 extern XArray
*VG_(clo_req_tsyms
);
300 /* Should we run __libc_freeres at exit? Sometimes causes crashes.
301 Default: YES. Note this is subservient to VG_(needs).libc_freeres;
302 if the latter says False, then the setting of VG_(clo_run_libc_freeres)
303 is ignored. Ie if a tool says no, I don't want this to run, that
304 cannot be overridden from the command line. */
305 extern Bool
VG_(clo_run_libc_freeres
);
307 /* Should we run __gnu_cxx::__freeres at exit for C++ programs?
308 Default: YES. Note this is subservient to VG_(needs).cxx_freeres;
309 if the latter says False, then the setting of VG_(clo_run_cxx_freeres)
310 is ignored. Ie if a tool says no, I don't want this to run, that
311 cannot be overridden from the command line. */
312 extern Bool
VG_(clo_run_cxx_freeres
);
314 /* Should we show VEX emulation warnings? Default: NO */
315 extern Bool
VG_(clo_show_emwarns
);
317 /* How much does the stack pointer have to change before tools
318 consider a stack switch to have happened? Default: 2000000 bytes
319 NB: must be host-word-sized to be correct (hence Word). */
320 extern Word
VG_(clo_max_stackframe
);
321 /* How large should Valgrind allow the primary thread's guest stack to
323 extern Word
VG_(clo_main_stacksize
);
325 /* The maximum number of threads we support. */
326 #define MAX_THREADS_DEFAULT 500
327 extern UInt
VG_(clo_max_threads
);
329 /* If the same IP is found twice in a backtrace in a sequence of max
330 VG_(clo_merge_recursive_frames) frames, then the recursive call
331 is merged in the backtrace.
332 Note also that the merge is done during unwinding, to obtain
333 an much as possible significant backtrace.
334 Note that the value is changeable by a gdbsrv command. */
335 extern Int
VG_(clo_merge_recursive_frames
);
337 /* Max number of sectors that will be used by the translation code cache. */
338 extern UInt
VG_(clo_num_transtab_sectors
);
340 /* Average size of a transtab code entry. 0 means to use the tool
342 extern UInt
VG_(clo_avg_transtab_entry_size
);
344 /* Only client requested fixed mapping can be done below
345 VG_(clo_aspacem_minAddr). */
346 extern Addr
VG_(clo_aspacem_minAddr
);
348 /* How large the Valgrind thread stacks should be.
349 Will be rounded up to a page.. */
350 extern Word
VG_(clo_valgrind_stacksize
);
352 /* Delay startup to allow GDB to be attached? Default: NO */
353 extern Bool
VG_(clo_wait_for_gdb
);
355 /* To what extent should self-checking translations be made? These
356 are needed to deal with self-modifying code on uncooperative
360 Vg_SmcNone
, // never generate self-checking translations
361 Vg_SmcStack
, // generate s-c-t's for code found in stacks
362 // (this is the default)
363 Vg_SmcAll
, // make all translations self-checking.
364 Vg_SmcAllNonFile
// make all translations derived from
365 // non-file-backed memory self checking
369 /* Describe extent to which self-modifying-code should be
371 extern VgSmc
VG_(clo_smc_check
);
373 /* A set of minor kernel variants,
374 so they can be properly handled by m_syswrap. */
378 KernelVariant_android_no_hw_tls
,
379 KernelVariant_android_gpu_sgx5xx
,
380 KernelVariant_android_gpu_adreno3xx
383 // Build mask to check or set KernelVariant a membership
384 #define KernelVariant2S(v) (1 << (v))
385 // KernelVariant v is member of the Set s ?
386 #define KernelVariantiS(v,s) ((s) & KernelVariant2S(v))
387 extern UInt
VG_(clo_kernel_variant
);
389 /* Darwin-specific: automatically run /usr/bin/dsymutil to update
390 .dSYM directories as necessary? */
391 extern Bool
VG_(clo_dsymutil
);
393 /* Outputs the list of dynamically changeable options. */
394 extern void VG_(list_dynamic_options
) (void);
396 /* Should we trace into this child executable (across execve etc) ?
397 This involves considering --trace-children=,
398 --trace-children-skip=, --trace-children-skip-by-arg=, and the name
399 of the executable. 'child_argv' must not include the name of the
400 executable itself; iow child_argv[0] must be the first arg, if any,
402 extern Bool
VG_(should_we_trace_this_child
) ( const HChar
* child_exe_name
,
403 const HChar
** child_argv
);
405 /* Whether illegal instructions should be reported/diagnosed.
406 Can be explicitly set through --sigill-diagnostics otherwise
407 depends on verbosity (False if -q). */
408 extern Bool
VG_(clo_sigill_diag
);
410 /* Unwind using stack scanning (a nasty hack at the best of times)
411 when the normal CFI/FP-chain scan fails. If the number of
412 "normally" recovered frames is below this number, stack scanning
413 will be used (on platforms on which it is supported, currently only
414 arm-linux). The default value of zero has the effect of disabling
415 stack scanning. Default: zero*/
416 extern UInt
VG_(clo_unw_stack_scan_thresh
);
418 /* If stack scanning is used, this is how many frames it may recover.
419 Since it tends to pick up a lot of junk, this value is set pretty
420 low by default. Default: 5 */
421 extern UInt
VG_(clo_unw_stack_scan_frames
);
423 /* Controls the resync-filter on MacOS. Has no effect on Linux.
424 0=disabled [default on Linux] "no"
425 1=enabled [default on MacOS] "yes"
426 2=enabled and verbose. "verbose" */
427 extern UInt
VG_(clo_resync_filter
);
429 #endif // __PUB_CORE_OPTIONS_H
431 /*--------------------------------------------------------------------*/
433 /*--------------------------------------------------------------------*/