2 /*--------------------------------------------------------------------*/
3 /*--- Command line options. pub_core_options.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2010 Julian Seward
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
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 //--------------------------------------------------------------------
40 #include "pub_tool_options.h"
42 /* The max number of suppression files. */
43 #define VG_CLO_MAX_SFILES 100
45 /* The max number of --require-text-symbol= specification strings. */
46 #define VG_CLO_MAX_REQ_TSYMS 100
48 /* Should we stop collecting errors if too many appear? default: YES */
49 extern Bool VG_(clo_error_limit);
50 /* Alternative exit code to hand to parent if errors were found.
51 default: 0 (no, return the application's exit code in the normal
53 extern Int VG_(clo_error_exitcode);
54 /* Enquire about whether to attach to a debugger at errors? default: NO */
55 extern Bool VG_(clo_db_attach);
56 /* The debugger command? default: whatever gdb ./configure found */
57 extern Char* VG_(clo_db_command);
58 /* Generating a suppression for each error? default: 0 (NO)
59 Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */
60 extern Int VG_(clo_gen_suppressions);
61 /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
62 extern Int VG_(clo_sanity_level);
63 /* Automatically attempt to demangle C++ names? default: YES */
64 extern Bool VG_(clo_demangle);
65 /* Simulate child processes? default: NO */
66 extern Bool VG_(clo_trace_children);
67 /* String containing comma-separated patterns for executable names
68 that should not be traced into even when --trace-children=yes */
69 extern HChar* VG_(clo_trace_children_skip);
70 /* After a fork, the child's output can become confusingly
71 intermingled with the parent's output. This is especially
72 problematic when VG_(clo_xml) is True. Setting
73 VG_(clo_child_silent_after_fork) causes children to fall silent
74 after fork() calls. Although note they become un-silent again
75 after the subsequent exec(). */
76 extern Bool VG_(clo_child_silent_after_fork);
78 /* If the user specified --log-file=STR and/or --xml-file=STR, these
79 hold STR after expansion of the %p and %q templates. */
80 extern Char* VG_(clo_log_fname_expanded);
81 extern Char* VG_(clo_xml_fname_expanded);
83 /* Add timestamps to log messages? default: NO */
84 extern Bool VG_(clo_time_stamp);
86 /* The file descriptor to read for input. default: 0 == stdin */
87 extern Int VG_(clo_input_fd);
89 /* The number of suppression files specified. */
90 extern Int VG_(clo_n_suppressions);
91 /* The names of the suppression files. */
92 extern Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
94 /* DEBUG: print generated code? default: 00000000 ( == NO ) */
95 extern UChar VG_(clo_trace_flags);
96 /* DEBUG: do bb profiling? default: 00000000 ( == NO ) */
97 extern UChar VG_(clo_profile_flags);
98 /* DEBUG: if tracing codegen, be quiet until after this bb ( 0 ) */
99 extern Int VG_(clo_trace_notbelow);
100 /* DEBUG: print system calls? default: NO */
101 extern Bool VG_(clo_trace_syscalls);
102 /* DEBUG: print signal details? default: NO */
103 extern Bool VG_(clo_trace_signals);
104 /* DEBUG: print symtab details? default: NO */
105 extern Bool VG_(clo_trace_symtab);
106 /* DEBUG: restrict symtab etc details to object name pattern. Default: "*" */
107 extern HChar* VG_(clo_trace_symtab_patt);
108 /* DEBUG: print call-frame-info details? default: NO */
109 extern Bool VG_(clo_trace_cfi);
110 /* DEBUG: mimic /usr/bin/readelf --syms? default: NO */
111 extern Bool VG_(clo_debug_dump_syms);
112 /* DEBUG: mimic /usr/bin/readelf --debug-dump=line? default: NO */
113 extern Bool VG_(clo_debug_dump_line);
114 /* DEBUG: mimic /usr/bin/readelf --debug-dump=frames? default: NO */
115 extern Bool VG_(clo_debug_dump_frames);
116 /* DEBUG: print redirection details? default: NO */
117 extern Bool VG_(clo_trace_redir);
118 /* DEBUG: print thread scheduling events? default: NO */
119 extern Bool VG_(clo_trace_sched);
120 /* DEBUG: do heap profiling? default: NO */
121 extern Bool VG_(clo_profile_heap);
122 /* DEBUG: display gory details for the k'th most popular error.
123 default: Infinity. */
124 extern Int VG_(clo_dump_error);
125 /* Engage miscellaneous weird hacks needed for some progs. */
126 extern Char* VG_(clo_sim_hints);
127 /* Show symbols in the form 'name+offset' ? Default: NO */
128 extern Bool VG_(clo_sym_offsets);
129 /* Read DWARF3 variable info even if tool doesn't ask for it? */
130 extern Bool VG_(clo_read_var_info);
132 /* An array of strings harvested from --require-text-symbol=
135 Each string specifies a pair: a soname pattern and a text symbol
136 name pattern, separated by a colon. The patterns can be written
137 using the normal "?" and "*" wildcards. For example:
138 ":*libc.so*:foo?bar".
140 These flags take effect when reading debuginfo from objects. If an
141 object is loaded and the object's soname matches the soname
142 component of one of the specified pairs, then Valgrind will examine
143 all the text symbol names in the object. If none of them match the
144 symbol name component of that same specification, then the run is
145 aborted, with an error message.
147 The purpose of this is to support reliable usage of marked-up
148 libraries. For example, suppose we have a version of GCC's
149 libgomp.so which has been marked up with annotations to support
150 Helgrind. It is only too easy and confusing to load the 'wrong'
151 libgomp.so into the application. So the idea is: add a text symbol
152 in the marked-up library (eg), "annotated_for_helgrind_3_6", and
155 --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
157 so that when libgomp.so is loaded, we scan the symbol table, and if
158 the symbol isn't present the run is aborted, rather than continuing
159 silently with the un-marked-up library. Note that you should put
160 the entire flag in quotes to stop shells messing up the * and ?
162 extern Int VG_(clo_n_req_tsyms);
163 extern HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
165 /* Track open file descriptors? */
166 extern Bool VG_(clo_track_fds);
168 /* Should we run __libc_freeres at exit? Sometimes causes crashes.
169 Default: YES. Note this is subservient to VG_(needs).libc_freeres;
170 if the latter says False, then the setting of VG_(clo_run_libc_freeres)
171 is ignored. Ie if a tool says no, I don't want this to run, that
172 cannot be overridden from the command line. */
173 extern Bool VG_(clo_run_libc_freeres);
175 /* Should we show VEX emulation warnings? Default: NO */
176 extern Bool VG_(clo_show_emwarns);
178 /* How much does the stack pointer have to change before tools
179 consider a stack switch to have happened? Default: 2000000 bytes
180 NB: must be host-word-sized to be correct (hence Word). */
181 extern Word VG_(clo_max_stackframe);
182 /* How large should Valgrind allow the primary thread's guest stack to
184 extern Word VG_(clo_main_stacksize);
186 /* Delay startup to allow GDB to be attached? Default: NO */
187 extern Bool VG_(clo_wait_for_gdb);
189 /* To what extent should self-checking translations be made? These
190 are needed to deal with self-modifying code on uncooperative
194 Vg_SmcNone, // never generate self-checking translations
195 Vg_SmcStack, // generate s-c-t's for code found in stacks
196 // (this is the default)
197 Vg_SmcAll // make all translations self-checking.
201 /* Describe extent to which self-modifying-code should be
203 extern VgSmc VG_(clo_smc_check);
205 /* String containing comma-separated names of minor kernel variants,
206 so they can be properly handled by m_syswrap. */
207 extern HChar* VG_(clo_kernel_variant);
209 /* Darwin-specific: automatically run /usr/bin/dsymutil to update
210 .dSYM directories as necessary? */
211 extern Bool VG_(clo_dsymutil);
213 /* Should we trace into this child executable (across execve etc) ?
214 This involves considering --trace-children=, --trace-children-skip=
215 and the name of the executable. */
216 extern Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name );
218 #endif // __PUB_CORE_OPTIONS_H
220 /*--------------------------------------------------------------------*/
222 /*--------------------------------------------------------------------*/