Implemented support for breakpoint caching in the GDB server
This commit is contained in:
@@ -36,7 +36,13 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
class CommandPacket: public Packet
|
||||
{
|
||||
public:
|
||||
explicit CommandPacket(const RawPacket& rawPacket): Packet(rawPacket) {}
|
||||
explicit CommandPacket(const RawPacket& rawPacket)
|
||||
: Packet(rawPacket)
|
||||
{}
|
||||
|
||||
virtual bool requiresBreakpointFlush() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should handle the command for the current active debug session.
|
||||
|
||||
@@ -28,6 +28,10 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
|
||||
explicit ContinueExecution(const RawPacket& rawPacket);
|
||||
|
||||
bool requiresBreakpointFlush() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
void handle(
|
||||
DebugSession& debugSession,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
|
||||
@@ -9,6 +9,10 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
public:
|
||||
explicit Detach(const RawPacket& rawPacket);
|
||||
|
||||
bool requiresBreakpointFlush() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
void handle(
|
||||
DebugSession& debugSession,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
|
||||
@@ -51,9 +51,18 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
}
|
||||
|
||||
void RemoveBreakpoint::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
|
||||
Logger::debug("Removing breakpoint at address " + std::to_string(this->address));
|
||||
Logger::debug("Handling RemoveBreakpoint packet");
|
||||
|
||||
try {
|
||||
if (debugSession.serverConfig.breakpointCachingEnabled) {
|
||||
debugSession.breakpointAddressesPendingRemoval.insert(this->address);
|
||||
debugSession.connection.writePacket(OkResponsePacket());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::debug("Removing breakpoint at address " + std::to_string(this->address));
|
||||
|
||||
targetControllerService.removeBreakpoint(TargetBreakpoint(this->address));
|
||||
debugSession.connection.writePacket(OkResponsePacket());
|
||||
|
||||
|
||||
@@ -54,7 +54,18 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
Logger::debug("Handling SetBreakpoint packet");
|
||||
|
||||
try {
|
||||
targetControllerService.setBreakpoint(TargetBreakpoint(this->address));
|
||||
if (
|
||||
!debugSession.serverConfig.breakpointCachingEnabled
|
||||
|| !debugSession.breakpointAddresses.contains(this->address)
|
||||
) {
|
||||
targetControllerService.setBreakpoint(TargetBreakpoint(this->address));
|
||||
}
|
||||
|
||||
if (debugSession.serverConfig.breakpointCachingEnabled) {
|
||||
debugSession.breakpointAddresses.insert(this->address);
|
||||
debugSession.breakpointAddressesPendingRemoval.erase(this->address);
|
||||
}
|
||||
|
||||
debugSession.connection.writePacket(OkResponsePacket());
|
||||
|
||||
} catch (const Exception& exception) {
|
||||
|
||||
@@ -23,6 +23,10 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
|
||||
explicit StepExecution(const RawPacket& rawPacket);
|
||||
|
||||
bool requiresBreakpointFlush() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void handle(
|
||||
DebugSession& debugSession,
|
||||
Services::TargetControllerService& targetControllerService
|
||||
|
||||
Reference in New Issue
Block a user