Core: Implement demangled names in code view
This commit is contained in:
parent
ac91f3c26a
commit
9f0f653f60
|
@ -70,6 +70,9 @@ CodeWidget::CodeWidget(QWidget* parent)
|
|||
|
||||
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &CodeWidget::Update);
|
||||
|
||||
connect(&Settings::Instance(), &Settings::ShowDemangledNamesChanged, this,
|
||||
&CodeWidget::OnShowDemangledNamesChanged);
|
||||
|
||||
ConnectWidgets();
|
||||
|
||||
m_code_splitter->restoreState(
|
||||
|
@ -215,6 +218,16 @@ void CodeWidget::OnSetCodeAddress(u32 address)
|
|||
SetAddress(address, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate);
|
||||
}
|
||||
|
||||
void CodeWidget::OnShowDemangledNamesChanged()
|
||||
{
|
||||
UpdateSymbols();
|
||||
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
|
||||
{
|
||||
UpdateFunctionCalls(symbol);
|
||||
UpdateFunctionCallers(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeWidget::OnPPCSymbolsChanged()
|
||||
{
|
||||
UpdateSymbols();
|
||||
|
@ -377,7 +390,7 @@ void CodeWidget::UpdateSymbols()
|
|||
|
||||
for (const auto& symbol : m_ppc_symbol_db.Symbols())
|
||||
{
|
||||
QString name = QString::fromStdString(symbol.second.name);
|
||||
QString name = QString::fromStdString(GetSymbolName(&symbol.second));
|
||||
|
||||
// If the symbol has an object name, add it to the entry name.
|
||||
if (!symbol.second.object_name.empty())
|
||||
|
@ -415,15 +428,16 @@ void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
|
|||
if (call_symbol)
|
||||
{
|
||||
QString name;
|
||||
const std::string& symbol_name = GetSymbolName(call_symbol);
|
||||
|
||||
if (!call_symbol->object_name.empty())
|
||||
{
|
||||
name = QString::fromStdString(
|
||||
fmt::format("< {} ({}, {:08x})", call_symbol->name, call_symbol->object_name, addr));
|
||||
fmt::format("< {} ({}, {:08x})", symbol_name, call_symbol->object_name, addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
name = QString::fromStdString(fmt::format("< {} ({:08x})", call_symbol->name, addr));
|
||||
name = QString::fromStdString(fmt::format("< {} ({:08x})", symbol_name, addr));
|
||||
}
|
||||
|
||||
if (!name.contains(filter, Qt::CaseInsensitive))
|
||||
|
@ -449,15 +463,16 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
|
|||
if (caller_symbol)
|
||||
{
|
||||
QString name;
|
||||
const std::string& symbol_name = GetSymbolName(caller_symbol);
|
||||
|
||||
if (!caller_symbol->object_name.empty())
|
||||
{
|
||||
name = QString::fromStdString(fmt::format("< {} ({}, {:08x})", caller_symbol->name,
|
||||
caller_symbol->object_name, addr));
|
||||
name = QString::fromStdString(
|
||||
fmt::format("< {} ({}, {:08x})", symbol_name, caller_symbol->object_name, addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
name = QString::fromStdString(fmt::format("< {} ({:08x})", caller_symbol->name, addr));
|
||||
name = QString::fromStdString(fmt::format("< {} ({:08x})", symbol_name, addr));
|
||||
}
|
||||
|
||||
if (!name.contains(filter, Qt::CaseInsensitive))
|
||||
|
@ -470,6 +485,22 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
|
|||
}
|
||||
}
|
||||
|
||||
// Gets the name of this symbol based on the option for whether or not to show
|
||||
// demangled names.
|
||||
const std::string& CodeWidget::GetSymbolName(const Common::Symbol* symbol) const
|
||||
{
|
||||
const bool show_demangled_names = Settings::Instance().IsShowDemangledNames();
|
||||
|
||||
if (show_demangled_names && symbol->IsDemangled())
|
||||
{
|
||||
return symbol->demangled_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return symbol->name;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeWidget::Step()
|
||||
{
|
||||
auto& cpu = m_system.GetCPU();
|
||||
|
|
|
@ -61,6 +61,7 @@ private:
|
|||
void UpdateFunctionCalls(const Common::Symbol* symbol);
|
||||
void UpdateFunctionCallers(const Common::Symbol* symbol);
|
||||
|
||||
void OnShowDemangledNamesChanged();
|
||||
void OnPPCSymbolsChanged();
|
||||
void OnSearchAddress();
|
||||
void OnSearchSymbols();
|
||||
|
@ -72,6 +73,8 @@ private:
|
|||
void closeEvent(QCloseEvent*) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
const std::string& GetSymbolName(const Common::Symbol* symbol) const;
|
||||
|
||||
Core::System& m_system;
|
||||
PPCSymbolDB& m_ppc_symbol_db;
|
||||
|
||||
|
|
|
@ -1070,6 +1070,17 @@ void MenuBar::AddSymbolsMenu()
|
|||
m_symbols->addSeparator();
|
||||
|
||||
m_symbols->addAction(tr("&Patch HLE Functions"), this, &MenuBar::PatchHLEFunctions);
|
||||
|
||||
m_symbols->addSeparator();
|
||||
|
||||
m_symbols_debugger_menu = m_symbols->addMenu(tr("Debugger"));
|
||||
m_debugger_show_demangled_names = m_symbols_debugger_menu->addAction(tr("&Show Demangled Names"));
|
||||
m_debugger_show_demangled_names->setCheckable(true);
|
||||
m_debugger_show_demangled_names->setChecked(Settings::Instance().IsShowDemangledNames());
|
||||
connect(m_debugger_show_demangled_names, &QAction::toggled, &Settings::Instance(),
|
||||
&Settings::SetShowDemangledNames);
|
||||
connect(&Settings::Instance(), &Settings::ShowDemangledNamesChanged,
|
||||
m_debugger_show_demangled_names, &QAction::setChecked);
|
||||
}
|
||||
|
||||
void MenuBar::UpdateToolsMenu(const Core::State state)
|
||||
|
|
|
@ -287,6 +287,8 @@ private:
|
|||
QAction* m_jit_systemregisters_off;
|
||||
QAction* m_jit_branch_off;
|
||||
QAction* m_jit_register_cache_off;
|
||||
QMenu* m_symbols_debugger_menu;
|
||||
QAction* m_debugger_show_demangled_names;
|
||||
|
||||
bool m_game_selected = false;
|
||||
};
|
||||
|
|
|
@ -685,6 +685,20 @@ QFont Settings::GetDebugFont() const
|
|||
return GetQSettings().value(QStringLiteral("debugger/font"), default_font).value<QFont>();
|
||||
}
|
||||
|
||||
void Settings::SetShowDemangledNames(bool enabled)
|
||||
{
|
||||
if (IsShowDemangledNames() == enabled)
|
||||
return;
|
||||
QSettings().setValue(QStringLiteral("debugger/showdemanglednames"), enabled);
|
||||
|
||||
emit ShowDemangledNamesChanged(enabled);
|
||||
}
|
||||
|
||||
bool Settings::IsShowDemangledNames() const
|
||||
{
|
||||
return QSettings().value(QStringLiteral("debugger/showdemanglednames")).toBool();
|
||||
}
|
||||
|
||||
void Settings::SetAutoUpdateTrack(const QString& mode)
|
||||
{
|
||||
if (mode == GetAutoUpdateTrack())
|
||||
|
|
|
@ -167,6 +167,8 @@ public:
|
|||
bool IsAssemblerVisible() const;
|
||||
QFont GetDebugFont() const;
|
||||
void SetDebugFont(QFont font);
|
||||
void SetShowDemangledNames(bool enabled);
|
||||
bool IsShowDemangledNames() const;
|
||||
|
||||
// Auto-Update
|
||||
QString GetAutoUpdateTrack() const;
|
||||
|
@ -215,6 +217,7 @@ signals:
|
|||
void AssemblerVisibilityChanged(bool visible);
|
||||
void DebugModeToggled(bool enabled);
|
||||
void DebugFontChanged(const QFont& font);
|
||||
void ShowDemangledNamesChanged(bool enabled);
|
||||
void AutoUpdateTrackChanged(const QString& mode);
|
||||
void FallbackRegionChanged(const DiscIO::Region& region);
|
||||
void AnalyticsToggled(bool enabled);
|
||||
|
|
Loading…
Reference in New Issue