gdb: fix compatibility with msp430-elf-gdb.

The new GDB expects 32-bit register fields, whereas msp430-gdb expected
16-bit fields. We distinguish between the two by looking at the list of
supported features on connection.
This commit is contained in:
Daniel Beer 2014-05-01 09:07:07 +12:00
parent d2f8592124
commit bb63112025
1 changed files with 24 additions and 6 deletions

View File

@ -35,6 +35,8 @@
#include "gdb_proto.h"
#include "ctrlc.h"
static int register_bytes;
/************************************************************************
* GDB server
*/
@ -49,10 +51,17 @@ static int read_registers(struct gdb_data *data)
return gdb_send(data, "E00");
gdb_packet_start(data);
for (i = 0; i < DEVICE_NUM_REGS; i++)
gdb_printf(data, "%02x%02x",
regs[i] & 0xff,
(regs[i] >> 8) & 0xff);
for (i = 0; i < DEVICE_NUM_REGS; i++) {
address_t value = regs[i];
int j;
for (j = 0; j < register_bytes; j++) {
gdb_printf(data, "%02x", value & 0xff);
value >>= 8;
}
}
gdb_packet_end(data);
return gdb_flush_ack(data);
}
@ -243,7 +252,7 @@ static int run_final_status(struct gdb_data *data)
* register. It complains if we give the full data.
*/
gdb_printf(data, "%02x:", i);
for (j = 0; j < 2; j++) {
for (j = 0; j < register_bytes; j++) {
gdb_printf(data, "%02x", value & 0xff);
value >>= 8;
}
@ -420,8 +429,16 @@ static int process_gdb_command(struct gdb_data *data, char *buf)
case 'q': /* Query */
if (!strncmp(buf, "qRcmd,", 6))
return monitor_command(data, buf + 6);
if (!strncmp(buf, "qSupported", 10))
if (!strncmp(buf, "qSupported", 10)) {
/* This is a hack to distinguish msp430-elf-gdb
* from msp430-gdb. The former expects 32-bit
* register fields.
*/
if (strstr(buf, "multiprocess+"))
register_bytes = 4;
return gdb_send_supported(data);
}
if (!strncmp(buf, "qfThreadInfo", 12))
return gdb_send_empty_threadlist(data);
break;
@ -514,6 +531,7 @@ static int gdb_server(int port)
printc("Client connected from %s:%d\n",
inet_ntoa(addr.sin_addr), htons(addr.sin_port));
register_bytes = 2;
gdb_init(&data, client);
/* Put the hardware breakpoint setting into a known state. */