aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2009-01-15 21:29:24 +0000
committernjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2009-01-15 21:29:24 +0000
commitc4431bfe04c7490ea2d74939d222d87f13f30960 (patch)
treed701361ded9eb32398ca0074a77a43fa47ecd200
parenta81465a37cee19a5d8a03ee1b1b51a3cdc7b04c9 (diff)
downloadvalgrind-c4431bfe04c7490ea2d74939d222d87f13f30960.tar.gz
Introduce a new type, PtrdiffT. Replace lots of uses of OffT (all those
that are memory offsets) with PtrdiffT; OffT should only be used for file sizes and offsets. Change Off64T from a ULong to a Long, as it should be. Replace some uses of ULong in the address space manager with Off64T to match. Also add a comment explaining the meanings of the basic types like Addr, OffT, SizeT, etc. Also fix the prototype for VG_(pread) -- the last arg is an OffT, not an Int. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8959 a5019735-40e9-0310-863c-91ae7b9d1cf9
-rw-r--r--callgrind/bb.c10
-rw-r--r--callgrind/global.h4
-rw-r--r--coregrind/m_aspacemgr/aspacemgr-aix5.c2
-rw-r--r--coregrind/m_aspacemgr/aspacemgr-linux.c12
-rw-r--r--coregrind/m_debuginfo/debuginfo.c26
-rw-r--r--coregrind/m_debuginfo/priv_readstabs.h2
-rw-r--r--coregrind/m_debuginfo/priv_storage.h40
-rw-r--r--coregrind/m_debuginfo/priv_tytypes.h4
-rw-r--r--coregrind/m_debuginfo/readdwarf3.c6
-rw-r--r--coregrind/m_debuginfo/readelf.c2
-rw-r--r--coregrind/m_debuginfo/readstabs.c2
-rw-r--r--coregrind/m_debuginfo/tytypes.c8
-rw-r--r--coregrind/m_libcfile.c2
-rw-r--r--coregrind/m_machine.c4
-rw-r--r--coregrind/m_oset.c2
-rw-r--r--coregrind/m_syswrap/priv_syswrap-generic.h2
-rw-r--r--coregrind/m_tooliface.c6
-rw-r--r--coregrind/pub_core_libcfile.h2
-rw-r--r--coregrind/pub_core_tooliface.h7
-rw-r--r--drd/drd_error.h2
-rw-r--r--exp-ptrcheck/h_main.c12
-rw-r--r--exp-ptrcheck/h_main.h4
-rw-r--r--exp-ptrcheck/pc_common.c14
-rw-r--r--include/pub_tool_aspacemgr.h2
-rw-r--r--include/pub_tool_basics.h28
-rw-r--r--include/pub_tool_debuginfo.h14
-rw-r--r--include/pub_tool_machine.h4
-rw-r--r--include/pub_tool_oset.h2
-rw-r--r--include/pub_tool_tooliface.h6
-rw-r--r--memcheck/mc_errors.c18
-rw-r--r--memcheck/mc_main.c7
31 files changed, 137 insertions, 119 deletions
diff --git a/callgrind/bb.c b/callgrind/bb.c
index 7939caed5..8df3539ba 100644
--- a/callgrind/bb.c
+++ b/callgrind/bb.c
@@ -57,7 +57,7 @@ bb_hash* CLG_(get_bb_hash)()
* - BB base as object file offset
*/
static __inline__
-UInt bb_hash_idx(obj_node* obj, OffT offset, UInt size)
+UInt bb_hash_idx(obj_node* obj, PtrdiffT offset, UInt size)
{
return (((Addr)obj) + offset) % size;
}
@@ -118,7 +118,7 @@ void resize_bb_table(void)
* Not initialized:
* - instr_len, cost_count, instr[]
*/
-static BB* new_bb(obj_node* obj, OffT offset,
+static BB* new_bb(obj_node* obj, PtrdiffT offset,
UInt instr_count, UInt cjmp_count, Bool cjmp_inverted)
{
BB* new;
@@ -176,7 +176,7 @@ static BB* new_bb(obj_node* obj, OffT offset,
/* get the BB structure for a BB start address */
static __inline__
-BB* lookup_bb(obj_node* obj, OffT offset)
+BB* lookup_bb(obj_node* obj, PtrdiffT offset)
{
BB* bb;
Int idx;
@@ -199,7 +199,7 @@ obj_node* obj_of_address(Addr addr)
{
obj_node* obj;
DebugInfo* di;
- OffT offset;
+ PtrdiffT offset;
di = VG_(find_seginfo)(addr);
obj = CLG_(get_obj_node)( di );
@@ -292,7 +292,7 @@ void CLG_(delete_bb)(Addr addr)
Int idx, size;
obj_node* obj = obj_of_address(addr);
- OffT offset = addr - obj->offset;
+ PtrdiffT offset = addr - obj->offset;
idx = bb_hash_idx(obj, offset, bbs.size);
bb = bbs.table[idx];
diff --git a/callgrind/global.h b/callgrind/global.h
index b6a033435..926e85881 100644
--- a/callgrind/global.h
+++ b/callgrind/global.h
@@ -304,7 +304,7 @@ struct _CJmpInfo {
*/
struct _BB {
obj_node* obj; /* ELF object of BB */
- OffT offset; /* offset of BB in ELF object file */
+ PtrdiffT offset; /* offset of BB in ELF object file */
BB* next; /* chaining for a hash entry */
VgSectKind sect_kind; /* section of this BB, e.g. PLT */
@@ -463,7 +463,7 @@ struct _obj_node {
Addr start; /* Start address of text segment mapping */
SizeT size; /* Length of mapping */
- OffT offset; /* Offset between symbol address and file offset */
+ PtrdiffT offset; /* Offset between symbol address and file offset */
file_node* files[N_FILE_ENTRIES];
UInt number;
diff --git a/coregrind/m_aspacemgr/aspacemgr-aix5.c b/coregrind/m_aspacemgr/aspacemgr-aix5.c
index e0b7312c0..d862c85d2 100644
--- a/coregrind/m_aspacemgr/aspacemgr-aix5.c
+++ b/coregrind/m_aspacemgr/aspacemgr-aix5.c
@@ -162,7 +162,7 @@ typedef
Bool fromP; // AnonC, AnonV only: originated from PreAlloc?
UChar* fname; // MText, FileV only: filename
UChar* mname; // MText only: member name if present
- ULong offset; // FileV only: file offset
+ Off64T offset; // FileV only: file offset
}
AixSegment;
diff --git a/coregrind/m_aspacemgr/aspacemgr-linux.c b/coregrind/m_aspacemgr/aspacemgr-linux.c
index 38c11f7ba..da388aa97 100644
--- a/coregrind/m_aspacemgr/aspacemgr-linux.c
+++ b/coregrind/m_aspacemgr/aspacemgr-linux.c
@@ -330,7 +330,7 @@ static Int find_nsegment_idx ( Addr a );
static void parse_procselfmaps (
void (*record_mapping)( Addr addr, SizeT len, UInt prot,
- ULong dev, ULong ino, ULong offset,
+ ULong dev, ULong ino, Off64T offset,
const UChar* filename ),
void (*record_gap)( Addr addr, SizeT len )
);
@@ -498,7 +498,7 @@ static void __attribute__ ((unused))
VG_(debugLog)(logLevel, "aspacem",
"NSegment{%s, start=0x%llx, end=0x%llx, smode=%s, dev=%llu, "
- "ino=%llu, offset=%llu, fnIdx=%d, hasR=%d, hasW=%d, hasX=%d, "
+ "ino=%llu, offset=%lld, fnIdx=%d, hasR=%d, hasW=%d, hasX=%d, "
"hasT=%d, mark=%d, name=\"%s\"}\n",
show_SegKind(seg->kind),
(ULong)seg->start,
@@ -553,7 +553,7 @@ static void show_nsegment ( Int logLevel, Int segNo, NSegment* seg )
seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-',
seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
seg->isCH ? 'H' : '-',
- seg->dev, seg->ino, (Long)seg->offset, seg->fnIdx
+ seg->dev, seg->ino, seg->offset, seg->fnIdx
);
break;
@@ -872,7 +872,7 @@ static Bool preen_nsegments ( void )
static Bool sync_check_ok = False;
static void sync_check_mapping_callback ( Addr addr, SizeT len, UInt prot,
- ULong dev, ULong ino, ULong offset,
+ ULong dev, ULong ino, Off64T offset,
const UChar* filename )
{
Int iLo, iHi, i;
@@ -1527,7 +1527,7 @@ static void init_resvn ( /*OUT*/NSegment* seg, Addr start, Addr end )
/*-----------------------------------------------------------------*/
static void read_maps_callback ( Addr addr, SizeT len, UInt prot,
- ULong dev, ULong ino, ULong offset,
+ ULong dev, ULong ino, Off64T offset,
const UChar* filename )
{
NSegment seg;
@@ -3060,7 +3060,7 @@ static void read_procselfmaps_into_buf ( void )
*/
static void parse_procselfmaps (
void (*record_mapping)( Addr addr, SizeT len, UInt prot,
- ULong dev, ULong ino, ULong offset,
+ ULong dev, ULong ino, Off64T offset,
const UChar* filename ),
void (*record_gap)( Addr addr, SizeT len )
)
diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c
index f244f0255..a521a0ee7 100644
--- a/coregrind/m_debuginfo/debuginfo.c
+++ b/coregrind/m_debuginfo/debuginfo.c
@@ -1088,11 +1088,11 @@ static void search_all_loctabs ( Addr ptr, /*OUT*/DebugInfo** pdi,
static
Bool get_sym_name ( Bool demangle, Addr a, Char* buf, Int nbuf,
Bool match_anywhere_in_sym, Bool show_offset,
- Bool findText, /*OUT*/OffT* offsetP )
+ Bool findText, /*OUT*/PtrdiffT* offsetP )
{
DebugInfo* di;
Word sno;
- Int offset;
+ PtrdiffT offset;
search_all_symtabs ( a, &di, &sno, match_anywhere_in_sym, findText );
if (di == NULL)
@@ -1105,7 +1105,7 @@ Bool get_sym_name ( Bool demangle, Addr a, Char* buf, Int nbuf,
}
offset = a - di->symtab[sno].addr;
- if (offsetP) *offsetP = (OffT)offset;
+ if (offsetP) *offsetP = offset;
if (show_offset && offset != 0) {
Char buf2[12];
@@ -1113,7 +1113,7 @@ Bool get_sym_name ( Bool demangle, Addr a, Char* buf, Int nbuf,
Char* end = buf + nbuf;
Int len;
- len = VG_(sprintf)(buf2, "%c%d",
+ len = VG_(sprintf)(buf2, "%c%ld",
offset < 0 ? '-' : '+',
offset < 0 ? -offset : offset);
vg_assert(len < (Int)sizeof(buf2));
@@ -1221,7 +1221,7 @@ Bool VG_(get_fnname_Z_demangle_only) ( Addr a, Char* buf, Int nbuf )
from the symbol start is put into *offset. */
Bool VG_(get_datasym_and_offset)( Addr data_addr,
/*OUT*/Char* dname, Int n_dname,
- /*OUT*/OffT* offset )
+ /*OUT*/PtrdiffT* offset )
{
Bool ok;
vg_assert(n_dname > 1);
@@ -1923,7 +1923,7 @@ Bool VG_(use_CF_info) ( /*MOD*/Addr* ipP,
offset of data_addr from the start of the variable. Note that
regs, which supplies ip,sp,fp values, will be NULL for global
variables, and non-NULL for local variables. */
-static Bool data_address_is_in_var ( /*OUT*/UWord* offset,
+static Bool data_address_is_in_var ( /*OUT*/PtrdiffT* offset,
XArray* /* TyEnt */ tyents,
DiVariable* var,
RegSummary* regs,
@@ -1993,8 +1993,8 @@ static void format_message ( /*OUT*/Char* dname1,
Int n_dname,
Addr data_addr,
DiVariable* var,
- OffT var_offset,
- OffT residual_offset,
+ PtrdiffT var_offset,
+ PtrdiffT residual_offset,
XArray* /*UChar*/ described,
Int frameNo,
ThreadId tid )
@@ -2237,14 +2237,14 @@ Bool consider_vars_in_frame ( /*OUT*/Char* dname1,
&& VG_(sizeXA)(vars) > 0) );
for (j = 0; j < VG_(sizeXA)( vars ); j++) {
DiVariable* var = (DiVariable*)VG_(indexXA)( vars, j );
- SizeT offset;
+ PtrdiffT offset;
if (debug)
VG_(printf)("QQQQ: var:name=%s %#lx-%#lx %#lx\n",
var->name,arange->aMin,arange->aMax,ip);
if (data_address_is_in_var( &offset, di->admin_tyents,
var, &regs,
data_addr, di->data_bias )) {
- OffT residual_offset = 0;
+ PtrdiffT residual_offset = 0;
XArray* described = ML_(describe_type)( &residual_offset,
di->admin_tyents,
var->typeR, offset );
@@ -2331,7 +2331,7 @@ Bool VG_(get_data_description)( /*OUT*/Char* dname1,
of any of them bracket data_addr. */
vars = global_arange->vars;
for (i = 0; i < VG_(sizeXA)( vars ); i++) {
- SizeT offset;
+ PtrdiffT offset;
DiVariable* var = (DiVariable*)VG_(indexXA)( vars, i );
vg_assert(var->name);
/* Note we use a NULL RegSummary* here. It can't make any
@@ -2343,7 +2343,7 @@ Bool VG_(get_data_description)( /*OUT*/Char* dname1,
if (data_address_is_in_var( &offset, di->admin_tyents, var,
NULL/* RegSummary* */,
data_addr, di->data_bias )) {
- OffT residual_offset = 0;
+ PtrdiffT residual_offset = 0;
XArray* described = ML_(describe_type)( &residual_offset,
di->admin_tyents,
var->typeR, offset );
@@ -2896,7 +2896,7 @@ const UChar* VG_(seginfo_filename)(const DebugInfo* di)
return di->filename;
}
-ULong VG_(seginfo_get_text_bias)(const DebugInfo* di)
+PtrdiffT VG_(seginfo_get_text_bias)(const DebugInfo* di)
{
return di->text_present ? di->text_bias : 0;
}
diff --git a/coregrind/m_debuginfo/priv_readstabs.h b/coregrind/m_debuginfo/priv_readstabs.h
index c2d53876f..3028099f5 100644
--- a/coregrind/m_debuginfo/priv_readstabs.h
+++ b/coregrind/m_debuginfo/priv_readstabs.h
@@ -41,7 +41,7 @@
Stabs reader
-------------------- */
extern
-void ML_(read_debuginfo_stabs) ( struct _DebugInfo* di, OffT debug_offset,
+void ML_(read_debuginfo_stabs) ( struct _DebugInfo* di, PtrdiffT debug_offset,
UChar* stabC, Int stab_sz,
UChar* stabstr, Int stabstr_sz );
diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h
index eb1746008..5088aff42 100644
--- a/coregrind/m_debuginfo/priv_storage.h
+++ b/coregrind/m_debuginfo/priv_storage.h
@@ -349,29 +349,29 @@ struct _DebugInfo {
(4) is ensured by canonicaliseCFI.
*/
/* .text */
- Bool text_present;
- Addr text_avma;
- Addr text_svma;
- SizeT text_size;
- OffT text_bias;
+ Bool text_present;
+ Addr text_avma;
+ Addr text_svma;
+ SizeT text_size;
+ PtrdiffT text_bias;
/* .data */
- Bool data_present;
- Addr data_svma;
- Addr data_avma;
- SizeT data_size;
- OffT data_bias;
+ Bool data_present;
+ Addr data_svma;
+ Addr data_avma;
+ SizeT data_size;
+ PtrdiffT data_bias;
/* .sdata */
- Bool sdata_present;
- Addr sdata_svma;
- Addr sdata_avma;
- SizeT sdata_size;
- OffT sdata_bias;
+ Bool sdata_present;
+ Addr sdata_svma;
+ Addr sdata_avma;
+ SizeT sdata_size;
+ PtrdiffT sdata_bias;
/* .bss */
- Bool bss_present;
- Addr bss_svma;
- Addr bss_avma;
- SizeT bss_size;
- OffT bss_bias;
+ Bool bss_present;
+ Addr bss_svma;
+ Addr bss_avma;
+ SizeT bss_size;
+ PtrdiffT bss_bias;
/* .plt */
Bool plt_present;
Addr plt_avma;
diff --git a/coregrind/m_debuginfo/priv_tytypes.h b/coregrind/m_debuginfo/priv_tytypes.h
index 4b6f3e861..1906418f4 100644
--- a/coregrind/m_debuginfo/priv_tytypes.h
+++ b/coregrind/m_debuginfo/priv_tytypes.h
@@ -166,10 +166,10 @@ MaybeULong ML_(sizeOfType)( XArray* /* of TyEnt */ tyents,
/* Describe where in the type 'offset' falls. Caller must
deallocate the resulting XArray. */
-XArray* /*UChar*/ ML_(describe_type)( /*OUT*/OffT* residual_offset,
+XArray* /*UChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
XArray* /* of TyEnt */ tyents,
UWord ty_cuOff,
- OffT offset );
+ PtrdiffT offset );
/* A fast-lookup cache for ML_(TyEnts__index_by_cuOff). Nothing
diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c
index 48e8dbe68..98a9d3378 100644
--- a/coregrind/m_debuginfo/readdwarf3.c
+++ b/coregrind/m_debuginfo/readdwarf3.c
@@ -524,9 +524,9 @@ typedef
typedef
struct {
/* FIXED */
- Addr rx_map_avma;
- SizeT rx_map_size;
- OffT text_bias;
+ Addr rx_map_avma;
+ SizeT rx_map_size;
+ PtrdiffT text_bias;
/* VARIABLE -- count stats */
UWord n_straightforward_biasings;
UWord n_kludgey_biasings;
diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
index b5e6be4a1..ebb661565 100644
--- a/coregrind/m_debuginfo/readelf.c
+++ b/coregrind/m_debuginfo/readelf.c
@@ -206,7 +206,7 @@ Bool get_elf_symbol_info (
Char* sym_name, /* name */
Addr sym_svma, /* address as stated in the object file */
UChar* opd_img, /* oimage of .opd sec (ppc64-linux only) */
- OffT opd_bias, /* for biasing AVMAs found in .opd */
+ PtrdiffT opd_bias, /* for biasing AVMAs found in .opd */
/* OUTPUTS */
Char** sym_name_out, /* name we should record */
Addr* sym_avma_out, /* addr we should record */
diff --git a/coregrind/m_debuginfo/readstabs.c b/coregrind/m_debuginfo/readstabs.c
index 20b886930..85a779fe3 100644
--- a/coregrind/m_debuginfo/readstabs.c
+++ b/coregrind/m_debuginfo/readstabs.c
@@ -80,7 +80,7 @@ typedef enum { N_UNDEF = 0, /* undefined symbol, new stringtab */
/* Read stabs-format debug info. This is all rather horrible because
stabs is a underspecified, kludgy hack.
*/
-void ML_(read_debuginfo_stabs) ( DebugInfo* di, OffT debug_offset,
+void ML_(read_debuginfo_stabs) ( DebugInfo* di, PtrdiffT debug_offset,
UChar* stabC, Int stab_sz,
UChar* stabstr, Int stabstr_sz )
{
diff --git a/coregrind/m_debuginfo/tytypes.c b/coregrind/m_debuginfo/tytypes.c
index ad80691f7..cfd850b4c 100644
--- a/coregrind/m_debuginfo/tytypes.c
+++ b/coregrind/m_debuginfo/tytypes.c
@@ -702,10 +702,10 @@ static void copy_UWord_into_XA ( XArray* /* of UChar */ xa,
VG_(addBytesToXA)( xa, buf, VG_(strlen)(buf));
}
-XArray* /*UChar*/ ML_(describe_type)( /*OUT*/OffT* residual_offset,
+XArray* /*UChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
XArray* /* of TyEnt */ tyents,
UWord ty_cuOff,
- OffT offset )
+ PtrdiffT offset )
{
TyEnt* ty;
XArray* xa = VG_(newXA)( ML_(dinfo_zalloc), "di.tytypes.dt.1",
@@ -737,7 +737,7 @@ XArray* /*UChar*/ ML_(describe_type)( /*OUT*/OffT* residual_offset,
XArray* fieldRs;
UWord fieldR;
TyEnt* field = NULL;
- OffT offMin = 0, offMax1 = 0;
+ PtrdiffT offMin = 0, offMax1 = 0;
if (!ty->Te.TyStOrUn.isStruct) goto done;
fieldRs = ty->Te.TyStOrUn.fieldRs;
if ((!fieldRs) || VG_(sizeXA)(fieldRs) == 0) goto done;
@@ -771,7 +771,7 @@ XArray* /*UChar*/ ML_(describe_type)( /*OUT*/OffT* residual_offset,
if (mul.b != True)
goto done; /* size of field is unknown (?!) */
offMin = res.word;
- offMax1 = offMin + (OffT)mul.ul;
+ offMax1 = offMin + (PtrdiffT)mul.ul;
if (offMin == offMax1)
continue;
vg_assert(offMin < offMax1);
diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c
index 79e27001f..bef8b8641 100644
--- a/coregrind/m_libcfile.c
+++ b/coregrind/m_libcfile.c
@@ -470,7 +470,7 @@ Int VG_(check_executable)(/*OUT*/Bool* is_setuid,
return 0;
}
-SysRes VG_(pread) ( Int fd, void* buf, Int count, Int offset )
+SysRes VG_(pread) ( Int fd, void* buf, Int count, OffT offset )
{
OffT off = VG_(lseek)( fd, (OffT)offset, VKI_SEEK_SET);
if (off < 0)
diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c
index b4b92f75e..cc1d63bc9 100644
--- a/coregrind/m_machine.c
+++ b/coregrind/m_machine.c
@@ -107,7 +107,7 @@ void VG_(set_syscall_return_shadows) ( ThreadId tid,
void
VG_(get_shadow_regs_area) ( ThreadId tid,
/*DST*/UChar* dst,
- /*SRC*/Int shadowNo, OffT offset, SizeT size )
+ /*SRC*/Int shadowNo, PtrdiffT offset, SizeT size )
{
void* src;
ThreadState* tst;
@@ -130,7 +130,7 @@ VG_(get_shadow_regs_area) ( ThreadId tid,
void
VG_(set_shadow_regs_area) ( ThreadId tid,
- /*DST*/Int shadowNo, OffT offset, SizeT size,
+ /*DST*/Int shadowNo, PtrdiffT offset, SizeT size,
/*SRC*/const UChar* src )
{
void* dst;
diff --git a/coregrind/m_oset.c b/coregrind/m_oset.c
index b213597fa..2955ef228 100644
--- a/coregrind/m_oset.c
+++ b/coregrind/m_oset.c
@@ -282,7 +282,7 @@ static inline Bool stackPop(AvlTree* t, AvlNode** n, Int* i)
/*--------------------------------------------------------------------*/
// The underscores avoid GCC complaints about overshadowing global names.
-AvlTree* VG_(OSetGen_Create)(OffT _keyOff, OSetCmp_t _cmp,
+AvlTree* VG_(OSetGen_Create)(PtrdiffT _keyOff, OSetCmp_t _cmp,
OSetAlloc_t _alloc, HChar* _cc,
OSetFree_t _free)
{
diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h
index 0e71fc19d..a2d327ce1 100644
--- a/coregrind/m_syswrap/priv_syswrap-generic.h
+++ b/coregrind/m_syswrap/priv_syswrap-generic.h
@@ -67,7 +67,7 @@ Bool ML_(do_sigkill)(Int pid, Int tgid);
extern
void
ML_(notify_aspacem_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
- UInt mm_flags, Int fd, ULong offset );
+ UInt mm_flags, Int fd, Off64T offset );
DECL_TEMPLATE(generic, sys_ni_syscall); // * P -- unimplemented
diff --git a/coregrind/m_tooliface.c b/coregrind/m_tooliface.c
index cc4ac1dc4..6504aa97b 100644
--- a/coregrind/m_tooliface.c
+++ b/coregrind/m_tooliface.c
@@ -391,10 +391,10 @@ DEF0(track_pre_mem_read_asciiz, CorePart, ThreadId, Char*, Addr)
DEF0(track_pre_mem_write, CorePart, ThreadId, Char*, Addr, SizeT)
DEF0(track_post_mem_write, CorePart, ThreadId, Addr, SizeT)
-DEF0(track_pre_reg_read, CorePart, ThreadId, Char*, OffT, SizeT)
-DEF0(track_post_reg_write, CorePart, ThreadId, OffT, SizeT)
+DEF0(track_pre_reg_read, CorePart, ThreadId, Char*, PtrdiffT, SizeT)
+DEF0(track_post_reg_write, CorePart, ThreadId, PtrdiffT, SizeT)
-DEF0(track_post_reg_write_clientcall_return, ThreadId, OffT, SizeT, Addr)
+DEF0(track_post_reg_write_clientcall_return, ThreadId, PtrdiffT, SizeT, Addr)
DEF0(track_start_client_code, ThreadId, ULong)
DEF0(track_stop_client_code, ThreadId, ULong)
diff --git a/coregrind/pub_core_libcfile.h b/coregrind/pub_core_libcfile.h
index bbb38bae6..8da1871b5 100644
--- a/coregrind/pub_core_libcfile.h
+++ b/coregrind/pub_core_libcfile.h
@@ -74,7 +74,7 @@ extern Int VG_(access) ( HChar* path, Bool irusr, Bool iwusr, Bool ixusr );
extern Int VG_(check_executable)(/*OUT*/Bool* is_setuid,
HChar* f, Bool allow_setuid);
-extern SysRes VG_(pread) ( Int fd, void* buf, Int count, Int offset );
+extern SysRes VG_(pread) ( Int fd, void* buf, Int count, OffT offset );
/* Create and open (-rw------) a tmp file name incorporating said arg.
Returns -1 on failure, else the fd of the file. If fullname is
diff --git a/coregrind/pub_core_tooliface.h b/coregrind/pub_core_tooliface.h
index ca6494b92..1e1535ac6 100644
--- a/coregrind/pub_core_tooliface.h
+++ b/coregrind/pub_core_tooliface.h
@@ -212,9 +212,10 @@ typedef struct {
void (*track_pre_mem_write) (CorePart, ThreadId, Char*, Addr, SizeT);
void (*track_post_mem_write) (CorePart, ThreadId, Addr, SizeT);
- void (*track_pre_reg_read) (CorePart, ThreadId, Char*, OffT, SizeT);
- void (*track_post_reg_write)(CorePart, ThreadId, OffT, SizeT);
- void (*track_post_reg_write_clientcall_return)(ThreadId, OffT, SizeT, Addr);
+ void (*track_pre_reg_read) (CorePart, ThreadId, Char*, PtrdiffT, SizeT);
+ void (*track_post_reg_write)(CorePart, ThreadId, PtrdiffT, SizeT);
+ void (*track_post_reg_write_clientcall_return)(ThreadId, PtrdiffT, SizeT,
+ Addr);
void (*track_start_client_code)(ThreadId, ULong);
void (*track_stop_client_code) (ThreadId, ULong);
diff --git a/drd/drd_error.h b/drd/drd_error.h
index 6b56051c3..b72b82ea5 100644
--- a/drd/drd_error.h
+++ b/drd/drd_error.h
@@ -81,7 +81,7 @@ typedef
struct { // Used by:
AddrKind akind; // ALL
SizeT size; // ALL
- OffT rwoffset; // ALL
+ PtrdiffT rwoffset; // ALL
ExeContext* lastchange; // Mallocd
DrdThreadId stack_tid; // Stack
DebugInfo* debuginfo; // Segment
diff --git a/exp-ptrcheck/h_main.c b/exp-ptrcheck/h_main.c
index f69a47172..2678b7ae9 100644
--- a/exp-ptrcheck/h_main.c
+++ b/exp-ptrcheck/h_main.c
@@ -1915,7 +1915,7 @@ static Bool is_integer_guest_reg ( Int offset, Int szB )
/* these assume guest and host have the same endianness and
word size (probably). */
static UWord get_guest_intreg ( ThreadId tid, Int shadowNo,
- OffT offset, SizeT size )
+ PtrdiffT offset, SizeT size )
{
UChar tmp[ 2 + sizeof(UWord) ];
tl_assert(size == sizeof(UWord));
@@ -1929,7 +1929,7 @@ static UWord get_guest_intreg ( ThreadId tid, Int shadowNo,
return * ((UWord*) &tmp[1] ); /* MISALIGNED LOAD */
}
static void put_guest_intreg ( ThreadId tid, Int shadowNo,
- OffT offset, SizeT size, UWord w )
+ PtrdiffT offset, SizeT size, UWord w )
{
tl_assert(size == sizeof(UWord));
tl_assert(0 == (offset % sizeof(UWord)));
@@ -1950,7 +1950,7 @@ static void init_shadow_registers ( ThreadId tid )
}
}
-static void post_reg_write_nonptr ( ThreadId tid, OffT offset, SizeT size )
+static void post_reg_write_nonptr ( ThreadId tid, PtrdiffT offset, SizeT size )
{
// syscall_return: Default is non-pointer. If it really is a pointer
// (eg. for mmap()), SK_(post_syscall) sets it again afterwards.
@@ -1968,7 +1968,7 @@ static void post_reg_write_nonptr ( ThreadId tid, OffT offset, SizeT size )
}
static void post_reg_write_nonptr_or_unknown ( ThreadId tid,
- OffT offset, SizeT size )
+ PtrdiffT offset, SizeT size )
{
// deliver_signal: called from two places; one sets the reg to zero, the
// other sets the stack pointer.
@@ -1985,7 +1985,7 @@ static void post_reg_write_nonptr_or_unknown ( ThreadId tid,
}
void h_post_reg_write_demux ( CorePart part, ThreadId tid,
- OffT guest_state_offset, SizeT size)
+ PtrdiffT guest_state_offset, SizeT size)
{
if (0)
VG_(printf)("post_reg_write_demux: tid %d part %d off %ld size %ld\n",
@@ -2015,7 +2015,7 @@ void h_post_reg_write_demux ( CorePart part, ThreadId tid,
}
}
-void h_post_reg_write_clientcall(ThreadId tid, OffT guest_state_offset,
+void h_post_reg_write_clientcall(ThreadId tid, PtrdiffT guest_state_offset,
SizeT size, Addr f )
{
UWord p;
diff --git a/exp-ptrcheck/h_main.h b/exp-ptrcheck/h_main.h
index 84efddca8..83e17b17a 100644
--- a/exp-ptrcheck/h_main.h
+++ b/exp-ptrcheck/h_main.h
@@ -77,8 +77,8 @@ void h_pre_mem_read_asciiz ( CorePart part, ThreadId tid,
Char* s, Addr lo );
void h_post_reg_write_demux ( CorePart part, ThreadId tid,
- OffT guest_state_offset, SizeT size);
-void h_post_reg_write_clientcall(ThreadId tid, OffT guest_state_offset,
+ PtrdiffT guest_state_offset, SizeT size);
+void h_post_reg_write_clientcall(ThreadId tid, PtrdiffT guest_state_offset,
SizeT size, Addr f );
void h_pre_syscall ( ThreadId tid, UInt syscallno );
diff --git a/exp-ptrcheck/pc_common.c b/exp-ptrcheck/pc_common.c
index 26c81270f..b72d2fc0f 100644
--- a/exp-ptrcheck/pc_common.c
+++ b/exp-ptrcheck/pc_common.c
@@ -130,13 +130,13 @@ typedef
HChar actual[128];
} SorG;
struct {
- Addr addr;
- SSizeT sszB; /* -ve is write, +ve is read */
- Seg* vseg;
- Char descr1[96];
- Char descr2[96];
- Char datasym[96];
- OffT datasymoff;
+ Addr addr;
+ SSizeT sszB; /* -ve is write, +ve is read */
+ Seg* vseg;
+ Char descr1[96];
+ Char descr2[96];
+ Char datasym[96];
+ PtrdiffT datasymoff;
} Heap;
struct {
Seg* seg1;
diff --git a/include/pub_tool_aspacemgr.h b/include/pub_tool_aspacemgr.h
index 6144d270e..118655126 100644
--- a/include/pub_tool_aspacemgr.h
+++ b/include/pub_tool_aspacemgr.h
@@ -101,7 +101,7 @@ typedef
/* Associated file (SkFile{C,V} only) */
ULong dev;
ULong ino;
- ULong offset;
+ Off64T offset;
UInt mode;
Int fnIdx; // file name table index, if name is known
/* Permissions (SkAnon{C,V}, SkFile{C,V} only) */
diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h
index 3292f00b9..d91bb81f3 100644
--- a/include/pub_tool_basics.h
+++ b/include/pub_tool_basics.h
@@ -62,22 +62,40 @@
// By choosing the right types, we can get these right for 32-bit and 64-bit
// platforms without having to do any conditional compilation or anything.
+// POSIX references:
+// - http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html
+// - http://www.opengroup.org/onlinepubs/009695399/basedefs/stddef.h.html
//
// Size in bits on: 32-bit archs 64-bit archs
// ------------ ------------
typedef unsigned long UWord; // 32 64
+typedef signed long Word; // 32 64
-typedef signed long Word; // 32 64
-
+// Addr is for holding an address. AddrH was intended to be "Addr on the
+// host", for the notional case where host word size != guest word size.
+// But since the assumption that host arch == guest arch has become so
+// deeply wired in, it's a pretty pointless distinction now.
typedef UWord Addr; // 32 64
typedef UWord AddrH; // 32 64
+// Our equivalents of POSIX 'size_t' and 'ssize_t':
+// - size_t is an "unsigned integer type of the result of the sizeof operator".
+// - ssize_t is "used for a count of bytes or an error indication".
typedef UWord SizeT; // 32 64
typedef Word SSizeT; // 32 64
-typedef Word OffT; // 32 64
-
-typedef ULong Off64T; // 64 64
+// Our equivalent of POSIX 'ptrdiff_t':
+// - ptrdiff_t is a "signed integer type of the result of subtracting two
+// pointers".
+// We use it for memory offsets, eg. the offset into a memory block.
+typedef Word PtrdiffT; // 32 64
+
+// Our equivalent of POSIX 'off_t':
+// - off_t is "used for file sizes".
+// At one point we were using it for memory offsets, but PtrdiffT should be
+// used in those cases.
+typedef Word OffT; // 32 64
+typedef Long Off64T; // 64 64
#if !defined(NULL)
# define NULL ((void*)0)
diff --git a/include/pub_tool_debuginfo.h b/include/pub_tool_debuginfo.h
index 30725d542..baf998147 100644
--- a/include/pub_tool_debuginfo.h
+++ b/include/pub_tool_debuginfo.h
@@ -80,7 +80,7 @@ extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* fnname, Int n_fnname );
from the symbol start is put into *offset. */
extern Bool VG_(get_datasym_and_offset)( Addr data_addr,
/*OUT*/Char* dname, Int n_dname,
- /*OUT*/OffT* offset );
+ /*OUT*/PtrdiffT* offset );
/* Try to form some description of data_addr by looking at the DWARF3
debug info we have. This considers all global variables, and all
@@ -113,11 +113,11 @@ extern Char* VG_(describe_IP)(Addr eip, Char* buf, Int n_buf);
typedef
struct {
- OffT base; /* offset from sp or fp */
- SizeT szB; /* size in bytes */
- Bool spRel; /* True => sp-rel, False => fp-rel */
- Bool isVec; /* does block have an array type, or not? */
- HChar name[16]; /* first 15 chars of name (asciiz) */
+ PtrdiffT base; /* offset from sp or fp */
+ SizeT szB; /* size in bytes */
+ Bool spRel; /* True => sp-rel, False => fp-rel */
+ Bool isVec; /* does block have an array type, or not? */
+ HChar name[16]; /* first 15 chars of name (asciiz) */
}
StackBlock;
@@ -167,7 +167,7 @@ extern Addr VG_(seginfo_get_gotplt_avma)( const DebugInfo *di );
extern SizeT VG_(seginfo_get_gotplt_size)( const DebugInfo *di );
extern const UChar* VG_(seginfo_soname) ( const DebugInfo *di );
extern const UChar* VG_(seginfo_filename) ( const DebugInfo *di );
-extern ULong VG_(seginfo_get_text_bias)( const DebugInfo *di );
+extern PtrdiffT VG_(seginfo_get_text_bias)( const DebugInfo *di );
/* Function for traversing the seginfo list. When called with NULL it
returns the first element; otherwise it returns the given element's
diff --git a/include/pub_tool_machine.h b/include/pub_tool_machine.h
index ae9669c05..fc86bf960 100644
--- a/include/pub_tool_machine.h
+++ b/include/pub_tool_machine.h
@@ -90,10 +90,10 @@ extern void VG_(set_IP) ( ThreadId tid, Addr ip );
void
VG_(get_shadow_regs_area) ( ThreadId tid,
/*DST*/UChar* dst,
- /*SRC*/Int shadowNo, OffT offset, SizeT size );
+ /*SRC*/Int shadowNo, PtrdiffT offset, SizeT size );
void
VG_(set_shadow_regs_area) ( ThreadId tid,
- /*DST*/Int shadowNo, OffT offset, SizeT size,
+ /*DST*/Int shadowNo, PtrdiffT offset, SizeT size,
/*SRC*/const UChar* src );
// Sets the shadow values for the syscall return value register(s).
diff --git a/include/pub_tool_oset.h b/include/pub_tool_oset.h
index 1573136fa..c496523fb 100644
--- a/include/pub_tool_oset.h
+++ b/include/pub_tool_oset.h
@@ -183,7 +183,7 @@ extern Bool VG_(OSetWord_Next) ( OSet* os, /*OUT*/UWord* val );
// a deallocation function (such as VG_(free)()) directly will likely
// lead to assertions in Valgrind's allocator.
-extern OSet* VG_(OSetGen_Create) ( OffT keyOff, OSetCmp_t cmp,
+extern OSet* VG_(OSetGen_Create) ( PtrdiffT keyOff, OSetCmp_t cmp,
OSetAlloc_t alloc, HChar* ec,
OSetFree_t free );
extern void VG_(OSetGen_Destroy) ( OSet* os );
diff --git a/include/pub_tool_tooliface.h b/include/pub_tool_tooliface.h
index 210df361a..8194706c8 100644
--- a/include/pub_tool_tooliface.h
+++ b/include/pub_tool_tooliface.h
@@ -567,15 +567,15 @@ void VG_(track_post_mem_write) (void(*f)(CorePart part, ThreadId tid,
/* Register events. Use VG_(set_shadow_state_area)() to set the shadow regs
for these events. */
void VG_(track_pre_reg_read) (void(*f)(CorePart part, ThreadId tid,
- Char* s, OffT guest_state_offset,
+ Char* s, PtrdiffT guest_state_offset,
SizeT size));
void VG_(track_post_reg_write)(void(*f)(CorePart part, ThreadId tid,
- OffT guest_state_offset,
+ PtrdiffT guest_state_offset,
SizeT size));
/* This one is called for malloc() et al if they are replaced by a tool. */
void VG_(track_post_reg_write_clientcall_return)(
- void(*f)(ThreadId tid, OffT guest_state_offset, SizeT size, Addr f));
+ void(*f)(ThreadId tid, PtrdiffT guest_state_offset, SizeT size, Addr f));
/* Scheduler events (not exhaustive) */
diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c
index e95ad5ee8..33dcc266f 100644
--- a/memcheck/mc_errors.c
+++ b/memcheck/mc_errors.c
@@ -98,15 +98,15 @@ struct _AddrInfo {
BlockKind block_kind;
Char* block_desc; // "block", "mempool" or user-defined
SizeT block_szB;
- OffT rwoffset;
+ PtrdiffT rwoffset;
ExeContext* lastchange;
} Block;
- // In a global .data symbol. This holds the first 63 chars of
- // the variable's (zero terminated), plus an offset.
+ // In a global .data symbol. This holds the first 127 chars of
+ // the variable's name (zero terminated), plus a (memory) offset.
struct {
- Char name[128];
- OffT offset;
+ Char name[128];
+ PtrdiffT offset;
} DataSym;
// Is described by Dwarf debug info. Arbitrary strings. Must
@@ -286,10 +286,10 @@ static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc )
break;
case Addr_Block: {
- SizeT block_szB = ai->Addr.Block.block_szB;
- OffT rwoffset = ai->Addr.Block.rwoffset;
- SizeT delta;
- const Char* relative;
+ SizeT block_szB = ai->Addr.Block.block_szB;
+ PtrdiffT rwoffset = ai->Addr.Block.rwoffset;
+ SizeT delta;
+ const Char* relative;
if (rwoffset < 0) {
delta = (SizeT)(-rwoffset);
diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c
index 60eea3137..3c069bfff 100644
--- a/memcheck/mc_main.c
+++ b/memcheck/mc_main.c
@@ -3722,7 +3722,7 @@ static UInt mb_get_origin_for_guest_offset ( ThreadId tid,
big as the biggest guest state.
*/
static void mc_post_reg_write ( CorePart part, ThreadId tid,
- OffT offset, SizeT size)
+ PtrdiffT offset, SizeT size)
{
# define MAX_REG_WRITE_SIZE 1408
UChar area[MAX_REG_WRITE_SIZE];
@@ -3734,8 +3734,7 @@ static void mc_post_reg_write ( CorePart part, ThreadId tid,
static
void mc_post_reg_write_clientcall ( ThreadId tid,
- OffT offset, SizeT size,
- Addr f)
+ PtrdiffT offset, SizeT size, Addr f)
{
mc_post_reg_write(/*dummy*/0, tid, offset, size);
}
@@ -3745,7 +3744,7 @@ void mc_post_reg_write_clientcall ( ThreadId tid,
a parameter error.
*/
static void mc_pre_reg_read ( CorePart part, ThreadId tid, Char* s,
- OffT offset, SizeT size)
+ PtrdiffT offset, SizeT size)
{
Int i;
Bool bad;