In the case of static local variables, the associated DW_TAG_variable
child should be added in subprogram's DW_AT_abstract_origin in case
one exists.
To highlight the difference, compile and debug the following example with:
$ clang -g test.c -o a.out $ gdb -ex "break g" -ex "run" -ex "print x" --args a.out int __attribute__((always_inline)) g(int n) { static int x[10]; int y = 1; return x[n] + y; } int f(int n) { return g(n); } int main(int argc, char *argv[]) { return f(argc); }
If the DIE for x is inserted as a child of the the DIE (with the tag DW_TAG_subprogram) associated to g,
then, when iterating over the inlined instructions of g we won't be
able to refer to x.
Annoyingly, this patch changes the order in which the dwarf info is
generated (which breaks way too many tests).