summaryrefslogtreecommitdiff
path: root/lldb/unittests
diff options
context:
space:
mode:
authorAleksandr Urakov <aleksandr.urakov@jetbrains.com>2018-11-30 06:56:37 +0000
committerAleksandr Urakov <aleksandr.urakov@jetbrains.com>2018-11-30 06:56:37 +0000
commite72cb7d00294605d25256abdfa47308888f14946 (patch)
tree99ff6598ef6306e8d8b65f83e5953ed49e3b6a59 /lldb/unittests
parentbeb9d995b35026cc23ed3d1ec6928858090e97ed (diff)
[Symbol] Search symbols with name and type in a symbol file
Summary: This patch adds possibility of searching a public symbol with name and type in a symbol file, not only in a symtab. It is helpful when working with PE, because PE's symtabs contain only imported / exported symbols only. Such a search is required for e.g. evaluation of an expression that calls some function of the debuggee. Reviewers: zturner, asmith, labath, clayborg, espindola Reviewed By: clayborg Subscribers: davide, emaste, arichardson, aleksandr.urakov, jingham, lldb-commits, stella.stamenova Tags: #lldb Differential Revision: https://reviews.llvm.org/D53368
Diffstat (limited to 'lldb/unittests')
-rw-r--r--lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 5ad4cff5b2e..32c7002a15c 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -620,3 +620,20 @@ TEST_F(SymbolFilePDBTests, TestNullName) {
EXPECT_EQ(0u, num_results);
EXPECT_EQ(0u, results.GetSize());
}
+
+TEST_F(SymbolFilePDBTests, TestFindSymbolsWithNameAndType) {
+ FileSpec fspec(m_pdb_test_exe.c_str());
+ ArchSpec aspec("i686-pc-windows");
+ lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);
+
+ SymbolContextList sc_list;
+ EXPECT_EQ(1u,
+ module->FindSymbolsWithNameAndType(ConstString("?foo@@YAHH@Z"),
+ lldb::eSymbolTypeAny, sc_list));
+ EXPECT_EQ(1u, sc_list.GetSize());
+
+ SymbolContext sc;
+ EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+ EXPECT_STREQ("int foo(int)",
+ sc.GetFunctionName(Mangled::ePreferDemangled).AsCString());
+}