Commit 76fc9722 authored by hjk's avatar hjk
Browse files

Debugger: Add specific customization hook for dumper initialization



We need to distiguish between start of GDB itself (a.k.a .gdbinit-style
customization) and after the dumper machinery is initialized, which is
nowadays often delayed until the first stop hook.

Change-Id: I40f1e7225c2043b8bcb7d50eef948bb3c9162bb6
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent c1404421
......@@ -382,6 +382,9 @@ def registerDumper(function):
def bbsetup(args = ''):
global qqDumpers, qqFormats, qqEditable, typeCache
qqDumpers = {}
qqFormats = {}
qqEditable = {}
typeCache = {}
module = sys.modules[__name__]
......
......@@ -447,6 +447,11 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
insertItem(GdbStartupCommands, item);
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("GdbCustomDumperCommands"));
item->setDefaultValue(QString());
insertItem(GdbCustomDumperCommands, item);
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("GdbPostAttachCommands"));
item->setDefaultValue(QString());
insertItem(GdbPostAttachCommands, item);
......
......@@ -130,6 +130,7 @@ enum DebuggerActionCode
LoadGdbDumpers,
AttemptQuickStart,
GdbStartupCommands,
GdbCustomDumperCommands,
GdbPostAttachCommands,
GdbWatchdogTimeout,
AutoEnrichParameters,
......
......@@ -1854,6 +1854,12 @@ void GdbEngine::handleHasPython(const GdbResponse &response)
void GdbEngine::handlePythonSetup(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
const QString commands = debuggerCore()->stringSetting(GdbCustomDumperCommands);
if (!commands.isEmpty()) {
postCommand(commands.toLocal8Bit());
postCommand("bbsetup");
}
postCommand("python qqStringCutOff = "
+ debuggerCore()->action(MaximalStringLength)->value().toByteArray(),
ConsoleCommand|NonCriticalResponse);
......@@ -4972,6 +4978,7 @@ void GdbEngine::tryLoadPythonDumpers()
postCommand("python execfile('" + dumperSourcePath + "gbridge.py')",
ConsoleCommand, CB(handlePythonSetup));
}
void GdbEngine::reloadDebuggingHelpers()
......
......@@ -72,6 +72,8 @@ public:
QTextEdit *textEditStartupCommands;
QGroupBox *groupBoxPostAttachCommands;
QTextEdit *textEditPostAttachCommands;
QGroupBox *groupBoxCustomDumperCommands;
QTextEdit *textEditCustomDumperCommands;
//QGroupBox *groupBoxPluginDebugging;
//QRadioButton *radioButtonAllPluginBreakpoints;
......@@ -167,20 +169,21 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
"<b>Note:</b>This feature needs special support from the Linux "
"distribution and GDB build and is not everywhere available.</p></body></html>"));
groupBoxStartupCommands = new QGroupBox(this);
groupBoxStartupCommands->setTitle(GdbOptionsPage::tr("Additional Startup Commands"));
groupBoxStartupCommands->setToolTip(GdbOptionsPage::tr(
"<html><head/><body><p>GDB commands entered here will be executed after "
"GDB has been started and the debugging helpers have been initialized.</p>"
"<p>You can add commands to load further debugging helpers here, or "
"modify existing ones.</p>"
QString howToUsePython = GdbOptionsPage::tr(
"<p>To execute simple Python commands, prefix them with \"python\".</p>"
"<p>To execute sequences of Python commands spanning multiple lines "
"prepend the block with \"python\" on a separate line, and append "
"\"end\" on a separate line.</p>"
"<p>To execute arbitrary Python scripts, "
"use <i>python execfile('/path/to/script.py')</i>.</p>"
"</body></html>"));
"use <i>python execfile('/path/to/script.py')</i>.</p>");
groupBoxStartupCommands = new QGroupBox(this);
groupBoxStartupCommands->setTitle(GdbOptionsPage::tr("Additional Startup Commands"));
groupBoxStartupCommands->setToolTip(GdbOptionsPage::tr(
"<html><head/><body><p>GDB commands entered here will be executed after "
"GDB has been started, but before the debugged program is started or "
"attached, and before the debugging helpers are initialized.</p>%1"
"<body></html>").arg(howToUsePython));
textEditStartupCommands = new QTextEdit(groupBoxStartupCommands);
textEditStartupCommands->setAcceptRichText(false);
......@@ -199,6 +202,18 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
textEditPostAttachCommands->setAcceptRichText(false);
textEditPostAttachCommands->setToolTip(groupBoxPostAttachCommands->toolTip());
groupBoxCustomDumperCommands = new QGroupBox(this);
groupBoxCustomDumperCommands->setTitle(GdbOptionsPage::tr("Debugging Helper Customization"));
groupBoxCustomDumperCommands->setToolTip(GdbOptionsPage::tr(
"<html><head/><body><p>GDB commands entered here will be executed after "
"Qt Creator's debugging helpers have been loaded and fully initialized. "
"You can load additional debugging helpers or modify existing ones here.</p>"
"%1</body></html>").arg(howToUsePython));
textEditCustomDumperCommands = new QTextEdit(groupBoxStartupCommands);
textEditCustomDumperCommands->setAcceptRichText(false);
textEditCustomDumperCommands->setToolTip(groupBoxStartupCommands->toolTip());
/*
groupBoxPluginDebugging = new QGroupBox(q);
groupBoxPluginDebugging->setTitle(GdbOptionsPage::tr(
......@@ -242,6 +257,9 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
QGridLayout *postAttachLayout = new QGridLayout(groupBoxPostAttachCommands);
postAttachLayout->addWidget(textEditPostAttachCommands, 0, 0, 1, 1);
QGridLayout *customDumperLayout = new QGridLayout(groupBoxCustomDumperCommands);
customDumperLayout->addWidget(textEditCustomDumperCommands, 0, 0, 1, 1);
//QHBoxLayout *horizontalLayout = new QHBoxLayout();
//horizontalLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Preferred, QSizePolicy::Minimum));
//horizontalLayout->addWidget(labelSelectedPluginBreakpoints);
......@@ -251,6 +269,7 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
gridLayout->addWidget(groupBoxGeneral, 0, 0, 2, 1);
gridLayout->addWidget(groupBoxStartupCommands, 0, 1, 1, 1);
gridLayout->addWidget(groupBoxPostAttachCommands, 1, 1, 1, 1);
gridLayout->addWidget(groupBoxCustomDumperCommands, 2, 1, 1, 1);
//gridLayout->addWidget(groupBoxStartupCommands, 0, 1, 1, 1);
//gridLayout->addWidget(radioButtonAllPluginBreakpoints, 0, 0, 1, 1);
......@@ -262,6 +281,7 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
DebuggerCore *dc = debuggerCore();
group.insert(dc->action(GdbStartupCommands), textEditStartupCommands);
group.insert(dc->action(GdbCustomDumperCommands), textEditCustomDumperCommands);
group.insert(dc->action(GdbPostAttachCommands), textEditPostAttachCommands);
group.insert(dc->action(LoadGdbInit), checkBoxLoadGdbInit);
group.insert(dc->action(LoadGdbDumpers), checkBoxLoadGdbDumpers);
......
Supports Markdown
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