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