Skip to content

Commit

Permalink
gdb_main: correct read register responses when the register is not av…
Browse files Browse the repository at this point in the history
…ailable

When reading registers, the stub may also return a string of literal ‘x’’s in place of the register data digits, to indicate that the corresponding register’s value is unavailable.
This indicates that the stub has no means to access the register contents, even though the corresponding register is known to exist.

If a register truly does not exist on the target, then it is better to not include it in the target description in the first place.
  • Loading branch information
perigoso committed Dec 11, 2024
1 parent 4d25373 commit 90190cf
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/gdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ int32_t gdb_main_loop(target_controller_s *const tc, const gdb_packet_s *const p
target_regs_read(cur_target, gp_regs);
gdb_put_packet_hex(gp_regs, reg_size);
} else {
gdb_put_packet_str("00");
/**
* Register data is unavailable
* See: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#read-registers-packet
*
* ... the stub may also return a string of literal ‘x’ in place of the register data digits,
* to indicate that the corresponding register’s value is unavailable.
*/
gdb_put_packet_str("xx");
}
break;
}
Expand Down Expand Up @@ -248,7 +255,14 @@ int32_t gdb_main_loop(target_controller_s *const tc, const gdb_packet_s *const p
gdb_put_packet_error(0xffU);
}
} else {
gdb_put_packet_str("00");
/**
* Register data is unavailable
* See: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#read-registers-packet
*
* ... the stub may also return a string of literal ‘x’ in place of the register data digits,
* to indicate that the corresponding register’s value is unavailable.
*/
gdb_put_packet_str("xx");
}
break;
}
Expand Down

0 comments on commit 90190cf

Please sign in to comment.