Browse Source

Merge branch 'master' of https://sselab.de/lab9/private/git/storm

tempestpy_adaptions
dehnert 12 years ago
parent
commit
525fc7c16f
  1. 4
      src/storm.cpp
  2. 64
      src/utility/ErrorHandling.h

4
src/storm.cpp

@ -28,6 +28,7 @@
#include "src/parser/AutoParser.h" #include "src/parser/AutoParser.h"
#include "src/parser/PrctlParser.h" #include "src/parser/PrctlParser.h"
#include "src/utility/Settings.h" #include "src/utility/Settings.h"
#include "src/utility/ErrorHandling.h"
#include "src/formula/Formulas.h" #include "src/formula/Formulas.h"
#include "log4cplus/logger.h" #include "log4cplus/logger.h"
@ -458,6 +459,9 @@ void testChecking() {
* Main entry point. * Main entry point.
*/ */
int main(const int argc, const char* argv[]) { int main(const int argc, const char* argv[]) {
// Catch segfaults and display a backtrace.
installSignalHandler();
printHeader(argc, argv); printHeader(argc, argv);
initializeLogger(); initializeLogger();

64
src/utility/ErrorHandling.h

@ -0,0 +1,64 @@
/*
* File: ErrorHandling.h
* Author: Gereon Kremer
*
* Created on March 15, 2013, 4:10 PM
*/
#ifndef ERRORHANDLING_H
#define ERRORHANDLING_H
#include <signal.h>
#include <execinfo.h>
#include <cxxabi.h>
std::string demangle(const char* symbol) {
int status;
// Attention: sscanf format strings rely on size being 128
char temp[128];
char* demangled;
// Check for C++ symbol
if (sscanf(symbol, "%*[^(]%*[^_]%127[^)+]", temp) == 1) {
if (NULL != (demangled = abi::__cxa_demangle(temp, NULL, NULL, &status))) {
std::string result(demangled);
free(demangled);
return result;
}
}
// Check for C symbol
if (sscanf(symbol, "%127s", temp) == 1) {
return temp;
}
// Return plain symbol
return symbol;
}
void signalHandler(int sig) {
#define SIZE 128
LOG4CPLUS_FATAL(logger, "We recieved a segfault. To start with, here is a backtrace.");
void *buffer[SIZE];
char **strings;
int nptrs;
nptrs = backtrace(buffer, SIZE);
strings = backtrace_symbols(buffer, nptrs);
if (strings == nullptr) {
std::cerr << "Obtaining the backtrace symbols failed. Well, shit." << std::endl;
exit(2);
}
// j = 2: skip the handler itself.
for (int j = 1; j < nptrs; j++) {
LOG4CPLUS_FATAL(logger, nptrs-j << ": " << demangle(strings[j]));
}
free(strings);
LOG4CPLUS_FATAL(logger, "That's all we can do. Bye.");
exit(2);
}
void installSignalHandler() {
signal(SIGSEGV, signalHandler);
}
#endif /* ERRORHANDLING_H */
Loading…
Cancel
Save