This commit is contained in:
Nav
2022-03-25 00:19:32 +00:00
parent e18a9bad19
commit c002bd0f0e
6 changed files with 24 additions and 11 deletions

View File

@@ -1,7 +1,5 @@
#include "AvrGdbRsp.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::DebugServers::Gdb::AvrGdb
{
using namespace Bloom::Exceptions;

View File

@@ -5,8 +5,6 @@
#include "TargetDescriptor.hpp"
#include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp"
#include "src/DebugServers/GdbRsp/RegisterDescriptor.hpp"
#include "src/Helpers/BiMap.hpp"
namespace Bloom::DebugServers::Gdb::AvrGdb
{

View File

@@ -1,5 +1,7 @@
#include "TargetDescriptor.hpp"
#include <numeric>
#include "src/Exceptions/Exception.hpp"
#include "src/Logger/Logger.hpp"
@@ -81,15 +83,15 @@ namespace Bloom::DebugServers::Gdb::AvrGdb
/*
* Worth noting that gpRegisterDescriptors will always be sorted in the correct order, from register 0 to 31.
*
* Hmm, but the sorting is based on the start address (see TargetRegisterDescriptor::<() for more). So effectively,
* we're assuming that the registers will be laid out in the correct order, in memory. I think this assumption is
* fair.
* Hmm, but the sorting is based on the start address (see TargetRegisterDescriptor::<() for more). So
* effectively, we're assuming that the registers will be laid out in the correct order, in memory. I think
* this assumption is fair.
*/
const auto& gpRegisterDescriptors = registerDescriptorsByType.at(
TargetRegisterType::GENERAL_PURPOSE_REGISTER
);
// General purpose CPU registers
// General purpose registers
GdbRegisterNumberType regNumber = 0;
for (const auto& descriptor : gpRegisterDescriptors) {
this->registerDescriptorsByGdbNumber.insert(std::pair(
@@ -109,6 +111,7 @@ namespace Bloom::DebugServers::Gdb::AvrGdb
regNumber++;
}
// Status, stack pointer and program counter registers
const auto statusDescriptor = RegisterDescriptor(
32,
1,

View File

@@ -46,6 +46,18 @@ namespace Bloom::DebugServers::Gdb::AvrGdb
const std::vector<GdbRegisterNumberType>& getRegisterNumbers() const override;
private:
std::vector<GdbRegisterNumberType> registerNumbers = std::vector<GdbRegisterNumberType>(35);
/**
* For AVR targets, avr-gdb defines 35 registers in total:
*
* Register number 0 through 31 are general purpose registers
* Register number 32 is the status register (SREG)
* Register number 33 is the stack pointer register
* Register number 34 is the program counter register
*
* This function will prepare the appropriate GDB register numbers and mappings.
*/
void loadRegisterMappings();
};
}

View File

@@ -36,7 +36,9 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
if (this->registerNumber.has_value()) {
Logger::debug("Reading register number: " + std::to_string(this->registerNumber.value()));
descriptors.insert(targetDescriptor.getTargetRegisterDescriptorFromNumber(this->registerNumber.value()));
descriptors.insert(
targetDescriptor.getTargetRegisterDescriptorFromNumber(this->registerNumber.value())
);
} else {
// Read all target registers mapped to a GDB register

View File

@@ -4,11 +4,11 @@
#include <optional>
#include <vector>
#include "RegisterDescriptor.hpp"
#include "src/Targets/TargetDescriptor.hpp"
#include "src/Targets/TargetRegister.hpp"
#include "RegisterDescriptor.hpp"
namespace Bloom::DebugServers::Gdb
{
struct TargetDescriptor