line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
#include "string.h" |
5
|
|
|
|
|
|
|
#include "refcnt.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
namespace panda { |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
struct Stackframe: public Refcnt { |
10
|
|
|
|
|
|
|
string file; |
11
|
|
|
|
|
|
|
string library; |
12
|
|
|
|
|
|
|
string name; |
13
|
|
|
|
|
|
|
string mangled_name; |
14
|
|
|
|
|
|
|
std::uint64_t address = 0; |
15
|
|
|
|
|
|
|
std::uint64_t offset = 0; |
16
|
|
|
|
|
|
|
std::uint64_t line_no = 0; |
17
|
|
|
|
|
|
|
std::vector args; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
using StackframeSP = iptr; |
21
|
|
|
|
|
|
|
using StackFrames = std::vector; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
struct BacktraceBackend: Refcnt { |
24
|
|
|
|
|
|
|
virtual bool produce_frame(StackFrames& result, size_t i) = 0; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
using BacktraceBackendSP = iptr; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
struct BacktraceInfo : Refcnt { |
29
|
|
|
|
|
|
|
BacktraceInfo(std::vector&& frames_) : frames(std::move(frames_)) {} |
30
|
|
|
|
|
|
|
virtual ~BacktraceInfo(); |
31
|
|
|
|
|
|
|
const std::vector& get_frames() const noexcept { return frames;} |
32
|
|
|
|
|
|
|
virtual string to_string() const noexcept; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
StackFrames frames; |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
using BacktraceInfoSP = iptr; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
struct Backtrace; |
39
|
|
|
|
|
|
|
using RawTrace = std::vector; |
40
|
|
|
|
|
|
|
using RawTraceProducer = int(*)(void**, int); |
41
|
|
|
|
|
|
|
using BacktraceProducer = BacktraceBackendSP(*)(const Backtrace& raw_traces); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
struct Backtrace { |
44
|
|
|
|
|
|
|
static const constexpr int max_depth = 150; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Backtrace () noexcept; |
47
|
|
|
|
|
|
|
Backtrace (const Backtrace &other) noexcept; |
48
|
|
|
|
|
|
|
virtual ~Backtrace (); |
49
|
|
|
|
|
|
|
Backtrace& operator=(const Backtrace& other) = default; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
iptr get_backtrace_info() const noexcept; |
52
|
|
|
|
|
|
|
const RawTrace& get_trace () const noexcept { return buffer; } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
static void install_producer (const BacktraceProducer& producer) noexcept; |
55
|
|
|
|
|
|
|
static void uninstall_producer(const BacktraceProducer& producer) noexcept; |
56
|
|
|
|
|
|
|
static string dump_trace() noexcept; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
std::vector buffer; |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
template |
62
|
|
|
|
|
|
|
struct bt : T, Backtrace { |
63
|
|
|
|
|
|
|
template |
64
|
|
|
|
|
|
|
bt (Args&&... args) noexcept : T(std::forward(args...)) {} |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
struct exception : std::exception, Backtrace { |
68
|
|
|
|
|
|
|
exception () noexcept; |
69
|
|
|
|
|
|
|
exception (const string& whats) noexcept; |
70
|
|
|
|
|
|
|
exception (const exception& oth) noexcept; |
71
|
|
|
|
|
|
|
exception& operator= (const exception& oth) noexcept; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
const char* what () const noexcept override; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
virtual string whats () const noexcept; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
private: |
78
|
|
|
|
|
|
|
mutable string _whats; |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |