stlink: add missing memory check handlers
[fw/openocd] / src / target / etm.c
index 4e15878332cf93528753b1a31e6eb36bab813b15..de8bb8a416579eea2609de62a2e83f41677428ca 100644 (file)
@@ -499,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);
@@ -585,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);
@@ -1196,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;
@@ -1217,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;
@@ -1268,13 +1268,7 @@ COMMAND_HANDLER(handle_etm_tracemode_command)
                                &tracemode);
                break;
        default:
-               command_print(CMD_CTX, "usage: tracemode "
-                               "('none'|'data'|'address'|'all') "
-                               "context_id_bits "
-                               "('enable'|'disable') "
-                               "('enable'|'disable')"
-                               );
-               return ERROR_FAIL;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        /**
@@ -1738,8 +1732,7 @@ COMMAND_HANDLER(handle_etm_image_command)
 
        if (CMD_ARGC < 1)
        {
-               command_print(CMD_CTX, "usage: etm image <file> [base address] [type]");
-               return ERROR_FAIL;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        target = get_current_target(CMD_CTX);
@@ -1799,8 +1792,7 @@ COMMAND_HANDLER(handle_etm_dump_command)
 
        if (CMD_ARGC != 1)
        {
-               command_print(CMD_CTX, "usage: etm dump <file>");
-               return ERROR_FAIL;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        target = get_current_target(CMD_CTX);
@@ -1866,8 +1858,7 @@ COMMAND_HANDLER(handle_etm_load_command)
 
        if (CMD_ARGC != 1)
        {
-               command_print(CMD_CTX, "usage: etm load <file>");
-               return ERROR_FAIL;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        target = get_current_target(CMD_CTX);
@@ -2148,6 +2139,7 @@ const struct command_registration etm_command_handlers[] = {
                .name = "etm",
                .mode = COMMAND_ANY,
                .help = "Emebdded Trace Macrocell command group",
+               .usage = "",
                .chain = etm_config_command_handlers,
        },
        COMMAND_REGISTRATION_DONE
@@ -2168,24 +2160,28 @@ static const struct command_registration etm_exec_command_handlers[] = {
                .name = "info",
                .handler = handle_etm_info_command,
                .mode = COMMAND_EXEC,
+               .usage = "",
                .help = "display info about the current target's ETM",
        },
        {
                .name = "status",
                .handler = handle_etm_status_command,
                .mode = COMMAND_EXEC,
+               .usage = "",
                .help = "display current target's ETM status",
        },
        {
                .name = "start",
                .handler = handle_etm_start_command,
                .mode = COMMAND_EXEC,
+               .usage = "",
                .help = "start ETM trace collection",
        },
        {
                .name = "stop",
                .handler = handle_etm_stop_command,
                .mode = COMMAND_EXEC,
+               .usage = "",
                .help = "stop ETM trace collection",
        },
        {
@@ -2199,6 +2195,7 @@ static const struct command_registration etm_exec_command_handlers[] = {
                .name = "analyze",
                .handler = handle_etm_analyze_command,
                .mode = COMMAND_EXEC,
+               .usage = "",
                .help = "analyze collected ETM trace",
        },
        {
@@ -2206,7 +2203,7 @@ static const struct command_registration etm_exec_command_handlers[] = {
                .handler = handle_etm_image_command,
                .mode = COMMAND_EXEC,
                .help = "load image from file with optional offset",
-               .usage = "filename [offset]",
+               .usage = "<file> [base address] [type]",
        },
        {
                .name = "dump",
@@ -2219,6 +2216,7 @@ static const struct command_registration etm_exec_command_handlers[] = {
                .name = "load",
                .handler = handle_etm_load_command,
                .mode = COMMAND_EXEC,
+               .usage = "",
                .help = "load trace data for analysis <file>",
        },
        COMMAND_REGISTRATION_DONE