2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cstddef>
|
2017-03-28 00:58:22 +00:00
|
|
|
#include <cstdlib>
|
2017-04-02 05:45:11 +00:00
|
|
|
#include <fstream>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <istream>
|
2017-03-28 00:58:22 +00:00
|
|
|
#include <limits>
|
2017-04-02 05:45:11 +00:00
|
|
|
#include <sstream>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
#include <wx/filedlg.h>
|
|
|
|
#include <wx/font.h>
|
|
|
|
#include <wx/fontdata.h>
|
2009-02-23 06:15:48 +00:00
|
|
|
#include <wx/fontdlg.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/listbox.h>
|
|
|
|
#include <wx/menu.h>
|
2011-02-28 20:40:15 +00:00
|
|
|
#include <wx/mimetype.h>
|
2016-12-04 13:47:08 +00:00
|
|
|
#include <wx/srchctrl.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/textdlg.h>
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/CommonPaths.h"
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/IniFile.h"
|
2017-03-02 17:15:02 +00:00
|
|
|
#include "Common/MsgHandler.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/SymbolDB.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/Boot/Boot.h"
|
2017-02-21 20:05:17 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Core/Core.h"
|
2017-03-28 00:58:22 +00:00
|
|
|
#include "Core/Debugger/RSO.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Core/HLE/HLE.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Core/Host.h"
|
2017-02-21 20:05:17 +00:00
|
|
|
#include "Core/PowerPC/JitInterface.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/PowerPC/PPCAnalyst.h"
|
|
|
|
#include "Core/PowerPC/PPCSymbolDB.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/PowerPC/Profiler.h"
|
2017-03-15 03:59:01 +00:00
|
|
|
#include "Core/PowerPC/SignatureDB/MEGASignatureDB.h"
|
2016-12-06 15:43:41 +00:00
|
|
|
#include "Core/PowerPC/SignatureDB/SignatureDB.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/Debugger/BreakpointWindow.h"
|
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/Debugger/DSPDebugWindow.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/Debugger/DebuggerPanel.h"
|
|
|
|
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
|
|
|
#include "DolphinWX/Debugger/JitWindow.h"
|
|
|
|
#include "DolphinWX/Debugger/MemoryWindow.h"
|
|
|
|
#include "DolphinWX/Debugger/RegisterWindow.h"
|
2014-10-19 10:45:40 +00:00
|
|
|
#include "DolphinWX/Debugger/WatchWindow.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/Frame.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2009-09-03 06:54:46 +00:00
|
|
|
// Save and load settings
|
2009-09-08 16:07:13 +00:00
|
|
|
// -----------------------------
|
2009-09-03 06:54:46 +00:00
|
|
|
void CCodeWindow::Load()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile ini;
|
|
|
|
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
|
|
|
|
|
|
|
// The font to override DebuggerFont with
|
|
|
|
std::string fontDesc;
|
|
|
|
|
2016-10-10 22:21:15 +00:00
|
|
|
auto& config_instance = SConfig::GetInstance();
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile::Section* general = ini.GetOrCreateSection("General");
|
|
|
|
general->Get("DebuggerFont", &fontDesc);
|
2016-10-10 22:21:15 +00:00
|
|
|
general->Get("AutomaticStart", &config_instance.bAutomaticStart, false);
|
|
|
|
general->Get("BootToPause", &config_instance.bBootToPause, true);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
if (!fontDesc.empty())
|
|
|
|
DebuggerFont.SetNativeFontInfoUserDesc(StrToWxStr(fontDesc));
|
|
|
|
|
|
|
|
const char* SettingName[] = {"Log", "LogConfig", "Console", "Registers", "Breakpoints",
|
|
|
|
"Memory", "JIT", "Sound", "Video", "Code"};
|
|
|
|
|
|
|
|
// Decide what windows to show
|
|
|
|
for (int i = 0; i <= IDM_VIDEO_WINDOW - IDM_LOG_WINDOW; i++)
|
|
|
|
ini.GetOrCreateSection("ShowOnStart")->Get(SettingName[i], &bShowOnStart[i], false);
|
|
|
|
|
|
|
|
// Get notebook affiliation
|
|
|
|
std::string section = "P - " + ((Parent->ActivePerspective < Parent->Perspectives.size()) ?
|
|
|
|
Parent->Perspectives[Parent->ActivePerspective].Name :
|
|
|
|
"Perspective 1");
|
|
|
|
|
|
|
|
for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++)
|
|
|
|
ini.GetOrCreateSection(section)->Get(SettingName[i], &iNbAffiliation[i], 0);
|
|
|
|
|
|
|
|
// Get floating setting
|
|
|
|
for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++)
|
|
|
|
ini.GetOrCreateSection("Float")->Get(SettingName[i], &Parent->bFloatWindow[i], false);
|
2009-09-03 06:54:46 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-03 06:54:46 +00:00
|
|
|
void CCodeWindow::Save()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile ini;
|
|
|
|
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
|
|
|
|
|
|
|
IniFile::Section* general = ini.GetOrCreateSection("General");
|
|
|
|
general->Set("DebuggerFont", WxStrToStr(DebuggerFont.GetNativeFontInfoUserDesc()));
|
2016-11-05 02:02:36 +00:00
|
|
|
general->Set("AutomaticStart", GetParentMenuBar()->IsChecked(IDM_AUTOMATIC_START));
|
|
|
|
general->Set("BootToPause", GetParentMenuBar()->IsChecked(IDM_BOOT_TO_PAUSE));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
const char* SettingName[] = {"Log", "LogConfig", "Console", "Registers", "Breakpoints",
|
|
|
|
"Memory", "JIT", "Sound", "Video", "Code"};
|
|
|
|
|
|
|
|
// Save windows settings
|
|
|
|
for (int i = IDM_LOG_WINDOW; i <= IDM_VIDEO_WINDOW; i++)
|
|
|
|
ini.GetOrCreateSection("ShowOnStart")
|
2016-11-05 02:02:36 +00:00
|
|
|
->Set(SettingName[i - IDM_LOG_WINDOW], GetParentMenuBar()->IsChecked(i));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
// Save notebook affiliations
|
|
|
|
std::string section = "P - " + Parent->Perspectives[Parent->ActivePerspective].Name;
|
|
|
|
for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++)
|
|
|
|
ini.GetOrCreateSection(section)->Set(SettingName[i], iNbAffiliation[i]);
|
|
|
|
|
|
|
|
// Save floating setting
|
|
|
|
for (int i = IDM_LOG_WINDOW_PARENT; i <= IDM_CODE_WINDOW_PARENT; i++)
|
|
|
|
ini.GetOrCreateSection("Float")->Set(SettingName[i - IDM_LOG_WINDOW_PARENT],
|
|
|
|
!!FindWindowById(i));
|
|
|
|
|
|
|
|
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2009-09-03 06:54:46 +00:00
|
|
|
}
|
2009-09-02 21:00:45 +00:00
|
|
|
|
2009-02-23 06:15:48 +00:00
|
|
|
void CCodeWindow::OnProfilerMenu(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_PROFILE_BLOCKS:
|
2017-02-05 12:39:58 +00:00
|
|
|
Core::SetState(Core::State::Paused);
|
2017-02-21 20:05:17 +00:00
|
|
|
JitInterface::ClearCache();
|
2016-11-05 02:02:36 +00:00
|
|
|
Profiler::g_ProfileBlocks = GetParentMenuBar()->IsChecked(IDM_PROFILE_BLOCKS);
|
2017-02-05 12:39:58 +00:00
|
|
|
Core::SetState(Core::State::Running);
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
|
|
|
case IDM_WRITE_PROFILE:
|
2017-02-05 12:39:58 +00:00
|
|
|
if (Core::GetState() == Core::State::Running)
|
|
|
|
Core::SetState(Core::State::Paused);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-02-05 12:39:58 +00:00
|
|
|
if (Core::GetState() == Core::State::Paused && PowerPC::GetMode() == PowerPC::CoreMode::JIT)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-02-21 20:05:17 +00:00
|
|
|
std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt";
|
|
|
|
File::CreateFullPath(filename);
|
|
|
|
Profiler::WriteProfileResults(filename);
|
|
|
|
|
|
|
|
wxFileType* filetype = nullptr;
|
|
|
|
if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromExtension("txt")))
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-02-21 20:05:17 +00:00
|
|
|
// From extension failed, trying with MIME type now
|
|
|
|
if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromMimeType("text/plain")))
|
|
|
|
// MIME type failed, aborting mission
|
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2017-02-21 20:05:17 +00:00
|
|
|
wxString OpenCommand = filetype->GetOpenCommand(StrToWxStr(filename));
|
|
|
|
if (!OpenCommand.IsEmpty())
|
|
|
|
wxExecute(OpenCommand, wxEXEC_SYNC);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
|
|
|
|
{
|
2016-12-06 15:43:41 +00:00
|
|
|
static const wxString signature_selector = _("Dolphin Signature File (*.dsy)") + "|*.dsy|" +
|
|
|
|
_("Dolphin Signature CSV File (*.csv)") + "|*.csv|" +
|
|
|
|
wxGetTranslation(wxALL_FILES);
|
2016-06-24 08:43:46 +00:00
|
|
|
Parent->ClearStatusBar();
|
|
|
|
|
|
|
|
if (!Core::IsRunning())
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::string existing_map_file, writable_map_file, title_id_str;
|
|
|
|
bool map_exists = CBoot::FindMapFile(&existing_map_file, &writable_map_file, &title_id_str);
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_CLEAR_SYMBOLS:
|
|
|
|
if (!AskYesNoT("Do you want to clear the list of symbol names?"))
|
|
|
|
return;
|
|
|
|
g_symbolDB.Clear();
|
|
|
|
Host_NotifyMapLoaded();
|
|
|
|
break;
|
|
|
|
case IDM_SCAN_FUNCTIONS:
|
2017-03-25 00:52:17 +00:00
|
|
|
PPCAnalyst::FindFunctions(0x80000000, 0x81800000, &g_symbolDB);
|
|
|
|
// Update GUI
|
|
|
|
NotifyMapLoaded();
|
|
|
|
break;
|
|
|
|
case IDM_SCAN_SIGNATURES:
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
PPCAnalyst::FindFunctions(0x80000000, 0x81800000, &g_symbolDB);
|
|
|
|
SignatureDB db;
|
|
|
|
if (db.Load(File::GetSysDirectory() + TOTALDB))
|
|
|
|
{
|
|
|
|
db.Apply(&g_symbolDB);
|
|
|
|
Parent->StatusBarMessage("Generated symbol names from '%s'", TOTALDB);
|
|
|
|
db.List();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Parent->StatusBarMessage("'%s' not found, no symbol names generated", TOTALDB);
|
|
|
|
}
|
|
|
|
// Update GUI
|
|
|
|
NotifyMapLoaded();
|
|
|
|
break;
|
|
|
|
}
|
2017-03-28 00:58:22 +00:00
|
|
|
case IDM_SCAN_RSO:
|
|
|
|
{
|
|
|
|
wxTextEntryDialog dialog(this, _("Enter the RSO module address:"));
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
{
|
|
|
|
unsigned long address;
|
|
|
|
if (dialog.GetValue().ToULong(&address, 0) && address <= std::numeric_limits<u32>::max())
|
|
|
|
{
|
|
|
|
RSOChainView rso_chain;
|
|
|
|
if (rso_chain.Load(static_cast<u32>(address)))
|
|
|
|
{
|
|
|
|
rso_chain.Apply(&g_symbolDB);
|
|
|
|
// Update GUI
|
|
|
|
NotifyMapLoaded();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Parent->StatusBarMessage("Failed to load RSO module at %s",
|
|
|
|
dialog.GetValue().ToStdString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Parent->StatusBarMessage("Invalid RSO module address: %s",
|
|
|
|
dialog.GetValue().ToStdString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
case IDM_LOAD_MAP_FILE:
|
|
|
|
if (!map_exists)
|
|
|
|
{
|
|
|
|
g_symbolDB.Clear();
|
|
|
|
PPCAnalyst::FindFunctions(0x81300000, 0x81800000, &g_symbolDB);
|
|
|
|
SignatureDB db;
|
|
|
|
if (db.Load(File::GetSysDirectory() + TOTALDB))
|
|
|
|
db.Apply(&g_symbolDB);
|
|
|
|
Parent->StatusBarMessage("'%s' not found, scanning for common functions instead",
|
|
|
|
writable_map_file.c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_symbolDB.LoadMap(existing_map_file);
|
|
|
|
Parent->StatusBarMessage("Loaded symbols from '%s'", existing_map_file.c_str());
|
|
|
|
}
|
|
|
|
HLE::PatchFunctions();
|
|
|
|
NotifyMapLoaded();
|
|
|
|
break;
|
|
|
|
case IDM_LOAD_MAP_FILE_AS:
|
|
|
|
{
|
|
|
|
const wxString path = wxFileSelector(
|
|
|
|
_("Load map file"), File::GetUserPath(D_MAPS_IDX), title_id_str + ".map", ".map",
|
|
|
|
_("Dolphin Map File (*.map)") + "|*.map|" + wxGetTranslation(wxALL_FILES),
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
|
|
|
|
|
|
|
if (!path.IsEmpty())
|
|
|
|
{
|
|
|
|
g_symbolDB.LoadMap(WxStrToStr(path));
|
|
|
|
Parent->StatusBarMessage("Loaded symbols from '%s'", WxStrToStr(path).c_str());
|
|
|
|
}
|
|
|
|
HLE::PatchFunctions();
|
|
|
|
NotifyMapLoaded();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_LOAD_BAD_MAP_FILE:
|
|
|
|
{
|
|
|
|
const wxString path = wxFileSelector(
|
|
|
|
_("Load bad map file"), File::GetUserPath(D_MAPS_IDX), title_id_str + ".map", ".map",
|
|
|
|
_("Dolphin Map File (*.map)") + "|*.map|" + wxGetTranslation(wxALL_FILES),
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
|
|
|
|
|
|
|
if (!path.IsEmpty())
|
|
|
|
{
|
|
|
|
g_symbolDB.LoadMap(WxStrToStr(path), true);
|
|
|
|
Parent->StatusBarMessage("Loaded symbols from '%s'", WxStrToStr(path).c_str());
|
|
|
|
}
|
|
|
|
HLE::PatchFunctions();
|
|
|
|
NotifyMapLoaded();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_SAVEMAPFILE:
|
|
|
|
g_symbolDB.SaveMap(writable_map_file);
|
|
|
|
break;
|
|
|
|
case IDM_SAVE_MAP_FILE_AS:
|
|
|
|
{
|
|
|
|
const wxString path = wxFileSelector(
|
|
|
|
_("Save map file as"), File::GetUserPath(D_MAPS_IDX), title_id_str + ".map", ".map",
|
|
|
|
_("Dolphin Map File (*.map)") + "|*.map|" + wxGetTranslation(wxALL_FILES),
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
|
|
|
|
|
|
|
|
if (!path.IsEmpty())
|
|
|
|
g_symbolDB.SaveMap(WxStrToStr(path));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_SAVE_MAP_FILE_WITH_CODES:
|
|
|
|
g_symbolDB.SaveMap(writable_map_file, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_RENAME_SYMBOLS:
|
|
|
|
{
|
|
|
|
const wxString path = wxFileSelector(
|
|
|
|
_("Apply signature file"), wxEmptyString, wxEmptyString, wxEmptyString,
|
|
|
|
_("Dolphin Symbol Rename File (*.sym)") + "|*.sym|" + wxGetTranslation(wxALL_FILES),
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
|
|
|
|
|
|
|
if (!path.IsEmpty())
|
|
|
|
{
|
|
|
|
std::ifstream f;
|
|
|
|
OpenFStream(f, WxStrToStr(path), std::ios_base::in);
|
|
|
|
|
|
|
|
std::string line;
|
|
|
|
while (std::getline(f, line))
|
|
|
|
{
|
|
|
|
if (line.length() < 12)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
u32 address, type;
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
std::istringstream ss(line);
|
|
|
|
ss >> std::hex >> address >> std::dec >> type >> name;
|
|
|
|
|
|
|
|
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
|
|
|
if (symbol)
|
|
|
|
symbol->name = line.substr(12);
|
|
|
|
}
|
|
|
|
|
|
|
|
Host_NotifyMapLoaded();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_CREATE_SIGNATURE_FILE:
|
|
|
|
{
|
|
|
|
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(_("Save signature as"), File::GetSysDirectory(), wxEmptyString,
|
2016-12-06 15:43:41 +00:00
|
|
|
wxEmptyString, signature_selector,
|
2016-06-24 08:43:46 +00:00
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
|
|
|
|
if (!path.IsEmpty())
|
|
|
|
{
|
2017-03-24 00:31:52 +00:00
|
|
|
std::string save_path = WxStrToStr(path);
|
|
|
|
SignatureDB db(save_path);
|
2017-03-16 23:13:18 +00:00
|
|
|
db.Populate(&g_symbolDB, prefix);
|
2017-03-24 00:31:52 +00:00
|
|
|
db.Save(save_path);
|
2016-06-24 08:43:46 +00:00
|
|
|
db.List();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_APPEND_SIGNATURE_FILE:
|
|
|
|
{
|
|
|
|
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()));
|
|
|
|
|
2016-12-06 15:43:41 +00:00
|
|
|
wxString path =
|
|
|
|
wxFileSelector(_("Append signature to"), File::GetSysDirectory(), wxEmptyString,
|
|
|
|
wxEmptyString, signature_selector, wxFD_SAVE, this);
|
2016-06-24 08:43:46 +00:00
|
|
|
if (!path.IsEmpty())
|
|
|
|
{
|
2017-03-24 00:31:52 +00:00
|
|
|
std::string signature_path = WxStrToStr(path);
|
|
|
|
SignatureDB db(signature_path);
|
2017-03-16 23:13:18 +00:00
|
|
|
db.Populate(&g_symbolDB, prefix);
|
2016-06-24 08:43:46 +00:00
|
|
|
db.List();
|
2017-03-24 00:31:52 +00:00
|
|
|
db.Load(signature_path);
|
|
|
|
db.Save(signature_path);
|
2016-06-24 08:43:46 +00:00
|
|
|
db.List();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_USE_SIGNATURE_FILE:
|
|
|
|
{
|
2016-12-06 15:43:41 +00:00
|
|
|
wxString path =
|
|
|
|
wxFileSelector(_("Apply signature file"), File::GetSysDirectory(), wxEmptyString,
|
|
|
|
wxEmptyString, signature_selector, wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
2016-06-24 08:43:46 +00:00
|
|
|
if (!path.IsEmpty())
|
|
|
|
{
|
2017-03-24 00:31:52 +00:00
|
|
|
std::string load_path = WxStrToStr(path);
|
|
|
|
SignatureDB db(load_path);
|
|
|
|
db.Load(load_path);
|
2016-06-24 08:43:46 +00:00
|
|
|
db.Apply(&g_symbolDB);
|
|
|
|
db.List();
|
|
|
|
NotifyMapLoaded();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_COMBINE_SIGNATURE_FILES:
|
|
|
|
{
|
2016-12-06 15:43:41 +00:00
|
|
|
wxString path1 =
|
|
|
|
wxFileSelector(_("Choose priority input file"), File::GetSysDirectory(), wxEmptyString,
|
|
|
|
wxEmptyString, signature_selector, wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
2016-06-24 08:43:46 +00:00
|
|
|
if (!path1.IsEmpty())
|
|
|
|
{
|
2017-03-24 00:31:52 +00:00
|
|
|
std::string load_path1 = WxStrToStr(path1);
|
|
|
|
SignatureDB db(load_path1);
|
2016-12-06 15:43:41 +00:00
|
|
|
wxString path2 =
|
|
|
|
wxFileSelector(_("Choose secondary input file"), File::GetSysDirectory(), wxEmptyString,
|
|
|
|
wxEmptyString, signature_selector, wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
2016-06-24 08:43:46 +00:00
|
|
|
if (!path2.IsEmpty())
|
|
|
|
{
|
2017-03-24 00:31:52 +00:00
|
|
|
db.Load(load_path1);
|
2016-06-24 08:43:46 +00:00
|
|
|
db.Load(WxStrToStr(path2));
|
|
|
|
|
|
|
|
path2 = wxFileSelector(_("Save combined output file as"), File::GetSysDirectory(),
|
2016-12-06 15:43:41 +00:00
|
|
|
wxEmptyString, ".dsy", signature_selector,
|
2016-06-24 08:43:46 +00:00
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
|
|
|
|
db.Save(WxStrToStr(path2));
|
|
|
|
db.List();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2017-03-15 03:59:01 +00:00
|
|
|
case IDM_USE_MEGA_SIGNATURE_FILE:
|
|
|
|
{
|
|
|
|
wxString path = wxFileSelector(
|
|
|
|
_("Apply MEGA signature file"), File::GetSysDirectory(), wxEmptyString, wxEmptyString,
|
|
|
|
_("MEGA Signature File (*.mega)") + "|*.mega|" + wxGetTranslation(wxALL_FILES),
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
|
|
|
if (!path.IsEmpty())
|
|
|
|
{
|
|
|
|
MEGASignatureDB db;
|
|
|
|
db.Load(WxStrToStr(path));
|
|
|
|
db.Apply(&g_symbolDB);
|
|
|
|
db.List();
|
|
|
|
NotifyMapLoaded();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
case IDM_PATCH_HLE_FUNCTIONS:
|
|
|
|
HLE::PatchFunctions();
|
2016-10-03 07:29:50 +00:00
|
|
|
Repopulate();
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 13:47:08 +00:00
|
|
|
void CCodeWindow::ReloadSymbolListBox()
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
symbols->Freeze(); // HyperIris: wx style fast filling
|
|
|
|
symbols->Clear();
|
2016-12-04 13:47:08 +00:00
|
|
|
const wxString filtering_string = m_symbol_filter_ctrl->GetValue().Trim().Trim(false);
|
2016-06-24 08:43:46 +00:00
|
|
|
for (const auto& symbol : g_symbolDB.Symbols())
|
|
|
|
{
|
2016-12-04 13:47:08 +00:00
|
|
|
if (symbol.second.name.find(filtering_string) == std::string::npos)
|
|
|
|
continue;
|
2016-06-24 08:43:46 +00:00
|
|
|
int idx = symbols->Append(StrToWxStr(symbol.second.name));
|
|
|
|
symbols->SetClientData(idx, (void*)&symbol.second);
|
|
|
|
}
|
|
|
|
symbols->Thaw();
|
2016-12-04 13:47:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCodeWindow::NotifyMapLoaded()
|
|
|
|
{
|
|
|
|
if (!codeview)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_symbolDB.FillInCallers();
|
|
|
|
ReloadSymbolListBox();
|
2016-10-03 07:29:50 +00:00
|
|
|
Repopulate();
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
int index = symbols->GetSelection();
|
|
|
|
if (index >= 0)
|
|
|
|
{
|
|
|
|
Symbol* pSymbol = static_cast<Symbol*>(symbols->GetClientData(index));
|
|
|
|
if (pSymbol != nullptr)
|
|
|
|
{
|
2016-09-14 01:01:35 +00:00
|
|
|
if (pSymbol->type == Symbol::Type::Data)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
CMemoryWindow* memory = GetPanel<CMemoryWindow>();
|
|
|
|
if (memory)
|
|
|
|
memory->JumpToAddress(pSymbol->address);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
JumpToAddress(pSymbol->address);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
2009-08-26 09:19:15 +00:00
|
|
|
// Change the global DebuggerFont
|
|
|
|
void CCodeWindow::OnChangeFont(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxFontData data;
|
|
|
|
data.SetInitialFont(DebuggerFont);
|
2009-08-26 09:19:15 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
wxFontDialog dialog(this, data);
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
DebuggerFont = dialog.GetFontData().GetChosenFont();
|
2016-10-03 07:29:50 +00:00
|
|
|
|
2016-11-03 22:02:53 +00:00
|
|
|
UpdateFonts();
|
2016-10-03 07:29:50 +00:00
|
|
|
// TODO: Send event to all panels that tells them to reload the font when it changes.
|
2009-08-26 09:19:15 +00:00
|
|
|
}
|
|
|
|
|
2013-04-19 13:21:45 +00:00
|
|
|
// Toggle windows
|
2009-08-31 05:56:30 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
wxPanel* CCodeWindow::GetUntypedPanel(int id) const
|
2010-07-19 02:09:34 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
wxASSERT_MSG(id >= IDM_DEBUG_WINDOW_LIST_START && id < IDM_DEBUG_WINDOW_LIST_END,
|
|
|
|
"ID out of range");
|
|
|
|
wxASSERT_MSG(id != IDM_LOG_WINDOW && id != IDM_LOG_CONFIG_WINDOW,
|
|
|
|
"Log windows are managed separately");
|
|
|
|
return m_sibling_panels.at(id - IDM_DEBUG_WINDOW_LIST_START);
|
2009-08-27 01:30:08 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
void CCodeWindow::TogglePanel(int id, bool show)
|
2009-08-30 19:44:42 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
wxPanel* panel = GetUntypedPanel(id);
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
// Not all the panels (i.e. CodeWindow) have corresponding menu options.
|
2016-11-05 02:02:36 +00:00
|
|
|
wxMenuItem* item = GetParentMenuBar()->FindItem(id);
|
2016-10-03 07:29:50 +00:00
|
|
|
if (item)
|
|
|
|
item->Check(show);
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
if (show)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
if (!panel)
|
|
|
|
{
|
|
|
|
panel = CreateSiblingPanel(id);
|
|
|
|
}
|
|
|
|
Parent->DoAddPage(panel, iNbAffiliation[id - IDM_DEBUG_WINDOW_LIST_START],
|
|
|
|
Parent->bFloatWindow[id - IDM_DEBUG_WINDOW_LIST_START]);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2016-10-03 07:29:50 +00:00
|
|
|
else if (panel) // Close
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
Parent->DoRemovePage(panel, panel == this);
|
|
|
|
m_sibling_panels[id - IDM_DEBUG_WINDOW_LIST_START] = nullptr;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2014-10-19 10:45:40 +00:00
|
|
|
}
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
wxPanel* CCodeWindow::CreateSiblingPanel(int id)
|
2009-02-23 06:15:48 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
// Includes range check inside the get call
|
|
|
|
wxASSERT_MSG(!GetUntypedPanel(id), "Panel must not already exist");
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
wxPanel* panel = nullptr;
|
|
|
|
switch (id)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
// case IDM_LOG_WINDOW: // These exist separately in CFrame.
|
|
|
|
// case IDM_LOG_CONFIG_WINDOW:
|
|
|
|
case IDM_REGISTER_WINDOW:
|
|
|
|
panel = new CRegisterWindow(Parent, IDM_REGISTER_WINDOW);
|
|
|
|
break;
|
|
|
|
case IDM_WATCH_WINDOW:
|
|
|
|
panel = new CWatchWindow(Parent, IDM_WATCH_WINDOW);
|
|
|
|
break;
|
|
|
|
case IDM_BREAKPOINT_WINDOW:
|
|
|
|
panel = new CBreakPointWindow(this, Parent, IDM_BREAKPOINT_WINDOW);
|
|
|
|
break;
|
|
|
|
case IDM_MEMORY_WINDOW:
|
|
|
|
panel = new CMemoryWindow(Parent, IDM_MEMORY_WINDOW);
|
|
|
|
break;
|
|
|
|
case IDM_JIT_WINDOW:
|
|
|
|
panel = new CJitWindow(Parent, IDM_JIT_WINDOW);
|
|
|
|
break;
|
|
|
|
case IDM_SOUND_WINDOW:
|
|
|
|
panel = new DSPDebuggerLLE(Parent, IDM_SOUND_WINDOW);
|
|
|
|
break;
|
|
|
|
case IDM_VIDEO_WINDOW:
|
|
|
|
panel = new GFXDebuggerPanel(Parent, IDM_VIDEO_WINDOW);
|
|
|
|
break;
|
|
|
|
case IDM_CODE_WINDOW:
|
|
|
|
panel = this;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wxTrap();
|
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2009-02-23 06:15:48 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
m_sibling_panels[id - IDM_DEBUG_WINDOW_LIST_START] = panel;
|
|
|
|
return panel;
|
2009-02-23 06:15:48 +00:00
|
|
|
}
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
void CCodeWindow::OpenPages()
|
2011-01-28 18:39:30 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
// This is forced, and should always be placed as the first tab in the notebook.
|
|
|
|
TogglePanel(IDM_CODE_WINDOW, true);
|
2011-01-28 18:39:30 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
// These panels are managed separately by CFrame
|
|
|
|
if (bShowOnStart[IDM_LOG_WINDOW - IDM_DEBUG_WINDOW_LIST_START])
|
|
|
|
Parent->ToggleLogWindow(true);
|
|
|
|
if (bShowOnStart[IDM_LOG_CONFIG_WINDOW - IDM_DEBUG_WINDOW_LIST_START])
|
|
|
|
Parent->ToggleLogConfigWindow(true);
|
|
|
|
|
|
|
|
// Iterate normal panels that don't have weird rules.
|
|
|
|
for (int i = IDM_REGISTER_WINDOW; i < IDM_CODE_WINDOW; ++i)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
if (bShowOnStart[i - IDM_DEBUG_WINDOW_LIST_START])
|
|
|
|
TogglePanel(i, true);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2009-09-07 20:51:02 +00:00
|
|
|
}
|