public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug ada/28180] FAIL: gdb.ada/interface.exp: print s (timeout)
Date: Thu, 05 Aug 2021 10:11:13 +0000	[thread overview]
Message-ID: <bug-28180-4717-X3nH53XBDG@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28180-4717@http.sourceware.org/bugzilla/>

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

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)
> With current master I noticed this timeout:
> ...
> (gdb) PASS: gdb.ada/interface.exp: print r
> print s^M
> Multiple matches for s^M
> [0] cancel^M
> [1] s at
> /home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/
> interface/foo.adb:20^M
> [2] s at
> /home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/
> interface/foo.adb:?^M
> > FAIL: gdb.ada/interface.exp: print s (timeout)
> ...

Doing a bit of investigation, we see:
...
Breakpoint 1, foo () at
/home/vries/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/interface/foo.adb:22
22         Do_Nothing (R);  -- STOP
(gdb) info locals
r = (x => 1, y => 2, w => 3, h => 4)
<G6b_LAST> = 8
<foo__G6b___U> = 8
s = (x => 1, y => 2, w => 3, h => 4)
s = 0x7fffffffd890
...

So both "s" are local variables.

That makes it easy to find in the dwarf.

We have:
...
 <2><1204>: Abbrev Number: 31 (DW_TAG_variable)
    <1205>   DW_AT_name        : (indirect string, offset: 0x13e6): s.14
    <1209>   DW_AT_type        : <0x1213>
    <120d>   DW_AT_artificial  : 1
    <120d>   DW_AT_location    : 5 byte block: 91 e0 7d 23 18   (DW_OP_fbreg:
-288; DW_OP_plus_uconst: 24)
...
and:
...
 <3><1249>: Abbrev Number: 33 (DW_TAG_variable) 
    <124a>   DW_AT_name        : s
    <124c>   DW_AT_decl_file   : 1
    <124d>   DW_AT_decl_line   : 20
    <124e>   DW_AT_type        : <0x146d>
    <1252>   DW_AT_location    : 6 byte block: 91 e0 7d 23 18 6        
(DW_OP_fbreg: -288; DW_OP_plus_uconst: 24; DW_OP_deref)
...

I suppose the first is the unexpected one.  It has DW_AT_artificial, but is
still put into the symbol table because it has a DW_AT_name.

This patch:
...
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index acabee3315f..44327ecbd9a 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -21585,6 +21585,9 @@ new_symbol (struct die_info *die, struct type *type,
struct dwarf2_
cu *cu,
   if (name)
     {
       int suppress_add = 0;
+      attr = dwarf2_attr (die, DW_AT_artificial, cu);
+      if (attr != nullptr)
+       suppress_add = 1;

       if (space)
        sym = space;
...
gets us:
...
$ gdb -q -batch  outputs/gdb.ada/interface/foo -ex "b foo.adb:22" -ex r -ex "p
s"
Breakpoint 1 at 0x404455: file foo.adb, line 22.

Breakpoint 1, foo () at foo.adb:22
22         Do_Nothing (R);  -- STOP
warning: Unknown upper bound, using 1.
$1 = (x => 1, y => 2, w => 3, h => 4)
...
but with the warning because foo__G6b___U (which is another artificial
variable) cannot be evaluated.

Hmm, so ada uses named artifical variables that need to be in the symbol table
in order to evaluate them, but they should be ignored in terms of gdb commands
that investigate source constructs like "p s".  That seems to be the root
cause.

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

  parent reply	other threads:[~2021-08-05 10:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 22:32 [Bug ada/28180] New: " vries at gcc dot gnu.org
2021-08-02 22:32 ` [Bug ada/28180] " vries at gcc dot gnu.org
2021-08-02 22:36 ` vries at gcc dot gnu.org
2021-08-03 21:03 ` tromey at sourceware dot org
2021-08-04 20:06 ` tromey at sourceware dot org
2021-08-05 10:11 ` vries at gcc dot gnu.org [this message]
2021-08-05 10:56 ` vries at gcc dot gnu.org
2021-08-05 13:03 ` vries at gcc dot gnu.org
2021-08-05 13:17 ` vries at gcc dot gnu.org
2021-08-05 15:04 ` vries at gcc dot gnu.org
2021-08-06 16:16 ` tromey at sourceware dot org
2021-08-08  8:35 ` vries at gcc dot gnu.org
2021-08-13 18:42 ` tromey at sourceware dot org
2021-08-13 18:53 ` tromey at sourceware dot org
2021-08-14 13:13 ` vries at gcc dot gnu.org
2021-08-14 14:36 ` vries at gcc dot gnu.org
2021-08-17 18:05 ` brobecker at gnat dot com
2021-08-17 20:08 ` tromey at sourceware dot org
2021-08-24 11:14 ` vries at gcc dot gnu.org
2021-10-05 11:18 ` vries at gcc dot gnu.org
2024-03-08  9:55 ` sam at gentoo dot org

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=bug-28180-4717-X3nH53XBDG@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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).