target/smp: reply to unknown packets in gdb_read_smp_packet

Some clients probe or use SMP-related 'j' packets. If OpenOCD
received an unknown 'j' packet, gdb_read_smp_packet previously did
not send any reply. This may result cause the client to hang while
waiting for a response.

Send an empty reply packet for unsupported 'j' packets.

Change-Id: I84c5e8e99f946d41dd5c11163c3eeb8af2b6c90f
Signed-off-by: Cristian Dinca <hello@icmd.tech>
Reviewed-on: https://review.openocd.org/c/openocd/+/9461
Tested-by: jenkins
Reviewed-by: Evgeniy Naydanov <eugnay@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Cristian Dinca
2026-02-13 15:50:48 +02:00
committed by Antonio Borneo
parent 092282c7d2
commit 22e1e1b33e
2 changed files with 28 additions and 19 deletions

View File

@@ -3753,18 +3753,30 @@ static int gdb_input_inner(struct connection *connection)
break; break;
case 'j': case 'j':
/* DEPRECATED */ if (strncmp(packet, "jc", 2) == 0) {
/* packet supported only by smp target i.e cortex_a.c*/ /* DEPRECATED */
/* handle smp packet replying coreid played to gbd */ /* packet supported only by smp target i.e cortex_a.c*/
gdb_read_smp_packet(connection, packet, packet_size); /* handle smp packet replying coreid played to gbd */
gdb_read_smp_packet(connection, packet, packet_size);
} else {
/* ignore unknown packets */
LOG_DEBUG("ignoring 0x%2.2x packet", packet[0]);
retval = gdb_put_packet(connection, "", 0);
}
break; break;
case 'J': case 'J':
/* DEPRECATED */ if (strncmp(packet, "jc", 2) == 0) {
/* packet supported only by smp target i.e cortex_a.c */ /* DEPRECATED */
/* handle smp packet setting coreid to be played at next /* packet supported only by smp target i.e cortex_a.c */
* resume to gdb */ /* handle smp packet setting coreid to be played at next
gdb_write_smp_packet(connection, packet, packet_size); * resume to gdb */
gdb_read_smp_packet(connection, packet, packet_size);
} else {
/* ignore unknown packets */
LOG_DEBUG("ignoring 0x%2.2x packet", packet[0]);
retval = gdb_put_packet(connection, "", 0);
}
break; break;
case 'F': case 'F':

View File

@@ -54,16 +54,13 @@ int gdb_read_smp_packet(struct connection *connection,
LOG_WARNING(DEPRECATED_MSG); LOG_WARNING(DEPRECATED_MSG);
if (target->smp) { if (target->smp) {
if (strncmp(packet, "jc", 2) == 0) { const uint32_t len = sizeof(target->gdb_service->core[0]);
const uint32_t len = sizeof(target->gdb_service->core[0]); char hex_buffer[len * 2 + 1];
char hex_buffer[len * 2 + 1]; uint8_t buffer[len];
uint8_t buffer[len]; buf_set_u32(buffer, 0, len * 8, target->gdb_service->core[0]);
buf_set_u32(buffer, 0, len * 8, target->gdb_service->core[0]); size_t pkt_len = hexify(hex_buffer, buffer, sizeof(buffer),
size_t pkt_len = hexify(hex_buffer, buffer, sizeof(buffer), sizeof(hex_buffer));
sizeof(hex_buffer)); retval = gdb_put_packet(connection, hex_buffer, pkt_len);
retval = gdb_put_packet(connection, hex_buffer, pkt_len);
}
} else } else
retval = gdb_put_packet(connection, "E01", 3); retval = gdb_put_packet(connection, "E01", 3);
return retval; return retval;