[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename ThreadPool->DefaultThreadPool and ThreadPoolInterface->ThreadPool (NFC) (PR #83702)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/83702 >From 5f657d872a78af9fb0035fc2f04dfa7ead7abadd Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 4 Mar 2024 23:21:04 -0800 Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. --- bolt/lib/Core/ParallelUtilities.cpp | 2 +- bolt/tools/merge-fdata/merge-fdata.cpp| 2 +- lld/MachO/Writer.cpp | 2 +- lldb/source/Core/Debugger.cpp | 2 +- llvm/docs/ORCv2.rst | 2 +- .../SpeculativeJIT/SpeculativeJIT.cpp | 2 +- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- llvm/include/llvm/Support/ThreadPool.h| 7 +++--- llvm/lib/CodeGen/ParallelCG.cpp | 2 +- llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 4 ++-- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 ++-- llvm/lib/Support/BalancedPartitioning.cpp | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-cov/CoverageExporterJson.cpp | 2 +- llvm/tools/llvm-cov/CoverageReport.cpp| 4 ++-- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Delta.cpp | 6 ++--- llvm/unittests/ADT/LazyAtomicPointerTest.cpp | 4 ++-- llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++--- llvm/unittests/Support/ParallelTest.cpp | 2 +- llvm/unittests/Support/ThreadPool.cpp | 22 +-- .../Support/ThreadSafeAllocatorTest.cpp | 6 ++--- mlir/lib/CAPI/IR/Support.cpp | 2 +- mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 4 ++-- mlir/lib/IR/MLIRContext.cpp | 4 ++-- 32 files changed, 61 insertions(+), 62 deletions(-) diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp index 1a28bc4346ecd5..1f5ac5655d9f98 100644 --- a/bolt/lib/Core/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -106,7 +106,7 @@ ThreadPool &getThreadPool() { if (ThreadPoolPtr.get()) return *ThreadPoolPtr; - ThreadPoolPtr = std::make_unique( + ThreadPoolPtr = std::make_unique( llvm::hardware_concurrency(opts::ThreadCount)); return *ThreadPoolPtr; } diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp index c6dfd3cfdc56de..f2ac5ad4492ee5 100644 --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl &Filenames) { // least 4 tasks. ThreadPoolStrategy S = optimal_concurrency( std::max(Filenames.size() / 4, static_cast(1))); - ThreadPool Pool(S); + DefaultThreadPool Pool(S); DenseMap ParsedProfiles( Pool.getMaxConcurrency()); for (const auto &Filename : Filenames) diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp index 65b598d1d7c422..9b0a32c136e8b1 100644 --- a/lld/MachO/Writer.cpp +++ b/lld/MachO/Writer.cpp @@ -66,7 +66,7 @@ class Writer { template void run(); - ThreadPool threadPool; + DefaultThreadPool threadPool; std::unique_ptr &buffer; uint64_t addr = 0; uint64_t fileOff = 0; diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 1b25527abf981f..a28d639fa34050 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -609,7 +609,7 @@ void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) { "Debugger::Initialize called more than once!"); g_debugger_list_mutex_ptr = new std::recursive_mutex(); g_debugger_list_ptr = new DebuggerList(); - g_thread_pool = new llvm::ThreadPool(llvm::optimal_concurrency()); + g_thread_pool = new llvm::DefaultThreadPool(llvm::optimal_concurrency()); g_load_plugin_callback = load_plugin_callback; } diff --git a/llvm/docs/ORCv2.rst b/llvm/docs/ORCv2.rst index add05e05a80e5f..910ef5b9f3d02f 100644 --- a/llvm/docs/ORCv2.rst +++ b/llvm/docs/ORCv2.rst @@ -738,7 +738,7 @@ or creating any Modules attached to it. E.g. ThreadSafeContext TSCtx(std::make_unique()); -ThreadPool TP(NumThreads); +DefaultThreadPool TP(NumThreads); JITStack J; for (auto &ModulePath : ModulePaths) { diff --git a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp index fdd376d82da5d8..0d97d379d2279e 100644 --- a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp +++ b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename ThreadPool->DefaultThreadPool and ThreadPoolInterface->ThreadPool (NFC) (PR #83702)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/83702 >From 08a5dde36450c99137c7b03bec503daca18bc2d2 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 4 Mar 2024 23:21:04 -0800 Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. --- bolt/include/bolt/Core/ParallelUtilities.h| 4 ++-- bolt/lib/Core/ParallelUtilities.cpp | 10 - bolt/lib/Passes/IdenticalCodeFolding.cpp | 2 +- bolt/lib/Rewrite/DWARFRewriter.cpp| 2 +- bolt/tools/merge-fdata/merge-fdata.cpp| 2 +- lld/MachO/Writer.cpp | 2 +- lldb/source/Core/Debugger.cpp | 2 +- llvm/docs/ORCv2.rst | 2 +- .../SpeculativeJIT/SpeculativeJIT.cpp | 2 +- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- llvm/include/llvm/Support/ThreadPool.h| 7 +++--- llvm/lib/CodeGen/ParallelCG.cpp | 2 +- llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 4 ++-- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 ++-- llvm/lib/Support/BalancedPartitioning.cpp | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-cov/CoverageExporterJson.cpp | 2 +- llvm/tools/llvm-cov/CoverageReport.cpp| 4 ++-- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Delta.cpp | 6 ++--- llvm/unittests/ADT/LazyAtomicPointerTest.cpp | 4 ++-- llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++--- llvm/unittests/Support/ParallelTest.cpp | 2 +- llvm/unittests/Support/ThreadPool.cpp | 22 +-- .../Support/ThreadSafeAllocatorTest.cpp | 6 ++--- mlir/lib/CAPI/IR/Support.cpp | 2 +- mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 4 ++-- mlir/lib/IR/MLIRContext.cpp | 4 ++-- 35 files changed, 69 insertions(+), 70 deletions(-) diff --git a/bolt/include/bolt/Core/ParallelUtilities.h b/bolt/include/bolt/Core/ParallelUtilities.h index e510525bc51d00..e7b35a79acc78c 100644 --- a/bolt/include/bolt/Core/ParallelUtilities.h +++ b/bolt/include/bolt/Core/ParallelUtilities.h @@ -49,8 +49,8 @@ enum SchedulingPolicy { SP_BB_QUADRATIC, /// cost is estimated by the square of the BB count }; -/// Return the managed thread pool and initialize it if not initiliazed. -ThreadPool &getThreadPool(); +/// Return the managed thread pool and initialize it if not initialized. +ThreadPoolInterface &getThreadPool(); /// Perform the work on each BinaryFunction except those that are accepted /// by SkipPredicate, scheduling heuristic is based on SchedPolicy. diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp index 1a28bc4346ecd5..5f5e96e0e7881c 100644 --- a/bolt/lib/Core/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -49,7 +49,7 @@ namespace ParallelUtilities { namespace { /// A single thread pool that is used to run parallel tasks -std::unique_ptr ThreadPoolPtr; +std::unique_ptr ThreadPoolPtr; unsigned computeCostFor(const BinaryFunction &BF, const PredicateTy &SkipPredicate, @@ -102,11 +102,11 @@ inline unsigned estimateTotalCost(const BinaryContext &BC, } // namespace -ThreadPool &getThreadPool() { +ThreadPoolInterface &getThreadPool() { if (ThreadPoolPtr.get()) return *ThreadPoolPtr; - ThreadPoolPtr = std::make_unique( + ThreadPoolPtr = std::make_unique( llvm::hardware_concurrency(opts::ThreadCount)); return *ThreadPoolPtr; } @@ -145,7 +145,7 @@ void runOnEachFunction(BinaryContext &BC, SchedulingPolicy SchedPolicy, TotalCost > BlocksCount ? TotalCost / BlocksCount : 1; // Divide work into blocks of equal cost - ThreadPool &Pool = getThreadPool(); + ThreadPoolInterface &Pool = getThreadPool(); auto BlockBegin = BC.getBinaryFunctions().begin(); unsigned CurrentCost = 0; @@ -202,7 +202,7 @@ void runOnEachFunctionWithUniqueAllocId( TotalCost > BlocksCount ? TotalCost / BlocksCount : 1; // Divide work into blocks of equal cost - ThreadPool &Pool = getThreadPool(); + ThreadPoolInterface &Pool = getThreadPool(); auto BlockBegin = BC.getBinaryFunctions().begin(); unsigned CurrentCost = 0; unsigned AllocId = 1; diff --git a/bolt/lib/Passes/IdenticalCodeFolding.cpp b/bolt/lib/Passes/IdenticalCodeFolding.cpp index 9f8d82b05ccf48..87eba10354a37b 100644 --- a/bolt/lib/Passes/IdenticalCodeFolding.cpp +++ b/b
[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph edited https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph edited https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Address mask sbprocess apis and new mask invalid const (PR #83663)
jasonmolenda wrote: I pushed an update to this PR where I have the base class Fix methods in ABI.cpp ignore the highmem masks completely, I added highmem mask use when it's a highmem address and they are set to the AArch64ABI class so all the AArch64 ABI plugins are checking this. I changed the API test to only do highmem tests on AArch64 targets, and on other targets they will test that highmem masks are ignored. If any target wants this feature, I would like them to have to explicitly declare it in the TestAddressMasks.py so things don't kinda-work/fail unintentionally. https://github.com/llvm/llvm-project/pull/83663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/83702 >From 41e5c286c29a4fea65f6116f6844b44a3847f9db Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 4 Mar 2024 23:21:04 -0800 Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. --- bolt/include/bolt/Core/ParallelUtilities.h| 4 ++-- bolt/lib/Core/ParallelUtilities.cpp | 10 - bolt/lib/Passes/IdenticalCodeFolding.cpp | 2 +- bolt/lib/Rewrite/DWARFRewriter.cpp| 2 +- bolt/tools/merge-fdata/merge-fdata.cpp| 2 +- .../clang-doc/tool/ClangDocMain.cpp | 2 +- .../tool/FindAllSymbolsMain.cpp | 2 +- clang/lib/Tooling/AllTUsExecution.cpp | 2 +- lld/MachO/Writer.cpp | 2 +- lldb/source/Core/Debugger.cpp | 2 +- llvm/docs/ORCv2.rst | 2 +- .../SpeculativeJIT/SpeculativeJIT.cpp | 2 +- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- llvm/include/llvm/Support/ThreadPool.h| 7 +++--- llvm/lib/CodeGen/ParallelCG.cpp | 2 +- llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 4 ++-- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 ++-- llvm/lib/Support/BalancedPartitioning.cpp | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-cov/CoverageExporterJson.cpp | 2 +- llvm/tools/llvm-cov/CoverageReport.cpp| 4 ++-- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Delta.cpp | 6 ++--- llvm/unittests/ADT/LazyAtomicPointerTest.cpp | 4 ++-- llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++--- llvm/unittests/Support/ParallelTest.cpp | 2 +- llvm/unittests/Support/ThreadPool.cpp | 22 +-- .../Support/ThreadSafeAllocatorTest.cpp | 6 ++--- mlir/lib/CAPI/IR/Support.cpp | 2 +- mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 4 ++-- mlir/lib/IR/MLIRContext.cpp | 4 ++-- 38 files changed, 72 insertions(+), 73 deletions(-) diff --git a/bolt/include/bolt/Core/ParallelUtilities.h b/bolt/include/bolt/Core/ParallelUtilities.h index e510525bc51d00..e7b35a79acc78c 100644 --- a/bolt/include/bolt/Core/ParallelUtilities.h +++ b/bolt/include/bolt/Core/ParallelUtilities.h @@ -49,8 +49,8 @@ enum SchedulingPolicy { SP_BB_QUADRATIC, /// cost is estimated by the square of the BB count }; -/// Return the managed thread pool and initialize it if not initiliazed. -ThreadPool &getThreadPool(); +/// Return the managed thread pool and initialize it if not initialized. +ThreadPoolInterface &getThreadPool(); /// Perform the work on each BinaryFunction except those that are accepted /// by SkipPredicate, scheduling heuristic is based on SchedPolicy. diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp index 1a28bc4346ecd5..5f5e96e0e7881c 100644 --- a/bolt/lib/Core/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -49,7 +49,7 @@ namespace ParallelUtilities { namespace { /// A single thread pool that is used to run parallel tasks -std::unique_ptr ThreadPoolPtr; +std::unique_ptr ThreadPoolPtr; unsigned computeCostFor(const BinaryFunction &BF, const PredicateTy &SkipPredicate, @@ -102,11 +102,11 @@ inline unsigned estimateTotalCost(const BinaryContext &BC, } // namespace -ThreadPool &getThreadPool() { +ThreadPoolInterface &getThreadPool() { if (ThreadPoolPtr.get()) return *ThreadPoolPtr; - ThreadPoolPtr = std::make_unique( + ThreadPoolPtr = std::make_unique( llvm::hardware_concurrency(opts::ThreadCount)); return *ThreadPoolPtr; } @@ -145,7 +145,7 @@ void runOnEachFunction(BinaryContext &BC, SchedulingPolicy SchedPolicy, TotalCost > BlocksCount ? TotalCost / BlocksCount : 1; // Divide work into blocks of equal cost - ThreadPool &Pool = getThreadPool(); + ThreadPoolInterface &Pool = getThreadPool(); auto BlockBegin = BC.getBinaryFunctions().begin(); unsigned CurrentCost = 0; @@ -202,7 +202,7 @@ void runOnEachFunctionWithUniqueAllocId( TotalCost > BlocksCount ? TotalCost / BlocksCount : 1; // Divide work into blocks of equal cost - ThreadPool &Pool = getThreadPool(); + ThreadPoolInterface &Pool = getThreadPool(); auto BlockBegin = BC.getBinaryFunctions().begin(); unsigned CurrentCost = 0; unsigned AllocId = 1; diff --git a/bolt/lib/Passes/Id
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/83702 >From f961f22a3643673c1f3a040715dcfa2887ee1dca Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 4 Mar 2024 23:21:04 -0800 Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. --- bolt/include/bolt/Core/ParallelUtilities.h| 4 ++-- bolt/lib/Core/ParallelUtilities.cpp | 10 - bolt/lib/Passes/IdenticalCodeFolding.cpp | 2 +- bolt/lib/Rewrite/DWARFRewriter.cpp| 2 +- bolt/tools/merge-fdata/merge-fdata.cpp| 2 +- .../clang-doc/tool/ClangDocMain.cpp | 2 +- .../tool/FindAllSymbolsMain.cpp | 2 +- clang/lib/Tooling/AllTUsExecution.cpp | 2 +- clang/tools/clang-scan-deps/ClangScanDeps.cpp | 2 +- lld/MachO/Writer.cpp | 2 +- lldb/source/Core/Debugger.cpp | 4 ++-- llvm/docs/ORCv2.rst | 2 +- .../SpeculativeJIT/SpeculativeJIT.cpp | 2 +- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- llvm/include/llvm/Support/ThreadPool.h| 7 +++--- llvm/lib/CodeGen/ParallelCG.cpp | 2 +- llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 4 ++-- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 ++-- llvm/lib/Support/BalancedPartitioning.cpp | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-cov/CoverageExporterJson.cpp | 2 +- llvm/tools/llvm-cov/CoverageReport.cpp| 4 ++-- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Delta.cpp | 6 ++--- llvm/unittests/ADT/LazyAtomicPointerTest.cpp | 4 ++-- llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++--- llvm/unittests/Support/ParallelTest.cpp | 2 +- llvm/unittests/Support/ThreadPool.cpp | 22 +-- .../Support/ThreadSafeAllocatorTest.cpp | 6 ++--- mlir/include/mlir/IR/MLIRContext.h| 2 +- mlir/lib/CAPI/IR/Support.cpp | 2 +- mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 4 ++-- mlir/lib/IR/MLIRContext.cpp | 4 ++-- 40 files changed, 75 insertions(+), 76 deletions(-) diff --git a/bolt/include/bolt/Core/ParallelUtilities.h b/bolt/include/bolt/Core/ParallelUtilities.h index e510525bc51d00..e7b35a79acc78c 100644 --- a/bolt/include/bolt/Core/ParallelUtilities.h +++ b/bolt/include/bolt/Core/ParallelUtilities.h @@ -49,8 +49,8 @@ enum SchedulingPolicy { SP_BB_QUADRATIC, /// cost is estimated by the square of the BB count }; -/// Return the managed thread pool and initialize it if not initiliazed. -ThreadPool &getThreadPool(); +/// Return the managed thread pool and initialize it if not initialized. +ThreadPoolInterface &getThreadPool(); /// Perform the work on each BinaryFunction except those that are accepted /// by SkipPredicate, scheduling heuristic is based on SchedPolicy. diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp index 1a28bc4346ecd5..5f5e96e0e7881c 100644 --- a/bolt/lib/Core/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -49,7 +49,7 @@ namespace ParallelUtilities { namespace { /// A single thread pool that is used to run parallel tasks -std::unique_ptr ThreadPoolPtr; +std::unique_ptr ThreadPoolPtr; unsigned computeCostFor(const BinaryFunction &BF, const PredicateTy &SkipPredicate, @@ -102,11 +102,11 @@ inline unsigned estimateTotalCost(const BinaryContext &BC, } // namespace -ThreadPool &getThreadPool() { +ThreadPoolInterface &getThreadPool() { if (ThreadPoolPtr.get()) return *ThreadPoolPtr; - ThreadPoolPtr = std::make_unique( + ThreadPoolPtr = std::make_unique( llvm::hardware_concurrency(opts::ThreadCount)); return *ThreadPoolPtr; } @@ -145,7 +145,7 @@ void runOnEachFunction(BinaryContext &BC, SchedulingPolicy SchedPolicy, TotalCost > BlocksCount ? TotalCost / BlocksCount : 1; // Divide work into blocks of equal cost - ThreadPool &Pool = getThreadPool(); + ThreadPoolInterface &Pool = getThreadPool(); auto BlockBegin = BC.getBinaryFunctions().begin(); unsigned CurrentCost = 0; @@ -202,7 +202,7 @@ void runOnEachFunctionWithUniqueAllocId( TotalCost > BlocksCount ? TotalCost / BlocksCount : 1; // Divide work into blocks of equal cost - ThreadPool &Pool = getThreadPool(); + ThreadPoolInterface &Pool = getThreadPool(); auto BlockBegin = BC.get
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
joker-eph wrote: I did the first part of the renaming @dwblaikie : looks good? https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Address mask sbprocess apis and new mask invalid const (PR #83663)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83663 >From c993c7cc7c1669ca7d06e52f1a1ff8dbefe9ebc9 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Thu, 29 Feb 2024 17:02:42 -0800 Subject: [PATCH 1/4] [lldb] Add SBProcess methods for get/set/use address masks (#83095) I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 114 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-defines.h | 5 + lldb/include/lldb/lldb-enumerations.h | 16 +++ lldb/source/API/SBProcess.cpp | 92 ++ lldb/source/Target/Process.cpp| 10 +- lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 74 .../python_api/process/address-masks/main.c | 5 + 10 files changed, 328 insertions(+), 6 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7da3335a7234b7 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,120 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// This choice of mask can be important for example on AArch32 + /// systems. Where instructions where instructions start on even addresses, + /// the 0th bit may be used to indicate that a function is thumb code. On + /// such a target, the eAddressMaskTypeCode may clear the 0th bit from an + /// address to get the actual address Whereas eAddressMaskTypeData would not. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures (e.g., AArch64), it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods description of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + ///
[Lldb-commits] [lldb] Address mask sbprocess apis and new mask invalid const (PR #83663)
@@ -0,0 +1,130 @@ +"""Test Python APIs for setting, getting, and using address masks.""" + +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class AddressMasksTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def reset_all_masks(self, process): +process.SetAddressMask( +lldb.eAddressMaskTypeAll, +lldb.LLDB_INVALID_ADDRESS_MASK, +lldb.eAddressMaskRangeAll, +) + +def test_address_masks(self): +self.build() +(target, process, t, bp) = lldbutil.run_to_source_breakpoint( +self, "break here", lldb.SBFileSpec("main.c") +) + +process.SetAddressableBits(lldb.eAddressMaskTypeAll, 42) +self.assertEqual(0x02953F94, process.FixAddress(0x00265E953F94)) +self.reset_all_masks(process) + +# ~((1ULL<<42)-1) == 0xfc00 +process.SetAddressMask(lldb.eAddressMaskTypeAll, 0xFC00) +self.assertEqual(0x02953F94, process.FixAddress(0x00265E953F94)) +self.reset_all_masks(process) + +# Check that all bits can pass through unmodified +process.SetAddressableBits(lldb.eAddressMaskTypeAll, 64) +self.assertEqual(0x00265E953F94, process.FixAddress(0x00265E953F94)) +self.reset_all_masks(process) + +process.SetAddressableBits( +lldb.eAddressMaskTypeAll, 42, lldb.eAddressMaskRangeAll +) +self.assertEqual(0x02950001F694, process.FixAddress(0x00265E950001F694)) +self.assertEqual(0xFE95F694, process.FixAddress(0xFFA65E95F694)) +self.reset_all_masks(process) + +# Set a eAddressMaskTypeCode which has the low 3 bits marked as non-address +# bits, confirm that they're cleared by FixAddress. +process.SetAddressableBits( +lldb.eAddressMaskTypeAll, 42, lldb.eAddressMaskRangeAll +) +mask = process.GetAddressMask(lldb.eAddressMaskTypeAny) +process.SetAddressMask(lldb.eAddressMaskTypeCode, mask | 0x3) +process.SetAddressMask(lldb.eAddressMaskTypeCode, 0xFC03) DavidSpickett wrote: These two lines do the same thing? https://github.com/llvm/llvm-project/pull/83663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Remove corefile test xfails (PR #84022)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/84022 Fixes #48759 As stated on the issue this was fixed by a change in FreeBSD 13, and I've confirmed that it passes on 14 as well. >From e07cfd18f760b08fb049d556f5115480fb25322d Mon Sep 17 00:00:00 2001 From: David Spickett Date: Tue, 5 Mar 2024 14:42:13 + Subject: [PATCH] [lldb][FreeBSD] Remove corefile test xfails Fixes #48759 As stated on the issue this was fixed by a change in FreeBSD 13, and I've confirmed that it passes on 14 as well. --- .../functionalities/postmortem/elf-core/TestLinuxCore.py | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index 7ec5e0d7c8309b..8ec0cbdd0fdd1f 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -292,9 +292,7 @@ def test_aarch64_pac(self): self.dbg.DeleteTarget(target) @skipIfLLVMTargetMissing("AArch64") -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49415" -) +# This test fails on FreeBSD 12 and earlier, see llvm.org/pr49415 for details. def test_aarch64_regs(self): # check 64 bit ARM core files target = self.dbg.CreateTarget(None) @@ -377,9 +375,7 @@ def test_aarch64_regs(self): self.expect("register read --all") @skipIfLLVMTargetMissing("AArch64") -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49415" -) +# This test fails on FreeBSD 12 and earlier, see llvm.org/pr49415 for details. def test_aarch64_sve_regs_fpsimd(self): # check 64 bit ARM core files target = self.dbg.CreateTarget(None) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Remove corefile test xfails (PR #84022)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Fixes #48759 As stated on the issue this was fixed by a change in FreeBSD 13, and I've confirmed that it passes on 14 as well. --- Full diff: https://github.com/llvm/llvm-project/pull/84022.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py (+2-6) ``diff diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py index 7ec5e0d7c8309b..8ec0cbdd0fdd1f 100644 --- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -292,9 +292,7 @@ def test_aarch64_pac(self): self.dbg.DeleteTarget(target) @skipIfLLVMTargetMissing("AArch64") -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49415" -) +# This test fails on FreeBSD 12 and earlier, see llvm.org/pr49415 for details. def test_aarch64_regs(self): # check 64 bit ARM core files target = self.dbg.CreateTarget(None) @@ -377,9 +375,7 @@ def test_aarch64_regs(self): self.expect("register read --all") @skipIfLLVMTargetMissing("AArch64") -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49415" -) +# This test fails on FreeBSD 12 and earlier, see llvm.org/pr49415 for details. def test_aarch64_sve_regs_fpsimd(self): # check 64 bit ARM core files target = self.dbg.CreateTarget(None) `` https://github.com/llvm/llvm-project/pull/84022 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Narrow vectorcall xfail to x86 platforms (PR #84024)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/84024 vectorcall only works on x86 https://clang.llvm.org/docs/AttributeReference.html#vectorcall so elsewhere it fails to compile. Which is expected on AArch64 for example so is treated as a pass. >From d86d189b30ff9655c597dcd58490753f8a84e7a8 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Tue, 5 Mar 2024 14:58:17 + Subject: [PATCH] [lldb][test][FreeBSD] Narrow vectorcall xfail to x86 platforms vectorcall only works on x86 https://clang.llvm.org/docs/AttributeReference.html#vectorcall so elsewhere it fails to compile. Which is expected on AArch64 for example so is treated as a pass. --- .../API/lang/c/calling-conventions/TestCCallingConventions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py index 9483dfcd040186..0304482e899b82 100644 --- a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py +++ b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py @@ -62,7 +62,10 @@ def test_stdcall(self): return self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10") +# Fails on x86, passes elsewhere because clang doesn't support vectorcall on +# any other architectures. @expectedFailureAll( +triple=re.compile("^(x86|i386)"), oslist=["freebsd"], bugnumber="github.com/llvm/llvm-project/issues/56084" ) def test_vectorcall(self): ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Narrow vectorcall xfail to x86 platforms (PR #84024)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes vectorcall only works on x86 https://clang.llvm.org/docs/AttributeReference.html#vectorcall so elsewhere it fails to compile. Which is expected on AArch64 for example so is treated as a pass. --- Full diff: https://github.com/llvm/llvm-project/pull/84024.diff 1 Files Affected: - (modified) lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py (+3) ``diff diff --git a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py index 9483dfcd040186..0304482e899b82 100644 --- a/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py +++ b/lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py @@ -62,7 +62,10 @@ def test_stdcall(self): return self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10") +# Fails on x86, passes elsewhere because clang doesn't support vectorcall on +# any other architectures. @expectedFailureAll( +triple=re.compile("^(x86|i386)"), oslist=["freebsd"], bugnumber="github.com/llvm/llvm-project/issues/56084" ) def test_vectorcall(self): `` https://github.com/llvm/llvm-project/pull/84024 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Narrow vectorcall xfail to x86 platforms (PR #84024)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/84024 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Remove xfails from TestGDBRemoteLoad (PR #84026)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/84026 Fixes #48758 These are now passing on AArch64 FreeBSD 14. >From 746413849693e1e4e6d667fc136d90bc97486d82 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Tue, 5 Mar 2024 15:06:49 + Subject: [PATCH] [lldb][test][FreeBSD] Remove xfails from TestGDBRemoteLoad Fixes #48758 These are now passing on AArch64 FreeBSD 14. --- .../gdb_remote_client/TestGDBRemoteLoad.py | 9 - 1 file changed, 9 deletions(-) diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py index c39cb4cd59aa07..f0a5429e6c1cec 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py @@ -6,9 +6,6 @@ class TestGDBRemoteLoad(GDBRemoteTestBase): -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414" -) def test_module_load_address(self): """Test that setting the load address of a module uses virtual addresses""" target = self.createTarget("a.yaml") @@ -20,9 +17,6 @@ def test_module_load_address(self): self.assertTrue(address.IsValid()) self.assertEqual(".data", address.GetSection().GetName()) -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414" -) def test_ram_load(self): """Test loading an object file to a target's ram""" target = self.createTarget("a.yaml") @@ -31,9 +25,6 @@ def test_ram_load(self): self.assertPacketLogContains(["M1000,4:c3c3c3c3", "M1004,2:3232"]) @skipIfXmlSupportMissing -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414" -) def test_flash_load(self): """Test loading an object file to a target's flash memory""" ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Remove xfails from TestGDBRemoteLoad (PR #84026)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Fixes #48758 These are now passing on AArch64 FreeBSD 14. --- Full diff: https://github.com/llvm/llvm-project/pull/84026.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py (-9) ``diff diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py index c39cb4cd59aa07..f0a5429e6c1cec 100644 --- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py +++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py @@ -6,9 +6,6 @@ class TestGDBRemoteLoad(GDBRemoteTestBase): -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414" -) def test_module_load_address(self): """Test that setting the load address of a module uses virtual addresses""" target = self.createTarget("a.yaml") @@ -20,9 +17,6 @@ def test_module_load_address(self): self.assertTrue(address.IsValid()) self.assertEqual(".data", address.GetSection().GetName()) -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414" -) def test_ram_load(self): """Test loading an object file to a target's ram""" target = self.createTarget("a.yaml") @@ -31,9 +25,6 @@ def test_ram_load(self): self.assertPacketLogContains(["M1000,4:c3c3c3c3", "M1004,2:3232"]) @skipIfXmlSupportMissing -@expectedFailureAll( -archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49414" -) def test_flash_load(self): """Test loading an object file to a target's flash memory""" `` https://github.com/llvm/llvm-project/pull/84026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
@@ -333,3 +335,41 @@ def expectedCompiler(compilers): return True return False + + +# This is a helper function to determine if a specific version of Xcode's linker +# contains a TLS bug. We want to skip TLS tests if they contain this bug, but +# adding a linker/linker_version conditions to a decorator is challenging due to +# the number of ways linkers can enter the build process. +def darwinLinkerHasTLSBug(): +"""Returns true iff a test is running on a darwin platform and the host linker is between versions 1000 and 1109.""" +darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all) +if getPlatform() not in darwin_platforms: +return False + +linker_path = ( +subprocess.check_output(["xcrun", "--find", "ld"]).rstrip().decode("utf-8") kastiglione wrote: I believe this is more conventional: ```suggestion subprocess.check_output(["xcrun", "--find", "ld"], text=True).rstrip() ``` https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
@@ -333,3 +335,41 @@ def expectedCompiler(compilers): return True return False + + +# This is a helper function to determine if a specific version of Xcode's linker +# contains a TLS bug. We want to skip TLS tests if they contain this bug, but +# adding a linker/linker_version conditions to a decorator is challenging due to +# the number of ways linkers can enter the build process. +def darwinLinkerHasTLSBug(): +"""Returns true iff a test is running on a darwin platform and the host linker is between versions 1000 and 1109.""" +darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all) +if getPlatform() not in darwin_platforms: +return False + +linker_path = ( +subprocess.check_output(["xcrun", "--find", "ld"]).rstrip().decode("utf-8") +) +if not is_exe(linker_path): +return False + +raw_linker_info = ( +subprocess.check_output([linker_path, "-version_details"]) +.rstrip() +.decode("utf-8") +) +parsed_linker_info = json.loads(raw_linker_info) +if "version" not in parsed_linker_info: +return False + +raw_version = parsed_linker_info["version"] +version = None +try: +version = int(raw_version) kastiglione wrote: this this guaranteed to always be an integer? Note that `ld -ld_classic -version_details` has a version of "954.7" on my machine. Were there any releases with decimals in the range that has the bug? https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
@@ -333,3 +335,41 @@ def expectedCompiler(compilers): return True return False + + +# This is a helper function to determine if a specific version of Xcode's linker +# contains a TLS bug. We want to skip TLS tests if they contain this bug, but +# adding a linker/linker_version conditions to a decorator is challenging due to +# the number of ways linkers can enter the build process. +def darwinLinkerHasTLSBug(): +"""Returns true iff a test is running on a darwin platform and the host linker is between versions 1000 and 1109.""" +darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all) +if getPlatform() not in darwin_platforms: +return False + +linker_path = ( +subprocess.check_output(["xcrun", "--find", "ld"]).rstrip().decode("utf-8") +) +if not is_exe(linker_path): +return False + +raw_linker_info = ( +subprocess.check_output([linker_path, "-version_details"]) +.rstrip() +.decode("utf-8") +) +parsed_linker_info = json.loads(raw_linker_info) +if "version" not in parsed_linker_info: +return False + +raw_version = parsed_linker_info["version"] +version = None +try: +version = int(raw_version) +except: +return False + +if version is None: +return False + +return 1000 <= version and version <= 1109 kastiglione wrote: ```suggestion try: version = int(raw_version) return 1000 <= version <= 1109 except: return False ``` https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
@@ -333,3 +335,41 @@ def expectedCompiler(compilers): return True return False + + +# This is a helper function to determine if a specific version of Xcode's linker +# contains a TLS bug. We want to skip TLS tests if they contain this bug, but +# adding a linker/linker_version conditions to a decorator is challenging due to +# the number of ways linkers can enter the build process. +def darwinLinkerHasTLSBug(): kastiglione wrote: should there be two functions here? A generic function that can check for arbitrary version ranges, and then a specific `darwinLinkerHasTLSBug` which is implemented as: ```py def darwinLinkerHasTLSBug(): return 1000 <= checkDarwinLinkerVersion() <= 1109 ``` https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
@@ -333,3 +335,41 @@ def expectedCompiler(compilers): return True return False + + +# This is a helper function to determine if a specific version of Xcode's linker +# contains a TLS bug. We want to skip TLS tests if they contain this bug, but +# adding a linker/linker_version conditions to a decorator is challenging due to +# the number of ways linkers can enter the build process. +def darwinLinkerHasTLSBug(): +"""Returns true iff a test is running on a darwin platform and the host linker is between versions 1000 and 1109.""" +darwin_platforms = lldbplatform.translate(lldbplatform.darwin_all) +if getPlatform() not in darwin_platforms: +return False + +linker_path = ( +subprocess.check_output(["xcrun", "--find", "ld"]).rstrip().decode("utf-8") +) +if not is_exe(linker_path): +return False + +raw_linker_info = ( +subprocess.check_output([linker_path, "-version_details"]) +.rstrip() +.decode("utf-8") +) +parsed_linker_info = json.loads(raw_linker_info) +if "version" not in parsed_linker_info: +return False + +raw_version = parsed_linker_info["version"] kastiglione wrote: ```suggestion raw_version = parsed_linker_info.get("version") ``` https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Account for spsr being 8 bytes (PR #84032)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/84032 Since https://reviews.freebsd.org/D38983, spsr (aka cpsr) is stored as an 8 byte value. However in lldb's structures it is a 32 bit value still. The version number comes from https://cgit.freebsd.org/src/commit/?id=ea3061526e9ce5d3b65932c1d3e4437abd556d65. >From 6e131a102eb0914303d5bbe08b69ba52c36e958f Mon Sep 17 00:00:00 2001 From: David Spickett Date: Tue, 5 Mar 2024 15:27:40 + Subject: [PATCH] [lldb][test][FreeBSD] Account for spsr being 8 bytes Since https://reviews.freebsd.org/D38983, spsr (aka cpsr) is stored as an 8 byte value. However in lldb's structures it is a 32 bit value still. The version number comes from https://cgit.freebsd.org/src/commit/?id=ea3061526e9ce5d3b65932c1d3e4437abd556d65. --- .../Process/Utility/RegisterContextFreeBSDTest.cpp | 9 + 1 file changed, 9 insertions(+) diff --git a/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp b/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp index e541a34e6e22a0..70697766dd82ba 100644 --- a/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp +++ b/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp @@ -7,6 +7,7 @@ //===--===// // clang-format off +#include #include #include #if defined(__arm__) @@ -362,7 +363,15 @@ TEST(RegisterContextFreeBSDTest, arm64) { EXPECT_GPR_ARM64(lr, lr); EXPECT_GPR_ARM64(sp, sp); EXPECT_GPR_ARM64(pc, elr); +#if __FreeBSD_version >= 1400084 + // LLDB assumes that cpsr is 32 bit but the kernel stores it as a 64 bit + // value. + EXPECT_THAT(GetRegParams(reg_ctx, gpr_cpsr_arm64), + ::testing::Pair(offsetof(reg, spsr), 4)); +#else + // Older kernels stored spsr as a 32 bit value. EXPECT_GPR_ARM64(cpsr, spsr); +#endif size_t base_offset = reg_ctx.GetRegisterInfo()[fpu_v0_arm64].byte_offset; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Account for spsr being 8 bytes in newer versions (PR #84032)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/84032 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Account for spsr being 8 bytes in newer versions (PR #84032)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Since https://reviews.freebsd.org/D38983, spsr (aka cpsr) is stored as an 8 byte value. However in lldb's structures it is a 32 bit value still. The version number comes from https://cgit.freebsd.org/src/commit/?id=ea3061526e9ce5d3b65932c1d3e4437abd556d65. --- Full diff: https://github.com/llvm/llvm-project/pull/84032.diff 1 Files Affected: - (modified) lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp (+9) ``diff diff --git a/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp b/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp index e541a34e6e22a0..70697766dd82ba 100644 --- a/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp +++ b/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp @@ -7,6 +7,7 @@ //===--===// // clang-format off +#include #include #include #if defined(__arm__) @@ -362,7 +363,15 @@ TEST(RegisterContextFreeBSDTest, arm64) { EXPECT_GPR_ARM64(lr, lr); EXPECT_GPR_ARM64(sp, sp); EXPECT_GPR_ARM64(pc, elr); +#if __FreeBSD_version >= 1400084 + // LLDB assumes that cpsr is 32 bit but the kernel stores it as a 64 bit + // value. + EXPECT_THAT(GetRegParams(reg_ctx, gpr_cpsr_arm64), + ::testing::Pair(offsetof(reg, spsr), 4)); +#else + // Older kernels stored spsr as a 32 bit value. EXPECT_GPR_ARM64(cpsr, spsr); +#endif size_t base_offset = reg_ctx.GetRegisterInfo()[fpu_v0_arm64].byte_offset; `` https://github.com/llvm/llvm-project/pull/84032 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][FreeBSD] Account for spsr being 8 bytes in newer versions (PR #84032)
DavidSpickett wrote: This may also imply there is work to be done to make lldb show the upper 32 bits, but I'll leave that to the FreeBSD experts to decide. https://github.com/llvm/llvm-project/pull/84032 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/81564 >From d65900f5e6169062fc0988b57fb5be2474789025 Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Mon, 12 Feb 2024 18:08:23 -0800 Subject: [PATCH 1/6] Fix lldb crash while handling concurrent vfork() --- .../Process/Linux/NativeThreadLinux.cpp | 12 - .../Process/gdb-remote/ProcessGDBRemote.cpp | 21 ++--- .../Process/gdb-remote/ProcessGDBRemote.h | 3 +- .../fork/concurrent_vfork/Makefile| 4 ++ .../concurrent_vfork/TestConcurrentVFork.py | 31 + .../fork/concurrent_vfork/main.cpp| 46 +++ 6 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 lldb/test/API/functionalities/fork/concurrent_vfork/Makefile create mode 100644 lldb/test/API/functionalities/fork/concurrent_vfork/TestConcurrentVFork.py create mode 100644 lldb/test/API/functionalities/fork/concurrent_vfork/main.cpp diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index b62e9f643fa792..cf8a1e7d34392a 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -120,7 +120,7 @@ bool NativeThreadLinux::GetStopReason(ThreadStopInfo &stop_info, case eStateCrashed: case eStateExited: case eStateSuspended: - case eStateUnloaded: + case eStateUnloaded: { if (log) LogThreadStopInfo(*log, m_stop_info, "m_stop_info in thread:"); stop_info = m_stop_info; @@ -128,7 +128,17 @@ bool NativeThreadLinux::GetStopReason(ThreadStopInfo &stop_info, if (log) LogThreadStopInfo(*log, stop_info, "returned stop_info:"); +// Include child process PID/TID for forks. +// Client expects " " format. +if (stop_info.reason == eStopReasonFork || +stop_info.reason == eStopReasonVFork) { + description = std::to_string(stop_info.details.fork.child_pid); + description += " "; + description += std::to_string(stop_info.details.fork.child_tid); +} + return true; + } case eStateInvalid: case eStateConnected: diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 629b191f3117aa..8ab2257e0a79b9 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -266,7 +266,7 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, m_waiting_for_attach(false), m_command_sp(), m_breakpoint_pc_offset(0), m_initial_tid(LLDB_INVALID_THREAD_ID), m_allow_flash_writes(false), - m_erased_flash_ranges(), m_vfork_in_progress(false) { + m_erased_flash_ranges(), m_vfork_in_progress(0) { m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadShouldExit, "async thread should exit"); m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue, @@ -5615,8 +5615,12 @@ void ProcessGDBRemote::DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) { void ProcessGDBRemote::DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid) { Log *log = GetLog(GDBRLog::Process); - assert(!m_vfork_in_progress); - m_vfork_in_progress = true; + LLDB_LOG( + log, + "ProcessGDBRemote::DidFork() called for child_pid: {0}, child_tid {1}", + child_pid, child_tid); + assert(m_vfork_in_progress >= 0); + ++m_vfork_in_progress; // Disable all software breakpoints for the duration of vfork. if (m_gdb_comm.SupportsGDBStoppointPacket(eBreakpointSoftware)) @@ -5670,8 +5674,8 @@ void ProcessGDBRemote::DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid) { } void ProcessGDBRemote::DidVForkDone() { - assert(m_vfork_in_progress); - m_vfork_in_progress = false; + --m_vfork_in_progress; + assert(m_vfork_in_progress >= 0); // Reenable all software breakpoints that were enabled before vfork. if (m_gdb_comm.SupportsGDBStoppointPacket(eBreakpointSoftware)) @@ -5681,7 +5685,10 @@ void ProcessGDBRemote::DidVForkDone() { void ProcessGDBRemote::DidExec() { // If we are following children, vfork is finished by exec (rather than // vforkdone that is submitted for parent). - if (GetFollowForkMode() == eFollowChild) -m_vfork_in_progress = false; + if (GetFollowForkMode() == eFollowChild) { +if (m_vfork_in_progress > 0) + --m_vfork_in_progress; +assert(m_vfork_in_progress >= 0); + } Process::DidExec(); } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index c1ea1cc7905587..29ed770c1275ea 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -301,7 +301,8 @@ class ProcessGDBRemote : public Process, using FlashRange = FlashRangeVector::Entry;
[Lldb-commits] [lldb] [lldb] Add ability to detect darwin host linker version to xfail tests (PR #83941)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/83941 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
dwblaikie wrote: > I did the first part of the renaming @dwblaikie : looks good? Hmm - this patch still seems to have both renamings in it, if I'm reading the PR correctly? I take it from the subject that isn't the intent/the intent is that his patch only does the ThreadPool->DefaultThreadPool change? https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
dwblaikie wrote: Oh, maybe issues related to layered patches - this is intended to be submitted after the introduction of the ThreadPoolInterface? But includes those changes in this review at the moment (I still haven't figured out what we're doing for dependent changes - and I thought the ThreadPoolInterface-introducing patch was already in - so not sure why it appears in this patch too) https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Allow languages to filter breakpoints set by line (PR #83908)
@@ -199,13 +200,24 @@ bool operator<(const SourceLoc lhs, const SourceLoc rhs) { } } // namespace +static void +ApplyLanguageFilters(llvm::SmallVectorImpl &sc_list) { + llvm::erase_if(sc_list, [](SymbolContext &sc) { +if (Language *lang = Language::FindPlugin(sc.GetLanguage())) + return !lang->IsInterestingCtxForLineBreakpoint(sc); +return false; + }); +} + void BreakpointResolver::SetSCMatchesByLine( SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, uint32_t line, std::optional column) { llvm::SmallVector all_scs; for (uint32_t i = 0; i < sc_list.GetSize(); ++i) all_scs.push_back(sc_list[i]); + ApplyLanguageFilters(all_scs); felipepiovezan wrote: Yup, I'll change that in the next iteration of this patch (it was uploaded before Adrian's comment) https://github.com/llvm/llvm-project/pull/83908 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
joker-eph wrote: Actually no: the first patch landed already, so `ThreadPoolInterface` is now the base class in the codebase. I have some mixup here in that when renaming ThreadPool -> DefaultThreadPool, I used the base class ThreadPoolInterface when updating some of the uses. I will push these ahead as a NFC change and rebase, that'll reduce the diff here. https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1b812f9 - [lldb] Log to system log instead of stderr from Host::SystemLog (#83366)
Author: Jonas Devlieghere Date: 2024-03-05T10:56:01-08:00 New Revision: 1b812f9cd64c14ab7600626c147da88f21e0217c URL: https://github.com/llvm/llvm-project/commit/1b812f9cd64c14ab7600626c147da88f21e0217c DIFF: https://github.com/llvm/llvm-project/commit/1b812f9cd64c14ab7600626c147da88f21e0217c.diff LOG: [lldb] Log to system log instead of stderr from Host::SystemLog (#83366) Currently, calls to Host::SystemLog print to stderr on all host platforms except Darwin. This severely limits its value on the command line, where we don't want to overload the user with log messages. Switch to using the syslog function on POSIX systems to send messages to the system logger instead of stdout. On Darwin systems this sends the log message to os_log, which matches what we do today. Nevertheless I kept the current implementation that uses os_log directly as it gives us more freedom. I'm not sure if there's an equivalent on Windows, so I kept the existing behavior of logging to stderr. Added: Modified: lldb/source/Host/common/Host.cpp Removed: diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index f4cec97f5af633..565138ba17031f 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -89,8 +89,19 @@ using namespace lldb; using namespace lldb_private; #if !defined(__APPLE__) +#if !defined(_WIN32) +#include +void Host::SystemLog(llvm::StringRef message) { + static llvm::once_flag g_openlog_once; + llvm::call_once(g_openlog_once, [] { +openlog("lldb", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); + }); + syslog(LOG_INFO, "%s", message.data()); +} +#else void Host::SystemLog(llvm::StringRef message) { llvm::errs() << message; } #endif +#endif #if !defined(__APPLE__) && !defined(_WIN32) static thread_result_t ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Log to system log instead of stderr from Host::SystemLog (PR #83366)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/83366 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Address mask sbprocess apis and new mask invalid const (PR #83663)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83663 >From c993c7cc7c1669ca7d06e52f1a1ff8dbefe9ebc9 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Thu, 29 Feb 2024 17:02:42 -0800 Subject: [PATCH 1/5] [lldb] Add SBProcess methods for get/set/use address masks (#83095) I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 114 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-defines.h | 5 + lldb/include/lldb/lldb-enumerations.h | 16 +++ lldb/source/API/SBProcess.cpp | 92 ++ lldb/source/Target/Process.cpp| 10 +- lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 74 .../python_api/process/address-masks/main.c | 5 + 10 files changed, 328 insertions(+), 6 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7da3335a7234b7 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,120 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// This choice of mask can be important for example on AArch32 + /// systems. Where instructions where instructions start on even addresses, + /// the 0th bit may be used to indicate that a function is thumb code. On + /// such a target, the eAddressMaskTypeCode may clear the 0th bit from an + /// address to get the actual address Whereas eAddressMaskTypeData would not. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures (e.g., AArch64), it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods description of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + ///
[Lldb-commits] [lldb] Address mask sbprocess apis and new mask invalid const (PR #83663)
@@ -0,0 +1,130 @@ +"""Test Python APIs for setting, getting, and using address masks.""" + +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class AddressMasksTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def reset_all_masks(self, process): +process.SetAddressMask( +lldb.eAddressMaskTypeAll, +lldb.LLDB_INVALID_ADDRESS_MASK, +lldb.eAddressMaskRangeAll, +) + +def test_address_masks(self): +self.build() +(target, process, t, bp) = lldbutil.run_to_source_breakpoint( +self, "break here", lldb.SBFileSpec("main.c") +) + +process.SetAddressableBits(lldb.eAddressMaskTypeAll, 42) +self.assertEqual(0x02953F94, process.FixAddress(0x00265E953F94)) +self.reset_all_masks(process) + +# ~((1ULL<<42)-1) == 0xfc00 +process.SetAddressMask(lldb.eAddressMaskTypeAll, 0xFC00) +self.assertEqual(0x02953F94, process.FixAddress(0x00265E953F94)) +self.reset_all_masks(process) + +# Check that all bits can pass through unmodified +process.SetAddressableBits(lldb.eAddressMaskTypeAll, 64) +self.assertEqual(0x00265E953F94, process.FixAddress(0x00265E953F94)) +self.reset_all_masks(process) + +process.SetAddressableBits( +lldb.eAddressMaskTypeAll, 42, lldb.eAddressMaskRangeAll +) +self.assertEqual(0x02950001F694, process.FixAddress(0x00265E950001F694)) +self.assertEqual(0xFE95F694, process.FixAddress(0xFFA65E95F694)) +self.reset_all_masks(process) + +# Set a eAddressMaskTypeCode which has the low 3 bits marked as non-address +# bits, confirm that they're cleared by FixAddress. +process.SetAddressableBits( +lldb.eAddressMaskTypeAll, 42, lldb.eAddressMaskRangeAll +) +mask = process.GetAddressMask(lldb.eAddressMaskTypeAny) +process.SetAddressMask(lldb.eAddressMaskTypeCode, mask | 0x3) +process.SetAddressMask(lldb.eAddressMaskTypeCode, 0xFC03) jasonmolenda wrote: Ah, thanks for spotting that. I originally wrote it as a hex literal and then I thought "Oh it would be clearer to bitmask in the 0b111" and forgot to remove the lit. https://github.com/llvm/llvm-project/pull/83663 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Don't require a UUID in a .dwp file. (PR #83935)
https://github.com/jeffreytan81 approved this pull request. https://github.com/llvm/llvm-project/pull/83935 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Don't require a UUID in a .dwp file. (PR #83935)
@@ -139,6 +139,20 @@ // RUN: -o "target variable a" \ // RUN: -b %t | FileCheck %s +// Now move the .debug and .dwp file into another directory so that we can use jeffreytan81 wrote: Are we able to create a stale dwp testcase to ensure lldb won't load mismatch dwo files in dwp after ignoring UUID? For example, 1. Build matching dwp for one target 2. Move target main executable to a different location 3. Modify source file and rebuild a new dwp which should not match the original saved executable 4. Try to debug the original saved binary which will load dwp but examining local variables should emit error due to mismatch dwo. https://github.com/llvm/llvm-project/pull/83935 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print a message when background tasks take a while to complete (PR #82799)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/82799 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2f343fc - [lldb] Print a message when background tasks take a while to complete (#82799)
Author: Jonas Devlieghere Date: 2024-03-05T12:04:32-08:00 New Revision: 2f343fc1574f36b3b5ff1acf63407c53dcdac331 URL: https://github.com/llvm/llvm-project/commit/2f343fc1574f36b3b5ff1acf63407c53dcdac331 DIFF: https://github.com/llvm/llvm-project/commit/2f343fc1574f36b3b5ff1acf63407c53dcdac331.diff LOG: [lldb] Print a message when background tasks take a while to complete (#82799) When terminating the debugger, we wait for all background tasks to complete. Given that there's no way to interrupt those treads, this can take a while. When that happens, the debugger appears to hang at exit. The above situation is unfortunately not uncommon when background downloading of dSYMs is enabled (`symbols.auto-download background`). Even when calling dsymForUUID with a reasonable timeout, it can take a while to complete. This patch improves the user experience by printing a message from the driver when it takes more than one (1) second to terminate the debugger. Added: Modified: lldb/tools/driver/Driver.cpp Removed: diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 9286abb27e1332..a821699c5e2ec2 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -801,6 +802,18 @@ int main(int argc, char const *argv[]) { } } - SBDebugger::Terminate(); + // When terminating the debugger we have to wait on all the background tasks + // to complete, which can take a while. Print a message when this takes longer + // than 1 second. + { +std::future future = +std::async(std::launch::async, []() { SBDebugger::Terminate(); }); + +if (future.wait_for(std::chrono::seconds(1)) == std::future_status::timeout) + fprintf(stderr, "Waiting for background tasks to complete...\n"); + +future.wait(); + } + return exit_code; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph edited https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/83702 >From 1b407d9d5abc9a1cf58afaf7f32ed40446d55f52 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Tue, 5 Mar 2024 10:38:41 -0800 Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. --- bolt/lib/Core/ParallelUtilities.cpp | 4 ++-- bolt/tools/merge-fdata/merge-fdata.cpp| 2 +- .../clang-doc/tool/ClangDocMain.cpp | 2 +- .../tool/FindAllSymbolsMain.cpp | 2 +- clang/lib/Tooling/AllTUsExecution.cpp | 2 +- clang/tools/clang-scan-deps/ClangScanDeps.cpp | 2 +- lld/MachO/Writer.cpp | 2 +- lldb/source/Core/Debugger.cpp | 4 ++-- llvm/docs/ORCv2.rst | 2 +- .../SpeculativeJIT/SpeculativeJIT.cpp | 2 +- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- llvm/include/llvm/Support/ThreadPool.h| 7 +++--- llvm/lib/CodeGen/ParallelCG.cpp | 2 +- llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 4 ++-- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 ++-- llvm/lib/Support/BalancedPartitioning.cpp | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-cov/CoverageExporterJson.cpp | 2 +- llvm/tools/llvm-cov/CoverageReport.cpp| 4 ++-- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Delta.cpp | 2 +- llvm/unittests/ADT/LazyAtomicPointerTest.cpp | 4 ++-- llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++--- llvm/unittests/Support/ParallelTest.cpp | 2 +- llvm/unittests/Support/ThreadPool.cpp | 22 +-- .../Support/ThreadSafeAllocatorTest.cpp | 6 ++--- mlir/include/mlir/IR/MLIRContext.h| 2 +- mlir/lib/CAPI/IR/Support.cpp | 2 +- mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 2 +- mlir/lib/IR/MLIRContext.cpp | 4 ++-- 37 files changed, 65 insertions(+), 66 deletions(-) diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp index 88d9444a6a2ba7..5f5e96e0e7881c 100644 --- a/bolt/lib/Core/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -49,7 +49,7 @@ namespace ParallelUtilities { namespace { /// A single thread pool that is used to run parallel tasks -std::unique_ptr ThreadPoolPtr; +std::unique_ptr ThreadPoolPtr; unsigned computeCostFor(const BinaryFunction &BF, const PredicateTy &SkipPredicate, @@ -106,7 +106,7 @@ ThreadPoolInterface &getThreadPool() { if (ThreadPoolPtr.get()) return *ThreadPoolPtr; - ThreadPoolPtr = std::make_unique( + ThreadPoolPtr = std::make_unique( llvm::hardware_concurrency(opts::ThreadCount)); return *ThreadPoolPtr; } diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp index c6dfd3cfdc56de..f2ac5ad4492ee5 100644 --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl &Filenames) { // least 4 tasks. ThreadPoolStrategy S = optimal_concurrency( std::max(Filenames.size() / 4, static_cast(1))); - ThreadPool Pool(S); + DefaultThreadPool Pool(S); DenseMap ParsedProfiles( Pool.getMaxConcurrency()); for (const auto &Filename : Filenames) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 22bdb5de22d871..21b581fa6df2e1 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -238,7 +238,7 @@ Example usage for a project using a compile commands database: Error = false; llvm::sys::Mutex IndexMutex; // ExecutorConcurrency is a flag exposed by AllTUsExecution.h - llvm::ThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency)); + llvm::DefaultThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency)); for (auto &Group : USRToBitcode) { Pool.async([&]() { std::vector> Infos; diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp index b2d0efecc20692..298b02e77cb0aa 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp +++ b/clang-tools-extra/clang-include-fixer/find
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/84071 When debugging LLDB itself, it can often be useful to know the mangled name of the function where a breakpoint is set. Since the `--verbose` setting of `break --list` is aimed at debugging LLDB, this patch makes it so that the mangled name is also printed in that mode. Note about testing: since mangling is not the same on Windows and Linux, the test refrains from hardcoding mangled names. >From 0252a23a8a63acca1a51a9f838b6ace3f3b13cc1 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Thu, 29 Feb 2024 15:48:28 -0800 Subject: [PATCH] [lldb] Print mangled names with verbose break list When debugging LLDB itself, it can often be useful to know the mangled name of the function where a breakpoint is set. Since the `--verbose` setting of `break --list` is aimed at debugging LLDB, this patch makes it so that the mangled name is also printed in that mode. Note about testing: since mangling is not the same on Windows and Linux, the test refrains from hardcoding mangled names. --- lldb/source/Breakpoint/BreakpointLocation.cpp| 3 +++ .../breakpoint_options/TestBreakpointOptions.py | 9 + 2 files changed, 12 insertions(+) diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index f7b8ca1f5506f3..045ed145cc7c49 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); + s->PutCString(sc.function->GetMangled().GetMangledName().AsCString("")); } if (sc.line_entry.line > 0) { diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py b/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py index 129290909029a1..c3b911145db3a6 100644 --- a/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py @@ -90,6 +90,15 @@ def breakpoint_options_language_test(self): num_expected_locations=1, ) +self.expect( +"breakpoint list -v", +"Verbose breakpoint list contains mangled names", +substrs=[ +"function = ns::func" +"mangled function =" +], +) + # This should create a breakpoint with 0 locations. lldbutil.run_break_set_by_symbol( self, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Felipe de Azevedo Piovezan (felipepiovezan) Changes When debugging LLDB itself, it can often be useful to know the mangled name of the function where a breakpoint is set. Since the `--verbose` setting of `break --list` is aimed at debugging LLDB, this patch makes it so that the mangled name is also printed in that mode. Note about testing: since mangling is not the same on Windows and Linux, the test refrains from hardcoding mangled names. --- Full diff: https://github.com/llvm/llvm-project/pull/84071.diff 2 Files Affected: - (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+3) - (modified) lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py (+9) ``diff diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index f7b8ca1f5506f3..045ed145cc7c49 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); + s->PutCString(sc.function->GetMangled().GetMangledName().AsCString("")); } if (sc.line_entry.line > 0) { diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py b/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py index 129290909029a1..c3b911145db3a6 100644 --- a/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py +++ b/lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py @@ -90,6 +90,15 @@ def breakpoint_options_language_test(self): num_expected_locations=1, ) +self.expect( +"breakpoint list -v", +"Verbose breakpoint list contains mangled names", +substrs=[ +"function = ns::func" +"mangled function =" +], +) + # This should create a breakpoint with 0 locations. lldbutil.run_break_set_by_symbol( self, `` https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 05390df497535b26879a7a96e03a76af26c8bcd3...0252a23a8a63acca1a51a9f838b6ace3f3b13cc1 lldb/test/API/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py `` View the diff from darker here. ``diff --- TestBreakpointOptions.py2024-03-04 23:52:55.00 + +++ TestBreakpointOptions.py2024-03-05 21:30:32.532036 + @@ -91,14 +91,11 @@ ) self.expect( "breakpoint list -v", "Verbose breakpoint list contains mangled names", -substrs=[ -"function = ns::func" -"mangled function =" -], +substrs=["function = ns::func" "mangled function ="], ) # This should create a breakpoint with 0 locations. lldbutil.run_break_set_by_symbol( self, `` https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
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 05390df497535b26879a7a96e03a76af26c8bcd3 0252a23a8a63acca1a51a9f838b6ace3f3b13cc1 -- 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 045ed145cc..329de71f93 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -526,7 +526,8 @@ void BreakpointLocation::GetDescription(Stream *s, s->PutCString(sc.function->GetName().AsCString("")); s->EOL(); s->Indent("mangled function = "); - s->PutCString(sc.function->GetMangled().GetMangledName().AsCString("")); + s->PutCString(sc.function->GetMangled().GetMangledName().AsCString( + "")); } if (sc.line_entry.line > 0) { `` https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
adrian-prantl wrote: > I would almost vote to change everything to uint64_t except for the public > API since we can't change the API without breaking. Though I winder if we can > actually change this one: @bulbazord I discovered that the idea that these are 32-bit values is deeply baked into the code by use of UINT32_MAX sentinel values in multiple places. We can of course change that too at some point, but we're really not giving anything up with this patch that isn't already a limitation. https://github.com/llvm/llvm-project/pull/83501 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); jimingham wrote: Do we want to emit "mangled function" for C which doesn't have mangled names? It might be nicer to check whether the GetMangledName returns a mangled name, and only print it if it does? Having: function = main mangled function = main looks a little silly. https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -90,6 +90,15 @@ def breakpoint_options_language_test(self): num_expected_locations=1, ) jimingham wrote: run_break_set_by_symbol returns the break ID of the new breakpoint. You could look it up, get its location, get the function from the symbol and get its mangled name. That way you could do a mangling scheme independent test that you produced the right mangled name. https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
https://github.com/jimingham edited https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); felipepiovezan wrote: That's doable, I'll have a look. (in the C case, we print "unknown" with the current impl, which is arguably more silly) https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
https://github.com/clayborg commented: Might be nice to print the mangled name of the symbol as well? We are doing it for the function... https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); + s->PutCString(sc.function->GetMangled().GetMangledName().AsCString("")); clayborg wrote: ``` if (sc.function->GetMangled().GetMangledName()) { s->Indent("mangled function = "); s->PutCString(sc.function->GetMangled().GetMangledName().AsCString("")); } ``` https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); jimingham wrote: I actually don't feel super strongly about this one, however. https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #78977)
paolosevMSFT wrote: > Apologies for the delay. LGTM! Thanks! I have not merged any changes in several years and I am not very familiar with the new process, now that llvm_project has moved to Github. I have read https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr and if I am not wrong there is no safe gating on PR merge commits? How do I make sure all tests pass in all platforms, before merging? https://github.com/llvm/llvm-project/pull/78977 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); jimingham wrote: Yeah, we really shouldn't print "unknown". You could make the fallback "", since there can't be a mangled name that's that, and then if you get back "" don't print in. https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
https://github.com/jimingham edited https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); + s->PutCString(sc.function->GetMangled().GetMangledName().AsCString("")); jimingham wrote: Does SymbolContext::GetFunctionName do the right thing here? It will also find the innermost inlined function if the SC is in some inlining and return that as well. https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); + s->PutCString(sc.function->GetMangled().GetMangledName().AsCString("")); jimingham wrote: If it does, you could just call it twice, once with the prefer mangled false, and once true. https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/83702 >From ea79b6037497230b23caf36024a9e6883d3cac04 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Tue, 5 Mar 2024 10:38:41 -0800 Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. --- bolt/lib/Core/ParallelUtilities.cpp | 4 ++-- bolt/tools/merge-fdata/merge-fdata.cpp| 2 +- .../clang-doc/tool/ClangDocMain.cpp | 2 +- .../tool/FindAllSymbolsMain.cpp | 2 +- clang/lib/Tooling/AllTUsExecution.cpp | 2 +- clang/tools/clang-scan-deps/ClangScanDeps.cpp | 2 +- lld/MachO/Writer.cpp | 2 +- lldb/source/Core/Debugger.cpp | 4 ++-- llvm/docs/ORCv2.rst | 2 +- .../SpeculativeJIT/SpeculativeJIT.cpp | 2 +- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- llvm/include/llvm/Support/ThreadPool.h| 7 +++--- llvm/lib/CodeGen/ParallelCG.cpp | 2 +- llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 4 ++-- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 ++-- llvm/lib/Support/BalancedPartitioning.cpp | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-cov/CoverageExporterJson.cpp | 2 +- llvm/tools/llvm-cov/CoverageReport.cpp| 4 ++-- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Delta.cpp | 2 +- llvm/unittests/ADT/LazyAtomicPointerTest.cpp | 4 ++-- llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++--- llvm/unittests/Support/ParallelTest.cpp | 2 +- llvm/unittests/Support/ThreadPool.cpp | 22 +-- .../Support/ThreadSafeAllocatorTest.cpp | 6 ++--- mlir/include/mlir/IR/MLIRContext.h| 2 +- mlir/lib/CAPI/IR/Support.cpp | 2 +- mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 2 +- mlir/lib/IR/MLIRContext.cpp | 4 ++-- 37 files changed, 65 insertions(+), 66 deletions(-) diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp index 88d9444a6a2ba7..5f5e96e0e7881c 100644 --- a/bolt/lib/Core/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -49,7 +49,7 @@ namespace ParallelUtilities { namespace { /// A single thread pool that is used to run parallel tasks -std::unique_ptr ThreadPoolPtr; +std::unique_ptr ThreadPoolPtr; unsigned computeCostFor(const BinaryFunction &BF, const PredicateTy &SkipPredicate, @@ -106,7 +106,7 @@ ThreadPoolInterface &getThreadPool() { if (ThreadPoolPtr.get()) return *ThreadPoolPtr; - ThreadPoolPtr = std::make_unique( + ThreadPoolPtr = std::make_unique( llvm::hardware_concurrency(opts::ThreadCount)); return *ThreadPoolPtr; } diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp index c6dfd3cfdc56de..f2ac5ad4492ee5 100644 --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl &Filenames) { // least 4 tasks. ThreadPoolStrategy S = optimal_concurrency( std::max(Filenames.size() / 4, static_cast(1))); - ThreadPool Pool(S); + DefaultThreadPool Pool(S); DenseMap ParsedProfiles( Pool.getMaxConcurrency()); for (const auto &Filename : Filenames) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 22bdb5de22d871..21b581fa6df2e1 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -238,7 +238,7 @@ Example usage for a project using a compile commands database: Error = false; llvm::sys::Mutex IndexMutex; // ExecutorConcurrency is a flag exposed by AllTUsExecution.h - llvm::ThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency)); + llvm::DefaultThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency)); for (auto &Group : USRToBitcode) { Pool.async([&]() { std::vector> Infos; diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp index b2d0efecc20692..298b02e77cb0aa 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp +++ b/clang-tools-extra/clang-include-fixer/find
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -524,6 +524,9 @@ void BreakpointLocation::GetDescription(Stream *s, s->EOL(); s->Indent("function = "); s->PutCString(sc.function->GetName().AsCString("")); + s->EOL(); + s->Indent("mangled function = "); + s->PutCString(sc.function->GetMangled().GetMangledName().AsCString("")); clayborg wrote: It might be nice in verbose mode to see the whole chain of functions from the concrete function down to the most inlined? https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/81564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
https://github.com/clayborg requested changes to this pull request. https://github.com/llvm/llvm-project/pull/81564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
@@ -0,0 +1,115 @@ +""" +Make sure that the concurrent vfork() from multiple threads works correctly. +""" + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestConcurrentVFork(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def get_pid_from_variable(self): +target = self.dbg.GetTargetAtIndex(0) +return target.FindFirstGlobalVariable("g_pid").GetValueAsUnsigned() + +def build_run_to_breakpoint(self, use_fork, call_exec): +self.build() + +args = [] +if use_fork: +args.append("--fork") +if call_exec: +args.append("--exec") +launch_info = lldb.SBLaunchInfo(args) +launch_info.SetWorkingDirectory(self.getBuildDir()) + +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.cpp") +) + +def follow_parent_helper(self, use_fork, call_exec): +self.build_run_to_breakpoint(use_fork, call_exec) + +parent_pid = self.get_pid_from_variable() clayborg wrote: pass target into this function: ``` parent_pid = self.get_pid_from_variable(target) ``` https://github.com/llvm/llvm-project/pull/81564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
@@ -0,0 +1,115 @@ +""" +Make sure that the concurrent vfork() from multiple threads works correctly. +""" + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestConcurrentVFork(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def get_pid_from_variable(self): +target = self.dbg.GetTargetAtIndex(0) clayborg wrote: Don't use this, the target should be returned from the call to `lldbutil.run_to_source_breakpoint`. I put example code in an inline comment below. So pass the target into here. I don't think we can rely on the debugger having only one target. https://github.com/llvm/llvm-project/pull/81564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
@@ -0,0 +1,115 @@ +""" +Make sure that the concurrent vfork() from multiple threads works correctly. +""" + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestConcurrentVFork(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def get_pid_from_variable(self): +target = self.dbg.GetTargetAtIndex(0) +return target.FindFirstGlobalVariable("g_pid").GetValueAsUnsigned() + +def build_run_to_breakpoint(self, use_fork, call_exec): +self.build() + +args = [] +if use_fork: +args.append("--fork") +if call_exec: +args.append("--exec") +launch_info = lldb.SBLaunchInfo(args) +launch_info.SetWorkingDirectory(self.getBuildDir()) + +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.cpp") +) + +def follow_parent_helper(self, use_fork, call_exec): +self.build_run_to_breakpoint(use_fork, call_exec) + +parent_pid = self.get_pid_from_variable() +self.runCmd("settings set target.process.follow-fork-mode parent") +self.runCmd("settings set target.process.stop-on-exec False", check=False) +self.expect( +"continue", substrs=[f"Process {parent_pid} exited with status = 0"] +) + +def follow_child_helper(self, use_fork, call_exec): +self.build_run_to_breakpoint(use_fork, call_exec) clayborg wrote: (target, process, thread, bkpt) = self.build_run_to_breakpoint(use_fork, call_exec) https://github.com/llvm/llvm-project/pull/81564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
@@ -0,0 +1,115 @@ +""" +Make sure that the concurrent vfork() from multiple threads works correctly. +""" + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestConcurrentVFork(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def get_pid_from_variable(self): +target = self.dbg.GetTargetAtIndex(0) +return target.FindFirstGlobalVariable("g_pid").GetValueAsUnsigned() + +def build_run_to_breakpoint(self, use_fork, call_exec): +self.build() + +args = [] +if use_fork: +args.append("--fork") +if call_exec: +args.append("--exec") +launch_info = lldb.SBLaunchInfo(args) +launch_info.SetWorkingDirectory(self.getBuildDir()) + +lldbutil.run_to_source_breakpoint( clayborg wrote: Get the target, process, thread and breakpoint from the return values: ``` (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( ``` https://github.com/llvm/llvm-project/pull/81564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
@@ -0,0 +1,115 @@ +""" +Make sure that the concurrent vfork() from multiple threads works correctly. +""" + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestConcurrentVFork(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def get_pid_from_variable(self): +target = self.dbg.GetTargetAtIndex(0) +return target.FindFirstGlobalVariable("g_pid").GetValueAsUnsigned() + +def build_run_to_breakpoint(self, use_fork, call_exec): +self.build() + +args = [] +if use_fork: +args.append("--fork") +if call_exec: +args.append("--exec") +launch_info = lldb.SBLaunchInfo(args) +launch_info.SetWorkingDirectory(self.getBuildDir()) + +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.cpp") +) + +def follow_parent_helper(self, use_fork, call_exec): +self.build_run_to_breakpoint(use_fork, call_exec) clayborg wrote: ``` (target, process, thread, bkpt) = self.build_run_to_breakpoint(use_fork, call_exec) ``` https://github.com/llvm/llvm-project/pull/81564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix lldb crash while handling concurrent vfork() (PR #81564)
@@ -0,0 +1,115 @@ +""" +Make sure that the concurrent vfork() from multiple threads works correctly. +""" + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestConcurrentVFork(TestBase): +NO_DEBUG_INFO_TESTCASE = True + +def get_pid_from_variable(self): +target = self.dbg.GetTargetAtIndex(0) +return target.FindFirstGlobalVariable("g_pid").GetValueAsUnsigned() + +def build_run_to_breakpoint(self, use_fork, call_exec): +self.build() + +args = [] +if use_fork: +args.append("--fork") +if call_exec: +args.append("--exec") +launch_info = lldb.SBLaunchInfo(args) +launch_info.SetWorkingDirectory(self.getBuildDir()) + +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.cpp") +) clayborg wrote: return all of the info from `lldbutil.run_to_source_breakpoint` from this function: ``` return (target, process, thread, bkpt) ``` https://github.com/llvm/llvm-project/pull/81564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
https://github.com/bulbazord approved this pull request. I'm a little disappointed but I think this is the right step to take. Thanks! https://github.com/llvm/llvm-project/pull/83501 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
adrian-prantl wrote: > So the only thing left to here is to stop using UINT32_MAX and switch to > using UINT64_MAX on internal APIs. If the goal is to migrate to 64-bit everywhere, yes. But we'd need to do this on a bunch more APIs. If you feel strongly we need to do this I can do it, but the patch will get much larger this way. https://github.com/llvm/llvm-project/pull/83501 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
https://github.com/clayborg approved this pull request. As long as the changes are planned for quick follow up patches I am good not changing it up front. And we can probably just switch to using `std::optional` instead of switching things to use UINT32_MAX anyway with a follow up patch which is even better. https://github.com/llvm/llvm-project/pull/83501 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Don't require a UUID in a .dwp file. (PR #83935)
@@ -139,6 +139,20 @@ // RUN: -o "target variable a" \ // RUN: -b %t | FileCheck %s +// Now move the .debug and .dwp file into another directory so that we can use clayborg wrote: That is already covered by other split DWARF testing, so it doesn't need to be covered here. https://github.com/llvm/llvm-project/pull/83935 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix up the TestGlobalModuleCache showing we succeed mostly. (PR #84099)
https://github.com/jimingham created https://github.com/llvm/llvm-project/pull/84099 The point behind this test was that we were noticing when running under a more complicated app than the driver (e.g. Xcode) we were seeing Modules get stranded when doing incremental debugging. These tests were to see if any of the slightly not normal but iterative development-like actions would of themselves strand modules. I couldn't come up with a case where they did, but a couple of test were failing because I didn't do them quite right. In particular, "two targets one debugger" was failing because SBTarget.Clear doesn't actually clear the target, just the SBTarget SP. So I needed to actually delete the target for this one to work. I also added a "two targets two debuggers" which also successfully deletes all its modules by the time it is done. Given that it looks like it's hard to get lldb itself to strand modules, this is likely just an error on the IDE side. But also, Modules are expensive objects and once we formally get rid of them by evicting them from the Shared Module Cache, it would be good to actively Finalize them so they can't sit around taking up resources. So I also add a couple test that show that an errant Python reference to this will keep modules that lldb can no longer use alive. I made them fail and xfailed them. But when we teach lldb to Finalize Modules, then we can check at the end of the test that the modules we held onto have been finalized. >From 44ef8137093c0d2e417cf09e71e4f81699d6d100 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Tue, 5 Mar 2024 12:49:11 -0800 Subject: [PATCH 1/2] Make the two targets one debugger and two targets two debuggers tests pass. The two targets one debugger test was failing because I incorrectly thought SBTarget.Clear did more than reset that SBTargets internal shared pointer, which in this case didn't do anything, since there are lots of other shared pointer references to the target. Calling "target delete" fixed that failure. The two debuggers two targets test was failing because the test wasn't right. Note, what this shows is that actually deleting Modules from the shared module cache happens in the normal course of shutting down lldb. But it is quite easy to defeat this, for instance by holding another shared pointer to the main Module. Then it will never go away. --- .../TestGlobalModuleCache.py | 57 +++ 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py index 0942dcd655b750..500efb5fe594af 100644 --- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py +++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py @@ -19,7 +19,7 @@ class GlobalModuleCacheTestCase(TestBase): def check_counter_var(self, thread, value): frame = thread.frames[0] var = frame.FindVariable("counter") -self.assertTrue(var.GetError().Success(), "Got counter variable") +self.assertSuccess(var.GetError(), "Didn't get counter variable") self.assertEqual(var.GetValueAsUnsigned(), value, "This was one-print") def copy_to_main(self, src, dst): @@ -28,12 +28,13 @@ def copy_to_main(self, src, dst): time.sleep(2) try: # Make sure dst is writeable before trying to write to it. -subprocess.run( -["chmod", "777", dst], -stdin=None, -capture_output=False, -encoding="utf-8", -) +if os.path.exists(dst): +subprocess.run( +["chmod", "777", dst], +stdin=None, +capture_output=False, +encoding="utf-8", +) shutil.copy(src, dst) except: self.fail(f"Could not copy {src} to {dst}") @@ -49,19 +50,16 @@ def copy_to_main(self, src, dst): def test_OneTargetOneDebugger(self): self.do_test(True, True) -# This behaves as implemented but that behavior is not desirable. -# This test tests for the desired behavior as an expected fail. + @skipIfWindows -@expectedFailureAll @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_TwoTargetsOneDebugger(self): self.do_test(False, True) @skipIfWindows -@expectedFailureAll @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) -def test_OneTargetTwoDebuggers(self): -self.do_test(True, False) +def test_TwoTargetsTwoDebuggers(self): +self.do_test(False, False) def do_test(self, one_target, one_debugger): # Make sure that if we have one target, and we run, then @@ -94,7 +92,6 @@ def do_test(self, one_target, one_debugger): process.Kill() # Now copy two-print.c over mai
[Lldb-commits] [lldb] Fix up the TestGlobalModuleCache showing we succeed mostly. (PR #84099)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (jimingham) Changes The point behind this test was that we were noticing when running under a more complicated app than the driver (e.g. Xcode) we were seeing Modules get stranded when doing incremental debugging. These tests were to see if any of the slightly not normal but iterative development-like actions would of themselves strand modules. I couldn't come up with a case where they did, but a couple of test were failing because I didn't do them quite right. In particular, "two targets one debugger" was failing because SBTarget.Clear doesn't actually clear the target, just the SBTarget SP. So I needed to actually delete the target for this one to work. I also added a "two targets two debuggers" which also successfully deletes all its modules by the time it is done. Given that it looks like it's hard to get lldb itself to strand modules, this is likely just an error on the IDE side. But also, Modules are expensive objects and once we formally get rid of them by evicting them from the Shared Module Cache, it would be good to actively Finalize them so they can't sit around taking up resources. So I also add a couple test that show that an errant Python reference to this will keep modules that lldb can no longer use alive. I made them fail and xfailed them. But when we teach lldb to Finalize Modules, then we can check at the end of the test that the modules we held onto have been finalized. --- Full diff: https://github.com/llvm/llvm-project/pull/84099.diff 1 Files Affected: - (modified) lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py (+74-24) ``diff diff --git a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py index 0942dcd655b750..a1b4ec4f9ef405 100644 --- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py +++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py @@ -19,7 +19,7 @@ class GlobalModuleCacheTestCase(TestBase): def check_counter_var(self, thread, value): frame = thread.frames[0] var = frame.FindVariable("counter") -self.assertTrue(var.GetError().Success(), "Got counter variable") +self.assertSuccess(var.GetError(), "Didn't get counter variable") self.assertEqual(var.GetValueAsUnsigned(), value, "This was one-print") def copy_to_main(self, src, dst): @@ -28,12 +28,13 @@ def copy_to_main(self, src, dst): time.sleep(2) try: # Make sure dst is writeable before trying to write to it. -subprocess.run( -["chmod", "777", dst], -stdin=None, -capture_output=False, -encoding="utf-8", -) +if os.path.exists(dst): +subprocess.run( +["chmod", "777", dst], +stdin=None, +capture_output=False, +encoding="utf-8", +) shutil.copy(src, dst) except: self.fail(f"Could not copy {src} to {dst}") @@ -49,25 +50,42 @@ def copy_to_main(self, src, dst): def test_OneTargetOneDebugger(self): self.do_test(True, True) -# This behaves as implemented but that behavior is not desirable. -# This test tests for the desired behavior as an expected fail. + @skipIfWindows -@expectedFailureAll @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_TwoTargetsOneDebugger(self): self.do_test(False, True) +@expectedFailureAll() # An external reference keeps modules alive @skipIfWindows -@expectedFailureAll @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) -def test_OneTargetTwoDebuggers(self): -self.do_test(True, False) +def test_TwoTargetsOneDebuggerWithPin(self): +self.do_test(False, True, True) -def do_test(self, one_target, one_debugger): +@skipIfWindows +@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) +def test_TwoTargetsTwoDebuggers(self): +self.do_test(False, False) + +@expectedFailureAll() # An external reference keeps modules alive +#@skipIfWindows +#@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) +def test_TwoTargetsTwoDebuggersWithPin(self): +self.do_test(False, False, True) + +def do_test(self, one_target, one_debugger, use_pinning_module=False): # Make sure that if we have one target, and we run, then # change the binary and rerun, the binary (and any .o files # if using dwarf in .o file debugging) get removed from the # shared module cache. They are no longer reachable. +# If use_pinning_module is true, we make another SBModule that holds +# a reference to the a.out, and will keep it alive. +# At present, those tests fai
[Lldb-commits] [lldb] Fix up the TestGlobalModuleCache showing we succeed mostly. (PR #84099)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 489eadd142e858dc28e375320da774eba53d21bb...29866d5a183097348cb4d5b2bf3ec66f2fc0ccc4 lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py `` View the diff from darker here. ``diff --- TestGlobalModuleCache.py2024-03-06 00:32:40.00 + +++ TestGlobalModuleCache.py2024-03-06 00:51:57.488092 + @@ -48,33 +48,32 @@ # the bug this is exposing (https://github.com/llvm/llvm-project/issues/76057). @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_OneTargetOneDebugger(self): self.do_test(True, True) - @skipIfWindows @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_TwoTargetsOneDebugger(self): self.do_test(False, True) -@expectedFailureAll() # An external reference keeps modules alive +@expectedFailureAll() # An external reference keeps modules alive @skipIfWindows @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_TwoTargetsOneDebuggerWithPin(self): self.do_test(False, True, True) @skipIfWindows @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_TwoTargetsTwoDebuggers(self): self.do_test(False, False) -@expectedFailureAll() # An external reference keeps modules alive -#@skipIfWindows -#@skipIf(oslist=["linux"], archs=["arm", "aarch64"]) +@expectedFailureAll() # An external reference keeps modules alive +# @skipIfWindows +# @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_TwoTargetsTwoDebuggersWithPin(self): self.do_test(False, False, True) - + def do_test(self, one_target, one_debugger, use_pinning_module=False): # Make sure that if we have one target, and we run, then # change the binary and rerun, the binary (and any .o files # if using dwarf in .o file debugging) get removed from the # shared module cache. They are no longer reachable. @@ -109,16 +108,18 @@ self.pinning_module = None if use_pinning_module: self.pinning_module = target.FindModule(target.executable) self.assertTrue(self.pinning_module.IsValid(), "Valid pinning module") + def cleanupPinningModule(self): if self.pinning_module: self.pinning_module.Clear() self.pinning_module = None + self.addTearDownHook(cleanupPinningModule) - + # Make sure we ran the version we intended here: self.check_counter_var(thread, 1) process.Kill() # Now copy two-print.c over main.c, rebuild, and rerun: @@ -188,12 +189,13 @@ error = self.check_image_list_result(num_a_dot_out_entries, 1) # Even if this fails, MemoryPressureDetected should fix this. if self.TraceOn(): print("*** Calling MemoryPressureDetected") lldb.SBDebugger.MemoryPressureDetected() -error_after_mpd = self.check_image_list_result(num_a_dot_out_entries, - num_main_dot_o_entries) +error_after_mpd = self.check_image_list_result( +num_a_dot_out_entries, num_main_dot_o_entries +) fail_msg = "" if error != "": fail_msg = "Error before MPD: " + error if error_after_mpd != "": `` https://github.com/llvm/llvm-project/pull/84099 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/83702 >From d1dc1dfb1bb601fe90289bf29176c74a38ac5697 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Tue, 5 Mar 2024 10:38:41 -0800 Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. --- bolt/lib/Core/ParallelUtilities.cpp | 4 ++-- bolt/tools/merge-fdata/merge-fdata.cpp| 2 +- .../clang-doc/tool/ClangDocMain.cpp | 2 +- .../tool/FindAllSymbolsMain.cpp | 2 +- clang/lib/Tooling/AllTUsExecution.cpp | 2 +- clang/tools/clang-scan-deps/ClangScanDeps.cpp | 2 +- lld/MachO/Writer.cpp | 2 +- lldb/source/Core/Debugger.cpp | 4 ++-- llvm/docs/ORCv2.rst | 2 +- .../SpeculativeJIT/SpeculativeJIT.cpp | 2 +- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 2 +- llvm/include/llvm/Support/ThreadPool.h| 7 +++--- llvm/lib/CodeGen/ParallelCG.cpp | 2 +- llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +- .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 2 +- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp | 2 +- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 4 ++-- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 ++-- llvm/lib/Support/BalancedPartitioning.cpp | 2 +- llvm/tools/dsymutil/dsymutil.cpp | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-cov/CoverageExporterJson.cpp | 2 +- llvm/tools/llvm-cov/CoverageReport.cpp| 4 ++-- .../tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 +- llvm/tools/llvm-profdata/llvm-profdata.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Delta.cpp | 2 +- llvm/unittests/ADT/LazyAtomicPointerTest.cpp | 4 ++-- llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++--- llvm/unittests/Support/ParallelTest.cpp | 2 +- llvm/unittests/Support/ThreadPool.cpp | 22 +-- .../Support/ThreadSafeAllocatorTest.cpp | 6 ++--- mlir/include/mlir/IR/MLIRContext.h| 2 +- mlir/lib/CAPI/IR/Support.cpp | 2 +- mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 2 +- mlir/lib/IR/MLIRContext.cpp | 4 ++-- 37 files changed, 65 insertions(+), 66 deletions(-) diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp index 88d9444a6a2ba7..5f5e96e0e7881c 100644 --- a/bolt/lib/Core/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -49,7 +49,7 @@ namespace ParallelUtilities { namespace { /// A single thread pool that is used to run parallel tasks -std::unique_ptr ThreadPoolPtr; +std::unique_ptr ThreadPoolPtr; unsigned computeCostFor(const BinaryFunction &BF, const PredicateTy &SkipPredicate, @@ -106,7 +106,7 @@ ThreadPoolInterface &getThreadPool() { if (ThreadPoolPtr.get()) return *ThreadPoolPtr; - ThreadPoolPtr = std::make_unique( + ThreadPoolPtr = std::make_unique( llvm::hardware_concurrency(opts::ThreadCount)); return *ThreadPoolPtr; } diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp index c6dfd3cfdc56de..f2ac5ad4492ee5 100644 --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl &Filenames) { // least 4 tasks. ThreadPoolStrategy S = optimal_concurrency( std::max(Filenames.size() / 4, static_cast(1))); - ThreadPool Pool(S); + DefaultThreadPool Pool(S); DenseMap ParsedProfiles( Pool.getMaxConcurrency()); for (const auto &Filename : Filenames) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 22bdb5de22d871..21b581fa6df2e1 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -238,7 +238,7 @@ Example usage for a project using a compile commands database: Error = false; llvm::sys::Mutex IndexMutex; // ExecutorConcurrency is a flag exposed by AllTUsExecution.h - llvm::ThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency)); + llvm::DefaultThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency)); for (auto &Group : USRToBitcode) { Pool.async([&]() { std::vector> Infos; diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp index b2d0efecc20692..298b02e77cb0aa 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp +++ b/clang-tools-extra/clang-include-fixer/find
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
https://github.com/joker-eph closed https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d32bcbf - [lldb] Fix build failure in Debugger.cpp (NFC)
Author: Jie Fu Date: 2024-03-06T10:17:58+08:00 New Revision: d32bcbf6a7f5beb63ce435c2bea737d33d5b7468 URL: https://github.com/llvm/llvm-project/commit/d32bcbf6a7f5beb63ce435c2bea737d33d5b7468 DIFF: https://github.com/llvm/llvm-project/commit/d32bcbf6a7f5beb63ce435c2bea737d33d5b7468.diff LOG: [lldb] Fix build failure in Debugger.cpp (NFC) llvm-project/lldb/source/Core/Debugger.cpp:107:14: error: no type named 'DefaultThreadPoolThreadPool' in namespace 'llvm' static llvm::DefaultThreadPoolThreadPool *g_thread_pool = nullptr; ~~^ 1 error generated. Added: Modified: lldb/source/Core/Debugger.cpp Removed: diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 9d62b2a908f770..90aabde2b764f1 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -104,7 +104,7 @@ static std::recursive_mutex *g_debugger_list_mutex_ptr = nullptr; // NOTE: intentional leak to avoid issues with C++ destructor chain static Debugger::DebuggerList *g_debugger_list_ptr = nullptr; // NOTE: intentional leak to avoid issues with C++ destructor chain -static llvm::DefaultThreadPoolThreadPool *g_thread_pool = nullptr; +static llvm::DefaultThreadPool *g_thread_pool = nullptr; static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = { { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)
@@ -104,7 +104,7 @@ static std::recursive_mutex *g_debugger_list_mutex_ptr = nullptr; // NOTE: intentional leak to avoid issues with C++ destructor chain static Debugger::DebuggerList *g_debugger_list_ptr = nullptr; // NOTE: intentional leak to avoid issues with C++ destructor chain -static llvm::ThreadPool *g_thread_pool = nullptr; +static llvm::DefaultThreadPoolThreadPool *g_thread_pool = nullptr; joker-eph wrote: Weirdly this issue wasn't caught in CI! https://github.com/llvm/llvm-project/pull/83702 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Allow languages to filter breakpoints set by line (PR #83908)
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/83908 >From 51307b548d09c34ee06037ccf459110e451970a9 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Mon, 4 Mar 2024 09:56:18 -0800 Subject: [PATCH 1/2] [lldb] Allow languages to filter breakpoints set by line Some languages may create artificial functions that have no real user code, even though there is line table information for them. One such case is with coroutine code that receives the CoroSplitter transformation in LLVM IR. That code transformation creates many different Functions, cloning one Instruction into many Instructions in many different Functions and copying the associated debug locations. It would be difficult to make that pass delete debug locations of cloned instructions in a language agnostic way (is it even possible?), but LLDB can ignore certain locations by querying its Language APIs and having it decide based on, for example, mangling information. --- lldb/include/lldb/Target/Language.h | 4 lldb/source/Breakpoint/BreakpointResolver.cpp | 12 2 files changed, 16 insertions(+) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 0cbd8a32dccd54..957c40eb7c0772 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,6 +339,10 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } + virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { +return true; + } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp index bc6348716ef418..876b30c6d76d55 100644 --- a/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -23,6 +23,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Target/Language.h" #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -199,6 +200,15 @@ bool operator<(const SourceLoc lhs, const SourceLoc rhs) { } } // namespace +static void +ApplyLanguageFilters(llvm::SmallVectorImpl &sc_list) { + llvm::erase_if(sc_list, [](SymbolContext &sc) { +if (Language *lang = Language::FindPlugin(sc.GetLanguage())) + return !lang->IsInterestingCtxForLineBreakpoint(sc); +return false; + }); +} + void BreakpointResolver::SetSCMatchesByLine( SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, uint32_t line, std::optional column) { @@ -206,6 +216,8 @@ void BreakpointResolver::SetSCMatchesByLine( for (uint32_t i = 0; i < sc_list.GetSize(); ++i) all_scs.push_back(sc_list[i]); + ApplyLanguageFilters(all_scs); + while (all_scs.size()) { uint32_t closest_line = UINT32_MAX; >From 7ea76d6c04d063d50da52756179639f2037aa793 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Tue, 5 Mar 2024 18:47:51 -0800 Subject: [PATCH 2/2] fixup! add target option --- lldb/include/lldb/Target/Language.h | 9 ++-- lldb/include/lldb/Target/Target.h | 2 ++ lldb/source/Breakpoint/BreakpointResolver.cpp | 23 +-- lldb/source/Target/Target.cpp | 8 +++ lldb/source/Target/TargetProperties.td| 3 +++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 957c40eb7c0772..9db9f4e297e114 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -339,8 +339,13 @@ class Language : public PluginInterface { virtual llvm::StringRef GetInstanceVariableName() { return {}; } - virtual bool IsInterestingCtxForLineBreakpoint(const SymbolContext &) const { -return true; + // Returns true if this SymbolContext should be used when setting breakpoints + // by line (number or regex). This is useful for languages that create + // artificial functions without any meaningful user code associated with them + // (e.g. code that gets expanded in late compilation stages, like by + // CoroSplitter). + virtual bool IsArtificialCtxForLineBreakpoint(const SymbolContext &) const { +return false; } protected: diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8f57358981d4d2..ab04aa57f17300 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + bool GetIgnoreBreakpointsFromLanguageArtificialLocations() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); diff --git a/lldb/source/Breakpoint/
[Lldb-commits] [lldb] [lldb] Allow languages to filter breakpoints set by line (PR #83908)
felipepiovezan wrote: I believe I've addressed all the feedback here. Tried really hard to come up with a shorter name for that target option, but could not find something both short and descriptive. If you can think of anything better, please let me know https://github.com/llvm/llvm-project/pull/83908 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Print mangled names with verbose break list (PR #84071)
@@ -90,6 +90,15 @@ def breakpoint_options_language_test(self): num_expected_locations=1, ) felipepiovezan wrote: Nice! this works really well https://github.com/llvm/llvm-project/pull/84071 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits