Debugger: Transform a few fields of DebuggerRunParameters

Transform macroExpander, exitCode, testCase.

Task-number: QTCREATORBUG-29168
Change-Id: Ibf6398ecc691191646ae84655802abe829793736
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-01-13 17:34:43 +01:00
parent e873f1ccbf
commit 36ed9f8c28
6 changed files with 20 additions and 21 deletions

View File

@@ -137,7 +137,7 @@ DebuggerRunParameters DebuggerRunParameters::fromRunControl(ProjectExplorer::Run
params.m_runAsRoot = runAsRootAspect->value; params.m_runAsRoot = runAsRootAspect->value;
params.setSysRoot(SysRootKitAspect::sysRoot(kit)); params.setSysRoot(SysRootKitAspect::sysRoot(kit));
params.macroExpander = runControl->macroExpander(); params.m_macroExpander = runControl->macroExpander();
params.m_debugger = DebuggerKitAspect::runnable(kit); params.m_debugger = DebuggerKitAspect::runnable(kit);
params.m_cppEngineType = DebuggerKitAspect::engineType(kit); params.m_cppEngineType = DebuggerKitAspect::engineType(kit);
params.m_version = DebuggerKitAspect::version(kit); params.m_version = DebuggerKitAspect::version(kit);
@@ -1157,7 +1157,7 @@ QString DebuggerEngine::stateName(int s)
void DebuggerEngine::notifyExitCode(int code) void DebuggerEngine::notifyExitCode(int code)
{ {
d->m_runParameters.exitCode = code; d->m_runParameters.setExitCode(code);
} }
void DebuggerEngine::showStatusMessage(const QString &msg, int timeout) const void DebuggerEngine::showStatusMessage(const QString &msg, int timeout) const
@@ -2133,7 +2133,7 @@ bool DebuggerEngine::canDisplayTooltip() const
QString DebuggerEngine::expand(const QString &string) const QString DebuggerEngine::expand(const QString &string) const
{ {
return runParameters().macroExpander->expand(string); return runParameters().macroExpander()->expand(string);
} }
QString DebuggerEngine::nativeStartupCommands() const QString DebuggerEngine::nativeStartupCommands() const
@@ -3111,7 +3111,7 @@ void CppDebuggerEngine::validateRunParameters(DebuggerRunParameters &rp)
globalRegExpSourceMap.reserve(sourcePathMap.size()); globalRegExpSourceMap.reserve(sourcePathMap.size());
for (auto it = sourcePathMap.begin(), end = sourcePathMap.end(); it != end; ++it) { for (auto it = sourcePathMap.begin(), end = sourcePathMap.end(); it != end; ++it) {
if (it.key().startsWith('(')) { if (it.key().startsWith('(')) {
const QString expanded = rp.macroExpander->expand(it.value()); const QString expanded = rp.macroExpander()->expand(it.value());
if (!expanded.isEmpty()) if (!expanded.isEmpty())
globalRegExpSourceMap.push_back({QRegularExpression(it.key()), expanded}); globalRegExpSourceMap.push_back({QRegularExpression(it.key()), expanded});
} }

View File

@@ -233,12 +233,13 @@ public:
bool isCppDebugging() const; bool isCppDebugging() const;
bool isNativeMixedDebugging() const; bool isNativeMixedDebugging() const;
const Utils::MacroExpander *macroExpander = nullptr; const Utils::MacroExpander *macroExpander() const { return m_macroExpander; }
std::optional<int> exitCode = {}; void setExitCode(int code) { m_exitCode = code; }
std::optional<int> exitCode() const { return m_exitCode; }
// For Debugger testing. void setTestCase(int testCase) { m_testCase = testCase; }
int testCase = 0; int testCase() const { return m_testCase; }
QStringList validationErrors; QStringList validationErrors;
@@ -331,6 +332,11 @@ private:
QString m_crashParameter; // Used by AttachCrashedExternal. QString m_crashParameter; // Used by AttachCrashedExternal.
bool m_nativeMixedEnabled = false; bool m_nativeMixedEnabled = false;
const Utils::MacroExpander *m_macroExpander = nullptr;
std::optional<int> m_exitCode = {};
int m_testCase = 0; // For Debugger testing.
}; };
namespace Internal { namespace Internal {

View File

@@ -103,11 +103,6 @@ public:
} // namespace Internal } // namespace Internal
void DebuggerRunTool::setTestCase(int testCase)
{
m_runParameters.testCase = testCase;
}
void DebuggerRunTool::addQmlServerInferiorCommandLineArgumentIfNeeded() void DebuggerRunTool::addQmlServerInferiorCommandLineArgumentIfNeeded()
{ {
d->addQmlServerInferiorCommandLineArgumentIfNeeded = true; d->addQmlServerInferiorCommandLineArgumentIfNeeded = true;
@@ -502,11 +497,11 @@ void DebuggerRunTool::handleEngineFinished(DebuggerEngine *engine)
{ {
engine->prepareForRestart(); engine->prepareForRestart();
if (--d->engineStopsNeeded == 0) { if (--d->engineStopsNeeded == 0) {
QString cmd = m_runParameters.inferior().command.toUserOutput(); const QString cmd = m_runParameters.inferior().command.toUserOutput();
QString msg = engine->runParameters().exitCode // Main engine. const QString msg = engine->runParameters().exitCode() // Main engine.
? Tr::tr("Debugging of %1 has finished with exit code %2.") ? Tr::tr("Debugging of %1 has finished with exit code %2.")
.arg(cmd) .arg(cmd)
.arg(*engine->runParameters().exitCode) .arg(*engine->runParameters().exitCode())
: Tr::tr("Debugging of %1 has finished.").arg(cmd); : Tr::tr("Debugging of %1 has finished.").arg(cmd);
appendMessage(msg, NormalMessageFormat); appendMessage(msg, NormalMessageFormat);
reportStopped(); reportStopped();

View File

@@ -32,8 +32,6 @@ public:
void setUseDebugServer(Utils::ProcessHandle attachPid, bool essential, bool useMulti); void setUseDebugServer(Utils::ProcessHandle attachPid, bool essential, bool useMulti);
void setTestCase(int testCase);
void kickoffTerminalProcess(); void kickoffTerminalProcess();
void interruptTerminal(); void interruptTerminal();

View File

@@ -110,7 +110,7 @@ void DebuggerUnitTests::testStateMachine()
DebuggerRunParameters &rp = debugger->runParameters(); DebuggerRunParameters &rp = debugger->runParameters();
rp.setInferior(rc->runnable()); rp.setInferior(rc->runnable());
debugger->setTestCase(TestNoBoundsOfCurrentFunction); rp.setTestCase(TestNoBoundsOfCurrentFunction);
connect(debugger, &DebuggerRunTool::stopped, connect(debugger, &DebuggerRunTool::stopped,
&QTestEventLoop::instance(), &QTestEventLoop::exitLoop); &QTestEventLoop::instance(), &QTestEventLoop::exitLoop);

View File

@@ -3813,7 +3813,7 @@ static SourcePathMap mergeStartParametersSourcePathMap(const DebuggerRunParamete
for (auto it = in.constBegin(), end = in.constEnd(); it != end; ++it) { for (auto it = in.constBegin(), end = in.constEnd(); it != end; ++it) {
// Entries that start with parenthesis are handled in CppDebuggerEngine::validateRunParameters // Entries that start with parenthesis are handled in CppDebuggerEngine::validateRunParameters
if (!it.key().startsWith('(')) if (!it.key().startsWith('('))
rc.insert(it.key(), sp.macroExpander->expand(it.value())); rc.insert(it.key(), sp.macroExpander()->expand(it.value()));
} }
return rc; return rc;
} }
@@ -4308,7 +4308,7 @@ bool GdbEngine::usesTargetAsync() const
void GdbEngine::scheduleTestResponse(int testCase, const QString &response) void GdbEngine::scheduleTestResponse(int testCase, const QString &response)
{ {
if (!m_testCases.contains(testCase) && runParameters().testCase != testCase) if (!m_testCases.contains(testCase) && runParameters().testCase() != testCase)
return; return;
int token = currentToken() + 1; int token = currentToken() + 1;