]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Changes to allow compilation with -Wwrite-strings. That compiler option
authorFlorian Krohm <florian@eich-krohm.de>
Fri, 23 Nov 2012 16:17:43 +0000 (16:17 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Fri, 23 Nov 2012 16:17:43 +0000 (16:17 +0000)
is not used for testcases, just for valgrind proper.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13137

63 files changed:
Makefile.tool-tests.am
cachegrind/cg_merge.c
callgrind/dump.c
callgrind/main.c
configure.in
coregrind/m_commandline.c
coregrind/m_debuginfo/d3basics.c
coregrind/m_debuginfo/debuginfo.c
coregrind/m_debuginfo/priv_d3basics.h
coregrind/m_debuginfo/priv_storage.h
coregrind/m_debuginfo/priv_tytypes.h
coregrind/m_debuginfo/readdwarf.c
coregrind/m_debuginfo/readdwarf3.c
coregrind/m_debuginfo/readelf.c
coregrind/m_debuginfo/readpdb.c
coregrind/m_debuginfo/storage.c
coregrind/m_debuginfo/tytypes.c
coregrind/m_debuglog.c
coregrind/m_gdbserver/m_gdbserver.c
coregrind/m_gdbserver/regdef.h
coregrind/m_gdbserver/remote-utils.c
coregrind/m_gdbserver/server.c
coregrind/m_gdbserver/server.h
coregrind/m_gdbserver/signals.c
coregrind/m_gdbserver/target.c
coregrind/m_gdbserver/target.h
coregrind/m_gdbserver/utils.c
coregrind/m_gdbserver/valgrind-low-amd64.c
coregrind/m_gdbserver/valgrind-low-arm.c
coregrind/m_gdbserver/valgrind-low-mips32.c
coregrind/m_gdbserver/valgrind-low-ppc32.c
coregrind/m_gdbserver/valgrind-low-ppc64.c
coregrind/m_gdbserver/valgrind-low-s390x.c
coregrind/m_gdbserver/valgrind-low-x86.c
coregrind/m_gdbserver/valgrind_low.h
coregrind/m_libcbase.c
coregrind/m_libcfile.c
coregrind/m_machine.c
coregrind/m_main.c
coregrind/m_mallocfree.c
coregrind/m_redir.c
coregrind/m_syswrap/syswrap-xen.c
coregrind/m_transtab.c
coregrind/m_xarray.c
coregrind/pub_core_debuginfo.h
coregrind/vgdb.c
drd/tests/unit_bitmap.c
exp-sgcheck/sg_main.c
helgrind/hg_errors.c
helgrind/hg_errors.h
helgrind/hg_main.c
helgrind/libhb_core.c
include/pub_tool_gdbserver.h
include/pub_tool_libcbase.h
include/pub_tool_libcfile.h
include/pub_tool_machine.h
include/pub_tool_xarray.h
massif/ms_main.c
memcheck/mc_errors.c
memcheck/mc_leakcheck.c
memcheck/mc_main.c
memcheck/mc_malloc_wrappers.c
memcheck/mc_translate.c

index da07ec7338a161b30ee8c3953eeb4ab5e98df262..c8fd434fca35006732261cfb024f8cd6f7e0eaad 100644 (file)
@@ -27,6 +27,10 @@ if VGCONF_OS_IS_DARWIN
 noinst_DSYMS = $(check_PROGRAMS)
 endif
 
+if HAS_WRITE_STRINGS_WARNING
+CFLAGS += -Wno-write-strings
+endif
+
 check-local: build-noinst_DSYMS
 
 clean-local: clean-noinst_DSYMS
index 54b82a3a144467755ccdb9db75f6892c561bfcae..20556fc31b4b3caa016fb5fd3ed5935871ebd6f7 100644 (file)
@@ -111,7 +111,7 @@ WordFM* dopyFM ( WordFM* fm, Word(*dopyK)(Word), Word(*dopyV)(Word) );
 //------------------------------------------------------------------//
 
 
-static char* argv0 = "cg_merge";
+static const char* argv0 = "cg_merge";
 
 /* Keep track of source filename/line no so as to be able to
    print decent error messages. */
@@ -129,7 +129,7 @@ static void printSrcLoc ( SOURCE* s )
 }
 
 __attribute__((noreturn))
-static void mallocFail ( SOURCE* s, char* who )
+static void mallocFail ( SOURCE* s, const char* who )
 {
    fprintf(stderr, "%s: out of memory in %s\n", argv0, who );
    printSrcLoc( s );
@@ -137,7 +137,7 @@ static void mallocFail ( SOURCE* s, char* who )
 }
 
 __attribute__((noreturn))
-static void parseError ( SOURCE* s, char* msg )
+static void parseError ( SOURCE* s, const char* msg )
 {
    fprintf(stderr, "%s: parse error: %s\n", argv0, msg );
    printSrcLoc( s );
@@ -145,7 +145,7 @@ static void parseError ( SOURCE* s, char* msg )
 }
 
 __attribute__((noreturn))
-static void barf ( SOURCE* s, char* msg )
+static void barf ( SOURCE* s, const char* msg )
 {
    fprintf(stderr, "%s: %s\n", argv0, msg );
    printSrcLoc( s );
@@ -186,12 +186,12 @@ static Bool readline ( SOURCE* s )
    return line[0] != 0;
 }
 
-static Bool streqn ( char* s1, char* s2, size_t n )
+static Bool streqn ( const char* s1, const char* s2, size_t n )
 {
    return 0 == strncmp(s1, s2, n);
 }
 
-static Bool streq ( char* s1, char* s2 )
+static Bool streq ( const char* s1, const char* s2 )
 {
    return 0 == strcmp(s1, s2 );
 }
@@ -534,7 +534,7 @@ static Bool addCountsToMap ( SOURCE* s,
 static
 void handle_counts ( SOURCE* s,
                      CacheProfFile* cpf, 
-                     char* fi, char* fn, char* newCountsStr )
+                     const char* fi, const char* fn, char* newCountsStr )
 {
    WordFM* countsMap;
    Bool    freeNewCounts;
@@ -604,10 +604,8 @@ static CacheProfFile* parse_CacheProfFile ( SOURCE* s )
    int            n_tmp_desclines = 0;
    CacheProfFile* cpf;
    Counts*        summaryRead; 
-   char*          curr_fn_init = "???";
-   char*          curr_fl_init = "???";
-   char*          curr_fn      = curr_fn_init;
-   char*          curr_fl      = curr_fl_init;
+   char*          curr_fn = strdup("???");
+   char*          curr_fl = strdup("???");
 
    cpf = new_CacheProfFile( NULL, NULL, NULL, 0, NULL, NULL, NULL );
    if (cpf == NULL)
@@ -686,15 +684,13 @@ static CacheProfFile* parse_CacheProfFile ( SOURCE* s )
       }
       else
       if (streqn(line, "fn=", 3)) {
-         if (curr_fn != curr_fn_init)
-            free(curr_fn);
+         free(curr_fn);
          curr_fn = strdup(line+3);
          continue;
       }
       else
       if (streqn(line, "fl=", 3)) {
-         if (curr_fl != curr_fl_init)
-            free(curr_fl);
+         free(curr_fl);
          curr_fl = strdup(line+3);
          continue;
       }
@@ -742,10 +738,8 @@ static CacheProfFile* parse_CacheProfFile ( SOURCE* s )
       cpf->summary_line = NULL;
    }
 
-   if (curr_fn != curr_fn_init)
-      free(curr_fn);
-   if (curr_fl != curr_fl_init)
-      free(curr_fl);
+   free(curr_fn);
+   free(curr_fl);
 
    // All looks OK
    return cpf;
index 8cdade63b382e81a46c9b710a9a774dc89372bd8..0f38e099af99cf8b07dd358235690e07f1bfe9be 100644 (file)
@@ -145,7 +145,7 @@ void init_fpos(FnPos* p)
 
 #if 0
 static __inline__
-static void my_fwrite(Int fd, HChar* buf, Int len)
+static void my_fwrite(Int fd, const HChar* buf, Int len)
 {
        VG_(write)(fd, buf, len);
 }
@@ -165,7 +165,7 @@ void fwrite_flush(void)
     fwrite_pos = 0;
 }
 
