Skip to content

Commit 1fd49fd

Browse files
authored
Added debugging functionality. (#150)
* Added debugging functionality. * Replaces deprecated debugger interface. As stated in issue #9037 in github.com/microsoft/vscode is the way to go. Fortran does not do anything different from the inhouse C++ debugger, hence we should only have the extension allow breaking points and nothing else. This of course means that we will be depending on Microsoft's C++ extension for the debugger. * Updated README.md to include debugging as feature * Marked code snippets as JSON * Attempt to fix highlighting on GitHub
1 parent 7914b97 commit 1fd49fd

File tree

2 files changed

+76
-8
lines changed

2 files changed

+76
-8
lines changed

README.md

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Installs](https://vsmarketplacebadge.apphb.com/installs/krvajalm.linter-gfortran.svg)](https://marketplace.visualstudio.com/items?itemName=krvajalm.linter-gfortran)
77
[![GitHub release](https://img.shields.io/github/release/krvajal/vscode-fortran-support.svg)](https://GitHub.com/krvajal/vscode-fortran-support/releases/)
88

9-
> This extension provides support for the Fortran programming language. It includes syntax highlighting, code snippets and a linting based on `gfortran`. You can download the Visual Studio Code editor from [here](https://code.visualstudio.com/download).
9+
> This extension provides support for the Fortran programming language. It includes syntax highlighting, debugging, code snippets and a linting based on `gfortran`. You can download the Visual Studio Code editor from [here](https://code.visualstudio.com/download).
1010
1111
## Features
1212

@@ -16,14 +16,15 @@
1616
- Code linting based on `gfortran` to show errors wiggles in your code
1717
- Code autocompletion (beta)
1818
- Symbols provider
19+
- Debugger, uses Microsoft's [C/C++ extension](https://github.com/Microsoft/vscode-cpptools)
1920

2021
![symbol_nav](./doc/symbol_nav.png)
2122

2223
## Settings
2324

2425
You can control the include paths to be used by the linter with the `fortran.includePaths` setting.
2526

26-
```
27+
``` jsonc
2728
{
2829
"fortran.includePaths": [
2930
"/usr/local/include",
@@ -34,23 +35,23 @@ You can control the include paths to be used by the linter with the `fortran.inc
3435

3536
By default the `gfortran` executable is assumed to be found in the path. In order to use a different one or if it can't be found in the path you can point the extension to use a custom one with the `fortran.gfortranExecutable` setting.
3637

37-
```
38+
``` jsonc
3839
{
3940
"fortran.gfortranExecutable": '/usr/local/bin/gfortran-4.7',
4041
}
4142
```
4243

4344
If you want to pass extra options to the `gfortran` executable or override the default one, you can use the setting `fortran.linterExtraArgs`. By default `-Wall` is the only option.
4445

45-
```
46+
``` jsonc
4647
{
4748
"fortran.linterExtraArgs": ['-Wall'],
4849
}
4950
```
5051

5152
You can configure what kind of symbols will appear in the symbol list by using
5253

53-
```
54+
``` jsonc
5455
{
5556
"fortran.symbols": [ "function", "subroutine"]
5657
}
@@ -68,7 +69,7 @@ and by default only functions and subroutines are shown
6869

6970
You can also configure the case for fortran intrinsics auto-complete by using
7071

71-
```
72+
``` jsonc
7273
{
7374
"fortran.preferredCase": "lowercase" | "uppercase"
7475
}
@@ -90,10 +91,65 @@ This is a list of some of the snippets included, if you like to include addition
9091

9192
To trigger code validations you must save the file first.
9293

94+
## Debugging
95+
96+
The extension uses the debugger from Microsoft's
97+
[C/C++ extension](https://github.com/Microsoft/vscode-cpptools)
98+
for Visual Studio Code. This allows this extension to use the full functionality
99+
of the C/C++ extension for debugging applications:
100+
(un)conditional breaking points, expression evaluation, multi-threaded debugging,
101+
call stack, stepping, watch window.
102+
103+
A minimal `launch.json` script, responsible for controlling the debugger, is
104+
provided below. However, Visual Studio Code is also capable of autogenerating
105+
a `launch.json` file and the configurations inside the file.
106+
107+
More details about how to setup the debugger can be found in Microsoft's website:
108+
109+
- General information about debugging in VS Code: <https://code.visualstudio.com/docs/editor/debugging>
110+
- C/C++ extension debugger information: <https://code.visualstudio.com/docs/cpp/cpp-debug>
111+
- Build tasks for easy compiling: <https://code.visualstudio.com/docs/editor/tasks>
112+
113+
``` jsonc
114+
{
115+
// Use IntelliSense to learn about possible attributes.
116+
// Hover to view descriptions of existing attributes.
117+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
118+
"version": "0.2.0",
119+
"configurations": [
120+
{
121+
"name": "(gdb) Fortran",
122+
"type": "cppdbg",
123+
"request": "launch",
124+
"program": "${workspaceFolder}/a.out",
125+
"args": [], // Possible input args for a.out
126+
"stopAtEntry": false,
127+
"cwd": "${workspaceFolder}",
128+
"environment": [],
129+
"externalConsole": false,
130+
"MIMode": "gdb",
131+
"setupCommands": [
132+
{
133+
"description": "Enable pretty-printing for gdb",
134+
"text": "-enable-pretty-printing",
135+
"ignoreFailures": true
136+
}
137+
]
138+
}
139+
]
140+
}
141+
```
142+
93143
## Requirements
94144

95145
For the linter to work you need to have `gfortran` on your path, or wherever you configure it to be.
96146

147+
For debugging you need to have one of the following debuggers installed:
148+
149+
- **Linux**: GDB
150+
- **macOS**: GDB or LLDB
151+
- **Windows**: GDB or Visual Studio Windows Debugger
152+
97153
## Issues
98154

99155
Please report any issues and feature request on the GitHub repo [here](https://github.com/krvajalmiguelangel/vscode-fortran-support/issues/new)

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
"categories": [
1616
"Programming Languages",
1717
"Snippets",
18-
"Linters"
18+
"Linters",
19+
"Debuggers"
1920
],
2021
"activationEvents": [
2122
"onLanguage:FortranFreeForm"
2223
],
2324
"main": "./out/src/extension",
25+
"extensionDependencies": [
26+
"ms-vscode.cpptools"
27+
],
2428
"contributes": {
2529
"languages": [
2630
{
@@ -84,6 +88,14 @@
8488
"path": "./snippets/fortran90.json"
8589
}
8690
],
91+
"breakpoints": [
92+
{
93+
"language": "FortranFreeForm"
94+
},
95+
{
96+
"language": "fortran_fixed-form"
97+
}
98+
],
8799
"configuration": {
88100
"type": "object",
89101
"title": "Fortran configuration",
@@ -197,4 +209,4 @@
197209
"dependencies": {
198210
"vscode-languageclient": "^5.1.0"
199211
}
200-
}
212+
}

0 commit comments

Comments
 (0)