Commit 7f8473f4 authored by hjk's avatar hjk
Browse files

move debugger options to configuration dialog

parent 73f9b175
......@@ -26,7 +26,6 @@ HEADERS += attachexternaldialog.h \
disassemblerwindow.h \
gdbengine.h \
gdbmi.h \
gdboptionpage.h \
idebuggerengine.h \
imports.h \
moduleshandler.h \
......@@ -55,7 +54,6 @@ SOURCES += attachexternaldialog.cpp \
disassemblerwindow.cpp \
gdbengine.cpp \
gdbmi.cpp \
gdboptionpage.cpp \
gdbengine.h \
moduleshandler.cpp \
moduleswindow.cpp \
......
......@@ -86,6 +86,18 @@ using namespace Debugger::Constants;
static const QString tooltipIName = "tooltip";
DebuggerSettings::DebuggerSettings()
{
m_autoRun = false;
m_autoQuit = false;
m_skipKnownFrames = false;
m_debugDumpers = false;
m_useToolTips = false;
m_useToolTips = false;
m_useCustomDumpers = true;
}
///////////////////////////////////////////////////////////////////////
//
// BreakByFunctionDialog
......@@ -322,56 +334,6 @@ void DebuggerManager::init()
m_breakAtMainAction = new QAction(this);
m_breakAtMainAction->setText(tr("Set Breakpoint at Function 'main'"));
m_debugDumpersAction = new QAction(this);
m_debugDumpersAction->setText(tr("Debug Custom Dumpers"));
m_debugDumpersAction->setToolTip(tr("This is an internal tool to "
"make debugging the Custom Data Dumper code easier. "
"Using this action is in general not needed unless you "
"want do debug Qt Creator itself."));
m_debugDumpersAction->setCheckable(true);
m_skipKnownFramesAction = new QAction(this);
m_skipKnownFramesAction->setText(tr("Skip Known Frames When Stepping"));
m_skipKnownFramesAction->setToolTip(tr("After checking this option"
"'Step Into' combines in certain situations several steps, "
"leading to 'less noisy' debugging. So will, e.g., the atomic "
"reference counting code be skipped, and a single 'Step Into' "
"for a signal emission will end up directly in the slot connected "
"to it"));
m_skipKnownFramesAction->setCheckable(true);
m_useCustomDumpersAction = new QAction(this);
m_useCustomDumpersAction->setText(tr("Use Custom Display for Qt Objects"));
m_useCustomDumpersAction->setToolTip(tr("Checking this will make the debugger "
"try to use code to format certain data (QObject, QString, ...) nicely. "));
m_useCustomDumpersAction->setCheckable(true);
m_useCustomDumpersAction->setChecked(true);
m_useFastStartAction = new QAction(this);
m_useFastStartAction->setText(tr("Fast Debugger Start"));
m_useFastStartAction->setToolTip(tr("Checking this will make the debugger "
"start fast by loading only very few debug symbols on start up. This "
"might lead to situations where breakpoints can not be set properly. "
"So uncheck this option if you experience breakpoint related problems."));
m_useFastStartAction->setCheckable(true);
m_useFastStartAction->setChecked(true);
m_useToolTipsAction = new QAction(this);
m_useToolTipsAction->setText(tr("Use Tooltips While Debugging"));
m_useToolTipsAction->setToolTip(tr("Checking this will make enable "
"tooltips for variable values during debugging. Since this can slow "
"down debugging and does not provide reliable information as it does "
"not use scope information, it is switched off by default."));
m_useToolTipsAction->setCheckable(true);
m_useToolTipsAction->setChecked(false);
// FIXME
m_useFastStartAction->setChecked(false);
m_useFastStartAction->setEnabled(false);
m_dumpLogAction = new QAction(this);
m_dumpLogAction->setText(tr("Dump Log File for Debugging Purposes"));
m_watchAction = new QAction(this);
m_watchAction->setText(tr("Add to Watch Window"));
......@@ -416,14 +378,6 @@ void DebuggerManager::init()
connect(m_breakAtMainAction, SIGNAL(triggered()),
this, SLOT(breakAtMain()));
connect(m_useFastStartAction, SIGNAL(triggered()),
this, SLOT(saveSessionData()));
connect(m_useCustomDumpersAction, SIGNAL(triggered()),
this, SLOT(saveSessionData()));
connect(m_skipKnownFramesAction, SIGNAL(triggered()),
this, SLOT(saveSessionData()));
connect(m_dumpLogAction, SIGNAL(triggered()),
this, SLOT(dumpLog()));
connect(m_statusTimer, SIGNAL(timeout()),
this, SLOT(clearStatusMessage()));
......@@ -947,16 +901,6 @@ void DebuggerManager::loadSessionData()
{
m_breakHandler->loadSessionData();
m_watchHandler->loadSessionData();
QVariant value;
querySessionValue(QLatin1String("UseFastStart"), &value);
m_useFastStartAction->setChecked(value.toBool());
querySessionValue(QLatin1String("UseToolTips"), &value);
m_useToolTipsAction->setChecked(value.toBool());
querySessionValue(QLatin1String("UseCustomDumpers"), &value);
m_useCustomDumpersAction->setChecked(!value.isValid() || value.toBool());
querySessionValue(QLatin1String("SkipKnownFrames"), &value);
m_skipKnownFramesAction->setChecked(value.toBool());
engine()->loadSessionData();
}
......@@ -964,15 +908,6 @@ void DebuggerManager::saveSessionData()
{
m_breakHandler->saveSessionData();
m_watchHandler->saveSessionData();
setSessionValue(QLatin1String("UseFastStart"),
m_useFastStartAction->isChecked());
setSessionValue(QLatin1String("UseToolTips"),
m_useToolTipsAction->isChecked());
setSessionValue(QLatin1String("UseCustomDumpers"),
m_useCustomDumpersAction->isChecked());
setSessionValue(QLatin1String("SkipKnownFrames"),
m_skipKnownFramesAction->isChecked());
engine()->saveSessionData();
}
......@@ -1139,22 +1074,22 @@ void DebuggerManager::setBusyCursor(bool busy)
bool DebuggerManager::skipKnownFrames() const
{
return m_skipKnownFramesAction->isChecked();
return m_settings.m_skipKnownFrames;
}
bool DebuggerManager::debugDumpers() const
{
return m_debugDumpersAction->isChecked();
return m_settings.m_debugDumpers;
}
bool DebuggerManager::useCustomDumpers() const
{
return m_useCustomDumpersAction->isChecked();
return m_settings.m_useCustomDumpers;
}
bool DebuggerManager::useFastStart() const
{
return 0; // && m_useFastStartAction->isChecked();
return 0; // && m_settings.m_useFastStart;
}
void DebuggerManager::queryCurrentTextEditor(QString *fileName, int *lineNumber,
......
......@@ -167,8 +167,8 @@ private:
virtual WatchHandler *watchHandler() = 0;
virtual void showApplicationOutput(const QString &prefix, const QString &data) = 0;
virtual QAction *useCustomDumpersAction() const = 0;
virtual QAction *debugDumpersAction() const = 0;
//virtual QAction *useCustomDumpersAction() const = 0;
//virtual QAction *debugDumpersAction() const = 0;
virtual bool skipKnownFrames() const = 0;
virtual bool debugDumpers() const = 0;
virtual bool useCustomDumpers() const = 0;
......@@ -180,6 +180,30 @@ private:
};
//
// DebuggerSettings
//
class DebuggerSettings
{
public:
DebuggerSettings();
public:
QString m_gdbCmd;
QString m_gdbEnv;
bool m_autoRun;
bool m_autoQuit;
bool m_useCustomDumpers;
bool m_skipKnownFrames;
bool m_debugDumpers;
bool m_useFastStart;
bool m_useToolTips;
QString m_scriptFile;
};
//
// DebuggerManager
//
......@@ -196,6 +220,7 @@ public:
IDebuggerManagerAccessForEngines *engineInterface();
QMainWindow *mainWindow() const { return m_mainWindow; }
QLabel *statusLabel() const { return m_statusLabel; }
DebuggerSettings *settings() { return &m_settings; }
enum StartMode { startInternal, startExternal, attachExternal };
enum DebuggerType { GdbDebugger, ScriptDebugger, WinDebugger };
......@@ -286,9 +311,9 @@ private:
StackHandler *stackHandler() { return m_stackHandler; }
ThreadsHandler *threadsHandler() { return m_threadsHandler; }
WatchHandler *watchHandler() { return m_watchHandler; }
QAction *useCustomDumpersAction() const { return m_useCustomDumpersAction; }
QAction *useToolTipsAction() const { return m_useToolTipsAction; }
QAction *debugDumpersAction() const { return m_debugDumpersAction; }
//QAction *useCustomDumpersAction() const { return m_useCustomDumpersAction; }
//QAction *useToolTipsAction() const { return m_useToolTipsAction; }
//QAction *debugDumpersAction() const { return m_debugDumpersAction; }
bool skipKnownFrames() const;
bool debugDumpers() const;
bool useCustomDumpers() const;
......@@ -342,7 +367,6 @@ signals:
void setConfigValueRequested(const QString &name, const QVariant &value);
void applicationOutputAvailable(const QString &prefix, const QString &msg);
public:
// FIXME: make private
QString m_executable;
......@@ -406,13 +430,6 @@ private:
QAction *m_sepAction;
QAction *m_stepIAction;
QAction *m_nextIAction;
QAction *m_skipKnownFramesAction;
QAction *m_debugDumpersAction;
QAction *m_useCustomDumpersAction;
QAction *m_useFastStartAction;
QAction *m_useToolTipsAction;
QAction *m_dumpLogAction;
QWidget *m_breakWindow;
QWidget *m_disassemblerWindow;
......@@ -432,9 +449,9 @@ private:
IDebuggerEngine *engine();
IDebuggerEngine *m_engine;
DebuggerSettings m_settings;
};
} // namespace Internal
} // namespace Debugger
......
......@@ -36,12 +36,14 @@
#include "debuggerconstants.h"
#include "debuggermanager.h"
#include "debuggerrunner.h"
#include "gdboptionpage.h"
#include "gdbengine.h"
#include "ui_gdboptionpage.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/basemode.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/icore.h>
......@@ -53,6 +55,8 @@
#include <coreplugin/rightpane.h>
#include <coreplugin/uniqueidmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <cppeditor/cppeditorconstants.h>
......@@ -73,6 +77,7 @@
#include <QtCore/QSettings>
#include <QtCore/QtPlugin>
#include <QtGui/QLineEdit>
#include <QtGui/QDockWidget>
#include <QtGui/QMainWindow>
#include <QtGui/QPlainTextEdit>
......@@ -80,6 +85,8 @@
#include <QtGui/QTextCursor>
namespace ExtensionSystem { class PluginManager; }
using namespace Core;
using namespace Debugger::Constants;
using namespace Debugger::Internal;
......@@ -143,6 +150,12 @@ const char * const ADD_TO_WATCH_KEY = "Ctrl+Alt+Q";
} // namespace Debugger
///////////////////////////////////////////////////////////////////////
//
// DebugMode
//
///////////////////////////////////////////////////////////////////////
namespace Debugger {
namespace Internal {
......@@ -159,9 +172,6 @@ public:
void shutdown() {}
};
} // namespace Internal
} // namespace Debugger
DebugMode::DebugMode(QObject *parent)
: BaseMode(parent)
{
......@@ -177,6 +187,9 @@ DebugMode::~DebugMode()
EditorManager::instance()->setParent(0);
}
} // namespace Internal
} // namespace Debugger
///////////////////////////////////////////////////////////////////////
//
......@@ -184,8 +197,10 @@ DebugMode::~DebugMode()
//
///////////////////////////////////////////////////////////////////////
class Debugger::Internal::LocationMark
: public TextEditor::BaseTextMark
namespace Debugger {
namespace Internal {
class LocationMark : public TextEditor::BaseTextMark
{
Q_OBJECT
......@@ -212,6 +227,112 @@ QIcon LocationMark::icon() const
return icon;
}
} // namespace Internal
} // namespace Debugger
///////////////////////////////////////////////////////////////////////
//
// GdbOptionPage
//
///////////////////////////////////////////////////////////////////////
namespace Debugger {
namespace Internal {
class GdbOptionPage : public Core::IOptionsPage
{
Q_OBJECT
public:
GdbOptionPage(DebuggerPlugin *plugin) : m_plugin(plugin) {}
// IOptionsPage
QString name() const { return tr("Gdb"); }
QString category() const { return "Debugger"; }
QString trCategory() const { return tr("Debugger"); }
QWidget *createPage(QWidget *parent);
void apply();
void finish() {} // automatically calls "apply"
private:
Ui::GdbOptionPage m_ui;
DebuggerSettings m_settings;
DebuggerPlugin *m_plugin;
};
QWidget *GdbOptionPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
m_settings = *m_plugin->m_manager->settings();
m_ui.setupUi(w);
m_ui.gdbLocationChooser->setExpectedKind(Core::Utils::PathChooser::Command);
m_ui.gdbLocationChooser->setPromptDialogTitle(tr("Choose Gdb Location"));
m_ui.gdbLocationChooser->setPath(m_settings.m_gdbCmd);
m_ui.scriptFileChooser->setExpectedKind(Core::Utils::PathChooser::File);
m_ui.scriptFileChooser->setPromptDialogTitle(tr("Choose Location of Startup Script File"));
m_ui.scriptFileChooser->setPath(m_settings.m_scriptFile);
m_ui.environmentEdit->setText(m_settings.m_gdbEnv);
m_ui.autoStartBox->setChecked(m_settings.m_autoRun);
m_ui.autoQuitBox->setChecked(m_settings.m_autoQuit);
m_ui.checkBoxSkipKnownFrames->setChecked(m_settings.m_skipKnownFrames);
m_ui.checkBoxDebugDumpers->setChecked(m_settings.m_debugDumpers);
m_ui.checkBoxUseCustomDumpers->setChecked(m_settings.m_useCustomDumpers);
m_ui.checkBoxFastStart->setChecked(m_settings.m_useFastStart);
m_ui.checkBoxUseToolTips->setChecked(m_settings.m_useToolTips);
#ifndef QT_DEBUG
#if 0
cmd = am->registerAction(m_manager->m_dumpLogAction,
Constants::DUMP_LOG, globalcontext);
//cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+L")));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F11")));
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_debugDumpersAction,
Constants::DEBUG_DUMPERS, debuggercontext);
mdebug->addAction(cmd);
#endif
#endif
// FIXME
m_ui.autoStartBox->hide();
m_ui.autoQuitBox->hide();
m_ui.environmentEdit->hide();
m_ui.labelEnvironment->hide();
m_ui.checkBoxFastStart->setChecked(false);
m_ui.checkBoxFastStart->hide();
//m_dumpLogAction = new QAction(this);
//m_dumpLogAction->setText(tr("Dump Log File for Debugging Purposes"));
return w;
}
void GdbOptionPage::apply()
{
m_settings.m_gdbCmd = m_ui.gdbLocationChooser->path();
m_settings.m_gdbEnv = m_ui.environmentEdit->text();
m_settings.m_autoRun = m_ui.autoStartBox->isChecked();
m_settings.m_autoQuit = m_ui.autoQuitBox->isChecked();
m_settings.m_scriptFile = m_ui.scriptFileChooser->path();
m_settings.m_skipKnownFrames = m_ui.checkBoxSkipKnownFrames->isChecked();
m_settings.m_debugDumpers = m_ui.checkBoxDebugDumpers->isChecked();
m_settings.m_useCustomDumpers = m_ui.checkBoxUseCustomDumpers->isChecked();
m_settings.m_useFastStart = m_ui.checkBoxFastStart->isChecked();
m_settings.m_useToolTips = m_ui.checkBoxUseToolTips->isChecked();
*m_plugin->m_manager->settings() = m_settings;
m_plugin->writeSettings();
}
} // namespace Internal
} // namespace Debugger
///////////////////////////////////////////////////////////////////////
//
......@@ -409,34 +530,6 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep2"), globalcontext);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_skipKnownFramesAction,
Constants::SKIP_KNOWN_FRAMES, globalcontext);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_useCustomDumpersAction,
Constants::USE_CUSTOM_DUMPERS, globalcontext);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_useFastStartAction,
Constants::USE_FAST_START, globalcontext);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_useToolTipsAction,
Constants::USE_TOOL_TIPS, globalcontext);
mdebug->addAction(cmd);
#ifdef QT_DEBUG
cmd = am->registerAction(m_manager->m_dumpLogAction,
Constants::DUMP_LOG, globalcontext);
//cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+L")));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F11")));
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_debugDumpersAction,
Constants::DEBUG_DUMPERS, debuggercontext);
mdebug->addAction(cmd);
#endif
sep = new QAction(this);
sep->setSeparator(true);
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep4"), globalcontext);
......@@ -479,7 +572,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
m_generalOptionPage = 0;
// FIXME:
m_generalOptionPage = new GdbOptionPage(&theGdbSettings());
m_generalOptionPage = new GdbOptionPage(this);
addObject(m_generalOptionPage);
m_locationMark = 0;
......@@ -711,7 +804,7 @@ void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber
void DebuggerPlugin::showToolTip(TextEditor::ITextEditor *editor,
const QPoint &point, int pos)
{
if (!m_manager->useToolTipsAction()->isChecked())
if (!m_manager->settings()->m_useToolTips)
return;
QPlainTextEdit *plaintext = qobject_cast<QPlainTextEdit*>(editor->widget());
......@@ -799,22 +892,57 @@ void DebuggerPlugin::changeStatus(int status)
void DebuggerPlugin::writeSettings() const
{
QSettings *s = settings();
QTC_ASSERT(m_manager, return);
QTC_ASSERT(m_manager->mainWindow(), return);
QSettings *s = settings();
DebuggerSettings *m = m_manager->settings();
s->beginGroup(QLatin1String("DebugMode"));
s->setValue(QLatin1String("State"), m_manager->mainWindow()->saveState());
s->setValue(QLatin1String("Locked"), m_toggleLockedAction->isChecked());
s->setValue("State", m_manager->mainWindow()->saveState());
s->setValue("Locked", m_toggleLockedAction->isChecked());
s->setValue("Location", m->m_gdbCmd);
s->setValue("Environment", m->m_gdbEnv);
s->setValue("AutoRun", m->m_autoRun);
s->setValue("AutoQuit", m->m_autoQuit);
s->setValue("UseFastStart", m->m_useFastStart);
s->setValue("UseToolTips", m->m_useToolTips);
s->setValue("UseCustomDumpers", m->m_useCustomDumpers);
s->setValue("SkipKnowFrames", m->m_skipKnownFrames);
s->setValue("DebugDumpers", m->m_debugDumpers);
s->endGroup();
}
void DebuggerPlugin::readSettings()
{
QSettings *s = settings();
DebuggerSettings *m = &m_manager->m_settings;
QString defaultCommand("gdb");
#if defined(Q_OS_WIN32)
defaultCommand.append(".exe");
#endif
Core::ICore *coreIFace = m_pm->getObject<Core::ICore>();
QString defaultScript = coreIFace->resourcePath() +
QLatin1String("/gdb/qt4macros");
s->beginGroup(QLatin1String("DebugMode"));
m_manager->mainWindow()->restoreState(s->value(QLatin1String("State"), QByteArray()).toByteArray());
m_toggleLockedAction->setChecked(s->value(QLatin1String("Locked"), true).toBool());
QByteArray ba = s->value("State", QByteArray()).toByteArray();
m_toggleLockedAction->setChecked(s->value("Locked", true).toBool());
m->m_gdbCmd = s->value("Location", defaultCommand).toString();
m->m_scriptFile= s->value("ScriptFile", defaultScript).toString();
m->m_gdbEnv = s->value("Environment", "").toString();
m->m_autoRun = s->value("AutoRun", true).toBool();
m->m_autoQuit = s->value("AutoQuit", true).toBool();
m->m_skipKnownFrames = s->value("SkipKnownFrames", false).toBool();
m->m_debugDumpers = s->value("DebugDumpers", false).toBool();
m->m_useCustomDumpers = s->value("UseCustomDupers", false).toBool();
m->m_useFastStart = s->value("UseFastStart", false).toBool();
m->m_useToolTips = s->value("UseToolTips", false).toBool();
s->endGroup();
m_manager->mainWindow()->restoreState(ba);
}
void DebuggerPlugin::focusCurrentEditor(IMode *mode)
......
......@@ -78,7 +78,6 @@ private slots:
void changeStatus(int status);
void requestMark(TextEditor::ITextEditor *editor, int lineNumber);
void showToolTip(TextEditor::ITextEditor *editor, const QPoint &pnt, int pos);
void querySessionValue(const QString &name, QVariant *value);
void setSessionValue(const QString &name, const QVariant &value);
void queryConfigValue(const QString &name, QVariant *value);
......@@ -97,6 +96,7 @@ private:
void writeSettings() const;
friend class DebuggerManager;
friend class GdbOptionPage;
friend class DebugMode; // FIXME: Just a hack now so that it can access the views
ProjectExplorer::ProjectExplorerPlugin *projectExplorer() const;
......
......@@ -84,19 +84,6 @@ Q_DECLARE_METATYPE(Debugger::Internal::GdbMi);
static const QString tooltipIName = "tooltip";
///////////////////////////////////////////////////////////////////////
//
// GdbSettings
//
///////////////////////////////////////////////////////////////////////
GdbSettings &Debugger::Internal::theGdbSettings()
{
static GdbSettings settings;
return settings;
}
///////////////////////////////////////////////////////////////////////
//
// GdbCommandType
......@@ -265,7 +252,6 @@ void GdbEngine::init()
m_pendingRequests = 0;
m_gdbVersion = 100;