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