This is an automated email from Gerrit. Alamy Liu ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/3320
-- gerrit commit 59259802651ffbcb0263a4befdd559a23ad2b0fc Author: Alamy Liu <[email protected]> Date: Mon Nov 2 13:39:00 2015 -0800 Debug: mdr command for opcode decoding Change-Id: I8bffb2111fe7fda28e23b51834fd7bea32817175 Signed-off-by: Alamy Liu <[email protected]> diff --git a/src/target/target.c b/src/target/target.c index 5f5b51a..6159759 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2960,6 +2960,68 @@ static void handle_md_output(struct command_context *cmd_ctx, } } +static void handle_md_rev_output(struct command_context *cmd_ctx, + struct target *target, uintmax_t address, unsigned size, + unsigned count, const uint8_t *buffer) +{ + const unsigned line_bytecnt = 32; + unsigned line_modulo = line_bytecnt / size; + + char output[line_bytecnt * 4 + 1]; + unsigned output_len = 0; + + const char *value_fmt; + switch (size) { + case 4: + value_fmt = "%8.8x "; + break; + case 2: + value_fmt = "%4.4x "; + break; + case 1: + value_fmt = "%2.2x "; + break; + default: + /* "can't happen", caller checked */ + LOG_ERROR("invalid memory read size: %u", size); + return; + } + + for (unsigned i = 0; i < count; i++) { +#if 0 + /* Address */ + if (i % line_modulo == 0) { + output_len += snprintf(output + output_len, + sizeof(output) - output_len, + "0x%.*" PRIXMAX ": ", + addr_fmt_width(target), (address + (i*size))); + } +#endif + + uint32_t value = 0; + const uint8_t *value_ptr = buffer + i * size; + switch (size) { + case 4: +// value = target_buffer_get_u32(target, value_ptr); + value = be_to_h_u32(value_ptr); + break; + case 2: + value = target_buffer_get_u16(target, value_ptr); + break; + case 1: + value = *value_ptr; + } + output_len += snprintf(output + output_len, + sizeof(output) - output_len, + value_fmt, value); + + if ((i % line_modulo == line_modulo - 1) || (i == count - 1)) { + command_print(cmd_ctx, "%s", output); + output_len = 0; + } + } +} + COMMAND_HANDLER(handle_md_command) { if (CMD_ARGC < 1) @@ -2968,6 +3030,8 @@ COMMAND_HANDLER(handle_md_command) unsigned size = 0; switch (CMD_NAME[2]) { /* Alamy: size = 8 ? */ + case 'r': /* Alamy: for debugging */ + /* fall through */ case 'w': size = 4; break; @@ -3007,6 +3071,10 @@ COMMAND_HANDLER(handle_md_command) if (ERROR_OK == retval) handle_md_output(CMD_CTX, target, address, size, count, buffer); + if (CMD_NAME[2] == 'r') { + handle_md_rev_output(CMD_CTX, target, address, size, count, buffer); + } + free(buffer); return retval; @@ -6109,6 +6177,14 @@ static const struct command_registration target_exec_command_handlers[] = { }, /* Alamy: "mdd" command */ { + .name = "mdr", /* Alamy: for debugging */ + .handler = handle_md_command, + .mode = COMMAND_EXEC, + .help = "display memory words (rev)", + .usage = "['phys'] address [count]", + }, + + { .name = "mdw", .handler = handle_md_command, .mode = COMMAND_EXEC, -- ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
