Bug 25650

Summary: GDB can't 'printf' a convenience variable holding an inferior address
Product: gdb Reporter: Sergio Durigan Junior <sergiodj>
Component: gdbAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: mark, mervegunesli
Priority: P2    
Version: 9.1   
Target Milestone: 9.2   
Host: Target:
Build: Last reconfirmed:

Description Sergio Durigan Junior 2020-03-09 22:45:56 UTC
This is a regression from 8.3.

When assigning an inferior address to a convenience variable, GDB is unable to print it correctly.  It's possible to reproduce this bug by doing:

$ echo -e 'int main(){const char a[]="test";return 0;}' | gcc -x c - -O0-g3
$ ./gdb/gdb --data-directory ./gdb/data-directory -q ./a.out -ex 'start' -ex 'set $x = (const char *) (&a[0] + 2)' -ex 'printf "%s\n", $x'

This has been fixed upstream; I'm creating this bug to backport the fix to the 9.1 branch.