Commit fc46406f authored by hjk's avatar hjk

Debugger: Allow loading dumpers from a file directly

Instead of requiring the user to add the required python
code to load them manually let him specify a file directly.
This also makes the feature accessible to LLDB which needs
a slightly different syntax.

Task-number: QTCREATORBUG-12492
Change-Id: I12621b1cea2429476b0865bcbcb739a238dcf6af
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent a83548f1
......@@ -404,7 +404,13 @@ DebuggerSettings::DebuggerSettings()
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("GdbCustomDumperCommands"));
item->setDefaultValue(QString());
insertItem(GdbCustomDumperCommands, item);
insertItem(ExtraDumperCommands, item);
item = new SavedAction(this);
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("ExtraDumperFile"));
item->setDefaultValue(QString());
insertItem(ExtraDumperFile, item);
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("GdbPostAttachCommands"));
......
......@@ -110,6 +110,8 @@ enum DebuggerActionCode
RegisterForPostMortem,
AlwaysAdjustColumnWidths,
ExtraDumperFile, // For loading a file. Recommended.
ExtraDumperCommands, // To modify an existing setup.
// Cdb
CdbAdditionalArguments,
......@@ -126,7 +128,6 @@ enum DebuggerActionCode
LoadGdbDumpers,
AttemptQuickStart,
GdbStartupCommands,
GdbCustomDumperCommands,
GdbPostAttachCommands,
GdbWatchdogTimeout,
AutoEnrichParameters,
......
......@@ -1735,12 +1735,25 @@ void GdbEngine::handlePythonSetup(const GdbResponse &response)
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
if (response.resultClass == GdbResultDone) {
const QString commands = debuggerCore()->stringSetting(GdbCustomDumperCommands);
bool needSetup = false;
const QString path = debuggerCore()->stringSetting(ExtraDumperFile);
if (!path.isEmpty()) {
QFileInfo fi(path);
postCommand("python sys.path.insert(1, '" + fi.absolutePath().toUtf8() + "')");
postCommand("python from " + fi.baseName().toUtf8() + " import *");
needSetup = true;
}
const QString commands = debuggerCore()->stringSetting(ExtraDumperCommands);
if (!commands.isEmpty()) {
postCommand(commands.toLocal8Bit());
postCommand("bbsetup");
needSetup = true;
}
if (needSetup)
postCommand("bbsetup");
GdbMi data;
data.fromStringMultiple(response.consoleStreamOutput);
const GdbMi dumpers = data["dumpers"];
......
......@@ -41,6 +41,7 @@
#include <QDebug>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QTextEdit>
......@@ -63,7 +64,6 @@ public:
explicit GdbOptionsPageWidget(QWidget *parent = 0);
QGroupBox *groupBoxGeneral;
QLabel *labelGdbWatchdogTimeout;
QSpinBox *spinBoxGdbWatchdogTimeout;
QCheckBox *checkBoxSkipKnownFrames;
QCheckBox *checkBoxUseMessageBoxForSignals;
......@@ -80,6 +80,7 @@ public:
QTextEdit *textEditPostAttachCommands;
QGroupBox *groupBoxCustomDumperCommands;
QTextEdit *textEditCustomDumperCommands;
QLineEdit *extraDumperFile;
//QGroupBox *groupBoxPluginDebugging;
//QRadioButton *radioButtonAllPluginBreakpoints;
......@@ -99,7 +100,7 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
groupBoxGeneral = new QGroupBox(this);
groupBoxGeneral->setTitle(GdbOptionsPage::tr("General"));
labelGdbWatchdogTimeout = new QLabel(groupBoxGeneral);
QLabel *labelGdbWatchdogTimeout = new QLabel(groupBoxGeneral);
labelGdbWatchdogTimeout->setText(GdbOptionsPage::tr("GDB timeout:"));
labelGdbWatchdogTimeout->setToolTip(GdbOptionsPage::tr(
"The number of seconds Qt Creator will wait before it terminates\n"
......@@ -221,6 +222,10 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
textEditCustomDumperCommands->setAcceptRichText(false);
textEditCustomDumperCommands->setToolTip(groupBoxCustomDumperCommands->toolTip());
extraDumperFile = new QLineEdit(groupBoxCustomDumperCommands);
extraDumperFile->setToolTip(GdbOptionsPage::tr(
"Path to a Python file containing additional data dumpers."));
/*
groupBoxPluginDebugging = new QGroupBox(q);
groupBoxPluginDebugging->setTitle(GdbOptionsPage::tr(
......@@ -250,6 +255,7 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
VariableChooser::addVariableSupport(textEditCustomDumperCommands);
VariableChooser::addVariableSupport(textEditPostAttachCommands);
VariableChooser::addVariableSupport(textEditStartupCommands);
VariableChooser::addVariableSupport(extraDumperFile);
QFormLayout *formLayout = new QFormLayout(groupBoxGeneral);
formLayout->addRow(labelGdbWatchdogTimeout, spinBoxGdbWatchdogTimeout);
......@@ -268,8 +274,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);
QFormLayout *customDumperLayout = new QFormLayout(groupBoxCustomDumperCommands);
customDumperLayout->addRow(GdbOptionsPage::tr("Additional file:"), extraDumperFile);
customDumperLayout->addRow(textEditCustomDumperCommands);
//QHBoxLayout *horizontalLayout = new QHBoxLayout();
//horizontalLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Preferred, QSizePolicy::Minimum));
......@@ -292,7 +299,8 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
DebuggerCore *dc = debuggerCore();
group.insert(dc->action(GdbStartupCommands), textEditStartupCommands);
group.insert(dc->action(GdbCustomDumperCommands), textEditCustomDumperCommands);
group.insert(dc->action(ExtraDumperFile), extraDumperFile);
group.insert(dc->action(ExtraDumperCommands), textEditCustomDumperCommands);
group.insert(dc->action(GdbPostAttachCommands), textEditPostAttachCommands);
group.insert(dc->action(LoadGdbInit), checkBoxLoadGdbInit);
group.insert(dc->action(LoadGdbDumpers), checkBoxLoadGdbDumpers);
......
......@@ -275,6 +275,26 @@ void LldbEngine::setupInferior()
{
const DebuggerStartParameters &sp = startParameters();
const QString path = debuggerCore()->stringSetting(ExtraDumperFile);
if (!path.isEmpty()) {
QFileInfo fi(path);
Command cmd1("executeDebuggerCommand");
cmd1.arg("command", "python sys.path.insert(1, '" + fi.absolutePath().toUtf8() + "')");
runCommand(cmd1);
Command cmd2("executeDebuggerCommand");
cmd2.arg("python from " + fi.baseName().toUtf8() + " import *");
runCommand(cmd2);
}
const QString commands = debuggerCore()->stringSetting(ExtraDumperCommands);
if (!commands.isEmpty()) {
Command cmd("executeDebuggerCommand");
cmd.arg(commands.toUtf8());
runCommand(cmd);
}
QString executable;
Utils::QtcProcess::Arguments args;
Utils::QtcProcess::prepareCommand(QFileInfo(sp.executable).absoluteFilePath(),
......
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