Skip to content

Commit

Permalink
Debugger: Add Rename Symbol option to symbol tree context menus
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoticgd committed Mar 2, 2024
1 parent ec45b2d commit 0c6a871
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pcsx2-qt/Debugger/SymbolTree/SymbolTreeWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ void SymbolTreeWidget::setupMenu()

m_context_menu->addSeparator();

QAction* rename_symbol = new QAction(tr("Rename Symbol"), this);
connect(rename_symbol, &QAction::triggered, this, &SymbolTreeWidget::onRenameSymbol);
m_context_menu->addAction(rename_symbol);

m_context_menu->addSeparator();

QAction* go_to_in_disassembly = new QAction(tr("Go to in Disassembly"), this);
connect(go_to_in_disassembly, &QAction::triggered, this, &SymbolTreeWidget::onGoToInDisassembly);
m_context_menu->addAction(go_to_in_disassembly);
Expand Down Expand Up @@ -318,6 +324,41 @@ void SymbolTreeWidget::onCopyLocation()
QApplication::clipboard()->setText(node->location.toString(m_cpu));
}

void SymbolTreeWidget::onRenameSymbol()
{
if (!m_model)
return;

QModelIndex index = m_ui.treeView->currentIndex();
if (!index.isValid())
return;

SymbolTreeNode* node = static_cast<SymbolTreeNode*>(index.internalPointer());
if (!node->symbol.valid())
return;

QString title = tr("Rename Symbol");
QString label = tr("Name:");

QString text;
m_cpu.GetSymbolGuardian().BlockingRead([&](const ccc::SymbolDatabase& database) {
const ccc::Symbol* symbol = node->symbol.lookup_symbol(database);
if (!symbol || !symbol->address().valid())
return;

text = QString::fromStdString(symbol->name());
});

bool ok;
std::string name = QInputDialog::getText(this, title, label, QLineEdit::Normal, text, &ok).toStdString();
if (!ok)
return;

m_cpu.GetSymbolGuardian().BlockingReadWrite([&](ccc::SymbolDatabase& database) {
node->symbol.rename_symbol(name, database);
});
}

void SymbolTreeWidget::onGoToInDisassembly()
{
SymbolTreeNode* node = currentNode();
Expand Down
1 change: 1 addition & 0 deletions pcsx2-qt/Debugger/SymbolTree/SymbolTreeWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class SymbolTreeWidget : public QWidget

void onCopyName();
void onCopyLocation();
void onRenameSymbol();
void onGoToInDisassembly();
void onGoToInMemoryView();
void onResetChildren();
Expand Down

0 comments on commit 0c6a871

Please sign in to comment.