msp430-elf-gdb

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

msp430-elf-gdb

Daniel Beer-3
Would anyone who has the new GDB handy mind trying this patch with the
latest (git) version of mspdebug? It's a bit ugly, but it should
hopefully work with both GDB versions without having to be configured.

If you could let me know your GDB version and whether or not it works,
that would be quite helpful.

diff --git a/ui/gdb.c b/ui/gdb.c
index c500d83..ddae214 100644
--- a/ui/gdb.c
+++ b/ui/gdb.c
@@ -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. */

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users