fix regressions with GDB port numbers
[openocd.git] / src / server / gdb_server.c
index 91852338bc3554298a8f745fd2c3d8d31589c1bd..21cd0fed9f050cfa798665fa7518bd2dcfa556a5 100644 (file)
@@ -31,7 +31,7 @@
 #include <target/target_request.h>
 #include <target/register.h>
 #include "server.h"
-#include "flash.h"
+#include <flash/flash.h>
 #include "gdb_server.h"
 #include <target/image.h>
 #include <jtag/jtag.h>
@@ -48,6 +48,7 @@ static enum breakpoint_type gdb_breakpoint_override_type;
 
 extern int gdb_error(struct connection *connection, int retval);
 static unsigned short gdb_port = 3333;
+static unsigned short gdb_port_next = 0;
 static const char *DIGITS = "0123456789abcdef";
 
 static void gdb_log_callback(void *priv, const char *file, unsigned line,
@@ -2217,6 +2218,8 @@ int gdb_target_add_one(struct target *target)
                LOG_INFO("gdb port disabled");
                return ERROR_OK;
        }
+       if (0 == gdb_port_next)
+               gdb_port_next = gdb_port;
 
        bool use_pipes = server_use_pipes;
        static bool server_started_with_pipes = false;
@@ -2229,10 +2232,12 @@ int gdb_target_add_one(struct target *target)
                use_pipes = false;
        }
 
-       int e = gdb_target_start(target, use_pipes ? 0 : gdb_port++);
+       int e = gdb_target_start(target, use_pipes ? 0 : gdb_port_next);
        if (ERROR_OK == e)
+       {
                server_started_with_pipes |= use_pipes;
-
+               gdb_port_next++;
+       }
        return e;
 }
 
@@ -2278,7 +2283,10 @@ COMMAND_HANDLER(handle_gdb_sync_command)
 /* daemon configuration command gdb_port */
 COMMAND_HANDLER(handle_gdb_port_command)
 {
-       return CALL_COMMAND_HANDLER(server_port_command, &gdb_port);
+       int retval = CALL_COMMAND_HANDLER(server_port_command, &gdb_port);
+       if (ERROR_OK == retval)
+               gdb_port_next = gdb_port;
+       return retval;
 }
 
 COMMAND_HANDLER(handle_gdb_memory_map_command)

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)