[Lldb-commits] [lldb] 7dd76cc - [LLDB] Skip TestExitDuringExpression on aarch64/linux buildbot

2021-03-19 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2021-03-19T15:30:10+05:00
New Revision: 7dd76a02ee59588647f2d97f1b554c48f580

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

LOG: [LLDB] Skip TestExitDuringExpression on aarch64/linux buildbot

TestExitDuringExpression test_exit_before_one_thread_unwind fails
sporadically on both Arm and AArch64 linux buildbots.
This seems like a thread timing issue. I am marking it skip for now.

Added: 


Modified: 

lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py
 
b/lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py
index 4ee65c85e8f1..dafc0a967605 100644
--- 
a/lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py
+++ 
b/lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py
@@ -15,7 +15,7 @@ class TestExitDuringExpression(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 @skipIfWindows
-@skipIf(oslist=["linux"], archs=["arm"], bugnumber="llvm.org/pr48414")
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"], 
bugnumber="llvm.org/pr48414")
 @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48414")
 @expectedFailureNetBSD
 def test_exit_before_one_thread_unwind(self):



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


[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 331824.
mgorny marked 3 inline comments as done.
mgorny added a comment.

Switched `Extension` to bitmask-enum, fixed prototype and decl for 
`getPIDForTID` and switched server features into a virtual as suggested by 
@labath.


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

https://reviews.llvm.org/D98822

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/include/lldb/Host/linux/Host.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Host/linux/Host.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -201,6 +201,8 @@
 
   PacketResult Handle_g(StringExtractorGDBRemote &packet);
 
+  PacketResult Handle_qSupported_LLGS(StringExtractorGDBRemote &packet);
+
   void SetCurrentThreadID(lldb::tid_t tid);
 
   lldb::tid_t GetCurrentThreadID() const;
@@ -219,6 +221,9 @@
 
   static std::string XMLEncodeAttributeValue(llvm::StringRef value);
 
+  llvm::SmallVector
+  HandleFeatures(const llvm::ArrayRef client_features) override;
+
 private:
   llvm::Expected> BuildTargetXml();
 
@@ -255,6 +260,9 @@
   bool allow_any = false,
   bool allow_all = false);
 
+  // Call SetEnabledExtensions() with appropriate flags on the process.
+  void SetEnabledExtensions(NativeProcessProtocol& process);
+
   // For GDBRemoteCommunicationServerLLGS only
   GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) =
   delete;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -254,6 +254,8 @@
 m_debugged_process_up = std::move(*process_or);
   }
 
+  SetEnabledExtensions(*m_debugged_process_up);
+
   // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as
   // needed. llgs local-process debugging may specify PTY paths, which will
   // make these file actions non-null process launch -i/e/o will also make
@@ -321,6 +323,7 @@
 return status;
   }
   m_debugged_process_up = std::move(*process_or);
+  SetEnabledExtensions(*m_debugged_process_up);
 
   // Setup stdout/stderr mapping from inferior.
   auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
@@ -3703,3 +3706,29 @@
 
   return tid;
 }
+
+llvm::SmallVector
+GDBRemoteCommunicationServerLLGS::HandleFeatures(
+const llvm::ArrayRef client_features) {
+  auto ret =
+  GDBRemoteCommunicationServerCommon::HandleFeatures(client_features);
+  if (m_debugged_process_up)
+SetEnabledExtensions(*m_debugged_process_up);
+  return ret;
+}
+
+void GDBRemoteCommunicationServerLLGS::SetEnabledExtensions(
+NativeProcessProtocol &process) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  NativeProcessProtocol::Extension flags;
+  if (m_fork_events_supported)
+flags |= NativeProcessProtocol::Extension::fork;
+  if (m_vfork_events_supported)
+flags |= NativeProcessProtocol::Extension::vfork;
+
+  llvm::Error error = process.SetEnabledExtensions(flags);
+  if (error)
+LLDB_LOG_ERROR(log, std::move(error),
+   "Enabling protocol extensions failed: {0}");
+}
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
@@ -38,6 +38,8 @@
   uint32_t m_proc_infos_index;
   bool m_thread_suffix_supported;
   bool m_list_threads_in_stop_reply;
+  bool m_fork_events_supported;
+  bool m_vfork_events_supported;
 
   PacketResult Handle_A(StringExtractorGDBRemote &packet);
 
@@ -145,6 +147,11 @@
   virtual FileSpec FindModuleFile(const std::string &module_path,
   const ArchSpec &arch);
 
+  // Process client_features (qSupported) and return

[Lldb-commits] [PATCH] D96458: [LLDB] Add support for Arm64/Linux dynamic register sets

2021-03-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid updated this revision to Diff 331830.
omjavaid added a comment.

This update address review comments from @labath


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

https://reviews.llvm.org/D96458

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
  lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp

Index: lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -177,9 +177,8 @@
 
 switch (arch.GetMachine()) {
 case llvm::Triple::aarch64:
-  m_thread_reg_ctx_sp = std::make_shared(
-  *this, std::make_unique(arch),
-  m_gpregset_data, m_notes);
+  m_thread_reg_ctx_sp = RegisterContextCorePOSIX_arm64::Create(
+  *this, arch, m_gpregset_data, m_notes);
   break;
 case llvm::Triple::arm:
   m_thread_reg_ctx_sp = std::make_shared(
Index: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
+++ lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
@@ -18,11 +18,10 @@
 
 class RegisterContextCorePOSIX_arm64 : public RegisterContextPOSIX_arm64 {
 public:
-  RegisterContextCorePOSIX_arm64(
-  lldb_private::Thread &thread,
-  std::unique_ptr register_info,
-  const lldb_private::DataExtractor &gpregset,
-  llvm::ArrayRef notes);
+  static std::unique_ptr
+  Create(lldb_private::Thread &thread, const lldb_private::ArchSpec &arch,
+ const lldb_private::DataExtractor &gpregset,
+ llvm::ArrayRef notes);
 
   ~RegisterContextCorePOSIX_arm64() override;
 
@@ -39,6 +38,13 @@
   bool HardwareSingleStep(bool enable) override;
 
 protected:
+  RegisterContextCorePOSIX_arm64(
+  lldb_private::Thread &thread,
+  std::unique_ptr register_info,
+  const lldb_private::DataExtractor &gpregset,
+  const lldb_private::DataExtractor &sveregset,
+  llvm::ArrayRef notes);
+
   bool ReadGPR() override;
 
   bool ReadFPR() override;
Index: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
===
--- lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -17,10 +17,29 @@
 
 using namespace lldb_private;
 
+std::unique_ptr
+RegisterContextCorePOSIX_arm64::Create(Thread &thread, const ArchSpec &arch,
+   const DataExtractor &gpregset,
+   llvm::ArrayRef notes) {
+  DataExtractor sveregset =
+  getRegset(notes, arch.GetTriple(), AARCH64_SVE_Desc);
+
+  Flags opt_regsets = RegisterInfoPOSIX_arm64::eRegsetMaskDefault;
+  if (sveregset.GetByteSize() > sizeof(sve::user_sve_header))
+opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskSVE);
+  auto register_info_up =
+  std::make_unique(arch, opt_regsets);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_arm64(thread, std::move(register_info_up),
+ gpregset, sveregset, notes));
+}
+
 RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
 Thread &thread, std::unique_ptr register_info,
-const DataExtractor &gpregset, llvm::ArrayRef notes)
-: RegisterContextPOSIX_arm64(thread, std::move(register_info)) {
+const DataExtractor &gpregset, const DataExtractor &sveregset,
+llvm::ArrayRef notes)
+: RegisterContextPOSIX_arm64(thread, std::move(register_info)),
+  m_sveregset(sveregset) {
   m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
   gpregset.GetByteSize());
   m_gpr.SetData(m_gpr_buffer);
@@ -29,10 +48,6 @@
   m_fpregset = getRegset(
   notes, m_register_info_up->GetTargetArchitecture().GetTriple(), FPR_Desc);
 
-  m_sveregset =
-  getRegset(notes, m_register_info_up->GetTargetArchitecture().GetTriple(),
-AARCH64_SVE_Desc);
-
   ConfigureRegisterContext();
 }
 
@@ -70,15 +85,16 @@
  sve::ptrace_regs_sve)
   m_sve_state = SVEState::Full;
 
-if (sve::vl_valid(m_sve_vector_length))
-  m_register_info_up->ConfigureVectorRegisterInfos(
-  sve::vq_from_vl(m_sve_vector_length));
-else {
+if (!sve::vl_valid(m_sve_ve

[Lldb-commits] [PATCH] D96458: [LLDB] Add support for Arm64/Linux dynamic register sets

2021-03-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid updated this revision to Diff 331834.
omjavaid added a comment.

This update further cleans up and removes static functions that calculated 
m_register_info_p GetRegisterInfoPtr and m_register_info_count 
GetRegisterInfoCount


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

https://reviews.llvm.org/D96458

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
  lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
  lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp

Index: lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -177,9 +177,8 @@
 
 switch (arch.GetMachine()) {
 case llvm::Triple::aarch64:
-  m_thread_reg_ctx_sp = std::make_shared(
-  *this, std::make_unique(arch),
-  m_gpregset_data, m_notes);
+  m_thread_reg_ctx_sp = RegisterContextCorePOSIX_arm64::Create(
+  *this, arch, m_gpregset_data, m_notes);
   break;
 case llvm::Triple::arm:
   m_thread_reg_ctx_sp = std::make_shared(
Index: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
+++ lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
@@ -18,11 +18,10 @@
 
 class RegisterContextCorePOSIX_arm64 : public RegisterContextPOSIX_arm64 {
 public:
-  RegisterContextCorePOSIX_arm64(
-  lldb_private::Thread &thread,
-  std::unique_ptr register_info,
-  const lldb_private::DataExtractor &gpregset,
-  llvm::ArrayRef notes);
+  static std::unique_ptr
+  Create(lldb_private::Thread &thread, const lldb_private::ArchSpec &arch,
+ const lldb_private::DataExtractor &gpregset,
+ llvm::ArrayRef notes);
 
   ~RegisterContextCorePOSIX_arm64() override;
 
@@ -39,6 +38,13 @@
   bool HardwareSingleStep(bool enable) override;
 
 protected:
+  RegisterContextCorePOSIX_arm64(
+  lldb_private::Thread &thread,
+  std::unique_ptr register_info,
+  const lldb_private::DataExtractor &gpregset,
+  const lldb_private::DataExtractor &sveregset,
+  llvm::ArrayRef notes);
+
   bool ReadGPR() override;
 
   bool ReadFPR() override;
Index: lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
===
--- lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -17,10 +17,29 @@
 
 using namespace lldb_private;
 
+std::unique_ptr
+RegisterContextCorePOSIX_arm64::Create(Thread &thread, const ArchSpec &arch,
+   const DataExtractor &gpregset,
+   llvm::ArrayRef notes) {
+  DataExtractor sveregset =
+  getRegset(notes, arch.GetTriple(), AARCH64_SVE_Desc);
+
+  Flags opt_regsets = RegisterInfoPOSIX_arm64::eRegsetMaskDefault;
+  if (sveregset.GetByteSize() > sizeof(sve::user_sve_header))
+opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskSVE);
+  auto register_info_up =
+  std::make_unique(arch, opt_regsets);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_arm64(thread, std::move(register_info_up),
+ gpregset, sveregset, notes));
+}
+
 RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
 Thread &thread, std::unique_ptr register_info,
-const DataExtractor &gpregset, llvm::ArrayRef notes)
-: RegisterContextPOSIX_arm64(thread, std::move(register_info)) {
+const DataExtractor &gpregset, const DataExtractor &sveregset,
+llvm::ArrayRef notes)
+: RegisterContextPOSIX_arm64(thread, std::move(register_info)),
+  m_sveregset(sveregset) {
   m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
   gpregset.GetByteSize());
   m_gpr.SetData(m_gpr_buffer);
@@ -29,10 +48,6 @@
   m_fpregset = getRegset(
   notes, m_register_info_up->GetTargetArchitecture().GetTriple(), FPR_Desc);
 
-  m_sveregset =
-  getRegset(notes, m_register_info_up->GetTargetArchitecture().GetTriple(),
-AARCH64_SVE_Desc);
-
   ConfigureRegisterContext();
 }
 
@@ -70,15 +85,16 @@
  sve::ptrace_regs_sve)
   m_sve_state = SVEState::Full;
 
-if (sve::vl_valid(m_sve_vector_length))
-  m_register_info_up->ConfigureVec

[Lldb-commits] [PATCH] D96460: [LLDB] Arm64/Linux Add MTE and Pointer Authentication registers

2021-03-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid updated this revision to Diff 331835.
omjavaid added a comment.

Rebased after changes to parent D96458 


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

https://reviews.llvm.org/D96460

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h

Index: lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
@@ -470,6 +470,13 @@
 LLDB_INVALID_REGNUM, lldb_kind \
   }
 
+// Generates register kinds array for registers with only lldb kind
+#define KIND_ALL_INVALID   \
+  {\
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM   \
+  }
+
 // Generates register kinds array for vector registers
 #define GPR64_KIND(reg, generic_kind) MISC_KIND(reg, gpr, generic_kind)
 #define VREG_KIND(reg) MISC_KIND(reg, fpu, LLDB_INVALID_REGNUM)
@@ -526,6 +533,13 @@
 nullptr, 0 \
   }
 
+// Defines pointer authentication mask registers
+#define DEFINE_EXTENSION_REG(reg)  \
+  {\
+#reg, nullptr, 8, 0, lldb::eEncodingUint, lldb::eFormatHex,\
+KIND_ALL_INVALID, nullptr, nullptr, nullptr, 0 \
+  }
+
 static lldb_private::RegisterInfo g_register_infos_arm64_le[] = {
 // DEFINE_GPR64(name, GENERIC KIND)
 DEFINE_GPR64(x0, LLDB_REGNUM_GENERIC_ARG1),
@@ -772,7 +786,12 @@
 {DEFINE_DBG(wcr, 13)},
 {DEFINE_DBG(wcr, 14)},
 {DEFINE_DBG(wcr, 15)}
-// clang-format on
 };
+// clang-format on
+static lldb_private::RegisterInfo g_register_infos_pauth[] = {
+DEFINE_EXTENSION_REG(data_mask), DEFINE_EXTENSION_REG(code_mask)};
+
+static lldb_private::RegisterInfo g_register_infos_mte[] = {
+DEFINE_EXTENSION_REG(mte_ctrl)};
 
 #endif // DECLARE_REGISTER_INFOS_ARM64_STRUCT
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -26,6 +26,8 @@
   enum {
 eRegsetMaskDefault = 0,
 eRegsetMaskSVE = 1,
+eRegsetMaskPAuth = 2,
+eRegsetMaskMTE = 4,
 eRegsetMaskDynamic = ~1,
   };
 
@@ -94,6 +96,10 @@
 
   size_t GetRegisterSetFromRegisterIndex(uint32_t reg_index) const override;
 
