Files
BloomPatched/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp

50 lines
1.6 KiB
C++
Raw Normal View History

#include "StepExecution.hpp"
2022-03-31 21:52:46 +01:00
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
2021-04-04 21:04:12 +01:00
#include "src/Services/StringService.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/Exception.hpp"
2021-04-04 21:04:12 +01:00
namespace DebugServer::Gdb::CommandPackets
{
using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket;
using ::Exceptions::Exception;
2022-10-01 21:01:37 +01:00
StepExecution::StepExecution(const RawPacket& rawPacket)
: CommandPacket(rawPacket)
{
if (this->data.size() > 2) {
this->fromAddress = static_cast<Targets::TargetMemoryAddress>(
Services::StringService::toUint32(std::string{this->data.begin() + 2, this->data.end()}, 16)
);
}
2021-04-04 21:04:12 +01:00
}
void StepExecution::handle(
DebugSession& debugSession,
const TargetDescriptor& gdbTargetDescriptor,
const Targets::TargetDescriptor&,
TargetControllerService& targetControllerService
) {
Logger::info("Handling StepExecution packet");
try {
const auto atomicSession = targetControllerService.makeAtomicSession();
if (this->fromAddress.has_value()) {
targetControllerService.setProgramCounter(*(this->fromAddress));
}
targetControllerService.stepTargetExecution();
debugSession.waitingForBreak = true;
} catch (const Exception& exception) {
Logger::error("Failed to step execution on target - " + exception.getMessage());
debugSession.connection.writePacket(ErrorResponsePacket{});
}
}
2021-04-04 21:04:12 +01:00
}