[Lldb-commits] [lldb] lldb/FreeBSD: Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
https://github.com/kiyolee created https://github.com/llvm/llvm-project/pull/97796 Supposingly this is a typo. >From dc56ef5d100525d48e7ecc86dc6bb65bceeea114 Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Fri, 5 Jul 2024 17:51:20 +1000 Subject: [PATCH] lldb/FreeBSD: Fix NativeRegisterContextFreeBSD_x86_64() declaration --- .../Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h index 54ec9fc154ca2..a522d850cb37d 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h +++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h @@ -38,7 +38,7 @@ class NativeRegisterContextFreeBSD_x86_64 public NativeRegisterContextDBReg_x86 { public: NativeRegisterContextFreeBSD_x86_64(const ArchSpec &target_arch, - NativeThreadProtocol &native_thread); + NativeThreadFreeBSD &native_thread); uint32_t GetRegisterSetCount() const override; const RegisterSet *GetRegisterSet(uint32_t set_index) const override; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb/FreeBSD: Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] lldb/FreeBSD: Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kelvin Lee (kiyolee) Changes Supposingly this is a typo. --- Full diff: https://github.com/llvm/llvm-project/pull/97796.diff 1 Files Affected: - (modified) lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h (+1-1) ``diff diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h index 54ec9fc154ca2..a522d850cb37d 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h +++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h @@ -38,7 +38,7 @@ class NativeRegisterContextFreeBSD_x86_64 public NativeRegisterContextDBReg_x86 { public: NativeRegisterContextFreeBSD_x86_64(const ArchSpec &target_arch, - NativeThreadProtocol &native_thread); + NativeThreadFreeBSD &native_thread); uint32_t GetRegisterSetCount() const override; const RegisterSet *GetRegisterSet(uint32_t set_index) const override; `` https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
https://github.com/DavidSpickett approved this pull request. Yes this is due to me only testing my changes on AArch64, thanks for the patch. https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
DavidSpickett wrote: Specifically changes from https://github.com/llvm/llvm-project/pull/85058. https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b3fa2a6 - [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (#97796)
Author: Kelvin Lee Date: 2024-07-05T09:05:05+01:00 New Revision: b3fa2a691ff7d5a85bc31fb428cd58d68bfecd10 URL: https://github.com/llvm/llvm-project/commit/b3fa2a691ff7d5a85bc31fb428cd58d68bfecd10 DIFF: https://github.com/llvm/llvm-project/commit/b3fa2a691ff7d5a85bc31fb428cd58d68bfecd10.diff LOG: [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (#97796) Supposingly this is a typo. Added: Modified: lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h Removed: diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h index 54ec9fc154ca2..a522d850cb37d 100644 --- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h +++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h @@ -38,7 +38,7 @@ class NativeRegisterContextFreeBSD_x86_64 public NativeRegisterContextDBReg_x86 { public: NativeRegisterContextFreeBSD_x86_64(const ArchSpec &target_arch, - NativeThreadProtocol &native_thread); + NativeThreadFreeBSD &native_thread); uint32_t GetRegisterSetCount() const override; const RegisterSet *GetRegisterSet(uint32_t set_index) const override; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Fix NativeRegisterContextFreeBSD_x86_64() declaration (PR #97796)
github-actions[bot] wrote: @kiyolee Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/97796 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/97754 >From b10f76bd6d02106e80315a70a7b72461cb6f2a99 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 13:35:21 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 149 - .../Plugins/Language/CPlusPlus/LibCxx.h | 54 + .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 196 ++ 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d4..feaa51a96843ab 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, - {"__value_", pair_type}}); -std::optional size = tree_node_type.GetByteSize(nullptr); -if (!size) - return lldb::ChildCacheState::eRefetch; -WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); -ProcessSP process_sp(target_sp->GetProcessSP()); -Status error; -process_sp->ReadMemory(addr, buffer_sp->GetBytes(), - buffer_sp->GetByteSize(), error); -if (error.Fail()) - return lldb::ChildCacheState::eRefetch
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/97754 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/97824 Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. >From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 5 Jul 2024 08:42:22 + Subject: [PATCH] [llvm][TargetParser] Return optional from getHostCPUFeatures Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. --- clang/lib/Driver/ToolChains/Arch/ARM.cpp | 6 ++-- clang/lib/Driver/ToolChains/Arch/X86.cpp | 6 ++-- lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++--- llvm/include/llvm/TargetParser/Host.h | 14 - llvm/lib/CodeGen/CommandFlags.cpp | 16 -- .../Orc/JITTargetMachineBuilder.cpp | 8 ++--- llvm/lib/Target/TargetMachineC.cpp| 5 ++-- llvm/lib/TargetParser/Host.cpp| 29 --- 8 files changed, 54 insertions(+), 51 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 8ae22cc37a1368..77adbf3865ab11 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, // Add CPU features for generic CPUs if (CPUName == "native") { -llvm::StringMap HostFeatures; -if (llvm::sys::getHostCPUFeatures(HostFeatures)) - for (auto &F : HostFeatures) +if (std::optional> HostFeatures = +llvm::sys::getHostCPUFeatures()) + for (auto &F : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } else if (!CPUName.empty()) { diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 92821b2a82daec..e4adfcac23ca0d 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple, // If -march=native, autodetect the feature list. if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { if (StringRef(A->getValue()) == "native") { - llvm::StringMap HostFeatures; - if (llvm::sys::getHostCPUFeatures(HostFeatures)) -for (auto &F : HostFeatures) + if (std::optional> HostFeatures = + llvm::sys::getHostCPUFeatures()) +for (auto &F : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp b/lldb/utils/lit-cpuid/lit-cpuid.cpp index be322cb6aa42a9..16743164e6a5d9 100644 --- a/lldb/utils/lit-cpuid/lit-cpuid.cpp +++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp @@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) + outs() << "sse\n"; +if ((*features)["avx"]) + outs() << "avx\n"; +if ((*features)["avx512f"]) + outs() << "avx512f\n"; + } else return 1; - - if (features["sse"]) -outs() << "sse\n"; - if (features["avx"]) -outs() << "avx\n"; - if (features["avx512f"]) -outs() << "avx512f\n"; #endif return 0; diff --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h index af72045a8fe67f..d68655835a3233 100644 --- a/llvm/include/llvm/TargetParser/Host.h +++ b/llvm/include/llvm/TargetParser/Host.h @@ -13,6 +13,7 @@ #ifndef LLVM_TARGETPARSER_HOST_H #define LLVM_TARGETPARSER_HOST_H +#include #include namespace llvm { @@ -47,13 +48,12 @@ namespace sys { /// The particular format of the names are target dependent, and suitable for /// passing as -mattr to the target which matches the host. /// - /// \param Features - A string mapping feature names to either - /// true (if enabled) or false (if disabled). This routine makes no guarantees - /// about exactly which features may appear in this map, except that they are - /// all valid LLVM feature names. - /// - /// \return - True on success. - bool getHostCPUFeatures(StringMap &Features); + /// \return - If feature detection succeeds, a string
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-clang-driver Author: David Spickett (DavidSpickett) Changes Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. --- Full diff: https://github.com/llvm/llvm-project/pull/97824.diff 8 Files Affected: - (modified) clang/lib/Driver/ToolChains/Arch/ARM.cpp (+3-3) - (modified) clang/lib/Driver/ToolChains/Arch/X86.cpp (+3-3) - (modified) lldb/utils/lit-cpuid/lit-cpuid.cpp (+11-10) - (modified) llvm/include/llvm/TargetParser/Host.h (+7-7) - (modified) llvm/lib/CodeGen/CommandFlags.cpp (+6-10) - (modified) llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp (+4-4) - (modified) llvm/lib/Target/TargetMachineC.cpp (+2-3) - (modified) llvm/lib/TargetParser/Host.cpp (+18-11) ``diff diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 8ae22cc37a136..77adbf3865ab1 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, // Add CPU features for generic CPUs if (CPUName == "native") { -llvm::StringMap HostFeatures; -if (llvm::sys::getHostCPUFeatures(HostFeatures)) - for (auto &F : HostFeatures) +if (std::optional> HostFeatures = +llvm::sys::getHostCPUFeatures()) + for (auto &F : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } else if (!CPUName.empty()) { diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 92821b2a82dae..e4adfcac23ca0 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple, // If -march=native, autodetect the feature list. if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { if (StringRef(A->getValue()) == "native") { - llvm::StringMap HostFeatures; - if (llvm::sys::getHostCPUFeatures(HostFeatures)) -for (auto &F : HostFeatures) + if (std::optional> HostFeatures = + llvm::sys::getHostCPUFeatures()) +for (auto &F : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp b/lldb/utils/lit-cpuid/lit-cpuid.cpp index be322cb6aa42a..16743164e6a5d 100644 --- a/lldb/utils/lit-cpuid/lit-cpuid.cpp +++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp @@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) + outs() << "sse\n"; +if ((*features)["avx"]) + outs() << "avx\n"; +if ((*features)["avx512f"]) + outs() << "avx512f\n"; + } else return 1; - - if (features["sse"]) -outs() << "sse\n"; - if (features["avx"]) -outs() << "avx\n"; - if (features["avx512f"]) -outs() << "avx512f\n"; #endif return 0; diff --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h index af72045a8fe67..d68655835a323 100644 --- a/llvm/include/llvm/TargetParser/Host.h +++ b/llvm/include/llvm/TargetParser/Host.h @@ -13,6 +13,7 @@ #ifndef LLVM_TARGETPARSER_HOST_H #define LLVM_TARGETPARSER_HOST_H +#include #include namespace llvm { @@ -47,13 +48,12 @@ namespace sys { /// The particular format of the names are target dependent, and suitable for /// passing as -mattr to the target which matches the host. /// - /// \param Features - A string mapping feature names to either - /// true (if enabled) or false (if disabled). This routine makes no guarantees - /// about exactly which features may appear in this map, except that they are - /// all valid LLVM feature names. - /// - /// \return - True on success. - bool getHostCPUFeatures(StringMap &Features); + /// \return - If feature detection succeeds, a string map mapping feature + /// names to either true (if enabled) or false (if disabled). This routine + /// makes no guarantees about exactly which features may appear in this map, + /// except that they are all valid LLVM feature names. If feature detection + /// fails, an empty optional is returned. + std::optional> getHostCPUFeatures(); /// This is a function compatible with cl::AddExtraV
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) tmatheson-arm wrote: Maybe ```suggestion if (features->lookup("sse")) ``` which does the same, but doesn't insert the default entry into the map. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -1710,15 +1710,17 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) -bool sys::getHostCPUFeatures(StringMap &Features) { +std::optional> sys::getHostCPUFeatures() { unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0; unsigned MaxLevel; if (getX86CpuIDAndInfo(0, &MaxLevel, &EBX, &ECX, &EDX) || MaxLevel < 1) -return false; +return {}; getX86CpuIDAndInfo(1, &EAX, &EBX, &ECX, &EDX); + StringMap Features; phoebewang wrote: IIUC, the motivation is to avoid creating a blank map. But here we still create it with each call. Is there any difference except early return in line 1728, which should rarely happend. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -1710,15 +1710,17 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) -bool sys::getHostCPUFeatures(StringMap &Features) { +std::optional> sys::getHostCPUFeatures() { unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0; unsigned MaxLevel; if (getX86CpuIDAndInfo(0, &MaxLevel, &EBX, &ECX, &EDX) || MaxLevel < 1) -return false; +return {}; getX86CpuIDAndInfo(1, &EAX, &EBX, &ECX, &EDX); + StringMap Features; DavidSpickett wrote: The caller creating a blank map to pass to this function is the symptom of what I'm looking to fix here. The implementations are still going to create a map if they're going to return features. The motivation for the change is to allow: ``` if (auto features = sys::getCPUHostFeatures()) ``` Instead of: ``` map features; if (sys::getCPUHostFeatures(map) ``` As the optional better describes the situation. You either get a feature map or you don't. Versus bool+mutable ref which could allow any combination of states. The docstring helps but might as well use the typesystem to say the same thing as well. If the callers were building a map as they went, I'd understand the mutable ref parameter. Like: ``` map features if (add_some_features(features)) if (add_some_more_features(features)) filter_features(features) ``` But all uses create an empty map specifically to pass to the function. ...which is to say yeah, I should include the motivation in the commit message, let me do that :) https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/97824 >From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 5 Jul 2024 08:42:22 + Subject: [PATCH 1/2] [llvm][TargetParser] Return optional from getHostCPUFeatures Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. --- clang/lib/Driver/ToolChains/Arch/ARM.cpp | 6 ++-- clang/lib/Driver/ToolChains/Arch/X86.cpp | 6 ++-- lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++--- llvm/include/llvm/TargetParser/Host.h | 14 - llvm/lib/CodeGen/CommandFlags.cpp | 16 -- .../Orc/JITTargetMachineBuilder.cpp | 8 ++--- llvm/lib/Target/TargetMachineC.cpp| 5 ++-- llvm/lib/TargetParser/Host.cpp| 29 --- 8 files changed, 54 insertions(+), 51 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 8ae22cc37a136..77adbf3865ab1 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, // Add CPU features for generic CPUs if (CPUName == "native") { -llvm::StringMap HostFeatures; -if (llvm::sys::getHostCPUFeatures(HostFeatures)) - for (auto &F : HostFeatures) +if (std::optional> HostFeatures = +llvm::sys::getHostCPUFeatures()) + for (auto &F : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } else if (!CPUName.empty()) { diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 92821b2a82dae..e4adfcac23ca0 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple, // If -march=native, autodetect the feature list. if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { if (StringRef(A->getValue()) == "native") { - llvm::StringMap HostFeatures; - if (llvm::sys::getHostCPUFeatures(HostFeatures)) -for (auto &F : HostFeatures) + if (std::optional> HostFeatures = + llvm::sys::getHostCPUFeatures()) +for (auto &F : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp b/lldb/utils/lit-cpuid/lit-cpuid.cpp index be322cb6aa42a..16743164e6a5d 100644 --- a/lldb/utils/lit-cpuid/lit-cpuid.cpp +++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp @@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) + outs() << "sse\n"; +if ((*features)["avx"]) + outs() << "avx\n"; +if ((*features)["avx512f"]) + outs() << "avx512f\n"; + } else return 1; - - if (features["sse"]) -outs() << "sse\n"; - if (features["avx"]) -outs() << "avx\n"; - if (features["avx512f"]) -outs() << "avx512f\n"; #endif return 0; diff --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h index af72045a8fe67..d68655835a323 100644 --- a/llvm/include/llvm/TargetParser/Host.h +++ b/llvm/include/llvm/TargetParser/Host.h @@ -13,6 +13,7 @@ #ifndef LLVM_TARGETPARSER_HOST_H #define LLVM_TARGETPARSER_HOST_H +#include #include namespace llvm { @@ -47,13 +48,12 @@ namespace sys { /// The particular format of the names are target dependent, and suitable for /// passing as -mattr to the target which matches the host. /// - /// \param Features - A string mapping feature names to either - /// true (if enabled) or false (if disabled). This routine makes no guarantees - /// about exactly which features may appear in this map, except that they are - /// all valid LLVM feature names. - /// - /// \return - True on success. - bool getHostCPUFeatures(StringMap &Features); + /// \return - If feature detection succeeds, a string map mapping feature + /// names to either true (if enabled) or false (if disabled). This routine + /// makes no guarantees about exactly which features may appear in this map, + /// except that they are all valid LLVM feature names. If feature detection + /// fails, an
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) DavidSpickett wrote: Done. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/97754 >From b10f76bd6d02106e80315a70a7b72461cb6f2a99 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 13:35:21 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 149 - .../Plugins/Language/CPlusPlus/LibCxx.h | 54 + .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 196 ++ 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d..feaa51a96843a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, - {"__value_", pair_type}}); -std::optional size = tree_node_type.GetByteSize(nullptr); -if (!size) - return lldb::ChildCacheState::eRefetch; -WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); -ProcessSP process_sp(target_sp->GetProcessSP()); -Status error; -process_sp->ReadMemory(addr, buffer_sp->GetBytes(), - buffer_sp->GetByteSize(), error); -if (error.Fail()) - return lldb::ChildCacheState::eRefetch;
[Lldb-commits] [lldb] [lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (PR #97754)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/97754 >From b10f76bd6d02106e80315a70a7b72461cb6f2a99 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 4 Jul 2024 13:35:21 +0200 Subject: [PATCH 1/2] [lldb][DataFormatter] Move std::unordered_map::iterator formatter into LibCxxUnorderedMap.cpp --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 149 - .../Plugins/Language/CPlusPlus/LibCxx.h | 54 + .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 196 ++ 3 files changed, 200 insertions(+), 199 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d..feaa51a96843a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -202,155 +202,6 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( return true; } -lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp) { - if (valobj_sp) -Update(); -} - -lldb::ChildCacheState lldb_private::formatters:: -LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update() { - m_pair_sp.reset(); - m_iter_ptr = nullptr; - - ValueObjectSP valobj_sp = m_backend.GetSP(); - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - TargetSP target_sp(valobj_sp->GetTargetSP()); - - if (!target_sp) -return lldb::ChildCacheState::eRefetch; - - if (!valobj_sp) -return lldb::ChildCacheState::eRefetch; - - auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions() - .DontCheckDotVsArrowSyntax() - .SetSyntheticChildrenTraversal( - ValueObject::GetValueForExpressionPathOptions:: - SyntheticChildrenTraversal::None); - - // This must be a ValueObject* because it is a child of the ValueObject we - // are producing children for it if were a ValueObjectSP, we would end up - // with a loop (iterator -> synthetic -> child -> parent == iterator) and - // that would in turn leak memory by never allowing the ValueObjects to die - // and free their memory. - m_iter_ptr = - valobj_sp - ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr, - exprPathOptions, nullptr) - .get(); - - if (m_iter_ptr) { -auto iter_child(valobj_sp->GetChildMemberWithName("__i_")); -if (!iter_child) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -CompilerType node_type(iter_child->GetCompilerType() - .GetTypeTemplateArgument(0) - .GetPointeeType()); - -CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); - -std::string name; -uint64_t bit_offset_ptr; -uint32_t bitfield_bit_size_ptr; -bool is_bitfield_ptr; - -pair_type = pair_type.GetFieldAtIndex( -0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr); -if (!pair_type) { - m_iter_ptr = nullptr; - return lldb::ChildCacheState::eRefetch; -} - -uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -m_iter_ptr = nullptr; - -if (addr == 0 || addr == LLDB_INVALID_ADDRESS) - return lldb::ChildCacheState::eRefetch; - -auto ts = pair_type.GetTypeSystem(); -auto ast_ctx = ts.dyn_cast_or_null(); -if (!ast_ctx) - return lldb::ChildCacheState::eRefetch; - -// Mimick layout of std::__hash_iterator::__node_ and read it in -// from process memory. -// -// The following shows the contiguous block of memory: -// -// +-+ class __hash_node_base -// __node_ | __next_pointer __next_; | -// +-+ class __hash_node -// | size_t __hash_; | -// | __node_value_type __value_; | <<< our key/value pair -// +-+ -// -CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier( -llvm::StringRef(), -{{"__next_", - ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()}, - {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)}, - {"__value_", pair_type}}); -std::optional size = tree_node_type.GetByteSize(nullptr); -if (!size) - return lldb::ChildCacheState::eRefetch; -WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0)); -ProcessSP process_sp(target_sp->GetProcessSP()); -Status error; -process_sp->ReadMemory(addr, buffer_sp->GetBytes(), - buffer_sp->GetByteSize(), error); -if (error.Fail()) - return lldb::ChildCacheState::eRefetch;
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -22,13 +22,13 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - if (std::optional> features = + if (const std::optional> features = sys::getHostCPUFeatures(features)) { -if ((*features)["sse"]) +if (features->contains("sse")) tmatheson-arm wrote: `contains` will only check if the key exists in the map, but you want to actually get the `bool` if it exists and default to `false` if it doesn't. I think `lookup` fits better. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -22,13 +22,13 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - if (std::optional> features = + if (const std::optional> features = sys::getHostCPUFeatures(features)) { -if ((*features)["sse"]) +if (features->contains("sse")) DavidSpickett wrote: Doh, of course. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/DavidSpickett updated https://github.com/llvm/llvm-project/pull/97824 >From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 5 Jul 2024 08:42:22 + Subject: [PATCH 1/3] [llvm][TargetParser] Return optional from getHostCPUFeatures Previously this took a reference to a map and returned a bool to say whether it succeeded. This is an optional but with more steps. The only reason to keep it that way was if someone was appending to an existing map, but all callers made a new map before calling it. --- clang/lib/Driver/ToolChains/Arch/ARM.cpp | 6 ++-- clang/lib/Driver/ToolChains/Arch/X86.cpp | 6 ++-- lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++--- llvm/include/llvm/TargetParser/Host.h | 14 - llvm/lib/CodeGen/CommandFlags.cpp | 16 -- .../Orc/JITTargetMachineBuilder.cpp | 8 ++--- llvm/lib/Target/TargetMachineC.cpp| 5 ++-- llvm/lib/TargetParser/Host.cpp| 29 --- 8 files changed, 54 insertions(+), 51 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 8ae22cc37a1368..77adbf3865ab11 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, // Add CPU features for generic CPUs if (CPUName == "native") { -llvm::StringMap HostFeatures; -if (llvm::sys::getHostCPUFeatures(HostFeatures)) - for (auto &F : HostFeatures) +if (std::optional> HostFeatures = +llvm::sys::getHostCPUFeatures()) + for (auto &F : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } else if (!CPUName.empty()) { diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 92821b2a82daec..e4adfcac23ca0d 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple, // If -march=native, autodetect the feature list. if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { if (StringRef(A->getValue()) == "native") { - llvm::StringMap HostFeatures; - if (llvm::sys::getHostCPUFeatures(HostFeatures)) -for (auto &F : HostFeatures) + if (std::optional> HostFeatures = + llvm::sys::getHostCPUFeatures()) +for (auto &F : *HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); } diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp b/lldb/utils/lit-cpuid/lit-cpuid.cpp index be322cb6aa42a9..16743164e6a5d9 100644 --- a/lldb/utils/lit-cpuid/lit-cpuid.cpp +++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp @@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) + outs() << "sse\n"; +if ((*features)["avx"]) + outs() << "avx\n"; +if ((*features)["avx512f"]) + outs() << "avx512f\n"; + } else return 1; - - if (features["sse"]) -outs() << "sse\n"; - if (features["avx"]) -outs() << "avx\n"; - if (features["avx512f"]) -outs() << "avx512f\n"; #endif return 0; diff --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h index af72045a8fe67f..d68655835a3233 100644 --- a/llvm/include/llvm/TargetParser/Host.h +++ b/llvm/include/llvm/TargetParser/Host.h @@ -13,6 +13,7 @@ #ifndef LLVM_TARGETPARSER_HOST_H #define LLVM_TARGETPARSER_HOST_H +#include #include namespace llvm { @@ -47,13 +48,12 @@ namespace sys { /// The particular format of the names are target dependent, and suitable for /// passing as -mattr to the target which matches the host. /// - /// \param Features - A string mapping feature names to either - /// true (if enabled) or false (if disabled). This routine makes no guarantees - /// about exactly which features may appear in this map, except that they are - /// all valid LLVM feature names. - /// - /// \return - True on success. - bool getHostCPUFeatures(StringMap &Features); + /// \return - If feature detection succeeds, a string map mapping feature + /// names to either true (if enabled) or false (if disabled). This routine + /// makes no guarantees about exactly which features may appear in this map, + /// except that they are all valid LLVM feature names. If feature detection + /// fa
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -22,13 +22,13 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - if (std::optional> features = + if (const std::optional> features = sys::getHostCPUFeatures(features)) { -if ((*features)["sse"]) +if (features->contains("sse")) DavidSpickett wrote: Fixed. https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix flake in TestZerothFrame.py (PR #96685)
kendalharland wrote: I'll need help merging this since I don't have write access to the repo. https://github.com/llvm/llvm-project/pull/96685 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix type error when calling random.randrange with 'float' arg (PR #97328)
kendalharland wrote: I'll also need help merging this since I don't have write access to the repo. https://github.com/llvm/llvm-project/pull/97328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 3bfc516 - [lldb-dap][NFC] Minor rename
Author: walter erquinigo Date: 2024-07-05T13:12:13-04:00 New Revision: 3bfc5167d9e49b9a53e364e8d8853fce543cca0f URL: https://github.com/llvm/llvm-project/commit/3bfc5167d9e49b9a53e364e8d8853fce543cca0f DIFF: https://github.com/llvm/llvm-project/commit/3bfc5167d9e49b9a53e364e8d8853fce543cca0f.diff LOG: [lldb-dap][NFC] Minor rename As a minor follow up for https://github.com/llvm/llvm-project/pull/97675, I'm renaming `SupportsExceptionBreakpoints` to `SupportsExceptionBreakpointsOnThrow` and adding a `SupportsExceptionBreakpointsOnCatch` to have a bit of more granularity. Added: Modified: lldb/include/lldb/Target/Language.h lldb/source/Commands/CommandObjectBreakpoint.cpp lldb/source/Plugins/Language/ObjC/ObjCLanguage.h Removed: diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 2d6e5a40a0c0e4..83bf7635e369a5 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -363,9 +363,13 @@ class Language : public PluginInterface { return false; } - /// Returns true if this Language supports exception breakpoints via a - /// corresponding LanguageRuntime plugin. - virtual bool SupportsExceptionBreakpoints() const { return false; } + /// Returns true if this Language supports exception breakpoints on throw via + /// a corresponding LanguageRuntime plugin. + virtual bool SupportsExceptionBreakpointsOnThrow() const { return false; } + + /// Returns true if this Language supports exception breakpoints on catch via + /// a corresponding LanguageRuntime plugin. + virtual bool SupportsExceptionBreakpointsOnCatch() const { return false; } protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index a5fe9273fac76d..773f8ed2fa8af8 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -317,7 +317,8 @@ class CommandObjectBreakpointSet : public CommandObjectParsed { break; default: if (Language *languagePlugin = Language::FindPlugin(language)) { -if (languagePlugin->SupportsExceptionBreakpoints()) { +if (languagePlugin->SupportsExceptionBreakpointsOnThrow() || +languagePlugin->SupportsExceptionBreakpointsOnCatch()) { m_exception_language = language; break; } diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h index a61d0f128370d4..d9c0cd3c18cfa1 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -194,7 +194,7 @@ class ObjCLanguage : public Language { llvm::StringRef GetInstanceVariableName() override { return "self"; } - bool SupportsExceptionBreakpoints() const override { return true; } + bool SupportsExceptionBreakpointsOnThrow() const override { return true; } // PluginInterface protocol llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/bulbazord commented: >From an API standpoint, there doesn't actually seem to be a huge difference >between an empty StringMap and an optional with an empty string map in it >right? Why not return a map every time? https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
https://github.com/jeffreytan81 edited https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -209,7 +208,20 @@ Status ProcessMinidump::DoLoadCore() { GetTarget().SetArchitecture(arch, true /*set_platform*/); m_thread_list = m_minidump_parser->GetThreads(); - m_active_exception = m_minidump_parser->GetExceptionStream(); + std::vector exception_streams = jeffreytan81 wrote: Do not return by a vector of copies, instead return a value of const references/pointers. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -82,15 +82,24 @@ class MinidumpFile : public Binary { return getListStream(minidump::StreamType::ThreadList); } - /// Returns the contents of the Exception stream. An error is returned if the - /// file does not contain this stream, or the stream is smaller than the size - /// of the ExceptionStream structure. The internal consistency of the stream - /// is not checked in any way. - Expected getExceptionStream() const { -return getStream( -minidump::StreamType::Exception); + /// Returns the contents of the Exception stream. An error is returned if the + /// associated stream is smaller than the size of the ExceptionStream + /// structure. Or the directory supplied is not of kind exception stream. + Expected + getExceptionStream(minidump::Directory Directory) const { +if (Directory.Type != minidump::StreamType::Exception) { + return createError("Not an exception stream"); +} + +return getStreamFromDirectory(Directory); jeffreytan81 wrote: Why are changing the API not to return by const reference? https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -109,7 +109,7 @@ class ProcessMinidump : public PostMortemProcess { private: lldb::DataBufferSP m_core_data; llvm::ArrayRef m_thread_list; - const minidump::ExceptionStream *m_active_exception; + std::unordered_map m_exceptions_by_tid; jeffreytan81 wrote: Store `const minidump::ExceptionStream&` instead. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -9,6 +9,7 @@ #include "llvm/Object/Minidump.h" #include "llvm/Object/Error.h" #include "llvm/Support/ConvertUTF.h" +#include jeffreytan81 wrote: Is this needed? https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -53,6 +54,31 @@ Expected MinidumpFile::getString(size_t Offset) const { return Result; } +Expected> +MinidumpFile::getExceptionStreams() const { + // Scan the directories for exceptions first + std::vector exceptionStreams; + for (const auto &directory : Streams) { +if (directory.Type == StreamType::Exception) + exceptionStreams.push_back(directory); + } + + if (exceptionStreams.empty()) +return createError("No exception streams found"); + + std::vector exceptionStreamList; + for (const auto &exceptionStream : exceptionStreams) { +llvm::Expected ExpectedStream = +getStreamFromDirectory(exceptionStream); +if (!ExpectedStream) + return ExpectedStream.takeError(); + +exceptionStreamList.push_back(ExpectedStream.get()); jeffreytan81 wrote: `minidump::ExceptionStream` is non-trivial in size. There are a lot of copying here which I do not think you need. The ownership of `minidump::ExceptionStream` is still inside the stream, so let's return reference/pointer from these functions instead of copying by value. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
https://github.com/jeffreytan81 requested changes to this pull request. One concern is that, whether minidump format specification supports multiple exception streams. If this is not supported by spec, we may generate minidump that only lldb can read/parse but can fail other consumers. It would be interesting to copy the generated minidump with multiple exception steams to a Windows machine and try windbg/Visual Studio and see if they break. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -82,15 +82,24 @@ class MinidumpFile : public Binary { return getListStream(minidump::StreamType::ThreadList); } - /// Returns the contents of the Exception stream. An error is returned if the - /// file does not contain this stream, or the stream is smaller than the size - /// of the ExceptionStream structure. The internal consistency of the stream - /// is not checked in any way. - Expected getExceptionStream() const { -return getStream( -minidump::StreamType::Exception); + /// Returns the contents of the Exception stream. An error is returned if the + /// associated stream is smaller than the size of the ExceptionStream + /// structure. Or the directory supplied is not of kind exception stream. + Expected + getExceptionStream(minidump::Directory Directory) const { +if (Directory.Type != minidump::StreamType::Exception) { + return createError("Not an exception stream"); +} + +return getStreamFromDirectory(Directory); } + /// Returns the contents of the Exception streams. An error is returned if + /// any of the streams are smaller than the size of the ExceptionStream + /// structure. The internal consistency of the stream is not checked in any + /// way. + Expected> getExceptionStreams() const; jeffreytan81 wrote: Should this API return `Expected<>` instead of `std::option<>`? It seems perfect expected that a minidump does not have any exceptions. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -464,8 +464,8 @@ Stream::create(const Directory &StreamDesc, const object::MinidumpFile &File) { StreamKind Kind = getKind(StreamDesc.Type); switch (Kind) { case StreamKind::Exception: { -Expected ExpectedExceptionStream = -File.getExceptionStream(); +Expected ExpectedExceptionStream = jeffreytan81 wrote: Why are you changing this to return by value copy? https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
@@ -53,6 +54,31 @@ Expected MinidumpFile::getString(size_t Offset) const { return Result; } +Expected> +MinidumpFile::getExceptionStreams() const { + // Scan the directories for exceptions first + std::vector exceptionStreams; + for (const auto &directory : Streams) { +if (directory.Type == StreamType::Exception) + exceptionStreams.push_back(directory); + } jeffreytan81 wrote: Similar, I do not think you need to make a copy of `Directory`, returning by reference is enough. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)
Jlalond wrote: @jeffreytan81 I think the callout for multiple exception is a good question. I made a C# testbed to see what would happen if I had multiple simultaneous exceptions. [Gist here](https://gist.github.com/Jlalond/467bc990f10fbb75cc9ca7db897a7beb). When manually collecting a minidump on my Windows system and then viewing it, I do get a warning that my application has multiple exceptions.  This leads me to believe multiple exceptions is acceptable, albeit rare. https://github.com/llvm/llvm-project/pull/97470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
@@ -29,6 +29,9 @@ add_subdirectory(UnwindAssembly) set(LLDB_STRIPPED_PLUGINS) get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) +get_property(LLDB_EXTRA_PLUGINS GLOBAL PROPERTY LLDB_EXTRA_SCRIPT_PLUGINS) +list(APPEND LLDB_ALL_PLUGINS ${LLDB_EXTRA_PLUGINS}) bulbazord wrote: I see why this doesn't work now. LLDB plugins are added to the `LLDB_PLUGINS` global property via the PLUGIN argument to `add_lldb_library`. You aren't adding the PLUGIN argument to the `add_lldb_library` invocation in `lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt`. This is how the build system knows the list of plugins. But even if you were to remove this and add that `PLUGIN` argument, this still wouldn't work. I don't think we've explicitly documented this behavior, but LLDB expects each library to be one plugin, not three as you've done here. When LLDB creates a plugin, it's going to generate a `Plugins.def` file that LLDB uses to initialize and teardown all plugins. It has a list of entries that look like this: `LLDB_PLUGIN(lldbPluginFooBar)`. There are some exceptions for the script interpreter plugins (not sure why, didn't check). It also expects the `LLDB_PLUGIN_DEFINE` argument to match the library name exactly (without the initial `lldbPlugin`, specifically). The way I see it, you have three options: 1. Restructure the build so that there are 3 libraries, each one of them a plugin. 2. Change LLDB's CMake machinery to accept libraries that define multiple plugin interfaces. You'll need to modify `add_lldb_library` so that you can pass it a list of plugin interface names instead of assuming the plugin names matches the library's name. 3. Keep the workaround and document why it exists. I would suggest (1) or (2). I think (3) is just kicking the can down the road. This is a solution that explicitly works around LLDB's existing plugin system, is difficult to discover without knowing its there, and could make future refactors more difficult. https://github.com/llvm/llvm-project/pull/97273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
@@ -19,6 +19,12 @@ if (LLDB_ENABLE_LIBEDIT) list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) endif() +set_property(GLOBAL PROPERTY LLDB_EXTRA_SCRIPT_PLUGINS + lldbPluginOperatingSystemPythonInterface + lldbPluginScriptedProcessPythonInterface + lldbPluginScriptedThreadPlanPythonInterface medismailben wrote: @bulbazord aren't we making 3 separate libraries here ? https://github.com/llvm/llvm-project/pull/97273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/Commands] Add `scripting template list` command with auto discovery (PR #97273)
@@ -19,6 +19,12 @@ if (LLDB_ENABLE_LIBEDIT) list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) endif() +set_property(GLOBAL PROPERTY LLDB_EXTRA_SCRIPT_PLUGINS + lldbPluginOperatingSystemPythonInterface + lldbPluginScriptedProcessPythonInterface + lldbPluginScriptedThreadPlanPythonInterface bulbazord wrote: No, you're just adding some elements to the list `LLDB_EXTRA_SCRIPT_PLUGINS`. Right below this is `add_lldb_library` which creates one library. It will contain the 3 cpp files that implement these plugin interfaces. https://github.com/llvm/llvm-project/pull/97273 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cf1ded3 - [lldb] Silence function cast warning when building with Clang ToT targetting Windows
Author: Alexandre Ganea Date: 2024-07-05T20:49:40-04:00 New Revision: cf1ded3ac248ad4feeed7b4dd20c60b7e3c40339 URL: https://github.com/llvm/llvm-project/commit/cf1ded3ac248ad4feeed7b4dd20c60b7e3c40339 DIFF: https://github.com/llvm/llvm-project/commit/cf1ded3ac248ad4feeed7b4dd20c60b7e3c40339.diff LOG: [lldb] Silence function cast warning when building with Clang ToT targetting Windows Added: Modified: lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp Removed: diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp index a69c10081ff190..dc7697f71d6a6f 100644 --- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp @@ -175,6 +175,11 @@ Status TargetThreadWindows::DoResume() { return Status(); } +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-function-type-mismatch" +#endif + const char *TargetThreadWindows::GetName() { Log *log = GetLog(LLDBLog::Thread); static GetThreadDescriptionFunctionPtr GetThreadDescription = []() { @@ -200,3 +205,7 @@ const char *TargetThreadWindows::GetName() { return m_name.c_str(); } + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)
https://github.com/walter-erquinigo created https://github.com/llvm/llvm-project/pull/97871 …lly registered languages First of all, this is done to support exceptions for the Mojo language, but it's done in a way that will benefit any other plugin language. 1. I added a new lldb-dap CLI argument (not DAP field) called `pre-init-commands`. These commands are executed before DAP initialization. The other `init-commands` are executed after DAP initialization. It's worth mentioning that the debug adapter returns to VSCode the list of supported exception breakpoints during DAP initialization, which means that I need to register the Mojo plugin before that initialization step, hence the need for `pre-init-commands`. In general, language plugins should be registered in that step, as they affect the capabilities of the debugger. 2. I added a set of APIs for lldb-dap to query information of each language related to exception breakpoints. E.g. whether a language supports throw or catch breakpoints, how the throw keyword is called in each particular language, etc. 3. I'm realizing that the Swift support for exception breakpoints in lldb-dap should have been implemented in this way, instead of hardcoding it. >From 63ab70e2a02faed8322c71dc2491428938891471 Mon Sep 17 00:00:00 2001 From: walter erquinigo Date: Fri, 5 Jul 2024 20:30:44 -0400 Subject: [PATCH] [lldb-dap] Support throw and catch exception breakpoints for dynamically registered languages First of all, this is done to support exceptions for the Mojo language, but it's done in a way that will benefit any other plugin language. 1. I added a new lldb-dap CLI argument (not DAP field) called `pre-init-commands`. These commands are executed before DAP initialization. The other `init-commands` are executed after DAP initialization. It's worth mentioning that the debug adapter returns to VSCode the list of supported exception breakpoints during DAP initialization, which means that I need to register the Mojo plugin before that initialization step, hence the need for `pre-init-commands`. In general, language plugins should be registered in that step, as they affect the capabilities of the debugger. 2. I added a set of APIs for lldb-dap to query information of each language related to exception breakpoints. E.g. whether a language supports throw or catch breakpoints, how the throw keyword is called in each particular language, etc. 3. I'm realizing that the Swift support for exception breakpoints in lldb-dap should have been implemented in this way, instead of hardcoding it. --- lldb/include/lldb/API/SBLanguageRuntime.h | 26 +++ lldb/include/lldb/Target/Language.h | 8 lldb/source/API/SBLanguageRuntime.cpp | 40 + lldb/tools/lldb-dap/DAP.cpp | 55 ++- lldb/tools/lldb-dap/DAP.h | 2 + lldb/tools/lldb-dap/Options.td| 8 lldb/tools/lldb-dap/lldb-dap.cpp | 19 ++-- 7 files changed, 154 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h b/lldb/include/lldb/API/SBLanguageRuntime.h index 38aac05d490c1..acdc256fa2ac5 100644 --- a/lldb/include/lldb/API/SBLanguageRuntime.h +++ b/lldb/include/lldb/API/SBLanguageRuntime.h @@ -18,6 +18,32 @@ class SBLanguageRuntime { static lldb::LanguageType GetLanguageTypeFromString(const char *string); static const char *GetNameForLanguageType(lldb::LanguageType language); + + /// Returns whether the given language is any version of C++. + static bool LanguageIsCPlusPlus(lldb::LanguageType language); + + /// Returns whether the given language is Obj-C or Obj-C++. + static bool LanguageIsObjC(lldb::LanguageType language); + + /// Returns whether the given language is any version of C, C++ or Obj-C. + static bool LanguageIsCFamily(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// throw statements. + static bool SupportsExceptionBreakpointsOnThrow(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// catch statements. + static bool SupportsExceptionBreakpointsOnCatch(lldb::LanguageType language); + + /// Returns the keyword used for throw statements in the given language, e.g. + /// Python uses \b raise. Returns \b nullptr if the language is not supported. + static const char *GetThrowKeywordForLanguage(lldb::LanguageType language); + + /// Returns the keyword used for catch statements in the given language, e.g. + /// Python uses \b except. Returns \b nullptr if the language is not + /// supported. + static const char *GetCatchKeywordForLanguage(lldb::LanguageType language); }; } // namespace lldb diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 83bf7635e369a..41d8eeef469ea 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.
[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Walter Erquinigo (walter-erquinigo) Changes …lly registered languages First of all, this is done to support exceptions for the Mojo language, but it's done in a way that will benefit any other plugin language. 1. I added a new lldb-dap CLI argument (not DAP field) called `pre-init-commands`. These commands are executed before DAP initialization. The other `init-commands` are executed after DAP initialization. It's worth mentioning that the debug adapter returns to VSCode the list of supported exception breakpoints during DAP initialization, which means that I need to register the Mojo plugin before that initialization step, hence the need for `pre-init-commands`. In general, language plugins should be registered in that step, as they affect the capabilities of the debugger. 2. I added a set of APIs for lldb-dap to query information of each language related to exception breakpoints. E.g. whether a language supports throw or catch breakpoints, how the throw keyword is called in each particular language, etc. 3. I'm realizing that the Swift support for exception breakpoints in lldb-dap should have been implemented in this way, instead of hardcoding it. --- Full diff: https://github.com/llvm/llvm-project/pull/97871.diff 7 Files Affected: - (modified) lldb/include/lldb/API/SBLanguageRuntime.h (+26) - (modified) lldb/include/lldb/Target/Language.h (+8) - (modified) lldb/source/API/SBLanguageRuntime.cpp (+40) - (modified) lldb/tools/lldb-dap/DAP.cpp (+54-1) - (modified) lldb/tools/lldb-dap/DAP.h (+2) - (modified) lldb/tools/lldb-dap/Options.td (+8) - (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+16-3) ``diff diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h b/lldb/include/lldb/API/SBLanguageRuntime.h index 38aac05d490c19..acdc256fa2ac5a 100644 --- a/lldb/include/lldb/API/SBLanguageRuntime.h +++ b/lldb/include/lldb/API/SBLanguageRuntime.h @@ -18,6 +18,32 @@ class SBLanguageRuntime { static lldb::LanguageType GetLanguageTypeFromString(const char *string); static const char *GetNameForLanguageType(lldb::LanguageType language); + + /// Returns whether the given language is any version of C++. + static bool LanguageIsCPlusPlus(lldb::LanguageType language); + + /// Returns whether the given language is Obj-C or Obj-C++. + static bool LanguageIsObjC(lldb::LanguageType language); + + /// Returns whether the given language is any version of C, C++ or Obj-C. + static bool LanguageIsCFamily(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// throw statements. + static bool SupportsExceptionBreakpointsOnThrow(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// catch statements. + static bool SupportsExceptionBreakpointsOnCatch(lldb::LanguageType language); + + /// Returns the keyword used for throw statements in the given language, e.g. + /// Python uses \b raise. Returns \b nullptr if the language is not supported. + static const char *GetThrowKeywordForLanguage(lldb::LanguageType language); + + /// Returns the keyword used for catch statements in the given language, e.g. + /// Python uses \b except. Returns \b nullptr if the language is not + /// supported. + static const char *GetCatchKeywordForLanguage(lldb::LanguageType language); }; } // namespace lldb diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 83bf7635e369a5..41d8eeef469eab 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -371,6 +371,14 @@ class Language : public PluginInterface { /// a corresponding LanguageRuntime plugin. virtual bool SupportsExceptionBreakpointsOnCatch() const { return false; } + /// Returns the keyword used for throw statements in this language, e.g. + /// Python uses \b raise. Defaults to \b throw. + virtual llvm::StringRef GetThrowKeyword() const { return "throw"; } + + /// Returns the keyword used for catch statements in this language, e.g. + /// Python uses \b except. Defaults to \b catch. + virtual llvm::StringRef GetCatchKeyword() const { return "catch"; } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp index d571f282fce03d..3926c57efedf54 100644 --- a/lldb/source/API/SBLanguageRuntime.cpp +++ b/lldb/source/API/SBLanguageRuntime.cpp @@ -26,3 +26,43 @@ SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType language) { return Language::GetNameForLanguageType(language); } + +bool SBLanguageRuntime::LanguageIsCPlusPlus(lldb::LanguageType language) { + return Language::LanguageIsCPlusPlus(language); +} + +bool SBLanguageRuntime::LanguageIsObjC(lldb::LanguageType language) { + return Language::LanguageIsObjC(language); +} + +bool SBLanguageRuntime::Lan
[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)
walter-erquinigo wrote: This is a screenshot of how it's looking for me on VSCode.  https://github.com/llvm/llvm-project/pull/97871 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits