This is an automated email from Gerrit.

"Ian Thompson <ia...@cadence.com>" just uploaded a new patch set to Gerrit, 
which you can find at https://review.openocd.org/c/openocd/+/8076

-- gerrit

commit f70ff37c27d397dbbd3aecee4942372f5337fee7
Author: ianst <ia...@cadence.com>
Date:   Tue Jan 2 16:49:36 2024 -0800

    target/xtensa: update COMMAND_HELPER output to use command_print() API
    
    Change LOG_ERROR() and LOG_INFO() output, but
    keep DEBUG and WARNING levels for verbosity
    
    Signed-off-by: ianst <ia...@cadence.com>
    Change-Id: I4ef0753b3a56be02716f2db43a7d4370a1917237

diff --git a/src/target/xtensa/xtensa.c b/src/target/xtensa/xtensa.c
index 97f95dca47..40159d8c7d 100644
--- a/src/target/xtensa/xtensa.c
+++ b/src/target/xtensa/xtensa.c
@@ -3236,7 +3236,7 @@ static COMMAND_HELPER(xtensa_cmd_exe_do, struct target 
*target)
        const char *parm = CMD_ARGV[0];
        unsigned int parm_len = strlen(parm);
        if ((parm_len >= 64) || (parm_len & 1)) {
-               LOG_ERROR("Invalid parameter length (%d): must be even, < 64 
characters", parm_len);
+               command_print(CMD, "Invalid parameter length (%d): must be 
even, < 64 characters", parm_len);
                return ERROR_FAIL;
        }
 
@@ -3257,7 +3257,7 @@ static COMMAND_HELPER(xtensa_cmd_exe_do, struct target 
*target)
         */
        int status = xtensa_write_dirty_registers(target);
        if (status != ERROR_OK) {
-               LOG_ERROR("%s: Failed to write back register cache.", 
target_name(target));
+               command_print(CMD, "%s: Failed to write back register cache.", 
target_name(target));
                return ERROR_FAIL;
        }
        xtensa_reg_val_t exccause = xtensa_reg_get(target, XT_REG_IDX_EXCCAUSE);
@@ -3275,18 +3275,18 @@ static COMMAND_HELPER(xtensa_cmd_exe_do, struct target 
*target)
        xtensa_queue_exec_ins_wide(xtensa, ops, oplen); /* Handles endian-swap 
*/
        status = xtensa_dm_queue_execute(&xtensa->dbg_mod);
        if (status != ERROR_OK) {
-               LOG_TARGET_ERROR(target, "exec: queue error %d", status);
+               command_print(CMD, "exec: queue error %d", status);
        } else {
                status = xtensa_core_status_check(target);
                if (status != ERROR_OK)
-                       LOG_TARGET_ERROR(target, "exec: status error %d", 
status);
+                       command_print(CMD, "exec: status error %d", status);
        }
 
        /* Reread register cache and restore saved regs after instruction 
execution */
        if (xtensa_fetch_all_regs(target) != ERROR_OK)
-               LOG_TARGET_ERROR(target, "post-exec: register fetch error");
+               command_print(CMD, "post-exec: register fetch error");
        if (status != ERROR_OK) {
-               LOG_TARGET_ERROR(target, "post-exec: EXCCAUSE 0x%02" PRIx32,
+               command_print(CMD, "post-exec: EXCCAUSE 0x%02" PRIx32,
                        xtensa_reg_get(target, XT_REG_IDX_EXCCAUSE));
        }
        xtensa_reg_set(target, XT_REG_IDX_EXCCAUSE, exccause);
@@ -3311,7 +3311,7 @@ COMMAND_HELPER(xtensa_cmd_xtdef_do, struct xtensa *xtensa)
        } else if (strcasecmp(core_name, "NX") == 0) {
                xtensa->core_config->core_type = XT_NX;
        } else {
-               LOG_ERROR("xtdef [LX|NX]\n");
+               command_print(CMD, "xtdef [LX|NX]\n");
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
        return ERROR_OK;
@@ -3369,7 +3369,7 @@ COMMAND_HELPER(xtensa_cmd_xtopt_do, struct xtensa *xtensa)
                if (!xtensa_cmd_xtopt_legal_val("excmlevel", opt_val, 1, 6))
                        return ERROR_COMMAND_ARGUMENT_INVALID;
                if (!xtensa->core_config->high_irq.enabled) {
-                       LOG_ERROR("xtopt excmlevel requires hipriints\n");
+                       command_print(CMD, "xtopt excmlevel requires 
hipriints\n");
                        return ERROR_COMMAND_ARGUMENT_INVALID;
                }
                xtensa->core_config->high_irq.excm_level = opt_val;
@@ -3382,7 +3382,7 @@ COMMAND_HELPER(xtensa_cmd_xtopt_do, struct xtensa *xtensa)
                                return ERROR_COMMAND_ARGUMENT_INVALID;
                }
                if (!xtensa->core_config->high_irq.enabled) {
-                       LOG_ERROR("xtopt intlevels requires hipriints\n");
+                       command_print(CMD, "xtopt intlevels requires 
hipriints\n");
                        return ERROR_COMMAND_ARGUMENT_INVALID;
                }
                xtensa->core_config->high_irq.level_num = opt_val;
@@ -3440,7 +3440,7 @@ COMMAND_HELPER(xtensa_cmd_xtmem_do, struct xtensa *xtensa)
        bool is_dcache = false;
 
        if (CMD_ARGC == 0) {
-               LOG_ERROR("xtmem <type> [parameters]\n");
+               command_print(CMD, "xtmem <type> [parameters]\n");
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
@@ -3473,13 +3473,13 @@ COMMAND_HELPER(xtensa_cmd_xtmem_do, struct xtensa 
*xtensa)
                memp = &xtensa->core_config->srom;
                mem_access = XT_MEM_ACCESS_READ;
        } else {
-               LOG_ERROR("xtmem types: 
<icache|dcache|l2cache|l2addr|iram|irom|dram|drom|sram|srom>\n");
+               command_print(CMD, "xtmem types: 
<icache|dcache|l2cache|l2addr|iram|irom|dram|drom|sram|srom>\n");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
 
        if (cachep) {
                if ((CMD_ARGC != 4) && (CMD_ARGC != 5)) {
-                       LOG_ERROR("xtmem <cachetype> <linebytes> <cachebytes> 
<ways> [writeback]\n");
+                       command_print(CMD, "xtmem <cachetype> <linebytes> 
<cachebytes> <ways> [writeback]\n");
                        return ERROR_COMMAND_SYNTAX_ERROR;
                }
                cachep->line_size = strtoul(CMD_ARGV[1], NULL, 0);
@@ -3489,7 +3489,7 @@ COMMAND_HELPER(xtensa_cmd_xtmem_do, struct xtensa *xtensa)
                        strtoul(CMD_ARGV[4], NULL, 0) : 0;
        } else if (memp) {
                if (CMD_ARGC != 3) {
-                       LOG_ERROR("xtmem <memtype> <baseaddr> <bytes>\n");
+                       command_print(CMD, "xtmem <memtype> <baseaddr> 
<bytes>\n");
                        return ERROR_COMMAND_SYNTAX_ERROR;
                }
                struct xtensa_local_mem_region_config *memcfgp = 
&memp->regions[memp->count];
@@ -3512,7 +3512,7 @@ COMMAND_HANDLER(xtensa_cmd_xtmem)
 COMMAND_HELPER(xtensa_cmd_xtmpu_do, struct xtensa *xtensa)
 {
        if (CMD_ARGC != 4) {
-               LOG_ERROR("xtmpu <num FG seg> <min seg size> <lockable> 
<executeonly>\n");
+               command_print(CMD, "xtmpu <num FG seg> <min seg size> 
<lockable> <executeonly>\n");
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
@@ -3522,16 +3522,16 @@ COMMAND_HELPER(xtensa_cmd_xtmpu_do, struct xtensa 
*xtensa)
        unsigned int execonly = strtoul(CMD_ARGV[3], NULL, 0);
 
        if ((nfgseg > 32)) {
-               LOG_ERROR("<nfgseg> must be within [0..32]\n");
+               command_print(CMD, "<nfgseg> must be within [0..32]\n");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        } else if (minsegsize & (minsegsize - 1)) {
-               LOG_ERROR("<minsegsize> must be a power of 2 >= 32\n");
+               command_print(CMD, "<minsegsize> must be a power of 2 >= 32\n");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        } else if (lockable > 1) {
-               LOG_ERROR("<lockable> must be 0 or 1\n");
+               command_print(CMD, "<lockable> must be 0 or 1\n");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        } else if (execonly > 1) {
-               LOG_ERROR("<execonly> must be 0 or 1\n");
+               command_print(CMD, "<execonly> must be 0 or 1\n");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
 
@@ -3553,17 +3553,17 @@ COMMAND_HANDLER(xtensa_cmd_xtmpu)
 COMMAND_HELPER(xtensa_cmd_xtmmu_do, struct xtensa *xtensa)
 {
        if (CMD_ARGC != 2) {
-               LOG_ERROR("xtmmu <NIREFILLENTRIES> <NDREFILLENTRIES>\n");
+               command_print(CMD, "xtmmu <NIREFILLENTRIES> 
<NDREFILLENTRIES>\n");
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        unsigned int nirefillentries = strtoul(CMD_ARGV[0], NULL, 0);
        unsigned int ndrefillentries = strtoul(CMD_ARGV[1], NULL, 0);
        if ((nirefillentries != 16) && (nirefillentries != 32)) {
-               LOG_ERROR("<nirefillentries> must be 16 or 32\n");
+               command_print(CMD, "<nirefillentries> must be 16 or 32\n");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        } else if ((ndrefillentries != 16) && (ndrefillentries != 32)) {
-               LOG_ERROR("<ndrefillentries> must be 16 or 32\n");
+               command_print(CMD, "<ndrefillentries> must be 16 or 32\n");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
 
@@ -3586,11 +3586,11 @@ COMMAND_HELPER(xtensa_cmd_xtreg_do, struct xtensa 
*xtensa)
        if (CMD_ARGC == 1) {
                int32_t numregs = strtoul(CMD_ARGV[0], NULL, 0);
                if ((numregs <= 0) || (numregs > UINT16_MAX)) {
-                       LOG_ERROR("xtreg <numregs>: Invalid 'numregs' (%d)", 
numregs);
+                       command_print(CMD, "xtreg <numregs>: Invalid 'numregs' 
(%d)", numregs);
                        return ERROR_COMMAND_SYNTAX_ERROR;
                }
                if ((xtensa->genpkt_regs_num > 0) && (numregs < 
(int32_t)xtensa->genpkt_regs_num)) {
-                       LOG_ERROR("xtregs (%d) must be larger than numgenregs 
(%d) (if xtregfmt specified)",
+                       command_print(CMD, "xtregs (%d) must be larger than 
numgenregs (%d) (if xtregfmt specified)",
                                numregs, xtensa->genpkt_regs_num);
                        return ERROR_COMMAND_SYNTAX_ERROR;
                }
@@ -3600,7 +3600,7 @@ COMMAND_HELPER(xtensa_cmd_xtreg_do, struct xtensa *xtensa)
                /* A little more memory than required, but saves a second 
initialization pass */
                xtensa->optregs = calloc(xtensa->total_regs_num, sizeof(struct 
xtensa_reg_desc));
                if (!xtensa->optregs) {
-                       LOG_ERROR("Failed to allocate xtensa->optregs!");
+                       command_print(CMD, "Failed to allocate 
xtensa->optregs!");
                        return ERROR_FAIL;
                }
                return ERROR_OK;
@@ -3613,7 +3613,7 @@ COMMAND_HELPER(xtensa_cmd_xtreg_do, struct xtensa *xtensa)
        if (xtensa->regmap_contiguous && !xtensa->contiguous_regs_desc) {
                xtensa->contiguous_regs_desc = calloc(xtensa->total_regs_num, 
sizeof(struct xtensa_reg_desc *));
                if (!xtensa->contiguous_regs_desc) {
-                       LOG_ERROR("Failed to allocate 
xtensa->contiguous_regs_desc!");
+                       command_print(CMD, "Failed to allocate 
xtensa->contiguous_regs_desc!");
                        return ERROR_FAIL;
                }
        }
@@ -3621,17 +3621,17 @@ COMMAND_HELPER(xtensa_cmd_xtreg_do, struct xtensa 
*xtensa)
        const char *regname = CMD_ARGV[0];
        unsigned int regnum = strtoul(CMD_ARGV[1], NULL, 0);
        if (regnum > UINT16_MAX) {
-               LOG_ERROR("<regnum> must be a 16-bit number");
+               command_print(CMD, "<regnum> must be a 16-bit number");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
 
        if ((xtensa->num_optregs + xtensa->core_regs_num) >= 
xtensa->total_regs_num) {
                if (xtensa->total_regs_num)
-                       LOG_ERROR("'xtreg %s 0x%04x': Too many registers (%d 
expected, %d core %d extended)",
+                       command_print(CMD, "'xtreg %s 0x%04x': Too many 
registers (%d expected, %d core %d extended)",
                                regname, regnum,
                                xtensa->total_regs_num, xtensa->core_regs_num, 
xtensa->num_optregs);
                else
-                       LOG_ERROR("'xtreg %s 0x%04x': Number of registers 
unspecified",
+                       command_print(CMD, "'xtreg %s 0x%04x': Number of 
registers unspecified",
                                regname, regnum);
                return ERROR_FAIL;
        }
@@ -3711,7 +3711,7 @@ COMMAND_HELPER(xtensa_cmd_xtreg_do, struct xtensa *xtensa)
                                idx = XT_NX_REG_IDX_MESRCLR;
                        if (idx < XT_NX_REG_IDX_NUM) {
                                if (xtensa->nx_reg_idx[idx] != 0) {
-                                       LOG_ERROR("nx_reg_idx[%d] previously 
set to %d",
+                                       command_print(CMD, "nx_reg_idx[%d] 
previously set to %d",
                                                idx, xtensa->nx_reg_idx[idx]);
                                        return ERROR_FAIL;
                                }
@@ -3758,7 +3758,7 @@ COMMAND_HELPER(xtensa_cmd_xtregfmt_do, struct xtensa 
*xtensa)
                                if ((numgregs <= 0) ||
                                        ((numgregs > xtensa->total_regs_num) &&
                                        (xtensa->total_regs_num > 0))) {
-                                       LOG_ERROR("xtregfmt: if specified, 
numgregs (%d) must be <= numregs (%d)",
+                                       command_print(CMD, "xtregfmt: if 
specified, numgregs (%d) must be <= numregs (%d)",
                                                numgregs, 
xtensa->total_regs_num);
                                        return ERROR_COMMAND_SYNTAX_ERROR;
                                }
@@ -3876,7 +3876,7 @@ COMMAND_HELPER(xtensa_cmd_perfmon_dump_do, struct xtensa 
*xtensa)
                        "%-12" PRIu64 "%s",
                        result.value,
                        result.overflow ? " (overflow)" : "");
-               LOG_INFO("%s", result_buf);
+               command_print(CMD, "%s", result_buf);
        }
 
        return ERROR_OK;
@@ -4126,21 +4126,21 @@ COMMAND_HELPER(xtensa_cmd_tracedump_do, struct xtensa 
*xtensa, const char *fname
        }
 
        memsz = trace_config.memaddr_end - trace_config.memaddr_start + 1;
-       LOG_INFO("Total trace memory: %d words", memsz);
+       command_print(CMD, "Total trace memory: %d words", memsz);
        if ((trace_config.addr &
                        ((TRAXADDR_TWRAP_MASK << TRAXADDR_TWRAP_SHIFT) | 
TRAXADDR_TWSAT)) == 0) {
                /*Memory hasn't overwritten itself yet. */
                wmem = trace_config.addr & TRAXADDR_TADDR_MASK;
-               LOG_INFO("...but trace is only %d words", wmem);
+               command_print(CMD, "...but trace is only %d words", wmem);
                if (wmem < memsz)
                        memsz = wmem;
        } else {
                if (trace_config.addr & TRAXADDR_TWSAT) {
-                       LOG_INFO("Real trace is many times longer than that 
(overflow)");
+                       command_print(CMD, "Real trace is many times longer 
than that (overflow)");
                } else {
                        uint32_t trc_sz = (trace_config.addr >> 
TRAXADDR_TWRAP_SHIFT) & TRAXADDR_TWRAP_MASK;
                        trc_sz = (trc_sz * memsz) + (trace_config.addr & 
TRAXADDR_TADDR_MASK);
-                       LOG_INFO("Real trace is %d words, but the start has 
been truncated.", trc_sz);
+                       command_print(CMD, "Real trace is %d words, but the 
start has been truncated.", trc_sz);
                }
        }
 

-- 

Reply via email to