mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Fix regular Rename from DisassemblyContextMenu
This commit is contained in:
parent
fab611f1b0
commit
10ce6e7e88
@ -330,6 +330,7 @@ void CutterCore::renameFunction(QString old_name, QString new_name)
|
|||||||
void CutterCore::renameFlag(QString old_name, QString new_name)
|
void CutterCore::renameFlag(QString old_name, QString new_name)
|
||||||
{
|
{
|
||||||
cmd("fr " + old_name + " " + new_name);
|
cmd("fr " + old_name + " " + new_name);
|
||||||
|
emit flagsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::setComment(RVA addr, const QString &cmt)
|
void CutterCore::setComment(RVA addr, const QString &cmt)
|
||||||
|
@ -155,6 +155,25 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
|||||||
|
|
||||||
actionCopy.setVisible(canCopy);
|
actionCopy.setVisible(canCopy);
|
||||||
copySeparator->setVisible(canCopy);
|
copySeparator->setVisible(canCopy);
|
||||||
|
|
||||||
|
|
||||||
|
RCore *core = Core()->core();
|
||||||
|
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, offset, R_ANAL_FCN_TYPE_NULL);
|
||||||
|
RFlagItem *f = r_flag_get_i (core->flags, offset);
|
||||||
|
if (fcn)
|
||||||
|
{
|
||||||
|
actionRename.setVisible(true);
|
||||||
|
actionRename.setText(tr("Rename function \"%1\"").arg(fcn->name));
|
||||||
|
}
|
||||||
|
else if (f)
|
||||||
|
{
|
||||||
|
actionRename.setVisible(true);
|
||||||
|
actionRename.setText(tr("Rename flag \"%1\"").arg(f->name));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actionRename.setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QKeySequence DisassemblyContextMenu::getCopySequence() const
|
QKeySequence DisassemblyContextMenu::getCopySequence() const
|
||||||
@ -231,62 +250,38 @@ void DisassemblyContextMenu::on_actionAddFlag_triggered()
|
|||||||
|
|
||||||
void DisassemblyContextMenu::on_actionRename_triggered()
|
void DisassemblyContextMenu::on_actionRename_triggered()
|
||||||
{
|
{
|
||||||
ut64 tgt_addr = UT64_MAX;
|
|
||||||
RAnalOp op;
|
|
||||||
RCore *core = Core()->core();
|
RCore *core = Core()->core();
|
||||||
|
|
||||||
RenameDialog *dialog = new RenameDialog(this);
|
RenameDialog *dialog = new RenameDialog(this);
|
||||||
|
|
||||||
r_anal_op(core->anal, &op, offset, core->block + offset - core->offset, 32);
|
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, offset, R_ANAL_FCN_TYPE_NULL);
|
||||||
tgt_addr = op.jump != UT64_MAX ? op.jump : op.ptr;
|
RFlagItem *f = r_flag_get_i (core->flags, offset);
|
||||||
if (op.var) {
|
if (fcn)
|
||||||
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, offset, 0);
|
{
|
||||||
if (fcn) {
|
|
||||||
RAnalVar *bar = r_anal_var_get_byname (core->anal, fcn, op.var->name);
|
|
||||||
if (!bar) {
|
|
||||||
bar = r_anal_var_get_byname (core->anal, fcn, op.var->name);
|
|
||||||
if (!bar) {
|
|
||||||
|
|
||||||
bar = r_anal_var_get_byname (core->anal, fcn, op.var->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bar) {
|
|
||||||
dialog->setName(bar->name);
|
|
||||||
if (dialog->exec()) {
|
|
||||||
QString new_name = dialog->getName();
|
|
||||||
r_anal_var_rename (core->anal, fcn->addr, bar->scope,
|
|
||||||
bar->kind, bar->name, new_name.toStdString().c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (tgt_addr != UT64_MAX) {
|
|
||||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, tgt_addr, R_ANAL_FCN_TYPE_NULL);
|
|
||||||
RFlagItem *f = r_flag_get_i (core->flags, tgt_addr);
|
|
||||||
if (fcn) {
|
|
||||||
/* Rename function */
|
/* Rename function */
|
||||||
|
dialog->setWindowTitle(tr("Rename function %1").arg(fcn->name));
|
||||||
dialog->setName(fcn->name);
|
dialog->setName(fcn->name);
|
||||||
if (dialog->exec()) {
|
if (dialog->exec())
|
||||||
|
{
|
||||||
QString new_name = dialog->getName();
|
QString new_name = dialog->getName();
|
||||||
Core()->renameFunction(fcn->name, new_name);
|
Core()->renameFunction(fcn->name, new_name);
|
||||||
}
|
}
|
||||||
} else if (f) {
|
}
|
||||||
|
else if (f)
|
||||||
|
{
|
||||||
/* Rename current flag */
|
/* Rename current flag */
|
||||||
|
dialog->setWindowTitle(tr("Rename flag %1").arg(f->name));
|
||||||
dialog->setName(f->name);
|
dialog->setName(f->name);
|
||||||
if (dialog->exec()) {
|
if (dialog->exec())
|
||||||
|
{
|
||||||
QString new_name = dialog->getName();
|
QString new_name = dialog->getName();
|
||||||
Core()->renameFlag(f->name, new_name);
|
Core()->renameFlag(f->name, new_name);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/* Create new flag */
|
|
||||||
dialog->setName("");
|
|
||||||
if (dialog->exec()) {
|
|
||||||
QString new_name = dialog->getName();
|
|
||||||
Core()->addFlag(tgt_addr, new_name, 1);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
r_anal_op_fini (&op);
|
|
||||||
emit Core()->commentsChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisassemblyContextMenu::on_actionXRefs_triggered()
|
void DisassemblyContextMenu::on_actionXRefs_triggered()
|
||||||
|
@ -81,6 +81,7 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent)
|
|||||||
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
|
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(on_seekChanged(RVA)));
|
||||||
connect(Core(), SIGNAL(raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType)), this, SLOT(raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType)));
|
connect(Core(), SIGNAL(raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType)), this, SLOT(raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType)));
|
||||||
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshDisasm()));
|
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshDisasm()));
|
||||||
|
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshDisasm()));
|
||||||
connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(refreshDisasm()));
|
connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(refreshDisasm()));
|
||||||
connect(Core(), &CutterCore::instructionChanged, this, [this](RVA offset) {
|
connect(Core(), &CutterCore::instructionChanged, this, [this](RVA offset) {
|
||||||
if (offset >= topOffset && offset <= bottomOffset)
|
if (offset >= topOffset && offset <= bottomOffset)
|
||||||
|
Loading…
Reference in New Issue
Block a user