Next phase of the move, reformat use C++ features.
Use the libbacktrace C++ interface instead of the C interface in debuggerd.
Reformat the debuggerd code to be closer to Google C++ style.
Fix all debuggerd casts to be C++ casts.
Add a frame number to the frame data structure for ease of formatting and
add another FormatFrameData function.
Change the format_test to use the new FormatFrameData function.
Modify all of the backtrace_test to use the C++ interface.
Change-Id: I10e1610861acf7f4a3ad53276b74971cfbfda464
diff --git a/include/backtrace/Backtrace.h b/include/backtrace/Backtrace.h
index bf4efd3..df40b87 100644
--- a/include/backtrace/Backtrace.h
+++ b/include/backtrace/Backtrace.h
@@ -60,6 +60,7 @@
// Create a string representing the formatted line of backtrace information
// for a single frame.
virtual std::string FormatFrameData(size_t frame_num);
+ virtual std::string FormatFrameData(const backtrace_frame_data_t* frame);
pid_t Pid() { return backtrace_.pid; }
pid_t Tid() { return backtrace_.tid; }
@@ -68,9 +69,16 @@
const backtrace_t* GetBacktrace() { return &backtrace_; }
const backtrace_frame_data_t* GetFrame(size_t frame_num) {
+ if (frame_num > NumFrames()) {
+ return NULL;
+ }
return &backtrace_.frames[frame_num];
}
+ const backtrace_map_info_t* GetMapList() {
+ return map_info_;
+ }
+
protected:
Backtrace(BacktraceImpl* impl, pid_t pid, backtrace_map_info_t* map_info);
diff --git a/include/backtrace/backtrace.h b/include/backtrace/backtrace.h
index fa81f21..cfcbf0f 100644
--- a/include/backtrace/backtrace.h
+++ b/include/backtrace/backtrace.h
@@ -44,6 +44,7 @@
} backtrace_map_info_t;
typedef struct {
+ size_t num; /* The current fame number. */
uintptr_t pc; /* The absolute pc. */
uintptr_t sp; /* The top of the stack. */
size_t stack_size; /* The size of the stack, zero indicate an unknown stack size. */