Constify coregrind.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14656 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_addrinfo.c b/coregrind/m_addrinfo.c
index 582b960..95ec0fe 100644
--- a/coregrind/m_addrinfo.c
+++ b/coregrind/m_addrinfo.c
@@ -349,7 +349,8 @@
       return tinfo.tid;
 }
 
-static void pp_addrinfo_WRK ( Addr a, AddrInfo* ai, Bool mc, Bool maybe_gcc )
+static void pp_addrinfo_WRK ( Addr a, const AddrInfo* ai, Bool mc,
+                              Bool maybe_gcc )
 {
    const HChar* xpre  = VG_(clo_xml) ? "  <auxwhat>" : " ";
    const HChar* xpost = VG_(clo_xml) ? "</auxwhat>"  : "";
@@ -560,12 +561,12 @@
    }
 }
 
-void VG_(pp_addrinfo) ( Addr a, AddrInfo* ai )
+void VG_(pp_addrinfo) ( Addr a, const AddrInfo* ai )
 {
    pp_addrinfo_WRK (a, ai, False /*mc*/, False /*maybe_gcc*/);
 }
 
-void VG_(pp_addrinfo_mc) ( Addr a, AddrInfo* ai, Bool maybe_gcc )
+void VG_(pp_addrinfo_mc) ( Addr a, const AddrInfo* ai, Bool maybe_gcc )
 {
    pp_addrinfo_WRK (a, ai, True /*mc*/, maybe_gcc);
 }
diff --git a/coregrind/m_debugger.c b/coregrind/m_debugger.c
index 4af8f18..45f4243 100644
--- a/coregrind/m_debugger.c
+++ b/coregrind/m_debugger.c
@@ -47,7 +47,7 @@
 #define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
 #define WSTOPSIG(status) (((status) & 0xff00) >> 8)
 
