No description
Find a file
YesDrX d9d03e7d0f
Add system dependencies installation step for Ubuntu
Added step to install system dependencies for Ubuntu.
2025-12-17 14:24:20 -05:00
.github/workflows Add system dependencies installation step for Ubuntu 2025-12-17 14:24:20 -05:00
src minor improvement 2025-12-17 10:17:20 -05:00
tests init 2025-12-08 15:28:01 -05:00
vscode-nim-debug fix vscode 2025-12-12 14:26:37 -05:00
.gitignore init 2025-12-08 15:28:01 -05:00
LICENSE init 2025-12-08 15:28:01 -05:00
nim_debugger_mi.nimble minor improvement 2025-12-17 10:17:20 -05:00
README.md fix vscode 2025-12-12 14:26:37 -05:00
screenshot.png init 2025-12-08 15:28:01 -05:00

nim-debugger-mi

A GDB/MI proxy for Nim that provides transparent symbol mangling/demangling for a better debugging experience in IDEs.

Features

  • Transparent Symbol Translation: Automatically demangles Nim symbols in GDB output and mangles user input
  • Function Name Demangling: Shows readable function names in call stacks (both Nim and C++ styles)
  • Internal Variable Renaming: Displays compiler-generated variables with readable names
  • Native Debugging: Works with standard GDB/LLDB through the MI protocol
  • VSCode Integration: Seamless integration with VSCode's native debugger
  • Cross-platform: Linux/MacOS/Windows

TODO: wrap around msvscode-cpptools DAP

Installation

nimble install nim_debugger_mi

Screenshot

Usage

With VSCode

Install the "Nim Debugger" VSCode extension for automatic configuration, or manually configure your launch.json:

Linux/WSL

{
    "name": "Nim",
    "type": "cppdbg",
    "request": "launch",
    "program": "${fileDirname}/${fileBasenameNoExtension}",
    "miDebuggerPath": "${userHome}/.nimble/bin/nim_debugger_mi",
    "miDebuggerArgs": "", //you may specify gdb path by --gdb=/path/to/your/gdb
    "MIMode": "gdb",
    "args": [],
    "cwd": "${workspaceFolder}"
}

Mac

{
    "name": "Nim",
    "type": "cppdbg",
    "request": "launch",
    "program": "${fileDirname}/${fileBasenameNoExtension}",
    "miDebuggerPath": "${userHome}/.nimble/bin/nim_debugger_mi",
    "miDebuggerArgs": "--lldb", //you may specify lldb path by --lldb=/path/to/your/lldb-mi
    "MIMode": "lldb",
    "args": [],
    "cwd": "${workspaceFolder}"
}

Windows

{
    "name": "Nim",
    "type": "cppdbg",
    "request": "launch",
    "program": "${fileDirname}/${fileBasenameNoExtension}",
    "miDebuggerPath": "${userHome}/.nimble/bin/nim_debugger_mi.cmd",
    "miDebuggerArgs": "", //you may specify gdb path by --gdb=/path/to/your/gdb.exe
    "MIMode": "gdb",
    "args": [],
    "cwd": "${workspaceFolder}"
}

before starting debugging, you should build your binary with debuginfo:

nim c --debuginfo -d:debug --debugger:native ./src/main.nim

How It Works

The proxy sits between your IDE and GDB, transforming symbols bidirectionally:

Output (GDB → IDE):

  • localVar_1localVar
  • _ZN4test4mainEtest::main
  • T5_[tmp5]

Input (IDE → GDB):

  • localVarlocalVar_1
  • [tmp5]T5_

Building from Source

git clone https://github.com/yesdrx/nim-debugger-mi
cd nim-debugger-mi
nimble build

Requirements

  • Nim >= 1.6.0
  • GDB or LLDB
  • C compiler (for custom process management)

License

MIT License - see LICENSE file for details

Author

yesdrx