forked from qt-creator/qt-creator
debugger: fix attaching to core file
This commit is contained in:
@@ -119,32 +119,59 @@ void CoreGdbAdapter::prepareInferior()
|
|||||||
void CoreGdbAdapter::startInferior()
|
void CoreGdbAdapter::startInferior()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
QFileInfo fi2(startParameters().coreFile);
|
QFileInfo fi(startParameters().coreFile);
|
||||||
// quoting core name below fails in gdb 6.8-debian
|
m_executable = startParameters().executable;
|
||||||
m_executable.clear();
|
if (m_executable.isEmpty()) {
|
||||||
QString coreName = fi2.absoluteFilePath();
|
// Extra round trip to get executable name from core file.
|
||||||
m_engine->postCommand(_("target core ") + coreName, CB(handleTargetCore));
|
// This is sometimes not the full name, so it can't be used
|
||||||
|
// as the generic solution.
|
||||||
|
// Quoting core name below fails in gdb 6.8-debian.
|
||||||
|
QString coreName = fi.absoluteFilePath();
|
||||||
|
m_engine->postCommand(_("target core ") + coreName, CB(handleTargetCore1));
|
||||||
|
} else {
|
||||||
|
// Directly load symbols.
|
||||||
|
QFileInfo fi(m_executable);
|
||||||
|
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"")
|
||||||
|
.arg(fi.absoluteFilePath()), CB(handleFileExecAndSymbols));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreGdbAdapter::handleTargetCore(const GdbResponse &response)
|
void CoreGdbAdapter::handleTargetCore1(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
showStatusMessage(tr("Attached to core."));
|
showStatusMessage(tr("Attached to core temporarily."));
|
||||||
m_executable = startParameters().executable;
|
GdbMi console = response.data.findChild("consolestreamoutput");
|
||||||
if (m_executable.isEmpty()) {
|
int pos1 = console.data().indexOf('`');
|
||||||
GdbMi console = response.data.findChild("consolestreamoutput");
|
int pos2 = console.data().indexOf('\'');
|
||||||
int pos1 = console.data().indexOf('`');
|
if (pos1 == -1 || pos2 == -1) {
|
||||||
int pos2 = console.data().indexOf('\'');
|
setState(InferiorStartFailed);
|
||||||
if (pos1 != -1 && pos2 != -1)
|
emit inferiorStartFailed(tr("No binary found."));
|
||||||
m_executable = console.data().mid(pos1 + 1, pos2 - pos1 - 1);
|
} else {
|
||||||
|
m_executable = console.data().mid(pos1 + 1, pos2 - pos1 - 1);
|
||||||
|
QTC_ASSERT(!m_executable.isEmpty(), /**/);
|
||||||
|
// Finish extra round.
|
||||||
|
m_engine->postCommand(_("detach"), CB(handleDetach1));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
||||||
|
const QByteArray msg = response.data.findChild("msg").data();
|
||||||
|
setState(InferiorStartFailed);
|
||||||
|
emit inferiorStartFailed(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreGdbAdapter::handleDetach1(const GdbResponse &response)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
|
if (response.resultClass == GdbResultDone) {
|
||||||
|
// Load symbols.
|
||||||
QFileInfo fi(m_executable);
|
QFileInfo fi(m_executable);
|
||||||
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"")
|
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"")
|
||||||
.arg(fi.absoluteFilePath()), CB(handleFileExecAndSymbols));
|
.arg(fi.absoluteFilePath()), CB(handleFileExecAndSymbols));
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
|
||||||
const QByteArray &msg = response.data.findChild("msg").data();
|
const QByteArray msg = response.data.findChild("msg").data();
|
||||||
setState(InferiorStartFailed);
|
setState(InferiorStartFailed);
|
||||||
emit inferiorStartFailed(msg);
|
emit inferiorStartFailed(msg);
|
||||||
}
|
}
|
||||||
@@ -155,8 +182,10 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
showStatusMessage(tr("Symbols found."));
|
showStatusMessage(tr("Symbols found."));
|
||||||
setState(InferiorUnrunnable);
|
// Quoting core name below fails in gdb 6.8-debian.
|
||||||
m_engine->updateAll();
|
QFileInfo fi(startParameters().coreFile);
|
||||||
|
QString coreName = fi.absoluteFilePath();
|
||||||
|
m_engine->postCommand(_("target core ") + coreName, CB(handleTargetCore2));
|
||||||
} else if (response.resultClass == GdbResultError) {
|
} else if (response.resultClass == GdbResultError) {
|
||||||
QString msg = tr("Symbols not found in \"%1\" failed:\n%2")
|
QString msg = tr("Symbols not found in \"%1\" failed:\n%2")
|
||||||
.arg(__(response.data.findChild("msg").data()));
|
.arg(__(response.data.findChild("msg").data()));
|
||||||
@@ -167,6 +196,22 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoreGdbAdapter::handleTargetCore2(const GdbResponse &response)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||||
|
if (response.resultClass == GdbResultDone) {
|
||||||
|
showStatusMessage(tr("Attached to core."));
|
||||||
|
setState(InferiorUnrunnable);
|
||||||
|
m_engine->updateAll();
|
||||||
|
} else if (response.resultClass == GdbResultError) {
|
||||||
|
QString msg = tr("Attach to core \"%1\" failed:\n%2")
|
||||||
|
.arg(__(response.data.findChild("msg").data()));
|
||||||
|
setState(InferiorUnrunnable);
|
||||||
|
m_engine->updateAll();
|
||||||
|
//setState(InferiorStartFailed);
|
||||||
|
// emit inferiorStartFailed(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
void CoreGdbAdapter::interruptInferior()
|
void CoreGdbAdapter::interruptInferior()
|
||||||
{
|
{
|
||||||
// A core should never 'run'
|
// A core should never 'run'
|
||||||
|
|||||||
@@ -67,8 +67,10 @@ private:
|
|||||||
void interruptInferior();
|
void interruptInferior();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
void handleTargetCore1(const GdbResponse &response);
|
||||||
|
void handleDetach1(const GdbResponse &response);
|
||||||
void handleFileExecAndSymbols(const GdbResponse &response);
|
void handleFileExecAndSymbols(const GdbResponse &response);
|
||||||
void handleTargetCore(const GdbResponse &response);
|
void handleTargetCore2(const GdbResponse &response);
|
||||||
void handleExit(const GdbResponse &response);
|
void handleExit(const GdbResponse &response);
|
||||||
|
|
||||||
Q_SLOT void handleGdbStarted();
|
Q_SLOT void handleGdbStarted();
|
||||||
|
|||||||
Reference in New Issue
Block a user