Matt Hsu <matt@0xlab.org> cortex_a8_exec_opcode is writing the ARM instruction into
[openocd.git] / src / target / armv4_5.c
index 8d2167e5ebab49764be0f1a8ed8db308ae64d4b5..9f9aa2f5f037111893763cb29f47f6d8c48f0367 100644 (file)
@@ -339,9 +339,9 @@ int handle_armv4_5_reg_command(struct command_context_s *cmd_ctx, char *cmd, cha
                        {
                                armv4_5->full_context(target);
                        }
-                       output_len += snprintf(output + output_len, 
-                                              128 - output_len, 
-                                              "%8s: %8.8" PRIx32 " ", 
+                       output_len += snprintf(output + output_len,
+                                              128 - output_len,
+                                              "%8s: %8.8" PRIx32 " ",
                                               ARMV4_5_CORE_REG_MODENUM(armv4_5->core_cache, mode, num).name,
                                               buf_get_u32(ARMV4_5_CORE_REG_MODENUM(armv4_5->core_cache, mode, num).value, 0, 32));
                }
@@ -387,13 +387,15 @@ int handle_armv4_5_core_state_command(struct command_context_s *cmd_ctx, char *c
        return ERROR_OK;
 }
 
-int handle_armv4_5_disassemble_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int
+handle_armv4_5_disassemble_command(struct command_context_s *cmd_ctx,
+               char *cmd, char **args, int argc)
 {
        int retval = ERROR_OK;
        target_t *target = get_current_target(cmd_ctx);
        armv4_5_common_t *armv4_5 = target->arch_info;
        uint32_t address;
-       int count;
+       int count = 1;
        int i;
        arm_instruction_t cur_instruction;
        uint32_t opcode;
@@ -406,19 +408,32 @@ int handle_armv4_5_disassemble_command(struct command_context_s *cmd_ctx, char *
                return ERROR_OK;
        }
 
-       if (argc < 2)
-       {
-               command_print(cmd_ctx, "usage: armv4_5 disassemble <address> <count> ['thumb']");
+       switch (argc) {
+       case 3:
+               if (strcmp(args[2], "thumb") != 0)
+                       goto usage;
+               thumb = 1;
+               /* FALL THROUGH */
+       case 2:
+               count = strtoul(args[1], NULL, 0);
+               /* FALL THROUGH */
+       case 1:
+               address = strtoul(args[0], NULL, 0);
+               if (address & 0x01) {
+                       if (!thumb) {
+                               command_print(cmd_ctx, "Disassemble as Thumb");
+                               thumb = 1;
+                       }
+                       address &= ~1;
+               }
+               break;
+       default:
+usage:
+               command_print(cmd_ctx,
+                       "usage: armv4_5 disassemble <address> [<count> ['thumb']]");
                return ERROR_OK;
        }
 
-       address = strtoul(args[0], NULL, 0);
-       count = strtoul(args[1], NULL, 0);
-
-       if (argc >= 3)
-               if (strcmp(args[2], "thumb") == 0)
-                       thumb = 1;
-
        for (i = 0; i < count; i++)
        {
                if (thumb)
@@ -453,12 +468,20 @@ int armv4_5_register_commands(struct command_context_s *cmd_ctx)
 {
        command_t *armv4_5_cmd;
 
-       armv4_5_cmd = register_command(cmd_ctx, NULL, "armv4_5", NULL, COMMAND_ANY, "armv4/5 specific commands");
+       armv4_5_cmd = register_command(cmd_ctx, NULL, "armv4_5",
+                       NULL, COMMAND_ANY,
+                       "armv4/5 specific commands");
 
-       register_command(cmd_ctx, armv4_5_cmd, "reg", handle_armv4_5_reg_command, COMMAND_EXEC, "display ARM core registers");
-       register_command(cmd_ctx, armv4_5_cmd, "core_state", handle_armv4_5_core_state_command, COMMAND_EXEC, "display/change ARM core state <arm | thumb>");
+       register_command(cmd_ctx, armv4_5_cmd, "reg",
+                       handle_armv4_5_reg_command, COMMAND_EXEC,
+                       "display ARM core registers");
+       register_command(cmd_ctx, armv4_5_cmd, "core_state",
+                       handle_armv4_5_core_state_command, COMMAND_EXEC,
+                       "display/change ARM core state <arm | thumb>");
+       register_command(cmd_ctx, armv4_5_cmd, "disassemble",
+                       handle_armv4_5_disassemble_command, COMMAND_EXEC,
+                       "disassemble instructions <address> [<count> ['thumb']]");
 
-       register_command(cmd_ctx, armv4_5_cmd, "disassemble", handle_armv4_5_disassemble_command, COMMAND_EXEC, "disassemble instructions <address> <count> ['thumb']");
        return ERROR_OK;
 }
 

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)