[lldb/DWARF/test] Freshen up debug_names tests

These tests used "clang -mllvm -accel-tables=Dwarf" as a way to
guarantee that clang will emit the debug_names table. Unfortunately,
a change it clang made that insufficient (-gpubnames is required now
too), which rendered these tests ineffective. Since lldb automatically
falls back to the manual index, the tests didn't fail and this change
went largely unnoticed.

This patch updates the tests to really use debug_names (-gdwarf-5
-gpubnames) is the combination that works now, and it adds additional
checks to ensure the section is actually emitted.

Fortunately, no regressions crept in while these tests were disabled.
This commit is contained in:
Pavel Labath 2020-01-15 12:17:35 +01:00
parent c24cf97960
commit 15a6df52ef
12 changed files with 70 additions and 35 deletions

View File

@ -62,4 +62,4 @@ class ForwardDeclarationTestCase(TestBase):
def test_debug_names(self):
"""Test that we are able to find complete types when using DWARF v5
accelerator tables"""
self.do_test(dict(CFLAGS_EXTRAS="-mllvm -accel-tables=Dwarf"))
self.do_test(dict(CFLAGS_EXTRAS="-gdwarf-5 -gpubnames"))

View File

@ -3,12 +3,15 @@
// REQUIRES: lld, zlib
// RUN: %clang -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s
// RUN: %clang -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames %s
// RUN: ld.lld %t.o -o %t --compress-debug-sections=zlib
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s
// NAMES: Name: .debug_names
// CHECK: Found 1 variables:
int foo;
// ONE-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = debug-names-compressed.cpp:[[@LINE-1]]
// CHECK-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = debug-names-compressed.cpp:[[@LINE-1]]
extern "C" void _start() {}

View File

@ -2,7 +2,7 @@
// REQUIRES: lld
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf -gpubnames
// RUN: %clang %s -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols %t | FileCheck %s

View File

@ -3,11 +3,14 @@
// REQUIRES: lld
// RUN: %clang %s -g -c -o %t-1.o --target=x86_64-pc-linux -DONE -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t-2.o --target=x86_64-pc-linux -DTWO -mllvm -accel-tables=Dwarf
// RUN: %clang %s -c -o %t-1.o --target=x86_64-pc-linux -DONE -gdwarf-5 -gpubnames
// RUN: llvm-readobj --sections %t-1.o | FileCheck %s --check-prefix NAMES
// RUN: %clang %s -c -o %t-2.o --target=x86_64-pc-linux -DTWO -gdwarf-5 -gno-pubnames
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: lldb-test symbols --find=variable --name=foo %t | FileCheck %s
// NAMES: Name: .debug_names
// CHECK: Found 2 variables:
#ifdef ONE
namespace one {

View File

@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gno-pubnames
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \
// RUN: FileCheck --check-prefix=BASE %s
@ -21,7 +21,7 @@
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN: FileCheck --check-prefix=METHOD %s
// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
// RUN: FileCheck --check-prefix=FULL-APPLE %s
// RUN: FileCheck --check-prefix=FULL-INDEXED %s
// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
// RUN: FileCheck --check-prefix=FULL-MANGLED %s
// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
@ -29,14 +29,15 @@
// RUN: lldb-test symbols --name=not_there --find=function %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames
// RUN: ld.lld %t.o -o %t
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \
// RUN: FileCheck --check-prefix=BASE %s
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN: FileCheck --check-prefix=METHOD %s
// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
// RUN: FileCheck --check-prefix=FULL %s
// RUN: FileCheck --check-prefix=FULL-INDEXED %s
// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
// RUN: FileCheck --check-prefix=FULL-MANGLED %s
// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
@ -44,6 +45,8 @@
// RUN: lldb-test symbols --name=not_there --find=function %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// NAMES: Name: .debug_names
// BASE: Found 4 functions:
// BASE-DAG: name = "foo()", mangled = "_Z3foov"
// BASE-DAG: name = "foo(int)", mangled = "_Z3fooi"
@ -55,14 +58,14 @@
// METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
// METHOD-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
// FULL-APPLE: Found 7 functions:
// FULL-APPLE-DAG: name = "foo()", mangled = "_Z3foov"
// FULL-APPLE-DAG: name = "foo(int)", mangled = "_Z3fooi"
// FULL-APPLE-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
// FULL-APPLE-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
// FULL-APPLE-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
// FULL-APPLE-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
// FULL-APPLE-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
// FULL-INDEXED: Found 7 functions:
// FULL-INDEXED-DAG: name = "foo()", mangled = "_Z3foov"
// FULL-INDEXED-DAG: name = "foo(int)", mangled = "_Z3fooi"
// FULL-INDEXED-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
// FULL-INDEXED-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
// FULL-INDEXED-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
// FULL-INDEXED-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
// FULL-INDEXED-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
// FULL: Found 0 functions:

View File

@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gno-pubnames
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=namespace %t | \
// RUN: FileCheck --check-prefix=FOO %s
@ -17,8 +17,9 @@
// RUN: lldb-test symbols --name=not_there --find=namespace %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames
// RUN: ld.lld %t.o -o %t
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --name=foo --find=namespace %t | \
// RUN: FileCheck --check-prefix=FOO %s
// RUN: lldb-test symbols --name=foo --find=namespace --context=context %t | \
@ -26,6 +27,8 @@
// RUN: lldb-test symbols --name=not_there --find=namespace %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// NAMES: Name: .debug_names
// FOO: Found namespace: foo
// CONTEXT: Found namespace: bar::foo

View File

@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gno-pubnames
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=type %t | \
// RUN: FileCheck --check-prefix=NAME %s
@ -17,8 +17,9 @@
// RUN: lldb-test symbols --name=not_there --find=type %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames
// RUN: ld.lld %t.o -o %t
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --name=foo --find=type %t | \
// RUN: FileCheck --check-prefix=NAME %s
// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
@ -26,6 +27,8 @@
// RUN: lldb-test symbols --name=not_there --find=type %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// NAMES: Name: .debug_names
// EMPTY: Found 0 types:
// NAME: Found 4 types:
// CONTEXT: Found 1 types:

View File

@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gno-pubnames
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \
// RUN: FileCheck --check-prefix=CONTEXT %s
@ -21,8 +21,9 @@
// RUN: lldb-test symbols --name=not_there --find=variable %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
//
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames
// RUN: ld.lld %t.o -o %t
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \
// RUN: FileCheck --check-prefix=CONTEXT %s
// RUN: lldb-test symbols --name=foo --find=variable %t | \
@ -32,6 +33,8 @@
// RUN: lldb-test symbols --name=not_there --find=variable %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// NAMES: Name: .debug_names
// EMPTY: Found 0 variables:
// NAME: Found 4 variables:
// CONTEXT: Found 1 variables:

View File

@ -1,16 +1,19 @@
// REQUIRES: lld
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gno-pubnames
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s
//
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames
// RUN: ld.lld %t.o -o %t
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --name=f.o --regex --find=function %t | FileCheck %s
// NAMES: Name: .debug_names
// CHECK: Found 3 functions:
// CHECK-DAG: name = "foo()", mangled = "_Z3foov"
// CHECK-DAG: name = "ffo()", mangled = "_Z3ffov"

View File

@ -1,6 +1,6 @@
// REQUIRES: lld
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
// RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gno-pubnames
// RUN: ld.lld %t.o -o %t
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN: FileCheck %s
@ -9,6 +9,14 @@
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN: FileCheck %s
// RUN: %clang %s -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames
// RUN: ld.lld %t.o -o %t
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
// RUN: FileCheck %s
// NAMES: Name: .debug_names
// CHECK-DAG: name = "A::foo()", mangled = "_ZN1A3fooEv"
// CHECK-DAG: name = "B::foo()", mangled = "_ZN1B3fooEv"
// CHECK-DAG: name = "C::foo()", mangled = "_ZN1C3fooEv"

View File

@ -1,14 +1,17 @@
// REQUIRES: lld
// RUN: %clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DONE | \
// RUN: llc -accel-tables=Dwarf -filetype=obj -split-dwarf-file=%t-1.dwo -o %t-1.o
// RUN: %clang %s -gdwarf-5 -gpubnames -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DONE | \
// RUN: llc -filetype=obj -split-dwarf-file=%t-1.dwo -o %t-1.o
// RUN: llvm-objcopy --split-dwo=%t-1.dwo %t-1.o
// RUN: %clang %s -g -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DTWO | \
// RUN: llc -accel-tables=Dwarf -filetype=obj -split-dwarf-file=%t-2.dwo -o %t-2.o
// RUN: %clang %s -gdwarf-5 -gpubnames -gsplit-dwarf -c -emit-llvm -o - --target=x86_64-pc-linux -DTWO | \
// RUN: llc -filetype=obj -split-dwarf-file=%t-2.dwo -o %t-2.o
// RUN: llvm-objcopy --split-dwo=%t-2.dwo %t-2.o
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --name=foo --find=variable %t | FileCheck %s
// NAMES: Name: .debug_names
// CHECK: Found 2 variables:
#ifdef ONE
namespace one {

View File

@ -1,7 +1,7 @@
// REQUIRES: lld
// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %s
// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable %S/Inputs/find-variable-file-2.cpp
// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -gno-pubnames %s
// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -gno-pubnames %S/Inputs/find-variable-file-2.cpp
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=ONE %s
@ -18,14 +18,17 @@
// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=TWO %s
// RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %s
// RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf %S/Inputs/find-variable-file-2.cpp
// RUN: %clang -c -o %t-1.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames %s
// RUN: %clang -c -o %t-2.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames %S/Inputs/find-variable-file-2.cpp
// RUN: ld.lld %t-1.o %t-2.o -o %t
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
// RUN: lldb-test symbols --file=find-variable-file.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=ONE %s
// RUN: lldb-test symbols --file=find-variable-file-2.cpp --find=variable %t | \
// RUN: FileCheck --check-prefix=TWO %s
// NAMES: Name: .debug_names
// ONE: Found 1 variables:
namespace one {
int foo;