-static Int ptrace_setregs(Int pid, VexGuestArchState* vex)
+static Int ptrace_setregs(Int pid, const VexGuestArchState* vex)
 {
 #if defined(VGP_x86_linux)
    struct vki_user_regs_struct regs;
diff --git a/coregrind/m_debuginfo/d3basics.c b/coregrind/m_debuginfo/d3basics.c
index 3e13241..d3f6735 100644
--- a/coregrind/m_debuginfo/d3basics.c
+++ b/coregrind/m_debuginfo/d3basics.c
@@ -343,7 +343,7 @@
 
 /* FIXME: duplicated in readdwarf.c */
 static 
-ULong read_leb128 ( UChar* data, Int* length_return, Int sign )
+ULong read_leb128 ( const UChar* data, Int* length_return, Int sign )
 {
   ULong  result = 0;
   UInt   num_read = 0;
@@ -397,7 +397,7 @@
 
 /* FIXME: duplicates logic in readdwarf.c: copy_convert_CfiExpr_tree
    and {FP,SP}_REG decls */
-static Bool get_Dwarf_Reg( /*OUT*/Addr* a, Word regno, RegSummary* regs )
+static Bool get_Dwarf_Reg( /*OUT*/Addr* a, Word regno, const RegSummary* regs )
 {
    vg_assert(regs);
 #  if defined(VGP_x86_linux) || defined(VGP_x86_darwin)
@@ -474,7 +474,7 @@
 /* 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, RegSummary* regs,
+                                     GExpr* fbGX, const RegSummary* regs,
                                      const DebugInfo* di,
                                      Bool push_initial_zero )
 {
@@ -943,7 +943,7 @@
 /* Evaluate a so-called Guarded (DWARF3) expression.  See detailed
    description in priv_d3basics.h. */
 GXResult ML_(evaluate_GX)( GExpr* gx, GExpr* fbGX,
-                           RegSummary* regs, const DebugInfo* di )
+                           const RegSummary* regs, const DebugInfo* di )
 {
    GXResult res;
    Addr     aMin, aMax;
@@ -1191,11 +1191,12 @@
 }
 
 
-void ML_(pp_GX) ( GExpr* gx ) {
+void ML_(pp_GX) ( const GExpr* gx )
+{
    Addr   aMin, aMax;
    UChar  uc;
    UShort nbytes;
-   UChar* p = &gx->payload[0];
+   const UChar* p = &gx->payload[0];
    uc = *p++;
    VG_(printf)("GX(%s){", uc == 0 ? "final" : "Breqd" );
    vg_assert(uc == 0 || uc == 1);
diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c
index 8485f19..3d61d57 100644
--- a/coregrind/m_debuginfo/debuginfo.c
+++ b/coregrind/m_debuginfo/debuginfo.c
@@ -187,7 +187,7 @@
    di->fsm.filename = ML_(dinfo_strdup)("di.debuginfo.aDI.2", filename);
    di->fsm.maps     = VG_(newXA)(
                          ML_(dinfo_zalloc), "di.debuginfo.aDI.3",
-                         ML_(dinfo_free), sizeof(struct _DebugInfoMapping));
+                         ML_(dinfo_free), sizeof(DebugInfoMapping));
 
    /* Everything else -- pointers, sizes, arrays -- is zeroed by
       ML_(dinfo_zalloc).  Now set up the debugging-output flags. */
@@ -402,15 +402,15 @@
 
 
 /* Do the basic mappings of the two DebugInfos overlap in any way? */
-static Bool do_DebugInfos_overlap ( DebugInfo* di1, DebugInfo* di2 )
+static Bool do_DebugInfos_overlap ( const DebugInfo* di1, const DebugInfo* di2 )
 {
    Word i, j;
    vg_assert(di1);
    vg_assert(di2);
    for (i = 0; i < VG_(sizeXA)(di1->fsm.maps); i++) {
-      struct _DebugInfoMapping* map1 = VG_(indexXA)(di1->fsm.maps, i);
+      const DebugInfoMapping* map1 = VG_(indexXA)(di1->fsm.maps, i);
       for (j = 0; j < VG_(sizeXA)(di2->fsm.maps); j++) {
-         struct _DebugInfoMapping* map2 = VG_(indexXA)(di2->fsm.maps, j);
+         const DebugInfoMapping* map2 = VG_(indexXA)(di2->fsm.maps, j);
          if (ranges_overlap(map1->avma, map1->size, map2->avma, map2->size))
             return True;
       }
@@ -467,7 +467,7 @@
 /* Find the existing DebugInfo for |filename| or if not found, create
    one.  In the latter case |filename| is strdup'd into VG_AR_DINFO,
    and the new DebugInfo is added to debugInfo_list. */
-static DebugInfo* find_or_create_DebugInfo_for ( HChar* filename )
+static DebugInfo* find_or_create_DebugInfo_for ( const HChar* filename )
 {
    DebugInfo* di;
    vg_assert(filename);
@@ -490,7 +490,7 @@
    Check that the invariants stated in
    "Comment_on_IMPORTANT_CFSI_REPRESENTATIONAL_INVARIANTS" in
    priv_storage.h are observed. */
-static void check_CFSI_related_invariants ( DebugInfo* di )
+static void check_CFSI_related_invariants ( const DebugInfo* di )
 {
    DebugInfo* di2 = NULL;
    Bool has_nonempty_rx = False;
@@ -503,7 +503,7 @@
    vg_assert(di->fsm.have_rx_map);
    vg_assert(di->fsm.have_rw_map);
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-      struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+      const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       /* We are interested in r-x mappings only */
       if (!map->rx)
          continue;
@@ -522,7 +522,7 @@
          if (di2 == di)
             continue;
          for (j = 0; j < VG_(sizeXA)(di2->fsm.maps); j++) {
-            struct _DebugInfoMapping* map2 = VG_(indexXA)(di2->fsm.maps, j);
+            const DebugInfoMapping* map2 = VG_(indexXA)(di2->fsm.maps, j);
             if (!map2->rx || map2->size == 0)
                continue;
             vg_assert(!ranges_overlap(map->avma,  map->size,
@@ -601,8 +601,8 @@
 #if defined(VGO_linux)  ||  defined(VGO_darwin)
 
 /* Helper (indirect) for di_notify_ACHIEVE_ACCEPT_STATE */
-static Bool overlaps_DebugInfoMappings ( struct _DebugInfoMapping* map1,
-                                         struct _DebugInfoMapping* map2 )
+static Bool overlaps_DebugInfoMappings ( const DebugInfoMapping* map1,
+                                         const DebugInfoMapping* map2 )
 {
    vg_assert(map1 && map2 && map1 != map2);
    vg_assert(map1->size != 0 && map2->size != 0);
@@ -614,15 +614,14 @@
 
 /* Helper (indirect) for di_notify_ACHIEVE_ACCEPT_STATE */
 static void show_DebugInfoMappings 
-               ( struct _DebugInfo* di,
-                 /*MOD*/XArray* maps /* XArray<struct _DebugInfoMapping> */ )
+               ( const DebugInfo* di,
+                 /*MOD*/XArray* maps /* XArray<DebugInfoMapping> */ )
 {
    Word i, n;
    vg_assert(maps);
    n = VG_(sizeXA)(maps);
    for (i = 0; i < n; i++) {
-      struct _DebugInfoMapping* map
-         = (struct _DebugInfoMapping*) VG_(indexXA)(maps, i);
+      const DebugInfoMapping* map = VG_(indexXA)(maps, i);
       TRACE_SYMTAB("  [%ld]    avma 0x%-16llx    size %-8lu    "
                    "foff %-8lld    %s %s %s\n",
                    i, (ULong)map->avma, map->size, (Long)map->foff,
@@ -640,26 +639,26 @@
    function returns (rather than asserts) that |maps| is overlap
    free. */
 static void truncate_DebugInfoMapping_overlaps
-               ( struct _DebugInfo* di,
-                 /*MOD*/XArray* maps /* XArray<struct _DebugInfoMapping> */ )
+               ( const DebugInfo* di,
+                 /*MOD*/XArray* maps /* XArray<DebugInfoMapping> */ )
 {
    TRACE_SYMTAB("Un-de-overlapped _DebugInfoMappings:\n");
    show_DebugInfoMappings(di, maps);
    TRACE_SYMTAB("\n");
 
    Word i, j, n;
-   struct _DebugInfoMapping *map_i, *map_j;
+   DebugInfoMapping *map_i, *map_j;
 
    n = VG_(sizeXA)(maps);
    for (i = 0; i < n; i++) {
 
-      map_i = (struct _DebugInfoMapping*) VG_(indexXA)(maps, i);
+      map_i = VG_(indexXA)(maps, i);
       if (map_i->size == 0)
         continue; // Hmm, mutancy.  Shouldn't happen.
 
       for (j = i+1; j < n; j++) {
 
-         map_j = (struct _DebugInfoMapping*) VG_(indexXA)(maps, j);
+         map_j = VG_(indexXA)(maps, j);
          if (map_j->size == 0)
            continue; // Hmm, mutancy.  Shouldn't happen.
 
@@ -679,17 +678,17 @@
       }
    }
 
-   TRACE_SYMTAB("De-overlapped _DebugInfoMappings:\n");
+   TRACE_SYMTAB("De-overlapped DebugInfoMappings:\n");
    show_DebugInfoMappings(di, maps);
    TRACE_SYMTAB("\n");
    TRACE_SYMTAB("Checking that there are no remaining overlaps.\n");
 
    for (i = 0; i < n; i++) {
-      map_i = (struct _DebugInfoMapping*) VG_(indexXA)(maps, i);
+      map_i = VG_(indexXA)(maps, i);
       if (map_i->size == 0)
         continue;
       for (j = i+1; j < n; j++) {
-         map_j = (struct _DebugInfoMapping*) VG_(indexXA)(maps, j);
+         map_j = VG_(indexXA)(maps, j);
          if (map_j->size == 0)
            continue;
          Bool overlap
@@ -1035,7 +1034,7 @@
                   "noting details in DebugInfo* at %p\n", di);
 
    /* Note the details about the mapping. */
-   struct _DebugInfoMapping map;
+   DebugInfoMapping map;
    map.avma = a;
    map.size = seg->end + 1 - seg->start;
    map.foff = seg->offset;
@@ -1134,7 +1133,7 @@
    if (debug)
       VG_(printf)("di_notify_vm_protect-3: looking for existing DebugInfo*\n");
    DebugInfo* di;
-   struct _DebugInfoMapping *map = NULL;
+   DebugInfoMapping *map = NULL;
    Word i;
    for (di = debugInfo_list; di; di = di->next) {
       vg_assert(di->fsm.filename);
@@ -1148,7 +1147,7 @@
          continue; /* need to have a rw- mapping */
       /* Try to find a mapping matching the memory area. */
       for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-         map = (struct _DebugInfoMapping*)VG_(indexXA)(di->fsm.maps, i);
+         map = VG_(indexXA)(di->fsm.maps, i);
          if (map->ro && map->avma == a && map->size == len)
             break;
          map = NULL;
@@ -1174,7 +1173,7 @@
    di->fsm.have_ro_map = False;
    /* See if there are any more ro mappings */
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-      map = (struct _DebugInfoMapping*)VG_(indexXA)(di->fsm.maps, i);
+      map = VG_(indexXA)(di->fsm.maps, i);
       if (map->ro) {
          di->fsm.have_ro_map = True;
          break;
@@ -1444,8 +1443,7 @@
 }
 
 
-struct _DebugInfoMapping* ML_(find_rx_mapping) ( struct _DebugInfo* di,
-                                                 Addr lo, Addr hi )
+DebugInfoMapping* ML_(find_rx_mapping) ( DebugInfo* di, Addr lo, Addr hi )
 {
    Word i;
    vg_assert(lo <= hi); 
@@ -1457,7 +1455,7 @@
       return di->last_rx_map;
 
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-      struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+      DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (   map->rx && map->size > 0
           && lo >= map->avma && hi < map->avma + map->size) {
          di->last_rx_map = map;
@@ -1487,12 +1485,12 @@
                          // level.
 };
 
-static Bool is_top(InlIPCursor *iipc)
+static Bool is_top(const InlIPCursor *iipc)
 {
    return !iipc || iipc->cur_inltab == -1;
 }
 
-static Bool is_bottom(InlIPCursor *iipc)
+static Bool is_bottom(const InlIPCursor *iipc)
 {
    return !iipc || iipc->next_inltab == -1;
 }
@@ -2101,11 +2099,12 @@
    Therefore specify "*" to search all the objects.  On TOC-afflicted
    platforms, a symbol is deemed to be found only if it has a nonzero
    TOC pointer.  */
-Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, HChar* name, SymAVMAs* avmas)
+Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, const HChar* name,
+                             SymAVMAs* avmas)
 {
    Bool     require_pToc = False;
    Int      i;
-   DebugInfo* si;
+   const DebugInfo* si;
    Bool     debug = False;
 #  if defined(VG_PLAT_USES_PPCTOC)
    require_pToc = True;
@@ -3178,11 +3177,11 @@
 static void format_message ( /*MOD*/XArray* /* of HChar */ dn1,
                              /*MOD*/XArray* /* of HChar */ dn2,
                              Addr     data_addr,
-                             DebugInfo* di,
-                             DiVariable* var,
+                             const DebugInfo* di,
+                             const DiVariable* var,
                              PtrdiffT var_offset,
                              PtrdiffT residual_offset,
-                             XArray* /*HChar*/ described,
+                             const XArray* /*HChar*/ described,
                              Int      frameNo, 
                              ThreadId tid )
 {
diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c
index a289f44..21ebe30 100644
--- a/coregrind/m_debuginfo/image.c
+++ b/coregrind/m_debuginfo/image.c
@@ -104,7 +104,7 @@
    }
 }
 
-static UInt read_UInt_le ( UChar* src )
+static UInt read_UInt_le ( const UChar* src )
 {
    UInt r = 0;
    Int i;
@@ -124,7 +124,7 @@
    }
 }
 
-static ULong read_ULong_le ( UChar* src )
+static ULong read_ULong_le ( const UChar* src )
 {
    ULong r = 0;
    Int i;
@@ -168,7 +168,7 @@
    fd has been set in blocking mode.  If it returns with the number of
    bytes written < len, it means that either fd was closed, or there was
    an error on it. */
-static Int my_write ( Int fd, UChar* buf, Int len )
+static Int my_write ( Int fd, const UChar* buf, Int len )
 {
    Int nWritten = 0;
    while (1) {
@@ -212,7 +212,7 @@
    return the frame it sends back.  Caller owns the resulting frame
    and must free it.  A NULL return means the transaction failed for
    some reason. */
-static Frame* do_transaction ( Int sd, Frame* req )
+static Frame* do_transaction ( Int sd, const Frame* req )
 {
    if (0) VG_(printf)("CLIENT: send %c%c%c%c\n",
                       req->data[0], req->data[1], req->data[2], req->data[3]);
@@ -387,7 +387,7 @@
 }
 
 /* Is this offset inside this CEnt? */
-static inline Bool is_in_CEnt ( CEnt* cent, DiOffT off )
+static inline Bool is_in_CEnt ( const CEnt* cent, DiOffT off )
 {
    /* This assertion is checked by set_CEnt, so checking it here has
       no benefit, whereas skipping it does remove it from the hottest
@@ -766,13 +766,13 @@
    ML_(dinfo_free)(img);
 }
 
-DiOffT ML_(img_size)(DiImage* img)
+DiOffT ML_(img_size)(const DiImage* img)
 {
    vg_assert(img);
    return img->size;
 }
 
-inline Bool ML_(img_valid)(DiImage* img, DiOffT offset, SizeT size)
+inline Bool ML_(img_valid)(const DiImage* img, DiOffT offset, SizeT size)
 {
    vg_assert(img);
    vg_assert(offset != DiOffT_INVALID);
@@ -784,7 +784,7 @@
    image, which normally means the image is corrupted somehow, or the
    caller is buggy.  Recovering is too complex, and we have
    probably-corrupt debuginfo, so just give up. */
-static void ensure_valid(DiImage* img, DiOffT offset, SizeT size,
+static void ensure_valid(const DiImage* img, DiOffT offset, SizeT size,
                          const HChar* caller)
 {
    if (LIKELY(ML_(img_valid)(img, offset, size)))
diff --git a/coregrind/m_debuginfo/misc.c b/coregrind/m_debuginfo/misc.c
index 271fd01..25ea58e 100644
--- a/coregrind/m_debuginfo/misc.c
+++ b/coregrind/m_debuginfo/misc.c
@@ -62,7 +62,7 @@
    return VG_(arena_strdup)( VG_AR_DINFO, cc, str );
 }
 
-void* ML_(dinfo_memdup) ( const HChar* cc, void* str, SizeT nStr ) {
+void* ML_(dinfo_memdup) ( const HChar* cc, const void* str, SizeT nStr ) {
    void* dst = VG_(arena_malloc)( VG_AR_DINFO, cc, nStr );
    VG_(memcpy)(dst, str, nStr);
    return dst;
@@ -74,7 +74,7 @@
    return toBool(*p == 0x10);
 }
 
-Short ML_(read_Short)( UChar* data ) {
+Short ML_(read_Short)( const UChar* data ) {
    Short r = 0;
    if (host_is_little_endian()) {
       r = data[0]
@@ -86,7 +86,7 @@
    return r;
 }
 
-Int ML_(read_Int) ( UChar* data ) {
+Int ML_(read_Int) ( const UChar* data ) {
    Int r = 0;
    if (host_is_little_endian()) {
       r = data[0]
@@ -102,7 +102,7 @@
    return r;
 }
 
-Long ML_(read_Long) ( UChar* data ) {
+Long ML_(read_Long) ( const UChar* data ) {
    Long r = 0;
    if (host_is_little_endian()) {
       r = data[0]
@@ -126,7 +126,7 @@
    return r;
 }
 
-UShort ML_(read_UShort) ( UChar* data ) {
+UShort ML_(read_UShort) ( const UChar* data ) {
    UInt r = 0;
    if (host_is_little_endian()) {
       r = data[0]
@@ -149,7 +149,7 @@
    return ptr + sizeof(UShort);
 }
 
-UWord ML_(read_UWord) ( UChar* data ) {
+UWord ML_(read_UWord) ( const UChar* data ) {
    if (sizeof(UWord) == sizeof(UInt)) {
       return ML_(read_UInt)(data);
    } else if  (sizeof(UWord) == sizeof(ULong)) {
@@ -159,7 +159,7 @@
    }
 }
 
-UInt ML_(read_UInt) ( UChar* data ) {
+UInt ML_(read_UInt) ( const UChar* data ) {
    UInt r = 0;
    if (host_is_little_endian()) {
       r = data[0]
@@ -190,7 +190,7 @@
    return ptr + sizeof(UInt);
 }
 
-ULong ML_(read_ULong) ( UChar* data ) {
+ULong ML_(read_ULong) ( const UChar* data ) {
    ULong r = 0;
    if (host_is_little_endian()) {
       r = data[0]
@@ -237,7 +237,7 @@
    return ptr + sizeof(ULong);
 }
 
-UChar ML_(read_UChar) ( UChar* data ) {
+UChar ML_(read_UChar) ( const UChar* data ) {
    return data[0];
 }
 
@@ -246,7 +246,7 @@
    return ptr + sizeof(UChar);
 }
 
-Addr ML_(read_Addr) ( UChar* data ) {
+Addr ML_(read_Addr) ( const UChar* data ) {
    if (sizeof(Addr) == sizeof(UInt)) {
       return ML_(read_UInt)(data);
    } else if  (sizeof(Addr) == sizeof(ULong)) {
diff --git a/coregrind/m_debuginfo/priv_d3basics.h b/coregrind/m_debuginfo/priv_d3basics.h
index b2bf610..1366b11 100644
--- a/coregrind/m_debuginfo/priv_d3basics.h
+++ b/coregrind/m_debuginfo/priv_d3basics.h
@@ -613,7 +613,7 @@
    GExpr;
 
 /* Show a so-called guarded expression */
-void ML_(pp_GX) ( GExpr* gx );
+void ML_(pp_GX) ( const GExpr* gx );
 
 /* Evaluation of a DWARF3 expression (and hence of a GExpr) may
    require knowing a suitably contextualising set of values for the
@@ -653,7 +653,7 @@
    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,
-                           RegSummary* regs, const DebugInfo* di );
+                           const RegSummary* regs, const DebugInfo* di );
 
 /* This is a subsidiary of ML_(evaluate_GX), which just evaluates a
    single standard DWARF3 expression.  Conventions w.r.t regs and fbGX
@@ -663,7 +663,7 @@
    ML_(evaluate_GX) and ML_(evaluate_Dwarf3_Expr) are mutually
    recursive. */
 GXResult ML_(evaluate_Dwarf3_Expr) ( UChar* expr, UWord exprszB, 
-                                     GExpr* fbGX, RegSummary* regs,
+                                     GExpr* fbGX, const RegSummary* regs,
                                      const DebugInfo* di,
                                      Bool push_initial_zero );
 
diff --git a/coregrind/m_debuginfo/priv_image.h b/coregrind/m_debuginfo/priv_image.h
index 169f344..083ed78 100644
--- a/coregrind/m_debuginfo/priv_image.h
+++ b/coregrind/m_debuginfo/priv_image.h
@@ -75,10 +75,10 @@
 void ML_(img_done)(DiImage*);
 
 /* How big is the image? */
-DiOffT ML_(img_size)(DiImage* img);
+DiOffT ML_(img_size)(const DiImage* img);
 
 /* Does the section [offset, +size) exist in the image? */
-Bool ML_(img_valid)(DiImage* img, DiOffT offset, SizeT size);
+Bool ML_(img_valid)(const DiImage* img, DiOffT offset, SizeT size);
 
 /* Get info out of an image.  If any part of the section denoted by
    [offset, +size) is invalid, does not return. */
diff --git a/coregrind/m_debuginfo/priv_misc.h b/coregrind/m_debuginfo/priv_misc.h
index 4031e17..0828290 100644
--- a/coregrind/m_debuginfo/priv_misc.h
+++ b/coregrind/m_debuginfo/priv_misc.h
@@ -43,19 +43,19 @@
 void*  ML_(dinfo_zalloc)( const HChar* cc, SizeT szB );
 void   ML_(dinfo_free)( void* v );
 HChar* ML_(dinfo_strdup)( const HChar* cc, const HChar* str );
-void*  ML_(dinfo_memdup)( const HChar* cc, void* str, SizeT nStr );
+void*  ML_(dinfo_memdup)( const HChar* cc, const void* str, SizeT nStr );
 void   ML_(dinfo_shrink_block)( void* ptr, SizeT szB );
 
 /* Extract (possibly unaligned) data of various sizes from a buffer. */
-Short ML_(read_Short)( UChar* data );
-Int ML_(read_Int)( UChar* data );
-Long ML_(read_Long)( UChar* data );
-UShort ML_(read_UShort)( UChar* data );
-UWord ML_(read_UWord)( UChar* data );
-UInt ML_(read_UInt)( UChar* data );
-ULong ML_(read_ULong)( UChar* data );
-UChar ML_(read_UChar)( UChar* data );
-Addr ML_(read_Addr)( UChar* data );
+Short ML_(read_Short)( const UChar* data );
+Int ML_(read_Int)( const UChar* data );
+Long ML_(read_Long)( const UChar* data );
+UShort ML_(read_UShort)( const UChar* data );
+UWord ML_(read_UWord)( const UChar* data );
+UInt ML_(read_UInt)( const UChar* data );
+ULong ML_(read_ULong)( const UChar* data );
+UChar ML_(read_UChar)( const UChar* data );
+Addr ML_(read_Addr)( const UChar* data );
 
 UChar* ML_(write_UShort)( UChar* ptr, UShort val );
 UChar* ML_(write_UInt)( UChar* ptr, UInt val );
diff --git a/coregrind/m_debuginfo/priv_readelf.h b/coregrind/m_debuginfo/priv_readelf.h
index 59ae353..22c58e9 100644
--- a/coregrind/m_debuginfo/priv_readelf.h
+++ b/coregrind/m_debuginfo/priv_readelf.h
@@ -43,7 +43,8 @@
 
 /* Identify an ELF object file by peering at the first few bytes of
    it. */
-extern Bool ML_(is_elf_object_file)( void* image, SizeT n_image, Bool rel_ok );
+extern Bool ML_(is_elf_object_file)( const void* image, SizeT n_image,
+                                     Bool rel_ok );
 
 /* The central function for reading ELF debug info.  For the
    object/exe specified by the SegInfo, find ELF sections, then read
diff --git a/coregrind/m_debuginfo/priv_readpdb.h b/coregrind/m_debuginfo/priv_readpdb.h
index bdef9c9..117a8c5 100644
--- a/coregrind/m_debuginfo/priv_readpdb.h
+++ b/coregrind/m_debuginfo/priv_readpdb.h
@@ -47,14 +47,14 @@
                PtrdiffT   obj_bias,
                void*      pdbimage,
                SizeT      n_pdbimage,
-               HChar*     pdbname,
+               const HChar* pdbname,
                ULong      pdbmtime
             );
 
 /* Finds the name of the PDB file that's embedded with the specified
    PE file, or NULL on failure.  Caller deallocates with
    ML_(dinfo_free). */
-HChar* ML_(find_name_of_pdb_file)( HChar* pename );
+HChar* ML_(find_name_of_pdb_file)( const HChar* pename );
 
 
 #endif /* ndef __PRIV_READPDB_H */
diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h
index b836636..1f02503 100644
--- a/coregrind/m_debuginfo/priv_storage.h
+++ b/coregrind/m_debuginfo/priv_storage.h
@@ -439,7 +439,7 @@
 extern Int ML_(CfiExpr_CfiReg)( XArray* dst, CfiReg reg );
 extern Int ML_(CfiExpr_DwReg) ( XArray* dst, Int reg );
 
-extern void ML_(ppCfiExpr)( XArray* src, Int ix );
+extern void ML_(ppCfiExpr)( const XArray* src, Int ix );
 
 /* ---------------- FPO INFO (Windows PE) -------------- */
 
@@ -532,19 +532,19 @@
    relocation, which only appears to be the case for 32 bit objects.
 */
 
-struct _DebugInfoMapping
+typedef struct
 {
    Addr  avma; /* these fields record the file offset, length */
    SizeT size; /* and map address of each mapping             */
    OffT  foff;
    Bool  rx, rw, ro;  /* memory access flags for this mapping */
-};
+} DebugInfoMapping;
 
 struct _DebugInfoFSM
 {
    HChar*  filename;  /* in mallocville (VG_AR_DINFO)               */
    HChar*  dbgname;   /* in mallocville (VG_AR_DINFO)               */
-   XArray* maps;      /* XArray of _DebugInfoMapping structs        */
+   XArray* maps;      /* XArray of DebugInfoMapping structs         */
    Bool  have_rx_map; /* did we see a r?x mapping yet for the file? */
    Bool  have_rw_map; /* did we see a rw? mapping yet for the file? */
    Bool  have_ro_map; /* did we see a r-- mapping yet for the file? */
@@ -975,7 +975,7 @@
    /* Cached last rx mapping matched and returned by ML_(find_rx_mapping).
       This helps performance a lot during ML_(addLineInfo) etc., which can
       easily be invoked hundreds of thousands of times. */
-   struct _DebugInfoMapping* last_rx_map;
+   DebugInfoMapping* last_rx_map;
 };
 
 /* --------------------- functions --------------------- */
@@ -997,17 +997,17 @@
 
 /* Returns the filename of the fndn pair identified by fndn_ix.
    Returns "???" if fndn_ix is 0. */
-extern const HChar* ML_(fndn_ix2filename) (struct _DebugInfo* di,
+extern const HChar* ML_(fndn_ix2filename) (const DebugInfo* di,
                                            UInt fndn_ix);
 
 /* Returns the dirname of the fndn pair identified by fndn_ix.
    Returns "" if fndn_ix is 0 or fndn->dirname is NULL. */
-extern const HChar* ML_(fndn_ix2dirname) (struct _DebugInfo* di,
+extern const HChar* ML_(fndn_ix2dirname) (const DebugInfo* di,
                                           UInt fndn_ix);
 
 /* Returns the fndn_ix for the LineInfo locno in di->loctab.
    0 if filename/dirname are unknown. */
-extern UInt ML_(fndn_ix) (struct _DebugInfo* di, Word locno);
+extern UInt ML_(fndn_ix) (const DebugInfo* di, Word locno);
 
 /* Add a line-number record to a DebugInfo.
    fndn_ix is an index in di->fndnpool, allocated using  ML_(addFnDn).
@@ -1041,7 +1041,7 @@
 /* Given a position in the di->cfsi_base/cfsi_m_ix arrays, return
    the corresponding cfsi_m*. Return NULL if the position corresponds
    to a cfsi hole. */
-DiCfSI_m* ML_(get_cfsi_m) (struct _DebugInfo* di, UInt pos);
+DiCfSI_m* ML_(get_cfsi_m) (const 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. */
@@ -1083,28 +1083,28 @@
 
 /* Find a symbol-table index containing the specified pointer, or -1
    if not found.  Binary search.  */
-extern Word ML_(search_one_symtab) ( struct _DebugInfo* di, Addr ptr,
+extern Word ML_(search_one_symtab) ( const DebugInfo* di, Addr ptr,
                                      Bool match_anywhere_in_sym,
                                      Bool findText );
 
 /* Find a location-table index containing the specified pointer, or -1
    if not found.  Binary search.  */
-extern Word ML_(search_one_loctab) ( struct _DebugInfo* di, Addr ptr );
+extern Word ML_(search_one_loctab) ( const DebugInfo* di, Addr ptr );
 
 /* Find a CFI-table index containing the specified pointer, or -1 if
    not found.  Binary search.  */
-extern Word ML_(search_one_cfitab) ( struct _DebugInfo* di, Addr ptr );
+extern Word ML_(search_one_cfitab) ( const DebugInfo* di, Addr ptr );
 
 /* Find a FPO-table index containing the specified pointer, or -1
    if not found.  Binary search.  */
-extern Word ML_(search_one_fpotab) ( struct _DebugInfo* di, Addr ptr );
+extern Word ML_(search_one_fpotab) ( const DebugInfo* di, Addr ptr );
 
 /* Helper function for the most often needed searching for an rx
    mapping containing the specified address range.  The range must
    fall entirely within the mapping to be considered to be within it.
    Asserts if lo > hi; caller must ensure this doesn't happen. */
-extern struct _DebugInfoMapping* ML_(find_rx_mapping) ( struct _DebugInfo* di,
-                                                        Addr lo, Addr hi );
+extern DebugInfoMapping* ML_(find_rx_mapping) ( DebugInfo* di,
+                                                Addr lo, Addr hi );
 
 /* ------ Misc ------ */
 
@@ -1112,15 +1112,15 @@
    terminal.  'serious' errors are always shown, not 'serious' ones
    are shown only at verbosity level 2 and above. */
 extern 
-void ML_(symerr) ( struct _DebugInfo* di, Bool serious, const HChar* msg );
+void ML_(symerr) ( const DebugInfo* di, Bool serious, const HChar* msg );
 
 /* Print a symbol. */
-extern void ML_(ppSym) ( Int idx, DiSym* sym );
+extern void ML_(ppSym) ( Int idx, const DiSym* sym );
 
 /* Print a call-frame-info summary. */
-extern void ML_(ppDiCfSI) ( XArray* /* of CfiExpr */ exprs,
+extern void ML_(ppDiCfSI) ( const XArray* /* of CfiExpr */ exprs,
                             Addr base, UInt len,
-                            DiCfSI_m* si_m );
+                            const DiCfSI_m* si_m );
 
 
 #define TRACE_SYMTAB_ENABLED (di->trace_symtab)
diff --git a/coregrind/m_debuginfo/priv_tytypes.h b/coregrind/m_debuginfo/priv_tytypes.h
index 301e897..82fd905 100644
--- a/coregrind/m_debuginfo/priv_tytypes.h
+++ b/coregrind/m_debuginfo/priv_tytypes.h
@@ -145,16 +145,16 @@
 
 /* Does this TyEnt denote a type, as opposed to some other kind of
    thing? */
-Bool ML_(TyEnt__is_type)( TyEnt* );
+Bool ML_(TyEnt__is_type)( const TyEnt* );
 
 /* Print a TyEnt, debug-style. */
-void ML_(pp_TyEnt)( TyEnt* );
+void ML_(pp_TyEnt)( const TyEnt* );
 
 /* Print a whole XArray of TyEnts, debug-style */
-void ML_(pp_TyEnts)( XArray* tyents, const HChar* who );
+void ML_(pp_TyEnts)( const XArray* tyents, const HChar* who );
 
 /* Print a TyEnt, C style, chasing stuff as necessary. */
-void ML_(pp_TyEnt_C_ishly)( XArray* /* of TyEnt */ tyents,
+void ML_(pp_TyEnt_C_ishly)( const XArray* /* of TyEnt */ tyents,
                             UWord cuOff );
 
 /* Generates a total ordering on TyEnts based only on their .cuOff
@@ -173,13 +173,13 @@
 /* How big is this type?  If .b in the returned struct is False, the
    size is unknown. */
 
-MaybeULong ML_(sizeOfType)( XArray* /* of TyEnt */ tyents,
+MaybeULong ML_(sizeOfType)( const XArray* /* of TyEnt */ tyents,
                             UWord cuOff );
 
 /* Describe where in the type 'offset' falls.  Caller must
    deallocate the resulting XArray. */
 XArray* /*UChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
-                                      XArray* /* of TyEnt */ tyents,
+                                      const XArray* /* of TyEnt */ tyents,
                                       UWord ty_cuOff, 
                                       PtrdiffT offset );
 
@@ -213,7 +213,7 @@
    the entry which has .cuOff field as specified.  Returns NULL if not
    found.  Asserts if more than one entry has the specified .cuOff
    value. */
-TyEnt* ML_(TyEnts__index_by_cuOff) ( XArray* /* of TyEnt */ ents,
+TyEnt* ML_(TyEnts__index_by_cuOff) ( const XArray* /* of TyEnt */ ents,
                                      TyEntIndexCache* cache,
                                      UWord cuOff_to_find );
 
diff --git a/coregrind/m_debuginfo/readdwarf.c b/coregrind/m_debuginfo/readdwarf.c
index 2877a62..af6ba2b 100644
--- a/coregrind/m_debuginfo/readdwarf.c
+++ b/coregrind/m_debuginfo/readdwarf.c
@@ -339,7 +339,7 @@
  */
 static 
 void read_dwarf2_lineblock ( struct _DebugInfo* di,
-                             UnitInfo* ui, 
+                             const UnitInfo* ui, 
                              DiCursor  theBlock, /* IMAGE */
                              Int       noLargerThan )
 {
@@ -1898,7 +1898,7 @@
    }
    RegRule;
 
-static void ppRegRule ( XArray* exprs, RegRule* rrule )
+static void ppRegRule ( XArray* exprs, const RegRule* rrule )
 {
    vg_assert(exprs);
    switch (rrule->tag) {
@@ -1952,12 +1952,12 @@
    }
    UnwindContext;
 
-static void ppUnwindContext ( UnwindContext* ctx )
+static void ppUnwindContext ( const UnwindContext* ctx )
 {
    Int j, i;
    VG_(printf)("0x%llx: ", (ULong)ctx->loc);
    for (j = 0; j <= ctx->state_sp; j++) {
-      struct UnwindContextState* ctxs = &ctx->state[j];
+      const struct UnwindContextState* ctxs = &ctx->state[j];
       VG_(printf)("%s[%d]={ ", j > 0 ? " " : "", j);
       if (ctxs->cfa_is_regoff) {
          VG_(printf)("%d(r%d) ", ctxs->cfa_off, ctxs->cfa_reg);
@@ -2033,9 +2033,8 @@
 
 /* Forward */
 static 
-Int copy_convert_CfiExpr_tree ( XArray*        dst,
-                                UnwindContext* srcuc, 
-                                Int            nd );
+Int copy_convert_CfiExpr_tree ( XArray* dst, const UnwindContext* srcuc, 
+                                Int nd );
 
 /* Summarise ctx into si, if possible.  Returns True if successful.
    This is taken to be just after ctx's loc advances; hence the
@@ -2046,11 +2045,11 @@
                               /*OUT*/UInt* len,
                               /*OUT*/DiCfSI_m* si_m,
                                Addr loc_start,
-	                       UnwindContext* ctx,
-                               struct _DebugInfo* debuginfo )
+	                       const UnwindContext* ctx,
+                               DebugInfo* debuginfo )
 {
    Int why = 0;
-   struct UnwindContextState* ctxs;
+   const struct UnwindContextState* ctxs;
 
    *base = 0;
    *len = 0;
@@ -2420,7 +2419,7 @@
    there is no equivalent register, return -1.  This has the
    undesirable side effect of de-dagifying the input; oh well. */
 static Int copy_convert_CfiExpr_tree ( XArray*        dstxa,
-                                       UnwindContext* srcuc, 
+                                       const UnwindContext* srcuc, 
                                        Int            srcix )
 {
    CfiExpr* src;
@@ -2500,9 +2499,9 @@
 }
 
 
-static void ppUnwindContext_summary ( UnwindContext* ctx )
+static void ppUnwindContext_summary ( const UnwindContext* ctx )
 {
-   struct UnwindContextState* ctxs = &ctx->state[ctx->state_sp];
+   const struct UnwindContextState* ctxs = &ctx->state[ctx->state_sp];
 
    VG_(printf)("0x%llx-1: ", (ULong)ctx->loc);
 
@@ -2573,7 +2572,7 @@
    }
 }
 
-static Addr step_encoded_Addr ( AddressDecodingInfo* adi,
+static Addr step_encoded_Addr ( const AddressDecodingInfo* adi,
                                 /*MOD*/DiCursor* data )
 {
    /* Regarding the handling of DW_EH_PE_absptr.  DWARF3 says this
@@ -2662,7 +2661,7 @@
    ctx->exprs of the root node.  Or fail in which case return -1. */
 /* IMPORTANT: when adding expression forms here, also remember to
    add suitable evaluation code in evalCfiExpr in debuginfo.c. */
-static Int dwarfexpr_to_dag ( UnwindContext* ctx, 
+static Int dwarfexpr_to_dag ( const UnwindContext* ctx, 
                               DiCursor expr, Int exprlen, 
                               Bool push_cfa_at_start,
                               Bool ddump_frames )
@@ -2697,7 +2696,7 @@
 
    Int sp; /* # of top element: valid is -1 .. N_EXPR_STACK-1 */
    Int stack[N_EXPR_STACK];  /* indices into ctx->exprs */
-   struct UnwindContextState* ctxs = &ctx->state[ctx->state_sp];
+   const struct UnwindContextState* ctxs = &ctx->state[ctx->state_sp];
 
    XArray*  dst   = ctx->exprs;
    DiCursor limit = ML_(cur_plus)(expr, exprlen);
@@ -2921,9 +2920,9 @@
 */
 static Int run_CF_instruction ( /*MOD*/UnwindContext* ctx, 
                                 DiCursor instrIN,
-                                UnwindContext* restore_ctx,
-                                AddressDecodingInfo* adi,
-                                struct _DebugInfo* di )
+                                const UnwindContext* restore_ctx,
+                                const AddressDecodingInfo* adi,
+                                const DebugInfo* di )
 {
    Int      off, reg, reg2, len, j;
    UInt     delta;
@@ -3329,7 +3328,7 @@
    readelf --debug-dump=frames would. */
 
 static Int show_CF_instruction ( DiCursor instrIN,
-                                 AddressDecodingInfo* adi,
+                                 const AddressDecodingInfo* adi,
                                  Int code_a_f, Int data_a_f )
 {
    Int      off, coff, reg, reg2, len;
@@ -3535,7 +3534,7 @@
 
 /* Show the instructions in instrs[0 .. ilen-1]. */
 static void show_CF_instructions ( DiCursor instrs, Int ilen,
-                                   AddressDecodingInfo* adi,
+                                   const AddressDecodingInfo* adi,
                                    Int code_a_f, Int data_a_f )
 {
    Int i = 0;
@@ -3551,12 +3550,12 @@
    reached, or until there is a failure.  Return True iff success. 
 */
 static 
-Bool run_CF_instructions ( struct _DebugInfo* di,
+Bool run_CF_instructions ( DebugInfo* di,
                            Bool record,
                            UnwindContext* ctx, DiCursor instrs, Int ilen,
                            UWord fde_arange,
-                           UnwindContext* restore_ctx,
-                           AddressDecodingInfo* adi )
+                           const UnwindContext* restore_ctx,
+                           const AddressDecodingInfo* adi )
 {
    Addr base;
    UInt len;
diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c
index 96cbfb1..1540499 100644
--- a/coregrind/m_debuginfo/readdwarf3.c
+++ b/coregrind/m_debuginfo/readdwarf3.c
@@ -176,7 +176,7 @@
    }
    Cursor;
 
-static inline Bool is_sane_Cursor ( Cursor* c ) {
+static inline Bool is_sane_Cursor ( const Cursor* c ) {
    if (!c)                return False;
    if (!c->barf)          return False;
    if (!c->barfstr)       return False;
@@ -204,12 +204,12 @@
    vg_assert(is_sane_Cursor(c));
 }
 
-static Bool is_at_end_Cursor ( Cursor* c ) {
+static Bool is_at_end_Cursor ( const Cursor* c ) {
    vg_assert(is_sane_Cursor(c));
    return c->sli_next >= c->sli.ioff + c->sli.szB;
 }
 
-static inline ULong get_position_of_Cursor ( Cursor* c ) {
+static inline ULong get_position_of_Cursor ( const Cursor* c ) {
    vg_assert(is_sane_Cursor(c));
    return c->sli_next - c->sli.ioff;
 }
@@ -222,7 +222,7 @@
    vg_assert(is_sane_Cursor(c));
 }
 
-static /*signed*/Long get_remaining_length_Cursor ( Cursor* c ) {
+static /*signed*/Long get_remaining_length_Cursor ( const Cursor* c ) {
    vg_assert(is_sane_Cursor(c));
    return c->sli.ioff + c->sli.szB - c->sli_next;
 }
@@ -495,7 +495,7 @@
    a contiguous whole, so that DIEs coming from .debug_types are numbered
    starting at the end of .debug_info and DIEs coming from alternate
    .debug_info are numbered starting at the end of .debug_types.  */
-static UWord cook_die( CUConst* cc, UWord die )
+static UWord cook_die( const CUConst* cc, UWord die )
 {
    if (cc->is_type_unit)
       die += cc->types_cuOff_bias;
@@ -508,7 +508,7 @@
    DW_FORM_ref_sig8 reference are already cooked.  Also, handle
    DW_FORM_GNU_ref_alt from within primary .debug_info or .debug_types
    as reference to alternate .debug_info.  */
-static UWord cook_die_using_form( CUConst *cc, UWord die, DW_FORM form)
+static UWord cook_die_using_form( const CUConst *cc, UWord die, DW_FORM form)
 {
    if (form == DW_FORM_ref_sig8)
       return die;
@@ -520,7 +520,7 @@
 /* Return the uncooked offset of DIE and set *TYPE_FLAG to true if the DIE
    came from the .debug_types section and *ALT_FLAG to true if the DIE
    came from alternate .debug_info section.  */
-static UWord uncook_die( CUConst *cc, UWord die, /*OUT*/Bool *type_flag,
+static UWord uncook_die( const CUConst *cc, UWord die, /*OUT*/Bool *type_flag,
                          Bool *alt_flag )
 {
    *alt_flag = False;
@@ -585,7 +585,7 @@
 
 
 /* Apply a text bias to a GX. */
-static void bias_GX ( /*MOD*/GExpr* gx, struct _DebugInfo* di )
+static void bias_GX ( /*MOD*/GExpr* gx, const DebugInfo* di )
 {
    UShort nbytes;
    UChar* p = &gx->payload[0];
@@ -651,7 +651,7 @@
 }
 
 __attribute__((noinline))
-static GExpr* make_general_GX ( CUConst* cc,
+static GExpr* make_general_GX ( const CUConst* cc,
                                 Bool     td3,
                                 ULong    debug_loc_offset,
                                 Addr     svma_of_referencing_CU )
@@ -830,10 +830,10 @@
    caller must deallocate it. */
 __attribute__((noinline))
 static XArray* /* of AddrRange */
-       get_range_list ( CUConst* cc,
-                        Bool     td3,
-                        UWord    debug_ranges_offset,
-                        Addr     svma_of_referencing_CU )
+get_range_list ( const CUConst* cc,
+                 Bool     td3,
+                 UWord    debug_ranges_offset,
+                 Addr     svma_of_referencing_CU )
 {
    Addr      base;
    Cursor    ranges;
@@ -885,7 +885,7 @@
 }
 
 #define VARSZ_FORM 0xffffffff
-static UInt get_Form_szB (CUConst* cc, DW_FORM form );
+static UInt get_Form_szB (const CUConst* cc, DW_FORM form );
 
 /* Initialises the hash table of abbreviations.
    We do a single scan of the abbv slice to parse and
@@ -979,7 +979,7 @@
    #undef SZ_G_ABBV
 }
 
-static g_abbv* get_abbv (CUConst* cc, ULong abbv_code)
+static g_abbv* get_abbv (const CUConst* cc, ULong abbv_code)
 {
    g_abbv *abbv;
 
@@ -1130,7 +1130,7 @@
    at a DiCursor.*/
 static
 void get_Form_contents ( /*OUT*/FormContents* cts,
-                         CUConst* cc, Cursor* c,
+                         const CUConst* cc, Cursor* c,
                          Bool td3, DW_FORM form )
 {
    VG_(bzero_inline)(cts, sizeof(*cts));
@@ -1461,7 +1461,7 @@
 /* If the form is a fixed length form, return the nr of bytes for this form.
    If the form is a variable length form, return VARSZ_FORM. */
 static
-UInt get_Form_szB (CUConst* cc, DW_FORM form )
+UInt get_Form_szB (const CUConst* cc, DW_FORM form )
 {
    // !!! keep switch in sync with get_Form_contents : the nr of bytes
    // read from a cursor by get_Form_contents must be returned by
@@ -1536,8 +1536,8 @@
 static
 void skip_DIE (UWord  *sibling,
                Cursor* c_die,
-               g_abbv *abbv,
-               CUConst* cc)
+               const g_abbv *abbv,
+               const CUConst* cc)
 {
    UInt nf_i;
    FormContents cts;
@@ -1636,7 +1636,8 @@
    }
    D3VarParser;
 
-static void varstack_show ( D3VarParser* parser, const HChar* str ) {
+static void varstack_show ( const D3VarParser* parser, const HChar* str )
+{
    Word i, j;
    VG_(printf)("  varstack (%s) {\n", str);
    for (i = 0; i <= parser->sp; i++) {
@@ -1690,7 +1691,7 @@
       varstack_show( parser, "after preen" );
 }
 
-static void varstack_push ( CUConst* cc,
+static void varstack_push ( const CUConst* cc,
                             D3VarParser* parser,
                             Bool td3,
                             XArray* ranges, Int level,
@@ -1731,7 +1732,7 @@
    in both cases bundle the expression or location list into a
    so-called GExpr (guarded expression). */
 __attribute__((noinline))
-static GExpr* get_GX ( CUConst* cc, Bool td3, const FormContents* cts )
+static GExpr* get_GX ( const CUConst* cc, Bool td3, const FormContents* cts )
 {
    GExpr* gexpr = NULL;
    if (cts->szB < 0) {
@@ -1761,7 +1762,7 @@
    whatever that means, according to the DWARF3 spec.
    FIXME??? readdwarf3.c/readdwarf.c have a lot of duplicated code */
 static
-XArray* read_dirname_xa (struct _DebugInfo* di, const HChar *compdir,
+XArray* read_dirname_xa (DebugInfo* di, const HChar *compdir,
                          Cursor *c,
                          Bool td3 )
 {
@@ -1839,7 +1840,7 @@
 static 
 void read_filename_table( /*MOD*/XArray* /* of UInt* */ fndn_ix_Table,
                           const HChar* compdir,
-                          CUConst* cc, ULong debug_line_offset,
+                          const CUConst* cc, ULong debug_line_offset,
                           Bool td3 )
 {
    Bool   is_dw64;
@@ -1847,10 +1848,10 @@
    Word   i;
    UShort version;
    UChar  opcode_base;
-   const  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;
+   const HChar* dirname;
    UInt   fndn_ix;
 
    vg_assert(fndn_ix_Table && cc && cc->barf);
@@ -1962,8 +1963,8 @@
    UWord posn,
    Int level,
    UWord saved_die_c_offset,
-   g_abbv *abbv,
-   CUConst* cc)
+   const g_abbv *abbv,
+   const CUConst* cc)
 {
    Cursor c;
    FormContents cts;
@@ -2020,8 +2021,8 @@
    Int level,
    Cursor* c_die,
    UWord saved_die_c_offset,
-   g_abbv *abbv,
-   CUConst* cc)
+   const g_abbv *abbv,
+   const CUConst* cc)
 {
    trace_DIE (dtag, posn, level, saved_die_c_offset, abbv, cc);
    VG_(printf)("%s:\n", whichparser);
@@ -2045,7 +2046,7 @@
    UWord posn,
    Int level,
    Cursor* c_die,
-   g_abbv *abbv,
+   const g_abbv *abbv,
    CUConst* cc,
    Bool td3
 )
@@ -2324,7 +2325,7 @@
             stack. */
          GExpr*   fbGX = NULL;
          Word     i, nRanges;
-         XArray*  /* of AddrRange */ xa;
+         const XArray*  /* of AddrRange */ xa;
          TempVar* tv;
          /* Stack can't be empty; we put a dummy entry on it for the
             entire address range before starting with the DIEs for
@@ -2549,10 +2550,10 @@
    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 const HChar* get_inlFnName (Int absori, CUConst* cc, Bool td3)
+static const HChar* get_inlFnName (Int absori, const CUConst* cc, Bool td3)
 {
    Cursor c;
-   g_abbv *abbv;
+   const g_abbv *abbv;
    ULong  atag, abbv_code;
    UInt   has_children;
    UWord  posn;
@@ -2660,7 +2661,7 @@
    UWord posn,
    Int level,
    Cursor* c_die,
-   g_abbv *abbv,
+   const g_abbv *abbv,
    CUConst* cc,
    Bool td3
 )
@@ -2861,7 +2862,8 @@
    }
    D3TypeParser;
 
-static void typestack_show ( D3TypeParser* parser, const HChar* str ) {
+static void typestack_show ( const D3TypeParser* parser, const HChar* str )
+{
    Word i;
    VG_(printf)("  typestack (%s) {\n", str);
    for (i = 0; i <= parser->sp; i++) {
@@ -2896,12 +2898,13 @@
       typestack_show( parser, "after preen" );
 }
 
-static Bool typestack_is_empty ( D3TypeParser* parser ) {
+static Bool typestack_is_empty ( const D3TypeParser* parser )
+{
    vg_assert(parser->sp >= -1 && parser->sp < N_D3_TYPE_STACK);
    return parser->sp == -1;
 }
 
-static void typestack_push ( CUConst* cc,
+static void typestack_push ( const CUConst* cc,
                              D3TypeParser* parser,
                              Bool td3,
                              TyEnt* parentE, Int level ) {
@@ -2933,7 +2936,7 @@
 }
 
 /* True if the subrange type being parsed gives the bounds of an array. */
-static Bool subrange_type_denotes_array_bounds ( D3TypeParser* parser,
+static Bool subrange_type_denotes_array_bounds ( const D3TypeParser* parser,
                                                  DW_TAG dtag ) {
    vg_assert(dtag == DW_TAG_subrange_type);
    /* For most languages, a subrange_type dtag always gives the 
@@ -2983,8 +2986,8 @@
                              UWord posn,
                              Int level,
                              Cursor* c_die,
-                             g_abbv *abbv,
-                             CUConst* cc,
+                             const g_abbv *abbv,
+                             const CUConst* cc,
                              Bool td3 )
 {
    FormContents cts;
@@ -4116,7 +4119,7 @@
    Cursor* c, Bool td3, CUConst* cc, Int level
 )
 {
-   g_abbv *abbv;
+   const g_abbv *abbv;
    ULong  atag, abbv_code;
    UWord  posn;
    UInt   has_children;
@@ -4250,7 +4253,7 @@
 
 }
 
-static void trace_debug_loc (struct _DebugInfo* di,
+static void trace_debug_loc (const DebugInfo* di,
                              __attribute__((noreturn)) void (*barf)( const HChar* ),
                              DiSlice escn_debug_loc)
 {
@@ -4317,7 +4320,7 @@
 #endif
 }
 
-static void trace_debug_ranges (struct _DebugInfo* di,
+static void trace_debug_ranges (const DebugInfo* di,
                                 __attribute__((noreturn)) void (*barf)( const HChar* ),
                                 DiSlice escn_debug_ranges)
 {
@@ -4371,7 +4374,7 @@
    }
 }
 
-static void trace_debug_abbrev (struct _DebugInfo* di,
+static void trace_debug_abbrev (const DebugInfo* di,
                                 __attribute__((noreturn)) void (*barf)( const HChar* ),
                                 DiSlice escn_debug_abbv)
 {
@@ -4413,7 +4416,7 @@
 
 static
 void new_dwarf3_reader_wrk ( 
-   struct _DebugInfo* di,
+   DebugInfo* di,
    __attribute__((noreturn)) void (*barf)( const HChar* ),
    DiSlice escn_debug_info,      DiSlice escn_debug_types,
    DiSlice escn_debug_abbv,      DiSlice escn_debug_line,
@@ -5135,7 +5138,7 @@
 
 void 
 ML_(new_dwarf3_reader) (
-   struct _DebugInfo* di,
+   DebugInfo* di,
    DiSlice escn_debug_info,      DiSlice escn_debug_types,
    DiSlice escn_debug_abbv,      DiSlice escn_debug_line,
    DiSlice escn_debug_str,       DiSlice escn_debug_ranges,
diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
index 880d830..a891e57 100644
--- a/coregrind/m_debuginfo/readelf.c
+++ b/coregrind/m_debuginfo/readelf.c
@@ -109,9 +109,9 @@
 /* Identify an ELF object file by peering at the first few bytes of
    it. */
 
-Bool ML_(is_elf_object_file)( void* image, SizeT n_image, Bool rel_ok )
+Bool ML_(is_elf_object_file)( const void* image, SizeT n_image, Bool rel_ok )
 {
-   ElfXX_Ehdr* ehdr = (ElfXX_Ehdr*)image;
+   const ElfXX_Ehdr* ehdr = image;
    Int ok = 1;
 
    if (n_image < sizeof(ElfXX_Ehdr))
@@ -158,7 +158,7 @@
 static
 void show_raw_elf_symbol ( DiImage* strtab_img,
                            Int i, 
-                           ElfXX_Sym* sym,
+                           const ElfXX_Sym* sym,
                            DiOffT sym_name_ioff, Addr sym_svma,
                            Bool ppc64_linux_format )
 {
@@ -224,12 +224,12 @@
 Bool get_elf_symbol_info ( 
         /* INPUTS */
         struct _DebugInfo* di, /* containing DebugInfo */
-        ElfXX_Sym* sym,        /* ELF symbol */
+        const ElfXX_Sym* sym,        /* ELF symbol */
         DiOffT     sym_name_ioff, /* name, may be absent (DiOffT_INVALID) */
-        DiSlice*   escn_strtab,   /* holds the name */
+        const DiSlice*   escn_strtab,   /* holds the name */
         Addr       sym_svma,   /* address as stated in the object file */
         Bool       symtab_in_debug, /* symbol table is in the debug file */
-        DiSlice*   escn_opd,   /* the .opd (ppc64be-linux only) */
+        const DiSlice*   escn_opd,   /* the .opd (ppc64be-linux only) */
         PtrdiffT   opd_bias,   /* for biasing AVMAs found in .opd */
         /* OUTPUTS */
         DiOffT* sym_name_out_ioff, /* name (in strtab) we should record */
@@ -745,7 +745,7 @@
      )
 {
    if (escn_strtab->img == NULL || escn_symtab->img == NULL) {
-      HChar buf[80];
+      HChar buf[80];  // FIXME: allocate dynamically
       vg_assert(VG_(strlen)(tab_name) < 40);
       VG_(sprintf)(buf, "   object doesn't have a %s", tab_name);
       ML_(symerr)(di, False, buf);
@@ -845,7 +845,7 @@
    }
    TempSym;
 
-static Word cmp_TempSymKey ( TempSymKey* key1, TempSym* elem2 )
+static Word cmp_TempSymKey ( const TempSymKey* key1, const TempSym* elem2 )
 {
    /* Stay sane ... */
    vg_assert(key1->img == elem2->key.img);
@@ -876,7 +876,7 @@
    TempSym    *prev;
 
    if (escn_strtab->img == NULL || escn_symtab->img == NULL) {
-      HChar buf[80];
+      HChar buf[80];  // FIXME: allocate dynamically
       vg_assert(VG_(strlen)(tab_name) < 40);
       VG_(sprintf)(buf, "   object doesn't have a %s", tab_name);
       ML_(symerr)(di, False, buf);
@@ -1316,7 +1316,7 @@
    hacky and dangerous way: check only the --extra-debuginfo-path and
    the --debuginfo-server.  And don't do a consistency check. */
 static
-DiImage* find_debug_file_ad_hoc( struct _DebugInfo* di,
+DiImage* find_debug_file_ad_hoc( const DebugInfo* di,
                                  const HChar* objpath )
 {
    const HChar* extrapath  = VG_(clo_extra_debuginfo_path);
@@ -1522,7 +1522,7 @@
       Bool has_nonempty_rx = False;
       Bool has_nonempty_rw = False;
       for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-         struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+         DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
          if (!map->rx && !map->rw)
             continue;
          if (map->rx && map->size > 0)
@@ -1598,13 +1598,13 @@
    TRACE_SYMTAB("shdr:    ioff %llu nent %ld ent_szB %ld\n",
                shdr_mioff, shdr_mnent, shdr_ment_szB);
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-      struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+      const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (map->rx)
          TRACE_SYMTAB("rx_map:  avma %#lx   size %lu  foff %lu\n",
                       map->avma, map->size, map->foff);
    }
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-      struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+      const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (map->rw)
          TRACE_SYMTAB("rw_map:  avma %#lx   size %lu  foff %lu\n",
                       map->avma, map->size, map->foff);
@@ -1688,7 +1688,7 @@
             if (a_phdr.p_memsz > 0) {
                Bool loaded = False;
                for (j = 0; j < VG_(sizeXA)(di->fsm.maps); j++) {
-                  struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, j);
+                  const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, j);
                   if (   (map->rx || map->rw)
                       && map->size > 0 /* stay sane */
                       && a_phdr.p_offset >= map->foff
@@ -1805,27 +1805,27 @@
    TRACE_SYMTAB("\n");
    TRACE_SYMTAB("------ Examining the section headers ------\n");
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-      struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+      const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (map->rx)
          TRACE_SYMTAB("rx: at %#lx are mapped foffsets %ld .. %ld\n",
                       map->avma, map->foff, map->foff + map->size - 1 );
    }
    TRACE_SYMTAB("rx: contains these svma regions:\n");
    for (i = 0; i < VG_(sizeXA)(svma_ranges); i++) {
-      RangeAndBias* reg = VG_(indexXA)(svma_ranges, i);
+      const RangeAndBias* reg = VG_(indexXA)(svma_ranges, i);
       if (reg->exec)
          TRACE_SYMTAB("  svmas %#lx .. %#lx with bias %#lx\n",
                       reg->svma_base, reg->svma_limit - 1, reg->bias );
    }
    for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-      struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+      const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
       if (map->rw)
          TRACE_SYMTAB("rw: at %#lx are mapped foffsets %ld .. %ld\n",
                       map->avma, map->foff, map->foff + map->size - 1 );
    }
    TRACE_SYMTAB("rw: contains these svma regions:\n");
    for (i = 0; i < VG_(sizeXA)(svma_ranges); i++) {
-      RangeAndBias* reg = VG_(indexXA)(svma_ranges, i);
+      const RangeAndBias* reg = VG_(indexXA)(svma_ranges, i);
       if (!reg->exec)
          TRACE_SYMTAB("  svmas %#lx .. %#lx with bias %#lx\n",
                       reg->svma_base, reg->svma_limit - 1, reg->bias );
@@ -2577,7 +2577,7 @@
                            sizeof(a_phdr));
             if (a_phdr.p_type == PT_LOAD) {
                for (j = 0; j < VG_(sizeXA)(di->fsm.maps); j++) {
-                  struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, j);
+                  const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, j);
                   if (   a_phdr.p_offset >= map->foff
                       && a_phdr.p_offset <  map->foff + map->size
                       && a_phdr.p_offset + a_phdr.p_filesz
diff --git a/coregrind/m_debuginfo/readpdb.c b/coregrind/m_debuginfo/readpdb.c
index 2502bf8..814acb1 100644
--- a/coregrind/m_debuginfo/readpdb.c
+++ b/coregrind/m_debuginfo/readpdb.c
@@ -949,7 +949,7 @@
 
 struct pdb_reader
 {
-   void* (*read_file)(struct pdb_reader*, unsigned, unsigned *);
+   void* (*read_file)(const struct pdb_reader*, unsigned, unsigned *);
    // JRS 2009-Apr-8: .uu_n_pdbimage is never used.
    UChar* pdbimage;      // image address
    SizeT  uu_n_pdbimage; // size
@@ -966,8 +966,8 @@
 };
 
 
-static void* pdb_ds_read( struct pdb_reader* pdb,
-                          unsigned* block_list,
+static void* pdb_ds_read( const struct pdb_reader* pdb,
+                          const unsigned* block_list,
                           unsigned  size )
 {
    unsigned  blocksize, nBlocks;
@@ -992,8 +992,8 @@
 }
 
 
-static void* pdb_jg_read( struct pdb_reader* pdb,
-                          unsigned short* block_list,
+static void* pdb_jg_read( const struct pdb_reader* pdb,
+                          const unsigned short* block_list,
                           int size )
 {
    unsigned  blocksize, nBlocks;
@@ -1028,7 +1028,7 @@
 }
 
 
-static void* pdb_ds_read_file( struct pdb_reader* reader,
+static void* pdb_ds_read_file( const struct pdb_reader* reader,
                                unsigned  file_number,
                                unsigned* plength )
 {
@@ -1053,7 +1053,7 @@
 }
 
 
-static void* pdb_jg_read_file( struct pdb_reader* pdb,
+static void* pdb_jg_read_file( const struct pdb_reader* pdb,
                                unsigned fileNr,
                                unsigned *plength )
 {
@@ -1108,10 +1108,8 @@
 }
 
 
-
-
 static 
-void pdb_check_root_version_and_timestamp( HChar* pdbname,
+void pdb_check_root_version_and_timestamp( const HChar* pdbname,
                                            ULong  pdbmtime,
                                            unsigned  version,
                                            UInt TimeDateStamp )
@@ -1137,7 +1135,7 @@
 }
 
 
-static DWORD pdb_get_file_size( struct pdb_reader* reader, unsigned idx )
+static DWORD pdb_get_file_size( const struct pdb_reader* reader, unsigned idx )
 {
    if (reader->read_file == pdb_jg_read_file)
       return reader->u.jg.toc->file[idx].size;
@@ -1203,8 +1201,8 @@
 static ULong DEBUG_SnarfCodeView(
                 DebugInfo* di,
                 PtrdiffT bias,
-                IMAGE_SECTION_HEADER* sectp,
-                void* root, /* FIXME: better name */
+                const IMAGE_SECTION_HEADER* sectp,
+                const void* root, /* FIXME: better name */
                 Int offset,
                 Int size
              )
@@ -1212,7 +1210,7 @@
    Int    i, length;
    DiSym  vsym;
    const  HChar* nmstr;
-   HChar  symname[4096 /*WIN32_PATH_MAX*/];
+   HChar  symname[4096 /*WIN32_PATH_MAX*/];  // FIXME: really ?
 
    Bool  debug = di->trace_symtab;
    ULong n_syms_read = 0;
@@ -1229,7 +1227,8 @@
     */
    for ( i = offset; i < size; i += length )
    {
-      union codeview_symbol *sym = (union codeview_symbol *)((char *)root + i);
+      const union codeview_symbol *sym =
+         (const union codeview_symbol *)((const char *)root + i);
 
       length = sym->generic.len + 2;
 
@@ -1238,14 +1237,13 @@
 
       default:
          if (0) {
+            const int *isym = (const int *)sym;
             VG_(printf)("unknown id 0x%x len=0x%x at %p\n",
                         sym->generic.id, sym->generic.len, sym);
             VG_(printf)("  %8x  %8x  %8x  %8x\n", 
-                        ((int *)sym)[1],((int *)sym)[2],
-                        ((int *)sym)[3],((int *)sym)[4]);
+                        isym[1], isym[2], isym[3], isym[4]);
             VG_(printf)("  %8x  %8x  %8x  %8x\n",
-                        ((int *)sym)[5],((int *)sym)[6],
-                        ((int *)sym)[7],((int *)sym)[8]);
+                        isym[5], isym[6], isym[7], isym[8]);
          }
          break;
       /*
@@ -1479,7 +1477,7 @@
       case S_PROCREF_V1:
       case S_DATAREF_V1:
       case S_LPROCREF_V1: {
-         unsigned char *name = (unsigned char *)sym + length;
+         const unsigned char *name = (const unsigned char *)sym + length;
          length += (*name + 1 + 3) & ~3;
          break;
       }
@@ -1518,8 +1516,8 @@
 static ULong DEBUG_SnarfLinetab(
           DebugInfo* di,
           PtrdiffT bias,
-          IMAGE_SECTION_HEADER* sectp,
-          void* linetab,
+          const IMAGE_SECTION_HEADER* sectp,
+          const void* linetab,
           Int size
        )
 {
@@ -1560,7 +1558,7 @@
     */
    nseg = 0;
    for (i = 0; i < nfile; i++) {
-      pnt2.c = (HChar *)linetab + filetab[i];
+      pnt2.c = (const HChar *)linetab + filetab[i];
       nseg += *pnt2.s;
    }
 
@@ -1573,7 +1571,7 @@
       /*
        * Get the pointer into the segment information.
        */
-      pnt2.c = (HChar *)linetab + filetab[i];
+      pnt2.c = (const HChar *)linetab + filetab[i];
       file_segcount = *pnt2.s;
 
       pnt2.ui++;
@@ -1606,7 +1604,7 @@
          Int linecount;
          Int segno;
 
-         pnt2.c = (HChar *)linetab + lt_ptr[k];
+         pnt2.c = (const HChar *)linetab + lt_ptr[k];
 
          segno = *pnt2.s++;
          linecount = *pnt2.s++;
@@ -1660,7 +1658,7 @@
  * an array (starting at <lineblk_offset>) of codeview_linetab2_block structures
  */
 
-struct codeview_linetab2_file
+typedef struct codeview_linetab2_file
 {
     DWORD       offset;         /* offset in string table for filename */
     WORD        unk;            /* always 0x0110... type of following
@@ -1668,9 +1666,9 @@
     BYTE        md5[16];        /* MD5 signature of file (signature on
                                    file's content or name ???) */
     WORD        pad0;           /* always 0 */
-};
+} codeview_linetab2_file;
 
-struct codeview_linetab2_block
+typedef struct codeview_linetab2_block
 {
     DWORD       header;         /* 0x000000f2 */
     DWORD       size_of_block;  /* next block is at # bytes after this field */
@@ -1687,33 +1685,33 @@
         DWORD   lineno;         /* the line number (OR:ed with
                                    0x80000000 why ???) */
     } l[1];                     /* actually array of <nlines> */
-};
+} codeview_linetab2_block;
 
 static ULong codeview_dump_linetab2(
                 DebugInfo* di,
                 Addr bias,
-                IMAGE_SECTION_HEADER* sectp,
-                HChar* linetab,
+                const IMAGE_SECTION_HEADER* sectp,
+                const HChar* linetab,
                 DWORD size,
-                HChar* strimage,
+                const HChar* strimage,
                 DWORD strsize,
                 const HChar* pfx
              )
 {
    DWORD       offset;
    unsigned    i;
-   struct codeview_linetab2_block* lbh;
-   struct codeview_linetab2_file* fd;
+   const codeview_linetab2_block* lbh;
+   const codeview_linetab2_file* fd;
 
    Bool  debug = di->trace_symtab;
    ULong n_line2s_read = 0;
 
    if (*(const DWORD*)linetab != 0x000000f4)
       return 0;
-   offset = *((DWORD*)linetab + 1);
-   lbh = (struct codeview_linetab2_block*)(linetab + 8 + offset);
+   offset = *((const DWORD*)linetab + 1);
+   lbh = (const codeview_linetab2_block*)(linetab + 8 + offset);
 
-   while ((HChar*)lbh < linetab + size) {
+   while ((const HChar*)lbh < linetab + size) {
 
       const HChar *filename, *dirname;
       UInt filedirname_ix;
@@ -1728,7 +1726,7 @@
          VG_(printf)("%sblock from %04x:%08x-%08x (size %u) (%u lines)\n",
                      pfx, lbh->seg, lbh->start, lbh->start + lbh->size - 1,
                      lbh->size, lbh->nlines);
-      fd = (struct codeview_linetab2_file*)(linetab + 8 + lbh->file_offset);
+      fd = (const codeview_linetab2_file*)(linetab + 8 + lbh->file_offset);
       if (debug)
          VG_(printf)(
             "%s  md5=%02x%02x%02x%02x%02x%02x%02x%02x"
@@ -1797,8 +1795,8 @@
           n_line2s_read++;
        }
 
-       lbh = (struct codeview_linetab2_block*)
-                ((char*)lbh + 8 + lbh->size_of_block);
+       lbh = (const codeview_linetab2_block*)
+                ((const char*)lbh + 8 + lbh->size_of_block);
     }
     return n_line2s_read;
 }
@@ -1827,11 +1825,11 @@
 
 
 /* JRS fixme: compare with version in current Wine sources */
-static void pdb_dump( struct pdb_reader* pdb,
+static void pdb_dump( const struct pdb_reader* pdb,
                       DebugInfo* di,
                       Addr       pe_avma,
                       PtrdiffT   pe_bias,
-                      IMAGE_SECTION_HEADER* sectp_avma )
+                      const IMAGE_SECTION_HEADER* sectp_avma )
 {
    Int header_size;
 
@@ -1839,7 +1837,7 @@
    PDB_SYMBOLS symbols;
    unsigned len_modimage;
    char *modimage;
-   char *file; 
+   const char *file; 
 
    Bool debug = di->trace_symtab;
 
@@ -1863,7 +1861,7 @@
          if (0)
             VG_(printf)("wrong header %x expecting 0xeffeeffe\n",
                         *(const DWORD*)filesimage);
-         ML_(dinfo_free)( (void*)filesimage);
+         ML_(dinfo_free)(filesimage);
          filesimage = NULL;
       }
    }
@@ -2073,7 +2071,7 @@
       if (VG_(clo_verbosity) > 1)
          VG_(message)(Vg_UserMsg, "Reading global symbols\n" );
       DEBUG_SnarfCodeView( di, pe_avma, sectp_avma, modimage, 0, len_modimage );
-      ML_(dinfo_free)( (void*)modimage );
+      ML_(dinfo_free)( modimage );
    }
 
    /*
@@ -2082,17 +2080,17 @@
    file = symbols_image + header_size;
    while ( file - symbols_image < header_size + symbols.module_size ) {
       int file_nr, /* file_index, */ symbol_size, lineno_size;
-      char *file_name;
+      const char *file_name;
 
       if ( symbols.version < 19970000 ) {
-         PDB_SYMBOL_FILE *sym_file = (PDB_SYMBOL_FILE *) file;
+         const PDB_SYMBOL_FILE *sym_file = (const PDB_SYMBOL_FILE *) file;
          file_nr     = sym_file->file;
          file_name   = sym_file->filename;
          /* file_index  = sym_file->range.index; */ /* UNUSED */
          symbol_size = sym_file->symbol_size;
          lineno_size = sym_file->lineno_size;
       } else {
-         PDB_SYMBOL_FILE_EX *sym_file = (PDB_SYMBOL_FILE_EX *) file;
+         const PDB_SYMBOL_FILE_EX *sym_file = (const PDB_SYMBOL_FILE_EX *) file;
          file_nr     = sym_file->file;
          file_name   = sym_file->filename;
          /* file_index  = sym_file->range.index; */ /* UNUSED */
@@ -2146,11 +2144,11 @@
                   filessize, "        "
                );
 
-         ML_(dinfo_free)( (void*)modimage );
+         ML_(dinfo_free)( modimage );
       }
 
       file_name += VG_(strlen)(file_name) + 1;
-      file = (char *)( 
+      file = (const char *)( 
                 (unsigned long)(file_name
                                 + VG_(strlen)(file_name) + 1 + 3) & ~3 );
    }
@@ -2189,7 +2187,7 @@
         PtrdiffT   obj_bias,
         void*      pdbimage,
         SizeT      n_pdbimage,
-        HChar*     pdbname,
+        const HChar* pdbname,
         ULong      pdbmtime
      )
 {
@@ -2257,7 +2255,7 @@
       mapped_avma     = (Addr)obj_avma + pe_sechdr_avma->VirtualAddress;
       mapped_end_avma = mapped_avma + pe_sechdr_avma->Misc.VirtualSize;
 
-      struct _DebugInfoMapping map;
+      DebugInfoMapping map;
       map.avma = mapped_avma;
       map.size = pe_sechdr_avma->Misc.VirtualSize;
       map.foff = pe_sechdr_avma->PointerToRawData;
@@ -2325,14 +2323,14 @@
 
    if (VG_(clo_verbosity) > 1) {
       for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-         struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+         const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
          if (map->rx)
             VG_(message)(Vg_DebugMsg,
                          "rx_map: avma %#lx size %7lu foff %llu\n",
                          map->avma, map->size, (Off64T)map->foff);
       }
       for (i = 0; i < VG_(sizeXA)(di->fsm.maps); i++) {
-         struct _DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
+         const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, i);
          if (map->rw)
             VG_(message)(Vg_DebugMsg,
                          "rw_map: avma %#lx size %7lu foff %llu\n",
@@ -2412,7 +2410,7 @@
    ML_(dinfo_free).
 */
 
-HChar* ML_(find_name_of_pdb_file)( HChar* pename )
+HChar* ML_(find_name_of_pdb_file)( const HChar* pename )
 {
    /* This is a giant kludge, of the kind "you did WTF?!?", but it
       works. */
diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c
index 458f0c7..1cccd31 100644
--- a/coregrind/m_debuginfo/storage.c
+++ b/coregrind/m_debuginfo/storage.c
@@ -62,7 +62,7 @@
 /* Show a non-fatal debug info reading error.  Use vg_panic if
    terminal.  'serious' errors are shown regardless of the
    verbosity setting. */
-void ML_(symerr) ( struct _DebugInfo* di, Bool serious, const HChar* msg )
+void ML_(symerr) ( const DebugInfo* di, Bool serious, const HChar* msg )
 {
    /* XML mode hides everything :-( */
    if (VG_(clo_xml))
@@ -92,7 +92,7 @@
 
 
 /* Print a symbol. */
-void ML_(ppSym) ( Int idx, DiSym* sym )
+void ML_(ppSym) ( Int idx, const DiSym* sym )
 {
    const HChar** sec_names = sym->sec_names;
    vg_assert(sym->pri_name);
@@ -115,9 +115,9 @@
 }
 
 /* Print a call-frame-info summary. */
-void ML_(ppDiCfSI) ( XArray* /* of CfiExpr */ exprs,
+void ML_(ppDiCfSI) ( const XArray* /* of CfiExpr */ exprs,
                      Addr base, UInt len,
-                     DiCfSI_m* si_m )
+                     const DiCfSI_m* si_m )
 {
 #  define SHOW_HOW(_how, _off)                   \
       do {                                       \
@@ -268,7 +268,7 @@
    return fndn_ix;
 }
 
-const HChar* ML_(fndn_ix2filename) (struct _DebugInfo* di,
+const HChar* ML_(fndn_ix2filename) (const DebugInfo* di,
                                     UInt fndn_ix)
 {
    FnDn *fndn;
@@ -280,7 +280,7 @@
    }
 }
 
-const HChar* ML_(fndn_ix2dirname) (struct _DebugInfo* di,
+const HChar* ML_(fndn_ix2dirname) (const DebugInfo* di,
                                    UInt fndn_ix)
 {
    FnDn *fndn;
@@ -343,7 +343,7 @@
    vg_assert(di->symtab_used <= di->symtab_size);
 }
 
-UInt ML_(fndn_ix) (struct _DebugInfo* di, Word locno)
+UInt ML_(fndn_ix) (const DebugInfo* di, Word locno)
 {
    UInt fndn_ix;
 
@@ -656,7 +656,7 @@
    addInl ( di, &inl );
 }
 
-DiCfSI_m* ML_(get_cfsi_m) (struct _DebugInfo* di, UInt pos)
+DiCfSI_m* ML_(get_cfsi_m) (const DebugInfo* di, UInt pos)
 {
    UInt cfsi_m_ix;
 
@@ -682,8 +682,8 @@
    UInt    new_sz;
    DiCfSI* new_tab;
    SSizeT  delta;
-   struct _DebugInfoMapping* map;
-   struct _DebugInfoMapping* map2;
+   DebugInfoMapping* map;
+   DebugInfoMapping* map2;
 
    if (debug) {
       VG_(printf)("adding DiCfSI: ");
@@ -916,7 +916,7 @@
    }
 }
 
-void ML_(ppCfiExpr)( XArray* src, Int ix )
+void ML_(ppCfiExpr)( const XArray* src, Int ix )
 {
    /* VG_(indexXA) checks for invalid src/ix values, so we can
       use it indiscriminately. */
@@ -1416,7 +1416,7 @@
    preferred.
  */
 static
-Bool preferName ( DebugInfo* di,
+Bool preferName ( const DebugInfo* di,
                   const HChar* a_name, const HChar* b_name,
                   Addr sym_avma/*exposition only*/ )
 {
@@ -1556,7 +1556,8 @@
 
 /* Add the names in FROM to the names in TO. */
 static
-void add_DiSym_names_to_from ( DebugInfo* di, DiSym* to, DiSym* from )
+void add_DiSym_names_to_from ( const DebugInfo* di, DiSym* to,
+                               const DiSym* from )
 {
    vg_assert(to->pri_name);
    vg_assert(from->pri_name);
@@ -2035,7 +2036,7 @@
    return 0;
 }
 
-static void get_cfsi_rd_stats ( struct _DebugInfo* di,
+static void get_cfsi_rd_stats ( const DebugInfo* di,
                                 UWord *n_mergeables, UWord *n_holes )
 {
    Word i;
@@ -2265,7 +2266,7 @@
 /* Find a symbol-table index containing the specified pointer, or -1
    if not found.  Binary search.  */
 
-Word ML_(search_one_symtab) ( struct _DebugInfo* di, Addr ptr,
+Word ML_(search_one_symtab) ( const DebugInfo* di, Addr ptr,
                               Bool match_anywhere_in_sym,
                               Bool findText )
 {
@@ -2298,7 +2299,7 @@
 /* Find a location-table index containing the specified pointer, or -1
    if not found.  Binary search.  */
 
-Word ML_(search_one_loctab) ( struct _DebugInfo* di, Addr ptr )
+Word ML_(search_one_loctab) ( const DebugInfo* di, Addr ptr )
 {
    Addr a_mid_lo, a_mid_hi;
    Word mid, 
@@ -2322,7 +2323,7 @@
 /* Find a CFI-table index containing the specified pointer, or -1
    if not found.  Binary search.  */
 
-Word ML_(search_one_cfitab) ( struct _DebugInfo* di, Addr ptr )
+Word ML_(search_one_cfitab) ( const DebugInfo* di, Addr ptr )
 {
    Word mid, 
         lo = 0, 
@@ -2352,7 +2353,7 @@
 /* Find a FPO-table index containing the specified pointer, or -1
    if not found.  Binary search.  */
 
-Word ML_(search_one_fpotab) ( struct _DebugInfo* di, Addr ptr )
+Word ML_(search_one_fpotab) ( const DebugInfo* di, Addr ptr )
 {
    Addr const addr = ptr - di->fpo_base_avma;
    Addr a_mid_lo, a_mid_hi;
diff --git a/coregrind/m_debuginfo/tytypes.c b/coregrind/m_debuginfo/tytypes.c
index aece0a5..6cb9096 100644
--- a/coregrind/m_debuginfo/tytypes.c
+++ b/coregrind/m_debuginfo/tytypes.c
@@ -48,7 +48,7 @@
 /* Does this TyEnt denote a type, as opposed to some other kind of
    thing? */
 
-Bool ML_(TyEnt__is_type)( TyEnt* te )
+Bool ML_(TyEnt__is_type)( const TyEnt* te )
 {
    switch (te->tag) {
       case Te_EMPTY: case Te_INDIR: case Te_UNKNOWN: 
@@ -67,7 +67,7 @@
 
 /* Print a TyEnt, debug-style. */
 
-static void pp_XArray_of_cuOffs ( XArray* xa )
+static void pp_XArray_of_cuOffs ( const XArray* xa )
 {
    Word i;
    VG_(printf)("{");
@@ -80,7 +80,7 @@
    VG_(printf)("}");
 }
 
-void ML_(pp_TyEnt)( TyEnt* te )
+void ML_(pp_TyEnt)( const TyEnt* te )
 {
    VG_(printf)("0x%05lx  ", te->cuOff);
    switch (te->tag) {
@@ -198,7 +198,7 @@
 
 /* Print a whole XArray of TyEnts, debug-style */
 
-void ML_(pp_TyEnts)( XArray* tyents, const HChar* who )
+void ML_(pp_TyEnts)( const XArray* tyents, const HChar* who )
 {
    Word i, n;
    VG_(printf)("------ %s ------\n", who);
@@ -214,7 +214,7 @@
 
 /* Print a TyEnt, C style, chasing stuff as necessary. */
 
-static void pp_TyBound_C_ishly ( XArray* tyents, UWord cuOff )
+static void pp_TyBound_C_ishly ( const XArray* tyents, UWord cuOff )
 {
    TyEnt* ent = ML_(TyEnts__index_by_cuOff)( tyents, NULL, cuOff );
    if (!ent) {
@@ -235,7 +235,7 @@
       ML_(pp_TyEnt)( ent );
 }
 
-void ML_(pp_TyEnt_C_ishly)( XArray* /* of TyEnt */ tyents,
+void ML_(pp_TyEnt_C_ishly)( const XArray* /* of TyEnt */ tyents,
                             UWord cuOff )
 {
    TyEnt* ent = ML_(TyEnts__index_by_cuOff)( tyents, NULL, cuOff );
@@ -337,7 +337,7 @@
    }
 }
 
-TyEnt* ML_(TyEnts__index_by_cuOff) ( XArray* /* of TyEnt */ ents,
+TyEnt* ML_(TyEnts__index_by_cuOff) ( const XArray* /* of TyEnt */ ents,
                                      TyEntIndexCache* cache,
                                      UWord cuOff_to_find )
 {
@@ -448,7 +448,7 @@
    if (a > b) return 1;
    return 0;
 }
-static Word XArray_of_UWord__cmp ( XArray* a, XArray* b ) {
+static Word XArray_of_UWord__cmp ( const XArray* a, const XArray* b ) {
    Word i, r;
    Word aN = VG_(sizeXA)( a );
    Word bN = VG_(sizeXA)( b );
@@ -461,7 +461,7 @@
    }
    return 0;
 }
-static Word Bytevector__cmp ( UChar* a, UChar* b, Word n ) {
+static Word Bytevector__cmp ( const UChar* a, const UChar* b, Word n ) {
    Word i, r;
    vg_assert(n >= 0);
    for (i = 0; i < n; i++) {
@@ -667,7 +667,7 @@
    return mul1;
 }
 
-MaybeULong ML_(sizeOfType)( XArray* /* of TyEnt */ tyents,
+MaybeULong ML_(sizeOfType)( const XArray* /* of TyEnt */ tyents,
                             UWord cuOff )
 {
    Word       i;
@@ -746,7 +746,7 @@
 }
 
 XArray* /*HChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
-                                      XArray* /* of TyEnt */ tyents,
+                                      const XArray* /* of TyEnt */ tyents,
                                       UWord ty_cuOff, 
                                       PtrdiffT offset )
 {
diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c
index 6cbc31e..2f02c81 100644
--- a/coregrind/m_errormgr.c
+++ b/coregrind/m_errormgr.c
@@ -96,7 +96,7 @@
 
 
 /* forwards ... */
-static Supp* is_suppressible_error ( Error* err );
+static Supp* is_suppressible_error ( const Error* err );
 
 static ThreadId last_tid_printed = 1;
 
@@ -291,7 +291,7 @@
 
 /* Compare errors, to detect duplicates. 
 */
-static Bool eq_Error ( VgRes res, Error* e1, Error* e2 )
+static Bool eq_Error ( VgRes res, const Error* e1, const Error* e2 )
 {
    if (e1->ekind != e2->ekind) 
       return False;
@@ -360,7 +360,7 @@
 
 /* Generate a suppression for an error, either in text or XML mode.
 */
-static void gen_suppression(Error* err)
+static void gen_suppression(const Error* err)
 {
    const HChar* name;
    ExeContext* ec;
@@ -521,7 +521,7 @@
    Note this should not be called in XML mode! 
 */
 static 
-void do_actions_on_error(Error* err, Bool allow_db_attach)
+void do_actions_on_error(const Error* err, Bool allow_db_attach)
 {
    Bool still_noisy = True;
 
@@ -585,7 +585,7 @@
      attach (and detach), and optionally prints a suppression; both
      of these may require user input.
 */
-static void pp_Error ( Error* err, Bool allow_db_attach, Bool xml )
+static void pp_Error ( const Error* err, Bool allow_db_attach, Bool xml )
 {
    /* If this fails, you probably specified your tool's method
       dictionary incorrectly. */
@@ -1173,7 +1173,7 @@
 }
 
 // True if buf starts with fun: or obj: or is ...
-static Bool is_location_line (HChar* buf)
+static Bool is_location_line (const HChar* buf)
 {
    return VG_(strncmp)(buf, "fun:", 4) == 0
       || VG_(strncmp)(buf, "obj:", 4) == 0
@@ -1213,7 +1213,7 @@
    after the descriptor (fun: or obj:) part.
    Returns False if failed.
 */
-static Bool setLocationTy ( SuppLoc* p, HChar *buf )
+static Bool setLocationTy ( SuppLoc* p, const HChar *buf )
 {
    if (VG_(strncmp)(buf, "fun:", 4) == 0) {
       p->name = VG_(strdup)("errormgr.sLTy.1", buf+4);
@@ -1240,7 +1240,7 @@
 
 
 /* Look for "tool" in a string like "tool1,tool2,tool3" */
-static Bool tool_name_present(const HChar *name, HChar *names)
+static Bool tool_name_present(const HChar *name, const HChar *names)
 {
    Bool  found;
    HChar *s = NULL;   /* Shut gcc up */
@@ -1569,7 +1569,7 @@
    }
    IPtoFunOrObjCompleter;
 
-static void pp_ip2fo (IPtoFunOrObjCompleter* ip2fo)
+static void pp_ip2fo (const IPtoFunOrObjCompleter* ip2fo)
 {
   Int i, j;
   Int o;
@@ -1597,7 +1597,7 @@
 /* free the memory in ip2fo.
    At debuglog 4, su (or NULL) will be used to show the matching
    (or non matching) with ip2fo. */
-static void clearIPtoFunOrObjCompleter ( Supp  *su, 
+static void clearIPtoFunOrObjCompleter ( const Supp  *su, 
                                          IPtoFunOrObjCompleter* ip2fo)
 {
    if (DEBUG_ERRORMGR || VG_(debugLog_getLevel)() >= 4) {
@@ -1847,7 +1847,8 @@
 
 /////////////////////////////////////////////////////
 
-static Bool supp_matches_callers(IPtoFunOrObjCompleter* ip2fo, Supp* su)
+static Bool supp_matches_callers(IPtoFunOrObjCompleter* ip2fo,
+                                 const Supp* su)
 {
    /* Unwrap the args and set up the correct parameterisation of
       VG_(generic_match), using supploc_IsStar, supploc_IsQuery and
@@ -1880,7 +1881,7 @@
 /////////////////////////////////////////////////////
 
 static
-Bool supp_matches_error(Supp* su, Error* err)
+Bool supp_matches_error(const Supp* su, const Error* err)
 {
    switch (su->skind) {
       //(example code, see comment on CoreSuppKind above)
@@ -1905,7 +1906,7 @@
    error?  If so, return a pointer to the Supp record, otherwise NULL.
    Tries to minimise the number of symbol searches since they are expensive.  
 */
-static Supp* is_suppressible_error ( Error* err )
+static Supp* is_suppressible_error ( const Error* err )
 {
    Supp* su;
    Supp* su_prev;
diff --git a/coregrind/m_execontext.c b/coregrind/m_execontext.c
index 2901fd9..0ec53de 100644
--- a/coregrind/m_execontext.c
+++ b/coregrind/m_execontext.c
@@ -121,7 +121,7 @@
 /*--- Exported functions.                                  ---*/
 /*------------------------------------------------------------*/
 
-static ExeContext* record_ExeContext_wrk2 ( Addr* ips, UInt n_ips ); /*fwds*/
+static ExeContext* record_ExeContext_wrk2 ( const Addr* ips, UInt n_ips );
 
 /* Initialise this subsystem. */
 static void init_ExeContext_storage ( void )
@@ -203,7 +203,8 @@
 
 
 /* Compare two ExeContexts.  Number of callers considered depends on res. */
-Bool VG_(eq_ExeContext) ( VgRes res, ExeContext* e1, ExeContext* e2 )
+Bool VG_(eq_ExeContext) ( VgRes res, const ExeContext* e1,
+                          const ExeContext* e2 )
 {
    Int i;
 
@@ -266,7 +267,7 @@
    return w;
 }
 
-static UWord calc_hash ( Addr* ips, UInt n_ips, UWord htab_sz )
+static UWord calc_hash ( const Addr* ips, UInt n_ips, UWord htab_sz )
 {
    UInt  i;
    UWord hash = 0;
@@ -351,7 +352,7 @@
    holds a proposed trace.  Find or allocate a suitable ExeContext.
    Note that callers must have done init_ExeContext_storage() before
    getting to this point. */
-static ExeContext* record_ExeContext_wrk2 ( Addr* ips, UInt n_ips )
+static ExeContext* record_ExeContext_wrk2 ( const Addr* ips, UInt n_ips )
 {
    Int         i;
    Bool        same;
@@ -467,12 +468,12 @@
    return e->ips;
 }  
 
-UInt VG_(get_ECU_from_ExeContext)( ExeContext* e ) {
+UInt VG_(get_ECU_from_ExeContext)( const ExeContext* e ) {
    vg_assert(VG_(is_plausible_ECU)(e->ecu));
    return e->ecu;
 }
 
-Int VG_(get_ExeContext_n_ips)( ExeContext* e ) {
+Int VG_(get_ExeContext_n_ips)( const ExeContext* e ) {
    vg_assert(e->n_ips >= 1);
    return e->n_ips;
 }
@@ -492,7 +493,7 @@
    return NULL;
 }
 
-ExeContext* VG_(make_ExeContext_from_StackTrace)( Addr* ips, UInt n_ips )
+ExeContext* VG_(make_ExeContext_from_StackTrace)( const Addr* ips, UInt n_ips )
 {
    init_ExeContext_storage();
    return record_ExeContext_wrk2(ips, n_ips);
diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c
index f982ff9..d8fe923 100644
--- a/coregrind/m_libcassert.c
+++ b/coregrind/m_libcassert.c
@@ -298,7 +298,7 @@
 static void show_sched_status_wrk ( Bool host_stacktrace,
                                     Bool stack_usage,
                                     Bool exited_threads,
-                                    UnwindStartRegs* startRegsIN)
+                                    const UnwindStartRegs* startRegsIN)
 {
    Int i; 
    if (host_stacktrace) {
@@ -385,7 +385,7 @@
 
 __attribute__ ((noreturn))
 static void report_and_quit ( const HChar* report,
-                              UnwindStartRegs* startRegsIN )
+                              const UnwindStartRegs* startRegsIN )
 {
    show_sched_status_wrk (True,  // host_stacktrace
                           False, // stack_usage
@@ -458,7 +458,7 @@
 
 __attribute__ ((noreturn))
 static void panic ( const HChar* name, const HChar* report, const HChar* str,
-                    UnwindStartRegs* startRegs )
+                    const UnwindStartRegs* startRegs )
 {
    if (VG_(clo_xml))
       VG_(printf_xml)("</valgrindoutput>\n");
@@ -466,7 +466,7 @@
    report_and_quit(report, startRegs);
 }
 
-void VG_(core_panic_at) ( const HChar* str, UnwindStartRegs* startRegs )
+void VG_(core_panic_at) ( const HChar* str, const UnwindStartRegs* startRegs )
 {
    panic("valgrind", VG_BUGS_TO, str, startRegs);
 }
diff --git a/coregrind/m_options.c b/coregrind/m_options.c
index 24d06ae..38aaea9 100644
--- a/coregrind/m_options.c
+++ b/coregrind/m_options.c
@@ -74,8 +74,8 @@
 const HChar* VG_(clo_trace_children_skip) = NULL;
 const HChar* VG_(clo_trace_children_skip_by_arg) = NULL;
 Bool   VG_(clo_child_silent_after_fork) = False;
-HChar* VG_(clo_log_fname_expanded) = NULL;
-HChar* VG_(clo_xml_fname_expanded) = NULL;
+const HChar* VG_(clo_log_fname_expanded) = NULL;
+const HChar* VG_(clo_xml_fname_expanded) = NULL;
 Bool   VG_(clo_time_stamp)     = False;
 Int    VG_(clo_input_fd)       = 0; /* stdin */
 Bool   VG_(clo_default_supp)   = True;
@@ -289,8 +289,8 @@
    of the executable.  'child_argv' must not include the name of the
    executable itself; iow child_argv[0] must be the first arg, if any,
    for the child. */
-Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name,
-                                       HChar** child_argv )
+Bool VG_(should_we_trace_this_child) ( const HChar* child_exe_name,
+                                       const HChar** child_argv )
 {
    // child_exe_name is pulled out of the guest's space.  We
    // should be at least marginally cautious with it, lest it
diff --git a/coregrind/m_rangemap.c b/coregrind/m_rangemap.c
index dcb9b83..daed001 100644
--- a/coregrind/m_rangemap.c
+++ b/coregrind/m_rangemap.c
@@ -57,9 +57,9 @@
 
 /* fwds */
 static void preen (/*MOD*/RangeMap* rm);
-static Word find ( RangeMap* rm, UWord key );
+static Word find ( const RangeMap* rm, UWord key );
 static void split_at ( /*MOD*/RangeMap* rm, UWord key );
-static void show ( RangeMap* rm );
+static void show ( const RangeMap* rm );
 
 
 RangeMap* VG_(newRangeMap) ( void*(*alloc_fn)(const HChar*,SizeT), 
@@ -114,7 +114,7 @@
 }
 
 void VG_(lookupRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
-                           /*OUT*/UWord* val, RangeMap* rm, UWord key )
+                           /*OUT*/UWord* val, const RangeMap* rm, UWord key )
 {
    Word   i   = find(rm, key);
    Range* rng = (Range*)VG_(indexXA)(rm->ranges, i);
@@ -123,14 +123,14 @@
    *val     = rng->val;
 }
 
-Word VG_(sizeRangeMap) ( RangeMap* rm )
+Word VG_(sizeRangeMap) ( const RangeMap* rm )
 {
    vg_assert(rm && rm->ranges);
    return VG_(sizeXA)(rm->ranges);
 }
 
 void VG_(indexRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
-                          /*OUT*/UWord* val, RangeMap* rm, Word ix )
+                          /*OUT*/UWord* val, const RangeMap* rm, Word ix )
 {
    vg_assert(rm && rm->ranges);
    Range* rng = (Range*)VG_(indexXA)(rm->ranges, ix);
@@ -158,7 +158,7 @@
    }
 }
 
-static Word find ( RangeMap* rm, UWord key )
+static Word find ( const RangeMap* rm, UWord key )
 {
    XArray* ranges = rm->ranges;
    Word    lo     = 0;
@@ -198,7 +198,7 @@
 }
 
 __attribute__((unused))
-static void show ( RangeMap* rm )
+static void show ( const RangeMap* rm )
 {
    Word i;
    VG_(printf)("<< %ld entries:\n", VG_(sizeXA)(rm->ranges) );
diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c
index caca7c9..07122db 100644
--- a/coregrind/m_redir.c
+++ b/coregrind/m_redir.c
@@ -256,7 +256,7 @@
 typedef
    struct _TopSpec {
       struct _TopSpec* next; /* linked list */
-      DebugInfo* seginfo;    /* symbols etc */
+      const DebugInfo* seginfo;    /* symbols etc */
       Spec*      specs;      /* specs pulled out of seginfo */
       Bool       mark; /* transient temporary used during deletion */
    }
@@ -308,12 +308,12 @@
 static Bool   is_plausible_guest_addr(Addr);
 
 static void   show_redir_state ( const HChar* who );
-static void   show_active ( const HChar* left, Active* act );
+static void   show_active ( const HChar* left, const Active* act );
 
 static void   handle_maybe_load_notifier( const HChar* soname, 
                                           const HChar* symbol, Addr addr );
 
-static void   handle_require_text_symbols ( DebugInfo* );
+static void   handle_require_text_symbols ( const DebugInfo* );
 
 /*------------------------------------------------------------*/
 /*--- NOTIFICATIONS                                        ---*/
@@ -325,7 +325,7 @@
         Spec*    specs, 
         TopSpec* parent_spec,
 	/* debuginfo and the owning TopSpec */
-        DebugInfo* di,
+        const DebugInfo* di,
         TopSpec* parent_sym 
      );
 
@@ -388,7 +388,7 @@
 
 #define N_DEMANGLED 256
 
-void VG_(redir_notify_new_DebugInfo)( DebugInfo* newdi )
+void VG_(redir_notify_new_DebugInfo)( const DebugInfo* newdi )
 {
    Bool         ok, isWrap;
    Int          i, nsyms, becTag, becPrio;
@@ -750,7 +750,7 @@
         Spec*    specs, 
         TopSpec* parent_spec,
 	/* seginfo and the owning TopSpec */
-        DebugInfo* di,
+        const DebugInfo* di,
         TopSpec* parent_sym 
      )
 {
@@ -1017,7 +1017,7 @@
    simple -- just get rid of all actives derived from it, and free up
    the associated list elements. */
 
-void VG_(redir_notify_delete_DebugInfo)( DebugInfo* delsi )
+void VG_(redir_notify_delete_DebugInfo)( const DebugInfo* delsi )
 {
    TopSpec* ts;
    TopSpec* tsPrev;
@@ -1575,7 +1575,7 @@
    symbols that satisfy any --require-text-symbol= specifications that
    apply to it, and abort the run with an error message if not.
 */
-static void handle_require_text_symbols ( DebugInfo* di )
+static void handle_require_text_symbols ( const DebugInfo* di )
 {
    /* First thing to do is figure out which, if any,
       --require-text-symbol specification strings apply to this
@@ -1690,7 +1690,7 @@
 /*--- SANITY/DEBUG                                         ---*/
 /*------------------------------------------------------------*/
 
-static void show_spec ( const HChar* left, Spec* spec )
+static void show_spec ( const HChar* left, const Spec* spec )
 {
    VG_(message)( Vg_DebugMsg, 
                  "%s%25s %30s %s-> (%04d.%d) 0x%08llx\n",
@@ -1701,7 +1701,7 @@
                  (ULong)spec->to_addr );
 }
 
-static void show_active ( const HChar* left, Active* act )
+static void show_active ( const HChar* left, const Active* act )
 {
    Bool ok;
    HChar name1[64] = "";
diff --git a/coregrind/m_sbprofile.c b/coregrind/m_sbprofile.c
index 53f9715..197fff5 100644
--- a/coregrind/m_sbprofile.c
+++ b/coregrind/m_sbprofile.c
@@ -46,7 +46,7 @@
 static UInt n_profiles = 0;
 
 static 
-void show_SB_profile ( SBProfEntry tops[], UInt n_tops,
+void show_SB_profile ( const SBProfEntry tops[], UInt n_tops,
                        ULong score_total, ULong ecs_done )
 {
    ULong score_cumul, score_cumul_saved, score_here;
diff --git a/coregrind/m_stacktrace.c b/coregrind/m_stacktrace.c
index be171b5..b4fb86d 100644
--- a/coregrind/m_stacktrace.c
+++ b/coregrind/m_stacktrace.c
@@ -139,7 +139,7 @@
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt max_n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
-                               UnwindStartRegs* startRegs,
+                               const UnwindStartRegs* startRegs,
                                Addr fp_max_orig )
 {
    const Bool do_stats = False; // compute and output some stats regularly.
@@ -457,7 +457,7 @@
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt max_n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
-                               UnwindStartRegs* startRegs,
+                               const UnwindStartRegs* startRegs,
                                Addr fp_max_orig )
 {
    Bool  debug = False;
@@ -628,7 +628,7 @@
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt max_n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
-                               UnwindStartRegs* startRegs,
+                               const UnwindStartRegs* startRegs,
                                Addr fp_max_orig )
 {
    Bool  lr_is_first_RA = False;
@@ -898,7 +898,7 @@
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt max_n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
-                               UnwindStartRegs* startRegs,
+                               const UnwindStartRegs* startRegs,
                                Addr fp_max_orig )
 {
    Bool  debug = False;
@@ -1044,7 +1044,7 @@
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt max_n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
-                               UnwindStartRegs* startRegs,
+                               const UnwindStartRegs* startRegs,
                                Addr fp_max_orig )
 {
    Bool  debug = False;
@@ -1140,7 +1140,7 @@
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt max_n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
-                               UnwindStartRegs* startRegs,
+                               const UnwindStartRegs* startRegs,
                                Addr fp_max_orig )
 {
    Bool  debug = False;
@@ -1223,7 +1223,7 @@
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt max_n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
-                               UnwindStartRegs* startRegs,
+                               const UnwindStartRegs* startRegs,
                                Addr fp_max_orig )
 {
    Bool  debug = False;
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
index 7e49124..121b064 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -2735,7 +2735,7 @@
    // Decide whether or not we want to follow along
    { // Make 'child_argv' be a pointer to the child's arg vector
      // (skipping the exe name)
-     HChar** child_argv = (HChar**)ARG2;
+     const HChar** child_argv = (const HChar**)ARG2;
      if (child_argv && child_argv[0] == NULL)
         child_argv = NULL;
      trace_this_child = VG_(should_we_trace_this_child)( (HChar*)ARG1, child_argv );
diff --git a/coregrind/m_transtab.c b/coregrind/m_transtab.c
index e261ecb..e9cfd02 100644
--- a/coregrind/m_transtab.c
+++ b/coregrind/m_transtab.c
@@ -469,7 +469,7 @@
    VG_(memset)(tte, 0, sizeof(*tte));
 }
 
-static UWord InEdgeArr__size ( InEdgeArr* iea )
+static UWord InEdgeArr__size ( const InEdgeArr* iea )
 {
    if (iea->var) {
       vg_assert(iea->n_fixed == 0);
@@ -546,7 +546,7 @@
    }
 }
 
-static UWord OutEdgeArr__size ( OutEdgeArr* oea )
+static UWord OutEdgeArr__size ( const OutEdgeArr* oea )
 {
    if (oea->var) {
       vg_assert(oea->n_fixed == 0);
@@ -680,8 +680,8 @@
       if (UNLIKELY(sno == -1))
          return False; /* run out of sectors to search */
 
-      Sector* sec = &sectors[sno];
-      XArray* /* of HostExtent */ host_extents = sec->host_extents;
+      const Sector* sec = &sectors[sno];
+      const XArray* /* of HostExtent */ host_extents = sec->host_extents;
       vg_assert(host_extents);
 
       HostExtent key;
@@ -722,15 +722,15 @@
 /* Figure out whether or not hcode is jitted code present in the main
    code cache (but not in the no-redir cache).  Used for sanity
    checking. */
-static Bool is_in_the_main_TC ( void* hcode )
+static Bool is_in_the_main_TC ( const void* hcode )
 {
    Int i, sno;
    for (i = 0; i < n_sectors; i++) {
       sno = sector_search_order[i];
       if (sno == -1)
          break; /* run out of sectors to search */
-      if ((UChar*)hcode >= (UChar*)sectors[sno].tc
-          && (UChar*)hcode <= (UChar*)sectors[sno].tc_next
+      if ((const UChar*)hcode >= (const UChar*)sectors[sno].tc
+          && (const UChar*)hcode <= (const UChar*)sectors[sno].tc_next
                               + sizeof(ULong) - 1)
          return True;
    }
@@ -963,8 +963,9 @@
 
 static 
 Int vexGuestExtents_to_eclasses ( /*OUT*/Int* eclasses,
-                                  VexGuestExtents* vge )
+                                  const VexGuestExtents* vge )
 {
+
 #  define SWAP(_lv1,_lv2) \
       do { Int t = _lv1; _lv1 = _lv2; _lv2 = t; } while (0)
 
@@ -1084,7 +1085,7 @@
 /* Check the eclass info in 'sec' to ensure it is consistent.  Returns
    True if OK, False if something's not right.  Expensive. */
 
-static Bool sanity_check_eclasses_in_sector ( Sector* sec )
+static Bool sanity_check_eclasses_in_sector ( const Sector* sec )
 {
 #  define BAD(_str) do { whassup = (_str); goto bad; } while (0)
 
@@ -1296,7 +1297,7 @@
 /*--- Add/find translations                                 ---*/
 /*-------------------------------------------------------------*/
 
-static UInt vge_osize ( VexGuestExtents* vge )
+static UInt vge_osize ( const VexGuestExtents* vge )
 {
    UInt i, n = 0;
    for (i = 0; i < vge->n_used; i++)
@@ -1511,7 +1512,7 @@
    pre: youngest_sector points to a valid (although possibly full)
    sector.
 */
-void VG_(add_to_transtab)( VexGuestExtents* vge,
+void VG_(add_to_transtab)( const VexGuestExtents* vge,
                            Addr64           entry,
                            AddrH            code,
                            UInt             code_len,
@@ -1769,7 +1770,7 @@
 }
 
 static inline
-Bool overlaps ( Addr64 start, ULong range, VexGuestExtents* vge )
+Bool overlaps ( Addr64 start, ULong range, const VexGuestExtents* vge )
 {
    if (overlap1(start, range, vge->base[0], (UInt)vge->len[0]))
       return True;
@@ -2104,7 +2105,7 @@
 /* Add an UNREDIRECTED translation of vge to TT/TC.  The translation
    is temporarily in code[0 .. code_len-1].
 */
-void VG_(add_to_unredir_transtab)( VexGuestExtents* vge,
+void VG_(add_to_unredir_transtab)( const VexGuestExtents* vge,
                                    Addr64           entry,
                                    AddrH            code,
                                    UInt             code_len )
@@ -2318,7 +2319,7 @@
 /*--- Printing out of profiling results.                   ---*/
 /*------------------------------------------------------------*/
 
-static ULong score ( TTEntry* tte )
+static ULong score ( const TTEntry* tte )
 {
    return ((ULong)tte->weight) * ((ULong)tte->count);
 }
diff --git a/coregrind/pub_core_debuginfo.h b/coregrind/pub_core_debuginfo.h
index 8060e82..23075b8 100644
--- a/coregrind/pub_core_debuginfo.h
+++ b/coregrind/pub_core_debuginfo.h
@@ -214,7 +214,8 @@
    platforms, a symbol is deemed to be found only if it has a nonzero
    TOC pointer.  */
 extern
-Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, HChar* name, SymAVMAs* avmas);
+Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, const HChar* name,
+                             SymAVMAs* avmas);
 
 #endif   // __PUB_CORE_DEBUGINFO_H
 
diff --git a/coregrind/pub_core_libcassert.h b/coregrind/pub_core_libcassert.h
index 6e1df85..32cfc50 100644
--- a/coregrind/pub_core_libcassert.h
+++ b/coregrind/pub_core_libcassert.h
@@ -64,7 +64,7 @@
 __attribute__ ((__noreturn__))
 extern void  VG_(core_panic)      ( const HChar* str );
 __attribute__ ((__noreturn__))
-extern void  VG_(core_panic_at)   ( const HChar* str, UnwindStartRegs* );
+extern void  VG_(core_panic_at)   ( const HChar* str, const UnwindStartRegs* );
 
 /* Exits with status as client exit code. */
 extern void VG_(client_exit)( Int status );
diff --git a/coregrind/pub_core_libcfile.h b/coregrind/pub_core_libcfile.h
index 707399f..cec1012 100644
--- a/coregrind/pub_core_libcfile.h
+++ b/coregrind/pub_core_libcfile.h
@@ -50,7 +50,8 @@
 extern Long VG_(fsize) ( Int fd );
 
 /* Lookup an extended attribute for a file */
-extern SysRes VG_(getxattr) ( const HChar* file_name, const HChar* attr_name, Addr attr_value, SizeT attr_value_len );
+extern SysRes VG_(getxattr) ( const HChar* file_name, const HChar* attr_name,
+                              Addr attr_value, SizeT attr_value_len );
 
 /* Is the file a directory? */
 extern Bool VG_(is_dir) ( const HChar* f );
diff --git a/coregrind/pub_core_options.h b/coregrind/pub_core_options.h
index e98a88c..3045742 100644
--- a/coregrind/pub_core_options.h
+++ b/coregrind/pub_core_options.h
@@ -116,8 +116,8 @@
 
 /* If the user specified --log-file=STR and/or --xml-file=STR, these
    hold STR after expansion of the %p and %q templates. */
-extern HChar* VG_(clo_log_fname_expanded);
-extern HChar* VG_(clo_xml_fname_expanded);
+extern const HChar* VG_(clo_log_fname_expanded);
+extern const HChar* VG_(clo_xml_fname_expanded);
 
 /* Add timestamps to log messages?  default: NO */
 extern Bool  VG_(clo_time_stamp);
@@ -351,8 +351,8 @@
    of the executable.  'child_argv' must not include the name of the
    executable itself; iow child_argv[0] must be the first arg, if any,
    for the child. */
-extern Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name,
-                                              HChar** child_argv );
+extern Bool VG_(should_we_trace_this_child) ( const HChar* child_exe_name,
+                                              const HChar** child_argv );
 
 /* Whether illegal instructions should be reported/diagnosed.
    Can be explicitly set through --sigill-diagnostics otherwise
diff --git a/coregrind/pub_core_redir.h b/coregrind/pub_core_redir.h
index d8325b2..3f2541b 100644
--- a/coregrind/pub_core_redir.h
+++ b/coregrind/pub_core_redir.h
@@ -63,11 +63,11 @@
 //--------------------------------------------------------------------
 
 /* Notify the module of a new DebugInfo (called from m_debuginfo). */
-extern void VG_(redir_notify_new_DebugInfo)( DebugInfo* );
+extern void VG_(redir_notify_new_DebugInfo)( const DebugInfo* );
 
 /* Notify the module of the disappearance of a DebugInfo (also called
    from m_debuginfo). */
-extern void VG_(redir_notify_delete_DebugInfo)( DebugInfo* );
+extern void VG_(redir_notify_delete_DebugInfo)( const DebugInfo* );
 
 /* Initialise the module, and load initial "hardwired" redirects. */
 extern void VG_(redir_initialise)( void );
diff --git a/coregrind/pub_core_stacktrace.h b/coregrind/pub_core_stacktrace.h
index 478e67c..5ec37aa 100644
--- a/coregrind/pub_core_stacktrace.h
+++ b/coregrind/pub_core_stacktrace.h
@@ -54,7 +54,7 @@
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
-                               UnwindStartRegs* startRegs,
+                               const UnwindStartRegs* startRegs,
                                Addr fp_max_orig );
 
 #endif   // __PUB_CORE_STACKTRACE_H
diff --git a/coregrind/pub_core_transtab.h b/coregrind/pub_core_transtab.h
index 6f810f8..e9e3233 100644
--- a/coregrind/pub_core_transtab.h
+++ b/coregrind/pub_core_transtab.h
@@ -78,7 +78,7 @@
 #endif
 
 extern
-void VG_(add_to_transtab)( VexGuestExtents* vge,
+void VG_(add_to_transtab)( const VexGuestExtents* vge,
                            Addr64           entry,
                            AddrH            code,
                            UInt             code_len,
@@ -109,7 +109,7 @@
    table. */
 
 extern
-void VG_(add_to_unredir_transtab)( VexGuestExtents* vge,
+void VG_(add_to_unredir_transtab)( const VexGuestExtents* vge,
                                    Addr64           entry,
                                    AddrH            code,
                                    UInt             code_len );
diff --git a/include/pub_tool_addrinfo.h b/include/pub_tool_addrinfo.h
index 0e55042..ce2c232 100644
--- a/include/pub_tool_addrinfo.h
+++ b/include/pub_tool_addrinfo.h
@@ -190,14 +190,14 @@
 
 /* Prints the AddrInfo ai describing a.
    Note that an ai with tag Addr_Undescribed will cause an assert.*/
-extern void VG_(pp_addrinfo) ( Addr a, AddrInfo* ai );
+extern void VG_(pp_addrinfo) ( Addr a, const AddrInfo* ai );
 
 /* Same as VG_(pp_addrinfo) but provides some memcheck specific behaviour:
    * maybe_gcc indicates Addr a was just below the stack ptr when the error
      with a was encountered.
    * the message for Unknown tag is slightly different, as memcheck
      has a recently freed list. */
-extern void VG_(pp_addrinfo_mc) ( Addr a, AddrInfo* ai, Bool maybe_gcc );
+extern void VG_(pp_addrinfo_mc) ( Addr a, const AddrInfo* ai, Bool maybe_gcc );
 
 #endif   // __PUB_TOOL_ADDRINFO_H
 
diff --git a/include/pub_tool_execontext.h b/include/pub_tool_execontext.h
index a78d66e..39f4a56 100644
--- a/include/pub_tool_execontext.h
+++ b/include/pub_tool_execontext.h
@@ -81,7 +81,8 @@
 //   Vg_LowRes:  2
 //   Vg_MedRes:  4
 //   Vg_HighRes: all
-extern Bool VG_(eq_ExeContext) ( VgRes res, ExeContext* e1, ExeContext* e2 );
+extern Bool VG_(eq_ExeContext) ( VgRes res, const ExeContext* e1,
+                                 const ExeContext* e2 );
 
 // Print an ExeContext.
 extern void VG_(pp_ExeContext) ( ExeContext* ec );
@@ -90,10 +91,10 @@
 // (the "ExeContext Unique").  Guaranteed to be nonzero and to be a
 // multiple of four (iow, the lowest two bits are guaranteed to
 // be zero, so that callers can store other information there.
-extern UInt VG_(get_ECU_from_ExeContext)( ExeContext* e );
+extern UInt VG_(get_ECU_from_ExeContext)( const ExeContext* e );
 
 // How many entries (frames) in this ExeContext?
-extern Int VG_(get_ExeContext_n_ips)( ExeContext* e );
+extern Int VG_(get_ExeContext_n_ips)( const ExeContext* e );
 
 // Find the ExeContext that has the given ECU, if any.
 // NOTE: very slow.  Do not call often.
@@ -110,7 +111,7 @@
 }
 
 // Make an ExeContext containing exactly the specified stack frames.
-ExeContext* VG_(make_ExeContext_from_StackTrace)( Addr* ips, UInt n_ips );
+ExeContext* VG_(make_ExeContext_from_StackTrace)( const Addr* ips, UInt n_ips );
 
 // Returns the "null" exe context. The null execontext is an artificial
 // exe context, with a stack trace made of one Addr (the NULL address).
diff --git a/include/pub_tool_rangemap.h b/include/pub_tool_rangemap.h
index dba0fcf..657fad6 100644
--- a/include/pub_tool_rangemap.h
+++ b/include/pub_tool_rangemap.h
@@ -68,14 +68,14 @@
    entire key space.  This is fast: O(log N) in the number of
    ranges. */
 void VG_(lookupRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
-                           /*OUT*/UWord* val, RangeMap* rm, UWord key );
+                           /*OUT*/UWord* val, const RangeMap* rm, UWord key );
 
 /* How many elements are there in the map? */
-Word VG_(sizeRangeMap) ( RangeMap* rm );
+Word VG_(sizeRangeMap) ( const RangeMap* rm );
 
 /* Get the i'th component */
 void VG_(indexRangeMap) ( /*OUT*/UWord* key_min, /*OUT*/UWord* key_max,
-                          /*OUT*/UWord* val, RangeMap* rm, Word ix );
+                          /*OUT*/UWord* val, const RangeMap* rm, Word ix );
 
 #endif   // __PUB_TOOL_RANGEMAP_H