[Lldb-commits] [PATCH] D158043: [lldb][NFCI] Module constructor should take ConstString by value

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, jingham, mib, aprantl.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

ConstStrings are super cheap to copy around. It is often more expensive
to pass a pointer and potentially dereference it than just to always copy it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158043

Files:
  lldb/include/lldb/Core/Module.h
  lldb/source/Core/Module.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Target/Process.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp


Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -57,7 +57,7 @@
   // Test that when we have Dwarf debug info, SymbolFileDWARF is used.
   FileSpec fspec(m_dwarf_test_exe);
   ArchSpec aspec("i686-pc-windows");
-  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+  lldb::ModuleSP module = std::make_shared(fspec, aspec, 
ConstString());
 
   SymbolFile *symfile = module->GetSymbolFile();
   ASSERT_NE(nullptr, symfile);
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2386,7 +2386,7 @@
   "Process::ReadModuleFromMemory reading %s binary from memory",
   file_spec.GetPath().c_str());
   }
-  ModuleSP module_sp(new Module(file_spec, ArchSpec()));
+  ModuleSP module_sp(new Module(file_spec, ArchSpec(), ConstString()));
   if (module_sp) {
 Status error;
 ObjectFile *objfile = module_sp->GetMemoryObjectFile(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -170,7 +170,7 @@
 public:
   DebugMapModule(const ModuleSP _module_sp, uint32_t cu_idx,
  const FileSpec _spec, const ArchSpec ,
- const ConstString *object_name, off_t object_offset,
+ const ConstString object_name, off_t object_offset,
  const llvm::sys::TimePoint<> object_mod_time)
   : Module(file_spec, arch, object_name, object_offset, object_mod_time),
 m_exe_module_wp(exe_module_sp), m_cu_idx(cu_idx) {}
@@ -459,7 +459,7 @@
  .c_str());
   comp_unit_info->oso_sp->module_sp = std::make_shared(
   obj_file->GetModule(), GetCompUnitInfoIndex(comp_unit_info), 
oso_file,
-  oso_arch, oso_object ? _object : nullptr, 0,
+  oso_arch, oso_object, 0,
   oso_object ? comp_unit_info->oso_mod_time : 
llvm::sys::TimePoint<>());
 
   if (oso_object && !comp_unit_info->oso_sp->module_sp->GetObjectFile() &&
Index: 
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
===
--- 
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -802,7 +802,8 @@
  kernel_search_error, true)) {
   if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
 m_module_sp = std::make_shared(module_spec.GetFileSpec(),
-   target.GetArchitecture());
+   target.GetArchitecture(),
+   ConstString());
   }
 }
   }
Index: lldb/source/Core/Module.cpp
===
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -233,7 +233,7 @@
 }
 
 Module::Module(const FileSpec _spec, const ArchSpec ,
-   const ConstString *object_name, lldb::offset_t object_offset,
+   const ConstString object_name, lldb::offset_t object_offset,
const llvm::sys::TimePoint<> _mod_time)
 : m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)),
   m_arch(arch), m_file(file_spec), m_object_offset(object_offset),
@@ -246,8 +246,7 @@
 GetModuleCollection().push_back(this);
   }
 
-  if (object_name)
-m_object_name = *object_name;
+  m_object_name = object_name;
 
   Log *log(GetLog(LLDBLog::Object | LLDBLog::Modules));
   if (log != nullptr)
Index: lldb/include/lldb/Core/Module.h
===
--- 

[Lldb-commits] [PATCH] D158023: [lldb] Simplify the LLDB website structure

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

I think the categories you've set are the same ones I would have created. May I 
suggest renaming `Extending LLDB` to `Scripting LLDB` or something similar? I 
think "Extending" and "Developing" are close enough in meaning that it may be 
confusing to end users.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158023/new/

https://reviews.llvm.org/D158023

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


[Lldb-commits] [PATCH] D158022: [lldb] Print an actionable error message when sphinx_automodapi is not installed

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.
This revision is now accepted and ready to land.

From the discussion this sounds like a reasonable thing to do.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158022/new/

https://reviews.llvm.org/D158022

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


[Lldb-commits] [PATCH] D158041: [lldb] [gdb-remote] Also handle high/low memory addressable bits setting in the stop info packet

2023-08-15 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added a reviewer: JDevlieghere.
jasonmolenda added a project: LLDB.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

A small follow on patch to https://reviews.llvm.org/D157667 to handle the new 
`low_mem_addressing_bits` and `high_mem_addressing_bits` keys in the stop reply 
packet too, not just qHostInfo.

I changed AddressableBits so that the low memory and high memory bits can be 
set separately, and we can query whether any addressing bits were seen while 
parsing the packet, and update the Process address masks if they were.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158041

Files:
  lldb/docs/lldb-gdb-remote.txt
  lldb/include/lldb/Utility/AddressableBits.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Utility/AddressableBits.cpp

Index: lldb/source/Utility/AddressableBits.cpp
===
--- lldb/source/Utility/AddressableBits.cpp
+++ lldb/source/Utility/AddressableBits.cpp
@@ -23,8 +23,14 @@
   m_high_memory_addr_bits = highmem_addressing_bits;
 }
 
-void AddressableBits::Clear() {
-  m_low_memory_addr_bits = m_high_memory_addr_bits = 0;
+void AddressableBits::SetLowmemAddressableBits(
+uint32_t lowmem_addressing_bits) {
+  m_low_memory_addr_bits = lowmem_addressing_bits;
+}
+
+void AddressableBits::SetHighmemAddressableBits(
+uint32_t highmem_addressing_bits) {
+  m_high_memory_addr_bits = highmem_addressing_bits;
 }
 
 void AddressableBits::SetProcessMasks(Process ) {
@@ -48,3 +54,11 @@
 process.SetHighmemDataAddressMask(hi_address_mask);
   }
 }
+
+bool AddressableBits::IsValid() {
+  return m_low_memory_addr_bits != 0 || m_high_memory_addr_bits != 0;
+}
+
+void AddressableBits::Clear() {
+  m_low_memory_addr_bits = m_high_memory_addr_bits = 0;
+}
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2124,6 +2124,7 @@
 QueueKind queue_kind = eQueueKindUnknown;
 uint64_t queue_serial_number = 0;
 ExpeditedRegisterMap expedited_register_map;
+AddressableBits addressable_bits;
 while (stop_packet.GetNameColonValue(key, value)) {
   if (key.compare("metype") == 0) {
 // exception type in big endian hex
@@ -2271,9 +2272,17 @@
   } else if (key.compare("addressing_bits") == 0) {
 uint64_t addressing_bits;
 if (!value.getAsInteger(0, addressing_bits)) {
-  addr_t address_mask = ~((1ULL << addressing_bits) - 1);
-  SetCodeAddressMask(address_mask);
-  SetDataAddressMask(address_mask);
+  addressable_bits.SetAddressableBits(addressing_bits);
+}
+  } else if (key.compare("low_mem_addressing_bits") == 0) {
+uint64_t addressing_bits;
+if (!value.getAsInteger(0, addressing_bits)) {
+  addressable_bits.SetLowmemAddressableBits(addressing_bits);
+}
+  } else if (key.compare("high_mem_addressing_bits") == 0) {
+uint64_t addressing_bits;
+if (!value.getAsInteger(0, addressing_bits)) {
+  addressable_bits.SetHighmemAddressableBits(addressing_bits);
 }
   } else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) {
 uint32_t reg = UINT32_MAX;
@@ -2302,6 +2311,10 @@
   }
 }
 
+if (addressable_bits.IsValid()) {
+  addressable_bits.SetProcessMasks(*this);
+}
+
 ThreadSP thread_sp = SetThreadStopInfo(
 tid, expedited_register_map, signo, thread_name, reason, description,
 exc_type, exc_data, thread_dispatch_qaddr, queue_vars_valid,
Index: lldb/include/lldb/Utility/AddressableBits.h
===
--- lldb/include/lldb/Utility/AddressableBits.h
+++ lldb/include/lldb/Utility/AddressableBits.h
@@ -29,8 +29,14 @@
   void SetAddressableBits(uint32_t lowmem_addressing_bits,
   uint32_t highmem_addressing_bits);
 
+  void SetLowmemAddressableBits(uint32_t lowmem_addressing_bits);
+
+  void SetHighmemAddressableBits(uint32_t highmem_addressing_bits);
+
   void SetProcessMasks(lldb_private::Process );
 
+  bool IsValid();
+
   void Clear();
 
 private:
Index: lldb/docs/lldb-gdb-remote.txt
===
--- lldb/docs/lldb-gdb-remote.txt
+++ lldb/docs/lldb-gdb-remote.txt
@@ -1661,6 +1661,18 @@
 //   start code that may be changing the
 //   page table setup, a dynamically set
 //   value may be needed.
+//  "low_mem_addressing_bits" unsigned optional, specifies how many bits in 
+//   

[Lldb-commits] [PATCH] D158022: [lldb] Print an actionable error message when sphinx_automodapi is not installed

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D158022#4590291 , @mib wrote:

> We should really add a `requirements.txt` file with all the dependencies.

I've long wanted to make this all automated, and have CMake install all the 
necessary dependencies. But that seems a bit intrusive without using something 
like a virtual environment, which would have to be project-wide and more work 
than I'm willing to put in. Regardless, that wouldn't actually help here, at 
least not on macOS if you installed sphinx with homebrew, because it packages 
its own version of Python 
(`/opt/homebrew/Cellar/sphinx-doc/7.1.2/libexec/bin/python`) and you have to 
install the `sphinx_automodapi` module with that. That's why I print 
`sys.executable` and really the motivation behind this patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158022/new/

https://reviews.llvm.org/D158022

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


[Lldb-commits] [PATCH] D158022: [lldb] Print an actionable error message when sphinx_automodapi is not installed

2023-08-15 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

We should really add a `requirements.txt` file with all the dependencies.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158022/new/

https://reviews.llvm.org/D158022

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


[Lldb-commits] [PATCH] D158035: [lldb] Protect RNBRemote from a data race

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/tools/debugserver/source/RNBRemote.cpp:780
 
   PThreadMutex::Locker locker(m_mutex);
   if (m_rx_packets.empty()) {

This is an RAII object, right? Can we just block scope it? Right now it looks 
like we might not unlock if we return early on line 787. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158035/new/

https://reviews.llvm.org/D158035

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


[Lldb-commits] [PATCH] D158034: [lldb] Fix data race in ThreadList

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158034/new/

https://reviews.llvm.org/D158034

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


[Lldb-commits] [PATCH] D158035: [lldb] Protect RNBRemote from a data race

2023-08-15 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 created this revision.
augusto2112 added reviewers: JDevlieghere, bulbazord, jingham.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Thread sanitizer reports the following data race:

  Write of size 8 at 0x000103303e70 by thread T1 (mutexes: write M0):
#0 RNBRemote::CommDataReceived(std::__1::basic_string, std::__1::allocator> const&) 
RNBRemote.cpp:1075 (debugserver:arm64+0x100038db8) (BuildId: 
f130b34f693c4f3eba96139104af2b71320021000e00)
#1 RNBRemote::ThreadFunctionReadRemoteData(void*) RNBRemote.cpp:1180 
(debugserver:arm64+0x1000391dc) (BuildId: 
f130b34f693c4f3eba96139104af2b71320021000e00)
  
  Previous read of size 8 at 0x000103303e70 by main thread:
#0 RNBRemote::GetPacketPayload(std::__1::basic_string, std::__1::allocator>&) RNBRemote.cpp:797 
(debugserver:arm64+0x100037c5c) (BuildId: 
f130b34f693c4f3eba96139104af2b71320021000e00)
#1 RNBRemote::GetPacket(std::__1::basic_string, std::__1::allocator>&, RNBRemote::Packet&, 
bool) RNBRemote.cpp:907 (debugserver:arm64+0x1000378cc) (BuildId: 
f130b34f693c4f3eba96139104af2b71320021000e00)

RNBRemote already has a mutex, extend its usage to protect the read of
m_rx_packets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158035

Files:
  lldb/tools/debugserver/source/RNBRemote.cpp


Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -792,12 +792,12 @@
   // m_rx_packets.size());
   return_packet.swap(m_rx_packets.front());
   m_rx_packets.pop_front();
-  locker.Reset(); // Release our lock on the mutex
 
   if (m_rx_packets.empty()) {
 // Reset the remote command available event if we have no more packets
 m_ctx.Events().ResetEvents(RNBContext::event_read_packet_available);
   }
+  locker.Reset(); // Release our lock on the mutex
 
   // DNBLogThreadedIf (LOG_RNB_MEDIUM, "%8u RNBRemote::%s: '%s'",
   // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__,


Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -792,12 +792,12 @@
   // m_rx_packets.size());
   return_packet.swap(m_rx_packets.front());
   m_rx_packets.pop_front();
-  locker.Reset(); // Release our lock on the mutex
 
   if (m_rx_packets.empty()) {
 // Reset the remote command available event if we have no more packets
 m_ctx.Events().ResetEvents(RNBContext::event_read_packet_available);
   }
+  locker.Reset(); // Release our lock on the mutex
 
   // DNBLogThreadedIf (LOG_RNB_MEDIUM, "%8u RNBRemote::%s: '%s'",
   // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158034: [lldb] Fix data race in ThreadList

2023-08-15 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

ThreadSanitizer reports the following issue:

  Write of size 8 at 0x00010a70abb0 by thread T3 (mutexes: write M0):
#0 lldb_private::ThreadList::Update(lldb_private::ThreadList&) 
ThreadList.cpp:741 (liblldb.18.0.0git.dylib:arm64+0x5dedf4) (BuildId: 
9bced2aafa373580ae9d750d9cf79a8f320021000e00)
#1 lldb_private::Process::UpdateThreadListIfNeeded() Process.cpp:1212 
(liblldb.18.0.0git.dylib:arm64+0x53bbec) (BuildId: 
9bced2aafa373580ae9d750d9cf79a8f320021000e00)
  
  Previous read of size 8 at 0x00010a70abb0 by main thread (mutexes: write M1):
#0 lldb_private::ThreadList::GetMutex() const ThreadList.cpp:785 
(liblldb.18.0.0git.dylib:arm64+0x5df138) (BuildId: 
9bced2aafa373580ae9d750d9cf79a8f320021000e00)
#1 lldb_private::ThreadList::DidResume() ThreadList.cpp:656 
(liblldb.18.0.0git.dylib:arm64+0x5de5c0) (BuildId: 
9bced2aafa373580ae9d750d9cf79a8f320021000e00)
#2 lldb_private::Process::PrivateResume() Process.cpp:3130 
(liblldb.18.0.0git.dylib:arm64+0x53cd7c) (BuildId: 
9bced2aafa373580ae9d750d9cf79a8f320021000e00)

Fix this by only using the mutex in ThreadList and removing the one in
process entirely.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158034

Files:
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/ThreadCollection.h
  lldb/include/lldb/Target/ThreadList.h
  lldb/source/Target/Process.cpp
  lldb/source/Target/ThreadList.cpp


Index: lldb/source/Target/ThreadList.cpp
===
--- lldb/source/Target/ThreadList.cpp
+++ lldb/source/Target/ThreadList.cpp
@@ -736,7 +736,8 @@
   if (this != ) {
 // Lock both mutexes to make sure neither side changes anyone on us while
 // the assignment occurs
-std::scoped_lock 
guard(GetMutex(), rhs.GetMutex());
+std::scoped_lock guard(
+GetMutex(), rhs.GetMutex());
 
 m_process = rhs.m_process;
 m_stop_id = rhs.m_stop_id;
@@ -781,10 +782,6 @@
 (*pos)->Flush();
 }
 
-std::recursive_mutex ::GetMutex() const {
-  return m_process->m_thread_mutex;
-}
-
 ThreadList::ExpressionExecutionThreadPusher::ExpressionExecutionThreadPusher(
 lldb::ThreadSP thread_sp)
 : m_thread_list(nullptr), m_tid(LLDB_INVALID_THREAD_ID) {
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -435,7 +435,7 @@
   Listener::MakeListener("lldb.process.internal_state_listener")),
   m_mod_id(), m_process_unique_id(0), m_thread_index_id(0),
   m_thread_id_to_index_id_map(), m_exit_status(-1), m_exit_string(),
-  m_exit_status_mutex(), m_thread_mutex(), m_thread_list_real(this),
+  m_exit_status_mutex(), m_thread_list_real(this),
   m_thread_list(this), m_thread_plans(*this), m_extended_thread_list(this),
   m_extended_thread_stop_id(0), m_queue_list(this), 
m_queue_list_stop_id(0),
   m_notifications(), m_image_tokens(), m_listener_sp(listener_sp),
@@ -2457,7 +2457,7 @@
 }
 
 void Process::LoadOperatingSystemPlugin(bool flush) {
-  std::lock_guard guard(m_thread_mutex);
+  std::lock_guard guard(GetThreadList().GetMutex());
   if (flush)
 m_thread_list.Clear();
   m_os_up.reset(OperatingSystem::FindPlugin(this, nullptr));
Index: lldb/include/lldb/Target/ThreadList.h
===
--- lldb/include/lldb/Target/ThreadList.h
+++ lldb/include/lldb/Target/ThreadList.h
@@ -133,8 +133,6 @@
 
   void SetStopID(uint32_t stop_id);
 
-  std::recursive_mutex () const override;
-
   void Update(ThreadList );
 
 protected:
Index: lldb/include/lldb/Target/ThreadCollection.h
===
--- lldb/include/lldb/Target/ThreadCollection.h
+++ lldb/include/lldb/Target/ThreadCollection.h
@@ -47,7 +47,7 @@
 return ThreadIterable(m_threads, GetMutex());
   }
 
-  virtual std::recursive_mutex () const { return m_mutex; }
+  std::recursive_mutex () const { return m_mutex; }
 
 protected:
   collection m_threads;
Index: lldb/include/lldb/Target/Process.h
===
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -2957,7 +2957,6 @@
   std::string m_exit_string; ///< A textual description of why a process 
