[Lldb-commits] [lldb] e07e1d4 - [test] Increase test assertion for reasonable auxv values.

2022-09-12 Thread Jordan Rupprecht via lldb-commits

Author: Jordan Rupprecht
Date: 2022-09-12T19:41:06-07:00
New Revision: e07e1d4425f837e5b38336664a24650834b3

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

LOG: [test] Increase test assertion for reasonable auxv values.

While auxv keys are usually small, e.g. less than 50, they can sometimes be 
larger, especially on a downstream kernel where a custom auxv entry is 
intentionally high to avoid conflicting with the standard lower numbers. This 
test fails on a system with an auxv value bigger than 1000, but instead of 
putting this test at that value plus one, it looks like 2023 (i.e. 
`AT_SUN_CAP_HW2`) is another large one out there. Use 2500 as a limit to still 
have this be a reasonable "small" check but still allow all known auxv keys.

Semi-related change: this test case prints the auxv dict at the trace level, 
but only _after_ the assertion fails, making it not print what the offending 
value is as the test case aborts. Move it earlier so we can see what the 
"unreasonable" auxv value is.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
index ac9c7fe9049c0..bf4001fd32e80 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
@@ -112,11 +112,12 @@ def test_auxv_keys_look_valid(self):
 auxv_dict = self.build_auxv_dict(endian, word_size, auxv_data)
 self.assertIsNotNone(auxv_dict)
 
-# Verify keys look reasonable.
+# Verify keys look reasonable. While AUX values are most commonly
+# small (usually smaller than 50), they can sometimes be larger.
+self.trace("auxv dict: {}".format(auxv_dict))
 for auxv_key in auxv_dict:
 self.assertTrue(auxv_key >= 1)
-self.assertTrue(auxv_key <= 1000)
-self.trace("auxv dict: {}".format(auxv_dict))
+self.assertTrue(auxv_key <= 2500)
 
 @skipIfWindows
 @expectedFailureNetBSD



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


[Lldb-commits] [PATCH] D133240: [Formatters][NFCI] Replace 'is_regex' arguments with an enum.

2022-09-12 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe updated this revision to Diff 459618.
jgorbe added a comment.

Fixed mis-spelled member name in comment.


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

https://reviews.llvm.org/D133240

Files:
  lldb/bindings/interface/SBTypeNameSpecifier.i
  lldb/include/lldb/API/SBTypeNameSpecifier.h
  lldb/include/lldb/DataFormatters/FormatClasses.h
  lldb/include/lldb/DataFormatters/FormattersContainer.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SBTypeNameSpecifier.cpp
  lldb/source/Core/FormatEntity.cpp

Index: lldb/source/Core/FormatEntity.cpp
===
--- lldb/source/Core/FormatEntity.cpp
+++ lldb/source/Core/FormatEntity.cpp
@@ -825,7 +825,7 @@
 bitfield_name.Printf("%s:%d", target->GetTypeName().AsCString(),
  target->GetBitfieldBitSize());
 auto type_sp = std::make_shared(
-bitfield_name.GetString(), false);
+bitfield_name.GetString(), lldb::eFormatterMatchExact);
 if (val_obj_display ==
 ValueObject::eValueObjectRepresentationStyleSummary &&
 !DataVisualization::GetSummaryForType(type_sp))
Index: lldb/source/API/SBTypeNameSpecifier.cpp
===
--- lldb/source/API/SBTypeNameSpecifier.cpp
+++ lldb/source/API/SBTypeNameSpecifier.cpp
@@ -20,8 +20,15 @@
 SBTypeNameSpecifier::SBTypeNameSpecifier() { LLDB_INSTRUMENT_VA(this); }
 
 SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
-: m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) {
+: SBTypeNameSpecifier(name, is_regex ? eFormatterMatchRegex
+ : eFormatterMatchExact) {
   LLDB_INSTRUMENT_VA(this, name, is_regex);
+}
+
+SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name,
+ FormatterMatchType match_type)
+: m_opaque_sp(new TypeNameSpecifierImpl(name, match_type)) {
+  LLDB_INSTRUMENT_VA(this, name, match_type);
 
   if (name == nullptr || (*name) == 0)
 m_opaque_sp.reset();
@@ -72,13 +79,20 @@
   return SBType();
 }
 
+FormatterMatchType SBTypeNameSpecifier::GetMatchType() {
+  LLDB_INSTRUMENT_VA(this);
+  if (!IsValid())
+return eFormatterMatchExact;
+  return m_opaque_sp->GetMatchType();
+}
+
 bool SBTypeNameSpecifier::IsRegex() {
   LLDB_INSTRUMENT_VA(this);
 
   if (!IsValid())
 return false;
 
-  return m_opaque_sp->IsRegex();
+  return m_opaque_sp->GetMatchType() == eFormatterMatchRegex;
 }
 
 bool SBTypeNameSpecifier::GetDescription(
@@ -116,7 +130,7 @@
   if (!IsValid())
 return !rhs.IsValid();
 
-  if (IsRegex() != rhs.IsRegex())
+  if (GetMatchType() != rhs.GetMatchType())
 return false;
   if (GetName() == nullptr || rhs.GetName() == nullptr)
 return false;
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -832,6 +832,15 @@
   eTemplateArgumentKindNullPtr,
 };
 
+/// Type of match to be performed when looking for a formatter for a data type.
+/// Used by classes like SBTypeNameSpecifier or lldb_private::TypeMatcher.
+enum FormatterMatchType {
+  eFormatterMatchExact,
+  eFormatterMatchRegex,
+
+  kNumFormatterMatchTypes,
+};
+
 /// Options that can be set for a formatter to alter its behavior. Not
 /// all of these are applicable to all formatter types.
 FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u),
Index: lldb/include/lldb/DataFormatters/FormattersContainer.h
===
--- lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -41,9 +41,11 @@
 class TypeMatcher {
   RegularExpression m_type_name_regex;
   ConstString m_type_name;
-  /// False if m_type_name_regex should be used for matching. False if this is
-  /// just matching by comparing with m_type_name string.
-  bool m_is_regex;
+  /// Indicates what kind of matching strategy should be used:
+  /// - eFormatterMatchExact: match the exact type name in m_type_name.
+  /// - eFormatterMatchRegex: match using the RegularExpression object
+  ///   `m_type_name_regex` instead.
+  lldb::FormatterMatchType m_match_type;
 
   // if the user tries to add formatters for, say, "struct Foo" those will not
   // match any type because of the way we strip qualifiers from typenames this
@@ -71,22 +73,25 @@
   TypeMatcher() = delete;
   /// Creates a matcher that accepts any type with exactly the given type name.
   TypeMatcher(ConstString type_name)
-  : m_type_name(type_name), m_is_regex(false) {}
+  : m_type_name(type_name), m_match_type(lldb::eFormatterMatchExact) {}
   /// Creates a matcher that accepts any type matching the given regex.
   TypeMatcher(RegularExpression regex)
-  : m_type_name_regex(std::move(regex)), m_is_regex(true) {}
+  : 

[Lldb-commits] [PATCH] D133240: [Formatters][NFCI] Replace 'is_regex' arguments with an enum.

2022-09-12 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe marked an inline comment as done.
jgorbe added inline comments.



Comment at: lldb/include/lldb/DataFormatters/FormattersContainer.h:46
   /// just matching by comparing with m_type_name string.
-  bool m_is_regex;
+  lldb::FormatterMatchType m_match_type;
 

hawkinsw wrote:
> I am really intrigued by this entire patchset and just wanted to drop by to 
> help, if I could. I hope that I am not upsetting you by commenting on 
> something so trivial, but it seems like we would want to change the comment 
> for this data member while we are at it?
> 
> Again, I think this work is great and I hope I am helping!
Good catch! I have updated the comment. Thanks for pointing it out :)


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

https://reviews.llvm.org/D133240

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


[Lldb-commits] [PATCH] D133240: [Formatters][NFCI] Replace 'is_regex' arguments with an enum.

2022-09-12 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe updated this revision to Diff 459610.
jgorbe added a comment.

Updated comment above the declaration of TypeMatcher::m_match_type that 
referred to the old m_is_regex boolean, to address review feedback


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

https://reviews.llvm.org/D133240

Files:
  lldb/bindings/interface/SBTypeNameSpecifier.i
  lldb/include/lldb/API/SBTypeNameSpecifier.h
  lldb/include/lldb/DataFormatters/FormatClasses.h
  lldb/include/lldb/DataFormatters/FormattersContainer.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/API/SBTypeNameSpecifier.cpp
  lldb/source/Core/FormatEntity.cpp

Index: lldb/source/Core/FormatEntity.cpp
===
--- lldb/source/Core/FormatEntity.cpp
+++ lldb/source/Core/FormatEntity.cpp
@@ -825,7 +825,7 @@
 bitfield_name.Printf("%s:%d", target->GetTypeName().AsCString(),
  target->GetBitfieldBitSize());
 auto type_sp = std::make_shared(
-bitfield_name.GetString(), false);
+bitfield_name.GetString(), lldb::eFormatterMatchExact);
 if (val_obj_display ==
 ValueObject::eValueObjectRepresentationStyleSummary &&
 !DataVisualization::GetSummaryForType(type_sp))
Index: lldb/source/API/SBTypeNameSpecifier.cpp
===
--- lldb/source/API/SBTypeNameSpecifier.cpp
+++ lldb/source/API/SBTypeNameSpecifier.cpp
@@ -20,8 +20,15 @@
 SBTypeNameSpecifier::SBTypeNameSpecifier() { LLDB_INSTRUMENT_VA(this); }
 
 SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
-: m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) {
+: SBTypeNameSpecifier(name, is_regex ? eFormatterMatchRegex
+ : eFormatterMatchExact) {
   LLDB_INSTRUMENT_VA(this, name, is_regex);
+}
+
+SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name,
+ FormatterMatchType match_type)
+: m_opaque_sp(new TypeNameSpecifierImpl(name, match_type)) {
+  LLDB_INSTRUMENT_VA(this, name, match_type);
 
   if (name == nullptr || (*name) == 0)
 m_opaque_sp.reset();
@@ -72,13 +79,20 @@
   return SBType();
 }
 
+FormatterMatchType SBTypeNameSpecifier::GetMatchType() {
+  LLDB_INSTRUMENT_VA(this);
+  if (!IsValid())
+return eFormatterMatchExact;
+  return m_opaque_sp->GetMatchType();
+}
+
 bool SBTypeNameSpecifier::IsRegex() {
   LLDB_INSTRUMENT_VA(this);
 
   if (!IsValid())
 return false;
 
-  return m_opaque_sp->IsRegex();
+  return m_opaque_sp->GetMatchType() == eFormatterMatchRegex;
 }
 
 bool SBTypeNameSpecifier::GetDescription(
@@ -116,7 +130,7 @@
   if (!IsValid())
 return !rhs.IsValid();
 
-  if (IsRegex() != rhs.IsRegex())
+  if (GetMatchType() != rhs.GetMatchType())
 return false;
   if (GetName() == nullptr || rhs.GetName() == nullptr)
 return false;
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -832,6 +832,15 @@
   eTemplateArgumentKindNullPtr,
 };
 
