Line data Source code
1 : // Copyright (c) 2014-2021 The Dash Core developers 2 : // Distributed under the MIT/X11 software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : 5 : #ifndef BITCOIN_STACKTRACES_H 6 : #define BITCOIN_STACKTRACES_H 7 : 8 : #include <string> 9 : #include <sstream> 10 : #include <exception> 11 : 12 : #include <cxxabi.h> 13 : 14 : std::string DemangleSymbol(const std::string& name); 15 : 16 : std::string GetPrettyExceptionStr(const std::exception_ptr& e); 17 : std::string GetCrashInfoStrFromSerializedStr(const std::string& ciStr); 18 : 19 : template<typename T> 20 : std::string GetExceptionWhat(const T& e); 21 : 22 : template<> 23 0 : inline std::string GetExceptionWhat(const std::exception& e) 24 : { 25 0 : return e.what(); 26 : } 27 : 28 : // Default implementation 29 : template<typename T> 30 0 : inline std::string GetExceptionWhat(const T& e) 31 : { 32 0 : std::ostringstream s; 33 0 : s << e; 34 0 : return s.str(); 35 0 : } 36 : 37 : void RegisterPrettyTerminateHander(); 38 : void RegisterPrettySignalHandlers(); 39 : 40 : #endif // BITCOIN_STACKTRACES_H