Skip to content

Commit 708e6fc

Browse files
Merge branch 'topic/doc_remote' into 'master'
Document VS Code support for remote/cross See merge request eng/ide/ada_language_server!1938
2 parents 075aa49 + 5266f25 commit 708e6fc

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

README.md

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,11 @@ See a [dedicated document](doc/refactoring_tools.md) with the list of available
157157

158158
### Tasks
159159

160-
The extension provides the following auto-detected tasks
161-
(under `/Terminal/Run Task...` menu):
162-
163-
* `ada: Build current project` - launch `gprbuild` to build the current GPR project
164-
* `ada: Check current file` - launch `gprbuild` to check errors in the current editor
165-
* `ada: Clean current project` - launch `gprclean` to clean the current GPR project
166-
* `spark: Examine project` - launch `gnatprove` in flow analysis mode on the current GPR project
167-
* `spark: Examine file` - launch `gnatprove` in flow analysis mode on the file in the current editor
168-
* `spark: Examine subprogram` - launch `gnatprove` in flow analysis mode on the current subprogram in the current editor
169-
* `spark: Prove project` - launch `gnatprove` on the current GPR project
170-
* `spark: Prove file` - launch `gnatprove` on the file in the current editor
171-
* `spark: Prove subprogram` - launch `gnatprove` on the current subprogram in the current editor
172-
* `spark: Prove selected region` - launch `gnatprove` on the selected region in the current editor
173-
* `spark: Prove line` - launch `gnatprove` on the cursor line in the current editor
174-
* `spark: Clean project for proof` - launch `gnatprove` on the current GPR project to clean proof artefacts
175-
* `ada: Analyze the project with GNAT SAS`
176-
* `ada: Analyze the current file with GNAT SAS`
177-
* `ada: Create a report after a GNAT SAS analysis`
178-
* `ada: Analyze the project with GNAT SAS and produce a report`
160+
The extension provides a number of auto-detected tasks under the `/Terminal/Run Task...` menu. These
161+
predefined tasks are all prefixed by `ada:` and belong to the `ada` group.
162+
They can be used to build and run your program (`ada: Build current project` task) or launch external tools such as GNAT SAS, GNATprove and a few others.
163+
164+
<img src="doc/run-task-ada-tasks.png" width="500" alt="GNATtest Test Results"/>
179165

180166
You can bind keyboard shortcuts to them by adding to the `keybindings.json` file:
181167

@@ -246,14 +232,12 @@ You can also customize the working directory of the task or the environment vari
246232
#### Tasks for Project Mains
247233

248234
If your GPR project defines main programs via the project attribute `Main`, additional tasks are automatically provided for each defined main.
249-
For example, if the project defines a `main1.adb` and `main2.adb` located under the `src/` source directory, the following tasks will be available:
235+
For example, if the project defines a `main1.adb` and `main2.adb` located under the `src/` source directory, two different tasks will be available to build a given main:
250236

251237
* `ada: Build main - src/main1.adb`
252238
* `ada: Run main - src/main1.adb`
253-
* `ada: Build and run main - src/main1.adb`
254-
* `ada: Build main - src/main2.adb`
255-
* `ada: Run main - src/main2.adb`
256-
* `ada: Build and run main - src/main2.adb`
239+
240+
Same thing for all the predefined tasks that can have a main specified in their command line.
257241

258242
### Alire Support
259243

@@ -322,6 +306,40 @@ The GNATtest integration in VS Code also supports running tests in coverage mode
322306

323307
Integrating the steps of source instrumentation and test harness build into the test execution workflow allows for a quick feedback loop: run a test, observe results and coverage, edit the test or the tested code, repeat... In this context invoking the VS Code commands `Test: Rerun Last Run` and `Test: Rerun Last Run with Coverage` with their respective keyboard shortcuts can be valuable.
324308

309+
### Cross and Embedded Support
310+
311+
This section provides some guidance to work on cross or embedded projects. It assumes
312+
that your `.gpr` project files are already properly configured to work on a cross environments/embedded platforms.
313+
314+
#### GNATemulator Support
315+
316+
If you have loaded an embedded project, the extension will automatically provide predefined tasks and commands
317+
to run and debug your application through GNATemulator, if available for your target.
318+
319+
For instance if you have loaded a project with an `arm-eabi` target configured to run on a STM32F4
320+
board, the extension will provide predefined tasks, commands and CodeLenses to run and debug your
321+
program using GNATemulator.
322+
323+
<img src="doc/media/gnatemu-debug-codelens.gif" width="800" alt="Debug with GNATemulator CodeLens" />
324+
325+
The port used by the debugger launched by VS Code to connect to the running GNATemulator instance
326+
is the one specified via the `Emulator'Debug_Port` project attribute, so make sure it is set before
327+
running the dedicated GNATemulator command/CodeLens.
328+
329+
Note that GNATemulator is not available for all GNAT embedded toolchains. For more information about GNATemulator itself and its availabilty please refer to the [GNATemulator User's Guide](https://docs.adacore.com/gnatemulator-docs/gnatemulator.html).
330+
331+
#### Remote Debugging
332+
333+
If your project can be debugged remotely via GDB using the `target remote <ip-of-target:port>` command, you will just need to set the `IDE'Program_Host` project attribute in your `.gpr` file to specify the address that should be used
334+
to connect to your machine or board.
335+
336+
You will also need to run the debugging utility that spawns the remote `gdbserver` before launching the debugger in VS Code ( e.g: `st-util` or `openocd` for STM32F4 boards). This can be done directly through a VS Code `Terminal` or by configuring a custom [VS Code task](https://code.visualstudio.com/docs/editor/tasks) for that purpose.
337+
338+
Once your project is setup, just open the VS Code
339+
`Run and Debug` panel and then click on the `Run and Debug` button.
340+
341+
For more advanced use cases or if your program cannot be debugged remotely via GDB, you can try creating your custom VS Code debug launch configuration following [VS Code User's Guide for Launch Configurations](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations).
342+
325343
### Commands and Shortcuts
326344

327345
The extension contributes commands and a few default key bindings.
@@ -379,7 +397,7 @@ The VS Code extension has a few limitations and some differences compared to [GN
379397
* **Indentation/formatting**: it does not support automatic indentation when adding a newline and range/document
380398
formatting might no succeed on incomplete/illegal code.
381399

382-
* **Tooling support**: we currently provide support for some *SPARK*, *GNATtest*, *GNATcoverage* and *GNAT SAS* [Tasks](#tasks), but some workflows may not be supported yet.
400+
* **Tooling support**: we currently provide support for some *SPARK*, *GNATtest*, *GNATcoverage*, *GNAT SAS* and *GNATemulator* [Tasks](#tasks), but some workflows may not be supported yet.
383401

384402
* **Alire support**: if the root folder contains an `alire.toml` file and
385403
there is `alr` executable in the `PATH`, then the language server fetches

doc/run-task-ada-tasks.png

151 KB
Loading

0 commit comments

Comments
 (0)