summaryrefslogtreecommitdiff
path: root/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/debugger/gdb/remotegdbserveradapter.cpp')
-rw-r--r--src/plugins/debugger/gdb/remotegdbserveradapter.cpp116
1 files changed, 56 insertions, 60 deletions
diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
index b5c7b72d88..137a41ed2d 100644
--- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
+++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
@@ -38,19 +38,20 @@
#include <debugger/debuggerstartparameters.h>
#include <debugger/debuggerstringutils.h>
+#include <coreplugin/messagebox.h>
+
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <QFileInfo>
-#include <QMessageBox>
+
+using namespace Utils;
namespace Debugger {
namespace Internal {
-#define CB(callback) \
- static_cast<GdbEngine::GdbCommandCallback>(&GdbRemoteServerEngine::callback), \
- STRINGIFY(callback)
+#define CB(callback) [this](const DebuggerResponse &r) { callback(r); }
///////////////////////////////////////////////////////////////////////
//
@@ -61,16 +62,17 @@ namespace Internal {
GdbRemoteServerEngine::GdbRemoteServerEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters), m_startAttempted(false)
{
- if (Utils::HostOsInfo::isWindowsHost())
+ if (HostOsInfo::isWindowsHost())
m_gdbProc->setUseCtrlCStub(startParameters.useCtrlCStub); // This is only set for QNX/BlackBerry
- connect(&m_uploadProc, SIGNAL(error(QProcess::ProcessError)),
- SLOT(uploadProcError(QProcess::ProcessError)));
- connect(&m_uploadProc, SIGNAL(readyReadStandardOutput()),
- SLOT(readUploadStandardOutput()));
- connect(&m_uploadProc, SIGNAL(readyReadStandardError()),
- SLOT(readUploadStandardError()));
- connect(&m_uploadProc, SIGNAL(finished(int)),
- SLOT(uploadProcFinished()));
+
+ connect(&m_uploadProc, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error),
+ this, &GdbRemoteServerEngine::uploadProcError);
+ connect(&m_uploadProc, &QProcess::readyReadStandardOutput,
+ this, &GdbRemoteServerEngine::readUploadStandardOutput);
+ connect(&m_uploadProc, &QProcess::readyReadStandardError,
+ this, &GdbRemoteServerEngine::readUploadStandardError);
+ connect(&m_uploadProc, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
+ this, &GdbRemoteServerEngine::uploadProcFinished);
}
void GdbRemoteServerEngine::setupEngine()
@@ -81,9 +83,9 @@ void GdbRemoteServerEngine::setupEngine()
// Provide script information about the environment
QString arglist;
- Utils::QtcProcess::addArg(&arglist, startParameters().serverStartScript);
- Utils::QtcProcess::addArg(&arglist, startParameters().executable);
- Utils::QtcProcess::addArg(&arglist, startParameters().remoteChannel);
+ QtcProcess::addArg(&arglist, startParameters().serverStartScript);
+ QtcProcess::addArg(&arglist, startParameters().executable);
+ QtcProcess::addArg(&arglist, startParameters().remoteChannel);
m_uploadProc.start(_("/bin/sh ") + arglist);
m_uploadProc.waitForStarted();
@@ -130,7 +132,7 @@ void GdbRemoteServerEngine::uploadProcError(QProcess::ProcessError error)
}
showMessage(msg, StatusBar);
- showMessageBox(QMessageBox::Critical, tr("Error"), msg);
+ Core::AsynchronousMessageBox::critical(tr("Error"), msg);
}
void GdbRemoteServerEngine::readUploadStandardOutput()
@@ -173,12 +175,12 @@ void GdbRemoteServerEngine::setupInferior()
//const QByteArray sysroot = sp.sysroot.toLocal8Bit();
//const QByteArray remoteArch = sp.remoteArchitecture.toLatin1();
- const QString args = isMasterEngine() ? startParameters().processArgs : masterEngine()->startParameters().processArgs;
+ const QString args = isMasterEngine() ? startParameters().processArgs
+ : masterEngine()->startParameters().processArgs;
// if (!remoteArch.isEmpty())
// postCommand("set architecture " + remoteArch);
- const QString solibSearchPath
- = sp.solibSearchPath.join(Utils::HostOsInfo::pathListSeparator());
+ const QString solibSearchPath = sp.solibSearchPath.join(HostOsInfo::pathListSeparator());
if (!solibSearchPath.isEmpty())
postCommand("set solib-search-path " + solibSearchPath.toLocal8Bit());
@@ -205,7 +207,7 @@ void GdbRemoteServerEngine::setupInferior()
// mi_execute_async_cli_command: Assertion `is_running (inferior_ptid)'
// failed.\nA problem internal to GDB has been detected,[...]
if (boolSetting(TargetAsync))
- postCommand("set target-async on", CB(handleSetTargetAsync));
+ postCommand("set target-async on", NoFlags, CB(handleSetTargetAsync));
if (executableFileName.isEmpty()) {
showMessage(tr("No symbol file given."), StatusBar);
@@ -215,21 +217,21 @@ void GdbRemoteServerEngine::setupInferior()
if (!executableFileName.isEmpty()) {
postCommand("-file-exec-and-symbols \"" + executableFileName.toLocal8Bit() + '"',
- CB(handleFileExecAndSymbols));
+ NoFlags, CB(handleFileExecAndSymbols));
}
}
-void GdbRemoteServerEngine::handleSetTargetAsync(const GdbResponse &response)
+void GdbRemoteServerEngine::handleSetTargetAsync(const DebuggerResponse &response)
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- if (response.resultClass == GdbResultError)
+ if (response.resultClass == ResultError)
qDebug() << "Adapter too old: does not support asynchronous mode.";
}
-void GdbRemoteServerEngine::handleFileExecAndSymbols(const GdbResponse &response)
+void GdbRemoteServerEngine::handleFileExecAndSymbols(const DebuggerResponse &response)
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- if (response.resultClass == GdbResultDone) {
+ if (response.resultClass == ResultDone) {
callTargetRemote();
} else {
QByteArray reason = response.data["msg"].data();
@@ -265,17 +267,17 @@ void GdbRemoteServerEngine::callTargetRemote()
}
if (m_isQnxGdb)
- postCommand("target qnx " + channel, CB(handleTargetQnx));
+ postCommand("target qnx " + channel, NoFlags, CB(handleTargetQnx));
else if (startParameters().multiProcess)
- postCommand("target extended-remote " + channel, CB(handleTargetExtendedRemote));
+ postCommand("target extended-remote " + channel, NoFlags, CB(handleTargetExtendedRemote));
else
- postCommand("target remote " + channel, CB(handleTargetRemote), 10);
+ postCommand("target remote " + channel, NoFlags, CB(handleTargetRemote));
}
-void GdbRemoteServerEngine::handleTargetRemote(const GdbResponse &response)
+void GdbRemoteServerEngine::handleTargetRemote(const DebuggerResponse &response)
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- if (response.resultClass == GdbResultDone) {
+ if (response.resultClass == ResultDone) {
// gdb server will stop the remote application itself.
showMessage(_("INFERIOR STARTED"));
showMessage(msgAttachedToStoppedInferior(), StatusBar);
@@ -293,10 +295,10 @@ void GdbRemoteServerEngine::handleTargetRemote(const GdbResponse &response)
}
}
-void GdbRemoteServerEngine::handleTargetExtendedRemote(const GdbResponse &response)
+void GdbRemoteServerEngine::handleTargetExtendedRemote(const DebuggerResponse &response)
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- if (response.resultClass == GdbResultDone) {
+ if (response.resultClass == ResultDone) {
showMessage(_("ATTACHED TO GDB SERVER STARTED"));
showMessage(msgAttachedToStoppedInferior(), StatusBar);
QString postAttachCommands = stringSetting(GdbPostAttachCommands);
@@ -307,10 +309,10 @@ void GdbRemoteServerEngine::handleTargetExtendedRemote(const GdbResponse &respon
if (startParameters().attachPID > 0) { // attach to pid if valid
// gdb server will stop the remote application itself.
postCommand("attach " + QByteArray::number(startParameters().attachPID),
- CB(handleTargetExtendedAttach));
+ NoFlags, CB(handleTargetExtendedAttach));
} else {
postCommand("-gdb-set remote exec-file " + startParameters().remoteExecutable.toLatin1(),
- CB(handleTargetExtendedAttach));
+ NoFlags, CB(handleTargetExtendedAttach));
}
} else {
QString msg = msgConnectRemoteServerFailed(
@@ -319,10 +321,10 @@ void GdbRemoteServerEngine::handleTargetExtendedRemote(const GdbResponse &respon
}
}
-void GdbRemoteServerEngine::handleTargetExtendedAttach(const GdbResponse &response)
+void GdbRemoteServerEngine::handleTargetExtendedAttach(const DebuggerResponse &response)
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- if (response.resultClass == GdbResultDone) {
+ if (response.resultClass == ResultDone) {
// gdb server will stop the remote application itself.
handleInferiorPrepared();
} else {
@@ -332,17 +334,11 @@ void GdbRemoteServerEngine::handleTargetExtendedAttach(const GdbResponse &respon
}
}
-void GdbRemoteServerEngine::notifyInferiorSetupOk()
-{
- emit aboutToNotifyInferiorSetupOk();
- GdbEngine::notifyInferiorSetupOk();
-}
-
-void GdbRemoteServerEngine::handleTargetQnx(const GdbResponse &response)
+void GdbRemoteServerEngine::handleTargetQnx(const DebuggerResponse &response)
{
QTC_ASSERT(m_isQnxGdb, qDebug() << m_isQnxGdb);
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- if (response.resultClass == GdbResultDone) {
+ if (response.resultClass == ResultDone) {
// gdb server will stop the remote application itself.
showMessage(_("INFERIOR STARTED"));
showMessage(msgAttachedToStoppedInferior(), StatusBar);
@@ -350,9 +346,9 @@ void GdbRemoteServerEngine::handleTargetQnx(const GdbResponse &response)
const qint64 pid = isMasterEngine() ? startParameters().attachPID : masterEngine()->startParameters().attachPID;
const QString remoteExecutable = isMasterEngine() ? startParameters().remoteExecutable : masterEngine()->startParameters().remoteExecutable;
if (pid > -1)
- postCommand("attach " + QByteArray::number(pid), CB(handleAttach));
+ postCommand("attach " + QByteArray::number(pid), NoFlags, CB(handleAttach));
else if (!remoteExecutable.isEmpty())
- postCommand("set nto-executable " + remoteExecutable.toLatin1(), CB(handleSetNtoExecutable));
+ postCommand("set nto-executable " + remoteExecutable.toLatin1(), NoFlags, CB(handleSetNtoExecutable));
else
handleInferiorPrepared();
} else {
@@ -363,18 +359,18 @@ void GdbRemoteServerEngine::handleTargetQnx(const GdbResponse &response)
}
}
-void GdbRemoteServerEngine::handleAttach(const GdbResponse &response)
+void GdbRemoteServerEngine::handleAttach(const DebuggerResponse &response)
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
switch (response.resultClass) {
- case GdbResultDone:
- case GdbResultRunning: {
+ case ResultDone:
+ case ResultRunning: {
showMessage(_("INFERIOR ATTACHED"));
showMessage(msgAttachedToStoppedInferior(), StatusBar);
handleInferiorPrepared();
break;
}
- case GdbResultError:
+ case ResultError:
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
notifyInferiorSetupFailed(msgPtraceError(startParameters().startMode));
break;
@@ -386,18 +382,18 @@ void GdbRemoteServerEngine::handleAttach(const GdbResponse &response)
}
}
-void GdbRemoteServerEngine::handleSetNtoExecutable(const GdbResponse &response)
+void GdbRemoteServerEngine::handleSetNtoExecutable(const DebuggerResponse &response)
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
switch (response.resultClass) {
- case GdbResultDone:
- case GdbResultRunning: {
+ case ResultDone:
+ case ResultRunning: {
showMessage(_("EXECUTABLE SET"));
showMessage(msgAttachedToStoppedInferior(), StatusBar);
handleInferiorPrepared();
break;
}
- case GdbResultError:
+ case ResultError:
default:
QString msg = QString::fromLocal8Bit(response.data["msg"].data());
notifyInferiorSetupFailed(msg);
@@ -418,10 +414,10 @@ void GdbRemoteServerEngine::runEngine()
}
}
-void GdbRemoteServerEngine::handleExecRun(const GdbResponse &response)
+void GdbRemoteServerEngine::handleExecRun(const DebuggerResponse &response)
{
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
- if (response.resultClass == GdbResultRunning) {
+ if (response.resultClass == ResultRunning) {
notifyEngineRunAndInferiorRunOk();
showMessage(_("INFERIOR STARTED"));
showMessage(msgInferiorSetupOk(), StatusBar);
@@ -438,7 +434,7 @@ void GdbRemoteServerEngine::interruptInferior2()
if (boolSetting(TargetAsync)) {
postCommand("-exec-interrupt", GdbEngine::Immediate,
CB(handleInterruptInferior));
- } else if (m_isQnxGdb && Utils::HostOsInfo::isWindowsHost()) {
+ } else if (m_isQnxGdb && HostOsInfo::isWindowsHost()) {
m_gdbProc->winInterruptByCtrlC();
} else {
bool ok = m_gdbProc->interrupt();
@@ -451,9 +447,9 @@ void GdbRemoteServerEngine::interruptInferior2()
}
}
-void GdbRemoteServerEngine::handleInterruptInferior(const GdbResponse &response)
+void GdbRemoteServerEngine::handleInterruptInferior(const DebuggerResponse &response)
{
- if (response.resultClass == GdbResultDone) {
+ if (response.resultClass == ResultDone) {
// The gdb server will trigger extra output that we will pick up
// to do a proper state transition.
} else {