[Lldb-commits] [lldb] [lldb] Correctly check and report error states in StackFrame.cpp (PR #74414)

2023-12-07 Thread David Spickett via lldb-commits

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

Testing sounds like more effort than it's worth, let's not block this on that.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

@JDevlieghere thanks for reviewing.

Once Jonas' last comment is addressed let me know if you're happy with the 
changes and PR message and I can merge this for you.

I think we may be able to reduce the boilerplate by putting the 
prefix/suffix/pattern in a struct, and passing that as an optional assuming we 
can figure out the move issue with regex. But this is for a future change if at 
all.

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


[Lldb-commits] [libcxxabi] [flang] [clang-tools-extra] [libcxx] [lldb] [clang] [llvm] [compiler-rt] [lld] [AMDGPU] GFX12: select @llvm.prefetch intrinsic (PR #74576)

2023-12-07 Thread Mariusz Sikora via lldb-commits

https://github.com/mariusz-sikora-at-amd updated 
https://github.com/llvm/llvm-project/pull/74576

>From 23759746b66c33028ad2340b1e98067ebf1f8074 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Tue, 28 Jun 2022 15:24:24 -0700
Subject: [PATCH] [AMDGPU] GFX12: select @llvm.prefetch intrinsic

---
 .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp  |  21 +
 llvm/lib/Target/AMDGPU/GCNSubtarget.h |   2 +
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp |  22 +
 llvm/lib/Target/AMDGPU/SIISelLowering.h   |   2 +
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp|   2 +
 llvm/lib/Target/AMDGPU/SIInstructions.td  |  12 +
 llvm/lib/Target/AMDGPU/SMInstructions.td  |  34 ++
 llvm/test/CodeGen/AMDGPU/llvm.prefetch.ll | 496 ++
 8 files changed, 591 insertions(+)
 create mode 100644 llvm/test/CodeGen/AMDGPU/llvm.prefetch.ll

diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
index 62996a3b3fb79..f0b3ed7adc294 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -3101,6 +3101,24 @@ void AMDGPURegisterBankInfo::applyMappingImpl(
   applyDefaultMapping(OpdMapper);
   constrainOpWithReadfirstlane(B, MI, 8); // M0
   return;
+case Intrinsic::prefetch: {
+  if (!Subtarget.hasPrefetch()) {
+MI.eraseFromParent();
+return;
+  }
+  unsigned PtrBank =
+  getRegBankID(MI.getOperand(1).getReg(), MRI, AMDGPU::SGPRRegBankID);
+  if (PtrBank == AMDGPU::VGPRRegBankID) {
+MI.eraseFromParent();
+return;
+  }
+  // FIXME: There is currently no support for prefetch in global isel.
+  // There is no node equivalence and what's worse there is no MMO produced
+  // for a prefetch on global isel path.
+  // Prefetch does not affect execution so erase it for now.
+  MI.eraseFromParent();
+  return;
+}
 default: {
   if (const AMDGPU::RsrcIntrinsic *RSrcIntrin =
   AMDGPU::lookupRsrcIntrinsic(IntrID)) {
@@ -4830,6 +4848,9 @@ AMDGPURegisterBankInfo::getInstrMapping(const 
MachineInstr &MI) const {
   getVGPROpMapping(MI.getOperand(5).getReg(), MRI, *TRI); // %data1
   break;
 }
+case Intrinsic::prefetch:
+  OpdsMapping[1] = getSGPROpMapping(MI.getOperand(1).getReg(), MRI, *TRI);
+  break;
 
 default:
   return getInvalidInstructionMapping();
diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.h 
b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
index 94b9e49b765a6..21a9b8147034f 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.h
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
@@ -828,6 +828,8 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
 
   bool hasInstPrefetch() const { return getGeneration() >= GFX10; }
 
+  bool hasPrefetch() const { return GFX12Insts; }
+
   // Scratch is allocated in 256 dword per wave blocks for the entire
   // wavefront. When viewed from the perspective of an arbitrary workitem, this
   // is 4-byte aligned.
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index a7f4d63229b7e..93af38d877c5d 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -763,6 +763,9 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
   if (Subtarget->hasMad64_32())
 setOperationAction({ISD::SMUL_LOHI, ISD::UMUL_LOHI}, MVT::i32, Custom);
 
+  if (Subtarget->hasPrefetch())
+setOperationAction(ISD::PREFETCH, MVT::Other, Custom);
+
   setOperationAction(ISD::INTRINSIC_WO_CHAIN,
  {MVT::Other, MVT::f32, MVT::v4f32, MVT::i16, MVT::f16,
   MVT::v2i16, MVT::v2f16, MVT::i128},
@@ -3858,6 +3861,23 @@ SDValue SITargetLowering::lowerGET_ROUNDING(SDValue Op,
   return DAG.getMergeValues({Result, GetReg.getValue(1)}, SL);
 }
 
+SDValue SITargetLowering::lowerPREFETCH(SDValue Op, SelectionDAG &DAG) const {
+  if (Op->isDivergent())
+return SDValue();
+
+  switch (cast(Op)->getAddressSpace()) {
+  case AMDGPUAS::FLAT_ADDRESS:
+  case AMDGPUAS::GLOBAL_ADDRESS:
+  case AMDGPUAS::CONSTANT_ADDRESS:
+  case AMDGPUAS::CONSTANT_ADDRESS_32BIT:
+break;
+  default:
+return SDValue();
+  }
+
+  return Op;
+}
+
 Register SITargetLowering::getRegisterByName(const char* RegName, LLT VT,
  const MachineFunction &MF) const {
   Register Reg = StringSwitch(RegName)
@@ -5395,6 +5415,8 @@ SDValue SITargetLowering::LowerOperation(SDValue Op, 
SelectionDAG &DAG) const {
 return LowerSTACKSAVE(Op, DAG);
   case ISD::GET_ROUNDING:
 return lowerGET_ROUNDING(Op, DAG);
+  case ISD::PREFETCH:
+return lowerPREFETCH(Op, DAG);
   }
   return SDValue();
 }
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.h 
b/llvm/lib/Target/AMDGPU/SIISelLowering.h
index c9cc149218a99..5bc091d6e84de 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.h

[Lldb-commits] [libcxxabi] [flang] [clang-tools-extra] [libcxx] [lldb] [clang] [llvm] [compiler-rt] [lld] [AMDGPU] GFX12: select @llvm.prefetch intrinsic (PR #74576)

2023-12-07 Thread Matt Arsenault via lldb-commits


@@ -959,6 +967,32 @@ def : GCNPat <
 }
 } // let OtherPredicates = [HasShaderCyclesRegister]
 
+def SIMM24bitPtr : ImmLeaf (Imm);}]
+>;
+
+multiclass SMPrefetchPat {
+  def : GCNPat <
+(smrd_prefetch (SMRDImm i64:$sbase, i32:$offset), timm, timm, (i32 
cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, $offset, (i32 
SGPR_NULL), (i8 0))
+  >;
+
+  def : GCNPat <
+(smrd_prefetch (i64 SReg_64:$sbase), timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, 0, (i32 SGPR_NULL), 
(i8 0))
+  >;
+
+  def : GCNPat <
+(prefetch SIMM24bitPtr:$offset, timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type#"_PC_REL") (as_i32timm 
$offset), (i32 SGPR_NULL), (i8 0))
+  > {
+let AddedComplexity = 10;
+  }

arsenm wrote:

I would interpret this as using the absolute address, you would need something 
else to represent a PC relative input 

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


[Lldb-commits] [flang] [clang] [libcxxabi] [lld] [lldb] [mlir] [llvm] [clang-tools-extra] [openmp] [compiler-rt] [libcxx] [AMDGPU] Add GFX12 encoding for VINTERP instructions (PR #74616)

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

https://github.com/jayfoad updated 
https://github.com/llvm/llvm-project/pull/74616

>From 69580e5f77514fecf0aabe2a80c98881f9bd7288 Mon Sep 17 00:00:00 2001
From: Jay Foad 
Date: Tue, 7 Feb 2023 16:27:27 +
Subject: [PATCH 1/2] [AMDGPU] Add GFX12 encoding for VINTERP instructions

---
 .../Disassembler/AMDGPUDisassembler.cpp   |   6 +-
 llvm/lib/Target/AMDGPU/VINTERPInstructions.td |  38 ++-
 llvm/test/MC/AMDGPU/gfx11_asm_vinterp.s   | 187 ++---
 .../AMDGPU/gfx12_dasm_vinterp.txt | 251 ++
 4 files changed, 378 insertions(+), 104 deletions(-)
 create mode 100644 llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vinterp.txt

diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp 
b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
index 3175f6358a045..c37af739e2019 100644
--- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
+++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
@@ -782,9 +782,13 @@ DecodeStatus AMDGPUDisassembler::convertEXPInst(MCInst 
&MI) const {
 
 DecodeStatus AMDGPUDisassembler::convertVINTERPInst(MCInst &MI) const {
   if (MI.getOpcode() == AMDGPU::V_INTERP_P10_F16_F32_inreg_gfx11 ||
+  MI.getOpcode() == AMDGPU::V_INTERP_P10_F16_F32_inreg_gfx12 ||
   MI.getOpcode() == AMDGPU::V_INTERP_P10_RTZ_F16_F32_inreg_gfx11 ||
+  MI.getOpcode() == AMDGPU::V_INTERP_P10_RTZ_F16_F32_inreg_gfx12 ||
   MI.getOpcode() == AMDGPU::V_INTERP_P2_F16_F32_inreg_gfx11 ||
-  MI.getOpcode() == AMDGPU::V_INTERP_P2_RTZ_F16_F32_inreg_gfx11) {
+  MI.getOpcode() == AMDGPU::V_INTERP_P2_F16_F32_inreg_gfx12 ||
+  MI.getOpcode() == AMDGPU::V_INTERP_P2_RTZ_F16_F32_inreg_gfx11 ||
+  MI.getOpcode() == AMDGPU::V_INTERP_P2_RTZ_F16_F32_inreg_gfx12) {
 // The MCInst has this field that is not directly encoded in the
 // instruction.
 insertNamedMCOperand(MI, MCOperand::createImm(0), AMDGPU::OpName::op_sel);
diff --git a/llvm/lib/Target/AMDGPU/VINTERPInstructions.td 
b/llvm/lib/Target/AMDGPU/VINTERPInstructions.td
index 7d03150bf5b11..fc563b7493adf 100644
--- a/llvm/lib/Target/AMDGPU/VINTERPInstructions.td
+++ b/llvm/lib/Target/AMDGPU/VINTERPInstructions.td
@@ -10,7 +10,7 @@
 // VINTERP encoding
 
//===--===//
 
-class VINTERPe_gfx11  op, VOPProfile P> : Enc64 {
+class VINTERPe  : Enc64 {
   bits<8> vdst;
   bits<4> src0_modifiers;
   bits<9> src0;
@@ -31,7 +31,6 @@ class VINTERPe_gfx11  op, VOPProfile P> : Enc64 {
   let Inst{13}= !if(P.HasOpSel, src2_modifiers{2}, 0); // op_sel(2)
   let Inst{14}= !if(P.HasOpSel, src0_modifiers{3}, 0); // op_sel(3)
   let Inst{15}= clamp;
-  let Inst{22-16} = op;
   let Inst{40-32} = src0;
   let Inst{49-41} = src1;
   let Inst{58-50} = src2;
@@ -40,6 +39,14 @@ class VINTERPe_gfx11  op, VOPProfile P> : Enc64 {
   let Inst{63}= src2_modifiers{0}; // neg(2)
 }
 
+class VINTERPe_gfx11  op, VOPProfile P> : VINTERPe {
+  let Inst{22-16} = op;
+}
+
+class VINTERPe_gfx12  op, VOPProfile P> : VINTERPe {
+  let Inst{20-16} = op{4-0};
+}
+
 
//===--===//
 // VOP3 VINTERP
 
//===--===//
@@ -171,17 +178,28 @@ defm : VInterpF16Pat op> {
+multiclass VINTERP_Real_gfx11  op> {
+  let AssemblerPredicate = isGFX11Only, DecoderNamespace = "GFX11" in {
 def _gfx11 :
   VINTERP_Real(NAME), SIEncodingFamily.GFX11>,
   VINTERPe_gfx11(NAME).Pfl>;
   }
 }
 
-defm V_INTERP_P10_F32_inreg  : VINTERP_Real_gfx11<0x000>;
-defm V_INTERP_P2_F32_inreg  : VINTERP_Real_gfx11<0x001>;
-defm V_INTERP_P10_F16_F32_inreg  : VINTERP_Real_gfx11<0x002>;
-defm V_INTERP_P2_F16_F32_inreg  : VINTERP_Real_gfx11<0x003>;
-defm V_INTERP_P10_RTZ_F16_F32_inreg  : VINTERP_Real_gfx11<0x004>;
-defm V_INTERP_P2_RTZ_F16_F32_inreg  : VINTERP_Real_gfx11<0x005>;
+multiclass VINTERP_Real_gfx12  op> {
+  let AssemblerPredicate = isGFX12Only, DecoderNamespace = "GFX12" in {
+def _gfx12 :
+  VINTERP_Real(NAME), SIEncodingFamily.GFX12>,
+  VINTERPe_gfx12(NAME).Pfl>;
+  }
+}
+
+multiclass VINTERP_Real_gfx11_gfx12  op> :
+  VINTERP_Real_gfx11, VINTERP_Real_gfx12;
+
+defm V_INTERP_P10_F32_inreg : VINTERP_Real_gfx11_gfx12<0x000>;
+defm V_INTERP_P2_F32_inreg : VINTERP_Real_gfx11_gfx12<0x001>;
+defm V_INTERP_P10_F16_F32_inreg : VINTERP_Real_gfx11_gfx12<0x002>;
+defm V_INTERP_P2_F16_F32_inreg : VINTERP_Real_gfx11_gfx12<0x003>;
+defm V_INTERP_P10_RTZ_F16_F32_inreg : VINTERP_Real_gfx11_gfx12<0x004>;
+defm V_INTERP_P2_RTZ_F16_F32_inreg : VINTERP_Real_gfx11_gfx12<0x005>;
diff --git a/llvm/test/MC/AMDGPU/gfx11_asm_vinterp.s 
b/llvm/test/MC/AMDGPU/gfx11_asm_vinterp.s
index e2e53776783f3..fdfbf65c0e3cf 100644
--- a/llvm/test/MC/AMDGPU/gfx11_asm_vinterp.s
+++ b/llvm/test/MC/AMDGPU/gfx11_asm_vinterp.s
@@ -1,277 +1,278 @@
-// RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -show-encoding %s | FileCheck 
-check-p

[Lldb-commits] [lld] [mlir] [clang-tools-extra] [libcxxabi] [lldb] [flang] [compiler-rt] [openmp] [libcxx] [clang] [llvm] [AMDGPU] Add GFX12 encoding for VINTERP instructions (PR #74616)

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

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


[Lldb-commits] [lldb] 7de53a8 - [lldb][test] TestConstStaticIntegralMember.py: un-XFAIL tests for DWARFv5

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

Author: Michael Buch
Date: 2023-12-07T11:38:26Z
New Revision: 7de53a8cfe45f60334dc3765c0bfc94beaf09883

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

LOG: [lldb][test] TestConstStaticIntegralMember.py: un-XFAIL tests for DWARFv5

Added: 


Modified: 

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

Removed: 




diff  --git 
a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
 
b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
index 60e116b422077..cdade2d335df0 100644
--- 
a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ 
b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -104,7 +104,7 @@ def test(self):
 
 # dsymutil strips the debug info for classes that only have const static
 # data members without locations.
-@expectedFailureAll(debug_info=["dsym"])
+@expectedFailureAll(debug_info=["dsym"], dwarf_version=["<", "5"])
 def test_class_with_only_const_static(self):
 self.build()
 lldbutil.run_to_source_breakpoint(
@@ -120,6 +120,9 @@ def check_global_var(self, name: str, expect_type, 
expect_val):
 self.assertEqual(varobj.type.name, expect_type)
 self.assertEqual(varobj.value, expect_val)
 
+@expectedFailureAll(dwarf_version=["<", "5"])
+# On linux this passes due to the manual index
+@expectedFailureDarwin(debug_info=no_match(["dsym"]))
 def test_inline_static_members(self):
 self.build()
 lldbutil.run_to_source_breakpoint(
@@ -167,6 +170,9 @@ def test_class_with_only_constexpr_static(self):
 "ClassWithEnumAlias::enum_alias_alias", 
result_value="scoped_enum_case1"
 )
 
+@expectedFailureAll(dwarf_version=["<", "5"])
+# On linux this passes due to the manual index
+@expectedFailureDarwin(debug_info=no_match(["dsym"]))
 def test_shadowed_static_inline_members(self):
 """Tests that the expression evaluator and SBAPI can both
 correctly determine the requested inline static variable



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


[Lldb-commits] [libcxxabi] [flang] [lld] [llvm] [compiler-rt] [lldb] [clang] [clang-tools-extra] [libcxx] [AMDGPU] GFX12: select @llvm.prefetch intrinsic (PR #74576)

2023-12-07 Thread Mariusz Sikora via lldb-commits


@@ -959,6 +967,32 @@ def : GCNPat <
 }
 } // let OtherPredicates = [HasShaderCyclesRegister]
 
+def SIMM24bitPtr : ImmLeaf (Imm);}]
+>;
+
+multiclass SMPrefetchPat {
+  def : GCNPat <
+(smrd_prefetch (SMRDImm i64:$sbase, i32:$offset), timm, timm, (i32 
cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, $offset, (i32 
SGPR_NULL), (i8 0))
+  >;
+
+  def : GCNPat <
+(smrd_prefetch (i64 SReg_64:$sbase), timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, 0, (i32 SGPR_NULL), 
(i8 0))
+  >;
+
+  def : GCNPat <
+(prefetch SIMM24bitPtr:$offset, timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type#"_PC_REL") (as_i32timm 
$offset), (i32 SGPR_NULL), (i8 0))
+  > {
+let AddedComplexity = 10;
+  }

mariusz-sikora-at-amd wrote:

Maybe for now I will remove PC_REL part.

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


[Lldb-commits] [libcxx] [flang] [clang-tools-extra] [libcxxabi] [compiler-rt] [clang] [lldb] [lld] [llvm] [AMDGPU] GFX12: select @llvm.prefetch intrinsic (PR #74576)

2023-12-07 Thread Mariusz Sikora via lldb-commits

https://github.com/mariusz-sikora-at-amd updated 
https://github.com/llvm/llvm-project/pull/74576

>From 23759746b66c33028ad2340b1e98067ebf1f8074 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Tue, 28 Jun 2022 15:24:24 -0700
Subject: [PATCH 1/2] [AMDGPU] GFX12: select @llvm.prefetch intrinsic

---
 .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp  |  21 +
 llvm/lib/Target/AMDGPU/GCNSubtarget.h |   2 +
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp |  22 +
 llvm/lib/Target/AMDGPU/SIISelLowering.h   |   2 +
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp|   2 +
 llvm/lib/Target/AMDGPU/SIInstructions.td  |  12 +
 llvm/lib/Target/AMDGPU/SMInstructions.td  |  34 ++
 llvm/test/CodeGen/AMDGPU/llvm.prefetch.ll | 496 ++
 8 files changed, 591 insertions(+)
 create mode 100644 llvm/test/CodeGen/AMDGPU/llvm.prefetch.ll

diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
index 62996a3b3fb79..f0b3ed7adc294 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -3101,6 +3101,24 @@ void AMDGPURegisterBankInfo::applyMappingImpl(
   applyDefaultMapping(OpdMapper);
   constrainOpWithReadfirstlane(B, MI, 8); // M0
   return;
+case Intrinsic::prefetch: {
+  if (!Subtarget.hasPrefetch()) {
+MI.eraseFromParent();
+return;
+  }
+  unsigned PtrBank =
+  getRegBankID(MI.getOperand(1).getReg(), MRI, AMDGPU::SGPRRegBankID);
+  if (PtrBank == AMDGPU::VGPRRegBankID) {
+MI.eraseFromParent();
+return;
+  }
+  // FIXME: There is currently no support for prefetch in global isel.
+  // There is no node equivalence and what's worse there is no MMO produced
+  // for a prefetch on global isel path.
+  // Prefetch does not affect execution so erase it for now.
+  MI.eraseFromParent();
+  return;
+}
 default: {
   if (const AMDGPU::RsrcIntrinsic *RSrcIntrin =
   AMDGPU::lookupRsrcIntrinsic(IntrID)) {
@@ -4830,6 +4848,9 @@ AMDGPURegisterBankInfo::getInstrMapping(const 
MachineInstr &MI) const {
   getVGPROpMapping(MI.getOperand(5).getReg(), MRI, *TRI); // %data1
   break;
 }
+case Intrinsic::prefetch:
+  OpdsMapping[1] = getSGPROpMapping(MI.getOperand(1).getReg(), MRI, *TRI);
+  break;
 
 default:
   return getInvalidInstructionMapping();
diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.h 
b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
index 94b9e49b765a6..21a9b8147034f 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.h
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
@@ -828,6 +828,8 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
 
   bool hasInstPrefetch() const { return getGeneration() >= GFX10; }
 
+  bool hasPrefetch() const { return GFX12Insts; }
+
   // Scratch is allocated in 256 dword per wave blocks for the entire
   // wavefront. When viewed from the perspective of an arbitrary workitem, this
   // is 4-byte aligned.
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index a7f4d63229b7e..93af38d877c5d 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -763,6 +763,9 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
   if (Subtarget->hasMad64_32())
 setOperationAction({ISD::SMUL_LOHI, ISD::UMUL_LOHI}, MVT::i32, Custom);
 
+  if (Subtarget->hasPrefetch())
+setOperationAction(ISD::PREFETCH, MVT::Other, Custom);
+
   setOperationAction(ISD::INTRINSIC_WO_CHAIN,
  {MVT::Other, MVT::f32, MVT::v4f32, MVT::i16, MVT::f16,
   MVT::v2i16, MVT::v2f16, MVT::i128},
@@ -3858,6 +3861,23 @@ SDValue SITargetLowering::lowerGET_ROUNDING(SDValue Op,
   return DAG.getMergeValues({Result, GetReg.getValue(1)}, SL);
 }
 
+SDValue SITargetLowering::lowerPREFETCH(SDValue Op, SelectionDAG &DAG) const {
+  if (Op->isDivergent())
+return SDValue();
+
+  switch (cast(Op)->getAddressSpace()) {
+  case AMDGPUAS::FLAT_ADDRESS:
+  case AMDGPUAS::GLOBAL_ADDRESS:
+  case AMDGPUAS::CONSTANT_ADDRESS:
+  case AMDGPUAS::CONSTANT_ADDRESS_32BIT:
+break;
+  default:
+return SDValue();
+  }
+
+  return Op;
+}
+
 Register SITargetLowering::getRegisterByName(const char* RegName, LLT VT,
  const MachineFunction &MF) const {
   Register Reg = StringSwitch(RegName)
@@ -5395,6 +5415,8 @@ SDValue SITargetLowering::LowerOperation(SDValue Op, 
SelectionDAG &DAG) const {
 return LowerSTACKSAVE(Op, DAG);
   case ISD::GET_ROUNDING:
 return lowerGET_ROUNDING(Op, DAG);
+  case ISD::PREFETCH:
+return lowerPREFETCH(Op, DAG);
   }
   return SDValue();
 }
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.h 
b/llvm/lib/Target/AMDGPU/SIISelLowering.h
index c9cc149218a99..5bc091d6e84de 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowerin

[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/69422

From c416443a93f7113a7f57d337682ec4862438522d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH 1/9] [lldb] colorize symbols in image lookup

This creates the method PutCStringColorHighlighted for Stream class,
which highlights searched symbols in red color for the image lookup command.

A new shell test was added to verify functionality. Relevant methods were
updated to accept the searched pattern/symbol as a parameter.

Co-authored-by: Talha 
---
 lldb/include/lldb/Core/Address.h  |  4 +-
 lldb/include/lldb/Symbol/Symbol.h |  4 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  8 ++--
 lldb/include/lldb/Utility/Stream.h| 16 
 lldb/source/Commands/CommandObjectTarget.cpp  | 16 +---
 lldb/source/Core/Address.cpp  | 21 ++
 lldb/source/Symbol/Symbol.cpp | 18 ++---
 lldb/source/Symbol/SymbolContext.cpp  | 16 +---
 lldb/source/Utility/Stream.cpp| 28 +
 .../Commands/command-image-lookup-color.test  | 39 +++
 10 files changed, 138 insertions(+), 32 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546..c3f2832be424e 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe..0e41cd95e0ef1 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope {
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a16..9567c3f4384c1 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -150,8 +150,8 @@ class SymbolContext {
   bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
const Address &so_addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
-   bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_arguments, bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -217,8 +217,8 @@ class SymbolContext {
   /// The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/include/lldb/Utility/Stream.h 
b/lldb/include/lldb/Utility/Stream.h
index 1a5fd343e4df0..8e3fd48dfe705 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -231,6 +231,22 @@ class Stream {
   /// The string to be output to the stream.
   size_t PutCString(llvm::StringRef cstr);
 
+  /// Output a C string to the stream with color highlighting.
+  ///
+  /// Print a C string \a text to the stream, applying red color highlighting 
to
+  /// the portions of the string that match the regex pattern \a pattern. The
+  /// pattern is matched as many times as possible throughout the string. If \a
+  /// pattern is nullptr, then no highlighting is applied.
+  ///
+  /// \param[in] text
+  /// The string to be output to the stream.
+  ///
+  /// \param[in] pattern
+  /// The regex pattern to match against the \a text string. Portions of \a
+  /// text matching this pattern will be colorized. If this parameter is
+  /// nullptr, highlighting is not performed.
+  voi

[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread José Lira Junior via lldb-commits

junior-jl wrote:

In the last commit:

- Added the conditions `prefix.empty()` and `suffix.empty()` to the 'no color' 
path.
- Added missing arguments to `PutCStringColorHighlighted` call in 
`SymbolContext` (line 177).

I had to copy the same statements from line 99 here. Is it better if I declared 
`llvm::StringRef ansi_prefix` and `llvm::StringRef ansi_suffix` outside the 
conditions even if they are not used?

```cpp
  llvm::StringRef ansi_prefix;
  llvm::StringRef ansi_suffix;
  if (target_sp) {
ansi_prefix = target_sp->GetDebugger().GetRegexMatchAnsiPrefix();
ansi_suffix = target_sp->GetDebugger().GetRegexMatchAnsiSuffix();
  }
  s->PutCStringColorHighlighted(symbol->GetName().GetStringRef(), pattern,
ansi_prefix, ansi_suffix);
```

Also, since these changes were approved, we opted to finalize this PR like it 
is now. Since we are creating another PR to do the same thing for function 
search, we are planning on refactoring this with an optional struct and 
`llvm::Regex` type as suggested. This change would also make this `if 
(pattern.empty() || prefix.empty() || suffix.empty())` prettier, I guess. Is 
that good?

I would also like to understand better the relation between SymbolContext and 
the target (or another way of getting Debugger properties).

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -1618,12 +1621,19 @@ static uint32_t LookupSymbolInModule(CommandInterpreter 
&interpreter,
 if (symbol->ValueIsAddress()) {
   DumpAddress(
   interpreter.GetExecutionContext().GetBestExecutionContextScope(),
-  symbol->GetAddressRef(), verbose, all_ranges, strm);
+  symbol->GetAddressRef(), verbose, all_ranges, strm,
+  use_color && name_is_regex ? name : nullptr);
   strm.EOL();
 } else {
   strm.IndentMore();
   strm.Indent("Name: ");
-  strm.PutCString(symbol->GetDisplayName().GetStringRef());
+  llvm::StringRef ansi_prefix =
+  interpreter.GetDebugger().GetRegexMatchAnsiPrefix();
+  llvm::StringRef ansi_suffix =
+  interpreter.GetDebugger().GetRegexMatchAnsiSuffix();

DavidSpickett wrote:

If you are doing a follow up, I would put these calls inside the call to 
`PutCStringColorHighlighted`. To limit the scope of the values even more.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

> Is it better if I declared llvm::StringRef ansi_prefix and llvm::StringRef 
> ansi_suffix outside the conditions even if they are not used?

As far as I can tell, that's how you must do it, or at least, one of the 
simpler ways.

You could do:
```
  s->PutCStringColorHighlighted(symbol->GetName().GetStringRef(), pattern,
 target_sp ? target_sp->GetDebugger().GetRegexMatchAnsiPrefix() : 
"", 
 target_sp ? target_sp->GetDebugger().GetRegexMatchAnsiSuffix() : 
"");
```

If you prefer. There's not much difference to it. One puts it all in a single 
call which is good because the scope of the values is limited. The other has 1 
conditional instead of two.

Leave it as is. Sounds like you will end up refactoring it anyway.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread José Lira Junior via lldb-commits

junior-jl wrote:

> You could do:

  s->PutCStringColorHighlighted(symbol->GetName().GetStringRef(), pattern,
 target_sp ? target_sp->GetDebugger().GetRegexMatchAnsiPrefix() : 
"", 
 target_sp ? target_sp->GetDebugger().GetRegexMatchAnsiSuffix() : 
"");
 
 I really thought about doing this, but it looked too long, so I gave up, good 
to know it's ok.
 
 > Leave it as is. Sounds like you will end up refactoring it anyway.
 
 Nice! Thank you for all the help so far!

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

Wait, one last thing :)

> If the prefix and suffix are empty, we can also take this shortcut, right?

If the prefix *and* suffix are empty. Not prefix or suffix is empty.

Also please add a couple of tests where you set only suffix, and only prefix. 
To validate that.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

Or rather, set the suffix to `""`, prefix to `""` and both to `""` (since we 
default to some red/normal sequence don't we).

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread José Lira Junior via lldb-commits

junior-jl wrote:

> If the prefix and suffix are empty. Not prefix or suffix is empty.

I tried this now and I guess it's not correct. For example, if I have a prefix 
(red color) and no suffix, the text does not go back to normal and will be 
forever red. Or am I doing something wrong?

> Or rather, set the suffix to "", prefix to "" and both to "" (since we 
> default to some red/normal sequence don't we).

Yes, I'm adding new tests like this now.

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread José Lira Junior via lldb-commits

junior-jl wrote:

> I tried this now and I guess it's not correct. For example, if I have a 
> prefix (red color) and no suffix, the text does not go back to normal and 
> will be forever red. Or am I doing something wrong?

![image](https://github.com/llvm/llvm-project/assets/69206952/2ed63ec4-6f5d-4ae8-a7be-f95adba313f5)

The condition is: `if (pattern.empty() || (prefix.empty() && suffix.empty()))`

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


[Lldb-commits] [libcxx] [llvm] [flang] [compiler-rt] [clang-tools-extra] [openmp] [libcxxabi] [lldb] [clang] [mlir] [MachineCopyPropagation] When the source of PreviousCopy is undef, we cannot replace

2023-12-07 Thread via lldb-commits

https://github.com/DianQK updated 
https://github.com/llvm/llvm-project/pull/74682

>From 5a5ade3a10fef4d50bb73de5a42a07011fbdba63 Mon Sep 17 00:00:00 2001
From: DianQK 
Date: Thu, 7 Dec 2023 22:57:12 +0800
Subject: [PATCH 1/2] [MachineCopyPropagation] Pre-commit test case

---
 .../test/CodeGen/AArch64/machine-cp-undef.mir | 32 +++
 1 file changed, 32 insertions(+)
 create mode 100644 llvm/test/CodeGen/AArch64/machine-cp-undef.mir

diff --git a/llvm/test/CodeGen/AArch64/machine-cp-undef.mir 
b/llvm/test/CodeGen/AArch64/machine-cp-undef.mir
new file mode 100644
index 0..7fdc94ec510e9
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/machine-cp-undef.mir
@@ -0,0 +1,32 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 
UTC_ARGS: --version 4
+# RUN: llc -o - %s -O3 --run-pass=machine-cp -mcp-use-is-copy-instr 
-mtriple=arm64-apple-macos -mcpu=apple-m1 --verify-machineinstrs | FileCheck %s
+
+---
+name: test
+tracksRegLiveness: true
+body: |
+  ; CHECK-LABEL: name: test
+  ; CHECK: bb.0:
+  ; CHECK-NEXT:   successors: %bb.1(0x8000)
+  ; CHECK-NEXT:   liveins: $w0
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   $x8 = ORRXrs $xzr, $x0, 0, implicit $w0
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.1:
+  ; CHECK-NEXT:   liveins: $x8
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   $x0 = ADDXri $x8, 1, 0
+  ; CHECK-NEXT:   RET undef $lr, implicit $x0
+  bb.0:
+successors: %bb.1(0x8000)
+liveins: $w0
+
+$x8 = ORRXrs $xzr, undef $x0, 0, implicit $w0
+$w8 = ORRWrs $wzr, $w0, 0, implicit-def $x8
+
+  bb.1:
+liveins: $x8
+$x0 = ADDXri $x8, 1, 0
+
+RET undef $lr, implicit $x0
+...

>From fd364a3dc8a061817de3a8006b04fd385c2f1ff7 Mon Sep 17 00:00:00 2001
From: DianQK 
Date: Thu, 7 Dec 2023 08:09:49 +0800
Subject: [PATCH 2/2] [MachineCopyPropagation] When the source of PreviousCopy
 is undef, we cannot replace sub register

The `postrapseudos` may replace `mov w8, w0` with `mov x8, x0`.
---
 llvm/lib/CodeGen/MachineCopyPropagation.cpp| 3 +++
 llvm/test/CodeGen/AArch64/machine-cp-undef.mir | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp 
b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index a032b31a1fc7c..fdbdaa0a6d641 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -443,6 +443,9 @@ static bool isNopCopy(const MachineInstr &PreviousCopy, 
MCRegister Src,
 return true;
   if (!TRI->isSubRegister(PreviousSrc, Src))
 return false;
+  // When the source of PreviousCopy is undef, we cannot replace sub register.
+  if (CopyOperands->Source->isUndef())
+return false;
   unsigned SubIdx = TRI->getSubRegIndex(PreviousSrc, Src);
   return SubIdx == TRI->getSubRegIndex(PreviousDef, Def);
 }
diff --git a/llvm/test/CodeGen/AArch64/machine-cp-undef.mir 
b/llvm/test/CodeGen/AArch64/machine-cp-undef.mir
index 7fdc94ec510e9..6c09f2ce7fcc1 100644
--- a/llvm/test/CodeGen/AArch64/machine-cp-undef.mir
+++ b/llvm/test/CodeGen/AArch64/machine-cp-undef.mir
@@ -10,7 +10,8 @@ body: |
   ; CHECK-NEXT:   successors: %bb.1(0x8000)
   ; CHECK-NEXT:   liveins: $w0
   ; CHECK-NEXT: {{  $}}
-  ; CHECK-NEXT:   $x8 = ORRXrs $xzr, $x0, 0, implicit $w0
+  ; CHECK-NEXT:   $x8 = ORRXrs $xzr, undef $x0, 0, implicit $w0
+  ; CHECK-NEXT:   $w8 = ORRWrs $wzr, $w0, 0, implicit-def $x8
   ; CHECK-NEXT: {{  $}}
   ; CHECK-NEXT: bb.1:
   ; CHECK-NEXT:   liveins: $x8

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


DavidSpickett wrote:

> I tried this now and I guess it's not correct. For example, if I have a 
> prefix (red color) and no suffix, the text does not go back to normal and 
> will be forever red. Or am I doing something wrong?

This is expected. We don't expect many people to do this but if they do, that's 
their mistake. A more realistic use might be prefix=`` and suffix=`""`. If 
you wanted to "highlight" matches in a way that wasn't colour, niche, but it's 
possible with the existing highlighters so might as well go with it.

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to CompilerType class (second try). (PR #73472)

2023-12-07 Thread via lldb-commits

cmtice wrote:

I've removed the Smart pointer functions from this PR.

Are there any other changes that I need to make? If not, could someone approve 
this?

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread via lldb-commits

https://github.com/oltolm created 
https://github.com/llvm/llvm-project/pull/74731

This PR adds support for thread names in lldb on Windows.

```
(lldb) thr list
Process 2960 stopped
  thread #53: tid = 0x03a0, 0x7ff84582db34 
ntdll.dll`NtWaitForMultipleObjects + 20
  thread #29: tid = 0x04ec, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPUW.6'
  thread #89: tid = 0x057c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x119] physics[main]'
  thread #3: tid = 0x0648, 0x7ff843c2cafe 
combase.dll`InternalDoATClassCreate + 39518
  thread #93: tid = 0x0688, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x100501d] 
uMovie::StreamingThread'
  thread #1: tid = 0x087c, 0x7ff842e7a104 
win32u.dll`NtUserMsgWaitForMultipleObjectsEx + 20
  thread #96: tid = 0x0890, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1002020] HLE Video 
Decoder'
  thread #40: tid = 0x08e0, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Camera Thread'
  thread #78: tid = 0x0a04, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x10e] 
_gcm_intr_thread'
  thread #44: tid = 0x0a48, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'RSX.W1'
  thread #90: tid = 0x0b24, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x11a] 
physics[job]-000'
  thread #80: tid = 0x0c70, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x110] Resource Loader'
  thread #26: tid = 0x0c78, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPUW.3'
  thread #47: tid = 0x0ec4, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'RSX.W4'
  thread #18: tid = 0x0fe8, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'NetStart Hack'
  thread #36: tid = 0x106c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'cellAudio Thread'
  thread #69: tid = 0x1090, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPU[0x3000400] 
xf_appli_CellSpursKernel3'
  thread #5: tid = 0x1094, 0x7ff845830a74 
ntdll.dll`NtWaitForWorkViaWorkerFactory + 20
  thread #65: tid = 0x1234, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x108] 
xf_sound_SpursHdlr0'
  thread #9: tid = 0x12f8, 0x7ff842e71224 win32u.dll`NtUserPostMessage + 20
  thread #60: tid = 0x13c4, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPU[0x200] 
xf_at3p_CellSpursKernel0'
  thread #46: tid = 0x1428, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'RSX.W3'
  thread #42: tid = 0x1470, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Overlay Input Thread'
  thread #91: tid = 0x1678, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x11b] nativeFiber 
Thread'
  thread #85: tid = 0x1718, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x115] 
snddrv_stream_preparing_thre'
  thread #13: tid = 0x19ac, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Tcp Over Udp Timeout Manager 
Thread'
  thread #31: tid = 0x1a00, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'CPU Profiler'
  thread #8: tid = 0x1a14, 0x7ff84582d664 ntdll.dll`NtDelayExecution + 20
  thread #15: tid = 0x1b44, 0x7ff84582d664 ntdll.dll`NtDelayExecution + 20, 
name = 'Network Thread'
  thread #39: tid = 0x1b68, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Gem Thread'
  thread #4: tid = 0x1b6c, 0x7ff845830a74 
ntdll.dll`NtWaitForWorkViaWorkerFactory + 20
  thread #79: tid = 0x2160, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x10f] closeAsync'
  thread #14: tid = 0x2200, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'MediaList Thread'
  thread #70: tid = 0x228c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPU[0x4000400] 
xf_appli_CellSpursKernel4'
  thread #97: tid = 0x229c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1002021] 
_atxdec_adapter_decode_thr_f'
  thread #17: tid = 0x22b8, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Signaling Manager Thread'
  thread #11: tid = 0x232c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Progress Dialog Server'
  thread #50: tid = 0x2360, 0x7ff84582d8a4 ntdll.dll`NtYieldExecution + 20, 
name = 'rsx::thread'
  thread #59: tid = 0x254c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x104] 
xf_ms_SpursHdlr0'
  thread #49: tid = 0x2614, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'RSX.W6'
  thread #30: tid = 0x2618, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU Syscall Usage Thread'
  thread #20: tid = 0x2640, 0x7ff845830a14 
n

[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: oltolm (oltolm)


Changes

This PR adds support for thread names in lldb on Windows.

```
(lldb) thr list
Process 2960 stopped
  thread #53: tid = 0x03a0, 0x7ff84582db34 
ntdll.dll`NtWaitForMultipleObjects + 20
  thread #29: tid = 0x04ec, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPUW.6'
  thread #89: tid = 0x057c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x119] physics[main]'
  thread #3: tid = 0x0648, 0x7ff843c2cafe 
combase.dll`InternalDoATClassCreate + 39518
  thread #93: tid = 0x0688, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x100501d] 
uMovie::StreamingThread'
  thread #1: tid = 0x087c, 0x7ff842e7a104 
win32u.dll`NtUserMsgWaitForMultipleObjectsEx + 20
  thread #96: tid = 0x0890, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1002020] HLE Video 
Decoder'
  thread #40: tid = 0x08e0, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Camera Thread'
  thread #78: tid = 0x0a04, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x10e] 
_gcm_intr_thread'
  thread #44: tid = 0x0a48, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'RSX.W1'
  thread #90: tid = 0x0b24, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x11a] 
physics[job]-000'
  thread #80: tid = 0x0c70, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x110] Resource Loader'
  thread #26: tid = 0x0c78, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPUW.3'
  thread #47: tid = 0x0ec4, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'RSX.W4'
  thread #18: tid = 0x0fe8, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'NetStart Hack'
  thread #36: tid = 0x106c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'cellAudio Thread'
  thread #69: tid = 0x1090, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPU[0x3000400] 
xf_appli_CellSpursKernel3'
  thread #5: tid = 0x1094, 0x7ff845830a74 
ntdll.dll`NtWaitForWorkViaWorkerFactory + 20
  thread #65: tid = 0x1234, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x108] 
xf_sound_SpursHdlr0'
  thread #9: tid = 0x12f8, 0x7ff842e71224 
win32u.dll`NtUserPostMessage + 20
  thread #60: tid = 0x13c4, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPU[0x200] 
xf_at3p_CellSpursKernel0'
  thread #46: tid = 0x1428, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'RSX.W3'
  thread #42: tid = 0x1470, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Overlay Input Thread'
  thread #91: tid = 0x1678, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x11b] nativeFiber 
Thread'
  thread #85: tid = 0x1718, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x115] 
snddrv_stream_preparing_thre'
  thread #13: tid = 0x19ac, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Tcp Over Udp Timeout Manager 
Thread'
  thread #31: tid = 0x1a00, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'CPU Profiler'
  thread #8: tid = 0x1a14, 0x7ff84582d664 
ntdll.dll`NtDelayExecution + 20
  thread #15: tid = 0x1b44, 0x7ff84582d664 
ntdll.dll`NtDelayExecution + 20, name = 'Network Thread'
  thread #39: tid = 0x1b68, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Gem Thread'
  thread #4: tid = 0x1b6c, 0x7ff845830a74 
ntdll.dll`NtWaitForWorkViaWorkerFactory + 20
  thread #79: tid = 0x2160, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x10f] closeAsync'
  thread #14: tid = 0x2200, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'MediaList Thread'
  thread #70: tid = 0x228c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPU[0x4000400] 
xf_appli_CellSpursKernel4'
  thread #97: tid = 0x229c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1002021] 
_atxdec_adapter_decode_thr_f'
  thread #17: tid = 0x22b8, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Signaling Manager Thread'
  thread #11: tid = 0x232c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'Progress Dialog Server'
  thread #50: tid = 0x2360, 0x7ff84582d8a4 
ntdll.dll`NtYieldExecution + 20, name = 'rsx::thread'
  thread #59: tid = 0x254c, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x104] 
xf_ms_SpursHdlr0'
  thread #49: tid = 0x2614, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'RSX.W6'
  thread #30: tid = 0x2618, 0x7ff845830a14 
ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU Syscall Usage Thread'
  thread #20: tid = 0x2640, 0x7ff845830a14 
nt

[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 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 dfd36aa70ec1cff0529272b00f6c6a81bf0cc49c 
b9accfb579b6d2718ad12ee55dacf38257693d56 -- 
lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp 
lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
index d9e0fbcdf7..047019ac30 100644
--- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -10,12 +10,12 @@
 #include "lldb/Host/HostNativeThreadBase.h"
 #include "lldb/Host/windows/HostThreadWindows.h"
 #include "lldb/Host/windows/windows.h"
-#include "llvm/Support/ConvertUTF.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Unwind.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/State.h"
+#include "llvm/Support/ConvertUTF.h"
 
 #include "ProcessWindows.h"
 #include "ProcessWindowsLog.h"

``




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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread via lldb-commits

https://github.com/oltolm updated 
https://github.com/llvm/llvm-project/pull/74731

>From 9383b8b92849c71a96b4b4e7e55f615d8f2efedb Mon Sep 17 00:00:00 2001
From: oltolm 
Date: Fri, 1 Dec 2023 16:49:13 +0100
Subject: [PATCH] lldb: add support for thread names on Windows

---
 .../Windows/Common/TargetThreadWindows.cpp| 31 +++
 .../Windows/Common/TargetThreadWindows.h  |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
index 37dc8f6d6d14a..047019ac30f49 100644
--- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/State.h"
+#include "llvm/Support/ConvertUTF.h"
 
 #include "ProcessWindows.h"
 #include "ProcessWindowsLog.h"
@@ -33,6 +34,9 @@
 using namespace lldb;
 using namespace lldb_private;
 
+using GetThreadDescriptionFunctionPtr = HRESULT
+WINAPI (*)(HANDLE hThread, PWSTR *ppszThreadDescription);
+
 TargetThreadWindows::TargetThreadWindows(ProcessWindows &process,
  const HostThread &thread)
 : Thread(process, thread.GetNativeThread().GetThreadId()),
@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
 
   return Status();
 }
+
+const char *TargetThreadWindows::GetName() {
+  Log *log = GetLog(LLDBLog::Thread);
+  HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+  if (hModule) {
+auto GetThreadDescription =
+reinterpret_cast(
+::GetProcAddress(hModule, "GetThreadDescription"));
+LLDB_LOGF(log, "GetProcAddress: %p",
+  reinterpret_cast(GetThreadDescription));
+if (GetThreadDescription) {
+  PWSTR pszThreadName;
+  if (SUCCEEDED(GetThreadDescription(
+  m_host_thread.GetNativeThread().GetSystemHandle(),
+  &pszThreadName))) {
+LLDB_LOGF(log, "GetThreadDescription: %ls", pszThreadName);
+llvm::convertUTF16ToUTF8String(
+llvm::ArrayRef(reinterpret_cast(pszThreadName),
+   wcslen(pszThreadName) * sizeof(wchar_t)),
+m_name);
+::LocalFree(pszThreadName);
+  }
+}
+  }
+
+  return m_name.c_str();
+}
diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h 
b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h
index 2845847738f60..07e1db464ad59 100644
--- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h
+++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.h
@@ -34,6 +34,7 @@ class TargetThreadWindows : public lldb_private::Thread {
   lldb::RegisterContextSP
   CreateRegisterContextForFrame(StackFrame *frame) override;
   bool CalculateStopInfo() override;
+  const char *GetName() override;
 
   Status DoResume();
 
@@ -42,6 +43,7 @@ class TargetThreadWindows : public lldb_private::Thread {
 private:
   lldb::RegisterContextSP m_thread_reg_ctx_sp;
   HostThread m_host_thread;
+  std::string m_name;
 };
 } // namespace lldb_private
 

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


[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/69422

From c416443a93f7113a7f57d337682ec4862438522d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 7 Nov 2023 16:57:18 -0300
Subject: [PATCH 01/10] [lldb] colorize symbols in image lookup

This creates the method PutCStringColorHighlighted for Stream class,
which highlights searched symbols in red color for the image lookup command.

A new shell test was added to verify functionality. Relevant methods were
updated to accept the searched pattern/symbol as a parameter.

Co-authored-by: Talha 
---
 lldb/include/lldb/Core/Address.h  |  4 +-
 lldb/include/lldb/Symbol/Symbol.h |  4 +-
 lldb/include/lldb/Symbol/SymbolContext.h  |  8 ++--
 lldb/include/lldb/Utility/Stream.h| 16 
 lldb/source/Commands/CommandObjectTarget.cpp  | 16 +---
 lldb/source/Core/Address.cpp  | 21 ++
 lldb/source/Symbol/Symbol.cpp | 18 ++---
 lldb/source/Symbol/SymbolContext.cpp  | 16 +---
 lldb/source/Utility/Stream.cpp| 28 +
 .../Commands/command-image-lookup-color.test  | 39 +++
 10 files changed, 138 insertions(+), 32 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index b19e694427546..c3f2832be424e 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -246,8 +246,8 @@ class Address {
   /// \see Address::DumpStyle
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+const char *pattern = nullptr) const;
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index 44a2d560010fe..0e41cd95e0ef1 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope {
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index b0f5ffead2a16..9567c3f4384c1 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -150,8 +150,8 @@ class SymbolContext {
   bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
const Address &so_addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
-   bool show_function_arguments,
-   bool show_function_name) const;
+   bool show_function_arguments, bool show_function_name,
+   const char *pattern = nullptr) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -217,8 +217,8 @@ class SymbolContext {
   /// The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level,
-  Target *target) const;
+  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
+  const char *pattern = nullptr) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/include/lldb/Utility/Stream.h 
b/lldb/include/lldb/Utility/Stream.h
index 1a5fd343e4df0..8e3fd48dfe705 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -231,6 +231,22 @@ class Stream {
   /// The string to be output to the stream.
   size_t PutCString(llvm::StringRef cstr);
 
+  /// Output a C string to the stream with color highlighting.
+  ///
+  /// Print a C string \a text to the stream, applying red color highlighting 
to
+  /// the portions of the string that match the regex pattern \a pattern. The
+  /// pattern is matched as many times as possible throughout the string. If \a
+  /// pattern is nullptr, then no highlighting is applied.
+  ///
+  /// \param[in] text
+  /// The string to be output to the stream.
+  ///
+  /// \param[in] pattern
+  /// The regex pattern to match against the \a text string. Portions of \a
+  /// text matching this pattern will be colorized. If this parameter is
+  /// nullptr, highlighting is not performed.
+  v

[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread José Lira Junior via lldb-commits

junior-jl wrote:

> > I tried this now and I guess it's not correct. For example, if I have a 
> > prefix (red color) and no suffix, the text does not go back to normal and 
> > will be forever red. Or am I doing something wrong?
> 
> This is expected. We don't expect many people to do this but if they do, 
> that's their mistake. A more realistic use might be prefix=`` and 
> suffix=`""`. If you wanted to "highlight" matches in a way that wasn't 
> colour, niche, but it's possible with the existing highlighters so might as 
> well go with it.

I see now. Thank you for the explanation.

The last commit adds the test cases and change the `if` condition.

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


[Lldb-commits] [lld] [libc] [mlir] [openmp] [llvm] [libcxxabi] [flang] [lldb] [libcxx] [clang-tools-extra] [clang] [compiler-rt] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread Jakub Mazurkiewicz via lldb-commits

https://github.com/JMazurkiewicz updated 
https://github.com/llvm/llvm-project/pull/74655

>From b3de573887cdd86fd6ce168bdcc6d729d73b13b2 Mon Sep 17 00:00:00 2001
From: Jakub Mazurkiewicz 
Date: Wed, 6 Dec 2023 14:03:51 +0100
Subject: [PATCH 1/9] [libc++] Fix `take_view::__sentinel`'s `operator==`

---
 libcxx/include/__ranges/take_view.h   |   2 +-
 .../base.pass.cpp |   5 +-
 .../ctor.pass.cpp |   0
 .../range.take.sentinel/eq.pass.cpp   | 192 ++
 .../range.take/sentinel/eq.pass.cpp   |  55 -
 5 files changed, 194 insertions(+), 60 deletions(-)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/base.pass.cpp (83%)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/ctor.pass.cpp (100%)
 create mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 delete mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/eq.pass.cpp

diff --git a/libcxx/include/__ranges/take_view.h 
b/libcxx/include/__ranges/take_view.h
index 4204017d9249b..811428e529f59 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -183,7 +183,7 @@ class take_view<_View>::__sentinel {
   template
 requires sentinel_for, 
iterator_t<__maybe_const<_OtherConst, _View>>>
   _LIBCPP_HIDE_FROM_ABI
-  friend constexpr bool operator==(const _Iter<_Const>& __lhs, const 
__sentinel& __rhs) {
+  friend constexpr bool operator==(const _Iter<_OtherConst>& __lhs, const 
__sentinel& __rhs) {
 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
   }
 };
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
similarity index 83%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
index c949eb7cc0846..15b2b5476e86d 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
@@ -8,10 +8,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-// sentinel() = default;
-// constexpr explicit sentinel(sentinel_t end);
-// constexpr sentinel(sentinel s)
-//   requires Const && convertible_to, sentinel_t>;
+// constexpr sentinel_t base() const;
 
 #include 
 #include 
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
similarity index 100%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
new file mode 100644
index 0..f20c29b4c6471
--- /dev/null
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
@@ -0,0 +1,192 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// friend constexpr bool operator==(const CI& y, const sentinel& x);
+// template
+//   requires sentinel_for, 
iterator_t>>
+// friend constexpr bool operator==(const CI& y, const sentinel& 
x);
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+class StrictIterator {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  using value_type  = int;
+  using difference_type = std::ptrdiff_t;
+
+  constexpr explicit StrictIterator(Base base) : base_(base) {}
+
+  StrictIterator(StrictIterator&&)= default;
+  StrictIterator& operator=(StrictIterator&&) = default;
+
+  constexpr StrictIterator& operator++() {
+++base_;
+return *this;
+  }
+
+  constexpr void operator++(int) { ++*this; }
+  constexpr decltype(auto) operator*() const { return *base_; }
+  constexpr Base base() const { return base_; }
+};
+
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+
+template 
+class StrictSentinel {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  StrictSentinel() = default;
+ 

[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup with a regex pattern (PR #69422)

2023-12-07 Thread Jonas Devlieghere via lldb-commits
=?utf-8?q?José?= L. Junior ,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 
<23100...@lums.edu.pk>,taalhaataahir0102
 <23100...@lums.edu.pk>,taalhaataahir0102 <23100...@lums.edu.pk>,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 



@@ -1618,12 +1621,19 @@ static uint32_t LookupSymbolInModule(CommandInterpreter 
&interpreter,
 if (symbol->ValueIsAddress()) {
   DumpAddress(
   interpreter.GetExecutionContext().GetBestExecutionContextScope(),
-  symbol->GetAddressRef(), verbose, all_ranges, strm);
+  symbol->GetAddressRef(), verbose, all_ranges, strm,
+  use_color && name_is_regex ? name : nullptr);
   strm.EOL();
 } else {
   strm.IndentMore();
   strm.Indent("Name: ");
-  strm.PutCString(symbol->GetDisplayName().GetStringRef());
+  llvm::StringRef ansi_prefix =
+  interpreter.GetDebugger().GetRegexMatchAnsiPrefix();
+  llvm::StringRef ansi_suffix =
+  interpreter.GetDebugger().GetRegexMatchAnsiSuffix();

JDevlieghere wrote:

I was about to suggest that too, but the `Stream` class lives in utility so you 
can't pass in the debugger or the target without breaking the layering. 

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


[Lldb-commits] [libc] [clang-tools-extra] [flang] [libcxx] [llvm] [clang] [lldb] [compiler-rt] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2023-12-07 Thread Yi Wu via lldb-commits

https://github.com/yi-wu-arm updated 
https://github.com/llvm/llvm-project/pull/71222

>From e0d99fb5baa4231ab351f7fd5abf0a1ffe589547 Mon Sep 17 00:00:00 2001
From: Yi Wu 
Date: Mon, 6 Nov 2023 19:55:06 +
Subject: [PATCH 01/10] FDATE extension implementation: get date and time in
 ctime format

reference to gfortran fdate https://gcc.gnu.org/onlinedocs/gfortran/FDATE.html
usage:
CHARACTER(32) :: time
CALL fdate(time)
WRITE(*,*) time
---
 flang/docs/Intrinsics.md |  2 +-
 flang/include/flang/Runtime/command.h|  5 +
 flang/include/flang/Runtime/extensions.h |  2 ++
 flang/runtime/command.cpp| 28 
 flang/runtime/extensions.cpp |  5 +
 flang/unittests/Runtime/CommandTest.cpp  | 14 
 6 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md
index ab0a940e53e55..982be82081642 100644
--- a/flang/docs/Intrinsics.md
+++ b/flang/docs/Intrinsics.md
@@ -751,7 +751,7 @@ This phase currently supports all the intrinsic procedures 
listed above but the
 | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, 
EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
 | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, 
MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
 | Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, 
SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, 
KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, 
RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, 
IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, 
INT_PTR_KIND, ISNAN, MALLOC |
-| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
+| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, FDATE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
 | Atomic intrinsic subroutines | ATOMIC_ADD |
 | Collective intrinsic subroutines | CO_REDUCE |
 
diff --git a/flang/include/flang/Runtime/command.h 
b/flang/include/flang/Runtime/command.h
index ec62893905454..07f6d8e169ead 100644
--- a/flang/include/flang/Runtime/command.h
+++ b/flang/include/flang/Runtime/command.h
@@ -23,6 +23,11 @@ extern "C" {
 // integer kind.
 std::int32_t RTNAME(ArgumentCount)();
 
+// Try to get the the current date (same format as CTIME: convert to a string)
+// Return a STATUS as described in the standard.
+std::int32_t RTNAME(FDate)(
+const Descriptor *argument = nullptr, const Descriptor *errmsg = nullptr);
+
 // 16.9.82 GET_COMMAND
 // Try to get the value of the whole command. All of the parameters are
 // optional.
diff --git a/flang/include/flang/Runtime/extensions.h 
b/flang/include/flang/Runtime/extensions.h
index ad592814e5acb..92b9907860121 100644
--- a/flang/include/flang/Runtime/extensions.h
+++ b/flang/include/flang/Runtime/extensions.h
@@ -24,6 +24,8 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 // GNU Fortran 77 compatibility function IARGC.
 std::int32_t FORTRAN_PROCEDURE_NAME(iargc)();
 
+void FORTRAN_PROCEDURE_NAME(fdate)(std::int8_t *string, std::int64_t length);
+
 // GNU Fortran 77 compatibility subroutine GETARG(N, ARG).
 void FORTRAN_PROCEDURE_NAME(getarg)(
 std::int32_t &n, std::int8_t *arg, std::int64_t length);
diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp
index b81a0791c5e57..da0803c39f49b 100644
--- a/flang/runtime/command.cpp
+++ b/flang/runtime/command.cpp
@@ -14,6 +14,7 @@
 #include "flang/Runtime/descriptor.h"
 #include 
 #include 
+#include 
 
 namespace Fortran::runtime {
 std::int32_t RTNAME(ArgumentCount)() {
@@ -125,6 +126,33 @@ static bool FitsInDescriptor(
   kind, terminator, value);
 }
 
+void removeNewLine(char *str) {
+  char *newlinePos = strchr(str, '\n');
+  if (newlinePos != NULL) {
+*newlinePos = '\0'; // Replace with null terminator
+  }
+}
+
+std::int32_t RTNAME(FDate)(const Descriptor *value, const Descriptor *errmsg) {
+  FillWithSpaces(*value);
+
+  time_t current_time;
+  time(¤t_time);
+
+  char *time_string = ctime(¤t_time);
+  removeNewLine(time_string);
+  std::int64_t stringLen{StringLength(time_string)};
+  if (stringLen <= 0) {
+return ToErrmsg(errmsg, StatMissingArgument);
+  }
+
+  if (value) {
+return CopyToDescriptor(*value, time_string, stringLen, errmsg);
+  }
+
+  return StatOk;
+}
+
 std::int32_t RTNAME(GetCommandArgument)(std::int32_t n, const Descriptor 
*value,
 const Descriptor *length, const Descriptor *errmsg, const char *sourceFile,
 int line) {
diff --git a/flang/runtime/extension

[Lldb-commits] [compiler-rt] [lldb] [libcxx] [clang-tools-extra] [clang] [flang] [llvm] [libc] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2023-12-07 Thread Yi Wu via lldb-commits

https://github.com/yi-wu-arm updated 
https://github.com/llvm/llvm-project/pull/71222

>From e0d99fb5baa4231ab351f7fd5abf0a1ffe589547 Mon Sep 17 00:00:00 2001
From: Yi Wu 
Date: Mon, 6 Nov 2023 19:55:06 +
Subject: [PATCH 01/11] FDATE extension implementation: get date and time in
 ctime format

reference to gfortran fdate https://gcc.gnu.org/onlinedocs/gfortran/FDATE.html
usage:
CHARACTER(32) :: time
CALL fdate(time)
WRITE(*,*) time
---
 flang/docs/Intrinsics.md |  2 +-
 flang/include/flang/Runtime/command.h|  5 +
 flang/include/flang/Runtime/extensions.h |  2 ++
 flang/runtime/command.cpp| 28 
 flang/runtime/extensions.cpp |  5 +
 flang/unittests/Runtime/CommandTest.cpp  | 14 
 6 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md
index ab0a940e53e55..982be82081642 100644
--- a/flang/docs/Intrinsics.md
+++ b/flang/docs/Intrinsics.md
@@ -751,7 +751,7 @@ This phase currently supports all the intrinsic procedures 
listed above but the
 | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, 
EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
 | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, 
MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
 | Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, 
SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, 
KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, 
RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, 
IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, 
INT_PTR_KIND, ISNAN, MALLOC |
-| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
+| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, FDATE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
 | Atomic intrinsic subroutines | ATOMIC_ADD |
 | Collective intrinsic subroutines | CO_REDUCE |
 
diff --git a/flang/include/flang/Runtime/command.h 
b/flang/include/flang/Runtime/command.h
index ec62893905454..07f6d8e169ead 100644
--- a/flang/include/flang/Runtime/command.h
+++ b/flang/include/flang/Runtime/command.h
@@ -23,6 +23,11 @@ extern "C" {
 // integer kind.
 std::int32_t RTNAME(ArgumentCount)();
 
+// Try to get the the current date (same format as CTIME: convert to a string)
+// Return a STATUS as described in the standard.
+std::int32_t RTNAME(FDate)(
+const Descriptor *argument = nullptr, const Descriptor *errmsg = nullptr);
+
 // 16.9.82 GET_COMMAND
 // Try to get the value of the whole command. All of the parameters are
 // optional.
diff --git a/flang/include/flang/Runtime/extensions.h 
b/flang/include/flang/Runtime/extensions.h
index ad592814e5acb..92b9907860121 100644
--- a/flang/include/flang/Runtime/extensions.h
+++ b/flang/include/flang/Runtime/extensions.h
@@ -24,6 +24,8 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 // GNU Fortran 77 compatibility function IARGC.
 std::int32_t FORTRAN_PROCEDURE_NAME(iargc)();
 
+void FORTRAN_PROCEDURE_NAME(fdate)(std::int8_t *string, std::int64_t length);
+
 // GNU Fortran 77 compatibility subroutine GETARG(N, ARG).
 void FORTRAN_PROCEDURE_NAME(getarg)(
 std::int32_t &n, std::int8_t *arg, std::int64_t length);
diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp
index b81a0791c5e57..da0803c39f49b 100644
--- a/flang/runtime/command.cpp
+++ b/flang/runtime/command.cpp
@@ -14,6 +14,7 @@
 #include "flang/Runtime/descriptor.h"
 #include 
 #include 
+#include 
 
 namespace Fortran::runtime {
 std::int32_t RTNAME(ArgumentCount)() {
@@ -125,6 +126,33 @@ static bool FitsInDescriptor(
   kind, terminator, value);
 }
 
+void removeNewLine(char *str) {
+  char *newlinePos = strchr(str, '\n');
+  if (newlinePos != NULL) {
+*newlinePos = '\0'; // Replace with null terminator
+  }
+}
+
+std::int32_t RTNAME(FDate)(const Descriptor *value, const Descriptor *errmsg) {
+  FillWithSpaces(*value);
+
+  time_t current_time;
+  time(¤t_time);
+
+  char *time_string = ctime(¤t_time);
+  removeNewLine(time_string);
+  std::int64_t stringLen{StringLength(time_string)};
+  if (stringLen <= 0) {
+return ToErrmsg(errmsg, StatMissingArgument);
+  }
+
+  if (value) {
+return CopyToDescriptor(*value, time_string, stringLen, errmsg);
+  }
+
+  return StatOk;
+}
+
 std::int32_t RTNAME(GetCommandArgument)(std::int32_t n, const Descriptor 
*value,
 const Descriptor *length, const Descriptor *errmsg, const char *sourceFile,
 int line) {
diff --git a/flang/runtime/extension

[Lldb-commits] [libc] [openmp] [lldb] [llvm] [flang] [compiler-rt] [lld] [mlir] [libcxx] [clang] [clang-tools-extra] [libcxxabi] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread Jakub Mazurkiewicz via lldb-commits

https://github.com/JMazurkiewicz updated 
https://github.com/llvm/llvm-project/pull/74655

>From b3de573887cdd86fd6ce168bdcc6d729d73b13b2 Mon Sep 17 00:00:00 2001
From: Jakub Mazurkiewicz 
Date: Wed, 6 Dec 2023 14:03:51 +0100
Subject: [PATCH 01/10] [libc++] Fix `take_view::__sentinel`'s `operator==`

---
 libcxx/include/__ranges/take_view.h   |   2 +-
 .../base.pass.cpp |   5 +-
 .../ctor.pass.cpp |   0
 .../range.take.sentinel/eq.pass.cpp   | 192 ++
 .../range.take/sentinel/eq.pass.cpp   |  55 -
 5 files changed, 194 insertions(+), 60 deletions(-)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/base.pass.cpp (83%)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/ctor.pass.cpp (100%)
 create mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 delete mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/eq.pass.cpp

diff --git a/libcxx/include/__ranges/take_view.h 
b/libcxx/include/__ranges/take_view.h
index 4204017d9249b..811428e529f59 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -183,7 +183,7 @@ class take_view<_View>::__sentinel {
   template
 requires sentinel_for, 
iterator_t<__maybe_const<_OtherConst, _View>>>
   _LIBCPP_HIDE_FROM_ABI
-  friend constexpr bool operator==(const _Iter<_Const>& __lhs, const 
__sentinel& __rhs) {
+  friend constexpr bool operator==(const _Iter<_OtherConst>& __lhs, const 
__sentinel& __rhs) {
 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
   }
 };
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
similarity index 83%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
index c949eb7cc0846..15b2b5476e86d 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
@@ -8,10 +8,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-// sentinel() = default;
-// constexpr explicit sentinel(sentinel_t end);
-// constexpr sentinel(sentinel s)
-//   requires Const && convertible_to, sentinel_t>;
+// constexpr sentinel_t base() const;
 
 #include 
 #include 
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
similarity index 100%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
new file mode 100644
index 0..f20c29b4c6471
--- /dev/null
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
@@ -0,0 +1,192 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// friend constexpr bool operator==(const CI& y, const sentinel& x);
+// template
+//   requires sentinel_for, 
iterator_t>>
+// friend constexpr bool operator==(const CI& y, const sentinel& 
x);
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+class StrictIterator {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  using value_type  = int;
+  using difference_type = std::ptrdiff_t;
+
+  constexpr explicit StrictIterator(Base base) : base_(base) {}
+
+  StrictIterator(StrictIterator&&)= default;
+  StrictIterator& operator=(StrictIterator&&) = default;
+
+  constexpr StrictIterator& operator++() {
+++base_;
+return *this;
+  }
+
+  constexpr void operator++(int) { ++*this; }
+  constexpr decltype(auto) operator*() const { return *base_; }
+  constexpr Base base() const { return base_; }
+};
+
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+
+template 
+class StrictSentinel {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  StrictSentinel() = default;

[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

2023-12-07 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

2023-12-07 Thread Alex Langford via lldb-commits

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

LGTM, small typo

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


[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

2023-12-07 Thread Alex Langford via lldb-commits


@@ -558,7 +558,10 @@ class Process : public 
std::enable_shared_from_this,
   ///
   /// Subclasses that override this method should always call this superclass
   /// method.
-  virtual void Finalize();
+  /// If you are running Finalize in your Process subclass Destructor, pass
+  /// \btrue.  If we are in the destructor, shared_from_this will no longer

bulbazord wrote:

`\btrue` -> `\b true`


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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread Greg Clayton via lldb-commits


@@ -33,6 +34,9 @@
 using namespace lldb;
 using namespace lldb_private;
 
+using GetThreadDescriptionFunctionPtr = HRESULT
+WINAPI (*)(HANDLE hThread, PWSTR *ppszThreadDescription);
+

clayborg wrote:

Can we just `#include ` and avoid manually declaring a 
function prototype?

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread Greg Clayton via lldb-commits


@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
 
   return Status();
 }
+
+const char *TargetThreadWindows::GetName() {
+  Log *log = GetLog(LLDBLog::Thread);
+  HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+  if (hModule) {
+auto GetThreadDescription =
+reinterpret_cast(
+::GetProcAddress(hModule, "GetThreadDescription"));

clayborg wrote:

This code is only compiled on windows, why do we need to get the library handle 
manually and get the function pointer. Can't we just `#include 
` and then call the function directly?

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

The implementation looks fine to me. Can you write a test?

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


[Lldb-commits] [llvm] [lldb] [lldb] Rename lldb-vscode to lldb-dap (PR #69264)

2023-12-07 Thread Greg Clayton via lldb-commits

clayborg wrote:

@JDevlieghere Can you delete the `llvm-project/lldb/tools/lldb-vscode` 
directory from git after this commit to clean up our codebase? There are still 
two copies of the `lldb-dap` code in the sources:
```
lldb/tools/lldb-dap
lldb/tools/lldb-vscode
```
I worry someone might make PR changes to the code in the `lldb-vscode` 
directory which is effectively dead at this point.

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


[Lldb-commits] [compiler-rt] [libcxxabi] [libcxx] [lld] [flang] [llvm] [clang-tools-extra] [lldb] [clang] [AMDGPU] GFX12: select @llvm.prefetch intrinsic (PR #74576)

2023-12-07 Thread Stanislav Mekhanoshin via lldb-commits


@@ -959,6 +967,32 @@ def : GCNPat <
 }
 } // let OtherPredicates = [HasShaderCyclesRegister]
 
+def SIMM24bitPtr : ImmLeaf (Imm);}]
+>;
+
+multiclass SMPrefetchPat {
+  def : GCNPat <
+(smrd_prefetch (SMRDImm i64:$sbase, i32:$offset), timm, timm, (i32 
cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, $offset, (i32 
SGPR_NULL), (i8 0))
+  >;
+
+  def : GCNPat <
+(smrd_prefetch (i64 SReg_64:$sbase), timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, 0, (i32 SGPR_NULL), 
(i8 0))
+  >;
+
+  def : GCNPat <
+(prefetch SIMM24bitPtr:$offset, timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type#"_PC_REL") (as_i32timm 
$offset), (i32 SGPR_NULL), (i8 0))
+  > {
+let AddedComplexity = 10;
+  }

rampitec wrote:

Prefetch on an absolute address is practically useless.

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


[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

2023-12-07 Thread via lldb-commits

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

>From 64505f573341c16a62eda786c4710d3a7233cecc Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Wed, 6 Dec 2023 17:01:06 -0800
Subject: [PATCH 1/2] We need to generate events when finalizing, or we won't
 know that we succeeded in stopping the process to detach/kill.  Instead, we
 stall and then after our 20 interrupt timeout, we kill the process (even if
 we were supposed to detach) and exit.

OTOH, we have to not generate events when the Process is being destructed
because shared_from_this has already been torn down, and using it will
cause crashes.
---
 lldb/include/lldb/Target/Process.h| 10 +-
 lldb/source/Core/Debugger.cpp |  2 +-
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  2 +-
 .../Process/elf-core/ProcessElfCore.cpp   |  2 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  2 +-
 .../Process/mach-core/ProcessMachCore.cpp |  2 +-
 .../Process/minidump/ProcessMinidump.cpp  |  2 +-
 .../Process/scripted/ScriptedProcess.cpp  |  2 +-
 lldb/source/Target/Process.cpp| 14 ++--
 lldb/source/Target/ProcessTrace.cpp   |  2 +-
 lldb/source/Target/Target.cpp |  2 +-
 lldb/test/API/driver/quit_speed/Makefile  |  3 ++
 .../driver/quit_speed/TestQuitWithProcess.py  | 34 +++
 lldb/test/API/driver/quit_speed/main.c| 10 ++
 14 files changed, 76 insertions(+), 13 deletions(-)
 create mode 100644 lldb/test/API/driver/quit_speed/Makefile
 create mode 100644 lldb/test/API/driver/quit_speed/TestQuitWithProcess.py
 create mode 100644 lldb/test/API/driver/quit_speed/main.c

diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 4646e3070cf14..889f553f897f5 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -558,7 +558,10 @@ class Process : public 
std::enable_shared_from_this,
   ///
   /// Subclasses that override this method should always call this superclass
   /// method.
-  virtual void Finalize();
+  /// If you are running Finalize in your Process subclass Destructor, pass
+  /// \btrue.  If we are in the destructor, shared_from_this will no longer
+  /// work, so we have to avoid doing anything that might trigger that.
+  virtual void Finalize(bool destructing);
 
   /// Return whether this object is valid (i.e. has not been finalized.)
   ///
@@ -3079,6 +3082,11 @@ void PruneThreadPlans();
   /// This is set at the beginning of Process::Finalize() to stop functions
   /// from looking up or creating things during or after a finalize call.
   std::atomic m_finalizing;
+  // When we are "Finalizing" we need to do some cleanup.  But if the Finalize
+  // call is coming in the Destructor, we can't do any actual work in the
+  // process because that is likely to call "shared_from_this" which crashes
+  // if run while destructing.  We use this flag to determine that.   
+  std::atomic m_destructing;
 
   /// Mask for code an data addresses. The default value (0) means no mask is
   /// set.  The bits set to 1 indicate bits that are NOT significant for
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 21f71e449ca5e..d0b362045e801 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -930,7 +930,7 @@ void Debugger::Clear() {
 for (TargetSP target_sp : m_target_list.Targets()) {
   if (target_sp) {
 if (ProcessSP process_sp = target_sp->GetProcessSP())
-  process_sp->Finalize();
+  process_sp->Finalize(false);
 target_sp->Destroy();
   }
 }
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp 
b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 70bb9aa7a833c..4ab6c8cf1959d 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -164,7 +164,7 @@ ProcessKDP::~ProcessKDP() {
   // make sure all of the broadcaster cleanup goes as planned. If we destruct
   // this class, then Process::~Process() might have problems trying to fully
   // destroy the broadcaster.
-  Finalize();
+  Finalize(true);
 }
 
 Status ProcessKDP::DoWillLaunch(Module *module) {
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index aedc43a015ff1..24d5fdebd4bd5 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -108,7 +108,7 @@ ProcessElfCore::~ProcessElfCore() {
   // make sure all of the broadcaster cleanup goes as planned. If we destruct
   // this class, then Process::~Process() might have problems trying to fully
   // destroy the broadcaster.
-  Finalize();
+  Finalize(true);
 }
 
 lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment(
diff --git a/lldb/source/Plugins/Process/gdb-r

[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

2023-12-07 Thread Greg Clayton via lldb-commits

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

LGTM

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


[Lldb-commits] [llvm] [lldb] [lldb] Rename lldb-vscode to lldb-dap (PR #69264)

2023-12-07 Thread Alex Langford via lldb-commits

bulbazord wrote:

> @JDevlieghere Can you delete the `llvm-project/lldb/tools/lldb-vscode` 
> directory from git after this commit to clean up our codebase? There are 
> still two copies of the `lldb-dap` code in the sources:
> 
> ```
> lldb/tools/lldb-dap
> lldb/tools/lldb-vscode
> ```
> 
> I worry someone might make PR changes to the code in the `lldb-vscode` 
> directory which is effectively dead at this point.

On my machine, `lldb-vscode` is a symlink.
```
alex@alangford lldb % ls -la tools/lldb-vscode
lrwxr-xr-x@ 1 alex  staff  8 Oct 19 13:34 tools/lldb-vscode -> lldb-dap
```

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-07 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

> > This change broke building against LLVM dylib:
> > ```
> > /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
> > cannot find -lLLVMDebuginfod: No such file or directory
> > collect2: error: ld returned 1 exit status
> > samu: subcommand failed
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > Full build log: 
> > [dev-util:lldb-18.0.0_pre20231206:20231206-163149.log](https://github.com/llvm/llvm-project/files/13588891/dev-util.lldb-18.0.0_pre20231206.20231206-163149.log)
> 
> @mgorny Can you please point me at where to find all the configuration for 
> those builds? I'm stuck on a weirdo CentOS build (or MacOS) and can't manage 
> to get my CMake configuration stuff to let me build a dylib/so. I'll get on 
> this first thing tomorrow.


> This change broke building against LLVM dylib:
> 
> ```
> /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
> cannot find -lLLVMDebuginfod: No such file or directory
> collect2: error: ld returned 1 exit status
> samu: subcommand failed
> ```
> 
> Full build log: 
> [dev-util:lldb-18.0.0_pre20231206:20231206-163149.log](https://github.com/llvm/llvm-project/files/13588891/dev-util.lldb-18.0.0_pre20231206.20231206-163149.log)

@mgorny I've burned 3 hours this morning trying to get the visible 
configuration flags from that log file to function _before_ my patch on (my 
weirdo CentOS 9) Linux box, or cause problems _after_ my patch on macOS, and 
failed on both fronts. I'm stuck until you can get me the contents of 
`gentoo_common_config.cmake` (or tell me where to find it...)

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


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/74748

There are some typescript vscode extensions that are effectively wrappers of 
lldb-dap, and they commonly configure the debug adapter in particular ways 
using initCommands, among other settings. An unfortunate side effect is that, 
at least for initCommands, their output is printed on the Debug Console, which 
doesn't look clean and might confuse some users because.
As a way to improve the experience, I'm definining a new `privateConfiguration` 
setting, which can be used by adapter wrappers for private initialization. I'm 
starting with private initCommands, whose output can also be controlled via a 
`printMode` setting. By default, the output is only printed upon errors.
This setting helps distinguish things that the adapter wrapper does privately 
from what the user might want to do using public settings in JSON.


>From c5817d7acf154798cff6ac0b8f24a80002ff202d Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 29 Nov 2023 18:12:54 -0500
Subject: [PATCH] [lldb-dap] Introduce the new privateConfiguration setting

There are some typescript vscode extensions that are effectively wrappers of 
lldb-dap, and they commonly configure the debug adapter in particular ways 
using initCommands, among other settings. An unfortunate side effect is that, 
at least for initCommands, their output is printed on the Debug Console, which 
doesn't look clean and might confuse some users because.
As a way to improve the experience, I'm definining a new `privateConfiguration` 
setting, which can be used by adapter wrappers for private initialization. I'm 
starting with private initCommands, whose output can also be controlled via a 
`printMode` setting. By default, the output is only printed upon errors.
This setting helps distinguish things that the adapter wrapper does privately 
from what the user might want to do using public settings in JSON.
---
 .../test/tools/lldb-dap/dap_server.py |  3 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 +
 .../lldb-dap/privateConfiguration/Makefile|  2 +
 .../TestDAP_privateConfiguration.py   | 77 +++
 .../lldb-dap/privateConfiguration/main.cpp|  1 +
 lldb/tools/lldb-dap/DAP.cpp   | 33 +++-
 lldb/tools/lldb-dap/DAP.h | 30 +++-
 lldb/tools/lldb-dap/LLDBUtils.cpp | 17 ++--
 lldb/tools/lldb-dap/LLDBUtils.h   |  7 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  7 +-
 lldb/tools/lldb-dap/package.json  | 17 
 11 files changed, 183 insertions(+), 15 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
 create mode 100644 lldb/test/API/tools/lldb-dap/privateConfiguration/main.cpp

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index bb863bb8719176..4f2bff7ad5101d 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -734,6 +734,7 @@ def request_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -779,6 +780,8 @@ def request_launch(
 args_dict["customFrameFormat"] = customFrameFormat
 if customThreadFormat:
 args_dict["customThreadFormat"] = customThreadFormat
+if privateConfiguration:
+args_dict["privateConfiguration"] = privateConfiguration
 
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 4ccd6014e54be6..f1bf4decbe0779 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -357,6 +357,7 @@ def launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Sending launch request to dap"""
 
@@ -398,6 +399,7 @@ def cleanup():
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
 
 if expectFailure:
@@ -437,6 +439,7 @@ def build_and_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+private

[Lldb-commits] [llvm] [libcxxabi] [clang-tools-extra] [lldb] [clang] [lld] [compiler-rt] [flang] [libcxx] [AMDGPU] GFX12: select @llvm.prefetch intrinsic (PR #74576)

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


@@ -959,6 +967,32 @@ def : GCNPat <
 }
 } // let OtherPredicates = [HasShaderCyclesRegister]
 
+def SIMM24bitPtr : ImmLeaf (Imm);}]
+>;
+
+multiclass SMPrefetchPat {
+  def : GCNPat <
+(smrd_prefetch (SMRDImm i64:$sbase, i32:$offset), timm, timm, (i32 
cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, $offset, (i32 
SGPR_NULL), (i8 0))
+  >;
+
+  def : GCNPat <
+(smrd_prefetch (i64 SReg_64:$sbase), timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, 0, (i32 SGPR_NULL), 
(i8 0))
+  >;
+
+  def : GCNPat <
+(prefetch SIMM24bitPtr:$offset, timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type#"_PC_REL") (as_i32timm 
$offset), (i32 SGPR_NULL), (i8 0))
+  > {
+let AddedComplexity = 10;
+  }

jayfoad wrote:

But that is how `llvm.prefetch` is defined: "`address` is the address to be 
prefetched". A different operation should use a different intrinsic.

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


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/74748

>From 07bd16ac9bbc4f9868d1b541e003aa95bf6ae8be Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 29 Nov 2023 18:12:54 -0500
Subject: [PATCH] [lldb-dap] Introduce the new privateConfiguration setting

There are some typescript vscode extensions that are effectively wrappers of 
lldb-dap, and they commonly configure the debug adapter in particular ways 
using initCommands, among other settings. An unfortunate side effect is that, 
at least for initCommands, their output is printed on the Debug Console, which 
doesn't look clean and might confuse some users because.
As a way to improve the experience, I'm definining a new `privateConfiguration` 
setting, which can be used by adapter wrappers for private initialization. I'm 
starting with private initCommands, whose output can also be controlled via a 
`printMode` setting. By default, the output is only printed upon errors.
This setting helps distinguish things that the adapter wrapper does privately 
from what the user might want to do using public settings in JSON.
---
 .../test/tools/lldb-dap/dap_server.py |  3 +
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  4 +
 .../lldb-dap/privateConfiguration/Makefile|  2 +
 .../TestDAP_privateConfiguration.py   | 77 +++
 .../lldb-dap/privateConfiguration/main.cpp|  1 +
 lldb/tools/lldb-dap/DAP.cpp   | 33 +++-
 lldb/tools/lldb-dap/DAP.h | 29 ++-
 lldb/tools/lldb-dap/LLDBUtils.cpp | 17 ++--
 lldb/tools/lldb-dap/LLDBUtils.h   | 15 ++--
 lldb/tools/lldb-dap/lldb-dap.cpp  |  7 +-
 lldb/tools/lldb-dap/package.json  | 34 
 11 files changed, 205 insertions(+), 17 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
 create mode 100644 
lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
 create mode 100644 lldb/test/API/tools/lldb-dap/privateConfiguration/main.cpp

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index bb863bb8719176..4f2bff7ad5101d 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -734,6 +734,7 @@ def request_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -779,6 +780,8 @@ def request_launch(
 args_dict["customFrameFormat"] = customFrameFormat
 if customThreadFormat:
 args_dict["customThreadFormat"] = customThreadFormat
+if privateConfiguration:
+args_dict["privateConfiguration"] = privateConfiguration
 
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 4ccd6014e54be6..f1bf4decbe0779 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -357,6 +357,7 @@ def launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Sending launch request to dap"""
 
@@ -398,6 +399,7 @@ def cleanup():
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
 
 if expectFailure:
@@ -437,6 +439,7 @@ def build_and_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Build the default Makefile target, create the DAP debug adaptor,
 and launch the process.
@@ -470,4 +473,5 @@ def build_and_launch(
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
diff --git a/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile 
b/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
new file mode 100644
index 00..3d0b98f13f3d7b
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfigur

[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [llvm] [clang-tools-extra] [mlir] [lldb] [clang] [libcxx] [compiler-rt] [flang] [libc] [openmp] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-12-07 Thread via lldb-commits

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


[Lldb-commits] [compiler-rt] [libcxx] [libc] [flang] [llvm] [clang-tools-extra] [lldb] [mlir] [clang] [openmp] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-12-07 Thread via lldb-commits

pizzud wrote:

I've been kind of leaving this in limbo while we sort out the shared_ptr one 
and I agree it probably makes more sense to make bugprone-unique-pointer-move 
as a parallel to shared-pointer in [PR 
#67467](https://github.com/llvm/llvm-project/pull/67467) and consider 
performance-heavy-move separately, since there's runtime-vs-compile-time 
considerations there (eg sizeof(std::string) vs s.size()). Let's drop this and 
I'll open up new PRs with each additional check.

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


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)


Changes

There are some typescript vscode extensions that are effectively wrappers of 
lldb-dap, and they commonly configure the debug adapter in particular ways 
using initCommands, among other settings. An unfortunate side effect is that, 
at least for initCommands, their output is printed on the Debug Console, which 
doesn't look clean and might confuse some users because.
As a way to improve the experience, I'm definining a new `privateConfiguration` 
setting, which can be used by adapter wrappers for private initialization. I'm 
starting with private initCommands, whose output can also be controlled via a 
`printMode` setting. By default, the output is only printed upon errors.
This setting helps distinguish things that the adapter wrapper does privately 
from what the user might want to do using public settings in JSON.


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


11 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
(+3) 
- (modified) 
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py (+4) 
- (added) lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile (+2) 
- (added) 
lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
 (+77) 
- (added) lldb/test/API/tools/lldb-dap/privateConfiguration/main.cpp (+1) 
- (modified) lldb/tools/lldb-dap/DAP.cpp (+30-3) 
- (modified) lldb/tools/lldb-dap/DAP.h (+27-2) 
- (modified) lldb/tools/lldb-dap/LLDBUtils.cpp (+11-6) 
- (modified) lldb/tools/lldb-dap/LLDBUtils.h (+10-5) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+6-1) 
- (modified) lldb/tools/lldb-dap/package.json (+34) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index bb863bb8719176..4f2bff7ad5101d 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -734,6 +734,7 @@ def request_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 args_dict = {"program": program}
 if args:
@@ -779,6 +780,8 @@ def request_launch(
 args_dict["customFrameFormat"] = customFrameFormat
 if customThreadFormat:
 args_dict["customThreadFormat"] = customThreadFormat
+if privateConfiguration:
+args_dict["privateConfiguration"] = privateConfiguration
 
 args_dict["enableAutoVariableSummaries"] = enableAutoVariableSummaries
 args_dict["enableSyntheticChildDebugging"] = 
enableSyntheticChildDebugging
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index 4ccd6014e54be6..f1bf4decbe0779 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -357,6 +357,7 @@ def launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Sending launch request to dap"""
 
@@ -398,6 +399,7 @@ def cleanup():
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
 
 if expectFailure:
@@ -437,6 +439,7 @@ def build_and_launch(
 commandEscapePrefix=None,
 customFrameFormat=None,
 customThreadFormat=None,
+privateConfiguration=None,
 ):
 """Build the default Makefile target, create the DAP debug adaptor,
 and launch the process.
@@ -470,4 +473,5 @@ def build_and_launch(
 commandEscapePrefix=commandEscapePrefix,
 customFrameFormat=customFrameFormat,
 customThreadFormat=customThreadFormat,
+privateConfiguration=privateConfiguration,
 )
diff --git a/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile 
b/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
new file mode 100644
index 00..3d0b98f13f3d7b
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/privateConfiguration/Makefile
@@ -0,0 +1,2 @@
+CXX_SOURCES := main.cpp
+include Makefile.rules
diff --git 
a/lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
 
b/lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
new file mode 100644
index 00..0d930dcbc80e38
--- /dev/null
+++ 
b/lldb/test/API/tools/lldb-dap/privateConfiguration/TestDAP_privateConfiguration.py
@@ -0,0 +1,77 @@
+"""
+Test lldb-dap stack trace respon

[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-07 Thread Greg Clayton via lldb-commits

clayborg wrote:

Sounds like some configs don't create `LLVMDebuginfod` target possibly because 
it isn't enabled. Is there a cmake option to disable `LLVMDebuginfod` or some 
magic in the Cmake config file for this target?

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


[Lldb-commits] [clang-tools-extra] [llvm] [libcxx] [lldb] [flang] [clang] [compiler-rt] [libcxxabi] [lld] [AMDGPU] GFX12: select @llvm.prefetch intrinsic (PR #74576)

2023-12-07 Thread Stanislav Mekhanoshin via lldb-commits


@@ -959,6 +967,32 @@ def : GCNPat <
 }
 } // let OtherPredicates = [HasShaderCyclesRegister]
 
+def SIMM24bitPtr : ImmLeaf (Imm);}]
+>;
+
+multiclass SMPrefetchPat {
+  def : GCNPat <
+(smrd_prefetch (SMRDImm i64:$sbase, i32:$offset), timm, timm, (i32 
cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, $offset, (i32 
SGPR_NULL), (i8 0))
+  >;
+
+  def : GCNPat <
+(smrd_prefetch (i64 SReg_64:$sbase), timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type) $sbase, 0, (i32 SGPR_NULL), 
(i8 0))
+  >;
+
+  def : GCNPat <
+(prefetch SIMM24bitPtr:$offset, timm, timm, (i32 cache_type)),
+(!cast("S_PREFETCH_"#type#"_PC_REL") (as_i32timm 
$offset), (i32 SGPR_NULL), (i8 0))
+  > {
+let AddedComplexity = 10;
+  }

rampitec wrote:

So you want a target intrinsic?

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


[Lldb-commits] [openmp] [clang-tools-extra] [libc] [llvm] [libcxx] [lldb] [flang] [clang] [compiler-rt] [mlir] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-12-07 Thread via lldb-commits


@@ -0,0 +1,21 @@
+.. title:: clang-tidy - performance-move-smart-pointer-contents
+
+performance-move-smart-pointer-contents
+===
+
+Recommends avoiding moving out of a smart pointer when moving the pointer is

EugeneZelenko wrote:

Please make this statement same as in Release Notes.

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


[Lldb-commits] [llvm] [clang-tools-extra] [mlir] [lldb] [clang] [libcxx] [compiler-rt] [flang] [libc] [openmp] [clang-tidy] Add performance-move-smart-pointer-contents check. (PR #66139)

2023-12-07 Thread via lldb-commits


@@ -0,0 +1,21 @@
+.. title:: clang-tidy - performance-move-smart-pointer-contents
+
+performance-move-smart-pointer-contents
+===
+
+Recommends avoiding moving out of a smart pointer when moving the pointer is
+cheaper.
+
+Given a smart pointer containing a movable type, such as a
+``std::unique_ptr``, it's possible to move the contents of 
the

EugeneZelenko wrote:

Please follow 80 characters limit. Same below.

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


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

I am not a fan of making a whole extra duplication of "initCommands" just to 
make these commands not show up in the debug console. Wouldn't a setting like:
```
  "showCommandsInDebugConsole": ["always", "error-only", "never"]
``` 
Would this achieve the same thing without needed to put these command elsewhere?

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


[Lldb-commits] [libcxxabi] [libc] [clang] [clang-tools-extra] [lld] [openmp] [compiler-rt] [libcxx] [flang] [lldb] [mlir] [llvm] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread Jakub Mazurkiewicz via lldb-commits

https://github.com/JMazurkiewicz updated 
https://github.com/llvm/llvm-project/pull/74655

>From b3de573887cdd86fd6ce168bdcc6d729d73b13b2 Mon Sep 17 00:00:00 2001
From: Jakub Mazurkiewicz 
Date: Wed, 6 Dec 2023 14:03:51 +0100
Subject: [PATCH 01/10] [libc++] Fix `take_view::__sentinel`'s `operator==`

---
 libcxx/include/__ranges/take_view.h   |   2 +-
 .../base.pass.cpp |   5 +-
 .../ctor.pass.cpp |   0
 .../range.take.sentinel/eq.pass.cpp   | 192 ++
 .../range.take/sentinel/eq.pass.cpp   |  55 -
 5 files changed, 194 insertions(+), 60 deletions(-)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/base.pass.cpp (83%)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/ctor.pass.cpp (100%)
 create mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 delete mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/eq.pass.cpp

diff --git a/libcxx/include/__ranges/take_view.h 
b/libcxx/include/__ranges/take_view.h
index 4204017d9249b..811428e529f59 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -183,7 +183,7 @@ class take_view<_View>::__sentinel {
   template
 requires sentinel_for, 
iterator_t<__maybe_const<_OtherConst, _View>>>
   _LIBCPP_HIDE_FROM_ABI
-  friend constexpr bool operator==(const _Iter<_Const>& __lhs, const 
__sentinel& __rhs) {
+  friend constexpr bool operator==(const _Iter<_OtherConst>& __lhs, const 
__sentinel& __rhs) {
 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
   }
 };
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
similarity index 83%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
index c949eb7cc0846..15b2b5476e86d 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
@@ -8,10 +8,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-// sentinel() = default;
-// constexpr explicit sentinel(sentinel_t end);
-// constexpr sentinel(sentinel s)
-//   requires Const && convertible_to, sentinel_t>;
+// constexpr sentinel_t base() const;
 
 #include 
 #include 
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
similarity index 100%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
new file mode 100644
index 0..f20c29b4c6471
--- /dev/null
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
@@ -0,0 +1,192 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// friend constexpr bool operator==(const CI& y, const sentinel& x);
+// template
+//   requires sentinel_for, 
iterator_t>>
+// friend constexpr bool operator==(const CI& y, const sentinel& 
x);
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+class StrictIterator {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  using value_type  = int;
+  using difference_type = std::ptrdiff_t;
+
+  constexpr explicit StrictIterator(Base base) : base_(base) {}
+
+  StrictIterator(StrictIterator&&)= default;
+  StrictIterator& operator=(StrictIterator&&) = default;
+
+  constexpr StrictIterator& operator++() {
+++base_;
+return *this;
+  }
+
+  constexpr void operator++(int) { ++*this; }
+  constexpr decltype(auto) operator*() const { return *base_; }
+  constexpr Base base() const { return base_; }
+};
+
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+
+template 
+class StrictSentinel {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  StrictSentinel() = default;

[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Greg Clayton via lldb-commits

clayborg wrote:

Another idea would be to add a command that allows users to specify the console 
to log LLDB commands from `*Commands` settings by allowing them to specify a 
console. From the DAP spec we have:
```
/**
 * The output category. If not specified or if the category is not
 * understood by the client, `console` is assumed.
 * Values:
 * 'console': Show the output in the client's default message UI, e.g. a
 * 'debug console'. This category should only be used for informational
 * output from the debugger (as opposed to the debuggee).
 * 'important': A hint for the client to show the output in the client's UI
 * for important and highly visible information, e.g. as a popup
 * notification. This category should only be used for important messages
 * from the debugger (as opposed to the debuggee). Since this category value
 * is a hint, clients might ignore the hint and assume the `console`
 * category.
 * 'stdout': Show the output as normal program output from the debuggee.
 * 'stderr': Show the output as error program output from the debuggee.
 * 'telemetry': Send the output to telemetry instead of showing it to the
 * user.
 * etc.
 */
category?: 'console' | 'important' | 'stdout' | 'stderr' | 'telemetry' | 
string;
```
I was thinking:
```
   "lldbCommandsOutputDestination" = ['console' | 'important' | 'stdout' | 
'stderr' | 'telemetry' | 'none']
```
Note that I added one exrtra 'none' which would also be 'off' or 'quiet'

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


[Lldb-commits] [llvm] [lldb] [lldb] Rename lldb-vscode to lldb-dap (PR #69264)

2023-12-07 Thread Greg Clayton via lldb-commits

clayborg wrote:

> > @JDevlieghere Can you delete the `llvm-project/lldb/tools/lldb-vscode` 
> > directory from git after this commit to clean up our codebase? There are 
> > still two copies of the `lldb-dap` code in the sources:
> > ```
> > lldb/tools/lldb-dap
> > lldb/tools/lldb-vscode
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > I worry someone might make PR changes to the code in the `lldb-vscode` 
> > directory which is effectively dead at this point.
> 
> On my machine, `lldb-vscode` is a symlink.
> 
> ```
> alex@alangford lldb % ls -la tools/lldb-vscode
> lrwxr-xr-x@ 1 alex  staff  8 Oct 19 13:34 tools/lldb-vscode -> lldb-dap
> ```
It is on mine too! interesting. Can we delete this link from git?


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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread via lldb-commits


@@ -175,3 +179,30 @@ Status TargetThreadWindows::DoResume() {
 
   return Status();
 }
+
+const char *TargetThreadWindows::GetName() {
+  Log *log = GetLog(LLDBLog::Thread);
+  HMODULE hModule = ::LoadLibraryW(L"Kernel32.dll");
+  if (hModule) {
+auto GetThreadDescription =
+reinterpret_cast(
+::GetProcAddress(hModule, "GetThreadDescription"));

Fulgen301 wrote:

The function was added in Windows 10 1607, which was also the only build 
(excluding Server 2016) where it isn't available in the header:

> [Windows Server 2016, Windows 10 LTSB 2016 and Windows 10 version 1607: 
> GetThreadDescription is only available by Run Time Dynamic Linking in 
> KernelBase.dll.](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreaddescription)

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread via lldb-commits

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-12-07 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

> Sounds like some configs don't create `LLVMDebuginfod` target possibly 
> because it isn't enabled. Is there a cmake option to disable `LLVMDebuginfod` 
> or some magic in the Cmake config file for this target?

Nothing that I could find. The library is written such that if the 
configuration doesn't include either libcurl or httplib then all the functions 
just fail to do anything, so from what I can tell there'd never be a reason to 
disable it.

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


[Lldb-commits] [lldb] lldb: add support for thread names on Windows (PR #74731)

2023-12-07 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

Sounds like there is good reason for linking in the kernel32.dll, so code looks 
good to me. A windows only test that creates a thread with a known name would 
be great to add where we verify the name is correct.

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


[Lldb-commits] [libcxx] [clang] [flang] [compiler-rt] [llvm] [clang-tools-extra] [libcxxabi] [lldb] [mlir] [openmp] [MachineCopyPropagation] When the source of PreviousCopy is undef, we cannot replace

2023-12-07 Thread David Green via lldb-commits

davemgreen wrote:

Hello. I think that if you removed undef from the first instruction the result 
would still be incorrect. With:
```
$x8 = ORRXrs $xzr, $x0, 0, implicit $w0
$w8 = ORRWrs $wzr, $w0, 0, implicit-def $x8
```
The second instruction will zero-extend the w0 register to x8. It would be OK 
to remove the first instruction (it is dead), it is not OK to remove the second 
if something is relying on the top bits being zero. I assume that's what goes 
wrong in your case? The top bits are not zero into the function?

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


[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

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

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

lgtm

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


[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

2023-12-07 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

The change itself LGTM, but I'd like to either have an inline comment (e.g. 
`Finalize(/*destructing=*/false)) `or use an enum value to convey the meaning 
of those values.

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


[Lldb-commits] [lldb] [lldb-dap] Introduce the new privateConfiguration setting (PR #74748)

2023-12-07 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@clayborg , the main issue is to allow users to use the regular initCommands 
and at the same time have another way for the vscode extension to issue their 
own initCommands and control the output of these specific commands without 
interfering with the initCommands provided by the user. 
Any sort of global setting that controls the output is not going to work 
because it would affect both the extension's initCommands as well as the 
user's. Like, we don't want to hide users' initCommands just because the 
extension wants to hide a few.
This makes me think that the cleanest approach is to have another set of 
initCommands for the extension, that runs totally independently from the ones 
provided by the user.
What do you think?

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


[Lldb-commits] [lldb] [compiler-rt] [lld] [libcxxabi] [clang-tools-extra] [llvm] [libc] [libcxx] [flang] [mlir] [clang] [openmp] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread via lldb-commits

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

LGTM with green CI

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


[Lldb-commits] [lld] [clang-tools-extra] [libcxxabi] [openmp] [libc] [mlir] [flang] [lldb] [compiler-rt] [libcxx] [clang] [llvm] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread via lldb-commits


@@ -183,7 +183,7 @@ class take_view<_View>::__sentinel {
   template
 requires sentinel_for, 
iterator_t<__maybe_const<_OtherConst, _View>>>
   _LIBCPP_HIDE_FROM_ABI
-  friend constexpr bool operator==(const _Iter<_Const>& __lhs, const 
__sentinel& __rhs) {
+  friend constexpr bool operator==(const _Iter<_OtherConst>& __lhs, const 
__sentinel& __rhs) {
 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
   }

huixie90 wrote:

Nothing to do with your patch, just wanted to point out that we don’t seem to 
have tests to test the default argument. (you don’t need to do it as this is 
nothing to do with the bug you are fixing)
template

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


[Lldb-commits] [llvm] [compiler-rt] [mlir] [lld] [clang-tools-extra] [openmp] [flang] [libcxxabi] [libcxx] [libc] [clang] [lldb] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread via lldb-commits

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


[Lldb-commits] [mlir] [lldb] [libc] [clang-tools-extra] [flang] [llvm] [libcxxabi] [openmp] [lld] [compiler-rt] [libcxx] [clang] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb][progress] Add discrete boolean flag to progress reports (PR #69516)

2023-12-07 Thread Chelsea Cassanova via lldb-commits


@@ -2225,7 +2225,8 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
   const char *file_name = file.GetFilename().AsCString("");
   LLDB_SCOPED_TIMERF("ObjectFileMachO::ParseSymtab () module = %s", file_name);
   LLDB_LOG(log, "Parsing symbol table for {0}", file_name);
-  Progress progress(llvm::formatv("Parsing symbol table for {0}", file_name));
+  Progress progress(llvm::formatv("Parsing symbol table for {0}", file_name),
+Progress::ProgressReportType::eAggregateProgressReport);

chelcassanova wrote:

The intention is that if `is_aggregate == false` then the progress report type 
can be grouped together in LLDB under one large umbrella progress report for 
that operation whereas if `is_aggregate == true` then the IDE could potentially 
filter out those progress reports since each progress report happening 
individually means that they look spammy in an IDE.

Instead of using a string as a `category` field we could have each progress 
report type/category be an enum in `lldb_enumerations.h` i.e. 
`ProgressReportType/Category == eProgressSymbolTableParse` or 
`eProgressDWARFIndexing`

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


[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

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

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

In optimized code we can end up with return address being the next instruction 
in a different block. If we are dealing with location lists, we want to 
decrement the PC value so it's within the calling block range that we're 
checking against the loclists.

This was fixed in https://reviews.llvm.org/D124597 
(`6e56c4961a106b8fde69ffcf9f803fe0890722fa`), by introducing a 
`GetFrameCodeAddressForSymbolication`. This fixed `frame variable`, but `expr` 
calls into `Variable::LocationIsValidForFrame`, where this new API wasn't used 
yet.

So in the associated test-case, running `frame var this` works, but `expr this` 
doesn't. With `dwim-print` this makes the situation more surprising for the 
user because `p this`, `v this` and `v *this` work, but `p *this` doesn't 
because it falls back onto `expr` (due to the dereference).

This patch makes sure we lookup loclists using the correct PC by using this new 
`GetFrameCodeAddressForSymbolication` API.

>From 2352f67789c04f86c8a0f7ad8940d782288750b8 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 7 Dec 2023 21:35:41 +
Subject: [PATCH] [lldb][Symbol] Make sure we decrement PC before checking
 location list

In optimized code we can end up with return address being the
next instruction in a different block. If we are dealing with
location lists, we want to decrement the PC value so it's within
the calling block range that we're checking against the loclists.

This was fixed in https://reviews.llvm.org/D124597
(`6e56c4961a106b8fde69ffcf9f803fe0890722fa`), by introducing
a `GetFrameCodeAddressForSymbolication`. This fixed `frame variable`,
but `expr` calls into `Variable::LocationIsValidForFrame`, where this
new API wasn't used yet.

So in the associated test-case, running `frame var this` works, but
`expr this` doesn't. With `dwim-print` this makes the situation more
surprising for the user because `p this`, `v this` and `v *this` work,
but `p *this` doesn't because it falls back onto `expr` (due to the
dereference).

This patch makes sure we lookup loclists using
the correct PC by using this new `GetFrameCodeAddressForSymbolication` API.
---
 lldb/source/Symbol/Variable.cpp   |  3 +-
 .../location-list-lookup-cpp-member/Makefile  |  3 ++
 .../TestCppMemberLocationListLookup.py| 29 +++
 .../location-list-lookup-cpp-member/main.cpp  | 23 +++
 4 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 85ceadd20c611..db740cb7cb6e4 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -227,7 +227,8 @@ bool Variable::LocationIsValidForFrame(StackFrame *frame) {
   // contains the current address when converted to a load address
   return m_location_list.ContainsAddress(
   loclist_base_load_addr,
-  frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
+  frame->GetFrameCodeAddressForSymbolication().GetLoadAddress(
+  target_sp.get()));
 }
   }
   return false;
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
new file mode 100644
index 0..8e453681d7b39
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS := -O1
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
new file mode 100644
index 0..846386ceffc6a
--- /dev/null
+++ 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
@@ -0,0 +1,29 @@
+"""Test that lldb picks the correct DWARF location list entry with a 
return-pc out of bounds."""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CppMemberLocationListLookupTestCase(TestBase):
+def test(self):
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+self.dbg.SetAsync(False)
+
+li = lldb.SBLaunchInfo(["a.out"])
+error = lldb.SBError()
+process = target.Launch(li, error)
+self.assertTrue(process.IsValid())
+self.assertTrue(process.is_stopped)
+
+# Find `bar` on the stack, then
+# find `this

[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

2023-12-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

In optimized code we can end up with return address being the next instruction 
in a different block. If we are dealing with location lists, we want to 
decrement the PC value so it's within the calling block range that we're 
checking against the loclists.

This was fixed in https://reviews.llvm.org/D124597 
(`6e56c4961a106b8fde69ffcf9f803fe0890722fa`), by introducing a 
`GetFrameCodeAddressForSymbolication`. This fixed `frame variable`, but `expr` 
calls into `Variable::LocationIsValidForFrame`, where this new API wasn't used 
yet.

So in the associated test-case, running `frame var this` works, but `expr this` 
doesn't. With `dwim-print` this makes the situation more surprising for the 
user because `p this`, `v this` and `v *this` work, but `p *this` doesn't 
because it falls back onto `expr` (due to the dereference).

This patch makes sure we lookup loclists using the correct PC by using this new 
`GetFrameCodeAddressForSymbolication` API.

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


4 Files Affected:

- (modified) lldb/source/Symbol/Variable.cpp (+2-1) 
- (added) 
lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile (+3) 
- (added) 
lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 (+29) 
- (added) 
lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp (+23) 


``diff
diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 85ceadd20c611e..db740cb7cb6e41 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -227,7 +227,8 @@ bool Variable::LocationIsValidForFrame(StackFrame *frame) {
   // contains the current address when converted to a load address
   return m_location_list.ContainsAddress(
   loclist_base_load_addr,
-  frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
+  frame->GetFrameCodeAddressForSymbolication().GetLoadAddress(
+  target_sp.get()));
 }
   }
   return false;
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
new file mode 100644
index 00..8e453681d7b390
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS := -O1
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
new file mode 100644
index 00..846386ceffc6ac
--- /dev/null
+++ 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
@@ -0,0 +1,29 @@
+"""Test that lldb picks the correct DWARF location list entry with a 
return-pc out of bounds."""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CppMemberLocationListLookupTestCase(TestBase):
+def test(self):
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+self.dbg.SetAsync(False)
+
+li = lldb.SBLaunchInfo(["a.out"])
+error = lldb.SBError()
+process = target.Launch(li, error)
+self.assertTrue(process.IsValid())
+self.assertTrue(process.is_stopped)
+
+# Find `bar` on the stack, then
+# find `this` local variable, then
+# check that we can read out the pointer value
+for f in process.GetSelectedThread().frames:
+if f.GetDisplayFunctionName().startswith("Foo::bar"):
+process.GetSelectedThread().SetSelectedFrame(f.idx)
+self.expect_expr("this", result_type="Foo *")
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp
new file mode 100644
index 00..96817f141b82cb
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp
@@ -0,0 +1,23 @@
+#include 
+#include 
+
+void func(int in);
+
+struct Foo {
+  int x;
+  [[clang::noinline]] void bar(Foo *f);
+};
+
+int main(int argc, char **argv) {
+  Foo f{.x = 5};
+  std::printf("%p\n", &f.x);
+  f.bar(&f);
+  return f.x;
+}
+
+void Foo::bar(Foo *f) {
+  std::printf("%p %p\n", f, this);
+  std::abort(); /// 'this' should be still accessible
+}
+
+void func(int in) { printf("%d\n", in); }

``




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


[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

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

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


[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

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

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


[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

2023-12-07 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan created 
https://github.com/llvm/llvm-project/pull/74773

There was duplicated (and complex) code querying whether tags were type-like 
tags (i.e. class or struct); this has been factored out into a helper function.

There was also a comment about not comparing identical DIEs without ever 
performing that check; this comment has been removed. It was likely a result of 
copy paste from another function in this same file which actually does that 
check.

>From 9f38564875620a44a982a50492d87ee431baffcd Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 13:41:44 -0800
Subject: [PATCH] [SymbolFileDWARF][NFC] Remove duplicated code checking for
 type tags

There was duplicated (and complex) code querying whether tags were type-like
tags (i.e. class or struct); this has been factored out into a helper function.

There was also a comment about not comparing identical DIEs without ever
performing that check; this comment has been removed. It was likely a result of
copy paste from another function in this same file which actually does that
check.
---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 58 +--
 1 file changed, 13 insertions(+), 45 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index d4cc26a3c329be..541d8d75f2187d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -130,6 +130,10 @@ class PluginProperties : public Properties {
   }
 };
 
+bool IsTypeTag(llvm::dwarf::Tag Tag) {
+  return Tag == llvm::dwarf::Tag::DW_TAG_class_type ||
+ Tag == llvm::dwarf::Tag::DW_TAG_structure_type;
+}
 } // namespace
 
 static PluginProperties &GetGlobalPluginProperties() {
@@ -2947,29 +2951,18 @@ TypeSP 
SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
 
   m_index->GetCompleteObjCClass(
   type_name, must_be_implementation, [&](DWARFDIE type_die) {
-bool try_resolving_type = false;
-
 // Don't try and resolve the DIE we are looking for with the DIE
 // itself!
-if (type_die != die) {
-  switch (type_die.Tag()) {
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-try_resolving_type = true;
-break;
-  default:
-break;
-  }
-}
-if (!try_resolving_type)
+if (type_die == die || !IsTypeTag(type_die.Tag()))
   return true;
 
 if (must_be_implementation &&
-type_die.Supports_DW_AT_APPLE_objc_complete_type())
-  try_resolving_type = type_die.GetAttributeValueAsUnsigned(
+type_die.Supports_DW_AT_APPLE_objc_complete_type()) {
+  bool try_resolving_type = type_die.GetAttributeValueAsUnsigned(
   DW_AT_APPLE_objc_complete_type, 0);
-if (!try_resolving_type)
-  return true;
+  if (!try_resolving_type)
+return true;
+}
 
 Type *resolved_type = ResolveType(type_die, false, true);
 if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
@@ -3128,36 +3121,11 @@ 
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
   if (type_system &&
   !type_system->SupportsLanguage(GetLanguage(*type_die.GetCU(
 return true;
-  bool try_resolving_type = false;
 
-  // Don't try and resolve the DIE we are looking for with the DIE
-  // itself!
   const dw_tag_t type_tag = type_die.Tag();
-  // Make sure the tags match
-  if (type_tag == tag) {
-// The tags match, lets try resolving this type
-try_resolving_type = true;
-  } else {
-// The tags don't match, but we need to watch our for a forward
-// declaration for a struct and ("struct foo") ends up being a
-// class ("class foo { ... };") or vice versa.
-switch (type_tag) {
-case DW_TAG_class_type:
-  // We had a "class foo", see if we ended up with a "struct foo
-  // { ... };"
-  try_resolving_type = (tag == DW_TAG_structure_type);
-  break;
-case DW_TAG_structure_type:
-  // We had a "struct foo", see if we ended up with a "class foo
-  // { ... };"
-  try_resolving_type = (tag == DW_TAG_class_type);
-  break;
-default:
-  // Tags don't match, don't event try to resolve using this type
-  // whose name matches
-  break;
-}
-  }
+  // Resolve the type if both have the same tag or {class, struct} tags.
+  bool try_resolving_type =
+  type_tag == tag || (IsTypeTag(type_tag) && IsTypeTag(tag));
 
   if (!try_resolving_type) {
 if (log) {

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

[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

2023-12-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

There was duplicated (and complex) code querying whether tags were type-like 
tags (i.e. class or struct); this has been factored out into a helper function.

There was also a comment about not comparing identical DIEs without ever 
performing that check; this comment has been removed. It was likely a result of 
copy paste from another function in this same file which actually does that 
check.

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


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+13-45) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index d4cc26a3c329b..541d8d75f2187 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -130,6 +130,10 @@ class PluginProperties : public Properties {
   }
 };
 
+bool IsTypeTag(llvm::dwarf::Tag Tag) {
+  return Tag == llvm::dwarf::Tag::DW_TAG_class_type ||
+ Tag == llvm::dwarf::Tag::DW_TAG_structure_type;
+}
 } // namespace
 
 static PluginProperties &GetGlobalPluginProperties() {
@@ -2947,29 +2951,18 @@ TypeSP 
SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
 
   m_index->GetCompleteObjCClass(
   type_name, must_be_implementation, [&](DWARFDIE type_die) {
-bool try_resolving_type = false;
-
 // Don't try and resolve the DIE we are looking for with the DIE
 // itself!
-if (type_die != die) {
-  switch (type_die.Tag()) {
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-try_resolving_type = true;
-break;
-  default:
-break;
-  }
-}
-if (!try_resolving_type)
+if (type_die == die || !IsTypeTag(type_die.Tag()))
   return true;
 
 if (must_be_implementation &&
-type_die.Supports_DW_AT_APPLE_objc_complete_type())
-  try_resolving_type = type_die.GetAttributeValueAsUnsigned(
+type_die.Supports_DW_AT_APPLE_objc_complete_type()) {
+  bool try_resolving_type = type_die.GetAttributeValueAsUnsigned(
   DW_AT_APPLE_objc_complete_type, 0);
-if (!try_resolving_type)
-  return true;
+  if (!try_resolving_type)
+return true;
+}
 
 Type *resolved_type = ResolveType(type_die, false, true);
 if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
@@ -3128,36 +3121,11 @@ 
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
   if (type_system &&
   !type_system->SupportsLanguage(GetLanguage(*type_die.GetCU(
 return true;
-  bool try_resolving_type = false;
 
-  // Don't try and resolve the DIE we are looking for with the DIE
-  // itself!
   const dw_tag_t type_tag = type_die.Tag();
-  // Make sure the tags match
-  if (type_tag == tag) {
-// The tags match, lets try resolving this type
-try_resolving_type = true;
-  } else {
-// The tags don't match, but we need to watch our for a forward
-// declaration for a struct and ("struct foo") ends up being a
-// class ("class foo { ... };") or vice versa.
-switch (type_tag) {
-case DW_TAG_class_type:
-  // We had a "class foo", see if we ended up with a "struct foo
-  // { ... };"
-  try_resolving_type = (tag == DW_TAG_structure_type);
-  break;
-case DW_TAG_structure_type:
-  // We had a "struct foo", see if we ended up with a "class foo
-  // { ... };"
-  try_resolving_type = (tag == DW_TAG_class_type);
-  break;
-default:
-  // Tags don't match, don't event try to resolve using this type
-  // whose name matches
-  break;
-}
-  }
+  // Resolve the type if both have the same tag or {class, struct} tags.
+  bool try_resolving_type =
+  type_tag == tag || (IsTypeTag(type_tag) && IsTypeTag(tag));
 
   if (!try_resolving_type) {
 if (log) {

``




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


[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

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


@@ -2947,29 +2951,18 @@ TypeSP 
SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
 
   m_index->GetCompleteObjCClass(
   type_name, must_be_implementation, [&](DWARFDIE type_die) {
-bool try_resolving_type = false;
-
 // Don't try and resolve the DIE we are looking for with the DIE
 // itself!
-if (type_die != die) {
-  switch (type_die.Tag()) {
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-try_resolving_type = true;
-break;
-  default:
-break;
-  }
-}
-if (!try_resolving_type)
+if (type_die == die || !IsTypeTag(type_die.Tag()))
   return true;
 
 if (must_be_implementation &&
-type_die.Supports_DW_AT_APPLE_objc_complete_type())
-  try_resolving_type = type_die.GetAttributeValueAsUnsigned(
+type_die.Supports_DW_AT_APPLE_objc_complete_type()) {
+  bool try_resolving_type = type_die.GetAttributeValueAsUnsigned(

Michael137 wrote:

```suggestion
  bool const try_resolving_type = type_die.GetAttributeValueAsUnsigned(
```

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


[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

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


@@ -3128,36 +3121,11 @@ 
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
   if (type_system &&
   !type_system->SupportsLanguage(GetLanguage(*type_die.GetCU(
 return true;
-  bool try_resolving_type = false;
 
-  // Don't try and resolve the DIE we are looking for with the DIE
-  // itself!
   const dw_tag_t type_tag = type_die.Tag();
-  // Make sure the tags match
-  if (type_tag == tag) {
-// The tags match, lets try resolving this type
-try_resolving_type = true;
-  } else {
-// The tags don't match, but we need to watch our for a forward
-// declaration for a struct and ("struct foo") ends up being a
-// class ("class foo { ... };") or vice versa.
-switch (type_tag) {
-case DW_TAG_class_type:
-  // We had a "class foo", see if we ended up with a "struct foo
-  // { ... };"
-  try_resolving_type = (tag == DW_TAG_structure_type);
-  break;
-case DW_TAG_structure_type:
-  // We had a "struct foo", see if we ended up with a "class foo
-  // { ... };"
-  try_resolving_type = (tag == DW_TAG_class_type);
-  break;
-default:
-  // Tags don't match, don't event try to resolve using this type
-  // whose name matches
-  break;
-}
-  }
+  // Resolve the type if both have the same tag or {class, struct} tags.
+  bool try_resolving_type =

Michael137 wrote:

```suggestion
  bool const try_resolving_type =
```

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


[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

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

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

LGTM

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


[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

2023-12-07 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -2947,29 +2951,18 @@ TypeSP 
SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
 
   m_index->GetCompleteObjCClass(
   type_name, must_be_implementation, [&](DWARFDIE type_die) {
-bool try_resolving_type = false;
-
 // Don't try and resolve the DIE we are looking for with the DIE
 // itself!
-if (type_die != die) {
-  switch (type_die.Tag()) {
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-try_resolving_type = true;
-break;
-  default:
-break;
-  }
-}
-if (!try_resolving_type)
+if (type_die == die || !IsTypeTag(type_die.Tag()))
   return true;
 
 if (must_be_implementation &&
-type_die.Supports_DW_AT_APPLE_objc_complete_type())
-  try_resolving_type = type_die.GetAttributeValueAsUnsigned(
+type_die.Supports_DW_AT_APPLE_objc_complete_type()) {
+  bool try_resolving_type = type_die.GetAttributeValueAsUnsigned(

felipepiovezan wrote:

https://github.com/llvm/llvm-project/assets/5406686/03084d6a-73f7-4017-8581-4230902d7d6b";>


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


[Lldb-commits] [libcxx] [llvm] [lldb] [lld] [clang-tools-extra] [flang] [compiler-rt] [libcxxabi] [clang] [mlir] [libc] [openmp] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread Jakub Mazurkiewicz via lldb-commits


@@ -183,7 +183,7 @@ class take_view<_View>::__sentinel {
   template
 requires sentinel_for, 
iterator_t<__maybe_const<_OtherConst, _View>>>
   _LIBCPP_HIDE_FROM_ABI
-  friend constexpr bool operator==(const _Iter<_Const>& __lhs, const 
__sentinel& __rhs) {
+  friend constexpr bool operator==(const _Iter<_OtherConst>& __lhs, const 
__sentinel& __rhs) {
 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
   }

JMazurkiewicz wrote:

I've tried changing default argument to `_Const` and removing it, and in both 
cases test failed. I think that current coverage is enough.

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


[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

2023-12-07 Thread via lldb-commits

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

>From 64505f573341c16a62eda786c4710d3a7233cecc Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Wed, 6 Dec 2023 17:01:06 -0800
Subject: [PATCH 1/3] We need to generate events when finalizing, or we won't
 know that we succeeded in stopping the process to detach/kill.  Instead, we
 stall and then after our 20 interrupt timeout, we kill the process (even if
 we were supposed to detach) and exit.

OTOH, we have to not generate events when the Process is being destructed
because shared_from_this has already been torn down, and using it will
cause crashes.
---
 lldb/include/lldb/Target/Process.h| 10 +-
 lldb/source/Core/Debugger.cpp |  2 +-
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |  2 +-
 .../Process/elf-core/ProcessElfCore.cpp   |  2 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  2 +-
 .../Process/mach-core/ProcessMachCore.cpp |  2 +-
 .../Process/minidump/ProcessMinidump.cpp  |  2 +-
 .../Process/scripted/ScriptedProcess.cpp  |  2 +-
 lldb/source/Target/Process.cpp| 14 ++--
 lldb/source/Target/ProcessTrace.cpp   |  2 +-
 lldb/source/Target/Target.cpp |  2 +-
 lldb/test/API/driver/quit_speed/Makefile  |  3 ++
 .../driver/quit_speed/TestQuitWithProcess.py  | 34 +++
 lldb/test/API/driver/quit_speed/main.c| 10 ++
 14 files changed, 76 insertions(+), 13 deletions(-)
 create mode 100644 lldb/test/API/driver/quit_speed/Makefile
 create mode 100644 lldb/test/API/driver/quit_speed/TestQuitWithProcess.py
 create mode 100644 lldb/test/API/driver/quit_speed/main.c

diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 4646e3070cf14..889f553f897f5 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -558,7 +558,10 @@ class Process : public 
std::enable_shared_from_this,
   ///
   /// Subclasses that override this method should always call this superclass
   /// method.
-  virtual void Finalize();
+  /// If you are running Finalize in your Process subclass Destructor, pass
+  /// \btrue.  If we are in the destructor, shared_from_this will no longer
+  /// work, so we have to avoid doing anything that might trigger that.
+  virtual void Finalize(bool destructing);
 
   /// Return whether this object is valid (i.e. has not been finalized.)
   ///
@@ -3079,6 +3082,11 @@ void PruneThreadPlans();
   /// This is set at the beginning of Process::Finalize() to stop functions
   /// from looking up or creating things during or after a finalize call.
   std::atomic m_finalizing;
+  // When we are "Finalizing" we need to do some cleanup.  But if the Finalize
+  // call is coming in the Destructor, we can't do any actual work in the
+  // process because that is likely to call "shared_from_this" which crashes
+  // if run while destructing.  We use this flag to determine that.   
+  std::atomic m_destructing;
 
   /// Mask for code an data addresses. The default value (0) means no mask is
   /// set.  The bits set to 1 indicate bits that are NOT significant for
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 21f71e449ca5e..d0b362045e801 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -930,7 +930,7 @@ void Debugger::Clear() {
 for (TargetSP target_sp : m_target_list.Targets()) {
   if (target_sp) {
 if (ProcessSP process_sp = target_sp->GetProcessSP())
-  process_sp->Finalize();
+  process_sp->Finalize(false);
 target_sp->Destroy();
   }
 }
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp 
b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 70bb9aa7a833c..4ab6c8cf1959d 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -164,7 +164,7 @@ ProcessKDP::~ProcessKDP() {
   // make sure all of the broadcaster cleanup goes as planned. If we destruct
   // this class, then Process::~Process() might have problems trying to fully
   // destroy the broadcaster.
-  Finalize();
+  Finalize(true);
 }
 
 Status ProcessKDP::DoWillLaunch(Module *module) {
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index aedc43a015ff1..24d5fdebd4bd5 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -108,7 +108,7 @@ ProcessElfCore::~ProcessElfCore() {
   // make sure all of the broadcaster cleanup goes as planned. If we destruct
   // this class, then Process::~Process() might have problems trying to fully
   // destroy the broadcaster.
-  Finalize();
+  Finalize(true);
 }
 
 lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment(
diff --git a/lldb/source/Plugins/Process/gdb-r

[Lldb-commits] [lldb] 9d3aec5 - Fix a stall in running `quit` while a live process is running (#74687)

2023-12-07 Thread via lldb-commits

Author: jimingham
Date: 2023-12-07T14:36:27-08:00
New Revision: 9d3aec5535adfdeb10a400e92cecc1cc0a5e26a6

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

LOG: Fix a stall in running `quit` while a live  process is running (#74687)

We need to generate events when finalizing, or we won't know that we
succeeded in stopping the process to detach/kill. Instead, we stall and
then after our 20 interrupt timeout, we kill the process (even if we
were supposed to detach) and exit.

OTOH, we have to not generate events when the Process is being
destructed because shared_from_this has already been torn down, and
using it will cause crashes.

Added: 
lldb/test/API/driver/quit_speed/Makefile
lldb/test/API/driver/quit_speed/TestQuitWithProcess.py
lldb/test/API/driver/quit_speed/main.c

Modified: 
lldb/include/lldb/Target/Process.h
lldb/source/Core/Debugger.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/ProcessTrace.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 4646e3070cf14..24c599e044c78 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -558,7 +558,10 @@ class Process : public 
std::enable_shared_from_this,
   ///
   /// Subclasses that override this method should always call this superclass
   /// method.
-  virtual void Finalize();
+  /// If you are running Finalize in your Process subclass Destructor, pass
+  /// \b true.  If we are in the destructor, shared_from_this will no longer
+  /// work, so we have to avoid doing anything that might trigger that.
+  virtual void Finalize(bool destructing);
 
   /// Return whether this object is valid (i.e. has not been finalized.)
   ///
@@ -3079,6 +3082,11 @@ void PruneThreadPlans();
   /// This is set at the beginning of Process::Finalize() to stop functions
   /// from looking up or creating things during or after a finalize call.
   std::atomic m_finalizing;
+  // When we are "Finalizing" we need to do some cleanup.  But if the Finalize
+  // call is coming in the Destructor, we can't do any actual work in the
+  // process because that is likely to call "shared_from_this" which crashes
+  // if run while destructing.  We use this flag to determine that.
+  std::atomic m_destructing;
 
   /// Mask for code an data addresses. The default value (0) means no mask is
   /// set.  The bits set to 1 indicate bits that are NOT significant for

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 21f71e449ca5e..398265dca1cb7 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -930,7 +930,7 @@ void Debugger::Clear() {
 for (TargetSP target_sp : m_target_list.Targets()) {
   if (target_sp) {
 if (ProcessSP process_sp = target_sp->GetProcessSP())
-  process_sp->Finalize();
+  process_sp->Finalize(false /* not destructing */);
 target_sp->Destroy();
   }
 }

diff  --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp 
b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 70bb9aa7a833c..de739acf5b2a5 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -164,7 +164,7 @@ ProcessKDP::~ProcessKDP() {
   // make sure all of the broadcaster cleanup goes as planned. If we destruct
   // this class, then Process::~Process() might have problems trying to fully
   // destroy the broadcaster.
-  Finalize();
+  Finalize(true /* destructing */);
 }
 
 Status ProcessKDP::DoWillLaunch(Module *module) {

diff  --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index aedc43a015ff1..a4540de4acc45 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -108,7 +108,7 @@ ProcessElfCore::~ProcessElfCore() {
   // make sure all of the broadcaster cleanup goes as planned. If we destruct
   // this class, then Process::~Process() might have problems trying to fully
   // destroy the broadcaster.
-  Finalize();
+  Finalize(true /* destructing */);
 }
 
 lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment(

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/so

[Lldb-commits] [lldb] Fix a stall in running `quit` while a live process is running (PR #74687)

2023-12-07 Thread via lldb-commits

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


[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

2023-12-07 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan updated 
https://github.com/llvm/llvm-project/pull/74773

>From 9f38564875620a44a982a50492d87ee431baffcd Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 13:41:44 -0800
Subject: [PATCH 1/2] [SymbolFileDWARF][NFC] Remove duplicated code checking
 for type tags

There was duplicated (and complex) code querying whether tags were type-like
tags (i.e. class or struct); this has been factored out into a helper function.

There was also a comment about not comparing identical DIEs without ever
performing that check; this comment has been removed. It was likely a result of
copy paste from another function in this same file which actually does that
check.
---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 58 +--
 1 file changed, 13 insertions(+), 45 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index d4cc26a3c329b..541d8d75f2187 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -130,6 +130,10 @@ class PluginProperties : public Properties {
   }
 };
 
+bool IsTypeTag(llvm::dwarf::Tag Tag) {
+  return Tag == llvm::dwarf::Tag::DW_TAG_class_type ||
+ Tag == llvm::dwarf::Tag::DW_TAG_structure_type;
+}
 } // namespace
 
 static PluginProperties &GetGlobalPluginProperties() {
@@ -2947,29 +2951,18 @@ TypeSP 
SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
 
   m_index->GetCompleteObjCClass(
   type_name, must_be_implementation, [&](DWARFDIE type_die) {
-bool try_resolving_type = false;
-
 // Don't try and resolve the DIE we are looking for with the DIE
 // itself!
-if (type_die != die) {
-  switch (type_die.Tag()) {
-  case DW_TAG_class_type:
-  case DW_TAG_structure_type:
-try_resolving_type = true;
-break;
-  default:
-break;
-  }
-}
-if (!try_resolving_type)
+if (type_die == die || !IsTypeTag(type_die.Tag()))
   return true;
 
 if (must_be_implementation &&
-type_die.Supports_DW_AT_APPLE_objc_complete_type())
-  try_resolving_type = type_die.GetAttributeValueAsUnsigned(
+type_die.Supports_DW_AT_APPLE_objc_complete_type()) {
+  bool try_resolving_type = type_die.GetAttributeValueAsUnsigned(
   DW_AT_APPLE_objc_complete_type, 0);
-if (!try_resolving_type)
-  return true;
+  if (!try_resolving_type)
+return true;
+}
 
 Type *resolved_type = ResolveType(type_die, false, true);
 if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
@@ -3128,36 +3121,11 @@ 
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
   if (type_system &&
   !type_system->SupportsLanguage(GetLanguage(*type_die.GetCU(
 return true;
-  bool try_resolving_type = false;
 
-  // Don't try and resolve the DIE we are looking for with the DIE
-  // itself!
   const dw_tag_t type_tag = type_die.Tag();
-  // Make sure the tags match
-  if (type_tag == tag) {
-// The tags match, lets try resolving this type
-try_resolving_type = true;
-  } else {
-// The tags don't match, but we need to watch our for a forward
-// declaration for a struct and ("struct foo") ends up being a
-// class ("class foo { ... };") or vice versa.
-switch (type_tag) {
-case DW_TAG_class_type:
-  // We had a "class foo", see if we ended up with a "struct foo
-  // { ... };"
-  try_resolving_type = (tag == DW_TAG_structure_type);
-  break;
-case DW_TAG_structure_type:
-  // We had a "struct foo", see if we ended up with a "class foo
-  // { ... };"
-  try_resolving_type = (tag == DW_TAG_class_type);
-  break;
-default:
-  // Tags don't match, don't event try to resolve using this type
-  // whose name matches
-  break;
-}
-  }
+  // Resolve the type if both have the same tag or {class, struct} tags.
+  bool try_resolving_type =
+  type_tag == tag || (IsTypeTag(type_tag) && IsTypeTag(tag));
 
   if (!try_resolving_type) {
 if (log) {

>From 0225efc828696fe2dabae519a09f5a7299ef2aed Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 14:39:24 -0800
Subject: [PATCH 2/2] fixup! [SymbolFileDWARF][NFC] Remove duplicated code
 checking for type tags

---
 lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 541d8d75f2187..a94bb93fc2f7f 100644
--- a/lldb/so

[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

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

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

This looks good to me.  Do you think we take the frame variable test in 
API/functionalities/location-list-lookup/TestLocationListLookup.py and add it 
to your test?  They're testing the same thing, and getting there the same way 
so I'm not sure there's value to having the two separate tests for the frame 
variable codepath and the expr codepath.

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


[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

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

Michael137 wrote:

> This looks good to me. Do you think we take the frame variable test in 
> API/functionalities/location-list-lookup/TestLocationListLookup.py and add it 
> to your test? They're testing the same thing, and getting there the same way 
> so I'm not sure there's value to having the two separate tests for the frame 
> variable codepath and the expr codepath.

Yup makes sense!

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


[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

2023-12-07 Thread Alex Langford via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

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

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

>From 2352f67789c04f86c8a0f7ad8940d782288750b8 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 7 Dec 2023 21:35:41 +
Subject: [PATCH 1/2] [lldb][Symbol] Make sure we decrement PC before checking
 location list

In optimized code we can end up with return address being the
next instruction in a different block. If we are dealing with
location lists, we want to decrement the PC value so it's within
the calling block range that we're checking against the loclists.

This was fixed in https://reviews.llvm.org/D124597
(`6e56c4961a106b8fde69ffcf9f803fe0890722fa`), by introducing
a `GetFrameCodeAddressForSymbolication`. This fixed `frame variable`,
but `expr` calls into `Variable::LocationIsValidForFrame`, where this
new API wasn't used yet.

So in the associated test-case, running `frame var this` works, but
`expr this` doesn't. With `dwim-print` this makes the situation more
surprising for the user because `p this`, `v this` and `v *this` work,
but `p *this` doesn't because it falls back onto `expr` (due to the
dereference).

This patch makes sure we lookup loclists using
the correct PC by using this new `GetFrameCodeAddressForSymbolication` API.
---
 lldb/source/Symbol/Variable.cpp   |  3 +-
 .../location-list-lookup-cpp-member/Makefile  |  3 ++
 .../TestCppMemberLocationListLookup.py| 29 +++
 .../location-list-lookup-cpp-member/main.cpp  | 23 +++
 4 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 85ceadd20c611e..db740cb7cb6e41 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -227,7 +227,8 @@ bool Variable::LocationIsValidForFrame(StackFrame *frame) {
   // contains the current address when converted to a load address
   return m_location_list.ContainsAddress(
   loclist_base_load_addr,
-  frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
+  frame->GetFrameCodeAddressForSymbolication().GetLoadAddress(
+  target_sp.get()));
 }
   }
   return false;
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
new file mode 100644
index 00..8e453681d7b390
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS := -O1
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
new file mode 100644
index 00..846386ceffc6ac
--- /dev/null
+++ 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
@@ -0,0 +1,29 @@
+"""Test that lldb picks the correct DWARF location list entry with a 
return-pc out of bounds."""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CppMemberLocationListLookupTestCase(TestBase):
+def test(self):
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+self.dbg.SetAsync(False)
+
+li = lldb.SBLaunchInfo(["a.out"])
+error = lldb.SBError()
+process = target.Launch(li, error)
+self.assertTrue(process.IsValid())
+self.assertTrue(process.is_stopped)
+
+# Find `bar` on the stack, then
+# find `this` local variable, then
+# check that we can read out the pointer value
+for f in process.GetSelectedThread().frames:
+if f.GetDisplayFunctionName().startswith("Foo::bar"):
+process.GetSelectedThread().SetSelectedFrame(f.idx)
+self.expect_expr("this", result_type="Foo *")
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp
new file mode 100644
index 00..96817f141b82cb
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp
@@ -0,0 +1,23 @@
+#include 
+#include 
+
+void func(int in);
+
+struct Foo {
+  int x;
+  [[clang::noinline]] void bar(Foo *f);
+};
+
+int main(int argc, char **argv) {
+  Foo f{.x = 5};
+  std::printf("%p\n", &f.x);
+  f.bar(&f);
+  return f.x;
+}
+
+void Foo::bar(Foo *f) {
+  std::printf("%p %p\n", f, this)

[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

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

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

>From 2352f67789c04f86c8a0f7ad8940d782288750b8 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 7 Dec 2023 21:35:41 +
Subject: [PATCH 1/3] [lldb][Symbol] Make sure we decrement PC before checking
 location list

In optimized code we can end up with return address being the
next instruction in a different block. If we are dealing with
location lists, we want to decrement the PC value so it's within
the calling block range that we're checking against the loclists.

This was fixed in https://reviews.llvm.org/D124597
(`6e56c4961a106b8fde69ffcf9f803fe0890722fa`), by introducing
a `GetFrameCodeAddressForSymbolication`. This fixed `frame variable`,
but `expr` calls into `Variable::LocationIsValidForFrame`, where this
new API wasn't used yet.

So in the associated test-case, running `frame var this` works, but
`expr this` doesn't. With `dwim-print` this makes the situation more
surprising for the user because `p this`, `v this` and `v *this` work,
but `p *this` doesn't because it falls back onto `expr` (due to the
dereference).

This patch makes sure we lookup loclists using
the correct PC by using this new `GetFrameCodeAddressForSymbolication` API.
---
 lldb/source/Symbol/Variable.cpp   |  3 +-
 .../location-list-lookup-cpp-member/Makefile  |  3 ++
 .../TestCppMemberLocationListLookup.py| 29 +++
 .../location-list-lookup-cpp-member/main.cpp  | 23 +++
 4 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 85ceadd20c611..db740cb7cb6e4 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -227,7 +227,8 @@ bool Variable::LocationIsValidForFrame(StackFrame *frame) {
   // contains the current address when converted to a load address
   return m_location_list.ContainsAddress(
   loclist_base_load_addr,
-  frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
+  frame->GetFrameCodeAddressForSymbolication().GetLoadAddress(
+  target_sp.get()));
 }
   }
   return false;
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
new file mode 100644
index 0..8e453681d7b39
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS := -O1
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
new file mode 100644
index 0..846386ceffc6a
--- /dev/null
+++ 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
@@ -0,0 +1,29 @@
+"""Test that lldb picks the correct DWARF location list entry with a 
return-pc out of bounds."""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CppMemberLocationListLookupTestCase(TestBase):
+def test(self):
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+self.dbg.SetAsync(False)
+
+li = lldb.SBLaunchInfo(["a.out"])
+error = lldb.SBError()
+process = target.Launch(li, error)
+self.assertTrue(process.IsValid())
+self.assertTrue(process.is_stopped)
+
+# Find `bar` on the stack, then
+# find `this` local variable, then
+# check that we can read out the pointer value
+for f in process.GetSelectedThread().frames:
+if f.GetDisplayFunctionName().startswith("Foo::bar"):
+process.GetSelectedThread().SetSelectedFrame(f.idx)
+self.expect_expr("this", result_type="Foo *")
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp
new file mode 100644
index 0..96817f141b82c
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp
@@ -0,0 +1,23 @@
+#include 
+#include 
+
+void func(int in);
+
+struct Foo {
+  int x;
+  [[clang::noinline]] void bar(Foo *f);
+};
+
+int main(int argc, char **argv) {
+  Foo f{.x = 5};
+  std::printf("%p\n", &f.x);
+  f.bar(&f);
+  return f.x;
+}
+
+void Foo::bar(Foo *f) {
+  std::printf("%p %p\n", f, this);
+  std

[Lldb-commits] [lldb] [lldb][Symbol] Make sure we decrement PC before checking location list (PR #74772)

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

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

>From 2352f67789c04f86c8a0f7ad8940d782288750b8 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 7 Dec 2023 21:35:41 +
Subject: [PATCH 1/4] [lldb][Symbol] Make sure we decrement PC before checking
 location list

In optimized code we can end up with return address being the
next instruction in a different block. If we are dealing with
location lists, we want to decrement the PC value so it's within
the calling block range that we're checking against the loclists.

This was fixed in https://reviews.llvm.org/D124597
(`6e56c4961a106b8fde69ffcf9f803fe0890722fa`), by introducing
a `GetFrameCodeAddressForSymbolication`. This fixed `frame variable`,
but `expr` calls into `Variable::LocationIsValidForFrame`, where this
new API wasn't used yet.

So in the associated test-case, running `frame var this` works, but
`expr this` doesn't. With `dwim-print` this makes the situation more
surprising for the user because `p this`, `v this` and `v *this` work,
but `p *this` doesn't because it falls back onto `expr` (due to the
dereference).

This patch makes sure we lookup loclists using
the correct PC by using this new `GetFrameCodeAddressForSymbolication` API.
---
 lldb/source/Symbol/Variable.cpp   |  3 +-
 .../location-list-lookup-cpp-member/Makefile  |  3 ++
 .../TestCppMemberLocationListLookup.py| 29 +++
 .../location-list-lookup-cpp-member/main.cpp  | 23 +++
 4 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 create mode 100644 
lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 85ceadd20c611e..db740cb7cb6e41 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -227,7 +227,8 @@ bool Variable::LocationIsValidForFrame(StackFrame *frame) {
   // contains the current address when converted to a load address
   return m_location_list.ContainsAddress(
   loclist_base_load_addr,
-  frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
+  frame->GetFrameCodeAddressForSymbolication().GetLoadAddress(
+  target_sp.get()));
 }
   }
   return false;
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
new file mode 100644
index 00..8e453681d7b390
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS := -O1
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
new file mode 100644
index 00..846386ceffc6ac
--- /dev/null
+++ 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/TestCppMemberLocationListLookup.py
@@ -0,0 +1,29 @@
+"""Test that lldb picks the correct DWARF location list entry with a 
return-pc out of bounds."""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CppMemberLocationListLookupTestCase(TestBase):
+def test(self):
+self.build()
+
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+self.dbg.SetAsync(False)
+
+li = lldb.SBLaunchInfo(["a.out"])
+error = lldb.SBError()
+process = target.Launch(li, error)
+self.assertTrue(process.IsValid())
+self.assertTrue(process.is_stopped)
+
+# Find `bar` on the stack, then
+# find `this` local variable, then
+# check that we can read out the pointer value
+for f in process.GetSelectedThread().frames:
+if f.GetDisplayFunctionName().startswith("Foo::bar"):
+process.GetSelectedThread().SetSelectedFrame(f.idx)
+self.expect_expr("this", result_type="Foo *")
diff --git 
a/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp 
b/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp
new file mode 100644
index 00..96817f141b82cb
--- /dev/null
+++ b/lldb/test/API/functionalities/location-list-lookup-cpp-member/main.cpp
@@ -0,0 +1,23 @@
+#include 
+#include 
+
+void func(int in);
+
+struct Foo {
+  int x;
+  [[clang::noinline]] void bar(Foo *f);
+};
+
+int main(int argc, char **argv) {
+  Foo f{.x = 5};
+  std::printf("%p\n", &f.x);
+  f.bar(&f);
+  return f.x;
+}
+
+void Foo::bar(Foo *f) {
+  std::printf("%p %p\n", f, this)

[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

2023-12-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Greg Clayton (clayborg)


Changes

This patch revives the effort to get this Phabricator patch into upstream:

https://reviews.llvm.org/D137900

This patch was accepted before in Phabricator but I found some 
-gsimple-template-names issues that are fixed in this patch.

A fixed up version of the description from the original patch starts now.

This patch started off trying to fix Module::FindFirstType() as it sometimes 
didn't work. The issue was the SymbolFile plug-ins didn't do any filtering of 
the matching types they produced, and they only looked up types using the type 
basename. This means if you have two types with the same basename, your type 
lookup can fail when only looking up a single type. We would ask the 
Module::FindFirstType to lookup "Foo::Bar" and it would ask the symbol file to 
find only 1 type matching the basename "Bar", and then we would filter out any 
matches that didn't match "Foo::Bar". So if the SymbolFile found "Foo::Bar" 
first, then it would work, but if it found "Baz::Bar" first, it would return 
only that type and it would be filtered out.

Discovering this issue lead me to think of the patch Alex Langford did a few 
months ago that was done for finding functions, where he allowed SymbolFile 
objects to make sure something fully matched before parsing the debug 
information into an AST type and other LLDB types. So this patch aimed to allow 
type lookups to also be much more efficient.

As LLDB has been developed over the years, we added more ways to to type 
lookups. These functions have lots of arguments. This patch aims to make one 
API that needs to be implemented that serves all previous lookups:

- Find a single type
- Find all types
- Find types in a namespace

This patch introduces a `TypeQuery` class that contains all of the state needed 
to perform the lookup which is powerful enough to perform all of the type 
searches that used to be in our API. It contain a vector of CompilerContext 
objects that can fully or partially specify the lookup that needs to take place.

If you just want to lookup all types with a matching basename, regardless of 
the containing context, you can specify just a single CompilerContext entry 
that has a name and a CompilerContextKind mask of CompilerContextKind::AnyType.

Or you can fully specify the exact context to use when doing lookups like: 
CompilerContextKind::Namespace "std"
CompilerContextKind::Class "foo"
CompilerContextKind::Typedef "size_type"

This change expands on the clang modules code that already used a 
vector items, but it modifies it to work with expression 
type lookups which have contexts, or user lookups where users query for types. 
The clang modules type lookup is still an option that can be enabled on the 
`TypeQuery` objects.

This mirrors the most recent addition of type lookups that took a 
vector that allowed lookups to happen for the expression 
parser in certain places.

Prior to this we had the following APIs in Module:

```
void
Module::FindTypes(ConstString type_name, bool exact_match, size_t max_matches,
  llvm::DenseSet 
&searched_symbol_files,
  TypeList &types);

void
Module::FindTypes(llvm::ArrayRef pattern, LanguageSet 
languages,
  llvm::DenseSet 
&searched_symbol_files,
  TypeMap &types);

void Module::FindTypesInNamespace(ConstString type_name,
  const CompilerDeclContext 
&parent_decl_ctx,
  size_t max_matches, TypeList &type_list);
```

The new Module API is much simpler. It gets rid of all three above functions 
and replaces them with:

```
void FindTypes(const TypeQuery &query, TypeResults &results);
```
The `TypeQuery` class contains all of the needed settings:

- The vector that allow efficient lookups in the symbol 
file classes since they can look at basename matches only realize fully 
matching types. Before this any basename that matched was fully realized only 
to be removed later by code outside of the SymbolFile layer which could cause 
many types to be realized when they didn't need to.
- If the lookup is exact or not. If not exact, then the compiler context must 
match the bottom most items that match the compiler context, otherwise it must 
match exactly
- If the compiler context match is for clang modules or not. Clang modules 
matches include a Module compiler context kind that allows types to be matched 
only from certain modules and these matches are not needed when d oing user 
type lookups.
- An optional list of languages to use to limit the search to only certain 
languages

The `TypeResults` object contains all state required to do the lookup and store 
the results:
- The max number of matches
- The set of SymbolFile objects that have already been searched
- The matc

[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

2023-12-07 Thread Greg Clayton via lldb-commits

clayborg wrote:

@adrian-prantl This patch is exactly the same as it was back when you accepted 
it in Phabricator with two things added:
- fixes for -gsimple-template-names
- updated the new `SBType::FindDirectNestedType(...)`

All tests pass on macOS.

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


[Lldb-commits] [lldb] Make only one function that needs to be implemented when searching for types (PR #74786)

2023-12-07 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
42bba97fc24f045f593fc26f998bac9b08633255...5adebf6f6068ef1eb8e5a4dbb02a52d8c21b1b3c
 lldb/test/API/functionalities/type_find_first/TestFindFirstType.py 
lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
``





View the diff from darker here.


``diff
--- functionalities/type_find_first/TestFindFirstType.py2023-12-07 
23:25:59.00 +
+++ functionalities/type_find_first/TestFindFirstType.py2023-12-07 
23:42:34.347989 +
@@ -6,22 +6,21 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
 
 class TypeFindFirstTestCase(TestBase):
-
 NO_DEBUG_INFO_TESTCASE = True
 
 def test_find_first_type(self):
 """
-Test SBTarget::FindFirstType() and SBModule::FindFirstType() APIs.
+Test SBTarget::FindFirstType() and SBModule::FindFirstType() APIs.
 
-This function had regressed after some past modification of the 
type
-lookup internal code where if we had multiple types with the same
-basename, FindFirstType() could end up failing depending on which
-type was found first in the debug info indexes. This test will
-ensure this doesn't regress in the future.
+This function had regressed after some past modification of the type
+lookup internal code where if we had multiple types with the same
+basename, FindFirstType() could end up failing depending on which
+type was found first in the debug info indexes. This test will
+ensure this doesn't regress in the future.
 """
 self.build()
 target = self.createTestTarget()
 # Test the SBTarget APIs for FindFirstType
 integer_type = target.FindFirstType("Integer::Point")
--- lang/cpp/unique-types4/TestUniqueTypes4.py  2023-12-07 23:25:59.00 +
+++ lang/cpp/unique-types4/TestUniqueTypes4.py  2023-12-07 23:42:34.377368 +
@@ -17,28 +17,31 @@
 lldbutil.run_to_source_breakpoint(
 self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp")
 )
 # FIXME: these should successfully print the values
 self.expect(
-"print ns::Foo::value", substrs=["no template named 'Foo' 
in namespace 'ns'"], error=True
+"print ns::Foo::value",
+substrs=["no template named 'Foo' in namespace 'ns'"],
+error=True,
 )
 self.expect(
-"print ns::Foo::value", substrs=["no template named 'Foo' in 
namespace 'ns'"], error=True
+"print ns::Foo::value",
+substrs=["no template named 'Foo' in namespace 'ns'"],
+error=True,
 )
 self.expect(
-"print ns::Bar::value", substrs=["no template named 'Bar' 
in namespace 'ns'"], error=True
+"print ns::Bar::value",
+substrs=["no template named 'Bar' in namespace 'ns'"],
+error=True,
 )
 self.expect(
-"print ns::Bar::value", substrs=["no template named 'Bar' in 
namespace 'ns'"], error=True
+"print ns::Bar::value",
+substrs=["no template named 'Bar' in namespace 'ns'"],
+error=True,
 )
-self.expect(
-"print ns::FooDouble::value", substrs=["(double) 0"]
-)
-self.expect(
-"print ns::FooInt::value", substrs=["(int) 0"]
-)
-
+self.expect("print ns::FooDouble::value", substrs=["(double) 0"])
+self.expect("print ns::FooInt::value", substrs=["(int) 0"])
 
 @skipIf(compiler=no_match("clang"))
 @skipIf(compiler_version=["<", "15.0"])
 def test_simple_template_names(self):
 self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names"))

``




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


[Lldb-commits] [lldb] [lldb][NFC] Simplify DWARRFDeclContext::GetQualifiedName (PR #74788)

2023-12-07 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan created 
https://github.com/llvm/llvm-project/pull/74788

This commit factors out the logic building each component of a qualified name 
into its own function so that it may be reused by a future commit, while also 
simplifying the logic of assembling these pieces together by using 
llvm::interleave.

>From 89c88d156170e5c8287d8a8236cfaf3e1ec2d1cf Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 15:45:05 -0800
Subject: [PATCH] [lldb][NFC] Simplify DWARRFDeclContext::GetQualifiedName

This commit factors out the logic building each component of a qualified name
into its own function so that it may be reused by a future commit, while also
simplifying the logic of assembling these pieces together by using
llvm::interleave.
---
 .../SymbolFile/DWARF/DWARFDeclContext.cpp | 40 +--
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
index 44e7602279013..eda2ff3e73d47 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
@@ -7,10 +7,28 @@
 
//===--===//
 
 #include "DWARFDeclContext.h"
+#include "llvm/Support/raw_ostream.h"
+
 
 using namespace lldb_private::dwarf;
 using namespace lldb_private::plugin::dwarf;
 
+/// Returns the name of `entry` if it has one, or the appropriate "anonymous
+/// {namespace, class, struct, union}".
+static const char *GetName(const DWARFDeclContext::Entry &entry) {
+  if (entry.name != nullptr)
+return entry.name;
+  if (entry.tag == DW_TAG_namespace)
+return "(anonymous namespace)";
+  if (entry.tag == DW_TAG_class_type)
+return "(anonymous class)";
+  if (entry.tag == DW_TAG_structure_type)
+return "(anonymous struct)";
+  if (entry.tag == DW_TAG_union_type)
+return "(anonymous union)";
+  return "(anonymous)";
+}
+
 const char *DWARFDeclContext::GetQualifiedName() const {
   if (m_qualified_name.empty()) {
 // The declaration context array for a class named "foo" in namespace
@@ -26,26 +44,8 @@ const char *DWARFDeclContext::GetQualifiedName() const {
   m_qualified_name.append(m_entries[0].name);
 }
   } else {
-collection::const_reverse_iterator pos;
-collection::const_reverse_iterator begin = m_entries.rbegin();
-collection::const_reverse_iterator end = m_entries.rend();
-for (pos = begin; pos != end; ++pos) {
-  if (pos != begin)
-m_qualified_name.append("::");
-  if (pos->name == nullptr) {
-if (pos->tag == DW_TAG_namespace)
-  m_qualified_name.append("(anonymous namespace)");
-else if (pos->tag == DW_TAG_class_type)
-  m_qualified_name.append("(anonymous class)");
-else if (pos->tag == DW_TAG_structure_type)
-  m_qualified_name.append("(anonymous struct)");
-else if (pos->tag == DW_TAG_union_type)
-  m_qualified_name.append("(anonymous union)");
-else
-  m_qualified_name.append("(anonymous)");
-  } else
-m_qualified_name.append(pos->name);
-}
+llvm::raw_string_ostream string_stream(m_qualified_name);
+llvm::interleave(llvm::reverse(m_entries), string_stream, GetName, 
"::");
   }
 }
   }

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


[Lldb-commits] [lldb] [lldb][NFC] Simplify DWARRFDeclContext::GetQualifiedName (PR #74788)

2023-12-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

This commit factors out the logic building each component of a qualified name 
into its own function so that it may be reused by a future commit, while also 
simplifying the logic of assembling these pieces together by using 
llvm::interleave.

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


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp (+20-20) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
index 44e76022790130..eda2ff3e73d47c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
@@ -7,10 +7,28 @@
 
//===--===//
 
 #include "DWARFDeclContext.h"
+#include "llvm/Support/raw_ostream.h"
+
 
 using namespace lldb_private::dwarf;
 using namespace lldb_private::plugin::dwarf;
 
+/// Returns the name of `entry` if it has one, or the appropriate "anonymous
+/// {namespace, class, struct, union}".
+static const char *GetName(const DWARFDeclContext::Entry &entry) {
+  if (entry.name != nullptr)
+return entry.name;
+  if (entry.tag == DW_TAG_namespace)
+return "(anonymous namespace)";
+  if (entry.tag == DW_TAG_class_type)
+return "(anonymous class)";
+  if (entry.tag == DW_TAG_structure_type)
+return "(anonymous struct)";
+  if (entry.tag == DW_TAG_union_type)
+return "(anonymous union)";
+  return "(anonymous)";
+}
+
 const char *DWARFDeclContext::GetQualifiedName() const {
   if (m_qualified_name.empty()) {
 // The declaration context array for a class named "foo" in namespace
@@ -26,26 +44,8 @@ const char *DWARFDeclContext::GetQualifiedName() const {
   m_qualified_name.append(m_entries[0].name);
 }
   } else {
-collection::const_reverse_iterator pos;
-collection::const_reverse_iterator begin = m_entries.rbegin();
-collection::const_reverse_iterator end = m_entries.rend();
-for (pos = begin; pos != end; ++pos) {
-  if (pos != begin)
-m_qualified_name.append("::");
-  if (pos->name == nullptr) {
-if (pos->tag == DW_TAG_namespace)
-  m_qualified_name.append("(anonymous namespace)");
-else if (pos->tag == DW_TAG_class_type)
-  m_qualified_name.append("(anonymous class)");
-else if (pos->tag == DW_TAG_structure_type)
-  m_qualified_name.append("(anonymous struct)");
-else if (pos->tag == DW_TAG_union_type)
-  m_qualified_name.append("(anonymous union)");
-else
-  m_qualified_name.append("(anonymous)");
-  } else
-m_qualified_name.append(pos->name);
-}
+llvm::raw_string_ostream string_stream(m_qualified_name);
+llvm::interleave(llvm::reverse(m_entries), string_stream, GetName, 
"::");
   }
 }
   }

``




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


[Lldb-commits] [lldb] [lldb][NFC] Simplify DWARRFDeclContext::GetQualifiedName (PR #74788)

2023-12-07 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 7003e255d3f1fbff3b2ef3052d478b65ec555963 
89c88d156170e5c8287d8a8236cfaf3e1ec2d1cf -- 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
index eda2ff3e73..a2d6eb70d3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
@@ -9,7 +9,6 @@
 #include "DWARFDeclContext.h"
 #include "llvm/Support/raw_ostream.h"
 
-
 using namespace lldb_private::dwarf;
 using namespace lldb_private::plugin::dwarf;
 
@@ -45,7 +44,8 @@ const char *DWARFDeclContext::GetQualifiedName() const {
 }
   } else {
 llvm::raw_string_ostream string_stream(m_qualified_name);
-llvm::interleave(llvm::reverse(m_entries), string_stream, GetName, 
"::");
+llvm::interleave(llvm::reverse(m_entries), string_stream, GetName,
+ "::");
   }
 }
   }

``




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


[Lldb-commits] [flang] [openmp] [compiler-rt] [libc] [lld] [lldb] [clang-tools-extra] [libcxx] [clang] [mlir] [llvm] [libcxxabi] [libc++] Fix `take_view::__sentinel`'s `operator==` (PR #74655)

2023-12-07 Thread Jakub Mazurkiewicz via lldb-commits

https://github.com/JMazurkiewicz updated 
https://github.com/llvm/llvm-project/pull/74655

>From b3de573887cdd86fd6ce168bdcc6d729d73b13b2 Mon Sep 17 00:00:00 2001
From: Jakub Mazurkiewicz 
Date: Wed, 6 Dec 2023 14:03:51 +0100
Subject: [PATCH 01/11] [libc++] Fix `take_view::__sentinel`'s `operator==`

---
 libcxx/include/__ranges/take_view.h   |   2 +-
 .../base.pass.cpp |   5 +-
 .../ctor.pass.cpp |   0
 .../range.take.sentinel/eq.pass.cpp   | 192 ++
 .../range.take/sentinel/eq.pass.cpp   |  55 -
 5 files changed, 194 insertions(+), 60 deletions(-)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/base.pass.cpp (83%)
 rename libcxx/test/std/ranges/range.adaptors/range.take/{sentinel => 
range.take.sentinel}/ctor.pass.cpp (100%)
 create mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 delete mode 100644 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/eq.pass.cpp

diff --git a/libcxx/include/__ranges/take_view.h 
b/libcxx/include/__ranges/take_view.h
index 4204017d9249b..811428e529f59 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -183,7 +183,7 @@ class take_view<_View>::__sentinel {
   template
 requires sentinel_for, 
iterator_t<__maybe_const<_OtherConst, _View>>>
   _LIBCPP_HIDE_FROM_ABI
-  friend constexpr bool operator==(const _Iter<_Const>& __lhs, const 
__sentinel& __rhs) {
+  friend constexpr bool operator==(const _Iter<_OtherConst>& __lhs, const 
__sentinel& __rhs) {
 return __lhs.count() == 0 || __lhs.base() == __rhs.__end_;
   }
 };
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
similarity index 83%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
index c949eb7cc0846..15b2b5476e86d 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/base.pass.cpp
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp
@@ -8,10 +8,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-// sentinel() = default;
-// constexpr explicit sentinel(sentinel_t end);
-// constexpr sentinel(sentinel s)
-//   requires Const && convertible_to, sentinel_t>;
+// constexpr sentinel_t base() const;
 
 #include 
 #include 
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
similarity index 100%
rename from 
libcxx/test/std/ranges/range.adaptors/range.take/sentinel/ctor.pass.cpp
rename to 
libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/ctor.pass.cpp
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
new file mode 100644
index 0..f20c29b4c6471
--- /dev/null
+++ 
b/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/eq.pass.cpp
@@ -0,0 +1,192 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// friend constexpr bool operator==(const CI& y, const sentinel& x);
+// template
+//   requires sentinel_for, 
iterator_t>>
+// friend constexpr bool operator==(const CI& y, const sentinel& 
x);
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+template 
+class StrictIterator {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  using value_type  = int;
+  using difference_type = std::ptrdiff_t;
+
+  constexpr explicit StrictIterator(Base base) : base_(base) {}
+
+  StrictIterator(StrictIterator&&)= default;
+  StrictIterator& operator=(StrictIterator&&) = default;
+
+  constexpr StrictIterator& operator++() {
+++base_;
+return *this;
+  }
+
+  constexpr void operator++(int) { ++*this; }
+  constexpr decltype(auto) operator*() const { return *base_; }
+  constexpr Base base() const { return base_; }
+};
+
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+static_assert(std::input_iterator>);
+static_assert(!std::copyable>);
+static_assert(!std::forward_iterator>);
+
+template 
+class StrictSentinel {
+  using Base = std::conditional_t;
+  Base base_;
+
+public:
+  StrictSentinel() = default;

  1   2   >