Commit 66674d3a authored by hjk's avatar hjk
Browse files

debugger: more actions reshuffling

parent 0b58f1f5
......@@ -101,7 +101,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(act1);
menu.addAction(act2);
menu.addAction(act4);
menu.addAction(theDebuggerSettings()->action(SettingsDialog));
menu.addAction(theDebuggerSetting(SettingsDialog)->action());
QAction *act = menu.exec(ev->globalPos());
......
......@@ -30,7 +30,7 @@
#ifndef DEBUGGER_BREAKWINDOW_H
#define DEBUGGER_BREAKWINDOW_H
#include <QTreeView>
#include <QtGui/QTreeView>
namespace Debugger {
namespace Internal {
......
......@@ -189,9 +189,11 @@ void QtcSettingsItem::connectWidget(QWidget *widget, ApplyMode applyMode)
}
}
void QtcSettingsItem::applyDeferedChange()
void QtcSettingsItem::apply(QSettings *s)
{
setValue(m_deferedValue);
if (s)
writeSettings(s);
}
void QtcSettingsItem::uncheckableButtonClicked()
......@@ -248,85 +250,44 @@ void QtcSettingsItem::actionTriggered(bool on)
//////////////////////////////////////////////////////////////////////////
//
// QtcSettings
// QtcSettingsPool
//
//////////////////////////////////////////////////////////////////////////
QtcSettings::QtcSettings(QObject *parent)
QtcSettingsPool::QtcSettingsPool(QObject *parent)
: QObject(parent)
{}
QtcSettings::~QtcSettings()
QtcSettingsPool::~QtcSettingsPool()
{
qDeleteAll(m_items);
}
QtcSettingsItem *QtcSettings::createItem(int code)
{
return m_items[code] = new QtcSettingsItem;
}
void QtcSettings::insertItem(int code, QtcSettingsItem *item)
void QtcSettingsPool::insertItem(int code, QtcSettingsItem *item)
{
m_items[code] = item;
}
void QtcSettings::readSettings(QSettings *settings)
void QtcSettingsPool::readSettings(QSettings *settings)
{
foreach (QtcSettingsItem *item, m_items)
item->readSettings(settings);
}
void QtcSettings::writeSettings(QSettings *settings)
void QtcSettingsPool::writeSettings(QSettings *settings)
{
foreach (QtcSettingsItem *item, m_items)
item->writeSettings(settings);
}
QtcSettingsItem *QtcSettings::item(int code)
QtcSettingsItem *QtcSettingsPool::item(int code)
{
QTC_ASSERT(m_items.value(code, 0), return 0);
return m_items.value(code, 0);
}
bool QtcSettings::boolValue(int code)
{
return item(code)->value().toBool();
}
QString QtcSettings::stringValue(int code)
{
return item(code)->value().toString();
}
int QtcSettings::intValue(int code)
{
return item(code)->value().toInt();
}
QAction *QtcSettings::action(int code)
{
return item(code)->action();
}
void QtcSettings::applyDeferedChanges()
{
foreach (QtcSettingsItem *item, m_items)
item->applyDeferedChange();
}
void QtcSettings::applyDeferedChange(int code)
{
return item(code)->applyDeferedChange();
}
void QtcSettings::connectWidget(int code, QWidget *widget, ApplyMode applyMode)
{
item(code)->connectWidget(widget, applyMode);
}
QString QtcSettings::dump()
QString QtcSettingsPool::dump()
{
QString out;
QTextStream ts(&out);
......@@ -338,7 +299,6 @@ QString QtcSettings::dump()
//////////////////////////////////////////////////////////////////////////
//
// Debugger specific stuff
......@@ -368,59 +328,71 @@ QString QtcSettings::dump()
#endif
QtcSettings *theDebuggerSettings()
QtcSettingsPool *theDebuggerSettings()
{
static QtcSettings *instance = 0;
static QtcSettingsPool *instance = 0;
if (instance)
return instance;
instance = new QtcSettings;
instance = new QtcSettingsPool;
QtcSettingsItem *item = 0;
item = instance->createItem(AdjustColumnWidths);
item = new QtcSettingsItem(instance);
instance->insertItem(AdjustColumnWidths, item);
item->setText(QObject::tr("Adjust column widths to contents"));
item = instance->createItem(AlwaysAdjustColumnWidths);
item = new QtcSettingsItem(instance);
instance->insertItem(AlwaysAdjustColumnWidths, item);
item->setText(QObject::tr("Always adjust column widths to contents"));
item->action()->setCheckable(true);
item = instance->createItem(WatchExpression);
item = new QtcSettingsItem(instance);
instance->insertItem(WatchExpression, item);
item->setTextPattern(QObject::tr("Watch expression \"%1\""));
item = instance->createItem(RemoveWatchExpression);
item = new QtcSettingsItem(instance);
instance->insertItem(RemoveWatchExpression, item);
item->setTextPattern(QObject::tr("Remove watch expression \"%1\""));
item = instance->createItem(SettingsDialog);
item = new QtcSettingsItem(instance);
instance->insertItem(SettingsDialog, item);
item->setText(QObject::tr("Debugger properties..."));
item = instance->createItem(DebugDumpers);
item = new QtcSettingsItem(instance);
instance->insertItem(DebugDumpers, item);
item->setText(QObject::tr("Debug custom dumpers"));
item->action()->setCheckable(true);
item = instance->createItem(RecheckDumpers);
item = new QtcSettingsItem(instance);
instance->insertItem(RecheckDumpers, item);
item->setText(QObject::tr("Recheck custom dumper availability"));
//
// Breakpoints
//
item = instance->createItem(SynchronizeBreakpoints);
item = new QtcSettingsItem(instance);
instance->insertItem(SynchronizeBreakpoints, item);
item->setText(QObject::tr("Syncronize breakpoints"));
//
item = instance->createItem(AutoQuit);
item = new QtcSettingsItem(instance);
instance->insertItem(AutoQuit, item);
item->setText(QObject::tr("Automatically quit debugger"));
item->action()->setCheckable(true);
item = instance->createItem(SkipKnownFrames);
item = new QtcSettingsItem(instance);
instance->insertItem(SkipKnownFrames, item);
item->setText(QObject::tr("Skip known frames"));
item->action()->setCheckable(true);
item = instance->createItem(UseToolTips);
item = new QtcSettingsItem(instance);
instance->insertItem(UseToolTips, item);
item->setText(QObject::tr("Use tooltips when debugging"));
item->action()->setCheckable(true);
item = instance->createItem(ListSourceFiles);
item = new QtcSettingsItem(instance);
instance->insertItem(ListSourceFiles, item);
item->setText(QObject::tr("List source files"));
item->action()->setCheckable(true);
......@@ -428,54 +400,83 @@ QtcSettings *theDebuggerSettings()
//
// Settings
//
item = instance->createItem(GdbLocation);
item = new QtcSettingsItem(instance);
instance->insertItem(GdbLocation, item);
item->setSettingsKey("DebugMode", "Location");
item = instance->createItem(GdbEnvironment);
item = new QtcSettingsItem(instance);
instance->insertItem(GdbEnvironment, item);
item->setSettingsKey("DebugMode", "Environment");
item = instance->createItem(GdbScriptFile);
item = new QtcSettingsItem(instance);
instance->insertItem(GdbScriptFile, item);
item->setSettingsKey("DebugMode", "ScriptFile");
item = instance->createItem(GdbAutoQuit);
item = new QtcSettingsItem(instance);
instance->insertItem(GdbAutoQuit, item);
item->setSettingsKey("DebugMode", "AutoQuit");
item = instance->createItem(GdbAutoRun);
item = new QtcSettingsItem(instance);
instance->insertItem(GdbAutoRun, item);
item->setSettingsKey("DebugMode", "AutoRun");
item = instance->createItem(UseToolTips);
item = new QtcSettingsItem(instance);
instance->insertItem(UseToolTips, item);
item->setSettingsKey("DebugMode", "UseToolTips");
item = instance->createItem(UseDumpers);
item = new QtcSettingsItem(instance);
instance->insertItem(UseDumpers, item);
item->setSettingsKey("DebugMode", "UseCustomDumpers");
item->setText(QObject::tr("Use custom dumpers"));
item->action()->setCheckable(true);
item = instance->createItem(ListSourceFiles);
item = new QtcSettingsItem(instance);
instance->insertItem(ListSourceFiles, item);
item->setSettingsKey("DebugMode", "ListSourceFiles");
item = instance->createItem(SkipKnownFrames);
item = new QtcSettingsItem(instance);
instance->insertItem(SkipKnownFrames, item);
item->setSettingsKey("DebugMode", "SkipKnownFrames");
item = instance->createItem(DebugDumpers);
item = new QtcSettingsItem(instance);
instance->insertItem(DebugDumpers, item);
item->setSettingsKey("DebugMode", "DebugDumpers");
item = instance->createItem(AllPluginBreakpoints);
item = new QtcSettingsItem(instance);
instance->insertItem(AllPluginBreakpoints, item);
item->setSettingsKey("DebugMode", "AllPluginBreakpoints");
item = instance->createItem(SelectedPluginBreakpoints);
item = new QtcSettingsItem(instance);
instance->insertItem(SelectedPluginBreakpoints, item);
item->setSettingsKey("DebugMode", "SelectedPluginBreakpoints");
item = instance->createItem(NoPluginBreakpoints);
item = new QtcSettingsItem(instance);
instance->insertItem(NoPluginBreakpoints, item);
item->setSettingsKey("DebugMode", "NoPluginBreakpoints");
item = instance->createItem(SelectedPluginBreakpointsPattern);
item = new QtcSettingsItem(instance);
instance->insertItem(SelectedPluginBreakpointsPattern, item);
item->setSettingsKey("DebugMode", "SelectedPluginBreakpointsPattern");
return instance;
}
QtcSettingsItem *theDebuggerSetting(int code)
{
return theDebuggerSettings()->item(code);
}
bool theDebuggerBoolSetting(int code)
{
return theDebuggerSettings()->item(code)->value().toBool();
}
QString theDebuggerStringSetting(int code)
{
return theDebuggerSettings()->item(code)->value().toString();
}
} // namespace Internal
} // namespace Debugger
......@@ -33,6 +33,7 @@
#include <QtCore/QHash>
#include <QtCore/QString>
#include <QtCore/QVariant>
#include <QtCore/QList>
QT_BEGIN_NAMESPACE
class QAction;
......@@ -72,7 +73,7 @@ public:
Q_SLOT virtual void writeSettings(QSettings *settings);
virtual void connectWidget(QWidget *widget, ApplyMode applyMode = DeferedApply);
Q_SLOT virtual void applyDeferedChange();
Q_SLOT virtual void apply(QSettings *settings);
virtual QString text() const;
Q_SLOT virtual void setText(const QString &value);
......@@ -102,29 +103,18 @@ private:
QHash<QObject *, ApplyMode> m_applyModes;
};
class QtcSettings : public QObject
class QtcSettingsPool : public QObject
{
Q_OBJECT
public:
QtcSettings(QObject *parent = 0);
~QtcSettings();
QtcSettingsPool(QObject *parent = 0);
~QtcSettingsPool();
void insertItem(int code, QtcSettingsItem *item);
QAction *action(int code);
QtcSettingsItem *item(int code);
QtcSettingsItem *createItem(int code);
// Convienience
bool boolValue(int code);
int intValue(int code);
QString stringValue(int code);
virtual QString dump();
void connectWidget(int code, QWidget *, ApplyMode applyMode = DeferedApply);
void applyDeferedChange(int code);
void applyDeferedChanges();
QString dump();
public slots:
void readSettings(QSettings *settings);
......@@ -179,7 +169,12 @@ enum DebuggerSettingsCode
};
// singleton access
QtcSettings *theDebuggerSettings();
QtcSettingsPool *theDebuggerSettings();
QtcSettingsItem *theDebuggerSetting(int code);
// convienience
bool theDebuggerBoolSetting(int code);
QString theDebuggerStringSetting(int code);
} // namespace Internal
} // namespace Debugger
......
......@@ -1092,7 +1092,7 @@ void DebuggerManager::addToWatchWindow()
if (!editor)
return;
QTextCursor tc = editor->textCursor();
theDebuggerSettings()->item(WatchExpression)->setValue(tc.selectedText());
theDebuggerSetting(WatchExpression)->setValue(tc.selectedText());
}
void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber)
......
......@@ -264,34 +264,33 @@ QWidget *GdbOptionPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
m_ui.setupUi(w);
QtcSettings *s = theDebuggerSettings();
m_ui.gdbLocationChooser->setExpectedKind(Core::Utils::PathChooser::Command);
m_ui.gdbLocationChooser->setPromptDialogTitle(tr("Choose Gdb Location"));
m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File);
m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File"));
s->connectWidget(GdbLocation, m_ui.gdbLocationChooser);
s->connectWidget(GdbScriptFile, m_ui.scriptFileChooser);
s->connectWidget(GdbEnvironment, m_ui.environmentEdit);
s->connectWidget(AllPluginBreakpoints,
m_ui.radioButtonAllPluginBreakpoints);
s->connectWidget(SelectedPluginBreakpoints,
m_ui.radioButtonSelectedPluginBreakpoints);
s->connectWidget(NoPluginBreakpoints,
m_ui.radioButtonNoPluginBreakpoints);
s->connectWidget(SelectedPluginBreakpointsPattern,
m_ui.lineEditSelectedPluginBreakpointsPattern);
s->connectWidget(UseDumpers, m_ui.checkBoxUseDumpers);
s->connectWidget(SkipKnownFrames, m_ui.checkBoxSkipKnownFrames);
s->connectWidget(UseToolTips, m_ui.checkBoxUseToolTips);
s->connectWidget(DebugDumpers, m_ui.checkBoxDebugDumpers);
s->connectWidget(SelectedPluginBreakpointsPattern,
m_ui.lineEditSelectedPluginBreakpointsPattern);
theDebuggerSetting(GdbLocation)->connectWidget(m_ui.gdbLocationChooser);
theDebuggerSetting(GdbScriptFile)->connectWidget(m_ui.scriptFileChooser);
theDebuggerSetting(GdbEnvironment)->connectWidget(m_ui.environmentEdit);
theDebuggerSetting(AllPluginBreakpoints)
->connectWidget(m_ui.radioButtonAllPluginBreakpoints);
theDebuggerSetting(SelectedPluginBreakpoints)
->connectWidget(m_ui.radioButtonSelectedPluginBreakpoints);
theDebuggerSetting(NoPluginBreakpoints)
->connectWidget(m_ui.radioButtonNoPluginBreakpoints);
theDebuggerSetting(SelectedPluginBreakpointsPattern)
->connectWidget(m_ui.lineEditSelectedPluginBreakpointsPattern);
theDebuggerSetting(UseDumpers)->connectWidget(m_ui.checkBoxUseDumpers);
theDebuggerSetting(SkipKnownFrames)->connectWidget(m_ui.checkBoxSkipKnownFrames);
theDebuggerSetting(UseToolTips)->connectWidget(m_ui.checkBoxUseToolTips);
theDebuggerSetting(DebugDumpers)->connectWidget(m_ui.checkBoxDebugDumpers);
theDebuggerSetting(SelectedPluginBreakpointsPattern)
->connectWidget(m_ui.lineEditSelectedPluginBreakpointsPattern);
m_ui.lineEditSelectedPluginBreakpointsPattern->
setEnabled(s->boolValue(SelectedPluginBreakpoints));
setEnabled(theDebuggerSetting(SelectedPluginBreakpoints)->value().toBool());
connect(m_ui.radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)),
m_ui.lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool)));
......@@ -317,9 +316,22 @@ QWidget *GdbOptionPage::createPage(QWidget *parent)
void GdbOptionPage::apply()
{
QtcSettings *s = theDebuggerSettings();
s->applyDeferedChanges();
s->writeSettings(ICore::instance()->settings());
QSettings *s = ICore::instance()->settings();
theDebuggerSetting(GdbLocation)->apply(s);
theDebuggerSetting(GdbScriptFile)->apply(s);
theDebuggerSetting(GdbEnvironment)->apply(s);
theDebuggerSetting(AllPluginBreakpoints)->apply(s);
theDebuggerSetting(SelectedPluginBreakpoints)->apply(s);
theDebuggerSetting(NoPluginBreakpoints)->apply(s);
theDebuggerSetting(SelectedPluginBreakpointsPattern)->apply(s);
theDebuggerSetting(UseDumpers)->apply(s);
theDebuggerSetting(SkipKnownFrames)->apply(s);
theDebuggerSetting(UseToolTips)->apply(s);
theDebuggerSetting(DebugDumpers)->apply(s);
theDebuggerSetting(SelectedPluginBreakpointsPattern)->apply(s);
}
} // namespace Internal
......@@ -696,7 +708,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
connect(m_manager, SIGNAL(debugModeRequested()),
this, SLOT(activateDebugMode()));
connect(theDebuggerSettings()->action(SettingsDialog), SIGNAL(triggered()),
connect(theDebuggerSetting(SettingsDialog)->action(), SIGNAL(triggered()),
this, SLOT(showSettingsDialog()));
return true;
......@@ -790,7 +802,7 @@ void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber
void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor,
const QPoint &point, int pos)
{
if (!theDebuggerSettings()->boolValue(UseToolTips))
if (!theDebuggerSetting(UseToolTips)->value().toBool())
return;
QPlainTextEdit *plaintext = qobject_cast<QPlainTextEdit*>(editor->widget());
......
......@@ -285,12 +285,11 @@ void GdbEngine::initializeConnections()
q, SLOT(showApplicationOutput(QString)),
Qt::QueuedConnection);
QtcSettings *s = theDebuggerSettings();
connect(s->item(UseDumpers), SIGNAL(boolValueChanged(bool)),
connect(theDebuggerSetting(UseDumpers), SIGNAL(boolValueChanged(bool)),
this, SLOT(setUseDumpers(bool)));
connect(s->item(DebugDumpers), SIGNAL(boolValueChanged(bool)),
connect(theDebuggerSetting(DebugDumpers), SIGNAL(boolValueChanged(bool)),
this, SLOT(setDebugDumpers(bool)));
connect(s->action(RecheckDumpers), SIGNAL(triggered()),
connect(theDebuggerSetting(RecheckDumpers)->action(), SIGNAL(triggered()),
this, SLOT(recheckCustomDumperAvailability()));
}
......@@ -321,7 +320,7 @@ void GdbEngine::gdbProcError(QProcess::ProcessError error)
msg = QString(tr("The Gdb process failed to start. Either the "
"invoked program '%1' is missing, or you may have insufficient "
"permissions to invoke the program."))
.arg(theDebuggerSettings()->stringValue(GdbLocation));
.arg(theDebuggerSetting(GdbLocation)->value().toString());
break;
case QProcess::Crashed:
msg = tr("The Gdb process crashed some time after starting "
......@@ -1146,24 +1145,23 @@ void GdbEngine::handleAqcuiredInferior()
#if defined(Q_OS_MAC)
sendCommand("info pid", GdbInfoProc, QVariant(), NeedsStop);
#endif
if (theDebuggerSettings()->boolValue(UseDumpers))
if (theDebuggerBoolSetting(UseDumpers))
reloadSourceFiles();
tryLoadCustomDumpers();
#ifndef Q_OS_MAC
// intentionally after tryLoadCustomDumpers(),
// otherwise we'd interupt solib loading.
QtcSettings *s = theDebuggerSettings();
if (s->boolValue(AllPluginBreakpoints)) {
if (theDebuggerBoolSetting(AllPluginBreakpoints)) {
sendCommand("set auto-solib-add on");
sendCommand("set stop-on-solib-events 0");
sendCommand("sharedlibrary .*");
} else if (s->boolValue(SelectedPluginBreakpoints)) {
} else if (theDebuggerBoolSetting(SelectedPluginBreakpoints)) {
sendCommand("set auto-solib-add on");
sendCommand("set stop-on-solib-events 1");
sendCommand("sharedlibrary "
+ s->stringValue(SelectedPluginBreakpointsPattern));
} else if (s->boolValue(NoPluginBreakpoints)) {
+ theDebuggerStringSetting(SelectedPluginBreakpointsPattern));
} else if (theDebuggerBoolSetting(NoPluginBreakpoints)) {
// should be like that already
sendCommand("set auto-solib-add off");
sendCommand("set stop-on-solib-events 0");
......@@ -1236,11 +1234,11 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
}
QString msg = data.findChild("consolestreamoutput").data();
QtcSettings *s = theDebuggerSettings();
if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) {
if (s->boolValue(SelectedPluginBreakpoints)) {
if (theDebuggerSetting(SelectedPluginBreakpoints)->value().toBool()) {
debugMessage("SHARED LIBRARY EVENT: " + data.toString());
QString pattern = s->stringValue(SelectedPluginBreakpointsPattern);
QString pattern = theDebuggerSetting(SelectedPluginBreakpointsPattern)
->value().toString();
debugMessage("PATTERN: " + pattern);
sendCommand("sharedlibrary " + pattern);
continueInferior();
......@@ -1266,7 +1264,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
// jump over well-known frames
static int stepCounter = 0;
if (s->boolValue(SkipKnownFrames)) {
if (theDebuggerBoolSetting(SkipKnownFrames)) {
if (reason == "end-stepping-range" || reason == "function-finished") {
GdbMi frame = data.findChild("frame");
//debugMessage(frame.toString());
......@@ -1308,7 +1306,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
frame.findChild("func").data() + '%';
QApplication::alert(q->mainWindow(), 3000);
if (s->boolValue(ListSourceFiles))
if (theDebuggerSetting(ListSourceFiles)->value().toBool())
reloadSourceFiles();
sendCommand("-break-list", BreakList);
QVariant var = QVariant::fromValue<GdbMi>(data);
......@@ -1614,7 +1612,7 @@ bool GdbEngine::startDebugger()
qDebug() << "ExeFile: " << q->m_executable;
#endif
QString loc = theDebuggerSettings()->stringValue(GdbLocation);
QString loc = theDebuggerStringSetting(GdbLocation);
q->showStatusMessage(tr("Starting Debugger: ") + loc + ' ' + gdbArgs.join(" "));
m_gdbProc.start(loc, gdbArgs);
if (!m_gdbProc.waitForStarted()) {
......@@ -1690,7 +1688,7 @@ bool GdbEngine::startDebugger()
"dyld \".*CarbonDataFormatters.*\" all");
#endif
QString scriptFileName = theDebuggerSettings()->stringValue(GdbScriptFile);
QString scriptFileName = theDebuggerStringSetting(GdbScriptFile);
if (!scriptFileName.isEmpty()) {
QFile scriptFile(scriptFileName);
if (scriptFile.open(QIODevice::ReadOnly)) {
......@@ -2766,7 +2764,7 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
return;
}