+  void AddRegSetPAuth();
+
+  void AddRegSetMTE();
+
   uint32_t ConfigureVectorLength(uint32_t sve_vq);
 
   bool VectorSizeIsValid(uint32_t vq) {
@@ -108,12 +114,16 @@
   bool IsSVEZReg(unsigned reg) const;
   bool IsSVEPReg(unsigned reg) const;
   bool IsSVERegVG(unsigned reg) const;
+  bool IsPAuthReg(unsigned reg) const;
+  bool IsMTEReg(unsigned reg) const;
 
   uint32_t GetRegNumSVEZ0() const;
   uint32_t GetRegNumSVEFFR() const;
   uint32_t GetRegNumFPCR() const;
   uint32_t GetRegNumFPSR() const;
   uint32_t GetRegNumSVEVG() const;
+  uint32_t GetPAuthOffset() const;
+  uint32_t GetMTEOffset() const;
 
 private:
   typedef std::map>
@@ -137,6 +147,9 @@
 
   std::vector m_dynamic_reg_infos;
   std::vector m_dynamic_reg_sets;
+
+  std::vector pauth_regnum_collection;
+  std::vector m_mte_regnum_collection;
 };
 
 #endif
Index: lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
===
--- lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -77,6 +77,8 @@
   k_num_gpr_registers = gpr_w28 - gpr_x0 + 1,
   k_num_fpr_registers = fpu_fpcr - fpu_v0 + 1,
   k_num_sve_registers = sve_ffr - sve_vg + 1,
+  k_num_mte_register = 1,
+  k_num_pauth_register = 2,
   k_num_register_sets_default = 2,
   k_num_register_sets = 3
 };
@@ -175,6 +177,12 @@
 {"Scalable Vector Extension Registers", "sve", k_num_sve_registers,
  g_sve_regnums_arm64}};
 
+static const lldb_private::RegisterSet g_reg_set_pauth_arm64 = {
+"Pointer Authentication Registers", "pauth", k_num_pauth_register, NULL};
+
+static const lldb_private::RegisterSet g_reg_set_mte_arm64 = {
+"MTE Control Register", "mte", k_num_mte_register, NULL};
+
 RegisterInf

[Lldb-commits] [PATCH] D96463: [LLDB] Arm64/Linux test case for MTE and Pointer Authentication regset

2021-03-19 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid updated this revision to Diff 331836.

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

https://reviews.llvm.org/D96463

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/commands/register/register/aarch64_dynamic_regset/Makefile
  
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
  lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c

Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c
@@ -0,0 +1,72 @@
+#include 
+
+void set_sve_registers() {
+  // AArch64 SVE extension ISA adds a new set of vector and predicate registers:
+  // 32 Z registers, 16 P registers, and 1 FFR register.
+  // Code below populates SVE registers to be read back by the debugger via
+  // ptrace interface at runtime.
+  // The P registers are predicate registers and hold one bit for each byte
+  // available in a Z vector register. For example, an SVE implementation with
+  // 1024-bit Z registers has 128-bit predicate registers.
+  // ptrue/pfalse instruction is used to set a predicate lane with a pattern.
+  // pattern is decided based on size specifier, b, h, s and d. if size
+  // specified is b all lanes will be set to 1. which is needed to set all bytes
+  // in a Z registers to the specified value.
+  asm volatile("setffr\n\t");
+  asm volatile("ptrue p0.b\n\t");
+  asm volatile("ptrue p1.h\n\t");
+  asm volatile("ptrue p2.s\n\t");
+  asm volatile("ptrue p3.d\n\t");
+  asm volatile("pfalse p4.b\n\t");
+  asm volatile("ptrue p5.b\n\t");
+  asm volatile("ptrue p6.h\n\t");
+  asm volatile("ptrue p7.s\n\t");
+  asm volatile("ptrue p8.d\n\t");
+  asm volatile("pfalse p9.b\n\t");
+  asm volatile("ptrue p10.b\n\t");
+  asm volatile("ptrue p11.h\n\t");
+  asm volatile("ptrue p12.s\n\t");
+  asm volatile("ptrue p13.d\n\t");
+  asm volatile("pfalse p14.b\n\t");
+  asm volatile("ptrue p15.b\n\t");
+
+  asm volatile("cpy  z0.b, p0/z, #1\n\t");
+  asm volatile("cpy  z1.b, p5/z, #2\n\t");
+  asm volatile("cpy  z2.b, p10/z, #3\n\t");
+  asm volatile("cpy  z3.b, p15/z, #4\n\t");
+  asm volatile("cpy  z4.b, p0/z, #5\n\t");
+  asm volatile("cpy  z5.b, p5/z, #6\n\t");
+  asm volatile("cpy  z6.b, p10/z, #7\n\t");
+  asm volatile("cpy  z7.b, p15/z, #8\n\t");
+  asm volatile("cpy  z8.b, p0/z, #9\n\t");
+  asm volatile("cpy  z9.b, p5/z, #10\n\t");
+  asm volatile("cpy  z10.b, p10/z, #11\n\t");
+  asm volatile("cpy  z11.b, p15/z, #12\n\t");
+  asm volatile("cpy  z12.b, p0/z, #13\n\t");
+  asm volatile("cpy  z13.b, p5/z, #14\n\t");
+  asm volatile("cpy  z14.b, p10/z, #15\n\t");
+  asm volatile("cpy  z15.b, p15/z, #16\n\t");
+  asm volatile("cpy  z16.b, p0/z, #17\n\t");
+  asm volatile("cpy  z17.b, p5/z, #18\n\t");
+  asm volatile("cpy  z18.b, p10/z, #19\n\t");
+  asm volatile("cpy  z19.b, p15/z, #20\n\t");
+  asm volatile("cpy  z20.b, p0/z, #21\n\t");
+  asm volatile("cpy  z21.b, p5/z, #22\n\t");
+  asm volatile("cpy  z22.b, p10/z, #23\n\t");
+  asm volatile("cpy  z23.b, p15/z, #24\n\t");
+  asm volatile("cpy  z24.b, p0/z, #25\n\t");
+  asm volatile("cpy  z25.b, p5/z, #26\n\t");
+  asm volatile("cpy  z26.b, p10/z, #27\n\t");
+  asm volatile("cpy  z27.b, p15/z, #28\n\t");
+  asm volatile("cpy  z28.b, p0/z, #29\n\t");
+  asm volatile("cpy  z29.b, p5/z, #30\n\t");
+  asm volatile("cpy  z30.b, p10/z, #31\n\t");
+  asm volatile("cpy  z31.b, p15/z, #32\n\t");
+}
+
+int main() {
+  if (getauxval(AT_HWCAP) & HWCAP_SVE) // check if SVE is present
+set_sve_registers();
+
+  return 0; // Set a break point here.
+}
Index: lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
===
--- /dev/null
+++ lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
@@ -0,0 +1,111 @@
+"""
+Test AArch64 dynamic register sets
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class RegisterCommandsTestCase(TestBase):
+
+def check_sve_register_size(self, set, name, expected):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Expected a register named %s' % (name))
+self.assertEqual(reg_value.GetByteSize(), expected,
+ 'Expected a register %s size == %i bytes' % (name, expected))
+
+def sve_regs_read_dynamic(self, sve_registers):
+vg_reg = sve_registers.GetChildMemberWithName("vg")
+vg_reg_value = sve_registers.GetChildMemberWithName(
+"vg").GetValueAsUnsigned()
+
+z_reg_size = vg_reg_value * 8
+p_reg_size = int(z_reg_size / 8)
+
+for i in range(32):
+z_regs_value = '{' + \
+

[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 331846.
mgorny added a comment.

Fix typo: qSupported needs to be joined using `;`, not `,`.


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

https://reviews.llvm.org/D98822

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/include/lldb/Host/linux/Host.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Host/linux/Host.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -201,6 +201,8 @@
 
   PacketResult Handle_g(StringExtractorGDBRemote &packet);
 
+  PacketResult Handle_qSupported_LLGS(StringExtractorGDBRemote &packet);
+
   void SetCurrentThreadID(lldb::tid_t tid);
 
   lldb::tid_t GetCurrentThreadID() const;
@@ -219,6 +221,9 @@
 
   static std::string XMLEncodeAttributeValue(llvm::StringRef value);
 
+  llvm::SmallVector
+  HandleFeatures(const llvm::ArrayRef client_features) override;
+
 private:
   llvm::Expected> BuildTargetXml();
 
@@ -255,6 +260,9 @@
   bool allow_any = false,
   bool allow_all = false);
 
+  // Call SetEnabledExtensions() with appropriate flags on the process.
+  void SetEnabledExtensions(NativeProcessProtocol& process);
+
   // For GDBRemoteCommunicationServerLLGS only
   GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) =
   delete;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -254,6 +254,8 @@
 m_debugged_process_up = std::move(*process_or);
   }
 
+  SetEnabledExtensions(*m_debugged_process_up);
+
   // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as
   // needed. llgs local-process debugging may specify PTY paths, which will
   // make these file actions non-null process launch -i/e/o will also make
@@ -321,6 +323,7 @@
 return status;
   }
   m_debugged_process_up = std::move(*process_or);
+  SetEnabledExtensions(*m_debugged_process_up);
 
   // Setup stdout/stderr mapping from inferior.
   auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
@@ -3703,3 +3706,29 @@
 
   return tid;
 }
+
+llvm::SmallVector
+GDBRemoteCommunicationServerLLGS::HandleFeatures(
+const llvm::ArrayRef client_features) {
+  auto ret =
+  GDBRemoteCommunicationServerCommon::HandleFeatures(client_features);
+  if (m_debugged_process_up)
+SetEnabledExtensions(*m_debugged_process_up);
+  return ret;
+}
+
+void GDBRemoteCommunicationServerLLGS::SetEnabledExtensions(
+NativeProcessProtocol &process) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  NativeProcessProtocol::Extension flags;
+  if (m_fork_events_supported)
+flags |= NativeProcessProtocol::Extension::fork;
+  if (m_vfork_events_supported)
+flags |= NativeProcessProtocol::Extension::vfork;
+
+  llvm::Error error = process.SetEnabledExtensions(flags);
+  if (error)
+LLDB_LOG_ERROR(log, std::move(error),
+   "Enabling protocol extensions failed: {0}");
+}
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
@@ -38,6 +38,8 @@
   uint32_t m_proc_infos_index;
   bool m_thread_suffix_supported;
   bool m_list_threads_in_stop_reply;
+  bool m_fork_events_supported;
+  bool m_vfork_events_supported;
 
   PacketResult Handle_A(StringExtractorGDBRemote &packet);
 
@@ -145,6 +147,11 @@
   virtual FileSpec FindModuleFile(const std::string &module_path,
   const ArchSpec &arch);
 
+  // Process client_features (qSupported) and return an array of server features
+  // to be returned in response.
+  virtual llvm::SmallVector
+  HandleFeatures(const llvm::ArrayRef cli

[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-19 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

The gdb model - since gdb only supports one debugee per gdb - is to either 
follow the fork or follow the parent.  It would be more in keeping with lldb's 
model to make a new target for the child side of the fork, and use that to 
follow the child.  That way you can continue to debug both the parent and the 
child processes.  It doesn't look like you've gotten that far yet, but IMO 
that's the direction we should be going for lldb.


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

https://reviews.llvm.org/D98822

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


[Lldb-commits] [PATCH] D98842: [lldb] Make the api, shell and unit tests independent lit test suites

2021-03-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 331918.
JDevlieghere added a comment.

Rebase


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

https://reviews.llvm.org/D98842

Files:
  lldb/test/API/CMakeLists.txt
  lldb/test/CMakeLists.txt
  lldb/test/Shell/CMakeLists.txt
  lldb/test/Unit/CMakeLists.txt
  lldb/unittests/CMakeLists.txt

Index: lldb/unittests/CMakeLists.txt
===
--- lldb/unittests/CMakeLists.txt
+++ lldb/unittests/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_custom_target(LLDBUnitTests)
 set_target_properties(LLDBUnitTests PROPERTIES FOLDER "lldb tests")
-add_dependencies(lldb-test-deps LLDBUnitTests)
+
+add_dependencies(lldb-unit-test-deps LLDBUnitTests)
 
 include_directories(${LLDB_SOURCE_ROOT})
 include_directories(${LLDB_PROJECT_ROOT}/unittests)
Index: lldb/test/Unit/CMakeLists.txt
===
--- lldb/test/Unit/CMakeLists.txt
+++ lldb/test/Unit/CMakeLists.txt
@@ -1,7 +1,17 @@
-# Configure the Unit test suite.
+add_custom_target(lldb-unit-test-deps)
+add_dependencies(lldb-unit-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-UNIT
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-unit-test-deps)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
+add_lit_testsuite(check-lldb-unit "Running lldb unit test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-unit-test-deps)
Index: lldb/test/Shell/CMakeLists.txt
===
--- lldb/test/Shell/CMakeLists.txt
+++ lldb/test/Shell/CMakeLists.txt
@@ -1,4 +1,10 @@
-# Configure the Shell test suite.
+add_custom_target(lldb-shell-test-deps)
+add_dependencies(lldb-shell-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-SHELL
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-shell-test-deps)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
@@ -8,10 +14,7 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/lit-lldb-init.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit-lldb-init)
 
-if (CMAKE_GENERATOR STREQUAL "Xcode")
-  # Xcode does not get the auto-generated targets. We need to create
-  # check-lldb-shell manually.
-  add_lit_testsuite(check-lldb-shell "Running lldb shell test suite"
-${CMAKE_CURRENT_BINARY_DIR}
-DEPENDS lldb-test-deps)
-endif()
+add_lit_testsuite(check-lldb-shell "Running lldb shell test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-shell-test-deps)
Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -185,19 +185,13 @@
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-add_lit_testsuites(LLDB
-  ${CMAKE_CURRENT_SOURCE_DIR}
-  DEPENDS lldb-test-deps)
-
-add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"
+add_lit_testsuite(check-lldb "Running lldb lit test suite"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS lldb-test-deps)
-set_target_properties(check-lldb-lit PROPERTIES FOLDER "lldb tests")
-
-add_custom_target(check-lldb)
-add_dependencies(check-lldb lldb-test-deps)
-set_target_properties(check-lldb PROPERTIES FOLDER "lldb misc")
-add_dependencies(check-lldb check-lldb-lit)
+  DEPENDS
+lldb-api-test-deps
+lldb-shell-test-deps
+lldb-unit-test-deps)
+set_target_properties(check-lldb PROPERTIES FOLDER "lldb tests")
 
 # Add a lit test suite that runs the API & shell test while capturing a
 # reproducer.
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -1,3 +1,10 @@
+add_custom_target(lldb-api-test-deps)
+add_dependencies(lldb-api-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-API
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-api-test-deps)
+
 function(add_python_test_target name test_script args comment)
   set(PYTHON_TEST_COMMAND
 ${Python3_EXECUTABLE}
@@ -153,39 +160,35 @@
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
 
-# Configure the API test suite.
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-if (CMAKE_GENERATOR STREQUAL "Xcode")
-  # Xcode does not get the auto-generated targets. We need to create
-  # check-lldb-api manually.
-  add_lit_testsuite(check-lldb-api "Running lldb api test suite"
-${CMAKE_CURRENT_BINARY_DIR}
-DEPENDS lldb-test-deps)
-endif()
-
 # Targets for running the test suite on the different Apple simulators.

[Lldb-commits] [PATCH] D97739: Add a progress class that can track and report long running operations that happen in LLDB.

2021-03-19 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D97739#2636343 , @jingham wrote:

> Thanks for doing this!  The event version looks pretty clean to me.  I think 
> we should go that way.  I don't think we should have two ways, that seems 
> confusing and still leaves us calling unknown user code in the middle of 
> symbol updates...

Sounds good, just wanted to make sure this was the way we want to go. I will 
remove the callback stuff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97739

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


[Lldb-commits] [PATCH] D98842: [lldb] Make the api, shell and unit tests independent lit test suites

2021-03-19 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Clean builds for all the test targets work now and this also looks good, so 
let's ship it.

(also thanks for working on that, the unit test builds where a big annoyance 
when testing API tests)


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

https://reviews.llvm.org/D98842

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


[Lldb-commits] [PATCH] D98842: [lldb] Make the api, shell and unit tests independent lit test suites

2021-03-19 Thread Jonas Devlieghere 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 rG6c52d4fd4c24: [lldb] Make the API, Shell and Unit tests 
independent lit test suites (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D98842?vs=331918&id=331946#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98842

Files:
  lldb/test/API/CMakeLists.txt
  lldb/test/API/lit.cfg.py
  lldb/test/API/lit.site.cfg.py.in
  lldb/test/CMakeLists.txt
  lldb/test/Shell/CMakeLists.txt
  lldb/test/Unit/CMakeLists.txt
  lldb/unittests/CMakeLists.txt

Index: lldb/unittests/CMakeLists.txt
===
--- lldb/unittests/CMakeLists.txt
+++ lldb/unittests/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_custom_target(LLDBUnitTests)
 set_target_properties(LLDBUnitTests PROPERTIES FOLDER "lldb tests")
-add_dependencies(lldb-test-deps LLDBUnitTests)
+
+add_dependencies(lldb-unit-test-deps LLDBUnitTests)
 
 include_directories(${LLDB_SOURCE_ROOT})
 include_directories(${LLDB_PROJECT_ROOT}/unittests)
Index: lldb/test/Unit/CMakeLists.txt
===
--- lldb/test/Unit/CMakeLists.txt
+++ lldb/test/Unit/CMakeLists.txt
@@ -1,7 +1,17 @@
-# Configure the Unit test suite.
+add_custom_target(lldb-unit-test-deps)
+add_dependencies(lldb-unit-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-UNIT
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-unit-test-deps)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
+add_lit_testsuite(check-lldb-unit "Running lldb unit test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-unit-test-deps)
Index: lldb/test/Shell/CMakeLists.txt
===
--- lldb/test/Shell/CMakeLists.txt
+++ lldb/test/Shell/CMakeLists.txt
@@ -1,4 +1,10 @@
-# Configure the Shell test suite.
+add_custom_target(lldb-shell-test-deps)
+add_dependencies(lldb-shell-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-SHELL
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-shell-test-deps)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
@@ -8,10 +14,7 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/lit-lldb-init.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit-lldb-init)
 
-if (CMAKE_GENERATOR STREQUAL "Xcode")
-  # Xcode does not get the auto-generated targets. We need to create
-  # check-lldb-shell manually.
-  add_lit_testsuite(check-lldb-shell "Running lldb shell test suite"
-${CMAKE_CURRENT_BINARY_DIR}
-DEPENDS lldb-test-deps)
-endif()
+add_lit_testsuite(check-lldb-shell "Running lldb shell test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-shell-test-deps)
Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -185,19 +185,13 @@
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-add_lit_testsuites(LLDB
-  ${CMAKE_CURRENT_SOURCE_DIR}
-  DEPENDS lldb-test-deps)
-
-add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"
+add_lit_testsuite(check-lldb "Running lldb lit test suite"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS lldb-test-deps)
-set_target_properties(check-lldb-lit PROPERTIES FOLDER "lldb tests")
-
-add_custom_target(check-lldb)
-add_dependencies(check-lldb lldb-test-deps)
-set_target_properties(check-lldb PROPERTIES FOLDER "lldb misc")
-add_dependencies(check-lldb check-lldb-lit)
+  DEPENDS
+lldb-api-test-deps
+lldb-shell-test-deps
+lldb-unit-test-deps)
+set_target_properties(check-lldb PROPERTIES FOLDER "lldb tests")
 
 # Add a lit test suite that runs the API & shell test while capturing a
 # reproducer.
Index: lldb/test/API/lit.site.cfg.py.in
===
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -1,6 +1,5 @@
 @LIT_SITE_CFG_IN_HEADER@
 
-config.test_exec_root = "@LLDB_BINARY_DIR@"
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -17,9 +17,10 @@
 config.suffixes = ['.py']
 
 # test_source_root: The root path where tests are located.
-# test_exec_root: The root path where tests should be run.
 config.test_source_root = os.path.dirname(__file__)
-config.test_exec_root = config.test_source_root
+
+# test_exec_root: The root path where tests should be run.
+config.test_ex

[Lldb-commits] [lldb] 6c52d4f - [lldb] Make the API, Shell and Unit tests independent lit test suites

2021-03-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-19T11:13:46-07:00
New Revision: 6c52d4fd4c24a0cf738e44516ca8378d65dcf019

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

LOG: [lldb] Make the API, Shell and Unit tests independent lit test suites

Make the API, Shell and Unit tests independent lit test suites. This
allows us to specify different dependencies and skip rebuilding all the
unit test (which is particularly expensive) when running check-lldb-api
or check-lldb-shell.

This does not change the autogenerated targets such as
check-lldb-shell-driver or the top level check-lldb target, which all
continue to work as before.

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

Added: 


Modified: 
lldb/test/API/CMakeLists.txt
lldb/test/API/lit.cfg.py
lldb/test/API/lit.site.cfg.py.in
lldb/test/CMakeLists.txt
lldb/test/Shell/CMakeLists.txt
lldb/test/Unit/CMakeLists.txt
lldb/unittests/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 0dbc46defc81..2b7dba456b1a 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -1,3 +1,10 @@
+add_custom_target(lldb-api-test-deps)
+add_dependencies(lldb-api-test-deps lldb-test-deps)
+
+add_lit_testsuites(LLDB-API
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-api-test-deps)
+
 function(add_python_test_target name test_script args comment)
   set(PYTHON_TEST_COMMAND
 ${Python3_EXECUTABLE}
@@ -153,39 +160,35 @@ string(REPLACE ${CMAKE_CFG_INTDIR} 
${dotest_args_replacement} LLDB_TEST_EXECUTAB
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
 
-# Configure the API test suite.
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-if (CMAKE_GENERATOR STREQUAL "Xcode")
-  # Xcode does not get the auto-generated targets. We need to create
-  # check-lldb-api manually.
-  add_lit_testsuite(check-lldb-api "Running lldb api test suite"
-${CMAKE_CURRENT_BINARY_DIR}
-DEPENDS lldb-test-deps)
-endif()
-
 # Targets for running the test suite on the 
diff erent Apple simulators.
 add_lit_testsuite(check-lldb-simulator-ios
   "Running lldb test suite on the iOS simulator"
   ${CMAKE_CURRENT_BINARY_DIR}
   PARAMS "lldb-run-with-simulator=ios"
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-test-deps)
+  DEPENDS lldb-api-test-deps)
 
 add_lit_testsuite(check-lldb-simulator-watchos
   "Running lldb test suite on the watchOS simulator"
   ${CMAKE_CURRENT_BINARY_DIR}
   PARAMS "lldb-run-with-simulator=watchos"
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-test-deps)
+  DEPENDS lldb-api-test-deps)
 
 add_lit_testsuite(check-lldb-simulator-tvos
   "Running lldb test suite on the tvOS simulator"
   ${CMAKE_CURRENT_BINARY_DIR}
   PARAMS "lldb-run-with-simulator=tvos"
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-test-deps)
+  DEPENDS lldb-api-test-deps)
+
+add_lit_testsuite(check-lldb-api "Running lldb api test suite"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-api-test-deps)

diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 54a02453b174..1bd7dc35fb2a 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -17,9 +17,10 @@
 config.suffixes = ['.py']
 
 # test_source_root: The root path where tests are located.
-# test_exec_root: The root path where tests should be run.
 config.test_source_root = os.path.dirname(__file__)
-config.test_exec_root = config.test_source_root
+
+# test_exec_root: The root path where tests should be run.
+config.test_exec_root = os.path.join(config.lldb_obj_root, 'test')
 
 
 def mkdir_p(path):

diff  --git a/lldb/test/API/lit.site.cfg.py.in 
b/lldb/test/API/lit.site.cfg.py.in
index 2e368325a9f0..49ea94aacd11 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -1,6 +1,5 @@
 @LIT_SITE_CFG_IN_HEADER@
 
-config.test_exec_root = "@LLDB_BINARY_DIR@"
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"

diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 8363bde23035..c6b01c66a0ef 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -185,19 +185,13 @@ configure_lit_site_cfg(
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-add_lit_testsuites(LLDB
-  ${CMAKE_CURRENT_SOURCE_DIR}
-  DEPENDS lldb-test-deps)
-
-add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"
+add_lit_testsuite(check-lldb "Running lldb lit test suite"
   

[Lldb-commits] [lldb] 9406d43 - Make the stop-on-sharedlibrary-events setting work.

2021-03-19 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2021-03-19T12:02:16-07:00
New Revision: 9406d43138811ac4dfd0ab31434f65a649bc882e

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

LOG: Make the stop-on-sharedlibrary-events setting work.

We weren't taking into account the "m_should_stop" setting that the
synchronous breakpoint callback had already set when we did PerformAction
in the StopInfoBreakpoint.  So we didn't obey its instructions when it
told us to stop.  Fixed that and added some tests both for when we
just have the setting, and when we have the setting AND other breakpoints
at the shared library load notification breakpoint address.

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

Added: 
lldb/test/API/functionalities/stop-on-sharedlibrary-load/Makefile

lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
lldb/test/API/functionalities/stop-on-sharedlibrary-load/a.cpp
lldb/test/API/functionalities/stop-on-sharedlibrary-load/b.cpp
lldb/test/API/functionalities/stop-on-sharedlibrary-load/main.cpp

Modified: 
lldb/source/Breakpoint/BreakpointOptions.cpp
lldb/source/Target/StopInfo.cpp

Removed: 




diff  --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 2fdb53e52723..24427835980e 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -453,9 +453,12 @@ bool 
BreakpointOptions::InvokeCallback(StoppointCallbackContext *context,
   : nullptr,
   context, break_id, break_loc_id);
 } else if (IsCallbackSynchronous()) {
-  // If a synchronous callback is called at async time, it should not say
-  // to stop.
-  return false;
+  // If a synchronous callback is called at async time, we will say we
+  // should stop, we're really expression no opinion about stopping, and
+  // the StopInfoBreakpoint::PerformAction will note whether an async
+  // callback had already made a claim to stop or not based on the incoming
+  // values of m_should_stop & m_should_stop_is_valid.
+  return true;
 }
   }
   return true;

diff  --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index 7e830c6e2bed..1cb582e83cc1 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -305,6 +305,20 @@ class StopInfoBreakpoint : public StopInfo {
   // location said we should stop. But that's better than not running
   // all the callbacks.
 
+  // There's one other complication here.  We may have run an async
+  // breakpoint callback that said we should stop.  We only want to
+  // override that if another breakpoint action says we shouldn't 
+  // stop.  If nobody else has an opinion, then we should stop if the
+  // async callback says we should.  An example of this is the async
+  // shared library load notification breakpoint and the setting
+  // stop-on-sharedlibrary-events.
+  // We'll keep the async value in async_should_stop, and track whether
+  // anyone said we should NOT stop in actually_said_continue.
+  bool async_should_stop = false;
+  if (m_should_stop_is_valid)
+async_should_stop = m_should_stop;
+  bool actually_said_continue = false;
+
   m_should_stop = false;
 
   // We don't select threads as we go through them testing breakpoint
@@ -422,9 +436,10 @@ class StopInfoBreakpoint : public StopInfo {
 
 bool precondition_result =
 bp_loc_sp->GetBreakpoint().EvaluatePrecondition(context);
-if (!precondition_result)
+if (!precondition_result) {
+  actually_said_continue = true;
   continue;
-
+}
 // Next run the condition for the breakpoint.  If that says we
 // should stop, then we'll run the callback for the breakpoint.  If
 // the callback says we shouldn't stop that will win.
@@ -462,6 +477,7 @@ class StopInfoBreakpoint : public StopInfo {
   // the condition fails. We've already bumped it by the time
   // we get here, so undo the bump:
   bp_loc_sp->UndoBumpHitCount();
+  actually_said_continue = true;
   continue;
 }
   }
@@ -504,6 +520,9 @@ class StopInfoBreakpoint : public StopInfo {
 
 if (callback_says_stop && auto_continue_says_stop)
   m_should_stop = true;
+else
+  actually_said_continue = true;
+
   
 // If we are going to stop for

[Lldb-commits] [PATCH] D98914: Make target.process.stop-on-sharedlibrary-events setting work

2021-03-19 Thread Jim Ingham 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 rG9406d4313881: Make the stop-on-sharedlibrary-events setting 
work. (authored by jingham).

Changed prior to commit:
  https://reviews.llvm.org/D98914?vs=331744&id=331972#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98914

Files:
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Target/StopInfo.cpp
  lldb/test/API/functionalities/stop-on-sharedlibrary-load/Makefile
  
lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
  lldb/test/API/functionalities/stop-on-sharedlibrary-load/a.cpp
  lldb/test/API/functionalities/stop-on-sharedlibrary-load/b.cpp
  lldb/test/API/functionalities/stop-on-sharedlibrary-load/main.cpp

Index: lldb/test/API/functionalities/stop-on-sharedlibrary-load/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/stop-on-sharedlibrary-load/main.cpp
@@ -0,0 +1,27 @@
+#include "dylib.h"
+#include 
+#include 
+#include 
+#include 
+
+int main(int argc, char const *argv[]) {
+  const char *a_name = "load_a";
+  void *a_dylib_handle = NULL;
+
+  a_dylib_handle = dylib_open(a_name); // Set a breakpoint here.
+  if (a_dylib_handle == NULL) { // Set another here - we should not hit this one
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(1);
+  }
+
+  const char *b_name = "load_b";
+  void *b_dylib_handle = NULL;
+
+  b_dylib_handle = dylib_open(b_name);
+  if (b_dylib_handle == NULL) { // Set a third here - we should not hit this one
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(1);
+  }
+
+  return 0;
+}
Index: lldb/test/API/functionalities/stop-on-sharedlibrary-load/b.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/stop-on-sharedlibrary-load/b.cpp
@@ -0,0 +1,6 @@
+extern int b_has_a_function();
+
+int
+b_has_a_function() {
+  return 100;
+}
Index: lldb/test/API/functionalities/stop-on-sharedlibrary-load/a.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/stop-on-sharedlibrary-load/a.cpp
@@ -0,0 +1,6 @@
+extern int a_has_a_function();
+
+int
+a_has_a_function() {
+  return 10;
+}
Index: lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
===
--- /dev/null
+++ lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
@@ -0,0 +1,96 @@
+""" Test that stop-on-sharedlibrary-events works and cooperates with breakpoints. """
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestStopOnSharedlibraryEvents(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfRemote
+@skipIfWindows
+@no_debug_info_test
+def test_stopping_breakpoints(self):
+self.do_test()
+
+def test_auto_continue(self):
+def auto_continue(bkpt):
+bkpt.SetAutoContinue(True)
+self.do_test(auto_continue)
+
+def test_failing_condition(self):
+def condition(bkpt):
+bkpt.SetCondition("1 == 2")
+self.do_test(condition)
+
+def test_continue_callback(self):
+def bkpt_callback(bkpt):
+bkpt.SetScriptCallbackBody("return False")
+self.do_test(bkpt_callback)
+
+def do_test(self, bkpt_modifier = None):
+self.build()
+main_spec = lldb.SBFileSpec("main.cpp")
+# Launch and stop before the dlopen call.
+target, process, _, _ = lldbutil.run_to_source_breakpoint(self,
+  "// Set a breakpoint here", main_spec)
+
+# Now turn on shared library events, continue and make sure we stop for the event.
+self.runCmd("settings set target.process.stop-on-sharedlibrary-events 1")
+self.addTearDownHook(lambda: self.runCmd(
+"settings set target.process.stop-on-sharedlibrary-events 0"))
+
+# Since I don't know how to check that we are at the "right place" to stop for
+# shared library events, make an breakpoint after the load is done and
+# make sure we don't stop there:
+backstop_bkpt_1 = target.BreakpointCreateBySourceRegex("Set another here - we should not hit this one", main_spec)
+self.assertGreater(backstop_bkpt_1.GetNumLocations(), 0, "Set our second breakpoint")
+
+process.Continue() 
+self.assertEqual(process.GetState(), lldb.eStateStopped, "We didn't stop for the load")
+self.assertEqual(backstop_bkpt_1.GetHitCount(), 0, "Hit our backstop breakpoint")
+
+# We should 

[Lldb-commits] [PATCH] D98914: Make target.process.stop-on-sharedlibrary-events setting work

2021-03-19 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

I added a couple more tests for having a breakpoint at the load site before 
committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98914

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


[Lldb-commits] [lldb] a8d62fc - Skip all the tests for Windows.

2021-03-19 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2021-03-19T12:05:16-07:00
New Revision: a8d62fc8ff1c836e16cfb1a510ee8063ac2652ff

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

LOG: Skip all the tests for Windows.

Added: 


Modified: 

lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
 
b/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
index 98c4eb89ff54..d19a790f7830 100644
--- 
a/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
+++ 
b/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
@@ -14,16 +14,25 @@ class TestStopOnSharedlibraryEvents(TestBase):
 def test_stopping_breakpoints(self):
 self.do_test()
 
+@skipIfRemote
+@skipIfWindows
+@no_debug_info_test
 def test_auto_continue(self):
 def auto_continue(bkpt):
 bkpt.SetAutoContinue(True)
 self.do_test(auto_continue)
 
+@skipIfRemote
+@skipIfWindows
+@no_debug_info_test
 def test_failing_condition(self):
 def condition(bkpt):
 bkpt.SetCondition("1 == 2")
 self.do_test(condition)
 
+@skipIfRemote
+@skipIfWindows
+@no_debug_info_test
 def test_continue_callback(self):
 def bkpt_callback(bkpt):
 bkpt.SetScriptCallbackBody("return False")



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


[Lldb-commits] [lldb] e8e07b3 - Revert "Skip all the tests for Windows."

2021-03-19 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2021-03-19T12:38:23-07:00
New Revision: e8e07b3a5e6032edeed559db448402094cff31bf

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

LOG: Revert "Skip all the tests for Windows."

This reverts commit a8d62fc8ff1c836e16cfb1a510ee8063ac2652ff.

Added: 


Modified: 

lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
 
b/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
index d19a790f7830..98c4eb89ff54 100644
--- 
a/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
+++ 
b/lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
@@ -14,25 +14,16 @@ class TestStopOnSharedlibraryEvents(TestBase):
 def test_stopping_breakpoints(self):
 self.do_test()
 
-@skipIfRemote
-@skipIfWindows
-@no_debug_info_test
 def test_auto_continue(self):
 def auto_continue(bkpt):
 bkpt.SetAutoContinue(True)
 self.do_test(auto_continue)
 
-@skipIfRemote
-@skipIfWindows
-@no_debug_info_test
 def test_failing_condition(self):
 def condition(bkpt):
 bkpt.SetCondition("1 == 2")
 self.do_test(condition)
 
-@skipIfRemote
-@skipIfWindows
-@no_debug_info_test
 def test_continue_callback(self):
 def bkpt_callback(bkpt):
 bkpt.SetScriptCallbackBody("return False")



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


[Lldb-commits] [lldb] 9d081a7 - Revert "Make the stop-on-sharedlibrary-events setting work."

2021-03-19 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2021-03-19T12:38:41-07:00
New Revision: 9d081a7ffe5c2f9575f77bedd6cbf4385287aeec

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

LOG: Revert "Make the stop-on-sharedlibrary-events setting work."

This reverts commit 9406d43138811ac4dfd0ab31434f65a649bc882e.

I messed up a test, and when I got it right it was failing.  The changed logic
doesn't work quite right (now the async callback called at sync time is
forcing us to stop.  I need to be a little more careful about that.

Added: 


Modified: 
lldb/source/Breakpoint/BreakpointOptions.cpp
lldb/source/Target/StopInfo.cpp

Removed: 
lldb/test/API/functionalities/stop-on-sharedlibrary-load/Makefile

lldb/test/API/functionalities/stop-on-sharedlibrary-load/TestStopOnSharedlibraryEvents.py
lldb/test/API/functionalities/stop-on-sharedlibrary-load/a.cpp
lldb/test/API/functionalities/stop-on-sharedlibrary-load/b.cpp
lldb/test/API/functionalities/stop-on-sharedlibrary-load/main.cpp



diff  --git a/lldb/source/Breakpoint/BreakpointOptions.cpp 
b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 24427835980e..2fdb53e52723 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -453,12 +453,9 @@ bool 
BreakpointOptions::InvokeCallback(StoppointCallbackContext *context,
   : nullptr,
   context, break_id, break_loc_id);
 } else if (IsCallbackSynchronous()) {
-  // If a synchronous callback is called at async time, we will say we
-  // should stop, we're really expression no opinion about stopping, and
-  // the StopInfoBreakpoint::PerformAction will note whether an async
-  // callback had already made a claim to stop or not based on the incoming
-  // values of m_should_stop & m_should_stop_is_valid.
-  return true;
+  // If a synchronous callback is called at async time, it should not say
+  // to stop.
+  return false;
 }
   }
   return true;

diff  --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index 1cb582e83cc1..7e830c6e2bed 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -305,20 +305,6 @@ class StopInfoBreakpoint : public StopInfo {
   // location said we should stop. But that's better than not running
   // all the callbacks.
 
-  // There's one other complication here.  We may have run an async
-  // breakpoint callback that said we should stop.  We only want to
-  // override that if another breakpoint action says we shouldn't 
-  // stop.  If nobody else has an opinion, then we should stop if the
-  // async callback says we should.  An example of this is the async
-  // shared library load notification breakpoint and the setting
-  // stop-on-sharedlibrary-events.
-  // We'll keep the async value in async_should_stop, and track whether
-  // anyone said we should NOT stop in actually_said_continue.
-  bool async_should_stop = false;
-  if (m_should_stop_is_valid)
-async_should_stop = m_should_stop;
-  bool actually_said_continue = false;
-
   m_should_stop = false;
 
   // We don't select threads as we go through them testing breakpoint
@@ -436,10 +422,9 @@ class StopInfoBreakpoint : public StopInfo {
 
 bool precondition_result =
 bp_loc_sp->GetBreakpoint().EvaluatePrecondition(context);
-if (!precondition_result) {
-  actually_said_continue = true;
+if (!precondition_result)
   continue;
-}
+
 // Next run the condition for the breakpoint.  If that says we
 // should stop, then we'll run the callback for the breakpoint.  If
 // the callback says we shouldn't stop that will win.
@@ -477,7 +462,6 @@ class StopInfoBreakpoint : public StopInfo {
   // the condition fails. We've already bumped it by the time
   // we get here, so undo the bump:
   bp_loc_sp->UndoBumpHitCount();
-  actually_said_continue = true;
   continue;
 }
   }
@@ -520,9 +504,6 @@ class StopInfoBreakpoint : public StopInfo {
 
 if (callback_says_stop && auto_continue_says_stop)
   m_should_stop = true;
-else
-  actually_said_continue = true;
-
   
 // If we are going to stop for this breakpoint, then remove the
 // breakpoint.
@@ -536,15 +517,9 @@ class StopInfoBreakpoint : public StopInfo {
 // here.
 if (HasTargetRun

[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 331982.
mgorny added a comment.

Now using the new thingie for threads. `getTIDForPID()` temporarily commented 
out but I plan to use it to distinguish `clone()` for new thread from `clone()` 
for new process.


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

https://reviews.llvm.org/D98822

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/include/lldb/Host/linux/Host.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Host/linux/Host.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -201,6 +201,8 @@
 
   PacketResult Handle_g(StringExtractorGDBRemote &packet);
 
+  PacketResult Handle_qSupported_LLGS(StringExtractorGDBRemote &packet);
+
   void SetCurrentThreadID(lldb::tid_t tid);
 
   lldb::tid_t GetCurrentThreadID() const;
@@ -219,6 +221,9 @@
 
   static std::string XMLEncodeAttributeValue(llvm::StringRef value);
 
+  llvm::SmallVector
+  HandleFeatures(const llvm::ArrayRef client_features) override;
+
 private:
   llvm::Expected> BuildTargetXml();
 
@@ -255,6 +260,9 @@
   bool allow_any = false,
   bool allow_all = false);
 
+  // Call SetEnabledExtensions() with appropriate flags on the process.
+  void SetEnabledExtensions(NativeProcessProtocol& process);
+
   // For GDBRemoteCommunicationServerLLGS only
   GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) =
   delete;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -254,6 +254,8 @@
 m_debugged_process_up = std::move(*process_or);
   }
 
+  SetEnabledExtensions(*m_debugged_process_up);
+
   // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as
   // needed. llgs local-process debugging may specify PTY paths, which will
   // make these file actions non-null process launch -i/e/o will also make
@@ -321,6 +323,7 @@
 return status;
   }
   m_debugged_process_up = std::move(*process_or);
+  SetEnabledExtensions(*m_debugged_process_up);
 
   // Setup stdout/stderr mapping from inferior.
   auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
@@ -3703,3 +3706,29 @@
 
   return tid;
 }
+
+llvm::SmallVector
+GDBRemoteCommunicationServerLLGS::HandleFeatures(
+const llvm::ArrayRef client_features) {
+  auto ret =
+  GDBRemoteCommunicationServerCommon::HandleFeatures(client_features);
+  if (m_debugged_process_up)
+SetEnabledExtensions(*m_debugged_process_up);
+  return ret;
+}
+
+void GDBRemoteCommunicationServerLLGS::SetEnabledExtensions(
+NativeProcessProtocol &process) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  NativeProcessProtocol::Extension flags;
+  if (m_fork_events_supported)
+flags |= NativeProcessProtocol::Extension::fork;
+  if (m_vfork_events_supported)
+flags |= NativeProcessProtocol::Extension::vfork;
+
+  llvm::Error error = process.SetEnabledExtensions(flags);
+  if (error)
+LLDB_LOG_ERROR(log, std::move(error),
+   "Enabling protocol extensions failed: {0}");
+}
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
@@ -38,6 +38,8 @@
   uint32_t m_proc_infos_index;
   bool m_thread_suffix_supported;
   bool m_list_threads_in_stop_reply;
+  bool m_fork_events_supported;
+  bool m_vfork_events_supported;
 
   PacketResult Handle_A(StringExtractorGDBRemote &packet);
 
@@ -145,6 +147,11 @@
   virtual FileSpec FindModuleFile(const std::string &module_path,
   const ArchSpec &arch);
 
+  // Process client_features (qSupported) and return an array of serv

[Lldb-commits] [PATCH] D98879: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp:609
 if (!path_strings) {
-  result_ptr->image_ptr = dlopen(name, 2);
+  result_ptr->image_ptr = dlopen(name, )" DLOPEN_OPTIONS R"();
   if (result_ptr->image_ptr)

Instead of `DLOPEN_OPTIONS` and string concatenation, what do you think about 
defining `RTLD_LAZY` inside this string of code?

```
static const int RTLD_LAZY = 0x1;

/// code…

result_ptr->image_ptr = dlopen(name, RTLD_LAZY);
```

The main reason I suggest this is putting the name inline like that makes it 
more grep friendly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98879

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


[Lldb-commits] [PATCH] D98987: [lldb] Call os_log_fault on lldb_assert

2021-03-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: LLDB, aprantl.
JDevlieghere requested review of this revision.

Call `os_log_fault` when an lldb assert fails. We piggyback off of the 
`LLVM_SUPPORT_XCODE_SIGNPOSTS` to for `os_log` support rather than introducing 
another check and define just for this. This patch also adds a small test using 
`lldb-test`.


https://reviews.llvm.org/D98987

Files:
  lldb/include/lldb/Utility/LLDBAssert.h
  lldb/source/Utility/LLDBAssert.cpp
  lldb/test/Shell/Error/assert.test
  lldb/tools/lldb-test/lldb-test.cpp

Index: lldb/tools/lldb-test/lldb-test.cpp
===
--- lldb/tools/lldb-test/lldb-test.cpp
+++ lldb/tools/lldb-test/lldb-test.cpp
@@ -29,6 +29,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -57,6 +58,7 @@
 "Display LLDB object file information");
 cl::SubCommand SymbolsSubcommand("symbols", "Dump symbols for an object file");
 cl::SubCommand IRMemoryMapSubcommand("ir-memory-map", "Test IRMemoryMap");
+cl::SubCommand AssertSubcommand("assert", "Test assert handling");
 
 cl::opt Log("log", cl::desc("Path to a log file"), cl::init(""),
  cl::sub(BreakpointSubcommand),
@@ -236,6 +238,9 @@
 int evaluateMemoryMapCommands(Debugger &Dbg);
 } // namespace irmemorymap
 
+namespace assert {
+int lldb_assert(Debugger &Dbg);
+} // namespace assert
 } // namespace opts
 
 std::vector parseCompilerContext() {
@@ -1077,6 +1082,11 @@
   return 0;
 }
 
+int opts::assert::lldb_assert(Debugger &Dbg) {
+  lldbassert(false && "lldb-test assert");
+  return 1;
+}
+
 int main(int argc, const char *argv[]) {
   StringRef ToolName = argv[0];
   sys::PrintStackTraceOnErrorSignal(ToolName);
@@ -1120,6 +1130,8 @@
 return opts::symbols::dumpSymbols(*Dbg);
   if (opts::IRMemoryMapSubcommand)
 return opts::irmemorymap::evaluateMemoryMapCommands(*Dbg);
+  if (opts::AssertSubcommand)
+return opts::assert::lldb_assert(*Dbg);
 
   WithColor::error() << "No command specified.\n";
   return 1;
Index: lldb/test/Shell/Error/assert.test
===
--- /dev/null
+++ lldb/test/Shell/Error/assert.test
@@ -0,0 +1,4 @@
+# REQUIRES: asserts
+# RUN: not --crash lldb-test assert > %t.error 2>&1
+# RUN: cat %t.error | FileCheck %s
+# CHECK: Assertion failed: (false && "lldb_assert failed")
Index: lldb/source/Utility/LLDBAssert.cpp
===
--- lldb/source/Utility/LLDBAssert.cpp
+++ lldb/source/Utility/LLDBAssert.cpp
@@ -7,11 +7,15 @@
 //===--===//
 
 #include "lldb/Utility/LLDBAssert.h"
-
+#include "llvm/Config/config.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 
+#if LLVM_SUPPORT_XCODE_SIGNPOSTS
+#include 
+#endif
+
 using namespace llvm;
 using namespace lldb_private;
 
@@ -21,6 +25,14 @@
   if (LLVM_LIKELY(expression))
 return;
 
+#if LLVM_SUPPORT_XCODE_SIGNPOSTS
+  if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
+os_log_fault(OS_LOG_DEFAULT,
+ "Assertion failed: (%s), function %s, file %s, line %u\n",
+ expr_text, func, file, line);
+  }
+#endif
+
   // If asserts are enabled abort here.
   assert(false && "lldb_assert failed");
 
Index: lldb/include/lldb/Utility/LLDBAssert.h
===
--- lldb/include/lldb/Utility/LLDBAssert.h
+++ lldb/include/lldb/Utility/LLDBAssert.h
@@ -20,6 +20,6 @@
 namespace lldb_private {
 void lldb_assert(bool expression, const char *expr_text, const char *func,
  const char *file, unsigned int line);
-}
+} // namespace lldb_private
 
 #endif // LLDB_UTILITY_LLDBASSERT_H
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D98987: [lldb] Call os_log_fault on lldb_assert

2021-03-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 331997.

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

https://reviews.llvm.org/D98987

Files:
  lldb/include/lldb/Utility/LLDBAssert.h
  lldb/source/Utility/LLDBAssert.cpp
  lldb/test/Shell/Error/assert.test
  lldb/tools/lldb-test/lldb-test.cpp

Index: lldb/tools/lldb-test/lldb-test.cpp
===
--- lldb/tools/lldb-test/lldb-test.cpp
+++ lldb/tools/lldb-test/lldb-test.cpp
@@ -29,6 +29,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -57,6 +58,7 @@
 "Display LLDB object file information");
 cl::SubCommand SymbolsSubcommand("symbols", "Dump symbols for an object file");
 cl::SubCommand IRMemoryMapSubcommand("ir-memory-map", "Test IRMemoryMap");
+cl::SubCommand AssertSubcommand("assert", "Test assert handling");
 
 cl::opt Log("log", cl::desc("Path to a log file"), cl::init(""),
  cl::sub(BreakpointSubcommand),
@@ -236,6 +238,9 @@
 int evaluateMemoryMapCommands(Debugger &Dbg);
 } // namespace irmemorymap
 
+namespace assert {
+int lldb_assert(Debugger &Dbg);
+} // namespace assert
 } // namespace opts
 
 std::vector parseCompilerContext() {
@@ -1077,6 +1082,11 @@
   return 0;
 }
 
+int opts::assert::lldb_assert(Debugger &Dbg) {
+  lldbassert(false && "lldb-test assert");
+  return 1;
+}
+
 int main(int argc, const char *argv[]) {
   StringRef ToolName = argv[0];
   sys::PrintStackTraceOnErrorSignal(ToolName);
@@ -1120,6 +1130,8 @@
 return opts::symbols::dumpSymbols(*Dbg);
   if (opts::IRMemoryMapSubcommand)
 return opts::irmemorymap::evaluateMemoryMapCommands(*Dbg);
+  if (opts::AssertSubcommand)
+return opts::assert::lldb_assert(*Dbg);
 
   WithColor::error() << "No command specified.\n";
   return 1;
Index: lldb/test/Shell/Error/assert.test
===
--- /dev/null
+++ lldb/test/Shell/Error/assert.test
@@ -0,0 +1,4 @@
+# REQUIRES: asserts
+# RUN: not --crash lldb-test assert > %t.error 2>&1
+# RUN: cat %t.error | FileCheck %s
+# CHECK: Assertion failed: (false && "lldb_assert failed")
Index: lldb/source/Utility/LLDBAssert.cpp
===
--- lldb/source/Utility/LLDBAssert.cpp
+++ lldb/source/Utility/LLDBAssert.cpp
@@ -7,11 +7,15 @@
 //===--===//
 
 #include "lldb/Utility/LLDBAssert.h"
-
+#include "llvm/Config/config.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 
+#if LLVM_SUPPORT_XCODE_SIGNPOSTS
+#include 
+#endif
+
 using namespace llvm;
 using namespace lldb_private;
 
@@ -24,6 +28,14 @@
   // If asserts are enabled abort here.
   assert(false && "lldb_assert failed");
 
+#if LLVM_SUPPORT_XCODE_SIGNPOSTS
+  if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
+os_log_fault(OS_LOG_DEFAULT,
+ "Assertion failed: (%s), function %s, file %s, line %u\n",
+ expr_text, func, file, line);
+  }
+#endif
+
   // In a release configuration it will print a warning and encourage the user
   // to file a bug report, similar to LLVM’s crash handler, and then return
   // execution.
Index: lldb/include/lldb/Utility/LLDBAssert.h
===
--- lldb/include/lldb/Utility/LLDBAssert.h
+++ lldb/include/lldb/Utility/LLDBAssert.h
@@ -20,6 +20,6 @@
 namespace lldb_private {
 void lldb_assert(bool expression, const char *expr_text, const char *func,
  const char *file, unsigned int line);
-}
+} // namespace lldb_private
 
 #endif // LLDB_UTILITY_LLDBASSERT_H
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D98879: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 331998.
vsk added a comment.

- Define RTLD_LAZY in the expression as suggested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98879

Files:
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/test/API/functionalities/load_lazy/Makefile
  lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
  lldb/test/API/functionalities/load_lazy/categories
  lldb/test/API/functionalities/load_lazy/main.cpp
  lldb/test/API/functionalities/load_lazy/t1.c
  lldb/test/API/functionalities/load_lazy/t2_0.c
  lldb/test/API/functionalities/load_lazy/t2_1.c

Index: lldb/test/API/functionalities/load_lazy/t2_0.c
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/t2_0.c
@@ -0,0 +1 @@
+void use() {}
Index: lldb/test/API/functionalities/load_lazy/t1.c
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/t1.c
@@ -0,0 +1,3 @@
+extern void use();
+void f1() {}
+void f2() { use(); }
Index: lldb/test/API/functionalities/load_lazy/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0; // break here
+}
Index: lldb/test/API/functionalities/load_lazy/categories
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/categories
@@ -0,0 +1 @@
+basic_process
Index: lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
@@ -0,0 +1,54 @@
+"""
+Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
+"""
+
+
+
+import os
+import shutil
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+class LoadUsingLazyBind(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+# Invoke the default build rule.
+self.build()
+
+self.wd = os.path.realpath(self.getBuildDir())
+
+self.ext = 'so'
+if self.platformIsDarwin():
+self.ext = 'dylib'
+
+# Overwrite t2_0 with t2_1 to delete the definition of `use`.
+shutil.copy(os.path.join(self.wd, 'libt2_1.{}'.format(self.ext)),
+os.path.join(self.wd, 'libt2_0.{}'.format(self.ext)))
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+def test_load_using_lazy_bind(self):
+"""Test that we load using RTLD_LAZY"""
+
+(target, process, thread, _) = lldbutil.run_to_source_breakpoint(self,
+"break here",
+lldb.SBFileSpec("main.cpp"))
+error = lldb.SBError()
+lib_spec = lldb.SBFileSpec("libt1.{}".format(self.ext))
+paths = lldb.SBStringList()
+paths.AppendString(self.wd)
+out_spec = lldb.SBFileSpec()
+token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error)
+self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token")
Index: lldb/test/API/functionalities/load_lazy/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/Makefile
@@ -0,0 +1,17 @@
+CXX_SOURCES := main.cpp
+
+all: t2_0 t2_1 t1 a.out
+
+include Makefile.rules
+
+t1: t2_0
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 LD_EXTRAS="-L. -lt2_0"
+
+t2_0:
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
+
+t2_1:
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1
Index: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
===
--- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,7 +578,19 @@
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
+  //
+  // Use lazy binding so as to not make dlopen()'s success conditional on
+  // forcing every symbol in the library.
+  //
+  // In general, the debugger should allow programs to load & run with
+  // libraries as far as they can, instead of defaulting to being super-picky
+  // 

[Lldb-commits] [PATCH] D98879: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 331999.
vsk added a comment.

- Delete an unused '#undef DLOPEN_OPTIONS'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98879

Files:
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/test/API/functionalities/load_lazy/Makefile
  lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
  lldb/test/API/functionalities/load_lazy/categories
  lldb/test/API/functionalities/load_lazy/main.cpp
  lldb/test/API/functionalities/load_lazy/t1.c
  lldb/test/API/functionalities/load_lazy/t2_0.c
  lldb/test/API/functionalities/load_lazy/t2_1.c

Index: lldb/test/API/functionalities/load_lazy/t2_0.c
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/t2_0.c
@@ -0,0 +1 @@
+void use() {}
Index: lldb/test/API/functionalities/load_lazy/t1.c
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/t1.c
@@ -0,0 +1,3 @@
+extern void use();
+void f1() {}
+void f2() { use(); }
Index: lldb/test/API/functionalities/load_lazy/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0; // break here
+}
Index: lldb/test/API/functionalities/load_lazy/categories
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/categories
@@ -0,0 +1 @@
+basic_process
Index: lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
@@ -0,0 +1,54 @@
+"""
+Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
+"""
+
+
+
+import os
+import shutil
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+class LoadUsingLazyBind(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+# Invoke the default build rule.
+self.build()
+
+self.wd = os.path.realpath(self.getBuildDir())
+
+self.ext = 'so'
+if self.platformIsDarwin():
+self.ext = 'dylib'
+
+# Overwrite t2_0 with t2_1 to delete the definition of `use`.
+shutil.copy(os.path.join(self.wd, 'libt2_1.{}'.format(self.ext)),
+os.path.join(self.wd, 'libt2_0.{}'.format(self.ext)))
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+def test_load_using_lazy_bind(self):
+"""Test that we load using RTLD_LAZY"""
+
+(target, process, thread, _) = lldbutil.run_to_source_breakpoint(self,
+"break here",
+lldb.SBFileSpec("main.cpp"))
+error = lldb.SBError()
+lib_spec = lldb.SBFileSpec("libt1.{}".format(self.ext))
+paths = lldb.SBStringList()
+paths.AppendString(self.wd)
+out_spec = lldb.SBFileSpec()
+token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error)
+self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token")
Index: lldb/test/API/functionalities/load_lazy/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/Makefile
@@ -0,0 +1,17 @@
+CXX_SOURCES := main.cpp
+
+all: t2_0 t2_1 t1 a.out
+
+include Makefile.rules
+
+t1: t2_0
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 LD_EXTRAS="-L. -lt2_0"
+
+t2_0:
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
+
+t2_1:
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1
Index: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
===
--- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,7 +578,19 @@
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
+  //
+  // Use lazy binding so as to not make dlopen()'s success conditional on
+  // forcing every symbol in the library.
+  //
+  // In general, the debugger should allow programs to load & run with
+  // libraries as far as they can, instead of defaulting to being super-picky
+  // about u

[Lldb-commits] [PATCH] D98879: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98879

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


[Lldb-commits] [lldb] e089b5e - [lldb] Call os_log_fault on lldb_assert

2021-03-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-19T14:23:50-07:00
New Revision: e089b5e9e11a61be0a11378f8df9af806807bddc

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

LOG: [lldb] Call os_log_fault on lldb_assert

Call `os_log_fault` when an lldb assert fails. We piggyback off
`LLVM_SUPPORT_XCODE_SIGNPOSTS`, which also depends on `os_log`, to avoid
having to introduce another CMake check and corresponding define.

This patch also adds a small test using lldb-test that verifies we abort
with a "regular" assertion when asserts are enabled.

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

Added: 
lldb/test/Shell/Error/assert.test

Modified: 
lldb/include/lldb/Utility/LLDBAssert.h
lldb/source/Utility/LLDBAssert.cpp
lldb/tools/lldb-test/lldb-test.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/LLDBAssert.h 
b/lldb/include/lldb/Utility/LLDBAssert.h
index 845af1d4cc2a..471a2f7e824f 100644
--- a/lldb/include/lldb/Utility/LLDBAssert.h
+++ b/lldb/include/lldb/Utility/LLDBAssert.h
@@ -20,6 +20,6 @@
 namespace lldb_private {
 void lldb_assert(bool expression, const char *expr_text, const char *func,
  const char *file, unsigned int line);
-}
+} // namespace lldb_private
 
 #endif // LLDB_UTILITY_LLDBASSERT_H

diff  --git a/lldb/source/Utility/LLDBAssert.cpp 
b/lldb/source/Utility/LLDBAssert.cpp
index 6ae0ee50ef14..532b56b6f59e 100644
--- a/lldb/source/Utility/LLDBAssert.cpp
+++ b/lldb/source/Utility/LLDBAssert.cpp
@@ -7,11 +7,15 @@
 
//===--===//
 
 #include "lldb/Utility/LLDBAssert.h"
-
+#include "llvm/Config/config.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 
+#if LLVM_SUPPORT_XCODE_SIGNPOSTS
+#include 
+#endif
+
 using namespace llvm;
 using namespace lldb_private;
 
@@ -24,6 +28,14 @@ void lldb_private::lldb_assert(bool expression, const char 
*expr_text,
   // If asserts are enabled abort here.
   assert(false && "lldb_assert failed");
 
+#if LLVM_SUPPORT_XCODE_SIGNPOSTS
+  if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
+os_log_fault(OS_LOG_DEFAULT,
+ "Assertion failed: (%s), function %s, file %s, line %u\n",
+ expr_text, func, file, line);
+  }
+#endif
+
   // In a release configuration it will print a warning and encourage the user
   // to file a bug report, similar to LLVM’s crash handler, and then return
   // execution.

diff  --git a/lldb/test/Shell/Error/assert.test 
b/lldb/test/Shell/Error/assert.test
new file mode 100644
index ..109795f6e8de
--- /dev/null
+++ b/lldb/test/Shell/Error/assert.test
@@ -0,0 +1,4 @@
+# REQUIRES: asserts
+# RUN: not --crash lldb-test assert > %t.error 2>&1
+# RUN: cat %t.error | FileCheck %s
+# CHECK: Assertion failed: (false && "lldb_assert failed")

diff  --git a/lldb/tools/lldb-test/lldb-test.cpp 
b/lldb/tools/lldb-test/lldb-test.cpp
index 842a951f384b..1109a6bb6558 100644
--- a/lldb/tools/lldb-test/lldb-test.cpp
+++ b/lldb/tools/lldb-test/lldb-test.cpp
@@ -29,6 +29,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -57,6 +58,7 @@ cl::SubCommand ObjectFileSubcommand("object-file",
 "Display LLDB object file information");
 cl::SubCommand SymbolsSubcommand("symbols", "Dump symbols for an object file");
 cl::SubCommand IRMemoryMapSubcommand("ir-memory-map", "Test IRMemoryMap");
+cl::SubCommand AssertSubcommand("assert", "Test assert handling");
 
 cl::opt Log("log", cl::desc("Path to a log file"), cl::init(""),
  cl::sub(BreakpointSubcommand),
@@ -236,6 +238,9 @@ bool evalFree(StringRef Line, IRMemoryMapTestState &State);
 int evaluateMemoryMapCommands(Debugger &Dbg);
 } // namespace irmemorymap
 
+namespace assert {
+int lldb_assert(Debugger &Dbg);
+} // namespace assert
 } // namespace opts
 
 std::vector parseCompilerContext() {
@@ -1077,6 +1082,11 @@ int 
opts::irmemorymap::evaluateMemoryMapCommands(Debugger &Dbg) {
   return 0;
 }
 
+int opts::assert::lldb_assert(Debugger &Dbg) {
+  lldbassert(false && "lldb-test assert");
+  return 1;
+}
+
 int main(int argc, const char *argv[]) {
   StringRef ToolName = argv[0];
   sys::PrintStackTraceOnErrorSignal(ToolName);
@@ -1120,6 +1130,8 @@ int main(int argc, const char *argv[]) {
 return opts::symbols::dumpSymbols(*Dbg);
   if (opts::IRMemoryMapSubcommand)
 return opts::irmemorymap::evaluateMemoryMapCommands(*Dbg);
+  if (opts::AssertSubcommand)
+return opts::assert::lldb_assert(*Dbg);
 
   WithColor::error() << 

[Lldb-commits] [PATCH] D98987: [lldb] Call os_log_fault on lldb_assert

2021-03-19 Thread Jonas Devlieghere 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 rGe089b5e9e11a: [lldb] Call os_log_fault on lldb_assert 
(authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98987

Files:
  lldb/include/lldb/Utility/LLDBAssert.h
  lldb/source/Utility/LLDBAssert.cpp
  lldb/test/Shell/Error/assert.test
  lldb/tools/lldb-test/lldb-test.cpp

Index: lldb/tools/lldb-test/lldb-test.cpp
===
--- lldb/tools/lldb-test/lldb-test.cpp
+++ lldb/tools/lldb-test/lldb-test.cpp
@@ -29,6 +29,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -57,6 +58,7 @@
 "Display LLDB object file information");
 cl::SubCommand SymbolsSubcommand("symbols", "Dump symbols for an object file");
 cl::SubCommand IRMemoryMapSubcommand("ir-memory-map", "Test IRMemoryMap");
+cl::SubCommand AssertSubcommand("assert", "Test assert handling");
 
 cl::opt Log("log", cl::desc("Path to a log file"), cl::init(""),
  cl::sub(BreakpointSubcommand),
@@ -236,6 +238,9 @@
 int evaluateMemoryMapCommands(Debugger &Dbg);
 } // namespace irmemorymap
 
+namespace assert {
+int lldb_assert(Debugger &Dbg);
+} // namespace assert
 } // namespace opts
 
 std::vector parseCompilerContext() {
@@ -1077,6 +1082,11 @@
   return 0;
 }
 
+int opts::assert::lldb_assert(Debugger &Dbg) {
+  lldbassert(false && "lldb-test assert");
+  return 1;
+}
+
 int main(int argc, const char *argv[]) {
   StringRef ToolName = argv[0];
   sys::PrintStackTraceOnErrorSignal(ToolName);
@@ -1120,6 +1130,8 @@
 return opts::symbols::dumpSymbols(*Dbg);
   if (opts::IRMemoryMapSubcommand)
 return opts::irmemorymap::evaluateMemoryMapCommands(*Dbg);
+  if (opts::AssertSubcommand)
+return opts::assert::lldb_assert(*Dbg);
 
   WithColor::error() << "No command specified.\n";
   return 1;
Index: lldb/test/Shell/Error/assert.test
===
--- /dev/null
+++ lldb/test/Shell/Error/assert.test
@@ -0,0 +1,4 @@
+# REQUIRES: asserts
+# RUN: not --crash lldb-test assert > %t.error 2>&1
+# RUN: cat %t.error | FileCheck %s
+# CHECK: Assertion failed: (false && "lldb_assert failed")
Index: lldb/source/Utility/LLDBAssert.cpp
===
--- lldb/source/Utility/LLDBAssert.cpp
+++ lldb/source/Utility/LLDBAssert.cpp
@@ -7,11 +7,15 @@
 //===--===//
 
 #include "lldb/Utility/LLDBAssert.h"
-
+#include "llvm/Config/config.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 
+#if LLVM_SUPPORT_XCODE_SIGNPOSTS
+#include 
+#endif
+
 using namespace llvm;
 using namespace lldb_private;
 
@@ -24,6 +28,14 @@
   // If asserts are enabled abort here.
   assert(false && "lldb_assert failed");
 
+#if LLVM_SUPPORT_XCODE_SIGNPOSTS
+  if (__builtin_available(macos 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
+os_log_fault(OS_LOG_DEFAULT,
+ "Assertion failed: (%s), function %s, file %s, line %u\n",
+ expr_text, func, file, line);
+  }
+#endif
+
   // In a release configuration it will print a warning and encourage the user
   // to file a bug report, similar to LLVM’s crash handler, and then return
   // execution.
Index: lldb/include/lldb/Utility/LLDBAssert.h
===
--- lldb/include/lldb/Utility/LLDBAssert.h
+++ lldb/include/lldb/Utility/LLDBAssert.h
@@ -20,6 +20,6 @@
 namespace lldb_private {
 void lldb_assert(bool expression, const char *expr_text, const char *func,
  const char *file, unsigned int line);
-}
+} // namespace lldb_private
 
 #endif // LLDB_UTILITY_LLDBASSERT_H
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] cdac601 - [lldb] Update assert.test to be less strict

2021-03-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-19T14:31:56-07:00
New Revision: cdac60107db9f04b27077379259678adf6f03617

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

LOG: [lldb] Update assert.test to be less strict

Be less strict when checking for the assert substring.

Added: 


Modified: 
lldb/test/Shell/Error/assert.test

Removed: 




diff  --git a/lldb/test/Shell/Error/assert.test 
b/lldb/test/Shell/Error/assert.test
index 109795f6e8de..92ccd134b92d 100644
--- a/lldb/test/Shell/Error/assert.test
+++ b/lldb/test/Shell/Error/assert.test
@@ -1,4 +1,4 @@
 # REQUIRES: asserts
 # RUN: not --crash lldb-test assert > %t.error 2>&1
 # RUN: cat %t.error | FileCheck %s
-# CHECK: Assertion failed: (false && "lldb_assert failed")
+# CHECK: "lldb_assert failed"



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


[Lldb-commits] [PATCH] D98879: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added a comment.

🚢


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98879

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


[Lldb-commits] [lldb] cb8c1ee - [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-03-19T15:13:43-07:00
New Revision: cb8c1ee269da72eb6e2c18800cd8ab0a74050785

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

LOG: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

In general, it seems like the debugger should allow programs to load & run with
libraries as far as possible, instead of defaulting to being super-picky about
unavailable symbols.

This is critical on macOS/Darwin, as libswiftCore.dylib may 1) export a version
symbol using @available markup and then 2) expect that other exported APIs are
only dynamically used once the version symbol is checked. We can't open a
version of the library built with a bleeding-edge SDK on an older OS without
RTLD_LAXY (or pervasive/expensive @available markup added to dyld APIs).

See: https://lists.llvm.org/pipermail/lldb-dev/2021-March/016796.html

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

Added: 
lldb/test/API/functionalities/load_lazy/Makefile
lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
lldb/test/API/functionalities/load_lazy/categories
lldb/test/API/functionalities/load_lazy/main.cpp
lldb/test/API/functionalities/load_lazy/t1.c
lldb/test/API/functionalities/load_lazy/t2_0.c
lldb/test/API/functionalities/load_lazy/t2_1.c

Modified: 
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index c8a006001fcb..3e5f1451ef5f 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,7 +578,19 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
+  //
+  // Use lazy binding so as to not make dlopen()'s success conditional on
+  // forcing every symbol in the library.
+  //
+  // In general, the debugger should allow programs to load & run with
+  // libraries as far as they can, instead of defaulting to being super-picky
+  // about unavailable symbols.
+  //
+  // The value "1" appears to imply lazy binding (RTLD_LAZY) on both Darwin
+  // and other POSIX OSes.
   static const char *dlopen_wrapper_code = R"(
+  const int RTLD_LAZY = 1;
+
   struct __lldb_dlopen_result {
 void *image_ptr;
 const char *error_str;
@@ -595,7 +607,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   {
 // This is the case where the name is the full path:
 if (!path_strings) {
-  result_ptr->image_ptr = dlopen(name, 2);
+  result_ptr->image_ptr = dlopen(name, RTLD_LAZY);
   if (result_ptr->image_ptr)
 result_ptr->error_str = nullptr;
   return nullptr;
@@ -609,7 +621,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   buffer[path_len] = '/';
   char *target_ptr = buffer+path_len+1; 
   memcpy((void *) target_ptr, (void *) name, name_len + 1);
-  result_ptr->image_ptr = dlopen(buffer, 2);
+  result_ptr->image_ptr = dlopen(buffer, RTLD_LAZY);
   if (result_ptr->image_ptr) {
 result_ptr->error_str = nullptr;
 break;

diff  --git a/lldb/test/API/functionalities/load_lazy/Makefile 
b/lldb/test/API/functionalities/load_lazy/Makefile
new file mode 100644
index ..14eff232bb6d
--- /dev/null
+++ b/lldb/test/API/functionalities/load_lazy/Makefile
@@ -0,0 +1,17 @@
+CXX_SOURCES := main.cpp
+
+all: t2_0 t2_1 t1 a.out
+
+include Makefile.rules
+
+t1: t2_0
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
+
+t2_0:
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
+
+t2_1:
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1

diff  --git a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py 
b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
new file mode 100644
index ..18135a18bdaf
--- /dev/null
+++ b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
@@ -0,0 +1,54 @@
+"""
+Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
+"""
+
+
+
+import os
+import shutil
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+class LoadUsingLazyBind(TestBase):
+
+mydir = Test

[Lldb-commits] [PATCH] D98879: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Vedant Kumar 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 rGcb8c1ee269da: [lldb/PlatformPOSIX] Change LoadImage default 
to RTLD_LAZY (authored by vsk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98879

Files:
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/test/API/functionalities/load_lazy/Makefile
  lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
  lldb/test/API/functionalities/load_lazy/categories
  lldb/test/API/functionalities/load_lazy/main.cpp
  lldb/test/API/functionalities/load_lazy/t1.c
  lldb/test/API/functionalities/load_lazy/t2_0.c
  lldb/test/API/functionalities/load_lazy/t2_1.c

Index: lldb/test/API/functionalities/load_lazy/t2_0.c
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/t2_0.c
@@ -0,0 +1 @@
+void use() {}
Index: lldb/test/API/functionalities/load_lazy/t1.c
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/t1.c
@@ -0,0 +1,3 @@
+extern void use();
+void f1() {}
+void f2() { use(); }
Index: lldb/test/API/functionalities/load_lazy/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0; // break here
+}
Index: lldb/test/API/functionalities/load_lazy/categories
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/categories
@@ -0,0 +1 @@
+basic_process
Index: lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
@@ -0,0 +1,54 @@
+"""
+Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
+"""
+
+
+
+import os
+import shutil
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+class LoadUsingLazyBind(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+# Invoke the default build rule.
+self.build()
+
+self.wd = os.path.realpath(self.getBuildDir())
+
+self.ext = 'so'
+if self.platformIsDarwin():
+self.ext = 'dylib'
+
+# Overwrite t2_0 with t2_1 to delete the definition of `use`.
+shutil.copy(os.path.join(self.wd, 'libt2_1.{}'.format(self.ext)),
+os.path.join(self.wd, 'libt2_0.{}'.format(self.ext)))
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+def test_load_using_lazy_bind(self):
+"""Test that we load using RTLD_LAZY"""
+
+(target, process, thread, _) = lldbutil.run_to_source_breakpoint(self,
+"break here",
+lldb.SBFileSpec("main.cpp"))
+error = lldb.SBError()
+lib_spec = lldb.SBFileSpec("libt1.{}".format(self.ext))
+paths = lldb.SBStringList()
+paths.AppendString(self.wd)
+out_spec = lldb.SBFileSpec()
+token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error)
+self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token")
Index: lldb/test/API/functionalities/load_lazy/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/Makefile
@@ -0,0 +1,17 @@
+CXX_SOURCES := main.cpp
+
+all: t2_0 t2_1 t1 a.out
+
+include Makefile.rules
+
+t1: t2_0
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 LD_EXTRAS="-L. -lt2_0"
+
+t2_0:
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
+
+t2_1:
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1
Index: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
===
--- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,7 +578,19 @@
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
+  //
+  // Use lazy binding so as to not make dlopen()'s success conditional on
+  // forcing every symbol in the library.
+  //
+  // In general, the debugger

[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

In D98822#2637871 , @jingham wrote:

> The gdb model - since gdb only supports one debugee per gdb - is to either 
> follow the fork or follow the parent.  It would be more in keeping with 
> lldb's model to make a new target for the child side of the fork, and use 
> that to follow the child.  That way you can continue to debug both the parent 
> and the child processes.  It doesn't look like you've gotten that far yet, 
> but IMO that's the direction we should be going for lldb.

Long-term, sure. Between life and deadlines, we're only working on the simpler 
one process model right now.


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

https://reviews.llvm.org/D98822

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


[Lldb-commits] [PATCH] D98822: [lldb] follow-fork/vfork support [WIP]

2021-03-19 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 332013.
mgorny added a comment.

Add a super-trivial test that the debugger doesn't lose parent after the fork.

Next on the list: clear software breakpoints in the detached fork.


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

https://reviews.llvm.org/D98822

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/include/lldb/Host/linux/Host.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Host/linux/Host.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/test/Shell/Subprocess/Inputs/fork.c
  lldb/test/Shell/Subprocess/fork-follow-parent.test

Index: lldb/test/Shell/Subprocess/fork-follow-parent.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/fork-follow-parent.test
@@ -0,0 +1,12 @@
+# Verify that the debugger continues tracing the parent after fork().
+# REQUIRES: native
+# RUN: %clang_host %p/Inputs/fork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+b parent_func
+process launch
+# CHECK: function run in child
+# CHECK-NOT: function run in parent
+# CHECK: stop reason = breakpoint
+continue
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/Inputs/fork.c
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/Inputs/fork.c
@@ -0,0 +1,37 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+void common_func() {
+  printf("common function\n");
+}
+
+void parent_func() {
+  printf("function run in parent\n");
+}
+
+void child_func() {
+  printf("function run in child\n");
+}
+
+int main() {
+  pid_t pid = fork();
+  assert(pid != -1);
+
+  common_func();
+  if (pid == 0) {
+child_func();
+_exit(0);
+  }
+
+  parent_func();
+  int status;
+  pid_t waited = waitpid(pid, &status, 0);
+  assert(waited == pid);
+  assert(WIFEXITED(status));
+  printf("child exited: %d\n", WEXITSTATUS(status));
+
+  return 0;
+}
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -201,6 +201,8 @@
 
   PacketResult Handle_g(StringExtractorGDBRemote &packet);
 
+  PacketResult Handle_qSupported_LLGS(StringExtractorGDBRemote &packet);
+
   void SetCurrentThreadID(lldb::tid_t tid);
 
   lldb::tid_t GetCurrentThreadID() const;
@@ -219,6 +221,9 @@
 
   static std::string XMLEncodeAttributeValue(llvm::StringRef value);
 
+  llvm::SmallVector
+  HandleFeatures(const llvm::ArrayRef client_features) override;
+
 private:
   llvm::Expected> BuildTargetXml();
 
@@ -255,6 +260,9 @@
   bool allow_any = false,
   bool allow_all = false);
 
+  // Call SetEnabledExtensions() with appropriate flags on the process.
+  void SetEnabledExtensions(NativeProcessProtocol& process);
+
   // For GDBRemoteCommunicationServerLLGS only
   GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) =
   delete;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -254,6 +254,8 @@
 m_debugged_process_up = std::move(*process_or);
   }
 
+  SetEnabledExtensions(*m_debugged_process_up);
+
   // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as
   // needed. llgs local-process debugging may specify PTY paths, which will
   // make these file actions non-null process launch -i/e/o will also make
@@ -321,6 +323,7 @@
 return status;
   }
   m_debugged_process_up = std::move(*process_or);
+  SetEnabledExtensions(*m_debugged_process_up);
 
   // Setup stdout/stderr mapping from inferior.
   auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
@@ -3703,3 +3706,29 @@
 
   return tid;
 }
+
+llvm::SmallVector
+GDBRemoteCommunicationServerLLGS::HandleFeatures(
+const llvm::ArrayRef client_features) {
+  auto ret =
+  GDBRemoteCommunicationServerCommon::HandleFeatures(client_features);
+  if (m_deb

[Lldb-commits] [lldb] d8d5ef2 - Revert "[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY"

2021-03-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-03-19T15:26:16-07:00
New Revision: d8d5ef2e9d84fbbc2878b3fd977f9c62ea0661d7

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

LOG: Revert "[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY"

This reverts commit cb8c1ee269da72eb6e2c18800cd8ab0a74050785. The test
is failing on Debian for unknown reasons.

https://lab.llvm.org/buildbot/#/builders/68/builds/8990

Added: 


Modified: 
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp

Removed: 
lldb/test/API/functionalities/load_lazy/Makefile
lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
lldb/test/API/functionalities/load_lazy/categories
lldb/test/API/functionalities/load_lazy/main.cpp
lldb/test/API/functionalities/load_lazy/t1.c
lldb/test/API/functionalities/load_lazy/t2_0.c
lldb/test/API/functionalities/load_lazy/t2_1.c



diff  --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 3e5f1451ef5f..c8a006001fcb 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,19 +578,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
-  //
-  // Use lazy binding so as to not make dlopen()'s success conditional on
-  // forcing every symbol in the library.
-  //
-  // In general, the debugger should allow programs to load & run with
-  // libraries as far as they can, instead of defaulting to being super-picky
-  // about unavailable symbols.
-  //
-  // The value "1" appears to imply lazy binding (RTLD_LAZY) on both Darwin
-  // and other POSIX OSes.
   static const char *dlopen_wrapper_code = R"(
-  const int RTLD_LAZY = 1;
-
   struct __lldb_dlopen_result {
 void *image_ptr;
 const char *error_str;
@@ -607,7 +595,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   {
 // This is the case where the name is the full path:
 if (!path_strings) {
-  result_ptr->image_ptr = dlopen(name, RTLD_LAZY);
+  result_ptr->image_ptr = dlopen(name, 2);
   if (result_ptr->image_ptr)
 result_ptr->error_str = nullptr;
   return nullptr;
@@ -621,7 +609,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   buffer[path_len] = '/';
   char *target_ptr = buffer+path_len+1; 
   memcpy((void *) target_ptr, (void *) name, name_len + 1);
-  result_ptr->image_ptr = dlopen(buffer, RTLD_LAZY);
+  result_ptr->image_ptr = dlopen(buffer, 2);
   if (result_ptr->image_ptr) {
 result_ptr->error_str = nullptr;
 break;

diff  --git a/lldb/test/API/functionalities/load_lazy/Makefile 
b/lldb/test/API/functionalities/load_lazy/Makefile
deleted file mode 100644
index 14eff232bb6d..
--- a/lldb/test/API/functionalities/load_lazy/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-CXX_SOURCES := main.cpp
-
-all: t2_0 t2_1 t1 a.out
-
-include Makefile.rules
-
-t1: t2_0
-   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
-
-t2_0:
-   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
-
-t2_1:
-   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1

diff  --git a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py 
b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
deleted file mode 100644
index 18135a18bdaf..
--- a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
+++ /dev/null
@@ -1,54 +0,0 @@
-"""
-Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
-"""
-
-
-
-import os
-import shutil
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-@skipIfRemote
-@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
-class LoadUsingLazyBind(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-NO_DEBUG_INFO_TESTCASE = True
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-
-# Invoke the default build rule.
-self.build()
-
-self.wd = os.path.realpath(self.getBuildDir())
-
-self.ext = 'so'
-if self.platformIsDarwin():
-self.ext = 'dylib'
-
-# Overwrite t2_0 with t2_1 to delete the definition of `use`.
-shutil.copy(os.path.join(self.wd, 'libt2_1.{}'.fo

[Lldb-commits] [PATCH] D98879: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 332024.
vsk added a comment.

Add asserts checking that the library paths exist, and restrict the test to 
Darwin. See https://bugs.llvm.org/show_bug.cgi?id=49656


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

https://reviews.llvm.org/D98879

Files:
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/test/API/.lit_test_times.txt
  lldb/test/API/functionalities/load_lazy/Makefile
  lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
  lldb/test/API/functionalities/load_lazy/categories
  lldb/test/API/functionalities/load_lazy/main.cpp
  lldb/test/API/functionalities/load_lazy/t1.c
  lldb/test/API/functionalities/load_lazy/t2_0.c
  lldb/test/API/functionalities/load_lazy/t2_1.c

Index: lldb/test/API/functionalities/load_lazy/t2_0.c
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/t2_0.c
@@ -0,0 +1 @@
+void use() {}
Index: lldb/test/API/functionalities/load_lazy/t1.c
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/t1.c
@@ -0,0 +1,3 @@
+extern void use();
+int f1() { return 5; }
+void f2() { use(); }
Index: lldb/test/API/functionalities/load_lazy/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0; // break here
+}
Index: lldb/test/API/functionalities/load_lazy/categories
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/categories
@@ -0,0 +1 @@
+basic_process
Index: lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
@@ -0,0 +1,65 @@
+"""
+Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
+"""
+
+
+
+import os
+import shutil
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LoadUsingLazyBind(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+# Failing for unknown reasons on Linux, see
+# https://bugs.llvm.org/show_bug.cgi?id=49656.
+@skipUnlessDarwin
+def test_load_using_lazy_bind(self):
+"""Test that we load using RTLD_LAZY"""
+
+self.build()
+wd = os.path.realpath(self.getBuildDir())
+
+ext = '.so'
+if self.platformIsDarwin():
+ext = '.dylib'
+
+def make_lib_path(name):
+libpath = os.path.join(wd, name + ext)
+self.assertTrue(os.path.exists(libpath))
+return libpath
+
+libt1 = make_lib_path('libt1')
+libt2_0 = make_lib_path('libt2_0')
+libt2_1 = make_lib_path('libt2_1')
+
+# Overwrite t2_0 with t2_1 to delete the definition of `use`.
+shutil.copy(libt2_1, libt2_0)
+
+# Launch a process and break
+(target, process, thread, _) = lldbutil.run_to_source_breakpoint(self,
+"break here",
+lldb.SBFileSpec("main.cpp"))
+
+# Load libt1; should fail unless we use RTLD_LAZY
+error = lldb.SBError()
+lib_spec = lldb.SBFileSpec('libt1' + ext)
+paths = lldb.SBStringList()
+paths.AppendString(wd)
+out_spec = lldb.SBFileSpec()
+token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error)
+self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token")
+
+# Calling `f1()` should return 5.
+frame = thread.GetFrameAtIndex(0)
+val = frame.EvaluateExpression("f1()")
+self.assertTrue(val.IsValid())
+self.assertEquals(val.GetValueAsSigned(-1), 5)
Index: lldb/test/API/functionalities/load_lazy/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/load_lazy/Makefile
@@ -0,0 +1,18 @@
+CXX_SOURCES := main.cpp
+USE_LIBDL := 1
+
+all: t2_0 t2_1 t1 a.out
+
+include Makefile.rules
+
+t1: t2_0
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 LD_EXTRAS="-L. -lt2_0"
+
+t2_0:
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
+
+t2_1:
+	$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1
Index: lldb/test/API/.lit_test_times.txt
===
--- /dev/null
+++ lldb/test/API/.lit_test_times.txt
@@ -0,0 +1 @@
+2.777875e+00 functionalities/load_lazy/TestL

[Lldb-commits] [lldb] 4bd2bfb - [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY (reapply)

2021-03-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-03-19T16:06:00-07:00
New Revision: 4bd2bfb6ec0980853d7f9d1874e0547b68b7a61e

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

LOG: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY (reapply)

In general, it seems like the debugger should allow programs to load & run with
libraries as far as possible, instead of defaulting to being super-picky about
unavailable symbols.

This is critical on macOS/Darwin, as libswiftCore.dylib may 1) export a version
symbol using @available markup and then 2) expect that other exported APIs are
only dynamically used once the version symbol is checked. We can't open a
version of the library built with a bleeding-edge SDK on an older OS without
RTLD_LAXY (or pervasive/expensive @available markup added to dyld APIs).

This was previously committed as cb8c1ee269da and reverted due to
unknown failures on the Linux bots. This version adds additional asserts
to check that the shared objects are where we expect them & that calling
f1() from libt1 produces the expected value. The Linux failure is
tracked by https://bugs.llvm.org/show_bug.cgi?id=49656.

See: https://lists.llvm.org/pipermail/lldb-dev/2021-March/016796.html

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

Added: 
lldb/test/API/.lit_test_times.txt
lldb/test/API/functionalities/load_lazy/Makefile
lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
lldb/test/API/functionalities/load_lazy/categories
lldb/test/API/functionalities/load_lazy/main.cpp
lldb/test/API/functionalities/load_lazy/t1.c
lldb/test/API/functionalities/load_lazy/t2_0.c
lldb/test/API/functionalities/load_lazy/t2_1.c

Modified: 
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index c8a006001fcb..3e5f1451ef5f 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,7 +578,19 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
+  //
+  // Use lazy binding so as to not make dlopen()'s success conditional on
+  // forcing every symbol in the library.
+  //
+  // In general, the debugger should allow programs to load & run with
+  // libraries as far as they can, instead of defaulting to being super-picky
+  // about unavailable symbols.
+  //
+  // The value "1" appears to imply lazy binding (RTLD_LAZY) on both Darwin
+  // and other POSIX OSes.
   static const char *dlopen_wrapper_code = R"(
+  const int RTLD_LAZY = 1;
+
   struct __lldb_dlopen_result {
 void *image_ptr;
 const char *error_str;
@@ -595,7 +607,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   {
 // This is the case where the name is the full path:
 if (!path_strings) {
-  result_ptr->image_ptr = dlopen(name, 2);
+  result_ptr->image_ptr = dlopen(name, RTLD_LAZY);
   if (result_ptr->image_ptr)
 result_ptr->error_str = nullptr;
   return nullptr;
@@ -609,7 +621,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   buffer[path_len] = '/';
   char *target_ptr = buffer+path_len+1; 
   memcpy((void *) target_ptr, (void *) name, name_len + 1);
-  result_ptr->image_ptr = dlopen(buffer, 2);
+  result_ptr->image_ptr = dlopen(buffer, RTLD_LAZY);
   if (result_ptr->image_ptr) {
 result_ptr->error_str = nullptr;
 break;

diff  --git a/lldb/test/API/.lit_test_times.txt 
b/lldb/test/API/.lit_test_times.txt
new file mode 100644
index ..5b848a0183c9
--- /dev/null
+++ b/lldb/test/API/.lit_test_times.txt
@@ -0,0 +1 @@
+2.777875e+00 functionalities/load_lazy/TestLoadUsingLazyBind.py

diff  --git a/lldb/test/API/functionalities/load_lazy/Makefile 
b/lldb/test/API/functionalities/load_lazy/Makefile
new file mode 100644
index ..7200114d03ae
--- /dev/null
+++ b/lldb/test/API/functionalities/load_lazy/Makefile
@@ -0,0 +1,18 @@
+CXX_SOURCES := main.cpp
+USE_LIBDL := 1
+
+all: t2_0 t2_1 t1 a.out
+
+include Makefile.rules
+
+t1: t2_0
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
+
+t2_0:
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
+
+t2_1:
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1

diff

[Lldb-commits] [PATCH] D98842: [lldb] Make the api, shell and unit tests independent lit test suites

2021-03-19 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

This did end up breaking the windows build bot...

https://lab.llvm.org/buildbot/#/builders/83/builds/4808


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98842

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


[Lldb-commits] [PATCH] D98842: [lldb] Make the api, shell and unit tests independent lit test suites

2021-03-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D98842#2638929 , @stella.stamenova 
wrote:

> This did end up breaking the windows build bot...
>
> https://lab.llvm.org/buildbot/#/builders/83/builds/4808

Thanks, the error message suggests the tests are run twice and the log shows 
every test failing twice. Let me try adding `EXCLUDE_FROM_CHECK_ALL` to 
`add_lit_testsuites` as well. It didn't change anything on macOS, but maybe it 
does on Windows. If that doesn't fix it I'll revert to turn the bot green again 
over the weekend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98842

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


[Lldb-commits] [PATCH] D98996: Teach DWARFExpression about DWARF 4+ Location Descriptions

2021-03-19 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jasonmolenda, JDevlieghere, labath.
aprantl requested review of this revision.

DWARFExpression implements the DWARF2 expression model that left ambiguity on 
whether the result of an expression was a value or an address. This patch 
implements the DWARF location description model introduces in DWARF 4 and sets 
the result Value's kind accordingly, if the expression comes from a DWARF v4+ 
compile unit. The nomenclature is taken from DWARF 5, chapter 2.6 "Location 
Descriptions".


https://reviews.llvm.org/D98996

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp

Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -213,42 +213,45 @@
   //
 
   // Leave as is.
-  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
-   DW_OP_convert, offs_uint32_t}),
-   llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
+  EXPECT_THAT_EXPECTED(
+  t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
+  DW_OP_convert, offs_uint32_t, DW_OP_stack_value}),
+  llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
 
   // Zero-extend to 64 bits.
-  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
-   DW_OP_convert, offs_uint64_t}),
-   llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
+  EXPECT_THAT_EXPECTED(
+  t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
+  DW_OP_convert, offs_uint64_t, DW_OP_stack_value}),
+  llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
 
   // Sign-extend to 64 bits.
   EXPECT_THAT_EXPECTED(
   t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
-  DW_OP_convert, offs_sint64_t}),
+  DW_OP_convert, offs_sint64_t, DW_OP_stack_value}),
   llvm::HasValue(GetScalar(64, 0xffeeddcc, is_signed)));
 
   // Sign-extend, then truncate.
-  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
-   DW_OP_convert, offs_sint64_t,  //
-   DW_OP_convert, offs_uint32_t}),
-   llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
+  EXPECT_THAT_EXPECTED(
+  t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
+  DW_OP_convert, offs_sint64_t,  //
+  DW_OP_convert, offs_uint32_t, DW_OP_stack_value}),
+  llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
 
   // Truncate to default unspecified (pointer-sized) type.
   EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
DW_OP_convert, offs_sint64_t,  //
-   DW_OP_convert, 0x00}),
+   DW_OP_convert, 0x00, DW_OP_stack_value}),
llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
 
   // Truncate to 8 bits.
-  EXPECT_THAT_EXPECTED(
-  t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert, offs_uchar}),
-  llvm::HasValue(GetScalar(8, 'A', not_signed)));
+  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert,
+   offs_uchar, DW_OP_stack_value}),
+   llvm::HasValue(GetScalar(8, 'A', not_signed)));
 
   // Also truncate to 8 bits.
-  EXPECT_THAT_EXPECTED(
-  t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert, offs_schar}),
-  llvm::HasValue(GetScalar(8, 'A', is_signed)));
+  EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert,
+   offs_schar, DW_OP_stack_value}),
+   llvm::HasValue(GetScalar(8, 'A', is_signed)));
 
   //
   // Errors.
@@ -354,4 +357,13 @@
   // Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
   EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4, DW_OP_deref}, {}, {}, &exe_ctx),
llvm::HasValue(Scalar(LLDB_INVALID_ADDRESS)));
+  // Memory location: *(*0x4).
+  // Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
+  EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4}, {}, {}, &exe_ctx),
+   llvm::HasValue(Scalar(4)));
+  // Memory location: *(*0x4).
+  // Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
+  EXPECT_THAT_EXPECTED(
+  Evaluate({DW_OP_lit4, DW_OP_deref, DW_OP_stack_value}, {}, {}, &exe_ctx),
+  llvm::HasValue(GetScalar(32, 0x07060504, false)));
 }
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -952,9 +952,59 @@
 !is_signed));
   };
 
+  enum L

[Lldb-commits] [lldb] e76b866 - Revert "[lldb] Make the API, Shell and Unit tests independent lit test suites"

2021-03-19 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-19T17:57:26-07:00
New Revision: e76b86642f51c868c307d097cb129df1b1ac6423

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

LOG: Revert "[lldb] Make the API, Shell and Unit tests independent lit test 
suites"

This reverts commit 6c52d4fd4c24a0cf738e44516ca8378d65dcf019.

Added: 


Modified: 
lldb/test/API/CMakeLists.txt
lldb/test/API/lit.cfg.py
lldb/test/API/lit.site.cfg.py.in
lldb/test/CMakeLists.txt
lldb/test/Shell/CMakeLists.txt
lldb/test/Unit/CMakeLists.txt
lldb/unittests/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 2b7dba456b1a..0dbc46defc81 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -1,10 +1,3 @@
-add_custom_target(lldb-api-test-deps)
-add_dependencies(lldb-api-test-deps lldb-test-deps)
-
-add_lit_testsuites(LLDB-API
-  ${CMAKE_CURRENT_SOURCE_DIR}
-  DEPENDS lldb-api-test-deps)
-
 function(add_python_test_target name test_script args comment)
   set(PYTHON_TEST_COMMAND
 ${Python3_EXECUTABLE}
@@ -160,35 +153,39 @@ string(REPLACE ${CMAKE_CFG_INTDIR} 
${dotest_args_replacement} LLDB_TEST_EXECUTAB
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
 string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} 
LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
 
+# Configure the API test suite.
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
+if (CMAKE_GENERATOR STREQUAL "Xcode")
+  # Xcode does not get the auto-generated targets. We need to create
+  # check-lldb-api manually.
+  add_lit_testsuite(check-lldb-api "Running lldb api test suite"
+${CMAKE_CURRENT_BINARY_DIR}
+DEPENDS lldb-test-deps)
+endif()
+
 # Targets for running the test suite on the 
diff erent Apple simulators.
 add_lit_testsuite(check-lldb-simulator-ios
   "Running lldb test suite on the iOS simulator"
   ${CMAKE_CURRENT_BINARY_DIR}
   PARAMS "lldb-run-with-simulator=ios"
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-api-test-deps)
+  DEPENDS lldb-test-deps)
 
 add_lit_testsuite(check-lldb-simulator-watchos
   "Running lldb test suite on the watchOS simulator"
   ${CMAKE_CURRENT_BINARY_DIR}
   PARAMS "lldb-run-with-simulator=watchos"
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-api-test-deps)
+  DEPENDS lldb-test-deps)
 
 add_lit_testsuite(check-lldb-simulator-tvos
   "Running lldb test suite on the tvOS simulator"
   ${CMAKE_CURRENT_BINARY_DIR}
   PARAMS "lldb-run-with-simulator=tvos"
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-api-test-deps)
-
-add_lit_testsuite(check-lldb-api "Running lldb api test suite"
-  ${CMAKE_CURRENT_BINARY_DIR}
-  EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-api-test-deps)
+  DEPENDS lldb-test-deps)

diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 1bd7dc35fb2a..54a02453b174 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -17,10 +17,9 @@
 config.suffixes = ['.py']
 
 # test_source_root: The root path where tests are located.
-config.test_source_root = os.path.dirname(__file__)
-
 # test_exec_root: The root path where tests should be run.
-config.test_exec_root = os.path.join(config.lldb_obj_root, 'test')
+config.test_source_root = os.path.dirname(__file__)
+config.test_exec_root = config.test_source_root
 
 
 def mkdir_p(path):

diff  --git a/lldb/test/API/lit.site.cfg.py.in 
b/lldb/test/API/lit.site.cfg.py.in
index 49ea94aacd11..2e368325a9f0 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -1,5 +1,6 @@
 @LIT_SITE_CFG_IN_HEADER@
 
+config.test_exec_root = "@LLDB_BINARY_DIR@"
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"

diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index c6b01c66a0ef..8363bde23035 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -185,13 +185,19 @@ configure_lit_site_cfg(
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 
-add_lit_testsuite(check-lldb "Running lldb lit test suite"
+add_lit_testsuites(LLDB
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS lldb-test-deps)
+
+add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS
-lldb-api-test-deps
-lldb-shell-test-deps
-lldb-unit-test-deps)
-set_target_properties(check-lldb PROPERTIES FOLDER "lldb tests")
+  DEPENDS lldb-test-deps)
+set_target_properties(check-lldb-lit PROPERTIES FOLDER "lldb tests")
+
+add_custom_target(check-lldb)
+add_dependencies(check-lldb lldb-test-deps)
+set_target_properties(

Re: [Lldb-commits] [lldb] e76b866 - Revert "[lldb] Make the API, Shell and Unit tests independent lit test suites"

2021-03-19 Thread David Blaikie via lldb-commits
Would be great if you could include some detail in the commit message (or,
in this case, in a follow-up reply) about why the patch was reverted,
thanks!

On Fri, Mar 19, 2021 at 5:57 PM Jonas Devlieghere via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

>
> Author: Jonas Devlieghere
> Date: 2021-03-19T17:57:26-07:00
> New Revision: e76b86642f51c868c307d097cb129df1b1ac6423
>
> URL:
> https://github.com/llvm/llvm-project/commit/e76b86642f51c868c307d097cb129df1b1ac6423
> DIFF:
> https://github.com/llvm/llvm-project/commit/e76b86642f51c868c307d097cb129df1b1ac6423.diff
>
> LOG: Revert "[lldb] Make the API, Shell and Unit tests independent lit
> test suites"
>
> This reverts commit 6c52d4fd4c24a0cf738e44516ca8378d65dcf019.
>
> Added:
>
>
> Modified:
> lldb/test/API/CMakeLists.txt
> lldb/test/API/lit.cfg.py
> lldb/test/API/lit.site.cfg.py.in
> lldb/test/CMakeLists.txt
> lldb/test/Shell/CMakeLists.txt
> lldb/test/Unit/CMakeLists.txt
> lldb/unittests/CMakeLists.txt
>
> Removed:
>
>
>
>
> 
> diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
> index 2b7dba456b1a..0dbc46defc81 100644
> --- a/lldb/test/API/CMakeLists.txt
> +++ b/lldb/test/API/CMakeLists.txt
> @@ -1,10 +1,3 @@
> -add_custom_target(lldb-api-test-deps)
> -add_dependencies(lldb-api-test-deps lldb-test-deps)
> -
> -add_lit_testsuites(LLDB-API
> -  ${CMAKE_CURRENT_SOURCE_DIR}
> -  DEPENDS lldb-api-test-deps)
> -
>  function(add_python_test_target name test_script args comment)
>set(PYTHON_TEST_COMMAND
>  ${Python3_EXECUTABLE}
> @@ -160,35 +153,39 @@ string(REPLACE ${CMAKE_CFG_INTDIR}
> ${dotest_args_replacement} LLDB_TEST_EXECUTAB
>  string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement}
> LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}")
>  string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement}
> LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}")
>
> +# Configure the API test suite.
>  configure_lit_site_cfg(
>${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
>${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
>MAIN_CONFIG
>${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
>
> +if (CMAKE_GENERATOR STREQUAL "Xcode")
> +  # Xcode does not get the auto-generated targets. We need to create
> +  # check-lldb-api manually.
> +  add_lit_testsuite(check-lldb-api "Running lldb api test suite"
> +${CMAKE_CURRENT_BINARY_DIR}
> +DEPENDS lldb-test-deps)
> +endif()
> +
>  # Targets for running the test suite on the
> diff erent Apple simulators.
>  add_lit_testsuite(check-lldb-simulator-ios
>"Running lldb test suite on the iOS simulator"
>${CMAKE_CURRENT_BINARY_DIR}
>PARAMS "lldb-run-with-simulator=ios"
>EXCLUDE_FROM_CHECK_ALL
> -  DEPENDS lldb-api-test-deps)
> +  DEPENDS lldb-test-deps)
>
>  add_lit_testsuite(check-lldb-simulator-watchos
>"Running lldb test suite on the watchOS simulator"
>${CMAKE_CURRENT_BINARY_DIR}
>PARAMS "lldb-run-with-simulator=watchos"
>EXCLUDE_FROM_CHECK_ALL
> -  DEPENDS lldb-api-test-deps)
> +  DEPENDS lldb-test-deps)
>
>  add_lit_testsuite(check-lldb-simulator-tvos
>"Running lldb test suite on the tvOS simulator"
>${CMAKE_CURRENT_BINARY_DIR}
>PARAMS "lldb-run-with-simulator=tvos"
>EXCLUDE_FROM_CHECK_ALL
> -  DEPENDS lldb-api-test-deps)
> -
> -add_lit_testsuite(check-lldb-api "Running lldb api test suite"
> -  ${CMAKE_CURRENT_BINARY_DIR}
> -  EXCLUDE_FROM_CHECK_ALL
> -  DEPENDS lldb-api-test-deps)
> +  DEPENDS lldb-test-deps)
>
> diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
> index 1bd7dc35fb2a..54a02453b174 100644
> --- a/lldb/test/API/lit.cfg.py
> +++ b/lldb/test/API/lit.cfg.py
> @@ -17,10 +17,9 @@
>  config.suffixes = ['.py']
>
>  # test_source_root: The root path where tests are located.
> -config.test_source_root = os.path.dirname(__file__)
> -
>  # test_exec_root: The root path where tests should be run.
> -config.test_exec_root = os.path.join(config.lldb_obj_root, 'test')
> +config.test_source_root = os.path.dirname(__file__)
> +config.test_exec_root = config.test_source_root
>
>
>  def mkdir_p(path):
>
> diff  --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/
> lit.site.cfg.py.in
> index 49ea94aacd11..2e368325a9f0 100644
> --- a/lldb/test/API/lit.site.cfg.py.in
> +++ b/lldb/test/API/lit.site.cfg.py.in
> @@ -1,5 +1,6 @@
>  @LIT_SITE_CFG_IN_HEADER@
>
> +config.test_exec_root = "@LLDB_BINARY_DIR@"
>  config.llvm_src_root = "@LLVM_SOURCE_DIR@"
>  config.llvm_obj_root = "@LLVM_BINARY_DIR@"
>  config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
>
> diff  --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
> index c6b01c66a0ef..8363bde23035 100644
> --- a/lldb/test/CMakeLists.txt
> +++ b/lldb/test/CMakeLists.txt
> @@ -185,13 +185,19 @@ configure_lit_site_cfg(
>MAIN_CONFIG
>${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
>
> -add_lit_testsuite(check-lldb "Running lldb lit test suite"
> +add_lit_testsuites(LLDB
> +  ${CMAKE

[Lldb-commits] [PATCH] D98996: Teach DWARFExpression about DWARF 4+ Location Descriptions

2021-03-19 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

(idle question: Is this code remotely related to any code in LLVM's 
libDebugInfoDWARF? Does this patch take us closer to or further away from 
unifying them? If it takes us further away, any chance of designing it in a 
direction that points towards each other rather than away from?)


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

https://reviews.llvm.org/D98996

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


[Lldb-commits] [PATCH] D98996: Teach DWARFExpression about DWARF 4+ Location Descriptions

2021-03-19 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

This fits with my reading of the DWARF5 doc; LGTM.


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

https://reviews.llvm.org/D98996

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