Thread with 10 posts
jump to expanded postthe next release of touchHLE will have a new feature that 99.9% of users will never have a use for, but which will hopefully save me a lot of time/effort/suffering/tears in future
I implemented the GDB Remote Serial Protocol :3
https://github.com/hikari-no-yume/touchHLE/commit/00aa841ec2c12c94c6194adf64432ec10a404f93
here’s my review of the GDB Remote Serial Protocol, having implemented a small subset of it:
it’s… fine. the docs lack a few details, but you can figure them out from reading the GDB source code and from seeing how GDB responds to your packets. I’m glad it’s all ASCII.
I’m also glad it gracefully degrades. it assumes only the absolute minimum feature set. every single modern fancy feature is optional, because it’ll query or probe for support before trying to use those.
well… GDB will, at least. LLDB is another story ^^;;;;
I really appreciate that GDB hasn’t removed support for the deprecated way of doing multi-threading, because I think the modern way would be a pain to implement for me.
and now I found a (very annoying) GDB bug lol https://sourceware.org/bugzilla/show_bug.cgi?id=30234
I wrote a debugging guide 😤 https://github.com/hikari-no-yume/touchHLE/blob/trunk/DEBUGGING.md
using a real debugger is amazing, I can effectively insert debug prints into a binary:
(gdb) b *0x29a88
Breakpoint 1 at 0x29a88
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>p *(char**)$r0
>continue
>end
(gdb) c
oh there’s actually a command for this: dprintf
the return on investment from implementing a GDB server in your emulator is incredible. my implementation is like 300 lines and does the bare minimum (memory and register read/write, step and continue), and now I have breakpoints, arbitrary C expression prints, disassembly view…
@hikari really impressive that it took so little code
I guess it makes sense since people often want gdb to work on tiny microcontrollers and stuff where having anything work on the guest device at all is shockingly difficult, so the debugger is under great pressure to do as much as possible with as little as possible.
@0x2ba22e11 yup! I have the luxury of TCP streams and a full-fat standard library, but this protocol was clearly intended for like, a microcontroller connected over serial!