dash/src/stacktraces.h
Alexander Block 780bffeb78 Enable stacktrace support in gitian builds (#3006)
* Remove use of -rdynamic

This causes check-symbols to fail horribly and also turned out to be not
required when using libbacktrace. It was only required when using
"backtrace()" from "<execinfo.h>"

* Remove spurious ], from configure.ac

* Add -DENABLE_STACKTRACES=1 to CMakeLists.txt

* Remove unused method my_backtrace_simple_callback

* Use fs::path().filename() instead of basename()

* Add static g_exeFileName and g_exeFileBaseName

* Use .exe.dbg file when available

* Use uint64_t instead of uintptr_t

* Implement GetBaseAddress() for unix and win32

* Implement unified crash_info and use it everywhere before printing crash info

* Print a serialized version of crash_info when there is no debug info

* Implement "-printcrashinfo" command line option

* Compile stacktrace support unconditionally and only make crash hooks conditional

This also renames the --enable-stacktraces option to --enable-crash-hooks

* Enable crash hooks in win/linux Gitian builds

* Try to load .debug file on MacOS and enable crash hooks for osx Gitian builds

* Check for dsymutil and if it needs --flat

* Create .debug files in osx Gitian build

* Handle review comments

* Also print crash description when no stacktrace is available

* Unconditionally add -g1 debug information

Instead of making it dependent on "--enable-crash-hooks". We will need the
debug info every time now, even in release builds.

* Put MacOS debug info into dSYM symbols instead of plain .debug files

* Implement MacOS specific GetBaseAddress
2019-07-02 07:16:11 +03:00

43 lines
970 B
C++

// Copyright (c) 2014-2019 The Dash Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef DASH_STACKTRACES_H
#define DASH_STACKTRACES_H
#include <string>
#include <sstream>
#include <exception>
#include <cxxabi.h>
#include "tinyformat.h"
std::string DemangleSymbol(const std::string& name);
std::string GetPrettyExceptionStr(const std::exception_ptr& e);
std::string GetCrashInfoStrFromSerializedStr(const std::string& ciStr);
template<typename T>
std::string GetExceptionWhat(const T& e);
template<>
inline std::string GetExceptionWhat(const std::exception& e)
{
return e.what();
}
// Default implementation
template<typename T>
inline std::string GetExceptionWhat(const T& e)
{
std::ostringstream s;
s << e;
return s.str();
}
void RegisterPrettyTerminateHander();
void RegisterPrettySignalHandlers();
#endif//DASH_STACKTRACES_H