[Lldb-commits] [lldb] Extending LLDB to work on AIX (PR #102601)

2025-05-12 Thread via lldb-commits

https://github.com/ravi-sh updated 
https://github.com/llvm/llvm-project/pull/102601



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,66 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const MemberOfNode *node) {
+  Status error;

labath wrote:

Declare it where it's being used to make it clear what's its scope and contents.

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,66 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const MemberOfNode *node) {
+  Status error;
+  auto base_or_err = Evaluate(node->GetBase());
+  if (!base_or_err) {
+return base_or_err;
+  }
+  lldb::ValueObjectSP base = *base_or_err;
+
+  // Perform basic type checking.
+  CompilerType base_type = base->GetCompilerType();
+  // When using an arrow, make sure the base is a pointer or array type.
+  // When using a period, make sure the base type is NOT a pointer type.
+  if (node->GetIsArrow() && !base_type.IsPointerType() &&
+  !base_type.IsArrayType()) {
+lldb::ValueObjectSP deref_sp = base->Dereference(error);
+if (error.Success()) {
+  base = deref_sp;
+  base_type = deref_sp->GetCompilerType().GetPointerType();
+} else {
+  std::string errMsg =
+  llvm::formatv("member reference type {0} is not a pointer; "
+"did you mean to use '.'?",
+base_type.TypeDescription());
+  return llvm::make_error(
+  m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+}
+  } else if (!node->GetIsArrow() && base_type.IsPointerType()) {
+std::string errMsg =
+llvm::formatv("member reference type {0} is a pointer; "
+  "did you mean to use '->'?",
+  base_type.TypeDescription());
+return llvm::make_error(
+m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+  }
+
+  // User specified array->elem; need to get to element[0] to look for fields.
+  if (node->GetIsArrow() && base_type.IsArrayType())
+base = base->GetChildAtIndex(0);

labath wrote:

This probably shouldn't exist

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,66 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const MemberOfNode *node) {
+  Status error;
+  auto base_or_err = Evaluate(node->GetBase());
+  if (!base_or_err) {
+return base_or_err;
+  }
+  lldb::ValueObjectSP base = *base_or_err;
+
+  // Perform basic type checking.
+  CompilerType base_type = base->GetCompilerType();
+  // When using an arrow, make sure the base is a pointer or array type.
+  // When using a period, make sure the base type is NOT a pointer type.
+  if (node->GetIsArrow() && !base_type.IsPointerType() &&
+  !base_type.IsArrayType()) {
+lldb::ValueObjectSP deref_sp = base->Dereference(error);
+if (error.Success()) {
+  base = deref_sp;
+  base_type = deref_sp->GetCompilerType().GetPointerType();
+} else {
+  std::string errMsg =
+  llvm::formatv("member reference type {0} is not a pointer; "
+"did you mean to use '.'?",
+base_type.TypeDescription());
+  return llvm::make_error(
+  m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+}
+  } else if (!node->GetIsArrow() && base_type.IsPointerType()) {

labath wrote:

same here

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -111,7 +111,27 @@ ASTNodeUP DILParser::ParseUnaryExpression() {
   llvm_unreachable("invalid token kind");
 }
   }
-  return ParsePrimaryExpression();
+  return ParsePostfixExpression();
+}
+// Parse a postfix_expression.

labath wrote:

```suggestion

// Parse a postfix_expression.
```

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -88,6 +89,29 @@ class IdentifierNode : public ASTNode {
   std::string m_name;
 };
 
+class MemberOfNode : public ASTNode {
+public:
+  MemberOfNode(uint32_t location, ASTNodeUP base, bool is_arrow,
+   std::string name)
+  : ASTNode(location, NodeKind::eMemberOfNode), m_base(std::move(base)),
+m_is_arrow(is_arrow), m_field_name(std::move(name)) {}
+
+  llvm::Expected Accept(Visitor *v) const override;
+
+  ASTNode *GetBase() const { return m_base.get(); }
+  bool GetIsArrow() const { return m_is_arrow; }
+  std::string GetFieldName() const { return m_field_name; }

labath wrote:

```suggestion
  llvm::StringRef GetFieldName() const { return m_field_name; }
```

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,66 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const MemberOfNode *node) {
+  Status error;
+  auto base_or_err = Evaluate(node->GetBase());
+  if (!base_or_err) {
+return base_or_err;
+  }
+  lldb::ValueObjectSP base = *base_or_err;
+
+  // Perform basic type checking.
+  CompilerType base_type = base->GetCompilerType();
+  // When using an arrow, make sure the base is a pointer or array type.
+  // When using a period, make sure the base type is NOT a pointer type.
+  if (node->GetIsArrow() && !base_type.IsPointerType() &&
+  !base_type.IsArrayType()) {

labath wrote:

I think we should drop the type checks and perform the dereference 
unconditionally.

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,66 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const MemberOfNode *node) {
+  Status error;
+  auto base_or_err = Evaluate(node->GetBase());
+  if (!base_or_err) {
+return base_or_err;
+  }
+  lldb::ValueObjectSP base = *base_or_err;
+
+  // Perform basic type checking.
+  CompilerType base_type = base->GetCompilerType();
+  // When using an arrow, make sure the base is a pointer or array type.
+  // When using a period, make sure the base type is NOT a pointer type.
+  if (node->GetIsArrow() && !base_type.IsPointerType() &&
+  !base_type.IsArrayType()) {
+lldb::ValueObjectSP deref_sp = base->Dereference(error);
+if (error.Success()) {
+  base = deref_sp;
+  base_type = deref_sp->GetCompilerType().GetPointerType();
+} else {
+  std::string errMsg =
+  llvm::formatv("member reference type {0} is not a pointer; "
+"did you mean to use '.'?",
+base_type.TypeDescription());
+  return llvm::make_error(
+  m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+}
+  } else if (!node->GetIsArrow() && base_type.IsPointerType()) {
+std::string errMsg =
+llvm::formatv("member reference type {0} is a pointer; "
+  "did you mean to use '->'?",
+  base_type.TypeDescription());
+return llvm::make_error(
+m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+  }
+
+  // User specified array->elem; need to get to element[0] to look for fields.
+  if (node->GetIsArrow() && base_type.IsArrayType())
+base = base->GetChildAtIndex(0);
+
+  // Now look for the member with the specified name.
+  lldb::ValueObjectSP field_obj =
+  base->GetChildMemberWithName(llvm::StringRef(node->GetFieldName()));
+  if (field_obj && field_obj->GetName().GetString() == node->GetFieldName()) {
+if (field_obj->GetCompilerType().IsReferenceType()) {
+  lldb::ValueObjectSP tmp_obj = field_obj->Dereference(error);
+  if (error.Fail())
+return error.ToError();
+  return tmp_obj;
+}
+return field_obj;
+  }
+
+  if (node->GetIsArrow() && base_type.IsPointerType())
+base_type = base_type.GetPointeeType();
+  std::string errMsg =
+  llvm::formatv("no member named '{0}' in {1}", node->GetFieldName(),

labath wrote:

What kind of error do we get from GetChildMemberWithName? Could we forward that?

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,66 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const MemberOfNode *node) {
+  Status error;
+  auto base_or_err = Evaluate(node->GetBase());
+  if (!base_or_err) {
+return base_or_err;
+  }
+  lldb::ValueObjectSP base = *base_or_err;
+
+  // Perform basic type checking.
+  CompilerType base_type = base->GetCompilerType();
+  // When using an arrow, make sure the base is a pointer or array type.
+  // When using a period, make sure the base type is NOT a pointer type.
+  if (node->GetIsArrow() && !base_type.IsPointerType() &&
+  !base_type.IsArrayType()) {
+lldb::ValueObjectSP deref_sp = base->Dereference(error);
+if (error.Success()) {
+  base = deref_sp;
+  base_type = deref_sp->GetCompilerType().GetPointerType();
+} else {
+  std::string errMsg =
+  llvm::formatv("member reference type {0} is not a pointer; "
+"did you mean to use '.'?",
+base_type.TypeDescription());
+  return llvm::make_error(
+  m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+}
+  } else if (!node->GetIsArrow() && base_type.IsPointerType()) {
+std::string errMsg =
+llvm::formatv("member reference type {0} is a pointer; "
+  "did you mean to use '->'?",
+  base_type.TypeDescription());
+return llvm::make_error(
+m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+  }
+
+  // User specified array->elem; need to get to element[0] to look for fields.
+  if (node->GetIsArrow() && base_type.IsArrayType())
+base = base->GetChildAtIndex(0);
+
+  // Now look for the member with the specified name.
+  lldb::ValueObjectSP field_obj =
+  base->GetChildMemberWithName(llvm::StringRef(node->GetFieldName()));
+  if (field_obj && field_obj->GetName().GetString() == node->GetFieldName()) {
+if (field_obj->GetCompilerType().IsReferenceType()) {
+  lldb::ValueObjectSP tmp_obj = field_obj->Dereference(error);

labath wrote:

Why is this necessary? GetChildMemberWithName seems to work just fine on 
references:
```
(lldb) script lldb.frame.FindVariable("b")
(A &) b = 0x7fffd7e8: {
  X = 42
  x = 0x7fffd7e8
}
(lldb) script lldb.frame.FindVariable("b").GetChildMemberWithName("X")
(int) X = 42
```

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,59 @@
+int
+main(int argc, char**argv)
+{
+  int x = 2;
+  struct Sx {
+int x;
+int& r;
+char y;
+  } s{1, x, 2};
+
+  Sx& sr = s;
+  Sx* sp = &s;
+
+  Sx sarr[2] = {{5, x, 2}, {1, x, 3}};
+
+  using SxAlias = Sx;
+  SxAlias sa{3, x, 4};
+
+  return 0; // Set a breakpoint here
+}
+
+/*
+  EXPECT_THAT(Eval("s.x"), IsEqual("1"));
+  EXPECT_THAT(Eval("s.r"), IsEqual("2"));
+  EXPECT_THAT(Eval("s.r + 1"), IsEqual("3"));
+  EXPECT_THAT(Eval("sr.x"), IsEqual("1"));
+  EXPECT_THAT(Eval("sr.r"), IsEqual("2"));
+  EXPECT_THAT(Eval("sr.r + 1"), IsEqual("3"));
+  EXPECT_THAT(Eval("sp->x"), IsEqual("1"));
+  EXPECT_THAT(Eval("sp->r"), IsEqual("2"));
+  EXPECT_THAT(Eval("sp->r + 1"), IsEqual("3"));
+  EXPECT_THAT(Eval("sarr->x"), IsEqual("5"));
+  EXPECT_THAT(Eval("sarr->r"), IsEqual("2"));
+  EXPECT_THAT(Eval("sarr->r + 1"), IsEqual("3"));
+  EXPECT_THAT(Eval("(sarr + 1)->x"), IsEqual("1"));
+
+  EXPECT_THAT(
+  Eval("sp->4"),
+  IsError(
+  ":1:5: expected 'identifier', got: <'4' (numeric_constant)>\n"
+  "sp->4\n"
+  "^"));
+  EXPECT_THAT(Eval("sp->foo"), IsError("no member named 'foo' in 'Sx'"));
+  EXPECT_THAT(
+  Eval("sp->r / (void*)0"),
+  IsError("invalid operands to binary expression ('int' and 'void *')"));
+
+  EXPECT_THAT(Eval("sp.x"), IsError("member reference type 'Sx *' is a "
+"pointer; did you mean to use '->'"));
+  EXPECT_THAT(
+  Eval("sarr.x"),
+  IsError(
+  "member reference base type 'Sx[2]' is not a structure or union"));
+
+  // Test for record typedefs.
+  EXPECT_THAT(Eval("sa.x"), IsEqual("3"));
+  EXPECT_THAT(Eval("sa.y"), IsEqual("'\\x04'"));
+
+*/

labath wrote:

??

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -272,4 +272,66 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const MemberOfNode *node) {
+  Status error;
+  auto base_or_err = Evaluate(node->GetBase());
+  if (!base_or_err) {
+return base_or_err;
+  }

labath wrote:

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-05-12 Thread Pavel Labath via lldb-commits

https://github.com/labath approved this pull request.


https://github.com/llvm/llvm-project/pull/131304
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -190,7 +190,59 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
 
 bool ObjectFileXCOFF::IsStripped() { return false; }
 
-void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {}
+void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {
+  if (m_sections_up)
+return;
+
+  m_sections_up = std::make_unique();
+  ModuleSP module_sp(GetModule());
+
+  if (!module_sp)
+return;
+
+  std::lock_guard guard(module_sp->GetMutex());
+
+  const auto §ions = m_binary->sections64();
+  int idx = 0;
+  for (size_t i = 0; i < sections.size(); ++i) {
+const llvm::object::XCOFFSectionHeader64 §ion = sections[i];

labath wrote:

Does this not work for some reason?

```suggestion
  int idx = 0;
  for (const llvm::object::XCOFFSectionHeader64 §ion = 
m_binary->sections64()) {
```

https://github.com/llvm/llvm-project/pull/131304
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -190,7 +190,59 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
 
 bool ObjectFileXCOFF::IsStripped() { return false; }
 
-void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {}
+void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {
+  if (m_sections_up)
+return;
+
+  m_sections_up = std::make_unique();
+  ModuleSP module_sp(GetModule());
+
+  if (!module_sp)
+return;
+
+  std::lock_guard guard(module_sp->GetMutex());
+
+  const auto §ions = m_binary->sections64();
+  int idx = 0;
+  for (size_t i = 0; i < sections.size(); ++i) {
+const llvm::object::XCOFFSectionHeader64 §ion = sections[i];
+
+ConstString const_sect_name(section.Name);
+
+SectionType section_type = lldb::eSectionTypeOther;
+if (section.Flags & XCOFF::STYP_TEXT)
+  section_type = eSectionTypeCode;
+else if (section.Flags & XCOFF::STYP_DATA)
+  section_type = eSectionTypeData;
+else if (section.Flags & XCOFF::STYP_BSS)
+  section_type = eSectionTypeZeroFill;
+else if (section.Flags & XCOFF::STYP_DWARF) {
+  section_type = llvm::StringSwitch(section.Name)
+ .Case(".dwinfo", eSectionTypeDWARFDebugInfo)
+ .Case(".dwline", eSectionTypeDWARFDebugLine)
+ .Case(".dwabrev", eSectionTypeDWARFDebugAbbrev)
+ .Default(eSectionTypeInvalid);
+
+  if (section_type == eSectionTypeInvalid)
+section_type = lldb::eSectionTypeOther;

labath wrote:

```suggestion
 .Default(eSectionTypeOther);
```

https://github.com/llvm/llvm-project/pull/131304
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -190,8 +190,83 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
 
 bool ObjectFileXCOFF::IsStripped() { return false; }
 
-void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {}
-
+void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {
+
+  if (m_sections_up)
+return;
+  m_sections_up = std::make_unique();
+  ModuleSP module_sp(GetModule());
+  if (module_sp) {
+std::lock_guard guard(module_sp->GetMutex());
+
+ModuleSP module_sp(GetModule());
+for (auto sIdx = m_binary->section_begin(); sIdx != 
m_binary->section_end();
+ ++sIdx) {

labath wrote:

SGTM

https://github.com/llvm/llvm-project/pull/131304
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -7,6 +7,9 @@
 # CHECK: Stripped: false
 # CHECK: Type: executable
 # CHECK: Strata: unknown
+# CHECK: Name: .text
+# CHECK-NEXT: code
+# CHECK-NEXT: r-x

labath wrote:

That's because most of their code is very old. I definitely wouldn't want to 
emulate that aspect of them.

https://github.com/llvm/llvm-project/pull/131304
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -1114,15 +1115,15 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
 num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 SymbolContextItem(eSymbolContextModule |
   eSymbolContextCompUnit),

labath wrote:

```suggestion
filename, 0, check_inlines,
SymbolContextItem(eSymbolContextModule |
  eSymbolContextCompUnit | 
eSymbolContextLineEntry),
```

https://github.com/llvm/llvm-project/pull/139002
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-12 Thread Pavel Labath via lldb-commits

https://github.com/labath edited 
https://github.com/llvm/llvm-project/pull/139002
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -1170,10 +1171,41 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's
+  // file(s) will be found. So if a header was requested and we got a
+  // primary file (ie., something with a different name), then look 
thru
+  // its support file(s) for the header.
+  lldb::SupportFileSP found_file_sp =

labath wrote:

And now get the file from `sc.line_entry.file_sp`

https://github.com/llvm/llvm-project/pull/139002
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-12 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

It seems rather wasteful (and error-prone) to repeat the search through the 
support files of a compile unit, given that ResolveSymbolContextForFilePath has 
already searched through them and told us that the CU really does contain a 
file with the given name. The problem is that the return value is just the CU 
itself, so all the information we get is "the file is *somewhere* in this CU".

However, this function is also (and primarily) used for setting file+line 
breakpoints, and you definitely can set breakpoints in the header files. So, 
how does that work?

When setting a breakpoint, we pass  eSymbolContextLineEntry to the function so 
that it returns a line entry matching the query. In this case, we're not really 
interested in the entire line entry, but I think it should be possible the line 
entry as a carrier for the file name: we ask for the function to fill it out, 
and then fetch the file from there. Can you see if that works?

I also think that changing `0` to `start_line` was not right change. Since 
we're not actually line entry (just the file name, we'll extract the lines 
ourselves), we want to maximize our chances of finding a matching line entry. 
If it cannot find an exact file+line match, `ResolveSymbolContextForFilePath` 
will return a line entry for any line that comes after it. Using zero ensures 
we don't skip any line entries.

https://github.com/llvm/llvm-project/pull/139002
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -734,15 +734,22 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
 } break;
 case eAddressTypeLoad: {
   ExecutionContext exe_ctx(GetExecutionContextRef());
-  Process *process = exe_ctx.GetProcessPtr();
-  if (process) {
-heap_buf_ptr->SetByteSize(bytes);
-size_t bytes_read = process->ReadMemory(
+  heap_buf_ptr->SetByteSize(bytes);
+  size_t bytes_read = 0;
+  if (Process *process = exe_ctx.GetProcessPtr();
+  process && process->IsLiveDebugSession()) {

labath wrote:

I'd like to avoid special casing core files. Can we just call the target 
version all the time?

https://github.com/llvm/llvm-project/pull/139196
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,268 @@
+//===-- ProtocolTypesTest.cpp ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Protocol/ProtocolTypes.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+  ExceptionBreakpointsFilter filter;
+  filter.filter = "testFilter";
+  filter.label = "Test Filter";
+  filter.description = "This is a test filter";
+  filter.defaultState = true;
+  filter.supportsCondition = true;
+  filter.conditionDescription = "Condition for test filter";
+
+  llvm::json::Value value = toJSON(filter);
+  const json::Object *obj = value.getAsObject();
+  ASSERT_NE(obj, nullptr);
+
+  EXPECT_EQ(obj->getString("filter"), "testFilter");
+  EXPECT_EQ(obj->getString("label"), "Test Filter");
+  EXPECT_EQ(obj->getString("description"), "This is a test filter");
+  EXPECT_EQ(obj->getBoolean("default"), true);
+  EXPECT_EQ(obj->getBoolean("supportsCondition"), true);
+  EXPECT_EQ(obj->getString("conditionDescription"),
+"Condition for test filter");

JDevlieghere wrote:

Alright, if that's the direction, let me start by landing the `Source` test and 
we can support the other types in a similar fashion as we add support for 
serialization.

https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][core] Fix getting summary of a variable pointing to r/o memory (PR #139196)

2025-05-12 Thread Igor Kudrin via lldb-commits

https://github.com/igorkudrin updated 
https://github.com/llvm/llvm-project/pull/139196

>From 499f723c3f974ff53deb8f354d879e0baaa7a9e8 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Wed, 7 May 2025 19:55:07 -0700
Subject: [PATCH 1/4] [lldb][core] Fix getting summary of a variable pointing
 to r/o memory

Motivation example:

```
> lldb -c altmain2.core
...
(lldb) var F
(const char *) F = 0x0804a000 ""
```

The variable `F` points to a read-only memory page not dumped to the
core file, so `Process::ReadMemory()` cannot read the data. The patch
switches to `Target::ReadMemory()`, which can read data both from the
process memory and the application binary.
---
 lldb/source/ValueObject/ValueObject.cpp   |  13 -
 .../postmortem/elf-core/TestLinuxCore.py  |  27 ++
 .../postmortem/elf-core/altmain2.core | Bin 0 -> 40960 bytes
 .../postmortem/elf-core/altmain2.out  | Bin 0 -> 9776 bytes
 4 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 
lldb/test/API/functionalities/postmortem/elf-core/altmain2.core
 create mode 100755 
lldb/test/API/functionalities/postmortem/elf-core/altmain2.out

diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index e1c66763ff0b8..aab78428d9103 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -735,7 +735,7 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
 case eAddressTypeLoad: {
   ExecutionContext exe_ctx(GetExecutionContextRef());
   Process *process = exe_ctx.GetProcessPtr();
-  if (process) {
+  if (process && process->IsLiveDebugSession()) {
 heap_buf_ptr->SetByteSize(bytes);
 size_t bytes_read = process->ReadMemory(
 addr + offset, heap_buf_ptr->GetBytes(), bytes, error);
@@ -743,6 +743,17 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, 
uint32_t item_idx,
   data.SetData(data_sp);
   return bytes_read;
 }
+  } else if (Target *target = exe_ctx.GetTargetPtr()) {
+Address target_addr;
+target_addr.SetLoadAddress(addr + offset, target);
+heap_buf_ptr->SetByteSize(bytes);
+size_t bytes_read =
+target->ReadMemory(target_addr, heap_buf_ptr->GetBytes(), bytes,
+   error, /*force_live_memory=*/true);
+if (error.Success() || bytes_read > 0) {
+  data.SetData(data_sp);
+  return bytes_read;
+}
   }
 } break;
 case eAddressTypeHost: {
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index a287fd19ba352..d1e065a32efdc 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -977,6 +977,33 @@ def test_get_core_file_api(self):
 self.assertEqual(process.GetCoreFile().GetFilename(), core_file_name)
 self.dbg.DeleteTarget(target)
 
+@skipIfLLVMTargetMissing("X86")
+def test_ro_cstring(self):
+"""
+Test that we can show the summary for a cstring variable that points
+to a r/o memory page which is not dumped to a core file.
+"""
+target = self.dbg.CreateTarget("altmain2.out")
+process = target.LoadCore("altmain2.core")
+self.assertTrue(process, PROCESS_IS_VALID)
+
+frame = process.GetSelectedThread().GetFrameAtIndex(0)
+self.assertEqual(frame.GetFunctionName(), "_start")
+
+var = frame.FindVariable("F")
+
+# The variable points to a RO segment that is not dumped to the core
+# file and thus process.ReadCStringFromMemory() cannot get the value.
+error = lldb.SBError()
+cstr = process.ReadCStringFromMemory(var.GetValueAsUnsigned(), 256, 
error)
+self.assertFailure(error, error_str="core file does not contain 
0x804a000")
+self.assertEqual(cstr, "")
+
+# Nevertheless, when getting the summary, the value can be read from 
the
+# application binary.
+cstr = var.GetSummary()
+self.assertEqual(cstr, '"_start"')
+
 def check_memory_regions(self, process, region_count):
 region_list = process.GetMemoryRegions()
 self.assertEqual(region_list.GetSize(), region_count)
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/altmain2.core 
b/lldb/test/API/functionalities/postmortem/elf-core/altmain2.core
new file mode 100755
index 
..b9dd8de08b813442037fcb5bedd08e8bbabfdc0b
GIT binary patch
literal 40960
zcmeHQ4^&jwnSa9!I!%cK#cib0IB9HSqA(1g2@tXp8Ij5$Wtd=M$vDi6Fme86<_(|;
z6+_tg`VJeLbo*!1-R7KixAr7yY1h*llO~{6F(sCWr_zMokd!oo(v~!T)FyTI_ucp2
z%tOtlZMJ8(-FH3T-0yz(yZ3(gcfb4H_udT89k#l)I-QPFl7Z86N~u&4A}{64oKY?t
zsH`Y~&;E#9A!n>A8-*T&)P#5twWFNXo5Amv>t%VSoTus^om+oN`+>Rj^Db^b`}?yb
z;#NyEr~PK

[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

2025-05-12 Thread Nico Weber via lldb-commits


@@ -1,20 +1,11 @@
-if(APPLE)
-  configure_file(
-${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
-${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
-)
-  # Inline info plist in binary (use target_link_options for this as soon as 
CMake 3.13 is available)
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
-endif()
-
 # We need to include the llvm components we depend on manually, as liblldb does
 # not re-export those.
 set(LLVM_LINK_COMPONENTS Support)
 set(LLVM_TARGET_DEFINITIONS Options.td)

nico wrote:

Should this move too? The .inc file is only used in lldb-dap.cpp.

https://github.com/llvm/llvm-project/pull/139402
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-05-12 Thread Alex Langford via lldb-commits


@@ -0,0 +1,535 @@
+//===-- RPCCommon.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication",  // What is this used for?
+"SBInputReader",// What is this used for?
+"SBCommandPluginInterface", // This is hard to support, we can do it if
+// really needed though.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// FIXME: We should be able to annotate these methods instead of maintaining a
+// list in the generator itself.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
+};
+
+static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
+"SBHostOS",
+"SBReproducer",
+};
+
+static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
+"SBHostOS",
+"SBReproducer",
+"SBStream",
+"SBProgress",
+};
+
+static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {

bulbazord wrote:

I'm still not sure what this would look like. Do you have some pseudocode or a 
sketch of the idea? I'm hesitant to add an entire new class just for RPC's 
sake, but it's hard to evaluate without more details.

https://github.com/llvm/llvm-project/pull/138031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-12 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/138116

>From 98659ed9520b5364092e72420aee5edea7cb7bba Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 29 Apr 2025 18:19:18 +0100
Subject: [PATCH 1/2] [lldb][lldb-dap] Migrate 'Scopes' to structured types.

---
 lldb/tools/lldb-dap/DAP.cpp   |  11 --
 lldb/tools/lldb-dap/DAP.h |   2 -
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  10 +-
 .../lldb-dap/Handler/ScopesRequestHandler.cpp | 121 --
 lldb/tools/lldb-dap/JSONUtils.h   |  21 ---
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  14 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  13 ++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  71 --
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  81 +++-
 9 files changed, 224 insertions(+), 120 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4feca1253be20..baaf9950b79db 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -559,17 +559,6 @@ lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object 
&arguments) {
   return GetLLDBFrame(frame_id);
 }
 
-llvm::json::Value DAP::CreateTopLevelScopes() {
-  llvm::json::Array scopes;
-  scopes.emplace_back(
-  CreateScope("Locals", VARREF_LOCALS, variables.locals.GetSize(), false));
-  scopes.emplace_back(CreateScope("Globals", VARREF_GLOBALS,
-  variables.globals.GetSize(), false));
-  scopes.emplace_back(CreateScope("Registers", VARREF_REGS,
-  variables.registers.GetSize(), false));
-  return llvm::json::Value(std::move(scopes));
-}
-
 ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression,
  bool partial_expression) {
   // Check for the escape hatch prefix.
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index c2e4c2dea582e..f66cb40451484 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -285,8 +285,6 @@ struct DAP {
   lldb::SBFrame GetLLDBFrame(uint64_t frame_id);
   lldb::SBFrame GetLLDBFrame(const llvm::json::Object &arguments);
 
-  llvm::json::Value CreateTopLevelScopes();
-
   void PopulateExceptionBreakpoints();
 
   /// Attempt to determine if an expression is a variable expression or
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index b0002440cf72e..eaebaf6619bbd 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -452,11 +452,15 @@ class PauseRequestHandler : public LegacyRequestHandler {
   void operator()(const llvm::json::Object &request) const override;
 };
 
-class ScopesRequestHandler : public LegacyRequestHandler {
+class ScopesRequestHandler final
+: public RequestHandler> {
 public:
-  using LegacyRequestHandler::LegacyRequestHandler;
+  using RequestHandler::RequestHandler;
   static llvm::StringLiteral GetCommand() { return "scopes"; }
-  void operator()(const llvm::json::Object &request) const override;
+
+  llvm::Expected
+  Run(const protocol::ScopesArguments &args) const override;
 };
 
 class SetVariableRequestHandler final
diff --git a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
index 7d1608f59f9a4..d9dd29f7269f2 100644
--- a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
@@ -7,69 +7,55 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
 #include "RequestHandler.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "ScopesRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Scopes request; value of command field is 'scopes'. The
-// request returns the variable scopes for a given stackframe ID.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "scopes" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/ScopesArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "ScopesArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'scopes' request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "Retrieve the scopes for this stackframe."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "ScopesResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'scopes' request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "scopes": {
-// "type": "array",
-//  

[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-12 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper updated 
https://github.com/llvm/llvm-project/pull/138116

>From 98659ed9520b5364092e72420aee5edea7cb7bba Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 29 Apr 2025 18:19:18 +0100
Subject: [PATCH 1/3] [lldb][lldb-dap] Migrate 'Scopes' to structured types.

---
 lldb/tools/lldb-dap/DAP.cpp   |  11 --
 lldb/tools/lldb-dap/DAP.h |   2 -
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |  10 +-
 .../lldb-dap/Handler/ScopesRequestHandler.cpp | 121 --
 lldb/tools/lldb-dap/JSONUtils.h   |  21 ---
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  14 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  13 ++
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  71 --
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  81 +++-
 9 files changed, 224 insertions(+), 120 deletions(-)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4feca1253be20..baaf9950b79db 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -559,17 +559,6 @@ lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object 
&arguments) {
   return GetLLDBFrame(frame_id);
 }
 
-llvm::json::Value DAP::CreateTopLevelScopes() {
-  llvm::json::Array scopes;
-  scopes.emplace_back(
-  CreateScope("Locals", VARREF_LOCALS, variables.locals.GetSize(), false));
-  scopes.emplace_back(CreateScope("Globals", VARREF_GLOBALS,
-  variables.globals.GetSize(), false));
-  scopes.emplace_back(CreateScope("Registers", VARREF_REGS,
-  variables.registers.GetSize(), false));
-  return llvm::json::Value(std::move(scopes));
-}
-
 ReplMode DAP::DetectReplMode(lldb::SBFrame frame, std::string &expression,
  bool partial_expression) {
   // Check for the escape hatch prefix.
diff --git a/lldb/tools/lldb-dap/DAP.h b/lldb/tools/lldb-dap/DAP.h
index c2e4c2dea582e..f66cb40451484 100644
--- a/lldb/tools/lldb-dap/DAP.h
+++ b/lldb/tools/lldb-dap/DAP.h
@@ -285,8 +285,6 @@ struct DAP {
   lldb::SBFrame GetLLDBFrame(uint64_t frame_id);
   lldb::SBFrame GetLLDBFrame(const llvm::json::Object &arguments);
 
-  llvm::json::Value CreateTopLevelScopes();
-
   void PopulateExceptionBreakpoints();
 
   /// Attempt to determine if an expression is a variable expression or
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.h 
b/lldb/tools/lldb-dap/Handler/RequestHandler.h
index b0002440cf72e..eaebaf6619bbd 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.h
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.h
@@ -452,11 +452,15 @@ class PauseRequestHandler : public LegacyRequestHandler {
   void operator()(const llvm::json::Object &request) const override;
 };
 
-class ScopesRequestHandler : public LegacyRequestHandler {
+class ScopesRequestHandler final
+: public RequestHandler> {
 public:
-  using LegacyRequestHandler::LegacyRequestHandler;
+  using RequestHandler::RequestHandler;
   static llvm::StringLiteral GetCommand() { return "scopes"; }
-  void operator()(const llvm::json::Object &request) const override;
+
+  llvm::Expected
+  Run(const protocol::ScopesArguments &args) const override;
 };
 
 class SetVariableRequestHandler final
diff --git a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
index 7d1608f59f9a4..d9dd29f7269f2 100644
--- a/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/ScopesRequestHandler.cpp
@@ -7,69 +7,55 @@
 
//===--===//
 
 #include "DAP.h"
-#include "EventHelper.h"
-#include "JSONUtils.h"
 #include "RequestHandler.h"
 
+using namespace lldb_dap::protocol;
 namespace lldb_dap {
 
-// "ScopesRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Scopes request; value of command field is 'scopes'. The
-// request returns the variable scopes for a given stackframe ID.",
-// "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "scopes" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/ScopesArguments"
-//   }
-// },
-// "required": [ "command", "arguments"  ]
-//   }]
-// },
-// "ScopesArguments": {
-//   "type": "object",
-//   "description": "Arguments for 'scopes' request.",
-//   "properties": {
-// "frameId": {
-//   "type": "integer",
-//   "description": "Retrieve the scopes for this stackframe."
-// }
-//   },
-//   "required": [ "frameId" ]
-// },
-// "ScopesResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to 'scopes' request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "scopes": {
-// "type": "array",
-//  

[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-12 Thread Ebuka Ezike via lldb-commits


@@ -98,9 +83,15 @@ void ScopesRequestHandler::operator()(const 
llvm::json::Object &request) const {
  /*statics=*/true,
  /*in_scope_only=*/true);
   dap.variables.registers = frame.GetRegisters();
-  body.try_emplace("scopes", dap.CreateTopLevelScopes());
-  response.try_emplace("body", std::move(body));
-  dap.SendJSON(llvm::json::Value(std::move(response)));
+
+  std::vector scopes = {CreateScope("Locals", VARREF_LOCALS,
+dap.variables.locals.GetSize(), false),
+CreateScope("Globals", VARREF_GLOBALS,
+dap.variables.globals.GetSize(), false),
+CreateScope("Registers", VARREF_REGS,
+dap.variables.registers.GetSize(), false)};
+
+  return ScopesResponseBody{std::move(scopes)};

da-viper wrote:

I  think it should be only in the scoped request since nothing outside is using 
the functionality.

would be worth it to move it to the variables if there was another request that 
depends on getting all the scopes. 



https://github.com/llvm/llvm-project/pull/138116
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-05-12 Thread Alex Langford via lldb-commits


@@ -0,0 +1,535 @@
+//===-- RPCCommon.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication",  // What is this used for?
+"SBInputReader",// What is this used for?
+"SBCommandPluginInterface", // This is hard to support, we can do it if
+// really needed though.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// FIXME: We should be able to annotate these methods instead of maintaining a
+// list in the generator itself.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
+};
+
+static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
+"SBHostOS",
+"SBReproducer",
+};
+
+static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
+"SBHostOS",
+"SBReproducer",
+"SBStream",
+"SBProgress",
+};
+
+static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {

bulbazord wrote:

So each method would get its own typedef?

https://github.com/llvm/llvm-project/pull/138031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Restore ObjC incomplete type dereferencing fix (PR #139567)

2025-05-12 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> @felipepiovezan I don't have a machine to run ObjC tests on, could you apply 
> this patch and see if it fixes the issue in #135843 ?

I'll try that for you.

https://github.com/llvm/llvm-project/pull/139567
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/139502



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

Updated the PR and settled on the roundtrip approach for `Source` and 
`ExceptionBreakpointsFilter`. 

https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Restore ObjC incomplete type dereferencing fix (PR #139567)

2025-05-12 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> @felipepiovezan I don't have a machine to run ObjC tests on, could you apply 
> this patch and see if it fixes the issue in #135843 ?

The test pass after applying this patch. Feel free to land this whenever :) 

https://github.com/llvm/llvm-project/pull/139567
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] While handling events, grab the APIMutex for consistency. (PR #139596)

2025-05-12 Thread John Harrison via lldb-commits

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/139596

A number of unit tests are unstable at the moment and I believe this is due to 
event handling between the event thread and the DAP::Loop.

One way this manifests is the 'disconnect' request terminating the SBTarget 
while the event handler is still handling module events. This is causing a 
SIGPIPE between the debugserver and the lldb-dap process.

I have some additional follow up patches to address test event synchronization, 
since many tests seem to be under specified in terms of their expected state 
that I think is contributing to these kinds of races.

>From 028af82dabf91276c6c77eeecb4292e5930b7cf9 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 12 May 2025 10:51:06 -0700
Subject: [PATCH] [lldb-dap] While handling events, grab the APIMutext for
 consistency.

A number of unit tests are unstable at the moment and I believe this is due to 
event handling between the event thread and the DAP::Loop.

One way this manifests is the 'disconnect' request terminating the SBTarget 
while the event handler is still handling module events. This is causing a 
SIGPIPE between the debugserver and the lldb-dap process.

I have some additional follow up patches to address test event synchronization, 
since many tests seem to be under specified in terms of their expected state 
that I think is contributing to these kinds of races.
---
 lldb/tools/lldb-dap/DAP.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4feca1253be20..e84d3d9e7eed8 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1504,6 +1504,11 @@ void DAP::EventThread() {
   bool done = false;
   while (!done) {
 if (listener.WaitForEvent(1, event)) {
+  // Once we get an event, make sure we finish handling it before the main
+  // thread handles the next DAP request.
+  lldb::SBMutex lock = GetAPIMutex();
+  std::lock_guard guard(lock);
+
   const auto event_mask = event.GetType();
   if (lldb::SBProcess::EventIsProcessEvent(event)) {
 lldb::SBProcess process = lldb::SBProcess::GetProcessFromEvent(event);

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


[Lldb-commits] [lldb] [lldb-dap] While handling events, grab the APIMutex for consistency. (PR #139596)

2025-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

A number of unit tests are unstable at the moment and I believe this is due to 
event handling between the event thread and the DAP::Loop.

One way this manifests is the 'disconnect' request terminating the SBTarget 
while the event handler is still handling module events. This is causing a 
SIGPIPE between the debugserver and the lldb-dap process.

I have some additional follow up patches to address test event synchronization, 
since many tests seem to be under specified in terms of their expected state 
that I think is contributing to these kinds of races.

---
Full diff: https://github.com/llvm/llvm-project/pull/139596.diff


1 Files Affected:

- (modified) lldb/tools/lldb-dap/DAP.cpp (+5) 


``diff
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4feca1253be20..e84d3d9e7eed8 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -1504,6 +1504,11 @@ void DAP::EventThread() {
   bool done = false;
   while (!done) {
 if (listener.WaitForEvent(1, event)) {
+  // Once we get an event, make sure we finish handling it before the main
+  // thread handles the next DAP request.
+  lldb::SBMutex lock = GetAPIMutex();
+  std::lock_guard guard(lock);
+
   const auto event_mask = event.GetType();
   if (lldb::SBProcess::EventIsProcessEvent(event)) {
 lldb::SBProcess process = lldb::SBProcess::GetProcessFromEvent(event);

``




https://github.com/llvm/llvm-project/pull/139596
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Restore ObjC incomplete type dereferencing fix (PR #139567)

2025-05-12 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben approved this pull request.


https://github.com/llvm/llvm-project/pull/139567
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/139252



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb-dap] While handling events, grab the APIMutex for consistency. (PR #139596)

2025-05-12 Thread John Harrison via lldb-commits

ashgti wrote:

I've been thinking about that as well. I wasn't sure if there was an easy way 
to integrate the event system into a MainLoop helper but that would definitely 
help.


https://github.com/llvm/llvm-project/pull/139596
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-05-12 Thread Dhruv Srivastava via lldb-commits


@@ -7,6 +7,9 @@
 # CHECK: Stripped: false
 # CHECK: Type: executable
 # CHECK: Strata: unknown
+# CHECK: Name: .text
+# CHECK-NEXT: code
+# CHECK-NEXT: r-x

DhruvSrivastavaX wrote:

Right, thats reasonable! Will increment accordingly in upcoming additions.

https://github.com/llvm/llvm-project/pull/131304
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread John Harrison via lldb-commits

https://github.com/ashgti approved this pull request.


https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread John Harrison via lldb-commits


@@ -0,0 +1,62 @@
+//===-- ProtocolTypesTest.cpp ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Protocol/ProtocolTypes.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+template  static llvm::Expected roundtrip(const T &input) {
+  llvm::json::Value value = toJSON(input);
+  llvm::json::Path::Root root;
+  T output;
+  if (!fromJSON(value, output, root))
+return root.getError();
+  return output;
+}
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+  ExceptionBreakpointsFilter filter;
+  filter.filter = "testFilter";
+  filter.label = "Test Filter";
+  filter.description = "This is a test filter";
+  filter.defaultState = true;
+  filter.supportsCondition = true;
+  filter.conditionDescription = "Condition for test filter";
+
+  llvm::Expected deserialized_filter =
+  roundtrip(filter);
+  ASSERT_THAT_EXPECTED(deserialized_filter, llvm::Succeeded());
+
+  EXPECT_EQ(filter.filter, deserialized_filter->filter);
+  EXPECT_EQ(filter.label, deserialized_filter->label);
+  EXPECT_EQ(filter.description, deserialized_filter->description);
+  EXPECT_EQ(filter.defaultState, deserialized_filter->defaultState);
+  EXPECT_EQ(filter.supportsCondition, deserialized_filter->supportsCondition);
+  EXPECT_EQ(filter.conditionDescription,
+deserialized_filter->conditionDescription);

ashgti wrote:

I think `json::Value` has a `==` operator, if you want to just compare the two 
`json::Value` objects, it would mean we wouldn't need to compare each field 
directly.

https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Add commands to list/enable/disable plugins (PR #134418)

2025-05-12 Thread David Peixotto via lldb-commits

dmpots wrote:

ping @clayborg @JDevlieghere @jimingham. Please take a look when you get a 
chance. Thanks!

https://github.com/llvm/llvm-project/pull/134418
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,62 @@
+//===-- ProtocolTypesTest.cpp ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Protocol/ProtocolTypes.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+template  static llvm::Expected roundtrip(const T &input) {
+  llvm::json::Value value = toJSON(input);
+  llvm::json::Path::Root root;
+  T output;
+  if (!fromJSON(value, output, root))
+return root.getError();
+  return output;
+}
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+  ExceptionBreakpointsFilter filter;
+  filter.filter = "testFilter";
+  filter.label = "Test Filter";
+  filter.description = "This is a test filter";
+  filter.defaultState = true;
+  filter.supportsCondition = true;
+  filter.conditionDescription = "Condition for test filter";
+
+  llvm::Expected deserialized_filter =
+  roundtrip(filter);
+  ASSERT_THAT_EXPECTED(deserialized_filter, llvm::Succeeded());
+
+  EXPECT_EQ(filter.filter, deserialized_filter->filter);
+  EXPECT_EQ(filter.label, deserialized_filter->label);
+  EXPECT_EQ(filter.description, deserialized_filter->description);
+  EXPECT_EQ(filter.defaultState, deserialized_filter->defaultState);
+  EXPECT_EQ(filter.supportsCondition, deserialized_filter->supportsCondition);
+  EXPECT_EQ(filter.conditionDescription,
+deserialized_filter->conditionDescription);

JDevlieghere wrote:

That sounds appealing, but how would you get the second `json::Value`? If you 
write it by hand you're back to the original state of this PR, and if you 
serialize the deserialized object again, and you have  a bug in your 
serializer, it wouldn't be caught, right?

https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-12 Thread John Harrison via lldb-commits

https://github.com/ashgti edited 
https://github.com/llvm/llvm-project/pull/138116
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-12 Thread John Harrison via lldb-commits

https://github.com/ashgti approved this pull request.

One style nit question but otherwise LGTM

https://github.com/llvm/llvm-project/pull/138116
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-12 Thread John Harrison via lldb-commits


@@ -269,17 +271,16 @@ struct Capabilities {
 };
 llvm::json::Value toJSON(const Capabilities &);
 
-enum PresentationHint : unsigned {
-  ePresentationHintNormal,
-  ePresentationHintEmphasize,
-  ePresentationHintDeemphasize,
-};
-llvm::json::Value toJSON(PresentationHint hint);
-
 /// A `Source` is a descriptor for source code. It is returned from the debug
 /// adapter as part of a `StackFrame` and it is used by clients when specifying
 /// breakpoints.
 struct Source {
+  enum PresentationHint : unsigned {
+ePresentationHintNormal,
+ePresentationHintEmphasize,
+ePresentationHintDeemphasize,
+  };

ashgti wrote:

style nit: I think in lldb enums are usually kept in the same namespace and we 
should make the type more specific like `ScopePresentationHint` and 
`eScopePresentationHintNormal`, but I'll defer @JDevlieghere this.

https://github.com/llvm/llvm-project/pull/138116
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread John Harrison via lldb-commits


@@ -0,0 +1,62 @@
+//===-- ProtocolTypesTest.cpp ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Protocol/ProtocolTypes.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+template  static llvm::Expected roundtrip(const T &input) {
+  llvm::json::Value value = toJSON(input);
+  llvm::json::Path::Root root;
+  T output;
+  if (!fromJSON(value, output, root))
+return root.getError();
+  return output;
+}
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+  ExceptionBreakpointsFilter filter;
+  filter.filter = "testFilter";
+  filter.label = "Test Filter";
+  filter.description = "This is a test filter";
+  filter.defaultState = true;
+  filter.supportsCondition = true;
+  filter.conditionDescription = "Condition for test filter";
+
+  llvm::Expected deserialized_filter =
+  roundtrip(filter);
+  ASSERT_THAT_EXPECTED(deserialized_filter, llvm::Succeeded());
+
+  EXPECT_EQ(filter.filter, deserialized_filter->filter);
+  EXPECT_EQ(filter.label, deserialized_filter->label);
+  EXPECT_EQ(filter.description, deserialized_filter->description);
+  EXPECT_EQ(filter.defaultState, deserialized_filter->defaultState);
+  EXPECT_EQ(filter.supportsCondition, deserialized_filter->supportsCondition);
+  EXPECT_EQ(filter.conditionDescription,
+deserialized_filter->conditionDescription);

ashgti wrote:

Yea, your right

https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Split lldb-dap into library and tool (NFC) (PR #139402)

2025-05-12 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

Fixed by fb9b43a0c56de9b1f36e862565c33e0ad637fb36

https://github.com/llvm/llvm-project/pull/139402
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread John Harrison via lldb-commits

https://github.com/ashgti approved this pull request.


https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread John Harrison via lldb-commits


@@ -0,0 +1,268 @@
+//===-- ProtocolTypesTest.cpp ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Protocol/ProtocolTypes.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+  ExceptionBreakpointsFilter filter;
+  filter.filter = "testFilter";
+  filter.label = "Test Filter";
+  filter.description = "This is a test filter";
+  filter.defaultState = true;
+  filter.supportsCondition = true;
+  filter.conditionDescription = "Condition for test filter";
+
+  llvm::json::Value value = toJSON(filter);
+  const json::Object *obj = value.getAsObject();
+  ASSERT_NE(obj, nullptr);
+
+  EXPECT_EQ(obj->getString("filter"), "testFilter");
+  EXPECT_EQ(obj->getString("label"), "Test Filter");
+  EXPECT_EQ(obj->getString("description"), "This is a test filter");
+  EXPECT_EQ(obj->getBoolean("default"), true);
+  EXPECT_EQ(obj->getBoolean("supportsCondition"), true);
+  EXPECT_EQ(obj->getString("conditionDescription"),
+"Condition for test filter");

ashgti wrote:

We could make it more of a convention to have both going forward for testing 
purposes.

https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Jan Svoboda (jansvoboda11)


Changes

The `DiagnosticOptions` class is currently intrusively reference-counted, which 
makes reasoning about its lifetime very difficult in some cases. For example, 
`CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in 
`llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning 
`DiagnosticOptions &`. One would think this gives `CompilerInvocation` 
exclusive ownership of the object, but that's not the case:

```c++
void shareOwnership(CompilerInvocation &CI) {
  llvm::IntrusiveRefCntPtr CoOwner = 
&CI.getDiagnosticOptions();
 // ...
}
```

This is a perfectly valid pattern that is being actually used in the codebase.

I would like to ensure the ownership of `DiagnosticOptions` by 
`CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a 
copy-on-write optimization later on. This PR changes usages of 
`DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be 
intrusively reference-counted.

---

Patch is 189.21 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/139584.diff


134 Files Affected:

- (modified) 
clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp 
(+2-2) 
- (modified) 
clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp (+3-3) 
- (modified) clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp 
(+3-3) 
- (modified) clang-tools-extra/clang-move/tool/ClangMove.cpp (+3-3) 
- (modified) clang-tools-extra/clang-query/Query.cpp (+1-1) 
- (modified) clang-tools-extra/clang-reorder-fields/tool/ClangReorderFields.cpp 
(+3-3) 
- (modified) clang-tools-extra/clang-tidy/ClangTidy.cpp (+12-12) 
- (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(+2-2) 
- (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h (+4-1) 
- (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp 
(+1-1) 
- (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h 
(+1) 
- (modified) clang-tools-extra/clangd/Compiler.cpp (+3-2) 
- (modified) clang-tools-extra/clangd/ModulesBuilder.cpp (+2-2) 
- (modified) clang-tools-extra/clangd/ParsedAST.cpp (+2-1) 
- (modified) clang-tools-extra/clangd/Preamble.cpp (+1-1) 
- (modified) clang-tools-extra/clangd/SystemIncludeExtractor.cpp (+2-1) 
- (modified) clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp (+2-1) 
- (modified) clang-tools-extra/clangd/unittests/tweaks/TweakTests.cpp (+2-1) 
- (modified) clang-tools-extra/include-cleaner/unittests/RecordTest.cpp (+2-2) 
- (modified) clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp (+3-3) 
- (modified) clang-tools-extra/modularize/ModularizeUtilities.cpp (+2-4) 
- (modified) clang-tools-extra/modularize/ModularizeUtilities.h (+1-1) 
- (modified) 
clang-tools-extra/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp 
(+2-2) 
- (modified) clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp 
(+9-9) 
- (modified) clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h (+3-3) 
- (modified) clang/include/clang/Basic/Diagnostic.h (+3-3) 
- (modified) clang/include/clang/Basic/DiagnosticOptions.h (+1-3) 
- (modified) clang/include/clang/Basic/SourceManager.h (+1) 
- (modified) clang/include/clang/Frontend/ASTUnit.h (+2) 
- (modified) clang/include/clang/Frontend/CompilerInstance.h (+1-1) 
- (modified) clang/include/clang/Frontend/CompilerInvocation.h (+1-1) 
- (modified) clang/include/clang/Frontend/DiagnosticRenderer.h (+3-4) 
- (modified) clang/include/clang/Frontend/LogDiagnosticPrinter.h (+2-2) 
- (modified) clang/include/clang/Frontend/SARIFDiagnostic.h (+1-1) 
- (modified) clang/include/clang/Frontend/SARIFDiagnosticPrinter.h (+2-2) 
- (modified) clang/include/clang/Frontend/SerializedDiagnosticPrinter.h (+1-1) 
- (modified) clang/include/clang/Frontend/TextDiagnostic.h (+1-1) 
- (modified) clang/include/clang/Frontend/TextDiagnosticPrinter.h (+2-2) 
- (modified) clang/include/clang/Serialization/ASTReader.h (+4-5) 
- (modified) clang/lib/Basic/Diagnostic.cpp (+5-5) 
- (modified) clang/lib/Basic/SourceManager.cpp (+2-2) 
- (modified) clang/lib/CrossTU/CrossTranslationUnit.cpp (+9-9) 
- (modified) clang/lib/Frontend/ASTMerge.cpp (+4-5) 
- (modified) clang/lib/Frontend/ASTUnit.cpp (+2) 
- (modified) clang/lib/Frontend/ChainedIncludesSource.cpp (+2-2) 
- (modified) clang/lib/Frontend/CompilerInstance.cpp (+13-14) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+7-20) 
- (modified) clang/lib/Frontend/CreateInvocationFromCommandLine.cpp (+9-5) 
- (modified) clang/lib/Frontend/DiagnosticRenderer.cpp (+8-9) 
- (modified) clang/lib/Frontend/FrontendAction.cpp (+2-3) 
- (modified) clang/lib/Frontend/FrontendActions.cpp (+8-8) 
- (modified) clang/lib/Frontend/LogDiagnosticPrinter.cpp (+2-2) 
- (modified) clang/lib/Frontend/SARIFDiagnostic.cpp (+2-2) 
- (modified) clang

[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-12 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-format

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)


Changes

The `DiagnosticOptions` class is currently intrusively reference-counted, which 
makes reasoning about its lifetime very difficult in some cases. For example, 
`CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in 
`llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning 
`DiagnosticOptions &`. One would think this gives `CompilerInvocation` 
exclusive ownership of the object, but that's not the case:

```c++
void shareOwnership(CompilerInvocation &CI) {
  llvm::IntrusiveRefCntPtr CoOwner = 
&CI.getDiagnosticOptions();
 // ...
}
```

This is a perfectly valid pattern that is being actually used in the codebase.

I would like to ensure the ownership of `DiagnosticOptions` by 
`CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a 
copy-on-write optimization later on. This PR changes usages of 
`DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be 
intrusively reference-counted.

---

Patch is 189.21 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/139584.diff


134 Files Affected:

- (modified) 
clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp 
(+2-2) 
- (modified) 
clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp (+3-3) 
- (modified) clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp 
(+3-3) 
- (modified) clang-tools-extra/clang-move/tool/ClangMove.cpp (+3-3) 
- (modified) clang-tools-extra/clang-query/Query.cpp (+1-1) 
- (modified) clang-tools-extra/clang-reorder-fields/tool/ClangReorderFields.cpp 
(+3-3) 
- (modified) clang-tools-extra/clang-tidy/ClangTidy.cpp (+12-12) 
- (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(+2-2) 
- (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h (+4-1) 
- (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp 
(+1-1) 
- (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h 
(+1) 
- (modified) clang-tools-extra/clangd/Compiler.cpp (+3-2) 
- (modified) clang-tools-extra/clangd/ModulesBuilder.cpp (+2-2) 
- (modified) clang-tools-extra/clangd/ParsedAST.cpp (+2-1) 
- (modified) clang-tools-extra/clangd/Preamble.cpp (+1-1) 
- (modified) clang-tools-extra/clangd/SystemIncludeExtractor.cpp (+2-1) 
- (modified) clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp (+2-1) 
- (modified) clang-tools-extra/clangd/unittests/tweaks/TweakTests.cpp (+2-1) 
- (modified) clang-tools-extra/include-cleaner/unittests/RecordTest.cpp (+2-2) 
- (modified) clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp (+3-3) 
- (modified) clang-tools-extra/modularize/ModularizeUtilities.cpp (+2-4) 
- (modified) clang-tools-extra/modularize/ModularizeUtilities.h (+1-1) 
- (modified) 
clang-tools-extra/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp 
(+2-2) 
- (modified) clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp 
(+9-9) 
- (modified) clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h (+3-3) 
- (modified) clang/include/clang/Basic/Diagnostic.h (+3-3) 
- (modified) clang/include/clang/Basic/DiagnosticOptions.h (+1-3) 
- (modified) clang/include/clang/Basic/SourceManager.h (+1) 
- (modified) clang/include/clang/Frontend/ASTUnit.h (+2) 
- (modified) clang/include/clang/Frontend/CompilerInstance.h (+1-1) 
- (modified) clang/include/clang/Frontend/CompilerInvocation.h (+1-1) 
- (modified) clang/include/clang/Frontend/DiagnosticRenderer.h (+3-4) 
- (modified) clang/include/clang/Frontend/LogDiagnosticPrinter.h (+2-2) 
- (modified) clang/include/clang/Frontend/SARIFDiagnostic.h (+1-1) 
- (modified) clang/include/clang/Frontend/SARIFDiagnosticPrinter.h (+2-2) 
- (modified) clang/include/clang/Frontend/SerializedDiagnosticPrinter.h (+1-1) 
- (modified) clang/include/clang/Frontend/TextDiagnostic.h (+1-1) 
- (modified) clang/include/clang/Frontend/TextDiagnosticPrinter.h (+2-2) 
- (modified) clang/include/clang/Serialization/ASTReader.h (+4-5) 
- (modified) clang/lib/Basic/Diagnostic.cpp (+5-5) 
- (modified) clang/lib/Basic/SourceManager.cpp (+2-2) 
- (modified) clang/lib/CrossTU/CrossTranslationUnit.cpp (+9-9) 
- (modified) clang/lib/Frontend/ASTMerge.cpp (+4-5) 
- (modified) clang/lib/Frontend/ASTUnit.cpp (+2) 
- (modified) clang/lib/Frontend/ChainedIncludesSource.cpp (+2-2) 
- (modified) clang/lib/Frontend/CompilerInstance.cpp (+13-14) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+7-20) 
- (modified) clang/lib/Frontend/CreateInvocationFromCommandLine.cpp (+9-5) 
- (modified) clang/lib/Frontend/DiagnosticRenderer.cpp (+8-9) 
- (modified) clang/lib/Frontend/FrontendAction.cpp (+2-3) 
- (modified) clang/lib/Frontend/FrontendActions.cpp (+8-8) 
- (modified) clang/lib/Frontend/LogDiagnosticPrinter.cpp (+2-2) 
- (modified) clang/lib/Frontend/SARIFDiagno

[Lldb-commits] [lldb] 8bec5e5 - [lldb-dap] Add unit tests for protocol types (#139502)

2025-05-12 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-12T13:23:50-07:00
New Revision: 8bec5e5b88de6cfa7cd979b73eafdc2ba69ee053

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

LOG: [lldb-dap] Add unit tests for protocol types (#139502)

Add unit tests for serializing and deserializing protocol types.

Added: 
lldb/unittests/DAP/ProtocolTypesTest.cpp

Modified: 
lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
lldb/unittests/DAP/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp 
b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
index 2b7419916268b..c9cab350f9f12 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp
@@ -69,6 +69,16 @@ llvm::json::Value toJSON(const Source &S) {
   return result;
 }
 
+bool fromJSON(const llvm::json::Value &Params, ExceptionBreakpointsFilter &EBF,
+  llvm::json::Path P) {
+  json::ObjectMapper O(Params, P);
+  return O && O.map("filter", EBF.filter) && O.map("label", EBF.label) &&
+ O.mapOptional("description", EBF.description) &&
+ O.mapOptional("default", EBF.defaultState) &&
+ O.mapOptional("supportsCondition", EBF.supportsCondition) &&
+ O.mapOptional("conditionDescription", EBF.conditionDescription);
+}
+
 json::Value toJSON(const ExceptionBreakpointsFilter &EBF) {
   json::Object result{{"filter", EBF.filter}, {"label", EBF.label}};
 

diff  --git a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h 
b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
index 1f0cb1e0b2d41..d1e86b0897675 100644
--- a/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
+++ b/lldb/tools/lldb-dap/Protocol/ProtocolTypes.h
@@ -55,6 +55,8 @@ struct ExceptionBreakpointsFilter {
   /// shown as the placeholder text for a text box and can be translated.
   std::optional conditionDescription;
 };
+bool fromJSON(const llvm::json::Value &, ExceptionBreakpointsFilter &,
+  llvm::json::Path);
 llvm::json::Value toJSON(const ExceptionBreakpointsFilter &);
 
 enum ColumnType : unsigned {

diff  --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index 4bbb552be9f34..8b240654046e2 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -1,9 +1,11 @@
 add_lldb_unittest(DAPTests
   JSONUtilsTest.cpp
   LLDBUtilsTest.cpp
+  ProtocolTypesTest.cpp
 
   LINK_LIBS
 lldbDAP
+LLVMTestingSupport
   LINK_COMPONENTS
 Support
   )

diff  --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp 
b/lldb/unittests/DAP/ProtocolTypesTest.cpp
new file mode 100644
index 0..fa46816ca4a10
--- /dev/null
+++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp
@@ -0,0 +1,62 @@
+//===-- ProtocolTypesTest.cpp ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Protocol/ProtocolTypes.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap::protocol;
+
+template  static llvm::Expected roundtrip(const T &input) {
+  llvm::json::Value value = toJSON(input);
+  llvm::json::Path::Root root;
+  T output;
+  if (!fromJSON(value, output, root))
+return root.getError();
+  return output;
+}
+
+TEST(ProtocolTypesTest, ExceptionBreakpointsFilter) {
+  ExceptionBreakpointsFilter filter;
+  filter.filter = "testFilter";
+  filter.label = "Test Filter";
+  filter.description = "This is a test filter";
+  filter.defaultState = true;
+  filter.supportsCondition = true;
+  filter.conditionDescription = "Condition for test filter";
+
+  llvm::Expected deserialized_filter =
+  roundtrip(filter);
+  ASSERT_THAT_EXPECTED(deserialized_filter, llvm::Succeeded());
+
+  EXPECT_EQ(filter.filter, deserialized_filter->filter);
+  EXPECT_EQ(filter.label, deserialized_filter->label);
+  EXPECT_EQ(filter.description, deserialized_filter->description);
+  EXPECT_EQ(filter.defaultState, deserialized_filter->defaultState);
+  EXPECT_EQ(filter.supportsCondition, deserialized_filter->supportsCondition);
+  EXPECT_EQ(filter.conditionDescription,
+deserialized_filter->conditionDescription);
+}
+
+TEST(ProtocolTypesTest, Source) {
+  Source source;
+  source.name = "testName";
+  source.path = "/path/to/source";
+  source.sourceReference = 12345;
+  source.presentationHint = ePresentationHintEmphasize;
+
+  llvm::Expected deserialized_source = roundtrip(source);
+  ASSERT_THAT_EXPECTED(deseri

[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (PR #139170)

2025-05-12 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> FWIW, I completely agree @royitaqi. I'm not saying inter-plugin dependencies 
> should be a free-for-all (*), but I think that some kinds of dependencies 
> make sense and I definitely think this is one of them. The debug map format 
> is intimately tied to the MachO and darwin ecosystems and I think there's 
> approximately zero chance that it will be implemented elsewhere. Using the 
> debug map requires MachO files, so why not just admit that?   
>  

To answer your last question: because the plugins (which is really a misnomer), 
as I understand it, are there to provide abstraction: the caller shouldn't have 
to know what concrete instance an `ObjectFile` is. The no-plugins-dependency 
enforces that at compile/link time. 

I'll be the first to admit that the current approach has shortcomings (like it 
does here, I totally agree with that). However we should also remember that it 
exists for a reason and that a lot of time and effort has been spent on 
detangling the plugins to fix layering issues and reduce binary sizes. The 
current rule is easy to understand and easy to enforce which makes it appealing 
and ensures we don't make things worse as we're still working on this. 

IMHO, the downsides being listed here don't outweigh the benefits, especially 
since we have a bunch of examples of those "moral dependencies". That said, if 
there's a way to enforce the DAG described in the asterisk, I'm totally fine 
with changing the rule to allow inter-plugin dependencies "where it makes 
sense" (which is still subjective). I made a similar argument in another PR a 
while ago, but I don't think we can expect reviewers to mentally verify this 
DAG every time someone tries to introduce a new inter-plugin dependencies.

TL;DR: My stance is that if there's a way to enforce the DAG, I'm totally fine 
with allowing inter-plugin dependencies where they make sense. Barring that I 
think the current rule, albeit overly strict, is the easiest way to enforce we 
don't regress inter-plugin dependencies in general. 

PS: I'm actually glad we're having this discussion. Whatever the outcome, I'd 
like to [document it on the 
website](https://lldb.llvm.org/resources/contributing.html) so contributors can 
know what to expect going forward. This comes up periodically and there's no 
reason this should be a surprise for existing or  new contributors.

https://github.com/llvm/llvm-project/pull/139170
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Remove the lldb-vscode symlink (NFC) (PR #139621)

2025-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Remove the `lldb-vscode` -> `lldb-dap` symlink in the `tools` directory. I 
initially created the symlink when we renamed the tool to make migration 
easier. I think enough time has passed that  we don't need it anymore.

My personal motivation is that the symlink causes every file in the `lldb-dap` 
directory to show up twice (once under `lldb-dap` and once under `lldb-vscode`) 
in Quick Open in VS Code.

---
Full diff: https://github.com/llvm/llvm-project/pull/139621.diff


1 Files Affected:

- (removed) lldb/tools/lldb-vscode (-1) 


``diff
diff --git a/lldb/tools/lldb-vscode b/lldb/tools/lldb-vscode
deleted file mode 12
index 46b40044086c9..0
--- a/lldb/tools/lldb-vscode
+++ /dev/null
@@ -1 +0,0 @@
-lldb-dap
\ No newline at end of file

``




https://github.com/llvm/llvm-project/pull/139621
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-05-12 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX updated 
https://github.com/llvm/llvm-project/pull/131304



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Jacques Pienaar via lldb-commits

jpienaar wrote:

I agree a condition variable would work here. I realized this later too (wanted 
all destroyed at end), one could do that as follows too

// In ManualDWARFIndex
...
   std::vector clear_cu_dies;
clear_cu_dies.reserve(units_to_index.size());
for (auto &unit : units_to_index) clear_cu_dies.push_back(*unit);
for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit*) {
  clear_cu_dies[idx].Extract();
});
...

// in DWARFUnit.cpp

void DWARFUnit::ScopedExtractDIEs::Extract() {
  {
llvm::sys::ScopedReader lock(m_cu->m_die_array_mutex);
if (!m_cu->m_die_array.empty())
  return; // Already parsed
  }
  llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
  if (!m_cu->m_die_array.empty())
return; // Already parsed

  // Otherwise m_die_array would be already populated.
  lldbassert(!m_cu->m_cancel_scopes);

  m_cu->ExtractDIEsRWLocked();
  m_clear_dies = true;
}

DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped() {
  ScopedExtractDIEs scoped(*this);
  scoped.Extract();
  return scoped;
}
---

But if plain counter preferred, will switch to that.

https://github.com/llvm/llvm-project/pull/139252
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/139252

>From c5ffbd84f8b68bae2112e8cec68803cefe571a72 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 05:23:00 -0700
Subject: [PATCH 1/3] [lldb][plugin] Clear in same thread as set

Here we were initializing & locking a mutex in a thread, while releasing it in 
the parent which may/often turned out to be a different thread 
(shared_mutex::unlock_shared is undefined behavior if called from a thread that 
doesn't hold the lock).

I'm not quite sure what the expectation is here as the variable is never used, 
so instead I've just reset in same thread as which it was set to ensure its 
freed in thread holding lock.
---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 523820874752a..0f0226ea9650c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,6 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
+ckear_cu_duex[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 5f5b8dc0deae4f63ddb83e0dfab96ab3a9e0cc80 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 08:15:26 -0700
Subject: [PATCH 2/3] Fix typo

---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0f0226ea9650c..6139d005b4f2e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,7 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
-ckear_cu_duex[idx].reset();
+ckear_cu_dies[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 6d8c69c480ce214772cb84a27da645b428916ecb Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Mon, 12 May 2025 13:19:45 +
Subject: [PATCH 3/3] Use plain reader counter

---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp   | 12 +---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h |  4 +++-
 .../Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp|  1 -
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 7d0afc04ac3b6..3a8409b1c3b66 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -189,17 +189,23 @@ DWARFUnit::ScopedExtractDIEs 
DWARFUnit::ExtractDIEsScoped() {
 }
 
 DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit &cu) : m_cu(&cu) {
-  m_cu->m_die_array_scoped_mutex.lock_shared();
+  llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
+  ++m_cu->m_die_array_scoped_count;
 }
 
 DWARFUnit::ScopedExtractDIEs::~ScopedExtractDIEs() {
   if (!m_cu)
 return;
-  m_cu->m_die_array_scoped_mutex.unlock_shared();
+  {
+llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
+--m_cu->m_die_array_scoped_count;
+if (m_cu->m_die_array_scoped_count == 0)
+  return;
+  }
   if (!m_clear_dies || m_cu->m_cancel_scopes)
 return;
   // Be sure no other ScopedExtractDIEs is running anymore.
-  llvm::sys::ScopedWriter lock_scoped(m_cu->m_die_array_scoped_mutex);
+  llvm::sys::ScopedLock lock_scoped(m_cu->m_die_array_scoped_mutex);
   llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
   if (m_cu->m_cancel_scopes)
 return;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 75a003e0a663c..c05bba36ed74b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -17,6 +17,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
+#include "llvm/Support/Mutex.h"
 #include "llvm/Support/RWMutex.h"
 #include 
 #include 
@@ -328,7 +329,8 @@ class DWARFUnit : public DWARFExpression::Delegate, public 
UserID {
   DWARFDebugInfoEntry::collection m_die_array;
   mutable llvm::sys::RWMutex m_die_array_mutex;
   // It is used for tracking of ScopedExtractDIEs instances.
-  mutable llvm::sys::RWMutex m_die_array_scoped_mutex;
+  mutable llvm::sys::Mutex m_die_array_scoped_mutex;
+  mutable int m_die_array_scoped_count = 0;
   // ScopedExtractDIEs ins

[Lldb-commits] [lldb] [lldb] Move lldb_enable_attach from test_common to a separate header (PR #139550)

2025-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

test_common is force-included into every compilation, which causes problems 
when we're compiling assembly code, as we were in #138805.

This avoids that as we can include the header only when it's needed.

---
Full diff: https://github.com/llvm/llvm-project/pull/139550.diff


17 Files Affected:

- (added) lldb/packages/Python/lldbsuite/test/make/attach.h (+34) 
- (modified) lldb/packages/Python/lldbsuite/test/make/test_common.h (-30) 
- (modified) lldb/test/API/commands/process/attach-resume/main.cpp (+3-3) 
- (modified) lldb/test/API/commands/process/attach/main.cpp (+2-2) 
- (modified) lldb/test/API/commands/process/detach-resumes/main.cpp (+2-1) 
- (modified) lldb/test/API/commands/register/register/register_command/main.cpp 
(+2-2) 
- (modified) lldb/test/API/driver/batch_mode/main.c (+1) 
- (modified) lldb/test/API/functionalities/deleted-executable/main.cpp (+1) 
- (modified) lldb/test/API/functionalities/load_after_attach/main.cpp (+3-2) 
- (modified) lldb/test/API/functionalities/process_group/main.c (+2-1) 
- (modified) lldb/test/API/functionalities/thread/create_after_attach/main.cpp 
(+2-1) 
- (modified) lldb/test/API/iohandler/completion/main.c (-1) 
- (modified) lldb/test/API/python_api/hello_world/main.c (+1) 
- (modified) lldb/test/API/tools/lldb-dap/attach/main.c (+1) 
- (modified) lldb/test/API/tools/lldb-dap/disconnect/main.cpp (+1) 
- (modified) lldb/test/API/tools/lldb-server/attach-wait/shim.cpp (+2-1) 
- (modified) lldb/test/API/tools/lldb-server/main.cpp (+1) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/make/attach.h 
b/lldb/packages/Python/lldbsuite/test/make/attach.h
new file mode 100644
index 0..decd3ea986a4b
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/make/attach.h
@@ -0,0 +1,34 @@
+#ifndef LLDB_TEST_ATTACH_H
+#define LLDB_TEST_ATTACH_H
+
+// On some systems (e.g., some versions of linux) it is not possible to attach
+// to a process without it giving us special permissions. This defines the
+// lldb_enable_attach macro, which should perform any such actions, if needed 
by
+// the platform.
+#if defined(__linux__)
+#include 
+
+// Android API <= 16 does not have these defined.
+#ifndef PR_SET_PTRACER
+#define PR_SET_PTRACER 0x59616d61
+#endif
+#ifndef PR_SET_PTRACER_ANY
+#define PR_SET_PTRACER_ANY ((unsigned long)-1)
+#endif
+
+// For now we execute on best effort basis.  If this fails for some reason, so
+// be it.
+#define lldb_enable_attach()   
\
+  do { 
\
+const int prctl_result =   
\
+prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
\
+(void)prctl_result;
\
+  } while (0)
+
+#else // not linux
+
+#define lldb_enable_attach()
+
+#endif // defined(__linux__)
+
+#endif // LLDB_TEST_ATTACH_H
diff --git a/lldb/packages/Python/lldbsuite/test/make/test_common.h 
b/lldb/packages/Python/lldbsuite/test/make/test_common.h
index aa8960e1c0aea..5082e41987020 100644
--- a/lldb/packages/Python/lldbsuite/test/make/test_common.h
+++ b/lldb/packages/Python/lldbsuite/test/make/test_common.h
@@ -20,33 +20,3 @@
 #else
 #define LLVM_PRETTY_FUNCTION LLVM_PRETTY_FUNCTION
 #endif
-
-
-// On some systems (e.g., some versions of linux) it is not possible to attach 
to a process
-// without it giving us special permissions. This defines the 
lldb_enable_attach macro, which
-// should perform any such actions, if needed by the platform. This is a macro 
instead of a
-// function to avoid the need for complex linking of the test programs.
-#if defined(__linux__)
-#include 
-
-// Android API <= 16 does not have these defined.
-#ifndef PR_SET_PTRACER
-#define PR_SET_PTRACER 0x59616d61
-#endif
-#ifndef PR_SET_PTRACER_ANY
-#define PR_SET_PTRACER_ANY ((unsigned long)-1)
-#endif
-
-// For now we execute on best effort basis.  If this fails for some reason, so 
be it.
-#define lldb_enable_attach()   
   \
-do 
   \
-{  
   \
-const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 
0, 0);  \
-(void)prctl_result;
   \
-} while (0)
-
-#else // not linux
-
-#define lldb_enable_attach()
-
-#endif
diff --git a/lldb/test/API/commands/process/attach-resume/main.cpp 
b/lldb/test/API/commands/process/attach-resume/main.cpp
index 82aad70eed560..3fe54d1e45601 100644
--- a/lldb/test/API/commands/process/attach-resume/main.cpp
+++ b/lldb/test/API/commands/process/attach-resume/main.cpp
@@ -1,7 +1,7 @@
-#include 
-#include 
-
+#include

[Lldb-commits] [lldb] [lldb] Move lldb_enable_attach from test_common to a separate header (PR #139550)

2025-05-12 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/139550

test_common is force-included into every compilation, which causes problems 
when we're compiling assembly code, as we were in #138805.

This avoids that as we can include the header only when it's needed.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb] Move lldb_enable_attach from test_common to a separate header (PR #139550)

2025-05-12 Thread Pavel Labath via lldb-commits

labath wrote:

@DavidSpickett, following up on 
https://github.com/llvm/llvm-project/issues/138085#issuecomment-2871438305, I 
noticed that some of these tests don't have the synchronization to prevent the 
test attaching before they disable YAMA -- and I think most of those tests are 
marked `@flakyIfArm`

https://github.com/llvm/llvm-project/pull/139550
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][TypeSystemClang][NFC] Use GetNumBaseClasses in TypeSystemClang::GetNumChildren (PR #139552)

2025-05-12 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/139552

`TypeSystemClang::GetNumBaseClasses` does exactly the same base-class 
accounting that we were doing in GetNumChildren. So re-use it.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb][TypeSystemClang][NFC] Use GetNumBaseClasses in TypeSystemClang::GetNumChildren (PR #139552)

2025-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

`TypeSystemClang::GetNumBaseClasses` does exactly the same base-class 
accounting that we were doing in GetNumChildren. So re-use it.

---
Full diff: https://github.com/llvm/llvm-project/pull/139552.diff


1 Files Affected:

- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+2-26) 


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 45f044733c0ff..b8ea2c17244c4 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5355,33 +5355,9 @@ 
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
   assert(record_decl);
   const clang::CXXRecordDecl *cxx_record_decl =
   llvm::dyn_cast(record_decl);
-  if (cxx_record_decl) {
-if (omit_empty_base_classes) {
-  // Check each base classes to see if it or any of its base classes
-  // contain any fields. This can help limit the noise in variable
-  // views by not having to show base classes that contain no members.
-  clang::CXXRecordDecl::base_class_const_iterator base_class,
-  base_class_end;
-  for (base_class = cxx_record_decl->bases_begin(),
-  base_class_end = cxx_record_decl->bases_end();
-   base_class != base_class_end; ++base_class) {
-const clang::CXXRecordDecl *base_class_decl =
-llvm::cast(
-base_class->getType()
-->getAs()
-->getDecl());
-
-// Skip empty base classes
-if (!TypeSystemClang::RecordHasFields(base_class_decl))
-  continue;
 
-num_children++;
-  }
-} else {
-  // Include all base classes
-  num_children += cxx_record_decl->getNumBases();
-}
-  }
+  num_children +=
+  GetNumBaseClasses(cxx_record_decl, omit_empty_base_classes);
   num_children += std::distance(record_decl->field_begin(),
record_decl->field_end());
 } else

``




https://github.com/llvm/llvm-project/pull/139552
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Provide lr value in faulting frame on arm64 (PR #138805)

2025-05-12 Thread Pavel Labath via lldb-commits

labath wrote:

I looked at why the test fails on linux. It turns out it's due to a bunch of 
reasons, but most of them are unrelated to the problem at hand. #139545 and 
#139550 fix the surrounding issues, and 
https://github.com/llvm/llvm-project/commit/c290e555d6e7d196ebbe5fd6d64e0be25275a5b4
 is enough to fix the test itself.

I needed to change the compile command because, for some reason the compiler 
was not finding the temporary file. I didn't look at what causes the difference 
because I think this is more robust and idiomatic.

I also needed to remove the `brk #0xf000` instruction because lldb is not able 
to step over it -- it just ends up spinning forever. FWICS, it's not actually 
necessary now that you're stepping through the test. Nonetheless, this is a bug 
-- one that @DavidSpickett might be interested in :)

Interestingly, the mac debug server does not step onto the breakpoint 
instruction at all. It skips over it when stepping over the previous 
instruction (i.e. that single step operation actually steps two instructions). 
This is most likely also some kind of a bug.

> FTR that test is skipped on darwin because _sigtramp in libc on aarch64 
> doesn't have any hand-supplied eh_frame right now :/

Oh... FWIW, we're in the same situation on aarch64 linux, but here we hard code 
the plan into lldb in `PlatformLinux::GetTrapHandlerUnwindPlan` (which we can, 
because it's part of the OS ABI). Maybe you could do the same?

https://github.com/llvm/llvm-project/pull/138805
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

2025-05-12 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

hi @kuilpd , I think this may have broken the mac incremental bots:

https://green.lab.llvm.org//job/as-lldb-cmake/25656/


```
[2025-05-12T12:08:03.542Z] runCmd: frame variable -d run-target *cfDictionaryRef
[2025-05-12T12:08:03.542Z] 
[2025-05-12T12:08:03.542Z] runCmd failed!
[2025-05-12T12:08:03.542Z] error: dereference failed: incomplete type "const 
__CFDictionary": (CFDictionaryRef) cfDictionaryRef
```

https://github.com/llvm/llvm-project/pull/135843
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Merge/unify ABI-provided AArch64 unwind plans (PR #139545)

2025-05-12 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/139545

>From 2aa2fd0d0777bd0bcdd1b627c2c3d306b79512c4 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 12 May 2025 04:38:05 -0700
Subject: [PATCH] [lldb] Merge/unify ABI-provided AArch64 unwind plans

The macos and sysv ABIs return functionally equivalent unwind plans, so they
can be implemented in the base AArch64 class. The only difference between them
was that the macos plan provided a "pc=lr" rule whereas the sysv plan called
SetReturnAddressRegister (which causes the unwind machinery to act as if that
rule was present). This difference was enough to cause
`CompareUnwindPlansForIdenticalInitialPCLocation` to return a different value
and break the (temporarily reverted) TestUnwindFramelessFaulted test.

While merging the two functions, I couldn't help myself from simplifying them
to use the generic register number schemes -- which exposed another bug in
CompareUnwindPlansForIdenticalInitialPCLocation, namely that it was expecting
all unwind plans to use the LLDB numbering scheme. This patch fixes that as
well.
---
 .../source/Plugins/ABI/AArch64/ABIAArch64.cpp | 42 +
 lldb/source/Plugins/ABI/AArch64/ABIAArch64.h  |  3 ++
 .../Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp   | 45 ---
 .../Plugins/ABI/AArch64/ABIMacOSX_arm64.h |  4 --
 .../Plugins/ABI/AArch64/ABISysV_arm64.cpp | 44 --
 .../Plugins/ABI/AArch64/ABISysV_arm64.h   |  4 --
 lldb/source/Symbol/FuncUnwinders.cpp  | 39 
 7 files changed, 63 insertions(+), 118 deletions(-)

diff --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 7d8d0a4d3d671..3bafb21f7c33a 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -19,6 +19,7 @@
 #include 
 
 using namespace lldb;
+using namespace lldb_private;
 
 LLDB_PLUGIN_DEFINE(ABIAArch64)
 
@@ -200,3 +201,44 @@ void ABIAArch64::AugmentRegisterInfo(
 lldb::eEncodingIEEE754, lldb::eFormatFloat);
   }
 }
+
+UnwindPlanSP ABIAArch64::CreateFunctionEntryUnwindPlan() {
+  UnwindPlan::Row row;
+
+  // Our previous Call Frame Address is the stack pointer
+  row.GetCFAValue().SetIsRegisterPlusOffset(LLDB_REGNUM_GENERIC_SP, 0);
+
+  // Our previous PC is in the LR, all other registers are the same.
+  row.SetRegisterLocationToRegister(LLDB_REGNUM_GENERIC_PC,
+LLDB_REGNUM_GENERIC_RA, true);
+
+  auto plan_sp = std::make_shared(eRegisterKindGeneric);
+  plan_sp->AppendRow(std::move(row));
+  plan_sp->SetSourceName("arm64 at-func-entry default");
+  plan_sp->SetSourcedFromCompiler(eLazyBoolNo);
+  plan_sp->SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+  plan_sp->SetUnwindPlanForSignalTrap(eLazyBoolNo);
+  return plan_sp;
+}
+
+UnwindPlanSP ABIAArch64::CreateDefaultUnwindPlan() {
+  UnwindPlan::Row row;
+  const int32_t ptr_size = 8;
+
+  row.GetCFAValue().SetIsRegisterPlusOffset(LLDB_REGNUM_GENERIC_FP,
+2 * ptr_size);
+  row.SetUnspecifiedRegistersAreUndefined(true);
+
+  row.SetRegisterLocationToAtCFAPlusOffset(LLDB_REGNUM_GENERIC_FP,
+   ptr_size * -2, true);
+  row.SetRegisterLocationToAtCFAPlusOffset(LLDB_REGNUM_GENERIC_PC,
+   ptr_size * -1, true);
+
+  auto plan_sp = std::make_shared(eRegisterKindGeneric);
+  plan_sp->AppendRow(std::move(row));
+  plan_sp->SetSourceName("arm64 default unwind plan");
+  plan_sp->SetSourcedFromCompiler(eLazyBoolNo);
+  plan_sp->SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+  plan_sp->SetUnwindPlanForSignalTrap(eLazyBoolNo);
+  return plan_sp;
+}
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
index 52e42f1260a83..53702f4da580d 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -19,6 +19,9 @@ class ABIAArch64 : public lldb_private::MCBasedABI {
   lldb::addr_t FixCodeAddress(lldb::addr_t pc) override;
   lldb::addr_t FixDataAddress(lldb::addr_t pc) override;
 
+  lldb::UnwindPlanSP CreateFunctionEntryUnwindPlan() override;
+  lldb::UnwindPlanSP CreateDefaultUnwindPlan() override;
+
 protected:
   virtual lldb::addr_t FixAddress(lldb::addr_t pc, lldb::addr_t mask) {
 return pc;
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index f86ab8cbb1195..094e0523a4edf 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -17,7 +17,6 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Value.h"
-#include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/T

[Lldb-commits] [lldb] [lldb][TypeSystemClang][NFC] Use GetNumBaseClasses in TypeSystemClang::GetNumChildren (PR #139552)

2025-05-12 Thread Pavel Labath via lldb-commits

https://github.com/labath approved this pull request.

yay

https://github.com/llvm/llvm-project/pull/139552
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Pavel Labath via lldb-commits


@@ -189,17 +189,23 @@ DWARFUnit::ScopedExtractDIEs 
DWARFUnit::ExtractDIEsScoped() {
 }
 
 DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit &cu) : m_cu(&cu) {
-  m_cu->m_die_array_scoped_mutex.lock_shared();
+  llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
+  ++m_cu->m_die_array_scoped_count;
 }
 
 DWARFUnit::ScopedExtractDIEs::~ScopedExtractDIEs() {
   if (!m_cu)
 return;
-  m_cu->m_die_array_scoped_mutex.unlock_shared();
+  {
+llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
+--m_cu->m_die_array_scoped_count;
+if (m_cu->m_die_array_scoped_count == 0)
+  return;
+  }
   if (!m_clear_dies || m_cu->m_cancel_scopes)
 return;
   // Be sure no other ScopedExtractDIEs is running anymore.

labath wrote:

I think all of this can/should be one critical section. The reason the code was 
originally doing the unlock is because it was switching the lock type 
(shared->exclusive). So, I think something like this ought to do it:

```
  llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
  --m_cu->m_die_array_scoped_count;
  if (m_cu->m_die_array_scoped_count == 0 && m_clear_dies && 
!m_cu->m_cancel_scopes)
m_cu->ClearDIEsRWLocked();
```

https://github.com/llvm/llvm-project/pull/139252
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Pavel Labath via lldb-commits

labath wrote:

> But if plain counter preferred, will switch to that.

That is the first idea that crossed my mind, I'm not saying its the best one. 
I'm not really sure how would a condition variable help here (like, you still 
need some kind of a counter to trigger the condition), but I'm open to other 
approaches.

https://github.com/llvm/llvm-project/pull/139252
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Remove the lldb-vscode symlink (NFC) (PR #139621)

2025-05-12 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/139621

Remove the `lldb-vscode` -> `lldb-dap` symlink in the `tools` directory. I 
initially created the symlink when we renamed the tool to make migration 
easier. I think enough time has passed that  we don't need it anymore.

My personal motivation is that the symlink causes every file in the `lldb-dap` 
directory to show up twice (once under `lldb-dap` and once under `lldb-vscode`) 
in Quick Open in VS Code.

>From de8cfd54b4d3c177872e8c9fbfbf5f3e779167ac Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 12 May 2025 13:37:53 -0700
Subject: [PATCH] [lldb-dap] Remove the lldb-vscode symlink (NFC)

Remove the lldb-vscode -> lldb-dap symlink in the tools directory. I
initially created the symlink when we renamed the tool to make migration
easier. I think enough time has passed that  we don't need it anymore.

My personal motivation is that the symlink causes every file in the
lldb-dap directory to show up twice (once under lldb-dap and once under
lldb-vscode) in Quick Open in VS Code.
---
 lldb/tools/lldb-vscode | 1 -
 1 file changed, 1 deletion(-)
 delete mode 12 lldb/tools/lldb-vscode

diff --git a/lldb/tools/lldb-vscode b/lldb/tools/lldb-vscode
deleted file mode 12
index 46b40044086c9..0
--- a/lldb/tools/lldb-vscode
+++ /dev/null
@@ -1 +0,0 @@
-lldb-dap
\ No newline at end of file

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


[Lldb-commits] [lldb] [lldb-dap] Remove the lldb-vscode symlink (NFC) (PR #139621)

2025-05-12 Thread John Harrison via lldb-commits

https://github.com/ashgti approved this pull request.


https://github.com/llvm/llvm-project/pull/139621
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-05-12 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,546 @@
+//===-- RPCCommon.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication",  // What is this used for?
+"SBInputReader",// What is this used for?

chelcassanova wrote:

@DavidSpickett On the original and larger patch that I had up for this, you 
asked if we could answer what these files are used for. I think Greg Clayton 
might know? But otherwise, these comments should be changed to better clarify 
that we just don't need these classes in RPC for now.

https://github.com/llvm/llvm-project/pull/138031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-12 Thread Jonas Devlieghere via lldb-commits


@@ -269,17 +271,16 @@ struct Capabilities {
 };
 llvm::json::Value toJSON(const Capabilities &);
 
-enum PresentationHint : unsigned {
-  ePresentationHintNormal,
-  ePresentationHintEmphasize,
-  ePresentationHintDeemphasize,
-};
-llvm::json::Value toJSON(PresentationHint hint);
-
 /// A `Source` is a descriptor for source code. It is returned from the debug
 /// adapter as part of a `StackFrame` and it is used by clients when specifying
 /// breakpoints.
 struct Source {
+  enum PresentationHint : unsigned {
+ePresentationHintNormal,
+ePresentationHintEmphasize,
+ePresentationHintDeemphasize,
+  };

JDevlieghere wrote:

I'm slightly leaning towards that too, because that would be most consistent 
with the other enums which are potentially shared across types. 

https://github.com/llvm/llvm-project/pull/138116
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)

2025-05-12 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

LGTM modulo the enum nit. Please add a unit test for `Scope` now that that's 
possible :-) 

https://github.com/llvm/llvm-project/pull/138116
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support stepping through Darwin "branch islands" (PR #139301)

2025-05-12 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/139301



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-12 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

> Maybe we should use line 1 than as that's the first real line number?

done!  thanks!

https://github.com/llvm/llvm-project/pull/139002
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] fb9b43a - [lldb-dap] Fix the framework build

2025-05-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-12T09:51:15-07:00
New Revision: fb9b43a0c56de9b1f36e862565c33e0ad637fb36

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

LOG: [lldb-dap] Fix the framework build

I forgot to remove the original logic after moving it into the tool
subdirectory.

Added: 


Modified: 
lldb/tools/lldb-dap/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index 608166bf0e0dd..224d64b83b7d4 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -84,18 +84,3 @@ if(LLDB_DAP_WELCOME_MESSAGE)
 PRIVATE
 -DLLDB_DAP_WELCOME_MESSAGE=\"${LLDB_DAP_WELCOME_MESSAGE}\")
 endif()
-
-if(LLDB_BUILD_FRAMEWORK)
-  # In the build-tree, we know the exact path to the framework directory.
-  # The installed framework can be in 
diff erent locations.
-  lldb_setup_rpaths(lldb-dap
-BUILD_RPATH
-  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
-INSTALL_RPATH
-  "@loader_path/../../../SharedFrameworks"
-  "@loader_path/../../System/Library/PrivateFrameworks"
-  "@loader_path/../../Library/PrivateFrameworks"
-  )
-endif()
-
-add_subdirectory(tool)



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


[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-12 Thread Jan Svoboda via lldb-commits

https://github.com/jansvoboda11 created 
https://github.com/llvm/llvm-project/pull/139584

The `DiagnosticOptions` class is currently intrusively reference-counted, which 
makes reasoning about its lifetime very difficult in some cases. For example, 
`CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in 
`llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning 
`DiagnosticOptions &`. One would think this gives `CompilerInvocation` 
exclusive ownership of the object, but that's not the case:

```c++
void shareOwnership(CompilerInvocation &CI) {
  llvm::IntrusiveRefCntPtr CoOwner = 
&CI.getDiagnosticOptions();
 // ...
}
```

This is a perfectly valid pattern that is being actually used in the codebase.

I would like to ensure the ownership of `DiagnosticOptions` by 
`CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a 
copy-on-write optimization later on. This PR changes usages of 
`DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be 
intrusively reference-counted.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-12 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/139002

>From 5746e997eea55c05cbbb63ad6f78ca225c9ac855 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 7 May 2025 21:37:31 -0400
Subject: [PATCH 1/8] [lldb]Make `list` command work with  headers when
 possible.

---
 lldb/source/Commands/CommandObjectSource.cpp | 36 +++-
 lldb/source/Core/ModuleList.cpp  |  2 +
 lldb/test/Shell/Commands/list-header.test| 59 
 3 files changed, 94 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/list-header.test

diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index c205813565d52..475317021255c 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1104,6 +1104,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   bool check_inlines = false;
   SymbolContextList sc_list;
   size_t num_matches = 0;
+  uint32_t start_line = m_options.start_line;
 
   if (!m_options.modules.empty()) {
 ModuleList matching_modules;
@@ -1114,7 +1115,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
 num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 SymbolContextItem(eSymbolContextModule |
   eSymbolContextCompUnit),
 sc_list);
@@ -1122,7 +1123,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 }
   } else {
 num_matches = target.GetImages().ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 eSymbolContextModule | eSymbolContextCompUnit, sc_list);
   }
 
@@ -1170,8 +1171,37 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's 
file(s)
+  // will be found.
+  // So if a header was requested and we got a primary file, then look
+  // thru its support file(s) for the header.
+  lldb::SupportFileSP actual_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+  if (llvm::StringRef(m_options.file_name).ends_with(".h")) {
+int support_matches_count = 0;
+for (auto &file : sc.comp_unit->GetSupportFiles()) {
+  if 
(llvm::StringRef(file->GetSpecOnly().GetPath()).ends_with(filename)) {
+actual_file_sp = file;
+++support_matches_count;
+  }
+}
+if (support_matches_count == 0) {
+  result.AppendErrorWithFormat(
+  "No file found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+} else if (support_matches_count > 1) {
+  result.AppendErrorWithFormat(
+  "Multiple files found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+}
+  }
+
   target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
-  sc.comp_unit->GetPrimarySupportFile(),
+  actual_file_sp,
   m_options.start_line, column, 0, m_options.num_lines, "",
   &result.GetOutputStream(), GetBreakpointLocations());
 
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index d5ddf6e846112..90c6a62727734 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -714,6 +714,8 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec(
 const FileSpec &file_spec, uint32_t line, bool check_inlines,
 SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
   std::lock_guard guard(m_modules_mutex);
+  // If we're looking for a header (not source), then need to check inline.
+  check_inlines = check_inlines || !file_spec.IsSourceImplementationFile();
   for (const ModuleSP &module_sp : m_modules) {
 module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
 resolve_scope, sc_list);
diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
new file mode 100644
index 0..ca700cd2b2fb1
--- /dev/null
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -0,0 +1,59 @@
+## Test that `list header.h:` works correctly when header is available.
+## 
+# REQUIRE

[Lldb-commits] [lldb] [lldb] Restore ObjC incomplete type dereferencing fix (PR #139567)

2025-05-12 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd ready_for_review 
https://github.com/llvm/llvm-project/pull/139567
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c8a0513 - [lldb] Restore ObjC incomplete type dereferencing fix (#139567)

2025-05-12 Thread via lldb-commits

Author: Ilia Kuklin
Date: 2025-05-12T22:59:40+05:00
New Revision: c8a0513a1a694078e5ea927faf8249ce77084d80

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

LOG: [lldb] Restore ObjC incomplete type dereferencing fix (#139567)

Attempt an ObjC incomplete type fix even if `GetDereferencedType`
returns an error.

Added: 


Modified: 
lldb/source/ValueObject/ValueObject.cpp

Removed: 




diff  --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index 6f0fe9a5b83f9..46426ae499be9 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2810,46 +2810,47 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
   std::string deref_error;
   if (deref_compiler_type_or_err) {
 deref_compiler_type = *deref_compiler_type_or_err;
-if (deref_compiler_type && deref_byte_size) {
-  ConstString deref_name;
-  if (!deref_name_str.empty())
-deref_name.SetCString(deref_name_str.c_str());
-
-  m_deref_valobj =
-  new ValueObjectChild(*this, deref_compiler_type, deref_name,
-   deref_byte_size, deref_byte_offset, 0, 0, false,
-   true, eAddressTypeInvalid, language_flags);
-}
-
-// In case of incomplete deref compiler type, use the pointee type and try
-// to recreate a new ValueObjectChild using it.
-if (!m_deref_valobj) {
-  // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
-  // `std::vector &`). Remove ObjC restriction once that's resolved.
-  if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
-  HasSyntheticValue()) {
-deref_compiler_type = compiler_type.GetPointeeType();
-
-if (deref_compiler_type) {
-  ConstString deref_name;
-  if (!deref_name_str.empty())
-deref_name.SetCString(deref_name_str.c_str());
-
-  m_deref_valobj = new ValueObjectChild(
-  *this, deref_compiler_type, deref_name, deref_byte_size,
-  deref_byte_offset, 0, 0, false, true, eAddressTypeInvalid,
-  language_flags);
-}
-  }
-}
   } else {
 deref_error = llvm::toString(deref_compiler_type_or_err.takeError());
 LLDB_LOG(GetLog(LLDBLog::Types), "could not find child: {0}", deref_error);
-if (IsSynthetic()) {
-  m_deref_valobj = GetChildMemberWithName("$$dereference$$").get();
+  }
+
+  if (deref_compiler_type && deref_byte_size) {
+ConstString deref_name;
+if (!deref_name_str.empty())
+  deref_name.SetCString(deref_name_str.c_str());
+
+m_deref_valobj =
+new ValueObjectChild(*this, deref_compiler_type, deref_name,
+ deref_byte_size, deref_byte_offset, 0, 0, false,
+ true, eAddressTypeInvalid, language_flags);
+  }
+
+  // In case of incomplete deref compiler type, use the pointee type and try
+  // to recreate a new ValueObjectChild using it.
+  if (!m_deref_valobj) {
+// FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
+// `std::vector &`). Remove ObjC restriction once that's resolved.
+if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
+HasSyntheticValue()) {
+  deref_compiler_type = compiler_type.GetPointeeType();
+
+  if (deref_compiler_type) {
+ConstString deref_name;
+if (!deref_name_str.empty())
+  deref_name.SetCString(deref_name_str.c_str());
+
+m_deref_valobj = new ValueObjectChild(
+*this, deref_compiler_type, deref_name, deref_byte_size,
+deref_byte_offset, 0, 0, false, true, eAddressTypeInvalid,
+language_flags);
+  }
 }
   }
 
+  if (!m_deref_valobj && IsSynthetic())
+m_deref_valobj = GetChildMemberWithName("$$dereference$$").get();
+
   if (m_deref_valobj) {
 error.Clear();
 return m_deref_valobj->GetSP();



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


[Lldb-commits] [lldb] [lldb] Restore ObjC incomplete type dereferencing fix (PR #139567)

2025-05-12 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd closed 
https://github.com/llvm/llvm-project/pull/139567
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Restore ObjC incomplete type dereferencing fix (PR #139567)

2025-05-12 Thread Ilia Kuklin via lldb-commits

kuilpd wrote:

Thank you!

https://github.com/llvm/llvm-project/pull/139567
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] While handling events, grab the APIMutex for consistency. (PR #139596)

2025-05-12 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

I too have been contemplating this for a while...

Given that the request handlers currently lock the API mutex and now the event 
thread does the same, this patch means that the two are essentially fully 
synchronized. That begs the question: Should these be separate threads at all? 
We could sidestep all the synchronization issues  by handling request and 
events on the same thread using the `MainLoop`.

https://github.com/llvm/llvm-project/pull/139596
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-05-12 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,535 @@
+//===-- RPCCommon.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication",  // What is this used for?
+"SBInputReader",// What is this used for?
+"SBCommandPluginInterface", // This is hard to support, we can do it if
+// really needed though.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// FIXME: We should be able to annotate these methods instead of maintaining a
+// list in the generator itself.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
+};
+
+static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
+"SBHostOS",
+"SBReproducer",
+};
+
+static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
+"SBHostOS",
+"SBReproducer",
+"SBStream",
+"SBProgress",
+};
+
+static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {

chelcassanova wrote:

I misspoke here, it wouldn't be a typedef but a new SB class that holds a 
struct that would be used in place of pointer + lens. This class could then be 
picked up by the tool (i.e. if one of the function params uses this class) to 
know if it's a pointer + len method without using this list.

https://github.com/llvm/llvm-project/pull/138031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][RPC] Upstream lldb-rpc-gen tool (PR #138031)

2025-05-12 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,535 @@
+//===-- RPCCommon.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RPCCommon.h"
+
+#include "clang/AST/AST.h"
+#include "clang/AST/Mangle.h"
+#include "clang/Lex/Lexer.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+// We intentionally do not generate some classes because they are currently
+// inconvenient, they aren't really used by most consumers, or we're not sure
+// why they exist.
+static constexpr llvm::StringRef DisallowedClasses[] = {
+"SBCommunication",  // What is this used for?
+"SBInputReader",// What is this used for?
+"SBCommandPluginInterface", // This is hard to support, we can do it if
+// really needed though.
+"SBCommand", // There's nothing too difficult about this one, but many of
+ // its methods take a SBCommandPluginInterface pointer so
+ // there's no reason to support this.
+};
+
+// We intentionally avoid generating certain methods either because they are
+// difficult to support correctly or they aren't really used much from C++.
+// FIXME: We should be able to annotate these methods instead of maintaining a
+// list in the generator itself.
+static constexpr llvm::StringRef DisallowedMethods[] = {
+// The threading functionality in SBHostOS is deprecated and thus we do not
+// generate them. It would be ideal to add the annotations to the methods
+// and then support not generating deprecated methods. However, without
+// annotations the generator generates most things correctly. This one is
+// problematic because it returns a pointer to an "opaque" structure
+// (thread_t) that is not `void *`, so special casing it is more effort 
than
+// it's worth.
+"_ZN4lldb8SBHostOS10ThreadJoinEP17_opaque_pthread_tPPvPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCancelEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadCreateEPKcPFPvS3_ES3_PNS_7SBErrorE",
+"_ZN4lldb8SBHostOS12ThreadDetachEP17_opaque_pthread_tPNS_7SBErrorE",
+"_ZN4lldb8SBHostOS13ThreadCreatedEPKc",
+};
+
+static constexpr llvm::StringRef ClassesWithoutDefaultCtor[] = {
+"SBHostOS",
+"SBReproducer",
+};
+
+static constexpr llvm::StringRef ClassesWithoutCopyOperations[] = {
+"SBHostOS",
+"SBReproducer",
+"SBStream",
+"SBProgress",
+};
+
+static constexpr llvm::StringRef MethodsWithPointerPlusLen[] = {

chelcassanova wrote:

So you'd have a class called something like `SBBuffer` and it would have a 
struct:
```
struct Buffer {
Buffer(void *buf, size_t size) {}
};
```

that covers a pointer + len. In a function that uses it (e.g. `size_t 
ReadRawData(lldb::SBError &error, lldb::offset_t offset, void *buf, size_t 
size`) becomes `size_t ReadRawData(lldb::SBError &error, lldb::offset_t offset, 
SBBuffer buf)`. 

The tool could see that the method has an `SBBuffer` parameter, so that could 
satisfy the "this method is using a pointer followed by a length". The older 
version of the original method would be marked as deprecated.

Obviously the main task here is having a cleaner way of knowing this detail 
about methods without maintaining an ever growing list. Another path we could 
try is using Clang's `annotate` attribute to note this information on the API 
side. The tool should also be able to pick up on this, but it also means adding 
an attribute to the main APIs that isn't very meaningful if you're not using 
RPC.


https://github.com/llvm/llvm-project/pull/138031
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 4086d5f - [lldb-dap] Unbreak lldb-dap

2025-05-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-12T11:56:57-07:00
New Revision: 4086d5ff74729e655c3b29479845c35c971541d9

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

LOG: [lldb-dap] Unbreak lldb-dap

Added: 


Modified: 
lldb/tools/lldb-dap/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/lldb-dap/CMakeLists.txt 
b/lldb/tools/lldb-dap/CMakeLists.txt
index 224d64b83b7d4..5dedee8a87f41 100644
--- a/lldb/tools/lldb-dap/CMakeLists.txt
+++ b/lldb/tools/lldb-dap/CMakeLists.txt
@@ -84,3 +84,5 @@ if(LLDB_DAP_WELCOME_MESSAGE)
 PRIVATE
 -DLLDB_DAP_WELCOME_MESSAGE=\"${LLDB_DAP_WELCOME_MESSAGE}\")
 endif()
+
+add_subdirectory(tool)



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


[Lldb-commits] [lldb] [lldb-dap] While handling events, grab the APIMutex for consistency. (PR #139596)

2025-05-12 Thread John Harrison via lldb-commits

ashgti wrote:

I'll take a look at refactoring the `DAP::Loop` and `EventThread`.

https://github.com/llvm/llvm-project/pull/139596
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB] Add field member operators to DIL (PR #138093)

2025-05-12 Thread via lldb-commits


@@ -272,4 +272,66 @@ Interpreter::Visit(const UnaryOpNode *node) {
   m_expr, "invalid ast: unexpected binary operator", node->GetLocation());
 }
 
+llvm::Expected
+Interpreter::Visit(const MemberOfNode *node) {
+  Status error;
+  auto base_or_err = Evaluate(node->GetBase());
+  if (!base_or_err) {
+return base_or_err;
+  }
+  lldb::ValueObjectSP base = *base_or_err;
+
+  // Perform basic type checking.
+  CompilerType base_type = base->GetCompilerType();
+  // When using an arrow, make sure the base is a pointer or array type.
+  // When using a period, make sure the base type is NOT a pointer type.
+  if (node->GetIsArrow() && !base_type.IsPointerType() &&
+  !base_type.IsArrayType()) {
+lldb::ValueObjectSP deref_sp = base->Dereference(error);
+if (error.Success()) {
+  base = deref_sp;
+  base_type = deref_sp->GetCompilerType().GetPointerType();
+} else {
+  std::string errMsg =
+  llvm::formatv("member reference type {0} is not a pointer; "
+"did you mean to use '.'?",
+base_type.TypeDescription());
+  return llvm::make_error(
+  m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+}
+  } else if (!node->GetIsArrow() && base_type.IsPointerType()) {
+std::string errMsg =
+llvm::formatv("member reference type {0} is a pointer; "
+  "did you mean to use '->'?",
+  base_type.TypeDescription());
+return llvm::make_error(
+m_expr, errMsg, node->GetLocation(), node->GetFieldName().size());
+  }
+
+  // User specified array->elem; need to get to element[0] to look for fields.
+  if (node->GetIsArrow() && base_type.IsArrayType())
+base = base->GetChildAtIndex(0);
+
+  // Now look for the member with the specified name.
+  lldb::ValueObjectSP field_obj =
+  base->GetChildMemberWithName(llvm::StringRef(node->GetFieldName()));
+  if (field_obj && field_obj->GetName().GetString() == node->GetFieldName()) {
+if (field_obj->GetCompilerType().IsReferenceType()) {
+  lldb::ValueObjectSP tmp_obj = field_obj->Dereference(error);
+  if (error.Fail())
+return error.ToError();
+  return tmp_obj;
+}
+return field_obj;
+  }
+
+  if (node->GetIsArrow() && base_type.IsPointerType())
+base_type = base_type.GetPointeeType();
+  std::string errMsg =
+  llvm::formatv("no member named '{0}' in {1}", node->GetFieldName(),

cmtice wrote:

We don't get an error from GetChildMemberWithName. Either it returns a 
ValueObjectSP, or it returns a nullptr.

https://github.com/llvm/llvm-project/pull/138093
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Refactor lldb-dap event handling. (PR #139669)

2025-05-12 Thread John Harrison via lldb-commits

ashgti wrote:

The tests are passing for me locally on macOS, but I need to check Linux at 
least before this is fully ready for review. I'll let the CI job run and go 
from there.

https://github.com/llvm/llvm-project/pull/139669
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3aacd74 - [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (#135843)

2025-05-12 Thread via lldb-commits

Author: Ilia Kuklin
Date: 2025-05-12T16:46:58+05:00
New Revision: 3aacd74594b1f8ab04904d277b6a106c98904b29

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

LOG: [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (#135843)

Add a function `GetDereferencedType` to `CompilerType` and allow
`TypeSystemClang` to dereference arrays.

Added: 


Modified: 
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp
lldb/source/ValueObject/ValueObject.cpp

lldb/test/API/commands/frame/var-dil/basics/PointerArithmetic/TestFrameVarDILPointerArithmetic.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py

Removed: 




diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index fdbc2057ac10f..b8badfda92cf3 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -433,6 +433,11 @@ class CompilerType {
 
   CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const;
 
+  llvm::Expected
+  GetDereferencedType(ExecutionContext *exe_ctx, std::string &deref_name,
+  uint32_t &deref_byte_size, int32_t &deref_byte_offset,
+  ValueObject *valobj, uint64_t &language_flags) const;
+
   llvm::Expected GetChildCompilerTypeAtIndex(
   ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
   bool omit_empty_base_classes, bool ignore_array_bounds,

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index df87fea32b72a..1f1a3ac4bc56b 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -364,6 +364,12 @@ class TypeSystem : public PluginInterface,
 return CompilerDecl();
   }
 
+  virtual llvm::Expected
+  GetDereferencedType(lldb::opaque_compiler_type_t type,
+  ExecutionContext *exe_ctx, std::string &deref_name,
+  uint32_t &deref_byte_size, int32_t &deref_byte_offset,
+  ValueObject *valobj, uint64_t &language_flags) = 0;
+
   virtual llvm::Expected GetChildCompilerTypeAtIndex(
   lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
   bool transparent_pointers, bool omit_empty_base_classes,

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 3b286885cc37f..d24f3726b1d25 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6184,6 +6184,24 @@ uint32_t 
TypeSystemClang::GetNumPointeeChildren(clang::QualType type) {
   return 0;
 }
 
+llvm::Expected TypeSystemClang::GetDereferencedType(
+lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
+std::string &deref_name, uint32_t &deref_byte_size,
+int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) 
{
+  bool type_valid = IsPointerOrReferenceType(type, nullptr) ||
+IsArrayType(type, nullptr, nullptr, nullptr);
+  if (!type_valid)
+return llvm::createStringError("not a pointer, reference or array type");
+  uint32_t child_bitfield_bit_size = 0;
+  uint32_t child_bitfield_bit_offset = 0;
+  bool child_is_base_class;
+  bool child_is_deref_of_parent;
+  return GetChildCompilerTypeAtIndex(
+  type, exe_ctx, 0, false, true, false, deref_name, deref_byte_size,
+  deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
+  child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
+}
+
 llvm::Expected TypeSystemClang::GetChildCompilerTypeAtIndex(
 lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
 bool transparent_pointers, bool omit_empty_base_classes,

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 93933846d114d..f918cb017f51b 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -889,6 +889,12 @@ class TypeSystemClang : public TypeSystem {
 
   static uint32_t GetNumPointeeChildren(clang::QualType type);
 
+  llvm::Expected
+  GetDereferencedType(lldb::opaque_compiler_type_t type,
+  ExecutionContext *exe_ctx, std::string &deref_name,
+  uint32_t &deref_byte_size, int32_t &deref_byte_offset,
+  ValueObject *valobj, uint64_t &language_flags) over

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Allow arrays to be dereferenced in C/C++. (PR #135843)

2025-05-12 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd closed 
https://github.com/llvm/llvm-project/pull/135843
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper approved this pull request.


https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add unit tests for protocol types (PR #139502)

2025-05-12 Thread Ebuka Ezike via lldb-commits

da-viper wrote:

LGTM. tiny nit for concrete types

https://github.com/llvm/llvm-project/pull/139502
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-12 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX created 
https://github.com/llvm/llvm-project/pull/139537

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

**Description:**
Adding NativeThreadAIX base files, along with the implementation of GetName() 
for AIX, 
to be integrated with already merged NativeProcessAIX.

>From 05aef7d40097d9a554c648fa2be75530f23ca05c Mon Sep 17 00:00:00 2001
From: DhruvSrivastavaX 
Date: Mon, 12 May 2025 03:23:49 -0500
Subject: [PATCH] Added NativeThreadAIX

---
 .../source/Plugins/Process/AIX/CMakeLists.txt |  1 +
 .../Plugins/Process/AIX/NativeThreadAIX.cpp   | 71 +++
 .../Plugins/Process/AIX/NativeThreadAIX.h | 53 ++
 3 files changed, 125 insertions(+)
 create mode 100644 lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
 create mode 100644 lldb/source/Plugins/Process/AIX/NativeThreadAIX.h

diff --git a/lldb/source/Plugins/Process/AIX/CMakeLists.txt 
b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
index 9a3c77bd2ffeb..911f30349ef52 100644
--- a/lldb/source/Plugins/Process/AIX/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_library(lldbPluginProcessAIX
   NativeProcessAIX.cpp
+  NativeThreadAIX.cpp
 
   LINK_LIBS
 lldbCore
diff --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp 
b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
new file mode 100644
index 0..c9593fbf08441
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
@@ -0,0 +1,71 @@
+//===-- NativeThreadAIX.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NativeThreadAIX.h"
+#include "NativeProcessAIX.h"
+#include "lldb/Utility/State.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+
+NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
+: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
+
+std::string NativeThreadAIX::GetName() {
+  NativeProcessAIX &process = GetProcess();
+  auto BufferOrError = getProcFile(process.GetID(), "psinfo");
+  if (!BufferOrError)
+return "";
+  auto &Buffer = *BufferOrError;
+  if (Buffer->getBufferSize() < sizeof(psinfo_t))
+return "";
+  const psinfo_t *psinfo =
+  reinterpret_cast(Buffer->getBufferStart());
+  return std::string(psinfo->pr_fname);
+}
+
+lldb::StateType NativeThreadAIX::GetState() { return m_state; }
+
+bool NativeThreadAIX::GetStopReason(ThreadStopInfo &stop_info,
+std::string &description) {
+  return false;
+}
+
+Status NativeThreadAIX::SetWatchpoint(lldb::addr_t addr, size_t size,
+  uint32_t watch_flags, bool hardware) {
+  return Status();
+}
+
+Status NativeThreadAIX::RemoveWatchpoint(lldb::addr_t addr) {
+  return Status("Clearing hardware watchpoint failed.");
+}
+
+Status NativeThreadAIX::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) {
+  return Status();
+}
+
+Status NativeThreadAIX::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+  return Status("Clearing hardware breakpoint failed.");
+}
+
+NativeProcessAIX &NativeThreadAIX::GetProcess() {
+  return static_cast(m_process);
+}
+
+const NativeProcessAIX &NativeThreadAIX::GetProcess() const {
+  return static_cast(m_process);
+}
+
+llvm::Expected>
+NativeThreadAIX::GetSiginfo() const {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Not implemented");
+}
diff --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h 
b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
new file mode 100644
index 0..e32d3db2c5fa2
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
@@ -0,0 +1,53 @@
+//===-- NativeThreadAIX.h --- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_
+#define LLDB_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_
+
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+namespace lldb_private::process_aix {
+
+class NativeProcessAIX;
+
+class NativeThreadAIX : public

[Lldb-commits] [lldb] [lldb][AIX] Adding NativeThreadAIX (PR #139537)

2025-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dhruv Srivastava (DhruvSrivastavaX)


Changes

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

**Description:**
Adding NativeThreadAIX base files, along with the implementation of GetName() 
for AIX, 
to be integrated with already merged NativeProcessAIX.

---
Full diff: https://github.com/llvm/llvm-project/pull/139537.diff


3 Files Affected:

- (modified) lldb/source/Plugins/Process/AIX/CMakeLists.txt (+1) 
- (added) lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp (+71) 
- (added) lldb/source/Plugins/Process/AIX/NativeThreadAIX.h (+53) 


``diff
diff --git a/lldb/source/Plugins/Process/AIX/CMakeLists.txt 
b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
index 9a3c77bd2ffeb..911f30349ef52 100644
--- a/lldb/source/Plugins/Process/AIX/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_library(lldbPluginProcessAIX
   NativeProcessAIX.cpp
+  NativeThreadAIX.cpp
 
   LINK_LIBS
 lldbCore
diff --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp 
b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
new file mode 100644
index 0..c9593fbf08441
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.cpp
@@ -0,0 +1,71 @@
+//===-- NativeThreadAIX.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NativeThreadAIX.h"
+#include "NativeProcessAIX.h"
+#include "lldb/Utility/State.h"
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+
+NativeThreadAIX::NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid)
+: NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid) {}
+
+std::string NativeThreadAIX::GetName() {
+  NativeProcessAIX &process = GetProcess();
+  auto BufferOrError = getProcFile(process.GetID(), "psinfo");
+  if (!BufferOrError)
+return "";
+  auto &Buffer = *BufferOrError;
+  if (Buffer->getBufferSize() < sizeof(psinfo_t))
+return "";
+  const psinfo_t *psinfo =
+  reinterpret_cast(Buffer->getBufferStart());
+  return std::string(psinfo->pr_fname);
+}
+
+lldb::StateType NativeThreadAIX::GetState() { return m_state; }
+
+bool NativeThreadAIX::GetStopReason(ThreadStopInfo &stop_info,
+std::string &description) {
+  return false;
+}
+
+Status NativeThreadAIX::SetWatchpoint(lldb::addr_t addr, size_t size,
+  uint32_t watch_flags, bool hardware) {
+  return Status();
+}
+
+Status NativeThreadAIX::RemoveWatchpoint(lldb::addr_t addr) {
+  return Status("Clearing hardware watchpoint failed.");
+}
+
+Status NativeThreadAIX::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) {
+  return Status();
+}
+
+Status NativeThreadAIX::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+  return Status("Clearing hardware breakpoint failed.");
+}
+
+NativeProcessAIX &NativeThreadAIX::GetProcess() {
+  return static_cast(m_process);
+}
+
+const NativeProcessAIX &NativeThreadAIX::GetProcess() const {
+  return static_cast(m_process);
+}
+
+llvm::Expected>
+NativeThreadAIX::GetSiginfo() const {
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Not implemented");
+}
diff --git a/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h 
b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
new file mode 100644
index 0..e32d3db2c5fa2
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeThreadAIX.h
@@ -0,0 +1,53 @@
+//===-- NativeThreadAIX.h --- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_
+#define LLDB_SOURCE_PLUGINS_PROCESS_AIX_NATIVETHREADAIX_H_
+
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+namespace lldb_private::process_aix {
+
+class NativeProcessAIX;
+
+class NativeThreadAIX : public NativeThreadProtocol {
+  friend class NativeProcessAIX;
+
+public:
+  NativeThreadAIX(NativeProcessAIX &process, lldb::tid_t tid);
+
+  // NativeThreadProtocol Interface
+  std::string GetName() override;
+
+  lldb::StateType GetStat

[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Pavel Labath via lldb-commits

https://github.com/labath requested changes to this pull request.

This defeats the purpose of storing the sentinel object -- the goal was to 
clear it only after performing all the indexing.

I think the ScopedExtractDIEs object needs to be implemented differently. It 
uses the RWMutex as a counter of active object instances, which is... cute... 
but not really necessary. Instead of the RW mutex, it could count the number of 
instances directly (in an integer variable) and then clean up when the count 
goes to zero. The variable could be protected by a (regular) mutex, and this 
would only need to be locked while manipulating the variable, so it will always 
be unlocked/locked on the same thread.

https://github.com/llvm/llvm-project/pull/139252
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][AIX] Support for XCOFF Sections (PR #131304)

2025-05-12 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX updated 
https://github.com/llvm/llvm-project/pull/131304

>From 106e137fea7d4b420ce3d97a8df16c3a91400997 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava 
Date: Fri, 14 Mar 2025 02:51:21 -0500
Subject: [PATCH 1/6] Support for XCOFF Sections

---
 .../ObjectFile/XCOFF/ObjectFileXCOFF.cpp  | 153 +-
 1 file changed, 114 insertions(+), 39 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index b54d43c5dd737..0dd9126468923 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -190,50 +190,125 @@ void ObjectFileXCOFF::ParseSymtab(Symtab &lldb_symtab) {}
 
 bool ObjectFileXCOFF::IsStripped() { return false; }
 
-void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {}
-
-void ObjectFileXCOFF::Dump(Stream *s) {}
-
-ArchSpec ObjectFileXCOFF::GetArchitecture() {
-  ArchSpec arch_spec =
-  ArchSpec(eArchTypeXCOFF, XCOFF::TCPU_PPC64, LLDB_INVALID_CPUTYPE);
-  return arch_spec;
+void ObjectFileXCOFF::CreateSections(SectionList &unified_section_list) {
+
+  if (m_sections_up)
+return;
+  m_sections_up = std::make_unique();
+  ModuleSP module_sp(GetModule());
+  if (module_sp) {
+std::lock_guard guard(module_sp->GetMutex());
+
+ModuleSP module_sp(GetModule());
+for (auto sIdx = m_binary->section_begin(); sIdx != 
m_binary->section_end();
+ ++sIdx) {
+  llvm::Expected name =
+  m_binary->getSectionName(sIdx->getRawDataRefImpl());
+  if (!name) {
+llvm::Error err = name.takeError();
+  }
+  llvm::StringRef sect_name = *name;
+  ConstString const_sect_name(sect_name);
+  int sect_index = sIdx->getIndex(), idx = 1;
+  llvm::Expected section =
+  m_binary->getSectionByNum(sect_index);
+  if (!section) {
+llvm::Error err = section.takeError();
+  }
+  llvm::object::DataRefImpl dataref = section.get();
+  const llvm::object::XCOFFSectionHeader64 *sectionPtr =
+  reinterpret_cast(
+  dataref.p);
+
+  SectionType section_type = lldb::eSectionTypeOther;
+  if (sectionPtr->Flags & XCOFF::STYP_TEXT)
+section_type = eSectionTypeCode;
+  if (sectionPtr->Flags & XCOFF::STYP_DATA)
+section_type = eSectionTypeData;
+  if (sectionPtr->Flags & XCOFF::STYP_BSS)
+section_type = eSectionTypeZeroFill;
+  if (sectionPtr->Flags & XCOFF::STYP_DWARF) {
+SectionType section_type =
+llvm::StringSwitch(sect_name)
+.Case(".dwinfo", eSectionTypeDWARFDebugInfo)
+.Case(".dwline", eSectionTypeDWARFDebugLine)
+.Case(".dwabrev", eSectionTypeDWARFDebugAbbrev)
+.Default(eSectionTypeInvalid);
+
+if (section_type == eSectionTypeInvalid)
+  section_type = lldb::eSectionTypeOther;
+  }
+  SectionSP section_sp(new Section(
+  module_sp,   // Module to which this section belongs
+  this,// Object file to which this section belongs
+  idx++,   // Section ID is the 1 based section index.
+  const_sect_name, // Name of this section
+  section_type,
+  sectionPtr->VirtualAddress,  // File VM address == addresses as
+   // they are found in the object file
+  sectionPtr->SectionSize, // VM size in bytes of this section
+  sectionPtr->FileOffsetToRawData, // Offset to the data for this
+   // section in the file
+  sectionPtr->SectionSize, // Size in bytes of this section as found in
+   // the file
+  0,   // FIXME: alignment
+  sectionPtr->Flags)); // Flags for this section
+
+  uint32_t permissions = 0;
+  permissions |= ePermissionsReadable;
+  if (sectionPtr->Flags & (XCOFF::STYP_DATA | XCOFF::STYP_BSS))
+permissions |= ePermissionsWritable;
+  if (sectionPtr->Flags & XCOFF::STYP_TEXT)
+permissions |= ePermissionsExecutable;
+  section_sp->SetPermissions(permissions);
+
+  m_sections_up->AddSection(section_sp);
+  unified_section_list.AddSection(section_sp);
+}
+  }
 }
+  void ObjectFileXCOFF::Dump(Stream * s) {}
 
-UUID ObjectFileXCOFF::GetUUID() { return UUID(); }
+  ArchSpec ObjectFileXCOFF::GetArchitecture() {
+ArchSpec arch_spec =
+ArchSpec(eArchTypeXCOFF, XCOFF::TCPU_PPC64, LLDB_INVALID_CPUTYPE);
+return arch_spec;
+  }
 
-uint32_t ObjectFileXCOFF::GetDependentModules(FileSpecList &files) { return 0; 
}
+  UUID ObjectFileXCOFF::GetUUID() { return UUID(); }
 
-ObjectFile::Type ObjectFileXCOFF::CalculateType() {
-  if (m_binary->fileHeader64()->Flags & XCOFF::F_EXEC)
-return eTypeExecutable;
-  else if (m_binary->fileHeader

[Lldb-commits] [lldb] [lldb] Merge/unify ABI-provided AArch64 unwind plans (PR #139545)

2025-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The macos and sysv ABIs return functionally equivalent unwind plans, so they 
can be implemented in the base AArch64 class. The only difference between them 
was that the macos plan provided a "pc=lr" rule whereas the sysv plan called 
SetReturnAddressRegister (which causes the unwind machinery to act as if that 
rule was present). This difference was enough to cause 
`CompareUnwindPlansForIdenticalInitialPCLocation` to return a different value 
and break the (temporarily reverted) TestUnwindFramelessFaulted test.

While merging the two functions, I couldn't stop myself from simplifying them 
to use the generic register number schemes -- which exposed another bug in 
CompareUnwindPlansForIdenticalInitialPCLocation, namely that it was expecting 
all unwind plans to use the LLDB numbering scheme. This patch fixes that as 
well.

---
Full diff: https://github.com/llvm/llvm-project/pull/139545.diff


7 Files Affected:

- (modified) lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp (+39) 
- (modified) lldb/source/Plugins/ABI/AArch64/ABIAArch64.h (+3) 
- (modified) lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp (-45) 
- (modified) lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h (-4) 
- (modified) lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp (-44) 
- (modified) lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h (-4) 
- (modified) lldb/source/Symbol/FuncUnwinders.cpp (+18-21) 


``diff
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
index 7d8d0a4d3d671..58b8459b1806f 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -19,6 +19,7 @@
 #include 
 
 using namespace lldb;
+using namespace lldb_private;
 
 LLDB_PLUGIN_DEFINE(ABIAArch64)
 
@@ -200,3 +201,41 @@ void ABIAArch64::AugmentRegisterInfo(
 lldb::eEncodingIEEE754, lldb::eFormatFloat);
   }
 }
+
+UnwindPlanSP ABIAArch64::CreateFunctionEntryUnwindPlan() {
+  UnwindPlan::Row row;
+
+  // Our previous Call Frame Address is the stack pointer
+  row.GetCFAValue().SetIsRegisterPlusOffset(LLDB_REGNUM_GENERIC_SP, 0);
+
+  // Our previous PC is in the LR, all other registers are the same.
+  row.SetRegisterLocationToRegister(LLDB_REGNUM_GENERIC_PC, 
LLDB_REGNUM_GENERIC_RA, true);
+
+  auto plan_sp = std::make_shared(eRegisterKindGeneric);
+  plan_sp->AppendRow(std::move(row));
+  plan_sp->SetSourceName("arm64 at-func-entry default");
+  plan_sp->SetSourcedFromCompiler(eLazyBoolNo);
+  plan_sp->SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+  plan_sp->SetUnwindPlanForSignalTrap(eLazyBoolNo);
+  return plan_sp;
+}
+
+UnwindPlanSP ABIAArch64::CreateDefaultUnwindPlan() {
+  UnwindPlan::Row row;
+  const int32_t ptr_size = 8;
+
+  row.GetCFAValue().SetIsRegisterPlusOffset(LLDB_REGNUM_GENERIC_FP, 2 * 
ptr_size);
+  row.SetUnspecifiedRegistersAreUndefined(true);
+
+  row.SetRegisterLocationToAtCFAPlusOffset(LLDB_REGNUM_GENERIC_FP, ptr_size * 
-2, true);
+  row.SetRegisterLocationToAtCFAPlusOffset(LLDB_REGNUM_GENERIC_PC, ptr_size * 
-1, true);
+
+  auto plan_sp = std::make_shared(eRegisterKindGeneric);
+  plan_sp->AppendRow(std::move(row));
+  plan_sp->SetSourceName("arm64 default unwind plan");
+  plan_sp->SetSourcedFromCompiler(eLazyBoolNo);
+  plan_sp->SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+  plan_sp->SetUnwindPlanForSignalTrap(eLazyBoolNo);
+  return plan_sp;
+}
+
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h 
b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
index 52e42f1260a83..53702f4da580d 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -19,6 +19,9 @@ class ABIAArch64 : public lldb_private::MCBasedABI {
   lldb::addr_t FixCodeAddress(lldb::addr_t pc) override;
   lldb::addr_t FixDataAddress(lldb::addr_t pc) override;
 
+  lldb::UnwindPlanSP CreateFunctionEntryUnwindPlan() override;
+  lldb::UnwindPlanSP CreateDefaultUnwindPlan() override;
+
 protected:
   virtual lldb::addr_t FixAddress(lldb::addr_t pc, lldb::addr_t mask) {
 return pc;
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index f86ab8cbb1195..094e0523a4edf 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -17,7 +17,6 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Value.h"
-#include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
@@ -30,8 +29,6 @@
 #include "lldb/Utility/Status.h"
 #include "lldb/ValueObject/ValueObjectConstResult.h"
 
-#include "Utility/ARM64_DWARF_Registers.h"
-
 using namespace lldb;
 using namespace lldb_private;
 
@@ -344,48 +341,6 @@ ABIMacOSX_arm64::SetReturnValueObject(lld

  1   2   >