[Lldb-commits] [lldb] e2ede17 - [lldb] Update field offset/sizes when encountering artificial members such as vtable pointers

2021-10-30 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-30T13:22:21+02:00
New Revision: e2ede1715d4141279bb76d8850e0494b85d1eee8

URL: 
https://github.com/llvm/llvm-project/commit/e2ede1715d4141279bb76d8850e0494b85d1eee8
DIFF: 
https://github.com/llvm/llvm-project/commit/e2ede1715d4141279bb76d8850e0494b85d1eee8.diff

LOG: [lldb] Update field offset/sizes when encountering artificial members such 
as vtable pointers

`DWARFASTParserClang::ParseSingleMember` turns DWARF DIEs that describe
struct/class members into their respective Clang representation (e.g.,
clang::FieldDecl). It also updates a record of where the last field
started/ended so that we can speculatively fill any holes between a field and a
bitfield with unnamed bitfield padding.

Right now we are completely ignoring 'artificial' members when parsing the DWARF
of a struct/class. The only artificial member that seems to be emitted in
practice for C/C++ seems to be the vtable pointer.

By completely skipping both the Clang AST node creation and the updating of the
last-field record, we essentially leave a hole in our layout with the size of
our artificial member. If the next member is a bitfield we then speculatively
fill the hole with an unnamed bitfield. During CodeGen Clang inserts an
artificial vtable pointer into the layout again which now occupies the same
offset as the unnamed bitfield. This later brings down Clang's
`CGRecordLowering::insertPadding` when it checks that none of the fields of the
generated record layout overlap.

Note that this is not a Clang bug. We explicitly set the offset of our fields in
LLDB and overwrite whatever Clang makes up.

Reviewed By: labath

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
lldb/test/API/lang/cpp/bitfields/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 8affb05d56a26..b6b99d2e9bcf6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2675,11 +2675,6 @@ void DWARFASTParserClang::ParseSingleMember(
 
   // FIXME: Remove the workarounds below and make this const.
   MemberAttributes attrs(die, parent_die, module_sp);
-  // Skip artificial members such as vtable pointers.
-  // FIXME: This check should verify that this is indeed an artificial member
-  // we are supposed to ignore.
-  if (attrs.is_artificial)
-return;
 
   const bool class_is_objc_object_or_interface =
   TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type);
@@ -2845,6 +2840,17 @@ void DWARFASTParserClang::ParseSingleMember(
 last_field_info.SetIsBitfield(false);
   }
 
+  // Don't turn artificial members such as vtable pointers into real FieldDecls
+  // in our AST. Clang will re-create those articial members and they would
+  // otherwise just overlap in the layout with the FieldDecls we add here.
+  // This needs to be done after updating FieldInfo which keeps track of where
+  // field start/end so we don't later try to fill the the space of this
+  // artificial member with (unnamed bitfield) padding.
+  // FIXME: This check should verify that this is indeed an artificial member
+  // we are supposed to ignore.
+  if (attrs.is_artificial)
+return;
+
   if (!member_clang_type.IsCompleteType())
 member_clang_type.GetCompleteType();
 

diff  --git a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py 
b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
index 4cdaf32ca0659..956ae275b337e 100644
--- a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -145,8 +145,6 @@ def test_bitfields(self):
 self.expect_expr("base_with_vtable", 
result_children=base_with_vtable_children)
 self.expect_var_path("base_with_vtable", 
children=base_with_vtable_children)
 
-# FIXME: These all crash due the vtable ptr.
-@skipIf
 @no_debug_info_test
 def test_bitfield_behind_vtable_ptr(self):
 self.build()
@@ -164,7 +162,7 @@ def test_bitfield_behind_vtable_ptr(self):
 
 # Test a class with a vtable ptr and unnamed bitfield directly after.
 with_vtable_and_unnamed_children = [
-ValueCheck(name="", type="unsigned int:4", value="0"),
+ValueCheck(name="", type="int:4", value="0"),
 ValueCheck(name="b", type="unsigned int:4", value="0"),
 ValueCheck(name="c", type="unsigned int:4", value="5")
 ]

diff  --git a/lldb/test/API/lang/cpp/bitfields/main.cpp 
b/lldb/test/API/lang/cpp/bitfields/main.cpp
index e40f1648ac834..eb9db7271aae6 100644
--- a/lldb/test/API/lang/cpp/bitfields/main.cpp
+++ b/lldb/test/API/lang/cpp/bitfiel

[Lldb-commits] [PATCH] D112697: [lldb] Update field offset/sizes when encountering artificial members such as vtable pointers

2021-10-30 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe2ede1715d41: [lldb] Update field offset/sizes when 
encountering artificial members such as… (authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112697/new/

https://reviews.llvm.org/D112697

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
  lldb/test/API/lang/cpp/bitfields/main.cpp


Index: lldb/test/API/lang/cpp/bitfields/main.cpp
===
--- lldb/test/API/lang/cpp/bitfields/main.cpp
+++ lldb/test/API/lang/cpp/bitfields/main.cpp
@@ -97,7 +97,7 @@
 
 struct WithVTableAndUnnamed {
   virtual ~WithVTableAndUnnamed() {}
-  unsigned a : 4;
+  unsigned : 4;
   unsigned b : 4;
   unsigned c : 4;
 };
@@ -146,7 +146,6 @@
   with_vtable.b = 0;
   with_vtable.c = 5;
 
-  with_vtable_and_unnamed.a = 5;
   with_vtable_and_unnamed.b = 0;
   with_vtable_and_unnamed.c = 5;
 
Index: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
===
--- lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -145,8 +145,6 @@
 self.expect_expr("base_with_vtable", 
result_children=base_with_vtable_children)
 self.expect_var_path("base_with_vtable", 
children=base_with_vtable_children)
 
-# FIXME: These all crash due the vtable ptr.
-@skipIf
 @no_debug_info_test
 def test_bitfield_behind_vtable_ptr(self):
 self.build()
@@ -164,7 +162,7 @@
 
 # Test a class with a vtable ptr and unnamed bitfield directly after.
 with_vtable_and_unnamed_children = [
-ValueCheck(name="", type="unsigned int:4", value="0"),
+ValueCheck(name="", type="int:4", value="0"),
 ValueCheck(name="b", type="unsigned int:4", value="0"),
 ValueCheck(name="c", type="unsigned int:4", value="5")
 ]
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2675,11 +2675,6 @@
 
   // FIXME: Remove the workarounds below and make this const.
   MemberAttributes attrs(die, parent_die, module_sp);
-  // Skip artificial members such as vtable pointers.
-  // FIXME: This check should verify that this is indeed an artificial member
-  // we are supposed to ignore.
-  if (attrs.is_artificial)
-return;
 
   const bool class_is_objc_object_or_interface =
   TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type);
