|
From: Nicholas N. <nj...@ca...> - 2004-09-10 13:59:40
|
CVS commit by nethercote:
To get 32-bit programs working on Opteron, VG_(valgrind_end) was recently
changed to name the last byte in Valgrind's section, rather than one past the
last byte. This was because the last byte is 0xffffffff, and so one past gave
0x0, which screwed things up.
However, when this change was made, all the places where VG_(valgrind_end) is
used weren't adjusted appropriately. So this commit makes those adjustments.
It also renames the variable as VG_(valgrind_last), which makes the difference
between it and the other VG_(*_end) variables much clearer.
MERGED FROM HEAD
M +1 -1 vg_include.h 1.235.2.1
M +10 -17 vg_main.c 1.198.2.1
M +10 -10 vg_memory.c 1.66.2.1
M +3 -3 vg_mylibc.c 1.85.2.1
--- valgrind/coregrind/vg_include.h #1.235:1.235.2.1
@@ -1275,5 +1275,5 @@ extern Addr VG_(shadow_base); /* tool's
extern Addr VG_(shadow_end);
extern Addr VG_(valgrind_base); /* valgrind's address range */
-extern Addr VG_(valgrind_end);
+extern Addr VG_(valgrind_last); // Nb: last byte, rather than one past the end
extern vki_rlimit VG_(client_rlimit_data); /* client's original rlimit data */
--- valgrind/coregrind/vg_main.c #1.198:1.198.2.1
@@ -110,9 +110,7 @@ Addr VG_(shadow_end);
Addr VG_(valgrind_base); /* valgrind's address range */
-// VG_(valgrind_end) has a slightly different meaning to all the other
-// VG_(*_end) vars -- ie. it names the last byte, whereas the others
-// go one byte past the end.
-
-Addr VG_(valgrind_end);
+// Note that VG_(valgrind_last) names the last byte of the section, whereas
+// the VG_(*_end) vars name the byte one past the end of the section.
+Addr VG_(valgrind_last);
vki_rlimit VG_(client_rlimit_data);
@@ -438,10 +436,5 @@ static void layout_remaining_space(Addr
VG_(valgrind_base) = (addr_t)&kickstart_base;
-
- // VG_(valgrind_end) has a slightly different meaning to all the other
- // VG_(*_end) vars -- ie. it names the last byte, whereas the others
- // go one byte past the end.
-
- VG_(valgrind_end) = ROUNDUP(argc_addr, 0x10000) - 1; // stack
+ VG_(valgrind_last) = ROUNDUP(argc_addr, 0x10000) - 1; // stack
// This gives the client the largest possible address space while
@@ -469,5 +462,5 @@ static void layout_remaining_space(Addr
"shadow_end %8x (%dMB)\n"
"valgrind_base %8x (%dMB)\n"
- "valgrind_end %8x\n",
+ "valgrind_last %8x\n",
VG_(client_base), SEGSIZE(client_base, client_mapbase),
VG_(client_mapbase), SEGSIZE(client_mapbase, client_end),
@@ -475,6 +468,6 @@ static void layout_remaining_space(Addr
VG_(shadow_base), SEGSIZE(shadow_base, shadow_end),
VG_(shadow_end), SEGSIZE(shadow_end, valgrind_base),
- VG_(valgrind_base), SEGSIZE(valgrind_base, valgrind_end),
- VG_(valgrind_end)
+ VG_(valgrind_base), SEGSIZE(valgrind_base, valgrind_last),
+ VG_(valgrind_last)
);
@@ -2565,5 +2558,5 @@ static void build_valgrind_map_callback
start allocating more memory (note: heap is OK, it's just mmap
which is the problem here). */
- if (start >= VG_(valgrind_base) && (start+size) <= VG_(valgrind_end)) {
+ if (start >= VG_(valgrind_base) && (start+size-1) <= VG_(valgrind_last)) {
flags |= SF_VALGRIND;
VG_(map_file_segment)(start, size, prot, flags, dev, ino, foffset, filename);
@@ -2598,5 +2591,5 @@ static void build_segment_map_callback
flags |= SF_FILE;
- if (start >= VG_(valgrind_base) && (start+size) <= VG_(valgrind_end))
+ if (start >= VG_(valgrind_base) && (start+size-1) <= VG_(valgrind_last))
flags |= SF_VALGRIND;
@@ -2727,5 +2720,5 @@ void VG_(sanity_check_general) ( Bool fo
- -
| valgrind stack ^^^^^^^^^|
- valgrind_end +-------------------------+
+ valgrind_last +-------------------------+
: kernel :
--- valgrind/coregrind/vg_memory.c #1.66:1.66.2.1
@@ -494,5 +494,5 @@ Addr VG_(find_map_space)(Addr addr, UInt
Segment *s;
Addr ret;
- Addr limit = (for_client ? VG_(client_end) : VG_(valgrind_end));
+ Addr limit = (for_client ? VG_(client_end)-1 : VG_(valgrind_last));
if (addr == 0)
@@ -538,5 +538,5 @@ Addr VG_(find_map_space)(Addr addr, UInt
}
- if ((limit - len) < ret)
+ if (((limit - len)+1) < ret)
ret = 0; /* no space */
else
@@ -551,5 +551,5 @@ Addr VG_(find_map_space)(Addr addr, UInt
/* Pad the entire process address space, from VG_(client_base)
- to VG_(valgrind_end) by creating an anonymous and inaccessible
+ to VG_(valgrind_last) by creating an anonymous and inaccessible
mapping over any part of the address space which is not covered
by an entry in the segment list.
@@ -573,5 +573,5 @@ void VG_(pad_address_space)(void)
args[5] = 0;
- while (s && addr < VG_(valgrind_end)) {
+ while (s && addr <= VG_(valgrind_last)) {
if (addr < s->addr) {
args[0] = (UInt)addr;
@@ -585,7 +585,7 @@ void VG_(pad_address_space)(void)
}
- if (addr < VG_(valgrind_end)) {
+ if (addr <= VG_(valgrind_last)) {
args[0] = (UInt)addr;
- args[1] = VG_(valgrind_end) - addr;
+ args[1] = VG_(valgrind_last) - addr + 1;
ret = VG_(do_syscall)(__NR_mmap, (UInt)args);
@@ -603,5 +603,5 @@ void VG_(unpad_address_space)(void)
Int ret;
- while (s && addr < VG_(valgrind_end)) {
+ while (s && addr <= VG_(valgrind_last)) {
if (addr < s->addr) {
ret = VG_(do_syscall)(__NR_munmap, (UInt)addr, s->addr - addr);
@@ -612,6 +612,6 @@ void VG_(unpad_address_space)(void)
}
- if (addr < VG_(valgrind_end)) {
- ret = VG_(do_syscall)(__NR_munmap, (UInt)addr, VG_(valgrind_end) - addr);
+ if (addr <= VG_(valgrind_last)) {
+ ret = VG_(do_syscall)(__NR_munmap, addr, (VG_(valgrind_last) - addr) + 1);
}
@@ -794,5 +794,5 @@ Bool VG_(is_shadow_addr)(Addr a)
Bool VG_(is_valgrind_addr)(Addr a)
{
- return a >= VG_(valgrind_base) && a < VG_(valgrind_end);
+ return a >= VG_(valgrind_base) && a <= VG_(valgrind_last);
}
--- valgrind/coregrind/vg_mylibc.c #1.85:1.85.2.1
@@ -285,5 +285,5 @@ void* VG_(mmap)( void* start, UInt lengt
vg_assert(VG_(client_base) <= res && res+length < VG_(client_end));
} else {
- vg_assert(VG_(valgrind_base) <= res && res+length < VG_(valgrind_end));
+ vg_assert(VG_(valgrind_base) <= res && res+length-1 <= VG_(valgrind_last));
}
@@ -1093,5 +1093,5 @@ static inline ExeContext *get_real_execo
asm("movl %%ebp, %0; movl %%esp, %1" : "=r" (ebp), "=r" (esp));
- stacktop = VG_(valgrind_end);
+ stacktop = VG_(valgrind_last);
VG_(get_sigstack_bounds)( &sigstack_low, &sigstack_high );
if (esp >= sigstack_low && esp < sigstack_high)
@@ -1664,5 +1664,5 @@ void* VG_(get_memory_from_mmap) ( Int nB
if (p != ((void*)(-1))) {
- vg_assert(p >= (void*)VG_(valgrind_base) && p < (void*)VG_(valgrind_end));
+ vg_assert((void*)VG_(valgrind_base) <= p && p <= (void*)VG_(valgrind_last));
tot_alloc += (UInt)nBytes;
if (0)
|