forked from qt-creator/qt-creator
actively try to obtain PID of non-pthread inferiors with gdb < 7 on linux
Reviewed-by: hjk
This commit is contained in:
@@ -1152,14 +1152,21 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
|||||||
setState(InferiorStopped);
|
setState(InferiorStopped);
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
|
if (!m_entryPoint.isEmpty()) {
|
||||||
|
GdbMi frameData = data.findChild("frame");
|
||||||
|
if (frameData.findChild("addr").data() == m_entryPoint) {
|
||||||
|
if (reason == "signal-received"
|
||||||
|
&& data.findChild("signal-name").data() == "SIGSTOP") {
|
||||||
// For some reason, attaching to a stopped process causes *two* stops
|
// For some reason, attaching to a stopped process causes *two* stops
|
||||||
// when trying to continue (kernel i386 2.6.24-23-ubuntu, gdb 6.8).
|
// when trying to continue (kernel i386 2.6.24-23-ubuntu, gdb 6.8).
|
||||||
// Interestingly enough, on MacOSX no signal is delivered at all.
|
// Interestingly enough, on MacOSX no signal is delivered at all.
|
||||||
if (!m_entryPoint.isEmpty()) {
|
continueInferiorInternal();
|
||||||
if (reason == "signal-received"
|
return;
|
||||||
&& data.findChild("signal-name").data() == "SIGSTOP") {
|
}
|
||||||
GdbMi frameData = data.findChild("frame");
|
if (reason.isEmpty()) { // tbreak does that
|
||||||
if (frameData.findChild("addr").data() == m_entryPoint) {
|
// For programs without -pthread under gdb <= 6.8.
|
||||||
|
if (!inferiorPid())
|
||||||
|
postCommand(_("info proc"), CB(handleInfoProc));
|
||||||
continueInferiorInternal();
|
continueInferiorInternal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1325,6 +1332,18 @@ void GdbEngine::handleStop1(const GdbMi &data)
|
|||||||
manager()->reloadRegisters();
|
manager()->reloadRegisters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
void GdbEngine::handleInfoProc(const GdbResponse &response)
|
||||||
|
{
|
||||||
|
if (response.resultClass == GdbResultDone) {
|
||||||
|
static QRegExp re(_("\\bprocess ([0-9]+)\n"));
|
||||||
|
QTC_ASSERT(re.isValid(), return);
|
||||||
|
if (re.indexIn(_(response.data.findChild("consolestreamoutput").data())) != -1)
|
||||||
|
maybeHandleInferiorPidChanged(re.cap(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void GdbEngine::handleShowVersion(const GdbResponse &response)
|
void GdbEngine::handleShowVersion(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
//qDebug () << "VERSION 2:" << response.data.findChild("consolestreamoutput").data();
|
//qDebug () << "VERSION 2:" << response.data.findChild("consolestreamoutput").data();
|
||||||
|
@@ -302,6 +302,8 @@ private: ////////// Inferior Management //////////
|
|||||||
void maybeHandleInferiorPidChanged(const QString &pid);
|
void maybeHandleInferiorPidChanged(const QString &pid);
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
|
void handleInfoProc(const GdbResponse &response);
|
||||||
|
|
||||||
QByteArray m_entryPoint;
|
QByteArray m_entryPoint;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -110,6 +110,13 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
// Old gdbs do not announce the PID for programs without pthreads.
|
||||||
|
// Note that successfully preloading the debugging helpers will
|
||||||
|
// automatically load pthreads, so this will be unnecessary.
|
||||||
|
if (m_engine->m_gdbVersion < 70000)
|
||||||
|
m_engine->postCommand(_("info target"), CB(handleInfoTarget));
|
||||||
|
#endif
|
||||||
emit inferiorPrepared();
|
emit inferiorPrepared();
|
||||||
} else {
|
} else {
|
||||||
QString msg = tr("Starting executable failed:\n") +
|
QString msg = tr("Starting executable failed:\n") +
|
||||||
@@ -118,6 +125,29 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
void PlainGdbAdapter::handleInfoTarget(const GdbResponse &response)
|
||||||
|
{
|
||||||
|
if (response.resultClass == GdbResultDone) {
|
||||||
|
// [some leading stdout here]
|
||||||
|
// >&" Entry point: 0x80831f0 0x08048134 - 0x08048147 is .interp\n"
|
||||||
|
// [some trailing stdout here]
|
||||||
|
QString msg = _(response.data.findChild("consolestreamoutput").data());
|
||||||
|
QRegExp needle(_("\\bEntry point: 0x([0-9a-f]+)\\b"));
|
||||||
|
if (needle.indexIn(msg) != -1) {
|
||||||
|
m_engine->m_entryPoint =
|
||||||
|
"0x" + needle.cap(1).toLatin1().rightJustified(sizeof(void *) * 2, '0');
|
||||||
|
m_engine->postCommand(_("tbreak *0x") + needle.cap(1));
|
||||||
|
// Do nothing here - inferiorPrepared handles the sequencing.
|
||||||
|
} else {
|
||||||
|
emit inferiorStartFailed(_("Parsing start address failed"));
|
||||||
|
}
|
||||||
|
} else if (response.resultClass == GdbResultError) {
|
||||||
|
emit inferiorStartFailed(_("Fetching start address failed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void PlainGdbAdapter::startInferiorPhase2()
|
void PlainGdbAdapter::startInferiorPhase2()
|
||||||
{
|
{
|
||||||
setState(InferiorRunningRequested);
|
setState(InferiorRunningRequested);
|
||||||
|
@@ -62,6 +62,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
void handleFileExecAndSymbols(const GdbResponse &response);
|
void handleFileExecAndSymbols(const GdbResponse &response);
|
||||||
void handleExecRun(const GdbResponse &response);
|
void handleExecRun(const GdbResponse &response);
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
void handleInfoTarget(const GdbResponse &response);
|
||||||
|
#endif
|
||||||
|
|
||||||
OutputCollector m_outputCollector;
|
OutputCollector m_outputCollector;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user