This is an automated email from Gerrit.

Mathias Küster (kes...@freenet.de) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/518

-- gerrit

commit d65460632c46430efebc253ea7549a956303e745
Author: Mathias K <kes...@freenet.de>
Date:   Tue Mar 13 20:10:33 2012 +0100

    gdb_server: Add gdb_tdesc_path cmd and qXfer:features:read support
    
    This patch add the command gdb_tdesc_path to set the path to gdb
    XML target description file(s). Also the gdb qXfer:features:read
    support is enabled if a path is set.
    
    WARNING: the transfered filename from gdb is not parsed and it is
    possible to read the first 4094 bytes from every accessible file
    on the filesystem over this gdb connection. Feel free to fix this.
    
    Change-Id: I549c864ad66d185e96158faf22062de479556487
    Signed-off-by: Mathias K <kes...@freenet.de>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 058f938..09c07e3 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -88,6 +88,7 @@ static enum breakpoint_type gdb_breakpoint_override_type;
 static int gdb_error(struct connection *connection, int retval);
 static const char *gdb_port;
 static const char *gdb_port_next;
+static const char *gdb_tdesc_path;
 static const char DIGITS[16] = "0123456789abcdef";
 
 static void gdb_log_callback(void *priv, const char *file, unsigned line,
@@ -1772,9 +1773,10 @@ static int gdb_query_packet(struct connection 
*connection,
                        &buffer,
                        &pos,
                        &size,
-                       
"PacketSize=%x;qXfer:memory-map:read%c;qXfer:features:read-;QStartNoAckMode+",
+                       
"PacketSize=%x;qXfer:memory-map:read%c;qXfer:features:read%c;QStartNoAckMode+",
                        (GDB_BUFFER_SIZE - 1),
-                       ((gdb_use_memory_map == 1) && (flash_get_bank_count() > 
0)) ? '+' : '-');
+                       ((gdb_use_memory_map == 1) && (flash_get_bank_count() > 
0)) ? '+' : '-',
+                       (gdb_tdesc_path) ? '+' : '-');
 
                if (retval != ERROR_OK) {
                        gdb_send_error(connection, 01);
@@ -1793,10 +1795,13 @@ static int gdb_query_packet(struct connection 
*connection,
                int size = 0;
                int pos = 0;
                int retval = ERROR_OK;
-
+               char *filename;
+               char *filebuffer;
                int offset;
                unsigned int length;
                char *annex;
+               struct fileio fileio;
+               size_t read_bytes;
 
                /* skip command character */
                packet += 20;
@@ -1806,7 +1811,32 @@ static int gdb_query_packet(struct connection 
*connection,
                        return ERROR_OK;
                }
 
-               if (strcmp(annex, "target.xml") != 0) {
+               /* open target xml file */
+               filename = malloc(1024);
+               memset(filename, 0, 1024);
+               strncpy(filename,gdb_tdesc_path,1023);
+               strncat(filename,annex,1023-strlen(filename));
+
+               retval = fileio_open(&fileio, filename, FILEIO_READ, 
FILEIO_BINARY);
+
+               free(filename);
+
+               if (retval != ERROR_OK) {
+                       gdb_send_error(connection, 01);
+                       return ERROR_OK;
+               }
+
+               filebuffer = malloc(4096);
+               memset(filebuffer, 0, 4096);
+
+               filebuffer[0] = 'l';
+
+               retval = fileio_read(&fileio, 4096-2, filebuffer+1, 
&read_bytes);
+
+               fileio_close(&fileio);
+
+               if (retval != ERROR_OK) {
+                       free(filebuffer);
                        gdb_send_error(connection, 01);
                        return ERROR_OK;
                }
@@ -1815,7 +1845,9 @@ static int gdb_query_packet(struct connection *connection,
                        &xml,
                        &pos,
                        &size, \
-                       "l < target version=\"1.0\">\n < architecture > 
arm</architecture>\n</target>\n");
+                       filebuffer);
+
+               free(filebuffer);
 
                if (retval != ERROR_OK) {
                        gdb_error(connection, retval);
@@ -2402,6 +2434,19 @@ COMMAND_HANDLER(handle_gdb_breakpoint_override_command)
        return ERROR_OK;
 }
 
+/* gdb_tdesc_path */
+COMMAND_HANDLER(handle_gdb_tdesc_path)
+{
+       if (CMD_ARGC == 0) {
+               gdb_tdesc_path = NULL;
+       } else if (CMD_ARGC == 1) {
+               if (gdb_tdesc_path)
+                       free((void *)gdb_tdesc_path);
+               gdb_tdesc_path = strdup(CMD_ARGV[0]);
+       }
+       return ERROR_OK;
+}
+
 static const struct command_registration gdb_command_handlers[] = {
        {
                .name = "gdb_sync",
@@ -2454,6 +2499,13 @@ static const struct command_registration 
gdb_command_handlers[] = {
                        "to be used by gdb 'break' commands.",
                .usage = "('hard'|'soft'|'disable')"
        },
+       {
+               .name = "gdb_tdesc_path",
+               .handler = handle_gdb_tdesc_path,
+               .mode = COMMAND_CONFIG,
+               .help = "set or clear the path to the XML target description 
file(s)",
+               .usage = ""
+       },
        COMMAND_REGISTRATION_DONE
 };
 
@@ -2461,5 +2513,6 @@ int gdb_register_commands(struct command_context *cmd_ctx)
 {
        gdb_port = strdup("3333");
        gdb_port_next = strdup("3333");
+       gdb_tdesc_path = NULL;
        return register_commands(cmd_ctx, NULL, gdb_command_handlers);
 }

-- 

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to