exited.
   std::mutex m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can
   ///be safely accessed from multiple threads
-  std::recursive_mutex m_thread_mutex;
   ThreadList m_thread_list_real; ///< The threads for this process as are known
 

[Lldb-commits] [lldb] 3b91957 - Revert "[lldb] Properly protect the Communication class with reader/writer lock"

2023-08-15 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2023-08-15T16:03:28-07:00
New Revision: 3b919570f2f08581987de7851f3673352afb1578

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

LOG: Revert "[lldb] Properly protect the Communication class with reader/writer 
lock"

This reverts commit 5d16957207ce1bd1a2091f3677e176012009c59a.

Added: 


Modified: 
lldb/include/lldb/Core/Communication.h
lldb/include/lldb/Core/ThreadedCommunication.h
lldb/source/Core/Communication.cpp
lldb/source/Core/ThreadedCommunication.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Communication.h 
b/lldb/include/lldb/Core/Communication.h
index 7e4ce362acf9a6..f5f636816cb4f9 100644
--- a/lldb/include/lldb/Core/Communication.h
+++ b/lldb/include/lldb/Core/Communication.h
@@ -16,7 +16,6 @@
 #include "lldb/lldb-types.h"
 
 #include 
-#include 
 #include 
 
 namespace lldb_private {
@@ -47,6 +46,8 @@ class Communication {
   /// The destructor is virtual since this class gets subclassed.
   virtual ~Communication();
 
+  virtual void Clear();
+
   /// Connect using the current connection by passing \a url to its connect
   /// function. string.
   ///
@@ -83,10 +84,7 @@ class Communication {
 
   bool HasConnection() const;
 
-  lldb_private::Connection *GetConnection() {
-std::shared_lock guard(m_connection_mutex);
-return m_connection_sp.get();
-  }
+  lldb_private::Connection *GetConnection() { return m_connection_sp.get(); }
 
   /// Read bytes from the current connection.
   ///
@@ -171,24 +169,13 @@ class Communication {
   ///by this communications class.
   std::mutex
   m_write_mutex; ///< Don't let multiple threads write at the same time...
-  mutable std::shared_mutex m_connection_mutex;
   bool m_close_on_eof;
 
-  /// Same as read but with m_connection_mutex unlocked.
-  size_t ReadUnlocked(void *dst, size_t dst_len,
-  const Timeout ,
-  lldb::ConnectionStatus , Status *error_ptr);
-
   size_t ReadFromConnection(void *dst, size_t dst_len,
 const Timeout ,
 lldb::ConnectionStatus , Status *error_ptr);
 
 private:
-  /// Same as Disconnect but with with m_connection_mutex unlocked.
-  lldb::ConnectionStatus DisconnectUnlocked(Status *error_ptr = nullptr);
-  /// Same as Write but with both m_write_mutex and m_connection_mutex 
unlocked.
-  size_t WriteUnlocked(const void *src, size_t src_len,
-   lldb::ConnectionStatus , Status *error_ptr);
   Communication(const Communication &) = delete;
   const Communication =(const Communication &) = delete;
 };

diff  --git a/lldb/include/lldb/Core/ThreadedCommunication.h 
b/lldb/include/lldb/Core/ThreadedCommunication.h
index 170fd2dfcb555d..7ebb77beb77f3d 100644
--- a/lldb/include/lldb/Core/ThreadedCommunication.h
+++ b/lldb/include/lldb/Core/ThreadedCommunication.h
@@ -97,6 +97,8 @@ class ThreadedCommunication : public Communication, public 
Broadcaster {
   /// The destructor is virtual since this class gets subclassed.
   ~ThreadedCommunication() override;
 
+  void Clear() override;
+
   /// Disconnect the communications connection if one is currently connected.
   ///
   /// \return

diff  --git a/lldb/source/Core/Communication.cpp 
b/lldb/source/Core/Communication.cpp
index e2ba461a02329a..5d890632ccc6a9 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -27,110 +27,110 @@ using namespace lldb;
 using namespace lldb_private;
 
 Communication::Communication()
-: m_connection_sp(), m_connection_mutex(), m_close_on_eof(true) {}
+: m_connection_sp(), m_write_mutex(), m_close_on_eof(true) {
+}
+
+Communication::~Communication() {
+  Clear();
+}
 
-Communication::~Communication() { Disconnect(nullptr); }
+void Communication::Clear() {
+  Disconnect(nullptr);
+}
 
 ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) {
-  std::unique_lock guard(m_connection_mutex);
+  Clear();
 
   LLDB_LOG(GetLog(LLDBLog::Communication),
"{0} Communication::Connect (url = {1})", this, url);
 
-  DisconnectUnlocked();
-
-  if (m_connection_sp)
-return m_connection_sp->Connect(url, error_ptr);
+  lldb::ConnectionSP connection_sp(m_connection_sp);
+  if (connection_sp)
+return connection_sp->Connect(url, error_ptr);
   if (error_ptr)
 error_ptr->SetErrorString("Invalid connection.");
   return eConnectionStatusNoConnection;
 }
 
 ConnectionStatus Communication::Disconnect(Status *error_ptr) {
-  std::unique_lock guard(m_connection_mutex);
-  return DisconnectUnlocked(error_ptr);
-}
-
-ConnectionStatus Communication::DisconnectUnlocked(Status *error_ptr) {
   

[Lldb-commits] [PATCH] D157760: [lldb] Properly protect the Communication class with reader/writer lock

2023-08-15 Thread Augusto Noronha via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5d16957207ce: [lldb] Properly protect the Communication 
class with reader/writer lock (authored by augusto2112).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157760/new/

https://reviews.llvm.org/D157760

Files:
  lldb/include/lldb/Core/Communication.h
  lldb/include/lldb/Core/ThreadedCommunication.h
  lldb/source/Core/Communication.cpp
  lldb/source/Core/ThreadedCommunication.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Index: lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
===
--- lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -557,7 +557,6 @@
 }
   }
   StopAsyncThread();
-  m_comm.Clear();
 
   SetPrivateState(eStateDetached);
   ResumePrivateStateThread();
Index: lldb/source/Core/ThreadedCommunication.cpp
===
--- lldb/source/Core/ThreadedCommunication.cpp
+++ lldb/source/Core/ThreadedCommunication.cpp
@@ -61,11 +61,6 @@
this, GetBroadcasterName());
 }
 
