cortex_a_poll: minor code factorization to enhance readability

cortex_a_debug_entry and update_halt_gdb are called in two consecutive
conditions which are complementary, so externalizing the common code
makes the conditions' body lighter

With the removal of LOG_DEBUG(" ") since it does not look too informative

Change-Id: I0c54e413619576bb3af164f2dcf256c5a862c5fd
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/4832
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
This commit is contained in:
Tarek BOCHKATI 2019-01-03 18:16:45 +01:00 committed by Tomas Vanek
parent c915e70568
commit 63aa917015
1 changed files with 11 additions and 24 deletions

View File

@ -725,39 +725,26 @@ static int cortex_a_poll(struct target *target)
/* We have a halting debug event */ /* We have a halting debug event */
LOG_DEBUG("Target halted"); LOG_DEBUG("Target halted");
target->state = TARGET_HALTED; target->state = TARGET_HALTED;
if ((prev_target_state == TARGET_RUNNING)
|| (prev_target_state == TARGET_UNKNOWN)
|| (prev_target_state == TARGET_RESET)) {
retval = cortex_a_debug_entry(target); retval = cortex_a_debug_entry(target);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
if (target->smp) { if (target->smp) {
retval = update_halt_gdb(target); retval = update_halt_gdb(target);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
} }
if (prev_target_state == TARGET_DEBUG_RUNNING) {
target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED);
} else { /* prev_target_state is RUNNING, UNKNOWN or RESET */
if (arm_semihosting(target, &retval) != 0) if (arm_semihosting(target, &retval) != 0)
return retval; return retval;
target_call_event_callbacks(target, target_call_event_callbacks(target,
TARGET_EVENT_HALTED); TARGET_EVENT_HALTED);
} }
if (prev_target_state == TARGET_DEBUG_RUNNING) {
LOG_DEBUG(" ");
retval = cortex_a_debug_entry(target);
if (retval != ERROR_OK)
return retval;
if (target->smp) {
retval = update_halt_gdb(target);
if (retval != ERROR_OK)
return retval;
}
target_call_event_callbacks(target,
TARGET_EVENT_DEBUG_HALTED);
}
} }
} else } else
target->state = TARGET_RUNNING; target->state = TARGET_RUNNING;