summaryrefslogtreecommitdiffstats
path: root/libbacktrace/include/backtrace/Backtrace.h
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-12-11 17:44:33 -0800
committerChristopher Ferris <cferris@google.com>2018-01-29 10:41:11 -0800
commitc8bec5aa91b20b0173bf6bf5f73f9e6daa40519d (patch)
treecada46a2ee86c8c6c22d563b605a5120caff0426 /libbacktrace/include/backtrace/Backtrace.h
parent8abe4e2638587957f621450b4e4c3ff7af310b08 (diff)
downloadsystem_core-c8bec5aa91b20b0173bf6bf5f73f9e6daa40519d.tar.gz
system_core-c8bec5aa91b20b0173bf6bf5f73f9e6daa40519d.tar.bz2
system_core-c8bec5aa91b20b0173bf6bf5f73f9e6daa40519d.zip
Use new unwinder for offline in libbacktrace.
libbbacktrace changes: - Completely rewrite the BacktraceOffline class to use the new unwinder. - Modify the test data to save ucontext_t data instead of unw_context data. - Convert the previous tests from unw_context data to ucontext_t data. Bug: 65682279 Test: New unit tests pass in libunwindstack. Test: All offline tests continue to pass. Change-Id: I540345c304b20199d46deeb0349a0638a0f3ab2f
Diffstat (limited to 'libbacktrace/include/backtrace/Backtrace.h')
-rw-r--r--libbacktrace/include/backtrace/Backtrace.h39
1 files changed, 27 insertions, 12 deletions
diff --git a/libbacktrace/include/backtrace/Backtrace.h b/libbacktrace/include/backtrace/Backtrace.h
index 18e9f61e8..7a37015d6 100644
--- a/libbacktrace/include/backtrace/Backtrace.h
+++ b/libbacktrace/include/backtrace/Backtrace.h
@@ -60,6 +60,10 @@ enum BacktraceUnwindErrorCode : uint32_t {
BACKTRACE_UNWIND_ERROR_FIND_PROC_INFO_FAILED,
// Failed to execute dwarf instructions in debug sections.
BACKTRACE_UNWIND_ERROR_EXECUTE_DWARF_INSTRUCTION_FAILED,
+ // Unwind information is incorrect.
+ BACKTRACE_UNWIND_ERROR_UNWIND_INFO,
+ // Unwind information stopped due to sp/pc repeating.
+ BACKTRACE_UNWIND_ERROR_REPEATED_FRAME,
};
struct BacktraceUnwindError {
@@ -87,14 +91,6 @@ struct backtrace_frame_data_t {
// NULL.
};
-#if defined(__APPLE__)
-struct __darwin_ucontext;
-typedef __darwin_ucontext ucontext_t;
-#else
-struct ucontext;
-typedef ucontext ucontext_t;
-#endif
-
struct backtrace_stackinfo_t {
uint64_t start;
uint64_t end;
@@ -106,7 +102,16 @@ class Regs;
}
class Backtrace {
-public:
+ public:
+ enum ArchEnum : uint8_t {
+ ARCH_ARM,
+ ARCH_ARM64,
+ ARCH_X86,
+ ARCH_X86_64,
+ };
+
+ static void SetGlobalElfCache(bool enable);
+
// Create the correct Backtrace object based on what is to be unwound.
// If pid < 0 or equals the current pid, then the Backtrace object
// corresponds to the current process.
@@ -120,6 +125,16 @@ public:
static Backtrace* Create(pid_t pid, pid_t tid, BacktraceMap* map = NULL);
// Create an offline Backtrace object that can be used to do an unwind without a process
+ // that is still running. By default, information is only cached in the map
+ // file. If the calling code creates the map, data can be cached between
+ // unwinds. If not, all cached data will be destroyed when the Backtrace
+ // object is destroyed.
+ static Backtrace* CreateOffline(ArchEnum arch, pid_t pid, pid_t tid,
+ const std::vector<backtrace_map_t>& maps,
+ const backtrace_stackinfo_t& stack);
+ static Backtrace* CreateOffline(ArchEnum arch, pid_t pid, pid_t tid, BacktraceMap* map);
+
+ // Create an offline Backtrace object that can be used to do an unwind without a process
// that is still running. If cache_file is set to true, then elf information will be cached
// for this call. The cached information survives until the calling process ends. This means
// that subsequent calls to create offline Backtrace objects will continue to use the same
@@ -130,11 +145,11 @@ 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) = 0;
+ virtual bool Unwind(size_t num_ignore_frames, void* context = NULL) = 0;
static bool Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames,
- std::vector<std::string>* skip_names);
+ std::vector<std::string>* skip_names, BacktraceUnwindError* error = nullptr);
// Get the function name and offset into the function given the pc.
// If the string is empty, then no valid function name was found,
@@ -184,7 +199,7 @@ public:
std::string GetErrorString(BacktraceUnwindError error);
-protected:
+ protected:
Backtrace(pid_t pid, pid_t tid, BacktraceMap* map);
// The name returned is not demangled, GetFunctionName() takes care of