diff options
Diffstat (limited to 'libbacktrace/UnwindPtrace.cpp')
-rw-r--r-- | libbacktrace/UnwindPtrace.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/libbacktrace/UnwindPtrace.cpp b/libbacktrace/UnwindPtrace.cpp index efe758b..a7c3de5 100644 --- a/libbacktrace/UnwindPtrace.cpp +++ b/libbacktrace/UnwindPtrace.cpp @@ -14,35 +14,36 @@ * limitations under the License. */ -#include <backtrace/Backtrace.h> -#include <backtrace/BacktraceMap.h> - +#include <stdint.h> #include <sys/types.h> -#include <string.h> #include <ucontext.h> #include <libunwind.h> #include <libunwind-ptrace.h> +#include <backtrace/Backtrace.h> +#include <backtrace/BacktraceMap.h> + #include "BacktraceLog.h" #include "UnwindMap.h" #include "UnwindPtrace.h" -UnwindPtrace::UnwindPtrace() : addr_space_(NULL), upt_info_(NULL) { +UnwindPtrace::UnwindPtrace(pid_t pid, pid_t tid, BacktraceMap* map) + : BacktracePtrace(pid, tid, map), addr_space_(nullptr), upt_info_(nullptr) { } UnwindPtrace::~UnwindPtrace() { if (upt_info_) { _UPT_destroy(upt_info_); - upt_info_ = NULL; + upt_info_ = nullptr; } if (addr_space_) { // Remove the map from the address space before destroying it. // It will be freed in the UnwindMap destructor. - unw_map_set(addr_space_, NULL); + unw_map_set(addr_space_, nullptr); unw_destroy_addr_space(addr_space_); - addr_space_ = NULL; + addr_space_ = nullptr; } } @@ -74,8 +75,6 @@ bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { return false; } - std::vector<backtrace_frame_data_t>* frames = GetFrames(); - frames->reserve(MAX_BACKTRACE_FRAMES); size_t num_frames = 0; do { unw_word_t pc; @@ -92,15 +91,15 @@ bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { } if (num_ignore_frames == 0) { - frames->resize(num_frames+1); - backtrace_frame_data_t* frame = &frames->at(num_frames); + frames_.resize(num_frames+1); + backtrace_frame_data_t* frame = &frames_.at(num_frames); frame->num = num_frames; frame->pc = static_cast<uintptr_t>(pc); frame->sp = static_cast<uintptr_t>(sp); frame->stack_size = 0; if (num_frames > 0) { - backtrace_frame_data_t* prev = &frames->at(num_frames-1); + backtrace_frame_data_t* prev = &frames_.at(num_frames-1); prev->stack_size = frame->sp - prev->sp; } @@ -129,10 +128,3 @@ std::string UnwindPtrace::GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) { } return ""; } - -//------------------------------------------------------------------------- -// C++ object creation function. -//------------------------------------------------------------------------- -Backtrace* CreatePtraceObj(pid_t pid, pid_t tid, BacktraceMap* map) { - return new BacktracePtrace(new UnwindPtrace(), pid, tid, map); -} |