summaryrefslogtreecommitdiff
path: root/gdbremote_parser.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'gdbremote_parser.hpp')
-rw-r--r--gdbremote_parser.hpp59
1 files changed, 54 insertions, 5 deletions
diff --git a/gdbremote_parser.hpp b/gdbremote_parser.hpp
index 0e2f375..6bf37bd 100644
--- a/gdbremote_parser.hpp
+++ b/gdbremote_parser.hpp
@@ -44,11 +44,17 @@ struct Feature {
enum class PacketType: int {
kNone = 0,
kQuerySupported,
+ kQueryHaltReason,
kQueryC,
kQueryFThreadInfo,
kQuerySThreadInfo,
- kH,
- kMustReplyEmpty,
+ kQueryRTOSThreadInfo,
+ kQueryAttached,
+ kQueryTraceStatus,
+ kSetThreadForCont,
+ kSetThreadForOps,
+ kVMustReplyEmpty,
+ kEnableExtendedMode,
};
struct PacketData {
@@ -65,21 +71,57 @@ struct PacketDataSupportedFeatures: public PacketData {
struct Packet {
const PacketType type{};
- const std::unique_ptr<PacketData> data;
+ const std::unique_ptr<PacketData> data{nullptr};
/** Convert raw packet data into a Packet
*
* Packet data is the data extracted by ExchangeContext::Consume function.
*/
static Packet Parse(std::string packet_data);
+
+ /** None packet creator */
+ static Packet None() { return Packet{}; }
+
+ /** Stringify PacketType for debugging purposes */
+ static const char* PacketTypeToString(PacketType type) {
+ switch (type) {
+ case PacketType::kNone:
+ return "None";
+ case PacketType::kQuerySupported:
+ return "qSupported";
+ case PacketType::kQueryHaltReason:
+ return "?";
+ case PacketType::kQueryC:
+ return "qC";
+ case PacketType::kQueryFThreadInfo:
+ return "qfThreadInfo";
+ case PacketType::kQuerySThreadInfo:
+ return "qsThreadInfo";
+ case PacketType::kQueryRTOSThreadInfo:
+ return "qL";
+ case PacketType::kQueryAttached:
+ return "qAttached";
+ case PacketType::kQueryTraceStatus:
+ return "qTStatus";
+ case PacketType::kSetThreadForCont:
+ return "Hc";
+ case PacketType::kSetThreadForOps:
+ return "Hg";
+ case PacketType::kVMustReplyEmpty:
+ return "vMustReplyEmpty";
+ case PacketType::kEnableExtendedMode:
+ return "!";
+ }
+ return "<unknown>";
+ }
};
struct ExchangeResult {
const std::string packet{};
- const std::string response{};
+ const std::string ack{};
ExchangeResult(std::string a_packet, std::string a_response)
- : packet(a_packet), response(a_response) {}
+ : packet(a_packet), ack(a_response) {}
static std::unique_ptr<ExchangeResult> Nak(std::string data=std::string{})
{
@@ -112,6 +154,12 @@ public:
*/
std::string WrapDataToSend(Packet packet=Packet{});
+ /** Returns last recognized packet
+ *
+ * For debugging purposes.
+ */
+ const std::string GetLastPacket() { return _last_packet; }
+
private:
enum class ParsingState {
kIdle,
@@ -126,6 +174,7 @@ private:
ParsingState _parsing_state{ParsingState::kIdle};
std::string _packet_data{};
+ std::string _last_packet{};
uint8_t _checksum{};
uint8_t _given_checksum_first_byte{};
};