@@ -2845,6 +2840,17 @@
 last_field_info.SetIsBitfield(false);
   }
 
+  // Don't turn artificial members such as vtable pointers into real FieldDecls
+  // in our AST. Clang will re-create those articial members and they would
+  // otherwise just overlap in the layout with the FieldDecls we add here.
+  // This needs to be done after updating FieldInfo which keeps track of where
+  // field start/end so we don't later try to fill the the space of this
+  // artificial member with (unnamed bitfield) padding.
+  // FIXME: This check should verify that this is indeed an artificial member
+  // we are supposed to ignore.
+  if (attrs.is_artificial)
+return;
+
   if (!member_clang_type.IsCompleteType())
 member_clang_type.GetCompleteType();
 


Index: lldb/test/API/lang/cpp/bitfields/main.cpp
===
--- lldb/test/API/lang/cpp/bitfields/main.cpp
+++ lldb/test/API/lang/cpp/bitfields/main.cpp
@@ -97,7 +97,7 @@
 
 struct WithVTableAndUnnamed {
   virtual ~WithVTableAndUnnamed() {}
-  unsigned a : 4;
+  unsigned : 4;
   unsigned b : 4;
   unsigned c : 4;
 };
@@ -146,7 +146,6 @@
   with_vtable.b = 0;
   with_vtable.c = 5;
 
-  with_vtable_and_unnamed.a = 5;
   with_vtable_and_unnamed.b = 0;
   with_vtable_and_unnamed.c = 5;
 
Index: lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
===
--- lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -145,8 +145,6 @@
 self.expect_expr("base_with_vtable", result_children=base_with_vtable_children)
 self.expect_var_path("base_with_vtable", children=base_with_vtable_children)
 
-# FIXME: These all crash due the vtable ptr.
-@skipIf
 @no_debug_info_test
 def test_bitfield_behind_vtable_ptr(self):
 self.build()
