Last change
on this file was
2573,
checked in by ymipsl, 10 months ago
|
create new external source lib : cpptrace, for statck trace output
YM
|
File size:
705 bytes
|
Line | |
---|
1 | #ifdef CPPTRACE_UNWIND_WITH_EXECINFO |
---|
2 | |
---|
3 | #include "unwind.hpp" |
---|
4 | #include "common.hpp" |
---|
5 | |
---|
6 | #include <algorithm> |
---|
7 | #include <cstddef> |
---|
8 | #include <vector> |
---|
9 | |
---|
10 | #include <execinfo.h> |
---|
11 | |
---|
12 | namespace cpptrace { |
---|
13 | namespace detail { |
---|
14 | CPPTRACE_FORCE_NO_INLINE |
---|
15 | std::vector<void*> capture_frames(size_t skip) { |
---|
16 | std::vector<void*> frames(hard_max_frames + skip, nullptr); |
---|
17 | const int n_frames = backtrace(frames.data(), int(hard_max_frames + skip)); // thread safe |
---|
18 | frames.resize(n_frames); |
---|
19 | frames.erase(frames.begin(), frames.begin() + ptrdiff_t(std::min(skip + 1, frames.size()))); |
---|
20 | frames.shrink_to_fit(); |
---|
21 | return frames; |
---|
22 | } |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.