pub_core_options.h revision 436e89c602e787e7a27dd6624b09beed41a0da8a
1
2/*--------------------------------------------------------------------*/
3/*--- Command line options.                     pub_core_options.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7   This file is part of Valgrind, a dynamic binary instrumentation
8   framework.
9
10   Copyright (C) 2000-2013 Julian Seward
11      jseward@acm.org
12
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.
17
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.
22
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.
27
28   The GNU General Public License is contained in the file COPYING.
29*/
30
31#ifndef __PUB_CORE_OPTIONS_H
32#define __PUB_CORE_OPTIONS_H
33
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
40#include "pub_tool_options.h"
41
42/* The max number of suppression files. */
43#define VG_CLO_MAX_SFILES 100
44
45/* The max number of --require-text-symbol= specification strings. */
46#define VG_CLO_MAX_REQ_TSYMS 100
47
48/* The max number of --fullpath-after= parameters. */
49#define VG_CLO_MAX_FULLPATH_AFTER 100
50
51/* Should we stop collecting errors if too many appear?  default: YES */
52extern Bool  VG_(clo_error_limit);
53/* Alternative exit code to hand to parent if errors were found.
54   default: 0 (no, return the application's exit code in the normal
55   way. */
56extern Int   VG_(clo_error_exitcode);
57
58typedef
59   enum {
60      Vg_VgdbNo,   // Do not activate gdbserver.
61      Vg_VgdbYes,  // Activate gdbserver (default).
62      Vg_VgdbFull, // ACtivate gdbserver in full mode, allowing
63                   // a precise handling of watchpoints and single stepping
64                   // at any moment.
65   }
66   VgVgdb;
67/* if != Vg_VgdbNo, allows valgrind to serve vgdb/gdb. */
68extern VgVgdb VG_(clo_vgdb);
69/* if > 0, checks every VG_(clo_vgdb_poll) BBS if vgdb wants to be served. */
70extern Int VG_(clo_vgdb_poll);
71
72/* prefix for the named pipes (FIFOs) used by vgdb/gdb to communicate with valgrind */
73extern const HChar *VG_(clo_vgdb_prefix);
74
75/* if True, gdbserver in valgrind will expose a target description containing
76   shadow registers */
77extern Bool  VG_(clo_vgdb_shadow_registers);
78
79/* Enquire about whether to attach to a debugger at errors?   default: NO */
80extern Bool  VG_(clo_db_attach);
81/* The debugger command?  default: whatever gdb ./configure found */
82extern const HChar* VG_(clo_db_command);
83/* Generating a suppression for each error?   default: 0 (NO)
84   Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */
85extern Int   VG_(clo_gen_suppressions);
86/* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
87extern Int   VG_(clo_sanity_level);
88/* Automatically attempt to demangle C++ names?  default: YES */
89extern Bool  VG_(clo_demangle);
90/* Simulate child processes? default: NO */
91/* Soname synonyms : a string containing a list of pairs
92   xxxxx=yyyyy separated by commas.
93   E.g. --soname-synonyms=somalloc=libtcmalloc*.so*,solibtruc=NONE */
94extern const HChar* VG_(clo_soname_synonyms);
95extern Bool  VG_(clo_trace_children);
96/* String containing comma-separated patterns for executable names
97   that should not be traced into even when --trace-children=yes */
98extern const HChar* VG_(clo_trace_children_skip);
99/* The same as VG_(clo_trace_children), except that these patterns are
100   tested against the arguments for child processes, rather than the
101   executable name. */
102extern const HChar* VG_(clo_trace_children_skip_by_arg);
103/* After a fork, the child's output can become confusingly
104   intermingled with the parent's output.  This is especially
105   problematic when VG_(clo_xml) is True.  Setting
106   VG_(clo_child_silent_after_fork) causes children to fall silent
107   after fork() calls.  Although note they become un-silent again
108   after the subsequent exec(). */
109extern Bool  VG_(clo_child_silent_after_fork);
110
111/* If the user specified --log-file=STR and/or --xml-file=STR, these
112   hold STR after expansion of the %p and %q templates. */
113extern HChar* VG_(clo_log_fname_expanded);
114extern HChar* VG_(clo_xml_fname_expanded);
115
116/* Add timestamps to log messages?  default: NO */
117extern Bool  VG_(clo_time_stamp);
118
119/* The file descriptor to read for input.  default: 0 == stdin */
120extern Int   VG_(clo_input_fd);
121
122/* The number of suppression files specified. */
123extern Int   VG_(clo_n_suppressions);
124/* The names of the suppression files. */
125extern const HChar* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
126
127/* An array of strings harvested from --fullpath-after= flags. */
128extern Int   VG_(clo_n_fullpath_after);
129extern const HChar* VG_(clo_fullpath_after)[VG_CLO_MAX_FULLPATH_AFTER];
130
131/* Full path to additional path to search for debug symbols */
132extern const HChar* VG_(clo_extra_debuginfo_path);
133
134/* Address of a debuginfo server to use.  Either an IPv4 address of
135   the form "d.d.d.d" or that plus a port spec, hence of the form
136   "d.d.d.d:d", where d is one or more digits. */
137extern const HChar* VG_(clo_debuginfo_server);
138
139/* Do we allow reading debuginfo from debuginfo objects that don't
140   match (in some sense) the main object?  This is dangerous, so the
141   default is NO (False).  In any case it applies only to objects
142   found either in _extra_debuginfo_path or via the
143   _debuginfo_server. */
144extern Bool VG_(clo_allow_mismatched_debuginfo);
145
146/* DEBUG: print generated code?  default: 00000000 ( == NO ) */
147extern UChar VG_(clo_trace_flags);
148
149/* DEBUG: do SB profiling? default: False (== NO).  NOTE: does not
150   have an associated command line flag.  Is set to True whenever
151   --profile-flags= is specified. */
152extern Bool  VG_(clo_profyle_sbs);
153/* DEBUG: if doing SB profiling, provides bits for which JIT stages
154   are shown.  Same meaning as for clo_trace_flags.  default: zero (==
155   show block counts only) */
156extern UChar VG_(clo_profyle_flags);
157/* DEBUG: if doing SB profiling, dump blocks and zero counters after
158   this-many back edges (event checks).  default: zero (== show
159   profiling results only at the end of the run. */
160extern ULong VG_(clo_profyle_interval);
161
162/* DEBUG: if tracing codegen, be quiet until after this bb */
163extern Int   VG_(clo_trace_notbelow);
164/* DEBUG: if tracing codegen, be quiet after this bb  */
165extern Int   VG_(clo_trace_notabove);
166/* DEBUG: print system calls?  default: NO */
167extern Bool  VG_(clo_trace_syscalls);
168/* DEBUG: print signal details?  default: NO */
169extern Bool  VG_(clo_trace_signals);
170/* DEBUG: print symtab details?  default: NO */
171extern Bool  VG_(clo_trace_symtab);
172/* DEBUG: restrict symtab etc details to object name pattern.  Default: "*" */
173extern const HChar* VG_(clo_trace_symtab_patt);
174/* DEBUG: print call-frame-info details?  default: NO */
175extern Bool  VG_(clo_trace_cfi);
176/* DEBUG:  mimic /usr/bin/readelf --syms?  default: NO */
177extern Bool  VG_(clo_debug_dump_syms);
178/* DEBUG: mimic /usr/bin/readelf --debug-dump=line?  default: NO */
179extern Bool  VG_(clo_debug_dump_line);
180/* DEBUG: mimic  /usr/bin/readelf --debug-dump=frames?  default: NO */
181extern Bool  VG_(clo_debug_dump_frames);
182/* DEBUG: print redirection details?  default: NO */
183extern Bool  VG_(clo_trace_redir);
184/* Enable fair scheduling on multicore systems? default: NO */
185enum FairSchedType { disable_fair_sched, enable_fair_sched, try_fair_sched };
186extern enum FairSchedType VG_(clo_fair_sched);
187/* DEBUG: print thread scheduling events?  default: NO */
188extern Bool  VG_(clo_trace_sched);
189/* DEBUG: do heap profiling?  default: NO */
190extern Bool  VG_(clo_profile_heap);
191#define MAX_REDZONE_SZB 128
192// Maximum for the default values for core arenas and for client
193// arena given by the tool.
194// 128 is no special figure, just something not too big
195#define MAX_CLO_REDZONE_SZB 4096
196// We allow the user to increase the redzone size to 4Kb :
197// This allows "off by one" in an array of pages to be detected.
198#define CORE_REDZONE_DEFAULT_SZB 4
199extern Int VG_(clo_core_redzone_size);
200// VG_(clo_redzone_size) has default value -1, indicating to keep
201// the tool provided value.
202extern Int VG_(clo_redzone_size);
203/* DEBUG: display gory details for the k'th most popular error.
204   default: Infinity. */
205extern Int   VG_(clo_dump_error);
206/* Engage miscellaneous weird hacks needed for some progs. */
207extern const HChar* VG_(clo_sim_hints);
208/* Show symbols in the form 'name+offset' ?  Default: NO */
209extern Bool VG_(clo_sym_offsets);
210/* Read DWARF3 variable info even if tool doesn't ask for it? */
211extern Bool VG_(clo_read_var_info);
212/* Which prefix to strip from full source file paths, if any. */
213extern const HChar* VG_(clo_prefix_to_strip);
214
215/* An array of strings harvested from --require-text-symbol=
216   flags.
217
218   Each string specifies a pair: a soname pattern and a text symbol
219   name pattern, separated by a colon.  The patterns can be written
220   using the normal "?" and "*" wildcards.  For example:
221   ":*libc.so*:foo?bar".
222
223   These flags take effect when reading debuginfo from objects.  If an
224   object is loaded and the object's soname matches the soname
225   component of one of the specified pairs, then Valgrind will examine
226   all the text symbol names in the object.  If none of them match the
227   symbol name component of that same specification, then the run is
228   aborted, with an error message.
229
230   The purpose of this is to support reliable usage of marked-up
231   libraries.  For example, suppose we have a version of GCC's
232   libgomp.so which has been marked up with annotations to support
233   Helgrind.  It is only too easy and confusing to load the 'wrong'
234   libgomp.so into the application.  So the idea is: add a text symbol
235   in the marked-up library (eg), "annotated_for_helgrind_3_6", and
236   then give the flag
237
238     --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
239
240   so that when libgomp.so is loaded, we scan the symbol table, and if
241   the symbol isn't present the run is aborted, rather than continuing
242   silently with the un-marked-up library.  Note that you should put
243   the entire flag in quotes to stop shells messing up the * and ?
244   wildcards. */
245extern Int    VG_(clo_n_req_tsyms);
246extern const HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
247
248/* Track open file descriptors? */
249extern Bool  VG_(clo_track_fds);
250
251/* Should we run __libc_freeres at exit?  Sometimes causes crashes.
252   Default: YES.  Note this is subservient to VG_(needs).libc_freeres;
253   if the latter says False, then the setting of VG_(clo_run_libc_freeres)
254   is ignored.  Ie if a tool says no, I don't want this to run, that
255   cannot be overridden from the command line. */
256extern Bool  VG_(clo_run_libc_freeres);
257
258/* Should we show VEX emulation warnings?  Default: NO */
259extern Bool VG_(clo_show_emwarns);
260
261/* How much does the stack pointer have to change before tools
262   consider a stack switch to have happened?  Default: 2000000 bytes
263   NB: must be host-word-sized to be correct (hence Word). */
264extern Word VG_(clo_max_stackframe);
265/* How large should Valgrind allow the primary thread's guest stack to
266   be? */
267extern Word VG_(clo_main_stacksize);
268
269/* If the same IP is found twice in a backtrace in a sequence of max
270   VG_(clo_merge_recursive_frames) frames, then the recursive call
271   is merged in the backtrace.
272   Note also that the merge is done during unwinding, to obtain
273   an much as possible significant backtrace.
274   Note that the value is changeable by a gdbsrv command. */
275extern Int VG_(clo_merge_recursive_frames);
276
277/* Max number of sectors that will be used by the translation code cache. */
278extern UInt VG_(clo_num_transtab_sectors);
279
280/* Delay startup to allow GDB to be attached?  Default: NO */
281extern Bool VG_(clo_wait_for_gdb);
282
283/* To what extent should self-checking translations be made?  These
284   are needed to deal with self-modifying code on uncooperative
285   platforms. */
286typedef
287   enum {
288      Vg_SmcNone,  // never generate self-checking translations
289      Vg_SmcStack, // generate s-c-t's for code found in stacks
290                   // (this is the default)
291      Vg_SmcAll,   // make all translations self-checking.
292      Vg_SmcAllNonFile // make all translations derived from
293                   // non-file-backed memory self checking
294   }
295   VgSmc;
296
297/* Describe extent to which self-modifying-code should be
298   auto-detected. */
299extern VgSmc VG_(clo_smc_check);
300
301/* String containing comma-separated names of minor kernel variants,
302   so they can be properly handled by m_syswrap. */
303extern const HChar* VG_(clo_kernel_variant);
304
305/* Darwin-specific: automatically run /usr/bin/dsymutil to update
306   .dSYM directories as necessary? */
307extern Bool VG_(clo_dsymutil);
308
309/* Should we trace into this child executable (across execve etc) ?
310   This involves considering --trace-children=,
311   --trace-children-skip=, --trace-children-skip-by-arg=, and the name
312   of the executable.  'child_argv' must not include the name of the
313   executable itself; iow child_argv[0] must be the first arg, if any,
314   for the child. */
315extern Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name,
316                                              HChar** child_argv );
317
318/* Whether illegal instructions should be reported/diagnosed.
319   Can be explicitly set through --sigill-diagnostics otherwise
320   depends on verbosity (False if -q). */
321extern Bool VG_(clo_sigill_diag);
322
323/* Unwind using stack scanning (a nasty hack at the best of times)
324   when the normal CFI/FP-chain scan fails.  If the number of
325   "normally" recovered frames is below this number, stack scanning
326   will be used (on platforms on which it is supported, currently only
327   arm-linux).  The default value of zero has the effect of disabling
328   stack scanning.  Default: zero*/
329extern UInt VG_(clo_unw_stack_scan_thresh);
330
331/* If stack scanning is used, this is how many frames it may recover.
332   Since it tends to pick up a lot of junk, this value is set pretty
333   low by default.  Default: 5 */
334extern UInt VG_(clo_unw_stack_scan_frames);
335
336#endif   // __PUB_CORE_OPTIONS_H
337
338/*--------------------------------------------------------------------*/
339/*--- end                                                          ---*/
340/*--------------------------------------------------------------------*/
341