<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 20, 2021, 1:21 AM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Stephen, Joel:<br>
<br>
On Fri, Mar 19, 2021 at 9:35 AM Stephen Clark <<a href="mailto:stephen.clark@oarcorp.com" target="_blank" rel="noreferrer">stephen.clark@oarcorp.com</a>> wrote:<br>
><br>
> Using 32bit types like uint32_t for pointers creates issues on 64 bit<br>
> architectures like AArch64. Replaced occurrences of these with uintptr_t,<br>
> which will work for both 32 and 64 bit architectures.<br>
> ---<br>
> cpukit/libdebugger/rtems-debugger-server.c | 4 ++--<br>
> cpukit/libdebugger/rtems-debugger-target.c | 2 +-<br>
> cpukit/libdebugger/rtems-debugger-target.h | 2 +-<br>
> 3 files changed, 4 insertions(+), 4 deletions(-)<br>
><br>
> diff --git a/cpukit/libdebugger/rtems-debugger-server.c b/cpukit/libdebugger/rtems-debugger-server.c<br>
> index 975ec23a30..f8c485a794 100644<br>
> --- a/cpukit/libdebugger/rtems-debugger-server.c<br>
> +++ b/cpukit/libdebugger/rtems-debugger-server.c<br>
> @@ -1438,7 +1438,7 @@ remote_read_memory(uint8_t* buffer, int size)<br>
> if (comma == NULL)<br>
> remote_packet_out_str(r_E01);<br>
> else {<br>
> - DB_UINT addr;<br>
> + uintptr_t addr;<br>
> DB_UINT length;<br>
> int r;<br>
> addr = hex_decode_uint(&buffer[1]);<br>
<br>
I still have concerns that just changing the variable types is not<br>
addressing any possible fundamental type errors that get hidden by<br>
later type coercion, for example, here we see addr = hex_decode_uint()<br>
that returns type DB_UINT, so now we have a type mismatch in 64-bit<br>
targets. Now, maybe it is fine, because the addresses are limited to<br>
32-bits in practice, but I would like some discussion of the analysis<br>
that has been done on these type changes.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">I commented earlier in this thread that Chris needs to comment on the gdb protocol. Switching to uintptr_t should be correct but, as you point out, whether or not the gdb protocol uses 64 bit addresses in the messages is unknown to us both.</div><div dir="auto"><br></div><div dir="auto">Looking at the gdb manual, it seems to use addr a lot without explaining this point.</div><div dir="auto"><br></div><div dir="auto">My money says there needs to be a decode address which returns a uintptr_t. And that combined with this patch and a review of where the variables are used is needed.</div><div dir="auto"><br></div><div dir="auto">I suspect the answer is in something like remote.c in the gdb source. </div><div dir="auto"><br></div><div dir="auto">But we really need guidance from Chris.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> @@ -1468,7 +1468,7 @@ remote_write_memory(uint8_t* buffer, int size)<br>
> comma = strchr((const char*) buffer, ',');<br>
> colon = strchr((const char*) buffer, ':');<br>
> if (comma != NULL && colon != NULL) {<br>
> - DB_UINT addr;<br>
> + uintptr_t addr;<br>
> DB_UINT length;<br>
> int r;<br>
> addr = hex_decode_uint(&buffer[1]);<br>
> diff --git a/cpukit/libdebugger/rtems-debugger-target.c b/cpukit/libdebugger/rtems-debugger-target.c<br>
> index bf7579700d..34e4e84d2f 100644<br>
> --- a/cpukit/libdebugger/rtems-debugger-target.c<br>
> +++ b/cpukit/libdebugger/rtems-debugger-target.c<br>
> @@ -168,7 +168,7 @@ rtems_debugger_target_reg_table_size(void)<br>
> }<br>
><br>
> int<br>
> -rtems_debugger_target_swbreak_control(bool insert, DB_UINT addr, DB_UINT kind)<br>
> +rtems_debugger_target_swbreak_control(bool insert, uintptr_t addr, DB_UINT kind)<br>
> {<br>
> rtems_debugger_target* target = rtems_debugger->target;<br>
> rtems_debugger_target_swbreak* swbreaks;<br>
> diff --git a/cpukit/libdebugger/rtems-debugger-target.h b/cpukit/libdebugger/rtems-debugger-target.h<br>
> index f2abbe5fd3..db356e1f07 100644<br>
> --- a/cpukit/libdebugger/rtems-debugger-target.h<br>
> +++ b/cpukit/libdebugger/rtems-debugger-target.h<br>
> @@ -200,7 +200,7 @@ extern void rtems_debugger_target_exception_print(CPU_Exception_frame* frame);<br>
> * Software breakpoints. These are also referred to as memory breakpoints.<br>
> */<br>
> extern int rtems_debugger_target_swbreak_control(bool insert,<br>
> - DB_UINT addr,<br>
> + uintptr_t addr,<br>
> DB_UINT kind);<br>
><br>
> /**<br>
> --<br>
> 2.27.0<br>
><br>
> _______________________________________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div></div>