Skip to content

Commit 5fce557

Browse files
authored
Feature/client side unwinding (#26)
Add support for client side unwinding If client side unwinding is enabled, then when there is a native/crashpad crash, the call stack will be resolved by the device (client) before submission to the Backtrace server. This allows better resolution of call stacks when symbols for native libraries are not available, e.g for syscalls or opaque libraries.
1 parent 7657719 commit 5fce557

File tree

16 files changed

+587
-32
lines changed

16 files changed

+587
-32
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "backtrace-library/src/main/cpp/crashpad-builds"]
22
path = backtrace-library/src/main/cpp/crashpad-builds
33
url = https://github.com/backtrace-labs/crashpad-builds.git
4+
[submodule "backtrace-library/src/main/cpp/libbun"]
5+
path = backtrace-library/src/main/cpp/libbun
6+
url = git@github.com:backtrace-labs/libbun.git

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Backtrace Android Release Notes
22

3+
4+
## Version 3.3.0 - 15.07.2021
5+
- Added support for client side unwinding of native crashes
6+
37
## Version 3.2.2 - 10.03.2021
48
- Hotfix for crash when user enables native integration without file attachments
59

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,33 @@ More details about [extractNativeLibs](https://developer.android.com/guide/topic
519519
## Uploading symbols to Backtrace
520520
For an NDK application, debugging symbols are not available to Backtrace by default. You will need to upload the application symbols for your native code to Backtrace. You can do this by uploading the native libraries themselves, which are usually found in the .apk bundle. [Click here to learn more about symbolification](https://support.backtrace.io/hc/en-us/articles/360040517071-Symbolication-Overview)
521521

522+
## Client side unwinding
523+
For an NDK application, debugging symbols for system functions (for instance in `libc.so`) and other opaque libraries can be difficult to obtain. In these cases, it is better to unwind the callstack on the crashing application (i.e: the client). This may not provide the same callstack quality as with debugging symbols, but will give you debugging information you would otherwise not have if you don't have debugging symbols available.
524+
525+
To enable client side unwinding, you can call the `setupNativeIntegration` method with an additional boolean value.
526+
```java
527+
database.setupNativeIntegration(backtraceClient, credentials, true);
528+
```
529+
530+
**NOTE:** Client side unwinding is only available in API level 23+ (Android 6.0)+
531+
532+
**NOTE:** When viewing a crash in the Backtrace Debugger, it may still show warning messages that symbols are missing from certain frames after client-side unwinding is performed. This warning is expected if these symbols are not available on the Backtrace server, and should have no impact to the end-user's ability to read the call stack.
533+
534+
**NOTE:** Client side unwinding is only available for fatal crashes. Non-fatal Crashpad dumps you generate via `DumpWithoutCrash` for instance will not use client side unwinding.
535+
536+
### Unwinding Modes and Options
537+
538+
You can optionally specify the unwinding mode (`REMOTE_DUMPWITHOUTCRASH` is the default)
539+
```java
540+
database.setupNativeIntegration(backtraceClient, credentials, true, UnwindingMode.REMOTE_DUMPWITHOUTCRASH);
541+
```
542+
543+
- **LOCAL** - Unwinding is done within the same process that has the crash. This is less robust than remote unwinding, but avoids the complexity of creating a child process and IPC. Local unwinding is executed from a signal handler and needs to be signal-safe.
544+
- **REMOTE** - Unwinding is done by a child process. This means that the unwinding is correct even in case of severe malfunctions in the crashing parent process, and signal-safety is not a concern.
545+
- **LOCAL_DUMPWITHOUTCRASH** - The same as `LOCAL` unwinding, but instead of using the regular Crashpad signal hander to call the unwinder and regular Crashpad reporting mechanism, Backtrace's custom signal handler will be used to call the unwinder before we send the report using Crashpad's `DumpWithoutCrash()` method.
546+
- **REMOTE_DUMPWITHOUTCRASH** - This is the default and recommended option. Same as `LOCAL` unwinding, but instead of using the regular Crashpad signal hander to call the unwinder and regular Crashpad reporting mechanism, Backtrace's custom signal handler will be used to call the unwinder before we send the report using Crashpad's `DumpWithoutCrash()` method.
547+
- **LOCAL_CONTEXT** - The same as `LOCAL` unwinding, but use `ucontext_t *` from the signal handler to reconstruct the callstack.
548+
522549
# Working with Proguard <a name="working_with_proguard"></a>
523550

524551
##### 1. Add the following to the `proguard_rules.pro` for your app

backtrace-library/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 21
99
targetSdkVersion 28
10-
versionCode 322
11-
versionName "3.2.2"
10+
versionCode 330
11+
versionName "3.3.0"
1212

1313
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1414

backtrace-library/src/main/cpp/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ set_property(TARGET base PROPERTY IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/crashp
3232
# Crashpad Headers
3333
include_directories(${PROJECT_SOURCE_DIR}/crashpad-builds/headers/ ${PROJECT_SOURCE_DIR}/crashpad-builds/headers/third_party/mini_chromium/mini_chromium/)
3434

35+
# Bun Libraries
36+
set(LIBUNWINDSTACK_ENABLED TRUE)
37+
add_subdirectory(libbun)
38+
3539
# Searches for a specified prebuilt library and stores the path as a
3640
# variable. Because CMake includes system libraries in the search path by
3741
# default, you only need to specify the name of the public NDK library
@@ -60,4 +64,5 @@ target_link_libraries( # Specifies the target library.
6064
crashpad_client
6165
crashpad_util
6266
base
63-
)
67+
bun
68+
)

0 commit comments

Comments
 (0)