This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Use target address size for DW_OP_deref in dwarf2expr.c
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: arnez at linux dot vnet dot ibm dot com (Andreas Arnez)
- Cc: gdb-patches at sourceware dot org, krebbel at linux dot vnet dot ibm dot com (Andreas Krebbel)
- Date: Wed, 5 Mar 2014 23:15:02 +0100 (CET)
- Subject: Re: [PATCH] Use target address size for DW_OP_deref in dwarf2expr.c
- Authentication-results: sourceware.org; auth=none
Andreas Arnez wrote:
> For DW_OP_deref, the DWARF standard states: "The size of the data
> retrieved from the dereferenced address is the size of an address on
> the target machine." However, gdb always dereferenced as much as the
> DWARF address size instead.
But that *is* the target address, as far as DWARF is concerned.
GDB's notion of ctx->addr_size derives from the address_size field
of the compilation unit header, which is documented in DWARF as:
A 1-byte unsigned integer representing the size in bytes of
an address on the target architecture. [...]
Every other place in the DWARF standard that uses "size of an
address on the target machine" refers to this field.
And this is also how it is used e.g. by GCC when generating
DW_OP_deref:
else if (size == DWARF2_ADDR_SIZE)
op = DW_OP_deref;
else
op = DW_OP_deref_size;
(where DWARF2_ADDR_SIZE is the value GCC emits into the compilation
unit header).
> On (some/all) 64-bit big-endian systems this mismatch led to failures
> with dw2-ifort-parameter.exp, where the DWARF address size is manually
> set to 4 bytes. DW_OP_deref only dereferenced the four higher-order
> bytes of the 64-bit pointer 'ptr', and the result (typically zero) was
> then used as a location of the formal parameter 'param'.
>
> See also https://sourceware.org/ml/gdb-patches/2014-01/msg00757.html
>
> gdb/
> * dwarf2expr.c (execute_stack_op): For DW_OP_deref, use the
> architecture's address size instead of the DWARF address size.
So given the above, I think this patch is wrong IMO, and will most
likely break parsing DWARF actually generated by GCC on machines that
define a non-default DWARF2_ADDR_SIZE.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com