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

Auto-dump binaries (PPU Debug), reduce ELF loader RAM usage #14416

Merged
merged 3 commits into from Aug 3, 2023

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Aug 3, 2023

  • Fix regression with manual-KLIC-required files from Qt: Improve PS3 Binaries Decryption tool #13990
  • Dump PPU executables (currently not PRX or OVL) when enabling PPU debug when booting games or on process exitspawn.
  • Optimize memory usage of ELF loader, found by accident when testing the PR.

image

This was the difference in file size when using this dumping code and the decryption tool because elf_object::open/save were not optimized to include inner sections.


if (ppu_load_exec(ppu_exec, false, m_path, DeserialManager()))
{
if (g_cfg.core.ppu_debug)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you put these spu and ppu debug prog saving sections into functions?
It's getting increasingly worse to read the general flow of these code sections

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@elad335 elad335 force-pushed the decrypt branch 2 times, most recently from 5da394e to cf4e568 Compare August 3, 2023 07:44
@elad335 elad335 requested a review from Nekotekina August 3, 2023 08:16
@elad335 elad335 added the Optimization Optimizes existing code label Aug 3, 2023
@elad335 elad335 changed the title Auto-dump decrypted binaries if PPU debug is enabled Auto-dump decrypted binaries if PPU debug is enabled, reduce ELF loader RAM usage Aug 3, 2023
@elad335 elad335 force-pushed the decrypt branch 2 times, most recently from 9a6379d to 72413de Compare August 3, 2023 08:30
@elad335 elad335 changed the title Auto-dump decrypted binaries if PPU debug is enabled, reduce ELF loader RAM usage Auto-dump decrypted binaries (PPU Debug), reduce ELF loader RAM usage Aug 3, 2023
@elad335 elad335 changed the title Auto-dump decrypted binaries (PPU Debug), reduce ELF loader RAM usage Auto-dump binaries (PPU Debug), reduce ELF loader RAM usage Aug 3, 2023
@elad335 elad335 force-pushed the decrypt branch 2 times, most recently from b998dd7 to 915f30c Compare August 3, 2023 10:59
@elad335 elad335 merged commit 744a152 into RPCS3:master Aug 3, 2023
5 checks passed
// Rely on previous sh_offset value!
if (hdr.p_offset <= shdr.sh_offset && shdr.sh_offset + shdr.sh_size - 1 <= hdr.p_offset + hdr.p_filesz - 1)
{
const auto& prog = ::at32(progs, p_index);
Copy link
Contributor

Choose a reason for hiding this comment

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

unused


for (const auto& hdr : progs)
{
if (shdr.bin_view.empty())
Copy link
Contributor

Choose a reason for hiding this comment

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

why not check this in line 440 ?

{
if (out.size() == data.size())
{
// Risky optimization: assume if file size match they are equal and does not need to rewrite it
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this need such an optimization if it's a debug tool anyway?

Copy link
Contributor Author

@elad335 elad335 Aug 4, 2023

Choose a reason for hiding this comment

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

So it would be convenient to use it most of the time, the risks are extremely low and depend on disk errors. The write itself is not atomic so it's not perfect anyways.

Copy link
Contributor Author

@elad335 elad335 Aug 4, 2023

Choose a reason for hiding this comment

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

And even if there are errors, common sense says to delete the file and redump it.

@elad335 elad335 deleted the decrypt branch May 6, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants