You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(32) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
1
(8) |
2
(8) |
3
(15) |
4
(14) |
5
(12) |
6
(40) |
7
(9) |
|
8
(5) |
9
(12) |
10
(9) |
11
(13) |
12
(7) |
13
(7) |
14
(19) |
|
15
(18) |
16
(13) |
17
(16) |
18
(8) |
19
(16) |
20
(16) |
21
(12) |
|
22
(21) |
23
(39) |
24
(27) |
25
(33) |
26
(41) |
27
(17) |
28
(15) |
|
From: <sv...@va...> - 2009-02-25 04:04:48
|
Author: njn
Date: 2009-02-25 04:04:29 +0000 (Wed, 25 Feb 2009)
New Revision: 9257
Log:
Delete memcheck/tests/zeropage. The original purpose of the test is no
longer valid, as the comment indicates. Furthermore it mmaps arbitrary bits
of address space and so is horribly unportable, and doesn't work on Darwin.
Removed:
trunk/memcheck/tests/zeropage.c
trunk/memcheck/tests/zeropage.stderr.exp
trunk/memcheck/tests/zeropage.stderr.exp2
trunk/memcheck/tests/zeropage.stdout.exp
trunk/memcheck/tests/zeropage.stdout.exp-glibc27
trunk/memcheck/tests/zeropage.vgtest
Modified:
trunk/memcheck/tests/Makefile.am
Modified: trunk/memcheck/tests/Makefile.am
===================================================================
--- trunk/memcheck/tests/Makefile.am 2009-02-25 02:57:52 UTC (rev 9256)
+++ trunk/memcheck/tests/Makefile.am 2009-02-25 04:04:29 UTC (rev 9257)
@@ -177,9 +177,7 @@
writev.stderr.exp writev.vgtest \
xml1.stderr.exp xml1.stderr.exp2 \
xml1.stderr.exp64 xml1.stdout.exp \
- xml1.vgtest \
- zeropage.stderr.exp zeropage.stderr.exp2 zeropage.stdout.exp \
- zeropage.vgtest
+ xml1.vgtest
check_PROGRAMS = \
addressable \
@@ -224,7 +222,7 @@
vcpu_fbench vcpu_fnfns \
xml1 \
wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap7so.so wrap8 \
- writev zeropage
+ writev
AM_CFLAGS += $(AM_FLAG_M3264_PRI)
Deleted: trunk/memcheck/tests/zeropage.c
===================================================================
--- trunk/memcheck/tests/zeropage.c 2009-02-25 02:57:52 UTC (rev 9256)
+++ trunk/memcheck/tests/zeropage.c 2009-02-25 04:04:29 UTC (rev 9257)
@@ -1,38 +0,0 @@
-#include <sys/mman.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-/* The quick sanity check of Memcheck (and other tools with shadow memory)
- relies on the first 64KB of memory never being used. So our mmap()
- refuses to touch this area. This program tests for that.
- [actually, no longer true, these all now succeed.] */
-int main(void)
-{
- /* mmap(0x0, ... FIXED) should fail */
- int* m = mmap(0x0, 4096, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
- if (m != (int*)-1)
- printf("succeeded?!\n");
-
- /* mmap(0x1000, ... FIXED) should fail */
- m = mmap((void*)0x1000, 4096, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
- if (m != (int*)-1)
- printf("succeeded?!\n");
-
- /* mmap(0xa000, ... FIXED) should fail */
- m = mmap((void*)0xa000, 4096, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
- if (m != (int*)-1)
- printf("succeeded?!\n");
-
- /* mmap(0x10000, ... FIXED) should fail */
- m = mmap((void*)0x10000, 4096, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0);
- if (m == (int*)-1)
- printf("failed?!\n");
-
- return 0;
-}
Deleted: trunk/memcheck/tests/zeropage.stderr.exp
===================================================================
Deleted: trunk/memcheck/tests/zeropage.stderr.exp2
===================================================================
--- trunk/memcheck/tests/zeropage.stderr.exp2 2009-02-25 02:57:52 UTC (rev 9256)
+++ trunk/memcheck/tests/zeropage.stderr.exp2 2009-02-25 04:04:29 UTC (rev 9257)
@@ -1,3 +0,0 @@
-Warning: client syscall old_mmap tried to modify addresses 0x........-0x........
-Warning: client syscall old_mmap tried to modify addresses 0x........-0x........
-Warning: client syscall old_mmap tried to modify addresses 0x........-0x........
Deleted: trunk/memcheck/tests/zeropage.stdout.exp
===================================================================
--- trunk/memcheck/tests/zeropage.stdout.exp 2009-02-25 02:57:52 UTC (rev 9256)
+++ trunk/memcheck/tests/zeropage.stdout.exp 2009-02-25 04:04:29 UTC (rev 9257)
@@ -1,3 +0,0 @@
-succeeded?!
-succeeded?!
-succeeded?!
Deleted: trunk/memcheck/tests/zeropage.stdout.exp-glibc27
===================================================================
Deleted: trunk/memcheck/tests/zeropage.vgtest
===================================================================
--- trunk/memcheck/tests/zeropage.vgtest 2009-02-25 02:57:52 UTC (rev 9256)
+++ trunk/memcheck/tests/zeropage.vgtest 2009-02-25 04:04:29 UTC (rev 9257)
@@ -1,2 +0,0 @@
-prog: zeropage
-vgopts: -q
|
|
From: Tom H. <th...@cy...> - 2009-02-25 03:48:48
|
Nightly build on vauxhall ( x86_64, Fedora 10 ) started at 2009-02-25 03:20:05 GMT Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... done Regression test results follow == 489 tests, 0 stderr failures, 0 stdout failures, 0 post failures == |
|
From: Tom H. <th...@cy...> - 2009-02-25 03:45:12
|
Nightly build on lloyd ( x86_64, Fedora 7 ) started at 2009-02-25 03:05:05 GMT Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 480 tests, 5 stderr failures, 0 stdout failures, 0 post failures == exp-ptrcheck/tests/ccc (stderr) exp-ptrcheck/tests/preen_invars (stderr) exp-ptrcheck/tests/pth_create (stderr) exp-ptrcheck/tests/pth_specific (stderr) helgrind/tests/tc20_verifywrap (stderr) |
|
From: Tom H. <th...@cy...> - 2009-02-25 03:32:29
|
Nightly build on mg ( x86_64, Fedora 9 ) started at 2009-02-25 03:10:06 GMT Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 486 tests, 4 stderr failures, 2 stdout failures, 0 post failures == exp-ptrcheck/tests/ccc (stderr) exp-ptrcheck/tests/preen_invars (stderr) exp-ptrcheck/tests/pth_create (stderr) exp-ptrcheck/tests/pth_specific (stderr) memcheck/tests/linux/timerfd-syscall (stdout) none/tests/linux/mremap2 (stdout) |
|
From: Nicholas N. <n.n...@gm...> - 2009-02-25 03:15:07
|
Hi, x86/Linux assembly code and x86/Darwin assembly code appear to be different dialects. Some of the tests in none/tests/x86/ and memcheck/tests/x86/ compile on x86/Darwin, eg. memcheck/tests/bug152022. But some don't, eg. pushfpopf, because x86/Darwin assembler doesn't accept the .type and .size options. The easiest thing to do is move the ones that don't compile on Darwin into an x86-linux/ directory. Anyone have any strong opinons about this, or other insights? Nick |
Author: njn
Date: 2009-02-25 02:57:52 +0000 (Wed, 25 Feb 2009)
New Revision: 9256
Log:
Merge r9255 (CLO cleanups) from the trunk.
Modified:
branches/DARWIN/cachegrind/cg_main.c
branches/DARWIN/callgrind/clo.c
branches/DARWIN/callgrind/sim.c
branches/DARWIN/coregrind/m_debugstub/debugstub-darwin.c
branches/DARWIN/coregrind/m_demangle/vg_libciface.h
branches/DARWIN/coregrind/m_libcbase.c
branches/DARWIN/coregrind/m_libcproc.c
branches/DARWIN/coregrind/m_main.c
branches/DARWIN/coregrind/m_replacemalloc/replacemalloc_core.c
branches/DARWIN/coregrind/m_syswrap/syswrap-generic.c
branches/DARWIN/drd/drd_main.c
branches/DARWIN/exp-ptrcheck/pc_common.c
branches/DARWIN/helgrind/hg_main.c
branches/DARWIN/include/pub_tool_libcbase.h
branches/DARWIN/include/pub_tool_options.h
branches/DARWIN/lackey/lk_main.c
branches/DARWIN/massif/ms_main.c
branches/DARWIN/memcheck/mc_main.c
Modified: branches/DARWIN/cachegrind/cg_main.c
===================================================================
--- branches/DARWIN/cachegrind/cg_main.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/cachegrind/cg_main.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -1645,50 +1645,48 @@
static void parse_cache_opt ( cache_t* cache, Char* opt )
{
- Int i = 0, i2, i3;
+ Long i1, i2, i3;
+ Char* endptr;
- // Option argument looks like "65536,2,64".
- // Find commas, replace with NULs to make three independent
- // strings, then extract numbers, put NULs back. Yuck.
- while (VG_(isdigit)(opt[i])) i++;
- if (',' == opt[i]) {
- opt[i++] = '\0';
- i2 = i;
- } else goto bad;
- while (VG_(isdigit)(opt[i])) i++;
- if (',' == opt[i]) {
- opt[i++] = '\0';
- i3 = i;
- } else goto bad;
- while (VG_(isdigit)(opt[i])) i++;
- if ('\0' != opt[i]) goto bad;
+ // Option argument looks like "65536,2,64". Extract them.
+ i1 = VG_(strtoll10)(opt, &endptr); if (*endptr != ',') goto bad;
+ i2 = VG_(strtoll10)(endptr+1, &endptr); if (*endptr != ',') goto bad;
+ i3 = VG_(strtoll10)(endptr+1, &endptr); if (*endptr != '\0') goto bad;
- cache->size = (Int)VG_(atoll)(opt);
- cache->assoc = (Int)VG_(atoll)(opt + i2);
- cache->line_size = (Int)VG_(atoll)(opt + i3);
+ // Check for overflow.
+ cache->size = (Int)i1;
+ cache->assoc = (Int)i2;
+ cache->line_size = (Int)i3;
+ if (cache->size != i1) goto overflow;
+ if (cache->assoc != i2) goto overflow;
+ if (cache->line_size != i3) goto overflow;
- opt[i2-1] = ',';
- opt[i3-1] = ',';
return;
+ overflow:
+ VG_(message)(Vg_UserMsg,
+ "one of the cache parameters was too large and overflowed\n");
bad:
+ // XXX: this omits the "--I1/D1/L2=" part from the message, but that's
+ // not a big deal.
VG_(err_bad_option)(opt);
}
static Bool cg_process_cmd_line_option(Char* arg)
{
+ Char* tmp_str;
+
// 5 is length of "--I1="
- if (VG_CLO_STREQN(5, arg, "--I1="))
- parse_cache_opt(&clo_I1_cache, &arg[5]);
- else if (VG_CLO_STREQN(5, arg, "--D1="))
- parse_cache_opt(&clo_D1_cache, &arg[5]);
- else if (VG_CLO_STREQN(5, arg, "--L2="))
- parse_cache_opt(&clo_L2_cache, &arg[5]);
- else if (VG_CLO_STREQN(22, arg, "--cachegrind-out-file=")) {
- clo_cachegrind_out_file = &arg[22];
- }
- else VG_BOOL_CLO(arg, "--cache-sim", clo_cache_sim)
- else VG_BOOL_CLO(arg, "--branch-sim", clo_branch_sim)
+ if VG_STR_CLO(arg, "--I1", tmp_str)
+ parse_cache_opt(&clo_I1_cache, tmp_str);
+ else if VG_STR_CLO(arg, "--D1", tmp_str)
+ parse_cache_opt(&clo_D1_cache, tmp_str);
+ else if VG_STR_CLO(arg, "--L2", tmp_str)
+ parse_cache_opt(&clo_L2_cache, tmp_str);
+
+ else if VG_STR_CLO( arg, "--cachegrind-out-file", clo_cachegrind_out_file) {}
+ else if VG_BOOL_CLO(arg, "--cache-sim", clo_cache_sim) {}
+ else if VG_BOOL_CLO(arg, "--branch-sim", clo_branch_sim) {}
else
return False;
Modified: branches/DARWIN/callgrind/clo.c
===================================================================
--- branches/DARWIN/callgrind/clo.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/callgrind/clo.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -395,252 +395,128 @@
/*--- Command line processing ---*/
/*--------------------------------------------------------------------*/
-static Char* getUInt(Char* s, UInt* pn)
-{
- UInt n = 0;
- while((*s >='0') && (*s <='9')) {
- n = 10*n + (*s-'0');
- s++;
- }
- if (pn) *pn = n;
- return s;
-}
-
-__attribute__((unused))
-static UWord getUWord(Char* s)
-{
- UWord n = 0;
- Bool isHex = False;
-
- if ((s[0] == '0') && (s[1] == 'x')) {
- isHex = True;
- s += 2;
- }
-
- if (!isHex) {
- while((*s >='0') && (*s <='9')) {
- n = 10*n + (*s-'0');
- s++;
- }
- }
- else {
- while(1) {
- if ((*s >='0') && (*s <='9')) {
- n = 16*n + (*s-'0');
- s++;
- continue;
- }
- if ((*s >='a') && (*s <='f')) {
- n = 16*n + (*s-'a'+10);
- s++;
- continue;
- }
- if ((*s >='A') && (*s <='F')) {
- n = 16*n + (*s-'A'+10);
- s++;
- continue;
- }
- break;
- }
- }
-
- return n;
-}
-
Bool CLG_(process_cmd_line_option)(Char* arg)
{
- if (0 == VG_(strcmp)(arg, "--skip-plt=yes"))
- CLG_(clo).skip_plt = True;
- else if (0 == VG_(strcmp)(arg, "--skip-plt=no"))
- CLG_(clo).skip_plt = False;
+ Char* tmp_str;
- else if (0 == VG_(strcmp)(arg, "--collect-jumps=yes"))
- CLG_(clo).collect_jumps = True;
- else if (0 == VG_(strcmp)(arg, "--collect-jumps=no"))
- CLG_(clo).collect_jumps = False;
+ if VG_BOOL_CLO(arg, "--skip-plt", CLG_(clo).skip_plt) {}
+
+ else if VG_BOOL_CLO(arg, "--collect-jumps", CLG_(clo).collect_jumps) {}
/* compatibility alias, deprecated option */
- else if (0 == VG_(strcmp)(arg, "--trace-jump=yes"))
- CLG_(clo).collect_jumps = True;
- else if (0 == VG_(strcmp)(arg, "--trace-jump=no"))
- CLG_(clo).collect_jumps = False;
+ else if VG_BOOL_CLO(arg, "--trace-jump", CLG_(clo).collect_jumps) {}
- else if (0 == VG_(strcmp)(arg, "--combine-dumps=yes"))
- CLG_(clo).combine_dumps = True;
- else if (0 == VG_(strcmp)(arg, "--combine-dumps=no"))
- CLG_(clo).combine_dumps = False;
+ else if VG_BOOL_CLO(arg, "--combine-dumps", CLG_(clo).combine_dumps) {}
- else if (0 == VG_(strcmp)(arg, "--collect-atstart=yes"))
- CLG_(clo).collect_atstart = True;
- else if (0 == VG_(strcmp)(arg, "--collect-atstart=no"))
- CLG_(clo).collect_atstart = False;
+ else if VG_BOOL_CLO(arg, "--collect-atstart", CLG_(clo).collect_atstart) {}
- else if (0 == VG_(strcmp)(arg, "--instr-atstart=yes"))
- CLG_(clo).instrument_atstart = True;
- else if (0 == VG_(strcmp)(arg, "--instr-atstart=no"))
- CLG_(clo).instrument_atstart = False;
+ else if VG_BOOL_CLO(arg, "--instr-atstart", CLG_(clo).instrument_atstart) {}
- else if (0 == VG_(strcmp)(arg, "--separate-threads=yes"))
- CLG_(clo).separate_threads = True;
- else if (0 == VG_(strcmp)(arg, "--separate-threads=no"))
- CLG_(clo).separate_threads = False;
+ else if VG_BOOL_CLO(arg, "--separate-threads", CLG_(clo).separate_threads) {}
- else if (0 == VG_(strcmp)(arg, "--compress-strings=yes"))
- CLG_(clo).compress_strings = True;
- else if (0 == VG_(strcmp)(arg, "--compress-strings=no"))
- CLG_(clo).compress_strings = False;
+ else if VG_BOOL_CLO(arg, "--compress-strings", CLG_(clo).compress_strings) {}
+ else if VG_BOOL_CLO(arg, "--compress-mangled", CLG_(clo).compress_mangled) {}
+ else if VG_BOOL_CLO(arg, "--compress-pos", CLG_(clo).compress_pos) {}
- else if (0 == VG_(strcmp)(arg, "--compress-mangled=yes"))
- CLG_(clo).compress_mangled = True;
- else if (0 == VG_(strcmp)(arg, "--compress-mangled=no"))
- CLG_(clo).compress_mangled = False;
-
- else if (0 == VG_(strcmp)(arg, "--compress-pos=yes"))
- CLG_(clo).compress_pos = True;
- else if (0 == VG_(strcmp)(arg, "--compress-pos=no"))
- CLG_(clo).compress_pos = False;
-
- else if (0 == VG_(strncmp)(arg, "--fn-skip=", 10)) {
- fn_config* fnc = get_fnc(arg+10);
+ else if VG_STR_CLO(arg, "--fn-skip", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->skip = CONFIG_TRUE;
}
- else if (0 == VG_(strncmp)(arg, "--dump-before=", 14)) {
- fn_config* fnc = get_fnc(arg+14);
+ else if VG_STR_CLO(arg, "--dump-before", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->dump_before = CONFIG_TRUE;
}
- else if (0 == VG_(strncmp)(arg, "--zero-before=", 14)) {
- fn_config* fnc = get_fnc(arg+14);
+ else if VG_STR_CLO(arg, "--zero-before", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->zero_before = CONFIG_TRUE;
}
- else if (0 == VG_(strncmp)(arg, "--dump-after=", 13)) {
- fn_config* fnc = get_fnc(arg+13);
+ else if VG_STR_CLO(arg, "--dump-after", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->dump_after = CONFIG_TRUE;
}
- else if (0 == VG_(strncmp)(arg, "--toggle-collect=", 17)) {
- fn_config* fnc = get_fnc(arg+17);
+ else if VG_STR_CLO(arg, "--toggle-collect", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->toggle_collect = CONFIG_TRUE;
/* defaults to initial collection off */
CLG_(clo).collect_atstart = False;
}
- else if (0 == VG_(strncmp)(arg, "--separate-recs=", 16))
- CLG_(clo).separate_recursions = (Int)VG_(atoll)(&arg[16]);
+ else if VG_INT_CLO(arg, "--separate-recs", CLG_(clo).separate_recursions) {}
/* change handling of a jump between functions to ret+call */
- else if (0 == VG_(strcmp)(arg, "--pop-on-jump")) {
- CLG_(clo).pop_on_jump = True;
- }
- else if (0 == VG_(strncmp)(arg, "--pop-on-jump=", 14)) {
- fn_config* fnc = get_fnc(arg+14);
+ else if VG_XACT_CLO(arg, "--pop-on-jump", CLG_(clo).pop_on_jump, True) {}
+ else if VG_STR_CLO( arg, "--pop-on-jump", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->pop_on_jump = CONFIG_TRUE;
}
#if CLG_ENABLE_DEBUG
- else if (0 == VG_(strncmp)(arg, "--ct-verbose=", 13))
- CLG_(clo).verbose = (Int)VG_(atoll)(&arg[13]);
+ else if VG_INT_CLO(arg, "--ct-verbose", CLG_(clo).verbose) {}
+ else if VG_INT_CLO(arg, "--ct-vstart", CLG_(clo).verbose_start) {}
- else if (0 == VG_(strncmp)(arg, "--ct-vstart=", 12))
- CLG_(clo).verbose_start = (ULong)VG_(atoll)(&arg[12]);
-
- else if (0 == VG_(strncmp)(arg, "--ct-verbose", 12)) {
- UInt n;
+ else if VG_STREQN(12, arg, "--ct-verbose") {
fn_config* fnc;
- Char* s = getUInt(arg+12, &n);
- if ((n == 0) || *s != '=') return False;
+ Char* s;
+ UInt n = VG_(strtoll10)(arg+12, &s);
+ if ((n <= 0) || *s != '=') return False;
fnc = get_fnc(s+1);
fnc->verbosity = n;
}
#endif
- else if (0 == VG_(strncmp)(arg, "--separate-callers=", 19)) {
- if (0 == VG_(strcmp)(arg+19, "auto"))
- CLG_(clo).separate_callers = CONFIG_AUTO;
- else
- CLG_(clo).separate_callers = (Int)VG_(atoll)(&arg[19]);
- }
+ else if VG_XACT_CLO(arg, "--separate-callers=auto",
+ CLG_(clo).separate_callers, CONFIG_AUTO) {}
+ else if VG_INT_CLO( arg, "--separate-callers",
+ CLG_(clo).separate_callers) {}
- else if (0 == VG_(strncmp)(arg, "--fn-group", 10)) {
- UInt n;
+ else if VG_STREQN(10, arg, "--fn-group") {
fn_config* fnc;
- Char* s = getUInt(arg+10, &n);
- if ((n == 0) || *s != '=') return False;
+ Char* s;
+ UInt n = VG_(strtoll10)(arg+10, &s);
+ if ((n <= 0) || *s != '=') return False;
fnc = get_fnc(s+1);
fnc->group = n;
}
- else if (0 == VG_(strncmp)(arg, "--separate-callers", 18)) {
- UInt n;
+ else if VG_STREQN(18, arg, "--separate-callers") {
fn_config* fnc;
- Char* s = getUInt(arg+18, &n);
- if ((n == 0) || *s != '=') return False;
+ Char* s;
+ UInt n = VG_(strtoll10)(arg+18, &s);
+ if ((n <= 0) || *s != '=') return False;
fnc = get_fnc(s+1);
fnc->separate_callers = n;
}
- else if (0 == VG_(strncmp)(arg, "--separate-recs", 15)) {
- UInt n;
+ else if VG_STREQN(15, arg, "--separate-recs") {
fn_config* fnc;
- Char* s = getUInt(arg+15, &n);
- if ((n == 0) || *s != '=') return False;
+ Char* s;
+ UInt n = VG_(strtoll10)(arg+15, &s);
+ if ((n <= 0) || *s != '=') return False;
fnc = get_fnc(s+1);
fnc->separate_recursions = n;
}
- else if (0 == VG_(strncmp)(arg, "--callgrind-out-file=", 21))
- CLG_(clo).out_format = VG_(strdup)("cl.clo.pclo.1", arg+21);
+ else if VG_STR_CLO(arg, "--callgrind-out-file", CLG_(clo).out_format) {}
- else if (0 == VG_(strcmp)(arg, "--mangle-names=yes"))
- CLG_(clo).mangle_names = True;
- else if (0 == VG_(strcmp)(arg, "--mangle-names=no"))
- CLG_(clo).mangle_names = False;
+ else if VG_BOOL_CLO(arg, "--mangle-names", CLG_(clo).mangle_names) {}
- else if (0 == VG_(strcmp)(arg, "--skip-direct-rec=yes"))
- CLG_(clo).skip_direct_recursion = True;
- else if (0 == VG_(strcmp)(arg, "--skip-direct-rec=no"))
- CLG_(clo).skip_direct_recursion = False;
+ else if VG_BOOL_CLO(arg, "--skip-direct-rec",
+ CLG_(clo).skip_direct_recursion) {}
- else if (0 == VG_(strcmp)(arg, "--dump-bbs=yes"))
- CLG_(clo).dump_bbs = True;
- else if (0 == VG_(strcmp)(arg, "--dump-bbs=no"))
- CLG_(clo).dump_bbs = False;
+ else if VG_BOOL_CLO(arg, "--dump-bbs", CLG_(clo).dump_bbs) {}
+ else if VG_BOOL_CLO(arg, "--dump-line", CLG_(clo).dump_line) {}
+ else if VG_BOOL_CLO(arg, "--dump-instr", CLG_(clo).dump_instr) {}
+ else if VG_BOOL_CLO(arg, "--dump-bb", CLG_(clo).dump_bb) {}
- else if (0 == VG_(strcmp)(arg, "--dump-line=yes"))
- CLG_(clo).dump_line = True;
- else if (0 == VG_(strcmp)(arg, "--dump-line=no"))
- CLG_(clo).dump_line = False;
+ else if VG_INT_CLO( arg, "--dump-every-bb", CLG_(clo).dump_every_bb) {}
- else if (0 == VG_(strcmp)(arg, "--dump-instr=yes"))
- CLG_(clo).dump_instr = True;
- else if (0 == VG_(strcmp)(arg, "--dump-instr=no"))
- CLG_(clo).dump_instr = False;
+ else if VG_BOOL_CLO(arg, "--collect-alloc", CLG_(clo).collect_alloc) {}
+ else if VG_BOOL_CLO(arg, "--collect-systime", CLG_(clo).collect_systime) {}
+ else if VG_BOOL_CLO(arg, "--simulate-cache", CLG_(clo).simulate_cache) {}
- else if (0 == VG_(strcmp)(arg, "--dump-bb=yes"))
- CLG_(clo).dump_bb = True;
- else if (0 == VG_(strcmp)(arg, "--dump-bb=no"))
- CLG_(clo).dump_bb = False;
-
- else if (0 == VG_(strncmp)(arg, "--dump-every-bb=", 16))
- CLG_(clo).dump_every_bb = (ULong)VG_(atoll)(&arg[16]);
-
-
- else if (0 == VG_(strcmp)(arg, "--collect-alloc=yes"))
- CLG_(clo).collect_alloc = True;
- else if (0 == VG_(strcmp)(arg, "--collect-alloc=no"))
- CLG_(clo).collect_alloc = False;
-
- else if (0 == VG_(strcmp)(arg, "--collect-systime=yes"))
- CLG_(clo).collect_systime = True;
- else if (0 == VG_(strcmp)(arg, "--collect-systime=no"))
- CLG_(clo).collect_systime = False;
-
- else if (0 == VG_(strcmp)(arg, "--simulate-cache=yes"))
- CLG_(clo).simulate_cache = True;
- else if (0 == VG_(strcmp)(arg, "--simulate-cache=no"))
- CLG_(clo).simulate_cache = False;
-
else {
Bool isCachesimOption = (*CLG_(cachesim).parse_opt)(arg);
Modified: branches/DARWIN/callgrind/sim.c
===================================================================
--- branches/DARWIN/callgrind/sim.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/callgrind/sim.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -1601,40 +1601,33 @@
);
}
-static void parse_opt ( cache_t* cache, char* orig_opt, int opt_len )
+static void parse_opt ( cache_t* cache, char* opt )
{
- int i1, i2, i3;
- int i;
- char *opt = VG_(strdup)("cl.sim.po.1", orig_opt);
+ Long i1, i2, i3;
+ Char* endptr;
- i = i1 = opt_len;
+ // Option argument looks like "65536,2,64". Extract them.
+ i1 = VG_(strtoll10)(opt, &endptr); if (*endptr != ',') goto bad;
+ i2 = VG_(strtoll10)(endptr+1, &endptr); if (*endptr != ',') goto bad;
+ i3 = VG_(strtoll10)(endptr+1, &endptr); if (*endptr != '\0') goto bad;
- /* Option looks like "--I1=65536,2,64".
- * Find commas, replace with NULs to make three independent
- * strings, then extract numbers. Yuck. */
- while (VG_(isdigit)(opt[i])) i++;
- if (',' == opt[i]) {
- opt[i++] = '\0';
- i2 = i;
- } else goto bad;
- while (VG_(isdigit)(opt[i])) i++;
- if (',' == opt[i]) {
- opt[i++] = '\0';
- i3 = i;
- } else goto bad;
- while (VG_(isdigit)(opt[i])) i++;
- if ('\0' != opt[i]) goto bad;
+ // Check for overflow.
+ cache->size = (Int)i1;
+ cache->assoc = (Int)i2;
+ cache->line_size = (Int)i3;
+ if (cache->size != i1) goto overflow;
+ if (cache->assoc != i2) goto overflow;
+ if (cache->line_size != i3) goto overflow;
- cache->size = (Int)VG_(atoll)(opt + i1);
- cache->assoc = (Int)VG_(atoll)(opt + i2);
- cache->line_size = (Int)VG_(atoll)(opt + i3);
-
- VG_(free)(opt);
-
return;
+ overflow:
+ VG_(message)(Vg_UserMsg,
+ "one of the cache parameters was too large and overflowed\n");
bad:
- VG_(err_bad_option)(orig_opt);
+ // XXX: this omits the "--I1/D1/L2=" part from the message, but that's
+ // not a big deal.
+ VG_(err_bad_option)(opt);
}
/* Check for command line option for cache configuration.
@@ -1644,36 +1637,25 @@
*/
static Bool cachesim_parse_opt(Char* arg)
{
- if (0 == VG_(strcmp)(arg, "--simulate-wb=yes"))
- clo_simulate_writeback = True;
- else if (0 == VG_(strcmp)(arg, "--simulate-wb=no"))
- clo_simulate_writeback = False;
+ Char* tmp_str;
- else if (0 == VG_(strcmp)(arg, "--simulate-hwpref=yes"))
- clo_simulate_hwpref = True;
- else if (0 == VG_(strcmp)(arg, "--simulate-hwpref=no"))
- clo_simulate_hwpref = False;
+ if VG_BOOL_CLO(arg, "--simulate-wb", clo_simulate_writeback) {}
+ else if VG_BOOL_CLO(arg, "--simulate-hwpref", clo_simulate_hwpref) {}
+ else if VG_BOOL_CLO(arg, "--simulate-sectors", clo_simulate_sectors) {}
- else if (0 == VG_(strcmp)(arg, "--simulate-sectors=yes"))
- clo_simulate_sectors = True;
- else if (0 == VG_(strcmp)(arg, "--simulate-sectors=no"))
- clo_simulate_sectors = False;
+ else if VG_BOOL_CLO(arg, "--cacheuse", clo_collect_cacheuse) {
+ if (clo_collect_cacheuse) {
+ /* Use counters only make sense with fine dumping */
+ CLG_(clo).dump_instr = True;
+ }
+ }
- else if (0 == VG_(strcmp)(arg, "--cacheuse=yes")) {
- clo_collect_cacheuse = True;
- /* Use counters only make sense with fine dumping */
- CLG_(clo).dump_instr = True;
- }
- else if (0 == VG_(strcmp)(arg, "--cacheuse=no"))
- clo_collect_cacheuse = False;
-
- /* 5 is length of "--I1=" */
- else if (0 == VG_(strncmp)(arg, "--I1=", 5))
- parse_opt(&clo_I1_cache, arg, 5);
- else if (0 == VG_(strncmp)(arg, "--D1=", 5))
- parse_opt(&clo_D1_cache, arg, 5);
- else if (0 == VG_(strncmp)(arg, "--L2=", 5))
- parse_opt(&clo_L2_cache, arg, 5);
+ else if VG_STR_CLO(arg, "--I1", tmp_str)
+ parse_opt(&clo_I1_cache, tmp_str);
+ else if VG_STR_CLO(arg, "--D1", tmp_str)
+ parse_opt(&clo_D1_cache, tmp_str);
+ else if VG_STR_CLO(arg, "--L2", tmp_str)
+ parse_opt(&clo_L2_cache, tmp_str);
else
return False;
Modified: branches/DARWIN/coregrind/m_debugstub/debugstub-darwin.c
===================================================================
--- branches/DARWIN/coregrind/m_debugstub/debugstub-darwin.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/coregrind/m_debugstub/debugstub-darwin.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -784,13 +784,13 @@
{
Long addr, len;
- addr = VG_(atoll16)(cmd);
+ addr = VG_(strtoll16)(cmd, NULL);
cmd = VG_(strchr)(cmd, ',');
if (!cmd) {
write_command(sock, "E01"); // fixme errno
return;
}
- len = VG_(atoll16)(cmd+1);
+ len = VG_(strtoll16)(cmd+1, NULL);
if (len > (sizeof(outbuf)-1) / 2) len = (sizeof(outbuf)-1) / 2;
if (! VG_(am_is_valid_for_client)((Addr)addr, (SizeT)len, VKI_PROT_READ)) {
@@ -807,14 +807,14 @@
Long addr, len;
unsigned char *inbuf;
- addr = VG_(atoll16)(cmd);
+ addr = VG_(strtoll16)(cmd, NULL);
cmd = VG_(strchr)(cmd, ',');
if (!cmd) {
write_command(sock, "E01"); // fixme errno
return;
}
- len = VG_(atoll16)(cmd+1);
+ len = VG_(strtoll16)(cmd+1, NULL);
if (! VG_(am_is_valid_for_client)((Addr)addr, (SizeT)len, VKI_PROT_READ)) {
write_command(sock, "E14"); // fixme EFAULT
@@ -983,7 +983,7 @@
}
if (cmd[0] == ':') {
// target thread ID
- tid = VG_(atoll16)(cmd+1);
+ tid = VG_(strtoll16)(cmd+1, NULL);
continueOthers = False;
}
@@ -1013,7 +1013,7 @@
{
char rbuf[16];
int rsize;
- Long reg = VG_(atoll16)(cmd);
+ Long reg = VG_(strtoll16)(cmd, NULL);
if (!VG_(is_valid_tid)(query_tid)) {
write_command(sock, "E01"); // fixme errno
} else if (reg < 0 || reg >= rcount) {
@@ -1030,7 +1030,7 @@
uint8_t rbuf[16] = {0};
int rsize;
- Long reg = VG_(atoll16)(cmd);
+ Long reg = VG_(strtoll16)(cmd, NULL);
cmd = VG_(strchr)(cmd, '=');
if (!cmd) {
write_command(sock, "E01");
@@ -1064,7 +1064,7 @@
static void handle_T(Int sock, char *cmd)
{
- Long tid = VG_(atoll16)(cmd);
+ Long tid = VG_(strtoll16)(cmd, NULL);
if (VG_(is_valid_tid)(tid)) {
write_command(sock, "OK");
} else {
@@ -1220,7 +1220,7 @@
else if (cmd[0] == 'H') {
// Hcxx, Hgxx: set thread focus
if (cmd[1] == 'g' || cmd[1] == 'c') {
- ThreadId tid = VG_(atoll16)(cmd+2);
+ ThreadId tid = VG_(strtoll16)(cmd+2, NULL);
// fixme -1
if (tid == 0) {
tid = first_valid_tid();
Modified: branches/DARWIN/coregrind/m_demangle/vg_libciface.h
===================================================================
--- branches/DARWIN/coregrind/m_demangle/vg_libciface.h 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/coregrind/m_demangle/vg_libciface.h 2009-02-25 02:57:52 UTC (rev 9256)
@@ -45,7 +45,7 @@
#define abort() vg_assert(0)
-#define atoi(_str) VG_(atoll)((_str))
+#define atoi(_str) VG_(strtoll10)((_str), NULL)
#define free(_pt) VG_(arena_free) (VG_AR_DEMANGLE,(_pt))
#define memcmp(_s1,_s2,_sz) VG_(memcmp)((_s1),(_s2),(_sz))
#define memcpy(_dd,_ss,_sz) VG_(memcpy)((_dd),(_ss),(_sz))
Modified: branches/DARWIN/coregrind/m_libcbase.c
===================================================================
--- branches/DARWIN/coregrind/m_libcbase.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/coregrind/m_libcbase.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -155,16 +155,6 @@
return n;
}
-Long VG_(atoll) ( Char* str )
-{
- return VG_(strtoll10)(str, NULL);
-}
-
-Long VG_(atoll16) ( Char* str )
-{
- return VG_(strtoll16)(str, NULL);
-}
-
Char VG_(tolower) ( Char c )
{
if ( c >= 'A' && c <= 'Z' ) {
Modified: branches/DARWIN/coregrind/m_libcproc.c
===================================================================
--- branches/DARWIN/coregrind/m_libcproc.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/coregrind/m_libcproc.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -517,8 +517,13 @@
res = VG_(do_syscall3)(__NR_readlink, (UWord)"/proc/self",
(UWord)pid, sizeof(pid));
if (!res.isError && res.res > 0) {
+ Char* s;
pid[res.res] = '\0';
- res.res = VG_(atoll)(pid);
+ res.res = VG_(strtoll10)(pid, &s);
+ if (*s != '\0') {
+ VG_(message)(Vg_DebugMsg,
+ "Warning: invalid file name linked to by /proc/self: %s", pid);
+ }
}
}
Modified: branches/DARWIN/coregrind/m_main.c
===================================================================
--- branches/DARWIN/coregrind/m_main.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/coregrind/m_main.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -275,31 +275,25 @@
str = * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i );
vg_assert(str);
- if (VG_STREQ(str, "--version")) {
- // Ensure the version string goes to stdout
- VG_(clo_log_fd) = 1;
+ // Nb: the version string goes to stdout.
+ if VG_XACT_CLO(str, "--version", VG_(clo_log_fd), 1) {
VG_(printf)("valgrind-" VERSION "\n");
VG_(exit)(0);
+ }
+ else if VG_XACT_CLO(str, "--help", *need_help, 1) {}
+ else if VG_XACT_CLO(str, "-h", *need_help, 1) {}
- } else if (VG_CLO_STREQ(str, "--help") ||
- VG_CLO_STREQ(str, "-h")) {
- *need_help = 1;
+ else if VG_XACT_CLO(str, "--help-debug", *need_help, 2) {}
- } else if (VG_CLO_STREQ(str, "--help-debug")) {
- *need_help = 2;
-
// The tool has already been determined, but we need to know the name
// here.
- } else if (VG_CLO_STREQN(7, str, "--tool=")) {
- *tool = &str[7];
+ else if VG_STR_CLO(str, "--tool", *tool) {}
// Set up VG_(clo_max_stackframe) and VG_(clo_main_stacksize).
// These are needed by VG_(ii_create_image), which happens
// before main_process_cmd_line_options().
- }
- else VG_NUM_CLO(str, "--max-stackframe", VG_(clo_max_stackframe))
- else VG_NUM_CLO(str, "--main-stacksize", VG_(clo_main_stacksize));
-
+ else if VG_INT_CLO(str, "--max-stackframe", VG_(clo_max_stackframe)) {}
+ else if VG_INT_CLO(str, "--main-stacksize", VG_(clo_main_stacksize)) {}
}
}
@@ -314,6 +308,7 @@
SysRes sres;
Int i, tmp_log_fd;
Int toolname_len = VG_(strlen)(toolname);
+ Char* tmp_str; // Used in a couple of places.
enum {
VgLogTo_Fd,
VgLogTo_File,
@@ -343,9 +338,9 @@
// in case someone has combined a prefix with a core-specific option,
// eg. "--memcheck:verbose".
if (*colon == ':') {
- if (VG_CLO_STREQN(2, arg, "--") &&
- VG_CLO_STREQN(toolname_len, arg+2, toolname) &&
- VG_CLO_STREQN(1, arg+2+toolname_len, ":"))
+ if (VG_STREQN(2, arg, "--") &&
+ VG_STREQN(toolname_len, arg+2, toolname) &&
+ VG_STREQN(1, arg+2+toolname_len, ":"))
{
// Prefix matches, convert "--toolname:foo" to "--foo".
// Two things to note:
@@ -375,137 +370,128 @@
}
/* Ignore these options - they've already been handled */
- if (VG_CLO_STREQN( 7, arg, "--tool=")) { }
- else if (VG_CLO_STREQN(20, arg, "--command-line-only=")) { }
- else if (VG_CLO_STREQ(arg, "--")) { }
- else if (VG_CLO_STREQ(arg, "-d")) { }
+ if VG_STREQN( 7, arg, "--tool=") {}
+ else if VG_STREQN(20, arg, "--command-line-only=") {}
+ else if VG_STREQ( arg, "--") {}
+ else if VG_STREQ( arg, "-d") {}
+ else if VG_STREQN(16, arg, "--max-stackframe") {}
+ else if VG_STREQN(16, arg, "--main-stacksize") {}
+ else if VG_STREQN(14, arg, "--profile-heap") {}
- else if (VG_CLO_STREQ(arg, "-v") ||
- VG_CLO_STREQ(arg, "--verbose"))
+ // These options are new.
+ else if (VG_STREQ(arg, "-v") ||
+ VG_STREQ(arg, "--verbose"))
VG_(clo_verbosity)++;
- else if (VG_CLO_STREQ(arg, "-q") ||
- VG_CLO_STREQ(arg, "--quiet"))
+ else if (VG_STREQ(arg, "-q") ||
+ VG_STREQ(arg, "--quiet"))
VG_(clo_verbosity)--;
- else VG_BOOL_CLO(arg, "--xml", VG_(clo_xml))
- else VG_BOOL_CLO(arg, "--db-attach", VG_(clo_db_attach))
- else VG_BOOL_CLO(arg, "--db-listen", VG_(clo_db_listen))
- else VG_NUM_CLO (arg, "--db-listen-port", VG_(clo_db_listen_port))
- else VG_BOOL_CLO(arg, "--demangle", VG_(clo_demangle))
- else VG_BOOL_CLO(arg, "--error-limit", VG_(clo_error_limit))
- else VG_NUM_CLO (arg, "--error-exitcode", VG_(clo_error_exitcode))
- else VG_BOOL_CLO(arg, "--show-emwarns", VG_(clo_show_emwarns))
+ else if VG_BOOL_CLO(arg, "--xml", VG_(clo_xml)) {}
+ else if VG_BOOL_CLO(arg, "--db-attach", VG_(clo_db_attach)) {}
+ else if VG_BOOL_CLO(arg, "--db-listen", VG_(clo_db_listen)) {}
+ else if VG_INT_CLO (arg, "--db-listen-port", VG_(clo_db_listen_port)) {}
+ else if VG_BOOL_CLO(arg, "--demangle", VG_(clo_demangle)) {}
+ else if VG_BOOL_CLO(arg, "--error-limit", VG_(clo_error_limit)) {}
+ else if VG_INT_CLO (arg, "--error-exitcode", VG_(clo_error_exitcode)) {}
+ else if VG_BOOL_CLO(arg, "--show-emwarns", VG_(clo_show_emwarns)) {}
- /* The next two are already done in
- early_process_cmd_line_options, but we need to redundantly
- handle them again, so they do not get rejected as invalid. */
- else VG_NUM_CLO (arg, "--max-stackframe", VG_(clo_max_stackframe))
- else VG_NUM_CLO (arg, "--main-stacksize", VG_(clo_main_stacksize))
+ else if VG_BOOL_CLO(arg, "--run-libc-freeres", VG_(clo_run_libc_freeres)) {}
+ else if VG_BOOL_CLO(arg, "--show-below-main", VG_(clo_show_below_main)) {}
+ else if VG_BOOL_CLO(arg, "--time-stamp", VG_(clo_time_stamp)) {}
+ else if VG_BOOL_CLO(arg, "--track-fds", VG_(clo_track_fds)) {}
+ else if VG_BOOL_CLO(arg, "--trace-children", VG_(clo_trace_children)) {}
+ else if VG_BOOL_CLO(arg, "--child-silent-after-fork",
+ VG_(clo_child_silent_after_fork)) {}
+ else if VG_BOOL_CLO(arg, "--trace-sched", VG_(clo_trace_sched)) {}
+ else if VG_BOOL_CLO(arg, "--trace-signals", VG_(clo_trace_signals)) {}
+ else if VG_BOOL_CLO(arg, "--trace-symtab", VG_(clo_trace_symtab)) {}
+ else if VG_STR_CLO (arg, "--trace-symtab-patt", VG_(clo_trace_symtab_patt)) {}
+ else if VG_BOOL_CLO(arg, "--trace-cfi", VG_(clo_trace_cfi)) {}
+ else if VG_XACT_CLO(arg, "--debug-dump=syms", VG_(clo_debug_dump_syms),
+ True) {}
+ else if VG_XACT_CLO(arg, "--debug-dump=line", VG_(clo_debug_dump_line),
+ True) {}
+ else if VG_XACT_CLO(arg, "--debug-dump=frames",
+ VG_(clo_debug_dump_frames), True) {}
+ else if VG_BOOL_CLO(arg, "--trace-redir", VG_(clo_trace_redir)) {}
- 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, "--child-silent-after-fork",
- VG_(clo_child_silent_after_fork))
- 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_STR_CLO (arg, "--trace-symtab-patt", VG_(clo_trace_symtab_patt))
- else VG_BOOL_CLO(arg, "--trace-cfi", VG_(clo_trace_cfi))
- else VG_XACT_CLO(arg, "--debug-dump=syms", VG_(clo_debug_dump_syms))
- else VG_XACT_CLO(arg, "--debug-dump=line", VG_(clo_debug_dump_line))
- else VG_XACT_CLO(arg, "--debug-dump=frames", VG_(clo_debug_dump_frames))
- else VG_BOOL_CLO(arg, "--trace-redir", VG_(clo_trace_redir))
+ else if VG_BOOL_CLO(arg, "--trace-syscalls", VG_(clo_trace_syscalls)) {}
+ else if VG_BOOL_CLO(arg, "--trace-unknown-syscalls",
+ VG_(clo_trace_unknown_syscalls)) {}
+ else if VG_BOOL_CLO(arg, "--wait-for-gdb", VG_(clo_wait_for_gdb)) {}
+ else if VG_STR_CLO (arg, "--db-command", VG_(clo_db_command)) {}
+ else if VG_STR_CLO (arg, "--sim-hints", VG_(clo_sim_hints)) {}
+ else if VG_BOOL_CLO(arg, "--sym-offsets", VG_(clo_sym_offsets)) {}
+ else if VG_BOOL_CLO(arg, "--read-var-info", VG_(clo_read_var_info)) {}
- else VG_BOOL_CLO(arg, "--trace-syscalls", VG_(clo_trace_syscalls))
- else VG_BOOL_CLO(arg, "--trace-unknown-syscalls", VG_(clo_trace_unknown_syscalls))
- else VG_BOOL_CLO(arg, "--wait-for-gdb", VG_(clo_wait_for_gdb))
- else VG_STR_CLO (arg, "--db-command", VG_(clo_db_command))
- else VG_STR_CLO (arg, "--sim-hints", VG_(clo_sim_hints))
- else VG_BOOL_CLO(arg, "--sym-offsets", VG_(clo_sym_offsets))
- else VG_BOOL_CLO(arg, "--read-var-info", VG_(clo_read_var_info))
+ else if VG_INT_CLO (arg, "--dump-error", VG_(clo_dump_error)) {}
+ else if VG_INT_CLO (arg, "--input-fd", VG_(clo_input_fd)) {}
+ else if VG_INT_CLO (arg, "--sanity-level", VG_(clo_sanity_level)) {}
+ else if VG_BINT_CLO(arg, "--num-callers", VG_(clo_backtrace_size), 1,
+ VG_DEEPEST_BACKTRACE) {}
- 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 if VG_XACT_CLO(arg, "--smc-check=none", VG_(clo_smc_check),
+ Vg_SmcNone);
+ else if VG_XACT_CLO(arg, "--smc-check=stack", VG_(clo_smc_check),
+ Vg_SmcStack);
+ else if VG_XACT_CLO(arg, "--smc-check=all", VG_(clo_smc_check),
+ Vg_SmcAll);
- else if (VG_CLO_STREQ(arg, "--smc-check=none"))
- VG_(clo_smc_check) = Vg_SmcNone;
- else if (VG_CLO_STREQ(arg, "--smc-check=stack"))
- VG_(clo_smc_check) = Vg_SmcStack;
- else if (VG_CLO_STREQ(arg, "--smc-check=all"))
- VG_(clo_smc_check) = Vg_SmcAll;
+ else if VG_STR_CLO (arg, "--kernel-variant", VG_(clo_kernel_variant)) {}
- else if (VG_CLO_STREQ(arg, "--profile-heap=no"))
- ; /* We already handled it right at the top of valgrind_main.
- Just ignore. */
- else if (VG_CLO_STREQ(arg, "--profile-heap=yes"))
- ; /* ditto */
+ else if VG_BINT_CLO(arg, "--vex-iropt-verbosity",
+ VG_(clo_vex_control).iropt_verbosity, 0, 10) {}
+ else if VG_BINT_CLO(arg, "--vex-iropt-level",
+ VG_(clo_vex_control).iropt_level, 0, 2) {}
+ else if VG_BOOL_CLO(arg, "--vex-iropt-precise-memory-exns",
+ VG_(clo_vex_control).iropt_precise_memory_exns) {}
+ else if VG_BINT_CLO(arg, "--vex-iropt-unroll-thresh",
+ VG_(clo_vex_control).iropt_unroll_thresh, 0, 400) {}
+ else if VG_BINT_CLO(arg, "--vex-guest-max-insns",
+ VG_(clo_vex_control).guest_max_insns, 1, 100) {}
+ else if VG_BINT_CLO(arg, "--vex-guest-chase-thresh",
+ VG_(clo_vex_control).guest_chase_thresh, 0, 99) {}
- else VG_STR_CLO (arg, "--kernel-variant", VG_(clo_kernel_variant))
-
- else VG_BNUM_CLO(arg, "--vex-iropt-verbosity",
- VG_(clo_vex_control).iropt_verbosity, 0, 10)
- else VG_BNUM_CLO(arg, "--vex-iropt-level",
- VG_(clo_vex_control).iropt_level, 0, 2)
- else VG_BOOL_CLO(arg, "--vex-iropt-precise-memory-exns",
- VG_(clo_vex_control).iropt_precise_memory_exns)
- else VG_BNUM_CLO(arg, "--vex-iropt-unroll-thresh",
- VG_(clo_vex_control).iropt_unroll_thresh, 0, 400)
- else VG_BNUM_CLO(arg, "--vex-guest-max-insns",
- VG_(clo_vex_control).guest_max_insns, 1, 100)
- 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=")) {
- log_to = VgLogTo_Fd;
+ else if VG_INT_CLO(arg, "--log-fd", tmp_log_fd) {
+ log_to = VgLogTo_Fd;
VG_(clo_log_name) = NULL;
- tmp_log_fd = (Int)VG_(atoll)(&arg[9]);
}
- else if (VG_CLO_STREQN(11, arg, "--log-file=")) {
- log_to = VgLogTo_File;
- VG_(clo_log_name) = &arg[11];
+ else if VG_STR_CLO(arg, "--log-file", VG_(clo_log_name)) {
+ log_to = VgLogTo_File;
}
- else if (VG_CLO_STREQN(13, arg, "--log-socket=")) {
- log_to = VgLogTo_Socket;
- VG_(clo_log_name) = &arg[13];
+ else if VG_STR_CLO(arg, "--log-socket", VG_(clo_log_name)) {
+ log_to = VgLogTo_Socket;
}
- else if (VG_CLO_STREQN(19, arg, "--xml-user-comment=")) {
- VG_(clo_xml_user_comment) = &arg[19];
- }
+ else if VG_STR_CLO(arg, "--xml-user-comment",
+ VG_(clo_xml_user_comment)) {}
- else if (VG_CLO_STREQN(15, arg, "--suppressions=")) {
+ else if VG_STR_CLO(arg, "--suppressions", tmp_str) {
if (VG_(clo_n_suppressions) >= VG_CLO_MAX_SFILES) {
VG_(message)(Vg_UserMsg, "Too many suppression files specified.");
VG_(message)(Vg_UserMsg,
"Increase VG_CLO_MAX_SFILES and recompile.");
VG_(err_bad_option)(arg);
}
- VG_(clo_suppressions)[VG_(clo_n_suppressions)] = &arg[15];
+ VG_(clo_suppressions)[VG_(clo_n_suppressions)] = tmp_str;
VG_(clo_n_suppressions)++;
}
/* "stuvwxyz" --> stuvwxyz (binary) */
- else if (VG_CLO_STREQN(14, arg, "--trace-flags=")) {
+ else if VG_STR_CLO(arg, "--trace-flags", tmp_str) {
Int j;
- char* opt = & arg[14];
- if (8 != VG_(strlen)(opt)) {
+ if (8 != VG_(strlen)(tmp_str)) {
VG_(message)(Vg_UserMsg,
"--trace-flags argument must have 8 digits");
VG_(err_bad_option)(arg);
}
for (j = 0; j < 8; j++) {
- if ('0' == opt[j]) { /* do nothing */ }
- else if ('1' == opt[j]) VG_(clo_trace_flags) |= (1 << (7-j));
+ if ('0' == tmp_str[j]) { /* do nothing */ }
+ else if ('1' == tmp_str[j]) VG_(clo_trace_flags) |= (1 << (7-j));
else {
VG_(message)(Vg_UserMsg, "--trace-flags argument can only "
"contain 0s and 1s");
@@ -515,18 +501,17 @@
}
/* "stuvwxyz" --> stuvwxyz (binary) */
- else if (VG_CLO_STREQN(16, arg, "--profile-flags=")) {
+ else if VG_STR_CLO(arg, "--profile-flags", tmp_str) {
Int j;
- char* opt = & arg[16];
- if (8 != VG_(strlen)(opt)) {
+ if (8 != VG_(strlen)(tmp_str)) {
VG_(message)(Vg_UserMsg,
"--profile-flags argument must have 8 digits");
VG_(err_bad_option)(arg);
}
for (j = 0; j < 8; j++) {
- if ('0' == opt[j]) { /* do nothing */ }
- else if ('1' == opt[j]) VG_(clo_profile_flags) |= (1 << (7-j));
+ if ('0' == tmp_str[j]) { /* do nothing */ }
+ else if ('1' == tmp_str[j]) VG_(clo_profile_flags) |= (1 << (7-j));
else {
VG_(message)(Vg_UserMsg, "--profile-flags argument can only "
"contain 0s and 1s");
@@ -535,14 +520,14 @@
}
}
- else VG_NUM_CLO (arg, "--trace-notbelow", VG_(clo_trace_notbelow))
+ else if VG_INT_CLO (arg, "--trace-notbelow", VG_(clo_trace_notbelow)) {}
- else if (VG_CLO_STREQ(arg, "--gen-suppressions=no"))
- VG_(clo_gen_suppressions) = 0;
- else if (VG_CLO_STREQ(arg, "--gen-suppressions=yes"))
- VG_(clo_gen_suppressions) = 1;
- else if (VG_CLO_STREQ(arg, "--gen-suppressions=all"))
- VG_(clo_gen_suppressions) = 2;
+ else if VG_XACT_CLO(arg, "--gen-suppressions=no",
+ VG_(clo_gen_suppressions), 0) {}
+ else if VG_XACT_CLO(arg, "--gen-suppressions=yes",
+ VG_(clo_gen_suppressions), 1) {}
+ else if VG_XACT_CLO(arg, "--gen-suppressions=all",
+ VG_(clo_gen_suppressions), 2) {}
else if ( ! VG_(needs).command_line_options
|| ! VG_TDICT_CALL(tool_process_cmd_line_option, arg) ) {
@@ -1227,19 +1212,15 @@
// p: none
//--------------------------------------------------------------
/* Start the debugging-log system ASAP. First find out how many
- "-d"s were specified. This is a pre-scan of the command line. */
+ "-d"s were specified. This is a pre-scan of the command line. Also
+ get --profile-heap=yes which is needed by the time we start up dynamic
+ memory management. */
loglevel = 0;
for (i = 1; i < argc; i++) {
- if (argv[i][0] != '-')
- break;
- if (VG_STREQ(argv[i], "--"))
- break;
- if (VG_STREQ(argv[i], "-d"))
- loglevel++;
- if (VG_STREQ(argv[i], "--profile-heap=yes"))
- VG_(clo_profile_heap) = True;
- if (VG_STREQ(argv[i], "--profile-heap=no"))
- VG_(clo_profile_heap) = False;
+ if (argv[i][0] != '-') break;
+ if VG_STREQ(argv[i], "--") break;
+ if VG_STREQ(argv[i], "-d") loglevel++;
+ if VG_BOOL_CLO(argv[i], "--profile-heap", VG_(clo_profile_heap)) {}
}
/* ... and start the debug logger. Now we can safely emit logging
@@ -1371,6 +1352,7 @@
//--------------------------------------------------------------
// Start up the dynamic memory manager
// p: address space management
+ // p: getting --profile-heap
// In fact m_mallocfree is self-initialising, so there's no
// initialisation call to do. Instead, try a simple malloc/
// free pair right now to check that nothing is broken.
@@ -1522,7 +1504,9 @@
//--------------------------------------------------------------
// Load client executable, finding in $PATH if necessary
- // p: early_process_cmd_line_options() [for 'exec', 'need_help']
+ // p: early_process_cmd_line_options() [for 'exec', 'need_help',
+ // clo_max_stackframe,
+ // clo_main_stacksize]
// p: layout_remaining_space [so there's space]
//
// Set up client's environment
Modified: branches/DARWIN/coregrind/m_replacemalloc/replacemalloc_core.c
===================================================================
--- branches/DARWIN/coregrind/m_replacemalloc/replacemalloc_core.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/coregrind/m_replacemalloc/replacemalloc_core.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -53,13 +53,11 @@
Bool VG_(replacement_malloc_process_cmd_line_option)(Char* arg)
{
- if (VG_CLO_STREQN(12, arg, "--alignment=")) {
- VG_(clo_alignment) = (UInt)VG_(atoll)(&arg[12]);
-
- if (VG_(clo_alignment) < VG_MIN_MALLOC_SZB
- || VG_(clo_alignment) > 4096
- || VG_(log2)( VG_(clo_alignment) ) == -1 /* not a power of 2 */) {
- VG_(message)(Vg_UserMsg, "");
+ if VG_INT_CLO(arg, "--alignment", VG_(clo_alignment)) {
+ if (VG_(clo_alignment) < VG_MIN_MALLOC_SZB ||
+ VG_(clo_alignment) > 4096 ||
+ VG_(log2)( VG_(clo_alignment) ) == -1 /* not a power of 2 */)
+ {
VG_(message)(Vg_UserMsg,
"Invalid --alignment= setting. "
"Should be a power of 2, >= %d, <= 4096.", VG_MIN_MALLOC_SZB);
@@ -67,7 +65,7 @@
}
}
- else VG_BOOL_CLO(arg, "--trace-malloc", VG_(clo_trace_malloc))
+ else if VG_BOOL_CLO(arg, "--trace-malloc", VG_(clo_trace_malloc)) {}
else
return False;
Modified: branches/DARWIN/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/syswrap-generic.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/coregrind/m_syswrap/syswrap-generic.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -789,11 +789,16 @@
goto out;
if (VG_(strcmp)(d.d_name, ".") && VG_(strcmp)(d.d_name, "..")) {
- Int fno = VG_(atoll)(d.d_name);
-
- if (fno != f.res)
- if (VG_(clo_track_fds))
- ML_(record_fd_open_named)(-1, fno);
+ Char* s;
+ Int fno = VG_(strtoll10)(d.d_name, &s);
+ if (*s == '\0') {
+ if (fno != f.res)
+ if (VG_(clo_track_fds))
+ ML_(record_fd_open_named)(-1, fno);
+ } else {
+ VG_(message)(Vg_DebugMsg,
+ "Warning: invalid file name in /proc/self/fd: %s", d.d_name);
+ }
}
VG_(lseek)(f.res, d.d_off, VKI_SEEK_SET);
Modified: branches/DARWIN/drd/drd_main.c
===================================================================
--- branches/DARWIN/drd/drd_main.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/drd/drd_main.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -83,27 +83,27 @@
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);
Modified: branches/DARWIN/exp-ptrcheck/pc_common.c
===================================================================
--- branches/DARWIN/exp-ptrcheck/pc_common.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/exp-ptrcheck/pc_common.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -64,9 +64,9 @@
Bool pc_process_cmd_line_options(Char* arg)
{
- VG_BOOL_CLO(arg, "--partial-loads-ok", h_clo_partial_loads_ok)
- /* else VG_BOOL_CLO(arg, "--lossage-check", h_clo_lossage_check) */
- else VG_BOOL_CLO(arg, "--enable-sg-checks", sg_clo_enable_sg_checks)
+ if VG_BOOL_CLO(arg, "--partial-loads-ok", h_clo_partial_loads_ok) {}
+ /* else if VG_BOOL_CLO(arg, "--lossage-check", h_clo_lossage_check) {} */
+ else if VG_BOOL_CLO(arg, "--enable-sg-checks", sg_clo_enable_sg_checks) {}
else
return VG_(replacement_malloc_process_cmd_line_option)(arg);
Modified: branches/DARWIN/helgrind/hg_main.c
===================================================================
--- branches/DARWIN/helgrind/hg_main.c 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/helgrind/hg_main.c 2009-02-25 02:57:52 UTC (rev 9256)
@@ -4000,39 +4000,32 @@
static Bool hg_process_cmd_line_option ( Char* arg )
{
- if (VG_CLO_STREQ(arg, "--track-lockorders=no"))
- HG_(clo_track_lockorders) = False;
- else if (VG_CLO_STREQ(arg, "--track-lockorders=yes"))
- HG_(clo_track_lockorders) = True;
+ Char* tmp_str;
- else if (VG_CLO_STREQ(arg, "--cmp-race-err-addrs=no"))
- HG_(clo_cmp_race_err_addrs) = False;
- else if (VG_CLO_STREQ(arg, "--cmp-race-err-addrs=yes"))
- HG_(clo_cmp_race_err_addrs) = True;
+ if VG_BOOL_CLO(arg, "--track-lockorders",
+ HG_(clo_track_lockorders)) {}
+ else if VG_BOOL_CLO(arg, "--cmp-race-err-addrs",
+ HG_(clo_cmp_race_err_addrs)) {}
+ else if VG_BOOL_CLO(arg, "--show-conflicts",
+ HG_(clo_show_conflicts)) {}
- else if (VG_CLO_STREQ(arg, "--show-conflicts=no"))
- HG_(clo_show_conflicts) = False;
- else if (VG_CLO_STREQ(arg, "--show-conflicts=yes"))
- HG_(clo_show_conflicts) = True;
-
/* If you change the 10k/10mill limits, remember to also change
them in assertions at the top of event_map_maybe_GC. */
- else VG_BNUM_CLO(arg, "--conflict-cache-size",
- HG_(clo_conflict_cache_size), 10*1000, 10*1000*1000)
+ else if VG_BINT_CLO(arg, "--conflict-cache-size",
+ HG_(clo_conflict_cache_size), 10*1000, 10*1000*1000) {}
/* "stuvwx" --> stuvwx (binary) */
- else if (VG_CLO_STREQN(18, arg, "--hg-sanity-flags=")) {
+ else if VG_STR_CLO(arg, "--hg-sanity-flags", tmp_str) {
Int j;
- Char* opt = & arg[18];
- if (6 != VG_(strlen)(opt)) {
+ if (6 != VG_(strlen)(tmp_str)) {
VG_(message)(Vg_UserMsg,
"--hg-sanity-flags argument must have 6 digits");
return False;
}
for (j = 0; j < 6; j++) {
- if ('0' == opt[j]) { /* do nothing */ }
- else if ('1' == opt[j]) HG_(clo_sanity_flags) |= (1 << (6-1-j));
+ if ('0' == tmp_str[j]) { /* do nothing */ }
+ else if ('1' == tmp_str[j]) HG_(clo_sanity_flags) |= (1 << (6-1-j));
else {
VG_(message)(Vg_UserMsg, "--hg-sanity-flags argument can "
"only contain 0s and 1s");
Modified: branches/DARWIN/include/pub_tool_libcbase.h
===================================================================
--- branches/DARWIN/include/pub_tool_libcbase.h 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/include/pub_tool_libcbase.h 2009-02-25 02:57:52 UTC (rev 9256)
@@ -52,36 +52,28 @@
// is set to the start of the string. None of them test that the number
// fits into 64 bits.
//
-// Nb: if you're wondering why we don't just have a single VG_(strtol) which
+// Nb: if you're wondering why we don't just have a single VG_(strtoll) which
// takes a base, it's because I wanted it to assert if it was given a bogus
// base (the standard glibc one sets 'errno' in this case). But
// m_libcbase.c doesn't import any code, not even vg_assert. --njn
-//
-// XXX: probably would be better to just have VG_(strtoll) which accepts a
-// decimal number by default or a hexadecimal number if '0x' or '0X' occurs
-// at the start.
extern Long VG_(strtoll10) ( Char* str, Char** endptr );
extern Long VG_(strtoll16) ( Char* str, Char** endptr );
- // Convert a string to a double. After leading whitespace is ignored, a
- // '+' or '-' is allowed, and then it accepts a non-empty sequence of
- // decimal digits possibly containing a '.'. Hexadecimal floats are not
- // accepted, nor are "fancy" floats (eg. "3.4e-5", "NAN").
+// Convert a string to a double. After leading whitespace is ignored, a
+// '+' or '-' is allowed, and then it accepts a non-empty sequence of
+// decimal digits possibly containing a '.'. Hexadecimal floats are not
+// accepted, nor are "fancy" floats (eg. "3.4e-5", "NAN").
extern double VG_(strtod) ( Char* str, Char** endptr );
- // These are just like their VG_(strtoll*) counterparts, except that you
- // cannot tell if an error occurred (because 0 is returned) or if there
- // is any trailing non-numeric characterws (eg. in "123xyz").
-extern Long VG_(atoll) ( Char* str ); // base 10
-extern Long VG_(atoll16) ( Char* str ); // base 16; leading 0x accepted
-
/* ---------------------------------------------------------------------
String functions and macros
------------------------------------------------------------------ */
-/* Use this for normal null-termination-style string comparison */
+/* Use this for normal null-termination-style string comparison. */
#define VG_STREQ(s1,s2) ( (s1 != NULL && s2 != NULL \
&& VG_(strcmp)((s1),(s2))==0) ? True : False )
+#define VG_STREQN(n,s1,s2) ( (s1 != NULL && s2 != NULL \
+ && VG_(strncmp)((s1),(s2),(n))==0) ? True : False )
extern SizeT VG_(strlen) ( const Char* str );
extern Char* VG_(strcat) ( Char* dest, const Char* src );
Modified: branches/DARWIN/include/pub_tool_options.h
===================================================================
--- branches/DARWIN/include/pub_tool_options.h 2009-02-25 01:01:05 UTC (rev 9255)
+++ branches/DARWIN/include/pub_tool_options.h 2009-02-25 02:57:52 UTC (rev 9256)
@@ -34,72 +34,110 @@
#include "libvex.h" // for VexControl
-/* Use these for recognising tool command line options -- stops comparing
- once whitespace is reached. */
-#define VG_CLO_STREQ(s1,s2) (0==VG_(strcmp_ws)((s1),(s2)))
-#define VG_CLO_STREQN(nn,s1,s2) (0==VG_(strncmp_ws)((s1),(s2),(nn)))
+// Higher-level command-line option recognisers; use in if/else chains.
+// Note that they assign a value to the 'qq_var' argument. So often they
+// can be used like this:
+//
+// if VG_STR_CLO(arg, "--foo", clo_foo) { }
+//
+// But if you want to do further checking or processing, you can do this:
+//
+// if VG_STR_CLO(arg, "--foo", clo_foo) { <further checking or processing> }
+//
+// They use GNU statement expressions to do the qq_var assignment within a
+// conditional expression.
-/* Higher-level command-line option recognisers; use in if/else chains */
-
+// String argument, eg. --foo=yes or --foo=no
#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)) { (qq_var) = True; } \
- else if (VG_CLO_STREQ(qq_arg, qq_option"=no")) { (qq_var) = False; }
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+ if VG_STREQ(val, "yes") (qq_var) = True; \
+ else if VG_STREQ(val, "no") (qq_var) = False; \
+ True; \
+ }) \
+ )
+// String argument, eg. --foo=bar
#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 ]; \
- }
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+ (qq_var) = val; \
+ True; \
+ }) \
+ )
-/* Unbounded integer arg */
-#define VG_NUM_CLO(qq_arg, qq_option, qq_var) \
- if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \
+// Unbounded integer arg, eg. --foo=10
+#define VG_INT_CLO(qq_arg, qq_option, qq_var) \
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
Char* s; \
- Long n = VG_(strtoll10)( &qq_arg[ VG_(strlen)(qq_option)+1 ], &s );\
+ Long n = VG_(strtoll10)( val, &s ); \
(qq_var) = n; \
- /* Check for non-numeralness, or overflow */ \
+ /* Check for non-numeralness, or overflow. */ \
if ('\0' != s[0] || (qq_var) != n) VG_(err_bad_option)(qq_arg); \
- }
+ True; \
+ }) \
+ )
-/* Bounded integer arg */
-#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"=")) { \
+// Bounded integer arg, eg. --foo=10 ; if the value exceeds the bounds it
+// causes an abort. 'qq_base' can be 10 or 16.
+#define VG_BINTN_CLO(qq_base, qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
Char* s; \
- Long n = VG_(strtoll10)( &qq_arg[ VG_(strlen)(qq_option)+1 ], &s );\
+ Long n = VG_(strtoll##qq_base)( val, &s ); \
(qq_var) = n; \
- /* Check for non-numeralness, or overflow */ \
+ /* Check for non-numeralness, or overflow. */ \
+ /* Nb: it will overflow if qq_var is unsigned and qq_val is negative! */ \
if ('\0' != s[0] || (qq_var) != n) VG_(err_bad_option)(qq_arg); \
- if ((qq_var) < (qq_lo)) (qq_var) = (qq_lo); \
- if ((qq_var) > (qq_hi)) (qq_var) = (qq_hi); \
- }
+ /* Check bounds. */ \
+ if ((qq_var) < (qq_lo) || (qq_var) > (qq_hi)) { \
+ VG_(message)(Vg_UserMsg, \
+ "'%s' argument must be between %lld and %lld", \
+ (qq_option), (Long)(qq_lo), (Long)(qq_hi)); \
+ VG_(err_bad_option)(qq_arg); \
+ } \
+ True; \
+ }) \
+ )
-/* Bounded hexadecimal arg */
+// Bounded decimal integer arg, eg. --foo=100
+#define VG_BINT_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
+ VG_BINTN_CLO(10, (qq_arg), qq_option, (qq_var), (qq_lo), (qq_hi))
+
+// Bounded hexadecimal integer arg, eg. --foo=0x1fa8
#define VG_BHEX_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
- if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \
- Char* s; \
- Long n = VG_(strtoll16)( &qq_arg[ VG_(strlen)(qq_option)+1 ], &s );\
- (qq_var) = n; \
- /* Check for non-numeralness, or overflow */ \
- if ('\0' != s[0] || (qq_var) != n) VG_(err_bad_option)(qq_arg); \
- if ((qq_...
[truncated message content] |
|
From: Nicholas N. <n.n...@gm...> - 2009-02-25 01:14:51
|
Hi, On my Mac, memcheck/tests/vcpu_fnfns fails due to some tiny FP differences (see below). I propose changing the test to omit the +/- at the start of the answers (to remove +0 and -0 differences), to print 12 decimal places rather than 13 (to remove the difference in the 13th decimal place), and possibly to filter the sign of the exponent if its zero (to remove the difference between 1.0000e-00 and 1.0000e+00). Does this sound reasonable? Nick 94,103c94,103 < ceilD(-9.0000000110000e-01) = -0.0000000000000e+00 < ceilD(-8.0000000120000e-01) = -0.0000000000000e+00 < ceilD(-7.0000000130000e-01) = -0.0000000000000e+00 < ceilD(-6.0000000140000e-01) = -0.0000000000000e+00 < ceilD(-5.0000000150000e-01) = -0.0000000000000e+00 < ceilD(-4.0000000160000e-01) = -0.0000000000000e+00 < ceilD(-3.0000000170000e-01) = -0.0000000000000e+00 < ceilD(-2.0000000180000e-01) = -0.0000000000000e+00 < ceilD(-1.0000000190000e-01) = -0.0000000000000e+00 < ceilD(-1.9999992495467e-09) = -0.0000000000000e+00 --- > ceilD(-9.0000000110000e-01) = +0.0000000000000e+00 > ceilD(-8.0000000120000e-01) = +0.0000000000000e+00 > ceilD(-7.0000000130000e-01) = +0.0000000000000e+00 > ceilD(-6.0000000140000e-01) = +0.0000000000000e+00 > ceilD(-5.0000000150000e-01) = +0.0000000000000e+00 > ceilD(-4.0000000160000e-01) = +0.0000000000000e+00 > ceilD(-3.0000000170000e-01) = +0.0000000000000e+00 > ceilD(-2.0000000180000e-01) = +0.0000000000000e+00 > ceilD(-1.0000000190000e-01) = +0.0000000000000e+00 > ceilD(-1.9999992495467e-09) = +0.0000000000000e+00 135,144c135,144 < ceilF( -9.0110e-01) = -0.0000e+00 < ceilF( -8.0120e-01) = -0.0000e+00 < ceilF( -7.0130e-01) = -0.0000e+00 < ceilF( -6.0140e-01) = -0.0000e+00 < ceilF( -5.0150e-01) = -0.0000e+00 < ceilF( -4.0160e-01) = -0.0000e+00 < ceilF( -3.0170e-01) = -0.0000e+00 < ceilF( -2.0180e-01) = -0.0000e+00 < ceilF( -1.0190e-01) = -0.0000e+00 < ceilF( -1.9999e-03) = -0.0000e+00 --- > ceilF( -9.0110e-01) = +0.0000e+00 > ceilF( -8.0120e-01) = +0.0000e+00 > ceilF( -7.0130e-01) = +0.0000e+00 > ceilF( -6.0140e-01) = +0.0000e+00 > ceilF( -5.0150e-01) = +0.0000e+00 > ceilF( -4.0160e-01) = +0.0000e+00 > ceilF( -3.0170e-01) = +0.0000e+00 > ceilF( -2.0180e-01) = +0.0000e+00 > ceilF( -1.0190e-01) = +0.0000e+00 > ceilF( -1.9999e-03) = +0.0000e+00 308c308 < cosF( -1.9999e-03) = +1.0000e-00 --- > cosF( -1.9999e-03) = +1.0000e+00 539c539 < logD(+3.9999999960000e-01) = -9.1629073287415e-01 --- > logD(+3.9999999960000e-01) = -9.1629073287416e-01 620c620 < asinD(-9.0000000010000e-01) = -1.1197695152281e+00 --- > asinD(-9.0000000010000e-01) = -1.1197695152280e+00 |
Author: njn
Date: 2009-02-25 01:01:05 +0000 (Wed, 25 Feb 2009)
New Revision: 9255
Log:
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.
Modified:
trunk/cachegrind/cg_main.c
trunk/callgrind/clo.c
trunk/callgrind/sim.c
trunk/coregrind/m_demangle/vg_libciface.h
trunk/coregrind/m_libcbase.c
trunk/coregrind/m_libcproc.c
trunk/coregrind/m_main.c
trunk/coregrind/m_replacemalloc/replacemalloc_core.c
trunk/coregrind/m_syswrap/syswrap-generic.c
trunk/drd/drd_main.c
trunk/exp-ptrcheck/pc_common.c
trunk/helgrind/hg_main.c
trunk/include/pub_tool_libcbase.h
trunk/include/pub_tool_options.h
trunk/lackey/lk_main.c
trunk/massif/ms_main.c
trunk/memcheck/mc_main.c
Modified: trunk/cachegrind/cg_main.c
===================================================================
--- trunk/cachegrind/cg_main.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/cachegrind/cg_main.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -1645,50 +1645,48 @@
static void parse_cache_opt ( cache_t* cache, Char* opt )
{
- Int i = 0, i2, i3;
+ Long i1, i2, i3;
+ Char* endptr;
- // Option argument looks like "65536,2,64".
- // Find commas, replace with NULs to make three independent
- // strings, then extract numbers, put NULs back. Yuck.
- while (VG_(isdigit)(opt[i])) i++;
- if (',' == opt[i]) {
- opt[i++] = '\0';
- i2 = i;
- } else goto bad;
- while (VG_(isdigit)(opt[i])) i++;
- if (',' == opt[i]) {
- opt[i++] = '\0';
- i3 = i;
- } else goto bad;
- while (VG_(isdigit)(opt[i])) i++;
- if ('\0' != opt[i]) goto bad;
+ // Option argument looks like "65536,2,64". Extract them.
+ i1 = VG_(strtoll10)(opt, &endptr); if (*endptr != ',') goto bad;
+ i2 = VG_(strtoll10)(endptr+1, &endptr); if (*endptr != ',') goto bad;
+ i3 = VG_(strtoll10)(endptr+1, &endptr); if (*endptr != '\0') goto bad;
- cache->size = (Int)VG_(atoll)(opt);
- cache->assoc = (Int)VG_(atoll)(opt + i2);
- cache->line_size = (Int)VG_(atoll)(opt + i3);
+ // Check for overflow.
+ cache->size = (Int)i1;
+ cache->assoc = (Int)i2;
+ cache->line_size = (Int)i3;
+ if (cache->size != i1) goto overflow;
+ if (cache->assoc != i2) goto overflow;
+ if (cache->line_size != i3) goto overflow;
- opt[i2-1] = ',';
- opt[i3-1] = ',';
return;
+ overflow:
+ VG_(message)(Vg_UserMsg,
+ "one of the cache parameters was too large and overflowed\n");
bad:
+ // XXX: this omits the "--I1/D1/L2=" part from the message, but that's
+ // not a big deal.
VG_(err_bad_option)(opt);
}
static Bool cg_process_cmd_line_option(Char* arg)
{
+ Char* tmp_str;
+
// 5 is length of "--I1="
- if (VG_CLO_STREQN(5, arg, "--I1="))
- parse_cache_opt(&clo_I1_cache, &arg[5]);
- else if (VG_CLO_STREQN(5, arg, "--D1="))
- parse_cache_opt(&clo_D1_cache, &arg[5]);
- else if (VG_CLO_STREQN(5, arg, "--L2="))
- parse_cache_opt(&clo_L2_cache, &arg[5]);
- else if (VG_CLO_STREQN(22, arg, "--cachegrind-out-file=")) {
- clo_cachegrind_out_file = &arg[22];
- }
- else VG_BOOL_CLO(arg, "--cache-sim", clo_cache_sim)
- else VG_BOOL_CLO(arg, "--branch-sim", clo_branch_sim)
+ if VG_STR_CLO(arg, "--I1", tmp_str)
+ parse_cache_opt(&clo_I1_cache, tmp_str);
+ else if VG_STR_CLO(arg, "--D1", tmp_str)
+ parse_cache_opt(&clo_D1_cache, tmp_str);
+ else if VG_STR_CLO(arg, "--L2", tmp_str)
+ parse_cache_opt(&clo_L2_cache, tmp_str);
+
+ else if VG_STR_CLO( arg, "--cachegrind-out-file", clo_cachegrind_out_file) {}
+ else if VG_BOOL_CLO(arg, "--cache-sim", clo_cache_sim) {}
+ else if VG_BOOL_CLO(arg, "--branch-sim", clo_branch_sim) {}
else
return False;
Modified: trunk/callgrind/clo.c
===================================================================
--- trunk/callgrind/clo.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/callgrind/clo.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -395,252 +395,128 @@
/*--- Command line processing ---*/
/*--------------------------------------------------------------------*/
-static Char* getUInt(Char* s, UInt* pn)
-{
- UInt n = 0;
- while((*s >='0') && (*s <='9')) {
- n = 10*n + (*s-'0');
- s++;
- }
- if (pn) *pn = n;
- return s;
-}
-
-__attribute__((unused))
-static UWord getUWord(Char* s)
-{
- UWord n = 0;
- Bool isHex = False;
-
- if ((s[0] == '0') && (s[1] == 'x')) {
- isHex = True;
- s += 2;
- }
-
- if (!isHex) {
- while((*s >='0') && (*s <='9')) {
- n = 10*n + (*s-'0');
- s++;
- }
- }
- else {
- while(1) {
- if ((*s >='0') && (*s <='9')) {
- n = 16*n + (*s-'0');
- s++;
- continue;
- }
- if ((*s >='a') && (*s <='f')) {
- n = 16*n + (*s-'a'+10);
- s++;
- continue;
- }
- if ((*s >='A') && (*s <='F')) {
- n = 16*n + (*s-'A'+10);
- s++;
- continue;
- }
- break;
- }
- }
-
- return n;
-}
-
Bool CLG_(process_cmd_line_option)(Char* arg)
{
- if (0 == VG_(strcmp)(arg, "--skip-plt=yes"))
- CLG_(clo).skip_plt = True;
- else if (0 == VG_(strcmp)(arg, "--skip-plt=no"))
- CLG_(clo).skip_plt = False;
+ Char* tmp_str;
- else if (0 == VG_(strcmp)(arg, "--collect-jumps=yes"))
- CLG_(clo).collect_jumps = True;
- else if (0 == VG_(strcmp)(arg, "--collect-jumps=no"))
- CLG_(clo).collect_jumps = False;
+ if VG_BOOL_CLO(arg, "--skip-plt", CLG_(clo).skip_plt) {}
+
+ else if VG_BOOL_CLO(arg, "--collect-jumps", CLG_(clo).collect_jumps) {}
/* compatibility alias, deprecated option */
- else if (0 == VG_(strcmp)(arg, "--trace-jump=yes"))
- CLG_(clo).collect_jumps = True;
- else if (0 == VG_(strcmp)(arg, "--trace-jump=no"))
- CLG_(clo).collect_jumps = False;
+ else if VG_BOOL_CLO(arg, "--trace-jump", CLG_(clo).collect_jumps) {}
- else if (0 == VG_(strcmp)(arg, "--combine-dumps=yes"))
- CLG_(clo).combine_dumps = True;
- else if (0 == VG_(strcmp)(arg, "--combine-dumps=no"))
- CLG_(clo).combine_dumps = False;
+ else if VG_BOOL_CLO(arg, "--combine-dumps", CLG_(clo).combine_dumps) {}
- else if (0 == VG_(strcmp)(arg, "--collect-atstart=yes"))
- CLG_(clo).collect_atstart = True;
- else if (0 == VG_(strcmp)(arg, "--collect-atstart=no"))
- CLG_(clo).collect_atstart = False;
+ else if VG_BOOL_CLO(arg, "--collect-atstart", CLG_(clo).collect_atstart) {}
- else if (0 == VG_(strcmp)(arg, "--instr-atstart=yes"))
- CLG_(clo).instrument_atstart = True;
- else if (0 == VG_(strcmp)(arg, "--instr-atstart=no"))
- CLG_(clo).instrument_atstart = False;
+ else if VG_BOOL_CLO(arg, "--instr-atstart", CLG_(clo).instrument_atstart) {}
- else if (0 == VG_(strcmp)(arg, "--separate-threads=yes"))
- CLG_(clo).separate_threads = True;
- else if (0 == VG_(strcmp)(arg, "--separate-threads=no"))
- CLG_(clo).separate_threads = False;
+ else if VG_BOOL_CLO(arg, "--separate-threads", CLG_(clo).separate_threads) {}
- else if (0 == VG_(strcmp)(arg, "--compress-strings=yes"))
- CLG_(clo).compress_strings = True;
- else if (0 == VG_(strcmp)(arg, "--compress-strings=no"))
- CLG_(clo).compress_strings = False;
+ else if VG_BOOL_CLO(arg, "--compress-strings", CLG_(clo).compress_strings) {}
+ else if VG_BOOL_CLO(arg, "--compress-mangled", CLG_(clo).compress_mangled) {}
+ else if VG_BOOL_CLO(arg, "--compress-pos", CLG_(clo).compress_pos) {}
- else if (0 == VG_(strcmp)(arg, "--compress-mangled=yes"))
- CLG_(clo).compress_mangled = True;
- else if (0 == VG_(strcmp)(arg, "--compress-mangled=no"))
- CLG_(clo).compress_mangled = False;
-
- else if (0 == VG_(strcmp)(arg, "--compress-pos=yes"))
- CLG_(clo).compress_pos = True;
- else if (0 == VG_(strcmp)(arg, "--compress-pos=no"))
- CLG_(clo).compress_pos = False;
-
- else if (0 == VG_(strncmp)(arg, "--fn-skip=", 10)) {
- fn_config* fnc = get_fnc(arg+10);
+ else if VG_STR_CLO(arg, "--fn-skip", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->skip = CONFIG_TRUE;
}
- else if (0 == VG_(strncmp)(arg, "--dump-before=", 14)) {
- fn_config* fnc = get_fnc(arg+14);
+ else if VG_STR_CLO(arg, "--dump-before", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->dump_before = CONFIG_TRUE;
}
- else if (0 == VG_(strncmp)(arg, "--zero-before=", 14)) {
- fn_config* fnc = get_fnc(arg+14);
+ else if VG_STR_CLO(arg, "--zero-before", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->zero_before = CONFIG_TRUE;
}
- else if (0 == VG_(strncmp)(arg, "--dump-after=", 13)) {
- fn_config* fnc = get_fnc(arg+13);
+ else if VG_STR_CLO(arg, "--dump-after", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->dump_after = CONFIG_TRUE;
}
- else if (0 == VG_(strncmp)(arg, "--toggle-collect=", 17)) {
- fn_config* fnc = get_fnc(arg+17);
+ else if VG_STR_CLO(arg, "--toggle-collect", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->toggle_collect = CONFIG_TRUE;
/* defaults to initial collection off */
CLG_(clo).collect_atstart = False;
}
- else if (0 == VG_(strncmp)(arg, "--separate-recs=", 16))
- CLG_(clo).separate_recursions = (Int)VG_(atoll)(&arg[16]);
+ else if VG_INT_CLO(arg, "--separate-recs", CLG_(clo).separate_recursions) {}
/* change handling of a jump between functions to ret+call */
- else if (0 == VG_(strcmp)(arg, "--pop-on-jump")) {
- CLG_(clo).pop_on_jump = True;
- }
- else if (0 == VG_(strncmp)(arg, "--pop-on-jump=", 14)) {
- fn_config* fnc = get_fnc(arg+14);
+ else if VG_XACT_CLO(arg, "--pop-on-jump", CLG_(clo).pop_on_jump, True) {}
+ else if VG_STR_CLO( arg, "--pop-on-jump", tmp_str) {
+ fn_config* fnc = get_fnc(tmp_str);
fnc->pop_on_jump = CONFIG_TRUE;
}
#if CLG_ENABLE_DEBUG
- else if (0 == VG_(strncmp)(arg, "--ct-verbose=", 13))
- CLG_(clo).verbose = (Int)VG_(atoll)(&arg[13]);
+ else if VG_INT_CLO(arg, "--ct-verbose", CLG_(clo).verbose) {}
+ else if VG_INT_CLO(arg, "--ct-vstart", CLG_(clo).verbose_start) {}
- else if (0 == VG_(strncmp)(arg, "--ct-vstart=", 12))
- CLG_(clo).verbose_start = (ULong)VG_(atoll)(&arg[12]);
-
- else if (0 == VG_(strncmp)(arg, "--ct-verbose", 12)) {
- UInt n;
+ else if VG_STREQN(12, arg, "--ct-verbose") {
fn_config* fnc;
- Char* s = getUInt(arg+12, &n);
- if ((n == 0) || *s != '=') return False;
+ Char* s;
+ UInt n = VG_(strtoll10)(arg+12, &s);
+ if ((n <= 0) || *s != '=') return False;
fnc = get_fnc(s+1);
fnc->verbosity = n;
}
#endif
- else if (0 == VG_(strncmp)(arg, "--separate-callers=", 19)) {
- if (0 == VG_(strcmp)(arg+19, "auto"))
- CLG_(clo).separate_callers = CONFIG_AUTO;
- else
- CLG_(clo).separate_callers = (Int)VG_(atoll)(&arg[19]);
- }
+ else if VG_XACT_CLO(arg, "--separate-callers=auto",
+ CLG_(clo).separate_callers, CONFIG_AUTO) {}
+ else if VG_INT_CLO( arg, "--separate-callers",
+ CLG_(clo).separate_callers) {}
- else if (0 == VG_(strncmp)(arg, "--fn-group", 10)) {
- UInt n;
+ else if VG_STREQN(10, arg, "--fn-group") {
fn_config* fnc;
- Char* s = getUInt(arg+10, &n);
- if ((n == 0) || *s != '=') return False;
+ Char* s;
+ UInt n = VG_(strtoll10)(arg+10, &s);
+ if ((n <= 0) || *s != '=') return False;
fnc = get_fnc(s+1);
fnc->group = n;
}
- else if (0 == VG_(strncmp)(arg, "--separate-callers", 18)) {
- UInt n;
+ else if VG_STREQN(18, arg, "--separate-callers") {
fn_config* fnc;
- Char* s = getUInt(arg+18, &n);
- if ((n == 0) || *s != '=') return False;
+ Char* s;
+ UInt n = VG_(strtoll10)(arg+18, &s);
+ if ((n <= 0) || *s != '=') return False;
fnc = get_fnc(s+1);
fnc->separate_callers = n;
}
- else if (0 == VG_(strncmp)(arg, "--separate-recs", 15)) {
- UInt n;
+ else if VG_STREQN(15, arg, "--separate-recs") {
fn_config* fnc;
- Char* s = getUInt(arg+15, &n);
- if ((n == 0) || *s != '=') return False;
+ Char* s;
+ UInt n = VG_(strtoll10)(arg+15, &s);
+ if ((n <= 0) || *s != '=') return False;
fnc = get_fnc(s+1);
fnc->separate_recursions = n;
}
- else if (0 == VG_(strncmp)(arg, "--callgrind-out-file=", 21))
- CLG_(clo).out_format = VG_(strdup)("cl.clo.pclo.1", arg+21);
+ else if VG_STR_CLO(arg, "--callgrind-out-file", CLG_(clo).out_format) {}
- else if (0 == VG_(strcmp)(arg, "--mangle-names=yes"))
- CLG_(clo).mangle_names = True;
- else if (0 == VG_(strcmp)(arg, "--mangle-names=no"))
- CLG_(clo).mangle_names = False;
+ else if VG_BOOL_CLO(arg, "--mangle-names", CLG_(clo).mangle_names) {}
- else if (0 == VG_(strcmp)(arg, "--skip-direct-rec=yes"))
- CLG_(clo).skip_direct_recursion = True;
- else if (0 == VG_(strcmp)(arg, "--skip-direct-rec=no"))
- CLG_(clo).skip_direct_recursion = False;
+ else if VG_BOOL_CLO(arg, "--skip-direct-rec",
+ CLG_(clo).skip_direct_recursion) {}
- else if (0 == VG_(strcmp)(arg, "--dump-bbs=yes"))
- CLG_(clo).dump_bbs = True;
- else if (0 == VG_(strcmp)(arg, "--dump-bbs=no"))
- CLG_(clo).dump_bbs = False;
+ else if VG_BOOL_CLO(arg, "--dump-bbs", CLG_(clo).dump_bbs) {}
+ else if VG_BOOL_CLO(arg, "--dump-line", CLG_(clo).dump_line) {}
+ else if VG_BOOL_CLO(arg, "--dump-instr", CLG_(clo).dump_instr) {}
+ else if VG_BOOL_CLO(arg, "--dump-bb", CLG_(clo).dump_bb) {}
- else if (0 == VG_(strcmp)(arg, "--dump-line=yes"))
- CLG_(clo).dump_line = True;
- else if (0 == VG_(strcmp)(arg, "--dump-line=no"))
- CLG_(clo).dump_line = False;
+ else if VG_INT_CLO( arg, "--dump-every-bb", CLG_(clo).dump_every_bb) {}
- else if (0 == VG_(strcmp)(arg, "--dump-instr=yes"))
- CLG_(clo).dump_instr = True;
- else if (0 == VG_(strcmp)(arg, "--dump-instr=no"))
- CLG_(clo).dump_instr = False;
+ else if VG_BOOL_CLO(arg, "--collect-alloc", CLG_(clo).collect_alloc) {}
+ else if VG_BOOL_CLO(arg, "--collect-systime", CLG_(clo).collect_systime) {}
+ else if VG_BOOL_CLO(arg, "--simulate-cache", CLG_(clo).simulate_cache) {}
- else if (0 == VG_(strcmp)(arg, "--dump-bb=yes"))
- CLG_(clo).dump_bb = True;
- else if (0 == VG_(strcmp)(arg, "--dump-bb=no"))
- CLG_(clo).dump_bb = False;
-
- else if (0 == VG_(strncmp)(arg, "--dump-every-bb=", 16))
- CLG_(clo).dump_every_bb = (ULong)VG_(atoll)(&arg[16]);
-
-
- else if (0 == VG_(strcmp)(arg, "--collect-alloc=yes"))
- CLG_(clo).collect_alloc = True;
- else if (0 == VG_(strcmp)(arg, "--collect-alloc=no"))
- CLG_(clo).collect_alloc = False;
-
- else if (0 == VG_(strcmp)(arg, "--collect-systime=yes"))
- CLG_(clo).collect_systime = True;
- else if (0 == VG_(strcmp)(arg, "--collect-systime=no"))
- CLG_(clo).collect_systime = False;
-
- else if (0 == VG_(strcmp)(arg, "--simulate-cache=yes"))
- CLG_(clo).simulate_cache = True;
- else if (0 == VG_(strcmp)(arg, "--simulate-cache=no"))
- CLG_(clo).simulate_cache = False;
-
else {
Bool isCachesimOption = (*CLG_(cachesim).parse_opt)(arg);
Modified: trunk/callgrind/sim.c
===================================================================
--- trunk/callgrind/sim.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/callgrind/sim.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -1506,40 +1506,33 @@
);
}
-static void parse_opt ( cache_t* cache, char* orig_opt, int opt_len )
+static void parse_opt ( cache_t* cache, char* opt )
{
- int i1, i2, i3;
- int i;
- char *opt = VG_(strdup)("cl.sim.po.1", orig_opt);
+ Long i1, i2, i3;
+ Char* endptr;
- i = i1 = opt_len;
+ // Option argument looks like "65536,2,64". Extract them.
+ i1 = VG_(strtoll10)(opt, &endptr); if (*endptr != ',') goto bad;
+ i2 = VG_(strtoll10)(endptr+1, &endptr); if (*endptr != ',') goto bad;
+ i3 = VG_(strtoll10)(endptr+1, &endptr); if (*endptr != '\0') goto bad;
- /* Option looks like "--I1=65536,2,64".
- * Find commas, replace with NULs to make three independent
- * strings, then extract numbers. Yuck. */
- while (VG_(isdigit)(opt[i])) i++;
- if (',' == opt[i]) {
- opt[i++] = '\0';
- i2 = i;
- } else goto bad;
- while (VG_(isdigit)(opt[i])) i++;
- if (',' == opt[i]) {
- opt[i++] = '\0';
- i3 = i;
- } else goto bad;
- while (VG_(isdigit)(opt[i])) i++;
- if ('\0' != opt[i]) goto bad;
+ // Check for overflow.
+ cache->size = (Int)i1;
+ cache->assoc = (Int)i2;
+ cache->line_size = (Int)i3;
+ if (cache->size != i1) goto overflow;
+ if (cache->assoc != i2) goto overflow;
+ if (cache->line_size != i3) goto overflow;
- cache->size = (Int)VG_(atoll)(opt + i1);
- cache->assoc = (Int)VG_(atoll)(opt + i2);
- cache->line_size = (Int)VG_(atoll)(opt + i3);
-
- VG_(free)(opt);
-
return;
+ overflow:
+ VG_(message)(Vg_UserMsg,
+ "one of the cache parameters was too large and overflowed\n");
bad:
- VG_(err_bad_option)(orig_opt);
+ // XXX: this omits the "--I1/D1/L2=" part from the message, but that's
+ // not a big deal.
+ VG_(err_bad_option)(opt);
}
/* Check for command line option for cache configuration.
@@ -1549,36 +1542,25 @@
*/
static Bool cachesim_parse_opt(Char* arg)
{
- if (0 == VG_(strcmp)(arg, "--simulate-wb=yes"))
- clo_simulate_writeback = True;
- else if (0 == VG_(strcmp)(arg, "--simulate-wb=no"))
- clo_simulate_writeback = False;
+ Char* tmp_str;
- else if (0 == VG_(strcmp)(arg, "--simulate-hwpref=yes"))
- clo_simulate_hwpref = True;
- else if (0 == VG_(strcmp)(arg, "--simulate-hwpref=no"))
- clo_simulate_hwpref = False;
+ if VG_BOOL_CLO(arg, "--simulate-wb", clo_simulate_writeback) {}
+ else if VG_BOOL_CLO(arg, "--simulate-hwpref", clo_simulate_hwpref) {}
+ else if VG_BOOL_CLO(arg, "--simulate-sectors", clo_simulate_sectors) {}
- else if (0 == VG_(strcmp)(arg, "--simulate-sectors=yes"))
- clo_simulate_sectors = True;
- else if (0 == VG_(strcmp)(arg, "--simulate-sectors=no"))
- clo_simulate_sectors = False;
+ else if VG_BOOL_CLO(arg, "--cacheuse", clo_collect_cacheuse) {
+ if (clo_collect_cacheuse) {
+ /* Use counters only make sense with fine dumping */
+ CLG_(clo).dump_instr = True;
+ }
+ }
- else if (0 == VG_(strcmp)(arg, "--cacheuse=yes")) {
- clo_collect_cacheuse = True;
- /* Use counters only make sense with fine dumping */
- CLG_(clo).dump_instr = True;
- }
- else if (0 == VG_(strcmp)(arg, "--cacheuse=no"))
- clo_collect_cacheuse = False;
-
- /* 5 is length of "--I1=" */
- else if (0 == VG_(strncmp)(arg, "--I1=", 5))
- parse_opt(&clo_I1_cache, arg, 5);
- else if (0 == VG_(strncmp)(arg, "--D1=", 5))
- parse_opt(&clo_D1_cache, arg, 5);
- else if (0 == VG_(strncmp)(arg, "--L2=", 5))
- parse_opt(&clo_L2_cache, arg, 5);
+ else if VG_STR_CLO(arg, "--I1", tmp_str)
+ parse_opt(&clo_I1_cache, tmp_str);
+ else if VG_STR_CLO(arg, "--D1", tmp_str)
+ parse_opt(&clo_D1_cache, tmp_str);
+ else if VG_STR_CLO(arg, "--L2", tmp_str)
+ parse_opt(&clo_L2_cache, tmp_str);
else
return False;
Modified: trunk/coregrind/m_demangle/vg_libciface.h
===================================================================
--- trunk/coregrind/m_demangle/vg_libciface.h 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/coregrind/m_demangle/vg_libciface.h 2009-02-25 01:01:05 UTC (rev 9255)
@@ -45,7 +45,7 @@
#define abort() vg_assert(0)
-#define atoi(_str) VG_(atoll)((_str))
+#define atoi(_str) VG_(strtoll10)((_str), NULL)
#define free(_pt) VG_(arena_free) (VG_AR_DEMANGLE,(_pt))
#define memcmp(_s1,_s2,_sz) VG_(memcmp)((_s1),(_s2),(_sz))
#define memcpy(_dd,_ss,_sz) VG_(memcpy)((_dd),(_ss),(_sz))
Modified: trunk/coregrind/m_libcbase.c
===================================================================
--- trunk/coregrind/m_libcbase.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/coregrind/m_libcbase.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -155,16 +155,6 @@
return n;
}
-Long VG_(atoll) ( Char* str )
-{
- return VG_(strtoll10)(str, NULL);
-}
-
-Long VG_(atoll16) ( Char* str )
-{
- return VG_(strtoll16)(str, NULL);
-}
-
/* ---------------------------------------------------------------------
String functions
------------------------------------------------------------------ */
Modified: trunk/coregrind/m_libcproc.c
===================================================================
--- trunk/coregrind/m_libcproc.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/coregrind/m_libcproc.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -401,8 +401,13 @@
res = VG_(do_syscall3)(__NR_readlink, (UWord)"/proc/self",
(UWord)pid, sizeof(pid));
if (!res.isError && res.res > 0) {
+ Char* s;
pid[res.res] = '\0';
- res.res = VG_(atoll)(pid);
+ res.res = VG_(strtoll10)(pid, &s);
+ if (*s != '\0') {
+ VG_(message)(Vg_DebugMsg,
+ "Warning: invalid file name linked to by /proc/self: %s", pid);
+ }
}
}
Modified: trunk/coregrind/m_main.c
===================================================================
--- trunk/coregrind/m_main.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/coregrind/m_main.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -273,31 +273,25 @@
str = * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i );
vg_assert(str);
- if (VG_STREQ(str, "--version")) {
- // Ensure the version string goes to stdout
- VG_(clo_log_fd) = 1;
+ // Nb: the version string goes to stdout.
+ if VG_XACT_CLO(str, "--version", VG_(clo_log_fd), 1) {
VG_(printf)("valgrind-" VERSION "\n");
VG_(exit)(0);
+ }
+ else if VG_XACT_CLO(str, "--help", *need_help, 1) {}
+ else if VG_XACT_CLO(str, "-h", *need_help, 1) {}
- } else if (VG_CLO_STREQ(str, "--help") ||
- VG_CLO_STREQ(str, "-h")) {
- *need_help = 1;
+ else if VG_XACT_CLO(str, "--help-debug", *need_help, 2) {}
- } else if (VG_CLO_STREQ(str, "--help-debug")) {
- *need_help = 2;
-
// The tool has already been determined, but we need to know the name
// here.
- } else if (VG_CLO_STREQN(7, str, "--tool=")) {
- *tool = &str[7];
+ else if VG_STR_CLO(str, "--tool", *tool) {}
// Set up VG_(clo_max_stackframe) and VG_(clo_main_stacksize).
// These are needed by VG_(ii_create_image), which happens
// before main_process_cmd_line_options().
- }
- else VG_NUM_CLO(str, "--max-stackframe", VG_(clo_max_stackframe))
- else VG_NUM_CLO(str, "--main-stacksize", VG_(clo_main_stacksize));
-
+ else if VG_INT_CLO(str, "--max-stackframe", VG_(clo_max_stackframe)) {}
+ else if VG_INT_CLO(str, "--main-stacksize", VG_(clo_main_stacksize)) {}
}
}
@@ -312,6 +306,7 @@
SysRes sres;
Int i, tmp_log_fd;
Int toolname_len = VG_(strlen)(toolname);
+ Char* tmp_str; // Used in a couple of places.
enum {
VgLogTo_Fd,
VgLogTo_File,
@@ -341,9 +336,9 @@
// in case someone has combined a prefix with a core-specific option,
// eg. "--memcheck:verbose".
if (*colon == ':') {
- if (VG_CLO_STREQN(2, arg, "--") &&
- VG_CLO_STREQN(toolname_len, arg+2, toolname) &&
- VG_CLO_STREQN(1, arg+2+toolname_len, ":"))
+ if (VG_STREQN(2, arg, "--") &&
+ VG_STREQN(toolname_len, arg+2, toolname) &&
+ VG_STREQN(1, arg+2+toolname_len, ":"))
{
// Prefix matches, convert "--toolname:foo" to "--foo".
// Two things to note:
@@ -373,134 +368,124 @@
}
/* Ignore these options - they've already been handled */
- if (VG_CLO_STREQN( 7, arg, "--tool=")) { }
- else if (VG_CLO_STREQN(20, arg, "--command-line-only=")) { }
- else if (VG_CLO_STREQ(arg, "--")) { }
- else if (VG_CLO_STREQ(arg, "-d")) { }
+ if VG_STREQN( 7, arg, "--tool=") {}
+ else if VG_STREQN(20, arg, "--command-line-only=") {}
+ else if VG_STREQ( arg, "--") {}
+ else if VG_STREQ( arg, "-d") {}
+ else if VG_STREQN(16, arg, "--max-stackframe") {}
+ else if VG_STREQN(16, arg, "--main-stacksize") {}
+ else if VG_STREQN(14, arg, "--profile-heap") {}
- else if (VG_CLO_STREQ(arg, "-v") ||
- VG_CLO_STREQ(arg, "--verbose"))
+ // These options are new.
+ else if (VG_STREQ(arg, "-v") ||
+ VG_STREQ(arg, "--verbose"))
VG_(clo_verbosity)++;
- else if (VG_CLO_STREQ(arg, "-q") ||
- VG_CLO_STREQ(arg, "--quiet"))
+ else if (VG_STREQ(arg, "-q") ||
+ VG_STREQ(arg, "--quiet"))
VG_(clo_verbosity)--;
- else VG_BOOL_CLO(arg, "--xml", VG_(clo_xml))
- 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_NUM_CLO (arg, "--error-exitcode", VG_(clo_error_exitcode))
- else VG_BOOL_CLO(arg, "--show-emwarns", VG_(clo_show_emwarns))
+ else if VG_BOOL_CLO(arg, "--xml", VG_(clo_xml)) {}
+ else if VG_BOOL_CLO(arg, "--db-attach", VG_(clo_db_attach)) {}
+ else if VG_BOOL_CLO(arg, "--demangle", VG_(clo_demangle)) {}
+ else if VG_BOOL_CLO(arg, "--error-limit", VG_(clo_error_limit)) {}
+ else if VG_INT_CLO (arg, "--error-exitcode", VG_(clo_error_exitcode)) {}
+ else if VG_BOOL_CLO(arg, "--show-emwarns", VG_(clo_show_emwarns)) {}
- /* The next two are already done in
- early_process_cmd_line_options, but we need to redundantly
- handle them again, so they do not get rejected as invalid. */
- else VG_NUM_CLO (arg, "--max-stackframe", VG_(clo_max_stackframe))
- else VG_NUM_CLO (arg, "--main-stacksize", VG_(clo_main_stacksize))
+ else if VG_BOOL_CLO(arg, "--run-libc-freeres", VG_(clo_run_libc_freeres)) {}
+ else if VG_BOOL_CLO(arg, "--show-below-main", VG_(clo_show_below_main)) {}
+ else if VG_BOOL_CLO(arg, "--time-stamp", VG_(clo_time_stamp)) {}
+ else if VG_BOOL_CLO(arg, "--track-fds", VG_(clo_track_fds)) {}
+ else if VG_BOOL_CLO(arg, "--trace-children", VG_(clo_trace_children)) {}
+ else if VG_BOOL_CLO(arg, "--child-silent-after-fork",
+ VG_(clo_child_silent_after_fork)) {}
+ else if VG_BOOL_CLO(arg, "--trace-sched", VG_(clo_trace_sched)) {}
+ else if VG_BOOL_CLO(arg, "--trace-signals", VG_(clo_trace_signals)) {}
+ else if VG_BOOL_CLO(arg, "--trace-symtab", VG_(clo_trace_symtab)) {}
+ else if VG_STR_CLO (arg, "--trace-symtab-patt", VG_(clo_trace_symtab_patt)) {}
+ else if VG_BOOL_CLO(arg, "--trace-cfi", VG_(clo_trace_cfi)) {}
+ else if VG_XACT_CLO(arg, "--debug-dump=syms", VG_(clo_debug_dump_syms),
+ True) {}
+ else if VG_XACT_CLO(arg, "--debug-dump=line", VG_(clo_debug_dump_line),
+ True) {}
+ else if VG_XACT_CLO(arg, "--debug-dump=frames",
+ VG_(clo_debug_dump_frames), True) {}
+ else if VG_BOOL_CLO(arg, "--trace-redir", VG_(clo_trace_redir)) {}
- 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, "--child-silent-after-fork",
- VG_(clo_child_silent_after_fork))
- 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_STR_CLO (arg, "--trace-symtab-patt", VG_(clo_trace_symtab_patt))
- else VG_BOOL_CLO(arg, "--trace-cfi", VG_(clo_trace_cfi))
- else VG_XACT_CLO(arg, "--debug-dump=syms", VG_(clo_debug_dump_syms))
- else VG_XACT_CLO(arg, "--debug-dump=line", VG_(clo_debug_dump_line))
- else VG_XACT_CLO(arg, "--debug-dump=frames", VG_(clo_debug_dump_frames))
- else VG_BOOL_CLO(arg, "--trace-redir", VG_(clo_trace_redir))
+ else if VG_BOOL_CLO(arg, "--trace-syscalls", VG_(clo_trace_syscalls)) {}
+ else if VG_BOOL_CLO(arg, "--wait-for-gdb", VG_(clo_wait_for_gdb)) {}
+ else if VG_STR_CLO (arg, "--db-command", VG_(clo_db_command)) {}
+ else if VG_STR_CLO (arg, "--sim-hints", VG_(clo_sim_hints)) {}
+ else if VG_BOOL_CLO(arg, "--sym-offsets", VG_(clo_sym_offsets)) {}
+ else if VG_BOOL_CLO(arg, "--read-var-info", VG_(clo_read_var_info)) {}
- else VG_BOOL_CLO(arg, "--trace-syscalls", VG_(clo_trace_syscalls))
- else VG_BOOL_CLO(arg, "--wait-for-gdb", VG_(clo_wait_for_gdb))
- else VG_STR_CLO (arg, "--db-command", VG_(clo_db_command))
- else VG_STR_CLO (arg, "--sim-hints", VG_(clo_sim_hints))
- else VG_BOOL_CLO(arg, "--sym-offsets", VG_(clo_sym_offsets))
- else VG_BOOL_CLO(arg, "--read-var-info", VG_(clo_read_var_info))
+ else if VG_INT_CLO (arg, "--dump-error", VG_(clo_dump_error)) {}
+ else if VG_INT_CLO (arg, "--input-fd", VG_(clo_input_fd)) {}
+ else if VG_INT_CLO (arg, "--sanity-level", VG_(clo_sanity_level)) {}
+ else if VG_BINT_CLO(arg, "--num-callers", VG_(clo_backtrace_size), 1,
+ VG_DEEPEST_BACKTRACE) {}
- 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 if VG_XACT_CLO(arg, "--smc-check=none", VG_(clo_smc_check),
+ Vg_SmcNone);
+ else if VG_XACT_CLO(arg, "--smc-check=stack", VG_(clo_smc_check),
+ Vg_SmcStack);
+ else if VG_XACT_CLO(arg, "--smc-check=all", VG_(clo_smc_check),
+ Vg_SmcAll);
- else if (VG_CLO_STREQ(arg, "--smc-check=none"))
- VG_(clo_smc_check) = Vg_SmcNone;
- else if (VG_CLO_STREQ(arg, "--smc-check=stack"))
- VG_(clo_smc_check) = Vg_SmcStack;
- else if (VG_CLO_STREQ(arg, "--smc-check=all"))
- VG_(clo_smc_check) = Vg_SmcAll;
+ else if VG_STR_CLO (arg, "--kernel-variant", VG_(clo_kernel_variant)) {}
- else if (VG_CLO_STREQ(arg, "--profile-heap=no"))
- ; /* We already handled it right at the top of valgrind_main.
- Just ignore. */
- else if (VG_CLO_STREQ(arg, "--profile-heap=yes"))
- ; /* ditto */
+ else if VG_BINT_CLO(arg, "--vex-iropt-verbosity",
+ VG_(clo_vex_control).iropt_verbosity, 0, 10) {}
+ else if VG_BINT_CLO(arg, "--vex-iropt-level",
+ VG_(clo_vex_control).iropt_level, 0, 2) {}
+ else if VG_BOOL_CLO(arg, "--vex-iropt-precise-memory-exns",
+ VG_(clo_vex_control).iropt_precise_memory_exns) {}
+ else if VG_BINT_CLO(arg, "--vex-iropt-unroll-thresh",
+ VG_(clo_vex_control).iropt_unroll_thresh, 0, 400) {}
+ else if VG_BINT_CLO(arg, "--vex-guest-max-insns",
+ VG_(clo_vex_control).guest_max_insns, 1, 100) {}
+ else if VG_BINT_CLO(arg, "--vex-guest-chase-thresh",
+ VG_(clo_vex_control).guest_chase_thresh, 0, 99) {}
- else VG_STR_CLO (arg, "--kernel-variant", VG_(clo_kernel_variant))
-
- else VG_BNUM_CLO(arg, "--vex-iropt-verbosity",
- VG_(clo_vex_control).iropt_verbosity, 0, 10)
- else VG_BNUM_CLO(arg, "--vex-iropt-level",
- VG_(clo_vex_control).iropt_level, 0, 2)
- else VG_BOOL_CLO(arg, "--vex-iropt-precise-memory-exns",
- VG_(clo_vex_control).iropt_precise_memory_exns)
- else VG_BNUM_CLO(arg, "--vex-iropt-unroll-thresh",
- VG_(clo_vex_control).iropt_unroll_thresh, 0, 400)
- else VG_BNUM_CLO(arg, "--vex-guest-max-insns",
- VG_(clo_vex_control).guest_max_insns, 1, 100)
- 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=")) {
- log_to = VgLogTo_Fd;
+ else if VG_INT_CLO(arg, "--log-fd", tmp_log_fd) {
+ log_to = VgLogTo_Fd;
VG_(clo_log_name) = NULL;
- tmp_log_fd = (Int)VG_(atoll)(&arg[9]);
}
- else if (VG_CLO_STREQN(11, arg, "--log-file=")) {
- log_to = VgLogTo_File;
- VG_(clo_log_name) = &arg[11];
+ else if VG_STR_CLO(arg, "--log-file", VG_(clo_log_name)) {
+ log_to = VgLogTo_File;
}
- else if (VG_CLO_STREQN(13, arg, "--log-socket=")) {
- log_to = VgLogTo_Socket;
- VG_(clo_log_name) = &arg[13];
+ else if VG_STR_CLO(arg, "--log-socket", VG_(clo_log_name)) {
+ log_to = VgLogTo_Socket;
}
- else if (VG_CLO_STREQN(19, arg, "--xml-user-comment=")) {
- VG_(clo_xml_user_comment) = &arg[19];
- }
+ else if VG_STR_CLO(arg, "--xml-user-comment",
+ VG_(clo_xml_user_comment)) {}
- else if (VG_CLO_STREQN(15, arg, "--suppressions=")) {
+ else if VG_STR_CLO(arg, "--suppressions", tmp_str) {
if (VG_(clo_n_suppressions) >= VG_CLO_MAX_SFILES) {
VG_(message)(Vg_UserMsg, "Too many suppression files specified.");
VG_(message)(Vg_UserMsg,
"Increase VG_CLO_MAX_SFILES and recompile.");
VG_(err_bad_option)(arg);
}
- VG_(clo_suppressions)[VG_(clo_n_suppressions)] = &arg[15];
+ VG_(clo_suppressions)[VG_(clo_n_suppressions)] = tmp_str;
VG_(clo_n_suppressions)++;
}
/* "stuvwxyz" --> stuvwxyz (binary) */
- else if (VG_CLO_STREQN(14, arg, "--trace-flags=")) {
+ else if VG_STR_CLO(arg, "--trace-flags", tmp_str) {
Int j;
- char* opt = & arg[14];
- if (8 != VG_(strlen)(opt)) {
+ if (8 != VG_(strlen)(tmp_str)) {
VG_(message)(Vg_UserMsg,
"--trace-flags argument must have 8 digits");
VG_(err_bad_option)(arg);
}
for (j = 0; j < 8; j++) {
- if ('0' == opt[j]) { /* do nothing */ }
- else if ('1' == opt[j]) VG_(clo_trace_flags) |= (1 << (7-j));
+ if ('0' == tmp_str[j]) { /* do nothing */ }
+ else if ('1' == tmp_str[j]) VG_(clo_trace_flags) |= (1 << (7-j));
else {
VG_(message)(Vg_UserMsg, "--trace-flags argument can only "
"contain 0s and 1s");
@@ -510,18 +495,17 @@
}
/* "stuvwxyz" --> stuvwxyz (binary) */
- else if (VG_CLO_STREQN(16, arg, "--profile-flags=")) {
+ else if VG_STR_CLO(arg, "--profile-flags", tmp_str) {
Int j;
- char* opt = & arg[16];
- if (8 != VG_(strlen)(opt)) {
+ if (8 != VG_(strlen)(tmp_str)) {
VG_(message)(Vg_UserMsg,
"--profile-flags argument must have 8 digits");
VG_(err_bad_option)(arg);
}
for (j = 0; j < 8; j++) {
- if ('0' == opt[j]) { /* do nothing */ }
- else if ('1' == opt[j]) VG_(clo_profile_flags) |= (1 << (7-j));
+ if ('0' == tmp_str[j]) { /* do nothing */ }
+ else if ('1' == tmp_str[j]) VG_(clo_profile_flags) |= (1 << (7-j));
else {
VG_(message)(Vg_UserMsg, "--profile-flags argument can only "
"contain 0s and 1s");
@@ -530,14 +514,14 @@
}
}
- else VG_NUM_CLO (arg, "--trace-notbelow", VG_(clo_trace_notbelow))
+ else if VG_INT_CLO (arg, "--trace-notbelow", VG_(clo_trace_notbelow)) {}
- else if (VG_CLO_STREQ(arg, "--gen-suppressions=no"))
- VG_(clo_gen_suppressions) = 0;
- else if (VG_CLO_STREQ(arg, "--gen-suppressions=yes"))
- VG_(clo_gen_suppressions) = 1;
- else if (VG_CLO_STREQ(arg, "--gen-suppressions=all"))
- VG_(clo_gen_suppressions) = 2;
+ else if VG_XACT_CLO(arg, "--gen-suppressions=no",
+ VG_(clo_gen_suppressions), 0) {}
+ else if VG_XACT_CLO(arg, "--gen-suppressions=yes",
+ VG_(clo_gen_suppressions), 1) {}
+ else if VG_XACT_CLO(arg, "--gen-suppressions=all",
+ VG_(clo_gen_suppressions), 2) {}
else if ( ! VG_(needs).command_line_options
|| ! VG_TDICT_CALL(tool_process_cmd_line_option, arg) ) {
@@ -1206,19 +1190,15 @@
// p: none
//--------------------------------------------------------------
/* Start the debugging-log system ASAP. First find out how many
- "-d"s were specified. This is a pre-scan of the command line. */
+ "-d"s were specified. This is a pre-scan of the command line. Also
+ get --profile-heap=yes which is needed by the time we start up dynamic
+ memory management. */
loglevel = 0;
for (i = 1; i < argc; i++) {
- if (argv[i][0] != '-')
- break;
- if (VG_STREQ(argv[i], "--"))
- break;
- if (VG_STREQ(argv[i], "-d"))
- loglevel++;
- if (VG_STREQ(argv[i], "--profile-heap=yes"))
- VG_(clo_profile_heap) = True;
- if (VG_STREQ(argv[i], "--profile-heap=no"))
- VG_(clo_profile_heap) = False;
+ if (argv[i][0] != '-') break;
+ if VG_STREQ(argv[i], "--") break;
+ if VG_STREQ(argv[i], "-d") loglevel++;
+ if VG_BOOL_CLO(argv[i], "--profile-heap", VG_(clo_profile_heap)) {}
}
/* ... and start the debug logger. Now we can safely emit logging
@@ -1330,6 +1310,7 @@
//--------------------------------------------------------------
// Start up the dynamic memory manager
// p: address space management
+ // p: getting --profile-heap
// In fact m_mallocfree is self-initialising, so there's no
// initialisation call to do. Instead, try a simple malloc/
// free pair right now to check that nothing is broken.
@@ -1481,7 +1462,9 @@
//--------------------------------------------------------------
// Load client executable, finding in $PATH if necessary
- // p: early_process_cmd_line_options() [for 'exec', 'need_help']
+ // p: early_process_cmd_line_options() [for 'exec', 'need_help',
+ // clo_max_stackframe,
+ // clo_main_stacksize]
// p: layout_remaining_space [so there's space]
//
// Set up client's environment
Modified: trunk/coregrind/m_replacemalloc/replacemalloc_core.c
===================================================================
--- trunk/coregrind/m_replacemalloc/replacemalloc_core.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/coregrind/m_replacemalloc/replacemalloc_core.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -53,13 +53,11 @@
Bool VG_(replacement_malloc_process_cmd_line_option)(Char* arg)
{
- if (VG_CLO_STREQN(12, arg, "--alignment=")) {
- VG_(clo_alignment) = (UInt)VG_(atoll)(&arg[12]);
-
- if (VG_(clo_alignment) < VG_MIN_MALLOC_SZB
- || VG_(clo_alignment) > 4096
- || VG_(log2)( VG_(clo_alignment) ) == -1 /* not a power of 2 */) {
- VG_(message)(Vg_UserMsg, "");
+ if VG_INT_CLO(arg, "--alignment", VG_(clo_alignment)) {
+ if (VG_(clo_alignment) < VG_MIN_MALLOC_SZB ||
+ VG_(clo_alignment) > 4096 ||
+ VG_(log2)( VG_(clo_alignment) ) == -1 /* not a power of 2 */)
+ {
VG_(message)(Vg_UserMsg,
"Invalid --alignment= setting. "
"Should be a power of 2, >= %d, <= 4096.", VG_MIN_MALLOC_SZB);
@@ -67,7 +65,7 @@
}
}
- else VG_BOOL_CLO(arg, "--trace-malloc", VG_(clo_trace_malloc))
+ else if VG_BOOL_CLO(arg, "--trace-malloc", VG_(clo_trace_malloc)) {}
else
return False;
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -750,11 +750,16 @@
goto out;
if (VG_(strcmp)(d.d_name, ".") && VG_(strcmp)(d.d_name, "..")) {
- Int fno = VG_(atoll)(d.d_name);
-
- if (fno != f.res)
- if (VG_(clo_track_fds))
- ML_(record_fd_open_named)(-1, fno);
+ Char* s;
+ Int fno = VG_(strtoll10)(d.d_name, &s);
+ if (*s == '\0') {
+ if (fno != f.res)
+ if (VG_(clo_track_fds))
+ ML_(record_fd_open_named)(-1, fno);
+ } else {
+ VG_(message)(Vg_DebugMsg,
+ "Warning: invalid file name in /proc/self/fd: %s", d.d_name);
+ }
}
VG_(lseek)(f.res, d.d_off, VKI_SEEK_SET);
Modified: trunk/drd/drd_main.c
===================================================================
--- trunk/drd/drd_main.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/drd/drd_main.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -83,27 +83,27 @@
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);
Modified: trunk/exp-ptrcheck/pc_common.c
===================================================================
--- trunk/exp-ptrcheck/pc_common.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/exp-ptrcheck/pc_common.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -64,9 +64,9 @@
Bool pc_process_cmd_line_options(Char* arg)
{
- VG_BOOL_CLO(arg, "--partial-loads-ok", h_clo_partial_loads_ok)
- /* else VG_BOOL_CLO(arg, "--lossage-check", h_clo_lossage_check) */
- else VG_BOOL_CLO(arg, "--enable-sg-checks", sg_clo_enable_sg_checks)
+ if VG_BOOL_CLO(arg, "--partial-loads-ok", h_clo_partial_loads_ok) {}
+ /* else if VG_BOOL_CLO(arg, "--lossage-check", h_clo_lossage_check) {} */
+ else if VG_BOOL_CLO(arg, "--enable-sg-checks", sg_clo_enable_sg_checks) {}
else
return VG_(replacement_malloc_process_cmd_line_option)(arg);
Modified: trunk/helgrind/hg_main.c
===================================================================
--- trunk/helgrind/hg_main.c 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/helgrind/hg_main.c 2009-02-25 01:01:05 UTC (rev 9255)
@@ -4009,39 +4009,32 @@
static Bool hg_process_cmd_line_option ( Char* arg )
{
- if (VG_CLO_STREQ(arg, "--track-lockorders=no"))
- HG_(clo_track_lockorders) = False;
- else if (VG_CLO_STREQ(arg, "--track-lockorders=yes"))
- HG_(clo_track_lockorders) = True;
+ Char* tmp_str;
- else if (VG_CLO_STREQ(arg, "--cmp-race-err-addrs=no"))
- HG_(clo_cmp_race_err_addrs) = False;
- else if (VG_CLO_STREQ(arg, "--cmp-race-err-addrs=yes"))
- HG_(clo_cmp_race_err_addrs) = True;
+ if VG_BOOL_CLO(arg, "--track-lockorders",
+ HG_(clo_track_lockorders)) {}
+ else if VG_BOOL_CLO(arg, "--cmp-race-err-addrs",
+ HG_(clo_cmp_race_err_addrs)) {}
+ else if VG_BOOL_CLO(arg, "--show-conflicts",
+ HG_(clo_show_conflicts)) {}
- else if (VG_CLO_STREQ(arg, "--show-conflicts=no"))
- HG_(clo_show_conflicts) = False;
- else if (VG_CLO_STREQ(arg, "--show-conflicts=yes"))
- HG_(clo_show_conflicts) = True;
-
/* If you change the 10k/10mill limits, remember to also change
them in assertions at the top of event_map_maybe_GC. */
- else VG_BNUM_CLO(arg, "--conflict-cache-size",
- HG_(clo_conflict_cache_size), 10*1000, 10*1000*1000)
+ else if VG_BINT_CLO(arg, "--conflict-cache-size",
+ HG_(clo_conflict_cache_size), 10*1000, 10*1000*1000) {}
/* "stuvwx" --> stuvwx (binary) */
- else if (VG_CLO_STREQN(18, arg, "--hg-sanity-flags=")) {
+ else if VG_STR_CLO(arg, "--hg-sanity-flags", tmp_str) {
Int j;
- Char* opt = & arg[18];
- if (6 != VG_(strlen)(opt)) {
+ if (6 != VG_(strlen)(tmp_str)) {
VG_(message)(Vg_UserMsg,
"--hg-sanity-flags argument must have 6 digits");
return False;
}
for (j = 0; j < 6; j++) {
- if ('0' == opt[j]) { /* do nothing */ }
- else if ('1' == opt[j]) HG_(clo_sanity_flags) |= (1 << (6-1-j));
+ if ('0' == tmp_str[j]) { /* do nothing */ }
+ else if ('1' == tmp_str[j]) HG_(clo_sanity_flags) |= (1 << (6-1-j));
else {
VG_(message)(Vg_UserMsg, "--hg-sanity-flags argument can "
"only contain 0s and 1s");
Modified: trunk/include/pub_tool_libcbase.h
===================================================================
--- trunk/include/pub_tool_libcbase.h 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/include/pub_tool_libcbase.h 2009-02-25 01:01:05 UTC (rev 9255)
@@ -51,32 +51,33 @@
// is set to the start of the string. None of them test that the number
// fits into 64 bits.
//
-// Nb: if you're wondering why we don't just have a single VG_(strtol) which
+// Nb: if you're wondering why we don't just have a single VG_(strtoll) which
// takes a base, it's because I wanted it to assert if it was given a bogus
// base (the standard glibc one sets 'errno' in this case). But
// m_libcbase.c doesn't import any code, not even vg_assert. --njn
+//
+// Nb: we also don't provide VG_(atoll*); these functions are worse than
+// useless because they don't do any error checking and so accept malformed
+// numbers and non-numbers -- eg. "123xyz" gives 123, and "foo" gives 0!
+// If you really want that behaviour, you can use "VG_(strtoll10)(str, NULL)".
extern Long VG_(strtoll10) ( Char* str, Char** endptr );
extern Long VG_(strtoll16) ( Char* str, Char** endptr );
- // Convert a string to a double. After leading whitespace is ignored, a
- // '+' or '-' is allowed, and then it accepts a non-empty sequence of
- // decimal digits possibly containing a '.'. Hexadecimal floats are not
- // accepted, nor are "fancy" floats (eg. "3.4e-5", "NAN").
+// Convert a string to a double. After leading whitespace is ignored, a
+// '+' or '-' is allowed, and then it accepts a non-empty sequence of
+// decimal digits possibly containing a '.'. Hexadecimal floats are not
+// accepted, nor are "fancy" floats (eg. "3.4e-5", "NAN").
extern double VG_(strtod) ( Char* str, Char** endptr );
- // These are just like their VG_(strtoll*) counterparts, except that you
- // cannot tell if an error occurred (because 0 is returned) or if there
- // is any trailing non-numeric characterws (eg. in "123xyz").
-extern Long VG_(atoll) ( Char* str ); // base 10
-extern Long VG_(atoll16) ( Char* str ); // base 16; leading 0x accepted
-
/* ---------------------------------------------------------------------
String functions and macros
------------------------------------------------------------------ */
-/* Use this for normal null-termination-style string comparison */
+/* Use this for normal null-termination-style string comparison. */
#define VG_STREQ(s1,s2) ( (s1 != NULL && s2 != NULL \
&& VG_(strcmp)((s1),(s2))==0) ? True : False )
+#define VG_STREQN(n,s1,s2) ( (s1 != NULL && s2 != NULL \
+ && VG_(strncmp)((s1),(s2),(n))==0) ? True : False )
extern SizeT VG_(strlen) ( const Char* str );
extern Char* VG_(strcat) ( Char* dest, const Char* src );
Modified: trunk/include/pub_tool_options.h
===================================================================
--- trunk/include/pub_tool_options.h 2009-02-24 23:59:52 UTC (rev 9254)
+++ trunk/include/pub_tool_options.h 2009-02-25 01:01:05 UTC (rev 9255)
@@ -34,71 +34,110 @@
#include "libvex.h" // for VexControl
-/* Use these for recognising tool command line options -- stops comparing
- once whitespace is reached. */
-#define VG_CLO_STREQ(s1,s2) (0==VG_(strcmp_ws)((s1),(s2)))
-#define VG_CLO_STREQN(nn,s1,s2) (0==VG_(strncmp_ws)((s1),(s2),(nn)))
+// Higher-level command-line option recognisers; use in if/else chains.
+// Note that they assign a value to the 'qq_var' argument. So often they
+// can be used like this:
+//
+// if VG_STR_CLO(arg, "--foo", clo_foo) { }
+//
+// But if you want to do further checking or processing, you can do this:
+//
+// if VG_STR_CLO(arg, "--foo", clo_foo) { <further checking or processing> }
+//
+// They use GNU statement expressions to do the qq_var assignment within a
+// conditional expression.
-/* Higher-level command-line option recognisers; use in if/else chains */
-
+// String argument, eg. --foo=yes or --foo=no
#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; }
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+ if VG_STREQ(val, "yes") (qq_var) = True; \
+ else if VG_STREQ(val, "no") (qq_var) = False; \
+ True; \
+ }) \
+ )
+// String argument, eg. --foo=bar
#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 ]; \
- }
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
+ (qq_var) = val; \
+ True; \
+ }) \
+ )
-/* Unbounded integer arg */
-#define VG_NUM_CLO(qq_arg, qq_option, qq_var) \
- if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \
+// Unbounded integer arg, eg. --foo=10
+#define VG_INT_CLO(qq_arg, qq_option, qq_var) \
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
Char* s; \
- Long n = VG_(strtoll10)( &qq_arg[ VG_(strlen)(qq_option)+1 ], &s );\
+ Long n = VG_(strtoll10)( val, &s ); \
(qq_var) = n; \
- /* Check for non-numeralness, or overflow */ \
+ /* Check for non-numeralness, or overflow. */ \
if ('\0' != s[0] || (qq_var) != n) VG_(err_bad_option)(qq_arg); \
- }
+ True; \
+ }) \
+ )
-/* Bounded integer arg */
-#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"=")) { \
+// Bounded integer arg, eg. --foo=10 ; if the value exceeds the bounds it
+// causes an abort. 'qq_base' can be 10 or 16.
+#define VG_BINTN_CLO(qq_base, qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
Char* s; \
- Long n = VG_(strtoll10)( &qq_arg[ VG_(strlen)(qq_option)+1 ], &s );\
+ Long n = VG_(strtoll##qq_base)( val, &s ); \
(qq_var) = n; \
- /* Check for non-numeralness, or overflow */ \
+ /* Check for non-numeralness, or overflow. */ \
+ /* Nb: it will overflow if qq_var is unsigned and qq_val is negative! */ \
if ('\0' != s[0] || (qq_var) != n) VG_(err_bad_option)(qq_arg); \
- if ((qq_var) < (qq_lo)) (qq_var) = (qq_lo); \
- if ((qq_var) > (qq_hi)) (qq_var) = (qq_hi); \
- }
+ /* Check bounds. */ \
+ if ((qq_var) < (qq_lo) || (qq_var) > (qq_hi)) { \
+ VG_(message)(Vg_UserMsg, \
+ "'%s' argument must be between %lld and %lld", \
+ (qq_option), (Long)(qq_lo), (Long)(qq_hi)); \
+ VG_(err_bad_option)(qq_arg); \
+ } \
+ True; \
+ }) \
+ )
-/* Bounded hexadecimal arg */
+// Bounded decimal integer arg, eg. --foo=100
+#define VG_BINT_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
+ VG_BINTN_CLO(10, (qq_arg), qq_option, (qq_var), (qq_lo), (qq_hi))
+
+// Bounded hexadecimal integer arg, eg. --foo=0x1fa8
#define VG_BHEX_CLO(qq_arg, qq_option, qq_var, qq_lo, qq_hi) \
- if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \
- Char* s; \
- Long n = VG_(strtoll16)( &qq_arg[ VG_(strlen)(qq_option)+1 ], &s );\
- (qq_var) = n; \
- /* Check for non-numeralness, or overflow */ \
- if ('\0' != s[0] || (qq_var) != n) VG_(err_bad_option)(qq_arg); \
- if ((qq_var) < (qq_lo)) (qq_var) = (qq_lo); \
- if ((qq_var) > (qq_hi)) (qq_var) = (qq_hi); \
- }
+ VG_BINTN_CLO(16, (qq_arg), qq_option, (qq_var), (qq_lo), (qq_hi))
-/* Double arg */
+// Double (decimal) arg, eg. --foo=4.6
+// XXX: there's not VG_BDBL_CLO because we don't have a good way of printing
+// floats at the moment!
#define VG_DBL_CLO(qq_arg, qq_option, qq_var) \
- if (VG_CLO_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) { \
+ (VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=") && \
+ ({ \
+ Char* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ]; \
Char* s; \
- double n = VG_(strtod)( &qq_arg[ VG_(strlen)(qq_option)+1 ], &s );\
+ double n = VG_(strtod)( val, &s ); \
(qq_var) = n; \
/* Check for non-numeralness */ \
if ('\0' != s[0]) VG_(err_bad_option)(qq_arg); \
- }
+ True; \
+ }) \
+ )
-/* Bool arg whose value is denoted by the exact presence of the given string. */
-#define VG_XACT_CL...
[truncated message content] |