blob: 1fbf21b3472d798315301d800f3b29efb911a24d [file] [log] [blame]
Magnus Jedvert7510e4a2019-01-20 11:46:32 +01001/*
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
17namespace webrtc {
18
19struct 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.
34std::vector<StackTraceElement> GetStackTrace(int tid);
35
36// Get a string representation of the stack trace in a format ndk-stack accepts.
37std::string StackTraceToString(
38 const std::vector<StackTraceElement>& stack_trace);
39
40} // namespace webrtc
41
42#endif // SDK_ANDROID_NATIVE_API_STACKTRACE_STACKTRACE_H_