[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Clarify comment around static member variable handling (PR #72495)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/72495 None >From cf66beffe36e53fed5740775fa50b767a62f2c50 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 16 Nov 2023 08:46:37 + Subject: [PATCH] [lldb][DWARFASTParserClang][NFC] Clarify comment around static member variable handling --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 37efe70461977ad..abe3c673e2cce69 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2963,9 +2963,9 @@ void DWARFASTParserClang::ParseSingleMember( // whereas GCC emits it only for static data members if not part of an // anonymous namespace. The flag that is consistently emitted for static // data members is DW_AT_declaration, so we check it instead. - // FIXME: Since DWARFv5, static data members are marked DW_AT_variable so we + // The following block is only necessary to support DWARFv4 and earlier. + // Starting with DWARFv5, static data members are marked DW_AT_variable so we // can consistently detect them on both GCC and Clang without below heuristic. - // Remove this block if we ever drop DWARFv4 support. if (attrs.member_byte_offset == UINT32_MAX && attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) { CreateStaticMemberVariable(die, attrs, class_clang_type); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Clarify comment around static member variable handling (PR #72495)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/72495.diff 1 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+2-2) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 37efe70461977ad..abe3c673e2cce69 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2963,9 +2963,9 @@ void DWARFASTParserClang::ParseSingleMember( // whereas GCC emits it only for static data members if not part of an // anonymous namespace. The flag that is consistently emitted for static // data members is DW_AT_declaration, so we check it instead. - // FIXME: Since DWARFv5, static data members are marked DW_AT_variable so we + // The following block is only necessary to support DWARFv4 and earlier. + // Starting with DWARFv5, static data members are marked DW_AT_variable so we // can consistently detect them on both GCC and Clang without below heuristic. - // Remove this block if we ever drop DWARFv4 support. if (attrs.member_byte_offset == UINT32_MAX && attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) { CreateStaticMemberVariable(die, attrs, class_clang_type); `` https://github.com/llvm/llvm-project/pull/72495 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (PR #72236)
@@ -2965,6 +2965,7 @@ void DWARFASTParserClang::ParseSingleMember( // data members is DW_AT_declaration, so we check it instead. // FIXME: Since DWARFv5, static data members are marked DW_AT_variable so we // can consistently detect them on both GCC and Clang without below heuristic. + // Remove this block if we ever drop DWARFv4 support. Michael137 wrote: Clarified here: https://github.com/llvm/llvm-project/pull/72495 https://github.com/llvm/llvm-project/pull/72236 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libunwind] [lld] [lldb] [clang] [clang-tools-extra] [compiler-rt] [llvm] [flang] [libcxx] [AMDGPU] - Add constant folding for s_quadmask (PR #72381)
https://github.com/OutOfCache updated https://github.com/llvm/llvm-project/pull/72381 >From 00d0f99207242befc8022031ccd8faf573cbf014 Mon Sep 17 00:00:00 2001 From: Jessica Del Date: Tue, 14 Nov 2023 22:17:26 +0100 Subject: [PATCH 1/2] [AMDGPU] - Add constant folding for s_quadmask If the input is a constant we can constant fold the `s_quadmask` intrinsic. --- llvm/lib/Analysis/ConstantFolding.cpp| 14 ++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll | 12 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 966a65ac26b8017..40b5938fcda0c2a 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1533,6 +1533,7 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) { case Intrinsic::amdgcn_perm: case Intrinsic::amdgcn_wave_reduce_umin: case Intrinsic::amdgcn_wave_reduce_umax: + case Intrinsic::amdgcn_s_quadmask: case Intrinsic::arm_mve_vctp8: case Intrinsic::arm_mve_vctp16: case Intrinsic::arm_mve_vctp32: @@ -2422,6 +2423,19 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, return ConstantFP::get(Ty->getContext(), Val); } + +case Intrinsic::amdgcn_s_quadmask: { + uint64_t Val = Op->getZExtValue(); + uint64_t QuadMask = 0; + for (unsigned i = 0; i < Op->getBitWidth() / 4; ++i, Val >>= 4) { +if (!(Val & 0xF)) + continue; + +QuadMask |= (1 << i); + } + return ConstantInt::get(Ty, QuadMask); +} + default: return nullptr; } diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll index 65443a6efa789d9..0f500c0999ad9a8 100644 --- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll +++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll @@ -9,11 +9,10 @@ define i32 @test_quadmask_constant_i32() { ; GFX11-LABEL: test_quadmask_constant_i32: ; GFX11: ; %bb.0: ; %entry ; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) -; GFX11-NEXT:s_quadmask_b32 s0, 0x85fe3a92 -; GFX11-NEXT:v_mov_b32_e32 v0, s0 +; GFX11-NEXT:v_mov_b32_e32 v0, 0xcb ; GFX11-NEXT:s_setpc_b64 s[30:31] entry: - %qm = call i32 @llvm.amdgcn.s.quadmask.i32(i32 u0x85FE3A92) + %qm = call i32 @llvm.amdgcn.s.quadmask.i32(i32 u0x85003092) ret i32 %qm } @@ -50,13 +49,10 @@ define i64 @test_quadmask_constant_i64() { ; GFX11-LABEL: test_quadmask_constant_i64: ; GFX11: ; %bb.0: ; %entry ; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) -; GFX11-NEXT:s_mov_b32 s0, 0x85fe3a92 -; GFX11-NEXT:s_mov_b32 s1, 0x67de48fc -; GFX11-NEXT:s_quadmask_b64 s[0:1], s[0:1] -; GFX11-NEXT:v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1 +; GFX11-NEXT:v_dual_mov_b32 v0, 0xe3e6 :: v_dual_mov_b32 v1, 0 ; GFX11-NEXT:s_setpc_b64 s[30:31] entry: - %qm = call i64 @llvm.amdgcn.s.quadmask.i64(i64 u0x67DE48FC85FE3A92) + %qm = call i64 @llvm.amdgcn.s.quadmask.i64(i64 u0x67D000FC85F00A90) ret i64 %qm } >From 144c4dc164ec137e518cfd647c116373e7a61b8f Mon Sep 17 00:00:00 2001 From: Jessica Del Date: Wed, 15 Nov 2023 15:59:56 +0100 Subject: [PATCH 2/2] fixup! [AMDGPU] - Add constant folding for s_quadmask --- llvm/lib/Analysis/ConstantFolding.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 40b5938fcda0c2a..39bbb04fbcf26cc 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -2427,11 +2427,11 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, case Intrinsic::amdgcn_s_quadmask: { uint64_t Val = Op->getZExtValue(); uint64_t QuadMask = 0; - for (unsigned i = 0; i < Op->getBitWidth() / 4; ++i, Val >>= 4) { + for (unsigned I = 0; I < Op->getBitWidth() / 4; ++I, Val >>= 4) { if (!(Val & 0xF)) continue; -QuadMask |= (1 << i); +QuadMask |= (1 << I); } return ConstantInt::get(Ty, QuadMask); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)
DavidSpickett wrote: I would be interested in at least having a way to opt into this style, it would be useful for registers for example here where I am experimenting with defining `TCF` as an enum: ``` (lldb) register read mte_ctrl mte_ctrl = 0x0007fffb = (TAGS = 65535, TCF = TCF_SYNC(1), TAGGED_ADDR_ENABLE = 1) ``` Having the numerical value is really useful and saves a trip to the manual (or in this case, kernel sources). For this use case I'm setting options in `lldb_private::DumpValueObjectOptions` down in C++ but I'm not sure if those directly map to what a formatter would have access to. Assuming they do somehow have the same control, would it be viable to add an option that a formatter could pass when it knows it wants the name plus the value? Instead of changing the global behaviour. @Endilll would that work for the types you're working with? https://github.com/llvm/llvm-project/pull/69815 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lld] [compiler-rt] [clang-tools-extra] [flang] [libunwind] [clang] [lldb] [llvm] [AMDGPU] - Add constant folding for s_quadmask (PR #72381)
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 979eb558dd7c203be10fa24ab2b0d7cb93c3443b 3302aaf961982c5c32d692fb813fa25ad7ea33d4 -- llvm/lib/Analysis/ConstantFolding.cpp `` View the diff from clang-format here. ``diff diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 64d088ea7a..33f7b85e16 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -2425,7 +2425,6 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, return ConstantFP::get(Ty->getContext(), Val); } - case Intrinsic::amdgcn_s_quadmask: { uint64_t Val = Op->getZExtValue(); uint64_t QuadMask = 0; @@ -2446,7 +2445,6 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, Val = (Val & 0xULL) | (Val & 0xULL) << 1; Val = Val | Val << 1; return ConstantInt::get(Ty, Val); - } default: `` https://github.com/llvm/llvm-project/pull/72381 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [libunwind] [libcxx] [llvm] [compiler-rt] [lld] [lldb] [clang] [flang] [AMDGPU] - Add constant folding for s_quadmask (PR #72381)
https://github.com/OutOfCache updated https://github.com/llvm/llvm-project/pull/72381 >From 00d0f99207242befc8022031ccd8faf573cbf014 Mon Sep 17 00:00:00 2001 From: Jessica Del Date: Tue, 14 Nov 2023 22:17:26 +0100 Subject: [PATCH 1/3] [AMDGPU] - Add constant folding for s_quadmask If the input is a constant we can constant fold the `s_quadmask` intrinsic. --- llvm/lib/Analysis/ConstantFolding.cpp| 14 ++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll | 12 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 966a65ac26b8017..40b5938fcda0c2a 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1533,6 +1533,7 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) { case Intrinsic::amdgcn_perm: case Intrinsic::amdgcn_wave_reduce_umin: case Intrinsic::amdgcn_wave_reduce_umax: + case Intrinsic::amdgcn_s_quadmask: case Intrinsic::arm_mve_vctp8: case Intrinsic::arm_mve_vctp16: case Intrinsic::arm_mve_vctp32: @@ -2422,6 +2423,19 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, return ConstantFP::get(Ty->getContext(), Val); } + +case Intrinsic::amdgcn_s_quadmask: { + uint64_t Val = Op->getZExtValue(); + uint64_t QuadMask = 0; + for (unsigned i = 0; i < Op->getBitWidth() / 4; ++i, Val >>= 4) { +if (!(Val & 0xF)) + continue; + +QuadMask |= (1 << i); + } + return ConstantInt::get(Ty, QuadMask); +} + default: return nullptr; } diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll index 65443a6efa789d9..0f500c0999ad9a8 100644 --- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll +++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.quadmask.ll @@ -9,11 +9,10 @@ define i32 @test_quadmask_constant_i32() { ; GFX11-LABEL: test_quadmask_constant_i32: ; GFX11: ; %bb.0: ; %entry ; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) -; GFX11-NEXT:s_quadmask_b32 s0, 0x85fe3a92 -; GFX11-NEXT:v_mov_b32_e32 v0, s0 +; GFX11-NEXT:v_mov_b32_e32 v0, 0xcb ; GFX11-NEXT:s_setpc_b64 s[30:31] entry: - %qm = call i32 @llvm.amdgcn.s.quadmask.i32(i32 u0x85FE3A92) + %qm = call i32 @llvm.amdgcn.s.quadmask.i32(i32 u0x85003092) ret i32 %qm } @@ -50,13 +49,10 @@ define i64 @test_quadmask_constant_i64() { ; GFX11-LABEL: test_quadmask_constant_i64: ; GFX11: ; %bb.0: ; %entry ; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) -; GFX11-NEXT:s_mov_b32 s0, 0x85fe3a92 -; GFX11-NEXT:s_mov_b32 s1, 0x67de48fc -; GFX11-NEXT:s_quadmask_b64 s[0:1], s[0:1] -; GFX11-NEXT:v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1 +; GFX11-NEXT:v_dual_mov_b32 v0, 0xe3e6 :: v_dual_mov_b32 v1, 0 ; GFX11-NEXT:s_setpc_b64 s[30:31] entry: - %qm = call i64 @llvm.amdgcn.s.quadmask.i64(i64 u0x67DE48FC85FE3A92) + %qm = call i64 @llvm.amdgcn.s.quadmask.i64(i64 u0x67D000FC85F00A90) ret i64 %qm } >From 144c4dc164ec137e518cfd647c116373e7a61b8f Mon Sep 17 00:00:00 2001 From: Jessica Del Date: Wed, 15 Nov 2023 15:59:56 +0100 Subject: [PATCH 2/3] fixup! [AMDGPU] - Add constant folding for s_quadmask --- llvm/lib/Analysis/ConstantFolding.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 40b5938fcda0c2a..39bbb04fbcf26cc 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -2427,11 +2427,11 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, case Intrinsic::amdgcn_s_quadmask: { uint64_t Val = Op->getZExtValue(); uint64_t QuadMask = 0; - for (unsigned i = 0; i < Op->getBitWidth() / 4; ++i, Val >>= 4) { + for (unsigned I = 0; I < Op->getBitWidth() / 4; ++I, Val >>= 4) { if (!(Val & 0xF)) continue; -QuadMask |= (1 << i); +QuadMask |= (1 << I); } return ConstantInt::get(Ty, QuadMask); } >From 65bb0b1164ff9b7491589cb88decb1d135504c1b Mon Sep 17 00:00:00 2001 From: Jessica Del Date: Thu, 16 Nov 2023 11:22:52 +0100 Subject: [PATCH 3/3] fixup! Merge branch 'main' into quadmask-folding --- llvm/lib/Analysis/ConstantFolding.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 64d088ea7a46404..2771a3d574f7799 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -2425,7 +2425,6 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, return ConstantFP::get(Ty->getContext(), Val); } - case Intrinsic::amdgcn_s_quadmask: { uint64_t Val = Op->getZExtValue(); uint64_t QuadMask = 0; @@ -2436,6 +2435,7 @@ static Constant
[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)
Endilll wrote: > For this use case I'm setting options in lldb_private::DumpValueObjectOptions > down in C++ but I'm not sure if those directly map to what a formatter would > have access to. @DavidSpickett What exactly do you set or unset there to get the output you're showing? This approach seems novel to me, so I'd like to investigate it. https://github.com/llvm/llvm-project/pull/69815 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)
DavidSpickett wrote: Yeah sorry I dropped the context there, I copied over your change to `lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp` into my changes to get that output. So what I meant to put across was that we are aiming for the same result. https://github.com/llvm/llvm-project/pull/69815 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)
DavidSpickett wrote: The existing code is https://github.com/llvm/llvm-project/blob/865f54e501739f382d33866baebfd0f9aaad01bb/lldb/source/Core/DumpRegisterValue.cpp#L47. Register contents is described as a packed struct with bitfields as members. Now I am looking at making some of those enums so we can say what each value means. https://github.com/llvm/llvm-project/pull/69815 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add interface to check if UserExpression::Parse() is cacheable (PR #66826)
DavidSpickett wrote: This got forgotten it seems. Could you add a comment in the header to address Jim's question? So folks upstream know whether to care about overriding this for whatever new thing they might be building (there are lots of mysterious methods over in llvm and I end up ignoring them and hoping they're not important). https://github.com/llvm/llvm-project/pull/66826 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)
Endilll wrote: @DavidSpickett There is `SBValue:SetFormat()`, which takes `lldb::Format`. We can invent a new format, e.g. `eFormatEnumWithValue`. Not every enum flows through my formatter, as I'm actively improving emitted debug info so that LLDB does the right thing by default (`[[clang::preferred_type]]` is one example), reducing formatter boilerplate. So I'd prefer something global and possibly under user control, rather than doing it from formatter side. How does this sound to you? https://github.com/llvm/llvm-project/pull/69815 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)
DavidSpickett wrote: > So I'd prefer something global and possibly under user control, rather than > doing it from formatter side. How does this sound to you? Sure, I can always set it to on when printing registers so that would work for me. https://github.com/llvm/llvm-project/pull/69815 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libcxx] [libc] [compiler-rt] [clang-tools-extra] [flang] [llvm] [lldb] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
https://github.com/PAX-12-WU 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 1/6] 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 ab0a940e53e5538..982be8208164296 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 ec6289390545479..07f6d8e169ead6c 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 ad592814e5acb79..92b9907860121aa 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 b81a0791c5e571b..da0803c39f49b6d 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/run
[Lldb-commits] [clang] [libcxx] [libc] [compiler-rt] [clang-tools-extra] [flang] [llvm] [lldb] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
https://github.com/PAX-12-WU 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 1/6] 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 ab0a940e53e5538..982be8208164296 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 ec6289390545479..07f6d8e169ead6c 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 ad592814e5acb79..92b9907860121aa 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 b81a0791c5e571b..da0803c39f49b6d 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/run
[Lldb-commits] [clang-tools-extra] [libcxx] [llvm] [compiler-rt] [libc] [flang] [clang] [lldb] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
https://github.com/PAX-12-WU 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 1/6] 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 ab0a940e53e5538..982be8208164296 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 ec6289390545479..07f6d8e169ead6c 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 ad592814e5acb79..92b9907860121aa 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 b81a0791c5e571b..da0803c39f49b6d 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/run
[Lldb-commits] [flang] [llvm] [libc] [compiler-rt] [clang] [clang-tools-extra] [lldb] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)
https://github.com/PAX-12-WU 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 1/6] 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 ab0a940e53e5538..982be8208164296 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 ec6289390545479..07f6d8e169ead6c 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 ad592814e5acb79..92b9907860121aa 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 b81a0791c5e571b..da0803c39f49b6d 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/run
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Clarify comment around static member variable handling (PR #72495)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/72495 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 70900ec - [lldb][DWARFASTParserClang][NFC] Clarify comment around static member variable handling (#72495)
Author: Michael Buch Date: 2023-11-16T16:09:47Z New Revision: 70900ec79984105c661a923aae2f993394ae7aae URL: https://github.com/llvm/llvm-project/commit/70900ec79984105c661a923aae2f993394ae7aae DIFF: https://github.com/llvm/llvm-project/commit/70900ec79984105c661a923aae2f993394ae7aae.diff LOG: [lldb][DWARFASTParserClang][NFC] Clarify comment around static member variable handling (#72495) Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 37efe70461977ad..abe3c673e2cce69 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2963,9 +2963,9 @@ void DWARFASTParserClang::ParseSingleMember( // whereas GCC emits it only for static data members if not part of an // anonymous namespace. The flag that is consistently emitted for static // data members is DW_AT_declaration, so we check it instead. - // FIXME: Since DWARFv5, static data members are marked DW_AT_variable so we + // The following block is only necessary to support DWARFv4 and earlier. + // Starting with DWARFv5, static data members are marked DW_AT_variable so we // can consistently detect them on both GCC and Clang without below heuristic. - // Remove this block if we ever drop DWARFv4 support. if (attrs.member_byte_offset == UINT32_MAX && attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) { CreateStaticMemberVariable(die, attrs, class_clang_type); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang][NFC] Clarify comment around static member variable handling (PR #72495)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/72495 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [libc] [flang] [openmp] [lldb] [libcxx] [mlir] [clang] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
https://github.com/mahtohappy updated https://github.com/llvm/llvm-project/pull/72522 >From ce4f4fc02e25359c8f38ff9ecf2a2d82aa90df72 Mon Sep 17 00:00:00 2001 From: mahtohappy Date: Thu, 16 Nov 2023 06:53:24 -0800 Subject: [PATCH] Fix Logical expression used for merged conditional if --- llvm/lib/Transforms/Utils/FlattenCFG.cpp | 8 llvm/test/Transforms/Util/flattencfg.ll | 22 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp b/llvm/lib/Transforms/Utils/FlattenCFG.cpp index 1925b91c4da7ec1..5f8cd12c1d50856 100644 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -436,9 +436,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { bool InvertCond2 = false; BinaryOperator::BinaryOps CombineOp; if (IfFalse1 == FirstEntryBlock) { -// The else-path is empty, so we must use "or" operation to combine the +// The then-path is empty, so we must use "and" operation to combine the // conditions. -CombineOp = BinaryOperator::Or; +CombineOp = BinaryOperator::And; if (IfFalse2 != SecondEntryBlock) { if (IfTrue2 != SecondEntryBlock) return false; @@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; if (IfTrue2 != SecondEntryBlock) { if (IfFalse2 != SecondEntryBlock) return false; diff --git a/llvm/test/Transforms/Util/flattencfg.ll b/llvm/test/Transforms/Util/flattencfg.ll index 4a4d4279f360d6a..0fd285be2715b80 100644 --- a/llvm/test/Transforms/Util/flattencfg.ll +++ b/llvm/test/Transforms/Util/flattencfg.ll @@ -10,12 +10,12 @@ define void @test_not_crash(i32 %in_a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[CMP0:%.*]] = icmp eq i32 [[IN_A]], -1 ; CHECK-NEXT:[[CMP1:%.*]] = icmp ne i32 [[IN_A]], 0 -; CHECK-NEXT:[[COND0:%.*]] = and i1 [[CMP0]], [[CMP1]] +; CHECK-NEXT:[[COND0:%.*]] = or i1 [[CMP0]], [[CMP1]] ; CHECK-NEXT:br i1 [[COND0]], label [[B0:%.*]], label [[B1:%.*]] ; CHECK: b0: ; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[IN_A]], 0 ; CHECK-NEXT:[[CMP3:%.*]] = icmp ne i32 [[IN_A]], 1 -; CHECK-NEXT:[[COND1:%.*]] = or i1 [[CMP2]], [[CMP3]] +; CHECK-NEXT:[[COND1:%.*]] = and i1 [[CMP2]], [[CMP3]] ; CHECK-NEXT:br i1 [[COND1]], label [[EXIT:%.*]], label [[B1]] ; CHECK: b1: ; CHECK-NEXT:br label [[EXIT]] @@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 { entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 - %cond0 = and i1 %cmp0, %cmp1 + %cond0 = or i1 %cmp0, %cmp1 br i1 %cond0, label %b0, label %b1 b0:; preds = %entry %cmp2 = icmp eq i32 %in_a, 0 %cmp3 = icmp ne i32 %in_a, 1 - %cond1 = or i1 %cmp2, %cmp3 + %cond1 = and i1 %cmp2, %cmp3 br i1 %cond1, label %exit, label %b1 b1: ; preds = %entry, %b0 @@ -47,7 +47,7 @@ define void @test_not_crash2(float %a, float %b) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[TMP0:%.*]] = fcmp ult float [[A]], 1.00e+00 ; CHECK-NEXT:[[TMP1:%.*]] = fcmp ult float [[B]], 1.00e+00 -; CHECK-NEXT:[[TMP2:%.*]] = and i1 [[TMP0]], [[TMP1]] +; CHECK-NEXT:[[TMP2:%.*]] = or i1 [[TMP0]], [[TMP1]] ; CHECK-NEXT:br i1 [[TMP2]], label [[BB4:%.*]], label [[BB3:%.*]] ; CHECK: bb3: ; CHECK-NEXT:br label [[BB4]] @@ -78,7 +78,7 @@ define void @test_not_crash3(i32 %a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0 ; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[A_EQ_0]], [[A_EQ_1]] ; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]] ; CHECK: bb2: ; CHECK-NEXT:br label [[BB3]] @@ -114,7 +114,7 @@ define void @test_then(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[CMP_X]], [[CMP_Y]] ; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]] ; CHECK: if.then.y: ; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4 @@ -148,7 +148,7 @@ define void @test_else(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp eq i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0 -; CHECK-NEXT:
[Lldb-commits] [llvm] [libc] [flang] [openmp] [lldb] [libcxx] [mlir] [clang] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
https://github.com/mahtohappy updated https://github.com/llvm/llvm-project/pull/72522 >From ce4f4fc02e25359c8f38ff9ecf2a2d82aa90df72 Mon Sep 17 00:00:00 2001 From: mahtohappy Date: Thu, 16 Nov 2023 06:53:24 -0800 Subject: [PATCH 1/2] Fix Logical expression used for merged conditional if --- llvm/lib/Transforms/Utils/FlattenCFG.cpp | 8 llvm/test/Transforms/Util/flattencfg.ll | 22 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp b/llvm/lib/Transforms/Utils/FlattenCFG.cpp index 1925b91c4da7ec1..5f8cd12c1d50856 100644 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -436,9 +436,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { bool InvertCond2 = false; BinaryOperator::BinaryOps CombineOp; if (IfFalse1 == FirstEntryBlock) { -// The else-path is empty, so we must use "or" operation to combine the +// The then-path is empty, so we must use "and" operation to combine the // conditions. -CombineOp = BinaryOperator::Or; +CombineOp = BinaryOperator::And; if (IfFalse2 != SecondEntryBlock) { if (IfTrue2 != SecondEntryBlock) return false; @@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; if (IfTrue2 != SecondEntryBlock) { if (IfFalse2 != SecondEntryBlock) return false; diff --git a/llvm/test/Transforms/Util/flattencfg.ll b/llvm/test/Transforms/Util/flattencfg.ll index 4a4d4279f360d6a..0fd285be2715b80 100644 --- a/llvm/test/Transforms/Util/flattencfg.ll +++ b/llvm/test/Transforms/Util/flattencfg.ll @@ -10,12 +10,12 @@ define void @test_not_crash(i32 %in_a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[CMP0:%.*]] = icmp eq i32 [[IN_A]], -1 ; CHECK-NEXT:[[CMP1:%.*]] = icmp ne i32 [[IN_A]], 0 -; CHECK-NEXT:[[COND0:%.*]] = and i1 [[CMP0]], [[CMP1]] +; CHECK-NEXT:[[COND0:%.*]] = or i1 [[CMP0]], [[CMP1]] ; CHECK-NEXT:br i1 [[COND0]], label [[B0:%.*]], label [[B1:%.*]] ; CHECK: b0: ; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[IN_A]], 0 ; CHECK-NEXT:[[CMP3:%.*]] = icmp ne i32 [[IN_A]], 1 -; CHECK-NEXT:[[COND1:%.*]] = or i1 [[CMP2]], [[CMP3]] +; CHECK-NEXT:[[COND1:%.*]] = and i1 [[CMP2]], [[CMP3]] ; CHECK-NEXT:br i1 [[COND1]], label [[EXIT:%.*]], label [[B1]] ; CHECK: b1: ; CHECK-NEXT:br label [[EXIT]] @@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 { entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 - %cond0 = and i1 %cmp0, %cmp1 + %cond0 = or i1 %cmp0, %cmp1 br i1 %cond0, label %b0, label %b1 b0:; preds = %entry %cmp2 = icmp eq i32 %in_a, 0 %cmp3 = icmp ne i32 %in_a, 1 - %cond1 = or i1 %cmp2, %cmp3 + %cond1 = and i1 %cmp2, %cmp3 br i1 %cond1, label %exit, label %b1 b1: ; preds = %entry, %b0 @@ -47,7 +47,7 @@ define void @test_not_crash2(float %a, float %b) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[TMP0:%.*]] = fcmp ult float [[A]], 1.00e+00 ; CHECK-NEXT:[[TMP1:%.*]] = fcmp ult float [[B]], 1.00e+00 -; CHECK-NEXT:[[TMP2:%.*]] = and i1 [[TMP0]], [[TMP1]] +; CHECK-NEXT:[[TMP2:%.*]] = or i1 [[TMP0]], [[TMP1]] ; CHECK-NEXT:br i1 [[TMP2]], label [[BB4:%.*]], label [[BB3:%.*]] ; CHECK: bb3: ; CHECK-NEXT:br label [[BB4]] @@ -78,7 +78,7 @@ define void @test_not_crash3(i32 %a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0 ; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[A_EQ_0]], [[A_EQ_1]] ; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]] ; CHECK: bb2: ; CHECK-NEXT:br label [[BB3]] @@ -114,7 +114,7 @@ define void @test_then(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[CMP_X]], [[CMP_Y]] ; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]] ; CHECK: if.then.y: ; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4 @@ -148,7 +148,7 @@ define void @test_else(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp eq i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0 -; CHECK-NE
[Lldb-commits] [lldb] [clang] [mlir] [compiler-rt] [libc] [flang] [llvm] [lld] [libcxx] [clang-tools-extra] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)
silee2 wrote: @antiagainst @kuhar Any comments? https://github.com/llvm/llvm-project/pull/71430 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] [mlir] [compiler-rt] [libc] [flang] [libunwind] [llvm] [lld] [libcxx] [clang-tools-extra] [IRPGO][ValueProfile] Instrument virtual table address that could be used to do
minglotus-6 wrote: > One heads up, the latest 'git merge main' brings a failure in test > https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/fuzzer/gc-sections.test > :( . `ninja check-all` on a clean main gives the same failure. Hopefully it > would be fixed soon. This is fixed at upstream main so merged upstream main. https://github.com/llvm/llvm-project/pull/66825 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add interface to check if UserExpression::Parse() is cacheable (PR #66826)
augusto2112 wrote: @DavidSpickett thanks for reminding me. I'll add a comment describing the situation. Right now, for conditional breakpoints, we assume that the condition expression is cacheable, since it's being run over and over again in the exact same context. This works for C/C++, but not for Swift, because Swift generics aren't monomorphized (the same problem would happen for other languages where generics aren't monomorphized either, so a more general escape hatch seemed appropriate to me). To illustrate what I mean, a function such as the following (in C++ syntax but Swift semantics): ``` template void use(T t) {} // In main use(5); use(std::string()) ``` Is lowered only once as a truly generic function (unlike C++ which will generate one version per instantiation), so it isn't safe to cache the expression parse, as the argument type may be different in every invocation. https://github.com/llvm/llvm-project/pull/66826 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add interface to check if UserExpression::Parse() is cacheable (PR #66826)
https://github.com/augusto2112 updated https://github.com/llvm/llvm-project/pull/66826 >From fcc27c3b81a8f2c0566af801e623d23f748fb04a Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Tue, 19 Sep 2023 13:27:41 -0700 Subject: [PATCH] [lldb] Add interface to check if UserExpression::Parse() is cacheable When setting conditional breakpoints, we currently assume that a call to UserExpression::Parse() can be cached and resued multiple times. This may not be true for every user expression. Add a new method so subclasses of UserExpression can customize if they are parseable or not. --- lldb/include/lldb/Expression/UserExpression.h | 8 lldb/source/Breakpoint/BreakpointLocation.cpp | 1 + 2 files changed, 9 insertions(+) diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h index df7a76664f6d5b6..b6cfeec7e899330 100644 --- a/lldb/include/lldb/Expression/UserExpression.h +++ b/lldb/include/lldb/Expression/UserExpression.h @@ -192,6 +192,14 @@ class UserExpression : public Expression { /// expression. Text() should contain the definition of this function. const char *FunctionName() override { return "$__lldb_expr"; } + /// Returns whether the call to Parse on this user expression is cacheable. + /// This function exists to provide an escape hatch for supporting languages + /// where parsing an expression in the exact same context is unsafe. For + /// example, languages where generic functions aren't monomorphized, but + /// implement some other mechanism to represent generic values, may be unsafe + /// to cache, as the concrete type substitution may be different in every + /// expression evaluation. + virtual bool IsParseCacheable() { return true; } /// Return the language that should be used when parsing. To use the /// default, return eLanguageTypeUnknown. lldb::LanguageType Language() const override { return m_language; } diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 0fcefe5c63be749..2d2e00883f32ef7 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -250,6 +250,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx, DiagnosticManager diagnostics; if (condition_hash != m_condition_hash || !m_user_expression_sp || + !m_user_expression_sp->IsParseCacheable() || !m_user_expression_sp->MatchesContext(exe_ctx)) { LanguageType language = eLanguageTypeUnknown; // See if we can figure out the language from the frame, otherwise use the ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add interface to check if UserExpression::Parse() is cacheable (PR #66826)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Augusto Noronha (augusto2112) Changes When setting conditional breakpoints, we currently assume that a call to UserExpression::Parse() can be cached and resued multiple times. This may not be true for every user expression. Add a new method so subclasses of UserExpression can customize if they are parseable or not. --- Full diff: https://github.com/llvm/llvm-project/pull/66826.diff 2 Files Affected: - (modified) lldb/include/lldb/Expression/UserExpression.h (+8) - (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+1) ``diff diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h index df7a76664f6d5b6..b6cfeec7e899330 100644 --- a/lldb/include/lldb/Expression/UserExpression.h +++ b/lldb/include/lldb/Expression/UserExpression.h @@ -192,6 +192,14 @@ class UserExpression : public Expression { /// expression. Text() should contain the definition of this function. const char *FunctionName() override { return "$__lldb_expr"; } + /// Returns whether the call to Parse on this user expression is cacheable. + /// This function exists to provide an escape hatch for supporting languages + /// where parsing an expression in the exact same context is unsafe. For + /// example, languages where generic functions aren't monomorphized, but + /// implement some other mechanism to represent generic values, may be unsafe + /// to cache, as the concrete type substitution may be different in every + /// expression evaluation. + virtual bool IsParseCacheable() { return true; } /// Return the language that should be used when parsing. To use the /// default, return eLanguageTypeUnknown. lldb::LanguageType Language() const override { return m_language; } diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 0fcefe5c63be749..2d2e00883f32ef7 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -250,6 +250,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx, DiagnosticManager diagnostics; if (condition_hash != m_condition_hash || !m_user_expression_sp || + !m_user_expression_sp->IsParseCacheable() || !m_user_expression_sp->MatchesContext(exe_ctx)) { LanguageType language = eLanguageTypeUnknown; // See if we can figure out the language from the frame, otherwise use the `` https://github.com/llvm/llvm-project/pull/66826 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add interface to check if UserExpression::Parse() is cacheable (PR #66826)
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 f8e8530f7377ab84b23c268454015fbcb95231c0 fcc27c3b81a8f2c0566af801e623d23f748fb04a -- lldb/include/lldb/Expression/UserExpression.h lldb/source/Breakpoint/BreakpointLocation.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 2d2e00883f..82046cb92d 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -627,8 +627,8 @@ void BreakpointLocation::Dump(Stream *s) const { bool is_resolved = IsResolved(); bool is_hardware = is_resolved && m_bp_site_sp->IsHardware(); - auto hardware_index = is_resolved ? - m_bp_site_sp->GetHardwareIndex() : LLDB_INVALID_INDEX32; + auto hardware_index = + is_resolved ? m_bp_site_sp->GetHardwareIndex() : LLDB_INVALID_INDEX32; lldb::tid_t tid = GetOptionsSpecifyingKind(BreakpointOptions::eThreadSpec) .GetThreadSpecNoCreate() `` https://github.com/llvm/llvm-project/pull/66826 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Clarify error messages on corefiles that no plugin handles (PR #72559)
https://github.com/jasonmolenda created https://github.com/llvm/llvm-project/pull/72559 These error messages are written in a way that makes sense to an lldb developer, but not to an end user who asks lldb to run on a compressed corefile or whatever. Simplfy the messages. >From cb79d7e6490db770b6be4fad5ad841f30ac66504 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Thu, 16 Nov 2023 11:17:13 -0800 Subject: [PATCH] Clarify error messages on corefiles that no plugin handles These error messages are written in a way that makes sense to an lldb developer, but not to an end user who asks lldb to run on a compressed corefile or whatever. Simplfy the messages. --- lldb/source/Commands/CommandObjectTarget.cpp | 8 +++- lldb/source/Core/IOHandlerCursesGUI.cpp | 4 ++-- lldb/test/API/commands/target/basic/TestTargetCommand.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 8f052d0a7b837e2..58785cde3ec7c63 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -436,8 +436,7 @@ class CommandObjectTargetCreate : public CommandObjectParsed { error = process_sp->LoadCore(); if (error.Fail()) { -result.AppendError( -error.AsCString("can't find plug-in for core file")); +result.AppendError(error.AsCString("unknown core file format")); return; } else { result.AppendMessageWithFormatv( @@ -447,9 +446,8 @@ class CommandObjectTargetCreate : public CommandObjectParsed { on_error.release(); } } else { - result.AppendErrorWithFormatv( - "Unable to find process plug-in for core file '{0}'\n", - core_file.GetPath()); + result.AppendErrorWithFormatv("Unknown core file format '{0}'\n", +core_file.GetPath()); } } else { result.AppendMessageWithFormat( diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index 22b8cc3582eae78..abf0b6b801f37fc 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -3178,13 +3178,13 @@ class TargetCreateFormDelegate : public FormDelegate { m_debugger.GetListener(), llvm::StringRef(), &core_file_spec, false)); if (!process_sp) { - SetError("Unable to find process plug-in for core file!"); + SetError("Unknown core file format!"); return; } Status status = process_sp->LoadCore(); if (status.Fail()) { - SetError("Can't find plug-in for core file!"); + SetError("Unknown core file format!"); return; } } diff --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py b/lldb/test/API/commands/target/basic/TestTargetCommand.py index 96e7fe86ac5aee5..cb7a5f33f6643e8 100644 --- a/lldb/test/API/commands/target/basic/TestTargetCommand.py +++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py @@ -447,7 +447,7 @@ def test_target_create_invalid_core_file(self): self.expect( "target create -c '" + invalid_core_path + "'", error=True, -substrs=["Unable to find process plug-in for core file '"], +substrs=["Unknown core file format '"], ) # Write only files don't seem to be supported on Windows. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Clarify error messages on corefiles that no plugin handles (PR #72559)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changes These error messages are written in a way that makes sense to an lldb developer, but not to an end user who asks lldb to run on a compressed corefile or whatever. Simplfy the messages. --- Full diff: https://github.com/llvm/llvm-project/pull/72559.diff 3 Files Affected: - (modified) lldb/source/Commands/CommandObjectTarget.cpp (+3-5) - (modified) lldb/source/Core/IOHandlerCursesGUI.cpp (+2-2) - (modified) lldb/test/API/commands/target/basic/TestTargetCommand.py (+1-1) ``diff diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 8f052d0a7b837e2..58785cde3ec7c63 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -436,8 +436,7 @@ class CommandObjectTargetCreate : public CommandObjectParsed { error = process_sp->LoadCore(); if (error.Fail()) { -result.AppendError( -error.AsCString("can't find plug-in for core file")); +result.AppendError(error.AsCString("unknown core file format")); return; } else { result.AppendMessageWithFormatv( @@ -447,9 +446,8 @@ class CommandObjectTargetCreate : public CommandObjectParsed { on_error.release(); } } else { - result.AppendErrorWithFormatv( - "Unable to find process plug-in for core file '{0}'\n", - core_file.GetPath()); + result.AppendErrorWithFormatv("Unknown core file format '{0}'\n", +core_file.GetPath()); } } else { result.AppendMessageWithFormat( diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index 22b8cc3582eae78..abf0b6b801f37fc 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -3178,13 +3178,13 @@ class TargetCreateFormDelegate : public FormDelegate { m_debugger.GetListener(), llvm::StringRef(), &core_file_spec, false)); if (!process_sp) { - SetError("Unable to find process plug-in for core file!"); + SetError("Unknown core file format!"); return; } Status status = process_sp->LoadCore(); if (status.Fail()) { - SetError("Can't find plug-in for core file!"); + SetError("Unknown core file format!"); return; } } diff --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py b/lldb/test/API/commands/target/basic/TestTargetCommand.py index 96e7fe86ac5aee5..cb7a5f33f6643e8 100644 --- a/lldb/test/API/commands/target/basic/TestTargetCommand.py +++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py @@ -447,7 +447,7 @@ def test_target_create_invalid_core_file(self): self.expect( "target create -c '" + invalid_core_path + "'", error=True, -substrs=["Unable to find process plug-in for core file '"], +substrs=["Unknown core file format '"], ) # Write only files don't seem to be supported on Windows. `` https://github.com/llvm/llvm-project/pull/72559 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
@@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text.data()); junior-jl wrote: Done! Thank you, I did not realize 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] Colorize output when searching for symbols in lldb (PR #69422)
@@ -163,7 +166,10 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, dumped_something = true; if (symbol->GetType() == eSymbolTypeTrampoline) s->PutCString("symbol stub for: "); - symbol->GetName().Dump(s); + if (pattern) +Address::DumpName(s, symbol->GetName().GetStringRef(), pattern); + else +symbol->GetName().Dump(s); junior-jl wrote: When I opened this suggestion, it only showed the changes from the first commit, not "changes from all commits", maybe that's the reason it was not corrected yet. I don't know why that happened. 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] [llvm] Emit DIE's size in bits when size is not a multiple of 8 (PR #69741)
dwblaikie wrote: > > I'm arguing it doesn't fit it particularly well. We use it for bit fields - > > which are pretty special, for instance, but it seems like this thing isn't > > quite like that - it does have a whole byte size (if you allocated an array > > of them, for instance, I'm guessing they're a byte each, right?) but then > > has some padding bits that can be reused in some circumstances? That's why > > I'm saying it seems like it fits more closely to the struct padding > > representation. > > Swift is really clever at packing at packing aggregate types. For example, > the discriminator bits for enums are always stored in unused bits of the > payload type. For a contrived example, the type Optional has a size > of 3 bits. Sure enough - C++ tail padding does similar things: https://godbolt.org/z/4jsYWK6ev - where t2's member is packed into the tail padding of t1, but still leaves more tail padding for t3. (it's not identical, of course - it's somewhere between C++ tail padding and the ad-hoc stuff we have in LLVM for PointerIntPair, where multiple of those can be nested together and use the remaining bits for another element) https://github.com/llvm/llvm-project/pull/69741 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
https://github.com/junior-jl edited 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] Colorize output when searching for symbols in lldb (PR #69422)
@@ -231,6 +231,18 @@ 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 color highlighting to + /// the specified \a pattern within the string. + /// + /// \param[in] text + /// The string to be output to the stream. + /// + /// \param[in] pattern + /// The portion of the \a text string to be colorized for highlighting. junior-jl wrote: ✅ 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] Colorize output when searching for symbols in lldb (PR #69422)
@@ -231,6 +231,18 @@ 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 color highlighting to + /// the specified \a pattern within the string. junior-jl wrote: > Print a C string \a text to the stream, applying color highlighting to the > portions of the string matched by the regex pattern \a pattern. Added the information and used the above as template 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 interface to check if UserExpression::Parse() is cacheable (PR #66826)
https://github.com/augusto2112 updated https://github.com/llvm/llvm-project/pull/66826 >From 5323ac957268e469207aae340e15f6809b53bf53 Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Thu, 16 Nov 2023 11:31:55 -0800 Subject: [PATCH] [lldb] Add interface to check if UserExpression::Parse() is cacheable When setting conditional breakpoints, we currently assume that a call to UserExpression::Parse() can be cached and resued multiple times. This may not be true for every user expression. Add a new method so subclasses of UserExpression can customize if they are parseable or not. --- lldb/include/lldb/Expression/UserExpression.h | 8 lldb/source/Breakpoint/BreakpointLocation.cpp | 1 + 2 files changed, 9 insertions(+) diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h index df7a76664f6d5b6..b6cfeec7e899330 100644 --- a/lldb/include/lldb/Expression/UserExpression.h +++ b/lldb/include/lldb/Expression/UserExpression.h @@ -192,6 +192,14 @@ class UserExpression : public Expression { /// expression. Text() should contain the definition of this function. const char *FunctionName() override { return "$__lldb_expr"; } + /// Returns whether the call to Parse on this user expression is cacheable. + /// This function exists to provide an escape hatch for supporting languages + /// where parsing an expression in the exact same context is unsafe. For + /// example, languages where generic functions aren't monomorphized, but + /// implement some other mechanism to represent generic values, may be unsafe + /// to cache, as the concrete type substitution may be different in every + /// expression evaluation. + virtual bool IsParseCacheable() { return true; } /// Return the language that should be used when parsing. To use the /// default, return eLanguageTypeUnknown. lldb::LanguageType Language() const override { return m_language; } diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 27dc7458dc26f70..931e1ad4b2d9339 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -250,6 +250,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx, DiagnosticManager diagnostics; if (condition_hash != m_condition_hash || !m_user_expression_sp || + !m_user_expression_sp->IsParseCacheable() || !m_user_expression_sp->MatchesContext(exe_ctx)) { LanguageType language = eLanguageTypeUnknown; // See if we can figure out the language from the frame, otherwise use the ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a322d50 - [lldb] Add forward declaration for SBWatchpointOptions in SBDefines.h
Author: Alex Langford Date: 2023-11-16T12:13:44-08:00 New Revision: a322d50804c5248f9e2981f3733bcb598fa13d51 URL: https://github.com/llvm/llvm-project/commit/a322d50804c5248f9e2981f3733bcb598fa13d51 DIFF: https://github.com/llvm/llvm-project/commit/a322d50804c5248f9e2981f3733bcb598fa13d51.diff LOG: [lldb] Add forward declaration for SBWatchpointOptions in SBDefines.h Added: Modified: lldb/include/lldb/API/SBDefines.h Removed: diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index 2630a82df0e7135..92d823fa1dfe250 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -128,6 +128,7 @@ class LLDB_API SBValue; class LLDB_API SBValueList; class LLDB_API SBVariablesOptions; class LLDB_API SBWatchpoint; +class LLDB_API SBWatchpointOptions; class LLDB_API SBUnixSignals; typedef bool (*SBBreakpointHitCallback)(void *baton, SBProcess &process, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
https://github.com/jimingham created https://github.com/llvm/llvm-project/pull/72565 Currently when you interrupt a: (lldb) process attach -w -n some_process lldb just closes the connection to the stub and kills the process it made for the attach. The stub at the other end notices the connection go down and exits because of that. But when communication to a device is handled through some kind of proxy server, that signal might not be reliable, causing debugserver to persist on the machine. We can work around those failures by sending an explicit interrupt before closing down the connection. The stub will also have to be waiting for the interrupt for this to make any difference. I changed debugserver to do that. I didn't make the equivalent change in lldb-server. So long as you aren't faced with a flakey connection, this should not be necessary. >From f5d66b41bc06840648725daa640c6923b0eab923 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 16 Nov 2023 12:18:36 -0800 Subject: [PATCH] Send an explicit interrupt to cancel an attach waitfor. Currently when you interrupt a: (lldb) process attach -w -n some_process lldb just closes the connection to the stub and kills the process it made for the attach. The stub at the other end notices the connection go down and exits because of that. But when communication to a device is handled through some kind of proxy server, that signal might not be reliable, causing debugserver to persist on the machine. We can work around those failures by sending an explicit interrupt before closing down the connection. The stub will also have to be waiting for the interrupt for this to make any difference. I changed debugserver to do that. I didn't make the equivalent change in lldb-server. So long as you aren't faced with a flakey connection, this should not be necessary. --- .../Process/gdb-remote/ProcessGDBRemote.cpp | 6 ++-- lldb/source/Target/Process.cpp| 9 +- lldb/tools/debugserver/source/DNB.cpp | 30 +-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index f90a561aae2e3b7..b6fe1bd7104b280 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2372,8 +2372,10 @@ Status ProcessGDBRemote::DoHalt(bool &caused_stop) { Status error; if (m_public_state.GetValue() == eStateAttaching) { -// We are being asked to halt during an attach. We need to just close our -// file handle and debugserver will go away, and we can be done... +// We are being asked to halt during an attach. We used to just close our +// file handle and debugserver will go away, but with remote proxies, it +// is better to send a positive signal, so let's send the interrupt first... +caused_stop = m_gdb_comm.Interrupt(GetInterruptTimeout()); m_gdb_comm.Disconnect(); } else caused_stop = m_gdb_comm.Interrupt(GetInterruptTimeout()); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 21b80b8240ab64b..f3da2839e262e23 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3156,8 +3156,8 @@ Status Process::Halt(bool clear_thread_plans, bool use_run_lock) { // Don't hijack and eat the eStateExited as the code that was doing the // attach will be waiting for this event... RestoreProcessEvents(); -SetExitStatus(SIGKILL, "Cancelled async attach."); Destroy(false); +SetExitStatus(SIGKILL, "Cancelled async attach."); return Status(); } @@ -3843,6 +3843,13 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) { ") woke up with an interrupt while attaching - " "forwarding interrupt.", __FUNCTION__, static_cast(this), GetID()); +// The server may be spinning waiting for a process to appear, in which +// case we should tell it to stop doing that. Normally, we don't NEED +// to do that because we will next close the communication to the stub +// and that will get it to shut down. But there are remote debugging +// cases where relying on that side-effect causes the shutdown to be +// flakey, so we should send a positive signal to interrupt the wait. +Status error = HaltPrivate(); BroadcastEvent(eBroadcastBitInterrupt, nullptr); } else if (StateIsRunningState(m_last_broadcast_state)) { LLDB_LOGF(log, diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index f6c1130fdd8054c..0ec50df42d1fedc 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -50,6 +50,7 @@ #include "MacOSX/MachProcess.h" #include "MacOSX/MachTask.h" #include "MacOSX/Threa
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (jimingham) Changes Currently when you interrupt a: (lldb) process attach -w -n some_process lldb just closes the connection to the stub and kills the process it made for the attach. The stub at the other end notices the connection go down and exits because of that. But when communication to a device is handled through some kind of proxy server, that signal might not be reliable, causing debugserver to persist on the machine. We can work around those failures by sending an explicit interrupt before closing down the connection. The stub will also have to be waiting for the interrupt for this to make any difference. I changed debugserver to do that. I didn't make the equivalent change in lldb-server. So long as you aren't faced with a flakey connection, this should not be necessary. --- Full diff: https://github.com/llvm/llvm-project/pull/72565.diff 3 Files Affected: - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+4-2) - (modified) lldb/source/Target/Process.cpp (+8-1) - (modified) lldb/tools/debugserver/source/DNB.cpp (+28-2) ``diff diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index f90a561aae2e3b7..b6fe1bd7104b280 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2372,8 +2372,10 @@ Status ProcessGDBRemote::DoHalt(bool &caused_stop) { Status error; if (m_public_state.GetValue() == eStateAttaching) { -// We are being asked to halt during an attach. We need to just close our -// file handle and debugserver will go away, and we can be done... +// We are being asked to halt during an attach. We used to just close our +// file handle and debugserver will go away, but with remote proxies, it +// is better to send a positive signal, so let's send the interrupt first... +caused_stop = m_gdb_comm.Interrupt(GetInterruptTimeout()); m_gdb_comm.Disconnect(); } else caused_stop = m_gdb_comm.Interrupt(GetInterruptTimeout()); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 21b80b8240ab64b..f3da2839e262e23 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3156,8 +3156,8 @@ Status Process::Halt(bool clear_thread_plans, bool use_run_lock) { // Don't hijack and eat the eStateExited as the code that was doing the // attach will be waiting for this event... RestoreProcessEvents(); -SetExitStatus(SIGKILL, "Cancelled async attach."); Destroy(false); +SetExitStatus(SIGKILL, "Cancelled async attach."); return Status(); } @@ -3843,6 +3843,13 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) { ") woke up with an interrupt while attaching - " "forwarding interrupt.", __FUNCTION__, static_cast(this), GetID()); +// The server may be spinning waiting for a process to appear, in which +// case we should tell it to stop doing that. Normally, we don't NEED +// to do that because we will next close the communication to the stub +// and that will get it to shut down. But there are remote debugging +// cases where relying on that side-effect causes the shutdown to be +// flakey, so we should send a positive signal to interrupt the wait. +Status error = HaltPrivate(); BroadcastEvent(eBroadcastBitInterrupt, nullptr); } else if (StateIsRunningState(m_last_broadcast_state)) { LLDB_LOGF(log, diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index f6c1130fdd8054c..0ec50df42d1fedc 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -50,6 +50,7 @@ #include "MacOSX/MachProcess.h" #include "MacOSX/MachTask.h" #include "MacOSX/ThreadInfo.h" +#include "RNBRemote.h" typedef std::shared_ptr MachProcessSP; typedef std::map ProcessMap; @@ -745,7 +746,6 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, break; } } else { - // Get the current process list, and check for matches that // aren't in our original list. If anyone wants to attach // to an existing process by name, they should do it with @@ -799,7 +799,33 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, break; } - ::usleep(waitfor_interval); // Sleep for WAITFOR_INTERVAL, then poll again + // Now we're going to wait a while before polling again. But we also + // need to check whether we've gotten an event from the debugger + // telling us to interrupt the wait. So we'll use the wait for a possible + // next event to also be our short pause... + s
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
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 a322d50804c5248f9e2981f3733bcb598fa13d51 f5d66b41bc06840648725daa640c6923b0eab923 -- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Target/Process.cpp lldb/tools/debugserver/source/DNB.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index f3da2839e2..382daa92b6 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3847,8 +3847,8 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) { // case we should tell it to stop doing that. Normally, we don't NEED // to do that because we will next close the communication to the stub // and that will get it to shut down. But there are remote debugging -// cases where relying on that side-effect causes the shutdown to be -// flakey, so we should send a positive signal to interrupt the wait. +// cases where relying on that side-effect causes the shutdown to be +// flakey, so we should send a positive signal to interrupt the wait. Status error = HaltPrivate(); BroadcastEvent(eBroadcastBitInterrupt, nullptr); } else if (StateIsRunningState(m_last_broadcast_state)) { diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index 0ec50df42d..37d71fd47a 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -800,15 +800,15 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, } // Now we're going to wait a while before polling again. But we also - // need to check whether we've gotten an event from the debugger + // need to check whether we've gotten an event from the debugger // telling us to interrupt the wait. So we'll use the wait for a possible // next event to also be our short pause... struct timespec short_timeout; DNBTimer::OffsetTimeOfDay(&short_timeout, 0, waitfor_interval); - uint32_t event_mask = RNBContext::event_read_packet_available - | RNBContext::event_read_thread_exiting; - nub_event_t set_events = ctx->Events().WaitForSetEvents(event_mask, - &short_timeout); + uint32_t event_mask = RNBContext::event_read_packet_available | +RNBContext::event_read_thread_exiting; + nub_event_t set_events = + ctx->Events().WaitForSetEvents(event_mask, &short_timeout); if (set_events & RNBContext::event_read_packet_available) { // If we get any packet from the debugger while waiting on the async, // it has to be telling us to interrupt. So always exit here. @@ -816,16 +816,16 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, // the methods to actually handle it are protected. It's not worth // rearranging all that just to get which packet we were sent... DNBLogError("Interrupted by packet while waiting for '%s' to appear.\n", - waitfor_process_name); +waitfor_process_name); break; } if (set_events & RNBContext::event_read_thread_exiting) { // The packet thread is shutting down, get out of here... DNBLogError("Interrupted by packet thread shutdown while waiting for " -"%s to appear.\n", waitfor_process_name); +"%s to appear.\n", +waitfor_process_name); break; } - } } `` https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
https://github.com/jimingham edited https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
https://github.com/junior-jl updated https://github.com/llvm/llvm-project/pull/69422 From 2c23aaf231beef11d3e0db6506fe82323a0be6a0 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/5] [lldb] colorize symbols in image lookup --- lldb/include/lldb/Core/Address.h | 7 ++- lldb/include/lldb/Symbol/Symbol.h | 4 +- lldb/include/lldb/Symbol/SymbolContext.h | 8 +-- lldb/source/Commands/CommandObjectTarget.cpp | 15 -- lldb/source/Core/Address.cpp | 53 --- lldb/source/Symbol/Symbol.cpp | 18 --- lldb/source/Symbol/SymbolContext.cpp | 16 -- .../Commands/command-image-lookup-color.test | 25 + 8 files changed, 114 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 b19e694427546f8..fac0ced910a11d4 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -246,8 +246,11 @@ 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; + + static void DumpName(Stream *strm, llvm::StringRef text, + const char *pattern = nullptr); AddressClass GetAddressClass() const; diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index 44a2d560010fe40..0e41cd95e0ef17d 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 b0f5ffead2a1656..9567c3f4384c175 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/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 8f052d0a7b837e2..a83575ad82d6909 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -8,6 +8,7 @@ #include "CommandObjectTarget.h" +#include "lldb/Core/Address.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" #include "lldb/Core/Module.h" @@ -1534,7 +1535,7 @@ static void DumpOsoFilesTable(Stream &strm, static void DumpAddress(ExecutionContextScope *exe_scope, const Address &so_addr, bool verbose, bool all_ranges, -Stream &strm) { +Stream &strm, const char *pattern = nullptr) { strm.IndentMore(); strm.Indent("Address: "); so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress); @@ -1544,13 +1545,14 @@ static void DumpAddress(ExecutionContextScope *exe_scope, strm.Indent("Summary: "); const uint32_t save_indent = strm.GetIndentLevel(); strm.SetIndentLevel(save_indent + 13); - so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription); + so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription, + Address::DumpStyleInvalid, UINT32_MAX, false, pattern); strm.SetIndentLevel(save_indent)
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
https://github.com/jasonmolenda approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/72565 ___ 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] [lldb] [compiler-rt] [flang] [clang] [mlir] [Profile] Add binary profile correlation for code coverage. (PR #69493)
ZequanWu wrote: > Some further discussion/pre-work needed before proceeding with this PR. These two discussions are addressed and this is ready to be reviewed. 1. Support for merging with multiple correlation files will be done in a separate change. 2. Removed the `VARIANT_MASK_BIN_CORRELATE` and runtime check for it to determine if name/data sections should be skipped. Instead, new section names are used (`__llvm_covdata` and `__llvm_covnames`). https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
@@ -799,7 +799,33 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, break; } - ::usleep(waitfor_interval); // Sleep for WAITFOR_INTERVAL, then poll again + // Now we're going to wait a while before polling again. But we also + // need to check whether we've gotten an event from the debugger + // telling us to interrupt the wait. So we'll use the wait for a possible + // next event to also be our short pause... + struct timespec short_timeout; + DNBTimer::OffsetTimeOfDay(&short_timeout, 0, waitfor_interval); + uint32_t event_mask = RNBContext::event_read_packet_available + | RNBContext::event_read_thread_exiting; + nub_event_t set_events = ctx->Events().WaitForSetEvents(event_mask, + &short_timeout); + if (set_events & RNBContext::event_read_packet_available) { +// If we get any packet from the debugger while waiting on the async, +// it has to be telling us to interrupt. So always exit here. +// Over here in DNB land we can see that there was a packet, but all +// the methods to actually handle it are protected. It's not worth +// rearranging all that just to get which packet we were sent... +DNBLogError("Interrupted by packet while waiting for '%s' to appear.\n", JDevlieghere wrote: Can we check the packet and assert/log when it's not an interrupt? I know that's technically not allowed by the GDB remote protocol, but that would make it easy to catch such a mistake. https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
@@ -3843,6 +3843,13 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) { ") woke up with an interrupt while attaching - " "forwarding interrupt.", __FUNCTION__, static_cast(this), GetID()); +// The server may be spinning waiting for a process to appear, in which +// case we should tell it to stop doing that. Normally, we don't NEED +// to do that because we will next close the communication to the stub +// and that will get it to shut down. But there are remote debugging +// cases where relying on that side-effect causes the shutdown to be +// flakey, so we should send a positive signal to interrupt the wait. +Status error = HaltPrivate(); JDevlieghere wrote: Should we log the return value? https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] [llvm] [clang-tools-extra] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -627,7 +628,7 @@ class Target : public std::enable_shared_from_this, // used. const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, - const FileSpec *crash_file, + lldb::FileSP crash_file, bool can_connect); GeorgeHuyubo wrote: If we move the open file code into Target.cpp, it's hard to handle error. Now in these 4 locations we have slightly different ways to report the error when the file is failed to open. ``` if (!file) { result.AppendErrorWithFormatv( "Failed to open the core file '{0}': '{1}.'\n", core_file.GetPath(), llvm::toString(file.takeError())); } ``` https://github.com/llvm/llvm-project/pull/71769 ___ 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] [clang] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/GeorgeHuyubo edited https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Clarify error messages on corefiles that no plugin handles (PR #72559)
https://github.com/medismailben approved this pull request. Makes sense. LGTM! https://github.com/llvm/llvm-project/pull/72559 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5f64b94 - Clarify error messages on corefiles that no plugin handles (#72559)
Author: Jason Molenda Date: 2023-11-16T13:58:07-08:00 New Revision: 5f64b940761002efcff04c40d6e882167d05197c URL: https://github.com/llvm/llvm-project/commit/5f64b940761002efcff04c40d6e882167d05197c DIFF: https://github.com/llvm/llvm-project/commit/5f64b940761002efcff04c40d6e882167d05197c.diff LOG: Clarify error messages on corefiles that no plugin handles (#72559) These error messages are written in a way that makes sense to an lldb developer, but not to an end user who asks lldb to run on a compressed corefile or whatever. Simplfy the messages. Added: Modified: lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Core/IOHandlerCursesGUI.cpp lldb/test/API/commands/target/basic/TestTargetCommand.py Removed: diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 8f052d0a7b837e2..58785cde3ec7c63 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -436,8 +436,7 @@ class CommandObjectTargetCreate : public CommandObjectParsed { error = process_sp->LoadCore(); if (error.Fail()) { -result.AppendError( -error.AsCString("can't find plug-in for core file")); +result.AppendError(error.AsCString("unknown core file format")); return; } else { result.AppendMessageWithFormatv( @@ -447,9 +446,8 @@ class CommandObjectTargetCreate : public CommandObjectParsed { on_error.release(); } } else { - result.AppendErrorWithFormatv( - "Unable to find process plug-in for core file '{0}'\n", - core_file.GetPath()); + result.AppendErrorWithFormatv("Unknown core file format '{0}'\n", +core_file.GetPath()); } } else { result.AppendMessageWithFormat( diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index 22b8cc3582eae78..abf0b6b801f37fc 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -3178,13 +3178,13 @@ class TargetCreateFormDelegate : public FormDelegate { m_debugger.GetListener(), llvm::StringRef(), &core_file_spec, false)); if (!process_sp) { - SetError("Unable to find process plug-in for core file!"); + SetError("Unknown core file format!"); return; } Status status = process_sp->LoadCore(); if (status.Fail()) { - SetError("Can't find plug-in for core file!"); + SetError("Unknown core file format!"); return; } } diff --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py b/lldb/test/API/commands/target/basic/TestTargetCommand.py index 96e7fe86ac5aee5..cb7a5f33f6643e8 100644 --- a/lldb/test/API/commands/target/basic/TestTargetCommand.py +++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py @@ -447,7 +447,7 @@ def test_target_create_invalid_core_file(self): self.expect( "target create -c '" + invalid_core_path + "'", error=True, -substrs=["Unable to find process plug-in for core file '"], +substrs=["Unknown core file format '"], ) # Write only files don't seem to be supported on Windows. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Clarify error messages on corefiles that no plugin handles (PR #72559)
https://github.com/jasonmolenda closed https://github.com/llvm/llvm-project/pull/72559 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
@@ -3843,6 +3843,13 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) { ") woke up with an interrupt while attaching - " "forwarding interrupt.", __FUNCTION__, static_cast(this), GetID()); +// The server may be spinning waiting for a process to appear, in which +// case we should tell it to stop doing that. Normally, we don't NEED +// to do that because we will next close the communication to the stub +// and that will get it to shut down. But there are remote debugging +// cases where relying on that side-effect causes the shutdown to be +// flakey, so we should send a positive signal to interrupt the wait. +Status error = HaltPrivate(); jimingham wrote: Sure, I'll add that. https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
@@ -799,7 +799,33 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, break; } - ::usleep(waitfor_interval); // Sleep for WAITFOR_INTERVAL, then poll again + // Now we're going to wait a while before polling again. But we also + // need to check whether we've gotten an event from the debugger + // telling us to interrupt the wait. So we'll use the wait for a possible + // next event to also be our short pause... + struct timespec short_timeout; + DNBTimer::OffsetTimeOfDay(&short_timeout, 0, waitfor_interval); + uint32_t event_mask = RNBContext::event_read_packet_available + | RNBContext::event_read_thread_exiting; + nub_event_t set_events = ctx->Events().WaitForSetEvents(event_mask, + &short_timeout); + if (set_events & RNBContext::event_read_packet_available) { +// If we get any packet from the debugger while waiting on the async, +// it has to be telling us to interrupt. So always exit here. +// Over here in DNB land we can see that there was a packet, but all +// the methods to actually handle it are protected. It's not worth +// rearranging all that just to get which packet we were sent... +DNBLogError("Interrupted by packet while waiting for '%s' to appear.\n", jimingham wrote: All the code that does the actual packet handling (as opposed to just waiting for a packet type) is private to RNBRemote.cpp, and not available here. I didn't think getting the packet here was worth rejiggering that relationship. You can turn on packet logging in debugserver if you wanted to see which packet this was. https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/GeorgeHuyubo updated https://github.com/llvm/llvm-project/pull/71769 >From be239ec76a426b6909b84b796785c7e1a9fe84aa Mon Sep 17 00:00:00 2001 From: George Hu Date: Wed, 8 Nov 2023 16:25:34 -0800 Subject: [PATCH] Add new API in SBTarget for loading core from SBFile --- lldb/include/lldb/API/SBTarget.h | 1 + lldb/include/lldb/Target/PostMortemProcess.h | 15 lldb/include/lldb/Target/Process.h| 10 +- lldb/include/lldb/Target/ProcessTrace.h | 5 +-- lldb/include/lldb/Target/Target.h | 3 +- lldb/include/lldb/lldb-private-interfaces.h | 7 ++-- lldb/source/API/SBTarget.cpp | 34 +-- lldb/source/Commands/CommandObjectTarget.cpp | 11 +- lldb/source/Core/IOHandlerCursesGUI.cpp | 13 +-- .../FreeBSDKernel/ProcessFreeBSDKernel.cpp| 27 +-- .../FreeBSDKernel/ProcessFreeBSDKernel.h | 8 ++--- .../Process/MacOSX-Kernel/ProcessKDP.cpp | 4 +-- .../Process/MacOSX-Kernel/ProcessKDP.h| 9 ++--- .../Process/elf-core/ProcessElfCore.cpp | 22 ++-- .../Plugins/Process/elf-core/ProcessElfCore.h | 12 +++ .../Process/gdb-remote/ProcessGDBRemote.cpp | 9 ++--- .../Process/gdb-remote/ProcessGDBRemote.h | 3 +- .../Process/mach-core/ProcessMachCore.cpp | 23 +++-- .../Process/mach-core/ProcessMachCore.h | 11 +++--- .../Process/minidump/ProcessMinidump.cpp | 16 + .../Process/minidump/ProcessMinidump.h| 6 ++-- .../Process/scripted/ScriptedProcess.cpp | 2 +- .../Process/scripted/ScriptedProcess.h| 2 +- lldb/source/Target/Process.cpp| 11 +++--- lldb/source/Target/ProcessTrace.cpp | 11 +++--- lldb/source/Target/Target.cpp | 2 +- .../postmortem/elf-core/TestLinuxCore.py | 17 ++ .../Target/LocateModuleCallbackTest.cpp | 3 +- 28 files changed, 201 insertions(+), 96 deletions(-) diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 83087623088c5b4..afc949390ac3379 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -184,6 +184,7 @@ class LLDB_API SBTarget { SBProcess LoadCore(const char *core_file); SBProcess LoadCore(const char *core_file, lldb::SBError &error); + SBProcess LoadCore(SBFile &file, lldb::SBError &error); /// Launch a new process with sensible defaults. /// diff --git a/lldb/include/lldb/Target/PostMortemProcess.h b/lldb/include/lldb/Target/PostMortemProcess.h index 7207fc99ef29a41..2bd775c9e2c5196 100644 --- a/lldb/include/lldb/Target/PostMortemProcess.h +++ b/lldb/include/lldb/Target/PostMortemProcess.h @@ -10,6 +10,8 @@ #define LLDB_TARGET_POSTMORTEMPROCESS_H #include "lldb/Target/Process.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-forward.h" namespace lldb_private { @@ -24,7 +26,20 @@ class PostMortemProcess : public Process { using Process::Process; public: + PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, +lldb::FileSP file_sp) + : Process(target_sp, listener_sp), m_core_file(file_sp) {} + bool IsLiveDebugSession() const override { return false; } + + FileSpec GetCoreFile() const override { +FileSpec file_spec; +m_core_file->GetFileSpec(file_spec); +return file_spec; + } + +protected: + lldb::FileSP m_core_file; }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index a6d3e6c2d16926e..6e2cafbfce9698e 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -52,6 +52,7 @@ #include "lldb/Utility/TraceGDBRemotePackets.h" #include "lldb/Utility/UnimplementedError.h" #include "lldb/Utility/UserIDResolver.h" +#include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" #include "llvm/ADT/ArrayRef.h" @@ -507,7 +508,7 @@ class Process : public std::enable_shared_from_this, static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp, llvm::StringRef plugin_name, lldb::ListenerSP listener_sp, -const FileSpec *crash_file_path, +lldb::FileSP crash_file_sp, bool can_connect); /// Static function that can be used with the \b host function @@ -1469,6 +1470,13 @@ class Process : public std::enable_shared_from_this, virtual bool IsLiveDebugSession() const { return true; }; + /// Provide a way to retrieve the core dump file that is loaded for debugging. + /// Only available if IsLiveDebugSession() returns false. + /// + /// \return + /// File path to the core file. + virtual FileSpec GetCoreFile() const { return {}; } + /// Before lldb detaches from a process, it warns the user that they are /// about to lo
[Lldb-commits] [lldb] 4639610 - [lldb] Add interface to check if UserExpression::Parse() is cacheable (#66826)
Author: Augusto Noronha Date: 2023-11-16T14:20:14-08:00 New Revision: 46396108deb24564159c441c6e6ebfac26714d7b URL: https://github.com/llvm/llvm-project/commit/46396108deb24564159c441c6e6ebfac26714d7b DIFF: https://github.com/llvm/llvm-project/commit/46396108deb24564159c441c6e6ebfac26714d7b.diff LOG: [lldb] Add interface to check if UserExpression::Parse() is cacheable (#66826) When setting conditional breakpoints, we currently assume that a call to UserExpression::Parse() can be cached and resued multiple times. This may not be true for every user expression. Add a new method so subclasses of UserExpression can customize if they are parseable or not. Added: Modified: lldb/include/lldb/Expression/UserExpression.h lldb/source/Breakpoint/BreakpointLocation.cpp Removed: diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h index df7a76664f6d5b6..b6cfeec7e899330 100644 --- a/lldb/include/lldb/Expression/UserExpression.h +++ b/lldb/include/lldb/Expression/UserExpression.h @@ -192,6 +192,14 @@ class UserExpression : public Expression { /// expression. Text() should contain the definition of this function. const char *FunctionName() override { return "$__lldb_expr"; } + /// Returns whether the call to Parse on this user expression is cacheable. + /// This function exists to provide an escape hatch for supporting languages + /// where parsing an expression in the exact same context is unsafe. For + /// example, languages where generic functions aren't monomorphized, but + /// implement some other mechanism to represent generic values, may be unsafe + /// to cache, as the concrete type substitution may be diff erent in every + /// expression evaluation. + virtual bool IsParseCacheable() { return true; } /// Return the language that should be used when parsing. To use the /// default, return eLanguageTypeUnknown. lldb::LanguageType Language() const override { return m_language; } diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 27dc7458dc26f70..931e1ad4b2d9339 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -250,6 +250,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx, DiagnosticManager diagnostics; if (condition_hash != m_condition_hash || !m_user_expression_sp || + !m_user_expression_sp->IsParseCacheable() || !m_user_expression_sp->MatchesContext(exe_ctx)) { LanguageType language = eLanguageTypeUnknown; // See if we can figure out the language from the frame, otherwise use the ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add interface to check if UserExpression::Parse() is cacheable (PR #66826)
https://github.com/augusto2112 closed https://github.com/llvm/llvm-project/pull/66826 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add --copyExecutable and --ignoreNegativeCache to dsymForUUID invoke (PR #72579)
https://github.com/jasonmolenda created https://github.com/llvm/llvm-project/pull/72579 On macOS lldb normally goes through the DebugSymbols framework to find dSYMs -- by spotlight search on the local computer, or specially laid out directories, or possibly calling a program which can download the dSYM and/or executable to the local computer and return paths to those in a plist (xml). For certain special debug scenarios, we have an additional mechanism where we force a download if we have a local utility, instead of making the user enable expensive downloads for all binaries in all debug sessions. This is all done in SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile where we invoke this dsymForUUID utility with --copyExecutable and --ignoreNegativeCache. This patch updates crashlog.py to invoke this utility the same way if it is available. rdar://118480731 >From 0b2c3c09f8049cc111ad5de071337872f355dd31 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Thu, 16 Nov 2023 14:02:01 -0800 Subject: [PATCH] Add --copyExecutable and --ignoreNegativeCache to dsymForUUID invoke On macOS lldb normally goes through the DebugSymbols framework to find dSYMs -- by spotlight search on the local computer, or specially laid out directories, or possibly calling a program which can download the dSYM and/or executable to the local computer and return paths to those in a plist (xml). For certain special debug scenarios, we have an additional mechanism where we force a download if we have a local utility, instead of making the user enable expensive downloads for all binaries in all debug sessions. This is all done in SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile where we invoke this dsymForUUID utility with --copyExecutable and --ignoreNegativeCache. This patch updates crashlog.py to invoke this utility the same way if it is available. --- lldb/examples/python/crashlog.py | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index cb8008419404c23..97649bb677cb1f8 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -356,7 +356,10 @@ def locate_module_and_debug_symbols(self): # Keep track of unresolved source paths. unavailable_source_paths = set() if os.path.exists(self.dsymForUUIDBinary): -dsym_for_uuid_command = "%s %s" % (self.dsymForUUIDBinary, uuid_str) +dsym_for_uuid_command = ( +"%s --copyExecutable --ignoreNegativeCache %s" +% (self.dsymForUUIDBinary, uuid_str) +) s = subprocess.check_output(dsym_for_uuid_command, shell=True) if s: try: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add --copyExecutable and --ignoreNegativeCache to dsymForUUID invoke (PR #72579)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changes On macOS lldb normally goes through the DebugSymbols framework to find dSYMs -- by spotlight search on the local computer, or specially laid out directories, or possibly calling a program which can download the dSYM and/or executable to the local computer and return paths to those in a plist (xml). For certain special debug scenarios, we have an additional mechanism where we force a download if we have a local utility, instead of making the user enable expensive downloads for all binaries in all debug sessions. This is all done in SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile where we invoke this dsymForUUID utility with --copyExecutable and --ignoreNegativeCache. This patch updates crashlog.py to invoke this utility the same way if it is available. rdar://118480731 --- Full diff: https://github.com/llvm/llvm-project/pull/72579.diff 1 Files Affected: - (modified) lldb/examples/python/crashlog.py (+4-1) ``diff diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index cb8008419404c23..97649bb677cb1f8 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -356,7 +356,10 @@ def locate_module_and_debug_symbols(self): # Keep track of unresolved source paths. unavailable_source_paths = set() if os.path.exists(self.dsymForUUIDBinary): -dsym_for_uuid_command = "%s %s" % (self.dsymForUUIDBinary, uuid_str) +dsym_for_uuid_command = ( +"%s --copyExecutable --ignoreNegativeCache %s" +% (self.dsymForUUIDBinary, uuid_str) +) s = subprocess.check_output(dsym_for_uuid_command, shell=True) if s: try: `` https://github.com/llvm/llvm-project/pull/72579 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Send an explicit interrupt to cancel an attach waitfor. (PR #72565)
@@ -799,7 +799,33 @@ DNBProcessAttachWait(RNBContext *ctx, const char *waitfor_process_name, break; } - ::usleep(waitfor_interval); // Sleep for WAITFOR_INTERVAL, then poll again + // Now we're going to wait a while before polling again. But we also + // need to check whether we've gotten an event from the debugger + // telling us to interrupt the wait. So we'll use the wait for a possible + // next event to also be our short pause... + struct timespec short_timeout; + DNBTimer::OffsetTimeOfDay(&short_timeout, 0, waitfor_interval); + uint32_t event_mask = RNBContext::event_read_packet_available + | RNBContext::event_read_thread_exiting; + nub_event_t set_events = ctx->Events().WaitForSetEvents(event_mask, + &short_timeout); + if (set_events & RNBContext::event_read_packet_available) { +// If we get any packet from the debugger while waiting on the async, +// it has to be telling us to interrupt. So always exit here. +// Over here in DNB land we can see that there was a packet, but all +// the methods to actually handle it are protected. It's not worth +// rearranging all that just to get which packet we were sent... +DNBLogError("Interrupted by packet while waiting for '%s' to appear.\n", jasonmolenda wrote: The structure of the gdb remote protocol is such that when you've sent a packet, you can't send anything else until you get a response. "continue" is special in that you can send ^C to the remote stub to interrupt execution. A "waitfor" attach request most reasonably behaves the same as "continue" - the only thing it would make any sense for the debugger to send when we're waiting is ^C. If the debugger were to send anything else, yeah, something has gone very wrong, but when Jim described the layering and how it wasn't straightforward to check that, I didn't push further, it seemed fine to me to assume the debugger didn't do something unsupported like send a non-interrupt packet. https://github.com/llvm/llvm-project/pull/72565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [clang] [lldb] [llvm] [libcxx] [lld] [mlir] [clang-tools-extra] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)
ldionne wrote: Gentle ping. There's outstanding feedback to address on this review. @ZijunZhaoCCK if you don't think you'll have time to pursue this PR anymore, it's all good but please let us know so we can assign it to someone else! https://github.com/llvm/llvm-project/pull/66963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
https://github.com/clayborg edited 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] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -62,15 +66,23 @@ bool canUseDebuginfod() { } SmallVector getDefaultDebuginfodUrls() { - const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); - if (DebuginfodUrlsEnv == nullptr) -return SmallVector(); - - SmallVector DebuginfodUrls; - StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " "); + if (!DebuginfodUrlsSet) { clayborg wrote: If we use std::optional above, then this can be: ``` if (!DebuginfodUrls) { ``` 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] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -62,15 +66,23 @@ bool canUseDebuginfod() { } SmallVector getDefaultDebuginfodUrls() { - const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); - if (DebuginfodUrlsEnv == nullptr) -return SmallVector(); - - SmallVector DebuginfodUrls; - StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " "); + if (!DebuginfodUrlsSet) { +// Only read from the environment variable if the user hasn't already +// set the value +if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS")) + StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ", -1, false); +DebuginfodUrlsSet = true; + } return DebuginfodUrls; } +// Set the default debuginfod URL list, override the environment variable +void setDefaultDebuginfodUrls(SmallVector URLs) { + DebuginfodUrls.clear(); + DebuginfodUrls.insert(DebuginfodUrls.begin(), URLs.begin(), URLs.end()); + DebuginfodUrlsSet = true; clayborg wrote: If we use std::optional this becomes: ``` DebuginfodUrls = URLs; ``` And the std::optional will have a new value and the value will be set. 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] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -62,15 +66,23 @@ bool canUseDebuginfod() { } SmallVector getDefaultDebuginfodUrls() { - const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); - if (DebuginfodUrlsEnv == nullptr) -return SmallVector(); - - SmallVector DebuginfodUrls; - StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " "); + if (!DebuginfodUrlsSet) { +// Only read from the environment variable if the user hasn't already +// set the value +if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS")) + StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ", -1, false); +DebuginfodUrlsSet = true; clayborg wrote: If we use std::optional, this can be: ``` DebuginfodUrls = SmallVector(); if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS")) StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls.value(), " ", -1, false); ``` 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] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -46,6 +46,10 @@ bool canUseDebuginfod(); /// environment variable. SmallVector getDefaultDebuginfodUrls(); +/// Sets the list of debuginfod server URLs to query. This overrides the +/// environment variable DEBUGINFOD_URLS. +void setDefaultDebuginfodUrls(SmallVector URLs); clayborg wrote: pass in a const reference to avoid copying on calling this?: ``` void setDefaultDebuginfodUrls(const SmallVector &URLs); ``` 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] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
https://github.com/clayborg commented: Looks good, a few suggestions in `llvm/lib/Debuginfod/Debuginfod.cpp`. I will let Jonas comment if the settings are done the right way in the plug-in manager. Plug-in code looks fine. 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] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -47,6 +47,10 @@ namespace llvm { using llvm::object::BuildIDRef; +SmallVector DebuginfodUrls; clayborg wrote: Maybe make this `std::optional< SmallVector >` and get rid of `DebuginfodUrlsSet` below? We might want a std::mutex here to protect multi-threaded access to the `DebuginfodUrls` variable. 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] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/GeorgeHuyubo updated https://github.com/llvm/llvm-project/pull/71769 >From 0037db8a5753e19726c56a4d8a968685860fe4e8 Mon Sep 17 00:00:00 2001 From: George Hu Date: Thu, 16 Nov 2023 15:46:33 -0800 Subject: [PATCH] Add new API in SBTarget for loading core from SBFile --- lldb/include/lldb/API/SBTarget.h | 1 + lldb/source/API/SBTarget.cpp | 26 +++ .../postmortem/elf-core/TestLinuxCore.py | 19 ++ 3 files changed, 46 insertions(+) diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 83087623088c5b4..afc949390ac3379 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -184,6 +184,7 @@ class LLDB_API SBTarget { SBProcess LoadCore(const char *core_file); SBProcess LoadCore(const char *core_file, lldb::SBError &error); + SBProcess LoadCore(SBFile &file, lldb::SBError &error); /// Launch a new process with sensible defaults. /// diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2d029554492a05c..90afe5808e914c4 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -16,6 +16,7 @@ #include "lldb/API/SBEnvironment.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExpressionOptions.h" +#include "lldb/API/SBFile.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" @@ -260,6 +261,31 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { return sb_process; } +SBProcess SBTarget::LoadCore(SBFile &file, lldb::SBError &error) { + LLDB_INSTRUMENT_VA(this, file, error); + + SBProcess sb_process; + TargetSP target_sp(GetSP()); + if (target_sp) { +FileSP file_sp = file.GetFile(); +FileSpec filespec; +file_sp->GetFileSpec(filespec); +FileSystem::Instance().Resolve(filespec); +ProcessSP process_sp(target_sp->CreateProcess( +target_sp->GetDebugger().GetListener(), "", &filespec, false)); +if (process_sp) { + error.SetError(process_sp->LoadCore()); + if (error.Success()) +sb_process.SetSP(process_sp); +} else { + error.SetErrorString("Failed to create the process"); +} + } else { +error.SetErrorString("SBTarget is invalid"); + } + return sb_process; +} + SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp, const char *working_directory) { LLDB_INSTRUMENT_VA(this, argv, envp, working_directory); diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index a083fab18eabcbc..7dd2245843c6c8f 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -53,6 +53,12 @@ def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions, "a.out") +@skipIfLLVMTargetMissing("X86") +def test_x86_64_fd(self): +"""Test that lldb can read the process information from an x86_64 linux core file.""" +self.do_test_fd("linux-x86_64", self._x86_64_pid, self._x86_64_regions, "a.out") + + @skipIfLLVMTargetMissing("SystemZ") def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" @@ -752,6 +758,19 @@ def do_test(self, filename, pid, region_count, thread_name): self.dbg.DeleteTarget(target) +def do_test_fd(self, filename, pid, region_count, thread_name): +file_object = open(filename + ".core", "r") +fd = file_object.fileno() +file = lldb.SBFile(fd, "r", True) +target = self.dbg.CreateTarget(filename + ".out") +error = lldb.SBError() +process = target.LoadCore(file, error) + +self.check_all(process, pid, region_count, thread_name) + +self.dbg.DeleteTarget(target) + + def replace_path(binary, replace_from, replace_to): src = replace_from.encode() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/GeorgeHuyubo updated https://github.com/llvm/llvm-project/pull/71769 >From 8aa5348b7ad6491c9363c0fcd41668e2e8ccda1a Mon Sep 17 00:00:00 2001 From: George Hu Date: Thu, 16 Nov 2023 15:46:33 -0800 Subject: [PATCH] Add new API in SBTarget for loading core from SBFile --- lldb/include/lldb/API/SBTarget.h | 1 + lldb/source/API/SBTarget.cpp | 26 +++ .../postmortem/elf-core/TestLinuxCore.py | 18 + 3 files changed, 45 insertions(+) diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 83087623088c5b4..afc949390ac3379 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -184,6 +184,7 @@ class LLDB_API SBTarget { SBProcess LoadCore(const char *core_file); SBProcess LoadCore(const char *core_file, lldb::SBError &error); + SBProcess LoadCore(SBFile &file, lldb::SBError &error); /// Launch a new process with sensible defaults. /// diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2d029554492a05c..90afe5808e914c4 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -16,6 +16,7 @@ #include "lldb/API/SBEnvironment.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExpressionOptions.h" +#include "lldb/API/SBFile.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" @@ -260,6 +261,31 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { return sb_process; } +SBProcess SBTarget::LoadCore(SBFile &file, lldb::SBError &error) { + LLDB_INSTRUMENT_VA(this, file, error); + + SBProcess sb_process; + TargetSP target_sp(GetSP()); + if (target_sp) { +FileSP file_sp = file.GetFile(); +FileSpec filespec; +file_sp->GetFileSpec(filespec); +FileSystem::Instance().Resolve(filespec); +ProcessSP process_sp(target_sp->CreateProcess( +target_sp->GetDebugger().GetListener(), "", &filespec, false)); +if (process_sp) { + error.SetError(process_sp->LoadCore()); + if (error.Success()) +sb_process.SetSP(process_sp); +} else { + error.SetErrorString("Failed to create the process"); +} + } else { +error.SetErrorString("SBTarget is invalid"); + } + return sb_process; +} + SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp, const char *working_directory) { LLDB_INSTRUMENT_VA(this, argv, envp, working_directory); diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index a083fab18eabcbc..4a638c99985c3dd 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -53,6 +53,11 @@ def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions, "a.out") +@skipIfLLVMTargetMissing("X86") +def test_x86_64_fd(self): +"""Test that lldb can read the process information from an x86_64 linux core file.""" +self.do_test_fd("linux-x86_64", self._x86_64_pid, self._x86_64_regions, "a.out") + @skipIfLLVMTargetMissing("SystemZ") def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" @@ -752,6 +757,19 @@ def do_test(self, filename, pid, region_count, thread_name): self.dbg.DeleteTarget(target) +def do_test_fd(self, filename, pid, region_count, thread_name): +file_object = open(filename + ".core", "r") +fd = file_object.fileno() +file = lldb.SBFile(fd, "r", True) +target = self.dbg.CreateTarget(filename + ".out") +error = lldb.SBError() +process = target.LoadCore(file, error) + +self.check_all(process, pid, region_count, thread_name) + +self.dbg.DeleteTarget(target) + + def replace_path(binary, replace_from, replace_to): src = replace_from.encode() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [flang] [clang] [lldb] [libcxx] [openmp] [mlir] [libc] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
@@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; arsenm wrote: Was this really just completely backwards? https://github.com/llvm/llvm-project/pull/72522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [libcxx] [openmp] [libc] [mlir] [clang] [llvm] [flang] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
@@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 { entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 - %cond0 = and i1 %cmp0, %cmp1 + %cond0 = or i1 %cmp0, %cmp1 br i1 %cond0, label %b0, label %b1 b0:; preds = %entry %cmp2 = icmp eq i32 %in_a, 0 %cmp3 = icmp ne i32 %in_a, 1 - %cond1 = or i1 %cmp2, %cmp3 arsenm wrote: Why is this changing the original test? I would expect additional tests, and updates to the existing functions https://github.com/llvm/llvm-project/pull/72522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add --copyExecutable and --ignoreNegativeCache to dsymForUUID invoke (PR #72579)
https://github.com/bulbazord approved this pull request. Awesome! https://github.com/llvm/llvm-project/pull/72579 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/bulbazord approved this pull request. LGTM I think, but wait a little bit for Jonas and/or Greg to give it another pass. https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -184,6 +184,7 @@ class LLDB_API SBTarget { SBProcess LoadCore(const char *core_file); SBProcess LoadCore(const char *core_file, lldb::SBError &error); + SBProcess LoadCore(SBFile &file, lldb::SBError &error); bulbazord wrote: Actually, can the `SBFile &` be marked `const`? This shouldn't modify the SBFile if I'm reading this correctly. https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/GeorgeHuyubo updated https://github.com/llvm/llvm-project/pull/71769 >From 749453ae9878dbc38c49db3a3086882ae886d849 Mon Sep 17 00:00:00 2001 From: George Hu Date: Thu, 16 Nov 2023 15:46:33 -0800 Subject: [PATCH] Add new API in SBTarget for loading core from SBFile --- lldb/include/lldb/API/SBTarget.h | 1 + lldb/source/API/SBTarget.cpp | 26 +++ .../postmortem/elf-core/TestLinuxCore.py | 18 + 3 files changed, 45 insertions(+) diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 83087623088c5b4..8e44cd5513c5b20 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -184,6 +184,7 @@ class LLDB_API SBTarget { SBProcess LoadCore(const char *core_file); SBProcess LoadCore(const char *core_file, lldb::SBError &error); + SBProcess LoadCore(const SBFile &file, lldb::SBError &error); /// Launch a new process with sensible defaults. /// diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 2d029554492a05c..9632627e3cefc42 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -16,6 +16,7 @@ #include "lldb/API/SBEnvironment.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExpressionOptions.h" +#include "lldb/API/SBFile.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" @@ -260,6 +261,31 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { return sb_process; } +SBProcess SBTarget::LoadCore(const SBFile &file, lldb::SBError &error) { + LLDB_INSTRUMENT_VA(this, file, error); + + SBProcess sb_process; + TargetSP target_sp(GetSP()); + if (target_sp) { +FileSP file_sp = file.GetFile(); +FileSpec filespec; +file_sp->GetFileSpec(filespec); +FileSystem::Instance().Resolve(filespec); +ProcessSP process_sp(target_sp->CreateProcess( +target_sp->GetDebugger().GetListener(), "", &filespec, false)); +if (process_sp) { + error.SetError(process_sp->LoadCore()); + if (error.Success()) +sb_process.SetSP(process_sp); +} else { + error.SetErrorString("Failed to create the process"); +} + } else { +error.SetErrorString("SBTarget is invalid"); + } + return sb_process; +} + SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp, const char *working_directory) { LLDB_INSTRUMENT_VA(this, argv, envp, working_directory); diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index a083fab18eabcbc..4a638c99985c3dd 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -53,6 +53,11 @@ def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions, "a.out") +@skipIfLLVMTargetMissing("X86") +def test_x86_64_fd(self): +"""Test that lldb can read the process information from an x86_64 linux core file.""" +self.do_test_fd("linux-x86_64", self._x86_64_pid, self._x86_64_regions, "a.out") + @skipIfLLVMTargetMissing("SystemZ") def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" @@ -752,6 +757,19 @@ def do_test(self, filename, pid, region_count, thread_name): self.dbg.DeleteTarget(target) +def do_test_fd(self, filename, pid, region_count, thread_name): +file_object = open(filename + ".core", "r") +fd = file_object.fileno() +file = lldb.SBFile(fd, "r", True) +target = self.dbg.CreateTarget(filename + ".out") +error = lldb.SBError() +process = target.LoadCore(file, error) + +self.check_all(process, pid, region_count, thread_name) + +self.dbg.DeleteTarget(target) + + def replace_path(binary, replace_from, replace_to): src = replace_from.encode() ___ 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] [clang] [llvm] [compiler-rt] [libcxx] [lld] [mlir] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)
@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) { registerLLVMDialectTranslation(registry); registerNVVMDialectTranslation(registry); registerROCDLDialectTranslation(registry); + registerSPIRVDialectTranslation(registry); joker-eph wrote: Trying to understand... What is the unit test that requires this? https://github.com/llvm/llvm-project/pull/71430 ___ 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] [clang] [llvm] [compiler-rt] [libcxx] [lld] [mlir] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)
@@ -0,0 +1,31 @@ +//===- SPIRVToLLVMIRTranslation.cpp - Translate SPIRV to LLVM IR --===// +// +// 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 +// +//===--===// +// +// This file implements a translation between the MLIR SPIRV dialect and +// LLVM IR. +// +//===--===// + +#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h" +#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/Operation.h" +#include "mlir/Target/LLVMIR/ModuleTranslation.h" + +using namespace mlir; +using namespace mlir::LLVM; + +void mlir::registerSPIRVDialectTranslation(DialectRegistry ®istry) { + registry.insert(); joker-eph wrote: I'm confused here: there is no translation interface. https://github.com/llvm/llvm-project/pull/71430 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [openmp] [libcxx] [llvm] [clang] [libc] [lldb] [flang] [mlir] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
@@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; mahtohappy wrote: Even I had my doubts about it, but the testcase this issue had seems to give correct results on executions(output) with the changes and from my understanding the changes are correct. I'm hoping the the original author or reviewer will take a look. From my side, I'll try to regenerate all the patterns in the testcase in c file and execute and see if they're giving correct output on execution. https://github.com/llvm/llvm-project/pull/72522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [libunwind] [openmp] [libcxx] [llvm] [clang] [libc] [lldb] [compiler-rt] [flang] [mlir] [libcxxabi] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #7
https://github.com/mahtohappy updated https://github.com/llvm/llvm-project/pull/72522 >From ce4f4fc02e25359c8f38ff9ecf2a2d82aa90df72 Mon Sep 17 00:00:00 2001 From: mahtohappy Date: Thu, 16 Nov 2023 06:53:24 -0800 Subject: [PATCH 1/2] Fix Logical expression used for merged conditional if --- llvm/lib/Transforms/Utils/FlattenCFG.cpp | 8 llvm/test/Transforms/Util/flattencfg.ll | 22 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp b/llvm/lib/Transforms/Utils/FlattenCFG.cpp index 1925b91c4da7ec1..5f8cd12c1d50856 100644 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -436,9 +436,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { bool InvertCond2 = false; BinaryOperator::BinaryOps CombineOp; if (IfFalse1 == FirstEntryBlock) { -// The else-path is empty, so we must use "or" operation to combine the +// The then-path is empty, so we must use "and" operation to combine the // conditions. -CombineOp = BinaryOperator::Or; +CombineOp = BinaryOperator::And; if (IfFalse2 != SecondEntryBlock) { if (IfTrue2 != SecondEntryBlock) return false; @@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; if (IfTrue2 != SecondEntryBlock) { if (IfFalse2 != SecondEntryBlock) return false; diff --git a/llvm/test/Transforms/Util/flattencfg.ll b/llvm/test/Transforms/Util/flattencfg.ll index 4a4d4279f360d6a..0fd285be2715b80 100644 --- a/llvm/test/Transforms/Util/flattencfg.ll +++ b/llvm/test/Transforms/Util/flattencfg.ll @@ -10,12 +10,12 @@ define void @test_not_crash(i32 %in_a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[CMP0:%.*]] = icmp eq i32 [[IN_A]], -1 ; CHECK-NEXT:[[CMP1:%.*]] = icmp ne i32 [[IN_A]], 0 -; CHECK-NEXT:[[COND0:%.*]] = and i1 [[CMP0]], [[CMP1]] +; CHECK-NEXT:[[COND0:%.*]] = or i1 [[CMP0]], [[CMP1]] ; CHECK-NEXT:br i1 [[COND0]], label [[B0:%.*]], label [[B1:%.*]] ; CHECK: b0: ; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[IN_A]], 0 ; CHECK-NEXT:[[CMP3:%.*]] = icmp ne i32 [[IN_A]], 1 -; CHECK-NEXT:[[COND1:%.*]] = or i1 [[CMP2]], [[CMP3]] +; CHECK-NEXT:[[COND1:%.*]] = and i1 [[CMP2]], [[CMP3]] ; CHECK-NEXT:br i1 [[COND1]], label [[EXIT:%.*]], label [[B1]] ; CHECK: b1: ; CHECK-NEXT:br label [[EXIT]] @@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 { entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 - %cond0 = and i1 %cmp0, %cmp1 + %cond0 = or i1 %cmp0, %cmp1 br i1 %cond0, label %b0, label %b1 b0:; preds = %entry %cmp2 = icmp eq i32 %in_a, 0 %cmp3 = icmp ne i32 %in_a, 1 - %cond1 = or i1 %cmp2, %cmp3 + %cond1 = and i1 %cmp2, %cmp3 br i1 %cond1, label %exit, label %b1 b1: ; preds = %entry, %b0 @@ -47,7 +47,7 @@ define void @test_not_crash2(float %a, float %b) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[TMP0:%.*]] = fcmp ult float [[A]], 1.00e+00 ; CHECK-NEXT:[[TMP1:%.*]] = fcmp ult float [[B]], 1.00e+00 -; CHECK-NEXT:[[TMP2:%.*]] = and i1 [[TMP0]], [[TMP1]] +; CHECK-NEXT:[[TMP2:%.*]] = or i1 [[TMP0]], [[TMP1]] ; CHECK-NEXT:br i1 [[TMP2]], label [[BB4:%.*]], label [[BB3:%.*]] ; CHECK: bb3: ; CHECK-NEXT:br label [[BB4]] @@ -78,7 +78,7 @@ define void @test_not_crash3(i32 %a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0 ; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[A_EQ_0]], [[A_EQ_1]] ; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]] ; CHECK: bb2: ; CHECK-NEXT:br label [[BB3]] @@ -114,7 +114,7 @@ define void @test_then(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[CMP_X]], [[CMP_Y]] ; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]] ; CHECK: if.then.y: ; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4 @@ -148,7 +148,7 @@ define void @test_else(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp eq i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0 -; CHECK-NE
[Lldb-commits] [lld] [libunwind] [openmp] [libcxx] [llvm] [clang] [libc] [lldb] [compiler-rt] [flang] [mlir] [libcxxabi] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #7
https://github.com/mahtohappy updated https://github.com/llvm/llvm-project/pull/72522 >From ce4f4fc02e25359c8f38ff9ecf2a2d82aa90df72 Mon Sep 17 00:00:00 2001 From: mahtohappy Date: Thu, 16 Nov 2023 06:53:24 -0800 Subject: [PATCH 1/3] Fix Logical expression used for merged conditional if --- llvm/lib/Transforms/Utils/FlattenCFG.cpp | 8 llvm/test/Transforms/Util/flattencfg.ll | 22 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp b/llvm/lib/Transforms/Utils/FlattenCFG.cpp index 1925b91c4da7ec1..5f8cd12c1d50856 100644 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -436,9 +436,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { bool InvertCond2 = false; BinaryOperator::BinaryOps CombineOp; if (IfFalse1 == FirstEntryBlock) { -// The else-path is empty, so we must use "or" operation to combine the +// The then-path is empty, so we must use "and" operation to combine the // conditions. -CombineOp = BinaryOperator::Or; +CombineOp = BinaryOperator::And; if (IfFalse2 != SecondEntryBlock) { if (IfTrue2 != SecondEntryBlock) return false; @@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; if (IfTrue2 != SecondEntryBlock) { if (IfFalse2 != SecondEntryBlock) return false; diff --git a/llvm/test/Transforms/Util/flattencfg.ll b/llvm/test/Transforms/Util/flattencfg.ll index 4a4d4279f360d6a..0fd285be2715b80 100644 --- a/llvm/test/Transforms/Util/flattencfg.ll +++ b/llvm/test/Transforms/Util/flattencfg.ll @@ -10,12 +10,12 @@ define void @test_not_crash(i32 %in_a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[CMP0:%.*]] = icmp eq i32 [[IN_A]], -1 ; CHECK-NEXT:[[CMP1:%.*]] = icmp ne i32 [[IN_A]], 0 -; CHECK-NEXT:[[COND0:%.*]] = and i1 [[CMP0]], [[CMP1]] +; CHECK-NEXT:[[COND0:%.*]] = or i1 [[CMP0]], [[CMP1]] ; CHECK-NEXT:br i1 [[COND0]], label [[B0:%.*]], label [[B1:%.*]] ; CHECK: b0: ; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[IN_A]], 0 ; CHECK-NEXT:[[CMP3:%.*]] = icmp ne i32 [[IN_A]], 1 -; CHECK-NEXT:[[COND1:%.*]] = or i1 [[CMP2]], [[CMP3]] +; CHECK-NEXT:[[COND1:%.*]] = and i1 [[CMP2]], [[CMP3]] ; CHECK-NEXT:br i1 [[COND1]], label [[EXIT:%.*]], label [[B1]] ; CHECK: b1: ; CHECK-NEXT:br label [[EXIT]] @@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 { entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 - %cond0 = and i1 %cmp0, %cmp1 + %cond0 = or i1 %cmp0, %cmp1 br i1 %cond0, label %b0, label %b1 b0:; preds = %entry %cmp2 = icmp eq i32 %in_a, 0 %cmp3 = icmp ne i32 %in_a, 1 - %cond1 = or i1 %cmp2, %cmp3 + %cond1 = and i1 %cmp2, %cmp3 br i1 %cond1, label %exit, label %b1 b1: ; preds = %entry, %b0 @@ -47,7 +47,7 @@ define void @test_not_crash2(float %a, float %b) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[TMP0:%.*]] = fcmp ult float [[A]], 1.00e+00 ; CHECK-NEXT:[[TMP1:%.*]] = fcmp ult float [[B]], 1.00e+00 -; CHECK-NEXT:[[TMP2:%.*]] = and i1 [[TMP0]], [[TMP1]] +; CHECK-NEXT:[[TMP2:%.*]] = or i1 [[TMP0]], [[TMP1]] ; CHECK-NEXT:br i1 [[TMP2]], label [[BB4:%.*]], label [[BB3:%.*]] ; CHECK: bb3: ; CHECK-NEXT:br label [[BB4]] @@ -78,7 +78,7 @@ define void @test_not_crash3(i32 %a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0 ; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[A_EQ_0]], [[A_EQ_1]] ; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]] ; CHECK: bb2: ; CHECK-NEXT:br label [[BB3]] @@ -114,7 +114,7 @@ define void @test_then(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[CMP_X]], [[CMP_Y]] ; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]] ; CHECK: if.then.y: ; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4 @@ -148,7 +148,7 @@ define void @test_else(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp eq i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0 -; CHECK-NE
[Lldb-commits] [libcxxabi] [libunwind] [openmp] [flang] [lld] [libc] [mlir] [llvm] [lldb] [libcxx] [clang] [compiler-rt] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #7
@@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; arsenm wrote: The existing tests should not have the inputs changed. You should add new tests https://github.com/llvm/llvm-project/pull/72522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits