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