Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DebugTools: Scan for functions from the ELF instead of from memory #11856

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

chaoticgd
Copy link
Contributor

@chaoticgd chaoticgd commented Sep 28, 2024

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 the MIPSAnalyst to use which is implemented by the debug interfaces and a new ElfMemoryReader class. The SymbolGuardian::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 since SymbolDatabase::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 entered Host::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

  • Check that symbol table loading still works.
  • Check that the functions tab still gets populated correctly, especially for games that don't have a symbol table.
  • Try constantly restarting the VM.

Copy link
Contributor

@kamfretoz kamfretoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more crashing when restarting the VM.

Copy link
Member

@F0bes F0bes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix. Looks good :)

@F0bes F0bes merged commit 31dcda0 into PCSX2:master Sep 28, 2024
12 checks passed
@chaoticgd chaoticgd deleted the symbol_guardian_blocking branch September 28, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants