From: Pedro Alves <palves@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Fix DW_OP_GNU_regval_type with FP registers
Date: Thu, 14 Nov 2013 20:12:00 -0000 [thread overview]
Message-ID: <5285267C.7080004@redhat.com> (raw)
In-Reply-To: <1384434175-15561-1-git-send-email-brobecker@adacore.com>
On 11/14/2013 01:02 PM, Joel Brobecker wrote:
> Hello,
>
> Consider the following code, compiled at -O2 on ppc-linux:
>
> procedure Increment (Val : in out Float; Msg : String);
>
> The implementation does not really matter in this case). In our example,
> this function is being called from a function with Param_1 set to 99.0.
> Trying to break inside that function, and running until reaching that
> breakpoint yields:
>
> (gdb) b increment
> Breakpoint 1 at 0x100014b4: file callee.adb, line 6.
> (gdb) run
> Starting program: /[...]/foo
>
> Breakpoint 1, callee.increment (val=99.0, val@entry=0.0, msg=...)
> at callee.adb:6
> 6 if Val > 200.0 then
>
> The @entry value for parameter "val" is incorrect, it should be 99.0.
>
> The associated call-site parameter DIE looks like this:
>
> .uleb128 0xc # (DIE (0x115) DW_TAG_GNU_call_site_parameter)
> .byte 0x2 # DW_AT_location
> .byte 0x90 # DW_OP_regx
> .uleb128 0x21
> .byte 0x3 # DW_AT_GNU_call_site_value
> .byte 0xf5 # DW_OP_GNU_regval_type
> .uleb128 0x3f
> .uleb128 0x25
>
> The DW_AT_GNU_call_site_value uses a DW_OP_GNU_regval_type
> operation, referencing register 0x3f=63, which is $f31,
> an 8-byte floating register. In that register, the value is
> stored using the usual 8-byte float format:
>
> (gdb) info float
> f31 99.0 (raw 0x4058c00000000000)
>
> The current code evaluating DW_OP_GNU_regval_type operations
> currently is (dwarf2expr.c:execute_stack_op):
>
> result = (ctx->funcs->read_reg) (ctx->baton, reg);
> result_val = value_from_ulongest (address_type, result);
> result_val = value_from_contents (type,
> value_contents_all (result_val));
>
> What the ctx->funcs->read_reg function does is read the contents
> of the register as if it contained an address. The rest of the code
> continues that assumption, thinking it's OK to then use that to
> create an address/ulongest struct value, which we then re-type
> to the type specified by DW_OP_GNU_regval_type.
>
> We're getting 0.0 above because the read_reg implementations
> end up treating the contents of the FP register as an integral,
> reading only 4 out of the 8 bytes.
>
> Being a big-endian target,
> we read the high-order ones, which gives us zero.
>
> This patch fixes the problem by introducing a new callback to
> read the contents of a register as a given type, and then adjust
> the handling of DW_OP_GNU_regval_type to use that new callback.
I definitely agree with this. The patch looked fine to me.
(Eliminating read_reg might be tricky, but I think it'd be nice
if it were be renamed to something that implies "address", like
read_addr_reg or some such.)
--
Pedro Alves
next prev parent reply other threads:[~2013-11-14 19:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 15:21 Joel Brobecker
2013-11-14 20:12 ` Pedro Alves [this message]
2013-11-14 21:02 ` Tom Tromey
2013-11-15 12:19 ` Joel Brobecker
2013-11-15 14:54 ` Pedro Alves
2013-11-16 5:46 ` [RFA] Rename "read_reg" into "read_addr_from_reg" in struct dwarf_expr_context_funcs Joel Brobecker
2013-11-17 3:02 ` Pedro Alves
2013-11-17 9:43 ` pushed: " Joel Brobecker
2013-11-18 12:39 ` [OB] Simplify dwarf2-frame.c:read_addr_from_reg. (was: [RFA] Rename "read_reg" into "read_addr_from_reg" in struct dwarf_expr_context_funcs) Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5285267C.7080004@redhat.com \
--to=palves@redhat.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox