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