Skip to content

Commit

Permalink
gdb_packet: add build flag to disable no ack mode
Browse files Browse the repository at this point in the history
  • Loading branch information
perigoso committed Jul 28, 2023
1 parent 7cab7df commit b5924fd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ ifdef RTT_IDENT
CFLAGS += -DRTT_IDENT=$(RTT_IDENT)
endif

ifeq ($(ENABLE_NOACKMODE), 1)
CFLAGS += -DENABLE_NOACKMODE=1
endif

OBJ = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(SRC)))

$(TARGET): include/version.h $(OBJ)
Expand Down
9 changes: 8 additions & 1 deletion src/gdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
#include "rtt.h"
#endif

#if ENABLE_NOACKMODE == 1
#define SUPPORTED_NOACKMODE ";QStartNoAckMode+"
#else
#define SUPPORTED_NOACKMODE ""
#endif

#if defined(_WIN32)
#include <malloc.h>
#else
Expand Down Expand Up @@ -430,7 +436,8 @@ static void exec_q_supported(const char *packet, const size_t length)
*/
gdb_set_noackmode(false);

gdb_putpacket_f("PacketSize=%X;qXfer:memory-map:read+;qXfer:features:read+;QStartNoAckMode+", GDB_MAX_PACKET_SIZE);
gdb_putpacket_f(
"PacketSize=%X;qXfer:memory-map:read+;qXfer:features:read+" SUPPORTED_NOACKMODE, GDB_MAX_PACKET_SIZE);
}

static void exec_q_memory_map(const char *packet, const size_t length)
Expand Down
9 changes: 9 additions & 0 deletions src/gdb_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ typedef enum packet_state {
PACKET_GDB_CHECKSUM_LOWER,
} packet_state_e;

#if ENABLE_NOACKMODE == 1
static bool noackmode = false;
#else
static const bool noackmode = false;
#endif

void gdb_set_noackmode(bool enable)
{
#if ENABLE_NOACKMODE == 1
/*
* If we were asked to disable no ack mode, and it was previously enabled,
* it might mean we got a packet we determined to be the first of a new
Expand All @@ -57,6 +62,10 @@ void gdb_set_noackmode(bool enable)

DEBUG_GDB("%s no ack mode\n", enable ? "Enable" : "Disable");
noackmode = enable;
#else
if (enable)
DEBUG_ERROR("Tried to set no ack mode but it's not enabled in this build\n");
#endif
}

packet_state_e consume_remote_packet(char *const packet, const size_t size)
Expand Down

0 comments on commit b5924fd

Please sign in to comment.