target: riscv: don't test 'debug_level' directly

Use the macro 'LOG_LEVEL_IS()' to test 'debug_level'.

Change-Id: Ic931fd2eff0fa97a7a315b4b276f85dfc5fc8d5f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9071
Reviewed-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
This commit is contained in:
Antonio Borneo
2025-08-04 17:40:39 +02:00
committed by Tomas Vanek
parent bd303d6a3d
commit 768b4084eb
3 changed files with 7 additions and 7 deletions

View File

@@ -204,7 +204,7 @@ static void log_batch(const struct riscv_batch *batch, size_t start_idx,
const struct riscv_scan_delays *delays, bool resets_delays,
size_t reset_delays_after)
{
if (debug_level < LOG_LVL_DEBUG)
if (!LOG_LEVEL_IS(LOG_LVL_DEBUG))
return;
const unsigned int abits = riscv_get_dmi_address_bits(batch->target);

View File

@@ -391,7 +391,7 @@ static void dump_field(const struct scan_field *field)
static const char * const op_string[] = {"nop", "r", "w", "?"};
static const char * const status_string[] = {"+", "?", "F", "b"};
if (debug_level < LOG_LVL_DEBUG)
if (!LOG_LEVEL_IS(LOG_LVL_DEBUG))
return;
uint64_t out = buf_get_u64(field->out_value, 0, field->num_bits);
@@ -1934,7 +1934,7 @@ static int poll_target(struct target *target, bool announce)
/* Inhibit debug logging during poll(), which isn't usually interesting and
* just fills up the screen/logs with clutter. */
int old_debug_level = debug_level;
if (debug_level >= LOG_LVL_DEBUG)
if (LOG_LEVEL_IS(LOG_LVL_DEBUG))
debug_level = LOG_LVL_INFO;
bits_t bits = {
.haltnot = 0,

View File

@@ -368,7 +368,7 @@ static struct riscv_debug_reg_ctx get_riscv_debug_reg_ctx(const struct target *t
static void log_debug_reg(struct target *target, enum riscv_debug_reg_ordinal reg,
riscv_reg_t value, const char *file, unsigned int line, const char *func)
{
if (debug_level < LOG_LVL_DEBUG)
if (!LOG_LEVEL_IS(LOG_LVL_DEBUG))
return;
const struct riscv_debug_reg_ctx context = get_riscv_debug_reg_ctx(target);
char * const buf = malloc(riscv_debug_reg_to_s(NULL, reg, context, value, RISCV_DEBUG_REG_HIDE_UNNAMED_0) + 1);
@@ -735,7 +735,7 @@ int riscv013_execute_abstract_command(struct target *target, uint32_t command,
{
assert(cmderr);
*cmderr = CMDERR_NONE;
if (debug_level >= LOG_LVL_DEBUG) {
if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) {
switch (get_field(command, DM_COMMAND_CMDTYPE)) {
case 0:
LOG_DEBUG_REG(target, AC_ACCESS_REGISTER, command);
@@ -3094,7 +3094,7 @@ static int execute_autofence(struct target *target)
static void log_memory_access128(target_addr_t address, uint64_t value_h,
uint64_t value_l, bool is_read)
{
if (debug_level < LOG_LVL_DEBUG)
if (!LOG_LEVEL_IS(LOG_LVL_DEBUG))
return;
char fmt[80];
@@ -3106,7 +3106,7 @@ static void log_memory_access128(target_addr_t address, uint64_t value_h,
static void log_memory_access64(target_addr_t address, uint64_t value,
unsigned int size_bytes, bool is_read)
{
if (debug_level < LOG_LVL_DEBUG)
if (!LOG_LEVEL_IS(LOG_LVL_DEBUG))
return;
char fmt[80];