Implemented support for breakpoint caching in the GDB server

This commit is contained in:
Nav
2023-04-01 14:30:33 +01:00
parent 06b6c4460b
commit 3a74906541
13 changed files with 129 additions and 6 deletions

View File

@@ -154,7 +154,8 @@ namespace Bloom::DebugServer::Gdb
this->activeDebugSession.emplace(
std::move(connection),
this->getSupportedFeatures(),
this->getGdbTargetDescriptor()
this->getGdbTargetDescriptor(),
this->debugServerConfig
);
/*
@@ -183,6 +184,10 @@ namespace Bloom::DebugServer::Gdb
const auto commandPacket = this->waitForCommandPacket();
if (commandPacket) {
if (this->debugServerConfig.breakpointCachingEnabled && commandPacket->requiresBreakpointFlush()) {
this->flushBreakpointRemovals();
}
commandPacket->handle(this->activeDebugSession.value(), this->targetControllerService);
}
@@ -367,4 +372,28 @@ namespace Bloom::DebugServer::Gdb
return;
}
}
void GdbRspDebugServer::flushBreakpointRemovals() {
Logger::debug(
"Removing " + std::to_string(this->activeDebugSession->breakpointAddressesPendingRemoval.size())
+ " breakpoint(s)"
);
for (const auto& breakpointAddress : this->activeDebugSession->breakpointAddressesPendingRemoval) {
try {
Logger::debug("Removing breakpoint at address " + std::to_string(breakpointAddress));
this->targetControllerService.removeBreakpoint(Targets::TargetBreakpoint(breakpointAddress));
this->activeDebugSession->breakpointAddresses.erase(breakpointAddress);
} catch (const Exception& exception) {
Logger::error(
"Failed to remove breakpoint at address " + std::to_string(breakpointAddress) + " from target - "
+ exception.getMessage()
);
}
}
this->activeDebugSession->breakpointAddressesPendingRemoval.clear();
}
}