| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#if !defined(__APPLE__) && !defined(_WIN32) |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#include |
|
4
|
|
|
|
|
|
|
#include // PATH_MAX |
|
5
|
|
|
|
|
|
|
#include |
|
6
|
|
|
|
|
|
|
#include |
|
7
|
|
|
|
|
|
|
#include "dl.h" |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
namespace panda { namespace backtrace { |
|
11
|
|
|
|
|
|
|
|
|
12
|
8091
|
|
|
|
|
|
int dl_iterate(struct dl_phdr_info *info, size_t, void* data){ |
|
13
|
|
|
|
|
|
|
//printf("so: %s at %lx\n", info->dlpi_name, info->dlpi_addr); |
|
14
|
8091
|
50
|
|
|
|
|
if (info->dlpi_name) { |
|
15
|
16182
|
|
|
|
|
|
string name = string(info->dlpi_name); |
|
16
|
|
|
|
|
|
|
/* special case - read self */ |
|
17
|
8091
|
100
|
|
|
|
|
if (name.length() == 0) { |
|
18
|
522
|
50
|
|
|
|
|
name.reserve(PATH_MAX); |
|
19
|
522
|
50
|
|
|
|
|
auto len = readlink("/proc/self/exe", name.buf(), PATH_MAX); |
|
20
|
522
|
50
|
|
|
|
|
if (len > 0) { |
|
21
|
522
|
|
|
|
|
|
name.length(static_cast(len)); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
} |
|
24
|
8091
|
50
|
|
|
|
|
if (!name) { return 0; } |
|
25
|
|
|
|
|
|
|
|
|
26
|
8091
|
|
|
|
|
|
auto container = reinterpret_cast(data); |
|
27
|
8091
|
|
|
|
|
|
auto end = info->dlpi_addr; |
|
28
|
66294
|
100
|
|
|
|
|
for (int j = 0; j < info->dlpi_phnum; j++) { |
|
29
|
58203
|
|
|
|
|
|
auto& header = info->dlpi_phdr[j]; |
|
30
|
58203
|
|
|
|
|
|
auto s = info->dlpi_addr + header.p_vaddr; |
|
31
|
58203
|
|
|
|
|
|
auto e = s + header.p_memsz; |
|
32
|
58203
|
100
|
|
|
|
|
if (e > end) { end = e; } |
|
33
|
|
|
|
|
|
|
//printf("\t\t header %2d: address=%10p .. %10p [%s at %10p]\n", j, (void *) start, (void*) end, info->dlpi_name, info->dlpi_addr); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
8091
|
|
|
|
|
|
auto begin = static_cast(info->dlpi_addr); |
|
36
|
8091
|
50
|
|
|
|
|
container->emplace_back(SharedObjectInfo{begin, static_cast(end), false, name}); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
8091
|
|
|
|
|
|
return 0; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
261
|
|
|
|
|
|
void gather_info(SharedObjectMap& map) { |
|
44
|
261
|
|
|
|
|
|
dl_iterate_phdr(dl_iterate, &map); |
|
45
|
261
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
}} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#endif |