diff options
Diffstat (limited to 'docs/ATTIC/3_Developer_Guides/4_X(cross)_Development_System:_User's_Guide/4_X(cross)_Development_System:_ Internals /3.4.4.3_xds-agent/3.4.4.3.4_Debug.md')
-rw-r--r-- | docs/ATTIC/3_Developer_Guides/4_X(cross)_Development_System:_User's_Guide/4_X(cross)_Development_System:_ Internals /3.4.4.3_xds-agent/3.4.4.3.4_Debug.md | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/docs/ATTIC/3_Developer_Guides/4_X(cross)_Development_System:_User's_Guide/4_X(cross)_Development_System:_ Internals /3.4.4.3_xds-agent/3.4.4.3.4_Debug.md b/docs/ATTIC/3_Developer_Guides/4_X(cross)_Development_System:_User's_Guide/4_X(cross)_Development_System:_ Internals /3.4.4.3_xds-agent/3.4.4.3.4_Debug.md new file mode 100644 index 0000000..7842741 --- /dev/null +++ b/docs/ATTIC/3_Developer_Guides/4_X(cross)_Development_System:_User's_Guide/4_X(cross)_Development_System:_ Internals /3.4.4.3_xds-agent/3.4.4.3.4_Debug.md @@ -0,0 +1,132 @@ +<!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/devguides/master/xds-docs-guides-devguides-book.yml --> + +# Debugging + +## XDS agent architecture + +The agent part is written in *Go* and the webapp / dashboard is in *typescript + Angular4*. + +```bash +| ++-- bin/ where xds-server binary file will be built +| ++-- conf.d Linux configuration and startup files (systemd user service) +| ++-- glide.yaml Go package dependency file +| ++-- lib/ sources of server part (Go) +| ++-- main.go main entry point of of Web server (Go) +| ++-- Makefile makefile including +| ++-- README.md readme +| ++-- scripts/ hold various scripts used for installation or startup +| ++-- tools/ temporary directory to hold development tools (like glide) +| ++-- vendor/ temporary directory to hold Go dependencies packages +| ++-- webapp/ source client basic webapp / dashboard +``` + +## Debug xds-agent (Go code) + +Install first [Visual Studio Code](https://code.visualstudio.com/) and +[Go plugin](https://marketplace.visualstudio.com/items?itemName=lukehoban.Go) +(`ext install lukehoban.Go`) + +Visual Studio Code launcher settings can be found into `.vscode/launch.json`. +The important think is to correctly set `GOPATH` in launch.json in order to +build xds-agent and debug it within Visual Studio Code. + +Here is an example of launch.json: + +```json +{ + "version": "0.2.0", + "configurations": [{ + "name": "XDS-Agent", + "type": "go", + "request": "launch", + "mode": "debug", + "remotePath": "", + "port": 2345, + "host": "127.0.0.1", + "program": "${workspaceRoot}", + "env": { + "GOPATH": "${workspaceRoot}/../../../../../..:${env:GOPATH}", + }, + "args": ["-log", "debug", "-c", "__agent-config_local_dev.json"], + "showLog": false + } + ] +} +``` + +And `__agent-config_local_dev.json` file content is as follow : + +```json +{ + "webAppDir": "./webapp/dist", + "logsDir": "${HOME}/tmp/xds-agent/logs", + "xdsServers": [ + { + "url": "http://localhost:8000" + } + ], + "syncthing": { + "binDir": "./bin", + "home": "${HOME}/tmp/xds_local_dev/syncthing-config", + "gui-address": "http://localhost:8386", + } +} +``` + +### Tricks to debug both xds-agent and xds-server + +To debug both `xds-agent` and `xds-server` or common code `xds-common`, it may +be useful use the same local sources. + +A trick to do that is to replace `xds-server` + `xds-common` in `vendor` +directory by a symlink that points to local sources. + +So clone first `xds-server` + `xds-common` sources next to `xds-agent` directory. + +You should have the following tree: + +```bash +tree -L 5 src/ +src/ +`-- gerrit.automotivelinux.org + `-- gerrit + `-- src + `-- xds + |-- xds-agent + |-- xds-common + `-- xds-server +``` + +Then invoke `vendor/debug` Makefile rule to create symbolic links inside vendor +directory : + +```bash +cd src/gerrit.automotivelinux.org/gerrit/src/xds/xds-agent +make vendor/debug +``` + +## Debug dashboard part (Typescript / angular code) + +Start `xds-agent` either from command line or in debug mode (see previous +chapter) and in another terminal start a watcher daemon so that type typescript +sources of webapp / dashboard are automatically "transpiled" using following +command : + +```bash +cd webapp +npm run watch +``` + +Then open the XDS Dashboard page ([http://localhost:8800](http://localhost:8800)) +and open the developer tool of web browser (for example `Ctrl+Shift+I` in Chrome). |