Commit 6941781c authored by hjk's avatar hjk

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

(cherry picked from commit 6959a122)

Conflicts:

	src/plugins/debugger/gdb/gdbengine.cpp
	src/plugins/debugger/gdb/gdbengine.h
parent 4c5a2485
......@@ -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);
......
......@@ -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
......
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