diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-12-03 05:13:45 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-12-03 05:28:51 -0800 |
commit | 23f07d08e3998642326aa115cdd4cb1199f2704b (patch) | |
tree | 49b7652c84b8881327da0f2a9083c1bbbe07f8be | |
parent | 434f570e51a0b0f2c09184646d91154c74bbff81 (diff) | |
download | openocd_libswd-23f07d08e3998642326aa115cdd4cb1199f2704b.tar.gz openocd_libswd-23f07d08e3998642326aa115cdd4cb1199f2704b.tar.bz2 openocd_libswd-23f07d08e3998642326aa115cdd4cb1199f2704b.tar.xz openocd_libswd-23f07d08e3998642326aa115cdd4cb1199f2704b.zip |
fix regressions with GDB port numbers
Use a separate variable for iterating GDB service port numbers than
the one set by the user. Restores the behavior of returning the
original port number and only incrementing the port used on success.
-rw-r--r-- | src/server/gdb_server.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 40380a89..21cd0fed 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -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) |