Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: threads-induced IDE hangups #1560

Merged
merged 2 commits into from
Jul 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/gdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ int gdb_main_loop(target_controller_s *tc, char *pbuf, size_t pbuf_size, size_t
gdb_putpacketz("OK");
break;
}
/* '[m|M|g|G|c][thread-id]' : Set the thread ID for the given subsequent operation
/*
* '[m|M|g|G|c][thread-id]' : Set the thread ID for the given subsequent operation
* (we don't actually care which as we only care about the TID for whether to send OK or an error)
*/
case 'H': {
Expand Down Expand Up @@ -254,7 +255,7 @@ int gdb_main_loop(target_controller_s *tc, char *pbuf, size_t pbuf_size, size_t
int n;
sscanf(pbuf, "P%" SCNx32 "=%n", &reg, &n);
// TODO: FIXME, VLAs considered harmful.
uint8_t val[strlen(&pbuf[n]) / 2U];
uint8_t val[strlen(pbuf + n) / 2U];
unhexify(val, pbuf + n, sizeof(val));
if (target_reg_write(cur_target, reg, val, sizeof(val)) > 0)
gdb_putpacketz("OK");
Expand All @@ -276,10 +277,11 @@ int gdb_main_loop(target_controller_s *tc, char *pbuf, size_t pbuf_size, size_t
break;

case '!': /* Enable Extended GDB Protocol. */
/* This doesn't do anything, we support the extended
* protocol anyway, but GDB will never send us a 'R'
* packet unless we answer 'OK' here.
*/
/*
* This doesn't do anything, we support the extended
* protocol anyway, but GDB will never send us a 'R'
* packet unless we answer 'OK' here.
*/
gdb_putpacketz("OK");
break;

Expand Down Expand Up @@ -495,7 +497,7 @@ static void exec_q_c(const char *packet, const size_t length)
static void exec_q_thread_info(const char *packet, const size_t length)
{
(void)length;
if (packet[-11] == 'f')
if (packet[-11] == 'f' && cur_target)
gdb_putpacketz("m1");
else
gdb_putpacketz("l");
Expand Down Expand Up @@ -655,8 +657,10 @@ static void handle_v_packet(char *packet, const size_t plen)
gdb_putpacketz("OK");

} else {
/* The vMustReplyEmpty is used as a feature test to check how gdbserver handles unknown packets */
/* print only actually unknown packets */
/*
* The vMustReplyEmpty is used as a feature test to check how gdbserver handles
* unknown packets print only actually unknown packets
*/
if (strcmp(packet, "vMustReplyEmpty") != 0)
DEBUG_GDB("*** Unsupported packet: %s\n", packet);
gdb_putpacket("", 0);
Expand Down