public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/18281] New: Miscomputes or does not handle dwarf expression
Date: Mon, 20 Apr 2015 09:55:00 -0000	[thread overview]
Message-ID: <bug-18281-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 18281
           Summary: Miscomputes or does not handle dwarf expression
           Product: gdb
           Version: 7.9
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: rguenth at gcc dot gnu.org

For

int main (int argc, char **argv)
{
  char a[argc + 1];
  a[0] = 0;
  return a[0];
}

gcc with -O -g on x86_64 generates just

00000000004004fd <main>:
  4004fd:       b8 00 00 00 00          mov    $0x0,%eax
  400502:       c3                      retq   

but

 <2><1c3>: Abbrev Number: 4 (DW_TAG_variable)
    <1c4>   DW_AT_name        : a
    <1c6>   DW_AT_decl_file   : 1
    <1c7>   DW_AT_decl_line   : 3
    <1c8>   DW_AT_type        : <0x1e7>
...
 <1><1e7>: Abbrev Number: 8 (DW_TAG_array_type)
    <1e8>   DW_AT_type        : <0x1e0>
    <1ec>   DW_AT_sibling     : <0x201>
 <2><1f0>: Abbrev Number: 9 (DW_TAG_subrange_type)
    <1f1>   DW_AT_type        : <0x201>
    <1f5>   DW_AT_upper_bound : 10 byte block: 75 1 8 20 24 8 20 26 31 1c      
(DW_OP_breg5 (rdi): 1; DW_OP_const1u: 32; DW_OP_shl; DW_OP_const1u: 32;
DW_OP_shra; DW_OP_lit1; DW_OP_minus)

should be able to evaluate sizeof (a) at the start of main correctly.

(gdb) start
Temporary breakpoint 1 at 0x4004fd: file t.c, line 6.
(gdb) ptype a
type = char [variable length]
(gdb) p sizeof (a)
$1 = 0

so either gdb should print out 'optimized out' as it does for

(gdb) p a
$2 = <optimized out>

or compute a correct value for sizeof (a).  Just computing zero looks
wrong to me.

The DWARF expression for the upper bound is thus either not evaluated
or evaluated to a wrong expression.

This causes a GCC testsuite FAIL for gcc.dg/guality/vla-1.c

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


             reply	other threads:[~2015-04-20  9:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20  9:55 rguenth at gcc dot gnu.org [this message]
2021-02-22  2:43 ` [Bug gdb/18281] " tromey at sourceware 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-18281-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).