diff --git a/src/gdb_packet.c b/src/gdb_packet.c index 3ca01ed..6f4f2e1 100644 --- a/src/gdb_packet.c +++ b/src/gdb_packet.c @@ -167,10 +167,10 @@ static void gdb_next_char(char c, unsigned char *csum) void gdb_putpacket2(const char *packet1, size_t size1, const char *packet2, size_t size2) { char xmit_csum[3]; - int tries = 0; + size_t tries = 0; do { - DEBUG_GDB_WIRE("%s : ", __func__); + DEBUG_GDB_WIRE("%s: ", __func__); unsigned char csum = 0; gdb_if_putchar('$', 0); @@ -184,16 +184,16 @@ void gdb_putpacket2(const char *packet1, size_t size1, const char *packet2, size gdb_if_putchar(xmit_csum[0], 0); gdb_if_putchar(xmit_csum[1], 1); DEBUG_GDB_WIRE("\n"); - } while ((gdb_if_getchar_to(2000) != '+') && (tries++ < 3)); + } while (gdb_if_getchar_to(2000) != '+' && tries++ < 3); } void gdb_putpacket(const char *packet, size_t size) { char xmit_csum[3]; - int tries = 0; + size_t tries = 0; do { - DEBUG_GDB_WIRE("%s : ", __func__); + DEBUG_GDB_WIRE("%s: ", __func__); unsigned char csum = 0; gdb_if_putchar('$', 0); for (size_t i = 0; i < size; ++i) @@ -203,7 +203,23 @@ void gdb_putpacket(const char *packet, size_t size) gdb_if_putchar(xmit_csum[0], 0); gdb_if_putchar(xmit_csum[1], 1); DEBUG_GDB_WIRE("\n"); - } while ((gdb_if_getchar_to(2000) != '+') && (tries++ < 3)); + } while (gdb_if_getchar_to(2000) != '+' && tries++ < 3); +} + +void gdb_put_notification(const char *const packet, const size_t size) +{ + char xmit_csum[3]; + + DEBUG_GDB_WIRE("%s: ", __func__); + uint8_t csum = 0; + gdb_if_putchar('%', 0); + for (size_t i = 0; i < size; ++i) + gdb_next_char(packet[i], &csum); + gdb_if_putchar('#', 0); + snprintf(xmit_csum, sizeof(xmit_csum), "%02X", csum); + gdb_if_putchar(xmit_csum[0], 0); + gdb_if_putchar(xmit_csum[1], 1); + DEBUG_GDB_WIRE("\n"); } void gdb_putpacket_f(const char *fmt, ...) diff --git a/src/include/gdb_packet.h b/src/include/gdb_packet.h index 89733ed..d1e7208 100644 --- a/src/include/gdb_packet.h +++ b/src/include/gdb_packet.h @@ -21,6 +21,7 @@ #ifndef __GDB_PACKET_H #define __GDB_PACKET_H +#include #include size_t gdb_getpacket(char *packet, size_t size); @@ -28,6 +29,8 @@ void gdb_putpacket(const char *packet, size_t size); void gdb_putpacket2(const char *packet1, size_t size1, const char *packet2, size_t size2); #define gdb_putpacketz(packet) gdb_putpacket((packet), strlen(packet)) void gdb_putpacket_f(const char *packet, ...); +void gdb_put_notification(const char *packet, size_t size); +#define gdb_put_notificationz(packet) gdb_put_notification((packet), strlen(packet)) void gdb_out(const char *buf); void gdb_voutf(const char *fmt, va_list);