-void ThreadedCommunication::Clear() {
-  SetReadThreadBytesReceivedCallback(nullptr, nullptr);
-  StopReadThread(nullptr);
-  Communication::Clear();
-}
 
 ConnectionStatus ThreadedCommunication::Disconnect(Status *error_ptr) {
   assert((!m_read_thread_enabled || m_read_thread_did_exit) &&
@@ -77,6 +72,7 @@
const Timeout ,
ConnectionStatus ,
Status *error_ptr) {
+  std::shared_lock guard(m_connection_mutex);
   Log *log = GetLog(LLDBLog::Communication);
   LLDB_LOG(
   log,
@@ -152,7 +148,7 @@
 
   // We aren't using a read thread, just read the data synchronously in this
   // thread.
-  return Communication::Read(dst, dst_len, timeout, status, error_ptr);
+  return Communication::ReadUnlocked(dst, dst_len, timeout, status, error_ptr);
 }
 
 bool ThreadedCommunication::StartReadThread(Status *error_ptr) {
@@ -273,46 +269,50 @@
   ConnectionStatus status = eConnectionStatusSuccess;
   bool done = false;
   bool disconnect = false;
-  while (!done && m_read_thread_enabled) {
-size_t bytes_read = ReadFromConnection(
-buf, sizeof(buf), std::chrono::seconds(5), status, );
-if (bytes_read > 0 || status == eConnectionStatusEndOfFile)
-  AppendBytesToCache(buf, bytes_read, true, status);
-
-switch (status) {
-case eConnectionStatusSuccess:
-  break;
-
-case eConnectionStatusEndOfFile:
-  done = true;
-  disconnect = GetCloseOnEOF();
-  break;
-case eConnectionStatusError: // Check GetError() for details
-  if (error.GetType() == eErrorTypePOSIX && error.GetError() == EIO) {
-// EIO on a pipe is usually caused by remote shutdown
+
+  {
+std::shared_lock guard(m_connection_mutex);
+while (!done && m_read_thread_enabled) {
+  size_t bytes_read = ReadUnlocked(buf, sizeof(buf),
+   std::chrono::seconds(5), status, );
+  if (bytes_read > 0 || status == eConnectionStatusEndOfFile)
+AppendBytesToCache(buf, bytes_read, true, status);
+
+  switch (status) {
+  case eConnectionStatusSuccess:
+break;
+
+  case eConnectionStatusEndOfFile:
+done = true;
 disconnect = GetCloseOnEOF();
+break;
+  case eConnectionStatusError: // Check GetError() for details
+if (error.GetType() == eErrorTypePOSIX && error.GetError() == EIO) {
+  // EIO on a pipe is usually caused by remote shutdown
+  disconnect = GetCloseOnEOF();
+  done = true;
+}
+if (error.Fail())
+  LLDB_LOG(log, "error: {0}, status = {1}", error,
+   ThreadedCommunication::ConnectionStatusAsString(status));
+break;
+  case eConnectionStatusInterrupted: // Synchronization signal from
+ // SynchronizeWithReadThread()
+// The connection returns eConnectionStatusInterrupted only when there
+// is no input pending to be read, so we can signal that.
+BroadcastEvent(eBroadcastBitNoMorePendingInput);
+break;
+  case eConnectionStatusNoConnection:   // No connection
+  case eConnectionStatusLostConnection: // Lost connection while connected
+// to a valid connection
 done = true;
+[[fallthrough]];
+  case eConnectionStatusTimedOut: // Request timed out
+if (error.Fail())
+  LLDB_LOG(log, "error: {0}, status = {1}", error,
+   ThreadedCommunication::ConnectionStatusAsString(status));
+break;
   }
-  if 

[Lldb-commits] [lldb] 5d16957 - [lldb] Properly protect the Communication class with reader/writer lock

2023-08-15 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2023-08-15T15:43:36-07:00
New Revision: 5d16957207ce1bd1a2091f3677e176012009c59a

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

LOG: [lldb] Properly protect the Communication class with reader/writer lock

This patch picks up where https://reviews.llvm.org/D157159 left of, but
allows for concurrent reads/writes, but protects setting up and tearing
down the underlying Connection object.

Differential Revision: https://reviews.llvm.org/D157760

Added: 


Modified: 
lldb/include/lldb/Core/Communication.h
lldb/include/lldb/Core/ThreadedCommunication.h
lldb/source/Core/Communication.cpp
lldb/source/Core/ThreadedCommunication.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Communication.h 
b/lldb/include/lldb/Core/Communication.h
index f5f636816cb4f9..7e4ce362acf9a6 100644
--- a/lldb/include/lldb/Core/Communication.h
+++ b/lldb/include/lldb/Core/Communication.h
@@ -16,6 +16,7 @@
 #include "lldb/lldb-types.h"
 
 #include 
+#include 
 #include 
 
 namespace lldb_private {
@@ -46,8 +47,6 @@ class Communication {
   /// The destructor is virtual since this class gets subclassed.
   virtual ~Communication();
 
-  virtual void Clear();
-
   /// Connect using the current connection by passing \a url to its connect
   /// function. string.
   ///
@@ -84,7 +83,10 @@ class Communication {
 
   bool HasConnection() const;
 
-  lldb_private::Connection *GetConnection() { return m_connection_sp.get(); }
+  lldb_private::Connection *GetConnection() {
+std::shared_lock guard(m_connection_mutex);
+return m_connection_sp.get();
+  }
 
   /// Read bytes from the current connection.
   ///
@@ -169,13 +171,24 @@ class Communication {
   ///by this communications class.
   std::mutex
   m_write_mutex; ///< Don't let multiple threads write at the same time...
+  mutable std::shared_mutex m_connection_mutex;
   bool m_close_on_eof;
 
+  /// Same as read but with m_connection_mutex unlocked.
+  size_t ReadUnlocked(void *dst, size_t dst_len,
+  const Timeout ,
+  lldb::ConnectionStatus , Status *error_ptr);
+
   size_t ReadFromConnection(void *dst, size_t dst_len,
 const Timeout ,
 lldb::ConnectionStatus , Status *error_ptr);
 
 private:
+  /// Same as Disconnect but with with m_connection_mutex unlocked.
+  lldb::ConnectionStatus DisconnectUnlocked(Status *error_ptr = nullptr);
+  /// Same as Write but with both m_write_mutex and m_connection_mutex 
unlocked.
+  size_t WriteUnlocked(const void *src, size_t src_len,
+   lldb::ConnectionStatus , Status *error_ptr);
   Communication(const Communication &) = delete;
   const Communication =(const Communication &) = delete;
 };

diff  --git a/lldb/include/lldb/Core/ThreadedCommunication.h 
b/lldb/include/lldb/Core/ThreadedCommunication.h
index 7ebb77beb77f3d..170fd2dfcb555d 100644
--- a/lldb/include/lldb/Core/ThreadedCommunication.h
+++ b/lldb/include/lldb/Core/ThreadedCommunication.h
@@ -97,8 +97,6 @@ class ThreadedCommunication : public Communication, public 
Broadcaster {
   /// The destructor is virtual since this class gets subclassed.
   ~ThreadedCommunication() override;
 
-  void Clear() override;
-
   /// Disconnect the communications connection if one is currently connected.
   ///
   /// \return

diff  --git a/lldb/source/Core/Communication.cpp 
b/lldb/source/Core/Communication.cpp
index 5d890632ccc6a9..e2ba461a02329a 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -27,110 +27,110 @@ using namespace lldb;
 using namespace lldb_private;
 
 Communication::Communication()
-: m_connection_sp(), m_write_mutex(), m_close_on_eof(true) {
-}
-
-Communication::~Communication() {
-  Clear();
-}
+: m_connection_sp(), m_connection_mutex(), m_close_on_eof(true) {}
 
-void Communication::Clear() {
-  Disconnect(nullptr);
-}
+Communication::~Communication() { Disconnect(nullptr); }
 
 ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) {
-  Clear();
+  std::unique_lock guard(m_connection_mutex);
 
   LLDB_LOG(GetLog(LLDBLog::Communication),
"{0} Communication::Connect (url = {1})", this, url);
 
-  lldb::ConnectionSP connection_sp(m_connection_sp);
-  if (connection_sp)
-return connection_sp->Connect(url, error_ptr);
+  DisconnectUnlocked();
+
+  if (m_connection_sp)
+return m_connection_sp->Connect(url, error_ptr);
   if (error_ptr)
 error_ptr->SetErrorString("Invalid connection.");
   return eConnectionStatusNoConnection;
 }
 
 ConnectionStatus Communication::Disconnect(Status *error_ptr) {
+  

[Lldb-commits] [PATCH] D157992: [lldb][CPlusPlus][NFCI] Remove redundant construction of ClangASTImporter

2023-08-15 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92d7254a989d: [lldb][CPlusPlus][NFCI] Remove redundant 
construction of ClangASTImporter (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157992/new/

https://reviews.llvm.org/D157992

Files:
  lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -54,18 +54,6 @@
 if (!clang_ast_context)
   return;
 
-std::shared_ptr clang_ast_importer;
-auto *state = target_sp->GetPersistentExpressionStateForLanguage(
-lldb::eLanguageTypeC_plus_plus);
-if (state) {
-  auto *persistent_vars = llvm::cast(state);
-  clang_ast_importer = persistent_vars->GetClangASTImporter();
-}
-
-if (!clang_ast_importer) {
-  return;
-}
-
 const char *const isa_name("__isa");
 const CompilerType isa_type =
 clang_ast_context->GetBasicType(lldb::eBasicTypeObjCClass);


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -54,18 +54,6 @@
 if (!clang_ast_context)
   return;
 
-std::shared_ptr clang_ast_importer;
-auto *state = target_sp->GetPersistentExpressionStateForLanguage(
-lldb::eLanguageTypeC_plus_plus);
-if (state) {
-  auto *persistent_vars = llvm::cast(state);
-  clang_ast_importer = persistent_vars->GetClangASTImporter();
-}
-
-if (!clang_ast_importer) {
-  return;
-}
-
 const char *const isa_name("__isa");
 const CompilerType isa_type =
 clang_ast_context->GetBasicType(lldb::eBasicTypeObjCClass);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 92d7254 - [lldb][CPlusPlus][NFCI] Remove redundant construction of ClangASTImporter

2023-08-15 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-08-15T23:09:59+01:00
New Revision: 92d7254a989d106ba63e64d315dbb9397c275671

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

LOG: [lldb][CPlusPlus][NFCI] Remove redundant construction of ClangASTImporter

The usage of this variable was removed in 
`4f14c17df70916913d71914343dd4f6c709e218d`.

This is no longer used inside this file. Since the call to
`GetPersistentExpressionStateForLanguage` has side-effects I marked this
NFCI. But there is no good reason we need this here.

Differential Revision: https://reviews.llvm.org/D157992

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index e780cd8285c455..314a4aca8d2663 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -54,18 +54,6 @@ class BlockPointerSyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
 if (!clang_ast_context)
   return;
 
-std::shared_ptr clang_ast_importer;
-auto *state = target_sp->GetPersistentExpressionStateForLanguage(
-lldb::eLanguageTypeC_plus_plus);
-if (state) {
-  auto *persistent_vars = llvm::cast(state);
-  clang_ast_importer = persistent_vars->GetClangASTImporter();
-}
-
-if (!clang_ast_importer) {
-  return;
-}
-
 const char *const isa_name("__isa");
 const CompilerType isa_type =
 clang_ast_context->GetBasicType(lldb::eBasicTypeObjCClass);



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


[Lldb-commits] [PATCH] D157556: Replace the singleton "ShadowListener" with a primary and N secondary listeners

2023-08-15 Thread Jim Ingham via Phabricator via lldb-commits
jingham marked 4 inline comments as done.
jingham added a comment.

I implemented Alex's suggestion for a GetListeners filter, but doing that 
triggered some bugs due to the fact that we weren't really pruning the 
m_listeners correctly as listeners come and go.  I fixed some bugs there along 
with implementing this suggestion.




Comment at: lldb/source/Utility/Broadcaster.cpp:154-157
+  // The primary listener listens for all event bits:
+  if (m_primary_listener_sp)
+return true;
+

clayborg wrote:
> Does the primary listener need to listen to all event bits?
I don't see a use case for saying "I want to be the one that gets first crack 
at this broadcaster" but only for some bits.  Plus, if we do it that way, we'd 
really have to have a map of "primary listener -> event mask" and add a way to 
make yourself the primary listener for only some bits.

We have this ability for HijackListeners, but we never use it, we always just 
hijack all bits as well...

There's no reason you can't do it that way, but until we see a need for 
multiple primary listeners, I don't think the extra complexity is warranted.



Comment at: lldb/source/Utility/Broadcaster.cpp:253
+  continue;
+if (pair.first != hijacking_listener_sp 
+&& pair.first != m_primary_listener_sp)

bulbazord wrote:
> nit: Checking to see if `pair.first` is `hijacking_listener_sp` is redundant. 
> If you've gotten to this point, `hijacking_listener_sp` must be pointing to 
> `nullptr`.
Interestingly enough, that was effectively a check on empty listeners in 
m_listeners.  There shouldn't have been any, but we weren't being very careful 
about pruning the list...



Comment at: lldb/source/Utility/Broadcaster.cpp:254
+if (pair.first != hijacking_listener_sp 
+&& pair.first != m_primary_listener_sp)
+  event_sp->AddPendingListener(pair.first);

bulbazord wrote:
> Why might `pair.first` be `m_primary_listener_sp`? I would assume that if a 
> primary listener is set, it wouldn't be among the other listeners in a 
> broadcaster But I suppose nothing stops you from doing that.
That's really an oversight in GetListeners.  That correctly doesn't return the 
Hijack listener, since that is a hidden agent, but the primary listener only 
differs from the secondary listeners in how dispatch gets done.  I fixed that 
in this patch.



Comment at: 
lldb/test/API/functionalities/interactive_scripted_process/TestInteractiveScriptedProcess.py:38-44
+self, self.dbg.GetListener(), self.mux_process.GetBroadcaster()
+)
+self.assertState(lldb.SBProcess.GetStateFromEvent(event), 
lldb.eStateRunning)
+event = lldbutil.fetch_next_event(
+self, self.dbg.GetListener(), self.mux_process.GetBroadcaster()
+)
+self.assertState(lldb.SBProcess.GetStateFromEvent(event), 
lldb.eStateStopped)

bulbazord wrote:
> This is to make sure that the primary listener is getting the run/stop events 
> before the `mux_process_listener` right?
correct.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157556/new/

https://reviews.llvm.org/D157556

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


[Lldb-commits] [PATCH] D158017: [lldb][NFCI] Rewrite error-handling code in ProcessGDBRemote::MonitorDebugserverProcess

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:3379-3385
+  const char *signal_name =
   process_sp->GetUnixSignals()->GetSignalAsCString(signo);
-  if (signal_cstr)
-::snprintf(error_str, sizeof(error_str),
-   DEBUGSERVER_BASENAME " died with signal %s", signal_cstr);
+  const char *format_str = DEBUGSERVER_BASENAME " died with signal {0}";
+  if (signal_name)
+stream.Format(format_str, signal_name);
   else
+stream.Format(format_str, signo);




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158017/new/

https://reviews.llvm.org/D158017

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


[Lldb-commits] [PATCH] D157556: Replace the singleton "ShadowListener" with a primary and N secondary listeners

2023-08-15 Thread Jim Ingham via Phabricator via lldb-commits
jingham updated this revision to Diff 550495.
jingham added a comment.

Respond to review comments.

In the course of implementing Alex's suggestion to add a filter to 
GetListeners, I noticed that there we were being lax in our dealing with 
removed listeners.  RemoveListener didn't actually do that, it just removed the 
event bits, and the next pass through GetListeners would actually clear out the 
entry.

Fixing that required a few other little fixes to get this working again.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157556/new/

https://reviews.llvm.org/D157556

Files:
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Utility/Broadcaster.h
  lldb/include/lldb/Utility/Event.h
  lldb/source/Target/Process.cpp
  lldb/source/Utility/Broadcaster.cpp
  lldb/source/Utility/Event.cpp
  lldb/source/Utility/Listener.cpp
  lldb/test/API/api/listeners/TestListener.py
  
lldb/test/API/functionalities/interactive_scripted_process/TestInteractiveScriptedProcess.py
  lldb/test/API/python_api/event/TestEvents.py

Index: lldb/test/API/python_api/event/TestEvents.py
===
--- lldb/test/API/python_api/event/TestEvents.py
+++ lldb/test/API/python_api/event/TestEvents.py
@@ -313,3 +313,121 @@
 self.assertEqual(
 self.state, "stopped", "Both expected state changed events received"
 )
+
+def wait_for_next_event(self, expected_state, test_shadow = False):
+"""Wait for an event from self.primary & self.shadow listener.
+   If test_shadow is true, we also check that the shadow listener only 
+   receives events AFTER the primary listener does."""
+# Waiting on the shadow listener shouldn't have events yet because
+# we haven't fetched them for the primary listener yet:
+event = lldb.SBEvent()
+
+if test_shadow:
+success = self.shadow_listener.WaitForEvent(1, event)
+self.assertFalse(success, "Shadow listener doesn't pull events")
+
+# But there should be an event for the primary listener:
+success = self.primary_listener.WaitForEvent(5, event)
+self.assertTrue(success, "Primary listener got the event")
+
+state = lldb.SBProcess.GetStateFromEvent(event)
+restart = False
+if state == lldb.eStateStopped:
+restart = lldb.SBProcess.GetRestartedFromEvent(event)
+
+if expected_state != None:
+self.assertEqual(state, expected_state, "Primary thread got the correct event")
+
+# And after pulling that one there should be an equivalent event for the shadow
+# listener:
+success = self.shadow_listener.WaitForEvent(5, event)
+self.assertTrue(success, "Shadow listener got event too")
+self.assertEqual(state, lldb.SBProcess.GetStateFromEvent(event), "It was the same event")
+self.assertEqual(restart, lldb.SBProcess.GetRestartedFromEvent(event), "It was the same restarted")
+
+return state, restart
+
+def test_shadow_listener(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# Now create a breakpoint on main.c by name 'c'.
+bkpt1 = target.BreakpointCreateByName("c", "a.out")
+self.trace("breakpoint:", bkpt1)
+self.assertTrue(bkpt1.GetNumLocations() == 1, VALID_BREAKPOINT)
+
+self.primary_listener = lldb.SBListener("my listener")
+self.shadow_listener = lldb.SBListener("shadow listener")
+
+self.cur_thread = None
+
+error = lldb.SBError()
+launch_info = target.GetLaunchInfo()
+launch_info.SetListener(self.primary_listener)
+launch_info.SetShadowListener(self.shadow_listener)
+
+self.runCmd("settings set target.process.extra-startup-command QSetLogging:bitmask=LOG_PROCESS|LOG_EXCEPTIONS|LOG_RNB_PACKETS|LOG_STEP;")
+self.dbg.SetAsync(True)
+
+self.process = target.Launch(launch_info, error)
+self.assertSuccess(error, "Process launched successfully")
+
+# Keep fetching events from the primary to trigger the do on removal and
+# then from the shadow listener, and make sure they match:
+
+# Events in the launch sequence might be platform dependent, so don't
+# expect any particular event till we get the stopped:
+state = lldb.eStateInvalid
+while state != lldb.eStateStopped:
+state, restart = self.wait_for_next_event(None, False)
+
+# Okay, we're now at a good stop, so try a next:
+self.cur_thread = self.process.threads[0]
+
+# Make sure we're at our expected breakpoint:
+self.assertTrue(self.cur_thread.IsValid(), "Got a zeroth thread")
+

[Lldb-commits] [PATCH] D157960: [lldb][gui] Update TreeItem children's m_parent on move

2023-08-15 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py:38
+for i in range(5):
+# Stopped at the breakpoit, continue over the thread creation
+self.child.send("c")




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157960/new/

https://reviews.llvm.org/D157960

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


[Lldb-commits] [PATCH] D158026: [lldb][NFCI] Remove unneeded ConstString from ValueObject::GetValueForExpressionPath_Impl

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, kastiglione, jingham.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158026

Files:
  lldb/source/Core/ValueObject.cpp


Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2148,11 +2148,10 @@
   temp_expression = temp_expression.drop_front(); // skip . or >
 
   size_t next_sep_pos = temp_expression.find_first_of("-.[", 1);
-  ConstString child_name;
   if (next_sep_pos == llvm::StringRef::npos) // if no other separator just
  // expand this last layer
   {
-child_name.SetString(temp_expression);
+llvm::StringRef child_name = temp_expression;
 ValueObjectSP child_valobj_sp =
 root->GetChildMemberWithName(child_name);
 
@@ -2220,8 +2219,7 @@
   } else // other layers do expand
   {
 llvm::StringRef next_separator = temp_expression.substr(next_sep_pos);
-
-child_name.SetString(temp_expression.slice(0, next_sep_pos));
+llvm::StringRef child_name = temp_expression.slice(0, next_sep_pos);
 
 ValueObjectSP child_valobj_sp =
 root->GetChildMemberWithName(child_name);


Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -2148,11 +2148,10 @@
   temp_expression = temp_expression.drop_front(); // skip . or >
 
   size_t next_sep_pos = temp_expression.find_first_of("-.[", 1);
-  ConstString child_name;
   if (next_sep_pos == llvm::StringRef::npos) // if no other separator just
  // expand this last layer
   {
-child_name.SetString(temp_expression);
+llvm::StringRef child_name = temp_expression;
 ValueObjectSP child_valobj_sp =
 root->GetChildMemberWithName(child_name);
 
@@ -2220,8 +2219,7 @@
   } else // other layers do expand
   {
 llvm::StringRef next_separator = temp_expression.substr(next_sep_pos);
-
-child_name.SetString(temp_expression.slice(0, next_sep_pos));
+llvm::StringRef child_name = temp_expression.slice(0, next_sep_pos);
 
 ValueObjectSP child_valobj_sp =
 root->GetChildMemberWithName(child_name);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157648: [lldb] Fix data race in Process

2023-08-15 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 added a comment.

@JDevlieghere do you have any opinions on this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157648/new/

https://reviews.llvm.org/D157648

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


[Lldb-commits] [PATCH] D158024: [lldb][NFCI] Remove unused method overload of ValueObject::GetChildAtNamePath

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, kastiglione, jingham.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158024

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/source/Core/ValueObject.cpp


Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -440,23 +440,6 @@
   return root;
 }
 
-lldb::ValueObjectSP ValueObject::GetChildAtNamePath(
-llvm::ArrayRef> names,
-ConstString *name_of_error) {
-  if (names.size() == 0)
-return GetSP();
-  ValueObjectSP root(GetSP());
-  for (std::pair name : names) {
-root = root->GetChildMemberWithName(name.first, name.second);
-if (!root) {
-  if (name_of_error)
-*name_of_error = name.first;
-  return root;
-}
-  }
-  return root;
-}
-
 size_t ValueObject::GetIndexOfChildWithName(llvm::StringRef name) {
   bool omit_empty_base_classes = true;
   return GetCompilerType().GetIndexOfChildWithName(name,
Index: lldb/include/lldb/Core/ValueObject.h
===
--- lldb/include/lldb/Core/ValueObject.h
+++ lldb/include/lldb/Core/ValueObject.h
@@ -479,10 +479,6 @@
   // this will always create the children if necessary
   lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef 
names);
 
-  lldb::ValueObjectSP
-  GetChildAtNamePath(llvm::ArrayRef> names,
- ConstString *name_of_error = nullptr);
-
   virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
  bool can_create = true);
 


Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -440,23 +440,6 @@
   return root;
 }
 
-lldb::ValueObjectSP ValueObject::GetChildAtNamePath(
-llvm::ArrayRef> names,
-ConstString *name_of_error) {
-  if (names.size() == 0)
-return GetSP();
-  ValueObjectSP root(GetSP());
-  for (std::pair name : names) {
-root = root->GetChildMemberWithName(name.first, name.second);
-if (!root) {
-  if (name_of_error)
-*name_of_error = name.first;
-  return root;
-}
-  }
-  return root;
-}
-
 size_t ValueObject::GetIndexOfChildWithName(llvm::StringRef name) {
   bool omit_empty_base_classes = true;
   return GetCompilerType().GetIndexOfChildWithName(name,
Index: lldb/include/lldb/Core/ValueObject.h
===
--- lldb/include/lldb/Core/ValueObject.h
+++ lldb/include/lldb/Core/ValueObject.h
@@ -479,10 +479,6 @@
   // this will always create the children if necessary
   lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef names);
 
-  lldb::ValueObjectSP
-  GetChildAtNamePath(llvm::ArrayRef> names,
- ConstString *name_of_error = nullptr);
-
   virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
  bool can_create = true);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d70d5e9 - Get binary UUID from fixed location in special Mach-O corefiles

2023-08-15 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-08-15T13:49:57-07:00
New Revision: d70d5e9f6fa2770f9a5e7be4ba6b3512f5424968

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

LOG: Get binary UUID from fixed location in special Mach-O corefiles

Some Apple firmware environments store the UUID of the main binary
at a fixed address in low memory.  Add that list of addresess to
ProcessMachCore to check for a UUID, and try to load it.

Differential Revision: https://reviews.llvm.org/D157756

Added: 


Modified: 
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp 
b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index 9ad6d70e25299d..9859e5982a01df 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -28,6 +28,7 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/State.h"
+#include "lldb/Utility/UUID.h"
 
 #include "ProcessMachCore.h"
 #include "Plugins/Process/Utility/StopInfoMachException.h"
@@ -223,6 +224,66 @@ void ProcessMachCore::CreateMemoryRegions() {
   }
 }
 
+// Some corefiles have a UUID stored in a low memory
+// address.  We inspect a set list of addresses for
+// the characters 'uuid' and 16 bytes later there will
+// be a uuid_t UUID.  If we can find a binary that
+// matches the UUID, it is loaded with no slide in the target.
+bool ProcessMachCore::LoadBinaryViaLowmemUUID() {
+  Log *log(GetLog(LLDBLog::DynamicLoader | LLDBLog::Process));
+  ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
+
+  uint64_t lowmem_uuid_addresses[] = {0x2000204, 0x1000204, 0x120, 0x4204,
+  0x1204,0x1020,0x4020,0xc00,
+  0xC0,  0};
+
+  for (uint64_t addr : lowmem_uuid_addresses) {
+const VMRangeToFileOffset::Entry *core_memory_entry =
+m_core_aranges.FindEntryThatContains(addr);
+if (core_memory_entry) {
+  const addr_t offset = addr - core_memory_entry->GetRangeBase();
+  const addr_t bytes_left = core_memory_entry->GetRangeEnd() - addr;
+  // (4-bytes 'uuid' + 12 bytes pad for align + 16 bytes uuid_t) == 32 
bytes
+  if (bytes_left >= 32) {
+char strbuf[4];
+if (core_objfile->CopyData(
+core_memory_entry->data.GetRangeBase() + offset, 4, ) &&
+strncmp("uuid", (char *), 4) == 0) {
+  uuid_t uuid_bytes;
+  if (core_objfile->CopyData(core_memory_entry->data.GetRangeBase() +
+ offset + 16,
+ sizeof(uuid_t), uuid_bytes)) {
+UUID uuid(uuid_bytes, sizeof(uuid_t));
+if (uuid.IsValid()) {
+  LLDB_LOGF(log,
+"ProcessMachCore::LoadBinaryViaLowmemUUID: found "
+"binary uuid %s at low memory address 0x%" PRIx64,
+uuid.GetAsString().c_str(), addr);
+  // We have no address specified, only a UUID.  Load it at the 
file
+  // address.
+  const bool value_is_offset = true;
+  const bool force_symbol_search = true;
+  const bool notify = true;
+  const bool set_address_in_target = true;
+  const bool allow_memory_image_last_resort = false;
+  if (DynamicLoader::LoadBinaryWithUUIDAndAddress(
+  this, llvm::StringRef(), uuid, 0, value_is_offset,
+  force_symbol_search, notify, set_address_in_target,
+  allow_memory_image_last_resort)) {
+m_dyld_plugin_name = 
DynamicLoaderStatic::GetPluginNameStatic();
+  }
+  // We found metadata saying which binary should be loaded; don't
+  // try an exhaustive search.
+  return true;
+}
+  }
+}
+  }
+}
+  }
+  return false;
+}
+
 bool ProcessMachCore::LoadBinariesViaMetadata() {
   Log *log(GetLog(LLDBLog::DynamicLoader | LLDBLog::Process));
   ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
@@ -338,6 +399,9 @@ bool ProcessMachCore::LoadBinariesViaMetadata() {
 m_dyld_plugin_name = DynamicLoaderStatic::GetPluginNameStatic();
   }
 
+  if (!found_binary_spec_in_metadata && LoadBinaryViaLowmemUUID())
+found_binary_spec_in_metadata = true;
+
   // LoadCoreFileImges may have set the dynamic loader, e.g. in
   // PlatformDarwinKernel::LoadPlatformBinaryAndSetup().
   // If we now have a dynamic loader, save its name so we don't 

diff  --git 

[Lldb-commits] [PATCH] D158023: [lldb] Simplify the LLDB website structure

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: LLDB.
Herald added a subscriber: arphaman.
Herald added a project: All.
JDevlieghere requested review of this revision.

Feedback I hear regularly is that the LLDB website is hard to navigate. This 
patch is an attempt to simplify things by breaking the website up in 3 major 
areas: using LLDB, extending LLDB and developing LLDB.

Concretely:

- The majority of the "project" pages were eliminated, with the exception of 
the projects page, which was moved under "Developing LLDB". The goals, features 
and status page were pretty outdated and while they probably made sense in the 
past, they don't feel all that relevant anymore now that LLDB is an established 
debugger. The releases page was replaced with a link under "External links".
- "USE & EXTENSION" was renamed to "Using LLDB". Besides that this section 
remained mostly unchanged, with the exception of the Python pages which were 
moved under "Extending LLDB".
- "Development" was renamed to "Developing LLDB" and now houses all the 
resources for LLDB developers. The old "Design" section (which only contained 
two pages) was moved back under here too.


https://reviews.llvm.org/D158023

Files:
  lldb/docs/.htaccess
  lldb/docs/design/overview.rst
  lldb/docs/design/sbapi.rst
  lldb/docs/index.rst
  lldb/docs/resources/fuzzing.rst
  lldb/docs/resources/overview.rst
  lldb/docs/resources/projects.rst
  lldb/docs/resources/sbapi.rst
  lldb/docs/status/features.rst
  lldb/docs/status/goals.rst
  lldb/docs/status/projects.rst
  lldb/docs/status/releases.rst
  lldb/docs/status/status.rst

Index: lldb/docs/status/status.rst
===
--- lldb/docs/status/status.rst
+++ /dev/null
@@ -1,68 +0,0 @@
-Status
-==
-
-FreeBSD

-
-LLDB on FreeBSD lags behind the Linux implementation but is improving rapidly.
-For more details, see the Features by OS section below.
-
-Linux
--
-
-LLDB is improving on Linux. Linux is nearing feature completeness with Darwin
-to debug x86_64, i386, ARM, AArch64, IBM POWER (ppc64), and IBM Z (s390x)
-programs. For more details, see the Features by OS section below.
-
-macOS
--
-
-LLDB is the system debugger on macOS, iOS, tvOS, and watchOS and
-can be used for C, C++, Objective-C and Swift development for x86_64,
-i386, ARM, and AArch64 debugging. The entire public API is exposed
-through a macOS framework which is used by Xcode and the `lldb`
-command line tool. It can also be imported from Python. The entire public API is
-exposed through script bridging which allows LLDB to use an embedded Python
-script interpreter, as well as having a Python module named "lldb" which can be
-used from Python on the command line. This allows debug sessions to be
-scripted. It also allows powerful debugging actions to be created and attached
-to a variety of debugging workflows.
-
-NetBSD
---
-
-LLDB is improving on NetBSD and reaching feature completeness with Linux.
-
-Windows

-
-LLDB on Windows is still under development, but already useful for i386
-programs (x86_64 untested) built with DWARF debug information, including
-postmortem analysis of minidumps. For more details, see the Features by OS
-section below.
-
-Features Matrix

-+---++-+---++--+
-| Feature   | FreeBSD| Linux   | macOS | NetBSD | Windows  |
-+===++=+===++==+
-| Backtracing   | YES| YES | YES   | YES| YES  |
-+---++-+---++--+
-| Breakpoints   | YES| YES | YES   | YES| YES  |
-+---++-+---++--+
-| C++11:| YES| YES | YES   | YES| Unknown  |
-+---++-+---++--+
-| Commandline tool  | YES| YES | YES   | YES| YES  |
-+---++-+---++--+
-| Core file debugging   | YES (ELF)  | YES (ELF)   | YES (MachO)   | YES (ELF)  | YES (Minidump)   |

[Lldb-commits] [PATCH] D158022: [lldb] Print an actionable error message when sphinx_automodapi is not installed

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: LLDB.
Herald added a project: All.
JDevlieghere requested review of this revision.

Print an error message with instructions on how to install sphinx_automodapi.


https://reviews.llvm.org/D158022

Files:
  lldb/docs/conf.py


Index: lldb/docs/conf.py
===
--- lldb/docs/conf.py
+++ lldb/docs/conf.py
@@ -49,6 +49,12 @@
 # Unless we only generate the basic manpage we need the plugin for generating
 # the Python API documentation.
 if not building_man_page:
+try:
+import sphinx_automodapi.automodapi
+except ModuleNotFoundError:
+print(
+f"install sphinx_automodapi with {sys.executable} -m pip install 
sphinx_automodapi"
+)
 extensions.append("sphinx_automodapi.automodapi")
 
 # Add any paths that contain templates here, relative to this directory.


Index: lldb/docs/conf.py
===
--- lldb/docs/conf.py
+++ lldb/docs/conf.py
@@ -49,6 +49,12 @@
 # Unless we only generate the basic manpage we need the plugin for generating
 # the Python API documentation.
 if not building_man_page:
+try:
+import sphinx_automodapi.automodapi
+except ModuleNotFoundError:
+print(
+f"install sphinx_automodapi with {sys.executable} -m pip install sphinx_automodapi"
+)
 extensions.append("sphinx_automodapi.automodapi")
 
 # Add any paths that contain templates here, relative to this directory.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5ed62c7 - Added a use of uuid_t, need to incl AppleUuidCompatibility.h

2023-08-15 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-08-15T13:52:37-07:00
New Revision: 5ed62c7bc99a979261d34e41aaca9581577674bf

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

LOG: Added a use of uuid_t, need to incl AppleUuidCompatibility.h

Added: 


Modified: 
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp 
b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index 9859e5982a01df..70c5a36dbb5dbb 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -24,6 +24,7 @@
 #include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Utility/AppleUuidCompatibility.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"



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


[Lldb-commits] [PATCH] D157756: Support corefiles that put the uuid of their binary in a fixed address in low memory; load that binary

2023-08-15 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd70d5e9f6fa2: Get binary UUID from fixed location in special 
Mach-O corefiles (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157756/new/

https://reviews.llvm.org/D157756

Files:
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.h

Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -87,6 +87,8 @@
 private:
   void CreateMemoryRegions();
 
+  bool LoadBinaryViaLowmemUUID();
+
   /// \return
   ///   True if any metadata were found indicating the binary that should
   ///   be loaded, regardless of whether the specified binary could be found.
Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -28,6 +28,7 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/State.h"
+#include "lldb/Utility/UUID.h"
 
 #include "ProcessMachCore.h"
 #include "Plugins/Process/Utility/StopInfoMachException.h"
@@ -223,6 +224,66 @@
   }
 }
 
+// Some corefiles have a UUID stored in a low memory
+// address.  We inspect a set list of addresses for
+// the characters 'uuid' and 16 bytes later there will
+// be a uuid_t UUID.  If we can find a binary that
+// matches the UUID, it is loaded with no slide in the target.
+bool ProcessMachCore::LoadBinaryViaLowmemUUID() {
+  Log *log(GetLog(LLDBLog::DynamicLoader | LLDBLog::Process));
+  ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
+
+  uint64_t lowmem_uuid_addresses[] = {0x2000204, 0x1000204, 0x120, 0x4204,
+  0x1204,0x1020,0x4020,0xc00,
+  0xC0,  0};
+
+  for (uint64_t addr : lowmem_uuid_addresses) {
+const VMRangeToFileOffset::Entry *core_memory_entry =
+m_core_aranges.FindEntryThatContains(addr);
+if (core_memory_entry) {
+  const addr_t offset = addr - core_memory_entry->GetRangeBase();
+  const addr_t bytes_left = core_memory_entry->GetRangeEnd() - addr;
+  // (4-bytes 'uuid' + 12 bytes pad for align + 16 bytes uuid_t) == 32 bytes
+  if (bytes_left >= 32) {
+char strbuf[4];
+if (core_objfile->CopyData(
+core_memory_entry->data.GetRangeBase() + offset, 4, ) &&
+strncmp("uuid", (char *), 4) == 0) {
+  uuid_t uuid_bytes;
+  if (core_objfile->CopyData(core_memory_entry->data.GetRangeBase() +
+ offset + 16,
+ sizeof(uuid_t), uuid_bytes)) {
+UUID uuid(uuid_bytes, sizeof(uuid_t));
+if (uuid.IsValid()) {
+  LLDB_LOGF(log,
+"ProcessMachCore::LoadBinaryViaLowmemUUID: found "
+"binary uuid %s at low memory address 0x%" PRIx64,
+uuid.GetAsString().c_str(), addr);
+  // We have no address specified, only a UUID.  Load it at the file
+  // address.
+  const bool value_is_offset = true;
+  const bool force_symbol_search = true;
+  const bool notify = true;
+  const bool set_address_in_target = true;
+  const bool allow_memory_image_last_resort = false;
+  if (DynamicLoader::LoadBinaryWithUUIDAndAddress(
+  this, llvm::StringRef(), uuid, 0, value_is_offset,
+  force_symbol_search, notify, set_address_in_target,
+  allow_memory_image_last_resort)) {
+m_dyld_plugin_name = DynamicLoaderStatic::GetPluginNameStatic();
+  }
+  // We found metadata saying which binary should be loaded; don't
+  // try an exhaustive search.
+  return true;
+}
+  }
+}
+  }
+}
+  }
+  return false;
+}
+
 bool ProcessMachCore::LoadBinariesViaMetadata() {
   Log *log(GetLog(LLDBLog::DynamicLoader | LLDBLog::Process));
   ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
@@ -338,6 +399,9 @@
 m_dyld_plugin_name = DynamicLoaderStatic::GetPluginNameStatic();
   }
 
+  if (!found_binary_spec_in_metadata && LoadBinaryViaLowmemUUID())
+found_binary_spec_in_metadata = true;
+
   // LoadCoreFileImges may have set the dynamic loader, e.g. in
   // PlatformDarwinKernel::LoadPlatformBinaryAndSetup().
   // If we now have a dynamic loader, save its name so we don't 
___

[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies added inline comments.



Comment at: lldb/source/Commands/CommandObjectType.cpp:2174
 
-#if LLDB_ENABLE_PYTHON
-

jingham wrote:
> electriclilies wrote:
> > rriddle wrote:
> > > Why is this dropped?
> > Walter and I want to use the synthetic types from C++, but right now it's 
> > only supported in Python. The motivation behind this is to make it so that 
> > we can actually use the synthetic types. 
> Just to be clear.  There are already lots of synthetic child providers 
> implemented in C++ in in lldb already (look for CXXSyntheticChildren 
> constructors in CPlusPlusLanguage.cpp for instance).  
> 
> I think what you are saying is that you are removing the restriction that you 
> have to BUILD lldb with Python in order to add C++ implemented summaries.  If 
> that's indeed what you are saying, then this is fine, since that seems an odd 
> restriction...
> 
> But it would be nice to have some kind of testing that this actually works, 
> since I don't think any of our bots build lldb w/o Python.
Yes that's exactly it! I agree it would be nice to have a test for it but I 
don't know how to add it. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

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


[Lldb-commits] [lldb] 3ad618f - Update qHostInfo/LC_NOTE so multiple address bits can be specified

2023-08-15 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-08-15T13:21:33-07:00
New Revision: 3ad618f4aea1ef7442f7ff75d92632aec177a4fd

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

LOG: Update qHostInfo/LC_NOTE so multiple address bits can be specified

On AArch64 systems, we may have different page table setups for
low memory and high memory, and therefore a different number of
bits used for addressing depending on which half of memory the
address is in.

This patch extends the qHostInfo and LC_NOTE "addrable bits" so
that it can specify the number of addressing bits in high memory
and in low memory separately.  It builds on the patch I added in
https://reviews.llvm.org/D151292 where Process tracks the separate
address masks, and there is a user setting to set them manually.

Differential Revision: https://reviews.llvm.org/D157667
rdar://113225907

Added: 
lldb/include/lldb/Utility/AddressableBits.h
lldb/source/Utility/AddressableBits.cpp

Modified: 
lldb/docs/lldb-gdb-remote.txt
lldb/include/lldb/Symbol/ObjectFile.h
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Utility/CMakeLists.txt

Removed: 




diff  --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt
index 27adaa33d14045..bfc10133051a3a 100644
--- a/lldb/docs/lldb-gdb-remote.txt
+++ b/lldb/docs/lldb-gdb-remote.txt
@@ -978,6 +978,14 @@ addressing_bits: optional, specifies how many bits in 
addresses are
 v8.3 ABIs that use pointer authentication, so lldb
 knows which bits to clear/set to get the actual
 addresses.
+low_mem_addressing_bits: optional, specifies how many bits in 
+ addresses in low memory are significant for addressing, base 10.  
+ AArch64 can have 
diff erent page table setups for low and high
+ memory, and therefore a 
diff erent number of bits used for addressing.
+high_mem_addressing_bits: optional, specifies how many bits in 
+ addresses in high memory are significant for addressing, base 10.  
+ AArch64 can have 
diff erent page table setups for low and high
+ memory, and therefore a 
diff erent number of bits used for addressing.
 
 //--
 // "qGDBServerVersion"

diff  --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index 2fc1cc582d2ceb..02d1248e23c342 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -13,6 +13,7 @@
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Symbol/Symtab.h"
 #include "lldb/Symbol/UnwindTable.h"
+#include "lldb/Utility/AddressableBits.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/FileSpec.h"
@@ -494,13 +495,18 @@ class ObjectFile : public 
std::enable_shared_from_this,
 
   /// Some object files may have the number of bits used for addressing
   /// embedded in them, e.g. a Mach-O core file using an LC_NOTE.  These
-  /// object files can return the address mask that should be used in
-  /// the Process.
+  /// object files can return an AddressableBits object that can can be
+  /// used to set the address masks in the Process.
+  ///
+  /// \param[out] address_bits
+  /// Can be used to set the Process address masks.
+  ///
   /// \return
-  /// The mask will have bits set which aren't used for addressing --
-  /// typically, the high bits.
-  /// Zero is returned when no address bits mask is available.
-  virtual lldb::addr_t GetAddressMask() { return 0; }
+  /// Returns true if addressable bits metadata was found.
+  virtual bool GetAddressableBits(lldb_private::AddressableBits _bits) 
{
+address_bits.Clear();
+return false;
+  }
 
   /// When the ObjectFile is a core file, lldb needs to locate the "binary" in
   /// the core file.  lldb can iterate over the pages looking for a valid

diff  --git a/lldb/include/lldb/Utility/AddressableBits.h 
b/lldb/include/lldb/Utility/AddressableBits.h
new file mode 100644
index 00..d7e2e341569655
--- /dev/null
+++ b/lldb/include/lldb/Utility/AddressableBits.h
@@ -0,0 +1,43 @@
+//===-- AddressableBits.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 

[Lldb-commits] [PATCH] D158017: [lldb][NFCI] Rewrite error-handling code in ProcessGDBRemote::MonitorDebugserverProcess

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, jasonmolenda, jingham, mib.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I'm rewriting this for 2 reasons:

1. Although a 1024 char buffer is probably enough space, the error string may 
grow beyond that and we could lose some information. Using StringStream (as we 
do in the rest of ProcessGDBRemote) seems like a sensible solution.
2. I am planning on changing `UnixSignals::GetSignalAsCString`, rewriting 
things with `llvm::formatv` will make that process easier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158017

Files:
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3371,23 +3371,20 @@
 
   if (state != eStateInvalid && state != eStateUnloaded &&
   state != eStateExited && state != eStateDetached) {
-char error_str[1024];
-if (signo) {
-  const char *signal_cstr =
+StreamString stream;
+if (signo == 0)
+  stream.Format(DEBUGSERVER_BASENAME " died with an exit status of {0:x8}",
+exit_status);
+else {
+  const char *signal_name =
   process_sp->GetUnixSignals()->GetSignalAsCString(signo);
-  if (signal_cstr)
-::snprintf(error_str, sizeof(error_str),
-   DEBUGSERVER_BASENAME " died with signal %s", signal_cstr);
+  const char *format_str = DEBUGSERVER_BASENAME " died with signal {0}";
+  if (signal_name)
+stream.Format(format_str, signal_name);
   else
-::snprintf(error_str, sizeof(error_str),
-   DEBUGSERVER_BASENAME " died with signal %i", signo);
-} else {
-  ::snprintf(error_str, sizeof(error_str),
- DEBUGSERVER_BASENAME " died with an exit status of 0x%8.8x",
- exit_status);
+stream.Format(format_str, signo);
 }
-
-process_sp->SetExitStatus(-1, error_str);
+process_sp->SetExitStatus(-1, stream.GetString());
   }
   // Debugserver has exited we need to let our ProcessGDBRemote know that it no
   // longer has a debugserver instance


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3371,23 +3371,20 @@
 
   if (state != eStateInvalid && state != eStateUnloaded &&
   state != eStateExited && state != eStateDetached) {
-char error_str[1024];
-if (signo) {
-  const char *signal_cstr =
+StreamString stream;
+if (signo == 0)
+  stream.Format(DEBUGSERVER_BASENAME " died with an exit status of {0:x8}",
+exit_status);
+else {
+  const char *signal_name =
   process_sp->GetUnixSignals()->GetSignalAsCString(signo);
-  if (signal_cstr)
-::snprintf(error_str, sizeof(error_str),
-   DEBUGSERVER_BASENAME " died with signal %s", signal_cstr);
+  const char *format_str = DEBUGSERVER_BASENAME " died with signal {0}";
+  if (signal_name)
+stream.Format(format_str, signal_name);
   else
-::snprintf(error_str, sizeof(error_str),
-   DEBUGSERVER_BASENAME " died with signal %i", signo);
-} else {
-  ::snprintf(error_str, sizeof(error_str),
- DEBUGSERVER_BASENAME " died with an exit status of 0x%8.8x",
- exit_status);
+stream.Format(format_str, signo);
 }
-
-process_sp->SetExitStatus(-1, error_str);
+process_sp->SetExitStatus(-1, stream.GetString());
   }
   // Debugserver has exited we need to let our ProcessGDBRemote know that it no
   // longer has a debugserver instance
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157667: Define qHostInfo and Mach-O LC_NOTE "addrable bits" methods to describe high and low memory addressing bits

2023-08-15 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ad618f4aea1: Update qHostInfo/LC_NOTE so multiple address 
bits can be specified (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157667/new/

https://reviews.llvm.org/D157667

Files:
  lldb/docs/lldb-gdb-remote.txt
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/include/lldb/Utility/AddressableBits.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Utility/AddressableBits.cpp
  lldb/source/Utility/CMakeLists.txt

Index: lldb/source/Utility/CMakeLists.txt
===
--- lldb/source/Utility/CMakeLists.txt
+++ lldb/source/Utility/CMakeLists.txt
@@ -24,6 +24,7 @@
 endif()
 
 add_lldb_library(lldbUtility NO_INTERNAL_DEPENDENCIES
+  AddressableBits.cpp
   ArchSpec.cpp
   Args.cpp
   Baton.cpp
Index: lldb/source/Utility/AddressableBits.cpp
===
--- /dev/null
+++ lldb/source/Utility/AddressableBits.cpp
@@ -0,0 +1,50 @@
+//===-- AddressableBits.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/Utility/AddressableBits.h"
+#include "lldb/Target/Process.h"
+#include "lldb/lldb-types.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+void AddressableBits::SetAddressableBits(uint32_t addressing_bits) {
+  m_low_memory_addr_bits = m_high_memory_addr_bits = addressing_bits;
+}
+
+void AddressableBits::SetAddressableBits(uint32_t lowmem_addressing_bits,
+ uint32_t highmem_addressing_bits) {
+  m_low_memory_addr_bits = lowmem_addressing_bits;
+  m_high_memory_addr_bits = highmem_addressing_bits;
+}
+
+void AddressableBits::Clear() {
+  m_low_memory_addr_bits = m_high_memory_addr_bits = 0;
+}
+
+void AddressableBits::SetProcessMasks(Process ) {
+  // In case either value is set to 0, indicating it was not set, use the
+  // other value.
+  if (m_low_memory_addr_bits == 0)
+m_low_memory_addr_bits = m_high_memory_addr_bits;
+  if (m_high_memory_addr_bits == 0)
+m_high_memory_addr_bits = m_low_memory_addr_bits;
+
+  if (m_low_memory_addr_bits == 0)
+return;
+
+  addr_t address_mask = ~((1ULL << m_low_memory_addr_bits) - 1);
+  process.SetCodeAddressMask(address_mask);
+  process.SetDataAddressMask(address_mask);
+
+  if (m_low_memory_addr_bits != m_high_memory_addr_bits) {
+lldb::addr_t hi_address_mask = ~((1ULL << m_high_memory_addr_bits) - 1);
+process.SetHighmemCodeAddressMask(hi_address_mask);
+process.SetHighmemDataAddressMask(hi_address_mask);
+  }
+}
Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -509,10 +509,9 @@
 
   CleanupMemoryRegionPermissions();
 
-  addr_t address_mask = core_objfile->GetAddressMask();
-  if (address_mask != 0) {
-SetCodeAddressMask(address_mask);
-SetDataAddressMask(address_mask);
+  AddressableBits addressable_bits;
+  if (core_objfile->GetAddressableBits(addressable_bits)) {
+addressable_bits.SetProcessMasks(*this);
   }
   return error;
 }
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -899,10 +899,9 @@
  process_arch.GetTriple().getTriple());
   }
 
-  if (int addressable_bits = m_gdb_comm.GetAddressingBits()) {
-lldb::addr_t address_mask = ~((1ULL << addressable_bits) - 1);
-SetCodeAddressMask(address_mask);
-SetDataAddressMask(address_mask);
+  AddressableBits addressable_bits;
+  if (m_gdb_comm.GetAddressableBits(addressable_bits)) {
+addressable_bits.SetProcessMasks(*this);
   }
 
   if (process_arch.IsValid()) {
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -19,6 

[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread Jim Ingham via Phabricator via lldb-commits
jingham added inline comments.



Comment at: lldb/source/Commands/CommandObjectType.cpp:2174
 
-#if LLDB_ENABLE_PYTHON
-

electriclilies wrote:
> rriddle wrote:
> > Why is this dropped?
> Walter and I want to use the synthetic types from C++, but right now it's 
> only supported in Python. The motivation behind this is to make it so that we 
> can actually use the synthetic types. 
Just to be clear.  There are already lots of synthetic child providers 
implemented in C++ in in lldb already (look for CXXSyntheticChildren 
constructors in CPlusPlusLanguage.cpp for instance).  

I think what you are saying is that you are removing the restriction that you 
have to BUILD lldb with Python in order to add C++ implemented summaries.  If 
that's indeed what you are saying, then this is fine, since that seems an odd 
restriction...

But it would be nice to have some kind of testing that this actually works, 
since I don't think any of our bots build lldb w/o Python.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

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


[Lldb-commits] [PATCH] D157851: [lldb/crashlog] Add support for Last Exception Backtrace

2023-08-15 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/examples/python/crashlog.py:800-806
+thread = self.crashlog.Thread(
+len(self.crashlog.threads), True, self.crashlog.process_arch
+)
+thread.queue = "Application Specific Backtrace"
+for backtrace in json_app_specific_bts:
 if self.parse_asi_backtrace(thread, backtrace):
 self.crashlog.threads.append(thread)

bulbazord wrote:
> Conceptually it looks like this is creating a new thread and adding it over 
> and over to the crashlog list of threads? How does this work?
Indeed, this is bogus :p Good catch!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157851/new/

https://reviews.llvm.org/D157851

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


[Lldb-commits] [PATCH] D157851: [lldb/crashlog] Add support for Last Exception Backtrace

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added inline comments.



Comment at: lldb/examples/python/crashlog.py:800-806
+thread = self.crashlog.Thread(
+len(self.crashlog.threads), True, self.crashlog.process_arch
+)
+thread.queue = "Application Specific Backtrace"
+for backtrace in json_app_specific_bts:
 if self.parse_asi_backtrace(thread, backtrace):
 self.crashlog.threads.append(thread)

Conceptually it looks like this is creating a new thread and adding it over and 
over to the crashlog list of threads? How does this work?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157851/new/

https://reviews.llvm.org/D157851

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


[Lldb-commits] [PATCH] D157852: [lldb/crashlog] Skip non-crashed threads in batch mode

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157852/new/

https://reviews.llvm.org/D157852

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


[Lldb-commits] [lldb] 04da749 - [lldb] Fix warnings

2023-08-15 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2023-08-15T12:46:36-07:00
New Revision: 04da7490d85dab7f2f97d0a782b674088bc5a10f

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

LOG: [lldb] Fix warnings

This patch fixes warnings like:

  lldb/source/Core/ModuleList.cpp:1086:3: error: 'scoped_lock' may not
  intend to support class template argument deduction
  [-Werror,-Wctad-maybe-unsupported]

Added: 


Modified: 
lldb/source/Core/ModuleList.cpp
lldb/source/Host/posix/PipePosix.cpp

Removed: 




diff  --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 6cb086f9f55d2c..17d4560f724b84 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -1083,6 +1083,7 @@ bool ModuleList::AnyOf(
 
 void ModuleList::Swap(ModuleList ) {
   // scoped_lock locks both mutexes at once.
-  std::scoped_lock lock(m_modules_mutex, other.m_modules_mutex);
+  std::scoped_lock lock(
+  m_modules_mutex, other.m_modules_mutex);
   m_modules.swap(other.m_modules);
 }

diff  --git a/lldb/source/Host/posix/PipePosix.cpp 
b/lldb/source/Host/posix/PipePosix.cpp
index 0050731acb3fcb..c02869cbf4d730 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -65,8 +65,9 @@ PipePosix::PipePosix(PipePosix &_posix)
 pipe_posix.ReleaseWriteFileDescriptor()} {}
 
 PipePosix ::operator=(PipePosix &_posix) {
-  std::scoped_lock guard(m_read_mutex, m_write_mutex, pipe_posix.m_read_mutex,
- pipe_posix.m_write_mutex);
+  std::scoped_lock guard(
+  m_read_mutex, m_write_mutex, pipe_posix.m_read_mutex,
+  pipe_posix.m_write_mutex);
 
   PipeBase::operator=(std::move(pipe_posix));
   m_fds[READ] = pipe_posix.ReleaseReadFileDescriptorUnlocked();
@@ -77,7 +78,7 @@ PipePosix ::operator=(PipePosix &_posix) {
 PipePosix::~PipePosix() { Close(); }
 
 Status PipePosix::CreateNew(bool child_processes_inherit) {
-  std::scoped_lock guard(m_read_mutex, m_write_mutex);
+  std::scoped_lock guard(m_read_mutex, m_write_mutex);
   if (CanReadUnlocked() || CanWriteUnlocked())
 return Status(EINVAL, eErrorTypePOSIX);
 
@@ -107,7 +108,7 @@ Status PipePosix::CreateNew(bool child_processes_inherit) {
 }
 
 Status PipePosix::CreateNew(llvm::StringRef name, bool child_process_inherit) {
-  std::scoped_lock (m_read_mutex, m_write_mutex);
+  std::scoped_lock (m_read_mutex, m_write_mutex);
   if (CanReadUnlocked() || CanWriteUnlocked())
 return Status("Pipe is already opened");
 
@@ -145,7 +146,7 @@ Status PipePosix::CreateWithUniqueName(llvm::StringRef 
prefix,
 
 Status PipePosix::OpenAsReader(llvm::StringRef name,
bool child_process_inherit) {
-  std::scoped_lock (m_read_mutex, m_write_mutex);
+  std::scoped_lock (m_read_mutex, m_write_mutex);
 
   if (CanReadUnlocked() || CanWriteUnlocked())
 return Status("Pipe is already opened");
@@ -168,7 +169,7 @@ Status
 PipePosix::OpenAsWriterWithTimeout(llvm::StringRef name,
bool child_process_inherit,
const std::chrono::microseconds ) {
-  std::lock_guard guard(m_write_mutex);
+  std::lock_guard guard(m_write_mutex);
   if (CanReadUnlocked() || CanWriteUnlocked())
 return Status("Pipe is already opened");
 
@@ -205,7 +206,7 @@ PipePosix::OpenAsWriterWithTimeout(llvm::StringRef name,
 }
 
 int PipePosix::GetReadFileDescriptor() const {
-  std::lock_guard guard(m_read_mutex);
+  std::lock_guard guard(m_read_mutex);
   return GetReadFileDescriptorUnlocked();
 }
 
@@ -214,7 +215,7 @@ int PipePosix::GetReadFileDescriptorUnlocked() const {
 }
 
 int PipePosix::GetWriteFileDescriptor() const {
-  std::lock_guard guard(m_write_mutex);
+  std::lock_guard guard(m_write_mutex);
   return GetWriteFileDescriptorUnlocked();
 }
 
@@ -223,7 +224,7 @@ int PipePosix::GetWriteFileDescriptorUnlocked() const {
 }
 
 int PipePosix::ReleaseReadFileDescriptor() {
-  std::lock_guard guard(m_read_mutex);
+  std::lock_guard guard(m_read_mutex);
   return ReleaseReadFileDescriptorUnlocked();
 }
 
@@ -234,7 +235,7 @@ int PipePosix::ReleaseReadFileDescriptorUnlocked() {
 }
 
 int PipePosix::ReleaseWriteFileDescriptor() {
-  std::lock_guard guard(m_write_mutex);
+  std::lock_guard guard(m_write_mutex);
   return ReleaseWriteFileDescriptorUnlocked();
 }
 
@@ -245,7 +246,7 @@ int PipePosix::ReleaseWriteFileDescriptorUnlocked() {
 }
 
 void PipePosix::Close() {
-  std::scoped_lock guard(m_read_mutex, m_write_mutex);
+  std::scoped_lock guard(m_read_mutex, m_write_mutex);
   CloseUnlocked();
 }
 
@@ -259,7 +260,7 @@ Status PipePosix::Delete(llvm::StringRef name) {
 }
 
 bool PipePosix::CanRead() const {
-  std::lock_guard guard(m_read_mutex);
+  std::lock_guard guard(m_read_mutex);
   return 

[Lldb-commits] [lldb] 2241364 - [lldb] Fix data race in PipePosix

2023-08-15 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2023-08-15T11:30:35-07:00
New Revision: 22413641e236ebee7485ce8bc5880e8d1e41573f

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

LOG: [lldb] Fix data race in PipePosix

Thread sanitizer reports the following data race:

```
WARNING: ThreadSanitizer: data race (pid=43201)
  Write of size 4 at 0x00010520c474 by thread T1 (mutexes: write M0, write M1):
#0 lldb_private::PipePosix::CloseWriteFileDescriptor() PipePosix.cpp:242 
(liblldb.18.0.0git.dylib:arm64+0x414700) (BuildId: 
2983976beb2637b5943bff32fd12eb89320021000e00)
#1 lldb_private::PipePosix::Close() PipePosix.cpp:217 
(liblldb.18.0.0git.dylib:arm64+0x4144e8) (BuildId: 
2983976beb2637b5943bff32fd12eb89320021000e00)
#2 
lldb_private::ConnectionFileDescriptor::Disconnect(lldb_private::Status*) 
ConnectionFileDescriptorPosix.cpp:239 (liblldb.18.0.0git.dylib:arm64+0x40a620) 
(BuildId: 2983976beb2637b5943bff32fd12eb89320021000e00)
#3 lldb_private::Communication::Disconnect(lldb_private::Status*) 
Communication.cpp:61 (liblldb.18.0.0git.dylib:arm64+0x2a9318) (BuildId: 
2983976beb2637b5943bff32fd12eb89320021000e00)
#4 lldb_private::process_gdb_remote::ProcessGDBRemote::DidExit() 
ProcessGDBRemote.cpp:1167 (liblldb.18.0.0git.dylib:arm64+0x8ed984) (BuildId: 
2983976beb2637b5943bff32fd12eb89320021000e00)

  Previous read of size 4 at 0x00010520c474 by main thread (mutexes: write M2, 
write M3):
#0 lldb_private::PipePosix::CanWrite() const PipePosix.cpp:229 
(liblldb.18.0.0git.dylib:arm64+0x4145e4) (BuildId: 
2983976beb2637b5943bff32fd12eb89320021000e00)
#1 
lldb_private::ConnectionFileDescriptor::Disconnect(lldb_private::Status*) 
ConnectionFileDescriptorPosix.cpp:212 (liblldb.18.0.0git.dylib:arm64+0x40a4a8) 
(BuildId: 2983976beb2637b5943bff32fd12eb89320021000e00)
#2 lldb_private::Communication::Disconnect(lldb_private::Status*) 
Communication.cpp:61 (liblldb.18.0.0git.dylib:arm64+0x2a9318) (BuildId: 
2983976beb2637b5943bff32fd12eb89320021000e00)
#3 
lldb_private::process_gdb_remote::GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote&,
 lldb_private::Timeout>, bool) 
GDBRemoteCommunication.cpp:373 (liblldb.18.0.0git.dylib:arm64+0x8b9c48) 
(BuildId: 2983976beb2637b5943bff32fd12eb89320021000e00)
#4 
lldb_private::process_gdb_remote::GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote&,
 lldb_private::Timeout>, bool) 
GDBRemoteCommunication.cpp:243 (liblldb.18.0.0git.dylib:arm64+0x8b9904) 
(BuildId: 2983976beb2637b5943bff32fd12eb89320021000e00)
```

Fix this by adding a mutex to PipePosix.

Differential Revision: https://reviews.llvm.org/D157654

Added: 


Modified: 
lldb/include/lldb/Host/posix/PipePosix.h
lldb/source/Host/posix/PipePosix.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/posix/PipePosix.h 
b/lldb/include/lldb/Host/posix/PipePosix.h
index 3bdb7431d8c770..ec4c752a24e94c 100644
--- a/lldb/include/lldb/Host/posix/PipePosix.h
+++ b/lldb/include/lldb/Host/posix/PipePosix.h
@@ -8,8 +8,8 @@
 
 #ifndef LLDB_HOST_POSIX_PIPEPOSIX_H
 #define LLDB_HOST_POSIX_PIPEPOSIX_H
-
 #include "lldb/Host/PipeBase.h"
+#include 
 
 namespace lldb_private {
 
@@ -70,7 +70,22 @@ class PipePosix : public PipeBase {
  size_t _read) override;
 
 private:
+  bool CanReadUnlocked() const;
+  bool CanWriteUnlocked() const;
+
+  int GetReadFileDescriptorUnlocked() const;
+  int GetWriteFileDescriptorUnlocked() const;
+  int ReleaseReadFileDescriptorUnlocked();
+  int ReleaseWriteFileDescriptorUnlocked();
+  void CloseReadFileDescriptorUnlocked();
+  void CloseWriteFileDescriptorUnlocked();
+  void CloseUnlocked();
+
   int m_fds[2];
+
+  /// Mutexes for m_fds;
+  mutable std::mutex m_read_mutex;
+  mutable std::mutex m_write_mutex;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Host/posix/PipePosix.cpp 
b/lldb/source/Host/posix/PipePosix.cpp
index 5e4e8618fa4f14..0050731acb3fcb 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -65,16 +65,20 @@ PipePosix::PipePosix(PipePosix &_posix)
 pipe_posix.ReleaseWriteFileDescriptor()} {}
 
 PipePosix ::operator=(PipePosix &_posix) {
+  std::scoped_lock guard(m_read_mutex, m_write_mutex, pipe_posix.m_read_mutex,
+ pipe_posix.m_write_mutex);
+
   PipeBase::operator=(std::move(pipe_posix));
-  m_fds[READ] = pipe_posix.ReleaseReadFileDescriptor();
-  m_fds[WRITE] = pipe_posix.ReleaseWriteFileDescriptor();
+  m_fds[READ] = pipe_posix.ReleaseReadFileDescriptorUnlocked();
+  m_fds[WRITE] = 

[Lldb-commits] [lldb] 4a390a5 - [lldb] Implement ModuleList::Swap

2023-08-15 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2023-08-15T11:33:34-07:00
New Revision: 4a390a56aeeb521d0eca1fa4cef6837157ea64ab

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

LOG: [lldb] Implement ModuleList::Swap

Added: 


Modified: 
lldb/include/lldb/Core/ModuleList.h
lldb/source/Core/ModuleList.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index 28c1945c83c478..9826dd09e91d71 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -480,6 +480,9 @@ class ModuleList {
   bool AnyOf(
   std::function const ) const;
 
+  /// Atomically swaps the contents of this module list with \a other.
+  void Swap(ModuleList );
+
 protected:
   // Class typedefs.
   typedef std::vector

diff  --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index d0d0b2050e181c..6cb086f9f55d2c 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -1079,3 +1079,10 @@ bool ModuleList::AnyOf(
 
   return false;
 }
+
+
+void ModuleList::Swap(ModuleList ) {
+  // scoped_lock locks both mutexes at once.
+  std::scoped_lock lock(m_modules_mutex, other.m_modules_mutex);
+  m_modules.swap(other.m_modules);
+}



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


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies added inline comments.



Comment at: lldb/include/lldb/DataFormatters/TypeSynthetic.h:257-262
+  virtual bool IsScripted();
 
-  virtual std::string GetDescription() = 0;
+  virtual std::string GetDescription();
 
   virtual SyntheticChildrenFrontEnd::AutoPointer
+  GetFrontEnd(ValueObject );

rriddle wrote:
> Why these changes?
I thought that this was causing linking problems but it is not, so I will 
revert.



Comment at: lldb/source/Commands/CommandObjectType.cpp:2174
 
-#if LLDB_ENABLE_PYTHON
-

rriddle wrote:
> Why is this dropped?
Walter and I want to use the synthetic types from C++, but right now it's only 
supported in Python. The motivation behind this is to make it so that we can 
actually use the synthetic types. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

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


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread River Riddle via Phabricator via lldb-commits
rriddle added a comment.

Moving the constructor/destructor to the cpp file makes sense to remove the 
"undefined reference to vtable" issues that we've seen before, but I don't 
understand the changes to pure virtual methods or the removal of the 
LLDB_ENABLE_PYTHON checks. Can you elaborate more?




Comment at: lldb/include/lldb/DataFormatters/TypeSynthetic.h:257-262
+  virtual bool IsScripted();
 
-  virtual std::string GetDescription() = 0;
+  virtual std::string GetDescription();
 
   virtual SyntheticChildrenFrontEnd::AutoPointer
+  GetFrontEnd(ValueObject );

Why these changes?



Comment at: lldb/source/Commands/CommandObjectType.cpp:2174
 
-#if LLDB_ENABLE_PYTHON
-

Why is this dropped?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

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


[Lldb-commits] [PATCH] D158009: [lldb] Enable synthetic providers in C++

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies abandoned this revision.
electriclilies added a comment.

Abandoning this since I messed up when updating, changes are now at 
https://reviews.llvm.org/D158010


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158009/new/

https://reviews.llvm.org/D158009

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


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added reviewers: jingham, augusto2112, kastiglione.
bulbazord added a comment.
Herald added a subscriber: JDevlieghere.

Adding a few relevant reviewers :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158010/new/

https://reviews.llvm.org/D158010

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


[Lldb-commits] [PATCH] D158010: [lldb] Allow synthetic providers in C++ and fix linking problems

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies created this revision.
Herald added a project: All.
electriclilies requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Allow the definition of synthetic formatters in C++, and fix linking problems 
with the CXXSyntheticChildren


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158010

Files:
  lldb/include/lldb/DataFormatters/TypeSynthetic.h
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/TypeSynthetic.cpp

Index: lldb/source/DataFormatters/TypeSynthetic.cpp
===
--- lldb/source/DataFormatters/TypeSynthetic.cpp
+++ lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -84,6 +84,27 @@
   return std::string(sstr.GetString());
 }
 
+SyntheticChildren::SyntheticChildren(const Flags ) : m_flags(flags) {}
+
+SyntheticChildren::~SyntheticChildren() = default;
+
+CXXSyntheticChildren::CXXSyntheticChildren(
+const SyntheticChildren::Flags , const char *description,
+CreateFrontEndCallback callback)
+: SyntheticChildren(flags), m_create_callback(std::move(callback)),
+  m_description(description ? description : "") {}
+
+CXXSyntheticChildren::~CXXSyntheticChildren() = default;
+
+bool SyntheticChildren::IsScripted() { return false; }
+
+std::string SyntheticChildren::GetDescription() { return ""; }
+
+SyntheticChildrenFrontEnd::AutoPointer
+SyntheticChildren::GetFrontEnd(ValueObject ) {
+  return nullptr;
+}
+
 std::string CXXSyntheticChildren::GetDescription() {
   StreamString sstr;
   sstr.Printf("%s%s%s %s", Cascades() ? "" : " (not cascading)",
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -218,10 +218,8 @@
 SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues));
 SetSummaryFormat(
 DataVisualization::GetSummaryFormat(*this, GetDynamicValueType()));
-#if LLDB_ENABLE_PYTHON
 SetSyntheticChildren(
 DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType()));
-#endif
   }
 
   return any_change;
@@ -1170,7 +1168,7 @@
 Stream , ValueObjectRepresentationStyle val_obj_display,
 Format custom_format, PrintableRepresentationSpecialCases special,
 bool do_dump_error) {
-
+
   // If the ValueObject has an error, we might end up dumping the type, which
   // is useful, but if we don't even have a type, then don't examine the object
   // further as that's not meaningful, only the error is.
@@ -2785,15 +2783,15 @@
 
 ValueObjectSP ValueObject::Cast(const CompilerType _type) {
   // Only allow casts if the original type is equal or larger than the cast
-  // type.  We don't know how to fetch more data for all the ConstResult types, 
+  // type.  We don't know how to fetch more data for all the ConstResult types,
   // so we can't guarantee this will work:
   Status error;
   CompilerType my_type = GetCompilerType();
 
-  ExecutionContextScope *exe_scope 
+  ExecutionContextScope *exe_scope
   = ExecutionContext(GetExecutionContextRef())
   .GetBestExecutionContextScope();
-  if (compiler_type.GetByteSize(exe_scope) 
+  if (compiler_type.GetByteSize(exe_scope)
   <= GetCompilerType().GetByteSize(exe_scope)) {
 return DoCast(compiler_type);
   }
Index: lldb/source/Commands/CommandObjectType.cpp
===
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -2171,8 +2171,6 @@
"Show a list of current filters.") {}
 };
 
-#if LLDB_ENABLE_PYTHON
-
 // CommandObjectTypeSynthList
 
 class CommandObjectTypeSynthList
@@ -2184,8 +2182,6 @@
 "Show a list of current synthetic providers.") {}
 };
 
-#endif
-
 // CommandObjectTypeFilterDelete
 
 class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
@@ -2197,8 +2193,6 @@
   ~CommandObjectTypeFilterDelete() override = default;
 };
 
-#if LLDB_ENABLE_PYTHON
-
 // CommandObjectTypeSynthDelete
 
 class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
@@ -2210,7 +2204,6 @@
   ~CommandObjectTypeSynthDelete() override = default;
 };
 
-#endif
 
 // CommandObjectTypeFilterClear
 
@@ -,7 +2215,6 @@
 "Delete all existing filter.") {}
 };
 
-#if LLDB_ENABLE_PYTHON
 // CommandObjectTypeSynthClear
 
 class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear {
@@ -2393,7 +2385,6 @@
   return true;
 }
 
-#endif
 #define LLDB_OPTIONS_type_filter_add
 #include "CommandOptions.inc"
 
@@ -2941,8 +2932,6 @@
   ~CommandObjectTypeFormat() override = default;
 };
 
-#if LLDB_ENABLE_PYTHON
-
 class CommandObjectTypeSynth : public CommandObjectMultiword {
 public:
   CommandObjectTypeSynth(CommandInterpreter 

[Lldb-commits] [PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-08-15 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

Thanks for the patch, but there are two issues that should be fixed:

(1) stat => fstat
(2) change the subject to mean that this is not AIX specific (`[LLVM][Support] 
Report EISDIR when opening a directory on AIX`). Other OSes including Linux are 
changed as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151567/new/

https://reviews.llvm.org/D151567

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


[Lldb-commits] [PATCH] D158009: [lldb] Enable synthetic providers in C++

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies added a comment.

Hangon reviewers, I forgot to squash my commits.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158009/new/

https://reviews.llvm.org/D158009

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


[Lldb-commits] [PATCH] D158009: [lldb] Enable synthetic providers in C++

2023-08-15 Thread Lily Orth-Smith via Phabricator via lldb-commits
electriclilies created this revision.
Herald added a project: All.
electriclilies requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158009

Files:
  lldb/include/lldb/Core/ValueObject.h
  lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/DataFormatters/DataVisualization.cpp
  lldb/source/DataFormatters/FormatManager.cpp
  lldb/source/DataFormatters/LanguageCategory.cpp

Index: lldb/source/DataFormatters/LanguageCategory.cpp
===
--- lldb/source/DataFormatters/LanguageCategory.cpp
+++ lldb/source/DataFormatters/LanguageCategory.cpp
@@ -71,20 +71,16 @@
 
 template <>
 auto ::GetHardcodedFinder() {
-llvm::errs() << "get hardedcoded finder type formatn\n";
   return m_hardcoded_formats;
 }
 
 template <>
 auto ::GetHardcodedFinder() {
-  llvm::errs() << "get hardedcoded finder type summary\n";
   return m_hardcoded_summaries;
 }
 
 template <>
 auto ::GetHardcodedFinder() {
-  llvm::errs() << "get hardedcoded finder synthetic children\n";
-
   return m_hardcoded_synthetics;
 }
 
@@ -94,19 +90,14 @@
 bool LanguageCategory::GetHardcoded(FormatManager _mgr,
 FormattersMatchData _data,
 ImplSP _sp) {
-  llvm::errs() << "languagecategory::GetHardcoded\n";
-  if (!IsEnabled()) {
-llvm::errs() << "not enabled\n";
+  if (!IsEnabled())
 return false;
-  }
 
   ValueObject (match_data.GetValueObject());
   lldb::DynamicValueType use_dynamic(match_data.GetDynamicValueType());
-  llvm::errs() << "language category checkpoint\n";
+
   for (auto  : GetHardcodedFinder()) {
-llvm::errs() << "looking at candidates\n;";
 if (auto result = candidate(valobj, use_dynamic, fmt_mgr)) {
-  llvm::errs() << "result\n";
   retval_sp = result;
   break;
 }
Index: lldb/source/DataFormatters/FormatManager.cpp
===
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -588,13 +588,9 @@
 ImplSP FormatManager::GetHardcoded(FormattersMatchData _data) {
   ImplSP retval_sp;
   for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
-llvm::errs() << "lang type: " << lang_type << "\n";
 if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
-  llvm::errs() << "lang_category: " << lang_category << "\n";
-  if (lang_category->GetHardcoded(*this, match_data, retval_sp)) {
-llvm::errs() << "lang_category->GetHardcoded succeeded\n";
+  if (lang_category->GetHardcoded(*this, match_data, retval_sp))
 return retval_sp;
-  }
 }
   }
   return retval_sp;
@@ -612,12 +608,9 @@
 template 
 ImplSP FormatManager::Get(ValueObject ,
   lldb::DynamicValueType use_dynamic) {
-  llvm::errs() << "format manager get\n";
-  llvm::errs() << "valobj dynamic value type: " << valobj.DoesProvideSyntheticValue() << "\n";
   FormattersMatchData match_data(valobj, use_dynamic);
   if (ImplSP retval_sp = GetCached(match_data))
 return retval_sp;
-  llvm::errs() << "ckpt 1\n";
 
   Log *log = GetLog(LLDBLog::DataFormatters);
 
@@ -632,8 +625,6 @@
 }
 }
   }
-  llvm::errs() << "ckpt 2\n";
-
 
   LLDB_LOGF(log, FORMAT_LOG("Search failed. Giving hardcoded a chance."));
   return GetHardcoded(match_data);
@@ -687,7 +678,6 @@
 lldb::SyntheticChildrenSP
 FormatManager::GetSyntheticChildren(ValueObject ,
 lldb::DynamicValueType use_dynamic) {
-  llvm::errs() << "format manager get synthetic children\n";
   return Get(valobj, use_dynamic);
 }
 
Index: lldb/source/DataFormatters/DataVisualization.cpp
===
--- lldb/source/DataFormatters/DataVisualization.cpp
+++ lldb/source/DataFormatters/DataVisualization.cpp
@@ -52,7 +52,6 @@
 lldb::SyntheticChildrenSP
 DataVisualization::GetSyntheticChildren(ValueObject ,
 lldb::DynamicValueType use_dynamic) {
-  llvm::errs() << "inside get synthetic children2\n";
   return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
 }
 
Index: lldb/source/Core/ValueObject.cpp
===
--- lldb/source/Core/ValueObject.cpp
+++ lldb/source/Core/ValueObject.cpp
@@ -218,10 +218,8 @@
 SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues));
 SetSummaryFormat(
 DataVisualization::GetSummaryFormat(*this, GetDynamicValueType()));
-llvm::errs() << "about to call SetSyntheticChildren\n";
 SetSyntheticChildren(
 DataVisualization::GetSyntheticChildren(*this, GetDynamicValueType()));
-llvm::errs() << "SetSyntheticChildren call finished\n";
   }
 
   

[Lldb-commits] [PATCH] D157654: [lldb] Fix data race in PipePosix

2023-08-15 Thread Augusto Noronha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22413641e236: [lldb] Fix data race in PipePosix (authored by 
augusto2112).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157654/new/

https://reviews.llvm.org/D157654

Files:
  lldb/include/lldb/Host/posix/PipePosix.h
  lldb/source/Host/posix/PipePosix.cpp

Index: lldb/source/Host/posix/PipePosix.cpp
===
--- lldb/source/Host/posix/PipePosix.cpp
+++ lldb/source/Host/posix/PipePosix.cpp
@@ -65,16 +65,20 @@
 pipe_posix.ReleaseWriteFileDescriptor()} {}
 
 PipePosix ::operator=(PipePosix &_posix) {
+  std::scoped_lock guard(m_read_mutex, m_write_mutex, pipe_posix.m_read_mutex,
+ pipe_posix.m_write_mutex);
+
   PipeBase::operator=(std::move(pipe_posix));
-  m_fds[READ] = pipe_posix.ReleaseReadFileDescriptor();
-  m_fds[WRITE] = pipe_posix.ReleaseWriteFileDescriptor();
+  m_fds[READ] = pipe_posix.ReleaseReadFileDescriptorUnlocked();
+  m_fds[WRITE] = pipe_posix.ReleaseWriteFileDescriptorUnlocked();
   return *this;
 }
 
 PipePosix::~PipePosix() { Close(); }
 
 Status PipePosix::CreateNew(bool child_processes_inherit) {
-  if (CanRead() || CanWrite())
+  std::scoped_lock guard(m_read_mutex, m_write_mutex);
+  if (CanReadUnlocked() || CanWriteUnlocked())
 return Status(EINVAL, eErrorTypePOSIX);
 
   Status error;
@@ -87,7 +91,7 @@
 if (!child_processes_inherit) {
   if (!SetCloexecFlag(m_fds[0]) || !SetCloexecFlag(m_fds[1])) {
 error.SetErrorToErrno();
-Close();
+CloseUnlocked();
 return error;
   }
 }
@@ -103,7 +107,8 @@
 }
 
 Status PipePosix::CreateNew(llvm::StringRef name, bool child_process_inherit) {
-  if (CanRead() || CanWrite())
+  std::scoped_lock (m_read_mutex, m_write_mutex);
+  if (CanReadUnlocked() || CanWriteUnlocked())
 return Status("Pipe is already opened");
 
   Status error;
@@ -140,7 +145,9 @@
 
 Status PipePosix::OpenAsReader(llvm::StringRef name,
bool child_process_inherit) {
-  if (CanRead() || CanWrite())
+  std::scoped_lock (m_read_mutex, m_write_mutex);
+
+  if (CanReadUnlocked() || CanWriteUnlocked())
 return Status("Pipe is already opened");
 
   int flags = O_RDONLY | O_NONBLOCK;
@@ -161,7 +168,8 @@
 PipePosix::OpenAsWriterWithTimeout(llvm::StringRef name,
bool child_process_inherit,
const std::chrono::microseconds ) {
-  if (CanRead() || CanWrite())
+  std::lock_guard guard(m_write_mutex);
+  if (CanReadUnlocked() || CanWriteUnlocked())
 return Status("Pipe is already opened");
 
   int flags = O_WRONLY | O_NONBLOCK;
@@ -171,7 +179,7 @@
   using namespace std::chrono;
   const auto finish_time = Now() + timeout;
 
-  while (!CanWrite()) {
+  while (!CanWriteUnlocked()) {
 if (timeout != microseconds::zero()) {
   const auto dur = duration_cast(finish_time - Now()).count();
   if (dur <= 0)
@@ -196,25 +204,54 @@
   return Status();
 }
 
-int PipePosix::GetReadFileDescriptor() const { return m_fds[READ]; }
+int PipePosix::GetReadFileDescriptor() const {
+  std::lock_guard guard(m_read_mutex);
+  return GetReadFileDescriptorUnlocked();
+}
+
+int PipePosix::GetReadFileDescriptorUnlocked() const {
+  return m_fds[READ];
+}
 
-int PipePosix::GetWriteFileDescriptor() const { return m_fds[WRITE]; }
+int PipePosix::GetWriteFileDescriptor() const {
+  std::lock_guard guard(m_write_mutex);
+  return GetWriteFileDescriptorUnlocked();
+}
+
+int PipePosix::GetWriteFileDescriptorUnlocked() const {
+  return m_fds[WRITE];
+}
 
 int PipePosix::ReleaseReadFileDescriptor() {
+  std::lock_guard guard(m_read_mutex);
+  return ReleaseReadFileDescriptorUnlocked();
+}
+
+int PipePosix::ReleaseReadFileDescriptorUnlocked() {
   const int fd = m_fds[READ];
   m_fds[READ] = PipePosix::kInvalidDescriptor;
   return fd;
 }
 
 int PipePosix::ReleaseWriteFileDescriptor() {
+  std::lock_guard guard(m_write_mutex);
+  return ReleaseWriteFileDescriptorUnlocked();
+}
+
+int PipePosix::ReleaseWriteFileDescriptorUnlocked() {
   const int fd = m_fds[WRITE];
   m_fds[WRITE] = PipePosix::kInvalidDescriptor;
   return fd;
 }
 
 void PipePosix::Close() {
-  CloseReadFileDescriptor();
-  CloseWriteFileDescriptor();
+  std::scoped_lock guard(m_read_mutex, m_write_mutex);
+  CloseUnlocked();
+}
+
+void PipePosix::CloseUnlocked() {
+  CloseReadFileDescriptorUnlocked();
+  CloseWriteFileDescriptorUnlocked();
 }
 
 Status PipePosix::Delete(llvm::StringRef name) {
@@ -222,22 +259,41 @@
 }
 
 bool PipePosix::CanRead() const {
+  std::lock_guard guard(m_read_mutex);
+  return CanReadUnlocked();
+}
+
+bool PipePosix::CanReadUnlocked() const {
   return m_fds[READ] != PipePosix::kInvalidDescriptor;
 }
 
 bool PipePosix::CanWrite() const {
+  std::lock_guard guard(m_write_mutex);
+  return CanWriteUnlocked();
+}
+
+bool 

[Lldb-commits] [lldb] f2ec73c - [lldb] Move deprecation message from implementation to header (NFC)

2023-08-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-08-15T10:41:11-07:00
New Revision: f2ec73c746504978cda96914a03952f65a29dd67

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

LOG: [lldb] Move deprecation message from implementation to header (NFC)

Address Alex's post commit review feedback from D158000.

Added: 


Modified: 
lldb/include/lldb/API/SBDebugger.h
lldb/source/API/SBDebugger.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 27962060370d29..29cf2c16fad4bd 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -380,8 +380,10 @@ class LLDB_API SBDebugger {
 
   void SetREPLLanguage(lldb::LanguageType repl_lang);
 
+  LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
   bool GetCloseInputOnEOF() const;
 
+  LLDB_DEPRECATED("SBDebugger::SetCloseInputOnEOF() is deprecated.")
   void SetCloseInputOnEOF(bool b);
 
   SBTypeCategory GetCategory(const char *category_name);

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 33346c1e304564..5328e079564f32 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1535,14 +1535,12 @@ bool SBDebugger::SetCurrentPlatformSDKRoot(const char 
*sysroot) {
   return false;
 }
 
-LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
 bool SBDebugger::GetCloseInputOnEOF() const {
   LLDB_INSTRUMENT_VA(this);
 
   return false;
 }
 
-LLDB_DEPRECATED("SBDebugger::SetCloseInputOnEOF() is deprecated.")
 void SBDebugger::SetCloseInputOnEOF(bool b) {
   LLDB_INSTRUMENT_VA(this, b);
 }



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


[Lldb-commits] [PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-08-15 Thread Alison Zhang via Phabricator via lldb-commits
azhan92 updated this revision to Diff 550402.
azhan92 added a comment.

Address TOCTOU condition (will add updated test later).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151567/new/

https://reviews.llvm.org/D151567

Files:
  llvm/lib/Support/Unix/Path.inc
  llvm/test/tools/llvm-symbolizer/input-file-err.test
  llvm/unittests/Support/CommandLineTest.cpp


Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -1060,7 +1060,6 @@
   ASSERT_STREQ(Argv[0], "clang");
   ASSERT_STREQ(Argv[1], AFileExp.c_str());
 
-#if !defined(_AIX) && !defined(__MVS__)
   std::string ADirExp = std::string("@") + std::string(ADir.path());
   Argv = {"clang", ADirExp.c_str()};
   Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
@@ -1068,7 +1067,6 @@
   ASSERT_EQ(2U, Argv.size());
   ASSERT_STREQ(Argv[0], "clang");
   ASSERT_STREQ(Argv[1], ADirExp.c_str());
-#endif
 }
 
 TEST(CommandLineTest, SetDefaultValue) {
Index: llvm/test/tools/llvm-symbolizer/input-file-err.test
===
--- llvm/test/tools/llvm-symbolizer/input-file-err.test
+++ llvm/test/tools/llvm-symbolizer/input-file-err.test
@@ -1,5 +1,3 @@
-Failing on AIX due to D153595. The test expects a different error message from 
the one given on AIX.
-XFAIL: target={{.*}}-aix{{.*}}
 RUN: not llvm-addr2line -e %p/Inputs/nonexistent 0x12 2>&1 | FileCheck %s 
--check-prefix=CHECK-NONEXISTENT-A2L -DMSG=%errc_ENOENT
 RUN: not llvm-addr2line -e %p/Inputs/nonexistent 2>&1 | FileCheck %s 
--check-prefix=CHECK-NONEXISTENT-A2L -DMSG=%errc_ENOENT
 CHECK-NONEXISTENT-A2L: llvm-addr2line{{.*}}: error: 
'{{.*}}Inputs/nonexistent': [[MSG]]
Index: llvm/lib/Support/Unix/Path.inc
===
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -1019,6 +1019,13 @@
   auto Open = [&]() { return ::open(P.begin(), OpenFlags, Mode); };
   if ((ResultFD = sys::RetryAfterSignal(-1, Open)) < 0)
 return std::error_code(errno, std::generic_category());
+  if (Access == FA_Read) {
+struct stat Status;
+if (stat(P.begin(), ) == -1)
+  return std::error_code(errno, std::generic_category());
+if (S_ISDIR(Status.st_mode))
+  return make_error_code(errc::is_a_directory);
+  }
 #ifndef O_CLOEXEC
   if (!(Flags & OF_ChildInherit)) {
 int r = fcntl(ResultFD, F_SETFD, FD_CLOEXEC);


Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -1060,7 +1060,6 @@
   ASSERT_STREQ(Argv[0], "clang");
   ASSERT_STREQ(Argv[1], AFileExp.c_str());
 
-#if !defined(_AIX) && !defined(__MVS__)
   std::string ADirExp = std::string("@") + std::string(ADir.path());
   Argv = {"clang", ADirExp.c_str()};
   Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
@@ -1068,7 +1067,6 @@
   ASSERT_EQ(2U, Argv.size());
   ASSERT_STREQ(Argv[0], "clang");
   ASSERT_STREQ(Argv[1], ADirExp.c_str());
-#endif
 }
 
 TEST(CommandLineTest, SetDefaultValue) {
Index: llvm/test/tools/llvm-symbolizer/input-file-err.test
===
--- llvm/test/tools/llvm-symbolizer/input-file-err.test
+++ llvm/test/tools/llvm-symbolizer/input-file-err.test
@@ -1,5 +1,3 @@
-Failing on AIX due to D153595. The test expects a different error message from the one given on AIX.
-XFAIL: target={{.*}}-aix{{.*}}
 RUN: not llvm-addr2line -e %p/Inputs/nonexistent 0x12 2>&1 | FileCheck %s --check-prefix=CHECK-NONEXISTENT-A2L -DMSG=%errc_ENOENT
 RUN: not llvm-addr2line -e %p/Inputs/nonexistent 2>&1 | FileCheck %s --check-prefix=CHECK-NONEXISTENT-A2L -DMSG=%errc_ENOENT
 CHECK-NONEXISTENT-A2L: llvm-addr2line{{.*}}: error: '{{.*}}Inputs/nonexistent': [[MSG]]
Index: llvm/lib/Support/Unix/Path.inc
===
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -1019,6 +1019,13 @@
   auto Open = [&]() { return ::open(P.begin(), OpenFlags, Mode); };
   if ((ResultFD = sys::RetryAfterSignal(-1, Open)) < 0)
 return std::error_code(errno, std::generic_category());
+  if (Access == FA_Read) {
+struct stat Status;
+if (stat(P.begin(), ) == -1)
+  return std::error_code(errno, std::generic_category());
+if (S_ISDIR(Status.st_mode))
+  return make_error_code(errc::is_a_directory);
+  }
 #ifndef O_CLOEXEC
   if (!(Flags & OF_ChildInherit)) {
 int r = fcntl(ResultFD, F_SETFD, FD_CLOEXEC);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 23312cd - [lldb] Remove {Get, Set}CloseInputOnEOF and deprecate SB equivalent (NFC)

2023-08-15 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-08-15T10:37:04-07:00
New Revision: 23312cde45b964b24b2c9f3aa2ff45a45174a8d9

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

LOG: [lldb] Remove {Get,Set}CloseInputOnEOF and deprecate SB equivalent (NFC)

These functions have been NO-OPs since 2014 (44d937820b451). Remove them
and deprecate the corresponding functions in SBDebugger.

Differential revision: https://reviews.llvm.org/D158000

Added: 


Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/source/API/SBDebugger.cpp
lldb/source/Core/Debugger.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 35703d6f885aa1..5532cace606bfe 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -241,10 +241,6 @@ class Debugger : public 
std::enable_shared_from_this,
 
   void ClearIOHandlers();
 
-  bool GetCloseInputOnEOF() const;
-
-  void SetCloseInputOnEOF(bool b);
-
   bool EnableLog(llvm::StringRef channel,
  llvm::ArrayRef categories,
  llvm::StringRef log_file, uint32_t log_options,

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index b3f36599df47ad..33346c1e304564 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1535,17 +1535,16 @@ bool SBDebugger::SetCurrentPlatformSDKRoot(const char 
*sysroot) {
   return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
 bool SBDebugger::GetCloseInputOnEOF() const {
   LLDB_INSTRUMENT_VA(this);
 
-  return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
+  return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::SetCloseInputOnEOF() is deprecated.")
 void SBDebugger::SetCloseInputOnEOF(bool b) {
   LLDB_INSTRUMENT_VA(this, b);
-
-  if (m_opaque_sp)
-m_opaque_sp->SetCloseInputOnEOF(b);
 }
 
 SBTypeCategory SBDebugger::GetCategory(const char *category_name) {

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 690432d4c3dfda..7ec1efc64fe938 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -929,15 +929,6 @@ void Debugger::Clear() {
   });
 }
 
-bool Debugger::GetCloseInputOnEOF() const {
-  //return m_input_comm.GetCloseOnEOF();
-  return false;
-}
-
-void Debugger::SetCloseInputOnEOF(bool b) {
-  //m_input_comm.SetCloseOnEOF(b);
-}
-
 bool Debugger::GetAsyncExecution() {
   return !m_command_interpreter_up->GetSynchronous();
 }



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


[Lldb-commits] [PATCH] D157850: [lldb/crashlog] Fix module loading for crashed thread behaviour

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157850/new/

https://reviews.llvm.org/D157850

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


[Lldb-commits] [PATCH] D158000: [lldb] Remove {Get, Set}CloseInputOnEOF and deprecate SB equivalent (NFC)

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added inline comments.



Comment at: lldb/source/API/SBDebugger.cpp:1538-1545
+LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
 bool SBDebugger::GetCloseInputOnEOF() const {
   LLDB_INSTRUMENT_VA(this);
 
-  return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
+  return false;
 }
 

bulbazord wrote:
> You probably want these annotations on the header file so that projects that 
> compile against LLDB get the deprecation warnings.
Good point. Fixed in f2ec73c74650. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158000/new/

https://reviews.llvm.org/D158000

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


[Lldb-commits] [PATCH] D158000: [lldb] Remove {Get, Set}CloseInputOnEOF and deprecate SB equivalent (NFC)

2023-08-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added inline comments.



Comment at: lldb/source/API/SBDebugger.cpp:1538-1545
+LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
 bool SBDebugger::GetCloseInputOnEOF() const {
   LLDB_INSTRUMENT_VA(this);
 
-  return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
+  return false;
 }
 

You probably want these annotations on the header file so that projects that 
compile against LLDB get the deprecation warnings.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158000/new/

https://reviews.llvm.org/D158000

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


[Lldb-commits] [PATCH] D158000: [lldb] Remove {Get, Set}CloseInputOnEOF and deprecate SB equivalent (NFC)

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG23312cde45b9: [lldb] Remove {Get,Set}CloseInputOnEOF and 
deprecate SB equivalent (NFC) (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D158000?vs=550383=550388#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158000/new/

https://reviews.llvm.org/D158000

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/Debugger.cpp


Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -929,15 +929,6 @@
   });
 }
 
-bool Debugger::GetCloseInputOnEOF() const {
-  //return m_input_comm.GetCloseOnEOF();
-  return false;
-}
-
-void Debugger::SetCloseInputOnEOF(bool b) {
-  //m_input_comm.SetCloseOnEOF(b);
-}
-
 bool Debugger::GetAsyncExecution() {
   return !m_command_interpreter_up->GetSynchronous();
 }
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -1535,17 +1535,16 @@
   return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
 bool SBDebugger::GetCloseInputOnEOF() const {
   LLDB_INSTRUMENT_VA(this);
 
-  return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
+  return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::SetCloseInputOnEOF() is deprecated.")
 void SBDebugger::SetCloseInputOnEOF(bool b) {
   LLDB_INSTRUMENT_VA(this, b);
-
-  if (m_opaque_sp)
-m_opaque_sp->SetCloseInputOnEOF(b);
 }
 
 SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -241,10 +241,6 @@
 
   void ClearIOHandlers();
 
-  bool GetCloseInputOnEOF() const;
-
-  void SetCloseInputOnEOF(bool b);
-
   bool EnableLog(llvm::StringRef channel,
  llvm::ArrayRef categories,
  llvm::StringRef log_file, uint32_t log_options,


Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -929,15 +929,6 @@
   });
 }
 
-bool Debugger::GetCloseInputOnEOF() const {
-  //return m_input_comm.GetCloseOnEOF();
-  return false;
-}
-
-void Debugger::SetCloseInputOnEOF(bool b) {
-  //m_input_comm.SetCloseOnEOF(b);
-}
-
 bool Debugger::GetAsyncExecution() {
   return !m_command_interpreter_up->GetSynchronous();
 }
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -1535,17 +1535,16 @@
   return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
 bool SBDebugger::GetCloseInputOnEOF() const {
   LLDB_INSTRUMENT_VA(this);
 
-  return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
+  return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::SetCloseInputOnEOF() is deprecated.")
 void SBDebugger::SetCloseInputOnEOF(bool b) {
   LLDB_INSTRUMENT_VA(this, b);
-
-  if (m_opaque_sp)
-m_opaque_sp->SetCloseInputOnEOF(b);
 }
 
 SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -241,10 +241,6 @@
 
   void ClearIOHandlers();
 
-  bool GetCloseInputOnEOF() const;
-
-  void SetCloseInputOnEOF(bool b);
-
   bool EnableLog(llvm::StringRef channel,
  llvm::ArrayRef categories,
  llvm::StringRef log_file, uint32_t log_options,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D158000: [lldb] Remove {Get, Set}CloseInputOnEOF and deprecate SB equivalent (NFC)

2023-08-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: bulbazord, clayborg.
Herald added a project: All.
JDevlieghere requested review of this revision.

These functions have been NO-OPs since 2014 (44d937820b451). Remove them
and deprecate the corresponding functions in SBDebugger.


https://reviews.llvm.org/D158000

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/Debugger.cpp


Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -929,15 +929,6 @@
   });
 }
 
-bool Debugger::GetCloseInputOnEOF() const {
-  //return m_input_comm.GetCloseOnEOF();
-  return false;
-}
-
-void Debugger::SetCloseInputOnEOF(bool b) {
-  //m_input_comm.SetCloseOnEOF(b);
-}
-
 bool Debugger::GetAsyncExecution() {
   return !m_command_interpreter_up->GetSynchronous();
 }
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -1535,17 +1535,15 @@
   return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
 bool SBDebugger::GetCloseInputOnEOF() const {
   LLDB_INSTRUMENT_VA(this);
-
-  return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
+  return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::SetCloseInputOnEOF() is deprecated.")
 void SBDebugger::SetCloseInputOnEOF(bool b) {
   LLDB_INSTRUMENT_VA(this, b);
-
-  if (m_opaque_sp)
-m_opaque_sp->SetCloseInputOnEOF(b);
 }
 
 SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -241,10 +241,6 @@
 
   void ClearIOHandlers();
 
-  bool GetCloseInputOnEOF() const;
-
-  void SetCloseInputOnEOF(bool b);
-
   bool EnableLog(llvm::StringRef channel,
  llvm::ArrayRef categories,
  llvm::StringRef log_file, uint32_t log_options,


Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -929,15 +929,6 @@
   });
 }
 
-bool Debugger::GetCloseInputOnEOF() const {
-  //return m_input_comm.GetCloseOnEOF();
-  return false;
-}
-
-void Debugger::SetCloseInputOnEOF(bool b) {
-  //m_input_comm.SetCloseOnEOF(b);
-}
-
 bool Debugger::GetAsyncExecution() {
   return !m_command_interpreter_up->GetSynchronous();
 }
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -1535,17 +1535,15 @@
   return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
 bool SBDebugger::GetCloseInputOnEOF() const {
   LLDB_INSTRUMENT_VA(this);
-
-  return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
+  return false;
 }
 
+LLDB_DEPRECATED("SBDebugger::SetCloseInputOnEOF() is deprecated.")
 void SBDebugger::SetCloseInputOnEOF(bool b) {
   LLDB_INSTRUMENT_VA(this, b);
-
-  if (m_opaque_sp)
-m_opaque_sp->SetCloseInputOnEOF(b);
 }
 
 SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -241,10 +241,6 @@
 
   void ClearIOHandlers();
 
-  bool GetCloseInputOnEOF() const;
-
-  void SetCloseInputOnEOF(bool b);
-
   bool EnableLog(llvm::StringRef channel,
  llvm::ArrayRef categories,
  llvm::StringRef log_file, uint32_t log_options,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157992: [lldb][CPlusPlus][NFCI] Remove redundant construction of ClangASTImporter

2023-08-15 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The usage of this variable was removed in 
`4f14c17df70916913d71914343dd4f6c709e218d`.

This is no longer used inside this file. Since the call to
`GetPersistentExpressionStateForLanguage` has side-effects I marked this
NFCI. But there is no good reason we need this here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157992

Files:
  lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -54,18 +54,6 @@
 if (!clang_ast_context)
   return;
 
-std::shared_ptr clang_ast_importer;
-auto *state = target_sp->GetPersistentExpressionStateForLanguage(
-lldb::eLanguageTypeC_plus_plus);
-if (state) {
-  auto *persistent_vars = llvm::cast(state);
-  clang_ast_importer = persistent_vars->GetClangASTImporter();
-}
-
-if (!clang_ast_importer) {
-  return;
-}
-
 const char *const isa_name("__isa");
 const CompilerType isa_type =
 clang_ast_context->GetBasicType(lldb::eBasicTypeObjCClass);


Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -54,18 +54,6 @@
 if (!clang_ast_context)
   return;
 
-std::shared_ptr clang_ast_importer;
-auto *state = target_sp->GetPersistentExpressionStateForLanguage(
-lldb::eLanguageTypeC_plus_plus);
-if (state) {
-  auto *persistent_vars = llvm::cast(state);
-  clang_ast_importer = persistent_vars->GetClangASTImporter();
-}
-
-if (!clang_ast_importer) {
-  return;
-}
-
 const char *const isa_name("__isa");
 const CompilerType isa_type =
 clang_ast_context->GetBasicType(lldb::eBasicTypeObjCClass);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157883: [lldb][AArch64] Add SME's Array Storage (ZA) and streaming vector length (SVG) registers

2023-08-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 550290.
DavidSpickett added a comment.

Remove redundant get process calls in TestSVEThreadedDynamic.py.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157883/new/

https://reviews.llvm.org/D157883

Files:
  lldb/include/lldb/Utility/RegisterValue.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/TestZAThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/main.c
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/TestZARegisterSaveRestore.py
  lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c

Index: lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
@@ -0,0 +1,225 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Important details for this program:
+// * Making a syscall will disable streaming mode if it is active.
+// * Changing the vector length will make streaming mode and ZA inactive.
+// * ZA can be active independent of streaming mode.
+// * ZA's size is the streaming vector length squared.
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#ifndef PR_SME_GET_VL
+#define PR_SME_GET_VL 64
+#endif
+
+#ifndef PR_SME_VL_LEN_MASK
+#define PR_SME_VL_LEN_MASK 0x
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART SM_INST(7)
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+#define SMSTOP SM_INST(6)
+#define SMSTOP_SM SM_INST(2)
+#define SMSTOP_ZA SM_INST(4)
+
+int start_vl = 0;
+int other_vl = 0;
+
+void write_sve_regs() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatile("cpy  z19.b, p15/z, #20\n\t");
+  asm volatile("cpy  z20.b, p0/z, #21\n\t");
+  asm volatile("cpy  z21.b, p5/z, #22\n\t");
+  asm volatile("cpy  z22.b, p10/z, #23\n\t");
+  asm volatile("cpy  z23.b, p15/z, #24\n\t");
+  asm volatile("cpy  z24.b, p0/z, #25\n\t");
+  asm volatile("cpy  z25.b, p5/z, #26\n\t");
+  asm volatile("cpy  z26.b, p10/z, #27\n\t");
+  asm volatile("cpy  z27.b, p15/z, #28\n\t");
+  asm volatile("cpy 

[Lldb-commits] [PATCH] D157883: [lldb][AArch64] Add SME's Array Storage (ZA) and streaming vector length (SVG) registers

2023-08-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 550289.
DavidSpickett added a comment.

Replace missing process variable in TestZAThreadedDynamic.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157883/new/

https://reviews.llvm.org/D157883

Files:
  lldb/include/lldb/Utility/RegisterValue.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/TestZAThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/main.c
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/TestZARegisterSaveRestore.py
  lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c

Index: lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
@@ -0,0 +1,225 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Important details for this program:
+// * Making a syscall will disable streaming mode if it is active.
+// * Changing the vector length will make streaming mode and ZA inactive.
+// * ZA can be active independent of streaming mode.
+// * ZA's size is the streaming vector length squared.
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#ifndef PR_SME_GET_VL
+#define PR_SME_GET_VL 64
+#endif
+
+#ifndef PR_SME_VL_LEN_MASK
+#define PR_SME_VL_LEN_MASK 0x
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART SM_INST(7)
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+#define SMSTOP SM_INST(6)
+#define SMSTOP_SM SM_INST(2)
+#define SMSTOP_ZA SM_INST(4)
+
+int start_vl = 0;
+int other_vl = 0;
+
+void write_sve_regs() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatile("cpy  z19.b, p15/z, #20\n\t");
+  asm volatile("cpy  z20.b, p0/z, #21\n\t");
+  asm volatile("cpy  z21.b, p5/z, #22\n\t");
+  asm volatile("cpy  z22.b, p10/z, #23\n\t");
+  asm volatile("cpy  z23.b, p15/z, #24\n\t");
+  asm volatile("cpy  z24.b, p0/z, #25\n\t");
+  asm volatile("cpy  z25.b, p5/z, #26\n\t");
+  asm volatile("cpy  z26.b, p10/z, #27\n\t");
+  asm volatile("cpy  z27.b, p15/z, #28\n\t");
+  asm volatile("cpy  

[Lldb-commits] [PATCH] D157967: [lldb][AArch64] Use atomics to sync threads in SVE threading test

2023-08-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: omjavaid.
DavidSpickett added a comment.

I was not able to reproduce the bot's timeout situation with this or the 
previous implementation, but I did run this on a loop with `stress` in the 
background and didn't get any failures. I think doing it with atomics is at 
least in theory the proper way to do it regardless, even if it has its own 
corner cases that I haven't thought of.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157967/new/

https://reviews.llvm.org/D157967

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


[Lldb-commits] [PATCH] D157967: [lldb][AArch64] Use atomics to sync threads in SVE threading test

2023-08-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

One recent example of a timeout on the Graviton bot: 
https://lab.llvm.org/buildbot/#/builders/96/builds/43649


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157967/new/

https://reviews.llvm.org/D157967

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


[Lldb-commits] [PATCH] D157967: [lldb][AArch64] Use atomics to sync threads in SVE threading test

2023-08-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Previously we would "process continue" then wait for the number of
threads to be 3 before proceeding with the test.

Testing this on QEMU I saw it would sometimes get stuck at this check,
with one of the threads on a breakpoint before the other had started.
We do want it to be on a breakpoint, but we need the other thread to have
at least started so lldb can interact with both.

I've also seen it timeout on the Graviton buildbot, likely the same
cause.

To fix this add 2 variables to stall either thread until the other
has started up. Then it doesn't matter which one hits its breakpoint
first, the test will just continue the one that didn't, until both
are on the expected breakpoint.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157967

Files:
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c


Index: 
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
===
--- 
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
+++ 
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
@@ -1,4 +1,6 @@
 #include 
+#include 
+#include 
 #include 
 
 #ifndef PR_SME_SET_VL
@@ -62,7 +64,18 @@
 
 int SET_VL_OPT = PR_SVE_SET_VL;
 
+// These ensure that when lldb stops in one of threadX / threadY, the other has
+// at least been created. That means we can continue the other onto the 
expected
+// breakpoint. Otherwise we could get to the breakpoint in one thread before 
the
+// other has started.
+atomic_bool threadX_ready = false;
+atomic_bool threadY_ready = false;
+
 void *threadX_func(void *x_arg) {
+  threadX_ready = true;
+  while (!threadY_ready) {
+  }
+
   prctl(SET_VL_OPT, 8 * 4);
 #ifdef USE_SSVE
   SMSTART();
@@ -73,6 +86,10 @@
 }
 
 void *threadY_func(void *y_arg) {
+  threadY_ready = true;
+  while (!threadX_ready) {
+  }
+
   prctl(SET_VL_OPT, 8 * 2);
 #ifdef USE_SSVE
   SMSTART();
Index: 
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
===
--- 
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
+++ 
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
@@ -148,10 +148,6 @@
 
 self.runCmd("process continue", RUN_SUCCEEDED)
 
-# If we start the checks too quickly, thread 3 may not have started.
-while process.GetNumThreads() < 3:
-pass
-
 for idx in range(1, process.GetNumThreads()):
 thread = process.GetThreadAtIndex(idx)
 if thread.GetStopReason() != lldb.eStopReasonBreakpoint:


Index: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
===
--- lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
+++ lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/main.c
@@ -1,4 +1,6 @@
 #include 
+#include 
+#include 
 #include 
 
 #ifndef PR_SME_SET_VL
@@ -62,7 +64,18 @@
 
 int SET_VL_OPT = PR_SVE_SET_VL;
 
+// These ensure that when lldb stops in one of threadX / threadY, the other has
+// at least been created. That means we can continue the other onto the expected
+// breakpoint. Otherwise we could get to the breakpoint in one thread before the
+// other has started.
+atomic_bool threadX_ready = false;
+atomic_bool threadY_ready = false;
+
 void *threadX_func(void *x_arg) {
+  threadX_ready = true;
+  while (!threadY_ready) {
+  }
+
   prctl(SET_VL_OPT, 8 * 4);
 #ifdef USE_SSVE
   SMSTART();
@@ -73,6 +86,10 @@
 }
 
 void *threadY_func(void *y_arg) {
+  threadY_ready = true;
+  while (!threadX_ready) {
+  }
+
   prctl(SET_VL_OPT, 8 * 2);
 #ifdef USE_SSVE
   SMSTART();
Index: lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
===
--- lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
+++ lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
@@ -148,10 +148,6 @@
 
 self.runCmd("process continue", RUN_SUCCEEDED)
 
-# If we start the checks too quickly, thread 3 may not 

[Lldb-commits] [PATCH] D157883: [lldb][AArch64] Add SME's Array Storage (ZA) and streaming vector length (SVG) registers

2023-08-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 550250.
DavidSpickett added a comment.

In TestZAThreadedDynamic.py, replace the while < 3 threads check in Python with
atomic variables in the program file. This fixes a situation where the first 
"process continue" hits the breakpoint in thread 2, and waits forever because 
thread 3 is never
created.

The atomics mean that while one thread may break before the other, the other
is at least known to have started before this can happen.

(I'll apply the same fix to the SVE threaded test, which does occasionally
timeout on the buildbot, presumably due to this)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157883/new/

https://reviews.llvm.org/D157883

Files:
  lldb/include/lldb/Utility/RegisterValue.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/LinuxPTraceDefines_arm64sve.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/TestZAThreadedDynamic.py
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_dynamic_resize/main.c
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/Makefile
  
lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/TestZARegisterSaveRestore.py
  lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c

Index: lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_za_reg/za_save_restore/main.c
@@ -0,0 +1,225 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Important details for this program:
+// * Making a syscall will disable streaming mode if it is active.
+// * Changing the vector length will make streaming mode and ZA inactive.
+// * ZA can be active independent of streaming mode.
+// * ZA's size is the streaming vector length squared.
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+#ifndef PR_SME_GET_VL
+#define PR_SME_GET_VL 64
+#endif
+
+#ifndef PR_SME_VL_LEN_MASK
+#define PR_SME_VL_LEN_MASK 0x
+#endif
+
+#define SM_INST(c) asm volatile("msr s0_3_c4_c" #c "_3, xzr")
+#define SMSTART SM_INST(7)
+#define SMSTART_SM SM_INST(3)
+#define SMSTART_ZA SM_INST(5)
+#define SMSTOP SM_INST(6)
+#define SMSTOP_SM SM_INST(2)
+#define SMSTOP_ZA SM_INST(4)
+
+int start_vl = 0;
+int other_vl = 0;
+
+void write_sve_regs() {
+  // We assume the smefa64 feature is present, which allows ffr access
+  // in streaming mode.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  

[Lldb-commits] [PATCH] D157960: [lldb][gui] Update TreeItem children's m_parent on move

2023-08-15 Thread Pavel Kosov via Phabricator via lldb-commits
kpdev42 created this revision.
kpdev42 added reviewers: clayborg, davide, k8stone.
kpdev42 added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
kpdev42 requested review of this revision.
Herald added a subscriber: lldb-commits.

Before this patch, any time TreeItem is copied in Resize method, its
parent is not updated, which can cause crashes when, for example, thread
window with multiple hierarchy levels is updated. Makes TreeItem
move-only, removes TreeItem's m_delegate extra self-assignment by making
it a pointer, adds code to fix up children's parent on move constructor
and operator=

~~~

Huawei RRI, OS Lab


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157960

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/test/API/commands/gui/spawn-threads/Makefile
  lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py
  lldb/test/API/commands/gui/spawn-threads/main.cpp

Index: lldb/test/API/commands/gui/spawn-threads/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/gui/spawn-threads/main.cpp
@@ -0,0 +1,25 @@
+#include 
+#include 
+#include 
+
+#include "pseudo_barrier.h"
+
+pseudo_barrier_t barrier_inside;
+
+void thread_func() { pseudo_barrier_wait(barrier_inside); }
+
+void test_thread() {
+  std::vector thrs;
+  for (int i = 0; i < 5; i++)
+thrs.push_back(std::thread(thread_func)); // break here
+
+  pseudo_barrier_wait(barrier_inside); // break before join
+  for (auto  : thrs)
+t.join();
+}
+
+int main() {
+  pseudo_barrier_init(barrier_inside, 6);
+  test_thread();
+  return 0;
+}
Index: lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py
===
--- /dev/null
+++ lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py
@@ -0,0 +1,47 @@
+"""
+Test that 'gui' does not crash when adding new threads, which
+populate TreeItem's children and may be reallocated elsewhere.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+import sys
+
+class TestGuiSpawnThreadsTest(PExpectTest):
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfCursesSupportMissing
+def test_gui(self):
+self.build()
+
+self.launch(executable=self.getBuildArtifact('a.out'), dimensions=(100, 500))
+self.expect(
+'breakpoint set -f main.cpp -p "break here"', substrs=['Breakpoint 1', 'address =']
+)
+self.expect(
+'breakpoint set -f main.cpp -p "before join"', substrs=['Breakpoint 2', 'address =']
+)
+self.expect("run", substrs=["stop reason ="])
+
+escape_key = chr(27).encode()
+
+# Start the GUI
+self.child.sendline("gui")
+self.child.expect_exact("Threads")
+self.child.expect_exact(f"thread #1: tid =")
+
+for i in range(5):
+# Stopped at the breakpoit, continue over the thread creation
+self.child.send("c")
+# Check the newly created thread
+self.child.expect_exact(f"thread #{i + 2}: tid =")
+
+# Exit GUI.
+self.child.send(escape_key)
+self.expect_prompt()
+
+self.quit()
Index: lldb/test/API/commands/gui/spawn-threads/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/gui/spawn-threads/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+ENABLE_THREADS := YES
+include Makefile.rules
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -4614,30 +4614,48 @@
 
 typedef std::shared_ptr TreeDelegateSP;
 
-class TreeItem {
+struct TreeItemData {
+  TreeItemData(TreeItem *parent, TreeDelegate ,
+   bool might_have_children, bool is_expanded)
+  : m_parent(parent), m_delegate(),
+m_might_have_children(might_have_children), m_is_expanded(is_expanded) {
+  }
+
+protected:
+  TreeItem *m_parent;
+  TreeDelegate *m_delegate;
+  void *m_user_data = nullptr;
+  uint64_t m_identifier = 0;
+  std::string m_text;
+  int m_row_idx = -1; // Zero based visible row index, -1 if not visible or for
+  // the root item
+  bool m_might_have_children;
+  bool m_is_expanded = false;
+};
+
+class TreeItem : public TreeItemData {
 public:
   TreeItem(TreeItem *parent, TreeDelegate , bool might_have_children)
-  : m_parent(parent), m_delegate(delegate), m_children(),
-m_might_have_children(might_have_children) {
-if (m_parent == nullptr)
-  m_is_expanded = m_delegate.TreeDelegateExpandRootByDefault();
-  }
+  : TreeItemData(parent, delegate, might_have_children,
+

[Lldb-commits] [PATCH] D157609: [lldb] Search debug file paths when looking for split DWARF files

2023-08-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

> We are also looking for a way to locate .dwo files at Meta. One idea we came 
> up with is to add a setting that can be set:
> (lldb) settings set symbols.locate-dwo-script /path/to/locate-dwo.py

Probably best bring this up on Discourse for a wider audience as I'm not up to 
date on all the search methods, I just dived into this one in particular. First 
thought is it sounds a bit like what debuginfod is supposed to do, but I don't 
know the details of that at the moment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157609/new/

https://reviews.llvm.org/D157609

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


[Lldb-commits] [PATCH] D157609: [lldb] Search debug file paths when looking for split DWARF files

2023-08-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1737
+  if (!dwo_file.IsRelative()) {
+found = FileSystem::Instance().Exists(dwo_file);
+  } else {

clayborg wrote:
> Maybe we can also check the debug info search paths to see if they contain 
> just the basename in case someone sends you a binary and any needed .dwo 
> files?
> 
> So if we have a DWO path of "/users/someone/build/foo.dwo", we would check 
> each of the debug info search paths for:
> ```
> path + dwo_file.GetFilename()
> ```
> This would allow someone to send a binary to someone else and allow them to 
> load it up.
> 
> But any such search might belong down below this entire if/else statement 
> when the file isn't found:
> 
> ```
> if (!found) {
>   // Search for debug info path + basename...
> }
> ```
Good idea, I'll write a test for that scenario and see if it makes sense here 
or in a follow up.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157609/new/

https://reviews.llvm.org/D157609

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