Added structures for parsing data stream from windbg to packet. Signed-off-by: Mihail Abakumov <mikhail.abaku...@ispras.ru> Signed-off-by: Pavel Dovgalyuk <dovga...@ispras.ru> Signed-off-by: Dmitriy Koltunov <koltu...@ispras.ru> --- include/exec/windbgstub-utils.h | 11 +++++++++++ windbgstub.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-utils.h index ff260287dc..d6abb82dfa 100755 --- a/include/exec/windbgstub-utils.h +++ b/include/exec/windbgstub-utils.h @@ -55,6 +55,17 @@ typedef struct InitedAddr { bool is_init; } InitedAddr; +typedef struct PacketData { + union { + struct { + DBGKD_MANIPULATE_STATE64 m64; + uint8_t extra[PACKET_MAX_SIZE - sizeof(DBGKD_MANIPULATE_STATE64)]; + }; + uint8_t buf[PACKET_MAX_SIZE]; + }; + uint16_t extra_size; +} PacketData; + InitedAddr *windbg_get_KPCR(void); InitedAddr *windbg_get_version(void); diff --git a/windbgstub.c b/windbgstub.c index e9aabd807b..395f244d4f 100755 --- a/windbgstub.c +++ b/windbgstub.c @@ -19,6 +19,36 @@ #include "sysemu/kvm.h" #include "sysemu/reset.h" +typedef enum ParsingState { + STATE_LEADER, + STATE_PACKET_TYPE, + STATE_PACKET_BYTE_COUNT, + STATE_PACKET_ID, + STATE_PACKET_CHECKSUM, + STATE_PACKET_DATA, + STATE_TRAILING_BYTE, +} ParsingState; + +typedef enum ParsingResult { + RESULT_NONE, + RESULT_BREAKIN_BYTE, + RESULT_UNKNOWN_PACKET, + RESULT_CONTROL_PACKET, + RESULT_DATA_PACKET, + RESULT_ERROR, +} ParsingResult; + +typedef struct ParsingContext { + /* index in the current buffer, + which depends on the current state */ + int index; + ParsingState state; + ParsingResult result; + KD_PACKET packet; + PacketData data; + const char *name; +} ParsingContext; + typedef struct WindbgState { bool is_loaded;