Don't print verbose messages when polling

I'm not 100% sure what the right thing to do here is, but I've found
that when I'm not debugging a polling issue there's way too much
verbosity in the debug level as it currently stands.
This commit is contained in:
Palmer Dabbelt 2018-05-29 19:51:00 -07:00
parent ab7ab8a867
commit 052b4e3142
1 changed files with 23 additions and 2 deletions

View File

@ -1001,8 +1001,15 @@ static enum riscv_poll_hart riscv_poll_hart(struct target *target, int hartid)
/*** OpenOCD Interface ***/ /*** OpenOCD Interface ***/
int riscv_openocd_poll(struct target *target) int riscv_openocd_poll(struct target *target)
{ {
#ifdef RISCV_DEBUG_POLL
LOG_DEBUG("polling all harts"); LOG_DEBUG("polling all harts");
#endif
int halted_hart = -1; int halted_hart = -1;
int old_debug_level = debug_level;
#ifdef RISCV_DEBUG_POLL
#else
debug_level = LOG_LVL_INFO;
#endif
if (riscv_rtos_enabled(target)) { if (riscv_rtos_enabled(target)) {
/* Check every hart for an event. */ /* Check every hart for an event. */
for (int i = 0; i < riscv_count_harts(target); ++i) { for (int i = 0; i < riscv_count_harts(target); ++i) {
@ -1015,14 +1022,20 @@ int riscv_openocd_poll(struct target *target)
halted_hart = i; halted_hart = i;
break; break;
case RPH_ERROR: case RPH_ERROR:
debug_level = old_debug_level;
return ERROR_FAIL; return ERROR_FAIL;
} }
} }
if (halted_hart == -1) { if (halted_hart == -1) {
#ifdef RISCV_DEBUG_POLL
LOG_DEBUG(" no harts just halted, target->state=%d", target->state); LOG_DEBUG(" no harts just halted, target->state=%d", target->state);
#endif
debug_level = old_debug_level;
return ERROR_OK; return ERROR_OK;
} }
#ifdef RISCV_DEBUG_POLL
LOG_DEBUG(" hart %d halted", halted_hart); LOG_DEBUG(" hart %d halted", halted_hart);
#endif
/* If we're here then at least one hart triggered. That means /* If we're here then at least one hart triggered. That means
* we want to go and halt _every_ hart in the system, as that's * we want to go and halt _every_ hart in the system, as that's
@ -1035,13 +1048,19 @@ int riscv_openocd_poll(struct target *target)
} else { } else {
enum riscv_poll_hart out = riscv_poll_hart(target, enum riscv_poll_hart out = riscv_poll_hart(target,
riscv_current_hartid(target)); riscv_current_hartid(target));
if (out == RPH_NO_CHANGE || out == RPH_DISCOVERED_RUNNING) if (out == RPH_NO_CHANGE || out == RPH_DISCOVERED_RUNNING) {
debug_level = old_debug_level;
return ERROR_OK; return ERROR_OK;
else if (out == RPH_ERROR) }
else if (out == RPH_ERROR) {
debug_level = old_debug_level;
return ERROR_FAIL; return ERROR_FAIL;
}
halted_hart = riscv_current_hartid(target); halted_hart = riscv_current_hartid(target);
#ifdef RISCV_DEBUG_POLL
LOG_DEBUG(" hart %d halted", halted_hart); LOG_DEBUG(" hart %d halted", halted_hart);
#endif
} }
target->state = TARGET_HALTED; target->state = TARGET_HALTED;
@ -1062,6 +1081,7 @@ int riscv_openocd_poll(struct target *target)
target->debug_reason = DBG_REASON_UNDEFINED; target->debug_reason = DBG_REASON_UNDEFINED;
break; break;
case RISCV_HALT_ERROR: case RISCV_HALT_ERROR:
debug_level = old_debug_level;
return ERROR_FAIL; return ERROR_FAIL;
} }
@ -1072,6 +1092,7 @@ int riscv_openocd_poll(struct target *target)
target->state = TARGET_HALTED; target->state = TARGET_HALTED;
target_call_event_callbacks(target, TARGET_EVENT_HALTED); target_call_event_callbacks(target, TARGET_EVENT_HALTED);
debug_level = old_debug_level;
return ERROR_OK; return ERROR_OK;
} }