Separate imports and exports for listing.

This commit is contained in:
Henrik Rydgård 2025-04-01 12:15:46 +02:00
parent 717ea3ec8e
commit 5e18576f59
5 changed files with 53 additions and 41 deletions

View file

@ -295,14 +295,14 @@ void PSPModule::ImportFunc(const FuncSymbolImport &func, bool reimporting) {
// Keep track and actually hook it up if possible.
importedFuncs.push_back(func);
impExpModuleNames.insert(func.moduleName);
impModuleNames.insert(func.moduleName);
ImportFuncSymbol(func, reimporting, GetName());
}
void PSPModule::ImportVar(WriteVarSymbolState &state, const VarSymbolImport &var) {
// Keep track and actually hook it up if possible.
importedVars.push_back(var);
impExpModuleNames.insert(var.moduleName);
impModuleNames.insert(var.moduleName);
ImportVarSymbol(state, var);
}
@ -311,7 +311,7 @@ void PSPModule::ExportFunc(const FuncSymbolExport &func) {
return;
}
exportedFuncs.push_back(func);
impExpModuleNames.insert(func.moduleName);
expModuleNames.insert(func.moduleName);
ExportFuncSymbol(func);
}
@ -320,7 +320,7 @@ void PSPModule::ExportVar(const VarSymbolExport &var) {
return;
}
exportedVars.push_back(var);
impExpModuleNames.insert(var.moduleName);
expModuleNames.insert(var.moduleName);
ExportVarSymbol(var);
}
@ -1150,11 +1150,11 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
// Opportunity to dump the decrypted elf, even if we choose to fake it.
// NOTE: filename is not necessarily a good choice!
std::string elfFilename(KeepAfterLast(filename, '/'));
if (elfFilename.empty()) {
if (elfFilename.empty() || startsWith(elfFilename, "sce_lbn")) {
// Use the name from the header.
elfFilename = head->modname;
}
DumpFileIfEnabled(ptr, elfSize, elfFilename.c_str(), DumpFileType::PRX);
DumpFileIfEnabled(ptr, (u32)elfSize, elfFilename.c_str(), DumpFileType::PRX);
// This should happen for all "kernel" modules.
*error_string = "Missing key";

View file

@ -161,22 +161,31 @@ public:
void ExportVar(const VarSymbolExport &var);
template <typename T>
void RebuildImpExpList(const std::vector<T> &list) {
void RebuildExpList(const std::vector<T> &list) {
for (size_t i = 0; i < list.size(); ++i) {
impExpModuleNames.insert(list[i].moduleName);
expModuleNames.insert(list[i].moduleName);
}
}
template <typename T>
void RebuildImpList(const std::vector<T> &list) {
for (size_t i = 0; i < list.size(); ++i) {
impModuleNames.insert(list[i].moduleName);
}
}
void RebuildImpExpModuleNames() {
impExpModuleNames.clear();
RebuildImpExpList(exportedFuncs);
RebuildImpExpList(importedFuncs);
RebuildImpExpList(exportedVars);
RebuildImpExpList(importedVars);
impModuleNames.clear();
expModuleNames.clear();
RebuildExpList(exportedFuncs);
RebuildImpList(importedFuncs);
RebuildExpList(exportedVars);
RebuildImpList(importedVars);
}
bool ImportsOrExportsModuleName(const std::string &moduleName) {
return impExpModuleNames.find(moduleName) != impExpModuleNames.end();
return impModuleNames.find(moduleName) != impModuleNames.end() ||
expModuleNames.find(moduleName) != expModuleNames.end();
}
NativeModule nm{};
@ -187,7 +196,8 @@ public:
std::vector<FuncSymbolImport> importedFuncs;
std::vector<VarSymbolExport> exportedVars;
std::vector<VarSymbolImport> importedVars;
std::set<std::string> impExpModuleNames;
std::set<std::string> impModuleNames;
std::set<std::string> expModuleNames;
// Keep track of the code region so we can throw out analysis results
// when unloaded.

View file

@ -119,7 +119,7 @@ GlobalUIState GetUIState() {
return globalUIState;
}
void SetGPUBackend(GPUBackend type, const std::string &device) {
void SetGPUBackend(GPUBackend type, std::string_view device) {
gpuBackend = type;
gpuBackendDevice = device;
}
@ -869,7 +869,7 @@ const char *DumpFileTypeToFileExtension(DumpFileType type) {
}
}
void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, const char *name, DumpFileType type) {
void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, std::string_view name, DumpFileType type) {
if (!(g_Config.iDumpFileTypes & (int)type)) {
return;
}
@ -883,7 +883,7 @@ void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, const char *name, Du
}
const char *extension = DumpFileTypeToFileExtension(type);
std::string filenameToDumpTo = StringFromFormat("%s_%s", g_paramSFO.GetDiscID().c_str(), name);
std::string filenameToDumpTo = g_paramSFO.GetDiscID() + "_" + std::string(name);
if (!endsWithNoCase(filenameToDumpTo, extension)) {
filenameToDumpTo += extension;
}

View file

@ -17,6 +17,7 @@
#pragma once
#include <string_view>
#include "Common/CommonTypes.h"
#include "Common/File/Path.h"
#include "Core/CoreParameter.h"
@ -68,7 +69,7 @@ void ResetUIState();
void UpdateUIState(GlobalUIState newState);
GlobalUIState GetUIState();
void SetGPUBackend(GPUBackend type, const std::string &device = "");
void SetGPUBackend(GPUBackend type, std::string_view device = "");
GPUBackend GetGPUBackend();
std::string GetGPUBackendDevice();
@ -128,4 +129,4 @@ inline CoreParameter &PSP_CoreParameter() {
}
// Centralized place for dumping useful files, also takes care of checking for dupes and creating a clickable UI popup.
void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, const char *name, DumpFileType type);
void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, std::string_view name, DumpFileType type);

View file

@ -1489,37 +1489,40 @@ static void DrawModules(const MIPSDebugInterface *debug, ImConfig &cfg, ImContro
if (mod->isFake) {
ImGui::PopStyleColor();
}
if (ImGui::CollapsingHeader("Import/export modules")) {
for (auto &name : mod->impExpModuleNames) {
if (!mod->impModuleNames.empty() && ImGui::CollapsingHeader("Imported modules")) {
for (auto &name : mod->impModuleNames) {
ImGui::TextUnformatted(name);
}
}
if (ImGui::CollapsingHeader("Imports")) {
if (!mod->importedVars.empty()) {
if (ImGui::CollapsingHeader("Vars")) {
if (!mod->expModuleNames.empty() && ImGui::CollapsingHeader("Exported modules")) {
for (auto &name : mod->expModuleNames) {
ImGui::TextUnformatted(name);
}
}
if (!mod->importedFuncs.empty() || !mod->importedVars.empty()) {
if (ImGui::CollapsingHeader("Imports")) {
if (!mod->importedVars.empty() && ImGui::CollapsingHeader("Vars")) {
for (auto &var : mod->importedVars) {
ImGui::TextUnformatted("(some var)"); // TODO
}
}
}
for (auto &import : mod->importedFuncs) {
// Look the name up in our HLE database.
const HLEFunction *func = GetHLEFunc(import.moduleName, import.nid);
ImGui::TextUnformatted(import.moduleName);
if (func) {
ImGui::SameLine();
ImGui::TextUnformatted(func->name);
for (auto &import : mod->importedFuncs) {
// Look the name up in our HLE database.
const HLEFunction *func = GetHLEFunc(import.moduleName, import.nid);
ImGui::TextUnformatted(import.moduleName);
if (func) {
ImGui::SameLine();
ImGui::TextUnformatted(func->name);
}
ImGui::SameLine(); ImClickableValue("addr", import.stubAddr, control, ImCmd::SHOW_IN_CPU_DISASM);
}
ImGui::SameLine(); ImClickableValue("addr", import.stubAddr, control, ImCmd::SHOW_IN_CPU_DISASM);
}
}
if (!mod->exportedFuncs.empty() || !mod->exportedVars.empty()) {
if (ImGui::CollapsingHeader("Exports")) {
if (!mod->exportedVars.empty()) {
if (ImGui::CollapsingHeader("Vars")) {
for (auto &var : mod->importedVars) {
ImGui::TextUnformatted("(some var)"); // TODO
}
if (!mod->exportedVars.empty() && ImGui::CollapsingHeader("Vars")) {
for (auto &var : mod->importedVars) {
ImGui::TextUnformatted("(some var)"); // TODO
}
}
for (auto &exportFunc : mod->exportedFuncs) {
@ -1533,8 +1536,6 @@ static void DrawModules(const MIPSDebugInterface *debug, ImConfig &cfg, ImContro
ImGui::SameLine(); ImClickableValue("addr", exportFunc.symAddr, control, ImCmd::SHOW_IN_CPU_DISASM);
}
}
} else {
ImGui::TextUnformatted("(no symbols exported)");
}
}
} else {