Author: florian
Date: Tue May 12 19:22:17 2015
New Revision: 15218
Log:
Give VG_(am_addr_is_in_extensible_client_stack) an additional
parameter that allows to select whether mapped and/or unmapped
addresses should be considered.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
branches/ASPACEM_TWEAKS/coregrind/m_sigframe/sigframe-common.c
branches/ASPACEM_TWEAKS/coregrind/m_signals.c
branches/ASPACEM_TWEAKS/coregrind/m_syswrap/syswrap-generic.c
branches/ASPACEM_TWEAKS/coregrind/m_syswrap/syswrap-main.c
branches/ASPACEM_TWEAKS/coregrind/pub_core_aspacemgr.h
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c Tue May 12 19:22:17 2015
@@ -1271,8 +1271,13 @@
extensible client stack segment. Return true if
(1) ADDR is located in an already mapped stack segment, OR
(2) ADDR is located in a reservation segment into which an abutting SkAnonC
- segment can be extended. */
-Bool VG_(am_addr_is_in_extensible_client_stack)( Addr addr )
+ segment can be extended.
+ The KIND parameter tells what kind of ADDR is allowed:
+ 'M' ADDR must be mapped
+ 'U' ADDR must be unmapped
+ '*' ADDR can be mapped or unmapped
+*/
+Bool VG_(am_addr_is_in_extensible_client_stack)( Addr addr, HChar kind )
{
const NSegment *seg = nsegments + find_nsegment_idx(addr);
@@ -1285,6 +1290,7 @@
return False;
case SkResvn: {
+ if (kind == 'M') return False;
if (seg->smode != SmUpper) return False;
/* If the the abutting segment towards higher addresses is an SkAnonC
segment, then ADDR is a future stack pointer. */
@@ -1298,6 +1304,7 @@
case SkAnonC: {
/* If the abutting segment towards lower addresses is an SkResvn
segment, then ADDR is a stack pointer into mapped memory. */
+ if (kind == 'U') return False;
const NSegment *next = VG_(am_next_nsegment)(seg, /*forward*/ False);
if (next == NULL || next->kind != SkResvn || next->smode != SmUpper)
return False;
Modified: branches/ASPACEM_TWEAKS/coregrind/m_sigframe/sigframe-common.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_sigframe/sigframe-common.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_sigframe/sigframe-common.c Tue May 12 19:22:17 2015
@@ -64,7 +64,7 @@
/* If the sigframe is allocated on an alternate stack, then we cannot
extend that stack. Nothing to do here. */
stackseg = VG_(am_find_nsegment)(addr);
- } else if (VG_(am_addr_is_in_extensible_client_stack)(addr)) {
+ } else if (VG_(am_addr_is_in_extensible_client_stack)(addr, '*')) {
if (VG_(extend_stack)(tid, addr)) {
stackseg = VG_(am_find_nsegment)(addr);
if (0 && stackseg)
Modified: branches/ASPACEM_TWEAKS/coregrind/m_signals.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_signals.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_signals.c Tue May 12 19:22:17 2015
@@ -1736,7 +1736,7 @@
if (tid == 1) { // main thread
Addr esp = VG_(get_SP)(tid);
Addr base = VG_PGROUNDDN(esp - VG_STACK_REDZONE_SZB);
- if (VG_(am_addr_is_in_extensible_client_stack)(base) &&
+ if (VG_(am_addr_is_in_extensible_client_stack)(base, '*') &&
VG_(extend_stack)(tid, base)) {
if (VG_(clo_trace_signals))
VG_(dmsg)(" -> extended stack base to %#lx\n",
@@ -2407,7 +2407,7 @@
{
Addr fault;
Addr esp;
- NSegment const *seg, *seg_next;
+ NSegment const *seg;
if (info->si_signo != VKI_SIGSEGV)
return False;
@@ -2415,8 +2415,6 @@
fault = (Addr)info->VKI_SIGINFO_si_addr;
esp = VG_(get_SP)(tid);
seg = VG_(am_find_nsegment)(fault);
- seg_next = seg ? VG_(am_next_nsegment)( seg, True/*fwds*/ )
- : NULL;
if (VG_(clo_trace_signals)) {
if (seg == NULL)
@@ -2430,11 +2428,7 @@
}
if (info->si_code == VKI_SEGV_MAPERR
- && seg
- && seg->kind == SkResvn
- && seg->smode == SmUpper
- && seg_next
- && seg_next->kind == SkAnonC
+ && VG_(am_addr_is_in_extensible_client_stack)(fault, 'U')
&& fault >= fault_mask(esp - VG_STACK_REDZONE_SZB)) {
/* If the fault address is above esp but below the current known
stack segment base, and it was a fault because there was
@@ -2442,7 +2436,7 @@
then extend the stack segment.
*/
Addr base = VG_PGROUNDDN(esp - VG_STACK_REDZONE_SZB);
- if (VG_(am_addr_is_in_extensible_client_stack)(base) &&
+ if (VG_(am_addr_is_in_extensible_client_stack)(base, '*') &&
VG_(extend_stack)(tid, base)) {
if (VG_(clo_trace_signals))
VG_(dmsg)(" -> extended stack base to %#lx\n",
Modified: branches/ASPACEM_TWEAKS/coregrind/m_syswrap/syswrap-generic.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_syswrap/syswrap-generic.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_syswrap/syswrap-generic.c Tue May 12 19:22:17 2015
@@ -3661,16 +3661,8 @@
vg_assert(grows == VKI_PROT_GROWSDOWN);
- NSegment const *aseg = VG_(am_find_nsegment)(ARG1);
- NSegment const *rseg;
-
- vg_assert(aseg);
-
- rseg = VG_(am_next_nsegment)( aseg, False/*backwards*/ );
- if (rseg &&
- rseg->kind == SkResvn &&
- rseg->smode == SmUpper &&
- rseg->end+1 == aseg->start) {
+ if (VG_(am_addr_is_in_extensible_client_stack)(ARG1, 'M')) {
+ const NSegment *aseg = VG_(am_find_nsegment)(ARG1);
Addr end = ARG1 + ARG2;
ARG1 = aseg->start;
ARG2 = end - aseg->start;
Modified: branches/ASPACEM_TWEAKS/coregrind/m_syswrap/syswrap-main.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_syswrap/syswrap-main.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_syswrap/syswrap-main.c Tue May 12 19:22:17 2015
@@ -1550,7 +1550,7 @@
So the approximation we're taking here is to extend the stack only
if the client stack pointer does not look bogus. */
- if (VG_(am_addr_is_in_extensible_client_stack)(stackMin))
+ if (VG_(am_addr_is_in_extensible_client_stack)(stackMin, '*'))
VG_(extend_stack)( tid, stackMin );
}
# endif
Modified: branches/ASPACEM_TWEAKS/coregrind/pub_core_aspacemgr.h
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/pub_core_aspacemgr.h (original)
+++ branches/ASPACEM_TWEAKS/coregrind/pub_core_aspacemgr.h Tue May 12 19:22:17 2015
@@ -90,7 +90,7 @@
/* Check whether ADDR looks like an address or address-to-be located in an
extensible client stack segment. */
-extern Bool VG_(am_addr_is_in_extensible_client_stack)( Addr addr );
+extern Bool VG_(am_addr_is_in_extensible_client_stack)( Addr addr, HChar kind );
/* Trivial fn: return the total amount of space in anonymous mappings,
both for V and the client. Is used for printing stats in
|