- comment about dummy ack '+' char from gdb
[openocd.git] / src / server / gdb_server.c
index c2c18baf208d7bf69824d32d397b606751f33ac0..cea5ad0db0046e8e4086dc66f84a6760e378ef2c 100644 (file)
@@ -287,7 +287,6 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
         * however sometimes '-' is sent even though we've already received
         * an ACK (+) for everything we've sent off.
         */
-#ifndef _WIN32
        int gotdata;
        for (;;)
        {
@@ -299,7 +298,6 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
                        return retval;
                LOG_WARNING("Discard unexpected char %c", reply);
        }
-#endif
 #endif
 
        while (1)
@@ -413,6 +411,8 @@ int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
                                case '$':
                                        break;
                                case '+':
+                                       /* gdb sends a dummy ack '+' at every remote connect - see remote_start_remote (remote.c)
+                                        * incase anyone tries to debug why they receive this warning every time */
                                        LOG_WARNING("acknowledgment received, but no packet pending");
                                        break;
                                case '-':
@@ -509,7 +509,6 @@ int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
                                my_checksum += character & 0xff;
                                buffer[count++] = character & 0xff;
                        }
-
                }
 
                *len = count;
@@ -568,7 +567,7 @@ int gdb_output_con(connection_t *connection, const char* line)
        return ERROR_OK;
 }
 
-int gdb_output(struct command_context_s *context, char* line)
+int gdb_output(struct command_context_s *context, const char* line)
 {
        /* this will be dumped to the log and also sent as an O packet if possible */
        LOG_USER_N("%s", line);
@@ -577,24 +576,10 @@ int gdb_output(struct command_context_s *context, char* line)
 
 int gdb_program_handler(struct target_s *target, enum target_event event, void *priv)
 {
-       FILE *script;
        struct command_context_s *cmd_ctx = priv;
 
-       if (target->gdb_program_script)
-       {
-               script = open_file_from_path(target->gdb_program_script, "r");
-               if (!script)
-               {
-                       LOG_ERROR("couldn't open script file %s", target->gdb_program_script);
-                               return ERROR_OK;
-               }
-
-               LOG_INFO("executing gdb_program script '%s'", target->gdb_program_script);
-               command_run_file(cmd_ctx, script, COMMAND_EXEC);
-               fclose(script);
-
-               jtag_execute_queue();
-       }
+       target_invoke_script(cmd_ctx, target, "gdb_program");
+       jtag_execute_queue();
 
        return ERROR_OK;
 }
@@ -1233,6 +1218,7 @@ void gdb_step_continue_packet(connection_t *connection, target_t *target, char *
        if (packet[0] == 'c')
        {
                LOG_DEBUG("continue");
+               target_invoke_script(connection->cmd_ctx, target, "pre_resume");
                target_resume(target, current, address, 0, 0); /* resume at current address, don't handle breakpoints, not debugging */
        }
        else if (packet[0] == 's')
@@ -1518,7 +1504,7 @@ int gdb_query_packet(connection_t *connection, target_t *target, char *packet, i
 
                xml_printf(&retval, &buffer, &pos, &size,
                                "PacketSize=%x;qXfer:memory-map:read%c;qXfer:features:read-",
-                               (GDB_BUFFER_SIZE - 1), gdb_use_memory_map == 1 ? '+' : '-');
+                               (GDB_BUFFER_SIZE - 1), ((gdb_use_memory_map == 1)&&(flash_get_bank_count()>0)) ? '+' : '-');
 
                if (retval != ERROR_OK)
                {
@@ -1531,7 +1517,7 @@ int gdb_query_packet(connection_t *connection, target_t *target, char *packet, i
 
                return ERROR_OK;
        }
-       else if (strstr(packet, "qXfer:memory-map:read::"))
+       else if (strstr(packet, "qXfer:memory-map:read::")&&(flash_get_bank_count()>0))
        {
                /* We get away with only specifying flash here. Regions that are not
                 * specified are treated as if we provided no memory map(if not we
@@ -1815,11 +1801,13 @@ int gdb_detach(connection_t *connection, target_t *target)
        switch( detach_mode )
        {
                case GDB_DETACH_RESUME:
+                       target_invoke_script(connection->cmd_ctx, target, "pre_resume");
                        target_resume(target, 1, 0, 1, 0);
                        break;
 
                case GDB_DETACH_RESET:
-                       target_process_reset(connection->cmd_ctx);
+                       /* FIX?? make this configurable?? */
+                       target_process_reset(connection->cmd_ctx, RESET_HALT);
                        break;
 
                case GDB_DETACH_HALT:
@@ -1961,7 +1949,7 @@ int gdb_input_inner(connection_t *connection)
                                        break;
                                case 'R':
                                        /* handle extended restart packet */
-                                       target_process_reset(connection->cmd_ctx);
+                                       command_run_linef(connection->cmd_ctx, "ocd_gdb_restart %d", get_num_by_target(target));
                                        break;
                                default:
                                        /* ignore unkown packets */

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)