Commit 2f88e72135a66727ff51e7bc5f93f87c8096cf9c
authorMichel Pollet <buserror@gmail.com>
Sun, 14 Jun 2015 09:43:45 +0000 (10:43 +0100)
committerMichel Pollet <buserror@gmail.com>
Thu, 2 Jul 2015 18:02:54 +0000 (19:02 +0100)
Also make sure we mask of only 24 bits of the address, newer gdb use one
somehow..

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/sim_gdb.c

index 363dbca09bde99d089ae4aae3c4370a61dd69fa5..e7d95eff8ba6d0d05a270ad1e534c0edbd64c42f 100644 (file)
@@ -358,10 +358,19 @@ gdb_handle_command(
                        uint32_t len;
                        sscanf(cmd, "%x,%x", &addr, &len);
                        uint8_t * src = NULL;
+                       /* GDB seems to also use 0x1800000 for sram ?!?! */
+                       addr &= 0xffffff;
                        if (addr < avr->flashend) {
                                src = avr->flash + addr;
                        } else if (addr >= 0x800000 && (addr - 0x800000) <= avr->ramend) {
                                src = avr->data + addr - 0x800000;
+                       } else if (addr == (0x800000 + avr->ramend + 1) && len == 2) {
+                               // Allow GDB to read a value just after end of stack.
+                               // This is necessary to make instruction stepping work when stack is empty
+                               AVR_LOG(avr, LOG_TRACE,
+                                               "GDB: read just past end of stack %08x, %08x; returning zero\n", addr, len);
+                               gdb_send_reply(g, "0000");
+                               break;
                        } else if (addr >= 0x810000 && (addr - 0x810000) <= avr->e2end) {
                                avr_eeprom_desc_t ee = {.offset = (addr - 0x810000)};
                                avr_ioctl(avr, AVR_IOCTL_EEPROM_GET, &ee);
@@ -371,14 +380,10 @@ gdb_handle_command(
                                        gdb_send_reply(g, "E01");
                                        break;
                                }
-                       } else if (addr >= 0x800000 && (addr - 0x800000) == avr->ramend+1 && len == 2) {
-                               // Allow GDB to read a value just after end of stack.
-                               // This is necessary to make instruction stepping work when stack is empty
-                               AVR_LOG(avr, LOG_TRACE, "GDB: read just past end of stack %08x, %08x; returning zero\n", addr, len);
-                               gdb_send_reply(g, "0000");
-                               break;
                        } else {
-                               AVR_LOG(avr, LOG_ERROR, "GDB: read memory error %08x, %08x (ramend %04x)\n", addr, len, avr->ramend+1);
+                               AVR_LOG(avr, LOG_ERROR,
+                                               "GDB: read memory error %08x, %08x (ramend %04x)\n",
+                                               addr, len, avr->ramend+1);
                                gdb_send_reply(g, "E01");
                                break;
                        }