From d0dd4cbf303c478d24499e6399408d414dbef2e3 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Wed, 22 Oct 2014 17:42:37 +0000 Subject: [PATCH] Change VG_(allocEltDedupPA) to return a pointer to const. The reason is that once an element has been allocated and added to the pool it must not be modified afterwards. See the documentation in pub_tool_deduppoolalloc.h The rest of the patch is ripple. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14654 --- coregrind/m_debuginfo/debuginfo.c | 10 ++--- coregrind/m_debuginfo/priv_storage.h | 12 +++--- coregrind/m_debuginfo/readdwarf.c | 6 +-- coregrind/m_debuginfo/readdwarf3.c | 19 ++++----- coregrind/m_debuginfo/readelf.c | 4 +- coregrind/m_debuginfo/readpdb.c | 8 ++-- coregrind/m_debuginfo/storage.c | 41 +++++++++---------- coregrind/m_deduppoolalloc.c | 9 +++-- coregrind/m_demangle/demangle.c | 2 +- coregrind/m_redir.c | 59 ++++++++++++++-------------- coregrind/pub_core_debuginfo.h | 4 +- coregrind/pub_core_demangle.h | 2 +- include/pub_tool_deduppoolalloc.h | 4 +- 13 files changed, 90 insertions(+), 90 deletions(-) diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 9f6e708dd4..8485f19efe 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -2119,14 +2119,14 @@ Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, HChar* name, SymAVMAs* avmas) 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) { @@ -4249,8 +4249,8 @@ void VG_(DebugInfo_syms_getidx) ( const DebugInfo *si, 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 ) { @@ -4258,7 +4258,7 @@ void VG_(DebugInfo_syms_getidx) ( const DebugInfo *si, 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; } diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h index 89238d53d4..b836636c40 100644 --- a/coregrind/m_debuginfo/priv_storage.h +++ b/coregrind/m_debuginfo/priv_storage.h @@ -73,8 +73,8 @@ typedef 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 @@ -476,7 +476,7 @@ typedef 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. */ @@ -1045,18 +1045,18 @@ DiCfSI_m* ML_(get_cfsi_m) (struct _DebugInfo* di, UInt pos); /* 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. */ diff --git a/coregrind/m_debuginfo/readdwarf.c b/coregrind/m_debuginfo/readdwarf.c index c8021d3524..2877a621f5 100644 --- a/coregrind/m_debuginfo/readdwarf.c +++ b/coregrind/m_debuginfo/readdwarf.c @@ -71,7 +71,7 @@ static UInt safe_fndn_ix (XArray* fndn_ix_xa, Int xa_ix) /* 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; @@ -348,8 +348,8 @@ void read_dwarf2_lineblock ( struct _DebugInfo* di, 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; diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index 89c7e2fff0..96cbfb1638 100644 --- a/coregrind/m_debuginfo/readdwarf3.c +++ b/coregrind/m_debuginfo/readdwarf3.c @@ -1571,7 +1571,7 @@ void skip_DIE (UWord *sibling, 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 @@ -1838,7 +1838,7 @@ XArray* read_dirname_xa (struct _DebugInfo* di, const HChar *compdir, 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 ) { @@ -1847,7 +1847,7 @@ void read_filename_table( /*MOD*/XArray* /* of UInt* */ fndn_ix_Table, 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; @@ -2067,7 +2067,7 @@ static void parse_var_DIE ( 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; @@ -2248,7 +2248,7 @@ static void parse_var_DIE ( } 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; @@ -2549,7 +2549,7 @@ typedef 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; @@ -2557,7 +2557,7 @@ static HChar* get_inlFnName (Int absori, CUConst* cc, Bool td3) UInt has_children; UWord posn; Bool type_flag, alt_flag; - HChar *ret = NULL; + const HChar *ret = NULL; FormContents cts; UInt nf_i; @@ -2675,7 +2675,7 @@ static Bool parse_inl_DIE ( 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) { @@ -2789,7 +2789,8 @@ static Bool parse_inl_DIE ( /* 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 diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 0b94bdefaf..880d83099e 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -807,7 +807,7 @@ void read_elf_symtab__normal( 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", @@ -1042,7 +1042,7 @@ void read_elf_symtab__ppc64be_linux( disym.avmas.main, GET_TOCPTR_AVMA(disym.avmas), (Int) disym.size, - (HChar*)disym.pri_name + disym.pri_name ); } i++; diff --git a/coregrind/m_debuginfo/readpdb.c b/coregrind/m_debuginfo/readpdb.c index 01b57ac474..2502bf80f4 100644 --- a/coregrind/m_debuginfo/readpdb.c +++ b/coregrind/m_debuginfo/readpdb.c @@ -1211,7 +1211,7 @@ static ULong DEBUG_SnarfCodeView( { Int i, length; DiSym vsym; - HChar* nmstr; + const HChar* nmstr; HChar symname[4096 /*WIN32_PATH_MAX*/]; Bool debug = di->trace_symtab; @@ -1566,8 +1566,8 @@ static ULong DEBUG_SnarfLinetab( this_seg = 0; for (i = 0; i < nfile; i++) { - HChar *fnmstr; - HChar *dirstr; + const HChar *fnmstr; + const HChar *dirstr; UInt fnmdirstr_ix; /* @@ -1715,7 +1715,7 @@ static ULong codeview_dump_linetab2( while ((HChar*)lbh < linetab + size) { - HChar *filename, *dirname; + const HChar *filename, *dirname; UInt filedirname_ix; Addr svma_s, svma_e; if (lbh->header != 0x000000f2) { diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c index ab570be4a3..458f0c7449 100644 --- a/coregrind/m_debuginfo/storage.c +++ b/coregrind/m_debuginfo/storage.c @@ -94,7 +94,7 @@ void ML_(symerr) ( struct _DebugInfo* di, Bool serious, const HChar* msg ) /* 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); @@ -233,10 +233,8 @@ void ML_(ppDiCfSI) ( XArray* /* of CfiExpr */ exprs, 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 { @@ -248,8 +246,7 @@ HChar* ML_(addStr) ( struct _DebugInfo* di, const HChar* str, Int len ) 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, @@ -301,13 +298,13 @@ const HChar* ML_(fndn_ix2dirname) (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; } @@ -1145,7 +1142,7 @@ void ML_(addVar)( struct _DebugInfo* di, 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, @@ -1419,8 +1416,8 @@ static Int compare_DiSym ( const void* va, const void* vb ) 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; @@ -1481,7 +1478,7 @@ Bool preferName ( struct _DebugInfo* di, { Bool blankA = True; Bool blankB = True; - HChar *s; + const HChar *s; s = a_name; while (*s) { if (!VG_(isspace)(*s++)) { @@ -1565,8 +1562,8 @@ void add_DiSym_names_to_from ( DebugInfo* di, DiSym* to, DiSym* from ) 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) { @@ -1584,8 +1581,8 @@ void add_DiSym_names_to_from ( DebugInfo* di, DiSym* to, DiSym* from ) 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; @@ -1616,7 +1613,7 @@ static void canonicaliseSymtab ( struct _DebugInfo* di ) { 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) \ @@ -1742,7 +1739,7 @@ static void canonicaliseSymtab ( struct _DebugInfo* di ) 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) { @@ -1813,7 +1810,7 @@ static void canonicaliseSymtab ( struct _DebugInfo* di ) 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, @@ -1821,8 +1818,8 @@ static void canonicaliseSymtab ( struct _DebugInfo* di ) 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++; } @@ -1840,7 +1837,7 @@ static void canonicaliseSymtab ( struct _DebugInfo* di ) 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; diff --git a/coregrind/m_deduppoolalloc.c b/coregrind/m_deduppoolalloc.c index 1c34ab4377..2456e1b65e 100644 --- a/coregrind/m_deduppoolalloc.c +++ b/coregrind/m_deduppoolalloc.c @@ -76,7 +76,7 @@ typedef 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; @@ -231,7 +231,8 @@ void VG_(freezeDedupPA) (DedupPoolAlloc *ddpa, 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; @@ -252,7 +253,7 @@ void* VG_(allocEltDedupPA) (DedupPoolAlloc *ddpa, SizeT eltSzB, const void *elt) 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) @@ -298,7 +299,7 @@ UInt VG_(allocFixedEltDedupPA) (DedupPoolAlloc *ddpa, 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); } diff --git a/coregrind/m_demangle/demangle.c b/coregrind/m_demangle/demangle.c index 6220dddaf8..385ee8dd79 100644 --- a/coregrind/m_demangle/demangle.c +++ b/coregrind/m_demangle/demangle.c @@ -84,7 +84,7 @@ /* 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; diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c index 24403300bf..caca7c9665 100644 --- a/coregrind/m_redir.c +++ b/coregrind/m_redir.c @@ -311,7 +311,7 @@ static void show_redir_state ( const HChar* who ); 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* ); @@ -334,8 +334,9 @@ void generate_and_add_actives ( 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. */ @@ -346,10 +347,10 @@ static HChar** alloc_symname_array ( HChar* pri_name, HChar** sec_names, } /* 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; @@ -361,7 +362,7 @@ static HChar** alloc_symname_array ( HChar* pri_name, HChar** 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); @@ -395,8 +396,8 @@ void VG_(redir_notify_new_DebugInfo)( DebugInfo* newdi ) 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]; @@ -511,10 +512,10 @@ void VG_(redir_notify_new_DebugInfo)( DebugInfo* newdi ) 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, @@ -621,10 +622,10 @@ void VG_(redir_notify_new_DebugInfo)( DebugInfo* newdi ) 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)( @@ -758,8 +759,8 @@ void generate_and_add_actives ( 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 @@ -783,10 +784,10 @@ void generate_and_add_actives ( 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 */ @@ -1533,7 +1534,7 @@ static Bool is_plausible_guest_addr(Addr a) 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. @@ -1634,15 +1635,15 @@ static void handle_require_text_symbols ( DebugInfo* di ) 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); diff --git a/coregrind/pub_core_debuginfo.h b/coregrind/pub_core_debuginfo.h index a455d74166..8060e824d6 100644 --- a/coregrind/pub_core_debuginfo.h +++ b/coregrind/pub_core_debuginfo.h @@ -197,8 +197,8 @@ void VG_(DebugInfo_syms_getidx) ( const DebugInfo *di, 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 diff --git a/coregrind/pub_core_demangle.h b/coregrind/pub_core_demangle.h index b3e5307d39..bf6c667ee1 100644 --- a/coregrind/pub_core_demangle.h +++ b/coregrind/pub_core_demangle.h @@ -43,7 +43,7 @@ * (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 diff --git a/include/pub_tool_deduppoolalloc.h b/include/pub_tool_deduppoolalloc.h index 2ba7f2063d..ba239bf4a3 100644 --- a/include/pub_tool_deduppoolalloc.h +++ b/include/pub_tool_deduppoolalloc.h @@ -95,8 +95,8 @@ extern DedupPoolAlloc* VG_(newDedupPA) ( SizeT poolSzB, /* 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. */ -- 2.47.2