forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathstacktraces.h
40 lines (30 loc) · 956 Bytes
/
stacktraces.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2014-2021 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 BITCOIN_STACKTRACES_H
#define BITCOIN_STACKTRACES_H
#include <string>
#include <sstream>
#include <exception>
#include <cxxabi.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 // BITCOIN_STACKTRACES_H