(void)VG_(do_syscall1)(__NR_close, fd);
}
-Int ML_(am_readlink)(HChar* path, HChar* buf, UInt bufsiz)
+Int ML_(am_readlink)(const HChar* path, HChar* buf, UInt bufsiz)
{
SysRes res;
# if defined(VGP_arm64_linux)
/* Figure out how many bytes of the stack's active area have not
been used. Used for estimating if we are close to overflowing it. */
-SizeT VG_(am_get_VgStack_unused_szB)( VgStack* stack, SizeT limit )
+SizeT VG_(am_get_VgStack_unused_szB)( const VgStack* stack, SizeT limit )
{
SizeT i;
- UInt* p;
+ const UInt* p;
- p = (UInt*)&stack->bytes[VG_STACK_GUARD_SZB];
+ p = (const UInt*)&stack->bytes[VG_STACK_GUARD_SZB];
for (i = 0; i < VG_STACK_ACTIVE_SZB/sizeof(UInt); i++) {
if (p[i] != 0xDEADBEEF)
break;
/* Show full details of an NSegment */
static void __attribute__ ((unused))
- show_nsegment_full ( Int logLevel, Int segNo, NSegment* seg )
+ show_nsegment_full ( Int logLevel, Int segNo, const NSegment* seg )
{
HChar len_buf[20];
const HChar* name = "(none)";
/* Show an NSegment in a user-friendly-ish way. */
-static void show_nsegment ( Int logLevel, Int segNo, NSegment* seg )
+static void show_nsegment ( Int logLevel, Int segNo, const NSegment* seg )
{
HChar len_buf[20];
show_len_concisely(len_buf, seg->start, seg->end);
/* Check representational invariants for NSegments. */
-static Bool sane_NSegment ( NSegment* s )
+static Bool sane_NSegment ( const NSegment* s )
{
if (s == NULL) return False;
modified, and True is returned. Otherwise s1 is unchanged and
False is returned. */
-static Bool maybe_merge_nsegments ( NSegment* s1, NSegment* s2 )
+static Bool maybe_merge_nsegments ( NSegment* s1, const NSegment* s2 )
{
if (s1->kind != s2->kind)
return False;
This deals with all the tricky cases of splitting up segments as
needed. */
-static void add_segment ( NSegment* seg )
+static void add_segment ( const NSegment* seg )
{
Int i, iLo, iHi, delta;
Bool segment_is_sane;
/* Query aspacem to ask where a mapping should go. */
-Addr VG_(am_get_advisory) ( MapRequest* req,
- Bool forClient,
+Addr VG_(am_get_advisory) ( const MapRequest* req,
+ Bool forClient,
/*OUT*/Bool* ok )
{
/* This function implements allocation policy.
extern SysRes ML_(am_open) ( const HChar* pathname, Int flags, Int mode );
extern void ML_(am_close) ( Int fd );
extern Int ML_(am_read) ( Int fd, void* buf, Int count);
-extern Int ML_(am_readlink) ( HChar* path, HChar* buf, UInt bufsiz );
+extern Int ML_(am_readlink) ( const HChar* path, HChar* buf, UInt bufsiz );
extern Int ML_(am_fcntl) ( Int fd, Int cmd, Addr arg );
/* Get the dev, inode and mode info for a file descriptor, if
* value is returned and the given pointer is
* moved past end of leb128 data */
/* FIXME: duplicated in readdwarf.c */
-static ULong read_leb128U( UChar **data )
+static ULong read_leb128U( const UChar **data )
{
Int len;
ULong val = read_leb128( *data, &len, 0 );
/* Same for signed data */
/* FIXME: duplicated in readdwarf.c */
-static Long read_leb128S( UChar **data )
+static Long read_leb128S( const UChar **data )
{
Int len;
ULong val = read_leb128( *data, &len, 1 );
/* Evaluate a standard DWARF3 expression. See detailed description in
priv_d3basics.h. Doesn't handle DW_OP_piece/DW_OP_bit_piece yet. */
-GXResult ML_(evaluate_Dwarf3_Expr) ( UChar* expr, UWord exprszB,
- GExpr* fbGX, const RegSummary* regs,
+GXResult ML_(evaluate_Dwarf3_Expr) ( const UChar* expr, UWord exprszB,
+ const GExpr* fbGX, const RegSummary* regs,
const DebugInfo* di,
Bool push_initial_zero )
{
} while (0)
UChar opcode;
- UChar* limit;
+ const UChar* limit;
Int sp; /* # of top element: valid is -1 .. N_EXPR_STACK-1 */
Addr stack[N_EXPR_STACK]; /* stack of addresses, as per D3 spec */
GXResult fbval, res;
PUSH(uw1);
break;
case DW_OP_const1s:
- uw1 = *(Char *)expr;
+ uw1 = *(const Char *)expr;
expr++;
PUSH(uw1);
break;
/* Evaluate a so-called Guarded (DWARF3) expression. See detailed
description in priv_d3basics.h. */
-GXResult ML_(evaluate_GX)( GExpr* gx, GExpr* fbGX,
+GXResult ML_(evaluate_GX)( const GExpr* gx, const GExpr* fbGX,
const RegSummary* regs, const DebugInfo* di )
{
GXResult res;
UChar uc;
UShort nbytes;
UWord nGuards = 0;
- UChar* p = &gx->payload[0];
+ const UChar* p = &gx->payload[0];
uc = *p++; /*biasMe*/
vg_assert(uc == 0 || uc == 1);
/* in fact it's senseless to evaluate if the guards need biasing.
Really it ought to be pulled out and turned into a general
constant- expression evaluator.
*/
-GXResult ML_(evaluate_trivial_GX)( GExpr* gx, const DebugInfo* di )
+GXResult ML_(evaluate_trivial_GX)( const GExpr* gx, const DebugInfo* di )
{
GXResult res;
Addr aMin, aMax;
MaybeULong *mul, *mul2;
const HChar* badness = NULL;
- UChar* p = &gx->payload[0]; /* must remain unsigned */
+ const UChar* p = &gx->payload[0]; /* must remain unsigned */
XArray* results = VG_(newXA)( ML_(dinfo_zalloc), "di.d3basics.etG.1",
ML_(dinfo_free),
sizeof(MaybeULong) );
{
DebugInfo* di;
const NSegment *seg;
- HChar* filename;
+ const HChar* filename;
vg_assert(nbuf > 0);
/* Look in the debugInfo_list to find the name. In most cases we
expect this to produce a result. */
/* Same as putStr, but escaping chars for XML output, and
also not adding more than count chars to n_buf. */
-static Int putStrEsc ( Int n, Int n_buf, Int count, HChar* buf, HChar* str )
+static Int putStrEsc ( Int n, Int n_buf, Int count, HChar* buf,
+ const HChar* str )
{
HChar alt[2];
vg_assert(n_buf > 0);
a CfiExpr into one convenient struct. */
typedef
struct {
- D3UnwindRegs* uregs;
+ const D3UnwindRegs* uregs;
Addr min_accessible;
Addr max_accessible;
}
caller must set it to True before calling. */
__attribute__((noinline))
static
-UWord evalCfiExpr ( XArray* exprs, Int ix,
- CfiExprEvalContext* eec, Bool* ok )
+UWord evalCfiExpr ( const XArray* exprs, Int ix,
+ const CfiExprEvalContext* eec, Bool* ok )
{
UWord w, wL, wR;
Addr a;
- CfiExpr* e;
+ const CfiExpr* e;
vg_assert(sizeof(Addr) == sizeof(UWord));
e = VG_(indexXA)( exprs, ix );
switch (e->tag) {
inline
-static Addr compute_cfa ( D3UnwindRegs* uregs,
+static Addr compute_cfa ( const D3UnwindRegs* uregs,
Addr min_accessible, Addr max_accessible,
- DebugInfo* di, DiCfSI_m* cfsi_m )
+ const DebugInfo* di, const DiCfSI_m* cfsi_m )
{
CfiExprEvalContext eec;
Addr cfa;
Addr max_accessible )
{
Word i;
- DebugInfo* di;
+ const DebugInfo* di;
FPO_DATA* fpo = NULL;
Addr spHere;
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*/PtrdiffT* offset,
- XArray* /* TyEnt */ tyents,
- DiVariable* var,
- RegSummary* regs,
- Addr data_addr,
+ const XArray* /* TyEnt */ tyents,
+ const DiVariable* var,
+ const RegSummary* regs,
+ Addr data_addr,
const DebugInfo* di )
{
MaybeULong mul;
static
void analyse_deps ( /*MOD*/XArray* /* of FrameBlock */ blocks,
- XArray* /* TyEnt */ tyents,
- Addr ip, const DebugInfo* di, DiVariable* var,
+ const XArray* /* TyEnt */ tyents,
+ Addr ip, const DebugInfo* di, const DiVariable* var,
Bool arrays_only )
{
GXResult res_sp_6k, res_sp_7k, res_fp_6k, res_fp_7k;
return f;
}
-static Bool parse_Frame_le64 ( Frame* fr, const HChar* tag, /*OUT*/ULong* n1 )
+static Bool parse_Frame_le64 ( const Frame* fr, const HChar* tag,
+ /*OUT*/ULong* n1 )
{
vg_assert(VG_(strlen)(tag) == 4);
if (!fr || !fr->data) return False;
return True;
}
-static Bool parse_Frame_le64_le64 ( Frame* fr, const HChar* tag,
+static Bool parse_Frame_le64_le64 ( const Frame* fr, const HChar* tag,
/*OUT*/ULong* n1, /*OUT*/ULong* n2 )
{
vg_assert(VG_(strlen)(tag) == 4);
return True;
}
-static Bool parse_Frame_asciiz ( Frame* fr, const HChar* tag,
+static Bool parse_Frame_asciiz ( const Frame* fr, const HChar* tag,
/*OUT*/UChar** str )
{
vg_assert(VG_(strlen)(tag) == 4);
}
static Bool parse_Frame_le64_le64_le64_bytes (
- Frame* fr, const HChar* tag,
+ const Frame* fr, const HChar* tag,
/*OUT*/ULong* n1, /*OUT*/ULong* n2, /*OUT*/ULong* n3,
/*OUT*/UChar** data, /*OUT*/ULong* n_data
)
the given offset. It is this function that brings data into the
cache, either by reading the local file or pulling it from the
remote server. */
-static void set_CEnt ( DiImage* img, UInt entNo, DiOffT off )
+static void set_CEnt ( const DiImage* img, UInt entNo, DiOffT off )
{
SizeT len;
DiOffT off_orig = off;
dstU[0] = get(img, offset);
/* Now just read as many bytes as we can (or need) directly out of
entry zero, without bothering to call |get| each time. */
- CEnt* ce = img->ces[0];
+ const CEnt* ce = img->ces[0];
vg_assert(ce && ce->used >= 1);
vg_assert(is_in_CEnt(ce, offset));
SizeT nToCopy = size - 1;
computed, then fbGX can provide an expression for it. If fbGX is
NULL but the frame base is still needed, then evaluation of gx as a
whole will fail. */
-GXResult ML_(evaluate_GX)( GExpr* gx, GExpr* fbGX,
+GXResult ML_(evaluate_GX)( const GExpr* gx, const GExpr* fbGX,
const RegSummary* regs, const DebugInfo* di );
/* This is a subsidiary of ML_(evaluate_GX), which just evaluates a
This is needed for computing structure field offsets. Note that
ML_(evaluate_GX) and ML_(evaluate_Dwarf3_Expr) are mutually
recursive. */
-GXResult ML_(evaluate_Dwarf3_Expr) ( UChar* expr, UWord exprszB,
- GExpr* fbGX, const RegSummary* regs,
+GXResult ML_(evaluate_Dwarf3_Expr) ( const UChar* expr, UWord exprszB,
+ const GExpr* fbGX, const RegSummary* regs,
const DebugInfo* di,
Bool push_initial_zero );
location is denoted, a frame base expression is required, or the
expression is not manifestly a constant. The range of addresses
covered by the guard is also ignored. */
-GXResult ML_(evaluate_trivial_GX)( GExpr* gx, const DebugInfo* di );
+GXResult ML_(evaluate_trivial_GX)( const GExpr* gx, const DebugInfo* di );
/* Compute call frame address (CFA) for IP/SP/FP. */
Addr ML_(get_CFA) ( Addr ip, Addr sp, Addr fp,
struct {
const HChar* name; /* in DebugInfo.strpool */
UWord typeR; /* a cuOff */
- GExpr* gexpr; /* on DebugInfo.gexprs list */
- GExpr* fbGX; /* SHARED. */
+ const GExpr* gexpr; /* on DebugInfo.gexprs list */
+ const GExpr* fbGX; /* SHARED. */
UInt fndn_ix; /* where declared; may be zero. index
in DebugInfo.fndnpool */
Int lineNo; /* where declared; may be zero. */
Addr aMax,
const HChar* name,
UWord typeR, /* a cuOff */
- GExpr* gexpr,
- GExpr* fbGX, /* SHARED. */
+ const GExpr* gexpr,
+ const GExpr* fbGX, /* SHARED. */
UInt fndn_ix, /* where decl'd - may be zero */
Int lineNo, /* where decl'd - may be zero */
Bool show );
}
RegRule;
-static void ppRegRule ( XArray* exprs, const RegRule* rrule )
+static void ppRegRule ( const XArray* exprs, const RegRule* rrule )
{
vg_assert(exprs);
switch (rrule->tag) {
// return &c->region_start_img[ c->region_next ];
//}
-static DiCursor get_DiCursor_from_Cursor ( Cursor* c ) {
+static DiCursor get_DiCursor_from_Cursor ( const Cursor* c ) {
return mk_DiCursor(c->sli.img, c->sli_next);
}
/* Generate an arbitrary structural total ordering on
XArray* of AddrRange. */
-static Word cmp__XArrays_of_AddrRange ( XArray* rngs1, XArray* rngs2 )
+static Word cmp__XArrays_of_AddrRange ( const XArray* rngs1,
+ const XArray* rngs2 )
{
Word n1, n2, i;
vg_assert(rngs1 && rngs2);
static void typestack_push ( const CUConst* cc,
D3TypeParser* parser,
Bool td3,
- TyEnt* parentE, Int level ) {
+ TyEnt* parentE, Int level )
+{
if (0)
TRACE_D3("BBBBAAAA typestack_push[newsp=%d]: %d %05lx\n",
parser->sp+1, level, parentE->cuOff);
/*------------------------------------------------------------*/
static UWord chase_cuOff ( Bool* changed,
- XArray* /* of TyEnt */ ents,
+ const XArray* /* of TyEnt */ ents,
TyEntIndexCache* ents_cache,
UWord cuOff )
{
static
void chase_cuOffs_in_XArray ( Bool* changed,
- XArray* /* of TyEnt */ ents,
+ const XArray* /* of TyEnt */ ents,
TyEntIndexCache* ents_cache,
/*MOD*/XArray* /* of UWord */ cuOffs )
{
*changed = b2;
}
-static Bool TyEnt__subst_R_fields ( XArray* /* of TyEnt */ ents,
+static Bool TyEnt__subst_R_fields ( const XArray* /* of TyEnt */ ents,
TyEntIndexCache* ents_cache,
/*MOD*/TyEnt* te )
{
/* Heuristic kludge: return True if this looks like an installed
standard library; hence we shouldn't consider automagically running
dsymutil on it. */
-static Bool is_systemish_library_name ( HChar* name )
+static Bool is_systemish_library_name ( const HChar* name )
{
vg_assert(name);
if (0 == VG_(strncasecmp)(name, "/usr/", 5)
{
/* VG_(indexXA) checks for invalid src/ix values, so we can
use it indiscriminately. */
- CfiExpr* e = (CfiExpr*) VG_(indexXA)( src, ix );
+ const CfiExpr* e = VG_(indexXA)( src, ix );
switch (e->tag) {
case Cex_Undef:
VG_(printf)("Undef");
Addr aMax,
const HChar* name, /* in di's .strpool */
UWord typeR, /* a cuOff */
- GExpr* gexpr,
- GExpr* fbGX,
+ const GExpr* gexpr,
+ const GExpr* fbGX,
UInt fndn_ix, /* where decl'd - may be zero.
index in in di's .fndnpool */
Int lineNo, /* where decl'd - may be zero */
VG_(printf)("------ %s ------\n", who);
n = VG_(sizeXA)( tyents );
for (i = 0; i < n; i++) {
- TyEnt* tyent = (TyEnt*)VG_(indexXA)( tyents, i );
+ const TyEnt* tyent = VG_(indexXA)( tyents, i );
VG_(printf)(" [%5ld] ", i);
ML_(pp_TyEnt)( tyent );
VG_(printf)("\n");
}
/* Add all signals in src to dst. */
-void VG_(sigaddset_from_set)( vki_sigset_t* dst, vki_sigset_t* src )
+void VG_(sigaddset_from_set)( vki_sigset_t* dst, const vki_sigset_t* src )
{
Int i;
vg_assert(dst != NULL && src != NULL);
}
/* Remove all signals in src from dst. */
-void VG_(sigdelset_from_set)( vki_sigset_t* dst, vki_sigset_t* src )
+void VG_(sigdelset_from_set)( vki_sigset_t* dst, const vki_sigset_t* src )
{
Int i;
vg_assert(dst != NULL && src != NULL);
}
/* dst = dst `intersect` src. */
-void VG_(sigintersectset)( vki_sigset_t* dst, vki_sigset_t* src )
+void VG_(sigintersectset)( vki_sigset_t* dst, const vki_sigset_t* src )
{
Int i;
vg_assert(dst != NULL && src != NULL);
}
/* dst = ~src */
-void VG_(sigcomplementset)( vki_sigset_t* dst, vki_sigset_t* src )
+void VG_(sigcomplementset)( vki_sigset_t* dst, const vki_sigset_t* src )
{
Int i;
vg_assert(dst != NULL && src != NULL);
/* See explanation in pub_core_libcsignal.h. */
void
-VG_(convert_sigaction_fromK_to_toK)( vki_sigaction_fromK_t* fromK,
+VG_(convert_sigaction_fromK_to_toK)( const vki_sigaction_fromK_t* fromK,
/*OUT*/vki_sigaction_toK_t* toK )
{
# if defined(VGO_linux)
set to False, it means aspacem has vetoed the mapping, and so the
caller should not proceed with it. */
extern Addr VG_(am_get_advisory)
- ( MapRequest* req, Bool forClient, /*OUT*/Bool* ok );
+ ( const MapRequest* req, Bool forClient, /*OUT*/Bool* ok );
/* Convenience wrapper for VG_(am_get_advisory) for client floating or
fixed requests. If start is zero, a floating request is issued; if
/* Figure out how many bytes of the stack's active area have not been
used. Used for estimating if we are close to overflowing it. If
the free area is larger than 'limit', just return 'limit'. */
-extern SizeT VG_(am_get_VgStack_unused_szB)( VgStack* stack, SizeT limit );
+extern SizeT VG_(am_get_VgStack_unused_szB)( const VgStack* stack,
+ SizeT limit );
// DDD: this is ugly
#if defined(VGO_darwin)
extern Int VG_(sigdelset) ( vki_sigset_t* set, Int signum );
extern Int VG_(sigismember) ( const vki_sigset_t* set, Int signum );
-extern void VG_(sigaddset_from_set) ( vki_sigset_t* dst, vki_sigset_t* src );
-extern void VG_(sigdelset_from_set) ( vki_sigset_t* dst, vki_sigset_t* src );
-extern void VG_(sigintersectset) ( vki_sigset_t* dst, vki_sigset_t* src );
-extern void VG_(sigcomplementset) ( vki_sigset_t* dst, vki_sigset_t* src );
+extern void VG_(sigaddset_from_set) ( vki_sigset_t* dst, const vki_sigset_t* src );
+extern void VG_(sigdelset_from_set) ( vki_sigset_t* dst, const vki_sigset_t* src );
+extern void VG_(sigintersectset) ( vki_sigset_t* dst, const vki_sigset_t* src );
+extern void VG_(sigcomplementset) ( vki_sigset_t* dst, const vki_sigset_t* src );
/* --- Mess with the kernel's sig state --- */
/* VG_(sigprocmask) is in pub_tool_libcsignal.h. */
vki_sigaction_{toK,fromK}_t are identical, so this is a no-op
(structure copy), but on Darwin it's not a no-op. */
extern void VG_(convert_sigaction_fromK_to_toK)(
- vki_sigaction_fromK_t*, /*OUT*/vki_sigaction_toK_t*);
+ const vki_sigaction_fromK_t*, /*OUT*/vki_sigaction_toK_t*);
extern Int VG_(kill) ( Int pid, Int signo );