• 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-2011 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 extern Bool  VG_(clo_trace_children);
90 /* String containing comma-separated patterns for executable names
91    that should not be traced into even when --trace-children=yes */
92 extern HChar* VG_(clo_trace_children_skip);
93 /* The same as VG_(clo_trace_children), except that these patterns are
94    tested against the arguments for child processes, rather than the
95    executable name. */
96 extern HChar* VG_(clo_trace_children_skip_by_arg);
97 /* After a fork, the child's output can become confusingly
98    intermingled with the parent's output.  This is especially
99    problematic when VG_(clo_xml) is True.  Setting
100    VG_(clo_child_silent_after_fork) causes children to fall silent
101    after fork() calls.  Although note they become un-silent again
102    after the subsequent exec(). */
103 extern Bool  VG_(clo_child_silent_after_fork);
104 
105 /* If the user specified --log-file=STR and/or --xml-file=STR, these
106    hold STR after expansion of the %p and %q templates. */
107 extern Char* VG_(clo_log_fname_expanded);
108 extern Char* VG_(clo_xml_fname_expanded);
109 
110 extern Char* VG_(clo_log_fname_unexpanded);
111 extern Char* VG_(clo_xml_fname_unexpanded);
112 
113 /* Add timestamps to log messages?  default: NO */
114 extern Bool  VG_(clo_time_stamp);
115 
116 /* The file descriptor to read for input.  default: 0 == stdin */
117 extern Int   VG_(clo_input_fd);
118 
119 /* The number of suppression files specified. */
120 extern Int   VG_(clo_n_suppressions);
121 /* The names of the suppression files. */
122 extern Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
123 
124 /* An array of strings harvested from --fullpath-after= flags. */
125 extern Int   VG_(clo_n_fullpath_after);
126 extern Char* VG_(clo_fullpath_after)[VG_CLO_MAX_FULLPATH_AFTER];
127 
128 /* DEBUG: print generated code?  default: 00000000 ( == NO ) */
129 extern UChar VG_(clo_trace_flags);
130 /* DEBUG: do bb profiling?  default: 00000000 ( == NO ) */
131 extern UChar VG_(clo_profile_flags);
132 /* DEBUG: if tracing codegen, be quiet until after this bb ( 0 ) */
133 extern Int   VG_(clo_trace_notbelow);
134 /* DEBUG: print system calls?  default: NO */
135 extern Bool  VG_(clo_trace_syscalls);
136 /* DEBUG: print signal details?  default: NO */
137 extern Bool  VG_(clo_trace_signals);
138 /* DEBUG: print symtab details?  default: NO */
139 extern Bool  VG_(clo_trace_symtab);
140 /* DEBUG: restrict symtab etc details to object name pattern.  Default: "*" */
141 extern HChar* VG_(clo_trace_symtab_patt);
142 /* DEBUG: print call-frame-info details?  default: NO */
143 extern Bool  VG_(clo_trace_cfi);
144 /* DEBUG:  mimic /usr/bin/readelf --syms?  default: NO */
145 extern Bool  VG_(clo_debug_dump_syms);
146 /* DEBUG: mimic /usr/bin/readelf --debug-dump=line?  default: NO */
147 extern Bool  VG_(clo_debug_dump_line);
148 /* DEBUG: mimic  /usr/bin/readelf --debug-dump=frames?  default: NO */
149 extern Bool  VG_(clo_debug_dump_frames);
150 /* DEBUG: print redirection details?  default: NO */
151 extern Bool  VG_(clo_trace_redir);
152 /* DEBUG: print thread scheduling events?  default: NO */
153 extern Bool  VG_(clo_trace_sched);
154 /* DEBUG: do heap profiling?  default: NO */
155 extern Bool  VG_(clo_profile_heap);
156 /* DEBUG: display gory details for the k'th most popular error.
157    default: Infinity. */
158 extern Int   VG_(clo_dump_error);
159 /* Engage miscellaneous weird hacks needed for some progs. */
160 extern Char* VG_(clo_sim_hints);
161 /* Show symbols in the form 'name+offset' ?  Default: NO */
162 extern Bool VG_(clo_sym_offsets);
163 /* Read DWARF3 variable info even if tool doesn't ask for it? */
164 extern Bool VG_(clo_read_var_info);
165 
166 /* Mountpoint for memfs */
167 extern Char* VG_(clo_memfs_malloc_path);
168 /* Size of memfs page in Kbytes */
169 extern Int   VG_(clo_memfs_page_size);
170 
171 
172 /* An array of strings harvested from --require-text-symbol=
173    flags.
174 
175    Each string specifies a pair: a soname pattern and a text symbol
176    name pattern, separated by a colon.  The patterns can be written
177    using the normal "?" and "*" wildcards.  For example:
178    ":*libc.so*:foo?bar".
179 
180    These flags take effect when reading debuginfo from objects.  If an
181    object is loaded and the object's soname matches the soname
182    component of one of the specified pairs, then Valgrind will examine
183    all the text symbol names in the object.  If none of them match the
184    symbol name component of that same specification, then the run is
185    aborted, with an error message.
186 
187    The purpose of this is to support reliable usage of marked-up
188    libraries.  For example, suppose we have a version of GCC's
189    libgomp.so which has been marked up with annotations to support
190    Helgrind.  It is only too easy and confusing to load the 'wrong'
191    libgomp.so into the application.  So the idea is: add a text symbol
192    in the marked-up library (eg), "annotated_for_helgrind_3_6", and
193    then give the flag
194 
195      --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
196 
197    so that when libgomp.so is loaded, we scan the symbol table, and if
198    the symbol isn't present the run is aborted, rather than continuing
199    silently with the un-marked-up library.  Note that you should put
200    the entire flag in quotes to stop shells messing up the * and ?
201    wildcards. */
202 extern Int    VG_(clo_n_req_tsyms);
203 extern HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
204 
205 /* Track open file descriptors? */
206 extern Bool  VG_(clo_track_fds);
207 
208 /* Should we run __libc_freeres at exit?  Sometimes causes crashes.
209    Default: YES.  Note this is subservient to VG_(needs).libc_freeres;
210    if the latter says False, then the setting of VG_(clo_run_libc_freeres)
211    is ignored.  Ie if a tool says no, I don't want this to run, that
212    cannot be overridden from the command line. */
213 extern Bool  VG_(clo_run_libc_freeres);
214 
215 /* Should we show VEX emulation warnings?  Default: NO */
216 extern Bool VG_(clo_show_emwarns);
217 
218 /* How much does the stack pointer have to change before tools
219    consider a stack switch to have happened?  Default: 2000000 bytes
220    NB: must be host-word-sized to be correct (hence Word). */
221 extern Word VG_(clo_max_stackframe);
222 /* How large should Valgrind allow the primary thread's guest stack to
223    be? */
224 extern Word VG_(clo_main_stacksize);
225 
226 /* Delay startup to allow GDB to be attached?  Default: NO */
227 extern Bool VG_(clo_wait_for_gdb);
228 
229 /* To what extent should self-checking translations be made?  These
230    are needed to deal with self-modifying code on uncooperative
231    platforms. */
232 typedef
233    enum {
234       Vg_SmcNone,  // never generate self-checking translations
235       Vg_SmcStack, // generate s-c-t's for code found in stacks
236                    // (this is the default)
237       Vg_SmcAll,   // make all translations self-checking.
238       Vg_SmcAllNonFile // make all translations derived from
239                    // non-file-backed memory self checking
240    }
241    VgSmc;
242 
243 /* Describe extent to which self-modifying-code should be
244    auto-detected. */
245 extern VgSmc VG_(clo_smc_check);
246 
247 /* String containing comma-separated names of minor kernel variants,
248    so they can be properly handled by m_syswrap. */
249 extern HChar* VG_(clo_kernel_variant);
250 
251 /* Darwin-specific: automatically run /usr/bin/dsymutil to update
252    .dSYM directories as necessary? */
253 extern Bool VG_(clo_dsymutil);
254 
255 /* NaCl nexe to read symbols from. Overrides the filename NaCl reports, if
256    any. */
257 extern Char* VG_(clo_nacl_file);
258 
259 /* Should we trace into this child executable (across execve etc) ?
260    This involves considering --trace-children=,
261    --trace-children-skip=, --trace-children-skip-by-arg=, and the name
262    of the executable.  'child_argv' must not include the name of the
263    executable itself; iow child_argv[0] must be the first arg, if any,
264    for the child. */
265 extern Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name,
266                                               HChar** child_argv );
267 
268 #endif   // __PUB_CORE_OPTIONS_H
269 
270 /*--------------------------------------------------------------------*/
271 /*--- end                                                          ---*/
272 /*--------------------------------------------------------------------*/
273