This commit is contained in:
Nav
2022-01-11 21:12:25 +00:00
parent 023b655145
commit d462358b1e
21 changed files with 128 additions and 23 deletions

View File

@@ -39,8 +39,6 @@ namespace Bloom::DebugServers
environmentConfig(environmentConfig),
debugServerConfig(debugServerConfig) {};
virtual ~DebugServer() = default;
/**
* Entry point for the DebugServer. This must called from a dedicated thread.
*/

View File

@@ -17,12 +17,19 @@ namespace Bloom::DebugServers::Gdb
class Packet
{
public:
Packet() = default;
explicit Packet(const std::vector<unsigned char>& rawPacket) {
this->init(rawPacket);
}
Packet() = default;
virtual ~Packet() = default;
Packet(const Packet& other) = default;
Packet(Packet&& other) = default;
Packet& operator = (const Packet& other) = default;
Packet& operator = (Packet&& other) = default;
[[nodiscard]] virtual std::vector<unsigned char> getData() const {
return this->data;
}

View File

@@ -15,8 +15,15 @@ namespace Bloom
class DebugTool
{
public:
DebugTool() = default;
virtual ~DebugTool() = default;
DebugTool(const DebugTool& other) = default;
DebugTool(DebugTool&& other) = default;
DebugTool& operator = (const DebugTool& other) = default;
DebugTool& operator = (DebugTool&& other) = default;
/**
* Should establish a connection to the device and prepare it for a debug session.
*/

View File

@@ -12,8 +12,8 @@ using namespace Bloom::Exceptions;
void CmsisDapInterface::sendCommand(const Command& cmsisDapCommand) {
if (this->msSendCommandDelay.count() > 0) {
using namespace std::chrono;
long now = duration_cast<milliseconds>(high_resolution_clock::now().time_since_epoch()).count();
long difference = (now - this->lastCommandSentTimeStamp);
std::int64_t now = duration_cast<milliseconds>(high_resolution_clock::now().time_since_epoch()).count();
std::int64_t difference = (now - this->lastCommandSentTimeStamp);
if (difference < this->msSendCommandDelay.count()) {
std::this_thread::sleep_for(milliseconds(this->msSendCommandDelay.count() - difference));
@@ -28,7 +28,7 @@ void CmsisDapInterface::sendCommand(const Command& cmsisDapCommand) {
std::unique_ptr<Response> CmsisDapInterface::getResponse() {
auto rawResponse = this->getUsbHidInterface().read(10000);
if (rawResponse.size() == 0) {
if (rawResponse.empty()) {
throw DeviceCommunicationFailure("Empty CMSIS-DAP response received");
}

View File

@@ -19,6 +19,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
{
public:
explicit CmsisDapInterface() = default;
virtual ~CmsisDapInterface() = default;
CmsisDapInterface(const CmsisDapInterface& other) = default;
CmsisDapInterface(CmsisDapInterface&& other) = default;
CmsisDapInterface& operator = (const CmsisDapInterface& other) = default;
CmsisDapInterface& operator = (CmsisDapInterface&& other) = default;
Usb::HidInterface& getUsbHidInterface() {
return this->usbHidInterface;
@@ -80,6 +87,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
* being sent, where x is the value of msSendCommandDelay.
*/
std::chrono::milliseconds msSendCommandDelay = std::chrono::milliseconds(0);
long lastCommandSentTimeStamp = 0;
std::int64_t lastCommandSentTimeStamp = 0;
};
}

View File

@@ -8,8 +8,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
class Command
{
public:
Command() = default;
virtual ~Command() = default;
Command(const Command& other) = default;
Command(Command&& other) = default;
Command& operator = (const Command& other) = default;
Command& operator = (Command&& other) = default;
[[nodiscard]] unsigned char getCommandId() const {
return this->commandId;
}
@@ -28,11 +35,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
[[nodiscard]] int getCommandSize() const {
// +1 for the command ID
return (int) (1 + this->getData().size());
return static_cast<int>(1 + this->getData().size());
}
[[nodiscard]] std::uint16_t getDataSize() const {
return (std::uint16_t) this->getData().size();
return static_cast<std::uint16_t>(this->getData().size());
}
/**

View File

@@ -10,6 +10,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
Response() = default;
virtual ~Response() = default;
Response(const Response& other) = default;
Response(Response&& other) = default;
Response& operator = (const Response& other) = default;
Response& operator = (Response&& other) = default;
virtual void init(const std::vector<unsigned char>& rawResponse);
[[nodiscard]] unsigned char getResponseId() const {

View File

@@ -12,11 +12,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
AVR8_BREAK_EVENT = 0x40,
};
inline bool operator==(unsigned char rawId, AvrEventId id) {
inline bool operator == (unsigned char rawId, AvrEventId id) {
return static_cast<unsigned char>(id) == rawId;
}
inline bool operator==(AvrEventId id, unsigned char rawId) {
inline bool operator == (AvrEventId id, unsigned char rawId) {
return rawId == id;
}

View File

@@ -26,6 +26,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
AvrCommandFrame::lastSequenceId = 0;
}
};
virtual ~AvrCommandFrame() = default;
AvrCommandFrame(const AvrCommandFrame& other) = default;
AvrCommandFrame(AvrCommandFrame&& other) = default;
AvrCommandFrame& operator = (const AvrCommandFrame& other) = default;
AvrCommandFrame& operator = (AvrCommandFrame&& other) = default;
[[nodiscard]] unsigned char getProtocolVersion() const {
return this->protocolVersion;

View File

@@ -18,19 +18,19 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
FAILED = 0xA0,
};
inline bool operator==(unsigned char rawId, ResponseId id) {
inline bool operator == (unsigned char rawId, ResponseId id) {
return static_cast<unsigned char>(id) == rawId;
}
inline bool operator==(ResponseId id, unsigned char rawId) {
inline bool operator == (ResponseId id, unsigned char rawId) {
return static_cast<unsigned char>(id) == rawId;
}
inline bool operator!=(unsigned char rawId, ResponseId id) {
inline bool operator != (unsigned char rawId, ResponseId id) {
return static_cast<unsigned char>(id) != rawId;
}
inline bool operator!=(ResponseId id, unsigned char rawId) {
inline bool operator != (ResponseId id, unsigned char rawId) {
return static_cast<unsigned char>(id) != rawId;
}

View File

@@ -13,11 +13,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
FAILED_WITH_DATA = 0xA1
};
inline bool operator==(unsigned char rawId, ResponseId id) {
inline bool operator == (unsigned char rawId, ResponseId id) {
return static_cast<unsigned char>(id) == rawId;
}
inline bool operator==(ResponseId id, unsigned char rawId) {
inline bool operator == (ResponseId id, unsigned char rawId) {
return rawId == id;
}

View File

@@ -20,6 +20,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
this->initFromAvrResponses(AVRResponses);
}
virtual ~AvrResponseFrame() = default;
AvrResponseFrame(const AvrResponseFrame& other) = default;
AvrResponseFrame(AvrResponseFrame&& other) = default;
AvrResponseFrame& operator = (const AvrResponseFrame& other) = default;
AvrResponseFrame& operator = (AvrResponseFrame&& other) = default;
/**
* An AVRResponse contains a single fragment of an AvrResponseFrame.
*

View File

@@ -26,6 +26,15 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
class Avr8Interface
{
public:
Avr8Interface() = default;
virtual ~Avr8Interface() = default;
Avr8Interface(const Avr8Interface& other) = default;
Avr8Interface(Avr8Interface&& other) = default;
Avr8Interface& operator = (const Avr8Interface& other) = default;
Avr8Interface& operator = (Avr8Interface&& other) = default;
/**
* Configures the interface. Any debug tool -> target interface specific configuration should take
* place here.

View File

@@ -14,7 +14,7 @@ void HidInterface::init() {
}
hid_init();
hid_device* hidDevice;
hid_device* hidDevice = nullptr;
std::string hidInterfacePath = this->getDevicePathByInterfaceNumber(this->getNumber());
Logger::debug("HID device path: " + hidInterfacePath);
@@ -36,7 +36,7 @@ void HidInterface::init() {
}
void HidInterface::close() {
auto hidDevice = this->getHidDevice();
auto* hidDevice = this->getHidDevice();
if (hidDevice != nullptr) {
this->libUsbDeviceHandle = nullptr;
@@ -74,8 +74,9 @@ void HidInterface::write(std::vector<unsigned char> buffer) {
throw DeviceCommunicationFailure(
"Cannot send data via HID interface - data exceeds maximum packet size."
);
}
} else if (buffer.size() < this->getInputReportSize()) {
if (buffer.size() < this->getInputReportSize()) {
/*
* Every report we send via the USB HID interface should be of a fixed size.
* In the event of a report being too small, we just fill the buffer vector with 0.
@@ -83,7 +84,7 @@ void HidInterface::write(std::vector<unsigned char> buffer) {
buffer.resize(this->getInputReportSize(), 0);
}
int transferred;
int transferred = 0;
auto length = buffer.size();
if ((transferred = hid_write(this->getHidDevice(), buffer.data(), length)) != length) {

View File

@@ -15,6 +15,14 @@ namespace Bloom::Usb
this->setNumber(interfaceNumber);
}
virtual ~Interface() = default;
Interface(const Interface& other) = default;
Interface(Interface&& other) = default;
Interface& operator = (const Interface& other) = default;
Interface& operator = (Interface&& other) = default;
void setLibUsbDevice(libusb_device* libUsbDevice) {
this->libUsbDevice = libUsbDevice;
}

View File

@@ -14,7 +14,14 @@ namespace Bloom::Usb
{
public:
UsbDevice(std::uint16_t vendorId, std::uint16_t productId): vendorId(vendorId), productId(productId) {};
~UsbDevice() = default;
virtual ~UsbDevice() = default;
UsbDevice(const UsbDevice& other) = default;
UsbDevice(UsbDevice&& other) = default;
UsbDevice& operator = (const UsbDevice& other) = default;
UsbDevice& operator = (UsbDevice&& other) = default;
void init();

View File

@@ -65,6 +65,15 @@ namespace Bloom::Events
static constexpr EventType type = EventType::GENERIC;
static inline const std::string name = "GenericEvent";
Event() = default;
virtual ~Event() = default;
Event(const Event& other) = default;
Event(Event&& other) = default;
Event& operator = (const Event& other) = default;
Event& operator = (Event&& other) = default;
[[nodiscard]] virtual std::string getName() const {
return Event::name;
}

View File

@@ -19,6 +19,15 @@ namespace Bloom
class Thread
{
public:
Thread() = default;
virtual ~Thread() = default;
Thread(const Thread& other) = delete;
Thread(Thread&& other) = delete;
Thread& operator = (const Thread& other) = delete;
Thread& operator = (Thread&& other) = delete;
virtual ThreadState getThreadState() {
return this->state.getValue();
};

View File

@@ -40,6 +40,14 @@ namespace Bloom
const Targets::TargetMemoryAddressRange& addressRange
): name(std::move(name)), type(type), memoryDescriptor(memoryDescriptor), addressRange(addressRange) {};
virtual ~MemoryRegion() = default;
MemoryRegion(const MemoryRegion& other) = default;
MemoryRegion(MemoryRegion&& other) = default;
MemoryRegion& operator = (const MemoryRegion& other) = default;
MemoryRegion& operator = (MemoryRegion&& other) = default;
bool operator == (const MemoryRegion& other) const {
return this->id == other.id;
}

View File

@@ -31,7 +31,7 @@ namespace Bloom::Widgets
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
const TargetMemoryInspectionPaneSettings& settings,
InsightWorker& insightWorker,
PanelWidget *parent
PanelWidget* parent
);
void refreshMemoryValues(std::optional<std::function<void(void)>> callback = std::nullopt);

View File

@@ -121,6 +121,13 @@ namespace Bloom::Targets::TargetDescription
std::map<std::string, Interface> interfacesByName;
TargetDescriptionFile() = default;
virtual ~TargetDescriptionFile() = default;
TargetDescriptionFile(const TargetDescriptionFile& other) = default;
TargetDescriptionFile(TargetDescriptionFile&& other) = default;
TargetDescriptionFile& operator = (const TargetDescriptionFile& other) = default;
TargetDescriptionFile& operator = (TargetDescriptionFile&& other) = default;
virtual void init(const QDomDocument& xml);
void init(const QString& xmlFilePath);