Commit 4c5a2485 authored by hjk's avatar hjk
Browse files

debugger: fix 'jump to line' with older versions of gdb

(cherry picked from commit ebba2748)

Conflicts:

	src/plugins/debugger/gdb/gdbengine.cpp
parent 21b211fe
...@@ -961,10 +961,20 @@ void GdbEngine::handleResultRecord(GdbResponse *response) ...@@ -961,10 +961,20 @@ void GdbEngine::handleResultRecord(GdbResponse *response)
response->cookie = cmd.cookie; response->cookie = cmd.cookie;
if (response->resultClass != GdbResultError && bool isExpectedResult =
response->resultClass != ((cmd.flags & RunRequest) ? GdbResultRunning : response->resultClass == GdbResultError
|| response->resultClass == ((cmd.flags & RunRequest) ? GdbResultRunning :
(cmd.flags & ExitRequest) ? GdbResultExit : (cmd.flags & ExitRequest) ? GdbResultExit :
GdbResultDone)) { GdbResultDone)
// Happens with some incarnations of gdb 6.8:
|| (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 {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// Ignore spurious 'running' responses to 'attach' // Ignore spurious 'running' responses to 'attach'
const bool warning = !(m_startParameters->startMode == AttachExternal const bool warning = !(m_startParameters->startMode == AttachExternal
...@@ -978,11 +988,6 @@ void GdbEngine::handleResultRecord(GdbResponse *response) ...@@ -978,11 +988,6 @@ void GdbEngine::handleResultRecord(GdbResponse *response)
qWarning() << rsp << " AT " __FILE__ ":" STRINGIFY(__LINE__); qWarning() << rsp << " AT " __FILE__ ":" STRINGIFY(__LINE__);
debugMessage(_(rsp)); debugMessage(_(rsp));
} }
} else {
if (cmd.callback)
(this->*cmd.callback)(*response);
else if (cmd.adapterCallback)
(m_gdbAdapter->*cmd.adapterCallback)(*response);
} }
if (cmd.flags & RebuildWatchModel) { if (cmd.flags & RebuildWatchModel) {
...@@ -1080,32 +1085,17 @@ void GdbEngine::handleQuerySources(const GdbResponse &response) ...@@ -1080,32 +1085,17 @@ void GdbEngine::handleQuerySources(const GdbResponse &response)
} }
} }
#if 0 void GdbEngine::handleExecuteJumpToLine(const GdbResponse &response)
void GdbEngine::handleExecJumpToLine(const GdbResponse &response) {
{ if (response.resultClass == GdbResultRunning) {
// FIXME: remove this special case as soon as 'jump' // All is fine. Waiting for the temporary breakpoint to be hit.
// is supported by MI } else if (response.resultClass == GdbResultDone) {
// "&"jump /home/apoenitz/dev/work/test1/test1.cpp:242" // This happens on old gdb. Trigger the effect of a '*stopped'.
// ~"Continuing at 0x4058f3." showStatusMessage(tr("Jumped. Stopped"));
// ~"run1 (argc=1, argv=0x7fffb213a478) at test1.cpp:242" setState(InferiorStopped);
// ~"242\t x *= 2;" handleStop1(response);
//109^done"
setState(InferiorStopped);
showStatusMessage(tr("Jumped. Stopped."));
QByteArray output = response.data.findChild("logstreamoutput").data();
if (output.isEmpty())
return;
int idx1 = output.indexOf(' ') + 1;
if (idx1 > 0) {
int idx2 = output.indexOf(':', idx1);
if (idx2 > 0) {
QString file = QString::fromLocal8Bit(output.mid(idx1, idx2 - idx1));
int line = output.mid(idx2 + 1).toInt();
gotoLocation(file, line, true);
}
} }
} }
#endif
//void GdbEngine::handleExecRunToFunction(const GdbResponse &response) //void GdbEngine::handleExecRunToFunction(const GdbResponse &response)
//{ //{
...@@ -1953,7 +1943,7 @@ void GdbEngine::executeJumpToLine(const QString &fileName, int lineNumber) ...@@ -1953,7 +1943,7 @@ void GdbEngine::executeJumpToLine(const QString &fileName, int lineNumber)
+ QByteArray::number(lineNumber); + QByteArray::number(lineNumber);
postCommand("tbreak " + loc); postCommand("tbreak " + loc);
setState(InferiorRunningRequested); setState(InferiorRunningRequested);
postCommand("jump " + loc, RunRequest); postCommand("jump " + loc, RunRequest, CB(handleExecuteJumpToLine));
// will produce something like // will produce something like
// &"jump \"/home/apoenitz/dev/work/test1/test1.cpp\":242" // &"jump \"/home/apoenitz/dev/work/test1/test1.cpp\":242"
// ~"Continuing at 0x4058f3." // ~"Continuing at 0x4058f3."
......
...@@ -315,6 +315,7 @@ private: ////////// Inferior Management ////////// ...@@ -315,6 +315,7 @@ private: ////////// Inferior Management //////////
void handleExecuteStep(const GdbResponse &response); void handleExecuteStep(const GdbResponse &response);
void handleExecuteNext(const GdbResponse &response); void handleExecuteNext(const GdbResponse &response);
void handleExecuteReturn(const GdbResponse &response); void handleExecuteReturn(const GdbResponse &response);
void handleExecuteJumpToLine(const GdbResponse &response);
qint64 inferiorPid() const { return m_manager->inferiorPid(); } qint64 inferiorPid() const { return m_manager->inferiorPid(); }
void handleInferiorPidChanged(qint64 pid) { manager()->notifyInferiorPidChanged(pid); } void handleInferiorPidChanged(qint64 pid) { manager()->notifyInferiorPidChanged(pid); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment