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