diff options
Diffstat (limited to 'docs/part-2')
-rw-r--r-- | docs/part-2/0_Abstract.md | 6 | ||||
-rw-r--r-- | docs/part-2/1_xds-server.md | 336 | ||||
-rw-r--r-- | docs/part-2/2_xds-agent.md | 166 | ||||
-rw-r--r-- | docs/part-2/3_xds-exec.md | 296 | ||||
-rw-r--r-- | docs/part-2/4_xds-gdb.md | 201 | ||||
-rw-r--r-- | docs/part-2/pictures/.gitkeep | 0 |
6 files changed, 1005 insertions, 0 deletions
diff --git a/docs/part-2/0_Abstract.md b/docs/part-2/0_Abstract.md new file mode 100644 index 0000000..51aa70d --- /dev/null +++ b/docs/part-2/0_Abstract.md @@ -0,0 +1,6 @@ +# Part 2 - XDS internals + +## Abstract + +This 2nd part is the "technical" documentation of all XDS pieces that allows +to fine tune XDS configuration or rebuild all XDS tools for scratch. diff --git a/docs/part-2/1_xds-server.md b/docs/part-2/1_xds-server.md new file mode 100644 index 0000000..d4ae63c --- /dev/null +++ b/docs/part-2/1_xds-server.md @@ -0,0 +1,336 @@ +# XDS - X(cross) Development System Server + +`xds-server` is a web server that allows user to remotely cross build applications. + +The first goal is to provide a multi-platform cross development tool with +near-zero installation. +The second goal is to keep application sources locally (on user's machine) to +make it compatible with existing IT policies (e.g. corporate backup or SCM), +and let user to continue to work as usual (use his favorite editor, +keep performance while editing/browsing sources). + +This powerful and portable webserver (written in [Go](https://golang.org)) +exposes a REST interface over HTTP and also provides a Web dashboard to configure projects and execute _(for now)_ only basics commands. + +`xds-server` uses [Syncthing](https://syncthing.net/) tool to synchronize +projects files from user machine to build server machine or container. + +> **NOTE**: For now, only Syncthing sharing method is supported to synchronize +projects files. But in a near future and for restricted configurations, `xds-server` +will also support "standard" folder sharing (eg. nfs mount points or docker +volumes). + +> **SEE ALSO**: [xds-exec](https://github.com/iotbzh/xds-exec), +wrappers on `exec` commands that allows you to send commands to `xds-server` +and for example build your application from command-line or from your favorite +IDE (such as Netbeans or Visual Studio Code) through `xds-server`. + +## How to run + +`xds-server` has been designed to easily compile and debug +[AGL](https://www.automotivelinux.org/) applications. That's why `xds-server` has +been integrated into AGL SDK docker container. + +>**NOTE** For more info about AGL SDK docker container, please refer to +[AGL SDK Quick Setup](http://docs.automotivelinux.org/docs/getting_started/en/dev/reference/setup-sdk-environment.html) + +### Get the container + +Load the pre-build AGL SDK docker image including `xds-server`: + +```bash +seb@laptop ~$ wget -O - http://iot.bzh/download/public/2017/XDS/docker/docker_agl_worker-xds-latest.tar.xz | docker load +``` + +### List container + +You should get `docker.automotivelinux.org/agl/worker-xds:X.Y` image + +```bash +# List image that we just built +seb@laptop ~$ docker images | grep worker-xds + +docker.automotivelinux.org/agl/worker-xds 3.99.1 786d65b2792c 6 days ago 602MB +``` + +### Start xds-server within the container + +Use provided script to create a new docker image and start a new container: + +```bash +# Get script +seb@laptop ~$ wget https://raw.githubusercontent.com/iotbzh/xds-server/master/scripts/xds-docker-create-container.sh + +# Create new XDS worker container +seb@laptop ~$ bash ./xds-docker-create-container.sh + +# Check that new container is running +seb@laptop ~$ docker ps | grep worker-xds + +b985d81af40c docker.automotivelinux.org/agl/worker-xds:3.99.1 "/usr/bin/wait_for..." 6 days ago Up 4 hours 0.0.0.0:8000->8000/tcp, 0.0.0.0:69->69/udp, 0.0.0.0:10809->10809/tcp, 0.0.0.0:2222->22/tcp agl-xds-seb@laptop-0-seb +``` + +This container (ID=0) exposes following ports: + +- 8000 : `xds-server` to serve XDS Dashboard +- 69 : TFTP +- 2222 : ssh + +#### Manually setup docker user id + +If you plan to **use path-mapping sharing type for your projects**, you need to have the same user id and group id inside and outside docker. By default user and group name inside docker is set `devel` (id `1664`), use following commands to replace id `1664` with your user/group id: +```bash +# Set docker container name to use (usually agl-xds-xxx where xxx is USERNAME@MACHINENAME-IDX-NAME) +seb@laptop ~$ export CONTAINER_NAME=agl-xds-seb@laptop-0-seb + +# First stop xds-server +seb@laptop ~$ docker exec ${CONTAINER_NAME} bash -c "systemctl stop xds-server" + +# Change user and group id inside docker to match your ids +seb@laptop ~$ docker exec ${CONTAINER_NAME} bash -c "usermod -u $(id -u) devel" +seb@laptop ~$ docker exec ${CONTAINER_NAME} bash -c "groupmod -g $(id -g) devel" + +# Update some files ownership +seb@laptop ~$ docker exec ${CONTAINER_NAME} bash -c "chown -R devel:devel /home/devel /tmp/xds*" + +# Restart xds-server +seb@laptop ~$ docker exec ${CONTAINER_NAME} bash -c "systemctl start xds-server" +``` + +## Check if xds-server is running (open XDS Dashboard) + +**`xds-server` is automatically started** as a service on container startup. + +If the container is running on your localhost, you can access the web interface (what we call the "Dashboard"): + +```bash +seb@laptop ~$ xdg-open http://localhost:8000 +``` + +If needed you can status / stop / start it manually using following commands: + +```bash +# Log into docker container +seb@laptop ~$ ssh -p 2222 devel@localhost + +# Status XDS server: +devel@docker ~$ sudo systemctl status xds-server.service + +# Stop XDS server +devel@docker ~$ sudo systemctl stop xds-server.service + +# Start XDS server +devel@docker ~$ sudo systemctl start xds-server.service + +# Get XDS server logs +devel@docker ~$ sudo journalctl --unit=xds-server.service --output=cat +``` + +### Manually Start XDS server + +XDS server is started as a service by Systemd. + +```bash +/lib/systemd/system/xds-server.service +``` + +This Systemd service starts a bash script `/opt/AGL/xds/server/xds-server-start.sh` + +If you needed you can change default setting by defining specific environment +variables in `/etc/default/xds-server`. +For example to control log level, just set LOG_LEVEL env variable knowing that +supported *level* are: panic, fatal, error, warn, info, debug. + +```bash +seb@laptop ~$ ssh -p 2222 devel@localhost +devel@docker ~$ echo 'LOG_LEVEL=debug' | sudo tee --append /etc/default/xds-server > /dev/null +devel@docker ~$ sudo systemctl restart xds-server.service +devel@docker ~$ tail -f /tmp/xds-server/logs/xds-server.log +``` + +### Install SDK cross-toolchain + +`xds-server` uses SDK cross-toolchain installed into directory pointed by +`sdkRootDir` setting (see configuration section below for more details). +For now, you need to install manually SDK cross toolchain. There are not embedded +into docker image by default because the size of these tarballs is too big. + +Use provided `install-agl-sdks` script, for example to install SDK for ARM64 and +Intel corei7-64: + +```bash +seb@laptop ~$ ssh -p 2222 devel@localhost + +# Install ARM64 SDK (automatic download) +devel@docker ~$ sudo /opt/AGL/xds/server/xds-utils/install-agl-sdks.sh --arch aarch64 + +# Install Intel corei7-64 SDK (using an SDK tarball that has been built or downloaded manually) +devel@docker ~$ sudo /opt/AGL/xds/server/xds-utils/install-agl-sdks.sh --arch corei7-64 --file /tmp/poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-corei7-64-toolchain- +3.99.1+snapshot.sh + +``` + +### XDS Dashboard + +`xds-server` serves a web-application at [http://localhost:8000](http://localhost:8000) +when XDS server is running on your host. Just replace `localhost` by the host +name or ip when XDS server is running on another host. So you can now connect +your browser to this url and use what we call the **XDS dashboard**. + +```bash +xdg-open http://localhost:8000 +``` + +Then follow instructions provided by this dashboard, knowing that the first time +you need to download and start `xds-agent` on your local machine. + +To download this tool, just click on download icon in dashboard configuration +page or download one of `xds-agent` released tarball: [https://github.com/iotbzh/xds-agent/releases](https://github.com/iotbzh/xds-agent/releases). + +See also `xds-agent` [README file](https://github.com/iotbzh/xds-agent) for more details. + +## Build xds-server from scratch + +### Dependencies + +- Install and setup [Go](https://golang.org/doc/install) version 1.7 or +higher to compile this tool. +- Install [npm](https://www.npmjs.com/) +- Install [gulp](http://gulpjs.com/) + +Ubuntu: + +```bash + sudo apt-get install golang npm curl git zip + sudo npm install -g gulp-cli +``` + +openSUSE: + +```bash + sudo zypper install go npm git curl zip + sudo npm install -g gulp-cli +``` + +Don't forget to open new user session after installing the packages. + +### Building + +#### Native build + +Create a GOPATH variable(must be a full path): + +```bash + export GOPATH=$(realpath ~/workspace_go) +``` + +Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Makefile: + +```bash + mkdir -p $GOPATH/src/github.com/iotbzh + cd $GOPATH/src/github.com/iotbzh + git clone https://github.com/iotbzh/xds-server.git + cd xds-server + make all +``` + +And to install `xds-server` (by default in `/opt/AGL/xds/server`): + +```bash + make install +``` + +>**NOTE:** Used `DESTDIR` to specify another install directory +>```bash +>make install DESTDIR=$HOME/opt/xds-server +>``` + +#### XDS docker image + +As an alternative to a pre-build image, you can rebuild the container from scratch. +`xds-server` has been integrated as a flavour of AGL SDK docker image. +So to rebuild docker image just execute following commands: + +```bash +# Clone docker-worker-generator git repo +git clone https://git.automotivelinux.org/AGL/docker-worker-generator +# Start build that will create a docker image +cd docker-worker-generator +make build FLAVOUR=xds +``` + +### Configuration + +`xds-server` configuration is driven by a JSON config file (`config.json`). + +Here is the logic to determine which `config.json` file will be used: + +1. from command line option: `--config myConfig.json` +1. `$HOME/.xds-server/config.json` file +1. `/etc/xds-server/config.json` file +1. `<xds-server executable dir>/config.json` file + +Supported fields in configuration file are (all fields are optional and example +below corresponds to the default values): + +- **httpPort** : HTTP port of client webapp / dashboard +- **webAppDir** : location of client dashboard (default: webapp/dist) +- **shareRootDir** : root directory where projects will be copied +- **logsDir** : directory to store logs (eg. syncthing output) +- **sdkRootDir** : root directory where cross SDKs are installed +- **syncthing.binDir** : syncthing binaries directory (default: executable directory) +- **syncthing.home"** : syncthing home directory (usually .../syncthing-config) +- **syncthing.gui-address** : syncthing gui url (default http://localhost:8384) +- **syncthing.gui-apikey** : syncthing api-key to use (default auto-generated) + +```json +{ + "httpPort": 8000, + "webAppDir": "webapp/dist", + "shareRootDir": "${HOME}/.xds-server/projects", + "logsDir": "/tmp/logs", + "sdkRootDir": "/xdt/sdk", + "syncthing": { + "binDir": "./bin", + "home": "${HOME}/.xds-server/syncthing-config", + "gui-address": "http://localhost:8384", + "gui-apikey": "123456789", + } +} +``` + +>**NOTE:** environment variables are supported by using `${MY_VAR}` syntax. + +## Debugging + +### XDS server architecture + +The server part is written in *Go* and web app / dashboard (client part) in +*Angular2*. + +``` +| ++-- bin/ where xds-server binary file will be built +| ++-- agent-config.json.in example of config.json file +| ++-- 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 this 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 dashboard (Angular2 app) +``` + +Visual Studio Code launcher settings can be found into `.vscode/launch.json`. diff --git a/docs/part-2/2_xds-agent.md b/docs/part-2/2_xds-agent.md new file mode 100644 index 0000000..eac157a --- /dev/null +++ b/docs/part-2/2_xds-agent.md @@ -0,0 +1,166 @@ +# XDS - X(cross) Development System Agent + +XDS-agent is a client that should run on your local / user development machine when you use XDS. + +This agent takes care, among others, of starting [Syncthing](https://syncthing.net/) +tool to synchronize your project files from your local host to XDS build server +machine or container (where `xds-server` is running). + +> **SEE ALSO**: [xds-server](https://github.com/iotbzh/xds-server), a web server +used to remotely cross build applications. + +## How to install xds-agent + +### Install package for debian distro type + +```bash +export DISTRO="Debian_8.0" +wget -O - http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/Release.key | sudo apt-key add - +sudo bash -c "cat >> /etc/apt/sources.list.d/AGL.list<<EOF +deb http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/ ./ +EOF +" +sudo apt-get update +sudo apt-get install agl-xds-agent +``` + +The value 'DISTRO' can be set to {Debian_8.0, Debian_9.0, xUbuntu_16.04, xUbuntu_16.10, xUbuntu_17.04} + +Update the package + +```bash +sudo apt-get update +sudo apt-get upgrade agl-xds-agent +``` + +The files are install here: + +```bash +/opt/AGL/agl-xds-agent +``` + +### Install package for rpm distro type + +#### openSUSE + +```bash +export DISTRO="openSUSE_Leap_42.2" +sudo zypper ar http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/isv:LinuxAutomotive:app-Development.repo +sudo zypper ref +sudo zypper install agl-xds-agent +``` + +The value 'DISTRO' can be set to {openSUSE_Leap_42.2, openSUSE_Leap_42.3, openSUSE_Tumbleweed} + +Update the package + +```bash +sudo zypper ref +sudo zypper install --force agl-xds-agent +``` + +The files are install here: + +```bash +/opt/AGL/agl-xds-agent +``` + +## How to install on other platform + +Download released tarballs from github [releases page](https://github.com/iotbzh/xds-agent/releases). + +Then unzip this tarball any where into your local disk (for example: /opt/AGL/xds or C:\AGL\xds). + +## Configuration + +xds-agent configuration is driven by a JSON config file (named `agent-config.json`). +The tarball mentioned in previous section includes this file with default settings. + +Here is the logic to determine which `agent-config.json` file will be used: + +1. from command line option: `--config myConfig.json` +1. `$HOME/.xds/agent/agent-config.json` file +1. `/etc/xds-agent/agent-config.json` file +1. `<xds-agent executable dir>/agent-config.json` file + +Supported fields in configuration file are (all fields are optional and example +below corresponds to the default values): + +- **httpPort** : http port of agent REST interface +- **logsDir** : directory to store logs (eg. syncthing output) +- **xds-apikey** : xds-agent api-key to use (always set value to "1234abcezam") +- **syncthing.binDir** : syncthing binaries directory (default: executable directory) +- **syncthing.home"** : syncthing home directory (usually .../syncthing-config) +- **syncthing.gui-address** : syncthing gui url (default http://localhost:8384) +- **syncthing.gui-apikey** : syncthing api-key to use (default auto-generated) + +```json +{ + "httpPort": "8010", + "logsDir": "/tmp/logs", + "xds-apikey": "1234abcezam", + "syncthing": { + "binDir": ".", + "home": "${HOME}/.xds/agent/syncthing-config", + "gui-address": "http://localhost:8384", + "gui-apikey": "1234abcezam", + } +} +``` + +>**NOTE:** environment variables are supported by using `${MY_VAR}` syntax. + +## Start-up + +Simply to start `xds-agent` executable + +```bash +./xds-agent & +``` + +>**NOTE** if need be, you can increase log level by setting option +`--log <level>`, supported *level* are: panic, fatal, error, warn, info, debug. + +You can now use XDS dashboard and check that connection with `xds-agent` is up. +(see also [xds-server README](https://github.com/iotbzh/xds-server/blob/master/README.md#xds-dashboard)) + +## Build xds-agent from scratch + +### Dependencies + +Install and setup [Go](https://golang.org/doc/install) version 1.8 or +higher to compile this tool. + +### Building + +Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Makefile: + +```bash + mkdir -p $GOPATH/src/github.com/iotbzh + cd $GOPATH/src/github.com/iotbzh + git clone https://github.com/iotbzh/xds-agent.git + cd xds-agent + make all +``` + +And to install xds-agent (by default in `/usr/local/bin`): + +```bash +make install +``` + +>**NOTE:** Used `DESTDIR` to specify another install directory +>```bash +>make install DESTDIR=$HOME/opt/xds-agent +>``` + +#### Cross build + +For example on a Linux machine to cross-build for Windows, just execute: + +```bash +export GOOS=windows +export GOARCH=amd64 +make all +make package +``` diff --git a/docs/part-2/3_xds-exec.md b/docs/part-2/3_xds-exec.md new file mode 100644 index 0000000..7899ba9 --- /dev/null +++ b/docs/part-2/3_xds-exec.md @@ -0,0 +1,296 @@ +# xds-exec: wrapper on exec for XDS + +`xds-exec` is a wrapper on exec linux command for X(cross) Development System. + +As well as `xds-exec` is a wrapper on exec command and can be use to execute any +command on a remote `xds-server`. + +This tool can be used in lieu of "standard" `exec` command to execute any +command on a remote `xds-server`. For example you can trig your project build by +executing : `xds-exec --config conf.env -- make build` + +> **SEE ALSO**: +> - [xds-agent](https://github.com/iotbzh/xds-agent), an agent that should run +on your local host in order to use XDS. +> - [xds-server](https://github.com/iotbzh/xds-server), a web server +used to remotely cross build applications. + +## Getting Started + +You must have a running `xds-server` (locally or on the Cloud), see +[README of xds-server](https://github.com/iotbzh/xds-server/blob/master/README.md) +for more details. + +Connect your favorite Web browser to the XDS dashboard (default url +http://localhost:8000) and follow instructions to start local `xds-agent` on +your local host. Please refer to instructions provided by XDS dashboard or see +`README of xds-agent`. + +Then create your project you XDS dashboard. + +### Installing xds-exec + +#### Install package for debian distro type + +```bash +export DISTRO="Debian_8.0" +wget -O - http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/Release.key | sudo apt-key add - +sudo bash -c "cat >> /etc/apt/sources.list.d/AGL.list <<EOF +deb http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/ ./ +EOF +" +sudo apt-get update +sudo apt-get install agl-xds-exec +``` + +The value 'DISTRO' can be set to {Debian_8.0, Debian_9.0, xUbuntu_16.04, xUbuntu_16.10, xUbuntu_17.04} + +Update the package + +```bash +sudo apt-get update +sudo apt-get upgrade agl-xds-exec +``` + +The files are install here: + +```bash +/opt/AGL/agl-xds-exec +``` + +#### Install package for rpm distro type + +##### openSUSE + +```bash +export DISTRO="openSUSE_Leap_42.2" +sudo zypper ar http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Development/${DISTRO}/isv:LinuxAutomotive:app-Development.repo +sudo zypper ref +sudo zypper install agl-xds-exec +``` + +The value 'DISTRO' can be set to {openSUSE_Leap_42.2, openSUSE_Leap_42.3, openSUSE_Tumbleweed} + +Update the package + +```bash +sudo zypper ref +sudo zypper install --force agl-xds-exec +``` + +The files are install here: + +```bash +/opt/AGL/agl-xds-exec +``` + +### Using xds-exec from command line + +You need to determine which is the unique id of your project. You can find +this ID in project page of XDS dashboard or you can get it from command line +using the `--list` option. This option lists all existing projects ID: + +```bash +./bin/xds-exec --list + +List of existing projects: + CKI7R47-UWNDQC3_myProject + CKI7R47-UWNDQC3_test2 + CKI7R47-UWNDQC3_test3 +``` + +Now to refer your project, just use --id option or use `XDS_PROJECT_ID` +environment variable. + +You are now ready to use XDS to for example cross build your project. +Here is an example to build a project based on CMakefile: + +```bash +# Add xds-exec in the PATH +export PATH=${PATH}:/opt/AGL/agl-xds-exec + +# Go into your project directory +cd $MY_PROJECT_DIR + +# Create a build directory +xds-exec --id=CKI7R47-UWNDQC3_myProject --sdkid=poky-agl_aarch64_4.0.1 --url=http://localhost:8000 -- mkdir build + +# Generate build system using cmake +xds-exec --id=CKI7R47-UWNDQC3_myProject --sdkid=poky-agl_aarch64_4.0.1 --url=http://localhost:8000 -- cd build && cmake .. + +# Build the project +xds-exec --id=CKI7R47-UWNDQC3_myProject --sdkid=poky-agl_aarch64_4.0.1 --url=http://localhost:8000 -- cd build && make all +``` + +To avoid to set project id, xds server url, ... at each command line, you can +define these settings as environment variable within an env file and just set +`--config` option or source file before executing xds-exec. + +For example, the equivalence of above command is: + +```bash +cat > config.env << EOF + export XDS_SERVER_URL=localhost:8000 + export XDS_PROJECT_ID=CKI7R47-UWNDQC3_myProject + export XDS_SDK_ID=poky-agl_aarch64_4.0.1 +EOF + +xds-exec --config config.env -- mkdir build + +# Or sourcing env file +source config.env +xds-exec -- cd build && cmake .. +xds-exec -- cd build && make all +``` + +### Using xds-exec within an IDE + +#### Visual Studio Code + +Open your project in VSC + +```bash +cd $MY_PROJECT_DIR +code . & +``` +Add new tasks : press `Ctrl+Shift+P` and select the `Tasks: Configure Task Runner` command and you will see a list of task runner templates. + +And define your own tasks, here is an example to build [unicens2-binding](https://github.com/iotbzh/unicens2-binding) AGL binding based on cmake (_options value of args array must be updated regarding your settings_): + +```json +{ + "version": "0.1.0", + "linux": { + "command": "/opt/AGL/agl-xds-exec/xds-exec" + }, + "isShellCommand": true, + "args": [ + "-url", "localhost:8010", + "-id", "W2EAQBA-HQI75XA_unicens2-binding", + "-sdkid", "poky-agl_aarch64_4.0.1", + "--" + ], + "showOutput": "always", + "tasks": [{ + "taskName": "clean", + "suppressTaskName": true, + "args": [ + "rm -rf build/* && echo Cleanup done." + ] + }, + { + "taskName": "pre-build", + "isBuildCommand": true, + "suppressTaskName": true, + "args": [ + "mkdir -p build && cd build && cmake -DRSYNC_TARGET=root@192.168.168.11 -DRSYNC_PREFIX=./opt" + ] + }, + { + "taskName": "build", + "isBuildCommand": true, + "suppressTaskName": true, + "args": [ + "cd build && make widget" + ], + "problemMatcher": { + "owner": "cpp", + "fileLocation": ["absolute"], + "pattern": { + "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + } + }, + { + "taskName": "populate", + "suppressTaskName": true, + "args" : [ + "cd build && make widget-target-install" + ] + } + ] +} +``` + +> **NOTE** You can also add your own keybindings to trig above tasks, for example: +> ```json +> // Build +> { +> "key": "alt+f9", +> "command": "workbench.action.tasks.runTask", +> "args": "clean" +> }, +> { +> "key": "alt+f10", +> "command": "workbench.action.tasks.runTask", +> "args": "pre-build" +> }, +> { +> "key": "alt+f11", +> "command": "workbench.action.tasks.runTask", +> "args": "build" +> }, +> { +> "key": "alt+f12", +> "command": "workbench.action.tasks.runTask", +> "args": "populate" +> }, +> ``` +> +> More details about VSC keybindings [here](https://code.visualstudio.com/docs/editor/tasks#_binding-keyboard-shortcuts-to-tasks) +> +> More details about VSC tasks [here](https://code.visualstudio.com/docs/editor/tasks) + +#### Qt Creator +Please refer to [agl-hello-qml](https://github.com/radiosound-com/agl-hello-qml#clone--build-project) project. +Thanks to Dennis for providing this useful example. + +#### Others IDE +*Coming soon...* + + +## How to build + +### Prerequisites + You must install and setup [Go](https://golang.org/doc/install) version 1.7 or + higher to compile this tool. + +### Building +Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Makefile: +```bash + export GOPATH=$(realpath ~/workspace_go) + mkdir -p $GOPATH/src/github.com/iotbzh + cd $GOPATH/src/github.com/iotbzh + git clone https://github.com/iotbzh/xds-exec.git + cd xds-exec + make +``` + +## Debug + +Visual Studio Code launcher settings can be found into `.vscode/launch.json`. + +>**Tricks:** To debug both `xds-exec` (client part) and `xds-server` (server part), +it may be useful use the same local sources. +So you should replace `xds-server` in `vendor` directory by a symlink. +So clone first `xds-server` sources next to `xds-exec` directory. +You should have the following tree: +``` +> tree -L 3 src +src +|-- github.com + |-- iotbzh + |-- xds-exec + |-- xds-server +``` +Then invoke `vendor/debug` Makefile rule to create a symlink inside vendor +directory : +```bash +cd src/github.com/iotbzh/xds-exec +make vendor/debug +``` diff --git a/docs/part-2/4_xds-gdb.md b/docs/part-2/4_xds-gdb.md new file mode 100644 index 0000000..5fe0ab9 --- /dev/null +++ b/docs/part-2/4_xds-gdb.md @@ -0,0 +1,201 @@ +# xds-gdb: wrapper on gdb for XDS + +`xds-gdb` is a wrapper on gdb debugger for X(cross) Development System. + +This tool allows you to debug an application built with an xds-server without +the need to install gdb or any cross tool. + +Two debugging models are supported: + +1. native debugging + +1. XDS remote debugging requiring an XDS server and allowing cross debug your + application. + + + By default XDS remote debug is used and you need to define `XDS_NATIVE_GDB` +variable to use native gdb debug mode instead. + +> **SEE ALSO**: [xds-server](https://github.com/iotbzh/xds-server), a web server +used to remotely cross build applications. +> **SEE ALSO**: [xds-exec](https://github.com/iotbzh/xds-exec), +wrappers on `exec` command that allows to cross build your application through `xds-server`. + +## Getting Started + +## Installing xds-gdb + +Download latest `xds-gdb` release on [https://github.com/iotbzh/xds-gdb/releases](https://github.com/iotbzh/xds-gdb/releases). + +Extract the tarball anywhere you want, for example: + +```bash +mkdir -p ~/opt/bin +unzip -j $DOWNLOAD_DIR/xds-gdb_linux-amd64-v1.0.0.zip xds-gdb/xds-gdb ~/opt/bin +``` + +## Configuration + + `xds-gdb` configuration is defined by variables (see listed below). + These variables may be set using : + +- environment variables (inherited), +- or a config file set with `XDS_CONFIG` environment variable, for example: + `XDS_CONFIG=/tmp/my_xds_gdb_config.env xds-gdb` +- or by setting variables within a gdb ini file (see details below), +- or a "user" config file located in following directory (first found is taken): + 1. $(CURRENT_DIRECTORY)/.xds-gdb.env + 1. $(CURRENT_DIRECTORY)/../xds-gdb.env + 1. $(CURRENT_DIRECTORY)/target/xds-gdb.env + 1. $(HOME)/.config/xds/xds-gdb.env + +### Configuration Variables + + `XDS_CONFIG` : + Config file defining `XDS_xxx` configuration variables. Variables of this file + will overwrite inherited environment variables. Variables definition may be + prefixed or not by "export" keyword. + Here is an example of + +```bash +cat $HOME/myProject/xds-gdb.env + +export XDS_SERVER_URL=http://xds-docker:8000 +export XDS_PROJECT_ID=IW7B4EE-DBY4Z74_myProject +export XDS_SDK_ID=poky-agl_aarch64_4.0.1 +``` + +`XDS_LOGLEVEL` : +Set logging level (supported levels: panic, fatal, error, warn, info, debug) + +`XDS_LOGFILE` : +Set logging file, default `/tmp/xds-gdb.log`. + +`XDS_NATIVE_GDB` : +Use native gdb mode instead of remote XDS server mode. + +`XDS_PROJECT_ID` : *(mandatory with XDS server mode)* +Project ID you want to build + +`XDS_RPATH` : +Relative path into project + +`XDS_SDK_ID` : *(mandatory with XDS server mode)* +Cross Sdk ID to use to build project + +`XDS_SERVER_URL` : *(mandatory with XDS server mode)* +Remote XDS server url + +### Configuration variables set within gdb init command file + +Above `XDS_xxx` variables may also be defined within gdb init command file +(see --command or -x option of genuine Gdb). +You must respect the following syntax: commented line including `:XDS-ENV:` tag + +Example of gdb init file where we define project and sdk ID: + +```bash + # :XDS-ENV: XDS_PROJECT_ID=IW7B4EE-DBY4Z74_myProject + # :XDS-ENV: XDS_SDK_ID=poky-agl_aarch64_4.0.1 +``` + +## Using xds-gdb from command line + +### XDS remote debugging mode + +First the project you want to debug must be declared on an xds-server and this +project may also has been built using this xds-server (see [xds-server](https://github.com/iotbzh/xds-server) for more details). + +So to debug it you need to know the xds-server url (eg. <http://xds-docker:8000>), +you also need the project and sdk unique id. You can find these IDs in project +page of XDS dashboard or you can get them from command line using the `--list` +option. +This option lists all existing projects ID: + +```bash +XDS_SERVER_URL=http://xds-docker:8000 xds-gdb --list +``` + +Now to refer your project, just set `XDS_PROJECT_ID` and `XDS_SDK_ID` variables. + +You are now ready to use `xds-gdb` to for example cross debug your project. +Here is an example to build and debug a project based on CMakefile and +[AGL app-templates](https://git.automotivelinux.org/apps/app-templates/): + +```bash +# Go into your project directory (for example helloworld-service) +git clone https://github.com/iotbzh/helloworld-service.git +cd helloworld-service + +# Declare your project on xds-server +# <for now, you can only do this step using xds HTML dashboard (see xds-server doc)> + +# Define XDS config +cat <<EOF >./xds-config.env +XDS_SERVER_URL=http://xds-docker:8000 +XDS_PROJECT_ID=IW7B4EE-DBY4Z74_myProject +XDS_SDK_ID=poky-agl_aarch64_4.0.1 +EOF + +# Tell to xds-exec and xds-gdb which is your config file +export XDS_CONFIG=../xds-config.env + +# Create a new build directory +mkdir build && cd build + +# Start remote cross build +xds-exec -- cmake .. +xds-exec -- make +xds-exec -- make remote-target-populate + +# Start debugging +xds-gdb -x target/gdb-on-root@myTarget.ini +``` + +> **Notes** : [Helloworld-service project](https://github.com/iotbzh/helloworld-service) +is an AGL project based on app-templates that can be build and debug using XDS. + +### Native debugging + +To enable native debugging mode, you need to define `XDS_NATIVE_GDB` variable. + +## Using xds-gdb within an IDE + +### Netbeans + +__Netbeans 8.x :__ +Open menu Tools -> Options +Then open C/C++ tab, in "Build Tools" sub-tab, click on "Add" button: +![Add new tool panel](./docs/images/nb_newtool.jpg) + +Then, you should set *Debugger Command* to point to xds-gdb + +![Add new tool panel](./docs/images/nb_xds_options.jpg) + +### Others IDE + +*Coming soon...* + +## How to build xds-gdb from scratch + +### Prerequisites + + You must install and setup [Go](https://golang.org/doc/install) version 1.7 or + higher to compile this tool. + +### Building + +Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Makefile: + +```bash + export GOPATH=$(realpath ~/workspace_go) + mkdir -p $GOPATH/src/github.com/iotbzh + cd $GOPATH/src/github.com/iotbzh + git clone https://github.com/iotbzh/xds-gdb.git + cd xds-gdb + make +``` + +## Debug + +Visual Studio Code launcher settings can be found into `.vscode/launch.json`. diff --git a/docs/part-2/pictures/.gitkeep b/docs/part-2/pictures/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docs/part-2/pictures/.gitkeep |