mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
PPCSymbolDB: Move instance to PowerPCManager
This commit is contained in:
@ -194,25 +194,26 @@ void BranchWatchProxyModel::SetInspected(const QModelIndex& index)
|
||||
}
|
||||
|
||||
BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& branch_watch,
|
||||
CodeWidget* code_widget, QWidget* parent)
|
||||
PPCSymbolDB& ppc_symbol_db, CodeWidget* code_widget,
|
||||
QWidget* parent)
|
||||
: QDialog(parent), m_system(system), m_branch_watch(branch_watch), m_code_widget(code_widget)
|
||||
{
|
||||
setWindowTitle(tr("Branch Watch Tool"));
|
||||
setWindowFlags((windowFlags() | Qt::WindowMinMaxButtonsHint) & ~Qt::WindowContextHelpButtonHint);
|
||||
SetQWidgetWindowDecorations(this);
|
||||
setLayout([this]() {
|
||||
setLayout([this, &ppc_symbol_db]() {
|
||||
auto* main_layout = new QVBoxLayout;
|
||||
|
||||
// Controls Toolbar (widgets are added later)
|
||||
main_layout->addWidget(m_control_toolbar = new QToolBar);
|
||||
|
||||
// Branch Watch Table
|
||||
main_layout->addWidget(m_table_view = [this]() {
|
||||
main_layout->addWidget(m_table_view = [this, &ppc_symbol_db]() {
|
||||
const auto& ui_settings = Settings::Instance();
|
||||
|
||||
m_table_proxy = new BranchWatchProxyModel(m_branch_watch);
|
||||
m_table_proxy->setSourceModel(m_table_model =
|
||||
new BranchWatchTableModel(m_system, m_branch_watch));
|
||||
m_table_proxy->setSourceModel(
|
||||
m_table_model = new BranchWatchTableModel(m_system, m_branch_watch, ppc_symbol_db));
|
||||
m_table_proxy->setSortRole(UserRole::SortRole);
|
||||
|
||||
m_table_model->setFont(ui_settings.GetDebugFont());
|
||||
|
@ -17,6 +17,8 @@ class BranchWatch;
|
||||
class CPUThreadGuard;
|
||||
class System;
|
||||
} // namespace Core
|
||||
class PPCSymbolDB;
|
||||
|
||||
class BranchWatchProxyModel;
|
||||
class BranchWatchTableModel;
|
||||
class CodeWidget;
|
||||
@ -48,7 +50,8 @@ class BranchWatchDialog : public QDialog
|
||||
|
||||
public:
|
||||
explicit BranchWatchDialog(Core::System& system, Core::BranchWatch& branch_watch,
|
||||
CodeWidget* code_widget, QWidget* parent = nullptr);
|
||||
PPCSymbolDB& ppc_symbol_db, CodeWidget* code_widget,
|
||||
QWidget* parent = nullptr);
|
||||
~BranchWatchDialog() override;
|
||||
|
||||
protected:
|
||||
|
@ -285,8 +285,8 @@ void BranchWatchTableModel::PrefetchSymbols()
|
||||
for (const Core::BranchWatch::Selection::value_type& value : selection)
|
||||
{
|
||||
const Core::BranchWatch::Collection::value_type* const kv = value.collection_ptr;
|
||||
m_symbol_list.emplace_back(g_symbolDB.GetSymbolFromAddr(kv->first.origin_addr),
|
||||
g_symbolDB.GetSymbolFromAddr(kv->first.destin_addr));
|
||||
m_symbol_list.emplace_back(m_ppc_symbol_db.GetSymbolFromAddr(kv->first.origin_addr),
|
||||
m_ppc_symbol_db.GetSymbolFromAddr(kv->first.destin_addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ class BranchWatch;
|
||||
class CPUThreadGuard;
|
||||
class System;
|
||||
} // namespace Core
|
||||
class PPCSymbolDB;
|
||||
|
||||
namespace BranchWatchTableModelColumn
|
||||
{
|
||||
@ -69,8 +70,9 @@ public:
|
||||
using SymbolList = QList<SymbolListValueType>;
|
||||
|
||||
explicit BranchWatchTableModel(Core::System& system, Core::BranchWatch& branch_watch,
|
||||
QObject* parent = nullptr)
|
||||
: QAbstractTableModel(parent), m_system(system), m_branch_watch(branch_watch)
|
||||
PPCSymbolDB& ppc_symbol_db, QObject* parent = nullptr)
|
||||
: QAbstractTableModel(parent), m_system(system), m_branch_watch(branch_watch),
|
||||
m_ppc_symbol_db(ppc_symbol_db)
|
||||
{
|
||||
}
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
@ -113,6 +115,7 @@ private:
|
||||
|
||||
Core::System& m_system;
|
||||
Core::BranchWatch& m_branch_watch;
|
||||
PPCSymbolDB& m_ppc_symbol_db;
|
||||
|
||||
SymbolList m_symbol_list;
|
||||
mutable QFont m_font;
|
||||
|
@ -178,6 +178,7 @@ void BreakpointWidget::Update()
|
||||
auto& power_pc = m_system.GetPowerPC();
|
||||
auto& breakpoints = power_pc.GetBreakPoints();
|
||||
auto& memchecks = power_pc.GetMemChecks();
|
||||
auto& ppc_symbol_db = power_pc.GetSymbolDB();
|
||||
|
||||
// Breakpoints
|
||||
for (const auto& bp : breakpoints.GetBreakPoints())
|
||||
@ -192,10 +193,10 @@ void BreakpointWidget::Update()
|
||||
m_table->setItem(i, 0, active);
|
||||
m_table->setItem(i, 1, create_item(QStringLiteral("BP")));
|
||||
|
||||
if (g_symbolDB.GetSymbolFromAddr(bp.address))
|
||||
if (ppc_symbol_db.GetSymbolFromAddr(bp.address))
|
||||
{
|
||||
m_table->setItem(i, 2,
|
||||
create_item(QString::fromStdString(g_symbolDB.GetDescription(bp.address))));
|
||||
m_table->setItem(
|
||||
i, 2, create_item(QString::fromStdString(ppc_symbol_db.GetDescription(bp.address))));
|
||||
}
|
||||
|
||||
m_table->setItem(i, 3,
|
||||
@ -233,10 +234,11 @@ void BreakpointWidget::Update()
|
||||
m_table->setItem(i, 0, active);
|
||||
m_table->setItem(i, 1, create_item(QStringLiteral("MBP")));
|
||||
|
||||
if (g_symbolDB.GetSymbolFromAddr(mbp.start_address))
|
||||
if (ppc_symbol_db.GetSymbolFromAddr(mbp.start_address))
|
||||
{
|
||||
m_table->setItem(
|
||||
i, 2, create_item(QString::fromStdString(g_symbolDB.GetDescription(mbp.start_address))));
|
||||
i, 2,
|
||||
create_item(QString::fromStdString(ppc_symbol_db.GetDescription(mbp.start_address))));
|
||||
}
|
||||
|
||||
if (mbp.is_ranged)
|
||||
|
@ -138,7 +138,8 @@ constexpr int CODE_VIEW_COLUMN_DESCRIPTION = 4;
|
||||
constexpr int CODE_VIEW_COLUMN_BRANCH_ARROWS = 5;
|
||||
constexpr int CODE_VIEW_COLUMNCOUNT = 6;
|
||||
|
||||
CodeViewWidget::CodeViewWidget() : m_system(Core::System::GetInstance())
|
||||
CodeViewWidget::CodeViewWidget()
|
||||
: m_system(Core::System::GetInstance()), m_ppc_symbol_db(m_system.GetPPCSymbolDB())
|
||||
{
|
||||
setColumnCount(CODE_VIEW_COLUMNCOUNT);
|
||||
setShowGrid(false);
|
||||
@ -382,7 +383,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
||||
if (debug_interface.IsBreakpoint(addr))
|
||||
{
|
||||
auto icon = Resources::GetThemeIcon("debugger_breakpoint").pixmap(QSize(rowh - 2, rowh - 2));
|
||||
if (!m_system.GetPowerPC().GetBreakPoints().IsBreakPointEnable(addr))
|
||||
if (!power_pc.GetBreakPoints().IsBreakPointEnable(addr))
|
||||
{
|
||||
QPixmap disabled_icon(icon.size());
|
||||
disabled_icon.fill(Qt::transparent);
|
||||
@ -410,7 +411,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
||||
|
||||
CalculateBranchIndentation();
|
||||
|
||||
g_symbolDB.FillInCallers();
|
||||
m_ppc_symbol_db.FillInCallers();
|
||||
|
||||
repaint();
|
||||
m_updating = false;
|
||||
@ -561,7 +562,7 @@ void CodeViewWidget::OnContextMenu()
|
||||
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
bool has_symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
const bool has_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
|
||||
|
||||
auto* follow_branch_action =
|
||||
menu->addAction(tr("Follow &branch"), this, &CodeViewWidget::OnFollowBranch);
|
||||
@ -819,7 +820,7 @@ void CodeViewWidget::OnCopyFunction()
|
||||
{
|
||||
const u32 address = GetContextAddress();
|
||||
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(address);
|
||||
if (!symbol)
|
||||
return;
|
||||
|
||||
@ -877,7 +878,7 @@ void CodeViewWidget::OnAddFunction()
|
||||
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
|
||||
g_symbolDB.AddFunction(guard, addr);
|
||||
m_ppc_symbol_db.AddFunction(guard, addr);
|
||||
emit SymbolsChanged();
|
||||
Update(&guard);
|
||||
}
|
||||
@ -915,7 +916,7 @@ void CodeViewWidget::OnRenameSymbol()
|
||||
{
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
Common::Symbol* const symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
|
||||
|
||||
if (!symbol)
|
||||
return;
|
||||
@ -950,7 +951,7 @@ void CodeViewWidget::OnSetSymbolSize()
|
||||
{
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
Common::Symbol* const symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
|
||||
|
||||
if (!symbol)
|
||||
return;
|
||||
@ -975,7 +976,7 @@ void CodeViewWidget::OnSetSymbolEndAddress()
|
||||
{
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
Common::Symbol* const symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
|
||||
|
||||
if (!symbol)
|
||||
return;
|
||||
|
@ -23,6 +23,7 @@ class System;
|
||||
|
||||
struct CodeViewBranch;
|
||||
class BranchDisplayDelegate;
|
||||
class PPCSymbolDB;
|
||||
|
||||
class CodeViewWidget : public QTableWidget
|
||||
{
|
||||
@ -102,6 +103,7 @@ private:
|
||||
void CalculateBranchIndentation();
|
||||
|
||||
Core::System& m_system;
|
||||
PPCSymbolDB& m_ppc_symbol_db;
|
||||
|
||||
bool m_updating = false;
|
||||
|
||||
|
@ -36,7 +36,9 @@ static const QString BOX_SPLITTER_STYLESHEET = QStringLiteral(
|
||||
"QSplitter::handle { border-top: 1px dashed black; width: 1px; margin-left: 10px; "
|
||||
"margin-right: 10px; }");
|
||||
|
||||
CodeWidget::CodeWidget(QWidget* parent) : QDockWidget(parent), m_system(Core::System::GetInstance())
|
||||
CodeWidget::CodeWidget(QWidget* parent)
|
||||
: QDockWidget(parent), m_system(Core::System::GetInstance()),
|
||||
m_ppc_symbol_db(m_system.GetPPCSymbolDB())
|
||||
{
|
||||
setWindowTitle(tr("Code"));
|
||||
setObjectName(QStringLiteral("code"));
|
||||
@ -171,13 +173,11 @@ void CodeWidget::ConnectWidgets()
|
||||
connect(m_search_address, &QLineEdit::returnPressed, this, &CodeWidget::OnSearchAddress);
|
||||
connect(m_search_symbols, &QLineEdit::textChanged, this, &CodeWidget::OnSearchSymbols);
|
||||
connect(m_search_calls, &QLineEdit::textChanged, this, [this]() {
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
|
||||
if (symbol)
|
||||
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
|
||||
UpdateFunctionCalls(symbol);
|
||||
});
|
||||
connect(m_search_callers, &QLineEdit::textChanged, this, [this]() {
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
|
||||
if (symbol)
|
||||
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
|
||||
UpdateFunctionCallers(symbol);
|
||||
});
|
||||
connect(m_search_callstack, &QLineEdit::textChanged, this, &CodeWidget::UpdateCallstack);
|
||||
@ -194,8 +194,7 @@ void CodeWidget::ConnectWidgets()
|
||||
connect(m_code_view, &CodeViewWidget::SymbolsChanged, this, [this]() {
|
||||
UpdateCallstack();
|
||||
UpdateSymbols();
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
|
||||
if (symbol)
|
||||
if (const Common::Symbol* symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress()))
|
||||
{
|
||||
UpdateFunctionCalls(symbol);
|
||||
UpdateFunctionCallers(symbol);
|
||||
@ -214,8 +213,8 @@ void CodeWidget::OnBranchWatchDialog()
|
||||
{
|
||||
if (m_branch_watch_dialog == nullptr)
|
||||
{
|
||||
m_branch_watch_dialog =
|
||||
new BranchWatchDialog(m_system, m_system.GetPowerPC().GetBranchWatch(), this, this);
|
||||
m_branch_watch_dialog = new BranchWatchDialog(m_system, m_system.GetPowerPC().GetBranchWatch(),
|
||||
m_ppc_symbol_db, this, this);
|
||||
}
|
||||
m_branch_watch_dialog->show();
|
||||
m_branch_watch_dialog->raise();
|
||||
@ -260,7 +259,7 @@ void CodeWidget::OnSelectSymbol()
|
||||
return;
|
||||
|
||||
const u32 address = items[0]->data(Qt::UserRole).toUInt();
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(address);
|
||||
|
||||
m_code_view->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithUpdate);
|
||||
UpdateCallstack();
|
||||
@ -321,7 +320,7 @@ void CodeWidget::Update()
|
||||
if (!isVisible())
|
||||
return;
|
||||
|
||||
const Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(m_code_view->GetAddress());
|
||||
const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(m_code_view->GetAddress());
|
||||
|
||||
UpdateCallstack();
|
||||
|
||||
@ -343,13 +342,7 @@ void CodeWidget::UpdateCallstack()
|
||||
return;
|
||||
|
||||
std::vector<Dolphin_Debugger::CallstackEntry> stack;
|
||||
|
||||
const bool success = [this, &stack] {
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
return Dolphin_Debugger::GetCallstack(guard, stack);
|
||||
}();
|
||||
|
||||
if (!success)
|
||||
if (!Dolphin_Debugger::GetCallstack(Core::CPUThreadGuard{m_system}, stack))
|
||||
{
|
||||
m_callstack_list->addItem(tr("Invalid callstack"));
|
||||
return;
|
||||
@ -377,7 +370,7 @@ void CodeWidget::UpdateSymbols()
|
||||
m_symbols_list->selectedItems()[0]->text();
|
||||
m_symbols_list->clear();
|
||||
|
||||
for (const auto& symbol : g_symbolDB.Symbols())
|
||||
for (const auto& symbol : m_ppc_symbol_db.Symbols())
|
||||
{
|
||||
QString name = QString::fromStdString(symbol.second.name);
|
||||
|
||||
@ -411,7 +404,7 @@ void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
|
||||
for (const auto& call : symbol->calls)
|
||||
{
|
||||
const u32 addr = call.function;
|
||||
const Common::Symbol* call_symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
const Common::Symbol* const call_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
|
||||
|
||||
if (call_symbol)
|
||||
{
|
||||
@ -436,7 +429,7 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
|
||||
for (const auto& caller : symbol->callers)
|
||||
{
|
||||
const u32 addr = caller.call_address;
|
||||
const Common::Symbol* caller_symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
const Common::Symbol* const caller_symbol = m_ppc_symbol_db.GetSymbolFromAddr(addr);
|
||||
|
||||
if (caller_symbol)
|
||||
{
|
||||
|
@ -26,6 +26,7 @@ namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
class PPCSymbolDB;
|
||||
|
||||
class CodeWidget : public QDockWidget
|
||||
{
|
||||
@ -71,6 +72,7 @@ private:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
Core::System& m_system;
|
||||
PPCSymbolDB& m_ppc_symbol_db;
|
||||
|
||||
BranchWatchDialog* m_branch_watch_dialog = nullptr;
|
||||
QLineEdit* m_search_address;
|
||||
|
Reference in New Issue
Block a user