DWARFv5: Handle location list for split dwarf.
authornitachra <Nitika.Achra@amd.com>
Tue, 7 Apr 2020 13:05:59 +0000 (18:35 +0530)
committerTom Tromey <tromey@adacore.com>
Tue, 7 Apr 2020 15:55:35 +0000 (09:55 -0600)
commit9fc3eaae69b2a60c5688d6bfe334829a3964b17f
treede14c8fb4bc1e180b8c47d523f4b8f4d6cd03cc8
parent4114425321d5c380bc8fb5344db8bc8664c170c6
DWARFv5: Handle location list for split dwarf.

GDB throws the error '<error reading variable: dwarf2_find_location_
expression: Corrupted DWARF expression.>' while printing the variable
value with executable file compiled with -gdwarf-5 and -gdwarf-split
flags. This is because DW_LLE_start* or DW_LLE_offset_pair with
DW_LLE_base_addressx are being emitted in DWARFv5 location list instead of
DW_LLE_GNU*. This patch fixes this error.

Tested by running the testsuite before and after the patch and there is no
increase in the number of test cases that fails. Tested with both -gdwarf-4
and -gdwarf-5 flags. Also tested -gslit-dwarf along with -gdwarf-4 as well as
-gdwarf-5 flags. Used clang version 10.0.0. This is the test case used-

void bar(int arr[], int l, int m, int r) {
    int i, j, k, n1= m - l + 1, n2= r - m, L[n1], R[n2];
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];
}

int main()
{
    int arr[] = {12, 11};
    bar(arr,0,1,2);
    return 0;
}

clang -gdwarf-5 -gsplit-dwarf test.c -o test.out

gdb test.out
gdb> start
gdb> step
gdb> step
gdb> step
gdb> step
gdb> p L[0]
dwarf2_find_location_expression: Corrupted DWARF expression.

gdb/ChangeLog:
2020-04-07  Nitika Achra  <Nitika.Achra@amd.com>

* dwarf2/loc.c (enum debug_loc_kind): Add a new kind DEBUG_LOC_OFFSET_PAIR.
(dwarf2_find_location_expression): Call the function decode_debug_loclists_
addresses if DWARF version is 5 or more. DW_LLE_start* or DW_LLE_offset_pair
with DW_LLE_base_addressx are being emitted in DWARFv5 instead of DW_LLE_GNU*.
Add applicable base address if the entry is DW_LLE_offset_pair from DWO.
(decode_debug_loclists_addresses): Return DEBUG_LOC_OFFSET_PAIR instead of
DEBUG_LOC_START_END in case of DW_LLE_offset_pair.
gdb/ChangeLog
gdb/dwarf2/loc.c
This page took 0.024768 seconds and 4 git commands to generate.