Commit 74aa5e99 authored by hjk's avatar hjk

Debugger: Update executable filename from core if possible

Task-number: QTCREATORBUG-10219

Change-Id: Ib17c23c7e8bfdad4f1dbcaf7757fdb130fba2abf
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 49871ea2
......@@ -89,20 +89,19 @@ void GdbCoreEngine::setupEngine()
unpackCoreIfNeeded();
}
QString GdbCoreEngine::readExecutableNameFromCore(bool *isCore)
QString readExecutableNameFromCore(const QString &debuggerCommand, const QString &coreFile, bool *isCore)
{
#if 0
ElfReader reader(coreFileName());
return QString::fromLocal8Bit(reader.readCoreName(isCore));
#else
const DebuggerStartParameters &sp = startParameters();
QStringList args;
args.append(QLatin1String("-nx"));
args.append(QLatin1String("-batch"));
args.append(QLatin1String("-c"));
args.append(coreFileName());
args.append(coreFile);
QProcess proc;
proc.start(sp.debuggerCommand, args);
proc.start(debuggerCommand, args);
if (proc.waitForFinished()) {
QByteArray ba = proc.readAllStandardOutput();
// Core was generated by `/data/dev/creator-2.6/bin/qtcreator'.
......@@ -134,7 +133,9 @@ void GdbCoreEngine::continueSetupEngine()
if (isCore && m_executable.isEmpty()) {
// Read executable from core.
isCore = false;
m_executable = readExecutableNameFromCore(&isCore);
m_executable = readExecutableNameFromCore(
startParameters().debuggerCommand,
coreFileName(), &isCore);
if (isCore) {
// Strip off command line arguments. FIXME: make robust.
......
......@@ -43,6 +43,8 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
QString readExecutableNameFromCore(const QString &cmd, const QString &coreFile, bool *isCore);
class GdbCoreEngine : public GdbEngine
{
Q_OBJECT
......@@ -63,7 +65,6 @@ private:
void handleRoundTrip(const GdbResponse &response);
void unpackCoreIfNeeded();
QString coreFileName() const;
QString readExecutableNameFromCore(bool *isCore);
QString coreName() const;
private slots:
......
......@@ -31,6 +31,8 @@
#include "debuggerstartparameters.h"
#include "debuggerdialogs.h"
#include "debuggerkitinformation.h"
#include "gdb/coregdbadapter.h"
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorerconstants.h>
......@@ -265,9 +267,9 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
formLayout->setHorizontalSpacing(6);
formLayout->setVerticalSpacing(6);
formLayout->addRow(tr("Kit:"), d->kitChooser);
formLayout->addRow(tr("&Executable:"), d->localExecFileName);
formLayout->addRow(d->forceLocalLabel, d->forceLocalCheckBox);
formLayout->addRow(tr("Core file:"), coreLayout);
formLayout->addRow(tr("&Executable:"), d->localExecFileName);
formLayout->addRow(tr("Override &start script:"), d->overrideStartScriptFileName);
QFrame *line = new QFrame(this);
......@@ -291,9 +293,9 @@ AttachCoreDialog::~AttachCoreDialog()
int AttachCoreDialog::exec()
{
connect(d->selectRemoteCoreButton, SIGNAL(clicked()), SLOT(selectRemoteCoreFile()));
connect(d->remoteCoreFileName, SIGNAL(textChanged(QString)), SLOT(changed()));
connect(d->remoteCoreFileName, SIGNAL(textChanged(QString)), SLOT(coreFileChanged(QString)));
connect(d->localExecFileName, SIGNAL(changed(QString)), SLOT(changed()));
connect(d->localCoreFileName, SIGNAL(changed(QString)), SLOT(changed()));
connect(d->localCoreFileName, SIGNAL(changed(QString)), SLOT(coreFileChanged(QString)));
connect(d->forceLocalCheckBox, SIGNAL(stateChanged(int)), SLOT(changed()));
connect(d->kitChooser, SIGNAL(currentIndexChanged(int)), SLOT(changed()));
connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject()));
......@@ -317,6 +319,17 @@ bool AttachCoreDialog::useLocalCoreFile() const
return isLocalKit() || d->forceLocalCheckBox->isChecked();
}
void AttachCoreDialog::coreFileChanged(const QString &core)
{
Kit *k = d->kitChooser->currentKit();
QTC_ASSERT(k, return);
FileName cmd = DebuggerKitInformation::debuggerCommand(k);
bool isCore = false;
QString exe = readExecutableNameFromCore(cmd.toString(), core, &isCore);
d->localExecFileName->setFileName(FileName::fromString(exe));
changed();
}
void AttachCoreDialog::changed()
{
bool isValid = d->kitChooser->currentKit() && d->localExecFileName->isValid();
......
......@@ -69,6 +69,7 @@ public:
private slots:
void changed();
void coreFileChanged(const QString &core);
void selectRemoteCoreFile();
private:
......
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