• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-2012 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 */
52 extern 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. */
56 extern Int   VG_(clo_error_exitcode);
57 
58 typedef
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. */
68 extern VgVgdb VG_(clo_vgdb);
69 /* if > 0, checks every VG_(clo_vgdb_poll) BBS if vgdb wants to be served. */
70 extern Int VG_(clo_vgdb_poll);
71 /* prefix for the named pipes (FIFOs) used by vgdb/gdb to communicate with valgrind */
72 extern HChar* VG_(clo_vgdb_prefix);
73 /* if True, gdbserver in valgrind will expose a target description containing
74    shadow registers */
75 extern Bool  VG_(clo_vgdb_shadow_registers);
76 
77 /* Enquire about whether to attach to a debugger at errors?   default: NO */
78 extern Bool  VG_(clo_db_attach);
79 /* The debugger command?  default: whatever gdb ./configure found */
80 extern Char* VG_(clo_db_command);
81 /* Generating a suppression for each error?   default: 0 (NO)
82    Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */
83 extern Int   VG_(clo_gen_suppressions);
84 /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
85 extern Int   VG_(clo_sanity_level);
86 /* Automatically attempt to demangle C++ names?  default: YES */
87 extern Bool  VG_(clo_demangle);
88 /* Simulate child processes? default: NO */
89 /* Soname synonyms : a string containing a list of pairs
90    xxxxx=yyyyy separated by commas.
91    E.g. --soname-synonyms=somalloc=libtcmalloc*.so*,solibtruc=NONE */
92 extern HChar* VG_(clo_soname_synonyms);
93 extern Bool  VG_(clo_trace_children);
94 /* String containing comma-separated patterns for executable names
95    that should not be traced into even when --trace-children=yes */
96 extern HChar* VG_(clo_trace_children_skip);
97 /* The same as VG_(clo_trace_children), except that these patterns are
98    tested against the arguments for child processes, rather than the
99    executable name. */
100 extern HChar* VG_(clo_trace_children_skip_by_arg);
101 /* After a fork, the child's output can become confusingly
102    intermingled with the parent's output.  This is especially
103    problematic when VG_(clo_xml) is True.  Setting
104    VG_(clo_child_silent_after_fork) causes children to fall silent
105    after fork() calls.  Although note they become un-silent again
106    after the subsequent exec(). */
107 extern Bool  VG_(clo_child_silent_after_fork);
108 
109 /* If the user specified --log-file=STR and/or --xml-file=STR, these
110    hold STR after expansion of the %p and %q templates. */
111 extern Char* VG_(clo_log_fname_expanded);
112 extern Char* VG_(clo_xml_fname_expanded);
113 
114 /* Add timestamps to log messages?  default: NO */
115 extern Bool  VG_(clo_time_stamp);
116 
117 /* The file descriptor to read for input.  default: 0 == stdin */
118 extern Int   VG_(clo_input_fd);
119 
120 /* The number of suppression files specified. */
121 extern Int   VG_(clo_n_suppressions);
122 /* The names of the suppression files. */
123 extern Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
124 
125 /* An array of strings harvested from --fullpath-after= flags. */
126 extern Int   VG_(clo_n_fullpath_after);
127 extern Char* VG_(clo_fullpath_after)[VG_CLO_MAX_FULLPATH_AFTER];
128 
129 /* DEBUG: print generated code?  default: 00000000 ( == NO ) */
130 extern UChar VG_(clo_trace_flags);
131 /* DEBUG: do bb profiling?  default: 00000000 ( == NO ) */
132 extern UChar VG_(clo_profile_flags);
133 /* DEBUG: if tracing codegen, be quiet until after this bb */
134 extern Int   VG_(clo_trace_notbelow);
135 /* DEBUG: if tracing codegen, be quiet after this bb  */
136 extern Int   VG_(clo_trace_notabove);
137 /* DEBUG: print system calls?  default: NO */
138 extern Bool  VG_(clo_trace_syscalls);
139 /* DEBUG: print signal details?  default: NO */
140 extern Bool  VG_(clo_trace_signals);
141 /* DEBUG: print symtab details?  default: NO */
142 extern Bool  VG_(clo_trace_symtab);
143 /* DEBUG: restrict symtab etc details to object name pattern.  Default: "*" */
144 extern HChar* VG_(clo_trace_symtab_patt);
145 /* DEBUG: print call-frame-info details?  default: NO */
146 extern Bool  VG_(clo_trace_cfi);
147 /* DEBUG:  mimic /usr/bin/readelf --syms?  default: NO */
148 extern Bool  VG_(clo_debug_dump_syms);
149 /* DEBUG: mimic /usr/bin/readelf --debug-dump=line?  default: NO */
150 extern Bool  VG_(clo_debug_dump_line);
151 /* DEBUG: mimic  /usr/bin/readelf --debug-dump=frames?  default: NO */
152 extern Bool  VG_(clo_debug_dump_frames);
153 /* DEBUG: print redirection details?  default: NO */
154 extern Bool  VG_(clo_trace_redir);
155 /* Enable fair scheduling on multicore systems? default: NO */
156 enum FairSchedType { disable_fair_sched, enable_fair_sched, try_fair_sched };
157 extern enum FairSchedType VG_(clo_fair_sched);
158 /* DEBUG: print thread scheduling events?  default: NO */
159 extern Bool  VG_(clo_trace_sched);
160 /* DEBUG: do heap profiling?  default: NO */
161 extern Bool  VG_(clo_profile_heap);
162 #define MAX_REDZONE_SZB 128
163 // Maximum for the default values for core arenas and for client
164 // arena given by the tool.
165 // 128 is no special figure, just something not too big
166 #define MAX_CLO_REDZONE_SZB 4096
167 // We allow the user to increase the redzone size to 4Kb :
168 // This allows "off by one" in an array of pages to be detected.
169 #define CORE_REDZONE_DEFAULT_SZB 4
170 extern Int VG_(clo_core_redzone_size);
171 // VG_(clo_redzone_size) has default value -1, indicating to keep
172 // the tool provided value.
173 extern Int VG_(clo_redzone_size);
174 /* DEBUG: display gory details for the k'th most popular error.
175    default: Infinity. */
176 extern Int   VG_(clo_dump_error);
177 /* Engage miscellaneous weird hacks needed for some progs. */
178 extern Char* VG_(clo_sim_hints);
179 /* Show symbols in the form 'name+offset' ?  Default: NO */
180 extern Bool VG_(clo_sym_offsets);
181 /* Read DWARF3 variable info even if tool doesn't ask for it? */
182 extern Bool VG_(clo_read_var_info);
183 /* Which prefix to strip from full source file paths, if any. */
184 extern Char* VG_(clo_prefix_to_strip);
185 
186 /* An array of strings harvested from --require-text-symbol=
187    flags.
188 
189    Each string specifies a pair: a soname pattern and a text symbol
190    name pattern, separated by a colon.  The patterns can be written
191    using the normal "?" and "*" wildcards.  For example:
192    ":*libc.so*:foo?bar".
193 
194    These flags take effect when reading debuginfo from objects.  If an
195    object is loaded and the object's soname matches the soname
196    component of one of the specified pairs, then Valgrind will examine
197    all the text symbol names in the object.  If none of them match the
198    symbol name component of that same specification, then the run is
199    aborted, with an error message.
200 
201    The purpose of this is to support reliable usage of marked-up
202    libraries.  For example, suppose we have a version of GCC's
203    libgomp.so which has been marked up with annotations to support
204    Helgrind.  It is only too easy and confusing to load the 'wrong'
205    libgomp.so into the application.  So the idea is: add a text symbol
206    in the marked-up library (eg), "annotated_for_helgrind_3_6", and
207    then give the flag
208 
209      --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
210 
211    so that when libgomp.so is loaded, we scan the symbol table, and if
212    the symbol isn't present the run is aborted, rather than continuing
213    silently with the un-marked-up library.  Note that you should put
214    the entire flag in quotes to stop shells messing up the * and ?
215    wildcards. */
216 extern Int    VG_(clo_n_req_tsyms);
217 extern HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
218 
219 /* Track open file descriptors? */
220 extern Bool  VG_(clo_track_fds);
221 
222 /* Should we run __libc_freeres at exit?  Sometimes causes crashes.
223    Default: YES.  Note this is subservient to VG_(needs).libc_freeres;
224    if the latter says False, then the setting of VG_(clo_run_libc_freeres)
225    is ignored.  Ie if a tool says no, I don't want this to run, that
226    cannot be overridden from the command line. */
227 extern Bool  VG_(clo_run_libc_freeres);
228 
229 /* Should we show VEX emulation warnings?  Default: NO */
230 extern Bool VG_(clo_show_emwarns);
231 
232 /* How much does the stack pointer have to change before tools
233    consider a stack switch to have happened?  Default: 2000000 bytes
234    NB: must be host-word-sized to be correct (hence Word). */
235 extern Word VG_(clo_max_stackframe);
236 /* How large should Valgrind allow the primary thread's guest stack to
237    be? */
238 extern Word VG_(clo_main_stacksize);
239 
240 /* Delay startup to allow GDB to be attached?  Default: NO */
241 extern Bool VG_(clo_wait_for_gdb);
242 
243 /* To what extent should self-checking translations be made?  These
244    are needed to deal with self-modifying code on uncooperative
245    platforms. */
246 typedef
247    enum {
248       Vg_SmcNone,  // never generate self-checking translations
249       Vg_SmcStack, // generate s-c-t's for code found in stacks
250                    // (this is the default)
251       Vg_SmcAll,   // make all translations self-checking.
252       Vg_SmcAllNonFile // make all translations derived from
253                    // non-file-backed memory self checking
254    }
255    VgSmc;
256 
257 /* Describe extent to which self-modifying-code should be
258    auto-detected. */
259 extern VgSmc VG_(clo_smc_check);
260 
261 /* String containing comma-separated names of minor kernel variants,
262    so they can be properly handled by m_syswrap. */
263 extern HChar* VG_(clo_kernel_variant);
264 
265 /* Darwin-specific: automatically run /usr/bin/dsymutil to update
266    .dSYM directories as necessary? */
267 extern Bool VG_(clo_dsymutil);
268 
269 /* Should we trace into this child executable (across execve etc) ?
270    This involves considering --trace-children=,
271    --trace-children-skip=, --trace-children-skip-by-arg=, and the name
272    of the executable.  'child_argv' must not include the name of the
273    executable itself; iow child_argv[0] must be the first arg, if any,
274    for the child. */
275 extern Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name,
276                                               HChar** child_argv );
277 
278 #endif   // __PUB_CORE_OPTIONS_H
279 
280 /*--------------------------------------------------------------------*/
281 /*--- end                                                          ---*/
282 /*--------------------------------------------------------------------*/
283