From a584a6773c288bd98d11bf2a46d5db05c7f4f3a2 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Mon, 15 Sep 2014 20:57:45 +0000 Subject: [PATCH] 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 --- coregrind/m_addrinfo.c | 8 ++-- coregrind/m_debuginfo/d3basics.c | 12 ++--- coregrind/m_debuginfo/debuginfo.c | 32 ++++++------- coregrind/m_debuginfo/misc.c | 2 +- coregrind/m_debuginfo/readdwarf3.c | 6 +-- coregrind/m_debuginfo/storage.c | 4 +- coregrind/m_debuginfo/tytypes.c | 6 +-- coregrind/m_errormgr.c | 4 +- coregrind/m_execontext.c | 4 +- coregrind/m_gdbserver/server.c | 8 ++-- coregrind/m_libcprint.c | 2 +- coregrind/m_machine.c | 4 +- coregrind/m_main.c | 10 ++-- coregrind/m_mallocfree.c | 18 +++---- coregrind/m_options.c | 2 +- coregrind/m_redir.c | 8 ++-- coregrind/m_translate.c | 6 +-- coregrind/m_wordfm.c | 76 +++++++++++++++--------------- coregrind/pub_core_tooliface.h | 2 +- tests/check_headers_and_includes | 18 +++++++ 20 files changed, 125 insertions(+), 107 deletions(-) diff --git a/coregrind/m_addrinfo.c b/coregrind/m_addrinfo.c index 49c8c5db9b..21fd41358a 100644 --- a/coregrind/m_addrinfo.c +++ b/coregrind/m_addrinfo.c @@ -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)( diff --git a/coregrind/m_debuginfo/d3basics.c b/coregrind/m_debuginfo/d3basics.c index f3d442edba..0d882ed07a 100644 --- a/coregrind/m_debuginfo/d3basics.c +++ b/coregrind/m_debuginfo/d3basics.c @@ -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 ); diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index ab11a5ab5a..33e16d6f23 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -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, ®s, 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, ®s, 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 ); diff --git a/coregrind/m_debuginfo/misc.c b/coregrind/m_debuginfo/misc.c index d4825a4636..430d4357f0 100644 --- a/coregrind/m_debuginfo/misc.c +++ b/coregrind/m_debuginfo/misc.c @@ -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; } diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index afc7b8bc66..995ef58bbd 100644 --- a/coregrind/m_debuginfo/readdwarf3.c +++ b/coregrind/m_debuginfo/readdwarf3.c @@ -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 ); diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c index efa04f35ae..3d8a13f0cb 100644 --- a/coregrind/m_debuginfo/storage.c +++ b/coregrind/m_debuginfo/storage.c @@ -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) diff --git a/coregrind/m_debuginfo/tytypes.c b/coregrind/m_debuginfo/tytypes.c index d80876c559..aece0a5e09 100644 --- a/coregrind/m_debuginfo/tytypes.c +++ b/coregrind/m_debuginfo/tytypes.c @@ -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; } diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index 02bf0e4bee..ae04087520 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -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++; diff --git a/coregrind/m_execontext.c b/coregrind/m_execontext.c index 8747bdb9eb..2901fd9271 100644 --- a/coregrind/m_execontext.c +++ b/coregrind/m_execontext.c @@ -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. */ diff --git a/coregrind/m_gdbserver/server.c b/coregrind/m_gdbserver/server.c index 072bd686eb..7f2e5c908d 100644 --- a/coregrind/m_gdbserver/server.c +++ b/coregrind/m_gdbserver/server.c @@ -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; diff --git a/coregrind/m_libcprint.c b/coregrind/m_libcprint.c index 46b488a5e8..8d30b00b81 100644 --- a/coregrind/m_libcprint.c +++ b/coregrind/m_libcprint.c @@ -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, diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c index 42d8ce8fd6..212673f802 100644 --- a/coregrind/m_machine.c +++ b/coregrind/m_machine.c @@ -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); } diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 131ac4fb8f..9663474dde 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -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 diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index c05cc0c775..a6a6705402 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -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"; diff --git a/coregrind/m_options.c b/coregrind/m_options.c index b188554045..0710c8d673 100644 --- a/coregrind/m_options.c +++ b/coregrind/m_options.c @@ -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. diff --git a/coregrind/m_redir.c b/coregrind/m_redir.c index 9aee707f18..5aec0b3e4f 100644 --- a/coregrind/m_redir.c +++ b/coregrind/m_redir.c @@ -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); } diff --git a/coregrind/m_translate.c b/coregrind/m_translate.c index 0b3d964aec..32e026c6e5 100644 --- a/coregrind/m_translate.c +++ b/coregrind/m_translate.c @@ -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. */ diff --git a/coregrind/m_wordfm.c b/coregrind/m_wordfm.c index 203824512d..0685c7f7bf 100644 --- a/coregrind/m_wordfm.c +++ b/coregrind/m_wordfm.c @@ -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; } diff --git a/coregrind/pub_core_tooliface.h b/coregrind/pub_core_tooliface.h index 5c129030d8..e9d3631164 100644 --- a/coregrind/pub_core_tooliface.h +++ b/coregrind/pub_core_tooliface.h @@ -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) ) diff --git a/tests/check_headers_and_includes b/tests/check_headers_and_includes index f234320d92..0215d49b58 100755 --- a/tests/check_headers_and_includes +++ b/tests/check_headers_and_includes @@ -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 { -- 2.47.2