Revert "server/gdb_server.c: support unavailable registers"
This reverts commit 236c54c94a
.
Change-Id: I59ac4e3907547356e08c567fc2c8f50a13902bd9
This commit is contained in:
parent
56dab6ce0c
commit
71b32bc43e
|
@ -1260,29 +1260,6 @@ static void gdb_target_to_reg(struct target *target,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get register value if needed and fill the buffer accordingly */
|
|
||||||
static int gdb_get_reg_value_as_str(struct target *target, char *tstr, struct reg *reg)
|
|
||||||
{
|
|
||||||
int retval = ERROR_OK;
|
|
||||||
|
|
||||||
if (!reg->valid)
|
|
||||||
retval = reg->type->get(reg);
|
|
||||||
|
|
||||||
const unsigned int len = DIV_ROUND_UP(reg->size, 8) * 2;
|
|
||||||
switch (retval) {
|
|
||||||
case ERROR_OK:
|
|
||||||
gdb_str_to_target(target, tstr, reg);
|
|
||||||
return ERROR_OK;
|
|
||||||
case ERROR_TARGET_RESOURCE_NOT_AVAILABLE:
|
|
||||||
memset(tstr, 'x', len);
|
|
||||||
tstr[len] = '\0';
|
|
||||||
return ERROR_OK;
|
|
||||||
}
|
|
||||||
memset(tstr, '0', len);
|
|
||||||
tstr[len] = '\0';
|
|
||||||
return ERROR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int gdb_get_registers_packet(struct connection *connection,
|
static int gdb_get_registers_packet(struct connection *connection,
|
||||||
char const *packet, int packet_size)
|
char const *packet, int packet_size)
|
||||||
{
|
{
|
||||||
|
@ -1324,13 +1301,16 @@ static int gdb_get_registers_packet(struct connection *connection,
|
||||||
for (i = 0; i < reg_list_size; i++) {
|
for (i = 0; i < reg_list_size; i++) {
|
||||||
if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden)
|
if (!reg_list[i] || !reg_list[i]->exist || reg_list[i]->hidden)
|
||||||
continue;
|
continue;
|
||||||
retval = gdb_get_reg_value_as_str(target, reg_packet_p, reg_list[i]);
|
if (!reg_list[i]->valid) {
|
||||||
if (retval != ERROR_OK && gdb_report_register_access_error) {
|
retval = reg_list[i]->type->get(reg_list[i]);
|
||||||
LOG_DEBUG("Couldn't get register %s.", reg_list[i]->name);
|
if (retval != ERROR_OK && gdb_report_register_access_error) {
|
||||||
free(reg_packet);
|
LOG_DEBUG("Couldn't get register %s.", reg_list[i]->name);
|
||||||
free(reg_list);
|
free(reg_packet);
|
||||||
return gdb_error(connection, retval);
|
free(reg_list);
|
||||||
|
return gdb_error(connection, retval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
gdb_str_to_target(target, reg_packet_p, reg_list[i]);
|
||||||
reg_packet_p += DIV_ROUND_UP(reg_list[i]->size, 8) * 2;
|
reg_packet_p += DIV_ROUND_UP(reg_list[i]->size, 8) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1447,15 +1427,18 @@ static int gdb_get_register_packet(struct connection *connection,
|
||||||
return gdb_error(connection, ERROR_FAIL);
|
return gdb_error(connection, ERROR_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!reg_list[reg_num]->valid) {
|
||||||
|
retval = reg_list[reg_num]->type->get(reg_list[reg_num]);
|
||||||
|
if (retval != ERROR_OK && gdb_report_register_access_error) {
|
||||||
|
LOG_DEBUG("Couldn't get register %s.", reg_list[reg_num]->name);
|
||||||
|
free(reg_list);
|
||||||
|
return gdb_error(connection, retval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reg_packet = calloc(DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2 + 1, 1); /* plus one for string termination null */
|
reg_packet = calloc(DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2 + 1, 1); /* plus one for string termination null */
|
||||||
|
|
||||||
retval = gdb_get_reg_value_as_str(target, reg_packet, reg_list[reg_num]);
|
gdb_str_to_target(target, reg_packet, reg_list[reg_num]);
|
||||||
if (retval != ERROR_OK && gdb_report_register_access_error) {
|
|
||||||
LOG_DEBUG("Couldn't get register %s.", reg_list[reg_num]->name);
|
|
||||||
free(reg_packet);
|
|
||||||
free(reg_list);
|
|
||||||
return gdb_error(connection, retval);
|
|
||||||
}
|
|
||||||
|
|
||||||
gdb_put_packet(connection, reg_packet, DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2);
|
gdb_put_packet(connection, reg_packet, DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue