• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2019 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef SDK_ANDROID_NATIVE_API_STACKTRACE_STACKTRACE_H_
12 #define SDK_ANDROID_NATIVE_API_STACKTRACE_STACKTRACE_H_
13 
14 #include <string>
15 #include <vector>
16 
17 namespace webrtc {
18 
19 struct StackTraceElement {
20   // Pathname of shared object (.so file) that contains address.
21   const char* shared_object_path;
22   // Execution address relative to the .so base address. This matches the
23   // addresses you get with "nm", "objdump", and "ndk-stack", as long as the
24   // code is compiled with position-independent code. Android requires
25   // position-independent code since Lollipop.
26   uint32_t relative_address;
27   // Name of symbol whose definition overlaps the address. This value is null
28   // when symbol names are stripped.
29   const char* symbol_name;
30 };
31 
32 // Utility to unwind stack for a given thread on Android ARM devices. This works
33 // on top of unwind.h and unwinds native (C++) stack traces only.
34 std::vector<StackTraceElement> GetStackTrace(int tid);
35 
36 // Unwind the stack of the current thread.
37 std::vector<StackTraceElement> GetStackTrace();
38 
39 // Get a string representation of the stack trace in a format ndk-stack accepts.
40 std::string StackTraceToString(
41     const std::vector<StackTraceElement>& stack_trace);
42 
43 }  // namespace webrtc
44 
45 #endif  // SDK_ANDROID_NATIVE_API_STACKTRACE_STACKTRACE_H_
46