Update all server port command to use new helper.
[openocd.git] / src / server / gdb_server.c
index ad09a0e704624a47d605b3d3afdf5a9174b062f2..3ed2b1fc4c0310b92bf7268e8ef748f5144f0a9b 100644 (file)
@@ -52,17 +52,6 @@ static const char *DIGITS = "0123456789abcdef";
 static void gdb_log_callback(void *priv, const char *file, int line,
                const char *function, const char *string);
 
-enum gdb_detach_mode
-{
-       GDB_DETACH_RESUME,
-       GDB_DETACH_RESET,
-       GDB_DETACH_HALT,
-       GDB_DETACH_NOTHING
-};
-
-/* target behaviour on gdb detach */
-enum gdb_detach_mode detach_mode = GDB_DETACH_RESUME;
-
 /* number of gdb connections, mainly to supress gdb related debugging spam
  * in helper/log.c when no gdb connections are actually active */
 int gdb_actual_connections;
@@ -1960,29 +1949,11 @@ int gdb_v_packet(connection_t *connection, target_t *target, char *packet, int p
 
 int gdb_detach(connection_t *connection, target_t *target)
 {
+       gdb_service_t *gdb_service = connection->service->priv;
 
-       switch (detach_mode)
-       {
-               case GDB_DETACH_RESUME:
-                       target_handle_event(target, TARGET_EVENT_OLD_pre_resume);
-                       target_resume(target, 1, 0, 1, 0);
-                       break;
-
-               case GDB_DETACH_RESET:
-                       /* FIX?? make this configurable?? */
-                       target_process_reset(connection->cmd_ctx, RESET_HALT);
-                       break;
-
-               case GDB_DETACH_HALT:
-                       target_halt(target);
-                       break;
-
-               case GDB_DETACH_NOTHING:
-                       break;
-       }
+       target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_DETACH);
 
-       gdb_put_packet(connection, "OK", 2);
-       return ERROR_OK;
+       return gdb_put_packet(connection, "OK", 2);
 }
 
 static void gdb_log_callback(void *priv, const char *file, int line,
@@ -2300,46 +2271,7 @@ int handle_gdb_sync_command(struct command_context_s *cmd_ctx, char *cmd, char *
 /* daemon configuration command gdb_port */
 int handle_gdb_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
-       if (argc == 0)
-       {
-               command_print(cmd_ctx, "%d", gdb_port);
-               return ERROR_OK;
-       }
-
-       gdb_port = strtoul(args[0], NULL, 0);
-
-       return ERROR_OK;
-}
-
-int handle_gdb_detach_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
-       if (argc == 1)
-       {
-               if (strcmp(args[0], "resume") == 0)
-               {
-                       detach_mode = GDB_DETACH_RESUME;
-                       return ERROR_OK;
-               }
-               else if (strcmp(args[0], "reset") == 0)
-               {
-                       detach_mode = GDB_DETACH_RESET;
-                       return ERROR_OK;
-               }
-               else if (strcmp(args[0], "halt") == 0)
-               {
-                       detach_mode = GDB_DETACH_HALT;
-                       return ERROR_OK;
-               }
-               else if (strcmp(args[0], "nothing") == 0)
-               {
-                       detach_mode = GDB_DETACH_NOTHING;
-                       return ERROR_OK;
-               }
-               else
-                       LOG_WARNING("invalid gdb_detach configuration directive: %s", args[0]);
-       }
-
-       return ERROR_COMMAND_SYNTAX_ERROR;
+       return server_port_command(cmd_ctx, cmd, args, argc, &gdb_port);
 }
 
 int handle_gdb_memory_map_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
@@ -2445,9 +2377,6 @@ int gdb_register_commands(command_context_t *command_context)
                        COMMAND_ANY, "next stepi will return immediately allowing GDB fetch register state without affecting target state");
        register_command(command_context, NULL, "gdb_port", handle_gdb_port_command,
                        COMMAND_ANY, "daemon configuration command gdb_port");
-       register_command(command_context, NULL, "gdb_detach", handle_gdb_detach_command,
-                       COMMAND_CONFIG, "resume/reset/halt/nothing - "
-                       "specify behavior when GDB detaches from the target");
        register_command(command_context, NULL, "gdb_memory_map", handle_gdb_memory_map_command,
                        COMMAND_CONFIG, "enable or disable memory map");
        register_command(command_context, NULL, "gdb_flash_program", handle_gdb_flash_program_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)