diff options
Diffstat (limited to 'include/backtrace/Backtrace.h')
-rw-r--r-- | include/backtrace/Backtrace.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/include/backtrace/Backtrace.h b/include/backtrace/Backtrace.h index bd4134c..e07d322 100644 --- a/include/backtrace/Backtrace.h +++ b/include/backtrace/Backtrace.h @@ -17,6 +17,7 @@ #ifndef _BACKTRACE_BACKTRACE_H #define _BACKTRACE_BACKTRACE_H +#include <inttypes.h> #include <stdint.h> #include <string> @@ -25,6 +26,14 @@ #include <backtrace/backtrace_constants.h> #include <backtrace/BacktraceMap.h> +#if __LP64__ +#define PRIPTR "016" PRIxPTR +typedef uint64_t word_t; +#else +#define PRIPTR "08" PRIxPTR +typedef uint32_t word_t; +#endif + struct backtrace_frame_data_t { size_t num; // The current fame number. uintptr_t pc; // The absolute pc. @@ -38,6 +47,14 @@ struct backtrace_frame_data_t { // Forward declarations. class BacktraceImpl; +#if defined(__APPLE__) +struct __darwin_ucontext; +typedef __darwin_ucontext ucontext_t; +#else +struct ucontext; +typedef ucontext ucontext_t; +#endif + class Backtrace { public: // Create the correct Backtrace object based on what is to be unwound. @@ -55,7 +72,7 @@ public: virtual ~Backtrace(); // Get the current stack trace and store in the backtrace_ structure. - virtual bool Unwind(size_t num_ignore_frames); + virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL); // Get the function name and offset into the function given the pc. // If the string is empty, then no valid function name was found. @@ -65,7 +82,7 @@ public: virtual const backtrace_map_t* FindMap(uintptr_t pc); // Read the data at a specific address. - virtual bool ReadWord(uintptr_t ptr, uint32_t* out_value) = 0; + virtual bool ReadWord(uintptr_t ptr, word_t* out_value) = 0; // Create a string representing the formatted line of backtrace information // for a single frame. @@ -96,7 +113,7 @@ public: protected: Backtrace(BacktraceImpl* impl, pid_t pid, BacktraceMap* map); - virtual bool VerifyReadWordArgs(uintptr_t ptr, uint32_t* out_value); + virtual bool VerifyReadWordArgs(uintptr_t ptr, word_t* out_value); bool BuildMap(); |