mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-18 10:35:25 +00:00
Use open API instead of commands (#2757)
This commit is contained in:
parent
8fd35f2109
commit
57f34bfb98
@ -19,8 +19,9 @@ void AnalTask::interrupt()
|
|||||||
QString AnalTask::getTitle()
|
QString AnalTask::getTitle()
|
||||||
{
|
{
|
||||||
// If no file is loaded we consider it's Initial Analysis
|
// If no file is loaded we consider it's Initial Analysis
|
||||||
QJsonArray openedFiles = Core()->getOpenedFiles();
|
RzCoreLocked core(Core());
|
||||||
if (!openedFiles.size()) {
|
RzList *descs = rz_id_storage_list(core->io->files);
|
||||||
|
if (rz_list_empty(descs)) {
|
||||||
return tr("Initial Analysis");
|
return tr("Initial Analysis");
|
||||||
}
|
}
|
||||||
return tr("Analyzing Program");
|
return tr("Analyzing Program");
|
||||||
@ -38,8 +39,9 @@ void AnalTask::runTask()
|
|||||||
Core()->setConfig("bin.demangle", options.demangle);
|
Core()->setConfig("bin.demangle", options.demangle);
|
||||||
|
|
||||||
// Do not reload the file if already loaded
|
// Do not reload the file if already loaded
|
||||||
QJsonArray openedFiles = Core()->getOpenedFiles();
|
RzCoreLocked core(Core());
|
||||||
if (!openedFiles.size() && options.filename.length()) {
|
RzList *descs = rz_id_storage_list(core->io->files);
|
||||||
|
if (rz_list_empty(descs) && options.filename.length()) {
|
||||||
log(tr("Loading the file..."));
|
log(tr("Loading the file..."));
|
||||||
openFailed = false;
|
openFailed = false;
|
||||||
bool fileLoaded =
|
bool fileLoaded =
|
||||||
|
@ -386,11 +386,12 @@ bool CutterCore::isRedirectableDebugee()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We are only able to redirect locally debugged unix processes
|
// We are only able to redirect locally debugged unix processes
|
||||||
QJsonArray openFilesArray = cmdj("oj").array();
|
RzCoreLocked core(Core());
|
||||||
;
|
RzList *descs = rz_id_storage_list(core->io->files);
|
||||||
for (QJsonValue value : openFilesArray) {
|
RzListIter *it;
|
||||||
QJsonObject openFile = value.toObject();
|
RzIODesc *desc;
|
||||||
QString URI = openFile["uri"].toString();
|
CutterRzListForeach(descs, it, RzIODesc, desc) {
|
||||||
|
QString URI = QString(desc->uri);
|
||||||
if (URI.contains("ptrace") | URI.contains("mach")) {
|
if (URI.contains("ptrace") | URI.contains("mach")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1913,10 +1914,12 @@ void CutterCore::attachRemote(const QString &uri)
|
|||||||
debugTask.clear();
|
debugTask.clear();
|
||||||
// Check if we actually connected
|
// Check if we actually connected
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
QJsonArray openFilesArray = getOpenedFiles();
|
RzCoreLocked core(Core());
|
||||||
for (QJsonValue value : openFilesArray) {
|
RzList *descs = rz_id_storage_list(core->io->files);
|
||||||
QJsonObject openFile = value.toObject();
|
RzListIter *it;
|
||||||
QString fileUri = openFile["uri"].toString();
|
RzIODesc *desc;
|
||||||
|
CutterRzListForeach(descs, it, RzIODesc, desc) {
|
||||||
|
QString fileUri = QString(desc->uri);
|
||||||
if (!fileUri.compare(uri)) {
|
if (!fileUri.compare(uri)) {
|
||||||
connected = true;
|
connected = true;
|
||||||
}
|
}
|
||||||
@ -2023,13 +2026,14 @@ void CutterCore::stopDebug()
|
|||||||
} else {
|
} else {
|
||||||
QString ptraceFiles = "";
|
QString ptraceFiles = "";
|
||||||
// close ptrace file descriptors left open
|
// close ptrace file descriptors left open
|
||||||
QJsonArray openFilesArray = cmdj("oj").array();
|
RzCoreLocked core(Core());
|
||||||
;
|
RzList *descs = rz_id_storage_list(core->io->files);
|
||||||
for (QJsonValue value : openFilesArray) {
|
RzListIter *it;
|
||||||
QJsonObject openFile = value.toObject();
|
RzIODesc *desc;
|
||||||
QString URI = openFile["uri"].toString();
|
CutterRzListForeach(descs, it, RzIODesc, desc) {
|
||||||
|
QString URI = QString(desc->uri);
|
||||||
if (URI.contains("ptrace")) {
|
if (URI.contains("ptrace")) {
|
||||||
ptraceFiles += "o-" + QString::number(openFile["fd"].toInt()) + ";";
|
ptraceFiles += "o-" + QString::number(desc->fd) + ";";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Use cmd because cmdRaw would not work with command concatenation
|
// Use cmd because cmdRaw would not work with command concatenation
|
||||||
@ -4025,12 +4029,6 @@ QString CutterCore::getVersionInformation()
|
|||||||
return versionInfo;
|
return versionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray CutterCore::getOpenedFiles()
|
|
||||||
{
|
|
||||||
QJsonDocument files = cmdj("oj");
|
|
||||||
return files.array();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QString> CutterCore::getColorThemes()
|
QList<QString> CutterCore::getColorThemes()
|
||||||
{
|
{
|
||||||
QList<QString> r;
|
QList<QString> r;
|
||||||
|
@ -278,7 +278,6 @@ public:
|
|||||||
bool tryFile(QString path, bool rw);
|
bool tryFile(QString path, bool rw);
|
||||||
bool mapFile(QString path, RVA mapaddr);
|
bool mapFile(QString path, RVA mapaddr);
|
||||||
void loadScript(const QString &scriptname);
|
void loadScript(const QString &scriptname);
|
||||||
QJsonArray getOpenedFiles();
|
|
||||||
|
|
||||||
/* Seek functions */
|
/* Seek functions */
|
||||||
void seek(QString thing);
|
void seek(QString thing);
|
||||||
|
Loading…
Reference in New Issue
Block a user