Fix regression in mdw output; identified by Magnus Lundin.
[openocd.git] / src / target / target.c
index 2209612cf180a2ef03c26b2560604a173d2653f2..d672649281add2bf6a737b3fa553cda9ffb17833 100644 (file)
@@ -34,6 +34,7 @@
 #endif
 
 #include "target.h"
+#include "target_type.h"
 #include "target_request.h"
 #include "time_support.h"
 #include "register.h"
@@ -41,8 +42,6 @@
 #include "image.h"
 #include "jtag.h"
 
-#include <inttypes.h>
-
 
 static int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 
@@ -467,6 +466,11 @@ static int default_examine(struct target_s *target)
        return ERROR_OK;
 }
 
+int target_examine_one(struct target_s *target)
+{
+       return target->type->examine(target);
+}
+
 /* Targets that correctly implement init+examine, i.e.
  * no communication with target during init:
  *
@@ -478,12 +482,16 @@ int target_examine(void)
        target_t *target = all_targets;
        while (target)
        {
-               if ((retval = target->type->examine(target))!=ERROR_OK)
+               if ((retval = target_examine_one(target)) != ERROR_OK)
                        return retval;
                target = target->next;
        }
        return retval;
 }
+const char *target_get_name(struct target_s *target)
+{
+       return target->type->name;
+}
 
 static int target_write_memory_imp(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer)
 {
@@ -536,6 +544,45 @@ int target_write_memory(struct target_s *target,
 {
        return target->type->write_memory(target, address, size, count, buffer);
 }
+int target_bulk_write_memory(struct target_s *target,
+               u32 address, u32 count, u8 *buffer)
+{
+       return target->type->bulk_write_memory(target, address, count, buffer);
+}
+
+int target_add_breakpoint(struct target_s *target,
+               struct breakpoint_s *breakpoint)
+{
+       return target->type->add_breakpoint(target, breakpoint);
+}
+int target_remove_breakpoint(struct target_s *target,
+               struct breakpoint_s *breakpoint)
+{
+       return target->type->remove_breakpoint(target, breakpoint);
+}
+
+int target_add_watchpoint(struct target_s *target,
+               struct watchpoint_s *watchpoint)
+{
+       return target->type->add_watchpoint(target, watchpoint);
+}
+int target_remove_watchpoint(struct target_s *target,
+               struct watchpoint_s *watchpoint)
+{
+       return target->type->remove_watchpoint(target, watchpoint);
+}
+
+int target_get_gdb_reg_list(struct target_s *target,
+               struct reg_s **reg_list[], int *reg_list_size)
+{
+       return target->type->get_gdb_reg_list(target, reg_list, reg_list_size);
+}
+int target_step(struct target_s *target,
+               int current, u32 address, int handle_breakpoints)
+{
+       return target->type->step(target, current, address, handle_breakpoints);
+}
+
 
 int target_run_algorithm(struct target_s *target,
                int num_mem_params, mem_param_t *mem_params,
@@ -580,7 +627,7 @@ int target_init(struct command_context_s *cmd_ctx)
 
                if ((retval = target->type->init_target(cmd_ctx, target)) != ERROR_OK)
                {
-                       LOG_ERROR("target '%s' init failed", target->type->name);
+                       LOG_ERROR("target '%s' init failed", target_get_name(target));
                        return retval;
                }
 
@@ -1433,7 +1480,7 @@ DumpTargets:
                command_print(cmd_ctx, "%2d: %-10s %-10s %-10s %10d %14s %s",
                                          target->target_number,
                                          target->cmd_name,
-                                         target->type->name,
+                                         target_get_name(target),
                                          Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness )->name,
                                          target->tap->abs_chain_position,
                                          target->tap->dotted_name,
@@ -1896,9 +1943,9 @@ static void handle_md_output(struct command_context_s *cmd_ctx,
 
        const char *value_fmt;
        switch (size) {
-       case 4: value_fmt = "%8.8x"; break;
-       case 2: value_fmt = "%4.2x"; break;
-       case 1: value_fmt = "%2.2x"; break;
+       case 4: value_fmt = "%8.8x "; break;
+       case 2: value_fmt = "%4.2x "; break;
+       case 1: value_fmt = "%2.2x "; break;
        default:
                LOG_ERROR("invalid memory read size: %u", size);
                exit(-1);
@@ -1913,7 +1960,7 @@ static void handle_md_output(struct command_context_s *cmd_ctx,
                                        "0x%8.8x: ", address + (i*size));
                }
 
-               u32 value;
+               u32 value=0;
                const u8 *value_ptr = buffer + i * size;
                switch (size) {
                case 4: value = target_buffer_get_u32(target, value_ptr); break;
@@ -3113,7 +3160,7 @@ void target_handle_event( target_t *target, enum target_event e )
                        LOG_DEBUG( "target: (%d) %s (%s) event: %d (%s) action: %s\n",
                                           target->target_number,
                                           target->cmd_name,
-                                          target->type->name,
+                                          target_get_name(target),
                                           e,
                                           Jim_Nvp_value2name_simple( nvp_target_event, e )->name,
                                           Jim_GetString( teap->body, NULL ) );
@@ -3202,7 +3249,7 @@ static int target_configure( Jim_GetOptInfo *goi, target_t *target )
                                        return JIM_ERR;
                                }
                        }
-                       Jim_SetResultString( goi->interp, target->type->name, -1 );
+                       Jim_SetResultString( goi->interp, target_get_name(target), -1 );
                        /* loop for more */
                        break;
                case TCFG_EVENT:
@@ -3401,7 +3448,7 @@ static int target_configure( Jim_GetOptInfo *goi, target_t *target )
                                if( e != JIM_OK ){
                                        return e;
                                }
-                               tap = jtag_TapByJimObj( goi->interp, o );
+                               tap = jtag_tap_by_jim_obj( goi->interp, o );
                                if( tap == NULL ){
                                        return JIM_ERR;
                                }

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)