[Lldb-commits] [lldb] [lldb] Small cleanup of ProcessEventData::ShouldStop (PR #98154)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -4194,8 +4188,7 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   // is, and it's better to let the user decide than continue behind their
   // backs.
 
-  for (idx = 0; idx < not_suspended_thread_list.GetSize(); ++idx) {
-curr_thread_list = process_sp->GetThreadList();

labath wrote:

curr_thread_list is a reference to the process's thread list, which made this a 
self-assignment.

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


[Lldb-commits] [lldb] [lldb] Small cleanup of ProcessEventData::ShouldStop (PR #98154)

2024-07-09 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/98154

>From 27d419b047d0c2e95978b8c88dd84641aae423f2 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 9 Jul 2024 15:00:05 +0200
Subject: [PATCH] [lldb] Small cleanup of ProcessEventData::ShouldStop

While looking at a TSAN report (patch coming soon) in the ThreadList
class, I noticed that this code would be simpler if it did not use the
ThreadList class.
---
 lldb/source/Target/Process.cpp | 32 +++-
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6fac0df1d7a66..dc7f6c9e86a47 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4152,7 +4152,6 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 
   ThreadList _thread_list = process_sp->GetThreadList();
   uint32_t num_threads = curr_thread_list.GetSize();
-  uint32_t idx;
 
   // The actions might change one of the thread's stop_info's opinions about
   // whether we should stop the process, so we need to query that as we go.
@@ -4162,23 +4161,18 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   // get that wrong (which is possible) then the thread list might have
   // changed, and that would cause our iteration here to crash.  We could
   // make a copy of the thread list, but we'd really like to also know if it
-  // has changed at all, so we make up a vector of the thread ID's and check
-  // what we get back against this list & bag out if anything differs.
-  ThreadList not_suspended_thread_list(process_sp.get());
-  std::vector thread_index_array(num_threads);
-  uint32_t not_suspended_idx = 0;
-  for (idx = 0; idx < num_threads; ++idx) {
+  // has changed at all, so we store the original thread ID's of all threads 
and
+  // check what we get back against this list & bag out if anything differs.
+  std::vector> not_suspended_threads;
+  for (uint32_t idx = 0; idx < num_threads; ++idx) {
 lldb::ThreadSP thread_sp = curr_thread_list.GetThreadAtIndex(idx);
 
 /*
  Filter out all suspended threads, they could not be the reason
  of stop and no need to perform any actions on them.
  */
-if (thread_sp->GetResumeState() != eStateSuspended) {
-  not_suspended_thread_list.AddThread(thread_sp);
-  thread_index_array[not_suspended_idx] = thread_sp->GetIndexID();
-  not_suspended_idx++;
-}
+if (thread_sp->GetResumeState() != eStateSuspended)
+  not_suspended_threads.emplace_back(thread_sp, thread_sp->GetIndexID());
   }
 
   // Use this to track whether we should continue from here.  We will only
@@ -4194,8 +4188,7 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   // is, and it's better to let the user decide than continue behind their
   // backs.
 
-  for (idx = 0; idx < not_suspended_thread_list.GetSize(); ++idx) {
-curr_thread_list = process_sp->GetThreadList();
+  for (auto [thread_sp, thread_index] : not_suspended_threads) {
 if (curr_thread_list.GetSize() != num_threads) {
   Log *log(GetLog(LLDBLog::Step | LLDBLog::Process));
   LLDB_LOGF(
@@ -4205,14 +4198,11 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   break;
 }
 
-lldb::ThreadSP thread_sp = not_suspended_thread_list.GetThreadAtIndex(idx);
-
-if (thread_sp->GetIndexID() != thread_index_array[idx]) {
+if (thread_sp->GetIndexID() != thread_index) {
   Log *log(GetLog(LLDBLog::Step | LLDBLog::Process));
-  LLDB_LOGF(log,
-"The thread at position %u changed from %u to %u while "
-"processing event.",
-idx, thread_index_array[idx], thread_sp->GetIndexID());
+  LLDB_LOG(log,
+   "The thread {0} changed from {1} to {2} while processing 
event.",
+   thread_sp.get(), thread_index, thread_sp->GetIndexID());
   break;
 }
 

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Pavel Labath via lldb-commits

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

Thank you.

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


[Lldb-commits] [lldb] [lldb] Small cleanup of ProcessEventData::ShouldStop (PR #98154)

2024-07-09 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 9856af634db8bf550893606ba42c56d4dff3f320 
2e74468a99015645f1abbfdf42f6e5c9893e7cf3 -- lldb/source/Target/Process.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 085e3f502e..f1140a2f12 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4188,7 +4188,7 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   // is, and it's better to let the user decide than continue behind their
   // backs.
 
-  for(auto [thread_sp, thread_index] : not_suspended_threads) {
+  for (auto [thread_sp, thread_index] : not_suspended_threads) {
 curr_thread_list = process_sp->GetThreadList();
 if (curr_thread_list.GetSize() != num_threads) {
   Log *log(GetLog(LLDBLog::Step | LLDBLog::Process));

``




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


[Lldb-commits] [lldb] [lldb] Small cleanup of ProcessEventData::ShouldStop (PR #98154)

2024-07-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

While looking at a TSAN report (patch coming soon) in the ThreadList class, I 
noticed that this code would be simpler if it did not use the ThreadList class.

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


1 Files Affected:

- (modified) lldb/source/Target/Process.cpp (+11-20) 


``diff
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6fac0df1d7a66..085e3f502e093 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4152,7 +4152,6 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 
   ThreadList _thread_list = process_sp->GetThreadList();
   uint32_t num_threads = curr_thread_list.GetSize();
-  uint32_t idx;
 
   // The actions might change one of the thread's stop_info's opinions about
   // whether we should stop the process, so we need to query that as we go.
@@ -4162,23 +4161,18 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   // get that wrong (which is possible) then the thread list might have
   // changed, and that would cause our iteration here to crash.  We could
   // make a copy of the thread list, but we'd really like to also know if it
-  // has changed at all, so we make up a vector of the thread ID's and check
-  // what we get back against this list & bag out if anything differs.
-  ThreadList not_suspended_thread_list(process_sp.get());
-  std::vector thread_index_array(num_threads);
-  uint32_t not_suspended_idx = 0;
-  for (idx = 0; idx < num_threads; ++idx) {
+  // has changed at all, so we store the original thread ID's of all threads 
and
+  // check what we get back against this list & bag out if anything differs.
+  std::vector> not_suspended_threads;
+  for (uint32_t idx = 0; idx < num_threads; ++idx) {
 lldb::ThreadSP thread_sp = curr_thread_list.GetThreadAtIndex(idx);
 
 /*
  Filter out all suspended threads, they could not be the reason
  of stop and no need to perform any actions on them.
  */
-if (thread_sp->GetResumeState() != eStateSuspended) {
-  not_suspended_thread_list.AddThread(thread_sp);
-  thread_index_array[not_suspended_idx] = thread_sp->GetIndexID();
-  not_suspended_idx++;
-}
+if (thread_sp->GetResumeState() != eStateSuspended)
+  not_suspended_threads.emplace_back(thread_sp, thread_sp->GetIndexID());
   }
 
   // Use this to track whether we should continue from here.  We will only
@@ -4194,7 +4188,7 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   // is, and it's better to let the user decide than continue behind their
   // backs.
 
-  for (idx = 0; idx < not_suspended_thread_list.GetSize(); ++idx) {
+  for(auto [thread_sp, thread_index] : not_suspended_threads) {
 curr_thread_list = process_sp->GetThreadList();
 if (curr_thread_list.GetSize() != num_threads) {
   Log *log(GetLog(LLDBLog::Step | LLDBLog::Process));
@@ -4205,14 +4199,11 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   break;
 }
 
-lldb::ThreadSP thread_sp = not_suspended_thread_list.GetThreadAtIndex(idx);
-
-if (thread_sp->GetIndexID() != thread_index_array[idx]) {
+if (thread_sp->GetIndexID() != thread_index) {
   Log *log(GetLog(LLDBLog::Step | LLDBLog::Process));
-  LLDB_LOGF(log,
-"The thread at position %u changed from %u to %u while "
-"processing event.",
-idx, thread_index_array[idx], thread_sp->GetIndexID());
+  LLDB_LOG(log,
+   "The thread {0} changed from {1} to {2} while processing 
event.",
+   thread_sp.get(), thread_index, thread_sp->GetIndexID());
   break;
 }
 

``




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


[Lldb-commits] [lldb] [lldb] Small cleanup of ProcessEventData::ShouldStop (PR #98154)

2024-07-09 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/98154

While looking at a TSAN report (patch coming soon) in the ThreadList class, I 
noticed that this code would be simpler if it did not use the ThreadList class.

>From 2e74468a99015645f1abbfdf42f6e5c9893e7cf3 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 9 Jul 2024 15:00:05 +0200
Subject: [PATCH] [lldb] Small cleanup of ProcessEventData::ShouldStop

While looking at a TSAN report (patch coming soon) in the ThreadList
class, I noticed that this code would be simpler if it did not use the
ThreadList class.
---
 lldb/source/Target/Process.cpp | 31 +++
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6fac0df1d7a66..085e3f502e093 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4152,7 +4152,6 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
 
   ThreadList _thread_list = process_sp->GetThreadList();
   uint32_t num_threads = curr_thread_list.GetSize();
-  uint32_t idx;
 
   // The actions might change one of the thread's stop_info's opinions about
   // whether we should stop the process, so we need to query that as we go.
@@ -4162,23 +4161,18 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   // get that wrong (which is possible) then the thread list might have
   // changed, and that would cause our iteration here to crash.  We could
   // make a copy of the thread list, but we'd really like to also know if it
-  // has changed at all, so we make up a vector of the thread ID's and check
-  // what we get back against this list & bag out if anything differs.
-  ThreadList not_suspended_thread_list(process_sp.get());
-  std::vector thread_index_array(num_threads);
-  uint32_t not_suspended_idx = 0;
-  for (idx = 0; idx < num_threads; ++idx) {
+  // has changed at all, so we store the original thread ID's of all threads 
and
+  // check what we get back against this list & bag out if anything differs.
+  std::vector> not_suspended_threads;
+  for (uint32_t idx = 0; idx < num_threads; ++idx) {
 lldb::ThreadSP thread_sp = curr_thread_list.GetThreadAtIndex(idx);
 
 /*
  Filter out all suspended threads, they could not be the reason
  of stop and no need to perform any actions on them.
  */
-if (thread_sp->GetResumeState() != eStateSuspended) {
-  not_suspended_thread_list.AddThread(thread_sp);
-  thread_index_array[not_suspended_idx] = thread_sp->GetIndexID();
-  not_suspended_idx++;
-}
+if (thread_sp->GetResumeState() != eStateSuspended)
+  not_suspended_threads.emplace_back(thread_sp, thread_sp->GetIndexID());
   }
 
   // Use this to track whether we should continue from here.  We will only
@@ -4194,7 +4188,7 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   // is, and it's better to let the user decide than continue behind their
   // backs.
 
-  for (idx = 0; idx < not_suspended_thread_list.GetSize(); ++idx) {
+  for(auto [thread_sp, thread_index] : not_suspended_threads) {
 curr_thread_list = process_sp->GetThreadList();
 if (curr_thread_list.GetSize() != num_threads) {
   Log *log(GetLog(LLDBLog::Step | LLDBLog::Process));
@@ -4205,14 +4199,11 @@ bool Process::ProcessEventData::ShouldStop(Event 
*event_ptr,
   break;
 }
 
-lldb::ThreadSP thread_sp = not_suspended_thread_list.GetThreadAtIndex(idx);
-
-if (thread_sp->GetIndexID() != thread_index_array[idx]) {
+if (thread_sp->GetIndexID() != thread_index) {
   Log *log(GetLog(LLDBLog::Step | LLDBLog::Process));
-  LLDB_LOGF(log,
-"The thread at position %u changed from %u to %u while "
-"processing event.",
-idx, thread_index_array[idx], thread_sp->GetIndexID());
+  LLDB_LOG(log,
+   "The thread {0} changed from {1} to {2} while processing 
event.",
+   thread_sp.get(), thread_index, thread_sp->GetIndexID());
   break;
 }
 

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


[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via lldb-commits

DavidSpickett wrote:

>  Why not return a map every time?

Done.


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


[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/97824

>From 7ebe4e487b763ff26fbab6d75aa7c8694d63e8b1 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 5 Jul 2024 08:42:22 +
Subject: [PATCH 1/4] [llvm][TargetParser] Return optional from
 getHostCPUFeatures

Previously this took a reference to a map and returned a bool
to say whether it succeeded. This is an optional but with more
steps.

The only reason to keep it that way was if someone was appending
to an existing map, but all callers made a new map before calling
it.
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp  |  6 ++--
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  6 ++--
 lldb/utils/lit-cpuid/lit-cpuid.cpp| 21 +++---
 llvm/include/llvm/TargetParser/Host.h | 14 -
 llvm/lib/CodeGen/CommandFlags.cpp | 16 --
 .../Orc/JITTargetMachineBuilder.cpp   |  8 ++---
 llvm/lib/Target/TargetMachineC.cpp|  5 ++--
 llvm/lib/TargetParser/Host.cpp| 29 ---
 8 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 8ae22cc37a136..77adbf3865ab1 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -591,9 +591,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
,
 
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
-llvm::StringMap HostFeatures;
-if (llvm::sys::getHostCPUFeatures(HostFeatures))
-  for (auto  : HostFeatures)
+if (std::optional> HostFeatures =
+llvm::sys::getHostCPUFeatures())
+  for (auto  : *HostFeatures)
 Features.push_back(
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
   } else if (!CPUName.empty()) {
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 92821b2a82dae..e4adfcac23ca0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -131,9 +131,9 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   // If -march=native, autodetect the feature list.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {
-  llvm::StringMap HostFeatures;
-  if (llvm::sys::getHostCPUFeatures(HostFeatures))
-for (auto  : HostFeatures)
+  if (std::optional> HostFeatures =
+  llvm::sys::getHostCPUFeatures())
+for (auto  : *HostFeatures)
   Features.push_back(
   Args.MakeArgString((F.second ? "+" : "-") + F.first()));
 }
diff --git a/lldb/utils/lit-cpuid/lit-cpuid.cpp 
b/lldb/utils/lit-cpuid/lit-cpuid.cpp
index be322cb6aa42a..16743164e6a5d 100644
--- a/lldb/utils/lit-cpuid/lit-cpuid.cpp
+++ b/lldb/utils/lit-cpuid/lit-cpuid.cpp
@@ -15,22 +15,23 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 
+#include 
+
 using namespace llvm;
 
 int main(int argc, char **argv) {
 #if defined(__i386__) || defined(_M_IX86) || \
 defined(__x86_64__) || defined(_M_X64)
-  StringMap features;
-
-  if (!sys::getHostCPUFeatures(features))
+  if (std::optional> features =
+  sys::getHostCPUFeatures(features)) {
+if ((*features)["sse"])
+  outs() << "sse\n";
+if ((*features)["avx"])
+  outs() << "avx\n";
+if ((*features)["avx512f"])
+  outs() << "avx512f\n";
+  } else
 return 1;
-
-  if (features["sse"])
-outs() << "sse\n";
-  if (features["avx"])
-outs() << "avx\n";
-  if (features["avx512f"])
-outs() << "avx512f\n";
 #endif
 
   return 0;
diff --git a/llvm/include/llvm/TargetParser/Host.h 
b/llvm/include/llvm/TargetParser/Host.h
index af72045a8fe67..d68655835a323 100644
--- a/llvm/include/llvm/TargetParser/Host.h
+++ b/llvm/include/llvm/TargetParser/Host.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_TARGETPARSER_HOST_H
 #define LLVM_TARGETPARSER_HOST_H
 
+#include 
 #include 
 
 namespace llvm {
@@ -47,13 +48,12 @@ namespace sys {
   /// The particular format of the names are target dependent, and suitable for
   /// passing as -mattr to the target which matches the host.
   ///
-  /// \param Features - A string mapping feature names to either
-  /// true (if enabled) or false (if disabled). This routine makes no 
guarantees
-  /// about exactly which features may appear in this map, except that they are
-  /// all valid LLVM feature names.
-  ///
-  /// \return - True on success.
-  bool getHostCPUFeatures(StringMap );
+  /// \return - If feature detection succeeds, a string map mapping feature
+  /// names to either true (if enabled) or false (if disabled). This routine
+  /// makes no guarantees about exactly which features may appear in this map,
+  /// except that they are all valid LLVM feature names. If feature detection
+  /// fails, an empty optional is returned.

[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits


@@ -113,6 +130,10 @@ def _get_platform_os(p):
 platform = "openbsd"
 return platform
 
+# Triple is not available if we're not connected yet
+if p.GetName() == "remote-linux":
+return "linux"
+

dzhidzhoev wrote:

Fixed.

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev updated 
https://github.com/llvm/llvm-project/pull/96654

>From 016ed9ec4ed320709b981f4a5fe228a91d753230 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Wed, 19 Jun 2024 23:50:18 +
Subject: [PATCH] [lldb][test] Set target and host OS for API tests in case of
 remote testing

Makefile.rules uses HOST_OS and OS variables for determining host and target
OSes for API tests compilation.

This commit starts moving the platform detection logic from Makefile to Python 
lldb
test suite.

When lldb's target is set to remote-linux, Makefile.rules script should be
executed with the target OS variable set to Linux.

This is useful for the case of Windows-to-Linux cross-testing.
---
 .../Python/lldbsuite/test/lldbplatformutil.py | 21 +--
 .../Python/lldbsuite/test/make/Makefile.rules |  5 -
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 21f2095db90f8..818fdf0e6b5c5 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -92,11 +92,28 @@ def match_android_device(device_arch, valid_archs=None, 
valid_api_levels=None):
 
 
 def finalize_build_dictionary(dictionary):
+# Provide uname-like platform name
+platform_name_to_uname = {
+"linux": "Linux",
+"netbsd": "NetBSD",
+"freebsd": "FreeBSD",
+"windows": "Windows_NT",
+"macosx": "Darwin",
+"darwin": "Darwin",
+}
+
+if dictionary is None:
+dictionary = {}
 if target_is_android():
-if dictionary is None:
-dictionary = {}
 dictionary["OS"] = "Android"
 dictionary["PIE"] = 1
+elif platformIsDarwin():
+dictionary["OS"] = "Darwin"
+else:
+dictionary["OS"] = platform_name_to_uname[getPlatform()]
+
+dictionary["HOST_OS"] = platform_name_to_uname[getHostPlatform()]
+
 return dictionary
 
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bd8eea3d6f5a0..3d562285ce9cc 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -55,7 +55,10 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
-HOST_OS := $(shell uname -s)
+ifeq "$(HOST_OS)" ""
+  HOST_OS := $(shell uname -s)
+endif
+
 ifneq (,$(findstring windows32,$(HOST_OS)))
HOST_OS := Windows_NT
 endif

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -113,6 +130,10 @@ def _get_platform_os(p):
 platform = "openbsd"
 return platform
 
+# Triple is not available if we're not connected yet
+if p.GetName() == "remote-linux":
+return "linux"
+

labath wrote:

Yes, I would very much prefer that, as the code you added only handles linux. 
To support other oses, we would need to create a whole new mapping from lldb 
platform names to os strings. That list could then get out of sync, etc., so it 
would be best to just avoid doing that.

I'm not worried about the debug target going down during testing, as that means 
the test results will be meaningless anyway. If we find out we regularly need 
the os name before connecting, then I think we ought to revisit the mechanism 
for determining the OS.

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


[Lldb-commits] [lldb] [lldb] Use correct path separator for C++ library files lookup (PR #98144)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] afee09c - [lldb] Use correct path separator for C++ library files lookup (#98144)

2024-07-09 Thread via lldb-commits

Author: Vladislav Dzhidzhoev
Date: 2024-07-09T14:22:33+02:00
New Revision: afee09c50c11da1ea6ba0b341a1c10dedeaf5be6

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

LOG: [lldb] Use correct path separator for C++ library files lookup (#98144)

Use POSIX-style path separators when checking for libcpp library path.
This is necessary to run API tests from 'std-module' group compiled on
Windows host for Linux target.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
index f43a04488230f..f3aabc12f92b7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
@@ -71,7 +71,7 @@ bool CppModuleConfiguration::analyzeFile(const FileSpec ,
   // If the path is in the libc++ include directory use it as the found libc++
   // path. Ignore subdirectories such as /c++/v1/experimental as those don't
   // need to be specified in the header search.
-  if (libcpp_regex.match(f.GetPath()) &&
+  if (libcpp_regex.match(convert_to_slash(f.GetPath())) &&
   parent_path(posix_dir, Style::posix).ends_with("c++")) {
 if (!m_std_inc.TrySet(posix_dir))
   return false;



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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits


@@ -113,6 +130,10 @@ def _get_platform_os(p):
 platform = "openbsd"
 return platform
 
+# Triple is not available if we're not connected yet
+if p.GetName() == "remote-linux":
+return "linux"
+

dzhidzhoev wrote:

That may be relevant if _get_platform_os is called before the connection is 
established, or, for example, if it has failed to be established.
But yeah, currently I'm not aware of such use cases. Should it be removed?

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


[Lldb-commits] [lldb] [lldb] Use correct path separator for C++ library files lookup (PR #98144)

2024-07-09 Thread Raphael Isemann via lldb-commits

Teemperor wrote:

This LGTM

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


[Lldb-commits] [lldb] [lldb] Use correct path separator for C++ library files lookup (PR #98144)

2024-07-09 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Use correct path separator for C++ library files lookup (PR #98144)

2024-07-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vladislav Dzhidzhoev (dzhidzhoev)


Changes

Use POSIX-style path separators when checking for libcpp library path.
This is necessary to run API tests from 'std-module' group compiled on Windows 
host for Linux target.

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


1 Files Affected:

- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp (+1-1) 


``diff
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
index f43a04488230f..f3aabc12f92b7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
@@ -71,7 +71,7 @@ bool CppModuleConfiguration::analyzeFile(const FileSpec ,
   // If the path is in the libc++ include directory use it as the found libc++
   // path. Ignore subdirectories such as /c++/v1/experimental as those don't
   // need to be specified in the header search.
-  if (libcpp_regex.match(f.GetPath()) &&
+  if (libcpp_regex.match(convert_to_slash(f.GetPath())) &&
   parent_path(posix_dir, Style::posix).ends_with("c++")) {
 if (!m_std_inc.TrySet(posix_dir))
   return false;

``




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


[Lldb-commits] [lldb] [lldb] Use correct path separator for C++ library files lookup (PR #98144)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev created 
https://github.com/llvm/llvm-project/pull/98144

Use POSIX-style path separators when checking for libcpp library path.
This is necessary to run API tests from 'std-module' group compiled on Windows 
host for Linux target.

>From fce5e1e4a59b511a0bd4aa1bb1865528297c5471 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Wed, 22 May 2024 11:19:44 -0700
Subject: [PATCH] [lldb] Use correct path separator for C++ library files
 lookup

Take into account separator style of target platorm.
This is necessary to run API tests from 'std-module' group compiled
on Windows host for Linux target.
---
 .../Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
index f43a04488230f..f3aabc12f92b7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
@@ -71,7 +71,7 @@ bool CppModuleConfiguration::analyzeFile(const FileSpec ,
   // If the path is in the libc++ include directory use it as the found libc++
   // path. Ignore subdirectories such as /c++/v1/experimental as those don't
   // need to be specified in the header search.
-  if (libcpp_regex.match(f.GetPath()) &&
+  if (libcpp_regex.match(convert_to_slash(f.GetPath())) &&
   parent_path(posix_dir, Style::posix).ends_with("c++")) {
 if (!m_std_inc.TrySet(posix_dir))
   return false;

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -113,6 +130,10 @@ def _get_platform_os(p):
 platform = "openbsd"
 return platform
 
+# Triple is not available if we're not connected yet
+if p.GetName() == "remote-linux":
+return "linux"
+

labath wrote:

Can you explain why was this necessary? I get the connected part, but who was 
asking for the platform before connecting?

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits

dzhidzhoev wrote:

Thank you! Updated it: improved code for Darwin host detection, and removed 
overriding of HOST_OS in Makefile.

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev updated 
https://github.com/llvm/llvm-project/pull/96654

>From b6e1aa283d46292556d0edac70eb05d6467497f2 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Wed, 19 Jun 2024 23:50:18 +
Subject: [PATCH] [lldb][test] Set target and host OS for API tests in case of
 remote testing

Makefile.rules uses HOST_OS and OS variables for determining host and target
OSes for API tests compilation.

This commit starts moving the platform detection logic from Makefile to Python 
lldb
test suite.

When lldb's target is set to remote-linux, Makefile.rules script should be
executed with the target OS variable set to Linux.

This is useful for the case of Windows-to-Linux cross-testing.
---
 .../Python/lldbsuite/test/lldbplatformutil.py | 25 +--
 .../Python/lldbsuite/test/make/Makefile.rules |  5 +++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 21f2095db90f8..1e076061c6c43 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -92,11 +92,28 @@ def match_android_device(device_arch, valid_archs=None, 
valid_api_levels=None):
 
 
 def finalize_build_dictionary(dictionary):
+# Provide uname-like platform name
+platform_name_to_uname = {
+"linux": "Linux",
+"netbsd": "NetBSD",
+"freebsd": "FreeBSD",
+"windows": "Windows_NT",
+"macosx": "Darwin",
+"darwin": "Darwin",
+}
+
+if dictionary is None:
+dictionary = {}
 if target_is_android():
-if dictionary is None:
-dictionary = {}
 dictionary["OS"] = "Android"
 dictionary["PIE"] = 1
+elif platformIsDarwin():
+dictionary["OS"] = "Darwin"
+else:
+dictionary["OS"] = platform_name_to_uname[getPlatform()]
+
+dictionary["HOST_OS"] = platform_name_to_uname[getHostPlatform()]
+
 return dictionary
 
 
@@ -113,6 +130,10 @@ def _get_platform_os(p):
 platform = "openbsd"
 return platform
 
+# Triple is not available if we're not connected yet
+if p.GetName() == "remote-linux":
+return "linux"
+
 return ""
 
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bd8eea3d6f5a0..3d562285ce9cc 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -55,7 +55,10 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
-HOST_OS := $(shell uname -s)
+ifeq "$(HOST_OS)" ""
+  HOST_OS := $(shell uname -s)
+endif
+
 ifneq (,$(findstring windows32,$(HOST_OS)))
HOST_OS := Windows_NT
 endif

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


[Lldb-commits] [lldb] [lldb][test] Set target OS for API tests in case of remote testing (PR #96654)

2024-07-09 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev updated 
https://github.com/llvm/llvm-project/pull/96654

>From d47f7306c913336529a01a401e41ce688d0c6b46 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Wed, 19 Jun 2024 23:50:18 +
Subject: [PATCH] [lldb][test] Set target and host OS for API tests in case of
 remote testing

Makefile.rules uses HOST_OS and OS variables for determining host and target
OSes for API tests compilation.

This commit starts moving the platform detection logic from Makefile to Python 
lldb
test suite.

When lldb's target is set to remote-linux, Makefile.rules script should be
executed with the target OS variable set to Linux.

This is useful for the case of Windows-to-Linux cross-testing.
---
 .../Python/lldbsuite/test/lldbplatformutil.py | 29 +--
 .../Python/lldbsuite/test/make/Makefile.rules |  5 +++-
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 21f2095db90f8..e4de298fb11ae 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -56,6 +56,10 @@ def target_is_android():
 return configuration.lldb_platform_name == "remote-android"
 
 
+def target_is_remote_linux():
+return configuration.lldb_platform_name == "remote-linux"
+
+
 def android_device_api():
 if not hasattr(android_device_api, "result"):
 assert configuration.lldb_platform_url is not None
@@ -92,11 +96,28 @@ def match_android_device(device_arch, valid_archs=None, 
valid_api_levels=None):
 
 
 def finalize_build_dictionary(dictionary):
+# Provide uname-like platform name
+platform_name_to_uname = { "linux": "Linux",
+"netbsd": "NetBSD",
+"freebsd": "FreeBSD",
+"windows": "Windows_NT",
+}
+
+if dictionary is None:
+dictionary = {}
 if target_is_android():
-if dictionary is None:
-dictionary = {}
 dictionary["OS"] = "Android"
 dictionary["PIE"] = 1
+elif platformIsDarwin():
+dictionary["OS"] = "Darwin"
+else:
+dictionary["OS"] = platform_name_to_uname[getPlatform()]
+
+if platformIsDarwin():
+dictionary["HOST_OS"] = "Darwin"
+else:
+dictionary["HOST_OS"] = platform_name_to_uname[getHostPlatform()]
+
 return dictionary
 
 
@@ -113,6 +134,10 @@ def _get_platform_os(p):
 platform = "openbsd"
 return platform
 
+# Triple is not available if we're not connected yet
+if p.GetName() == "remote-linux":
+return "linux"
+
 return ""
 
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bd8eea3d6f5a0..c101d84a9b959 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -55,7 +55,10 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
-HOST_OS := $(shell uname -s)
+ifeq "$(OS)" ""
+  HOST_OS := $(shell uname -s)
+endif
+
 ifneq (,$(findstring windows32,$(HOST_OS)))
HOST_OS := Windows_NT
 endif

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-07-09 Thread Shivam Gupta via lldb-commits


@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.substr(0, pos);
+source_file = source_file.resize(0, pos);

xgupta wrote:

Thanks, got it.

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-07-09 Thread Shivam Gupta via lldb-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/94785

>From 6ec5b1a005b7551f2857b30e2461d297e7febfa3 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 7 Jun 2024 23:44:49 +0530
Subject: [PATCH 1/3] [LLDB][NFC] Fix a cppcheck warning in
 Platform/Android/PlatformAndroid.cpp

Fix #91211
---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index e177c134fea20..6367763dd8b4a 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.substr(0, pos);
+source_file = source_file.resize(0, pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

>From c05f1a9812b8ef6cfc4f1f4c2d7525371d65a95b Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 6 Jul 2024 11:00:16 +0200
Subject: [PATCH 2/3] address review comment

---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index 6367763dd8b4a..ff63af68aec9d 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.resize(0, pos);
+source_file = source_file.resize(pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

>From 1cd2f9c11070bcbee2efad2e5b84433eef31438c Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Tue, 9 Jul 2024 12:31:01 +0200
Subject: [PATCH 3/3] address review comment

---
 lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
index ff63af68aec9d..50b6a5c29a657 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.resize(pos);
+source_file.resize(pos);
 
   Status error;
   AdbClientUP adb(GetAdbClient(error));

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {
+
+/// Struct to hold information about member fields. Used by the parser for the
+/// Data Inspection Language (DIL).
+struct DILMemberInfo {
+  std::optional name;
+  CompilerType type;
+  bool is_bitfield;
+  uint32_t bitfield_size_in_bits;
+  bool is_synthetic;
+  bool is_dynamic;
+  lldb::ValueObjectSP val_obj_sp;
+
+  explicit operator bool() const { return type.IsValid(); }
+};
+
+/// This determines if the type is a shared, unique or weak pointer, either
+/// from stdlibc++ or libc+++.
+bool IsSmartPtrType(CompilerType type);
+
+/// Finds the member field with the given name and type, stores the child index
+/// corresponding to the field in the idx vector and returns a DILMemberInfo
+/// struct with appropriate information about the field.
+DILMemberInfo GetFieldWithNameIndexPath(lldb::ValueObjectSP lhs_val_sp,
+CompilerType type,
+const std::string ,
+std::vector *idx,
+CompilerType empty_type,
+bool use_synthetic, bool is_dynamic);
+
+std::tuple>
+GetMemberInfo(lldb::ValueObjectSP lhs_val_sp, CompilerType type,
+  const std::string , bool use_synthetic);
+
+/// Get the appropriate ValueObjectSP, consulting the use_dynamic and
+/// use_synthetic options passed, acquiring the process & target locks if
+/// appropriate.
+lldb::ValueObjectSP
+DILGetSPWithLock(lldb::ValueObjectSP valobj_sp,
+ lldb::DynamicValueType use_dynamic = lldb::eNoDynamicValues,
+ bool use_synthetic = false);
+
+/// The various types DIL AST nodes (used by the DIL parser).
+enum class DILNodeKind {
+  kDILErrorNode,
+  kLiteralNode,
+  kIdentifierNode,
+  kBuiltinFunctionCallNode,
+  kCStyleCastNode,
+  kMemberOfNode,
+  kArraySubscriptNode,
+  kUnaryOpNode,
+  kSmartPtrToPtrDecay
+};
+
+/// The C-Style casts allowed by DIL.
+enum class CStyleCastKind {
+  kArithmetic,
+  kEnumeration,
+  kPointer,
+  kNullptr,
+  kReference,
+};
+
+/// The Unary operators recognized by DIL.
+enum class UnaryOpKind {
+  AddrOf, // "&"
+  Deref,  // "*"
+  Minus,  // "-"
+};
+
+/// Given a string representing a type, returns the CompilerType corresponding
+/// to the named type, if it exists.
+CompilerType
+ResolveTypeByName(const std::string ,
+  std::shared_ptr ctx_scope);
+
+/// Quick lookup to check if a type name already exists in a
+/// name-to-CompilerType map the DIL parser keeps of previously found
+/// name/type pairs.
+bool IsContextVar(const std::string );
+
+/// Checks to see if the CompilerType is a Smart Pointer (shared, unique, weak)
+/// or not. Only applicable for C++, which is why this is here and not part of
+/// the CompilerType class.
+bool IsSmartPtrType(CompilerType type);
+
+/// Class used to store & manipulate information about identifiers.
+class IdentifierInfo {
+private:
+  using MemberPath = std::vector;
+  using IdentifierInfoPtr = std::unique_ptr;
+
+public:
+  enum class Kind {
+kValue,
+kContextArg,
+kMemberPath,
+kThisKeyword,
+  };
+
+  static IdentifierInfoPtr FromValue(lldb::ValueObjectSP value_sp) {
+CompilerType type;
+lldb::ValueObjectSP value = DILGetSPWithLock(value_sp);
+if (value)
+  type = value->GetCompilerType();
+return IdentifierInfoPtr(new IdentifierInfo(Kind::kValue, type, value, 
{}));
+  }
+
+  static IdentifierInfoPtr FromContextArg(CompilerType type) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(
+new IdentifierInfo(Kind::kContextArg, type, empty_value, {}));
+  }
+
+  static IdentifierInfoPtr FromMemberPath(CompilerType type, MemberPath path) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(new IdentifierInfo(Kind::kMemberPath, type,
+empty_value, std::move(path)));
+  }
+
+  static IdentifierInfoPtr FromThisKeyword(CompilerType type) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(
+new 

[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {
+
+/// Struct to hold information about member fields. Used by the parser for the
+/// Data Inspection Language (DIL).
+struct DILMemberInfo {
+  std::optional name;
+  CompilerType type;
+  bool is_bitfield;
+  uint32_t bitfield_size_in_bits;
+  bool is_synthetic;
+  bool is_dynamic;
+  lldb::ValueObjectSP val_obj_sp;
+
+  explicit operator bool() const { return type.IsValid(); }
+};
+
+/// This determines if the type is a shared, unique or weak pointer, either
+/// from stdlibc++ or libc+++.
+bool IsSmartPtrType(CompilerType type);
+
+/// Finds the member field with the given name and type, stores the child index
+/// corresponding to the field in the idx vector and returns a DILMemberInfo
+/// struct with appropriate information about the field.
+DILMemberInfo GetFieldWithNameIndexPath(lldb::ValueObjectSP lhs_val_sp,
+CompilerType type,
+const std::string ,
+std::vector *idx,
+CompilerType empty_type,
+bool use_synthetic, bool is_dynamic);
+
+std::tuple>
+GetMemberInfo(lldb::ValueObjectSP lhs_val_sp, CompilerType type,
+  const std::string , bool use_synthetic);
+
+/// Get the appropriate ValueObjectSP, consulting the use_dynamic and
+/// use_synthetic options passed, acquiring the process & target locks if
+/// appropriate.
+lldb::ValueObjectSP
+DILGetSPWithLock(lldb::ValueObjectSP valobj_sp,
+ lldb::DynamicValueType use_dynamic = lldb::eNoDynamicValues,
+ bool use_synthetic = false);
+
+/// The various types DIL AST nodes (used by the DIL parser).
+enum class DILNodeKind {
+  kDILErrorNode,
+  kLiteralNode,
+  kIdentifierNode,
+  kBuiltinFunctionCallNode,
+  kCStyleCastNode,
+  kMemberOfNode,
+  kArraySubscriptNode,
+  kUnaryOpNode,
+  kSmartPtrToPtrDecay

labath wrote:

lldb doesn't use the `k` prefix for constants. For unscoped enums, we use `e`. 
I think some of the scoped ones have it as well, but an empty prefix is also 
pretty common (so you can then refer to them as `DILNodeKind::Literal` (or 
`dil::NodeKind::Literal` in the namespace version).

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,468 @@
+//===-- DILAST.cpp 
===//
+//
+// 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 "lldb/Core/DILAST.h"
+#include "lldb/API/SBType.h"
+#include "lldb/Core/ValueObjectRegister.h"
+#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/RegisterContext.h"
+#include "llvm/ADT/StringRef.h"
+
+#include 
+
+namespace lldb_private {
+
+lldb::ValueObjectSP DILGetSPWithLock(lldb::ValueObjectSP in_valobj_sp,
+ lldb::DynamicValueType use_dynamic,
+ bool use_synthetic) {
+  Process::StopLocker stop_locker;
+  std::unique_lock lock;
+  Status error;
+
+  if (!in_valobj_sp) {
+error.SetErrorString("invalid value object");
+return in_valobj_sp;
+  }
+
+  lldb::ValueObjectSP value_sp = in_valobj_sp;
+
+  Target *target = value_sp->GetTargetSP().get();
+  // If this ValueObject holds an error, then it is valuable for that.
+  if (value_sp->GetError().Fail())
+return value_sp;
+
+  if (!target)
+return lldb::ValueObjectSP();
+
+  lock = std::unique_lock(target->GetAPIMutex());
+
+  lldb::ProcessSP process_sp(value_sp->GetProcessSP());
+  if (process_sp && !stop_locker.TryLock(_sp->GetRunLock())) {
+// We don't allow people to play around with ValueObject if the process
+// is running. If you want to look at values, pause the process, then
+// look.
+error.SetErrorString("process must be stopped.");
+return lldb::ValueObjectSP();
+  }
+
+  if (use_dynamic != lldb::eNoDynamicValues) {
+lldb::ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(use_dynamic);
+if (dynamic_sp)
+  value_sp = dynamic_sp;
+  }
+
+  if (use_synthetic) {
+lldb::ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue();
+if (synthetic_sp)
+  value_sp = synthetic_sp;
+  }
+
+  if (!value_sp)
+error.SetErrorString("invalid value object");
+
+  return value_sp;
+}
+
+CompilerType DILASTNode::result_type_deref() const {
+  auto type = result_type();
+  return type.IsReferenceType() ? type.GetNonReferenceType() : type;
+}
+
+static std::unordered_map context_args;
+
+bool IsContextVar(const std::string ) {
+  return context_args.find(name) != context_args.end();
+}
+
+static lldb::ValueObjectSP
+LookupStaticIdentifier(lldb::TargetSP target_sp,
+   const llvm::StringRef _ref,
+   ConstString unqualified_name) {
+  // List global variable with the same "basename". There can be many matches
+  // from other scopes (namespaces, classes), so we do additional filtering
+  // later.
+  std::vector values;
+  VariableList variable_list;
+  ConstString name(name_ref);
+  target_sp->GetImages().FindGlobalVariables(
+  name, (size_t)std::numeric_limits::max, variable_list);
+  if (!variable_list.Empty()) {
+ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
+if (exe_scope == nullptr)
+  exe_scope = target_sp.get();
+for (const lldb::VariableSP _sp : variable_list) {
+  lldb::ValueObjectSP valobj_sp(
+  ValueObjectVariable::Create(exe_scope, var_sp));
+  if (valobj_sp)
+values.push_back(valobj_sp);
+}
+  }
+
+  // Find the corrent variable by matching the name. lldb::SBValue::GetName()
+  // can return strings like "::globarVar", "ns::i" or "int const ns::foo"
+  // depending on the version and the platform.
+  for (uint32_t i = 0; i < values.size(); ++i) {
+lldb::ValueObjectSP val = values[i];
+llvm::StringRef val_name_sstr = val->GetName().GetStringRef();
+llvm::StringRef name_sstr = name.GetStringRef();
+
+if (val->GetVariable() && 
val->GetVariable()->NameMatches(unqualified_name))
+  return val;
+
+if (val_name_sstr == name_sstr ||
+val_name_sstr == llvm::formatv("::{0}", name_sstr).str() ||
+val_name_sstr.ends_with(llvm::formatv(" {0}", name_sstr).str()) ||
+val_name_sstr.ends_with(llvm::formatv("*{0}", name_sstr).str()) ||
+val_name_sstr.ends_with(llvm::formatv("&{0}", name_sstr).str()))
+  return val;
+  }
+  lldb::ValueObjectSP empty_obj_sp;
+  return empty_obj_sp;
+}
+
+struct EnumMember {
+  CompilerType type;
+  ConstString name;
+  llvm::APSInt value;
+};
+
+static std::vector GetEnumMembers(CompilerType type) {
+  std::vector enum_member_list;
+  if (type.IsValid()) {
+type.ForEachEnumerator(
+[_member_list](const CompilerType _type, ConstString name,
+const llvm::APSInt ) -> bool {
+  EnumMember enum_member = {integer_type, name, value};
+  

[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {
+
+/// Struct to hold information about member fields. Used by the parser for the
+/// Data Inspection Language (DIL).
+struct DILMemberInfo {
+  std::optional name;
+  CompilerType type;
+  bool is_bitfield;
+  uint32_t bitfield_size_in_bits;
+  bool is_synthetic;
+  bool is_dynamic;
+  lldb::ValueObjectSP val_obj_sp;
+
+  explicit operator bool() const { return type.IsValid(); }
+};
+
+/// This determines if the type is a shared, unique or weak pointer, either
+/// from stdlibc++ or libc+++.
+bool IsSmartPtrType(CompilerType type);
+
+/// Finds the member field with the given name and type, stores the child index
+/// corresponding to the field in the idx vector and returns a DILMemberInfo
+/// struct with appropriate information about the field.
+DILMemberInfo GetFieldWithNameIndexPath(lldb::ValueObjectSP lhs_val_sp,
+CompilerType type,
+const std::string ,
+std::vector *idx,
+CompilerType empty_type,
+bool use_synthetic, bool is_dynamic);
+
+std::tuple>
+GetMemberInfo(lldb::ValueObjectSP lhs_val_sp, CompilerType type,
+  const std::string , bool use_synthetic);
+
+/// Get the appropriate ValueObjectSP, consulting the use_dynamic and
+/// use_synthetic options passed, acquiring the process & target locks if
+/// appropriate.
+lldb::ValueObjectSP
+DILGetSPWithLock(lldb::ValueObjectSP valobj_sp,
+ lldb::DynamicValueType use_dynamic = lldb::eNoDynamicValues,
+ bool use_synthetic = false);
+
+/// The various types DIL AST nodes (used by the DIL parser).
+enum class DILNodeKind {
+  kDILErrorNode,
+  kLiteralNode,
+  kIdentifierNode,
+  kBuiltinFunctionCallNode,
+  kCStyleCastNode,
+  kMemberOfNode,
+  kArraySubscriptNode,
+  kUnaryOpNode,
+  kSmartPtrToPtrDecay
+};
+
+/// The C-Style casts allowed by DIL.
+enum class CStyleCastKind {
+  kArithmetic,
+  kEnumeration,
+  kPointer,
+  kNullptr,
+  kReference,
+};
+
+/// The Unary operators recognized by DIL.
+enum class UnaryOpKind {
+  AddrOf, // "&"
+  Deref,  // "*"
+  Minus,  // "-"
+};
+
+/// Given a string representing a type, returns the CompilerType corresponding
+/// to the named type, if it exists.
+CompilerType
+ResolveTypeByName(const std::string ,
+  std::shared_ptr ctx_scope);
+
+/// Quick lookup to check if a type name already exists in a
+/// name-to-CompilerType map the DIL parser keeps of previously found
+/// name/type pairs.
+bool IsContextVar(const std::string );
+
+/// Checks to see if the CompilerType is a Smart Pointer (shared, unique, weak)
+/// or not. Only applicable for C++, which is why this is here and not part of
+/// the CompilerType class.
+bool IsSmartPtrType(CompilerType type);
+
+/// Class used to store & manipulate information about identifiers.
+class IdentifierInfo {
+private:
+  using MemberPath = std::vector;
+  using IdentifierInfoPtr = std::unique_ptr;
+
+public:
+  enum class Kind {
+kValue,
+kContextArg,
+kMemberPath,
+kThisKeyword,
+  };
+
+  static IdentifierInfoPtr FromValue(lldb::ValueObjectSP value_sp) {
+CompilerType type;
+lldb::ValueObjectSP value = DILGetSPWithLock(value_sp);
+if (value)
+  type = value->GetCompilerType();
+return IdentifierInfoPtr(new IdentifierInfo(Kind::kValue, type, value, 
{}));
+  }
+
+  static IdentifierInfoPtr FromContextArg(CompilerType type) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(
+new IdentifierInfo(Kind::kContextArg, type, empty_value, {}));
+  }
+
+  static IdentifierInfoPtr FromMemberPath(CompilerType type, MemberPath path) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(new IdentifierInfo(Kind::kMemberPath, type,
+empty_value, std::move(path)));
+  }
+
+  static IdentifierInfoPtr FromThisKeyword(CompilerType type) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(
+new 

[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {
+
+/// Struct to hold information about member fields. Used by the parser for the
+/// Data Inspection Language (DIL).
+struct DILMemberInfo {
+  std::optional name;
+  CompilerType type;
+  bool is_bitfield;
+  uint32_t bitfield_size_in_bits;
+  bool is_synthetic;
+  bool is_dynamic;
+  lldb::ValueObjectSP val_obj_sp;
+
+  explicit operator bool() const { return type.IsValid(); }
+};
+
+/// This determines if the type is a shared, unique or weak pointer, either
+/// from stdlibc++ or libc+++.
+bool IsSmartPtrType(CompilerType type);
+
+/// Finds the member field with the given name and type, stores the child index
+/// corresponding to the field in the idx vector and returns a DILMemberInfo
+/// struct with appropriate information about the field.
+DILMemberInfo GetFieldWithNameIndexPath(lldb::ValueObjectSP lhs_val_sp,
+CompilerType type,
+const std::string ,
+std::vector *idx,
+CompilerType empty_type,
+bool use_synthetic, bool is_dynamic);
+
+std::tuple>
+GetMemberInfo(lldb::ValueObjectSP lhs_val_sp, CompilerType type,
+  const std::string , bool use_synthetic);

labath wrote:

these aren't implemented anywhere.

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {
+
+/// Struct to hold information about member fields. Used by the parser for the
+/// Data Inspection Language (DIL).
+struct DILMemberInfo {
+  std::optional name;
+  CompilerType type;
+  bool is_bitfield;
+  uint32_t bitfield_size_in_bits;

labath wrote:

Does every bitfield have to have a size? If yes, what would you say to 
`optional bitfield_bit_size` (with `nullopt` meaning "it's not a 
bitfield")?

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,43 @@
+(* LLDB Debug Expressions, a subset of C++ *)
+(* Insired by https://www.nongnu.org/hcb *)
+
+expression = cast_expression;
+
+cast_expression = unary_expression;
+
+unary_expression = postfix_expression
+ | unary_operator cast_expression;
+
+unary_operator = "*" | "&" | "-" ;
+
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]"
+   | postfix_expression "." id_expression
+   | postfix_expression "->" id_expression
+
+primary_expression = numeric_literal
+   | boolean_literal
+   | pointer_literal
+   | id_expression
+   | "this" ;
+
+nested_name_specifier = namespace_name '::'
+  | nested_name_specifier identifier "::";
+
+namespace_name = identifier ;
+
+id_expression = unqualified_id
+  | qualified_id ;
+
+unqualified_id = identifier ;
+
+qualified_id = [nested_name_specifier] unqualified_id
+ | identifier ;
+
+identifier = ? clang::tok::identifier ? ;
+
+numeric_literal = ? clang::tok::numeric_constant ? ;
+
+boolean_literal = "true" | "false" ;
+
+pointer_literal = "nullptr" ;

labath wrote:

true/false/nullptr are also spelled differently in different languages, and I 
don't believe they're necessary for the basic "frame variable" implementation. 
Can we skip those for now?

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {
+
+/// Struct to hold information about member fields. Used by the parser for the
+/// Data Inspection Language (DIL).
+struct DILMemberInfo {
+  std::optional name;
+  CompilerType type;
+  bool is_bitfield;
+  uint32_t bitfield_size_in_bits;
+  bool is_synthetic;
+  bool is_dynamic;
+  lldb::ValueObjectSP val_obj_sp;
+
+  explicit operator bool() const { return type.IsValid(); }

labath wrote:

What would you say to deleting this and using `optional` instead?

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {
+
+/// Struct to hold information about member fields. Used by the parser for the
+/// Data Inspection Language (DIL).
+struct DILMemberInfo {
+  std::optional name;
+  CompilerType type;
+  bool is_bitfield;
+  uint32_t bitfield_size_in_bits;
+  bool is_synthetic;
+  bool is_dynamic;
+  lldb::ValueObjectSP val_obj_sp;
+
+  explicit operator bool() const { return type.IsValid(); }
+};
+
+/// This determines if the type is a shared, unique or weak pointer, either
+/// from stdlibc++ or libc+++.
+bool IsSmartPtrType(CompilerType type);
+
+/// Finds the member field with the given name and type, stores the child index
+/// corresponding to the field in the idx vector and returns a DILMemberInfo
+/// struct with appropriate information about the field.
+DILMemberInfo GetFieldWithNameIndexPath(lldb::ValueObjectSP lhs_val_sp,
+CompilerType type,
+const std::string ,
+std::vector *idx,
+CompilerType empty_type,
+bool use_synthetic, bool is_dynamic);
+
+std::tuple>
+GetMemberInfo(lldb::ValueObjectSP lhs_val_sp, CompilerType type,
+  const std::string , bool use_synthetic);
+
+/// Get the appropriate ValueObjectSP, consulting the use_dynamic and
+/// use_synthetic options passed, acquiring the process & target locks if
+/// appropriate.
+lldb::ValueObjectSP
+DILGetSPWithLock(lldb::ValueObjectSP valobj_sp,
+ lldb::DynamicValueType use_dynamic = lldb::eNoDynamicValues,
+ bool use_synthetic = false);
+
+/// The various types DIL AST nodes (used by the DIL parser).
+enum class DILNodeKind {
+  kDILErrorNode,
+  kLiteralNode,
+  kIdentifierNode,
+  kBuiltinFunctionCallNode,
+  kCStyleCastNode,
+  kMemberOfNode,
+  kArraySubscriptNode,
+  kUnaryOpNode,
+  kSmartPtrToPtrDecay
+};
+
+/// The C-Style casts allowed by DIL.
+enum class CStyleCastKind {
+  kArithmetic,
+  kEnumeration,
+  kPointer,
+  kNullptr,
+  kReference,
+};
+
+/// The Unary operators recognized by DIL.
+enum class UnaryOpKind {
+  AddrOf, // "&"
+  Deref,  // "*"
+  Minus,  // "-"
+};
+
+/// Given a string representing a type, returns the CompilerType corresponding
+/// to the named type, if it exists.
+CompilerType
+ResolveTypeByName(const std::string ,
+  std::shared_ptr ctx_scope);
+
+/// Quick lookup to check if a type name already exists in a
+/// name-to-CompilerType map the DIL parser keeps of previously found
+/// name/type pairs.
+bool IsContextVar(const std::string );
+
+/// Checks to see if the CompilerType is a Smart Pointer (shared, unique, weak)
+/// or not. Only applicable for C++, which is why this is here and not part of
+/// the CompilerType class.
+bool IsSmartPtrType(CompilerType type);
+
+/// Class used to store & manipulate information about identifiers.
+class IdentifierInfo {
+private:
+  using MemberPath = std::vector;
+  using IdentifierInfoPtr = std::unique_ptr;
+
+public:
+  enum class Kind {
+kValue,
+kContextArg,
+kMemberPath,
+kThisKeyword,
+  };
+
+  static IdentifierInfoPtr FromValue(lldb::ValueObjectSP value_sp) {
+CompilerType type;
+lldb::ValueObjectSP value = DILGetSPWithLock(value_sp);
+if (value)
+  type = value->GetCompilerType();
+return IdentifierInfoPtr(new IdentifierInfo(Kind::kValue, type, value, 
{}));
+  }
+
+  static IdentifierInfoPtr FromContextArg(CompilerType type) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(
+new IdentifierInfo(Kind::kContextArg, type, empty_value, {}));
+  }
+
+  static IdentifierInfoPtr FromMemberPath(CompilerType type, MemberPath path) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(new IdentifierInfo(Kind::kMemberPath, type,
+empty_value, std::move(path)));
+  }
+
+  static IdentifierInfoPtr FromThisKeyword(CompilerType type) {
+lldb::ValueObjectSP empty_value;
+return IdentifierInfoPtr(
+new 

[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,43 @@
+(* LLDB Debug Expressions, a subset of C++ *)
+(* Insired by https://www.nongnu.org/hcb *)
+
+expression = cast_expression;
+
+cast_expression = unary_expression;
+
+unary_expression = postfix_expression
+ | unary_operator cast_expression;
+
+unary_operator = "*" | "&" | "-" ;
+
+postfix_expression = primary_expression
+   | postfix_expression "[" expression "]"
+   | postfix_expression "." id_expression
+   | postfix_expression "->" id_expression
+
+primary_expression = numeric_literal
+   | boolean_literal
+   | pointer_literal
+   | id_expression
+   | "this" ;

labath wrote:

Other languages may use a different keyword (`self` typically) to refer to 
"this" object (in which case `this` can refer to a regular variable). 
Special-casing `this` in the parser could make that difficult, so it may be 
better to treat `this` as a regular identifier, and only resolve it later, once 
we know which language we're in.

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {
+
+/// Struct to hold information about member fields. Used by the parser for the
+/// Data Inspection Language (DIL).
+struct DILMemberInfo {
+  std::optional name;
+  CompilerType type;
+  bool is_bitfield;
+  uint32_t bitfield_size_in_bits;
+  bool is_synthetic;
+  bool is_dynamic;
+  lldb::ValueObjectSP val_obj_sp;
+
+  explicit operator bool() const { return type.IsValid(); }
+};
+
+/// This determines if the type is a shared, unique or weak pointer, either
+/// from stdlibc++ or libc+++.
+bool IsSmartPtrType(CompilerType type);
+
+/// Finds the member field with the given name and type, stores the child index
+/// corresponding to the field in the idx vector and returns a DILMemberInfo
+/// struct with appropriate information about the field.
+DILMemberInfo GetFieldWithNameIndexPath(lldb::ValueObjectSP lhs_val_sp,
+CompilerType type,
+const std::string ,
+std::vector *idx,
+CompilerType empty_type,
+bool use_synthetic, bool is_dynamic);
+
+std::tuple>
+GetMemberInfo(lldb::ValueObjectSP lhs_val_sp, CompilerType type,
+  const std::string , bool use_synthetic);
+
+/// Get the appropriate ValueObjectSP, consulting the use_dynamic and
+/// use_synthetic options passed, acquiring the process & target locks if
+/// appropriate.
+lldb::ValueObjectSP
+DILGetSPWithLock(lldb::ValueObjectSP valobj_sp,
+ lldb::DynamicValueType use_dynamic = lldb::eNoDynamicValues,
+ bool use_synthetic = false);
+
+/// The various types DIL AST nodes (used by the DIL parser).
+enum class DILNodeKind {
+  kDILErrorNode,
+  kLiteralNode,
+  kIdentifierNode,
+  kBuiltinFunctionCallNode,
+  kCStyleCastNode,
+  kMemberOfNode,
+  kArraySubscriptNode,
+  kUnaryOpNode,
+  kSmartPtrToPtrDecay
+};
+
+/// The C-Style casts allowed by DIL.
+enum class CStyleCastKind {
+  kArithmetic,
+  kEnumeration,
+  kPointer,
+  kNullptr,
+  kReference,
+};
+
+/// The Unary operators recognized by DIL.
+enum class UnaryOpKind {
+  AddrOf, // "&"
+  Deref,  // "*"
+  Minus,  // "-"
+};
+
+/// Given a string representing a type, returns the CompilerType corresponding
+/// to the named type, if it exists.
+CompilerType
+ResolveTypeByName(const std::string ,
+  std::shared_ptr ctx_scope);
+
+/// Quick lookup to check if a type name already exists in a
+/// name-to-CompilerType map the DIL parser keeps of previously found
+/// name/type pairs.
+bool IsContextVar(const std::string );
+
+/// Checks to see if the CompilerType is a Smart Pointer (shared, unique, weak)
+/// or not. Only applicable for C++, which is why this is here and not part of
+/// the CompilerType class.
+bool IsSmartPtrType(CompilerType type);
+
+/// Class used to store & manipulate information about identifiers.
+class IdentifierInfo {
+private:
+  using MemberPath = std::vector;
+  using IdentifierInfoPtr = std::unique_ptr;

labath wrote:

elsewhere, we'd use IdentifierInfoUP

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,468 @@
+//===-- DILAST.cpp 
===//
+//
+// 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 "lldb/Core/DILAST.h"
+#include "lldb/API/SBType.h"
+#include "lldb/Core/ValueObjectRegister.h"
+#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Target/RegisterContext.h"
+#include "llvm/ADT/StringRef.h"
+
+#include 
+
+namespace lldb_private {
+
+lldb::ValueObjectSP DILGetSPWithLock(lldb::ValueObjectSP in_valobj_sp,
+ lldb::DynamicValueType use_dynamic,
+ bool use_synthetic) {
+  Process::StopLocker stop_locker;
+  std::unique_lock lock;
+  Status error;
+
+  if (!in_valobj_sp) {
+error.SetErrorString("invalid value object");
+return in_valobj_sp;
+  }
+
+  lldb::ValueObjectSP value_sp = in_valobj_sp;
+
+  Target *target = value_sp->GetTargetSP().get();
+  // If this ValueObject holds an error, then it is valuable for that.
+  if (value_sp->GetError().Fail())
+return value_sp;
+
+  if (!target)
+return lldb::ValueObjectSP();
+
+  lock = std::unique_lock(target->GetAPIMutex());
+
+  lldb::ProcessSP process_sp(value_sp->GetProcessSP());
+  if (process_sp && !stop_locker.TryLock(_sp->GetRunLock())) {
+// We don't allow people to play around with ValueObject if the process
+// is running. If you want to look at values, pause the process, then
+// look.
+error.SetErrorString("process must be stopped.");
+return lldb::ValueObjectSP();
+  }
+
+  if (use_dynamic != lldb::eNoDynamicValues) {
+lldb::ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(use_dynamic);
+if (dynamic_sp)
+  value_sp = dynamic_sp;
+  }
+
+  if (use_synthetic) {
+lldb::ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue();
+if (synthetic_sp)
+  value_sp = synthetic_sp;
+  }
+
+  if (!value_sp)
+error.SetErrorString("invalid value object");
+
+  return value_sp;
+}
+
+CompilerType DILASTNode::result_type_deref() const {
+  auto type = result_type();
+  return type.IsReferenceType() ? type.GetNonReferenceType() : type;
+}
+
+static std::unordered_map context_args;
+
+bool IsContextVar(const std::string ) {
+  return context_args.find(name) != context_args.end();
+}

labath wrote:

This definitely needs to be scoped to something (and not a global), but since 
its not used right now, let's remove it.

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,446 @@
+//===-- DILAST.h *- 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 LLDB_DIL_AST_H_
+#define LLDB_DIL_AST_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/LanguageRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+
+namespace lldb_private {

labath wrote:

Some of the names defined here have embedded namespace names (DILMemberInfo), 
while others (IdentifierInfo) have deceptively generic name even though they're 
specific to the DIL. What do you (all) think about putting all of this in a 
namespace (I suggest `dil`)?

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


[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)

2024-07-09 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

> BTW, I have verified that this stripped down version passes all the frame 
> variable tests in LLDB.

That's cool. Just to confirm, have you looked at replacing `target variable` as 
well? It uses the same language as "frame var" under the hood, which  but it 
has a somewhat different starting point (it basically ignores the local scope 
and looks only at globals), which means it may need some special handling in 
the new parser.

> I agree with Jim re the DIL language: We should only have a single language 
> definition, and it can be a superset of the languages it supports. So there 
> may be parts of it that belong to particular languages, but that does not 
> mean it supports those languages exclusively.

This direction makes sense to me, but I think that's all the more reason to be 
conservative/cautious about adding new features to the language. We can't just 
put every possible feature of every language into it, as we'd end up with a 
unmaintainable mess.

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


[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

2024-07-09 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Fair point, iirc all the callers go on to iterate the map so no one is handling 
failure in a special way. I'll update this.

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


[Lldb-commits] [lldb] [lldb][NFC] Add maybe_unused to err used in asserts (PR #98055)

2024-07-09 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] ae5aebd - [lldb][NFC] Add maybe_unused to err used in asserts (#98055)

2024-07-09 Thread via lldb-commits

Author: Keith Smiley
Date: 2024-07-09T10:35:56+01:00
New Revision: ae5aebd48df8d15f06a7a9aa7a9e193d32cd5c85

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

LOG: [lldb][NFC] Add maybe_unused to err used in asserts (#98055)

Added: 


Modified: 
lldb/tools/debugserver/source/PThreadMutex.h

Removed: 




diff  --git a/lldb/tools/debugserver/source/PThreadMutex.h 
b/lldb/tools/debugserver/source/PThreadMutex.h
index a4535dd79172c..17f9fdff5f2d3 100644
--- a/lldb/tools/debugserver/source/PThreadMutex.h
+++ b/lldb/tools/debugserver/source/PThreadMutex.h
@@ -78,13 +78,13 @@ class PThreadMutex {
   };
 
   PThreadMutex() {
-int err;
+[[maybe_unused]] int err;
 err = ::pthread_mutex_init(_mutex, NULL);
 assert(err == 0);
   }
 
   PThreadMutex(int type) {
-int err;
+[[maybe_unused]] int err;
 ::pthread_mutexattr_t attr;
 err = ::pthread_mutexattr_init();
 assert(err == 0);
@@ -97,7 +97,7 @@ class PThreadMutex {
   }
 
   ~PThreadMutex() {
-int err;
+[[maybe_unused]] int err;
 err = ::pthread_mutex_destroy(_mutex);
 if (err != 0) {
   err = Unlock();



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


[Lldb-commits] [lldb] [lldb] Correct invalid format style (PR #98089)

2024-07-09 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] cd89d92 - [lldb] Correct invalid format style (#98089)

2024-07-09 Thread via lldb-commits

Author: Alex Langford
Date: 2024-07-09T09:34:06+01:00
New Revision: cd89d926aed1de3d1255043eba39801b54393040

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

LOG: [lldb] Correct invalid format style (#98089)

Fixes https://github.com/llvm/llvm-project/issues/97511

Added: 


Modified: 
lldb/source/Target/StackFrameList.cpp

Removed: 




diff  --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 314b5e39c7169..0cf9ce1bf043f 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -966,9 +966,9 @@ size_t StackFrameList::GetStatus(Stream , uint32_t 
first_frame,
 // Check for interruption here.  If we're fetching arguments, this loop
 // can go slowly:
 Debugger  = m_thread.GetProcess()->GetTarget().GetDebugger();
-if (INTERRUPT_REQUESTED(dbg, 
-  "Interrupted dumping stack for thread {0:hex} with {1} shown.",
-  m_thread.GetID(), num_frames_displayed))
+if (INTERRUPT_REQUESTED(
+dbg, "Interrupted dumping stack for thread {0:x} with {1} shown.",
+m_thread.GetID(), num_frames_displayed))
   break;
 
 



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


[Lldb-commits] [lldb] [lldb] Put the new debugger in synchronous mode in TestGlobalModuleCache (PR #98041)

2024-07-09 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `lldb` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/59/builds/1234

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-index-is-used.cpp (1606 of 1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-implicit-const.s (1607 of 1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5_locations.s (1608 of 1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-line-strp.s (1609 of 1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5_tu_index_abbrev_offset.s (1610 
of 1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-split.s (1611 of 1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwarf5-partial-index.cpp (1612 of 1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwo-not-found-warning.cpp (1613 of 
1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwo-type-in-main-file.s (1614 of 1989)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dwp-debug-types.s (1615 of 1989)
FAIL: lldb-shell :: SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp (1616 of 
1989)
 TEST 'lldb-shell :: 
SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 21: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
-gdwarf-5 -gsplit-dwarf-fdebug-types-section -gpubnames -c 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp
 -o 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.main.o
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
-gdwarf-5 -gsplit-dwarf -fdebug-types-section -gpubnames -c 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp
 -o 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.main.o
RUN: at line 23: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
-gdwarf-5 -gsplit-dwarf -DVARIANT-fdebug-types-section -gpubnames -c 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp
 -o 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.foo.o
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang 
--target=specify-a-target-or-use-a-_host-substitution -target x86_64-pc-linux 
-gdwarf-5 -gsplit-dwarf -DVARIANT -fdebug-types-section -gpubnames -c 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp
 -o 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.foo.o
RUN: at line 25: 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/ld.lld 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.main.o
 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.foo.o
 -o 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp
+ /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/ld.lld 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.main.o
 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.foo.o
 -o 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp
ld.lld: warning: cannot find entry symbol _start; not setting start address
RUN: at line 28: rm -f 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.dwp
+ rm -f 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/SymbolFile/DWARF/x86/Output/dwp-foreign-type-units.cpp.tmp.dwp
RUN: at line 29: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb 
--no-lldbinit -S 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/Shell/lit-lldb-init-quiet
-o "type lookup IntegerType"-o "type lookup FloatType" 

[Lldb-commits] [lldb] [lldb] Put the new debugger in synchronous mode in TestGlobalModuleCache (PR #98041)

2024-07-09 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] 58e750b - [lldb] Put the new debugger in synchronous mode in TestGlobalModuleCache (#98041)

2024-07-09 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-07-09T09:59:49+02:00
New Revision: 58e750bfd621ac7ef8647eb1170b254e05ffc10d

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

LOG: [lldb] Put the new debugger in synchronous mode in TestGlobalModuleCache 
(#98041)

In async mode, the test terminates sooner than it should
(`run_to_source_breakpoint` does not work in this mode), and then the
test crashes due to #76057. Most of the time, the test does not fail
because its already XFAILed, but the crash still registers as a failure.

Added: 


Modified: 
lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py

Removed: 




diff  --git 
a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py 
b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
index 0942dcd655b75..ccefc28946e06 100644
--- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
+++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
@@ -111,6 +111,7 @@ def do_test(self, one_target, one_debugger):
 else:
 if one_target:
 new_debugger = lldb.SBDebugger().Create()
+new_debugger.SetAsync(False)
 self.old_debugger = self.dbg
 self.dbg = new_debugger
 



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


[Lldb-commits] [lldb] [lldb] Put the new debugger in synchronous mode in TestGlobalModuleCache (PR #98041)

2024-07-08 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Correct invalid format style (PR #98089)

2024-07-08 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-08 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

Thanks again for all the help @AlexK0 I pushed an update that should compile 
correctly with my update.  It's great to hear that the testsuite looks clean -- 
that's the part that worried me the most about these changes.

I finished an aarch64 Ubuntu testsuite run and it is clean.  I think this patch 
is about ready for review by @jimingham when he has time.

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-08 Thread Jason Molenda via lldb-commits

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

>From 9b541e6a035635e26c6a24eca022de8552fa4c17 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 20 Jun 2024 17:53:17 -0700
Subject: [PATCH 1/6] [lldb] Change lldb's breakpoint handling behavior

lldb today has two rules:  When a thread stops at a BreakpointSite,
we set the thread's StopReason to be "breakpoint hit" (regardless
if we've actually hit the breakpoint, or if we've merely stopped
*at* the breakpoint instruction/point and haven't tripped it yet).
And second, when resuming a process, any thread sitting at a
BreakpointSite is silently stepped over the BreakpointSite -- because
we've already flagged the breakpoint hit when we stopped there
originally.

In this patch, I change lldb to only set a thread's stop reason to
breakpoint-hit when we've actually executed the instruction/triggered
the breakpoint.  When we resume, we only silently step past a
BreakpointSite that we've registered as hit.  We preserve this state
across inferior function calls that the user may do while stopped,
etc.

Also, when a user adds a new breakpoint at $pc while stopped, or
changes $pc to be the address of a BreakpointSite, we will silently
step past that breakpoint when the process resumes.  This is purely
a UX call, I don't think there's any person who wants to set a
breakpoint at $pc and then hit it immediately on resuming.

One non-intuitive UX from this change, but I'm convinced it is
necessary:  If you're stopped at a BreakpointSite that has not yet
executed, you `stepi`, you will hit the breakpoint and the pc will
not yet advance.  This thread has not completed its stepi, and the
thread plan is still on the stack.  If you then `continue` the
thread, lldb will now stop and say, "instruction step completed",
one instruction past the BreakpointSite.  You can continue a second
time to resume execution.  I discussed this with Jim, and trying
to paper over this behavior will lead to more complicated scenarios
behaving non-intuitively.  And mostly it's the testsuite that was
trying to instruction step past a breakpoint and getting thrown off
-- and I changed those tests to expect the new behavior.

The bugs driving this change are all from lldb dropping the real
stop reason for a thread and setting it to breakpoint-hit when that
was not the case.  Jim hit one where we have an aarch64 watchpoint
that triggers one instruction before a BreakpointSite.  On this
arch we are notified of the watchpoint hit after the instruction
has been unrolled -- we disable the watchpoint, instruction step,
re-enable the watchpoint and collect the new value.  But now we're
on a BreakpointSite so the watchpoint-hit stop reason is lost.

Another was reported by ZequanWu in
https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282
we attach to/launch a process with the pc at a BreakpointSite and
misbehave.  Caroline Tice mentioned it is also a problem they've
had with putting a breakpoint on _dl_debug_state.

The change to each Process plugin that does execution control
is that

1. If we've stopped at a BreakpointSite (whether we hit it or not),
we call Thread::SetThreadStoppedAtBreakpointSite(pc) to record the
state at the point when the thread stopped.  (so we can detect
newly-added breakpoints, or when the pc is changed to an instruction
that is a BreakpointSite)

2. When we have actually hit a breakpoint, and it is enabled for
this thread, we call Thread::SetThreadHitBreakpointAtAddr(pc) so
we know that it should be silently stepped past when we resume
execution.

When resuming, we silently step over a breakpoint if we've hit it,
or if it is newly added (or the pc was changed to an existing
BreakpointSite).

The biggest set of changes is to StopInfoMachException where we
translate a Mach Exception into a stop reason.  The Mach exception
codes differ in a few places depending on the target (unambiguously),
and I didn't want to duplicate the new code for each target so I've
tested what mach exceptions we get for each action on each target,
and reorganized StopInfoMachException::CreateStopReasonWithMachException
to document these possible values, and handle them without specializing
based on the target arch.

rdar://123942164
---
 lldb/include/lldb/Target/Thread.h |  29 ++
 .../Process/Utility/StopInfoMachException.cpp | 296 +++---
 .../Process/Windows/Common/ProcessWindows.cpp |  16 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 118 +++
 .../Process/scripted/ScriptedThread.cpp   |   9 +
 lldb/source/Target/Thread.cpp |  17 +-
 .../TestConsecutiveBreakpoints.py |  26 +-
 .../TestStepOverBreakpoint.py |   6 +-
 8 files changed, 235 insertions(+), 282 deletions(-)

diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index c17bddf4d98b8..1e1aead896018 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ 

[Lldb-commits] [lldb] Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (PR #98101)

2024-07-08 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] b2fd1eb - Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (#98101)

2024-07-08 Thread via lldb-commits

Author: Kevin Frei
Date: 2024-07-08T17:59:00-07:00
New Revision: b2fd1ebc3523d225956120052bcc0698adf4579f

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

LOG: Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (#98101)

Reverts llvm/llvm-project#96802

Attempt #5 fails. It's been 6 months. I despise Makefile.rules and have
no ability to even *detect* these failures without _landing_ a diff. In
the mean time, we have no testing for DWP files at all (and a regression
that was introduced, that I fix with this diff) so I'm going to just
remove some of the tests and try to land it again, but with less testing
I guess.

Added: 


Modified: 
lldb/include/lldb/Host/Config.h.cmake
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/source/API/SBDebugger.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp

Removed: 
lldb/test/API/debuginfod/Normal/Makefile
lldb/test/API/debuginfod/Normal/TestDebuginfod.py
lldb/test/API/debuginfod/Normal/main.c
lldb/test/API/debuginfod/SplitDWARF/Makefile
lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
lldb/test/API/debuginfod/SplitDWARF/main.c



diff  --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 9e538534086a2..3defa454f6d42 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,8 +33,6 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
-#cmakedefine01 LLVM_ENABLE_CURL
-
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 0e8ca159efd55..ecc7b81035f11 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1053,10 +1053,6 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
-def skipIfCurlSupportMissing(func):
-return _get_bool_config_skip_if_decorator("curl")(func)
-
-
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 

diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index a7d9d34509f5d..bd8eea3d6f5a0 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here.
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,12 +210,6 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
-
-   ifeq "$(MAKE_DWP)" "YES"
-   MAKE_DWO := YES
-   DWP_NAME = $(EXE).dwp
-   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
-   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -364,17 +358,6 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
-   # Look for llvm-dwp or gnu dwp
-   DWP ?= $(call replace_cc_with,llvm-dwp)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(call replace_cc_with,dwp)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(shell command -v llvm-dwp 2> /dev/null)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(shell command -v dwp 2> /dev/null)
-   endif
-   endif
-   endif
override AR = $(ARCHIVER)
 endif
 
@@ -545,10 +528,6 @@ ifneq "$(CXX)" ""
endif
 endif
 
-ifeq "$(GEN_GNU_BUILD_ID)" "YES"
-   LDFLAGS += -Wl,--build-id
-endif
-
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -587,18 +566,11 @@ else
 endif
 else
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
-ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
-   cp "$(EXE)" "$(EXE).unstripped"
-endif
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
$(OBJCOPY) 

[Lldb-commits] [lldb] Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (PR #98101)

2024-07-08 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (PR #98101)

2024-07-08 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff f6eda6fb7a335861d8a8ce32ea805830685f218d 
76f102112c8a8a1292929b65ebb7db8b033ee344 -- lldb/source/API/SBDebugger.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 29da7d33dd..683cee0878 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1724,20 +1724,20 @@ SBDebugger::LoadTraceFromFile(SBError ,
 
 void SBDebugger::RequestInterrupt() {
   LLDB_INSTRUMENT_VA(this);
-  
+
   if (m_opaque_sp)
-m_opaque_sp->RequestInterrupt();  
+m_opaque_sp->RequestInterrupt();
 }
 void SBDebugger::CancelInterruptRequest()  {
   LLDB_INSTRUMENT_VA(this);
-  
+
   if (m_opaque_sp)
-m_opaque_sp->CancelInterruptRequest();  
+m_opaque_sp->CancelInterruptRequest();
 }
 
 bool SBDebugger::InterruptRequested()   {
   LLDB_INSTRUMENT_VA(this);
-  
+
   if (m_opaque_sp)
 return m_opaque_sp->InterruptRequested();
   return false;

``




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


[Lldb-commits] [lldb] Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (PR #98101)

2024-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Kevin Frei (kevinfrei)


Changes

Reverts llvm/llvm-project#96802

Attempt #5 fails. It's been 6 months. I despise Makefile.rules and have 
no ability to even *detect* these failures without _landing_ a diff. In the 
mean time, we have no testing for DWP files at all (and a regression that was 
introduced, that I fix with this diff) so I'm going to just remove some of the 
tests and try to land it again, but with less testing I guess.

---

Patch is 27.92 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/98101.diff


13 Files Affected:

- (modified) lldb/include/lldb/Host/Config.h.cmake (-2) 
- (modified) lldb/packages/Python/lldbsuite/test/decorators.py (-4) 
- (modified) lldb/packages/Python/lldbsuite/test/make/Makefile.rules (+1-35) 
- (modified) lldb/source/API/SBDebugger.cpp (+5-8) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+13-25) 
- (modified) lldb/source/Plugins/SymbolLocator/CMakeLists.txt (+1-6) 
- (modified) lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp (+2-27) 
- (removed) lldb/test/API/debuginfod/Normal/Makefile (-19) 
- (removed) lldb/test/API/debuginfod/Normal/TestDebuginfod.py (-186) 
- (removed) lldb/test/API/debuginfod/Normal/main.c (-7) 
- (removed) lldb/test/API/debuginfod/SplitDWARF/Makefile (-23) 
- (removed) lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py (-196) 
- (removed) lldb/test/API/debuginfod/SplitDWARF/main.c (-7) 


``diff
diff --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 9e538534086a2..3defa454f6d42 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,8 +33,6 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
-#cmakedefine01 LLVM_ENABLE_CURL
-
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 0e8ca159efd55..ecc7b81035f11 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1053,10 +1053,6 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
-def skipIfCurlSupportMissing(func):
-return _get_bool_config_skip_if_decorator("curl")(func)
-
-
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index a7d9d34509f5d..bd8eea3d6f5a0 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here.
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,12 +210,6 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
-
-   ifeq "$(MAKE_DWP)" "YES"
-   MAKE_DWO := YES
-   DWP_NAME = $(EXE).dwp
-   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
-   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -364,17 +358,6 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
-   # Look for llvm-dwp or gnu dwp
-   DWP ?= $(call replace_cc_with,llvm-dwp)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(call replace_cc_with,dwp)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(shell command -v llvm-dwp 2> /dev/null)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(shell command -v dwp 2> /dev/null)
-   endif
-   endif
-   endif
override AR = $(ARCHIVER)
 endif
 
@@ -545,10 +528,6 @@ ifneq "$(CXX)" ""
endif
 endif
 
-ifeq "$(GEN_GNU_BUILD_ID)" "YES"
-   LDFLAGS += -Wl,--build-id
-endif
-
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -587,18 +566,11 @@ else
 endif
 else
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
-ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
-   cp "$(EXE)" "$(EXE).unstripped"
-endif
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
$(OBJCOPY) --strip-debug 

[Lldb-commits] [lldb] [lldb] Correct invalid format style (PR #98089)

2024-07-08 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.


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


[Lldb-commits] [lldb] Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (PR #98101)

2024-07-08 Thread Kevin Frei via lldb-commits

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


[Lldb-commits] [lldb] Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build" (PR #98101)

2024-07-08 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei created 
https://github.com/llvm/llvm-project/pull/98101

Reverts llvm/llvm-project#96802

Attempt #5 fails. It's been 6 months. I despise Makefile.rules and have no 
ability to even *detect* these failures without _landing_ a diff. In the mean 
time, we have no testing for DWP files at all (and a regression that was 
introduced, that I fix with this diff) so I'm going to just remove some of the 
tests and try to land it again, but with less testing I guess.

>From 76f102112c8a8a1292929b65ebb7db8b033ee344 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Mon, 8 Jul 2024 17:07:16 -0700
Subject: [PATCH] Revert "[LLDB] DebugInfoD tests: attempt to fix Fuchsia build
 (#96802)"

This reverts commit 2a7abb04e258542679476fa6527418c34412283c.
---
 lldb/include/lldb/Host/Config.h.cmake |   2 -
 .../Python/lldbsuite/test/decorators.py   |   4 -
 .../Python/lldbsuite/test/make/Makefile.rules |  36 +---
 lldb/source/API/SBDebugger.cpp|  13 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  38 ++--
 .../Plugins/SymbolLocator/CMakeLists.txt  |   7 +-
 .../SymbolVendor/ELF/SymbolVendorELF.cpp  |  29 +--
 lldb/test/API/debuginfod/Normal/Makefile  |  19 --
 .../API/debuginfod/Normal/TestDebuginfod.py   | 186 -
 lldb/test/API/debuginfod/Normal/main.c|   7 -
 lldb/test/API/debuginfod/SplitDWARF/Makefile  |  23 --
 .../SplitDWARF/TestDebuginfodDWP.py   | 196 --
 lldb/test/API/debuginfod/SplitDWARF/main.c|   7 -
 13 files changed, 22 insertions(+), 545 deletions(-)
 delete mode 100644 lldb/test/API/debuginfod/Normal/Makefile
 delete mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py
 delete mode 100644 lldb/test/API/debuginfod/Normal/main.c
 delete mode 100644 lldb/test/API/debuginfod/SplitDWARF/Makefile
 delete mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
 delete mode 100644 lldb/test/API/debuginfod/SplitDWARF/main.c

diff --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 9e538534086a2..3defa454f6d42 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,8 +33,6 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
-#cmakedefine01 LLVM_ENABLE_CURL
-
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 0e8ca159efd55..ecc7b81035f11 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1053,10 +1053,6 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
-def skipIfCurlSupportMissing(func):
-return _get_bool_config_skip_if_decorator("curl")(func)
-
-
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index a7d9d34509f5d..bd8eea3d6f5a0 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here.
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,12 +210,6 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
-
-   ifeq "$(MAKE_DWP)" "YES"
-   MAKE_DWO := YES
-   DWP_NAME = $(EXE).dwp
-   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
-   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -364,17 +358,6 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
-   # Look for llvm-dwp or gnu dwp
-   DWP ?= $(call replace_cc_with,llvm-dwp)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(call replace_cc_with,dwp)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(shell command -v llvm-dwp 2> /dev/null)
-   ifeq ($(wildcard $(DWP)),)
-   DWP = $(shell command -v dwp 2> /dev/null)
-   endif
-   endif
-   endif
override AR = $(ARCHIVER)
 endif
 
@@ -545,10 +528,6 @@ ifneq "$(CXX)" ""
endif
 endif
 
-ifeq "$(GEN_GNU_BUILD_ID)" "YES"
-   LDFLAGS += -Wl,--build-id
-endif
-
 

[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-07-08 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `lldb` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/59/builds/1213

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
UNSUPPORTED: lldb-api :: 
commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py 
(262 of 1991)
PASS: lldb-api :: 
commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py (263 of 
1991)
PASS: lldb-api :: 
commands/watchpoints/watchpoint_events/TestWatchpointEvents.py (264 of 1991)
PASS: lldb-api :: 
commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py (265 of 1991)
PASS: lldb-api :: 
commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py (266 of 
1991)
UNSUPPORTED: lldb-api :: driver/batch_mode/TestBatchMode.py (267 of 1991)
UNSUPPORTED: lldb-api :: driver/job_control/TestJobControl.py (268 of 1991)
PASS: lldb-api :: debuginfod/Normal/TestDebuginfod.py (269 of 1991)
PASS: lldb-api :: functionalities/abbreviation/TestAbbreviations.py (270 of 
1991)
UNRESOLVED: lldb-api :: debuginfod/SplitDWARF/TestDebuginfodDWP.py (271 of 1991)
 TEST 'lldb-api :: 
debuginfod/SplitDWARF/TestDebuginfodDWP.py' FAILED 
Script:
--
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb 
--lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/debuginfod/SplitDWARF
 -p TestDebuginfodDWP.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision 
2a7abb04e258542679476fa6527418c34412283c)
  clang revision 2a7abb04e258542679476fa6527418c34412283c
  llvm revision 2a7abb04e258542679476fa6527418c34412283c
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_debuginfod_both_okd_symfiles_from_service 
(TestDebuginfodDWP.DebugInfodDWPTests) (requires curl) 
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_debuginfod_both_symfiles_from_service 
(TestDebuginfodDWP.DebugInfodDWPTests) (requires curl) 
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_debuginfod_dwp_from_service (TestDebuginfodDWP.DebugInfodDWPTests) 
(requires curl) 
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_normal_stripped (TestDebuginfodDWP.DebugInfodDWPTests)
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_normal_stripped_only_dwp (TestDebuginfodDWP.DebugInfodDWPTests)
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_normal_stripped_split_with_dwp (TestDebuginfodDWP.DebugInfodDWPTests)
==
ERROR: test_normal_stripped (TestDebuginfodDWP.DebugInfodDWPTests)
   Validate behavior with a stripped binary, no symbols or symbol locator.
--
Error when building test subject.

Build Command:
make 
VPATH=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/debuginfod/SplitDWARF
 -C 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/debuginfod/SplitDWARF/TestDebuginfodDWP.test_normal_stripped
 -I 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/debuginfod/SplitDWARF
 -I 

[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-07-08 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] 2a7abb0 - [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (#96802)

2024-07-08 Thread via lldb-commits

Author: Kevin Frei
Date: 2024-07-08T16:44:16-07:00
New Revision: 2a7abb04e258542679476fa6527418c34412283c

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

LOG: [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (#96802)

This is the same diff I've put up at many times before. I've been trying
to add some brand new functionality to the LLDB test infrastucture
(create split-dwarf files!), and we all know that no good deed goes
unpunished. The last attempt was reverted because it didn't work on the
Fuchsia build.

There are no code differences between this and
[the](https://github.com/llvm/llvm-project/pull/90622)
[previous](https://github.com/llvm/llvm-project/pull/87676)
[four](https://github.com/llvm/llvm-project/pull/86812)
[diffs](https://github.com/llvm/llvm-project/pull/85693) landed &
reverted (due to testing infra failures). The only change in this one is
the way `dwp` is being identified in `Makefile.rules`.

Thanks to @petrhosek for helping me figure out how the fuchsia builders
are configured. I now prefer to use llvm-dwp and fall back to gnu's dwp
if the former isn't found. Hopefully this will work everywhere it needs
to.

Added: 
lldb/test/API/debuginfod/Normal/Makefile
lldb/test/API/debuginfod/Normal/TestDebuginfod.py
lldb/test/API/debuginfod/Normal/main.c
lldb/test/API/debuginfod/SplitDWARF/Makefile
lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
lldb/test/API/debuginfod/SplitDWARF/main.c

Modified: 
lldb/include/lldb/Host/Config.h.cmake
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/source/API/SBDebugger.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 3defa454f6d42..9e538534086a2 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,6 +33,8 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
+#cmakedefine01 LLVM_ENABLE_CURL
+
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index ecc7b81035f11..0e8ca159efd55 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1053,6 +1053,10 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
+def skipIfCurlSupportMissing(func):
+return _get_bool_config_skip_if_decorator("curl")(func)
+
+
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 

diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bd8eea3d6f5a0..a7d9d34509f5d 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here. 
+# standardize on "Windows_NT", so we'll make it consistent here.
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,6 +210,12 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
+
+   ifeq "$(MAKE_DWP)" "YES"
+   MAKE_DWO := YES
+   DWP_NAME = $(EXE).dwp
+   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
+   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -358,6 +364,17 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
+   # Look for llvm-dwp or gnu dwp
+   DWP ?= $(call replace_cc_with,llvm-dwp)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(call replace_cc_with,dwp)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(shell command -v llvm-dwp 2> /dev/null)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(shell command -v dwp 2> /dev/null)
+   endif
+   endif
+   endif
override AR = $(ARCHIVER)
 endif
 
@@ -528,6 +545,10 @@ ifneq "$(CXX)" ""
endif
 endif
 
+ifeq 

[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-07-08 Thread via lldb-commits

jimingham wrote:

> > Why does the ThreadPlanSingleThreadTimeout have to claim to explain stops 
> > (like a random breakpoint hit) that on the face of it it's not responsible 
> > for
> 
> Just a quick comment to add the context for this question: we are doing so to 
> ensure `ThreadPlanSingleThreadTimeout` can stay in the leaf thread plan. And 
> it comes from your suggestion `So ThreadPlanSingleThreadTimeout should always 
> say it explains the stop` in this comment: 
> https://discourse.llvm.org/t/improve-single-thread-stepping/74599/17?u=jeffreytan81

So maybe we need to do something explicit here.  

The ThreadPlanSingleThreadTimeout's desired behavior, IIUC, is either it 
explains the stop or it should get discarded.  I can't think of any instance 
where it should stay on the stack when there's a stop that's not for the 
timeout.  If, for instance, you hit a "next range" breakpoint for a "step over" 
then we're going to remove the plan and have the thread plan push it again when 
you resume.

So instead of semi-lying about whether it actually explains stops it knows 
nothing about, can we add the concept of a plan that "has to be a leaf plan".  
So if it doesn't explain a stop during ShouldStop, it will get popped right 
away.  So after we check "plan explains stop" and get `false` back, we check 
IsLeafPlan, and if that returns true, pop the plan and go on to the next plan.

The harder option is to either convert the ShouldStop to a single loop that 
re-enters if the plan that explained the stop returns True to MischiefManaged, 
or to figure out why the second loop is behaving asymmetrically to the first.  
We ought to do the first at some point, but that's probably a lot more work.

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


[Lldb-commits] [clang] [lldb] [llvm] [BOLT][DWARF][NFC] Refactor address writers (PR #98094)

2024-07-08 Thread Sayhaan Siddiqui via lldb-commits

https://github.com/sayhaan created 
https://github.com/llvm/llvm-project/pull/98094

Refactors address writers to create an instance for each CU and its DWO CU.

>From b2fe35ae825dc757ea1daaf49142e789c4a560fc Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Tue, 1 Jun 2021 11:37:41 -0700
Subject: [PATCH 1/8] Rebase: [Facebook] Add clang driver options to test debug
 info and BOLT

Summary:
This is an essential piece of infrastructure for us to be
continuously testing debug info with BOLT. We can't only make changes
to a test repo because we need to change debuginfo tests to call BOLT,
hence, this diff needs to sit in our opensource repo. But when upstreaming
to LLVM, this should be kept BOLT-only outside of LLVM. When upstreaming,
we need to git diff and check all folders that are being modified by our
commits and discard this one (and leave as an internal diff).

To test BOLT in debuginfo tests, configure it with -DLLVM_TEST_BOLT=ON.
Then run check-lldb and check-debuginfo.

Manual rebase conflict history:
https://phabricator.intern.facebook.com/D29205224
https://phabricator.intern.facebook.com/D29564078
https://phabricator.intern.facebook.com/D33289118
https://phabricator.intern.facebook.com/D34957174
https://phabricator.intern.facebook.com/D35317341

Test Plan:
tested locally
Configured with:
-DLLVM_ENABLE_PROJECTS="clang;lld;lldb;compiler-rt;bolt;debuginfo-tests"
-DLLVM_TEST_BOLT=ON
Ran test suite with:
ninja check-debuginfo
ninja check-lldb

Reviewers: maks, #llvm-bolt

Reviewed By: maks

Subscribers: ayermolo, phabricatorlinter

Differential Revision: https://phabricator.intern.facebook.com/D46256657

Tasks: T92898286
---
 clang/include/clang/Driver/Options.td  |  4 
 clang/lib/Driver/ToolChains/Gnu.cpp| 29 ++
 cross-project-tests/lit.cfg.py | 14 -
 cross-project-tests/lit.site.cfg.py.in |  4 
 lldb/test/API/lit.cfg.py   |  5 +
 lldb/test/API/lit.site.cfg.py.in   |  8 +++
 lldb/test/Shell/helper/toolchain.py|  5 +
 lldb/test/Shell/lit.site.cfg.py.in |  9 
 llvm/CMakeLists.txt|  4 
 9 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d44faa55c456f..63bb86717bb14 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5483,6 +5483,10 @@ def pg : Flag<["-"], "pg">, HelpText<"Enable mcount 
instrumentation">,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
   HelpText<"Use pipes between commands, when possible">;
+// Facebook T92898286
+def post_link_optimize : Flag<["--"], "post-link-optimize">,
+  HelpText<"Apply post-link optimizations using BOLT">;
+// End Facebook T92898286
 def prebind__all__twolevel__modules : Flag<["-"], 
"prebind_all_twolevel_modules">;
 def prebind : Flag<["-"], "prebind">;
 def preload : Flag<["-"], "preload">;
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index b141e5f2adfab..f7611af5763ab 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -672,12 +672,41 @@ void tools::gnutools::Linker::ConstructJob(Compilation 
, const JobAction ,
 }
   }
 
+  // Facebook T92898286
+  if (Args.hasArg(options::OPT_post_link_optimize))
+CmdArgs.push_back("-q");
+  // End Facebook T92898286
+
   Args.AddAllArgs(CmdArgs, options::OPT_T);
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
  Exec, CmdArgs, Inputs, Output));
+  // Facebook T92898286
+  if (!Args.hasArg(options::OPT_post_link_optimize) || !Output.isFilename())
+return;
+
+  const char *MvExec = Args.MakeArgString(ToolChain.GetProgramPath("mv"));
+  ArgStringList MoveCmdArgs;
+  MoveCmdArgs.push_back(Output.getFilename());
+  const char *PreBoltBin =
+  Args.MakeArgString(Twine(Output.getFilename()) + ".pre-bolt");
+  MoveCmdArgs.push_back(PreBoltBin);
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ MvExec, MoveCmdArgs, std::nullopt));
+
+  ArgStringList BoltCmdArgs;
+  const char *BoltExec =
+  Args.MakeArgString(ToolChain.GetProgramPath("llvm-bolt"));
+  BoltCmdArgs.push_back(PreBoltBin);
+  BoltCmdArgs.push_back("-reorder-blocks=reverse");
+  BoltCmdArgs.push_back("-update-debug-sections");
+  BoltCmdArgs.push_back("-o");
+  BoltCmdArgs.push_back(Output.getFilename());
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ BoltExec, BoltCmdArgs, std::nullopt));
+  // End Facebook T92898286
 }
 
 void tools::gnutools::Assembler::ConstructJob(Compilation ,
diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py
index 

[Lldb-commits] [lldb] [lldb] Correct invalid format style (PR #98089)

2024-07-08 Thread Alex Langford via lldb-commits

bulbazord wrote:

This is the exact same PR as https://github.com/apple/llvm-project/pull/8952 
(on apple's LLVM fork). It should have gone here first.

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


[Lldb-commits] [lldb] [lldb] Correct invalid format style (PR #98089)

2024-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes

Fixes https://github.com/llvm/llvm-project/issues/97511

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


1 Files Affected:

- (modified) lldb/source/Target/StackFrameList.cpp (+3-3) 


``diff
diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 314b5e39c71699..0cf9ce1bf043f5 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -966,9 +966,9 @@ size_t StackFrameList::GetStatus(Stream , uint32_t 
first_frame,
 // Check for interruption here.  If we're fetching arguments, this loop
 // can go slowly:
 Debugger  = m_thread.GetProcess()->GetTarget().GetDebugger();
-if (INTERRUPT_REQUESTED(dbg, 
-  "Interrupted dumping stack for thread {0:hex} with {1} shown.",
-  m_thread.GetID(), num_frames_displayed))
+if (INTERRUPT_REQUESTED(
+dbg, "Interrupted dumping stack for thread {0:x} with {1} shown.",
+m_thread.GetID(), num_frames_displayed))
   break;
 
 

``




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


[Lldb-commits] [lldb] [lldb] Correct invalid format style (PR #98089)

2024-07-08 Thread Alex Langford via lldb-commits

https://github.com/bulbazord created 
https://github.com/llvm/llvm-project/pull/98089

Fixes https://github.com/llvm/llvm-project/issues/97511

>From 31b3d4db2389dd4bd72b54618ba12c86f51fe02f Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Mon, 8 Jul 2024 13:24:49 -0700
Subject: [PATCH] [lldb] Correct invalid format style

---
 lldb/source/Target/StackFrameList.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 314b5e39c71699..0cf9ce1bf043f5 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -966,9 +966,9 @@ size_t StackFrameList::GetStatus(Stream , uint32_t 
first_frame,
 // Check for interruption here.  If we're fetching arguments, this loop
 // can go slowly:
 Debugger  = m_thread.GetProcess()->GetTarget().GetDebugger();
-if (INTERRUPT_REQUESTED(dbg, 
-  "Interrupted dumping stack for thread {0:hex} with {1} shown.",
-  m_thread.GetID(), num_frames_displayed))
+if (INTERRUPT_REQUESTED(
+dbg, "Interrupted dumping stack for thread {0:x} with {1} shown.",
+m_thread.GetID(), num_frames_displayed))
   break;
 
 

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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-08 Thread Walter Erquinigo via lldb-commits

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

>From aa2ad3b675f67581dde07a476725d2574fc6e7da Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Fri, 5 Jul 2024 20:30:44 -0400
Subject: [PATCH] [lldb-dap] Support throw and catch exception breakpoints for
 dynamically registered languages

First of all, this is done to support exceptions for the Mojo language, but 
it's done in a way that will benefit any other plugin language.

1. I added a new lldb-dap CLI argument (not DAP field) called 
`pre-init-commands`. These commands are executed before DAP initialization. The 
other `init-commands` are executed after DAP initialization. It's worth 
mentioning that the debug adapter returns to VSCode the list of supported 
exception breakpoints during DAP initialization, which means that I need to 
register the Mojo plugin before that initialization step, hence the need for 
`pre-init-commands`. In general, language plugins should be registered in that 
step, as they affect the capabilities of the debugger.
2. I added a set of APIs for lldb-dap to query information of each language 
related to exception breakpoints. E.g. whether a language supports throw or 
catch breakpoints, how the throw keyword is called in each particular language, 
etc.
3. I'm realizing that the Swift support for exception breakpoints in lldb-dap 
should have been implemented in this way, instead of hardcoding it.
---
 lldb/include/lldb/API/SBLanguageRuntime.h | 26 +++
 lldb/include/lldb/Target/Language.h   |  8 
 lldb/source/API/SBLanguageRuntime.cpp | 40 +
 lldb/tools/lldb-dap/DAP.cpp   | 54 ++-
 lldb/tools/lldb-dap/DAP.h |  2 +
 lldb/tools/lldb-dap/Options.td|  8 
 lldb/tools/lldb-dap/lldb-dap.cpp  | 19 ++--
 7 files changed, 153 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h 
b/lldb/include/lldb/API/SBLanguageRuntime.h
index 38aac05d490c1..acdc256fa2ac5 100644
--- a/lldb/include/lldb/API/SBLanguageRuntime.h
+++ b/lldb/include/lldb/API/SBLanguageRuntime.h
@@ -18,6 +18,32 @@ class SBLanguageRuntime {
   static lldb::LanguageType GetLanguageTypeFromString(const char *string);
 
   static const char *GetNameForLanguageType(lldb::LanguageType language);
+
+  /// Returns whether the given language is any version of  C++.
+  static bool LanguageIsCPlusPlus(lldb::LanguageType language);
+
+  /// Returns whether the given language is Obj-C or Obj-C++.
+  static bool LanguageIsObjC(lldb::LanguageType language);
+
+  /// Returns whether the given language is any version of C, C++ or Obj-C.
+  static bool LanguageIsCFamily(lldb::LanguageType language);
+
+  /// Returns whether the given language supports exception breakpoints on
+  /// throw statements.
+  static bool SupportsExceptionBreakpointsOnThrow(lldb::LanguageType language);
+
+  /// Returns whether the given language supports exception breakpoints on
+  /// catch statements.
+  static bool SupportsExceptionBreakpointsOnCatch(lldb::LanguageType language);
+
+  /// Returns the keyword used for throw statements in the given language, e.g.
+  /// Python uses \b raise. Returns \b nullptr if the language is not 
supported.
+  static const char *GetThrowKeywordForLanguage(lldb::LanguageType language);
+
+  /// Returns the keyword used for catch statements in the given language, e.g.
+  /// Python uses \b except. Returns \b nullptr if the language is not
+  /// supported.
+  static const char *GetCatchKeywordForLanguage(lldb::LanguageType language);
 };
 
 } // namespace lldb
diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 83bf7635e369a..41d8eeef469ea 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -371,6 +371,14 @@ class Language : public PluginInterface {
   /// a corresponding LanguageRuntime plugin.
   virtual bool SupportsExceptionBreakpointsOnCatch() const { return false; }
 
+  /// Returns the keyword used for throw statements in this language, e.g.
+  /// Python uses \b raise. Defaults to \b throw.
+  virtual llvm::StringRef GetThrowKeyword() const { return "throw"; }
+
+  /// Returns the keyword used for catch statements in this language, e.g.
+  /// Python uses \b except. Defaults to \b catch.
+  virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/API/SBLanguageRuntime.cpp 
b/lldb/source/API/SBLanguageRuntime.cpp
index d571f282fce03..8599c2598b9fb 100644
--- a/lldb/source/API/SBLanguageRuntime.cpp
+++ b/lldb/source/API/SBLanguageRuntime.cpp
@@ -26,3 +26,43 @@ SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType 
language) {
 
   return Language::GetNameForLanguageType(language);
 }
+
+bool SBLanguageRuntime::LanguageIsCPlusPlus(lldb::LanguageType language) {
+  return 

[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-08 Thread Walter Erquinigo via lldb-commits


@@ -58,10 +58,17 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+/// Return string with first character capitalized.
+static std::string capitalize(llvm::StringRef str) {
+  if (str.empty())
+return "";
+  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
+}
+
 void DAP::PopulateExceptionBreakpoints() {
   llvm::call_once(init_exception_breakpoints_flag, [this]() {
 exception_breakpoints = std::vector {};
-
+

walter-erquinigo wrote:

This one doesn't affect git blame history. It should be fine :)

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-07-08 Thread via lldb-commits

jeffreytan81 wrote:

> Why does the ThreadPlanSingleThreadTimeout have to claim to explain stops 
> (like a random breakpoint hit) that on the face of it it's not responsible for

We are doing so to ensure `ThreadPlanSingleThreadTimeout` can stay in the leaf 
thread plan. And it comes from your suggestion `So 
ThreadPlanSingleThreadTimeout should always say it explains the stop` in this 
comment:
https://discourse.llvm.org/t/improve-single-thread-stepping/74599/17?u=jeffreytan81

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


[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)

2024-07-08 Thread Jacob Lalonde via lldb-commits


@@ -82,15 +82,24 @@ class MinidumpFile : public Binary {
 return getListStream(minidump::StreamType::ThreadList);
   }
 
-  /// Returns the contents of the Exception stream.  An error is returned if 
the
-  /// file does not contain this stream, or the stream is smaller than the size
-  /// of the ExceptionStream structure.  The internal consistency of the stream
-  /// is not checked in any way.
-  Expected getExceptionStream() const {
-return getStream(
-minidump::StreamType::Exception);
+  /// Returns the contents of the Exception stream. An error is returned if the
+  /// associated stream is smaller than the size of the ExceptionStream
+  /// structure. Or the directory supplied is not of kind exception stream.
+  Expected
+  getExceptionStream(minidump::Directory Directory) const {
+if (Directory.Type != minidump::StreamType::Exception) {
+  return createError("Not an exception stream");
+}
+
+return getStreamFromDirectory(Directory);

Jlalond wrote:

Fixed.

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


[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)

2024-07-08 Thread Jacob Lalonde via lldb-commits


@@ -109,7 +109,7 @@ class ProcessMinidump : public PostMortemProcess {
 private:
   lldb::DataBufferSP m_core_data;
   llvm::ArrayRef m_thread_list;
-  const minidump::ExceptionStream *m_active_exception;
+  std::unordered_map m_exceptions_by_tid;

Jlalond wrote:

This will expose my noviceness in C++, but I struggled that you can't emplace a 
list of references, so instead I refactored this to return a vector of const 
pointers.

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


[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)

2024-07-08 Thread Jacob Lalonde via lldb-commits


@@ -82,15 +82,24 @@ class MinidumpFile : public Binary {
 return getListStream(minidump::StreamType::ThreadList);
   }
 
-  /// Returns the contents of the Exception stream.  An error is returned if 
the
-  /// file does not contain this stream, or the stream is smaller than the size
-  /// of the ExceptionStream structure.  The internal consistency of the stream
-  /// is not checked in any way.
-  Expected getExceptionStream() const {
-return getStream(
-minidump::StreamType::Exception);
+  /// Returns the contents of the Exception stream. An error is returned if the
+  /// associated stream is smaller than the size of the ExceptionStream
+  /// structure. Or the directory supplied is not of kind exception stream.
+  Expected
+  getExceptionStream(minidump::Directory Directory) const {
+if (Directory.Type != minidump::StreamType::Exception) {
+  return createError("Not an exception stream");
+}
+
+return getStreamFromDirectory(Directory);
   }
 
+  /// Returns the contents of the Exception streams.  An error is returned if
+  /// any of the streams are smaller than the size of the ExceptionStream
+  /// structure. The internal consistency of the stream is not checked in any
+  /// way.
+  Expected> getExceptionStreams() const;

Jlalond wrote:

I decided against this for Minidump.h because the existing API's expose 
`Expected`, for the Minidumparser I used optional upon your recommendation

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-07-08 Thread via lldb-commits

jimingham wrote:



> On Jul 8, 2024, at 12:55 PM, jeffreytan81 ***@***.***> wrote:
> 
> 
> @jimingham , thanks for the comment.
> 
> When I try to add a new testcase for stepping over a function with a user set 
> breakpoint, there is a bug found -- the user set breakpoint did not stop with 
> ThreadPlanSingleThreadTimeout present (which is c case in your RFC comment)
> 
> I did some investigation, when we issue normal step-over, the all thread 
> plans in the stack return false for PlanExplainsStop, so base thread plan got 
> a chance to check thread's stop info and stop the execution.
> 
> However, while doing single thread stepping, ThreadPlanSingleThreadTimeout as 
> leaf plan always return true for PlanExplainsStop, causing the logic to use 
> the second while loop in Thread::ShouldStop(), eventually, 
> ThreadPlanStepOut::MischiefManaged() returns false causing the loop to 
> terminate early without giving base thread plan to decide should stop or not:
> https://github.com/llvm/llvm-project/blob/393eff4e02e7ab3d234d246a8d6912c8e745e6f9/lldb/source/Target/Thread.cpp#L905-L907
> 
> So overall the Thread::ShouldStop() returns false and ignores the hit inner 
> breakpoint during stepping. Any suggestion how to fix this?
> 

Why does the ThreadPlanSingleThreadTimeout have to claim to explain stops (like 
a random breakpoint hit) that on the face of it it's not responsible for?  What 
would happen if it just didn't explain this breakpoint, and instead uses 
marking itself as stale when a user stop like this comes in to make sure it 
will get popped.

I don't remember anymore why I had to do this as a two-pass thing, making the 
first plan that explains the stop privileged.  That's an odd asymmetry, and it 
seems like going back to the "explains stop" loop after processing a previous 
"I explain the stop" plan will fix this issue.  But it will probably require a 
bunch of fiddling to get right again (and maybe discovering why I did it this 
way in the first place)...  So that should be a later resort.

Jim


> —
> Reply to this email directly, view it on GitHub 
> , or 
> unsubscribe 
> .
> You are receiving this because you were mentioned.
> 



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


[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)

2024-07-08 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

> Exception Breakpoints are created by the static method 
> LanguageRuntime::CreateExceptionBreakpoint. So they don't require a process. 

Indeed, but let me elaborate. What I need is a method that doesn't require a 
process that could tell me if a certain language can support exception 
breakpoints, as that's what the checks in the `breakpoint set -E ` 
command try to do.

Then I had two main choices w.r.t `LanguageRuntime`:
- Add the method as non-static `LanguageRuntime`, but `LanguageRuntime` 
instances do require a process.
- Add a static method in `LanguageRuntime`, like `CreateExceptionBreakpoint`, 
but it turns out that `CreateExceptionBreakpoint` ends up relying on 
`Language::GetDefaultExceptionResolverDescription` and 
`Language::GetExceptionResolverDescription`. So this made me believe that it'd 
be better to place all the static exception feature bits in `Language` and not 
`LanguageRuntime`. `LanguageRuntime` seems to be a place more suited for 
dealing with runtime behaviors and not static pieces of information.

> It's a little awkward to have a static method in LanguageRuntime that makes 
> the Exception breakpoint conditioned by a Language method 
> 'SupportsExceptionBreakpoint".

I somewhat agree with it, but probably I'd end up writing a static method 
`LanguageRuntime::SupportsExceptionBreakpoint` that invokes a non-static 
`Language::SupportsExceptionBreakpoint`. And as I mentioned, there's already 
precedent for other exception related stuff in `Language`.

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


[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)

2024-07-08 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

> > @jeffreytan81 I think the callout for multiple exception is a good 
> > question. I made a C# testbed to see what would happen if I had multiple 
> > simultaneous exceptions. [Gist 
> > here](https://gist.github.com/Jlalond/467bc990f10fbb75cc9ca7db897a7beb). 
> > When manually collecting a minidump on my Windows system and then viewing 
> > it, I do get a warning that my application has multiple exceptions.
> > ![image](https://private-user-images.githubusercontent.com/25160653/346230140-d7f7f1c2-3de9-40bd-b692-f3f3ef23fd38.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0NTk4NzIsIm5iZiI6MTcyMDQ1OTU3MiwicGF0aCI6Ii8yNTE2MDY1My8zNDYyMzAxNDAtZDdmN2YxYzItM2RlOS00MGJkLWI2OTItZjNmM2VmMjNmZDM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDE3MjYxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViZTBkMGEzMmUyMDgzMDUyYzQyZWZiMzEzNmY2YmU1MzQ2OTU4Y2M5MWE5YWUwNzIxOGQyZTQzMzRjNjFmYmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.0hYRLR8moBxXwtvieDm-QrmHXdH_pxUUt8xLF4HriVE)
> > This leads me to believe multiple exceptions is acceptable, albeit rare.
> 
> That's good to know, but this is still an indirectly way to check. We would 
> feel much convinced if you can copy the minidump generated by lldb to Windows 
> and give windbg or Visual Studio a try.

Okay, I took the same program and then collected a dump with LLDB. As this was 
.net, we have an issue not collecting information about private core lib or the 
windows OS version, so Visual studio does encounter some issue. However I can 
still enter managed debug and see the exception objects on every thread.

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-07-08 Thread via lldb-commits

jeffreytan81 wrote:

@jimingham, thanks for the comment.

When I try to add a new testcase for stepping over a function with a user set 
breakpoint, there is a bug found -- the user set breakpoint did not stop with 
`ThreadPlanSingleThreadTimeout` present (which is `c` case in your RFC comment)

I did some investigation, when we issue normal step-over, the all thread plans 
in the stack return false for `PlanExplainsStop`, so base thread plan got a 
chance to check thread's stop info and stop the execution. 

However, while doing single thread stepping, `ThreadPlanSingleThreadTimeout` as 
leaf plan always return true for `PlanExplainsStop`, causing the logic to use 
the second while loop in `Thread::ShouldStop()`, eventually, 
`ThreadPlanStepOut::MischiefManaged()` returns false causing the loop to 
terminate early without giving base thread plan to decide should stop or not:
https://github.com/llvm/llvm-project/blob/393eff4e02e7ab3d234d246a8d6912c8e745e6f9/lldb/source/Target/Thread.cpp#L905-L907

So overall the `Thread::ShouldStop()` returns false and ignores the hit inner 
breakpoint during stepping. Any suggestion how to fix this? 



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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-07-08 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix string truncation method when substring is the prefix of string (NFC) (PR #94785)

2024-07-08 Thread Alex Langford via lldb-commits


@@ -287,7 +287,7 @@ Status PlatformAndroid::DownloadModuleSlice(const FileSpec 
_file_spec,
   static constexpr llvm::StringLiteral k_zip_separator("!/");
   size_t pos = source_file.find(k_zip_separator);
   if (pos != std::string::npos)
-source_file = source_file.substr(0, pos);
+source_file = source_file.resize(0, pos);

bulbazord wrote:

This still isn't resolved, you're still doing `source_file = 
source_file.resize(pos)`. It doesn't return a value.

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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-08 Thread Alex Langford via lldb-commits


@@ -80,6 +87,46 @@ void DAP::PopulateExceptionBreakpoints() {
   exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
   lldb::eLanguageTypeSwift);
 }
+// Besides handling the hardcoded list of languages from above, we try to
+// find any other languages that support exception breakpoints using the
+// SB API.
+for (int raw_lang = lldb::eLanguageTypeUnknown;
+ raw_lang < lldb::eNumLanguageTypes; ++raw_lang) {
+  lldb::LanguageType lang = static_cast(raw_lang);
+
+  // We first discard any languages already handled above.
+  if (lldb::SBLanguageRuntime::LanguageIsCFamily(lang) ||
+  lang == lldb::eLanguageTypeSwift)
+continue;
+
+  if (!lldb::SBDebugger::SupportsLanguage(lang))
+continue;
+
+  const char *name = lldb::SBLanguageRuntime::GetNameForLanguageType(lang);
+  if (!name)
+continue;
+  std::string raw_lang_name = name;
+  std::string capitalized_lang_name = capitalize(name);
+  const char *raw_throw_keyword =
+  lldb::SBLanguageRuntime::GetThrowKeywordForLanguage(lang);
+  const char *raw_catch_keyword =
+  lldb::SBLanguageRuntime::GetCatchKeywordForLanguage(lang);
+  std::string throw_keyword =
+  raw_throw_keyword ? raw_throw_keyword : "throw";
+  std::string catch_keyword =
+  raw_catch_keyword ? raw_catch_keyword : "catch";
+
+  if (lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnThrow(lang)) {
+exception_breakpoints->emplace_back(
+raw_lang_name + "_" + throw_keyword,
+capitalized_lang_name + " " + capitalize(throw_keyword), lang);
+  }
+  if (lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnCatch(lang)) {
+exception_breakpoints->emplace_back(
+raw_lang_name + "_" + catch_keyword,
+capitalized_lang_name + " " + capitalize(catch_keyword), lang);
+  }

bulbazord wrote:

same as above

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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-08 Thread Alex Langford via lldb-commits


@@ -80,6 +87,46 @@ void DAP::PopulateExceptionBreakpoints() {
   exception_breakpoints->emplace_back("swift_throw", "Swift Throw",
   lldb::eLanguageTypeSwift);
 }
+// Besides handling the hardcoded list of languages from above, we try to
+// find any other languages that support exception breakpoints using the
+// SB API.
+for (int raw_lang = lldb::eLanguageTypeUnknown;
+ raw_lang < lldb::eNumLanguageTypes; ++raw_lang) {
+  lldb::LanguageType lang = static_cast(raw_lang);
+
+  // We first discard any languages already handled above.
+  if (lldb::SBLanguageRuntime::LanguageIsCFamily(lang) ||
+  lang == lldb::eLanguageTypeSwift)
+continue;
+
+  if (!lldb::SBDebugger::SupportsLanguage(lang))
+continue;
+
+  const char *name = lldb::SBLanguageRuntime::GetNameForLanguageType(lang);
+  if (!name)
+continue;
+  std::string raw_lang_name = name;
+  std::string capitalized_lang_name = capitalize(name);
+  const char *raw_throw_keyword =
+  lldb::SBLanguageRuntime::GetThrowKeywordForLanguage(lang);
+  const char *raw_catch_keyword =
+  lldb::SBLanguageRuntime::GetCatchKeywordForLanguage(lang);
+  std::string throw_keyword =
+  raw_throw_keyword ? raw_throw_keyword : "throw";
+  std::string catch_keyword =
+  raw_catch_keyword ? raw_catch_keyword : "catch";
+
+  if (lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnThrow(lang)) {
+exception_breakpoints->emplace_back(
+raw_lang_name + "_" + throw_keyword,
+capitalized_lang_name + " " + capitalize(throw_keyword), lang);
+  }

bulbazord wrote:

nit: [single-statement if 
](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements)

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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-08 Thread Alex Langford via lldb-commits


@@ -58,10 +58,17 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+/// Return string with first character capitalized.
+static std::string capitalize(llvm::StringRef str) {
+  if (str.empty())
+return "";
+  return ((llvm::Twine)llvm::toUpper(str[0]) + str.drop_front()).str();
+}
+
 void DAP::PopulateExceptionBreakpoints() {
   llvm::call_once(init_exception_breakpoints_flag, [this]() {
 exception_breakpoints = std::vector {};
-
+

bulbazord wrote:

Unrelated whitespace change

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


[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)

2024-07-08 Thread Alex Langford via lldb-commits


@@ -26,3 +26,43 @@ SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType 
language) {
 
   return Language::GetNameForLanguageType(language);
 }
+
+bool SBLanguageRuntime::LanguageIsCPlusPlus(lldb::LanguageType language) {
+  return Language::LanguageIsCPlusPlus(language);
+}
+
+bool SBLanguageRuntime::LanguageIsObjC(lldb::LanguageType language) {
+  return Language::LanguageIsObjC(language);
+}
+
+bool SBLanguageRuntime::LanguageIsCFamily(lldb::LanguageType language) {
+  return Language::LanguageIsCFamily(language);
+}
+
+bool SBLanguageRuntime::SupportsExceptionBreakpointsOnThrow(
+lldb::LanguageType language) {
+  if (Language *lang_plugin = Language::FindPlugin(language))
+return lang_plugin->SupportsExceptionBreakpointsOnThrow();
+  return false;
+}
+
+bool SBLanguageRuntime::SupportsExceptionBreakpointsOnCatch(
+lldb::LanguageType language) {
+  if (Language *lang_plugin = Language::FindPlugin(language))
+return lang_plugin->SupportsExceptionBreakpointsOnCatch();
+  return false;
+}
+
+const char *
+SBLanguageRuntime::GetThrowKeywordForLanguage(lldb::LanguageType language) {
+  if (Language *lang_plugin = Language::FindPlugin(language))
+return lang_plugin->GetThrowKeyword().data();

bulbazord wrote:

You should wrap these in `ConstString`. It is not safe in general for LLDB to 
pass out `const char *` values that are derived from `llvm::StringRef`. I know 
that `GetThrowKeyword` and `GetCatchKeyword` are passing out static c-strings 
wrapped in a `llvm::StringRef`, but those are virtual and plugins may not do 
the same.

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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-07-08 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][NFC] Add maybe_unused to err used in asserts (PR #98055)

2024-07-08 Thread Jason Molenda via lldb-commits

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

LGTM.

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


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-08 Thread Justin Bogner via lldb-commits


@@ -115,6 +116,18 @@ GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer ) {
 
 } // namespace
 
+llvm::Type *CGHLSLRuntime::convertHLSLSpecificType(const Type *T) {
+  assert(T->isHLSLSpecificType() && "Not an HLSL specific type!");
+
+  // Check if the target has a specific translation for this type first.
+  if (llvm::Type *TargetTy = CGM.getTargetCodeGenInfo().getHLSLType(CGM, T))
+return TargetTy;
+
+  // TODO: What do we actually want to do generically here? OpenCL uses a
+  // pointer in a particular address space.
+  llvm_unreachable("Generic handling of HLSL types is not implemented yet");

bogner wrote:

For DirectX and SPIR-V we'll implement `getHLSLType` and this should really be 
unreachable, but we may want to do something generic in the future if/when we 
want to generate code for GPU or CPU targets directly generically. Something 
like the OpenCL approach mentioned in the comment might make sense in that case.

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


[Lldb-commits] [lldb] [llvm] [lldb] [lldb-server] Introduce Host/qnx and NativeProcessQNX (PR #97630)

2024-07-08 Thread Ayush Sahay via lldb-commits

ayushsahay1837 wrote:

> This is only a very light review. I agree with others that an RFC thread is a 
> better place to discuss this. After we sort that out, this patch should be 
> further subdivided into smaller pieces.

Thanks, @labath! I'll look into these and get back to you at the earliest.

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


[Lldb-commits] [lldb] [LLDB] DebugInfoD tests: attempt to fix Fuchsia build (PR #96802)

2024-07-08 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

Friendly ping @JDevlieghere 

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


[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)

2024-07-08 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/97470

>From dc4730dcff31c2c9212d2ce5412ecb8a9f4d83c0 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Tue, 2 Jul 2024 12:41:02 -0700
Subject: [PATCH 1/6] Add support to read multiple exception streams in
 minidumps

---
 .../Process/minidump/MinidumpParser.cpp   |  11 +-
 .../Plugins/Process/minidump/MinidumpParser.h |   2 +-
 .../Process/minidump/ProcessMinidump.cpp  | 122 ++
 .../Process/minidump/ProcessMinidump.h|   2 +-
 .../Process/minidump/ThreadMinidump.cpp   |  14 +-
 .../Plugins/Process/minidump/ThreadMinidump.h |   3 +-
 .../Process/minidump/MinidumpParserTest.cpp   |  11 +-
 llvm/include/llvm/Object/Minidump.h   |  34 -
 llvm/lib/Object/Minidump.cpp  |  37 ++
 llvm/lib/ObjectYAML/MinidumpYAML.cpp  |   4 +-
 10 files changed, 162 insertions(+), 78 deletions(-)

diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp 
b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
index be9fae938e227..ac487a5ed0c0a 100644
--- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -408,7 +408,7 @@ std::vector 
MinidumpParser::GetFilteredModuleList() {
 continue;
   }
   // This module has been seen. Modules are sometimes mentioned multiple
-  // times when they are mapped discontiguously, so find the module with
+  // times when they are mapped discontiguously, so find the module with 
   // the lowest "base_of_image" and use that as the filtered module.
   if (module.BaseOfImage < dup_module->BaseOfImage)
 filtered_modules[iter->second] = 
@@ -417,14 +417,15 @@ std::vector 
MinidumpParser::GetFilteredModuleList() {
   return filtered_modules;
 }
 
-const minidump::ExceptionStream *MinidumpParser::GetExceptionStream() {
-  auto ExpectedStream = GetMinidumpFile().getExceptionStream();
+const std::vector 
MinidumpParser::GetExceptionStreams() {
+  auto ExpectedStream = GetMinidumpFile().getExceptionStreams();
   if (ExpectedStream)
-return &*ExpectedStream;
+return ExpectedStream.get();
 
   LLDB_LOG_ERROR(GetLog(LLDBLog::Process), ExpectedStream.takeError(),
  "Failed to read minidump exception stream: {0}");
-  return nullptr;
+  // return empty on failure.
+  return std::vector();
 }
 
 std::optional
diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.h 
b/lldb/source/Plugins/Process/minidump/MinidumpParser.h
index 050ba086f46f5..e552c7210e330 100644
--- a/lldb/source/Plugins/Process/minidump/MinidumpParser.h
+++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.h
@@ -82,7 +82,7 @@ class MinidumpParser {
   // have the same name, it keeps the copy with the lowest load address.
   std::vector GetFilteredModuleList();
 
-  const llvm::minidump::ExceptionStream *GetExceptionStream();
+  const std::vector GetExceptionStreams();
 
   std::optional FindMemoryRange(lldb::addr_t addr);
 
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp 
b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index 13599f4a1553f..9f707c0d8a7a7 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -39,6 +39,7 @@
 
 #include 
 #include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -157,7 +158,7 @@ ProcessMinidump::ProcessMinidump(lldb::TargetSP target_sp,
  const FileSpec _file,
  DataBufferSP core_data)
 : PostMortemProcess(target_sp, listener_sp, core_file),
-  m_core_data(std::move(core_data)), m_active_exception(nullptr),
+  m_core_data(std::move(core_data)),
   m_is_wow64(false) {}
 
 ProcessMinidump::~ProcessMinidump() {
@@ -209,7 +210,19 @@ Status ProcessMinidump::DoLoadCore() {
   GetTarget().SetArchitecture(arch, true /*set_platform*/);
 
   m_thread_list = m_minidump_parser->GetThreads();
-  m_active_exception = m_minidump_parser->GetExceptionStream();
+  std::vector exception_streams = 
m_minidump_parser->GetExceptionStreams();
+  for (const auto _stream : exception_streams) {
+if (m_exceptions_by_tid.count(exception_stream.ThreadId) > 0) {
+  // We only cast to avoid the warning around converting little endian in 
printf.
+  error.SetErrorStringWithFormat("duplicate exception stream for tid %" 
PRIu32, (uint32_t)exception_stream.ThreadId);
+  return error;
+} else 
+  m_exceptions_by_tid[exception_stream.ThreadId] = exception_stream;
+
+
+std::cout << "Adding Exception Stream # " << 
(uint32_t)exception_stream.ThreadId << std::endl;
+std::cout << "Added index " << 
(uint32_t)m_exceptions_by_tid[exception_stream.ThreadId].ExceptionRecord.ExceptionCode
 << std::endl;
+  }
 
   SetUnixSignals(UnixSignals::Create(GetArchitecture()));
 
@@ -232,60 +245,59 @@ Status 

[Lldb-commits] [lldb] [lldb][NFC] Add maybe_unused to err used in asserts (PR #98055)

2024-07-08 Thread Joe Loser via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][NFC] Add maybe_unused to err used in asserts (PR #98055)

2024-07-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Keith Smiley (keith)


Changes



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


1 Files Affected:

- (modified) lldb/tools/debugserver/source/PThreadMutex.h (+3-3) 


``diff
diff --git a/lldb/tools/debugserver/source/PThreadMutex.h 
b/lldb/tools/debugserver/source/PThreadMutex.h
index a4535dd79172c2..17f9fdff5f2d3a 100644
--- a/lldb/tools/debugserver/source/PThreadMutex.h
+++ b/lldb/tools/debugserver/source/PThreadMutex.h
@@ -78,13 +78,13 @@ class PThreadMutex {
   };
 
   PThreadMutex() {
-int err;
+[[maybe_unused]] int err;
 err = ::pthread_mutex_init(_mutex, NULL);
 assert(err == 0);
   }
 
   PThreadMutex(int type) {
-int err;
+[[maybe_unused]] int err;
 ::pthread_mutexattr_t attr;
 err = ::pthread_mutexattr_init();
 assert(err == 0);
@@ -97,7 +97,7 @@ class PThreadMutex {
   }
 
   ~PThreadMutex() {
-int err;
+[[maybe_unused]] int err;
 err = ::pthread_mutex_destroy(_mutex);
 if (err != 0) {
   err = Unlock();

``




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


[Lldb-commits] [lldb] [lldb][NFC] Add maybe_unused to err used in asserts (PR #98055)

2024-07-08 Thread Keith Smiley via lldb-commits

https://github.com/keith created https://github.com/llvm/llvm-project/pull/98055

None

>From 6a6fc355e3623a0d0aacc465220a562e103e6dfc Mon Sep 17 00:00:00 2001
From: Keith Smiley 
Date: Mon, 8 Jul 2024 10:28:22 -0700
Subject: [PATCH] [lldb][NFC] Add maybe_unused to err used in asserts

---
 lldb/tools/debugserver/source/PThreadMutex.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/tools/debugserver/source/PThreadMutex.h 
b/lldb/tools/debugserver/source/PThreadMutex.h
index a4535dd79172c..17f9fdff5f2d3 100644
--- a/lldb/tools/debugserver/source/PThreadMutex.h
+++ b/lldb/tools/debugserver/source/PThreadMutex.h
@@ -78,13 +78,13 @@ class PThreadMutex {
   };
 
   PThreadMutex() {
-int err;
+[[maybe_unused]] int err;
 err = ::pthread_mutex_init(_mutex, NULL);
 assert(err == 0);
   }
 
   PThreadMutex(int type) {
-int err;
+[[maybe_unused]] int err;
 ::pthread_mutexattr_t attr;
 err = ::pthread_mutexattr_init();
 assert(err == 0);
@@ -97,7 +97,7 @@ class PThreadMutex {
   }
 
   ~PThreadMutex() {
-int err;
+[[maybe_unused]] int err;
 err = ::pthread_mutex_destroy(_mutex);
 if (err != 0) {
   err = Unlock();

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


[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Support minidumps where there are multiple exception streams (PR #97470)

2024-07-08 Thread via lldb-commits

jeffreytan81 wrote:

> @jeffreytan81 I think the callout for multiple exception is a good question. 
> I made a C# testbed to see what would happen if I had multiple simultaneous 
> exceptions. [Gist 
> here](https://gist.github.com/Jlalond/467bc990f10fbb75cc9ca7db897a7beb). When 
> manually collecting a minidump on my Windows system and then viewing it, I do 
> get a warning that my application has multiple exceptions.
> 
> ![image](https://private-user-images.githubusercontent.com/25160653/346230140-d7f7f1c2-3de9-40bd-b692-f3f3ef23fd38.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0NTk4NzIsIm5iZiI6MTcyMDQ1OTU3MiwicGF0aCI6Ii8yNTE2MDY1My8zNDYyMzAxNDAtZDdmN2YxYzItM2RlOS00MGJkLWI2OTItZjNmM2VmMjNmZDM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDE3MjYxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViZTBkMGEzMmUyMDgzMDUyYzQyZWZiMzEzNmY2YmU1MzQ2OTU4Y2M5MWE5YWUwNzIxOGQyZTQzMzRjNjFmYmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.0hYRLR8moBxXwtvieDm-QrmHXdH_pxUUt8xLF4HriVE)
> 
> This leads me to believe multiple exceptions is acceptable, albeit rare.

That's good to know, but this is still a indirectly way to check. We would feel 
much convinced if you can copy the minidump generated by lldb to Windows and 
give windbg or Visual Studio a try. 

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


[Lldb-commits] [lldb] [LLDB] Support exception breakpoints for plugin-provided languages (PR #97675)

2024-07-08 Thread via lldb-commits

jimingham wrote:

> CommandObjectBreakpoint has a harcoded list of languages for which exception 
> breakpoints can be enabled. I'm making this a bit more generic so that my 
> Mojo plugin can get this feature. Basically, I'm adding a new overridable 
> method `Language::SupportsExceptionBreakpoints` that can be used by language 
> plugins to determine whether they support this feature or not. This method is 
> used in addition to the hardcoded list and, as an example, I'm using it for 
> the ObjC language support.
> 
> Another route is simply to avoid doing the check that it's being done right 
> now and simply try to the create the exception breakpoint for whatever 
> language that is not in the hardcoded list. I'm happy to do that if the 
> reviewers think it's a good idea.
> 
> As a note, the other possible place for adding this 
> `SupportsExceptionBreakpoints` method is in `LanguageRuntime`. However, 
> accessing it requires having a process, which is not always the case when 
> invoking the `breakpoint set -E` command. The process might not be alive yet, 
> so `Language` is a good second place for this.
> 

Exception Breakpoints are created by the static method 
LanguageRuntime::CreateExceptionBreakpoint.  So they don't require a process.  
Exception breakpoint resolvers can be "resolver discovering resolvers".  This 
used to be necessary when there were two ObjC runtimes possible on MacOS X, and 
you couldn't necessarily tell which one was going to be used till the program 
till it ran.  So they are able to adjust themselves when their Target launches 
a process.

It's a little awkward to have a static method in LanguageRuntime that makes the 
Exception breakpoint conditioned by a Language method 
'SupportsExceptionBreakpoint".

> And as a final note, I don't want to make this `SupportsExceptionBreakpoints` 
> complicated. I'm keeping it as simple as possible because it can easily 
> evolve as it's not part of the public API.



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


[Lldb-commits] [lldb] [lldb] Improve error message for unrecognized executables (PR #97490)

2024-07-08 Thread Jonas Devlieghere via lldb-commits

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


  1   2   3   4   5   6   7   8   9   10   >