Bug 25650 - GDB can't 'printf' a convenience variable holding an inferior address
Summary: GDB can't 'printf' a convenience variable holding an inferior address
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 9.1
: P2 normal
Target Milestone: 9.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-09 22:45 UTC by Sergio Durigan Junior
Modified: 2020-03-11 16:32 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.