This is an automated email from Gerrit.

Antonio Borneo ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/5310

-- gerrit

commit 4c64163c857dabbac2e8cb9206543382daf2d54e
Author: Antonio Borneo <[email protected]>
Date:   Fri Sep 27 12:27:01 2019 +0200

    gdb_server: fix extended_protocol for multi-target
    
    The flag extended_protocol is currently a single static variable
    thus, in case of multiple targets, it is shared among all the gdb
    connections. This is an issue if the gdb connections are not all
    using extended protocol, but also when one connection get closed
    because the code sets the flag to zero impacting the other
    connections still open.
    
    Move the flag extended_protocol in the per-connection struct
    gdb_connection.
    
    Change-Id: I19d565f925df6a31767fd8d392242f60867109f2
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 0202042..bd41adf 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -90,6 +90,8 @@ struct gdb_connection {
         * normally we reply with a S reply via gdb_last_signal_packet.
         * as a side note this behaviour only effects gdb > 6.8 */
        bool attached;
+       /* set when extended protocol is used */
+       bool extended_protocol;
        /* temporarily used for target description support */
        struct target_desc_format target_desc;
        /* temporarily used for thread list support */
@@ -948,6 +950,7 @@ static int gdb_new_connection(struct connection *connection)
        gdb_connection->sync = false;
        gdb_connection->mem_write_error = false;
        gdb_connection->attached = true;
+       gdb_connection->extended_protocol = false;
        gdb_connection->target_desc.tdesc = NULL;
        gdb_connection->target_desc.tdesc_length = 0;
        gdb_connection->thread_list = NULL;
@@ -3127,7 +3130,6 @@ static int gdb_input_inner(struct connection *connection)
        int packet_size;
        int retval;
        struct gdb_connection *gdb_con = connection->priv;
-       static int extended_protocol;
 
        target = get_target_from_connection(connection);
 
@@ -3279,7 +3281,6 @@ static int gdb_input_inner(struct connection *connection)
                                        break;
                                case 'D':
                                        retval = gdb_detach(connection);
-                                       extended_protocol = 0;
                                        break;
                                case 'X':
                                        retval = 
gdb_write_memory_binary_packet(connection, packet, packet_size);
@@ -3287,7 +3288,7 @@ static int gdb_input_inner(struct connection *connection)
                                                return retval;
                                        break;
                                case 'k':
-                                       if (extended_protocol != 0) {
+                                       if (gdb_con->extended_protocol) {
                                                gdb_con->attached = false;
                                                break;
                                        }
@@ -3295,7 +3296,7 @@ static int gdb_input_inner(struct connection *connection)
                                        return ERROR_SERVER_REMOTE_CLOSED;
                                case '!':
                                        /* handle extended remote protocol */
-                                       extended_protocol = 1;
+                                       gdb_con->extended_protocol = true;
                                        gdb_put_packet(connection, "OK", 2);
                                        break;
                                case 'R':

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to