[lldb] Print newline between found types
authorArthur Eubanks <aeubanks@google.com>
Wed, 12 Oct 2022 23:18:44 +0000 (16:18 -0700)
committerArthur Eubanks <aeubanks@google.com>
Mon, 17 Oct 2022 21:24:21 +0000 (14:24 -0700)
Or else multiple entries end up overlapping on the same line.

Reviewed By: DavidSpickett

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

lldb/source/Commands/CommandObjectTarget.cpp
lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile [new file with mode: 0644]
lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py [new file with mode: 0644]
lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp [new file with mode: 0644]

index 59b7dfd74e85277ddfffd84d2b7cd814dc529919..61ac468ec90d86f2154d3e438bbb2fb4f1cc8a48 100644 (file)
@@ -1663,8 +1663,8 @@ static size_t LookupTypeInModule(Target *target,
         typedef_type_sp = typedefed_type_sp;
         typedefed_type_sp = typedef_type_sp->GetTypedefType();
       }
+      strm.EOL();
     }
-    strm.EOL();
   }
   return type_list.GetSize();
 }
diff --git a/lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile b/lldb/test/API/lang/cpp/type_lookup_duplicate/Makefile
new file mode 100644 (file)
index 0000000..3d0b98f
--- /dev/null
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
diff --git a/lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py b/lldb/test/API/lang/cpp/type_lookup_duplicate/TestCppTypeLookupDuplicate.py
new file mode 100644 (file)
index 0000000..8268ea1
--- /dev/null
@@ -0,0 +1,16 @@
+"""
+Test that we properly print multiple types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestTypeLookupDuplicate(TestBase):
+
+    def test_namespace_only(self):
+        self.build()
+        lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+
+        self.expect("image lookup -A -t Foo", DATA_TYPES_DISPLAYED_CORRECTLY, substrs=["2 matches found", "\nid =", "\nid ="])
diff --git a/lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp b/lldb/test/API/lang/cpp/type_lookup_duplicate/main.cpp
new file mode 100644 (file)
index 0000000..2518aaf
--- /dev/null
@@ -0,0 +1,13 @@
+namespace a {
+struct Foo {};
+} // namespace a
+
+namespace b {
+struct Foo {};
+} // namespace b
+
+int main() {
+  a::Foo a;
+  b::Foo b;
+  return 0; // Set breakpoint here
+}