diff --git a/src/plugins/baremetal/debugservers/gdb/eblinkgdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/eblinkgdbserverprovider.cpp index 1af7db4b99c..5219333d262 100644 --- a/src/plugins/baremetal/debugservers/gdb/eblinkgdbserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/gdb/eblinkgdbserverprovider.cpp @@ -79,7 +79,6 @@ public: bool operator==(const IDebugServerProvider &other) const final; - QString channelString() const final; Utils::CommandLine command() const final; QSet supportedStartupModes() const final; @@ -138,17 +137,6 @@ QString EBlinkGdbServerProvider::scriptFileWoExt() const return m_deviceScript.absolutePath().pathAppended(m_deviceScript.baseName()).path(); } -QString EBlinkGdbServerProvider::channelString() const -{ - switch (startupMode()) { - case StartupOnNetwork: - // Just return as "host:port" form. - return GdbServerProvider::channelString(); - default: - return {}; - } -} - CommandLine EBlinkGdbServerProvider::command() const { CommandLine cmd{m_executableFile}; diff --git a/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp index 6132d1b7640..07dd030408d 100644 --- a/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/gdb/gdbserverprovider.cpp @@ -130,7 +130,8 @@ void GdbServerProvider::toMap(Store &data) const bool GdbServerProvider::isValid() const { - return !channelString().isEmpty(); + return (m_startupMode == GdbServerProvider::StartupOnNetwork && channel().isValid()) || + (m_startupMode == GdbServerProvider::StartupOnPipe && !channelPipe().isEmpty()); } Result<> GdbServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp, @@ -155,7 +156,10 @@ Result<> GdbServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp rp.setStartMode(AttachToRemoteServer); rp.setCommandsAfterConnect(initCommands()); // .. and here? rp.setCommandsForReset(resetCommands()); - rp.setRemoteChannel(channelString()); + if (m_startupMode == GdbServerProvider::StartupOnNetwork) + rp.setRemoteChannel(channel()); + else + rp.setRemoteChannelPipe(channelPipe()); rp.setUseContinueInsteadOfRun(true); rp.setUseExtendedRemote(useExtendedRemote()); rp.setPeripheralDescriptionFile(m_peripheralDescriptionFile); diff --git a/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.cpp index d11bcd9fd89..94ab1ba2b47 100644 --- a/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/gdb/jlinkgdbserverprovider.cpp @@ -84,7 +84,6 @@ public: bool operator==(const IDebugServerProvider &other) const final; - QString channelString() const final; CommandLine command() const final; QSet supportedStartupModes() const final; @@ -130,17 +129,6 @@ QString JLinkGdbServerProvider::defaultResetCommands() return {"monitor reset halt\n"}; } -QString JLinkGdbServerProvider::channelString() const -{ - switch (startupMode()) { - case StartupOnNetwork: - // Just return as "host:port" form. - return GdbServerProvider::channelString(); - default: // wrong - return {}; - } -} - CommandLine JLinkGdbServerProvider::command() const { CommandLine cmd{m_executableFile}; diff --git a/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.cpp index 3f964a4865d..e7418a9a04a 100644 --- a/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/gdb/openocdgdbserverprovider.cpp @@ -60,7 +60,7 @@ public: bool operator==(const IDebugServerProvider &other) const final; - QString channelString() const final; + QString channelPipe() const final; Utils::CommandLine command() const final; QSet supportedStartupModes() const final; @@ -105,28 +105,17 @@ QString OpenOcdGdbServerProvider::defaultResetCommands() return {"monitor reset halt\n"}; } -QString OpenOcdGdbServerProvider::channelString() const +QString OpenOcdGdbServerProvider::channelPipe() const { - switch (startupMode()) { - case StartupOnNetwork: - // Just return as "host:port" form. - return GdbServerProvider::channelString(); - case StartupOnPipe: { - // In the pipe mode need to add quotes to each item of arguments; - // otherwise running will be stuck. - CommandLine cmd = command(); - QStringList args = {"|", cmd.executable().path()}; - for (const QString &a : ProcessArgs::splitArgs(cmd.arguments(), HostOsInfo::hostOs())) { - if (a.startsWith('\"') && a.endsWith('\"')) - args << a; - else - args << ('\"' + a + '\"'); - } - return args.join(' '); - } - default: // wrong - return {}; + CommandLine cmd = command(); + QStringList args = {cmd.executable().path()}; + for (const QString &a : ProcessArgs::splitArgs(cmd.arguments(), HostOsInfo::hostOs())) { + if (a.startsWith('\"') && a.endsWith('\"')) + args << a; + else + args << ('\"' + a + '\"'); } + return args.join(' '); } CommandLine OpenOcdGdbServerProvider::command() const diff --git a/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.cpp b/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.cpp index 96a94dc609c..347524d77fe 100644 --- a/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/gdb/stlinkutilgdbserverprovider.cpp @@ -72,7 +72,6 @@ public: bool operator==(const IDebugServerProvider &other) const final; - QString channelString() const final; Utils::CommandLine command() const final; QSet supportedStartupModes() const final; @@ -115,20 +114,6 @@ QString StLinkUtilGdbServerProvider::defaultResetCommands() return {}; } -QString StLinkUtilGdbServerProvider::channelString() const -{ - switch (startupMode()) { - case StartupOnNetwork: - // Just return as "host:port" form. - return GdbServerProvider::channelString(); - case StartupOnPipe: - // Unsupported mode - return {}; - default: // wrong - return {}; - } -} - CommandLine StLinkUtilGdbServerProvider::command() const { CommandLine cmd{m_executableFile}; diff --git a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp index 8bc4385c628..b048316f71c 100644 --- a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp +++ b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.cpp @@ -154,11 +154,6 @@ bool UvscServerProvider::isValid() const return m_channel.isValid(); } -QString UvscServerProvider::channelString() const -{ - return m_channel.toString(); -} - Result<> UvscServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &rp, RunControl *runControl) const { @@ -190,7 +185,7 @@ Result<> UvscServerProvider::setupDebuggerRunParameters(DebuggerRunParameters &r rp.setInferior(inferior); rp.setSymbolFile(bin); rp.setStartMode(AttachToRemoteServer); - rp.setRemoteChannel(channelString()); + rp.setRemoteChannel(channelPipe()); rp.setUseContinueInsteadOfRun(true); return ResultOk; } diff --git a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h index 61636cd0319..d9582ae69ef 100644 --- a/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h +++ b/src/plugins/baremetal/debugservers/uvsc/uvscserverprovider.h @@ -52,7 +52,6 @@ public: ProjectExplorer::RunWorker *targetRunner(ProjectExplorer::RunControl *runControl) const final; bool isValid() const override; - QString channelString() const final; static QString buildDllRegistryKey(const Uv::DriverSelection &driver); static QString adjustFlashAlgorithmProperty(const QString &property); diff --git a/src/plugins/baremetal/idebugserverprovider.cpp b/src/plugins/baremetal/idebugserverprovider.cpp index 0f62f1509b6..885a48e0873 100644 --- a/src/plugins/baremetal/idebugserverprovider.cpp +++ b/src/plugins/baremetal/idebugserverprovider.cpp @@ -83,9 +83,9 @@ QUrl IDebugServerProvider::channel() const return m_channel; } -QString IDebugServerProvider::channelString() const +QString IDebugServerProvider::channelPipe() const { - return m_channel.toString(); + return {}; } QString IDebugServerProvider::id() const diff --git a/src/plugins/baremetal/idebugserverprovider.h b/src/plugins/baremetal/idebugserverprovider.h index 375e2021a35..6396711bad3 100644 --- a/src/plugins/baremetal/idebugserverprovider.h +++ b/src/plugins/baremetal/idebugserverprovider.h @@ -53,7 +53,7 @@ public: void setChannel(const QUrl &channel); void setChannel(const QString &host, int port); - virtual QString channelString() const; + virtual QString channelPipe() const; QString id() const; QString typeDisplayName() const;