mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Add an option to compress .ppsym files when saving or not (was always on before).
This commit is contained in:
@@ -281,6 +281,13 @@ int OpenFD(const Path &path, OpenFlag flags) {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
void CloseFD(int fd) {
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
static bool ResolvePathVista(const std::wstring &path, wchar_t *buf, DWORD bufSize) {
|
||||
typedef DWORD(WINAPI *getFinalPathNameByHandleW_f)(HANDLE hFile, LPWSTR lpszFilePath, DWORD cchFilePath, DWORD dwFlags);
|
||||
|
||||
@@ -56,6 +56,9 @@ enum OpenFlag {
|
||||
// of DirectoryFileSystem::Open here eventually for symmetry.
|
||||
int OpenFD(const Path &filename, OpenFlag flags);
|
||||
|
||||
// Cross-platform way to close FDs, corresponsing in platform support with OpenFD above.
|
||||
void CloseFD(int fd);
|
||||
|
||||
// Resolves symlinks and similar.
|
||||
std::string ResolvePath(std::string_view path);
|
||||
|
||||
|
||||
+45
-27
@@ -42,7 +42,9 @@
|
||||
#include "Common/Log.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/Buffer.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Debugger/SymbolMap.h"
|
||||
|
||||
#ifndef NO_ARMIPS
|
||||
@@ -189,10 +191,10 @@ bool SymbolMap::LoadSymbolMap(const Path &filename) {
|
||||
continue;
|
||||
|
||||
if (!strcmp(name, ".text") || !strcmp(name, ".init") || strlen(name) <= 1) {
|
||||
|
||||
// Ignored
|
||||
} else {
|
||||
switch (type)
|
||||
{
|
||||
// Seems legit
|
||||
switch (type) {
|
||||
case ST_FUNCTION:
|
||||
AddFunction(name, vaddress, size, moduleIndex);
|
||||
break;
|
||||
@@ -209,6 +211,7 @@ bool SymbolMap::LoadSymbolMap(const Path &filename) {
|
||||
}
|
||||
}
|
||||
gzclose(f);
|
||||
activeNeedUpdate_ = true;
|
||||
SortSymbols();
|
||||
return started;
|
||||
}
|
||||
@@ -221,33 +224,49 @@ bool SymbolMap::SaveSymbolMap(const Path &filename) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO(scoped): Use gzdopen
|
||||
#if defined(_WIN32) && defined(UNICODE)
|
||||
gzFile f = gzopen_w(filename.ToWString().c_str(), "w9");
|
||||
#else
|
||||
gzFile f = gzopen(filename.c_str(), "w9");
|
||||
#endif
|
||||
|
||||
if (f == Z_NULL)
|
||||
return false;
|
||||
|
||||
gzprintf(f, ".text\n");
|
||||
|
||||
Buffer buf;
|
||||
buf.Printf(".text\n");
|
||||
for (auto it = modules.begin(), end = modules.end(); it != end; ++it) {
|
||||
const ModuleEntry &mod = *it;
|
||||
gzprintf(f, ".module %x %08x %08x %s\n", mod.index, mod.start, mod.size, mod.name);
|
||||
buf.Printf(".module %x %08x %08x %s\n", mod.index, mod.start, mod.size, mod.name);
|
||||
}
|
||||
|
||||
for (auto it = functions.begin(), end = functions.end(); it != end; ++it) {
|
||||
const FunctionEntry& e = it->second;
|
||||
gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_FUNCTION, GetLabelNameRel(e.start, e.module));
|
||||
buf.Printf("%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_FUNCTION, GetLabelNameRel(e.start, e.module));
|
||||
}
|
||||
|
||||
for (auto it = data.begin(), end = data.end(); it != end; ++it) {
|
||||
const DataEntry& e = it->second;
|
||||
gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_DATA, GetLabelNameRel(e.start, e.module));
|
||||
buf.Printf("%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_DATA, GetLabelNameRel(e.start, e.module));
|
||||
}
|
||||
|
||||
std::string data;
|
||||
buf.TakeAll(&data);
|
||||
if (g_Config.bCompressSymbols) {
|
||||
// TODO: Wrap this in some nicer way.
|
||||
gzFile f;
|
||||
if (filename.Type() == PathType::CONTENT_URI) {
|
||||
int fd = File::OpenFD(filename, File::OPEN_WRITE);
|
||||
f = gzdopen(fd, "w9");
|
||||
if (f == Z_NULL) {
|
||||
File::CloseFD(fd);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
f = gzopen(filename.c_str(), "w9");
|
||||
if (f == Z_NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
gzwrite(f, data.data(), (unsigned int)data.size());
|
||||
gzclose(f);
|
||||
} else {
|
||||
// Just plain write it.
|
||||
FILE *file = File::OpenCFile(filename, "wb");
|
||||
fwrite(data.data(), 1, data.size(), file);
|
||||
fclose(file);
|
||||
}
|
||||
gzclose(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -291,20 +310,19 @@ bool SymbolMap::LoadNocashSym(const Path &filename) {
|
||||
}
|
||||
} else { // labels
|
||||
unsigned int size = 1;
|
||||
char* seperator = strchr(value, ',');
|
||||
if (seperator != NULL) {
|
||||
*seperator = 0;
|
||||
sscanf(seperator+1,"%08X",&size);
|
||||
char *separator = strchr(value, ',');
|
||||
if (separator != NULL) {
|
||||
*separator = '\0';
|
||||
sscanf(separator + 1, "%08X", &size);
|
||||
}
|
||||
|
||||
if (size != 1) {
|
||||
AddFunction(value, address,size, 0);
|
||||
AddFunction(value, address, size, 0);
|
||||
} else {
|
||||
AddLabel(value, address, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
@@ -422,7 +440,7 @@ std::string SymbolMap::GetDescription(unsigned int address) {
|
||||
return descriptionTemp;
|
||||
}
|
||||
|
||||
std::vector<SymbolEntry> SymbolMap::GetAllSymbols(SymbolType symmask) {
|
||||
std::vector<SymbolEntry> SymbolMap::GetAllActiveSymbols(SymbolType symmask) {
|
||||
if (activeNeedUpdate_)
|
||||
UpdateActiveSymbols();
|
||||
|
||||
@@ -721,8 +739,8 @@ void SymbolMap::AssignFunctionIndices() {
|
||||
}
|
||||
}
|
||||
|
||||
// Copies functions, labels and data to the active set depending on which modules are "active".
|
||||
void SymbolMap::UpdateActiveSymbols() {
|
||||
// return; (slow in debug mode)
|
||||
std::lock_guard<std::recursive_mutex> guard(lock_);
|
||||
|
||||
activeFunctions.clear();
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
bool GetSymbolInfo(SymbolInfo *info, u32 address, SymbolType symmask = ST_FUNCTION);
|
||||
u32 GetNextSymbolAddress(u32 address, SymbolType symmask);
|
||||
std::string GetDescription(unsigned int address);
|
||||
std::vector<SymbolEntry> GetAllSymbols(SymbolType symmask);
|
||||
std::vector<SymbolEntry> GetAllActiveSymbols(SymbolType symmask);
|
||||
|
||||
#ifdef _WIN32
|
||||
void FillSymbolListBox(HWND listbox, SymbolType symType);
|
||||
|
||||
@@ -209,7 +209,7 @@ void WebSocketHLEFuncList(DebuggerRequest &req) {
|
||||
if (!g_symbolMap)
|
||||
return req.Fail("CPU not active");
|
||||
|
||||
auto functions = g_symbolMap->GetAllSymbols(ST_FUNCTION);
|
||||
auto functions = g_symbolMap->GetAllActiveSymbols(ST_FUNCTION);
|
||||
|
||||
JsonWriter &json = req.Respond();
|
||||
json.pushArray("functions");
|
||||
|
||||
@@ -1723,6 +1723,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
|
||||
});
|
||||
}
|
||||
ImGui::Separator();
|
||||
ImGui::MenuItem("Compress .ppmap files", nullptr, &g_Config.bCompressSymbols);
|
||||
if (ImGui::MenuItem("Reset symbol map")) {
|
||||
g_symbolMap->Clear();
|
||||
disasm_.DirtySymbolMap();
|
||||
@@ -2221,7 +2222,7 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro
|
||||
|
||||
if (ImGui::BeginChild("left", ImVec2(150.0f, avail.y), ImGuiChildFlags_ResizeX)) {
|
||||
if (symCache_.empty() || symsDirty_) {
|
||||
symCache_ = g_symbolMap->GetAllSymbols(SymbolType::ST_FUNCTION);
|
||||
symCache_ = g_symbolMap->GetAllActiveSymbols(SymbolType::ST_FUNCTION);
|
||||
symsDirty_ = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user