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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157648

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

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -629,6 +629,7 @@
 const Timeout ) {
   // don't sync (potentially context switch) in case where there is no process
   // IO
+  std::lock_guard guard(m_process_input_reader_mutex);
   if (!m_process_input_reader)
 return;
 
@@ -2504,7 +2505,11 @@
   m_jit_loaders_up.reset();
   m_system_runtime_up.reset();
   m_os_up.reset();
-  m_process_input_reader.reset();
+
+  {
+std::lock_guard guard(m_process_input_reader_mutex);
+m_process_input_reader.reset();
+  }
 
   Module *exe_module = GetTarget().GetExecutableModulePointer();
 
@@ -2802,7 +2807,10 @@
 
 Status Process::Attach(ProcessAttachInfo _info) {
   m_abi_sp.reset();
-  m_process_input_reader.reset();
+  {
+std::lock_guard guard(m_process_input_reader_mutex);
+m_process_input_reader.reset();
+  }
   m_dyld_up.reset();
   m_jit_loaders_up.reset();
   m_system_runtime_up.reset();
@@ -3053,7 +3061,10 @@
 
 Status Process::ConnectRemote(llvm::StringRef remote_url) {
   m_abi_sp.reset();
-  m_process_input_reader.reset();
+  {
+std::lock_guard guard(m_process_input_reader_mutex);
+m_process_input_reader.reset();
+  }
 
   // Find the process and its architecture.  Make sure it matches the
   // architecture of the current Target, and if not adjust it.
@@ -3341,10 +3352,13 @@
 m_stdio_communication.Disconnect();
 m_stdin_forward = false;
 
-if (m_process_input_reader) {
-  m_process_input_reader->SetIsDone(true);
-  m_process_input_reader->Cancel();
-  m_process_input_reader.reset();
+{
+  std::lock_guard guard(m_process_input_reader_mutex);
+  if (m_process_input_reader) {
+m_process_input_reader->SetIsDone(true);
+m_process_input_reader->Cancel();
+m_process_input_reader.reset();
+  }
 }
 
 // If we exited when we were waiting for a process to stop, then forward
@@ -4522,20 +4536,25 @@
 m_stdio_communication.StartReadThread();
 
 // Now read thread is set up, set up input reader.
-
-if (!m_process_input_reader)
-  m_process_input_reader =
-  std::make_shared(this, fd);
+{
+  std::lock_guard guard(m_process_input_reader_mutex);
+  if (!m_process_input_reader)
+m_process_input_reader =
+std::make_shared(this, fd);
+}
   }
 }
 
 bool Process::ProcessIOHandlerIsActive() {
+  std::lock_guard guard(m_process_input_reader_mutex);
   IOHandlerSP io_handler_sp(m_process_input_reader);
   if (io_handler_sp)
 return GetTarget().GetDebugger().IsTopIOHandler(io_handler_sp);
   return false;
 }
+
 bool Process::PushProcessIOHandler() {
+  std::lock_guard guard(m_process_input_reader_mutex);
   IOHandlerSP io_handler_sp(m_process_input_reader);
   if (io_handler_sp) {
 Log *log = GetLog(LLDBLog::Process);
@@ -4555,6 +4574,7 @@
 }
 
 bool Process::PopProcessIOHandler() {
+  std::lock_guard guard(m_process_input_reader_mutex);
   IOHandlerSP io_handler_sp(m_process_input_reader);
   if (io_handler_sp)
 return GetTarget().GetDebugger().RemoveIOHandler(io_handler_sp);
Index: lldb/include/lldb/Target/Process.h
===
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -3007,6 +3007,7 @@
   m_unix_signals_sp; /// This is the current signal set for this process.
   lldb::ABISP m_abi_sp;
   lldb::IOHandlerSP m_process_input_reader;
+  mutable std::mutex m_process_input_reader_mutex;
   ThreadedCommunication m_stdio_communication;
   std::recursive_mutex m_stdio_communication_mutex;
   bool m_stdin_forward; /// Remember if stdin must be forwarded to remote debug
@@ -3132,6 +3133,7 @@
   bool ProcessIOHandlerIsActive();
 
   bool ProcessIOHandlerExists() const {
+std::lock_guard guard(m_process_input_reader_mutex);
 return static_cast(m_process_input_reader);
   }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 79a8e00 - [lldb] Fix data race in Process

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

Author: Augusto Noronha
Date: 2023-08-18T16:55:37-07:00
New Revision: 79a8e006dbc4ea281e9ec5933f484e476db3d9ab

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

LOG: [lldb] Fix data race in Process

Thread sanitizer reports a data race in Process.cpp in the usage of
m_process_input_reader. Fix this data race by introducing a mutex
guarding the access to this variable.

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

Added: 


Modified: 
lldb/include/lldb/Target/Process.h
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 2e1bce561526df..8e75ed85229429 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -3007,6 +3007,7 @@ void PruneThreadPlans();
   m_unix_signals_sp; /// This is the current signal set for this process.
   lldb::ABISP m_abi_sp;
   lldb::IOHandlerSP m_process_input_reader;
+  mutable std::mutex m_process_input_reader_mutex;
   ThreadedCommunication m_stdio_communication;
   std::recursive_mutex m_stdio_communication_mutex;
   bool m_stdin_forward; /// Remember if stdin must be forwarded to remote debug
@@ -3132,6 +3133,7 @@ void PruneThreadPlans();
   bool ProcessIOHandlerIsActive();
 
   bool ProcessIOHandlerExists() const {
+std::lock_guard guard(m_process_input_reader_mutex);
 return static_cast(m_process_input_reader);
   }
 

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 4a33d8980c2782..d76db377d3e900 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -629,6 +629,7 @@ void Process::SyncIOHandler(uint32_t iohandler_id,
 const Timeout ) {
   // don't sync (potentially context switch) in case where there is no process
   // IO
+  std::lock_guard guard(m_process_input_reader_mutex);
   if (!m_process_input_reader)
 return;
 
@@ -2504,7 +2505,11 @@ Status Process::LaunchPrivate(ProcessLaunchInfo 
_info, StateType ,
   m_jit_loaders_up.reset();
   m_system_runtime_up.reset();
   m_os_up.reset();
-  m_process_input_reader.reset();
+
+  {
+std::lock_guard guard(m_process_input_reader_mutex);
+m_process_input_reader.reset();
+  }
 
   Module *exe_module = GetTarget().GetExecutableModulePointer();
 
@@ -2802,7 +2807,10 @@ Status Process::WillAttachToProcessWithName(const char 
*process_name,
 
 Status Process::Attach(ProcessAttachInfo _info) {
   m_abi_sp.reset();
-  m_process_input_reader.reset();
+  {
+std::lock_guard guard(m_process_input_reader_mutex);
+m_process_input_reader.reset();
+  }
   m_dyld_up.reset();
   m_jit_loaders_up.reset();
   m_system_runtime_up.reset();
@@ -3053,7 +3061,10 @@ void Process::CompleteAttach() {
 
 Status Process::ConnectRemote(llvm::StringRef remote_url) {
   m_abi_sp.reset();
-  m_process_input_reader.reset();
+  {
+std::lock_guard guard(m_process_input_reader_mutex);
+m_process_input_reader.reset();
+  }
 
   // Find the process and its architecture.  Make sure it matches the
   // architecture of the current Target, and if not adjust it.
@@ -3341,10 +3352,13 @@ Status Process::DestroyImpl(bool force_kill) {
 m_stdio_communication.Disconnect();
 m_stdin_forward = false;
 
-if (m_process_input_reader) {
-  m_process_input_reader->SetIsDone(true);
-  m_process_input_reader->Cancel();
-  m_process_input_reader.reset();
+{
+  std::lock_guard guard(m_process_input_reader_mutex);
+  if (m_process_input_reader) {
+m_process_input_reader->SetIsDone(true);
+m_process_input_reader->Cancel();
+m_process_input_reader.reset();
+  }
 }
 
 // If we exited when we were waiting for a process to stop, then forward
@@ -4522,20 +4536,25 @@ void Process::SetSTDIOFileDescriptor(int fd) {
 m_stdio_communication.StartReadThread();
 
 // Now read thread is set up, set up input reader.
-
-if (!m_process_input_reader)
-  m_process_input_reader =
-  std::make_shared(this, fd);
+{
+  std::lock_guard guard(m_process_input_reader_mutex);
+  if (!m_process_input_reader)
+m_process_input_reader =
+std::make_shared(this, fd);
+}
   }
 }
 
 bool Process::ProcessIOHandlerIsActive() {
+  std::lock_guard guard(m_process_input_reader_mutex);
   IOHandlerSP io_handler_sp(m_process_input_reader);
   if (io_handler_sp)
 return GetTarget().GetDebugger().IsTopIOHandler(io_handler_sp);
   return false;
 }
+
 bool Process::PushProcessIOHandler() {
+  std::lock_guard guard(m_process_input_reader_mutex);
   IOHandlerSP io_handler_sp(m_process_input_reader);
   if (io_handler_sp) {
 Log *log = GetLog(LLDBLog::Process);
@@ -4555,6 +4574,7 @@ bool 

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

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

Changed prior to commit:
  https://reviews.llvm.org/D158034?vs=550519=551673#toc

Repository:
  rG LLVM Github Monorepo

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

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(),
@@ -2456,7 +2456,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
@@ -2970,7 +2970,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
  ///to the protocol we are debugging with
   ThreadList m_thread_list; ///< The threads for this process as the user will


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 

[Lldb-commits] [lldb] bb90063 - [lldb] Fix data race in ThreadList

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

Author: Augusto Noronha
Date: 2023-08-18T16:53:26-07:00
New Revision: bb90063249707e3ae081bfbd8e3512566abb7df6

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

LOG: [lldb] Fix data race in ThreadList

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.

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

Added: 


Modified: 
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

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 2186eea7ef5054..2e1bce561526df 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2970,7 +2970,6 @@ void PruneThreadPlans();
   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
  ///to the protocol we are debugging with
   ThreadList m_thread_list; ///< The threads for this process as the user will

diff  --git a/lldb/include/lldb/Target/ThreadCollection.h 
b/lldb/include/lldb/Target/ThreadCollection.h
index 29f5103e7eec7c..dc7d8f13eee037 100644
--- a/lldb/include/lldb/Target/ThreadCollection.h
+++ b/lldb/include/lldb/Target/ThreadCollection.h
@@ -47,7 +47,7 @@ class ThreadCollection {
 return ThreadIterable(m_threads, GetMutex());
   }
 
-  virtual std::recursive_mutex () const { return m_mutex; }
+  std::recursive_mutex () const { return m_mutex; }
 
 protected:
   collection m_threads;

diff  --git a/lldb/include/lldb/Target/ThreadList.h 
b/lldb/include/lldb/Target/ThreadList.h
index 6af04f8ffc3767..8aaff6e4cba0d4 100644
--- a/lldb/include/lldb/Target/ThreadList.h
+++ b/lldb/include/lldb/Target/ThreadList.h
@@ -133,8 +133,6 @@ class ThreadList : public ThreadCollection {
 
   void SetStopID(uint32_t stop_id);
 
-  std::recursive_mutex () const override;
-
   void Update(ThreadList );
 
 protected:

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index fc08cce096103f..4a33d8980c2782 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -435,7 +435,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP 
listener_sp,
   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(),
@@ -2456,7 +2456,7 @@ Process::WaitForProcessStopPrivate(EventSP _sp,
 }
 
 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));

diff  --git a/lldb/source/Target/ThreadList.cpp 
b/lldb/source/Target/ThreadList.cpp
index 1ba0c435b993d3..fc6cbd48cf8653 100644
--- 

[Lldb-commits] [PATCH] D157043: [lldb/crashlog] Make TextCrashLogParser more resilient to new lines

2023-08-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib closed this revision.
mib added a comment.

In D157043#4584339 , @mib wrote:

> In D157043#4582385 , @JDevlieghere 
> wrote:
>
>> Test?
>
> I'll do it in a follow-up.

7602641 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157043

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


[Lldb-commits] [PATCH] D158237: Change LLGSTest.cpp to run environment_check inferior with stdin/stdout disabled, to work around ASAN CI bot issue

2023-08-18 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG18b211cb1521: Disable stdin/stdout for environment_check 
inferior process (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158237

Files:
  lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
  lldb/unittests/tools/lldb-server/tests/TestClient.cpp
  lldb/unittests/tools/lldb-server/tests/TestClient.h


Index: lldb/unittests/tools/lldb-server/tests/TestClient.h
===
--- lldb/unittests/tools/lldb-server/tests/TestClient.h
+++ lldb/unittests/tools/lldb-server/tests/TestClient.h
@@ -48,8 +48,9 @@
   /// using this for generic tests, as the two stubs have different
   /// command-line interfaces.
   static llvm::Expected>
-  launchCustom(llvm::StringRef Log, llvm::ArrayRef 
ServerArgs, llvm::ArrayRef InferiorArgs);
-
+  launchCustom(llvm::StringRef Log, bool disable_stdio,
+   llvm::ArrayRef ServerArgs,
+   llvm::ArrayRef InferiorArgs);
 
   ~TestClient() override;
   llvm::Error SetInferior(llvm::ArrayRef inferior_args);
Index: lldb/unittests/tools/lldb-server/tests/TestClient.cpp
===
--- lldb/unittests/tools/lldb-server/tests/TestClient.cpp
+++ lldb/unittests/tools/lldb-server/tests/TestClient.cpp
@@ -59,10 +59,13 @@
 }
 
 Expected> TestClient::launch(StringRef Log, 
ArrayRef InferiorArgs) {
-  return launchCustom(Log, {}, InferiorArgs);
+  return launchCustom(Log, false, {}, InferiorArgs);
 }
 
-Expected> TestClient::launchCustom(StringRef Log, 
ArrayRef ServerArgs, ArrayRef InferiorArgs) {
+Expected>
+TestClient::launchCustom(StringRef Log, bool disable_stdio,
+ ArrayRef ServerArgs,
+ ArrayRef InferiorArgs) {
   const ArchSpec _spec = HostInfo::GetArchitecture();
   Args args;
   args.AppendArgument(LLDB_SERVER);
@@ -111,6 +114,8 @@
   // Accept().
   Info.SetMonitorProcessCallback(::NoOpMonitorCallback);
 
+  if (disable_stdio)
+Info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
   status = Host::LaunchProcess(Info);
   if (status.Fail())
 return status.ToError();
Index: lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
===
--- lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
+++ lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
@@ -41,9 +41,10 @@
   // Test that --env takes precedence over inherited environment variables.
   putenv(const_cast("LLDB_TEST_MAGIC_VARIABLE=foobar"));
 
-  auto ClientOr = TestClient::launchCustom(getLogFileName(),
-  { "--env", "LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE" },
- {getInferiorPath("environment_check")});
+  auto ClientOr = TestClient::launchCustom(
+  getLogFileName(), /* disable_stdio */ true,
+  {"--env", "LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE"},
+  {getInferiorPath("environment_check")});
   ASSERT_THAT_EXPECTED(ClientOr, Succeeded());
   auto  = **ClientOr;
 


Index: lldb/unittests/tools/lldb-server/tests/TestClient.h
===
--- lldb/unittests/tools/lldb-server/tests/TestClient.h
+++ lldb/unittests/tools/lldb-server/tests/TestClient.h
@@ -48,8 +48,9 @@
   /// using this for generic tests, as the two stubs have different
   /// command-line interfaces.
   static llvm::Expected>
-  launchCustom(llvm::StringRef Log, llvm::ArrayRef ServerArgs, llvm::ArrayRef InferiorArgs);
-
+  launchCustom(llvm::StringRef Log, bool disable_stdio,
+   llvm::ArrayRef ServerArgs,
+   llvm::ArrayRef InferiorArgs);
 
   ~TestClient() override;
   llvm::Error SetInferior(llvm::ArrayRef inferior_args);
Index: lldb/unittests/tools/lldb-server/tests/TestClient.cpp
===
--- lldb/unittests/tools/lldb-server/tests/TestClient.cpp
+++ lldb/unittests/tools/lldb-server/tests/TestClient.cpp
@@ -59,10 +59,13 @@
 }
 
 Expected> TestClient::launch(StringRef Log, ArrayRef InferiorArgs) {
-  return launchCustom(Log, {}, InferiorArgs);
+  return launchCustom(Log, false, {}, InferiorArgs);
 }
 
-Expected> TestClient::launchCustom(StringRef Log, ArrayRef ServerArgs, ArrayRef InferiorArgs) {
+Expected>
+TestClient::launchCustom(StringRef Log, bool disable_stdio,
+ ArrayRef ServerArgs,
+ ArrayRef InferiorArgs) {
   const ArchSpec _spec = HostInfo::GetArchitecture();
   Args args;
   args.AppendArgument(LLDB_SERVER);
@@ -111,6 +114,8 @@
   // Accept().
   Info.SetMonitorProcessCallback(::NoOpMonitorCallback);
 
+  if (disable_stdio)
+Info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
   status = Host::LaunchProcess(Info);
   if (status.Fail())
 return 

[Lldb-commits] [lldb] 18b211c - Disable stdin/stdout for environment_check inferior process

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

Author: Jason Molenda
Date: 2023-08-18T16:25:50-07:00
New Revision: 18b211cb15213f984b2014413b74958243a4805f

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

LOG: Disable stdin/stdout for environment_check inferior process

To work around an address sanitizer issue on macOS where
environment_check prints a spurious stderr msg when executing,

environment_check(41292,0x113e7a600) malloc: nano zone abandoned due to 
inability to preallocate reserved vm space.

And TestClient::Continue() which intends to continue to exit
instead sees the stderr output streamed, and doesn't handle that
unexpected output.  Easiest to disable stdin/stdout for this
one test case to avoid this corner case issue with this TestClient.cpp
way of expecting a stop reply packet after continuing.

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

Added: 


Modified: 
lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
lldb/unittests/tools/lldb-server/tests/TestClient.cpp
lldb/unittests/tools/lldb-server/tests/TestClient.h

Removed: 




diff  --git a/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp 
b/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
index 92efeffde7f19e..1f53b6d9d9944e 100644
--- a/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
+++ b/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
@@ -41,9 +41,10 @@ TEST_F(TestBase, DS_TEST(DebugserverEnv)) {
   // Test that --env takes precedence over inherited environment variables.
   putenv(const_cast("LLDB_TEST_MAGIC_VARIABLE=foobar"));
 
-  auto ClientOr = TestClient::launchCustom(getLogFileName(),
-  { "--env", "LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE" },
- {getInferiorPath("environment_check")});
+  auto ClientOr = TestClient::launchCustom(
+  getLogFileName(), /* disable_stdio */ true,
+  {"--env", "LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE"},
+  {getInferiorPath("environment_check")});
   ASSERT_THAT_EXPECTED(ClientOr, Succeeded());
   auto  = **ClientOr;
 

diff  --git a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp 
b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
index 232f725baf58a7..2d7ce36bacfaa3 100644
--- a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
+++ b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
@@ -59,10 +59,13 @@ Expected> 
TestClient::launch(StringRef Log) {
 }
 
 Expected> TestClient::launch(StringRef Log, 
ArrayRef InferiorArgs) {
-  return launchCustom(Log, {}, InferiorArgs);
+  return launchCustom(Log, false, {}, InferiorArgs);
 }
 
-Expected> TestClient::launchCustom(StringRef Log, 
ArrayRef ServerArgs, ArrayRef InferiorArgs) {
+Expected>
+TestClient::launchCustom(StringRef Log, bool disable_stdio,
+ ArrayRef ServerArgs,
+ ArrayRef InferiorArgs) {
   const ArchSpec _spec = HostInfo::GetArchitecture();
   Args args;
   args.AppendArgument(LLDB_SERVER);
@@ -111,6 +114,8 @@ Expected> 
TestClient::launchCustom(StringRef Log, Ar
   // Accept().
   Info.SetMonitorProcessCallback(::NoOpMonitorCallback);
 
+  if (disable_stdio)
+Info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
   status = Host::LaunchProcess(Info);
   if (status.Fail())
 return status.ToError();

diff  --git a/lldb/unittests/tools/lldb-server/tests/TestClient.h 
b/lldb/unittests/tools/lldb-server/tests/TestClient.h
index 9a1831d4dbc174..deb6802d0da707 100644
--- a/lldb/unittests/tools/lldb-server/tests/TestClient.h
+++ b/lldb/unittests/tools/lldb-server/tests/TestClient.h
@@ -48,8 +48,9 @@ class TestClient
   /// using this for generic tests, as the two stubs have 
diff erent
   /// command-line interfaces.
   static llvm::Expected>
-  launchCustom(llvm::StringRef Log, llvm::ArrayRef 
ServerArgs, llvm::ArrayRef InferiorArgs);
-
+  launchCustom(llvm::StringRef Log, bool disable_stdio,
+   llvm::ArrayRef ServerArgs,
+   llvm::ArrayRef InferiorArgs);
 
   ~TestClient() override;
   llvm::Error SetInferior(llvm::ArrayRef inferior_args);



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


[Lldb-commits] [lldb] b6e148f - [lldb] Shorten "DWARF Extensions supported by LLDB" in the docs

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

Author: Jonas Devlieghere
Date: 2023-08-18T15:48:19-07:00
New Revision: b6e148f02ca8c9b3d32914c2abafc773b9727223

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

LOG: [lldb] Shorten "DWARF Extensions supported by LLDB" in the docs

Shorten "DWARF Extensions supported by LLDB" to just "DWARF Extension".

Added: 


Modified: 
lldb/docs/resources/extensions.rst

Removed: 




diff  --git a/lldb/docs/resources/extensions.rst 
b/lldb/docs/resources/extensions.rst
index 3c73326dfa2bf9..30bd6d5c6b8da9 100644
--- a/lldb/docs/resources/extensions.rst
+++ b/lldb/docs/resources/extensions.rst
@@ -1,5 +1,5 @@
-DWARF Extensions supported by LLDB
-==
+DWARF Extensions
+
 
 LLDB supports some DWARF extensions produced by Clang.
 
@@ -66,9 +66,9 @@ M.pcm
  DW_AT_name "A"
  DW_TAG_member
DW_AT_name "x"
-   
+
 A.c
-   
+
 ::
 
A a;
@@ -90,7 +90,7 @@ A.o
DW_TAG_compile_unit
  DW_AT_GNU_dwo_id  (0xabcdef)
  DW_AT_GNU_dwo_name("M.pcm")
-   
+
 The debug info inside a ``.pcm`` file may recursively reference
 further external types that are defined in other ``.pcm`` files. Clang
 generates external references (and debug info inside the modules) for



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


[Lldb-commits] [PATCH] D158312: [debugserver] align received mach exception data before accessing it as array of uint64_t's, fix UB sanitizer failure

2023-08-18 Thread Jason Molenda 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 rG1a2122e9e9d1: Align mach exception data before accessing it 
(authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158312

Files:
  lldb/tools/debugserver/source/MacOSX/MachException.cpp


Index: lldb/tools/debugserver/source/MacOSX/MachException.cpp
===
--- lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -95,13 +95,20 @@
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
+std::vector exc_datas;
+uint64_t tmp;
+for (unsigned i = 0; i < exc_data_count; ++i) {
+  // Perform an unaligned copy.
+  memcpy(, _data[i], sizeof(uint64_t));
+  exc_datas.push_back(tmp);
+}
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
"0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
"0x%llx })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
+   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
+   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();


Index: lldb/tools/debugserver/source/MacOSX/MachException.cpp
===
--- lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -95,13 +95,20 @@
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
+std::vector exc_datas;
+uint64_t tmp;
+for (unsigned i = 0; i < exc_data_count; ++i) {
+  // Perform an unaligned copy.
+  memcpy(, _data[i], sizeof(uint64_t));
+  exc_datas.push_back(tmp);
+}
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
"0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
"0x%llx })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
+   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
+   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1a2122e - Align mach exception data before accessing it

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

Author: Jason Molenda
Date: 2023-08-18T15:34:13-07:00
New Revision: 1a2122e9e9d1d495fdf337a4a9445b61ca56df6f

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

LOG: Align mach exception data before accessing it

The mach exception data may not be doubleword aligned when we receive
it.  We use memcpy to align it later in this method when we save
the data, but for printing the value at the top, we need to do the
same or ubsan can trigger when LOG_EXCEPTIONS is enabled in
debugserver.

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

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachException.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
index e760a3ef9faae3..eab4cdfc8b775d 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -95,13 +95,20 @@ catch_mach_exception_raise(mach_port_t exc_port, 
mach_port_t thread_port,
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
+std::vector exc_datas;
+uint64_t tmp;
+for (unsigned i = 0; i < exc_data_count; ++i) {
+  // Perform an unaligned copy.
+  memcpy(, _data[i], sizeof(uint64_t));
+  exc_datas.push_back(tmp);
+}
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
"0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
"0x%llx })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
+   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
+   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();



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


[Lldb-commits] [lldb] ef70f5c - Revert "Align mach exception data before accessing it"

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

Author: Jason Molenda
Date: 2023-08-18T15:33:32-07:00
New Revision: ef70f5c6bbdadcaaeed6f028ed8eee8112b6543a

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

LOG: Revert "Align mach exception data before accessing it"

This reverts commit b10c2f846d936a98eecfcef1a90a754522282285.

Need to add the phabracator line to the message.

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachException.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
index eab4cdfc8b775d..e760a3ef9faae3 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -95,20 +95,13 @@ catch_mach_exception_raise(mach_port_t exc_port, 
mach_port_t thread_port,
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
-std::vector exc_datas;
-uint64_t tmp;
-for (unsigned i = 0; i < exc_data_count; ++i) {
-  // Perform an unaligned copy.
-  memcpy(, _data[i], sizeof(uint64_t));
-  exc_datas.push_back(tmp);
-}
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
"0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
"0x%llx })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
+   (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
+   (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();



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


[Lldb-commits] [lldb] b10c2f8 - Align mach exception data before accessing it

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

Author: Jason Molenda
Date: 2023-08-18T15:32:03-07:00
New Revision: b10c2f846d936a98eecfcef1a90a754522282285

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

LOG: Align mach exception data before accessing it

The mach exception data may not be doubleword aligned when we receive
it.  We use memcpy to align it later in this method when we save
the data, but for printing the value at the top, we need to do the
same or ubsan can trigger when LOG_EXCEPTIONS is enabled in
debugserver.

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachException.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp 
b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
index e760a3ef9faae3..eab4cdfc8b775d 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -95,13 +95,20 @@ catch_mach_exception_raise(mach_port_t exc_port, 
mach_port_t thread_port,
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
+std::vector exc_datas;
+uint64_t tmp;
+for (unsigned i = 0; i < exc_data_count; ++i) {
+  // Perform an unaligned copy.
+  memcpy(, _data[i], sizeof(uint64_t));
+  exc_datas.push_back(tmp);
+}
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
"0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
"0x%llx })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
+   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
+   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();



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


[Lldb-commits] [lldb] a3e6ac1 - [lldb/test] Fix TestSaveCrashlog.py following changes in eef5eadbe617

2023-08-18 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-08-18T23:29:40+01:00
New Revision: a3e6ac16ffc32e794da3f60150e903027f279f27

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

LOG: [lldb/test] Fix TestSaveCrashlog.py following changes in eef5eadbe617

This patch fixes TestSaveCrashlog.py failure introduces by eef5eadbe617,
which restricts the number of positional argument for the output file to 1.

I expected to get the output file but `argparse` puts the object in a
list (even by constrained to a singled positional argument).

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 5f6b84ff795eb8..efef43045f9c60 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1274,7 +1274,7 @@ def save_crashlog(debugger, command, exe_ctx, result, 
dict):
 return
 target = exe_ctx.target
 if target:
-out_file = options.output
+out_file = options.output[0]
 identifier = target.executable.basename
 process = exe_ctx.process
 if process:



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


[Lldb-commits] [PATCH] D158312: [debugserver] align received mach exception data before accessing it as array of uint64_t's, fix UB sanitizer failure

2023-08-18 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

I'm going to land this one sans-approval to fix the CI bot.  but I still think

  self.runCmd("settings set target.process.extra-startup-command 
QSetLogging:bitmask=LOG_PROCESS|LOG_EXCEPTIONS|LOG_RNB_PACKETS|LOG_STEP;")

shouldn't be in a test case, even though it helpfully found this ubsan issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158312

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


[Lldb-commits] [lldb] 8806b4f - Get LLDB building with clang-6 on Ubuntu 18.04

2023-08-18 Thread Evan Wilde via lldb-commits

Author: Evan Wilde
Date: 2023-08-18T14:59:38-07:00
New Revision: 8806b4f9b1fce4cb62e93b21fd9c9cc5a45317e3

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

LOG: Get LLDB building with clang-6 on Ubuntu 18.04

This patch gets clang-6 building with LLDB. The move from makeArrayRef
to deduction guides in 984b800a036fc61ccb129a8da7592af9cadc94dd is
tripping up clang-6 on Ubuntu 18.04.

Related to issue #64782.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index f9d95fc5d2a66d..65c7a0fabe90ff 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -2304,7 +2304,7 @@ 
GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote ) {
   // Build the reginfos response.
   StreamGDBRemote response;
 
-  RegisterValue reg_value(ArrayRef(m_reg_bytes, reg_size),
+  RegisterValue reg_value(ArrayRef(m_reg_bytes, reg_size),
   m_current_process->GetArchitecture().GetByteOrder());
   Status error = reg_context.WriteRegister(reg_info, reg_value);
   if (error.Fail()) {



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


[Lldb-commits] [PATCH] D158312: [debugserver] align received mach exception data before accessing it as array of uint64_t's, fix UB sanitizer failure

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

The mach exception data received in debugserver is not aligned to a doubleword 
boundary.  Most of these were fixed in 2017 by Vedant (`[MachException] Avoid 
alignment UB, NFC`) but there was a codepath when debugserver logging is 
enabled where we would still access the mach exception data without aligning it 
first.  This has been causing failures on the sanitizer greendragon bot for the 
last few days from Jim's change in  https://reviews.llvm.org/D157556  where he 
is enabling LOG_EXCEPTIONS debugserver logging unconditionally (this should 
prob be in a self.TraceOn() conditional, or maybe not even be in the test - it 
looks like a debug print he forgot to remove) in the new test_shadow_listener 
test.

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/

Simplest fix, and it's only done when LOG_EXCEPTIONS is enabled, is to align 
the data one-off for the logging.

I would have handed this to Jim to fix, but by the time I understood what the 
actual failure was, it was nothing to fix it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158312

Files:
  lldb/tools/debugserver/source/MacOSX/MachException.cpp


Index: lldb/tools/debugserver/source/MacOSX/MachException.cpp
===
--- lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -95,13 +95,20 @@
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
+std::vector exc_datas;
+uint64_t tmp;
+for (unsigned i = 0; i < exc_data_count; ++i) {
+  // Perform an unaligned copy.
+  memcpy(, _data[i], sizeof(uint64_t));
+  exc_datas.push_back(tmp);
+}
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
"0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
"0x%llx })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
+   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
+   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();


Index: lldb/tools/debugserver/source/MacOSX/MachException.cpp
===
--- lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -95,13 +95,20 @@
mach_exception_data_t exc_data,
mach_msg_type_number_t exc_data_count) {
   if (DNBLogCheckLogBit(LOG_EXCEPTIONS)) {
+std::vector exc_datas;
+uint64_t tmp;
+for (unsigned i = 0; i < exc_data_count; ++i) {
+  // Perform an unaligned copy.
+  memcpy(, _data[i], sizeof(uint64_t));
+  exc_datas.push_back(tmp);
+}
 DNBLogThreaded("::%s ( exc_port = 0x%4.4x, thd_port = 0x%4.4x, tsk_port = "
"0x%4.4x, exc_type = %d ( %s ), exc_data[%d] = { 0x%llx, "
"0x%llx })",
__FUNCTION__, exc_port, thread_port, task_port, exc_type,
MachException::Name(exc_type), exc_data_count,
-   (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
-   (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
+   (uint64_t)(exc_data_count > 0 ? exc_datas[0] : 0xBADDBADD),
+   (uint64_t)(exc_data_count > 1 ? exc_datas[1] : 0xBADDBADD));
   }
   g_message->exc_type = 0;
   g_message->exc_data.clear();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] cf6d16f - [lldb] Rename "Projects" to "Open Projects" in the docs

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

Author: Jonas Devlieghere
Date: 2023-08-18T14:18:21-07:00
New Revision: cf6d16f9b54a55ad771dc018592f112841d546ec

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

LOG: [lldb] Rename "Projects" to "Open Projects" in the docs

Make it more obvious that these are project ideas rather than say
ongoing projects.

Added: 


Modified: 
lldb/docs/resources/projects.rst

Removed: 




diff  --git a/lldb/docs/resources/projects.rst 
b/lldb/docs/resources/projects.rst
index 245654dd2ae449..eb2dcdcf8de270 100644
--- a/lldb/docs/resources/projects.rst
+++ b/lldb/docs/resources/projects.rst
@@ -1,5 +1,5 @@
-Projects
-
+Open Projects
+=
 
 The following is a mostly unordered set of the ideas for improvements to the
 LLDB debugger. Some are fairly deep, some would require less effort.



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


[Lldb-commits] [lldb] 12db5c2 - [lldb] Move Continuous Integration documentation under Testing

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

Author: Jonas Devlieghere
Date: 2023-08-18T14:05:38-07:00
New Revision: 12db5c29e13c36e9e51b32b57cf555be4c475b7c

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

LOG: [lldb] Move Continuous Integration documentation under Testing

The current "Continuous Integration" is pretty scarce. All we really
need is a link to buildbot and GreenDragon. Move this under testing.

Added: 


Modified: 
lldb/docs/.htaccess
lldb/docs/index.rst
lldb/docs/resources/test.rst

Removed: 
lldb/docs/resources/bots.rst



diff  --git a/lldb/docs/.htaccess b/lldb/docs/.htaccess
index 194c9ddc288828..f094bd6ebc783e 100644
--- a/lldb/docs/.htaccess
+++ b/lldb/docs/.htaccess
@@ -19,6 +19,7 @@ Redirect 301 /resources/architecture.html 
https://lldb.llvm.org/resources/overvi
 Redirect 301 /design/sbapi.html https://lldb.llvm.org/resources/sbapi.html
 Redirect 301 /design/overview.html 
https://lldb.llvm.org/resources/overview.html
 Redirect 301 /use/extensions.html 
https://lldb.llvm.org/resources/extensions.html
+Redirect 301 /resources/bots.html https://lldb.llvm.org/resources/test.html
 
 # Redirect old Python API to new Python API.
 Redirect 301 /python_reference/lldb-module.html 
https://lldb.llvm.org/python_api.html

diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index 0ae7c4ce1bac46..ae0261e15973da 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -148,7 +148,6 @@ interesting areas to contribute to lldb.
resources/build
resources/test
resources/fuzzing
-   resources/bots
resources/sbapi
resources/extensions
resources/caveats

diff  --git a/lldb/docs/resources/bots.rst b/lldb/docs/resources/bots.rst
deleted file mode 100644
index 635b3982c3d035..00
--- a/lldb/docs/resources/bots.rst
+++ /dev/null
@@ -1,31 +0,0 @@
-Continuous Integration
-==
-
-Buildbot
-
-
-LLVM Buildbot is the place where volunteers provide build machines. Everyone 
can
-`add a buildbot for LLDB `_.
-
-An overview of all LLDB builders can be found here:
-
-`https://lab.llvm.org/buildbot/#/builders?tags=lldb 
`_
-
-GreenDragon

-
-GreenDragon builds and tests LLDB on macOS. It has a `dedicated tab
-`_ for LLDB.
-
-* `lldb-cmake `_
-* `lldb-cmake-matrix 
`_
-* `lldb-cmake-standalone 
`_
-* `lldb-cmake-sanitized 
`_
-
-Documentation
--
-
-The documentation bot validates that the website builds correctly with Sphinx.
-It does not generate the website itself, which happens on a separate server.
-
-* `lldb-sphinx-docs `_

diff  --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst
index f91285980f2a87..1d96357b54960a 100644
--- a/lldb/docs/resources/test.rst
+++ b/lldb/docs/resources/test.rst
@@ -409,6 +409,21 @@ The 'child_send1.txt' file gets generated during the test 
run, so it makes sense
 TestSTTYBeforeAndAfter.py file to do the cleanup instead of artificially 
adding it as part of the default cleanup action which serves to
 cleanup those intermediate and a.out files.
 
+CI
+--
+
+LLVM Buildbot is the place where volunteers provide machines for building and
+testing. Everyone can `add a buildbot for LLDB 
`_.
+
+An overview of all LLDB builders can be found here:
+
+`https://lab.llvm.org/buildbot/#/builders?tags=lldb 
`_
+
+Building and testing for macOS uses a 
diff erent platform called GreenDragon. It
+has a dedicated tab for LLDB: `https://green.lab.llvm.org/green/view/LLDB/
+`_
+
+
 Running The Tests
 -
 



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


[Lldb-commits] [lldb] 8842d7e - [lldb] Add link to Discourse to the website

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

Author: Jonas Devlieghere
Date: 2023-08-18T13:52:22-07:00
New Revision: 8842d7eb8b5291009559b9859319cca7714d436d

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

LOG: [lldb] Add link to Discourse to the website

Added: 


Modified: 
lldb/docs/index.rst

Removed: 




diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index 8d6f68f13e27c5..0ae7c4ce1bac46 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -25,9 +25,8 @@ Tutorial `_. For 
users already familiar
 with GDB there is a cheat sheet listing common tasks and their LLDB equivalent
 in the `GDB to LLDB command map `_.
 
-There are also multiple resources on how to script LLDB using Python `Python
-Reference `_ is a great
-starting point for that.
+There are also multiple resources on how to script LLDB using Python:
+`use/python-reference`_ is a great starting point for that.
 
 Compiler Integration Benefits
 -
@@ -164,5 +163,6 @@ interesting areas to contribute to lldb.
 
Source Code 
Releases 
-   Code Reviews 
+   Discussion Forums 
Bug Reports 
+   Code Reviews 



___
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-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a44eedb842d: [lldb/crashlog] Skip non-crashed threads in 
batch mode (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D157852?vs=549855=551615#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157852

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -949,6 +949,7 @@
 self.thread.reason += (
 " (%s)" % 
self.crashlog.thread_exception_data
 )
+self.thread.crashed = True
 if self.app_specific_backtrace:
 self.crashlog.backtraces.append(self.thread)
 else:
@@ -1437,6 +1438,10 @@
 print()
 
 for thread in crash_log.threads:
+if options.crashed_only and not (
+thread.crashed or thread.app_specific_backtrace
+):
+continue
 thread.dump_symbolicated(crash_log, options)
 print()
 


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -949,6 +949,7 @@
 self.thread.reason += (
 " (%s)" % self.crashlog.thread_exception_data
 )
+self.thread.crashed = True
 if self.app_specific_backtrace:
 self.crashlog.backtraces.append(self.thread)
 else:
@@ -1437,6 +1438,10 @@
 print()
 
 for thread in crash_log.threads:
+if options.crashed_only and not (
+thread.crashed or thread.app_specific_backtrace
+):
+continue
 thread.dump_symbolicated(crash_log, options)
 print()
 
___
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-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c4f0d81f47c: [lldb/crashlog] Add support for Last Exception 
Backtrace (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D157851?vs=549854=551613#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157851

Files:
  lldb/examples/python/crashlog.py
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/leb.txt
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test
@@ -0,0 +1,52 @@
+# REQUIRES: python, native && target-aarch64 && system-darwin
+
+# RUN: mkdir -p %t.dir
+# RUN: yaml2obj %S/Inputs/application_specific_info/asi.yaml > %t.dir/asi
+# RUN: %lldb -o 'command script import lldb.macosx.crashlog' \
+# RUN: -o 'crashlog -a -i -t %t.dir/asi %S/Inputs/application_specific_info/leb.txt' \
+# RUN: -o "thread list" -o "bt all" 2>&1 | FileCheck %s
+
+# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
+
+# CHECK: (lldb) process status --verbose
+# CHECK-NEXT: Process 96535 stopped
+# CHECK-NEXT: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
+# CHECK-NEXT: frame #0: 0x0001a08c7224{{.*}}[artificial]
+# CHECK: Extended Crash Information:
+# CHECK:   Application Specific Information:
+# CHECK-NEXT: CoreFoundation: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 10 beyond bounds [0 .. 3]'
+# CHECK-NEXT: libc++abi.dylib: terminating with uncaught exception of type NSException
+# CHECK-NEXT: libsystem_c.dylib: abort() called
+
+
+# CHECK: (lldb) thread backtrace --extended true
+# CHECK: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
+# CHECK-NEXT:   * frame #0: 0x0001a08c7224{{.*}}[artificial]
+# CHECK-NEXT: frame #1: 0x0001a08fdceb{{.*}}[artificial]
+# CHECK-NEXT: frame #2: 0x0001a08372c7{{.*}}[artificial]
+# CHECK-NEXT: frame #3: 0x0001a08b7b17{{.*}}[artificial]
+# CHECK-NEXT: frame #4: 0x0001a08a7a0b{{.*}}[artificial]
+# CHECK-NEXT: frame #5: 0x0001a05ab763{{.*}}[artificial]
+# CHECK-NEXT: frame #6: 0x0001a08b6eb3{{.*}}[artificial]
+# CHECK-NEXT: frame #7: 0x0001a08b9c2b{{.*}}[artificial]
+# CHECK-NEXT: frame #8: 0x0001a08b9bd7{{.*}}[artificial]
+# CHECK-NEXT: frame #9: 0x0001a05a3007{{.*}}[artificial]
+# CHECK-NEXT: frame #10: 0x0001a0b3dcc3{{.*}}[artificial]
+# CHECK-NEXT: frame #11: 0x0001a0b46af3{{.*}}[artificial]
+# CHECK-NEXT: frame #12: 0x0001a09a12a3{{.*}}[artificial]
+# CHECK-NEXT: frame #13: 0x0001047e3ecf asi`main{{.*}}[artificial]
+# CHECK-NEXT: frame #14: 0x0001a05d3e4f{{.*}}[artificial]
+
+# CHECK:   thread #4294967295: tid = 0x0001, 0x0001a0a5840c{{.*}}, queue = 'Application Specific Backtrace'
+# CHECK-NEXT: frame #0: 0x0001a0a5840c{{.*}}
+# CHECK-NEXT: frame #1: 0x0001a05a2ea7{{.*}}
+# CHECK-NEXT: frame #2: 0x0001a0b3dcc3{{.*}}
+# CHECK-NEXT: frame #3: 0x0001a0b46af3{{.*}}
+# CHECK-NEXT: frame #4: 0x0001a09a12a3{{.*}}
+# CHECK-NEXT: frame #5: 0x0001047e3ecf asi`main{{.*}}
+# CHECK-NEXT: frame #6: 0x0001a05d3e4f
+
+
+# CHECK: (lldb) thread list
+# CHECK-NEXT: Process 96535 stopped
+# CHECK-NEXT: * thread #1: tid = 0x1af8f3, 0x0001a08c7224{{.*}}, queue = 'com.apple.main-thread', stop reason = EXC_CRASH (code=0, subcode=0x0)
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
@@ -37,7 +37,6 @@
   "asi" : {"CoreFoundation":["*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** __boundsFail: index 10 beyond bounds [0 .. 3]'"],"libsystem_c.dylib":["abort() called"],"libc++abi.dylib":["terminating with uncaught exception of type NSException"]},
   "asiBacktraces" : ["0   CoreFoundation  0x0001a0a58418 __exceptionPreprocess + 176\n1   libobjc.A.dylib 0x0001a05a2ea8 objc_exception_throw + 60\n2   CoreFoundation  0x0001a0b3dcc4 

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

2023-08-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG21a597c31cb8: [lldb/crashlog] Fix module loading for crashed 
thread behaviour (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157850

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1590,10 +1590,10 @@
 arg_parser.add_argument(
 "--crashed-only",
 "-c",
-action="store_true",
+action=argparse.BooleanOptionalAction,
 dest="crashed_only",
 help="only symbolicate the crashed thread",
-default=False,
+default=True,
 )
 arg_parser.add_argument(
 "--disasm-depth",


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -1590,10 +1590,10 @@
 arg_parser.add_argument(
 "--crashed-only",
 "-c",
-action="store_true",
+action=argparse.BooleanOptionalAction,
 dest="crashed_only",
 help="only symbolicate the crashed thread",
-default=False,
+default=True,
 )
 arg_parser.add_argument(
 "--disasm-depth",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D157849: [lldb/crashlog] Replace deprecated optparse by argparse (NFC)

2023-08-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeef5eadbe617: [lldb/crashlog] Replace deprecated optparse by 
argparse (NFC) (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157849

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test
@@ -2,8 +2,10 @@
 
 # CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
 
-# CHECK: Usage: crashlog [options]  [FILE ...]
+# CHECK: usage: crashlog [options]  [FILE ...]
 # CHECK: Symbolicate one or more darwin crash log files to provide source file and line
-# CHECK: Options:
+# CHECK: positional arguments:
+# CHECK-NEXT: FILE  crash report(s) to symbolicate (default: None)
+# CHECK: options:
 # CHECK:  -h, --helpshow this help message and exit
 
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -27,11 +27,11 @@
 # --
 
 import abc
+import argparse
 import concurrent.futures
 import contextlib
 import datetime
 import json
-import optparse
 import os
 import platform
 import plistlib
@@ -1234,12 +1234,20 @@
 
 
 def save_crashlog(debugger, command, exe_ctx, result, dict):
-usage = "usage: %prog [options] "
+usage = "save_crashlog [options] "
 description = """Export the state of current target into a crashlog file"""
-parser = optparse.OptionParser(
-description=description, prog="save_crashlog", usage=usage
+parser = argparse.ArgumentParser(
+description=description,
+prog="save_crashlog",
+formatter_class=argparse.ArgumentDefaultsHelpFormatter,
 )
-parser.add_option(
+parser.add_argument(
+"output",
+metavar="output-file",
+type=argparse.FileType("w", encoding="utf-8"),
+nargs=1,
+)
+parser.add_argument(
 "-v",
 "--verbose",
 action="store_true",
@@ -1248,21 +1256,13 @@
 default=False,
 )
 try:
-(options, args) = parser.parse_args(shlex.split(command))
-except:
-result.PutCString("error: invalid options")
-return
-if len(args) != 1:
-result.PutCString(
-"error: invalid arguments, a single output file is the only valid argument"
-)
-return
-out_file = open(args[0], "w", encoding="utf-8")
-if not out_file:
-result.PutCString("error: failed to open file '%s' for writing...", args[0])
+options = parser.parse_args(shlex.split(command))
+except Exception as e:
+result.SetError(str(e))
 return
 target = exe_ctx.target
 if target:
+out_file = options.output
 identifier = target.executable.basename
 process = exe_ctx.process
 if process:
@@ -1352,7 +1352,7 @@
 )
 out_file.close()
 else:
-result.PutCString("error: invalid target")
+result.SetError("invalid target")
 
 
 class Symbolicate:
@@ -1366,8 +1366,8 @@
 return "Symbolicate one or more darwin crash log files."
 
 def get_long_help(self):
-option_parser = CrashLogOptionParser()
-return option_parser.format_help()
+arg_parser = CrashLogOptionParser()
+return arg_parser.format_help()
 
 
 def SymbolicateCrashLog(crash_log, options):
@@ -1523,11 +1523,22 @@
 def CreateSymbolicateCrashLogOptions(
 command_name, description, add_interactive_options
 ):
-usage = "usage: %prog [options]  [FILE ...]"
-option_parser = optparse.OptionParser(
-description=description, prog="crashlog", usage=usage
+usage = "crashlog [options]  [FILE ...]"
+arg_parser = argparse.ArgumentParser(
+description=description,
+prog="crashlog",
+usage=usage,
+formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+)
+arg_parser.add_argument(
+"reports",
+metavar="FILE",
+type=str,
+nargs="*",
+help="crash report(s) to symbolicate",
 )
-option_parser.add_option(
+
+arg_parser.add_argument(
 "--version",
 "-V",
 dest="version",
@@ -1535,7 +1546,7 @@
 help="Show crashlog version",
 default=False,
 )
-option_parser.add_option(
+arg_parser.add_argument(
 "--verbose",
 "-v",
 action="store_true",
@@ -1543,7 +1554,7 @@
 help="display verbose debug 

[Lldb-commits] [lldb] 9a44eed - [lldb/crashlog] Skip non-crashed threads in batch mode

2023-08-18 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-08-18T20:50:39+01:00
New Revision: 9a44eedb842d03b0e4d24f8dcc57a49e1a9cc1ac

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

LOG: [lldb/crashlog] Skip non-crashed threads in batch mode

When using the `crashlog` command in batch mode, most users only care
about the crashed thread and end up having to scroll past all the
non-crashed threads, which is not a good user experience.

Now that `-c|--crashed-only` is set by default, we should also apply
that behavior for batch mode: Only the crashed thread and "Application
Specific Backtrace" threads will be shown to the user in batch mode.

The user will still have the ability to show all the threads if they use
`--no-crashed-only` which will parse the symbols from the report, or
with `-a|--load-all-images` which will fetch binaries and debug info
from the build record and symbolicate every thread.

rdar://106329893

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 080062be5374dc..5f6b84ff795eb8 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -949,6 +949,7 @@ def parse(self):
 self.thread.reason += (
 " (%s)" % 
self.crashlog.thread_exception_data
 )
+self.thread.crashed = True
 if self.app_specific_backtrace:
 self.crashlog.backtraces.append(self.thread)
 else:
@@ -1437,6 +1438,10 @@ def add_module(image, target, obj_dir):
 print()
 
 for thread in crash_log.threads:
+if options.crashed_only and not (
+thread.crashed or thread.app_specific_backtrace
+):
+continue
 thread.dump_symbolicated(crash_log, options)
 print()
 



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


[Lldb-commits] [lldb] 4c4f0d8 - [lldb/crashlog] Add support for Last Exception Backtrace

2023-08-18 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-08-18T20:50:39+01:00
New Revision: 4c4f0d81f47cf9ad785dc2ea323ec2f0aedb72df

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

LOG: [lldb/crashlog] Add support for Last Exception Backtrace

This patch adds support to the "Last Exception Backtrace" to the
`crashlog` command.

This metadata is homologous to the "Application Specific Backtrace",
however the format is closer to a regular stack frame.

Since the thread that "contains" the "Last Exception Backtrace" doesn't
really exist, this information is displayed when requesting an extended
backtrace of the crashed thread, similarly to the "Application Specific
Backtrace".

To achieve that, this patch includes some refactors and fixes to the
existing "Application Specific Backtrace" handling.

rdar://113046509

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

Signed-off-by: Med Ismail Bennani 

Added: 

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/leb.txt

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/last_exception_backtrace_crashlog.test

Modified: 
lldb/examples/python/crashlog.py
lldb/examples/python/scripted_process/crashlog_scripted_process.py

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 10e89b10fbb1df..080062be5374dc 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -586,10 +586,15 @@ def parse(self):
 self.parse_threads(self.data["threads"])
 if "asi" in self.data:
 self.crashlog.asi = self.data["asi"]
+# FIXME: With the current design, we can either show the ASI or 
Last
+# Exception Backtrace, not both. Is there a situation where we 
would
+# like to show both ?
 if "asiBacktraces" in self.data:
 self.parse_app_specific_backtraces(self.data["asiBacktraces"])
 if "lastExceptionBacktrace" in self.data:
-self.crashlog.asb = self.data["lastExceptionBacktrace"]
+self.parse_last_exception_backtraces(
+self.data["lastExceptionBacktrace"]
+)
 self.parse_errors(self.data)
 thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
 reason = self.parse_crash_reason(self.data["exception"])
@@ -792,11 +797,22 @@ def parse_asi_backtrace(self, thread, bt):
 return True
 
 def parse_app_specific_backtraces(self, json_app_specific_bts):
-for idx, backtrace in enumerate(json_app_specific_bts):
-thread = self.crashlog.Thread(idx, True, 
self.crashlog.process_arch)
-thread.queue = "Application Specific Backtrace"
-if self.parse_asi_backtrace(thread, backtrace):
-self.crashlog.threads.append(thread)
+thread = self.crashlog.Thread(
+len(self.crashlog.threads), True, self.crashlog.process_arch
+)
+thread.queue = "Application Specific Backtrace"
+if self.parse_asi_backtrace(thread, json_app_specific_bts[0]):
+self.crashlog.threads.append(thread)
+else:
+print("error: Couldn't parse Application Specific Backtrace.")
+
+def parse_last_exception_backtraces(self, json_last_exc_bts):
+thread = self.crashlog.Thread(
+len(self.crashlog.threads), True, self.crashlog.process_arch
+)
+thread.queue = "Last Exception Backtrace"
+self.parse_frames(thread, json_last_exc_bts)
+self.crashlog.threads.append(thread)
 
 def parse_thread_registers(self, json_thread_state, prefix=None):
 registers = dict()

diff  --git 
a/lldb/examples/python/scripted_process/crashlog_scripted_process.py 
b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
index f15fd4ca3f1faa..43f767de138cd5 100644
--- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -178,7 +178,7 @@ def __init__(self, process, args, crashlog_thread):
 self.idx = self.backing_thread.index
 self.tid = self.backing_thread.id
 if self.backing_thread.app_specific_backtrace:
-self.name = "Application Specific Backtrace - " + str(self.idx)
+self.name = "Application Specific Backtrace"
 else:
 self.name = self.backing_thread.name
 self.queue = self.backing_thread.queue

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/application_specific_info/asi.txt
 

[Lldb-commits] [lldb] 21a597c - [lldb/crashlog] Fix module loading for crashed thread behaviour

2023-08-18 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-08-18T20:50:39+01:00
New Revision: 21a597c31cb8ad03e18a293c73ecd7c498387ef8

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

LOG: [lldb/crashlog] Fix module loading for crashed thread behaviour

Before 27f27d15f, the `crashlog` command would always load images even
if `-a` or `-c` was not set by the user.

Since that change, images are loaded only when one of these 2 flags are
set, otherwise, we fallback to parsing the symbols from the report and
load them into a `SymbolFileJSON`.

Although that makes it way faster than pulling binaries and debug
symbols from build records, that cause a degraded experience since none
of our users are used to set these 2 flags. For instance, that would
symbolicate the backtraces, however the users wouldn't see sources.

To address that change of behavior, this patch changes the default value
for the `-c|--crash-only` flag to `true`. On the other hand, thanks to
the move to `argparse`, we introduced a new `--no-only-crashed` flag
that will let the user force skipping loading any images, relying only
on the `SymbolFileJSON`.

This gives the users a good compromise since they would be able to see
sources for the crashed thread if they're available, otherwise, they'll
only get a symbolicated backtrace.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index f91400a6c36051..216eb7c56690cc 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1590,10 +1590,10 @@ def CreateSymbolicateCrashLogOptions(
 arg_parser.add_argument(
 "--crashed-only",
 "-c",
-action="store_true",
+action=argparse.BooleanOptionalAction,
 dest="crashed_only",
 help="only symbolicate the crashed thread",
-default=False,
+default=True,
 )
 arg_parser.add_argument(
 "--disasm-depth",



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


[Lldb-commits] [lldb] 3054a0c - [lldb/crashlog] Remove dead code (NFC)

2023-08-18 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-08-18T20:50:39+01:00
New Revision: 3054a0c4bc50856156f26b528895ddcfba4210fa

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

LOG: [lldb/crashlog] Remove dead code (NFC)

This patch cleans up the crashlog.py script and removes dead code.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 216eb7c56690cc..10e89b10fbb1df 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -1228,11 +1228,6 @@ def parse_instructions(self, line):
 pass
 
 
-def usage():
-print("Usage: lldb-symbolicate.py [-n name] executable-image")
-sys.exit(0)
-
-
 def save_crashlog(debugger, command, exe_ctx, result, dict):
 usage = "save_crashlog [options] "
 description = """Export the state of current target into a crashlog file"""



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


[Lldb-commits] [lldb] eef5ead - [lldb/crashlog] Replace deprecated optparse by argparse (NFC)

2023-08-18 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-08-18T20:50:39+01:00
New Revision: eef5eadbe617a9530d982a9ea3cfc284d2a52858

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

LOG: [lldb/crashlog] Replace deprecated optparse by argparse (NFC)

This patch replace the deprecated `optparse` module used for the
`crashlog`& `save_crashlog` commands with the new `argparse` from the
python standard library. This provides many benefits such as showing the
default values for each option in the help description, but also greatly
improve the handling of position arguments.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no-args.test

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 1413c702f9163f..f91400a6c36051 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -27,11 +27,11 @@
 # --
 
 import abc
+import argparse
 import concurrent.futures
 import contextlib
 import datetime
 import json
-import optparse
 import os
 import platform
 import plistlib
@@ -1234,12 +1234,20 @@ def usage():
 
 
 def save_crashlog(debugger, command, exe_ctx, result, dict):
-usage = "usage: %prog [options] "
+usage = "save_crashlog [options] "
 description = """Export the state of current target into a crashlog file"""
-parser = optparse.OptionParser(
-description=description, prog="save_crashlog", usage=usage
+parser = argparse.ArgumentParser(
+description=description,
+prog="save_crashlog",
+formatter_class=argparse.ArgumentDefaultsHelpFormatter,
 )
-parser.add_option(
+parser.add_argument(
+"output",
+metavar="output-file",
+type=argparse.FileType("w", encoding="utf-8"),
+nargs=1,
+)
+parser.add_argument(
 "-v",
 "--verbose",
 action="store_true",
@@ -1248,21 +1256,13 @@ def save_crashlog(debugger, command, exe_ctx, result, 
dict):
 default=False,
 )
 try:
-(options, args) = parser.parse_args(shlex.split(command))
-except:
-result.PutCString("error: invalid options")
-return
-if len(args) != 1:
-result.PutCString(
-"error: invalid arguments, a single output file is the only valid 
argument"
-)
-return
-out_file = open(args[0], "w", encoding="utf-8")
-if not out_file:
-result.PutCString("error: failed to open file '%s' for writing...", 
args[0])
+options = parser.parse_args(shlex.split(command))
+except Exception as e:
+result.SetError(str(e))
 return
 target = exe_ctx.target
 if target:
+out_file = options.output
 identifier = target.executable.basename
 process = exe_ctx.process
 if process:
@@ -1352,7 +1352,7 @@ def save_crashlog(debugger, command, exe_ctx, result, 
dict):
 )
 out_file.close()
 else:
-result.PutCString("error: invalid target")
+result.SetError("invalid target")
 
 
 class Symbolicate:
@@ -1366,8 +1366,8 @@ def get_short_help(self):
 return "Symbolicate one or more darwin crash log files."
 
 def get_long_help(self):
-option_parser = CrashLogOptionParser()
-return option_parser.format_help()
+arg_parser = CrashLogOptionParser()
+return arg_parser.format_help()
 
 
 def SymbolicateCrashLog(crash_log, options):
@@ -1523,11 +1523,22 @@ def synchronous(debugger):
 def CreateSymbolicateCrashLogOptions(
 command_name, description, add_interactive_options
 ):
-usage = "usage: %prog [options]  [FILE ...]"
-option_parser = optparse.OptionParser(
-description=description, prog="crashlog", usage=usage
+usage = "crashlog [options]  [FILE ...]"
+arg_parser = argparse.ArgumentParser(
+description=description,
+prog="crashlog",
+usage=usage,
+formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+)
+arg_parser.add_argument(
+"reports",
+metavar="FILE",
+type=str,
+nargs="*",
+help="crash report(s) to symbolicate",
 )
-option_parser.add_option(
+
+arg_parser.add_argument(
 "--version",
 "-V",
 dest="version",
@@ -1535,7 +1546,7 @@ def CreateSymbolicateCrashLogOptions(
 help="Show crashlog version",
 default=False,
 )
-option_parser.add_option(
+arg_parser.add_argument(
 "--verbose",
 "-v",
 action="store_true",
@@ -1543,7 +1554,7 @@ 

[Lldb-commits] [lldb] 7602641 - [lldb/crashlog] Add test for 8f75c4d01eff3c65d7ae40bfd05582de7dffa590 (NFC)

2023-08-18 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-08-18T20:50:39+01:00
New Revision: 7602641d7bf96b727e1739e2f68db1cadc27324a

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

LOG: [lldb/crashlog] Add test for 8f75c4d01eff3c65d7ae40bfd05582de7dffa590 (NFC)

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash

Removed: 




diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
index 6bd5c109fc4ba7..0c7b99673187d7 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/interactive_crashlog/multithread-test.crash
@@ -87,6 +87,7 @@ Binary Images:
0x19cc3e000 -0x19cc76feb libsystem_kernel.dylib (*) 
 /usr/lib/system/libsystem_kernel.dylib
0x19cc77000 -0x19cc83ffb libsystem_pthread.dylib (*) 
 /usr/lib/system/libsystem_pthread.dylib
0x19cbbf000 -0x19cc25ff3 libc++.1.dylib (*) 
 /usr/lib/libc++.1.dylib
+
0x100ec4000 -0x100ec7fff multithread-test (*) 
 /Users/USER/*/multithread-test
0x2230f3000 -0x22317be4b dyld (*) 
 /usr/lib/dyld
0x19cb3e000 -0x19cbbefff libsystem_c.dylib (*) 
 /usr/lib/system/libsystem_c.dylib



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


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

2023-08-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3e3880e370c8: [lldb] Simplify the LLDB website structure 
(authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D158023?vs=550791=551578#toc

Repository:
  rG LLVM Github Monorepo

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

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/extensions.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
  lldb/docs/use/extensions.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)   |
-+---++-+---++--+
-| Remote debugging  | YES (lldb-server)  | YES (lldb-server)   | YES (debugserver) | YES (lldb-server)  | NO   |
-+---++-+---++--+
-| Disassembly   | YES| YES | YES   | YES| YES  |
-+---++-+---++--+
-| Expression evaluation | YES (known issues) | YES (known 

[Lldb-commits] [lldb] 3e3880e - [lldb] Simplify the LLDB website structure

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

Author: Jonas Devlieghere
Date: 2023-08-18T11:20:20-07:00
New Revision: 3e3880e370c8aed629750fe94a9f98f4cb6160cc

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

LOG: [lldb] Simplify the LLDB website structure

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", "Scripting LLDB" and "Developing LLDB".

  - The majority of the "project" pages were eliminated. The projects
page was moved under "Developing LLDB". The releases page was
replaced with a link under "External links". The other pages (goals,
features and status) 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.

  - "USE & EXTENSION" was renamed to "Using LLDB". Besides that, this
section remained mostly unchanged. The exception are the Python
pages which were moved under "Scripting 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.

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

Added: 
lldb/docs/resources/extensions.rst
lldb/docs/resources/overview.rst
lldb/docs/resources/projects.rst
lldb/docs/resources/sbapi.rst

Modified: 
lldb/docs/.htaccess
lldb/docs/index.rst
lldb/docs/resources/fuzzing.rst

Removed: 
lldb/docs/design/overview.rst
lldb/docs/design/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
lldb/docs/use/extensions.rst



diff  --git a/lldb/docs/.htaccess b/lldb/docs/.htaccess
index 91b25fb504f106..194c9ddc288828 100644
--- a/lldb/docs/.htaccess
+++ b/lldb/docs/.htaccess
@@ -15,9 +15,10 @@ Redirect 301 /varformats.html 
https://lldb.llvm.org/use/variable.html
 Redirect 301 /resources/source.html 
https://lldb.llvm.org/resources/contributing.html
 Redirect 301 /resources/download.html 
https://lldb.llvm.org/status/releases.html
 Redirect 301 /use/architecture.html 
https://lldb.llvm.org/resources/architecture.html
-Redirect 301 /resources/architecture.html 
https://lldb.llvm.org/design/overview.html
-Redirect 301 /resources/reproducers.html 
https://lldb.llvm.org/design/reproducers.html
-Redirect 301 /resources/sbapi.html https://lldb.llvm.org/design/sbapi.html
+Redirect 301 /resources/architecture.html 
https://lldb.llvm.org/resources/overview.html
+Redirect 301 /design/sbapi.html https://lldb.llvm.org/resources/sbapi.html
+Redirect 301 /design/overview.html 
https://lldb.llvm.org/resources/overview.html
+Redirect 301 /use/extensions.html 
https://lldb.llvm.org/resources/extensions.html
 
 # Redirect old Python API to new Python API.
 Redirect 301 /python_reference/lldb-module.html 
https://lldb.llvm.org/python_api.html

diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index ad09129ee32b37..8d6f68f13e27c5 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -107,24 +107,13 @@ messages are automatically sent to the `lldb-commits
 `__ mailing list, and
 this is also the preferred mailing list for patch submissions.
 
-See the :doc:`Projects page ` if you are looking for some
+See the :doc:`Projects page ` if you are looking for some
 interesting areas to contribute to lldb.
 
 .. toctree::
:hidden:
:maxdepth: 1
-   :caption: Project
-
-   status/goals
-   status/features
-   status/status
-   status/projects
-   status/releases
-
-.. toctree::
-   :hidden:
-   :maxdepth: 1
-   :caption: Use & Extension
+   :caption: Using LLDB
 
use/tutorial
use/map
@@ -132,46 +121,41 @@ interesting areas to contribute to lldb.
use/variable
use/symbolication
use/symbols
-   use/extensions
-   use/python
-   use/python-reference
use/remote
use/qemu-testing
use/intel_pt
use/ondemand
use/troubleshooting
use/links
+   Man Page 
 
 .. toctree::
:hidden:
:maxdepth: 1
-   :caption: Development
-
-   resources/contributing
-   resources/build
-   resources/test
-   resources/fuzzing
-   resources/bots
-   resources/caveats
-
+   :caption: Scripting LLDB
 
-.. toctree::
-   :hidden:
-   :maxdepth: 1
-   :caption: Design
+   use/python
+   use/python-reference
+   Python API 
 
-   design/overview
-   design/sbapi
 
 .. toctree::
:hidden:
:maxdepth: 1
-   :caption: Reference
+   :caption: Developing LLDB
 
-   Public Python API 
+   resources/overview
+   resources/contributing
+   resources/build
+   resources/test
+   

[Lldb-commits] [PATCH] D158085: [LLDB][Docs] Update cross compilation docs and examples

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

In D158085#4598601 , @DavidSpickett 
wrote:

>> It could be useful to also document some other interesting cross-compilation 
>> options like CMAKE_TOOLCHAIN_FILE
>
> So this is the way CMake prefers you to do it, but I don't really understand 
> the best practice so I'll leave it out for now. We have plenty of caches that 
> directly set the system and processor name in llvm already, so I am in good 
> (/not as good as could be) company.

IMO it's usually the safest/most sustainable way to maintain cross-compilation 
jobs. CMake documents all of the intricacies with cross-compiling to other 
platforms here on their page documenting cmake toolchains: 
https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
I don't think we need to include all the intricacies, but it might be nice to 
maintain a link to the cmake documentation so people can self-service a bit 
when they encounter issues.

>> or mention the use of CMake caches, but if you're unfamiliar or aren't 
>> comfortable listing those that's ok too.
>
> This seems like a general tip so I'm not sure it belongs here, beyond the 
> fact that you might have 99 options to get a cross build, but want to tweak 
> just one on top. Again, bit of a generic tip.
>
> As to adding a cache file, one thing the Github poster mentioned is that if 
> you don't set `LLVM_NATIVE_TOOL_DIR` we appear to compile the host tools for 
> you now. So I'd like to land this as is, then I'll look into that and see if 
> it can be even simpler.

Sounds good to me. Thanks for working on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158085

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


[Lldb-commits] [PATCH] D158085: [LLDB][Docs] Update cross compilation docs and examples

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

Will land Monday unless there are other comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158085

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


[Lldb-commits] [PATCH] D158085: [LLDB][Docs] Update cross compilation docs and examples

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

Use `` so people have to think about what that should be for 
their build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158085

Files:
  lldb/docs/resources/build.rst

Index: lldb/docs/resources/build.rst
===
--- lldb/docs/resources/build.rst
+++ lldb/docs/resources/build.rst
@@ -36,6 +36,8 @@
 * `Python `_
 * `SWIG `_ 4 or later.
 
+.. _Optional Dependencies:
+
 Optional Dependencies
 *
 
@@ -458,37 +460,56 @@
   -DLLDB_ENABLE_CURSES=0
   -DLLVM_ENABLE_TERMINFO=0
 
+(see :ref:`Optional Dependencies` for more)
+
 In this case you, will often not need anything other than the standard C and
 C++ libraries.
 
+If you find that CMake is finding a version of an optional dependency that
+for whatever reason doesn't work, consider simply disabling it if you don't
+know that you need it.
+
 Once all of the dependencies are in place, it's just a matter of configuring
 the build system with the locations and arguments of all the necessary tools.
 The most important cmake options here are:
 
-* ``CMAKE_CROSSCOMPILING`` : Set to 1 to enable cross-compilation.
-* ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
-  for libraries. You may need to set this to your architecture triple if you do
-  not specify all your include and library paths explicitly.
+* ``CMAKE_SYSTEM_NAME`` and ``CMAKE_SYSTEM_PROCESSOR``: This tells CMake what
+  the build target is and from this it will infer that you are cross compiling.
 * ``CMAKE_C_COMPILER``, ``CMAKE_CXX_COMPILER`` : C and C++ compilers for the
-  target architecture
+  target architecture.
 * ``CMAKE_C_FLAGS``, ``CMAKE_CXX_FLAGS`` : The flags for the C and C++ target
-  compilers. You may need to specify the exact target cpu and abi besides the
+  compilers. You may need to specify the exact target cpu and ABI besides the
   include paths for the target headers.
 * ``CMAKE_EXE_LINKER_FLAGS`` : The flags to be passed to the linker. Usually
   just a list of library search paths referencing the target libraries.
-* ``LLVM_TABLEGEN``, ``CLANG_TABLEGEN`` : Paths to llvm-tblgen and clang-tblgen
-  for the host architecture. If you already have built clang for the host, you
-  can point these variables to the executables in your build directory. If not,
-  you will need to build the llvm-tblgen and clang-tblgen host targets at
-  least.
 * ``LLVM_HOST_TRIPLE`` : The triple of the system that lldb (or lldb-server)
   will run on. Not setting this (or setting it incorrectly) can cause a lot of
   issues with remote debugging as a lot of the choices lldb makes depend on the
   triple reported by the remote platform.
+* ``LLVM_NATIVE_TOOL_DIR`` : Is a path to the llvm tools compiled for the host.
+  Any tool that must be run on the host during a cross build will be configured
+  from this path, so you do not need to set them all individually. If you are
+  doing a host build just for the purpose of a cross build, you will need it
+  to include at least ``llvm-tblgen``, ``clang-tblgen`` and ``lldb-tblgen``.
+  Please be aware that that list may grow over time.
+* ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
+  for libraries. You may need to set this to your architecture triple if you do
+  not specify all your include and library paths explicitly.
+
+To find the possible values of the ``CMAKE_*`` options, please refer to the
+CMake documentation.
 
 You can of course also specify the usual cmake options like
 ``CMAKE_BUILD_TYPE``, etc.
 
+For testing, you may want to set one of:
+
+* ``LLDB_TEST_COMPILER`` : The compiler used to build programs used
+  in the test suite. If you are also building clang, this will be used
+  but if you want to test remotely from the host, you should choose the
+  cross compiler you are using for the cross build.
+* ``LLDB_INCLUDE_TESTS=0`` : To disable the tests completely.
+
 Example 1: Cross-compiling for linux arm64 on Ubuntu host
 *
 
@@ -499,15 +520,19 @@
 
 ::
 
-  -DCMAKE_CROSSCOMPILING=1 \
-  -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-  -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
-  -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
-  -DLLVM_TABLEGEN=/bin/llvm-tblgen \
-  -DCLANG_TABLEGEN=/bin/clang-tblgen \
-  -DLLDB_ENABLE_PYTHON=0 \
-  -DLLDB_ENABLE_LIBEDIT=0 \
-  -DLLDB_ENABLE_CURSES=0
+  cmake /llvm-project/llvm -G Ninja \
+-DCMAKE_BUILD_TYPE=Release \
+-DLLVM_ENABLE_PROJECTS="clang;lld;lldb" \
+-DCMAKE_SYSTEM_NAME=Linux \
+-DCMAKE_SYSTEM_PROCESSOR=AArch64 \
+-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
+-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
+-DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
+

[Lldb-commits] [PATCH] D158085: [LLDB][Docs] Update cross compilation docs and examples

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

> It could be useful to also document some other interesting cross-compilation 
> options like CMAKE_TOOLCHAIN_FILE

So this is the way CMake prefers you to do it, but I don't really understand 
the best practice so I'll leave it out for now. We have plenty of caches that 
directly set the system and processor name in llvm already, so I am in good 
(/not as good as could be) company.

> or mention the use of CMake caches, but if you're unfamiliar or aren't 
> comfortable listing those that's ok too.

This seems like a general tip so I'm not sure it belongs here, beyond the fact 
that you might have 99 options to get a cross build, but want to tweak just one 
on top. Again, bit of a generic tip.

As to adding a cache file, one thing the Github poster mentioned is that if you 
don't set `LLVM_NATIVE_TOOL_DIR` we appear to compile the host tools for you 
now. So I'd like to land this as is, then I'll look into that and see if it can 
be even simpler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158085

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


[Lldb-commits] [PATCH] D158085: [LLDB][Docs] Update cross compilation docs and examples

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

Address feedback from Github issue:

- Include the whole command not just the additions.
- Note how to find the possible values of CMAKE_SYSTEM_*.
- Add a note about testing and setting the test compiler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158085

Files:
  lldb/docs/resources/build.rst

Index: lldb/docs/resources/build.rst
===
--- lldb/docs/resources/build.rst
+++ lldb/docs/resources/build.rst
@@ -36,6 +36,8 @@
 * `Python `_
 * `SWIG `_ 4 or later.
 
+.. _Optional Dependencies:
+
 Optional Dependencies
 *
 
@@ -458,37 +460,56 @@
   -DLLDB_ENABLE_CURSES=0
   -DLLVM_ENABLE_TERMINFO=0
 
+(see :ref:`Optional Dependencies` for more)
+
 In this case you, will often not need anything other than the standard C and
 C++ libraries.
 
+If you find that CMake is finding a version of an optional dependency that
+for whatever reason doesn't work, consider simply disabling it if you don't
+know that you need it.
+
 Once all of the dependencies are in place, it's just a matter of configuring
 the build system with the locations and arguments of all the necessary tools.
 The most important cmake options here are:
 
-* ``CMAKE_CROSSCOMPILING`` : Set to 1 to enable cross-compilation.
-* ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
-  for libraries. You may need to set this to your architecture triple if you do
-  not specify all your include and library paths explicitly.
+* ``CMAKE_SYSTEM_NAME`` and ``CMAKE_SYSTEM_PROCESSOR``: This tells CMake what
+  the build target is and from this it will infer that you are cross compiling.
 * ``CMAKE_C_COMPILER``, ``CMAKE_CXX_COMPILER`` : C and C++ compilers for the
-  target architecture
+  target architecture.
 * ``CMAKE_C_FLAGS``, ``CMAKE_CXX_FLAGS`` : The flags for the C and C++ target
-  compilers. You may need to specify the exact target cpu and abi besides the
+  compilers. You may need to specify the exact target cpu and ABI besides the
   include paths for the target headers.
 * ``CMAKE_EXE_LINKER_FLAGS`` : The flags to be passed to the linker. Usually
   just a list of library search paths referencing the target libraries.
-* ``LLVM_TABLEGEN``, ``CLANG_TABLEGEN`` : Paths to llvm-tblgen and clang-tblgen
-  for the host architecture. If you already have built clang for the host, you
-  can point these variables to the executables in your build directory. If not,
-  you will need to build the llvm-tblgen and clang-tblgen host targets at
-  least.
 * ``LLVM_HOST_TRIPLE`` : The triple of the system that lldb (or lldb-server)
   will run on. Not setting this (or setting it incorrectly) can cause a lot of
   issues with remote debugging as a lot of the choices lldb makes depend on the
   triple reported by the remote platform.
+* ``LLVM_NATIVE_TOOL_DIR`` : Is a path to the llvm tools compiled for the host.
+  Any tool that must be run on the host during a cross build will be configured
+  from this path, so you do not need to set them all individually. If you are
+  doing a host build just for the purpose of a cross build, you will need it
+  to include at least ``llvm-tblgen``, ``clang-tblgen`` and ``lldb-tblgen``.
+  Please be aware that that list may grow over time.
+* ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
+  for libraries. You may need to set this to your architecture triple if you do
+  not specify all your include and library paths explicitly.
+
+To find the possible values of the ``CMAKE_*`` options, please refer to the
+CMake documentation.
 
 You can of course also specify the usual cmake options like
 ``CMAKE_BUILD_TYPE``, etc.
 
+For testing, you may want to set one of:
+
+* ``LLDB_TEST_COMPILER`` : The compiler used to build programs used
+  in the test suite. If you are also building clang, this will be used
+  but if you want to test remotely from the host, you should choose the
+  cross compiler you are using for the cross build.
+* ``LLDB_INCLUDE_TESTS=0`` : To disable the tests completely.
+
 Example 1: Cross-compiling for linux arm64 on Ubuntu host
 *
 
@@ -499,15 +520,19 @@
 
 ::
 
-  -DCMAKE_CROSSCOMPILING=1 \
-  -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-  -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
-  -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
-  -DLLVM_TABLEGEN=/bin/llvm-tblgen \
-  -DCLANG_TABLEGEN=/bin/clang-tblgen \
-  -DLLDB_ENABLE_PYTHON=0 \
-  -DLLDB_ENABLE_LIBEDIT=0 \
-  -DLLDB_ENABLE_CURSES=0
+  cmake ../llvm-project/llvm -G Ninja \
+-DCMAKE_BUILD_TYPE=Release \
+-DLLVM_ENABLE_PROJECTS="clang;lld;lldb" \
+-DCMAKE_SYSTEM_NAME=Linux \
+-DCMAKE_SYSTEM_PROCESSOR=AArch64 \
+

[Lldb-commits] [PATCH] D158205: [lldb] Fix performance regression after adding GNUstep ObjC runtime

2023-08-18 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

Backport for 17.x release: https://github.com/llvm/llvm-project/issues/64800


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158205

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


[Lldb-commits] [PATCH] D158205: [lldb] Fix performance regression after adding GNUstep ObjC runtime

2023-08-18 Thread Stefan Gränitz via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf2eb838309d: [lldb] Fix performance regression after adding 
GNUstep ObjC runtime (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158205

Files:
  
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp


Index: 
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
===
--- 
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
+++ 
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
@@ -37,6 +37,33 @@
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
+static bool CanModuleBeGNUstepObjCLibrary(const ModuleSP _sp,
+  const llvm::Triple ) {
+  if (!module_sp)
+return false;
+  const FileSpec _file_spec = module_sp->GetFileSpec();
+  if (!module_file_spec)
+return false;
+  llvm::StringRef filename = module_file_spec.GetFilename().GetStringRef();
+  if (TT.isOSBinFormatELF())
+return filename.starts_with("libobjc.so");
+  if (TT.isOSWindows())
+return filename == "objc.dll";
+  return false;
+}
+
+static bool ScanForGNUstepObjCLibraryCandidate(const ModuleList ,
+   const llvm::Triple ) {
+  std::lock_guard guard(modules.GetMutex());
+  size_t num_modules = modules.GetSize();
+  for (size_t i = 0; i < num_modules; i++) {
+auto mod = modules.GetModuleAtIndex(i);
+if (CanModuleBeGNUstepObjCLibrary(mod, TT))
+  return true;
+  }
+  return false;
+}
+
 LanguageRuntime *GNUstepObjCRuntime::CreateInstance(Process *process,
 LanguageType language) {
   if (language != eLanguageTypeObjC)
@@ -50,6 +77,9 @@
 return nullptr;
 
   const ModuleList  = target.GetImages();
+  if (!ScanForGNUstepObjCLibraryCandidate(images, TT))
+return nullptr;
+
   if (TT.isOSBinFormatELF()) {
 SymbolContextList eh_pers;
 RegularExpression regex("__gnustep_objc[x]*_personality_v[0-9]+");
@@ -176,18 +206,8 @@
 }
 
 bool GNUstepObjCRuntime::IsModuleObjCLibrary(const ModuleSP _sp) {
-  if (!module_sp)
-return false;
-  const FileSpec _file_spec = module_sp->GetFileSpec();
-  if (!module_file_spec)
-return false;
-  llvm::StringRef filename = module_file_spec.GetFilename().GetStringRef();
   const llvm::Triple  = GetTargetRef().GetArchitecture().GetTriple();
-  if (TT.isOSBinFormatELF())
-return filename.starts_with("libobjc.so");
-  if (TT.isOSWindows())
-return filename == "objc.dll";
-  return false;
+  return CanModuleBeGNUstepObjCLibrary(module_sp, TT);
 }
 
 bool GNUstepObjCRuntime::ReadObjCLibrary(const ModuleSP _sp) {


Index: lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
@@ -37,6 +37,33 @@
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
+static bool CanModuleBeGNUstepObjCLibrary(const ModuleSP _sp,
+  const llvm::Triple ) {
+  if (!module_sp)
+return false;
+  const FileSpec _file_spec = module_sp->GetFileSpec();
+  if (!module_file_spec)
+return false;
+  llvm::StringRef filename = module_file_spec.GetFilename().GetStringRef();
+  if (TT.isOSBinFormatELF())
+return filename.starts_with("libobjc.so");
+  if (TT.isOSWindows())
+return filename == "objc.dll";
+  return false;
+}
+
+static bool ScanForGNUstepObjCLibraryCandidate(const ModuleList ,
+   const llvm::Triple ) {
+  std::lock_guard guard(modules.GetMutex());
+  size_t num_modules = modules.GetSize();
+  for (size_t i = 0; i < num_modules; i++) {
+auto mod = modules.GetModuleAtIndex(i);
+if (CanModuleBeGNUstepObjCLibrary(mod, TT))
+  return true;
+  }
+  return false;
+}
+
 LanguageRuntime *GNUstepObjCRuntime::CreateInstance(Process *process,
 LanguageType language) {
   if (language != eLanguageTypeObjC)
@@ -50,6 +77,9 @@
 return nullptr;
 
   const ModuleList  = target.GetImages();
+  if (!ScanForGNUstepObjCLibraryCandidate(images, TT))
+return nullptr;
+
   if (TT.isOSBinFormatELF()) {
 SymbolContextList eh_pers;
 RegularExpression regex("__gnustep_objc[x]*_personality_v[0-9]+");
@@ -176,18 +206,8 @@
 }
 
 bool GNUstepObjCRuntime::IsModuleObjCLibrary(const ModuleSP _sp) {
-  if (!module_sp)
-return false;
-  const FileSpec _file_spec = module_sp->GetFileSpec();
-  if (!module_file_spec)
-return false;
-  llvm::StringRef filename = 

[Lldb-commits] [lldb] af2eb83 - [lldb] Fix performance regression after adding GNUstep ObjC runtime

2023-08-18 Thread Stefan Gränitz via lldb-commits

Author: Stefan Gränitz
Date: 2023-08-18T13:57:50+02:00
New Revision: af2eb838309d88f046d34bca6055f1de6078fa3b

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

LOG: [lldb] Fix performance regression after adding GNUstep ObjC runtime

We added support for the GNUstep ObjC runtime in 0b6264738f3d. In order to 
check if the target process uses
GNUstep we run an expensive symbol lookup in `CreateInstance()`. This turned 
out to cause a heavy performance
regression for non-GNUstep inferiors.

This patch puts a cheaper check in front, so that the vast majority of requests 
should return early. This
should fix the symptom for the moment. The conceptual question remains: Why 
does `LanguageRuntime::FindPlugin`
invoke `create_callback` for each available runtime unconditionally in every 
`Process::ModulesDidLoad`?

Reviewed By: jasonmolenda, jingham, bulbazord

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

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
index fb2656ef1385e7..39b3e816f4becf 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp
@@ -37,6 +37,33 @@ void GNUstepObjCRuntime::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
+static bool CanModuleBeGNUstepObjCLibrary(const ModuleSP _sp,
+  const llvm::Triple ) {
+  if (!module_sp)
+return false;
+  const FileSpec _file_spec = module_sp->GetFileSpec();
+  if (!module_file_spec)
+return false;
+  llvm::StringRef filename = module_file_spec.GetFilename().GetStringRef();
+  if (TT.isOSBinFormatELF())
+return filename.starts_with("libobjc.so");
+  if (TT.isOSWindows())
+return filename == "objc.dll";
+  return false;
+}
+
+static bool ScanForGNUstepObjCLibraryCandidate(const ModuleList ,
+   const llvm::Triple ) {
+  std::lock_guard guard(modules.GetMutex());
+  size_t num_modules = modules.GetSize();
+  for (size_t i = 0; i < num_modules; i++) {
+auto mod = modules.GetModuleAtIndex(i);
+if (CanModuleBeGNUstepObjCLibrary(mod, TT))
+  return true;
+  }
+  return false;
+}
+
 LanguageRuntime *GNUstepObjCRuntime::CreateInstance(Process *process,
 LanguageType language) {
   if (language != eLanguageTypeObjC)
@@ -50,6 +77,9 @@ LanguageRuntime *GNUstepObjCRuntime::CreateInstance(Process 
*process,
 return nullptr;
 
   const ModuleList  = target.GetImages();
+  if (!ScanForGNUstepObjCLibraryCandidate(images, TT))
+return nullptr;
+
   if (TT.isOSBinFormatELF()) {
 SymbolContextList eh_pers;
 RegularExpression regex("__gnustep_objc[x]*_personality_v[0-9]+");
@@ -176,18 +206,8 @@ void 
GNUstepObjCRuntime::UpdateISAToDescriptorMapIfNeeded() {
 }
 
 bool GNUstepObjCRuntime::IsModuleObjCLibrary(const ModuleSP _sp) {
-  if (!module_sp)
-return false;
-  const FileSpec _file_spec = module_sp->GetFileSpec();
-  if (!module_file_spec)
-return false;
-  llvm::StringRef filename = module_file_spec.GetFilename().GetStringRef();
   const llvm::Triple  = GetTargetRef().GetArchitecture().GetTriple();
-  if (TT.isOSBinFormatELF())
-return filename.starts_with("libobjc.so");
-  if (TT.isOSWindows())
-return filename == "objc.dll";
-  return false;
+  return CanModuleBeGNUstepObjCLibrary(module_sp, TT);
 }
 
 bool GNUstepObjCRuntime::ReadObjCLibrary(const ModuleSP _sp) {



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


[Lldb-commits] [PATCH] D158205: [lldb] Fix performance regression after adding GNUstep ObjC runtime

2023-08-18 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

Thanks for your quick feedback everyone!

> Did you have the chance to verify that it improves performance of non-objc 
> inferiors on Linux?

Nope, but the author of the bug report confirmed that this fixes the issue for 
them. Since I will be on vacation starting tomorrow, I propose to land this as 
is.

> We'll also probably want to make sure this gets back ported into llvm-17.

Yes, let me check.




Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/GNUstepObjCRuntime.cpp:49
+  if (TT.isOSBinFormatELF())
+return filename.starts_with("libobjc.so");
+  if (TT.isOSWindows())

jingham wrote:
> bulbazord wrote:
> > jasonmolenda wrote:
> > > theraven wrote:
> > > > This is a bit unfortunate.  I know some downstream users that link the 
> > > > Objective-C runtime components into another .so, so we can't really 
> > > > rely on the name.  It would be nice if there were some mechanism for 
> > > > the user to specify the name of the runtime if they're using something 
> > > > non-standard.
> > > If the runtime was merged in to a library with a known name, we could 
> > > search for a name in the runtime (if it were the Darwin runtime, 
> > > objc_msgSend would be a good candidate) in the list of libraries that 
> > > might have the runtime in them.  Doing a "search for a symbol name in any 
> > > binary that is added" is expensive, doing "search these three solibs for 
> > > a symbol if they're loaded" is much less expensive, doing "is a solib 
> > > with this name loaded" is free.
> > That would be a nice follow-up!
> If we can't know up front what library contains the runtime, we could also 
> add a setting for the library name, so we don't have to guess.
Thanks for the note. Sounds reasonable. However, this is out of scope for the 
regression fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158205

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


[Lldb-commits] [PATCH] D158251: [lldb] Propagate destination type's byte order to memory writer

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

Seems like a noble goal but I don't have the experience to review.

I will just ask, how do you plan to test this? I guess this change is in 
response to an issue you hit, that's a good place to start from.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158251

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


[Lldb-commits] [PATCH] D158209: [lldb] Change UnixSignals::GetSignalAsCString to GetSignalAsStringRef

2023-08-18 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett 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/D158209/new/

https://reviews.llvm.org/D158209

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


[Lldb-commits] [PATCH] D158251: [lldb] Propagate destination type's byte order to memory writer

2023-08-18 Thread Kamlesh Kumar via Phabricator via lldb-commits
kkcode0 updated this revision to Diff 551398.
kkcode0 added a comment.

typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158251

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/include/lldb/Target/Process.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2111,14 +2111,14 @@
 }
 
 size_t Process::WriteMemoryPrivate(addr_t addr, const void *buf, size_t size,
-   Status ) {
+   Status , ByteOrder byte_order) {
   size_t bytes_written = 0;
   const uint8_t *bytes = (const uint8_t *)buf;
 
   while (bytes_written < size) {
 const size_t curr_size = size - bytes_written;
 const size_t curr_bytes_written = DoWriteMemory(
-addr + bytes_written, bytes + bytes_written, curr_size, error);
+addr + bytes_written, bytes + bytes_written, curr_size, error, byte_order);
 bytes_written += curr_bytes_written;
 if (curr_bytes_written == curr_size || curr_bytes_written == 0)
   break;
@@ -2127,7 +2127,7 @@
 }
 
 size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size,
-Status ) {
+Status , ByteOrder byte_order) {
   if (ABISP abi_sp = GetABI())
 addr = abi_sp->FixAnyAddress(addr);
 
@@ -2146,17 +2146,17 @@
 
   BreakpointSiteList bp_sites_in_range;
   if (!m_breakpoint_site_list.FindInRange(addr, addr + size, bp_sites_in_range))
-return WriteMemoryPrivate(addr, buf, size, error);
+return WriteMemoryPrivate(addr, buf, size, error, byte_order);
 
   // No breakpoint sites overlap
   if (bp_sites_in_range.IsEmpty())
-return WriteMemoryPrivate(addr, buf, size, error);
+return WriteMemoryPrivate(addr, buf, size, error, byte_order);
 
   const uint8_t *ubuf = (const uint8_t *)buf;
   uint64_t bytes_written = 0;
 
   bp_sites_in_range.ForEach([this, addr, size, _written, ,
- ](BreakpointSite *bp) -> void {
+ , byte_order](BreakpointSite *bp) -> void {
 if (error.Fail())
   return;
 
@@ -2182,7 +2182,7 @@
   // write to memory
   size_t curr_size = intersect_addr - curr_addr;
   size_t curr_bytes_written =
-  WriteMemoryPrivate(curr_addr, ubuf + bytes_written, curr_size, error);
+  WriteMemoryPrivate(curr_addr, ubuf + bytes_written, curr_size, error, byte_order);
   bytes_written += curr_bytes_written;
   if (curr_bytes_written != curr_size) {
 // We weren't able to write all of the requested bytes, we are
@@ -2203,13 +2203,14 @@
   if (bytes_written < size)
 bytes_written +=
 WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written,
-   size - bytes_written, error);
+   size - bytes_written, error, byte_order);
 
   return bytes_written;
 }
 
 size_t Process::WriteScalarToMemory(addr_t addr, const Scalar ,
-size_t byte_size, Status ) {
+size_t byte_size, Status ,
+ByteOrder byte_order) {
   if (byte_size == UINT32_MAX)
 byte_size = scalar.GetByteSize();
   if (byte_size > 0) {
@@ -2217,7 +2218,7 @@
 const size_t mem_size =
 scalar.GetAsMemoryData(buf, byte_size, GetByteOrder(), error);
 if (mem_size > 0)
-  return WriteMemory(addr, buf, mem_size, error);
+  return WriteMemory(addr, buf, mem_size, error, byte_order);
 else
   error.SetErrorString("failed to get scalar as memory data");
   } else {
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -584,6 +584,13 @@
   return lldb::eEncodingInvalid;
 }
 
+lldb::ByteOrder CompilerType::GetByteOrder() const {
+  if (IsValid())
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->GetByteOrder(m_type);
+  return endian::InlHostByteOrder();
+}
+
 lldb::Format CompilerType::GetFormat() const {
   if (IsValid())
 if (auto type_system_sp = GetTypeSystem())
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- 

[Lldb-commits] [PATCH] D158251: [lldb] Propagate destination type's byte order to memory writer

2023-08-18 Thread Kamlesh Kumar via Phabricator via lldb-commits
kkcode0 updated this revision to Diff 551397.
kkcode0 added a comment.
Herald added a subscriber: JDevlieghere.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158251

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/include/lldb/Target/Process.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2111,14 +2111,14 @@
 }
 
 size_t Process::WriteMemoryPrivate(addr_t addr, const void *buf, size_t size,
-   Status ) {
+   Status , ByteOrder byte_order) {
   size_t bytes_written = 0;
   const uint8_t *bytes = (const uint8_t *)buf;
 
   while (bytes_written < size) {
 const size_t curr_size = size - bytes_written;
 const size_t curr_bytes_written = DoWriteMemory(
-addr + bytes_written, bytes + bytes_written, curr_size, error);
+addr + bytes_written, bytes + bytes_written, curr_size, error, byte_order);
 bytes_written += curr_bytes_written;
 if (curr_bytes_written == curr_size || curr_bytes_written == 0)
   break;
@@ -2127,7 +2127,7 @@
 }
 
 size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size,
-Status ) {
+Status , ByteOrder byte_order) {
   if (ABISP abi_sp = GetABI())
 addr = abi_sp->FixAnyAddress(addr);
 
@@ -2146,17 +2146,17 @@
 
   BreakpointSiteList bp_sites_in_range;
   if (!m_breakpoint_site_list.FindInRange(addr, addr + size, bp_sites_in_range))
-return WriteMemoryPrivate(addr, buf, size, error);
+return WriteMemoryPrivate(addr, buf, size, error, byte_order);
 
   // No breakpoint sites overlap
   if (bp_sites_in_range.IsEmpty())
-return WriteMemoryPrivate(addr, buf, size, error);
+return WriteMemoryPrivate(addr, buf, size, error, byte_order);
 
   const uint8_t *ubuf = (const uint8_t *)buf;
   uint64_t bytes_written = 0;
 
   bp_sites_in_range.ForEach([this, addr, size, _written, ,
- ](BreakpointSite *bp) -> void {
+ , byte_order](BreakpointSite *bp) -> void {
 if (error.Fail())
   return;
 
@@ -2182,7 +2182,7 @@
   // write to memory
   size_t curr_size = intersect_addr - curr_addr;
   size_t curr_bytes_written =
-  WriteMemoryPrivate(curr_addr, ubuf + bytes_written, curr_size, error);
+  WriteMemoryPrivate(curr_addr, ubuf + bytes_written, curr_size, error, byte_order);
   bytes_written += curr_bytes_written;
   if (curr_bytes_written != curr_size) {
 // We weren't able to write all of the requested bytes, we are
@@ -2203,13 +2203,14 @@
   if (bytes_written < size)
 bytes_written +=
 WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written,
-   size - bytes_written, error);
+   size - bytes_written, error, byte_order);
 
   return bytes_written;
 }
 
 size_t Process::WriteScalarToMemory(addr_t addr, const Scalar ,
-size_t byte_size, Status ) {
+size_t byte_size, Status ,
+ByteOrder byte_order) {
   if (byte_size == UINT32_MAX)
 byte_size = scalar.GetByteSize();
   if (byte_size > 0) {
@@ -2217,7 +2218,7 @@
 const size_t mem_size =
 scalar.GetAsMemoryData(buf, byte_size, GetByteOrder(), error);
 if (mem_size > 0)
-  return WriteMemory(addr, buf, mem_size, error);
+  return WriteMemory(addr, buf, mem_size, error, byte_order);
 else
   error.SetErrorString("failed to get scalar as memory data");
   } else {
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -584,6 +584,13 @@
   return lldb::eEncodingInvalid;
 }
 
+lldb::ByteOrder CompilerType::GetByteOrder() const {
+  if (IsValid())
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->GetByteOrder(m_type);
+  return endian::InlHostByteOrder();
+}
+
 lldb::Format CompilerType::GetFormat() const {
   if (IsValid())
 if (auto type_system_sp = GetTypeSystem())
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

[Lldb-commits] [PATCH] D158251: [lldb] Propagate destination type's byte order to memory writer

2023-08-18 Thread Kamlesh Kumar via Phabricator via lldb-commits
kkcode0 created this revision.
Herald added a project: All.
kkcode0 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When a compiler attaches endianess to type, debugger should honor that when 
writing to variables of that variable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158251

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/include/lldb/Target/Process.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2111,14 +2111,14 @@
 }
 
 size_t Process::WriteMemoryPrivate(addr_t addr, const void *buf, size_t size,
-   Status ) {
+   Status , ByteOrder byte_order) {
   size_t bytes_written = 0;
   const uint8_t *bytes = (const uint8_t *)buf;
 
   while (bytes_written < size) {
 const size_t curr_size = size - bytes_written;
 const size_t curr_bytes_written = DoWriteMemory(
-addr + bytes_written, bytes + bytes_written, curr_size, error);
+addr + bytes_written, bytes + bytes_written, curr_size, error, byte_order);
 bytes_written += curr_bytes_written;
 if (curr_bytes_written == curr_size || curr_bytes_written == 0)
   break;
@@ -2127,7 +2127,7 @@
 }
 
 size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size,
-Status ) {
+Status , ByteOrder byte_order) {
   if (ABISP abi_sp = GetABI())
 addr = abi_sp->FixAnyAddress(addr);
 
@@ -2146,17 +2146,17 @@
 
   BreakpointSiteList bp_sites_in_range;
   if (!m_breakpoint_site_list.FindInRange(addr, addr + size, bp_sites_in_range))
-return WriteMemoryPrivate(addr, buf, size, error);
+return WriteMemoryPrivate(addr, buf, size, error, byte_order);
 
   // No breakpoint sites overlap
   if (bp_sites_in_range.IsEmpty())
-return WriteMemoryPrivate(addr, buf, size, error);
+return WriteMemoryPrivate(addr, buf, size, error, byte_order);
 
   const uint8_t *ubuf = (const uint8_t *)buf;
   uint64_t bytes_written = 0;
 
   bp_sites_in_range.ForEach([this, addr, size, _written, ,
- ](BreakpointSite *bp) -> void {
+ , byte_order](BreakpointSite *bp) -> void {
 if (error.Fail())
   return;
 
@@ -2182,7 +2182,7 @@
   // write to memory
   size_t curr_size = intersect_addr - curr_addr;
   size_t curr_bytes_written =
-  WriteMemoryPrivate(curr_addr, ubuf + bytes_written, curr_size, error);
+  WriteMemoryPrivate(curr_addr, ubuf + bytes_written, curr_size, error, byte_order);
   bytes_written += curr_bytes_written;
   if (curr_bytes_written != curr_size) {
 // We weren't able to write all of the requested bytes, we are
@@ -2203,13 +2203,14 @@
   if (bytes_written < size)
 bytes_written +=
 WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written,
-   size - bytes_written, error);
+   size - bytes_written, error, byte_order);
 
   return bytes_written;
 }
 
 size_t Process::WriteScalarToMemory(addr_t addr, const Scalar ,
-size_t byte_size, Status ) {
+size_t byte_size, Status ,
+ByteOrder byte_order) {
   if (byte_size == UINT32_MAX)
 byte_size = scalar.GetByteSize();
   if (byte_size > 0) {
@@ -2217,7 +2218,7 @@
 const size_t mem_size =
 scalar.GetAsMemoryData(buf, byte_size, GetByteOrder(), error);
 if (mem_size > 0)
-  return WriteMemory(addr, buf, mem_size, error);
+  return WriteMemory(addr, buf, mem_size, error, byte_order);
 else
   error.SetErrorString("failed to get scalar as memory data");
   } else {
Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -584,6 +584,13 @@
   return lldb::eEncodingInvalid;
 }
 
+lldb::ByteOrder CompilerType::GetByteOrder() const {
+  if (IsValid())
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->GetByteOrder(m_type);
+  return endian::InlHostByteOrder();
+}
+
 lldb::Format CompilerType::GetFormat() const {
   if (IsValid())
 if (auto type_system_sp = GetTypeSystem())
Index: