[Lldb-commits] [flang] [lldb] [libcxxabi] [lld] [llvm] [libcxx] [clang] [polly] [clang-tools-extra] [libc] [mlir] [openmp] [compiler-rt] [libunwind] [libc++][numeric] P0543R3: Saturation arithmetic (P

2024-01-18 Thread Hristo Hristov via lldb-commits

https://github.com/H-G-Hristov converted_to_draft 
https://github.com/llvm/llvm-project/pull/77967
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)

2024-01-18 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] 430e145 - Clean up PlatformDarwinKernel::GetSharedModule, document (#78652)

2024-01-18 Thread via lldb-commits

Author: Jason Molenda
Date: 2024-01-18T23:26:15-08:00
New Revision: 430e145fc3964dac0bbf355f27616190d403dd83

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

LOG: Clean up PlatformDarwinKernel::GetSharedModule, document (#78652)

PlatformDarwinKernel::GetSharedModule, which can find a kernel or kext
from a local filesystem scan, needed a little cleanup. The method which
finds kernels was (1) not looking for the SymbolFileSpec when creating a
Module, and (2) adding that newly created Module to a Target, which
GetSharedModule should not be doing - after auditing many other subclass
implementations of this method, I haven't found any others doing it.
Platform::GetSharedModule didn't have a headerdoc so it took a little
work to piece together the intended behaviors.

This is addressing a bug where
PlatformDarwinKernel::GetSharedModuleKernel would find the ObjectFile
for a kernel, create a Module, and add it to the Target. Then up in
DynamicLoaderDarwinKernel, it would check if the Module had a SymbolFile
FileSpec, and because it did not, it would do its own search for a
binary & dSYM, find them, and then add that to the Target. Now we have
two copies of the Module in the Target, one with a dSYM and the other
without, and only one of them has its load addresses set.

GetSharedModule should not be adding binaries to the Target, and it
should set the SymbolFile FileSpec when it is creating the Module.

rdar://120895951

Added: 


Modified: 
lldb/include/lldb/Target/Platform.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 129e4565d9ff99..13196ff74d663f 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -288,6 +288,32 @@ class Platform : public PluginInterface {
   LocateExecutableScriptingResources(Target *target, Module ,
  Stream _stream);
 
+  /// \param[in] module_spec
+  /// The ModuleSpec of a binary to find.
+  ///
+  /// \param[in] process
+  /// A Process.
+  ///
+  /// \param[out] module_sp
+  /// A Module that matches the ModuleSpec, if one is found.
+  ///
+  /// \param[in] module_search_paths_ptr
+  /// Locations to possibly look for a binary that matches the ModuleSpec.
+  ///
+  /// \param[out] old_modules
+  /// Existing Modules in the Process' Target image list which match
+  /// the FileSpec.
+  ///
+  /// \param[out] did_create_ptr
+  /// Optional boolean, nullptr may be passed for this argument.
+  /// If this method is returning a *new* ModuleSP, this
+  /// will be set to true.
+  /// If this method is returning a ModuleSP that is already in the
+  /// Target's image list, it will be false.
+  ///
+  /// \return
+  /// The Status object for any errors found while searching for
+  /// the binary.
   virtual Status GetSharedModule(
   const ModuleSpec _spec, Process *process,
   lldb::ModuleSP _sp, const FileSpecList *module_search_paths_ptr,

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index e2839f3285cce4..1f121f5c4e5d0a 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -791,9 +791,10 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
 const ModuleSpec _spec, Process *process, ModuleSP _sp,
 const FileSpecList *module_search_paths_ptr,
 llvm::SmallVectorImpl *old_modules, bool *did_create_ptr) {
-  Status error;
-  module_sp.reset();
+  assert(module_sp.get() == nullptr);
   UpdateKextandKernelsLocalScan();
+  if (did_create_ptr)
+*did_create_ptr = false;
 
   // First try all kernel binaries that have a dSYM next to them
   for (auto possible_kernel : m_kernel_binaries_with_dsyms) {
@@ -803,22 +804,19 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
   module_sp.reset(new Module(kern_spec));
   if (module_sp && module_sp->GetObjectFile() &&
   module_sp->MatchesModuleSpec(kern_spec)) {
-// module_sp is an actual kernel binary we want to add.
-if (process) {
-  const bool notify = false;
-  process->GetTarget().GetImages().AppendIfNeeded(module_sp, notify);
-  error.Clear();
-  return error;
-} else {
-  error = ModuleList::GetSharedModule(kern_spec, module_sp, nullptr,
-  nullptr, nullptr);
-  if (module_sp && module_sp->GetObjectFile() &&
-  module_sp->GetObjectFile()->GetType() !=
-  ObjectFile::Type::eTypeCoreFile) {
-  

[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)

2024-01-18 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/78652

>From 0936638373f9ae720de0ca9f50d3e5436897254b Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 18 Jan 2024 16:25:01 -0800
Subject: [PATCH 1/2] Clean up PlatformDarwinKernel::GetSharedModule, docuemnt

PlatformDarwinKernel::GetSharedModule, which can find a kernel or
kext from a local filesystem scan, needed a little cleanup.  The
method which finds kernels was (1) not looking for the SymbolFileSpec
when creating a Module, and (2) adding that newly created Module
to a Target, which GetSharedModule should not be doing - after
auditing many other subclass implementations of this method, I
haven't found any others doing it.  Platform::GetSharedModule didn't
have a headerdoc so it took a little work to piece together the
intended behaviors.

This is addressing a bug where PlatformDarwinKernel::GetSharedModuleKernel
would find the ObjectFile for a kernel, create a Module, and add it
to the Target.  Then up in DynamicLoaderDarwinKernel, it would check if
the Module had a SymbolFile FileSpec, and because it did not, it would
do its own search for a binary & dSYM, find them, and then add that to
the Target.  Now we have two copies of the Module in the Target, one
with a dSYM and the other without, and only one of them has its load
addresses set.

GetSharedModule should not be adding binaries to the Target, and it
should set the SymbolFile FileSpec when it is creating the Module.

rdar://120895951
---
 lldb/include/lldb/Target/Platform.h   | 26 
 .../Platform/MacOSX/PlatformDarwinKernel.cpp  | 62 +++
 2 files changed, 47 insertions(+), 41 deletions(-)

diff --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 129e4565d9ff993..13196ff74d663f8 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -288,6 +288,32 @@ class Platform : public PluginInterface {
   LocateExecutableScriptingResources(Target *target, Module ,
  Stream _stream);
 
+  /// \param[in] module_spec
+  /// The ModuleSpec of a binary to find.
+  ///
+  /// \param[in] process
+  /// A Process.
+  ///
+  /// \param[out] module_sp
+  /// A Module that matches the ModuleSpec, if one is found.
+  ///
+  /// \param[in] module_search_paths_ptr
+  /// Locations to possibly look for a binary that matches the ModuleSpec.
+  ///
+  /// \param[out] old_modules
+  /// Existing Modules in the Process' Target image list which match
+  /// the FileSpec.
+  ///
+  /// \param[out] did_create_ptr
+  /// Optional boolean, nullptr may be passed for this argument.
+  /// If this method is returning a *new* ModuleSP, this
+  /// will be set to true.
+  /// If this method is returning a ModuleSP that is already in the
+  /// Target's image list, it will be false.
+  ///
+  /// \return
+  /// The Status object for any errors found while searching for
+  /// the binary.
   virtual Status GetSharedModule(
   const ModuleSpec _spec, Process *process,
   lldb::ModuleSP _sp, const FileSpecList *module_search_paths_ptr,
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index e2839f3285cce45..6490432c72e18d3 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -791,9 +791,10 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
 const ModuleSpec _spec, Process *process, ModuleSP _sp,
 const FileSpecList *module_search_paths_ptr,
 llvm::SmallVectorImpl *old_modules, bool *did_create_ptr) {
-  Status error;
   module_sp.reset();
   UpdateKextandKernelsLocalScan();
+  if (did_create_ptr)
+*did_create_ptr = false;
 
   // First try all kernel binaries that have a dSYM next to them
   for (auto possible_kernel : m_kernel_binaries_with_dsyms) {
@@ -803,22 +804,19 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
   module_sp.reset(new Module(kern_spec));
   if (module_sp && module_sp->GetObjectFile() &&
   module_sp->MatchesModuleSpec(kern_spec)) {
-// module_sp is an actual kernel binary we want to add.
-if (process) {
-  const bool notify = false;
-  process->GetTarget().GetImages().AppendIfNeeded(module_sp, notify);
-  error.Clear();
-  return error;
-} else {
-  error = ModuleList::GetSharedModule(kern_spec, module_sp, nullptr,
-  nullptr, nullptr);
-  if (module_sp && module_sp->GetObjectFile() &&
-  module_sp->GetObjectFile()->GetType() !=
-  ObjectFile::Type::eTypeCoreFile) {
-return error;
-  }
-  module_sp.reset();
-}
+// The dSYM is next to the binary (that's the only
+// 

[Lldb-commits] [libcxx] [openmp] [clang] [mlir] [lldb] [compiler-rt] [clang-tools-extra] [lld] [llvm] [libc] [flang] [libc++][memory] P2868R1: Removing deprecated typedef `std::allocator::is_always_eq

2024-01-18 Thread Hristo Hristov via lldb-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/78562

>From fadaafbf791d5fe78f6ac9ee3494b128339781ba Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Thu, 18 Jan 2024 09:47:40 +0200
Subject: [PATCH 1/6] [libc++][memory] P2868R1 - Removing deprecated typedef
 `std::allocator::is_always_equal`

Implements:
- https://wg21.link/P2868R1
- https://wg21.link/LWG3170
---
 libcxx/.clang-format  |  1 +
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx23Issues.csv|  2 +-
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/docs/UsingLibcxx.rst   |  4 ++
 libcxx/include/__memory/allocator.h   |  8 +++-
 libcxx/include/memory |  2 +-
 ...cator_types.deprecated_in_cxx23.verify.cpp | 44 +++
 .../allocator_types.pass.cpp  |  2 +
 ...llocator_types.removed_in_cxx26.verify.cpp | 34 ++
 10 files changed, 95 insertions(+), 5 deletions(-)
 create mode 100644 
libcxx/test/std/utilities/memory/default.allocator/allocator_types.deprecated_in_cxx23.verify.cpp
 create mode 100644 
libcxx/test/std/utilities/memory/default.allocator/allocator_types.removed_in_cxx26.verify.cpp

diff --git a/libcxx/.clang-format b/libcxx/.clang-format
index 56bdf2b5f911659..39ae1322ffa8a63 100644
--- a/libcxx/.clang-format
+++ b/libcxx/.clang-format
@@ -28,6 +28,7 @@ AttributeMacros: [
   '_LIBCPP_DEPRECATED_IN_CXX14',
   '_LIBCPP_DEPRECATED_IN_CXX17',
   '_LIBCPP_DEPRECATED_IN_CXX20',
+  '_LIBCPP_DEPRECATED_IN_CXX23',
   '_LIBCPP_DEPRECATED',
   '_LIBCPP_DISABLE_EXTENTSION_WARNING',
   '_LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION',
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 77b7939a0c0ac96..3e2fb8727941d6b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -60,6 +60,7 @@ Implemented Papers
 - P0521R0 - Proposed Resolution for CA 14 (``shared_ptr`` ``use_count/unique``)
 - P1759R6 - Native handles and file streams
 - P2517R1 - Add a conditional ``noexcept`` specification to ``std::apply``
+- P2868R3 - Remove Deprecated ``std::allocator`` Typedef From C++26
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx23Issues.csv 
b/libcxx/docs/Status/Cxx23Issues.csv
index b24ecc5525a1497..70480b338205804 100644
--- a/libcxx/docs/Status/Cxx23Issues.csv
+++ b/libcxx/docs/Status/Cxx23Issues.csv
@@ -15,7 +15,7 @@
 "`2743 `__","P0083R3 ``node_handle`` private 
members missing ""exposition only"" comment","November 2020","|Nothing To 
Do|",""
 "`2820 `__","Clarify  
macros","November 2020","|Nothing To Do|",""
 "`3120 `__","Unclear behavior of 
``monotonic_buffer_resource::release()``","November 2020","",""
-"`3170 `__","``is_always_equal`` added to 
``std::allocator`` makes the standard library treat derived types as always 
equal","November 2020","",""
+"`3170 `__","``is_always_equal`` added to 
``std::allocator`` makes the standard library treat derived types as always 
equal","November 2020","|Complete|","18.0"
 "`3036 `__","``polymorphic_allocator::destroy`` is 
extraneous","November 2020","",""
 "`3171 `__","LWG2989 breaks ``directory_entry`` 
stream insertion","November 2020","|Complete|","14.0"
 "`3306 `__","``ranges::advance`` violates its 
preconditions","November 2020","|Complete|","14.0","|ranges|"
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index 5701717f39766c6..762cbc6d487c69d 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -36,7 +36,7 @@
 "`P0952R2 `__","LWG","A new specification for 
``std::generate_canonical``","Kona November 2023","","",""
 "`P2447R6 `__","LWG","``std::span`` over an 
initializer list","Kona November 2023","","",""
 "`P2821R5 `__","LWG","``span.at()``","Kona November 
2023","|Complete|","18.0",""
-"`P2868R3 `__","LWG","Remove Deprecated 
``std::allocator`` Typedef From C++26","Kona November 2023","","",""
+"`P2868R3 `__","LWG","Remove Deprecated 
``std::allocator`` Typedef From C++26","Kona November 
2023","|Complete|","18.0",""
 "`P2870R3 `__","LWG","Remove 
``basic_string::reserve()`` From C++26","Kona November 
2023","|Complete|","18.0",""
 "`P2871R3 `__","LWG","Remove Deprecated Unicode 
Conversion Facets from C++26","Kona November 2023","|Complete|","18.0",""
 "`P2819R2 `__","LWG","Add tuple protocol to 

[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)

2024-01-18 Thread Jason Molenda via lldb-commits


@@ -836,36 +834,18 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
   module_sp.reset(new Module(kern_spec));
   if (module_sp && module_sp->GetObjectFile() &&
   module_sp->MatchesModuleSpec(kern_spec)) {
-// module_sp is an actual kernel binary we want to add.
-if (process) {
-  const bool notify = false;
-  process->GetTarget().GetImages().AppendIfNeeded(module_sp, notify);
-  error.Clear();
-  return error;
-} else {
-  error = ModuleList::GetSharedModule(kern_spec, module_sp, nullptr,
-  nullptr, nullptr);
-  if (module_sp && module_sp->GetObjectFile() &&
-  module_sp->GetObjectFile()->GetType() !=
-  ObjectFile::Type::eTypeCoreFile) {
-return error;
-  }
-  module_sp.reset();
-}
+if (did_create_ptr)
+  *did_create_ptr = true;
+return {};
   }
 }
   }
 
   // Give the generic methods, including possibly calling into  DebugSymbols
   // framework on macOS systems, a chance.
-  error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
-  module_search_paths_ptr, old_modules,
-  did_create_ptr);
-  if (error.Success() && module_sp.get()) {
-return error;
-  }
-
-  return error;
+  return PlatformDarwin::GetSharedModule(module_spec, process, module_sp,

jasonmolenda wrote:

Thanks for the question, yeah Jonas is right I shouldn't have bothered reseting 
the shared pointer at the beginning, I did that more to demonstrate in the code 
that it does not have a value on entry to the method, to make it clearer for 
the reader.  An assert would work just as well.

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


[Lldb-commits] [lld] [lldb] [libcxx] [llvm] [compiler-rt] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits

OldWorldOrdr wrote:

I've added a basic comment and a test case, I've never written a test with lit 
before so sorry if its terrible and broken

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


[Lldb-commits] [lld] [lldb] [libcxx] [llvm] [compiler-rt] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits

https://github.com/OldWorldOrdr updated 
https://github.com/llvm/llvm-project/pull/78628

>From e73fc2d0263e9e601f2964a90cfe347e8d2bb87c Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Thu, 18 Jan 2024 16:20:52 -0500
Subject: [PATCH 1/3] [lld-macho] Find objects in library search path

---
 lld/MachO/Driver.cpp | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 401459a054394ec..f04165f5c026153 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});
 }
-return findPathCombination("lib" + name, config->librarySearchPaths,
-   {".tbd", ".dylib", ".so", ".a"});
+if (std::optional path =
+findPathCombination("lib" + name, config->librarySearchPaths,
+{".tbd", ".dylib", ".so", ".a"}))
+  return path;
+return findPathCombination(name, config->librarySearchPaths, {""});
   };
 
   std::optional path = doFind();

>From 5b29c5da6770982fb2f36edcd3a367893b18a19d Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Thu, 18 Jan 2024 21:16:57 -0500
Subject: [PATCH 2/3] [lld-macho] find objects in library search path version 2

---
 lld/MachO/Driver.cpp | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index f04165f5c026153..f8b01da5255c6d4 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -90,21 +90,19 @@ static std::optional findLibrary(StringRef name) 
{
 return entry->second;
 
   auto doFind = [&] {
+// Special case for Csu support files.
+if (name.ends_with(".o"))
+  return findPathCombination(name, config->librarySearchPaths, {""});
 if (config->searchDylibsFirst) {
   if (std::optional path =
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  else if (std::optional path = findPathCombination(
-   "lib" + name, config->librarySearchPaths, {".a"}))
-return path;
-  return findPathCombination(name, config->librarySearchPaths, {""});
+  return findPathCombination("lib" + name, config->librarySearchPaths,
+ {".a"});
 }
-if (std::optional path =
-findPathCombination("lib" + name, config->librarySearchPaths,
-{".tbd", ".dylib", ".so", ".a"}))
-  return path;
-return findPathCombination(name, config->librarySearchPaths, {""});
+return findPathCombination("lib" + name, config->librarySearchPaths,
+   {".tbd", ".dylib", ".so", ".a"});
   };
 
   std::optional path = doFind();

>From 5aab87e5c580ca1dba654fb00cf9571c7e3c7999 Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Fri, 19 Jan 2024 01:32:20 -0500
Subject: [PATCH 3/3] add test case

---
 lld/test/MachO/link-csu-obj.s | 10 ++
 1 file changed, 10 insertions(+)
 create mode 100644 lld/test/MachO/link-csu-obj.s

diff --git a/lld/test/MachO/link-csu-obj.s b/lld/test/MachO/link-csu-obj.s
new file mode 100644
index 000..00cb26bb260743f
--- /dev/null
+++ b/lld/test/MachO/link-csu-obj.s
@@ -0,0 +1,10 @@
+# REQUIRES: x86
+# RUN: mkdir -p %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s 
-o %t/hello.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
+# RUN: %lld -L %t %t/main.o %t/hello.o -o %t/a.out
+
+.globl _main
+_main:
+call _print_hello
+ret

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


[Lldb-commits] [lld] [compiler-rt] [llvm] [libcxx] [lldb] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits

https://github.com/OldWorldOrdr updated 
https://github.com/llvm/llvm-project/pull/78628

>From e73fc2d0263e9e601f2964a90cfe347e8d2bb87c Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Thu, 18 Jan 2024 16:20:52 -0500
Subject: [PATCH 1/2] [lld-macho] Find objects in library search path

---
 lld/MachO/Driver.cpp | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 401459a054394e..f04165f5c02615 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});
 }
-return findPathCombination("lib" + name, config->librarySearchPaths,
-   {".tbd", ".dylib", ".so", ".a"});
+if (std::optional path =
+findPathCombination("lib" + name, config->librarySearchPaths,
+{".tbd", ".dylib", ".so", ".a"}))
+  return path;
+return findPathCombination(name, config->librarySearchPaths, {""});
   };
 
   std::optional path = doFind();

>From 5b29c5da6770982fb2f36edcd3a367893b18a19d Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Thu, 18 Jan 2024 21:16:57 -0500
Subject: [PATCH 2/2] [lld-macho] find objects in library search path version 2

---
 lld/MachO/Driver.cpp | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index f04165f5c02615..f8b01da5255c6d 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -90,21 +90,19 @@ static std::optional findLibrary(StringRef name) 
{
 return entry->second;
 
   auto doFind = [&] {
+// Special case for Csu support files.
+if (name.ends_with(".o"))
+  return findPathCombination(name, config->librarySearchPaths, {""});
 if (config->searchDylibsFirst) {
   if (std::optional path =
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  else if (std::optional path = findPathCombination(
-   "lib" + name, config->librarySearchPaths, {".a"}))
-return path;
-  return findPathCombination(name, config->librarySearchPaths, {""});
+  return findPathCombination("lib" + name, config->librarySearchPaths,
+ {".a"});
 }
-if (std::optional path =
-findPathCombination("lib" + name, config->librarySearchPaths,
-{".tbd", ".dylib", ".so", ".a"}))
-  return path;
-return findPathCombination(name, config->librarySearchPaths, {""});
+return findPathCombination("lib" + name, config->librarySearchPaths,
+   {".tbd", ".dylib", ".so", ".a"});
   };
 
   std::optional path = doFind();

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


[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)

2024-01-18 Thread Will Hawkins via lldb-commits


@@ -836,36 +834,18 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
   module_sp.reset(new Module(kern_spec));
   if (module_sp && module_sp->GetObjectFile() &&
   module_sp->MatchesModuleSpec(kern_spec)) {
-// module_sp is an actual kernel binary we want to add.
-if (process) {
-  const bool notify = false;
-  process->GetTarget().GetImages().AppendIfNeeded(module_sp, notify);
-  error.Clear();
-  return error;
-} else {
-  error = ModuleList::GetSharedModule(kern_spec, module_sp, nullptr,
-  nullptr, nullptr);
-  if (module_sp && module_sp->GetObjectFile() &&
-  module_sp->GetObjectFile()->GetType() !=
-  ObjectFile::Type::eTypeCoreFile) {
-return error;
-  }
-  module_sp.reset();
-}
+if (did_create_ptr)
+  *did_create_ptr = true;
+return {};
   }
 }
   }
 
   // Give the generic methods, including possibly calling into  DebugSymbols
   // framework on macOS systems, a chance.
-  error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
-  module_search_paths_ptr, old_modules,
-  did_create_ptr);
-  if (error.Success() && module_sp.get()) {
-return error;
-  }
-
-  return error;
+  return PlatformDarwin::GetSharedModule(module_spec, process, module_sp,

hawkinsw wrote:

Of course! Now that I looked at the signature and saw that `module_sp` is 
passed by reference, we assume that it will go out of the caller's scope (or 
the caller's, caller's scope ...) at some point and the "leaked" instance of 
`Module` would be cleaned up then! 

Thank you for the explanation.

It just seemed odd to have that contain a pointer at all at that point in the 
code because the point of calling `PlatformDarwin::GetSharedModule` is that a 
valid one was not found. I.e., if the condition on lines 805/806 was false, it 
seemed to me that "A Module that matches the ModuleSpec" was *not* actually 
found and so `module_sp` should have been reset before either falling out of 
the loop or going to the next iteration.

Thank you again for the explanation!

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


[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)

2024-01-18 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)

2024-01-18 Thread Jonas Devlieghere via lldb-commits


@@ -836,36 +834,18 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
   module_sp.reset(new Module(kern_spec));
   if (module_sp && module_sp->GetObjectFile() &&
   module_sp->MatchesModuleSpec(kern_spec)) {
-// module_sp is an actual kernel binary we want to add.
-if (process) {
-  const bool notify = false;
-  process->GetTarget().GetImages().AppendIfNeeded(module_sp, notify);
-  error.Clear();
-  return error;
-} else {
-  error = ModuleList::GetSharedModule(kern_spec, module_sp, nullptr,
-  nullptr, nullptr);
-  if (module_sp && module_sp->GetObjectFile() &&
-  module_sp->GetObjectFile()->GetType() !=
-  ObjectFile::Type::eTypeCoreFile) {
-return error;
-  }
-  module_sp.reset();
-}
+if (did_create_ptr)
+  *did_create_ptr = true;
+return {};
   }
 }
   }
 
   // Give the generic methods, including possibly calling into  DebugSymbols
   // framework on macOS systems, a chance.
-  error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
-  module_search_paths_ptr, old_modules,
-  did_create_ptr);
-  if (error.Success() && module_sp.get()) {
-return error;
-  }
-
-  return error;
+  return PlatformDarwin::GetSharedModule(module_spec, process, module_sp,

JDevlieghere wrote:

Not a dumb question at all! `module_sp` is an "out parameter" and not clearing 
an out parameter is a common opportunity for bugs. Whether it's a "bug" depends 
on the contract of course. Per the documentation that Jason added here ("A 
Module that matches the ModuleSpec, if one is found.") it should only be set 
when a module is found (and assuming it applies to all the overloads) the same 
expectation could be had about `PlatformDarwin::GetSharedModule`. 

The obvious way to sidestep this issue is to not use out parameters at all. If 
the shared pointer was the only out parameter we could've potentially 
refactored this to return an `Expected` or something, but we have a 
handful of other out parameters that suffer from the same problem. 

Regardless, as we're using smart pointers, there's no risk of a leak. Therefore 
I don't think the extra reset is warranted. If we really wanted to be 
defensive, I'd prefer to use `asserts` to catch cases where we're not holding 
ourselves to these kind of contracts. 

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


[Lldb-commits] [clang] [flang] [libc] [openmp] [lldb] [llvm] [lld] [libcxx] [clang-tools-extra] [compiler-rt] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)

2024-01-18 Thread Ethan Luis McDonough via lldb-commits

https://github.com/EthanLuisMcDonough updated 
https://github.com/llvm/llvm-project/pull/76587

>From 530eb982b9770190377bb0bd09c5cb715f34d484 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough 
Date: Fri, 15 Dec 2023 20:38:38 -0600
Subject: [PATCH 01/12] Add profiling functions to libomptarget

---
 .../include/llvm/Frontend/OpenMP/OMPKinds.def |  3 +++
 openmp/libomptarget/DeviceRTL/CMakeLists.txt  |  2 ++
 .../DeviceRTL/include/Profiling.h | 21 +++
 .../libomptarget/DeviceRTL/src/Profiling.cpp  | 19 +
 4 files changed, 45 insertions(+)
 create mode 100644 openmp/libomptarget/DeviceRTL/include/Profiling.h
 create mode 100644 openmp/libomptarget/DeviceRTL/src/Profiling.cpp

diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def 
b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index d22d2a8e948b00..1d887d5cb58127 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -503,6 +503,9 @@ __OMP_RTL(__kmpc_barrier_simple_generic, false, Void, 
IdentPtr, Int32)
 __OMP_RTL(__kmpc_warp_active_thread_mask, false, Int64,)
 __OMP_RTL(__kmpc_syncwarp, false, Void, Int64)
 
+__OMP_RTL(__llvm_profile_register_function, false, Void, VoidPtr)
+__OMP_RTL(__llvm_profile_register_names_function, false, Void, VoidPtr, Int64)
+
 __OMP_RTL(__last, false, Void, )
 
 #undef __OMP_RTL
diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt 
b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 1ce3e1e40a80ab..55ee15d068c67b 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -89,6 +89,7 @@ set(include_files
   ${include_directory}/Interface.h
   ${include_directory}/LibC.h
   ${include_directory}/Mapping.h
+  ${include_directory}/Profiling.h
   ${include_directory}/State.h
   ${include_directory}/Synchronization.h
   ${include_directory}/Types.h
@@ -104,6 +105,7 @@ set(src_files
   ${source_directory}/Mapping.cpp
   ${source_directory}/Misc.cpp
   ${source_directory}/Parallelism.cpp
+  ${source_directory}/Profiling.cpp
   ${source_directory}/Reduction.cpp
   ${source_directory}/State.cpp
   ${source_directory}/Synchronization.cpp
diff --git a/openmp/libomptarget/DeviceRTL/include/Profiling.h 
b/openmp/libomptarget/DeviceRTL/include/Profiling.h
new file mode 100644
index 00..68c7744cd60752
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/include/Profiling.h
@@ -0,0 +1,21 @@
+//=== Profiling.h - OpenMP interface -- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//
+//===--===//
+
+#ifndef OMPTARGET_DEVICERTL_PROFILING_H
+#define OMPTARGET_DEVICERTL_PROFILING_H
+
+extern "C" {
+
+void __llvm_profile_register_function(void *ptr);
+void __llvm_profile_register_names_function(void *ptr, long int i);
+}
+
+#endif
diff --git a/openmp/libomptarget/DeviceRTL/src/Profiling.cpp 
b/openmp/libomptarget/DeviceRTL/src/Profiling.cpp
new file mode 100644
index 00..799477f5e47d27
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/src/Profiling.cpp
@@ -0,0 +1,19 @@
+//===--- Profiling.cpp  C++ 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Profiling.h"
+
+#pragma omp begin declare target device_type(nohost)
+
+extern "C" {
+
+void __llvm_profile_register_function(void *ptr) {}
+void __llvm_profile_register_names_function(void *ptr, long int i) {}
+}
+
+#pragma omp end declare target

>From fb067d4ffe604fd68cf90b705db1942bce49dbb1 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough 
Date: Sat, 16 Dec 2023 01:18:41 -0600
Subject: [PATCH 02/12] Fix PGO instrumentation for GPU targets

---
 clang/lib/CodeGen/CodeGenPGO.cpp  | 10 --
 .../lib/Transforms/Instrumentation/InstrProfiling.cpp | 11 ---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 81bf8ea696b164..edae6885b528ac 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -959,8 +959,14 @@ void CodeGenPGO::emitCounterIncrement(CGBuilderTy 
, const Stmt *S,
 
   unsigned Counter = (*RegionCounterMap)[S];
 
-  llvm::Value *Args[] = {FuncNameVar,
- Builder.getInt64(FunctionHash),
+  // Make sure that pointer to global is passed in with zero addrspace
+  // This is 

[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)

2024-01-18 Thread Will Hawkins via lldb-commits


@@ -836,36 +834,18 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
   module_sp.reset(new Module(kern_spec));
   if (module_sp && module_sp->GetObjectFile() &&
   module_sp->MatchesModuleSpec(kern_spec)) {
-// module_sp is an actual kernel binary we want to add.
-if (process) {
-  const bool notify = false;
-  process->GetTarget().GetImages().AppendIfNeeded(module_sp, notify);
-  error.Clear();
-  return error;
-} else {
-  error = ModuleList::GetSharedModule(kern_spec, module_sp, nullptr,
-  nullptr, nullptr);
-  if (module_sp && module_sp->GetObjectFile() &&
-  module_sp->GetObjectFile()->GetType() !=
-  ObjectFile::Type::eTypeCoreFile) {
-return error;
-  }
-  module_sp.reset();
-}
+if (did_create_ptr)
+  *did_create_ptr = true;
+return {};
   }
 }
   }
 
   // Give the generic methods, including possibly calling into  DebugSymbols
   // framework on macOS systems, a chance.
-  error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
-  module_search_paths_ptr, old_modules,
-  did_create_ptr);
-  if (error.Success() && module_sp.get()) {
-return error;
-  }
-
-  return error;
+  return PlatformDarwin::GetSharedModule(module_spec, process, module_sp,

hawkinsw wrote:

I am *sure* that this is a dumb question, so forgive me ...

It seems like we can end up here with a "useless" pointer to an instance of 
`Module` in `module_sp`. Fortunately, the first thing that 
`PlatformDarwin::GetSharedModule` does is to reset that pointer which means 
that there is no leak. However, would it make sense to do a `reset` before 
calling just in case the code in that function changes in the future? 

Again, I apologize if this is a stupid question!

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


[Lldb-commits] [lldb] [llvm] [clang] [BOLT] Fix unconditional output of boltedcollection in merge-fdata (PR #78653)

2024-01-18 Thread Davide Italiano via lldb-commits

https://github.com/dcci commented:

LG

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


[Lldb-commits] [lldb] [clang] [llvm] [BOLT] Fix unconditional output of boltedcollection in merge-fdata (PR #78653)

2024-01-18 Thread Amir Ayupov via lldb-commits

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


[Lldb-commits] [lldb] [clang] [llvm] [BOLT] Fix unconditional output of boltedcollection in merge-fdata (PR #78653)

2024-01-18 Thread Amir Ayupov via lldb-commits

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


[Lldb-commits] [compiler-rt] [lld] [libcxx] [llvm] [lldb] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits

https://github.com/OldWorldOrdr updated 
https://github.com/llvm/llvm-project/pull/78628

>From e73fc2d0263e9e601f2964a90cfe347e8d2bb87c Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Thu, 18 Jan 2024 16:20:52 -0500
Subject: [PATCH 1/2] [lld-macho] Find objects in library search path

---
 lld/MachO/Driver.cpp | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 401459a054394e..f04165f5c02615 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});
 }
-return findPathCombination("lib" + name, config->librarySearchPaths,
-   {".tbd", ".dylib", ".so", ".a"});
+if (std::optional path =
+findPathCombination("lib" + name, config->librarySearchPaths,
+{".tbd", ".dylib", ".so", ".a"}))
+  return path;
+return findPathCombination(name, config->librarySearchPaths, {""});
   };
 
   std::optional path = doFind();

>From 04129383861613a71b55e934feed1d247ab01a02 Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Thu, 18 Jan 2024 21:16:57 -0500
Subject: [PATCH 2/2] [lld-macho] find objects in library search path version 2

---
 lld/MachO/Driver.cpp | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index f04165f5c02615..68f1a05cf86717 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -90,21 +90,19 @@ static std::optional findLibrary(StringRef name) 
{
 return entry->second;
 
   auto doFind = [&] {
+// Special case for Csu support files.
+if (name.ends_with(".o"))
+  return findPathCombination(name, config->librarySearchPaths, {});
 if (config->searchDylibsFirst) {
   if (std::optional path =
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  else if (std::optional path = findPathCombination(
-   "lib" + name, config->librarySearchPaths, {".a"}))
-return path;
-  return findPathCombination(name, config->librarySearchPaths, {""});
+  return findPathCombination("lib" + name, config->librarySearchPaths,
+ {".a"});
 }
-if (std::optional path =
-findPathCombination("lib" + name, config->librarySearchPaths,
-{".tbd", ".dylib", ".so", ".a"}))
-  return path;
-return findPathCombination(name, config->librarySearchPaths, {""});
+return findPathCombination("lib" + name, config->librarySearchPaths,
+   {".tbd", ".dylib", ".so", ".a"});
   };
 
   std::optional path = doFind();

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


[Lldb-commits] [compiler-rt] [lld] [libcxx] [llvm] [lldb] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits

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


[Lldb-commits] [compiler-rt] [lld] [libcxx] [llvm] [lldb] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits

OldWorldOrdr wrote:

Patch reworked to more closely replicate ld64's behavior.

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


[Lldb-commits] [lld] [llvm] [lldb] [compiler-rt] [libcxx] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits

https://github.com/OldWorldOrdr updated 
https://github.com/llvm/llvm-project/pull/78628

>From e73fc2d0263e9e601f2964a90cfe347e8d2bb87c Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Thu, 18 Jan 2024 16:20:52 -0500
Subject: [PATCH 1/2] [lld-macho] Find objects in library search path

---
 lld/MachO/Driver.cpp | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 401459a054394e..f04165f5c02615 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});
 }
-return findPathCombination("lib" + name, config->librarySearchPaths,
-   {".tbd", ".dylib", ".so", ".a"});
+if (std::optional path =
+findPathCombination("lib" + name, config->librarySearchPaths,
+{".tbd", ".dylib", ".so", ".a"}))
+  return path;
+return findPathCombination(name, config->librarySearchPaths, {""});
   };
 
   std::optional path = doFind();

>From 004fd9ae7e96e74c4bc1de811505d777e860c721 Mon Sep 17 00:00:00 2001
From: OldWorldOrdr 
Date: Thu, 18 Jan 2024 21:16:57 -0500
Subject: [PATCH 2/2] [lld-macho] find objects in library search path version 2

---
 lld/MachO/Driver.cpp | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index f04165f5c02615..3fd8ca21ac533b 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -90,21 +90,18 @@ static std::optional findLibrary(StringRef name) 
{
 return entry->second;
 
   auto doFind = [&] {
+if (name.ends_with(".o"))
+  return findPathCombination(name, config->librarySearchPaths, {});
 if (config->searchDylibsFirst) {
   if (std::optional path =
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  else if (std::optional path = findPathCombination(
-   "lib" + name, config->librarySearchPaths, {".a"}))
-return path;
-  return findPathCombination(name, config->librarySearchPaths, {""});
+  return findPathCombination("lib" + name, config->librarySearchPaths,
+ {".a"});
 }
-if (std::optional path =
-findPathCombination("lib" + name, config->librarySearchPaths,
-{".tbd", ".dylib", ".so", ".a"}))
-  return path;
-return findPathCombination(name, config->librarySearchPaths, {""});
+return findPathCombination("lib" + name, config->librarySearchPaths,
+   {".tbd", ".dylib", ".so", ".a"});
   };
 
   std::optional path = doFind();

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


[Lldb-commits] [lld] [libc] [llvm] [lldb] [flang] [openmp] [clang] [compiler-rt] [clang-tools-extra] [libcxx] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)

2024-01-18 Thread Ethan Luis McDonough via lldb-commits

https://github.com/EthanLuisMcDonough updated 
https://github.com/llvm/llvm-project/pull/76587

>From 530eb982b9770190377bb0bd09c5cb715f34d484 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough 
Date: Fri, 15 Dec 2023 20:38:38 -0600
Subject: [PATCH 01/11] Add profiling functions to libomptarget

---
 .../include/llvm/Frontend/OpenMP/OMPKinds.def |  3 +++
 openmp/libomptarget/DeviceRTL/CMakeLists.txt  |  2 ++
 .../DeviceRTL/include/Profiling.h | 21 +++
 .../libomptarget/DeviceRTL/src/Profiling.cpp  | 19 +
 4 files changed, 45 insertions(+)
 create mode 100644 openmp/libomptarget/DeviceRTL/include/Profiling.h
 create mode 100644 openmp/libomptarget/DeviceRTL/src/Profiling.cpp

diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def 
b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index d22d2a8e948b00..1d887d5cb58127 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -503,6 +503,9 @@ __OMP_RTL(__kmpc_barrier_simple_generic, false, Void, 
IdentPtr, Int32)
 __OMP_RTL(__kmpc_warp_active_thread_mask, false, Int64,)
 __OMP_RTL(__kmpc_syncwarp, false, Void, Int64)
 
+__OMP_RTL(__llvm_profile_register_function, false, Void, VoidPtr)
+__OMP_RTL(__llvm_profile_register_names_function, false, Void, VoidPtr, Int64)
+
 __OMP_RTL(__last, false, Void, )
 
 #undef __OMP_RTL
diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt 
b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 1ce3e1e40a80ab..55ee15d068c67b 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -89,6 +89,7 @@ set(include_files
   ${include_directory}/Interface.h
   ${include_directory}/LibC.h
   ${include_directory}/Mapping.h
+  ${include_directory}/Profiling.h
   ${include_directory}/State.h
   ${include_directory}/Synchronization.h
   ${include_directory}/Types.h
@@ -104,6 +105,7 @@ set(src_files
   ${source_directory}/Mapping.cpp
   ${source_directory}/Misc.cpp
   ${source_directory}/Parallelism.cpp
+  ${source_directory}/Profiling.cpp
   ${source_directory}/Reduction.cpp
   ${source_directory}/State.cpp
   ${source_directory}/Synchronization.cpp
diff --git a/openmp/libomptarget/DeviceRTL/include/Profiling.h 
b/openmp/libomptarget/DeviceRTL/include/Profiling.h
new file mode 100644
index 00..68c7744cd60752
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/include/Profiling.h
@@ -0,0 +1,21 @@
+//=== Profiling.h - OpenMP interface -- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//
+//===--===//
+
+#ifndef OMPTARGET_DEVICERTL_PROFILING_H
+#define OMPTARGET_DEVICERTL_PROFILING_H
+
+extern "C" {
+
+void __llvm_profile_register_function(void *ptr);
+void __llvm_profile_register_names_function(void *ptr, long int i);
+}
+
+#endif
diff --git a/openmp/libomptarget/DeviceRTL/src/Profiling.cpp 
b/openmp/libomptarget/DeviceRTL/src/Profiling.cpp
new file mode 100644
index 00..799477f5e47d27
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/src/Profiling.cpp
@@ -0,0 +1,19 @@
+//===--- Profiling.cpp  C++ 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Profiling.h"
+
+#pragma omp begin declare target device_type(nohost)
+
+extern "C" {
+
+void __llvm_profile_register_function(void *ptr) {}
+void __llvm_profile_register_names_function(void *ptr, long int i) {}
+}
+
+#pragma omp end declare target

>From fb067d4ffe604fd68cf90b705db1942bce49dbb1 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough 
Date: Sat, 16 Dec 2023 01:18:41 -0600
Subject: [PATCH 02/11] Fix PGO instrumentation for GPU targets

---
 clang/lib/CodeGen/CodeGenPGO.cpp  | 10 --
 .../lib/Transforms/Instrumentation/InstrProfiling.cpp | 11 ---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 81bf8ea696b164..edae6885b528ac 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -959,8 +959,14 @@ void CodeGenPGO::emitCounterIncrement(CGBuilderTy 
, const Stmt *S,
 
   unsigned Counter = (*RegionCounterMap)[S];
 
-  llvm::Value *Args[] = {FuncNameVar,
- Builder.getInt64(FunctionHash),
+  // Make sure that pointer to global is passed in with zero addrspace
+  // This is 

[Lldb-commits] [lld] [llvm] [lldb] [compiler-rt] [libcxx] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits


@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});

OldWorldOrdr wrote:

Looks like ld64 checks if the library name ends in `.o` and if so, assumes it's 
a Csu support file, and looks for a file in the library search path with that 
exact name, not searching for any `libcrt1.o.a`.

If a Csu support file is not found ld64 automatically changes the target to 
MacOS 10.8 which stopped requiring Csu support files, then continues without 
linking the object.

Apples new linker does the same, but it has no concept of Csu support files and 
just links with it like it were a normal file, exiting with an error if it's 
not found.

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


[Lldb-commits] [llvm] [libcxx] [lld] [lldb] [compiler-rt] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread Shoaib Meenai via lldb-commits


@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});

smeenai wrote:

Huh, that's interesting. I wonder if they have some special-cased logic around 
these specific extensions, or if they just won't append the `.a` if there's 
already any other extension present...

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


[Lldb-commits] [libcxx] [llvm] [lldb] [compiler-rt] [lld] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits


@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});

OldWorldOrdr wrote:

removing the object and trying again gives an error, ld64 wont link with the .a 
file at all

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


[Lldb-commits] [libcxx] [llvm] [lldb] [compiler-rt] [lld] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread Shoaib Meenai via lldb-commits


@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});

smeenai wrote:

Hmm. In that case, we probably want to instead change `findPathCombination` to 
take a list of prefixes, so that we can match ld64's search behavior?

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


[Lldb-commits] [llvm] [compiler-rt] [libcxx] [lld] [lldb] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits


@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});

OldWorldOrdr wrote:

a quick test with both `libcrt1.o.a` and `crt1.o` shows ld64 prefers crt1.o

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


[Lldb-commits] [lldb] [libcxx] [lld] [llvm] [compiler-rt] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread Shoaib Meenai via lldb-commits


@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});

smeenai wrote:

You're right; that was a think-o on my part :) That being said, the scenario in 
my first comment (except with `/bar/libcrt1.o.a`) still applies; it's an edge 
case, but if we're matching ld64 behavior, we might as well match it as closely 
as reasonable.

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


[Lldb-commits] [lldb] [libcxx] [lld] [llvm] [compiler-rt] [lld-macho] Find objects in library search path (PR #78628)

2024-01-18 Thread via lldb-commits


@@ -95,11 +95,16 @@ static std::optional findLibrary(StringRef name) 
{
   findPathCombination("lib" + name, config->librarySearchPaths,
   {".tbd", ".dylib", ".so"}))
 return path;
-  return findPathCombination("lib" + name, config->librarySearchPaths,
- {".a"});
+  else if (std::optional path = findPathCombination(
+   "lib" + name, config->librarySearchPaths, {".a"}))
+return path;
+  return findPathCombination(name, config->librarySearchPaths, {""});

OldWorldOrdr wrote:

are you suggesting the code be
```c++
  return findPathCombination("lib" + name, config->librarySearchPaths,
 {".a", ""});
```
Won't that look for `libcrt1.o` instead of `crt1.o`?

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


[Lldb-commits] [lldb] Clean up PlatformDarwinKernel::GetSharedModule, document (PR #78652)

2024-01-18 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

Hmm, yeah testing this is probably tricky to do.

Nonetheless, I think your cleanup logic makes sense. It's also nice that you've 
documented the intended behavior.  

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/78605

>From 48c6e5edc1dc5f832f8f5c922c61af9070ad341d Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Thu, 18 Jan 2024 09:09:50 -0800
Subject: [PATCH 1/8] Added settings for cache location and timeout

---
 .../Debuginfod/SymbolLocatorDebuginfod.cpp| 82 +++
 .../SymbolLocatorDebuginfodProperties.td  |  8 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h | 13 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 31 +--
 4 files changed, 108 insertions(+), 26 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp 
b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 111be6be365240e..a20437c256eb437 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -9,6 +9,7 @@
 #include "SymbolLocatorDebuginfod.h"
 
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueString.h"
 #include "lldb/Utility/Args.h"
 
 #include "llvm/Debuginfod/Debuginfod.h"
@@ -54,6 +55,34 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {
+OptionValueString *s =
+m_collection_sp->GetPropertyAtIndexAsOptionValueString(
+ePropertySymbolCachePath);
+// If we don't have a valid cache location, use the default one.
+if (!s || !s->GetCurrentValueAsRef().size()) {
+  llvm::Expected maybeCachePath =
+  llvm::getDefaultDebuginfodCacheDirectory();
+  if (!maybeCachePath) {
+return maybeCachePath;
+  }
+  m_cache_path = *maybeCachePath;
+  return llvm::StringRef(m_cache_path);
+}
+return s->GetCurrentValueAsRef();
+  }
+
+  std::chrono::milliseconds GetTimeout() const {
+std::optional seconds =
+m_collection_sp->GetPropertyAtIndexAs(ePropertyTimeout);
+if (seconds && *seconds != 0) {
+  return std::chrono::duration_cast(
+  std::chrono::seconds(*seconds));
+} else {
+  return llvm::getDefaultDebuginfodTimeout();
+}
+  }
+
 private:
   void ServerURLsChangedCallback() {
 m_server_urls = GetDebugInfoDURLs();
@@ -65,6 +94,7 @@ class PluginProperties : public Properties {
   }
   // Storage for the StringRef's used within the Debuginfod library.
   Args m_server_urls;
+  std::string m_cache_path;
 };
 
 } // namespace
@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);
+  std::string CacheKey = llvm::getDebuginfodCacheKey(UrlPath);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  CacheKey, UrlPath, CacheDirectoryPath, DebuginfodUrls, Timeout);
+  if (result)
+return FileSpec(*result);
+  // An error here should be logged as a failure in the Debuginfod library,
+  // just consume it here
+  consumeError(result.takeError());
   return {};
 }
 
 std::optional SymbolLocatorDebuginfod::LocateExecutableObjectFile(
 const ModuleSpec _spec) {
-  return GetFileForModule(module_spec, llvm::getCachedOrDownloadExecutable);
+  return GetFileForModule(module_spec, 

[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Jonas Devlieghere via lldb-commits

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

Thanks! This LGTM. 

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Jonas Devlieghere via lldb-commits


@@ -112,31 +141,52 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
+static std::optional
+GetFileForModule(const ModuleSpec _spec,
+ std::function UrlBuilder) 
{
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false.
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab LLDB's Debuginfod overrides from the
+  // plugin.symbol-locator.debuginfod.* settings.
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected cache_path_or_err = plugin_props.GetCachePath();
+  // A cache location is *required*.
+  if (!cache_path_or_err)
+return {};
+  std::string cache_path = *cache_path_or_err;
+  llvm::SmallVector debuginfod_urls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file.
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string url_path = UrlBuilder(build_id);
+  std::string cache_key = llvm::getDebuginfodCacheKey(url_path);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  cache_key, url_path, cache_path, debuginfod_urls, timeout);
+  if (result)
+return FileSpec(*result);
+
+  Log *log = GetLog(LLDBLog::Symbols);
+  auto err_message = llvm::toString(result.takeError());
+  LLDB_LOGV(log,
+"[Debuginfod] Failed to download symbol artifact {0} "

JDevlieghere wrote:

Yeah you need to pass `-F` to `log enable` to include the file and function 
names. Anyway this works for me!

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/78605

>From b46553c6fe17a50dc2072544e46b7a1dde127436 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Thu, 18 Jan 2024 09:09:50 -0800
Subject: [PATCH 1/8] Added settings for cache location and timeout

---
 .../Debuginfod/SymbolLocatorDebuginfod.cpp| 82 +++
 .../SymbolLocatorDebuginfodProperties.td  |  8 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h | 13 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 31 +--
 4 files changed, 108 insertions(+), 26 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp 
b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 111be6be365240..a20437c256eb43 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -9,6 +9,7 @@
 #include "SymbolLocatorDebuginfod.h"
 
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueString.h"
 #include "lldb/Utility/Args.h"
 
 #include "llvm/Debuginfod/Debuginfod.h"
@@ -54,6 +55,34 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {
+OptionValueString *s =
+m_collection_sp->GetPropertyAtIndexAsOptionValueString(
+ePropertySymbolCachePath);
+// If we don't have a valid cache location, use the default one.
+if (!s || !s->GetCurrentValueAsRef().size()) {
+  llvm::Expected maybeCachePath =
+  llvm::getDefaultDebuginfodCacheDirectory();
+  if (!maybeCachePath) {
+return maybeCachePath;
+  }
+  m_cache_path = *maybeCachePath;
+  return llvm::StringRef(m_cache_path);
+}
+return s->GetCurrentValueAsRef();
+  }
+
+  std::chrono::milliseconds GetTimeout() const {
+std::optional seconds =
+m_collection_sp->GetPropertyAtIndexAs(ePropertyTimeout);
+if (seconds && *seconds != 0) {
+  return std::chrono::duration_cast(
+  std::chrono::seconds(*seconds));
+} else {
+  return llvm::getDefaultDebuginfodTimeout();
+}
+  }
+
 private:
   void ServerURLsChangedCallback() {
 m_server_urls = GetDebugInfoDURLs();
@@ -65,6 +94,7 @@ class PluginProperties : public Properties {
   }
   // Storage for the StringRef's used within the Debuginfod library.
   Args m_server_urls;
+  std::string m_cache_path;
 };
 
 } // namespace
@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);
+  std::string CacheKey = llvm::getDebuginfodCacheKey(UrlPath);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  CacheKey, UrlPath, CacheDirectoryPath, DebuginfodUrls, Timeout);
+  if (result)
+return FileSpec(*result);
+  // An error here should be logged as a failure in the Debuginfod library,
+  // just consume it here
+  consumeError(result.takeError());
   return {};
 }
 
 std::optional SymbolLocatorDebuginfod::LocateExecutableObjectFile(
 const ModuleSpec _spec) {
-  return GetFileForModule(module_spec, llvm::getCachedOrDownloadExecutable);
+  return GetFileForModule(module_spec, 

[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits


@@ -1,7 +1,13 @@
 include "../../../../include/lldb/Core/PropertiesBase.td"
 
 let Definition = "symbollocatordebuginfod" in {
-  def ServerURLs : Property<"server_urls", "Array">,
+  def ServerURLs : Property<"server-urls", "Array">,
 ElementType<"String">,
 Desc<"An ordered list of Debuginfod server URLs to query for symbols. This 
defaults to the contents of the DEBUGINFOD_URLS environment variable.">;
+  def SymbolCachePath: Property<"cache-path", "String">,
+DefaultStringValue<"">,
+Desc<"The path where symbol files should be cached. This defaults to 
LLDB's system cache location.">;
+  def Timeout : Property<"timeout", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Timeout (in seconds) for requests made to a DEBUGINFOD server. A 
value of zero defaults to DEBUGINFOD_TIMEOUT environment variable (or 90 
seconds).">;

kevinfrei wrote:

I make no claims to my ability to write readable prose. Your description makes 
at least much as sense as mine, so I'll just swipe it directly.

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Jonas Devlieghere via lldb-commits


@@ -1,7 +1,13 @@
 include "../../../../include/lldb/Core/PropertiesBase.td"
 
 let Definition = "symbollocatordebuginfod" in {
-  def ServerURLs : Property<"server_urls", "Array">,
+  def ServerURLs : Property<"server-urls", "Array">,
 ElementType<"String">,
 Desc<"An ordered list of Debuginfod server URLs to query for symbols. This 
defaults to the contents of the DEBUGINFOD_URLS environment variable.">;
+  def SymbolCachePath: Property<"cache-path", "String">,
+DefaultStringValue<"">,
+Desc<"The path where symbol files should be cached. This defaults to 
LLDB's system cache location.">;
+  def Timeout : Property<"timeout", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Timeout (in seconds) for requests made to a DEBUGINFOD server. A 
value of zero defaults to DEBUGINFOD_TIMEOUT environment variable (or 90 
seconds).">;

JDevlieghere wrote:

Gotcha, that makes sense and that's not how I understood it when I read the 
description. Not sure if this is better but maybe something along the lines of: 

> Timeout (in seconds) for requests made to a DEBUGINFOD server. A value of 
> zero means we use the debuginfod default timeout: DEBUGINFOD_TIMEOUT if the 
> environment variable is set and 90 seconds otherwise. 

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits


@@ -112,31 +141,52 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
+static std::optional
+GetFileForModule(const ModuleSpec _spec,
+ std::function UrlBuilder) 
{
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false.
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab LLDB's Debuginfod overrides from the
+  // plugin.symbol-locator.debuginfod.* settings.
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected cache_path_or_err = plugin_props.GetCachePath();
+  // A cache location is *required*.
+  if (!cache_path_or_err)
+return {};
+  std::string cache_path = *cache_path_or_err;
+  llvm::SmallVector debuginfod_urls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file.
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string url_path = UrlBuilder(build_id);
+  std::string cache_key = llvm::getDebuginfodCacheKey(url_path);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  cache_key, url_path, cache_path, debuginfod_urls, timeout);
+  if (result)
+return FileSpec(*result);
+
+  Log *log = GetLog(LLDBLog::Symbols);
+  auto err_message = llvm::toString(result.takeError());
+  LLDB_LOGV(log,
+"[Debuginfod] Failed to download symbol artifact {0} "

kevinfrei wrote:

> I'd drop the `[Debuginfod]` as it's not something other plugins do and you 
> can see where the log message came from which will make it obvious that 
> that's coming from the debuginfod plugin. If you really want to include it, 
> I'd do something like "Debuginfod failed".

I can't see that it's coming from the Debuginfod plugin: 
```
(lldb) log enable lldb symbol --verbose
(lldb) target create /bin/tar
Debuginfod failed to download symbol artifact 
buildid/b4e36170d228ca4ae032f06b16f69adb48d07c50/debuginfo with error 
curl_easy_perform() failed: Timeout was reached
```

so I'm inclined to just switch it to...what you can see I switched it to. If 
you want me to create a new LLDBLog category, I do believe *that* would make it 
more obvious. I just reused LLDBLog::Symbols.

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Jonas Devlieghere via lldb-commits


@@ -112,31 +141,52 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
+static std::optional
+GetFileForModule(const ModuleSpec _spec,
+ std::function UrlBuilder) 
{
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false.
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab LLDB's Debuginfod overrides from the
+  // plugin.symbol-locator.debuginfod.* settings.
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected cache_path_or_err = plugin_props.GetCachePath();
+  // A cache location is *required*.
+  if (!cache_path_or_err)
+return {};
+  std::string cache_path = *cache_path_or_err;
+  llvm::SmallVector debuginfod_urls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file.
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string url_path = UrlBuilder(build_id);
+  std::string cache_key = llvm::getDebuginfodCacheKey(url_path);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  cache_key, url_path, cache_path, debuginfod_urls, timeout);
+  if (result)
+return FileSpec(*result);
+
+  Log *log = GetLog(LLDBLog::Symbols);
+  auto err_message = llvm::toString(result.takeError());
+  LLDB_LOGV(log,
+"[Debuginfod] Failed to download symbol artifact {0} "

JDevlieghere wrote:

I'd drop the `[Debuginfod]` as it's not something other plugins do and you can 
see where the log message came from which will make it obvious that that's 
coming from the debuginfod plugin. If you really want to include it, I'd do 
something like "Debuginfod failed". 

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


[Lldb-commits] [lldb] [llvm] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Jonas Devlieghere via lldb-commits


@@ -1,7 +1,13 @@
 include "../../../../include/lldb/Core/PropertiesBase.td"
 
 let Definition = "symbollocatordebuginfod" in {
-  def ServerURLs : Property<"server_urls", "Array">,
+  def ServerURLs : Property<"server-urls", "Array">,
 ElementType<"String">,
 Desc<"An ordered list of Debuginfod server URLs to query for symbols. This 
defaults to the contents of the DEBUGINFOD_URLS environment variable.">;
+  def SymbolCachePath: Property<"cache-path", "String">,
+DefaultStringValue<"">,
+Desc<"The path where symbol files should be cached. This defaults to 
LLDB's system cache location.">;
+  def Timeout : Property<"timeout", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Timeout (in seconds) for requests made to a DEBUGINFOD server. A 
value of zero defaults to DEBUGINFOD_TIMEOUT environment variable (or 90 
seconds).">;

JDevlieghere wrote:

I think this is rather weird: why not make 90 the default? If I specify zero 
I'd expect no timeout. 

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

> LGTM for debuginfod

I've considered moving that entire thing into a namespace. Would you be 
amenable to that (at a later date...)?

Unimportant: The OMF2097 github pic is pretty excellent, but clearly you're 
almost as old as me...

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/78605

>From b46553c6fe17a50dc2072544e46b7a1dde127436 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Thu, 18 Jan 2024 09:09:50 -0800
Subject: [PATCH 1/6] Added settings for cache location and timeout

---
 .../Debuginfod/SymbolLocatorDebuginfod.cpp| 82 +++
 .../SymbolLocatorDebuginfodProperties.td  |  8 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h | 13 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 31 +--
 4 files changed, 108 insertions(+), 26 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp 
b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 111be6be365240..a20437c256eb43 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -9,6 +9,7 @@
 #include "SymbolLocatorDebuginfod.h"
 
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueString.h"
 #include "lldb/Utility/Args.h"
 
 #include "llvm/Debuginfod/Debuginfod.h"
@@ -54,6 +55,34 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {
+OptionValueString *s =
+m_collection_sp->GetPropertyAtIndexAsOptionValueString(
+ePropertySymbolCachePath);
+// If we don't have a valid cache location, use the default one.
+if (!s || !s->GetCurrentValueAsRef().size()) {
+  llvm::Expected maybeCachePath =
+  llvm::getDefaultDebuginfodCacheDirectory();
+  if (!maybeCachePath) {
+return maybeCachePath;
+  }
+  m_cache_path = *maybeCachePath;
+  return llvm::StringRef(m_cache_path);
+}
+return s->GetCurrentValueAsRef();
+  }
+
+  std::chrono::milliseconds GetTimeout() const {
+std::optional seconds =
+m_collection_sp->GetPropertyAtIndexAs(ePropertyTimeout);
+if (seconds && *seconds != 0) {
+  return std::chrono::duration_cast(
+  std::chrono::seconds(*seconds));
+} else {
+  return llvm::getDefaultDebuginfodTimeout();
+}
+  }
+
 private:
   void ServerURLsChangedCallback() {
 m_server_urls = GetDebugInfoDURLs();
@@ -65,6 +94,7 @@ class PluginProperties : public Properties {
   }
   // Storage for the StringRef's used within the Debuginfod library.
   Args m_server_urls;
+  std::string m_cache_path;
 };
 
 } // namespace
@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);
+  std::string CacheKey = llvm::getDebuginfodCacheKey(UrlPath);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  CacheKey, UrlPath, CacheDirectoryPath, DebuginfodUrls, Timeout);
+  if (result)
+return FileSpec(*result);
+  // An error here should be logged as a failure in the Debuginfod library,
+  // just consume it here
+  consumeError(result.takeError());
   return {};
 }
 
 std::optional SymbolLocatorDebuginfod::LocateExecutableObjectFile(
 const ModuleSpec _spec) {
-  return GetFileForModule(module_spec, llvm::getCachedOrDownloadExecutable);
+  return GetFileForModule(module_spec, 

[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-18 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-18 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-18 Thread Adrian Prantl via lldb-commits


@@ -663,6 +663,30 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(GetData(), this, _offset))
+return llvm::StringRef();
+
+  // Does die contain an AT_Name?

adrian-prantl wrote:

```suggestion
  // Does die contain a DW_AT_name?
```
makes grepping more reliable

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/78605

>From b46553c6fe17a50dc2072544e46b7a1dde127436 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Thu, 18 Jan 2024 09:09:50 -0800
Subject: [PATCH 1/6] Added settings for cache location and timeout

---
 .../Debuginfod/SymbolLocatorDebuginfod.cpp| 82 +++
 .../SymbolLocatorDebuginfodProperties.td  |  8 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h | 13 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 31 +--
 4 files changed, 108 insertions(+), 26 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp 
b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 111be6be365240e..a20437c256eb437 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -9,6 +9,7 @@
 #include "SymbolLocatorDebuginfod.h"
 
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueString.h"
 #include "lldb/Utility/Args.h"
 
 #include "llvm/Debuginfod/Debuginfod.h"
@@ -54,6 +55,34 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {
+OptionValueString *s =
+m_collection_sp->GetPropertyAtIndexAsOptionValueString(
+ePropertySymbolCachePath);
+// If we don't have a valid cache location, use the default one.
+if (!s || !s->GetCurrentValueAsRef().size()) {
+  llvm::Expected maybeCachePath =
+  llvm::getDefaultDebuginfodCacheDirectory();
+  if (!maybeCachePath) {
+return maybeCachePath;
+  }
+  m_cache_path = *maybeCachePath;
+  return llvm::StringRef(m_cache_path);
+}
+return s->GetCurrentValueAsRef();
+  }
+
+  std::chrono::milliseconds GetTimeout() const {
+std::optional seconds =
+m_collection_sp->GetPropertyAtIndexAs(ePropertyTimeout);
+if (seconds && *seconds != 0) {
+  return std::chrono::duration_cast(
+  std::chrono::seconds(*seconds));
+} else {
+  return llvm::getDefaultDebuginfodTimeout();
+}
+  }
+
 private:
   void ServerURLsChangedCallback() {
 m_server_urls = GetDebugInfoDURLs();
@@ -65,6 +94,7 @@ class PluginProperties : public Properties {
   }
   // Storage for the StringRef's used within the Debuginfod library.
   Args m_server_urls;
+  std::string m_cache_path;
 };
 
 } // namespace
@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);
+  std::string CacheKey = llvm::getDebuginfodCacheKey(UrlPath);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  CacheKey, UrlPath, CacheDirectoryPath, DebuginfodUrls, Timeout);
+  if (result)
+return FileSpec(*result);
+  // An error here should be logged as a failure in the Debuginfod library,
+  // just consume it here
+  consumeError(result.takeError());
   return {};
 }
 
 std::optional SymbolLocatorDebuginfod::LocateExecutableObjectFile(
 const ModuleSpec _spec) {
-  return GetFileForModule(module_spec, llvm::getCachedOrDownloadExecutable);
+  return GetFileForModule(module_spec, 

[Lldb-commits] [lldb] [llvm] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits


@@ -54,6 +55,34 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {

kevinfrei wrote:

D'oh. You're right. I'll hoist that StringRef up and switch the function to 
return a string. Good catch!

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


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

2024-01-18 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

I've returned to this after getting some other work up for a PR, and I'm stuck 
again. If I remove LLVM_DIR, the thing doesn't get anywhere. It explicitly asks 
for LLVM_DIR, if I work through that, then it asks for Clang_DIR. I'm getting 
frustrated because it seems like the configuration you're stuck on isn't 
supported (anymore: I'm guessing it's a holdover from before the monorepo). I 
just can't find any documentation for building the way you're describing. 
Everything says to use LLVM_DIR. So, if I set LLVM_DIR, it (correctly) links 
against libDebuginfod.a just fine. And if I don't have LLVM_DIR set, there'a 
whole lot of stuff that fails to work properly.

Is there some docker container I can spin up with your configuration already 
setup or something? I'm completely stuck again.

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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-18 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

@clayborg  with your feedback, I think I was able to solve the issue _and_ 
reuse existing code.
Please have a look at the latest commit!

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


[Lldb-commits] [lldb] [lldb] refactor colorize function for image lookup command (PR #76112)

2024-01-18 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] enhance colorize process for image lookup command (PR #76112)

2024-01-18 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] [lldb] enhance colorize process for image lookup command (PR #76112)

2024-01-18 Thread José Lira Junior via lldb-commits


@@ -72,23 +72,21 @@ size_t Stream::PutCString(llvm::StringRef str) {
   return bytes_written;
 }
 
-void Stream::PutCStringColorHighlighted(llvm::StringRef text,
-llvm::StringRef pattern,
-llvm::StringRef prefix,
-llvm::StringRef suffix) {
-  // Only apply color formatting when a pattern is present and both prefix and
-  // suffix are specified. In the absence of these conditions, output the text
-  // without color formatting.
-  if (pattern.empty() || (prefix.empty() && suffix.empty())) {
+void Stream::PutCStringColorHighlighted(
+llvm::StringRef text, std::optional pattern_info) {
+  // Only apply color formatting when the pattern information is specified.
+  // Otherwise, output the text without color formatting.
+  if (!pattern_info.has_value()) {
 PutCString(text);
 return;
   }
 
-  llvm::Regex reg_pattern(pattern);
+  llvm::Regex reg_pattern(pattern_info.value().pattern);

junior-jl wrote:

Done. Thanks!

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


[Lldb-commits] [lldb] [lldb] enhance colorize process for image lookup command (PR #76112)

2024-01-18 Thread José Lira Junior via lldb-commits


@@ -262,14 +263,12 @@ void Symbol::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
   }
   if (ConstString demangled = m_mangled.GetDemangledName()) {
 s->PutCString(", name=\"");
-s->PutCStringColorHighlighted(demangled.GetStringRef(), pattern,
-  ansi_prefix, ansi_suffix);
+s->PutCStringColorHighlighted(demangled.GetStringRef(), pattern_info);
 s->PutCString("\"");
   }
   if (ConstString mangled_name = m_mangled.GetMangledName()) {
 s->PutCString(", mangled=\"");
-s->PutCStringColorHighlighted(mangled_name.GetStringRef(), pattern,
-  ansi_prefix, ansi_suffix);
+s->PutCStringColorHighlighted(mangled_name.GetStringRef(), pattern_info);

junior-jl wrote:

Since the struct name changed, should we rename this to something like 
`highlight_settings` or `color_settings`?

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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-18 Thread Felipe de Azevedo Piovezan via lldb-commits

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

>From b0a33481162e24a7106cbd554b33ddb098df7612 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 11:26:52 -0800
Subject: [PATCH 1/4] [lldb][DWARFUnit] Implement PeekDIEName query

This allows us to query the AT_Name of a DIE without parsing the entire CU.

Part of the ongoing effort to support IDX_Parent in accelerator tables [1].

[1]: 
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44
---
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   |  7 +++
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  5 ++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|  8 +++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  5 ++
 .../SymbolFile/DWARF/DWARFDIETest.cpp | 59 +++
 5 files changed, 84 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 553b6a4c551d205..775b7a2e73f512f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -191,3 +191,10 @@ DWARFDebugInfo::GetDIE(const DIERef _ref) {
 return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
   return DWARFDIE(); // Not found
 }
+
+llvm::StringRef
+DWARFDebugInfo::PeekDIEName(const DIERef _ref) {
+  if(DWARFUnit *cu = GetUnit(die_ref))
+return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset());
+  return llvm::StringRef();
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index d5e48f312ea0e98..a8b5abc3beed2d0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -43,6 +43,11 @@ class DWARFDebugInfo {
   bool ContainsTypeUnits();
   DWARFDIE GetDIE(const DIERef _ref);
 
+  /// Returns the AT_Name of this DIE, if it exists, without parsing the entire
+  /// compile unit. An empty is string is returned upon error or if the
+  /// attribute is not present.
+  llvm::StringRef PeekDIEName(const DIERef _ref);
+
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
 eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 0e2f4d45543bb53..7db279ed37d04aa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor  = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, _offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}
+
 DWARFUnit ::GetNonSkeletonUnit() {
   ExtractUnitDIEIfNeeded();
   if (m_dwo)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 3f528e913d8cfab..bc225a52e1d0309 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -187,6 +187,11 @@ class DWARFUnit : public UserID {
 
   DWARFDIE GetDIE(dw_offset_t die_offset);
 
+  /// Returns the AT_Name of the DIE at `die_offset`, if it exists, without
+  /// parsing the entire compile unit. An empty is string is returned upon
+  /// error or if the attribute is not present.
+  llvm::StringRef PeekDIEName(dw_offset_t die_offset);
+
   DWARFUnit ();
 
   static uint8_t GetAddressByteSize(const DWARFUnit *cu);
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 8497855b2f3db59..ff433c7a14ef7be 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "llvm/ADT/STLExtras.h"
 #include "gmock/gmock.h"
@@ -104,3 +105,61 @@ TEST(DWARFDIETest, ChildIteration) {
   DWARFDIE no_children_die(unit, die_child0);
   EXPECT_TRUE(no_children_die.children().empty());
 }
+
+TEST(DWARFDIETest, PeekName) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'NameType1'
+- 'NameType2'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:  

[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Daniel Thornburgh via lldb-commits


@@ -58,15 +61,25 @@ Expected getDefaultDebuginfodCacheDirectory();
 /// DEBUGINFOD_TIMEOUT environment variable, default is 90 seconds (9 ms).
 std::chrono::milliseconds getDefaultDebuginfodTimeout();
 
+/// Get the full UrlPath for a source request of a given BuildID and file path.
+std::string getDebuginfodSourceUrlPath(object::BuildIDRef ID,
+   StringRef SourceFilePath);
+
 /// Fetches a specified source file by searching the default local cache
 /// directory and server URLs.
 Expected getCachedOrDownloadSource(object::BuildIDRef ID,
 StringRef SourceFilePath);
 
+/// Get the full UrlPath for an Executable request of a given BuildID.
+std::string getDebuginfodExecutableUrlPath(object::BuildIDRef ID);
+
 /// Fetches an executable by searching the default local cache directory and
 /// server URLs.
 Expected getCachedOrDownloadExecutable(object::BuildIDRef ID);
 
+/// Get the full UrlPath for a debug binary request of a given BuildID.

mysterymath wrote:

```suggestion
/// Get the full URL path for a debug binary request of a given BuildID.
```

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Daniel Thornburgh via lldb-commits


@@ -58,15 +61,25 @@ Expected getDefaultDebuginfodCacheDirectory();
 /// DEBUGINFOD_TIMEOUT environment variable, default is 90 seconds (9 ms).
 std::chrono::milliseconds getDefaultDebuginfodTimeout();
 
+/// Get the full UrlPath for a source request of a given BuildID and file path.

mysterymath wrote:

```suggestion
/// Get the full URL path for a source request of a given BuildID and file path.
```

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Daniel Thornburgh via lldb-commits


@@ -58,15 +61,25 @@ Expected getDefaultDebuginfodCacheDirectory();
 /// DEBUGINFOD_TIMEOUT environment variable, default is 90 seconds (9 ms).
 std::chrono::milliseconds getDefaultDebuginfodTimeout();
 
+/// Get the full UrlPath for a source request of a given BuildID and file path.
+std::string getDebuginfodSourceUrlPath(object::BuildIDRef ID,
+   StringRef SourceFilePath);
+
 /// Fetches a specified source file by searching the default local cache
 /// directory and server URLs.
 Expected getCachedOrDownloadSource(object::BuildIDRef ID,
 StringRef SourceFilePath);
 
+/// Get the full UrlPath for an Executable request of a given BuildID.

mysterymath wrote:

```suggestion
/// Get the full URL path for an executable request of a given BuildID.
```

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Daniel Thornburgh via lldb-commits


@@ -46,6 +46,9 @@ bool canUseDebuginfod();
 /// environment variable.
 SmallVector getDefaultDebuginfodUrls();
 
+/// Creates the cache-key for a given Debuginfod UrlPath

mysterymath wrote:

```suggestion
/// Returns the cache key for a given debuginfod URL path.
```

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Daniel Thornburgh via lldb-commits

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


[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Daniel Thornburgh via lldb-commits

https://github.com/mysterymath commented:

LGTM for debuginfod

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


[Lldb-commits] [lldb] [lldb] enhance colorize process for image lookup command (PR #76112)

2024-01-18 Thread José Lira Junior via lldb-commits


@@ -1609,6 +1612,11 @@ static uint32_t LookupSymbolInModule(CommandInterpreter 
,
   }
 
   if (num_matches > 0) {
+llvm::StringRef ansi_prefix =
+interpreter.GetDebugger().GetRegexMatchAnsiPrefix();
+llvm::StringRef ansi_suffix =
+interpreter.GetDebugger().GetRegexMatchAnsiSuffix();
+Information info(name, ansi_prefix, ansi_suffix);

junior-jl wrote:

I'm unsure if the modification made in last commit addresses this correctly.

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


[Lldb-commits] [lldb] [lldb] enhance colorize process for image lookup command (PR #76112)

2024-01-18 Thread José Lira Junior via lldb-commits


@@ -23,6 +23,16 @@
 
 namespace lldb_private {
 
+struct Information {

junior-jl wrote:

Done.

I was thinking: should we add a default constructor?

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


[Lldb-commits] [libunwind] [lldb] [libc] [lld] [clang-tools-extra] [compiler-rt] [llvm] [clang] [libclc] [flang] [libcxxabi] [libcxx] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #

2024-01-18 Thread Paul Kirth via lldb-commits


@@ -80,6 +80,11 @@ static cl::opt EnableRISCVDeadRegisterElimination(
  " them with stores to x0"),
 cl::init(true));
 
+// TODO: This should be controlled by -mtls-dialect=
+cl::opt EnableRISCVTLSDESC("riscv-enable-tlsdesc",

ilovepi wrote:

That's a good suggestion. I was thinking of doing something like that as a 
follow up for the Clang driver patches, but I agree, its probably better to do 
it in this patch.

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


[Lldb-commits] [lldb] [lldb] enhance colorize process for image lookup command (PR #76112)

2024-01-18 Thread José Lira Junior via lldb-commits

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

From fb2383f3e6e2124e4f14e8e0f6a04df4bed15f65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Thu, 18 Jan 2024 20:03:25 -0300
Subject: [PATCH] refactor PutCStringColorHighlight | add struct to store
 highlight settings

---
 lldb/include/lldb/Core/Address.h |  4 +-
 lldb/include/lldb/Symbol/Symbol.h|  4 +-
 lldb/include/lldb/Symbol/SymbolContext.h |  7 +++-
 lldb/include/lldb/Utility/Stream.h   | 18 +++--
 lldb/source/Commands/CommandObjectTarget.cpp | 39 
 lldb/source/Core/Address.cpp | 22 +--
 lldb/source/Symbol/Symbol.cpp| 11 +++---
 lldb/source/Symbol/SymbolContext.cpp | 36 +++---
 lldb/source/Utility/Stream.cpp   | 17 -
 9 files changed, 85 insertions(+), 73 deletions(-)

diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index 725b5d9f91d3d5..f11ece414eec83 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_CORE_ADDRESS_H
 #define LLDB_CORE_ADDRESS_H
 
+#include "lldb/Utility/Stream.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"
@@ -255,7 +256,8 @@ class Address {
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
 uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
-llvm::StringRef pattern = "") const;
+std::optional pattern_info =
+std::nullopt) const;
 
   AddressClass GetAddressClass() const;
 
diff --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index e6c0b495bcf28c..0da431f5ccf5da 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -13,6 +13,7 @@
 #include "lldb/Core/Mangled.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Utility/Stream.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 #include "llvm/Support/JSON.h"
@@ -175,7 +176,8 @@ class Symbol : public SymbolContextScope {
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
-  llvm::StringRef pattern = "") const;
+  std::optional pattern_info =
+  std::nullopt) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index 26f3bac09a9626..a089e93863a75d 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -17,6 +17,7 @@
 #include "lldb/Core/Mangled.h"
 #include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/Iterable.h"
+#include "lldb/Utility/Stream.h"
 #include "lldb/lldb-private.h"
 
 namespace lldb_private {
@@ -157,7 +158,8 @@ class SymbolContext {
const Address _addr, bool show_fullpaths,
bool show_module, bool show_inlined_frames,
bool show_function_arguments, bool show_function_name,
-   llvm::StringRef pattern = "") const;
+   std::optional pattern_info =
+   std::nullopt) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -224,7 +226,8 @@ class SymbolContext {
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status );
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
-  llvm::StringRef pattern = "") const;
+  std::optional pattern_info =
+  std::nullopt) const;
 
   uint32_t GetResolvedMask() const;
 
diff --git a/lldb/include/lldb/Utility/Stream.h 
b/lldb/include/lldb/Utility/Stream.h
index 20c55ac4597ae6..f2666a749d5fa1 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -33,6 +33,17 @@ class Stream {
/// string mode.
   };
 
+  /// Struct to store information for color highlighting in the stream.
+  struct HighlightSettings {
+llvm::StringRef pattern; ///< Regex pattern for highlighting.
+llvm::StringRef prefix;  ///< ANSI color code to start colorization.
+llvm::StringRef suffix;  ///< ANSI color code to end colorization.
+
+HighlightSettings(llvm::StringRef p, llvm::StringRef pre,
+  llvm::StringRef suf)
+: pattern(p), prefix(pre), suffix(suf) {}
+  };
+
   /// Utility class for counting the bytes that were written to a stream in a
   /// certain time span.
   ///
@@ -260,10 +271,9 @@ class Stream {
   /// The ANSI color code to end colorization. This is
   

[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/78605

>From b46553c6fe17a50dc2072544e46b7a1dde127436 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Thu, 18 Jan 2024 09:09:50 -0800
Subject: [PATCH 1/5] Added settings for cache location and timeout

---
 .../Debuginfod/SymbolLocatorDebuginfod.cpp| 82 +++
 .../SymbolLocatorDebuginfodProperties.td  |  8 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h | 13 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 31 +--
 4 files changed, 108 insertions(+), 26 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp 
b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 111be6be365240..a20437c256eb43 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -9,6 +9,7 @@
 #include "SymbolLocatorDebuginfod.h"
 
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueString.h"
 #include "lldb/Utility/Args.h"
 
 #include "llvm/Debuginfod/Debuginfod.h"
@@ -54,6 +55,34 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {
+OptionValueString *s =
+m_collection_sp->GetPropertyAtIndexAsOptionValueString(
+ePropertySymbolCachePath);
+// If we don't have a valid cache location, use the default one.
+if (!s || !s->GetCurrentValueAsRef().size()) {
+  llvm::Expected maybeCachePath =
+  llvm::getDefaultDebuginfodCacheDirectory();
+  if (!maybeCachePath) {
+return maybeCachePath;
+  }
+  m_cache_path = *maybeCachePath;
+  return llvm::StringRef(m_cache_path);
+}
+return s->GetCurrentValueAsRef();
+  }
+
+  std::chrono::milliseconds GetTimeout() const {
+std::optional seconds =
+m_collection_sp->GetPropertyAtIndexAs(ePropertyTimeout);
+if (seconds && *seconds != 0) {
+  return std::chrono::duration_cast(
+  std::chrono::seconds(*seconds));
+} else {
+  return llvm::getDefaultDebuginfodTimeout();
+}
+  }
+
 private:
   void ServerURLsChangedCallback() {
 m_server_urls = GetDebugInfoDURLs();
@@ -65,6 +94,7 @@ class PluginProperties : public Properties {
   }
   // Storage for the StringRef's used within the Debuginfod library.
   Args m_server_urls;
+  std::string m_cache_path;
 };
 
 } // namespace
@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);
+  std::string CacheKey = llvm::getDebuginfodCacheKey(UrlPath);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  CacheKey, UrlPath, CacheDirectoryPath, DebuginfodUrls, Timeout);
+  if (result)
+return FileSpec(*result);
+  // An error here should be logged as a failure in the Debuginfod library,
+  // just consume it here
+  consumeError(result.takeError());
   return {};
 }
 
 std::optional SymbolLocatorDebuginfod::LocateExecutableObjectFile(
 const ModuleSpec _spec) {
-  return GetFileForModule(module_spec, llvm::getCachedOrDownloadExecutable);
+  return GetFileForModule(module_spec, 

[Lldb-commits] [lldb] [lldb] Stop creating BreakpointEventData raw pointers (PR #78508)

2024-01-18 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] da4b8ab - [lldb] Stop creating BreakpointEventData raw pointers (#78508)

2024-01-18 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-18T14:26:45-08:00
New Revision: da4b8ab7fd8e43c3456ed9881a4eb4ad9da320fa

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

LOG: [lldb] Stop creating BreakpointEventData raw pointers (#78508)

The lifetime of these BreakpointEventData objects is difficult to reason
about. These BreakpointEventData pointers are created and passed along
to `Event` which takes the raw pointer and sticks them in a shared
pointer. Instead of manually managing the lifetime and memory, it would
be simpler to have them be shared pointers from the start.

Added: 


Modified: 
lldb/include/lldb/Breakpoint/Breakpoint.h
lldb/source/Breakpoint/Breakpoint.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index 3a8b29aee544c6..8c4308ab0bc12d 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -672,7 +672,7 @@ class Breakpoint : public 
std::enable_shared_from_this,
 
   void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind);
 
-  void SendBreakpointChangedEvent(BreakpointEventData *data);
+  void SendBreakpointChangedEvent(const lldb::EventDataSP _data_sp);
 
   Breakpoint(const Breakpoint &) = delete;
   const Breakpoint =(const Breakpoint &) = delete;

diff  --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 6e6b51b562496c..af5dcc9cd88d4f 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -460,17 +460,13 @@ void Breakpoint::ResolveBreakpointInModules(ModuleList 
_list,
 // If this is not an internal breakpoint, set up to record the new
 // locations, then dispatch an event with the new locations.
 if (!IsInternal() && send_event) {
-  BreakpointEventData *new_locations_event = new BreakpointEventData(
-  eBreakpointEventTypeLocationsAdded, shared_from_this());
-
+  std::shared_ptr new_locations_event =
+  std::make_shared(
+  eBreakpointEventTypeLocationsAdded, shared_from_this());
   ResolveBreakpointInModules(
   module_list, new_locations_event->GetBreakpointLocationCollection());
-
-  if (new_locations_event->GetBreakpointLocationCollection().GetSize() !=
-  0) {
+  if (new_locations_event->GetBreakpointLocationCollection().GetSize() != 
0)
 SendBreakpointChangedEvent(new_locations_event);
-  } else
-delete new_locations_event;
 } else {
   ElapsedTime elapsed(m_resolve_time);
   m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
@@ -565,12 +561,10 @@ void Breakpoint::ModulesChanged(ModuleList _list, 
bool load,
 // the module list, then remove their breakpoint sites, and their locations
 // if asked to.
 
-BreakpointEventData *removed_locations_event;
+std::shared_ptr removed_locations_event;
 if (!IsInternal())
-  removed_locations_event = new BreakpointEventData(
+  removed_locations_event = std::make_shared(
   eBreakpointEventTypeLocationsRemoved, shared_from_this());
-else
-  removed_locations_event = nullptr;
 
 for (ModuleSP module_sp : module_list.Modules()) {
   if (m_filter_sp->ModulePasses(module_sp)) {
@@ -795,31 +789,30 @@ void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
 // about telling the world about removing a location we didn't tell them
 // about adding.
 
-BreakpointEventData *locations_event;
+std::shared_ptr removed_locations_event;
 if (!IsInternal())
-  locations_event = new BreakpointEventData(
+  removed_locations_event = std::make_shared(
   eBreakpointEventTypeLocationsRemoved, shared_from_this());
-else
-  locations_event = nullptr;
 
 for (BreakpointLocationSP loc_sp :
  locations_to_remove.BreakpointLocations()) {
   m_locations.RemoveLocation(loc_sp);
-  if (locations_event)
-locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+  if (removed_locations_event)
+removed_locations_event->GetBreakpointLocationCollection().Add(loc_sp);
 }
-SendBreakpointChangedEvent(locations_event);
+SendBreakpointChangedEvent(removed_locations_event);
 
 // And announce the new ones.
 
 if (!IsInternal()) {
-  locations_event = new BreakpointEventData(
-  eBreakpointEventTypeLocationsAdded, shared_from_this());
+  std::shared_ptr added_locations_event =
+  std::make_shared(
+  eBreakpointEventTypeLocationsAdded, shared_from_this());
   for (BreakpointLocationSP loc_sp :
locations_to_announce.BreakpointLocations())
-

[Lldb-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [clang-tools-extra] [flang] [libc] [lld] [llvm] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/76449
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang-tools-extra] [openmp] [llvm] [lld] [compiler-rt] [mlir] [libc] [flang] [clang] [libcxx] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/76449
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [clang-tools-extra] [flang] [libc] [lld] [llvm] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/76449
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [clang-tools-extra] [flang] [libc] [lld] [llvm] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/76449
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [clang-tools-extra] [flang] [libc] [lld] [llvm] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits


@@ -144,7 +144,8 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) 
__visit_format_arg(_Visitor&& __vis, basic_
   __libcpp_unreachable();
 }
 
-#  if _LIBCPP_STD_VER >= 26
+#  if _LIBCPP_STD_VER >= 26 && (!defined(_LIBCPP_COMPILER_CLANG_BASED) || 
_LIBCPP_CLANG_VER >= 1800)

H-G-Hristov wrote:

Maybe something like:

```c++
#  if _LIBCPP_STD_VER >= 26 && (defined(__cpp_explicit_this_parameter) || 
!defined(_LIBCPP_COMPILER_CLANG_BASED) || _LIBCPP_CLANG_VER >= 1800)
...
#endif
```
or 

```c++
#if defined(__cpp_explicit_this_parameter) || 
!defined(_LIBCPP_COMPILER_CLANG_BASED) || _LIBCPP_CLANG_VER >= 1800
#define _LIBCPP_EXPLICIT_THIS_PARAMETER
#endif
```

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


[Lldb-commits] [lldb] [llvm] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits


@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);
+  std::string CacheKey = llvm::getDebuginfodCacheKey(UrlPath);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  CacheKey, UrlPath, CacheDirectoryPath, DebuginfodUrls, Timeout);
+  if (result)
+return FileSpec(*result);
+  // An error here should be logged as a failure in the Debuginfod library,
+  // just consume it here
+  consumeError(result.takeError());

kevinfrei wrote:

LLDB_LOGV (LLDBLog::Symbols context) seems like the right choice, given how 
noisy it will be.

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


[Lldb-commits] [lldb] [llvm] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits


@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need

kevinfrei wrote:

Modified to describe the 'interesting part'.

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


[Lldb-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [clang-tools-extra] [flang] [libc] [lld] [llvm] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits

https://github.com/H-G-Hristov deleted 
https://github.com/llvm/llvm-project/pull/76449
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang-tools-extra] [flang] [clang] [libcxx] [mlir] [llvm] [openmp] [libc] [lldb] [BOLT] Use continuous output addresses in delta encoding in BAT (PR #76904)

2024-01-18 Thread Amir Ayupov via lldb-commits

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


[Lldb-commits] [clang-tools-extra] [flang] [clang] [libcxx] [mlir] [llvm] [openmp] [libc] [lldb] [BOLT] Use continuous output addresses in delta encoding in BAT (PR #76904)

2024-01-18 Thread Amir Ayupov via lldb-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/76904

>From 2027bc7dc00395884c3bd4da21bbb79d079293fc Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Wed, 3 Jan 2024 21:25:27 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 bolt/docs/BAT.md  |  91 
 .../bolt/Profile/BoltAddressTranslation.h |  14 +-
 bolt/lib/Profile/BoltAddressTranslation.cpp   | 138 ++
 bolt/lib/Rewrite/RewriteInstance.cpp  |   1 +
 bolt/test/X86/bolt-address-translation.test   |   2 +-
 5 files changed, 180 insertions(+), 66 deletions(-)
 create mode 100644 bolt/docs/BAT.md

diff --git a/bolt/docs/BAT.md b/bolt/docs/BAT.md
new file mode 100644
index 00..5a257a46955607
--- /dev/null
+++ b/bolt/docs/BAT.md
@@ -0,0 +1,91 @@
+# BOLT Address Translation (BAT)
+# Purpose
+A regular profile collection for BOLT involves collecting samples from
+unoptimized binary. BOLT Address Translation allows collecting profile
+from BOLT-optimized binary and using it for optimizing the input (pre-BOLT)
+binary.
+
+# Overview
+BOLT Address Translation is an extra section (`.note.bolt_bat`) inserted by 
BOLT
+into the output binary containing translation tables and split functions 
linkage
+information. This information enables mapping the profile back from optimized
+binary onto the original binary.
+
+# Usage
+`--enable-bat` flag controls the generation of BAT section. Sampled profile 
+needs to be passed along with the optimized binary containing BAT section to
+`perf2bolt` which reads BAT section and produces fdata profile for the original
+binary. Note that YAML profile generation is not supported since BAT doesn't
+contain the metadata for input functions.
+
+# Internals
+## Section contents
+The section is organized as follows:
+- Hot functions table
+  - Address translation tables
+- Cold functions table
+
+## Construction and parsing
+BAT section is created from `BoltAddressTranslation` class which captures
+address translation information provided by BOLT linker. It is then encoded as 
a
+note section in the output binary.
+
+During profile conversion when BAT-enabled binary is passed to perf2bolt, 
+`BoltAddressTranslation` class is populated from BAT section. The class is then
+queried by `DataAggregator` during sample processing to reconstruct addresses/
+offsets in the input binary.
+
+## Encoding format
+The encoding is specified in bolt/include/bolt/Profile/BoltAddressTranslation.h
+and bolt/lib/Profile/BoltAddressTranslation.cpp.
+
+### Layout
+The general layout is as follows:
+```
+Hot functions table header
+|--|
+|  Function entry  |
+| |--| |
+| | OutOff InOff | |
+| |--| |
+
+
+Cold functions table header
+|--|
+|  Function entry  |
+| |--| |
+| | OutOff InOff | |
+| |--| |
+
+```
+
+### Functions table
+Hot and cold functions tables share the encoding except difference marked 
below.
+Header:
+| Entry  | Encoding | Description |
+| -- | - | --- |
+| `NumFuncs` | ULEB128 | Number of functions in the functions table |
+
+The header is followed by Functions table with `NumFuncs` entries.
+Output binary addresses are delta encoded, meaning that only the difference 
with
+the previous output address is stored. Addresses implicitly start at zero.
+Hot indices are delta encoded, implicitly starting at zero.
+| Entry  | Encoding | Description |
+| -- | --| --- |
+| `Address` | Delta, ULEB128 | Function address in the output binary |
+| `HotIndex` | Delta, ULEB128 | Cold functions only: index of corresponding 
hot function in hot functions table |
+| `NumEntries` | ULEB128 | Number of address translation entries for a 
function |
+Function header is followed by `NumEntries` pairs of offsets for current
+function.
+
+### Address translation table
+Delta encoding means that only the difference with the previous corresponding
+entry is encoded. Offsets implicitly start at zero.
+| Entry  | Encoding | Description |
+| -- | --| --- |
+| `OutputAddr` | Delta, ULEB128 | Function offset in output binary |
+| `InputAddr` | Delta, SLEB128 | Function offset in input binary with 
`BRANCHENTRY` LSB bit |
+
+`BRANCHENTRY` bit denotes whether a given offset pair is a control flow source
+(branch or call instruction). If not set, it signifies a control flow target
+(basic block offset).
diff --git a/bolt/include/bolt/Profile/BoltAddressTranslation.h 
b/bolt/include/bolt/Profile/BoltAddressTranslation.h
index 07e4b283211c69..feeda2ca1871be 100644
--- a/bolt/include/bolt/Profile/BoltAddressTranslation.h
+++ b/bolt/include/bolt/Profile/BoltAddressTranslation.h

[Lldb-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [clang-tools-extra] [flang] [libc] [llvm] [BOLT] Use continuous output addresses in delta encoding in BAT (PR #76904)

2024-01-18 Thread Amir Ayupov via lldb-commits

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


[Lldb-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [clang-tools-extra] [flang] [libc] [lld] [llvm] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits


@@ -24,14 +24,17 @@ void test(From value) {
   auto store = std::make_format_args(value);
   const std::basic_format_args format_args{store};
 
-  std::visit_format_arg(
-  [v = To(value)](auto a) {
-if constexpr (std::is_same_v)
-  assert(v == a);
-else
-  assert(false);
-  },
-  format_args.get(0));
+  auto visitor = [v = To(value)](auto a) {
+if constexpr (std::is_same_v)
+  assert(v == a);
+else
+  assert(false);
+  };
+#if _LIBCPP_STD_VER >= 26 && (!defined(TEST_COMPILER_CLANG) || TEST_CLANG_VER 
>= 1800)

H-G-Hristov wrote:

N.B. `TEST_CLANG_VER` is not defined for Apple Clang ???

```c++
#if defined(__apple_build_version__)
// Given AppleClang XX.Y.Z, TEST_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 
14.0.3 => 1403)
#define TEST_APPLE_CLANG_VER (__apple_build_version__ / 1)
#elif defined(__clang_major__)
#define TEST_CLANG_VER (__clang_major__ * 100) + __clang_minor__
#elif defined(__GNUC__)
// Given GCC XX.YY.ZZ, TEST_GCC_VER is XXYYZZ
#define TEST_GCC_VER ((__GNUC__ * 1) + (__GNUC_MINOR__ * 100) + 
__GNUC_PATCHLEVEL__)
#endif
```

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


[Lldb-commits] [clang] [lldb] [libcxx] [compiler-rt] [clang-tools-extra] [libunwind] [libcxxabi] [flang] [libc] [llvm] [libc++][span] P2447R4: `std::span` over an initializer list (PR #78157)

2024-01-18 Thread Hristo Hristov via lldb-commits

H-G-Hristov wrote:

> > Thanks. The documentation build fails due to some CMake error consistently 
> > otherwise I believe I addressed all comments.
> > I think I fixed this a few days ago.
> 
> LGTM modulo 1 nit.

Thanx!

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


[Lldb-commits] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [clang-tools-extra] [flang] [libc] [lld] [llvm] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits

H-G-Hristov wrote:

Thank you for the review!

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


[Lldb-commits] [libc] [clang-tools-extra] [libcxx] [lldb] [flang] [clang] [mlir] [llvm] [libc++][memory] P2868R1: Removing deprecated typedef `std::allocator::is_always_equal` (PR #78562)

2024-01-18 Thread Hristo Hristov via lldb-commits

H-G-Hristov wrote:

Thank you for the review!

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


[Lldb-commits] [flang] [clang] [lldb] [lld] [clang-tools-extra] [mlir] [libc] [compiler-rt] [llvm] [libcxx] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Hristo Hristov via lldb-commits


@@ -144,7 +144,8 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) 
__visit_format_arg(_Visitor&& __vis, basic_
   __libcpp_unreachable();
 }
 
-#  if _LIBCPP_STD_VER >= 26
+#  if _LIBCPP_STD_VER >= 26 && (!defined(_LIBCPP_COMPILER_CLANG_BASED) || 
_LIBCPP_CLANG_VER >= 1800)

H-G-Hristov wrote:

https://clang.llvm.org/docs/ReleaseNotes.html

> Implemented P0847R7: Deducing this. Some related core issues were also 
> implemented (CWG2553, CWG2554, CWG2653, CWG2687). Because the support for 
> this feature is still experimental, the feature test macro 
> __cpp_explicit_this_parameter was not set in this version.

I'll revert the change.

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


[Lldb-commits] [lldb] [llvm] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Jonas Devlieghere via lldb-commits


@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);

JDevlieghere wrote:

Yeah, LLDB diverges from LLVM's coding style in this: 
https://lldb.llvm.org/resources/contributing.html#coding-style. it should use 
snake_case everywhere. 

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


[Lldb-commits] [lldb] [llvm] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits


@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);
+  std::string CacheKey = llvm::getDebuginfodCacheKey(UrlPath);

kevinfrei wrote:

ditto from above.

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


[Lldb-commits] [lldb] [llvm] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits


@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec _spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec _spec,
+std::function UrlBuilder) {
   const UUID _uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties _props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);

kevinfrei wrote:

What's the style guidance for locals? The locals above this are filled with 
PascalCaseOrErr everywhere. I'm happy to change the entire function, but right 
now it's really inconsistent (and kinda ugly). I'd like to make it consistent, 
either snake or pascal, based on your guidance, here. Should I just snake them 
all (cache_directory_path_or_err?) or Pascal them all (BuildId), or is there 
some rule I'm missing that makes the mixture sensible?

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


[Lldb-commits] [lldb] [llvm] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-18 Thread Kevin Frei via lldb-commits


@@ -54,6 +55,34 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {

kevinfrei wrote:

String storage lives 40 lines lower (line 97) because, yeah, this bit me. The 
Debuginfod library takes a StringRef, and I found this was the most consistent 
way to deal with it. If you'd prefer me to switch this and cons up a StringRef 
before the API, I'm okay with that (just let me know in here)

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


[Lldb-commits] [libunwind] [clang-tools-extra] [libc] [flang] [llvm] [lld] [libcxx] [clang] [compiler-rt] [lldb] [libcxxabi] Fix a bug in Smith's algorithm used in complex div. (PR #78330)

2024-01-18 Thread John McCall via lldb-commits

rjmccall wrote:

If LLVM wants to provide intrinsics that cover patterns that the frontend wants 
to emit, that'd be great.  The frontend will still have to make decisions about 
e.g. whether to request Smith's algorithm, of course.

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


[Lldb-commits] [lldb] [lldb] Remove redundant severity substring within a diagnostic message. (PR #76111)

2024-01-18 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] c82b7fd - [lldb] Remove redundant severity substring within a diagnostic message. (#76111)

2024-01-18 Thread via lldb-commits

Author: Pete Lawrence
Date: 2024-01-18T12:04:26-08:00
New Revision: c82b7fddfcbd6adfae4faf324a453fb8652efa91

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

LOG: [lldb] Remove redundant severity substring within a diagnostic message. 
(#76111)

For example, the following message has the severity string "error: "
twice.
> "error: :3:1: error: cannot find 'bogus' in scope

This method already appends the severity string in the beginning, but
with this fix, it also removes a secondary instance, if applicable.

Note that this change only removes the *first* redundant substring. I
considered putting the removal logic in a loop, but I decided that if
something is generating more than one redundant severity substring, then
that's a problem the message's source should probably fix.

rdar://114203423

Added: 


Modified: 
lldb/source/Expression/DiagnosticManager.cpp
lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py

Removed: 




diff  --git a/lldb/source/Expression/DiagnosticManager.cpp 
b/lldb/source/Expression/DiagnosticManager.cpp
index 08977066e3330a..9a1100df78db2b 100644
--- a/lldb/source/Expression/DiagnosticManager.cpp
+++ b/lldb/source/Expression/DiagnosticManager.cpp
@@ -46,11 +46,20 @@ static const char *StringForSeverity(DiagnosticSeverity 
severity) {
 
 std::string DiagnosticManager::GetString(char separator) {
   std::string ret;
+  llvm::raw_string_ostream stream(ret);
 
   for (const auto  : Diagnostics()) {
-ret.append(StringForSeverity(diagnostic->GetSeverity()));
-ret.append(std::string(diagnostic->GetMessage()));
-ret.push_back(separator);
+llvm::StringRef severity = StringForSeverity(diagnostic->GetSeverity());
+stream << severity;
+
+llvm::StringRef message = diagnostic->GetMessage();
+std::string searchable_message = message.lower();
+auto severity_pos = message.find(severity);
+stream << message.take_front(severity_pos);
+
+if (severity_pos != llvm::StringRef::npos)
+  stream << message.drop_front(severity_pos + severity.size());
+stream << separator;
   }
 
   return ret;

diff  --git 
a/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py 
b/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
index 36e302be2525b5..620b6e44fc852a 100644
--- a/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
+++ b/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
@@ -21,7 +21,7 @@ def test(self):
 "expr @import LLDBTestModule",
 error=True,
 substrs=[
-"module.h:4:1: error: use of undeclared identifier 
'syntax_error_for_lldb_to_find'",
+"module.h:4:1: use of undeclared identifier 
'syntax_error_for_lldb_to_find'",
 "syntax_error_for_lldb_to_find // comment that tests source 
printing",
 "could not build module 'LLDBTestModule'",
 ],



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


[Lldb-commits] [openmp] [clang-tools-extra] [libc] [flang] [llvm] [libcxx] [clang] [mlir] [lldb] [BOLT] Use continuous output addresses in delta encoding in BAT (PR #76904)

2024-01-18 Thread Amir Ayupov via lldb-commits

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


[Lldb-commits] [lld] [libcxx] [lldb] [flang] [llvm] [libc] [clang] [compiler-rt] [mlir] [clang-tools-extra] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -144,7 +144,8 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) 
__visit_format_arg(_Visitor&& __vis, basic_
   __libcpp_unreachable();
 }
 
-#  if _LIBCPP_STD_VER >= 26
+#  if _LIBCPP_STD_VER >= 26 && (!defined(_LIBCPP_COMPILER_CLANG_BASED) || 
_LIBCPP_CLANG_VER >= 1800)

mordante wrote:

Actually let's make this more portable. This macro is introduced by 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0847r7.html
```suggestion
#  if _LIBCPP_STD_VER >= 26 && defined(__cpp_explicit_this_parameter)
```

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


[Lldb-commits] [libcxx] [compiler-rt] [clang-tools-extra] [flang] [llvm] [lldb] [lld] [libc] [mlir] [clang] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -0,0 +1,36 @@
+//===--===//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME

mordante wrote:

disable this for clang-16 and clang-17. 

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


[Lldb-commits] [lld] [libc] [llvm] [libcxx] [clang-tools-extra] [lldb] [clang] [mlir] [compiler-rt] [flang] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -267,7 +366,8 @@ class _LIBCPP_TEMPLATE_VIS 
basic_format_arg<_Context>::handle {
 // This function is user facing, so it must wrap the non-standard types of
 // the "variant" in a handle to stay conforming. See __arg_t for more details.
 template 
-_LIBCPP_HIDE_FROM_ABI decltype(auto) visit_format_arg(_Visitor&& __vis, 
basic_format_arg<_Context> __arg) {
+_LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_HIDE_FROM_ABI decltype(auto)

mordante wrote:

let's not show a deprecated message when the replacement can't be used by the 
user's compiler.
```suggestion
#ifdef __cpp_explicit_this_parameter
_LIBCPP_DEPRECATED_IN_CXX26 
#endif
_LIBCPP_HIDE_FROM_ABI decltype(auto)
```

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


[Lldb-commits] [libcxx] [clang-tools-extra] [mlir] [clang] [libc] [llvm] [flang] [lld] [compiler-rt] [lldb] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -19,19 +19,25 @@
 #include "test_macros.h"
 #include "make_string.h"
 
+#if _LIBCPP_STD_VER >= 26
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+#endif
+
 template 
 void test(From value) {
   auto store = std::make_format_args(value);
   const std::basic_format_args format_args{store};
 
-  std::visit_format_arg(
-  [v = To(value)](auto a) {
-if constexpr (std::is_same_v)
-  assert(v == a);
-else
-  assert(false);
-  },
-  format_args.get(0));
+  auto visitor = [v = To(value)](auto a) {
+if constexpr (std::is_same_v)
+  assert(v == a);
+else
+  assert(false);
+  };
+#if _LIBCPP_STD_VER >= 26
+  format_args.get(0).visit(visitor);
+#endif
+  std::visit_format_arg(visitor, format_args.get(0));

mordante wrote:

If we put this in an `#else` we don't need to disable deprecated warnings right?
This function tests `get` so we don't need to add coverage for the visitor.

This means the code looks like what you did in 
libcxx/test/support/test_basic_format_arg.h

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


[Lldb-commits] [llvm] [clang-tools-extra] [compiler-rt] [libcxx] [clang] [flang] [libc] [mlir] [lldb] [lld] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -7,6 +7,7 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
+// XFAIL: clang-16 || clang-17

mordante wrote:

We know it fails so there is no real need to test that.
Quite often we do XFAIL when we want to update tests when they suddenly start 
to work.
```suggestion
// The tested functionality needs deducing this.
// UNSUPPORTED: clang-16 || clang-17
```

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


[Lldb-commits] [flang] [mlir] [clang-tools-extra] [llvm] [clang] [libc] [lld] [lldb] [compiler-rt] [libcxx] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -163,20 +163,26 @@ class _LIBCPP_TEMPLATE_VIS basic_format_context basic_format_arg {
-if constexpr (same_as)
-  return {};
-else if constexpr (same_as::handle>)
-  // At the moment it's not possible for formatting to use a 
re-targeted handle.
-  // TODO FMT add this when support is needed.
-  std::__throw_format_error("Re-targeting handle not 
supported");
-else
-  return basic_format_arg{
-  __format::__determine_arg_t(),
-  __basic_format_arg_value(__arg)};
-  },
-  static_cast<_Context*>(__c)->arg(__id));
+  auto __visitor = [&](auto __arg) -> 
basic_format_arg {
+if constexpr (same_as)
+  return {};
+else if constexpr (same_as::handle>)
+  // At the moment it's not possible for formatting to use a 
re-targeted handle.
+  // TODO FMT add this when support is needed.
+  std::__throw_format_error("Re-targeting handle not supported");
+else
+  return basic_format_arg{
+  __format::__determine_arg_t(),
+  __basic_format_arg_value(__arg)};
+  };
+#  if _LIBCPP_STD_VER >= 26 && (!defined(_LIBCPP_COMPILER_CLANG_BASED) || 
_LIBCPP_CLANG_VER >= 1800)
+  return 
static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor));
+#  else
+  _LIBCPP_DIAGNOSTIC_PUSH
+  _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")

mordante wrote:

```suggestion
  _LIBCPP_SUPPRESS_DEPRECATED_PUSH
```

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


[Lldb-commits] [flang] [mlir] [libcxx] [clang] [clang-tools-extra] [llvm] [libc] [compiler-rt] [lld] [lldb] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -193,7 +194,8 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& 
__vis, basic_format_arg<
 
   __libcpp_unreachable();
 }
-#  endif
+
+#  endif // if _LIBCPP_STD_VER >= 26

mordante wrote:

```suggestion
#  endif // if _LIBCPP_STD_VER >= 26  && defined(__cpp_explicit_this_parameter)
```

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


[Lldb-commits] [compiler-rt] [lldb] [libc] [clang-tools-extra] [mlir] [llvm] [clang] [flang] [lld] [libcxx] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -19,19 +19,25 @@
 #include "test_macros.h"
 #include "make_string.h"
 
+#if _LIBCPP_STD_VER >= 26
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+#endif
+
 template 
 void test(From value) {
   auto store = std::make_format_args(value);
   const std::basic_format_args format_args{store};
 
-  std::visit_format_arg(
-  [v = To(value)](auto a) {
-if constexpr (std::is_same_v)
-  assert(v == a);
-else
-  assert(false);
-  },
-  format_args.get(0));
+  auto visitor = [v = To(value)](auto a) {
+if constexpr (std::is_same_v)
+  assert(v == a);
+else
+  assert(false);
+  };
+#if _LIBCPP_STD_VER >= 26

mordante wrote:

This needs to test for the FTM too.

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


[Lldb-commits] [clang-tools-extra] [llvm] [compiler-rt] [mlir] [clang] [libc] [flang] [libcxx] [lldb] [lld] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits


@@ -163,20 +163,26 @@ class _LIBCPP_TEMPLATE_VIS basic_format_context basic_format_arg {
-if constexpr (same_as)
-  return {};
-else if constexpr (same_as::handle>)
-  // At the moment it's not possible for formatting to use a 
re-targeted handle.
-  // TODO FMT add this when support is needed.
-  std::__throw_format_error("Re-targeting handle not 
supported");
-else
-  return basic_format_arg{
-  __format::__determine_arg_t(),
-  __basic_format_arg_value(__arg)};
-  },
-  static_cast<_Context*>(__c)->arg(__id));
+  auto __visitor = [&](auto __arg) -> 
basic_format_arg {
+if constexpr (same_as)
+  return {};
+else if constexpr (same_as::handle>)
+  // At the moment it's not possible for formatting to use a 
re-targeted handle.
+  // TODO FMT add this when support is needed.
+  std::__throw_format_error("Re-targeting handle not supported");
+else
+  return basic_format_arg{
+  __format::__determine_arg_t(),
+  __basic_format_arg_value(__arg)};
+  };
+#  if _LIBCPP_STD_VER >= 26 && (!defined(_LIBCPP_COMPILER_CLANG_BASED) || 
_LIBCPP_CLANG_VER >= 1800)
+  return 
static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor));
+#  else
+  _LIBCPP_DIAGNOSTIC_PUSH
+  _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+  return std::visit_format_arg(std::move(__visitor), 
static_cast<_Context*>(__c)->arg(__id));
+  _LIBCPP_DIAGNOSTIC_POP

mordante wrote:

```suggestion
  _LIBCPP_SUPPRESS_DEPRECATED_POP
```

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


[Lldb-commits] [mlir] [lldb] [libc] [clang] [flang] [compiler-rt] [clang-tools-extra] [lld] [llvm] [libcxx] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-18 Thread Mark de Wever via lldb-commits

https://github.com/mordante requested changes to this pull request.

In general this looks good. I'd like to have another look after addressing the 
comments.

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


  1   2   >