summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorCarlKenner <carl.kenner@gmail.com>2014-12-15 18:42:07 +1030
committerCarlKenner <carl.kenner@gmail.com>2014-12-17 01:11:58 +1030
commitdfd915eb535276088f9d9f8681b196b37bd11229 (patch)
treed2edb1f28bf9fae56550980a36dd967a55b726f4 /Source/Core
parentf95f43fdde1a0c8f5181c1359314253e973b43ea (diff)
Merge bad map file loading into the original function.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/PowerPC/PPCSymbolDB.cpp105
-rw-r--r--Source/Core/Core/PowerPC/PPCSymbolDB.h3
-rw-r--r--Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp2
3 files changed, 20 insertions, 90 deletions
diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp
index 1d6f5076ce..d9eb1adb9c 100644
--- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp
+++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp
@@ -197,13 +197,15 @@ void PPCSymbolDB::LogFunctionCall(u32 addr)
// This one can load both leftover map files on game discs (like Zelda), and mapfiles
// produced by SaveSymbolMap below.
-bool PPCSymbolDB::LoadMap(const std::string& filename)
+// bad=true means carefully load map files that might not be from exactly the right version
+bool PPCSymbolDB::LoadMap(const std::string& filename, bool bad)
{
File::IOFile f(filename, "r");
if (!f)
return false;
bool started = false;
+ int good_count = 0, bad_count = 0;
char line[512];
while (fgets(line, 512, f.GetHandle()))
@@ -261,97 +263,25 @@ bool PPCSymbolDB::LoadMap(const std::string& filename)
// Check if this is a valid entry.
if (strcmp(name, ".text") != 0 && strcmp(name, ".init") != 0 && strlen(name) > 0)
{
- AddKnownSymbol(vaddress | 0x80000000, size, name); // ST_FUNCTION
- }
- }
-
- Index();
- return true;
-}
-
-// Carefully load map files that might not be from exactly the right version
-bool PPCSymbolDB::LoadBadMap(const std::string& filename)
-{
- File::IOFile f(filename, "r");
- if (!f)
- return false;
-
- bool started = false;
- int good_count = 0, bad_count = 0;
-
- char line[512];
- while (fgets(line, 512, f.GetHandle()))
- {
- if (strlen(line) < 4)
- continue;
-
- char temp[256];
- sscanf(line, "%255s", temp);
-
- if (strcmp(temp, "UNUSED") == 0) continue;
- if (strcmp(temp, ".text") == 0) { started = true; continue; };
- if (strcmp(temp, ".init") == 0) { started = true; continue; };
- if (strcmp(temp, "Starting") == 0) continue;
- if (strcmp(temp, "extab") == 0) continue;
- if (strcmp(temp, ".ctors") == 0) break; //uh?
- if (strcmp(temp, ".dtors") == 0) break;
- if (strcmp(temp, ".rodata") == 0) continue;
- if (strcmp(temp, ".data") == 0) continue;
- if (strcmp(temp, ".sbss") == 0) continue;
- if (strcmp(temp, ".sdata") == 0) continue;
- if (strcmp(temp, ".sdata2") == 0) continue;
- if (strcmp(temp, "address") == 0) continue;
- if (strcmp(temp, "-----------------------") == 0) continue;
- if (strcmp(temp, ".sbss2") == 0) break;
- if (temp[1] == ']') continue;
-
- if (!started) continue;
-
- u32 address, vaddress, size, unknown;
- char name[512];
- // some entries in the table have a function name followed by " (entry of " followed by a container name, followed by ")"
- // instead of a space followed by a number followed by a space followed by a name
- if (strlen(line) > 27 && line[27] != ' ' && strstr(line, "(entry of "))
- {
- sscanf(line, "%08x %08x %08x %511s", &address, &size, &vaddress, name);
- }
- else
- {
- sscanf(line, "%08x %08x %08x %i %511s", &address, &size, &vaddress, &unknown, name);
- }
-
- const char *namepos = strstr(line, name);
- if (namepos != nullptr) //would be odd if not :P
- strcpy(name, namepos);
- name[strlen(name) - 1] = 0;
-
- // we want the function names only .... TODO: or do we really? aren't we wasting information here?
- for (size_t i = 0; i < strlen(name); i++)
- {
- if (name[i] == ' ') name[i] = 0x00;
- if (name[i] == '(') name[i] = 0x00;
- }
-
- // Check if this is a valid entry.
- if (strcmp(name, ".text") != 0 && strcmp(name, ".init") != 0 && strlen(name) > 0)
- {
vaddress |= 0x80000000;
- // check for BLR before function
- u32 opcode = Memory::Read_Instruction(vaddress - 4);
- if (opcode == 0x4e800020)
+ bool good = !bad;
+ if (!good)
{
- // check for BLR at end of function
- opcode = Memory::Read_Instruction(vaddress + size - 4);
+ // check for BLR before function
+ u32 opcode = Memory::Read_Instruction(vaddress - 4);
if (opcode == 0x4e800020)
{
- AddKnownSymbol(vaddress, size, name); // ST_FUNCTION
- ++good_count;
- }
- else
- {
- ++bad_count;
+ // check for BLR at end of function
+ opcode = Memory::Read_Instruction(vaddress + size - 4);
+ if (opcode == 0x4e800020)
+ good = true;
}
}
+ if (good)
+ {
+ ++good_count;
+ AddKnownSymbol(vaddress | 0x80000000, size, name); // ST_FUNCTION
+ }
else
{
++bad_count;
@@ -360,7 +290,8 @@ bool PPCSymbolDB::LoadBadMap(const std::string& filename)
}
Index();
- PanicAlertT("Loaded %d good functions, ignored %d bad functions", good_count, bad_count);
+ if (bad)
+ PanicAlertT("Loaded %d good functions, ignored %d bad functions", good_count, bad_count);
return true;
}
diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.h b/Source/Core/Core/PowerPC/PPCSymbolDB.h
index a301721242..fb24188efb 100644
--- a/Source/Core/Core/PowerPC/PPCSymbolDB.h
+++ b/Source/Core/Core/PowerPC/PPCSymbolDB.h
@@ -34,8 +34,7 @@ public:
void FillInCallers();
- bool LoadMap(const std::string& filename);
- bool LoadBadMap(const std::string& filename);
+ bool LoadMap(const std::string& filename, bool bad = false);
bool SaveMap(const std::string& filename, bool WithCodes = false) const;
void PrintCalls(u32 funcAddr) const;
diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp
index 2adbb32b66..e5f91692ee 100644
--- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp
+++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp
@@ -314,7 +314,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
if (!path.IsEmpty())
{
- g_symbolDB.LoadBadMap(WxStrToStr(path));
+ g_symbolDB.LoadMap(WxStrToStr(path), true);
Parent->StatusBarMessage("Loaded symbols from '%s'", WxStrToStr(path).c_str());
}
HLE::PatchFunctions();