]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change VG_(allocEltDedupPA) to return a pointer to const. The reason is
authorFlorian Krohm <florian@eich-krohm.de>
Wed, 22 Oct 2014 17:42:37 +0000 (17:42 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Wed, 22 Oct 2014 17:42:37 +0000 (17:42 +0000)
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

13 files changed:
coregrind/m_debuginfo/debuginfo.c
coregrind/m_debuginfo/priv_storage.h
coregrind/m_debuginfo/readdwarf.c
coregrind/m_debuginfo/readdwarf3.c
coregrind/m_debuginfo/readelf.c
coregrind/m_debuginfo/readpdb.c
coregrind/m_debuginfo/storage.c
coregrind/m_deduppoolalloc.c
coregrind/m_demangle/demangle.c
coregrind/m_redir.c
coregrind/pub_core_debuginfo.h
coregrind/pub_core_demangle.h
include/pub_tool_deduppoolalloc.h

index 9f6e708dd421ada40c86728dd61ef9ac5ecb0198..8485f19efeeba96e387238ef0205f58c6492a431 100644 (file)
@@ -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;
 }
index 89238d53d4dab327697761ca59c85f92ebb9d056..b836636c40870dc88d83a750a59bf225fdacdaee 100644 (file)
@@ -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. */
index c8021d3524af7fc01aff5d0214eb291d9602c35d..2877a621f55915c5014b77d8f05d5c47f9f5c834 100644 (file)
@@ -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;
index 89c7e2fff09b394a01adc9157e11de90213ce130..96cbfb1638f01d06ce8038ff684cc616abbdcb1d 100644 (file)
@@ -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
index 0b94bdefaf8bfd96a57054662c875140bdefe397..880d83099ea51d81448bc0dc3b085e39c4f03a11 100644 (file)
@@ -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++;
index 01b57ac4746e94cdb241788e7af28af19e1a400e..2502bf80f4fb12e0a00bd7cf90e39533045a35df 100644 (file)
@@ -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) {
index ab570be4a39c11b5ab8a5b53dc103a9494444998..458f0c7449304e6e5583652783bf376aecdab596 100644 (file)
@@ -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;
index 1c34ab4377cb5ca7cb178329cdee8bdb84964d14..2456e1b65eab321335df2dec80516f4896b95544 100644 (file)
@@ -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);
 }
 
index 6220dddaf839a5e12ff75d9378d65ea75ce0b244..385ee8dd79c777aa891fb7caf88dd46195ec41c6 100644 (file)
@@ -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;
index 24403300bfc23c892245686883970f6e06d5e5ea..caca7c96657e79966aa120a03df432b1db06c980 100644 (file)
@@ -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);
index a455d741663a9b982ae80f6774a6ca4b0a1a2ed7..8060e824d6ec397994d0e8574279cfbe0f5d5996 100644 (file)
@@ -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
index b3e5307d390b8ea8335d5f3ad242b5c411eaeb20..bf6c667ee1c97856c4c2768a46eae6bb26158b08 100644 (file)
@@ -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 
index 2ba7f2063df6ac5c20f384bcf0748d90cb3cbb13..ba239bf4a321f596fcde4c6ddf36df07f2da0b5c 100644 (file)
@@ -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. */