From f54d9e33c256560e0c06041cc2c480d6ada32c6e Mon Sep 17 00:00:00 2001 From: CarlKenner Date: Mon, 15 Dec 2014 08:47:36 +1030 Subject: Fix many bugs with the Symbols menu (when run with -d argument). The Symbols menu is now fully useable. --- .../DolphinWX/Debugger/CodeWindowFunctions.cpp | 125 +++++++++++++++++++-- 1 file changed, 114 insertions(+), 11 deletions(-) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp') diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index 099d184bee..cba74774da 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -146,11 +146,19 @@ void CCodeWindow::Save() void CCodeWindow::CreateMenuSymbols(wxMenuBar *pMenuBar) { wxMenu *pSymbolsMenu = new wxMenu; - pSymbolsMenu->Append(IDM_CLEARSYMBOLS, _("&Clear symbols")); - pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _("&Generate symbol map")); + pSymbolsMenu->Append(IDM_CLEARSYMBOLS, _("&Clear symbols"), + _("Remove names from all functions and variables.")); + pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _("&Generate symbol map"), + _("Recognise standard functions from sys\\totaldb.dsy, and use generic zz_ names for other functions.")); pSymbolsMenu->AppendSeparator(); - pSymbolsMenu->Append(IDM_LOADMAPFILE, _("&Load symbol map")); - pSymbolsMenu->Append(IDM_SAVEMAPFILE, _("&Save symbol map")); + pSymbolsMenu->Append(IDM_LOADMAPFILE, _("&Load symbol map"), + _("Try to load this game's function names automatically - but doesn't check .map files stored on the disc image yet.")); + pSymbolsMenu->Append(IDM_SAVEMAPFILE, _("&Save symbol map"), + _("Save the function names for each address to a .map file in your user settings map folder, named after the title id.")); + pSymbolsMenu->Append(IDM_LOADMAPFILEAS, _("Choose symbol map file to load..."), + _("Load any .map file containing the function names and addresses for this game.")); + pSymbolsMenu->Append(IDM_SAVEMAPFILEAS, _("Save symbol map &as..."), + _("Save the function names and addresses for this game as a .map file. If you want to open it in IDA pro, use the .idc script.")); pSymbolsMenu->AppendSeparator(); pSymbolsMenu->Append(IDM_SAVEMAPFILEWITHCODES, _("Save code"), _("Save the entire disassembled code. This may take a several seconds" @@ -161,8 +169,14 @@ void CCodeWindow::CreateMenuSymbols(wxMenuBar *pMenuBar) ); pSymbolsMenu->AppendSeparator(); - pSymbolsMenu->Append(IDM_CREATESIGNATUREFILE, _("&Create signature file...")); - pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _("&Use signature file...")); + pSymbolsMenu->Append(IDM_CREATESIGNATUREFILE, _("&Create signature file..."), + _("Create a .dsy file that can be used to recognise these same functions in other games.")); + pSymbolsMenu->Append(IDM_APPENDSIGNATUREFILE, _("Append to &existing signature file..."), + _("Add any named functions missing from a .dsy file, so it can also recognise these additional functions in other games.")); + pSymbolsMenu->Append(IDM_COMBINESIGNATUREFILES, _("Combine &2 signature files..."), + _("Make a new .dsy file which can recognise more functions, by combining two existing files. The first input file has priority.")); + pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _("&Use signature file..."), + _("Must use Generate symbol map first! Recognise names of any standard library functions used in multiple games, by loading them from a .dsy file.")); pSymbolsMenu->AppendSeparator(); pSymbolsMenu->Append(IDM_PATCHHLEFUNCTIONS, _("&Patch HLE functions")); pSymbolsMenu->Append(IDM_RENAME_SYMBOLS, _("&Rename symbols from file...")); @@ -222,9 +236,10 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) if (!Core::IsRunning()) return; - std::string existing_map_file, writable_map_file; + std::string existing_map_file, writable_map_file, title_id_str; bool map_exists = CBoot::FindMapFile(&existing_map_file, - &writable_map_file); + &writable_map_file, + &title_id_str); switch (event.GetId()) { case IDM_CLEARSYMBOLS: @@ -240,6 +255,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) { db.Apply(&g_symbolDB); Parent->StatusBarMessage("Generated symbol names from '%s'", TOTALDB); + db.List(); } else { @@ -268,9 +284,38 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) HLE::PatchFunctions(); NotifyMapLoaded(); break; + case IDM_LOADMAPFILEAS: + { + const wxString path = wxFileSelector( + _("Load map file"), File::GetUserPath(D_MAPS_IDX), + title_id_str + ".map", ".map", + "Dolphin Map File (*.map)|*.map|All files (*.*)|*.*", + wxFD_OPEN | wxFD_FILE_MUST_EXIST, this); + + if (!path.IsEmpty()) + { + g_symbolDB.LoadMap(WxStrToStr(path)); + Parent->StatusBarMessage("Loaded symbols from '%s'", path.c_str()); + } + HLE::PatchFunctions(); + NotifyMapLoaded(); + } + break; case IDM_SAVEMAPFILE: g_symbolDB.SaveMap(writable_map_file); break; + case IDM_SAVEMAPFILEAS: + { + const wxString path = wxFileSelector( + _("Save map file as"), File::GetUserPath(D_MAPS_IDX), + title_id_str + ".map", ".map", + "Dolphin Map File (*.map)|*.map|All files (*.*)|*.*", + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this); + + if (!path.IsEmpty()) + g_symbolDB.SaveMap(WxStrToStr(path)); + } + break; case IDM_SAVEMAPFILEWITHCODES: g_symbolDB.SaveMap(writable_map_file, true); break; @@ -323,14 +368,43 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) std::string prefix(WxStrToStr(input_prefix.GetValue())); wxString path = wxFileSelector( - _("Save signature as"), wxEmptyString, wxEmptyString, wxEmptyString, + _("Save signature as"), File::GetSysDirectory(), wxEmptyString, wxEmptyString, + "Dolphin Signature File (*.dsy)|*.dsy;", wxFD_SAVE | wxFD_OVERWRITE_PROMPT, + this); + if (!path.IsEmpty()) + { + SignatureDB db; + db.Initialize(&g_symbolDB, prefix); + db.Save(WxStrToStr(path)); + db.List(); + } + } + } + break; + case IDM_APPENDSIGNATUREFILE: + { + wxTextEntryDialog input_prefix( + this, + _("Only export symbols with prefix:\n(Blank for all symbols)"), + wxGetTextFromUserPromptStr, + wxEmptyString); + + if (input_prefix.ShowModal() == wxID_OK) + { + std::string prefix(WxStrToStr(input_prefix.GetValue())); + + wxString path = wxFileSelector( + _("Append signature to"), File::GetSysDirectory(), wxEmptyString, wxEmptyString, "Dolphin Signature File (*.dsy)|*.dsy;", wxFD_SAVE, this); if (!path.IsEmpty()) { SignatureDB db; db.Initialize(&g_symbolDB, prefix); + db.List(); + db.Load(WxStrToStr(path)); db.Save(WxStrToStr(path)); + db.List(); } } } @@ -338,7 +412,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) case IDM_USESIGNATUREFILE: { wxString path = wxFileSelector( - _("Apply signature file"), wxEmptyString, wxEmptyString, wxEmptyString, + _("Apply signature file"), File::GetSysDirectory(), wxEmptyString, wxEmptyString, "Dolphin Signature File (*.dsy)|*.dsy;", wxFD_OPEN | wxFD_FILE_MUST_EXIST, this); if (!path.IsEmpty()) @@ -346,9 +420,38 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) SignatureDB db; db.Load(WxStrToStr(path)); db.Apply(&g_symbolDB); + db.List(); + NotifyMapLoaded(); + } + } + break; + case IDM_COMBINESIGNATUREFILES: + { + wxString path1 = wxFileSelector( + _("Choose priority input file"), File::GetSysDirectory(), wxEmptyString, wxEmptyString, + "Dolphin Signature File (*.dsy)|*.dsy;", wxFD_OPEN | wxFD_FILE_MUST_EXIST, + this); + if (!path1.IsEmpty()) + { + SignatureDB db; + wxString path2 = wxFileSelector( + _("Choose secondary input file"), File::GetSysDirectory(), wxEmptyString, wxEmptyString, + "Dolphin Signature File (*.dsy)|*.dsy;", wxFD_OPEN | wxFD_FILE_MUST_EXIST, + this); + if (!path2.IsEmpty()) + { + db.Load(WxStrToStr(path2)); + db.Load(WxStrToStr(path1)); + + path2 = wxFileSelector( + _("Save combined output file as"), File::GetSysDirectory(), wxEmptyString, ".dsy", + "Dolphin Signature File (*.dsy)|*.dsy;", wxFD_SAVE | wxFD_OVERWRITE_PROMPT, + this); + db.Save(WxStrToStr(path2)); + db.List(); + } } } - NotifyMapLoaded(); break; case IDM_PATCHHLEFUNCTIONS: HLE::PatchFunctions(); -- cgit v1.2.3 From e246aaf419c34e23e6c37013e0b7ed7dbf11ba21 Mon Sep 17 00:00:00 2001 From: CarlKenner Date: Mon, 15 Dec 2014 10:13:45 +1030 Subject: Add "Load bad map file" option for map files on disc that don't quite match. Currently it is very simple and naive, but filters out most of the bad matches. --- .../Core/DolphinWX/Debugger/CodeWindowFunctions.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp') diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index cba74774da..b19d26fb74 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -155,8 +155,11 @@ void CCodeWindow::CreateMenuSymbols(wxMenuBar *pMenuBar) _("Try to load this game's function names automatically - but doesn't check .map files stored on the disc image yet.")); pSymbolsMenu->Append(IDM_SAVEMAPFILE, _("&Save symbol map"), _("Save the function names for each address to a .map file in your user settings map folder, named after the title id.")); + pSymbolsMenu->AppendSeparator(); pSymbolsMenu->Append(IDM_LOADMAPFILEAS, _("Choose symbol map file to load..."), _("Load any .map file containing the function names and addresses for this game.")); + pSymbolsMenu->Append(IDM_LOADBADMAPFILE, _("Load &bad map file..."), + _("Try to load a .map file that might be from a slightly different version.")); pSymbolsMenu->Append(IDM_SAVEMAPFILEAS, _("Save symbol map &as..."), _("Save the function names and addresses for this game as a .map file. If you want to open it in IDA pro, use the .idc script.")); pSymbolsMenu->AppendSeparator(); @@ -301,6 +304,23 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) NotifyMapLoaded(); } break; + case IDM_LOADBADMAPFILE: + { + const wxString path = wxFileSelector( + _("Load bad map file"), File::GetUserPath(D_MAPS_IDX), + title_id_str + ".map", ".map", + "Dolphin Map File (*.map)|*.map|All files (*.*)|*.*", + wxFD_OPEN | wxFD_FILE_MUST_EXIST, this); + + if (!path.IsEmpty()) + { + g_symbolDB.LoadBadMap(WxStrToStr(path)); + Parent->StatusBarMessage("Loaded symbols from '%s'", path.c_str()); + } + HLE::PatchFunctions(); + NotifyMapLoaded(); + } + break; case IDM_SAVEMAPFILE: g_symbolDB.SaveMap(writable_map_file); break; -- cgit v1.2.3 From f95f43fdde1a0c8f5181c1359314253e973b43ea Mon Sep 17 00:00:00 2001 From: CarlKenner Date: Mon, 15 Dec 2014 11:34:18 +1030 Subject: Apparently c_str doesn't return a C str. --- Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp') diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index b19d26fb74..2adbb32b66 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -298,7 +298,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) if (!path.IsEmpty()) { g_symbolDB.LoadMap(WxStrToStr(path)); - Parent->StatusBarMessage("Loaded symbols from '%s'", path.c_str()); + Parent->StatusBarMessage("Loaded symbols from '%s'", WxStrToStr(path).c_str()); } HLE::PatchFunctions(); NotifyMapLoaded(); @@ -315,7 +315,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) if (!path.IsEmpty()) { g_symbolDB.LoadBadMap(WxStrToStr(path)); - Parent->StatusBarMessage("Loaded symbols from '%s'", path.c_str()); + Parent->StatusBarMessage("Loaded symbols from '%s'", WxStrToStr(path).c_str()); } HLE::PatchFunctions(); NotifyMapLoaded(); -- cgit v1.2.3 From dfd915eb535276088f9d9f8681b196b37bd11229 Mon Sep 17 00:00:00 2001 From: CarlKenner Date: Mon, 15 Dec 2014 18:42:07 +1030 Subject: Merge bad map file loading into the original function. --- Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp') 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(); -- cgit v1.2.3 From 6e7eb52211844727bdf9f665630273ea109a1589 Mon Sep 17 00:00:00 2001 From: CarlKenner Date: Wed, 17 Dec 2014 00:11:05 +1030 Subject: Rename menu items, stop using PanicAlertT, remove -d when running from visual studio. I accidentally committed my addition of the -d option that I used for testing, now it's fixed. --- Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp') diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index e5f91692ee..1bf48b523e 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -156,7 +156,7 @@ void CCodeWindow::CreateMenuSymbols(wxMenuBar *pMenuBar) pSymbolsMenu->Append(IDM_SAVEMAPFILE, _("&Save symbol map"), _("Save the function names for each address to a .map file in your user settings map folder, named after the title id.")); pSymbolsMenu->AppendSeparator(); - pSymbolsMenu->Append(IDM_LOADMAPFILEAS, _("Choose symbol map file to load..."), + pSymbolsMenu->Append(IDM_LOADMAPFILEAS, _("Load &other map file..."), _("Load any .map file containing the function names and addresses for this game.")); pSymbolsMenu->Append(IDM_LOADBADMAPFILE, _("Load &bad map file..."), _("Try to load a .map file that might be from a slightly different version.")); @@ -176,9 +176,9 @@ void CCodeWindow::CreateMenuSymbols(wxMenuBar *pMenuBar) _("Create a .dsy file that can be used to recognise these same functions in other games.")); pSymbolsMenu->Append(IDM_APPENDSIGNATUREFILE, _("Append to &existing signature file..."), _("Add any named functions missing from a .dsy file, so it can also recognise these additional functions in other games.")); - pSymbolsMenu->Append(IDM_COMBINESIGNATUREFILES, _("Combine &2 signature files..."), + pSymbolsMenu->Append(IDM_COMBINESIGNATUREFILES, _("Combine two signature files..."), _("Make a new .dsy file which can recognise more functions, by combining two existing files. The first input file has priority.")); - pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _("&Use signature file..."), + pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _("Apply signat&ure file..."), _("Must use Generate symbol map first! Recognise names of any standard library functions used in multiple games, by loading them from a .dsy file.")); pSymbolsMenu->AppendSeparator(); pSymbolsMenu->Append(IDM_PATCHHLEFUNCTIONS, _("&Patch HLE functions")); -- cgit v1.2.3