Thread with 15 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…
god as i drill deeper and deeper into this call stack, reverse-engineering this c++ app with no symbols, i keep fucking doing this to myself:
haha joke’s on me, some of them are std::wstring!!
words cannot describe how much better, more efficient, more effective, more fun the debugging experience is once you have an actual debugger to work with
i completely lost track of how many levels deep in the stack i got in this app, it was at least a dozen…
and then i discover that it can’t possibly be a problem with that bit of the code. in fact, it’s probably something very simple:
a missing slash in an absolute path
😅😅😅
(gdb) p *(char**)$r1
$5 = 0x3000b3ec "User/Applications/00000000-0000-0000-0000-", '0' <repeats 12 times>, "/FooBar.app"
gdb casting shade on the length of that UUID lmao
sometimes an app breaks your resolve. this app has finally done this to me. i haven’t the faintest idea why it’s making such strange assumptions about paths. everything i can gather tells me it must be wrong.
i’ll just… add the app-specific hack. just this once. it’s okay.
WAIT THE DYNAMIC LINKING FOR POSITION-INDEPENDENT CODE HAS BEEN BROKEN THIS ENTIRE TIME
h
how did i get three apps working already. how did this app get anywhere when it would literally write the function pointer to the wrong place. hhhh
😭