diff options
author | hjk <qtc-committer@nokia.com> | 2010-06-30 14:47:08 +0200 |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2010-06-30 14:47:08 +0200 |
commit | 6941781c0d2485e6281d93b601091565a7493365 (patch) | |
tree | da02be537b874bf269eb8ab4cd4bcc83c8570fe1 /src/plugins/debugger | |
parent | 4c5a2485520b7d42859bfefa7cd9dc83b8bb8336 (diff) | |
download | qt-creator-6941781c0d2485e6281d93b601091565a7493365.tar.gz |
debugger: fix 'run to line' with older versions of gdb
(cherry picked from commit 6959a12211737783a7cba50eb5f343e95fd8fe59)
Conflicts:
src/plugins/debugger/gdb/gdbengine.cpp
src/plugins/debugger/gdb/gdbengine.h
Diffstat (limited to 'src/plugins/debugger')
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.cpp | 74 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/gdbengine.h | 7 |
2 files changed, 55 insertions, 26 deletions
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 7b41e5de57..48cd51a46c 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -966,15 +966,12 @@ void GdbEngine::handleResultRecord(GdbResponse *response) || response->resultClass == ((cmd.flags & RunRequest) ? GdbResultRunning : (cmd.flags & ExitRequest) ? GdbResultExit : GdbResultDone) - // Happens with some incarnations of gdb 6.8: + // Happens with some incarnations of gdb 6.8 for "run to line" + || (response->resultClass == GdbResultDone && cmd.command == "continue") + // Happens with some incarnations of gdb 6.8 for "jump to line" || (response->resultClass == GdbResultDone && cmd.command.startsWith("jump")); - if (isExpectedResult) { - if (cmd.callback) - (this->*cmd.callback)(*response); - else if (cmd.adapterCallback) - (m_gdbAdapter->*cmd.adapterCallback)(*response); - } else { + if (!isExpectedResult) { #ifdef Q_OS_WIN // Ignore spurious 'running' responses to 'attach' const bool warning = !(m_startParameters->startMode == AttachExternal @@ -990,6 +987,11 @@ void GdbEngine::handleResultRecord(GdbResponse *response) } } + if (cmd.callback) + (this->*cmd.callback)(*response); + else if (cmd.adapterCallback) + (m_gdbAdapter->*cmd.adapterCallback)(*response); + if (cmd.flags & RebuildWatchModel) { --m_pendingWatchRequests; PENDING_DEBUG(" WATCH" << cmd.command << "=>" << cmd.callbackName @@ -1097,21 +1099,41 @@ void GdbEngine::handleExecuteJumpToLine(const GdbResponse &response) } } -//void GdbEngine::handleExecRunToFunction(const GdbResponse &response) -//{ -// // FIXME: remove this special case as soon as there's a real -// // reason given when the temporary breakpoint is hit. -// // reight now we get: -// // 14*stopped,thread-id="1",frame={addr="0x0000000000403ce4", -// // func="foo",args=[{name="str",value="@0x7fff0f450460"}], -// // file="main.cpp",fullname="/tmp/g/main.cpp",line="37"} -// QTC_ASSERT(state() == InferiorStopping, qDebug() << state()) -// setState(InferiorStopped); -// showStatusMessage(tr("Function reached. Stopped.")); -// GdbMi frame = response.data.findChild("frame"); -// StackFrame f = parseStackFrame(frame, 0); -// gotoLocation(f, true); -//} +void GdbEngine::handleExecuteRunToLine(const GdbResponse &response) +{ + if (response.resultClass == GdbResultRunning) { + // All is fine. Waiting for the temporary breakpoint to be hit. + } else if (response.resultClass == GdbResultDone) { + // This happens on old gdb. Trigger the effect of a '*stopped'. + // >&"continue\n" + // >~"Continuing.\n" + //>~"testArray () at ../simple/app.cpp:241\n" + //>~"241\t s[1] = \"b\";\n" + //>122^done + gotoLocation(m_targetFrame, true); + showStatusMessage(tr("Target line hit. Stopped")); + setState(InferiorStopped); + handleStop1(response); + } +} + +/* +void GdbEngine::handleExecuteRunToFunction(const GdbResponse &response) +{ + // FIXME: remove this special case as soon as there's a real + // reason given when the temporary breakpoint is hit. + // reight now we get: + // 14*stopped,thread-id="1",frame={addr="0x0000000000403ce4", + // func="foo",args=[{name="str",value="@0x7fff0f450460"}], + // file="main.cpp",fullname="/tmp/g/main.cpp",line="37"} + QTC_ASSERT(state() == InferiorStopping, qDebug() << state()) + setState(InferiorStopped); + showStatusMessage(tr("Function reached. Stopped")); + GdbMi frame = response.data.findChild("frame"); + StackFrame f = parseStackFrame(frame, 0); + gotoLocation(f, true); +} +*/ static bool isExitedReason(const QByteArray &reason) { @@ -1908,10 +1930,12 @@ void GdbEngine::executeRunToLine(const QString &fileName, int lineNumber) setState(InferiorRunningRequested); showStatusMessage(tr("Run to line %1 requested...").arg(lineNumber), 5000); #if 1 + m_targetFrame.file = fileName; + m_targetFrame.line = lineNumber; QByteArray loc = '"' + breakLocation(fileName).toLocal8Bit() + '"' + ':' + QByteArray::number(lineNumber); postCommand("tbreak " + loc); - postCommand("continue", RunRequest); + postCommand("continue", RunRequest, CB(handleExecuteRunToLine)); #else // Seems to jump to unpredicatable places. Observed in the manual // tests in the Foo::Foo() constructor with both gdb 6.8 and 7.1. @@ -1928,7 +1952,7 @@ void GdbEngine::executeRunToFunction(const QString &functionName) postCommand("-break-insert -t " + functionName.toLatin1()); continueInferiorInternal(); //setState(InferiorRunningRequested); - //postCommand("-exec-continue", handleExecRunToFunction); + //postCommand("-exec-continue", handleExecuteRunToFunction); showStatusMessage(tr("Run to function %1 requested...").arg(functionName), 5000); } @@ -1954,7 +1978,7 @@ void GdbEngine::executeJumpToLine(const QString &fileName, int lineNumber) //setBreakpoint(); //postCommand("jump " + loc); #else - gotoLocation(frame, true); + gotoLocation(frame, true); setBreakpoint(fileName, lineNumber); setState(InferiorRunningRequested); postCommand("jump " + loc, RunRequest); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 7e852caa61..ef6c83d69c 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -33,6 +33,7 @@ #include "idebuggerengine.h" #include "debuggermanager.h" // only for StartParameters #include "gdbmi.h" +#include "stackframe.h" #include "watchutils.h" #include <QtCore/QByteArray> @@ -307,7 +308,6 @@ private: ////////// Inferior Management ////////// virtual void executeRunToLine(const QString &fileName, int lineNumber); virtual void executeRunToFunction(const QString &functionName); -// void handleExecRunToFunction(const GdbResponse &response); virtual void executeJumpToLine(const QString &fileName, int lineNumber); virtual void executeReturn(); @@ -316,6 +316,8 @@ private: ////////// Inferior Management ////////// void handleExecuteNext(const GdbResponse &response); void handleExecuteReturn(const GdbResponse &response); void handleExecuteJumpToLine(const GdbResponse &response); + void handleExecuteRunToLine(const GdbResponse &response); + //void handleExecuteRunToFunction(const GdbResponse &response); qint64 inferiorPid() const { return m_manager->inferiorPid(); } void handleInferiorPidChanged(qint64 pid) { manager()->notifyInferiorPidChanged(pid); } @@ -529,6 +531,9 @@ private: ////////// Convenience Functions ////////// static QString m_toolTipExpression; static QPoint m_toolTipPos; static QByteArray tooltipINameForExpression(const QByteArray &exp); + + // HACK: + StackFrame m_targetFrame; }; } // namespace Internal |