forked from qt-creator/qt-creator
debugger: issue a warning if the user tries to debug a 'Release' build
This works only for locally started gcc compiled executables.
This commit is contained in:
@@ -36,6 +36,8 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtCore/QProcess>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -90,6 +92,33 @@ void LocalPlainGdbAdapter::startAdapter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit adapterStarted();
|
emit adapterStarted();
|
||||||
|
checkForReleaseBuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalPlainGdbAdapter::checkForReleaseBuild()
|
||||||
|
{
|
||||||
|
// Quick check for a "release" build
|
||||||
|
QProcess proc;
|
||||||
|
QStringList args;
|
||||||
|
args.append(_("-h"));
|
||||||
|
args.append(_("-j"));
|
||||||
|
args.append(_(".debug_info"));
|
||||||
|
args.append(startParameters().executable);
|
||||||
|
proc.start(_("objdump"), args);
|
||||||
|
proc.closeWriteChannel();
|
||||||
|
QTC_ASSERT(proc.waitForStarted(), qDebug() << "UNABLE TO RUN OBJDUMP");
|
||||||
|
proc.waitForFinished();
|
||||||
|
QByteArray ba = proc.readAllStandardOutput();
|
||||||
|
// This should yield something like
|
||||||
|
// "debuggertest: file format elf32-i386\n\n"
|
||||||
|
// "Sections:\nIdx Name Size VMA LMA File off Algn\n"
|
||||||
|
// "30 .debug_info 00087d36 00000000 00000000 0006bbd5 2**0\n"
|
||||||
|
// " CONTENTS, READONLY, DEBUGGING"
|
||||||
|
if (ba.contains("Sections:") && !ba.contains(".debug_info")) {
|
||||||
|
m_engine->showMessageBox(QMessageBox::Information, "Warning",
|
||||||
|
tr("This does not seem to be a \"Debug\" build.\n"
|
||||||
|
"Setting breakpoints by file name and line number may fail."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlainGdbAdapter::interruptInferior()
|
void LocalPlainGdbAdapter::interruptInferior()
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ private:
|
|||||||
virtual bool infoTargetNecessary() const;
|
virtual bool infoTargetNecessary() const;
|
||||||
virtual QByteArray toLocalEncoding(const QString &s) const;
|
virtual QByteArray toLocalEncoding(const QString &s) const;
|
||||||
virtual QString fromLocalEncoding(const QByteArray &b) const;
|
virtual QString fromLocalEncoding(const QByteArray &b) const;
|
||||||
|
void checkForReleaseBuild();
|
||||||
|
|
||||||
OutputCollector m_outputCollector;
|
OutputCollector m_outputCollector;
|
||||||
LocalGdbProcess m_gdbProc;
|
LocalGdbProcess m_gdbProc;
|
||||||
|
|||||||
Reference in New Issue
Block a user