mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.63k stars 770 forks source link

Towards a comprehensive debug suite #1749

Open RetroEdit opened 4 years ago

RetroEdit commented 4 years ago

One of the goals for mGBA is a comprehensive debug suite. I would value this feature greatly, and have some ideas.

I separate this into three lists: "required" and "nice to have", and "theoretical". Hopefully my classifications are sensible; I base them off of having spent time using the debuggers of other emulators, and then spending a fair bit of time attempting to use mGBA's debugger.

One may notice I also filed #1117, but this current issue is a result of significantly more experience using emulator debuggers in practice, and has a slightly different (and hopefully more focused) scope than the previous issue.

For me, a comprehensive debug suite requires:

Some features that would be nice to have:

Some theoretical featueres I don't really see elsewhere:

This is by no means a comprehensive list of what I'd like to see it the debug suite. There are many potential features, but I do not want to make this post unreadable, and I feel like my effort in composing such a post would be better spent by attempting to implement such features myself.

matheusmoreira commented 4 years ago

mGBA already supports acting as a GDB server. Would be great if it could also integrate with modern reverse engineering frameworks like Radare2 and Ghidra.

Wouldn't this be more efficient compared to every emulator independently developing their own debugging tools?

RetroEdit commented 4 years ago

I will admit I am not sure how to use mGBA's GDB functionality. However, my impression is that the implementation is not ideal. Certainly, I will claim it's much easier to use a well-integrated debugging interface where standard functionalities are laid out in an intuitive way, though it might not be as powerful as GBD. It is also, as I understand, the ultimate goal for mGBA's debugging tools.

I welcome the idea of integrating static analysis tools. Something like that seems ambitious enough to be an entirely separate project from the short-term goals for mGBA's debugger; integrating tools like this well is not trivial. Additionally, when I spent some time using Ghidra, I found the lack of handling for virtual method tables to be a severe limitation (though I may have missed something, but my ideal setup didn't seem possible, making it a severe limitation; of course, I could eventually write my own if none exists, as I noted in the previous issue).

In any case, it's work someone has to do, so progress will largely be shaped by the development priorities of those actually working on mGBA.

YoshiRulz commented 4 years ago

The Debugger in EmuHawk uses external libdarm for disassembly. edit: So it would be nice to replace that with mGBA's own solution.

see also TASVideos/BizHawk#2312

endrift commented 4 years ago

Ok? I've already written a disassembler. And forcing people to use a third-party program with its own release schedule when I've already got progress towards it on my own debugger doesn't really sound like a solution.

RetroEdit commented 4 years ago

BizHawk's debugger is super janky and broken in my experience. I've never gotten it to work consistently or productively. mGBA seems to have a better debugging infrastructure than BizHawk's current stuff.

matheusmoreira commented 3 years ago

People are already using mgba with Ghidra in order to reverse engineer GBA games.

Looks like it already implements every requirement described in this issue. Not sure about the nice-to-have features though. It should be possible though.