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
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(13) |
2
(15) |
|
3
(16) |
4
(42) |
5
(9) |
6
(20) |
7
(22) |
8
(24) |
9
(12) |
|
10
(24) |
11
(11) |
12
(2) |
13
(13) |
14
(8) |
15
|
16
(16) |
|
17
(24) |
18
(36) |
19
(100) |
20
(94) |
21
(50) |
22
(39) |
23
(10) |
|
24
(14) |
25
(19) |
26
(2) |
27
(6) |
28
(17) |
29
(9) |
30
(8) |
|
31
(21) |
|
|
|
|
|
|
|
From: <sv...@va...> - 2009-05-10 22:42:31
|
Author: njn
Date: 2009-05-10 23:42:19 +0100 (Sun, 10 May 2009)
New Revision: 9831
Log:
Merge r9828 (fix aspacem layering violation) from the DARWIN branch.
Modified:
trunk/coregrind/m_aspacehl.c
trunk/coregrind/m_syswrap/priv_syswrap-generic.h
trunk/coregrind/m_syswrap/syswrap-generic.c
trunk/coregrind/m_syswrap/syswrap-linux.c
Modified: trunk/coregrind/m_aspacehl.c
===================================================================
--- trunk/coregrind/m_aspacehl.c 2009-05-10 22:40:50 UTC (rev 9830)
+++ trunk/coregrind/m_aspacehl.c 2009-05-10 22:42:19 UTC (rev 9831)
@@ -64,8 +64,6 @@
return starts;
}
-
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_syswrap/priv_syswrap-generic.h
===================================================================
--- trunk/coregrind/m_syswrap/priv_syswrap-generic.h 2009-05-10 22:40:50 UTC (rev 9830)
+++ trunk/coregrind/m_syswrap/priv_syswrap-generic.h 2009-05-10 22:42:19 UTC (rev 9831)
@@ -62,13 +62,15 @@
extern
Bool ML_(do_sigkill)(Int pid, Int tgid);
-/* So that it can be seen from syswrap-x86-linux.c. */
-/* When a client mmap has been successfully done, both aspacem and the
- tool need to be notified of the new mapping. Hence this fn. */
-extern
-void
-ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
- UInt mm_flags, Int fd, Off64T offset );
+/* When a client mmap or munmap has been successfully done, both the core
+ and the tool need to be notified of the new mapping. Hence this fn. */
+extern void
+ML_(notify_core_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
+ UInt mm_flags, Int fd, Off64T offset );
+extern void
+ML_(notify_core_and_tool_of_munmap) ( Addr a, SizeT len );
+extern void
+ML_(notify_core_and_tool_of_mprotect) ( Addr a, SizeT len, Int prot );
extern void
ML_(buf_and_len_pre_check) ( ThreadId tid, Addr buf_p, Addr buflen_p,
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2009-05-10 22:40:50 UTC (rev 9830)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2009-05-10 22:42:19 UTC (rev 9831)
@@ -59,15 +59,6 @@
#include "priv_syswrap-generic.h"
-/* Local function declarations. */
-
-static
-void notify_aspacem_of_mmap(Addr a, SizeT len, UInt prot,
- UInt flags, Int fd, Off64T offset);
-static
-void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, ULong di_handle);
-
-
/* Returns True iff address range is something the client can
plausibly mess with: all of it is either already belongs to the
client or is free or a reservation. */
@@ -125,11 +116,6 @@
Doing mmap, mremap
------------------------------------------------------------------ */
-// Nb: this isn't done as precisely as possible, but it seems that programs
-// are usually sufficiently well-behaved that the more obscure corner cases
-// aren't important. Various comments in the few functions below give more
-// details... njn 2002-Sep-17
-
/* AFAICT from kernel sources (mm/mprotect.c) and general experimentation,
munmap, mprotect (and mremap??) work at the page level. So addresses
and lengths must be adjusted for this. */
@@ -148,31 +134,9 @@
*a = ra;
}
-/* When a client mmap has been successfully done, this function must
- be called. It notifies both aspacem and the tool of the new
- mapping.
-
- JRS 2008-Aug-14: But notice this is *very* obscure. The only place
- it is called from is POST(sys_io_setup). In particular,
- ML_(generic_PRE_sys_mmap), further down in this file, is the
- "normal case" handler for client mmap. But it doesn't call this
- function; instead it does the relevant notifications itself. Here,
- we just pass di_handle=0 to notify_tool_of_mmap as we have no
- better information. But really this function should be done away
- with; problem is I don't understand what POST(sys_io_setup) does or
- how it works. */
-void
-ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
- UInt flags, Int fd, Off64T offset )
+static void notify_core_of_mmap(Addr a, SizeT len, UInt prot,
+ UInt flags, Int fd, Off64T offset)
{
- notify_aspacem_of_mmap(a, len, prot, flags, fd, offset);
- notify_tool_of_mmap(a, len, prot, 0/*di_handle*/);
-}
-
-static
-void notify_aspacem_of_mmap(Addr a, SizeT len, UInt prot,
- UInt flags, Int fd, Off64T offset)
-{
Bool d;
/* 'a' is the return value from a real kernel mmap, hence: */
@@ -184,11 +148,10 @@
if (d)
VG_(discard_translations)( (Addr64)a, (ULong)len,
- "ML_(notify_aspacem_of_mmap)" );
+ "notify_core_of_mmap" );
}
-static
-void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, ULong di_handle)
+static void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, ULong di_handle)
{
Bool rr, ww, xx;
@@ -204,6 +167,67 @@
VG_TRACK( new_mem_mmap, a, len, rr, ww, xx, di_handle );
}
+
+/* When a client mmap has been successfully done, this function must
+ be called. It notifies both aspacem and the tool of the new
+ mapping.
+
+ JRS 2008-Aug-14: But notice this is *very* obscure. The only place
+ it is called from is POST(sys_io_setup). In particular,
+ ML_(generic_PRE_sys_mmap), in m_syswrap, is the "normal case" handler for
+ client mmap. But it doesn't call this function; instead it does the
+ relevant notifications itself. Here, we just pass di_handle=0 to
+ notify_tool_of_mmap as we have no better information. But really this
+ function should be done away with; problem is I don't understand what
+ POST(sys_io_setup) does or how it works.
+
+ [However, this function is used lots for Darwin, because
+ ML_(generic_PRE_sys_mmap) cannot be used for Darwin.]
+ */
+void
+ML_(notify_core_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
+ UInt flags, Int fd, Off64T offset )
+{
+ // XXX: unlike the other notify_core_and_tool* functions, this one doesn't
+ // do anything with debug info (ie. it doesn't call VG_(di_notify_mmap)).
+ // Should it? --njn
+ notify_core_of_mmap(a, len, prot, flags, fd, offset);
+ notify_tool_of_mmap(a, len, prot, 0/*di_handle*/);
+}
+
+void
+ML_(notify_core_and_tool_of_munmap) ( Addr a, SizeT len )
+{
+ Bool d;
+
+ page_align_addr_and_len(&a, &len);
+ d = VG_(am_notify_munmap)(a, len);
+ VG_TRACK( die_mem_munmap, a, len );
+ VG_(di_notify_munmap)( a, len );
+ if (d)
+ VG_(discard_translations)( (Addr64)a, (ULong)len,
+ "ML_(notify_core_and_tool_of_munmap)" );
+}
+
+void
+ML_(notify_core_and_tool_of_mprotect) ( Addr a, SizeT len, Int prot )
+{
+ Bool rr = toBool(prot & VKI_PROT_READ);
+ Bool ww = toBool(prot & VKI_PROT_WRITE);
+ Bool xx = toBool(prot & VKI_PROT_EXEC);
+ Bool d;
+
+ page_align_addr_and_len(&a, &len);
+ d = VG_(am_notify_mprotect)(a, len, prot);
+ VG_TRACK( change_mem_mprotect, a, len, rr, ww, xx );
+ VG_(di_notify_mprotect)( a, len, prot );
+ if (d)
+ VG_(discard_translations)( (Addr64)a, (ULong)len,
+ "ML_(notify_core_and_tool_of_mprotect)" );
+}
+
+
+
/* Expand (or shrink) an existing mapping, potentially moving it at
the same time (controlled by the MREMAP_MAYMOVE flag). Nightmare.
*/
@@ -1910,7 +1934,7 @@
if (!sres.isError) {
ULong di_handle;
/* Notify aspacem. */
- notify_aspacem_of_mmap(
+ notify_core_of_mmap(
(Addr)sres.res, /* addr kernel actually assigned */
arg2, /* length */
arg3, /* prot */
@@ -3235,18 +3259,8 @@
Addr a = ARG1;
SizeT len = ARG2;
Int prot = ARG3;
- Bool rr = toBool(prot & VKI_PROT_READ);
- Bool ww = toBool(prot & VKI_PROT_WRITE);
- Bool xx = toBool(prot & VKI_PROT_EXEC);
- Bool d;
- page_align_addr_and_len(&a, &len);
- d = VG_(am_notify_mprotect)(a, len, prot);
- VG_TRACK( change_mem_mprotect, a, len, rr, ww, xx );
- VG_(di_notify_mprotect)( a, len, prot );
- if (d)
- VG_(discard_translations)( (Addr64)a, (ULong)len,
- "POST(sys_mprotect)" );
+ ML_(notify_core_and_tool_of_mprotect)(a, len, prot);
}
PRE(sys_munmap)
@@ -3263,15 +3277,8 @@
{
Addr a = ARG1;
SizeT len = ARG2;
- Bool d;
- page_align_addr_and_len(&a, &len);
- d = VG_(am_notify_munmap)(a, len);
- VG_TRACK( die_mem_munmap, a, len );
- VG_(di_notify_munmap)( a, len );
- if (d)
- VG_(discard_translations)( (Addr64)a, (ULong)len,
- "POST(sys_munmap)" );
+ ML_(notify_core_and_tool_of_munmap)( (Addr64)a, (ULong)len );
}
PRE(sys_mincore)
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
===================================================================
--- trunk/coregrind/m_syswrap/syswrap-linux.c 2009-05-10 22:40:50 UTC (rev 9830)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c 2009-05-10 22:42:19 UTC (rev 9831)
@@ -1273,9 +1273,9 @@
r = *(struct vki_aio_ring **)ARG2;
vg_assert(ML_(valid_client_addr)((Addr)r, size, tid, "io_setup"));
- ML_(notify_aspacem_and_tool_of_mmap)( (Addr)r, size,
- VKI_PROT_READ | VKI_PROT_WRITE,
- VKI_MAP_ANONYMOUS, -1, 0 );
+ ML_(notify_core_and_tool_of_mmap)( (Addr)r, size,
+ VKI_PROT_READ | VKI_PROT_WRITE,
+ VKI_MAP_ANONYMOUS, -1, 0 );
POST_MEM_WRITE( ARG2, sizeof(vki_aio_context_t) );
}
|
Author: njn
Date: 2009-05-10 23:40:50 +0100 (Sun, 10 May 2009)
New Revision: 9830
Log:
Merge from the trunk r9813, r9814, r9816, r9817, r9819, r9822, r9823 (DRD
tweaks and ignore file updates) done by Bart.
Modified:
branches/DARWIN/configure.in
branches/DARWIN/drd/drd_bitmap.c
branches/DARWIN/drd/drd_bitmap.h
branches/DARWIN/drd/pub_drd_bitmap.h
branches/DARWIN/drd/scripts/run-splash2
branches/DARWIN/drd/tests/drd_bitmap_test.c
branches/DARWIN/massif/tests/
branches/DARWIN/memcheck/perf/
branches/DARWIN/memcheck/tests/
branches/DARWIN/nightly/
branches/DARWIN/none/tests/linux/
branches/DARWIN/none/tests/x86-linux/
branches/DARWIN/tests/
Modified: branches/DARWIN/configure.in
===================================================================
--- branches/DARWIN/configure.in 2009-05-10 22:23:48 UTC (rev 9829)
+++ branches/DARWIN/configure.in 2009-05-10 22:40:50 UTC (rev 9830)
@@ -983,7 +983,15 @@
void *(*)(void*), void*);
__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
], [
+#ifdef __powerpc__
+/*
+ * Apparently on PowerPC linking this program succeeds and generates an
+ * executable with the undefined symbol pthread_create@GLIBC_2.0.
+ */
+#error This test does not work properly on PowerPC.
+#else
pthread_create_glibc_2_0(0, 0, 0, 0);
+#endif
return 0;
],
[
Modified: branches/DARWIN/drd/drd_bitmap.c
===================================================================
--- branches/DARWIN/drd/drd_bitmap.c 2009-05-10 22:23:48 UTC (rev 9829)
+++ branches/DARWIN/drd/drd_bitmap.c 2009-05-10 22:40:50 UTC (rev 9830)
@@ -37,20 +37,18 @@
#include "pub_tool_mallocfree.h" /* VG_(malloc), VG_(free) */
-/* Forward declarations. */
-
-struct bitmap2;
-
-
/* Local function declarations. */
static void bm2_merge(struct bitmap2* const bm2l,
const struct bitmap2* const bm2r);
+static void bm2_print(const struct bitmap2* const bm2);
/* Local variables. */
static ULong s_bitmap_creation_count;
+static ULong s_bitmap_merge_count;
+static ULong s_bitmap2_merge_count;
/* Function definitions. */
@@ -66,9 +64,10 @@
bm = VG_(malloc)("drd.bitmap.bn.1", sizeof(*bm));
tl_assert(bm);
- /* Cache initialization. a1 is initialized with a value that never can */
- /* match any valid address: the upper ADDR0_BITS bits of a1 are always */
- /* zero for a valid cache entry. */
+ /* Cache initialization. a1 is initialized with a value that never can
+ * match any valid address: the upper (ADDR_LSB_BITS + ADDR_IGNORED_BITS)
+ * bits of a1 are always zero for a valid cache entry.
+ */
for (i = 0; i < N_CACHE_ELEM; i++)
{
bm->cache[i].a1 = ~(UWord)1;
@@ -84,22 +83,8 @@
void DRD_(bm_delete)(struct bitmap* const bm)
{
- struct bitmap2* bm2;
- struct bitmap2ref* bm2ref;
-
tl_assert(bm);
- VG_(OSetGen_ResetIter)(bm->oset);
- for ( ; (bm2ref = VG_(OSetGen_Next)(bm->oset)) != 0; )
- {
- bm2 = bm2ref->bm2;
- tl_assert(bm2->refcnt >= 1);
- if (--bm2->refcnt == 0)
- {
- VG_(free)(bm2);
- }
- }
-
VG_(OSetGen_Destroy)(bm->oset);
VG_(free)(bm);
}
@@ -107,6 +92,11 @@
/**
* Record an access of type access_type at addresses a .. a + size - 1 in
* bitmap bm.
+ *
+ * @note The current implementation of bm_access_range does not work for the
+ * highest addresses in the address range. At least on Linux this is
+ * not a problem since the upper part of the address space is reserved
+ * for the kernel.
*/
void DRD_(bm_access_range)(struct bitmap* const bm,
const Addr a1, const Addr a2,
@@ -120,52 +110,50 @@
return DRD_(bm_access_range_store)(bm, a1, a2);
}
-void DRD_(bm_access_range_load)(struct bitmap* const bm,
- const Addr a1, const Addr a2)
+void DRD_(bm_access_range_load)(struct bitmap* const bm, Addr a1, Addr a2)
{
Addr b, b_next;
tl_assert(bm);
tl_assert(a1 < a2);
- /* The current implementation of bm_access_range does not work for the */
- /* ADDR0_COUNT highest addresses in the address range. At least on Linux */
- /* this is not a problem since the upper part of the address space is */
- /* reserved for the kernel. */
- tl_assert(a2 + ADDR0_COUNT > a2);
+ tl_assert(a2 < first_address_with_higher_msb(a2));
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
for (b = a1; b < a2; b = b_next)
{
Addr b_start;
Addr b_end;
struct bitmap2* bm2;
- SPLIT_ADDRESS(b);
+ UWord b0;
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
}
- bm2 = bm2_lookup_or_insert_exclusive(bm, b1);
+ bm2 = bm2_lookup_or_insert_exclusive(bm, address_msb(b));
tl_assert(bm2);
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_start && b_start < b_end && b_end && b_end <= a2);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_msb(b_start) == address_msb(b_end - 1));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- if (b_end - b_start == ADDR0_COUNT)
+ if (address_lsb(b_start) == 0 && address_lsb(b_end) == 0)
{
unsigned k;
@@ -176,7 +164,7 @@
}
else
{
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end - 1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
bm0_set(bm2->bm1.bm0_r, b0);
}
@@ -225,45 +213,44 @@
tl_assert(bm);
tl_assert(a1 < a2);
- /* The current implementation of bm_access_range does not work for the */
- /* ADDR0_COUNT highest addresses in the address range. At least on Linux */
- /* this is not a problem since the upper part of the address space is */
- /* reserved for the kernel. */
- tl_assert(a2 + ADDR0_COUNT > a2);
+ tl_assert(a2 < first_address_with_higher_msb(a2));
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
for (b = a1; b < a2; b = b_next)
{
Addr b_start;
Addr b_end;
struct bitmap2* bm2;
- SPLIT_ADDRESS(b);
+ UWord b0;
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
}
- bm2 = bm2_lookup_or_insert_exclusive(bm, b1);
+ bm2 = bm2_lookup_or_insert_exclusive(bm, address_msb(b));
tl_assert(bm2);
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_start && b_start < b_end && b_end && b_end <= a2);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_msb(b_start) == address_msb(b_end - 1));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- if (b_end - b_start == ADDR0_COUNT)
+ if (address_lsb(b_start) == 0 && address_lsb(b_end) == 0)
{
unsigned k;
@@ -274,7 +261,7 @@
}
else
{
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end - 1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
bm0_set(bm2->bm1.bm0_w, b0);
}
@@ -336,9 +323,9 @@
for (b = a1; b < a2; b = b_next)
{
- const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+ const struct bitmap2* bm2 = bm2_lookup(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -351,24 +338,24 @@
UWord b0;
const struct bitmap1* const p1 = &bm2->bm1;
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
tl_assert(a1 <= b_start && b_start <= a2);
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_end && b_end <= a2);
tl_assert(b_start < b_end);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
if (bm0_is_set(p1->bm0_r, b0))
{
@@ -389,9 +376,9 @@
for (b = a1; b < a2; b = b_next)
{
- const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+ const struct bitmap2* bm2 = bm2_lookup(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -404,24 +391,24 @@
UWord b0;
const struct bitmap1* const p1 = &bm2->bm1;
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
tl_assert(a1 <= b_start && b_start <= a2);
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_end && b_end <= a2);
tl_assert(b_start < b_end);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
if (bm0_is_set(p1->bm0_w, b0))
{
@@ -444,9 +431,9 @@
for (b = a1; b < a2; b = b_next)
{
- const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+ const struct bitmap2* bm2 = bm2_lookup(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -459,24 +446,24 @@
UWord b0;
const struct bitmap1* const p1 = &bm2->bm1;
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
tl_assert(a1 <= b_start && b_start <= a2);
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_end && b_end <= a2);
tl_assert(b_start < b_end);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
if (bm0_is_set(p1->bm0_r, b0) | bm0_is_set(p1->bm0_w, b0))
{
@@ -498,11 +485,11 @@
const struct bitmap2* p2;
const struct bitmap1* p1;
const UWord* p0;
- const UWord a0 = a & ADDR0_MASK;
+ const UWord a0 = address_lsb(a);
tl_assert(bm);
- p2 = bm2_lookup(bm, a >> ADDR0_BITS);
+ p2 = bm2_lookup(bm, address_msb(a));
if (p2)
{
p1 = &p2->bm1;
@@ -512,20 +499,16 @@
return False;
}
-void DRD_(bm_clear)(struct bitmap* const bm, const Addr a1, const Addr a2)
+void DRD_(bm_clear)(struct bitmap* const bm, Addr a1, Addr a2)
{
Addr b, b_next;
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
-#if 0
- if (a2 - a1 >= ADDR0_COUNT)
- VG_(message)(Vg_DebugMsg, "bm_clear(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx", bm, a1, a2, a2 - a1);
-#endif
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -535,9 +518,9 @@
tl_assert(a1 <= b && b < a2);
#endif
- p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
+ p2 = bm2_lookup_exclusive(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -549,34 +532,33 @@
c = b;
/* If the first address in the bitmap that must be cleared does not */
/* start on an UWord boundary, start clearing the first addresses. */
- if (UWORD_LSB(c))
+ if (uword_lsb(address_lsb(c)))
{
- Addr c_next = UWORD_MSB(c) + BITS_PER_UWORD;
+ Addr c_next = first_address_with_higher_uword_msb(c);
if (c_next > b_next)
c_next = b_next;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= c_next && c_next <= b_next
&& b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, c_next - c);
- bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, c_next - c);
+ bm0_clear_range(p2->bm1.bm0_r, address_lsb(c), SCALED_SIZE(c_next - c));
+ bm0_clear_range(p2->bm1.bm0_w, address_lsb(c), SCALED_SIZE(c_next - c));
c = c_next;
}
/* If some UWords have to be cleared entirely, do this now. */
- if (UWORD_LSB(c) == 0)
+ if (uword_lsb(address_lsb(c)) == 0)
{
- const Addr c_next = UWORD_MSB(b_next);
+ Addr c_next = first_address_with_same_uword_lsb(b_next);
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(UWORD_LSB(c) == 0);
- tl_assert(UWORD_LSB(c_next) == 0);
+ tl_assert(uword_lsb(address_lsb(c)) == 0);
+ tl_assert(uword_lsb(address_lsb(c_next)) == 0);
tl_assert(c_next <= b_next);
- tl_assert(c <= c_next);
#endif
if (c_next > c)
{
- UWord idx = (c & ADDR0_MASK) >> BITS_PER_BITS_PER_UWORD;
- VG_(memset)(&p2->bm1.bm0_r[idx], 0, (c_next - c) / 8);
- VG_(memset)(&p2->bm1.bm0_w[idx], 0, (c_next - c) / 8);
+ UWord idx = uword_msb(address_lsb(c));
+ VG_(memset)(&p2->bm1.bm0_r[idx], 0, SCALED_SIZE((c_next - c) / 8));
+ VG_(memset)(&p2->bm1.bm0_w[idx], 0, SCALED_SIZE((c_next - c) / 8));
c = c_next;
}
}
@@ -585,8 +567,8 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, b_next - c);
- bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, b_next - c);
+ bm0_clear_range(p2->bm1.bm0_r, address_lsb(c), SCALED_SIZE(b_next - c));
+ bm0_clear_range(p2->bm1.bm0_w, address_lsb(c), SCALED_SIZE(b_next - c));
}
}
@@ -594,20 +576,16 @@
* Clear all references to loads in bitmap bm starting at address a1 and
* up to but not including address a2.
*/
-void DRD_(bm_clear_load)(struct bitmap* const bm, const Addr a1, const Addr a2)
+void DRD_(bm_clear_load)(struct bitmap* const bm, Addr a1, Addr a2)
{
Addr b, b_next;
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
-#if 0
- if (a2 - a1 >= ADDR0_COUNT)
- VG_(message)(Vg_DebugMsg, "bm_clear_load(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx", bm, a1, a2, a2 - a1);
-#endif
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -617,9 +595,9 @@
tl_assert(a1 <= b && b < a2);
#endif
- p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
+ p2 = bm2_lookup_exclusive(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -634,35 +612,35 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c < b_next && b_next <= a2);
#endif
- if (UWORD_LSB(c))
+ if (uword_lsb(address_lsb(c)))
{
- Addr c_next = UWORD_MSB(c) + BITS_PER_UWORD;
+ Addr c_next = first_address_with_higher_uword_msb(c);
if (c_next > b_next)
c_next = b_next;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c < c_next && c_next <= b_next
&& b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, c_next - c);
+ bm0_clear_range(p2->bm1.bm0_r, address_lsb(c), SCALED_SIZE(c_next - c));
c = c_next;
}
/* If some UWords have to be cleared entirely, do this now. */
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- if (UWORD_LSB(c) == 0)
+ if (uword_lsb(address_lsb(c)) == 0)
{
- const Addr c_next = UWORD_MSB(b_next);
+ Addr c_next = first_address_with_same_uword_lsb(b_next);
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(UWORD_LSB(c) == 0);
- tl_assert(UWORD_LSB(c_next) == 0);
+ tl_assert(uword_lsb(address_lsb(c)) == 0);
+ tl_assert(uword_lsb(address_lsb(c_next)) == 0);
tl_assert(a1 <= b && b <= c && c <= c_next && c_next <= b_next
&& b_next <= a2);
#endif
if (c_next > c)
{
- UWord idx = (c & ADDR0_MASK) >> BITS_PER_BITS_PER_UWORD;
- VG_(memset)(&p2->bm1.bm0_r[idx], 0, (c_next - c) / 8);
+ UWord idx = uword_msb(address_lsb(c));
+ VG_(memset)(&p2->bm1.bm0_r[idx], 0, SCALED_SIZE((c_next - c) / 8));
c = c_next;
}
}
@@ -671,7 +649,7 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, b_next - c);
+ bm0_clear_range(p2->bm1.bm0_r, address_lsb(c), SCALED_SIZE(b_next - c));
}
}
@@ -687,13 +665,9 @@
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
-#if 0
- if (a2 - a1 >= ADDR0_COUNT)
- VG_(message)(Vg_DebugMsg, "bm_clear_store(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx", bm, a1, a2, a2 - a1);
-#endif
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -703,9 +677,9 @@
tl_assert(a1 <= b && b < a2);
#endif
- p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
+ p2 = bm2_lookup_exclusive(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -720,35 +694,35 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c < b_next && b_next <= a2);
#endif
- if (UWORD_LSB(c))
+ if (uword_lsb(address_lsb(c)))
{
- Addr c_next = UWORD_MSB(c) + BITS_PER_UWORD;
+ Addr c_next = first_address_with_higher_uword_msb(c);
if (c_next > b_next)
c_next = b_next;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c < c_next && c_next <= b_next
&& b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, c_next - c);
+ bm0_clear_range(p2->bm1.bm0_w, address_lsb(c), SCALED_SIZE(c_next - c));
c = c_next;
}
/* If some UWords have to be cleared entirely, do this now. */
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- if (UWORD_LSB(c) == 0)
+ if (uword_lsb(address_lsb(c)) == 0)
{
- const Addr c_next = UWORD_MSB(b_next);
+ Addr c_next = first_address_with_same_uword_lsb(b_next);
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(UWORD_LSB(c) == 0);
- tl_assert(UWORD_LSB(c_next) == 0);
+ tl_assert(uword_lsb(address_lsb(c)) == 0);
+ tl_assert(uword_lsb(address_lsb(c_next)) == 0);
tl_assert(a1 <= b && b <= c && c <= c_next && c_next <= b_next
&& b_next <= a2);
#endif
if (c_next > c)
{
- UWord idx = (c & ADDR0_MASK) >> BITS_PER_BITS_PER_UWORD;
- VG_(memset)(&p2->bm1.bm0_w[idx], 0, (c_next - c) / 8);
+ UWord idx = uword_msb(address_lsb(c));
+ VG_(memset)(&p2->bm1.bm0_w[idx], 0, SCALED_SIZE((c_next - c) / 8));
c = c_next;
}
}
@@ -757,7 +731,7 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, b_next - c);
+ bm0_clear_range(p2->bm1.bm0_w, address_lsb(c), SCALED_SIZE(b_next - c));
}
}
@@ -786,9 +760,9 @@
for (b = a1; b < a2; b = b_next)
{
- const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+ const struct bitmap2* bm2 = bm2_lookup(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -801,24 +775,24 @@
UWord b0;
const struct bitmap1* const p1 = &bm2->bm1;
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
tl_assert(a1 <= b_start && b_start <= a2);
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_end && b_end <= a2);
tl_assert(b_start < b_end);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
if (access_type == eLoad)
{
@@ -919,9 +893,7 @@
Bool DRD_(bm_equal)(struct bitmap* const lhs, struct bitmap* const rhs)
{
struct bitmap2* bm2l;
- struct bitmap2ref* bm2l_ref;
struct bitmap2* bm2r;
- const struct bitmap2ref* bm2r_ref;
/* It's not possible to have two independent iterators over the same OSet, */
/* so complain if lhs == rhs. */
@@ -930,54 +902,38 @@
VG_(OSetGen_ResetIter)(lhs->oset);
VG_(OSetGen_ResetIter)(rhs->oset);
- for ( ; (bm2l_ref = VG_(OSetGen_Next)(lhs->oset)) != 0; )
+ for ( ; (bm2l = VG_(OSetGen_Next)(lhs->oset)) != 0; )
{
- while (bm2l_ref
- && (bm2l = bm2l_ref->bm2)
- && bm2l
+ while (bm2l
&& ! DRD_(bm_has_any_access)(lhs,
- bm2l->addr << ADDR0_BITS,
- (bm2l->addr + 1) << ADDR0_BITS))
+ make_address(bm2l->addr, 0),
+ make_address(bm2l->addr + 1, 0)))
{
- bm2l_ref = VG_(OSetGen_Next)(lhs->oset);
+ bm2l = VG_(OSetGen_Next)(lhs->oset);
}
- if (bm2l_ref == 0)
+ if (bm2l == 0)
break;
tl_assert(bm2l);
-#if 0
- VG_(message)(Vg_DebugMsg, "bm_equal: at 0x%lx", bm2l->addr << ADDR0_BITS);
-#endif
do
{
- bm2r_ref = VG_(OSetGen_Next)(rhs->oset);
- if (bm2r_ref == 0)
- {
-#if 0
- VG_(message)(Vg_DebugMsg, "bm_equal: no match found");
-#endif
+ bm2r = VG_(OSetGen_Next)(rhs->oset);
+ if (bm2r == 0)
return False;
- }
- bm2r = bm2r_ref->bm2;
- tl_assert(bm2r);
}
while (! DRD_(bm_has_any_access)(rhs,
- bm2r->addr << ADDR0_BITS,
- (bm2r->addr + 1) << ADDR0_BITS));
+ make_address(bm2r->addr, 0),
+ make_address(bm2r->addr + 1, 0)));
tl_assert(bm2r);
tl_assert(DRD_(bm_has_any_access)(rhs,
- bm2r->addr << ADDR0_BITS,
- (bm2r->addr + 1) << ADDR0_BITS));
+ make_address(bm2r->addr, 0),
+ make_address(bm2r->addr + 1, 0)));
if (bm2l != bm2r
&& (bm2l->addr != bm2r->addr
|| VG_(memcmp)(&bm2l->bm1, &bm2r->bm1, sizeof(bm2l->bm1)) != 0))
{
-#if 0
- VG_(message)(Vg_DebugMsg, "bm_equal: rhs 0x%lx -- returning false",
- bm2r->addr << ADDR0_BITS);
-#endif
return False;
}
}
@@ -986,18 +942,13 @@
{
bm2r = VG_(OSetGen_Next)(rhs->oset);
} while (bm2r && ! DRD_(bm_has_any_access)(rhs,
- bm2r->addr << ADDR0_BITS,
- (bm2r->addr + 1) << ADDR0_BITS));
+ make_address(bm2r->addr, 0),
+ make_address(bm2r->addr + 1, 0)));
if (bm2r)
{
tl_assert(DRD_(bm_has_any_access)(rhs,
- bm2r->addr << ADDR0_BITS,
- (bm2r->addr + 1) << ADDR0_BITS));
-#if 0
- VG_(message)(Vg_DebugMsg,
- "bm_equal: remaining rhs 0x%lx -- returning false",
- bm2r->addr << ADDR0_BITS);
-#endif
+ make_address(bm2r->addr, 0),
+ make_address(bm2r->addr + 1, 0)));
return False;
}
return True;
@@ -1015,29 +966,27 @@
struct bitmap* const rhs)
{
struct bitmap2* bm2l;
- struct bitmap2ref* bm2l_ref;
struct bitmap2* bm2r;
- const struct bitmap2ref* bm2r_ref;
+ /* It's not possible to have two independent iterators over the same OSet, */
+ /* so complain if lhs == rhs. */
+ tl_assert(lhs != rhs);
+
+ s_bitmap_merge_count++;
+
VG_(OSetGen_ResetIter)(rhs->oset);
- for ( ; (bm2r_ref = VG_(OSetGen_Next)(rhs->oset)) != 0; )
+ for ( ; (bm2r = VG_(OSetGen_Next)(rhs->oset)) != 0; )
{
- bm2r = bm2r_ref->bm2;
- bm2l_ref = VG_(OSetGen_Lookup)(lhs->oset, &bm2r->addr);
- if (bm2l_ref)
+ bm2l = VG_(OSetGen_Lookup)(lhs->oset, &bm2r->addr);
+ if (bm2l)
{
- bm2l = bm2l_ref->bm2;
- if (bm2l != bm2r)
- {
- if (bm2l->refcnt > 1)
- bm2l = bm2_make_exclusive(lhs, bm2l_ref);
- bm2_merge(bm2l, bm2r);
- }
+ tl_assert(bm2l != bm2r);
+ bm2_merge(bm2l, bm2r);
}
else
{
- bm2_insert_addref(lhs, bm2r);
+ bm2_insert_copy(lhs, bm2r);
}
}
}
@@ -1055,24 +1004,20 @@
for (;;)
{
- const struct bitmap2ref* bm2l_ref;
- const struct bitmap2ref* bm2r_ref;
const struct bitmap2* bm2l;
const struct bitmap2* bm2r;
const struct bitmap1* bm1l;
const struct bitmap1* bm1r;
unsigned k;
- bm2l_ref = VG_(OSetGen_Next)(lhs->oset);
- bm2l = bm2l_ref->bm2;
- bm2r_ref = VG_(OSetGen_Next)(rhs->oset);
- bm2r = bm2r_ref->bm2;
+ bm2l = VG_(OSetGen_Next)(lhs->oset);
+ bm2r = VG_(OSetGen_Next)(rhs->oset);
while (bm2l && bm2r && bm2l->addr != bm2r->addr)
{
if (bm2l->addr < bm2r->addr)
- bm2l = (bm2l_ref = VG_(OSetGen_Next)(lhs->oset))->bm2;
+ bm2l = VG_(OSetGen_Next)(lhs->oset);
else
- bm2r = (bm2r_ref = VG_(OSetGen_Next)(rhs->oset))->bm2;
+ bm2r = VG_(OSetGen_Next)(rhs->oset);
}
if (bm2l == 0 || bm2r == 0)
break;
@@ -1090,7 +1035,7 @@
| ((bm1l->bm0_w[k] & bm0_mask(b)) ? LHS_W : 0)
| ((bm1r->bm0_r[k] & bm0_mask(b)) ? RHS_R : 0)
| ((bm1r->bm0_w[k] & bm0_mask(b)) ? RHS_W : 0);
- Addr const a = MAKE_ADDRESS(bm2l->addr, k * BITS_PER_UWORD | b);
+ Addr const a = make_address(bm2l->addr, k * BITS_PER_UWORD | b);
if (HAS_RACE(access_mask) && ! DRD_(is_suppressed)(a, a + 1))
{
return 1;
@@ -1104,29 +1049,35 @@
void DRD_(bm_print)(struct bitmap* const bm)
{
struct bitmap2* bm2;
- struct bitmap2ref* bm2ref;
- VG_(OSetGen_ResetIter)(bm->oset);
-
- for ( ; (bm2ref = VG_(OSetGen_Next)(bm->oset)) != 0; )
+ for (VG_(OSetGen_ResetIter)(bm->oset);
+ (bm2 = VG_(OSetGen_Next)(bm->oset)) != 0;
+ )
{
- const struct bitmap1* bm1;
- unsigned b;
+ bm2_print(bm2);
+ }
+}
- bm2 = bm2ref->bm2;
- bm1 = &bm2->bm1;
- for (b = 0; b < ADDR0_COUNT; b++)
+static void bm2_print(const struct bitmap2* const bm2)
+{
+ const struct bitmap1* bm1;
+ Addr a;
+
+ tl_assert(bm2);
+
+ bm1 = &bm2->bm1;
+ for (a = make_address(bm2->addr, 0);
+ a <= make_address(bm2->addr + 1, 0) - 1;
+ a++)
+ {
+ const Bool r = bm0_is_set(bm1->bm0_r, address_lsb(a)) != 0;
+ const Bool w = bm0_is_set(bm1->bm0_w, address_lsb(a)) != 0;
+ if (r || w)
{
- const Addr a = (bm2->addr << ADDR0_BITS) | b;
- const Bool r = bm0_is_set(bm1->bm0_r, b) != 0;
- const Bool w = bm0_is_set(bm1->bm0_w, b) != 0;
- if (r || w)
- {
- VG_(printf)("0x%08lx %c %c\n",
- a,
- w ? 'W' : ' ',
- r ? 'R' : ' ');
- }
+ VG_(printf)("0x%08lx %c %c\n",
+ a,
+ w ? 'W' : ' ',
+ r ? 'R' : ' ');
}
}
}
@@ -1146,63 +1097,30 @@
return s_bitmap2_creation_count;
}
-/** Allocate and initialize a second level bitmap. */
-static struct bitmap2* bm2_new(const UWord a1)
+ULong DRD_(bm_get_bitmap2_merge_count)(void)
{
- struct bitmap2* bm2;
-
- bm2 = VG_(malloc)("drd.bitmap.bm2n.1", sizeof(*bm2));
- bm2->addr = a1;
- bm2->refcnt = 1;
-
- s_bitmap2_creation_count++;
-
- return bm2;
+ return s_bitmap2_merge_count;
}
-/** Make a copy of a shared second level bitmap such that the copy can be
- * modified.
- *
- * @param a1 client address shifted right by ADDR0_BITS.
- * @param bm bitmap pointer.
- */
-static struct bitmap2* bm2_make_exclusive(struct bitmap* const bm,
- struct bitmap2ref* const bm2ref)
+/** Clear the bitmap contents. */
+static void bm2_clear(struct bitmap2* const bm2)
{
- UWord a1;
- struct bitmap2* bm2;
- struct bitmap2* bm2_copy;
-
- tl_assert(bm);
- tl_assert(bm2ref);
- bm2 = bm2ref->bm2;
tl_assert(bm2);
- tl_assert(bm2->refcnt > 1);
- bm2->refcnt--;
- tl_assert(bm2->refcnt >= 1);
- a1 = bm2->addr;
- bm2_copy = bm2_new(a1);
- tl_assert(bm2_copy);
- tl_assert(bm2_copy->addr == a1);
- tl_assert(bm2_copy->refcnt == 1);
- VG_(memcpy)(&bm2_copy->bm1, &bm2->bm1, sizeof(bm2->bm1));
- bm2ref->bm2 = bm2_copy;
-
- bm_update_cache(bm, a1, bm2_copy);
-
- return bm2_copy;
+ VG_(memset)(&bm2->bm1, 0, sizeof(bm2->bm1));
}
-static void bm2_merge(struct bitmap2* const bm2l,
- const struct bitmap2* const bm2r)
+/** Compute *bm2l |= *bm2r. */
+static
+void bm2_merge(struct bitmap2* const bm2l, const struct bitmap2* const bm2r)
{
unsigned k;
tl_assert(bm2l);
tl_assert(bm2r);
tl_assert(bm2l->addr == bm2r->addr);
- tl_assert(bm2l->refcnt == 1);
+ s_bitmap2_merge_count++;
+
for (k = 0; k < BITMAP1_UWORD_COUNT; k++)
{
bm2l->bm1.bm0_r[k] |= bm2r->bm1.bm0_r[k];
Modified: branches/DARWIN/drd/drd_bitmap.h
===================================================================
--- branches/DARWIN/drd/drd_bitmap.h 2009-05-10 22:23:48 UTC (rev 9829)
+++ branches/DARWIN/drd/drd_bitmap.h 2009-05-10 22:40:50 UTC (rev 9830)
@@ -27,36 +27,109 @@
#define __DRD_BITMAP_H
+#include "pub_drd_bitmap.h"
#include "pub_tool_basics.h"
#include "pub_tool_oset.h"
#include "pub_tool_libcbase.h"
-/*
- Bitmap representation. A bitmap is a data structure in which two bits are
- reserved per 32 bit address: one bit that indicates that the data at the
- specified address has been read, and one bit that indicates that the data has
- been written to.
-*/
+/* Bitmap representation. A bitmap is a data structure in which two bits are
+ * reserved per 32 bit address: one bit that indicates that the data at the
+ * specified address has been read, and one bit that indicates that the data
+ * has been written to.
+ */
+/* Client addresses are split into bitfields as follows:
+ * ------------------------------------------------------
+ * | Address MSB | Address LSB | Ignored bits |
+ * ------------------------------------------------------
+ * | Address MSB | UWord MSB | UWord LSB | Ignored bits |
+ * ------------------------------------------------------
+ */
-/* Macro definitions. */
-#define ADDR0_BITS 14
-#define ADDR0_COUNT ((UWord)1 << ADDR0_BITS)
+/* Address MSB / LSB split. */
-#define ADDR0_MASK (ADDR0_COUNT - 1)
-#define SPLIT_ADDRESS(a) \
- UWord a##0 = ((a) & ADDR0_MASK); \
- UWord a##1 = ((a) >> ADDR0_BITS);
+/** Number of least significant address bits that are ignored. */
+#define ADDR_IGNORED_BITS 0
+#define ADDR_IGNORED_MASK ((1U << ADDR_IGNORED_BITS) - 1U)
+#define ADDR_GRANULARITY (1U << ADDR_IGNORED_BITS)
-// Assumption: sizeof(Addr) == sizeof(UWord).
-#define MAKE_ADDRESS(a1, a0) \
- (Addr)(((UWord)(a1) << (ADDR0_BITS)) | ((UWord)(a0)))
+/** Round argument a up to a multiple of (1 << ADDR_GRANULARITY), and next
+ * shift it right ADDR_GRANULARITY bits. The expression below is optimized
+ * for the case where a is a constant.
+ */
+#define SCALED_SIZE(a) \
+ (((((a) - 1U) | ADDR_IGNORED_MASK) + 1U) >> ADDR_IGNORED_BITS)
-#define BITS_PER_UWORD (8UL*sizeof(UWord))
+/** Number of bits assigned to the least significant component of an address.
+ */
+#define ADDR_LSB_BITS 12
+
+/** Mask that has to be applied to an address of type Addr in order to
+ * compute the least significant part of an address split, after having
+ * shifted the address bits ADDR_GRANULARITY to the right.
+ */
+#define ADDR_LSB_MASK (((UWord)1 << ADDR_LSB_BITS) - 1U)
+
+/** Compute least significant bits of an address of type Addr. */
+static __inline__
+UWord address_lsb(const Addr a)
+{ return (a >> ADDR_IGNORED_BITS) & ADDR_LSB_MASK; }
+
+/**
+ * Compute the first address for which address_lsb() is equal to
+ * address_lsb(a).
+ */
+static __inline__
+Addr first_address_with_same_lsb(const Addr a)
+{
+ return ((a | ADDR_IGNORED_MASK) ^ ADDR_IGNORED_MASK);
+}
+
+/**
+ * Compute the first address for which address_lsb() is greater than
+ * address_lsb(a).
+ */
+static __inline__
+Addr first_address_with_higher_lsb(const Addr a)
+{
+ return ((a | ADDR_IGNORED_MASK) + 1U);
+}
+
+/** Compute most significant bits of an address of type Addr. */
+static __inline__
+UWord address_msb(const Addr a)
+{ return a >> (ADDR_LSB_BITS + ADDR_IGNORED_BITS); }
+
+static __inline__
+Addr first_address_with_higher_msb(const Addr a)
+{
+ return ((a | ((ADDR_LSB_MASK << ADDR_IGNORED_BITS) | ADDR_IGNORED_MASK))
+ + 1U);
+}
+
+/** Convert LSB and MSB back into an address.
+ *
+ * @note It is assumed that sizeof(Addr) == sizeof(UWord).
+ */
+static __inline__
+Addr make_address(const UWord a1, const UWord a0)
+{
+ return ((a1 << (ADDR_LSB_BITS + ADDR_IGNORED_BITS))
+ | (a0 << ADDR_IGNORED_BITS));
+}
+
+
+
+
+
+/* Number of bits that fit in a variable of type UWord. */
+#define BITS_PER_UWORD (8U * sizeof(UWord))
+
+/* Log2 of BITS_PER_UWORD. */
#if defined(VGA_x86) || defined(VGA_ppc32)
#define BITS_PER_BITS_PER_UWORD 5
#elif defined(VGA_amd64) || defined(VGA_ppc64)
@@ -65,18 +138,66 @@
#error Unknown platform.
#endif
-#define BITMAP1_UWORD_COUNT (ADDR0_COUNT >> BITS_PER_BITS_PER_UWORD)
+/** Number of UWord's needed to store one bit per address LSB.
+ */
+#define BITMAP1_UWORD_COUNT (1U << (ADDR_LSB_BITS - BITS_PER_BITS_PER_UWORD))
-/* Highest bits of an address that fit into the same UWord of bm0[]. */
-#define UWORD_MSB(a) ((a) & ~(BITS_PER_UWORD - 1))
+/** Mask that has to be applied to an (Addr >> ADDR_IGNORED_BITS) expression
+ * in order to compute the least significant part of an UWord.
+ */
+#define UWORD_LSB_MASK (((UWord)1 << BITS_PER_BITS_PER_UWORD) - 1)
-/* Lowest bits of an address that fit into the same UWord of bm0[]. */
-#define UWORD_LSB(a) ((a) & (BITS_PER_UWORD - 1))
+/** Compute index into bm0[] array.
+ *
+ * @param a Address shifted right ADDR_IGNORED_BITS bits.
+ */
+static __inline__
+UWord uword_msb(const UWord a)
+{
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(a < (1U << ADDR_LSB_BITS));
+#endif
+ return a >> BITS_PER_BITS_PER_UWORD;
+}
-/* Highest address that fits in the same UWord as a. */
-#define UWORD_HIGHEST_ADDRESS(a) ((a) | (BITS_PER_UWORD - 1))
+/** Return the least significant bits.
+ *
+ * @param a Address shifted right ADDR_IGNORED_BITS bits.
+ */
+static __inline__
+UWord uword_lsb(const UWord a)
+{
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(a < (1U << ADDR_LSB_BITS));
+#endif
+ return a & UWORD_LSB_MASK;
+}
+/** Compute the highest address lower than a for which
+ * uword_lsb(address_lsb(a)) == 0.
+ *
+ * @param a Address.
+ */
+static __inline__
+Addr first_address_with_same_uword_lsb(const Addr a)
+{
+ return (a & (~UWORD_LSB_MASK << ADDR_IGNORED_BITS));
+}
+/**
+ * First address that will go in the UWord past the one 'a' goes in.
+ *
+ * @param a Address.
+ */
+static __inline__
+Addr first_address_with_higher_uword_msb(const Addr a)
+{
+ return ((a | ((UWORD_LSB_MASK << ADDR_IGNORED_BITS) | ADDR_IGNORED_MASK))
+ + 1);
+}
+
+
+
/* Local variables. */
static ULong s_bitmap2_creation_count;
@@ -89,56 +210,69 @@
/*********************************************************************/
-/* Lowest level, corresponding to the lowest ADDR0_BITS of an address. */
+/* Lowest level, corresponding to the lowest ADDR_LSB_BITS of an address. */
struct bitmap1
{
UWord bm0_r[BITMAP1_UWORD_COUNT];
UWord bm0_w[BITMAP1_UWORD_COUNT];
};
-static __inline__ UWord bm0_mask(const Addr a)
+static __inline__ UWord bm0_mask(const UWord a)
{
- return ((UWord)1 << UWORD_LSB(a));
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(address_msb(make_address(0, a)) == 0);
+#endif
+ return ((UWord)1 << uword_lsb(a));
}
-static __inline__ void bm0_set(UWord* bm0, const Addr a)
+/** Set the bit corresponding to address a in bitmap bm0. */
+static __inline__ void bm0_set(UWord* bm0, const UWord a)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a < ADDR0_COUNT);
+ tl_assert(address_msb(make_address(0, a)) == 0);
#endif
- bm0[a >> BITS_PER_BITS_PER_UWORD] |= (UWord)1 << UWORD_LSB(a);
+ bm0[uword_msb(a)] |= (UWord)1 << uword_lsb(a);
}
-/** Set all of the addresses in range [ a1 .. a1 + size [ in bitmap bm0. */
+/**
+ * Set the bits corresponding to all of the addresses in range
+ * [ a << ADDR_IGNORED_BITS .. (a + size) << ADDR_IGNORED_BITS [
+ * in bitmap bm0.
+ */
static __inline__ void bm0_set_range(UWord* bm0,
- const Addr a1, const SizeT size)
+ const UWord a, const SizeT size)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a1 < ADDR0_COUNT);
tl_assert(size > 0);
- tl_assert(a1 + size <= ADDR0_COUNT);
- tl_assert(UWORD_MSB(a1) == UWORD_MSB(a1 + size - 1));
+ tl_assert(address_msb(make_address(0, a)) == 0);
+ tl_assert(address_msb(make_address(0, a + size - 1)) == 0);
+ tl_assert(uword_msb(a) == uword_msb(a + size - 1));
#endif
- bm0[a1 >> BITS_PER_BITS_PER_UWORD]
- |= (((UWord)1 << size) - 1) << UWORD_LSB(a1);
+ bm0[uword_msb(a)]
+ |= (((UWord)1 << size) - 1) << uword_lsb(a);
}
-static __inline__ void bm0_clear(UWord* bm0, const Addr a)
+/** Clear the bit corresponding to address a in bitmap bm0. */
+static __inline__ void bm0_clear(UWord* bm0, const UWord a)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a < ADDR0_COUNT);
+ tl_assert(address_msb(make_address(0, a)) == 0);
#endif
- bm0[a >> BITS_PER_BITS_PER_UWORD] &= ~((UWord)1 << UWORD_LSB(a));
+ bm0[uword_msb(a)] &= ~((UWord)1 << uword_lsb(a));
}
-/** Clear all of the addresses in range [ a1 .. a1 + size [ in bitmap bm0. */
+/**
+ * Clear all of the addresses in range
+ * [ a << ADDR_IGNORED_BITS .. (a + size) << ADDR_IGNORED_BITS [
+ * in bitmap bm0.
+ */
static __inline__ void bm0_clear_range(UWord* bm0,
- const Addr a1, const SizeT size)
+ const UWord a, const SizeT size)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a1 <= ADDR0_COUNT);
- tl_assert(a1 + size <= ADDR0_COUNT);
- tl_assert(size == 0 || UWORD_MSB(a1) == UWORD_MSB(a1 + size - 1));
+ tl_assert(address_msb(make_address(0, a)) == 0);
+ tl_assert(size == 0 || address_msb(make_address(0, a + size - 1)) == 0);
+ tl_assert(size == 0 || uword_msb(a) == uword_msb(a + size - 1));
#endif
/*
* Note: although the expression below yields a correct result even if
@@ -147,31 +281,35 @@
*/
if (size > 0)
{
- bm0[a1 >> BITS_PER_BITS_PER_UWORD]
- &= ~((((UWord)1 << size) - 1) << UWORD_LSB(a1));
+ bm0[uword_msb(a)]
+ &= ~((((UWord)1 << size) - 1) << uword_lsb(a));
}
}
-static __inline__ UWord bm0_is_set(const UWord* bm0, const Addr a)
+/** Test whether the bit corresponding to address a is set in bitmap bm0. */
+static __inline__ UWord bm0_is_set(const UWord* bm0, const UWord a)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a < ADDR0_COUNT);
+ tl_assert(address_msb(make_address(0, a)) == 0);
#endif
- return (bm0[a >> BITS_PER_BITS_PER_UWORD] & ((UWord)1 << UWORD_LSB(a)));
+ return (bm0[uword_msb(a)] & ((UWord)1 << uword_lsb(a)));
}
-/** Return true if any of the bits [ a1 .. a1+size [ are set in bm0. */
+/**
+ * Return true if a bit corresponding to any of the addresses in range
+ * [ a << ADDR_IGNORED_BITS .. (a + size) << ADDR_IGNORED_BITS [
+ * is set in bm0.
+ */
static __inline__ UWord bm0_is_any_set(const UWord* bm0,
- const Addr a1, const SizeT size)
+ const Addr a, const SizeT size)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a1 < ADDR0_COUNT);
tl_assert(size > 0);
- tl_assert(a1 + size <= ADDR0_COUNT);
- tl_assert(UWORD_MSB(a1) == UWORD_MSB(a1 + size - 1));
+ tl_assert(address_msb(make_address(0, a)) == 0);
+ tl_assert(address_msb(make_address(0, a + size - 1)) == 0);
+ tl_assert(uword_msb(a) == uword_msb(a + size - 1));
#endif
- return (bm0[a1 >> BITS_PER_BITS_PER_UWORD]
- & ((((UWord)1 << size) - 1) << UWORD_LSB(a1)));
+ return (bm0[uword_msb(a)] & ((((UWord)1 << size) - 1) << uword_lsb(a)));
}
@@ -184,18 +322,10 @@
/* Second level bitmap. */
struct bitmap2
{
- Addr addr; ///< address >> ADDR0_BITS
- int refcnt;
+ Addr addr; ///< address_msb(...)
struct bitmap1 bm1;
};
-/* One node of bitmap::oset. */
-struct bitmap2ref
-{
- Addr addr; ///< address >> ADDR0_BITS
- struct bitmap2* bm2;
-};
-
struct bm_cache_elem
{
Addr a1;
@@ -212,10 +342,12 @@
};
-static struct bitmap2* bm2_new(const UWord a1);
-static struct bitmap2* bm2_make_exclusive(struct bitmap* const bm,
- struct bitmap2ref* const bm2ref);
+static void bm2_clear(struct bitmap2* const bm2);
+static __inline__
+struct bitmap2* bm2_insert(struct bitmap* const bm, const UWord a1);
+
+
/** Rotate elements cache[0..n-1] such that the element at position n-1 is
* moved to position 0. This allows to speed up future cache lookups.
*/
@@ -365,26 +497,22 @@
* shared second level bitmap. The bitmap where the returned pointer points
* at may not be modified by the caller.
*
- * @param a1 client address shifted right by ADDR0_BITS.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
* @param bm bitmap pointer.
*/
static __inline__
const struct bitmap2* bm2_lookup(struct bitmap* const bm, const UWord a1)
{
- struct bitmap2* bm2;
- struct bitmap2ref* bm2ref;
+ struct bitmap2* bm2;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(bm);
#endif
+
if (! bm_cache_lookup(bm, a1, &bm2))
{
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- if (bm2ref)
- {
- bm2 = bm2ref->bm2;
- }
- bm_update_cache(*(struct bitmap**)&bm, a1, bm2);
+ bm2 = VG_(OSetGen_Lookup)(bm->oset, &a1);
+ bm_update_cache(bm, a1, bm2);
}
return bm2;
}
@@ -392,134 +520,95 @@
/** Look up the address a1 in bitmap bm and return a pointer to a second
* level bitmap that is not shared and hence may be modified.
*
- * @param a1 client address shifted right by ADDR0_BITS.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
* @param bm bitmap pointer.
*/
static __inline__
struct bitmap2*
bm2_lookup_exclusive(struct bitmap* const bm, const UWord a1)
{
- struct bitmap2ref* bm2ref;
struct bitmap2* bm2;
- bm2ref = 0;
- if (bm_cache_lookup(bm, a1, &bm2))
- {
- if (bm2 == 0)
- return 0;
- if (bm2->refcnt > 1)
- {
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- }
- }
- else
- {
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- if (bm2ref == 0)
- return 0;
- bm2 = bm2ref->bm2;
- }
-
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm2);
+ tl_assert(bm);
#endif
- if (bm2->refcnt > 1)
+ if (! bm_cache_lookup(bm, a1, &bm2))
{
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm2ref);
-#endif
- bm2 = bm2_make_exclusive(*(struct bitmap**)&bm, bm2ref);
+ bm2 = VG_(OSetGen_Lookup)(bm->oset, &a1);
}
return bm2;
}
-/** Look up the address a1 in bitmap bm. The returned second level bitmap has
- * reference count one and hence may be modified.
+/** Insert an uninitialized second level bitmap for the address a1.
*
- * @param a1 client address shifted right by ADDR0_BITS.
* @param bm bitmap pointer.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
*/
static __inline__
struct bitmap2* bm2_insert(struct bitmap* const bm, const UWord a1)
{
- struct bitmap2ref* bm2ref;
struct bitmap2* bm2;
- s_bitmap2_node_creation_count++;
- bm2ref = VG_(OSetGen_AllocNode)(bm->oset, sizeof(*bm2ref));
- bm2ref->addr = a1;
- bm2 = bm2_new(a1);
- bm2ref->bm2 = bm2;
- VG_(memset)(&bm2->bm1, 0, sizeof(bm2->bm1));
- VG_(OSetGen_Insert)(bm->oset, bm2ref);
-
- bm_update_cache(*(struct bitmap**)&bm, a1, bm2);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
+ s_bitmap2_creation_count++;
+
+ bm2 = VG_(OSetGen_AllocNode)(bm->oset, sizeof(*bm2));
+ bm2->addr = a1;
+ VG_(OSetGen_Insert)(bm->oset, bm2);
+
+ bm_update_cache(bm, a1, bm2);
+
return bm2;
}
-/** Insert a new node in bitmap bm that points to the second level bitmap
- * *bm2. This means that *bm2 becomes shared over two or more bitmaps.
- */
static __inline__
-struct bitmap2* bm2_insert_addref(struct bitmap* const bm,
- struct bitmap2* const bm2)
+struct bitmap2* bm2_insert_copy(struct bitmap* const bm,
+ struct bitmap2* const bm2)
{
- struct bitmap2ref* bm2ref;
+ struct bitmap2* bm2_copy;
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm);
- tl_assert(VG_(OSetGen_Lookup)(bm->oset, &bm2->addr) == 0);
-#endif
-
- s_bitmap2_node_creation_count++;
- bm2ref = VG_(OSetGen_AllocNode)(bm->oset, sizeof(*bm2ref));
- bm2ref->addr = bm2->addr;
- bm2ref->bm2 = bm2;
- bm2->refcnt++;
- VG_(OSetGen_Insert)(bm->oset, bm2ref);
-
- bm_update_cache(*(struct bitmap**)&bm, bm2->addr, bm2);
-
- return bm2;
+ bm2_copy = bm2_insert(bm, bm2->addr);
+ VG_(memcpy)(&bm2_copy->bm1, &bm2->bm1, sizeof(bm2->bm1));
+ return bm2_copy;
}
/** Look up the address a1 in bitmap bm, and insert it if not found.
* The returned second level bitmap may not be modified.
*
- * @param a1 client address shifted right by ADDR0_BITS.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
* @param bm bitmap pointer.
*/
static __inline__
struct bitmap2* bm2_lookup_or_insert(struct bitmap* const bm, const UWord a1)
{
- struct bitmap2ref* bm2ref;
struct bitmap2* bm2;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(bm);
#endif
+
if (bm_cache_lookup(bm, a1, &bm2))
{
if (bm2 == 0)
{
bm2 = bm2_insert(bm, a1);
+ bm2_clear(bm2);
}
}
else
{
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- if (bm2ref)
+ bm2 = VG_(OSetGen_Lookup)(bm->oset, &a1);
+ if (! bm2)
{
- bm2 = bm2ref->bm2;
- }
- else
- {
bm2 = bm2_insert(bm, a1);
+ bm2_clear(bm2);
}
- bm_update_cache(*(struct bitmap**)&bm, a1, bm2);
+ bm_update_cache(bm, a1, bm2);
}
return bm2;
}
@@ -527,29 +616,14 @@
/** Look up the address a1 in bitmap bm, and insert it if not found.
* The returned second level bitmap may be modified.
*
- * @param a1 client address shifted right by ADDR0_BITS.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
* @param bm bitmap pointer.
*/
static __inline__
struct bitmap2* bm2_lookup_or_insert_exclusive(struct bitmap* const bm,
const UWord a1)
{
- struct bitmap2* bm2;
-
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm);
-#endif
- bm2 = (struct bitmap2*)bm2_lookup_or_insert(bm, a1);
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm2);
-#endif
- if (bm2->refcnt > 1)
- {
- struct bitmap2ref* bm2ref;
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- bm2 = bm2_make_exclusive(bm, bm2ref);
- }
- return bm2;
+ return bm2_lookup_or_insert(bm, a1);
}
static __inline__
@@ -558,8 +632,14 @@
{
struct bitmap2* bm2;
- bm2 = bm2_lookup_or_insert_exclusive(bm, a1 >> ADDR0_BITS);
- bm0_set_range(bm2->bm1.bm0_r, a1 & ADDR0_MASK, size);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
+
+ bm2 = bm2_lookup_or_insert_exclusive(bm, address_msb(a1));
+ bm0_set_range(bm2->bm1.bm0_r,
+ (a1 >> ADDR_IGNORED_BITS) & ADDR_LSB_MASK,
+ SCALED_SIZE(size));
}
static __inline__
@@ -568,33 +648,48 @@
{
struct bitmap2* bm2;
- bm2 = bm2_lookup_or_insert_exclusive(bm, a1 >> ADDR0_BITS);
- bm0_set_range(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
+
+ bm2 = bm2_lookup_or_insert_exclusive(bm, address_msb(a1));
+ bm0_set_range(bm2->bm1.bm0_w,
+ (a1 >> ADDR_IGNORED_BITS) & ADDR_LSB_MASK,
+ SCALED_SIZE(size));
}
static __inline__
Bool bm_aligned_load_has_conflict_with(struct bitmap* const bm,
- const Addr a1, const SizeT size)
+ const Addr a, const SizeT size)
{
const struct bitmap2* bm2;
- bm2 = bm2_lookup(bm, a1 >> ADDR0_BITS);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
- return (bm2 && bm0_is_any_set(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size));
+ bm2 = bm2_lookup(bm, address_msb(a));
+ return (bm2
+ && bm0_is_any_set(bm2->bm1.bm0_w,
+ address_lsb(a),
+ SCALED_SIZE(size)));
}
static __inline__
Bool bm_aligned_store_has_conflict_with(struct bitmap* const bm,
- const Addr a1, const SizeT size)
+ const Addr a, const SizeT size)
{
const struct bitmap2* bm2;
- bm2 = bm2_lookup(bm, a1 >> ADDR0_BITS);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
+ bm2 = bm2_lookup(bm, address_msb(a));
if (bm2)
{
- if (bm0_is_any_set(bm2->bm1.bm0_r, a1 & ADDR0_MASK, size)
- | bm0_is_any_set(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size))
+ if (bm0_is_any_set(bm2->bm1.bm0_r, address_lsb(a), SCALED_SIZE(size))
+ | bm0_is_any_set(bm2->bm1.bm0_w, address_lsb(a), SCALED_SIZE(size)))
{
return True;
}
Modified: branches/DARWIN/drd/pub_drd_bitmap.h
===================================================================
--- branches/DARWIN/drd/pub_drd_bitmap.h 2009-05-10 22:23:48 UTC (rev 9829)
+++ branches/DARWIN/drd/pub_drd_bitmap.h 2009-05-10 22:40:50 UTC (rev 9830)
@@ -34,6 +34,7 @@
#define __PUB_DRD_BITMAP_H
+#include "drd_basics.h" /* DRD_() */
#include "pub_tool_basics.h" /* Addr, SizeT */
@@ -123,8 +124,6 @@
ULong DRD_(bm_get_bitmap_creation_count)(void);
ULong DRD_(bm_get_bitmap2_node_creation_count)(void);
ULong DRD_(bm_get_bitmap2_creation_count)(void);
+ULong DRD_(bm_get_bitmap2_merge_count)(void);
-void DRD_(bm_test)(void);
-
-
#endif /* __PUB_DRD_BITMAP_H */
Modified: branches/DARWIN/drd/scripts/run-splash2
===================================================================
--- branches/DARWIN/drd/scripts/run-splash2 2009-05-10 22:23:48 UTC (rev 9829)
+++ branches/DARWIN/drd/scripts/run-splash2 2009-05-10 22:40:50 UTC (rev 9830)
@@ -59,12 +59,14 @@
p=4
test_output="${1}-drd-with-stack-var-4.out" \
print_runtime_ratio "${avg4}" "${stddev4}" "${vsz4}" "${vszdev4}" \
- "$VG" --tool=drd --check-stack-var=yes "$@" -p${psep}${p} "${test_args}"
+ "$VG" --tool=drd --first-race-only=yes --check-stack-var=yes \
+ "$@" -p${psep}${p} "${test_args}"
p=4
test_output="${1}-drd-without-stack-var-4.out" \
print_runtime_ratio "${avg4}" "${stddev4}" "${vsz4}" "${vszdev4}" \
- "$VG" --tool=drd --check-stack-var=no "$@" -p${psep}${p} "${test_args}"
+ "$VG" --tool=drd --first-race-only=yes --check-stack-var=no \
+ "$@" -p${psep}${p} "${test_args}"
p=4
test_output="${1}-helgrind-4.out" \
@@ -129,25 +131,25 @@
# granularity does ITC use ? And which m4 macro's have been used by ITC as
# implementation of the synchronization primitives ?
#
-# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
-###########################################################################################################################
-# Results: native native native none none DRD DRD HG ITC ITC
-# -p1 -p2 -p4 -p1 -p4 -p4 -p4+f -p4 -p4 -p4+f
-# .........................................................................................................................
-# Cholesky 0.09 11880 0.07 21888 0.65 41883 13.2 4.86 2.5 2.08 19 2.34 13 2.53 29 6.04 239 82
-# FFT 0.03 6560 0.02 15101 0.02 32176 21.0 7.92 20.5 2.41 118 2.81 53 3.06 120 5.42 90 41
-# LU, contiguous 0.07 3968 0.05 12176 0.06 28584 14.8 12.29 21.0 2.62 124 2.87 74 3.16 157 5.53 428 128
-# Ocean, contiguous 0.19 23208 0.18 31744 0.13 48888 6.7 3.75 10.6 2.09 69 2.52 43 2.71 264 5.95 90 28
-# Radix 0.20 15008 0.11 23200 0.11 39592 13.1 4.06 22.6 2.17 56 2.61 41 2.82 111 6.11 222 56
-# Raytrace 0.66 206976 0.47 215168 0.47 232235 8.4 1.22 10.8 1.20 272 1.53 88 1.56 211 3.79 172 53
-# Water-n2 0.19 10560 0.09 26944 0.10 59704 12.9 5.40 24.0 1.79 3793 2.92 621 2.95 109 3.54 189 39
-# Water-sp 0.21 4312 0.10 13400 0.10 29496 10.2 11.41 22.0 2.52 279 3.03 55 5.55 97 4.76 183 34
-# .........................................................................................................................
-# geometric mean 0.14 13360 0.09 26319 0.12 48476 11.9 5.21 14.0 2.06 154 2.53 64 2.88 117 5.05 180 51
-# .........................................................................................................................
+# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+############################################################################################################################
+# Results: native native native none none DRD DRD HG ITC ITC
+# -p1 -p2 -p4 -p1 -p4 -p4 -p4+f -p4 -p4 -p4+f
+# ..........................................................................................................................
+# Cholesky 0.13 12016 0.06 22016 0.59 41669 11.3 4.46 2.4 2.11 24 2.37 16 2.57 28 6.10 239 82
+# FFT 0.03 6692 0.02 15571 0.02 31962 12.0 7.92 20.0 2.43 121 2.84 54 3.09 117 5.48 90 41
+# LU, contiguous 0.08 ...
[truncated message content] |
|
From: <sv...@va...> - 2009-05-10 22:24:04
|
Author: sewardj
Date: 2009-05-10 23:23:48 +0100 (Sun, 10 May 2009)
New Revision: 9829
Log:
Hook up Memcheck to the revised XML printing framework.
Modified:
branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c
branches/MESSAGING_TIDYUP/coregrind/m_main.c
branches/MESSAGING_TIDYUP/memcheck/mc_errors.c
Modified: branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c 2009-05-10 22:14:40 UTC (rev 9828)
+++ branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c 2009-05-10 22:23:48 UTC (rev 9829)
@@ -623,8 +623,12 @@
errors = p;
if (p->supp == NULL) {
n_errs_found++;
- if (!is_first_shown_context)
- VG_(UMSG)("\n");
+ if (!is_first_shown_context) {
+ if (VG_(clo_xml))
+ VG_(printf_xml)("\n");
+ else
+ VG_(UMSG)("\n");
+ }
pp_Error(p);
is_first_shown_context = False;
n_errs_shown++;
Modified: branches/MESSAGING_TIDYUP/coregrind/m_main.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_main.c 2009-05-10 22:14:40 UTC (rev 9828)
+++ branches/MESSAGING_TIDYUP/coregrind/m_main.c 2009-05-10 22:23:48 UTC (rev 9829)
@@ -613,23 +613,23 @@
any need for user input during the run. */
if (VG_(clo_xml)) {
/* Disable suppression generation (requires user input) */
- VG_(clo_gen_suppressions) = 0;
+ //VG_(clo_gen_suppressions) = 0;
/* Disable attaching to GDB (requires user input) */
- VG_(clo_db_attach) = False;
+ //VG_(clo_db_attach) = False;
/* Set a known verbosity level */
- VG_(clo_verbosity) = 1;
+ //VG_(clo_verbosity) = 1;
/* Disable error limits (this might be a bad idea!) */
VG_(clo_error_limit) = False;
/* Disable emulation warnings */
- VG_(clo_show_emwarns) = False;
+ //VG_(clo_show_emwarns) = False;
/* Disable waiting for GDB to debug Valgrind */
- VG_(clo_wait_for_gdb) = False;
+ //VG_(clo_wait_for_gdb) = False;
/* No file-descriptor leak checking yet */
- VG_(clo_track_fds) = False;
+ //VG_(clo_track_fds) = False;
/* Disable timestamped output */
- VG_(clo_time_stamp) = False;
+ //VG_(clo_time_stamp) = False;
/* Disable heap profiling, since that prints lots of stuff. */
- VG_(clo_profile_heap) = False;
+ //VG_(clo_profile_heap) = False;
/* Also, we want to set options for the leak checker, but that
will have to be done in Memcheck's flag-handling code, not
here. */
@@ -1038,6 +1038,8 @@
// Empty line after the preamble
if (VG_(clo_verbosity) > 0)
VG_(message)(Vg_UserMsg, "\n");
+ if (VG_(clo_xml))
+ VG_(printf_xml)("\n");
if (VG_(clo_verbosity) > 1) {
SysRes fd;
@@ -2267,9 +2269,9 @@
VG_TDICT_CALL(tool_fini, 0/*exitcode*/);
if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, "\n");
- VG_(message)(Vg_UserMsg, "</valgrindoutput>\n");
- VG_(message)(Vg_UserMsg, "\n");
+ VG_(printf_xml)("\n");
+ VG_(printf_xml)("</valgrindoutput>\n");
+ VG_(printf_xml)("\n");
}
VG_(sanity_check_general)( True /*include expensive checks*/ );
Modified: branches/MESSAGING_TIDYUP/memcheck/mc_errors.c
===================================================================
--- branches/MESSAGING_TIDYUP/memcheck/mc_errors.c 2009-05-10 22:14:40 UTC (rev 9828)
+++ branches/MESSAGING_TIDYUP/memcheck/mc_errors.c 2009-05-10 22:23:48 UTC (rev 9829)
@@ -258,6 +258,36 @@
/*--- Printing errors ---*/
/*------------------------------------------------------------*/
+/* Do a printf-style op (with a trailing \n) on either the XML or
+ normal output channel, depending on the setting of VG_(clo_xml).
+*/
+static void emit_WRK ( HChar* format, va_list vargs )
+{
+ if (VG_(clo_xml)) {
+ VG_(vprintf_xml)(format, vargs);
+ } else {
+ VG_(vmessage)(Vg_UserMsg, format, vargs);
+ }
+}
+
+static void emit ( HChar* format, ... ) PRINTF_CHECK(1, 2);
+static void emit ( HChar* format, ... )
+{
+ va_list vargs;
+ va_start(vargs, format);
+ emit_WRK(format, vargs);
+ va_end(vargs);
+}
+
+static void emit_no_f_c ( HChar* format, ... )
+{
+ va_list vargs;
+ va_start(vargs, format);
+ emit_WRK(format, vargs);
+ va_end(vargs);
+}
+
+
static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc )
{
HChar* xpre = VG_(clo_xml) ? " <auxwhat>" : " ";
@@ -266,23 +296,19 @@
switch (ai->tag) {
case Addr_Unknown:
if (maybe_gcc) {
- VG_(message)(Vg_UserMsg,
- "%sAddress 0x%llx is just below the stack ptr. "
- "To suppress, use: --workaround-gcc296-bugs=yes%s\n",
- xpre, (ULong)a, xpost
- );
+ emit( "%sAddress 0x%llx is just below the stack ptr. "
+ "To suppress, use: --workaround-gcc296-bugs=yes%s\n",
+ xpre, (ULong)a, xpost );
} else {
- VG_(message)(Vg_UserMsg,
- "%sAddress 0x%llx "
- "is not stack'd, malloc'd or (recently) free'd%s\n",
- xpre, (ULong)a, xpost);
+ emit( "%sAddress 0x%llx "
+ "is not stack'd, malloc'd or (recently) free'd%s\n",
+ xpre, (ULong)a, xpost );
}
break;
case Addr_Stack:
- VG_(message)(Vg_UserMsg,
- "%sAddress 0x%llx is on thread %d's stack%s\n",
- xpre, (ULong)a, ai->Addr.Stack.tid, xpost);
+ emit( "%sAddress 0x%llx is on thread %d's stack%s\n",
+ xpre, (ULong)a, ai->Addr.Stack.tid, xpost );
break;
case Addr_Block: {
@@ -301,7 +327,7 @@
delta = rwoffset;
relative = "inside";
}
- VG_(message)(Vg_UserMsg,
+ emit(
"%sAddress 0x%lx is %'lu bytes %s a %s of size %'lu %s%s\n",
xpre,
a, delta, relative, ai->Addr.Block.block_desc,
@@ -309,39 +335,36 @@
ai->Addr.Block.block_kind==Block_Mallocd ? "alloc'd"
: ai->Addr.Block.block_kind==Block_Freed ? "free'd"
: "client-defined",
- xpost);
+ xpost
+ );
VG_(pp_ExeContext)(ai->Addr.Block.lastchange);
break;
}
case Addr_DataSym:
- VG_(message_no_f_c)(Vg_UserMsg,
- "%sAddress 0x%llx is %llu bytes "
- "inside data symbol \"%t\"%s\n",
- xpre,
- (ULong)a,
- (ULong)ai->Addr.DataSym.offset,
- ai->Addr.DataSym.name,
- xpost);
+ emit_no_f_c( "%sAddress 0x%llx is %llu bytes "
+ "inside data symbol \"%t\"%s\n",
+ xpre,
+ (ULong)a,
+ (ULong)ai->Addr.DataSym.offset,
+ ai->Addr.DataSym.name,
+ xpost );
break;
case Addr_Variable:
if (ai->Addr.Variable.descr1[0] != '\0')
- VG_(message)(Vg_UserMsg, "%s%s%s\n",
- xpre, ai->Addr.Variable.descr1, xpost);
+ emit( "%s%s%s\n", xpre, ai->Addr.Variable.descr1, xpost);
if (ai->Addr.Variable.descr2[0] != '\0')
- VG_(message)(Vg_UserMsg, "%s%s%s\n",
- xpre, ai->Addr.Variable.descr2, xpost);
+ emit( "%s%s%s\n", xpre, ai->Addr.Variable.descr2, xpost);
break;
case Addr_SectKind:
- VG_(message_no_f_c)(Vg_UserMsg,
- "%sAddress 0x%llx is in the %t segment of %t%s\n",
- xpre,
- (ULong)a,
- VG_(pp_SectKind)(ai->Addr.SectKind.kind),
- ai->Addr.SectKind.objname,
- xpost);
+ emit_no_f_c( "%sAddress 0x%llx is in the %t segment of %t%s\n",
+ xpre,
+ (ULong)a,
+ VG_(pp_SectKind)(ai->Addr.SectKind.kind),
+ ai->Addr.SectKind.objname,
+ xpost );
break;
default:
@@ -381,11 +404,15 @@
va_list vargs;
if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>%s</kind>\n", xml_name);
+ VG_(printf_xml)(" <kind>%s</kind>\n", xml_name);
// Stick xpre and xpost on the front and back of the format string.
VG_(snprintf)(buf, 256, "%s%s%s\n", xpre, format, xpost);
va_start(vargs, format);
- VG_(vmessage) ( Vg_UserMsg, buf, vargs );
+ if (VG_(clo_xml)) {
+ VG_(vprintf_xml) ( buf, vargs );
+ } else {
+ VG_(vmessage) ( Vg_UserMsg, buf, vargs );
+ }
va_end(vargs);
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
}
@@ -405,16 +432,17 @@
}
tl_assert(src); /* guards against invalid 'okind' */
- if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, " <origin>\n");
+ if (VG_(clo_xml)) {
+ VG_(printf_xml)(" <origin>\n");
+ VG_(printf_xml)("%sUninitialised value was created%s%s",
+ xpre, src, xpost);
+ VG_(pp_ExeContext)( ec );
+ VG_(printf_xml)(" </origin>\n");
+ } else {
+ VG_(message)(Vg_UserMsg, "Uninitialised value was created%s\n",
+ src);
+ VG_(pp_ExeContext)( ec );
}
-
- VG_(message)(Vg_UserMsg, "%sUninitialised value was created%s%s\n",
- xpre, src, xpost);
- VG_(pp_ExeContext)( ec );
- if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, " </origin>\n");
- }
}
void MC_(pp_Error) ( Error* err )
|
|
From: <sv...@va...> - 2009-05-10 22:14:49
|
Author: njn
Date: 2009-05-10 23:14:40 +0100 (Sun, 10 May 2009)
New Revision: 9828
Log:
Fix another layering violation in aspacemgr; it's now (more or less)
self-sufficient again.
Modified:
branches/DARWIN/coregrind/m_aspacehl.c
branches/DARWIN/coregrind/m_aspacemgr/aspacemgr-linux.c
branches/DARWIN/coregrind/m_syswrap/priv_syswrap-generic.h
branches/DARWIN/coregrind/m_syswrap/syswrap-amd64-darwin.c
branches/DARWIN/coregrind/m_syswrap/syswrap-darwin.c
branches/DARWIN/coregrind/m_syswrap/syswrap-generic.c
branches/DARWIN/coregrind/m_syswrap/syswrap-linux.c
branches/DARWIN/coregrind/m_syswrap/syswrap-x86-darwin.c
branches/DARWIN/coregrind/pub_core_aspacemgr.h
Modified: branches/DARWIN/coregrind/m_aspacehl.c
===================================================================
--- branches/DARWIN/coregrind/m_aspacehl.c 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/m_aspacehl.c 2009-05-10 22:14:40 UTC (rev 9828)
@@ -64,8 +64,6 @@
return starts;
}
-
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: branches/DARWIN/coregrind/m_aspacemgr/aspacemgr-linux.c
===================================================================
--- branches/DARWIN/coregrind/m_aspacemgr/aspacemgr-linux.c 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/m_aspacemgr/aspacemgr-linux.c 2009-05-10 22:14:40 UTC (rev 9828)
@@ -3,7 +3,7 @@
/*--- The address space manager: segment initialisation and ---*/
/*--- tracking, stack operations ---*/
/*--- ---*/
-/*--- Implementation for Linux m_aspacemgr-linux.c ---*/
+/*--- Implementation for Linux (and Darwin!) m_aspacemgr-linux.c ---*/
/*--------------------------------------------------------------------*/
/*
@@ -3273,13 +3273,12 @@
static UInt stats_machcalls = 0;
-static void
-parse_procselfmaps (
- void (*record_mapping)( Addr addr, SizeT len, UInt prot,
- ULong dev, ULong ino, Off64T foff,
- const UChar* filename ),
- void (*record_gap)( Addr addr, SizeT len )
- )
+static void parse_procselfmaps (
+ void (*record_mapping)( Addr addr, SizeT len, UInt prot,
+ ULong dev, ULong ino, Off64T offset,
+ const UChar* filename ),
+ void (*record_gap)( Addr addr, SizeT len )
+ )
{
vm_address_t iter;
unsigned int depth;
@@ -3324,31 +3323,10 @@
(*record_gap)(last, (Addr)-1 - last);
}
+ChangedSeg* css_local;
+Int css_size_local;
+Int css_used_local;
-// GrP hack
-extern void ML_(notify_aspacem_and_tool_of_mmap)
- ( Addr a, SizeT len, UInt prot, UInt flags, Int fd, Off64T offset );
-extern void ML_(notify_aspacem_and_tool_of_munmap) ( Addr a, SizeT len );
-
-typedef
- struct {
- Bool is_added; // Added or removed seg?
- Addr start;
- SizeT end;
- UInt prot; // Not used for removed segs.
- Off64T offset; // Not used for removed segs.
- }
- ChangedSeg;
-
-// I haven't seen more than 1 segment be added or removed in a single calls to
-// VG_(sync_mappings). So 20 seems generous. However, if it needs to be made
-// larger, we know that it'll never need to be larger than 'segnames_used', so
-// an array of that size could be dynamically allocated in VG_(sync_mappings).
-// --njn
-#define CHANGED_SEGS_SIZE 20
-static ChangedSeg changed_segs[CHANGED_SEGS_SIZE];
-static Int changed_segs_used;
-
static void add_mapping_callback(Addr addr, SizeT len, UInt prot,
ULong dev, ULong ino, Off64T offset,
const UChar *filename)
@@ -3378,14 +3356,14 @@
}
else if (nsegments[i].kind == SkFree || nsegments[i].kind == SkResvn) {
/* Add mapping for SkResvn regions */
- ChangedSeg* cs = &changed_segs[changed_segs_used];
- aspacem_assert(changed_segs_used < CHANGED_SEGS_SIZE);
+ ChangedSeg* cs = &css_local[css_used_local];
+ aspacem_assert(css_used_local < css_size_local);
cs->is_added = True;
cs->start = addr;
cs->end = addr + len - 1;
cs->prot = prot;
cs->offset = offset;
- changed_segs_used++;
+ css_used_local++;
return;
} else if (nsegments[i].kind == SkAnonC ||
@@ -3437,58 +3415,42 @@
for (i = iLo; i <= iHi; i++) {
if (nsegments[i].kind != SkFree && nsegments[i].kind != SkResvn) {
// V has a mapping, kernel doesn't
- ChangedSeg* cs = &changed_segs[changed_segs_used];
- aspacem_assert(changed_segs_used < CHANGED_SEGS_SIZE);
+ ChangedSeg* cs = &css_local[css_used_local];
+ aspacem_assert(css_used_local < css_size_local);
+ cs->is_added = True;
cs->is_added = False;
cs->start = nsegments[i].start;
cs->end = nsegments[i].end;
cs->prot = 0;
cs->offset = 0;
- changed_segs_used++;
+ css_used_local++;
return;
}
}
}
-void VG_(sync_mappings)(const HChar *when, const HChar *where, Int num)
+void VG_(get_changed_segments)(
+ const HChar* when, const HChar* where, /*OUT*/ChangedSeg* css,
+ Int css_size, /*OUT*/Int* css_used)
{
- Int i;
static UInt stats_synccalls = 1;
aspacem_assert(when && where);
if (0)
VG_(debugLog)(0,"aspacem",
- "[%u,%u] VG_(sync_mappings)(%s, %s, %d)\n",
- stats_synccalls++, stats_machcalls, when, where, num
+ "[%u,%u] VG_(get_changed_segments)(%s, %s)\n",
+ stats_synccalls++, stats_machcalls, when, where
);
- changed_segs_used = 0;
+ css_local = css;
+ css_size_local = css_size;
+ css_used_local = 0;
// Get the list of segs that need to be added/removed.
parse_procselfmaps(&add_mapping_callback, &remove_mapping_callback);
- // Now add/remove them.
- for (i = 0; i < changed_segs_used; i++) {
- ChangedSeg* cs = &changed_segs[i];
- Char* action;
- if (cs->is_added) {
- ML_(notify_aspacem_and_tool_of_mmap)(
- cs->start, cs->end - cs->start + 1,
- cs->prot, VKI_MAP_PRIVATE, 0, cs->offset);
- action = "added";
-
- } else {
- ML_(notify_aspacem_and_tool_of_munmap)(
- cs->start, cs->end - cs->start + 1);
- action = "removed";
- }
- if (VG_(clo_trace_syscalls)) {
- VG_(debugLog)(0, "aspacem",
- "\n%s region 0x%010lx..0x%010lx at %s (%s)",
- action, cs->start, cs->end + 1, where, when);
- }
- }
+ *css_used = css_used_local;
}
#endif
Modified: branches/DARWIN/coregrind/m_syswrap/priv_syswrap-generic.h
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/priv_syswrap-generic.h 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/m_syswrap/priv_syswrap-generic.h 2009-05-10 22:14:40 UTC (rev 9828)
@@ -62,16 +62,15 @@
extern
Bool ML_(do_sigkill)(Int pid, Int tgid);
-/* So that it can be seen from syswrap-$VG_PLATFORM.c. */
-/* When a client mmap or munmap has been successfully done, both aspacem
+/* When a client mmap or munmap has been successfully done, both the core
and the tool need to be notified of the new mapping. Hence this fn. */
extern void
-ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
- UInt mm_flags, Int fd, Off64T offset );
+ML_(notify_core_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
+ UInt mm_flags, Int fd, Off64T offset );
extern void
-ML_(notify_aspacem_and_tool_of_munmap) ( Addr a, SizeT len );
+ML_(notify_core_and_tool_of_munmap) ( Addr a, SizeT len );
extern void
-ML_(notify_aspacem_and_tool_of_mprotect) ( Addr a, SizeT len, Int prot );
+ML_(notify_core_and_tool_of_mprotect) ( Addr a, SizeT len, Int prot );
extern void
ML_(buf_and_len_pre_check) ( ThreadId tid, Addr buf_p, Addr buflen_p,
Modified: branches/DARWIN/coregrind/m_syswrap/syswrap-amd64-darwin.c
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/syswrap-amd64-darwin.c 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/m_syswrap/syswrap-amd64-darwin.c 2009-05-10 22:14:40 UTC (rev 9828)
@@ -320,17 +320,16 @@
tst->client_stack_szB = stacksize;
// pthread structure
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack+stacksize, pthread_structsize,
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack+stacksize, pthread_structsize,
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
// stack contents
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack, stacksize,
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack, stacksize,
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
// guard page
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack-VKI_PAGE_SIZE, VKI_PAGE_SIZE,
- 0, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack-VKI_PAGE_SIZE, VKI_PAGE_SIZE, 0, VKI_MAP_PRIVATE, -1, 0);
} else {
// client allocated stack
find_stack_segment(tst->tid, sp);
@@ -433,19 +432,18 @@
// GrP fixme scheduler lock?!
// pthread structure
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack+stacksize, pthread_structsize,
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack+stacksize, pthread_structsize,
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
// stack contents
// GrP fixme uninitialized!
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack, stacksize,
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack, stacksize,
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
// guard page
// GrP fixme ban_mem_stack!
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack-VKI_PAGE_SIZE, VKI_PAGE_SIZE,
- 0, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack-VKI_PAGE_SIZE, VKI_PAGE_SIZE, 0, VKI_MAP_PRIVATE, -1, 0);
VG_(am_do_sync_check)("after", "wqthread_hijack", 0);
Modified: branches/DARWIN/coregrind/m_syswrap/syswrap-darwin.c
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/syswrap-darwin.c 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/m_syswrap/syswrap-darwin.c 2009-05-10 22:14:40 UTC (rev 9828)
@@ -586,6 +586,46 @@
/* ---------------------------------------------------------------------
+ sync_mappings
+ ------------------------------------------------------------------ */
+
+static void sync_mappings(const HChar *when, const HChar *where, Int num)
+{
+ // I haven't seen more than 1 segment be added or removed in a single calls
+ // to sync_mappings(). So 20 seems generous. The upper bound is the
+ // number of segments currently in use. --njn
+ #define CSS_SIZE 20
+ ChangedSeg css[CSS_SIZE];
+ Int css_used;
+ Int i;
+
+ VG_(get_changed_segments)(when, where, css, CSS_SIZE, &css_used);
+
+ // Now add/remove them.
+ for (i = 0; i < css_used; i++) {
+ ChangedSeg* cs = &css[i];
+ Char* action;
+ if (cs->is_added) {
+ ML_(notify_core_and_tool_of_mmap)(
+ cs->start, cs->end - cs->start + 1,
+ cs->prot, VKI_MAP_PRIVATE, 0, cs->offset);
+ // should this call VG_(di_notify_mmap) also?
+ action = "added";
+
+ } else {
+ ML_(notify_core_and_tool_of_munmap)(
+ cs->start, cs->end - cs->start + 1);
+ action = "removed";
+ }
+ if (VG_(clo_trace_syscalls)) {
+ VG_(debugLog)(0, "aspacem",
+ "\n%s region 0x%010lx..0x%010lx at %s (%s)\n",
+ action, cs->start, cs->end + 1, where, when);
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------
wrappers
------------------------------------------------------------------ */
@@ -3108,8 +3148,7 @@
POST(sys_mmap)
{
if (RES != -1) {
- ML_(notify_aspacem_and_tool_of_mmap)
- (RES, ARG2, ARG3, ARG4, ARG5, ARG6);
+ ML_(notify_core_and_tool_of_mmap)(RES, ARG2, ARG3, ARG4, ARG5, ARG6);
// Try to load symbols from the region
VG_(di_notify_mmap)( (Addr)RES, False/*allow_SkFileV*/ );
}
@@ -3349,9 +3388,9 @@
PRINT("got ool mem %p..%#lx; ", desc->out_of_line.address,
(Addr)desc->out_of_line.address+desc->out_of_line.size);
- ML_(notify_aspacem_and_tool_of_mmap)
- (start, end - start, VKI_PROT_READ|VKI_PROT_WRITE,
- VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ start, end - start, VKI_PROT_READ|VKI_PROT_WRITE,
+ VKI_MAP_PRIVATE, -1, 0);
}
// GrP fixme mark only un-rounded part as initialized
break;
@@ -3366,9 +3405,9 @@
Addr end = VG_PGROUNDUP((Addr)desc->ool_ports.address + desc->ool_ports.count * sizeof(mach_port_t));
mach_port_t *ports = (mach_port_t *)desc->ool_ports.address;
- ML_(notify_aspacem_and_tool_of_mmap)
- (start, end - start, VKI_PROT_READ|VKI_PROT_WRITE,
- VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ start, end - start, VKI_PROT_READ|VKI_PROT_WRITE,
+ VKI_MAP_PRIVATE, -1, 0);
PRINT(":");
for (i = 0; i < desc->ool_ports.count; i++) {
@@ -3500,7 +3539,7 @@
Addr end = VG_PGROUNDUP((Addr)desc->out_of_line.address + size);
PRINT("kill ool mem %p..%#lx; ", desc->out_of_line.address,
(Addr)desc->out_of_line.address + size);
- ML_(notify_aspacem_and_tool_of_munmap)(start, end - start);
+ ML_(notify_core_and_tool_of_munmap)(start, end - start);
}
break;
@@ -3516,7 +3555,7 @@
Addr end = VG_PGROUNDUP((Addr)desc->ool_ports.address + size);
PRINT("kill ool port array %p..%#lx; ", desc->ool_ports.address,
(Addr)desc->ool_ports.address + size);
- ML_(notify_aspacem_and_tool_of_munmap)(start, end - start);
+ ML_(notify_core_and_tool_of_munmap)(start, end - start);
}
break;
default:
@@ -4529,9 +4568,9 @@
PRINT("allocated at %#x", reply->address);
// requesting 0 bytes returns address 0 with no error
if (MACH_ARG(vm_allocate.size)) {
- ML_(notify_aspacem_and_tool_of_mmap)
- (reply->address, MACH_ARG(vm_allocate.size),
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_ANON, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ reply->address, MACH_ARG(vm_allocate.size),
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_ANON, -1, 0);
}
} else {
PRINT("allocated at %#x in remote task %s", reply->address,
@@ -4590,7 +4629,7 @@
Addr end = VG_PGROUNDUP(MACH_ARG(vm_deallocate.address) +
MACH_ARG(vm_deallocate.size));
// Must have cleared SfMayBlock in PRE to prevent race
- ML_(notify_aspacem_and_tool_of_munmap)(start, end - start);
+ ML_(notify_core_and_tool_of_munmap)(start, end - start);
}
}
} else {
@@ -4650,7 +4689,7 @@
VG_(printf)("UNKNOWN vm_protect set maximum");
//VG_(mprotect_max_range)(start, end-start, prot);
} else {
- ML_(notify_aspacem_and_tool_of_mprotect)(start, end-start, prot);
+ ML_(notify_core_and_tool_of_mprotect)(start, end-start, prot);
}
}
} else {
@@ -4954,9 +4993,9 @@
// GrP fixme check src and dest tasks
PRINT("mapped at %#x", reply->address);
// GrP fixme max prot
- ML_(notify_aspacem_and_tool_of_mmap)
- (reply->address, VG_PGROUNDUP(MACH_ARG(vm_map.size)),
- MACH_ARG(vm_map.protection), VKI_MAP_SHARED, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ reply->address, VG_PGROUNDUP(MACH_ARG(vm_map.size)),
+ MACH_ARG(vm_map.protection), VKI_MAP_SHARED, -1, 0);
// GrP fixme VKI_MAP_PRIVATE if !copy?
} else {
PRINT("mig return %d", reply->RetCode);
@@ -5031,9 +5070,9 @@
UInt prot = reply->cur_protection & reply->max_protection;
// GrP fixme max prot
PRINT("mapped at %#x", reply->target_address);
- ML_(notify_aspacem_and_tool_of_mmap)
- (reply->target_address, VG_PGROUNDUP(MACH_ARG(vm_remap.size)),
- prot, VKI_MAP_SHARED, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ reply->target_address, VG_PGROUNDUP(MACH_ARG(vm_remap.size)),
+ prot, VKI_MAP_SHARED, -1, 0);
// GrP fixme VKI_MAP_FIXED if !copy?
// GrP fixme copy initialized bits from source to dest if source_task is also mach_task_self
} else {
@@ -5217,9 +5256,9 @@
PRINT("allocated at 0x%llx", reply->address);
// requesting 0 bytes returns address 0 with no error
if (MACH_ARG(mach_vm_allocate.size)) {
- ML_(notify_aspacem_and_tool_of_mmap)
- (reply->address, MACH_ARG(mach_vm_allocate.size),
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_ANON, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ reply->address, MACH_ARG(mach_vm_allocate.size),
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_ANON, -1, 0);
}
} else {
PRINT("allocated at 0x%llx in remote task %s", reply->address,
@@ -5278,7 +5317,7 @@
Addr end = VG_PGROUNDUP(MACH_ARG(mach_vm_deallocate.address) +
MACH_ARG(mach_vm_deallocate.size));
// Must have cleared SfMayBlock in PRE to prevent race
- ML_(notify_aspacem_and_tool_of_munmap)(start, end - start);
+ ML_(notify_core_and_tool_of_munmap)(start, end - start);
}
}
} else {
@@ -5337,7 +5376,7 @@
// DDD: #warning GrP fixme mprotect max
//VG_(mprotect_max_range)(start, end-start, prot);
} else {
- ML_(notify_aspacem_and_tool_of_mprotect)(start, end-start, prot);
+ ML_(notify_core_and_tool_of_mprotect)(start, end-start, prot);
}
}
} else {
@@ -5495,9 +5534,9 @@
// GrP fixme check src and dest tasks
PRINT("mapped at 0x%llx", reply->address);
// GrP fixme max prot
- ML_(notify_aspacem_and_tool_of_mmap)
- (reply->address, VG_PGROUNDUP(MACH_ARG(mach_vm_map.size)),
- MACH_ARG(mach_vm_map.protection), VKI_MAP_SHARED, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ reply->address, VG_PGROUNDUP(MACH_ARG(mach_vm_map.size)),
+ MACH_ARG(mach_vm_map.protection), VKI_MAP_SHARED, -1, 0);
// GrP fixme VKI_MAP_PRIVATE if !copy?
} else {
PRINT("mig return %d", reply->RetCode);
@@ -5740,7 +5779,7 @@
// GrP fixme errors?
if (ARG4) semaphore_signal((semaphore_t)ARG4);
if (ARG1 && ARG2) {
- ML_(notify_aspacem_and_tool_of_munmap)(ARG1, ARG2);
+ ML_(notify_core_and_tool_of_munmap)(ARG1, ARG2);
vm_deallocate(mach_task_self(), (vm_address_t)ARG1, (vm_size_t)ARG2);
}
@@ -5980,7 +6019,7 @@
// PRINT("UNHANDLED reply %d", mh->msgh_id);
// Assume the call may have mapped or unmapped memory
- VG_(sync_mappings)("after", "mach_msg_receive", 0);
+ sync_mappings("after", "mach_msg_receive", 0);
}
PRE(mach_msg_receive)
@@ -6391,7 +6430,7 @@
POST(mach_msg_unhandled)
{
- VG_(sync_mappings)("after", "mach_msg_unhandled", 0);
+ sync_mappings("after", "mach_msg_unhandled", 0);
}
@@ -6690,7 +6729,7 @@
POST(iokit_user_client_trap)
{
- VG_(sync_mappings)("after", "iokit_user_client_trap", ARG2);
+ sync_mappings("after", "iokit_user_client_trap", ARG2);
}
Modified: branches/DARWIN/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/syswrap-generic.c 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/m_syswrap/syswrap-generic.c 2009-05-10 22:14:40 UTC (rev 9828)
@@ -59,15 +59,6 @@
#include "priv_syswrap-generic.h"
-/* Local function declarations. */
-
-static
-void notify_aspacem_of_mmap(Addr a, SizeT len, UInt prot,
- UInt flags, Int fd, Off64T offset);
-static
-void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, ULong di_handle);
-
-
/* Returns True iff address range is something the client can
plausibly mess with: all of it is either already belongs to the
client or is free or a reservation. */
@@ -125,11 +116,6 @@
Doing mmap, mremap
------------------------------------------------------------------ */
-// Nb: this isn't done as precisely as possible, but it seems that programs
-// are usually sufficiently well-behaved that the more obscure corner cases
-// aren't important. Various comments in the few functions below give more
-// details... njn 2002-Sep-17
-
/* AFAICT from kernel sources (mm/mprotect.c) and general experimentation,
munmap, mprotect (and mremap??) work at the page level. So addresses
and lengths must be adjusted for this. */
@@ -148,35 +134,9 @@
*a = ra;
}
-/* When a client mmap has been successfully done, this function must
- be called. It notifies both aspacem and the tool of the new
- mapping.
-
- JRS 2008-Aug-14: But notice this is *very* obscure. The only place
- it is called from is POST(sys_io_setup). In particular,
- ML_(generic_PRE_sys_mmap), further down in this file, is the
- "normal case" handler for client mmap. But it doesn't call this
- function; instead it does the relevant notifications itself. Here,
- we just pass di_handle=0 to notify_tool_of_mmap as we have no
- better information. But really this function should be done away
- with; problem is I don't understand what POST(sys_io_setup) does or
- how it works.
-
- [This function is also used lots for Darwin, because
- ML_(generic_PRE_sys_mmap) cannot be used for Darwin.]
- */
-void
-ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
- UInt flags, Int fd, Off64T offset )
+static void notify_core_of_mmap(Addr a, SizeT len, UInt prot,
+ UInt flags, Int fd, Off64T offset)
{
- notify_aspacem_of_mmap(a, len, prot, flags, fd, offset);
- notify_tool_of_mmap(a, len, prot, 0/*di_handle*/);
-}
-
-static
-void notify_aspacem_of_mmap(Addr a, SizeT len, UInt prot,
- UInt flags, Int fd, Off64T offset)
-{
Bool d;
/* 'a' is the return value from a real kernel mmap, hence: */
@@ -188,11 +148,10 @@
if (d)
VG_(discard_translations)( (Addr64)a, (ULong)len,
- "ML_(notify_aspacem_of_mmap)" );
+ "notify_core_of_mmap" );
}
-static
-void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, ULong di_handle)
+static void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, ULong di_handle)
{
Bool rr, ww, xx;
@@ -208,9 +167,34 @@
VG_TRACK( new_mem_mmap, a, len, rr, ww, xx, di_handle );
}
+
+/* When a client mmap has been successfully done, this function must
+ be called. It notifies both aspacem and the tool of the new
+ mapping.
+
+ JRS 2008-Aug-14: But notice this is *very* obscure. The only place
+ it is called from is POST(sys_io_setup). In particular,
+ ML_(generic_PRE_sys_mmap), in m_syswrap, is the "normal case" handler for
+ client mmap. But it doesn't call this function; instead it does the
+ relevant notifications itself. Here, we just pass di_handle=0 to
+ notify_tool_of_mmap as we have no better information. But really this
+ function should be done away with; problem is I don't understand what
+ POST(sys_io_setup) does or how it works.
+
+ [However, this function is used lots for Darwin, because
+ ML_(generic_PRE_sys_mmap) cannot be used for Darwin.]
+ */
void
-ML_(notify_aspacem_and_tool_of_munmap) ( Addr a, SizeT len )
+ML_(notify_core_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
+ UInt flags, Int fd, Off64T offset )
{
+ notify_core_of_mmap(a, len, prot, flags, fd, offset);
+ notify_tool_of_mmap(a, len, prot, 0/*di_handle*/);
+}
+
+void
+ML_(notify_core_and_tool_of_munmap) ( Addr a, SizeT len )
+{
Bool d;
page_align_addr_and_len(&a, &len);
@@ -219,11 +203,11 @@
VG_(di_notify_munmap)( a, len );
if (d)
VG_(discard_translations)( (Addr64)a, (ULong)len,
- "ML_(notify_aspacem_and_tool_of_munmap)" );
+ "ML_(notify_core_and_tool_of_munmap)" );
}
void
-ML_(notify_aspacem_and_tool_of_mprotect) ( Addr a, SizeT len, Int prot )
+ML_(notify_core_and_tool_of_mprotect) ( Addr a, SizeT len, Int prot )
{
Bool rr = toBool(prot & VKI_PROT_READ);
Bool ww = toBool(prot & VKI_PROT_WRITE);
@@ -236,10 +220,11 @@
VG_(di_notify_mprotect)( a, len, prot );
if (d)
VG_(discard_translations)( (Addr64)a, (ULong)len,
- "ML_(notify_aspacem_and_tool_of_mprotect)" );
+ "ML_(notify_core_and_tool_of_mprotect)" );
}
+
#if HAVE_MREMAP
/* Expand (or shrink) an existing mapping, potentially moving it at
the same time (controlled by the MREMAP_MAYMOVE flag). Nightmare.
@@ -2027,7 +2012,7 @@
if (!sr_isError(sres)) {
ULong di_handle;
/* Notify aspacem. */
- notify_aspacem_of_mmap(
+ notify_core_of_mmap(
(Addr)sr_Res(sres), /* addr kernel actually assigned */
arg2, /* length */
arg3, /* prot */
@@ -3475,7 +3460,7 @@
SizeT len = ARG2;
Int prot = ARG3;
- ML_(notify_aspacem_and_tool_of_mprotect)(a, len, prot);
+ ML_(notify_core_and_tool_of_mprotect)(a, len, prot);
}
PRE(sys_munmap)
@@ -3493,7 +3478,7 @@
Addr a = ARG1;
SizeT len = ARG2;
- ML_(notify_aspacem_and_tool_of_munmap)( (Addr64)a, (ULong)len );
+ ML_(notify_core_and_tool_of_munmap)( (Addr64)a, (ULong)len );
}
PRE(sys_mincore)
Modified: branches/DARWIN/coregrind/m_syswrap/syswrap-linux.c
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/syswrap-linux.c 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/m_syswrap/syswrap-linux.c 2009-05-10 22:14:40 UTC (rev 9828)
@@ -1273,9 +1273,9 @@
r = *(struct vki_aio_ring **)ARG2;
vg_assert(ML_(valid_client_addr)((Addr)r, size, tid, "io_setup"));
- ML_(notify_aspacem_and_tool_of_mmap)( (Addr)r, size,
- VKI_PROT_READ | VKI_PROT_WRITE,
- VKI_MAP_ANONYMOUS, -1, 0 );
+ ML_(notify_core_and_tool_of_mmap)( (Addr)r, size,
+ VKI_PROT_READ | VKI_PROT_WRITE,
+ VKI_MAP_ANONYMOUS, -1, 0 );
POST_MEM_WRITE( ARG2, sizeof(vki_aio_context_t) );
}
Modified: branches/DARWIN/coregrind/m_syswrap/syswrap-x86-darwin.c
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/syswrap-x86-darwin.c 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/m_syswrap/syswrap-x86-darwin.c 2009-05-10 22:14:40 UTC (rev 9828)
@@ -315,17 +315,17 @@
tst->client_stack_szB = stacksize;
// pthread structure
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack+stacksize, pthread_structsize,
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack+stacksize, pthread_structsize,
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
// stack contents
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack, stacksize,
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack, stacksize,
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
// guard page
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack-VKI_PAGE_SIZE, VKI_PAGE_SIZE,
- 0, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack-VKI_PAGE_SIZE, VKI_PAGE_SIZE,
+ 0, VKI_MAP_PRIVATE, -1, 0);
} else {
// client allocated stack
find_stack_segment(tst->tid, sp);
@@ -462,19 +462,19 @@
// GrP fixme scheduler lock?!
// pthread structure
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack+stacksize, pthread_structsize,
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack+stacksize, pthread_structsize,
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
// stack contents
// GrP fixme uninitialized!
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack, stacksize,
- VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack, stacksize,
+ VKI_PROT_READ|VKI_PROT_WRITE, VKI_MAP_PRIVATE, -1, 0);
// guard page
// GrP fixme ban_mem_stack!
- ML_(notify_aspacem_and_tool_of_mmap)
- (stack-VKI_PAGE_SIZE, VKI_PAGE_SIZE,
- 0, VKI_MAP_PRIVATE, -1, 0);
+ ML_(notify_core_and_tool_of_mmap)(
+ stack-VKI_PAGE_SIZE, VKI_PAGE_SIZE,
+ 0, VKI_MAP_PRIVATE, -1, 0);
VG_(am_do_sync_check)("after", "wqthread_hijack", 0);
Modified: branches/DARWIN/coregrind/pub_core_aspacemgr.h
===================================================================
--- branches/DARWIN/coregrind/pub_core_aspacemgr.h 2009-05-10 20:17:27 UTC (rev 9827)
+++ branches/DARWIN/coregrind/pub_core_aspacemgr.h 2009-05-10 22:14:40 UTC (rev 9828)
@@ -406,7 +406,23 @@
extern Int VG_(am_get_VgStack_unused_szB)( VgStack* stack );
+// DDD: this is ugly
+#if defined(VGO_darwin)
+typedef
+ struct {
+ Bool is_added; // Added or removed seg?
+ Addr start;
+ SizeT end;
+ UInt prot; // Not used for removed segs.
+ Off64T offset; // Not used for removed segs.
+ }
+ ChangedSeg;
+extern void VG_(get_changed_segments)(
+ const HChar* when, const HChar* where, /*OUT*/ChangedSeg* css,
+ Int css_size, /*OUT*/Int* css_used);
+#endif
+
#endif // __PUB_CORE_ASPACEMGR_H
/*--------------------------------------------------------------------*/
|
|
From: <sv...@va...> - 2009-05-10 20:17:39
|
Author: sewardj
Date: 2009-05-10 21:17:27 +0100 (Sun, 10 May 2009)
New Revision: 9827
Log:
Cause XML output generated by the core, to go through to the XML
output channel rather than the normal one.
Modified:
branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c
branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c
branches/MESSAGING_TIDYUP/coregrind/m_main.c
branches/MESSAGING_TIDYUP/coregrind/m_stacktrace.c
Modified: branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c 2009-05-10 19:48:20 UTC (rev 9826)
+++ branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c 2009-05-10 20:17:27 UTC (rev 9827)
@@ -289,9 +289,9 @@
static void pp_Error ( Error* err )
{
if (VG_(clo_xml)) {
- VG_(UMSG)("<error>\n");
- VG_(UMSG)(" <unique>0x%x</unique>\n", err->unique);
- VG_(UMSG)(" <tid>%d</tid>\n", err->tid);
+ VG_(printf_xml)("<error>\n");
+ VG_(printf_xml)(" <unique>0x%x</unique>\n", err->unique);
+ VG_(printf_xml)(" <tid>%d</tid>\n", err->tid);
}
if (!VG_(clo_xml)) {
@@ -320,7 +320,7 @@
}
if (VG_(clo_xml))
- VG_(UMSG)("</error>\n");
+ VG_(printf_xml)("</error>\n");
}
/* Figure out if we want to perform a given action for this error, possibly
@@ -696,7 +696,7 @@
Bool any_supp;
if (VG_(clo_xml))
- VG_(UMSG)("<suppcounts>\n");
+ VG_(printf_xml)("<suppcounts>\n");
any_supp = False;
for (su = suppressions; su != NULL; su = su->next) {
@@ -704,19 +704,18 @@
continue;
any_supp = True;
if (VG_(clo_xml)) {
- VG_(message_no_f_c)(Vg_DebugMsg,
- " <pair>\n"
- " <count>%d</count>\n"
- " <name>%t</name>\n"
- " </pair>\n",
- su->count, su->sname);
+ VG_(printf_xml_no_f_c)( " <pair>\n"
+ " <count>%d</count>\n"
+ " <name>%t</name>\n"
+ " </pair>\n",
+ su->count, su->sname );
} else {
VG_(DMSG)("supp: %6d %s\n", su->count, su->sname);
}
}
if (VG_(clo_xml))
- VG_(UMSG)("</suppcounts>\n");
+ VG_(printf_xml)("</suppcounts>\n");
return any_supp;
}
@@ -812,18 +811,18 @@
void VG_(show_error_counts_as_XML) ( void )
{
Error* err;
- VG_(UMSG)("<errorcounts>\n");
+ VG_(printf_xml)("<errorcounts>\n");
for (err = errors; err != NULL; err = err->next) {
if (err->supp != NULL)
continue;
if (err->count <= 0)
continue;
- VG_(UMSG)(" <pair>\n");
- VG_(UMSG)(" <count>%d</count>\n", err->count);
- VG_(UMSG)(" <unique>0x%x</unique>\n", err->unique);
- VG_(UMSG)(" </pair>\n");
+ VG_(printf_xml)(" <pair>\n");
+ VG_(printf_xml)(" <count>%d</count>\n", err->count);
+ VG_(printf_xml)(" <unique>0x%x</unique>\n", err->unique);
+ VG_(printf_xml)(" </pair>\n");
}
- VG_(UMSG)("</errorcounts>\n");
+ VG_(printf_xml)("</errorcounts>\n");
}
Modified: branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c 2009-05-10 19:48:20 UTC (rev 9826)
+++ branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c 2009-05-10 20:17:27 UTC (rev 9827)
@@ -166,7 +166,7 @@
UInt ret;
va_list vargs;
va_start(vargs, format);
- ret = VG_(vprintf)(format, vargs);
+ ret = VG_(vprintf_xml)(format, vargs);
va_end(vargs);
return ret;
}
Modified: branches/MESSAGING_TIDYUP/coregrind/m_main.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_main.c 2009-05-10 19:48:20 UTC (rev 9826)
+++ branches/MESSAGING_TIDYUP/coregrind/m_main.c 2009-05-10 20:17:27 UTC (rev 9827)
@@ -911,131 +911,128 @@
Char* xml_fname_unexpanded,
const HChar* toolname )
{
+ Int i;
HChar* xpre = VG_(clo_xml) ? " <line>" : "";
HChar* xpost = VG_(clo_xml) ? "</line>" : "";
- Int i;
+ UInt (*umsg_or_xml)( const HChar*, ... )
+ = VG_(clo_xml) ? VG_(printf_xml) : VG_(UMSG);
vg_assert( VG_(args_for_client) );
vg_assert( VG_(args_for_valgrind) );
vg_assert( toolname );
if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, "<?xml version=\"1.0\"?>\n");
- VG_(message)(Vg_UserMsg, "\n");
- VG_(message)(Vg_UserMsg, "<valgrindoutput>\n");
- VG_(message)(Vg_UserMsg, "\n");
- VG_(message)(Vg_UserMsg, "<protocolversion>3</protocolversion>\n");
- VG_(message)(Vg_UserMsg, "\n");
+ VG_(printf_xml)("<?xml version=\"1.0\"?>\n");
+ VG_(printf_xml)("\n");
+ VG_(printf_xml)("<valgrindoutput>\n");
+ VG_(printf_xml)("\n");
+ VG_(printf_xml)("<protocolversion>3</protocolversion>\n");
+ VG_(printf_xml)("\n");
}
- if (VG_(clo_verbosity > 0)) {
+ if (VG_(clo_xml) || VG_(clo_verbosity > 0)) {
if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, "<preamble>\n");
+ VG_(printf_xml)("<preamble>\n");
/* Tool details */
- VG_(message)(Vg_UserMsg, "%s%s%s%s, %s.%s\n",
+ umsg_or_xml( "%s%s%s%s, %s.%s\n",
xpre,
VG_(details).name,
NULL == VG_(details).version ? "" : "-",
NULL == VG_(details).version
? (Char*)"" : VG_(details).version,
VG_(details).description,
- xpost);
+ xpost );
if (VG_(strlen)(toolname) >= 4
&& 0 == VG_(strncmp)(toolname, "exp-", 4)) {
- VG_(message)(
- Vg_UserMsg,
+ umsg_or_xml(
"%sNOTE: This is an Experimental-Class Valgrind Tool.%s\n",
xpre, xpost
);
}
- VG_(message)(Vg_UserMsg, "%s%s%s\n",
+ umsg_or_xml("%s%s%s\n",
xpre, VG_(details).copyright_author, xpost);
/* Core details */
- VG_(message)(Vg_UserMsg,
+ umsg_or_xml(
"%sUsing LibVEX rev %s, a library for dynamic binary translation.%s\n",
xpre, LibVEX_Version(), xpost );
- VG_(message)(Vg_UserMsg,
- "%sCopyright (C) 2004-2009, and GNU GPL'd, by OpenWorks LLP.%s\n",
+ umsg_or_xml(
+ "%sCopyright (C) 2004-2009, and GNU GPL'd, by OpenWorks Ltd.%s\n",
xpre, xpost );
- VG_(message)(Vg_UserMsg,
+ umsg_or_xml(
"%sUsing valgrind-%s, a dynamic binary instrumentation framework.%s\n",
xpre, VERSION, xpost);
- VG_(message)(Vg_UserMsg,
+ umsg_or_xml(
"%sCopyright (C) 2000-2009, and GNU GPL'd, by Julian Seward et al.%s\n",
xpre, xpost );
if (VG_(clo_verbosity) == 1 && !VG_(clo_xml))
- VG_(message)(Vg_UserMsg, "For more details, rerun with: -v\n");
+ VG_(UMSG)("For more details, rerun with: -v\n");
if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, "</preamble>\n");
+ VG_(printf_xml)("</preamble>\n");
}
if (!VG_(clo_xml) && VG_(clo_verbosity) > 0 && !logging_to_fd) {
- VG_(message)(Vg_UserMsg, "\n");
- VG_(message)(Vg_UserMsg,
- "My PID = %d, parent PID = %d. Prog and args are:\n",
- VG_(getpid)(), VG_(getppid)() );
+ VG_(UMSG)("\n");
+ VG_(UMSG)("My PID = %d, parent PID = %d. Prog and args are:\n",
+ VG_(getpid)(), VG_(getppid)() );
if (VG_(args_the_exename))
- VG_(message)(Vg_UserMsg, " %s\n", VG_(args_the_exename));
+ VG_(UMSG)(" %s\n", VG_(args_the_exename));
for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++)
- VG_(message)(Vg_UserMsg,
- " %s\n",
- * (HChar**) VG_(indexXA)( VG_(args_for_client), i ));
+ VG_(UMSG)(" %s\n",
+ * (HChar**) VG_(indexXA)( VG_(args_for_client), i ));
}
else
if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, "\n");
- VG_(message)(Vg_UserMsg, "<pid>%d</pid>\n", VG_(getpid)());
- VG_(message)(Vg_UserMsg, "<ppid>%d</ppid>\n", VG_(getppid)());
- VG_(message_no_f_c)(Vg_UserMsg, "<tool>%t</tool>\n", toolname);
+ VG_(printf_xml)("\n");
+ VG_(printf_xml)("<pid>%d</pid>\n", VG_(getpid)());
+ VG_(printf_xml)("<ppid>%d</ppid>\n", VG_(getppid)());
+ VG_(printf_xml_no_f_c)("<tool>%t</tool>\n", toolname);
if (xml_fname_unexpanded)
print_file_vars(xml_fname_unexpanded);
if (VG_(clo_xml_user_comment)) {
/* Note: the user comment itself is XML and is therefore to
be passed through verbatim (%s) rather than escaped
(%t). */
- VG_(message)(Vg_UserMsg, "<usercomment>%s</usercomment>\n",
- VG_(clo_xml_user_comment));
+ VG_(printf_xml)("<usercomment>%s</usercomment>\n",
+ VG_(clo_xml_user_comment));
}
- VG_(message)(Vg_UserMsg, "\n");
- VG_(message)(Vg_UserMsg, "<args>\n");
+ VG_(printf_xml)("\n");
+ VG_(printf_xml)("<args>\n");
- VG_(message)(Vg_UserMsg, " <vargv>\n");
+ VG_(printf_xml)(" <vargv>\n");
if (VG_(name_of_launcher))
- VG_(message_no_f_c)(Vg_UserMsg, " <exe>%t</exe>\n",
- VG_(name_of_launcher));
+ VG_(printf_xml_no_f_c)(" <exe>%t</exe>\n",
+ VG_(name_of_launcher));
else
- VG_(message_no_f_c)(Vg_UserMsg, " <exe>%t</exe>\n",
- "(launcher name unknown)");
+ VG_(printf_xml_no_f_c)(Vg_UserMsg, " <exe>%t</exe>\n",
+ "(launcher name unknown)");
for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
- VG_(message_no_f_c)(
- Vg_UserMsg,
+ VG_(printf_xml_no_f_c)(
" <arg>%t</arg>\n",
* (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i )
);
}
- VG_(message)(Vg_UserMsg, " </vargv>\n");
+ VG_(printf_xml)(" </vargv>\n");
- VG_(message)(Vg_UserMsg, " <argv>\n");
+ VG_(printf_xml)(" <argv>\n");
if (VG_(args_the_exename))
- VG_(message_no_f_c)(Vg_UserMsg, " <exe>%t</exe>\n",
- VG_(args_the_exename));
+ VG_(printf_xml_no_f_c)(" <exe>%t</exe>\n",
+ VG_(args_the_exename));
for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
- VG_(message_no_f_c)(
- Vg_UserMsg,
+ VG_(printf_xml_no_f_c)(
" <arg>%t</arg>\n",
* (HChar**) VG_(indexXA)( VG_(args_for_client), i )
);
}
- VG_(message)(Vg_UserMsg, " </argv>\n");
+ VG_(printf_xml)(" </argv>\n");
- VG_(message)(Vg_UserMsg, "</args>\n");
+ VG_(printf_xml)("</args>\n");
}
// Empty line after the preamble
@@ -2141,13 +2138,12 @@
if (VG_(clo_xml)) {
HChar buf[50];
VG_(elapsed_wallclock_time)(buf);
- VG_(message_no_f_c)(Vg_UserMsg,
- "<status>\n"
- " <state>RUNNING</state>\n"
- " <time>%t</time>\n"
- "</status>\n",
- buf);
- VG_(message)(Vg_UserMsg, "\n");
+ VG_(printf_xml_no_f_c)( "<status>\n"
+ " <state>RUNNING</state>\n"
+ " <time>%t</time>\n"
+ "</status>\n",
+ buf );
+ VG_(printf_xml_no_f_c)( "\n" );
}
VG_(debugLog)(1, "main", "Running thread 1\n");
@@ -2250,16 +2246,15 @@
HChar buf[50];
if (VG_(needs).core_errors || VG_(needs).tool_errors) {
VG_(show_error_counts_as_XML)();
- VG_(message)(Vg_UserMsg, "\n");
+ VG_(printf_xml)( "\n" );
}
VG_(elapsed_wallclock_time)(buf);
- VG_(message_no_f_c)(Vg_UserMsg,
- "<status>\n"
- " <state>FINISHED</state>\n"
- " <time>%t</time>\n"
- "</status>\n",
- buf);
- VG_(message)(Vg_UserMsg, "\n");
+ VG_(printf_xml_no_f_c)( "<status>\n"
+ " <state>FINISHED</state>\n"
+ " <time>%t</time>\n"
+ "</status>\n",
+ buf);
+ VG_(printf_xml)( "\n" );
}
/* Print out file descriptor summary and stats. */
Modified: branches/MESSAGING_TIDYUP/coregrind/m_stacktrace.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_stacktrace.c 2009-05-10 19:48:20 UTC (rev 9826)
+++ branches/MESSAGING_TIDYUP/coregrind/m_stacktrace.c 2009-05-10 20:17:27 UTC (rev 9827)
@@ -519,7 +519,7 @@
VG_(describe_IP)(ip, buf, BUF_LEN);
if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, " %s\n", buf);
+ VG_(printf_xml)(" %s\n", buf);
} else {
VG_(message)(Vg_UserMsg, " %s %s\n", ( n == 0 ? "at" : "by" ), buf);
}
@@ -531,12 +531,12 @@
vg_assert( n_ips > 0 );
if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <stack>\n");
+ VG_(printf_xml)(" <stack>\n");
VG_(apply_StackTrace)( printIpDesc, ips, n_ips );
if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " </stack>\n");
+ VG_(printf_xml)(" </stack>\n");
}
/* Get and immediately print a StackTrace. */
|
|
From: <sv...@va...> - 2009-05-10 19:48:36
|
Author: sewardj
Date: 2009-05-10 20:48:20 +0100 (Sun, 10 May 2009)
New Revision: 9826
Log:
Make VG_(printf_xml) send output on the XML output channel and not the
normal one. Duh.
Modified:
branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c
Modified: branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c 2009-05-10 19:26:37 UTC (rev 9825)
+++ branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c 2009-05-10 19:48:20 UTC (rev 9826)
@@ -155,7 +155,7 @@
UInt ret;
va_list vargs;
va_start(vargs, format);
- ret = VG_(vprintf)(format, vargs);
+ ret = VG_(vprintf_xml)(format, vargs);
va_end(vargs);
return ret;
}
|
|
From: <sv...@va...> - 2009-05-10 19:26:45
|
Author: sewardj
Date: 2009-05-10 20:26:37 +0100 (Sun, 10 May 2009)
New Revision: 9825
Log:
Fix a couple of regtest failures caused by logic changes in r9820.
Modified:
branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-generic.c
Modified: branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-generic.c 2009-05-10 18:38:53 UTC (rev 9824)
+++ branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-generic.c 2009-05-10 19:26:37 UTC (rev 9825)
@@ -1157,10 +1157,10 @@
VG_(message)(Vg_UserMsg,
"Warning: invalid file descriptor %d in syscall %s()\n",
fd, syscallname);
- if (fd == VG_(log_output_sink).fd)
+ if (fd == VG_(log_output_sink).fd && VG_(log_output_sink).fd >= 0)
VG_(message)(Vg_UserMsg,
" Use --log-fd=<number> to select an alternative log fd.\n");
- if (fd == VG_(xml_output_sink).fd)
+ if (fd == VG_(xml_output_sink).fd && VG_(xml_output_sink).fd >= 0)
VG_(message)(Vg_UserMsg,
" Use --xml-fd=<number> to select an alternative XML "
"output fd.\n");
|
|
From: <sv...@va...> - 2009-05-10 15:41:54
|
Author: bart
Date: 2009-05-10 16:41:45 +0100 (Sun, 10 May 2009)
New Revision: 9823
Log:
Let the pthread_create@GLIBC_2.0() detection test fail on PowerPC.
Modified:
trunk/configure.in
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2009-05-10 11:51:09 UTC (rev 9822)
+++ trunk/configure.in 2009-05-10 15:41:45 UTC (rev 9823)
@@ -894,7 +894,15 @@
void *(*)(void*), void*);
__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
], [
+#ifdef __powerpc__
+/*
+ * Apparently on PowerPC linking this program succeeds and generates an
+ * executable with the undefined symbol pthread_create@GLIBC_2.0.
+ */
+#error This test does not work properly on PowerPC.
+#else
pthread_create_glibc_2_0(0, 0, 0, 0);
+#endif
return 0;
],
[
|
|
From: <sv...@va...> - 2009-05-10 11:51:13
|
Author: bart Date: 2009-05-10 12:51:09 +0100 (Sun, 10 May 2009) New Revision: 9822 Log: Updated ignore list. Modified: trunk/nightly/ Property changes on: trunk/nightly ___________________________________________________________________ Name: svn:ignore + new.short new.verbose old.short old.verbose valgrind |
|
From: <sv...@va...> - 2009-05-10 11:20:16
|
Author: bart
Date: 2009-05-10 12:20:09 +0100 (Sun, 10 May 2009)
New Revision: 9821
Log:
Restored code that was deleted a few weeks ago from the trunk.
Modified:
branches/DRDDEV/drd/drd_thread.c
Modified: branches/DRDDEV/drd/drd_thread.c
===================================================================
--- branches/DRDDEV/drd/drd_thread.c 2009-05-10 11:10:08 UTC (rev 9820)
+++ branches/DRDDEV/drd/drd_thread.c 2009-05-10 11:20:09 UTC (rev 9821)
@@ -52,6 +52,7 @@
static void thread_discard_segment(const DrdThreadId tid, Segment* const sg);
static void thread_compute_conflict_set(struct bitmap** conflict_set,
const DrdThreadId tid);
+static Bool thread_conflict_set_up_to_date(const DrdThreadId tid);
/* Local variables. */
@@ -250,6 +251,7 @@
tl_assert(DRD_(g_threadinfo)[created].first == 0);
tl_assert(DRD_(g_threadinfo)[created].last == 0);
+ /* Create an initial segment for the newly created thread. */
thread_append_segment(created, DRD_(sg_new)(creator, created));
return created;
@@ -598,7 +600,9 @@
{
tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
&& tid != DRD_INVALID_THREADID);
- //tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid]));
+#if 0
+ tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid]));
+#endif
if (sg->prev)
sg->prev->next = sg->next;
@@ -610,7 +614,9 @@
DRD_(g_threadinfo)[tid].last = sg->prev;
DRD_(sg_put)(sg);
- //tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid]));
+#if 0
+ tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid]));
+#endif
}
/**
@@ -743,6 +749,44 @@
}
/**
+ * Verify that all segments of other threads than 'tid' are ordered
+ * consistently against both sg1 and sg2.
+ */
+static Bool thread_consistent_segment_ordering(const DrdThreadId tid,
+ Segment* const sg1,
+ Segment* const sg2)
+{
+ unsigned i;
+
+ tl_assert(DRD_(vc_lte)(&sg1->vc, &sg2->vc));
+
+ for (i = 0; i < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]);
+ i++)
+ {
+ Segment* sg;
+
+ if (i == tid)
+ continue;
+
+ for (sg = DRD_(g_threadinfo)[i].first; sg; sg = sg->next)
+ {
+ if (DRD_(vc_lte)(&sg2->vc, &sg->vc))
+ break;
+ if (DRD_(vc_lte)(&sg1->vc, &sg->vc))
+ return False;
+ }
+ for (sg = DRD_(g_threadinfo)[i].last; sg; sg = sg->prev)
+ {
+ if (DRD_(vc_lte)(&sg->vc, &sg1->vc))
+ break;
+ if (DRD_(vc_lte)(&sg->vc, &sg2->vc))
+ return False;
+ }
+ }
+ return True;
+}
+
+/**
* Merge all segments that may be merged without triggering false positives
* or discarding real data races. For the theoretical background of segment
* merging, see also the following paper:
@@ -760,10 +804,13 @@
{
Segment* sg;
- // tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[i]));
+#if 0
+ tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[i]));
+#endif
for (sg = DRD_(g_threadinfo)[i].first; sg; sg = sg->next)
{
+#if 1
if (DRD_(sg_get_refcnt)(sg) == 1
&& sg->next
&& DRD_(sg_get_refcnt)(sg->next) == 1
@@ -773,13 +820,92 @@
DRD_(sg_merge)(sg, sg->next);
thread_discard_segment(i, sg->next);
}
+#else
+ if (DRD_(sg_get_refcnt)(sg) == 1
+ && sg->next
+ && DRD_(sg_get_refcnt)(sg->next) == 1
+ && sg->next->next
+ && thread_consistent_segment_ordering(i, sg, sg->next))
+ {
+ /* Merge sg and sg->next into sg. */
+ DRD_(sg_merge)(sg, sg->next);
+ thread_discard_segment(i, sg->next);
+ }
+#endif
}
- // tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[i]));
+#if 0
+ tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[i]));
+#endif
}
}
/**
+ * Every change in the vector clock of a thread may cause segments that
+ * were previously ordered to this thread to become unordered. Hence,
+ * it may be necessary to recalculate the conflict set if the vector clock
+ * of the current thread is updated. This function check whether such a
+ * recalculation is necessary.
+ *
+ * @param tid Thread ID of the thread to which a new segment has been
+ * appended.
+ * @param new_sg Pointer to the most recent segment of thread tid.
+ */
+static Bool conflict_set_update_needed(const DrdThreadId tid,
+ const Segment* const new_sg)
+{
+#if 0
+ unsigned j;
+ const Segment* old_sg;
+
+ tl_assert(new_sg);
+
+ /*
+ * If a new segment has been added to another thread than the running
+ * thread, tell the caller to update the conflict set.
+ */
+ if (tid != DRD_(g_drd_running_tid))
+ return True;
+
+ tl_assert(tid == DRD_(g_drd_running_tid));
+
+ /*
+ * Always let the caller update the conflict set after creation of the
+ * first segment.
+ */
+ old_sg = new_sg->prev;
+ if (old_sg == 0)
+ return True;
+
+ for (j = 0; j < sizeof(DRD_(g_threadinfo)) / sizeof(DRD_(g_threadinfo)[0]);
+ j++)
+ {
+ Segment* q;
+
+ if (j == tid || ! DRD_(IsValidDrdThreadId)(j))
+ continue;
+
+ for (q = DRD_(g_threadinfo)[j].last; q; q = q->prev)
+ {
+ /* Does not yield correct results because of segment merging. */
+ const int included_in_old_conflict_set
+ = ! DRD_(vc_lte)(&q->vc, &old_sg->vc)
+ && ! DRD_(vc_lte)(&old_sg->vc, &q->vc);
+ const int included_in_new_conflict_set
+ = ! DRD_(vc_lte)(&q->vc, &new_sg->vc)
+ && ! DRD_(vc_lte)(&new_sg->vc, &q->vc);
+ if (included_in_old_conflict_set != included_in_new_conflict_set)
+ return True;
+ }
+ }
+
+ return False;
+#else
+ return True;
+#endif
+}
+
+/**
* Create a new segment for the specified thread, and discard any segments
* that cannot cause races anymore.
*/
@@ -793,8 +919,16 @@
new_sg = DRD_(sg_new)(tid, tid);
thread_append_segment(tid, new_sg);
- thread_compute_conflict_set(&DRD_(g_conflict_set), DRD_(g_drd_running_tid));
- s_conflict_set_new_segment_count++;
+ if (conflict_set_update_needed(tid, new_sg))
+ {
+ thread_compute_conflict_set(&DRD_(g_conflict_set),
+ DRD_(g_drd_running_tid));
+ s_conflict_set_new_segment_count++;
+ }
+ else if (tid == DRD_(g_drd_running_tid))
+ {
+ tl_assert(thread_conflict_set_up_to_date(DRD_(g_drd_running_tid)));
+ }
DRD_(thread_discard_ordered_segments)();
@@ -1030,6 +1164,37 @@
}
/**
+ * Verify whether the conflict set for thread tid is up to date. Only perform
+ * the check if the environment variable DRD_VERIFY_CONFLICT_SET has been set.
+ */
+static Bool thread_conflict_set_up_to_date(const DrdThreadId tid)
+{
+ static int do_verify_conflict_set = -1;
+ Bool result;
+ struct bitmap* computed_conflict_set = 0;
+
+ if (do_verify_conflict_set < 0)
+ do_verify_conflict_set = VG_(getenv)("DRD_VERIFY_CONFLICT_SET") != 0;
+
+ if (do_verify_conflict_set == 0)
+ return True;
+
+ thread_compute_conflict_set(&computed_conflict_set, tid);
+ result = DRD_(bm_equal)(DRD_(g_conflict_set), computed_conflict_set);
+ if (! result)
+ {
+ VG_(printf)("actual conflict set:\n");
+ DRD_(bm_print)(DRD_(g_conflict_set));
+ VG_(printf)("\n");
+ VG_(printf)("computed conflict set:\n");
+ DRD_(bm_print)(computed_conflict_set);
+ VG_(printf)("\n");
+ }
+ DRD_(bm_delete)(computed_conflict_set);
+ return result;
+}
+
+/**
* Compute a bitmap that represents the union of all memory accesses of all
* segments that are unordered to the current segment of the thread tid.
*/
|
|
From: <sv...@va...> - 2009-05-10 11:10:12
|
Author: sewardj
Date: 2009-05-10 12:10:08 +0100 (Sun, 10 May 2009)
New Revision: 9820
Log:
Add a second output channel (file descriptor), to be used for XML
output. This gives the normal text output and the XML output their
own independent file descriptors. It solves two longstanding
problems with XML output:
* in XML mode, it was not possible to emit any text output at
all, even critical warning messages, eg, to say that the
debuginfo of some object is corrupted or unreadable
* in XML mode, if any such messages did happen to get emitted
(as is inevitably the case) then tools parsing the XML would
break.
So now there are two output channels, the normal (text) channel and
the XML channel. These are specified as follows:
text channel: --log-fd=, --log-file= or --log-socket= (as before)
XML channel: --xml-fd=, --xml-file= or --xml-socket=
Note that these merely specify where the relevant kind of output
is to be sent. They have no effect on what kind of output (text
or XML) the tool actually produces. That decision is still
controlled using the --xml= flag.
Mostly the command line arg changes should be invisible to users;
the normal --log-{fd,file,socket} work exactly as before. The
only obvious change is that to get XML output into a file, you
need --xml=yes --xml-file=... instead of --xml=yes --log-file=yes
now.
There are some other associated cleanups:
* in m_libcprint, some of the routines are now parameterised also
by an OutputSink structure, which indicates where the output is
to be sent.
* in m_options, various logging related VG_(clo_...) variables
have been removed, because they're not needed. m_main examines
the command line arguments, and sets up the OutputSinks for
text and XML output; but m_libcprint "owns" those OutputSinks,
not m_options.
At present the XML outputting is not hooked up to the new mechanism.
Modified:
branches/MESSAGING_TIDYUP/coregrind/m_coredump/coredump-elf.c
branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c
branches/MESSAGING_TIDYUP/coregrind/m_main.c
branches/MESSAGING_TIDYUP/coregrind/m_options.c
branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-generic.c
branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-linux.c
branches/MESSAGING_TIDYUP/coregrind/pub_core_libcprint.h
branches/MESSAGING_TIDYUP/coregrind/pub_core_options.h
branches/MESSAGING_TIDYUP/include/pub_tool_libcprint.h
Modified: branches/MESSAGING_TIDYUP/coregrind/m_coredump/coredump-elf.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_coredump/coredump-elf.c 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/coregrind/m_coredump/coredump-elf.c 2009-05-10 11:10:08 UTC (rev 9820)
@@ -272,11 +272,11 @@
Addr *seg_starts;
Int n_seg_starts;
- if (VG_(clo_log_name) != NULL) {
+ if (VG_(clo_log_fname_expanded) != NULL) {
coreext = ".core";
basename = VG_(expand_file_name)(
"--log-file (while creating core filename)",
- VG_(clo_log_name));
+ VG_(clo_log_fname_expanded));
}
vg_assert(coreext);
Modified: branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/coregrind/m_libcprint.c 2009-05-10 11:10:08 UTC (rev 9820)
@@ -40,36 +40,40 @@
#include "valgrind.h" // For RUNNING_ON_VALGRIND
-
/* ---------------------------------------------------------------------
Writing to file or a socket
------------------------------------------------------------------ */
-/* Tell the logging mechanism whether we are logging to a file
- descriptor or a socket descriptor. */
-Bool VG_(logging_to_socket) = False;
-
+/* The destination sinks for normal and XML output. These have their
+ initial values here; they are set to final values by
+ m_main.main_process_cmd_line_options(). See comment at the top of
+ that function for the associated logic. */
+OutputSink VG_(log_output_sink) = { 2, False }; /* 2 = stderr */
+OutputSink VG_(xml_output_sink) = { -1, False }; /* disabled */
+
/* Do the low-level send of a message to the logging sink. */
-static void send_bytes_to_logging_sink ( Char* msg, Int nbytes )
+static
+void send_bytes_to_logging_sink ( OutputSink* sink, Char* msg, Int nbytes )
{
- if (!VG_(logging_to_socket)) {
- /* VG_(clo_log_fd) could have been set to -1 in the various
+ if (sink->is_socket) {
+ Int rc = VG_(write_socket)( sink->fd, msg, nbytes );
+ if (rc == -1) {
+ // For example, the listener process died. Switch back to stderr.
+ sink->is_socket = False;
+ sink->fd = 2;
+ VG_(write)( sink->fd, msg, nbytes );
+ }
+ } else {
+ /* sink->fd could have been set to -1 in the various
sys-wrappers for sys_fork, if --child-silent-after-fork=yes
is in effect. That is a signal that we should not produce
any more output. */
- if (VG_(clo_log_fd) >= 0)
- VG_(write)( VG_(clo_log_fd), msg, nbytes );
- } else {
- Int rc = VG_(write_socket)( VG_(clo_log_fd), msg, nbytes );
- if (rc == -1) {
- // For example, the listener process died. Switch back to stderr.
- VG_(logging_to_socket) = False;
- VG_(clo_log_fd) = 2;
- VG_(write)( VG_(clo_log_fd), msg, nbytes );
- }
+ if (sink->fd >= 0)
+ VG_(write)( sink->fd, msg, nbytes );
}
}
+
/* ---------------------------------------------------------------------
printf() and friends
------------------------------------------------------------------ */
@@ -78,8 +82,9 @@
typedef
struct {
- HChar buf[512];
- Int buf_used;
+ HChar buf[512];
+ Int buf_used;
+ OutputSink* sink;
}
printf_buf_t;
@@ -90,7 +95,7 @@
printf_buf_t *b = (printf_buf_t *)p;
if (b->buf_used > sizeof(b->buf) - 2 ) {
- send_bytes_to_logging_sink( b->buf, b->buf_used );
+ send_bytes_to_logging_sink( b->sink, b->buf, b->buf_used );
b->buf_used = 0;
}
b->buf[b->buf_used++] = c;
@@ -98,57 +103,75 @@
tl_assert(b->buf_used < sizeof(b->buf));
}
-static UInt vprintf_to_buf ( printf_buf_t *prbuf,
+static UInt vprintf_to_buf ( printf_buf_t* b,
const HChar *format, va_list vargs )
{
UInt ret = 0;
-
- if (VG_(clo_log_fd) >= 0) {
+ if (b->sink->fd >= 0) {
ret = VG_(debugLog_vprintf)
- ( add_to__printf_buf, prbuf, format, vargs );
+ ( add_to__printf_buf, b, format, vargs );
}
return ret;
}
-UInt VG_(vprintf) ( const HChar *format, va_list vargs )
+static UInt vprintf_WRK ( OutputSink* sink,
+ const HChar *format, va_list vargs )
{
- UInt ret = 0;
- printf_buf_t myprintf_buf = {"",0};
-
- ret = vprintf_to_buf(&myprintf_buf, format, vargs);
+ printf_buf_t myprintf_buf
+ = { "", 0, sink };
+ UInt ret
+ = vprintf_to_buf(&myprintf_buf, format, vargs);
// Write out any chars left in the buffer.
if (myprintf_buf.buf_used > 0) {
- send_bytes_to_logging_sink( myprintf_buf.buf,
+ send_bytes_to_logging_sink( myprintf_buf.sink,
+ myprintf_buf.buf,
myprintf_buf.buf_used );
}
return ret;
}
+UInt VG_(vprintf) ( const HChar *format, va_list vargs )
+{
+ return vprintf_WRK( &VG_(log_output_sink), format, vargs );
+}
+
UInt VG_(printf) ( const HChar *format, ... )
{
UInt ret;
va_list vargs;
+ va_start(vargs, format);
+ ret = VG_(vprintf)(format, vargs);
+ va_end(vargs);
+ return ret;
+}
+UInt VG_(vprintf_xml) ( const HChar *format, va_list vargs )
+{
+ return vprintf_WRK( &VG_(xml_output_sink), format, vargs );
+}
+
+UInt VG_(printf_xml) ( const HChar *format, ... )
+{
+ UInt ret;
+ va_list vargs;
va_start(vargs, format);
ret = VG_(vprintf)(format, vargs);
va_end(vargs);
+ return ret;
+}
+/* An exact clone of VG_(printf_xml), unfortunately. */
+UInt VG_(printf_xml_no_f_c) ( const HChar *format, ... )
+{
+ UInt ret;
+ va_list vargs;
+ va_start(vargs, format);
+ ret = VG_(vprintf)(format, vargs);
+ va_end(vargs);
return ret;
}
-//static UInt printf_to_buf ( printf_buf_t* prbuf, const HChar *format, ... )
-//{
-// UInt ret;
-// va_list vargs;
-//
-// va_start(vargs, format);
-// ret = vprintf_to_buf(prbuf, format, vargs);
-// va_end(vargs);
-//
-// return ret;
-//}
-
/* --------- sprintf --------- */
/* If we had an explicit buf structure here, it would contain only one
@@ -179,11 +202,9 @@
{
UInt ret;
va_list vargs;
-
va_start(vargs,format);
ret = VG_(vsprintf)(buf, format, vargs);
va_end(vargs);
-
return ret;
}
@@ -228,11 +249,9 @@
{
UInt ret;
va_list vargs;
-
va_start(vargs,format);
ret = VG_(vsnprintf)(buf, size, format, vargs);
va_end(vargs);
-
return ret;
}
@@ -342,12 +361,17 @@
Int buf_used;
Bool atLeft; /* notionally, is the next char position at the
leftmost column? */
+ /* Current message kind - changes from call to call */
VgMsgKind kind;
+ /* PID; acquired just once and stays constant */
Int my_pid;
+ /* destination */
+ OutputSink* sink;
}
vmessage_buf_t;
-static vmessage_buf_t vmessage_buf = {"", 0, True, Vg_UserMsg, -1};
+static vmessage_buf_t vmessage_buf
+ = { "", 0, True, Vg_UserMsg, -1, &VG_(log_output_sink) };
// Adds a single char to the buffer. We aim to have at least 128
@@ -413,7 +437,7 @@
b->buf[b->buf_used] = 0;
if (b->buf_used >= sizeof(b->buf) - 128) {
- send_bytes_to_logging_sink( b->buf, b->buf_used );
+ send_bytes_to_logging_sink( b->sink, b->buf, b->buf_used );
b->buf_used = 0;
}
@@ -448,7 +472,7 @@
in later messages, so don't bother to flush it right now. */
if (b->atLeft && b->buf_used > 0) {
- send_bytes_to_logging_sink( b->buf, b->buf_used );
+ send_bytes_to_logging_sink( b->sink, b->buf, b->buf_used );
b->buf_used = 0;
}
@@ -482,7 +506,7 @@
void VG_(message_flush) ( void )
{
vmessage_buf_t* b = &vmessage_buf;
- send_bytes_to_logging_sink( b->buf, b->buf_used );
+ send_bytes_to_logging_sink( b->sink, b->buf, b->buf_used );
b->buf_used = 0;
}
Modified: branches/MESSAGING_TIDYUP/coregrind/m_main.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_main.c 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/coregrind/m_main.c 2009-05-10 11:10:08 UTC (rev 9820)
@@ -217,8 +217,8 @@
Char* gdb_path = GDB_PATH;
// Ensure the message goes to stdout
- VG_(clo_log_fd) = 1;
- vg_assert( !VG_(logging_to_socket) );
+ VG_(log_output_sink).fd = 1;
+ VG_(log_output_sink).is_socket = False;
/* 'usage1' expects one char* argument */
VG_(printf)(usage1, gdb_path);
@@ -275,7 +275,8 @@
vg_assert(str);
// Nb: the version string goes to stdout.
- if VG_XACT_CLO(str, "--version", VG_(clo_log_fd), 1) {
+ if VG_XACT_CLO(str, "--version", VG_(log_output_sink).fd, 1) {
+ VG_(log_output_sink).is_socket = False;
VG_(printf)("valgrind-" VERSION "\n");
VG_(exit)(0);
}
@@ -297,26 +298,59 @@
}
/* The main processing for command line options. See comments above
- on early_process_cmd_line_options.
+ on early_process_cmd_line_options.
+
+ Comments on how the logging options are handled:
+
+ User can specify:
+ --log-fd= for a fd to write to (default setting, fd = 2)
+ --log-file= for a file name to write to
+ --log-socket= for a socket to write to
+
+ As a result of examining these and doing relevant socket/file
+ opening, a final fd is established. This is stored in
+ VG_(log_output_sink) in m_libcprint. Also, if --log-file=STR was
+ specified, then STR, after expansion of %p and %q templates within
+ it, is stored in VG_(clo_log_fname_expanded), in m_options, just in
+ case anybody wants to know what it is.
+
+ When printing, VG_(log_output_sink) is consulted to find the
+ fd to send output to.
+
+ Exactly analogous actions are undertaken for the XML output
+ channel, with the one difference that the default fd is -1, meaning
+ the channel is disabled by default.
*/
-static Bool main_process_cmd_line_options( const HChar* toolname )
+static
+void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
+ /*OUT*/Char** xml_fname_unexpanded,
+ const HChar* toolname )
{
// VG_(clo_log_fd) is used by all the messaging. It starts as 2 (stderr)
// and we cannot change it until we know what we are changing it to is
// ok. So we have tmp_log_fd to hold the tmp fd prior to that point.
SysRes sres;
- Int i, tmp_log_fd;
+ Int i, tmp_log_fd, tmp_xml_fd;
Int toolname_len = VG_(strlen)(toolname);
Char* tmp_str; // Used in a couple of places.
enum {
VgLogTo_Fd,
VgLogTo_File,
VgLogTo_Socket
- } log_to = VgLogTo_Fd; // Where is logging output to be sent?
+ } log_to = VgLogTo_Fd, // Where is logging output to be sent?
+ xml_to = VgLogTo_Fd; // Where is XML output to be sent?
- /* log to stderr by default, but usage message goes to stdout */
+ /* Temporarily holds the string STR specified with
+ --{log,xml}-{name,socket}=STR. 'fs' stands for
+ file-or-socket. */
+ Char* log_fsname_unexpanded = NULL;
+ Char* xml_fsname_unexpanded = NULL;
+
+ /* Log to stderr by default, but usage message goes to stdout. XML
+ output is initially disabled. */
tmp_log_fd = 2;
-
+ tmp_xml_fd = -1;
+
/* Check for sane path in ./configure --prefix=... */
if (VG_LIBDIR[0] != '/')
VG_(err_config_error)("Please use absolute paths in "
@@ -450,16 +484,26 @@
else if VG_INT_CLO(arg, "--log-fd", tmp_log_fd) {
log_to = VgLogTo_Fd;
- VG_(clo_log_name) = NULL;
+ log_fsname_unexpanded = NULL;
}
+ else if VG_INT_CLO(arg, "--xml-fd", tmp_xml_fd) {
+ xml_to = VgLogTo_Fd;
+ xml_fsname_unexpanded = NULL;
+ }
- else if VG_STR_CLO(arg, "--log-file", VG_(clo_log_name)) {
+ else if VG_STR_CLO(arg, "--log-file", log_fsname_unexpanded) {
log_to = VgLogTo_File;
}
-
- else if VG_STR_CLO(arg, "--log-socket", VG_(clo_log_name)) {
+ else if VG_STR_CLO(arg, "--xml-file", xml_fsname_unexpanded) {
+ xml_to = VgLogTo_File;
+ }
+
+ else if VG_STR_CLO(arg, "--log-socket", log_fsname_unexpanded) {
log_to = VgLogTo_Socket;
}
+ else if VG_STR_CLO(arg, "--xml-socket", xml_fsname_unexpanded) {
+ xml_to = VgLogTo_Socket;
+ }
else if VG_STR_CLO(arg, "--xml-user-comment",
VG_(clo_xml_user_comment)) {}
@@ -554,6 +598,16 @@
VG_(err_bad_option)("--gen-suppressions=");
}
+ /* If XML output is requested, check that the tool actually
+ supports it. */
+ if (VG_(clo_xml) && !VG_(needs).xml_output) {
+ VG_(clo_xml) = False;
+ VG_(message)(Vg_UserMsg,
+ "%s does not support XML output.\n", VG_(details).name);
+ VG_(err_bad_option)("--xml=yes");
+ /*NOTREACHED*/
+ }
+
/* If we've been asked to emit XML, mash around various other
options so as to constrain the output somewhat, and to remove
any need for user input during the run. */
@@ -588,34 +642,44 @@
the terminal any problems to do with processing command line
opts.)
- So set up logging now. After this is done, VG_(clo_log_fd)
- should be connected to whatever sink has been selected, and we
- indiscriminately chuck stuff into it without worrying what the
- nature of it is. Oh the wonder of Unix streams. */
+ So set up logging now. After this is done, VG_(log_output_sink)
+ and (if relevant) VG_(xml_output_sink) should be connected to
+ whatever sink has been selected, and we indiscriminately chuck
+ stuff into it without worrying what the nature of it is. Oh the
+ wonder of Unix streams. */
- vg_assert(VG_(clo_log_fd) == 2 /* stderr */);
- vg_assert(VG_(logging_to_socket) == False);
+ vg_assert(VG_(log_output_sink).fd == 2 /* stderr */);
+ vg_assert(VG_(log_output_sink).is_socket == False);
+ vg_assert(VG_(clo_log_fname_expanded) == NULL);
+ vg_assert(VG_(xml_output_sink).fd == -1 /* disabled */);
+ vg_assert(VG_(xml_output_sink).is_socket == False);
+ vg_assert(VG_(clo_xml_fname_expanded) == NULL);
+
+ /* --- set up the normal text output channel --- */
+
switch (log_to) {
case VgLogTo_Fd:
- vg_assert(VG_(clo_log_name) == NULL);
+ vg_assert(log_fsname_unexpanded == NULL);
break;
case VgLogTo_File: {
Char* logfilename;
- vg_assert(VG_(clo_log_name) != NULL);
- vg_assert(VG_(strlen)(VG_(clo_log_name)) <= 900); /* paranoia */
+ vg_assert(log_fsname_unexpanded != NULL);
+ vg_assert(VG_(strlen)(log_fsname_unexpanded) <= 900); /* paranoia */
// Nb: we overwrite an existing file of this name without asking
// any questions.
- logfilename = VG_(expand_file_name)("--log-file", VG_(clo_log_name));
+ logfilename = VG_(expand_file_name)("--log-file",
+ log_fsname_unexpanded);
sres = VG_(open)(logfilename,
VKI_O_CREAT|VKI_O_WRONLY|VKI_O_TRUNC,
VKI_S_IRUSR|VKI_S_IWUSR);
if (!sres.isError) {
tmp_log_fd = sres.res;
+ VG_(clo_log_fname_expanded) = logfilename;
} else {
VG_(message)(Vg_UserMsg,
"Can't create log file '%s' (%s); giving up!\n",
@@ -624,19 +688,19 @@
"--log-file=<file> (didn't work out for some reason.)");
/*NOTREACHED*/
}
- break; /* switch (VG_(clo_log_to)) */
+ break;
}
case VgLogTo_Socket: {
- vg_assert(VG_(clo_log_name) != NULL);
- vg_assert(VG_(strlen)(VG_(clo_log_name)) <= 900); /* paranoia */
- tmp_log_fd = VG_(connect_via_socket)( VG_(clo_log_name) );
+ vg_assert(log_fsname_unexpanded != NULL);
+ vg_assert(VG_(strlen)(log_fsname_unexpanded) <= 900); /* paranoia */
+ tmp_log_fd = VG_(connect_via_socket)( log_fsname_unexpanded );
if (tmp_log_fd == -1) {
VG_(message)(Vg_UserMsg,
"Invalid --log-socket=ipaddr or "
"--log-socket=ipaddr:port spec\n");
VG_(message)(Vg_UserMsg,
- "of '%s'; giving up!\n", VG_(clo_log_name) );
+ "of '%s'; giving up!\n", log_fsname_unexpanded );
VG_(err_bad_option)(
"--log-socket=");
/*NOTREACHED*/
@@ -644,62 +708,152 @@
if (tmp_log_fd == -2) {
VG_(message)(Vg_UserMsg,
"valgrind: failed to connect to logging server '%s'.\n",
- VG_(clo_log_name) );
+ log_fsname_unexpanded );
VG_(message)(Vg_UserMsg,
"Log messages will sent to stderr instead.\n" );
VG_(message)(Vg_UserMsg,
"\n" );
/* We don't change anything here. */
- vg_assert(VG_(clo_log_fd) == 2);
+ vg_assert(VG_(log_output_sink).fd == 2);
tmp_log_fd = 2;
} else {
vg_assert(tmp_log_fd > 0);
- VG_(logging_to_socket) = True;
+ VG_(log_output_sink).is_socket = True;
}
break;
}
}
+ /* --- set up the XML output channel --- */
- /* Check that the requested tool actually supports XML output. */
- if (VG_(clo_xml) && !VG_(needs).xml_output) {
- VG_(clo_xml) = False;
- VG_(message)(Vg_UserMsg,
- "%s does not support XML output.\n", VG_(details).name);
- VG_(err_bad_option)("--xml=yes");
- /*NOTREACHED*/
+ switch (xml_to) {
+
+ case VgLogTo_Fd:
+ vg_assert(xml_fsname_unexpanded == NULL);
+ break;
+
+ case VgLogTo_File: {
+ Char* xmlfilename;
+
+ vg_assert(xml_fsname_unexpanded != NULL);
+ vg_assert(VG_(strlen)(xml_fsname_unexpanded) <= 900); /* paranoia */
+
+ // Nb: we overwrite an existing file of this name without asking
+ // any questions.
+ xmlfilename = VG_(expand_file_name)("--xml-file",
+ xml_fsname_unexpanded);
+ sres = VG_(open)(xmlfilename,
+ VKI_O_CREAT|VKI_O_WRONLY|VKI_O_TRUNC,
+ VKI_S_IRUSR|VKI_S_IWUSR);
+ if (!sres.isError) {
+ tmp_xml_fd = sres.res;
+ VG_(clo_xml_fname_expanded) = xmlfilename;
+ /* strdup here is probably paranoid overkill, but ... */
+ *xml_fname_unexpanded = VG_(strdup)( "main.mpclo.2",
+ xml_fsname_unexpanded );
+ } else {
+ VG_(message)(Vg_UserMsg,
+ "Can't create XML file '%s' (%s); giving up!\n",
+ xmlfilename, VG_(strerror)(sres.err));
+ VG_(err_bad_option)(
+ "--xml-file=<file> (didn't work out for some reason.)");
+ /*NOTREACHED*/
+ }
+ break;
+ }
+
+ case VgLogTo_Socket: {
+ vg_assert(xml_fsname_unexpanded != NULL);
+ vg_assert(VG_(strlen)(xml_fsname_unexpanded) <= 900); /* paranoia */
+ tmp_xml_fd = VG_(connect_via_socket)( xml_fsname_unexpanded );
+ if (tmp_xml_fd == -1) {
+ VG_(message)(Vg_UserMsg,
+ "Invalid --xml-socket=ipaddr or "
+ "--xml-socket=ipaddr:port spec\n");
+ VG_(message)(Vg_UserMsg,
+ "of '%s'; giving up!\n", xml_fsname_unexpanded );
+ VG_(err_bad_option)(
+ "--xml-socket=");
+ /*NOTREACHED*/
+ }
+ if (tmp_xml_fd == -2) {
+ VG_(message)(Vg_UserMsg,
+ "valgrind: failed to connect to XML logging server '%s'.\n",
+ xml_fsname_unexpanded );
+ VG_(message)(Vg_UserMsg,
+ "XML output will sent to stderr instead.\n" );
+ VG_(message)(Vg_UserMsg,
+ "\n" );
+ /* We don't change anything here. */
+ vg_assert(VG_(xml_output_sink).fd == 2);
+ tmp_xml_fd = 2;
+ } else {
+ vg_assert(tmp_xml_fd > 0);
+ VG_(xml_output_sink).is_socket = True;
+ }
+ break;
+ }
}
+ // Finalise the output fds: the log fd ..
+
if (tmp_log_fd >= 0) {
- // Move log_fd into the safe range, so it doesn't conflict with any app fds.
+ // Move log_fd into the safe range, so it doesn't conflict with
+ // any app fds.
tmp_log_fd = VG_(fcntl)(tmp_log_fd, VKI_F_DUPFD, VG_(fd_hard_limit));
if (tmp_log_fd < 0) {
- VG_(message)(Vg_UserMsg, "valgrind: failed to move logfile "
- "fd into safe range, using stderr\n");
- VG_(clo_log_fd) = 2; // stderr
+ VG_(message)(Vg_UserMsg, "valgrind: failed to move logfile fd "
+ "into safe range, using stderr\n");
+ VG_(log_output_sink).fd = 2; // stderr
+ VG_(log_output_sink).is_socket = False;
} else {
- VG_(clo_log_fd) = tmp_log_fd;
- VG_(fcntl)(VG_(clo_log_fd), VKI_F_SETFD, VKI_FD_CLOEXEC);
+ VG_(log_output_sink).fd = tmp_log_fd;
+ VG_(fcntl)(VG_(log_output_sink).fd, VKI_F_SETFD, VKI_FD_CLOEXEC);
}
} else {
// If they said --log-fd=-1, don't print anything. Plausible for use in
// regression testing suites that use client requests to count errors.
- VG_(clo_log_fd) = tmp_log_fd;
+ VG_(log_output_sink).fd = -1;
+ VG_(log_output_sink).is_socket = False;
}
+ // Finalise the output fds: and the XML fd ..
+
+ if (tmp_xml_fd >= 0) {
+ // Move xml_fd into the safe range, so it doesn't conflict with
+ // any app fds.
+ tmp_xml_fd = VG_(fcntl)(tmp_xml_fd, VKI_F_DUPFD, VG_(fd_hard_limit));
+ if (tmp_xml_fd < 0) {
+ VG_(message)(Vg_UserMsg, "valgrind: failed to move XML file fd "
+ "into safe range, using stderr\n");
+ VG_(xml_output_sink).fd = 2; // stderr
+ VG_(xml_output_sink).is_socket = False;
+ } else {
+ VG_(xml_output_sink).fd = tmp_xml_fd;
+ VG_(fcntl)(VG_(xml_output_sink).fd, VKI_F_SETFD, VKI_FD_CLOEXEC);
+ }
+ } else {
+ // If they said --xml-fd=-1, don't print anything. Plausible for use in
+ // regression testing suites that use client requests to count errors.
+ VG_(xml_output_sink).fd = -1;
+ VG_(xml_output_sink).is_socket = False;
+ }
+
+ // Suppressions related stuff
+
if (VG_(clo_n_suppressions) < VG_CLO_MAX_SFILES-1 &&
(VG_(needs).core_errors || VG_(needs).tool_errors)) {
/* If we haven't reached the max number of suppressions, load
the default one. */
static const Char default_supp[] = "default.supp";
Int len = VG_(strlen)(VG_(libdir)) + 1 + sizeof(default_supp);
- Char *buf = VG_(arena_malloc)(VG_AR_CORE, "main.mpclo.2", len);
+ Char *buf = VG_(arena_malloc)(VG_AR_CORE, "main.mpclo.3", len);
VG_(sprintf)(buf, "%s/%s", VG_(libdir), default_supp);
VG_(clo_suppressions)[VG_(clo_n_suppressions)] = buf;
VG_(clo_n_suppressions)++;
}
- return (log_to == VgLogTo_Fd);
+ *logging_to_fd = log_to == VgLogTo_Fd || log_to == VgLogTo_Socket;
}
// Write the name and value of log file qualifiers to the xml file.
@@ -753,7 +907,9 @@
If logging to file or a socket, write details of parent PID and
command line args, to help people trying to interpret the
results of a run which encompasses multiple processes. */
-static void print_preamble(Bool logging_to_fd, const char* toolname)
+static void print_preamble ( Bool logging_to_fd,
+ Char* xml_fname_unexpanded,
+ const HChar* toolname )
{
HChar* xpre = VG_(clo_xml) ? " <line>" : "";
HChar* xpost = VG_(clo_xml) ? "</line>" : "";
@@ -838,8 +994,8 @@
VG_(message)(Vg_UserMsg, "<pid>%d</pid>\n", VG_(getpid)());
VG_(message)(Vg_UserMsg, "<ppid>%d</ppid>\n", VG_(getppid)());
VG_(message_no_f_c)(Vg_UserMsg, "<tool>%t</tool>\n", toolname);
- if (VG_(clo_log_name))
- print_file_vars(VG_(clo_log_name));
+ if (xml_fname_unexpanded)
+ print_file_vars(xml_fname_unexpanded);
if (VG_(clo_xml_user_comment)) {
/* Note: the user comment itself is XML and is therefore to
be passed through verbatim (%s) rather than escaped
@@ -1140,8 +1296,9 @@
HChar* toolname = "memcheck"; // default to Memcheck
Int need_help = 0; // 0 = no, 1 = --help, 2 = --help-debug
ThreadId tid_main = VG_INVALID_THREADID;
+ Bool logging_to_fd = False;
+ Char* xml_fname_unexpanded = NULL;
Int loglevel, i;
- Bool logging_to_fd;
struct vki_rlimit zero = { 0, 0 };
XArray* addr2dihandle = NULL;
@@ -1580,7 +1737,8 @@
VG_(debugLog)(1, "main",
"(main_) Process Valgrind's command line options, "
"setup logging\n");
- logging_to_fd = main_process_cmd_line_options(toolname);
+ main_process_cmd_line_options ( &logging_to_fd, &xml_fname_unexpanded,
+ toolname );
//--------------------------------------------------------------
// Zeroise the millisecond counter by doing a first read of it.
@@ -1591,12 +1749,12 @@
//--------------------------------------------------------------
// Print the preamble
// p: tl_pre_clo_init [for 'VG_(details).name' and friends]
- // p: main_process_cmd_line_options() [for VG_(clo_verbosity),
- // VG_(clo_xml),
- // logging_to_fd]
+ // p: main_process_cmd_line_options()
+ // [for VG_(clo_verbosity), VG_(clo_xml),
+ // logging_to_fd, xml_fname_unexpanded]
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Print the preamble...\n");
- print_preamble(logging_to_fd, toolname);
+ print_preamble(logging_to_fd, xml_fname_unexpanded, toolname);
VG_(debugLog)(1, "main", "...finished the preamble\n");
//--------------------------------------------------------------
Modified: branches/MESSAGING_TIDYUP/coregrind/m_options.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_options.c 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/coregrind/m_options.c 2009-05-10 11:10:08 UTC (rev 9820)
@@ -56,8 +56,8 @@
Bool VG_(clo_demangle) = True;
Bool VG_(clo_trace_children) = False;
Bool VG_(clo_child_silent_after_fork) = False;
-Int VG_(clo_log_fd) = 2; /* must be signed, as -1 is possible. */
-Char* VG_(clo_log_name) = NULL;
+Char* VG_(clo_log_fname_expanded) = NULL;
+Char* VG_(clo_xml_fname_expanded) = NULL;
Bool VG_(clo_time_stamp) = False;
Int VG_(clo_input_fd) = 0; /* stdin */
Int VG_(clo_n_suppressions) = 0;
@@ -98,8 +98,8 @@
static void revert_to_stderr ( void )
{
- vg_assert( !VG_(logging_to_socket) );
- VG_(clo_log_fd) = 2; /* stderr */
+ VG_(log_output_sink).fd = 2; /* stderr */
+ VG_(log_output_sink).is_socket = False;
}
__attribute__((noreturn))
Modified: branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-generic.c 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-generic.c 2009-05-10 11:10:08 UTC (rev 9820)
@@ -1125,8 +1125,8 @@
if (fd < 0 || fd >= VG_(fd_hard_limit))
allowed = False;
- /* hijacking the logging fd is never allowed */
- if (fd == VG_(clo_log_fd))
+ /* hijacking the output fds is never allowed */
+ if (fd == VG_(log_output_sink).fd || fd == VG_(xml_output_sink).fd)
allowed = False;
/* if creating a new fd (rather than using an existing one), the
@@ -1157,9 +1157,13 @@
VG_(message)(Vg_UserMsg,
"Warning: invalid file descriptor %d in syscall %s()\n",
fd, syscallname);
- if (fd == VG_(clo_log_fd))
+ if (fd == VG_(log_output_sink).fd)
VG_(message)(Vg_UserMsg,
" Use --log-fd=<number> to select an alternative log fd.\n");
+ if (fd == VG_(xml_output_sink).fd)
+ VG_(message)(Vg_UserMsg,
+ " Use --xml-fd=<number> to select an alternative XML "
+ "output fd.\n");
if (VG_(clo_verbosity) > 1) {
VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
}
@@ -2792,11 +2796,15 @@
VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
/* If --child-silent-after-fork=yes was specified, set the
- logging file descriptor to an 'impossible' value. This is
+ output file descriptors to 'impossible' values. This is
noticed by send_bytes_to_logging_sink in m_libcprint.c, which
- duly stops writing any further logging output. */
- if (!VG_(logging_to_socket) && VG_(clo_child_silent_after_fork))
- VG_(clo_log_fd) = -1;
+ duly stops writing any further output. */
+ if (VG_(clo_child_silent_after_fork)) {
+ if (!VG_(log_output_sink).is_socket)
+ VG_(log_output_sink).fd = -1;
+ if (!VG_(xml_output_sink).is_socket)
+ VG_(xml_output_sink).fd = -1;
+ }
}
else
if (SUCCESS && RES > 0) {
Modified: branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-linux.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-linux.c 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/coregrind/m_syswrap/syswrap-linux.c 2009-05-10 11:10:08 UTC (rev 9820)
@@ -339,11 +339,15 @@
VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
/* If --child-silent-after-fork=yes was specified, set the
- logging file descriptor to an 'impossible' value. This is
+ output file descriptors to 'impossible' values. This is
noticed by send_bytes_to_logging_sink in m_libcprint.c, which
- duly stops writing any further logging output. */
- if (!VG_(logging_to_socket) && VG_(clo_child_silent_after_fork))
- VG_(clo_log_fd) = -1;
+ duly stops writing any further output. */
+ if (VG_(clo_child_silent_after_fork)) {
+ if (!VG_(log_output_sink).is_socket)
+ VG_(log_output_sink).fd = -1;
+ if (!VG_(xml_output_sink).is_socket)
+ VG_(xml_output_sink).fd = -1;
+ }
}
else
if (!res.isError && res.res > 0) {
Modified: branches/MESSAGING_TIDYUP/coregrind/pub_core_libcprint.h
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/pub_core_libcprint.h 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/coregrind/pub_core_libcprint.h 2009-05-10 11:10:08 UTC (rev 9820)
@@ -38,9 +38,15 @@
#include "pub_tool_libcprint.h"
-/* Tell the logging mechanism whether we are logging to a file
- descriptor or a socket descriptor. */
-extern Bool VG_(logging_to_socket);
+/* An output file descriptor wrapped up with a Bool indicating whether
+ or not the fd is a socket. */
+typedef
+ struct { Int fd; Bool is_socket; }
+ OutputSink;
+
+/* And the destinations for normal and XML output. */
+extern OutputSink VG_(log_output_sink);
+extern OutputSink VG_(xml_output_sink);
/* Get the elapsed wallclock time since startup into buf, which must
16 chars long. This is unchecked. It also relies on the
Modified: branches/MESSAGING_TIDYUP/coregrind/pub_core_options.h
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/pub_core_options.h 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/coregrind/pub_core_options.h 2009-05-10 11:10:08 UTC (rev 9820)
@@ -65,31 +65,15 @@
intermingled with the parent's output. This is especially
problematic when VG_(clo_xml) is True. Setting
VG_(clo_child_silent_after_fork) causes children to fall silent
- after fork() calls. */
+ after fork() calls. Although note they become un-silent again
+ after the subsequent exec(). */
extern Bool VG_(clo_child_silent_after_fork);
-/* Where logging output is to be sent to.
+/* If the user specified --log-file=STR and/or --xml-file=STR, these
+ hold STR after expansion of the %p and %q templates. */
+extern Char* VG_(clo_log_fname_expanded);
+extern Char* VG_(clo_xml_fname_expanded);
- With --log-fd (and by default), clo_log_fd holds the file id, and is
- taken from the command line. (fd 2, stderr, is the default.)
- clo_log_name is irrelevant.
-
- With --log-file, clo_log_name holds the log-file name, and is taken from
- the command line (and possibly has process ID/env var contents in it, if
- the %p or %q format specifiers are used). clo_log_fd is then made to
- hold the relevant file id, by opening clo_log_name (concatenated with the
- process ID) for writing.
-
- With --log-socket, clo_log_name holds the hostname:portnumber pair,
- and is taken from the command line. clo_log_fd is then made to hold
- the relevant file handle, by opening a connection to that
- hostname:portnumber pair.
-
- Global default is to set log_to == VgLogTo_Fd and log_fd == 2
- (stderr). */
-extern Int VG_(clo_log_fd);
-extern Char* VG_(clo_log_name);
-
/* Add timestamps to log messages? default: NO */
extern Bool VG_(clo_time_stamp);
Modified: branches/MESSAGING_TIDYUP/include/pub_tool_libcprint.h
===================================================================
--- branches/MESSAGING_TIDYUP/include/pub_tool_libcprint.h 2009-05-10 11:08:10 UTC (rev 9819)
+++ branches/MESSAGING_TIDYUP/include/pub_tool_libcprint.h 2009-05-10 11:10:08 UTC (rev 9820)
@@ -50,22 +50,47 @@
------------------------------------------------------------------ */
/* Note that they all output to the file descriptor given by the
- * --log-fd/--log-file/--log-socket argument, which defaults to 2 (stderr).
- * Hence no need for VG_(fprintf)().
- */
-extern UInt VG_(printf) ( const HChar *format, ... ) PRINTF_CHECK(1, 2);
-extern UInt VG_(vprintf) ( const HChar *format, va_list vargs ) PRINTF_CHECK(1, 0);
-extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... ) PRINTF_CHECK(2, 3);
-extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs ) PRINTF_CHECK(2, 0);
+ --log-fd/--log-file/--log-socket argument, which defaults to 2
+ (stderr). Hence no need for VG_(fprintf)().
+*/
+extern UInt VG_(printf) ( const HChar *format, ... )
+ PRINTF_CHECK(1, 2);
+
+extern UInt VG_(vprintf) ( const HChar *format, va_list vargs )
+ PRINTF_CHECK(1, 0);
+
+extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... )
+ PRINTF_CHECK(2, 3);
+
+extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs )
+ PRINTF_CHECK(2, 0);
+
extern UInt VG_(snprintf) ( Char* buf, Int size,
- const HChar *format, ... ) PRINTF_CHECK(3, 4);
+ const HChar *format, ... )
+ PRINTF_CHECK(3, 4);
+
extern UInt VG_(vsnprintf)( Char* buf, Int size,
- const HChar *format, va_list vargs ) PRINTF_CHECK(3, 0);
+ const HChar *format, va_list vargs )
+ PRINTF_CHECK(3, 0);
+/* These are the same as the non "_xml" versions above, except the
+ output goes on the selected XML output channel instead of the
+ normal one.
+*/
+extern UInt VG_(printf_xml) ( const HChar *format, ... )
+ PRINTF_CHECK(1, 2);
+
+extern UInt VG_(vprintf_xml) ( const HChar *format, va_list vargs )
+ PRINTF_CHECK(1, 0);
+
+extern UInt VG_(printf_xml_no_f_c) ( const HChar *format, ... );
+
+
// Percentify n/m with d decimal places. Includes the '%' symbol at the end.
// Right justifies in 'buf'.
extern void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]);
+
/* ---------------------------------------------------------------------
Messages for the user
------------------------------------------------------------------ */
|
|
From: <sv...@va...> - 2009-05-10 11:08:13
|
Author: bart Date: 2009-05-10 12:08:10 +0100 (Sun, 10 May 2009) New Revision: 9819 Log: Updated ignore lists. Modified: trunk/massif/tests/ trunk/memcheck/perf/ trunk/memcheck/tests/ trunk/none/tests/linux/ trunk/none/tests/x86-linux/ trunk/tests/ Property changes on: trunk/massif/tests ___________________________________________________________________ Name: svn:ignore - *.post.diff* *.post.out *.stderr.diff* *.stderr.out *.stdout.diff* *.stdout.out .deps alloc-fns basic basic_malloc big-alloc culling1 culling2 custom_alloc deep ignoring insig long-names long-time Makefile Makefile.in malloc_usable massif.*.aux massif.*.hp massif.*.html massif.*.ps massif.*.txt massif.out.* new-cpp null one overloaded-new peak realloc thresholds zero + *.post.diff* *.post.out *.stderr.diff* *.stderr.out *.stdout.diff* *.stdout.out .deps alloc-fns basic basic_malloc big-alloc culling1 culling2 custom_alloc deep ignored ignoring insig long-names long-time Makefile Makefile.in malloc_usable massif.*.aux massif.*.hp massif.*.html massif.*.ps massif.*.txt massif.out.* new-cpp null one overloaded-new peak realloc thresholds zero Property changes on: trunk/memcheck/perf ___________________________________________________________________ Name: svn:ignore + .deps Makefile Makefile.in many-loss-records Property changes on: trunk/memcheck/tests ___________________________________________________________________ Name: svn:ignore - *.stderr.diff* *.stderr.out *.stdout.diff* *.stdout.out .deps addressable badaddrvalue badfree badjump badjump2 badloop badpoll badrw brk brk2 buflen_check clientperm clientstackperm custom_alloc deep_templates describe-block dir doublefree erringfds error_counts errs1 execve execve2 exitprog file_locking filter_leak_check_size filter_stderr fprw fwrite hello inits inline leak-0 leak-cycle leak-pool leak-regroot leak-tree leakotron linux-capget linux-syscalls-2007 linux-syslog-syscall linux-timerfd-syscall long_namespace_xml lsframe1 lsframe2 Makefile Makefile.in mallinfo malloc1 malloc2 malloc3 malloc_free_fill malloc_usable manuel1 manuel2 manuel3 match-overrun memalign2 memalign_test memcmptest mempool metadata mismatches mmaptest nanoleak nanoleak2 new_nothrow new_override noisy_child null_socket origin1-yes origin2-not-quite origin3-no origin4-many origin5-bz2 origin6-fp oset_test overlap partiallydefinedeq partial_load pdb-realloc pdb-realloc2 pipe pointer-trace post-syscall realloc1 realloc2 realloc3 scalar scalar_exit_group scalar_fork scalar_supp scalar_vfork sh-mem sh-mem-random sigaltstack sigkill signal2 sigprocmask stack_changes stack_switch strchr str_tester supp1 supp2 suppfree supp_unknown threadederrno trivialleak unit_libcbase unit_oset varinfo1 varinfo2 varinfo3 varinfo4 varinfo5 varinfo5so.so varinfo6 vcpu_bz2 vcpu_fbench vcpu_fnfns vgtest_ume weirdioctl with space wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap7so.so wrap8 writev xml1 zeropage + *.stderr.diff* *.stderr.out *.stdout.diff* *.stdout.out .deps addressable badaddrvalue badfree badjump badjump2 badloop badpoll badrw brk brk2 buflen_check clientperm clientstackperm custom_alloc deep_templates describe-block dir doublefree erringfds error_counts errs1 execve execve2 exitprog file_locking filter_leak_check_size filter_stderr fprw fwrite hello inits inline leak-0 leak-cases leak-cycle leak-pool leak-regroot leak-tree leakotron linux-capget linux-syscalls-2007 linux-syslog-syscall linux-timerfd-syscall long_namespace_xml lsframe1 lsframe2 Makefile Makefile.in mallinfo malloc1 malloc2 malloc3 malloc_free_fill malloc_usable manuel1 manuel2 manuel3 match-overrun memalign2 memalign_test memcmptest mempool metadata mismatches mmaptest nanoleak nanoleak2 nanoleak_supp new_nothrow new_override noisy_child null_socket origin1-yes origin2-not-quite origin3-no origin4-many origin5-bz2 origin6-fp oset_test overlap partiallydefinedeq partial_load pdb-realloc pdb-realloc2 pipe pointer-trace post-syscall realloc1 realloc2 realloc3 scalar scalar_exit_group scalar_fork scalar_supp scalar_vfork sh-mem sh-mem-random sigaltstack sigkill signal2 sigprocmask stack_changes stack_switch strchr str_tester supp1 supp2 suppfree supp_unknown threadederrno trivialleak unit_libcbase unit_oset varinfo1 varinfo2 varinfo3 varinfo4 varinfo5 varinfo5so.so varinfo6 vcpu_bz2 vcpu_fbench vcpu_fnfns vgtest_ume weirdioctl with space wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap7so.so wrap8 writev xml1 zeropage Property changes on: trunk/none/tests/linux ___________________________________________________________________ Name: svn:ignore - .deps Makefile Makefile.in mremap mremap2 + .deps blockfault Makefile Makefile.in mremap mremap2 Property changes on: trunk/none/tests/x86-linux ___________________________________________________________________ Name: svn:ignore + .deps Makefile Makefile.in Property changes on: trunk/tests ___________________________________________________________________ Name: svn:ignore - .deps arch_test cputest Makefile Makefile.in os_test toobig-allocs true vg_regtest + .deps arch_test cputest Makefile Makefile.in os_test toobig-allocs true vg_regtest x86_amd64_features |
|
From: <sv...@va...> - 2009-05-10 10:44:28
|
Author: bart
Date: 2009-05-10 11:44:21 +0100 (Sun, 10 May 2009)
New Revision: 9818
Log:
Made source files on the DRDDEV branch identical to trunk r9817.
Added:
branches/DRDDEV/drd/scripts/add-libjemalloc-support
Modified:
branches/DRDDEV/drd/scripts/run-splash2
Copied: branches/DRDDEV/drd/scripts/add-libjemalloc-support (from rev 8407, trunk/drd/scripts/add-libjemalloc-support)
===================================================================
--- branches/DRDDEV/drd/scripts/add-libjemalloc-support (rev 0)
+++ branches/DRDDEV/drd/scripts/add-libjemalloc-support 2009-05-10 10:44:21 UTC (rev 9818)
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+if [ ! -e coregrind/m_replacemalloc/vg_replace_malloc.c ]; then
+ echo "Error: please start this script from the Valgrind source directory."
+ exit 1
+fi
+
+if grep -q -w libjemallocZdsoZa coregrind/m_replacemalloc/vg_replace_malloc.c;
+then
+ echo "The libjemalloc patch is already present."
+ exit 0
+fi
+
+{ cat <<'EOF' | patch -p0; } || exit $?
+Index: coregrind/m_replacemalloc/vg_replace_malloc.c
+===================================================================
+--- coregrind/m_replacemalloc/vg_replace_malloc.c (revision 7759)
++++ coregrind/m_replacemalloc/vg_replace_malloc.c (revision 7778)
+@@ -68,6 +68,10 @@
+ # error "Unknown platform"
+ #endif
+
++/* --- Soname of libjemalloc. --- */
++
++#define m_jemalloc_soname libjemallocZdsoZa /* libjemalloc.so* */
++
+ /* --- Soname of the GNU C++ library. --- */
+
+ #define m_libstdcxx_soname libstdcZpZpZa // libstdc++*
+@@ -203,6 +207,7 @@
+ // (from_so, from_fn, v's replacement)
+
+ // malloc
++ALLOC_or_NULL(m_jemalloc_soname, malloc, malloc);
+ ALLOC_or_NULL(m_libstdcxx_soname, malloc, malloc);
+ ALLOC_or_NULL(m_libc_soname, malloc, malloc);
+ #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+@@ -319,6 +324,7 @@
+ }
+
+ // free
++FREE(m_jemalloc_soname, free, free );
+ FREE(m_libstdcxx_soname, free, free );
+ FREE(m_libc_soname, free, free );
+ #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+@@ -394,6 +400,7 @@
+ return v; \
+ }
+
++CALLOC(m_jemalloc_soname, calloc);
+ CALLOC(m_libc_soname, calloc);
+ #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ CALLOC(m_libc_soname, calloc_common);
+@@ -426,6 +433,7 @@
+ return v; \
+ }
+
++REALLOC(m_jemalloc_soname, realloc);
+ REALLOC(m_libc_soname, realloc);
+ #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ REALLOC(m_libc_soname, realloc_common);
+@@ -457,6 +465,7 @@
+ return v; \
+ }
+
++MEMALIGN(m_jemalloc_soname, memalign);
+ MEMALIGN(m_libc_soname, memalign);
+
+
+@@ -483,6 +492,7 @@
+ ((SizeT)pszB, size); \
+ }
+
++VALLOC(m_jemalloc_soname, valloc);
+ VALLOC(m_libc_soname, valloc);
+
+
+@@ -566,6 +576,7 @@
+ return VKI_ENOMEM; \
+ }
+
++POSIX_MEMALIGN(m_jemalloc_soname, posix_memalign);
+ POSIX_MEMALIGN(m_libc_soname, posix_memalign);
+ #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+ /* 27 Nov 07: it appears that xlc links into executables, a
+@@ -596,6 +607,7 @@
+ return pszB; \
+ }
+
++MALLOC_USABLE_SIZE(m_jemalloc_soname, malloc_usable_size);
+ MALLOC_USABLE_SIZE(m_libc_soname, malloc_usable_size);
+
+
+EOF
+
+make -s
Modified: branches/DRDDEV/drd/scripts/run-splash2
===================================================================
--- branches/DRDDEV/drd/scripts/run-splash2 2009-05-10 10:36:18 UTC (rev 9817)
+++ branches/DRDDEV/drd/scripts/run-splash2 2009-05-10 10:44:21 UTC (rev 9818)
@@ -123,8 +123,7 @@
# 19. Execution time ratio for Intel Thread Checker -p4 versus -p4.
#
# Notes:
-# - Helgrind uses a granularity of one byte for data race detection, while
-# DRD uses a granularity of four bytes.
+# - Both Helgrind and DRD use a granularity of one byte for data race detection.
# - Helgrind does detect data races on stack variables. DRD only detects
# data races on stack variables with --check-stack-var=yes.
# - The ITC tests have been run on a 4-way 2.5 GHz Pentium 4 workstation, most
@@ -132,25 +131,25 @@
# granularity does ITC use ? And which m4 macro's have been used by ITC as
# implementation of the synchronization primitives ?
#
-# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
-###########################################################################################################################
-# Results: native native native none none DRD DRD HG ITC ITC
-# -p1 -p2 -p4 -p1 -p4 -p4 -p4+f -p4 -p4 -p4+f
-# .........................................................................................................................
-# Cholesky 0.09 11880 0.07 21888 0.65 41883 13.2 4.86 2.5 2.08 19 2.34 13 2.53 29 6.04 239 82
-# FFT 0.03 6560 0.02 15101 0.02 32176 21.0 7.92 20.5 2.41 118 2.81 53 3.06 120 5.42 90 41
-# LU, contiguous 0.07 3968 0.05 12176 0.06 28584 14.8 12.29 21.0 2.62 124 2.87 74 3.16 157 5.53 428 128
-# Ocean, contiguous 0.19 23208 0.18 31744 0.13 48888 6.7 3.75 10.6 2.09 69 2.52 43 2.71 264 5.95 90 28
-# Radix 0.20 15008 0.11 23200 0.11 39592 13.1 4.06 22.6 2.17 56 2.61 41 2.82 111 6.11 222 56
-# Raytrace 0.66 206976 0.47 215168 0.47 232235 8.4 1.22 10.8 1.20 272 1.53 88 1.56 211 3.79 172 53
-# Water-n2 0.19 10560 0.09 26944 0.10 59704 12.9 5.40 24.0 1.79 3793 2.92 621 2.95 109 3.54 189 39
-# Water-sp 0.21 4312 0.10 13400 0.10 29496 10.2 11.41 22.0 2.52 279 3.03 55 5.55 97 4.76 183 34
-# .........................................................................................................................
-# geometric mean 0.14 13360 0.09 26319 0.12 48476 11.9 5.21 14.0 2.06 154 2.53 64 2.88 117 5.05 180 51
-# .........................................................................................................................
+# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+############################################################################################################################
+# Results: native native native none none DRD DRD HG ITC ITC
+# -p1 -p2 -p4 -p1 -p4 -p4 -p4+f -p4 -p4 -p4+f
+# ..........................................................................................................................
+# Cholesky 0.13 12016 0.06 22016 0.59 41669 11.3 4.46 2.4 2.11 24 2.37 16 2.57 28 6.10 239 82
+# FFT 0.03 6692 0.02 15571 0.02 31962 12.0 7.92 20.0 2.43 121 2.84 54 3.09 117 5.48 90 41
+# LU, contiguous 0.08 4100 0.05 12304 0.05 28712 13.4 12.29 20.0 2.62 117 2.73 72 3.16 156 5.53 428 128
+# Ocean, contiguous 0.25 16848 0.22 25384 0.14 42528 7.6 3.75 12.9 2.09 99 2.45 68 2.68 327 5.95 90 28
+# Radix 0.27 15136 0.10 23336 0.11 39728 12.8 4.06 24.5 2.17 65 2.61 46 2.82 121 6.15 222 56
+# Raytrace 0.82 207104 0.59 215979 0.59 232363 9.0 1.22 11.4 1.20 251 1.48 82 1.52 205 3.78 172 53
+# Water-n2 0.18 10696 0.10 27072 0.10 59832 16.4 5.40 23.8 1.79 4972 2.61 1538 2.68 110 3.54 189 39
+# Water-sp 0.22 4444 0.11 13536 0.10 29928 11.6 11.41 22.7 2.52 301 2.89 55 3.17 97 4.76 183 34
+# ..........................................................................................................................
+# geometric mean 0.17 13023 0.10 25823 0.12 47718 11.5 5.15 14.4 2.06 174 2.45 78 2.65 120 5.06 180 51
+# ..........................................................................................................................
# Hardware: dual-core Intel Core2 Duo E6750, 2.66 GHz, 4 MB L2 cache, 2 GB RAM.
-# Software: openSUSE 11.0 (64-bit edition), runlevel 3, gcc 4.3.1, 32 bit executables, valgrind trunk r9629.
-###########################################################################################################################
+# Software: openSUSE 11.0 (64-bit edition), runlevel 3, gcc 4.3.1, 32 bit executables, valgrind trunk r9796.
+############################################################################################################################
####
# Notes:
|
|
From: <sv...@va...> - 2009-05-10 10:36:22
|
Author: bart
Date: 2009-05-10 11:36:18 +0100 (Sun, 10 May 2009)
New Revision: 9817
Log:
Merged all revisions up to and including 9814 from the DRDDEV branch to the trunk for the script run-splash2. Updated performance results.
Modified:
trunk/drd/scripts/run-splash2
Modified: trunk/drd/scripts/run-splash2
===================================================================
--- trunk/drd/scripts/run-splash2 2009-05-10 06:55:39 UTC (rev 9816)
+++ trunk/drd/scripts/run-splash2 2009-05-10 10:36:18 UTC (rev 9817)
@@ -59,12 +59,14 @@
p=4
test_output="${1}-drd-with-stack-var-4.out" \
print_runtime_ratio "${avg4}" "${stddev4}" "${vsz4}" "${vszdev4}" \
- "$VG" --tool=drd --check-stack-var=yes "$@" -p${psep}${p} "${test_args}"
+ "$VG" --tool=drd --first-race-only=yes --check-stack-var=yes \
+ "$@" -p${psep}${p} "${test_args}"
p=4
test_output="${1}-drd-without-stack-var-4.out" \
print_runtime_ratio "${avg4}" "${stddev4}" "${vsz4}" "${vszdev4}" \
- "$VG" --tool=drd --check-stack-var=no "$@" -p${psep}${p} "${test_args}"
+ "$VG" --tool=drd --first-race-only=yes --check-stack-var=no \
+ "$@" -p${psep}${p} "${test_args}"
p=4
test_output="${1}-helgrind-4.out" \
@@ -129,25 +131,25 @@
# granularity does ITC use ? And which m4 macro's have been used by ITC as
# implementation of the synchronization primitives ?
#
-# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
-###########################################################################################################################
-# Results: native native native none none DRD DRD HG ITC ITC
-# -p1 -p2 -p4 -p1 -p4 -p4 -p4+f -p4 -p4 -p4+f
-# .........................................................................................................................
-# Cholesky 0.09 11880 0.07 21888 0.65 41883 13.2 4.86 2.5 2.08 19 2.34 13 2.53 29 6.04 239 82
-# FFT 0.03 6560 0.02 15101 0.02 32176 21.0 7.92 20.5 2.41 118 2.81 53 3.06 120 5.42 90 41
-# LU, contiguous 0.07 3968 0.05 12176 0.06 28584 14.8 12.29 21.0 2.62 124 2.87 74 3.16 157 5.53 428 128
-# Ocean, contiguous 0.19 23208 0.18 31744 0.13 48888 6.7 3.75 10.6 2.09 69 2.52 43 2.71 264 5.95 90 28
-# Radix 0.20 15008 0.11 23200 0.11 39592 13.1 4.06 22.6 2.17 56 2.61 41 2.82 111 6.11 222 56
-# Raytrace 0.66 206976 0.47 215168 0.47 232235 8.4 1.22 10.8 1.20 272 1.53 88 1.56 211 3.79 172 53
-# Water-n2 0.19 10560 0.09 26944 0.10 59704 12.9 5.40 24.0 1.79 3793 2.92 621 2.95 109 3.54 189 39
-# Water-sp 0.21 4312 0.10 13400 0.10 29496 10.2 11.41 22.0 2.52 279 3.03 55 5.55 97 4.76 183 34
-# .........................................................................................................................
-# geometric mean 0.14 13360 0.09 26319 0.12 48476 11.9 5.21 14.0 2.06 154 2.53 64 2.88 117 5.05 180 51
-# .........................................................................................................................
+# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+############################################################################################################################
+# Results: native native native none none DRD DRD HG ITC ITC
+# -p1 -p2 -p4 -p1 -p4 -p4 -p4+f -p4 -p4 -p4+f
+# ..........................................................................................................................
+# Cholesky 0.13 12016 0.06 22016 0.59 41669 11.3 4.46 2.4 2.11 24 2.37 16 2.57 28 6.10 239 82
+# FFT 0.03 6692 0.02 15571 0.02 31962 12.0 7.92 20.0 2.43 121 2.84 54 3.09 117 5.48 90 41
+# LU, contiguous 0.08 4100 0.05 12304 0.05 28712 13.4 12.29 20.0 2.62 117 2.73 72 3.16 156 5.53 428 128
+# Ocean, contiguous 0.25 16848 0.22 25384 0.14 42528 7.6 3.75 12.9 2.09 99 2.45 68 2.68 327 5.95 90 28
+# Radix 0.27 15136 0.10 23336 0.11 39728 12.8 4.06 24.5 2.17 65 2.61 46 2.82 121 6.15 222 56
+# Raytrace 0.82 207104 0.59 215979 0.59 232363 9.0 1.22 11.4 1.20 251 1.48 82 1.52 205 3.78 172 53
+# Water-n2 0.18 10696 0.10 27072 0.10 59832 16.4 5.40 23.8 1.79 4972 2.61 1538 2.68 110 3.54 189 39
+# Water-sp 0.22 4444 0.11 13536 0.10 29928 11.6 11.41 22.7 2.52 301 2.89 55 3.17 97 4.76 183 34
+# ..........................................................................................................................
+# geometric mean 0.17 13023 0.10 25823 0.12 47718 11.5 5.15 14.4 2.06 174 2.45 78 2.65 120 5.06 180 51
+# ..........................................................................................................................
# Hardware: dual-core Intel Core2 Duo E6750, 2.66 GHz, 4 MB L2 cache, 2 GB RAM.
-# Software: openSUSE 11.0 (64-bit edition), runlevel 3, gcc 4.3.1, 32 bit executables, valgrind trunk r9629.
-###########################################################################################################################
+# Software: openSUSE 11.0 (64-bit edition), runlevel 3, gcc 4.3.1, 32 bit executables, valgrind trunk r9796.
+############################################################################################################################
####
# Notes:
|
|
From: <sv...@va...> - 2009-05-10 06:55:43
|
Author: bart
Date: 2009-05-10 07:55:39 +0100 (Sun, 10 May 2009)
New Revision: 9816
Log:
Merged all revisions up to and including 9814 from the DRDDEV branch to the trunk for the files pub_drd_bitmap.h, drd_bitmap.h, drd_bitmap.c and tests/drd_bitmap_test.c.
Modified:
trunk/drd/drd_bitmap.c
trunk/drd/drd_bitmap.h
trunk/drd/pub_drd_bitmap.h
trunk/drd/tests/drd_bitmap_test.c
Modified: trunk/drd/drd_bitmap.c
===================================================================
--- trunk/drd/drd_bitmap.c 2009-05-10 06:46:31 UTC (rev 9815)
+++ trunk/drd/drd_bitmap.c 2009-05-10 06:55:39 UTC (rev 9816)
@@ -37,20 +37,18 @@
#include "pub_tool_mallocfree.h" /* VG_(malloc), VG_(free) */
-/* Forward declarations. */
-
-struct bitmap2;
-
-
/* Local function declarations. */
static void bm2_merge(struct bitmap2* const bm2l,
const struct bitmap2* const bm2r);
+static void bm2_print(const struct bitmap2* const bm2);
/* Local variables. */
static ULong s_bitmap_creation_count;
+static ULong s_bitmap_merge_count;
+static ULong s_bitmap2_merge_count;
/* Function definitions. */
@@ -66,9 +64,10 @@
bm = VG_(malloc)("drd.bitmap.bn.1", sizeof(*bm));
tl_assert(bm);
- /* Cache initialization. a1 is initialized with a value that never can */
- /* match any valid address: the upper ADDR0_BITS bits of a1 are always */
- /* zero for a valid cache entry. */
+ /* Cache initialization. a1 is initialized with a value that never can
+ * match any valid address: the upper (ADDR_LSB_BITS + ADDR_IGNORED_BITS)
+ * bits of a1 are always zero for a valid cache entry.
+ */
for (i = 0; i < N_CACHE_ELEM; i++)
{
bm->cache[i].a1 = ~(UWord)1;
@@ -84,22 +83,8 @@
void DRD_(bm_delete)(struct bitmap* const bm)
{
- struct bitmap2* bm2;
- struct bitmap2ref* bm2ref;
-
tl_assert(bm);
- VG_(OSetGen_ResetIter)(bm->oset);
- for ( ; (bm2ref = VG_(OSetGen_Next)(bm->oset)) != 0; )
- {
- bm2 = bm2ref->bm2;
- tl_assert(bm2->refcnt >= 1);
- if (--bm2->refcnt == 0)
- {
- VG_(free)(bm2);
- }
- }
-
VG_(OSetGen_Destroy)(bm->oset);
VG_(free)(bm);
}
@@ -107,6 +92,11 @@
/**
* Record an access of type access_type at addresses a .. a + size - 1 in
* bitmap bm.
+ *
+ * @note The current implementation of bm_access_range does not work for the
+ * highest addresses in the address range. At least on Linux this is
+ * not a problem since the upper part of the address space is reserved
+ * for the kernel.
*/
void DRD_(bm_access_range)(struct bitmap* const bm,
const Addr a1, const Addr a2,
@@ -120,52 +110,50 @@
return DRD_(bm_access_range_store)(bm, a1, a2);
}
-void DRD_(bm_access_range_load)(struct bitmap* const bm,
- const Addr a1, const Addr a2)
+void DRD_(bm_access_range_load)(struct bitmap* const bm, Addr a1, Addr a2)
{
Addr b, b_next;
tl_assert(bm);
tl_assert(a1 < a2);
- /* The current implementation of bm_access_range does not work for the */
- /* ADDR0_COUNT highest addresses in the address range. At least on Linux */
- /* this is not a problem since the upper part of the address space is */
- /* reserved for the kernel. */
- tl_assert(a2 + ADDR0_COUNT > a2);
+ tl_assert(a2 < first_address_with_higher_msb(a2));
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
for (b = a1; b < a2; b = b_next)
{
Addr b_start;
Addr b_end;
struct bitmap2* bm2;
- SPLIT_ADDRESS(b);
+ UWord b0;
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
}
- bm2 = bm2_lookup_or_insert_exclusive(bm, b1);
+ bm2 = bm2_lookup_or_insert_exclusive(bm, address_msb(b));
tl_assert(bm2);
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_start && b_start < b_end && b_end && b_end <= a2);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_msb(b_start) == address_msb(b_end - 1));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- if (b_end - b_start == ADDR0_COUNT)
+ if (address_lsb(b_start) == 0 && address_lsb(b_end) == 0)
{
unsigned k;
@@ -176,7 +164,7 @@
}
else
{
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end - 1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
bm0_set(bm2->bm1.bm0_r, b0);
}
@@ -225,45 +213,44 @@
tl_assert(bm);
tl_assert(a1 < a2);
- /* The current implementation of bm_access_range does not work for the */
- /* ADDR0_COUNT highest addresses in the address range. At least on Linux */
- /* this is not a problem since the upper part of the address space is */
- /* reserved for the kernel. */
- tl_assert(a2 + ADDR0_COUNT > a2);
+ tl_assert(a2 < first_address_with_higher_msb(a2));
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
for (b = a1; b < a2; b = b_next)
{
Addr b_start;
Addr b_end;
struct bitmap2* bm2;
- SPLIT_ADDRESS(b);
+ UWord b0;
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
}
- bm2 = bm2_lookup_or_insert_exclusive(bm, b1);
+ bm2 = bm2_lookup_or_insert_exclusive(bm, address_msb(b));
tl_assert(bm2);
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_start && b_start < b_end && b_end && b_end <= a2);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_msb(b_start) == address_msb(b_end - 1));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- if (b_end - b_start == ADDR0_COUNT)
+ if (address_lsb(b_start) == 0 && address_lsb(b_end) == 0)
{
unsigned k;
@@ -274,7 +261,7 @@
}
else
{
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end - 1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
bm0_set(bm2->bm1.bm0_w, b0);
}
@@ -336,9 +323,9 @@
for (b = a1; b < a2; b = b_next)
{
- const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+ const struct bitmap2* bm2 = bm2_lookup(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -351,24 +338,24 @@
UWord b0;
const struct bitmap1* const p1 = &bm2->bm1;
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
tl_assert(a1 <= b_start && b_start <= a2);
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_end && b_end <= a2);
tl_assert(b_start < b_end);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
if (bm0_is_set(p1->bm0_r, b0))
{
@@ -389,9 +376,9 @@
for (b = a1; b < a2; b = b_next)
{
- const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+ const struct bitmap2* bm2 = bm2_lookup(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -404,24 +391,24 @@
UWord b0;
const struct bitmap1* const p1 = &bm2->bm1;
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
tl_assert(a1 <= b_start && b_start <= a2);
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_end && b_end <= a2);
tl_assert(b_start < b_end);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
if (bm0_is_set(p1->bm0_w, b0))
{
@@ -444,9 +431,9 @@
for (b = a1; b < a2; b = b_next)
{
- const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+ const struct bitmap2* bm2 = bm2_lookup(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -459,24 +446,24 @@
UWord b0;
const struct bitmap1* const p1 = &bm2->bm1;
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
tl_assert(a1 <= b_start && b_start <= a2);
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_end && b_end <= a2);
tl_assert(b_start < b_end);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
if (bm0_is_set(p1->bm0_r, b0) | bm0_is_set(p1->bm0_w, b0))
{
@@ -498,11 +485,11 @@
const struct bitmap2* p2;
const struct bitmap1* p1;
const UWord* p0;
- const UWord a0 = a & ADDR0_MASK;
+ const UWord a0 = address_lsb(a);
tl_assert(bm);
- p2 = bm2_lookup(bm, a >> ADDR0_BITS);
+ p2 = bm2_lookup(bm, address_msb(a));
if (p2)
{
p1 = &p2->bm1;
@@ -512,13 +499,15 @@
return False;
}
-void DRD_(bm_clear)(struct bitmap* const bm, const Addr a1, const Addr a2)
+void DRD_(bm_clear)(struct bitmap* const bm, Addr a1, Addr a2)
{
Addr b, b_next;
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
for (b = a1; b < a2; b = b_next)
{
@@ -529,9 +518,9 @@
tl_assert(a1 <= b && b < a2);
#endif
- p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
+ p2 = bm2_lookup_exclusive(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -543,34 +532,33 @@
c = b;
/* If the first address in the bitmap that must be cleared does not */
/* start on an UWord boundary, start clearing the first addresses. */
- if (UWORD_LSB(c))
+ if (uword_lsb(address_lsb(c)))
{
- Addr c_next = UWORD_MSB(c) + BITS_PER_UWORD;
+ Addr c_next = first_address_with_higher_uword_msb(c);
if (c_next > b_next)
c_next = b_next;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= c_next && c_next <= b_next
&& b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, c_next - c);
- bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, c_next - c);
+ bm0_clear_range(p2->bm1.bm0_r, address_lsb(c), SCALED_SIZE(c_next - c));
+ bm0_clear_range(p2->bm1.bm0_w, address_lsb(c), SCALED_SIZE(c_next - c));
c = c_next;
}
/* If some UWords have to be cleared entirely, do this now. */
- if (UWORD_LSB(c) == 0)
+ if (uword_lsb(address_lsb(c)) == 0)
{
- const Addr c_next = UWORD_MSB(b_next);
+ Addr c_next = first_address_with_same_uword_lsb(b_next);
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(UWORD_LSB(c) == 0);
- tl_assert(UWORD_LSB(c_next) == 0);
+ tl_assert(uword_lsb(address_lsb(c)) == 0);
+ tl_assert(uword_lsb(address_lsb(c_next)) == 0);
tl_assert(c_next <= b_next);
- tl_assert(c <= c_next);
#endif
if (c_next > c)
{
- UWord idx = (c & ADDR0_MASK) >> BITS_PER_BITS_PER_UWORD;
- VG_(memset)(&p2->bm1.bm0_r[idx], 0, (c_next - c) / 8);
- VG_(memset)(&p2->bm1.bm0_w[idx], 0, (c_next - c) / 8);
+ UWord idx = uword_msb(address_lsb(c));
+ VG_(memset)(&p2->bm1.bm0_r[idx], 0, SCALED_SIZE((c_next - c) / 8));
+ VG_(memset)(&p2->bm1.bm0_w[idx], 0, SCALED_SIZE((c_next - c) / 8));
c = c_next;
}
}
@@ -579,8 +567,8 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, b_next - c);
- bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, b_next - c);
+ bm0_clear_range(p2->bm1.bm0_r, address_lsb(c), SCALED_SIZE(b_next - c));
+ bm0_clear_range(p2->bm1.bm0_w, address_lsb(c), SCALED_SIZE(b_next - c));
}
}
@@ -588,13 +576,15 @@
* Clear all references to loads in bitmap bm starting at address a1 and
* up to but not including address a2.
*/
-void DRD_(bm_clear_load)(struct bitmap* const bm, const Addr a1, const Addr a2)
+void DRD_(bm_clear_load)(struct bitmap* const bm, Addr a1, Addr a2)
{
Addr b, b_next;
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
for (b = a1; b < a2; b = b_next)
{
@@ -605,9 +595,9 @@
tl_assert(a1 <= b && b < a2);
#endif
- p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
+ p2 = bm2_lookup_exclusive(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -622,35 +612,35 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c < b_next && b_next <= a2);
#endif
- if (UWORD_LSB(c))
+ if (uword_lsb(address_lsb(c)))
{
- Addr c_next = UWORD_MSB(c) + BITS_PER_UWORD;
+ Addr c_next = first_address_with_higher_uword_msb(c);
if (c_next > b_next)
c_next = b_next;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c < c_next && c_next <= b_next
&& b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, c_next - c);
+ bm0_clear_range(p2->bm1.bm0_r, address_lsb(c), SCALED_SIZE(c_next - c));
c = c_next;
}
/* If some UWords have to be cleared entirely, do this now. */
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- if (UWORD_LSB(c) == 0)
+ if (uword_lsb(address_lsb(c)) == 0)
{
- const Addr c_next = UWORD_MSB(b_next);
+ Addr c_next = first_address_with_same_uword_lsb(b_next);
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(UWORD_LSB(c) == 0);
- tl_assert(UWORD_LSB(c_next) == 0);
+ tl_assert(uword_lsb(address_lsb(c)) == 0);
+ tl_assert(uword_lsb(address_lsb(c_next)) == 0);
tl_assert(a1 <= b && b <= c && c <= c_next && c_next <= b_next
&& b_next <= a2);
#endif
if (c_next > c)
{
- UWord idx = (c & ADDR0_MASK) >> BITS_PER_BITS_PER_UWORD;
- VG_(memset)(&p2->bm1.bm0_r[idx], 0, (c_next - c) / 8);
+ UWord idx = uword_msb(address_lsb(c));
+ VG_(memset)(&p2->bm1.bm0_r[idx], 0, SCALED_SIZE((c_next - c) / 8));
c = c_next;
}
}
@@ -659,7 +649,7 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_r, c & ADDR0_MASK, b_next - c);
+ bm0_clear_range(p2->bm1.bm0_r, address_lsb(c), SCALED_SIZE(b_next - c));
}
}
@@ -675,6 +665,8 @@
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
for (b = a1; b < a2; b = b_next)
{
@@ -685,9 +677,9 @@
tl_assert(a1 <= b && b < a2);
#endif
- p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
+ p2 = bm2_lookup_exclusive(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -702,35 +694,35 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c < b_next && b_next <= a2);
#endif
- if (UWORD_LSB(c))
+ if (uword_lsb(address_lsb(c)))
{
- Addr c_next = UWORD_MSB(c) + BITS_PER_UWORD;
+ Addr c_next = first_address_with_higher_uword_msb(c);
if (c_next > b_next)
c_next = b_next;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c < c_next && c_next <= b_next
&& b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, c_next - c);
+ bm0_clear_range(p2->bm1.bm0_w, address_lsb(c), SCALED_SIZE(c_next - c));
c = c_next;
}
/* If some UWords have to be cleared entirely, do this now. */
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- if (UWORD_LSB(c) == 0)
+ if (uword_lsb(address_lsb(c)) == 0)
{
- const Addr c_next = UWORD_MSB(b_next);
+ Addr c_next = first_address_with_same_uword_lsb(b_next);
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(UWORD_LSB(c) == 0);
- tl_assert(UWORD_LSB(c_next) == 0);
+ tl_assert(uword_lsb(address_lsb(c)) == 0);
+ tl_assert(uword_lsb(address_lsb(c_next)) == 0);
tl_assert(a1 <= b && b <= c && c <= c_next && c_next <= b_next
&& b_next <= a2);
#endif
if (c_next > c)
{
- UWord idx = (c & ADDR0_MASK) >> BITS_PER_BITS_PER_UWORD;
- VG_(memset)(&p2->bm1.bm0_w[idx], 0, (c_next - c) / 8);
+ UWord idx = uword_msb(address_lsb(c));
+ VG_(memset)(&p2->bm1.bm0_w[idx], 0, SCALED_SIZE((c_next - c) / 8));
c = c_next;
}
}
@@ -739,7 +731,7 @@
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(a1 <= b && b <= c && c <= b_next && b_next <= a2);
#endif
- bm0_clear_range(p2->bm1.bm0_w, c & ADDR0_MASK, b_next - c);
+ bm0_clear_range(p2->bm1.bm0_w, address_lsb(c), SCALED_SIZE(b_next - c));
}
}
@@ -768,9 +760,9 @@
for (b = a1; b < a2; b = b_next)
{
- const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+ const struct bitmap2* bm2 = bm2_lookup(bm, address_msb(b));
- b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+ b_next = first_address_with_higher_msb(b);
if (b_next > a2)
{
b_next = a2;
@@ -783,24 +775,24 @@
UWord b0;
const struct bitmap1* const p1 = &bm2->bm1;
- if ((bm2->addr << ADDR0_BITS) < a1)
+ if (make_address(bm2->addr, 0) < a1)
b_start = a1;
else
- if ((bm2->addr << ADDR0_BITS) < a2)
- b_start = (bm2->addr << ADDR0_BITS);
+ if (make_address(bm2->addr, 0) < a2)
+ b_start = make_address(bm2->addr, 0);
else
break;
tl_assert(a1 <= b_start && b_start <= a2);
- if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
- b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+ if (make_address(bm2->addr + 1, 0) < a2)
+ b_end = make_address(bm2->addr + 1, 0);
else
b_end = a2;
tl_assert(a1 <= b_end && b_end <= a2);
tl_assert(b_start < b_end);
- tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+ tl_assert(address_lsb(b_start) <= address_lsb(b_end - 1));
- for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+ for (b0 = address_lsb(b_start); b0 <= address_lsb(b_end - 1); b0++)
{
if (access_type == eLoad)
{
@@ -901,9 +893,7 @@
Bool DRD_(bm_equal)(struct bitmap* const lhs, struct bitmap* const rhs)
{
struct bitmap2* bm2l;
- struct bitmap2ref* bm2l_ref;
struct bitmap2* bm2r;
- const struct bitmap2ref* bm2r_ref;
/* It's not possible to have two independent iterators over the same OSet, */
/* so complain if lhs == rhs. */
@@ -912,39 +902,33 @@
VG_(OSetGen_ResetIter)(lhs->oset);
VG_(OSetGen_ResetIter)(rhs->oset);
- for ( ; (bm2l_ref = VG_(OSetGen_Next)(lhs->oset)) != 0; )
+ for ( ; (bm2l = VG_(OSetGen_Next)(lhs->oset)) != 0; )
{
- while (bm2l_ref
- && (bm2l = bm2l_ref->bm2)
- && bm2l
+ while (bm2l
&& ! DRD_(bm_has_any_access)(lhs,
- bm2l->addr << ADDR0_BITS,
- (bm2l->addr + 1) << ADDR0_BITS))
+ make_address(bm2l->addr, 0),
+ make_address(bm2l->addr + 1, 0)))
{
- bm2l_ref = VG_(OSetGen_Next)(lhs->oset);
+ bm2l = VG_(OSetGen_Next)(lhs->oset);
}
- if (bm2l_ref == 0)
+ if (bm2l == 0)
break;
tl_assert(bm2l);
do
{
- bm2r_ref = VG_(OSetGen_Next)(rhs->oset);
- if (bm2r_ref == 0)
- {
+ bm2r = VG_(OSetGen_Next)(rhs->oset);
+ if (bm2r == 0)
return False;
- }
- bm2r = bm2r_ref->bm2;
- tl_assert(bm2r);
}
while (! DRD_(bm_has_any_access)(rhs,
- bm2r->addr << ADDR0_BITS,
- (bm2r->addr + 1) << ADDR0_BITS));
+ make_address(bm2r->addr, 0),
+ make_address(bm2r->addr + 1, 0)));
tl_assert(bm2r);
tl_assert(DRD_(bm_has_any_access)(rhs,
- bm2r->addr << ADDR0_BITS,
- (bm2r->addr + 1) << ADDR0_BITS));
+ make_address(bm2r->addr, 0),
+ make_address(bm2r->addr + 1, 0)));
if (bm2l != bm2r
&& (bm2l->addr != bm2r->addr
@@ -958,13 +942,13 @@
{
bm2r = VG_(OSetGen_Next)(rhs->oset);
} while (bm2r && ! DRD_(bm_has_any_access)(rhs,
- bm2r->addr << ADDR0_BITS,
- (bm2r->addr + 1) << ADDR0_BITS));
+ make_address(bm2r->addr, 0),
+ make_address(bm2r->addr + 1, 0)));
if (bm2r)
{
tl_assert(DRD_(bm_has_any_access)(rhs,
- bm2r->addr << ADDR0_BITS,
- (bm2r->addr + 1) << ADDR0_BITS));
+ make_address(bm2r->addr, 0),
+ make_address(bm2r->addr + 1, 0)));
return False;
}
return True;
@@ -982,29 +966,27 @@
struct bitmap* const rhs)
{
struct bitmap2* bm2l;
- struct bitmap2ref* bm2l_ref;
struct bitmap2* bm2r;
- const struct bitmap2ref* bm2r_ref;
+ /* It's not possible to have two independent iterators over the same OSet, */
+ /* so complain if lhs == rhs. */
+ tl_assert(lhs != rhs);
+
+ s_bitmap_merge_count++;
+
VG_(OSetGen_ResetIter)(rhs->oset);
- for ( ; (bm2r_ref = VG_(OSetGen_Next)(rhs->oset)) != 0; )
+ for ( ; (bm2r = VG_(OSetGen_Next)(rhs->oset)) != 0; )
{
- bm2r = bm2r_ref->bm2;
- bm2l_ref = VG_(OSetGen_Lookup)(lhs->oset, &bm2r->addr);
- if (bm2l_ref)
+ bm2l = VG_(OSetGen_Lookup)(lhs->oset, &bm2r->addr);
+ if (bm2l)
{
- bm2l = bm2l_ref->bm2;
- if (bm2l != bm2r)
- {
- if (bm2l->refcnt > 1)
- bm2l = bm2_make_exclusive(lhs, bm2l_ref);
- bm2_merge(bm2l, bm2r);
- }
+ tl_assert(bm2l != bm2r);
+ bm2_merge(bm2l, bm2r);
}
else
{
- bm2_insert_addref(lhs, bm2r);
+ bm2_insert_copy(lhs, bm2r);
}
}
}
@@ -1022,24 +1004,20 @@
for (;;)
{
- const struct bitmap2ref* bm2l_ref;
- const struct bitmap2ref* bm2r_ref;
const struct bitmap2* bm2l;
const struct bitmap2* bm2r;
const struct bitmap1* bm1l;
const struct bitmap1* bm1r;
unsigned k;
- bm2l_ref = VG_(OSetGen_Next)(lhs->oset);
- bm2l = bm2l_ref->bm2;
- bm2r_ref = VG_(OSetGen_Next)(rhs->oset);
- bm2r = bm2r_ref->bm2;
+ bm2l = VG_(OSetGen_Next)(lhs->oset);
+ bm2r = VG_(OSetGen_Next)(rhs->oset);
while (bm2l && bm2r && bm2l->addr != bm2r->addr)
{
if (bm2l->addr < bm2r->addr)
- bm2l = (bm2l_ref = VG_(OSetGen_Next)(lhs->oset))->bm2;
+ bm2l = VG_(OSetGen_Next)(lhs->oset);
else
- bm2r = (bm2r_ref = VG_(OSetGen_Next)(rhs->oset))->bm2;
+ bm2r = VG_(OSetGen_Next)(rhs->oset);
}
if (bm2l == 0 || bm2r == 0)
break;
@@ -1057,7 +1035,7 @@
| ((bm1l->bm0_w[k] & bm0_mask(b)) ? LHS_W : 0)
| ((bm1r->bm0_r[k] & bm0_mask(b)) ? RHS_R : 0)
| ((bm1r->bm0_w[k] & bm0_mask(b)) ? RHS_W : 0);
- Addr const a = MAKE_ADDRESS(bm2l->addr, k * BITS_PER_UWORD | b);
+ Addr const a = make_address(bm2l->addr, k * BITS_PER_UWORD | b);
if (HAS_RACE(access_mask) && ! DRD_(is_suppressed)(a, a + 1))
{
return 1;
@@ -1071,29 +1049,35 @@
void DRD_(bm_print)(struct bitmap* const bm)
{
struct bitmap2* bm2;
- struct bitmap2ref* bm2ref;
- VG_(OSetGen_ResetIter)(bm->oset);
-
- for ( ; (bm2ref = VG_(OSetGen_Next)(bm->oset)) != 0; )
+ for (VG_(OSetGen_ResetIter)(bm->oset);
+ (bm2 = VG_(OSetGen_Next)(bm->oset)) != 0;
+ )
{
- const struct bitmap1* bm1;
- unsigned b;
+ bm2_print(bm2);
+ }
+}
- bm2 = bm2ref->bm2;
- bm1 = &bm2->bm1;
- for (b = 0; b < ADDR0_COUNT; b++)
+static void bm2_print(const struct bitmap2* const bm2)
+{
+ const struct bitmap1* bm1;
+ Addr a;
+
+ tl_assert(bm2);
+
+ bm1 = &bm2->bm1;
+ for (a = make_address(bm2->addr, 0);
+ a <= make_address(bm2->addr + 1, 0) - 1;
+ a++)
+ {
+ const Bool r = bm0_is_set(bm1->bm0_r, address_lsb(a)) != 0;
+ const Bool w = bm0_is_set(bm1->bm0_w, address_lsb(a)) != 0;
+ if (r || w)
{
- const Addr a = (bm2->addr << ADDR0_BITS) | b;
- const Bool r = bm0_is_set(bm1->bm0_r, b) != 0;
- const Bool w = bm0_is_set(bm1->bm0_w, b) != 0;
- if (r || w)
- {
- VG_(printf)("0x%08lx %c %c\n",
- a,
- w ? 'W' : ' ',
- r ? 'R' : ' ');
- }
+ VG_(printf)("0x%08lx %c %c\n",
+ a,
+ w ? 'W' : ' ',
+ r ? 'R' : ' ');
}
}
}
@@ -1113,63 +1097,30 @@
return s_bitmap2_creation_count;
}
-/** Allocate and initialize a second level bitmap. */
-static struct bitmap2* bm2_new(const UWord a1)
+ULong DRD_(bm_get_bitmap2_merge_count)(void)
{
- struct bitmap2* bm2;
-
- bm2 = VG_(malloc)("drd.bitmap.bm2n.1", sizeof(*bm2));
- bm2->addr = a1;
- bm2->refcnt = 1;
-
- s_bitmap2_creation_count++;
-
- return bm2;
+ return s_bitmap2_merge_count;
}
-/** Make a copy of a shared second level bitmap such that the copy can be
- * modified.
- *
- * @param a1 client address shifted right by ADDR0_BITS.
- * @param bm bitmap pointer.
- */
-static struct bitmap2* bm2_make_exclusive(struct bitmap* const bm,
- struct bitmap2ref* const bm2ref)
+/** Clear the bitmap contents. */
+static void bm2_clear(struct bitmap2* const bm2)
{
- UWord a1;
- struct bitmap2* bm2;
- struct bitmap2* bm2_copy;
-
- tl_assert(bm);
- tl_assert(bm2ref);
- bm2 = bm2ref->bm2;
tl_assert(bm2);
- tl_assert(bm2->refcnt > 1);
- bm2->refcnt--;
- tl_assert(bm2->refcnt >= 1);
- a1 = bm2->addr;
- bm2_copy = bm2_new(a1);
- tl_assert(bm2_copy);
- tl_assert(bm2_copy->addr == a1);
- tl_assert(bm2_copy->refcnt == 1);
- VG_(memcpy)(&bm2_copy->bm1, &bm2->bm1, sizeof(bm2->bm1));
- bm2ref->bm2 = bm2_copy;
-
- bm_update_cache(bm, a1, bm2_copy);
-
- return bm2_copy;
+ VG_(memset)(&bm2->bm1, 0, sizeof(bm2->bm1));
}
-static void bm2_merge(struct bitmap2* const bm2l,
- const struct bitmap2* const bm2r)
+/** Compute *bm2l |= *bm2r. */
+static
+void bm2_merge(struct bitmap2* const bm2l, const struct bitmap2* const bm2r)
{
unsigned k;
tl_assert(bm2l);
tl_assert(bm2r);
tl_assert(bm2l->addr == bm2r->addr);
- tl_assert(bm2l->refcnt == 1);
+ s_bitmap2_merge_count++;
+
for (k = 0; k < BITMAP1_UWORD_COUNT; k++)
{
bm2l->bm1.bm0_r[k] |= bm2r->bm1.bm0_r[k];
Modified: trunk/drd/drd_bitmap.h
===================================================================
--- trunk/drd/drd_bitmap.h 2009-05-10 06:46:31 UTC (rev 9815)
+++ trunk/drd/drd_bitmap.h 2009-05-10 06:55:39 UTC (rev 9816)
@@ -27,36 +27,109 @@
#define __DRD_BITMAP_H
+#include "pub_drd_bitmap.h"
#include "pub_tool_basics.h"
#include "pub_tool_oset.h"
#include "pub_tool_libcbase.h"
-/*
- Bitmap representation. A bitmap is a data structure in which two bits are
- reserved per 32 bit address: one bit that indicates that the data at the
- specified address has been read, and one bit that indicates that the data has
- been written to.
-*/
+/* Bitmap representation. A bitmap is a data structure in which two bits are
+ * reserved per 32 bit address: one bit that indicates that the data at the
+ * specified address has been read, and one bit that indicates that the data
+ * has been written to.
+ */
+/* Client addresses are split into bitfields as follows:
+ * ------------------------------------------------------
+ * | Address MSB | Address LSB | Ignored bits |
+ * ------------------------------------------------------
+ * | Address MSB | UWord MSB | UWord LSB | Ignored bits |
+ * ------------------------------------------------------
+ */
-/* Macro definitions. */
-#define ADDR0_BITS 14
-#define ADDR0_COUNT ((UWord)1 << ADDR0_BITS)
+/* Address MSB / LSB split. */
-#define ADDR0_MASK (ADDR0_COUNT - 1)
-#define SPLIT_ADDRESS(a) \
- UWord a##0 = ((a) & ADDR0_MASK); \
- UWord a##1 = ((a) >> ADDR0_BITS);
+/** Number of least significant address bits that are ignored. */
+#define ADDR_IGNORED_BITS 0
+#define ADDR_IGNORED_MASK ((1U << ADDR_IGNORED_BITS) - 1U)
+#define ADDR_GRANULARITY (1U << ADDR_IGNORED_BITS)
-// Assumption: sizeof(Addr) == sizeof(UWord).
-#define MAKE_ADDRESS(a1, a0) \
- (Addr)(((UWord)(a1) << (ADDR0_BITS)) | ((UWord)(a0)))
+/** Round argument a up to a multiple of (1 << ADDR_GRANULARITY), and next
+ * shift it right ADDR_GRANULARITY bits. The expression below is optimized
+ * for the case where a is a constant.
+ */
+#define SCALED_SIZE(a) \
+ (((((a) - 1U) | ADDR_IGNORED_MASK) + 1U) >> ADDR_IGNORED_BITS)
-#define BITS_PER_UWORD (8UL*sizeof(UWord))
+/** Number of bits assigned to the least significant component of an address.
+ */
+#define ADDR_LSB_BITS 12
+
+/** Mask that has to be applied to an address of type Addr in order to
+ * compute the least significant part of an address split, after having
+ * shifted the address bits ADDR_GRANULARITY to the right.
+ */
+#define ADDR_LSB_MASK (((UWord)1 << ADDR_LSB_BITS) - 1U)
+
+/** Compute least significant bits of an address of type Addr. */
+static __inline__
+UWord address_lsb(const Addr a)
+{ return (a >> ADDR_IGNORED_BITS) & ADDR_LSB_MASK; }
+
+/**
+ * Compute the first address for which address_lsb() is equal to
+ * address_lsb(a).
+ */
+static __inline__
+Addr first_address_with_same_lsb(const Addr a)
+{
+ return ((a | ADDR_IGNORED_MASK) ^ ADDR_IGNORED_MASK);
+}
+
+/**
+ * Compute the first address for which address_lsb() is greater than
+ * address_lsb(a).
+ */
+static __inline__
+Addr first_address_with_higher_lsb(const Addr a)
+{
+ return ((a | ADDR_IGNORED_MASK) + 1U);
+}
+
+/** Compute most significant bits of an address of type Addr. */
+static __inline__
+UWord address_msb(const Addr a)
+{ return a >> (ADDR_LSB_BITS + ADDR_IGNORED_BITS); }
+
+static __inline__
+Addr first_address_with_higher_msb(const Addr a)
+{
+ return ((a | ((ADDR_LSB_MASK << ADDR_IGNORED_BITS) | ADDR_IGNORED_MASK))
+ + 1U);
+}
+
+/** Convert LSB and MSB back into an address.
+ *
+ * @note It is assumed that sizeof(Addr) == sizeof(UWord).
+ */
+static __inline__
+Addr make_address(const UWord a1, const UWord a0)
+{
+ return ((a1 << (ADDR_LSB_BITS + ADDR_IGNORED_BITS))
+ | (a0 << ADDR_IGNORED_BITS));
+}
+
+
+
+
+
+/* Number of bits that fit in a variable of type UWord. */
+#define BITS_PER_UWORD (8U * sizeof(UWord))
+
+/* Log2 of BITS_PER_UWORD. */
#if defined(VGA_x86) || defined(VGA_ppc32)
#define BITS_PER_BITS_PER_UWORD 5
#elif defined(VGA_amd64) || defined(VGA_ppc64)
@@ -65,18 +138,66 @@
#error Unknown platform.
#endif
-#define BITMAP1_UWORD_COUNT (ADDR0_COUNT >> BITS_PER_BITS_PER_UWORD)
+/** Number of UWord's needed to store one bit per address LSB.
+ */
+#define BITMAP1_UWORD_COUNT (1U << (ADDR_LSB_BITS - BITS_PER_BITS_PER_UWORD))
-/* Highest bits of an address that fit into the same UWord of bm0[]. */
-#define UWORD_MSB(a) ((a) & ~(BITS_PER_UWORD - 1))
+/** Mask that has to be applied to an (Addr >> ADDR_IGNORED_BITS) expression
+ * in order to compute the least significant part of an UWord.
+ */
+#define UWORD_LSB_MASK (((UWord)1 << BITS_PER_BITS_PER_UWORD) - 1)
-/* Lowest bits of an address that fit into the same UWord of bm0[]. */
-#define UWORD_LSB(a) ((a) & (BITS_PER_UWORD - 1))
+/** Compute index into bm0[] array.
+ *
+ * @param a Address shifted right ADDR_IGNORED_BITS bits.
+ */
+static __inline__
+UWord uword_msb(const UWord a)
+{
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(a < (1U << ADDR_LSB_BITS));
+#endif
+ return a >> BITS_PER_BITS_PER_UWORD;
+}
-/* Highest address that fits in the same UWord as a. */
-#define UWORD_HIGHEST_ADDRESS(a) ((a) | (BITS_PER_UWORD - 1))
+/** Return the least significant bits.
+ *
+ * @param a Address shifted right ADDR_IGNORED_BITS bits.
+ */
+static __inline__
+UWord uword_lsb(const UWord a)
+{
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(a < (1U << ADDR_LSB_BITS));
+#endif
+ return a & UWORD_LSB_MASK;
+}
+/** Compute the highest address lower than a for which
+ * uword_lsb(address_lsb(a)) == 0.
+ *
+ * @param a Address.
+ */
+static __inline__
+Addr first_address_with_same_uword_lsb(const Addr a)
+{
+ return (a & (~UWORD_LSB_MASK << ADDR_IGNORED_BITS));
+}
+/**
+ * First address that will go in the UWord past the one 'a' goes in.
+ *
+ * @param a Address.
+ */
+static __inline__
+Addr first_address_with_higher_uword_msb(const Addr a)
+{
+ return ((a | ((UWORD_LSB_MASK << ADDR_IGNORED_BITS) | ADDR_IGNORED_MASK))
+ + 1);
+}
+
+
+
/* Local variables. */
static ULong s_bitmap2_creation_count;
@@ -89,56 +210,69 @@
/*********************************************************************/
-/* Lowest level, corresponding to the lowest ADDR0_BITS of an address. */
+/* Lowest level, corresponding to the lowest ADDR_LSB_BITS of an address. */
struct bitmap1
{
UWord bm0_r[BITMAP1_UWORD_COUNT];
UWord bm0_w[BITMAP1_UWORD_COUNT];
};
-static __inline__ UWord bm0_mask(const Addr a)
+static __inline__ UWord bm0_mask(const UWord a)
{
- return ((UWord)1 << UWORD_LSB(a));
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(address_msb(make_address(0, a)) == 0);
+#endif
+ return ((UWord)1 << uword_lsb(a));
}
-static __inline__ void bm0_set(UWord* bm0, const Addr a)
+/** Set the bit corresponding to address a in bitmap bm0. */
+static __inline__ void bm0_set(UWord* bm0, const UWord a)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a < ADDR0_COUNT);
+ tl_assert(address_msb(make_address(0, a)) == 0);
#endif
- bm0[a >> BITS_PER_BITS_PER_UWORD] |= (UWord)1 << UWORD_LSB(a);
+ bm0[uword_msb(a)] |= (UWord)1 << uword_lsb(a);
}
-/** Set all of the addresses in range [ a1 .. a1 + size [ in bitmap bm0. */
+/**
+ * Set the bits corresponding to all of the addresses in range
+ * [ a << ADDR_IGNORED_BITS .. (a + size) << ADDR_IGNORED_BITS [
+ * in bitmap bm0.
+ */
static __inline__ void bm0_set_range(UWord* bm0,
- const Addr a1, const SizeT size)
+ const UWord a, const SizeT size)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a1 < ADDR0_COUNT);
tl_assert(size > 0);
- tl_assert(a1 + size <= ADDR0_COUNT);
- tl_assert(UWORD_MSB(a1) == UWORD_MSB(a1 + size - 1));
+ tl_assert(address_msb(make_address(0, a)) == 0);
+ tl_assert(address_msb(make_address(0, a + size - 1)) == 0);
+ tl_assert(uword_msb(a) == uword_msb(a + size - 1));
#endif
- bm0[a1 >> BITS_PER_BITS_PER_UWORD]
- |= (((UWord)1 << size) - 1) << UWORD_LSB(a1);
+ bm0[uword_msb(a)]
+ |= (((UWord)1 << size) - 1) << uword_lsb(a);
}
-static __inline__ void bm0_clear(UWord* bm0, const Addr a)
+/** Clear the bit corresponding to address a in bitmap bm0. */
+static __inline__ void bm0_clear(UWord* bm0, const UWord a)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a < ADDR0_COUNT);
+ tl_assert(address_msb(make_address(0, a)) == 0);
#endif
- bm0[a >> BITS_PER_BITS_PER_UWORD] &= ~((UWord)1 << UWORD_LSB(a));
+ bm0[uword_msb(a)] &= ~((UWord)1 << uword_lsb(a));
}
-/** Clear all of the addresses in range [ a1 .. a1 + size [ in bitmap bm0. */
+/**
+ * Clear all of the addresses in range
+ * [ a << ADDR_IGNORED_BITS .. (a + size) << ADDR_IGNORED_BITS [
+ * in bitmap bm0.
+ */
static __inline__ void bm0_clear_range(UWord* bm0,
- const Addr a1, const SizeT size)
+ const UWord a, const SizeT size)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a1 <= ADDR0_COUNT);
- tl_assert(a1 + size <= ADDR0_COUNT);
- tl_assert(size == 0 || UWORD_MSB(a1) == UWORD_MSB(a1 + size - 1));
+ tl_assert(address_msb(make_address(0, a)) == 0);
+ tl_assert(size == 0 || address_msb(make_address(0, a + size - 1)) == 0);
+ tl_assert(size == 0 || uword_msb(a) == uword_msb(a + size - 1));
#endif
/*
* Note: although the expression below yields a correct result even if
@@ -147,31 +281,35 @@
*/
if (size > 0)
{
- bm0[a1 >> BITS_PER_BITS_PER_UWORD]
- &= ~((((UWord)1 << size) - 1) << UWORD_LSB(a1));
+ bm0[uword_msb(a)]
+ &= ~((((UWord)1 << size) - 1) << uword_lsb(a));
}
}
-static __inline__ UWord bm0_is_set(const UWord* bm0, const Addr a)
+/** Test whether the bit corresponding to address a is set in bitmap bm0. */
+static __inline__ UWord bm0_is_set(const UWord* bm0, const UWord a)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a < ADDR0_COUNT);
+ tl_assert(address_msb(make_address(0, a)) == 0);
#endif
- return (bm0[a >> BITS_PER_BITS_PER_UWORD] & ((UWord)1 << UWORD_LSB(a)));
+ return (bm0[uword_msb(a)] & ((UWord)1 << uword_lsb(a)));
}
-/** Return true if any of the bits [ a1 .. a1+size [ are set in bm0. */
+/**
+ * Return true if a bit corresponding to any of the addresses in range
+ * [ a << ADDR_IGNORED_BITS .. (a + size) << ADDR_IGNORED_BITS [
+ * is set in bm0.
+ */
static __inline__ UWord bm0_is_any_set(const UWord* bm0,
- const Addr a1, const SizeT size)
+ const Addr a, const SizeT size)
{
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(a1 < ADDR0_COUNT);
tl_assert(size > 0);
- tl_assert(a1 + size <= ADDR0_COUNT);
- tl_assert(UWORD_MSB(a1) == UWORD_MSB(a1 + size - 1));
+ tl_assert(address_msb(make_address(0, a)) == 0);
+ tl_assert(address_msb(make_address(0, a + size - 1)) == 0);
+ tl_assert(uword_msb(a) == uword_msb(a + size - 1));
#endif
- return (bm0[a1 >> BITS_PER_BITS_PER_UWORD]
- & ((((UWord)1 << size) - 1) << UWORD_LSB(a1)));
+ return (bm0[uword_msb(a)] & ((((UWord)1 << size) - 1) << uword_lsb(a)));
}
@@ -184,18 +322,10 @@
/* Second level bitmap. */
struct bitmap2
{
- Addr addr; ///< address >> ADDR0_BITS
- int refcnt;
+ Addr addr; ///< address_msb(...)
struct bitmap1 bm1;
};
-/* One node of bitmap::oset. */
-struct bitmap2ref
-{
- Addr addr; ///< address >> ADDR0_BITS
- struct bitmap2* bm2;
-};
-
struct bm_cache_elem
{
Addr a1;
@@ -212,10 +342,12 @@
};
-static struct bitmap2* bm2_new(const UWord a1);
-static struct bitmap2* bm2_make_exclusive(struct bitmap* const bm,
- struct bitmap2ref* const bm2ref);
+static void bm2_clear(struct bitmap2* const bm2);
+static __inline__
+struct bitmap2* bm2_insert(struct bitmap* const bm, const UWord a1);
+
+
/** Rotate elements cache[0..n-1] such that the element at position n-1 is
* moved to position 0. This allows to speed up future cache lookups.
*/
@@ -365,26 +497,22 @@
* shared second level bitmap. The bitmap where the returned pointer points
* at may not be modified by the caller.
*
- * @param a1 client address shifted right by ADDR0_BITS.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
* @param bm bitmap pointer.
*/
static __inline__
const struct bitmap2* bm2_lookup(struct bitmap* const bm, const UWord a1)
{
- struct bitmap2* bm2;
- struct bitmap2ref* bm2ref;
+ struct bitmap2* bm2;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(bm);
#endif
+
if (! bm_cache_lookup(bm, a1, &bm2))
{
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- if (bm2ref)
- {
- bm2 = bm2ref->bm2;
- }
- bm_update_cache(*(struct bitmap**)&bm, a1, bm2);
+ bm2 = VG_(OSetGen_Lookup)(bm->oset, &a1);
+ bm_update_cache(bm, a1, bm2);
}
return bm2;
}
@@ -392,134 +520,95 @@
/** Look up the address a1 in bitmap bm and return a pointer to a second
* level bitmap that is not shared and hence may be modified.
*
- * @param a1 client address shifted right by ADDR0_BITS.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
* @param bm bitmap pointer.
*/
static __inline__
struct bitmap2*
bm2_lookup_exclusive(struct bitmap* const bm, const UWord a1)
{
- struct bitmap2ref* bm2ref;
struct bitmap2* bm2;
- bm2ref = 0;
- if (bm_cache_lookup(bm, a1, &bm2))
- {
- if (bm2 == 0)
- return 0;
- if (bm2->refcnt > 1)
- {
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- }
- }
- else
- {
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- if (bm2ref == 0)
- return 0;
- bm2 = bm2ref->bm2;
- }
-
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm2);
+ tl_assert(bm);
#endif
- if (bm2->refcnt > 1)
+ if (! bm_cache_lookup(bm, a1, &bm2))
{
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm2ref);
-#endif
- bm2 = bm2_make_exclusive(*(struct bitmap**)&bm, bm2ref);
+ bm2 = VG_(OSetGen_Lookup)(bm->oset, &a1);
}
return bm2;
}
-/** Look up the address a1 in bitmap bm. The returned second level bitmap has
- * reference count one and hence may be modified.
+/** Insert an uninitialized second level bitmap for the address a1.
*
- * @param a1 client address shifted right by ADDR0_BITS.
* @param bm bitmap pointer.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
*/
static __inline__
struct bitmap2* bm2_insert(struct bitmap* const bm, const UWord a1)
{
- struct bitmap2ref* bm2ref;
struct bitmap2* bm2;
- s_bitmap2_node_creation_count++;
- bm2ref = VG_(OSetGen_AllocNode)(bm->oset, sizeof(*bm2ref));
- bm2ref->addr = a1;
- bm2 = bm2_new(a1);
- bm2ref->bm2 = bm2;
- VG_(memset)(&bm2->bm1, 0, sizeof(bm2->bm1));
- VG_(OSetGen_Insert)(bm->oset, bm2ref);
-
- bm_update_cache(*(struct bitmap**)&bm, a1, bm2);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
+ s_bitmap2_creation_count++;
+
+ bm2 = VG_(OSetGen_AllocNode)(bm->oset, sizeof(*bm2));
+ bm2->addr = a1;
+ VG_(OSetGen_Insert)(bm->oset, bm2);
+
+ bm_update_cache(bm, a1, bm2);
+
return bm2;
}
-/** Insert a new node in bitmap bm that points to the second level bitmap
- * *bm2. This means that *bm2 becomes shared over two or more bitmaps.
- */
static __inline__
-struct bitmap2* bm2_insert_addref(struct bitmap* const bm,
- struct bitmap2* const bm2)
+struct bitmap2* bm2_insert_copy(struct bitmap* const bm,
+ struct bitmap2* const bm2)
{
- struct bitmap2ref* bm2ref;
+ struct bitmap2* bm2_copy;
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm);
- tl_assert(VG_(OSetGen_Lookup)(bm->oset, &bm2->addr) == 0);
-#endif
-
- s_bitmap2_node_creation_count++;
- bm2ref = VG_(OSetGen_AllocNode)(bm->oset, sizeof(*bm2ref));
- bm2ref->addr = bm2->addr;
- bm2ref->bm2 = bm2;
- bm2->refcnt++;
- VG_(OSetGen_Insert)(bm->oset, bm2ref);
-
- bm_update_cache(*(struct bitmap**)&bm, bm2->addr, bm2);
-
- return bm2;
+ bm2_copy = bm2_insert(bm, bm2->addr);
+ VG_(memcpy)(&bm2_copy->bm1, &bm2->bm1, sizeof(bm2->bm1));
+ return bm2_copy;
}
/** Look up the address a1 in bitmap bm, and insert it if not found.
* The returned second level bitmap may not be modified.
*
- * @param a1 client address shifted right by ADDR0_BITS.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
* @param bm bitmap pointer.
*/
static __inline__
struct bitmap2* bm2_lookup_or_insert(struct bitmap* const bm, const UWord a1)
{
- struct bitmap2ref* bm2ref;
struct bitmap2* bm2;
#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
tl_assert(bm);
#endif
+
if (bm_cache_lookup(bm, a1, &bm2))
{
if (bm2 == 0)
{
bm2 = bm2_insert(bm, a1);
+ bm2_clear(bm2);
}
}
else
{
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- if (bm2ref)
+ bm2 = VG_(OSetGen_Lookup)(bm->oset, &a1);
+ if (! bm2)
{
- bm2 = bm2ref->bm2;
- }
- else
- {
bm2 = bm2_insert(bm, a1);
+ bm2_clear(bm2);
}
- bm_update_cache(*(struct bitmap**)&bm, a1, bm2);
+ bm_update_cache(bm, a1, bm2);
}
return bm2;
}
@@ -527,29 +616,14 @@
/** Look up the address a1 in bitmap bm, and insert it if not found.
* The returned second level bitmap may be modified.
*
- * @param a1 client address shifted right by ADDR0_BITS.
+ * @param a1 client address shifted right by ADDR_LSB_BITS.
* @param bm bitmap pointer.
*/
static __inline__
struct bitmap2* bm2_lookup_or_insert_exclusive(struct bitmap* const bm,
const UWord a1)
{
- struct bitmap2* bm2;
-
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm);
-#endif
- bm2 = (struct bitmap2*)bm2_lookup_or_insert(bm, a1);
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
- tl_assert(bm2);
-#endif
- if (bm2->refcnt > 1)
- {
- struct bitmap2ref* bm2ref;
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- bm2 = bm2_make_exclusive(bm, bm2ref);
- }
- return bm2;
+ return bm2_lookup_or_insert(bm, a1);
}
static __inline__
@@ -558,8 +632,14 @@
{
struct bitmap2* bm2;
- bm2 = bm2_lookup_or_insert_exclusive(bm, a1 >> ADDR0_BITS);
- bm0_set_range(bm2->bm1.bm0_r, a1 & ADDR0_MASK, size);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
+
+ bm2 = bm2_lookup_or_insert_exclusive(bm, address_msb(a1));
+ bm0_set_range(bm2->bm1.bm0_r,
+ (a1 >> ADDR_IGNORED_BITS) & ADDR_LSB_MASK,
+ SCALED_SIZE(size));
}
static __inline__
@@ -568,33 +648,48 @@
{
struct bitmap2* bm2;
- bm2 = bm2_lookup_or_insert_exclusive(bm, a1 >> ADDR0_BITS);
- bm0_set_range(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
+
+ bm2 = bm2_lookup_or_insert_exclusive(bm, address_msb(a1));
+ bm0_set_range(bm2->bm1.bm0_w,
+ (a1 >> ADDR_IGNORED_BITS) & ADDR_LSB_MASK,
+ SCALED_SIZE(size));
}
static __inline__
Bool bm_aligned_load_has_conflict_with(struct bitmap* const bm,
- const Addr a1, const SizeT size)
+ const Addr a, const SizeT size)
{
const struct bitmap2* bm2;
- bm2 = bm2_lookup(bm, a1 >> ADDR0_BITS);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
- return (bm2 && bm0_is_any_set(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size));
+ bm2 = bm2_lookup(bm, address_msb(a));
+ return (bm2
+ && bm0_is_any_set(bm2->bm1.bm0_w,
+ address_lsb(a),
+ SCALED_SIZE(size)));
}
static __inline__
Bool bm_aligned_store_has_conflict_with(struct bitmap* const bm,
- const Addr a1, const SizeT size)
+ const Addr a, const SizeT size)
{
const struct bitmap2* bm2;
- bm2 = bm2_lookup(bm, a1 >> ADDR0_BITS);
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ tl_assert(bm);
+#endif
+ bm2 = bm2_lookup(bm, address_msb(a));
if (bm2)
{
- if (bm0_is_any_set(bm2->bm1.bm0_r, a1 & ADDR0_MASK, size)
- | bm0_is_any_set(bm2->bm1.bm0_w, a1 & ADDR0_MASK, size))
+ if (bm0_is_any_set(bm2->bm1.bm0_r, address_lsb(a), SCALED_SIZE(size))
+ | bm0_is_any_set(bm2->bm1.bm0_w, address_lsb(a), SCALED_SIZE(size)))
{
return True;
}
Modified: trunk/drd/pub_drd_bitmap.h
===================================================================
--- trunk/drd/pub_drd_bitmap.h 2009-05-10 06:46:31 UTC (rev 9815)
+++ trunk/drd/pub_drd_bitmap.h 2009-05-10 06:55:39 UTC (rev 9816)
@@ -34,6 +34,7 @@
#define __PUB_DRD_BITMAP_H
+#include "drd_basics.h" /* DRD_() */
#include "pub_tool_basics.h" /* Addr, SizeT */
@@ -123,6 +124,6 @@
ULong DRD_(bm_get_bitmap_creation_count)(void);
ULong DRD_(bm_get_bitmap2_node_creation_count)(void);
ULong DRD_(bm_get_bitmap2_creation_count)(void);
+ULong DRD_(bm_get_bitmap2_merge_count)(void);
-
#endif /* __PUB_DRD_BITMAP_H */
Modified: trunk/drd/tests/drd_bitmap_test.c
===================================================================
--- trunk/drd/tests/drd_bitmap_test.c 2009-05-10 06:46:31 UTC (rev 9815)
+++ trunk/drd/tests/drd_bitmap_test.c 2009-05-10 06:55:39 UTC (rev 9816)
@@ -8,6 +8,14 @@
#include "drd/pub_drd_bitmap.h"
+#ifndef MIN
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+#endif
+#ifndef MAX
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#endif
+
+
/* Replacements for core functionality. */
void* VG_(malloc)(HChar* cc, SizeT nbytes)
@@ -25,6 +33,7 @@
function ? (char*)function : "",
function ? ": " : "",
assertion);
+ fflush(stdout);
fflush(stderr);
abort();
}
@@ -57,12 +66,15 @@
{ 0xffffULL, 1, eStore },
{ 0x0001ffffULL, 1, eLoad },
{ 0x00ffffffULL, 1, eLoad },
- { 0xfffffffeULL - ADDR0_COUNT, 1, eStore },
+ { 0xffffffffULL - (((1 << ADDR_LSB_BITS) + 1) << ADDR_IGNORED_BITS),
+ 1, eStore },
#if defined(VGP_amd64_linux) || defined(VGP_ppc64_linux) || defined(VGP_ppc64_aix5)
- { 0xffffffffULL - ADDR0_COUNT, 1, eStore },
+ { 0xffffffffULL - (1 << ADDR_LSB_BITS << ADDR_IGNORED_BITS),
+ 1, eStore },
{ 0xffffffffULL, 1, eStore },
{ 0x100000000ULL, 1, eStore },
- { -2ULL - ADDR0_COUNT, 1, eStore },
+ { -2ULL - (1 << ADDR_LSB_BITS << ADDR_IGNORED_BITS),
+ 1, eStore },
#endif
};
@@ -76,13 +88,24 @@
equal = DRD_(bm_equal)(bm1, bm2);
if (s_verbose && ! equal)
{
+ unsigned i;
+
VG_(printf)("Bitmaps are different.\n");
- VG_(printf)("Bitmap 1:\n");
- DRD_(bm_print)(bm1);
- VG_(printf)("\n");
- VG_(printf)("Bitmap 2:\n");
- DRD_(bm_print)(bm2);
- VG_(printf)("\n");
+ for (i = 0; i < 0x10000; i++)
+ {
+ if (DRD_(bm_has_1)(bm1, i, eLoad) != DRD_(bm_has_1)(bm2, i, eLoad)
+ || DRD_(bm_has_1)(bm1, i, eStore) != DRD_(bm_has_1)(bm2, i, eStore))
+ {
+ printf("0x%x %c %c %c %c\n",
+ i,
+ DRD_(bm_has_1)(bm1, i, eLoad) ? 'R' : ' ',
+ DRD_(bm_has_1)(bm1, i, eStore) ? 'W' : ' ',
+ DRD_(bm_has_1)(bm2, i, eLoad) ? 'R' : ' ',
+ DRD_(bm_has_1)(bm2, i, eStore) ? 'W' : ' '
+ );
+ }
+ }
+ fflush(stdout);
}
return equal;
@@ -104,15 +127,11 @@
s_test1_args[i].access_type);
}
- if (s_verbose)
- {
- VG_(printf)("Bitmap contents:\n");
- DRD_(bm_print)(bm);
- }
-
for (i = 0; i < sizeof(s_test1_args)/sizeof(s_test1_args[0]); i++)
{
- for (j = 0; j < s_test1_args[i].size; j++)
+ for (j = 0;
+ first_address_with_higher_lsb(j) <= s_test1_args[i].size;
+ j = first_address_with_higher_lsb(j))
{
tl_assert(DRD_(bm_has_1)(bm,
s_test1_args[i].address + j,
@@ -120,14 +139,9 @@
}
}
- if (s_verbose)
- VG_(printf)("Merge result:\n");
bm2 = DRD_(bm_new)();
DRD_(bm_merge2)(bm2, bm);
DRD_(bm_merge2)(bm2, bm);
- if (s_verbose)
- DRD_(bm_print)(bm2);
- //assert(bm_equal(bm, bm2));
assert(bm_equal_print_diffs(bm2, bm));
if (s_verbose)
@@ -147,13 +161,13 @@
bm1 = DRD_(bm_new)();
bm2 = DRD_(bm_new)();
DRD_(bm_access_load_1)(bm1, 7);
- DRD_(bm_access_load_1)(bm2, ADDR0_COUNT + 7);
+ DRD_(bm_access_load_1)(bm2, make_address(1, 0) + 7);
assert(! DRD_(bm_equal)(bm1, bm2));
assert(! DRD_(bm_equal)(bm2, bm1));
DRD_(bm_access_load_1)(bm2, 7);
assert(! DRD_(bm_equal)(bm1, bm2));
assert(! DRD_(bm_equal)(bm2, bm1));
- DRD_(bm_access_store_1)(bm1, ADDR0_COUNT + 7);
+ DRD_(bm_access_store_1)(bm1, make_address(1, 0) + 7);
assert(! DRD_(bm_equal)(bm1, bm2));
assert(! DRD_(bm_equal)(bm2, bm1));
DRD_(bm_delete)(bm2);
@@ -167,48 +181,50 @@
struct bitmap* bm1;
struct bitmap* bm2;
- const Addr lb = ADDR0_COUNT - 2 * BITS_PER_UWORD;
- const Addr ub = ADDR0_COUNT + 2 * BITS_PER_UWORD;
+ const Addr lb = make_address(2, 0) - 2 * BITS_PER_UWORD;
+ const Addr ub = make_address(2, 0) + 2 * BITS_PER_UWORD;
assert(outer_loop_step >= 1);
+ assert((outer_loop_step % ADDR_GRANULARITY) == 0);
assert(inner_loop_step >= 1);
+ assert((inner_loop_step % ADDR_GRANULARITY) == 0);
bm1 = DRD_(bm_new)();
bm2 = DRD_(bm_new)();
for (i = lb; i < ub; i += outer_loop_step)
{
- for (j = i + 1; j < ub; j += inner_loop_step)
+ for (j = i + ADDR_GRANULARITY; j < ub; j += inner_loop_step)
{
DRD_(bm_access_range_load)(bm1, i, j);
DRD_(bm_clear_load)(bm1, i, j);
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_load_1)(bm1, i);
- DRD_(bm_clear_load)(bm1, i, i+1);
+ DRD_(bm_clear_load)(bm1, i, i + MAX(1, ADDR_GRANULARITY));
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_load_2)(bm1, i);
- DRD_(bm_clear_load)(bm1, i, i+2);
+ DRD_(bm_clear_load)(bm1, i, i + MAX(2, ADDR_GRANULARITY));
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_load_4)(bm1, i);
- DRD_(bm_clear_load)(bm1, i, i+4);
+ DRD_(bm_clear_load)(bm1, i, i + MAX(4, ADDR_GRANULARITY));
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_load_8)(bm1, i);
- DRD_(bm_clear_load)(bm1, i, i+8);
+ DRD_(bm_clear_load)(bm1, i, i + MAX(8, ADDR_GRANULARITY));
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_range_store)(bm1, i, j);
DRD_(bm_clear_store)(bm1, i, j);
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_store_1)(bm1, i);
- DRD_(bm_clear_store)(bm1, i, i + 1);
+ DRD_(bm_clear_store)(bm1, i, i + MAX(1, ADDR_GRANULARITY));
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_store_2)(bm1, i);
- DRD_(bm_clear_store)(bm1, i, i + 2);
+ DRD_(bm_clear_store)(bm1, i, i + MAX(2, ADDR_GRANULARITY));
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_store_4)(bm1, i);
- DRD_(bm_clear_store)(bm1, i, i + 4);
+ DRD_(bm_clear_store)(bm1, i, i + MAX(4, ADDR_GRANULARITY));
assert(bm_equal_print_diffs(bm1, bm2));
DRD_(bm_access_store_8)(bm1, i);
- DRD_(bm_clear_store)(bm1, i, i + 8);
+ DRD_(bm_clear_store)(bm1, i, i + MAX(8, ADDR_GRANULARITY));
assert(bm_equal_p...
[truncated message content] |
|
From: <sv...@va...> - 2009-05-10 06:46:34
|
Author: bart
Date: 2009-05-10 07:46:31 +0100 (Sun, 10 May 2009)
New Revision: 9815
Log:
More diff minimizing.
Modified:
branches/DRDDEV/drd/drd_bitmap.c
branches/DRDDEV/drd/drd_bitmap.h
branches/DRDDEV/drd/pub_drd_bitmap.h
Modified: branches/DRDDEV/drd/drd_bitmap.c
===================================================================
--- branches/DRDDEV/drd/drd_bitmap.c 2009-05-10 06:39:37 UTC (rev 9814)
+++ branches/DRDDEV/drd/drd_bitmap.c 2009-05-10 06:46:31 UTC (rev 9815)
@@ -37,15 +37,11 @@
#include "pub_tool_mallocfree.h" /* VG_(malloc), VG_(free) */
-/* Forward declarations. */
-
-struct bitmap2;
-
-
/* Local function declarations. */
static void bm2_merge(struct bitmap2* const bm2l,
const struct bitmap2* const bm2r);
+static void bm2_print(const struct bitmap2* const bm2);
/* Local variables. */
@@ -1058,11 +1054,11 @@
(bm2 = VG_(OSetGen_Next)(bm->oset)) != 0;
)
{
- DRD_(bm2_print)(bm2);
+ bm2_print(bm2);
}
}
-void DRD_(bm2_print)(const struct bitmap2* const bm2)
+static void bm2_print(const struct bitmap2* const bm2)
{
const struct bitmap1* bm1;
Addr a;
@@ -1107,7 +1103,7 @@
}
/** Clear the bitmap contents. */
-void DRD_(bm2_clear)(struct bitmap2* const bm2)
+static void bm2_clear(struct bitmap2* const bm2)
{
tl_assert(bm2);
VG_(memset)(&bm2->bm1, 0, sizeof(bm2->bm1));
Modified: branches/DRDDEV/drd/drd_bitmap.h
===================================================================
--- branches/DRDDEV/drd/drd_bitmap.h 2009-05-10 06:39:37 UTC (rev 9814)
+++ branches/DRDDEV/drd/drd_bitmap.h 2009-05-10 06:46:31 UTC (rev 9815)
@@ -342,6 +342,7 @@
};
+static void bm2_clear(struct bitmap2* const bm2);
static __inline__
struct bitmap2* bm2_insert(struct bitmap* const bm, const UWord a1);
@@ -596,7 +597,7 @@
if (bm2 == 0)
{
bm2 = bm2_insert(bm, a1);
- DRD_(bm2_clear)(bm2);
+ bm2_clear(bm2);
}
}
else
@@ -605,7 +606,7 @@
if (! bm2)
{
bm2 = bm2_insert(bm, a1);
- DRD_(bm2_clear)(bm2);
+ bm2_clear(bm2);
}
bm_update_cache(bm, a1, bm2);
}
Modified: branches/DRDDEV/drd/pub_drd_bitmap.h
===================================================================
--- branches/DRDDEV/drd/pub_drd_bitmap.h 2009-05-10 06:39:37 UTC (rev 9814)
+++ branches/DRDDEV/drd/pub_drd_bitmap.h 2009-05-10 06:46:31 UTC (rev 9815)
@@ -51,7 +51,6 @@
/* Forward declarations. */
struct bitmap;
-struct bitmap2;
/* Datatype definitions. */
@@ -127,11 +126,4 @@
ULong DRD_(bm_get_bitmap2_creation_count)(void);
ULong DRD_(bm_get_bitmap2_merge_count)(void);
-/* Second-level bitmaps. */
-void DRD_(bm2_clear)(struct bitmap2* const bm2);
-void DRD_(bm2_print)(const struct bitmap2* const bm2);
-ULong DRD_(bm_get_bitmap2_creation_count)(void);
-
-void DRD_(bm_test)(void);
-
#endif /* __PUB_DRD_BITMAP_H */
|
|
From: <sv...@va...> - 2009-05-10 06:39:39
|
Author: bart Date: 2009-05-10 07:39:37 +0100 (Sun, 10 May 2009) New Revision: 9814 Log: Cleanup. Modified: trunk/drd/pub_drd_bitmap.h Modified: trunk/drd/pub_drd_bitmap.h =================================================================== --- trunk/drd/pub_drd_bitmap.h 2009-05-10 06:37:05 UTC (rev 9813) +++ trunk/drd/pub_drd_bitmap.h 2009-05-10 06:39:37 UTC (rev 9814) @@ -124,7 +124,5 @@ ULong DRD_(bm_get_bitmap2_node_creation_count)(void); ULong DRD_(bm_get_bitmap2_creation_count)(void); -void DRD_(bm_test)(void); - #endif /* __PUB_DRD_BITMAP_H */ |
|
From: <sv...@va...> - 2009-05-10 06:37:09
|
Author: bart
Date: 2009-05-10 07:37:05 +0100 (Sun, 10 May 2009)
New Revision: 9813
Log:
Removed commented-out tracing statements.
Modified:
trunk/drd/drd_bitmap.c
Modified: trunk/drd/drd_bitmap.c
===================================================================
--- trunk/drd/drd_bitmap.c 2009-05-10 06:14:42 UTC (rev 9812)
+++ trunk/drd/drd_bitmap.c 2009-05-10 06:37:05 UTC (rev 9813)
@@ -520,12 +520,6 @@
tl_assert(a1);
tl_assert(a1 <= a2);
-#if 0
- if (a2 - a1 >= ADDR0_COUNT)
- VG_(message)(Vg_DebugMsg, "bm_clear(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx", bm, a1, a2, a2 - a1);
-#endif
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -602,12 +596,6 @@
tl_assert(a1);
tl_assert(a1 <= a2);
-#if 0
- if (a2 - a1 >= ADDR0_COUNT)
- VG_(message)(Vg_DebugMsg, "bm_clear_load(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx", bm, a1, a2, a2 - a1);
-#endif
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -688,12 +676,6 @@
tl_assert(a1);
tl_assert(a1 <= a2);
-#if 0
- if (a2 - a1 >= ADDR0_COUNT)
- VG_(message)(Vg_DebugMsg, "bm_clear_store(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx", bm, a1, a2, a2 - a1);
-#endif
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -944,18 +926,12 @@
if (bm2l_ref == 0)
break;
tl_assert(bm2l);
-#if 0
- VG_(message)(Vg_DebugMsg, "bm_equal: at 0x%lx", bm2l->addr << ADDR0_BITS);
-#endif
do
{
bm2r_ref = VG_(OSetGen_Next)(rhs->oset);
if (bm2r_ref == 0)
{
-#if 0
- VG_(message)(Vg_DebugMsg, "bm_equal: no match found");
-#endif
return False;
}
bm2r = bm2r_ref->bm2;
@@ -974,10 +950,6 @@
&& (bm2l->addr != bm2r->addr
|| VG_(memcmp)(&bm2l->bm1, &bm2r->bm1, sizeof(bm2l->bm1)) != 0))
{
-#if 0
- VG_(message)(Vg_DebugMsg, "bm_equal: rhs 0x%lx -- returning false",
- bm2r->addr << ADDR0_BITS);
-#endif
return False;
}
}
@@ -993,11 +965,6 @@
tl_assert(DRD_(bm_has_any_access)(rhs,
bm2r->addr << ADDR0_BITS,
(bm2r->addr + 1) << ADDR0_BITS));
-#if 0
- VG_(message)(Vg_DebugMsg,
- "bm_equal: remaining rhs 0x%lx -- returning false",
- bm2r->addr << ADDR0_BITS);
-#endif
return False;
}
return True;
|
|
From: <sv...@va...> - 2009-05-10 06:14:49
|
Author: bart
Date: 2009-05-10 07:14:42 +0100 (Sun, 10 May 2009)
New Revision: 9812
Log:
Inserted DRD_(...) where it was missing.
Modified:
branches/DRDDEV/drd/drd_bitmap.c
branches/DRDDEV/drd/drd_bitmap.h
branches/DRDDEV/drd/pub_drd_bitmap.h
Modified: branches/DRDDEV/drd/drd_bitmap.c
===================================================================
--- branches/DRDDEV/drd/drd_bitmap.c 2009-05-10 06:10:47 UTC (rev 9811)
+++ branches/DRDDEV/drd/drd_bitmap.c 2009-05-10 06:14:42 UTC (rev 9812)
@@ -1058,11 +1058,11 @@
(bm2 = VG_(OSetGen_Next)(bm->oset)) != 0;
)
{
- bm2_print(bm2);
+ DRD_(bm2_print)(bm2);
}
}
-void bm2_print(const struct bitmap2* const bm2)
+void DRD_(bm2_print)(const struct bitmap2* const bm2)
{
const struct bitmap1* bm1;
Addr a;
@@ -1107,13 +1107,14 @@
}
/** Clear the bitmap contents. */
-void bm2_clear(struct bitmap2* const bm2)
+void DRD_(bm2_clear)(struct bitmap2* const bm2)
{
tl_assert(bm2);
VG_(memset)(&bm2->bm1, 0, sizeof(bm2->bm1));
}
/** Compute *bm2l |= *bm2r. */
+static
void bm2_merge(struct bitmap2* const bm2l, const struct bitmap2* const bm2r)
{
unsigned k;
Modified: branches/DRDDEV/drd/drd_bitmap.h
===================================================================
--- branches/DRDDEV/drd/drd_bitmap.h 2009-05-10 06:10:47 UTC (rev 9811)
+++ branches/DRDDEV/drd/drd_bitmap.h 2009-05-10 06:14:42 UTC (rev 9812)
@@ -596,7 +596,7 @@
if (bm2 == 0)
{
bm2 = bm2_insert(bm, a1);
- bm2_clear(bm2);
+ DRD_(bm2_clear)(bm2);
}
}
else
@@ -605,7 +605,7 @@
if (! bm2)
{
bm2 = bm2_insert(bm, a1);
- bm2_clear(bm2);
+ DRD_(bm2_clear)(bm2);
}
bm_update_cache(bm, a1, bm2);
}
Modified: branches/DRDDEV/drd/pub_drd_bitmap.h
===================================================================
--- branches/DRDDEV/drd/pub_drd_bitmap.h 2009-05-10 06:10:47 UTC (rev 9811)
+++ branches/DRDDEV/drd/pub_drd_bitmap.h 2009-05-10 06:14:42 UTC (rev 9812)
@@ -128,9 +128,9 @@
ULong DRD_(bm_get_bitmap2_merge_count)(void);
/* Second-level bitmaps. */
-void bm2_clear(struct bitmap2* const bm2);
-void bm2_print(const struct bitmap2* const bm2);
-ULong bm_get_bitmap2_creation_count(void);
+void DRD_(bm2_clear)(struct bitmap2* const bm2);
+void DRD_(bm2_print)(const struct bitmap2* const bm2);
+ULong DRD_(bm_get_bitmap2_creation_count)(void);
void DRD_(bm_test)(void);
|
|
From: <sv...@va...> - 2009-05-10 06:10:50
|
Author: bart
Date: 2009-05-10 07:10:47 +0100 (Sun, 10 May 2009)
New Revision: 9811
Log:
Minimized diffs with trunk.
Modified:
branches/DRDDEV/drd/drd_bitmap.c
branches/DRDDEV/drd/pub_drd_bitmap.h
Modified: branches/DRDDEV/drd/drd_bitmap.c
===================================================================
--- branches/DRDDEV/drd/drd_bitmap.c 2009-05-10 06:02:09 UTC (rev 9810)
+++ branches/DRDDEV/drd/drd_bitmap.c 2009-05-10 06:10:47 UTC (rev 9811)
@@ -210,7 +210,8 @@
DRD_(bm_access_range)(bm, a1, a1 + 8, eLoad);
}
-void DRD_(bm_access_range_store)(struct bitmap* const bm, Addr a1, Addr a2)
+void DRD_(bm_access_range_store)(struct bitmap* const bm,
+ const Addr a1, const Addr a2)
{
Addr b, b_next;
@@ -660,7 +661,8 @@
* Clear all references to stores in bitmap bm starting at address a1 and
* up to but not including address a2.
*/
-void DRD_(bm_clear_store)(struct bitmap* const bm, Addr a1, Addr a2)
+void DRD_(bm_clear_store)(struct bitmap* const bm,
+ const Addr a1, const Addr a2)
{
Addr b, b_next;
@@ -993,33 +995,6 @@
}
}
-/** Compute *lhs ^= *rhs. */
-void bm_xor(struct bitmap* const lhs, struct bitmap* const rhs)
-{
- struct bitmap2* bm2l;
- struct bitmap2* bm2r;
-
- /* It's not possible to have two independent iterators over the same OSet, */
- /* so complain if lhs == rhs. */
- tl_assert(lhs != rhs);
-
- VG_(OSetGen_ResetIter)(rhs->oset);
-
- for ( ; (bm2r = VG_(OSetGen_Next)(rhs->oset)) != 0; )
- {
- bm2l = VG_(OSetGen_Lookup)(lhs->oset, &bm2r->addr);
- if (bm2l)
- {
- tl_assert(bm2l != bm2r);
- bm2_xor(bm2l, bm2r);
- }
- else
- {
- bm2_insert_copy(lhs, bm2r);
- }
- }
-}
-
/**
* Report whether there are any RW / WR / WW patterns in lhs and rhs.
* @param lhs First bitmap.
@@ -1158,22 +1133,3 @@
bm2l->bm1.bm0_w[k] |= bm2r->bm1.bm0_w[k];
}
}
-
-/** Compute *bm2l ^= *bm2r. */
-void bm2_xor(struct bitmap2* const bm2l, const struct bitmap2* const bm2r)
-{
- unsigned k;
-
- tl_assert(bm2l);
- tl_assert(bm2r);
- tl_assert(bm2l->addr == bm2r->addr);
-
- for (k = 0; k < BITMAP1_UWORD_COUNT; k++)
- {
- bm2l->bm1.bm0_r[k] ^= bm2r->bm1.bm0_r[k];
- }
- for (k = 0; k < BITMAP1_UWORD_COUNT; k++)
- {
- bm2l->bm1.bm0_w[k] ^= bm2r->bm1.bm0_w[k];
- }
-}
Modified: branches/DRDDEV/drd/pub_drd_bitmap.h
===================================================================
--- branches/DRDDEV/drd/pub_drd_bitmap.h 2009-05-10 06:02:09 UTC (rev 9810)
+++ branches/DRDDEV/drd/pub_drd_bitmap.h 2009-05-10 06:10:47 UTC (rev 9811)
@@ -116,7 +116,6 @@
void DRD_(bm_swap)(struct bitmap* const bm1, struct bitmap* const bm2);
void DRD_(bm_merge2)(struct bitmap* const lhs,
struct bitmap* const rhs);
-void bm_xor(struct bitmap* const lhs, struct bitmap* const rhs);
int DRD_(bm_has_races)(struct bitmap* const bm1,
struct bitmap* const bm2);
void DRD_(bm_report_races)(ThreadId const tid1, ThreadId const tid2,
@@ -130,7 +129,6 @@
/* Second-level bitmaps. */
void bm2_clear(struct bitmap2* const bm2);
-void bm2_xor(struct bitmap2* const bm2l, const struct bitmap2* const bm2r);
void bm2_print(const struct bitmap2* const bm2);
ULong bm_get_bitmap2_creation_count(void);
|
|
From: <sv...@va...> - 2009-05-10 06:02:14
|
Author: bart
Date: 2009-05-10 07:02:09 +0100 (Sun, 10 May 2009)
New Revision: 9810
Log:
Converted several assignment statements in assert statements.
Modified:
branches/DRDDEV/drd/drd_bitmap.c
Modified: branches/DRDDEV/drd/drd_bitmap.c
===================================================================
--- branches/DRDDEV/drd/drd_bitmap.c 2009-05-09 22:57:57 UTC (rev 9809)
+++ branches/DRDDEV/drd/drd_bitmap.c 2009-05-10 06:02:09 UTC (rev 9810)
@@ -121,10 +121,9 @@
tl_assert(bm);
tl_assert(a1 < a2);
tl_assert(a2 < first_address_with_higher_msb(a2));
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
- a1 = first_address_with_same_lsb(a1);
- a2 = first_address_with_same_lsb(a2);
-
for (b = a1; b < a2; b = b_next)
{
Addr b_start;
@@ -218,10 +217,9 @@
tl_assert(bm);
tl_assert(a1 < a2);
tl_assert(a2 < first_address_with_higher_msb(a2));
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
- a1 = first_address_with_same_lsb(a1);
- a2 = first_address_with_same_lsb(a2);
-
for (b = a1; b < a2; b = b_next)
{
Addr b_start;
@@ -511,16 +509,9 @@
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
-#if 0
- if (address_msb(a1) != address_msb(a2))
- VG_(message)(Vg_DebugMsg, "bm_clear(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx)", bm, a1, a2, a2 - a1);
-#endif
-
- a1 = first_address_with_same_lsb(a1);
- a2 = first_address_with_same_lsb(a2);
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -595,16 +586,9 @@
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
-#if 0
- if (address_msb(a1) != address_msb(a2))
- VG_(message)(Vg_DebugMsg, "bm_clear_load(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx)", bm, a1, a2, a2 - a1);
-#endif
-
- a1 = first_address_with_same_lsb(a1);
- a2 = first_address_with_same_lsb(a2);
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -683,16 +667,9 @@
tl_assert(bm);
tl_assert(a1);
tl_assert(a1 <= a2);
+ tl_assert(a1 == first_address_with_same_lsb(a1));
+ tl_assert(a2 == first_address_with_same_lsb(a2));
-#if 0
- if (address_msb(a1) != address_msb(a2))
- VG_(message)(Vg_DebugMsg, "bm_clear_store(bm = %p, a1 = 0x%lx, a2 = 0x%lx,"
- " delta = 0x%lx)", bm, a1, a2, a2 - a1);
-#endif
-
- a1 = first_address_with_same_lsb(a1);
- a2 = first_address_with_same_lsb(a2);
-
for (b = a1; b < a2; b = b_next)
{
struct bitmap2* p2;
@@ -939,10 +916,6 @@
if (bm2l == 0)
break;
tl_assert(bm2l);
-#if 0
- VG_(message)(Vg_DebugMsg, "bm_equal: at 0x%lx",
- make_address(bm2l->addr, 0));
-#endif
do
{
@@ -963,10 +936,6 @@
&& (bm2l->addr != bm2r->addr
|| VG_(memcmp)(&bm2l->bm1, &bm2r->bm1, sizeof(bm2l->bm1)) != 0))
{
-#if 0
- VG_(message)(Vg_DebugMsg, "bm_equal: rhs 0x%lx -- returning false",
- make_address(bm2r->addr, 0));
-#endif
return False;
}
}
@@ -982,11 +951,6 @@
tl_assert(DRD_(bm_has_any_access)(rhs,
make_address(bm2r->addr, 0),
make_address(bm2r->addr + 1, 0)));
-#if 0
- VG_(message)(Vg_DebugMsg,
- "bm_equal: remaining rhs 0x%lx -- returning false",
- make_address(bm2r->addr, 0));
-#endif
return False;
}
return True;
|
|
From: Tom H. <th...@cy...> - 2009-05-10 02:44:26
|
Nightly build on lloyd ( x86_64, Fedora 7 ) started at 2009-05-10 03:05:08 BST 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 == 480 tests, 0 stderr failures, 0 stdout failures, 0 post failures == |
|
From: Tom H. <th...@cy...> - 2009-05-10 02:27:48
|
Nightly build on mg ( x86_64, Fedora 9 ) started at 2009-05-10 03:10:05 BST 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, 0 stderr failures, 1 stdout failure, 0 post failures == none/tests/linux/mremap2 (stdout) |