Commit 85a1841f authored by hjk's avatar hjk Committed by hjk

debugger: add option to search debug info in well-known locations

Change-Id: I16e32f0e44fc628c7dca5270083a9bb1050769c1
Reviewed-on: http://codereview.qt-project.org/5371Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 3a110439
......@@ -349,6 +349,14 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
item->setValue(true);
insertItem(LoadGdbInit, item);
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("AutoEnrichParameters"));
item->setDefaultValue(QString());
item->setCheckable(true);
item->setDefaultValue(false);
item->setValue(false);
insertItem(AutoEnrichParameters, item);
item = new SavedAction(this);
item->setSettingsKey(debugModeGroup, QLatin1String("TargetAsync"));
item->setCheckable(true);
......
......@@ -55,17 +55,18 @@ public:
void toSettings(QSettings *) const;
void fromSettings(QSettings *);
bool equals(const GlobalDebuggerOptions &rhs) const { return sourcePathMap == rhs.sourcePathMap; }
bool operator==(const GlobalDebuggerOptions &rhs) const
{ return sourcePathMap == rhs.sourcePathMap; }
bool operator!=(const GlobalDebuggerOptions &rhs) const
{ return sourcePathMap != rhs.sourcePathMap; }
SourcePathMap sourcePathMap;
};
inline bool operator==(const GlobalDebuggerOptions &o1, const GlobalDebuggerOptions &o2) { return o1.equals(o2); }
inline bool operator!=(const GlobalDebuggerOptions &o1, const GlobalDebuggerOptions &o2) { return !o1.equals(o2); }
class DebuggerSettings : public QObject
{
Q_OBJECT // For tr().
public:
explicit DebuggerSettings(QSettings *setting);
~DebuggerSettings();
......@@ -118,6 +119,7 @@ enum DebuggerActionCode
LoadGdbInit,
GdbScriptFile,
GdbWatchdogTimeout,
AutoEnrichParameters,
TargetAsync,
// Stack
......
......@@ -1187,6 +1187,23 @@ static QString msgParameterMissing(const QString &a)
return DebuggerPlugin::tr("Option '%1' is missing the parameter.").arg(a);
}
static void maybeEnrichParameters(DebuggerStartParameters *sp)
{
if (!theDebuggerCore->boolSetting(AutoEnrichParameters))
return;
if (sp->debugInfoLocation.isEmpty())
sp->debugInfoLocation = sp->sysroot + "/usr/lib/debug";
if (sp->debugSourceLocation.isEmpty()) {
QString base = sp->sysroot + "/usr/src/debug/";
sp->debugSourceLocation.append(base + "qt5base/src/corelib");
sp->debugSourceLocation.append(base + "qt5base/src/gui");
sp->debugSourceLocation.append(base + "qt5base/src/network");
sp->debugSourceLocation.append(base + "qt5base/src/v8");
sp->debugSourceLocation.append(base + "qtdeclarative/src/declarative/qml");
}
}
bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
const QStringList::const_iterator &cend,
unsigned *enabledEngines, QString *errorMessage)
......@@ -1467,6 +1484,7 @@ void DebuggerPluginPrivate::attachExternalApplication()
sp.startMode = AttachExternal;
sp.toolChainAbi = dlg.abi();
sp.debuggerCommand = dlg.debuggerCommand();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1478,6 +1496,7 @@ void DebuggerPluginPrivate::attachExternalApplication(ProjectExplorer::RunContro
sp.displayName = tr("Debugger attached to %1").arg(rc->displayName());
sp.startMode = AttachExternal;
sp.toolChainAbi = rc->abi();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1509,6 +1528,7 @@ void DebuggerPluginPrivate::attachCore()
sp.toolChainAbi = dlg.abi();
sp.sysroot = dlg.sysroot();
sp.overrideStartScript = dlg.overrideStartScript();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1523,6 +1543,7 @@ void DebuggerPluginPrivate::attachRemote(const QString &spec)
sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel);
sp.startMode = AttachToRemoteServer;
sp.toolChainAbi = anyAbiOfBinary(sp.executable);
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1611,16 +1632,6 @@ bool DebuggerPluginPrivate::queryRemoteParameters(DebuggerStartParameters &sp, b
sp.serverStartScript = dlg.serverStartScript();
sp.sysroot = dlg.sysroot();
sp.debugInfoLocation = dlg.debugInfoLocation();
if (sp.debugInfoLocation.isEmpty())
sp.debugInfoLocation = sp.sysroot + "/usr/lib/debug";
if (sp.debugSourceLocation.isEmpty()) {
QString base = sp.sysroot + "/usr/src/debug/";
sp.debugSourceLocation.append(base + "qt5base/src/corelib");
sp.debugSourceLocation.append(base + "qt5base/src/gui");
sp.debugSourceLocation.append(base + "qt5base/src/network");
sp.debugSourceLocation.append(base + "qt5base/src/v8");
sp.debugSourceLocation.append(base + "qtdeclarative/src/declarative/qml");
}
return true;
}
......@@ -1628,9 +1639,11 @@ void DebuggerPluginPrivate::startRemoteApplication()
{
DebuggerStartParameters sp;
sp.startMode = StartRemote;
if (queryRemoteParameters(sp, true))
if (RunControl *rc = createDebugger(sp))
startDebugger(rc);
if (!queryRemoteParameters(sp, true))
return;
maybeEnrichParameters(&sp);
if (RunControl *rc = createDebugger(sp))
startDebugger(rc);
}
void DebuggerPluginPrivate::attachRemoteApplication()
......@@ -1641,6 +1654,7 @@ void DebuggerPluginPrivate::attachRemoteApplication()
sp.startMode = AttachToRemoteServer;
sp.useServerStartScript = false;
sp.serverStartScript.clear();
maybeEnrichParameters(&sp);
if (RunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......
......@@ -4759,6 +4759,12 @@ void GdbEngine::setupInferior()
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
showStatusMessage(tr("Setting up inferior..."));
const DebuggerStartParameters &sp = startParameters();
const QByteArray debugInfoLocation = sp.debugInfoLocation.toLocal8Bit();
if (!debugInfoLocation.isEmpty())
postCommand("set debug-file-directory " + debugInfoLocation);
foreach (const QString &src, sp.debugSourceLocation)
postCommand("directory " + src.toLocal8Bit());
m_gdbAdapter->setupInferior();
}
......
......@@ -90,6 +90,8 @@ QWidget *GdbOptionsPage::createPage(QWidget *parent)
m_ui->scriptFileChooser);
m_group.insert(debuggerCore()->action(LoadGdbInit),
m_ui->checkBoxLoadGdbInit);
m_group.insert(debuggerCore()->action(AutoEnrichParameters),
m_ui->checkBoxAutoEnrichParameters);
m_group.insert(debuggerCore()->action(TargetAsync),
m_ui->checkBoxTargetAsync);
m_group.insert(debuggerCore()->action(AdjustBreakpointLocations),
......
......@@ -123,20 +123,30 @@ on slow machines. In this case, the value should be increased.</string>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxAutoEnrichParameters">
<property name="toolTip">
<string>This adds common paths to locations of debug information at debugger startup.</string>
</property>
<property name="text">
<string>Use common locations for debug information automatically</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxBreakOnWarning">
<property name="text">
<string>Stop when a qWarning is issued</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxBreakOnFatal">
<property name="text">
<string>Stop when a qFatal is issued</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxEnableReverseDebugging">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Selecting this enables reverse debugging.&lt;/p&gt;&lt;.p&gt;&lt;b&gt;Note:&lt;/b&gt;This feature is very slow and unstable on the GDB side. It exhibits unpredictable behaviour when going backwards over system calls and is very likely to destroy your debugging session.&lt;/p&gt;&lt;body&gt;&lt;/html&gt;</string>
......
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