mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 11:35:45 +00:00
functions to dump import functions
This commit is contained in:
parent
fb48626d7e
commit
e9754a2684
4 changed files with 41 additions and 5 deletions
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <Zydis/Zydis.h>
|
||||
#include <common/path_util.h>
|
||||
#include "common/logging/log.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/aerolib/aerolib.h"
|
||||
|
@ -645,6 +646,7 @@ static void RunMainEntry(u64 addr, EntryParams* params, exit_func_t exit_func) {
|
|||
}
|
||||
|
||||
void Linker::Execute() {
|
||||
DebugDump();
|
||||
Core::Libraries::LibKernel::pthreadInitSelfMainThread();
|
||||
EntryParams p{};
|
||||
p.argc = 1;
|
||||
|
@ -654,4 +656,14 @@ void Linker::Execute() {
|
|||
RunMainEntry(module->elf.GetElfEntry() + module->base_virtual_addr, &p, ProgramExitFunc);
|
||||
}
|
||||
|
||||
void Linker::DebugDump() {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
const auto& log_dir = Common::FS::GetUserPath(Common::FS::PathType::LogDir);
|
||||
const std::filesystem::path debug(log_dir / "debugdump");
|
||||
std::filesystem::create_directory(debug);
|
||||
for (const auto& m : m_modules) {
|
||||
m.get()->import_sym.DebugDump(debug / "imports.txt");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -127,6 +127,7 @@ public:
|
|||
void Resolve(const std::string& name, Loader::SymbolType Symtype, Module* m,
|
||||
Loader::SymbolRecord* return_info);
|
||||
void Execute();
|
||||
void DebugDump();
|
||||
|
||||
private:
|
||||
const ModuleInfo* FindModule(const Module& m, const std::string& id);
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <common/string_util.h>
|
||||
#include "common/io_file.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/types.h"
|
||||
#include "core/aerolib/aerolib.h"
|
||||
#include "core/loader/symbols_resolver.h"
|
||||
|
||||
namespace Core::Loader {
|
||||
|
@ -15,9 +18,8 @@ void SymbolsResolver::AddSymbol(const SymbolResolver& s, u64 virtual_addr) {
|
|||
}
|
||||
|
||||
std::string SymbolsResolver::GenerateName(const SymbolResolver& s) {
|
||||
return fmt::format("{} lib[{}_v{}]mod[{}_v{}.{}][{}]", s.name, s.library, s.library_version,
|
||||
s.module, s.module_version_major, s.module_version_minor,
|
||||
SymbolTypeToS(s.type));
|
||||
return fmt::format("{}#{}#{}#{}#{}#{}#{}", s.name, s.library, s.library_version, s.module,
|
||||
s.module_version_major, s.module_version_minor, SymbolTypeToS(s.type));
|
||||
}
|
||||
|
||||
const SymbolRecord* SymbolsResolver::FindSymbol(const SymbolResolver& s) const {
|
||||
|
@ -32,4 +34,23 @@ const SymbolRecord* SymbolsResolver::FindSymbol(const SymbolResolver& s) const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void SymbolsResolver::DebugDump(const std::filesystem::path& file_name) {
|
||||
Common::FS::IOFile f;
|
||||
f.Open(file_name, Common::FS::FileAccessMode::Write, Common::FS::FileType::TextFile);
|
||||
for (const auto& symbol : m_symbols) {
|
||||
const auto ids = Common::SplitString(symbol.name, '#');
|
||||
std::string nidName = "";
|
||||
auto aeronid = AeroLib::FindByNid(ids.at(0).c_str());
|
||||
if (aeronid != nullptr) {
|
||||
nidName = aeronid->name;
|
||||
} else {
|
||||
nidName = "UNK";
|
||||
}
|
||||
f.WriteString(fmt::format("{} {} {} {} {} {} {} {} {}\n", symbol.virtual_address, ids.at(0),
|
||||
nidName, ids.at(1), ids.at(2), ids.at(3), ids.at(4), ids.at(5),
|
||||
ids.at(6)));
|
||||
}
|
||||
f.Close();
|
||||
}
|
||||
|
||||
} // namespace Core::Loader
|
||||
|
|
|
@ -44,8 +44,8 @@ public:
|
|||
|
||||
static std::string GenerateName(const SymbolResolver& s);
|
||||
|
||||
static std::string SymbolTypeToS(SymbolType symType) {
|
||||
switch (symType) {
|
||||
static std::string SymbolTypeToS(SymbolType sym_type) {
|
||||
switch (sym_type) {
|
||||
case SymbolType::Unknown:
|
||||
return "Unknown";
|
||||
case SymbolType::Function:
|
||||
|
@ -59,6 +59,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void DebugDump(const std::filesystem::path& file_name);
|
||||
|
||||
private:
|
||||
std::vector<SymbolRecord> m_symbols;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue