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