Add BacktraceOffline for offline backtracing.
It is used by simpeleprf for stack unwinding.
Bug: 22229391
Change-Id: I26d698610ccdc9545da837bc5a8a9ec787f27a6b
diff --git a/include/backtrace/Backtrace.h b/include/backtrace/Backtrace.h
index 290682a..f440bd2 100644
--- a/include/backtrace/Backtrace.h
+++ b/include/backtrace/Backtrace.h
@@ -52,6 +52,12 @@
typedef ucontext ucontext_t;
#endif
+struct backtrace_stackinfo_t {
+ uint64_t start;
+ uint64_t end;
+ const uint8_t* data;
+};
+
class Backtrace {
public:
// Create the correct Backtrace object based on what is to be unwound.
@@ -66,6 +72,14 @@
// If map is not NULL, the map is still owned by the caller.
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. 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
+ // cache. It also assumes that the elf files used for each offline unwind are the same.
+ static Backtrace* CreateOffline(pid_t pid, pid_t tid, BacktraceMap* map,
+ const backtrace_stackinfo_t& stack, bool cache_file = false);
+
virtual ~Backtrace();
// Get the current stack trace and store in the backtrace_ structure.