[Lldb-commits] [lldb] [lldb][test] Implement getting thread ID on OpenBSD (PR #71129)

2023-11-12 Thread Jason Molenda via lldb-commits

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

This looks good, please merge.

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


[Lldb-commits] [lldb] 9ba5b52 - [lldb][test] Implement getting thread ID on OpenBSD (#71129)

2023-11-12 Thread via lldb-commits

Author: Brad Smith
Date: 2023-11-12T14:38:09-05:00
New Revision: 9ba5b52c135c2fd2e6dd5f5e228d0742aa0cf3e4

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

LOG: [lldb][test] Implement getting thread ID on OpenBSD (#71129)

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/make/thread.h

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/thread.h 
b/lldb/packages/Python/lldbsuite/test/make/thread.h
index 053ba86dc9062a1..ba1f381c7e40a14 100644
--- a/lldb/packages/Python/lldbsuite/test/make/thread.h
+++ b/lldb/packages/Python/lldbsuite/test/make/thread.h
@@ -13,6 +13,8 @@ int pthread_threadid_np(pthread_t, __uint64_t *);
 #include 
 #elif defined(__NetBSD__)
 #include 
+#elif defined(__OpenBSD__)
+#include 
 #elif defined(_WIN32)
 #include 
 #endif
@@ -29,6 +31,8 @@ inline uint64_t get_thread_id() {
 #elif defined(__NetBSD__)
   // Technically lwpid_t is 32-bit signed integer
   return static_cast(_lwp_self());
+#elif defined(__OpenBSD__)
+  return static_cast(getthrid());
 #elif defined(_WIN32)
   return static_cast(::GetCurrentThreadId());
 #else



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


[Lldb-commits] [lldb] [lldb][test] Implement getting thread ID on OpenBSD (PR #71129)

2023-11-12 Thread Brad Smith via lldb-commits

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


[Lldb-commits] [clang] [compiler-rt] [llvm] [lld] [libc] [clang-tools-extra] [flang] [lldb] [libcxx] MapVector: add C++17-style try_emplace and insert_or_assign (PR #71969)

2023-11-12 Thread Fangrui Song via lldb-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/71969

>From ceb7d2236df5ffedcddc2c5b0bbed1c3d0db7c43 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 9 Nov 2023 23:51:54 -0800
Subject: [PATCH 1/4] MapVector: add C++17-style try_emplace and
 insert_or_assign

They can avoid a copy/move for many insert/operator[] uses.

For example, insert_or_assign can be used to simplify
CodeGenModule::AddDeferredUnusedCoverageMapping in
clang/lib/CodeGen/CodeGenModule.cpp
---
 llvm/include/llvm/ADT/MapVector.h|  45 ---
 llvm/unittests/ADT/MapVectorTest.cpp | 107 +++
 2 files changed, 142 insertions(+), 10 deletions(-)

diff --git a/llvm/include/llvm/ADT/MapVector.h 
b/llvm/include/llvm/ADT/MapVector.h
index c45779c0ce8e0cf..56d02d73bb0fc30 100644
--- a/llvm/include/llvm/ADT/MapVector.h
+++ b/llvm/include/llvm/ADT/MapVector.h
@@ -114,31 +114,56 @@ class MapVector {
 return Pos == Map.end()? ValueT() : Vector[Pos->second].second;
   }
 
-  std::pair insert(const std::pair &KV) {
-std::pair Pair = 
std::make_pair(KV.first, 0);
-std::pair Result = Map.insert(Pair);
+  template 
+  std::pair try_emplace(const KeyT &Key, Ts &&...Args) {
+std::pair Result =
+Map.insert(std::make_pair(Key, 0));
 auto &I = Result.first->second;
 if (Result.second) {
-  Vector.push_back(std::make_pair(KV.first, KV.second));
+  Vector.emplace_back(std::piecewise_construct, std::forward_as_tuple(Key),
+  std::forward_as_tuple(std::forward(Args)...));
   I = Vector.size() - 1;
   return std::make_pair(std::prev(end()), true);
 }
 return std::make_pair(begin() + I, false);
   }
-
-  std::pair insert(std::pair &&KV) {
-// Copy KV.first into the map, then move it into the vector.
-std::pair Pair = 
std::make_pair(KV.first, 0);
-std::pair Result = Map.insert(Pair);
+  template 
+  std::pair try_emplace(KeyT &&Key, Ts &&...Args) {
+std::pair Result =
+Map.insert(std::make_pair(Key, 0));
 auto &I = Result.first->second;
 if (Result.second) {
-  Vector.push_back(std::move(KV));
+  Vector.emplace_back(std::piecewise_construct,
+  std::forward_as_tuple(static_cast(Key)),
+  std::forward_as_tuple(std::forward(Args)...));
   I = Vector.size() - 1;
   return std::make_pair(std::prev(end()), true);
 }
 return std::make_pair(begin() + I, false);
   }
 
+  std::pair insert(const std::pair &KV) {
+return try_emplace(KV.first, KV.second);
+  }
+  std::pair insert(std::pair &&KV) {
+return try_emplace(std::move(KV.first), std::move(KV.second));
+  }
+
+  template 
+  std::pair insert_or_assign(const KeyT &Key, V &&Val) {
+auto Ret = try_emplace(Key, std::forward(Val));
+if (!Ret.second)
+  Ret.first->second = std::forward(Val);
+return Ret;
+  }
+  template 
+  std::pair insert_or_assign(KeyT &&Key, V &&Val) {
+auto Ret = try_emplace(std::move(Key), std::forward(Val));
+if (!Ret.second)
+  Ret.first->second = std::forward(Val);
+return Ret;
+  }
+
   bool contains(const KeyT &Key) const { return Map.find(Key) != Map.end(); }
 
   size_type count(const KeyT &Key) const { return contains(Key) ? 1 : 0; }
diff --git a/llvm/unittests/ADT/MapVectorTest.cpp 
b/llvm/unittests/ADT/MapVectorTest.cpp
index 1a371cbfba81e8e..40645b9a4de07b7 100644
--- a/llvm/unittests/ADT/MapVectorTest.cpp
+++ b/llvm/unittests/ADT/MapVectorTest.cpp
@@ -9,10 +9,36 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/iterator_range.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 
 using namespace llvm;
 
+namespace {
+struct CountCopyAndMove {
+  CountCopyAndMove() = default;
+  CountCopyAndMove(const CountCopyAndMove &) { copy = 1; }
+  CountCopyAndMove(CountCopyAndMove &&) { move = 1; }
+  void operator=(const CountCopyAndMove &) { ++copy; }
+  void operator=(CountCopyAndMove &&) { ++move; }
+  int copy = 0;
+  int move = 0;
+};
+
+struct A : CountCopyAndMove {
+  A(int v) : v(v) {}
+  int v;
+};
+} // namespace
+
+template <> struct DenseMapInfo {
+  static inline A getEmptyKey() { return 0x7fff; }
+  static inline A getTombstoneKey() { return -0x7fff - 1; }
+  static unsigned getHashValue(const A &Val) { return (unsigned)(Val.v * 37U); 
}
+  static bool isEqual(const A &LHS, const A &RHS) { return LHS.v == RHS.v; }
+};
+
+namespace {
 TEST(MapVectorTest, swap) {
   MapVector MV1, MV2;
   std::pair::iterator, bool> R;
@@ -79,6 +105,86 @@ TEST(MapVectorTest, insert_pop) {
   EXPECT_EQ(MV[4], 7);
 }
 
+TEST(MapVectorTest, try_emplace) {
+  struct AAndU {
+A a;
+std::unique_ptr b;
+AAndU(A a, std::unique_ptr b) : a(a), b(std::move(b)) {}
+  };
+  MapVector mv;
+
+  A zero(0);
+  auto try0 = mv.try_emplace(zero, zero, nullptr);
+  EXPECT_TRUE(try0.second);
+  EXPECT_EQ(0, try0.first->second.a.v);
+  EXPECT_EQ(1, try0.first->second.a.copy);
+  EXPECT_EQ(0, try0.first->second.a.move)

[Lldb-commits] [flang] [lldb] [compiler-rt] [libcxx] [clang-tools-extra] [lld] [libc] [clang] [llvm] MapVector: add C++17-style try_emplace and insert_or_assign (PR #71969)

2023-11-12 Thread Fangrui Song via lldb-commits

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


[Lldb-commits] [libcxx] [lld] [lldb] [clang-tools-extra] [compiler-rt] [llvm] [libc] [flang] [clang] MapVector: add C++17-style try_emplace and insert_or_assign (PR #71969)

2023-11-12 Thread Fangrui Song via lldb-commits

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


[Lldb-commits] [lldb] 638a839 - Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (#71780)

2023-11-12 Thread via lldb-commits

Author: Michael Buch
Date: 2023-11-13T06:04:27Z
New Revision: 638a8393615e911b729d5662096f60ef49f1c65e

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

LOG: Reland "[clang][DebugInfo] Emit global variable definitions for static 
data members with constant initializers" (#71780)

This patch relands https://github.com/llvm/llvm-project/pull/70639

It was reverted because under certain conditions we triggered an
assertion
in `DIBuilder`. Specifically, in the original patch we called
`EmitGlobalVariable`
at the end of `CGDebugInfo::finalize`, after all the temporary `DIType`s
have
been uniqued. With limited debug-info such temporary nodes would be
created
more frequently, leaving us with non-uniqued nodes by the time we got to
`DIBuilder::finalize`; this violated its pre-condition and caused
assertions to trigger.

To fix this, the latest iteration of the patch moves
`EmitGlobalVariable` to the
beginning of `CGDebugInfo::finalize`. Now, when we create a temporary
`DIType` node as a result of emitting a variable definition, it will get
uniqued
in time. A test-case was added for this scenario.

We also now don't emit a linkage name for non-locationed constants since
LLDB doesn't make use of it anyway.

Original commit message:
"""
When an LLDB user asks for the value of a static data member, LLDB
starts
by searching the Names accelerator table for the corresponding variable
definition DIE. For static data members with out-of-class definitions
that
works fine, because those get represented as global variables with a
location
and making them eligible to be added to the Names table. However,
in-class
definitions won’t get indexed because we usually don't emit global
variables
for them. So in DWARF we end up with a single `DW_TAG_member` that
usually holds the constant initializer. But we don't get a corresponding
CU-level `DW_TAG_variable` like we do for out-of-class definitions.

To make it more convenient for debuggers to get to the value of inline
static data
members, this patch makes sure we emit definitions for static variables
with
constant initializers the same way we do for other static variables.
This also aligns
Clang closer to GCC, which produces CU-level definitions for inline
statics and also
emits these into `.debug_pubnames`.

The implementation keeps track of newly created static data members.
Then in `CGDebugInfo::finalize`, we emit a global `DW_TAG_variable` with
a
`DW_AT_const_value` for any of those declarations that didn't end up
with a
definition in the `DeclCache`.

The newly emitted `DW_TAG_variable` will look as follows:
```
0x007b:   DW_TAG_structure_type
DW_AT_calling_convention(DW_CC_pass_by_value)
DW_AT_name  ("Foo")
...

0x008d: DW_TAG_member
  DW_AT_name("i")
  DW_AT_type(0x0062 "const int")
  DW_AT_external(true)
  DW_AT_declaration (true)
  DW_AT_const_value (4)

Newly added
v

0x009a:   DW_TAG_variable
DW_AT_specification (0x008d "i")
DW_AT_const_value   (4)
DW_AT_linkage_name  ("_ZN2t2IiE1iIfEE")
```

This patch also drops the `DW_AT_const_value` off of the declaration
since we
now always have it on the definition. This ensures that the
`DWARFParallelLinker`
can type-merge class with static members where we couldn't attach the
constant
on the declaration in some CUs.
"""

Dependent changes:
* https://github.com/llvm/llvm-project/pull/71800

Added: 
clang/test/CodeGenCXX/debug-info-static-inline-member.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGenCXX/debug-info-class.cpp
clang/test/CodeGenCXX/debug-info-static-member.cpp

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 84a166d3ac3659c..04ca02cfe858579 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1677,22 +1677,13 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl 
*Var, llvm::DIType *RecordTy,
 
   unsigned LineNumber = getLineNumber(Var->getLocation());
   StringRef VName = Var->getName();
-  llvm::Constant *C = nullptr;
-  if (Var->getInit()) {
-const APValue *Value = Var->evaluateValue();
-if (Value) {
-  if (Value->isInt())
-C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
-  if (Value->isFloat())
-C = llvm::ConstantFP::get(CGM

[Lldb-commits] [lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)

2023-11-12 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] Reland "[lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available" (PR #71800)

2023-11-12 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/71800

>From 21567b31b5f11c7ed17fc49139e58cef570c4dac Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 6 Nov 2023 11:34:09 +
Subject: [PATCH 1/2] Reland "[lldb][DWARFASTParserClang] Fetch constant value
 from variable defintion if available"

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 62 ++-
 .../SymbolFile/DWARF/DWARFASTParserClang.h| 11 
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  7 +--
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 10 +--
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |  7 +++
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |  5 ++
 .../TestConstStaticIntegralMember.py  | 53 
 .../cpp/const_static_integral_member/main.cpp | 20 ++
 8 files changed, 165 insertions(+), 10 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a70dc9832f425c6..570cd5d46952681 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -31,6 +31,7 @@
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
@@ -139,6 +140,53 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef 
FieldName) {
   return FieldName.starts_with("_vptr$")
  // gdb emit vtable pointer as "_vptr.classname"
  || FieldName.starts_with("_vptr.");
+
+std::optional
+DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+  assert(die.Tag() == llvm::dwarf::DW_TAG_member);
+
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return {};
+
+  ConstString name{die.GetName()};
+  if (!name)
+return {};
+
+  auto *CU = die.GetCU();
+  if (!CU)
+return {};
+
+  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+  // Make sure we populate the GetDieToVariable cache.
+  VariableList variables;
+  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+
+  // The cache contains the variable definition whose DW_AT_specification
+  // points to our declaration DIE. Look up that definition using our
+  // declaration.
+  auto const &die_to_var = dwarf->GetDIEToVariable();
+  auto it = die_to_var.find(die.GetDIE());
+  if (it == die_to_var.end())
+return {};
+
+  auto var_sp = it->getSecond();
+  assert(var_sp != nullptr);
+
+  if (!var_sp->GetLocationIsConstantValueData())
+return {};
+
+  auto def = dwarf->GetDIE(var_sp->GetID());
+  auto def_attrs = def.GetAttributes();
+  DWARFFormValue form_value;
+  if (!def_attrs.ExtractFormValueAtIndex(
+  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+  form_value))
+return {};
+
+  return form_value;
 }
 
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
@@ -2914,9 +2962,21 @@ void DWARFASTParserClang::ParseSingleMember(
 
   bool unused;
   // TODO: Support float/double static members as well.
-  if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
+  if (!ct.IsIntegerOrEnumerationType(unused))
 return;
 
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of an inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!attrs.const_value_form) {
+auto maybe_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_form_value)
+  return;
+
+attrs.const_value_form = *maybe_form_value;
+  }
+
   llvm::Expected const_value_or_err =
   ExtractIntFromFormValue(ct, *attrs.const_value_form);
   if (!const_value_or_err) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index c381c58fba74263..21fd6f9d7980efc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -373,6 +373,17 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
+
+  /// Tries to find the definition DW_TAG_variable DIE of the the specified
+  /// DW_TAG_member 'die'. If such definition exists, returns the
+  /// DW_AT_const_value of that definition if available. Returns std::nullopt
+  /// otherwise.
+  ///
+  /// In newer versions of clang, DW_AT_const_value att

[Lldb-commits] [lldb] Reland "[lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available" (PR #71800)

2023-11-12 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] 15c8085 - Reland "[lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available" (#71800)

2023-11-12 Thread via lldb-commits

Author: Michael Buch
Date: 2023-11-13T06:09:58Z
New Revision: 15c80852028ff4020b3f85ee13ad3a2ed4bce3be

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

LOG: Reland "[lldb][DWARFASTParserClang] Fetch constant value from variable 
defintion if available" (#71800)

This patch relands https://github.com/llvm/llvm-project/pull/71004 which
was reverted because the clang change it depends on was reverted.

In addition to the original patch, this PR includes a change to
`SymbolFileDWARF::ParseVariableDIE` to support CU-level variable
definitions that don't have locations, but represent a constant value.
Previously, when debug-maps were available, we would assume that a
variable with "static lifetime" (which in this case means "has a linkage
name") has a valid address, which isn't the case for non-locationed
constants. We could omit this additional change if we stopped attaching
linkage names to global non-locationed constants.

Original commit message:
"""
https://github.com/llvm/llvm-project/pull/71780 proposes moving the
`DW_AT_const_value` on inline static members from the declaration DIE to
the definition DIE. This patch makes sure the LLDB's expression
evaluator can continue to support static initialisers even if the
declaration doesn't have a `DW_AT_const_value` anymore.

Previously the expression evaluator would find the constant for a
VarDecl from its declaration `DW_TAG_member` DIE. In cases where the
initialiser was specified out-of-class, LLDB could find it during symbol
resolution.

However, neither of those will work for constants, since we don't have a
constant attribute on the declaration anymore and we don't have
constants in the symbol table.
"""

Depends on:
* https://github.com/llvm/llvm-project/pull/71780

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a70dc9832f425c6..570cd5d46952681 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -31,6 +31,7 @@
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
@@ -139,6 +140,53 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef 
FieldName) {
   return FieldName.starts_with("_vptr$")
  // gdb emit vtable pointer as "_vptr.classname"
  || FieldName.starts_with("_vptr.");
+
+std::optional
+DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+  assert(die.Tag() == llvm::dwarf::DW_TAG_member);
+
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return {};
+
+  ConstString name{die.GetName()};
+  if (!name)
+return {};
+
+  auto *CU = die.GetCU();
+  if (!CU)
+return {};
+
+  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+  // Make sure we populate the GetDieToVariable cache.
+  VariableList variables;
+  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+
+  // The cache contains the variable definition whose DW_AT_specification
+  // points to our declaration DIE. Look up that definition using our
+  // declaration.
+  auto const &die_to_var = dwarf->GetDIEToVariable();
+  auto it = die_to_var.find(die.GetDIE());
+  if (it == die_to_var.end())
+return {};
+
+  auto var_sp = it->getSecond();
+  assert(var_sp != nullptr);
+
+  if (!var_sp->GetLocationIsConstantValueData())
+return {};
+
+  auto def = dwarf->GetDIE(var_sp->GetID());
+  auto def_attrs = def.GetAttributes();
+  DWARFFormValue form_value;
+  if (!def_attrs.ExtractFormValueAtIndex(
+  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+  form_value))
+return {};
+
+  return form_value;
 }
 
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
@@ -2914,9 +2962,21 @@ void DWARFASTParserClang::ParseSingleMember(
 
   bool unused;
   // TODO: Support float/double static members as well.
-  if (!attrs.co

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Make MemberAttributes const when parsing member DIEs (PR #71921)

2023-11-12 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] 576f7cc - [lldb][DWARFASTParserClang] Make MemberAttributes const when parsing member DIEs (#71921)

2023-11-12 Thread via lldb-commits

Author: Michael Buch
Date: 2023-11-13T06:11:05Z
New Revision: 576f7ccfa4c1da241fb697185d03546298bfe2b6

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

LOG: [lldb][DWARFASTParserClang] Make MemberAttributes const when parsing 
member DIEs (#71921)

This patch removes the Objective-C accessibility workaround added in
https://github.com/llvm/llvm-project/commit/5a477cfd90a8a12510518973fa450ae67372f199
(rdar://8492646). This allows us to make the local `MemberAttributes`
variable immutable, which is useful for some other work around this
function I was planning on doing.

We don't need the workaround anymore since compiler-support for giving
debuggers access to private ivars was done couple of years later in
https://github.com/llvm/llvm-project/commit/d6cb4a858db0592f6f946fd99a10a9dfcbea6ee9
(rdar://10997647).

**Testing**

* Test-suite runs cleanly

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 570cd5d46952681..00b66085feabac8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2925,15 +2925,7 @@ void DWARFASTParserClang::ParseSingleMember(
   const uint64_t parent_bit_size =
   parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
 
-  // FIXME: Remove the workarounds below and make this const.
-  MemberAttributes attrs(die, parent_die, module_sp);
-
-  const bool class_is_objc_object_or_interface =
-  TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type);
-
-  // FIXME: Make Clang ignore Objective-C accessibility for expressions
-  if (class_is_objc_object_or_interface)
-attrs.accessibility = eAccessNone;
+  const MemberAttributes attrs(die, parent_die, module_sp);
 
   // Handle static members, which are typically members without
   // locations. However, GCC doesn't emit DW_AT_data_member_location
@@ -2948,13 +2940,13 @@ void DWARFASTParserClang::ParseSingleMember(
   if (attrs.member_byte_offset == UINT32_MAX &&
   attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) {
 Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
-
 if (var_type) {
-  if (attrs.accessibility == eAccessNone)
-attrs.accessibility = eAccessPublic;
+  const auto accessibility = attrs.accessibility == eAccessNone
+ ? eAccessPublic
+ : attrs.accessibility;
   CompilerType ct = var_type->GetForwardCompilerType();
   clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
-  class_clang_type, attrs.name, ct, attrs.accessibility);
+  class_clang_type, attrs.name, ct, accessibility);
   if (!v) {
 LLDB_LOG(log, "Failed to add variable to the record type");
 return;
@@ -3010,8 +3002,9 @@ void DWARFASTParserClang::ParseSingleMember(
   const uint64_t word_width = 32;
   CompilerType member_clang_type = member_type->GetLayoutCompilerType();
 
-  if (attrs.accessibility == eAccessNone)
-attrs.accessibility = default_accessibility;
+  const auto accessibility = attrs.accessibility == eAccessNone
+ ? default_accessibility
+ : attrs.accessibility;
 
   uint64_t field_bit_offset = (attrs.member_byte_offset == UINT32_MAX
? 0
@@ -3025,12 +3018,13 @@ void DWARFASTParserClang::ParseSingleMember(
 if (attrs.data_bit_offset != UINT64_MAX) {
   this_field_info.bit_offset = attrs.data_bit_offset;
 } else {
-  if (!attrs.byte_size)
-attrs.byte_size = member_type->GetByteSize(nullptr);
+  auto byte_size = attrs.byte_size;
+  if (!byte_size)
+byte_size = member_type->GetByteSize(nullptr);
 
   ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
   if (objfile->GetByteOrder() == eByteOrderLittle) {
-this_field_info.bit_offset += attrs.byte_size.value_or(0) * 8;
+this_field_info.bit_offset += byte_size.value_or(0) * 8;
 this_field_info.bit_offset -= (attrs.bit_offset + attrs.bit_size);
   } else {
 this_field_info.bit_offset += attrs.bit_offset;
@@ -3069,7 +3063,7 @@ void DWARFASTParserClang::ParseSingleMember(
 // unnamed bitfields if we have a new enough clang.
 bool detect_unnamed_bitfields = true;
 
-if (class_is_objc_object_or_interface)
+if (TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type))
   detect_unnamed_bitfields =
   die.GetCU()->Supports_unnamed_objc_bitfields();
 
@@ -3101,7 +3095,7 @@ void DWARFA

[Lldb-commits] [lldb] Reland "[lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available" (PR #71800)

2023-11-12 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff d4912e80500706a9912725d45d822675cf9153d8 
feba840daf34d0a8c0756d3cef34ec4585849c92 -- 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h 
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 570cd5d469..63f0561b4e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -141,53 +141,53 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef 
FieldName) {
  // gdb emit vtable pointer as "_vptr.classname"
  || FieldName.starts_with("_vptr.");
 
-std::optional
-DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
-  assert(die.Tag() == llvm::dwarf::DW_TAG_member);
+  std::optional
+  DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+assert(die.Tag() == llvm::dwarf::DW_TAG_member);
 
-  auto *dwarf = die.GetDWARF();
-  if (!dwarf)
-return {};
+auto *dwarf = die.GetDWARF();
+if (!dwarf)
+  return {};
 
-  ConstString name{die.GetName()};
-  if (!name)
-return {};
+ConstString name{die.GetName()};
+if (!name)
+  return {};
 
-  auto *CU = die.GetCU();
-  if (!CU)
-return {};
+auto *CU = die.GetCU();
+if (!CU)
+  return {};
 
-  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
-  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+auto parent_decl_ctx = 
dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
 
-  // Make sure we populate the GetDieToVariable cache.
-  VariableList variables;
-  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+// Make sure we populate the GetDieToVariable cache.
+VariableList variables;
+dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
 
-  // The cache contains the variable definition whose DW_AT_specification
-  // points to our declaration DIE. Look up that definition using our
-  // declaration.
-  auto const &die_to_var = dwarf->GetDIEToVariable();
-  auto it = die_to_var.find(die.GetDIE());
-  if (it == die_to_var.end())
-return {};
+// The cache contains the variable definition whose DW_AT_specification
+// points to our declaration DIE. Look up that definition using our
+// declaration.
+auto const &die_to_var = dwarf->GetDIEToVariable();
+auto it = die_to_var.find(die.GetDIE());
+if (it == die_to_var.end())
+  return {};
 
-  auto var_sp = it->getSecond();
-  assert(var_sp != nullptr);
+auto var_sp = it->getSecond();
+assert(var_sp != nullptr);
 
-  if (!var_sp->GetLocationIsConstantValueData())
-return {};
+if (!var_sp->GetLocationIsConstantValueData())
+  return {};
 
-  auto def = dwarf->GetDIE(var_sp->GetID());
-  auto def_attrs = def.GetAttributes();
-  DWARFFormValue form_value;
-  if (!def_attrs.ExtractFormValueAtIndex(
-  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
-  form_value))
-return {};
+auto def = dwarf->GetDIE(var_sp->GetID());
+auto def_attrs = def.GetAttributes();
+DWARFFormValue form_value;
+if (!def_attrs.ExtractFormValueAtIndex(
+def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+form_value))
+  return {};
 
-  return form_value;
-}
+return form_value;
+  }
 
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,

``




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


[Lldb-commits] [lldb] 9d58748 - [lldb][DWARFASTParserClang][NFC] Fix build failure

2023-11-12 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-11-13T06:14:23Z
New Revision: 9d587480dce30ff2c00dfba3dfdb2812d68ea9e9

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

LOG: [lldb][DWARFASTParserClang][NFC] Fix build failure

Caused by a badly resolved merge conflict

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 00b66085feabac8..03ee0cc96345e1e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -140,6 +140,7 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef 
FieldName) {
   return FieldName.starts_with("_vptr$")
  // gdb emit vtable pointer as "_vptr.classname"
  || FieldName.starts_with("_vptr.");
+}
 
 std::optional
 DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {



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


[Lldb-commits] [lldb] c501bf4 - Revert "[lldb][DWARFASTParserClang] Make MemberAttributes const when parsing member DIEs (#71921)"

2023-11-12 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-11-13T06:16:32Z
New Revision: c501bf4334d6cbe3fc3160ea6b9e91459e66cbe1

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

LOG: Revert "[lldb][DWARFASTParserClang] Make MemberAttributes const when 
parsing member DIEs (#71921)"

This reverts commit 576f7ccfa4c1da241fb697185d03546298bfe2b6.

Causes build bot failure because new code started depending
on the non-constness of the MemberAttributes.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 03ee0cc96345e1e..378e9c8fc379505 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2926,7 +2926,15 @@ void DWARFASTParserClang::ParseSingleMember(
   const uint64_t parent_bit_size =
   parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
 
-  const MemberAttributes attrs(die, parent_die, module_sp);
+  // FIXME: Remove the workarounds below and make this const.
+  MemberAttributes attrs(die, parent_die, module_sp);
+
+  const bool class_is_objc_object_or_interface =
+  TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type);
+
+  // FIXME: Make Clang ignore Objective-C accessibility for expressions
+  if (class_is_objc_object_or_interface)
+attrs.accessibility = eAccessNone;
 
   // Handle static members, which are typically members without
   // locations. However, GCC doesn't emit DW_AT_data_member_location
@@ -2941,13 +2949,13 @@ void DWARFASTParserClang::ParseSingleMember(
   if (attrs.member_byte_offset == UINT32_MAX &&
   attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) {
 Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
+
 if (var_type) {
-  const auto accessibility = attrs.accessibility == eAccessNone
- ? eAccessPublic
- : attrs.accessibility;
+  if (attrs.accessibility == eAccessNone)
+attrs.accessibility = eAccessPublic;
   CompilerType ct = var_type->GetForwardCompilerType();
   clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
-  class_clang_type, attrs.name, ct, accessibility);
+  class_clang_type, attrs.name, ct, attrs.accessibility);
   if (!v) {
 LLDB_LOG(log, "Failed to add variable to the record type");
 return;
@@ -3003,9 +3011,8 @@ void DWARFASTParserClang::ParseSingleMember(
   const uint64_t word_width = 32;
   CompilerType member_clang_type = member_type->GetLayoutCompilerType();
 
-  const auto accessibility = attrs.accessibility == eAccessNone
- ? default_accessibility
- : attrs.accessibility;
+  if (attrs.accessibility == eAccessNone)
+attrs.accessibility = default_accessibility;
 
   uint64_t field_bit_offset = (attrs.member_byte_offset == UINT32_MAX
? 0
@@ -3019,13 +3026,12 @@ void DWARFASTParserClang::ParseSingleMember(
 if (attrs.data_bit_offset != UINT64_MAX) {
   this_field_info.bit_offset = attrs.data_bit_offset;
 } else {
-  auto byte_size = attrs.byte_size;
-  if (!byte_size)
-byte_size = member_type->GetByteSize(nullptr);
+  if (!attrs.byte_size)
+attrs.byte_size = member_type->GetByteSize(nullptr);
 
   ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
   if (objfile->GetByteOrder() == eByteOrderLittle) {
-this_field_info.bit_offset += byte_size.value_or(0) * 8;
+this_field_info.bit_offset += attrs.byte_size.value_or(0) * 8;
 this_field_info.bit_offset -= (attrs.bit_offset + attrs.bit_size);
   } else {
 this_field_info.bit_offset += attrs.bit_offset;
@@ -3064,7 +3070,7 @@ void DWARFASTParserClang::ParseSingleMember(
 // unnamed bitfields if we have a new enough clang.
 bool detect_unnamed_bitfields = true;
 
-if (TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type))
+if (class_is_objc_object_or_interface)
   detect_unnamed_bitfields =
   die.GetCU()->Supports_unnamed_objc_bitfields();
 
@@ -3096,7 +3102,7 @@ void DWARFASTParserClang::ParseSingleMember(
 class_clang_type, llvm::StringRef(),
 m_ast.GetBuiltinTypeForEncodingAndBitSize(eEncodingSint,
   word_width),
-accessibility, unnamed_field_info->bit_size);
+attrs.accessibility, unnamed_field_info->bit_size);
 
 layout_info.field_offsets.insert(std::make_pair(
  

[Lldb-commits] [lldb] f86770a - Reland "[lldb][DWARFASTParserClang] Make MemberAttributes const when parsing member DIEs (#71921)"

2023-11-12 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-11-13T06:38:57Z
New Revision: f86770aa073ac9c17d9ccb6409254e879dca2de6

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

LOG: Reland "[lldb][DWARFASTParserClang] Make MemberAttributes const when 
parsing member DIEs (#71921)"

Changed the recently added `FindConstantOnVariableDefinition` to
not rely on MemberAttributes being non-const.

Original commit message:
"""
This patch removes the Objective-C accessibility workaround added in
https://github.com/llvm/llvm-project/commit/5a477cfd90a8a12510518973fa450ae67372f199
(rdar://8492646). This allows us to make the local `MemberAttributes`
variable immutable, which is useful for some other work around this
function I was planning on doing.

We don't need the workaround anymore since compiler-support for giving
debuggers access to private ivars was done couple of years later in
https://github.com/llvm/llvm-project/commit/d6cb4a858db0592f6f946fd99a10a9dfcbea6ee9
(rdar://10997647).

**Testing**

* Test-suite runs cleanly
"""

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 378e9c8fc379505..eb894328547ea5e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2926,15 +2926,7 @@ void DWARFASTParserClang::ParseSingleMember(
   const uint64_t parent_bit_size =
   parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
 
-  // FIXME: Remove the workarounds below and make this const.
-  MemberAttributes attrs(die, parent_die, module_sp);
-
-  const bool class_is_objc_object_or_interface =
-  TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type);
-
-  // FIXME: Make Clang ignore Objective-C accessibility for expressions
-  if (class_is_objc_object_or_interface)
-attrs.accessibility = eAccessNone;
+  const MemberAttributes attrs(die, parent_die, module_sp);
 
   // Handle static members, which are typically members without
   // locations. However, GCC doesn't emit DW_AT_data_member_location
@@ -2949,13 +2941,13 @@ void DWARFASTParserClang::ParseSingleMember(
   if (attrs.member_byte_offset == UINT32_MAX &&
   attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) {
 Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
-
 if (var_type) {
-  if (attrs.accessibility == eAccessNone)
-attrs.accessibility = eAccessPublic;
+  const auto accessibility = attrs.accessibility == eAccessNone
+ ? eAccessPublic
+ : attrs.accessibility;
   CompilerType ct = var_type->GetForwardCompilerType();
   clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
-  class_clang_type, attrs.name, ct, attrs.accessibility);
+  class_clang_type, attrs.name, ct, accessibility);
   if (!v) {
 LLDB_LOG(log, "Failed to add variable to the record type");
 return;
@@ -2966,20 +2958,20 @@ void DWARFASTParserClang::ParseSingleMember(
   if (!ct.IsIntegerOrEnumerationType(unused))
 return;
 
+  auto maybe_const_form_value = attrs.const_value_form;
+
   // Newer versions of Clang don't emit the DW_AT_const_value
   // on the declaration of an inline static data member. Instead
   // it's attached to the definition DIE. If that's the case,
   // try and fetch it.
-  if (!attrs.const_value_form) {
-auto maybe_form_value = FindConstantOnVariableDefinition(die);
-if (!maybe_form_value)
+  if (!maybe_const_form_value) {
+maybe_const_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_const_form_value)
   return;
-
-attrs.const_value_form = *maybe_form_value;
   }
 
   llvm::Expected const_value_or_err =
-  ExtractIntFromFormValue(ct, *attrs.const_value_form);
+  ExtractIntFromFormValue(ct, *maybe_const_form_value);
   if (!const_value_or_err) {
 LLDB_LOG_ERROR(log, const_value_or_err.takeError(),
"Failed to add const value to variable {1}: {0}",
@@ -3011,8 +3003,9 @@ void DWARFASTParserClang::ParseSingleMember(
   const uint64_t word_width = 32;
   CompilerType member_clang_type = member_type->GetLayoutCompilerType();
 
-  if (attrs.accessibility == eAccessNone)
-attrs.accessibility = default_accessibility;
+  const auto accessibility = attrs.accessibility == eAccessNone
+ ? default_accessibility
+ : attrs.accessibility;
 
   uint64_t field_bit_offset 

[Lldb-commits] [llvm] [lldb] [mlir] [clang-tools-extra] [clang] [CodeGen][DebugInfo] Add missing debug info for jump table BB (PR #71021)

2023-11-12 Thread via lldb-commits

https://github.com/HaohaiWen updated 
https://github.com/llvm/llvm-project/pull/71021

>From 1be56cf6541d34e4e2ead3f4b3d3ce482d69f68f Mon Sep 17 00:00:00 2001
From: Haohai Wen 
Date: Thu, 2 Nov 2023 12:14:15 +0800
Subject: [PATCH 1/4] [DebugInfo] Add debug info test for jump table

Test whether jump table BB has debug info after ISel.
---
 .../Generic/debug-info-jump-table.ll  | 176 ++
 1 file changed, 176 insertions(+)
 create mode 100644 llvm/test/DebugInfo/Generic/debug-info-jump-table.ll

diff --git a/llvm/test/DebugInfo/Generic/debug-info-jump-table.ll 
b/llvm/test/DebugInfo/Generic/debug-info-jump-table.ll
new file mode 100644
index 000..b73d05441f654bb
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/debug-info-jump-table.ll
@@ -0,0 +1,176 @@
+; RUN: llc -debug-only=isel %s -o /dev/null 2>&1 | FileCheck 
--match-full-lines %s
+
+source_filename = "jump_table.c"
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@str = private unnamed_addr constant [2 x i8] c"1\00", align 1
+@str.12 = private unnamed_addr constant [2 x i8] c"2\00", align 1
+@str.13 = private unnamed_addr constant [2 x i8] c"3\00", align 1
+@str.14 = private unnamed_addr constant [2 x i8] c"4\00", align 1
+@str.15 = private unnamed_addr constant [2 x i8] c"5\00", align 1
+@str.16 = private unnamed_addr constant [2 x i8] c"6\00", align 1
+@str.17 = private unnamed_addr constant [2 x i8] c"7\00", align 1
+@str.18 = private unnamed_addr constant [2 x i8] c"8\00", align 1
+@str.19 = private unnamed_addr constant [2 x i8] c"9\00", align 1
+@str.20 = private unnamed_addr constant [3 x i8] c"10\00", align 1
+@str.21 = private unnamed_addr constant [3 x i8] c"11\00", align 1
+@str.22 = private unnamed_addr constant [3 x i8] c"12\00", align 1
+
+
+
+; Function Attrs: nofree nounwind uwtable
+define dso_local void @foo(i32 noundef %cond) local_unnamed_addr #0 !dbg !42 {
+;CHECK: Initial selection DAG: %bb.{{[0-9]+}} 'foo:entry'
+;CHECK: SelectionDAG has 5 nodes:
+;CHECK: [[TMP1:t.*]]: ch,glue = EntryToken
+;CHECK:   [[TMP2:t.*]]: i64,ch = CopyFromReg [[TMP1]], Register:i64 %{{[0-9]+}}
+;CHECK:   t{{[0-9]+}}: ch = br_jt [[TMP2]]:1, JumpTable:i64<0>, [[TMP2]]
+
+entry:
+  call void @llvm.dbg.value(metadata i32 %cond, metadata !47, metadata 
!DIExpression()), !dbg !48
+  switch i32 %cond, label %sw.epilog [
+i32 1, label %sw.bb
+i32 2, label %sw.bb1
+i32 3, label %sw.bb3
+i32 4, label %sw.bb5
+i32 5, label %sw.bb7
+i32 6, label %sw.bb9
+i32 7, label %sw.bb11
+i32 8, label %sw.bb13
+i32 9, label %sw.bb15
+i32 10, label %sw.bb17
+i32 11, label %sw.bb19
+i32 12, label %sw.bb21
+  ], !dbg !49
+
+sw.bb:; preds = %entry
+  %puts = tail call i32 @puts(ptr nonnull dereferenceable(1) @str), !dbg !50
+  br label %sw.bb1, !dbg !50
+
+sw.bb1:   ; preds = %entry, %sw.bb
+  %puts23 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.12), !dbg 
!52
+  br label %sw.bb3, !dbg !52
+
+sw.bb3:   ; preds = %entry, %sw.bb1
+  %puts24 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.13), !dbg 
!53
+  br label %sw.bb5, !dbg !53
+
+sw.bb5:   ; preds = %entry, %sw.bb3
+  %puts25 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.14), !dbg 
!54
+  br label %sw.bb7, !dbg !54
+
+sw.bb7:   ; preds = %entry, %sw.bb5
+  %puts26 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.15), !dbg 
!55
+  br label %sw.bb9, !dbg !55
+
+sw.bb9:   ; preds = %entry, %sw.bb7
+  %puts27 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.16), !dbg 
!56
+  br label %sw.bb11, !dbg !56
+
+sw.bb11:  ; preds = %entry, %sw.bb9
+  %puts28 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.17), !dbg 
!57
+  br label %sw.bb13, !dbg !57
+
+sw.bb13:  ; preds = %entry, %sw.bb11
+  %puts29 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.18), !dbg 
!58
+  br label %sw.bb15, !dbg !58
+
+sw.bb15:  ; preds = %entry, %sw.bb13
+  %puts30 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.19), !dbg 
!59
+  br label %sw.bb17, !dbg !59
+
+sw.bb17:  ; preds = %entry, %sw.bb15
+  %puts31 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.20), !dbg 
!60
+  br label %sw.bb19, !dbg !60
+
+sw.bb19:  ; preds = %entry, %sw.bb17
+  %puts32 = tail call i32 @puts(ptr nonnull dereferenceable(1) @str.21), !dbg 
!61
+  br label %sw.bb21, !dbg !61
+
+sw.bb21:  ; preds = %entry, %sw.bb19
+  %puts33 = tail ca

[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-12 Thread via lldb-commits
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


taalhaataahir0102 wrote:

Hi David! We are working on host level physical machine. We've tried the 
configurations but the issue is still the same (Also others like `ninja 
check-llvm`, `ninja check-clang` etc. are working perfectly fine)

Initially a lot of test cases were failing:
```

Failed Tests (47):
  lldb-shell :: Breakpoint/breakpoint-command.test
  lldb-shell :: Breakpoint/dummy-target.test
  lldb-shell :: Driver/CommandOnCrashMultiThreaded.test
  lldb-shell :: Driver/TestConvenienceVariables.test
  lldb-shell :: Expr/TestExited.test
  lldb-shell :: Expr/TestIRMemoryMap.test
  lldb-shell :: Process/TestEnvironment.test
  lldb-shell :: Register/x86-64-fp-read.test
  lldb-shell :: Register/x86-64-fp-write.test
  lldb-shell :: Register/x86-64-gp-read.test
  lldb-shell :: Register/x86-64-gp-write.test
  lldb-shell :: Register/x86-64-read.test
  lldb-shell :: Register/x86-64-write.test
  lldb-shell :: Register/x86-64-ymm-read.test
  lldb-shell :: Register/x86-64-ymm-write.test
  lldb-shell :: Register/x86-fp-write.test
  lldb-shell :: Register/x86-mm-xmm-read.test
  lldb-shell :: Register/x86-mm-xmm-write.test
  lldb-shell :: Register/x86-multithread-read.test
  lldb-shell :: Register/x86-multithread-write.test
  lldb-shell :: Settings/TestFrameFormatMangling.test
  lldb-shell :: Settings/TestFrameFormatNameWithArgs.test
  lldb-shell :: Subprocess/clone-follow-child-softbp.test
  lldb-shell :: Subprocess/clone-follow-child-wp.test
  lldb-shell :: Subprocess/clone-follow-child.test
  lldb-shell :: Subprocess/clone-follow-parent-softbp.test
  lldb-shell :: Subprocess/clone-follow-parent-wp.test
  lldb-shell :: Subprocess/clone-follow-parent.test
  lldb-shell :: Subprocess/fork-follow-child-softbp.test
  lldb-shell :: Subprocess/fork-follow-child-wp.test
  lldb-shell :: Subprocess/fork-follow-child.test
  lldb-shell :: Subprocess/fork-follow-parent-softbp.test
  lldb-shell :: Subprocess/fork-follow-parent-wp.test
  lldb-shell :: Subprocess/fork-follow-parent.test
  lldb-shell :: Subprocess/vfork-follow-child-softbp.test
  lldb-shell :: Subprocess/vfork-follow-child-wp.test
  lldb-shell :: Subprocess/vfork-follow-child.test
  lldb-shell :: Subprocess/vfork-follow-parent-softbp.test
  lldb-shell :: Subprocess/vfork-follow-parent-wp.test
  lldb-shell :: Subprocess/vfork-follow-parent.test
  lldb-shell :: SymbolFile/DWARF/clang-gmodules-type-lookup.c
  lldb-shell :: SymbolFile/DWARF/debug-types-expressions.test
  lldb-shell :: SymbolFile/NativePDB/lookup-by-types.cpp
  lldb-shell :: SymbolFile/OnDemand/source-breakpoint.test
  lldb-shell :: SymbolFile/OnDemand/symbolic-breakpoint.test
  lldb-shell :: Watchpoint/ExpressionLanguage.test
  lldb-shell :: Watchpoint/SetErrorCases.test


Testing Time: 258.26s

Total Discovered Tests: 2889
  Unsupported  :  374 (12.95%)
  Passed   : 1782 (61.68%)
  Expectedly Failed:   20 (0.69%)
  Unresolved   :  666 (23.05%)
  Failed   :   47 (1.63%)

2 warning(s) in tests
FAILED: tools/lldb/test/CMakeFiles/check-lldb 
/home/talha/llvm-latest/build/tools/lldb/test/CMakeFiles/check-lldb 
cd /home/talha/llvm-latest/build/tools/lldb/test && /usr/bin/python3.10 
/home/talha/llvm-latest/build/./bin/llvm-lit -v 
/home/talha/llvm-latest/build/tools/lldb/test
ninja: build stopped: subcommand failed.
```
For the failed tests, we ran them manually. For instance for lldb-shell :: 
Breakpoint/breakpoint-command.test:

```
./bin/llvm-lit 
../llvm-project/lldb/test/Shell/Breakpoint/breakpoint-command.test -a
llvm-lit: 
/home/talha/llvm-latest/llvm-project/llvm/utils/lit/lit/llvm/config.py:488: 
note: using clang: /home/talha/llvm-latest/build/bin/clang
llvm-lit: 
/home/talha/llvm-latest/llvm-project/llvm/utils/lit/lit/llvm/config.py:488: 
note: using ld.lld: /home/talha/llvm-latest/build/bin/ld.lld
llvm-lit: 
/home/talha/llvm-latest/llvm-project/llvm/utils/lit/lit/llvm/config.py:488: 
note: using lld-link: /home/talha/llvm-latest/build/bin/lld-link
llvm-lit: 
/home/talha/llvm-latest/llvm-project/llvm/utils/lit/lit/llvm/config.py:488: 
note: using ld64.lld: /home/talha/llvm-latest/build/bin/ld64.lld
llvm-lit: 
/home/talha/llvm-latest/llvm-project/llvm/utils/lit/lit/llvm/config.py:488: 
note: using wasm-ld: /home/talha/llvm-latest/build/bin/wasm-ld
llvm-lit: /home/talha/llvm-latest/llvm-project/lldb/test/Shell/lit.cfg.py:113: 
warning: Could not set a default per-test timeout. Requires the Python psutil 
module but it could not be found. Try installing it via pip or via your 
operating system's package manager.
-- Testing: 1 tests, 1 workers --
FAIL: lldb-shell :: Breakpoint/breakpoint-command.test (1 of 1)
 TEST 'lldb-shell :: Breakpoint/breakpoint-command.test' 
FAILED 
Exit Code: 1

Command Output (stdout):
--
Cleaning breakpoint-command.test.tmp.out-dummy-target.o
Cleaning breakpoint-command.test.tmp.out



compiling dummy-target.c -> breakpoint-command.

[Lldb-commits] [llvm] [clang] [flang] [clang-tools-extra] [openmp] [mlir] [libcxx] [lldb] [libc] GlobalISel: Guide return in llvm::getIConstantSplatVal (PR #71989)

2023-11-12 Thread Jay Foad via lldb-commits

jayfoad wrote:

Typo in subject "**Guard** return ..."?

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