summaryrefslogtreecommitdiff
path: root/src/main/util.cpp
diff options
context:
space:
mode:
authorTim King <taking@google.com>2016-01-05 11:36:30 -0800
committerTim King <taking@google.com>2016-01-05 11:36:30 -0800
commitb717513e2a1d956c4456d13e0625957fc84c2449 (patch)
tree50b8a1fbd720fd5094004bde02de0ca61780df30 /src/main/util.cpp
parent541c88a37f0880d7ea42a1aaa3a8688fc86ac811 (diff)
Adding a new class LastExceptionBuffer for the purpose of owning the memory for the last exception C string. This replaces s_debugLastException.
Diffstat (limited to 'src/main/util.cpp')
-rw-r--r--src/main/util.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/util.cpp b/src/main/util.cpp
index ce4e4509d..bc3d45287 100644
--- a/src/main/util.cpp
+++ b/src/main/util.cpp
@@ -44,7 +44,7 @@ using namespace std;
namespace CVC4 {
#ifdef CVC4_DEBUG
- extern CVC4_THREADLOCAL(const char*) s_debugLastException;
+//extern CVC4_THREADLOCAL(const char*) s_debugLastException;
#endif /* CVC4_DEBUG */
namespace main {
@@ -167,12 +167,14 @@ void cvc4unexpected() {
"CVC4 threw an \"unexpected\" exception (one that wasn't properly "
"specified\nin the throws() specifier for the throwing function)."
"\n\n");
- if(CVC4::s_debugLastException == NULL) {
+
+ const char* lastContents = LastExceptionBuffer::currentContents();
+
+ if(lastContents == NULL) {
fprintf(stderr,
"The exception is unknown (maybe it's not a CVC4::Exception).\n\n");
} else {
- fprintf(stderr, "The exception is:\n%s\n\n",
- static_cast<const char*>(CVC4::s_debugLastException));
+ fprintf(stderr, "The exception is:\n%s\n\n", lastContents);
}
if(!segvSpin) {
if((*pOptions)[options::statistics] && pExecutor != NULL) {
@@ -201,6 +203,10 @@ void cvc4unexpected() {
void cvc4terminate() {
set_terminate(default_terminator);
#ifdef CVC4_DEBUG
+ LastExceptionBuffer* current = LastExceptionBuffer::getCurrent();
+ LastExceptionBuffer::setCurrent(NULL);
+ delete current;
+
fprintf(stderr, "\n"
"CVC4 was terminated by the C++ runtime.\n"
"Perhaps an exception was thrown during stack unwinding. "
@@ -224,6 +230,10 @@ void cvc4terminate() {
/** Initialize the driver. Sets signal handlers for SIGINT and SIGSEGV. */
void cvc4_init() throw(Exception) {
+#ifdef CVC4_DEBUG
+ LastExceptionBuffer::setCurrent(new LastExceptionBuffer());
+#endif
+
#ifndef __WIN32__
stack_t ss;
ss.ss_sp = malloc(SIGSTKSZ);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback