njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 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 | |
sewardj | 4d474d0 | 2008-02-11 11:34:59 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2008 Julian Seward |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 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 | |
| 40 | #include "pub_tool_options.h" |
| 41 | |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 42 | /* The max number of suppression files. */ |
bart | b000d78 | 2008-05-13 17:45:28 +0000 | [diff] [blame] | 43 | #define VG_CLO_MAX_SFILES 100 |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 44 | |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 45 | /* Should we stop collecting errors if too many appear? default: YES */ |
| 46 | extern Bool VG_(clo_error_limit); |
sewardj | b977908 | 2006-05-12 23:50:15 +0000 | [diff] [blame] | 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); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 51 | /* Enquire about whether to attach to a debugger at errors? default: NO */ |
| 52 | extern Bool VG_(clo_db_attach); |
| 53 | /* The debugger command? default: whatever gdb ./configure found */ |
| 54 | extern Char* VG_(clo_db_command); |
| 55 | /* Generating a suppression for each error? default: 0 (NO) |
| 56 | Other values: 1 (yes, but ask user), 2 (yes, don't ask user) */ |
sewardj | b977908 | 2006-05-12 23:50:15 +0000 | [diff] [blame] | 57 | extern Int VG_(clo_gen_suppressions); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 58 | /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */ |
| 59 | extern Int VG_(clo_sanity_level); |
| 60 | /* Automatically attempt to demangle C++ names? default: YES */ |
| 61 | extern Bool VG_(clo_demangle); |
| 62 | /* Simulate child processes? default: NO */ |
| 63 | extern Bool VG_(clo_trace_children); |
sewardj | 6e31f80 | 2007-11-17 22:29:25 +0000 | [diff] [blame] | 64 | /* After a fork, the child's output can become confusingly |
| 65 | intermingled with the parent's output. This is especially |
| 66 | problematic when VG_(clo_xml) is True. Setting |
| 67 | VG_(clo_child_silent_after_fork) causes children to fall silent |
| 68 | after fork() calls. */ |
| 69 | extern Bool VG_(clo_child_silent_after_fork); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 70 | |
| 71 | /* Where logging output is to be sent to. |
| 72 | |
| 73 | With --log-fd (and by default), clo_log_fd holds the file id, and is |
| 74 | taken from the command line. (fd 2, stderr, is the default.) |
| 75 | clo_log_name is irrelevant. |
| 76 | |
njn | 374a36d | 2007-11-23 01:41:32 +0000 | [diff] [blame] | 77 | With --log-file, clo_log_name holds the log-file name, and is taken from |
| 78 | the command line (and possibly has process ID/env var contents in it, if |
| 79 | the %p or %q format specifiers are used). clo_log_fd is then made to |
| 80 | hold the relevant file id, by opening clo_log_name (concatenated with the |
| 81 | process ID) for writing. |
sewardj | ad31116 | 2005-07-19 11:25:02 +0000 | [diff] [blame] | 82 | |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 83 | With --log-socket, clo_log_name holds the hostname:portnumber pair, |
| 84 | and is taken from the command line. clo_log_fd is then made to hold |
| 85 | the relevant file handle, by opening a connection to that |
| 86 | hostname:portnumber pair. |
| 87 | |
| 88 | Global default is to set log_to == VgLogTo_Fd and log_fd == 2 |
| 89 | (stderr). */ |
sewardj | ad31116 | 2005-07-19 11:25:02 +0000 | [diff] [blame] | 90 | extern Int VG_(clo_log_fd); |
| 91 | extern Char* VG_(clo_log_name); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 92 | |
| 93 | /* Add timestamps to log messages? default: NO */ |
| 94 | extern Bool VG_(clo_time_stamp); |
| 95 | |
| 96 | /* The file descriptor to read for input. default: 0 == stdin */ |
| 97 | extern Int VG_(clo_input_fd); |
| 98 | /* The number of suppression files specified. */ |
| 99 | extern Int VG_(clo_n_suppressions); |
| 100 | /* The names of the suppression files. */ |
| 101 | extern Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES]; |
| 102 | |
| 103 | /* DEBUG: print generated code? default: 00000000 ( == NO ) */ |
sewardj | b224a48 | 2007-02-09 17:45:09 +0000 | [diff] [blame] | 104 | extern UChar VG_(clo_trace_flags); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 105 | /* DEBUG: do bb profiling? default: 00000000 ( == NO ) */ |
sewardj | b224a48 | 2007-02-09 17:45:09 +0000 | [diff] [blame] | 106 | extern UChar VG_(clo_profile_flags); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 107 | /* DEBUG: if tracing codegen, be quiet until after this bb ( 0 ) */ |
| 108 | extern Int VG_(clo_trace_notbelow); |
| 109 | /* DEBUG: print system calls? default: NO */ |
| 110 | extern Bool VG_(clo_trace_syscalls); |
| 111 | /* DEBUG: print signal details? default: NO */ |
| 112 | extern Bool VG_(clo_trace_signals); |
| 113 | /* DEBUG: print symtab details? default: NO */ |
| 114 | extern Bool VG_(clo_trace_symtab); |
sewardj | f767d96 | 2007-02-12 17:47:14 +0000 | [diff] [blame] | 115 | /* DEBUG: restrict symtab etc details to object name pattern. Default: "*" */ |
| 116 | extern HChar* VG_(clo_trace_symtab_patt); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 117 | /* DEBUG: print call-frame-info details? default: NO */ |
| 118 | extern Bool VG_(clo_trace_cfi); |
sewardj | f767d96 | 2007-02-12 17:47:14 +0000 | [diff] [blame] | 119 | /* DEBUG: mimic /usr/bin/readelf --syms? default: NO */ |
| 120 | extern Bool VG_(clo_debug_dump_syms); |
| 121 | /* DEBUG: mimic /usr/bin/readelf --debug-dump=line? default: NO */ |
| 122 | extern Bool VG_(clo_debug_dump_line); |
| 123 | /* DEBUG: mimic /usr/bin/readelf --debug-dump=frames? default: NO */ |
| 124 | extern Bool VG_(clo_debug_dump_frames); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 125 | /* DEBUG: print redirection details? default: NO */ |
| 126 | extern Bool VG_(clo_trace_redir); |
| 127 | /* DEBUG: print thread scheduling events? default: NO */ |
| 128 | extern Bool VG_(clo_trace_sched); |
sewardj | 9c606bd | 2008-09-18 18:12:50 +0000 | [diff] [blame] | 129 | /* DEBUG: do heap profiling? default: NO */ |
| 130 | extern Bool VG_(clo_profile_heap); |
| 131 | /* DEBUG: display gory details for the k'th most popular error. |
| 132 | default: Infinity. */ |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 133 | extern Int VG_(clo_dump_error); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 134 | /* Engage miscellaneous weird hacks needed for some progs. */ |
njn | 628add6 | 2005-11-12 18:21:40 +0000 | [diff] [blame] | 135 | extern Char* VG_(clo_sim_hints); |
sewardj | 41ded2c | 2006-10-17 01:34:57 +0000 | [diff] [blame] | 136 | /* Show symbols in the form 'name+offset' ? Default: NO */ |
| 137 | extern Bool VG_(clo_sym_offsets); |
sewardj | b8b79ad | 2008-03-03 01:35:41 +0000 | [diff] [blame] | 138 | /* Read DWARF3 variable info even if tool doesn't ask for it? */ |
| 139 | extern Bool VG_(clo_read_var_info); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 140 | |
| 141 | /* Track open file descriptors? */ |
| 142 | extern Bool VG_(clo_track_fds); |
| 143 | |
| 144 | /* Should we run __libc_freeres at exit? Sometimes causes crashes. |
| 145 | Default: YES. Note this is subservient to VG_(needs).libc_freeres; |
sewardj | 19617ae | 2005-10-20 01:09:57 +0000 | [diff] [blame] | 146 | if the latter says False, then the setting of VG_(clo_run_libc_freeres) |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 147 | is ignored. Ie if a tool says no, I don't want this to run, that |
| 148 | cannot be overridden from the command line. */ |
| 149 | extern Bool VG_(clo_run_libc_freeres); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 150 | /* Continue stack traces below main()? Default: NO */ |
| 151 | extern Bool VG_(clo_show_below_main); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 152 | |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 153 | /* Should we show VEX emulation warnings? Default: NO */ |
| 154 | extern Bool VG_(clo_show_emwarns); |
| 155 | |
| 156 | /* How much does the stack pointer have to change before tools |
sewardj | 91b470c | 2007-08-28 17:03:01 +0000 | [diff] [blame] | 157 | consider a stack switch to have happened? Default: 2000000 bytes |
| 158 | NB: must be host-word-sized to be correct (hence Word). */ |
| 159 | extern Word VG_(clo_max_stackframe); |
sewardj | 95d86c0 | 2007-12-18 01:49:23 +0000 | [diff] [blame] | 160 | /* How large should Valgrind allow the primary thread's guest stack to |
| 161 | be? */ |
| 162 | extern Word VG_(clo_main_stacksize); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 163 | |
| 164 | /* Delay startup to allow GDB to be attached? Default: NO */ |
| 165 | extern Bool VG_(clo_wait_for_gdb); |
| 166 | |
sewardj | 26412bd | 2005-07-07 10:05:05 +0000 | [diff] [blame] | 167 | /* To what extent should self-checking translations be made? These |
| 168 | are needed to deal with self-modifying code on uncooperative |
| 169 | platforms. */ |
| 170 | typedef |
| 171 | enum { |
| 172 | Vg_SmcNone, // never generate self-checking translations |
| 173 | Vg_SmcStack, // generate s-c-t's for code found in stacks |
sewardj | 26412bd | 2005-07-07 10:05:05 +0000 | [diff] [blame] | 174 | // (this is the default) |
| 175 | Vg_SmcAll // make all translations self-checking. |
| 176 | } |
| 177 | VgSmc; |
| 178 | |
sewardj | ce5a566 | 2005-10-06 03:19:49 +0000 | [diff] [blame] | 179 | /* Describe extent to which self-modifying-code should be |
| 180 | auto-detected. */ |
sewardj | 6c3a219 | 2005-07-24 07:00:45 +0000 | [diff] [blame] | 181 | extern VgSmc VG_(clo_smc_check); |
sewardj | 26412bd | 2005-07-07 10:05:05 +0000 | [diff] [blame] | 182 | |
sewardj | ce5a566 | 2005-10-06 03:19:49 +0000 | [diff] [blame] | 183 | /* String containing comma-separated names of minor kernel variants, |
| 184 | so they can be properly handled by m_syswrap. */ |
| 185 | extern HChar* VG_(clo_kernel_variant); |
sewardj | 26412bd | 2005-07-07 10:05:05 +0000 | [diff] [blame] | 186 | |
sewardj | 63d1c00 | 2006-10-19 17:31:37 +0000 | [diff] [blame] | 187 | /* --------- Functions --------- */ |
| 188 | |
| 189 | /* Call this if the executable is missing. This function prints an |
| 190 | error message, then shuts down the entire system. */ |
njn | 3ed1971 | 2007-11-22 23:01:59 +0000 | [diff] [blame] | 191 | __attribute__((noreturn)) |
sewardj | 63d1c00 | 2006-10-19 17:31:37 +0000 | [diff] [blame] | 192 | extern void VG_(err_missing_prog) ( void ); |
| 193 | |
| 194 | /* Similarly - complain and stop if there is some kind of config |
| 195 | error. */ |
njn | 3ed1971 | 2007-11-22 23:01:59 +0000 | [diff] [blame] | 196 | __attribute__((noreturn)) |
sewardj | 63d1c00 | 2006-10-19 17:31:37 +0000 | [diff] [blame] | 197 | extern void VG_(err_config_error) ( Char* msg ); |
| 198 | |
| 199 | |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 200 | #endif // __PUB_CORE_OPTIONS_H |
| 201 | |
| 202 | /*--------------------------------------------------------------------*/ |
| 203 | /*--- end ---*/ |
| 204 | /*--------------------------------------------------------------------*/ |