aboutsummaryrefslogtreecommitdiff
path: root/drd/drd_main.c
diff options
context:
space:
mode:
authornjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2009-02-25 01:01:05 +0000
committernjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2009-02-25 01:01:05 +0000
commit83df0b67a14425c484d8dda42b53f3ff0b598894 (patch)
treea8ceec138b7937a95b255cdc022fb0d52032e657 /drd/drd_main.c
parent09ee78ec9675201840d895623d49efba1ffe05d8 (diff)
downloadvalgrind-83df0b67a14425c484d8dda42b53f3ff0b598894.tar.gz
atoll() is a terrible function -- you can't do any error checking with it.
Some of our option processing code uses it. This means that eg. '--log-fd=9xxx' logs to fd 9, and '--log-fd=blahblahblah' logs to 0 (because atoll() returns 0 if the string doesn't contain a number!) It turns out that most of our option processing uses VG_(strtoll*) instead of VG_(atoll). The reason that not all of it does is that the option-processing macros are underpowered -- they currently work well if you just want to assign the value to a variable, eg: VG_BOOL_CLO(arg, "--heap", clo_heap) else VG_BOOL_CLO(arg, "--stacks", clo_stacks) else VG_NUM_CLO(arg, "--heap-admin", clo_heap_admin) else VG_NUM_CLO(arg, "--depth", clo_depth) (This works because they are actually an if-statement, but it looks odd.) VG_NUM_CLO uses VG_(stroll10). But if you want to do any checking or processing, you can't use those macros, leading to code like this: else if (VG_CLO_STREQN(9, arg, "--log-fd=")) { log_to = VgLogTo_Fd; VG_(clo_log_name) = NULL; tmp_log_fd = (Int)VG_(atoll)(&arg[9]); } So this commit: - Improves the *_CLO_* macros so that they can be used in all circumstances. They're now just expressions (albeit ones with side-effects, setting the named variable appropriately). Thus they can be used as if-conditions, and any post-checking or processing can occur in the then-statement. And malformed numeric arguments (eg. --log-fd=foo) aren't accepted. This also means you don't have to specify the lengths of any option strings anywhere (eg. the 9 in the --log-fd example above). The use of a wrong number caused at least one bug, in Massif. - Updates all places where the macros were used. - Updates Helgrind to use the *_CLO_* macros (it didn't use them). - Updates Callgrind to use the *_CLO_* macros (it didn't use them), except for the more esoteric option names (those with numbers in the option name). This allowed getUInt() and getUWord() to be removed. - Improves the cache option parsing in Cachegrind and Callgrind -- now uses VG_(strtoll10)(), detects overflow, and is shorter. - Uses INT instead of NUM in the macro names, to distinguish better vs. the DBL macro. - Removes VG_(atoll*) and the few remaining uses -- they're wretched functions and VG_(strtoll*) should be used instead. - Adds the VG_STREQN macro. - Changes VG_BINT_CLO and VG_BHEX_CLO to abort if the given value is outside the range -- the current silent truncation is likely to cause confusion as much as anything. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9255 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'drd/drd_main.c')
-rw-r--r--drd/drd_main.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/drd/drd_main.c b/drd/drd_main.c
index 4792ffdc5..4ef3bb53c 100644
--- a/drd/drd_main.c
+++ b/drd/drd_main.c
@@ -83,27 +83,27 @@ static Bool DRD_(process_cmd_line_option)(Char* arg)
int trace_suppression = -1;
Char* trace_address = 0;
- VG_BOOL_CLO (arg, "--check-stack-var", check_stack_accesses)
- else VG_BOOL_CLO(arg, "--drd-stats", DRD_(s_print_stats))
- else VG_BOOL_CLO(arg,"--report-signal-unlocked",report_signal_unlocked)
- else VG_BOOL_CLO(arg, "--segment-merging", segment_merging)
- else VG_BOOL_CLO(arg, "--show-confl-seg", show_confl_seg)
- else VG_BOOL_CLO(arg, "--show-stack-usage", DRD_(s_show_stack_usage))
- else VG_BOOL_CLO(arg, "--trace-barrier", trace_barrier)
- else VG_BOOL_CLO(arg, "--trace-clientobj", trace_clientobj)
- else VG_BOOL_CLO(arg, "--trace-cond", trace_cond)
- else VG_BOOL_CLO(arg, "--trace-conflict-set", trace_conflict_set)
- else VG_BOOL_CLO(arg, "--trace-csw", trace_csw)
- else VG_BOOL_CLO(arg, "--trace-fork-join", trace_fork_join)
- else VG_BOOL_CLO(arg, "--trace-mutex", trace_mutex)
- else VG_BOOL_CLO(arg, "--trace-rwlock", trace_rwlock)
- else VG_BOOL_CLO(arg, "--trace-segment", trace_segment)
- else VG_BOOL_CLO(arg, "--trace-semaphore", trace_semaphore)
- else VG_BOOL_CLO(arg, "--trace-suppr", trace_suppression)
- else VG_BOOL_CLO(arg, "--var-info", DRD_(s_var_info))
- else VG_NUM_CLO (arg, "--exclusive-threshold", exclusive_threshold_ms)
- else VG_NUM_CLO (arg, "--shared-threshold", shared_threshold_ms)
- else VG_STR_CLO (arg, "--trace-addr", trace_address)
+ if VG_BOOL_CLO(arg, "--check-stack-var", check_stack_accesses) {}
+ else if VG_BOOL_CLO(arg, "--drd-stats", DRD_(s_print_stats)) {}
+ else if VG_BOOL_CLO(arg,"--report-signal-unlocked",report_signal_unlocked) {}
+ else if VG_BOOL_CLO(arg, "--segment-merging", segment_merging) {}
+ else if VG_BOOL_CLO(arg, "--show-confl-seg", show_confl_seg) {}
+ else if VG_BOOL_CLO(arg, "--show-stack-usage", DRD_(s_show_stack_usage)) {}
+ else if VG_BOOL_CLO(arg, "--trace-barrier", trace_barrier) {}
+ else if VG_BOOL_CLO(arg, "--trace-clientobj", trace_clientobj) {}
+ else if VG_BOOL_CLO(arg, "--trace-cond", trace_cond) {}
+ else if VG_BOOL_CLO(arg, "--trace-conflict-set", trace_conflict_set) {}
+ else if VG_BOOL_CLO(arg, "--trace-csw", trace_csw) {}
+ else if VG_BOOL_CLO(arg, "--trace-fork-join", trace_fork_join) {}
+ else if VG_BOOL_CLO(arg, "--trace-mutex", trace_mutex) {}
+ else if VG_BOOL_CLO(arg, "--trace-rwlock", trace_rwlock) {}
+ else if VG_BOOL_CLO(arg, "--trace-segment", trace_segment) {}
+ else if VG_BOOL_CLO(arg, "--trace-semaphore", trace_semaphore) {}
+ else if VG_BOOL_CLO(arg, "--trace-suppr", trace_suppression) {}
+ else if VG_BOOL_CLO(arg, "--var-info", DRD_(s_var_info)) {}
+ else if VG_INT_CLO (arg, "--exclusive-threshold", exclusive_threshold_ms) {}
+ else if VG_INT_CLO (arg, "--shared-threshold", shared_threshold_ms) {}
+ else if VG_STR_CLO (arg, "--trace-addr", trace_address) {}
else
return VG_(replacement_malloc_process_cmd_line_option)(arg);