Browse Source

HPCC-12104 Generate stack traces on unexpected execution exception

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 10 years ago
parent
commit
78b0667785
2 changed files with 17 additions and 2 deletions
  1. 12 0
      system/jlib/jexcept.cpp
  2. 5 2
      system/jlib/jexcept.hpp

+ 12 - 0
system/jlib/jexcept.cpp

@@ -497,6 +497,18 @@ void userBreakpoint()
 #endif
 }
 
+void throwUnexpectedException(const char * file, unsigned line)
+{
+    printStackReport();
+    throw makeStringExceptionV(9999, "Internal Error at %s(%d)", file, line);
+}
+
+void throwUnexpectedException(const char * where, const char * file, unsigned line)
+{
+    printStackReport();
+    throw makeStringExceptionV(9999, "Internal Error '%s' at %s(%d)", where, file, line);
+}
+
 void raiseAssertException(const char *assertion, const char *file, unsigned line)
 {
     printStackReport();

+ 5 - 2
system/jlib/jexcept.hpp

@@ -127,9 +127,12 @@ void jlib_decl setTerminateOnSEHInSystemDLLs(bool set=true);
 void jlib_decl setTerminateOnSEH(bool set=true);
 
 
+__declspec(noreturn) void jlib_decl throwUnexpectedException(const char * file, unsigned line) __attribute__((noreturn));
+__declspec(noreturn) void jlib_decl throwUnexpectedException(const char * where, const char * file, unsigned line) __attribute__((noreturn));
+
 #define makeUnexpectedException()  makeStringExceptionV(9999, "Internal Error at %s(%d)", __FILE__, __LINE__)
-#define throwUnexpected()          throw makeStringExceptionV(9999, "Internal Error at %s(%d)", __FILE__, __LINE__)
-#define throwUnexpectedX(x)        throw makeStringExceptionV(9999, "Internal Error '" x "' at %s(%d)", __FILE__, __LINE__)
+#define throwUnexpected()          throwUnexpectedException(__FILE__, __LINE__)
+#define throwUnexpectedX(x)        throwUnexpectedException(x, __FILE__, __LINE__)
 #define assertThrow(x)             assertex(x)
 
 #define UNIMPLEMENTED throw makeStringExceptionV(-1, "UNIMPLEMENTED feature at %s(%d)", __FILE__, __LINE__)