diff --git a/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.cpp b/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.cpp index 302c7e0c..33bbea41 100644 --- a/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.cpp +++ b/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.cpp @@ -179,19 +179,24 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec if (statusRegister.anyHaveReset) { Logger::warning("Reset detected at RISC-V hart " + std::to_string(this->selectedHartIndex)); - if (statusRegister.anyRunning) { - this->stop(); - } + try { + if (statusRegister.anyRunning) { + this->stop(); + } - this->initDebugControlStatusRegister(); - this->writeDebugModuleControlRegister(ControlRegister{ - .debugModuleActive = true, - .selectedHartIndex = this->selectedHartIndex, - .acknowledgeHaveReset = true, - }); + this->initDebugControlStatusRegister(); + this->writeDebugModuleControlRegister(ControlRegister{ + .debugModuleActive = true, + .selectedHartIndex = this->selectedHartIndex, + .acknowledgeHaveReset = true, + }); - if (statusRegister.anyRunning) { - this->run(); + if (statusRegister.anyRunning) { + this->run(); + } + + } catch (const Exceptions::TargetOperationFailure& exception) { + Logger::error("Failed to handle unexpected RISC-V hart reset - error: " + exception.getMessage()); } }