|
From: <sv...@va...> - 2008-05-20 10:16:42
|
Author: bart
Date: 2008-05-20 11:16:34 +0100 (Tue, 20 May 2008)
New Revision: 8108
Log:
Only notify a tool about mmap() after the debug information for the mapped file has been read.
Modified:
branches/CROSS_COMPILATION/coregrind/m_syswrap/priv_syswrap-generic.h
branches/CROSS_COMPILATION/coregrind/m_syswrap/syswrap-generic.c
Modified: branches/CROSS_COMPILATION/coregrind/m_syswrap/priv_syswrap-generic.h
===================================================================
--- branches/CROSS_COMPILATION/coregrind/m_syswrap/priv_syswrap-generic.h 2008-05-19 07:53:20 UTC (rev 8107)
+++ branches/CROSS_COMPILATION/coregrind/m_syswrap/priv_syswrap-generic.h 2008-05-20 10:16:34 UTC (rev 8108)
@@ -64,10 +64,16 @@
/* So that it can be seen from syswrap-x86-linux.c. */
/* When a client mmap has been successfully done, both aspacem and the
tool need to be notified of the new mapping. Hence this fn. */
-extern
+extern
void
ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
UInt mm_flags, Int fd, ULong offset );
+void
+ML_(notify_aspacem_of_mmap) ( Addr a, SizeT len, UInt prot,
+ UInt mm_flags, Int fd, ULong offset );
+void
+ML_(notify_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
+ UInt mm_flags, Int fd, ULong offset );
DECL_TEMPLATE(generic, sys_ni_syscall); // * P -- unimplemented
Modified: branches/CROSS_COMPILATION/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- branches/CROSS_COMPILATION/coregrind/m_syswrap/syswrap-generic.c 2008-05-19 07:53:20 UTC (rev 8107)
+++ branches/CROSS_COMPILATION/coregrind/m_syswrap/syswrap-generic.c 2008-05-20 10:16:34 UTC (rev 8108)
@@ -147,8 +147,16 @@
ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
UInt flags, Int fd, Off64T offset )
{
- Bool rr, ww, xx, d;
+ ML_(notify_aspacem_of_mmap)(a, len, prot, flags, fd, offset);
+ ML_(notify_tool_of_mmap)(a, len, prot, flags, fd, offset);
+}
+void
+ML_(notify_aspacem_of_mmap) ( Addr a, SizeT len, UInt prot,
+ UInt flags, Int fd, Off64T offset )
+{
+ Bool d;
+
/* 'a' is the return value from a real kernel mmap, hence: */
vg_assert(VG_IS_PAGE_ALIGNED(a));
/* whereas len is whatever the syscall supplied. So: */
@@ -156,15 +164,27 @@
d = VG_(am_notify_client_mmap)( a, len, prot, flags, fd, offset );
+ if (d)
+ VG_(discard_translations)( (Addr64)a, (ULong)len,
+ "ML_(notify_aspacem_and_tool_of_mmap)" );
+}
+
+void
+ML_(notify_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
+ UInt flags, Int fd, Off64T offset )
+{
+ Bool rr, ww, xx;
+
+ /* 'a' is the return value from a real kernel mmap, hence: */
+ vg_assert(VG_IS_PAGE_ALIGNED(a));
+ /* whereas len is whatever the syscall supplied. So: */
+ len = VG_PGROUNDUP(len);
+
rr = toBool(prot & VKI_PROT_READ);
ww = toBool(prot & VKI_PROT_WRITE);
xx = toBool(prot & VKI_PROT_EXEC);
VG_TRACK( new_mem_mmap, a, len, rr, ww, xx );
-
- if (d)
- VG_(discard_translations)( (Addr64)a, (ULong)len,
- "ML_(notify_aspacem_and_tool_of_mmap)" );
}
/* Expand (or shrink) an existing mapping, potentially moving it at
@@ -1909,8 +1929,8 @@
}
if (!sres.isError) {
- /* Notify aspacem and the tool. */
- ML_(notify_aspacem_and_tool_of_mmap)(
+ /* Notify aspacem. */
+ ML_(notify_aspacem_of_mmap)(
(Addr)sres.res, /* addr kernel actually assigned */
arg2, arg3,
arg4, /* the original flags value */
@@ -1918,6 +1938,13 @@
);
/* Load symbols? */
VG_(di_notify_mmap)( (Addr)sres.res, False/*allow_SkFileV*/ );
+ /* Notify the tool. */
+ ML_(notify_tool_of_mmap)(
+ (Addr)sres.res, /* addr kernel actually assigned */
+ arg2, arg3,
+ arg4, /* the original flags value */
+ arg5, arg6
+ );
}
/* Stay sane */
|