diff options
Diffstat (limited to 'include/backtrace')
-rw-r--r-- | include/backtrace/Backtrace.h | 23 | ||||
-rw-r--r-- | include/backtrace/BacktraceMap.h | 3 |
2 files changed, 22 insertions, 4 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(); diff --git a/include/backtrace/BacktraceMap.h b/include/backtrace/BacktraceMap.h index 06da2f4..c717f09 100644 --- a/include/backtrace/BacktraceMap.h +++ b/include/backtrace/BacktraceMap.h @@ -18,6 +18,7 @@ #define _BACKTRACE_BACKTRACE_MAP_H #include <stdint.h> +#include <sys/types.h> #ifdef USE_MINGW // MINGW does not define these constants. #define PROT_NONE 0 @@ -45,7 +46,7 @@ public: virtual ~BacktraceMap(); // Get the map data structure for the given address. - const backtrace_map_t* Find(uintptr_t addr); + virtual const backtrace_map_t* Find(uintptr_t addr); // The flags returned are the same flags as used by the mmap call. // The values are PROT_*. |