<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Debug info generated for arrays is not what GDB expects (not as good as GCC's)"
   href="https://llvm.org/bugs/show_bug.cgi?id=30553">30553</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Debug info generated for arrays is not what GDB expects (not as good as GCC's)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>cmtice@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>