mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-04 02:18:37 +00:00
Make sure the debug information is read before a tool is notified about an mmap() system call.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8142
This commit is contained in:
parent
1d9c8f92d5
commit
7fbbba6ae4
@ -59,6 +59,15 @@
|
||||
#include "priv_syswrap-generic.h"
|
||||
|
||||
|
||||
/* Local function declarations. */
|
||||
|
||||
static
|
||||
void notify_aspacem_of_mmap(Addr a, SizeT len, UInt prot,
|
||||
UInt flags, Int fd, Off64T offset);
|
||||
static
|
||||
void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, Off64T offset);
|
||||
|
||||
|
||||
/* 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 or a reservation. */
|
||||
@ -147,7 +156,15 @@ void
|
||||
ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
|
||||
UInt flags, Int fd, Off64T offset )
|
||||
{
|
||||
Bool rr, ww, xx, d;
|
||||
notify_aspacem_of_mmap(a, len, prot, flags, fd, offset);
|
||||
notify_tool_of_mmap(a, len, prot, offset);
|
||||
}
|
||||
|
||||
static
|
||||
void 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));
|
||||
@ -156,15 +173,26 @@ ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
|
||||
|
||||
d = VG_(am_notify_client_mmap)( a, len, prot, flags, fd, offset );
|
||||
|
||||
if (d)
|
||||
VG_(discard_translations)( (Addr64)a, (ULong)len,
|
||||
"ML_(notify_aspacem_of_mmap)" );
|
||||
}
|
||||
|
||||
static
|
||||
void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, 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,15 +1937,24 @@ ML_(generic_PRE_sys_mmap) ( ThreadId tid,
|
||||
}
|
||||
|
||||
if (!sres.isError) {
|
||||
/* Notify aspacem and the tool. */
|
||||
ML_(notify_aspacem_and_tool_of_mmap)(
|
||||
/* Notify aspacem. */
|
||||
notify_aspacem_of_mmap(
|
||||
(Addr)sres.res, /* addr kernel actually assigned */
|
||||
arg2, arg3,
|
||||
arg2, /* length */
|
||||
arg3, /* prot */
|
||||
arg4, /* the original flags value */
|
||||
arg5, arg6
|
||||
arg5, /* fd */
|
||||
arg6 /* offset */
|
||||
);
|
||||
/* Load symbols? */
|
||||
VG_(di_notify_mmap)( (Addr)sres.res, False/*allow_SkFileV*/ );
|
||||
/* Notify the tool. */
|
||||
notify_tool_of_mmap(
|
||||
(Addr)sres.res, /* addr kernel actually assigned */
|
||||
arg2, /* length */
|
||||
arg3, /* prot */
|
||||
arg6 /* offset */
|
||||
);
|
||||
}
|
||||
|
||||
/* Stay sane */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user