is not used for testcases, just for valgrind proper.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13137
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
//------------------------------------------------------------------//
-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. */
}
__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 );
}
__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 );
}
__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 );
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 );
}
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;
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)
}
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;
}
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;
#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);
}
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();
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)
{
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])
// 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;
#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";
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";
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";
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";
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),
*/
static void discard_DebugInfo ( DebugInfo* di )
{
- HChar* reason = "munmap";
+ const HChar* reason = "munmap";
DebugInfo** prev_next_ptr = &debugInfo_list;
DebugInfo* curr = debugInfo_list;
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;
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
}
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 --- */
/* 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,
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 );
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,
/* 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
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)
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 */
Bool is_ehframe )
{
Int nbytes;
- HChar* how = NULL;
+ const HChar* how = NULL;
Int n_CIEs = 0;
UChar* data = frame_image;
UWord cfsi_used_orig;
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;
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));
/* 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;
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) */
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
}
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++) {
}
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++) {
/* 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
__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
/*--- ---*/
/*------------------------------------------------------------*/
-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;
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,
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 */
/*------------------------------------------------------------*/
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);
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;
/*--- ---*/
/*------------------------------------------------------------*/
-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;
/* 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)
/* 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))
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;
}
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);
Bool all;
TyEnt* ent;
MaybeULong mul;
- HChar* badness;
+ const HChar* badness;
tl_assert(di && di->admin_tyents);
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;
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;
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;
/* 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);
/* 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;
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;
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)
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');
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];
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
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;
/* 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.
{
#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;
}
static
-char * ppFinishReason (FinishReason reason)
+const char * ppFinishReason (FinishReason reason)
{
switch (reason) {
case orderly_finish: return "orderly_finish";
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;
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;
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) {
}
static
-void kill_request (char *msg)
+void kill_request (const char *msg)
{
VG_(umsg) ("%s", msg);
remote_close();
char s[strlen(mon)+1]; /* copy for strtok_r */
char* wcmd;
HChar* ssaveptr;
- char* endptr;
+ const char* endptr;
int kwdid;
int int_value;
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");
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);
}
&& 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;
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
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);
/* 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.
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). */
#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"},
/* 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)
}
/* 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;
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,
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);
}
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);
/* -------------------------------------------------------------------------- */
/* 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))
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)
}
static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
{
if (shadow_mode) {
return "arm-with-vfpv3-valgrind.xml";
}
static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
{
if (shadow_mode) {
return "mips-linux-valgrind.xml";
}
static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
{
if (shadow_mode) {
return "powerpc-altivec32l-valgrind.xml";
}
static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
{
if (shadow_mode) {
return "powerpc-altivec64l-valgrind.xml";
}
static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
{
if (shadow_mode) {
return "s390x-generic-valgrind.xml";
}
static
-char* target_xml (Bool shadow_mode)
+const char* target_xml (Bool shadow_mode)
{
if (shadow_mode) {
#if defined(VGO_linux)
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);
};
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);
}
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;
// 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);
}
}
-HChar *VG_(basename)(const HChar *path)
+const HChar *VG_(basename)(const HChar *path)
{
static HChar buf[VKI_PATH_MAX];
}
-HChar *VG_(dirname)(const HChar *path)
+const HChar *VG_(dirname)(const HChar *path)
{
static HChar buf[VKI_PATH_MAX];
}
-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)
}
-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;
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);
#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"
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;
}
if (sp) {
const HChar** strp;
- HChar* v = "valgrind: ";
+ const HChar* v = "valgrind: ";
vg_assert(sp->mark);
vg_assert(!sp->done);
vg_assert(sp->mandatory);
conflicting bindings. */
static void maybe_add_active ( Active act )
{
- HChar* what = NULL;
+ const HChar* what = NULL;
Active* old = NULL;
Bool add_act = False;
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);
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;
}
if (!found) {
- HChar* v = "valgrind: ";
+ const HChar* v = "valgrind: ";
VG_(printf)("\n");
VG_(printf)(
"%sFatal error at when loading library with soname\n", v);
/*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",
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:
}
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 */
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);
{
# 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;
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 */
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);
}
}
-Word VG_(addToXA) ( XArray* xao, void* elem )
+Word VG_(addToXA) ( XArray* xao, const void* elem )
{
struct _XArray* xa = (struct _XArray*)xao;
vg_assert(xa);
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;
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;
}
}
-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;
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
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;
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;
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;
}
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);
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);
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;
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";
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);
/* 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] == '=')
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 */
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;
}
/* 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));
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. */
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) {
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) );
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) );
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);
}
}
-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;
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. */
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 {
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;
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 );
/* 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);
/* 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);
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);
}
-static void show_vts_stats ( HChar* caller )
+static void show_vts_stats ( const HChar* caller )
{
UWord nSet, nTab, nLive;
ULong totrc;
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);
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;
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",
// //
/////////////////////////////////////////////////////////
-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) {
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);
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
/* 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. */
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);
// 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
/* 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.) */
/* 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. */
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
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* );
// 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
}
// 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;
}
// 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);
// 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:
);
} 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
}
// 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...
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:
/*------------------------------------------------------------*/
// 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;
}
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);
}
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;
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) {
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");
SizeT szB = 1;
Addr bad_addr;
UInt okind;
- HChar* src;
+ const HChar* src;
UInt otag;
UInt ecu;
ExeContext* origin_ec;
}
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;
IRAtom* cond;
IRAtom* origin;
void* fn;
- HChar* nm;
+ const HChar* nm;
IRExpr** args;
Int nargs;
IRAtom* baseaddr, Int offset )
{
void* hFun;
- HChar* hName;
+ const HChar* hName;
IRTemp bTmp;
IRDirty* di;
IRType aTy = typeOfIRExpr( mce->sb->tyenv, baseaddr );
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;