Commit 151b785d authored by Oswald Buddenhagen's avatar Oswald Buddenhagen

terminal adapter: make skipping of initial SIGSTOPs more reliable

first, _start being resolvable depends on libc-dbg being installed.
second, depending on the frame being in the dynloader makes it
a) work only for dynamic executables and b) fail on multi-target
systems (due to a hard-coded file name).
so instead just remember the entry point, as we are already there
anyway.

Reviewed-By: hjk
parent 6d6ed26e
......@@ -285,6 +285,9 @@ void GdbEngine::initializeVariables()
m_currentFunctionArgs.clear();
m_currentFrame.clear();
m_dumperHelper.clear();
#ifdef Q_OS_LINUX
m_entryPoint.clear();
#endif
}
QString GdbEngine::errorMessage(QProcess::ProcessError error)
......@@ -1068,16 +1071,19 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
#ifdef Q_OS_LINUX
// For some reason, attaching to a stopped process causes *two* stops
// when trying to continue (kernel 2.6.24-23-ubuntu).
// when trying to continue (kernel i386 2.6.24-23-ubuntu, gdb 6.8).
// Interestingly enough, on MacOSX no signal is delivered at all.
if (reason == "signal-received"
&& data.findChild("signal-name").data() == "SIGSTOP") {
GdbMi frameData = data.findChild("frame");
if (frameData.findChild("func").data() == "_start"
&& frameData.findChild("from").data() == "/lib/ld-linux.so.2") {
continueInferiorInternal();
return;
if (!m_entryPoint.isEmpty()) {
if (reason == "signal-received"
&& data.findChild("signal-name").data() == "SIGSTOP") {
GdbMi frameData = data.findChild("frame");
if (frameData.findChild("addr").data() == m_entryPoint) {
continueInferiorInternal();
return;
}
}
// We are past the initial stops. No need to waste time on further checks.
m_entryPoint.clear();
}
#endif
......
......@@ -294,6 +294,10 @@ private: ////////// Inferior Management //////////
void handleInferiorPidChanged(qint64 pid) { manager()->notifyInferiorPidChanged(pid); }
void maybeHandleInferiorPidChanged(const QString &pid);
#ifdef Q_OS_LINUX
QByteArray m_entryPoint;
#endif
private: ////////// View & Data Stuff //////////
virtual void selectThread(int index);
......
......@@ -119,6 +119,9 @@ void TermGdbAdapter::handleStubAttached(const GdbResponse &response)
setState(InferiorStopped);
debugMessage(_("INFERIOR ATTACHED"));
emit inferiorPrepared();
#ifdef Q_OS_LINUX
m_engine->postCommand(_("-stack-list-frames 0 0"), CB(handleEntryPoint));
#endif
} else if (response.resultClass == GdbResultError) {
QString msg = _(response.data.findChild("msg").data());
emit inferiorStartFailed(msg);
......@@ -130,6 +133,17 @@ void TermGdbAdapter::startInferiorPhase2()
m_engine->continueInferiorInternal();
}
#ifdef Q_OS_LINUX
void TermGdbAdapter::handleEntryPoint(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
GdbMi stack = response.data.findChild("stack");
if (stack.isValid() && stack.childCount() == 1)
m_engine->m_entryPoint = stack.childAt(0).findChild("addr").data();
}
}
#endif
void TermGdbAdapter::interruptInferior()
{
const qint64 attachedPID = m_engine->inferiorPid();
......
......@@ -60,6 +60,9 @@ public:
private:
void handleStubAttached(const GdbResponse &response);
#ifdef Q_OS_LINUX
void handleEntryPoint(const GdbResponse &response);
#endif
Q_SLOT void handleInferiorStarted();
Q_SLOT void stubExited();
......
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