retire ERROR_INVALID_ARGUMENTS and replace with ERROR_COMMAND_SYNTAX_ERROR
[openocd.git] / src / target / etm.c
index 9da69550421df9b117ddb76c790dbdf2bee5dbda..cd50e44d511d09bdebdf03a1849086e9f16f1309 100644 (file)
@@ -314,7 +314,6 @@ struct reg_cache *etm_build_reg_cache(struct target *target,
 
        /* figure ETM version then add base registers */
        if (config & (1 << 31)) {
-               bcd_vers = 0x20;
                LOG_WARNING("ETMv2+ support is incomplete");
 
                /* REVISIT more registers may exist; they may now be
@@ -500,7 +499,7 @@ static int etm_read_reg_w_check(struct reg *reg,
 
        if (etm_reg->reg_info->mode == WO) {
                LOG_ERROR("BUG: can't read write-only register %s", r->name);
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        LOG_DEBUG("%s (%u)", r->name, reg_addr);
@@ -586,7 +585,7 @@ static int etm_write_reg(struct reg *reg, uint32_t value)
 
        if (etm_reg->reg_info->mode == RO) {
                LOG_ERROR("BUG: can't write read--only register %s", r->name);
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        LOG_DEBUG("%s (%u): 0x%8.8" PRIx32 "", r->name, reg_addr, value);
@@ -669,7 +668,7 @@ static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction
                        ctx->current_pc - ctx->image->sections[section].base_address,
                        4, buf, &size_read)) != ERROR_OK)
                {
-                       LOG_ERROR("error while reading instruction: %i", retval);
+                       LOG_ERROR("error while reading instruction");
                        return ERROR_TRACE_INSTRUCTION_UNAVAILABLE;
                }
                opcode = target_buffer_get_u32(ctx->target, buf);
@@ -682,7 +681,7 @@ static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction
                        ctx->current_pc - ctx->image->sections[section].base_address,
                        2, buf, &size_read)) != ERROR_OK)
                {
-                       LOG_ERROR("error while reading instruction: %i", retval);
+                       LOG_ERROR("error while reading instruction");
                        return ERROR_TRACE_INSTRUCTION_UNAVAILABLE;
                }
                opcode = target_buffer_get_u16(ctx->target, buf);
@@ -1197,7 +1196,7 @@ static COMMAND_HELPER(handle_etm_tracemode_command_update,
        else
        {
                command_print(CMD_CTX, "invalid option '%s'", CMD_ARGV[0]);
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        uint8_t context_id;
@@ -1218,7 +1217,7 @@ static COMMAND_HELPER(handle_etm_tracemode_command_update,
                break;
        default:
                command_print(CMD_CTX, "invalid option '%s'", CMD_ARGV[1]);
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        bool etmv1_cycle_accurate;
@@ -1897,7 +1896,15 @@ COMMAND_HANDLER(handle_etm_load_command)
                return ERROR_FAIL;
        }
 
-       if (file.size % 4)
+       int filesize;
+       int retval = fileio_size(&file, &filesize);
+       if (retval != ERROR_OK)
+       {
+               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);
@@ -2101,6 +2108,7 @@ COMMAND_HANDLER(handle_etm_analyze_command)
 
        if ((retval = etmv1_analyze_trace(etm_ctx, CMD_CTX)) != ERROR_OK)
        {
+               /* FIX! error should be reported inside etmv1_analyze_trace() */
                switch (retval)
                {
                        case ERROR_ETM_ANALYSIS_FAILED:
@@ -2113,7 +2121,7 @@ COMMAND_HANDLER(handle_etm_analyze_command)
                                command_print(CMD_CTX, "no image available for trace analysis");
                                break;
                        default:
-                               command_print(CMD_CTX, "unknown error: %i", retval);
+                               command_print(CMD_CTX, "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)