summaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api/basename
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2025-09-10 15:25:31 -0700
committerGitHub <noreply@github.com>2025-09-10 15:25:31 -0700
commit1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch)
tree57f4b1f313c8cf74eed8819870f39c36ea263c68 /lldb/test/API/python_api/basename
parent898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff)
parentb8cefcb601ddaa18482555c4ff363c01a270c2fe (diff)
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'lldb/test/API/python_api/basename')
-rw-r--r--lldb/test/API/python_api/basename/Makefile3
-rw-r--r--lldb/test/API/python_api/basename/TestGetBaseName.py40
-rw-r--r--lldb/test/API/python_api/basename/main.cpp16
3 files changed, 59 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/basename/Makefile b/lldb/test/API/python_api/basename/Makefile
new file mode 100644
index 000000000000..99998b20bcb0
--- /dev/null
+++ b/lldb/test/API/python_api/basename/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/python_api/basename/TestGetBaseName.py b/lldb/test/API/python_api/basename/TestGetBaseName.py
new file mode 100644
index 000000000000..a3b752e67a35
--- /dev/null
+++ b/lldb/test/API/python_api/basename/TestGetBaseName.py
@@ -0,0 +1,40 @@
+"""
+Test SBFunction::GetBaseName() and SBSymbol::GetBaseName() APIs.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class GetBaseNameTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ TestBase.setUp(self)
+ self.main_source_file = lldb.SBFileSpec("main.cpp")
+
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="https://github.com/llvm/llvm-project/issues/156861",
+ )
+ def test(self):
+ """Test SBFunction.GetBaseName() and SBSymbol.GetBaseName()"""
+ self.build()
+ _, _, thread, _ = lldbutil.run_to_source_breakpoint(
+ self, "Set a breakpoint here", self.main_source_file
+ )
+
+ frame0 = thread.GetFrameAtIndex(0)
+
+ # Get both function and symbol
+ function = frame0.GetFunction()
+ symbol = frame0.GetSymbol()
+
+ # Test consistency between function and symbol basename
+ function_basename = function.GetBaseName()
+ symbol_basename = symbol.GetBaseName()
+
+ self.assertEqual(function_basename, "templateFunc")
+ self.assertEqual(symbol_basename, "templateFunc")
diff --git a/lldb/test/API/python_api/basename/main.cpp b/lldb/test/API/python_api/basename/main.cpp
new file mode 100644
index 000000000000..9b4140985cf4
--- /dev/null
+++ b/lldb/test/API/python_api/basename/main.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+
+namespace ns {
+template <typename T> class MyClass {
+public:
+ void templateFunc() {
+ std::cout << "In templateFunc" << std::endl; // Set a breakpoint here
+ }
+};
+} // namespace ns
+
+int main() {
+ ns::MyClass<int> obj;
+ obj.templateFunc();
+ return 0;
+}