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