diff options
author | 2021-09-30 12:54:34 +0200 | |
---|---|---|
committer | 2021-10-13 11:04:52 +0200 | |
commit | 9699c52ca3eab18369704cd3824b5ddd90ff7078 (patch) | |
tree | 35d0f8bfbbff8936277dc699077785bfae792726 /README.md | |
parent | 3e4d25552b620c20c29749677280b0dcf2bc6926 (diff) |
Update debugging instructions.
The ones here were obsolete.
Test: None (only documentation changes)
Change-Id: Idf5d1490e0f9d55f2078e6ba7396b80da73be369
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 59 |
1 files changed, 44 insertions, 15 deletions
@@ -561,27 +561,41 @@ written to a [ninja](http://ninja-build.org) build file. ## Developing for Soong -To load Soong code in a Go-aware IDE, create a directory outside your android tree and then: -```bash -apt install bindfs -export GOPATH=<path to the directory you created> -build/soong/scripts/setup_go_workspace_for_soong.sh -``` - -This will bind mount the Soong source directories into the directory in the layout expected by -the IDE. - +To load the code of Soong in IntelliJ: + +* File -> Open, open the `build/soong` directory. It will be opened as a new + project. +* File -> Settings, then Languages & Frameworks -> Go -> GOROOT, then set it to + `prebuilts/go/linux-x86` +* File -> Project Structure, then, Project Settings -> Modules, then Add + Content Root, then add the `build/blueprint` directory. +* Optional: also add the `external/golang-protobuf` directory. In practice, + IntelliJ seems to work well enough without this, too. ### Running Soong in a debugger -To run the soong_build process in a debugger, install `dlv` and then start the build with -`SOONG_DELVE=<listen addr>` in the environment. +To make `soong_build` wait for a debugger connection, install `dlv` and then +start the build with `SOONG_DELVE=<listen addr>` in the environment. For example: ```bash -SOONG_DELVE=:1234 m nothing +SOONG_DELVE=:5006 m nothing +``` + +To make `soong_ui` wait for a debugger connection, use the `SOONG_UI_DELVE` +variable: + +``` +SOONG_UI_DELVE=:5006 m nothing ``` -and then in another terminal: + + +setting or unsetting `SOONG_DELVE` causes a recompilation of `soong_build`. This +is because in order to debug the binary, it needs to be built with debug +symbols. + +To test the debugger connection, run this command: + ``` -dlv connect :1234 +dlv connect :5006 ``` If you see an error: @@ -596,6 +610,21 @@ using: sudo sysctl -w kernel.yama.ptrace_scope=0 ``` +To connect to the process using IntelliJ: + +* Run -> Edit Configurations... +* Choose "Go Remote" on the left +* Click on the "+" buttion on the top-left +* Give it a nice name and set "Host" to localhost and "Port" to the port in the + environment variable + +Debugging works far worse than debugging Java, but is sometimes useful. + +Sometimes the `dlv` process hangs on connection. A symptom of this is `dlv` +spinning a core or two. In that case, `kill -9` `dlv` and try again. +Anecdotally, it _feels_ like waiting a minute after the start of `soong_build` +helps. + ## Contact Email android-building@googlegroups.com (external) for any questions, or see |