Skip to content

Commit 2341b9c

Browse files
Added a README
1 parent 04811c3 commit 2341b9c

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "Debug Nim Project",
99
"type": "gdb",
1010
"request": "launch",
11-
"target": "main",
11+
"target": "./bin/main",
1212
"cwd": "${workspaceRoot}",
1313
"valuesFormatting": "parseText"
1414
}

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"label": "Build Nim Project",
88
"type": "shell",
9-
"command": "nim c -d:debug --debugger:native main.nim",
9+
"command": "nim c --out:bin/main -d:debug --debugger:native main.nim",
1010
"group": {
1111
"kind": "build",
1212
"isDefault": true

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# How to debug Nim code in VSCode
2+
3+
Below are some steps to help you debug [Nim](https://nim-lang.org/) code in [Visual Studio Code](https://code.visualstudio.com/).
4+
5+
## Prerequisites
6+
7+
1. Nim is installed.
8+
2. GDB is installed.
9+
3. VSCode is installed.
10+
4. The [Nim VSCode extension](https://marketplace.visualstudio.com/items?itemName=kosz78.nim) is installed.
11+
5. The [Native Debug VSCode extension](https://marketplace.visualstudio.com/items?itemName=webfreak.debug) is installed.
12+
6. This example repository has been cloned with [Git](https://git-scm.com/).
13+
14+
## Steps to setup debugging
15+
16+
This repository contains some files to help setup debugging in VSCode.
17+
18+
1. Open VSCode.
19+
2. File -> Open Folder -> Open the cloned repository folder in VSCode.
20+
3. Open `main.nim`.
21+
4. Set a breakpoint.
22+
5. Debug -> Start Debugging.
23+
6. Once your breakpoint is hit, open the Debug Console (at the bottom) and type:
24+
25+
```
26+
python exec(open("bin/nim3.py").read())
27+
```
28+
29+
and press [enter].
30+
31+
## References
32+
33+
[Debug Nim with GDB](https://internet-of-tomohiro.netlify.com/nim/gdb.en.html)
34+
[Nim GDB video](https://www.youtube.com/watch?v=DmYOPkI_LzU)
35+
[nim-gdb bash script](https://github.com/nim-lang/Nim/blob/devel/bin/nim-gdb)
36+
[nim-gdb.py file, Nim repository](https://github.com/nim-lang/Nim/blob/devel/tools/nim-gdb.py)
37+
[Nim Editor Support](https://github.com/nim-lang/Nim/wiki/Editor-Support)
38+
[repr method for debugging](https://nim-lang.org/docs/system.html#repr%2CT)
39+
[Nim VSCode plugin debug feature request](https://github.com/pragmagic/vscode-nim/issues/65)
40+
[Extending GDB using Python](https://sourceware.org/gdb/onlinedocs/gdb/Python.html#Python)

0 commit comments

Comments
 (0)