+/// Type of match to be performed when looking for a formatter for a data type.
+/// Used by classes like SBTypeNameSpecifier or lldb_private::TypeMatcher.
+enum FormatterMatchType {
+  eFormatterMatchExact,
+  eFormatterMatchRegex,
+
+  kNumFormatterMatchTypes,
+};
+
 /// Options that can be set for a formatter to alter its behavior. Not
 /// all of these are applicable to all formatter types.
 FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u),
Index: lldb/include/lldb/DataFormatters/FormattersContainer.h
===
--- lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -41,9 +41,11 @@
 class TypeMatcher {
   RegularExpression m_type_name_regex;
   ConstString m_type_name;
-  /// False if m_type_name_regex should be used for matching. False if this is
-  /// just matching by comparing with m_type_name string.
-  bool m_is_regex;
+  /// Indicates what kind of matching strategy should be used:
+  /// - eFormatterMatchExact: match the exact type name in m_name.
+  /// - eFormatterMatchRegex: match using the RegularExpression object
+  ///   `m_type_name_regex` instead.
+  lldb::FormatterMatchType m_match_type;
 
   // if the user tries to add formatters for, say, "struct Foo" those will not
   // match any type because of the way we strip qualifiers from typenames this
@@ -71,22 +73,25 @@
   TypeMatcher() = delete;
   /// Creates a matcher that accepts any type with exactly the given type name.
   TypeMatcher(ConstString type_name)
-  : m_type_name(type_name), m_is_regex(false) {}
+  : m_type_name(type_name), m_match_type(lldb::eFormatterMatchExact) {}
   /// Creates a matcher that accepts any type matching the given regex.
   

[Lldb-commits] [PATCH] D133623: Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG376c7bd92aff: Fix DW_OP_convert to resolve the CU relative 
offset correctly. (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133623

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h

Index: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
===
--- lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
+++ lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
@@ -33,7 +33,7 @@
 
 public:
   /// Parse the debug info sections from the YAML description.
-  YAMLModuleTester(llvm::StringRef yaml_data);
+  YAMLModuleTester(llvm::StringRef yaml_data, size_t cu_index = 0);
   DWARFUnit *GetDwarfUnit() const { return m_dwarf_unit; }
   lldb::ModuleSP GetModule() const { return m_module_sp; }
 };
Index: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
===
--- lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
+++ lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
@@ -14,7 +14,7 @@
 
 using namespace lldb_private;
 
-YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data) {
+YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data, size_t cu_index) {
   llvm::Expected File = TestFile::fromYaml(yaml_data);
   EXPECT_THAT_EXPECTED(File, llvm::Succeeded());
   m_file = std::move(*File);
@@ -22,5 +22,5 @@
   m_module_sp = std::make_shared(m_file->moduleSpec());
   auto  = *llvm::cast(m_module_sp->GetSymbolFile());
 
-  m_dwarf_unit = symfile.DebugInfo().GetUnitAtIndex(0);
+  m_dwarf_unit = symfile.DebugInfo().GetUnitAtIndex(cu_index);
 }
Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -61,6 +61,9 @@
 
 class DWARFExpressionTester : public YAMLModuleTester {
 public:
+  DWARFExpressionTester(llvm::StringRef yaml_data, size_t cu_index) :
+  YAMLModuleTester(yaml_data, cu_index) {}
+
   using YAMLModuleTester::YAMLModuleTester;
   llvm::Expected Eval(llvm::ArrayRef expr) {
 return ::Evaluate(expr, m_module_sp, m_dwarf_unit);
@@ -179,6 +182,17 @@
   debug_info:
 - Version: 4
   AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
+  Entries:
+- AbbrCode:0x0001
+  Values:
+- Value:   0x000C
+- AbbrCode:0x
+- Version: 4
+  AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
   Entries:
 - AbbrCode:0x0001
   Values:
@@ -214,14 +228,16 @@
 - Value:   0x000b # DW_ATE_numeric_string
 - Value:   0x0001
 - AbbrCode:0x
+
 )";
+  // Compile unit relative offsets to each DW_TAG_base_type
   uint8_t offs_uint32_t = 0x000e;
   uint8_t offs_uint64_t = 0x0011;
   uint8_t offs_sint64_t = 0x0014;
   uint8_t offs_uchar = 0x0017;
   uint8_t offs_schar = 0x001a;
 
-  DWARFExpressionTester t(yamldata);
+  DWARFExpressionTester t(yamldata, /*cu_index=*/1);
   ASSERT_TRUE((bool)t.GetDwarfUnit());
 
   // Constant is given as little-endian.
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2374,9 +2374,11 @@
   return false;
 }
   } else {
-// Retrieve the type DIE that the value is being converted to.
+// Retrieve the type DIE that the value is being converted to. This
+// offset is compile unit relative so we need to fix it up.
+const uint64_t abs_die_offset = die_offset +  dwarf_cu->GetOffset();
 // FIXME: the constness has annoying ripple effects.
-DWARFDIE die = const_cast(dwarf_cu)->GetDIE(die_offset);
+DWARFDIE die = const_cast(dwarf_cu)->GetDIE(abs_die_offset);
 if (!die) {
   if (error_ptr)
 error_ptr->SetErrorString("Cannot resolve DW_OP_convert type DIE");
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 376c7bd - Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2022-09-12T16:53:19-07:00
New Revision: 376c7bd92aff0e4256b2842400936a9b29343045

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

LOG: Fix DW_OP_convert to resolve the CU relative offset correctly.

Debugging some DWARF5 binaries was causing errors to appear when 
DWARFExpression::Evaluate was called:

error: GetDIE for DIE 0x31 is outside of its CU 0x123450

The issue is in the DWARF expression evaluator. Fixed with this.

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

Added: 


Modified: 
lldb/source/Expression/DWARFExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp
lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h

Removed: 




diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 283e04021a52a..8e9c868a6405b 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2374,9 +2374,11 @@ bool DWARFExpression::Evaluate(
   return false;
 }
   } else {
-// Retrieve the type DIE that the value is being converted to.
+// Retrieve the type DIE that the value is being converted to. This
+// offset is compile unit relative so we need to fix it up.
+const uint64_t abs_die_offset = die_offset +  dwarf_cu->GetOffset();
 // FIXME: the constness has annoying ripple effects.
-DWARFDIE die = const_cast(dwarf_cu)->GetDIE(die_offset);
+DWARFDIE die = const_cast(dwarf_cu)->GetDIE(abs_die_offset);
 if (!die) {
   if (error_ptr)
 error_ptr->SetErrorString("Cannot resolve DW_OP_convert type DIE");

diff  --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp 
b/lldb/unittests/Expression/DWARFExpressionTest.cpp
index 2678db9aa6a42..8d23f1c49564b 100644
--- a/lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -61,6 +61,9 @@ static llvm::Expected 
Evaluate(llvm::ArrayRef expr,
 
 class DWARFExpressionTester : public YAMLModuleTester {
 public:
+  DWARFExpressionTester(llvm::StringRef yaml_data, size_t cu_index) :
+  YAMLModuleTester(yaml_data, cu_index) {}
+
   using YAMLModuleTester::YAMLModuleTester;
   llvm::Expected Eval(llvm::ArrayRef expr) {
 return ::Evaluate(expr, m_module_sp, m_dwarf_unit);
@@ -179,6 +182,17 @@ TEST(DWARFExpression, DW_OP_convert) {
   debug_info:
 - Version: 4
   AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
+  Entries:
+- AbbrCode:0x0001
+  Values:
+- Value:   0x000C
+- AbbrCode:0x
+- Version: 4
+  AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
   Entries:
 - AbbrCode:0x0001
   Values:
@@ -214,14 +228,16 @@ TEST(DWARFExpression, DW_OP_convert) {
 - Value:   0x000b # DW_ATE_numeric_string
 - Value:   0x0001
 - AbbrCode:0x
+
 )";
+  // Compile unit relative offsets to each DW_TAG_base_type
   uint8_t offs_uint32_t = 0x000e;
   uint8_t offs_uint64_t = 0x0011;
   uint8_t offs_sint64_t = 0x0014;
   uint8_t offs_uchar = 0x0017;
   uint8_t offs_schar = 0x001a;
 
-  DWARFExpressionTester t(yamldata);
+  DWARFExpressionTester t(yamldata, /*cu_index=*/1);
   ASSERT_TRUE((bool)t.GetDwarfUnit());
 
   // Constant is given as little-endian.

diff  --git a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp 
b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
index 15db62451f91a..14e7c7d5203ed 100644
--- a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
+++ b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
@@ -14,7 +14,7 @@
 
 using namespace lldb_private;
 
-YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data) {
+YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data, size_t cu_index) 
{
   llvm::Expected File = TestFile::fromYaml(yaml_data);
   EXPECT_THAT_EXPECTED(File, llvm::Succeeded());
   m_file = std::move(*File);
@@ -22,5 +22,5 @@ YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data) 
{
   m_module_sp = std::make_shared(m_file->moduleSpec());
   auto  = *llvm::cast(m_module_sp->GetSymbolFile());
 
-  m_dwarf_unit = symfile.DebugInfo().GetUnitAtIndex(0);
+  m_dwarf_unit = symfile.DebugInfo().GetUnitAtIndex(cu_index);
 }

diff  --git a/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h 
b/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
index 60715ab2c16a6..1b1bf22be1cb2 100644
--- 

[Lldb-commits] [lldb] c9ccaf1 - Fix make invocation to pass in the correct source file

2022-09-12 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2022-09-12T16:51:17-07:00
New Revision: c9ccaf176de7d7104492e19484f18e4b3ec1ba42

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

LOG: Fix make invocation to pass in the correct source file

Added: 


Modified: 
lldb/test/API/macosx/lc-note/kern-ver-str/Makefile

Removed: 




diff  --git a/lldb/test/API/macosx/lc-note/kern-ver-str/Makefile 
b/lldb/test/API/macosx/lc-note/kern-ver-str/Makefile
index ad37346bbebc0..05d9552a80209 100644
--- a/lldb/test/API/macosx/lc-note/kern-ver-str/Makefile
+++ b/lldb/test/API/macosx/lc-note/kern-ver-str/Makefile
@@ -6,6 +6,6 @@ all: a.out create-empty-corefile
 
 create-empty-corefile:
$(MAKE) -f $(MAKEFILE_RULES) EXE=create-empty-corefile \
-   C_SOURCES=create-empty-corefile.c
+   CXX=$(CC) CXX_SOURCES=create-empty-corefile.cpp
 
 include Makefile.rules



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


[Lldb-commits] [lldb] 455aff7 - Force system C++ stdlib in test that forces system clang.

2022-09-12 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2022-09-12T16:47:46-07:00
New Revision: 455aff72ce45982ae94e88d8b5474411a520047d

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

LOG: Force system C++ stdlib in test that forces system clang.

Unfortunately these options are still not upstream.

Added: 


Modified: 
lldb/test/API/functionalities/data-formatter/poarray/TestPrintObjectArray.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/poarray/TestPrintObjectArray.py 
b/lldb/test/API/functionalities/data-formatter/poarray/TestPrintObjectArray.py
index 3f1190a9388c4..cdfee184c5741 100644
--- 
a/lldb/test/API/functionalities/data-formatter/poarray/TestPrintObjectArray.py
+++ 
b/lldb/test/API/functionalities/data-formatter/poarray/TestPrintObjectArray.py
@@ -24,6 +24,8 @@ def test_print_array_no_const(self):
 disable_constant_classes = {
 'CC':
 'xcrun clang',  # FIXME: Remove when flags are available upstream.
+'USE_SYSTEM_STDLIB':
+'1', # See above.
 'CFLAGS_EXTRAS':
 '-fno-constant-nsnumber-literals ' +
 '-fno-constant-nsarray-literals ' +



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


[Lldb-commits] [lldb] 1910eeb - Fix make invocation to pass in the correct source file

2022-09-12 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2022-09-12T16:36:56-07:00
New Revision: 1910eeb59f38f32a3ab25e3fb6f555cb35f4e5ed

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

LOG: Fix make invocation to pass in the correct source file

Added: 


Modified: 
lldb/test/API/macosx/lc-note/firmware-corefile/Makefile

Removed: 




diff  --git a/lldb/test/API/macosx/lc-note/firmware-corefile/Makefile 
b/lldb/test/API/macosx/lc-note/firmware-corefile/Makefile
index 05020112520e8..4d798fc9ad993 100644
--- a/lldb/test/API/macosx/lc-note/firmware-corefile/Makefile
+++ b/lldb/test/API/macosx/lc-note/firmware-corefile/Makefile
@@ -6,6 +6,6 @@ all: a.out create-empty-corefile
 
 create-empty-corefile:
"$(MAKE)" -f "$(MAKEFILE_RULES)" EXE=create-empty-corefile \
-   C_SOURCES=create-empty-corefile.c
+   CXX=$(CC) CXX_SOURCES=create-empty-corefile.cpp
 
 include Makefile.rules



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


[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-09-12 Thread David Rector via Phabricator via lldb-commits
davrec added inline comments.



Comment at: clang/include/clang/AST/Type.h:5530-5537
 /// Represents a type that was referred to using an elaborated type
 /// keyword, e.g., struct S, or via a qualified name, e.g., N::M::type,
 /// or both.
 ///
 /// This type is used to keep track of a type name as written in the
 /// source code, including tag keywords and any nested-name-specifiers.
 /// The type itself is always "sugar", used to express what was written

This documentation needs to be updated given the changes in this patch.  
Suggest you remove the first paragraph and flesh out the second paragraph, e.g.

```
/// A sugar type used to keep track of a type name as written in the
/// source code, including any tag keywords (e.g. struct S) and/or any 
/// nested-name-specifiers (e.g. N::M::type).  Note it will even be created
/// for types written *without* tag words or nested-name-specifiers, to
/// properly represent their absence in the written code.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [PATCH] D133164: Add the ability to show when variables fails to be available when debug info is valid.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4763200ec95c: Add the ability to show when variables fails 
to be available when debug info is… (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133164

Files:
  lldb/bindings/interface/SBValueList.i
  lldb/include/lldb/API/SBError.h
  lldb/include/lldb/API/SBValueList.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/StackFrame.h
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBFrame.cpp
  lldb/source/API/SBValueList.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Symbol/Variable.cpp
  lldb/source/Target/StackFrame.cpp
  lldb/test/API/commands/frame/var/TestFrameVar.py
  lldb/test/API/functionalities/archives/Makefile
  lldb/test/API/functionalities/archives/TestBSDArchives.py

Index: lldb/test/API/functionalities/archives/TestBSDArchives.py
===
--- lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -6,10 +6,16 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
-
+import os
+import time
 
 class BSDArchivesTestCase(TestBase):
 
+# If your test case doesn't stress debug info, then
+# set this to true.  That way it won't be run once for
+# each debug info format.
+NO_DEBUG_INFO_TESTCASE = True
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -17,8 +23,6 @@
 self.line = line_number(
 'a.c', '// Set file and line breakpoint inside a().')
 
-# Doesn't depend on any specific debug information.
-@no_debug_info_test
 @expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24527.  Makefile.rules doesn't know how to build static libs on Windows")
@@ -65,3 +69,80 @@
 num_specs = module_specs.GetSize()
 self.assertEqual(num_specs, 1)
 self.assertEqual(module_specs.GetSpecAtIndex(0).GetObjectName(), "c.o")
+
+
+def check_frame_variable_errors(self, thread, error_strings):
+command_result = lldb.SBCommandReturnObject()
+interp = self.dbg.GetCommandInterpreter()
+result = interp.HandleCommand("frame variable", command_result)
+self.assertEqual(result, lldb.eReturnStatusFailed,
+ "frame var succeeded unexpectedly")
+command_error = command_result.GetError()
+
+frame = thread.GetFrameAtIndex(0)
+var_list = frame.GetVariables(True, True, False, True)
+self.assertEqual(var_list.GetSize(), 0)
+api_error = var_list.GetError().GetCString()
+
+for s in error_strings:
+self.assertTrue(s in command_error, 'Make sure "%s" exists in the command error "%s"' % (s, command_error))
+for s in error_strings:
+self.assertTrue(s in api_error, 'Make sure "%s" exists in the API error "%s"' % (s, api_error))
+
+@skipIfRemote
+@skipUnlessDarwin
+def test_frame_var_errors_when_archive_missing(self):
+"""
+Break inside a() and remove libfoo.a to make sure we can't load
+the debug information and report an appropriate error when doing
+'frame variable'.
+"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+libfoo_path = self.getBuildArtifact("libfoo.a")
+# Delete the main.o file that contains the debug info so we force an
+# error when we run to main and try to get variables for the a()
+# function. Since the libfoo.a is missing, the debug info won't be
+# loaded and we should see an error when trying to read varibles.
+os.unlink(libfoo_path)
+
+(target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(
+self, 'a', bkpt_module=exe)
+
+error_strings = [
+'debug map object file "',
+'libfoo.a(a.o)" containing debug info does not exist, debug info will not be loaded'
+]
+self.check_frame_variable_errors(thread, error_strings)
+
+@skipIfRemote
+@skipUnlessDarwin
+def test_frame_var_errors_when_mtime_mistmatch_for_object_in_archive(self):
+"""
+Break inside a() and modify 

[Lldb-commits] [lldb] 4763200 - Add the ability to show when variables fails to be available when debug info is valid.

2022-09-12 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2022-09-12T13:59:05-07:00
New Revision: 4763200ec95ce6514403176017f29b87757b292a

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

LOG: Add the ability to show when variables fails to be available when debug 
info is valid.

Summary:
Many times when debugging variables might not be available even though a user 
can successfully set breakpoints and stops somewhere. Letting the user know 
will help users fix these kinds of issues and have a better debugging 
experience.

Examples of this include:
- enabling -gline-tables-only and being able to set file and line breakpoints 
and yet see no variables
- unable to open object file for DWARF in .o file debugging for darwin targets 
due to modification time mismatch or not being able to locate the N_OSO file.

This patch adds an new API to SBValueList:

  lldb::SBError lldb::SBValueList::GetError();

object so that if you request a stack frame's variables using SBValueList 
SBFrame::GetVariables(...), you can get an error the describes why the 
variables were not available.

This patch adds the ability to get an error back when requesting variables from 
a lldb_private::StackFrame when calling GetVariableList.

It also now shows an error in response to "frame variable" if we have debug 
info and are unable to get varialbes due to an error as mentioned above:

(lldb) frame variable
error: "a.o" object from the "/tmp/libfoo.a" archive: either the .o file 
doesn't exist in the archive or the modification time (0x63111541) of the .o 
file doesn't match

Reviewers: labath JDevlieghere aadsm yinghuitan jdoerfert sscalpone

Subscribers:

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

Added: 


Modified: 
lldb/bindings/interface/SBValueList.i
lldb/include/lldb/API/SBError.h
lldb/include/lldb/API/SBValueList.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Target/StackFrame.h
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBFrame.cpp
lldb/source/API/SBValueList.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Symbol/Variable.cpp
lldb/source/Target/StackFrame.cpp
lldb/test/API/commands/frame/var/TestFrameVar.py
lldb/test/API/functionalities/archives/Makefile
lldb/test/API/functionalities/archives/TestBSDArchives.py

Removed: 




diff  --git a/lldb/bindings/interface/SBValueList.i 
b/lldb/bindings/interface/SBValueList.i
index 76fa937b98764..32543af17413b 100644
--- a/lldb/bindings/interface/SBValueList.i
+++ b/lldb/bindings/interface/SBValueList.i
@@ -102,6 +102,8 @@ public:
 lldb::SBValue
 GetFirstValueByName (const char* name) const;
 
+lldb::SBError GetError();
+
 %extend {
%nothreadallow;
std::string lldb::SBValueList::__str__ (){

diff  --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index f8289e2fcbb3a..b34014aecc441 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -64,6 +64,7 @@ class LLDB_API SBError {
   friend class SBCommunication;
   friend class SBData;
   friend class SBDebugger;
+  friend class SBFile;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;
@@ -73,8 +74,8 @@ class LLDB_API SBError {
   friend class SBThread;
   friend class SBTrace;
   friend class SBValue;
+  friend class SBValueList;
   friend class SBWatchpoint;
-  friend class SBFile;
 
   friend class lldb_private::ScriptInterpreter;
 

diff  --git a/lldb/include/lldb/API/SBValueList.h 
b/lldb/include/lldb/API/SBValueList.h
index dc8389b752938..a5017bccc5053 100644
--- a/lldb/include/lldb/API/SBValueList.h
+++ b/lldb/include/lldb/API/SBValueList.h
@@ -43,6 +43,33 @@ class LLDB_API SBValueList {
 
   const lldb::SBValueList =(const lldb::SBValueList );
 
+  // Get an error for why this list is empty.
+  //
+  // If this list is empty, check for an underlying error in the debug
+  // information that prevented this list from being populated. This is not
+  // meant to return an error if there is no debug information as it is ok for 
a
+  // value list to be empty and no error should be returned in that case. If 
the
+  // debug info is for an assembly file or language that doesn't have 

[Lldb-commits] [PATCH] D133623: Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Adrian: I added an extra compile unit into the YAML and verified it would fail 
without the fix. I also added the ability to select a different compile unit by 
index in the YAMLModuleTester so it can select the second compile unit in the 
test. Should be good to go now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133623

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


[Lldb-commits] [PATCH] D133623: Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 459551.
clayborg added a comment.

- Added the ability to select a compile unit by index to YAMLModuleTester
- Added an extra empty compile unit to the yaml for 
DWARFExpression::DW_OP_convert test to make sure we can trigger the previous bug
- Select the second compile unit that contains the DW_TAG_base_type entries we 
need for testing so the DWARF expressions succeed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133623

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
  lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h

Index: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
===
--- lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
+++ lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.h
@@ -33,7 +33,7 @@
 
 public:
   /// Parse the debug info sections from the YAML description.
-  YAMLModuleTester(llvm::StringRef yaml_data);
+  YAMLModuleTester(llvm::StringRef yaml_data, size_t cu_index = 0);
   DWARFUnit *GetDwarfUnit() const { return m_dwarf_unit; }
   lldb::ModuleSP GetModule() const { return m_module_sp; }
 };
Index: lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
===
--- lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
+++ lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp
@@ -14,7 +14,7 @@
 
 using namespace lldb_private;
 
-YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data) {
+YAMLModuleTester::YAMLModuleTester(llvm::StringRef yaml_data, size_t cu_index) {
   llvm::Expected File = TestFile::fromYaml(yaml_data);
   EXPECT_THAT_EXPECTED(File, llvm::Succeeded());
   m_file = std::move(*File);
@@ -22,5 +22,5 @@
   m_module_sp = std::make_shared(m_file->moduleSpec());
   auto  = *llvm::cast(m_module_sp->GetSymbolFile());
 
-  m_dwarf_unit = symfile.DebugInfo().GetUnitAtIndex(0);
+  m_dwarf_unit = symfile.DebugInfo().GetUnitAtIndex(cu_index);
 }
Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -61,6 +61,9 @@
 
 class DWARFExpressionTester : public YAMLModuleTester {
 public:
+  DWARFExpressionTester(llvm::StringRef yaml_data, size_t cu_index) :
+  YAMLModuleTester(yaml_data, cu_index) {}
+
   using YAMLModuleTester::YAMLModuleTester;
   llvm::Expected Eval(llvm::ArrayRef expr) {
 return ::Evaluate(expr, m_module_sp, m_dwarf_unit);
@@ -179,6 +182,17 @@
   debug_info:
 - Version: 4
   AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
+  Entries:
+- AbbrCode:0x0001
+  Values:
+- Value:   0x000C
+- AbbrCode:0x
+- Version: 4
+  AddrSize:8
+  AbbrevTableID:   0
+  AbbrOffset:  0x0
   Entries:
 - AbbrCode:0x0001
   Values:
@@ -214,14 +228,16 @@
 - Value:   0x000b # DW_ATE_numeric_string
 - Value:   0x0001
 - AbbrCode:0x
+
 )";
+  // Compile unit relative offsets to each DW_TAG_base_type
   uint8_t offs_uint32_t = 0x000e;
   uint8_t offs_uint64_t = 0x0011;
   uint8_t offs_sint64_t = 0x0014;
   uint8_t offs_uchar = 0x0017;
   uint8_t offs_schar = 0x001a;
 
-  DWARFExpressionTester t(yamldata);
+  DWARFExpressionTester t(yamldata, /*cu_index=*/1);
   ASSERT_TRUE((bool)t.GetDwarfUnit());
 
   // Constant is given as little-endian.
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2374,9 +2374,11 @@
   return false;
 }
   } else {
-// Retrieve the type DIE that the value is being converted to.
+// Retrieve the type DIE that the value is being converted to. This
+// offset is compile unit relative so we need to fix it up.
+const uint64_t abs_die_offset = die_offset +  dwarf_cu->GetOffset();
 // FIXME: the constness has annoying ripple effects.
-DWARFDIE die = const_cast(dwarf_cu)->GetDIE(die_offset);
+DWARFDIE die = const_cast(dwarf_cu)->GetDIE(abs_die_offset);
 if (!die) {
   if (error_ptr)
 error_ptr->SetErrorString("Cannot resolve DW_OP_convert type DIE");
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133164: Add the ability to show when variables fails to be available when debug info is valid.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

If anyone can accept this diff again it would be most appreciated, the only 
failing buildbot was windows and I added @skipIfWindows to the failing test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133164

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


[Lldb-commits] [PATCH] D133164: Add the ability to show when variables fails to be available when debug info is valid.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/test/API/commands/frame/var/TestFrameVar.py:166
+@skipIfRemote
+@skipIfWindows # Windows can't set breakpoints by name 'main' in this case.
+def test_gline_tables_only(self):

This is the line that will fix the windows buildbots.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133164

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


[Lldb-commits] [PATCH] D133164: Add the ability to show when variables fails to be available when debug info is valid.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 459545.
clayborg added a comment.

Added a @skipIfWindows to make on TestFrameVar.test_gline_tables_only as 
windows doesn't seem to be able to set a breakpoint by function name 'main' 
when debug info is -gline-tables-only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133164

Files:
  lldb/bindings/interface/SBValueList.i
  lldb/include/lldb/API/SBError.h
  lldb/include/lldb/API/SBValueList.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/StackFrame.h
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBFrame.cpp
  lldb/source/API/SBValueList.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Symbol/Variable.cpp
  lldb/source/Target/StackFrame.cpp
  lldb/test/API/commands/frame/var/TestFrameVar.py
  lldb/test/API/functionalities/archives/Makefile
  lldb/test/API/functionalities/archives/TestBSDArchives.py

Index: lldb/test/API/functionalities/archives/TestBSDArchives.py
===
--- lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -6,10 +6,16 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
-
+import os
+import time
 
 class BSDArchivesTestCase(TestBase):
 
+# If your test case doesn't stress debug info, then
+# set this to true.  That way it won't be run once for
+# each debug info format.
+NO_DEBUG_INFO_TESTCASE = True
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -17,8 +23,6 @@
 self.line = line_number(
 'a.c', '// Set file and line breakpoint inside a().')
 
-# Doesn't depend on any specific debug information.
-@no_debug_info_test
 @expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24527.  Makefile.rules doesn't know how to build static libs on Windows")
@@ -65,3 +69,80 @@
 num_specs = module_specs.GetSize()
 self.assertEqual(num_specs, 1)
 self.assertEqual(module_specs.GetSpecAtIndex(0).GetObjectName(), "c.o")
+
+
+def check_frame_variable_errors(self, thread, error_strings):
+command_result = lldb.SBCommandReturnObject()
+interp = self.dbg.GetCommandInterpreter()
+result = interp.HandleCommand("frame variable", command_result)
+self.assertEqual(result, lldb.eReturnStatusFailed,
+ "frame var succeeded unexpectedly")
+command_error = command_result.GetError()
+
+frame = thread.GetFrameAtIndex(0)
+var_list = frame.GetVariables(True, True, False, True)
+self.assertEqual(var_list.GetSize(), 0)
+api_error = var_list.GetError().GetCString()
+
+for s in error_strings:
+self.assertTrue(s in command_error, 'Make sure "%s" exists in the command error "%s"' % (s, command_error))
+for s in error_strings:
+self.assertTrue(s in api_error, 'Make sure "%s" exists in the API error "%s"' % (s, api_error))
+
+@skipIfRemote
+@skipUnlessDarwin
+def test_frame_var_errors_when_archive_missing(self):
+"""
+Break inside a() and remove libfoo.a to make sure we can't load
+the debug information and report an appropriate error when doing
+'frame variable'.
+"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+libfoo_path = self.getBuildArtifact("libfoo.a")
+# Delete the main.o file that contains the debug info so we force an
+# error when we run to main and try to get variables for the a()
+# function. Since the libfoo.a is missing, the debug info won't be
+# loaded and we should see an error when trying to read varibles.
+os.unlink(libfoo_path)
+
+(target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(
+self, 'a', bkpt_module=exe)
+
+error_strings = [
+'debug map object file "',
+'libfoo.a(a.o)" containing debug info does not exist, debug info will not be loaded'
+]
+self.check_frame_variable_errors(thread, error_strings)
+
+@skipIfRemote
+@skipUnlessDarwin
+def test_frame_var_errors_when_mtime_mistmatch_for_object_in_archive(self):
+  

[Lldb-commits] [PATCH] D133164: Add the ability to show when variables fails to be available when debug info is valid.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg reopened this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Reopen for submission with windows fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133164

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


[Lldb-commits] [PATCH] D133623: Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

unless yaml2obj doesn't support multi-CU `.debug_info` sections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133623

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


[Lldb-commits] [PATCH] D133623: Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

In D133623#3784604 , @clayborg wrote:

> In D133623#378 , @aprantl wrote:
>
>> You would need to modify or clone the existing test 
>> https://github.com/llvm/llvm-project/blob/38ffa2bb963714cd117b6d4534d328fa6a0fb875/lldb/unittests/Expression/DWARFExpressionTest.cpp#L153
>>  and add a second CU to it. The inlined text is just the output of obj2yaml.
>
> I believe you. The main question is how top get an object file to produce 
> this file in a small and simple test case. Are you saying it would be easy to 
> add another CU by just appending some yaml? Or do I need to come up with a 
> binary first that already has this in two CUs and then try to obj2yaml the 
> binary? If so, please let me know how to make code that does this.

Looking at the test, I think for someone familiar with the DWARF format ;-) 
manually extending yaml should be pretty straightforward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133623

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


[Lldb-commits] [lldb] 67c73d8 - Reland "[lldb] Use just-built libcxx for tests when available"

2022-09-12 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2022-09-12T15:32:25-04:00
New Revision: 67c73d88de0e6b095a5eca46016277e4ac66d52d

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

LOG: Reland "[lldb] Use just-built libcxx for tests when available"

This commit improves upon cc0b5ebf7fc8, which added support for
specifying which libcxx to use when testing LLDB. That patch honored
requests by tests that had `USE_LIBCPP=1` defined in their makefiles.
Now, we also use a non-default libcxx if all conditions below are true:

1. The test is not explicitly requesting the use of libstdcpp
(USE_LIBSTDCPP=1).
2. The test is not explicitly requesting the use of the system's
library (USE_SYSTEM_STDLIB=1).
3. A path to libcxx was either provided by the user through CMake flags
or libcxx was built together with LLDB.

Condition (2) is new and introduced in this patch in order to support
tests that are either:

* Cross-platform (such as API/macosx/macCatalyst and
API/tools/lldb-server). The just-built libcxx is usually not built for
platforms other than the host's.
* Cross-language (such as API/lang/objc/exceptions). In this case, the
Objective C runtime throws an exceptions that always goes through the
system's libcxx, instead of the just built libcxx. Fixing this would
require either changing the install-name of the just built libcxx in Mac
systems, or tuning the DYLD_LIBRARY_PATH variable at runtime.

Some other tests exposes limitations of LLDB when running with a debug
standard library. TestDbgInfoContentForwardLists had an assertion
removed, as it was checking for buggy LLDB behavior (which now
crashes). TestFixIts had a variable renamed, as the old name clashes
with a standard library name when debug info is present. This is a known
issue: https://github.com/llvm/llvm-project/issues/34391.

For `TestSBModule`, the way the "main" module is found was changed to
look for the "a.out" module, instead of relying on the index being 0. In
some systems, the index 0 is dyld when a custom standard library is
used.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/test/API/commands/expression/fixits/TestFixIts.py

lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
lldb/test/API/lang/objc/exceptions/Makefile
lldb/test/API/macosx/macCatalyst/Makefile
lldb/test/API/python_api/sbmodule/TestSBModule.py
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 937a2ae06fc44..c0fd5ecd0dc84 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -387,6 +387,16 @@ endif
 #--
 # C++ standard library options
 #--
+ifneq ($(and $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+   $(error Libcxx and Libstdc++ cannot be used together)
+endif
+
+ifeq (1, $(USE_SYSTEM_STDLIB))
+   ifneq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+   $(error Cannot use system's standard library and a custom 
standard library together)
+   endif
+endif
+
 ifeq (1,$(USE_LIBSTDCPP))
# Clang requires an extra flag: -stdlib=libstdc++
ifneq (,$(findstring clang,$(CC)))
@@ -415,6 +425,15 @@ ifeq (1,$(USE_LIBCPP))
endif
 endif
 
+# If no explicit request was made, but we have paths to a custom libcxx, use
+# them.
+ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), $(USE_SYSTEM_STDLIB)),)
+   ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
+   CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem 
$(LIBCPP_INCLUDE_DIR)
+   LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) 
-lc++
+   endif
+endif
+
 #--
 # Additional system libraries
 #--

diff  --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py 
b/lldb/test/API/commands/expression/fixits/TestFixIts.py
index bf4118d1b9d86..bcc7e61d5261c 100644
--- a/lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py
@@ -45,7 +45,7 @@ def test_with_target(self):
 
 # Try with one error in a top-level expression.
 # The Fix-It changes "ptr.m" to "ptr->m".
-expr = "struct X { int m; }; X x; X *ptr =  int m = ptr.m;"
+expr = "struct MyTy { int m; }; MyTy 

[Lldb-commits] [lldb] aedad60 - [LLDB][NativePDB] Add local variables with no location info.

2022-09-12 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2022-09-12T12:01:24-07:00
New Revision: aedad60231fcfd967f041616573caa7ff229e2b2

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

LOG: [LLDB][NativePDB] Add local variables with no location info.

If we don't add local variables with no location info, when trying to print it,
lldb won't find it in the its parent DeclContext, which makes lldb to spend more
time to search all the way up in DeclContext hierarchy until found same name
variable or failed. Dwarf plugin also add local vars even if they don't have
location info.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
index 387182cc46a97..695bb85e2b464 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
@@ -898,7 +898,6 @@ VariableInfo lldb_private::npdb::GetVariableLocationInfo(
   loc_specifier_id.modi,
   loc_specifier_id.offset + loc_specifier_cvs.RecordData.size());
 }
-result.location = DWARFExpressionList();
 for (const auto  : location_map) {
   DWARFExpression dwarf_expr =
   entry.data.is_dwarf ? entry.data.expr
@@ -906,7 +905,7 @@ VariableInfo lldb_private::npdb::GetVariableLocationInfo(
 entry.data.offset_to_location,
 offset_to_size, type_size, module);
 
-  result.location->AddExpression(entry.GetRangeBase(), entry.GetRangeEnd(),
+  result.location.AddExpression(entry.GetRangeBase(), entry.GetRangeEnd(),
  dwarf_expr);
 }
 return result;

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h 
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
index fa078ca061a8c..ee54c649d367f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
@@ -103,7 +103,7 @@ struct SegmentOffsetLength {
 struct VariableInfo {
   llvm::StringRef name;
   llvm::codeview::TypeIndex type;
-  llvm::Optional location;
+  DWARFExpressionList location;
   bool is_param;
 };
 

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 2781ae0c87abf..3bcebb6d46f63 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1729,12 +1729,14 @@ VariableSP 
SymbolFileNativePDB::CreateLocalVariable(PdbCompilandSymId scope_id,
   func_block->GetStartAddress(addr);
   VariableInfo var_info =
   GetVariableLocationInfo(*m_index, var_id, *func_block, module);
-  if (!var_info.location || var_info.location->GetSize() == 0)
-return nullptr;
   Function *func = func_block->CalculateSymbolContextFunction();
   if (!func)
-return VariableSP();
-  var_info.location->SetFuncFileAddress(
+return nullptr;
+  // Use empty dwarf expr if optimized away so that it won't be filtered out
+  // when lookuping local variables in this scope.
+  if (!var_info.location.IsValid())
+var_info.location = DWARFExpressionList(module, DWARFExpression(), 
nullptr);
+  var_info.location.SetFuncFileAddress(
   func->GetAddressRange().GetBaseAddress().GetFileAddress());
   CompilandIndexItem *cii = m_index->compilands().GetCompiland(var_id.modi);
   CompUnitSP comp_unit_sp = GetOrCreateCompileUnit(*cii);
@@ -1756,11 +1758,10 @@ VariableSP 
SymbolFileNativePDB::CreateLocalVariable(PdbCompilandSymId scope_id,
   Variable::RangeList scope_ranges;
   VariableSP var_sp = std::make_shared(
   toOpaqueUid(var_id), name.c_str(), name.c_str(), sftype, var_scope,
-  , scope_ranges, , *var_info.location, external, artificial,
+  , scope_ranges, , var_info.location, external, artificial,
   location_is_constant_data, static_member);
   if (!is_param)
 m_ast->GetOrCreateVariableDecl(scope_id, var_id);
-
   m_local_variables[toOpaqueUid(var_id)] = var_sp;
   return var_sp;
 }

diff  --git a/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test 
b/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
index 6fd4186e98846..cf82f8b493568 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
+++ b/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
@@ -71,6 +71,7 @@
 # CHECK: Blocks: id = {{.*}}, range = 

[Lldb-commits] [PATCH] D133626: [LLDB][NativePDB] Add local variables with no location info.

2022-09-12 Thread Zequan Wu via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaedad60231fc: [LLDB][NativePDB] Add local variables with no 
location info. (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133626

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test

Index: lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
===
--- lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
+++ lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
@@ -71,6 +71,7 @@
 # CHECK: Blocks: id = {{.*}}, range = [0x140001000-0x140001046)
 # CHECK-NEXT:id = {{.*}}, ranges = [0x140001004-0x140001039)[0x14000103f-0x140001046), name = "Namespace1::foo", decl = a.h:4
 # CHECK:   LineEntry: [0x000140001004-0x00014000100c): /tmp/a.h:5
+# CHECK-NEXT:  Variable: id = {{.*}}, name = "x", type = "int", valid ranges = , location = , decl =
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "foo_local", type = "int", valid ranges = , location = [0x000140001004, 0x000140001039) -> DW_OP_breg7 RSP+44
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "argc", type = "int", valid ranges = , location = [0x000140001000, 0x00014000102d) -> DW_OP_reg26 XMM9
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "argv", type = "char **", valid ranges = , location = [0x000140001000, 0x000140001045) -> DW_OP_reg3 RBX
@@ -83,6 +84,7 @@
 # CHECK: Blocks: id = {{.*}}, range = [0x140001000-0x140001046)
 # CHECK-NEXT:id = {{.*}}, ranges = [0x140001004-0x140001039)[0x14000103f-0x140001046), name = "Namespace1::foo", decl = a.h:4
 # CHECK:   LineEntry: [0x000140001010-0x000140001018): /tmp/a.h:7
+# CHECK-NEXT:  Variable: id = {{.*}}, name = "x", type = "int", valid ranges = , location = , decl =
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "foo_local", type = "int", valid ranges = , location = [0x000140001004, 0x000140001039) -> DW_OP_breg7 RSP+44
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "argc", type = "int", valid ranges = , location = [0x000140001000, 0x00014000102d) -> DW_OP_reg26 XMM9
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "argv", type = "char **", valid ranges = , location = [0x000140001000, 0x000140001045) -> DW_OP_reg3 RBX
@@ -99,6 +101,7 @@
 # CHECK:   LineEntry: [0x00014000101c-0x000140001022): /tmp/b.h:5
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "x", type = "int", valid ranges = , location = [0x00014000101c, 0x00014000101e) -> DW_OP_reg24 XMM7
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "bar_local", type = "int", valid ranges = , location = [0x00014000101c, 0x000140001039) -> DW_OP_breg7 RSP+52
+# CHECK-NEXT:  Variable: id = {{.*}}, name = "x", type = "int", valid ranges = , location = , decl =
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "foo_local", type = "int", valid ranges = , location = [0x000140001004, 0x000140001039) -> DW_OP_breg7 RSP+44
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "argc", type = "int", valid ranges = , location = [0x000140001000, 0x00014000102d) -> DW_OP_reg26 XMM9
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "argv", type = "char **", valid ranges = , location = [0x000140001000, 0x000140001045) -> DW_OP_reg3 RBX
@@ -118,6 +121,7 @@
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "x", type = "int", valid ranges = , location = [0x00014000102a, 0x000140001039) -> DW_OP_reg24 XMM7
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "func_local", type = "int", valid ranges = , location = [0x00014000102a, 0x000140001039) -> DW_OP_breg7 RSP+48
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "bar_local", type = "int", valid ranges = , location = [0x00014000101c, 0x000140001039) -> DW_OP_breg7 RSP+52
+# CHECK-NEXT:  Variable: id = {{.*}}, name = "x", type = "int", valid ranges = , location = , decl =
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "foo_local", type = "int", valid ranges = , location = [0x000140001004, 0x000140001039) -> DW_OP_breg7 RSP+44
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "argc", type = "int", valid ranges = , location = [0x000140001000, 0x00014000102d) -> DW_OP_reg26 XMM9
 # CHECK-NEXT:  Variable: id = {{.*}}, name = "argv", type = "char **", valid ranges = , location = [0x000140001000, 0x000140001045) -> DW_OP_reg3 RBX
@@ -138,6 +142,7 @@
 # CHECK: Blocks: id = {{.*}}, range = [0x140001000-0x140001046)
 # CHECK-NEXT:id = {{.*}}, ranges = [0x140001004-0x140001039)[0x14000103f-0x140001046), name = "Namespace1::foo", decl = a.h:4
 # CHECK:   LineEntry: [0x000140001044-0x000140001046): /tmp/a.h:8

[Lldb-commits] [PATCH] D133164: Add the ability to show when variables fails to be available when debug info is valid.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Yikes, looks like you can't set a breakpoint by name 'main' on windows... I 
will add a skipIfWindows to the failing test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133164

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


[Lldb-commits] [PATCH] D133623: Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D133623#378 , @aprantl wrote:

> You would need to modify or clone the existing test 
> https://github.com/llvm/llvm-project/blob/38ffa2bb963714cd117b6d4534d328fa6a0fb875/lldb/unittests/Expression/DWARFExpressionTest.cpp#L153
>  and add a second CU to it. The inlined text is just the output of obj2yaml.

I believe you. The main question is how top get an object file to produce this 
file in a small and simple test case. Are you saying it would be easy to add 
another CU by just appending some yaml? Or do I need to come up with a binary 
first that already has this in two CUs and then try to obj2yaml the binary? If 
so, please let me know how to make code that does this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133623

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


[Lldb-commits] [lldb] 3271466 - Revert "Add the ability to show when variables fails to be available when debug info is valid."

2022-09-12 Thread Stella Stamenova via lldb-commits

Author: Stella Stamenova
Date: 2022-09-12T11:31:17-07:00
New Revision: 327146639c049f3cff13c94ec44c12aa718b9fe4

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

LOG: Revert "Add the ability to show when variables fails to be available when 
debug info is valid."

This reverts commit 9af089f5179d52c6561ec27532880edcfb6253af.

This broke the windows lldb bot: 
https://lab.llvm.org/buildbot/#/builders/83/builds/23528

Added: 


Modified: 
lldb/bindings/interface/SBValueList.i
lldb/include/lldb/API/SBError.h
lldb/include/lldb/API/SBValueList.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Target/StackFrame.h
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBFrame.cpp
lldb/source/API/SBValueList.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Symbol/Variable.cpp
lldb/source/Target/StackFrame.cpp
lldb/test/API/commands/frame/var/TestFrameVar.py
lldb/test/API/functionalities/archives/Makefile
lldb/test/API/functionalities/archives/TestBSDArchives.py

Removed: 




diff  --git a/lldb/bindings/interface/SBValueList.i 
b/lldb/bindings/interface/SBValueList.i
index 32543af17413b..76fa937b98764 100644
--- a/lldb/bindings/interface/SBValueList.i
+++ b/lldb/bindings/interface/SBValueList.i
@@ -102,8 +102,6 @@ public:
 lldb::SBValue
 GetFirstValueByName (const char* name) const;
 
-lldb::SBError GetError();
-
 %extend {
%nothreadallow;
std::string lldb::SBValueList::__str__ (){

diff  --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index b34014aecc441..f8289e2fcbb3a 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -64,7 +64,6 @@ class LLDB_API SBError {
   friend class SBCommunication;
   friend class SBData;
   friend class SBDebugger;
-  friend class SBFile;
   friend class SBHostOS;
   friend class SBPlatform;
   friend class SBProcess;
@@ -74,8 +73,8 @@ class LLDB_API SBError {
   friend class SBThread;
   friend class SBTrace;
   friend class SBValue;
-  friend class SBValueList;
   friend class SBWatchpoint;
+  friend class SBFile;
 
   friend class lldb_private::ScriptInterpreter;
 

diff  --git a/lldb/include/lldb/API/SBValueList.h 
b/lldb/include/lldb/API/SBValueList.h
index a5017bccc5053..dc8389b752938 100644
--- a/lldb/include/lldb/API/SBValueList.h
+++ b/lldb/include/lldb/API/SBValueList.h
@@ -43,33 +43,6 @@ class LLDB_API SBValueList {
 
   const lldb::SBValueList =(const lldb::SBValueList );
 
-  // Get an error for why this list is empty.
-  //
-  // If this list is empty, check for an underlying error in the debug
-  // information that prevented this list from being populated. This is not
-  // meant to return an error if there is no debug information as it is ok for 
a
-  // value list to be empty and no error should be returned in that case. If 
the
-  // debug info is for an assembly file or language that doesn't have any
-  // variables, no error should be returned.
-  //
-  // This is designed as a way to let users know when they enable certain
-  // compiler options that enable debug information but provide a degraded
-  // debug information content, like -gline-tables-only, which is a compiler
-  // option that allows users to set file and line breakpoints, but users get
-  // confused when no variables show up during debugging.
-  //
-  // It is also designed to inform a user that debug information might be
-  // available if an external file, like a .dwo file, but that file doesn't
-  // exist or wasn't able to be loaded due to a mismatched ID. When debugging
-  // with fission enabled, the line tables are linked into the main executable,
-  // but if the .dwo or .dwp files are not available or have been modified,
-  // users can get confused if they can stop at a file and line breakpoint but
-  // can't see variables in this case.
-  //
-  // This error can give vital clues to the user about the cause is and allow
-  // the user to fix the issue.
-  lldb::SBError GetError();
-
 protected:
   // only useful for visualizing the pointer or comparing two SBValueLists to
   // see if they are backed by the same underlying Impl.
@@ -95,8 +68,6 @@ class 

[Lldb-commits] [PATCH] D131122: [lldb] Fixed a number of typos

2022-09-12 Thread Gabriel Ravier via Phabricator via lldb-commits
GabrielRavier added a comment.

Btw just so you know, I do not have commit access to LLVM so I cannot land this 
revision myself (I've also been told I should tell you my usual handle on git 
is `Gabriel Ravier ` w.r.t. that)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131122

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


[Lldb-commits] [PATCH] D133623: Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Thorsten via Phabricator via lldb-commits
tschuett added inline comments.



Comment at: lldb/source/Expression/DWARFExpression.cpp:2379
+// offset is compile unit relative so we need to fix it up.
+die_offset += dwarf_cu->GetOffset();
 // FIXME: the constness has annoying ripple effects.

Do you need to give up the const or:
```
descriptive_offset = die_offset + dwarf_cu->GetOffset();
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133623

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


[Lldb-commits] [PATCH] D133689: [lldb] Add SBBreakpointLocation::SetCallback

2022-09-12 Thread Andy Yankovsky via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f5d109fca23: [lldb] Add SBBreakpointLocation::SetCallback 
(authored by lauralcg, committed by werat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133689

Files:
  lldb/include/lldb/API/SBBreakpointLocation.h
  lldb/source/API/SBBreakpointLocation.cpp
  lldb/test/API/api/multithreaded/TestMultithreaded.py
  lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template

Index: lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template
===
--- /dev/null
+++ lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template
@@ -0,0 +1,52 @@
+
+// LLDB C++ API Test: verify that the function registered with
+// SBBreakpoint.SetCallback() is invoked when a breakpoint is hit.
+
+#include 
+#include 
+#include 
+#include 
+
+%include_SB_APIs%
+
+#include "common.h"
+
+using namespace std;
+using namespace lldb;
+
+mutex g_mutex;
+condition_variable g_condition;
+int g_breakpoint_hit_count = 0;
+
+bool BPCallback (void *baton,
+ SBProcess ,
+ SBThread ,
+ SBBreakpointLocation ) {
+  lock_guard lock(g_mutex);
+  g_breakpoint_hit_count += 1;
+  g_condition.notify_all();
+  return true;
+}
+
+void test(SBDebugger , vector args) {
+  dbg.SetAsync(false);
+  SBTarget target = dbg.CreateTarget(args.at(0).c_str());
+  if (!target.IsValid()) throw Exception("invalid target");
+
+  SBBreakpoint breakpoint = target.BreakpointCreateByName("next");
+  if (!breakpoint.IsValid()) throw Exception("invalid breakpoint");
+
+  if(breakpoint.GetNumLocations() != 1) throw Exception("unexpected amount of breakpoint locations");
+  SBBreakpointLocation breakpoint_location = breakpoint.GetLocationAtIndex(0);
+  breakpoint_location.SetCallback(BPCallback, 0);
+
+  std::unique_ptr working_dir(get_working_dir());
+  SBProcess process = target.LaunchSimple (0, 0, working_dir.get());
+
+  {
+unique_lock lock(g_mutex);
+g_condition.wait_for(lock, chrono::seconds(5));
+if (g_breakpoint_hit_count != 1)
+  throw Exception("Breakpoint hit count expected to be 1");
+  }
+}
Index: lldb/test/API/api/multithreaded/TestMultithreaded.py
===
--- lldb/test/API/api/multithreaded/TestMultithreaded.py
+++ lldb/test/API/api/multithreaded/TestMultithreaded.py
@@ -18,6 +18,7 @@
 self.generateSource('driver.cpp')
 self.generateSource('listener_test.cpp')
 self.generateSource('test_breakpoint_callback.cpp')
+self.generateSource('test_breakpoint_location_callback.cpp')
 self.generateSource('test_listener_event_description.cpp')
 self.generateSource('test_listener_event_process_state.cpp')
 self.generateSource('test_listener_resume.cpp')
@@ -41,6 +42,15 @@
 self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
 'test_breakpoint_callback')
 
+@skipIfRemote
+@skipIfNoSBHeaders
+# clang-cl does not support throw or catch (llvm.org/pr24538)
+@skipIfWindows
+def test_breakpoint_location_callback(self):
+"""Test the that SBBreakpointLocation callback is invoked when a breakpoint is hit. """
+self.build_and_test('driver.cpp test_breakpoint_location_callback.cpp',
+'test_breakpoint_location_callback')
+
 @skipIfRemote
 @skipIfNoSBHeaders
 # clang-cl does not support throw or catch (llvm.org/pr24538)
Index: lldb/source/API/SBBreakpointLocation.cpp
===
--- lldb/source/API/SBBreakpointLocation.cpp
+++ lldb/source/API/SBBreakpointLocation.cpp
@@ -28,6 +28,8 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "SBBreakpointOptionCommon.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -198,6 +200,21 @@
   return false;
 }
 
+void SBBreakpointLocation::SetCallback(SBBreakpointHitCallback callback,
+   void *baton) {
+  LLDB_INSTRUMENT_VA(this, callback, baton);
+
+  BreakpointLocationSP loc_sp = GetSP();
+
+  if (loc_sp) {
+std::lock_guard guard(
+loc_sp->GetTarget().GetAPIMutex());
+BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
+loc_sp->SetCallback(SBBreakpointCallbackBaton::PrivateBreakpointHitCallback,
+baton_sp, false);
+  }
+}
+
 void SBBreakpointLocation::SetScriptCallbackFunction(
   const char *callback_function_name) {
   LLDB_INSTRUMENT_VA(this, callback_function_name);
Index: lldb/include/lldb/API/SBBreakpointLocation.h
===
--- lldb/include/lldb/API/SBBreakpointLocation.h
+++ 

[Lldb-commits] [lldb] 6f5d109 - [lldb] Add SBBreakpointLocation::SetCallback

2022-09-12 Thread Andy Yankovsky via lldb-commits

Author: Laura Chaparro-Gutierrez
Date: 2022-09-12T17:44:02Z
New Revision: 6f5d109fca23056dd74d673d2e3439ece22c80b4

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

LOG: [lldb] Add SBBreakpointLocation::SetCallback

* Include SetCallback in SBBreakpointLocation, similar as in SBBreakpoint.
* Add test_breakpoint_location_callback test as part of TestMultithreaded.

Reviewed By: werat, JDevlieghere

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

Co-authored-by: Andy Yankovsky 

Added: 

lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template

Modified: 
lldb/include/lldb/API/SBBreakpointLocation.h
lldb/source/API/SBBreakpointLocation.cpp
lldb/test/API/api/multithreaded/TestMultithreaded.py

Removed: 




diff  --git a/lldb/include/lldb/API/SBBreakpointLocation.h 
b/lldb/include/lldb/API/SBBreakpointLocation.h
index a906727f938a3..ca29696065eab 100644
--- a/lldb/include/lldb/API/SBBreakpointLocation.h
+++ b/lldb/include/lldb/API/SBBreakpointLocation.h
@@ -48,11 +48,13 @@ class LLDB_API SBBreakpointLocation {
   void SetCondition(const char *condition);
 
   const char *GetCondition();
-   
+
   void SetAutoContinue(bool auto_continue);
 
   bool GetAutoContinue();
 
+  void SetCallback(SBBreakpointHitCallback callback, void *baton);
+
   void SetScriptCallbackFunction(const char *callback_function_name);
 
   SBError SetScriptCallbackFunction(const char *callback_function_name,

diff  --git a/lldb/source/API/SBBreakpointLocation.cpp 
b/lldb/source/API/SBBreakpointLocation.cpp
index 6c03aba15447f..a253530f5718b 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -28,6 +28,8 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "SBBreakpointOptionCommon.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -198,6 +200,21 @@ bool SBBreakpointLocation::GetAutoContinue() {
   return false;
 }
 
+void SBBreakpointLocation::SetCallback(SBBreakpointHitCallback callback,
+   void *baton) {
+  LLDB_INSTRUMENT_VA(this, callback, baton);
+
+  BreakpointLocationSP loc_sp = GetSP();
+
+  if (loc_sp) {
+std::lock_guard guard(
+loc_sp->GetTarget().GetAPIMutex());
+BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
+
loc_sp->SetCallback(SBBreakpointCallbackBaton::PrivateBreakpointHitCallback,
+baton_sp, false);
+  }
+}
+
 void SBBreakpointLocation::SetScriptCallbackFunction(
   const char *callback_function_name) {
   LLDB_INSTRUMENT_VA(this, callback_function_name);

diff  --git a/lldb/test/API/api/multithreaded/TestMultithreaded.py 
b/lldb/test/API/api/multithreaded/TestMultithreaded.py
index 231eb9ffefc42..33759906243a4 100644
--- a/lldb/test/API/api/multithreaded/TestMultithreaded.py
+++ b/lldb/test/API/api/multithreaded/TestMultithreaded.py
@@ -18,6 +18,7 @@ def setUp(self):
 self.generateSource('driver.cpp')
 self.generateSource('listener_test.cpp')
 self.generateSource('test_breakpoint_callback.cpp')
+self.generateSource('test_breakpoint_location_callback.cpp')
 self.generateSource('test_listener_event_description.cpp')
 self.generateSource('test_listener_event_process_state.cpp')
 self.generateSource('test_listener_resume.cpp')
@@ -41,6 +42,15 @@ def test_breakpoint_callback(self):
 self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
 'test_breakpoint_callback')
 
+@skipIfRemote
+@skipIfNoSBHeaders
+# clang-cl does not support throw or catch (llvm.org/pr24538)
+@skipIfWindows
+def test_breakpoint_location_callback(self):
+"""Test the that SBBreakpointLocation callback is invoked when a 
breakpoint is hit. """
+self.build_and_test('driver.cpp test_breakpoint_location_callback.cpp',
+'test_breakpoint_location_callback')
+
 @skipIfRemote
 @skipIfNoSBHeaders
 # clang-cl does not support throw or catch (llvm.org/pr24538)

diff  --git 
a/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template
 
b/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template
new file mode 100644
index 0..0b0dc5652e850
--- /dev/null
+++ 
b/lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template
@@ -0,0 +1,52 @@
+
+// LLDB C++ API Test: verify that the function registered with
+// SBBreakpoint.SetCallback() is invoked when a breakpoint is hit.
+
+#include 
+#include 
+#include 
+#include 
+
+%include_SB_APIs%
+
+#include "common.h"
+
+using namespace std;
+using namespace lldb;
+
+mutex g_mutex;
+condition_variable g_condition;
+int 

[Lldb-commits] [PATCH] D133623: Fix DW_OP_convert to resolve the CU relative offset correctly.

2022-09-12 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

You would need to modify or clone the existing test 
https://github.com/llvm/llvm-project/blob/38ffa2bb963714cd117b6d4534d328fa6a0fb875/lldb/unittests/Expression/DWARFExpressionTest.cpp#L153
 and add a second CU to it. The inlined text is just the output of obj2yaml.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133623

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


[Lldb-commits] [PATCH] D133038: Add SBDebugger::GetSetting() public API

2022-09-12 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan added inline comments.



Comment at: lldb/include/lldb/Interpreter/OptionValue.h:86-87
 
+  // TODO: make this function pure virtual after implementing it in all
+  // child classes.
+  virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) {

JDevlieghere wrote:
> Is this done?
No. My goal is simply adding a public API for testing auto deduce source map 
feature, this patch is much larger than I wanted to achieve so it focuses 
adding skeleton of the API and implements a subset of OptionValue child classes 
leaving the remaining for future patches (the implementation is not hard but 
adding test coverage takes some time). 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133038

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


[Lldb-commits] [PATCH] D132954: lldb: Add support for R_386_32 relocations to ObjectFileELF

2022-09-12 Thread David M. Lary via Phabricator via lldb-commits
dmlary added a comment.

Could someone please merge this?  I do not have commit access.


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

https://reviews.llvm.org/D132954

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


[Lldb-commits] [lldb] 8599cb0 - Skip crashing test

2022-09-12 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2022-09-12T09:48:42-07:00
New Revision: 8599cb002b635bb6bedeaebe622be333d579697b

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

LOG: Skip crashing test

Added: 


Modified: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py
index 3236544e21859..e37f1a9799fca 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py
@@ -44,6 +44,7 @@ def check_numbers(self, var_name):
 
 @add_test_categories(['libc++'])
 @skipIf(compiler='clang', compiler_version=['<', '11.0'])
+@skipIf(debug_info='gmodules', bugnumber="rdar://99758046") # Crashes 
Clang while compiling module. 
 def test_with_run_command(self):
 """Test that std::span variables are formatted correctly when 
printed."""
 self.build()
@@ -135,6 +136,7 @@ def test_with_run_command(self):
 
 @add_test_categories(['libc++'])
 @skipIf(compiler='clang', compiler_version=['<', '11.0'])
+@skipIf(debug_info='gmodules', bugnumber="rdar://99758046") # Crashes 
Clang while compiling module. 
 def test_ref_and_ptr(self):
 """Test that std::span is correctly formatted when passed by ref and 
ptr"""
 self.build()



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


[Lldb-commits] [PATCH] D133639: [lldb] Fix detection of existing libcxx

2022-09-12 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc04749957f1: [lldb] Fix detection of existing libcxx 
(authored by fdeazeve).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133639

Files:
  lldb/test/API/lit.cfg.py
  lldb/test/API/lit.site.cfg.py.in


Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -31,7 +31,7 @@
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
-config.has_libcxx = '@LLDB_HAS_LIBCXX@'
+config.has_libcxx = @LLDB_HAS_LIBCXX@
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", 
"lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", 
"lldb-api")
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -171,10 +171,11 @@
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
-  if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
-dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
-dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
+if is_configured('has_libcxx') and config.has_libcxx:
+  if platform.system() != 'Windows':
+if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
+  dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
+  dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
 
 # Forward ASan-specific environment variables to tests, as a test may load an
 # ASan-ified dylib.


Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -31,7 +31,7 @@
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
-config.has_libcxx = '@LLDB_HAS_LIBCXX@'
+config.has_libcxx = @LLDB_HAS_LIBCXX@
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -171,10 +171,11 @@
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
-  if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
-dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
-dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
+if is_configured('has_libcxx') and config.has_libcxx:
+  if platform.system() != 'Windows':
+if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
+  dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
+  dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
 
 # Forward ASan-specific environment variables to tests, as a test may load an
 # ASan-ified dylib.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] fc04749 - [lldb] Fix detection of existing libcxx

2022-09-12 Thread Felipe de Azevedo Piovezan via lldb-commits

Author: Felipe de Azevedo Piovezan
Date: 2022-09-12T12:34:11-04:00
New Revision: fc04749957f17f42b1eab538fa3e68857034facb

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

LOG: [lldb] Fix detection of existing libcxx

The CMake variable LLDB_HAS_LIBCXX is passed to
`llvm_canonicalize_cmake_booleans`, which transforms TRUE/FALSE into
'1'/'0'. It also transforms undefined variables to '0'.

In particular, this means that the configuration script for LLDB API's
test always has _some_ value for the `has_libcxx` configuration:

```
config.has_libcxx = '@LLDB_HAS_LIBCXX@'
```

When deciding whether a libcxx exist, the testing scripts would only
check for the existence of `has_libcxx`, but not for its value. In other
words, because `if ('0')` is true in python we always think there is a
libcxx.

This was caught once D132940 was merged and most tests started to use
libcxx by default if `has_libcxx` is true.  Prior to that, no failures
were seen because only tests are marked with
`@add_test_categories(["libc++"])` would require a libcxx, and these
would be filtered out on builds without the libcxx target. Furthermore,
the MacOS bots always build libcxx.

We fix this by making `has_libcxx` a boolean (instead of a string) and
by checking its value in the test configuration.

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

Added: 


Modified: 
lldb/test/API/lit.cfg.py
lldb/test/API/lit.site.cfg.py.in

Removed: 




diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 51309d5d384ae..e9a4e36be1d6a 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -171,10 +171,11 @@ def delete_module_cache(path):
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
-  if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
-dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
-dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
+if is_configured('has_libcxx') and config.has_libcxx:
+  if platform.system() != 'Windows':
+if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
+  dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
+  dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
 
 # Forward ASan-specific environment variables to tests, as a test may load an
 # ASan-ified dylib.

diff  --git a/lldb/test/API/lit.site.cfg.py.in 
b/lldb/test/API/lit.site.cfg.py.in
index d10a91d2af1ed..ca8354ddc069a 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -31,7 +31,7 @@ config.lldb_executable = 
lit_config.substitute('@LLDB_TEST_EXECUTABLE@')
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
-config.has_libcxx = '@LLDB_HAS_LIBCXX@'
+config.has_libcxx = @LLDB_HAS_LIBCXX@
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", 
"lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", 
"lldb-api")



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


[Lldb-commits] [PATCH] D133639: [lldb] Fix detection of existing libcxx

2022-09-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133639

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


[Lldb-commits] [PATCH] D133639: [lldb] Fix detection of existing libcxx

2022-09-12 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve updated this revision to Diff 459474.
fdeazeve edited the summary of this revision.
fdeazeve added a comment.

Addressed review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133639

Files:
  lldb/test/API/lit.cfg.py
  lldb/test/API/lit.site.cfg.py.in


Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -31,7 +31,7 @@
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
-config.has_libcxx = '@LLDB_HAS_LIBCXX@'
+config.has_libcxx = @LLDB_HAS_LIBCXX@
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", 
"lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", 
"lldb-api")
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -171,10 +171,11 @@
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
-  if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
-dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
-dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
+if is_configured('has_libcxx') and config.has_libcxx:
+  if platform.system() != 'Windows':
+if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
+  dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
+  dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
 
 # Forward ASan-specific environment variables to tests, as a test may load an
 # ASan-ified dylib.


Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -31,7 +31,7 @@
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
-config.has_libcxx = '@LLDB_HAS_LIBCXX@'
+config.has_libcxx = @LLDB_HAS_LIBCXX@
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -171,10 +171,11 @@
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
-  if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
-dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
-dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
+if is_configured('has_libcxx') and config.has_libcxx:
+  if platform.system() != 'Windows':
+if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
+  dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
+  dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
 
 # Forward ASan-specific environment variables to tests, as a test may load an
 # ASan-ified dylib.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133038: Add SBDebugger::GetSetting() public API

2022-09-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/Core/UserSettingsController.h:62-64
   virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx,
- Stream , uint32_t dump_mask);
+ Stream , uint32_t dump_mask,
+ bool is_json = false);

A flag doesn't scale if we ever decide we need another format. An enum would 
solve that and would eliminate the need for a comment `/*is_json=*/. I think 
the two values could be `Plain` (or `Text`) and `JSON`. 



Comment at: lldb/include/lldb/Interpreter/OptionValue.h:86-87
 
+  // TODO: make this function pure virtual after implementing it in all
+  // child classes.
+  virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) {

Is this done?



Comment at: lldb/source/Core/UserSettingsController.cpp:63
+  if (is_json) {
+llvm::json::Value json = properties_sp->ToJSON(exe_ctx);
+strm.Printf("%s", llvm::formatv("{0:2}", json).str().c_str());

Earlier you said that `ToJSON` should never return NULL. We should enforce that 
with an assert here.



Comment at: lldb/source/Interpreter/OptionValueArray.cpp:80-81
+  llvm::json::Array json_array;
+  const uint32_t size = m_values.size();
+  for (uint32_t i = 0; i < size; ++i)
+json_array.emplace_back(m_values[i]->ToJSON(exe_ctx));





Comment at: lldb/source/Interpreter/OptionValueDictionary.cpp:89-91
+  for (const auto  : m_values) {
+dict.try_emplace(value.first.GetCString(), value.second->ToJSON(exe_ctx));
+  }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133038

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


[Lldb-commits] [PATCH] D133689: [lldb] Add SBBreakpointLocation::SetCallback

2022-09-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133689

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


[Lldb-commits] [PATCH] D133639: [lldb] Fix detection of existing libcxx

2022-09-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/test/API/lit.cfg.py:181-184
+if is_configured_and_true('has_libcxx') and platform.system() != 'Windows':
   if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
 dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
 dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]

fdeazeve wrote:
> JDevlieghere wrote:
> > Are there other places where this helper would be useful? If not I think we 
> > can check the value directly. With the helper we lose a little bit of 
> > signal (if it returns false, was it not configured or set to false?). I 
> > don't think it's a big deal, but those two things combined make me favor 
> > inlining the check. 
> I agree that inlining is better here, but note that `config.has_libcxx` 
> doesn't work, this is still going to return `True`: `config.has_libcxx` is a 
> string, not a boolean, so anything `!= None` -- in particular '0' -- will 
> evaluate to true.
> 
> There are two ways to inline this: 
> 
> 1.`is_configured('has_libcxx') and config.has_libcxx == '1'`
> 2.`is_configured('has_libcxx') == '1'`
> 
> Actually, since `has_libcxx` comes from a canonicalized variable (in the 
> sense described in the commit message), we could also just do:
> 
> 3.`config.has_libcxx == '1'`
> 
> 
> What do you think?
> 
> Related: in a separate patch I think we should change the implementation of 
> `is_configured` to compare against None, so that it returns a boolean.
Aha, if `has_libcxx` is a string then that's a bug. It should be `0` or `1` 
like `config.shared_libs` and `config.lldb_enable_python`. Seems like someone 
(me) unintentionally added quotes. 

This should fix that:

```
-config.has_libcxx = '@LLDB_HAS_LIBCXX@'
+config.has_libcxx = @LLDB_HAS_LIBCXX@

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133639

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


[Lldb-commits] [PATCH] D133689: [lldb] Add SBBreakpointLocation::SetCallback

2022-09-12 Thread Andy Yankovsky via Phabricator via lldb-commits
werat accepted this revision.
werat added a comment.
This revision is now accepted and ready to land.

Look good to me, but giving some time for others to take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133689

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


[Lldb-commits] [PATCH] D133639: [lldb] Fix detection of existing libcxx

2022-09-12 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve updated this revision to Diff 459441.
fdeazeve added a comment.

Addressed review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133639

Files:
  lldb/test/API/lit.cfg.py


Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -91,6 +91,13 @@
   This allows us to check if the attribute exists before trying to access 
it."""
   return getattr(config, attr, None)
 
+def is_configured_and_true(attr):
+  """Returns true if and only if the configuration attribute exists and it is
+  set to'1'.
+
+  This is useful when checking CMake variables that have been cannonicalized to
+  0/1."""
+  return getattr(config, attr, None) == '1'
 
 def delete_module_cache(path):
   """Clean the module caches in the test build directory.
@@ -171,10 +178,11 @@
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
-  if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
-dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
-dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
+if is_configured('has_libcxx') and config.has_libcxx == '1':
+  if platform.system() != 'Windows':
+if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
+  dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
+  dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
 
 # Forward ASan-specific environment variables to tests, as a test may load an
 # ASan-ified dylib.


Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -91,6 +91,13 @@
   This allows us to check if the attribute exists before trying to access it."""
   return getattr(config, attr, None)
 
+def is_configured_and_true(attr):
+  """Returns true if and only if the configuration attribute exists and it is
+  set to'1'.
+
+  This is useful when checking CMake variables that have been cannonicalized to
+  0/1."""
+  return getattr(config, attr, None) == '1'
 
 def delete_module_cache(path):
   """Clean the module caches in the test build directory.
@@ -171,10 +178,11 @@
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
-  if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
-dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
-dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
+if is_configured('has_libcxx') and config.has_libcxx == '1':
+  if platform.system() != 'Windows':
+if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
+  dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
+  dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
 
 # Forward ASan-specific environment variables to tests, as a test may load an
 # ASan-ified dylib.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133689: LLDB: Add SBBreakpointLocation::SetCallback

2022-09-12 Thread Laura Chaparro Gutiérrez via Phabricator via lldb-commits
lauralcg created this revision.
lauralcg added a reviewer: werat.
Herald added a project: All.
lauralcg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

- Include SetCallback in SBBreakpointLocation, similar as in

SBBreakpointLocation.

- Add test_breakpoint_location_callback test as part of

TestMultithreaded.

Change-Id: I266e960b37a6e5fbe42d6a6386ed56247272c56c


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133689

Files:
  lldb/include/lldb/API/SBBreakpointLocation.h
  lldb/source/API/SBBreakpointLocation.cpp
  lldb/test/API/api/multithreaded/TestMultithreaded.py
  lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template

Index: lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template
===
--- /dev/null
+++ lldb/test/API/api/multithreaded/test_breakpoint_location_callback.cpp.template
@@ -0,0 +1,52 @@
+
+// LLDB C++ API Test: verify that the function registered with
+// SBBreakpoint.SetCallback() is invoked when a breakpoint is hit.
+
+#include 
+#include 
+#include 
+#include 
+
+%include_SB_APIs%
+
+#include "common.h"
+
+using namespace std;
+using namespace lldb;
+
+mutex g_mutex;
+condition_variable g_condition;
+int g_breakpoint_hit_count = 0;
+
+bool BPCallback (void *baton,
+ SBProcess ,
+ SBThread ,
+ SBBreakpointLocation ) {
+  lock_guard lock(g_mutex);
+  g_breakpoint_hit_count += 1;
+  g_condition.notify_all();
+  return true;
+}
+
+void test(SBDebugger , vector args) {
+  dbg.SetAsync(false);
+  SBTarget target = dbg.CreateTarget(args.at(0).c_str());
+  if (!target.IsValid()) throw Exception("invalid target");
+
+  SBBreakpoint breakpoint = target.BreakpointCreateByName("next");
+  if (!breakpoint.IsValid()) throw Exception("invalid breakpoint");
+
+  if(breakpoint.GetNumLocations() != 1) throw Exception("unexpected amount of breakpoint locations");
+  SBBreakpointLocation breakpoint_location = breakpoint.GetLocationAtIndex(0);
+  breakpoint_location.SetCallback(BPCallback, 0);
+
+  std::unique_ptr working_dir(get_working_dir());
+  SBProcess process = target.LaunchSimple (0, 0, working_dir.get());
+
+  {
+unique_lock lock(g_mutex);
+g_condition.wait_for(lock, chrono::seconds(5));
+if (g_breakpoint_hit_count != 1)
+  throw Exception("Breakpoint hit count expected to be 1");
+  }
+}
Index: lldb/test/API/api/multithreaded/TestMultithreaded.py
===
--- lldb/test/API/api/multithreaded/TestMultithreaded.py
+++ lldb/test/API/api/multithreaded/TestMultithreaded.py
@@ -20,6 +20,7 @@
 self.generateSource('driver.cpp')
 self.generateSource('listener_test.cpp')
 self.generateSource('test_breakpoint_callback.cpp')
+self.generateSource('test_breakpoint_location_callback.cpp')
 self.generateSource('test_listener_event_description.cpp')
 self.generateSource('test_listener_event_process_state.cpp')
 self.generateSource('test_listener_resume.cpp')
@@ -45,6 +46,15 @@
 self.build_and_test('driver.cpp test_breakpoint_callback.cpp',
 'test_breakpoint_callback')
 
+@skipIfRemote
+@skipIfNoSBHeaders
+# clang-cl does not support throw or catch (llvm.org/pr24538)
+@skipIfWindows
+def test_breakpoint_location_callback(self):
+"""Test the that SBBreakpointLocation callback is invoked when a breakpoint is hit. """
+self.build_and_test('driver.cpp test_breakpoint_location_callback.cpp',
+'test_breakpoint_location_callback')
+
 @skipIfRemote
 @skipIfNoSBHeaders
 # clang-cl does not support throw or catch (llvm.org/pr24538)
Index: lldb/source/API/SBBreakpointLocation.cpp
===
--- lldb/source/API/SBBreakpointLocation.cpp
+++ lldb/source/API/SBBreakpointLocation.cpp
@@ -28,6 +28,8 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "SBBreakpointOptionCommon.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -198,6 +200,21 @@
   return false;
 }
 
+void SBBreakpointLocation::SetCallback(SBBreakpointHitCallback callback,
+   void *baton) {
+  LLDB_INSTRUMENT_VA(this, callback, baton);
+
+  BreakpointLocationSP loc_sp = GetSP();
+
+  if (loc_sp) {
+std::lock_guard guard(
+loc_sp->GetTarget().GetAPIMutex());
+BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
+loc_sp->SetCallback(SBBreakpointCallbackBaton::PrivateBreakpointHitCallback,
+baton_sp, false);
+  }
+}
+
 void SBBreakpointLocation::SetScriptCallbackFunction(
   const char *callback_function_name) {
   LLDB_INSTRUMENT_VA(this, callback_function_name);
Index: lldb/include/lldb/API/SBBreakpointLocation.h

[Lldb-commits] [PATCH] D133639: [lldb] Fix detection of existing libcxx

2022-09-12 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added inline comments.



Comment at: lldb/test/API/lit.cfg.py:181-184
+if is_configured_and_true('has_libcxx') and platform.system() != 'Windows':
   if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
 dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
 dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]

JDevlieghere wrote:
> Are there other places where this helper would be useful? If not I think we 
> can check the value directly. With the helper we lose a little bit of signal 
> (if it returns false, was it not configured or set to false?). I don't think 
> it's a big deal, but those two things combined make me favor inlining the 
> check. 
I agree that inlining is better here, but note that `config.has_libcxx` doesn't 
work, this is still going to return `True`: `config.has_libcxx` is a string, 
not a boolean, so anything `!= None` -- in particular '0' -- will evaluate to 
true.

There are two ways to inline this: 

1.`is_configured('has_libcxx') and config.has_libcxx == '1'`
2.`is_configured('has_libcxx') == '1'`

Actually, since `has_libcxx` comes from a canonicalized variable (in the sense 
described in the commit message), we could also just do:

3.`config.has_libcxx == '1'`


What do you think?

Related: in a separate patch I think we should change the implementation of 
`is_configured` to compare against None, so that it returns a boolean.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133639

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


[Lldb-commits] [PATCH] D133680: Add support for mach-o corefile loading of a platform binary

2022-09-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/include/lldb/Target/DynamicLoader.h:231
+  /// Name of the binary, if available.  If an empty StringRef is
+  /// passed here, a name will be constructed for the module.
+  ///

Can you list what it might be constructed from? My guess:
* the filename if loading from a path
* @ if loading from something in memory



Comment at: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp:420
 LLDB_LOGF(log,
-  "ProcessMachCore::DoLoadCore: Using kernel corefile image "
+  "ProcessMachCore::LoadBinariesAndSetDYLD: Using kernel "
+  "corefile image "

I think the various log messages could use `__FUNCTION__` instead but hey let's 
not make this diff any bigger :) .
(the one time I know you need to write out the name is inside a lambda)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133680

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