rtems-debugger: Fixed pointer types to work on 32 and 64 bit architectures

Using 32bit types like uint32_t for pointers creates issues on 64 bit
architectures like AArch64. Replaced occurrences of these with
uintptr_t, which will work for both 32 and 64 bit architectures. Added
hex_decode_addr function to rtems-debugger.
This commit is contained in:
Stephen Clark
2021-05-13 10:13:57 -05:00
committed by Joel Sherrill
parent 75c133bda0
commit 9b088157ed
3 changed files with 28 additions and 8 deletions

View File

@@ -154,6 +154,26 @@ hex_encode(int val)
return "0123456789abcdef"[val & 0xf];
}
static inline uintptr_t
hex_decode_addr(const uint8_t* data)
{
uintptr_t ui = 0;
size_t i;
if (data[0] == '-') {
if (data[1] == '1')
ui = (uintptr_t) -1;
}
else {
for (i = 0; i < (sizeof(ui) * 2); ++i) {
int v = hex_decode(data[i]);
if (v < 0)
break;
ui = (ui << 4) | v;
}
}
return ui;
}
static inline DB_UINT
hex_decode_uint(const uint8_t* data)
{
@@ -1438,10 +1458,10 @@ remote_read_memory(uint8_t* buffer, int size)
if (comma == NULL)
remote_packet_out_str(r_E01);
else {
DB_UINT addr;
uintptr_t addr;
DB_UINT length;
int r;
addr = hex_decode_uint(&buffer[1]);
addr = hex_decode_addr(&buffer[1]);
length = hex_decode_uint((const uint8_t*) comma + 1);
remote_packet_out_reset();
r = rtems_debugger_target_start_memory_access();
@@ -1468,10 +1488,10 @@ remote_write_memory(uint8_t* buffer, int size)
comma = strchr((const char*) buffer, ',');
colon = strchr((const char*) buffer, ':');
if (comma != NULL && colon != NULL) {
DB_UINT addr;
uintptr_t addr;
DB_UINT length;
int r;
addr = hex_decode_uint(&buffer[1]);
addr = hex_decode_addr(&buffer[1]);
length = hex_decode_uint((const uint8_t*) comma + 1);
r = rtems_debugger_target_start_memory_access();
if (r == 0) {
@@ -1519,9 +1539,9 @@ remote_breakpoints(bool insert, uint8_t* buffer, int size)
comma2 = strchr(comma1 + 1, ',');
if (comma2 != NULL) {
uint32_t capabilities;
DB_UINT addr;
uintptr_t addr;
DB_UINT kind;
addr = hex_decode_uint((const uint8_t*) comma1 + 1);
addr = hex_decode_addr((const uint8_t*) comma1 + 1);
kind = hex_decode_uint((const uint8_t*)comma2 + 1);
capabilities = rtems_debugger_target_capabilities();
switch (buffer[1]) {

View File

@@ -168,7 +168,7 @@ rtems_debugger_target_reg_table_size(void)
}
int
rtems_debugger_target_swbreak_control(bool insert, DB_UINT addr, DB_UINT kind)
rtems_debugger_target_swbreak_control(bool insert, uintptr_t addr, DB_UINT kind)
{
rtems_debugger_target* target = rtems_debugger->target;
rtems_debugger_target_swbreak* swbreaks;

View File

@@ -200,7 +200,7 @@ extern void rtems_debugger_target_exception_print(CPU_Exception_frame* frame);
* Software breakpoints. These are also referred to as memory breakpoints.
*/
extern int rtems_debugger_target_swbreak_control(bool insert,
DB_UINT addr,
uintptr_t addr,
DB_UINT kind);
/**