forked from qt-creator/qt-creator
centralize gdb command result class checking
each command can have only one of two legitimate responses: "error" or - depending on the command, and thus declared via a flag - "done" or "running". this is way nicer than sprinkling the code with else-ifs (where elses are sufficient) and asserts all over the place - and silently failing in release builds.
This commit is contained in:
@@ -109,7 +109,7 @@ void AttachGdbAdapter::handleAttach(const GdbResponse &response)
|
|||||||
debugMessage(_("INFERIOR STARTED"));
|
debugMessage(_("INFERIOR STARTED"));
|
||||||
showStatusMessage(msgAttachedToStoppedInferior());
|
showStatusMessage(msgAttachedToStoppedInferior());
|
||||||
m_engine->updateAll();
|
m_engine->updateAll();
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = __(response.data.findChild("msg").data());
|
QString msg = __(response.data.findChild("msg").data());
|
||||||
setState(InferiorStartFailed);
|
setState(InferiorStartFailed);
|
||||||
emit inferiorStartFailed(msg);
|
emit inferiorStartFailed(msg);
|
||||||
@@ -154,7 +154,7 @@ void AttachGdbAdapter::handleDetach(const GdbResponse &response)
|
|||||||
setState(InferiorShutDown);
|
setState(InferiorShutDown);
|
||||||
emit inferiorShutDown();
|
emit inferiorShutDown();
|
||||||
shutdown(); // re-iterate...
|
shutdown(); // re-iterate...
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
const QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
|
const QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
|
||||||
setState(InferiorShutdownFailed);
|
setState(InferiorShutdownFailed);
|
||||||
emit inferiorShutdownFailed(msg);
|
emit inferiorShutdownFailed(msg);
|
||||||
@@ -165,7 +165,7 @@ void AttachGdbAdapter::handleExit(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
// don't set state here, this will be handled in handleGdbFinished()
|
// don't set state here, this will be handled in handleGdbFinished()
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
||||||
emit adapterShutdownFailed(msg);
|
emit adapterShutdownFailed(msg);
|
||||||
}
|
}
|
||||||
|
@@ -133,7 +133,6 @@ void CoreGdbAdapter::handleTargetCore1(const GdbResponse &response)
|
|||||||
m_engine->postCommand(_("detach"), CB(handleDetach1));
|
m_engine->postCommand(_("detach"), CB(handleDetach1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
|
||||||
const QByteArray msg = response.data.findChild("msg").data();
|
const QByteArray msg = response.data.findChild("msg").data();
|
||||||
setState(InferiorStartFailed);
|
setState(InferiorStartFailed);
|
||||||
emit inferiorStartFailed(msg);
|
emit inferiorStartFailed(msg);
|
||||||
@@ -149,7 +148,6 @@ void CoreGdbAdapter::handleDetach1(const GdbResponse &response)
|
|||||||
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"")
|
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"")
|
||||||
.arg(fi.absoluteFilePath()), CB(handleFileExecAndSymbols));
|
.arg(fi.absoluteFilePath()), CB(handleFileExecAndSymbols));
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
|
||||||
const QByteArray msg = response.data.findChild("msg").data();
|
const QByteArray msg = response.data.findChild("msg").data();
|
||||||
setState(InferiorStartFailed);
|
setState(InferiorStartFailed);
|
||||||
emit inferiorStartFailed(msg);
|
emit inferiorStartFailed(msg);
|
||||||
@@ -165,7 +163,7 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
QFileInfo fi(startParameters().coreFile);
|
QFileInfo fi(startParameters().coreFile);
|
||||||
QString coreName = fi.absoluteFilePath();
|
QString coreName = fi.absoluteFilePath();
|
||||||
m_engine->postCommand(_("target core ") + coreName, CB(handleTargetCore2));
|
m_engine->postCommand(_("target core ") + coreName, CB(handleTargetCore2));
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = tr("Symbols not found in \"%1\" failed:\n%2")
|
QString msg = tr("Symbols not found in \"%1\" failed:\n%2")
|
||||||
.arg(__(response.data.findChild("msg").data()));
|
.arg(__(response.data.findChild("msg").data()));
|
||||||
setState(InferiorUnrunnable);
|
setState(InferiorUnrunnable);
|
||||||
@@ -182,7 +180,7 @@ void CoreGdbAdapter::handleTargetCore2(const GdbResponse &response)
|
|||||||
showStatusMessage(tr("Attached to core."));
|
showStatusMessage(tr("Attached to core."));
|
||||||
setState(InferiorUnrunnable);
|
setState(InferiorUnrunnable);
|
||||||
m_engine->updateAll();
|
m_engine->updateAll();
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = tr("Attach to core \"%1\" failed:\n%2")
|
QString msg = tr("Attach to core \"%1\" failed:\n%2")
|
||||||
.arg(__(response.data.findChild("msg").data()));
|
.arg(__(response.data.findChild("msg").data()));
|
||||||
setState(InferiorUnrunnable);
|
setState(InferiorUnrunnable);
|
||||||
@@ -220,7 +218,7 @@ void CoreGdbAdapter::handleExit(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
// don't set state here, this will be handled in handleGdbFinished()
|
// don't set state here, this will be handled in handleGdbFinished()
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
||||||
emit adapterShutdownFailed(msg);
|
emit adapterShutdownFailed(msg);
|
||||||
}
|
}
|
||||||
|
@@ -811,10 +811,17 @@ void GdbEngine::handleResultRecord(const GdbResponse &response)
|
|||||||
GdbResponse responseWithCookie = response;
|
GdbResponse responseWithCookie = response;
|
||||||
responseWithCookie.cookie = cmd.cookie;
|
responseWithCookie.cookie = cmd.cookie;
|
||||||
|
|
||||||
if (cmd.callback)
|
if (response.resultClass != GdbResultError &&
|
||||||
(this->*cmd.callback)(responseWithCookie);
|
response.resultClass != ((cmd.flags & RunRequest) ? GdbResultRunning : GdbResultDone)) {
|
||||||
if (cmd.adapterCallback)
|
debugMessage(_("UNEXPECTED RESPONSE %1 TO COMMAND %2")
|
||||||
(m_gdbAdapter->*cmd.adapterCallback)(responseWithCookie);
|
.arg(_(GdbResponse::stringFromResultClass(response.resultClass)))
|
||||||
|
.arg(cmd.command));
|
||||||
|
} else {
|
||||||
|
if (cmd.callback)
|
||||||
|
(this->*cmd.callback)(responseWithCookie);
|
||||||
|
else if (cmd.adapterCallback)
|
||||||
|
(m_gdbAdapter->*cmd.adapterCallback)(responseWithCookie);
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd.flags & RebuildModel) {
|
if (cmd.flags & RebuildModel) {
|
||||||
--m_pendingRequests;
|
--m_pendingRequests;
|
||||||
@@ -1173,7 +1180,7 @@ void GdbEngine::handleStop1(const GdbMi &data)
|
|||||||
GdbMi frameData = data.findChild("frame");
|
GdbMi frameData = data.findChild("frame");
|
||||||
if (frameData.findChild("func").data() == "_start"
|
if (frameData.findChild("func").data() == "_start"
|
||||||
&& frameData.findChild("from").data() == "/lib/ld-linux.so.2") {
|
&& frameData.findChild("from").data() == "/lib/ld-linux.so.2") {
|
||||||
postCommand(_("-exec-continue"), CB(handleExecContinue));
|
postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1302,7 +1309,7 @@ void GdbEngine::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
//m_breakHandler->clearBreakMarkers();
|
//m_breakHandler->clearBreakMarkers();
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = __(response.data.findChild("msg").data());
|
QString msg = __(response.data.findChild("msg").data());
|
||||||
showMessageBox(QMessageBox::Critical, tr("Starting executable failed"), msg);
|
showMessageBox(QMessageBox::Critical, tr("Starting executable failed"), msg);
|
||||||
QTC_ASSERT(state() == InferiorRunning, /**/);
|
QTC_ASSERT(state() == InferiorRunning, /**/);
|
||||||
@@ -1316,7 +1323,7 @@ void GdbEngine::handleExecContinue(const GdbResponse &response)
|
|||||||
if (response.resultClass == GdbResultRunning) {
|
if (response.resultClass == GdbResultRunning) {
|
||||||
// The "running" state is picked up in handleResponse()
|
// The "running" state is picked up in handleResponse()
|
||||||
QTC_ASSERT(state() == InferiorRunning, /**/);
|
QTC_ASSERT(state() == InferiorRunning, /**/);
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QTC_ASSERT(state() == InferiorRunningRequested, /**/);
|
QTC_ASSERT(state() == InferiorRunningRequested, /**/);
|
||||||
QByteArray msg = response.data.findChild("msg").data();
|
QByteArray msg = response.data.findChild("msg").data();
|
||||||
if (msg.startsWith("Cannot find bounds of current function")) {
|
if (msg.startsWith("Cannot find bounds of current function")) {
|
||||||
@@ -1331,8 +1338,6 @@ void GdbEngine::handleExecContinue(const GdbResponse &response)
|
|||||||
QTC_ASSERT(state() == InferiorRunning, /**/);
|
QTC_ASSERT(state() == InferiorRunning, /**/);
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
QTC_ASSERT(false, /**/);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1474,7 +1479,7 @@ void GdbEngine::continueInferiorInternal()
|
|||||||
m_manager->resetLocation();
|
m_manager->resetLocation();
|
||||||
setTokenBarrier();
|
setTokenBarrier();
|
||||||
setState(InferiorRunningRequested);
|
setState(InferiorRunningRequested);
|
||||||
postCommand(_("-exec-continue"), CB(handleExecContinue));
|
postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::autoContinueInferior()
|
void GdbEngine::autoContinueInferior()
|
||||||
@@ -1496,9 +1501,9 @@ void GdbEngine::stepExec()
|
|||||||
setState(InferiorRunningRequested);
|
setState(InferiorRunningRequested);
|
||||||
showStatusMessage(tr("Step requested..."), 5000);
|
showStatusMessage(tr("Step requested..."), 5000);
|
||||||
if (manager()->isReverseDebugging())
|
if (manager()->isReverseDebugging())
|
||||||
postCommand(_("-reverse-step"), CB(handleExecContinue));
|
postCommand(_("-reverse-step"), RunRequest, CB(handleExecContinue));
|
||||||
else
|
else
|
||||||
postCommand(_("-exec-step"), CB(handleExecContinue));
|
postCommand(_("-exec-step"), RunRequest, CB(handleExecContinue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::stepIExec()
|
void GdbEngine::stepIExec()
|
||||||
@@ -1508,9 +1513,9 @@ void GdbEngine::stepIExec()
|
|||||||
setState(InferiorRunningRequested);
|
setState(InferiorRunningRequested);
|
||||||
showStatusMessage(tr("Step by instruction requested..."), 5000);
|
showStatusMessage(tr("Step by instruction requested..."), 5000);
|
||||||
if (manager()->isReverseDebugging())
|
if (manager()->isReverseDebugging())
|
||||||
postCommand(_("-reverse-stepi"), CB(handleExecContinue));
|
postCommand(_("-reverse-stepi"), RunRequest, CB(handleExecContinue));
|
||||||
else
|
else
|
||||||
postCommand(_("-exec-step-instruction"), CB(handleExecContinue));
|
postCommand(_("-exec-step-instruction"), RunRequest, CB(handleExecContinue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::stepOutExec()
|
void GdbEngine::stepOutExec()
|
||||||
@@ -1519,7 +1524,7 @@ void GdbEngine::stepOutExec()
|
|||||||
setTokenBarrier();
|
setTokenBarrier();
|
||||||
setState(InferiorRunningRequested);
|
setState(InferiorRunningRequested);
|
||||||
showStatusMessage(tr("Finish function requested..."), 5000);
|
showStatusMessage(tr("Finish function requested..."), 5000);
|
||||||
postCommand(_("-exec-finish"), CB(handleExecContinue));
|
postCommand(_("-exec-finish"), RunRequest, CB(handleExecContinue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::nextExec()
|
void GdbEngine::nextExec()
|
||||||
@@ -1529,14 +1534,14 @@ void GdbEngine::nextExec()
|
|||||||
setState(InferiorRunningRequested);
|
setState(InferiorRunningRequested);
|
||||||
showStatusMessage(tr("Step next requested..."), 5000);
|
showStatusMessage(tr("Step next requested..."), 5000);
|
||||||
if (manager()->isReverseDebugging())
|
if (manager()->isReverseDebugging())
|
||||||
postCommand(_("-reverse-next"), CB(handleExecContinue));
|
postCommand(_("-reverse-next"), RunRequest, CB(handleExecContinue));
|
||||||
else {
|
else {
|
||||||
#if 1
|
#if 1
|
||||||
postCommand(_("-exec-next"), CB(handleExecContinue));
|
postCommand(_("-exec-next"), RunRequest, CB(handleExecContinue));
|
||||||
#else
|
#else
|
||||||
postCommand(_("tbreak %1:%2").arg(QFileInfo(lastFile).fileName())
|
postCommand(_("tbreak %1:%2").arg(QFileInfo(lastFile).fileName())
|
||||||
.arg(lastLine + 1));
|
.arg(lastLine + 1));
|
||||||
postCommand(_("-exec-continue"), CB(handleExecContinue));
|
postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1548,9 +1553,9 @@ void GdbEngine::nextIExec()
|
|||||||
setState(InferiorRunningRequested);
|
setState(InferiorRunningRequested);
|
||||||
showStatusMessage(tr("Step next instruction requested..."), 5000);
|
showStatusMessage(tr("Step next instruction requested..."), 5000);
|
||||||
if (manager()->isReverseDebugging())
|
if (manager()->isReverseDebugging())
|
||||||
postCommand(_("-reverse-nexti"), CB(handleExecContinue));
|
postCommand(_("-reverse-nexti"), RunRequest, CB(handleExecContinue));
|
||||||
else
|
else
|
||||||
postCommand(_("-exec-next-instruction"), CB(handleExecContinue));
|
postCommand(_("-exec-next-instruction"), RunRequest, CB(handleExecContinue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbEngine::runToLineExec(const QString &fileName, int lineNumber)
|
void GdbEngine::runToLineExec(const QString &fileName, int lineNumber)
|
||||||
@@ -1571,7 +1576,7 @@ void GdbEngine::runToFunctionExec(const QString &functionName)
|
|||||||
showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000);
|
showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000);
|
||||||
// that should be "^running". We need to handle the resulting
|
// that should be "^running". We need to handle the resulting
|
||||||
// "Stopped"
|
// "Stopped"
|
||||||
postCommand(_("-exec-continue"), CB(handleExecContinue));
|
postCommand(_("-exec-continue"), RunRequest, CB(handleExecContinue));
|
||||||
//postCommand(_("-exec-continue"), handleExecRunToFunction);
|
//postCommand(_("-exec-continue"), handleExecRunToFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1851,7 +1856,7 @@ void GdbEngine::handleBreakCondition(const GdbResponse &response)
|
|||||||
BreakpointData *data = handler->at(index);
|
BreakpointData *data = handler->at(index);
|
||||||
//qDebug() << "HANDLE BREAK CONDITION" << index << data->condition;
|
//qDebug() << "HANDLE BREAK CONDITION" << index << data->condition;
|
||||||
data->bpCondition = data->condition;
|
data->bpCondition = data->condition;
|
||||||
} else { // GdbResultError
|
} else {
|
||||||
QByteArray msg = response.data.findChild("msg").data();
|
QByteArray msg = response.data.findChild("msg").data();
|
||||||
// happens on Mac
|
// happens on Mac
|
||||||
if (1 || msg.startsWith("Error parsing breakpoint condition. "
|
if (1 || msg.startsWith("Error parsing breakpoint condition. "
|
||||||
@@ -1877,7 +1882,7 @@ void GdbEngine::handleBreakInsert(const GdbResponse &response)
|
|||||||
//#endif
|
//#endif
|
||||||
attemptBreakpointSynchronization();
|
attemptBreakpointSynchronization();
|
||||||
handler->updateMarkers();
|
handler->updateMarkers();
|
||||||
} else { // GdbResultError
|
} else {
|
||||||
const BreakpointData *data = handler->at(index);
|
const BreakpointData *data = handler->at(index);
|
||||||
// Note that it is perfectly correct that the file name is put
|
// Note that it is perfectly correct that the file name is put
|
||||||
// in quotes but not escaped. GDB simply is like that.
|
// in quotes but not escaped. GDB simply is like that.
|
||||||
@@ -1967,7 +1972,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response)
|
|||||||
BreakpointData *data = handler->at(index);
|
BreakpointData *data = handler->at(index);
|
||||||
GdbMi bkpt = response.data.findChild("bkpt");
|
GdbMi bkpt = response.data.findChild("bkpt");
|
||||||
breakpointDataFromOutput(data, bkpt);
|
breakpointDataFromOutput(data, bkpt);
|
||||||
} else { // GdbResultError
|
} else {
|
||||||
qDebug() << "INSERTING BREAKPOINT WITH BASE NAME FAILED. GIVING UP";
|
qDebug() << "INSERTING BREAKPOINT WITH BASE NAME FAILED. GIVING UP";
|
||||||
BreakpointData *data = handler->at(index);
|
BreakpointData *data = handler->at(index);
|
||||||
data->bpNumber = _("<unavailable>");
|
data->bpNumber = _("<unavailable>");
|
||||||
@@ -3128,7 +3133,7 @@ void GdbEngine::handleVarCreate(const GdbResponse &response)
|
|||||||
// data.setValue(QString());
|
// data.setValue(QString());
|
||||||
insertData(data);
|
insertData(data);
|
||||||
}
|
}
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data()));
|
data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data()));
|
||||||
if (data.isWatcher()) {
|
if (data.isWatcher()) {
|
||||||
data.value = strNotInScope;
|
data.value = strNotInScope;
|
||||||
@@ -3151,7 +3156,7 @@ void GdbEngine::handleEvaluateExpression(const GdbResponse &response)
|
|||||||
// data.name = response.data.findChild("value").data();
|
// data.name = response.data.findChild("value").data();
|
||||||
//else
|
//else
|
||||||
setWatchDataValue(data, response.data.findChild("value"));
|
setWatchDataValue(data, response.data.findChild("value"));
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data()));
|
data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data()));
|
||||||
}
|
}
|
||||||
//qDebug() << "HANDLE EVALUATE EXPRESSION:" << data.toString();
|
//qDebug() << "HANDLE EVALUATE EXPRESSION:" << data.toString();
|
||||||
@@ -3163,7 +3168,7 @@ void GdbEngine::handleDebuggingHelperSetup(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
//qDebug() << "CUSTOM SETUP RESULT:" << response.toString();
|
//qDebug() << "CUSTOM SETUP RESULT:" << response.toString();
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data());
|
QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data());
|
||||||
//qDebug() << "CUSTOM DUMPER SETUP ERROR MESSAGE:" << msg;
|
//qDebug() << "CUSTOM DUMPER SETUP ERROR MESSAGE:" << msg;
|
||||||
showStatusMessage(tr("Custom dumper setup: %1").arg(msg), 10000);
|
showStatusMessage(tr("Custom dumper setup: %1").arg(msg), 10000);
|
||||||
@@ -3176,7 +3181,7 @@ void GdbEngine::handleDebuggingHelperValue1(const GdbResponse &response)
|
|||||||
QTC_ASSERT(data.isValid(), return);
|
QTC_ASSERT(data.isValid(), return);
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
// ignore this case, data will follow
|
// ignore this case, data will follow
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data());
|
QString msg = QString::fromLocal8Bit(response.data.findChild("msg").data());
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
// Make debugging of dumpers easier
|
// Make debugging of dumpers easier
|
||||||
@@ -3347,7 +3352,7 @@ void GdbEngine::handleDebuggingHelperValue3(const GdbResponse &response)
|
|||||||
data.setAllUnneeded();
|
data.setAllUnneeded();
|
||||||
insertData(data);
|
insertData(data);
|
||||||
}
|
}
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
WatchData data = response.cookie.value<WatchData>();
|
WatchData data = response.cookie.value<WatchData>();
|
||||||
data.setError(strNotInScope);
|
data.setError(strNotInScope);
|
||||||
data.setAllUnneeded();
|
data.setAllUnneeded();
|
||||||
@@ -3460,7 +3465,7 @@ void GdbEngine::handleStackListArguments(const GdbResponse &response)
|
|||||||
const GdbMi frame = list.findChild("frame");
|
const GdbMi frame = list.findChild("frame");
|
||||||
const GdbMi args = frame.findChild("args");
|
const GdbMi args = frame.findChild("args");
|
||||||
m_currentFunctionArgs = args.children();
|
m_currentFunctionArgs = args.children();
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
qDebug() << "FIXME: GdbEngine::handleStackListArguments: should not happen"
|
qDebug() << "FIXME: GdbEngine::handleStackListArguments: should not happen"
|
||||||
<< response.toString();
|
<< response.toString();
|
||||||
}
|
}
|
||||||
@@ -3705,10 +3710,8 @@ void GdbEngine::handleVarListChildren(const GdbResponse &response)
|
|||||||
// this skips the spurious "public", "private" etc levels
|
// this skips the spurious "public", "private" etc levels
|
||||||
// gdb produces
|
// gdb produces
|
||||||
}
|
}
|
||||||
} else if (response.resultClass == GdbResultError) {
|
|
||||||
data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data()));
|
|
||||||
} else {
|
} else {
|
||||||
data.setError(tr("Unknown error: ") + QString::fromLocal8Bit(response.toString()));
|
data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4024,7 +4027,7 @@ void GdbEngine::handleFetchDisassemblerByLine(const GdbResponse &response)
|
|||||||
fetchDisassemblerByAddress(ac.agent, true);
|
fetchDisassemblerByAddress(ac.agent, true);
|
||||||
else
|
else
|
||||||
ac.agent->setContents(parseDisassembler(lines));
|
ac.agent->setContents(parseDisassembler(lines));
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
// 536^error,msg="mi_cmd_disassemble: Invalid line number"
|
// 536^error,msg="mi_cmd_disassemble: Invalid line number"
|
||||||
QByteArray msg = response.data.findChild("msg").data();
|
QByteArray msg = response.data.findChild("msg").data();
|
||||||
if (msg == "mi_cmd_disassemble: Invalid line number")
|
if (msg == "mi_cmd_disassemble: Invalid line number")
|
||||||
|
@@ -176,7 +176,8 @@ public: // otherwise the Qt flag macros are unhappy
|
|||||||
Discardable = 2,
|
Discardable = 2,
|
||||||
RebuildModel = 4,
|
RebuildModel = 4,
|
||||||
WatchUpdate = Discardable | RebuildModel,
|
WatchUpdate = Discardable | RebuildModel,
|
||||||
EmbedToken = 8
|
EmbedToken = 8,
|
||||||
|
RunRequest = 16
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(GdbCommandFlags, GdbCommandFlag)
|
Q_DECLARE_FLAGS(GdbCommandFlags, GdbCommandFlag)
|
||||||
|
|
||||||
|
@@ -362,7 +362,7 @@ GdbMi GdbMi::findChild(const char *name) const
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
QByteArray stringFromResultClass(GdbResultClass resultClass)
|
QByteArray GdbResponse::stringFromResultClass(GdbResultClass resultClass)
|
||||||
{
|
{
|
||||||
switch (resultClass) {
|
switch (resultClass) {
|
||||||
case GdbResultDone: return "done";
|
case GdbResultDone: return "done";
|
||||||
|
@@ -160,6 +160,7 @@ class GdbResponse
|
|||||||
public:
|
public:
|
||||||
GdbResponse() : token(-1), resultClass(GdbResultUnknown) {}
|
GdbResponse() : token(-1), resultClass(GdbResultUnknown) {}
|
||||||
QByteArray toString() const;
|
QByteArray toString() const;
|
||||||
|
static QByteArray stringFromResultClass(GdbResultClass resultClass);
|
||||||
|
|
||||||
int token;
|
int token;
|
||||||
GdbResultClass resultClass;
|
GdbResultClass resultClass;
|
||||||
|
@@ -122,7 +122,7 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
//m_breakHandler->clearBreakMarkers();
|
//m_breakHandler->clearBreakMarkers();
|
||||||
setState(InferiorPrepared);
|
setState(InferiorPrepared);
|
||||||
emit inferiorPrepared();
|
emit inferiorPrepared();
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = tr("Starting executable failed:\n") +
|
QString msg = tr("Starting executable failed:\n") +
|
||||||
__(response.data.findChild("msg").data());
|
__(response.data.findChild("msg").data());
|
||||||
setState(InferiorPreparationFailed);
|
setState(InferiorPreparationFailed);
|
||||||
@@ -138,7 +138,6 @@ void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
|
|||||||
showStatusMessage(msgInferiorStarted());
|
showStatusMessage(msgInferiorStarted());
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
|
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
|
||||||
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
|
||||||
const QByteArray &msg = response.data.findChild("msg").data();
|
const QByteArray &msg = response.data.findChild("msg").data();
|
||||||
//QTC_ASSERT(status() == InferiorRunning, /**/);
|
//QTC_ASSERT(status() == InferiorRunning, /**/);
|
||||||
//interruptInferior();
|
//interruptInferior();
|
||||||
@@ -151,7 +150,7 @@ void PlainGdbAdapter::startInferior()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
setState(InferiorRunningRequested);
|
setState(InferiorRunningRequested);
|
||||||
m_engine->postCommand(_("-exec-run"), CB(handleExecRun));
|
m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlainGdbAdapter::interruptInferior()
|
void PlainGdbAdapter::interruptInferior()
|
||||||
@@ -218,7 +217,7 @@ void PlainGdbAdapter::handleKill(const GdbResponse &response)
|
|||||||
setState(InferiorShutDown);
|
setState(InferiorShutDown);
|
||||||
emit inferiorShutDown();
|
emit inferiorShutDown();
|
||||||
shutdown(); // re-iterate...
|
shutdown(); // re-iterate...
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
const QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
|
const QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
|
||||||
setState(InferiorShutdownFailed);
|
setState(InferiorShutdownFailed);
|
||||||
emit inferiorShutdownFailed(msg);
|
emit inferiorShutdownFailed(msg);
|
||||||
@@ -229,7 +228,7 @@ void PlainGdbAdapter::handleExit(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
// don't set state here, this will be handled in handleGdbFinished()
|
// don't set state here, this will be handled in handleGdbFinished()
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
||||||
emit adapterShutdownFailed(msg);
|
emit adapterShutdownFailed(msg);
|
||||||
}
|
}
|
||||||
|
@@ -184,7 +184,7 @@ void RemoteGdbAdapter::handleSetTargetAsync(const GdbResponse &response)
|
|||||||
QString fileName = fi.absoluteFilePath();
|
QString fileName = fi.absoluteFilePath();
|
||||||
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName),
|
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName),
|
||||||
CB(handleFileExecAndSymbols));
|
CB(handleFileExecAndSymbols));
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = tr("Adapter too old: does not support asynchronous mode.");
|
QString msg = tr("Adapter too old: does not support asynchronous mode.");
|
||||||
setState(InferiorPreparationFailed);
|
setState(InferiorPreparationFailed);
|
||||||
emit inferiorPreparationFailed(msg);
|
emit inferiorPreparationFailed(msg);
|
||||||
@@ -198,7 +198,7 @@ void RemoteGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
//m_breakHandler->clearBreakMarkers();
|
//m_breakHandler->clearBreakMarkers();
|
||||||
m_engine->setState(InferiorPrepared);
|
m_engine->setState(InferiorPrepared);
|
||||||
emit inferiorPrepared();
|
emit inferiorPrepared();
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = tr("Starting remote executable failed:\n");
|
QString msg = tr("Starting remote executable failed:\n");
|
||||||
msg += __(response.data.findChild("msg").data());
|
msg += __(response.data.findChild("msg").data());
|
||||||
setState(InferiorPreparationFailed);
|
setState(InferiorPreparationFailed);
|
||||||
@@ -215,7 +215,7 @@ void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
|||||||
showStatusMessage(msgAttachedToStoppedInferior());
|
showStatusMessage(msgAttachedToStoppedInferior());
|
||||||
setState(InferiorStopped);
|
setState(InferiorStopped);
|
||||||
m_engine->continueInferior();
|
m_engine->continueInferior();
|
||||||
} else if (record.resultClass == GdbResultError) {
|
} else {
|
||||||
// 16^error,msg="hd:5555: Connection timed out."
|
// 16^error,msg="hd:5555: Connection timed out."
|
||||||
QString msg = msgConnectRemoteServerFailed(__(record.data.findChild("msg").data()));
|
QString msg = msgConnectRemoteServerFailed(__(record.data.findChild("msg").data()));
|
||||||
setState(InferiorPreparationFailed);
|
setState(InferiorPreparationFailed);
|
||||||
@@ -271,7 +271,7 @@ void RemoteGdbAdapter::handleKill(const GdbResponse &response)
|
|||||||
setState(InferiorShutDown);
|
setState(InferiorShutDown);
|
||||||
emit inferiorShutDown();
|
emit inferiorShutDown();
|
||||||
shutdown(); // re-iterate...
|
shutdown(); // re-iterate...
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
|
QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
|
||||||
setState(InferiorShutdownFailed);
|
setState(InferiorShutdownFailed);
|
||||||
emit inferiorShutdownFailed(msg);
|
emit inferiorShutdownFailed(msg);
|
||||||
@@ -282,7 +282,7 @@ void RemoteGdbAdapter::handleExit(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
// don't set state here, this will be handled in handleGdbFinished()
|
// don't set state here, this will be handled in handleGdbFinished()
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
||||||
emit adapterShutdownFailed(msg);
|
emit adapterShutdownFailed(msg);
|
||||||
}
|
}
|
||||||
|
@@ -1679,7 +1679,7 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
|||||||
if (record.resultClass == GdbResultDone) {
|
if (record.resultClass == GdbResultDone) {
|
||||||
setState(InferiorPrepared);
|
setState(InferiorPrepared);
|
||||||
emit inferiorPrepared();
|
emit inferiorPrepared();
|
||||||
} else if (record.resultClass == GdbResultError) {
|
} else {
|
||||||
QString msg = tr("Connecting to trk server adapter failed:\n")
|
QString msg = tr("Connecting to trk server adapter failed:\n")
|
||||||
+ _(record.data.findChild("msg").data());
|
+ _(record.data.findChild("msg").data());
|
||||||
emit inferiorPreparationFailed(msg);
|
emit inferiorPreparationFailed(msg);
|
||||||
@@ -1699,7 +1699,7 @@ void TrkGdbAdapter::handleFirstContinue(const GdbResponse &record)
|
|||||||
if (record.resultClass == GdbResultDone) {
|
if (record.resultClass == GdbResultDone) {
|
||||||
debugMessage(_("INFERIOR STARTED"));
|
debugMessage(_("INFERIOR STARTED"));
|
||||||
showStatusMessage(msgInferiorRunning());
|
showStatusMessage(msgInferiorRunning());
|
||||||
} else if (record.resultClass == GdbResultError) {
|
} else {
|
||||||
emit inferiorStartFailed(msgConnectRemoteServerFailed(record.toString()));
|
emit inferiorStartFailed(msgConnectRemoteServerFailed(record.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2076,7 +2076,7 @@ void TrkGdbAdapter::handleKill(const GdbResponse &response)
|
|||||||
setState(InferiorShutDown);
|
setState(InferiorShutDown);
|
||||||
emit inferiorShutDown();
|
emit inferiorShutDown();
|
||||||
shutdown(); // re-iterate...
|
shutdown(); // re-iterate...
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
const QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
|
const QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
|
||||||
setState(InferiorShutdownFailed);
|
setState(InferiorShutdownFailed);
|
||||||
emit inferiorShutdownFailed(msg);
|
emit inferiorShutdownFailed(msg);
|
||||||
@@ -2088,7 +2088,7 @@ void TrkGdbAdapter::handleExit(const GdbResponse &response)
|
|||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
qDebug() << "EXITED, NO MESSAGE...";
|
qDebug() << "EXITED, NO MESSAGE...";
|
||||||
// don't set state here, this will be handled in handleGdbFinished()
|
// don't set state here, this will be handled in handleGdbFinished()
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else {
|
||||||
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
|
||||||
emit adapterShutdownFailed(msg);
|
emit adapterShutdownFailed(msg);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user