WCH RISC-V software breakpoints, and a few other bits of refactoring/tidying

This commit is contained in:
Nav
2024-12-05 23:09:01 +00:00
parent 966244a01a
commit 33ed399337
55 changed files with 1530 additions and 686 deletions

View File

@@ -14,8 +14,8 @@
#include "src/TargetController/Commands/WriteTargetMemory.hpp"
#include "src/TargetController/Commands/EraseTargetMemory.hpp"
#include "src/TargetController/Commands/StepTargetExecution.hpp"
#include "src/TargetController/Commands/SetBreakpoint.hpp"
#include "src/TargetController/Commands/RemoveBreakpoint.hpp"
#include "src/TargetController/Commands/SetProgramBreakpointAnyType.hpp"
#include "src/TargetController/Commands/RemoveProgramBreakpoint.hpp"
#include "src/TargetController/Commands/SetTargetProgramCounter.hpp"
#include "src/TargetController/Commands/SetTargetStackPointer.hpp"
#include "src/TargetController/Commands/GetTargetGpioPadStates.hpp"
@@ -43,8 +43,8 @@ namespace Services
using TargetController::Commands::WriteTargetMemory;
using TargetController::Commands::EraseTargetMemory;
using TargetController::Commands::StepTargetExecution;
using TargetController::Commands::SetBreakpoint;
using TargetController::Commands::RemoveBreakpoint;
using TargetController::Commands::SetProgramBreakpointAnyType;
using TargetController::Commands::RemoveProgramBreakpoint;
using TargetController::Commands::SetTargetProgramCounter;
using TargetController::Commands::SetTargetStackPointer;
using TargetController::Commands::GetTargetGpioPadStates;
@@ -71,8 +71,6 @@ namespace Services
using Targets::TargetMemoryBufferSpan;
using Targets::TargetStackPointer;
using Targets::TargetBreakpoint;
using Targets::TargetPinoutDescriptor;
using Targets::TargetPinDescriptor;
using Targets::TargetGpioPadState;
@@ -236,20 +234,27 @@ namespace Services
);
}
Targets::TargetBreakpoint TargetControllerService::setBreakpoint(
Targets::TargetProgramBreakpoint TargetControllerService::setProgramBreakpointAnyType(
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
Targets::TargetMemoryAddress address,
Targets::TargetBreakpoint::Type preferredType
Targets::TargetMemorySize size
) const {
return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<SetBreakpoint>(address, preferredType),
std::make_unique<SetProgramBreakpointAnyType>(
addressSpaceDescriptor,
memorySegmentDescriptor,
address,
size
),
this->defaultTimeout,
this->activeAtomicSessionId
)->breakpoint;
}
void TargetControllerService::removeBreakpoint(TargetBreakpoint breakpoint) const {
void TargetControllerService::removeProgramBreakpoint(const Targets::TargetProgramBreakpoint& breakpoint) const {
this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<RemoveBreakpoint>(breakpoint),
std::make_unique<RemoveProgramBreakpoint>(breakpoint),
this->defaultTimeout,
this->activeAtomicSessionId
);

View File

@@ -170,25 +170,29 @@ namespace Services
) const;
/**
* Requests the TargetController to set a breakpoint on the target.
* Requests the TargetController to set a program breakpoint of any type (hardware/software) on the target.
*
* @param addressSpaceDescriptor
* @param memorySegmentDescriptor
* @param address
* @param preferredType
* @param size
*
* @return
* The installed breakpoint.
*/
[[nodiscard]] Targets::TargetBreakpoint setBreakpoint(
[[nodiscard]] Targets::TargetProgramBreakpoint setProgramBreakpointAnyType(
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
Targets::TargetMemoryAddress address,
Targets::TargetBreakpoint::Type preferredType = Targets::TargetBreakpoint::Type::HARDWARE
Targets::TargetMemorySize size
) const;
/**
* Requests the TargetController to remove a breakpoint from the target.
* Requests the TargetController to remove a program breakpoint from the target.
*
* @param breakpoint
*/
void removeBreakpoint(Targets::TargetBreakpoint breakpoint) const;
void removeProgramBreakpoint(const Targets::TargetProgramBreakpoint& breakpoint) const;
/**
* Retrieves the current program counter value from the target.