[llvm-bugs] [Bug 30553] New: Debug info generated for arrays is not what GDB expects (not as good as GCC's)

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 28 10:16:13 PDT 2016


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

            Bug ID: 30553
           Summary: Debug info generated for arrays is not what GDB
                    expects (not as good as GCC's)
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: cmtice at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

There is a very annoying difference in the way GCC & LLVM generate debug
information for arrays.  The symptom is that when GDB is asked to print an
array-type variable that was compiled with GCC, it shows the array and it's
contents, while when asked to print the same variable for the same program,
compiled by LLVM, all you get is a pointer:

GCC version:
(gdb) print vla
$1 = {5, 7, 9}
(gdb) print vlaref
$2 = (int (&)[3]) @0x7fffffffdc30: {5, 7, 9}
(gdb) print vlaref2
$3 = (const vlareftypedef) @0x7fffffffdc30: {5, 7, 9}

LLVM version:
(gdb) print vla
$1 = 0x7fffffffdc20
(gdb) print vlaref
$2 = (int (&)[]) @0x7fffffffdc20: 0x7fffffffdc20
(gdb) print vlaref2
$3 = (vlareftypedef) @0x7fffffffdc20: 0x7fffffffdc20

LLVM can't even tell gdb the length of the array, much less its contents!

In discussing this with Eric Christopher, he said:

A simple testcase is:

int foo(int a) {
  int vla[a];
  int sum = 0;

  for (int i = 0; i < a; ++i)
    vla[i] = i;
  for (int j = 0; j < a; ++j)
    sum += vla[j];

  return sum;
}

int main (void) {
  return foo(4);
}

What's happening is that we're not adding a DW_AT_upper_bound of type
DW_FORM_expr/exprloc with the upper bound of the array.

-- 
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/20160928/fc738cb4/attachment.html>


More information about the llvm-bugs mailing list