skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.67k stars 185 forks source link

Support Guile scripts for gdb? #60

Open Peter0x44 opened 1 year ago

Peter0x44 commented 1 year ago

Currently, the GDB provided doesn't have support for either of the scripting languages GDB supports (Python and Guile)

Python isn't currently supported, because CPython isn't supporting cross-compilation with a windows target, but it seems Guile does. At least, here is one repository claiming to do just that:

https://github.com/Madsy/guile-automatic-build

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Writing-a-Guile-Pretty_002dPrinter.html Here, it's also documented that you can write gdb pretty-printers using Guile. This could potentially be a solution for #16, though I'm not certain about this.

I think it's worth some investigation either way, I figured I'd open this issue in case anyone else has already discovered some info regarding why this may or may not be possible.

Peter0x44 commented 1 year ago

GNU Make also has some sort of support for Guile scripts embedded. If it is figured out, I suppose that feature should be enabled too: https://www.gnu.org/software/make/manual/html_node/Guile-Integration.html

(though, I have never seen a single Makefile using this feature)

skeeto commented 1 year ago

Interesting idea. I'd just sort of mentally dismissed Guile, but it does appear to be a more viable option than CPython. GDB's built-in scripting language is badly neglected, so it would be nice to fill that gap. I spent some time investigating what it would take:

Were it Lua instead — a joy and a breeze both to build and embed! — I'd definitely go for it, but Guile seems like a lot more trouble than it's worth. Who knew a Scheme implementation could be so complex and finicky?

Peter0x44 commented 1 year ago

I also went ahead and investigated whether it would enable standard C++ container pretty-printers, apparently not. Trying a gdb configured with --without-python could not pretty-print an std::string, despite having Guile. Those all need python, so it wouldn't even solve that. The API mentioned is just if you want to write pretty-printers for your own data structures. I concur it doesn't seem worth the hassle, plus adding those numerous dependencies.

This idea seems like a dead end, but maybe it can change in future.

Who knew a Scheme implementation could be so complex and finicky?

I agree, it's impressive how so much complexity can be crammed into a language seemingly made for embedding and extensions.

skeeto commented 1 year ago

Those all need python, so it wouldn't even solve that.

Ah, I suspected that might be the case. Honestly, it would be the main reason to link an extension language. Thanks for the followup.