public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/43762]  New: VLA artificial length var loclist is missing DW_OP_stack_value
@ 2010-04-15 21:48 jan dot kratochvil at redhat dot com
  2010-04-16  7:02 ` [Bug debug/43762] " jakub at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-04-15 21:48 UTC (permalink / raw)
  To: gcc-bugs

gcc (GCC) 4.6.0 20100415 (experimental)
-O2 -g
-----------------------------------------------------------------------------
void __attribute__((noinline))
f (int l)
{
  char s[l];
}
int
main (void)
{
  f (5);
  return 0;
}
-----------------------------------------------------------------------------
 <2><63>: Abbrev Number: 5 (DW_TAG_variable)
    <64>   DW_AT_name        : s
    <68>   DW_AT_type        : <0x74>
 <1><74>: Abbrev Number: 7 (DW_TAG_array_type)
 <2><7d>: Abbrev Number: 8 (DW_TAG_subrange_type)
    <82>   DW_AT_upper_bound : <0x59>
 <2><59>: Abbrev Number: 4 (DW_TAG_variable)
    <5a>   DW_AT_artificial  : 1
    <5b>   DW_AT_type        : <0x8a>
    <5f>   DW_AT_location    : 0x83     (location list)
 <1><8a>: Abbrev Number: 10 (DW_TAG_const_type)
    <8b>   DW_AT_type        : <0x87>
 <1><87>: Abbrev Number: 9 (DW_TAG_base_type)
    <88>   DW_AT_byte_size   : 8
    <89>   DW_AT_encoding    : 7        (unsigned)

 <2><4c>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <4d>   DW_AT_name        : l
    <51>   DW_AT_type        : <0x6d>
    <55>   DW_AT_location    : 0x60     (location list)
 <1><6d>: Abbrev Number: 6 (DW_TAG_base_type)
    <6e>   DW_AT_byte_size   : 4
    <6f>   DW_AT_encoding    : 5        (signed)
    <70>   DW_AT_name        : int

Contents of the .debug_loc section:
    Offset   Begin    End      Expression
    00000060 0000000000400460 0000000000400468 (DW_OP_reg5)
    00000060 <End of list>
    00000083 0000000000400460 0000000000400463 (DW_OP_breg5: 0; DW_OP_const1u:
32; DW_OP_shl; DW_OP_const1u: 32; DW_OP_shra; DW_OP_const1s: -1; DW_OP_plus)
    00000083 0000000000400463 0000000000400468 (DW_OP_breg5: -1)
    00000083 0000000000400468 000000000040046c (DW_OP_breg5: -31)
    00000083 <End of list>
-----------------------------------------------------------------------------

I believe the loclist at 0x83 should have DW_OP_stack_value on each line.
Even according to recent (offlist) mail by Jakub these are "location
expressions".

I do not see in the DWARF spec. an explicit description what should mean a DIE
reference for DW_AT_upper_bound, currently generated by GCC as:
    <82>   DW_AT_upper_bound : <0x59>

I believe it was designed to supply there the real variable "l" holding the
value such as if it would be:
    <82>   DW_AT_upper_bound : <0x4c>

If an artificial variable calculating the same value is used the artificial
variable should simulate it has such _value_ (and not such its _address_).

(This problem is also affecting Fortran dynamic arrays with -O2 -g.)


-- 
           Summary: VLA artificial length var loclist is missing
                    DW_OP_stack_value
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jan dot kratochvil at redhat dot com
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug debug/43762] VLA artificial length var loclist is missing DW_OP_stack_value
  2010-04-15 21:48 [Bug debug/43762] New: VLA artificial length var loclist is missing DW_OP_stack_value jan dot kratochvil at redhat dot com
@ 2010-04-16  7:02 ` jakub at gcc dot gnu dot org
  2010-04-16  7:34 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-04-16  7:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2010-04-16 07:02 -------
Probably you are right, though I think clarification on dwarf-discuss wouldn't
hurt.  Can you raise it there?

I think 2.19 Static and Dynamic Values of Attributes is what matters here:

The value of these attributes is determined based on the class as follows:
- For a constant, the value of the constant is the value of the attribute.
- For a reference, the value is a reference to another entity which specifies
the value of the attribute.
- For an exprloc, the value is interpreted as a DWARF expression or location
description; evaluation of the expression yields the value of the attribute.

The "or location description" confuses me, either it is a DWARF expression, or
location description, but leaving in both options is ambiguous, given that a
DWARF expression is also a memory location description and differ in a
dereference.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug debug/43762] VLA artificial length var loclist is missing DW_OP_stack_value
  2010-04-15 21:48 [Bug debug/43762] New: VLA artificial length var loclist is missing DW_OP_stack_value jan dot kratochvil at redhat dot com
  2010-04-16  7:02 ` [Bug debug/43762] " jakub at gcc dot gnu dot org
@ 2010-04-16  7:34 ` jakub at gcc dot gnu dot org
  2010-04-16 15:35 ` jakub at gcc dot gnu dot org
  2010-05-19 14:56 ` jakub at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-04-16  7:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2010-04-16 07:33 -------
Created an attachment (id=20392)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20392&action=view)
gcc46-pr43762.patch

Possible fix.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug debug/43762] VLA artificial length var loclist is missing DW_OP_stack_value
  2010-04-15 21:48 [Bug debug/43762] New: VLA artificial length var loclist is missing DW_OP_stack_value jan dot kratochvil at redhat dot com
  2010-04-16  7:02 ` [Bug debug/43762] " jakub at gcc dot gnu dot org
  2010-04-16  7:34 ` jakub at gcc dot gnu dot org
@ 2010-04-16 15:35 ` jakub at gcc dot gnu dot org
  2010-05-19 14:56 ` jakub at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-04-16 15:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2010-04-16 15:35 -------
Subject: Bug 43762

Author: jakub
Date: Fri Apr 16 15:34:47 2010
New Revision: 158430

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158430
Log:
        PR debug/43762
        * dwarf2out.c (add_bound_info): Always call loc_list_from_tree
        with want_address 2 and in case a single element list might be
        possible, call it again with want_address 0.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug debug/43762] VLA artificial length var loclist is missing DW_OP_stack_value
  2010-04-15 21:48 [Bug debug/43762] New: VLA artificial length var loclist is missing DW_OP_stack_value jan dot kratochvil at redhat dot com
                   ` (2 preceding siblings ...)
  2010-04-16 15:35 ` jakub at gcc dot gnu dot org
@ 2010-05-19 14:56 ` jakub at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-05-19 14:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2010-05-19 14:55 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-19 14:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-15 21:48 [Bug debug/43762] New: VLA artificial length var loclist is missing DW_OP_stack_value jan dot kratochvil at redhat dot com
2010-04-16  7:02 ` [Bug debug/43762] " jakub at gcc dot gnu dot org
2010-04-16  7:34 ` jakub at gcc dot gnu dot org
2010-04-16 15:35 ` jakub at gcc dot gnu dot org
2010-05-19 14:56 ` jakub at gcc dot gnu dot org

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).