Tidying
This commit is contained in:
@@ -207,7 +207,7 @@ namespace DebugServer::Gdb
|
|||||||
bool interruptible,
|
bool interruptible,
|
||||||
std::optional<std::chrono::milliseconds> timeout
|
std::optional<std::chrono::milliseconds> timeout
|
||||||
) {
|
) {
|
||||||
auto output = std::vector<unsigned char>();
|
auto output = std::vector<unsigned char>{};
|
||||||
|
|
||||||
if (this->readInterruptEnabled != interruptible) {
|
if (this->readInterruptEnabled != interruptible) {
|
||||||
if (interruptible) {
|
if (interruptible) {
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
#include "src/Helpers/EventFdNotifier.hpp"
|
#include "src/Helpers/EventFdNotifier.hpp"
|
||||||
#include "src/Helpers/EpollInstance.hpp"
|
#include "src/Helpers/EpollInstance.hpp"
|
||||||
|
|
||||||
#include "src/DebugServer/Gdb/Packet.hpp"
|
#include "Packet.hpp"
|
||||||
#include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp"
|
#include "ResponsePackets/ResponsePacket.hpp"
|
||||||
|
|
||||||
namespace DebugServer::Gdb
|
namespace DebugServer::Gdb
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -159,15 +159,17 @@ namespace DebugServer::Gdb
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto commandPacket = this->waitForCommandPacket();
|
const auto commandPacket = this->waitForCommandPacket();
|
||||||
if (commandPacket) {
|
if (!commandPacket) {
|
||||||
commandPacket->handle(
|
return;
|
||||||
*(this->getActiveDebugSession()),
|
|
||||||
this->getGdbTargetDescriptor(),
|
|
||||||
this->targetDescriptor,
|
|
||||||
this->targetControllerService
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commandPacket->handle(
|
||||||
|
*(this->getActiveDebugSession()),
|
||||||
|
this->getGdbTargetDescriptor(),
|
||||||
|
this->targetDescriptor,
|
||||||
|
this->targetControllerService
|
||||||
|
);
|
||||||
|
|
||||||
} catch (const ClientDisconnected&) {
|
} catch (const ClientDisconnected&) {
|
||||||
Logger::info("GDB RSP client disconnected");
|
Logger::info("GDB RSP client disconnected");
|
||||||
this->endDebugSession();
|
this->endDebugSession();
|
||||||
|
|||||||
@@ -361,8 +361,6 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
|
|||||||
TargetMemorySize bytes,
|
TargetMemorySize bytes,
|
||||||
const std::set<TargetMemoryAddressRange>& excludedAddressRanges
|
const std::set<TargetMemoryAddressRange>& excludedAddressRanges
|
||||||
) {
|
) {
|
||||||
using DebugModule::Registers::MemoryAccessControlField;
|
|
||||||
|
|
||||||
// TODO: excluded addresses
|
// TODO: excluded addresses
|
||||||
|
|
||||||
const auto pageSize = 4;
|
const auto pageSize = 4;
|
||||||
@@ -383,34 +381,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
|
|||||||
return TargetMemoryBuffer{offset, offset + bytes};
|
return TargetMemoryBuffer{offset, offset + bytes};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto output = TargetMemoryBuffer{};
|
return this->readMemoryViaAbstractCommand(startAddress, bytes);
|
||||||
output.reserve(bytes);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We only need to set the address once. No need to update it as we use the post-increment function to
|
|
||||||
* increment the address. See MemoryAccessControlField::postIncrement
|
|
||||||
*/
|
|
||||||
this->dtmInterface.writeDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_1, startAddress);
|
|
||||||
|
|
||||||
constexpr auto command = AbstractCommandRegister{
|
|
||||||
.control = MemoryAccessControlField{
|
|
||||||
.postIncrement = true,
|
|
||||||
.size = MemoryAccessControlField::MemorySize::SIZE_32,
|
|
||||||
}.value(),
|
|
||||||
.commandType = AbstractCommandRegister::CommandType::MEMORY_ACCESS
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto address = startAddress; address <= (startAddress + bytes - 1); address += 4) {
|
|
||||||
this->executeAbstractCommand(command);
|
|
||||||
|
|
||||||
const auto data = this->dtmInterface.readDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_0);
|
|
||||||
output.emplace_back(static_cast<unsigned char>(data));
|
|
||||||
output.emplace_back(static_cast<unsigned char>(data >> 8));
|
|
||||||
output.emplace_back(static_cast<unsigned char>(data >> 16));
|
|
||||||
output.emplace_back(static_cast<unsigned char>(data >> 24));
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugTranslator::writeMemory(
|
void DebugTranslator::writeMemory(
|
||||||
@@ -462,30 +433,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->dtmInterface.writeDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_1, startAddress);
|
return this->writeMemoryViaAbstractCommand(startAddress, buffer);
|
||||||
|
|
||||||
constexpr auto command = AbstractCommandRegister{
|
|
||||||
.control = MemoryAccessControlField{
|
|
||||||
.write = true,
|
|
||||||
.postIncrement = true,
|
|
||||||
.size = MemoryAccessControlField::MemorySize::SIZE_32,
|
|
||||||
}.value(),
|
|
||||||
.commandType = AbstractCommandRegister::CommandType::MEMORY_ACCESS
|
|
||||||
};
|
|
||||||
|
|
||||||
for (TargetMemoryAddress offset = 0; offset < buffer.size(); offset += 4) {
|
|
||||||
this->dtmInterface.writeDebugModuleRegister(
|
|
||||||
RegisterAddress::ABSTRACT_DATA_0,
|
|
||||||
static_cast<RegisterValue>(
|
|
||||||
(buffer[offset + 3] << 24)
|
|
||||||
| (buffer[offset + 2] << 16)
|
|
||||||
| (buffer[offset + 1] << 8)
|
|
||||||
| (buffer[offset])
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
this->executeAbstractCommand(command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<DebugModule::HartIndex> DebugTranslator::discoverHartIndices() {
|
std::vector<DebugModule::HartIndex> DebugTranslator::discoverHartIndices() {
|
||||||
@@ -800,6 +748,74 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
|
|||||||
) * alignTo;
|
) * alignTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Targets::TargetMemoryBuffer DebugTranslator::readMemoryViaAbstractCommand(
|
||||||
|
Targets::TargetMemoryAddress startAddress,
|
||||||
|
Targets::TargetMemorySize bytes
|
||||||
|
) {
|
||||||
|
using DebugModule::Registers::MemoryAccessControlField;
|
||||||
|
|
||||||
|
auto output = TargetMemoryBuffer{};
|
||||||
|
output.reserve(bytes);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We only need to set the address once. No need to update it as we use the post-increment function to
|
||||||
|
* increment the address. See MemoryAccessControlField::postIncrement
|
||||||
|
*/
|
||||||
|
this->dtmInterface.writeDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_1, startAddress);
|
||||||
|
|
||||||
|
constexpr auto command = AbstractCommandRegister{
|
||||||
|
.control = MemoryAccessControlField{
|
||||||
|
.postIncrement = true,
|
||||||
|
.size = MemoryAccessControlField::MemorySize::SIZE_32,
|
||||||
|
}.value(),
|
||||||
|
.commandType = AbstractCommandRegister::CommandType::MEMORY_ACCESS
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto address = startAddress; address <= (startAddress + bytes - 1); address += 4) {
|
||||||
|
this->executeAbstractCommand(command);
|
||||||
|
|
||||||
|
const auto data = this->dtmInterface.readDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_0);
|
||||||
|
output.emplace_back(static_cast<unsigned char>(data));
|
||||||
|
output.emplace_back(static_cast<unsigned char>(data >> 8));
|
||||||
|
output.emplace_back(static_cast<unsigned char>(data >> 16));
|
||||||
|
output.emplace_back(static_cast<unsigned char>(data >> 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebugTranslator::writeMemoryViaAbstractCommand(
|
||||||
|
Targets::TargetMemoryAddress startAddress,
|
||||||
|
const TargetMemoryBuffer& buffer
|
||||||
|
) {
|
||||||
|
using DebugModule::Registers::MemoryAccessControlField;
|
||||||
|
|
||||||
|
this->dtmInterface.writeDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_1, startAddress);
|
||||||
|
|
||||||
|
constexpr auto command = AbstractCommandRegister{
|
||||||
|
.control = MemoryAccessControlField{
|
||||||
|
.write = true,
|
||||||
|
.postIncrement = true,
|
||||||
|
.size = MemoryAccessControlField::MemorySize::SIZE_32,
|
||||||
|
}.value(),
|
||||||
|
.commandType = AbstractCommandRegister::CommandType::MEMORY_ACCESS
|
||||||
|
};
|
||||||
|
|
||||||
|
for (TargetMemoryAddress offset = 0; offset < buffer.size(); offset += 4) {
|
||||||
|
this->dtmInterface.writeDebugModuleRegister(
|
||||||
|
RegisterAddress::ABSTRACT_DATA_0,
|
||||||
|
static_cast<RegisterValue>(
|
||||||
|
(buffer[offset + 3] << 24)
|
||||||
|
| (buffer[offset + 2] << 16)
|
||||||
|
| (buffer[offset + 1] << 8)
|
||||||
|
| (buffer[offset])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
this->executeAbstractCommand(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<
|
std::optional<
|
||||||
std::reference_wrapper<const TriggerModule::TriggerDescriptor>
|
std::reference_wrapper<const TriggerModule::TriggerDescriptor>
|
||||||
> DebugTranslator::getAvailableTrigger() {
|
> DebugTranslator::getAvailableTrigger() {
|
||||||
|
|||||||
@@ -140,6 +140,15 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
|
|||||||
);
|
);
|
||||||
Targets::TargetMemorySize alignMemorySize(Targets::TargetMemorySize size, Targets::TargetMemorySize alignTo);
|
Targets::TargetMemorySize alignMemorySize(Targets::TargetMemorySize size, Targets::TargetMemorySize alignTo);
|
||||||
|
|
||||||
|
Targets::TargetMemoryBuffer readMemoryViaAbstractCommand(
|
||||||
|
Targets::TargetMemoryAddress startAddress,
|
||||||
|
Targets::TargetMemorySize bytes
|
||||||
|
);
|
||||||
|
void writeMemoryViaAbstractCommand(
|
||||||
|
Targets::TargetMemoryAddress startAddress,
|
||||||
|
const Targets::TargetMemoryBuffer& buffer
|
||||||
|
);
|
||||||
|
|
||||||
std::optional<std::reference_wrapper<const TriggerModule::TriggerDescriptor>> getAvailableTrigger();
|
std::optional<std::reference_wrapper<const TriggerModule::TriggerDescriptor>> getAvailableTrigger();
|
||||||
void clearTrigger(const TriggerModule::TriggerDescriptor& triggerDescriptor);
|
void clearTrigger(const TriggerModule::TriggerDescriptor& triggerDescriptor);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace DebugToolDrivers::Wch
|
|||||||
this->wchLinkUsbInterface->init();
|
this->wchLinkUsbInterface->init();
|
||||||
|
|
||||||
this->wchLinkInterface = std::make_unique<Protocols::WchLink::WchLinkInterface>(
|
this->wchLinkInterface = std::make_unique<Protocols::WchLink::WchLinkInterface>(
|
||||||
*(this->wchLinkUsbInterface.get()),
|
*(this->wchLinkUsbInterface),
|
||||||
*this
|
*this
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ namespace DebugToolDrivers::Wch
|
|||||||
|
|
||||||
if (!this->wchRiscVTranslator) {
|
if (!this->wchRiscVTranslator) {
|
||||||
this->wchRiscVTranslator = std::make_unique<DebugTranslator>(
|
this->wchRiscVTranslator = std::make_unique<DebugTranslator>(
|
||||||
*(this->wchLinkInterface.get()),
|
*(this->wchLinkInterface),
|
||||||
this->toolConfig.riscVDebugTranslatorConfig,
|
this->toolConfig.riscVDebugTranslatorConfig,
|
||||||
targetDescriptionFile,
|
targetDescriptionFile,
|
||||||
targetConfig
|
targetConfig
|
||||||
|
|||||||
Reference in New Issue
Block a user