|
From: <sv...@va...> - 2015-07-29 19:02:23
|
Author: florian
Date: Wed Jul 29 20:02:11 2015
New Revision: 15457
Log:
Simplify ML_(am_clientise) taking advantage of the fact, that
the address interval is supposed to be located in a single segment.
Modified:
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-linux.c
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c
branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_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 Wed Jul 29 20:02:11 2015
@@ -1938,7 +1938,6 @@
segment (anon or file). Change the ownership of [start, start+len)
to the client instead. Fails if (start,len) does not denote a
suitable segment. */
-
Bool VG_(am_change_ownership_v_to_c)( Addr start, SizeT len )
{
if (len == 0)
@@ -1948,17 +1947,7 @@
if (!VG_IS_PAGE_ALIGNED(start) || !VG_IS_PAGE_ALIGNED(len))
return False;
- const NSegment *seg = ML_(am_find_segment)(start);
- if (seg->kind != SkFileV && seg->kind != SkAnonV)
- return False;
- if (start+len-1 > seg->end)
- return False;
-
- aspacem_assert(start >= seg->start);
- aspacem_assert(start+len-1 <= seg->end);
-
- ML_(am_clientise)( start, len );
- return True;
+ return ML_(am_clientise)( start, len );
}
/* Set the 'hasT' bit on the segment containing ADDR indicating that
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/aspacemgr-segments.c Wed Jul 29 20:02:11 2015
@@ -1354,24 +1354,32 @@
if (expensive_checking) check_tree(root_segment());
}
-/* Change ownership of valgrind address space [addr:addr+len-1] to client. */
-void ML_(am_clientise)( Addr start, SizeT len )
+/* Change ownership of valgrind address space [addr:addr+len-1] to client.
+ The address range is supposed to be located in a single segment. If that
+ is not so, return False. */
+Bool ML_(am_clientise)( Addr start, SizeT len )
{
- NSegment *segLo, *segHi;
+ const NSegment *seg = ML_(am_find_segment)(start);
- split_segments_lo_and_hi( start, start + len - 1, &segLo, &segHi );
- aspacem_assert(segLo == segHi);
+ if (seg->kind != SkFileV && seg->kind != SkAnonV)
+ return False;
+ if (start + len - 1 > seg->end)
+ return False;
- switch (segLo->kind) {
- case SkFileV: segLo->kind = SkFileC; break;
- case SkAnonV: segLo->kind = SkAnonC; break;
+ /* OK. SEG is a segment of the appropriate kind. Set up a template
+ segment with the corresponding client kind and insert that. Function
+ ML_(am_add_segment) will take care of everything. */
+ NSegment tmp = *seg;
+
+ switch (seg->kind) {
+ case SkFileV: tmp.kind = SkFileC; break;
+ case SkAnonV: tmp.kind = SkAnonC; break;
default: aspacem_assert(0); /* can't happen - guarded above */
}
- /* Changing permissions could have made previously un-mergable
- segments mergeable. Therefore have to re-preen them. */
- // preen_segments();
- if (expensive_checking) check_tree(root_segment());
+ ML_(am_add_segment)(&tmp);
+
+ return True;
}
/*--------------------------------------------------------------------*/
Modified: branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_aspacemgr.h
==============================================================================
--- branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_aspacemgr.h (original)
+++ branches/ASPACEM_TWEAKS/coregrind/m_aspacemgr/priv_aspacemgr.h Wed Jul 29 20:02:11 2015
@@ -161,7 +161,7 @@
void ML_(am_add_segment)( const NSegment *seg );
void ML_(am_show_segment_full)( Int logLevel, Int segNo, const NSegment *seg );
void ML_(am_change_permissions)( Addr start, SizeT len, UInt prot );
-void ML_(am_clientise)( Addr start, SizeT len );
+Bool ML_(am_clientise)( Addr start, SizeT len );
void ML_(am_init_segment)( /*OUT*/NSegment *seg, SegKind kind, Addr start,
Addr end);
NSegment *ML_(am_next_segment)( const NSegment *seg );
|