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-2010 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 /* Enquire about whether to attach to a debugger at errors? default: NO */ 58 extern Bool VG_(clo_db_attach); 59 /* The debugger command? default: whatever gdb ./configure found */ 60 extern Char* VG_(clo_db_command); 61 /* Generating a suppression for each error? default: 0 (NO) 62 Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */ 63 extern Int VG_(clo_gen_suppressions); 64 /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */ 65 extern Int VG_(clo_sanity_level); 66 /* Automatically attempt to demangle C++ names? default: YES */ 67 extern Bool VG_(clo_demangle); 68 /* Simulate child processes? default: NO */ 69 extern Bool VG_(clo_trace_children); 70 /* String containing comma-separated patterns for executable names 71 that should not be traced into even when --trace-children=yes */ 72 extern HChar* VG_(clo_trace_children_skip); 73 /* After a fork, the child's output can become confusingly 74 intermingled with the parent's output. This is especially 75 problematic when VG_(clo_xml) is True. Setting 76 VG_(clo_child_silent_after_fork) causes children to fall silent 77 after fork() calls. Although note they become un-silent again 78 after the subsequent exec(). */ 79 extern Bool VG_(clo_child_silent_after_fork); 80 81 /* If the user specified --log-file=STR and/or --xml-file=STR, these 82 hold STR after expansion of the %p and %q templates. */ 83 extern Char* VG_(clo_log_fname_expanded); 84 extern Char* VG_(clo_xml_fname_expanded); 85 86 extern Char* VG_(clo_log_fname_unexpanded); 87 extern Char* VG_(clo_xml_fname_unexpanded); 88 89 /* Add timestamps to log messages? default: NO */ 90 extern Bool VG_(clo_time_stamp); 91 92 /* The file descriptor to read for input. default: 0 == stdin */ 93 extern Int VG_(clo_input_fd); 94 95 /* The number of suppression files specified. */ 96 extern Int VG_(clo_n_suppressions); 97 /* The names of the suppression files. */ 98 extern Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES]; 99 100 /* An array of strings harvested from --fullpath-after= flags. */ 101 extern Int VG_(clo_n_fullpath_after); 102 extern Char* VG_(clo_fullpath_after)[VG_CLO_MAX_FULLPATH_AFTER]; 103 104 /* DEBUG: print generated code? default: 00000000 ( == NO ) */ 105 extern UChar VG_(clo_trace_flags); 106 /* DEBUG: do bb profiling? default: 00000000 ( == NO ) */ 107 extern UChar VG_(clo_profile_flags); 108 /* DEBUG: if tracing codegen, be quiet until after this bb ( 0 ) */ 109 extern Int VG_(clo_trace_notbelow); 110 /* DEBUG: print system calls? default: NO */ 111 extern Bool VG_(clo_trace_syscalls); 112 /* DEBUG: print signal details? default: NO */ 113 extern Bool VG_(clo_trace_signals); 114 /* DEBUG: print symtab details? default: NO */ 115 extern Bool VG_(clo_trace_symtab); 116 /* DEBUG: restrict symtab etc details to object name pattern. Default: "*" */ 117 extern HChar* VG_(clo_trace_symtab_patt); 118 /* DEBUG: print call-frame-info details? default: NO */ 119 extern Bool VG_(clo_trace_cfi); 120 /* DEBUG: mimic /usr/bin/readelf --syms? default: NO */ 121 extern Bool VG_(clo_debug_dump_syms); 122 /* DEBUG: mimic /usr/bin/readelf --debug-dump=line? default: NO */ 123 extern Bool VG_(clo_debug_dump_line); 124 /* DEBUG: mimic /usr/bin/readelf --debug-dump=frames? default: NO */ 125 extern Bool VG_(clo_debug_dump_frames); 126 /* DEBUG: print redirection details? default: NO */ 127 extern Bool VG_(clo_trace_redir); 128 /* DEBUG: print thread scheduling events? default: NO */ 129 extern Bool VG_(clo_trace_sched); 130 /* DEBUG: do heap profiling? default: NO */ 131 extern Bool VG_(clo_profile_heap); 132 /* DEBUG: display gory details for the k'th most popular error. 133 default: Infinity. */ 134 extern Int VG_(clo_dump_error); 135 /* Engage miscellaneous weird hacks needed for some progs. */ 136 extern Char* VG_(clo_sim_hints); 137 /* Show symbols in the form 'name+offset' ? Default: NO */ 138 extern Bool VG_(clo_sym_offsets); 139 /* Read DWARF3 variable info even if tool doesn't ask for it? */ 140 extern Bool VG_(clo_read_var_info); 141 142 /* Mountpoint for memfs */ 143 extern Char* VG_(clo_memfs_malloc_path); 144 /* Size of memfs page in Kbytes */ 145 extern Int VG_(clo_memfs_page_size); 146 147 148 /* An array of strings harvested from --require-text-symbol= 149 flags. 150 151 Each string specifies a pair: a soname pattern and a text symbol 152 name pattern, separated by a colon. The patterns can be written 153 using the normal "?" and "*" wildcards. For example: 154 ":*libc.so*:foo?bar". 155 156 These flags take effect when reading debuginfo from objects. If an 157 object is loaded and the object's soname matches the soname 158 component of one of the specified pairs, then Valgrind will examine 159 all the text symbol names in the object. If none of them match the 160 symbol name component of that same specification, then the run is 161 aborted, with an error message. 162 163 The purpose of this is to support reliable usage of marked-up 164 libraries. For example, suppose we have a version of GCC's 165 libgomp.so which has been marked up with annotations to support 166 Helgrind. It is only too easy and confusing to load the 'wrong' 167 libgomp.so into the application. So the idea is: add a text symbol 168 in the marked-up library (eg), "annotated_for_helgrind_3_6", and 169 then give the flag 170 171 --require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6 172 173 so that when libgomp.so is loaded, we scan the symbol table, and if 174 the symbol isn't present the run is aborted, rather than continuing 175 silently with the un-marked-up library. Note that you should put 176 the entire flag in quotes to stop shells messing up the * and ? 177 wildcards. */ 178 extern Int VG_(clo_n_req_tsyms); 179 extern HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS]; 180 181 /* Track open file descriptors? */ 182 extern Bool VG_(clo_track_fds); 183 184 /* Should we run __libc_freeres at exit? Sometimes causes crashes. 185 Default: YES. Note this is subservient to VG_(needs).libc_freeres; 186 if the latter says False, then the setting of VG_(clo_run_libc_freeres) 187 is ignored. Ie if a tool says no, I don't want this to run, that 188 cannot be overridden from the command line. */ 189 extern Bool VG_(clo_run_libc_freeres); 190 191 /* Should we show VEX emulation warnings? Default: NO */ 192 extern Bool VG_(clo_show_emwarns); 193 194 /* How much does the stack pointer have to change before tools 195 consider a stack switch to have happened? Default: 2000000 bytes 196 NB: must be host-word-sized to be correct (hence Word). */ 197 extern Word VG_(clo_max_stackframe); 198 /* How large should Valgrind allow the primary thread's guest stack to 199 be? */ 200 extern Word VG_(clo_main_stacksize); 201 202 /* Delay startup to allow GDB to be attached? Default: NO */ 203 extern Bool VG_(clo_wait_for_gdb); 204 205 /* To what extent should self-checking translations be made? These 206 are needed to deal with self-modifying code on uncooperative 207 platforms. */ 208 typedef 209 enum { 210 Vg_SmcNone, // never generate self-checking translations 211 Vg_SmcStack, // generate s-c-t's for code found in stacks 212 // (this is the default) 213 Vg_SmcAll // make all translations self-checking. 214 } 215 VgSmc; 216 217 /* Describe extent to which self-modifying-code should be 218 auto-detected. */ 219 extern VgSmc VG_(clo_smc_check); 220 221 /* String containing comma-separated names of minor kernel variants, 222 so they can be properly handled by m_syswrap. */ 223 extern HChar* VG_(clo_kernel_variant); 224 225 /* Darwin-specific: automatically run /usr/bin/dsymutil to update 226 .dSYM directories as necessary? */ 227 extern Bool VG_(clo_dsymutil); 228 229 /* Should we trace into this child executable (across execve etc) ? 230 This involves considering --trace-children=, --trace-children-skip= 231 and the name of the executable. */ 232 extern Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name ); 233 234 #endif // __PUB_CORE_OPTIONS_H 235 236 /*--------------------------------------------------------------------*/ 237 /*--- end ---*/ 238 /*--------------------------------------------------------------------*/ 239