public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "gbenson at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/26905] New: Inconsistent DW_AT_count evaluation
Date: Mon, 16 Nov 2020 15:01:45 +0000	[thread overview]
Message-ID: <bug-26905-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 26905
           Summary: Inconsistent DW_AT_count evaluation
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: gbenson at redhat dot com
  Target Milestone: ---

Clang describes the upper bounds of variable length arrays using a DW_AT_count
attribute which references the DIE of a synthetic variable whose value is a
DW_AT_location.  In some cases GDB correctly handles these, but other times GDB
attempts to dereference the result of evaluating the location expression and
fails.

An example where GDB does not dereference the value:

 $ gdb /path/to/gdb/testsuite/outputs/gdb.mi/mi-vla-c99/mi-vla-c99
 (gdb) b vla.c:28
 (gdb) r
  ...
 Breakpoint 1, func (n=5) at /gdbtest/src/gdb/testsuite/gdb.mi/vla.c:28
 28       return n;                 /* vla-filled */
 (gdb) p vla
 $1 = {0, 1, 2, 3, 4}
 (gdb) p __vla_expr0
 $2 = 5

An example where GDB does dereference the value:

 $ gdb
/path/to/gdb/testsuite/outputs/gdb.base/vla-optimized-out/vla-optimized-out-o1 
 (gdb) b f1
 Breakpoint 1 at 0x401110: file
/gdbtest/src/gdb/testsuite/gdb.base/vla-optimized-out.c, line 34.
 (gdb) r
  ...
 Breakpoint 1, f1 (i=5) at
/gdbtest/src/gdb/testsuite/gdb.base/vla-optimized-out.c:34
 34     }
 (gdb) p a
 Cannot access memory at address 0x6
 (gdb) 
 (gdb) p __vla_expr0
 $1 = 6

In both these examples, __vla_expr0 is the name Clang assigned the synthetic
variable containing the value of DW_AT_count.

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

             reply	other threads:[~2020-11-16 15:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 15:01 gbenson at redhat dot com [this message]
2020-11-16 15:03 ` [Bug gdb/26905] " gbenson at redhat dot com
2020-11-16 15:05 ` gbenson at redhat dot com
2020-11-16 15:05 ` gbenson at redhat dot com
2020-11-16 15:06 ` gbenson at redhat dot com
2020-11-16 15:23 ` gbenson at redhat dot com
2020-11-16 15:25 ` gbenson at redhat dot com
2020-11-16 15:26 ` gbenson at redhat dot com
2020-11-17  9:51 ` gbenson at redhat dot com
2020-11-20 13:50 ` [Bug symtab/26905] " vries at gcc dot gnu.org
2020-11-20 16:32 ` vries at gcc dot gnu.org
2020-11-22  9:55 ` cvs-commit at gcc dot gnu.org
2020-11-23 17:59 ` mark at klomp dot org
2020-11-30 12:50 ` cvs-commit at gcc dot gnu.org
2020-11-30 12:53 ` vries at gcc dot gnu.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-26905-4717@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).