summaryrefslogtreecommitdiffstats
path: root/include/backtrace/Backtrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/backtrace/Backtrace.h')
-rw-r--r--include/backtrace/Backtrace.h33
1 files changed, 18 insertions, 15 deletions
diff --git a/include/backtrace/Backtrace.h b/include/backtrace/Backtrace.h
index e07d322..290682a 100644
--- a/include/backtrace/Backtrace.h
+++ b/include/backtrace/Backtrace.h
@@ -39,14 +39,11 @@ struct backtrace_frame_data_t {
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.
- const backtrace_map_t* map; // The map associated with the given pc.
+ backtrace_map_t map; // The map associated with the given pc.
std::string func_name; // The function name associated with this pc, NULL if not found.
uintptr_t func_offset; // pc relative to the start of the function, only valid if func_name is not NULL.
};
-// Forward declarations.
-class BacktraceImpl;
-
#if defined(__APPLE__)
struct __darwin_ucontext;
typedef __darwin_ucontext ucontext_t;
@@ -72,26 +69,32 @@ public:
virtual ~Backtrace();
// Get the current stack trace and store in the backtrace_ structure.
- virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL);
+ virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL) = 0;
// Get the function name and offset into the function given the pc.
// If the string is empty, then no valid function name was found.
virtual std::string GetFunctionName(uintptr_t pc, uintptr_t* offset);
- // Find the map associated with the given pc.
- virtual const backtrace_map_t* FindMap(uintptr_t pc);
+ // Fill in the map data associated with the given pc.
+ virtual void FillInMap(uintptr_t pc, backtrace_map_t* map);
// Read the data at a specific address.
virtual bool ReadWord(uintptr_t ptr, word_t* out_value) = 0;
+ // Read arbitrary data from a specific address. If a read request would
+ // span from one map to another, this call only reads up until the end
+ // of the current map.
+ // Returns the total number of bytes actually read.
+ virtual size_t Read(uintptr_t addr, uint8_t* buffer, size_t bytes) = 0;
+
// 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 pid_; }
- pid_t Tid() { return tid_; }
- size_t NumFrames() { return frames_.size(); }
+ pid_t Pid() const { return pid_; }
+ pid_t Tid() const { return tid_; }
+ size_t NumFrames() const { return frames_.size(); }
const backtrace_frame_data_t* GetFrame(size_t frame_num) {
if (frame_num >= frames_.size()) {
@@ -111,7 +114,11 @@ public:
BacktraceMap* GetMap() { return map_; }
protected:
- Backtrace(BacktraceImpl* impl, pid_t pid, BacktraceMap* map);
+ Backtrace(pid_t pid, pid_t tid, BacktraceMap* map);
+
+ // The name returned is not demangled, GetFunctionName() takes care of
+ // demangling the name.
+ virtual std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) = 0;
virtual bool VerifyReadWordArgs(uintptr_t ptr, word_t* out_value);
@@ -124,10 +131,6 @@ protected:
bool map_shared_;
std::vector<backtrace_frame_data_t> frames_;
-
- BacktraceImpl* impl_;
-
- friend class BacktraceImpl;
};
#endif // _BACKTRACE_BACKTRACE_H