
This is a reland of dc32cc00e80972223767be339f9318b803f4a2ae Relanding because this CL was not the culprit for the Chrome bot. (This code shouldn't even be executed in Chrome). Original change's description: > Android: Add helper methods for printing native stack traces > > This CL adds utility functions to unwind the stack for a given thread on > Android ARM devices. This works on top of unwind.h and unwinds native > (C++) stack traces only. Unwinding a thread from another thread is done > by overriding the signal handler with a custom function and then > interrupting the specific thread. > > Bug: webrtc:10168 > Change-Id: If5adffd3a6bb57bf502168743e09a7eefc292bf3 > Reviewed-on: https://webrtc-review.googlesource.com/c/118141 > Commit-Queue: Magnus Jedvert <magjed@webrtc.org> > Reviewed-by: Tommi <tommi@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#26328} TBR=tommi Bug: webrtc:10168 Change-Id: I4c33c2c147cf10c0172c98a55d32dd35a08517c8 Reviewed-on: https://webrtc-review.googlesource.com/c/118704 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26341}
43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
/*
|
|
* Copyright 2019 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef SDK_ANDROID_NATIVE_API_STACKTRACE_STACKTRACE_H_
|
|
#define SDK_ANDROID_NATIVE_API_STACKTRACE_STACKTRACE_H_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace webrtc {
|
|
|
|
struct StackTraceElement {
|
|
// Pathname of shared object (.so file) that contains address.
|
|
const char* shared_object_path;
|
|
// Execution address relative to the .so base address. This matches the
|
|
// addresses you get with "nm", "objdump", and "ndk-stack", as long as the
|
|
// code is compiled with position-independent code. Android requires
|
|
// position-independent code since Lollipop.
|
|
uint32_t relative_address;
|
|
// Name of symbol whose definition overlaps the address. This value is null
|
|
// when symbol names are stripped.
|
|
const char* symbol_name;
|
|
};
|
|
|
|
// Utility to unwind stack for a given thread on Android ARM devices. This works
|
|
// on top of unwind.h and unwinds native (C++) stack traces only.
|
|
std::vector<StackTraceElement> GetStackTrace(int tid);
|
|
|
|
// Get a string representation of the stack trace in a format ndk-stack accepts.
|
|
std::string StackTraceToString(
|
|
const std::vector<StackTraceElement>& stack_trace);
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // SDK_ANDROID_NATIVE_API_STACKTRACE_STACKTRACE_H_
|