lldb-test symbols: Add ability to do name-based lookup
Summary:
lldb-test already had the ability to dump all symbol information in a
module. This is interesting, but it can be too verbose, and it also does
not use the same APIs that lldb uses to query symbol information. The
last part is interesting to me now, because I am about to add DWARF v5
debug_names support, which needs to implement these APIs.
This patch adds a set of arguments to lldb-test, which modify it's
behavior from dumping all symbols to dumping only the requested
information:
- --find={function,namespace,type,variable} - search for the given
kind of objects.
- --name - the name to search for.
- --regex - whether to treat the "name" as a regular expression. This is
not available for all lookup types (we do not have the required APIs
for namespaces and types).
- --context - specifies the context, which can be used to restrict the
search. This argument takes a variable name (which must be defined and
be unique), and we then use the context that this variable is defined
in as the search context.
- --function-flags={auto,full,base,method,selector} - a set of flags to
further restrict the search for function symbols.
Together, these flags and their combinations cover the main SymbolFile
entry points which I will need to modify for the accelerator table
support, and so I plan to do most of the regression testing this way.
(I've also found this a useful tool for exploration of what the given
APIs are supposed to do.)
I add a couple of tests to demonstrate the usage of the usage of the
various options, and also an xfailed test which demonstrates a bug I
found while playing with this. The only requirement for these tests is
the presence of lld -- the should run on any platform which is able to
build lldb.
These tests use c++ code as input, but this isn't a requirement. It is also
possible to use IR, assembly or json to create the test module.
Reviewers: davide, zturner, asmith, JDevlieghere, clayborg, alexshap
Subscribers: mgorny, aprantl, lldb-commits
Differential Revision: https://reviews.llvm.org/D46318
llvm-svn: 331447
2018-05-03 18:57:16 +08:00
|
|
|
// REQUIRES: lld
|
|
|
|
|
2018-06-12 20:43:55 +08:00
|
|
|
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Disable
|
lldb-test symbols: Add ability to do name-based lookup
Summary:
lldb-test already had the ability to dump all symbol information in a
module. This is interesting, but it can be too verbose, and it also does
not use the same APIs that lldb uses to query symbol information. The
last part is interesting to me now, because I am about to add DWARF v5
debug_names support, which needs to implement these APIs.
This patch adds a set of arguments to lldb-test, which modify it's
behavior from dumping all symbols to dumping only the requested
information:
- --find={function,namespace,type,variable} - search for the given
kind of objects.
- --name - the name to search for.
- --regex - whether to treat the "name" as a regular expression. This is
not available for all lookup types (we do not have the required APIs
for namespaces and types).
- --context - specifies the context, which can be used to restrict the
search. This argument takes a variable name (which must be defined and
be unique), and we then use the context that this variable is defined
in as the search context.
- --function-flags={auto,full,base,method,selector} - a set of flags to
further restrict the search for function symbols.
Together, these flags and their combinations cover the main SymbolFile
entry points which I will need to modify for the accelerator table
support, and so I plan to do most of the regression testing this way.
(I've also found this a useful tool for exploration of what the given
APIs are supposed to do.)
I add a couple of tests to demonstrate the usage of the usage of the
various options, and also an xfailed test which demonstrates a bug I
found while playing with this. The only requirement for these tests is
the presence of lld -- the should run on any platform which is able to
build lldb.
These tests use c++ code as input, but this isn't a requirement. It is also
possible to use IR, assembly or json to create the test module.
Reviewers: davide, zturner, asmith, JDevlieghere, clayborg, alexshap
Subscribers: mgorny, aprantl, lldb-commits
Differential Revision: https://reviews.llvm.org/D46318
llvm-svn: 331447
2018-05-03 18:57:16 +08:00
|
|
|
// RUN: ld.lld %t.o -o %t
|
|
|
|
// 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 | \
|
|
|
|
// RUN: FileCheck --check-prefix=NAME %s
|
|
|
|
// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \
|
|
|
|
// RUN: FileCheck --check-prefix=REGEX %s
|
|
|
|
// RUN: lldb-test symbols --name=not_there --find=variable %t | \
|
|
|
|
// RUN: FileCheck --check-prefix=EMPTY %s
|
2018-05-21 17:27:16 +08:00
|
|
|
//
|
|
|
|
// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
|
|
|
|
// 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 | \
|
|
|
|
// RUN: FileCheck --check-prefix=NAME %s
|
|
|
|
// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \
|
|
|
|
// RUN: FileCheck --check-prefix=REGEX %s
|
|
|
|
// RUN: lldb-test symbols --name=not_there --find=variable %t | \
|
|
|
|
// RUN: FileCheck --check-prefix=EMPTY %s
|
2018-06-07 18:04:44 +08:00
|
|
|
//
|
2018-06-12 20:43:55 +08:00
|
|
|
// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux -mllvm -accel-tables=Dwarf
|
2018-06-07 18:04:44 +08:00
|
|
|
// RUN: ld.lld %t.o -o %t
|
|
|
|
// 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 | \
|
|
|
|
// RUN: FileCheck --check-prefix=NAME %s
|
|
|
|
// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \
|
|
|
|
// RUN: FileCheck --check-prefix=REGEX %s
|
|
|
|
// RUN: lldb-test symbols --name=not_there --find=variable %t | \
|
|
|
|
// RUN: FileCheck --check-prefix=EMPTY %s
|
lldb-test symbols: Add ability to do name-based lookup
Summary:
lldb-test already had the ability to dump all symbol information in a
module. This is interesting, but it can be too verbose, and it also does
not use the same APIs that lldb uses to query symbol information. The
last part is interesting to me now, because I am about to add DWARF v5
debug_names support, which needs to implement these APIs.
This patch adds a set of arguments to lldb-test, which modify it's
behavior from dumping all symbols to dumping only the requested
information:
- --find={function,namespace,type,variable} - search for the given
kind of objects.
- --name - the name to search for.
- --regex - whether to treat the "name" as a regular expression. This is
not available for all lookup types (we do not have the required APIs
for namespaces and types).
- --context - specifies the context, which can be used to restrict the
search. This argument takes a variable name (which must be defined and
be unique), and we then use the context that this variable is defined
in as the search context.
- --function-flags={auto,full,base,method,selector} - a set of flags to
further restrict the search for function symbols.
Together, these flags and their combinations cover the main SymbolFile
entry points which I will need to modify for the accelerator table
support, and so I plan to do most of the regression testing this way.
(I've also found this a useful tool for exploration of what the given
APIs are supposed to do.)
I add a couple of tests to demonstrate the usage of the usage of the
various options, and also an xfailed test which demonstrates a bug I
found while playing with this. The only requirement for these tests is
the presence of lld -- the should run on any platform which is able to
build lldb.
These tests use c++ code as input, but this isn't a requirement. It is also
possible to use IR, assembly or json to create the test module.
Reviewers: davide, zturner, asmith, JDevlieghere, clayborg, alexshap
Subscribers: mgorny, aprantl, lldb-commits
Differential Revision: https://reviews.llvm.org/D46318
llvm-svn: 331447
2018-05-03 18:57:16 +08:00
|
|
|
|
|
|
|
// EMPTY: Found 0 variables:
|
|
|
|
// NAME: Found 4 variables:
|
|
|
|
// CONTEXT: Found 1 variables:
|
|
|
|
// REGEX: Found 5 variables:
|
|
|
|
int foo;
|
|
|
|
// NAME-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]]
|
|
|
|
// REGEX-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]]
|
|
|
|
namespace bar {
|
|
|
|
int context;
|
|
|
|
long foo;
|
|
|
|
// NAME-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]]
|
|
|
|
// CONTEXT-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]]
|
|
|
|
// REGEX-DAG: name = "foo", type = {{.*}} (long int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-3]]
|
|
|
|
namespace baz {
|
|
|
|
static short foo;
|
|
|
|
// NAME-DAG: name = "foo", type = {{.*}} (short), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]]
|
|
|
|
// REGEX-DAG: name = "foo", type = {{.*}} (short), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sbar {
|
|
|
|
static int foo;
|
|
|
|
// NAME-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]]
|
|
|
|
// REGEX-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]]
|
|
|
|
};
|
|
|
|
int sbar::foo;
|
|
|
|
|
|
|
|
int foobar;
|
|
|
|
// REGEX-DAG: name = "foobar", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]]
|
|
|
|
|
|
|
|
int fbar() {
|
|
|
|
static int foo;
|
|
|
|
return foo + bar::baz::foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Foo;
|
|
|
|
|
|
|
|
struct ssbar {
|
|
|
|
int foo;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" void _start(sbar, ssbar) {}
|