m_options.c revision 3ed1971497f0d58f894ed6a61c30ea3a79b69a25
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 11 Copyright (C) 2000-2007 Nicholas Nethercote 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 32#include "pub_core_basics.h" 33#include "pub_core_options.h" 34#include "pub_core_libcassert.h" 35#include "pub_core_libcprint.h" 36 37// See pub_{core,tool}_options.h for explanations of all these. 38 39 40/* Define, and set defaults. */ 41VexControl VG_(clo_vex_control); 42Bool VG_(clo_error_limit) = True; 43Int VG_(clo_error_exitcode) = 0; 44Bool VG_(clo_db_attach) = False; 45Char* VG_(clo_db_command) = GDB_PATH " -nw %f %p"; 46Int VG_(clo_gen_suppressions) = 0; 47Int VG_(clo_sanity_level) = 1; 48Int VG_(clo_verbosity) = 1; 49Bool VG_(clo_xml) = False; 50HChar* VG_(clo_xml_user_comment) = NULL; 51Bool VG_(clo_demangle) = True; 52Bool VG_(clo_trace_children) = False; 53Bool VG_(clo_child_silent_after_fork) = False; 54Int VG_(clo_log_fd) = 2; /* must be signed, as -1 is possible. */ 55Char* VG_(clo_log_name) = NULL; 56Char* VG_(clo_log_file_qualifier) = NULL; 57Bool VG_(clo_time_stamp) = False; 58Int VG_(clo_input_fd) = 0; /* stdin */ 59Int VG_(clo_n_suppressions) = 0; 60Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES]; 61UChar VG_(clo_trace_flags) = 0; // 00000000b 62UChar VG_(clo_profile_flags) = 0; // 00000000b 63Int VG_(clo_trace_notbelow) = 999999999; 64Bool VG_(clo_trace_syscalls) = False; 65Bool VG_(clo_trace_signals) = False; 66Bool VG_(clo_trace_symtab) = False; 67HChar* VG_(clo_trace_symtab_patt) = "*"; 68Bool VG_(clo_trace_cfi) = False; 69Bool VG_(clo_debug_dump_syms) = False; 70Bool VG_(clo_debug_dump_line) = False; 71Bool VG_(clo_debug_dump_frames) = False; 72Bool VG_(clo_trace_redir) = False; 73Bool VG_(clo_trace_sched) = False; 74Bool VG_(clo_trace_pthreads) = False; 75Int VG_(clo_dump_error) = 0; 76Int VG_(clo_backtrace_size) = 12; 77Char* VG_(clo_sim_hints) = NULL; 78Bool VG_(clo_sym_offsets) = False; 79Bool VG_(clo_run_libc_freeres) = True; 80Bool VG_(clo_track_fds) = False; 81Bool VG_(clo_show_below_main)= False; 82Bool VG_(clo_show_emwarns) = False; 83Word VG_(clo_max_stackframe) = 2000000; 84Bool VG_(clo_wait_for_gdb) = False; 85VgSmc VG_(clo_smc_check) = Vg_SmcStack; 86HChar* VG_(clo_kernel_variant) = NULL; 87 88 89/*====================================================================*/ 90/*=== Command line errors ===*/ 91/*====================================================================*/ 92 93static void revert_to_stderr ( void ) 94{ 95 vg_assert( !VG_(logging_to_socket) ); 96 VG_(clo_log_fd) = 2; /* stderr */ 97} 98 99__attribute__((noreturn)) 100void VG_(err_bad_option) ( Char* opt ) 101{ 102 revert_to_stderr(); 103 VG_(printf)("valgrind: Bad option '%s'; aborting.\n", opt); 104 VG_(printf)("valgrind: Use --help for more information.\n"); 105 VG_(exit)(1); 106} 107 108__attribute__((noreturn)) 109void VG_(err_missing_prog) ( void ) 110{ 111 revert_to_stderr(); 112 VG_(printf)("valgrind: no program specified\n"); 113 VG_(printf)("valgrind: Use --help for more information.\n"); 114 VG_(exit)(1); 115} 116 117__attribute__((noreturn)) 118void VG_(err_config_error) ( Char* msg ) 119{ 120 revert_to_stderr(); 121 VG_(printf)("valgrind: Startup or configuration error:\n %s\n", msg); 122 VG_(printf)("valgrind: Unable to start up properly. Giving up.\n"); 123 VG_(exit)(1); 124} 125 126 127/*--------------------------------------------------------------------*/ 128/*--- end m_options.c ---*/ 129/*--------------------------------------------------------------------*/ 130