sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Command line options. ---*/ |
| 4 | /*--- m_options.c ---*/ |
| 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
| 8 | This file is part of Valgrind, a dynamic binary instrumentation |
| 9 | framework. |
| 10 | |
sewardj | e4b0bf0 | 2006-06-05 23:21:15 +0000 | [diff] [blame] | 11 | Copyright (C) 2000-2006 Nicholas Nethercote |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 12 | njn@valgrind.org |
| 13 | |
| 14 | This program is free software; you can redistribute it and/or |
| 15 | modify it under the terms of the GNU General Public License as |
| 16 | published by the Free Software Foundation; either version 2 of the |
| 17 | License, or (at your option) any later version. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, but |
| 20 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | General Public License for more details. |
| 23 | |
| 24 | You should have received a copy of the GNU General Public License |
| 25 | along with this program; if not, write to the Free Software |
| 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 27 | 02111-1307, USA. |
| 28 | |
| 29 | The GNU General Public License is contained in the file COPYING. |
| 30 | */ |
| 31 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 32 | #include "pub_core_basics.h" |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 33 | #include "pub_core_options.h" |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame^] | 34 | #include "pub_core_libcassert.h" |
| 35 | #include "pub_core_libcprint.h" |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 36 | |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 37 | // See pub_{core,tool}_options.h for explanations of all these. |
| 38 | |
| 39 | |
| 40 | /* Define, and set defaults. */ |
| 41 | VexControl VG_(clo_vex_control); |
| 42 | Bool VG_(clo_error_limit) = True; |
sewardj | b977908 | 2006-05-12 23:50:15 +0000 | [diff] [blame] | 43 | Int VG_(clo_error_exitcode) = 0; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 44 | Bool VG_(clo_db_attach) = False; |
| 45 | Char* VG_(clo_db_command) = GDB_PATH " -nw %f %p"; |
| 46 | Int VG_(clo_gen_suppressions) = 0; |
| 47 | Int VG_(clo_sanity_level) = 1; |
| 48 | Int VG_(clo_verbosity) = 1; |
sewardj | 71bc3cb | 2005-05-19 00:25:45 +0000 | [diff] [blame] | 49 | Bool VG_(clo_xml) = False; |
sewardj | 768db0e | 2005-07-19 14:18:56 +0000 | [diff] [blame] | 50 | HChar* VG_(clo_xml_user_comment) = NULL; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 51 | Bool VG_(clo_demangle) = True; |
| 52 | Bool VG_(clo_trace_children) = False; |
| 53 | Int VG_(clo_log_fd) = 2; |
| 54 | Char* VG_(clo_log_name) = NULL; |
sewardj | ad31116 | 2005-07-19 11:25:02 +0000 | [diff] [blame] | 55 | Char* VG_(clo_log_file_qualifier) = NULL; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 56 | Bool VG_(clo_time_stamp) = False; |
| 57 | Int VG_(clo_input_fd) = 0; /* stdin */ |
| 58 | Int VG_(clo_n_suppressions) = 0; |
| 59 | Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES]; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 60 | UChar VG_(clo_trace_flags) = 0; // 00000000b |
| 61 | UChar VG_(clo_profile_flags) = 0; // 00000000b |
sewardj | 33afdb5 | 2006-01-17 02:36:40 +0000 | [diff] [blame] | 62 | Int VG_(clo_trace_notbelow) = 999999999; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 63 | Bool VG_(clo_trace_syscalls) = False; |
| 64 | Bool VG_(clo_trace_signals) = False; |
| 65 | Bool VG_(clo_trace_symtab) = False; |
| 66 | Bool VG_(clo_trace_cfi) = False; |
| 67 | Bool VG_(clo_trace_redir) = False; |
| 68 | Bool VG_(clo_trace_sched) = False; |
| 69 | Bool VG_(clo_trace_pthreads) = False; |
| 70 | Int VG_(clo_dump_error) = 0; |
| 71 | Int VG_(clo_backtrace_size) = 12; |
njn | 628add6 | 2005-11-12 18:21:40 +0000 | [diff] [blame] | 72 | Char* VG_(clo_sim_hints) = NULL; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 73 | Bool VG_(clo_run_libc_freeres) = True; |
| 74 | Bool VG_(clo_track_fds) = False; |
| 75 | Bool VG_(clo_show_below_main)= False; |
njn | a3506d3 | 2005-05-18 04:36:01 +0000 | [diff] [blame] | 76 | Bool VG_(clo_model_pthreads) = False; |
| 77 | Bool VG_(clo_show_emwarns) = False; |
| 78 | Int VG_(clo_max_stackframe) = 2000000; |
| 79 | Bool VG_(clo_wait_for_gdb) = False; |
sewardj | 6c3a219 | 2005-07-24 07:00:45 +0000 | [diff] [blame] | 80 | VgSmc VG_(clo_smc_check) = Vg_SmcStack; |
sewardj | ce5a566 | 2005-10-06 03:19:49 +0000 | [diff] [blame] | 81 | HChar* VG_(clo_kernel_variant) = NULL; |
sewardj | 26412bd | 2005-07-07 10:05:05 +0000 | [diff] [blame] | 82 | |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 83 | |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame^] | 84 | /*====================================================================*/ |
| 85 | /*=== Command line errors ===*/ |
| 86 | /*====================================================================*/ |
| 87 | |
| 88 | static void revert_to_stderr ( void ) |
| 89 | { |
| 90 | vg_assert( !VG_(logging_to_socket) ); |
| 91 | VG_(clo_log_fd) = 2; /* stderr */ |
| 92 | } |
| 93 | |
| 94 | void VG_(err_bad_option) ( Char* opt ) |
| 95 | { |
| 96 | revert_to_stderr(); |
| 97 | VG_(printf)("valgrind: Bad option '%s'; aborting.\n", opt); |
| 98 | VG_(printf)("valgrind: Use --help for more information.\n"); |
| 99 | VG_(exit)(1); |
| 100 | } |
| 101 | |
| 102 | void VG_(err_missing_prog) ( void ) |
| 103 | { |
| 104 | revert_to_stderr(); |
| 105 | VG_(printf)("valgrind: no program specified\n"); |
| 106 | VG_(printf)("valgrind: Use --help for more information.\n"); |
| 107 | VG_(exit)(1); |
| 108 | } |
| 109 | |
| 110 | void VG_(err_config_error) ( Char* msg ) |
| 111 | { |
| 112 | revert_to_stderr(); |
| 113 | VG_(printf)("valgrind: Startup or configuration error:\n %s\n", msg); |
| 114 | VG_(printf)("valgrind: Unable to start up properly. Giving up.\n"); |
| 115 | VG_(exit)(1); |
| 116 | } |
| 117 | |
| 118 | |
sewardj | 3282402 | 2005-05-17 13:45:04 +0000 | [diff] [blame] | 119 | /*--------------------------------------------------------------------*/ |
| 120 | /*--- end m_options.c ---*/ |
| 121 | /*--------------------------------------------------------------------*/ |