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