Commit 07d51d0c authored by hjk's avatar hjk

Fixes: debugger: worlk on core file loading

parent 00a9c053
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AttachCoreDialog</class>
<widget class="QDialog" name="AttachCoreDialog" >
<property name="geometry" >
<widget class="QDialog" name="AttachCoreDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>561</width>
<height>866</height>
<width>425</width>
<height>127</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Start Debugger</string>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin" >
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="pidLabel" >
<property name="text" >
<string>Attach to Process ID:</string>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="execLabel">
<property name="text">
<string>Executable:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="coreLabel">
<property name="text">
<string>Core File:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="pidLineEdit" />
<item row="0" column="1">
<widget class="Core::Utils::PathChooser" name="execFileName" native="true"/>
</item>
<item row="1" column="1">
<widget class="Core::Utils::PathChooser" name="coreFileName" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="procView" >
<property name="editTriggers" >
<set>QAbstractItemView::NoEditTriggers</set>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>407</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line" >
<property name="orientation" >
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Core::Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -29,6 +29,11 @@
#include "debuggerdialogs.h"
#include "ui_attachcoredialog.h"
#include "ui_attachexternaldialog.h"
#include "ui_attachremotedialog.h"
#include "ui_startexternaldialog.h"
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
......@@ -54,17 +59,46 @@ using namespace Debugger::Internal;
///////////////////////////////////////////////////////////////////////
AttachCoreDialog::AttachCoreDialog(QWidget *parent)
: QDialog(parent)
: QDialog(parent), m_ui(new Ui::AttachCoreDialog)
{
setupUi(this);
m_ui->setupUi(this);
m_ui->execFileName->setExpectedKind(Core::Utils::PathChooser::File);
m_ui->execFileName->setPromptDialogTitle(tr("Select Executable"));
m_ui->coreFileName->setExpectedKind(Core::Utils::PathChooser::File);
m_ui->coreFileName->setPromptDialogTitle(tr("Select Executable"));
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
AttachCoreDialog::~AttachCoreDialog()
{
delete m_ui;
}
//connect(procView, SIGNAL(activated(const QModelIndex &)),
// this, SLOT(procSelected(const QModelIndex &)));
QString AttachCoreDialog::executableFile() const
{
return m_ui->execFileName->path();
}
void AttachCoreDialog::setExecutableFile(const QString &fileName)
{
m_ui->execFileName->setPath(fileName);
}
QString AttachCoreDialog::coreFile() const
{
return m_ui->coreFileName->path();
}
void AttachCoreDialog::setCoreFile(const QString &fileName)
{
m_ui->coreFileName->setPath(fileName);
}
///////////////////////////////////////////////////////////////////////
......@@ -74,23 +108,28 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
///////////////////////////////////////////////////////////////////////
AttachExternalDialog::AttachExternalDialog(QWidget *parent)
: QDialog(parent)
: QDialog(parent), m_ui(new Ui::AttachExternalDialog)
{
setupUi(this);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_ui->setupUi(this);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_model = new QStandardItemModel(this);
procView->setSortingEnabled(true);
m_ui->procView->setSortingEnabled(true);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(procView, SIGNAL(activated(const QModelIndex &)),
this, SLOT(procSelected(const QModelIndex &)));
connect(m_ui->procView, SIGNAL(activated(QModelIndex)),
this, SLOT(procSelected(QModelIndex)));
rebuildProcessList();
}
AttachExternalDialog::~AttachExternalDialog()
{
delete m_ui;
}
static bool isProcessName(const QString &procname)
{
for (int i = 0; i != procname.size(); ++i)
......@@ -132,7 +171,7 @@ void AttachExternalDialog::rebuildProcessList()
{
QStringList procnames = QDir("/proc/").entryList();
if (procnames.isEmpty()) {
procView->hide();
m_ui->procView->hide();
return;
}
......@@ -165,11 +204,11 @@ void AttachExternalDialog::rebuildProcessList()
//model->setHeaderData(2, Qt::Horizontal, "Parent", Qt::DisplayRole);
m_model->setHeaderData(2, Qt::Horizontal, "State", Qt::DisplayRole);
procView->setModel(m_model);
procView->expandAll();
procView->resizeColumnToContents(0);
procView->resizeColumnToContents(1);
procView->sortByColumn(1, Qt::AscendingOrder);
m_ui->procView->setModel(m_model);
m_ui->procView->expandAll();
m_ui->procView->resizeColumnToContents(0);
m_ui->procView->resizeColumnToContents(1);
m_ui->procView->sortByColumn(1, Qt::AscendingOrder);
}
void AttachExternalDialog::procSelected(const QModelIndex &index0)
......@@ -178,13 +217,13 @@ void AttachExternalDialog::procSelected(const QModelIndex &index0)
QStandardItem *item = m_model->itemFromIndex(index);
if (!item)
return;
pidLineEdit->setText(item->text());
m_ui->pidLineEdit->setText(item->text());
accept();
}
int AttachExternalDialog::attachPID() const
{
return pidLineEdit->text().toInt();
return m_ui->pidLineEdit->text().toInt();
}
......@@ -196,31 +235,35 @@ int AttachExternalDialog::attachPID() const
///////////////////////////////////////////////////////////////////////
AttachRemoteDialog::AttachRemoteDialog(QWidget *parent, const QString &pid)
: QDialog(parent)
: QDialog(parent), m_ui(new Ui::AttachRemoteDialog)
{
setupUi(this);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_ui->setupUi(this);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_defaultPID = pid;
m_model = new QStandardItemModel(this);
procView->setSortingEnabled(true);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
m_ui->procView->setSortingEnabled(true);
connect(procView, SIGNAL(activated(const QModelIndex &)),
this, SLOT(procSelected(const QModelIndex &)));
connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_ui->procView, SIGNAL(activated(QModelIndex)),
this, SLOT(procSelected(QModelIndex)));
pidLineEdit->setText(m_defaultPID);
m_ui->pidLineEdit->setText(m_defaultPID);
rebuildProcessList();
}
AttachRemoteDialog::~AttachRemoteDialog()
{
delete m_ui;
}
void AttachRemoteDialog::rebuildProcessList()
{
QStringList procnames = QDir("/proc/").entryList();
if (procnames.isEmpty()) {
procView->hide();
m_ui->procView->hide();
return;
}
......@@ -253,10 +296,10 @@ void AttachRemoteDialog::rebuildProcessList()
//model->setHeaderData(2, Qt::Horizontal, "Parent", Qt::DisplayRole);
m_model->setHeaderData(2, Qt::Horizontal, "State", Qt::DisplayRole);
procView->setModel(m_model);
procView->expandAll();
procView->resizeColumnToContents(0);
procView->resizeColumnToContents(1);
m_ui->procView->setModel(m_model);
m_ui->procView->expandAll();
m_ui->procView->resizeColumnToContents(0);
m_ui->procView->resizeColumnToContents(1);
}
void AttachRemoteDialog::procSelected(const QModelIndex &index0)
......@@ -265,13 +308,13 @@ void AttachRemoteDialog::procSelected(const QModelIndex &index0)
QStandardItem *item = m_model->itemFromIndex(index);
if (!item)
return;
pidLineEdit->setText(item->text());
m_ui->pidLineEdit->setText(item->text());
accept();
}
int AttachRemoteDialog::attachPID() const
{
return pidLineEdit->text().toInt();
return m_ui->pidLineEdit->text().toInt();
}
......@@ -284,40 +327,45 @@ int AttachRemoteDialog::attachPID() const
StartExternalDialog::StartExternalDialog(QWidget *parent)
: QDialog(parent)
: QDialog(parent), m_ui(new Ui::StartExternalDialog)
{
setupUi(this);
execFile->setExpectedKind(Core::Utils::PathChooser::File);
execFile->setPromptDialogTitle(tr("Select Executable"));
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_ui->setupUi(this);
m_ui->execFile->setExpectedKind(Core::Utils::PathChooser::File);
m_ui->execFile->setPromptDialogTitle(tr("Select Executable"));
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
//execLabel->setHidden(false);
//execEdit->setHidden(false);
//browseButton->setHidden(false);
execLabel->setText(tr("Executable:"));
argLabel->setText(tr("Arguments:"));
m_ui->execLabel->setText(tr("Executable:"));
m_ui->argLabel->setText(tr("Arguments:"));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
StartExternalDialog::~StartExternalDialog()
{
delete m_ui;
}
void StartExternalDialog::setExecutableFile(const QString &str)
{
execFile->setPath(str);
m_ui->execFile->setPath(str);
}
void StartExternalDialog::setExecutableArguments(const QString &str)
{
argsEdit->setText(str);
m_ui->argsEdit->setText(str);
}
QString StartExternalDialog::executableFile() const
{
return execFile->path();
return m_ui->execFile->path();
}
QString StartExternalDialog::executableArguments() const
{
return argsEdit->text();
return m_ui->argsEdit->text();
}
......@@ -30,39 +30,53 @@
#ifndef DEBUGGER_DIALOGS_H
#define DEBUGGER_DIALOGS_H
#include "ui_attachcoredialog.h"
#include "ui_attachexternaldialog.h"
#include "ui_attachremotedialog.h"
#include "ui_startexternaldialog.h"
#include <QtGui/QDialog>
QT_BEGIN_NAMESPACE
class QModelIndex;
class QStandardItemModel;
namespace Ui {
class AttachCoreDialog;
class AttachExternalDialog;
class AttachRemoteDialog;
class StartExternalDialog;
} // namespace Ui
QT_END_NAMESPACE
namespace Debugger {
namespace Internal {
class AttachCoreDialog : public QDialog, Ui::AttachCoreDialog
class AttachCoreDialog : public QDialog
{
Q_OBJECT
public:
explicit AttachCoreDialog(QWidget *parent);
~AttachCoreDialog();
void setExecutableFile(const QString &executable);
void setCoreFile(const QString &core);
QString executableFile() const;
QString coreFile() const;
private:
Ui::AttachCoreDialog *m_ui;
};
class AttachExternalDialog : public QDialog, Ui::AttachExternalDialog
class AttachExternalDialog : public QDialog
{
Q_OBJECT
public:
explicit AttachExternalDialog(QWidget *parent);
~AttachExternalDialog();
int attachPID() const;
private slots:
......@@ -70,16 +84,19 @@ private slots:
void procSelected(const QModelIndex &);
private:
Ui::AttachExternalDialog *m_ui;
QStandardItemModel *m_model;
};
class AttachRemoteDialog : public QDialog, Ui::AttachRemoteDialog
class AttachRemoteDialog : public QDialog
{
Q_OBJECT
public:
explicit AttachRemoteDialog(QWidget *parent, const QString &pid);
~AttachRemoteDialog();
int attachPID() const;
private slots:
......@@ -87,23 +104,28 @@ private slots:
void procSelected(const QModelIndex &);
private:
Ui::AttachRemoteDialog *m_ui;
QString m_defaultPID;
QStandardItemModel *m_model;
};
class StartExternalDialog : public QDialog, Ui::StartExternalDialog
class StartExternalDialog : public QDialog
{
Q_OBJECT
public:
explicit StartExternalDialog(QWidget *parent);
~StartExternalDialog();
void setExecutableFile(const QString &executable);
void setExecutableArguments(const QString &args);
QString executableFile() const;
QString executableArguments() const;
private:
Ui::StartExternalDialog *m_ui;
};
} // namespace Debugger
......
......@@ -779,7 +779,7 @@ void DebuggerManager::attachCore()
emit debuggingFinished();
}
bool DebuggerManager::startNewDebugger(StartMode mode)
bool DebuggerManager::startNewDebugger(DebuggerStartMode mode)
{
m_startMode = mode;
// FIXME: Clean up
......@@ -838,19 +838,20 @@ bool DebuggerManager::startNewDebugger(StartMode mode)
m_attachedPID = 0;
}
} else if (startMode() == AttachCore) {
StartExternalDialog dlg(mainWindow());
AttachCoreDialog dlg(mainWindow());
dlg.setExecutableFile(
configValue(QLatin1String("LastExternalExecutableFile")).toString());
dlg.setExecutableArguments(
configValue(QLatin1String("LastExternalExecutableArguments")).toString());
dlg.setCoreFile(
configValue(QLatin1String("LastExternalCoreFile")).toString());
if (dlg.exec() != QDialog::Accepted)
return false;
setConfigValue(QLatin1String("LastExternalExecutableFile"),
dlg.executableFile());
setConfigValue(QLatin1String("LastExternalExecutableArguments"),
dlg.executableArguments());
setConfigValue(QLatin1String("LastExternalCoreFile"),
dlg.coreFile());
m_executable = dlg.executableFile();
m_processArgs = dlg.executableArguments().split(' ');
m_coreFile = dlg.coreFile();
m_processArgs.clear();
m_workingDir = QString();
m_attachedPID = -1;
}
......
......@@ -102,6 +102,14 @@ enum DebuggerStatus
DebuggerInferiorStopped, // Debuggee stopped
};
enum DebuggerStartMode
{
StartInternal, // Start current start project's binary
StartExternal, // Start binary found in file system
AttachExternal, // Attach to running process
AttachCore // Attach to a core file
};
class IDebuggerEngine;
class GdbEngine;
class ScriptEngine;
......@@ -215,11 +223,10 @@ public:
QLabel *statusLabel() const { return m_statusLabel; }
DebuggerSettings *settings() { return &m_settings; }
enum StartMode { StartInternal, StartExternal, AttachExternal, AttachCore };
enum DebuggerType { GdbDebugger, ScriptDebugger, WinDebugger };
public slots:
bool startNewDebugger(StartMode mode);
bool startNewDebugger(DebuggerStartMode mode);
void exitDebugger();
void setSimpleDockWidgetArrangement();
......@@ -354,7 +361,7 @@ public:
// one of the interfaces
QAbstractItemModel *threadsModel();
int status() const { return m_status; }
StartMode startMode() const { return m_startMode; }
DebuggerStartMode startMode() const { return m_startMode; }
signals:
void debuggingFinished();
......@@ -377,6 +384,7 @@ signals:
public:
// FIXME: make private
QString m_executable;
QString m_coreFile;
QStringList m_environment;
QString m_workingDir;
QString m_buildDir;
......@@ -394,7 +402,7 @@ private:
void toggleBreakpoint(const QString &fileName, int lineNumber);
void setToolTipExpression(const QPoint &pos, const QString &exp0);
StartMode m_startMode;
DebuggerStartMode m_startMode;
DebuggerType m_debuggerType;
/// Views
......
......@@ -94,6 +94,7 @@ namespace Constants {
const char * const STARTEXTERNAL = "Debugger.StartExternal";
const char * const ATTACHEXTERNAL = "Debugger.AttachExternal";
const char * const ATTACHCORE = "Debugger.AttachCore";
const char * const RUN_TO_LINE = "Debugger.RunToLine";
const char * const RUN_TO_FUNCTION = "Debugger.RunToFunction";
......@@ -446,6 +447,10 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
cmd = am->registerAction(m_manager->m_attachExternalAction,
Constants::ATTACHEXTERNAL, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
cmd = am->registerAction(m_manager->m_attachCoreAction,
Constants::ATTACHCORE, globalcontext);
mdebug->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
#endif
cmd = am->registerAction(m_manager->m_continueAction,
......
......@@ -135,7 +135,7 @@ void DebuggerRunControl::start()
//<daniel> andre: + "\qtc-gdbmacros\"
//emit addToOutputWindow(this, tr("Debugging %1").arg(m_executable));
if (m_manager->startNewDebugger(DebuggerManager::StartInternal))
if (m_manager->startNewDebugger(StartInternal))
emit started();
else
debuggingFinished();
......
......@@ -53,6 +53,7 @@
#include <QtCore/QTimer>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QLabel>
#include <QtGui/QMainWindow>
#include <QtGui/QMessageBox>
......@@ -114,6 +115,7 @@ enum GdbCommandType
GdbQueryDataDumper1,
GdbQueryDataDumper2,