Commit ad47d913b54cef188269c4b75fdde51d27d6fe32
authorDoug Goldstein <cardoe@cardoe.com>
Sun, 16 Mar 2014 20:02:59 +0000 (15:02 -0500)
committerDoug Goldstein <cardoe@cardoe.com>
Tue, 18 Mar 2014 01:36:28 +0000 (20:36 -0500)
GDB wants to have knowledge of the RAM and flash regions of memory on
the chips. Since AVR is Harvard architecture, the RAM must begin at a
fake offset and per Atmel's docs that is 0x800000.

simavr/sim/sim_gdb.c

index a9d4c84489f3de1e206c445439c1780956a7b14c..363dbca09bde99d089ae4aae3c4370a61dd69fa5 100644 (file)
@@ -288,7 +288,14 @@ gdb_handle_command(
        uint8_t command = *cmd++;
        switch (command) {
                case 'q':
-                       if (strncmp(cmd, "Attached", 8) == 0) {
+                       if (strncmp(cmd, "Supported", 9) == 0) {
+                               /* If GDB asked what features we support, report back
+                                * the features we support, which is just memory layout
+                                * information for now.
+                                */
+                               gdb_send_reply(g, "qXfer:memory-map:read+");
+                               break;
+                       } else if (strncmp(cmd, "Attached", 8) == 0) {
                                /* Respond that we are attached to an existing process..
                                 * ourselves!
                                 */
@@ -297,6 +304,19 @@ gdb_handle_command(
                        } else if (strncmp(cmd, "Offsets", 7) == 0) {
                                gdb_send_reply(g, "Text=0;Data=800000;Bss=800000");
                                break;
+                       } else if (strncmp(cmd, "Xfer:memory-map:read", 20) == 0) {
+                               snprintf(rep, sizeof(rep),
+                                               "l<memory-map>\n"
+                                               " <memory type='ram' start='0x800000' length='%#x'/>\n"
+                                               " <memory type='flash' start='0' length='%#x'>\n"
+                                               "  <property name='blocksize'>0x80</property>\n"
+                                               " </memory>\n"
+                                               "</memory-map>",
+                                               g->avr->ramend + 1, g->avr->flashend + 1);
+
+                               gdb_send_reply(g, rep);
+                               break;
+            }
                        gdb_send_reply(g, "");
                        break;
                case '?':