Commit d27d5105 authored by hjk's avatar hjk

Debugger: Use kit macro expander instead of global one where possible

This is low hanging fruit enabling a lot more customization.

Change-Id: I1a90fa731ea512852c12a55fad75551efb44e875
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 3c2f0096
......@@ -549,7 +549,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
arguments << QLatin1String("-srcpath") << sourcePaths.join(QLatin1Char(';'));
// Compile argument string preserving quotes
QString nativeArguments = stringSetting(CdbAdditionalArguments);
QString nativeArguments = expand(stringSetting(CdbAdditionalArguments));
switch (sp.startMode) {
case StartInternal:
case StartExternal:
......
......@@ -1340,6 +1340,16 @@ void DebuggerEngine::removeBreakpointMarker(const Breakpoint &bp)
d->m_disassemblerAgent.removeBreakpointMarker(bp);
}
QString DebuggerEngine::expand(const QString &string) const
{
return d->m_runParameters.macroExpander->expand(string);
}
QByteArray DebuggerEngine::expand(const QByteArray &string) const
{
return d->m_runParameters.macroExpander->expand(string);
}
void DebuggerEngine::updateBreakpointMarker(const Breakpoint &bp)
{
d->m_disassemblerAgent.updateBreakpointMarker(bp);
......
......@@ -44,6 +44,7 @@ class QAbstractItemModel;
QT_END_NAMESPACE
namespace Core { class IOptionsPage; }
namespace Utils { class MacroExpander; }
namespace Debugger {
......@@ -112,6 +113,8 @@ public:
bool nativeMixedEnabled = false;
Utils::MacroExpander *macroExpander = 0;
// For Debugger testing.
int testCase = 0;
};
......@@ -319,6 +322,9 @@ public:
void updateBreakpointMarker(const Breakpoint &bp);
void removeBreakpointMarker(const Breakpoint &bp);
QString expand(const QString &string) const;
QByteArray expand(const QByteArray &string) const;
signals:
void stateChanged(Debugger::DebuggerState state);
// A new stack frame is on display including locals.
......
......@@ -2929,8 +2929,7 @@ bool boolSetting(int code)
QString stringSetting(int code)
{
QString raw = dd->m_debuggerSettings->item(code)->value().toString();
return globalMacroExpander()->expand(raw);
return dd->m_debuggerSettings->item(code)->value().toString();
}
QStringList stringListSetting(int code)
......
......@@ -399,6 +399,8 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
return;
}
m_rp.macroExpander = m_kit->macroExpander();
if (m_runConfig) {
if (auto envAspect = m_runConfig->extraAspect<EnvironmentAspect>()) {
m_rp.inferior.environment = envAspect->environment(); // Correct.
......
......@@ -4186,7 +4186,7 @@ void GdbEngine::loadInitScript()
).arg(script));
}
} else {
const QString commands = stringSetting(GdbStartupCommands);
const QString commands = expand(stringSetting(GdbStartupCommands));
if (!commands.isEmpty())
runCommand({commands.toLocal8Bit(), NoFlags});
}
......@@ -4258,7 +4258,7 @@ void GdbEngine::abortDebugger()
void GdbEngine::resetInferior()
{
if (!runParameters().commandsForReset.isEmpty()) {
QByteArray commands = globalMacroExpander()->expand(runParameters().commandsForReset);
const QByteArray commands = expand(runParameters().commandsForReset);
foreach (QByteArray command, commands.split('\n')) {
command = command.trimmed();
if (!command.isEmpty())
......@@ -4300,7 +4300,7 @@ void GdbEngine::handleInferiorPrepared()
CHECK_STATE(InferiorSetupRequested);
if (!rp.commandsAfterConnect.isEmpty()) {
QByteArray commands = globalMacroExpander()->expand(rp.commandsAfterConnect);
const QByteArray commands = expand(rp.commandsAfterConnect);
foreach (QByteArray command, commands.split('\n'))
runCommand({command, NoFlags});
}
......
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