Added TargetFamily to TargetDescriptor and comparability check in AVR GDB debug server

This commit is contained in:
Nav
2023-11-22 00:37:29 +00:00
parent 0d5213c84c
commit d3c7cddb82
6 changed files with 31 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ namespace DebugServer
DebugServerComponent::DebugServerComponent(const DebugServerConfig& debugServerConfig)
: debugServerConfig(debugServerConfig)
, targetDescriptor((Services::TargetControllerService()).getTargetDescriptor())
{}
void DebugServerComponent::run() {
@@ -42,8 +43,13 @@ namespace DebugServer
{
"avr-gdb-rsp",
[this] () -> std::unique_ptr<ServerInterface> {
if (this->targetDescriptor.family != Targets::TargetFamily::AVR8) {
throw Exceptions::Exception("The AVR GDB RSP server is only compatible with AVR8 targets.");
}
return std::make_unique<DebugServer::Gdb::AvrGdb::AvrGdbRsp>(
this->debugServerConfig,
this->targetDescriptor,
*(this->eventListener.get()),
this->interruptEventNotifier
);

View File

@@ -7,12 +7,16 @@
#include "src/Helpers/Thread.hpp"
#include "src/ProjectConfig.hpp"
#include "src/Helpers/EventFdNotifier.hpp"
#include "src/EventManager/EventListener.hpp"
#include "src/EventManager/Events/Events.hpp"
#include "ServerInterface.hpp"
#include "src/Services/TargetControllerService.hpp"
#include "src/Targets/TargetDescriptor.hpp"
namespace DebugServer
{
/**
@@ -47,6 +51,11 @@ namespace DebugServer
*/
DebugServerConfig debugServerConfig;
/**
* The current target descriptor.
*/
Targets::TargetDescriptor targetDescriptor;
/**
* This EventFdNotifier is injected into this->eventListener. It can be used by server implementations to
* interrupt blocking I/O calls upon an event being triggered. For more, see the "Servicing events" section in

View File

@@ -26,11 +26,12 @@ namespace DebugServer::Gdb::AvrGdb
AvrGdbRsp::AvrGdbRsp(
const DebugServerConfig& debugServerConfig,
const Targets::TargetDescriptor& targetDescriptor,
EventListener& eventListener,
EventFdNotifier& eventNotifier
)
: GdbRspDebugServer(debugServerConfig, eventListener, eventNotifier)
, gdbTargetDescriptor(TargetDescriptor(this->targetControllerService.getTargetDescriptor()))
, gdbTargetDescriptor(targetDescriptor)
{}
DebugSession* AvrGdbRsp::startDebugSession(Connection&& connection) {

View File

@@ -14,6 +14,7 @@ namespace DebugServer::Gdb::AvrGdb
public:
AvrGdbRsp(
const DebugServerConfig& debugServerConfig,
const Targets::TargetDescriptor& targetDescriptor,
EventListener& eventListener,
EventFdNotifier& eventNotifier
);

View File

@@ -268,6 +268,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
TargetDescriptor Avr8::getDescriptor() {
auto descriptor = TargetDescriptor(
this->signature.toHex(),
TargetFamily::AVR8,
this->name,
"Microchip",
this->targetMemoryDescriptorsByType,

View File

@@ -14,10 +14,17 @@
namespace Targets
{
enum class TargetFamily: std::uint8_t
{
AVR8,
RISC_V,
};
struct TargetDescriptor
{
std::string name;
std::string id;
TargetFamily family;
std::string name;
std::string vendorName;
std::map<TargetMemoryType, TargetMemoryDescriptor> memoryDescriptorsByType;
std::map<TargetRegisterDescriptorId, TargetRegisterDescriptor> registerDescriptorsById;
@@ -28,6 +35,7 @@ namespace Targets
TargetDescriptor(
const std::string& id,
TargetFamily family,
const std::string& name,
const std::string& vendorName,
const std::map<TargetMemoryType, TargetMemoryDescriptor>& memoryDescriptorsByType,
@@ -36,8 +44,9 @@ namespace Targets
const std::vector<TargetVariant>& variants,
TargetMemoryType programMemoryType
)
: name(name)
, id(id)
: id(id)
, family(family)
, name(name)
, vendorName(vendorName)
, memoryDescriptorsByType(memoryDescriptorsByType)
, registerDescriptorsById(registerDescriptorsById)