-static void my_fwrite(Int fd, HChar* buf, Int len)
+static void my_fwrite(Int fd, const HChar* buf, Int len)
 {
     if (fwrite_fd != fd) {
        fwrite_flush();
index d82d38248671f9fbfad493b3363f521474bf3e0a..c15e6c29be7cc21343576a21f2c14fea34a36dff 100644 (file)
@@ -1376,8 +1376,9 @@ void zero_state_cost(thread_info* t)
     CLG_(zero_cost)( CLG_(sets).full, CLG_(current_state).cost );
 }
 
-/* Ups, this can go very wrong... */
-extern void VG_(discard_translations) ( Addr64 start, ULong range, HChar* who );
+/* Ups, this can go very wrong...
+   FIXME: We should export this function or provide other means to get a handle */
+extern void VG_(discard_translations) ( Addr64 start, ULong range, const HChar* who );
 
 void CLG_(set_instrument_state)(const HChar* reason, Bool state)
 {
index 17deeddd5e9139108384a1c25d30ca61dbd4e46e..31e08150e335ad10e85b3d1060fb40c873b833dc 100644 (file)
@@ -1417,6 +1417,29 @@ CFLAGS=$safe_CFLAGS
 AM_CONDITIONAL(HAS_POINTER_SIGN_WARNING, test x$no_pointer_sign = xyes)
 
 
+# does this compiler support -Wno-write-strings ?
+AC_MSG_CHECKING([if gcc accepts -Wwrite-strings])
+
+safe_CFLAGS=$CFLAGS
+CFLAGS="-Wwrite-strings"
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+  return 0;
+]])], [
+no_write_strings=yes
+AC_MSG_RESULT([yes])
+], [
+no_write_strings=no
+AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+
+if test x$no_write_strings = xyes; then
+  CFLAGS="$CFLAGS -Wwrite-strings"
+fi
+
+AM_CONDITIONAL(HAS_WRITE_STRINGS_WARNING, test x$no_write_strings = xyes)
+
 # does this compiler support -Wno-empty-body ?
 
 AC_MSG_CHECKING([if gcc accepts -Wno-empty-body])
index 64133a3e6457a721f1dd47841fbb0e42b072002c..6d5871af824588e0b5b89c0c1ba0fe394172a818 100644 (file)
@@ -53,7 +53,7 @@ static void add_string ( XArray* /* of HChar* */xa, HChar* str )
 // Note that we deliberately don't free the malloc'd memory.  See
 // comment at call site.
 
-static HChar* read_dot_valgrindrc ( HChar* dir )
+static HChar* read_dot_valgrindrc ( const HChar* dir )
 {
    Int    n;
    SysRes fd;
index e6f6c7da85ba04233459d0e418ea49b235579da4..88475bc309bbbe8b4311b9297eb46931b9147cdd 100644 (file)
@@ -48,7 +48,7 @@
 #include "priv_d3basics.h"      /* self */
 #include "priv_storage.h"
 
-HChar* ML_(pp_DW_children) ( DW_children hashch )
+const HChar* ML_(pp_DW_children) ( DW_children hashch )
 {
    switch (hashch) {
       case DW_children_no:  return "no children";
@@ -57,7 +57,7 @@ HChar* ML_(pp_DW_children) ( DW_children hashch )
    return "DW_children_???";
 }
 
-HChar* ML_(pp_DW_TAG) ( DW_TAG tag )
+const HChar* ML_(pp_DW_TAG) ( DW_TAG tag )
 {
    switch (tag) {
       case DW_TAG_padding:            return "DW_TAG_padding";
@@ -152,7 +152,7 @@ HChar* ML_(pp_DW_TAG) ( DW_TAG tag )
    return "DW_TAG_???";
 }
 
-HChar* ML_(pp_DW_FORM) ( DW_FORM form )
+const HChar* ML_(pp_DW_FORM) ( DW_FORM form )
 {
    switch (form) {
       case DW_FORM_addr:      return "DW_FORM_addr";
@@ -186,7 +186,7 @@ HChar* ML_(pp_DW_FORM) ( DW_FORM form )
    return "DW_FORM_???";
 }
 
-HChar* ML_(pp_DW_AT) ( DW_AT attr )
+const HChar* ML_(pp_DW_AT) ( DW_AT attr )
 {
    switch (attr) {
       case DW_AT_sibling:             return "DW_AT_sibling";
@@ -1013,7 +1013,7 @@ GXResult ML_(evaluate_trivial_GX)( GExpr* gx, const DebugInfo* di )
    Word       i, nGuards;
    MaybeULong *mul, *mul2;
 
-   HChar*  badness = NULL;
+   const HChar*  badness = NULL;
    UChar*  p       = &gx->payload[0]; /* must remain unsigned */
    XArray* results = VG_(newXA)( ML_(dinfo_zalloc), "di.d3basics.etG.1",
                                  ML_(dinfo_free),
index 16f0cf7b0d5ef27cb350402844d5c5d4c3696b80..0e7d33e53dc967ecf7b660f10e3aa72ba4cc3691 100644 (file)
@@ -298,7 +298,7 @@ static void free_DebugInfo ( DebugInfo* di )
 */
 static void discard_DebugInfo ( DebugInfo* di )
 {
-   HChar* reason = "munmap";
+   const HChar* reason = "munmap";
 
    DebugInfo** prev_next_ptr = &debugInfo_list;
    DebugInfo*  curr          =  debugInfo_list;
@@ -1765,7 +1765,7 @@ Bool VG_(get_filename_linenum) ( Addr a,
    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)(HChar* sopatt, HChar* name, 
+Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, HChar* name, 
                              Addr* pEnt, Addr* pToc)
 {
    Bool     require_pToc = False;
@@ -1909,8 +1909,8 @@ HChar* VG_(describe_IP)(Addr eip, HChar* buf, Int n_buf)
    if (VG_(clo_xml)) {
 
       Bool   human_readable = True;
-      HChar* maybe_newline  = human_readable ? "\n      " : "";
-      HChar* maybe_newline2 = human_readable ? "\n    "   : "";
+      const HChar* maybe_newline  = human_readable ? "\n      " : "";
+      const HChar* maybe_newline2 = human_readable ? "\n    "   : "";
 
       /* Print in XML format, dumping in as much info as we know.
          Ensure all tags are balanced even if the individual strings
index 457943eea9468f91df3a145de6fd70ed66724e1b..61acc7156717d802e0c7cef6beca98b58ea320e1 100644 (file)
@@ -562,10 +562,10 @@ typedef enum
   }
   DW_OP;
 
-HChar* ML_(pp_DW_children) ( DW_children hashch );
-HChar* ML_(pp_DW_TAG)      ( DW_TAG tag );
-HChar* ML_(pp_DW_FORM)     ( DW_FORM form );
-HChar* ML_(pp_DW_AT)       ( DW_AT attr );
+const HChar* ML_(pp_DW_children) ( DW_children hashch );
+const HChar* ML_(pp_DW_TAG)      ( DW_TAG tag );
+const HChar* ML_(pp_DW_FORM)     ( DW_FORM form );
+const HChar* ML_(pp_DW_AT)       ( DW_AT attr );
 
 
 /* --- To do with evaluation of Dwarf expressions --- */
index dd90f187da8c768c7a111178ad37929ab4650ff3..a88c2e4e1953843c78e9cb457887205d36b8d45d 100644 (file)
@@ -843,7 +843,7 @@ extern void ML_(addDiCfSI) ( struct _DebugInfo* di, DiCfSI* cfsi );
 
 /* Add a string to the string table of a DebugInfo.  If len==-1,
    ML_(addStr) will itself measure the length of the string. */
-extern HChar* ML_(addStr) ( struct _DebugInfo* di, HChar* str, Int len );
+extern HChar* ML_(addStr) ( struct _DebugInfo* di, const HChar* str, Int len );
 
 extern void ML_(addVar)( struct _DebugInfo* di,
                          Int    level,
@@ -899,7 +899,7 @@ extern struct _DebugInfoMapping* ML_(find_rx_mapping) ( struct _DebugInfo* di,
    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, HChar* msg );
+void ML_(symerr) ( struct _DebugInfo* di, Bool serious, const HChar* msg );
 
 /* Print a symbol. */
 extern void ML_(ppSym) ( Int idx, DiSym* sym );
index 4ed2dab00144570cae03800740fb71704b022e07..5a208b4c1cde0fb396cb7c664f9dbde46f547eac 100644 (file)
@@ -146,7 +146,7 @@ Bool ML_(TyEnt__is_type)( TyEnt* );
 void ML_(pp_TyEnt)( TyEnt* );
 
 /* Print a whole XArray of TyEnts, debug-style */
-void ML_(pp_TyEnts)( XArray* tyents, HChar* who );
+void ML_(pp_TyEnts)( XArray* tyents, const HChar* who );
 
 /* Print a TyEnt, C style, chasing stuff as necessary. */
 void ML_(pp_TyEnt_C_ishly)( XArray* /* of TyEnt */ tyents,
@@ -154,11 +154,11 @@ void ML_(pp_TyEnt_C_ishly)( XArray* /* of TyEnt */ tyents,
 
 /* Generates a total ordering on TyEnts based only on their .cuOff
    fields. */
-Word ML_(TyEnt__cmp_by_cuOff_only) ( TyEnt* te1, TyEnt* te2 );
+Word ML_(TyEnt__cmp_by_cuOff_only) ( const TyEnt* te1, const TyEnt* te2 );
 
 /* Generates a total ordering on TyEnts based on everything except
    their .cuOff fields. */
-Word ML_(TyEnt__cmp_by_all_except_cuOff) ( TyEnt* te1, TyEnt* te2 );
+Word ML_(TyEnt__cmp_by_all_except_cuOff) ( const TyEnt* te1, const TyEnt* te2 );
 
 /* Free up all directly or indirectly heap-allocated stuff attached to
    this TyEnt, and set its tag to Te_EMPTY.  The .cuOff field is
index 7cb2380f9d20f8da28e6b1bba2f755b2444f9fc6..e5471706fdf77c927255ee3017430d6284d9f534 100644 (file)
@@ -370,7 +370,7 @@ Word process_extended_line_op( struct _DebugInfo* di,
          if (state_machine_regs.is_stmt) {
             if (state_machine_regs.last_address) {
                Bool inRange = False;
-               HChar* filename
+               const HChar* filename
                   = (HChar*)index_WordArray( &inRange, filenames, 
                                              state_machine_regs.last_file);
                if (!inRange || !filename)
@@ -2734,7 +2734,7 @@ static Int dwarfexpr_to_dag ( UnwindContext* ctx,
    UWord    uw;
    CfiUnop  uop;
    CfiBinop bop;
-   HChar*   opname;
+   const HChar* opname;
 
    Int sp; /* # of top element: valid is -1 .. N_EXPR_STACK-1 */
    Int stack[N_EXPR_STACK];  /* indices into ctx->exprs */
@@ -3737,7 +3737,7 @@ void ML_(read_callframe_info_dwarf3)
           Bool is_ehframe )
 {
    Int    nbytes;
-   HChar* how = NULL;
+   const HChar* how = NULL;
    Int    n_CIEs = 0;
    UChar* data = frame_image;
    UWord  cfsi_used_orig;
index 7e924aa06708d7636ddbfc49706b4c392d7217bc..ee79a165730718b9f1d58bd20f61a86bcea18224 100644 (file)
@@ -169,8 +169,8 @@ typedef
       UChar* region_start_img;
       UWord  region_szB;
       UWord  region_next;
-      void (*barf)( HChar* ) __attribute__((noreturn));
-      HChar* barfstr;
+      void (*barf)( const HChar* ) __attribute__((noreturn));
+      const HChar* barfstr;
    }
    Cursor;
 
@@ -185,8 +185,8 @@ static void init_Cursor ( Cursor* c,
                           UChar*  region_start_img,
                           UWord   region_szB,
                           UWord   region_next,
-                          __attribute__((noreturn)) void (*barf)( HChar* ),
-                          HChar*  barfstr )
+                          __attribute__((noreturn)) void (*barf)( const HChar* ),
+                          const HChar* barfstr )
 {
    vg_assert(c);
    VG_(memset)(c, 0, sizeof(*c));
@@ -343,7 +343,7 @@ static UWord get_UWord ( Cursor* c ) {
 /* Read a DWARF3 'Initial Length' field */
 static ULong get_Initial_Length ( /*OUT*/Bool* is64,
                                   Cursor* c, 
-                                  HChar* barfMsg )
+                                  const HChar* barfMsg )
 {
    ULong w64;
    UInt  w32;
@@ -377,7 +377,7 @@ static ULong get_Initial_Length ( /*OUT*/Bool* is64,
 typedef
    struct {
       /* Call here if anything goes wrong */
-      void (*barf)( HChar* ) __attribute__((noreturn));
+      void (*barf)( const HChar* ) __attribute__((noreturn));
       /* Is this 64-bit DWARF ? */
       Bool   is_dw64;
       /* Which DWARF version ?  (2, 3 or 4) */
@@ -1045,7 +1045,7 @@ static void record_signatured_type ( VgHashTable tab,
    BARF.  */
 static UWord lookup_signatured_type ( VgHashTable tab,
                                       ULong type_signature,
-                                      void (*barf)( HChar* ) __attribute__((noreturn)) )
+                                      void (*barf)( const HChar* ) __attribute__((noreturn)) )
 {
    D3SignatureType *dstype = VG_(HT_lookup) ( tab, (UWord) type_signature );
    /* This may be unwarranted chumminess with the hash table
@@ -1439,7 +1439,7 @@ typedef
    }
    D3VarParser;
 
-static void varstack_show ( D3VarParser* parser, HChar* str ) {
+static void varstack_show ( D3VarParser* parser, const HChar* str ) {
    Word i, j;
    VG_(printf)("  varstack (%s) {\n", str);
    for (i = 0; i <= parser->sp; i++) {
@@ -2164,7 +2164,7 @@ typedef
    }
    D3TypeParser;
 
-static void typestack_show ( D3TypeParser* parser, HChar* str ) {
+static void typestack_show ( D3TypeParser* parser, const HChar* str ) {
    Word i;
    VG_(printf)("  typestack (%s) {\n", str);
    for (i = 0; i <= parser->sp; i++) {
@@ -3292,10 +3292,7 @@ void dedup_types ( Bool td3,
 
    /* First we must sort .ents by its .cuOff fields, so we
       can index into it. */
-   VG_(setCmpFnXA)(
-      ents,
-      (Int(*)(void*,void*)) ML_(TyEnt__cmp_by_cuOff_only)
-   );
+   VG_(setCmpFnXA)( ents, (XACmpFn_t) ML_(TyEnt__cmp_by_cuOff_only) );
    VG_(sortXA)( ents );
 
    /* Now repeatedly do commoning and substitution passes over
@@ -3344,7 +3341,7 @@ void dedup_types ( Bool td3,
 
 __attribute__((noinline))
 static void resolve_variable_types (
-               void (*barf)( HChar* ) __attribute__((noreturn)),
+               void (*barf)( const HChar* ) __attribute__((noreturn)),
                /*R-O*/XArray* /* of TyEnt */ ents,
                /*MOD*/TyEntIndexCache* ents_cache,
                /*MOD*/XArray* /* of TempVar* */ vars
@@ -3396,9 +3393,9 @@ static void resolve_variable_types (
 /*---                                                      ---*/
 /*------------------------------------------------------------*/
 
-static Int cmp_TempVar_by_dioff ( void* v1, void* v2 ) {
-   TempVar* t1 = *(TempVar**)v1;
-   TempVar* t2 = *(TempVar**)v2;
+static Int cmp_TempVar_by_dioff ( const void* v1, const void* v2 ) {
+   const TempVar* t1 = *(const TempVar**)v1;
+   const TempVar* t2 = *(const TempVar**)v2;
    if (t1->dioff < t2->dioff) return -1;
    if (t1->dioff > t2->dioff) return 1;
    return 0;
@@ -3518,7 +3515,7 @@ static void read_DIE (
 static
 void new_dwarf3_reader_wrk ( 
    struct _DebugInfo* di,
-   __attribute__((noreturn)) void (*barf)( HChar* ),
+   __attribute__((noreturn)) void (*barf)( const HChar* ),
    UChar* debug_info_img,   SizeT debug_info_sz,
    UChar* debug_types_img,  SizeT debug_types_sz,
    UChar* debug_abbv_img,   SizeT debug_abbv_sz,
@@ -4048,10 +4045,7 @@ void new_dwarf3_reader_wrk (
       minor) waste of time, since tyents itself is sorted, but
       necessary since VG_(lookupXA) refuses to cooperate if we
       don't. */
-   VG_(setCmpFnXA)(
-      tyents_to_keep,
-      (Int(*)(void*,void*)) ML_(TyEnt__cmp_by_cuOff_only)
-   );
+   VG_(setCmpFnXA)( tyents_to_keep, (XACmpFn_t) ML_(TyEnt__cmp_by_cuOff_only) );
    VG_(sortXA)( tyents_to_keep );
 
    /* Enable cacheing on tyents_to_keep */
@@ -4337,10 +4331,10 @@ void new_dwarf3_reader_wrk (
 /*------------------------------------------------------------*/
 
 static Bool               d3rd_jmpbuf_valid  = False;
-static HChar*             d3rd_jmpbuf_reason = NULL;
+static const HChar*       d3rd_jmpbuf_reason = NULL;
 static VG_MINIMAL_JMP_BUF(d3rd_jmpbuf);
 
-static __attribute__((noreturn)) void barf ( HChar* reason ) {
+static __attribute__((noreturn)) void barf ( const HChar* reason ) {
    vg_assert(d3rd_jmpbuf_valid);
    d3rd_jmpbuf_reason = reason;
    VG_MINIMAL_LONGJMP(d3rd_jmpbuf);
index 6e022a5f4eb76e1fc77e5d154384b2bb61653dd6..1d046805bdaf37b9b331b9a31a5ee27d1a678560 100644 (file)
@@ -149,7 +149,7 @@ void show_raw_elf_symbol ( Int i,
                            ElfXX_Sym* sym, const HChar* sym_name, Addr sym_svma,
                            Bool ppc64_linux_format )
 {
-   HChar* space = ppc64_linux_format ? "                  " : "";
+   const HChar* space = ppc64_linux_format ? "                  " : "";
    VG_(printf)("raw symbol [%4d]: ", i);
    switch (ELFXX_ST_BIND(sym->st_info)) {
       case STB_LOCAL:  VG_(printf)("LOC "); break;
index ada70e4320bd92274c13e792d825395a79f74dc2..cf542855d5708fa9cf4d11cd6872672284ed1512 100644 (file)
@@ -1800,13 +1800,14 @@ static ULong codeview_dump_linetab2(
 /*---                                                      ---*/
 /*------------------------------------------------------------*/
 
-static Int cmp_FPO_DATA_for_canonicalisation ( void* f1V, void* f2V )
+static Int cmp_FPO_DATA_for_canonicalisation ( const void* f1V,
+                                               const void* f2V )
 {
    /* Cause FPO data to be sorted first in ascending order of range
       starts, and for entries with the same range start, with the
       shorter range (length) first. */
-   FPO_DATA* f1 = (FPO_DATA*)f1V;
-   FPO_DATA* f2 = (FPO_DATA*)f2V;
+   const FPO_DATA* f1 = f1V;
+   const FPO_DATA* f2 = f2V;
    if (f1->ulOffStart < f2->ulOffStart) return -1;
    if (f1->ulOffStart > f2->ulOffStart) return  1;
    if (f1->cbProcSize < f2->cbProcSize) return -1;
@@ -2428,9 +2429,9 @@ HChar* ML_(find_name_of_pdb_file)( HChar* pename )
    /* Make up the command to run, essentially:
       sh -c "strings (pename) | egrep '\.pdb|\.PDB' > (tmpname)"
    */
-   HChar* sh      = "/bin/sh";
-   HChar* strings = "/usr/bin/strings";
-   HChar* egrep   = "/usr/bin/egrep";
+   const HChar* sh      = "/bin/sh";
+   const HChar* strings = "/usr/bin/strings";
+   const HChar* egrep   = "/usr/bin/egrep";
 
    /* (sh) -c "(strings) (pename) | (egrep) 'pdb' > (tmpname) */
    Int cmdlen = VG_(strlen)(strings) + VG_(strlen)(pename)
index 840753ef4fa33a616a142d9fecdbdd77ed71bc56..f344c8f70e6b9a629264c699779a95b4de45d2a7 100644 (file)
@@ -59,7 +59,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, HChar* msg )
+void ML_(symerr) ( struct _DebugInfo* di, Bool serious, const HChar* msg )
 {
    /* XML mode hides everything :-( */
    if (VG_(clo_xml))
@@ -215,7 +215,7 @@ void ML_(ppDiCfSI) ( XArray* /* of CfiExpr */ exprs, DiCfSI* si )
    a chunking memory allocator rather than reallocating, so the
    pointers are stable.
 */
-HChar* ML_(addStr) ( struct _DebugInfo* di, HChar* str, Int len )
+HChar* ML_(addStr) ( struct _DebugInfo* di, const HChar* str, Int len )
 {
    struct strchunk *chunk;
    Int    space_needed;
@@ -725,7 +725,7 @@ Word ML_(cmp_for_DiAddrRange_range) ( const void* keyV,
 }
 
 static
-void show_scope ( OSet* /* of DiAddrRange */ scope, HChar* who )
+void show_scope ( OSet* /* of DiAddrRange */ scope, const HChar* who )
 {
    DiAddrRange* range;
    VG_(printf)("Scope \"%s\" = {\n", who);
@@ -910,7 +910,7 @@ void ML_(addVar)( struct _DebugInfo* di,
    Bool       all;
    TyEnt*     ent;
    MaybeULong mul;
-   HChar*     badness;
+   const HChar* badness;
 
    tl_assert(di && di->admin_tyents);
 
@@ -1131,10 +1131,10 @@ static void canonicaliseVarInfo ( struct _DebugInfo* di )
    facilitates using binary search to map addresses to symbols when we
    come to query the table.
 */
-static Int compare_DiSym ( void* va, void* vb ) 
+static Int compare_DiSym ( const void* va, const void* vb ) 
 {
-   DiSym* a = (DiSym*)va;
-   DiSym* b = (DiSym*)vb;
+   const DiSym* a = va;
+   const DiSym* b = vb;
    if (a->addr < b->addr) return -1;
    if (a->addr > b->addr) return  1;
    return 0;
@@ -1608,10 +1608,10 @@ static void canonicaliseSymtab ( struct _DebugInfo* di )
    ranges do not overlap.  This facilitates using binary search to map
    addresses to locations when we come to query the table.
 */
-static Int compare_DiLoc ( void* va, void* vb ) 
+static Int compare_DiLoc ( const void* va, const void* vb ) 
 {
-   DiLoc* a = (DiLoc*)va;
-   DiLoc* b = (DiLoc*)vb;
+   const DiLoc* a = va;
+   const DiLoc* b = vb;
    if (a->addr < b->addr) return -1;
    if (a->addr > b->addr) return  1;
    return 0;
@@ -1694,10 +1694,10 @@ static void canonicaliseLoctab ( struct _DebugInfo* di )
    as to facilitate rapidly skipping this SegInfo when looking for an
    address which falls outside that range.
 */
-static Int compare_DiCfSI ( void* va, void* vb )
+static Int compare_DiCfSI ( const void* va, const void* vb )
 {
-   DiCfSI* a = (DiCfSI*)va;
-   DiCfSI* b = (DiCfSI*)vb;
+   const DiCfSI* a = va;
+   const DiCfSI* b = vb;
    if (a->base < b->base) return -1;
    if (a->base > b->base) return  1;
    return 0;
index 95b391cd5bf89e79b7fb16235b4d48c830aad68c..9fcda784014a298b80c1d4225be6130f3befaa56 100644 (file)
@@ -198,7 +198,7 @@ void ML_(pp_TyEnt)( TyEnt* te )
 
 /* Print a whole XArray of TyEnts, debug-style */
 
-void ML_(pp_TyEnts)( XArray* tyents, HChar* who )
+void ML_(pp_TyEnts)( XArray* tyents, const HChar* who )
 {
    Word i, n;
    VG_(printf)("------ %s ------\n", who);
@@ -410,7 +410,7 @@ TyEnt* ML_(TyEnts__index_by_cuOff) ( XArray* /* of TyEnt */ ents,
 /* Generates a total ordering on TyEnts based only on their .cuOff
    fields. */
 
-Word ML_(TyEnt__cmp_by_cuOff_only) ( TyEnt* te1, TyEnt* te2 )
+Word ML_(TyEnt__cmp_by_cuOff_only) ( const TyEnt* te1, const TyEnt* te2 )
 {
    if (te1->cuOff < te2->cuOff) return -1;
    if (te1->cuOff > te2->cuOff) return 1;
@@ -477,7 +477,7 @@ static Word Asciiz__cmp ( const HChar* a, const HChar* b ) {
    return VG_(strcmp)(a, b);
 }
 
-Word ML_(TyEnt__cmp_by_all_except_cuOff) ( TyEnt* te1, TyEnt* te2 )
+Word ML_(TyEnt__cmp_by_all_except_cuOff) ( const TyEnt* te1, const TyEnt* te2 )
 {
    Word r;
    if (te1->tag < te2->tag) return -1;
index 37eb7a5c6e1f08e9ccfd7e96bb4a82286fe60c75..3c6025e2b0294bcfad35ccbdf1eec6d09d78bbe7 100644 (file)
@@ -762,14 +762,14 @@ VG_(debugLog_vprintf) (
                i++;
                /* %pS, like %s but escaping chars for XML safety */
                /* Note: simplistic; ignores field width and flags */
-               HChar *str = va_arg (vargs, HChar *);
+               const HChar *str = va_arg (vargs, HChar *);
                if (str == NULL)
                   str = "(null)";
                ret += myvprintf_str_XML_simplistic(send, send_arg2, str);
             } else if (format[i+1] == 's') {
                i++;
                /* %ps, synonym for %s with --xml=no / %pS with --xml=yes */
-               HChar *str = va_arg (vargs, HChar *);
+               const HChar *str = va_arg (vargs, HChar *);
                if (str == NULL)
                   str = "(null)";
                if (clo_xml)
@@ -806,7 +806,7 @@ VG_(debugLog_vprintf) (
             send(va_arg (vargs, int), send_arg2);
             break;
          case 's': case 'S': { /* %s */
-            HChar *str = va_arg (vargs, HChar *);
+            const HChar *str = va_arg (vargs, HChar *);
             if (str == NULL) str = "(null)";
             ret += myvprintf_str(send, send_arg2, 
                                  flags, width, str, format[i]=='S');
index c7b77f3fafc06db6b6281146135d66ec1bcdd107..57aeefe8271b98923d2ef69cc2b9c1ba17ddb0a0 100644 (file)
@@ -1269,7 +1269,8 @@ UInt VG_(gdb_printf) ( const HChar *format, ... )
    return b.ret;
 }
 
-Int VG_(keyword_id) (HChar* keywords, HChar* input_word, kwd_report_error report)
+Int VG_(keyword_id) (const HChar* keywords, const HChar* input_word,
+                     kwd_report_error report)
 {
    const Int il = (input_word == NULL ? 0 : VG_(strlen) (input_word));
    HChar  iw[il+1];
index e9744594ee6f20d49f47a1529cf53b9870448df7..146079c1e1dc1682328a485858b8a34a61388bf5 100644 (file)
@@ -25,7 +25,7 @@
 struct reg
 {
   /* The name of this register - NULL for pad entries.  */
-  char *name;
+  const char *name;
 
   /* At the moment, both of the following bit counts must be divisible
      by eight (to match the representation as two hex digits) and divisible
index 2e6efa6368805e31960e75d17d7bb2a32c896088..a08aef7e975024f8be889c9c15a25c82e0d5f63a 100644 (file)
@@ -59,7 +59,7 @@ static char *to_gdb = NULL;
 static char *shared_mem = NULL;
 
 static
-int open_fifo (char *side, char *path, int flags)
+int open_fifo (const char *side, const char *path, int flags)
 {
   SysRes o;
   int fd;
@@ -91,7 +91,7 @@ void remote_utils_output_status(void)
 /* Returns 0 if vgdb and connection state looks good,
    otherwise returns an int value telling which check failed. */
 static
-int vgdb_state_looks_bad(char* where)
+int vgdb_state_looks_bad(const char* where)
 {
    if (VG_(kill)(shared->vgdb_pid, 0) != 0)
       return 1; // vgdb process does not exist anymore.
@@ -114,7 +114,7 @@ void set_ptracer(void)
 {
 #ifdef PR_SET_PTRACER
    SysRes o;
-   char *ptrace_scope_setting_file = "/proc/sys/kernel/yama/ptrace_scope";
+   const char *ptrace_scope_setting_file = "/proc/sys/kernel/yama/ptrace_scope";
    int fd;
    char ptrace_scope;
    int ret;
@@ -362,7 +362,7 @@ void sync_gdb_connection(void)
 }
 
 static
-char * ppFinishReason (FinishReason reason)
+const char * ppFinishReason (FinishReason reason)
 {
    switch (reason) {
    case orderly_finish:    return "orderly_finish";
@@ -438,7 +438,7 @@ void error_poll_cond(void)
    gives a small value to --vgdb-poll. So, the function avoids
    doing repetitively system calls by rather looking at the
    counter values maintained in shared memory by vgdb. */
-int remote_desc_activity(char *msg)
+int remote_desc_activity(const char *msg)
 {
    int ret;
    const int looking_at = shared->written_by_vgdb;
index 1d6ff8a6c038c5748e8b8beb2f547026de150361..1e9ee301bc36d7e2e93927f24699725f3a79811b 100644 (file)
@@ -53,7 +53,7 @@ VG_MINIMAL_JMP_BUF(toplevel);
    or -1 otherwise.  */
 
 static
-int decode_xfer_read (char *buf, char **annex, CORE_ADDR *ofs, unsigned int *len)
+int decode_xfer_read (char *buf, const char **annex, CORE_ADDR *ofs, unsigned int *len)
 {
    /* Extract and NUL-terminate the annex.  */
    *annex = buf;
@@ -95,7 +95,7 @@ static OutputSink initial_valgrind_sink;
 static Bool command_output_to_log = False;
 /* True <=> command output goes to log instead of gdb */
 
-void reset_valgrind_sink(char *info)
+void reset_valgrind_sink(const char *info)
 {
    if (VG_(log_output_sink).fd != initial_valgrind_sink.fd
        && initial_valgrind_sink_saved) {
@@ -106,7 +106,7 @@ void reset_valgrind_sink(char *info)
 }
 
 static
-void kill_request (char *msg)
+void kill_request (const char *msg)
 {
    VG_(umsg) ("%s", msg);
    remote_close();
@@ -127,7 +127,7 @@ int handle_gdb_valgrind_command (char* mon, OutputSink* sink_wanted_at_return)
    char s[strlen(mon)+1]; /* copy for strtok_r */
    char* wcmd;
    HChar* ssaveptr;
-   char* endptr;
+   const char* endptr;
    int   kwdid;
    int int_value;
 
@@ -200,7 +200,9 @@ int handle_gdb_valgrind_command (char* mon, OutputSink* sink_wanted_at_return)
             int_value = 0;
             endptr = "empty"; /* to report an error below */
          } else {
-            int_value = strtol (wcmd, &endptr, 10);
+            HChar *the_end;
+            int_value = strtol (wcmd, &the_end, 10);
+            endptr = the_end;
          }
          if (*endptr != '\0') {
             VG_(gdb_printf) ("missing or malformed integer value\n");
@@ -301,7 +303,7 @@ int handle_gdb_valgrind_command (char* mon, OutputSink* sink_wanted_at_return)
    case  3: /* v.wait */
       wcmd = strtok_r (NULL, " ", &ssaveptr);
       if (wcmd != NULL) {
-         int_value = strtol (wcmd, &endptr, 10);
+         int_value = strtol (wcmd, NULL, 10);
          VG_(gdb_printf) ("gdbserver: continuing in %d ms ...\n", int_value);
          VG_(poll)(NULL, 0, int_value);
       }
@@ -547,7 +549,7 @@ void handle_query (char *arg_own_buf, int *new_packet_len_p)
         && strncmp ("qXfer:features:read:", arg_own_buf, 20) == 0) {
       CORE_ADDR ofs;
       unsigned int len, doc_len;
-      char *annex = NULL;
+      const char *annex = NULL;
       // First, the annex is extracted from the packet received.
       // Then, it is replaced by the corresponding file name.
       int fd;
@@ -611,7 +613,7 @@ void handle_query (char *arg_own_buf, int *new_packet_len_p)
       int n;
       CORE_ADDR ofs;
       unsigned int len;
-      char *annex;
+      const char *annex;
 
       /* Reject any annex; grab the offset and length.  */
       if (decode_xfer_read (arg_own_buf + 16, &annex, &ofs, &len) < 0
index 6686c194683aef5d1c06f507ea7b3abe3cbe49e2..d0d8a9f0dd86a2f75d9f132d74931296342dcd14 100644 (file)
@@ -76,7 +76,7 @@ extern void monitor_output (char *s);
    returns 2 if remote_desc_activity detected the connection has been
              lost and should be reopened.
    msg is used for debug logging.*/
-extern int remote_desc_activity(char *msg);
+extern int remote_desc_activity(const char *msg);
 
 /* output some status of gdbserver communication */
 extern void remote_utils_output_status(void);
@@ -92,7 +92,7 @@ extern void remote_finish(FinishReason reason);
 /* If Valgrind sink was changed by gdbserver:
       Resets the valgrind sink to before the changes done by gdbserver,
       and does VG_(umsg). If info != NULL, info added in VG_(usmg). */
-extern void reset_valgrind_sink(char* info);
+extern void reset_valgrind_sink(const char* info);
 
 /* For ARM usage.
    Guesses if pc is a thumb pc.
@@ -312,14 +312,14 @@ int remote_escape_output (const gdb_byte *buffer, int len,
 enum target_signal target_signal_from_host (int hostsig);
 int target_signal_to_host_p (enum target_signal oursig);
 int target_signal_to_host (enum target_signal oursig);
-char *target_signal_to_name (enum target_signal);
+const char *target_signal_to_name (enum target_signal);
 
 /* Functions from utils.c */
 
 /* error is like VG_(umsg), then VG_MINIMAL_LONGJMP to gdbserver toplevel. */
 void error (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
 /* first output a description of the error inside sr, then like VG_(umsg). */
-void sr_perror (SysRes sr,char *string,...) ATTR_FORMAT (printf, 2, 3);
+void sr_perror (SysRes sr,const char *string,...) ATTR_FORMAT (printf, 2, 3);
 /* fatal is like VG_(umsg), then exit(1). */
 void fatal (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
 /* warning is like VG_(umsg). */
index ee60ccd4e7fce7e066f2438b3c5fbddd2c5381cb..69aa9b183a080de127e6a107839249bace77f2fb 100644 (file)
 #endif
 #endif
 
-enum target_signal target_signal_from_name (char *name);
+enum target_signal target_signal_from_name (const char *name);
 enum target_signal target_signal_from_command (int num);
 
 /* This table must match in order and size the signals in enum target_signal
    in gdb/signals.h. */
 /* *INDENT-OFF* */
 static struct {
-   char *name;
-   char *string;
+   const char *name;
+   const char *string;
 } signals [] =
    {
       {"0", "Signal 0"},
@@ -205,7 +205,7 @@ static struct {
 
 
 /* Return the name for a signal.  */
-char *target_signal_to_name (enum target_signal sig)
+const char *target_signal_to_name (enum target_signal sig)
 {
    if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST)
        && signals[sig].name != NULL)
@@ -217,7 +217,7 @@ char *target_signal_to_name (enum target_signal sig)
 }
 
 /* Given a name, return its signal.  */
-enum target_signal target_signal_from_name (char *name)
+enum target_signal target_signal_from_name (const char *name)
 {
    enum target_signal sig;
 
index 62e1b857317ae6ed8d12a203b22e7aa6644f3930..7c95ecde1afdb0bd5413d0456c7799d914b7f589 100644 (file)
@@ -102,16 +102,17 @@ void valgrind_update_threads (int pid)
 static
 struct reg* build_shadow_arch (struct reg *reg_defs, int n) {
    int i, r;
-   static char *postfix[3] = { "", "s1", "s2" };
+   static const char *postfix[3] = { "", "s1", "s2" };
    struct reg *new_regs = malloc(3 * n * sizeof(reg_defs[0]));
    int reg_set_len = reg_defs[n-1].offset + reg_defs[n-1].size;
 
    for (i = 0; i < 3; i++) {
       for (r = 0; r < n; r++) {
-         new_regs[i*n + r].name = malloc(strlen(reg_defs[r].name) 
-                                         + strlen (postfix[i]) + 1);
-         strcpy (new_regs[i*n + r].name, reg_defs[r].name);
-         strcat (new_regs[i*n + r].name, postfix[i]);
+         char *regname = malloc(strlen(reg_defs[r].name) 
+                                + strlen (postfix[i]) + 1);
+         strcpy (regname, reg_defs[r].name);
+         strcat (regname, postfix[i]);
+         new_regs[i*n + r].name = regname;
          new_regs[i*n + r].offset = i*reg_set_len + reg_defs[r].offset;
          new_regs[i*n + r].size = reg_defs[r].size;
          dlog(1,
@@ -519,7 +520,7 @@ int valgrind_point (Bool insert, char type, CORE_ADDR addr, int len)
       return 1; /* error or unsupported */
 }
 
-char* valgrind_target_xml (Bool shadow_mode)
+const char* valgrind_target_xml (Bool shadow_mode)
 {
    return (*the_low_target.target_xml) (shadow_mode);
 }
index 2cd41fd918d745aead4c54e679a293604ec797da..2d4949cb079b61f27d43e0ec77fc5a19a89fc6c0 100644 (file)
@@ -63,7 +63,7 @@ extern void initialize_shadow_low (Bool shadow_mode);
    with the shadow registers
    else returns the xml target description only for
    the normal registers. */
-extern char* valgrind_target_xml (Bool shadow_mode);
+extern const char* valgrind_target_xml (Bool shadow_mode);
 
 
 /* -------------------------------------------------------------------------- */
index 57db1751f6fec241dce4cd3763d42b70c7659d87..511b1e60570743c64fcce8680c473058c5b529c5 100644 (file)
@@ -26,7 +26,7 @@
 
 /* Print the system error message for sr.
    Then print the rest of the args. */
-void sr_perror (SysRes sr,char *string,...)
+void sr_perror (SysRes sr, const char *string,...)
 {
    va_list args;
    if (sr_isError (sr))
index 7de55a0a35ce689941ef63cb877c250fa69f6e33..b8164518b15076c1e4105662c17e65720e2d029b 100644 (file)
@@ -316,7 +316,7 @@ Bool have_avx(void)
    return (vai.hwcaps & VEX_HWCAPS_AMD64_AVX ? True : False);
 }
 static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
 {
    if (shadow_mode) {
 #if defined(VGO_linux)
index e7ac5f079f877c16a4ea0e8bcfbb2a2481bfbe0d..b14084a2bcc6871b0cbd4e87634e8a0813b6b2e6 100644 (file)
@@ -278,7 +278,7 @@ void transfer_register (ThreadId tid, int abs_regno, void * buf,
 }
 
 static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
 {
    if (shadow_mode) {
       return "arm-with-vfpv3-valgrind.xml";
index cf2d6034485befebe549e1b7c4bb8717d3531fec..b6b6491bb92ef1aeb97acb056969bdf58d2451ed 100644 (file)
@@ -230,7 +230,7 @@ void transfer_register (ThreadId tid, int abs_regno, void * buf,
 }
 
 static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
 {
    if (shadow_mode) {
       return "mips-linux-valgrind.xml";
index 9f2f36e3ad225b08aedb6cb9a075c626846f5628..ba4ae8fc4c9b807191a723b430ab2058942a0ad3 100644 (file)
@@ -323,7 +323,7 @@ void transfer_register (ThreadId tid, int abs_regno, void * buf,
 }
 
 static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
 {
    if (shadow_mode) {
       return "powerpc-altivec32l-valgrind.xml";
index 9b1a3587b47dc8adc5d227a967af11451aa0dee3..a516d209b720cac41911f9eecf398f33d9602431 100644 (file)
@@ -320,7 +320,7 @@ void transfer_register (ThreadId tid, int abs_regno, void * buf,
 }
 
 static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
 {
    if (shadow_mode) {
       return "powerpc-altivec64l-valgrind.xml";
index 017a402099301200cb35f827dacd651d98927af4..6909e4c9c445a85694c080a2f1f68c535b868f73 100644 (file)
@@ -188,7 +188,7 @@ void transfer_register (ThreadId tid, int abs_regno, void * buf,
 }
 
 static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
 {
    if (shadow_mode) {
       return "s390x-generic-valgrind.xml";
index 50d31931937a8a2ef3b1d0b2fa5e1072bb066d17..fc533f7f870b197289799bd1ac664a287bd46898 100644 (file)
@@ -244,7 +244,7 @@ void transfer_register (ThreadId tid, int abs_regno, void * buf,
 }
 
 static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
 {
    if (shadow_mode) {
 #if defined(VGO_linux)
index 4a8e1dc4afebe97bf05480e703b1f6c50cb4e90f..3ff6d19c403def2ca12338ae65d9c097d6aa0697 100644 (file)
@@ -63,7 +63,7 @@ struct valgrind_target_ops
       including the two shadow registers sets.
       This is mandatory to use the option --vgdb-shadow-registers=yes. 
       Returns NULL if there is no target xml file*/
-   char* (*target_xml) (Bool shadow_mode);
+   const char* (*target_xml) (Bool shadow_mode);
 
 };
 
index fc6df6caa2de180d8c34bd3ff577576eb6090be9..3567882affa5d0defae5c67370147fbf31fe715d 100644 (file)
@@ -672,7 +672,7 @@ Int VG_(memcmp) ( const void* s1, const void* s2, SizeT n )
       pv = (Char*)&v, v = *(Word*)pm
 
 static Char* bm_med3 ( Char* a, Char* b, Char* c, 
-                       Int (*cmp)(void*,void*) ) {
+                       Int (*cmp)(const void*, const void*) ) {
    return cmp(a, b) < 0
           ? (cmp(b, c) < 0 ? b : cmp(a, c) < 0 ? c : a)
           : (cmp(b, c) > 0 ? b : cmp(a, c) > 0 ? c : a);
@@ -693,7 +693,7 @@ static void bm_swapfunc ( Char* a, Char* b, SizeT n, Int swaptype )
 }
 
 static void bm_qsort ( Char* a, SizeT n, SizeT es,
-                       Int (*cmp)(void*,void*) )
+                       Int (*cmp)(const void*, const void*) )
 {
    Char  *pa, *pb, *pc, *pd, *pl, *pm, *pn, *pv;
    Int   r, swaptype;
@@ -802,7 +802,7 @@ Int VG_(log2_64) ( ULong x )
 
 // Generic quick sort.
 void VG_(ssort)( void* base, SizeT nmemb, SizeT size,
-                 Int (*compar)(void*, void*) )
+                 Int (*compar)(const void*, const void*) )
 {
    bm_qsort(base,nmemb,size,compar);
 }
index a4f6d1be2d4a73352fc9b515c845876235161fa7..2e8ebca80602c082ab4d3fbc80fc6b3cfb0a59ae 100644 (file)
@@ -1054,7 +1054,7 @@ Int VG_(getsockopt) ( Int sd, Int level, Int optname, void *optval,
 }
 
 
-HChar *VG_(basename)(const HChar *path)
+const HChar *VG_(basename)(const HChar *path)
 {
    static HChar buf[VKI_PATH_MAX];
    
@@ -1090,7 +1090,7 @@ HChar *VG_(basename)(const HChar *path)
 }
 
 
-HChar *VG_(dirname)(const HChar *path)
+const HChar *VG_(dirname)(const HChar *path)
 {
    static HChar buf[VKI_PATH_MAX];
     
index e1396e22ed0fa6b0b79750c25bf4b6708619accc..85f20ef299386e04f2f3525c3262dc59babab0ba 100644 (file)
@@ -198,7 +198,8 @@ VG_(set_shadow_regs_area) ( ThreadId tid,
 }
 
 
-static void apply_to_GPs_of_tid(ThreadId tid, void (*f)(ThreadId, HChar*, Addr))
+static void apply_to_GPs_of_tid(ThreadId tid, void (*f)(ThreadId,
+                                                        const HChar*, Addr))
 {
    VexGuestArchState* vex = &(VG_(get_ThreadState)(tid)->arch.vex);
 #if defined(VGA_x86)
@@ -333,7 +334,7 @@ static void apply_to_GPs_of_tid(ThreadId tid, void (*f)(ThreadId, HChar*, Addr))
 }
 
 
-void VG_(apply_to_GP_regs)(void (*f)(ThreadId, HChar*, UWord))
+void VG_(apply_to_GP_regs)(void (*f)(ThreadId, const HChar*, UWord))
 {
    ThreadId tid;
 
index 31e04570730ef4447cb694d8bcab1098e7a6e12c..dae95011c3574578aef479b070dff08d0d3a98fd 100644 (file)
@@ -1161,8 +1161,8 @@ static void print_preamble ( Bool logging_to_fd,
                              const HChar* toolname )
 {
    Int    i;
-   HChar* xpre  = VG_(clo_xml) ? "  <line>" : "";
-   HChar* xpost = VG_(clo_xml) ? "</line>" : "";
+   const HChar* xpre  = VG_(clo_xml) ? "  <line>" : "";
+   const HChar* xpost = VG_(clo_xml) ? "</line>" : "";
    UInt (*umsg_or_xml)( const HChar*, ... )
       = VG_(clo_xml) ? VG_(printf_xml) : VG_(umsg);
 
index 2ed53b6b0e16f6625c9317d524eaa0d994b7ba8b..7f19e8c47e92b0b1785756d6d11e8d0775424228 100644 (file)
@@ -243,7 +243,7 @@ typedef
 
 #define SIZE_T_0x1      ((SizeT)0x1)
 
-static char* probably_your_fault =
+static const char* probably_your_fault =
    "This is probably caused by your program erroneously writing past the\n"
    "end of a heap block and corrupting heap metadata.  If you fix any\n"
    "invalid writes reported by Memcheck, this assertion failure will\n"
@@ -1280,7 +1280,7 @@ typedef struct {
 
 static AnCC anCCs[N_AN_CCS];
 
-static Int cmp_AnCC_by_vol ( void* v1, void* v2 ) {
+static Int cmp_AnCC_by_vol ( const void* v1, const void* v2 ) {
    AnCC* ancc1 = (AnCC*)v1;
    AnCC* ancc2 = (AnCC*)v2;
    if (ancc1->nBytes < ancc2->nBytes) return -1;
index dde527c1ff53a5c693b721ff0f2180421b5cb101..81f969e426e4bcb975dc7603dc963c40447f2501 100644 (file)
@@ -801,7 +801,7 @@ void generate_and_add_actives (
    }
    if (sp) {
       const HChar** strp;
-      HChar* v = "valgrind:  ";
+      const HChar* v = "valgrind:  ";
       vg_assert(sp->mark);
       vg_assert(!sp->done);
       vg_assert(sp->mandatory);
@@ -846,7 +846,7 @@ void generate_and_add_actives (
    conflicting bindings. */
 static void maybe_add_active ( Active act )
 {
-   HChar*  what    = NULL;
+   const HChar*  what = NULL;
    Active* old     = NULL;
    Bool    add_act = False;
 
@@ -1129,9 +1129,9 @@ static void add_hardwired_active ( Addr from, Addr to )
    entry that holds these initial specs. */
 
 __attribute__((unused)) /* not used on all platforms */
-static void add_hardwired_spec ( HChar* sopatt, HChar* fnpatt, 
-                                 Addr   to_addr,
-                                 const HChar** mandatory )
+static void add_hardwired_spec (const  HChar* sopatt, const HChar* fnpatt, 
+                                Addr   to_addr,
+                                const HChar** mandatory )
 {
    Spec* spec = dinfo_zalloc("redir.ahs.1", sizeof(Spec));
    vg_assert(spec);
@@ -1146,8 +1146,8 @@ static void add_hardwired_spec ( HChar* sopatt, HChar* fnpatt,
    vg_assert(topSpecs->next == NULL);
    vg_assert(topSpecs->seginfo == NULL);
    /* FIXED PARTS */
-   spec->from_sopatt = sopatt;
-   spec->from_fnpatt = fnpatt;
+   spec->from_sopatt = (HChar *)sopatt;
+   spec->from_fnpatt = (HChar *)fnpatt;
    spec->to_addr     = to_addr;
    spec->isWrap      = False;
    spec->mandatory   = mandatory;
@@ -1544,7 +1544,7 @@ static void handle_require_text_symbols ( DebugInfo* di )
       }
 
       if (!found) {
-         HChar* v = "valgrind:  ";
+         const HChar* v = "valgrind:  ";
          VG_(printf)("\n");
          VG_(printf)(
          "%sFatal error at when loading library with soname\n", v);
index 4fa9a9632220079812767b71b16a6d9fd478bee9..3ec73527a527abbe4db23619bfc80c79eaebee04 100644 (file)
@@ -71,7 +71,7 @@ static void bad_subop ( ThreadId              tid,
                         /*MOD*/SyscallArgs*   args,
                         /*OUT*/SyscallStatus* status,
                         /*OUT*/UWord*         flags,
-                        const char*           hypercall,
+                        const HChar*           hypercall,
                         UWord                 subop)
 {
    VG_(dmsg)("WARNING: unhandled %s subop: %ld\n",
@@ -107,7 +107,7 @@ PRE(memory_op)
    case VKI_XENMEM_populate_physmap: {
       struct xen_memory_reservation *memory_reservation =
          (struct xen_memory_reservation *)ARG2;
-      char *which;
+      const HChar *which;
 
       switch (ARG1) {
       case VKI_XENMEM_increase_reservation:
index 3f84b7fb0033b2a6dde777d41888019034c8b788..ed72041953d2bee1796600be2340c4e870ddc22c 100644 (file)
@@ -623,10 +623,10 @@ void OutEdgeArr__add ( OutEdgeArr* oea, OutEdge* oe )
 }
 
 static
-Int HostExtent__cmpOrd ( void* v1, void* v2 )
+Int HostExtent__cmpOrd ( const void* v1, const void* v2 )
 {
-   HostExtent* hx1 = (HostExtent*)v1;
-   HostExtent* hx2 = (HostExtent*)v2;
+   const HostExtent* hx1 = v1;
+   const HostExtent* hx2 = v2;
    if (hx1->start + hx1->len <= hx2->start) return -1;
    if (hx2->start + hx2->len <= hx1->start) return 1;
    return 0; /* partial overlap */
@@ -656,8 +656,7 @@ Bool find_TTEntry_from_hcode( /*OUT*/UInt* from_sNo,
       Word firstW = -1, lastW = -1;
       Bool found  = VG_(lookupXA_UNSAFE)(
                        host_extents, &key, &firstW, &lastW,
-                       (Int(*)(void*,void*))HostExtent__cmpOrd
-                    );
+                       HostExtent__cmpOrd );
       vg_assert(firstW == lastW); // always true, even if not found
       if (found) {
          HostExtent* hx = VG_(indexXA)(host_extents, firstW);
@@ -1044,7 +1043,7 @@ static Bool sanity_check_eclasses_in_sector ( Sector* sec )
 {
 #  define BAD(_str) do { whassup = (_str); goto bad; } while (0)
 
-   HChar*   whassup = NULL;
+   const HChar* whassup = NULL;
    Int      i, j, k, n, ec_num, ec_idx;
    TTEntry* tte;
    UShort   tteno;
index c784f90f4e65d1b59bfd0105d5a696c803b52556..e110dbd8ec016aaeb617c08f3697d9dc6a0e4499 100644 (file)
@@ -41,7 +41,7 @@ struct _XArray {
    void* (*alloc) ( const HChar*, SizeT ); /* alloc fn (nofail) */
    const HChar* cc;                 /* cost centre for alloc */
    void  (*free) ( void* );         /* free fn */
-   Int   (*cmpFn) ( void*, void* ); /* cmp fn (may be NULL) */
+   Int   (*cmpFn) ( const void*, const void* ); /* cmp fn (may be NULL) */
    Word  elemSzB;   /* element size in bytes */
    void* arr;       /* pointer to elements */
    Word  usedsizeE; /* # used elements in arr */
@@ -125,7 +125,7 @@ void VG_(deleteXA) ( XArray* xao )
    xa->free(xa);
 }
 
-void VG_(setCmpFnXA) ( XArray* xao, Int (*compar)(void*,void*) )
+void VG_(setCmpFnXA) ( XArray* xao, XACmpFn_t compar )
 {
    struct _XArray* xa = (struct _XArray*)xao;
    vg_assert(xa);
@@ -178,7 +178,7 @@ static inline void ensureSpaceXA ( struct _XArray* xa )
    }
 }
 
-Word VG_(addToXA) ( XArray* xao, void* elem )
+Word VG_(addToXA) ( XArray* xao, const void* elem )
 {
    struct _XArray* xa = (struct _XArray*)xao;
    vg_assert(xa);
@@ -195,7 +195,7 @@ Word VG_(addToXA) ( XArray* xao, void* elem )
    return xa->usedsizeE-1;
 }
 
-Word VG_(addBytesToXA) ( XArray* xao, void* bytesV, Word nbytes )
+Word VG_(addBytesToXA) ( XArray* xao, const void* bytesV, Word nbytes )
 {
    Word r, i;
    struct _XArray* xa = (struct _XArray*)xao;
@@ -225,9 +225,9 @@ void VG_(sortXA) ( XArray* xao )
    xa->sorted = True;
 }
 
-Bool VG_(lookupXA_UNSAFE) ( XArray* xao, void* key,
+Bool VG_(lookupXA_UNSAFE) ( XArray* xao, const void* key,
                             /*OUT*/Word* first, /*OUT*/Word* last,
-                            Int(*cmpFn)(void*,void*) )
+                            Int(*cmpFn)(const void*, const void*) )
 {
    Word  lo, mid, hi, cres;
    void* midv;
@@ -264,7 +264,7 @@ Bool VG_(lookupXA_UNSAFE) ( XArray* xao, void* key,
    }
 }
 
-Bool VG_(lookupXA) ( XArray* xao, void* key,
+Bool VG_(lookupXA) ( XArray* xao, const void* key,
                      /*OUT*/Word* first, /*OUT*/Word* last )
 {
    struct _XArray* xa = (struct _XArray*)xao;
index 732fbb37f9947e7f7923572d6cb6c63b76e7d1f8..95bcd5bffd8c30da2aff291c3367f563ebbe4256 100644 (file)
@@ -153,7 +153,8 @@ extern Addr VG_(get_tocptr) ( Addr guest_code_addr );
    platforms, a symbol is deemed to be found only if it has a nonzero
    TOC pointer.  */
 extern
-Bool VG_(lookup_symbol_SLOW)(HChar* sopatt, HChar* name, Addr* pEnt, Addr* pToc);
+Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, HChar* name, Addr* pEnt,
+                             Addr* pToc);
 
 #endif   // __PUB_CORE_DEBUGINFO_H
 
index ed183a6452c6cf9e54fbb1cc23d0239471c8f14e..160b71c3d4d646ce42bfd732dde5fc7235c282fc 100644 (file)
@@ -459,7 +459,7 @@ char *status_image (int status)
    If pid is reported as being dead/exited, waitstopped will return False.
 */
 static
-Bool waitstopped (int pid, int signal_expected, char *msg)
+Bool waitstopped (int pid, int signal_expected, const char *msg)
 {
    pid_t p;
    int status = 0;
@@ -505,7 +505,7 @@ Bool waitstopped (int pid, int signal_expected, char *msg)
    Returns True if succesful, False otherwise.
    msg is used in tracing and error reporting. */
 static
-Bool stop (int pid, char *msg)
+Bool stop (int pid, const char *msg)
 {
    long res;
 
@@ -524,7 +524,7 @@ Bool stop (int pid, char *msg)
    Returns True if succesful, False otherwise.
    msg is used in tracing and error reporting. */
 static
-Bool attach (int pid, char *msg)
+Bool attach (int pid, const char *msg)
 {
    long res;
    static Bool output_error = True;
@@ -1267,7 +1267,7 @@ void *invoke_gdbserver_in_valgrind(void *v_pid)
 }
 
 static
-int open_fifo (char* name, int flags, char* desc)
+int open_fifo (const char* name, int flags, const char* desc)
 {
    int fd;
    DEBUG(1, "opening %s %s\n", name, desc);
@@ -1319,7 +1319,7 @@ void acquire_lock (int fd, int valgrind_pid)
    Returns the nr of characters read, -1 if error.
    desc is a string used in tracing */
 static
-int read_buf (int fd, char* buf, char* desc)
+int read_buf (int fd, char* buf, const char* desc)
 {
    int nrread;
    DEBUG(2, "reading %s\n", desc);
@@ -1339,7 +1339,7 @@ int read_buf (int fd, char* buf, char* desc)
    valgrind process that there is new data.
    Returns True if write is ok, False if there was a problem. */
 static
-Bool write_buf(int fd, char* buf, int size, char* desc, Bool notify)
+Bool write_buf(int fd, char* buf, int size, const char* desc, Bool notify)
 {
    int nrwritten;
    int nrw;
@@ -1366,7 +1366,7 @@ typedef enum {
    TO_PID } ConnectionKind;
 static const int NumConnectionKind = TO_PID+1;
 static 
-char *ppConnectionKind (ConnectionKind con)
+const char *ppConnectionKind (ConnectionKind con)
 {
    switch (con) {
    case FROM_GDB: return "FROM_GDB";
@@ -2033,7 +2033,7 @@ static
 void ptrace_restrictions_msg(void)
 {
 #  ifdef PR_SET_PTRACER
-   char *ptrace_scope_setting_file = "/proc/sys/kernel/yama/ptrace_scope";
+   const char *ptrace_scope_setting_file = "/proc/sys/kernel/yama/ptrace_scope";
    int fd = -1;
    char ptrace_scope = 'X';
    fd = open (ptrace_scope_setting_file, O_RDONLY, 0);
@@ -2279,7 +2279,7 @@ Bool numeric_val(char* arg, int *value)
 
 /* true if arg matches the provided option */
 static
-Bool is_opt(char* arg, char *option)
+Bool is_opt(char* arg, const char *option)
 {
    int option_len = strlen(option);
    if (option[option_len-1] == '=')
index f2474f5cc3fb0e5e24bb24d51e5edde170e8601a..e537e6d38bde237cccf8e091aed850329c7bed2a 100644 (file)
@@ -63,7 +63,7 @@ void VG_(vcbprintf)(void(*char_sink)(HChar, void* opaque),
                     const HChar* format, va_list vargs)
 { assert(0); }
 void VG_(ssort)( void* base, SizeT nmemb, SizeT size,
-                 Int (*compar)(void*, void*) )
+                 Int (*compar)(const void*, const void*) )
 { assert(0); }
 
 /* Actual unit test */
index d250d0e987270dacdfd44c0552fe08d065988c07..f5a3133ce516c495ae389270e742e756445cc0e2 100644 (file)
@@ -146,7 +146,7 @@ static Addr Addr__max ( Addr a1, Addr a2 ) {
    vectors describe the same set of variables but are not structurally
    identical. */
 
-static inline Bool StackBlock__sane ( StackBlock* fb )
+static inline Bool StackBlock__sane ( const StackBlock* fb )
 {
    if (fb->name[ sizeof(fb->name)-1 ] != 0)
       return False;
@@ -158,7 +158,7 @@ static inline Bool StackBlock__sane ( StackBlock* fb )
 }
 
 /* Generate an arbitrary total ordering on StackBlocks. */
-static Word StackBlock__cmp ( StackBlock* fb1, StackBlock* fb2 )
+static Word StackBlock__cmp ( const StackBlock* fb1, const StackBlock* fb2 )
 {
    Word r;
    tl_assert(StackBlock__sane(fb1));
@@ -261,7 +261,7 @@ static XArray* /* of StackBlock */
    UWord key, val;
 
    /* First, normalise, as per comments above. */
-   VG_(setCmpFnXA)( orig, (Int(*)(void*,void*))StackBlock__cmp );
+   VG_(setCmpFnXA)( orig, (XACmpFn_t)StackBlock__cmp );
    VG_(sortXA)( orig );
 
    /* Now get rid of any exact duplicates. */
@@ -944,7 +944,7 @@ static void gen_delta_str ( /*OUT*/HChar* buf,
    messages. */
 static void show_Invar( HChar* buf, Word nBuf, Invar* inv, Word depth )
 {
-   HChar* str;
+   const HChar* str;
    tl_assert(nBuf >= 128);
    buf[0] = 0;
    switch (inv->tag) {
index 8a6c1d4ae5ca571639eb7aa0d46f6170634ec4e0..d218024fd35623d35d052b2144718bde6bc20ed2 100644 (file)
@@ -641,8 +641,8 @@ void HG_(record_error_LockOrder)(
                             XE_LockOrder, 0, NULL, &xe );
 }
 
-void HG_(record_error_PthAPIerror) ( Thread* thr, HChar* fnname, 
-                                     Word err, HChar* errstr )
+void HG_(record_error_PthAPIerror) ( Thread* thr, const HChar* fnname, 
+                                     Word err, const HChar* errstr )
 {
    XError xe;
    tl_assert( HG_(is_sane_Thread)(thr) );
@@ -661,8 +661,8 @@ void HG_(record_error_PthAPIerror) ( Thread* thr, HChar* fnname,
                             XE_PthAPIerror, 0, NULL, &xe );
 }
 
-void HG_(record_error_Misc_w_aux) ( Thread* thr, HChar* errstr,
-                                    HChar* auxstr, ExeContext* auxctx )
+void HG_(record_error_Misc_w_aux) ( Thread* thr, const HChar* errstr,
+                                    const HChar* auxstr, ExeContext* auxctx )
 {
    XError xe;
    tl_assert( HG_(is_sane_Thread)(thr) );
@@ -680,7 +680,7 @@ void HG_(record_error_Misc_w_aux) ( Thread* thr, HChar* errstr,
                             XE_Misc, 0, NULL, &xe );
 }
 
-void HG_(record_error_Misc) ( Thread* thr, HChar* errstr )
+void HG_(record_error_Misc) ( Thread* thr, const HChar* errstr )
 {
    HG_(record_error_Misc_w_aux)(thr, errstr, NULL, NULL);
 }
@@ -848,7 +848,7 @@ static void announce_combined_LockP_vecs ( Lock** lockvec,
 }
 
 
-static void show_LockP_summary_textmode ( Lock** locks, HChar* pre )
+static void show_LockP_summary_textmode ( Lock** locks, const HChar* pre )
 {
    tl_assert(locks);
    UWord i;
index eb2285906b7c35be2e847c07269d8feb98865b03..79c6fb536ed825027530d9f8709d315476985cdd 100644 (file)
@@ -56,16 +56,18 @@ void HG_(record_error_Race) ( Thread* thr,
 void HG_(record_error_UnlockUnlocked) ( Thread*, Lock* );
 void HG_(record_error_UnlockForeign)  ( Thread*, Thread*, Lock* );
 void HG_(record_error_UnlockBogus)    ( Thread*, Addr );
-void HG_(record_error_PthAPIerror)    ( Thread*, HChar*, Word, HChar* );
+void HG_(record_error_PthAPIerror)    ( Thread*, const HChar*, Word,
+                                        const HChar* );
 
 /* see the implementation for meaning of these params */
 void HG_(record_error_LockOrder)      ( Thread*, Addr, Addr,
                                         ExeContext*, ExeContext*,
                                         ExeContext* );
 
-void HG_(record_error_Misc_w_aux)     ( Thread*, HChar* errstr,
-                                        HChar* auxstr, ExeContext* auxctx );
-void HG_(record_error_Misc)           ( Thread* thr, HChar* errstr );
+void HG_(record_error_Misc_w_aux)     ( Thread*, const HChar* errstr,
+                                        const HChar* auxstr,
+                                        ExeContext* auxctx );
+void HG_(record_error_Misc)           ( Thread* thr, const HChar* errstr );
 
 
 /* Statistics pertaining to error management. */
index c5bea8c89dbaee5878ba9bb9fb55acf83e8d70c1..f5e36252a83981360d31a8c424a16cdd759c1a24 100644 (file)
@@ -1951,9 +1951,9 @@ static void evh__HG_PTHREAD_MUTEX_LOCK_PRE ( ThreadId tid,
          this is a real lock operation (not a speculative "tryLock"
          kind of thing).  Duh.  Deadlock coming up; but at least
          produce an error message. */
-      HChar* errstr = "Attempt to re-lock a "
-                      "non-recursive lock I already hold";
-      HChar* auxstr = "Lock was previously acquired";
+      const HChar* errstr = "Attempt to re-lock a "
+                            "non-recursive lock I already hold";
+      const HChar* auxstr = "Lock was previously acquired";
       if (lk->acquired_at) {
          HG_(record_error_Misc_w_aux)( thr, errstr, auxstr, lk->acquired_at );
       } else {
index 3ae242dd00feadee07b7c857ae8e65c46ef08257..1b71e3f9ac1c80aa1d1bfe085b7ea5a9b0320c0c 100644 (file)
@@ -1832,9 +1832,9 @@ static void scalarts_limitations_fail_NORETURN ( Bool due_to_nThrs )
 static XArray* /* of ThrID */ verydead_thread_table = NULL;
 
 /* Arbitrary total ordering on ThrIDs. */
-static Int cmp__ThrID ( void* v1, void* v2 ) {
-   ThrID id1 = *(ThrID*)v1;
-   ThrID id2 = *(ThrID*)v2;
+static Int cmp__ThrID ( const void* v1, const void* v2 ) {
+   ThrID id1 = *(const ThrID*)v1;
+   ThrID id2 = *(const ThrID*)v2;
    if (id1 < id2) return -1;
    if (id1 > id2) return 1;
    return 0;
@@ -1866,17 +1866,17 @@ typedef
    VTS;
 
 /* Allocate a VTS capable of storing 'sizeTS' entries. */
-static VTS* VTS__new ( HChar* who, UInt sizeTS );
+static VTS* VTS__new ( const HChar* who, UInt sizeTS );
 
 /* Make a clone of 'vts', sizing the new array to exactly match the
    number of ScalarTSs present. */
-static VTS* VTS__clone ( HChar* who, VTS* vts );
+static VTS* VTS__clone ( const HChar* who, VTS* vts );
 
 /* Make a clone of 'vts' with the thrids in 'thrids' removed.  The new
    array is sized exactly to hold the number of required elements.
    'thridsToDel' is an array of ThrIDs to be omitted in the clone, and
    must be in strictly increasing order. */
-static VTS* VTS__subtract ( HChar* who, VTS* vts, XArray* thridsToDel );
+static VTS* VTS__subtract ( const HChar* who, VTS* vts, XArray* thridsToDel );
 
 /* Delete this VTS in its entirety. */
 static void VTS__delete ( VTS* vts );
@@ -1960,7 +1960,7 @@ static Bool is_sane_VTS ( VTS* vts )
 
 /* Create a new, empty VTS.
 */
-static VTS* VTS__new ( HChar* who, UInt sizeTS )
+static VTS* VTS__new ( const HChar* who, UInt sizeTS )
 {
    VTS* vts = HG_(zalloc)(who, sizeof(VTS) + (sizeTS+1) * sizeof(ScalarTS));
    tl_assert(vts->usedTS == 0);
@@ -1971,7 +1971,7 @@ static VTS* VTS__new ( HChar* who, UInt sizeTS )
 
 /* Clone this VTS.
 */
-static VTS* VTS__clone ( HChar* who, VTS* vts )
+static VTS* VTS__clone ( const HChar* who, VTS* vts )
 {
    tl_assert(vts);
    tl_assert( *(ULong*)(&vts->ts[vts->sizeTS]) == 0x0ddC0ffeeBadF00dULL);
@@ -1993,7 +1993,7 @@ static VTS* VTS__clone ( HChar* who, VTS* vts )
    must be in strictly increasing order.  We could obviously do this
    much more efficiently (in linear time) if necessary.
 */
-static VTS* VTS__subtract ( HChar* who, VTS* vts, XArray* thridsToDel )
+static VTS* VTS__subtract ( const HChar* who, VTS* vts, XArray* thridsToDel )
 {
    UInt i, j;
    tl_assert(vts);
@@ -2672,7 +2672,7 @@ static VtsID vts_tab__find__or__clone_and_add ( VTS* cand )
 }
 
 
-static void show_vts_stats ( HChar* caller )
+static void show_vts_stats ( const HChar* caller )
 {
    UWord nSet, nTab, nLive;
    ULong totrc;
@@ -3333,7 +3333,7 @@ static Thr* VtsID__findFirst_notLEQ ( VtsID vi1, VtsID vi2 )
    fast way to do this is simply to stuff in tags which we know are
    not going to match anything, since they're not aligned to the start
    of a line. */
-static void Filter__clear ( Filter* fi, HChar* who )
+static void Filter__clear ( Filter* fi, const HChar* who )
 {
    UWord i;
    if (0) VG_(printf)("  Filter__clear(%p, %s)\n", fi, who);
@@ -3745,7 +3745,8 @@ static void note_local_Kw_n_stack_for ( Thr* thr )
       VG_(pp_ExeContext)(pair.ec);
 }
 
-static Int cmp__ULong_n_EC__by_ULong ( ULong_n_EC* pair1, ULong_n_EC* pair2 )
+static Int cmp__ULong_n_EC__by_ULong ( const ULong_n_EC* pair1,
+                                       const ULong_n_EC* pair2 )
 {
    if (pair1->ull < pair2->ull) return -1;
    if (pair1->ull > pair2->ull) return 1;
@@ -4897,7 +4898,7 @@ static void record_race_info ( Thr* acc_thr,
       found = VG_(lookupXA_UNSAFE)(
                  confThr->local_Kws_n_stacks,
                  &key, &firstIx, &lastIx,
-                 (Int(*)(void*,void*))cmp__ULong_n_EC__by_ULong
+                 (XACmpFn_t)cmp__ULong_n_EC__by_ULong
               );
       if (0) VG_(printf)("record_race_info %u %u %u  confThr %p "
                          "confTym %llu found %d (%lu,%lu)\n", 
@@ -6047,7 +6048,7 @@ static void SO__Dealloc ( SO* so )
 //                                                     //
 /////////////////////////////////////////////////////////
 
-static void show_thread_state ( HChar* str, Thr* t ) 
+static void show_thread_state ( const HChar* str, Thr* t ) 
 {
    if (1) return;
    if (t->viR == t->viW) {
@@ -6491,7 +6492,7 @@ static inline Bool TRACEME(Addr a, SizeT szB) {
    if (XXX2 && a <= XXX2 && XXX2 <= a+szB) return True;
    return False;
 }
-static void trace ( Thr* thr, Addr a, SizeT szB, const HChar* s ) 
+static void trace ( Thr* thr, Addr a, SizeT szB, const const HChar* s ) 
 {
   SVal sv = zsm_sread08(a);
   VG_(printf)("thr %p (%#lx,%lu) %s: 0x%016llx ", thr,a,szB,s,sv);
index d6fe139abf291ea877276f7af1665c76ff50227a..03be811c42f0ae553fd360193e35e8f1f5adf715 100644 (file)
@@ -160,7 +160,7 @@ typedef
       kwd_report_none,
       kwd_report_all,
       kwd_report_duplicated_matches } kwd_report_error;
-extern Int VG_(keyword_id) (HChar* keywords, HChar* input_word, 
+extern Int VG_(keyword_id) (const HChar* keywords, const HChar* input_word, 
                             kwd_report_error report);
 
 /* Extract an address and (optionally) a size from the string
index f1b47f57f131674b43bccd83a11e11aa8ec1646b..ba1dd0c7b27c535fd8f00ada579a43bdfc609366 100644 (file)
@@ -179,7 +179,7 @@ static void VG_(bzero_inline) ( void* s, SizeT sz )
 /* Like qsort().  The name VG_(ssort) is for historical reasons -- it used
  * to be a shell sort, but is now a quicksort. */
 extern void VG_(ssort)( void* base, SizeT nmemb, SizeT size,
-                        Int (*compar)(void*, void*) );
+                        Int (*compar)(const void*, const void*) );
 
 /* Returns the base-2 logarithm of a 32 bit unsigned number.  Returns
  -1 if it is not a power of two.  Nb: VG_(log2)(1) == 0. */
index b9acc1c69c2be0b33779e10cc3521f702d2649a1..3b4d7cef711a474c3ee4631b8ca6973b8acb6df7 100644 (file)
@@ -91,8 +91,8 @@ extern Int    VG_(poll) (struct vki_pollfd *fds, Int nfds, Int timeout);
 extern Int    VG_(readlink)( const HChar* path, HChar* buf, UInt bufsize );
 extern Int    VG_(getdents)( Int fd, struct vki_dirent *dirp, UInt count );
 
-extern HChar* VG_(basename)( const HChar* path );
-extern HChar* VG_(dirname) ( const HChar* path );
+extern const HChar* VG_(basename)( const HChar* path );
+extern const HChar* VG_(dirname) ( const HChar* path );
 
 /* Return the name of a directory for temporary files. */
 extern const HChar* VG_(tmpdir)(void);
index 08ab203a2093f7f9f157fefd7a63946d88721555..e52e47cc5f5496eda6dbe93af8ca65ba73d625e6 100644 (file)
@@ -130,7 +130,7 @@ void VG_(set_syscall_return_shadows) ( ThreadId tid,
 // This is very Memcheck-specific -- it's used to find the roots when
 // doing leak checking.
 extern void VG_(apply_to_GP_regs)(void (*f)(ThreadId tid,
-                                            HChar* regname, UWord val));
+                                            const HChar* regname, UWord val));
 
 // This iterator lets you inspect each live thread's stack bounds.
 // Returns False at the end.  'tid' is the iterator and you can only
index 81e05263bcaca24e5009ef927ac1918e31743e6d..91484e0943e2c9ea64ef75660c742e7e3859ba0d 100644 (file)
@@ -46,6 +46,8 @@
 /* It's an abstract type.  Bwaha. */
 typedef  struct _XArray  XArray;
 
+typedef Int (*XACmpFn_t)(const void *, const void *);
+
 /* Create new XArray, using given allocation and free function, and
    for elements of the specified size.  Alloc fn must not fail (that
    is, if it returns it must have succeeded.) */
@@ -60,17 +62,17 @@ extern void VG_(deleteXA) ( XArray* );
 /* Set the comparison function for this XArray.  This clears an
    internal 'array is sorted' flag, which means you must call sortXA
    before making further queries with lookupXA. */
-extern void VG_(setCmpFnXA) ( XArray*, Int (*compar)(void*,void*) );
+extern void VG_(setCmpFnXA) ( XArray*, XACmpFn_t);
 
 /* Add an element to an XArray.  Element is copied into the XArray.
    Index at which it was added is returned.  Note this will be
    invalidated if the array is later sortXA'd. */
-extern Word VG_(addToXA) ( XArray*, void* elem );
+extern Word VG_(addToXA) ( XArray*, const void* elem );
 
 /* Add a sequence of bytes to an XArray of bytes.  Asserts if nbytes
    is negative or the array's element size is not 1.  Returns the
    index at which the first byte was added. */
-extern Word VG_(addBytesToXA) ( XArray* xao, void* bytesV, Word nbytes );
+extern Word VG_(addBytesToXA) ( XArray* xao, const void* bytesV, Word nbytes );
 
 /* Sort an XArray using its comparison function, if set; else bomb.
    Probably not a stable sort w.r.t. equal elements module cmpFn. */
@@ -81,7 +83,7 @@ extern void VG_(sortXA) ( XArray* );
    value found.  If any values are found, return True, else return
    False, and don't change *first or *last.  first and/or last may be
    NULL.  Bomb if the array is not sorted. */
-extern Bool VG_(lookupXA) ( XArray*, void* key, 
+extern Bool VG_(lookupXA) ( XArray*, const void* key, 
                             /*OUT*/Word* first, /*OUT*/Word* last );
 
 /* A version of VG_(lookupXA) in which you can specify your own
@@ -92,9 +94,9 @@ extern Bool VG_(lookupXA) ( XArray*, void* key,
    VG_(lookupXA), which refuses to do anything (asserts) unless the
    array has first been sorted using the same comparison function as
    is being used for the lookup. */
-extern Bool VG_(lookupXA_UNSAFE) ( XArray* xao, void* key,
+extern Bool VG_(lookupXA_UNSAFE) ( XArray* xao, const void* key,
                                    /*OUT*/Word* first, /*OUT*/Word* last,
-                                   Int(*cmpFn)(void*,void*) );
+                                   XACmpFn_t cmpFn );
 
 /* How elements are there in this XArray now? */
 extern Word VG_(sizeXA) ( XArray* );
index 32421b100f59069eda549a7b9bb6b8cd6d9e3487..4374e49967374ff67089f15b77b777af47e882e2 100644 (file)
@@ -311,7 +311,7 @@ static void init_alloc_fns(void)
    // Create the list, and add the default elements.
    alloc_fns = VG_(newXA)(VG_(malloc), "ms.main.iaf.1",
                                        VG_(free), sizeof(HChar*));
-   #define DO(x)  { HChar* s = x; VG_(addToXA)(alloc_fns, &s); }
+   #define DO(x)  { const HChar* s = x; VG_(addToXA)(alloc_fns, &s); }
 
    // Ordered roughly according to (presumed) frequency.
    // Nb: The C++ "operator new*" ones are overloadable.  We include them
@@ -361,7 +361,7 @@ static void init_ignore_fns(void)
 }
 
 // Determines if the named function is a member of the XArray.
-static Bool is_member_fn(XArray* fns, HChar* fnname)
+static Bool is_member_fn(XArray* fns, const HChar* fnname)
 {
    HChar** fn_ptr;
    Int i;
@@ -660,10 +660,10 @@ static void add_child_xpt(XPt* parent, XPt* child)
 }
 
 // Reverse comparison for a reverse sort -- biggest to smallest.
-static Int SXPt_revcmp_szB(void* n1, void* n2)
+static Int SXPt_revcmp_szB(const void* n1, const void* n2)
 {
-   SXPt* sxpt1 = *(SXPt**)n1;
-   SXPt* sxpt2 = *(SXPt**)n2;
+   const SXPt* sxpt1 = *(const SXPt**)n1;
+   const SXPt* sxpt2 = *(const SXPt**)n2;
    return ( sxpt1->szB < sxpt2->szB ?  1
           : sxpt1->szB > sxpt2->szB ? -1
           :                            0);
@@ -2172,7 +2172,7 @@ static void pp_snapshot_SXPt(Int fd, SXPt* sxpt, Int depth, HChar* depth_str,
    // of the stack frame -- this function is recursive.  Obviously this
    // now means its contents are trashed across the recursive call.
    static HChar ip_desc_array[BUF_LEN];
-   HChar* ip_desc = ip_desc_array;
+   const HChar* ip_desc = ip_desc_array;
 
    switch (sxpt->tag) {
     case SigSXPt:
@@ -2186,6 +2186,10 @@ static void pp_snapshot_SXPt(Int fd, SXPt* sxpt, Int depth, HChar* depth_str,
                );
          } else {
             // XXX: --alloc-fns?
+
+            // Nick thinks this case cannot happen. ip_desc_array would be
+            // conceptually uninitialised here. Therefore:
+            tl_assert2(0, "pp_snapshot_SXPt: unexpected");
          }
       } else {
          // If it's main-or-below-main, we (if appropriate) ignore everything
@@ -2198,7 +2202,7 @@ static void pp_snapshot_SXPt(Int fd, SXPt* sxpt, Int depth, HChar* depth_str,
          }
 
          // We need the -1 to get the line number right, But I'm not sure why.
-         ip_desc = VG_(describe_IP)(sxpt->Sig.ip-1, ip_desc, BUF_LEN);
+         ip_desc = VG_(describe_IP)(sxpt->Sig.ip-1, ip_desc_array, BUF_LEN);
       }
       
       // Do the non-ip_desc part first...
index b140b16aa107ed731c0e4461d9b8774087c6fb78..d3aed412b858cf155c34f86af4be2e585975ece0 100644 (file)
@@ -297,8 +297,8 @@ static void emiN ( const HChar* format, ... ) /* NO FORMAT CHECK */
 
 static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc )
 {
-   HChar* xpre  = VG_(clo_xml) ? "  <auxwhat>" : " ";
-   HChar* xpost = VG_(clo_xml) ? "</auxwhat>"  : "";
+   const HChar* xpre  = VG_(clo_xml) ? "  <auxwhat>" : " ";
+   const HChar* xpost = VG_(clo_xml) ? "</auxwhat>"  : "";
 
    switch (ai->tag) {
       case Addr_Unknown:
index e8482918d36fc7e7fbd9bc3a2e4e8aef7430f6e7..1df6303bdbf4914288c48f778ce2f6543ee5f1d4 100644 (file)
 /*------------------------------------------------------------*/
 
 // Compare the MC_Chunks by 'data' (i.e. the address of the block).
-static Int compare_MC_Chunks(void* n1, void* n2)
+static Int compare_MC_Chunks(const void* n1, const void* n2)
 {
-   MC_Chunk* mc1 = *(MC_Chunk**)n1;
-   MC_Chunk* mc2 = *(MC_Chunk**)n2;
+   const MC_Chunk* mc1 = *(const MC_Chunk**)n1;
+   const MC_Chunk* mc2 = *(const MC_Chunk**)n2;
    if (mc1->data < mc2->data) return -1;
    if (mc1->data > mc2->data) return  1;
    return 0;
@@ -604,7 +604,7 @@ lc_push_without_clique_if_a_chunk_ptr(Addr ptr, Bool is_prior_definite)
 }
 
 static void
-lc_push_if_a_chunk_ptr_register(ThreadId tid, HChar* regname, Addr ptr)
+lc_push_if_a_chunk_ptr_register(ThreadId tid, const HChar* regname, Addr ptr)
 {
    lc_push_without_clique_if_a_chunk_ptr(ptr, /*is_prior_definite*/True);
 }
@@ -850,10 +850,10 @@ static Word cmp_LossRecordKey_LossRecord(const void* key, const void* elem)
    VG_(tool_panic)("bad LossRecord comparison");
 }
 
-static Int cmp_LossRecords(void* va, void* vb)
+static Int cmp_LossRecords(const void* va, const void* vb)
 {
-   LossRecord* lr_a = *(LossRecord**)va;
-   LossRecord* lr_b = *(LossRecord**)vb;
+   const LossRecord* lr_a = *(const LossRecord**)va;
+   const LossRecord* lr_b = *(const LossRecord**)vb;
    SizeT total_szB_a = lr_a->szB + lr_a->indirect_szB;
    SizeT total_szB_b = lr_b->szB + lr_b->indirect_szB;
 
@@ -1522,7 +1522,7 @@ void MC_(detect_memory_leaks) ( ThreadId tid, LeakCheckParams* lcp)
 static Addr searched_wpa;
 static SizeT searched_szB;
 static void
-search_address_in_GP_reg(ThreadId tid, HChar* regname, Addr addr_in_reg)
+search_address_in_GP_reg(ThreadId tid, const HChar* regname, Addr addr_in_reg)
 {
    if (addr_in_reg >= searched_wpa 
        && addr_in_reg < searched_wpa + searched_szB) {
index 812c613fb79552dfe5832875aa137ff770b17e4a..2434de15dacb2fdd0be56ff8a6322eb1bbe7578c 100644 (file)
@@ -5203,14 +5203,16 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
             lcp.max_loss_records_output = 999999999; break;
          case  9: { /* limited */
             Int int_value;
-            HChar* endptr;
+            const HChar* endptr;
 
             wcmd = VG_(strtok_r) (NULL, " ", &ssaveptr);
             if (wcmd == NULL) {
                int_value = 0;
                endptr = "empty"; /* to report an error below */
             } else {
-               int_value = VG_(strtoll10) (wcmd, &endptr);
+               HChar *the_end;
+               int_value = VG_(strtoll10) (wcmd, &the_end);
+               endptr = the_end;
             }
             if (*endptr != '\0')
                VG_(gdb_printf) ("missing or malformed integer value\n");
@@ -5256,7 +5258,7 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
       SizeT szB = 1;
       Addr bad_addr;
       UInt okind;
-      HChar* src;
+      const HChar* src;
       UInt otag;
       UInt ecu;
       ExeContext* origin_ec;
index f31fe2a81b4a6f5df40e3da943cc9e983647eed2..5b967b09618ce0b2cf01fbce979bf4c5c8ff5c31 100644 (file)
@@ -667,10 +667,10 @@ void MC_(destroy_mempool)(Addr pool)
 }
 
 static Int 
-mp_compar(void* n1, void* n2)
+mp_compar(const void* n1, const void* n2)
 {
-   MC_Chunk* mc1 = *(MC_Chunk**)n1;
-   MC_Chunk* mc2 = *(MC_Chunk**)n2;
+   const MC_Chunk* mc1 = *(const MC_Chunk**)n1;
+   const MC_Chunk* mc2 = *(const MC_Chunk**)n2;
    if (mc1->data < mc2->data) return -1;
    if (mc1->data > mc2->data) return  1;
    return 0;
index 57229f8f5467a44de62876077c2ebbacfaa94dc5..91cb80c56258c6783cef023057eede8f57e9f069 100644 (file)
@@ -1109,7 +1109,7 @@ static void complainIfUndefined ( MCEnv* mce, IRAtom* atom, IRExpr *guard )
    IRAtom*  cond;
    IRAtom*  origin;
    void*    fn;
-   HChar*   nm;
+   const HChar* nm;
    IRExpr** args;
    Int      nargs;
 
@@ -5859,7 +5859,7 @@ static IRAtom* gen_load_b ( MCEnv* mce, Int szB,
                             IRAtom* baseaddr, Int offset )
 {
    void*    hFun;
-   HChar*   hName;
+   const HChar* hName;
    IRTemp   bTmp;
    IRDirty* di;
    IRType   aTy   = typeOfIRExpr( mce->sb->tyenv, baseaddr );
@@ -5937,7 +5937,7 @@ static void gen_store_b ( MCEnv* mce, Int szB,
                           IRAtom* guard )
 {
    void*    hFun;
-   HChar*   hName;
+   const HChar* hName;
    IRDirty* di;
    IRType   aTy   = typeOfIRExpr( mce->sb->tyenv, baseaddr );
    IROp     opAdd = aTy == Ity_I32 ? Iop_Add32 : Iop_Add64;