-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Will Holen's doc on symbolication. Feels like this is a debugg…
…ing technique and like we need a section on Debugging. For future IA discussions. (#2112)
- Loading branch information
1 parent
d30c6c1
commit 3d9942c
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
id: symbolication | ||
title: Symbolicating a stack trace | ||
--- | ||
|
||
If a React Native app throws an unhandled exception in a release build, the output may be obfuscated and hard to read: | ||
|
||
```sh | ||
07-15 10:58:25.820 18979 18998 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules | ||
07-15 10:58:25.820 18979 18998 E AndroidRuntime: Process: com.awesomeproject, PID: 18979 07-15 10:58:25.820 18979 18998 E AndroidRuntime: com.facebook.react.common.JavascriptException: Failed, js engine: hermes, stack: | ||
07-15 10:58:25.820 18979 18998 E AndroidRuntime: p@1:132161 | ||
07-15 10:58:25.820 18979 18998 E AndroidRuntime: p@1:132084 | ||
07-15 10:58:25.820 18979 18998 E AndroidRuntime: f@1:131854 | ||
07-15 10:58:25.820 18979 18998 E AndroidRuntime: anonymous@1:131119 | ||
``` | ||
|
||
The sections like `p@1:132161` are minified function names and bytecode offsets. To debug the problem, you would instead want to translate it into file, line and function name: `AwesomeProject/App.js:54:initializeMap`. This is known as **symbolication.** You can symbolicate minified function names and bytecode like the above by passing `metro-symbolicate` a generated source map and the stack trace. | ||
|
||
> The `metro-symbolicate` package is installed by default in the React Native template project from [setting up your development environment](environment-setup). | ||
From a file containing the stacktrace: | ||
|
||
```sh | ||
npx metro-symbolicate android/app/build/generated/sourcemaps/react/release/index.android.bundle.map < stacktrace.txt | ||
``` | ||
|
||
From `adb logcat`directly: | ||
|
||
```sh | ||
adb logcat -d | npx metro-symbolicate android/app/build/generated/sourcemaps/react/release/index.android.bundle.map | ||
``` | ||
|
||
This will turn each minified function name and offset like `p@1:132161` into the actual file- and function name `AwesomeProject/App.js:54:initializeMap`. | ||
|
||
## Notes on Sourcemaps | ||
|
||
- Multiple source maps may be generated by the build process. Make sure to used the one in the location shown in the examples. | ||
- Make sure that the source map you use corresponds to the exact commit of the crashing app. Small changes in source code can cause large differences in offsets. | ||
- If `metro-symbolicate` exits immediately with success, make sure the input comes from a pipe or redirection and not from a terminal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters