diff options
author | Greg Clayton <gclayton@apple.com> | 2017-02-13 21:34:58 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2017-02-13 21:34:58 +0000 |
commit | 5d0c114630f3f8206a69ba7b5e649570dc8196bc (patch) | |
tree | 12dbeb846919dd3d06f792d59f673539aff2a150 /lldb/packages/Python/lldbsuite/test | |
parent | b74485dfaaf42e58e2b240bcb040c5f93910338e (diff) | |
download | bcm5719-llvm-5d0c114630f3f8206a69ba7b5e649570dc8196bc.tar.gz bcm5719-llvm-5d0c114630f3f8206a69ba7b5e649570dc8196bc.zip |
FindFunctions now works again with mangled names.
<rdar://problem/28147057>
llvm-svn: 294990
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
3 files changed, 124 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile b/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile new file mode 100644 index 00000000000..8a7102e347a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py b/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py new file mode 100644 index 00000000000..024b157ab0d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py @@ -0,0 +1,65 @@ +""" +Test SBTarget APIs. +""" + +from __future__ import print_function + + +import unittest2 +import os +import time +import re +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestNameLookup(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @add_test_categories(['pyapi']) + def test_target(self): + """Exercise SBTarget.FindFunctions() with various name masks. + + A previous regression caused mangled names to not be able to be looked up. + This test verifies that using a mangled name with eFunctionNameTypeFull works + and that using a function basename with eFunctionNameTypeFull works for all + C++ functions that are at the global namespace level.""" + self.build(); + exe = os.path.join(os.getcwd(), 'a.out') + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + exe_module = target.FindModule(target.GetExecutable()) + + c_name_to_symbol = {} + cpp_name_to_symbol = {} + mangled_to_symbol = {} + num_symbols = exe_module.GetNumSymbols(); + for i in range(num_symbols): + symbol = exe_module.GetSymbolAtIndex(i); + name = symbol.GetName() + if 'unique_function_name' in name: + mangled = symbol.GetMangledName() + if mangled: + mangled_to_symbol[mangled] = symbol + if name: + cpp_name_to_symbol[name] = symbol + elif name: + c_name_to_symbol[name] = symbol + + # Make sure each mangled name turns up exactly one match when looking up + # functions by full name and using the mangled name as the name in the + # lookup + for mangled in mangled_to_symbol.keys(): + symbol_contexts = target.FindFunctions(mangled, lldb.eFunctionNameTypeFull) + self.assertTrue(symbol_contexts.GetSize() == 1) + for symbol_context in symbol_contexts: + self.assertTrue(symbol_context.GetFunction().IsValid()) + self.assertTrue(symbol_context.GetSymbol().IsValid()) + +
\ No newline at end of file diff --git a/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp b/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp new file mode 100644 index 00000000000..79aa2d0452f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp @@ -0,0 +1,54 @@ +#include <stdio.h> + +extern "C" int unique_function_name(int i) +{ + return puts(__PRETTY_FUNCTION__); +} + +int unique_function_name() +{ + return puts(__PRETTY_FUNCTION__); +} + +int unique_function_name(float f) +{ + return puts(__PRETTY_FUNCTION__); +} + +namespace e +{ + int unique_function_name() + { + return puts(__PRETTY_FUNCTION__); + } + + namespace g + { + int unique_function_name() + { + return puts(__PRETTY_FUNCTION__); + } + } +} + +class g +{ +public: + int unique_function_name() + { + return puts(__PRETTY_FUNCTION__); + } + + int unique_function_name(int i) + { + return puts(__PRETTY_FUNCTION__); + } +}; + +int main (int argc, char const *argv[]) +{ + g g; + g.unique_function_name(); + g.unique_function_name(argc); + return 0; +}
\ No newline at end of file |