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
(12) |
2
(11) |
3
(8) |
|
4
(9) |
5
(10) |
6
(18) |
7
(8) |
8
(12) |
9
(23) |
10
(14) |
|
11
(15) |
12
(31) |
13
(45) |
14
(28) |
15
(20) |
16
(16) |
17
(9) |
|
18
(18) |
19
(26) |
20
(49) |
21
(14) |
22
(18) |
23
(24) |
24
(28) |
|
25
(39) |
26
(17) |
27
(27) |
28
(27) |
29
(14) |
30
(44) |
|
|
From: <sv...@va...> - 2005-09-19 23:35:56
|
Author: sewardj
Date: 2005-09-20 00:35:54 +0100 (Tue, 20 Sep 2005)
New Revision: 4687
Log:
Completely empty out this module in preparation for deleting it.
Modified:
branches/ASPACEM/coregrind/m_libcmman.c
branches/ASPACEM/coregrind/pub_core_libcmman.h
Modified: branches/ASPACEM/coregrind/m_libcmman.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_libcmman.c 2005-09-19 23:25:26 UTC (rev =
4686)
+++ branches/ASPACEM/coregrind/m_libcmman.c 2005-09-19 23:35:54 UTC (rev =
4687)
@@ -28,123 +28,8 @@
The GNU General Public License is contained in the file COPYING.
*/
=20
-#include "pub_core_basics.h"
-#include "pub_core_debuginfo.h" // Needed for pub_core_aspacemgr :(
-#include "pub_core_aspacemgr.h"
-#include "pub_core_libcbase.h"
-#include "pub_core_libcassert.h"
-#include "pub_core_libcmman.h"
-#include "pub_core_libcprint.h"
=20
-/* Returns -1 on failure. */
-void* VG_(mmap)( void* start, SizeT length,
- UInt prot, UInt flags, UInt sf_flags, UInt fd, OffT off=
set)
-{
- SysRes res;
=20
- if (!(flags & VKI_MAP_FIXED)) {
- start =3D (void *)VG_(find_map_space)((Addr)start, length, !!(flag=
s & VKI_MAP_CLIENT));
- }
- if (start =3D=3D 0)
- return (void *)-1;
-
- res =3D VG_(mmap_native)(start, length, prot,=20
- (flags | VKI_MAP_FIXED) & ~(VKI_MAP_NOSYMS | V=
KI_MAP_CLIENT),
- fd, offset);
-
- // Check it ended up in the right place.
- if (!res.isError) {
- if (flags & VKI_MAP_CLIENT) {
- vg_assert(VG_(client_base) <=3D res.val=20
- && res.val+length <=3D VG_(client_end));
- } else {
- vg_assert(VG_(valgrind_base) <=3D res.val=20
- && res.val+length-1 <=3D VG_(valgrind_last));
- }
-
- sf_flags |=3D SF_MMAP;
- if ( flags & VKI_MAP_SHARED) sf_flags |=3D SF_SHARED;
- if (!(flags & VKI_MAP_ANONYMOUS)) sf_flags |=3D SF_FILE;
- if (!(flags & VKI_MAP_CLIENT)) sf_flags |=3D SF_VALGRIND;
- if ( flags & VKI_MAP_NOSYMS) sf_flags |=3D SF_NOSYMS;
-
- VG_(map_fd_segment)(res.val, length, prot, sf_flags, fd, offset, N=
ULL);
- }
-
- return res.isError ? (void*)-1 : (void*)res.val;
-}
-
-/* Returns -1 on failure. */
-Int VG_(munmap)( void* start, SizeT length )
-{
- SysRes res =3D VG_(munmap_native)(start, length);
- if (!res.isError) {
- VG_(unmap_range)((Addr)start, length);
- return 0;
- } else {
- return -1;
- }
-}
-
-Int VG_(mprotect)( void *start, SizeT length, UInt prot )
-{
- SysRes res =3D VG_(mprotect_native)(start, length, prot);
- if (!res.isError) {
- VG_(mprotect_range)((Addr)start, length, prot);
- return 0;
- } else {
- return -1;
- }
-}
-
-void* VG_(get_memory_from_mmap) ( SizeT nBytes, Char* who )
-{
- static SizeT tot_alloc =3D 0;
- void* p;
- p =3D VG_(mmap)(0, nBytes,
- VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC,
- VKI_MAP_PRIVATE|VKI_MAP_ANONYMOUS, SF_VALGRIND, -1, 0);
-
- if (p !=3D ((void*)(-1))) {
- vg_assert((void*)VG_(valgrind_base) <=3D p && p <=3D (void*)VG_(va=
lgrind_last));
- tot_alloc +=3D nBytes;
- if (0)
- VG_(printf)(
- "get_memory_from_mmap: %llu tot, %llu req =3D %p .. %p, call=
er %s\n",
- (ULong)tot_alloc, (ULong)nBytes, p, ((char*)p) + nBytes - 1,=
who );
- return p;
- }
-
- VG_(printf)("\n");
- VG_(printf)("VG_(get_memory_from_mmap): %s's request for %llu bytes f=
ailed.\n",
- who, (ULong)nBytes);
- VG_(printf)("VG_(get_memory_from_mmap): %llu bytes already allocated.=
\n",=20
- (ULong)tot_alloc);
- VG_(printf)("\n");
- VG_(printf)("Sorry. You could try using a tool that uses less memory=
;\n");
- VG_(printf)("eg. addrcheck instead of memcheck.\n");
- VG_(printf)("\n");
- VG_(exit)(1);
-}
-
-// Returns 0 on failure.
-Addr VG_(get_memory_from_mmap_for_client) (SizeT len)
-{
- Addr addr;
-
- len =3D VG_PGROUNDUP(len);
-
- addr =3D (Addr)VG_(mmap)(NULL, len,=20
- VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC,
- VKI_MAP_PRIVATE|VKI_MAP_ANONYMOUS|VKI_MAP_CLIE=
NT,
- SF_CORE, -1, 0);
- if ((Addr)-1 !=3D addr)
- return addr;
- else
- return 0;
-}
-
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: branches/ASPACEM/coregrind/pub_core_libcmman.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/pub_core_libcmman.h 2005-09-19 23:25:26 UT=
C (rev 4686)
+++ branches/ASPACEM/coregrind/pub_core_libcmman.h 2005-09-19 23:35:54 UT=
C (rev 4687)
@@ -38,13 +38,6 @@
=20
#include "pub_tool_libcmman.h"
=20
-extern void* VG_(mmap) ( void* start, SizeT length, UInt prot, UInt fl=
ags,
- UInt sf_flags, UInt fd, OffT offset );
-extern Int VG_(munmap) ( void* start, SizeT length );
-extern Int VG_(mprotect) ( void *start, SizeT length, UInt prot );
-
-extern Addr VG_(get_memory_from_mmap_for_client)(SizeT len);
-
#endif // __PUB_CORE_LIBCMMAN_H
=20
/*--------------------------------------------------------------------*/
|
|
From: <sv...@va...> - 2005-09-19 23:25:30
|
Author: sewardj
Date: 2005-09-20 00:25:26 +0100 (Tue, 20 Sep 2005)
New Revision: 4686
Log:
Delete the old address space manager and generally start tidying up.
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
branches/ASPACEM/coregrind/m_main.c
branches/ASPACEM/coregrind/m_stacktrace.c
branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c
branches/ASPACEM/coregrind/m_syswrap/syswrap-linux.c
branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c
branches/ASPACEM/coregrind/pub_core_mallocfree.h
branches/ASPACEM/helgrind/hg_main.c
branches/ASPACEM/include/pub_tool_aspacemgr.h
branches/ASPACEM/include/pub_tool_libcmman.h
branches/ASPACEM/include/pub_tool_mallocfree.h
branches/ASPACEM/massif/ms_main.c
branches/ASPACEM/memcheck/mc_main.c
Modified: branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-19 22:32:5=
1 UTC (rev 4685)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-19 23:25:2=
6 UTC (rev 4686)
@@ -49,11 +49,6 @@
static void aspacem_barf ( HChar* what );
=20
=20
-/* Define to debug the memory-leak-detector. */
-/* #define VG_DEBUG_LEAKCHECK */
-
-static const Bool mem_debug =3D False;
-
/*--------------------------------------------------------------*/
/*--- Basic globals about the address space. ---*/
/*--------------------------------------------------------------*/
@@ -78,50 +73,7 @@
// the VG_(*_end) vars name the byte one past the end of the section.
Addr VG_(valgrind_last);
=20
-/*--------------------------------------------------------------*/
-/*--- The raw mman syscalls ---*/
-/*--------------------------------------------------------------*/
=20
-SysRes VG_(mmap_native)(void *start, SizeT length, UInt prot, UInt flags=
,
- UInt fd, OffT offset)
-{
- SysRes res;
-aspacem_barf("mmap_native");
-#if defined(VGP_x86_linux)
- {=20
- UWord args[6];
- args[0] =3D (UWord)start;
- args[1] =3D length;
- args[2] =3D prot;
- args[3] =3D flags;
- args[4] =3D fd;
- args[5] =3D offset;
- res =3D VG_(do_syscall1)(__NR_mmap, (UWord)args );
- }
-#elif defined(VGP_amd64_linux)
- res =3D VG_(do_syscall6)(__NR_mmap, (UWord)start, length,=20
- prot, flags, fd, offset);
-#elif defined(VGP_ppc32_linux)
- res =3D VG_(do_syscall6)(__NR_mmap, (UWord)(start), (length),
- prot, flags, fd, offset);
-#else
-# error Unknown platform
-#endif
- return res;
-}
-
-SysRes VG_(munmap_native)(void *start, SizeT length)
-{
-aspacem_barf("munmap_native");
- return VG_(do_syscall2)(__NR_munmap, (UWord)start, length );
-}
-
-SysRes VG_(mprotect_native)( void *start, SizeT length, UInt prot )
-{
-aspacem_barf("mprotect_native");
- return VG_(do_syscall3)(__NR_mprotect, (UWord)start, length, prot );
-}
-
/*--------------------------------------------------------------*/
/*--- A simple, self-contained ordered array of segments. ---*/
/*--------------------------------------------------------------*/
@@ -138,15 +90,6 @@
=20
/* ------ STATE for the address-space manager ------ */
=20
-/* Array [0 .. segments_used-1] of all mappings. */
-/* Sorted by .addr field. */
-/* I: len may not be zero. */
-/* I: overlapping segments are not allowed. */
-/* Each segment can optionally hold an index into the filename table. */
-
-static Segment segments[VG_N_SEGMENTS];
-static Int segments_used =3D 0;
-
typedef
struct {
Bool inUse;
@@ -227,1124 +170,6 @@
}
=20
=20
-/* Returns -1 if 'a' denotes an address prior to seg, 1 if it denotes
- an address after it, and 0 if it denotes an address covered by
- seg.=20
-*/
-static inline Int compare_addr_with_seg ( Addr a, Segment* seg )
-{
- if (a < seg->addr)=20
- return -1;
- if (a >=3D seg->addr + seg->len)=20
- return 1;
- return 0;
-}
-
-
-/* Find the (index of the) segment that contains 'a', or -1 if
- none.=20
-*/
-static Int find_segment ( Addr a )
-{
- Int i;
- for (i =3D 0; i < segments_used; i++) {
- if (compare_addr_with_seg(a, &segments[i]) =3D=3D 0)
- return i;
- }
- return -1;
-}
-
-
-/* Assumes that 'a' is not in any segment. Finds the index of the
- lowest-addressed segment above 'a', or -1 if none. Passing 'a'
- which is in fact in a segment is a checked error.=20
-*/
-static Int find_segment_above_unmapped ( Addr a )
-{
- Int i, r;
- for (i =3D 0; i < segments_used; i++) {
- r =3D compare_addr_with_seg(a, &segments[i]);
- vg_assert(r !=3D 0); /* 'a' should not be in any segment. */
- if (r =3D=3D 1)
- continue;
- vg_assert(r =3D=3D -1);
- break;
- }
-
- if (i =3D=3D segments_used)
- return -1; /* not found */
- else
- return i;
-}
-
-
-/* Assumes that 'a' is in some segment. Finds the next segment along,
- or NULL if none. Passing 'a' which is in fact not in a segment is
- a checked error.
-*/
-static Int find_segment_above_mapped ( Addr a )
-{
- Int i, r;
- for (i =3D 0; i < segments_used; i++) {
- r =3D compare_addr_with_seg(a, &segments[i]);
- if (r =3D=3D 1)
- continue; /* not yet there */
- if (r =3D=3D 0)
- break; /* found it */
- vg_assert(0);
- /* we shouldn't get here -- r =3D=3D -1 and so it means we went pa=
st=20
- 'a' without seeing it -- it is therefore unmapped. */
- /*NOTREACHED*/
- }
-
- vg_assert(i < segments_used);
- if (i =3D=3D segments_used-1)
- return -1; /* not found */
- else
- return i+1;
-}
-
-
-/* Shift segments[i .. segments_used-1] up by one. */
-static void make_space_at ( Int i )
-{
- Int j;
- vg_assert(i >=3D 0 && i <=3D segments_used);
- vg_assert(segments_used >=3D 0);
- if (segments_used+1 =3D=3D VG_N_SEGMENTS) {
- VG_(printf)(
- "coregrind/m_aspacemgr/aspacemgr.c:\n"
- " VG_N_SEGMENTS is too small: "
- "increase it and rebuild Valgrind.\n"
- );
- VG_(printf)(
- "coregrind/m_aspacemgr/aspacemgr.c:\n"
- " giving up now.\n\n"
- );
- VG_(exit)(0);
- }
- vg_assert(segments_used+1 < VG_N_SEGMENTS);
- for (j =3D segments_used; j > i; j--)
- segments[j] =3D segments[j-1];
- segments_used++;
-}
-
-// Forward declaration
-static void dealloc_seg_memory(Segment *s);
-
-/* Shift segments [i+1 .. segments_used-1] down by one, and decrement
- segments_used.=20
-*/
-static void delete_segment_at ( Int i )
-{
- Int j;
- vg_assert(i >=3D 0 && i < segments_used);
- dealloc_seg_memory(&segments[i]);
- for (j =3D i+1; j < segments_used; j++) {
- segments[j-1] =3D segments[j];
- }
- segments_used--;
- vg_assert(segments_used >=3D 0 && segments_used < VG_N_SEGMENTS);
-}
-
-
-/* Fill the i'th record all with zeroes. */
-static void zeroise_segment ( Int i )
-{
- vg_assert(i >=3D 0 && i < segments_used);
- segments[i].prot =3D 0;
- segments[i].flags =3D 0;
- segments[i].addr =3D 0;
- segments[i].len =3D 0;
- segments[i].offset =3D 0;
- segments[i].filename =3D NULL;
- segments[i].fnIdx =3D -1;
- segments[i].dev =3D 0;
- segments[i].ino =3D 0;
- segments[i].seginfo =3D NULL;
-}
-
-
-/* Create a segment to contain 'a', and return its index. Or -1 if
- this failed because some other segment already contains 'a'. If
- successful, fill in the segment's .addr field with 'a' but leave
- all other fields alone.=20
-*/
-static Int create_segment ( Addr a )
-{
- Int i, r;
- for (i =3D 0; i < segments_used; i++) {
- r =3D compare_addr_with_seg( a, &segments[i] );
- if (r =3D=3D 1)
- continue; /* seg[i] precedes a */
- if (r =3D=3D 0)
- return -1; /* seg[i] contains a. Give up */
- vg_assert(r =3D=3D -1);
- break;
- }
- /* a precedes seg[i]. Shift segs at i and above up one, and use
- this slot. */
- make_space_at(i);
- zeroise_segment(i);
- segments[i].addr =3D a;
- return i;
-}
-
-
-/* Print out the segment array (debugging only!). Note, this calls
- VG_(printf), and I'm not 100% clear that that wouldn't require
- dynamic memory allocation and hence more segments to be allocated.
-*/
-static void show_segments ( HChar* who )
-{
- Int i;
- VG_(printf)("<<< SHOW_SEGMENTS: %s (%d segments, %d segnames)\n",=20
- who, segments_used, segnames_used);
- for (i =3D 0; i < segnames_used; i++) {
- if (!segnames[i].inUse)
- continue;
- VG_(printf)("(%2d) %s\n", i, segnames[i].fname);
- }
- for (i =3D 0; i < segments_used; i++) {
- VG_(printf)(
- "%3d: %08p-%08p %7llu pr=3D0x%x fl=3D0x%04x d=3D0x%03x i=3D%-7d=
o=3D%-7lld (%d)\n",
- i,
- segments[i].addr, segments[i].addr + segments[i].len,
- (ULong)segments[i].len, segments[i].prot,=20
- segments[i].flags, segments[i].dev, segments[i].ino,=20
- (Long)segments[i].offset,=20
- segments[i].fnIdx);
- }
- VG_(printf)(">>>\n");
-}
-
-
-/* Find the segment containing 'a' and split it into two pieces at
- 'a'. Does nothing if no segment contains 'a', or if the split
- would cause either of the pieces to have zero size.
-
- If 'a' is not found, or if no splitting happens, -1 is returned.
-
- If a value 'r' other than -1 is returned, this is the index of the
- higher-addressed segment resulting from the split, and the index of
- the lower-addressed segment is r-1.
-*/
-static Int split_segment ( Addr a )
-{
- Int r;
- HWord delta;
- vg_assert(VG_IS_PAGE_ALIGNED(a));
- r =3D find_segment(a);
- if (r =3D=3D -1)
- /* not found */
- return -1;
- if (segments[r].addr =3D=3D a)
- /* segment starts at 'a', so splitting it would create a
- zero-sized segment */
- return -1;
-
- /* copy original; make adjustments. */
- vg_assert(a > segments[r].addr);
- delta =3D a - segments[r].addr;
- make_space_at(r);
- =20
- segments[r] =3D segments[r+1];
- segments[r].len =3D delta;
- if (segments[r].seginfo)
- VG_(seginfo_incref)(segments[r].seginfo);
- =20
- segments[r+1].len -=3D delta;
- segments[r+1].addr +=3D delta;
- segments[r+1].offset +=3D delta;
- return r+1;
-}
-
-
-/* Return true if two segments are adjacent and mergable (s1 is
- assumed to have a lower ->addr than s2) */
-static inline Bool segments_are_mergeable(Segment *s1, Segment *s2)
-{
- if (s1->addr+s1->len !=3D s2->addr)
- return False;
-
- if (s1->flags !=3D s2->flags)
- return False;
-
- if (s1->prot !=3D s2->prot)
- return False;
-
- if (s1->seginfo !=3D s2->seginfo)
- return False;
-
- if (s1->flags & SF_FILE){
- if ((s1->offset + s1->len) !=3D s2->offset)
- return False;
- if (s1->dev !=3D s2->dev)
- return False;
- if (s1->ino !=3D s2->ino)
- return False;
- if (s1->fnIdx !=3D s2->fnIdx)
- return False;
- }
- =20
- return True;
-}
-
-
-/* Clean up and sanity check the segment array:
- - check segments are in ascending order
- - check segments do not overlap
- - check no segment has zero size
- - merge adjacent where possible
- - perform checks on the filename table, and reclaim dead entries
-*/
-static void preen_segments ( void )
-{
- Int i, j, rd, wr;
- Segment *s, *s1;
- aspacem_barf("preen_segments");
- vg_assert(segments_used >=3D 0 && segments_used < VG_N_SEGMENTS);
- vg_assert(segnames_used >=3D 0 && segnames_used < VG_N_SEGNAMES);
-
- if (0) show_segments("before preen");
-
- /* clear string table mark bits */
- for (i =3D 0; i < segnames_used; i++)
- segnames[i].mark =3D False;
-
- /* check for non-zero size, and set mark bits for any used strings */
- for (i =3D 0; i < segments_used; i++) {
- vg_assert(segments[i].len > 0);
- j =3D segments[i].fnIdx;
- vg_assert(j >=3D -1 && j < segnames_used);
- if (j >=3D 0) {
- vg_assert(segnames[j].inUse);
- segnames[j].mark =3D True;
- }
- }
-
- /* check ascendingness and non-overlap */
- for (i =3D 0; i < segments_used-1; i++) {
- s =3D &segments[i];
- s1 =3D &segments[i+1];
- vg_assert(s->addr < s1->addr);
- vg_assert(s->addr + s->len <=3D s1->addr);
- }
-
- /* merge */
- if (segments_used < 1)
- return;
-
- wr =3D 1;
- for (rd =3D 1; rd < segments_used; rd++) {
- s =3D &segments[wr-1];
- s1 =3D &segments[rd];
- if (segments_are_mergeable(s,s1)) {
- if (0)
- VG_(printf)("merge %p-%p with %p-%p\n",
- s->addr, s->addr+s->len,
- s1->addr, s1->addr+s1->len);
- s->len +=3D s1->len;
-
- vg_assert(s->seginfo =3D=3D s1->seginfo);
- dealloc_seg_memory(s1);
- =20
- continue;
- }
- if (wr < rd)
- segments[wr] =3D segments[rd];
- wr++;
- }
- vg_assert(wr >=3D 0 && wr <=3D segments_used);
- segments_used =3D wr;
-
- /* Free up any strings which are no longer referenced. */
- for (i =3D 0; i < segnames_used; i++) {
- if (segnames[i].mark =3D=3D False) {
- segnames[i].inUse =3D False;
- segnames[i].fname[0] =3D 0;
- }
- }
-
- if (0) show_segments("after preen");
-}
-
-
-/*--------------------------------------------------------------*/
-/*--- Maintain an ordered list of all the client's mappings ---*/
-/*--------------------------------------------------------------*/
-
-Bool VG_(seg_contains)(const Segment *s, Addr p, SizeT len)
-{
- Addr se =3D s->addr+s->len;
- Addr pe =3D p+len;
-aspacem_barf("seg_contains");
- vg_assert(pe >=3D p);
-
- return (p >=3D s->addr && pe <=3D se);
-}
-
-Bool VG_(seg_overlaps)(const Segment *s, Addr p, SizeT len)
-{
- Addr se =3D s->addr+s->len;
- Addr pe =3D p+len;
-aspacem_barf("seg_overlaps");
- vg_assert(pe >=3D p);
-
- return (p < se && pe > s->addr);
-}
-
-/* When freeing a Segment, also clean up every one else's ideas of
- what was going on in that range of memory */
-static void dealloc_seg_memory(Segment *s)
-{
- if (s->seginfo !=3D NULL) {
- VG_(seginfo_decref)(s->seginfo, s->addr);
- s->seginfo =3D NULL;
- }
-}
-
-/* Get rid of any translations arising from s. */
-/* Note, this is not really the job of the low level memory manager.
- When it comes time to rewrite this subsystem, clean this up. */
-static void dump_translations_from ( Segment* s )
-{
- if (s->flags & SF_CODE) {
- VG_(discard_translations)(s->addr, s->len);
- if (0)
- VG_(printf)("dumping translations in %p .. %p\n",
- s->addr, s->addr+s->len);
- }
-}
-
-
-/* This unmaps all the segments in the range [addr, addr+len); any
- partial mappings at the ends are truncated. */
-void VG_(unmap_range)(Addr addr, SizeT len)
-{
- const Bool debug =3D False || mem_debug;
- Segment* s;
- Addr end, s_end;
- Int i;
- Bool deleted;
-aspacem_barf("unmap_range");
-
- if (len =3D=3D 0)
- return;
-
- len =3D VG_PGROUNDUP(len);
-
- if (debug)
- VG_(printf)("unmap_range(%p, %llu)\n", addr, (ULong)len);
- if (0) show_segments("unmap_range(BEFORE)");
- end =3D addr+len;
-
- /* Everything must be page-aligned */
- vg_assert(VG_IS_PAGE_ALIGNED(addr));
- vg_assert(VG_IS_PAGE_ALIGNED(len));
-
- for (i =3D 0; i < segments_used; i++) {
-
- /* do not delete .. even though it looks stupid */
- vg_assert(i >=3D 0);
-
- deleted =3D False;
- s =3D &segments[i];
- s_end =3D s->addr + s->len;
-
- if (0 && debug)
- VG_(printf)("unmap: addr=3D%p-%p s=3D%p ->addr=3D%p-%p len=3D%d\n",
- addr, end, s, s->addr, s_end, s->len);
-
- if (!VG_(seg_overlaps)(s, addr, len)) {
- if (0 && debug)
- VG_(printf)(" (no overlap)\n");
- continue;
- }
-
- /* 4 cases: */
- if (addr > s->addr &&
- addr < s_end &&
- end >=3D s_end) {
- /* this segment's tail is truncated by [addr, addr+len)
- -> truncate tail
- */
- dump_translations_from(s);
- s->len =3D addr - s->addr;
-
- if (debug)
- VG_(printf)(" case 1: s->len=3D%lu\n", s->len);
- } else if (addr <=3D s->addr && end > s->addr && end < s_end) {
- /* this segment's head is truncated by [addr, addr+len)
- -> truncate head
- */
- Word delta =3D end - s->addr;
-
- if (debug)
- VG_(printf)(" case 2: s->addr=3D%p s->len=3D%lu delta=3D%d\n",=20
- s->addr, s->len, delta);
-
- dump_translations_from(s);
- s->addr +=3D delta;
- s->offset +=3D delta;
- s->len -=3D delta;
-
- vg_assert(s->len !=3D 0);
- } else if (addr <=3D s->addr && end >=3D s_end) {
- /* this segment is completely contained within [addr, addr+len)
- -> delete segment
- */
- dump_translations_from(s);
- delete_segment_at(i);
- deleted =3D True;
-
- if (debug)
- VG_(printf)(" case 3: seg %d deleted\n", i);
- } else if (addr > s->addr && end < s_end) {
- /* [addr, addr+len) is contained within a single segment
- -> split segment into 3, delete middle portion
- */
- Int i_middle;
- dump_translations_from(s);
- i_middle =3D split_segment(addr);
- vg_assert(i_middle !=3D -1);
- (void)split_segment(addr+len);
- vg_assert(segments[i_middle].addr =3D=3D addr);
- delete_segment_at(i_middle);
- deleted =3D True;
-
- if (debug)
- VG_(printf)(" case 4: subrange %p-%p deleted\n",
- addr, addr+len);
- }
-
- /* If we deleted this segment (or any above), those above will
- have been moved down to fill in the hole in the segment
- array. In order that we don't miss them, we have to
- re-consider this slot number; hence the i--. */
- if (deleted)
- i--;
- }
- preen_segments();
- if (0) show_segments("unmap_range(AFTER)");
-}
-
-
-/* Add a binding of [addr,addr+len) to
- (prot,flags,dev,ino,off,filename) in the segment array.
- Delete/truncate any previous mapping(s) covering that range.
-*/
-void=20
-VG_(map_file_segment)( Addr addr, SizeT len,=20
- UInt prot, UInt flags,=20
- UInt dev, UInt ino, ULong off,=20
- const Char *filename)
-{
- const Bool debug =3D False || mem_debug;
- Segment* s;
- Int idx;
- HChar* stage2_suffix1 =3D "lib/valgrind/stage2";
- HChar* stage2_suffix2 =3D "coregrind/stage2";
- Bool is_stage2 =3D False;
-aspacem_barf("map_file_segment");
- =20
- is_stage2 =3D is_stage2 || ( VG_(strstr)(filename, stage2_suffix1) !=3D=
NULL );
- is_stage2 =3D is_stage2 || ( VG_(strstr)(filename, stage2_suffix2) !=3D=
NULL );
-
- if (debug)
- VG_(printf)(
- "\n"
- "map_file_segment(addr=3D%p len=3D%lu prot=3D0x%x flags=3D0x%x\=
n"
- " dev=3D0x%4x ino=3D%d off=3D%ld\n"
- " filename=3D'%s')\n",
- addr, (ULong)len, prot, flags, dev, ino, off, filename);
-
- if (0) show_segments("before map_file_segment");
-
- /* Everything must be page-aligned */
- vg_assert(VG_IS_PAGE_ALIGNED(addr));
- len =3D VG_PGROUNDUP(len);
-
- /* Nuke/truncate any existing segment(s) covering [addr,addr+len) */
- VG_(unmap_range)(addr, len);
-
- /* and now install this one */
- idx =3D create_segment(addr);
- vg_assert(segments_used >=3D 0 && segments_used <=3D VG_N_SEGMENTS);
- vg_assert(idx !=3D -1);
- vg_assert(idx >=3D 0 && idx < segments_used);
-
- s =3D &segments[idx];
- vg_assert(s->addr =3D=3D addr);
- s->prot =3D prot;
- s->flags =3D flags;
- s->len =3D len;
- s->offset =3D off;
- s->fnIdx =3D filename=3D=3DNULL ? -1 : allocate_segname(filename);
- s->filename =3D s->fnIdx=3D=3D-1 ? NULL : &segnames[s->fnIdx].fname[0=
];
- s->dev =3D dev;
- s->ino =3D ino;
- s->seginfo =3D NULL;
-
- /* Clean up right now */
- preen_segments();
- if (0) show_segments("after map_file_segment");
-
- /* If this mapping is at the beginning of a file, isn't part of
- Valgrind, is at least readable and seems to contain an object
- file, then try reading symbols from it.
-
- Getting this heuristic right is critical. On x86-linux,
- objects are typically mapped twice:
-
- 1b8fb000-1b8ff000 r-xp 00000000 08:02 4471477 vgpreload_memcheck.s=
o
- 1b8ff000-1b900000 rw-p 00004000 08:02 4471477 vgpreload_memcheck.s=
o
-
- whereas ppc32-linux mysteriously does this:
-
- 118a6000-118ad000 r-xp 00000000 08:05 14209428 vgpreload_memcheck.=
so
- 118ad000-118b6000 ---p 00007000 08:05 14209428 vgpreload_memcheck.=
so
- 118b6000-118bd000 rwxp 00000000 08:05 14209428 vgpreload_memcheck.=
so
-
- The third mapping should not be considered to have executable code=
in.
- Therefore a test which works for both is: r and x and NOT w. Read=
ing
- symbols from the rwx segment -- which overlaps the r-x segment in =
the
- file -- causes the redirection mechanism to redirect to addresses =
in
- that third segment, which is wrong and causes crashes.
- */
- if (s->seginfo =3D=3D NULL
- && ( (addr+len < VG_(valgrind_base) || addr > VG_(valgrind_last))
- || is_stage2
- )
- && (flags & (SF_MMAP|SF_NOSYMS)) =3D=3D SF_MMAP
- ) {
- if (off =3D=3D 0
- && s->fnIdx !=3D -1
- /* r, x are set */
- && (prot & (VKI_PROT_READ|VKI_PROT_EXEC)) =3D=3D (VKI_PROT_READ=
|VKI_PROT_EXEC)
- /* w is clear */
- && (prot & VKI_PROT_WRITE) =3D=3D 0
- /* other checks .. */
- && len >=3D VKI_PAGE_SIZE
- && VG_(is_object_file)((void *)addr) ) {
- s->seginfo =3D VG_(read_seg_symbols)(s->addr, s->len, s->offset=
,
- s->filename);
- }
- else if (flags & SF_MMAP)=20
- {
- const SegInfo *si;
- =20
- /* Otherwise see if an existing SegInfo applies to this Segment=
*/
- for (si =3D VG_(next_seginfo)(NULL);
- si !=3D NULL;
- si =3D VG_(next_seginfo)(si))=20
- {
- if (VG_(seg_overlaps)(s, VG_(seginfo_start)(si),=20
- VG_(seginfo_size)(si)))
- {
- s->seginfo =3D (SegInfo *)si;
- VG_(seginfo_incref)((SegInfo *)si);
- }
- }
- }
- }
-
- /* clean up */
- preen_segments();
-}
-
-void VG_(map_fd_segment)(Addr addr, SizeT len, UInt prot, UInt flags,=20
- Int fd, ULong off, const Char *filename)
-{
- Char buf[VKI_PATH_MAX];
- struct vki_stat st;
-aspacem_barf("map_fd_segment");
-
- st.st_dev =3D 0;
- st.st_ino =3D 0;
-
- if (fd !=3D -1 && (flags & SF_FILE)) {
- vg_assert((off & (VKI_PAGE_SIZE-1)) =3D=3D 0);
-
- if (VG_(fstat)(fd, &st) < 0)
- flags &=3D ~SF_FILE;
- }
-
- if ((flags & SF_FILE) && filename =3D=3D NULL && fd !=3D -1)
- if (VG_(resolve_filename)(fd, buf, VKI_PATH_MAX))
- filename =3D buf;
-
- VG_(map_file_segment)(addr, len, prot, flags,=20
- st.st_dev, st.st_ino, off, filename);
-}
-
-void VG_(map_segment)(Addr addr, SizeT len, UInt prot, UInt flags)
-{
-aspacem_barf("map_segment");
- flags &=3D ~SF_FILE;
-
- VG_(map_file_segment)(addr, len, prot, flags, 0, 0, 0, 0);
-}
-
-/* set new protection flags on an address range */
-void VG_(mprotect_range)(Addr a, SizeT len, UInt prot)
-{
- Int r;
- const Bool debug =3D False || mem_debug;
-aspacem_barf("mprotect_range");
-
- if (debug)
- VG_(printf)("\nmprotect_range(%p, %lu, %x)\n", a, len, prot);
-
- if (0) show_segments( "mprotect_range(before)" );
-
- /* Everything must be page-aligned */
- vg_assert(VG_IS_PAGE_ALIGNED(a));
- len =3D VG_PGROUNDUP(len);
-
- split_segment(a);
- split_segment(a+len);
-
- r =3D find_segment(a);
- vg_assert(r !=3D -1);
- segments[r].prot =3D prot;
-
- preen_segments();
-
- if (0) show_segments( "mprotect_range(after)");
-}
-
-
-/* Try to find a map space for [addr,addr+len). If addr=3D=3D0, it mean=
s
- the caller is prepared to accept a space at any location; if not,
- we will try for addr, but fail if we can't get it. This mimics
- mmap fixed vs mmap not-fixed.
-*/
-Addr VG_(find_map_space)(Addr addr, SizeT len, Bool for_client)
-{
- const Bool debug =3D False || mem_debug;
-aspacem_barf("find_map_space");
-
- Addr ret;
- Addr addrOrig =3D addr;
- Addr limit =3D (for_client ? VG_(client_end)-1 : VG_(valgrind_last)=
);
- Addr base =3D (for_client ? VG_(client_mapbase) : VG_(valgrind_base)=
);
- Addr hole_start, hole_end, hstart_any, hstart_fixed, hstart_final;
- Int i, i_any, i_fixed, i_final;
- SizeT hole_len;
-
- Bool fixed;
-
- if (debug) {
- VG_(printf)("\n\n");
- VG_(printf)("find_map_space(%p, %llu, %d) ...\n",
- addr, (ULong)len, for_client);
- }
-
- if (0) show_segments("find_map_space: start");
-
- if (addr =3D=3D 0) {
- fixed =3D False;
- } else {
- fixed =3D True;
- /* leave space for redzone and still try to get the exact
- address asked for */
- addr -=3D VKI_PAGE_SIZE;
- }
-
- /* Everything must be page-aligned */
- vg_assert((addr & (VKI_PAGE_SIZE-1)) =3D=3D 0);
- len =3D VG_PGROUNDUP(len);
-
- len +=3D VKI_PAGE_SIZE * 2; /* leave redzone gaps before and after ma=
pping */
-
- /* Scan the segment list, looking for a hole which satisfies the
- requirements. At each point i we ask the question "can we use
- the hole in between segments[i-1] and segments[i] ?" */
- i_any =3D i_fixed =3D -1;
- hstart_any =3D hstart_fixed =3D 0;
-
- hole_start =3D hole_end =3D 0;
-
- /* Iterate over all possible holes, generating them into
- hole_start/hole_end. Filter out invalid ones. Then see if any
- are usable; if so set i_fixed/i_any and hstart_fixed/hstart_any. =20
- */
- for (i =3D 0; i <=3D/*yes,really*/ segments_used; i++) {
- if (i =3D=3D 0) {
- hole_start =3D 0;
- hole_end =3D segments[0].addr-1;
- }=20
- else {
- vg_assert(segments_used > 0);
- if (i =3D=3D segments_used) {
- hole_start =3D segments[i-1].addr + segments[i-1].len;
- hole_end =3D ~(Addr)0;
- } else {
- hole_start =3D segments[i-1].addr + segments[i-1].len;
- hole_end =3D segments[i].addr - 1;
- }
- }
-
- vg_assert(hole_start <=3D hole_end || hole_start =3D=3D hole_end+1=
);
-
- /* ignore zero-sized holes */
- if (hole_start =3D=3D hole_end+1)
- continue;
-
- vg_assert(VG_IS_PAGE_ALIGNED(hole_start));
- vg_assert(VG_IS_PAGE_ALIGNED(hole_end+1));
-
- /* ignore holes which fall outside the allowable area */
- if (!(hole_start >=3D base && hole_end <=3D limit))
- continue;
-
- vg_assert(hole_end > hole_start);
- hole_len =3D hole_end - hole_start + 1;
- vg_assert(VG_IS_PAGE_ALIGNED(hole_len));
-
- if (hole_len >=3D len && i_any =3D=3D -1) {
- /* It will at least fit in this hole. */
- i_any =3D i;
- hstart_any =3D hole_start;
- }
-
- if (fixed && hole_start <=3D addr=20
- && hole_start+hole_len >=3D addr+len) {
- /* We were asked for a fixed mapping, and this hole works.
- Bag it -- and stop searching as further searching is
- pointless. */
- i_fixed =3D i;
- hstart_fixed =3D addr;
- break;
- }
- }
-
- /* Summarise the final decision into i_final/hstart_final. */
- i_final =3D -1;
- hstart_final =3D 0;
-
- if (fixed) {
- i_final =3D i_fixed;
- hstart_final =3D hstart_fixed + VKI_PAGE_SIZE; /* skip leading re=
dzone */
- } else {
- i_final =3D i_any;
- hstart_final =3D hstart_any;
- }
-
-
- if (i_final !=3D -1)
- ret =3D hstart_final;
- else
- ret =3D 0; /* not found */
-
- if (debug)
- VG_(printf)("find_map_space(%p, %llu, %d) -> %p\n\n",
- addr, (ULong)len, for_client, ret);
-
- if (fixed) {
- vg_assert(ret =3D=3D 0 || ret =3D=3D addrOrig);
- }
-
- return ret;
-}
-
-
-/* Pad the entire process address space, from "start"
- to VG_(valgrind_last) by creating an anonymous and inaccessible
- mapping over any part of the address space which is not covered
- by an entry in the segment list.
-
- This is designed for use around system calls which allocate
- memory in the process address space without providing a way to
- control its location such as io_setup. By choosing a suitable
- address with VG_(find_map_space) and then adding a segment for
- it and padding the address space valgrind can ensure that the
- kernel has no choice but to put the memory where we want it. */
-void VG_(pad_address_space)(Addr start)
-{
- Addr addr =3D (start =3D=3D 0) ? VG_(client_base) : start;
- SysRes ret;
-aspacem_barf("pad_address_space");
-
- Int i =3D 0;
- Segment* s =3D i >=3D segments_used ? NULL : &segments[i];
- =20
- while (s && addr <=3D VG_(valgrind_last)) {
- if (addr < s->addr) {
- ret =3D VG_(mmap_native)((void*)addr, s->addr - addr, 0,
- VKI_MAP_FIXED | VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS=
,
- -1, 0);
- vg_assert(!ret.isError);
- }
- addr =3D s->addr + s->len;
- i++;
- s =3D i >=3D segments_used ? NULL : &segments[i];
- }
-
- if (addr <=3D VG_(valgrind_last)) {
- ret =3D VG_(mmap_native)((void*)addr, VG_(valgrind_last) - addr + =
1, 0,
- VKI_MAP_FIXED | VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS,
- -1, 0);
- vg_assert(!ret.isError);
- }
-}
-
-/* Remove the address space padding added by VG_(pad_address_space)
- by removing any mappings that it created. */
-void VG_(unpad_address_space)(Addr start)
-{
- Addr addr =3D (start =3D=3D 0) ? VG_(client_base) : start;
- SysRes ret;
-
- Int i =3D 0;
- Segment* s =3D i >=3D segments_used ? NULL : &segments[i];
-aspacem_barf("unpad_address_space");
-
- while (s && addr <=3D VG_(valgrind_last)) {
- if (addr < s->addr) {
- //ret =3D VG_(do_syscall2)(__NR_munmap, addr, s->addr - addr);
- ret =3D VG_(do_syscall2)(__NR_munmap, addr, s->addr - addr);
- }
- addr =3D s->addr + s->len;
- i++;
- s =3D i >=3D segments_used ? NULL : &segments[i];
- }
-
- if (addr <=3D VG_(valgrind_last)) {
- ret =3D VG_(do_syscall2)(__NR_munmap, addr,=20
- (VG_(valgrind_last) - addr) + 1);
- }
-}
-
-/* Find the segment holding 'a', or NULL if none. */
-Segment *VG_(find_segment)(Addr a)
-{
- Int r =3D find_segment(a);
-aspacem_barf("find_segment");
-
- if (0) show_segments("find_segment");
- if (r =3D=3D -1) return NULL;
- return &segments[r];
-}
-
-/* Assumes that 'a' is not in any segment. Finds the lowest-addressed
- segment above 'a', or NULL if none. Passing 'a' which is in fact in
- a segment is a checked error.
-*/
-Segment *VG_(find_segment_above_unmapped)(Addr a)
-{
- Int r =3D find_segment_above_unmapped(a);
-aspacem_barf("find_segment_above_unmapped");
- if (0) show_segments("find_segment_above_unmapped");
- if (r =3D=3D -1) return NULL;
- return &segments[r];
-}
-
-/* Assumes that 'a' is in some segment. Finds the next segment along,
- or NULL if none. Passing 'a' which is in fact not in a segment is
- a checked error.
-*/
-Segment *VG_(find_segment_above_mapped)(Addr a)
-{
- Int r =3D find_segment_above_mapped(a);
-aspacem_barf("find_segment_above_mapped");
- if (0) show_segments("find_segment_above_mapped");
- if (r =3D=3D -1) return NULL;
- return &segments[r];
-}
-
-
-/*=20
- Test if a piece of memory is addressable with at least the "prot"
- protection permissions by examining the underlying segments.
-
- Really this is a very stupid algorithm and we could do much
- better by iterating through the segment array instead of through
- the address space.
- */
-Bool VG_(is_addressable)(Addr p, SizeT size, UInt prot)
-{
- Segment *seg;
-aspacem_barf("is_addressable");
-
- if ((p + size) < p)
- return False; /* reject wraparounds */
- if (size =3D=3D 0)
- return True; /* isn't this a bit of a strange case? */
-
- p =3D VG_PGROUNDDN(p);
- size =3D VG_PGROUNDUP(size);
- vg_assert(VG_IS_PAGE_ALIGNED(p));
- vg_assert(VG_IS_PAGE_ALIGNED(size));
-
- for (; size > 0; size -=3D VKI_PAGE_SIZE) {
- seg =3D VG_(find_segment)(p);
- if (!seg)
- return False;
- if ((seg->prot & prot) !=3D prot)
- return False;
- p +=3D VKI_PAGE_SIZE;
- }
-
- return True;
-}
-
-
-/*--------------------------------------------------------------------*/
-/*--- Random function that doesn't really belong here ---*/
-/*--------------------------------------------------------------------*/
-
-/* We'll call any RW mmaped memory segment, within the client address
- range, which isn't SF_CORE, a root.=20
-*/
-void VG_(find_root_memory)(void (*add_rootrange)(Addr a, SizeT sz))
-{
- Int i;
- UInt flags;
- Segment *s;
-aspacem_barf("find_root_memory");
-
- for (i =3D 0; i < segments_used; i++) {
- s =3D &segments[i];
- flags =3D s->flags & (SF_SHARED|SF_MMAP|SF_VALGRIND|SF_CORE|SF_STA=
CK);
- if (flags !=3D SF_MMAP && flags !=3D SF_STACK && flags !=3D (SF_MM=
AP|SF_STACK))
- continue;
- if ((s->prot & (VKI_PROT_READ|VKI_PROT_WRITE))=20
- !=3D (VKI_PROT_READ|VKI_PROT_WRITE))
- continue;
- if (!VG_(is_client_addr)(s->addr) ||
- !VG_(is_client_addr)(s->addr+s->len-1))
- continue;
-
- (*add_rootrange)(s->addr, s->len);
- }
-}
-
-
-/*--------------------------------------------------------------------*/
-/*--- Querying memory layout ---*/
-/*--------------------------------------------------------------------*/
-
-Bool VG_(is_client_addr)(Addr a)
-{
-aspacem_barf("is_client_addr");
- return a >=3D VG_(client_base) && a < VG_(client_end);
-}
-
-Bool VG_(is_shadow_addr)(Addr a)
-{
-aspacem_barf("is_shadow_addr");
- return a >=3D VG_(shadow_base) && a < VG_(shadow_end);
-}
-
-
-/*--------------------------------------------------------------------*/
-/*--- Handling shadow memory ---*/
-/*--------------------------------------------------------------------*/
-
-void *VG_(shadow_alloc)(UInt size)
-{
- static Addr shadow_alloc =3D 0;
- Addr try_here;
- SysRes r;
-aspacem_barf("shadow_alloc");
-
- if (0) show_segments("shadow_alloc(before)");
-
- vg_assert(VG_(needs).shadow_memory);
-
- size =3D VG_PGROUNDUP(size);
-
- if (shadow_alloc =3D=3D 0)
- shadow_alloc =3D VG_(shadow_base);
-
- if (shadow_alloc >=3D VG_(shadow_end))
- goto failed;
-
- try_here =3D shadow_alloc;
- vg_assert(VG_IS_PAGE_ALIGNED(try_here));
- vg_assert(VG_IS_PAGE_ALIGNED(size));
- vg_assert(size > 0);
-
- if (0)
- VG_(printf)("shadow_alloc: size %d, trying at %p\n", size, (void*)=
try_here);
-
- /* this is big-bang allocated, so we don't expect to find a listed
- segment for it. */
- /* This is really an absolute disgrace. Sometimes the big-bang
- mapping is in the list (due to re-reads of /proc/self/maps,
- presumably) and sometimes it isn't. */
-#if 0
- r =3D find_segment(try_here);
- vg_assert(r =3D=3D -1);
- r =3D find_segment(try_here+size-1);
- vg_assert(r =3D=3D -1);
-#endif
-
- r =3D VG_(mprotect_native)( (void*)try_here,=20
- size, VKI_PROT_READ|VKI_PROT_WRITE );
-
- if (r.isError)
- goto failed;
-
- shadow_alloc +=3D size;
- return (void*)try_here;
-
- failed:
- VG_(printf)(
- "valgrind: Could not allocate address space (0x%x bytes)\n"
- "valgrind: for shadow memory chunk.\n",
- size
- );=20
- VG_(exit)(1);
-}
-
-/*------------------------------------------------------------*/
-/*--- pointercheck ---*/
-/*------------------------------------------------------------*/
-
-Bool VG_(setup_pointercheck)(Addr client_base, Addr client_end)
-{
-aspacem_barf("setup_pointercheck");
- vg_assert(0 !=3D client_end);
-#if defined(VGP_x86_linux)
- /* Client address space segment limit descriptor entry */
- #define POINTERCHECK_SEGIDX 1
-
- vki_modify_ldt_t ldt =3D {=20
- POINTERCHECK_SEGIDX, // entry_number
- client_base, // base_addr
- (client_end - client_base) / VKI_PAGE_SIZE, // limit
- 1, // seg_32bit
- 0, // contents: data, RW, non-expanding
- 0, // ! read_exec_only
- 1, // limit_in_pages
- 0, // ! seg not present
- 1, // useable
- };
- SysRes ret =3D VG_(do_syscall3)(__NR_modify_ldt, 1, (UWord)&ldt, size=
of(ldt));
- if (ret.isError) {
- VG_(message)(Vg_UserMsg,
- "Warning: ignoring --pointercheck=3Dyes, "
- "because modify_ldt failed (errno=3D%d)", ret.val);
- return False;
- } else {
- return True;
- }
-#elif defined(VGP_amd64_linux)
- if (0)=20
- VG_(message)(Vg_DebugMsg, "ignoring --pointercheck (unimplemented)=
");
- return True;
-#elif defined(VGP_ppc32_linux)
- if (0)=20
- VG_(message)(Vg_DebugMsg, "ignoring --pointercheck (unimplemented)=
");
- return True;
-#else
-# error Unknown architecture
-#endif
-}
-
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
@@ -1737,7 +562,7 @@
Int i;
VG_(debugLog)(logLevel, "aspacem",
"<<< SHOW_SEGMENTS: %s (%d segments, %d segnames)\n",=20
- who, segments_used, segnames_used);
+ who, nsegments_used, segnames_used);
for (i =3D 0; i < segnames_used; i++) {
if (!segnames[i].inUse)
continue;
Modified: branches/ASPACEM/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_main.c 2005-09-19 22:32:51 UTC (rev 4685=
)
+++ branches/ASPACEM/coregrind/m_main.c 2005-09-19 23:25:26 UTC (rev 4686=
)
@@ -192,97 +192,6 @@
=20
=20
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Address space determination =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-// defined at the end of this file
-extern char _start[];
-
-static void layout_remaining_space(Addr argc_addr, float ratio)
-{
- SysRes res;
- Addr client_size, shadow_size;
-
- // VG_(valgrind_base) should have been set by scan_auxv, but if not,
- // this is a workable approximation
- if (VG_(valgrind_base) =3D=3D 0) {
- VG_(valgrind_base) =3D VG_PGROUNDDN(&_start);
- }
-
- VG_(valgrind_last) =3D VG_ROUNDUP(argc_addr, 0x10000) - 1; // stack
-
- // This gives the client the largest possible address space while
- // taking into account the tool's shadow needs.
- client_size =3D VG_ROUNDDN((VG_(valgrind_base)-REDZONE_SIZE) =
/ (1.+ratio),
- CLIENT_SIZE_MULTIPLE);
- VG_(client_base) =3D 0;
- VG_(client_end) =3D VG_(client_base) + client_size;
- /* where !FIXED mmap goes */
- VG_(client_mapbase) =3D VG_(client_base) +
- VG_PGROUNDDN((Addr)(client_size * CLIENT_HEAP_PROPORTION));
-
- VG_(shadow_base) =3D VG_(client_end) + REDZONE_SIZE;
- VG_(shadow_end) =3D VG_(valgrind_base);
- shadow_size =3D VG_(shadow_end) - VG_(shadow_base);
-
-#define SEGSIZE(a,b) ((VG_(b) - VG_(a))/(1024*1024))
-
- if (0)
- VG_(printf)(
- "client_base %p (%dMB)\n"
- "client_mapbase %p (%dMB)\n"
- "client_end %p (%dMB)\n"
- "shadow_base %p (%dMB)\n"
- "shadow_end %p\n"
- "valgrind_base %p (%dMB)\n"
- "valgrind_last %p\n",
- VG_(client_base), SEGSIZE(client_base, client_mapba=
se),
- VG_(client_mapbase), SEGSIZE(client_mapbase, client_end),
- VG_(client_end), SEGSIZE(client_end, shadow_base)=
,
- VG_(shadow_base), SEGSIZE(shadow_base, shadow_end),
- VG_(shadow_end),
- VG_(valgrind_base), SEGSIZE(valgrind_base, valgrind_las=
t),
- VG_(valgrind_last)
- );
-
-#undef SEGSIZE
-
- // Ban redzone
- res =3D VG_(mmap_native)((void *)VG_(client_end), REDZONE_SIZE, VKI_P=
ROT_NONE,
- VKI_MAP_FIXED|VKI_MAP_ANONYMOUS|VKI_MAP_PRIVATE|VKI_MAP_N=
ORESERVE,
- -1, 0);
- vg_assert(!res.isError);
-
- // Make client hole
- res =3D VG_(munmap_native)((void*)VG_(client_base), client_size);
- vg_assert(!res.isError);
-
- // Map shadow memory.
- // Initially all inaccessible, incrementally initialized as it is use=
d
- if (shadow_size !=3D 0) {
- res =3D VG_(mmap_native)((char *)VG_(shadow_base), shadow_size,
- VKI_PROT_NONE,
- VKI_MAP_PRIVATE|VKI_MAP_ANONYMOUS|VKI_MAP_FIXED|VKI_MA=
P_NORESERVE,
- -1, 0);
- if (res.isError) {
- VG_(printf)(
- "valgrind: Could not allocate address space (%p bytes)\n"
- "valgrind: for shadow memory\n"
- "valgrind: Possible causes:\n"
- "valgrind: - For some systems (especially under RedHat 8), Val=
grind\n"
- "valgrind: needs at least 1.5GB swap space.\n"
- "valgrind: - Or, your virtual memory size may be limited (chec=
k\n"
- "valgrind: with 'ulimit -v').\n"
- "valgrind: - Or, your system may use a kernel that provides on=
ly a\n"=20
- "valgrind: too-small (eg. 2GB) user address space.\n"
- , (void*)shadow_size
- );=20
- VG_(exit)(1);
- }
- }
-}
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D Environment and stack setup =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
@@ -1777,116 +1686,7 @@
VG_(clexecfd) =3D VG_(safe_fd)( VG_(clexecfd) );
}
=20
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Initialise program data/text, etc. =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
-static void build_valgrind_map_callback ( Addr start, SizeT size, UInt p=
rot,
- UInt dev, UInt ino, ULong foffset,=20
- const UChar* filename )
-{
- /* Only record valgrind mappings for now, without loading any
- symbols. This is so we know where the free space is before we
- start allocating more memory (note: heap is OK, it's just mmap
- which is the problem here). */
- if (start >=3D VG_(client_end) && start < VG_(valgrind_last)) {
- VG_(debugLog)(2, "main",
- "valgrind-seg: %p-%p prot 0x%x file=3D%s\n",
- (void*)start, (void*)(start+size), prot, filename);
- VG_(map_file_segment)(start, size, prot,
- SF_MMAP|SF_NOSYMS|SF_VALGRIND,
- dev, ino, foffset, filename);
- /* update VG_(valgrind_last) if it looks wrong */
- if (start+size > VG_(valgrind_last))
- VG_(valgrind_last) =3D start+size-1;
- }
-}
-
-// Global var used to pass local data to callback
-Addr sp_at_startup___global_arg =3D 0;
-
-/*=20
- This second pass adds in client mappings, and loads symbol tables
- for all interesting mappings. The trouble is that things can
- change as we go, because we're calling the Tool to track memory as
- we find it.
-
- So for Valgrind mappings, we don't replace any mappings which
- aren't still identical (which will include the .so mappings, so we
- will load their symtabs)>
- */
-static void build_segment_map_callback ( Addr start, SizeT size, UInt pr=
ot,
- UInt dev, UInt ino, ULong foffset,
- const UChar* filename )
-{
- UInt flags;
- Bool is_stack_segment;
- Addr r_esp;
-
- is_stack_segment=20
- =3D (start =3D=3D VG_(clstk_base) && (start+size) =3D=3D VG_(clstk=
_end));
-
- VG_(debugLog)(2, "main",
- "any-seg: %p-%p prot 0x%x stack=3D%d file=3D%s\n",
- (void*)start, (void*)(start+size), prot, is_stack_segme=
nt,=20
- filename);
-
- if (is_stack_segment)
- flags =3D SF_STACK | SF_GROWDOWN;
- else
- flags =3D SF_MMAP;
-
- if (filename !=3D NULL)
- flags |=3D SF_FILE;
-
-#if 0
- // This needs to be fixed properly. jrs 20050307
- if (start >=3D VG_(client_end) && start < VG_(valgrind_last)) {
- Segment *s =3D VG_(find_segment_before)(start);
-
- /* We have to be a bit careful about inserting new mappings into
- the Valgrind part of the address space. We're actively
- changing things as we parse these mappings, particularly in
- shadow memory, and so we don't want to overwrite those
- changes. Therefore, we only insert/update a mapping if it is
- mapped from a file or it exactly matches an existing mapping.
-
- NOTE: we're only talking about the Segment list mapping
- metadata; this doesn't actually mmap anything more. */
- if (filename || (s && s->addr =3D=3D start && s->len =3D=3D size))=
{
- flags |=3D SF_VALGRIND;
- VG_(map_file_segment)(start, size, prot, flags, dev, ino, foffset, fil=
ename);
- } else {
- /* assert range is already mapped */
- vg_assert(VG_(is_addressable)(start, size, VKI_PROT_NONE));
- }
- } else
-#endif
- VG_(map_file_segment)(start, size, prot, flags, dev, ino, foffset,=
filename);
-
- if (VG_(is_client_addr)(start) && VG_(is_client_addr)(start+size-1)) =
{
- VG_TRACK( new_mem_startup, start, size,
- !!(prot & VKI_PROT_READ),=20
- !!(prot & VKI_PROT_WRITE),=20
- !!(prot & VKI_PROT_EXEC));
- }
-
- /* If this is the stack segment mark all below %esp as noaccess. */
- r_esp =3D sp_at_startup___global_arg;
- vg_assert(0 !=3D r_esp);
- if (is_stack_segment) {
- if (0) {
- VG_(message)(Vg_DebugMsg, "invalidating stack area: %p .. %p",
- start,r_esp);
- VG_(message)(Vg_DebugMsg, " validating stack area: %p .. %p",
- r_esp, start+size);
- }
- VG_TRACK( die_mem_stack, start, r_esp-start );
- // what's this for?
- //VG_TRACK( post_mem_write, r_esp, (start+size)-r_esp );
- }
-}
-
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D Initialise the first thread. =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
Modified: branches/ASPACEM/coregrind/m_stacktrace.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_stacktrace.c 2005-09-19 22:32:51 UTC (re=
v 4685)
+++ branches/ASPACEM/coregrind/m_stacktrace.c 2005-09-19 23:25:26 UTC (re=
v 4686)
@@ -184,7 +184,7 @@
useful. */
if (ip >=3D (Addr)&VG_(trampoline_stuff_start)=20
&& ip < (Addr)&VG_(trampoline_stuff_end)
- && VG_(is_addressable)(sp, sizeof(Addr), VKI_PROT_READ)) {
+ && VG_(am_is_valid_for_client)(sp, sizeof(Addr), VKI_PROT_READ)) =
{
ip =3D *(Addr *)sp;
sp +=3D sizeof(Addr);
}
Modified: branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c 2005-09-19 22:=
32:51 UTC (rev 4685)
+++ branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c 2005-09-19 23:=
25:26 UTC (rev 4686)
@@ -1627,7 +1627,8 @@
=20
if (!(arg2 & 010000)) /* =3D SHM_RDONLY */
prot &=3D ~VKI_PROT_WRITE;
- VG_(map_segment)(res, segmentSize, prot, SF_SHARED|SF_SHM);
+ VG_(am_notify_client_mmap)( res, segmentSize,=20
+ prot, VKI_MAP_ANONYMOUS, 0,0);
}
}
=20
@@ -1643,11 +1644,13 @@
void
ML_(generic_POST_sys_shmdt) ( ThreadId tid, UWord res, UWord arg0 )
{
- Segment *s =3D VG_(find_segment)(arg0);
+ NSegment *s =3D VG_(am_find_nsegment)(arg0);
=20
- if (s !=3D NULL && (s->flags & SF_SHM) && VG_(seg_contains)(s, arg0, =
1)) {
- VG_TRACK( die_mem_munmap, s->addr, s->len );
- VG_(unmap_range)(s->addr, s->len);
+ if (s !=3D NULL /* && (s->flags & SF_SHM) */
+ /* && Implied by defn of am_find_nsegment:
+ VG_(seg_contains)(s, arg0, 1) */) {
+ VG_TRACK( die_mem_munmap, s->start, s->end+1 - s->start );
+ VG_(am_notify_munmap)(s->start, s->end+1 - s->start);
}
}
/* ------ */
Modified: branches/ASPACEM/coregrind/m_syswrap/syswrap-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_syswrap/syswrap-linux.c 2005-09-19 22:32=
:51 UTC (rev 4685)
+++ branches/ASPACEM/coregrind/m_syswrap/syswrap-linux.c 2005-09-19 23:25=
:26 UTC (rev 4686)
@@ -678,41 +678,47 @@
// the padding is in place.
PRE(sys_io_setup)
{
- SizeT size;
- Addr addr;
+ // JRS 19 Sept 2005: this wrapper might be a lot easier with the
+ // new aspacemgr in place. No need to do address space padding/
+ // unpadding; just let the kernel do what the hell it likes and
+ // notify aspacem of the results afterwards. For now, however:
+ SET_STATUS_Failure( VKI_ENOSYS );
=20
- PRINT("sys_io_setup ( %u, %p )", ARG1,ARG2);
- PRE_REG_READ2(long, "io_setup",
- unsigned, nr_events, vki_aio_context_t *, ctxp);
- PRE_MEM_WRITE( "io_setup(ctxp)", ARG2, sizeof(vki_aio_context_t) );
- =20
- size =3D VG_PGROUNDUP(sizeof(struct vki_aio_ring) +
- ARG1*sizeof(struct vki_io_event));
- addr =3D VG_(find_map_space)(0, size, True);
- =20
- if (addr =3D=3D 0) {
- SET_STATUS_Failure( VKI_ENOMEM );
- return;
- }
-
- VG_(map_segment)(addr, size, VKI_PROT_READ|VKI_PROT_WRITE, 0);
- =20
- VG_(pad_address_space)(0);
- SET_STATUS_from_SysRes( VG_(do_syscall2)(SYSNO, ARG1, ARG2) );
- VG_(unpad_address_space)(0);
-
- if (SUCCESS && RES =3D=3D 0) {
- struct vki_aio_ring *r =3D *(struct vki_aio_ring **)ARG2;
- =20
- vg_assert(addr =3D=3D (Addr)r);
- vg_assert(ML_(valid_client_addr)(addr, size, tid, "io_setup"));
- =20
- VG_TRACK( new_mem_mmap, addr, size, True, True, False );
- POST_MEM_WRITE( ARG2, sizeof(vki_aio_context_t) );
- }
- else {
- VG_(unmap_range)(addr, size);
- }
+// SizeT size;
+// Addr addr;
+//
+// PRINT("sys_io_setup ( %u, %p )", ARG1,ARG2);
+// PRE_REG_READ2(long, "io_setup",
+// unsigned, nr_events, vki_aio_context_t *, ctxp);
+// PRE_MEM_WRITE( "io_setup(ctxp)", ARG2, sizeof(vki_aio_context_t) );
+// =20
+// size =3D VG_PGROUNDUP(sizeof(struct vki_aio_ring) +
+// ARG1*sizeof(struct vki_io_event));
+// addr =3D VG_(find_map_space)(0, size, True);
+// =20
+// if (addr =3D=3D 0) {
+// SET_STATUS_Failure( VKI_ENOMEM );
+// return;
+// }
+//
+// VG_(map_segment)(addr, size, VKI_PROT_READ|VKI_PROT_WRITE, 0);
+// =20
+// VG_(pad_address_space)(0);
+// SET_STATUS_from_SysRes( VG_(do_syscall2)(SYSNO, ARG1, ARG2) );
+// VG_(unpad_address_space)(0);
+//
+// if (SUCCESS && RES =3D=3D 0) {
+// struct vki_aio_ring *r =3D *(struct vki_aio_ring **)ARG2;
+// =20
+// vg_assert(addr =3D=3D (Addr)r);
+// vg_assert(ML_(valid_client_addr)(addr, size, tid, "io_setup"));
+// =20
+// VG_TRACK( new_mem_mmap, addr, size, True, True, False );
+// POST_MEM_WRITE( ARG2, sizeof(vki_aio_context_t) );
+// }
+// else {
+// VG_(unmap_range)(addr, size);
+// }
}
=20
// Nb: This wrapper is "Special" because we need 'size' to do the unmap
@@ -724,8 +730,9 @@
// XXX This segment can be implicitly unmapped when aio
// file-descriptors are closed...
PRE(sys_io_destroy)
-{ =20
- Segment *s =3D VG_(find_segment)(ARG1);
+{
+ SET_STATUS_Failure( VKI_ENOSYS );
+ NSegment *s =3D VG_(am_find_nsegment)(ARG1);
struct vki_aio_ring *r;
SizeT size;
=20
@@ -740,14 +747,18 @@
=20
SET_STATUS_from_SysRes( VG_(do_syscall1)(SYSNO, ARG1) );
=20
+ /* jrs 20050917: testing s here seems nonsensical. Even if s is
+ NULL, the syscall might have succeeded, and so if s is null then
+ neither the tool nor aspacem will be notified. */
if (SUCCESS && RES =3D=3D 0 && s !=3D NULL) {=20
VG_TRACK( die_mem_munmap, ARG1, size );
- VG_(unmap_range)(ARG1, size);
+ VG_(am_notify_munmap)(ARG1, size);
} =20
} =20
=20
PRE(sys_io_getevents)
{
+ SET_STATUS_Failure( VKI_ENOSYS );
*flags |=3D SfMayBlock;
PRINT("sys_io_getevents ( %llu, %lld, %lld, %p, %p )",
(ULong)ARG1,(Long)ARG2,(Long)ARG3,ARG4,ARG5);
Modified: branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c 2005-09-19 2=
2:32:51 UTC (rev 4685)
+++ branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c 2005-09-19 2=
3:25:26 UTC (rev 4686)
@@ -1028,21 +1028,24 @@
=20
if (ARG1 & VKI_CLONE_PARENT_SETTID) {
PRE_MEM_WRITE("clone(parent_tidptr)", ARG3, sizeof(Int));
- if (!VG_(is_addressable)(ARG3, sizeof(Int), VKI_PROT_WRITE)) {
+ if (!VG_(am_is_valid_for_client)(ARG3, sizeof(Int),=20
+ VKI_PROT_WRITE)) {
SET_STATUS_Failure( VKI_EFAULT );
return;
}
}
if (ARG1 & (VKI_CLONE_CHILD_SETTID | VKI_CLONE_CHILD_CLEARTID)) {
PRE_MEM_WRITE("clone(child_tidptr)", ARG5, sizeof(Int));
- if (!VG_(is_addressable)(ARG5, sizeof(Int), VKI_PROT_WRITE)) {
+ if (!VG_(am_is_valid_for_client)(ARG5, sizeof(Int),=20
+ VKI_PROT_WRITE)) {
SET_STATUS_Failure( VKI_EFAULT );
return;
}
}
if (ARG1 & VKI_CLONE_SETTLS) {
PRE_MEM_READ("clone(tls_user_desc)", ARG4, sizeof(vki_modify_ldt_t=
));
- if (!VG_(is_addressable)(ARG4, sizeof(vki_modify_ldt_t), VKI_PROT_=
READ)) {
+ if (!VG_(am_is_valid_for_client)(ARG4, sizeof(vki_modify_ldt_t),=20
+ VKI_PROT_READ)) {
SET_STATUS_Failure( VKI_EFAULT );
return;
}
Modified: branches/ASPACEM/coregrind/pub_core_mallocfree.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/pub_core_mallocfree.h 2005-09-19 22:32:51 =
UTC (rev 4685)
+++ branches/ASPACEM/coregrind/pub_core_mallocfree.h 2005-09-19 23:25:26 =
UTC (rev 4686)
@@ -83,10 +83,6 @@
=20
extern void VG_(print_all_arena_stats) ( void );
=20
-// TODO: move somewhere else
-// Call here to bomb the system when out of memory (mmap anon fails)
-extern void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB );
-
#endif // __PUB_CORE_MALLOCFREE_H
=20
/*--------------------------------------------------------------------*/
Modified: branches/ASPACEM/helgrind/hg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/helgrind/hg_main.c 2005-09-19 22:32:51 UTC (rev 4685=
)
+++ branches/ASPACEM/helgrind/hg_main.c 2005-09-19 23:25:26 UTC (rev 4686=
)
@@ -501,7 +501,10 @@
//PROF_EVENT(10); PPP
=20
// Mark all words as virgin.
- map =3D (ESecMap *)VG_(shadow_alloc)(sizeof(ESecMap));
+ map =3D (ESecMap *)VG_(am_shadow_alloc)(sizeof(ESecMap));
+ if (map =3D=3D NULL)
+ VG_(out_of_memory_NORETURN)( "helgrind:allocate new ESecMap",=20
+ sizeof(ESecMap) );
for (i =3D 0; i < ESEC_MAP_WORDS; i++)
map->swords[i] =3D virgin_sword;
=20
Modified: branches/ASPACEM/include/pub_tool_aspacemgr.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/include/pub_tool_aspacemgr.h 2005-09-19 22:32:51 UTC=
(rev 4685)
+++ branches/ASPACEM/include/pub_tool_aspacemgr.h 2005-09-19 23:25:26 UTC=
(rev 4686)
@@ -130,23 +130,10 @@
extern Bool VG_(am_is_valid_for_client) ( Addr start, SizeT len,=20
UInt prot );
=20
-extern Bool VG_(is_client_addr) (Addr a);
-
-extern Bool VG_(is_shadow_addr) (Addr a);
-
+// See pub_core_aspacemgr.h for description.
/* Really just a wrapper around VG_(am_mmap_anon_float_valgrind). */
extern void* VG_(am_shadow_alloc)(SizeT size);
=20
-extern Bool VG_(is_addressable)(Addr p, SizeT sz, UInt prot);
-
-/* Calls into the core used by leak-checking */
-
-/* Calls "add_rootrange" with each range of memory which looks like a
- plausible source of root pointers. This is very Memcheck-specific --
- it's used in leak detection.
-*/
-extern void VG_(find_root_memory)(void (*add_rootrange)(Addr addr, SizeT=
sz));
-
#endif // __PUB_TOOL_ASPACEMGR_H
=20
/*--------------------------------------------------------------------*/
Modified: branches/ASPACEM/include/pub_tool_libcmman.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/include/pub_tool_libcmman.h 2005-09-19 22:32:51 UTC =
(rev 4685)
+++ branches/ASPACEM/include/pub_tool_libcmman.h 2005-09-19 23:25:26 UTC =
(rev 4686)
@@ -31,9 +31,6 @@
#ifndef __PUB_TOOL_LIBCMMAN_H
#define __PUB_TOOL_LIBCMMAN_H
=20
-/* Get memory by anonymous mmap. */
-extern void* VG_(get_memory_from_mmap) ( SizeT nBytes, Char* who );
-
#endif // __PUB_TOOL_LIBCMMAN_H
=20
/*--------------------------------------------------------------------*/
Modified: b...
[truncated message content] |
|
From: Julian S. <js...@ac...> - 2005-09-19 23:18:44
|
> > * Architectural issue: tools that ask for malloc replacements > > (massif, memcheck) cannot currently set a non-default redzone > > size. In order to make memcheck work I have currently kludged > > it by setting the default RZ size to 16; however that makes massif > > totally not work. Nick to consider? > > I just fixed this by making the client arena get initialised later than > the others, so that the tool has a chance to set the redzone size > beforehand. Great, thanks. Also for the command line stuff. J |
|
From: <sv...@va...> - 2005-09-19 22:32:55
|
Author: njn Date: 2005-09-19 23:32:51 +0100 (Mon, 19 Sep 2005) New Revision: 4685 Log: Fix building from scratch. Modified: branches/ASPACEM/Makefile.tool.am branches/ASPACEM/coregrind/Makefile.am Modified: branches/ASPACEM/Makefile.tool.am =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/ASPACEM/Makefile.tool.am 2005-09-19 20:21:33 UTC (rev 4684) +++ branches/ASPACEM/Makefile.tool.am 2005-09-19 22:32:51 UTC (rev 4685) @@ -20,7 +20,12 @@ $(top_builddir)/coregrind/m_syswrap/libsyswrap.a \ @VEX_DIR@/libvex.a =20 +@VEX_DIR@/libvex.a: @VEX_DIR@/priv/main/vex_svnversion.h + $(MAKE) -C @VEX_DIR@ libvex.a =20 +@VEX_DIR@/priv/main/vex_svnversion.h: + $(MAKE) -C @VEX_DIR@ version + ## Nb: do not call this variables "TOOL_LINKADD" and "TOOL_LDFLAGS" -- t= hat ## makes automake think we are building something called "TOOLS". TOOL_LINKADD =3D $(COREGRIND_LIBS) -lgcc Modified: branches/ASPACEM/coregrind/Makefile.am =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/ASPACEM/coregrind/Makefile.am 2005-09-19 20:21:33 UTC (rev 4= 684) +++ branches/ASPACEM/coregrind/Makefile.am 2005-09-19 22:32:51 UTC (rev 4= 685) @@ -133,12 +133,6 @@ -Wl,--soname,vg_preload_core.so \ -Wl,-z,initfirst =20 -@VEX_DIR@/libvex.a: @VEX_DIR@/priv/main/vex_svnversion.h - $(MAKE) -C @VEX_DIR@ libvex.a - -@VEX_DIR@/priv/main/vex_svnversion.h: - $(MAKE) -C @VEX_DIR@ version - clean-local: $(MAKE) -C @VEX_DIR@ clean =20 |
|
From: Nicholas N. <nj...@cs...> - 2005-09-19 22:27:09
|
Hi, I'm planning to run another Valgrind survey later this week. The last one was in December 2003 and a lot has changed since then. I'm planning to mail all three lists to announce it (vg-announce, vg-users, vg-dev). Anyone have any comments or suggestionss about the survey form before I do? I get about one response per week, and I've noticed that since Donna web-form-ified it, and I reduced the number of questions, that the quality of the responses have dropped -- I've got quite a few where people have answered the really short questions at the start, but written nothing for the (slightly) longer questions later on. Hopefully that won't be the case for the official survey period. Nick |
|
From: <sv...@va...> - 2005-09-19 20:21:38
|
Author: njn
Date: 2005-09-19 21:21:33 +0100 (Mon, 19 Sep 2005)
New Revision: 4684
Log:
wibble
Modified:
branches/ASPACEM/coregrind/m_syscall.c
Modified: branches/ASPACEM/coregrind/m_syscall.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_syscall.c 2005-09-19 20:17:07 UTC (rev 4=
683)
+++ branches/ASPACEM/coregrind/m_syscall.c 2005-09-19 20:21:33 UTC (rev 4=
684)
@@ -239,7 +239,7 @@
case VKI_EEXIST: return "File exists";
case VKI_EINVAL: return "Invalid argument";
case VKI_EMFILE: return "Too many open files";
- case VKI_ENOSYS: return "ENOSYS";
+ case VKI_ENOSYS: return "Function not implemented";
case VKI_ERESTARTSYS: return "ERESTARTSYS";
default: return "VG_(strerror): unknown error";
}
|
|
From: Nicholas N. <nj...@cs...> - 2005-09-19 20:17:33
|
On Mon, 19 Sep 2005, Julian Seward wrote: > * none/tests/cmdline* mostly fail. I don't understand how the command > line parsing works. Anyhow, there is some bad interaction with the > new startup sequence. I've fixed this. Nick |
|
From: <sv...@va...> - 2005-09-19 20:17:10
|
Author: njn
Date: 2005-09-19 21:17:07 +0100 (Mon, 19 Sep 2005)
New Revision: 4683
Log:
Fixed the cmdline* tests:
- avoid the crash for -h
- use full error strings rather than just the ENAME
Modified:
branches/ASPACEM/coregrind/m_main.c
branches/ASPACEM/coregrind/m_syscall.c
Modified: branches/ASPACEM/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_main.c 2005-09-19 19:27:45 UTC (rev 4682=
)
+++ branches/ASPACEM/coregrind/m_main.c 2005-09-19 20:17:07 UTC (rev 4683=
)
@@ -2374,7 +2374,8 @@
if (dseg_max_size > m8) dseg_max_size =3D m8;
dseg_max_size =3D VG_PGROUNDUP(dseg_max_size);
=20
- setup_client_dataseg( dseg_max_size );
+ if (!need_help)
+ setup_client_dataseg( dseg_max_size );
}
=20
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Modified: branches/ASPACEM/coregrind/m_syscall.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_syscall.c 2005-09-19 19:27:45 UTC (rev 4=
682)
+++ branches/ASPACEM/coregrind/m_syscall.c 2005-09-19 20:17:07 UTC (rev 4=
683)
@@ -227,18 +227,18 @@
const HChar* VG_(strerror) ( UWord errnum )
{
switch (errnum) {
- case VKI_EPERM: return "EPERM";
- case VKI_ENOENT: return "ENOENT";
- case VKI_ESRCH: return "ESRCH";
- case VKI_EINTR: return "EINTR";
- case VKI_EBADF: return "EBADF";
- case VKI_EAGAIN: return "EAGAIN";
- case VKI_ENOMEM: return "ENOMEM";
- case VKI_EACCES: return "EACCES";
- case VKI_EFAULT: return "EFAULT";
- case VKI_EEXIST: return "EEXIST";
- case VKI_EINVAL: return "EINVAL";
- case VKI_EMFILE: return "EMFILE";
+ case VKI_EPERM: return "Operation not permitted";
+ case VKI_ENOENT: return "No such file or directory";
+ case VKI_ESRCH: return "No such process";
+ case VKI_EINTR: return "Interrupted system call";
+ case VKI_EBADF: return "Bad file number";
+ case VKI_EAGAIN: return "Try again";
+ case VKI_ENOMEM: return "Out of memory";
+ case VKI_EACCES: return "Permission denied";
+ case VKI_EFAULT: return "Bad address";
+ case VKI_EEXIST: return "File exists";
+ case VKI_EINVAL: return "Invalid argument";
+ case VKI_EMFILE: return "Too many open files";
case VKI_ENOSYS: return "ENOSYS";
case VKI_ERESTARTSYS: return "ERESTARTSYS";
default: return "VG_(strerror): unknown error";
|
|
From: Nicholas N. <nj...@cs...> - 2005-09-19 19:30:33
|
On Mon, 19 Sep 2005, Julian Seward wrote: > * Architectural issue: tools that ask for malloc replacements > (massif, memcheck) cannot currently set a non-default redzone > size. In order to make memcheck work I have currently kludged > it by setting the default RZ size to 16; however that makes massif > totally not work. Nick to consider? I just fixed this by making the client arena get initialised later than the others, so that the tool has a chance to set the redzone size beforehand. Nick |
|
From: <sv...@va...> - 2005-09-19 19:27:56
|
Author: njn
Date: 2005-09-19 20:27:45 +0100 (Mon, 19 Sep 2005)
New Revision: 4682
Log:
Initialise the client arena after the others, so the tool has a chance
to set the redzone size beforehand.
Modified:
branches/ASPACEM/coregrind/m_mallocfree.c
Modified: branches/ASPACEM/coregrind/m_mallocfree.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_mallocfree.c 2005-09-19 17:12:04 UTC (re=
v 4681)
+++ branches/ASPACEM/coregrind/m_mallocfree.c 2005-09-19 19:27:45 UTC (re=
v 4682)
@@ -419,34 +419,20 @@
/* This library is self-initialising, as it makes this more self-contain=
ed,
less coupled with the outside world. Hence VG_(arena_malloc)() and
VG_(arena_free)() below always call ensure_mm_init() to ensure things=
are
- correctly initialised. */
+ correctly initialised. =20
+
+ We initialise the client arena separately (and later) because the cor=
e
+ must do non-client allocation before the tool has a chance to set the
+ client arena's redzone size.
+*/
static
-void ensure_mm_init ( void )
+void ensure_mm_init ( ArenaId aid )
{
- static Bool init_done =3D False;
- static SizeT client_redzone_szB =3D 16; //8; // default: be paranoi=
d
+ static Bool client_inited =3D False;
+ static Bool nonclient_inited =3D False;
+ static SizeT client_redzone_szB =3D 8; // default: be paranoid
=20
- if (init_done) {
- // This assertion ensures that a tool cannot try to change the cli=
ent
- // redzone size with VG_(needs_malloc_replacement)() after this mo=
dule
- // has done its first allocation.
- if (VG_(needs).malloc_replacement)
- vg_assert(client_redzone_szB =3D=3D VG_(tdict).tool_client_redz=
one_szB);
- return;
- }
-
- if (VG_(needs).malloc_replacement) {
- client_redzone_szB =3D VG_(tdict).tool_client_redzone_szB;
- // 128 is no special figure, just something not too big
- if (client_redzone_szB > 128) {
- VG_(printf)( "\nTool error:\n"
- " specified redzone size is too big (%llu)\n",=20
- (ULong)client_redzone_szB);
- VG_(exit)(1);
- }
- }
-
- /* Use checked red zones (of various sizes) for our internal stuff,
+ /* We use checked red zones (of various sizes) for our internal stuff=
,
and an unchecked zone of arbitrary size for the client. Of
course the client's red zone can be checked by the tool, eg.=20
by using addressibility maps, but not by the mechanism implemented
@@ -459,15 +445,45 @@
stays as 16 --- the extra 4 bytes in both are accounted for by the
larger prev/next ptr.
*/
- arena_init ( VG_AR_CORE, "core", 4, CORE_ARENA_MIN_SZB=
);
- arena_init ( VG_AR_TOOL, "tool", 4, 1048576=
);
- arena_init ( VG_AR_SYMTAB, "symtab", 4, 1048576=
);
- arena_init ( VG_AR_CLIENT, "client", client_redzone_szB, 1048576=
);
- arena_init ( VG_AR_DEMANGLE, "demangle", 4, 65536=
);
- arena_init ( VG_AR_EXECTXT, "exectxt", 4, 65536=
);
- arena_init ( VG_AR_ERRORS, "errors", 4, 65536=
);
+ if (VG_AR_CLIENT =3D=3D aid) {
+ if (client_inited) {
+ // This assertion ensures that a tool cannot try to change the =
client
+ // redzone size with VG_(needs_malloc_replacement)() after this=
module
+ // has done its first allocation from the client arena.
+ if (VG_(needs).malloc_replacement)
+ vg_assert(client_redzone_szB =3D=3D VG_(tdict).tool_client_r=
edzone_szB);
+ return;
+ }
=20
- init_done =3D True;
+ // Check and set the client arena redzone size
+ if (VG_(needs).malloc_replacement) {
+ client_redzone_szB =3D VG_(tdict).tool_client_redzone_szB;
+ // 128 is no special figure, just something not too big
+ if (client_redzone_szB > 128) {
+ VG_(printf)( "\nTool error:\n"
+ " specified redzone size is too big (%llu)\n",=
=20
+ (ULong)client_redzone_szB);
+ VG_(exit)(1);
+ }
+ }
+ // Initialise the client arena
+ arena_init ( VG_AR_CLIENT, "client", client_redzone_szB, 1048=
576 );
+ client_inited =3D True;
+
+ } else {
+ if (nonclient_inited) {
+ return;
+ }
+ // Initialise the non-client arenas
+ arena_init ( VG_AR_CORE, "core", 4, CORE_ARENA_MIN_=
SZB );
+ arena_init ( VG_AR_TOOL, "tool", 4, 1048=
576 );
+ arena_init ( VG_AR_SYMTAB, "symtab", 4, 1048=
576 );
+ arena_init ( VG_AR_DEMANGLE, "demangle", 4, 65=
536 );
+ arena_init ( VG_AR_EXECTXT, "exectxt", 4, 65=
536 );
+ arena_init ( VG_AR_ERRORS, "errors", 4, 65=
536 );
+ nonclient_inited =3D True;
+ }
+
# ifdef DEBUG_MALLOC
VG_(sanity_check_malloc_all)();
# endif
@@ -932,7 +948,7 @@
=20
VGP_PUSHCC(VgpMalloc);
=20
- ensure_mm_init();
+ ensure_mm_init(aid);
a =3D arenaId_to_ArenaP(aid);
=20
vg_assert(req_pszB < MAX_PSZB);
@@ -1025,7 +1041,7 @@
=20
VGP_PUSHCC(VgpMalloc);
=20
- ensure_mm_init();
+ ensure_mm_init(aid);
a =3D arenaId_to_ArenaP(aid);
=20
if (ptr =3D=3D NULL) {
@@ -1149,7 +1165,7 @@
=20
VGP_PUSHCC(VgpMalloc);
=20
- ensure_mm_init();
+ ensure_mm_init(aid);
a =3D arenaId_to_ArenaP(aid);
=20
vg_assert(req_pszB < MAX_PSZB);
@@ -1273,7 +1289,7 @@
=20
VGP_PUSHCC(VgpMalloc);
=20
- ensure_mm_init();
+ ensure_mm_init(aid);
a =3D arenaId_to_ArenaP(aid);
=20
vg_assert(req_pszB < MAX_PSZB);
|
|
From: Julian S. <js...@ac...> - 2005-09-19 17:58:10
|
As you may know, Valgrind's low level address space manager has been completely rewritten in this past couple of weeks. The aims are: - to allow more flexible memory layout, which will help portability and removes the reliance on VM overcommit in kernels - to allow use of > 2 G of address space on 64-bit platforms. Currently it is set up to limit the process size to about 16G, but that is trivially changed. - on 64-bit targets, to keep as many client mappings as possible below 16G/32G/whatever we choose, so that they are handled by the fast-case paths in memcheck - to be initialised extremely early in the startup sequence, and to rely on practically nothing (specifically, no dynamic memory allocation) so as to get rid of some longstanding circular dependencies and resulting awkward startup-time problems. As of r4681, the it works well enough for hardened hacker types to try it out. It is still a work in progress, so expect breakage. I plan to clean up and stabilise it during this week, and, if nothing adverse happens, then move on to merging it into the trunk. The plan is to ship the new address space manager in 3.1.0. You can get hold of a copy using svn co svn://svn.valgrind.org/branches/ASPACEM Detaching the old manager and reconnecting the new one has been a massively intrusive process, so lots of little bits and pieces have changed all over the place, and various things are broken that weren't before. As of now I have 19 stderr fails and 6 stdout fails on SuSE 9.1 (x86). Here are some notes about stuff still outstanding: * the old manager code is all still there, but disabled, so as to make bringing up the new one easier. * the root thread's stack is limited to 8M, regardless of what rlimit.stack_size says. Ditto its data segment. * m_libcmman is basically dead. All requests that have anything to do with address space (mmap, etc) have to go direct to aspacem (see pub_core_aspacemgr.h, which has extensive comments on the new entry points). * Architectural issue: tools that ask for malloc replacements (massif, memcheck) cannot currently set a non-default redzone size. In order to make memcheck work I have currently kludged it by setting the default RZ size to 16; however that makes massif totally not work. Nick to consider? * Tom: you had some layout issues re amd64? Can you outline them again? You said you had to change map_base in order that the dataseg placement didn't fail. I need to make the dataseg placement more robust. * none/tests/cmdline* mostly fail. I don't understand how the command line parsing works. Anyhow, there is some bad interaction with the new startup sequence. * Architectural issues: - get_seg_starts() is duplicated in m_main.c and mc_main.c. They should be commoned up and put somewhere suitable, but I am not sure where. - m_mallocfree has a new function VG_(out_of_memory_NORETURN), which really should be given a proper home. There is probably more breakage, but that'll do for now :-) J |
|
From: <sv...@va...> - 2005-09-19 17:12:37
|
Author: sewardj
Date: 2005-09-19 18:12:04 +0100 (Mon, 19 Sep 2005)
New Revision: 4681
Log:
A whole stack of changes needed to make memcheck work with the new
address space manager.
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
branches/ASPACEM/coregrind/m_debuginfo/symtab.c
branches/ASPACEM/coregrind/m_main.c
branches/ASPACEM/coregrind/m_mallocfree.c
branches/ASPACEM/coregrind/m_scheduler/scheduler.c
branches/ASPACEM/coregrind/m_signals.c
branches/ASPACEM/coregrind/m_stacktrace.c
branches/ASPACEM/coregrind/pub_core_aspacemgr.h
branches/ASPACEM/coregrind/pub_core_scheduler.h
branches/ASPACEM/include/pub_tool_aspacemgr.h
branches/ASPACEM/memcheck/mac_leakcheck.c
branches/ASPACEM/memcheck/mc_main.c
Modified: branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-19 08:08:4=
6 UTC (rev 4680)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-19 17:12:0=
4 UTC (rev 4681)
@@ -1767,18 +1767,26 @@
}
=20
/* Collect up the start addresses of all non-free, non-resvn segments.
- The interface is a bit strange. You have to call it twice. If
- 'starts' is NULL, the number of such segments is calculated and
- written to *nStarts. If 'starts' is non-NULL, it should point to
- an array of size *nStarts, and the segment start addresses are
- written at starts[0 .. *nStarts-1]. In the latter case, the number
- of required slots is recalculated, and the function asserts if this
- is not equal to *nStarts. */
+ The interface is a bit strange in order to avoid potential
+ segment-creation races caused by dynamic allocation of the result
+ buffer *starts.
=20
-void VG_(am_get_segment_starts)( Addr* starts, Int* nStarts )
+ The function first computes how many entries in the result
+ buffer *starts will be needed. If this number <=3D nStarts,
+ they are placed in starts[0..], and the number is returned.
+ If nStarts is not large enough, nothing is written to
+ starts[0..], and the negation of the size is returned.
+
+ Correct use of this function may mean calling it multiple times in
+ order to establish a suitably-sized buffer. */
+
+Int VG_(am_get_segment_starts)( Addr* starts, Int nStarts )
{
Int i, j, nSegs;
=20
+ /* don't pass dumbass arguments */
+ aspacem_assert(nStarts >=3D 0);
+
nSegs =3D 0;
for (i =3D 0; i < nsegments_used; i++) {
if (nsegments[i].kind =3D=3D SkFree || nsegments[i].kind =3D=3D Sk=
Resvn)
@@ -1786,15 +1794,14 @@
nSegs++;
}
=20
- if (starts =3D=3D NULL) {
- /* caller just wants to know how many segments there are. */
- *nStarts =3D nSegs;
- return;
+ if (nSegs > nStarts) {
+ /* The buffer isn't big enough. Tell the caller how big it needs
+ to be. */
+ return -nSegs;
}
=20
- /* otherwise, caller really is after the segments. */
- /* If this assertion fails, the passed-in *nStarts is incorrect. */
- aspacem_assert(*nStarts =3D=3D nSegs);
+ /* There's enough space. So write into the result buffer. */
+ aspacem_assert(nSegs <=3D nStarts);
=20
j =3D 0;
for (i =3D 0; i < nsegments_used; i++) {
@@ -1805,6 +1812,7 @@
}
=20
aspacem_assert(j =3D=3D nSegs); /* this should not fail */
+ return nSegs;
}
=20
=20
@@ -3090,7 +3098,16 @@
return sres;
}
=20
+/* Really just a wrapper around VG_(am_mmap_anon_float_valgrind). */
=20
+void* VG_(am_shadow_alloc)(SizeT size)
+{
+ SysRes sres =3D VG_(am_mmap_anon_float_valgrind)( size );
+ return sres.isError ? NULL : (void*)sres.val;
+}
+
+
+
/* Map a file at an unconstrained address for V, and update the
segment array accordingly. This is used by V for transiently
mapping in object files to read their debug info. */
Modified: branches/ASPACEM/coregrind/m_debuginfo/symtab.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_debuginfo/symtab.c 2005-09-19 08:08:46 U=
TC (rev 4680)
+++ branches/ASPACEM/coregrind/m_debuginfo/symtab.c 2005-09-19 17:12:04 U=
TC (rev 4681)
@@ -158,7 +158,7 @@
}
=20
if (!found) break;
- unload_symbols( curr->start, 1 );
+ unload_symbols( curr->start, curr->size );
=20
}
}
@@ -207,7 +207,11 @@
=20
void VG_(di_notify_mprotect)( Addr a, SizeT len, UInt prot )
{
- if (!(prot & VKI_PROT_EXEC))
+ Bool exe_ok =3D toBool(prot & VKI_PROT_EXEC);
+# if defined(VGP_x86_linux)
+ exe_ok =3D exe_ok || toBool(prot & VKI_PROT_READ);
+# endif
+ if (!exe_ok)
nuke_syms_in_range(a, len);
}
=20
Modified: branches/ASPACEM/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_main.c 2005-09-19 08:08:46 UTC (rev 4680=
)
+++ branches/ASPACEM/coregrind/m_main.c 2005-09-19 17:12:04 UTC (rev 4681=
)
@@ -920,7 +920,7 @@
=20
// See pub_{core,tool}_options.h for explanations of all these.
=20
-static void usage ( Bool debug_help )
+static void usage_NORETURN ( Bool debug_help )
{
Char* usage1 =3D=20
"usage: valgrind --tool=3D<toolname> [options] prog-and-args\n"
@@ -2035,6 +2035,40 @@
/*=3D=3D=3D main() =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
+/* TODO: GIVE THIS A PROPER HOME
+ TODO: MERGE THIS WITH DUPLICATE IN mac_leakcheck.c
+ Extract from aspacem a vector of the current segment start
+ addresses. The vector is dynamically allocated and should be freed
+ by the caller when done. REQUIRES m_mallocfree to be running.
+ Writes the number of addresses required into *n_acquired. */
+
+static Addr* get_seg_starts ( /*OUT*/Int* n_acquired )
+{
+ Addr* starts;
+ Int n_starts, r;
+
+ n_starts =3D 1;
+ while (True) {
+ starts =3D VG_(malloc)( n_starts * sizeof(Addr) );
+ if (starts =3D=3D NULL)
+ break;
+ r =3D VG_(am_get_segment_starts)( starts, n_starts );
+ if (r >=3D 0)
+ break;
+ VG_(free)(starts);
+ n_starts *=3D 2;
+ }
+
+ if (starts =3D=3D NULL) {
+ *n_acquired =3D 0;
+ return NULL;
+ }
+
+ *n_acquired =3D r;
+ return starts;
+}
+
+
/*
This code decides on the layout of the client and Valgrind address
spaces, loads valgrind.so and the tool.so into the valgrind part,
@@ -2098,6 +2132,7 @@
Addr initial_client_IP;
Addr initial_client_SP;
Addr clstack_top;
+ SizeT clstack_max_size;
UInt* client_auxv;
Int loglevel, i;
struct vki_rlimit zero =3D { 0, 0 };
@@ -2307,14 +2342,14 @@
void* init_sp =3D argv - 1;
SizeT m1 =3D 1024 * 1024;
SizeT m8 =3D 8 * m1;
- SizeT stack_max_size =3D (SizeT)VG_(client_rlimit_stack).rlim_cur;
- if (stack_max_size < m1) stack_max_size =3D m1;
- if (stack_max_size > m8) stack_max_size =3D m8;
- stack_max_size =3D VG_PGROUNDUP(stack_max_size);
+ clstack_max_size =3D (SizeT)VG_(client_rlimit_stack).rlim_cur;
+ if (clstack_max_size < m1) clstack_max_size =3D m1;
+ if (clstack_max_size > m8) clstack_max_size =3D m8;
+ clstack_max_size =3D VG_PGROUNDUP(clstack_max_size);
=20
initial_client_SP
=3D setup_client_stack( init_sp, cl_argv, env, &info,
- &client_auxv, clstack_top, stack_max_size=
);
+ &client_auxv, clstack_top, clstack_max_si=
ze);
=20
VG_(free)(env);
}
@@ -2330,7 +2365,6 @@
// Setup client data (brk) segment. Initially a 1-page segment
// which abuts a shrinkable reservation.=20
// p: load_client() [for 'info' and hence VG_(brk_base)]
- //setup_client_dataseg();
VG_(debugLog)(1, "main", "Setup client data (brk) segment\n");
{=20
SizeT m1 =3D 1024 * 1024;
@@ -2402,7 +2436,7 @@
// If --tool and --help/--help-debug was given, now give the core+too=
l
// help message
if (need_help) {
- usage(/*--help-debug?*/2 =3D=3D need_help);
+ usage_NORETURN(/*--help-debug?*/2 =3D=3D need_help);
}
process_cmd_line_options(client_auxv, tool);
=20
@@ -2469,31 +2503,69 @@
// p: mallocfree
// p: probably: setup fds and process CLOs, so that logging works
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Load initial debug info\n");
{ Addr* seg_starts;
Int n_seg_starts;
- /* find out how many spaces are needed */
- VG_(am_get_segment_starts)( NULL, &n_seg_starts );
- /* allocate */
- seg_starts =3D VG_(malloc)( n_seg_starts * sizeof(Addr) );
- vg_assert(seg_starts);
- /* guard against race */
- VG_(am_get_segment_starts)( NULL, &i );
- vg_assert(n_seg_starts =3D=3D i);
- /* acquire */
- VG_(am_get_segment_starts)( seg_starts, &n_seg_starts );
+
+ seg_starts =3D get_seg_starts( &n_seg_starts );
+ vg_assert(seg_starts && n_seg_starts > 0);
+
/* show them all to the debug info reader */
for (i =3D 0; i < n_seg_starts; i++)
VG_(di_notify_mmap)( seg_starts[i] );
- /* release */
+
VG_(free)( seg_starts );
}
=20
//--------------------------------------------------------------
+ // Tell the tool about the initial client memory permissions
+ // p: aspacem
+ // p: mallocfree
+ // p: setup_client_stack
+ // p: setup_client_dataseg
+ //--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Tell tool about initial permissions\n");
+ { Addr* seg_starts;
+ Int n_seg_starts;
+ NSegment* seg;
+
+ seg_starts =3D get_seg_starts( &n_seg_starts );
+ vg_assert(seg_starts && n_seg_starts > 0);
+
+ /* show interesting ones to the tool */
+ for (i =3D 0; i < n_seg_starts; i++) {
+ seg =3D VG_(am_find_nsegment)( seg_starts[i] );
+ vg_assert(seg);
+ if (seg->kind =3D=3D SkFileC || seg->kind =3D=3D SkAnonC)
+ VG_TRACK( new_mem_startup, seg->start, seg->end+1-seg->start,=
=20
+ seg->hasR, seg->hasW, seg->hasX );
+ }
+
+ VG_(free)( seg_starts );
+
+ /* Also do the initial stack permissions. */
+ seg =3D VG_(am_find_nsegment)( initial_client_SP );
+ vg_assert(seg);
+ vg_assert(seg->kind =3D=3D SkAnonC);
+ vg_assert(initial_client_SP >=3D seg->start);
+ vg_assert(initial_client_SP <=3D seg->end);
+ /* Stuff below the initial SP is unaddressable. */
+ VG_TRACK( die_mem_stack, seg->start, initial_client_SP - seg->start=
);
+ }
+
+ //--------------------------------------------------------------
// Initialise the scheduler
// p: setup_file_descriptors() [else VG_(safe_fd)() breaks]
+ // p: setup_client_stack
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Initialise scheduler\n");
- VG_(scheduler_init)();
+ { NSegment* seg =3D VG_(am_find_nsegment)( initial_client_SP );
+ vg_assert(seg);
+ vg_assert(seg->kind =3D=3D SkAnonC);
+ vg_assert(initial_client_SP >=3D seg->start);
+ vg_assert(initial_client_SP <=3D seg->end);
+ VG_(scheduler_init)( seg->end, clstack_max_size );
+ }
=20
//--------------------------------------------------------------
// Initialise the pthread model
Modified: branches/ASPACEM/coregrind/m_mallocfree.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_mallocfree.c 2005-09-19 08:08:46 UTC (re=
v 4680)
+++ branches/ASPACEM/coregrind/m_mallocfree.c 2005-09-19 17:12:04 UTC (re=
v 4681)
@@ -424,7 +424,7 @@
void ensure_mm_init ( void )
{
static Bool init_done =3D False;
- static SizeT client_redzone_szB =3D 8; // default: be paranoid
+ static SizeT client_redzone_szB =3D 16; //8; // default: be paranoi=
d
=20
if (init_done) {
// This assertion ensures that a tool cannot try to change the cli=
ent
@@ -532,9 +532,11 @@
=20
if (a->clientmem) {
// client allocation -- return 0 to client if it fails
- sb =3D (Superblock*)VG_(get_memory_from_mmap_for_client)(cszB);
- if (NULL =3D=3D sb)
+ sres =3D VG_(am_mmap_anon_float_client)
+ ( cszB, VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC );
+ if (sres.isError)
return 0;
+ sb =3D (Superblock*)sres.val;
} else {
// non-client allocation -- aborts if it fails
sres =3D VG_(am_mmap_anon_float_valgrind)( cszB );
Modified: branches/ASPACEM/coregrind/m_scheduler/scheduler.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_scheduler/scheduler.c 2005-09-19 08:08:4=
6 UTC (rev 4680)
+++ branches/ASPACEM/coregrind/m_scheduler/scheduler.c 2005-09-19 17:12:0=
4 UTC (rev 4681)
@@ -535,11 +535,14 @@
caller subsequently initialises the guest state components of this
main thread, thread 1. =20
*/
-void VG_(scheduler_init) ( void )
+void VG_(scheduler_init) ( Addr clstack_end, SizeT clstack_size )
{
Int i;
ThreadId tid_main;
=20
+ vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1));
+ vg_assert(VG_IS_PAGE_ALIGNED(clstack_size));
+
ML_(sema_init)(&run_sema);
=20
for (i =3D 0 /* NB; not 1 */; i < VG_N_THREADS; i++) {
@@ -559,10 +562,10 @@
=20
tid_main =3D VG_(alloc_ThreadState)();
=20
- /* Initial thread's stack is the original process stack */
VG_(threads)[tid_main].client_stack_highest_word=20
- =3D VG_(clstk_end) - sizeof(=
UWord);
- VG_(threads)[tid_main].client_stack_szB =3D VG_(client_rlimit_stack)=
.rlim_cur;
+ =3D clstack_end + 1 - sizeof(UWord);
+ VG_(threads)[tid_main].client_stack_szB=20
+ =3D clstack_size;
=20
VG_(atfork_child)(sched_fork_cleanup);
}
Modified: branches/ASPACEM/coregrind/m_signals.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_signals.c 2005-09-19 08:08:46 UTC (rev 4=
680)
+++ branches/ASPACEM/coregrind/m_signals.c 2005-09-19 17:12:04 UTC (rev 4=
681)
@@ -1313,7 +1313,8 @@
=20
if (VG_(clo_verbosity) > 1 || (could_core && info->si_code > VKI_SI_U=
SER)) {
VG_(message)(Vg_UserMsg, "");
- VG_(message)(Vg_UserMsg, "Process terminating with default action =
of signal %d (%s)%s",=20
+ VG_(message)(Vg_UserMsg,=20
+ "Process terminating with default action of signal %d=
(%s)%s",=20
sigNo, signame(sigNo), core ? ": dumping core" : "");
=20
/* Be helpful - decode some more details about this fault */
@@ -1339,11 +1340,14 @@
haveaddr =3D False;
break;
}
- VG_(am_show_nsegments)(0,"post segfault");
- {HChar buf[110];
- VG_(sprintf)(buf, "/bin/cat /proc/%d/maps", VG_(getpid)());
- VG_(system)(buf);
- }
+#if 0
+ {
+ HChar buf[110];
+ VG_(am_show_nsegments)(0,"post segfault");
+ VG_(sprintf)(buf, "/bin/cat /proc/%d/maps", VG_(getpid)())=
;
+ VG_(system)(buf);
+ }
+#endif
break;
=20
case VKI_SIGILL:
Modified: branches/ASPACEM/coregrind/m_stacktrace.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_stacktrace.c 2005-09-19 08:08:46 UTC (re=
v 4680)
+++ branches/ASPACEM/coregrind/m_stacktrace.c 2005-09-19 17:12:04 UTC (re=
v 4681)
@@ -89,7 +89,7 @@
// JRS 2002-sep-17: hack, to round up fp_max to the end of the
// current page, at least. Dunno if it helps.
// NJN 2002-sep-17: seems to -- stack traces look like 1.0.X again
- fp_max =3D (fp_max_orig + VKI_PAGE_SIZE - 1) & ~(VKI_PAGE_SIZE - 1);
+ fp_max =3D VG_PGROUNDUP(fp_max_orig);
fp_max -=3D sizeof(Addr);
=20
if (debug)
Modified: branches/ASPACEM/coregrind/pub_core_aspacemgr.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/pub_core_aspacemgr.h 2005-09-19 08:08:46 U=
TC (rev 4680)
+++ branches/ASPACEM/coregrind/pub_core_aspacemgr.h 2005-09-19 17:12:04 U=
TC (rev 4681)
@@ -160,78 +160,10 @@
//--------------------------------------------------------------
// Definition of address-space segments
=20
-/* Describes segment kinds. */
-typedef
- enum {
- SkFree, // unmapped space
- SkAnonC, // anonymous mapping belonging to the client
- SkAnonV, // anonymous mapping belonging to valgrind
- SkFileC, // file mapping belonging to the client
- SkFileV, // file mapping belonging to valgrind
- SkResvn // reservation
- }
- SegKind;
+/* types SegKind, ShrinkMode and NSegment are described in
+ the tool-visible header file, not here. */
=20
-/* Describes how a reservation segment can be resized. */
-typedef
- enum {
- SmLower, // lower end can move up
- SmFixed, // cannot be shrunk
- SmUpper // upper end can move down
- }
- ShrinkMode;
=20
-/* Describes a segment. Invariants:
-
- kind =3D=3D SkFree:
- // the only meaningful fields are .start and .end
-
- kind =3D=3D SkAnon{C,V}:
- // smode=3D=3DSmFixed
- // there's no associated file:
- dev=3D=3Dino=3D=3Dfoff =3D 0, fnidx =3D=3D -1
- // segment may have permissions
-
- kind =3D=3D SkFile{C,V}:
- // smode=3D=3DSmFixed
- moveLo =3D=3D moveHi =3D=3D NotMovable, maxlen =3D=3D 0
- // there is an associated file
- // segment may have permissions
-
- kind =3D=3D SkResvn
- // the segment may be resized if required
- // there's no associated file:
- dev=3D=3Dino=3D=3Dfoff =3D 0, fnidx =3D=3D -1
- // segment has no permissions
- hasR=3D=3DhasW=3D=3DhasX=3D=3DanyTranslated =3D=3D False
-
- Also: anyTranslated=3D=3DTrue is only allowed in SkFileV and SkAnon=
V
- (viz, not allowed to make translations from non-client areas)
-*/
-typedef
- struct {
- SegKind kind;
- /* Extent (SkFree, SkAnon{C,V}, SkFile{C,V}, SkResvn) */
- Addr start; // lowest address in range
- Addr end; // highest address in range
- /* Shrinkable? (SkResvn only) */
- ShrinkMode smode;
- /* Associated file (SkFile{C,V} only) */
- UWord dev;
- UWord ino;
- ULong offset;
- Int fnIdx; // file name table index, if name is known
- /* Permissions (SkAnon{C,V}, SkFile{C,V} only) */
- Bool hasR;
- Bool hasW;
- Bool hasX;
- Bool hasT; // True --> translations have (or MAY have)
- /* Admin */ // been taken from this segment
- Bool mark;
- }
- NSegment;
-
-
//--------------------------------------------------------------
// Initialisation
=20
@@ -251,7 +183,8 @@
=20
/* Finds the segment containing 'a'. Only returns file/anon/resvn
segments. */
-extern NSegment* VG_(am_find_nsegment) ( Addr a );
+// Is in tool-visible header file.
+// extern NSegment* VG_(am_find_nsegment) ( Addr a );
=20
/* Find the next segment along from 'here', if it is a file/anon/resvn
segment. */
@@ -263,8 +196,9 @@
VKI_PROT_NONE as 'prot'. Will return False if any part of the
area does not belong to the client or does not have at least
the stated permissions. */
-extern Bool VG_(am_is_valid_for_client)
- ( Addr start, SizeT len, UInt prot );
+// Is in tool-visible header file.
+// extern Bool VG_(am_is_valid_for_client)
+// ( Addr start, SizeT len, UInt prot );
=20
/* Variant of VG_(am_is_valid_for_client) which allows free areas to
be consider part of the client's addressable space. It also
@@ -287,15 +221,8 @@
elsewhere. */
extern HChar* VG_(am_get_filename)( NSegment* );
=20
-/* Collect up the start addresses of all non-free, non-resvn segments.
- The interface is a bit strange. You have to call it twice. If
- 'starts' is NULL, the number of such segments is calculated and
- written to *nStarts. If 'starts' is non-NULL, it should point to
- an array of size *nStarts, and the segment start addresses are
- written at starts[0 .. *nStarts-1]. In the latter case, the number
- of required slots is recalculated, and the function asserts if this
- is not equal to *nStarts. */
-extern void VG_(am_get_segment_starts)( Addr* starts, Int* nStarts );
+/* VG_(am_get_segment_starts) is also part of this section, but its
+ prototype is tool-visible, hence not in this header file. */
=20
=20
//--------------------------------------------------------------
Modified: branches/ASPACEM/coregrind/pub_core_scheduler.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/pub_core_scheduler.h 2005-09-19 08:08:46 U=
TC (rev 4680)
+++ branches/ASPACEM/coregrind/pub_core_scheduler.h 2005-09-19 17:12:04 U=
TC (rev 4681)
@@ -75,7 +75,8 @@
// The scheduler.
extern VgSchedReturnCode VG_(scheduler) ( ThreadId tid );
=20
-extern void VG_(scheduler_init) ( void );
+// Initialise. Is passed the extent of the root thread's client stack.
+extern void VG_(scheduler_init) ( Addr clstack_end, SizeT clstack_size )=
;
=20
/* Stats ... */
extern void VG_(print_scheduler_stats) ( void );
Modified: branches/ASPACEM/include/pub_tool_aspacemgr.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/include/pub_tool_aspacemgr.h 2005-09-19 08:08:46 UTC=
(rev 4680)
+++ branches/ASPACEM/include/pub_tool_aspacemgr.h 2005-09-19 17:12:04 UTC=
(rev 4681)
@@ -31,11 +31,111 @@
#ifndef __PUB_TOOL_ASPACEMGR_H
#define __PUB_TOOL_ASPACEMGR_H
=20
+
+//--------------------------------------------------------------
+// Definition of address-space segments
+
+/* Describes segment kinds. */
+typedef
+ enum {
+ SkFree, // unmapped space
+ SkAnonC, // anonymous mapping belonging to the client
+ SkAnonV, // anonymous mapping belonging to valgrind
+ SkFileC, // file mapping belonging to the client
+ SkFileV, // file mapping belonging to valgrind
+ SkResvn // reservation
+ }
+ SegKind;
+
+/* Describes how a reservation segment can be resized. */
+typedef
+ enum {
+ SmLower, // lower end can move up
+ SmFixed, // cannot be shrunk
+ SmUpper // upper end can move down
+ }
+ ShrinkMode;
+
+/* Describes a segment. Invariants:
+
+ kind =3D=3D SkFree:
+ // the only meaningful fields are .start and .end
+
+ kind =3D=3D SkAnon{C,V}:
+ // smode=3D=3DSmFixed
+ // there's no associated file:
+ dev=3D=3Dino=3D=3Dfoff =3D 0, fnidx =3D=3D -1
+ // segment may have permissions
+
+ kind =3D=3D SkFile{C,V}:
+ // smode=3D=3DSmFixed
+ moveLo =3D=3D moveHi =3D=3D NotMovable, maxlen =3D=3D 0
+ // there is an associated file
+ // segment may have permissions
+
+ kind =3D=3D SkResvn
+ // the segment may be resized if required
+ // there's no associated file:
+ dev=3D=3Dino=3D=3Dfoff =3D 0, fnidx =3D=3D -1
+ // segment has no permissions
+ hasR=3D=3DhasW=3D=3DhasX=3D=3DanyTranslated =3D=3D False
+
+ Also: anyTranslated=3D=3DTrue is only allowed in SkFileV and SkAnon=
V
+ (viz, not allowed to make translations from non-client areas)
+*/
+typedef
+ struct {
+ SegKind kind;
+ /* Extent (SkFree, SkAnon{C,V}, SkFile{C,V}, SkResvn) */
+ Addr start; // lowest address in range
+ Addr end; // highest address in range
+ /* Shrinkable? (SkResvn only) */
+ ShrinkMode smode;
+ /* Associated file (SkFile{C,V} only) */
+ UWord dev;
+ UWord ino;
+ ULong offset;
+ Int fnIdx; // file name table index, if name is known
+ /* Permissions (SkAnon{C,V}, SkFile{C,V} only) */
+ Bool hasR;
+ Bool hasW;
+ Bool hasX;
+ Bool hasT; // True --> translations have (or MAY have)
+ /* Admin */ // been taken from this segment
+ Bool mark;
+ }
+ NSegment;
+
+
+/* Collect up the start addresses of all non-free, non-resvn segments.
+ The interface is a bit strange in order to avoid potential
+ segment-creation races caused by dynamic allocation of the result
+ buffer *starts.
+
+ The function first computes how many entries in the result
+ buffer *starts will be needed. If this number <=3D nStarts,
+ they are placed in starts[0..], and the number is returned.
+ If nStarts is not large enough, nothing is written to
+ starts[0..], and the negation of the size is returned.
+
+ Correct use of this function may mean calling it multiple times in
+ order to establish a suitably-sized buffer. */
+extern Int VG_(am_get_segment_starts)( Addr* starts, Int nStarts );
+
+
+// See pub_core_aspacemgr.h for description.
+extern NSegment* VG_(am_find_nsegment) ( Addr a );=20
+
+// See pub_core_aspacemgr.h for description.
+extern Bool VG_(am_is_valid_for_client) ( Addr start, SizeT len,=20
+ UInt prot );
+
extern Bool VG_(is_client_addr) (Addr a);
=20
extern Bool VG_(is_shadow_addr) (Addr a);
=20
-extern void *VG_(shadow_alloc)(UInt size);
+/* Really just a wrapper around VG_(am_mmap_anon_float_valgrind). */
+extern void* VG_(am_shadow_alloc)(SizeT size);
=20
extern Bool VG_(is_addressable)(Addr p, SizeT sz, UInt prot);
=20
Modified: branches/ASPACEM/memcheck/mac_leakcheck.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/memcheck/mac_leakcheck.c 2005-09-19 08:08:46 UTC (re=
v 4680)
+++ branches/ASPACEM/memcheck/mac_leakcheck.c 2005-09-19 17:12:04 UTC (re=
v 4681)
@@ -72,6 +72,41 @@
__builtin_longjmp(memscan_jmpbuf, 1);
}
=20
+
+/* TODO: GIVE THIS A PROPER HOME
+ TODO: MERGE THIS WITH DUPLICATE IN m_main.c
+ Extract from aspacem a vector of the current segment start
+ addresses. The vector is dynamically allocated and should be freed
+ by the caller when done. REQUIRES m_mallocfree to be running.
+ Writes the number of addresses required into *n_acquired. */
+
+static Addr* get_seg_starts ( /*OUT*/Int* n_acquired )
+{
+ Addr* starts;
+ Int n_starts, r;
+
+ n_starts =3D 1;
+ while (True) {
+ starts =3D VG_(malloc)( n_starts * sizeof(Addr) );
+ if (starts =3D=3D NULL)
+ break;
+ r =3D VG_(am_get_segment_starts)( starts, n_starts );
+ if (r >=3D 0)
+ break;
+ VG_(free)(starts);
+ n_starts *=3D 2;
+ }
+
+ if (starts =3D=3D NULL) {
+ *n_acquired =3D 0;
+ return NULL;
+ }
+
+ *n_acquired =3D r;
+ return starts;
+}
+
+
/*------------------------------------------------------------*/
/*--- Detecting leaked (unreachable) malloc'd blocks. ---*/
/*------------------------------------------------------------*/
@@ -293,7 +328,8 @@
{
Int sh_no;
=20
- if (!VG_(is_client_addr)(ptr)) /* quick filter */
+ /* quick filter */
+ if (!VG_(am_is_valid_for_client)(ptr, 1, VKI_PROT_NONE))
return;
=20
sh_no =3D find_shadow_for(ptr, lc_shadows, lc_n_shadows);
@@ -393,8 +429,7 @@
=20
lc_scanned +=3D end-ptr;
=20
- if (!VG_(is_client_addr)(ptr) ||
- !VG_(is_addressable)(ptr, sizeof(Addr), VKI_PROT_READ))
+ if (!VG_(am_is_valid_for_client)(ptr, sizeof(Addr), VKI_PROT_READ))
ptr =3D VG_PGROUNDUP(ptr+1); /* first page bad */
=20
while (ptr < end) {
@@ -408,8 +443,7 @@
=20
/* Look to see if this page seems reasonble */
if ((ptr % VKI_PAGE_SIZE) =3D=3D 0) {
- if (!VG_(is_client_addr)(ptr) ||
- !VG_(is_addressable)(ptr, sizeof(Addr), VKI_PROT_READ))
+ if (!VG_(am_is_valid_for_client)(ptr, sizeof(Addr), VKI_PROT_READ))
ptr +=3D VKI_PAGE_SIZE; /* bad page - skip it */
}
=20
@@ -692,8 +726,24 @@
=20
lc_scanned =3D 0;
=20
- /* Do the scan of memory, pushing any pointers onto the mark stack */
- VG_(find_root_memory)(lc_scan_memory);
+ /* Do the scan of memory, pushing any pointers onto the mark stack.
+ Here, we iterate over the segment array, handing any RW client
+ sections to lc_scan_memory. */
+ { NSegment* seg;
+ Addr* seg_starts;
+ Int n_seg_starts;
+ seg_starts =3D get_seg_starts( &n_seg_starts );
+ tl_assert(seg_starts && n_seg_starts > 0);
+ for (i =3D 0; i < n_seg_starts; i++) {
+ seg =3D VG_(am_find_nsegment)( seg_starts[i] );
+ tl_assert(seg);
+ if (seg->kind !=3D SkFileC && seg->kind !=3D SkAnonC)=20
+ continue;
+ if (!(seg->hasR && seg->hasW))
+ continue;
+ lc_scan_memory(seg->start, seg->end+1 - seg->start);
+ }
+ }
=20
/* Push registers onto mark stack */
VG_(apply_to_GP_regs)(lc_markstack_push);
Modified: branches/ASPACEM/memcheck/mc_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/memcheck/mc_main.c 2005-09-19 08:08:46 UTC (rev 4680=
)
+++ branches/ASPACEM/memcheck/mc_main.c 2005-09-19 17:12:04 UTC (rev 4681=
)
@@ -190,7 +190,7 @@
|| dist_sm =3D=3D &sm_distinguished[1]
|| dist_sm =3D=3D &sm_distinguished[2]);
=20
- new_sm =3D VG_(shadow_alloc)(sizeof(SecMap));
+ new_sm =3D VG_(am_shadow_alloc)(sizeof(SecMap));
VG_(memcpy)(new_sm, dist_sm, sizeof(SecMap));
n_secmaps_issued++;
return new_sm;
|
|
From: Julian S. <js...@ac...> - 2005-09-19 09:37:28
|
> So we could require a malloc-replacing tool to provide a function that > returns the redzone size, which the core calls, which would be separate > from VG_(needs_malloc_replacement)(). It's easy, but a shame because it's > less neat than having a single function. Yes. Simple and moderately grubby. > Another possibility is to call the tools VG_(tdict).pre_clo_init function > before starting m_mallocfree.c. That would preclude it from allocating > memory, though, which is probably less neat than having two functions. Agreed. Significantly less neat, imo. > Another possibility is to allow the individual arenas in m_mallocfree.c to > be initialized not all at the same time, but on demand. So > ensure_mm_init(void) would become ensure_mm_init(Arena aid). If the tool > tried to set the redzone size with VG_(needs_malloc_replacement)() after > having allocated some memory, m_mallocfree could abort saying "you can't > do that". I like that solution the best. That's an interesting idea. > If you like, just get some hacky workaround working so you can move onto > more important things, and I'll implement the nice solution later. I just set the default size to 16 in m_mallocfree, which allowed me to make progress with memcheck last night. I now have it running all the way up to dying in the leak checker. Overall, this new aspacem is turning out to me a mammoth task, but I now expect to have something tryable-outable in the next couple of days. J |
|
From: Julian S. <js...@ac...> - 2005-09-19 09:22:53
|
On Monday 19 September 2005 05:52, Nicholas Nethercote wrote:
> On Sun, 18 Sep 2005, sv...@va... wrote:
> > + if (sres.val != advised) {
> > + /* I don't think this can happen. It means the kernel made a
> > + fixed map succeed but not at the requested location. Try to
> > + repair the damage, then return saying the mapping failed. */
> > + (void)do_munmap_NO_NOTIFY( sres.val, length );
> > + return VG_(mk_SysRes_Error)( VKI_EINVAL );
> > + }
>
> I think we've seen a buggy kernel do that before.
I was thinking that we should have a standard function to
call, perhaps VG_(kernel_bug)( HChar* what, Bool fatal ) to call
whenever the kernel doesn't behave the way we expect, as a
centralised uniform way of reporting such behaviour.
J
|
|
From: <sv...@va...> - 2005-09-19 08:08:50
|
Author: tom
Date: 2005-09-19 09:08:46 +0100 (Mon, 19 Sep 2005)
New Revision: 4680
Log:
Use the new address space manager calls to map separated debug informatio=
n.
Modified:
branches/ASPACEM/coregrind/m_debuginfo/symtab.c
Modified: branches/ASPACEM/coregrind/m_debuginfo/symtab.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_debuginfo/symtab.c 2005-09-19 07:57:20 U=
TC (rev 4679)
+++ branches/ASPACEM/coregrind/m_debuginfo/symtab.c 2005-09-19 08:08:46 U=
TC (rev 4680)
@@ -1299,9 +1299,8 @@
static
Addr open_debug_file( Char* name, UInt crc, UInt* size )
{
- SysRes fd;
+ SysRes fd, sres;
struct vki_stat stat_buf;
- Addr addr;
UInt calccrc;
=20
fd =3D VG_(open)(name, VKI_O_RDONLY, 0);
@@ -1318,26 +1317,24 @@
=20
*size =3D stat_buf.st_size;
=20
- if ((addr =3D (Addr)VG_(mmap)(NULL, *size, VKI_PROT_READ,
- VKI_MAP_PRIVATE|VKI_MAP_NOSYMS,=20
- 0, fd.val, 0)) =3D=3D (Addr)-1)=20
- {
- VG_(close)(fd.val);
- return 0;
- }
+ sres =3D VG_(am_mmap_file_float_valgrind)
+ ( *size, VKI_PROT_READ, fd.val, 0 );
=20
VG_(close)(fd.val);
=20
- calccrc =3D calc_gnu_debuglink_crc32(0, (UChar*)addr, *size);
+ if (sres.isError)
+ return 0;
+
+ calccrc =3D calc_gnu_debuglink_crc32(0, (UChar*)sres.val, *size);
if (calccrc !=3D crc) {
- int res =3D VG_(munmap)((void*)addr, *size);
- vg_assert(0 =3D=3D res);
+ SysRes res =3D VG_(am_munmap_valgrind)(sres.val, *size);
+ vg_assert(!res.isError);
if (VG_(clo_verbosity) > 1)
VG_(message)(Vg_DebugMsg, "... CRC mismatch (computed %08x wanted %08x=
)", calccrc, crc);
return 0;
}
=20
- return addr;
+ return sres.val;
}
=20
/*
|
|
From: <sv...@va...> - 2005-09-19 07:57:24
|
Author: tom
Date: 2005-09-19 08:57:20 +0100 (Mon, 19 Sep 2005)
New Revision: 4679
Log:
Make the mremap2 test a bit more portable so it builds on amd64.
Modified:
branches/ASPACEM/none/tests/mremap2.c
Modified: branches/ASPACEM/none/tests/mremap2.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/none/tests/mremap2.c 2005-09-19 00:53:52 UTC (rev 46=
78)
+++ branches/ASPACEM/none/tests/mremap2.c 2005-09-19 07:57:20 UTC (rev 46=
79)
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
=20
#include <stdio.h>
#include <sys/mman.h>
@@ -5,17 +6,17 @@
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
+#include <errno.h>
+#include <syscall.h>
=20
=20
-/* x86 linux specifics */
-#define __NR_mremap 163
-#define VKI_MREMAP_MAYMOVE 1
-#define VKI_MREMAP_FIXED 2
+#ifndef REMAP_FIXED
+#define MREMAP_FIXED 2
+#endif
=20
=20
+static int PAGE;
=20
-#define PAGE 4096
-
void mapanon_fixed ( void* start, size_t length )
{
void* r =3D mmap(start, length, PROT_NONE,=20
@@ -82,40 +83,6 @@
}
=20
=20
-int is_kerror(int r)=20
-{
- return r >=3D -4096 && r <=3D -1;
-}
-
-typedef unsigned int UWord;
-extern UWord do_syscall_WRK (
- UWord syscall_no,
- UWord a1, UWord a2, UWord a3,
- UWord a4, UWord a5, UWord a6
- );
-asm(
-"do_syscall_WRK:\n"
-" push %esi\n"
-" push %edi\n"
-" push %ebx\n"
-" push %ebp\n"
-" movl 16+ 4(%esp),%eax\n"
-" movl 16+ 8(%esp),%ebx\n"
-" movl 16+12(%esp),%ecx\n"
-" movl 16+16(%esp),%edx\n"
-" movl 16+20(%esp),%esi\n"
-" movl 16+24(%esp),%edi\n"
-" movl 16+28(%esp),%ebp\n"
-" int $0x80\n"
-" popl %ebp\n"
-" popl %ebx\n"
-" popl %edi\n"
-" popl %esi\n"
-" ret\n"
-);
-
-
-
char* dst =3D NULL;
char* src =3D NULL;
char* dst_impossible =3D NULL;
@@ -141,6 +108,8 @@
int firsttime =3D 1;
char buf[100];
=20
+ PAGE =3D sysconf(_SC_PAGESIZE);
+
for (maymove =3D 0; maymove <=3D 1 ; maymove++) {
for (fixed =3D 0; fixed <=3D 1; fixed++) {
printf("\n");
@@ -148,8 +117,8 @@
for (dstpossible =3D 0; dstpossible <=3D 1; dstpossible++) {
=20
int newsize =3D newsizes[nsi] * PAGE;
- int flags =3D (maymove ? VKI_MREMAP_MAYMOVE : 0) |
- (fixed ? VKI_MREMAP_FIXED : 0);
+ int flags =3D (maymove ? MREMAP_MAYMOVE : 0) |
+ (fixed ? MREMAP_FIXED : 0);
dst =3D dstpossible ? try_dst : dst_impossible;
src =3D setup( tidythis, tidylen );
=20
@@ -165,22 +134,21 @@
firsttime =3D 0;
}
=20
- printf("maymv %d fixed %d newsz %2d dstpo %d dst 0x%08x -> "=
,
- maymove, fixed, newsizes[nsi], dstpossible, (UWord)dst );
+ printf("maymv %d fixed %d newsz %2d dstpo %d dst %p -> ",
+ maymove, fixed, newsizes[nsi], dstpossible, dst );
r =3D (char*)
- do_syscall_WRK(__NR_mremap, (UWord)src,=20
- 20*PAGE, newsize, flags, (UWord)dst, 0 );
- if (is_kerror((int)r))
- printf("error %d\n", -(int)r);
+ syscall(__NR_mremap, src, 20*PAGE, newsize, flags, dst, 0 );
+ if (r =3D=3D MAP_FAILED)
+ printf("error %d\n", errno);
else
- printf("0x%08x (=3D=3D %s)\n", (int)r, identify(r));
+ printf("%p (=3D=3D %s)\n", r, identify(r));
=20
if (1) {
show();
printf("\n");
}
=20
- if (!is_kerror((int)r)) {
+ if (r !=3D MAP_FAILED) {
if (r !=3D src && r !=3D try_dst && r !=3D dst_impossible) {
tidythis =3D r;
tidylen =3D newsize;
|
|
From: Nicholas N. <nj...@cs...> - 2005-09-19 04:52:29
|
On Sun, 18 Sep 2005, sv...@va... wrote:
> + if (sres.val != advised) {
> + /* I don't think this can happen. It means the kernel made a
> + fixed map succeed but not at the requested location. Try to
> + repair the damage, then return saying the mapping failed. */
> + (void)do_munmap_NO_NOTIFY( sres.val, length );
> + return VG_(mk_SysRes_Error)( VKI_EINVAL );
> + }
I think we've seen a buggy kernel do that before.
Nick
|
|
From: Nicholas N. <nj...@cs...> - 2005-09-19 04:49:23
|
On Mon, 19 Sep 2005, Julian Seward wrote: > memcheck is a problem, though. It dies like this at startup: > > valgrind: m_mallocfree.c:434 (ensure_mm_init): > Assertion 'client_redzone_szB == VG_(tdict).tool_client_redzone_szB' failed. > > I know why, but I don't know how to fix it. It's another circular > dependency. The new startup sequence in main() looks more or less > like this (yay!): > > - start debug logger > - start address space manager (very early, as desired) > - start m_mallocfree (do a test malloc/free) > > Starting mallocfree early is convenient for all later phases. > > It then goes on to use m_ume to load the client, builds its stack, > loads initial debug info, etc. Around this point it also initialises > the tool. Memcheck's initialisation code sets > VG_(tdict).tool_client_redzone_szB to some new non-default value, > and that causes m_mallocfree to assert, because it specifically checks > that the client redzone size doesn't change after the first allocation > (fair enough). > > One solution might be for the core to have a way to ask a tool its > client redzone size very early on, way before actually initialising > the tool, and then passing that value into m_mallocfree when > starting it up. [It might be good to give m_mallocfree an explicit > initialisation method rather than having it self-initialising as > at present]. This would require a change to the core/tool interface, > though. What do you reckon? Until recently the tools specified their redzone size with a variable (which overrode the default value thanks to weak symbol magic) for exactly this reason. Then things changed and I made it part of the VG_(needs_malloc_replacement)() call, which is neater because it puts all the things a tool needs to initialise for malloc replacement in a single call. So we could require a malloc-replacing tool to provide a function that returns the redzone size, which the core calls, which would be separate from VG_(needs_malloc_replacement)(). It's easy, but a shame because it's less neat than having a single function. Another possibility is to call the tools VG_(tdict).pre_clo_init function before starting m_mallocfree.c. That would preclude it from allocating memory, though, which is probably less neat than having two functions. Another possibility is to allow the individual arenas in m_mallocfree.c to be initialized not all at the same time, but on demand. So ensure_mm_init(void) would become ensure_mm_init(Arena aid). If the tool tried to set the redzone size with VG_(needs_malloc_replacement)() after having allocated some memory, m_mallocfree could abort saying "you can't do that". I like that solution the best. If you like, just get some hacky workaround working so you can move onto more important things, and I'll implement the nice solution later. Nick |
|
From: <js...@ac...> - 2005-09-19 02:56:52
|
Nightly build on phoenix ( SuSE 9.1 ) started at 2005-09-19 03:30:00 BST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 185 tests, 2 stderr failures, 0 stdout failures ================= none/tests/faultstatus (stderr) none/tests/x86/int (stderr) |
|
From: Tom H. <to...@co...> - 2005-09-19 02:42:46
|
Nightly build on dunsmere ( athlon, Fedora Core 4 ) started at 2005-09-19 03:30:04 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 == 187 tests, 5 stderr failures, 0 stdout failures ================= memcheck/tests/leak-tree (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) none/tests/x86/int (stderr) |
|
From: Tom H. <th...@cy...> - 2005-09-19 02:28:36
|
Nightly build on alvis ( i686, Red Hat 7.3 ) started at 2005-09-19 03:15:04 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 == 186 tests, 14 stderr failures, 0 stdout failures ================= memcheck/tests/addressable (stderr) memcheck/tests/describe-block (stderr) memcheck/tests/erringfds (stderr) memcheck/tests/leak-0 (stderr) memcheck/tests/leak-cycle (stderr) memcheck/tests/leak-regroot (stderr) memcheck/tests/leak-tree (stderr) memcheck/tests/match-overrun (stderr) memcheck/tests/partiallydefinedeq (stderr) memcheck/tests/pointer-trace (stderr) memcheck/tests/sigkill (stderr) memcheck/tests/stack_changes (stderr) none/tests/faultstatus (stderr) none/tests/x86/int (stderr) |
|
From: Tom H. <th...@cy...> - 2005-09-19 02:26:41
|
Nightly build on ginetta ( i686, Red Hat 8.0 ) started at 2005-09-19 03:10:07 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 == 186 tests, 2 stderr failures, 0 stdout failures ================= none/tests/faultstatus (stderr) none/tests/x86/int (stderr) |
|
From: Tom H. <th...@cy...> - 2005-09-19 02:21:40
|
Nightly build on dellow ( x86_64, Fedora Core 4 ) started at 2005-09-19 03:10:07 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 == 164 tests, 6 stderr failures, 0 stdout failures ================= memcheck/tests/sigprocmask (stderr) memcheck/tests/strchr (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) |
|
From: Tom H. <th...@cy...> - 2005-09-19 02:19:34
|
Nightly build on aston ( x86_64, Fedora Core 3 ) started at 2005-09-19 03:05:04 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 == 164 tests, 6 stderr failures, 0 stdout failures ================= memcheck/tests/sigprocmask (stderr) memcheck/tests/strchr (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) |
|
From: Tom H. <th...@cy...> - 2005-09-19 02:14:53
|
Nightly build on gill ( x86_64, Fedora Core 2 ) started at 2005-09-19 03:00:03 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 == 164 tests, 7 stderr failures, 0 stdout failures ================= memcheck/tests/sigprocmask (stderr) memcheck/tests/strchr (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) none/tests/fdleak_fcntl (stderr) |