[Bug 26010] New: LLDB fails to display content of a variable size array

Bug ID 26010
Summary LLDB fails to display content of a variable size array
Product lldb
Version unspecified
Hardware PC
OS Linux
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter tberghammer@google.com
CC llvm-bugs@lists.llvm.org
Classification Unclassified

Compile the following code snippet with g++ (tested with 4.8.2 on Linux
x86_64):

int main() {
    for (int i = 0; i < 10; ++i) {
        int x[i + 1];
        x[0] = sizeof(x);
        x[0] *= 2; // Break here
    }
}

Break at the marked line and display the variable x with executing the "frame
variable x" command.

Expected behavior is to display x as an array with the number of displayed
elements matching with the actual element count of the array in the current
implementation.

Actual behavior is that the array is always displayed with 4 element regardless
of the current iteration.

In the same scenario gdb displays the array with the correct number of element.

If the inferior is compiled with clang then gdb fails as well because incorrect
debug info is generated ([http://llvm.org/pr25934](http://llvm.org/pr25934))

The problem is that for variable sized arrays g++ correctly generates a
DW_TAG_subrange_type children with a DW_AT_upper_bound attribute containing a
dwarf expression pointing to the location where the current size of the array
is stored but LLDB don't handle the case where DW_AT_upper_bound is a dwarf
expression.