From ed0e2f7a6fe721175b80f6397c9abd5c0080033f Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 24 May 2013 14:38:36 +0200 Subject: Added log_assert() api --- frontends/ast/ast.cc | 3 +-- kernel/celltypes.h | 6 ++++-- kernel/log.h | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index 2c552ea2..f4231395 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -140,8 +140,7 @@ std::string AST::type2str(AstNodeType type) X(AST_EDGE) #undef X default: - assert(!"Missing enum to string def in AST::type2str()."); - abort(); + log_abort(); } } diff --git a/kernel/celltypes.h b/kernel/celltypes.h index bf5ef4b3..cc84251c 100644 --- a/kernel/celltypes.h +++ b/kernel/celltypes.h @@ -24,6 +24,9 @@ #include #include +#include +#include + struct CellTypes { std::set cell_types; @@ -225,8 +228,7 @@ struct CellTypes if (type == "$_XOR_") return const_xor(arg1, arg2, false, false, 1); - assert(!"Called CellType.eval() with unsupported cell type!"); - abort(); + log_abort(); } static RTLIL::Const eval(RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2) diff --git a/kernel/log.h b/kernel/log.h index 6d190034..a1b129aa 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -49,5 +49,6 @@ void log_flush(); const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true); #define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__) +#define log_assert(_assert_expr_) do { if (_assert_expr_) break; log_error("Assert `%s' failed in %s:%d.\n", #_assert_expr_, __FILE__, __LINE__); } while (0) #endif -- cgit v1.2.3