Tidying
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
#include "AvrGdbRsp.hpp"
|
#include "AvrGdbRsp.hpp"
|
||||||
|
|
||||||
#include "src/Exceptions/Exception.hpp"
|
|
||||||
|
|
||||||
namespace Bloom::DebugServers::Gdb::AvrGdb
|
namespace Bloom::DebugServers::Gdb::AvrGdb
|
||||||
{
|
{
|
||||||
using namespace Bloom::Exceptions;
|
using namespace Bloom::Exceptions;
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
#include "TargetDescriptor.hpp"
|
#include "TargetDescriptor.hpp"
|
||||||
|
|
||||||
#include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp"
|
#include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp"
|
||||||
#include "src/DebugServers/GdbRsp/RegisterDescriptor.hpp"
|
|
||||||
#include "src/Helpers/BiMap.hpp"
|
|
||||||
|
|
||||||
namespace Bloom::DebugServers::Gdb::AvrGdb
|
namespace Bloom::DebugServers::Gdb::AvrGdb
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "TargetDescriptor.hpp"
|
#include "TargetDescriptor.hpp"
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#include "src/Exceptions/Exception.hpp"
|
||||||
#include "src/Logger/Logger.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.
|
* 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,
|
* Hmm, but the sorting is based on the start address (see TargetRegisterDescriptor::<() for more). So
|
||||||
* we're assuming that the registers will be laid out in the correct order, in memory. I think this assumption is
|
* effectively, we're assuming that the registers will be laid out in the correct order, in memory. I think
|
||||||
* fair.
|
* this assumption is fair.
|
||||||
*/
|
*/
|
||||||
const auto& gpRegisterDescriptors = registerDescriptorsByType.at(
|
const auto& gpRegisterDescriptors = registerDescriptorsByType.at(
|
||||||
TargetRegisterType::GENERAL_PURPOSE_REGISTER
|
TargetRegisterType::GENERAL_PURPOSE_REGISTER
|
||||||
);
|
);
|
||||||
|
|
||||||
// General purpose CPU registers
|
// General purpose registers
|
||||||
GdbRegisterNumberType regNumber = 0;
|
GdbRegisterNumberType regNumber = 0;
|
||||||
for (const auto& descriptor : gpRegisterDescriptors) {
|
for (const auto& descriptor : gpRegisterDescriptors) {
|
||||||
this->registerDescriptorsByGdbNumber.insert(std::pair(
|
this->registerDescriptorsByGdbNumber.insert(std::pair(
|
||||||
@@ -109,6 +111,7 @@ namespace Bloom::DebugServers::Gdb::AvrGdb
|
|||||||
regNumber++;
|
regNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Status, stack pointer and program counter registers
|
||||||
const auto statusDescriptor = RegisterDescriptor(
|
const auto statusDescriptor = RegisterDescriptor(
|
||||||
32,
|
32,
|
||||||
1,
|
1,
|
||||||
|
|||||||
@@ -46,6 +46,18 @@ namespace Bloom::DebugServers::Gdb::AvrGdb
|
|||||||
const std::vector<GdbRegisterNumberType>& getRegisterNumbers() const override;
|
const std::vector<GdbRegisterNumberType>& getRegisterNumbers() const override;
|
||||||
|
|
||||||
private:
|
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();
|
void loadRegisterMappings();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ namespace Bloom::DebugServers::Gdb::CommandPackets
|
|||||||
|
|
||||||
if (this->registerNumber.has_value()) {
|
if (this->registerNumber.has_value()) {
|
||||||
Logger::debug("Reading register number: " + std::to_string(this->registerNumber.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 {
|
} else {
|
||||||
// Read all target registers mapped to a GDB register
|
// Read all target registers mapped to a GDB register
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "RegisterDescriptor.hpp"
|
|
||||||
|
|
||||||
#include "src/Targets/TargetDescriptor.hpp"
|
#include "src/Targets/TargetDescriptor.hpp"
|
||||||
#include "src/Targets/TargetRegister.hpp"
|
#include "src/Targets/TargetRegister.hpp"
|
||||||
|
|
||||||
|
#include "RegisterDescriptor.hpp"
|
||||||
|
|
||||||
namespace Bloom::DebugServers::Gdb
|
namespace Bloom::DebugServers::Gdb
|
||||||
{
|
{
|
||||||
struct TargetDescriptor
|
struct TargetDescriptor
|
||||||
|
|||||||
Reference in New Issue
Block a user