Nim Debugger - VSCode Extension
A VSCode extension that provides seamless native debugging for Nim with automatic symbol demangling.
Features
- Automatic Installation Check: Detects if
nim-debugger-mi is installed
- One-Click Installation: Install
nim-debugger-mi directly from VSCode
- Debug Configuration Snippets: Pre-configured debug templates for Nim programs
- Automatic Path Detection: Finds
nim_debugger_mi in ~/.nimble/bin or PATH
- Symbol Demangling: Shows readable variable and function names during debugging
Requirements
Installation
- Install from the VSCode Marketplace (search for "Nim Debugger")
- The extension will prompt you to install
nim-debugger-mi if not found
- Click "Install" to automatically run
nimble install nim_debugger_mi
Usage
Quick Start
- Open a Nim project
- Press
F5 or go to Run > Start Debugging
- Select "Nim: Debug (Native)" from the configuration list
- Set breakpoints and start debugging!
Manual Configuration
Add to your .vscode/launch.json:
Linux/WSL
{
"name": "Debug Nim",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"miDebuggerPath": "${userHome}/.nimble/bin/nim_debugger_mi",
"miDebuggerArgs": "", // you may specify gdb path by --gdb-path=/path/to/your/gdb
"MIMode": "gdb",
"args": [],
"cwd": "${workspaceFolder}"
}
Mac (Apple Silicon)
{
"name": "Debug Nim",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"miDebuggerPath": "${userHome}/.nimble/bin/nim_debugger_mi",
"miDebuggerArgs": "--lldb", //if --lldb is specified, it will try to load lldb-mi from ms-vscode.cpptools; you may specify --lldb-path as well
"MIMode": "lldb",
"args": [],
"cwd": "${workspaceFolder}"
}
Commands
- Nim: Install nim-debugger-mi - Install or reinstall the debugger proxy
- Nim: Check nim-debugger-mi Installation - Verify installation status
The extension uses nim-debugger-mi to transform symbols:
Variables:
localVar_1 → localVar
T5_ → [tmp5] (compiler temporaries)
FR_ → [StackFrame]
Functions:
_ZN4test4mainE → test::main
myFunc__hello_u6 → myFunc
Debug Console:
- Type
p myVar instead of p myVar_1
- All commands work with demangled names
Building from Source
cd vscode-nim-debug
npm install
npm run compile
Press F5 in VSCode to launch the extension development host.
License
MIT - see LICENSE file
Author
yesdrx
Links