This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug corefiles/22795] Variables in the .bss section are printed as 32-bit


https://sourceware.org/bugzilla/show_bug.cgi?id=22795

--- Comment #2 from Byron Hawkins <byron.c.hawkins at gmail dot com> ---
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 *'

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]