[llvm-bugs] [Bug 48247] New: vla var with typedef'd type has incomplete debug info

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Nov 21 03:31:48 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48247

            Bug ID: 48247
           Summary: vla var with typedef'd type has incomplete debug info
           Product: new-bugs
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: vries at gcc.gnu.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Consider test.c:
...
int n = 5;
int a = 1;

int
main (void)
{
#if V == 1
  int vla[n];
#elif V == 2
  typedef int vla_t[n];
  vla_t vla;
#endif

  for (int i = 0; i < n; i++)
    vla[i] = i;

  return vla[a];
}
...

With gcc, we print the correct type of vla in both V=1 and V=2 cases:
...
$ gcc test.c -g -DV=1
$ gdb -batch a.out -ex "b 17" -ex run -ex "ptype vla" 
Breakpoint 1 at 0x400533: file test.c, line 17.

Breakpoint 1, main () at test.c:17
17        return vla[a];
type = int [5]
$ gcc test.c -g -DV=2
$ gdb -batch a.out -ex "b 17" -ex run -ex "ptype vla" 
Breakpoint 1 at 0x400533: file test.c, line 17.

Breakpoint 1, main () at test.c:17
17        return vla[a];
type = int [5]
...

With clang-10, that's only for V=1:
...
$ clang test.c -g -DV=1
$ gdb -batch a.out -ex "b 17" -ex run -ex "ptype vla" 
Breakpoint 1 at 0x40050e: file test.c, line 17.

Breakpoint 1, main () at test.c:17
17        return vla[a];
type = int [5]
$ clang test.c -g -DV=2
$ gdb -batch a.out -ex "b 17" -ex run -ex "ptype vla" 
Breakpoint 1 at 0x40050e: file test.c, line 17.

Breakpoint 1, main () at test.c:17
17        return vla[a];
type = int []
...

With clang and V=2, the variable vla:
...
 <2><147>: Abbrev Number: 6 (DW_TAG_variable)
    <14c>   DW_AT_name        : (indirect string, offset: 0x21d): vla
    <152>   DW_AT_type        : <0x172>
...
has type:
...
 <2><172>: Abbrev Number: 9 (DW_TAG_typedef)
    <173>   DW_AT_type        : <0x185>
    <177>   DW_AT_name        : (indirect string, offset: 0x235): vla_t
...
which refers to type:
...
 <1><185>: Abbrev Number: 10 (DW_TAG_array_type)
    <186>   DW_AT_type        : <0x106>
 <2><18a>: Abbrev Number: 11 (DW_TAG_subrange_type)
    <18b>   DW_AT_type        : <0x190>
...

There's no DW_AT_count for the DW_TAG_subrange_type.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201121/279ba27f/attachment-0001.html>


More information about the llvm-bugs mailing list