-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug info generated for arrays is not what GDB expects (not as good as GCC's) #29901
Comments
assigned to @adrian-prantl |
Sander is working on this and has put up a set of patches https://reviews.llvm.org/D41698 |
This was fixed in https://reviews.llvm.org/rL323952 Thanks Sander! |
Reopened on behalf of Carlos Enciso, who made this comment on Phabricator Hi @sdesmalen! First of all my apologies for commenting after the issue has been closed, but I do not have an account to add a comment to the associated bugzilla. I have found what it seems to be an issue with the current implementation. For the given test case int main() {
} and while debugging with LLDB, the following error is generated: (lldb) n
(lldb) p vla_expr (lldb) p vla_expr[1] (lldb) Looking at the DWARF generated, there are 2 variables with the same name at the same scope DW_TAG_subprogram "main" I think there are 2 issues: The compiler generated variable 'vla_expr'
Thanks, |
I really can't reproduce this on ToT, but I hit a different issue. (lldb) frame var So, the 81 elements array is definitely off. |
And, FWIW, we already synthetize the variable as artificial and put two underscores in front of via_expr 0x00000051: TAG_variable [4] 0x0000005d: TAG_variable [5] |
Looking at the DWARF more closely, this is still a debug info generation bug. 0x0000007b: TAG_array_type [7] * 0x00000080: TAG_subrange_type [8] 0x00000089: NULL |
What does llvm-dwarfdump --debug-info=0x51 say? |
davide@Davidinos-Mac-Pro ~/w/l/b/bin> ./llvm-dwarfdump --debug-info=0x51 ./blah.dSYM .debug_info contents: 0x00000051: DW_TAG_variable |
It looks like LLDB may be misinterpreting the DIE reference in the DW_AT_count attribute for a constant. |
I completely agree, I tried GDB and this what I got (gdb) r Breakpoint 1, main () at blah.c:2 So, yes, we miss the support in lldb. |
This is the culprit. Process 62787 stopped
I wonder if this has ever worked :) |
The DWARF standard says (thanks to Adrian for pointing out!): The subrange entry may have the attributes DW_AT_lower_bound and DW_AT_upper_bound to specify, respectively, the lower and upper bound values of the subrange. The DW_AT_upper_bound attribute may be replaced by a DW_AT_count attribute, whose value describes the number of elements in the subrange rather than the value of the last element. The value of each of these attributes is determined as described in Section 2.19 on page 55. 2.19 Static and Dynamic Values of Attributes
lldb currently handles only the first case correctly. |
dwarfdump -F makes this more clear (the fact that this is a reference): 0x0000007b: DW_TAG_array_type 0x00000080: DW_TAG_subrange_type |
Adrian, you fixed this one, didn't you? |
I investigated some debuginfo problem using VLA for an out of tree target and I noticed:
|
mentioned in issue llvm/llvm-bugzilla-archive#36322 |
Extended Description
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.
The text was updated successfully, but these errors were encountered: