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-2013 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, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 The GNU General Public License is contained in the file COPYING.
31 #ifndef __PUB_CORE_OPTIONS_H
32 #define __PUB_CORE_OPTIONS_H
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 #include "pub_tool_options.h"
40 #include "pub_core_xarray.h"
42 /* Should we stop collecting errors if too many appear? default: YES */
43 extern Bool
VG_(clo_error_limit
);
44 /* Alternative exit code to hand to parent if errors were found.
45 default: 0 (no, return the application's exit code in the normal
47 extern Int
VG_(clo_error_exitcode
);
49 /* 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. */
53 extern HChar
*VG_(clo_error_markers
)[2];
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
64 /* if != Vg_VgdbNo, allows valgrind to serve vgdb/gdb. */
65 extern VgVgdb
VG_(clo_vgdb
);
66 /* if > 0, checks every VG_(clo_vgdb_poll) BBS if vgdb wants to be served. */
67 extern Int
VG_(clo_vgdb_poll
);
69 /* Specify when Valgrind gdbserver stops the execution and wait
70 for a GDB to connect. */
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.
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))
82 extern UInt
VG_(clo_vgdb_stop_at
); // A set of VgdbStopAt reasons.
84 /* prefix for the named pipes (FIFOs) used by vgdb/gdb to communicate with valgrind */
85 extern const HChar
*VG_(clo_vgdb_prefix
);
87 /* if True, gdbserver in valgrind will expose a target description containing
89 extern Bool
VG_(clo_vgdb_shadow_registers
);
91 /* Enquire about whether to attach to a debugger at errors? default: NO */
92 extern Bool
VG_(clo_db_attach
);
93 /* The debugger command? default: whatever gdb ./configure found */
94 extern const HChar
* VG_(clo_db_command
);
95 /* Generating a suppression for each error? default: 0 (NO)
96 Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */
97 extern Int
VG_(clo_gen_suppressions
);
98 /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
99 extern Int
VG_(clo_sanity_level
);
100 /* Automatically attempt to demangle C++ names? default: YES */
101 extern Bool
VG_(clo_demangle
);
102 /* Soname synonyms : a string containing a list of pairs
103 xxxxx=yyyyy separated by commas.
104 E.g. --soname-synonyms=somalloc=libtcmalloc*.so*,solibtruc=NONE */
105 extern const HChar
* VG_(clo_soname_synonyms
);
106 /* Valgrind-ise child processes (follow execve)? default : NO */
107 extern Bool
VG_(clo_trace_children
);
108 /* String containing comma-separated patterns for executable names
109 that should not be traced into even when --trace-children=yes */
110 extern const HChar
* VG_(clo_trace_children_skip
);
111 /* The same as VG_(clo_trace_children), except that these patterns are
112 tested against the arguments for child processes, rather than the
114 extern const HChar
* VG_(clo_trace_children_skip_by_arg
);
115 /* After a fork, the child's output can become confusingly
116 intermingled with the parent's output. This is especially
117 problematic when VG_(clo_xml) is True. Setting
118 VG_(clo_child_silent_after_fork) causes children to fall silent
119 after fork() calls. Although note they become un-silent again
120 after the subsequent exec(). */
121 extern Bool
VG_(clo_child_silent_after_fork
);
123 /* If the user specified --log-file=STR and/or --xml-file=STR, these
124 hold STR after expansion of the %p and %q templates. */
125 extern const HChar
* VG_(clo_log_fname_expanded
);
126 extern const HChar
* VG_(clo_xml_fname_expanded
);
128 /* Add timestamps to log messages? default: NO */
129 extern Bool
VG_(clo_time_stamp
);
131 /* The file descriptor to read for input. default: 0 == stdin */
132 extern Int
VG_(clo_input_fd
);
134 /* Whether or not to load the default suppressions. */
135 extern Bool
VG_(clo_default_supp
);
137 /* The names of the suppression files. */
138 extern XArray
*VG_(clo_suppressions
);
140 /* An array of strings harvested from --fullpath-after= flags. */
141 extern XArray
*VG_(clo_fullpath_after
);
143 /* Full path to additional path to search for debug symbols */
144 extern const HChar
* VG_(clo_extra_debuginfo_path
);
146 /* Address of a debuginfo server to use. Either an IPv4 address of
147 the form "d.d.d.d" or that plus a port spec, hence of the form
148 "d.d.d.d:d", where d is one or more digits. */
149 extern const HChar
* VG_(clo_debuginfo_server
);
151 /* Do we allow reading debuginfo from debuginfo objects that don't
152 match (in some sense) the main object? This is dangerous, so the
153 default is NO (False). In any case it applies only to objects
154 found either in _extra_debuginfo_path or via the
155 _debuginfo_server. */
156 extern Bool
VG_(clo_allow_mismatched_debuginfo
);
158 /* DEBUG: print generated code? default: 00000000 ( == NO ) */
159 extern UChar
VG_(clo_trace_flags
);
161 /* DEBUG: do SB profiling? default: False (== NO). NOTE: does not
162 have an associated command line flag. Is set to True whenever
163 --profile-flags= is specified. */
164 extern Bool
VG_(clo_profyle_sbs
);
165 /* DEBUG: if doing SB profiling, provides bits for which JIT stages
166 are shown. Same meaning as for clo_trace_flags. default: zero (==
167 show block counts only) */
168 extern UChar
VG_(clo_profyle_flags
);
169 /* DEBUG: if doing SB profiling, dump blocks and zero counters after
170 this-many back edges (event checks). default: zero (== show
171 profiling results only at the end of the run. */
172 extern ULong
VG_(clo_profyle_interval
);
174 /* DEBUG: if tracing codegen, be quiet until after this bb */
175 extern Int
VG_(clo_trace_notbelow
);
176 /* DEBUG: if tracing codegen, be quiet after this bb */
177 extern Int
VG_(clo_trace_notabove
);
178 /* DEBUG: print system calls? default: NO */
179 extern Bool
VG_(clo_trace_syscalls
);
180 /* DEBUG: print signal details? default: NO */
181 extern Bool
VG_(clo_trace_signals
);
182 /* DEBUG: print symtab details? default: NO */
183 extern Bool
VG_(clo_trace_symtab
);
184 /* DEBUG: restrict symtab etc details to object name pattern. Default: "*" */
185 extern const HChar
* VG_(clo_trace_symtab_patt
);
186 /* DEBUG: print call-frame-info details? default: NO */
187 extern Bool
VG_(clo_trace_cfi
);
188 /* DEBUG: mimic /usr/bin/readelf --syms? default: NO */
189 extern Bool
VG_(clo_debug_dump_syms
);
190 /* DEBUG: mimic /usr/bin/readelf --debug-dump=line? default: NO */
191 extern Bool
VG_(clo_debug_dump_line
);
192 /* DEBUG: mimic /usr/bin/readelf --debug-dump=frames? default: NO */
193 extern Bool
VG_(clo_debug_dump_frames
);
194 /* DEBUG: print redirection details? default: NO */
195 extern Bool
VG_(clo_trace_redir
);
196 /* Enable fair scheduling on multicore systems? default: NO */
197 enum FairSchedType
{ disable_fair_sched
, enable_fair_sched
, try_fair_sched
};
198 extern enum FairSchedType
VG_(clo_fair_sched
);
199 /* DEBUG: print thread scheduling events? default: NO */
200 extern Bool
VG_(clo_trace_sched
);
201 /* DEBUG: do heap profiling? default: NO */
202 extern Bool
VG_(clo_profile_heap
);
203 #define MAX_REDZONE_SZB 128
204 // Maximum for the default values for core arenas and for client
205 // arena given by the tool.
206 // 128 is no special figure, just something not too big
207 #define MAX_CLO_REDZONE_SZB 4096
208 // We allow the user to increase the redzone size to 4Kb :
209 // This allows "off by one" in an array of pages to be detected.
210 #define CORE_REDZONE_DEFAULT_SZB 4
211 extern Int
VG_(clo_core_redzone_size
);
212 // VG_(clo_redzone_size) has default value -1, indicating to keep
213 // the tool provided value.
214 extern Int
VG_(clo_redzone_size
);
215 /* DEBUG: display gory details for the k'th most popular error.
216 default: Infinity. */
217 extern Int
VG_(clo_dump_error
);
219 /* Engage miscellaneous weird hacks needed for some progs. */
223 SimHint_fuse_compatible
,
224 SimHint_enable_outer
,
225 SimHint_no_inner_prefix
,
226 SimHint_no_nptl_pthread_stackcache
230 // Build mask to check or set SimHint a membership
231 #define SimHint2S(a) (1 << (a))
232 // SimHint h is member of the Set s ?
233 #define SimHintiS(h,s) ((s) & SimHint2S(h))
234 extern UInt
VG_(clo_sim_hints
);
236 /* Show symbols in the form 'name+offset' ? Default: NO */
237 extern Bool
VG_(clo_sym_offsets
);
238 /* Read DWARF3 inline info ? */
239 extern Bool
VG_(clo_read_inline_info
);
240 /* Read DWARF3 variable info even if tool doesn't ask for it? */
241 extern Bool
VG_(clo_read_var_info
);
242 /* Which prefix to strip from full source file paths, if any. */
243 extern const HChar
* VG_(clo_prefix_to_strip
);
245 /* An array of strings harvested from --require-text-symbol=
248 Each string specifies a pair: a soname pattern and a text symbol
249 name pattern, separated by a colon. The patterns can be written
250 using the normal "?" and "*" wildcards. For example:
251 ":*libc.so*:foo?bar".
253 These flags take effect when reading debuginfo from objects. If an
254 object is loaded and the object's soname matches the soname
255 component of one of the specified pairs, then Valgrind will examine
256 all the text symbol names in the object. If none of them match the
257 symbol name component of that same specification, then the run is
258 aborted, with an error message.
260 The purpose of this is to support reliable usage of marked-up
261 libraries. For example, suppose we have a version of GCC's
262 libgomp.so which has been marked up with annotations to support
263 Helgrind. It is only too easy and confusing to load the 'wrong'
264 libgomp.so into the application. So the idea is: add a text symbol
265 in the marked-up library (eg), "annotated_for_helgrind_3_6", and
268 --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
270 so that when libgomp.so is loaded, we scan the symbol table, and if
271 the symbol isn't present the run is aborted, rather than continuing
272 silently with the un-marked-up library. Note that you should put
273 the entire flag in quotes to stop shells messing up the * and ?
275 extern XArray
*VG_(clo_req_tsyms
);
277 /* Track open file descriptors? */
278 extern Bool
VG_(clo_track_fds
);
280 /* Should we run __libc_freeres at exit? Sometimes causes crashes.
281 Default: YES. Note this is subservient to VG_(needs).libc_freeres;
282 if the latter says False, then the setting of VG_(clo_run_libc_freeres)
283 is ignored. Ie if a tool says no, I don't want this to run, that
284 cannot be overridden from the command line. */
285 extern Bool
VG_(clo_run_libc_freeres
);
287 /* Should we show VEX emulation warnings? Default: NO */
288 extern Bool
VG_(clo_show_emwarns
);
290 /* How much does the stack pointer have to change before tools
291 consider a stack switch to have happened? Default: 2000000 bytes
292 NB: must be host-word-sized to be correct (hence Word). */
293 extern Word
VG_(clo_max_stackframe
);
294 /* How large should Valgrind allow the primary thread's guest stack to
296 extern Word
VG_(clo_main_stacksize
);
298 /* If the same IP is found twice in a backtrace in a sequence of max
299 VG_(clo_merge_recursive_frames) frames, then the recursive call
300 is merged in the backtrace.
301 Note also that the merge is done during unwinding, to obtain
302 an much as possible significant backtrace.
303 Note that the value is changeable by a gdbsrv command. */
304 extern Int
VG_(clo_merge_recursive_frames
);
306 /* Max number of sectors that will be used by the translation code cache. */
307 extern UInt
VG_(clo_num_transtab_sectors
);
309 /* Only client requested fixed mapping can be done below
310 VG_(clo_aspacem_minAddr). */
311 extern Addr
VG_(clo_aspacem_minAddr
);
313 /* Delay startup to allow GDB to be attached? Default: NO */
314 extern Bool
VG_(clo_wait_for_gdb
);
316 /* To what extent should self-checking translations be made? These
317 are needed to deal with self-modifying code on uncooperative
321 Vg_SmcNone
, // never generate self-checking translations
322 Vg_SmcStack
, // generate s-c-t's for code found in stacks
323 // (this is the default)
324 Vg_SmcAll
, // make all translations self-checking.
325 Vg_SmcAllNonFile
// make all translations derived from
326 // non-file-backed memory self checking
330 /* Describe extent to which self-modifying-code should be
332 extern VgSmc
VG_(clo_smc_check
);
334 /* A set of minor kernel variants,
335 so they can be properly handled by m_syswrap. */
339 KernelVariant_android_no_hw_tls
,
340 KernelVariant_android_gpu_sgx5xx
,
341 KernelVariant_android_gpu_adreno3xx
344 // Build mask to check or set KernelVariant a membership
345 #define KernelVariant2S(v) (1 << (v))
346 // KernelVariant v is member of the Set s ?
347 #define KernelVariantiS(v,s) ((s) & KernelVariant2S(v))
348 extern UInt
VG_(clo_kernel_variant
);
350 /* Darwin-specific: automatically run /usr/bin/dsymutil to update
351 .dSYM directories as necessary? */
352 extern Bool
VG_(clo_dsymutil
);
354 /* Should we trace into this child executable (across execve etc) ?
355 This involves considering --trace-children=,
356 --trace-children-skip=, --trace-children-skip-by-arg=, and the name
357 of the executable. 'child_argv' must not include the name of the
358 executable itself; iow child_argv[0] must be the first arg, if any,
360 extern Bool
VG_(should_we_trace_this_child
) ( const HChar
* child_exe_name
,
361 const HChar
** child_argv
);
363 /* Whether illegal instructions should be reported/diagnosed.
364 Can be explicitly set through --sigill-diagnostics otherwise
365 depends on verbosity (False if -q). */
366 extern Bool
VG_(clo_sigill_diag
);
368 /* Unwind using stack scanning (a nasty hack at the best of times)
369 when the normal CFI/FP-chain scan fails. If the number of
370 "normally" recovered frames is below this number, stack scanning
371 will be used (on platforms on which it is supported, currently only
372 arm-linux). The default value of zero has the effect of disabling
373 stack scanning. Default: zero*/
374 extern UInt
VG_(clo_unw_stack_scan_thresh
);
376 /* If stack scanning is used, this is how many frames it may recover.
377 Since it tends to pick up a lot of junk, this value is set pretty
378 low by default. Default: 5 */
379 extern UInt
VG_(clo_unw_stack_scan_frames
);
381 /* Controls the resync-filter on MacOS. Has no effect on Linux.
382 0=disabled [default on Linux] "no"
383 1=enabled [default on MacOS] "yes"
384 2=enabled and verbose. "verbose" */
385 extern UInt
VG_(clo_resync_filter
);
387 #endif // __PUB_CORE_OPTIONS_H
389 /*--------------------------------------------------------------------*/
391 /*--------------------------------------------------------------------*/