This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] - Implement the support for the .debug_loclists section.
ClosedPublic

Authored by grimar on Oct 19 2018, 7:31 AM.

Details

Summary

This implements the support for .debug_loclists section, which is
DWARF 5 version of .debug_loc.

Currently, clang is able to emit it with the use of D53365.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Oct 19 2018, 7:31 AM

Since .debug_loclists contains locations descriptions for objects
that can change location during lifetime, I do not see a way to
write the test without relying on a compiler that has support for
DWARF5. We should compile and run executable to test that location
was calculated properly I believe. Other our tests for DWARF5 sections
recently implemented used YAML and never run any executables.
So, the test case is not included.

At the same time I was able to test it with the following code and invocation:
(trunk clang + D53365 applied):

~/LLVM/build/bin/clang -gdwarf-5 test.cc  -o test_v5-fuse-ld=lld -fno-rtti
struct A { 
  int x = 0; 
  virtual void foo(); 
};

void baz(struct A a) { 
 a.foo();
}

void A::foo() { int x = 0; ++x; }

int main() {
  A objA;
  objA.x = 3;
  baz(objA);
  return 0;
}

After executing the following commands, the location of a is properly evaluated:

(lldb) target create "test_v5"
Current executable set to 'test_v5' (x86_64).
(lldb) b baz
Breakpoint 1: where = test_v5`baz(A) + 4 at test.cc:9:6, address = 0x00000000002010e4
(lldb) run
Process 115974 launched: '/home/umb/tests_2018/110_lldbloclists/test_v5' (x86_64)
Process 115974 stopped
* thread #1, name = 'test_v5', stop reason = breakpoint 1.1
    frame #0: 0x00000000002010e4 test_v5`baz(a=(x = 3)) at test.cc:9:6
   6    };
   7   
   8    void baz(struct A a) {
-> 9       a.foo();
   10   }

Without this patch output will be:

...
frame #0: 0x00000000002010e4 test_v5`baz(a=<unavailable>) at test.cc:9:6
...

Just fix the assert to use lldbassert so we don't crash as mentioned in the inline comment and this is good to go.

source/Expression/DWARFExpression.cpp
3070 ↗(On Diff #170198)

use lldbassert so this doesn't crash a release debugger.

grimar updated this revision to Diff 170468.Oct 22 2018, 12:04 PM
  • Used lldbassert as suggested.
clayborg accepted this revision.Oct 22 2018, 12:49 PM
This revision is now accepted and ready to land.Oct 22 2018, 12:49 PM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.