Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Use Backward for printing pretty stack trace #706

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ addons:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
- libdw-dev
- verilator
before_install:
- export COREIRCONFIG="g++-4.9";
Expand Down
21 changes: 20 additions & 1 deletion include/coreir/ir/fwd_declare.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@

#include <execinfo.h>

#define ASSERT(C,MSG) \
#if BACKWARD_HAS_DW == 1

# include "coreir/tools/backward.hpp"
# define ASSERT(C,MSG) \
do { \
if (!(C)) { \
std::cerr << "ERROR: " << MSG << std::endl << std::endl; \
backward::StackTrace st; \
backward::Printer p; \
st.load_here(20); \
p.print(st, stderr); \
exit(1); \
} \
} while(0)

#else

# define ASSERT(C,MSG) \
do { \
if (!(C)) { \
void* array[20]; \
Expand All @@ -26,6 +43,8 @@
} \
} while(0)

#endif

typedef uint32_t uint;

namespace bsim {
Expand Down
Loading