Suspend TargetController upon GDB detach, if running under CLion
This commit is contained in:
@@ -38,12 +38,6 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
return;
|
||||
}
|
||||
|
||||
if (packetString[0] == 'D') {
|
||||
// Detach packet - there's not really anything we need to do here, so just respond with an OK
|
||||
debugSession.connection.writePacket(OkResponsePacket());
|
||||
return;
|
||||
}
|
||||
|
||||
if (packetString.find("vMustReplyEmpty") == 0) {
|
||||
Logger::debug("Handling vMustReplyEmpty");
|
||||
debugSession.connection.writePacket(EmptyResponsePacket());
|
||||
|
||||
38
src/DebugServer/Gdb/CommandPackets/Detach.cpp
Normal file
38
src/DebugServer/Gdb/CommandPackets/Detach.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "Detach.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp"
|
||||
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
||||
|
||||
#include "src/Helpers/Process.hpp"
|
||||
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
{
|
||||
using TargetController::TargetControllerConsole;
|
||||
|
||||
using ResponsePackets::OkResponsePacket;
|
||||
using ResponsePackets::ErrorResponsePacket;
|
||||
|
||||
using Exceptions::Exception;
|
||||
|
||||
Detach::Detach(const RawPacketType& rawPacket)
|
||||
: CommandPacket(rawPacket)
|
||||
{}
|
||||
|
||||
void Detach::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
|
||||
Logger::debug("Handling Detach packet");
|
||||
|
||||
try {
|
||||
if (Process::isProcessManagedByClion(Process::getParentProcessId())) {
|
||||
targetControllerConsole.suspendTargetController();
|
||||
}
|
||||
|
||||
debugSession.connection.writePacket(OkResponsePacket());
|
||||
|
||||
} catch (const Exception& exception) {
|
||||
Logger::error("Failed to suspend TargetController - " + exception.getMessage());
|
||||
debugSession.connection.writePacket(ErrorResponsePacket());
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/DebugServer/Gdb/CommandPackets/Detach.hpp
Normal file
17
src/DebugServer/Gdb/CommandPackets/Detach.hpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "CommandPacket.hpp"
|
||||
|
||||
namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
{
|
||||
class Detach: public CommandPacket
|
||||
{
|
||||
public:
|
||||
explicit Detach(const RawPacketType& rawPacket);
|
||||
|
||||
void handle(
|
||||
DebugSession& debugSession,
|
||||
TargetController::TargetControllerConsole& targetControllerConsole
|
||||
) override;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user