Removed unnecessary init() member functions in command packet classes.
This commit is contained in:
@@ -10,7 +10,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
using ResponsePackets::ErrorResponsePacket;
|
using ResponsePackets::ErrorResponsePacket;
|
||||||
using Exceptions::Exception;
|
using Exceptions::Exception;
|
||||||
|
|
||||||
void ContinueExecution::init() {
|
ContinueExecution::ContinueExecution(const std::vector<unsigned char>& rawPacket)
|
||||||
|
: CommandPacket(rawPacket)
|
||||||
|
{
|
||||||
if (this->data.size() > 1) {
|
if (this->data.size() > 1) {
|
||||||
this->fromProgramCounter = static_cast<std::uint32_t>(
|
this->fromProgramCounter = static_cast<std::uint32_t>(
|
||||||
std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16)
|
std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16)
|
||||||
|
|||||||
@@ -24,13 +24,8 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
*/
|
*/
|
||||||
std::optional<std::uint32_t> fromProgramCounter;
|
std::optional<std::uint32_t> fromProgramCounter;
|
||||||
|
|
||||||
explicit ContinueExecution(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
explicit ContinueExecution(const std::vector<unsigned char>& rawPacket);
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
||||||
|
|
||||||
private:
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
|
|
||||||
using Exceptions::Exception;
|
using Exceptions::Exception;
|
||||||
|
|
||||||
void ReadRegisters::init() {
|
ReadRegisters::ReadRegisters(const std::vector<unsigned char>& rawPacket)
|
||||||
|
: CommandPacket(rawPacket)
|
||||||
|
{
|
||||||
if (this->data.size() >= 2 && this->data.front() == 'p') {
|
if (this->data.size() >= 2 && this->data.front() == 'p') {
|
||||||
// This command packet is requesting a specific register
|
// This command packet is requesting a specific register
|
||||||
this->registerNumber = static_cast<size_t>(
|
this->registerNumber = static_cast<size_t>(
|
||||||
|
|||||||
@@ -25,13 +25,8 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
*/
|
*/
|
||||||
std::optional<GdbRegisterNumberType> registerNumber;
|
std::optional<GdbRegisterNumberType> registerNumber;
|
||||||
|
|
||||||
explicit ReadRegisters(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
explicit ReadRegisters(const std::vector<unsigned char>& rawPacket);
|
||||||
init();
|
|
||||||
};
|
|
||||||
|
|
||||||
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
||||||
|
|
||||||
private:
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
|
|
||||||
using Exceptions::Exception;
|
using Exceptions::Exception;
|
||||||
|
|
||||||
void RemoveBreakpoint::init() {
|
RemoveBreakpoint::RemoveBreakpoint(const std::vector<unsigned char>& rawPacket)
|
||||||
|
: CommandPacket(rawPacket)
|
||||||
|
{
|
||||||
if (this->data.size() < 6) {
|
if (this->data.size() < 6) {
|
||||||
throw Exception("Unexpected RemoveBreakpoint packet size");
|
throw Exception("Unexpected RemoveBreakpoint packet size");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,8 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
*/
|
*/
|
||||||
std::uint32_t address = 0;
|
std::uint32_t address = 0;
|
||||||
|
|
||||||
explicit RemoveBreakpoint(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
explicit RemoveBreakpoint(const std::vector<unsigned char>& rawPacket);
|
||||||
this->init();
|
|
||||||
};
|
|
||||||
|
|
||||||
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
||||||
|
|
||||||
private:
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
|
|
||||||
using Exceptions::Exception;
|
using Exceptions::Exception;
|
||||||
|
|
||||||
void SetBreakpoint::init() {
|
SetBreakpoint::SetBreakpoint(const std::vector<unsigned char>& rawPacket)
|
||||||
|
: CommandPacket(rawPacket)
|
||||||
|
{
|
||||||
if (this->data.size() < 6) {
|
if (this->data.size() < 6) {
|
||||||
throw Exception("Unexpected SetBreakpoint packet size");
|
throw Exception("Unexpected SetBreakpoint packet size");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,8 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
*/
|
*/
|
||||||
std::uint32_t address = 0;
|
std::uint32_t address = 0;
|
||||||
|
|
||||||
explicit SetBreakpoint(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
explicit SetBreakpoint(const std::vector<unsigned char>& rawPacket);
|
||||||
this->init();
|
|
||||||
};
|
|
||||||
|
|
||||||
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
||||||
|
|
||||||
private:
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
|
|
||||||
using Exceptions::Exception;
|
using Exceptions::Exception;
|
||||||
|
|
||||||
void StepExecution::init() {
|
StepExecution::StepExecution(const std::vector<unsigned char>& rawPacket)
|
||||||
|
: CommandPacket(rawPacket)
|
||||||
|
{
|
||||||
if (this->data.size() > 1) {
|
if (this->data.size() > 1) {
|
||||||
this->fromProgramCounter = static_cast<std::uint32_t>(
|
this->fromProgramCounter = static_cast<std::uint32_t>(
|
||||||
std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16)
|
std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16)
|
||||||
|
|||||||
@@ -19,13 +19,8 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
*/
|
*/
|
||||||
std::optional<std::size_t> fromProgramCounter;
|
std::optional<std::size_t> fromProgramCounter;
|
||||||
|
|
||||||
explicit StepExecution(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
explicit StepExecution(const std::vector<unsigned char>& rawPacket);
|
||||||
init();
|
|
||||||
};
|
|
||||||
|
|
||||||
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
||||||
|
|
||||||
private:
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
using Bloom::Exceptions::Exception;
|
using Bloom::Exceptions::Exception;
|
||||||
using Gdb::Exceptions::ClientNotSupported;
|
using Gdb::Exceptions::ClientNotSupported;
|
||||||
|
|
||||||
void SupportedFeaturesQuery::init() {
|
SupportedFeaturesQuery::SupportedFeaturesQuery(const std::vector<unsigned char>& rawPacket)
|
||||||
|
: CommandPacket(rawPacket)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* For qSupported packets, supported and unsupported GDB features are reported in the packet
|
* For qSupported packets, supported and unsupported GDB features are reported in the packet data, where each
|
||||||
* data, where each GDB feature is separated by a semicolon.
|
* GDB feature is separated by a semicolon.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// The "qSupported:" prefix occupies 11 bytes
|
// The "qSupported:" prefix occupies 11 bytes
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
class SupportedFeaturesQuery: public CommandPacket
|
class SupportedFeaturesQuery: public CommandPacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit SupportedFeaturesQuery(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
explicit SupportedFeaturesQuery(const std::vector<unsigned char>& rawPacket);
|
||||||
this->init();
|
|
||||||
};
|
|
||||||
|
|
||||||
[[nodiscard]] bool isFeatureSupported(const Feature& feature) const {
|
[[nodiscard]] bool isFeatureSupported(const Feature& feature) const {
|
||||||
return this->supportedFeatures.find(feature) != this->supportedFeatures.end();
|
return this->supportedFeatures.find(feature) != this->supportedFeatures.end();
|
||||||
@@ -38,7 +36,5 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<Feature> supportedFeatures;
|
std::set<Feature> supportedFeatures;
|
||||||
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
|
|
||||||
using Exceptions::Exception;
|
using Exceptions::Exception;
|
||||||
|
|
||||||
void WriteRegister::init() {
|
WriteRegister::WriteRegister(const std::vector<unsigned char>& rawPacket)
|
||||||
|
: CommandPacket(rawPacket)
|
||||||
|
{
|
||||||
// The P packet updates a single register
|
// The P packet updates a single register
|
||||||
auto packet = std::string(this->data.begin(), this->data.end());
|
auto packet = std::string(this->data.begin(), this->data.end());
|
||||||
|
|
||||||
@@ -42,7 +44,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
Logger::debug("Handling WriteRegister packet");
|
Logger::debug("Handling WriteRegister packet");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto targetRegisterDescriptor = debugSession.targetDescriptor.getTargetRegisterDescriptorFromNumber(this->registerNumber);
|
auto targetRegisterDescriptor = debugSession.targetDescriptor.getTargetRegisterDescriptorFromNumber(
|
||||||
|
this->registerNumber
|
||||||
|
);
|
||||||
|
|
||||||
const auto valueSize = this->registerValue.size();
|
const auto valueSize = this->registerValue.size();
|
||||||
if (valueSize > 0 && valueSize > targetRegisterDescriptor.size) {
|
if (valueSize > 0 && valueSize > targetRegisterDescriptor.size) {
|
||||||
@@ -57,7 +61,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->registerValue.size() > targetRegisterDescriptor.size) {
|
if (this->registerValue.size() > targetRegisterDescriptor.size) {
|
||||||
const auto& gdbRegisterDescriptor = debugSession.targetDescriptor.getRegisterDescriptorFromNumber(this->registerNumber);
|
const auto& gdbRegisterDescriptor = debugSession.targetDescriptor.getRegisterDescriptorFromNumber(
|
||||||
|
this->registerNumber
|
||||||
|
);
|
||||||
throw Exception("Cannot set value for " + gdbRegisterDescriptor.name
|
throw Exception("Cannot set value for " + gdbRegisterDescriptor.name
|
||||||
+ " - value size exceeds register size."
|
+ " - value size exceeds register size."
|
||||||
);
|
);
|
||||||
@@ -67,6 +73,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
targetControllerConsole.writeRegisters({
|
targetControllerConsole.writeRegisters({
|
||||||
TargetRegister(targetRegisterDescriptor, this->registerValue)
|
TargetRegister(targetRegisterDescriptor, this->registerValue)
|
||||||
});
|
});
|
||||||
|
|
||||||
debugSession.connection.writePacket(OkResponsePacket());
|
debugSession.connection.writePacket(OkResponsePacket());
|
||||||
|
|
||||||
} catch (const Exception& exception) {
|
} catch (const Exception& exception) {
|
||||||
|
|||||||
@@ -17,13 +17,8 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
int registerNumber = 0;
|
int registerNumber = 0;
|
||||||
std::vector<unsigned char> registerValue;
|
std::vector<unsigned char> registerValue;
|
||||||
|
|
||||||
explicit WriteRegister(const std::vector<unsigned char>& rawPacket): CommandPacket(rawPacket) {
|
explicit WriteRegister(const std::vector<unsigned char>& rawPacket);
|
||||||
init();
|
|
||||||
};
|
|
||||||
|
|
||||||
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
||||||
|
|
||||||
private:
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user