|
From: <sv...@va...> - 2008-08-18 21:47:07
|
Author: sewardj
Date: 2008-08-18 22:47:11 +0100 (Mon, 18 Aug 2008)
New Revision: 8521
Log:
The address space manager, and in particular the NSegment type,
hardwire the assumption that an inode number is a UWord, that is, a
host word. There's no reason for that assumption to be valid; an
inode number could be a 64-bit int even on a 32 bit platform (eg w.r.t
sys_stat64). This commit changes inode numbers and, for good measure,
dev numbers, to be 64-bit regardless.
Modified:
trunk/coregrind/m_aspacemgr/aspacemgr-common.c
trunk/coregrind/m_aspacemgr/aspacemgr-linux.c
trunk/coregrind/m_aspacemgr/priv_aspacemgr.h
trunk/include/pub_tool_aspacemgr.h
Modified: trunk/coregrind/m_aspacemgr/aspacemgr-common.c
===================================================================
--- trunk/coregrind/m_aspacemgr/aspacemgr-common.c 2008-08-08 08:38:23 UTC (rev 8520)
+++ trunk/coregrind/m_aspacemgr/aspacemgr-common.c 2008-08-18 21:47:11 UTC (rev 8521)
@@ -255,8 +255,8 @@
/* Get the dev, inode and mode info for a file descriptor, if
possible. Returns True on success. */
Bool ML_(am_get_fd_d_i_m)( Int fd,
- /*OUT*/UWord* dev,
- /*OUT*/UWord* ino, /*OUT*/UInt* mode )
+ /*OUT*/ULong* dev,
+ /*OUT*/ULong* ino, /*OUT*/UInt* mode )
{
SysRes res;
struct vki_stat buf;
@@ -267,17 +267,17 @@
struct vki_stat64 buf64;
res = VG_(do_syscall2)(__NR_fstat64, fd, (UWord)&buf64);
if (!res.isError) {
- *dev = buf64.st_dev;
- *ino = buf64.st_ino;
- *mode = buf64.st_mode;
+ *dev = (ULong)buf64.st_dev;
+ *ino = (ULong)buf64.st_ino;
+ *mode = (UInt) buf64.st_mode;
return True;
}
# endif
res = VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf);
if (!res.isError) {
- *dev = buf.st_dev;
- *ino = buf.st_ino;
- *mode = buf.st_mode;
+ *dev = (ULong)buf.st_dev;
+ *ino = (ULong)buf.st_ino;
+ *mode = (UInt) buf.st_mode;
return True;
}
return False;
Modified: trunk/coregrind/m_aspacemgr/aspacemgr-linux.c
===================================================================
--- trunk/coregrind/m_aspacemgr/aspacemgr-linux.c 2008-08-08 08:38:23 UTC (rev 8520)
+++ trunk/coregrind/m_aspacemgr/aspacemgr-linux.c 2008-08-18 21:47:11 UTC (rev 8521)
@@ -329,7 +329,7 @@
static void parse_procselfmaps (
void (*record_mapping)( Addr addr, SizeT len, UInt prot,
- UInt dev, UInt ino, ULong offset,
+ ULong dev, ULong ino, ULong offset,
const UChar* filename ),
void (*record_gap)( Addr addr, SizeT len )
);
@@ -343,8 +343,8 @@
/* Extract the device, inode and mode numbers for a fd. */
static
-Bool get_inode_for_fd ( Int fd, /*OUT*/UWord* dev,
- /*OUT*/UWord* ino, /*OUT*/UInt* mode )
+Bool get_inode_for_fd ( Int fd, /*OUT*/ULong* dev,
+ /*OUT*/ULong* ino, /*OUT*/UInt* mode )
{
return ML_(am_get_fd_d_i_m)(fd, dev, ino, mode);
}
@@ -503,7 +503,7 @@
(ULong)seg->start,
(ULong)seg->end,
show_ShrinkMode(seg->smode),
- (ULong)seg->dev, (ULong)seg->ino, (ULong)seg->offset, seg->fnIdx,
+ seg->dev, seg->ino, seg->offset, seg->fnIdx,
(Int)seg->hasR, (Int)seg->hasW, (Int)seg->hasX, (Int)seg->hasT,
(Int)seg->mark,
name
@@ -552,7 +552,7 @@
seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
seg->isCH ? 'H' : '-',
- (ULong)seg->dev, (ULong)seg->ino, (Long)seg->offset, seg->fnIdx
+ seg->dev, seg->ino, (Long)seg->offset, seg->fnIdx
);
break;
@@ -871,7 +871,7 @@
static Bool sync_check_ok = False;
static void sync_check_mapping_callback ( Addr addr, SizeT len, UInt prot,
- UInt dev, UInt ino, ULong offset,
+ ULong dev, ULong ino, ULong offset,
const UChar* filename )
{
Int iLo, iHi, i;
@@ -908,7 +908,7 @@
These kernels report which mappings are really executable in
the /proc/self/maps output rather than mirroring what was asked
for when each mapping was created. In order to cope with this we
- have a slopyXcheck mode which we enable on x86 - in this mode we
+ have a sloppyXcheck mode which we enable on x86 - in this mode we
allow the kernel to report execute permission when we weren't
expecting it but not vice versa. */
sloppyXcheck = False;
@@ -988,7 +988,7 @@
"segment mismatch: kernel's seg:\n");
VG_(debugLog)(0,"aspacem",
"start=0x%llx end=0x%llx prot=%u "
- "dev=%u ino=%u offset=%lld name=\"%s\"\n",
+ "dev=%llu ino=%llu offset=%lld name=\"%s\"\n",
(ULong)addr, ((ULong)addr) + ((ULong)len) - 1,
prot, dev, ino, offset,
filename ? (HChar*)filename : "(none)" );
@@ -1469,7 +1469,7 @@
/*-----------------------------------------------------------------*/
static void read_maps_callback ( Addr addr, SizeT len, UInt prot,
- UInt dev, UInt ino, ULong offset,
+ ULong dev, ULong ino, ULong offset,
const UChar* filename )
{
NSegment seg;
@@ -1517,13 +1517,12 @@
aspacem_assert(sizeof(SizeT) == sizeof(void*));
aspacem_assert(sizeof(SSizeT) == sizeof(void*));
- {
- /* If these fail, we'd better change the type of dev and ino in
- NSegment accordingly. */
- struct vki_stat buf;
- aspacem_assert(sizeof(buf.st_dev) == sizeof(seg.dev));
- aspacem_assert(sizeof(buf.st_ino) == sizeof(seg.ino));
- }
+ /* Check that we can store the largest imaginable dev, ino and
+ offset numbers in an NSegment. */
+ aspacem_assert(sizeof(seg.dev) == 8);
+ aspacem_assert(sizeof(seg.ino) == 8);
+ aspacem_assert(sizeof(seg.offset) == 8);
+ aspacem_assert(sizeof(seg.mode) == 4);
/* Add a single interval covering the entire address space. */
init_nsegment(&seg);
@@ -1878,7 +1877,7 @@
Int fd, Off64T offset )
{
HChar buf[VKI_PATH_MAX];
- UWord dev, ino;
+ ULong dev, ino;
UInt mode;
NSegment seg;
Bool needDiscard;
@@ -2070,7 +2069,7 @@
Addr advised;
Bool ok;
MapRequest req;
- UWord dev, ino;
+ ULong dev, ino;
UInt mode;
HChar buf[VKI_PATH_MAX];
@@ -2347,7 +2346,7 @@
Addr advised;
Bool ok;
MapRequest req;
- UWord dev, ino;
+ ULong dev, ino;
UInt mode;
HChar buf[VKI_PATH_MAX];
@@ -2935,7 +2934,7 @@
return n;
}
-static Int readdec ( const Char* buf, UInt* val )
+static Int readdec64 ( const Char* buf, ULong* val )
{
Int n = 0;
*val = 0;
@@ -3003,7 +3002,7 @@
*/
static void parse_procselfmaps (
void (*record_mapping)( Addr addr, SizeT len, UInt prot,
- UInt dev, UInt ino, ULong offset,
+ ULong dev, ULong ino, ULong offset,
const UChar* filename ),
void (*record_gap)( Addr addr, SizeT len )
)
@@ -3012,9 +3011,9 @@
Addr start, endPlusOne, gapStart;
UChar* filename;
UChar rr, ww, xx, pp, ch, tmp;
- UInt ino, prot;
- UWord maj, min, dev;
- ULong foffset;
+ UInt prot;
+ UWord maj, min;
+ ULong foffset, dev, ino;
foffset = ino = 0; /* keep gcc-4.1.0 happy */
@@ -3072,7 +3071,7 @@
j = readchar(&procmap_buf[i], &ch);
if (j == 1 && ch == ' ') i += j; else goto syntaxerror;
- j = readdec(&procmap_buf[i], &ino);
+ j = readdec64(&procmap_buf[i], &ino);
if (j > 0) i += j; else goto syntaxerror;
goto read_line_ok;
Modified: trunk/coregrind/m_aspacemgr/priv_aspacemgr.h
===================================================================
--- trunk/coregrind/m_aspacemgr/priv_aspacemgr.h 2008-08-08 08:38:23 UTC (rev 8520)
+++ trunk/coregrind/m_aspacemgr/priv_aspacemgr.h 2008-08-18 21:47:11 UTC (rev 8521)
@@ -112,8 +112,8 @@
possible. Returns True on success. */
extern
Bool ML_(am_get_fd_d_i_m)( Int fd,
- /*OUT*/UWord* dev,
- /*OUT*/UWord* ino, /*OUT*/UInt* mode );
+ /*OUT*/ULong* dev,
+ /*OUT*/ULong* ino, /*OUT*/UInt* mode );
/* ------ Implemented seperately in aspacemgr-{linux,aix5}.c ------ */
Modified: trunk/include/pub_tool_aspacemgr.h
===================================================================
--- trunk/include/pub_tool_aspacemgr.h 2008-08-08 08:38:23 UTC (rev 8520)
+++ trunk/include/pub_tool_aspacemgr.h 2008-08-18 21:47:11 UTC (rev 8521)
@@ -99,10 +99,10 @@
/* Shrinkable? (SkResvn only) */
ShrinkMode smode;
/* Associated file (SkFile{C,V} only) */
- UWord dev;
- UWord ino;
+ ULong dev;
+ ULong ino;
+ ULong offset;
UInt mode;
- ULong offset;
Int fnIdx; // file name table index, if name is known
/* Permissions (SkAnon{C,V}, SkFile{C,V} only) */
Bool hasR;
|