continue;
}
for (i = 0; i < si->symtab_used; i++) {
- HChar* pri_name = si->symtab[i].pri_name;
+ const HChar* pri_name = si->symtab[i].pri_name;
vg_assert(pri_name);
if (0==VG_(strcmp)(name, pri_name)
&& (require_pToc ? GET_TOCPTR_AVMA(si->symtab[i].avmas) : True)) {
*avmas = si->symtab[i].avmas;
return True;
}
- HChar** sec_names = si->symtab[i].sec_names;
+ const HChar** sec_names = si->symtab[i].sec_names;
if (sec_names) {
vg_assert(sec_names[0]);
while (*sec_names) {
Int idx,
/*OUT*/SymAVMAs* avmas,
/*OUT*/UInt* size,
- /*OUT*/HChar** pri_name,
- /*OUT*/HChar*** sec_names,
+ /*OUT*/const HChar** pri_name,
+ /*OUT*/const HChar*** sec_names,
/*OUT*/Bool* isText,
/*OUT*/Bool* isIFunc )
{
if (avmas) *avmas = si->symtab[idx].avmas;
if (size) *size = si->symtab[idx].size;
if (pri_name) *pri_name = si->symtab[idx].pri_name;
- if (sec_names) *sec_names = (HChar **)si->symtab[idx].sec_names; // FIXME
+ if (sec_names) *sec_names = si->symtab[idx].sec_names;
if (isText) *isText = si->symtab[idx].isText;
if (isIFunc) *isIFunc = si->symtab[idx].isIFunc;
}
SymAVMAs avmas; /* Symbol Actual VMAs: lowest address of entity,
+ platform specific fields, to access with
the macros defined in pub_core_debuginfo.h */
- HChar* pri_name; /* primary name, never NULL */
- HChar** sec_names; /* NULL, or a NULL term'd array of other names */
+ const HChar* pri_name; /* primary name, never NULL */
+ const HChar** sec_names; /* NULL, or a NULL term'd array of other names */
// XXX: this could be shrunk (on 32-bit platforms) by using 30
// bits for the size and 1 bit each for isText and isIFunc. If you
// do this, make sure that all assignments to the latter two use
typedef
struct {
- HChar* name; /* in DebugInfo.strpool */
+ const HChar* name; /* in DebugInfo.strpool */
UWord typeR; /* a cuOff */
GExpr* gexpr; /* on DebugInfo.gexprs list */
GExpr* fbGX; /* SHARED. */
/* Add a string to the string table of a DebugInfo. If len==-1,
ML_(addStr) will itself measure the length of the string. */
-extern HChar* ML_(addStr) ( struct _DebugInfo* di, const HChar* str, Int len );
+extern const HChar* ML_(addStr) ( DebugInfo* di, const HChar* str, Int len );
/* Add a string to the string table of a DebugInfo, by copying the
string from the given DiCursor. Measures the length of the string
itself. */
-extern HChar* ML_(addStrFromCursor)( struct _DebugInfo* di, DiCursor c );
+extern const HChar* ML_(addStrFromCursor)( DebugInfo* di, DiCursor c );
extern void ML_(addVar)( struct _DebugInfo* di,
Int level,
Addr aMin,
Addr aMax,
- HChar* name,
+ const HChar* name,
UWord typeR, /* a cuOff */
GExpr* gexpr,
GExpr* fbGX, /* SHARED. */
/* if xa_ix is a valid index in dirname_xa,
return the element (i.e. the HChar*).
If xa_ix is invalid, return NULL. */
-static HChar* safe_dirname_ix (XArray* dirname_xa, Int xa_ix)
+static const HChar* safe_dirname_ix (XArray* dirname_xa, Int xa_ix)
{
if (xa_ix < 0) return NULL;
if (xa_ix >= VG_(sizeXA) (dirname_xa)) return NULL;
Bool is64;
XArray* fndn_ix_xa; /* xarray of UInt fndn_ix */
UInt fndn_ix;
- XArray* dirname_xa; /* xarray of HChar* dirname */
- HChar* dirname;
+ XArray* dirname_xa; /* xarray of const HChar* dirname */
+ const HChar* dirname;
DiCursor external = theBlock;
DiCursor data = theBlock;
typedef
struct _TempVar {
- HChar* name; /* in DebugInfo's .strpool */
+ const HChar* name; /* in DebugInfo's .strpool */
/* Represent ranges economically. nRanges is the number of
ranges. Cases:
0: .rngOneMin .rngOneMax .manyRanges are all zero
static
void read_filename_table( /*MOD*/XArray* /* of UInt* */ fndn_ix_Table,
- HChar* compdir,
+ const HChar* compdir,
CUConst* cc, ULong debug_line_offset,
Bool td3 )
{
Word i;
UShort version;
UChar opcode_base;
- HChar* str;
+ const HChar* str;
XArray* dirname_xa; /* xarray of HChar* dirname */
ULong dir_xa_ix; /* Index in dirname_xa, as read from dwarf info. */
HChar* dirname;
Addr ip_lo = 0;
Addr ip_hi1 = 0;
Addr rangeoff = 0;
- HChar *compdir = NULL;
+ const HChar *compdir = NULL;
nf_i = 0;
while (True) {
DW_AT attr = (DW_AT) abbv->nf[nf_i].at_name;
}
if (dtag == DW_TAG_variable || dtag == DW_TAG_formal_parameter) {
- HChar* name = NULL;
+ const HChar* name = NULL;
UWord typeR = D3_INVALID_CUOFF;
Bool global = False;
GExpr* gexpr = NULL;
table is kept, while we must handle all abbreviations in all CUs
referenced by an absori (being a reference to an alt CU, or a previous
or following CU). */
-static HChar* get_inlFnName (Int absori, CUConst* cc, Bool td3)
+static const HChar* get_inlFnName (Int absori, CUConst* cc, Bool td3)
{
Cursor c;
g_abbv *abbv;
UInt has_children;
UWord posn;
Bool type_flag, alt_flag;
- HChar *ret = NULL;
+ const HChar *ret = NULL;
FormContents cts;
UInt nf_i;
if (dtag == DW_TAG_compile_unit || dtag == DW_TAG_partial_unit) {
Bool have_lo = False;
Addr ip_lo = 0;
- HChar *compdir = NULL;
+ const HChar *compdir = NULL;
nf_i = 0;
while (True) {
/* This inlined call is several address ranges. */
XArray *ranges;
Word j;
- HChar *inlfnname = get_inlFnName (inlinedfn_abstract_origin, cc, td3);
+ const HChar *inlfnname =
+ get_inlFnName (inlinedfn_abstract_origin, cc, td3);
/* Ranges are biased for the inline info using the same logic
as what is used for biasing ranges for the var info, for which
i,
disym.avmas.main,
(Int)disym.size,
- (HChar*)disym.pri_name
+ disym.pri_name
);
if (GET_LOCAL_EP_AVMA(disym.avmas) != 0) {
TRACE_SYMTAB(" local entry point %#010lx\n",
disym.avmas.main,
GET_TOCPTR_AVMA(disym.avmas),
(Int) disym.size,
- (HChar*)disym.pri_name
+ disym.pri_name
);
}
i++;
{
Int i, length;
DiSym vsym;
- HChar* nmstr;
+ const HChar* nmstr;
HChar symname[4096 /*WIN32_PATH_MAX*/];
Bool debug = di->trace_symtab;
this_seg = 0;
for (i = 0; i < nfile; i++) {
- HChar *fnmstr;
- HChar *dirstr;
+ const HChar *fnmstr;
+ const HChar *dirstr;
UInt fnmdirstr_ix;
/*
while ((HChar*)lbh < linetab + size) {
- HChar *filename, *dirname;
+ const HChar *filename, *dirname;
UInt filedirname_ix;
Addr svma_s, svma_e;
if (lbh->header != 0x000000f2) {
/* Print a symbol. */
void ML_(ppSym) ( Int idx, DiSym* sym )
{
- HChar** sec_names = sym->sec_names;
+ const HChar** sec_names = sym->sec_names;
vg_assert(sym->pri_name);
if (sec_names)
vg_assert(sec_names);
a chunking memory allocator rather than reallocating, so the
pointers are stable.
*/
-HChar* ML_(addStr) ( struct _DebugInfo* di, const HChar* str, Int len )
+const HChar* ML_(addStr) ( DebugInfo* di, const HChar* str, Int len )
{
- HChar* p;
-
if (len == -1) {
len = VG_(strlen)(str);
} else {
ML_(dinfo_zalloc),
"di.storage.addStr.1",
ML_(dinfo_free));
- p = VG_(allocEltDedupPA) (di->strpool, len+1, str);
- return p;
+ return VG_(allocEltDedupPA) (di->strpool, len+1, str);
}
UInt ML_(addFnDn) (struct _DebugInfo* di,
/* Add a string to the string table of a DebugInfo, by copying the
string from the given DiCursor. Measures the length of the string
itself. */
-HChar* ML_(addStrFromCursor)( struct _DebugInfo* di, DiCursor c )
+const HChar* ML_(addStrFromCursor)( DebugInfo* di, DiCursor c )
{
/* This is a less-than-stellar implementation, but it should
work. */
vg_assert(ML_(cur_is_valid)(c));
HChar* str = ML_(cur_read_strdup)(c, "di.addStrFromCursor.1");
- HChar* res = ML_(addStr)(di, str, -1);
+ const HChar* res = ML_(addStr)(di, str, -1);
ML_(dinfo_free)(str);
return res;
}
Int level,
Addr aMin,
Addr aMax,
- HChar* name, /* in di's .strpool */
+ const HChar* name, /* in di's .strpool */
UWord typeR, /* a cuOff */
GExpr* gexpr,
GExpr* fbGX,
preferred.
*/
static
-Bool preferName ( struct _DebugInfo* di,
- HChar* a_name, HChar* b_name,
+Bool preferName ( DebugInfo* di,
+ const HChar* a_name, const HChar* b_name,
Addr sym_avma/*exposition only*/ )
{
Word cmp;
{
Bool blankA = True;
Bool blankB = True;
- HChar *s;
+ const HChar *s;
s = a_name;
while (*s) {
if (!VG_(isspace)(*s++)) {
vg_assert(from->pri_name);
/* Figure out how many names there will be in the new combined
secondary vector. */
- HChar** to_sec = to->sec_names;
- HChar** from_sec = from->sec_names;
+ const HChar** to_sec = to->sec_names;
+ const HChar** from_sec = from->sec_names;
Word n_new_sec = 1;
if (from_sec) {
while (*from_sec) {
TRACE_SYMTAB("merge: -> %ld\n", n_new_sec);
/* Create the new sec and copy stuff into it, putting the new
entries at the end. */
- HChar** new_sec = ML_(dinfo_zalloc)( "di.storage.aDntf.1",
- (n_new_sec+1) * sizeof(HChar*) );
+ const HChar** new_sec = ML_(dinfo_zalloc)( "di.storage.aDntf.1",
+ (n_new_sec+1) * sizeof(HChar*) );
from_sec = from->sec_names;
to_sec = to->sec_names;
Word i = 0;
{
Word i, j, n_truncated;
Addr sta1, sta2, end1, end2, toc1, toc2;
- HChar *pri1, *pri2, **sec1, **sec2;
+ const HChar *pri1, *pri2, **sec1, **sec2;
Bool ist1, ist2, isf1, isf2;
# define SWAP(ty,aa,bb) \
if (end1 > end2) {
sta1 = end2 + 1;
SWAP(Addr,sta1,sta2); SWAP(Addr,end1,end2); SWAP(Addr,toc1,toc2);
- SWAP(HChar*,pri1,pri2); SWAP(HChar**,sec1,sec2);
+ SWAP(const HChar*,pri1,pri2); SWAP(const HChar**,sec1,sec2);
SWAP(Bool,ist1,ist2); SWAP(Bool,isf1,isf2);
} else
if (end1 < end2) {
show the user. */
for (i = 0; i < ((Word)di->symtab_used)-1; i++) {
DiSym* sym = &di->symtab[i];
- HChar** sec = sym->sec_names;
+ const HChar** sec = sym->sec_names;
if (!sec)
continue;
/* Slow but simple. Copy all the cands into a temp array,
Word n_tmp = 1;
while (*sec) { n_tmp++; sec++; }
j = 0;
- HChar** tmp = ML_(dinfo_zalloc)( "di.storage.cS.1",
- (n_tmp+1) * sizeof(HChar*) );
+ const HChar** tmp = ML_(dinfo_zalloc)( "di.storage.cS.1",
+ (n_tmp+1) * sizeof(HChar*) );
tmp[j++] = sym->pri_name;
sec = sym->sec_names;
while (*sec) { tmp[j++] = *sec; sec++; }
vg_assert(best >= 0 && best < n_tmp);
/* Copy back */
sym->pri_name = tmp[best];
- HChar** cursor = sym->sec_names;
+ const HChar** cursor = sym->sec_names;
for (j = 0; j < n_tmp; j++) {
if (j == best)
continue;
struct _ht_node *next; // Read/Write by hashtable (pub_tool_hashtable.h)
UWord key; // Read by hashtable (pub_tool_hashtable.h)
SizeT eltSzB;
- void *elt;
+ const void *elt;
}
ht_node;
ddpa->ht_node_pa = NULL;
}
-void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB, const void *elt)
+const void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB,
+ const void *elt)
{
ht_node ht_elt;
void* elt_ins;
ht_elt.key = VG_(adler32) (ht_elt.key, elt, eltSzB);
ht_elt.eltSzB = eltSzB;
- ht_elt.elt = CONST_CAST(void *,elt);
+ ht_elt.elt = elt;
ht_ins = VG_(HT_gen_lookup) (ddpa->ht_elements, &ht_elt, cmp_pool_elt);
if (ht_ins)
ddpa->fixedSzb = eltSzB;
}
vg_assert (ddpa->fixedSzb == eltSzB);
- void *dedup_elt = VG_(allocEltDedupPA) (ddpa, eltSzB, elt);
+ const void *dedup_elt = VG_(allocEltDedupPA) (ddpa, eltSzB, elt);
return elt2nr (ddpa, dedup_elt);
}
/* This is the main, standard demangler entry point. */
void VG_(demangle) ( Bool do_cxx_demangling, Bool do_z_demangling,
- HChar* orig, HChar* result, Int result_size )
+ const HChar* orig, HChar* result, Int result_size )
{
# define N_ZBUF 4096
HChar* demangled = NULL;
static void show_active ( const HChar* left, Active* act );
static void handle_maybe_load_notifier( const HChar* soname,
- HChar* symbol, Addr addr );
+ const HChar* symbol, Addr addr );
static void handle_require_text_symbols ( DebugInfo* );
NULL terminated array, for easy iteration. Caller must pass also
the address of a 2-entry array which can be used in the common case
to avoid dynamic allocation. */
-static HChar** alloc_symname_array ( HChar* pri_name, HChar** sec_names,
- HChar** twoslots )
+static const HChar** alloc_symname_array ( const HChar* pri_name,
+ const HChar** sec_names,
+ const HChar** twoslots )
{
/* Special-case the common case: only one name. We expect the
caller to supply a stack-allocated 2-entry array for this. */
}
/* Else must use dynamic allocation. Figure out size .. */
Word n_req = 1;
- HChar** pp = sec_names;
+ const HChar** pp = sec_names;
while (*pp) { n_req++; pp++; }
/* .. allocate and copy in. */
- HChar** arr = dinfo_zalloc( "redir.asa.1", (n_req+1) * sizeof(HChar*) );
+ const HChar** arr = dinfo_zalloc("redir.asa.1", (n_req+1) * sizeof(HChar*));
Word i = 0;
arr[i++] = pri_name;
pp = sec_names;
/* Free the array allocated by alloc_symname_array, if any. */
-static void free_symname_array ( HChar** names, HChar** twoslots )
+static void free_symname_array ( const HChar** names, const HChar** twoslots )
{
if (names != twoslots)
dinfo_free(names);
Spec* spec;
TopSpec* ts;
TopSpec* newts;
- HChar* sym_name_pri;
- HChar** sym_names_sec;
+ const HChar* sym_name_pri;
+ const HChar** sym_names_sec;
SymAVMAs sym_avmas;
HChar demangled_sopatt[N_DEMANGLED];
HChar demangled_fnpatt[N_DEMANGLED];
NULL, &sym_name_pri, &sym_names_sec,
&isText, NULL );
/* Set up to conveniently iterate over all names for this symbol. */
- HChar* twoslots[2];
- HChar** names_init = alloc_symname_array(sym_name_pri, sym_names_sec,
- &twoslots[0]);
- HChar** names;
+ const HChar* twoslots[2];
+ const HChar** names_init =
+ alloc_symname_array(sym_name_pri, sym_names_sec, &twoslots[0]);
+ const HChar** names;
for (names = names_init; *names; names++) {
ok = VG_(maybe_Z_demangle)( *names,
demangled_sopatt, N_DEMANGLED,
VG_(DebugInfo_syms_getidx)( newdi, i, &sym_avmas,
NULL, &sym_name_pri, &sym_names_sec,
&isText, NULL );
- HChar* twoslots[2];
- HChar** names_init = alloc_symname_array(sym_name_pri, sym_names_sec,
- &twoslots[0]);
- HChar** names;
+ const HChar* twoslots[2];
+ const HChar** names_init =
+ alloc_symname_array(sym_name_pri, sym_names_sec, &twoslots[0]);
+ const HChar** names;
for (names = names_init; *names; names++) {
ok = isText
&& VG_(maybe_Z_demangle)(
Active act;
Int nsyms, i;
SymAVMAs sym_avmas;
- HChar* sym_name_pri;
- HChar** sym_names_sec;
+ const HChar* sym_name_pri;
+ const HChar** sym_names_sec;
/* First figure out which of the specs match the seginfo's soname.
Also clear the 'done' bits, so that after the main loop below
VG_(DebugInfo_syms_getidx)( di, i, &sym_avmas,
NULL, &sym_name_pri, &sym_names_sec,
&isText, &isIFunc );
- HChar* twoslots[2];
- HChar** names_init = alloc_symname_array(sym_name_pri, sym_names_sec,
- &twoslots[0]);
- HChar** names;
+ const HChar* twoslots[2];
+ const HChar** names_init =
+ alloc_symname_array(sym_name_pri, sym_names_sec, &twoslots[0]);
+ const HChar** names;
for (names = names_init; *names; names++) {
/* ignore data symbols */
static
void handle_maybe_load_notifier( const HChar* soname,
- HChar* symbol, Addr addr )
+ const HChar* symbol, Addr addr )
{
# if defined(VGP_x86_linux)
/* x86-linux only: if we see _dl_sysinfo_int80, note its address.
Int nsyms = VG_(DebugInfo_syms_howmany)(di);
for (j = 0; j < nsyms; j++) {
Bool isText = False;
- HChar* sym_name_pri = NULL;
- HChar** sym_names_sec = NULL;
+ const HChar* sym_name_pri = NULL;
+ const HChar** sym_names_sec = NULL;
VG_(DebugInfo_syms_getidx)( di, j, NULL,
NULL, &sym_name_pri, &sym_names_sec,
&isText, NULL );
- HChar* twoslots[2];
- HChar** names_init = alloc_symname_array(sym_name_pri, sym_names_sec,
- &twoslots[0]);
- HChar** names;
+ const HChar* twoslots[2];
+ const HChar** names_init =
+ alloc_symname_array(sym_name_pri, sym_names_sec, &twoslots[0]);
+ const HChar** names;
for (names = names_init; *names; names++) {
/* ignore data symbols */
if (0) VG_(printf)("QQQ %s\n", *names);
Int idx,
/*OUT*/SymAVMAs* ad,
/*OUT*/UInt* size,
- /*OUT*/HChar** pri_name,
- /*OUT*/HChar*** sec_names,
+ /*OUT*/const HChar** pri_name,
+ /*OUT*/const HChar*** sec_names,
/*OUT*/Bool* isText,
/*OUT*/Bool* isIFunc );
/* ppc64-linux only: find the TOC pointer (R2 value) that should be in
* (2) undoes C++ demangling, if 'do_cxx_demangle' is True. */
extern
void VG_(demangle) ( Bool do_cxx_demangling, Bool do_z_demangling,
- HChar* orig, HChar* result, Int result_size );
+ const HChar* orig, HChar* result, Int result_size );
/* Demangle a Z-encoded name as described in pub_tool_redir.h.
Z-encoded names are used by Valgrind for doing function
/* Allocates a new element from ddpa with eltSzB bytes to store elt.
This function never returns NULL. */
-extern void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa,
- SizeT eltSzB, const void *elt);
+extern const void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa,
+ SizeT eltSzB, const void *elt);
/* Allocates a new (fixed size) element from ddpa. Returns the
unique number identifying this element. This function never returns NULL. */