Open miguelmartin75 opened 1 year ago
+1 Please let's write our own debugger.
Implementing for GDB would be similar process ^1. Imo adding support to existing debuggers is better than writing our own since it means less maintenance and allows easy integration with existing tools
Summary
Related issue which is closed: https://github.com/nim-lang/Nim/issues/8596
print x
rather thanprint x_<nim-specific-mangle>
Description
Here are my findings from researching LLDB. I have not researched GDB. I thought I would post them here in case others wanted to implement/execute this or whether I have missed something in my proposed solution.
For LLDB, one needs to:
References:
From reading the source: a unique mangling scheme identifiable from others is needed along with code to de-mangle it. All mangling schemes used by other languages/compilers (C++/Itanium, C++/MSVC, D, Rust) use a prefix to classify how/from what compiler the name was mangled.
For Nim: identifying the mangling scheme/language from a mangled name is more complex. This is because Nim is compiled into a target language that uses an existing mangling scheme. If we had control over the binary or Debug Symbol output file (e.g. DWARF), I believe this would be easier, but again: since the target language's compiler is being used it is slightly more complex.
To solve this with today's standard Nim compiler, here are my researched steps:
GetDemangledFunctionNameWithoutArguments
)Alternatives
Here are some alternatives I can think of, but will likely require more work:
Examples
No response
Backwards Compatibility
My proposed solution will change the way the nim compiler mangles, but for backward compatibility: one could offer a flag to mangle the old way. Though I don't think this flag would be necessary: just re-compile your source if you want debugging support.
Links
Mangling & D:
LLDB codepointers:
Writing a debugger: