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: Julian S. <js...@ac...> - 2005-09-18 23:15:23
|
On Sunday 18 September 2005 14:00, Nicholas Nethercote wrote: > On Sun, 18 Sep 2005, Julian Seward wrote: > > Any ideas if something this simple would work (before I find out > > the hard way? :-) IIRC 1.0.X had an even more moronic scheme and I > > don't remember people complaining about it, although equally it > > could have had problems with corner cases / unusual uses > > that I wasn't aware of. > > I don't know how important the corner cases are. I suggest you implement > your scheme, and make it abort when it hits a corner case; you'll soon > find out how common they are :) The simplistic version seems to be working now, and all tools except memcheck run. 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? J |
|
From: <sv...@va...> - 2005-09-18 22:44:22
|
Author: sewardj
Date: 2005-09-18 23:44:17 +0100 (Sun, 18 Sep 2005)
New Revision: 4677
Log:
Add simplistic support for loading/unloading debug info.
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_syswrap/syswrap-generic.c
branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c
branches/ASPACEM/coregrind/pub_core_aspacemgr.h
branches/ASPACEM/coregrind/pub_core_debuginfo.h
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-18 10:07:5=
1 UTC (rev 4676)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-18 22:44:1=
7 UTC (rev 4677)
@@ -1751,6 +1751,63 @@
}
=20
=20
+/* Get the filename corresponding to this segment, if known and if it
+ has one. The returned name's storage cannot be assumed to be
+ persistent, so the caller should immediately copy the name
+ elsewhere. */
+HChar* VG_(am_get_filename)( NSegment* seg )
+{
+ Int i;
+ aspacem_assert(seg);
+ i =3D seg->fnIdx;
+ if (i < 0 || i >=3D segnames_used || !segnames[i].inUse)
+ return NULL;
+ else
+ return &segnames[i].fname[0];
+}
+
+/* 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. */
+
+void VG_(am_get_segment_starts)( Addr* starts, Int* nStarts )
+{
+ Int i, j, nSegs;
+
+ 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)
+ continue;
+ nSegs++;
+ }
+
+ if (starts =3D=3D NULL) {
+ /* caller just wants to know how many segments there are. */
+ *nStarts =3D nSegs;
+ return;
+ }
+
+ /* otherwise, caller really is after the segments. */
+ /* If this assertion fails, the passed-in *nStarts is incorrect. */
+ aspacem_assert(*nStarts =3D=3D nSegs);
+
+ j =3D 0;
+ for (i =3D 0; i < nsegments_used; i++) {
+ if (nsegments[i].kind =3D=3D SkFree || nsegments[i].kind =3D=3D Sk=
Resvn)
+ continue;
+ starts[j] =3D nsegments[i].start;
+ j++;
+ }
+
+ aspacem_assert(j =3D=3D nSegs); /* this should not fail */
+}
+
+
/*-----------------------------------------------------------------*/
/*--- ---*/
/*--- Sanity checking and preening of the segment array. ---*/
@@ -2150,6 +2207,32 @@
return is_valid_for_client( start, len, prot, True/*free is OK*/ );
}
=20
+
+/* Test if a piece of memory is addressable by valgrind with at least
+ PROT_NONE protection permissions by examining the underlying
+ segments. */
+static Bool is_valid_for_valgrind( Addr start, SizeT len )
+{
+ Int i, iLo, iHi;
+
+ if (len =3D=3D 0)
+ return True; /* somewhat dubious case */
+ if (start + len < start)
+ return False; /* reject wraparounds */
+
+ iLo =3D find_nsegment_idx(start);
+ iHi =3D find_nsegment_idx(start + len - 1);
+ for (i =3D iLo; i <=3D iHi; i++) {
+ if (nsegments[i].kind =3D=3D SkFileV || nsegments[i].kind =3D=3D S=
kAnonV) {
+ /* ok */
+ } else {
+ return False;
+ }
+ }
+ return True;
+}
+
+
/*-----------------------------------------------------------------*/
/*--- ---*/
/*--- Modifying the segment array, and constructing segments. ---*/
@@ -3008,12 +3091,80 @@
}
=20
=20
-/* Unmap the given address range an update the segment array
- accordingly. This fails if the range isn't valid for the
- client. */
+/* 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. */
=20
-SysRes VG_(am_munmap_client)( Addr start, SizeT len )
+SysRes VG_(am_mmap_file_float_valgrind) ( SizeT length, UInt prot,=20
+ Int fd, SizeT offset )
{
+ SysRes sres;
+ NSegment seg;
+ Addr advised;
+ Bool ok;
+ MapRequest req;
+ UInt dev, ino;
+ HChar buf[VKI_PATH_MAX];
+=20
+ /* Not allowable. */
+ if (length =3D=3D 0)
+ return VG_(mk_SysRes_Error)( VKI_EINVAL );
+
+ /* Ask for an advisory. If it's negative, fail immediately. */
+ req.rkind =3D MAny;
+ req.start =3D 0;
+ req.len =3D length;
+ advised =3D VG_(am_get_advisory)( &req, True/*client*/, &ok );
+ if (!ok)
+ return VG_(mk_SysRes_Error)( VKI_EINVAL );
+
+ /* We have been advised that the mapping is allowable at the
+ specified address. So hand it off to the kernel, and propagate
+ any resulting failure immediately. */
+ sres =3D VG_(am_do_mmap_NO_NOTIFY)(=20
+ advised, length, prot,=20
+ VKI_MAP_FIXED|VKI_MAP_PRIVATE,=20
+ fd, offset=20
+ );
+ if (sres.isError)
+ return sres;
+
+ if (sres.val !=3D 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 );
+ }
+
+ /* Ok, the mapping succeeded. Now notify the interval map. */
+ init_nsegment( &seg );
+ seg.kind =3D SkFileV;
+ seg.start =3D sres.val;
+ seg.end =3D seg.start + VG_PGROUNDUP(length) - 1;
+ seg.offset =3D offset;
+ seg.hasR =3D toBool(prot & VKI_PROT_READ);
+ seg.hasW =3D toBool(prot & VKI_PROT_WRITE);
+ seg.hasX =3D toBool(prot & VKI_PROT_EXEC);
+ if (get_inode_for_fd(fd, &dev, &ino)) {
+ seg.dev =3D dev;
+ seg.ino =3D ino;
+ }
+ if (get_name_for_fd(fd, buf, VKI_PATH_MAX)) {
+ seg.fnIdx =3D allocate_segname( buf );
+ }
+ add_segment( &seg );
+
+ AM_SANITY_CHECK;
+ return sres;
+}
+
+
+/* --- --- munmap helper --- --- */
+
+static=20
+SysRes am_munmap_both_wrk ( Addr start, SizeT len, Bool forClient )
+{
SysRes sres;
=20
if (!VG_IS_PAGE_ALIGNED(start))
@@ -3029,9 +3180,14 @@
aspacem_assert(VG_IS_PAGE_ALIGNED(start));
aspacem_assert(VG_IS_PAGE_ALIGNED(len));
=20
- if (!VG_(am_is_valid_for_client_or_free_or_resvn)
- ( start, len, VKI_PROT_NONE ))
- goto eINVAL;
+ if (forClient) {
+ if (!VG_(am_is_valid_for_client_or_free_or_resvn)
+ ( start, len, VKI_PROT_NONE ))
+ goto eINVAL;
+ } else {
+ if (!is_valid_for_valgrind( start, len ))
+ goto eINVAL;
+ }
=20
sres =3D do_munmap_NO_NOTIFY( start, len );
if (sres.isError)
@@ -3045,7 +3201,24 @@
return VG_(mk_SysRes_Error)( VKI_EINVAL );
}
=20
+/* Unmap the given address range and update the segment array
+ accordingly. This fails if the range isn't valid for the
+ client. */
=20
+SysRes VG_(am_munmap_client)( Addr start, SizeT len )
+{
+ return am_munmap_both_wrk( start, len, True/*client*/ );
+}
+
+/* Unmap the given address range and update the segment array
+ accordingly. This fails if the range isn't valid for valgrind. */
+
+SysRes VG_(am_munmap_valgrind)( Addr start, SizeT len )
+{
+ return am_munmap_both_wrk( start, len, False/*valgrind*/ );
+}
+
+
/* --- --- --- reservations --- --- --- */
=20
/* Create a reservation from START .. START+LENGTH-1, with the given
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-18 10:07:51 U=
TC (rev 4676)
+++ branches/ASPACEM/coregrind/m_debuginfo/symtab.c 2005-09-18 22:44:17 U=
TC (rev 4677)
@@ -45,6 +45,8 @@
#include "pub_core_redir.h"
#include "pub_core_tooliface.h" // For VG_(needs).data_syms
=20
+#include "pub_core_aspacemgr.h"
+
#include "priv_symtypes.h"
#include "priv_symtab.h"
=20
@@ -95,6 +97,124 @@
=20
=20
/*------------------------------------------------------------*/
+/*--- TOP LEVEL ---*/
+/*------------------------------------------------------------*/
+
+/* 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.so
+ 1b8ff000-1b900000 rw-p 00004000 08:02 4471477 vgpreload_memcheck.so
+
+ 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. Reading
+ 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.
+*/
+
+static Bool is_self ( HChar* filename )
+{=20
+ return VG_(strstr)( filename, "/lib/valgrind/" ) !=3D NULL;
+}
+
+////////////
+
+// fwds
+static void unload_symbols ( Addr start, SizeT length );
+
+static void nuke_syms_in_range ( Addr start, SizeT length )
+{
+ /* Repeatedly scan the segInfo list, looking for segInfos in this
+ range, and call unload_symbols on the segInfo's stated start
+ point. This modifies the list, hence the multiple
+ iterations. */
+ Bool found;
+ SegInfo* curr;
+
+ while (True) {
+ found =3D False;
+
+ curr =3D segInfo_list;
+ while (True) {
+ if (curr =3D=3D NULL) break;
+ if (start+length-1 < curr->start || curr->start+curr->size-1 < =
start) {
+ /* no overlap */
+ } else {
+ found =3D True;
+ break;
+ }
+ curr =3D curr->next;
+ }
+
+ if (!found) break;
+ unload_symbols( curr->start, 1 );
+
+ }
+}
+
+void VG_(di_notify_mmap)( Addr a )
+{
+ NSegment* seg;
+ HChar* filename;
+ Bool ok;
+
+ seg =3D VG_(am_find_nsegment)(a);
+ vg_assert(seg);
+
+ filename =3D VG_(am_get_filename)( seg );
+ if (!filename)
+ return;
+
+ filename =3D VG_(arena_strdup)( VG_AR_SYMTAB, filename );
+
+ ok =3D (seg->kind =3D=3D SkFileC || (seg->kind =3D=3D SkFileV && is_s=
elf(filename)))
+ && seg->offset =3D=3D 0
+ && seg->fnIdx !=3D -1
+ && seg->hasR
+ && seg->hasX
+ && !seg->hasW
+ && VG_(is_object_file)( (const void*)seg->start );
+
+ if (!ok) {
+ VG_(arena_free)(VG_AR_SYMTAB, filename);
+ return;
+ }
+
+ nuke_syms_in_range( seg->start, seg->end + 1 - seg->start );
+ VG_(read_seg_symbols)( seg->start, seg->end + 1 - seg->start,=20
+ seg->offset, filename );
+
+ /* VG_(read_seg_symbols) makes its own copy of filename, so is safe
+ to free it. */
+ VG_(arena_free)(VG_AR_SYMTAB, filename);
+}
+
+void VG_(di_notify_munmap)( Addr a, SizeT len )
+{
+ nuke_syms_in_range(a, len);
+}
+
+void VG_(di_notify_mprotect)( Addr a, SizeT len, UInt prot )
+{
+ if (!(prot & VKI_PROT_EXEC))
+ nuke_syms_in_range(a, len);
+}
+
+
+
+
+/*------------------------------------------------------------*/
/*--- ---*/
/*------------------------------------------------------------*/
=20
@@ -1261,7 +1381,7 @@
ElfXX_Ehdr* ehdr; /* The ELF header =
*/
ElfXX_Shdr* shdr; /* The section table =
*/
UChar* sh_strtab; /* The section table's string table =
*/
- SysRes fd;
+ SysRes fd, sres;
Int i;
Bool ok;
Addr oimage;
@@ -1272,7 +1392,8 @@
=20
oimage =3D (Addr)NULL;
if (VG_(clo_verbosity) > 1)
- VG_(message)(Vg_DebugMsg, "Reading syms from %s (%p)", si->filenam=
e, si->start );
+ VG_(message)(Vg_DebugMsg, "Reading syms from %s (%p)",=20
+ si->filename, si->start );
=20
/* mmap the object image aboard, so that we can read symbols and
line number info out of it. It will be munmapped immediately
@@ -1291,18 +1412,19 @@
return False;
}
=20
- oimage =3D (Addr)VG_(mmap)( NULL, n_oimage,=20
- VKI_PROT_READ, VKI_MAP_PRIVATE|VKI_MAP_NOSY=
MS,=20
- 0, fd.val, 0 );
+ sres =3D VG_(am_mmap_file_float_valgrind)
+ ( n_oimage, VKI_PROT_READ, fd.val, 0 );
=20
VG_(close)(fd.val);
=20
- if (oimage =3D=3D ((Addr)(-1))) {
+ if (sres.isError) {
VG_(message)(Vg_UserMsg, "warning: mmap failed on %s", si->filenam=
e );
VG_(message)(Vg_UserMsg, " no symbols or debug info loaded=
" );
return False;
}
=20
+ oimage =3D sres.val;
+
/* Ok, the object image is safely in oimage[0 .. n_oimage-1].=20
Now verify that it is a valid ELF .so or executable image.
*/
@@ -1631,14 +1753,14 @@
res =3D True;
=20
out: {
- Int m_res;
+ SysRes m_res;
/* Last, but not least, heave the image(s) back overboard. */
if (dimage) {
- m_res =3D VG_(munmap) ( (void*)dimage, n_dimage );
- vg_assert(0 =3D=3D m_res);
+ m_res =3D VG_(am_munmap_valgrind) ( dimage, n_dimage );
+ vg_assert(!m_res.isError);
}
- m_res =3D VG_(munmap) ( (void*)oimage, n_oimage );
- vg_assert(0 =3D=3D m_res);
+ m_res =3D VG_(am_munmap_valgrind) ( oimage, n_oimage );
+ vg_assert(!m_res.isError);
return res;
}=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-18 10:07:51 UTC (rev 4676=
)
+++ branches/ASPACEM/coregrind/m_main.c 2005-09-18 22:44:17 UTC (rev 4677=
)
@@ -2344,11 +2344,26 @@
}
=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
- // Finished setting up operating environment. Now initialise
- // Valgrind. (This is where the old VG_(main)() started.)
+ //
+ // Finished loading/setting up the client address space.
+ //
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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
//--------------------------------------------------------------
+ // Initialise translation table and translation cache
+ // p: aspacem
+ //--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Initialise TT/TC\n");
+ VG_(init_tt_tc)();
+
+ //--------------------------------------------------------------
+ // Initialise the redirect table.
+ // p: init_tt_tc [so it can call VG_(search_transtab) safely]
+ //--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Initialise redirects\n");
+ VG_(setup_code_redirect_table)();
+
+ //--------------------------------------------------------------
// setup file descriptors
// p: n/a
//--------------------------------------------------------------
@@ -2449,6 +2464,31 @@
}
=20
//--------------------------------------------------------------
+ // Load debug info for the existing segments.
+ // p: setup_code_redirect_table [so that redirs can be recorded]
+ // p: mallocfree
+ // p: probably: setup fds and process CLOs, so that logging works
+ //--------------------------------------------------------------
+ { 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 );
+ /* 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 );
+ }
+
+ //--------------------------------------------------------------
// Initialise the scheduler
// p: setup_file_descriptors() [else VG_(safe_fd)() breaks]
//--------------------------------------------------------------
@@ -2508,23 +2548,6 @@
}
=20
//--------------------------------------------------------------
- // Initialise translation table and translation cache
- // p: read_procselfmaps [so the anonymous mmaps for the TT/TC
- // aren't identified as part of the client, which would waste
- // > 20M of virtual address space.]
- //--------------------------------------------------------------
- VG_(debugLog)(1, "main", "Initialise TT/TC\n");
- VG_(init_tt_tc)();
-
- //--------------------------------------------------------------
- // Initialise the redirect table.
- // p: parse_procselfmaps? [XXX for debug info?]
- // p: init_tt_tc [so it can call VG_(search_transtab) safely]
- //--------------------------------------------------------------
- VG_(debugLog)(1, "main", "Initialise redirects\n");
- VG_(setup_code_redirect_table)();
-
- //--------------------------------------------------------------
// Tell the tool about permissions in our handwritten assembly
// helpers.
// p: init tool [for 'new_mem_startup']
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-18 10:=
07:51 UTC (rev 4676)
+++ branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c 2005-09-18 22:=
44:17 UTC (rev 4677)
@@ -4740,6 +4740,7 @@
page_align_addr_and_len(&a, &len);
VG_(am_notify_mprotect)(a, len, prot);
VG_TRACK( change_mem_mprotect, a, len, rr, ww, xx );
+ VG_(di_notify_mprotect)( a, len, prot );
}
=20
PRE(sys_munmap)
@@ -4760,6 +4761,7 @@
page_align_addr_and_len(&a, &len);
VG_(am_notify_munmap)(a, len);
VG_TRACK( die_mem_munmap, a, len );
+ VG_(di_notify_munmap)( a, len );
}
=20
PRE(sys_mincore)
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-18 1=
0:07:51 UTC (rev 4676)
+++ branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c 2005-09-18 2=
2:44:17 UTC (rev 4677)
@@ -1539,6 +1539,8 @@
args[4-1], /* the original flags value */
a5, a6=20
);
+ /* Load symbols? */
+ VG_(di_notify_mmap)( (Addr)sres.val );
}
=20
/* Stay sane */
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-18 10:07:51 U=
TC (rev 4676)
+++ branches/ASPACEM/coregrind/pub_core_aspacemgr.h 2005-09-18 22:44:17 U=
TC (rev 4677)
@@ -281,7 +281,23 @@
/* Show the segment array on the debug log, at given loglevel. */
extern void VG_(am_show_nsegments) ( Int logLevel, HChar* who );
=20
+/* Get the filename corresponding to this segment, if known and if it
+ has one. The returned name's storage cannot be assumed to be
+ persistent, so the caller should immediately copy the name
+ 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 );
+
+
//--------------------------------------------------------------
// Functions pertaining to the central query-notify mechanism
// used to handle mmap/munmap/mprotect resulting from client
@@ -370,11 +386,21 @@
itself more address space when needed. */
extern SysRes VG_(am_mmap_anon_float_valgrind)( SizeT cszB );
=20
-/* Unmap the given address range an update the segment array
+/* 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. */
+extern SysRes VG_(am_mmap_file_float_valgrind)
+ ( SizeT length, UInt prot, Int fd, SizeT offset );
+
+/* Unmap the given address range and update the segment array
accordingly. This fails if the range isn't valid for the
client. */
extern SysRes VG_(am_munmap_client)( Addr start, SizeT length );
=20
+/* Unmap the given address range and update the segment array
+ accordingly. This fails if the range isn't valid for valgrind. */
+extern SysRes VG_(am_munmap_valgrind)( Addr start, SizeT length );
+
/* --- --- --- reservations --- --- --- */
=20
/* Create a reservation from START .. START+LENGTH-1, with the given
Modified: branches/ASPACEM/coregrind/pub_core_debuginfo.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_debuginfo.h 2005-09-18 10:07:51 U=
TC (rev 4676)
+++ branches/ASPACEM/coregrind/pub_core_debuginfo.h 2005-09-18 22:44:17 U=
TC (rev 4677)
@@ -41,6 +41,10 @@
=20
#include "pub_tool_debuginfo.h"
=20
+extern void VG_(di_notify_mmap)( Addr a );
+extern void VG_(di_notify_munmap)( Addr a, SizeT len );
+extern void VG_(di_notify_mprotect)( Addr a, SizeT len, UInt prot );
+
extern Bool VG_(is_object_file) ( const void *hdr );
extern SegInfo *VG_(read_seg_symbols) ( Addr addr, SizeT len,
OffT offset, const Char* filenam=
e);
|
|
From: John R.
|
Julian Seward wrote: >>Similarly, if a Segment gets split (by mprotect, for example), the two >>pieces will still be associated with the same SegInfo. This happens when a debugger inserts a breakpoint, or when ld-linux relocates a module that has DT_TEXTREL, or when a co-resident monitor rewrites some instructions. On x86, a shared lib with relocations to .text "works" just fine. The modified pages are no longer sharable, but the instruction stream is functional. It's even rather common, when a builder forgets to use -fpic for one or more files. It can be done on purpose when the modularity is more important than the page sharing. Non-pic code is faster, too: register %ebx is not dedicated to _GLOBAL_OFFSET_TABLE_ addressing, and global variables can be accessed by [relocated] inline 32-bit offset rather than by address fetched from the GOT. >>If a new mmap appears in the address range of an existing SegInfo On x86_64 the static linker ld inserts a 1MB "hole" between .text and .data. This is on advice from the hardware performance mavens, because various caching+prefetching hardware can look ahead that far. Currently ld-linux leaves this as PROT_NONE, but anybody else is free to override that assignment. > From peering at various /proc/*/maps files, the following scheme > sounds plausible: > > Load symbols following an mmap if: > > map is to a file > map has r-x permissions > file has a valid ELF header > possibly: mapping is > 1 page (catches the case of mapping first > page just to examine the header) > > If the client wants to subsequently chop up the mapping, or change its > permissions, we ignore that. I have never seen any evidence in proc/*/maps > that ld.so does such things. glibc-2.3.5 ld-linux does. It finds the minimum interval of pages which covers the p_memsz of all PT_LOAD, mmap()s that much from the file [even if this maps beyond EOF of the file], then munmap()s [or mprotect(,,PROT_NONE)] everything that is not covered by the first PT_LOAD, then mmap(,,,MAP_FIXED,,) each remaining PT_LOAD. This is done to overcome the possibility that a kernel which randomizes the placement of mmap(0, ...) might place the first PT_LOAD so that subsequent PT_LOAD [must maintain relative addressing to other PT_LOAD from the same file] would evict something else. Needless to say, ld-linux assumes that it is the only actor (well, dlopen() does try for mutual exclusion) and that any "holes" between PT_LOAD from the same module are ignorable as far as allocation is concerned. Also, there is nothing to stop a file from having PT_LOAD that overlap, or appear in non-ascending order, etc. The results might depend on order of processing, but always it has been by order of appearance in the file. [Probably this is a good way to trigger "bugs" in ld-linux and/or the kernel.] Some algorithms and data structures internal to glibc-2.3.5 assume that modules do not overlap. In particular, ld-linux sometimes searches for __builtin_return_address_(0) in a set of intervals in order to determine which shared lib called ld-linux. This matters for dlsym(), dlmopen(), etc., and assumes that the intervals are a disjoint cover of any "legal" callers. ld-linux tries to hide all of this from the prying eyes of anyone else [the internal version of struct link_map contains much more than specified in <link.h>]. Some of this is good because it changes very frequently, but some parts are bad because in the past ld-linux has been slow to provide needed services [such as dl_iterate_phdr()] and even antagonistic towards anybody else trying for peaceful co-existence without the blessing of ld-linux. -- John Reiser, jreiser@BitWagon.com |
|
From: Nicholas N. <nj...@cs...> - 2005-09-18 13:00:31
|
On Sun, 18 Sep 2005, Julian Seward wrote: > Any ideas if something this simple would work (before I find out > the hard way? :-) IIRC 1.0.X had an even more moronic scheme and I > don't remember people complaining about it, although equally it > could have had problems with corner cases / unusual uses > that I wasn't aware of. I don't know how important the corner cases are. I suggest you implement your scheme, and make it abort when it hits a corner case; you'll soon find out how common they are :) Nick |
|
From: Julian S. <js...@ac...> - 2005-09-18 12:25:16
|
Starting to consider symbol loading on the aspacem branch.
I looked at docs/internals/segments-seginfos.txt, and studied the
associated code a bit, and I think I see what's going on.
What I can't figure out is whether such a complex approach is
really needed. I realise that the question "should we load=20
symbols for the mmap that just happened" can't be answered=20
exactly, because there is no surefire way to distinguish an
mmap done by ld.so(dlopen) vs some random mmap of an object file
which just happens to look indistinguishable. However clever
we are, a sufficiently devious program can always fool us into
not loading debuginfo when we should, or vice versa. =20
I don't feel there's much point in trying to correctly handle
anything other than the bog-standard nothing-weird case.
It would be useful to enumerate the cases which happen in
practice. segments-seginfos.txt contains a couple of comments
in support of the reference counting scheme:
> Similarly, if a Segment gets split (by mprotect, for example), the two
> pieces will still be associated with the same SegInfo.
> If a new mmap appears in the address range of an existing SegInfo
Do either of these happen in practice?
> For example, if the process mmaps the
> first page of an ELF file (the one containing the header), a SegInfo
> will be created for that ELF file's mappings, which will include memory
> which will be later mmaped by the client's ELF loader.
I wasn't clear what is supposed to happen here.
=2D-----------
=46rom peering at various /proc/*/maps files, the following scheme
sounds plausible:
Load symbols following an mmap if:
map is to a file
map has r-x permissions
file has a valid ELF header
possibly: mapping is > 1 page (catches the case of mapping first
page just to examine the header)
If the client wants to subsequently chop up the mapping, or change its
permissions, we ignore that. I have never seen any evidence in proc/*/maps
that ld.so does such things.
=46ollowing an munmap, dump symbols for any previously loaded range
which intersects the unmapped range. Again, this screws up if half an
executable segment is unmapped, and again I'm not sure this happens in
practice.
=46ollowing an mprotect, dump symbols for any previously loaded range
which intersects the protected range AND the new protection does not
include 'x' access.
=2D-----------
Any ideas if something this simple would work (before I find out
the hard way? :-) IIRC 1.0.X had an even more moronic scheme and I
don't remember people complaining about it, although equally it
could have had problems with corner cases / unusual uses=20
that I wasn't aware of.
J
|
|
From: <sv...@va...> - 2005-09-18 10:07:54
|
Author: sewardj
Date: 2005-09-18 11:07:51 +0100 (Sun, 18 Sep 2005)
New Revision: 4676
Log:
Make mc_copy_address_range_state safe in the presence of overlaps.
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
branches/ASPACEM/coregrind/pub_core_tooliface.h
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-18 09:45:3=
3 UTC (rev 4675)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-18 10:07:5=
1 UTC (rev 4676)
@@ -1391,7 +1391,7 @@
=20
#define AM_SANITY_CHECK \
do { \
- if (VG_(clo_sanity_level > 1)) \
+ if (VG_(clo_sanity_level >=3D 3)) \
aspacem_assert(do_sync_check(__PRETTY_FUNCTION__, \
__FILE__,__LINE__)); \
} while (0)=20
@@ -1971,6 +1971,16 @@
"sync check at %s:%d (%s): FAILED\n",
file, line, fn);
VG_(debugLog)(0,"aspacem", "\n");
+
+# if 0
+ {
+ HChar buf[100];
+ VG_(am_show_nsegments)(0,"post segfault");
+ VG_(sprintf)(buf, "/bin/cat /proc/%d/maps", VG_(getpid)());
+ VG_(system)(buf);
+ }
+# endif
+
}
return sync_check_ok;
}
Modified: branches/ASPACEM/coregrind/pub_core_tooliface.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_tooliface.h 2005-09-18 09:45:33 U=
TC (rev 4675)
+++ branches/ASPACEM/coregrind/pub_core_tooliface.h 2005-09-18 10:07:51 U=
TC (rev 4676)
@@ -158,7 +158,7 @@
void (*track_new_mem_brk) (Addr, SizeT);
void (*track_new_mem_mmap) (Addr, SizeT, Bool, Bool, Bool);
=20
- void (*track_copy_mem_remap) (Addr, Addr, SizeT);
+ void (*track_copy_mem_remap) (Addr src, Addr dst, SizeT);
void (*track_change_mem_mprotect) (Addr, SizeT, Bool, Bool, Bool);
void (*track_die_mem_stack_signal)(Addr, SizeT);
void (*track_die_mem_brk) (Addr, SizeT);
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-18 09:45:33 UTC (rev 4675=
)
+++ branches/ASPACEM/memcheck/mc_main.c 2005-09-18 10:07:51 UTC (rev 4676=
)
@@ -738,21 +738,35 @@
}
=20
=20
-/* --- Block-copy permissions (needed for implementing realloc()). --- *=
/
+/* --- Block-copy permissions (needed for implementing realloc() and
+ sys_mremap). --- */
=20
static void mc_copy_address_range_state ( Addr src, Addr dst, SizeT len =
)
{
- SizeT i;
+ SizeT i, j;
UWord abit, vbyte;
=20
DEBUG("mc_copy_address_range_state\n");
+ PROF_EVENT(50, "mc_copy_address_range_state");
=20
- PROF_EVENT(50, "mc_copy_address_range_state");
- for (i =3D 0; i < len; i++) {
- PROF_EVENT(51, "mc_copy_address_range_state(loop)");
- get_abit_and_vbyte( &abit, &vbyte, src+i );
- set_abit_and_vbyte( dst+i, abit, vbyte );
+ if (len =3D=3D 0)
+ return;
+
+ if (src < dst) {
+ for (i =3D 0, j =3D len-1; i < len; i++, j--) {
+ PROF_EVENT(51, "mc_copy_address_range_state(loop)");
+ get_abit_and_vbyte( &abit, &vbyte, src+j );
+ set_abit_and_vbyte( dst+j, abit, vbyte );
+ }
}
+
+ if (src > dst) {
+ for (i =3D 0; i < len; i++) {
+ PROF_EVENT(51, "mc_copy_address_range_state(loop)");
+ get_abit_and_vbyte( &abit, &vbyte, src+i );
+ set_abit_and_vbyte( dst+i, abit, vbyte );
+ }
+ }
}
=20
=20
|
|
From: <sv...@va...> - 2005-09-18 09:45:41
|
Author: sewardj
Date: 2005-09-18 10:45:33 +0100 (Sun, 18 Sep 2005)
New Revision: 4675
Log:
do_mremap(): reinstate tool-notification tracking calls
Modified:
branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c
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-18 09:=
03:56 UTC (rev 4674)
+++ branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c 2005-09-18 09:=
45:33 UTC (rev 4675)
@@ -158,6 +158,8 @@
Addr new_addr, SizeT new_len,
UWord flags, ThreadId tid )
{
+# define MIN_SIZET(_aa,_bb) (_aa) < (_bb) ? (_aa) : (_bb)
+
Bool ok;
NSegment* old_seg;
Addr advised;
@@ -278,8 +280,15 @@
goto eNOMEM;
ok =3D VG_(am_relocate_nooverlap_client)
( old_addr, old_len, new_addr, new_len );
- if (ok)=20
+ if (ok) {
+ VG_TRACK( copy_mem_remap, old_addr, new_addr,=20
+ MIN_SIZET(old_len,new_len) );
+ if (new_len > old_len)
+ VG_TRACK( new_mem_mmap, new_addr+old_len, new_len-old_len,
+ old_seg->hasR, old_seg->hasW, old_seg->hasX );
+ VG_TRACK(die_mem_munmap, old_addr, old_len);
return VG_(mk_SysRes_Success)( new_addr );
+ }
goto eNOMEM;
}
=20
@@ -300,9 +309,12 @@
advised =3D VG_(am_get_advisory_client_simple)( needA, needL, &ok );
if (ok && advised =3D=3D needA) {
ok =3D VG_(am_extend_map_client)( old_seg, needL );
- old_seg =3D NULL;
- if (ok)
+ if (ok) {
+ VG_TRACK( new_mem_mmap, needA, needL,=20
+ old_seg->hasR,=20
+ old_seg->hasW, old_seg->hasX );
return VG_(mk_SysRes_Success)( old_addr );
+ }
}
=20
/* that failed. Look elsewhere. */
@@ -313,7 +325,15 @@
|| advised > old_addr+old_len-1);
ok =3D VG_(am_relocate_nooverlap_client)
( old_addr, old_len, advised, new_len );
- if (ok) return VG_(mk_SysRes_Success)( advised );
+ if (ok) {
+ VG_TRACK( copy_mem_remap, old_addr, new_addr,=20
+ MIN_SIZET(old_len,new_len) );
+ if (new_len > old_len)
+ VG_TRACK( new_mem_mmap, new_addr+old_len, new_len-old_len,
+ old_seg->hasR, old_seg->hasW, old_seg->hasX );
+ VG_TRACK(die_mem_munmap, old_addr, old_len);
+ return VG_(mk_SysRes_Success)( advised );
+ }
}
goto eNOMEM;
}
@@ -331,18 +351,20 @@
if (!ok || advised !=3D needA)
goto eNOMEM;
ok =3D VG_(am_extend_map_client)( old_seg, needL );
- old_seg =3D NULL;
if (!ok)
goto eNOMEM;
+ VG_TRACK( new_mem_mmap, needA, needL,=20
+ old_seg->hasR, old_seg->hasW, old_seg->hasX )=
;
return VG_(mk_SysRes_Success)( old_addr );
}
/*NOTREACHED*/ vg_assert(0);
=20
shrink_in_place:
{
- SysRes sres =3D VG_(am_munmap_client)( old_addr+new_len, old_len-new_=
len);
+ SysRes sres =3D VG_(am_munmap_client)( old_addr+new_len, old_len-new_=
len );
if (sres.isError)
return sres;
+ VG_TRACK( die_mem_munmap, old_addr+new_len, old_len-new_len );
return VG_(mk_SysRes_Success)( old_addr );
}
/*NOTREACHED*/ vg_assert(0);
@@ -355,6 +377,8 @@
return VG_(mk_SysRes_Error)( VKI_EINVAL );
eNOMEM:
return VG_(mk_SysRes_Error)( VKI_ENOMEM );
+
+# undef MIN_SIZET
}
=20
=20
|
|
From: <sv...@va...> - 2005-09-18 09:04:03
|
Author: sewardj
Date: 2005-09-18 10:03:56 +0100 (Sun, 18 Sep 2005)
New Revision: 4674
Log:
Add a second, very thorough, test of mremap.
Added:
branches/ASPACEM/none/tests/mremap2.c
branches/ASPACEM/none/tests/mremap2.stderr.exp
branches/ASPACEM/none/tests/mremap2.stdout.exp
branches/ASPACEM/none/tests/mremap2.vgtest
Modified:
branches/ASPACEM/none/tests/Makefile.am
Modified: branches/ASPACEM/none/tests/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/none/tests/Makefile.am 2005-09-18 08:34:38 UTC (rev =
4673)
+++ branches/ASPACEM/none/tests/Makefile.am 2005-09-18 09:03:56 UTC (rev =
4674)
@@ -56,6 +56,7 @@
map_unmap.stderr.exp map_unmap.stdout.exp map_unmap.vgtest \
mq.stderr.exp mq.vgtest \
mremap.stderr.exp mremap.stdout.exp mremap.vgtest \
+ mremap2.stderr.exp mremap2.stdout.exp mremap2.vgtest \
munmap_exe.stderr.exp munmap_exe.vgtest \
nestedfns.stderr.exp nestedfns.stdout.exp nestedfns.vgtest \
pending.stdout.exp pending.stderr.exp pending.vgtest \
@@ -107,7 +108,7 @@
fdleak_fcntl fdleak_ipv4 fdleak_open fdleak_pipe \
fdleak_socketpair \
floored fork fucomip manythreads \
- munmap_exe map_unaligned map_unmap mq mremap \
+ munmap_exe map_unaligned map_unmap mq mremap mremap2 \
nestedfns \
pending \
pth_atfork1 pth_blockedsig pth_cancel1 pth_cancel2 pth_cvsimple \
Added: 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-18 08:34:38 UTC (rev 46=
73)
+++ branches/ASPACEM/none/tests/mremap2.c 2005-09-18 09:03:56 UTC (rev 46=
74)
@@ -0,0 +1,195 @@
+
+#include <stdio.h>
+#include <sys/mman.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+
+/* x86 linux specifics */
+#define __NR_mremap 163
+#define VKI_MREMAP_MAYMOVE 1
+#define VKI_MREMAP_FIXED 2
+
+
+
+#define PAGE 4096
+
+void mapanon_fixed ( void* start, size_t length )
+{
+ void* r =3D mmap(start, length, PROT_NONE,=20
+ MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, 0,0);
+ assert(r !=3D MAP_FAILED);
+ assert(r =3D=3D start);
+}
+
+void unmap_and_check ( void* start, size_t length )
+{
+ int r =3D munmap( start, length );
+ assert(r =3D=3D 0);
+}
+
+char* workingarea =3D NULL;
+char* try_dst =3D NULL;
+
+// set up working area so expansion limit is 20*PAGE
+//
+// | 10 | 20 | 10 | 60 |
+// | pre | src | FREE | post |
+//
+// A suitable attempted fixed dst is workingarea + 150*PAGE.
+
+char* setup ( void* other_stuff, int other_len )
+{
+ if (!workingarea) {
+ workingarea =3D mmap(0, 200*PAGE, PROT_NONE,=20
+ MAP_ANONYMOUS|MAP_PRIVATE, 0,0);
+ assert(workingarea);
+ try_dst =3D workingarea + 150*PAGE;
+ unmap_and_check(workingarea, 200*PAGE);
+ }
+
+ if (other_stuff) {
+ unmap_and_check(other_stuff, other_len);
+ }
+
+ // get rid of the old working area
+ unmap_and_check( workingarea, 200*PAGE);
+
+ // pre block
+ mapanon_fixed( workingarea + 0*PAGE, 9*PAGE);
+
+ // the area
+ mapanon_fixed( workingarea + 10*PAGE, 20*PAGE );
+
+ // upper half
+ mapanon_fixed( workingarea + 40*PAGE, 60*PAGE );
+
+ return workingarea + 10*PAGE;
+}
+
+/* show the working area */
+void show ( void )
+{
+ int i,r;
+ for (i =3D 0; i < 200; i++) {
+ r =3D mprotect( workingarea + i * PAGE, PAGE, PROT_NONE );
+ printf("%c", r =3D=3D 0 ? 'X' : '.');
+ if (i =3D=3D 49 || i =3D=3D 99 || i =3D=3D 149) printf("\n");
+ }
+ printf("\n");
+}
+
+
+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;
+
+
+char* identify ( char* p )
+{
+ if (p =3D=3D dst) return "dst";
+ if (p =3D=3D src) return "src";
+ if (p =3D=3D dst_impossible) return "dst_imp!";
+ if (p =3D=3D try_dst) return "dst_poss";
+ return "other";
+}
+
+int main ( void )
+{
+ int alocal, maymove, fixed, nsi, dstpossible;
+ dst_impossible =3D (char*)(&alocal) + 500 * 1000 * 1000;
+ int newsizes[6] =3D { 19, 20, 21, 29, 30, 31 };
+
+ char* tidythis =3D NULL;
+ int tidylen =3D 0;
+ int firsttime =3D 1;
+ char buf[100];
+
+ for (maymove =3D 0; maymove <=3D 1 ; maymove++) {
+ for (fixed =3D 0; fixed <=3D 1; fixed++) {
+ printf("\n");
+ for (nsi =3D 0; nsi < 6; nsi++) {
+ for (dstpossible =3D 0; dstpossible <=3D 1; dstpossible++) {
+
+ int newsize =3D newsizes[nsi] * PAGE;
+ int flags =3D (maymove ? VKI_MREMAP_MAYMOVE : 0) |
+ (fixed ? VKI_MREMAP_FIXED : 0);
+ dst =3D dstpossible ? try_dst : dst_impossible;
+ src =3D setup( tidythis, tidylen );
+
+ char* r;
+
+ if (firsttime) {
+ printf("dst_possible =3D %p\n", try_dst );
+ printf("dst_impossible =3D %p\n", dst_impossible );
+ printf(" src =3D %p\n", src);
+ printf("\n");
+ sprintf(buf, "cat /proc/%d/maps", getpid());
+ if (0) system(buf);
+ firsttime =3D 0;
+ }
+
+ printf("maymv %d fixed %d newsz %2d dstpo %d dst 0x%08x -> "=
,
+ maymove, fixed, newsizes[nsi], dstpossible, (UWord)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);
+ else
+ printf("0x%08x (=3D=3D %s)\n", (int)r, identify(r));
+
+ if (1) {
+ show();
+ printf("\n");
+ }
+
+ if (!is_kerror((int)r)) {
+ if (r !=3D src && r !=3D try_dst && r !=3D dst_impossible) {
+ tidythis =3D r;
+ tidylen =3D newsize;
+ }
+ }
+
+ }
+ }
+ }
+ }
+ return 0;
+}
Added: branches/ASPACEM/none/tests/mremap2.stderr.exp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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.stderr.exp 2005-09-18 08:34:38 UT=
C (rev 4673)
+++ branches/ASPACEM/none/tests/mremap2.stderr.exp 2005-09-18 09:03:56 UT=
C (rev 4674)
@@ -0,0 +1,2 @@
+
+
Added: branches/ASPACEM/none/tests/mremap2.stdout.exp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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.stdout.exp 2005-09-18 08:34:38 UT=
C (rev 4673)
+++ branches/ASPACEM/none/tests/mremap2.stdout.exp 2005-09-18 09:03:56 UT=
C (rev 4674)
@@ -0,0 +1,296 @@
+
+dst_possible =3D 0x........
+dst_impossible =3D 0x........
+ src =3D 0x........
+
+maymv 0 fixed 0 newsz 19 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXX...........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 19 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXX...........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 20 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 20 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 21 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXX.........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 21 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXX.........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 29 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 29 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 30 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 30 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 31 dstpo 0 dst 0x........ -> error 12
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 0 newsz 31 dstpo 1 dst 0x........ -> error 12
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+
+maymv 0 fixed 1 newsz 19 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 19 dstpo 1 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 20 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 20 dstpo 1 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 21 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 21 dstpo 1 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 29 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 29 dstpo 1 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 30 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 30 dstpo 1 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 31 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 0 fixed 1 newsz 31 dstpo 1 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+
+maymv 1 fixed 0 newsz 19 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXX...........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 19 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXX...........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 20 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 20 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 21 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXX.........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 21 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXX.........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 29 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 29 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 30 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 30 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D src)
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 0 newsz 31 dstpo 0 dst 0x........ -> 0x........ (=3D=
=3D other)
+XXXXXXXXX...............................XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...................
+..................................................
+
+maymv 1 fixed 0 newsz 31 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D other)
+XXXXXXXXX...............................XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...................
+..................................................
+
+
+maymv 1 fixed 1 newsz 19 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 1 newsz 19 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D dst)
+XXXXXXXXX...............................XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+XXXXXXXXXXXXXXXXXXX...............................
+
+maymv 1 fixed 1 newsz 20 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 1 newsz 20 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D dst)
+XXXXXXXXX...............................XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+XXXXXXXXXXXXXXXXXXXX..............................
+
+maymv 1 fixed 1 newsz 21 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 1 newsz 21 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D dst)
+XXXXXXXXX...............................XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+XXXXXXXXXXXXXXXXXXXXX.............................
+
+maymv 1 fixed 1 newsz 29 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 1 newsz 29 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D dst)
+XXXXXXXXX...............................XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.....................
+
+maymv 1 fixed 1 newsz 30 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 1 newsz 30 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D dst)
+XXXXXXXXX...............................XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX....................
+
+maymv 1 fixed 1 newsz 31 dstpo 0 dst 0x........ -> error 22
+XXXXXXXXX.XXXXXXXXXXXXXXXXXXXX..........XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+..................................................
+
+maymv 1 fixed 1 newsz 31 dstpo 1 dst 0x........ -> 0x........ (=3D=
=3D dst)
+XXXXXXXXX...............................XXXXXXXXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+..................................................
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...................
+
Added: branches/ASPACEM/none/tests/mremap2.vgtest
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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.vgtest 2005-09-18 08:34:38 UTC (r=
ev 4673)
+++ branches/ASPACEM/none/tests/mremap2.vgtest 2005-09-18 09:03:56 UTC (r=
ev 4674)
@@ -0,0 +1,2 @@
+prog: mremap2
+stdout_filter: ../../tests/filter_addresses
|
|
From: <sv...@va...> - 2005-09-18 08:34:45
|
Author: sewardj
Date: 2005-09-18 09:34:38 +0100 (Sun, 18 Sep 2005)
New Revision: 4673
Log:
Fix another mremap bug.
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.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-18 00:25:3=
3 UTC (rev 4672)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-18 08:34:3=
8 UTC (rev 4673)
@@ -1549,7 +1549,7 @@
__NR_mremap,=20
old_addr, old_len, new_len,=20
VKI_MREMAP_MAYMOVE|VKI_MREMAP_FIXED/*move-or-fail*/,
- 0/*new_addr*/
+ new_addr
);
}
=20
@@ -3292,8 +3292,8 @@
sres =3D do_relocate_nooverlap_mapping_NO_NOTIFY( old_addr, old_len,=20
new_addr, new_len );
if (sres.isError) {
+ AM_SANITY_CHECK;
return False;
- AM_SANITY_CHECK;
}
=20
oldseg =3D nsegments[iLo];
|
|
From: <js...@ac...> - 2005-09-18 02:56:43
|
Nightly build on phoenix ( SuSE 9.1 ) started at 2005-09-18 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: <js...@ac...> - 2005-09-18 02:45:04
|
Nightly build on g5 ( YDL 4.0, ppc970 ) started at 2005-09-18 04:40:00 CEST 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 == 158 tests, 17 stderr failures, 1 stdout failure ================= memcheck/tests/badjump (stderr) memcheck/tests/badjump2 (stderr) memcheck/tests/fprw (stderr) memcheck/tests/leak-cycle (stderr) memcheck/tests/leak-tree (stderr) memcheck/tests/partiallydefinedeq (stderr) memcheck/tests/sigaltstack (stderr) memcheck/tests/supp1 (stderr) memcheck/tests/supp_unknown (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) cachegrind/tests/chdir (stderr) cachegrind/tests/dlclose (stdout) cachegrind/tests/dlclose (stderr) none/tests/faultstatus (stderr) none/tests/fdleak_cmsg (stderr) none/tests/fdleak_ipv4 (stderr) |
|
From: Tom H. <to...@co...> - 2005-09-18 02:41:15
|
Nightly build on dunsmere ( athlon, Fedora Core 4 ) started at 2005-09-18 03:30:05 BST Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 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-18 02:28:36
|
Nightly build on alvis ( i686, Red Hat 7.3 ) started at 2005-09-18 03:15:05 BST Results differ 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, 1 stdout failure ================= 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) none/tests/x86/yield (stdout) ================================================= == Results 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) ================================================= == Difference between 24 hours ago and now == ================================================= *** old.short Sun Sep 18 03:22:05 2005 --- new.short Sun Sep 18 03:28:32 2005 *************** *** 8,10 **** ! == 186 tests, 14 stderr failures, 0 stdout failures ================= memcheck/tests/addressable (stderr) --- 8,10 ---- ! == 186 tests, 14 stderr failures, 1 stdout failure ================= memcheck/tests/addressable (stderr) *************** *** 23,24 **** --- 23,25 ---- none/tests/x86/int (stderr) + none/tests/x86/yield (stdout) |
|
From: Tom H. <th...@cy...> - 2005-09-18 02:25:35
|
Nightly build on ginetta ( i686, Red Hat 8.0 ) started at 2005-09-18 03:10:06 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-18 02:21:01
|
Nightly build on dellow ( x86_64, Fedora Core 4 ) started at 2005-09-18 03:10:06 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-18 02:18:22
|
Nightly build on aston ( x86_64, Fedora Core 3 ) started at 2005-09-18 03:05:05 BST Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 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-18 02:13:04
|
Nightly build on gill ( x86_64, Fedora Core 2 ) started at 2005-09-18 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) |
|
From: <sv...@va...> - 2005-09-18 00:25:37
|
Author: sewardj
Date: 2005-09-18 01:25:33 +0100 (Sun, 18 Sep 2005)
New Revision: 4672
Log:
Add a sanity checker which can check Valgrind's segment array against
what the kernel believes is going on, by rereading /proc/self/maps at
any time.
Use this to find and fix a bug in VG_(am_extend_map_client).
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.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-17 01:50:1=
5 UTC (rev 4671)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-18 00:25:3=
3 UTC (rev 4672)
@@ -41,6 +41,9 @@
#include "pub_core_syscall.h"
#include "pub_core_tooliface.h"
#include "pub_core_transtab.h" // For VG_(discard_translations)
+
+#include "pub_core_options.h" // VG_(clo_sanity_level)
+
#include "vki_unistd.h"
=20
static void aspacem_barf ( HChar* what );
@@ -1386,6 +1389,14 @@
static Addr aspacem_vStart =3D 0;
=20
=20
+#define AM_SANITY_CHECK \
+ do { \
+ if (VG_(clo_sanity_level > 1)) \
+ aspacem_assert(do_sync_check(__PRETTY_FUNCTION__, \
+ __FILE__,__LINE__)); \
+ } while (0)=20
+
+
/*-----------------------------------------------------------------*/
/*--- ---*/
/*--- Stuff to make aspacem almost completely independent of ---*/
@@ -1424,11 +1435,11 @@
VG_(exit)(1);
}
=20
-#define aspacem_assert(expr) \
- ((void) ((expr) ? 0 : \
- (aspacem_assert_fail(#expr, \
- __FILE__, __LINE__, \
- __PRETTY_FUNCTION__))))
+#define aspacem_assert(expr) \
+ ((void) ((expr) ? 0 : \
+ (aspacem_assert_fail(#expr, \
+ __FILE__, __LINE__, \
+ __PRETTY_FUNCTION__))))
=20
=20
//--------------------------------------------------------------
@@ -1881,6 +1892,90 @@
}
=20
=20
+/* Check the segment array corresponds with the kernel's view of
+ memory layout. sync_check_ok returns True if no anomalies were
+ found, else False. In the latter case the mismatching segments are
+ displayed. */
+
+static Int sync_check_i =3D 0;
+static Bool sync_check_ok =3D False;
+
+static void sync_check_callback ( Addr addr, SizeT len, UInt prot,
+ UInt dev, UInt ino, ULong offset,=20
+ const UChar* filename )
+{
+ Bool same;
+
+ /* If a problem has already been detected, don't continue comparing
+ segments, so as to avoid flooding the output with error
+ messages. */
+ if (!sync_check_ok)
+ return;
+
+ /* Advance sync_check_i to the first possible nsegment entry which
+ could map the kernel's offering. It will have been left at the
+ previous match. We are prepared to skip any sequence of free
+ and reservation segments, but everything else must match the
+ kernel's segments. */
+ sync_check_i++;
+
+ while (sync_check_i < nsegments_used
+ && (nsegments[sync_check_i].kind =3D=3D SkFree
+ || nsegments[sync_check_i].kind =3D=3D SkResvn))
+ sync_check_i++;
+
+ aspacem_assert(sync_check_i >=3D 0 && sync_check_i <=3D nsegments_use=
d);
+
+ if (sync_check_i =3D=3D nsegments_used) {
+ sync_check_ok =3D False;
+ VG_(debugLog)(0,"aspacem","sync_check_callback: out of segments\n"=
);
+ goto show_kern_seg;
+ }
+
+ /* compare the kernel's offering against ours. */
+ same =3D nsegments[sync_check_i].start =3D=3D addr
+ && nsegments[sync_check_i].end =3D=3D addr+len-1
+ && nsegments[sync_check_i].dev =3D=3D dev
+ && nsegments[sync_check_i].ino =3D=3D ino
+ && nsegments[sync_check_i].offset =3D=3D offset;
+ if (!same) {
+ sync_check_ok =3D False;
+ VG_(debugLog)(0,"aspacem",
+ "sync_check_callback: segment mismatch: V's seg:\n=
");
+ show_nsegment_full( 0, &nsegments[sync_check_i] );
+ goto show_kern_seg;
+ }
+
+ /* Looks harmless. Keep going. */
+ return;
+
+ show_kern_seg:
+ VG_(debugLog)(0,"aspacem",
+ "sync_check_callback: segment mismatch: kernel's seg:=
\n");
+ VG_(debugLog)(0,"aspacem",=20
+ "start=3D0x%llx end=3D0x%llx dev=3D%u ino=3D%u offset=
=3D%lld\n",
+ (ULong)addr, ((ULong)addr) + ((ULong)len) - 1,
+ dev, ino, offset );
+ return;
+}
+
+static Bool do_sync_check ( HChar* fn, HChar* file, Int line )
+{
+ sync_check_i =3D -1;
+ sync_check_ok =3D True;
+ if (0)
+ VG_(debugLog)(0,"aspacem", "do_sync_check %s:%d\n", file,line);
+ VG_(parse_procselfmaps)( sync_check_callback );
+ if (!sync_check_ok) {
+ VG_(debugLog)(0,"aspacem",=20
+ "sync check at %s:%d (%s): FAILED\n",
+ file, line, fn);
+ VG_(debugLog)(0,"aspacem", "\n");
+ }
+ return sync_check_ok;
+}
+
+
/*-----------------------------------------------------------------*/
/*--- ---*/
/*--- Low level access / modification of the segment array. ---*/
@@ -2321,6 +2416,7 @@
=20
VG_(am_show_nsegments)(2, "With contents of /proc/self/maps");
=20
+ AM_SANITY_CHECK;
return suggested_clstack_top;
}
=20
@@ -2484,6 +2580,8 @@
if (floatIdx >=3D 0)=20
aspacem_assert(nsegments[floatIdx].kind =3D=3D SkFree);
=20
+ AM_SANITY_CHECK;
+
/* Now see if we found anything which can satisfy the request. */
switch (req->rkind) {
case MFixed:
@@ -2571,6 +2669,7 @@
}
}
add_segment( &seg );
+ AM_SANITY_CHECK;
}
=20
/* Notifies aspacem that an mprotect was completed successfully. The
@@ -2618,6 +2717,7 @@
/* Changing permissions could have made previously un-mergable
segments mergeable. Therefore have to re-preen them. */
(void)preen_nsegments();
+ AM_SANITY_CHECK;
}
=20
=20
@@ -2644,6 +2744,7 @@
=20
/* Unmapping could create two adjacent free segments, so a preen is
needed. add_segment() will do that, so no need to here. */
+ AM_SANITY_CHECK;
}
=20
=20
@@ -2719,6 +2820,7 @@
}
add_segment( &seg );
=20
+ AM_SANITY_CHECK;
return sres;
}
=20
@@ -2775,6 +2877,7 @@
seg.hasX =3D toBool(prot & VKI_PROT_EXEC);
add_segment( &seg );
=20
+ AM_SANITY_CHECK;
return sres;
}
=20
@@ -2831,6 +2934,7 @@
seg.hasX =3D toBool(prot & VKI_PROT_EXEC);
add_segment( &seg );
=20
+ AM_SANITY_CHECK;
return sres;
}
=20
@@ -2889,6 +2993,7 @@
seg.hasX =3D True;
add_segment( &seg );
=20
+ AM_SANITY_CHECK;
return sres;
}
=20
@@ -2923,6 +3028,7 @@
return sres;
=20
VG_(am_notify_munmap)( start, len );
+ AM_SANITY_CHECK;
return sres;
=20
eINVAL:
@@ -2987,6 +3093,8 @@
seg.end =3D end1;
seg.smode =3D smode;
add_segment( &seg );
+
+ AM_SANITY_CHECK;
return True;
}
=20
@@ -3091,6 +3199,7 @@
=20
}
=20
+ AM_SANITY_CHECK;
return True;
}
=20
@@ -3107,7 +3216,8 @@
{
Addr xStart;
SysRes sres;
- NSegment seg_copy;
+ NSegment seg_copy =3D *seg;
+ SizeT seg_old_len =3D seg->end + 1 - seg->start;
=20
if (seg->kind !=3D SkFileC && seg->kind !=3D SkAnonC)
return False;
@@ -3123,14 +3233,19 @@
VKI_PROT_NONE ))
return False;
=20
- sres =3D do_extend_mapping_NO_NOTIFY( seg->start, seg->end+1-seg->sta=
rt,
- delta );
- if (sres.isError)
+ AM_SANITY_CHECK;
+ sres =3D do_extend_mapping_NO_NOTIFY( seg->start,=20
+ seg_old_len,
+ seg_old_len + delta );
+ if (sres.isError) {
+ AM_SANITY_CHECK;
return False;
+ }
=20
- seg_copy =3D *seg;
seg_copy.end +=3D delta;
add_segment( &seg_copy );
+
+ AM_SANITY_CHECK;
return True;
}
=20
@@ -3176,8 +3291,10 @@
=20
sres =3D do_relocate_nooverlap_mapping_NO_NOTIFY( old_addr, old_len,=20
new_addr, new_len );
- if (sres.isError)
+ if (sres.isError) {
return False;
+ AM_SANITY_CHECK;
+ }
=20
oldseg =3D nsegments[iLo];
=20
@@ -3194,6 +3311,7 @@
oldseg.end =3D new_addr + new_len - 1;
add_segment( &seg );
=20
+ AM_SANITY_CHECK;
return True;
}
=20
@@ -3265,12 +3383,14 @@
=20
VG_(debugLog)( 1,"aspacem","allocated thread stack at 0x%llx size %d\=
n",
(ULong)(Addr)stack, szB);
+ AM_SANITY_CHECK;
return stack;
=20
protect_failed:
/* The stack was allocated, but we can't protect it. Unmap it and
return NULL (failure). */
(void)do_munmap_NO_NOTIFY( (Addr)stack, szB );
+ AM_SANITY_CHECK;
return NULL;
}
=20
|