New clion_adaptation environment config param, to allow for use of Bloom with CLion's new "debug server" functionality
This commit is contained in:
@@ -13,8 +13,12 @@ namespace DebugServer
|
||||
{
|
||||
using namespace Events;
|
||||
|
||||
DebugServerComponent::DebugServerComponent(const DebugServerConfig& debugServerConfig)
|
||||
: debugServerConfig(debugServerConfig)
|
||||
DebugServerComponent::DebugServerComponent(
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const DebugServerConfig& debugServerConfig
|
||||
)
|
||||
: environmentConfig(environmentConfig)
|
||||
, debugServerConfig(debugServerConfig)
|
||||
, targetDescriptor((Services::TargetControllerService()).getTargetDescriptor())
|
||||
{}
|
||||
|
||||
@@ -49,6 +53,7 @@ namespace DebugServer
|
||||
}
|
||||
|
||||
return std::make_unique<DebugServer::Gdb::AvrGdb::AvrGdbRsp>(
|
||||
this->environmentConfig,
|
||||
this->debugServerConfig,
|
||||
this->targetDescriptor,
|
||||
*(this->eventListener.get()),
|
||||
@@ -64,6 +69,7 @@ namespace DebugServer
|
||||
}
|
||||
|
||||
return std::make_unique<DebugServer::Gdb::RiscVGdb::RiscVGdbRsp>(
|
||||
this->environmentConfig,
|
||||
this->debugServerConfig,
|
||||
this->targetDescriptor,
|
||||
*(this->eventListener.get()),
|
||||
|
||||
@@ -25,7 +25,10 @@ namespace DebugServer
|
||||
class DebugServerComponent: public Thread
|
||||
{
|
||||
public:
|
||||
explicit DebugServerComponent(const DebugServerConfig& debugServerConfig);
|
||||
explicit DebugServerComponent(
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const DebugServerConfig& debugServerConfig
|
||||
);
|
||||
|
||||
/**
|
||||
* Entry point for the DebugServer. This must called from a dedicated thread.
|
||||
@@ -44,9 +47,7 @@ namespace DebugServer
|
||||
*/
|
||||
EventListenerPointer eventListener = std::make_shared<EventListener>("DebugServerEventListener");
|
||||
|
||||
/**
|
||||
* Project configuration for the debug server (extracted from the user project's bloom.yaml).
|
||||
*/
|
||||
EnvironmentConfig environmentConfig;
|
||||
DebugServerConfig debugServerConfig;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,12 +29,14 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
using Targets::TargetRegisterType;
|
||||
|
||||
AvrGdbRsp::AvrGdbRsp(
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
EventListener& eventListener,
|
||||
EventFdNotifier& eventNotifier
|
||||
)
|
||||
: GdbRspDebugServer(
|
||||
environmentConfig,
|
||||
debugServerConfig,
|
||||
targetDescriptor,
|
||||
AvrGdbTargetDescriptor{targetDescriptor},
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace DebugServer::Gdb::AvrGdb
|
||||
{
|
||||
public:
|
||||
AvrGdbRsp(
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
EventListener& eventListener,
|
||||
|
||||
@@ -16,8 +16,9 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
|
||||
using ::Exceptions::Exception;
|
||||
|
||||
Detach::Detach(const RawPacket& rawPacket)
|
||||
Detach::Detach(const RawPacket& rawPacket, const EnvironmentConfig& environmentConfig)
|
||||
: CommandPacket(rawPacket)
|
||||
, environmentConfig(environmentConfig)
|
||||
{}
|
||||
|
||||
void Detach::handle(
|
||||
@@ -29,7 +30,14 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
Logger::info("Handling Detach packet");
|
||||
|
||||
try {
|
||||
if (Services::ProcessService::isManagedByClion()) {
|
||||
if (this->environmentConfig.clionAdaptation && Services::ProcessService::isManagedByClion()) {
|
||||
/*
|
||||
* CLion is about to kill Bloom's process. This is our last chance to detach from the target and
|
||||
* disconnect from the debug tool, cleanly.
|
||||
*
|
||||
* So we have to force the TC to shut down immediately, to prevent CLion from killing Bloom and leaving
|
||||
* the debug tool and target in an undefined state.
|
||||
*/
|
||||
targetControllerService.shutdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
#include "src/ProjectConfig.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::CommandPackets
|
||||
{
|
||||
class Detach: public CommandPacket
|
||||
{
|
||||
public:
|
||||
explicit Detach(const RawPacket& rawPacket);
|
||||
explicit Detach(const RawPacket& rawPacket, const EnvironmentConfig& environmentConfig);
|
||||
|
||||
void handle(
|
||||
DebugSession& debugSession,
|
||||
@@ -15,5 +17,8 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
) override;
|
||||
|
||||
private:
|
||||
const EnvironmentConfig& environmentConfig;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -86,13 +86,15 @@ namespace DebugServer::Gdb
|
||||
{
|
||||
public:
|
||||
explicit GdbRspDebugServer(
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
GdbTargetDescriptorType&& gdbTargetDescriptor,
|
||||
EventListener& eventListener,
|
||||
EventFdNotifier& eventNotifier
|
||||
)
|
||||
: debugServerConfig(GdbDebugServerConfig{debugServerConfig})
|
||||
: environmentConfig(environmentConfig)
|
||||
, debugServerConfig(GdbDebugServerConfig{debugServerConfig})
|
||||
, targetDescriptor(targetDescriptor)
|
||||
, gdbTargetDescriptor(std::move(gdbTargetDescriptor))
|
||||
, eventListener(eventListener)
|
||||
@@ -179,9 +181,10 @@ namespace DebugServer::Gdb
|
||||
std::bind(&GdbRspDebugServer::onTargetStateChanged, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
if (Services::ProcessService::isManagedByClion()) {
|
||||
if (this->environmentConfig.clionAdaptation && Services::ProcessService::isManagedByClion()) {
|
||||
Logger::warning(
|
||||
"Bloom's process is being managed by CLion - Bloom will automatically shutdown upon detaching from GDB."
|
||||
"Bloom's process is being managed by CLion - Bloom will automatically shut down upon"
|
||||
" detaching from GDB."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -286,6 +289,7 @@ namespace DebugServer::Gdb
|
||||
}
|
||||
|
||||
protected:
|
||||
const EnvironmentConfig& environmentConfig;
|
||||
GdbDebugServerConfig debugServerConfig;
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
GdbTargetDescriptorType gdbTargetDescriptor;
|
||||
@@ -434,7 +438,7 @@ namespace DebugServer::Gdb
|
||||
}
|
||||
|
||||
if (rawPacket[1] == 'D') {
|
||||
return std::make_unique<CommandPackets::Detach>(rawPacket);
|
||||
return std::make_unique<CommandPackets::Detach>(rawPacket, this->environmentConfig);
|
||||
}
|
||||
|
||||
const auto rawPacketString = std::string{rawPacket.begin() + 1, rawPacket.end()};
|
||||
|
||||
@@ -26,12 +26,14 @@ namespace DebugServer::Gdb::RiscVGdb
|
||||
using Targets::TargetRegisterType;
|
||||
|
||||
RiscVGdbRsp::RiscVGdbRsp(
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
EventListener& eventListener,
|
||||
EventFdNotifier& eventNotifier
|
||||
)
|
||||
: GdbRspDebugServer(
|
||||
environmentConfig,
|
||||
debugServerConfig,
|
||||
targetDescriptor,
|
||||
RiscVGdbTargetDescriptor{targetDescriptor},
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace DebugServer::Gdb::RiscVGdb
|
||||
{
|
||||
public:
|
||||
RiscVGdbRsp(
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const DebugServerConfig& debugServerConfig,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
EventListener& eventListener,
|
||||
|
||||
Reference in New Issue
Block a user