mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-18 02:25:26 +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()
|
||||
{
|
||||
// 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 =
|
||||
|
@ -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<QString> CutterCore::getColorThemes()
|
||||
{
|
||||
QList<QString> r;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user