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 StackframePtr = iptr; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
struct BacktraceInfo : Refcnt { |
23
|
|
|
|
|
|
|
virtual ~BacktraceInfo(); |
24
|
|
|
|
|
|
|
virtual const std::vector& get_frames() const = 0; |
25
|
|
|
|
|
|
|
virtual string to_string() const = 0; |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
using RawTrace = std::vector; |
29
|
|
|
|
|
|
|
using BacktraceProducer = iptr(*)(const RawTrace&); |
30
|
|
|
|
|
|
|
using RawTraceProducer = int(*)(void**, int); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
struct Backtrace { |
33
|
|
|
|
|
|
|
static const constexpr int max_depth = 50; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Backtrace () noexcept; |
36
|
|
|
|
|
|
|
Backtrace (const Backtrace &other) noexcept; |
37
|
|
|
|
|
|
|
virtual ~Backtrace (); |
38
|
|
|
|
|
|
|
Backtrace& operator=(const Backtrace& other) = default; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
iptr get_backtrace_info() const noexcept; |
41
|
|
|
|
|
|
|
const RawTrace& get_trace () const noexcept { return buffer; } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
static void install_producer(BacktraceProducer& producer); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
private: |
46
|
|
|
|
|
|
|
std::vector buffer; |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
template |
50
|
|
|
|
|
|
|
struct bt : T, Backtrace { |
51
|
|
|
|
|
|
|
template |
52
|
|
|
|
|
|
|
bt (Args&&... args) noexcept : T(std::forward(args...)) {} |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
struct exception : std::exception, Backtrace { |
56
|
|
|
|
|
|
|
exception () noexcept; |
57
|
|
|
|
|
|
|
exception (const string& whats) noexcept; |
58
|
|
|
|
|
|
|
exception (const exception& oth) noexcept; |
59
|
|
|
|
|
|
|
exception& operator= (const exception& oth) noexcept; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
const char* what () const noexcept override; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
virtual string whats () const noexcept; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
private: |
66
|
|
|
|
|
|
|
mutable string _whats; |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |