Skip to content

Commit

Permalink
Qt/debugger: restore previous symbols and signature features
Browse files Browse the repository at this point in the history
They were mysteriously lost after the Qt migration.
  • Loading branch information
aldelaro5 committed Oct 9, 2018
1 parent 4b75876 commit 3921d8a
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 6 deletions.
112 changes: 107 additions & 5 deletions Source/Core/DolphinQt/MenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,13 +876,19 @@ void MenuBar::AddSymbolsMenu()
m_symbols->addSeparator();

m_symbols->addAction(tr("Load &Other Map File..."), this, &MenuBar::LoadOtherSymbolMap);
m_symbols->addAction(tr("Load &Bad Map File..."), this, &MenuBar::LoadBadSymbolMap);
m_symbols->addAction(tr("Save Symbol Map &As..."), this, &MenuBar::SaveSymbolMapAs);
m_symbols->addSeparator();

m_symbols->addAction(tr("Save Code"), this, &MenuBar::SaveCode);
m_symbols->addAction(tr("Sa&ve Code"), this, &MenuBar::SaveCode);
m_symbols->addSeparator();

m_symbols->addAction(tr("&Create Signature File..."), this, &MenuBar::CreateSignatureFile);
m_symbols->addAction(tr("C&reate Signature File..."), this, &MenuBar::CreateSignatureFile);
m_symbols->addAction(tr("Append to &Existing Signature File..."), this,
&MenuBar::AppendSignatureFile);
m_symbols->addAction(tr("Combine &Two Signature Files..."), this,
&MenuBar::CombineSignatureFiles);
m_symbols->addAction(tr("Appl&y Signature File..."), this, &MenuBar::ApplySignatureFile);
m_symbols->addSeparator();

m_symbols->addAction(tr("&Patch HLE Functions"), this, &MenuBar::PatchHLEFunctions);
Expand Down Expand Up @@ -1226,6 +1232,22 @@ void MenuBar::LoadOtherSymbolMap()
emit NotifySymbolsUpdated();
}

void MenuBar::LoadBadSymbolMap()
{
const QString file = QFileDialog::getOpenFileName(
this, tr("Load map file"), QString::fromStdString(File::GetUserPath(D_MAPS_IDX)),
tr("Dolphin Map File (*.map)"));

if (file.isEmpty())
return;

if (!TryLoadMapFile(file, true))
return;

HLE::PatchFunctions();
emit NotifySymbolsUpdated();
}

void MenuBar::SaveSymbolMapAs()
{
const std::string& title_id_str = SConfig::GetInstance().m_debugger_game_id;
Expand Down Expand Up @@ -1256,9 +1278,9 @@ void MenuBar::SaveCode()
}
}

bool MenuBar::TryLoadMapFile(const QString& path)
bool MenuBar::TryLoadMapFile(const QString& path, const bool bad)
{
if (!g_symbolDB.LoadMap(path.toStdString()))
if (!g_symbolDB.LoadMap(path.toStdString(), bad))
{
QMessageBox::warning(this, tr("Error"), tr("Failed to load map file '%1'").arg(path));
return false;
Expand All @@ -1280,7 +1302,8 @@ void MenuBar::CreateSignatureFile()
const QString text = QInputDialog::getText(
this, tr("Input"), tr("Only export symbols with prefix:\n(Blank for all symbols)"));

const QString file = QFileDialog::getSaveFileName(this, tr("Save signature file"));
const QString file = QFileDialog::getSaveFileName(
this, tr("Save signature file"), QDir::homePath(), tr("Functions signature *.dsy(*.dsy)"));
if (file.isEmpty())
return;

Expand All @@ -1298,6 +1321,85 @@ void MenuBar::CreateSignatureFile()
db.List();
}

void MenuBar::AppendSignatureFile()
{
const QString text = QInputDialog::getText(
this, tr("Input"), tr("Only append symbols with prefix:\n(Blank for all symbols)"));

const QString file = QFileDialog::getSaveFileName(
this, tr("Append signature to"), QDir::homePath(), tr("Functions signature *.dsy(*.dsy)"));
if (file.isEmpty())
return;

const std::string prefix = text.toStdString();
const std::string signature_path = file.toStdString();
SignatureDB db(signature_path);
db.Populate(&g_symbolDB, prefix);
db.List();
db.Load(signature_path);
if (!db.Save(signature_path))
{
QMessageBox::warning(this, tr("Error"),
tr("Failed to append to signature file '%1'").arg(file));
return;
}

db.List();
}

void MenuBar::ApplySignatureFile()
{
const QString file = QFileDialog::getOpenFileName(
this, tr("Apply signature file"), QDir::homePath(), tr("Functions signature *.dsy(*.dsy)"));

if (file.isEmpty())
return;

const std::string load_path = file.toStdString();
SignatureDB db(load_path);
db.Load(load_path);
db.Apply(&g_symbolDB);
db.List();
HLE::PatchFunctions();
emit NotifySymbolsUpdated();
}

void MenuBar::CombineSignatureFiles()
{
const QString priorityFile =
QFileDialog::getOpenFileName(this, tr("Choose priority input file"), QDir::homePath(),
tr("Functions signature *.dsy(*.dsy)"));
if (priorityFile.isEmpty())
return;

const QString secondaryFile =
QFileDialog::getOpenFileName(this, tr("Choose secondary input file"), QDir::homePath(),
tr("Functions signature *.dsy(*.dsy)"));
if (secondaryFile.isEmpty())
return;

const QString saveFile =
QFileDialog::getSaveFileName(this, tr("Save combined output file as"), QDir::homePath(),
tr("Functions signature *.dsy(*.dsy)"));
if (saveFile.isEmpty())
return;

const std::string load_pathPriorityFile = priorityFile.toStdString();
const std::string load_pathSecondaryFile = secondaryFile.toStdString();
const std::string save_path = saveFile.toStdString();
SignatureDB db(load_pathPriorityFile);
db.Load(load_pathPriorityFile);
db.Load(load_pathSecondaryFile);
if (!db.Save(save_path))
{
QMessageBox::warning(this, tr("Error"),
tr("Failed to save to signature file '%1'").arg(saveFile));
return;
}

db.List();
}

void MenuBar::PatchHLEFunctions()
{
HLE::PatchFunctions();
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/DolphinQt/MenuBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,16 @@ class MenuBar final : public QMenuBar
void GenerateSymbolsFromRSO();
void LoadSymbolMap();
void LoadOtherSymbolMap();
void LoadBadSymbolMap();
void SaveSymbolMap();
void SaveSymbolMapAs();
void SaveCode();
bool TryLoadMapFile(const QString& path);
bool TryLoadMapFile(const QString& path, const bool bad = false);
void TrySaveSymbolMap(const QString& path);
void CreateSignatureFile();
void AppendSignatureFile();
void ApplySignatureFile();
void CombineSignatureFiles();
void PatchHLEFunctions();
void ClearCache();
void LogInstructions();
Expand Down

0 comments on commit 3921d8a

Please sign in to comment.