1// Test that we can use .debug_names to lookup a type that is only referenced
2// from within a type unit. In the code below the type named "stype" is only
3// referenced within the type unit itself and when we enable .debug_names, we
4// expect the have an entry for this and to be able to find this type when
5// we do a lookup.
6
7// REQUIRES: lld
8
9// RUN: %clang %s -target x86_64-pc-linux -gdwarf-5 -fdebug-types-section \
10// RUN: -gpubnames -fno-limit-debug-info -c -o %t.o
11// RUN: ld.lld %t.o -o %t
12// RUN: %lldb %t -o "type lookup stype" -b | FileCheck %s --check-prefix=BASE
13// RUN: %lldb %t -o "type lookup bar::stype" -b | FileCheck %s --check-prefix=PART
14// RUN: %lldb %t -o "type lookup foo::bar::stype" -b | FileCheck %s --check-prefix=FULL
15
16// BASE: (lldb) type lookup stype
17// BASE-NEXT: int
18
19// PART: (lldb) type lookup bar::stype
20// PART-NEXT: int
21
22// FULL: (lldb) type lookup foo::bar::stype
23// FULL-NEXT: int
24
25namespace foo {
26class bar {
27public:
28 typedef unsigned utype;
29 // This type is only referenced from within the type unit and we need to
30 // make sure we can find it with the new type unit support in .debug_names.
31 typedef int stype;
32
33private:
34 utype m_unsigned;
35
36public:
37 bar(utype u) : m_unsigned(u) {}
38
39 utype get() const { return m_unsigned; }
40 void set(utype u) { m_unsigned = u; }
41 stype gets() const { return (stype)m_unsigned; }
42};
43} // namespace foo
44
45int main() {
46 foo::bar b(12);
47 return 0;
48}
49

source code of lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-debug-names.cpp