diff --git a/src/common/AnalTask.cpp b/src/common/AnalTask.cpp index 81cfecd7..7a9fda27 100644 --- a/src/common/AnalTask.cpp +++ b/src/common/AnalTask.cpp @@ -19,8 +19,9 @@ void AnalTask::interrupt() QString AnalTask::getTitle() { // If no file is loaded we consider it's Initial Analysis - QJsonArray openedFiles = Core()->getOpenedFiles(); - if (!openedFiles.size()) { + RzCoreLocked core(Core()); + RzList *descs = rz_id_storage_list(core->io->files); + if (rz_list_empty(descs)) { return tr("Initial Analysis"); } return tr("Analyzing Program"); @@ -38,8 +39,9 @@ void AnalTask::runTask() Core()->setConfig("bin.demangle", options.demangle); // Do not reload the file if already loaded - QJsonArray openedFiles = Core()->getOpenedFiles(); - if (!openedFiles.size() && options.filename.length()) { + RzCoreLocked core(Core()); + RzList *descs = rz_id_storage_list(core->io->files); + if (rz_list_empty(descs) && options.filename.length()) { log(tr("Loading the file...")); openFailed = false; bool fileLoaded = diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 4f21288e..8791250c 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -386,11 +386,12 @@ bool CutterCore::isRedirectableDebugee() } // We are only able to redirect locally debugged unix processes - QJsonArray openFilesArray = cmdj("oj").array(); - ; - for (QJsonValue value : openFilesArray) { - QJsonObject openFile = value.toObject(); - QString URI = openFile["uri"].toString(); + RzCoreLocked core(Core()); + RzList *descs = rz_id_storage_list(core->io->files); + RzListIter *it; + RzIODesc *desc; + CutterRzListForeach(descs, it, RzIODesc, desc) { + QString URI = QString(desc->uri); if (URI.contains("ptrace") | URI.contains("mach")) { return true; } @@ -1913,10 +1914,12 @@ void CutterCore::attachRemote(const QString &uri) debugTask.clear(); // Check if we actually connected bool connected = false; - QJsonArray openFilesArray = getOpenedFiles(); - for (QJsonValue value : openFilesArray) { - QJsonObject openFile = value.toObject(); - QString fileUri = openFile["uri"].toString(); + RzCoreLocked core(Core()); + RzList *descs = rz_id_storage_list(core->io->files); + RzListIter *it; + RzIODesc *desc; + CutterRzListForeach(descs, it, RzIODesc, desc) { + QString fileUri = QString(desc->uri); if (!fileUri.compare(uri)) { connected = true; } @@ -2023,13 +2026,14 @@ void CutterCore::stopDebug() } else { QString ptraceFiles = ""; // close ptrace file descriptors left open - QJsonArray openFilesArray = cmdj("oj").array(); - ; - for (QJsonValue value : openFilesArray) { - QJsonObject openFile = value.toObject(); - QString URI = openFile["uri"].toString(); + RzCoreLocked core(Core()); + RzList *descs = rz_id_storage_list(core->io->files); + RzListIter *it; + RzIODesc *desc; + CutterRzListForeach(descs, it, RzIODesc, desc) { + QString URI = QString(desc->uri); 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 @@ -4025,12 +4029,6 @@ QString CutterCore::getVersionInformation() return versionInfo; } -QJsonArray CutterCore::getOpenedFiles() -{ - QJsonDocument files = cmdj("oj"); - return files.array(); -} - QList CutterCore::getColorThemes() { QList r; diff --git a/src/core/Cutter.h b/src/core/Cutter.h index 375943d1..cd382444 100644 --- a/src/core/Cutter.h +++ b/src/core/Cutter.h @@ -278,7 +278,6 @@ public: bool tryFile(QString path, bool rw); bool mapFile(QString path, RVA mapaddr); void loadScript(const QString &scriptname); - QJsonArray getOpenedFiles(); /* Seek functions */ void seek(QString thing);