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);
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// 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).
|
||||
// Interestingly enough, on MacOSX no signal is delivered at all.
|
||||
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) {
|
||||
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
|
||||
// when trying to continue (kernel i386 2.6.24-23-ubuntu, gdb 6.8).
|
||||
// Interestingly enough, on MacOSX no signal is delivered at all.
|
||||
continueInferiorInternal();
|
||||
return;
|
||||
}
|
||||
if (reason.isEmpty()) { // tbreak does that
|
||||
// For programs without -pthread under gdb <= 6.8.
|
||||
if (!inferiorPid())
|
||||
postCommand(_("info proc"), CB(handleInfoProc));
|
||||
continueInferiorInternal();
|
||||
return;
|
||||
}
|
||||
@@ -1325,6 +1332,18 @@ void GdbEngine::handleStop1(const GdbMi &data)
|
||||
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)
|
||||
{
|
||||
//qDebug () << "VERSION 2:" << response.data.findChild("consolestreamoutput").data();
|
||||
|
@@ -302,6 +302,8 @@ private: ////////// Inferior Management //////////
|
||||
void maybeHandleInferiorPidChanged(const QString &pid);
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
void handleInfoProc(const GdbResponse &response);
|
||||
|
||||
QByteArray m_entryPoint;
|
||||
#endif
|
||||
|
||||
|
@@ -110,6 +110,13 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
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();
|
||||
} else {
|
||||
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()
|
||||
{
|
||||
setState(InferiorRunningRequested);
|
||||
|
@@ -62,6 +62,9 @@ public:
|
||||
private:
|
||||
void handleFileExecAndSymbols(const GdbResponse &response);
|
||||
void handleExecRun(const GdbResponse &response);
|
||||
#ifdef Q_OS_LINUX
|
||||
void handleInfoTarget(const GdbResponse &response);
|
||||
#endif
|
||||
|
||||
OutputCollector m_outputCollector;
|
||||
};
|
||||
|
Reference in New Issue
Block a user