blob: e27e158a950b3ee78041ff07d9a10dda79570a0b [file] [log] [blame]
njn20242342005-05-16 23:31:24 +00001
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
10 Copyright (C) 2000-2005 Julian Seward
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
34/* Use these for recognising tool command line options -- stops comparing
35 once whitespace is reached. */
36#define VG_CLO_STREQ(s1,s2) (0==VG_(strcmp_ws)((s1),(s2)))
37#define VG_CLO_STREQN(nn,s1,s2) (0==VG_(strncmp_ws)((s1),(s2),(nn)))
38
39/* Higher-level command-line option recognisers; use in if/else chains */
40
41#define VG_BOOL_CLO(qq_arg, qq_option, qq_var) \
42 if (VG_CLO_STREQ(qq_arg, qq_option"=yes")) { (qq_var) = True; } \
43 else if (VG_CLO_STREQ(qq_arg, qq_option"=no")) { (qq_var) = False; }
44
45#define VG_STR_CLO(qq_arg, qq_option, qq_var) \
46 if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \
47 (qq_var) = &qq_arg[ VG_(strlen)(qq_option)+1 ]; \
48 }
49
50#define VG_NUM_CLO(qq_arg, qq_option, qq_var) \
51 if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \
52 (qq_var) = (Int)VG_(atoll)( &qq_arg[ VG_(strlen)(qq_option)+1 ] ); \
53 }
54
55/* Bounded integer arg */
56#define VG_BNUM_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
57 if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \
58 (qq_var) = (Int)VG_(atoll)( &qq_arg[ VG_(strlen)(qq_option)+1 ] ); \
59 if ((qq_var) < (qq_lo)) (qq_var) = (qq_lo); \
60 if ((qq_var) > (qq_hi)) (qq_var) = (qq_hi); \
61 }
62
63/* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */
sewardj71bc3cb2005-05-19 00:25:45 +000064extern Int VG_(clo_verbosity);
njn20242342005-05-16 23:31:24 +000065
sewardj71bc3cb2005-05-19 00:25:45 +000066/* Profile? default: NO */
67extern Bool VG_(clo_profile);
68
69/* Emit all messages as XML? default: NO */
70/* If clo_xml is set, various other options are set in a non-default
71 way. See vg_main.c and mc_main.c. */
72extern Bool VG_(clo_xml);
njn20242342005-05-16 23:31:24 +000073
74/* Call this if a recognised option was bad for some reason.
75 Note: don't use it just because an option was unrecognised -- return 'False'
76 from VG_(tdict).tool_process_cmd_line_option) to indicate that. */
77extern void VG_(bad_option) ( Char* opt );
78
79#endif // __PUB_TOOL_OPTIONS_H
80
81/*--------------------------------------------------------------------*/
82/*--- end ---*/
83/*--------------------------------------------------------------------*/