njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Command line options. pub_tool_options.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
sewardj | 9ebd6e0 | 2007-01-08 06:01:59 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2007 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_TOOL_OPTIONS_H |
| 32 | #define __PUB_TOOL_OPTIONS_H |
| 33 | |
sewardj | f9b5b7d | 2005-07-26 23:47:00 +0000 | [diff] [blame] | 34 | #include "libvex.h" // for VexControl |
| 35 | |
| 36 | |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 37 | /* Use these for recognising tool command line options -- stops comparing |
| 38 | once whitespace is reached. */ |
| 39 | #define VG_CLO_STREQ(s1,s2) (0==VG_(strcmp_ws)((s1),(s2))) |
| 40 | #define VG_CLO_STREQN(nn,s1,s2) (0==VG_(strncmp_ws)((s1),(s2),(nn))) |
| 41 | |
| 42 | /* Higher-level command-line option recognisers; use in if/else chains */ |
| 43 | |
| 44 | #define VG_BOOL_CLO(qq_arg, qq_option, qq_var) \ |
| 45 | if (VG_CLO_STREQ(qq_arg, qq_option"=yes")) { (qq_var) = True; } \ |
| 46 | else if (VG_CLO_STREQ(qq_arg, qq_option"=no")) { (qq_var) = False; } |
| 47 | |
| 48 | #define VG_STR_CLO(qq_arg, qq_option, qq_var) \ |
| 49 | if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \ |
| 50 | (qq_var) = &qq_arg[ VG_(strlen)(qq_option)+1 ]; \ |
| 51 | } |
| 52 | |
| 53 | #define VG_NUM_CLO(qq_arg, qq_option, qq_var) \ |
| 54 | if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \ |
| 55 | (qq_var) = (Int)VG_(atoll)( &qq_arg[ VG_(strlen)(qq_option)+1 ] ); \ |
| 56 | } |
| 57 | |
| 58 | /* Bounded integer arg */ |
| 59 | #define VG_BNUM_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \ |
| 60 | if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \ |
| 61 | (qq_var) = (Int)VG_(atoll)( &qq_arg[ VG_(strlen)(qq_option)+1 ] ); \ |
| 62 | if ((qq_var) < (qq_lo)) (qq_var) = (qq_lo); \ |
| 63 | if ((qq_var) > (qq_hi)) (qq_var) = (qq_hi); \ |
| 64 | } |
| 65 | |
sewardj | f767d96 | 2007-02-12 17:47:14 +0000 | [diff] [blame^] | 66 | /* Bool arg whose value is denoted by the exact presence of the given string. */ |
| 67 | #define VG_XACT_CLO(qq_arg, qq_option, qq_var) \ |
| 68 | if (VG_CLO_STREQ(qq_arg, qq_option)) { \ |
| 69 | (qq_var) = True; \ |
| 70 | } /* else leave it alone */ |
| 71 | |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 72 | /* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */ |
sewardj | 71bc3cb | 2005-05-19 00:25:45 +0000 | [diff] [blame] | 73 | extern Int VG_(clo_verbosity); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 74 | |
sewardj | 71bc3cb | 2005-05-19 00:25:45 +0000 | [diff] [blame] | 75 | /* Emit all messages as XML? default: NO */ |
| 76 | /* If clo_xml is set, various other options are set in a non-default |
| 77 | way. See vg_main.c and mc_main.c. */ |
| 78 | extern Bool VG_(clo_xml); |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 79 | |
sewardj | 768db0e | 2005-07-19 14:18:56 +0000 | [diff] [blame] | 80 | /* An arbitrary user-supplied string which is copied into the |
| 81 | XML output, in between <usercomment> tags. */ |
| 82 | extern HChar* VG_(clo_xml_user_comment); |
| 83 | |
sewardj | 4d56c7c | 2007-02-07 19:50:55 +0000 | [diff] [blame] | 84 | /* Name of an environment variable which, if set, is to be used as |
| 85 | part of any output file name. See pub_core_options.h for |
| 86 | details. */ |
| 87 | extern Char* VG_(clo_log_file_qualifier); |
| 88 | |
sewardj | f9b5b7d | 2005-07-26 23:47:00 +0000 | [diff] [blame] | 89 | /* Vex iropt control. Tool-visible so tools can make Vex optimise |
| 90 | less aggressively if that is needed (callgrind needs this). */ |
| 91 | extern VexControl VG_(clo_vex_control); |
| 92 | |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame] | 93 | /* Call this if a recognised option was bad for some reason. Note: |
| 94 | don't use it just because an option was unrecognised -- return |
| 95 | 'False' from VG_(tdict).tool_process_cmd_line_option) to indicate |
| 96 | that. This function prints an error message, then shuts down the |
| 97 | entire system. */ |
| 98 | extern void VG_(err_bad_option) ( Char* opt ); |
| 99 | |
sewardj | 6893d65 | 2006-10-15 01:25:13 +0000 | [diff] [blame] | 100 | |
njn | 2024234 | 2005-05-16 23:31:24 +0000 | [diff] [blame] | 101 | #endif // __PUB_TOOL_OPTIONS_H |
| 102 | |
| 103 | /*--------------------------------------------------------------------*/ |
| 104 | /*--- end ---*/ |
| 105 | /*--------------------------------------------------------------------*/ |