"maintenance info sections" expected output and other bare metal woes. #5337
Replies: 4 comments 7 replies
-
@nicolasnoble Hey Nicolas, with a little luck, will get a chance to look at your issues in detail tomorrow. In the meantime, if you look at Discussion #4301 and Ghidra/Debug/Debugger-agent-gdb/data/scripts/fallback_info_proc_mappings.gdb, I think you’ll see what you need for “maint info sections” and “info proc mappings”. Basically, you want to return a single line indicating all of memory is in play and is contained in one section. On the remote target threadid, might be as simple as not returning the tid in hex, but I need to look at that in a bit more detail. The breakpoint failure most definitely sounds liked a casualty of the missing commands above. Basically, without a module list, the debugger doesn’t know how to map static Ghidra programs to dynamic memory. You can try forcing all memory in from the Regions view and mapping memory identically from the Modules view as a test, although that’s probably not the ideal long term solution. No immediate guess on the stack unwind problem - hopefully tomorrow. Probably, better to modify the debugger opinions than the mips.ldefs unless you plan to write a language module for the 3000. Will ping the team on the best approach there and get back to you. |
Beta Was this translation helpful? Give feedback.
-
So with these changes, (and still the change to the mips.ldefs file) breakpoints now work properly, but hovering on variables now fail differently. When trying to hover on a variable the first time, there'll be an out of bound exception during this callstack: Any further hovering just gets a generic failure about how it can't find the stack frame. |
Beta Was this translation helpful? Give feedback.
-
@nicolasnoble @dev747368 has a tickets in for the various hover issues - will add this to the queue. Also, if I get a chance today, will see if there's a straightforward workaround. Thanks! |
Beta Was this translation helpful? Give feedback.
-
@nicolasnoble Just following up: the video was very very helpful - am going to lobby all of customers to do this. :) Various issues: Again, thanks for the visuals. Keep us posted if you hit other bugs! |
Beta Was this translation helpful? Give feedback.
-
Alright so, I've decided to try the ghidra debugger again with the 10.3 release, and I'm still not getting good results.
Context: I'm the author of PCSX-Redux, and I have written a gdb server in there that gdb or IDA can successfully connect to in general, and properly debug.
In order to try out what I'm talking about here, one can simply download PCSX-Redux. The Windows version contains a file called
openbios.elf
, an open source software which is a MIPS r3000 binary, able to boot the PlayStation. It can simply be loaded within ghidra to analyze.Within PCSX-Redux, the default installation will load openbios and it can be debugged straight by enabling the debugger: in Configuration->Emulation, uncheck "Dynarec CPU", check "Enable Debugger", and check "Enable GDB Server". You can then connect to it using gdb-multiarch:
I managed to get past a few hurdles:
ghidra doesn't recognize the
mips:3000
architecture:ghidra/Ghidra/Processors/MIPS/data/languages/mips.ldefs
Line 33 in ce5f6b4
mips:3000
makes ghidra accept an offer from the generic gdb class, which is probably the only one that should handle this properly. Note that I don't think there's a good way to handle this in upstream: correctly handling the nuances between the r3000 and r4000 and above CPUs would require doing a breaking change by further refining the processor IDs. "MIPS:LE:32:default" would neither fit r3000 nor r4000 properly anymore.ghidra doesn't seem to understand the "remote target" threadid. I'm sending some generic thread information to the gdb client, and the non-machine version of
info threads
returns this:Which ends up confusing this function:
ghidra/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/manager/impl/GdbThreadInfo.java
Line 78 in ce5f6b4
I had to add the following:
Otherwise, with
this.tid
beingnull
, then down the line, there'll be multiple exceptions with various pieces of the code trying to use it as a number.Now, with these two changes, I can properly attach and step through the code, but:
maintenance info sections
command returns nothing, but at this point, I don't have a good idea of what this is expected to do nor return. I have the feeling this is going to be the same problem as withinfo proc mappings
, which can then be solved with another alias, but given I don't know what to send out, I'm a bit stuck here. I guess I could also try changing the server to support the command properly, but I'm similarly stuck in what this is expected to do anyway. Note that I can place breakpoints manually using the gdb console, and they'll even show up in the Dynamic view, or the Objects view. I just can't interact with breakpoints in the UI.Error: java.lang.NullPointerException: Cannot invoke "ghidra.app.plugin.core.debug.stack.UnwindInfo.function()" because "this.info" is null
. I haven't started investigating this one yet, aside from this exception that's firing:ghidra/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/stack/AnalysisUnwoundFrame.java
Lines 97 to 99 in ce5f6b4
What would be the best course of action for me to clear out these next hurdles?
Beta Was this translation helpful? Give feedback.
All reactions