Merge pull request #230 from shadps4-emu/stabilization12

reduced logging
This commit is contained in:
georgemoralis 2024-07-01 23:53:59 +03:00 committed by GitHub
commit dc8d3b208c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 51 deletions

View File

@ -379,6 +379,12 @@ void Linker::DebugDump() {
std::filesystem::create_directory(filepath);
m.get()->import_sym.DebugDump(filepath / "imports.txt");
m.get()->export_sym.DebugDump(filepath / "exports.txt");
if (m.get()->elf.IsSelfFile()) {
m.get()->elf.SelfHeaderDebugDump(filepath / "selfHeader.txt");
m.get()->elf.SelfSegHeaderDebugDump(filepath / "selfSegHeaders.txt");
}
m.get()->elf.ElfHeaderDebugDump(filepath / "elfHeader.txt");
m.get()->elf.PHeaderDebugDump(filepath / "elfPHeaders.txt");
}
}

View File

@ -226,8 +226,6 @@ void Elf::Open(const std::filesystem::path& file_name) {
m_f.ReadObject(m_self_id_header);
}
}
DebugDump();
}
bool Elf::IsSelfFile() const {
@ -326,54 +324,6 @@ bool Elf::IsElfFile() const {
return true;
}
void Elf::DebugDump() {
if (is_self) { // If we load elf instead
LOG_INFO(Loader, "{}", SElfHeaderStr());
for (u16 i = 0; i < m_self.segment_count; i++) {
LOG_INFO(Loader, "{}", SELFSegHeader(i));
}
}
LOG_INFO(Loader, "{}", ElfHeaderStr());
if (m_elf_header.e_phentsize > 0) {
LOG_INFO(Loader, "Program headers:");
for (u16 i = 0; i < m_elf_header.e_phnum; i++) {
LOG_INFO(Loader, "{}", ElfPHeaderStr(i));
}
}
if (m_elf_header.e_shentsize > 0) {
LOG_INFO(Loader, "Section headers:");
for (u16 i = 0; i < m_elf_header.e_shnum; i++) {
LOG_INFO(Loader, "--- shdr {} --", i);
LOG_INFO(Loader, "sh_name ........: {}", m_elf_shdr[i].sh_name);
LOG_INFO(Loader, "sh_type ........: {:#010x}", m_elf_shdr[i].sh_type);
LOG_INFO(Loader, "sh_flags .......: {:#018x}", m_elf_shdr[i].sh_flags);
LOG_INFO(Loader, "sh_addr ........: {:#018x}", m_elf_shdr[i].sh_addr);
LOG_INFO(Loader, "sh_offset ......: {:#018x}", m_elf_shdr[i].sh_offset);
LOG_INFO(Loader, "sh_size ........: {:#018x}", m_elf_shdr[i].sh_size);
LOG_INFO(Loader, "sh_link ........: {:#010x}", m_elf_shdr[i].sh_link);
LOG_INFO(Loader, "sh_info ........: {:#010x}", m_elf_shdr[i].sh_info);
LOG_INFO(Loader, "sh_addralign ...: {:#018x}", m_elf_shdr[i].sh_addralign);
LOG_INFO(Loader, "sh_entsize .....: {:#018x}", m_elf_shdr[i].sh_entsize);
}
}
if (is_self) {
LOG_INFO(Loader, "SELF info:");
LOG_INFO(Loader, "auth id ............: {:#018x}", m_self_id_header.authid);
LOG_INFO(Loader, "program type .......: {}",
GetProgramTypeName(m_self_id_header.program_type));
LOG_INFO(Loader, "app version ........: {:#018x}", m_self_id_header.appver);
LOG_INFO(Loader, "fw version .........: {:#018x}", m_self_id_header.firmver);
std::string digest;
for (int i = 0; i < 32; i++) {
digest += fmt::format("{:02X}", m_self_id_header.digest[i]);
}
LOG_INFO(Loader, "digest..............: 0x{}", digest);
}
}
std::string Elf::SElfHeaderStr() {
std::string header = fmt::format("======= SELF HEADER =========\n", m_self.magic);
header += fmt::format("magic ..............: 0x{:X}\n", m_self.magic);
@ -542,4 +492,34 @@ bool Elf::IsSharedLib() {
return m_elf_header.e_type == ET_SCE_DYNAMIC;
}
void Elf::ElfHeaderDebugDump(const std::filesystem::path& file_name) {
Common::FS::IOFile f{file_name, Common::FS::FileAccessMode::Write,
Common::FS::FileType::TextFile};
f.WriteString(ElfHeaderStr());
}
void Elf::SelfHeaderDebugDump(const std::filesystem::path& file_name) {
Common::FS::IOFile f{file_name, Common::FS::FileAccessMode::Write,
Common::FS::FileType::TextFile};
f.WriteString(SElfHeaderStr());
}
void Elf::SelfSegHeaderDebugDump(const std::filesystem::path& file_name) {
Common::FS::IOFile f{file_name, Common::FS::FileAccessMode::Write,
Common::FS::FileType::TextFile};
for (u16 i = 0; i < m_self.segment_count; i++) {
f.WriteString(SELFSegHeader(i));
}
}
void Elf::PHeaderDebugDump(const std::filesystem::path& file_name) {
Common::FS::IOFile f{file_name, Common::FS::FileAccessMode::Write,
Common::FS::FileType::TextFile};
if (m_elf_header.e_phentsize > 0) {
for (u16 i = 0; i < m_elf_header.e_phnum; i++) {
f.WriteString(ElfPHeaderStr(i));
}
}
}
} // namespace Core::Loader

View File

@ -468,7 +468,6 @@ public:
void Open(const std::filesystem::path& file_name);
bool IsSelfFile() const;
bool IsElfFile() const;
void DebugDump();
[[nodiscard]] self_header GetSElfHeader() const {
return m_self;
@ -503,6 +502,10 @@ public:
void LoadSegment(u64 virtual_addr, u64 file_offset, u64 size);
bool IsSharedLib();
void ElfHeaderDebugDump(const std::filesystem::path& file_name);
void SelfHeaderDebugDump(const std::filesystem::path& file_name);
void SelfSegHeaderDebugDump(const std::filesystem::path& file_name);
void PHeaderDebugDump(const std::filesystem::path& file_name);
private:
Common::FS::IOFile m_f{};