Replies: 9 comments 8 replies
-
@flagrama Just wanted to let you know that your request has not been ignored - there already may be a fix in-play, but I need to verify that. Will let you know when I know. |
Beta Was this translation helpful? Give feedback.
-
@flagrama Apologies for the delayed response - am trying to verify some of our fixes for related issues but having a difficult time getting gdb to work with the Ares emulator at all. Any tips regarding setup? (Am testing running “Sonic the Hedgehog”, but have no registers, no disassembly, and no ability to break.) |
Beta Was this translation helpful? Give feedback.
-
I have yet to find an N64 rom that works "correctly" in gdb proper, so am considering closing this issue until the emulator is in a more stable state. Objections? |
Beta Was this translation helpful? Give feedback.
-
I have been tracking this on and off. Sorry for missing the conversation last week. Example video of gdb working with ares on the Ocarina of Time randomizer romhack: https://www.youtube.com/watch?v=QdERiG-p0Kw&t=187s The file I passed to gdb is at https://github.com/mracsys/OoT-Randomizer/blob/gdb_debugging/ASM/build/gdb_bundle.o. This contains only the the randomizer's added code, no Nintendo copyrighted-assets. Ares needs a full rom patched with that branch of the randomizer. It would be helpful to use ghidra for lower level debugging without resorting to raw gdb commands. I have the same problems as @flagrama |
Beta Was this translation helpful? Give feedback.
-
@d-millar there seems to have been a bug in attaching gdb to ares' n64 core in versions 140 and 141 which should now be fixed in nightly builds. Which 140 was likely the version you tested. I confirmed with @mracsys that they were using 139 for that video. Perhaps one of you could give the ares nightly build a try? I don't have anything set up to try it myself at the moment to be honest. |
Beta Was this translation helpful? Give feedback.
-
@flagrama that works much better! we still have a bug in our code (pc is being interpreted as negative somewhere). will let you know when I have a fix! |
Beta Was this translation helpful? Give feedback.
-
hmmmm, ok - well, our bug aside, it still seems to me that the registers returned by the g packet are sketchy. When I connect from gdb (no Ghidra in the picture), "info registers" always return 0xFFFFFFFF for the PC, which seems questionable. Any chance I'm doing something clearly wrong? Am basically, enabling the gdbstub, loading a ROM, waiting for it to be running, and then connectiing. "Show arch" returns "mips:4000", which seems close enough, but the register values make no sense to me. |
Beta Was this translation helpful? Give feedback.
-
Well, if you can point me to the code for building the custom version of gdb, I can try that, assuming it supports MI2, or at least see if it works with the ROMs I have, which are random old games (Asteroids, Frogger, etc.). |
Beta Was this translation helpful? Give feedback.
-
Yep, I just pushed the branch with the (slightly) less hacky implementation. Probably be a few days before it makes "master" and won't make the next release, but.... |
Beta Was this translation helpful? Give feedback.
-
I do a fair bit of for-fun software development and reverse engineering on the Nintendo 64 hardware and software. Debugging is always an issue though because only a couple of Windows-only emulators have fleshed out working debuggers. On the other hand, the ares emulator has a gdbstub which works pretty well for debugging your own code, but isn't quite as useful if your code is a modification to an existing binary.
I already use Ghidra for documenting these existing binaries, so I figured using it's debugger with ares' gdbstub would be pretty easy and would let me reference my documentation easier. So far it has been difficult to get the debugger to work properly in the first place.
First, I don't know if this is relevant, but I use the N64LoaderWV extension to import the ROMs and give a decent starting point for documentation. Maybe it is missing information that it should be providing to make this work easier.
Second, when I run the debugger normally I don't get any display in the dynamic view, memory view, regions, etc. Instead in the terminal I get overflow exceptions about converting a negative signed integer to a unsigned integer. This seems pretty obvious to me, it's a sign-extension issue. The PC and general purpose registers of the N64 CPU are all 64-bit sign extended, so for example the beginning of RDRAM at
0x80000000
will be stored as0xFFFFFFFF80000000
when in the PC or a GPR.Furthermore, if I manually edit
commands.py
and mask these addresses with0xFFFFFFFF
the debugger progresses much further. I'm able to actually see values in the memory view, the regions tab has a region at least. However this does not yet solve all my issues. gdb is still quite unhappy being unable to find the beginning of functions. Trying to step through code seems to increment randomly rather than 4 bytes at a time. Specifically it seems to run until a branch or delay slot, I didn't pay super close attention to which. And trying to set breakpoints fails. In the dynamic view they fail saying that the value 0xFFFFFFFF80xxxxxx is out of range. Trying to set them elsewhere, like in my listing with all the documented code it generally says something about not being in the tracepath or the same snap or something.So I'm wondering what exactly I have to do to improve the situation from here.
Does the N64 loader need to provide NEC VR4300 specific data files? Do data files need to be added to Ghidra's source somehow? Is there something missing in existing data files? Something entirely different?
I'd appreciate any help I can get with this as I believe it would help my workflow immensely.
Beta Was this translation helpful? Give feedback.
All reactions