helper/binarybuffer: fix clang static analyzer warnings
[openocd.git] / src / target / etm.c
index ddeb9226e501ebe5b381fb22fa4462d60c833d6e..5218a9e480bfb19f0fac9998c7ff2a46e56dc940 100644 (file)
@@ -13,9 +13,7 @@
  *   GNU General Public License for more details.                          *
  *                                                                         *
  *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -305,6 +303,11 @@ struct reg_cache *etm_build_reg_cache(struct target *target,
        reg_list = calloc(128, sizeof(struct reg));
        arch_info = calloc(128, sizeof(struct etm_reg));
 
+       if (reg_cache == NULL || reg_list == NULL || arch_info == NULL) {
+               LOG_ERROR("No memory");
+               goto fail;
+       }
+
        /* fill in values for the reg cache */
        reg_cache->name = "etm registers";
        reg_cache->next = NULL;
@@ -500,6 +503,7 @@ static int etm_read_reg_w_check(struct reg *reg,
        uint8_t *check_value, uint8_t *check_mask)
 {
        struct etm_reg *etm_reg = reg->arch_info;
+       assert(etm_reg);
        const struct etm_reg_info *r = etm_reg->reg_info;
        uint8_t reg_addr = r->addr & 0x7f;
        struct scan_field fields[3];
@@ -515,7 +519,7 @@ static int etm_read_reg_w_check(struct reg *reg,
        retval = arm_jtag_scann(etm_reg->jtag_info, 0x6, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
-       retval = arm_jtag_set_instr(etm_reg->jtag_info,
+       retval = arm_jtag_set_instr(etm_reg->jtag_info->tap,
                        etm_reg->jtag_info->intest_instr,
                        NULL,
                        TAP_IDLE);
@@ -529,7 +533,7 @@ static int etm_read_reg_w_check(struct reg *reg,
        fields[0].check_mask = NULL;
 
        fields[1].num_bits = 7;
-       uint8_t temp1;
+       uint8_t temp1 = 0;
        fields[1].out_value = &temp1;
        buf_set_u32(&temp1, 0, 7, reg_addr);
        fields[1].in_value = NULL;
@@ -537,7 +541,7 @@ static int etm_read_reg_w_check(struct reg *reg,
        fields[1].check_mask = NULL;
 
        fields[2].num_bits = 1;
-       uint8_t temp2;
+       uint8_t temp2 = 0;
        fields[2].out_value = &temp2;
        buf_set_u32(&temp2, 0, 1, 0);
        fields[2].in_value = NULL;
@@ -602,7 +606,7 @@ static int etm_write_reg(struct reg *reg, uint32_t value)
        retval = arm_jtag_scann(etm_reg->jtag_info, 0x6, TAP_IDLE);
        if (retval != ERROR_OK)
                return retval;
-       retval = arm_jtag_set_instr(etm_reg->jtag_info,
+       retval = arm_jtag_set_instr(etm_reg->jtag_info->tap,
                        etm_reg->jtag_info->intest_instr,
                        NULL,
                        TAP_IDLE);
@@ -616,13 +620,13 @@ static int etm_write_reg(struct reg *reg, uint32_t value)
        fields[0].in_value = NULL;
 
        fields[1].num_bits = 7;
-       uint8_t tmp2;
+       uint8_t tmp2 = 0;
        fields[1].out_value = &tmp2;
        buf_set_u32(&tmp2, 0, 7, reg_addr);
        fields[1].in_value = NULL;
 
        fields[2].num_bits = 1;
-       uint8_t tmp3;
+       uint8_t tmp3 = 0;
        fields[2].out_value = &tmp3;
        buf_set_u32(&tmp3, 0, 1, 1);
        fields[2].in_value = NULL;
@@ -861,7 +865,7 @@ static int etmv1_data(struct etm_context *ctx, int size, uint32_t *data)
        return 0;
 }
 
-static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *cmd_ctx)
+static int etmv1_analyze_trace(struct etm_context *ctx, struct command_invocation *cmd)
 {
        int retval;
        struct arm_instruction instruction;
@@ -871,7 +875,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                ctx->capture_driver->read_trace(ctx);
 
        if (ctx->trace_depth == 0) {
-               command_print(cmd_ctx, "Trace is empty.");
+               command_print(cmd, "Trace is empty.");
                return ERROR_OK;
        }
 
@@ -895,7 +899,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                int current_pc_ok = ctx->pc_ok;
 
                if (ctx->trace_data[ctx->pipe_index].flags & ETMV1_TRIGGER_CYCLE)
-                       command_print(cmd_ctx, "--- trigger ---");
+                       command_print(cmd, "--- trigger ---");
 
                /* instructions execute in IE/D or BE/D cycles */
                if ((pipestat == STAT_IE) || (pipestat == STAT_ID))
@@ -944,7 +948,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                        next_pc = ctx->last_branch;
                                        break;
                                case 0x1:       /* tracing enabled */
-                                       command_print(cmd_ctx,
+                                       command_print(cmd,
                                                "--- tracing enabled at 0x%8.8" PRIx32 " ---",
                                                ctx->last_branch);
                                        ctx->current_pc = ctx->last_branch;
@@ -952,7 +956,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                        continue;
                                        break;
                                case 0x2:       /* trace restarted after FIFO overflow */
-                                       command_print(cmd_ctx,
+                                       command_print(cmd,
                                                "--- trace restarted after FIFO overflow at 0x%8.8" PRIx32 " ---",
                                                ctx->last_branch);
                                        ctx->current_pc = ctx->last_branch;
@@ -960,7 +964,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                        continue;
                                        break;
                                case 0x3:       /* exit from debug state */
-                                       command_print(cmd_ctx,
+                                       command_print(cmd,
                                                "--- exit from debug state at 0x%8.8" PRIx32 " ---",
                                                ctx->last_branch);
                                        ctx->current_pc = ctx->last_branch;
@@ -973,7 +977,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                         * we have to move on with the next trace cycle
                                         */
                                        if (!current_pc_ok) {
-                                               command_print(cmd_ctx,
+                                               command_print(cmd,
                                                        "--- periodic synchronization point at 0x%8.8" PRIx32 " ---",
                                                        next_pc);
                                                ctx->current_pc = next_pc;
@@ -1000,9 +1004,9 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                || ((ctx->last_branch >= 0xffff0000) &&
                                (ctx->last_branch <= 0xffff0020))) {
                                if ((ctx->last_branch & 0xff) == 0x10)
-                                       command_print(cmd_ctx, "data abort");
+                                       command_print(cmd, "data abort");
                                else {
-                                       command_print(cmd_ctx,
+                                       command_print(cmd,
                                                "exception vector 0x%2.2" PRIx32 "",
                                                ctx->last_branch);
                                        ctx->current_pc = ctx->last_branch;
@@ -1060,7 +1064,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                        ctx->ptr_ok = 1;
 
                                if (ctx->ptr_ok)
-                                       command_print(cmd_ctx,
+                                       command_print(cmd,
                                                "address: 0x%8.8" PRIx32 "",
                                                ctx->last_ptr);
                        }
@@ -1075,7 +1079,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                                        uint32_t data;
                                                        if (etmv1_data(ctx, 4, &data) != 0)
                                                                return ERROR_ETM_ANALYSIS_FAILED;
-                                                       command_print(cmd_ctx,
+                                                       command_print(cmd,
                                                                "data: 0x%8.8" PRIx32 "",
                                                                data);
                                                }
@@ -1086,7 +1090,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                        if (etmv1_data(ctx, arm_access_size(&instruction),
                                                &data) != 0)
                                                return ERROR_ETM_ANALYSIS_FAILED;
-                                       command_print(cmd_ctx, "data: 0x%8.8" PRIx32 "", data);
+                                       command_print(cmd, "data: 0x%8.8" PRIx32 "", data);
                                }
                        }
 
@@ -1121,7 +1125,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_context *
                                        (cycles == 1) ? "cycle" : "cycles");
                        }
 
-                       command_print(cmd_ctx, "%s%s%s",
+                       command_print(cmd, "%s%s%s",
                                instruction.text,
                                (pipestat == STAT_IN) ? " (not executed)" : "",
                                cycles_text);
@@ -1158,7 +1162,7 @@ static COMMAND_HELPER(handle_etm_tracemode_command_update,
        else if (strcmp(CMD_ARGV[0], "all") == 0)
                tracemode = ETM_CTRL_TRACE_DATA | ETM_CTRL_TRACE_ADDR;
        else {
-               command_print(CMD_CTX, "invalid option '%s'", CMD_ARGV[0]);
+               command_print(CMD, "invalid option '%s'", CMD_ARGV[0]);
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
@@ -1178,7 +1182,7 @@ static COMMAND_HELPER(handle_etm_tracemode_command_update,
                        tracemode |= ETM_CTRL_CONTEXTID_32;
                        break;
                default:
-                       command_print(CMD_CTX, "invalid option '%s'", CMD_ARGV[1]);
+                       command_print(CMD, "invalid option '%s'", CMD_ARGV[1]);
                        return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
@@ -1209,13 +1213,13 @@ COMMAND_HANDLER(handle_etm_tracemode_command)
        struct etm_context *etm;
 
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm = arm->etm;
        if (!etm) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
@@ -1237,47 +1241,47 @@ COMMAND_HANDLER(handle_etm_tracemode_command)
         * or couldn't be written; display actual hardware state...
         */
 
-       command_print(CMD_CTX, "current tracemode configuration:");
+       command_print(CMD, "current tracemode configuration:");
 
        switch (tracemode & ETM_CTRL_TRACE_MASK) {
                default:
-                       command_print(CMD_CTX, "data tracing: none");
+                       command_print(CMD, "data tracing: none");
                        break;
                case ETM_CTRL_TRACE_DATA:
-                       command_print(CMD_CTX, "data tracing: data only");
+                       command_print(CMD, "data tracing: data only");
                        break;
                case ETM_CTRL_TRACE_ADDR:
-                       command_print(CMD_CTX, "data tracing: address only");
+                       command_print(CMD, "data tracing: address only");
                        break;
                case ETM_CTRL_TRACE_DATA | ETM_CTRL_TRACE_ADDR:
-                       command_print(CMD_CTX, "data tracing: address and data");
+                       command_print(CMD, "data tracing: address and data");
                        break;
        }
 
        switch (tracemode & ETM_CTRL_CONTEXTID_MASK) {
                case ETM_CTRL_CONTEXTID_NONE:
-                       command_print(CMD_CTX, "contextid tracing: none");
+                       command_print(CMD, "contextid tracing: none");
                        break;
                case ETM_CTRL_CONTEXTID_8:
-                       command_print(CMD_CTX, "contextid tracing: 8 bit");
+                       command_print(CMD, "contextid tracing: 8 bit");
                        break;
                case ETM_CTRL_CONTEXTID_16:
-                       command_print(CMD_CTX, "contextid tracing: 16 bit");
+                       command_print(CMD, "contextid tracing: 16 bit");
                        break;
                case ETM_CTRL_CONTEXTID_32:
-                       command_print(CMD_CTX, "contextid tracing: 32 bit");
+                       command_print(CMD, "contextid tracing: 32 bit");
                        break;
        }
 
        if (tracemode & ETM_CTRL_CYCLE_ACCURATE)
-               command_print(CMD_CTX, "cycle-accurate tracing enabled");
+               command_print(CMD, "cycle-accurate tracing enabled");
        else
-               command_print(CMD_CTX, "cycle-accurate tracing disabled");
+               command_print(CMD, "cycle-accurate tracing disabled");
 
        if (tracemode & ETM_CTRL_BRANCH_OUTPUT)
-               command_print(CMD_CTX, "full branch address output enabled");
+               command_print(CMD, "full branch address output enabled");
        else
-               command_print(CMD_CTX, "full branch address output disabled");
+               command_print(CMD, "full branch address output disabled");
 
 #define TRACEMODE_MASK ( \
                ETM_CTRL_CONTEXTID_MASK \
@@ -1333,7 +1337,7 @@ COMMAND_HANDLER(handle_etm_config_command)
 
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "target '%s' is '%s'; not an ARM",
+               command_print(CMD, "target '%s' is '%s'; not an ARM",
                        target_name(target),
                        target_type_name(target));
                return ERROR_FAIL;
@@ -1384,7 +1388,7 @@ COMMAND_HANDLER(handle_etm_config_command)
                        portmode |= ETM_PORT_2BIT;
                        break;
                default:
-                       command_print(CMD_CTX,
+                       command_print(CMD,
                                "unsupported ETM port width '%s'", CMD_ARGV[1]);
                        return ERROR_FAIL;
        }
@@ -1396,7 +1400,7 @@ COMMAND_HANDLER(handle_etm_config_command)
        else if (strcmp("demultiplexed", CMD_ARGV[2]) == 0)
                portmode |= ETM_PORT_DEMUXED;
        else {
-               command_print(CMD_CTX,
+               command_print(CMD,
                        "unsupported ETM port mode '%s', must be 'normal', 'multiplexed' or 'demultiplexed'",
                        CMD_ARGV[2]);
                return ERROR_FAIL;
@@ -1407,7 +1411,7 @@ COMMAND_HANDLER(handle_etm_config_command)
        else if (strcmp("full", CMD_ARGV[3]) == 0)
                portmode |= ETM_PORT_FULL_CLOCK;
        else {
-               command_print(CMD_CTX,
+               command_print(CMD,
                        "unsupported ETM port clocking '%s', must be 'full' or 'half'",
                        CMD_ARGV[3]);
                return ERROR_FAIL;
@@ -1463,44 +1467,44 @@ COMMAND_HANDLER(handle_etm_info_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm = arm->etm;
        if (!etm) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
-       command_print(CMD_CTX, "ETM v%d.%d",
+       command_print(CMD, "ETM v%d.%d",
                etm->bcd_vers >> 4, etm->bcd_vers & 0xf);
-       command_print(CMD_CTX, "pairs of address comparators: %i",
+       command_print(CMD, "pairs of address comparators: %i",
                (int) (etm->config >> 0) & 0x0f);
-       command_print(CMD_CTX, "data comparators: %i",
+       command_print(CMD, "data comparators: %i",
                (int) (etm->config >> 4) & 0x0f);
-       command_print(CMD_CTX, "memory map decoders: %i",
+       command_print(CMD, "memory map decoders: %i",
                (int) (etm->config >> 8) & 0x1f);
-       command_print(CMD_CTX, "number of counters: %i",
+       command_print(CMD, "number of counters: %i",
                (int) (etm->config >> 13) & 0x07);
-       command_print(CMD_CTX, "sequencer %spresent",
+       command_print(CMD, "sequencer %spresent",
                (int) (etm->config & (1 << 16)) ? "" : "not ");
-       command_print(CMD_CTX, "number of ext. inputs: %i",
+       command_print(CMD, "number of ext. inputs: %i",
                (int) (etm->config >> 17) & 0x07);
-       command_print(CMD_CTX, "number of ext. outputs: %i",
+       command_print(CMD, "number of ext. outputs: %i",
                (int) (etm->config >> 20) & 0x07);
-       command_print(CMD_CTX, "FIFO full %spresent",
+       command_print(CMD, "FIFO full %spresent",
                (int) (etm->config & (1 << 23)) ? "" : "not ");
        if (etm->bcd_vers < 0x20)
-               command_print(CMD_CTX, "protocol version: %i",
+               command_print(CMD, "protocol version: %i",
                        (int) (etm->config >> 28) & 0x07);
        else {
-               command_print(CMD_CTX,
+               command_print(CMD,
                        "coprocessor and memory access %ssupported",
                        (etm->config & (1 << 26)) ? "" : "not ");
-               command_print(CMD_CTX, "trace start/stop %spresent",
+               command_print(CMD, "trace start/stop %spresent",
                        (etm->config & (1 << 26)) ? "" : "not ");
-               command_print(CMD_CTX, "number of context comparators: %i",
+               command_print(CMD, "number of context comparators: %i",
                        (int) (etm->config >> 24) & 0x03);
        }
 
@@ -1551,30 +1555,30 @@ COMMAND_HANDLER(handle_etm_info_command)
                        LOG_ERROR("Illegal max_port_size");
                        return ERROR_FAIL;
        }
-       command_print(CMD_CTX, "max. port size: %i", max_port_size);
+       command_print(CMD, "max. port size: %i", max_port_size);
 
        if (etm->bcd_vers < 0x30) {
-               command_print(CMD_CTX, "half-rate clocking %ssupported",
+               command_print(CMD, "half-rate clocking %ssupported",
                        (config & (1 << 3)) ? "" : "not ");
-               command_print(CMD_CTX, "full-rate clocking %ssupported",
+               command_print(CMD, "full-rate clocking %ssupported",
                        (config & (1 << 4)) ? "" : "not ");
-               command_print(CMD_CTX, "normal trace format %ssupported",
+               command_print(CMD, "normal trace format %ssupported",
                        (config & (1 << 5)) ? "" : "not ");
-               command_print(CMD_CTX, "multiplex trace format %ssupported",
+               command_print(CMD, "multiplex trace format %ssupported",
                        (config & (1 << 6)) ? "" : "not ");
-               command_print(CMD_CTX, "demultiplex trace format %ssupported",
+               command_print(CMD, "demultiplex trace format %ssupported",
                        (config & (1 << 7)) ? "" : "not ");
        } else {
                /* REVISIT show which size and format are selected ... */
-               command_print(CMD_CTX, "current port size %ssupported",
+               command_print(CMD, "current port size %ssupported",
                        (config & (1 << 10)) ? "" : "not ");
-               command_print(CMD_CTX, "current trace format %ssupported",
+               command_print(CMD, "current trace format %ssupported",
                        (config & (1 << 11)) ? "" : "not ");
        }
        if (etm->bcd_vers >= 0x21)
-               command_print(CMD_CTX, "fetch comparisons %ssupported",
+               command_print(CMD, "fetch comparisons %ssupported",
                        (config & (1 << 17)) ? "not " : "");
-       command_print(CMD_CTX, "FIFO full %ssupported",
+       command_print(CMD, "FIFO full %ssupported",
                (config & (1 << 8)) ? "" : "not ");
 
        return ERROR_OK;
@@ -1590,13 +1594,13 @@ COMMAND_HANDLER(handle_etm_status_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm = arm->etm;
        if (!etm) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
@@ -1610,7 +1614,7 @@ COMMAND_HANDLER(handle_etm_status_command)
                if (etm_get_reg(reg) == ERROR_OK) {
                        unsigned s = buf_get_u32(reg->value, 0, reg->size);
 
-                       command_print(CMD_CTX, "etm: %s%s%s%s",
+                       command_print(CMD, "etm: %s%s%s%s",
                                /* bit(1) == progbit */
                                (etm->bcd_vers >= 0x12)
                                ? ((s & (1 << 1))
@@ -1628,21 +1632,21 @@ COMMAND_HANDLER(handle_etm_status_command)
        /* Trace Port Driver status */
        trace_status = etm->capture_driver->status(etm);
        if (trace_status == TRACE_IDLE)
-               command_print(CMD_CTX, "%s: idle", etm->capture_driver->name);
+               command_print(CMD, "%s: idle", etm->capture_driver->name);
        else {
                static char *completed = " completed";
                static char *running = " is running";
                static char *overflowed = ", overflowed";
                static char *triggered = ", triggered";
 
-               command_print(CMD_CTX, "%s: trace collection%s%s%s",
+               command_print(CMD, "%s: trace collection%s%s%s",
                        etm->capture_driver->name,
                        (trace_status & TRACE_RUNNING) ? running : completed,
                        (trace_status & TRACE_OVERFLOWED) ? overflowed : "",
                        (trace_status & TRACE_TRIGGERED) ? triggered : "");
 
                if (etm->trace_depth > 0) {
-                       command_print(CMD_CTX, "%i frames of trace data read",
+                       command_print(CMD, "%i frames of trace data read",
                                (int)(etm->trace_depth));
                }
        }
@@ -1662,20 +1666,20 @@ COMMAND_HANDLER(handle_etm_image_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm_ctx = arm->etm;
        if (!etm_ctx) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
        if (etm_ctx->image) {
                image_close(etm_ctx->image);
                free(etm_ctx->image);
-               command_print(CMD_CTX, "previously loaded image found and closed");
+               command_print(CMD, "previously loaded image found and closed");
        }
 
        etm_ctx->image = malloc(sizeof(struct image));
@@ -1701,7 +1705,7 @@ COMMAND_HANDLER(handle_etm_image_command)
 
 COMMAND_HANDLER(handle_etm_dump_command)
 {
-       struct fileio file;
+       struct fileio *file;
        struct target *target;
        struct arm *arm;
        struct etm_context *etm_ctx;
@@ -1713,24 +1717,24 @@ COMMAND_HANDLER(handle_etm_dump_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm_ctx = arm->etm;
        if (!etm_ctx) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
        if (etm_ctx->capture_driver->status == TRACE_IDLE) {
-               command_print(CMD_CTX, "trace capture wasn't enabled, no trace data captured");
+               command_print(CMD, "trace capture wasn't enabled, no trace data captured");
                return ERROR_OK;
        }
 
        if (etm_ctx->capture_driver->status(etm_ctx) & TRACE_RUNNING) {
                /* TODO: if on-the-fly capture is to be supported, this needs to be changed */
-               command_print(CMD_CTX, "trace capture not completed");
+               command_print(CMD, "trace capture not completed");
                return ERROR_FAIL;
        }
 
@@ -1741,24 +1745,24 @@ COMMAND_HANDLER(handle_etm_dump_command)
        if (fileio_open(&file, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK)
                return ERROR_FAIL;
 
-       fileio_write_u32(&file, etm_ctx->capture_status);
-       fileio_write_u32(&file, etm_ctx->control);
-       fileio_write_u32(&file, etm_ctx->trace_depth);
+       fileio_write_u32(file, etm_ctx->capture_status);
+       fileio_write_u32(file, etm_ctx->control);
+       fileio_write_u32(file, etm_ctx->trace_depth);
 
        for (i = 0; i < etm_ctx->trace_depth; i++) {
-               fileio_write_u32(&file, etm_ctx->trace_data[i].pipestat);
-               fileio_write_u32(&file, etm_ctx->trace_data[i].packet);
-               fileio_write_u32(&file, etm_ctx->trace_data[i].flags);
+               fileio_write_u32(file, etm_ctx->trace_data[i].pipestat);
+               fileio_write_u32(file, etm_ctx->trace_data[i].packet);
+               fileio_write_u32(file, etm_ctx->trace_data[i].flags);
        }
 
-       fileio_close(&file);
+       fileio_close(file);
 
        return ERROR_OK;
 }
 
 COMMAND_HANDLER(handle_etm_load_command)
 {
-       struct fileio file;
+       struct fileio *file;
        struct target *target;
        struct arm *arm;
        struct etm_context *etm_ctx;
@@ -1770,18 +1774,18 @@ COMMAND_HANDLER(handle_etm_load_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm_ctx = arm->etm;
        if (!etm_ctx) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
        if (etm_ctx->capture_driver->status(etm_ctx) & TRACE_RUNNING) {
-               command_print(CMD_CTX, "trace capture running, stop first");
+               command_print(CMD, "trace capture running, stop first");
                return ERROR_FAIL;
        }
 
@@ -1789,15 +1793,15 @@ COMMAND_HANDLER(handle_etm_load_command)
                return ERROR_FAIL;
 
        size_t filesize;
-       int retval = fileio_size(&file, &filesize);
+       int retval = fileio_size(file, &filesize);
        if (retval != ERROR_OK) {
-               fileio_close(&file);
+               fileio_close(file);
                return retval;
        }
 
        if (filesize % 4) {
-               command_print(CMD_CTX, "size isn't a multiple of 4, no valid trace data");
-               fileio_close(&file);
+               command_print(CMD, "size isn't a multiple of 4, no valid trace data");
+               fileio_close(file);
                return ERROR_FAIL;
        }
 
@@ -1808,28 +1812,28 @@ COMMAND_HANDLER(handle_etm_load_command)
 
        {
                uint32_t tmp;
-               fileio_read_u32(&file, &tmp); etm_ctx->capture_status = tmp;
-               fileio_read_u32(&file, &tmp); etm_ctx->control = tmp;
-               fileio_read_u32(&file, &etm_ctx->trace_depth);
+               fileio_read_u32(file, &tmp); etm_ctx->capture_status = tmp;
+               fileio_read_u32(file, &tmp); etm_ctx->control = tmp;
+               fileio_read_u32(file, &etm_ctx->trace_depth);
        }
        etm_ctx->trace_data = malloc(sizeof(struct etmv1_trace_data) * etm_ctx->trace_depth);
        if (etm_ctx->trace_data == NULL) {
-               command_print(CMD_CTX, "not enough memory to perform operation");
-               fileio_close(&file);
+               command_print(CMD, "not enough memory to perform operation");
+               fileio_close(file);
                return ERROR_FAIL;
        }
 
        for (i = 0; i < etm_ctx->trace_depth; i++) {
                uint32_t pipestat, packet, flags;
-               fileio_read_u32(&file, &pipestat);
-               fileio_read_u32(&file, &packet);
-               fileio_read_u32(&file, &flags);
+               fileio_read_u32(file, &pipestat);
+               fileio_read_u32(file, &packet);
+               fileio_read_u32(file, &flags);
                etm_ctx->trace_data[i].pipestat = pipestat & 0xff;
                etm_ctx->trace_data[i].packet = packet & 0xffff;
                etm_ctx->trace_data[i].flags = flags;
        }
 
-       fileio_close(&file);
+       fileio_close(file);
 
        return ERROR_OK;
 }
@@ -1844,13 +1848,13 @@ COMMAND_HANDLER(handle_etm_start_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm_ctx = arm->etm;
        if (!etm_ctx) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
@@ -1889,13 +1893,13 @@ COMMAND_HANDLER(handle_etm_stop_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm_ctx = arm->etm;
        if (!etm_ctx) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
@@ -1925,14 +1929,14 @@ COMMAND_HANDLER(handle_etm_trigger_debug_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: %s isn't an ARM",
+               command_print(CMD, "ETM: %s isn't an ARM",
                        target_name(target));
                return ERROR_FAIL;
        }
 
        etm = arm->etm;
        if (!etm) {
-               command_print(CMD_CTX, "ETM: no ETM configured for %s",
+               command_print(CMD, "ETM: no ETM configured for %s",
                        target_name(target));
                return ERROR_FAIL;
        }
@@ -1957,7 +1961,7 @@ COMMAND_HANDLER(handle_etm_trigger_debug_command)
                buf_set_u32(etm_ctrl_reg->value, 0, 32, etm->control);
        }
 
-       command_print(CMD_CTX, "ETM: %s debug halt",
+       command_print(CMD, "ETM: %s debug halt",
                (etm->control & ETM_CTRL_DBGRQ)
                ? "triggers"
                : "does not trigger");
@@ -1974,33 +1978,33 @@ COMMAND_HANDLER(handle_etm_analyze_command)
        target = get_current_target(CMD_CTX);
        arm = target_to_arm(target);
        if (!is_arm(arm)) {
-               command_print(CMD_CTX, "ETM: current target isn't an ARM");
+               command_print(CMD, "ETM: current target isn't an ARM");
                return ERROR_FAIL;
        }
 
        etm_ctx = arm->etm;
        if (!etm_ctx) {
-               command_print(CMD_CTX, "current target doesn't have an ETM configured");
+               command_print(CMD, "current target doesn't have an ETM configured");
                return ERROR_FAIL;
        }
 
-       retval = etmv1_analyze_trace(etm_ctx, CMD_CTX);
+       retval = etmv1_analyze_trace(etm_ctx, CMD);
        if (retval != ERROR_OK) {
                /* FIX! error should be reported inside etmv1_analyze_trace() */
                switch (retval) {
                        case ERROR_ETM_ANALYSIS_FAILED:
-                               command_print(CMD_CTX,
+                               command_print(CMD,
                                        "further analysis failed (corrupted trace data or just end of data");
                                break;
                        case ERROR_TRACE_INSTRUCTION_UNAVAILABLE:
-                               command_print(CMD_CTX,
+                               command_print(CMD,
                                        "no instruction for current address available, analysis aborted");
                                break;
                        case ERROR_TRACE_IMAGE_UNAVAILABLE:
-                               command_print(CMD_CTX, "no image available for trace analysis");
+                               command_print(CMD, "no image available for trace analysis");
                                break;
                        default:
-                               command_print(CMD_CTX, "unknown error");
+                               command_print(CMD, "unknown error");
                }
        }
 

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)