Commit b052ce2c authored by hjk's avatar hjk

debugger: add a 'break at main' checkbox in the 'start and debug external' dialog

parent 94b1b1fd
......@@ -168,13 +168,8 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
BreakByFunctionDialog dlg(this);
if (dlg.exec())
emit breakByFunctionRequested(dlg.functionName());
} else if (act == act8) {
#ifdef Q_OS_WIN
emit breakByFunctionRequested("qMain");
#else
emit breakByFunctionRequested("main");
#endif
}
} else if (act == act8)
emit breakByFunctionMainRequested();
}
void BreakWindow::deleteBreakpoint(const QModelIndex &idx)
......
......@@ -51,6 +51,7 @@ signals:
void breakpointActivated(int index);
void breakpointSynchronizationRequested();
void breakByFunctionRequested(const QString &functionName);
void breakByFunctionMainRequested();
private slots:
void rowActivated(const QModelIndex &index);
......
......@@ -389,13 +389,13 @@ void AttachTcfDialog::updateState()
m_ui->serverStartScript->setEnabled(enabled);
}
///////////////////////////////////////////////////////////////////////
//
// StartExternalDialog
//
///////////////////////////////////////////////////////////////////////
StartExternalDialog::StartExternalDialog(QWidget *parent)
: QDialog(parent), m_ui(new Ui::StartExternalDialog)
{
......@@ -440,6 +440,12 @@ QString StartExternalDialog::executableArguments() const
return m_ui->argsEdit->text();
}
bool StartExternalDialog::breakAtMain() const
{
return m_ui->checkBoxBreakAtMain->isChecked();
}
///////////////////////////////////////////////////////////////////////
//
......
......@@ -140,6 +140,7 @@ public:
QString executableFile() const;
QString executableArguments() const;
bool breakAtMain() const;
private:
Ui::StartExternalDialog *m_ui;
......
......@@ -279,6 +279,8 @@ void DebuggerManager::init()
this, SIGNAL(setSessionValueRequested(QString,QVariant)));
connect(breakView, SIGNAL(breakByFunctionRequested(QString)),
this, SLOT(breakByFunction(QString)), Qt::QueuedConnection);
connect(breakView, SIGNAL(breakByFunctionMainRequested()),
this, SLOT(breakByFunctionMain()), Qt::QueuedConnection);
// Modules
QAbstractItemView *modulesView =
......@@ -1106,6 +1108,16 @@ void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber)
attemptBreakpointSynchronization();
}
void DebuggerManager::breakByFunctionMain()
{
#ifdef Q_OS_WIN
// FIXME: wrong on non-Qt based binaries
emit breakByFunction("qMain");
#else
emit breakByFunction("main");
#endif
}
void DebuggerManager::breakByFunction(const QString &functionName)
{
QTC_ASSERT(m_breakHandler, return);
......
......@@ -127,7 +127,8 @@ enum DebuggerStartMode
StartRemote // Start and attach to a remote process
};
struct DebuggerStartParameters {
struct DebuggerStartParameters
{
DebuggerStartParameters();
void clear();
......@@ -278,6 +279,7 @@ public slots:
void runToFunctionExec();
void toggleBreakpoint();
void breakByFunction(const QString &functionName);
void breakByFunctionMain();
void setBreakpoint(const QString &fileName, int lineNumber);
void activateFrame(int index);
void selectThread(int index);
......
......@@ -1202,15 +1202,17 @@ void DebuggerPlugin::startExternalApplication()
configValue(_("LastExternalExecutableFile")).toString());
dlg.setExecutableArguments(
configValue(_("LastExternalExecutableArguments")).toString());
if (dlg.exec() != QDialog::Accepted) {
if (dlg.exec() != QDialog::Accepted)
return;
}
setConfigValue(_("LastExternalExecutableFile"),
dlg.executableFile());
setConfigValue(_("LastExternalExecutableArguments"),
dlg.executableArguments());
sp->executable = dlg.executableFile();
sp->processArgs = dlg.executableArguments().split(QLatin1Char(' '));
if (dlg.breakAtMain())
m_manager->breakByFunctionMain();
QSharedPointer<RunConfiguration> rc = activeRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
......
......@@ -20,6 +20,19 @@
<property name="margin">
<number>9</number>
</property>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>407</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout">
<property name="margin">
......@@ -48,21 +61,22 @@
<item row="0" column="1">
<widget class="Core::Utils::PathChooser" name="execFile" native="true"/>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBoxBreakAtMain">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelBreakAtMain">
<property name="text">
<string>Break at 'main':</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<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">
......
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