Skip to content

Commit

Permalink
gdb_server,rtos: Differentiate rtos_get_gdb_reg failing and not imple…
Browse files Browse the repository at this point in the history
…mented

If it fails, then pass that failure on. If it's simply not implemented,
then we can fall through and try target_get_gdb_reg_list_noread().

This difference matters when the target representing the current
hwthread is unavailable, but the target that is linked to the gdb
connection is available. In that case we want the operation to return an
error to gdb, instead of reading the register from the target that is
available.

Change-Id: I9c84ca556f818c5580e25ab349a34a226fcf0f43
Signed-off-by: Tim Newsome <[email protected]>
  • Loading branch information
timsifive committed Sep 27, 2023
1 parent b5e57e1 commit 15f3996
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/rtos/rtos.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ int rtos_get_gdb_reg(struct connection *connection, int reg_num)

free(reg_list);
}
return ERROR_FAIL;
return ERROR_NOT_IMPLEMENTED;
}

/** Return a list of general registers. */
Expand Down
9 changes: 7 additions & 2 deletions src/server/gdb_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,13 @@ static int gdb_get_register_packet(struct connection *connection,
LOG_DEBUG("-");
#endif

if ((target->rtos) && (rtos_get_gdb_reg(connection, reg_num) == ERROR_OK))
return ERROR_OK;
if (target->rtos) {
retval = rtos_get_gdb_reg(connection, reg_num);
if (retval == ERROR_OK)
return ERROR_OK;
if (retval != ERROR_NOT_IMPLEMENTED)
return gdb_error(connection, retval);
}

retval = target_get_gdb_reg_list_noread(target, &reg_list, &reg_list_size,
REG_CLASS_ALL);
Expand Down

0 comments on commit 15f3996

Please sign in to comment.