public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Tom Tromey <tom@tromey.com>
Cc: Keith Seitz via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Resolve dynamic types before computing pointer size
Date: Thu, 21 Oct 2021 12:19:05 -0600	[thread overview]
Message-ID: <87y26ms0km.fsf@tromey.com> (raw)
In-Reply-To: <87k0i7tlsw.fsf@tromey.com> (Tom Tromey's message of "Wed, 20 Oct 2021 15:42:55 -0600")

Keith> Unfortunately, my patch to find_size_for_pointer_math interferes with your recently committed
Keith> patch ["Fix bug in dynamic type resolution"], which you "snuck" [:-)] in before I could finish
Keith> rebasing and retesting my patch.

Tom> Sorry about that.

I debugged this today and came up with the appended.

The ada-lang.c hunk is the important bit.  I don't see a reason to call
value_addr here, and this call results in a value that has no address.

It seems wrong to have a not_lval object with a 0 address that can then
be treated as a pointer.  Though in this case, the value has
contents... so I wonder if that's something your patch needs to account
for.

The other hunk just changes the failure from 0x4 to 0x0, which seems
more correct in this case.  Though I wonder if this should really go in,
since it seems like it could do the wrong thing on platforms where 0 is
a valid address.

Tom

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 8b9e94e25d8..b9c693e277c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10685,9 +10685,6 @@ ada_funcall_operation::evaluate (struct type *expect_type,
 	 well.  */
       callee = ada_to_fixed_value (coerce_ref (callee));
     }
-  else if (value_type (callee)->code () == TYPE_CODE_ARRAY
-	   && VALUE_LVAL (callee) == lval_memory)
-    callee = value_addr (callee);
 
   struct type *type = ada_check_typedef (value_type (callee));
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b39d2b72348..b162e8fe20c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2619,7 +2619,9 @@ resolve_dynamic_struct (struct type *type,
       pinfo.valaddr = addr_stack->valaddr;
       if (!pinfo.valaddr.empty ())
 	pinfo.valaddr = pinfo.valaddr.slice (offset);
-      pinfo.addr = addr_stack->addr + offset;
+      pinfo.addr = addr_stack->addr;
+      if (pinfo.addr != 0)
+	pinfo.addr += offset;
       pinfo.next = addr_stack;
 
       resolved_type->field (i).set_type

  reply	other threads:[~2021-10-21 18:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 16:42 Keith Seitz
2021-10-19 16:21 ` Tom Tromey
2021-10-20 19:29   ` Keith Seitz
2021-10-20 21:42     ` Tom Tromey
2021-10-21 18:19       ` Tom Tromey [this message]
2021-11-11 18:21         ` Keith Seitz
2022-02-24 19:51           ` Keith Seitz

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=87y26ms0km.fsf@tromey.com \
    --to=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).