Fixes for debugging (#2727)

* Fix continue until main not being enabled
* Use Rizin API instead of commands
* Fix attaching to a process with no file opened
This commit is contained in:
GustavoLCR 2021-08-12 18:28:10 -03:00 committed by GitHub
parent f59797fb3d
commit 2d05ae2595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -1957,8 +1957,10 @@ void CutterCore::attachDebug(int pid)
offsetPriorDebugging = getOffset();
}
QString attach_command = currentlyOpenFile.isEmpty() ? "o" : "oodf";
// attach to process with dbg plugin
asyncCmd("e cfg.debug = true; oodf dbg://" + QString::number(pid), debugTask);
asyncCmd("e cfg.debug=true;" + attach_command + " dbg://" + QString::number(pid), debugTask);
emit debugTaskStateChanged();
connect(debugTask.data(), &RizinTask::finished, this, [this, pid]() {

View File

@ -249,10 +249,10 @@ DebugActions::DebugActions(QToolBar *toolBar, MainWindow *main) : QObject(main),
void DebugActions::setButtonVisibleIfMainExists()
{
// Use cmd because cmdRaw would not handle multiple commands concatenated
int mainExists = Core()->cmd("f?sym.main; ??").toInt();
RzCoreLocked core(Core()->core());
// if main is not a flag we hide the continue until main button
if (!mainExists) {
if (!rz_flag_get(Core()->core()->flags, "sym.main")
&& !rz_flag_get(Core()->core()->flags, "main")) {
actionContinueUntilMain->setVisible(false);
continueUntilButton->setDefaultAction(actionContinueUntilCall);
}
@ -273,8 +273,15 @@ void DebugActions::showDebugWarning()
void DebugActions::continueUntilMain()
{
QString mainAddr = Core()->cmdRaw("?v sym.main");
Core()->continueUntilDebug(mainAddr);
RzCoreLocked core(Core()->core());
RzFlagItem *main_flag = rz_flag_get(Core()->core()->flags, "sym.main");
if (!main_flag) {
main_flag = rz_flag_get(Core()->core()->flags, "main");
if (!main_flag) {
return;
}
}
Core()->continueUntilDebug(QString::number(main_flag->offset));
}
void DebugActions::attachRemoteDebugger()