diff --git a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp index 74d4ffeb..e0d5e155 100644 --- a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp +++ b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp @@ -156,6 +156,7 @@ void GdbRspDebugServer::waitForConnection() { Logger::info("Accepted GDP RSP connection from " + this->clientConnection->getIpAddress()); this->eventManager.triggerEvent(std::make_shared()); + } else { // This method should not return until a connection has been established (or an exception is thrown) return this->waitForConnection(); diff --git a/src/DebugToolDrivers/DebugTool.hpp b/src/DebugToolDrivers/DebugTool.hpp index e6b63cbd..b4717e3b 100644 --- a/src/DebugToolDrivers/DebugTool.hpp +++ b/src/DebugToolDrivers/DebugTool.hpp @@ -29,8 +29,14 @@ namespace Bloom return this->initialised; } + /** + * Should establish a connection to the device and prepare it for a debug session. + */ virtual void init() = 0; + /** + * Should disconnect from the device after performing any tasks required to formally end the debug session. + */ virtual void close() = 0; virtual std::string getName() = 0; @@ -43,6 +49,8 @@ namespace Bloom * * For debug tools that do not support AVR8 targets, this method should return a nullptr. * + * Note: the caller of this method will not manage the lifetime of the returned Avr8Interface instance. + * * @return */ virtual Avr8Interface* getAvr8Interface() { diff --git a/src/TargetController/TargetController.cpp b/src/TargetController/TargetController.cpp index 71897420..783bad9e 100644 --- a/src/TargetController/TargetController.cpp +++ b/src/TargetController/TargetController.cpp @@ -235,6 +235,7 @@ void TargetController::shutdown() { Logger::info("Closing debug tool"); debugTool->close(); } + } catch (const std::exception& exception) { Logger::error("Failed to properly shutdown TargetController. Error: " + std::string(exception.what())); } diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index 1c0fbcbc..e406d66c 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -564,8 +564,6 @@ void Avr8::writeRegisters(const TargetRegisters& registers) { gpRegisters.push_back(targetRegister); } else if (targetRegister.descriptor.type == TargetRegisterType::PROGRAM_COUNTER) { - Logger::debug("Setting PC register"); - auto programCounterBytes = targetRegister.value; if (programCounterBytes.size() < 4) { @@ -581,11 +579,9 @@ void Avr8::writeRegisters(const TargetRegisters& registers) { )); } else if (targetRegister.descriptor.type == TargetRegisterType::STATUS_REGISTER) { - Logger::error("Setting status register"); this->avr8Interface->setStatusRegister(targetRegister); } else if (targetRegister.descriptor.type == TargetRegisterType::STACK_POINTER) { - Logger::error("Setting stack pointer register"); this->avr8Interface->setStackPointerRegister(targetRegister); } } @@ -707,11 +703,9 @@ std::map Avr8::getPinStates(int variantId) { if (pad.ddrSetAddress.has_value()) { auto dataDirectionRegisterValue = readMemoryBitset(pad.ddrSetAddress.value()); pinState.ioDirection = dataDirectionRegisterValue.test(pad.gpioPinNumber.value()) ? - TargetPinState::IoDirection::OUTPUT : TargetPinState::IoDirection::INPUT; + TargetPinState::IoDirection::OUTPUT : TargetPinState::IoDirection::INPUT; - if (pinState.ioDirection == TargetPinState::IoDirection::OUTPUT - && pad.gpioPortSetAddress.has_value() - ) { + if (pinState.ioDirection == TargetPinState::IoDirection::OUTPUT && pad.gpioPortSetAddress.has_value()) { auto portRegisterValue = readMemoryBitset(pad.gpioPortSetAddress.value()); pinState.ioState = portRegisterValue.test(pad.gpioPinNumber.value()) ? TargetPinState::IoState::HIGH : TargetPinState::IoState::LOW;