mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 12:26:11 +00:00
Rename functions and flags in Raw Command, Fix #230
This commit is contained in:
parent
ec2dfe83f7
commit
aad3797159
@ -203,6 +203,13 @@ QString CutterCore::cmd(const QString &str)
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CutterCore::cmdRaw(const QString &str)
|
||||||
|
{
|
||||||
|
QString cmdStr = str;
|
||||||
|
cmdStr.replace('\"', "\\\"");
|
||||||
|
return cmd("\"" + cmdStr + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
QJsonDocument CutterCore::cmdj(const QString &str)
|
QJsonDocument CutterCore::cmdj(const QString &str)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
@ -322,10 +329,10 @@ void CutterCore::analyze(int level, QList<QString> advanced)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::renameFunction(QString old_name, QString new_name)
|
void CutterCore::renameFunction(const QString &oldName, const QString &newName)
|
||||||
{
|
{
|
||||||
cmd("afn " + new_name + " " + old_name);
|
cmdRaw("afn " + newName + " " + oldName);
|
||||||
emit functionRenamed(old_name, new_name);
|
emit functionRenamed(oldName, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::delFunction(RVA addr)
|
void CutterCore::delFunction(RVA addr)
|
||||||
@ -336,7 +343,7 @@ void CutterCore::delFunction(RVA addr)
|
|||||||
|
|
||||||
void CutterCore::renameFlag(QString old_name, QString new_name)
|
void CutterCore::renameFlag(QString old_name, QString new_name)
|
||||||
{
|
{
|
||||||
cmd("fr " + old_name + " " + new_name);
|
cmdRaw("fr " + old_name + " " + new_name);
|
||||||
emit flagsChanged();
|
emit flagsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,12 +206,13 @@ public:
|
|||||||
int fcnEndBbs(RVA addr);
|
int fcnEndBbs(RVA addr);
|
||||||
static QString sanitizeStringForCommand(QString s);
|
static QString sanitizeStringForCommand(QString s);
|
||||||
QString cmd(const QString &str);
|
QString cmd(const QString &str);
|
||||||
|
QString cmdRaw(const QString &str);
|
||||||
QJsonDocument cmdj(const QString &str);
|
QJsonDocument cmdj(const QString &str);
|
||||||
QStringList cmdList(const QString &str) { auto l = cmd(str).split("\n"); l.removeAll(""); return l; }
|
QStringList cmdList(const QString &str) { auto l = cmd(str).split("\n"); l.removeAll(""); return l; }
|
||||||
|
|
||||||
QList<DisassemblyLine> disassembleLines(RVA offset, int lines);
|
QList<DisassemblyLine> disassembleLines(RVA offset, int lines);
|
||||||
|
|
||||||
void renameFunction(QString prev_name, QString new_name);
|
void renameFunction(const QString &oldName, const QString &newName);
|
||||||
void delFunction(RVA addr);
|
void delFunction(RVA addr);
|
||||||
void renameFlag(QString old_name, QString new_name);
|
void renameFlag(QString old_name, QString new_name);
|
||||||
void delFlag(RVA addr);
|
void delFlag(RVA addr);
|
||||||
@ -346,7 +347,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void refreshAll();
|
void refreshAll();
|
||||||
|
|
||||||
void functionRenamed(QString prev_name, QString new_name);
|
void functionRenamed(const QString &prev_name, const QString &new_name);
|
||||||
void varsChanged();
|
void varsChanged();
|
||||||
void functionsChanged();
|
void functionsChanged();
|
||||||
void flagsChanged();
|
void flagsChanged();
|
||||||
|
@ -22,7 +22,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
|||||||
// Signals that require a refresh all
|
// Signals that require a refresh all
|
||||||
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshView()));
|
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshView()));
|
||||||
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshView()));
|
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshView()));
|
||||||
connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(refreshView()));
|
connect(Core(), SIGNAL(functionRenamed(const QString &, const QString &)), this, SLOT(refreshView()));
|
||||||
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshView()));
|
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshView()));
|
||||||
connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshView()));
|
connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshView()));
|
||||||
connect(Core(), SIGNAL(instructionChanged(RVA)), this, SLOT(refreshView()));
|
connect(Core(), SIGNAL(instructionChanged(RVA)), this, SLOT(refreshView()));
|
||||||
|
@ -109,7 +109,7 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent)
|
|||||||
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshDisasm()));
|
connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshDisasm()));
|
||||||
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshDisasm()));
|
connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshDisasm()));
|
||||||
connect(Core(), SIGNAL(functionsChanged()), this, SLOT(refreshDisasm()));
|
connect(Core(), SIGNAL(functionsChanged()), this, SLOT(refreshDisasm()));
|
||||||
connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(refreshDisasm()));
|
connect(Core(), SIGNAL(functionRenamed(const QString &, const QString &)), this, SLOT(refreshDisasm()));
|
||||||
connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshDisasm()));
|
connect(Core(), SIGNAL(varsChanged()), 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) {
|
||||||
|
@ -25,7 +25,7 @@ FunctionModel::FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *i
|
|||||||
|
|
||||||
{
|
{
|
||||||
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(seekChanged(RVA)));
|
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(seekChanged(RVA)));
|
||||||
connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(functionRenamed(QString, QString)));
|
connect(Core(), SIGNAL(functionRenamed(const QString &, const QString &)), this, SLOT(functionRenamed(QString, QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FunctionModel::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex FunctionModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
|
@ -56,7 +56,7 @@ void SidebarWidget::refresh(RVA addr)
|
|||||||
if(addr == RVA_INVALID)
|
if(addr == RVA_INVALID)
|
||||||
addr = Core()->getOffset();
|
addr = Core()->getOffset();
|
||||||
|
|
||||||
get_refs_data(addr);
|
updateRefs(addr);
|
||||||
setFcnName(addr);
|
setFcnName(addr);
|
||||||
fillOffsetInfo(RAddressString(addr));
|
fillOffsetInfo(RAddressString(addr));
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ void SidebarWidget::on_xrefToToolButton_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SidebarWidget::get_refs_data(RVA addr)
|
void SidebarWidget::updateRefs(RVA addr)
|
||||||
{
|
{
|
||||||
// refs = calls q hace esa funcion
|
// refs = calls q hace esa funcion
|
||||||
QList<XrefDescription> refs = Core()->getXRefs(addr, false, false);
|
QList<XrefDescription> refs = Core()->getXRefs(addr, false, false);
|
||||||
@ -137,28 +137,12 @@ void SidebarWidget::get_refs_data(RVA addr)
|
|||||||
// xrefs = calls a esa funcion
|
// xrefs = calls a esa funcion
|
||||||
QList<XrefDescription> xrefs = Core()->getXRefs(addr, true, false);
|
QList<XrefDescription> xrefs = Core()->getXRefs(addr, true, false);
|
||||||
|
|
||||||
// Data for the disasm side graph
|
|
||||||
QList<int> data;
|
|
||||||
//qDebug() << "Refs:" << refs.size();
|
|
||||||
data << refs.size();
|
|
||||||
//qDebug() << "XRefs:" << xrefs.size();
|
|
||||||
data << xrefs.size();
|
|
||||||
//qDebug() << "CC: " << this->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16));
|
|
||||||
//data << this->core->fcnCyclomaticComplexity(offset.toLong(&ok, 16));
|
|
||||||
data << Core()->getCycloComplex(addr);
|
|
||||||
//qDebug() << "BB: " << this->core->fcnBasicBlockCount(offset.toLong(&ok, 16));
|
|
||||||
data << Core()->fcnBasicBlockCount(addr);
|
|
||||||
data << Core()->fcnEndBbs(addr);
|
|
||||||
//qDebug() << "MEOW: " + this->core->fcnEndBbs(offset);
|
|
||||||
|
|
||||||
// Update disasm side bar
|
// Update disasm side bar
|
||||||
this->fill_refs(refs, xrefs, data);
|
this->fillRefs(refs, xrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SidebarWidget::fill_refs(QList<XrefDescription> refs, QList<XrefDescription> xrefs, QList<int> graph_data)
|
void SidebarWidget::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> xrefs)
|
||||||
{
|
{
|
||||||
Q_UNUSED(graph_data);
|
|
||||||
|
|
||||||
TempConfig tempConfig;
|
TempConfig tempConfig;
|
||||||
tempConfig.set("scr.html", false)
|
tempConfig.set("scr.html", false)
|
||||||
.set("scr.color", false);
|
.set("scr.color", false);
|
||||||
|
@ -37,8 +37,8 @@ private:
|
|||||||
std::unique_ptr<Ui::SidebarWidget> ui;
|
std::unique_ptr<Ui::SidebarWidget> ui;
|
||||||
|
|
||||||
void setFcnName(RVA addr);
|
void setFcnName(RVA addr);
|
||||||
void get_refs_data(RVA addr);
|
void updateRefs(RVA addr);
|
||||||
void fill_refs(QList<XrefDescription> refs, QList<XrefDescription> xrefs, QList<int> graph_data);
|
void fillRefs(QList<XrefDescription> refs, QList<XrefDescription> xrefs);
|
||||||
void fillOffsetInfo(QString off);
|
void fillOffsetInfo(QString off);
|
||||||
|
|
||||||
void setScrollMode();
|
void setScrollMode();
|
||||||
|
Loading…
Reference in New Issue
Block a user