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