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