|
From: <sv...@va...> - 2005-09-15 08:58:58
|
Author: sewardj
Date: 2005-09-15 09:58:53 +0100 (Thu, 15 Sep 2005)
New Revision: 4665
Log:
Make the meaning of ML_(valid_client_addr) more closely match what it
did before -- free space is allowable too.
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c
branches/ASPACEM/coregrind/pub_core_aspacemgr.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-15 07:40:2=
0 UTC (rev 4664)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-15 08:58:5=
3 UTC (rev 4665)
@@ -1956,9 +1956,10 @@
=20
/* Test if a piece of memory is addressable by the client with at
least the "prot" protection permissions by examining the underlying
- segments.
+ segments. If freeOk is True then SkFree areas are also allowed.
*/
-Bool VG_(am_is_valid_for_client)( Addr start, SizeT len, UInt prot )
+static
+Bool is_valid_for_client( Addr start, SizeT len, UInt prot, Bool freeOk =
)
{
Int i, iLo, iHi;
Bool needR, needW, needX;
@@ -1975,10 +1976,13 @@
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 SkFileC || nsegments[i].kind =3D=3D =
SkAnonC)
- && (needR ? nsegments[i].hasR : True)
- && (needW ? nsegments[i].hasW : True)
- && (needX ? nsegments[i].hasX : True)) {
+ if ( (nsegments[i].kind =3D=3D SkFileC=20
+ || nsegments[i].kind =3D=3D SkAnonC
+ || (nsegments[i].kind =3D=3D SkFree && freeOk)
+ || (nsegments[i].kind =3D=3D SkResvn && freeOk))
+ && (needR ? nsegments[i].hasR : True)
+ && (needW ? nsegments[i].hasW : True)
+ && (needX ? nsegments[i].hasX : True) ) {
/* ok */
} else {
return False;
@@ -1987,7 +1991,25 @@
return True;
}
=20
+/* Test if a piece of memory is addressable by the client with at
+ least the "prot" protection permissions by examining the underlying
+ segments. */
+Bool VG_(am_is_valid_for_client)( Addr start, SizeT len,=20
+ UInt prot )
+{
+ return is_valid_for_client( start, len, prot, False/*free not OK*/ );
+}
=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
+ considers reservations to be allowable, since from the client's
+ point of view they don't exist. */
+Bool VG_(am_is_free_or_valid_for_client)( Addr start, SizeT len,=20
+ UInt prot )
+{
+ return is_valid_for_client( start, len, prot, True/*free is OK*/ );
+}
+
/*-----------------------------------------------------------------*/
/*--- ---*/
/*--- Modifying the segment array, and constructing segments. ---*/
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-15 07:=
40:20 UTC (rev 4664)
+++ branches/ASPACEM/coregrind/m_syswrap/syswrap-generic.c 2005-09-15 08:=
58:53 UTC (rev 4665)
@@ -57,32 +57,28 @@
#include "vki_unistd.h" /* for the __NR_* constants */
=20
=20
-/* return true if address range entirely contained within client
- address space */
+/* Returns True iff address range is something the client can
+ plausibly mess with: all of it is either already belongs to the
+ client or is free. */
+
Bool ML_(valid_client_addr)(Addr start, SizeT size, ThreadId tid,
const Char *syscallname)
{
- Addr end =3D start+size;
- Addr cl_base =3D VG_(client_base);
Bool ret;
=20
if (size =3D=3D 0)
return True;
=20
- if (0 && cl_base < 0x10000)
- cl_base =3D 0x10000;
+ ret =3D VG_(am_is_free_or_valid_for_client)(start,size,VKI_PROT_NONE)=
;
=20
- ret =3D VG_(am_is_valid_for_client)(start,size,VKI_PROT_NONE);
-
if (0)
- VG_(printf)("%s: test=3D%p-%p client=3D%p-%p ret=3D%d\n",
- syscallname, start, end, cl_base, VG_(client_end), (Int)ret);
+ VG_(printf)("%s: test=3D%p-%p ret=3D%d\n",
+ syscallname, start, start+size-1, (Int)ret);
=20
if (!ret && syscallname !=3D NULL) {
VG_(message)(Vg_UserMsg, "Warning: client syscall %s tried "
"to modify addresses %p-%p",
- syscallname, start, end);
-
+ syscallname, start, start+size-1);
if (VG_(clo_verbosity) > 1) {
VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
}
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-15 07:40:20 U=
TC (rev 4664)
+++ branches/ASPACEM/coregrind/pub_core_aspacemgr.h 2005-09-15 08:58:53 U=
TC (rev 4665)
@@ -266,6 +266,13 @@
extern Bool VG_(am_is_valid_for_client)( Addr start, SizeT len,=20
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
+ considers reservations to be allowable, since from the client's
+ point of view they don't exist. */
+extern Bool VG_(am_is_free_or_valid_for_client)( Addr start, SizeT len,=20
+ UInt prot );
+
/* Trivial fn: return the total amount of space in anonymous mappings,
both for V and the client. Is used for printing stats in
out-of-memory messages. */
|