You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
1
(12) |
2
(11) |
3
(8) |
|
4
(9) |
5
(10) |
6
(18) |
7
(8) |
8
(12) |
9
(23) |
10
(14) |
|
11
(15) |
12
(31) |
13
(45) |
14
(28) |
15
(20) |
16
(16) |
17
(9) |
|
18
(18) |
19
(26) |
20
(49) |
21
(14) |
22
(18) |
23
(24) |
24
(28) |
|
25
(39) |
26
(17) |
27
(27) |
28
(27) |
29
(14) |
30
(44) |
|
|
From: Josef W. <Jos...@gm...> - 2005-09-11 23:32:24
|
Hi Tom, On Thursday 01 September 2005 09:47, Tom Hughes wrote: > In message <200...@gm...> > > Josef Weidendorfer <Jos...@gm...> wrote: > > For (2) I need a heuristic for detecting the function for lazy symbol > > relocation in the runtime linker. Some background: > > When I see a JMP crossing functions (e.g. A calls B, B jumps to C), I > > have two possibilities to map this onto a call graph: > > a) A calls B, returns to A, A calls C > > b) A calls B, B calls C > > I default to (b), as this gives nice graphs e.g. with tail recursion. > > With one exception: every call to a shared lib usually first calls the > > runtime linker, which jumps to the right function at the end. So using > > (b) here gives call chains with the relocation function multiple times > > showing up, and this looks like recursive cycles for KCachegrind. This > > leads to profiles showing most functions in a recursive cycle, which is > > bad. So I want (a) for the relocation function. > > x86 used "push <addr>;ret" at end of relocation, and in a bad hack I used > > this to decide for (a). But AMD64 uses a normal JMP instruction. > > The thing is, that with a stripped runtime linker, the relocation > > function gets no symbol name (how is this possible?). How should I decide > > that I want (a) in this case? > > Ideas welcome. > > When this happens do you still know the original address that the > first jump went to? So if foo() calls bar() which is in a different > shared library then foo jumps to the PLT entry which jumps to the > dynamic linker which eventually jumps to bar. Yes. > Do you know when that > last jump to bar happens the target address of the original jump from > foo into the PLT? Sorry, I do not understand this question... > If you do then the trick is that when you read the ELF header for > each shared library you remember the address and size of the PLT > section for each one and if that original jump was into a PLT then > you know you've just done a lazy symbol resolution. > > I guess the problem is that future calls will still go through > the PLT and if the called functions then tail calls it will get > confusing. Yes. Calls will always go through PLT. At least on x86/AMD64, the PLT code does an indirect jump, which usually first jumps into the runtime linker. The "usually" is a problem here: for prelinked code, this is of course not true. And then, a call into the runtime linker does not have to be about symbol resolution at all... Detecting PLT sections is no problem, and looking up if a function was jumped to from PLT would also be possible, but this all is getting quite complex and probably fragile. > Maybe you have to look for a jump into the PLT followed by a jump > into ld.so followed by a another jump... It's all getting a bit > horrible though ;-) Yes. The easiest way would be to look at the symbol "dl_runtime_resolve". I just do not understand why this symbol on some systems seems not to be available. Does this happen on your system? I think I'll go with the symbol name, which can be configured via command line option. Josef > > Tom |
|
From: <sv...@va...> - 2005-09-11 23:00:33
|
Author: sewardj
Date: 2005-09-12 00:00:24 +0100 (Mon, 12 Sep 2005)
New Revision: 4619
Log:
Infrastructure to deal with resizable reservations and resizable
anonymous mappings.
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
branches/ASPACEM/coregrind/pub_core_aspacemgr.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 12:48:2=
3 UTC (rev 4618)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-11 23:00:2=
4 UTC (rev 4619)
@@ -1472,16 +1472,6 @@
#define Addr_MAX ((Addr)(-1ULL))
=20
=20
-static HChar* showMovable ( Movable m )
-{
- switch (m) {
- case MoFixed: return "Fixed";
- case MoDownOK: return "MoveD";
- case MoUpOK: return "MoveU";
- default: return "?????";
- }
-}
-
/* Array [0 .. nsegments_used-1] of all mappings. */
/* Sorted by .addr field. */
/* I: len may not be zero. */
@@ -1492,6 +1482,22 @@
static Int nsegments_used =3D 0;
=20
=20
+/* Given a pointer to a seg, tries to figure out which one it is in
+ nsegments[..]. Very paranoid. */
+static Int segAddr_to_index ( NSegment* seg )
+{
+ Int i;
+ if (seg < &nsegments[0] || seg >=3D &nsegments[nsegments_used])
+ return -1;
+ i =3D (seg - &nsegments[0]) / sizeof(NSegment);
+ if (i < 0 || i >=3D nsegments_used)
+ return -1;
+ if (seg =3D=3D &nsegments[i])
+ return i;
+ return -1;
+}
+
+
ULong VG_(aspacem_get_anonsize_total)( void )
{
Int i;
@@ -1689,9 +1695,7 @@
seg->isClient =3D False;
seg->start =3D 0;
seg->end =3D 0;
- seg->moveLo =3D MoFixed;
- seg->moveHi =3D MoFixed;
- seg->maxlen =3D 0;
+ seg->smode =3D SmFixed;
seg->dev =3D 0;
seg->ino =3D 0;
seg->offset =3D 0;
@@ -1722,6 +1726,16 @@
}
}
=20
+static HChar* show_ShrinkMode ( ShrinkMode sm )
+{
+ switch (sm) {
+ case SmLower: return "SmLower";
+ case SmUpper: return "SmUpper";
+ case SmFixed: return "SmFixed";
+ default: return "Sm?????";
+ }
+}
+
static void show_Addr_concisely ( /*OUT*/HChar* buf, Addr aA )
{
HChar* fmt;
@@ -1796,7 +1810,7 @@
case SkResvn:
VG_(debugLog)(
logLevel, "aspacem",
- "%3d: %s %08llx-%08llx %s %c%c%c%c (%s,%s,%llu)\n",
+ "%3d: %s %08llx-%08llx %s %c%c%c%c %s\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
@@ -1806,9 +1820,7 @@
seg->hasW ? 'w' : '-',=20
seg->hasX ? 'x' : '-',=20
seg->hasT ? 'T' : '-',=20
- showMovable(seg->moveLo),
- showMovable(seg->moveHi),
-(ULong)seg->maxlen
+ show_ShrinkMode(seg->smode)
);
break;
=20
@@ -2311,6 +2323,149 @@
}
=20
=20
+/* See comment on prototype in pub_core_aspacemgr.h for a description
+ of this. */
+Bool VG_(create_reservation) ( Addr start, SizeT length,=20
+ ShrinkMode smode, SSizeT extra )
+{
+ Int startI, endI;
+ NSegment seg;
+
+ /* start and end, not taking into account the extra space. */
+ Addr start1 =3D start;
+ Addr end1 =3D start + length - 1;
+
+ /* start and end, taking into account the extra space. */
+ Addr start2 =3D start1;
+ Addr end2 =3D end1;
+
+ if (extra < 0) start2 +=3D extra; // this moves it down :-)
+ if (extra > 0) end2 +=3D extra;
+
+ aspacem_assert(VG_IS_PAGE_ALIGNED(start));
+ aspacem_assert(VG_IS_PAGE_ALIGNED(start+length-1));
+ aspacem_assert(VG_IS_PAGE_ALIGNED(start2));
+ aspacem_assert(VG_IS_PAGE_ALIGNED(end2));
+
+ startI =3D find_nsegment_idx( start2 );
+ endI =3D find_nsegment_idx( end2 );
+
+ /* If the start and end points don't fall within the same (free)
+ segment, we're hosed. This does rely on the assumption that all
+ mergeable adjacent segments can be merged, but add_segment()
+ should ensure that. */
+ if (startI !=3D endI)
+ return False;
+
+ if (nsegments[startI].kind !=3D SkFree)
+ return False;
+
+ /* Looks good - make the reservation. */
+ aspacem_assert(nsegments[startI].start <=3D start2);
+ aspacem_assert(end2 <=3D nsegments[startI].end);
+
+ init_nsegment( &seg );
+ seg.kind =3D SkResvn;
+ seg.start =3D start1; /* NB: extra space is not included in the rese=
rvation. */
+ seg.end =3D end1;
+ seg.smode =3D smode;
+ add_segment( &seg );
+ return True;
+}
+
+
+/* See comment on prototype in pub_core_aspacemgr.h for a description
+ of this. */
+Bool VG_(extend_into_adjacent_reservation)( NSegment* seg, SSizeT delta =
)
+{
+ Int segA, segR;
+ UInt prot;
+ SysRes sres;
+
+ /* Find the segment array index for SEG. If the assertion fails it
+ probably means you passed in a bogus SEG. */
+ segA =3D segAddr_to_index( seg );
+ aspacem_assert(segA >=3D 0 && segA < nsegments_used);
+
+ if (nsegments[segA].kind !=3D SkAnon)
+ return False;
+
+ if (delta =3D=3D 0)
+ return True;
+
+ prot =3D (nsegments[segA].hasR ? VKI_PROT_READ : 0)
+ | (nsegments[segA].hasW ? VKI_PROT_WRITE : 0)
+ | (nsegments[segA].hasX ? VKI_PROT_EXEC : 0);
+
+ aspacem_assert(VG_IS_PAGE_ALIGNED(delta<0 ? -delta : delta));
+
+ if (delta > 0) {
+
+ /* Extending the segment forwards. */
+ segR =3D segA+1;
+ if (segR >=3D nsegments_used
+ || nsegments[segR].kind !=3D SkResvn
+ || nsegments[segR].smode !=3D SmLower
+ || nsegments[segR].start !=3D nsegments[segA].end + 1
+ || delta > (nsegments[segR].end - nsegments[segR].start + 1))
+ return False;
+ =20
+ /* Extend the kernel's mapping. */
+ sres =3D do_mmap_NATIVE( nsegments[segR].start, delta,
+ prot,
+ VKI_MAP_FIXED|VKI_MAP_PRIVATE
+ |VKI_MAP_ANONYMOUS, 0, 0 );
+ if (sres.isError)
+ return False; /* kernel bug if this happens? */
+ if (sres.val !=3D nsegments[segR].start) {
+ /* kernel bug if this happens? */
+ do_munmap_NATIVE( sres.val, delta );
+ return False;
+ }
+
+ /* Ok, success with the kernel. Update our structures. */
+ nsegments[segR].start +=3D delta;
+ nsegments[segA].end +=3D delta;
+ aspacem_assert(nsegments[segR].start <=3D nsegments[segR].end);
+
+ } else {
+
+ /* Extending the segment backwards. */
+ delta =3D -delta;
+ aspacem_assert(delta > 0);
+
+ segR =3D segA-1;
+ if (segR < 0
+ || nsegments[segR].kind !=3D SkResvn
+ || nsegments[segR].smode !=3D SmUpper
+ || nsegments[segR].end + 1 !=3D nsegments[segA].start
+ || delta > (nsegments[segR].end - nsegments[segR].start + 1))
+ return False;
+ =20
+ /* Extend the kernel's mapping. */
+ sres =3D do_mmap_NATIVE( nsegments[segA].start-delta, delta,
+ prot,
+ VKI_MAP_FIXED|VKI_MAP_PRIVATE
+ |VKI_MAP_ANONYMOUS, 0, 0 );
+ if (sres.isError)
+ return False; /* kernel bug if this happens? */
+ if (sres.val !=3D nsegments[segA].start-delta) {
+ /* kernel bug if this happens? */
+ do_munmap_NATIVE( sres.val, delta );
+ return False;
+ }
+
+ /* Ok, success with the kernel. Update our structures. */
+ nsegments[segR].end -=3D delta;
+ nsegments[segA].start -=3D delta;
+ aspacem_assert(nsegments[segR].start <=3D nsegments[segR].end);
+
+ }
+
+ return True;
+}
+
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
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 12:48:23 U=
TC (rev 4618)
+++ branches/ASPACEM/coregrind/pub_core_aspacemgr.h 2005-09-11 23:00:24 U=
TC (rev 4619)
@@ -161,17 +161,8 @@
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
@@ -179,6 +170,14 @@
}
MKind;
=20
+typedef
+ enum {
+ SmLower, // lower end can move up
+ SmFixed, // cannot be shrunk
+ SmUpper // upper end can move down
+ }
+ ShrinkMode;
+
/* Describes a segment. Invariants:
=20
kind =3D=3D SkFree:
@@ -213,10 +212,8 @@
/* 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?
+ /* Shrinkable? (SkResvn only) */
+ ShrinkMode smode;
/* Associated file (SkFile only) */
UInt dev;
UInt ino;
@@ -233,7 +230,7 @@
NSegment;
=20
=20
-/* Takes a pointer to the sp at the time V gained control. This is
+/* 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. */
@@ -273,7 +270,33 @@
extern SysRes VG_(munmap_client)( Addr base, SizeT length );
=20
extern NSegment* VG_(find_nsegment) ( Addr a );
+extern NSegment* VG_(next_nsegment) ( NSegment* here, Bool fwds );
=20
+/* Create a reservation from START .. START+LENGTH-1, with the given
+ ShrinkMode. When checking whether the reservation can be created,
+ also ensure that at least abs(EXTRA) extra free bytes will remain
+ above (> 0) or below (< 0) the reservation.
+
+ The reservation will only be created if it, plus the extra-zone,
+ falls entirely within a single free segment. The returned Bool
+ indicates whether the creation succeeded. */
+extern=20
+Bool VG_(create_reservation) ( Addr start, SizeT length,=20
+ ShrinkMode smode, SSizeT extra );
+
+
+/* Let SEG be an anonymous mapping. This fn extends the mapping by
+ DELTA bytes, taking the space from a reservation section which must
+ be adjacent. If DELTA is positive, the segment is extended
+ forwards in the address space, and the reservation must be the next
+ one along. If DELTA is negative, the segment is extended backwards
+ in the address space and the reservation must be the previous one.
+ DELTA must be page aligned and must not exceed the size of the
+ reservation segment. */
+extern
+Bool VG_(extend_into_adjacent_reservation) ( NSegment* seg, SSizeT delta=
);
+
+
#endif // __PUB_CORE_ASPACEMGR_H
=20
/*--------------------------------------------------------------------*/
|
|
From: Nicholas N. <nj...@cs...> - 2005-09-11 20:52:14
|
On Sat, 10 Sep 2005, Julian Seward wrote: > Unlike the current manager, the list explicitly > represents free areas as that makes it easier to iterate over them, > and so it should account for *every* address in (Addr)0 through > (Addr)(-1) inclusive. > > The new manager also has the concept of a reservation segment. Such a > segment is not mapped, and so is similar to a free-space segment, but > with the difference that it will not attempt to allocate anything in > that space. Ah, those both sound very good. N |
|
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
/*--------------------------------------------------------------------*/
|
|
From: <sv...@va...> - 2005-09-11 10:06:14
|
Author: sewardj Date: 2005-09-11 11:06:07 +0100 (Sun, 11 Sep 2005) New Revision: 4617 Log: Attempt to make linking of the tools work more reliably. Modified: branches/ASPACEM/Makefile.tool.am Modified: branches/ASPACEM/Makefile.tool.am =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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/Makefile.tool.am 2005-09-11 00:48:18 UTC (rev 4616) +++ branches/ASPACEM/Makefile.tool.am 2005-09-11 10:06:07 UTC (rev 4617) @@ -23,7 +23,7 @@ =20 ## Nb: do not call this variables "TOOL_LINKADD" and "TOOL_LDFLAGS" -- t= hat ## makes automake think we are building something called "TOOLS". -TOOL_LINKADD =3D $(COREGRIND_LIBS) $(COREGRIND_LIBS) -lgcc +TOOL_LINKADD =3D -Wl,-whole-archive $(COREGRIND_LIBS) -Wl,-no-whole-arch= ive -lgcc TOOL_LINKFLAGS =3D \ -static \ -Wl,-defsym,valt_load_address=3D@VALT_LOAD_ADDRESS@ \ |
|
From: Greg P. <gp...@us...> - 2005-09-11 03:44:21
|
Julian Seward writes: > The new manager also has the concept of a reservation segment. Such a > segment is not mapped, and so is similar to a free-space segment, but > with the difference that it will not attempt to allocate anything in > that space. This is perfect for Mac OS X's special "shared regions". Basically, this is a chunk of address space reserved for mapping some system shared libraries, if the process uses them. You don't want to try to put anything else there - either the kernel won't let you, or you'll really confuse the system if a library gets loaded later. > I think the real issue re spontaneous mappings is to have a > reliable way to know they have happened, and where the new mapping > is. On Linux that comes down to rescanning /proc/self/maps > after any event which might create such a mapping. I haven't seen any truly spontaneous mappings; there's always something in the transaction that says at least where the mapping is, even if it's unconvenient. Mac OS X has kernel API to enumerate the mappings, not unlike /proc/self/maps. > Anyway, that's the theory. Let me know ASAP if it is not what > Darwin needs. It's taken me most of this week to understand in detail > how the aspacemgr needs to be connected to the rest of system. > I hope to have something starting to work in the next couple of days. I like everything I've heard so far. -- Greg Parker gp...@ap... Runtime Wrangler |
|
From: Tom H. <th...@cy...> - 2005-09-11 02:59:49
|
Nightly build on gill ( x86_64, Fedora Core 2 ) started at 2005-09-11 03:00:03 BST Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 165 tests, 8 stderr failures, 2 stdout failures ================= memcheck/tests/sigprocmask (stderr) memcheck/tests/strchr (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) none/tests/fdleak_fcntl (stderr) none/tests/ppc32/lsw (stdout) none/tests/ppc32/lsw (stderr) none/tests/tls (stdout) |
|
From: <js...@ac...> - 2005-09-11 02:58:40
|
Nightly build on phoenix ( SuSE 9.1 ) started at 2005-09-11 03:30:00 BST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 186 tests, 3 stderr failures, 1 stdout failure ================= none/tests/faultstatus (stderr) none/tests/ppc32/lsw (stdout) none/tests/ppc32/lsw (stderr) none/tests/x86/int (stderr) |
|
From: <js...@ac...> - 2005-09-11 02:44:52
|
Nightly build on g5 ( YDL 4.0, ppc970 ) started at 2005-09-11 04:40:00 CEST Checking out vex source tree ... done Building vex ... done Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 159 tests, 18 stderr failures, 1 stdout failure ================= memcheck/tests/badjump (stderr) memcheck/tests/badjump2 (stderr) memcheck/tests/fprw (stderr) memcheck/tests/leak-cycle (stderr) memcheck/tests/leak-tree (stderr) memcheck/tests/partiallydefinedeq (stderr) memcheck/tests/pointer-trace (stderr) memcheck/tests/sigaltstack (stderr) memcheck/tests/supp1 (stderr) memcheck/tests/supp_unknown (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) cachegrind/tests/chdir (stderr) cachegrind/tests/dlclose (stdout) cachegrind/tests/dlclose (stderr) none/tests/faultstatus (stderr) none/tests/fdleak_cmsg (stderr) none/tests/fdleak_ipv4 (stderr) |
|
From: Tom H. <to...@co...> - 2005-09-11 02:41:02
|
Nightly build on dunsmere ( athlon, Fedora Core 4 ) started at 2005-09-11 03:30:04 BST Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 188 tests, 6 stderr failures, 1 stdout failure ================= memcheck/tests/leak-tree (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) none/tests/ppc32/lsw (stdout) none/tests/ppc32/lsw (stderr) none/tests/x86/int (stderr) |
|
From: Tom H. <th...@cy...> - 2005-09-11 02:28:11
|
Nightly build on alvis ( i686, Red Hat 7.3 ) started at 2005-09-11 03:15:04 BST Results differ from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 187 tests, 15 stderr failures, 2 stdout failures ================= memcheck/tests/addressable (stderr) memcheck/tests/describe-block (stderr) memcheck/tests/erringfds (stderr) memcheck/tests/leak-0 (stderr) memcheck/tests/leak-cycle (stderr) memcheck/tests/leak-regroot (stderr) memcheck/tests/leak-tree (stderr) memcheck/tests/match-overrun (stderr) memcheck/tests/partiallydefinedeq (stderr) memcheck/tests/pointer-trace (stderr) memcheck/tests/sigkill (stderr) memcheck/tests/stack_changes (stderr) none/tests/faultstatus (stderr) none/tests/ppc32/lsw (stdout) none/tests/ppc32/lsw (stderr) none/tests/x86/int (stderr) none/tests/x86/yield (stdout) ================================================= == Results from 24 hours ago == ================================================= Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 187 tests, 15 stderr failures, 1 stdout failure ================= memcheck/tests/addressable (stderr) memcheck/tests/describe-block (stderr) memcheck/tests/erringfds (stderr) memcheck/tests/leak-0 (stderr) memcheck/tests/leak-cycle (stderr) memcheck/tests/leak-regroot (stderr) memcheck/tests/leak-tree (stderr) memcheck/tests/match-overrun (stderr) memcheck/tests/partiallydefinedeq (stderr) memcheck/tests/pointer-trace (stderr) memcheck/tests/sigkill (stderr) memcheck/tests/stack_changes (stderr) none/tests/faultstatus (stderr) none/tests/ppc32/lsw (stdout) none/tests/ppc32/lsw (stderr) none/tests/x86/int (stderr) ================================================= == Difference between 24 hours ago and now == ================================================= *** old.short Sun Sep 11 03:21:57 2005 --- new.short Sun Sep 11 03:28:03 2005 *************** *** 8,10 **** ! == 187 tests, 15 stderr failures, 1 stdout failure ================= memcheck/tests/addressable (stderr) --- 8,10 ---- ! == 187 tests, 15 stderr failures, 2 stdout failures ================= memcheck/tests/addressable (stderr) *************** *** 25,26 **** --- 25,27 ---- none/tests/x86/int (stderr) + none/tests/x86/yield (stdout) |
|
From: Tom H. <th...@cy...> - 2005-09-11 02:25:12
|
Nightly build on ginetta ( i686, Red Hat 8.0 ) started at 2005-09-11 03:10:06 BST Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 187 tests, 3 stderr failures, 1 stdout failure ================= none/tests/faultstatus (stderr) none/tests/ppc32/lsw (stdout) none/tests/ppc32/lsw (stderr) none/tests/x86/int (stderr) |
|
From: Tom H. <th...@cy...> - 2005-09-11 02:20:53
|
Nightly build on dellow ( x86_64, Fedora Core 4 ) started at 2005-09-11 03:10:06 BST Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 165 tests, 7 stderr failures, 1 stdout failure ================= memcheck/tests/sigprocmask (stderr) memcheck/tests/strchr (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) none/tests/ppc32/lsw (stdout) none/tests/ppc32/lsw (stderr) |
|
From: Tom H. <th...@cy...> - 2005-09-11 02:18:55
|
Nightly build on aston ( x86_64, Fedora Core 3 ) started at 2005-09-11 03:05:13 BST Results unchanged from 24 hours ago Checking out valgrind source tree ... done Configuring valgrind ... done Building valgrind ... done Running regression tests ... failed Regression test results follow == 165 tests, 7 stderr failures, 1 stdout failure ================= memcheck/tests/sigprocmask (stderr) memcheck/tests/strchr (stderr) memcheck/tests/vgtest_ume (stderr) memcheck/tests/weirdioctl (stderr) memcheck/tests/xml1 (stderr) none/tests/faultstatus (stderr) none/tests/ppc32/lsw (stdout) none/tests/ppc32/lsw (stderr) |
|
From: <sv...@va...> - 2005-09-11 00:48:25
|
Author: sewardj
Date: 2005-09-11 01:48:18 +0100 (Sun, 11 Sep 2005)
New Revision: 4616
Log:
Many changes:
- make client loading work (m_ume)
- make client stack setup work
- get rid of hack_malloc() as it is no longer necessary
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
branches/ASPACEM/coregrind/m_main.c
branches/ASPACEM/coregrind/m_ume.c
branches/ASPACEM/coregrind/pub_core_aspacemgr.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-10 16:02:0=
3 UTC (rev 4615)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-11 00:48:1=
8 UTC (rev 4616)
@@ -1658,9 +1658,6 @@
=20
i =3D find_nsegment_idx(startPoint);
=20
- if (0) VG_(debugLog)(0,"","startPoint %p, idx %d, reqlen %d\n",=20
- startPoint,i,reqLen);
-
/* Now examine holes from index i back round to i-1. Record the
index first fixed hole and the first floating hole which would
satisfy the request. */
@@ -1776,7 +1773,7 @@
static HChar* show_seg_kind ( NSegment* seg )
{
switch (seg->kind) {
- case SkFree: return "FREE";
+ case SkFree: return " ";
case SkAnon: return seg->isClient ? "anon" : "ANON";
case SkFile: return seg->isClient ? "file" : "FILE";
case SkResvn: return "RSVN";
@@ -1807,7 +1804,7 @@
case SkFree: {
VG_(debugLog)(
logLevel, "aspacem",
- "%3d: %s 0x%08llx-0x%08llx %s\n",
+ "%3d: %s %08llx-%08llx %s\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
@@ -1820,7 +1817,7 @@
case SkAnon:
VG_(debugLog)(
logLevel, "aspacem",
- "%3d: %s 0x%08llx-0x%08llx %s %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%-7l=
ld (%d)\n",
+ "%3d: %s %08llx-%08llx %s %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%-7lld (=
%d)\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
@@ -1839,7 +1836,7 @@
case SkFile:
VG_(debugLog)(
logLevel, "aspacem",
- "%3d: %s 0x%08llx-0x%08llx %s %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%-7l=
ld (%d)\n",
+ "%3d: %s %08llx-%08llx %s %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%-7lld (=
%d)\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
@@ -1858,7 +1855,7 @@
case SkResvn:
VG_(debugLog)(
logLevel, "aspacem",
- "%3d: %s 0x%08llx-0x%08llx %s %c%c%c%c (%s,%s,%llu)\n",
+ "%3d: %s %08llx-%08llx %s %c%c%c%c (%s,%s,%llu)\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
@@ -1902,6 +1899,12 @@
">>>\n");
}
=20
+void VG_(show_nsegments) ( HChar* who )
+{
+ show_nsegments( 0, who );
+}
+
+
/* Add SEG to the collection, deleting/truncating any it overlaps */
static void add_segment ( NSegment* seg )
{
@@ -2034,9 +2037,10 @@
add_segment( &seg );
}
=20
-void VG_(new_aspacem_start) ( void )
+Addr VG_(new_aspacem_start) ( Addr sp_at_startup )
{
NSegment seg;
+ Addr suggested_clstack_top;
=20
aspacem_assert(sizeof(Word) =3D=3D sizeof(void*));
aspacem_assert(sizeof(Addr) =3D=3D sizeof(void*));
@@ -2054,26 +2058,45 @@
/* Establish address limits and block out unusable parts
accordingly. */
=20
- aspacem_minAddr =3D (Addr) 0x00000000;
+ VG_(debugLog)(2, "aspacem",=20
+ " sp_at_startup =3D 0x%llx (supplied)\n",=20
+ (ULong)sp_at_startup );
=20
+ aspacem_minAddr =3D (Addr) 0x04000000; // 64M
+
# if VG_WORDSIZE =3D=3D 8
aspacem_maxAddr =3D (Addr)0x400000000 - 1; // 16G
# else
- aspacem_maxAddr =3D (Addr) 0xC0000000 - 1; // 3G
+ aspacem_maxAddr =3D VG_PGROUNDDN( sp_at_startup ) - 1;
# endif
=20
- aspacem_cStart =3D (Addr)0x04000000; // 64M
- aspacem_vStart =3D (aspacem_minAddr + aspacem_maxAddr + 1) / 2;
+ aspacem_cStart =3D aspacem_minAddr; // 64M
+ aspacem_vStart =3D VG_PGROUNDUP((aspacem_minAddr + aspacem_maxAddr + =
1) / 2);
=20
+ suggested_clstack_top =3D aspacem_maxAddr - 16*1024*1024ULL
+ + VKI_PAGE_SIZE;
+
aspacem_assert(VG_IS_PAGE_ALIGNED(aspacem_minAddr));
aspacem_assert(VG_IS_PAGE_ALIGNED(aspacem_maxAddr + 1));
aspacem_assert(VG_IS_PAGE_ALIGNED(aspacem_cStart));
aspacem_assert(VG_IS_PAGE_ALIGNED(aspacem_vStart));
+ aspacem_assert(VG_IS_PAGE_ALIGNED(suggested_clstack_top + 1));
=20
- VG_(debugLog)(2, "aspacem", "minAddr =3D 0x%llx\n", (ULong)aspacem_mi=
nAddr);
- VG_(debugLog)(2, "aspacem", "maxAddr =3D 0x%llx\n", (ULong)aspacem_ma=
xAddr);
- VG_(debugLog)(2, "aspacem", " cStart =3D 0x%llx\n", (ULong)aspacem_cS=
tart);
- VG_(debugLog)(2, "aspacem", " vStart =3D 0x%llx\n", (ULong)aspacem_vS=
tart);
+ VG_(debugLog)(2, "aspacem",=20
+ " minAddr =3D 0x%08llx (computed)\n",=20
+ (ULong)aspacem_minAddr);
+ VG_(debugLog)(2, "aspacem",=20
+ " maxAddr =3D 0x%08llx (computed)\n",=20
+ (ULong)aspacem_maxAddr);
+ VG_(debugLog)(2, "aspacem",=20
+ " cStart =3D 0x%08llx (computed)\n",=20
+ (ULong)aspacem_cStart);
+ VG_(debugLog)(2, "aspacem",=20
+ " vStart =3D 0x%08llx (computed)\n",=20
+ (ULong)aspacem_vStart);
+ VG_(debugLog)(2, "aspacem",=20
+ "suggested_clstack_top =3D 0x%08llx (computed)\n",=20
+ (ULong)suggested_clstack_top);
=20
if (aspacem_cStart > Addr_MIN) {
init_resvn(&seg, Addr_MIN, aspacem_cStart-1);
@@ -2098,6 +2121,8 @@
VG_(parse_procselfmaps) ( read_maps_callback );
=20
show_nsegments(2, "With contents of /proc/self/maps");
+
+ return suggested_clstack_top;
}
=20
=20
@@ -2221,6 +2246,59 @@
}
=20
=20
+SysRes VG_(mmap_anon_float_client)
+ ( SizeT length, Int prot )
+{
+ SysRes sres;
+ NSegment seg;
+ Addr advised;
+ Bool ok;
+ MapRequest req;
+=20
+ /* Not allowable. */
+ if (length =3D=3D 0)
+ return VG_(mk_SysRes_Error)( VKI_EINVAL );
+
+ /* Ask for an advisory. If it's negative, fail immediately. */
+ req.rkind =3D MAny;
+ req.start =3D 0;
+ req.len =3D length;
+ ok =3D VG_(aspacem_getAdvisory)( &req, True/*client*/, &advised );
+ if (!ok)
+ return VG_(mk_SysRes_Error)( VKI_EINVAL );
+
+ /* We have been advised that the mapping is allowable at the
+ advised address. So hand it off to the kernel, and propagate
+ any resulting failure immediately. */
+ sres =3D do_mmap_NATIVE( advised, length, prot,=20
+ VKI_MAP_FIXED|VKI_MAP_PRIVATE
+ |VKI_MAP_ANONYMOUS, 0, 0 );
+ if (sres.isError)
+ return sres;
+
+ if (sres.val !=3D advised) {
+ /* I don't think this can happen. It means the kernel made a
+ fixed map succeed but not at the requested location. Try to
+ repair the damage, then return saying the mapping failed. */
+ (void)do_munmap_NATIVE( sres.val, length );
+ return VG_(mk_SysRes_Error)( VKI_EINVAL );
+ }
+
+ /* Ok, the mapping succeeded. Now notify the interval map. */
+ init_nsegment( &seg );
+ seg.kind =3D SkAnon;
+ seg.isClient =3D True;
+ seg.start =3D advised;
+ seg.end =3D seg.start + VG_PGROUNDUP(length) - 1;
+ seg.hasR =3D toBool(prot & VKI_PROT_READ);
+ seg.hasW =3D toBool(prot & VKI_PROT_WRITE);
+ seg.hasX =3D toBool(prot & VKI_PROT_EXEC);
+ add_segment( &seg );
+
+ return sres;
+}
+
+
SysRes VG_(map_anon_float_valgrind)( SizeT length )
{
SysRes sres;
@@ -2275,6 +2353,28 @@
}
=20
=20
+SysRes VG_(munmap_client)( Addr base, SizeT length )
+{
+ NSegment seg;
+ SysRes sres;
+
+ if (length =3D=3D 0 || !VG_IS_PAGE_ALIGNED(base))
+ return VG_(mk_SysRes_Error)( VKI_EINVAL );
+
+ sres =3D do_munmap_NATIVE( base, length );
+ if (sres.isError)
+ return sres;
+
+ init_nsegment( &seg );
+ seg.kind =3D SkFree;
+ seg.start =3D base;
+ seg.end =3D seg.start + VG_PGROUNDUP(length) - 1;
+ add_segment( &seg );
+
+ return sres;
+}
+
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
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-10 16:02:03 UTC (rev 4615=
)
+++ branches/ASPACEM/coregrind/m_main.c 2005-09-11 00:48:18 UTC (rev 4616=
)
@@ -104,31 +104,6 @@
=20
=20
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Ultra-basic startup stuff =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-// HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK A
-// temporary bootstrapping allocator, for use until such time as we
-// can get rid of the circularities in allocator dependencies at
-// startup. There is also a copy of this in m_ume.c.
-#define N_HACK_BYTES 10000
-static Int hack_bytes_used =3D 0;
-static HChar hack_bytes[N_HACK_BYTES];
-
-static void* hack_malloc ( Int n )
-{
- VG_(debugLog)(1, "main", " FIXME: hack_malloc(m_main)(%d)\n", n);
- while (n % 16) n++;
- if (hack_bytes_used + n > N_HACK_BYTES) {
- VG_(printf)("valgrind: N_HACK_BYTES(m_main) too low. Sorry.\n");
- VG_(exit)(0);
- }
- hack_bytes_used +=3D n;
- return (void*) &hack_bytes[hack_bytes_used - n];
-}
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D Global entities not referenced from generated code =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
@@ -143,7 +118,15 @@
static Int vg_argc;
static Char **vg_argv;
=20
+/* This should get some address inside the stack on which we gained
+ control (eg, it could be the SP at startup). It doesn't matter
+ exactly where in the stack it is. This value is passed to the
+ address space manager at startup, which uses it to identify the
+ initial stack segment and hence the upper end of the usable address
+ space. */
+static Addr sp_at_startup_new =3D 0;
=20
+
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D Counters, for profiling purposes only =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
@@ -374,13 +357,12 @@
Int preload_core_path_len =3D vgliblen + sizeof(preload_core_so) + 16=
;
Int preload_tool_path_len =3D vgliblen + VG_(strlen)(toolname) + 16=
;
Int preload_string_len =3D preload_core_path_len + preload_tool_pa=
th_len;
- /* FIXME */
- HChar* preload_string =3D /*VG_(malloc)*/ hack_malloc(preload_str=
ing_len);
+ HChar* preload_string =3D VG_(malloc)(preload_string_len);
vg_assert(preload_string);
=20
/* Determine if there's a vgpreload_<tool>.so file, and setup
preload_string. */
- preload_tool_path =3D /*VG_(malloc)*/ hack_malloc(preload_tool_path_l=
en);
+ preload_tool_path =3D VG_(malloc)(preload_tool_path_len);
vg_assert(preload_tool_path);
VG_(snprintf)(preload_tool_path, preload_tool_path_len,
"%s/vgpreload_%s.so", VG_(libdir), toolname);
@@ -391,7 +373,7 @@
VG_(snprintf)(preload_string, preload_string_len, "%s/%s",=20
VG_(libdir), preload_core_so);
}
- //FIXME VG_(free)(preload_tool);
+ VG_(free)(preload_tool_path);
=20
VG_(debugLog)(1, "main", "preload_string =3D %s\n", preload_string);
=20
@@ -401,7 +383,7 @@
envc++;
=20
/* Allocate a new space */
- ret =3D /* FIXME VG_(malloc)*/ hack_malloc (sizeof(HChar *) * (envc+1=
+1)); /* 1 new entry + NULL */
+ ret =3D VG_(malloc) (sizeof(HChar *) * (envc+1+1)); /* 1 new entry + =
NULL */
vg_assert(ret);
=20
/* copy it over */
@@ -415,7 +397,7 @@
for (cpp =3D ret; cpp && *cpp; cpp++) {
if (VG_(memcmp)(*cpp, ld_preload, ld_preload_len) =3D=3D 0) {
Int len =3D VG_(strlen)(*cpp) + preload_string_len;
- HChar *cp =3D /*FIXME VG_(malloc)*/ hack_malloc(len);
+ HChar *cp =3D VG_(malloc)(len);
vg_assert(cp);
=20
VG_(snprintf)(cp, len, "%s%s:%s",
@@ -432,7 +414,7 @@
/* Add the missing bits */
if (!ld_preload_done) {
Int len =3D ld_preload_len + preload_string_len;
- HChar *cp =3D /*FIXME VG_(malloc)*/ hack_malloc (len);
+ HChar *cp =3D VG_(malloc) (len);
vg_assert(cp);
=20
VG_(snprintf)(cp, len, "%s%s", ld_preload, preload_string);
@@ -440,7 +422,7 @@
ret[envc++] =3D cp;
}
=20
- //FIXME VG_(free)(preload_string);
+ VG_(free)(preload_string);
ret[envc] =3D NULL;
=20
return ret;
@@ -472,7 +454,7 @@
=20
The format of the stack is:
=20
- higher address +-----------------+
+ higher address +-----------------+ <- clstack_end
| Trampoline code |
+-----------------+
| |
@@ -496,10 +478,17 @@
| undefined |
: :
*/
-static Addr setup_client_stack(void* init_sp,
- char **orig_argv, char **orig_envp,=20
- const struct exeinfo *info,
- UInt** client_auxv)
+
+/* Allocate and create the initial client stack. It is allocated down
+ from clstack_end, which was previously determined by the address
+ space manager. A modified version of our auxv is copied into the
+ new stack. The returned value is the SP value for the client. */
+static=20
+Addr setup_client_stack( void* init_sp,
+ char **orig_argv, char **orig_envp,=20
+ const struct exeinfo *info,
+ UInt** client_auxv,
+ Addr clstack_end )
{
SysRes res;
char **cpp;
@@ -514,8 +503,11 @@
int argc; /* total argc */
int envc; /* total number of env vars */
unsigned stacksize; /* total client stack size */
- Addr cl_esp; /* client stack base (initial esp) */
+ Addr client_SP; /* client stack base (initial SP) */
+ Addr clstack_start;
=20
+ vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1));
+
/* use our own auxv as a prototype */
orig_auxv =3D VG_(find_auxv)(init_sp);
=20
@@ -574,38 +566,36 @@
=20
if (0) VG_(printf)("stacksize =3D %d\n", stacksize);
=20
- // decide where stack goes!
- VG_(clstk_end) =3D VG_(client_end);
+ /* client_SP is the client's stack pointer */
+ client_SP =3D clstack_end - stacksize;
+ client_SP =3D VG_ROUNDDN(client_SP, 16); /* make stack 16 byte aligne=
d */
=20
- /* cl_esp is the client's stack pointer */
- cl_esp =3D VG_(clstk_end) - stacksize;
- cl_esp =3D VG_ROUNDDN(cl_esp, 16); /* make stack 16 byte aligned */
-
/* base of the string table (aligned) */
- stringbase =3D strtab =3D (char *)(VG_(clstk_end)=20
- - VG_ROUNDUP(stringsize, sizeof(int)));
+ stringbase =3D strtab =3D (char *)clstack_end=20
+ - VG_ROUNDUP(stringsize, sizeof(int));
=20
- VG_(clstk_base) =3D VG_PGROUNDDN(cl_esp);
+ clstack_start =3D VG_PGROUNDDN(client_SP);
=20
- if (0)
+ if (1)
VG_(printf)("stringsize=3D%d auxsize=3D%d stacksize=3D%d\n"
- "clstk_base %p\n"
- "clstk_end %p\n",
+ "clstack_start %p\n"
+ "clstack_end %p\n",
stringsize, auxsize, stacksize,
- (void*)VG_(clstk_base), (void*)VG_(clstk_end));
+ (void*)clstack_start, (void*)clstack_end);
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D alloc=
ate space =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
=20
/* allocate a stack - mmap enough space for the stack */
- res =3D VG_(mmap_native)((void *)VG_PGROUNDDN(cl_esp),=20
- VG_(clstk_end) - VG_PGROUNDDN(cl_esp),
- VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC,=20
- VKI_MAP_PRIVATE|VKI_MAP_ANONYMOUS|VKI_MAP_FIXED, -1, 0);
+ res =3D VG_(mmap_anon_fixed_client)(
+ (void *)clstack_start,
+ clstack_end - clstack_start + 1,
+ VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC
+ );
vg_assert(!res.isError);=20
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D copy =
client stack =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
*/
=20
- ptr =3D (Addr*)cl_esp;
+ ptr =3D (Addr*)client_SP;
=20
/* --- argc --- */
*ptr++ =3D argc; /* client argc */
@@ -613,11 +603,11 @@
/* --- argv --- */
if (info->interp_name) {
*ptr++ =3D (Addr)copy_str(&strtab, info->interp_name);
-//FIXME free(info->interp_name);
+ VG_(free)(info->interp_name);
}
if (info->interp_args) {
*ptr++ =3D (Addr)copy_str(&strtab, info->interp_args);
-//FIXME free(info->interp_args);
+ VG_(free)(info->interp_args);
}
for (cpp =3D orig_argv; *cpp; ptr++, cpp++) {
*ptr =3D (Addr)copy_str(&strtab, *cpp);
@@ -732,12 +722,12 @@
=20
vg_assert((strtab-stringbase) =3D=3D stringsize);
=20
- /* We know the initial ESP is pointing at argc/argv */
- VG_(client_argc) =3D *(Int*)cl_esp;
- VG_(client_argv) =3D (Char**)(cl_esp + sizeof(HWord));
+ /* We know the initial SP is pointing at argc/argv */
+ VG_(client_argc) =3D *(Int*)client_SP;
+ VG_(client_argv) =3D (Char**)(client_SP + sizeof(HWord));
=20
- if (0) VG_(printf)("startup SP =3D %p\n", cl_esp);
- return cl_esp;
+ if (0) VG_(printf)("startup SP =3D %p\n", client_SP);
+ return client_SP;
}
=20
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
@@ -1242,7 +1232,7 @@
}
skip_arg:
if (arg !=3D vg_argv[i]) {
- //FIXME free(arg);
+ VG_(free)(arg);
}
}
=20
@@ -2039,9 +2029,9 @@
HChar** env;
Int need_help =3D 0; // 0 =3D no, 1 =3D --help, 2 =3D --help=
-debug
struct exeinfo info;
- Addr client_eip;
- Addr sp_at_startup; /* client's SP at the point we
- gained control. */
+ Addr initial_client_IP;
+ Addr initial_client_SP;
+ Addr clstack_top;
UInt* client_auxv;
Int loglevel, i;
struct vki_rlimit zero =3D { 0, 0 };
@@ -2081,13 +2071,13 @@
messages all through startup. */
VG_(debugLog_startup)(loglevel, "Stage 2 (main)");
VG_(debugLog)(1, "main", "Welcome to Valgrind version "=20
- VERSION " debug logging.\n");
+ VERSION " debug logging\n");
=20
//--------------------------------------------------------------
// Ensure we're on a plausible stack.
// p: logging
//--------------------------------------------------------------
- VG_(debugLog)(1, "main", "Checking we're on a plausible stack\n");
+ VG_(debugLog)(1, "main", "Checking current stack is plausible");
{ 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 */
@@ -2095,18 +2085,34 @@
/* something's wrong. Stop. */
VG_(debugLog)(0, "main", "Root stack %p to %p, a local %p\n",
limLo, limHi, aLocal );
- VG_(debugLog)(0, "main", "FATAL: Initial stack switched failed.\=
n");
- VG_(debugLog)(0, "main", " Cannot continue. Sorry.\n");
+ VG_(debugLog)(0, "main", "Valgrind: FATAL: "
+ "Initial stack switched failed.\n");
+ VG_(debugLog)(0, "main", " Cannot continue. Sorry.\n");
VG_(exit)(1);
}
}
=20
//--------------------------------------------------------------
- // Start up the address space manager
+ // Ensure we have a plausible pointer to the stack on which
+ // we gained control (not the current stack!)
+ // p: logging
+ //--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Checking initial stack was noted\n");
+ if (sp_at_startup_new =3D=3D 0) {
+ VG_(debugLog)(0, "main", "Valgrind: FATAL: "
+ "Initial stack was not noted.\n");
+ VG_(debugLog)(0, "main", " Cannot continue. Sorry.\n");
+ VG_(exit)(1);
+ }
+
+
+ //--------------------------------------------------------------
+ // Start up the address space manager, and determine the
+ // approximate location of the client's stack
// p: logging, plausible-stack
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Starting the address space manager\n");
- VG_(new_aspacem_start)();
+ clstack_top =3D VG_(new_aspacem_start)( sp_at_startup_new );
VG_(debugLog)(1, "main", "Address space manager is running\n");
=20
//--------------------------------------------------------------
@@ -2151,19 +2157,17 @@
// at that point.
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Doing scan_auxv()\n");
- {
- void* init_sp =3D argv - 1;
- scan_auxv(init_sp);
+ { void* init_sp =3D argv - 1;
+ scan_auxv(init_sp);
}
=20
//--------------------------------------------------------------
// Look for alternative libdir =20
// p: none
//--------------------------------------------------------------
- {
- HChar *cp =3D VG_(getenv)(VALGRINDLIB);
- if (cp !=3D NULL)
- VG_(libdir) =3D cp;
+ { HChar *cp =3D VG_(getenv)(VALGRINDLIB);
+ if (cp !=3D NULL)
+ VG_(libdir) =3D cp;
}
=20
//--------------------------------------------------------------
@@ -2209,7 +2213,7 @@
// p: layout_remaining_space [so there's space]
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Loading client\n");
- load_client(cl_argv, exec, need_help, &info, &client_eip);
+ load_client(cl_argv, exec, need_help, &info, &initial_client_IP);
=20
//--------------------------------------------------------------
// Everything in place, remove padding done by stage1
@@ -2233,18 +2237,19 @@
// p: fix_environment() [for 'env']
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Setup client stack\n");
- {=20
- void* init_sp =3D argv - 1;
+ { void* init_sp =3D argv - 1;
=20
- sp_at_startup =3D setup_client_stack(init_sp, cl_argv, env, &info,
- &client_auxv);
- //FIXME free(env);
+ initial_client_SP
+ =3D setup_client_stack(init_sp, cl_argv, env, &info,
+ &client_auxv,clstack_top);
+ VG_(free)(env);
}
=20
VG_(debugLog)(2, "main",
"Client info: "
- "entry=3D%p client esp=3D%p vg_argc=3D%d brkbase=3D%=
p\n",
- (void*)client_eip, (void*)sp_at_startup, vg_argc,=20
+ "entry=3D%p client_SP=3D%p vg_argc=3D%d brkbase=3D%p=
\n",
+ (void*)initial_client_IP,=20
+ (void*)initial_client_SP, vg_argc,=20
(void*)VG_(brk_base) );
=20
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
@@ -2263,8 +2268,8 @@
// Build segment map (Valgrind segments only)
// p: tl_pre_clo_init() [to setup new_mem_startup tracker]
//--------------------------------------------------------------
- VG_(debugLog)(1, "main", "Parse /proc/self/maps (round 1)\n");
- VG_(parse_procselfmaps) ( build_valgrind_map_callback );
+ //VG_(debugLog)(1, "main", "Parse /proc/self/maps (round 1)\n");
+ //VG_(parse_procselfmaps) ( build_valgrind_map_callback );
=20
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
// Can use VG_(arena_malloc)() with non-CORE arena after segments set=
up
@@ -2303,10 +2308,10 @@
// p: setup_client_stack() [for 'sp_at_startup']
// p: init tool [for 'new_mem_startup']
//--------------------------------------------------------------
- VG_(debugLog)(1, "main", "Parse /proc/self/maps (round 2)\n");
- sp_at_startup___global_arg =3D sp_at_startup;
- VG_(parse_procselfmaps) ( build_segment_map_callback ); /* everythin=
g */
- sp_at_startup___global_arg =3D 0;
+ //VG_(debugLog)(1, "main", "Parse /proc/self/maps (round 2)\n");
+ //sp_at_startup___global_arg =3D sp_at_startup;
+ //VG_(parse_procselfmaps) ( build_segment_map_callback ); /* everyth=
ing */
+ //sp_at_startup___global_arg =3D 0;
=20
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
// Can use VG_(map)() after segments set up
@@ -2367,7 +2372,8 @@
// setup_scheduler() [for the rest of state 1 stuff]
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Initialise thread 1's state\n");
- init_thread1state(client_eip, sp_at_startup, &VG_(threads)[1].arch);
+ init_thread1state( initial_client_IP, initial_client_SP,=20
+ &VG_(threads)[1].arch);
=20
//--------------------------------------------------------------
// Initialise the pthread model
@@ -2742,10 +2748,12 @@
void _start_in_C ( UWord* pArgc );
void _start_in_C ( UWord* pArgc )
{
+ Int r;
Word argc =3D pArgc[0];
HChar** argv =3D (HChar**)&pArgc[1];
HChar** envp =3D (HChar**)&pArgc[1+argc+1];
- Int r =3D main( (Int)argc, argv, envp );
+ sp_at_startup_new =3D (Addr)pArgc;
+ r =3D main( (Int)argc, argv, envp );
VG_(exit)(r);
}
=20
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-10 16:02:03 UTC (rev 4615)
+++ branches/ASPACEM/coregrind/m_ume.c 2005-09-11 00:48:18 UTC (rev 4616)
@@ -55,33 +55,6 @@
#include "pub_core_ume.h"
=20
=20
-// HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK A
-// temporary bootstrapping allocator, for use until such time as we
-// can get rid of the circularites in allocator dependencies at
-// startup. There is also a copy of this in m_main.c.
-#define N_HACK_BYTES 10000
-static Int hack_bytes_used =3D 0;
-static HChar hack_bytes[N_HACK_BYTES];
-
-static void* hack_malloc ( Int n )
-{
- VG_(debugLog)(1, "ume", " FIXME: hack_malloc(m_ume)(%d)\n", n);
- while (n % 16) n++;
- if (hack_bytes_used + n > N_HACK_BYTES) {
- VG_(printf)("valgrind: N_HACK_BYTES(m_ume) too low. Sorry.\n");
- VG_(exit)(0);
- }
- hack_bytes_used +=3D n;
- return (void*) &hack_bytes[hack_bytes_used - n];
-}
-
-static HChar* hack_strdup ( HChar* str )
-{
- HChar* p =3D hack_malloc( 1 + VG_(strlen)(str) );
- VG_(strcpy)(p, str);
- return p;
-}
-
#if VG_WORDSIZE =3D=3D 8
#define ESZ(x) Elf64_##x
#elif VG_WORDSIZE =3D=3D 4
@@ -298,7 +271,7 @@
struct elfinfo *readelf(int fd, const char *filename)
{
SysRes sres;
- struct elfinfo *e =3D hack_malloc(sizeof(*e));
+ struct elfinfo *e =3D VG_(malloc)(sizeof(*e));
int phsz;
=20
vg_assert(e);
@@ -341,21 +314,21 @@
}
=20
phsz =3D sizeof(ESZ(Phdr)) * e->e.e_phnum;
- e->p =3D hack_malloc(phsz);
+ e->p =3D VG_(malloc)(phsz);
vg_assert(e->p);
=20
sres =3D VG_(pread)(fd, e->p, phsz, e->e.e_phoff);
if (sres.isError || sres.val !=3D phsz) {
VG_(printf)("valgrind: can't read phdr: %s\n",=20
VG_(strerror)(sres.val));
- //FIXME VG_(free)(e->p);
+ VG_(free)(e->p);
goto bad;
}
=20
return e;
=20
bad:
- //FIXME VG_(free)(e);
+ VG_(free)(e);
return NULL;
}
=20
@@ -412,12 +385,13 @@
//
// The condition handles the case of a zero-length segment.
if (VG_PGROUNDUP(bss)-VG_PGROUNDDN(addr) > 0) {
- res =3D VG_(mmap_native)
- ((char *)VG_PGROUNDDN(addr),
+ res =3D VG_(mmap_file_fixed_client)
+ ((void *)VG_PGROUNDDN(addr),
VG_PGROUNDUP(bss)-VG_PGROUNDDN(addr),
- prot, VKI_MAP_FIXED|VKI_MAP_PRIVATE,=20
+ prot, /*VKI_MAP_FIXED|VKI_MAP_PRIVATE, */
e->fd, VG_PGROUNDDN(off)
);
+ if (0) VG_(show_nsegments)("after native 1");
check_mmap(res, (char*)VG_PGROUNDDN(addr),
VG_PGROUNDUP(bss)-VG_PGROUNDDN(addr));
}
@@ -428,6 +402,7 @@
=20
bytes =3D VG_PGROUNDUP(brkaddr)-VG_PGROUNDUP(bss);
if (bytes > 0) {
+ VG_(debugLog)(0,"","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
@@ -509,7 +484,7 @@
break;
=09
case PT_INTERP: {
- char *buf =3D hack_malloc(ph->p_filesz+1);
+ char *buf =3D VG_(malloc)(ph->p_filesz+1);
int j;
int intfd;
int baseaddr_set;
@@ -530,7 +505,7 @@
VG_(printf)("valgrind: m_ume.c: can't read interpreter\n");
return 1;
}
- //FIXME VG_(free)(buf);
+ VG_(free)(buf);
=20
baseaddr_set =3D 0;
for(j =3D 0; j < interp->e.e_phnum; j++) {
@@ -593,13 +568,20 @@
flags |=3D VKI_MAP_FIXED;
}
=20
- res =3D VG_(mmap_native)(base, interp_size, VKI_PROT_NONE, flags, =
-1, 0);
+ if (base)
+ res =3D VG_(mmap_anon_fixed_client)(base, interp_size, VKI_PROT=
_NONE);
+ else
+ res =3D VG_(mmap_anon_float_client)(interp_size, VKI_PROT_NONE)=
;
+
+ if (0) VG_(show_nsegments)("after native 3");
+
check_mmap(res, base, interp_size);
vg_assert(!res.isError);
base =3D (Char*)res.val;
=20
- baseoff =3D base - interp_addr;
+ VG_(munmap_client)( res.val, interp_size );
=20
+ baseoff =3D base - interp_addr;
mapelf(interp, (ESZ(Addr))baseoff);
=20
VG_(close)(interp->fd);
@@ -607,8 +589,8 @@
entry =3D baseoff + interp->e.e_entry;
info->interp_base =3D (ESZ(Addr))base;
=20
- //FIXME VG_(free)(interp->p);
- //FIXME VG_(free)(interp);
+ VG_(free)(interp->p);
+ VG_(free)(interp);
} else
entry =3D (void *)(ebase + e->e.e_entry);
=20
@@ -617,8 +599,8 @@
=20
info->init_eip =3D (Addr)entry;
=20
- //FIXME VG_(free)(e->p);
- //FIXME VG_(free)(e);
+ VG_(free)(e->p);
+ VG_(free)(e);
=20
return 0;
}
@@ -666,10 +648,10 @@
*cp =3D '\0';
}
=20
- info->interp_name =3D hack_strdup(interp);
+ info->interp_name =3D VG_(strdup)(interp);
vg_assert(NULL !=3D info->interp_name);
if (arg !=3D NULL && *arg !=3D '\0') {
- info->interp_args =3D hack_strdup(arg);
+ info->interp_args =3D VG_(strdup)(arg);
vg_assert(NULL !=3D info->interp_args);
}
=20
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-10 16:02:03 U=
TC (rev 4615)
+++ branches/ASPACEM/coregrind/pub_core_aspacemgr.h 2005-09-11 00:48:18 U=
TC (rev 4616)
@@ -161,8 +161,13 @@
HChar
VgStack[VG_STACK_GUARD_SZB + VG_STACK_ACTIVE_SZB + VG_STACK_GUARD_SZB=
];
=20
-extern void VG_(new_aspacem_start) ( void );
+/* 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 );
=20
typedef
struct {
@@ -185,11 +190,17 @@
( void* startV, SizeT length, Int prot );
=20
extern
+SysRes VG_(mmap_anon_float_client)
+ ( SizeT length, Int prot );
+
+extern
SysRes VG_(map_anon_float_valgrind)( SizeT cszB );
=20
extern ULong VG_(aspacem_get_anonsize_total)( void );
=20
+extern SysRes VG_(munmap_client)( Addr base, SizeT length );
=20
+
#endif // __PUB_CORE_ASPACEMGR_H
=20
/*--------------------------------------------------------------------*/
|