line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#include "SharedObjectInfo.h" |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
#include |
9
|
|
|
|
|
|
|
#include |
10
|
|
|
|
|
|
|
#include |
11
|
|
|
|
|
|
|
#include |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
namespace panda { namespace backtrace { |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
namespace dwarf { |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
const constexpr std::size_t max_inline = 10; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
struct HighLow { |
20
|
|
|
|
|
|
|
Dwarf_Addr high; |
21
|
|
|
|
|
|
|
Dwarf_Addr low; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
enum class Scan { found, not_found, dead_end }; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
struct DieHolder; |
27
|
|
|
|
|
|
|
struct LookupResult; |
28
|
|
|
|
|
|
|
struct DieRC; |
29
|
|
|
|
|
|
|
using DieSP = panda::iptr; |
30
|
|
|
|
|
|
|
struct CU; |
31
|
|
|
|
|
|
|
using CUSP = panda::iptr; |
32
|
|
|
|
|
|
|
using DieCollection = std::list; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
struct FunctionDetails { |
35
|
|
|
|
|
|
|
panda::string name; |
36
|
|
|
|
|
|
|
DieSP name_die = nullptr; |
37
|
|
|
|
|
|
|
std::uint64_t line_no = 0; |
38
|
|
|
|
|
|
|
panda::string source; |
39
|
|
|
|
|
|
|
std::uint32_t mask = 0; |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
struct DieRC: panda::Refcnt { |
43
|
|
|
|
|
|
|
Dwarf_Die die; |
44
|
|
|
|
|
|
|
Dwarf_Debug debug; |
45
|
|
|
|
|
|
|
DieSP parent; |
46
|
|
|
|
|
|
|
DieCollection context; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
struct FQN { |
49
|
|
|
|
|
|
|
string full_name; |
50
|
|
|
|
|
|
|
DieSP source_die; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
DieRC(Dwarf_Die die_, Dwarf_Debug debug_, DieSP parent_); |
54
|
|
|
|
|
|
|
~DieRC(); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
panda::optional get_addr() noexcept; |
57
|
|
|
|
|
|
|
Scan contains(std::uint64_t offset) noexcept; |
58
|
|
|
|
|
|
|
DieSP resolve_ref(DieSP source, Dwarf_Half attribute) noexcept; |
59
|
|
|
|
|
|
|
DieSP discover(DieSP target) noexcept; |
60
|
|
|
|
|
|
|
DieSP discover(Dwarf_Off target_offset, DieSP node) noexcept; |
61
|
|
|
|
|
|
|
FQN gather_fqn() noexcept; |
62
|
|
|
|
|
|
|
DieSP refine_location(std::uint64_t offset) noexcept; |
63
|
|
|
|
|
|
|
FunctionDetails refine_fn(LookupResult& lr) noexcept; |
64
|
|
|
|
|
|
|
void refine_fn_ao(DieSP abstract_origin, FunctionDetails& details) noexcept; |
65
|
|
|
|
|
|
|
void refine_fn_name(DieSP it, FunctionDetails& details) noexcept; |
66
|
|
|
|
|
|
|
void refine_fn_line(DieSP die, std::uint64_t offset, FunctionDetails& details) noexcept; |
67
|
|
|
|
|
|
|
void refine_fn_line_fallback(DieSP it, FunctionDetails& details) noexcept; |
68
|
|
|
|
|
|
|
void refine_fn_source(DieSP it, FunctionDetails& details, CU& cu) noexcept; |
69
|
|
|
|
|
|
|
void refine_fn_spec(DieSP specification, FunctionDetails& details) noexcept; |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
struct LookupResult { |
73
|
0
|
|
|
|
|
|
LookupResult(CU& root_) noexcept: root{CUSP{&root_}} {} |
74
|
|
|
|
|
|
|
LookupResult(const LookupResult&) = delete; |
75
|
|
|
|
|
|
|
LookupResult(LookupResult&&); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
bool is_complete() noexcept; |
78
|
|
|
|
|
|
|
bool get_frames(std::uint64_t ip, const SharedObjectInfo& so, StackFrames& frames) noexcept; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
CUSP root; |
81
|
|
|
|
|
|
|
DieSP cu; |
82
|
|
|
|
|
|
|
DieSP subprogram; |
83
|
|
|
|
|
|
|
std::uint64_t offset{0}; |
84
|
|
|
|
|
|
|
}; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
struct CU: panda::Refcnt { |
87
|
|
|
|
|
|
|
Dwarf_Debug debug; |
88
|
|
|
|
|
|
|
int number; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Dwarf_Unsigned header_length = 0; |
91
|
|
|
|
|
|
|
Dwarf_Unsigned abbrev_offset = 0; |
92
|
|
|
|
|
|
|
Dwarf_Half address_size = 0; |
93
|
|
|
|
|
|
|
Dwarf_Half version_stamp = 0; |
94
|
|
|
|
|
|
|
Dwarf_Half offset_size = 0; |
95
|
|
|
|
|
|
|
Dwarf_Half extension_size = 0; |
96
|
|
|
|
|
|
|
Dwarf_Unsigned typeoffset = 0; |
97
|
|
|
|
|
|
|
Dwarf_Half header_type = DW_UT_compile; |
98
|
|
|
|
|
|
|
Dwarf_Sig8 signature; |
99
|
|
|
|
|
|
|
Dwarf_Off cu_offset = 0; |
100
|
|
|
|
|
|
|
DieSP cu_die; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
char **sources = nullptr; |
103
|
|
|
|
|
|
|
Dwarf_Signed sources_count = 0; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
CU(Dwarf_Debug debug, int number_); |
106
|
|
|
|
|
|
|
~CU(); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
LookupResult resolve(std::uint64_t offset) noexcept; |
109
|
|
|
|
|
|
|
void resolve(std::uint64_t offset, DieSP& root, LookupResult& lr) noexcept; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
string get_source(size_t index) noexcept; |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
struct DwarfInfo; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
struct DwarfInfo { |
119
|
|
|
|
|
|
|
using file_guard_t = std::unique_ptr>; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
SharedObjectInfo so_info; |
122
|
|
|
|
|
|
|
Dwarf_Ptr err_arg = nullptr; |
123
|
|
|
|
|
|
|
Dwarf_Debug debug = nullptr; |
124
|
|
|
|
|
|
|
std::list CUs; |
125
|
|
|
|
|
|
|
file_guard_t guard; |
126
|
|
|
|
|
|
|
|
127
|
1054
|
|
|
|
|
|
DwarfInfo(const SharedObjectInfo& info_):so_info{info_}{} |
128
|
|
|
|
|
|
|
~DwarfInfo(); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
bool load(file_guard_t&& guard) noexcept; |
131
|
|
|
|
|
|
|
bool resolve(std::uint64_t ip, StackFrames& frames) noexcept; |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
using DwarfInfoMap = std::map>; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
void install_backtracer(); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
}} |