Add gdbserver instructions to site docs

Change-Id: I13ba477d5b390a0fc03cd4960b6a19bcaa4266d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/482699
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
This commit is contained in:
Brian Osman 2021-12-10 11:06:17 -05:00 committed by SkCQ
parent 15f186d277
commit f693b20c37
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,62 @@
---
title: "Debugging DM on Android"
linkTitle: "Debugging DM on Android"
---
By default, we dont do Android builds with full symbols. Assuming you want more than callstacks,
add the following to your GN args:
~~~
extra_cflags = [ "-g" ]
~~~
When you build, you need to have built the `gdbserver` target. Either build everything, or at least
build both `dm` and `gdbserver`:
<!--?prettify lang=sh?-->
ninja -C out/android dm gdbserver
At this point, the Android gdb script should work. Try running:
<!--?prettify lang=sh?-->
platform_tools/android/bin/android_gdb_native -C out/android dm -i /data/local/tmp/resources <args>
You will end up in a command-line gdb session connected to dm on the device. Youre done, but you
can do better. From here, Im assuming that you use VS Code. I strongly suspect that this could be
adapted to other IDEs' GDB integration.
VS Code comes with lldb support, but this workflow needs a GDB extension. Search for 'Native Debug'
in the extension browser and install it, the thing you want comes from
https://github.com/WebFreak001/code-debug if youre unsure.
In your VS Code projects `launch.json`, add an entry that looks like the following. You'll need to
replace <NDK_BUNDLE> with the path to your NDK bundle (ie $ANDROID_NDK_ROOT):
~~~
{
"name": "Android GDB",
"type": "gdb",
"request": "attach",
"target": ":5039",
"remote": true,
"gdbpath": "<NDK bundle>/prebuilt/linux-x86_64/bin/gdb",
"executable": "out/android/android_gdb_tmp/dm",
"cwd": "${workspaceRoot}",
"autorun": [ "break main" ]
}
~~~
Rather than running `android_gdb_native`, run `android_gdbserver` in the same directory (and with
the same arguments). This will do all of the same deployment, and run `gdbserver` on the device,
but wont start command line gdb on your host.
Now, just 'Start Debugging' in VS Code (with the new configuration selected, if you have more than
one). The VSC hosted gdb will connect to gdbserver, and youll have a somewhat interactive debugger
where you can set breakpoints in your source windows, have panes for watches, locals, and the call
stack, etc. Enjoy:
![VS Code Debugger Screenshot](../android_gdb.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB