Files
clang-p2996/lldb/lit/SymbolFile/DWARF/find-basic-function.cpp
Pavel Labath bf5a3f8393 Add some apple-tables lookup tests
Summary:
Now that we are able to parse MachO files everywhere, we can write some
cross-platform tests for handling of apple accelerator tables. This
reruns the same lookup tests we have for manual indexes on MachO files
which will use the accelerator tables instead. This makes sure we return
the same results regardless of the method we used to access the debug
info.

The tests confirm we return the same results for looking up types,
namespaces and variables, but have found an inconsistency in the
treatment of function lookup. In the function case we mis-classify the
method "foo" declared in the local struct sbar (inside function ffbar).
We classify it as a function whereas it really is a method. Preliminary
analysis suggests this is because
DWARFASTParserClang::GetClangDeclContextForDIE returns null when given
the local "struct sbar" DIE. This causes us to get the wrong
CompilerDeclContext when we ask for the context of the inner foo, which
means CompilerDeclContext::ISStructUnionOrClass returns false.

Until this is fixed, I do not include the darwin versions of the "base"
and "method" function lookup tests.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, ilya-biryukov, ioeric, lldb-commits

Differential Revision: https://reviews.llvm.org/D47064

llvm-svn: 332831
2018-05-21 09:27:16 +00:00

88 lines
3.0 KiB
C++

// REQUIRES: lld
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux
// 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
// 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: 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 | \
// RUN: FileCheck --check-prefix=CONTEXT %s
// RUN: lldb-test symbols --name=not_there --find=function %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
//
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
// RUN: FileCheck --check-prefix=FULL %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 | \
// RUN: FileCheck --check-prefix=CONTEXT %s
// RUN: lldb-test symbols --name=not_there --find=function %t | \
// RUN: FileCheck --check-prefix=EMPTY %s
// BASE: Found 4 functions:
// BASE-DAG: name = "foo()", mangled = "_Z3foov"
// BASE-DAG: name = "foo(int)", mangled = "_Z3fooi"
// BASE-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
// BASE-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
// METHOD: Found 3 functions:
// METHOD-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
// METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
// METHOD-DAG: name = "ffbar()::sbar::foo()", mangled = "_ZZ5ffbarvEN4sbar3fooEv"
// FULL: Found 7 functions:
// FULL-DAG: name = "foo()", mangled = "_Z3foov"
// FULL-DAG: name = "foo(int)", mangled = "_Z3fooi"
// FULL-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
// FULL-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
// FULL-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
// FULL-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
// FULL-DAG: name = "ffbar()::sbar::foo()", mangled = "_ZZ5ffbarvEN4sbar3fooEv"
// FULL-MANGLED: Found 1 functions:
// FULL-DAG: name = "foo(int)", mangled = "_Z3fooi"
// CONTEXT: Found 1 functions:
// CONTEXT-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
// EMPTY: Found 0 functions:
void foo() {}
void foo(int) {}
namespace bar {
int context;
void foo() {}
namespace baz {
void foo() {}
} // namespace baz
} // namespace bar
struct foo {};
void fbar(struct foo) {}
void Foo() {}
struct sbar {
void foo();
static void foo(int);
};
void sbar::foo() {}
void sbar::foo(int) {}
void ffbar() {
struct sbar {
void foo() {}
};
sbar a;
a.foo();
}
extern "C" void _start() {}