diff options
author | Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> | 2023-12-01 15:53:58 +0300 |
---|---|---|
committer | Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> | 2023-12-01 16:45:30 +0300 |
commit | f5b8862a763948130aa79fd8d80a205ec4a0bf45 (patch) | |
tree | e10b0813eaa46356875bf1e03f901f10a0da8016 | |
parent | d4c5d2657074613d429f57f60e939ca151ed4f32 (diff) | |
download | riscv-openocd-f5b8862a763948130aa79fd8d80a205ec4a0bf45.zip riscv-openocd-f5b8862a763948130aa79fd8d80a205ec4a0bf45.tar.gz riscv-openocd-f5b8862a763948130aa79fd8d80a205ec4a0bf45.tar.bz2 |
target/riscv: report helpfull location during register decode
`LOG_TARGET_DEBUG()` reports file, line and function name at the call
site. This information is not helpfull if it always points to the same
location inside `log_debug_reg()`.
Change-Id: Ib73be0344fb5c80c9ac8e5fdee1084d405522eb7
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
-rw-r--r-- | src/target/riscv/riscv-013.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 8a83795..58ebad7 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -297,16 +297,18 @@ static riscv_debug_reg_ctx_t get_riscv_debug_reg_ctx(struct target *target) } static void log_debug_reg(struct target *target, enum riscv_debug_reg_ordinal reg, - riscv_reg_t value) + riscv_reg_t value, const char *file, unsigned int line, const char *func) { if (debug_level < LOG_LVL_DEBUG) return; const riscv_debug_reg_ctx_t context = get_riscv_debug_reg_ctx(target); char buf[riscv_debug_reg_to_s(NULL, reg, context, value) + 1]; riscv_debug_reg_to_s(buf, reg, context, value); - LOG_TARGET_DEBUG(target, "%s", buf); + log_printf_lf(LOG_LVL_DEBUG, file, line, func, "[%s] %s", target_name(target), buf); } +#define LOG_DEBUG_REG(t, r, v) log_debug_reg(t, r##_ORDINAL, v, __FILE__, __LINE__, __func__) + static uint32_t set_dmcontrol_hartsel(uint32_t initial, int hart_index) { assert(hart_index != HART_INDEX_UNKNOWN); @@ -864,7 +866,7 @@ static int execute_abstract_command(struct target *target, uint32_t command) if (debug_level >= LOG_LVL_DEBUG) { switch (get_field(command, DM_COMMAND_CMDTYPE)) { case 0: - log_debug_reg(target, AC_ACCESS_REGISTER_ORDINAL, command); + LOG_DEBUG_REG(target, AC_ACCESS_REGISTER, command); break; default: LOG_TARGET_DEBUG(target, "command=0x%x", command); @@ -1860,7 +1862,7 @@ static int examine(struct target *target) } LOG_TARGET_DEBUG(target, "dtmcontrol=0x%x", dtmcontrol); - log_debug_reg(target, DTM_DTMCS_ORDINAL, dtmcontrol); + LOG_DEBUG_REG(target, DTM_DTMCS, dtmcontrol); if (get_field(dtmcontrol, DTM_DTMCS_VERSION) != 1) { LOG_TARGET_ERROR(target, "Unsupported DTM version %" PRIu32 ". (dtmcontrol=0x%" PRIx32 ")", |