coregrind files shall use vg_assert not tl_assert.

Tool files shall use tl_assert not vg_assert.
Fix code accordingly.
Adapted check_headers_and_includes to make sure the code
stays clean in that respect.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14542
This commit is contained in:
Florian Krohm 2014-09-15 20:57:45 +00:00
parent 62a1b2529b
commit a584a6773c
20 changed files with 125 additions and 107 deletions

View File

@ -474,7 +474,7 @@ static void pp_addrinfo_WRK ( Addr a, AddrInfo* ai, Bool mc, Bool maybe_gcc )
);
if (ai->Addr.Block.block_kind==Block_Mallocd) {
VG_(pp_ExeContext)(ai->Addr.Block.allocated_at);
tl_assert (ai->Addr.Block.freed_at == VG_(null_ExeContext)());
vg_assert (ai->Addr.Block.freed_at == VG_(null_ExeContext)());
}
else if (ai->Addr.Block.block_kind==Block_Freed) {
VG_(pp_ExeContext)(ai->Addr.Block.freed_at);
@ -491,14 +491,14 @@ static void pp_addrinfo_WRK ( Addr a, AddrInfo* ai, Bool mc, Bool maybe_gcc )
|| ai->Addr.Block.block_kind==Block_UserG) {
// client-defined
VG_(pp_ExeContext)(ai->Addr.Block.allocated_at);
tl_assert (ai->Addr.Block.freed_at == VG_(null_ExeContext)());
vg_assert (ai->Addr.Block.freed_at == VG_(null_ExeContext)());
/* Nb: cannot have a freed_at, as a freed client-defined block
has a Block_Freed block_kind. */
} else {
// Client or Valgrind arena. At least currently, we never
// have stacktraces for these.
tl_assert (ai->Addr.Block.allocated_at == VG_(null_ExeContext)());
tl_assert (ai->Addr.Block.freed_at == VG_(null_ExeContext)());
vg_assert (ai->Addr.Block.allocated_at == VG_(null_ExeContext)());
vg_assert (ai->Addr.Block.freed_at == VG_(null_ExeContext)());
}
if (ai->Addr.Block.alloc_tinfo.tnr || ai->Addr.Block.alloc_tinfo.tid)
VG_(emit)(

View File

@ -1111,7 +1111,7 @@ GXResult ML_(evaluate_trivial_GX)( GExpr* gx, const DebugInfo* di )
VG_(printf)(" ML_(evaluate_trivial_GX): unhandled:\n ");
ML_(pp_GX)( gx );
VG_(printf)("\n");
tl_assert(0);
vg_assert(0);
}
else
if (!badness)
@ -1124,10 +1124,10 @@ GXResult ML_(evaluate_trivial_GX)( GExpr* gx, const DebugInfo* di )
res.kind = GXR_Failure;
tl_assert(nGuards == VG_(sizeXA)( results ));
tl_assert(nGuards >= 0);
vg_assert(nGuards == VG_(sizeXA)( results ));
vg_assert(nGuards >= 0);
if (nGuards == 0) {
tl_assert(!badness);
vg_assert(!badness);
res.word = (UWord)"trivial GExpr has no guards (!)";
VG_(deleteXA)( results );
return res;
@ -1151,11 +1151,11 @@ GXResult ML_(evaluate_trivial_GX)( GExpr* gx, const DebugInfo* di )
/* All the subexpressions produced a constant, but did they all produce
the same one? */
mul = VG_(indexXA)( results, 0 );
tl_assert(mul->b == True); /* we just established that all exprs are ok */
vg_assert(mul->b == True); /* we just established that all exprs are ok */
for (i = 1; i < nGuards; i++) {
mul2 = VG_(indexXA)( results, i );
tl_assert(mul2->b == True);
vg_assert(mul2->b == True);
if (mul2->ul != mul->ul) {
res.word = (UWord)"trivial GExpr: subexpressions disagree";
VG_(deleteXA)( results );

View File

@ -663,7 +663,7 @@ static ULong di_notify_ACHIEVE_ACCEPT_STATE ( struct _DebugInfo* di )
VG_(redir_notify_new_DebugInfo)( di );
/* Note that we succeeded */
di->have_dinfo = True;
tl_assert(di->handle > 0);
vg_assert(di->handle > 0);
di_handle = di->handle;
} else {
@ -2014,7 +2014,7 @@ Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, HChar* name, SymAVMAs* avmas)
}
for (i = 0; i < si->symtab_used; i++) {
HChar* pri_name = si->symtab[i].pri_name;
tl_assert(pri_name);
vg_assert(pri_name);
if (0==VG_(strcmp)(name, pri_name)
&& (require_pToc ? GET_TOCPTR_AVMA(si->symtab[i].avmas) : True)) {
*avmas = si->symtab[i].avmas;
@ -2022,7 +2022,7 @@ Bool VG_(lookup_symbol_SLOW)(const HChar* sopatt, HChar* name, SymAVMAs* avmas)
}
HChar** sec_names = si->symtab[i].sec_names;
if (sec_names) {
tl_assert(sec_names[0]);
vg_assert(sec_names[0]);
while (*sec_names) {
if (0==VG_(strcmp)(name, *sec_names)
&& (require_pToc
@ -3756,8 +3756,8 @@ void analyse_deps ( /*MOD*/XArray* /* of FrameBlock */ blocks,
GXResult res;
UWord sp_delta = res_sp_7k.word - res_sp_6k.word;
UWord fp_delta = res_fp_7k.word - res_fp_6k.word;
tl_assert(sp_delta == 0 || sp_delta == 1024);
tl_assert(fp_delta == 0 || fp_delta == 1024);
vg_assert(sp_delta == 0 || sp_delta == 1024);
vg_assert(fp_delta == 0 || fp_delta == 1024);
if (sp_delta == 0 && fp_delta == 0) {
/* depends neither on sp nor fp, so it can't be a stack
@ -3768,7 +3768,7 @@ void analyse_deps ( /*MOD*/XArray* /* of FrameBlock */ blocks,
regs.sp = regs.fp = 0;
regs.ip = ip;
res = ML_(evaluate_GX)( var->gexpr, var->fbGX, &regs, di );
tl_assert(res.kind == GXR_Addr);
vg_assert(res.kind == GXR_Addr);
if (debug)
VG_(printf)(" %5ld .. %5ld (sp) %s\n",
res.word, res.word + ((UWord)mul.ul) - 1, var->name);
@ -3787,7 +3787,7 @@ void analyse_deps ( /*MOD*/XArray* /* of FrameBlock */ blocks,
regs.sp = regs.fp = 0;
regs.ip = ip;
res = ML_(evaluate_GX)( var->gexpr, var->fbGX, &regs, di );
tl_assert(res.kind == GXR_Addr);
vg_assert(res.kind == GXR_Addr);
if (debug)
VG_(printf)(" %5ld .. %5ld (FP) %s\n",
res.word, res.word + ((UWord)mul.ul) - 1, var->name);
@ -3939,7 +3939,7 @@ void* /* really, XArray* of GlobalBlock */
/* The first thing to do is find the DebugInfo that
pertains to 'di_handle'. */
tl_assert(di_handle > 0);
vg_assert(di_handle > 0);
for (di = debugInfo_list; di; di = di->next) {
if (di->handle == di_handle)
break;
@ -3948,7 +3948,7 @@ void* /* really, XArray* of GlobalBlock */
/* If this fails, we were unable to find any DebugInfo with the
given handle. This is considered an error on the part of the
caller. */
tl_assert(di != NULL);
vg_assert(di != NULL);
/* we'll put the collected variables in here. */
gvars = VG_(newXA)( ML_(dinfo_zalloc), "di.debuginfo.dggbfd.1",
@ -3968,13 +3968,13 @@ void* /* really, XArray* of GlobalBlock */
DiAddrRange* range;
OSet* /* of DiAddrInfo */ scope
= *(OSet**)VG_(indexXA)( di->varinfo, scopeIx );
tl_assert(scope);
vg_assert(scope);
VG_(OSetGen_ResetIter)(scope);
while ( (range = VG_(OSetGen_Next)(scope)) ) {
/* Iterate over each variable in the current address range */
Word nVars, varIx;
tl_assert(range->vars);
vg_assert(range->vars);
nVars = VG_(sizeXA)( range->vars );
for (varIx = 0; varIx < nVars; varIx++) {
@ -3984,7 +3984,7 @@ void* /* really, XArray* of GlobalBlock */
GlobalBlock gb;
TyEnt* ty;
DiVariable* var = VG_(indexXA)( range->vars, varIx );
tl_assert(var->name);
vg_assert(var->name);
if (0) VG_(printf)("at depth %ld var %s ", scopeIx, var->name );
/* Now figure out if this variable has a constant address
@ -4031,8 +4031,8 @@ void* /* really, XArray* of GlobalBlock */
if (arrays_only && !isVec) continue;
/* Ok, so collect it! */
tl_assert(var->name);
tl_assert(di->soname);
vg_assert(var->name);
vg_assert(di->soname);
if (0) VG_(printf)("XXXX %s %s %d\n", var->name,
ML_(fndn_ix2filename)(di, var->fndn_ix),
var->lineNo);
@ -4042,8 +4042,8 @@ void* /* really, XArray* of GlobalBlock */
gb.isVec = isVec;
VG_(strncpy)(&gb.name[0], var->name, sizeof(gb.name)-1);
VG_(strncpy)(&gb.soname[0], di->soname, sizeof(gb.soname)-1);
tl_assert(gb.name[ sizeof(gb.name)-1 ] == 0);
tl_assert(gb.soname[ sizeof(gb.soname)-1 ] == 0);
vg_assert(gb.name[ sizeof(gb.name)-1 ] == 0);
vg_assert(gb.soname[ sizeof(gb.soname)-1 ] == 0);
VG_(addToXA)( gvars, &gb );

View File

@ -65,7 +65,7 @@ HChar* ML_(dinfo_strdup) ( const HChar* cc, const HChar* str ) {
void* ML_(dinfo_memdup) ( const HChar* cc, void* str, SizeT nStr ) {
void* dst = VG_(arena_malloc)( VG_AR_DINFO, cc, nStr );
tl_assert(dst);
vg_assert(dst);
VG_(memcpy)(dst, str, nStr);
return dst;
}

View File

@ -777,7 +777,7 @@ typedef
static Word cmp__XArrays_of_AddrRange ( XArray* rngs1, XArray* rngs2 )
{
Word n1, n2, i;
tl_assert(rngs1 && rngs2);
vg_assert(rngs1 && rngs2);
n1 = VG_(sizeXA)( rngs1 );
n2 = VG_(sizeXA)( rngs2 );
if (n1 < n2) return -1;
@ -2388,8 +2388,8 @@ static void parse_var_DIE (
UWord keyW, valW;
if (VG_(lookupFM)( rangestree, &keyW, &valW, (UWord)xa )) {
XArray* old = (XArray*)keyW;
tl_assert(valW == 0);
tl_assert(old != xa);
vg_assert(valW == 0);
vg_assert(old != xa);
tv->rngMany = old;
} else {
XArray* cloned = VG_(cloneXA)( "di.readdwarf3.pvD.2", xa );

View File

@ -1161,7 +1161,7 @@ void ML_(addVar)( struct _DebugInfo* di,
MaybeULong mul;
const HChar* badness;
tl_assert(di && di->admin_tyents);
vg_assert(di && di->admin_tyents);
if (0) {
VG_(printf)(" ML_(addVar): level %d %#lx-%#lx %s :: ",
@ -1186,7 +1186,7 @@ void ML_(addVar)( struct _DebugInfo* di,
vg_assert(gexpr);
ent = ML_(TyEnts__index_by_cuOff)( di->admin_tyents, NULL, typeR);
tl_assert(ent);
vg_assert(ent);
vg_assert(ML_(TyEnt__is_type)(ent));
/* "Comment_Regarding_Text_Range_Checks" (is referred to elsewhere)

View File

@ -849,7 +849,7 @@ XArray* /*HChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
offset -= offMin;
ty = ML_(TyEnts__index_by_cuOff)(tyents, NULL,
field->Te.Field.typeR );
tl_assert(ty);
vg_assert(ty);
if (ty->tag == Te_UNKNOWN) goto done;
/* keep going; look inside the field. */
break;
@ -899,7 +899,7 @@ XArray* /*HChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
case Te_TyQual: {
ty = ML_(TyEnts__index_by_cuOff)(tyents, NULL,
ty->Te.TyQual.typeR);
tl_assert(ty);
vg_assert(ty);
if (ty->tag == Te_UNKNOWN) goto done;
break;
}
@ -907,7 +907,7 @@ XArray* /*HChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
case Te_TyTyDef: {
ty = ML_(TyEnts__index_by_cuOff)(tyents, NULL,
ty->Te.TyTyDef.typeR);
tl_assert(ty);
vg_assert(ty);
if (ty->tag == Te_UNKNOWN) goto done;
break;
}

View File

@ -404,7 +404,7 @@ static void gen_suppression(Error* err)
// Print stack trace elements
UInt n_ips = VG_(get_ExeContext_n_ips)(ec);
tl_assert(n_ips > 0);
vg_assert(n_ips > 0);
if (n_ips > VG_MAX_SUPP_CALLERS)
n_ips = VG_MAX_SUPP_CALLERS;
VG_(apply_StackTrace)(printSuppForIp_nonXML,
@ -647,7 +647,7 @@ void construct_error ( Error* err, ThreadId tid, ErrorKind ekind, Addr a,
/* DO NOT MAKE unique_counter NON-STATIC */
static UInt unique_counter = 0;
tl_assert(tid < VG_N_THREADS);
vg_assert(tid < VG_N_THREADS);
/* Core-only parts */
err->unique = unique_counter++;

View File

@ -211,7 +211,7 @@ Bool VG_(eq_ExeContext) ( VgRes res, ExeContext* e1, ExeContext* e2 )
return False;
// Must be at least one address in each trace.
tl_assert(e1->n_ips >= 1 && e2->n_ips >= 1);
vg_assert(e1->n_ips >= 1 && e2->n_ips >= 1);
switch (res) {
case Vg_LowRes:
@ -362,7 +362,7 @@ static ExeContext* record_ExeContext_wrk2 ( Addr* ips, UInt n_ips )
static UInt ctr = 0;
tl_assert(n_ips >= 1 && n_ips <= VG_(clo_backtrace_size));
vg_assert(n_ips >= 1 && n_ips <= VG_(clo_backtrace_size));
/* Now figure out if we've seen this one before. First hash it so
as to determine the list number. */

View File

@ -216,7 +216,7 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return)
case -2: int_value = 0; break;
case -1: int_value = 0; break;
case 0: int_value = 1; break;
default: tl_assert (0);
default: vg_assert (0);
}
}
@ -321,7 +321,7 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return)
case 1:
hostvisibility = False;
break;
default: tl_assert (0);
default: vg_assert (0);
}
} else {
hostvisibility = True;
@ -390,7 +390,7 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return)
case 0:
VG_(am_show_nsegments) (0, "gdbserver v.info memory aspacemgr");
break;
default: tl_assert (0);
default: vg_assert (0);
}
}
@ -518,7 +518,7 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return)
VG_(clo_sanity_level) = save_clo_sanity_level;
break;
}
default: tl_assert (0);
default: vg_assert (0);
}
break;

View File

@ -108,7 +108,7 @@ static void add_to__printf_buf ( HChar c, void *p )
}
b->buf[b->buf_used++] = c;
b->buf[b->buf_used] = 0;
tl_assert(b->buf_used < sizeof(b->buf));
vg_assert(b->buf_used < sizeof(b->buf));
}
static UInt vprintf_to_buf ( printf_buf_t* b,

View File

@ -152,7 +152,7 @@ VG_(get_shadow_regs_area) ( ThreadId tid,
case 1: src = (void*)(((Addr)&(tst->arch.vex_shadow1)) + offset); break;
case 2: src = (void*)(((Addr)&(tst->arch.vex_shadow2)) + offset); break;
}
tl_assert(src != NULL);
vg_assert(src != NULL);
VG_(memcpy)( dst, src, size);
}
@ -176,7 +176,7 @@ VG_(set_shadow_regs_area) ( ThreadId tid,
case 1: dst = (void*)(((Addr)&(tst->arch.vex_shadow1)) + offset); break;
case 2: dst = (void*)(((Addr)&(tst->arch.vex_shadow2)) + offset); break;
}
tl_assert(dst != NULL);
vg_assert(dst != NULL);
VG_(memcpy)( dst, src, size);
}

View File

@ -2112,7 +2112,7 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Load initial debug info\n");
tl_assert(!addr2dihandle);
vg_assert(!addr2dihandle);
addr2dihandle = VG_(newXA)( VG_(malloc), "main.vm.2",
VG_(free), sizeof(Addr_n_ULong) );
@ -2219,12 +2219,12 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
{ Addr* seg_starts;
Int n_seg_starts;
tl_assert(addr2dihandle);
vg_assert(addr2dihandle);
/* Mark the main thread as running while we tell the tool about
the client memory so that the tool can associate that memory
with the main thread. */
tl_assert(VG_(running_tid) == VG_INVALID_THREADID);
vg_assert(VG_(running_tid) == VG_INVALID_THREADID);
VG_(running_tid) = tid_main;
seg_starts = VG_(get_segment_starts)( &n_seg_starts );
@ -2271,7 +2271,7 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
for (j = 0; j < n; j++) {
Addr_n_ULong* anl = VG_(indexXA)( addr2dihandle, j );
if (anl->a == seg->start) {
tl_assert(anl->ull > 0); /* check it's a valid handle */
vg_assert(anl->ull > 0); /* check it's a valid handle */
break;
}
}
@ -2327,7 +2327,7 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
/* Clear the running thread indicator */
VG_(running_tid) = VG_INVALID_THREADID;
tl_assert(VG_(running_tid) == VG_INVALID_THREADID);
vg_assert(VG_(running_tid) == VG_INVALID_THREADID);
/* Darwin only: tell the tools where the client's kernel commpage
is. It would be better to do this by telling aspacemgr about

View File

@ -1427,13 +1427,13 @@ static void cc_analyse_alloc_arena ( ArenaId aid )
if (!blockSane(a, b)) {
VG_(printf)("sanity_check_malloc_arena: sb %p, block %ld "
"(bszB %lu): BAD\n", sb, i, b_bszB );
tl_assert(0);
vg_assert(0);
}
thisFree = !is_inuse_block(b);
if (thisFree && lastWasFree) {
VG_(printf)("sanity_check_malloc_arena: sb %p, block %ld "
"(bszB %lu): UNMERGED FREES\n", sb, i, b_bszB );
tl_assert(0);
vg_assert(0);
}
lastWasFree = thisFree;
@ -1448,35 +1448,35 @@ static void cc_analyse_alloc_arena ( ArenaId aid )
(Int)(!thisFree),
(Int)bszB_to_pszB(a, b_bszB),
get_cc(b));
tl_assert(cc);
vg_assert(cc);
for (k = 0; k < n_ccs; k++) {
tl_assert(anCCs[k].cc);
vg_assert(anCCs[k].cc);
if (0 == VG_(strcmp)(cc, anCCs[k].cc))
break;
}
tl_assert(k >= 0 && k <= n_ccs);
vg_assert(k >= 0 && k <= n_ccs);
if (k == n_ccs) {
tl_assert(n_ccs < N_AN_CCS-1);
vg_assert(n_ccs < N_AN_CCS-1);
n_ccs++;
anCCs[k].nBytes = 0;
anCCs[k].nBlocks = 0;
anCCs[k].cc = cc;
}
tl_assert(k >= 0 && k < n_ccs && k < N_AN_CCS);
vg_assert(k >= 0 && k < n_ccs && k < N_AN_CCS);
anCCs[k].nBytes += (ULong)bszB_to_pszB(a, b_bszB);
anCCs[k].nBlocks++;
}
if (i > sb->n_payload_bytes) {
VG_(printf)( "sanity_check_malloc_arena: sb %p: last block "
"overshoots end\n", sb);
tl_assert(0);
vg_assert(0);
}
}
if (a->stats__perm_bytes_on_loan > 0) {
tl_assert(n_ccs < N_AN_CCS-1);
vg_assert(n_ccs < N_AN_CCS-1);
anCCs[n_ccs].nBytes = a->stats__perm_bytes_on_loan;
anCCs[n_ccs].nBlocks = a->stats__perm_blocks;
anCCs[n_ccs].cc = "perm_malloc";

View File

@ -147,7 +147,7 @@ HChar* VG_(expand_file_name)(const HChar* option_name, const HChar* format)
HChar* out;
Bool ok = VG_(get_startup_wd)(base_dir, VKI_PATH_MAX);
tl_assert(ok);
vg_assert(ok);
if (VG_STREQ(format, "")) {
// Empty name, bad.

View File

@ -354,8 +354,8 @@ static HChar** alloc_symname_array ( HChar* pri_name, HChar** sec_names,
arr[i++] = pri_name;
pp = sec_names;
while (*pp) { arr[i++] = *pp; pp++; }
tl_assert(i == n_req);
tl_assert(arr[n_req] == NULL);
vg_assert(i == n_req);
vg_assert(arr[n_req] == NULL);
return arr;
}
@ -1508,13 +1508,13 @@ static void* dinfo_zalloc(const HChar* ec, SizeT n) {
void* p;
vg_assert(n > 0);
p = VG_(arena_malloc)(VG_AR_DINFO, ec, n);
tl_assert(p);
vg_assert(p);
VG_(memset)(p, 0, n);
return p;
}
static void dinfo_free(void* p) {
tl_assert(p);
vg_assert(p);
return VG_(arena_free)(VG_AR_DINFO, p);
}

View File

@ -344,7 +344,7 @@ IRSB* vg_SP_update_pass ( void* closureV,
\
addStmtToIRSB( bb, IRStmt_Dirty(dcall) ); \
\
tl_assert(syze > 0); \
vg_assert(syze > 0); \
update_SP_aliases(syze); \
\
n_SP_updates_fast++; \
@ -374,7 +374,7 @@ IRSB* vg_SP_update_pass ( void* closureV,
\
addStmtToIRSB( bb, IRStmt_Dirty(dcall) ); \
\
tl_assert(syze > 0); \
vg_assert(syze > 0); \
update_SP_aliases(-(syze)); \
\
n_SP_updates_fast++; \
@ -1564,7 +1564,7 @@ Bool VG_(translate) ( ThreadId tid,
# endif
/* ------ Actually do the translation. ------ */
tl_assert2(VG_(tdict).tool_instrument,
vg_assert2(VG_(tdict).tool_instrument,
"you forgot to set VgToolInterface function 'tool_instrument'");
/* Get the CPU info established at startup. */

View File

@ -130,7 +130,7 @@ static void avl_nasty ( AvlNode* root )
root->child[1]->balance = 0;
break;
default:
tl_assert(0);
vg_assert(0);
}
root->balance=0;
}
@ -190,7 +190,7 @@ Bool avl_insert_wrk ( AvlNode** rootp,
case 1: return False;
case 0: return True;
case -1: break;
default: tl_assert(0);
default: vg_assert(0);
}
if ((*rootp)->child[0]->balance < 0) {
avl_swr( rootp );
@ -211,7 +211,7 @@ Bool avl_insert_wrk ( AvlNode** rootp,
return False;
return True;
}
tl_assert(0);/*NOTREACHED*/
vg_assert(0);/*NOTREACHED*/
}
else
if (cmpres < 0) {
@ -223,7 +223,7 @@ Bool avl_insert_wrk ( AvlNode** rootp,
case -1: return False;
case 0: return True;
case 1: break;
default: tl_assert(0);
default: vg_assert(0);
}
if ((*rootp)->child[1]->balance > 0) {
avl_swl( rootp );
@ -244,7 +244,7 @@ Bool avl_insert_wrk ( AvlNode** rootp,
return False;
return True;
}
tl_assert(0);/*NOTREACHED*/
vg_assert(0);/*NOTREACHED*/
}
else {
/* cmpres == 0, a duplicate - replace the val, but don't
@ -273,7 +273,7 @@ Bool avl_remove_wrk ( AvlNode** rootp,
if (cmpres > 0){
/* remove from the left subtree */
AvlNode* left_subtree = (*rootp)->child[0];
tl_assert(left_subtree);
vg_assert(left_subtree);
ch = avl_remove_wrk(&left_subtree, a, kCmp);
(*rootp)->child[0]=left_subtree;
if (ch) {
@ -281,7 +281,7 @@ Bool avl_remove_wrk ( AvlNode** rootp,
case -1: return True;
case 0: return False;
case 1: break;
default: tl_assert(0);
default: vg_assert(0);
}
switch ((*rootp)->child[1]->balance) {
case 0:
@ -297,7 +297,7 @@ Bool avl_remove_wrk ( AvlNode** rootp,
case -1:
break;
default:
tl_assert(0);
vg_assert(0);
}
avl_swr( &((*rootp)->child[1]) );
avl_swl( rootp );
@ -309,7 +309,7 @@ Bool avl_remove_wrk ( AvlNode** rootp,
if (cmpres < 0) {
/* remove from the right subtree */
AvlNode* right_subtree = (*rootp)->child[1];
tl_assert(right_subtree);
vg_assert(right_subtree);
ch = avl_remove_wrk(&right_subtree, a, kCmp);
(*rootp)->child[1] = right_subtree;
if (ch) {
@ -317,7 +317,7 @@ Bool avl_remove_wrk ( AvlNode** rootp,
case 1: return True;
case 0: return False;
case -1: break;
default: tl_assert(0);
default: vg_assert(0);
}
switch ((*rootp)->child[0]->balance) {
case 0:
@ -333,7 +333,7 @@ Bool avl_remove_wrk ( AvlNode** rootp,
case 1:
break;
default:
tl_assert(0);
vg_assert(0);
}
avl_swl( &((*rootp)->child[0]) );
avl_swr( rootp );
@ -342,8 +342,8 @@ Bool avl_remove_wrk ( AvlNode** rootp,
}
}
else {
tl_assert(cmpres == 0);
tl_assert((*rootp)==a);
vg_assert(cmpres == 0);
vg_assert((*rootp)==a);
return avl_removeroot_wrk(rootp, kCmp);
}
return 0;
@ -462,7 +462,7 @@ Bool avl_find_bounds ( AvlNode* t,
static void stackClear(WordFM* fm)
{
Int i;
tl_assert(fm);
vg_assert(fm);
for (i = 0; i < WFM_STKMAX; i++) {
fm->nodeStack[i] = NULL;
fm->numStack[i] = 0;
@ -473,8 +473,8 @@ static void stackClear(WordFM* fm)
// Push onto the iterator stack.
static inline void stackPush(WordFM* fm, AvlNode* n, Int i)
{
tl_assert(fm->stackTop < WFM_STKMAX);
tl_assert(1 <= i && i <= 3);
vg_assert(fm->stackTop < WFM_STKMAX);
vg_assert(1 <= i && i <= 3);
fm->nodeStack[fm->stackTop] = n;
fm-> numStack[fm->stackTop] = i;
fm->stackTop++;
@ -483,13 +483,13 @@ static inline void stackPush(WordFM* fm, AvlNode* n, Int i)
// Pop from the iterator stack.
static inline Bool stackPop(WordFM* fm, AvlNode** n, Int* i)
{
tl_assert(fm->stackTop <= WFM_STKMAX);
vg_assert(fm->stackTop <= WFM_STKMAX);
if (fm->stackTop > 0) {
fm->stackTop--;
*n = fm->nodeStack[fm->stackTop];
*i = fm-> numStack[fm->stackTop];
tl_assert(1 <= *i && *i <= 3);
vg_assert(1 <= *i && *i <= 3);
fm->nodeStack[fm->stackTop] = NULL;
fm-> numStack[fm->stackTop] = 0;
return True;
@ -692,7 +692,7 @@ UWord VG_(sizeFM) ( WordFM* fm )
// set up FM for iteration
void VG_(initIterFM) ( WordFM* fm )
{
tl_assert(fm);
vg_assert(fm);
stackClear(fm);
if (fm->root)
stackPush(fm, fm->root, 1);
@ -709,7 +709,7 @@ void VG_(initIterAtFM) ( WordFM* fm, UWord start_at )
Word cmpresS; /* signed */
UWord cmpresU; /* unsigned */
tl_assert(fm);
vg_assert(fm);
stackClear(fm);
if (!fm->root)
@ -744,20 +744,20 @@ void VG_(initIterAtFM) ( WordFM* fm, UWord start_at )
if (stackPop(fm, &n, &i)) {
// If we've pushed something to stack and did not find the exact key,
// we must fix the top element of stack.
tl_assert(i == 2);
vg_assert(i == 2);
stackPush(fm, n, 3);
// the stack looks like {2, 2, ..., 2, 3}
}
}
// get next key/val pair. Will tl_assert if fm has been modified
// get next key/val pair. Will vg_assert if fm has been modified
// or looked up in since initIter{,At}FM was called.
Bool VG_(nextIterFM) ( WordFM* fm, /*OUT*/UWord* pKey, /*OUT*/UWord* pVal )
{
Int i = 0;
AvlNode* n = NULL;
tl_assert(fm);
vg_assert(fm);
// This in-order traversal requires each node to be pushed and popped
// three times. These could be avoided by updating nodes in-situ on the
@ -780,7 +780,7 @@ Bool VG_(nextIterFM) ( WordFM* fm, /*OUT*/UWord* pKey, /*OUT*/UWord* pVal )
if (n->child[1]) { n = n->child[1]; goto case_1; }
break;
default:
tl_assert(0);
vg_assert(0);
}
}
@ -798,7 +798,7 @@ WordFM* VG_(dopyFM) ( WordFM* fm, UWord(*dopyK)(UWord), UWord(*dopyV)(UWord) )
WordFM* nyu;
/* can't clone the fm whilst iterating on it */
tl_assert(fm->stackTop == 0);
vg_assert(fm->stackTop == 0);
nyu = fm->alloc_nofail( fm->cc, sizeof(WordFM) );
@ -854,8 +854,8 @@ void VG_(addToBag)( WordBag* bag, UWord w )
{
UWord key, count;
if (VG_(lookupFM)(bag->fm, &key, &count, w)) {
tl_assert(key == w);
tl_assert(count >= 1);
vg_assert(key == w);
vg_assert(count >= 1);
VG_(addToFM)(bag->fm, w, count+1);
} else {
VG_(addToFM)(bag->fm, w, 1);
@ -866,8 +866,8 @@ UWord VG_(elemBag) ( WordBag* bag, UWord w )
{
UWord key, count;
if (VG_(lookupFM)( bag->fm, &key, &count, w)) {
tl_assert(key == w);
tl_assert(count >= 1);
vg_assert(key == w);
vg_assert(count >= 1);
return count;
} else {
return 0;
@ -883,7 +883,7 @@ static UWord sizeTotalBag_wrk ( AvlNode* nd )
{
/* unchecked pre: nd is non-NULL */
UWord w = nd->val;
tl_assert(w >= 1);
vg_assert(w >= 1);
if (nd->child[0])
w += sizeTotalBag_wrk(nd->child[0]);
if (nd->child[1])
@ -902,12 +902,12 @@ Bool VG_(delFromBag)( WordBag* bag, UWord w )
{
UWord key, count;
if (VG_(lookupFM)(bag->fm, &key, &count, w)) {
tl_assert(key == w);
tl_assert(count >= 1);
vg_assert(key == w);
vg_assert(count >= 1);
if (count > 1) {
VG_(addToFM)(bag->fm, w, count-1);
} else {
tl_assert(count == 1);
vg_assert(count == 1);
VG_(delFromFM)( bag->fm, NULL, NULL, w );
}
return True;
@ -927,9 +927,9 @@ Bool VG_(isSingletonTotalBag)( WordBag* bag )
if (VG_(sizeFM)(bag->fm) != 1)
return False;
nd = bag->fm->root;
tl_assert(nd);
tl_assert(!nd->child[0]);
tl_assert(!nd->child[1]);
vg_assert(nd);
vg_assert(!nd->child[0]);
vg_assert(!nd->child[1]);
return nd->val == 1;
}
@ -938,8 +938,8 @@ UWord VG_(anyElementOfBag)( WordBag* bag )
/* Return an arbitrarily chosen element in the bag. We might as
well return the one at the root of the underlying AVL tree. */
AvlNode* nd = bag->fm->root;
tl_assert(nd); /* if this fails, 'bag' is empty - caller is in error. */
tl_assert(nd->val >= 1);
vg_assert(nd); /* if this fails, 'bag' is empty - caller is in error. */
vg_assert(nd->val >= 1);
return nd->key;
}

View File

@ -43,7 +43,7 @@
// statement. This lets us say "x = VG_TDICT_CALL(...)" in the required
// places, while still checking the assertion.
#define VG_TDICT_CALL(fn, args...) \
( tl_assert2(VG_(tdict).fn, \
( vg_assert2(VG_(tdict).fn, \
"you forgot to set VgToolInterface function '" #fn "'"), \
VG_(tdict).fn(args) )

View File

@ -10,6 +10,8 @@
# (4) tool *.[ch] files must not include pub_core_...h
# (5) include pub_core/tool_clreq.h instead of valgrind.h except in tools'
# export headers
# (6) coregrind/ *.[ch] must not use tl_assert
# (7) include/*.h must not use vg_assert
#-------------------------------------------------------------------
use strict;
@ -205,6 +207,7 @@ sub get_included_files {
#---------------------------------------------------------------------
sub check_coregrind_export_header {
my ($path_name) = @_;
my $file = basename($path_name);
foreach my $inc (get_included_files($path_name)) {
$inc = basename($inc);
@ -217,6 +220,11 @@ sub check_coregrind_export_header {
error("File $path_name should include pub_tool_clreq.h instead of $inc\n");
}
}
# Must not use vg_assert
my $assert = `grep vg_assert $file`;
if ($assert ne "") {
error("File $path_name must not use vg_assert\n");
}
}
#---------------------------------------------------------------------
@ -241,6 +249,11 @@ sub check_coregrind_file {
error("File $path_name should include pub_core_clreq.h instead of $inc\n");
}
}
# Must not use tl_assert
my $assert = `grep tl_assert $file`;
if ($assert ne "") {
error("File $path_name must not use tl_assert\n");
}
}
#---------------------------------------------------------------------
@ -261,6 +274,11 @@ sub check_tool_file {
error("File $path_name should include pub_tool_clreq.h instead of $inc\n");
}
}
# Must not use vg_assert
my $assert = `grep vg_assert $file`;
if ($assert ne "") {
error("File $path_name must not use vg_assert\n");
}
}
sub process_file {