[PATCH] [gdb/exp] Fix cast handling for indirection

Kevin Buettner kevinb@redhat.com
Mon May 6 00:54:39 GMT 2024


On Sat, 4 May 2024 00:26:49 +0100
Pedro Alves <pedro@palves.net> wrote:

> I kind of emphasized the sign extension part above, but to be clear, with
> 
>   (gdb) p (long long)*a_loc()
> 
> and gdb assuming that means a_loc returns "long long *", gdb incorrectly reads a
> 64-bit value off of the pointer address, which is totally bogus and would not
> be what gdb would do if it had debug info for a_loc(), in which case GDB would
> know that it returns char *, and thus would deref only one byte and behave like
> described above in the 1: 2: 3: steps.  The behavior of the expression should not
> change like that depending on whether you have debug info.  Thus, GDB should error
> out.

This argument is compelling.  You've convinced me.

Kevin



More information about the Gdb-patches mailing list