|
From: <sv...@va...> - 2005-09-11 12:48:28
|
Author: sewardj
Date: 2005-09-11 13:48:23 +0100 (Sun, 11 Sep 2005)
New Revision: 4618
Log:
Add enough changes so that programs can at least get started on 'none'.
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
branches/ASPACEM/coregrind/m_main.c
branches/ASPACEM/coregrind/m_mallocfree.c
branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c
branches/ASPACEM/coregrind/m_translate.c
branches/ASPACEM/coregrind/m_transtab.c
branches/ASPACEM/coregrind/m_ume.c
branches/ASPACEM/coregrind/pub_core_aspacemgr.h
branches/ASPACEM/coregrind/pub_core_mallocfree.h
Modified: branches/ASPACEM/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
--- branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-11 10:06:0=
7 UTC (rev 4617)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-11 12:48:2=
3 UTC (rev 4618)
@@ -1472,15 +1472,6 @@
#define Addr_MAX ((Addr)(-1ULL))
=20
=20
-/* Describes the ways in which the ends of a segment may be moved. */
-typedef
- enum {
- MoFixed, // usual case -- cannot be moved
- MoDownOK, // can be moved to a lower address
- MoUpOK // can be moved to a higher address
- }
- Movable;
-
static HChar* showMovable ( Movable m )
{
switch (m) {
@@ -1491,68 +1482,6 @@
}
}
=20
-typedef
- enum {
- SkFree, // unmapped space
- SkAnon, // anonymous mapping
- SkFile, // mapping to a file
- SkResvn // reservation
- }
- MKind;
-
-/* Describes a segment. Invariants:
-
- kind =3D=3D SkFree:
- // the only meaningful fields are .start and .end
-
- kind =3D=3D SkAnon:
- // the segment may be resized if required
- // there's no associated file:
- dev=3D=3Dino=3D=3Dfoff =3D 0, fnidx =3D=3D -1
- // segment may have permissions
-
- kind =3D=3D SkFile
- // the segment may not be resized:
- moveLo =3D=3D moveHi =3D=3D NotMovable, maxlen =3D=3D 0
- // there is an associated file
- // segment may have permissions
-
- kind =3D=3D SkResvn
- // the segment may be resized if required
- // there's no associated file:
- dev=3D=3Dino=3D=3Dfoff =3D 0, fnidx =3D=3D -1
- // segment has no permissions
- hasR=3D=3DhasW=3D=3DhasX=3D=3DanyTranslated =3D=3D False
-
- Also: if !isClient then anyTranslated=3D=3DFalse
- (viz, not allowed to make translations from non-client areas)
-*/
-typedef
- struct {
- MKind kind;
- Bool isClient;
- /* Extent (SkFree, SkAnon, SkFile, SkResvn) */
- Addr start; // lowest address in range
- Addr end; // highest address in range
- /* Resizability (SkAnon, SkResvn only) */
- Movable moveLo; // if yes, can lower end be moved
- Movable moveHi; // if yes, can upper end be moved
- SizeT maxlen; // if yes, what's the max size?
- /* Associated file (SkFile only) */
- UInt dev;
- UInt ino;
- ULong offset;
- Int fnIdx; // file name table index, if name is known
- /* Permissions (SkAnon, SkFile only) */
- Bool hasR;
- Bool hasW;
- Bool hasX;
- Bool anyTranslated;
- /* Admin */
- Bool mark;
- }
- NSegment;
-
/* Array [0 .. nsegments_used-1] of all mappings. */
/* Sorted by .addr field. */
/* I: len may not be zero. */
@@ -1613,8 +1542,21 @@
}
}
=20
+/* Find a segment, not include free-space and ones, for outside use. */
+NSegment* VG_(find_nsegment) ( Addr a )
+{
+ Int i =3D find_nsegment_idx(a);
+ aspacem_assert(i >=3D 0 && i < nsegments_used);
+ aspacem_assert(nsegments[i].start <=3D a);
+ aspacem_assert(a <=3D nsegments[i].end);
+ if (nsegments[i].kind =3D=3D SkFree)=20
+ return NULL;
+ else
+ return &nsegments[i];
+}
=20
=20
+
/* Limits etc */
=20
// The smallest address that aspacem will try to allocate
@@ -1754,8 +1696,7 @@
seg->ino =3D 0;
seg->offset =3D 0;
seg->fnIdx =3D -1;
- seg->hasR =3D seg->hasR =3D seg->hasW =3D False;
- seg->anyTranslated =3D False;
+ seg->hasR =3D seg->hasR =3D seg->hasW =3D seg->hasT =3D False;
seg->mark =3D False;
}
=20
@@ -1826,7 +1767,7 @@
seg->hasR ? 'r' : '-',=20
seg->hasW ? 'w' : '-',=20
seg->hasX ? 'x' : '-',=20
- seg->anyTranslated ? 'T' : '-',=20
+ seg->hasT ? 'T' : '-',=20
seg->dev,
seg->ino,
(Long)seg->offset,
@@ -1845,7 +1786,7 @@
seg->hasR ? 'r' : '-',=20
seg->hasW ? 'w' : '-',=20
seg->hasX ? 'x' : '-',=20
- seg->anyTranslated ? 'T' : '-',=20
+ seg->hasT ? 'T' : '-',=20
seg->dev,
seg->ino,
(Long)seg->offset,
@@ -1864,7 +1805,7 @@
seg->hasR ? 'r' : '-',=20
seg->hasW ? 'w' : '-',=20
seg->hasX ? 'x' : '-',=20
- seg->anyTranslated ? 'T' : '-',=20
+ seg->hasT ? 'T' : '-',=20
showMovable(seg->moveLo),
showMovable(seg->moveHi),
(ULong)seg->maxlen
@@ -1881,7 +1822,7 @@
}
=20
/* Print out the segment array (debugging only!). */
-static void show_nsegments ( Int logLevel, HChar* who )
+void VG_(show_nsegments) ( Int logLevel, HChar* who )
{
Int i;
VG_(debugLog)(logLevel, "aspacem",
@@ -1899,12 +1840,7 @@
">>>\n");
}
=20
-void VG_(show_nsegments) ( HChar* who )
-{
- show_nsegments( 0, who );
-}
=20
-
/* Add SEG to the collection, deleting/truncating any it overlaps */
static void add_segment ( NSegment* seg )
{
@@ -2033,7 +1969,7 @@
seg.fnIdx =3D allocate_segname( filename );
}
=20
- show_nsegment( 0,0, &seg );
+ show_nsegment( 2,0, &seg );
add_segment( &seg );
}
=20
@@ -2115,12 +2051,12 @@
init_resvn(&seg, aspacem_vStart, aspacem_vStart + VKI_PAGE_SIZE - 1)=
;
add_segment(&seg);
=20
- show_nsegments(2, "Initial layout");
+ VG_(show_nsegments)(2, "Initial layout");
=20
VG_(debugLog)(2, "aspacem", "Reading /proc/self/maps\n");
VG_(parse_procselfmaps) ( read_maps_callback );
=20
- show_nsegments(2, "With contents of /proc/self/maps");
+ VG_(show_nsegments)(2, "With contents of /proc/self/maps");
=20
return suggested_clstack_top;
}
Modified: branches/ASPACEM/coregrind/m_main.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
--- branches/ASPACEM/coregrind/m_main.c 2005-09-11 10:06:07 UTC (rev 4617=
)
+++ branches/ASPACEM/coregrind/m_main.c 2005-09-11 12:48:23 UTC (rev 4618=
)
@@ -576,7 +576,7 @@
=20
clstack_start =3D VG_PGROUNDDN(client_SP);
=20
- if (1)
+ if (0)
VG_(printf)("stringsize=3D%d auxsize=3D%d stacksize=3D%d\n"
"clstack_start %p\n"
"clstack_end %p\n",
@@ -587,8 +587,8 @@
=20
/* allocate a stack - mmap enough space for the stack */
res =3D VG_(mmap_anon_fixed_client)(
- (void *)clstack_start,
- clstack_end - clstack_start + 1,
+ (void *)clstack_start -40960,
+ clstack_end - clstack_start + 1 +40960,
VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC
);
vg_assert(!res.isError);=20
@@ -2077,7 +2077,7 @@
// Ensure we're on a plausible stack.
// p: logging
//--------------------------------------------------------------
- VG_(debugLog)(1, "main", "Checking current stack is plausible");
+ VG_(debugLog)(1, "main", "Checking current stack is plausible\n");
{ HChar* limLo =3D (HChar*)(&VG_(the_root_stack)[0]);
HChar* limHi =3D limLo + sizeof(VG_(the_root_stack));
HChar* aLocal =3D (HChar*)&zero; /* any auto local will do */
@@ -2460,9 +2460,9 @@
// p: layout_remaining_space() [for VG_(client_{base,end})]
// p: process_cmd_line_options() [for VG_(clo_pointercheck)]
//--------------------------------------------------------------
- if (VG_(clo_pointercheck))
- VG_(clo_pointercheck) =3D
- VG_(setup_pointercheck)( VG_(client_base), VG_(client_end));
+ //if (VG_(clo_pointercheck))
+ // VG_(clo_pointercheck) =3D
+ // VG_(setup_pointercheck)( VG_(client_base), VG_(client_end));
=20
//--------------------------------------------------------------
// register client stack
@@ -2470,6 +2470,15 @@
VG_(clstk_id) =3D VG_(register_stack)(VG_(clstk_base), VG_(clstk_end)=
);
=20
//--------------------------------------------------------------
+ // Show the address space state so far
+ //--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "\n");
+ VG_(debugLog)(1, "main", "\n");
+ VG_(show_nsegments)(1,"Memory layout at client startup");
+ VG_(debugLog)(1, "main", "\n");
+ VG_(debugLog)(1, "main", "\n");
+
+ //--------------------------------------------------------------
// Run!
//--------------------------------------------------------------
VGP_POPCC(VgpStartup);
Modified: branches/ASPACEM/coregrind/m_mallocfree.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
--- branches/ASPACEM/coregrind/m_mallocfree.c 2005-09-11 10:06:07 UTC (re=
v 4617)
+++ branches/ASPACEM/coregrind/m_mallocfree.c 2005-09-11 12:48:23 UTC (re=
v 4618)
@@ -478,7 +478,6 @@
/*--- Superblock management ---*/
/*------------------------------------------------------------*/
=20
-static
void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB )
{
static Bool alreadyCrashing =3D False;
@@ -552,9 +551,10 @@
vg_assert(0 =3D=3D (Addr)sb % VG_MIN_MALLOC_SZB);
sb->n_payload_bytes =3D cszB - sizeof(Superblock);
a->bytes_mmaped +=3D cszB;
- if (1)
- VG_(message)(Vg_DebugMsg, "newSuperblock at %p, %d payload bytes",=
=20
- sb, sb->n_payload_bytes);
+ VG_(debugLog)(1, "mallocfree",
+ "newSuperblock at %p, for %s, %lld payload bytes\n",=
=20
+ sb, a->clientmem ? "CLIENT" : "VALGRIND",
+ (Long)sb->n_payload_bytes);
return sb;
}
=20
Modified: branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.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
--- branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c 2005-09-11 1=
0:06:07 UTC (rev 4617)
+++ branches/ASPACEM/coregrind/m_syswrap/syswrap-x86-linux.c 2005-09-11 1=
2:48:23 UTC (rev 4618)
@@ -245,7 +245,7 @@
{
VG_(debugLog)(1, "syswrap-x86-linux",=20
"entering VG_(main_thread_wrapper_NORETURN)\n");
-
+#if 0
UWord* esp =3D allocstack(tid);
=20
/* shouldn't be any other threads around yet */
@@ -257,7 +257,10 @@
run_a_thread_NORETURN, /* fn to call */
(Word)tid /* arg to give it */
);
+#endif
=20
+ run_a_thread_NORETURN( tid );
+
/*NOTREACHED*/
vg_assert(0);
}
Modified: branches/ASPACEM/coregrind/m_translate.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
--- branches/ASPACEM/coregrind/m_translate.c 2005-09-11 10:06:07 UTC (rev=
4617)
+++ branches/ASPACEM/coregrind/m_translate.c 2005-09-11 12:48:23 UTC (rev=
4618)
@@ -408,10 +408,12 @@
match the logic at XXXYYYZZZ below. */
if (VG_(clo_smc_check) =3D=3D Vg_SmcStack) {
ThreadId tid =3D chase_into_ok__CLOSURE_tid;
- Segment* seg =3D VG_(find_segment)(addr);
- if (seg=20
- && seg->addr <=3D VG_(get_SP)(tid)
- && VG_(get_SP)(tid) < seg->addr+seg->len)
+ NSegment* seg =3D VG_(find_nsegment)(addr);
+ if (seg
+ && (seg->kind =3D=3D SkAnon || seg->kind =3D=3D SkFile)
+ && seg->isClient
+ && seg->start <=3D VG_(get_SP)(tid)
+ && VG_(get_SP)(tid)+sizeof(Word)-1 <=3D seg->end)
goto dontchase;
}
=20
@@ -441,7 +443,7 @@
Int tmpbuf_used, verbosity;
Bool notrace_until_done, do_self_check;
UInt notrace_until_limit =3D 0;
- Segment* seg;
+ NSegment* seg;
VexGuestExtents vge;
=20
/* Indicates what arch we are running on, and other important info
@@ -512,8 +514,6 @@
notrace_until_done
=3D VG_(get_bbs_translated)() >=3D notrace_until_limit;
=20
- seg =3D VG_(find_segment)(orig_addr);
-
if (!debugging_translation)
VG_TRACK( pre_mem_read, Vg_CoreTranslate, tid, "", orig_addr, 1 );
=20
@@ -527,23 +527,38 @@
bbs_done);
}
=20
- if (seg =3D=3D NULL ||
- !VG_(seg_contains)(seg, orig_addr, 1) ||=20
- (seg->prot & (VKI_PROT_READ|VKI_PROT_EXEC)) =3D=3D 0) {
+ /* Figure out what segment the requested address is in, and=20
+ look for possible reasons to disallow it. */
+
+ seg =3D VG_(find_nsegment)(orig_addr);
+
+ if (seg =3D=3D NULL=20
+ || !(seg->kind =3D=3D SkAnon || seg->kind =3D=3D SkFile)
+ || !seg->isClient
+ || !seg->hasX) {
+
+ /* U R busted, sonny. Place your hands on your head and step
+ away from the orig_addr. */
/* Code address is bad - deliver a signal instead */
- vg_assert(!VG_(is_addressable)(orig_addr, 1,=20
- VKI_PROT_READ|VKI_PROT_EXEC));
-
- if (seg !=3D NULL && VG_(seg_contains)(seg, orig_addr, 1)) {
- vg_assert((seg->prot & VKI_PROT_EXEC) =3D=3D 0);
+ if (seg !=3D NULL) {
+ /* There's some kind of segment at the requested place, but we
+ aren't allowed to execute code here. */
VG_(synth_fault_perms)(tid, orig_addr);
- } else
+ } else {
+ /* There is no segment at all; we are attempting to execute in
+ the middle of nowhere. */
VG_(synth_fault_mapping)(tid, orig_addr);
-
+ }
return False;
- } else
- seg->flags |=3D SF_CODE; /* contains cached code */
=20
+ } else {
+
+ /* Ok to execute here. Mark that we have taken a translation
+ from this segment. */
+ seg->hasT =3D True; /* contains cached code */
+ }
+
+
/* Do we want a self-checking translation? */
do_self_check =3D False;
switch (VG_(clo_smc_check)) {
@@ -554,8 +569,8 @@
do_self_check
/* =3D seg ? toBool(seg->flags & SF_GROWDOWN) : False; */
=3D seg=20
- ? (seg->addr <=3D VG_(get_SP)(tid)
- && VG_(get_SP)(tid) < seg->addr+seg->len)
+ ? (seg->start <=3D VG_(get_SP)(tid)
+ && VG_(get_SP)(tid)+sizeof(Word)-1 <=3D seg->end)
: False;
break;
default:=20
Modified: branches/ASPACEM/coregrind/m_transtab.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
--- branches/ASPACEM/coregrind/m_transtab.c 2005-09-11 10:06:07 UTC (rev =
4617)
+++ branches/ASPACEM/coregrind/m_transtab.c 2005-09-11 12:48:23 UTC (rev =
4618)
@@ -30,6 +30,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_debuglog.h"
#include "pub_core_machine.h" // ppc32: VG_(cache_line_size_ppc32)
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
@@ -39,6 +40,10 @@
#include "pub_core_tooliface.h" // For VG_(details).avg_translation_siz=
eB
#include "pub_core_transtab.h"
=20
+#include "pub_core_debuginfo.h" // Needed for pub_core_aspacemgr :(
+#include "pub_core_aspacemgr.h"
+#include "pub_core_mallocfree.h" // VG_(out_of_memory_NORETURN)
+
/* #define DEBUG_TRANSTAB */
=20
=20
@@ -288,7 +293,8 @@
=20
static void initialiseSector ( Int sno )
{
- Int i;
+ Int i;
+ SysRes sres;
vg_assert(isValidSector(sno));
=20
if (sectors[sno].tc =3D=3D NULL) {
@@ -297,16 +303,30 @@
vg_assert(sectors[sno].tt =3D=3D NULL);
vg_assert(sectors[sno].tc_next =3D=3D NULL);
vg_assert(sectors[sno].tt_n_inuse =3D=3D 0);
- sectors[sno].tc=20
- =3D VG_(get_memory_from_mmap)
- ( 8 * tc_sector_szQ, "sectors[sno].tc" );
- sectors[sno].tt=20
- =3D VG_(get_memory_from_mmap)=20
- ( N_TTES_PER_SECTOR * sizeof(TTEntry), "sectors[sno].tt" )=
;
+
+ VG_(debugLog)(1,"transtab", "allocate sector %d\n", sno);
+
+ sres =3D VG_(map_anon_float_valgrind)( 8 * tc_sector_szQ );
+ if (sres.isError) {
+ VG_(out_of_memory_NORETURN)("initialiseSector(TC)",=20
+ 8 * tc_sector_szQ );
+ /*NOTREACHED*/
+ }
+ sectors[sno].tc =3D sres.val;
+
+ sres =3D VG_(map_anon_float_valgrind)( N_TTES_PER_SECTOR * sizeof(=
TTEntry) );
+ if (sres.isError) {
+ VG_(out_of_memory_NORETURN)("initialiseSector(TT)",=20
+ N_TTES_PER_SECTOR * sizeof(TTEntry)=
);
+ /*NOTREACHED*/
+ }
+ sectors[sno].tt =3D sres.val;
+
if (VG_(clo_verbosity) > 2)
VG_(message)(Vg_DebugMsg, "TT/TC: initialise sector %d", sno);
} else {
/* Sector has been used before. */
+ VG_(debugLog)(1,"transtab", "recycle sector %d\n", sno);
vg_assert(sectors[sno].tt !=3D NULL);
vg_assert(sectors[sno].tc_next !=3D NULL);
n_dump_count +=3D sectors[sno].tt_n_inuse;
Modified: branches/ASPACEM/coregrind/m_ume.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
--- branches/ASPACEM/coregrind/m_ume.c 2005-09-11 10:06:07 UTC (rev 4617)
+++ branches/ASPACEM/coregrind/m_ume.c 2005-09-11 12:48:23 UTC (rev 4618)
@@ -391,7 +391,7 @@
prot, /*VKI_MAP_FIXED|VKI_MAP_PRIVATE, */
e->fd, VG_PGROUNDDN(off)
);
- if (0) VG_(show_nsegments)("after native 1");
+ if (0) VG_(show_nsegments)(0,"after native 1");
check_mmap(res, (char*)VG_PGROUNDDN(addr),
VG_PGROUNDUP(bss)-VG_PGROUNDDN(addr));
}
@@ -402,7 +402,7 @@
=20
bytes =3D VG_PGROUNDUP(brkaddr)-VG_PGROUNDUP(bss);
if (bytes > 0) {
- VG_(debugLog)(0,"","mmap_native 2\n");
+ VG_(debugLog)(0,"ume","mmap_native 2\n");
res =3D VG_(mmap_native)(
(Char *)VG_PGROUNDUP(bss), bytes,
prot, VKI_MAP_FIXED|VKI_MAP_ANONYMOUS|VKI_MAP_PRIVATE,=20
@@ -573,7 +573,7 @@
else
res =3D VG_(mmap_anon_float_client)(interp_size, VKI_PROT_NONE)=
;
=20
- if (0) VG_(show_nsegments)("after native 3");
+ if (0) VG_(show_nsegments)(0,"after native 3");
=20
check_mmap(res, base, interp_size);
vg_assert(!res.isError);
Modified: branches/ASPACEM/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
--- branches/ASPACEM/coregrind/pub_core_aspacemgr.h 2005-09-11 10:06:07 U=
TC (rev 4617)
+++ branches/ASPACEM/coregrind/pub_core_aspacemgr.h 2005-09-11 12:48:23 U=
TC (rev 4618)
@@ -161,13 +161,85 @@
HChar
VgStack[VG_STACK_GUARD_SZB + VG_STACK_ACTIVE_SZB + VG_STACK_GUARD_SZB=
];
=20
+/* Describes the ways in which the ends of a segment may be moved. */
+typedef
+ enum {
+ MoFixed, // usual case -- cannot be moved
+ MoDownOK, // can be moved to a lower address
+ MoUpOK // can be moved to a higher address
+ }
+ Movable;
+
+typedef
+ enum {
+ SkFree, // unmapped space
+ SkAnon, // anonymous mapping
+ SkFile, // mapping to a file
+ SkResvn // reservation
+ }
+ MKind;
+
+/* Describes a segment. Invariants:
+
+ kind =3D=3D SkFree:
+ // the only meaningful fields are .start and .end
+
+ kind =3D=3D SkAnon:
+ // the segment may be resized if required
+ // there's no associated file:
+ dev=3D=3Dino=3D=3Dfoff =3D 0, fnidx =3D=3D -1
+ // segment may have permissions
+
+ kind =3D=3D SkFile
+ // the segment may not be resized:
+ moveLo =3D=3D moveHi =3D=3D NotMovable, maxlen =3D=3D 0
+ // there is an associated file
+ // segment may have permissions
+
+ kind =3D=3D SkResvn
+ // the segment may be resized if required
+ // there's no associated file:
+ dev=3D=3Dino=3D=3Dfoff =3D 0, fnidx =3D=3D -1
+ // segment has no permissions
+ hasR=3D=3DhasW=3D=3DhasX=3D=3DanyTranslated =3D=3D False
+
+ Also: if !isClient then anyTranslated=3D=3DFalse
+ (viz, not allowed to make translations from non-client areas)
+*/
+typedef
+ struct {
+ MKind kind;
+ Bool isClient;
+ /* Extent (SkFree, SkAnon, SkFile, SkResvn) */
+ Addr start; // lowest address in range
+ Addr end; // highest address in range
+ /* Resizability (SkAnon, SkResvn only) */
+ Movable moveLo; // if yes, can lower end be moved
+ Movable moveHi; // if yes, can upper end be moved
+ SizeT maxlen; // if yes, what's the max size?
+ /* Associated file (SkFile only) */
+ UInt dev;
+ UInt ino;
+ ULong offset;
+ Int fnIdx; // file name table index, if name is known
+ /* Permissions (SkAnon, SkFile only) */
+ Bool hasR;
+ Bool hasW;
+ Bool hasX;
+ Bool hasT; // True --> translations have (or MAY have)
+ /* Admin */ // been taken from this segment
+ Bool mark;
+ }
+ NSegment;
+
+
/* Takes a pointer to the sp at the time V gained control. This is
taken to be the highest usable address (more or less). Based on
that (and general consultation of tea leaves, etc) return a
suggested end address for the client's stack. */
extern Addr VG_(new_aspacem_start) ( Addr sp_at_startup );
=20
-extern void VG_(show_nsegments) ( HChar* who );
+extern void VG_(show_nsegments) ( Int logLevel, HChar* who );
=20
typedef
struct {
@@ -200,6 +272,7 @@
=20
extern SysRes VG_(munmap_client)( Addr base, SizeT length );
=20
+extern NSegment* VG_(find_nsegment) ( Addr a );
=20
#endif // __PUB_CORE_ASPACEMGR_H
=20
Modified: branches/ASPACEM/coregrind/pub_core_mallocfree.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
--- branches/ASPACEM/coregrind/pub_core_mallocfree.h 2005-09-11 10:06:07 =
UTC (rev 4617)
+++ branches/ASPACEM/coregrind/pub_core_mallocfree.h 2005-09-11 12:48:23 =
UTC (rev 4618)
@@ -83,6 +83,10 @@
=20
extern void VG_(print_all_arena_stats) ( void );
=20
+// TODO: move somewhere else
+// Call here to bomb the system when out of memory (mmap anon fails)
+extern void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB );
+
#endif // __PUB_CORE_MALLOCFREE_H
=20
/*--------------------------------------------------------------------*/
|