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/5201

-- gerrit

commit b7873056d64ddf480c1ba142834673a1776c7c6f
Author: Antonio Borneo <[email protected]>
Date:   Tue Jun 4 12:06:44 2019 +0200

    gdb_server: refuse gdb connection if target is not halted
    
    GDB expects the target to be halted by the inferior when the
    connection is established. OpenOCD embeds a default gdb-attach
    event handler to halt the target.
    There are situations that let gdb erroneously connect with the
    target not halted, e.g.:
    - default gdb-attach event handler replaced with an incorrect one
      that does not halt the target;
    - target in a secure state or without clock which prevents the
      debugger to halt the target;
    - target not examined yet and gdb-attach event handler not forcing
      the examine.
    In all the cases above (and potentially other not listed) gdb is
    not supposed to work. In case of target not examine, OpenOCD will
    even hit a segmentation fault.
    
    After the execution of the gdb-attach event handler, check if
    target has been properly halted and eventually return error to
    refuse the gdb connection.
    
    Change-Id: If727d68f683c3a94e4826e8c62977de41274ceff
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index c6cf7d3..cff588e 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -1019,6 +1019,13 @@ static int gdb_new_connection(struct connection 
*connection)
                        target_name(target),
                        target_state_name(target));
 
+       if (target->state != TARGET_HALTED) {
+               LOG_ERROR("Target %s not halted, refuse gdb connection %d!",
+                                 target_name(target), gdb_actual_connections);
+               gdb_actual_connections--;
+               return ERROR_FAIL;
+       }
+
        /* DANGER! If we fail subsequently, we must remove this handler,
         * otherwise we occasionally see crashes as the timer can invoke the
         * callback fn.

-- 


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

Reply via email to