From: Nicholas Nethercote Date: Sun, 27 Mar 2005 01:00:11 +0000 (+0000) Subject: Make the 'arg' parameter to VG_BOOL_CLO and similar macros explicit, rather X-Git-Tag: svn/VALGRIND_3_0_0~865 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8aac9bd8a7abe975f7340680d11f941e9568bc04;p=thirdparty%2Fvalgrind.git Make the 'arg' parameter to VG_BOOL_CLO and similar macros explicit, rather than implicit. Also tweak some formatting of command-line arg code. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3453 --- diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index c901cf9e95..81181cf249 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -651,7 +651,7 @@ static void get_command_line( int argc, char** argv, vg_argc0++; break; } - VG_BOOL_CLO("--command-line-only", noaugment) + VG_BOOL_CLO(arg, "--command-line-only", noaugment) } cl_argv = &argv[vg_argc0]; @@ -1665,15 +1665,11 @@ static void process_cmd_line_options( UInt* client_auxv, const char* toolname ) } /* Ignore these options - they've already been handled */ - if (VG_CLO_STREQN(7, arg, "--tool=")) - goto skip_arg; - if (VG_CLO_STREQN(7, arg, "--exec=")) - goto skip_arg; - if (VG_CLO_STREQN(20, arg, "--command-line-only=")) - goto skip_arg; + if (VG_CLO_STREQN( 7, arg, "--tool=")) goto skip_arg; + if (VG_CLO_STREQN( 7, arg, "--exec=")) goto skip_arg; + if (VG_CLO_STREQN(20, arg, "--command-line-only=")) goto skip_arg; - if ( VG_CLO_STREQ(arg, "--")) - goto skip_arg; + if ( VG_CLO_STREQ(arg, "--")) goto skip_arg; else if (VG_CLO_STREQ(arg, "-v") || VG_CLO_STREQ(arg, "--verbose")) @@ -1683,48 +1679,48 @@ static void process_cmd_line_options( UInt* client_auxv, const char* toolname ) VG_CLO_STREQ(arg, "--quiet")) VG_(clo_verbosity)--; - else VG_BOOL_CLO("--branchpred", VG_(clo_branchpred)) - else VG_BOOL_CLO("--db-attach", VG_(clo_db_attach)) - else VG_BOOL_CLO("--demangle", VG_(clo_demangle)) - else VG_BOOL_CLO("--error-limit", VG_(clo_error_limit)) - else VG_BOOL_CLO("--pointercheck", VG_(clo_pointercheck)) - else VG_BOOL_CLO("--support-elan3", VG_(clo_support_elan3)) - else VG_BOOL_CLO("--show-emwarns", VG_(clo_show_emwarns)) - else VG_BOOL_CLO("--profile", VG_(clo_profile)) - else VG_BOOL_CLO("--run-libc-freeres", VG_(clo_run_libc_freeres)) - else VG_BOOL_CLO("--show-below-main", VG_(clo_show_below_main)) - else VG_BOOL_CLO("--time-stamp", VG_(clo_time_stamp)) - else VG_BOOL_CLO("--track-fds", VG_(clo_track_fds)) - else VG_BOOL_CLO("--trace-children", VG_(clo_trace_children)) - else VG_BOOL_CLO("--trace-sched", VG_(clo_trace_sched)) - else VG_BOOL_CLO("--trace-signals", VG_(clo_trace_signals)) - else VG_BOOL_CLO("--trace-symtab", VG_(clo_trace_symtab)) - else VG_BOOL_CLO("--trace-redir", VG_(clo_trace_redir)) - else VG_BOOL_CLO("--trace-syscalls", VG_(clo_trace_syscalls)) - else VG_BOOL_CLO("--trace-pthreads", VG_(clo_trace_pthreads)) - else VG_BOOL_CLO("--wait-for-gdb", VG_(clo_wait_for_gdb)) - else VG_BOOL_CLO("--model-pthreads", VG_(clo_model_pthreads)) - - else VG_STR_CLO ("--db-command", VG_(clo_db_command)) - else VG_STR_CLO ("--weird-hacks", VG_(clo_weird_hacks)) - - else VG_NUM_CLO ("--dump-error", VG_(clo_dump_error)) - else VG_NUM_CLO ("--input-fd", VG_(clo_input_fd)) - else VG_NUM_CLO ("--sanity-level", VG_(clo_sanity_level)) - else VG_BNUM_CLO("--num-callers", VG_(clo_backtrace_size), 1, - VG_DEEPEST_BACKTRACE) - - else VG_BNUM_CLO("--vex-iropt-verbosity", + else VG_BOOL_CLO(arg, "--branchpred", VG_(clo_branchpred)) + else VG_BOOL_CLO(arg, "--db-attach", VG_(clo_db_attach)) + else VG_BOOL_CLO(arg, "--demangle", VG_(clo_demangle)) + else VG_BOOL_CLO(arg, "--error-limit", VG_(clo_error_limit)) + else VG_BOOL_CLO(arg, "--pointercheck", VG_(clo_pointercheck)) + else VG_BOOL_CLO(arg, "--support-elan3", VG_(clo_support_elan3)) + else VG_BOOL_CLO(arg, "--show-emwarns", VG_(clo_show_emwarns)) + else VG_BOOL_CLO(arg, "--profile", VG_(clo_profile)) + else VG_BOOL_CLO(arg, "--run-libc-freeres", VG_(clo_run_libc_freeres)) + else VG_BOOL_CLO(arg, "--show-below-main", VG_(clo_show_below_main)) + else VG_BOOL_CLO(arg, "--time-stamp", VG_(clo_time_stamp)) + else VG_BOOL_CLO(arg, "--track-fds", VG_(clo_track_fds)) + else VG_BOOL_CLO(arg, "--trace-children", VG_(clo_trace_children)) + else VG_BOOL_CLO(arg, "--trace-sched", VG_(clo_trace_sched)) + else VG_BOOL_CLO(arg, "--trace-signals", VG_(clo_trace_signals)) + else VG_BOOL_CLO(arg, "--trace-symtab", VG_(clo_trace_symtab)) + else VG_BOOL_CLO(arg, "--trace-redir", VG_(clo_trace_redir)) + else VG_BOOL_CLO(arg, "--trace-syscalls", VG_(clo_trace_syscalls)) + else VG_BOOL_CLO(arg, "--trace-pthreads", VG_(clo_trace_pthreads)) + else VG_BOOL_CLO(arg, "--wait-for-gdb", VG_(clo_wait_for_gdb)) + else VG_BOOL_CLO(arg, "--model-pthreads", VG_(clo_model_pthreads)) + + else VG_STR_CLO (arg, "--db-command", VG_(clo_db_command)) + else VG_STR_CLO (arg, "--weird-hacks", VG_(clo_weird_hacks)) + + else VG_NUM_CLO (arg, "--dump-error", VG_(clo_dump_error)) + else VG_NUM_CLO (arg, "--input-fd", VG_(clo_input_fd)) + else VG_NUM_CLO (arg, "--sanity-level", VG_(clo_sanity_level)) + else VG_BNUM_CLO(arg, "--num-callers", VG_(clo_backtrace_size), 1, + VG_DEEPEST_BACKTRACE) + + else VG_BNUM_CLO(arg, "--vex-iropt-verbosity", VG_(clo_vex_control).iropt_verbosity, 0, 10) - else VG_BNUM_CLO("--vex-iropt-level", + else VG_BNUM_CLO(arg, "--vex-iropt-level", VG_(clo_vex_control).iropt_level, 0, 2) - else VG_BOOL_CLO("--vex-iropt-precise-memory-exns", + else VG_BOOL_CLO(arg, "--vex-iropt-precise-memory-exns", VG_(clo_vex_control).iropt_precise_memory_exns) - else VG_BNUM_CLO("--vex-iropt-unroll-thresh", + else VG_BNUM_CLO(arg, "--vex-iropt-unroll-thresh", VG_(clo_vex_control).iropt_unroll_thresh, 0, 400) - else VG_BNUM_CLO("--vex-guest-max-insns", + else VG_BNUM_CLO(arg, "--vex-guest-max-insns", VG_(clo_vex_control).guest_max_insns, 1, 100) - else VG_BNUM_CLO("--vex-guest-chase-thresh", + else VG_BNUM_CLO(arg, "--vex-guest-chase-thresh", VG_(clo_vex_control).guest_chase_thresh, 0, 99) else if (VG_CLO_STREQN(9, arg, "--log-fd=")) { @@ -1801,7 +1797,7 @@ static void process_cmd_line_options( UInt* client_auxv, const char* toolname ) } } - else VG_NUM_CLO ("--trace-notbelow", VG_(clo_trace_notbelow)) + else VG_NUM_CLO (arg, "--trace-notbelow", VG_(clo_trace_notbelow)) else if (VG_CLO_STREQ(arg, "--gen-suppressions=no")) VG_(clo_gen_suppressions) = 0; diff --git a/coregrind/vg_malloc2.c b/coregrind/vg_malloc2.c index 6e3514e46d..ca3cbe1884 100644 --- a/coregrind/vg_malloc2.c +++ b/coregrind/vg_malloc2.c @@ -538,8 +538,8 @@ Bool VG_(replacement_malloc_process_cmd_line_option)(Char* arg) } } - else VG_BOOL_CLO("--sloppy-malloc", VG_(clo_sloppy_malloc)) - else VG_BOOL_CLO("--trace-malloc", VG_(clo_trace_malloc)) + else VG_BOOL_CLO(arg, "--sloppy-malloc", VG_(clo_sloppy_malloc)) + else VG_BOOL_CLO(arg, "--trace-malloc", VG_(clo_trace_malloc)) else return False; diff --git a/include/tool.h.base b/include/tool.h.base index a56dada6f9..4b5d6c64b6 100644 --- a/include/tool.h.base +++ b/include/tool.h.base @@ -137,24 +137,24 @@ typedef struct _ToolInfo { /* Higher-level command-line option recognisers; use in if/else chains */ -#define VG_BOOL_CLO(qq_option, qq_var) \ - if (VG_CLO_STREQ(arg, qq_option"=yes")) { (qq_var) = True; } \ - else if (VG_CLO_STREQ(arg, qq_option"=no")) { (qq_var) = False; } +#define VG_BOOL_CLO(qq_arg, qq_option, qq_var) \ + if (VG_CLO_STREQ(qq_arg, qq_option"=yes")) { (qq_var) = True; } \ + else if (VG_CLO_STREQ(qq_arg, qq_option"=no")) { (qq_var) = False; } -#define VG_STR_CLO(qq_option, qq_var) \ - if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, arg, qq_option"=")) { \ - (qq_var) = &arg[ VG_(strlen)(qq_option)+1 ]; \ +#define VG_STR_CLO(qq_arg, qq_option, qq_var) \ + if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \ + (qq_var) = &qq_arg[ VG_(strlen)(qq_option)+1 ]; \ } -#define VG_NUM_CLO(qq_option, qq_var) \ - if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, arg, qq_option"=")) { \ - (qq_var) = (Int)VG_(atoll)( &arg[ VG_(strlen)(qq_option)+1 ] ); \ +#define VG_NUM_CLO(qq_arg, qq_option, qq_var) \ + if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \ + (qq_var) = (Int)VG_(atoll)( &qq_arg[ VG_(strlen)(qq_option)+1 ] ); \ } /* Bounded integer arg */ -#define VG_BNUM_CLO(qq_option, qq_var, qq_lo, qq_hi) \ - if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, arg, qq_option"=")) { \ - (qq_var) = (Int)VG_(atoll)( &arg[ VG_(strlen)(qq_option)+1 ] ); \ +#define VG_BNUM_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \ + if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \ + (qq_var) = (Int)VG_(atoll)( &qq_arg[ VG_(strlen)(qq_option)+1 ] ); \ if ((qq_var) < (qq_lo)) (qq_var) = (qq_lo); \ if ((qq_var) > (qq_hi)) (qq_var) = (qq_hi); \ } diff --git a/massif/ms_main.c b/massif/ms_main.c index 6b4661c371..7ac1832099 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -290,11 +290,11 @@ static XFormat clo_format = XText; Bool TL_(process_cmd_line_option)(Char* arg) { - VG_BOOL_CLO("--heap", clo_heap) - else VG_BOOL_CLO("--stacks", clo_stacks) + VG_BOOL_CLO(arg, "--heap", clo_heap) + else VG_BOOL_CLO(arg, "--stacks", clo_stacks) - else VG_NUM_CLO ("--heap-admin", clo_heap_admin) - else VG_BNUM_CLO("--depth", clo_depth, 1, MAX_DEPTH) + else VG_NUM_CLO (arg, "--heap-admin", clo_heap_admin) + else VG_BNUM_CLO(arg, "--depth", clo_depth, 1, MAX_DEPTH) else if (VG_CLO_STREQN(11, arg, "--alloc-fn=")) { alloc_fns[n_alloc_fns] = & arg[11]; diff --git a/memcheck/mac_needs.c b/memcheck/mac_needs.c index 705e271ef6..c2cf3c3967 100644 --- a/memcheck/mac_needs.c +++ b/memcheck/mac_needs.c @@ -56,11 +56,11 @@ Bool MAC_(clo_workaround_gcc296_bugs) = False; Bool MAC_(process_common_cmd_line_option)(Char* arg) { - VG_BOOL_CLO("--partial-loads-ok", MAC_(clo_partial_loads_ok)) - else VG_BOOL_CLO("--show-reachable", MAC_(clo_show_reachable)) - else VG_BOOL_CLO("--workaround-gcc296-bugs",MAC_(clo_workaround_gcc296_bugs)) + VG_BOOL_CLO(arg, "--partial-loads-ok", MAC_(clo_partial_loads_ok)) + else VG_BOOL_CLO(arg, "--show-reachable", MAC_(clo_show_reachable)) + else VG_BOOL_CLO(arg, "--workaround-gcc296-bugs",MAC_(clo_workaround_gcc296_bugs)) - else VG_BNUM_CLO("--freelist-vol", MAC_(clo_freelist_vol), 0, 1000000000) + else VG_BNUM_CLO(arg, "--freelist-vol", MAC_(clo_freelist_vol), 0, 1000000000) else if (VG_CLO_STREQ(arg, "--leak-check=no")) MAC_(clo_leak_check) = LC_Off; diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index eb2fd350a0..732707072f 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -1582,7 +1582,7 @@ Bool MC_(clo_avoid_strlen_errors) = True; Bool TL_(process_cmd_line_option)(Char* arg) { - VG_BOOL_CLO("--avoid-strlen-errors", MC_(clo_avoid_strlen_errors)) + VG_BOOL_CLO(arg, "--avoid-strlen-errors", MC_(clo_avoid_strlen_errors)) else return MAC_(process_common_cmd_line_option)(arg);