@@ -164,7 +162,7 @@
 
 # Test a class with a vtable ptr and unnamed bitfield directly after.
 with_vtable_and_unnamed_children = [
-ValueCheck(name="", type="unsigned int:4", value="0"),
+ 

[Lldb-commits] [lldb] 85bcc1e - [lldb] Make SBType::IsTypeComplete more consistent by forcing the loading of definitions

2021-10-30 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-30T13:28:27+02:00
New Revision: 85bcc1eb2f56af00123a8d6b99e9ad677613767c

URL: 
https://github.com/llvm/llvm-project/commit/85bcc1eb2f56af00123a8d6b99e9ad677613767c
DIFF: 
https://github.com/llvm/llvm-project/commit/85bcc1eb2f56af00123a8d6b99e9ad677613767c.diff

LOG: [lldb] Make SBType::IsTypeComplete more consistent by forcing the loading 
of definitions

Currently calling SBType::IsTypeComplete returns true for record types if and
only if the underlying record in our internal Clang AST has a definition.

The function however doesn't actually force the loading of any external
definition from debug info, so it currently can return false even if the type is
actually defined in a program's debug info but LLDB hasn't lazily created the
definition yet.

This patch changes the behaviour to always load the definition first so that
IsTypeComplete now consistently returns true if there is a definition in the
module/target.

The motivation for this patch is twofold:

* The API is now arguably more useful for the user which don't know or care
about the internal lazy loading mechanism of LLDB.

* With D101950 there is no longer a good way to ask a Decl for a definition
without automatically pulling in a definition from the ExternalASTSource. The
current behaviour doesn't seem useful enough to justify the necessary
workarounds to preserve it for a time after D101950.

Note that there was a test that used this API to test lazy loading of debug info
but that has been replaced with TestLazyLoading by now (which just dumps the
internal Clang AST state instead).

Reviewed By: aprantl

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

Added: 
lldb/test/API/lang/cpp/complete-type-check/Makefile
lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
lldb/test/API/lang/cpp/complete-type-check/main.cpp
lldb/test/API/lang/objc/complete-type-check/Makefile
lldb/test/API/lang/objc/complete-type-check/TestObjCIsTypeComplete.py
lldb/test/API/lang/objc/complete-type-check/main.m

Modified: 
lldb/bindings/interface/SBType.i
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 
lldb/test/API/functionalities/type_completion/Makefile
lldb/test/API/functionalities/type_completion/TestTypeCompletion.py
lldb/test/API/functionalities/type_completion/main.cpp



diff  --git a/lldb/bindings/interface/SBType.i 
b/lldb/bindings/interface/SBType.i
index 500bc99ca8cd4..d6e8db3ab4287 100644
--- a/lldb/bindings/interface/SBType.i
+++ b/lldb/bindings/interface/SBType.i
@@ -837,6 +837,21 @@ public:
 lldb::SBTypeMemberFunction
 GetMemberFunctionAtIndex (uint32_t idx);
 
+%feature("docstring",
+"Returns true if the type is completely defined.
+
+Language-specific behaviour:
+
+* C: Returns false for struct types that were only forward declared in the
+  type's `SBTarget`/`SBModule`. Otherwise returns true.
+* C++: Returns false for template/non-template struct/class types and
+  scoped enums that were only forward declared inside the type's
+  `SBTarget`/`SBModule`. Otherwise returns true.
+* Objective-C: Follows the same behavior as C for struct types. Objective-C
+  classes are considered complete unless they were only forward declared 
via
+  ``@class ClassName`` in the type's `SBTarget`/`SBModule`. Otherwise
+  returns true.
+") IsTypeComplete;
 bool
 IsTypeComplete ();
 

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index aa0a8086cb28c..9beccf30f94be 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2940,7 +2940,12 @@ bool 
TypeSystemClang::IsCharType(lldb::opaque_compiler_type_t type) {
 }
 
 bool TypeSystemClang::IsCompleteType(lldb::opaque_compiler_type_t type) {
-  const bool allow_completion = false;
+  // If the type hasn't been lazily completed yet, complete it now so that we
+  // can give the caller an accurate answer whether the type actually has a
+  // definition. Without completing the type now we would just tell the user
+  // the current (internal) completeness state of the type and most users don't
+  // care (or even know) about this behavior.
+  const bool allow_completion = true;
   return GetCompleteQualType(&getASTContext(), GetQualType(type),
  allow_completion);
 }

diff  --git 
a/lldb/test/API/functionalities/type_completion/TestTypeCompletion.py 
b/lldb/test/API/functionalities/type_completion/TestTypeCompletion.py
deleted file mode 100644
index fb0b1096f4d4b..0
--- a/lldb/test/API/functionalities/type_completion/TestTypeCompletion.py
+++ /dev/null
@@ -1,155 +0,0 @@
-"""
-Check that types only get completed when necessary.
-"""
-
-
-
-import lldb
-from ll

[Lldb-commits] [PATCH] D112615: [lldb] Make SBType::IsTypeComplete more consistent by forcing the loading of definitions

2021-10-30 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG85bcc1eb2f56: [lldb] Make SBType::IsTypeComplete more 
consistent by forcing the loading of… (authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112615/new/

https://reviews.llvm.org/D112615

Files:
  lldb/bindings/interface/SBType.i
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/functionalities/type_completion/Makefile
  lldb/test/API/functionalities/type_completion/TestTypeCompletion.py
  lldb/test/API/functionalities/type_completion/main.cpp
  lldb/test/API/lang/cpp/complete-type-check/Makefile
  lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py
  lldb/test/API/lang/cpp/complete-type-check/main.cpp
  lldb/test/API/lang/objc/complete-type-check/Makefile
  lldb/test/API/lang/objc/complete-type-check/TestObjCIsTypeComplete.py
  lldb/test/API/lang/objc/complete-type-check/main.m

Index: lldb/test/API/lang/objc/complete-type-check/main.m
===
--- /dev/null
+++ lldb/test/API/lang/objc/complete-type-check/main.m
@@ -0,0 +1,19 @@
+#include 
+
+@class IncompleteClass;
+
+@interface CompleteClass : NSObject
+@end
+
+@interface CompleteClassWithImpl : NSObject
+@end
+@implementation CompleteClassWithImpl
+@end
+
+IncompleteClass *incomplete = 0;
+CompleteClass *complete = 0;
+CompleteClassWithImpl *complete_impl = 0;
+
+int main() {
+  return 0; // break here
+}
Index: lldb/test/API/lang/objc/complete-type-check/TestObjCIsTypeComplete.py
===
--- /dev/null
+++ lldb/test/API/lang/objc/complete-type-check/TestObjCIsTypeComplete.py
@@ -0,0 +1,39 @@
+""" Tests SBType.IsTypeComplete on Objective-C types. """
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@no_debug_info_test
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
+
+# A class that is only forward declared is not complete.
+incomplete = self.expect_expr("incomplete", result_type="IncompleteClass *")
+self.assertTrue(incomplete.IsValid())
+incomplete_class = incomplete.GetType().GetPointeeType()
+self.assertTrue(incomplete_class.IsValid())
+self.assertFalse(incomplete_class.IsTypeComplete())
+
+# A class that has its interface fully declared is complete.
+complete = self.expect_expr("complete", result_type="CompleteClass *")
+self.assertTrue(complete.IsValid())
+complete_class = complete.GetType().GetPointeeType()
+self.assertTrue(complete_class.IsValid())
+self.assertTrue(complete_class.IsTypeComplete())
+
+# A class that has its interface fully declared and an implementation
+# is also complete.
+complete_with_impl = self.expect_expr("complete_impl",
+result_type="CompleteClassWithImpl *")
+self.assertTrue(complete_with_impl.IsValid())
+complete_class_with_impl = complete_with_impl.GetType().GetPointeeType()
+self.assertTrue(complete_class_with_impl.IsValid())
+self.assertTrue(complete_class_with_impl.IsTypeComplete())
Index: lldb/test/API/lang/objc/complete-type-check/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/objc/complete-type-check/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -framework Foundation
+CFLAGS_EXTRAS := -fobjc-arc
+
+include Makefile.rules
Index: lldb/test/API/lang/cpp/complete-type-check/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/complete-type-check/main.cpp
@@ -0,0 +1,36 @@
+struct EmptyClass {};
+struct DefinedClass {
+  int i;
+};
+typedef DefinedClass DefinedClassTypedef;
+
+struct FwdClass;
+typedef FwdClass FwdClassTypedef;
+
+template  struct DefinedTemplateClass {};
+template <> struct DefinedTemplateClass {};
+
+template  struct FwdTemplateClass;
+template <> struct FwdTemplateClass;
+
+enum class EnumClassFwd;
+
+enum DefinedEnum { Case1 };
+enum DefinedEnumClass { Case2 };
+
+EmptyClass empty_class;
+DefinedClass defined_class;
+DefinedClassTypedef defined_class_typedef;
+
+FwdClass *fwd_class;
+FwdClassTypedef *fwd_class_typedef;
+
+DefinedTemplateClass defined_template_class;
+FwdTemplateClass *fwd_template_class;
+
+EnumClassFwd *fwd_enum_class = nullptr;
+
+DefinedEnum defined_enum = Case1;
+DefinedEnumClass defined_enum_class = DefinedEnumClass::Case2;
+
+int main() {}
Index: lldb/test/API/lang/cpp/complete-type-check/TestCppIsTypeComplete.py

[Lldb-commits] [lldb] 4cf9d1e - [lldb][NFC] Modernize for-loops in ModuleList

2021-10-30 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-30T13:40:58+02:00
New Revision: 4cf9d1e4492fe70768d13fba5fbb61d9d93adf5c

URL: 
https://github.com/llvm/llvm-project/commit/4cf9d1e4492fe70768d13fba5fbb61d9d93adf5c
DIFF: 
https://github.com/llvm/llvm-project/commit/4cf9d1e4492fe70768d13fba5fbb61d9d93adf5c.diff

LOG: [lldb][NFC] Modernize for-loops in ModuleList

Reviewed By: mib

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

Added: 


Modified: 
lldb/include/lldb/Core/ModuleList.h
lldb/source/Core/ModuleList.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index 39d4a63dbf464..6ca5813d9662a 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -159,7 +159,7 @@ class ModuleList {
   /// ModulesDidLoad may be deferred when adding multiple Modules
   /// to the Target, but it must be called at the end,
   /// before resuming execution.
-  bool AppendIfNeeded(const lldb::ModuleSP &module_sp, bool notify = true);
+  bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify = true);
 
   void Append(const ModuleList &module_list);
 

diff  --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 44afed7fcf0de..629c075cbc00a 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -200,16 +200,15 @@ void ModuleList::ReplaceEquivalent(
   }
 }
 
-bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp, bool notify) {
-  if (module_sp) {
+bool ModuleList::AppendIfNeeded(const ModuleSP &new_module, bool notify) {
+  if (new_module) {
 std::lock_guard guard(m_modules_mutex);
-collection::iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  if (pos->get() == module_sp.get())
+for (const ModuleSP &module_sp : m_modules) {
+  if (module_sp.get() == new_module.get())
 return false; // Already in the list
 }
 // Only push module_sp on the list if it wasn't already in there.
-Append(module_sp, notify);
+Append(new_module, notify);
 return true;
   }
   return false;
@@ -372,10 +371,10 @@ void ModuleList::FindFunctions(ConstString name,
 Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
 
 std::lock_guard guard(m_modules_mutex);
-collection::const_iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  (*pos)->FindFunctions(lookup_info.GetLookupName(), CompilerDeclContext(),
-lookup_info.GetNameTypeMask(), options, sc_list);
+for (const ModuleSP &module_sp : m_modules) {
+  module_sp->FindFunctions(lookup_info.GetLookupName(),
+   CompilerDeclContext(),
+   lookup_info.GetNameTypeMask(), options, 
sc_list);
 }
 
 const size_t new_size = sc_list.GetSize();
@@ -384,10 +383,9 @@ void ModuleList::FindFunctions(ConstString name,
   lookup_info.Prune(sc_list, old_size);
   } else {
 std::lock_guard guard(m_modules_mutex);
-collection::const_iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  (*pos)->FindFunctions(name, CompilerDeclContext(), name_type_mask,
-options, sc_list);
+for (const ModuleSP &module_sp : m_modules) {
+  module_sp->FindFunctions(name, CompilerDeclContext(), name_type_mask,
+   options, sc_list);
 }
   }
 }
@@ -401,10 +399,9 @@ void ModuleList::FindFunctionSymbols(ConstString name,
 Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
 
 std::lock_guard guard(m_modules_mutex);
-collection::const_iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  (*pos)->FindFunctionSymbols(lookup_info.GetLookupName(),
-  lookup_info.GetNameTypeMask(), sc_list);
+for (const ModuleSP &module_sp : m_modules) {
+  module_sp->FindFunctionSymbols(lookup_info.GetLookupName(),
+ lookup_info.GetNameTypeMask(), sc_list);
 }
 
 const size_t new_size = sc_list.GetSize();
@@ -413,9 +410,8 @@ void ModuleList::FindFunctionSymbols(ConstString name,
   lookup_info.Prune(sc_list, old_size);
   } else {
 std::lock_guard guard(m_modules_mutex);
-collection::const_iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  (*pos)->FindFunctionSymbols(name, name_type_mask, sc_list);
+for (const ModuleSP &module_sp : m_modules) {
+  module_sp->FindFunctionSymbols(name, name_type_mask, sc_list);
 }
   }
 }
@@ -424,28 +420,23 @@ void ModuleList::FindFunctions(const RegularExpression 
&name,
const ModuleFunctionSearchOptions &options,

[Lldb-commits] [PATCH] D112379: [lldb][NFC] Modernize for-loops in ModuleList

2021-10-30 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cf9d1e4492f: [lldb][NFC] Modernize for-loops in ModuleList 
(authored by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112379/new/

https://reviews.llvm.org/D112379

Files:
  lldb/include/lldb/Core/ModuleList.h
  lldb/source/Core/ModuleList.cpp

Index: lldb/source/Core/ModuleList.cpp
===
--- lldb/source/Core/ModuleList.cpp
+++ lldb/source/Core/ModuleList.cpp
@@ -200,16 +200,15 @@
   }
 }
 
-bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp, bool notify) {
-  if (module_sp) {
+bool ModuleList::AppendIfNeeded(const ModuleSP &new_module, bool notify) {
+  if (new_module) {
 std::lock_guard guard(m_modules_mutex);
-collection::iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  if (pos->get() == module_sp.get())
+for (const ModuleSP &module_sp : m_modules) {
+  if (module_sp.get() == new_module.get())
 return false; // Already in the list
 }
 // Only push module_sp on the list if it wasn't already in there.
-Append(module_sp, notify);
+Append(new_module, notify);
 return true;
   }
   return false;
@@ -372,10 +371,10 @@
 Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
 
 std::lock_guard guard(m_modules_mutex);
-collection::const_iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  (*pos)->FindFunctions(lookup_info.GetLookupName(), CompilerDeclContext(),
-lookup_info.GetNameTypeMask(), options, sc_list);
+for (const ModuleSP &module_sp : m_modules) {
+  module_sp->FindFunctions(lookup_info.GetLookupName(),
+   CompilerDeclContext(),
+   lookup_info.GetNameTypeMask(), options, sc_list);
 }
 
 const size_t new_size = sc_list.GetSize();
@@ -384,10 +383,9 @@
   lookup_info.Prune(sc_list, old_size);
   } else {
 std::lock_guard guard(m_modules_mutex);
-collection::const_iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  (*pos)->FindFunctions(name, CompilerDeclContext(), name_type_mask,
-options, sc_list);
+for (const ModuleSP &module_sp : m_modules) {
+  module_sp->FindFunctions(name, CompilerDeclContext(), name_type_mask,
+   options, sc_list);
 }
   }
 }
@@ -401,10 +399,9 @@
 Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
 
 std::lock_guard guard(m_modules_mutex);
-collection::const_iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  (*pos)->FindFunctionSymbols(lookup_info.GetLookupName(),
-  lookup_info.GetNameTypeMask(), sc_list);
+for (const ModuleSP &module_sp : m_modules) {
+  module_sp->FindFunctionSymbols(lookup_info.GetLookupName(),
+ lookup_info.GetNameTypeMask(), sc_list);
 }
 
 const size_t new_size = sc_list.GetSize();
@@ -413,9 +410,8 @@
   lookup_info.Prune(sc_list, old_size);
   } else {
 std::lock_guard guard(m_modules_mutex);
-collection::const_iterator pos, end = m_modules.end();
-for (pos = m_modules.begin(); pos != end; ++pos) {
-  (*pos)->FindFunctionSymbols(name, name_type_mask, sc_list);
+for (const ModuleSP &module_sp : m_modules) {
+  module_sp->FindFunctionSymbols(name, name_type_mask, sc_list);
 }
   }
 }
@@ -424,28 +420,23 @@
const ModuleFunctionSearchOptions &options,
SymbolContextList &sc_list) {
   std::lock_guard guard(m_modules_mutex);
-  collection::const_iterator pos, end = m_modules.end();
-  for (pos = m_modules.begin(); pos != end; ++pos) {
-(*pos)->FindFunctions(name, options, sc_list);
-  }
+  for (const ModuleSP &module_sp : m_modules)
+module_sp->FindFunctions(name, options, sc_list);
 }
 
 void ModuleList::FindCompileUnits(const FileSpec &path,
   SymbolContextList &sc_list) const {
   std::lock_guard guard(m_modules_mutex);
-  collection::const_iterator pos, end = m_modules.end();
-  for (pos = m_modules.begin(); pos != end; ++pos) {
-(*pos)->FindCompileUnits(path, sc_list);
-  }
+  for (const ModuleSP &module_sp : m_modules)
+module_sp->FindCompileUnits(path, sc_list);
 }
 
 void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
  VariableList &variable_list) const {
   std::lock_guard guard(m_modules_mutex);
-  collection::const_iterator pos, end = m_modules.end();
-  for (pos = m_modules.begin(); pos != end; ++pos) {
-(*pos)->FindGlobal

[Lldb-commits] [PATCH] D112752: [formatters] Add a libstdcpp formatter for multimap and unify modify tests across stdlibs

2021-10-30 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 383587.
danilashtefan added a comment.

All the above specified parts are changed. Thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112752/new/

https://reviews.llvm.org/D112752

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp
@@ -1,77 +0,0 @@
-#include 
-#include 
-
-#define intint_map std::multimap 
-#define strint_map std::multimap 
-#define intstr_map std::multimap 
-#define strstr_map std::multimap 
-
-int g_the_foo = 0;
-
-int thefoo_rw(int arg = 1)
-{
-	if (arg < 0)
-		arg = 0;
-	if (!arg)
-		arg = 1;
-	g_the_foo += arg;
-	return g_the_foo;
-}
-
-int main()
-{
-intint_map ii;
-
-ii.emplace(0,0); // Set break point at this line.
-ii.emplace(1,1);
-	thefoo_rw(1);  // Set break point at this line.
-ii.emplace(2,0);
-	ii.emplace(3,1);
-	thefoo_rw(1);  // Set break point at this line.
-	ii.emplace(4,0);
-	ii.emplace(5,1);
-	ii.emplace(6,0);
-	ii.emplace(7,1);
-thefoo_rw(1);  // Set break point at this line.
-ii.emplace(85,1234567);
-
-ii.clear();
-
-strint_map si;
-thefoo_rw(1);  // Set break point at this line.
-	
-si.emplace("zero",0);
-	thefoo_rw(1);  // Set break point at this line.
-	si.emplace("one",1);
-	si.emplace("two",2);
-	si.emplace("three",3);
-	thefoo_rw(1);  // Set break point at this line.
-	si.emplace("four",4);
-
-si.clear();
-thefoo_rw(1);  // Set break point at this line.
-	
-intstr_map is;
-thefoo_rw(1);  // Set break point at this line.
-is.emplace(85,"goofy");
-is.emplace(1,"is");
-is.emplace(2,"smart");
-is.emplace(3,"!!!");
-thefoo_rw(1);  // Set break point at this line.
-	
-is.clear();
-thefoo_rw(1);  // Set break point at this line.
-	
-strstr_map ss;
-thefoo_rw(1);  // Set break point at this line.
-	
-ss.emplace("ciao","hello");
-ss.emplace("casa","house");
-ss.emplace("gatto","cat");
-thefoo_rw(1);  // Set break point at this line.
-ss.emplace("a Mac..","..is always a Mac!");
-
-ss.clear();
-thefoo_rw(1);  // Set break point at this line.
-return 0;
-}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py
@@ -10,19 +10,38 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
 
-class LibcxxMultiMapDataFormatterTestCase(TestBase):
+class GenericMultiMapDataFormatterTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
 TestBase.setUp(self)
 self.namespace = 'std'
-
-@add_test_categories(["libc++"])
-def test_with_run_command(self):
+
+def findVariable(self, name):
+var = self.frame().FindVariable(name)
+self.assertTrue(var.IsValid())
+return var
+
+def getVariableType(self, name):
+var = self.findVariable(name)
+return var.GetType().GetDisplayTypeName()
+
+def check(self, var_name, size):
+var = self.findVariable(var_name)
+self.assertEqual(var.GetNumChildren(), size)
+children = []
+for i in range(size):
+child = var.GetChildAtIndex(i)
+children.append(ValueCheck(value=child.GetValue()))
+self.expect_var_path(var_name, type=self.getVariableType(var_name), children=children)
+
+def do_test_with_run_command(self, stdlib_type):
 """Test that that file and class static variables display correctly."""
-self.build()
+self.build(dictionary={stdlib_type: "1"})
 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 

[Lldb-commits] [PATCH] D112752: [formatters] Add a libstdcpp formatter for multimap and unify modify tests across stdlibs

2021-10-30 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan added a comment.

I thought that you misprinted the name and wanted to call the formatter 
MapLikeSynth provider. Please, correct me if I am wrong and I will change names 
accordingly


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112752/new/

https://reviews.llvm.org/D112752

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112752: [formatters] Add a libstdcpp formatter for multimap and unify modify tests across stdlibs

2021-10-30 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

thanks! i'll land this now




Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:321
 """
-class StdSetOrMapSynthProvider:
+class StdMapLikeSynthProvider:
 

this is correct


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112752/new/

https://reviews.llvm.org/D112752

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] f869e0b - [formatters] Add a libstdcpp formatter for multimap and unify modify tests across stdlibs

2021-10-30 Thread Walter Erquinigo via lldb-commits

Author: Danil Stefaniuc
Date: 2021-10-30T12:53:32-07:00
New Revision: f869e0be445800e71f9a74a60b4f5611d3cff7d0

URL: 
https://github.com/llvm/llvm-project/commit/f869e0be445800e71f9a74a60b4f5611d3cff7d0
DIFF: 
https://github.com/llvm/llvm-project/commit/f869e0be445800e71f9a74a60b4f5611d3cff7d0.diff

LOG: [formatters] Add a libstdcpp formatter for multimap and unify modify tests 
across stdlibs

This diff adds a data formatter for libstdcpp's multimap. Besides, it improves 
and unifies the tests for multimap for libcxx and libstdcpp for maintainability.

Reviewed By: wallace

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

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/main.cpp

Modified: 
lldb/examples/synthetic/gnu_libstdcpp.py
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp



diff  --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index 21c89754c082..dd07195d6ec8 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -315,10 +315,10 @@ def has_children(self):
 return True
 
 """
-Set and Map have the same underlying data structure,
-therefore we can use exactly the same implementation for the formatter.
+ This formatter can be applied to all
+ map-like structures (map, multimap, set, multiset)
 """
-class StdSetOrMapSynthProvider:
+class StdMapLikeSynthProvider:
 
 def __init__(self, valobj, dict):
 logger = lldb.formatters.Logger.Logger()

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 626c5a5a8282..7b64faa6d6ed 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -902,12 +902,17 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   RegularExpression("^std::map<.+> >(( )?&)?$"),
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
   stl_synth_flags,
-  "lldb.formatters.cpp.gnu_libstdcpp.StdSetOrMapSynthProvider")));
+  "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
   RegularExpression("^std::set<.+> >(( )?&)?$"),
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
   stl_deref_flags,
-  "lldb.formatters.cpp.gnu_libstdcpp.StdSetOrMapSynthProvider")));
+  "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
+  cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
+  RegularExpression("^std::multimap<.+> >(( )?&)?$"),
+  SyntheticChildrenSP(new ScriptedSyntheticChildren(
+  stl_deref_flags,
+  "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
   RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"),
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
@@ -931,6 +936,10 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   RegularExpression("^std::set<.+> >(( )?&)?$"),
   TypeSummaryImplSP(
   new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+  cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
+  RegularExpression("^std::multimap<.+> >(( )?&)?$"),
+  TypeSummaryImplSP(
+  new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
   RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"),
   TypeSummaryImplSP(

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/Makefile
similarity index 54%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/Makefile
index 564cbada74e0..8b20bcb0 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/Makefile
@

[Lldb-commits] [PATCH] D112752: [formatters] Add a libstdcpp formatter for multimap and unify modify tests across stdlibs

2021-10-30 Thread Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf869e0be4458: [formatters] Add a libstdcpp formatter for 
multimap and unify modify tests… (authored by danilashtefan, committed by 
Walter Erquinigo ).

Changed prior to commit:
  https://reviews.llvm.org/D112752?vs=383587&id=383615#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112752/new/

https://reviews.llvm.org/D112752

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py
@@ -10,19 +10,38 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
 
-class LibcxxMultiMapDataFormatterTestCase(TestBase):
+class GenericMultiMapDataFormatterTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
 TestBase.setUp(self)
 self.namespace = 'std'
-
-@add_test_categories(["libc++"])
-def test_with_run_command(self):
+
+def findVariable(self, name):
+var = self.frame().FindVariable(name)
+self.assertTrue(var.IsValid())
+return var
+
+def getVariableType(self, name):
+var = self.findVariable(name)
+return var.GetType().GetDisplayTypeName()
+
+def check(self, var_name, size):
+var = self.findVariable(var_name)
+self.assertEqual(var.GetNumChildren(), size)
+children = []
+for i in range(size):
+child = var.GetChildAtIndex(i)
+children.append(ValueCheck(value=child.GetValue()))
+self.expect_var_path(var_name, type=self.getVariableType(var_name), children=children)
+
+def do_test_with_run_command(self, stdlib_type):
 """Test that that file and class static variables display correctly."""
-self.build()
+self.build(dictionary={stdlib_type: "1"})
 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 
 bkpt = self.target().FindBreakpointByID(
@@ -65,6 +84,8 @@
 '[0] = (first = 0, second = 0)',
 '[1] = (first = 1, second = 1)',
 ])
+
+self.check("ii", 2)
 
 lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
@@ -76,6 +97,8 @@
  '[3] = ',
  'first = 3',
  'second = 1'])
+
+self.check("ii", 4)
 
 lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
@@ -88,6 +111,8 @@
  'first = 7',
  'second = 1'])
 
+self.check("ii", 8)
+
 self.expect("p ii",
 substrs=[multimap, 'size=8',
  '[5] = ',
@@ -235,12 +260,16 @@
 substrs=[multimap, 'size=0',
  '{}'])
 
+self.check("is", 0)
+
 lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
 self.expect('frame variable ss',
 substrs=[multimap, 'size=0',
  '{}'])
 
+self.check("ss", 0)
+
 lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
 self.expect(
@@ -253,6 +282,8 @@
 '[2] = (first = "gatto", second = "cat")',
 ])
 
+self.check("ss", 3)
+
 self.expect(
 "p ss",
 substrs=[
@@ -285,3 +316,14 @@
 self.expect('frame variable ss',
 substrs=[multimap, 'size=0',
  '{}'])
+
+self.check("ss", 0)
+
+@add_test_categories(["libstdcxx"])
+def test_with_run_command_libstdcpp(self):
+self.do_test_with_run_command(USE_LIBSTDCPP)
+
+@add_test_categories(["libc++"])
+def test_with_run_command_libcpp(self):
+self.do_test_with_run_command(

[Lldb-commits] [PATCH] D112863: [lldb][NFC] avoid unnecessary roundtrips between different string types

2021-10-30 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

@xujuntwt95329 do you have push permissions or do you need help to land this 
diff?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112863/new/

https://reviews.llvm.org/D112863

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112785: [formatters] Add a libstdcpp formatter for multiset and unify tests across stdlibs

2021-10-30 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 383619.
danilashtefan added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112785/new/

https://reviews.llvm.org/D112785

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include 
-#include 
-
-int g_the_foo = 0;
-
-int thefoo_rw(int arg = 1)
-{
-	if (arg < 0)
-		arg = 0;
-	if (!arg)
-		arg = 1;
-	g_the_foo += arg;
-	return g_the_foo;
-}
-
-void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr)
-{
-// Stop here to check by ref and ptr
-return;
-} 
-
-int main()
-{
-std::multiset ii;
-thefoo_rw(1);  // Set break point at this line.
-	
-	ii.insert(0);
-	ii.insert(1);
-	ii.insert(2);
-	ii.insert(3);
-	ii.insert(4);
-	ii.insert(5);
-thefoo_rw(1);  // Set break point at this line.
-
-	ii.insert(6);
-	thefoo_rw(1);  // Set break point at this line.
-
-by_ref_and_ptr(ii, &ii);
-
-	ii.clear();
-	thefoo_rw(1);  // Set break point at this line.
-
-	std::multiset ss;
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("a");
-	ss.insert("a very long string is right here");
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("b");
-	ss.insert("c");
-	thefoo_rw(1);  // Set break point at this line.
-	
-	ss.erase("b");
-	thefoo_rw(1);  // Set break point at this line.
-
-return 0;
-}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -12,7 +12,7 @@
 USE_LIBSTDCPP = "USE_LIBSTDCPP"
 USE_LIBCPP = "USE_LIBCPP"
 
-class LibcxxSetDataFormatterTestCase(TestBase):
+class GenericSetDataFormatterTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::multiset ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::multiset ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
@@ -9,8 +9,10 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
 
-class LibcxxMulti

[Lldb-commits] [PATCH] D112785: [formatters] Add a libstdcpp formatter for multiset and unify tests across stdlibs

2021-10-30 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 383621.
danilashtefan added a comment.

refactoring


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112785/new/

https://reviews.llvm.org/D112785

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include 
-#include 
-
-int g_the_foo = 0;
-
-int thefoo_rw(int arg = 1)
-{
-	if (arg < 0)
-		arg = 0;
-	if (!arg)
-		arg = 1;
-	g_the_foo += arg;
-	return g_the_foo;
-}
-
-void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr)
-{
-// Stop here to check by ref and ptr
-return;
-} 
-
-int main()
-{
-std::multiset ii;
-thefoo_rw(1);  // Set break point at this line.
-	
-	ii.insert(0);
-	ii.insert(1);
-	ii.insert(2);
-	ii.insert(3);
-	ii.insert(4);
-	ii.insert(5);
-thefoo_rw(1);  // Set break point at this line.
-
-	ii.insert(6);
-	thefoo_rw(1);  // Set break point at this line.
-
-by_ref_and_ptr(ii, &ii);
-
-	ii.clear();
-	thefoo_rw(1);  // Set break point at this line.
-
-	std::multiset ss;
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("a");
-	ss.insert("a very long string is right here");
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("b");
-	ss.insert("c");
-	thefoo_rw(1);  // Set break point at this line.
-	
-	ss.erase("b");
-	thefoo_rw(1);  // Set break point at this line.
-
-return 0;
-}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -12,7 +12,7 @@
 USE_LIBSTDCPP = "USE_LIBSTDCPP"
 USE_LIBCPP = "USE_LIBCPP"
 
-class LibcxxSetDataFormatterTestCase(TestBase):
+class GenericSetDataFormatterTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::multiset ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::multiset ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
@@ -9,8 +9,10 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+USE_LIBSTDCPP = "USE_LIBSTDCPP"

[Lldb-commits] [PATCH] D112785: [formatters] Add a libstdcpp formatter for multiset and unify tests across stdlibs

2021-10-30 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

good job


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112785/new/

https://reviews.llvm.org/D112785

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 82ed106 - [formatters] Add a libstdcpp formatter for multiset and unify tests across stdlibs

2021-10-30 Thread Walter Erquinigo via lldb-commits

Author: Danil Stefaniuc
Date: 2021-10-30T15:07:23-07:00
New Revision: 82ed106567063ea269c6d5669278b733e173a42f

URL: 
https://github.com/llvm/llvm-project/commit/82ed106567063ea269c6d5669278b733e173a42f
DIFF: 
https://github.com/llvm/llvm-project/commit/82ed106567063ea269c6d5669278b733e173a42f.diff

LOG: [formatters] Add a libstdcpp formatter for multiset and unify tests across 
stdlibs

This diff adds a data formatter for libstdcpp's multiset. Besides, it improves 
and unifies the tests for multiset for libcxx and libstdcpp for maintainability.

Reviewed By: wallace

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

Added: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp

Modified: 
lldb/examples/synthetic/gnu_libstdcpp.py
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py

Removed: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp



diff  --git a/lldb/examples/synthetic/gnu_libstdcpp.py 
b/lldb/examples/synthetic/gnu_libstdcpp.py
index dd07195d6ec80..30149d17b68af 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -324,10 +324,17 @@ def __init__(self, valobj, dict):
 logger = lldb.formatters.Logger.Logger()
 self.valobj = valobj
 self.count = None
-self.kind = "set" if "set" in valobj.GetTypeName() else "map"
+self.kind = self.get_object_kind(valobj)
 logger >> "Providing synthetic children for a " + self.kind + " named 
" + \
 str(valobj.GetName())
 
+def get_object_kind(self, valobj):
+type_name = valobj.GetTypeName()
+for kind in ["multiset", "multimap", "set", "map"]:
+   if kind in type_name:
+  return kind
+return type_name
+
 # we need this function as a temporary workaround for 
rdar://problem/10801549
 # which prevents us from extracting the std::pair SBType out of the 
template
 # arguments for _Rep_Type _M_t in the object itself - because we have to 
make up the

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 7b64faa6d6ed3..e4d9813dcd5cf 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -913,6 +913,11 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
   stl_deref_flags,
   "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
+  cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
+  RegularExpression("^std::multiset<.+> >(( )?&)?$"),
+  SyntheticChildrenSP(new ScriptedSyntheticChildren(
+  stl_deref_flags,
+  "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
   RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"),
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
@@ -940,6 +945,10 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   RegularExpression("^std::multimap<.+> >(( )?&)?$"),
   TypeSummaryImplSP(
   new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+  cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
+  RegularExpression("^std::multiset<.+> >(( )?&)?$"),
+  TypeSummaryImplSP(
+  new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
   RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"),
   TypeSummaryImplSP(

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile
similarity index 54%
rename from 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
rename to 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile
index 564cbada74e08..8b20bcb05 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
+++ 
b/lldb/test/API/functionalities/data-fo

[Lldb-commits] [PATCH] D112785: [formatters] Add a libstdcpp formatter for multiset and unify tests across stdlibs

2021-10-30 Thread Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG82ed10656706: [formatters] Add a libstdcpp formatter for 
multiset and unify tests across… (authored by danilashtefan, committed by 
Walter Erquinigo ).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112785/new/

https://reviews.llvm.org/D112785

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include 
-#include 
-
-int g_the_foo = 0;
-
-int thefoo_rw(int arg = 1)
-{
-	if (arg < 0)
-		arg = 0;
-	if (!arg)
-		arg = 1;
-	g_the_foo += arg;
-	return g_the_foo;
-}
-
-void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr)
-{
-// Stop here to check by ref and ptr
-return;
-} 
-
-int main()
-{
-std::multiset ii;
-thefoo_rw(1);  // Set break point at this line.
-	
-	ii.insert(0);
-	ii.insert(1);
-	ii.insert(2);
-	ii.insert(3);
-	ii.insert(4);
-	ii.insert(5);
-thefoo_rw(1);  // Set break point at this line.
-
-	ii.insert(6);
-	thefoo_rw(1);  // Set break point at this line.
-
-by_ref_and_ptr(ii, &ii);
-
-	ii.clear();
-	thefoo_rw(1);  // Set break point at this line.
-
-	std::multiset ss;
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("a");
-	ss.insert("a very long string is right here");
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("b");
-	ss.insert("c");
-	thefoo_rw(1);  // Set break point at this line.
-	
-	ss.erase("b");
-	thefoo_rw(1);  // Set break point at this line.
-
-return 0;
-}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -12,7 +12,7 @@
 USE_LIBSTDCPP = "USE_LIBSTDCPP"
 USE_LIBCPP = "USE_LIBCPP"
 
-class LibcxxSetDataFormatterTestCase(TestBase):
+class GenericSetDataFormatterTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::multiset ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::multiset ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py
+++ lldb/test/API/functional

[Lldb-commits] [PATCH] D112863: [lldb][NFC] avoid unnecessary roundtrips between different string types

2021-10-30 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 added a comment.

In D112863#3098706 , @wallace wrote:

> @xujuntwt95329 do you have push permissions or do you need help to land this 
> diff?

I don't have push permissions, could you please help me to land this?

Thanks a lot!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112863/new/

https://reviews.llvm.org/D112863

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits