diff options
author | Christopher Ferris | 2015-03-26 21:18:36 -0500 |
---|---|---|
committer | Christopher Ferris | 2015-03-31 12:51:44 -0500 |
commit | 2c43cff01d1271be451671567955158629b23670 (patch) | |
tree | b08d199b9cc4d0b665d7dc844cadedf883d0590c /include/backtrace | |
parent | e29744d94df787fa83307572d90a954b1592f69b (diff) | |
download | platform-system-core-2c43cff01d1271be451671567955158629b23670.tar.gz platform-system-core-2c43cff01d1271be451671567955158629b23670.tar.xz platform-system-core-2c43cff01d1271be451671567955158629b23670.zip |
Refactor the code.
The object hierarchy was confusing and convoluted. This removes
a lot of unnecessary code, and consolidates the BacktraceCurrent
and BacktraceThread code into BacktraceCurrent.
Change-Id: I01c8407d493712a48169df49dd3ff46db4a7c3ae
Diffstat (limited to 'include/backtrace')
-rw-r--r-- | include/backtrace/Backtrace.h | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/include/backtrace/Backtrace.h b/include/backtrace/Backtrace.h index 8c39acb38..290682a74 100644 --- a/include/backtrace/Backtrace.h +++ b/include/backtrace/Backtrace.h | |||
@@ -44,9 +44,6 @@ struct backtrace_frame_data_t { | |||
44 | uintptr_t func_offset; // pc relative to the start of the function, only valid if func_name is not NULL. | 44 | uintptr_t func_offset; // pc relative to the start of the function, only valid if func_name is not NULL. |
45 | }; | 45 | }; |
46 | 46 | ||
47 | // Forward declarations. | ||
48 | class BacktraceImpl; | ||
49 | |||
50 | #if defined(__APPLE__) | 47 | #if defined(__APPLE__) |
51 | struct __darwin_ucontext; | 48 | struct __darwin_ucontext; |
52 | typedef __darwin_ucontext ucontext_t; | 49 | typedef __darwin_ucontext ucontext_t; |
@@ -72,7 +69,7 @@ public: | |||
72 | virtual ~Backtrace(); | 69 | virtual ~Backtrace(); |
73 | 70 | ||
74 | // Get the current stack trace and store in the backtrace_ structure. | 71 | // Get the current stack trace and store in the backtrace_ structure. |
75 | virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL); | 72 | virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL) = 0; |
76 | 73 | ||
77 | // Get the function name and offset into the function given the pc. | 74 | // Get the function name and offset into the function given the pc. |
78 | // If the string is empty, then no valid function name was found. | 75 | // If the string is empty, then no valid function name was found. |
@@ -95,9 +92,9 @@ public: | |||
95 | virtual std::string FormatFrameData(size_t frame_num); | 92 | virtual std::string FormatFrameData(size_t frame_num); |
96 | virtual std::string FormatFrameData(const backtrace_frame_data_t* frame); | 93 | virtual std::string FormatFrameData(const backtrace_frame_data_t* frame); |
97 | 94 | ||
98 | pid_t Pid() { return pid_; } | 95 | pid_t Pid() const { return pid_; } |
99 | pid_t Tid() { return tid_; } | 96 | pid_t Tid() const { return tid_; } |
100 | size_t NumFrames() { return frames_.size(); } | 97 | size_t NumFrames() const { return frames_.size(); } |
101 | 98 | ||
102 | const backtrace_frame_data_t* GetFrame(size_t frame_num) { | 99 | const backtrace_frame_data_t* GetFrame(size_t frame_num) { |
103 | if (frame_num >= frames_.size()) { | 100 | if (frame_num >= frames_.size()) { |
@@ -117,7 +114,11 @@ public: | |||
117 | BacktraceMap* GetMap() { return map_; } | 114 | BacktraceMap* GetMap() { return map_; } |
118 | 115 | ||
119 | protected: | 116 | protected: |
120 | Backtrace(BacktraceImpl* impl, pid_t pid, BacktraceMap* map); | 117 | Backtrace(pid_t pid, pid_t tid, BacktraceMap* map); |
118 | |||
119 | // The name returned is not demangled, GetFunctionName() takes care of | ||
120 | // demangling the name. | ||
121 | virtual std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) = 0; | ||
121 | 122 | ||
122 | virtual bool VerifyReadWordArgs(uintptr_t ptr, word_t* out_value); | 123 | virtual bool VerifyReadWordArgs(uintptr_t ptr, word_t* out_value); |
123 | 124 | ||
@@ -130,10 +131,6 @@ protected: | |||
130 | bool map_shared_; | 131 | bool map_shared_; |
131 | 132 | ||
132 | std::vector<backtrace_frame_data_t> frames_; | 133 | std::vector<backtrace_frame_data_t> frames_; |
133 | |||
134 | BacktraceImpl* impl_; | ||
135 | |||
136 | friend class BacktraceImpl; | ||
137 | }; | 134 | }; |
138 | 135 | ||
139 | #endif // _BACKTRACE_BACKTRACE_H | 136 | #endif // _BACKTRACE_BACKTRACE_H |