|
From: <sv...@va...> - 2005-06-24 22:17:48
|
Author: njn
Date: 2005-06-24 23:17:38 +0100 (Fri, 24 Jun 2005)
New Revision: 4015
Log:
Moved the mman VG_(*_native)() functions into m_aspacemgr, and removed
the unused init_shadow_page() function. As a result, m_aspacemgr no long=
er
depends on m_libcmman, breaking a circular module dependency, good!
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr.c
trunk/coregrind/m_libcmman.c
trunk/coregrind/m_signals.c
trunk/coregrind/m_tooliface.c
trunk/coregrind/pub_core_aspacemgr.h
trunk/coregrind/pub_core_libcmman.h
trunk/coregrind/pub_core_tooliface.h
trunk/include/pub_tool_aspacemgr.h
trunk/include/pub_tool_tooliface.h
Modified: trunk/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
--- trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-06-24 21:41:28 UTC (rev =
4014)
+++ trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-06-24 22:17:38 UTC (rev =
4015)
@@ -36,7 +36,6 @@
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcfile.h" // For VG_(fstat), VG_(resolve_filename=
_nodup)
-#include "pub_core_libcmman.h"
#include "pub_core_libcprint.h"
#include "pub_core_syscall.h"
#include "pub_core_tooliface.h"
@@ -74,6 +73,47 @@
Addr VG_(valgrind_last);
=20
/*--------------------------------------------------------------*/
+/*--- The raw mman syscalls ---*/
+/*--------------------------------------------------------------*/
+
+SysRes VG_(mmap_native)(void *start, SizeT length, UInt prot, UInt flags=
,
+ UInt fd, OffT offset)
+{
+ SysRes res;
+#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)
+{
+ return VG_(do_syscall2)(__NR_munmap, (UWord)start, length );
+}
+
+SysRes VG_(mprotect_native)( void *start, SizeT length, UInt prot )
+{
+ return VG_(do_syscall3)(__NR_mprotect, (UWord)start, length, prot );
+}
+
+/*--------------------------------------------------------------*/
/*--- A simple, self-contained ordered array of segments. ---*/
/*--------------------------------------------------------------*/
=20
@@ -1021,6 +1061,7 @@
=20
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;
@@ -1153,30 +1194,6 @@
/*--- Handling shadow memory ---*/
/*--------------------------------------------------------------------*/
=20
-void VG_(init_shadow_range)(Addr p, UInt sz, Bool call_init)
-{
-vg_assert(0);
- if (0)
- VG_(printf)("init_shadow_range(%p, %d)\n", p, sz);
-
- vg_assert(VG_(needs).shadow_memory);
- vg_assert(VG_(tdict).track_init_shadow_page);
-
- sz =3D VG_PGROUNDUP(p+sz) - VG_PGROUNDDN(p);
- p =3D VG_PGROUNDDN(p);
-
- VG_(mprotect)((void *)p, sz, VKI_PROT_READ|VKI_PROT_WRITE);
- =20
- if (call_init)=20
- while(sz) {
- /* ask the tool to initialize each page */
- VG_TRACK( init_shadow_page, VG_PGROUNDDN(p) );
- =20
- p +=3D VKI_PAGE_SIZE;
- sz -=3D VKI_PAGE_SIZE;
- }
-}
-
void *VG_(shadow_alloc)(UInt size)
{
static Addr shadow_alloc =3D 0;
@@ -1186,7 +1203,6 @@
if (0) show_segments("shadow_alloc(before)");
=20
vg_assert(VG_(needs).shadow_memory);
- vg_assert(!VG_(tdict).track_init_shadow_page);
=20
size =3D VG_PGROUNDUP(size);
=20
Modified: trunk/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
--- trunk/coregrind/m_libcmman.c 2005-06-24 21:41:28 UTC (rev 4014)
+++ trunk/coregrind/m_libcmman.c 2005-06-24 22:17:38 UTC (rev 4015)
@@ -38,33 +38,6 @@
#include "pub_core_syscall.h"
#include "vki_unistd.h"
=20
-SysRes VG_(mmap_native)(void *start, SizeT length, UInt prot, UInt flags=
,
- UInt fd, OffT offset)
-{
- SysRes res;
-#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;
-}
-
/* Returns -1 on failure. */
void* VG_(mmap)( void* start, SizeT length,
UInt prot, UInt flags, UInt sf_flags, UInt fd, OffT off=
set)
@@ -106,11 +79,6 @@
return res.isError ? (void*)-1 : (void*)res.val;
}
=20
-SysRes VG_(munmap_native)(void *start, SizeT length)
-{
- return VG_(do_syscall2)(__NR_munmap, (UWord)start, length );
-}
-
/* Returns -1 on failure. */
Int VG_(munmap)( void* start, SizeT length )
{
@@ -123,11 +91,6 @@
}
}
=20
-SysRes VG_(mprotect_native)( void *start, SizeT length, UInt prot )
-{
- return VG_(do_syscall3)(__NR_mprotect, (UWord)start, length, prot );
-}
-
Int VG_(mprotect)( void *start, SizeT length, UInt prot )
{
SysRes res =3D VG_(mprotect_native)(start, length, prot);
Modified: trunk/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
--- trunk/coregrind/m_signals.c 2005-06-24 21:41:28 UTC (rev 4014)
+++ trunk/coregrind/m_signals.c 2005-06-24 22:17:38 UTC (rev 4015)
@@ -1885,28 +1885,8 @@
} else
VG_(message)(Vg_UserMsg, "Stack overflow in thread %d: can't grow s=
tack to %p",=20
tid, fault);
-
- /* Fall into normal signal handling for all other cases */
- } else if (info->si_code =3D=3D 2 && /* SEGV_ACCERR */
- VG_(needs).shadow_memory &&
- VG_(is_shadow_addr)(fault)) {
- /* If there's a fault within the shadow memory range, and it
- is a permissions fault, then it means that the client is
- using some memory which had not previously been used.
- This catches those faults, makes the memory accessible,
- and calls the tool to initialize that page.
- */
- static Int recursion =3D 0;
-
- if (recursion++ =3D=3D 0) {
- VG_(init_shadow_range)(VG_PGROUNDDN(fault), VKI_PAGE_SIZE, True);
- recursion--;
- return;
- } else {
- /* otherwise fall into normal SEGV handling */ =20
- recursion--;
- }
}
+ /* Fall into normal signal handling for all other cases */
}
=20
/* OK, this is a signal we really have to deal with. If it came
Modified: trunk/coregrind/m_tooliface.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
--- trunk/coregrind/m_tooliface.c 2005-06-24 21:41:28 UTC (rev 4014)
+++ trunk/coregrind/m_tooliface.c 2005-06-24 22:17:38 UTC (rev 4015)
@@ -322,8 +322,6 @@
DEF(track_pre_deliver_signal, ThreadId, Int sigNo, Bool)
DEF(track_post_deliver_signal, ThreadId, Int sigNo)
=20
-DEF(track_init_shadow_page, Addr)
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: trunk/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
--- trunk/coregrind/pub_core_aspacemgr.h 2005-06-24 21:41:28 UTC (rev 401=
4)
+++ trunk/coregrind/pub_core_aspacemgr.h 2005-06-24 22:17:38 UTC (rev 401=
5)
@@ -59,6 +59,12 @@
extern Addr VG_(valgrind_base); // valgrind's address range
extern Addr VG_(valgrind_last); // Nb: last byte, rather than one past =
the end
=20
+// Direct access to these system calls.
+extern SysRes VG_(mmap_native) ( void* start, SizeT length, UInt pro=
t,
+ UInt flags, UInt fd, OffT offset );
+extern SysRes VG_(munmap_native) ( void* start, SizeT length );
+extern SysRes VG_(mprotect_native) ( void *start, SizeT length, UInt pro=
t );
+
/* A Segment is mapped piece of client memory. This covers all kinds
of mapped memory (exe, brk, mmap, .so, shm, stack, etc)
=20
Modified: trunk/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
--- trunk/coregrind/pub_core_libcmman.h 2005-06-24 21:41:28 UTC (rev 4014=
)
+++ trunk/coregrind/pub_core_libcmman.h 2005-06-24 22:17:38 UTC (rev 4015=
)
@@ -43,11 +43,6 @@
extern Int VG_(munmap) ( void* start, SizeT length );
extern Int VG_(mprotect) ( void *start, SizeT length, UInt prot );
=20
-extern SysRes VG_(mmap_native) ( void* start, SizeT length, UInt pro=
t,
- UInt flags, UInt fd, OffT offset );
-extern SysRes VG_(munmap_native) ( void* start, SizeT length );
-extern SysRes VG_(mprotect_native) ( void *start, SizeT length, UInt pro=
t );
-
extern Addr VG_(get_memory_from_mmap_for_client)
(Addr base, SizeT len, UInt prot, UInt flags);
=20
Modified: trunk/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
--- trunk/coregrind/pub_core_tooliface.h 2005-06-24 21:41:28 UTC (rev 401=
4)
+++ trunk/coregrind/pub_core_tooliface.h 2005-06-24 22:17:38 UTC (rev 401=
5)
@@ -201,8 +201,6 @@
void (*track_pre_deliver_signal) (ThreadId, Int sigNo, Bool);
void (*track_post_deliver_signal)(ThreadId, Int sigNo);
=20
- void (*track_init_shadow_page)(Addr);
-
} VgToolInterface;
=20
extern VgToolInterface VG_(tdict);
Modified: trunk/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
--- trunk/include/pub_tool_aspacemgr.h 2005-06-24 21:41:28 UTC (rev 4014)
+++ trunk/include/pub_tool_aspacemgr.h 2005-06-24 22:17:38 UTC (rev 4015)
@@ -39,12 +39,6 @@
=20
extern Bool VG_(is_addressable)(Addr p, SizeT sz, UInt prot);
=20
-/* initialize shadow pages in the range [p, p+sz) This calls
- init_shadow_page for each one. It should be a lot more efficient
- for bulk-initializing shadow pages than faulting on each one.=20
-*/
-extern void VG_(init_shadow_range)(Addr p, UInt sz, Bool call_init);
-
/* Calls into the core used by leak-checking */
=20
/* Calls "add_rootrange" with each range of memory which looks like a
Modified: trunk/include/pub_tool_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
--- trunk/include/pub_tool_tooliface.h 2005-06-24 21:41:28 UTC (rev 4014)
+++ trunk/include/pub_tool_tooliface.h 2005-06-24 22:17:38 UTC (rev 4015)
@@ -398,9 +398,7 @@
=20
/* Others... condition variables...
...
- Shadow memory management
*/
-void VG_(track_init_shadow_page)(void(*f)(Addr p));
=20
#endif // __PUB_TOOL_TOOLIFACE_H
=20
|