DebugTools: Scan for functions from the ELF instead of from memory #11856
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
I've been planning to change the behaviour of the
MIPSAnalyst
so that it at first only reads from the ELF file on the disc, and then later the user can re-run it on demand if the code in memory was overwritten.This PR implements the first half of that plan. I've added a
MemoryReader
interface for theMIPSAnalyst
to use which is implemented by the debug interfaces and a newElfMemoryReader
class. TheSymbolGuardian::ImportElf
function has been updated accordingly.While I was at it, I also fixed some error handling logic in
MIPSAnalyst::ScanForFunctions
. In practice I believe this was harmless sinceSymbolDatabase::get_symbol_source
should really never fail, however it's still nice to get this fixed.Rationale behind Changes
The previous behaviour resulted in a race condition where
MIPSAnalyst::ScanForFunctions
would be run at a different time, and hence on different memory contents, depending on how long it took to parse the symbol table(s).More seriously, f0bes pointed out a deadlock bug in the previous implementation where if
SymbolGuardian::ShutdownWorkerThread
was called right at the same moment the worker thread enteredHost::RunOnCPUThread
both threads would block on each other.This behaviour would only be appropriate if the user was playing Ratchet: Deadlocked, and is hence what prompted me to split this into two pull requests.
Suggested Testing Steps