rtos: Refactor rtos_get_gdb_reg()
Exit early if conditions aren't satisfied, instead of putting the core code inside an if(). Also return ERROR_FAIL if conditions are satisfied but no matching registers were found. Change-Id: I77aa63d9f707bc38d1a71899275ba603914b52c9 Signed-off-by: Tim Newsome <tim@sifive.com>
This commit is contained in:
parent
15f399691e
commit
969b30326c
src/rtos
|
@ -529,18 +529,20 @@ int rtos_get_gdb_reg(struct connection *connection, int reg_num)
|
||||||
{
|
{
|
||||||
struct target *target = get_target_from_connection(connection);
|
struct target *target = get_target_from_connection(connection);
|
||||||
threadid_t current_threadid = target->rtos->current_threadid;
|
threadid_t current_threadid = target->rtos->current_threadid;
|
||||||
if ((target->rtos) && (current_threadid != -1) &&
|
if (!target->rtos ||
|
||||||
(current_threadid != 0) &&
|
current_threadid == -1 ||
|
||||||
((current_threadid != target->rtos->current_thread) ||
|
current_threadid == 0 ||
|
||||||
(target->smp))) { /* in smp several current thread are possible */
|
(current_threadid == target->rtos->current_thread &&
|
||||||
|
!target->smp)) { /* in smp several current thread are possible */
|
||||||
|
return ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
struct rtos_reg *reg_list;
|
struct rtos_reg *reg_list;
|
||||||
int num_regs;
|
int num_regs;
|
||||||
|
|
||||||
LOG_DEBUG("getting register %d for thread 0x%" PRIx64
|
LOG_TARGET_DEBUG(target, "getting register %d for thread 0x%" PRIx64
|
||||||
", target->rtos->current_thread=0x%" PRIx64,
|
", target->rtos->current_thread=0x%" PRIx64,
|
||||||
reg_num,
|
reg_num, current_threadid, target->rtos->current_thread);
|
||||||
current_threadid,
|
|
||||||
target->rtos->current_thread);
|
|
||||||
|
|
||||||
int retval;
|
int retval;
|
||||||
if (target->rtos->type->get_thread_reg_value) {
|
if (target->rtos->type->get_thread_reg_value) {
|
||||||
|
@ -590,8 +592,8 @@ int rtos_get_gdb_reg(struct connection *connection, int reg_num)
|
||||||
}
|
}
|
||||||
|
|
||||||
free(reg_list);
|
free(reg_list);
|
||||||
}
|
|
||||||
return ERROR_NOT_IMPLEMENTED;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a list of general registers. */
|
/** Return a list of general registers. */
|
||||||
|
|
Loading…
Reference in New Issue