This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug corefiles/22795] Variables in the .bss section are printed as 32-bit
- From: "simon.marchi at ericsson dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 07 Feb 2018 12:50:22 +0000
- Subject: [Bug corefiles/22795] Variables in the .bss section are printed as 32-bit
- Auto-submitted: auto-generated
- References: <bug-22795-4717@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=22795
--- Comment #3 from Simon Marchi <simon.marchi at ericsson dot com> ---
(In reply to Byron Hawkins from comment #2)
> If the type of the __environ variable is not known, then why does GDB assume
> type "int *" and dereference the pointer? I can suggest two reasonable
> options:
>
> 1. print the address of __environ as a "void *" unless it knows the specific
> type of the variable.
> 2. respond with an error "attempt to dereference a generic pointer", since
> the user did ask for the variable's value without providing a type.
>
> But casting the pointer to an arbitrarily chosen type is totally confusing.
> How can the user figure out that "char **__environ" has been cast to "int
> *"? There is nothing in the program to suggest that __environ should refer
> to any int anywhere, and there is nothing in the output to suggest that the
> printed value was truncated at 4 bytes (i.e., it is indistinguishable from
> an 8-byte type because leading zeros are omitted).
>
> If it is really necessary to presume a type, GDB should at the very least
> print what it is doing:
>
> Variable '__environ' has unknown type: assuming 'int *'
It used to assume the type, it doesn't anymore starting with GDB 8.1, for
exactly the reasons you mentioned. So you just need to upgrade your GDB to
8.1.
--
You are receiving this mail because:
You are on the CC list for the bug.