mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-30 16:55:26 +00:00
Fetch Functions in Task
This commit is contained in:
parent
4001c80a11
commit
83c6fd5d22
@ -994,29 +994,7 @@ QList<RAsmPluginDescription> CutterCore::getRAsmPluginDescriptions()
|
||||
|
||||
QList<FunctionDescription> CutterCore::getAllFunctions()
|
||||
{
|
||||
CORE_LOCK();
|
||||
QList<FunctionDescription> ret;
|
||||
|
||||
QJsonArray jsonArray = cmdj("aflj").array();
|
||||
|
||||
for (QJsonValue value : jsonArray) {
|
||||
QJsonObject jsonObject = value.toObject();
|
||||
|
||||
FunctionDescription function;
|
||||
|
||||
function.offset = (RVA)jsonObject["offset"].toVariant().toULongLong();
|
||||
function.size = (RVA)jsonObject["size"].toVariant().toULongLong();
|
||||
function.nargs = (RVA)jsonObject["nargs"].toVariant().toULongLong();
|
||||
function.nbbs = (RVA)jsonObject["nbbs"].toVariant().toULongLong();
|
||||
function.nlocals = (RVA)jsonObject["nlocals"].toVariant().toULongLong();
|
||||
function.cc = (RVA)jsonObject["cc"].toVariant().toULongLong();
|
||||
function.calltype = jsonObject["calltype"].toString();
|
||||
function.name = jsonObject["name"].toString();
|
||||
|
||||
ret << function;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return parseFunctionsJson(cmdjTask("aflj"));
|
||||
}
|
||||
|
||||
QList<ImportDescription> CutterCore::getAllImports()
|
||||
@ -1233,6 +1211,31 @@ QList<StringDescription> CutterCore::parseStringsJson(const QJsonDocument &doc)
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<FunctionDescription> CutterCore::parseFunctionsJson(const QJsonDocument &doc)
|
||||
{
|
||||
QList<FunctionDescription> ret;
|
||||
QJsonArray jsonArray = doc.array();
|
||||
|
||||
for (QJsonValue value : jsonArray) {
|
||||
QJsonObject jsonObject = value.toObject();
|
||||
|
||||
FunctionDescription function;
|
||||
|
||||
function.offset = (RVA)jsonObject["offset"].toVariant().toULongLong();
|
||||
function.size = (RVA)jsonObject["size"].toVariant().toULongLong();
|
||||
function.nargs = (RVA)jsonObject["nargs"].toVariant().toULongLong();
|
||||
function.nbbs = (RVA)jsonObject["nbbs"].toVariant().toULongLong();
|
||||
function.nlocals = (RVA)jsonObject["nlocals"].toVariant().toULongLong();
|
||||
function.cc = (RVA)jsonObject["cc"].toVariant().toULongLong();
|
||||
function.calltype = jsonObject["calltype"].toString();
|
||||
function.name = jsonObject["name"].toString();
|
||||
|
||||
ret << function;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<FlagspaceDescription> CutterCore::getAllFlagspaces()
|
||||
{
|
||||
CORE_LOCK();
|
||||
@ -1652,7 +1655,6 @@ void CutterCore::loadScript(const QString &scriptname)
|
||||
{
|
||||
r_core_cmd_file(core_, scriptname.toStdString().data());
|
||||
}
|
||||
|
||||
QString CutterCore::getVersionInformation()
|
||||
{
|
||||
int i;
|
||||
@ -1693,15 +1695,16 @@ QString CutterCore::getVersionInformation()
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QJsonArray CutterCore::getOpenedFiles()
|
||||
{
|
||||
QJsonDocument files = cmdj("oj");
|
||||
return files.array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QList<QString> CutterCore::getColorThemes()
|
||||
{
|
||||
QList<QString> r;
|
||||
@ -1722,7 +1725,6 @@ void CutterCore::joinTask(RCoreTask *task)
|
||||
{
|
||||
r_core_task_join(core_, nullptr, task);
|
||||
}
|
||||
|
||||
void CutterCore::deleteTask(RCoreTask *task)
|
||||
{
|
||||
r_core_task_del(core_, task->id);
|
||||
|
@ -493,6 +493,7 @@ public:
|
||||
const QString &filterType = QString::null);
|
||||
|
||||
QList<StringDescription> parseStringsJson(const QJsonDocument &doc);
|
||||
QList<FunctionDescription> parseFunctionsJson(const QJsonDocument &doc);
|
||||
|
||||
/* Signals related */
|
||||
void triggerVarsChanged();
|
||||
|
@ -167,7 +167,6 @@ SOURCES += \
|
||||
widgets/RegistersWidget.cpp \
|
||||
widgets/BacktraceWidget.cpp \
|
||||
dialogs/OpenFileDialog.cpp \
|
||||
utils/StringsTask.cpp \
|
||||
utils/CommandTask.cpp \
|
||||
utils/ProgressIndicator.cpp
|
||||
|
||||
@ -252,6 +251,7 @@ HEADERS += \
|
||||
widgets/BacktraceWidget.h \
|
||||
dialogs/OpenFileDialog.h \
|
||||
utils/StringsTask.h \
|
||||
utils/FunctionsTask.h \
|
||||
utils/CommandTask.h \
|
||||
utils/ProgressIndicator.h
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qRegisterMetaType<QList<StringDescription>>();
|
||||
qRegisterMetaType<QList<FunctionDescription>>();
|
||||
|
||||
CutterApplication a(argc, argv);
|
||||
|
||||
|
@ -56,7 +56,6 @@ private:
|
||||
void prepareRun();
|
||||
};
|
||||
|
||||
|
||||
class AsyncTaskManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
26
src/utils/FunctionsTask.h
Normal file
26
src/utils/FunctionsTask.h
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
#ifndef FUNCTIONSTASK_H
|
||||
#define FUNCTIONSTASK_H
|
||||
|
||||
#include "utils/AsyncTask.h"
|
||||
#include "Cutter.h"
|
||||
|
||||
class FunctionsTask : public AsyncTask
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QString getTitle() override { return tr("Fetching Functions"); }
|
||||
|
||||
signals:
|
||||
void fetchFinished(const QList<FunctionDescription> &strings);
|
||||
|
||||
protected:
|
||||
void runTask() override
|
||||
{
|
||||
auto functions = Core()->getAllFunctions();
|
||||
emit fetchFinished(functions);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //FUNCTIONSTASK_H
|
@ -1,14 +0,0 @@
|
||||
|
||||
#include "StringsTask.h"
|
||||
|
||||
void StringsTask::runTask()
|
||||
{
|
||||
auto strings = Core()->getAllStrings();
|
||||
|
||||
/*RCoreTask *task = Core()->startTask("izzj");
|
||||
Core()->joinTask(task);
|
||||
|
||||
QList<StringDescription> strings = Core()->parseStringsJson(task->msg->res);*/
|
||||
|
||||
emit stringSearchFinished(strings);
|
||||
}
|
@ -16,7 +16,11 @@ signals:
|
||||
void stringSearchFinished(const QList<StringDescription> &strings);
|
||||
|
||||
protected:
|
||||
void runTask() override;
|
||||
void runTask() override
|
||||
{
|
||||
auto strings = Core()->getAllStrings();
|
||||
emit stringSearchFinished(strings);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //STRINGSASYNCTASK_H
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "dialogs/CommentsDialog.h"
|
||||
#include "dialogs/RenameDialog.h"
|
||||
#include "dialogs/XrefsDialog.h"
|
||||
#include "utils/FunctionsTask.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <QMenu>
|
||||
@ -439,13 +440,20 @@ FunctionsWidget::~FunctionsWidget() {}
|
||||
|
||||
void FunctionsWidget::refreshTree()
|
||||
{
|
||||
if (task) {
|
||||
task->wait();
|
||||
}
|
||||
|
||||
task = QSharedPointer<FunctionsTask>(new FunctionsTask());
|
||||
connect(task.data(), &FunctionsTask::fetchFinished, this, [this] (const QList<FunctionDescription> &functions) {
|
||||
functionModel->beginReloadFunctions();
|
||||
|
||||
functions = Core()->getAllFunctions();
|
||||
this->functions = functions;
|
||||
|
||||
importAddresses.clear();
|
||||
for (ImportDescription import : Core()->getAllImports())
|
||||
for (ImportDescription import : Core()->getAllImports()) {
|
||||
importAddresses.insert(import.plt);
|
||||
}
|
||||
|
||||
mainAdress = (ut64)Core()->cmdj("iMj").object()["vaddr"].toInt();
|
||||
|
||||
@ -453,6 +461,8 @@ void FunctionsWidget::refreshTree()
|
||||
|
||||
// resize offset and size columns
|
||||
qhelpers::adjustColumns(ui->functionsTreeView, 3, 0);
|
||||
});
|
||||
Core()->getAsyncTaskManager()->start(task);
|
||||
}
|
||||
|
||||
void FunctionsWidget::onFunctionsDoubleClicked(const QModelIndex &index)
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
class MainWindow;
|
||||
class QTreeWidgetItem;
|
||||
class FunctionsTask;
|
||||
|
||||
namespace Ui {
|
||||
class FunctionsWidget;
|
||||
@ -121,6 +122,8 @@ private:
|
||||
std::unique_ptr<Ui::FunctionsWidget> ui;
|
||||
MainWindow *main;
|
||||
|
||||
QSharedPointer<FunctionsTask> task;
|
||||
|
||||
QList<FunctionDescription> functions;
|
||||
QSet<RVA> importAddresses;
|
||||
ut64 mainAdress;
|
||||
|
Loading…
Reference in New Issue
Block a user