[Lldb-commits] [lldb] af92100 - [lldb] Remove the global platform list

2022-04-13 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2022-04-13T14:41:13+02:00
New Revision: af921006d3792fa28d1070f015dcfd145e082ed2

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

LOG: [lldb] Remove the global platform list

This patch moves the platform creation and selection logic into the
per-debugger platform lists. I've tried to keep functional changes to a
minimum -- the main (only) observable difference in this change is that
APIs, which select a platform by name (e.g.,
Debugger::SetCurrentPlatform) will not automatically pick up a platform
associated with another debugger (or no debugger at all).

I've also added several tests for this functionality -- one of the
pleasant consequences of the debugger isolation is that it is now
possible to test the platform selection and creation logic.

This is a product of the discussion at
.

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

Added: 
lldb/test/API/python_api/debugger/elf.yaml
lldb/test/API/python_api/debugger/macho.yaml

Modified: 
lldb/include/lldb/Target/Platform.h
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/source/API/SBDebugger.cpp
lldb/source/API/SBPlatform.cpp
lldb/source/Interpreter/OptionGroupPlatform.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/Platform/POSIX/CMakeLists.txt
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/Windows/CMakeLists.txt
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TargetList.cpp
lldb/test/API/python_api/debugger/TestDebuggerAPI.py
lldb/test/API/python_api/sbplatform/TestSBPlatform.py
lldb/unittests/Platform/PlatformTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 3b02f44a7fe21..8b8ca6268071f 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -94,79 +94,11 @@ class Platform : public PluginInterface {
   /// attaching to processes unless another platform is specified.
   static lldb::PlatformSP GetHostPlatform();
 
-  /// Get the platform for the given architecture. See Platform::Create for how
-  /// a platform is chosen for a given architecture.
-  ///
-  /// \param[in] arch
-  /// The architecture for which we are getting a platform.
-  ///
-  /// \param[in] process_host_arch
-  /// The process host architecture if it's known. An invalid ArchSpec
-  /// represents that the process host architecture is unknown.
-  ///
-  /// \param[out] platform_arch_ptr
-  /// The architecture which was used to pick the returned platform. This
-  /// can be 
diff erent from the input architecture if we're looking for a
-  /// compatible match instead of an exact match.
-  ///
-  /// \return
-  /// Return the platform that matches the input architecture or the
-  /// default (invalid) platform if none could be found.
-  static lldb::PlatformSP
-  GetPlatformForArchitecture(const ArchSpec &arch,
- const ArchSpec &process_host_arch = {},
- ArchSpec *platform_arch_ptr = nullptr);
-
-  /// Get the platform for the given list of architectures.
-  ///
-  /// The algorithm works a follows:
-  ///
-  /// 1. Returns the selected platform if it matches any of the architectures.
-  /// 2. Returns the host platform if it matches any of the architectures.
-  /// 3. Returns the platform that matches all the architectures.
-  ///
-  /// If none of the above apply, this function returns a default platform. The
-  /// candidates output argument 
diff erentiates between either no platforms
-  /// supporting the given architecture or multiple platforms supporting the
-  /// given architecture.
-  ///
-  /// \param[in] arch
-  /// The architecture for which we are getting a platform.
-  ///
-  /// \param[in] process_host_arch
-  /// The process host architecture if it's known. An invalid ArchSpec
-  /// represents that the process host architecture is unknown.
-  ///
-  /// \param[in] selected_platform_sp
-  /// The currently selected platform.
-  ///
-  /// \param[out] candidates
-  /// A list of candidate platforms in case multiple platforms could
-  /// support the given list of architectures. If no platforms match the
-  /// given architecture the list will be empty.
-  ///
-  /// \return
-  /// Return the platform that matches the input architectures or the
-  /// default (invalid) p

[Lldb-commits] [PATCH] D120810: [lldb] Remove the global platform list

2022-04-13 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf921006d379: [lldb] Remove the global platform list 
(authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D120810?vs=420507&id=422489#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120810

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBPlatform.cpp
  lldb/source/Interpreter/OptionGroupPlatform.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/Platform/POSIX/CMakeLists.txt
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/Platform/Windows/CMakeLists.txt
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/gdb-server/CMakeLists.txt
  lldb/source/Target/Platform.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetList.cpp
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py
  lldb/test/API/python_api/debugger/elf.yaml
  lldb/test/API/python_api/debugger/macho.yaml
  lldb/test/API/python_api/sbplatform/TestSBPlatform.py
  lldb/unittests/Platform/PlatformTest.cpp

Index: lldb/unittests/Platform/PlatformTest.cpp
===
--- lldb/unittests/Platform/PlatformTest.cpp
+++ lldb/unittests/Platform/PlatformTest.cpp
@@ -21,7 +21,6 @@
 class TestPlatform : public PlatformPOSIX {
 public:
   TestPlatform() : PlatformPOSIX(false) {}
-  using Platform::Clear;
 };
 
 class PlatformArm : public TestPlatform {
@@ -75,67 +74,66 @@
 
 class PlatformTest : public ::testing::Test {
   SubsystemRAII subsystems;
-  void SetUp() override { TestPlatform::Clear(); }
+
+protected:
+  PlatformList list;
+
+  void SetHostPlatform(const PlatformSP &platform_sp) {
+Platform::SetHostPlatform(platform_sp);
+ASSERT_EQ(Platform::GetHostPlatform(), platform_sp);
+list.Append(platform_sp, /*set_selected=*/true);
+  }
 };
 
 TEST_F(PlatformTest, GetPlatformForArchitecturesHost) {
-  const PlatformSP host_platform_sp = std::make_shared();
-  Platform::SetHostPlatform(host_platform_sp);
-  ASSERT_EQ(Platform::GetHostPlatform(), host_platform_sp);
+  SetHostPlatform(std::make_shared());
 
   const std::vector archs = {ArchSpec("arm64-apple-ps4"),
ArchSpec("arm64e-apple-ps4")};
   std::vector candidates;
 
   // The host platform matches all architectures.
-  PlatformSP platform_sp =
-  Platform::GetPlatformForArchitectures(archs, {}, {}, candidates);
+  PlatformSP platform_sp = list.GetOrCreate(archs, {}, candidates);
   ASSERT_TRUE(platform_sp);
-  EXPECT_EQ(platform_sp, host_platform_sp);
+  EXPECT_EQ(platform_sp, Platform::GetHostPlatform());
 }
 
 TEST_F(PlatformTest, GetPlatformForArchitecturesSelected) {
-  const PlatformSP host_platform_sp = std::make_shared();
-  Platform::SetHostPlatform(host_platform_sp);
-  ASSERT_EQ(Platform::GetHostPlatform(), host_platform_sp);
+  SetHostPlatform(std::make_shared());
 
   const std::vector archs = {ArchSpec("arm64-apple-ps4"),
ArchSpec("arm64e-apple-ps4")};
   std::vector candidates;
 
-  // The host platform matches no architectures. No selected platform.
-  PlatformSP platform_sp =
-  Platform::GetPlatformForArchitectures(archs, {}, {}, candidates);
+  // The host platform matches no architectures.
+  PlatformSP platform_sp = list.GetOrCreate(archs, {}, candidates);
   ASSERT_FALSE(platform_sp);
 
   // The selected platform matches all architectures.
   const PlatformSP selected_platform_sp = std::make_shared();
-  platform_sp = Platform::GetPlatformForArchitectures(
-  archs, {}, selected_platform_sp, candidates);
+  list.Append(selected_platform_sp, /*set_selected=*/true);
+  platform_sp = list.GetOrCreate(archs, {}, candidates);
   ASSERT_TRUE(platform_sp);
   EXPECT_EQ(platform_sp, selected_platform_sp);
 }
 
 TEST_F(PlatformTest, GetPlatformForArchitecturesSelectedOverHost) {
-  const PlatformSP host_platform_sp = std::make_shared();
-  Platform::SetHostPlatform(host_platform_sp);
-  ASSERT_EQ(Platform::GetHostPlatform(), host_platform_sp);
+  SetHostPlatform(std::make_shared());
 
   const std::vector archs = {ArchSpec("arm64-apple-ps4"),
ArchSpec("x86_64-apple-ps4")};
   std::vector candidates;
 
-  // The host platform matches one architecture. No selected platform.
-  PlatformSP platform_sp =
-  Platform::GetPlatformForArchitectures(archs, {}, {}, candidates);
+  // The host platform matches one architecture.
+  PlatformSP platform_sp = list.GetOrCreate(archs, {}, candidates);
   ASSERT_TRUE(platform_sp);
-  EXPECT_EQ(platform_sp, host_platform_sp);
+  EXPECT_EQ(platform_sp, Platform::GetHostPlatform());
 
   // The selected 

[Lldb-commits] [lldb] 7d70b1a - [lldb] Fixup af921006d3792f for non-linux platforms

2022-04-13 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2022-04-13T15:38:36+02:00
New Revision: 7d70b1a4058cc07e527a3b16eef000b892e29797

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

LOG: [lldb] Fixup af921006d3792f for non-linux platforms

Added: 


Modified: 
lldb/test/API/python_api/debugger/TestDebuggerAPI.py
lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp

Removed: 




diff  --git a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py 
b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
index f0ba1d1e20aae..ff1ebd96d401b 100644
--- a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -108,7 +108,8 @@ def test_CreateTarget_platform(self):
 False, error)
 self.assertSuccess(error)
 platform2 = target2.GetPlatform()
-self.assertEqual(platform2.GetWorkingDirectory(), "/foo/bar")
+self.assertTrue(platform2.GetWorkingDirectory().endswith("bar"),
+platform2.GetWorkingDirectory())
 
 # ... but create a new one if it doesn't.
 self.dbg.SetSelectedPlatform(lldb.SBPlatform("remote-windows"))
@@ -123,9 +124,11 @@ def test_CreateTarget_arch(self):
 if lldbplatformutil.getHostPlatform() == 'linux':
 self.yaml2obj("macho.yaml", exe)
 arch = "x86_64-apple-macosx"
+expected_platform = "remote-macosx"
 else:
 self.yaml2obj("elf.yaml", exe)
 arch = "x86_64-pc-linux"
+expected_platform = "remote-linux"
 
 fbsd = lldb.SBPlatform("remote-freebsd")
 self.dbg.SetSelectedPlatform(fbsd)
@@ -134,7 +137,7 @@ def test_CreateTarget_arch(self):
 target1 = self.dbg.CreateTarget(exe, arch, None, False, error)
 self.assertSuccess(error)
 platform1 = target1.GetPlatform()
-self.assertEqual(platform1.GetName(), "remote-macosx")
+self.assertEqual(platform1.GetName(), expected_platform)
 platform1.SetWorkingDirectory("/foo/bar")
 
 # Reuse a platform even if it is not currently selected.
@@ -142,5 +145,6 @@ def test_CreateTarget_arch(self):
 target2 = self.dbg.CreateTarget(exe, arch, None, False, error)
 self.assertSuccess(error)
 platform2 = target2.GetPlatform()
-self.assertEqual(platform2.GetName(), "remote-macosx")
-self.assertEqual(platform2.GetWorkingDirectory(), "/foo/bar")
+self.assertEqual(platform2.GetName(), expected_platform)
+self.assertTrue(platform2.GetWorkingDirectory().endswith("bar"),
+platform2.GetWorkingDirectory())

diff  --git a/lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp 
b/lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
index 410c104299cbe..7cb07cbe55d35 100644
--- a/lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
+++ b/lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
@@ -25,8 +25,7 @@ class PlatformAppleSimulatorTest : public ::testing::Test {
 #ifdef __APPLE__
 
 static void testSimPlatformArchHasSimEnvironment(llvm::StringRef name) {
-  Status error;
-  auto platform_sp = Platform::Create(ConstString(name), error);
+  auto platform_sp = Platform::Create(name);
   ASSERT_TRUE(platform_sp);
   int num_arches = 0;
 
@@ -55,12 +54,12 @@ TEST_F(PlatformAppleSimulatorTest, TestHostPlatformToSim) {
   };
 
   for (auto sim : sim_platforms) {
+PlatformList list;
 ArchSpec arch = platform_arch;
 arch.GetTriple().setOS(sim);
 arch.GetTriple().setEnvironment(llvm::Triple::Simulator);
 
-Status error;
-auto platform_sp = Platform::Create(arch, {}, nullptr, error);
+auto platform_sp = list.GetOrCreate(arch, {}, nullptr);
 EXPECT_TRUE(platform_sp);
   }
 }



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


[Lldb-commits] [PATCH] D104629: [lldb] Escape semicolons for all shells

2022-04-13 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This is good in general, but I'm not sure we want to escape $.  One of the uses 
of shell expansion is to get shell variables expanded.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104629

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


[Lldb-commits] [PATCH] D123420: [demangler] Rust demangler buffer reuse

2022-04-13 Thread Nathan Sidwell 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 rG201c4b9cc4a6: [demangler] Rust demangler buffer return 
(authored by urnathan).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123420

Files:
  lldb/source/Core/Mangled.cpp
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/Demangle/Demangle.cpp
  llvm/lib/Demangle/RustDemangle.cpp
  llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
  llvm/unittests/Demangle/RustDemangleTest.cpp

Index: llvm/unittests/Demangle/RustDemangleTest.cpp
===
--- llvm/unittests/Demangle/RustDemangleTest.cpp
+++ llvm/unittests/Demangle/RustDemangleTest.cpp
@@ -13,78 +13,19 @@
 #include 
 
 TEST(RustDemangle, Success) {
-  char *Demangled =
-  llvm::rustDemangle("_RNvC1a4main", nullptr, nullptr, nullptr);
-  EXPECT_STREQ(Demangled, "a::main");
-  std::free(Demangled);
-
-  // With status.
-  int Status = 0;
-  Demangled = llvm::rustDemangle("_RNvC1a4main", nullptr, nullptr, &Status);
-  EXPECT_EQ(Status, llvm::demangle_success);
-  EXPECT_STREQ(Demangled, "a::main");
-  std::free(Demangled);
-
-  // With status and length.
-  size_t N = 0;
-  Demangled = llvm::rustDemangle("_RNvC1a4main", nullptr, &N, &Status);
-  EXPECT_EQ(Status, llvm::demangle_success);
-  EXPECT_EQ(N, 8u);
+  char *Demangled = llvm::rustDemangle("_RNvC1a4main");
   EXPECT_STREQ(Demangled, "a::main");
   std::free(Demangled);
 }
 
 TEST(RustDemangle, Invalid) {
-  int Status = 0;
   char *Demangled = nullptr;
 
   // Invalid prefix.
-  Demangled = llvm::rustDemangle("_ABCDEF", nullptr, nullptr, &Status);
-  EXPECT_EQ(Status, llvm::demangle_invalid_mangled_name);
+  Demangled = llvm::rustDemangle("_ABCDEF");
   EXPECT_EQ(Demangled, nullptr);
 
   // Correct prefix but still invalid.
-  Demangled = llvm::rustDemangle("_RRR", nullptr, nullptr, &Status);
-  EXPECT_EQ(Status, llvm::demangle_invalid_mangled_name);
+  Demangled = llvm::rustDemangle("_RRR");
   EXPECT_EQ(Demangled, nullptr);
 }
-
-TEST(RustDemangle, OutputBufferWithoutLength) {
-  char *Buffer = static_cast(std::malloc(1024));
-  ASSERT_NE(Buffer, nullptr);
-
-  int Status = 0;
-  char *Demangled =
-  llvm::rustDemangle("_RNvC1a4main", Buffer, nullptr, &Status);
-
-  EXPECT_EQ(Status, llvm::demangle_invalid_args);
-  EXPECT_EQ(Demangled, nullptr);
-  std::free(Buffer);
-}
-
-TEST(RustDemangle, OutputBuffer) {
-  size_t N = 1024;
-  char *Buffer = static_cast(std::malloc(N));
-  ASSERT_NE(Buffer, nullptr);
-
-  int Status = 0;
-  char *Demangled = llvm::rustDemangle("_RNvC1a4main", Buffer, &N, &Status);
-
-  EXPECT_EQ(Status, llvm::demangle_success);
-  EXPECT_EQ(Demangled, Buffer);
-  EXPECT_STREQ(Demangled, "a::main");
-  std::free(Demangled);
-}
-
-TEST(RustDemangle, SmallOutputBuffer) {
-  size_t N = 1;
-  char *Buffer = static_cast(std::malloc(N));
-  ASSERT_NE(Buffer, nullptr);
-
-  int Status = 0;
-  char *Demangled = llvm::rustDemangle("_RNvC1a4main", Buffer, &N, &Status);
-
-  EXPECT_EQ(Status, llvm::demangle_success);
-  EXPECT_STREQ(Demangled, "a::main");
-  std::free(Demangled);
-}
Index: llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
===
--- llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
+++ llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
@@ -13,9 +13,7 @@
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   std::string NullTerminatedString((const char *)Data, Size);
-  int Status = 0;
-  char *Demangled = llvm::rustDemangle(NullTerminatedString.c_str(), nullptr,
-   nullptr, &Status);
+  char *Demangled = llvm::rustDemangle(NullTerminatedString.c_str());
   std::free(Demangled);
   return 0;
 }
Index: llvm/lib/Demangle/RustDemangle.cpp
===
--- llvm/lib/Demangle/RustDemangle.cpp
+++ llvm/lib/Demangle/RustDemangle.cpp
@@ -147,57 +147,27 @@
 
 } // namespace
 
-char *llvm::rustDemangle(const char *MangledName, char *Buf, size_t *N,
- int *Status) {
-  if (MangledName == nullptr || (Buf != nullptr && N == nullptr)) {
-if (Status != nullptr)
-  *Status = demangle_invalid_args;
+char *llvm::rustDemangle(const char *MangledName) {
+  if (MangledName == nullptr)
 return nullptr;
-  }
 
   // Return early if mangled name doesn't look like a Rust symbol.
   StringView Mangled(MangledName);
-  if (!Mangled.startsWith("_R")) {
-if (Status != nullptr)
-  *Status = demangle_invalid_mangled_name;
+  if (!Mangled.startsWith("_R"))
 return nullptr;
-  }
 
   Demangler D;
-  if (!initializeOutputBuffer(nullptr, nullptr, D.Output,

[Lldb-commits] [lldb] 201c4b9 - [demangler] Rust demangler buffer return

2022-04-13 Thread Nathan Sidwell via lldb-commits

Author: Nathan Sidwell
Date: 2022-04-13T08:50:04-07:00
New Revision: 201c4b9cc4a649e4a54b418749ab5b8bd227e4f0

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

LOG: [demangler] Rust demangler buffer return

The rust demangler has some odd buffer handling code, which will copy
the demangled string into the provided buffer, if it will fit.
Otherwise it uses the allocated buffer it made.  But the length of the
incoming buffer will have come from a previous call, which was the
length of the demangled string -- not the buffer size.  And of course,
we're unconditionally allocating a temporary buffer in the first
place.  So we don't actually get buffer reuse, and we get a memcpy in
somecases.

However, nothing in LLVM ever passes in a non-null pointer.  Neither
does anything pass in a status pointer that is then made use of.  The
only exercise these have is in the test suite.

So let's just make the rust demangler have the same API as the dlang
demangler.

Reviewed By: tmiasko

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

Added: 


Modified: 
lldb/source/Core/Mangled.cpp
llvm/include/llvm/Demangle/Demangle.h
llvm/lib/Demangle/Demangle.cpp
llvm/lib/Demangle/RustDemangle.cpp
llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
llvm/unittests/Demangle/RustDemangleTest.cpp

Removed: 




diff  --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 31e1d68c29f31..0c4d9f78c4402 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -168,7 +168,7 @@ static char *GetItaniumDemangledStr(const char *M) {
 }
 
 static char *GetRustV0DemangledStr(const char *M) {
-  char *demangled_cstr = llvm::rustDemangle(M, nullptr, nullptr, nullptr);
+  char *demangled_cstr = llvm::rustDemangle(M);
 
   if (Log *log = GetLog(LLDBLog::Demangle)) {
 if (demangled_cstr && demangled_cstr[0])

diff  --git a/llvm/include/llvm/Demangle/Demangle.h 
b/llvm/include/llvm/Demangle/Demangle.h
index 3150e049320bf..6133d0b95bbfc 100644
--- a/llvm/include/llvm/Demangle/Demangle.h
+++ b/llvm/include/llvm/Demangle/Demangle.h
@@ -57,8 +57,8 @@ char *microsoftDemangle(const char *mangled_name, size_t 
*n_read, char *buf,
 size_t *n_buf, int *status,
 MSDemangleFlags Flags = MSDF_None);
 
-// Demangles a Rust v0 mangled symbol. The API follows that of __cxa_demangle.
-char *rustDemangle(const char *MangledName, char *Buf, size_t *N, int *Status);
+// Demangles a Rust v0 mangled symbol.
+char *rustDemangle(const char *MangledName);
 
 // Demangles a D mangled symbol.
 char *dlangDemangle(const char *MangledName);

diff  --git a/llvm/lib/Demangle/Demangle.cpp b/llvm/lib/Demangle/Demangle.cpp
index 13aa2864c183d..9d128424cabf4 100644
--- a/llvm/lib/Demangle/Demangle.cpp
+++ b/llvm/lib/Demangle/Demangle.cpp
@@ -51,7 +51,7 @@ bool llvm::nonMicrosoftDemangle(const char *MangledName, 
std::string &Result) {
   if (isItaniumEncoding(MangledName))
 Demangled = itaniumDemangle(MangledName, nullptr, nullptr, nullptr);
   else if (isRustEncoding(MangledName))
-Demangled = rustDemangle(MangledName, nullptr, nullptr, nullptr);
+Demangled = rustDemangle(MangledName);
   else if (isDLangEncoding(MangledName))
 Demangled = dlangDemangle(MangledName);
 

diff  --git a/llvm/lib/Demangle/RustDemangle.cpp 
b/llvm/lib/Demangle/RustDemangle.cpp
index d62891d69dc3f..32b10db2a968d 100644
--- a/llvm/lib/Demangle/RustDemangle.cpp
+++ b/llvm/lib/Demangle/RustDemangle.cpp
@@ -147,57 +147,27 @@ class Demangler {
 
 } // namespace
 
-char *llvm::rustDemangle(const char *MangledName, char *Buf, size_t *N,
- int *Status) {
-  if (MangledName == nullptr || (Buf != nullptr && N == nullptr)) {
-if (Status != nullptr)
-  *Status = demangle_invalid_args;
+char *llvm::rustDemangle(const char *MangledName) {
+  if (MangledName == nullptr)
 return nullptr;
-  }
 
   // Return early if mangled name doesn't look like a Rust symbol.
   StringView Mangled(MangledName);
-  if (!Mangled.startsWith("_R")) {
-if (Status != nullptr)
-  *Status = demangle_invalid_mangled_name;
+  if (!Mangled.startsWith("_R"))
 return nullptr;
-  }
 
   Demangler D;
-  if (!initializeOutputBuffer(nullptr, nullptr, D.Output, 1024)) {
-if (Status != nullptr)
-  *Status = demangle_memory_alloc_failure;
+  if (!initializeOutputBuffer(nullptr, nullptr, D.Output, 1024))
 return nullptr;
-  }
 
   if (!D.demangle(Mangled)) {
-if (Status != nullptr)
-  *Status = demangle_invalid_mangled_name;
 std::free(D.Output.getBuffer());
 return nullptr;
   }
 
   D.Output += '\0';
-  char *Demangled = D.Output.getBuffer();
-  size_t DemangledLen = D.Output.getCurrentPosition();
-
-  if

[Lldb-commits] [PATCH] D123690: [lldb] Expand $ when using tcsh

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: jingham.
Herald added a project: All.
JDevlieghere requested review of this revision.

Unlike for any of the other shells, we were escaping $ when using tcsh.
There's nothing special about $ in tcsh and this prevents you from
expanding shell variables, one of the main reasons this functionality
exists in the first place.


https://reviews.llvm.org/D123690

Files:
  lldb/source/Utility/Args.cpp
  lldb/unittests/Utility/ArgsTest.cpp


Index: lldb/unittests/Utility/ArgsTest.cpp
===
--- lldb/unittests/Utility/ArgsTest.cpp
+++ lldb/unittests/Utility/ArgsTest.cpp
@@ -336,8 +336,8 @@
 
   // Test escaping tcsh special characters.
   FileSpec tcsh("/bin/tcsh", FileSpec::Style::posix);
-  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&$;)"),
-R"(\ \'\"\<\>\(\)\&\$\;)");
+  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&;)"),
+R"(\ \'\"\<\>\(\)\&\;)");
   // Normal characters and globbing expressions that shouldn't be escaped.
   EXPECT_EQ(Args::GetShellSafeArgument(tcsh, "aA1*"), "aA1*");
 
Index: lldb/source/Utility/Args.cpp
===
--- lldb/source/Utility/Args.cpp
+++ lldb/source/Utility/Args.cpp
@@ -385,7 +385,7 @@
   };
 
   static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"},
-   {ConstString("tcsh"), " '\"<>()&$;"},
+   {ConstString("tcsh"), " '\"<>()&;"},
{ConstString("zsh"), " '\"<>()&;\\|"},
{ConstString("sh"), " '\"<>()&;"}};
 


Index: lldb/unittests/Utility/ArgsTest.cpp
===
--- lldb/unittests/Utility/ArgsTest.cpp
+++ lldb/unittests/Utility/ArgsTest.cpp
@@ -336,8 +336,8 @@
 
   // Test escaping tcsh special characters.
   FileSpec tcsh("/bin/tcsh", FileSpec::Style::posix);
-  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&$;)"),
-R"(\ \'\"\<\>\(\)\&\$\;)");
+  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&;)"),
+R"(\ \'\"\<\>\(\)\&\;)");
   // Normal characters and globbing expressions that shouldn't be escaped.
   EXPECT_EQ(Args::GetShellSafeArgument(tcsh, "aA1*"), "aA1*");
 
Index: lldb/source/Utility/Args.cpp
===
--- lldb/source/Utility/Args.cpp
+++ lldb/source/Utility/Args.cpp
@@ -385,7 +385,7 @@
   };
 
   static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"},
-   {ConstString("tcsh"), " '\"<>()&$;"},
+   {ConstString("tcsh"), " '\"<>()&;"},
{ConstString("zsh"), " '\"<>()&;\\|"},
{ConstString("sh"), " '\"<>()&;"}};
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D123358: [trace][intelpt] Remove code smell when printing the raw trace size

2022-04-13 Thread walter erquinigo via Phabricator via lldb-commits
wallace closed this revision.
wallace added a comment.

Committed as 44103c96fa6b00e7824319de1b10ce26781e3852 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123358

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


[Lldb-commits] [PATCH] D123357: [trace][intelpt] Add task timer classes

2022-04-13 Thread walter erquinigo via Phabricator via lldb-commits
wallace closed this revision.
wallace added a comment.

Committed as bdf3e7e5b886ab690a82e8d34b4502d9c6c5d6a9 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123357

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


[Lldb-commits] [PATCH] D123690: [lldb] Expand $ when using tcsh

2022-04-13 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

tcsh is different from the other shells in that a non-existent variable is 
trapped by the shell, and an error produced BEFORE running the command, whereas 
in other shells it just gets passed raw.  So we should make sure that passing a 
non-existent shell variable produces a reasonable error.  At present it sort of 
does:

  (lldb) process launch --shell=tcsh -- $PWD $NO_SUCH_SHELL_VARIABLE
  NO_SUCH_SHELL_VARIABLE: Undefined variable.
  error: process exited with status 1
  'r' and 'run' are aliases that default to launching through a shell.
  Try launching without going through a shell by using 'process launch'.
  (lldb)

The advisory part of that message is a little bogus, but that's a separate 
issue.  Erroring out seems reasonable since that's actually what tcsh would 
have done with these arguments, and we seem in a fine state to try again.

It might be nice to have a test where we pass a bad variable and make sure that 
the error stays reasonable?  But that's on the nice to have side...


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

https://reviews.llvm.org/D123690

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


[Lldb-commits] [PATCH] D123698: [lldb] Port Process::PrintWarning* to use the new diagnostic events

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: kastiglione.
Herald added a project: All.
JDevlieghere requested review of this revision.

Port the two Process::PrintWarning functions  to use the new diagnostic events 
through Debugger::ReportWarning. I kept the wrapper function in the process, 
but delegated the work to the Module. Consistent with the current code, the 
Module ensures the warning is only printed once per module.


https://reviews.llvm.org/D123698

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

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -436,8 +436,8 @@
   m_private_run_lock(), m_finalizing(false),
   m_clear_thread_plans_on_stop(false), m_force_next_event_delivery(false),
   m_last_broadcast_state(eStateInvalid), m_destroy_in_process(false),
-  m_can_interpret_function_calls(false), m_warnings_issued(),
-  m_run_thread_plan_lock(), m_can_jit(eCanJITDontKnow) {
+  m_can_interpret_function_calls(false), m_run_thread_plan_lock(),
+  m_can_jit(eCanJITDontKnow) {
   CheckInWithManager();
 
   Log *log = GetLog(LLDBLog::Object);
@@ -5697,48 +5697,12 @@
   }
 }
 
-void Process::PrintWarning(uint64_t warning_type, const void *repeat_key,
-   const char *fmt, ...) {
-  bool print_warning = true;
-
-  StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream();
-  if (!stream_sp)
-return;
-
-  if (repeat_key != nullptr) {
-WarningsCollection::iterator it = m_warnings_issued.find(warning_type);
-if (it == m_warnings_issued.end()) {
-  m_warnings_issued[warning_type] = WarningsPointerSet();
-  m_warnings_issued[warning_type].insert(repeat_key);
-} else {
-  if (it->second.find(repeat_key) != it->second.end()) {
-print_warning = false;
-  } else {
-it->second.insert(repeat_key);
-  }
-}
-  }
-
-  if (print_warning) {
-va_list args;
-va_start(args, fmt);
-stream_sp->PrintfVarArg(fmt, args);
-va_end(args);
-  }
-}
-
 void Process::PrintWarningOptimization(const SymbolContext &sc) {
   if (!GetWarningsOptimization())
 return;
-  if (!sc.module_sp)
+  if (!sc.module_sp || !sc.function || !sc.function->GetIsOptimized())
 return;
-  if (!sc.module_sp->GetFileSpec().GetFilename().IsEmpty() && sc.function &&
-  sc.function->GetIsOptimized()) {
-PrintWarning(Process::Warnings::eWarningsOptimization, sc.module_sp.get(),
- "%s was compiled with optimization - stepping may behave "
- "oddly; variables may not be available.\n",
- sc.module_sp->GetFileSpec().GetFilename().GetCString());
-  }
+  sc.module_sp->ReportWarningOptimization(GetTarget().GetDebugger().GetID());
 }
 
 void Process::PrintWarningUnsupportedLanguage(const SymbolContext &sc) {
@@ -5751,13 +5715,10 @@
 return;
   LanguageSet plugins =
   PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
-  if (!plugins[language]) {
-PrintWarning(Process::Warnings::eWarningsUnsupportedLanguage,
- sc.module_sp.get(),
- "This version of LLDB has no plugin for the language \"%s\". "
- "Inspection of frame variables will be limited.\n",
- Language::GetNameForLanguageType(language));
-  }
+  if (plugins[language])
+return;
+  sc.module_sp->ReportWarningUnsupportedLanguage(
+  language, GetTarget().GetDebugger().GetID());
 }
 
 bool Process::GetProcessInfo(ProcessInstanceInfo &info) {
Index: lldb/source/Core/Module.cpp
===
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -1126,6 +1126,31 @@
   return m_file_has_changed;
 }
 
+void Module::ReportWarningOptimization(
+llvm::Optional debugger_id) {
+  ConstString file_name = GetFileSpec().GetFilename();
+  if (file_name.IsEmpty())
+return;
+
+  StreamString ss;
+  ss << file_name.GetStringRef()
+ << " was compiled with optimization - stepping may behave "
+"oddly; variables may not be available.";
+  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
+  &m_optimization_warning);
+}
+
+void Module::ReportWarningUnsupportedLanguage(
+LanguageType language, llvm::Optional debugger_id) {
+  StreamString ss;
+  ss << "This version of LLDB has no plugin for the language \""
+ << Language::GetNameForLanguageType(language)
+ << "\". "
+"Inspection of frame variables will be limited.";
+  Debugger::ReportWarning(std::string(ss.GetString()), debugger_id,
+  &m_language_warning);
+}
+
 void Module::ReportErrorIfModifyDetected(const char *format, ...) {
   if (!m_first_file_changed_log) {
 if (FileHasChanged()) {
Ind

[Lldb-commits] [lldb] acc56e5 - [lldb] Expand $ when using tcsh

2022-04-13 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-04-13T13:01:09-07:00
New Revision: acc56e55feee61fc0038bc132a94e54ce56ced98

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

LOG: [lldb] Expand $ when using tcsh

Unlike for any of the other shells, we were escaping $ when using tcsh.
There's nothing special about $ in tcsh and this prevents you from
expanding shell variables, one of the main reasons this functionality
exists in the first place.

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

Added: 
lldb/test/Shell/Process/Inputs/echo.c
lldb/test/Shell/Process/TestShell.test

Modified: 
lldb/source/Utility/Args.cpp
lldb/unittests/Utility/ArgsTest.cpp

Removed: 




diff  --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp
index 8b20ee3f05ee9..3978f94226530 100644
--- a/lldb/source/Utility/Args.cpp
+++ b/lldb/source/Utility/Args.cpp
@@ -385,7 +385,7 @@ std::string Args::GetShellSafeArgument(const FileSpec 
&shell,
   };
 
   static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"},
-   {ConstString("tcsh"), " '\"<>()&$;"},
+   {ConstString("tcsh"), " '\"<>()&;"},
{ConstString("zsh"), " '\"<>()&;\\|"},
{ConstString("sh"), " '\"<>()&;"}};
 

diff  --git a/lldb/test/Shell/Process/Inputs/echo.c 
b/lldb/test/Shell/Process/Inputs/echo.c
new file mode 100644
index 0..dc8db7368f5d0
--- /dev/null
+++ b/lldb/test/Shell/Process/Inputs/echo.c
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char **argv) {
+  for (int i = 0; i < argc; ++i)
+printf("%s\n", argv[i]);
+}

diff  --git a/lldb/test/Shell/Process/TestShell.test 
b/lldb/test/Shell/Process/TestShell.test
new file mode 100644
index 0..b08d8611d41f5
--- /dev/null
+++ b/lldb/test/Shell/Process/TestShell.test
@@ -0,0 +1,8 @@
+REQUIRES: shell, system-darwin
+RUN: %clang_host %p/Inputs/echo.c -o %t.out
+
+RUN: not %lldb %t.out -b -o 'process launch --shell=tcsh -- 
$NO_SUCH_SHELL_VARIABLE' 2>&1 | FileCheck --check-prefix=FAILURE %s
+RUN: %lldb %t.out -b -o 'process launch --shell=tcsh -- $HOME' 2>&1 | 
FileCheck --check-prefix=SUCCESS %s
+
+FAILURE: exited with status 1
+SUCCESS: exited with status = 0

diff  --git a/lldb/unittests/Utility/ArgsTest.cpp 
b/lldb/unittests/Utility/ArgsTest.cpp
index dc306b209a24d..755a110aa555f 100644
--- a/lldb/unittests/Utility/ArgsTest.cpp
+++ b/lldb/unittests/Utility/ArgsTest.cpp
@@ -336,8 +336,8 @@ TEST(ArgsTest, GetShellSafeArgument) {
 
   // Test escaping tcsh special characters.
   FileSpec tcsh("/bin/tcsh", FileSpec::Style::posix);
-  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&$;)"),
-R"(\ \'\"\<\>\(\)\&\$\;)");
+  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&;)"),
+R"(\ \'\"\<\>\(\)\&\;)");
   // Normal characters and globbing expressions that shouldn't be escaped.
   EXPECT_EQ(Args::GetShellSafeArgument(tcsh, "aA1*"), "aA1*");
 



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


[Lldb-commits] [PATCH] D123690: [lldb] Expand $ when using tcsh

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGacc56e55feee: [lldb] Expand $ when using tcsh (authored by 
JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D123690?vs=422551&id=422622#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123690

Files:
  lldb/source/Utility/Args.cpp
  lldb/test/Shell/Process/Inputs/echo.c
  lldb/test/Shell/Process/TestShell.test
  lldb/unittests/Utility/ArgsTest.cpp


Index: lldb/unittests/Utility/ArgsTest.cpp
===
--- lldb/unittests/Utility/ArgsTest.cpp
+++ lldb/unittests/Utility/ArgsTest.cpp
@@ -336,8 +336,8 @@
 
   // Test escaping tcsh special characters.
   FileSpec tcsh("/bin/tcsh", FileSpec::Style::posix);
-  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&$;)"),
-R"(\ \'\"\<\>\(\)\&\$\;)");
+  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&;)"),
+R"(\ \'\"\<\>\(\)\&\;)");
   // Normal characters and globbing expressions that shouldn't be escaped.
   EXPECT_EQ(Args::GetShellSafeArgument(tcsh, "aA1*"), "aA1*");
 
Index: lldb/test/Shell/Process/TestShell.test
===
--- /dev/null
+++ lldb/test/Shell/Process/TestShell.test
@@ -0,0 +1,8 @@
+REQUIRES: shell, system-darwin
+RUN: %clang_host %p/Inputs/echo.c -o %t.out
+
+RUN: not %lldb %t.out -b -o 'process launch --shell=tcsh -- 
$NO_SUCH_SHELL_VARIABLE' 2>&1 | FileCheck --check-prefix=FAILURE %s
+RUN: %lldb %t.out -b -o 'process launch --shell=tcsh -- $HOME' 2>&1 | 
FileCheck --check-prefix=SUCCESS %s
+
+FAILURE: exited with status 1
+SUCCESS: exited with status = 0
Index: lldb/test/Shell/Process/Inputs/echo.c
===
--- /dev/null
+++ lldb/test/Shell/Process/Inputs/echo.c
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char **argv) {
+  for (int i = 0; i < argc; ++i)
+printf("%s\n", argv[i]);
+}
Index: lldb/source/Utility/Args.cpp
===
--- lldb/source/Utility/Args.cpp
+++ lldb/source/Utility/Args.cpp
@@ -385,7 +385,7 @@
   };
 
   static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"},
-   {ConstString("tcsh"), " '\"<>()&$;"},
+   {ConstString("tcsh"), " '\"<>()&;"},
{ConstString("zsh"), " '\"<>()&;\\|"},
{ConstString("sh"), " '\"<>()&;"}};
 


Index: lldb/unittests/Utility/ArgsTest.cpp
===
--- lldb/unittests/Utility/ArgsTest.cpp
+++ lldb/unittests/Utility/ArgsTest.cpp
@@ -336,8 +336,8 @@
 
   // Test escaping tcsh special characters.
   FileSpec tcsh("/bin/tcsh", FileSpec::Style::posix);
-  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&$;)"),
-R"(\ \'\"\<\>\(\)\&\$\;)");
+  EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&;)"),
+R"(\ \'\"\<\>\(\)\&\;)");
   // Normal characters and globbing expressions that shouldn't be escaped.
   EXPECT_EQ(Args::GetShellSafeArgument(tcsh, "aA1*"), "aA1*");
 
Index: lldb/test/Shell/Process/TestShell.test
===
--- /dev/null
+++ lldb/test/Shell/Process/TestShell.test
@@ -0,0 +1,8 @@
+REQUIRES: shell, system-darwin
+RUN: %clang_host %p/Inputs/echo.c -o %t.out
+
+RUN: not %lldb %t.out -b -o 'process launch --shell=tcsh -- $NO_SUCH_SHELL_VARIABLE' 2>&1 | FileCheck --check-prefix=FAILURE %s
+RUN: %lldb %t.out -b -o 'process launch --shell=tcsh -- $HOME' 2>&1 | FileCheck --check-prefix=SUCCESS %s
+
+FAILURE: exited with status 1
+SUCCESS: exited with status = 0
Index: lldb/test/Shell/Process/Inputs/echo.c
===
--- /dev/null
+++ lldb/test/Shell/Process/Inputs/echo.c
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char **argv) {
+  for (int i = 0; i < argc; ++i)
+printf("%s\n", argv[i]);
+}
Index: lldb/source/Utility/Args.cpp
===
--- lldb/source/Utility/Args.cpp
+++ lldb/source/Utility/Args.cpp
@@ -385,7 +385,7 @@
   };
 
   static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"},
-   {ConstString("tcsh"), " '\"<>()&$;"},
+   {ConstString("tcsh"), " '\"<>()&;"},
{ConstString("zsh"), " '\"<>()&;\\|"},
{ConstString("sh"), " '\"<>()&;"}};
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D123698: [lldb] Port Process::PrintWarning* to use the new diagnostic events

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 422647.
JDevlieghere added a comment.

Update tests to check stderr


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

https://reviews.llvm.org/D123698

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Target/Process.h
  lldb/source/Core/Module.cpp
  lldb/source/Target/Process.cpp
  lldb/test/Shell/Process/Optimization.test
  lldb/test/Shell/Process/UnsupportedLanguage.test

Index: lldb/test/Shell/Process/UnsupportedLanguage.test
===
--- lldb/test/Shell/Process/UnsupportedLanguage.test
+++ lldb/test/Shell/Process/UnsupportedLanguage.test
@@ -3,6 +3,6 @@
 RUN: %clang_host %S/Inputs/true.c -std=c99 -g -c -S -emit-llvm -o - \
 RUN:   | sed -e 's/DW_LANG_C99/DW_LANG_Mips_Assembler/g' >%t.ll
 RUN: %clang_host %t.ll -g -o %t.exe
-RUN: %lldb -o "b main" -o r -o q -b %t.exe | FileCheck %s
+RUN: %lldb -o "b main" -o r -o q -b %t.exe 2>&1 | FileCheck %s
 
 CHECK: This version of LLDB has no plugin for the language "assembler"
Index: lldb/test/Shell/Process/Optimization.test
===
--- lldb/test/Shell/Process/Optimization.test
+++ lldb/test/Shell/Process/Optimization.test
@@ -1,6 +1,6 @@
 Test warnings.
 REQUIRES: shell, system-darwin
 RUN: %clang_host -O3 %S/Inputs/true.c -std=c99 -g -o %t.exe
-RUN: %lldb -o "b main" -o r -o q -b %t.exe | FileCheck %s
+RUN: %lldb -o "b main" -o r -o q -b %t.exe 2>&1 | FileCheck %s
 
 CHECK: compiled with optimization
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -436,8 +436,8 @@
   m_private_run_lock(), m_finalizing(false),
   m_clear_thread_plans_on_stop(false), m_force_next_event_delivery(false),
   m_last_broadcast_state(eStateInvalid), m_destroy_in_process(false),
-  m_can_interpret_function_calls(false), m_warnings_issued(),
-  m_run_thread_plan_lock(), m_can_jit(eCanJITDontKnow) {
+  m_can_interpret_function_calls(false), m_run_thread_plan_lock(),
+  m_can_jit(eCanJITDontKnow) {
   CheckInWithManager();
 
   Log *log = GetLog(LLDBLog::Object);
@@ -5697,48 +5697,12 @@
   }
 }
 
-void Process::PrintWarning(uint64_t warning_type, const void *repeat_key,
-   const char *fmt, ...) {
-  bool print_warning = true;
-
-  StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream();
-  if (!stream_sp)
-return;
-
-  if (repeat_key != nullptr) {
-WarningsCollection::iterator it = m_warnings_issued.find(warning_type);
-if (it == m_warnings_issued.end()) {
-  m_warnings_issued[warning_type] = WarningsPointerSet();
-  m_warnings_issued[warning_type].insert(repeat_key);
-} else {
-  if (it->second.find(repeat_key) != it->second.end()) {
-print_warning = false;
-  } else {
-it->second.insert(repeat_key);
-  }
-}
-  }
-
-  if (print_warning) {
-va_list args;
-va_start(args, fmt);
-stream_sp->PrintfVarArg(fmt, args);
-va_end(args);
-  }
-}
-
 void Process::PrintWarningOptimization(const SymbolContext &sc) {
   if (!GetWarningsOptimization())
 return;
-  if (!sc.module_sp)
+  if (!sc.module_sp || !sc.function || !sc.function->GetIsOptimized())
 return;
-  if (!sc.module_sp->GetFileSpec().GetFilename().IsEmpty() && sc.function &&
-  sc.function->GetIsOptimized()) {
-PrintWarning(Process::Warnings::eWarningsOptimization, sc.module_sp.get(),
- "%s was compiled with optimization - stepping may behave "
- "oddly; variables may not be available.\n",
- sc.module_sp->GetFileSpec().GetFilename().GetCString());
-  }
+  sc.module_sp->ReportWarningOptimization(GetTarget().GetDebugger().GetID());
 }
 
 void Process::PrintWarningUnsupportedLanguage(const SymbolContext &sc) {
@@ -5751,13 +5715,10 @@
 return;
   LanguageSet plugins =
   PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
-  if (!plugins[language]) {
-PrintWarning(Process::Warnings::eWarningsUnsupportedLanguage,
- sc.module_sp.get(),
- "This version of LLDB has no plugin for the language \"%s\". "
- "Inspection of frame variables will be limited.\n",
- Language::GetNameForLanguageType(language));
-  }
+  if (plugins[language])
+return;
+  sc.module_sp->ReportWarningUnsupportedLanguage(
+  language, GetTarget().GetDebugger().GetID());
 }
 
 bool Process::GetProcessInfo(ProcessInstanceInfo &info) {
Index: lldb/source/Core/Module.cpp
===
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -1126,6 +1126,31 @@
   return m_file_has_changed;
 }
 
+void Module::ReportWarningOptimization(
+llvm::Optional debugger_id) {
+  ConstString file_name = GetFileSpec().GetFi

[Lldb-commits] [lldb] 763ff89 - [debugserver ] Un-conditionalize use of libcompression

2022-04-13 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-04-13T14:36:25-07:00
New Revision: 763ff89c0e0dcf77ee14c92936205bcf1b38385a

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

LOG: [debugserver ] Un-conditionalize use of libcompression

Jason removed the include guards in 681f6c2f552f. This patch removes the
corresponding CMake logic as well.

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

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index 86ad62de6088a..f636e387bf1f0 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -106,8 +106,6 @@ if (BUILDING_FOR_ARM64_OSX AND 
LLDB_ENABLE_ARM64E_DEBUGSERVER)
   set(CMAKE_OSX_ARCHITECTURES "arm64;arm64e")
 endif ()
 
-check_library_exists(compression compression_encode_buffer "" 
HAVE_LIBCOMPRESSION)
-
 find_library(SECURITY_LIBRARY Security)
 
 add_subdirectory(MacOSX)
@@ -125,6 +123,7 @@ set_property(GLOBAL PROPERTY
   LLDB_DEBUGSERVER_CODESIGN_IDENTITY ${debugserver_codesign_identity})
 
 if(APPLE)
+  set(LIBCOMPRESSION compression)
   if(APPLE_EMBEDDED)
 find_library(BACKBOARD_LIBRARY BackBoardServices
   PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks)
@@ -146,10 +145,6 @@ if(APPLE)
   endif()
 endif()
 
-if(HAVE_LIBCOMPRESSION)
-  set(LIBCOMPRESSION compression)
-endif()
-
 if(LLDB_USE_ENTITLEMENTS)
   if(APPLE_EMBEDDED)
 set(entitlements 
${DEBUGSERVER_RESOURCE_DIR}/debugserver-entitlements.plist)
@@ -258,10 +253,6 @@ target_link_libraries(lldbDebugserverCommon
   ${SECURITY_LIBRARY}
   ${LIBCOMPRESSION}
   ${ENERGY_LIBRARY})
-if(HAVE_LIBCOMPRESSION)
-  set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
-COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
-endif()
 add_lldb_tool(debugserver ADD_TO_FRAMEWORK
   debugserver.cpp
   LINK_LIBS lldbDebugserverCommon
@@ -325,10 +316,6 @@ if(APPLE_EMBEDDED)
   lldbDebugserverArchSupport
   ${SECURITY_LIBRARY}
   ${LIBCOMPRESSION})
-  if(HAVE_LIBCOMPRESSION)
-set_property(TARGET lldbDebugserverCommon_NonUI APPEND PROPERTY
-  COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
-  endif()
 
   add_lldb_tool(debugserver-nonui
 debugserver.cpp



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


[Lldb-commits] [PATCH] D123616: [debugserver ] Un-conditionalize use of libcompression

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG763ff89c0e0d: [debugserver ] Un-conditionalize use of 
libcompression (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123616

Files:
  lldb/tools/debugserver/source/CMakeLists.txt


Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -106,8 +106,6 @@
   set(CMAKE_OSX_ARCHITECTURES "arm64;arm64e")
 endif ()
 
-check_library_exists(compression compression_encode_buffer "" 
HAVE_LIBCOMPRESSION)
-
 find_library(SECURITY_LIBRARY Security)
 
 add_subdirectory(MacOSX)
@@ -125,6 +123,7 @@
   LLDB_DEBUGSERVER_CODESIGN_IDENTITY ${debugserver_codesign_identity})
 
 if(APPLE)
+  set(LIBCOMPRESSION compression)
   if(APPLE_EMBEDDED)
 find_library(BACKBOARD_LIBRARY BackBoardServices
   PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks)
@@ -146,10 +145,6 @@
   endif()
 endif()
 
-if(HAVE_LIBCOMPRESSION)
-  set(LIBCOMPRESSION compression)
-endif()
-
 if(LLDB_USE_ENTITLEMENTS)
   if(APPLE_EMBEDDED)
 set(entitlements 
${DEBUGSERVER_RESOURCE_DIR}/debugserver-entitlements.plist)
@@ -258,10 +253,6 @@
   ${SECURITY_LIBRARY}
   ${LIBCOMPRESSION}
   ${ENERGY_LIBRARY})
-if(HAVE_LIBCOMPRESSION)
-  set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
-COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
-endif()
 add_lldb_tool(debugserver ADD_TO_FRAMEWORK
   debugserver.cpp
   LINK_LIBS lldbDebugserverCommon
@@ -325,10 +316,6 @@
   lldbDebugserverArchSupport
   ${SECURITY_LIBRARY}
   ${LIBCOMPRESSION})
-  if(HAVE_LIBCOMPRESSION)
-set_property(TARGET lldbDebugserverCommon_NonUI APPEND PROPERTY
-  COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
-  endif()
 
   add_lldb_tool(debugserver-nonui
 debugserver.cpp


Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -106,8 +106,6 @@
   set(CMAKE_OSX_ARCHITECTURES "arm64;arm64e")
 endif ()
 
-check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSION)
-
 find_library(SECURITY_LIBRARY Security)
 
 add_subdirectory(MacOSX)
@@ -125,6 +123,7 @@
   LLDB_DEBUGSERVER_CODESIGN_IDENTITY ${debugserver_codesign_identity})
 
 if(APPLE)
+  set(LIBCOMPRESSION compression)
   if(APPLE_EMBEDDED)
 find_library(BACKBOARD_LIBRARY BackBoardServices
   PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks)
@@ -146,10 +145,6 @@
   endif()
 endif()
 
-if(HAVE_LIBCOMPRESSION)
-  set(LIBCOMPRESSION compression)
-endif()
-
 if(LLDB_USE_ENTITLEMENTS)
   if(APPLE_EMBEDDED)
 set(entitlements ${DEBUGSERVER_RESOURCE_DIR}/debugserver-entitlements.plist)
@@ -258,10 +253,6 @@
   ${SECURITY_LIBRARY}
   ${LIBCOMPRESSION}
   ${ENERGY_LIBRARY})
-if(HAVE_LIBCOMPRESSION)
-  set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
-COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
-endif()
 add_lldb_tool(debugserver ADD_TO_FRAMEWORK
   debugserver.cpp
   LINK_LIBS lldbDebugserverCommon
@@ -325,10 +316,6 @@
   lldbDebugserverArchSupport
   ${SECURITY_LIBRARY}
   ${LIBCOMPRESSION})
-  if(HAVE_LIBCOMPRESSION)
-set_property(TARGET lldbDebugserverCommon_NonUI APPEND PROPERTY
-  COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
-  endif()
 
   add_lldb_tool(debugserver-nonui
 debugserver.cpp
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 343f3de - [lldb] Fix a bug in the decorator matching logic.

2022-04-13 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-04-13T15:07:33-07:00
New Revision: 343f3de559c636dcec941613dca91e4fff6547a3

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

LOG: [lldb] Fix a bug in the decorator matching logic.

This changes the decorator helper `_match_decorator_property` to
consider `None` as the actual value as not a match. Using `None` for the
pattern continues to be considered a match.

I discovered the issue because marking a test as NO_DEBUG_INFO_TESTCASE
will cause the call to `self.getDebugInfo()` to return `None` and
incorrectly skip or XFAIL the corresponding test.

I used the above scenario to create a test for the decorators.

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

Added: 
lldb/test/API/test_utils/TestDecorators.py

Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index c44c007a20fc2..8f636024abe91 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -73,18 +73,23 @@ def fn_neq(x, y): return x != y
 
 _re_pattern_type = type(re.compile(''))
 def _match_decorator_property(expected, actual):
-if actual is None or expected is None:
+if expected is None:
 return True
 
+if actual is None :
+return False
+
 if isinstance(expected, no_match):
 return not _match_decorator_property(expected.item, actual)
-elif isinstance(expected, (_re_pattern_type,) + six.string_types):
+
+if isinstance(expected, (_re_pattern_type,) + six.string_types):
 return re.search(expected, actual) is not None
-elif hasattr(expected, "__iter__"):
+
+if hasattr(expected, "__iter__"):
 return any([x is not None and _match_decorator_property(x, actual)
 for x in expected])
-else:
-return expected == actual
+
+return expected == actual
 
 
 def _compiler_supports(compiler,

diff  --git a/lldb/test/API/test_utils/TestDecorators.py 
b/lldb/test/API/test_utils/TestDecorators.py
new file mode 100644
index 0..f536f4255656c
--- /dev/null
+++ b/lldb/test/API/test_utils/TestDecorators.py
@@ -0,0 +1,13 @@
+from lldbsuite.test.lldbtest import Base
+from lldbsuite.test.decorators import *
+
+
+class TestDecorators(Base):
+
+mydir = Base.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@expectedFailureAll(debug_info="dwarf")
+def test_decorator_skip_no_debug_info(self):
+"""Test that specifying a debug info category works for a 
NO_DEBUG_INFO_TESTCASE"""
+pass



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


[Lldb-commits] [PATCH] D123401: [lldb] Fix debug_info decorators for NO_DEBUG_INFO_TESTCASE

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG343f3de559c6: [lldb] Fix a bug in the decorator matching 
logic. (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D123401?vs=421548&id=422673#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123401

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/test/API/test_utils/TestDecorators.py


Index: lldb/test/API/test_utils/TestDecorators.py
===
--- /dev/null
+++ lldb/test/API/test_utils/TestDecorators.py
@@ -0,0 +1,13 @@
+from lldbsuite.test.lldbtest import Base
+from lldbsuite.test.decorators import *
+
+
+class TestDecorators(Base):
+
+mydir = Base.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@expectedFailureAll(debug_info="dwarf")
+def test_decorator_skip_no_debug_info(self):
+"""Test that specifying a debug info category works for a 
NO_DEBUG_INFO_TESTCASE"""
+pass
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -73,18 +73,23 @@
 
 _re_pattern_type = type(re.compile(''))
 def _match_decorator_property(expected, actual):
-if actual is None or expected is None:
+if expected is None:
 return True
 
+if actual is None :
+return False
+
 if isinstance(expected, no_match):
 return not _match_decorator_property(expected.item, actual)
-elif isinstance(expected, (_re_pattern_type,) + six.string_types):
+
+if isinstance(expected, (_re_pattern_type,) + six.string_types):
 return re.search(expected, actual) is not None
-elif hasattr(expected, "__iter__"):
+
+if hasattr(expected, "__iter__"):
 return any([x is not None and _match_decorator_property(x, actual)
 for x in expected])
-else:
-return expected == actual
+
+return expected == actual
 
 
 def _compiler_supports(compiler,


Index: lldb/test/API/test_utils/TestDecorators.py
===
--- /dev/null
+++ lldb/test/API/test_utils/TestDecorators.py
@@ -0,0 +1,13 @@
+from lldbsuite.test.lldbtest import Base
+from lldbsuite.test.decorators import *
+
+
+class TestDecorators(Base):
+
+mydir = Base.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@expectedFailureAll(debug_info="dwarf")
+def test_decorator_skip_no_debug_info(self):
+"""Test that specifying a debug info category works for a NO_DEBUG_INFO_TESTCASE"""
+pass
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -73,18 +73,23 @@
 
 _re_pattern_type = type(re.compile(''))
 def _match_decorator_property(expected, actual):
-if actual is None or expected is None:
+if expected is None:
 return True
 
+if actual is None :
+return False
+
 if isinstance(expected, no_match):
 return not _match_decorator_property(expected.item, actual)
-elif isinstance(expected, (_re_pattern_type,) + six.string_types):
+
+if isinstance(expected, (_re_pattern_type,) + six.string_types):
 return re.search(expected, actual) is not None
-elif hasattr(expected, "__iter__"):
+
+if hasattr(expected, "__iter__"):
 return any([x is not None and _match_decorator_property(x, actual)
 for x in expected])
-else:
-return expected == actual
+
+return expected == actual
 
 
 def _compiler_supports(compiler,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D123743: [lldb] Show the DBGError if dsymForUUID can't find a dSYM

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: jasonmolenda.
Herald added a project: All.
JDevlieghere requested review of this revision.

Show the user the DBGError (if available) when dsymForUUID fails.

rdar://90949180


https://reviews.llvm.org/D123743

Files:
  lldb/include/lldb/Symbol/LocateSymbolFile.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Interpreter/CommandReturnObject.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Symbol/LocateSymbolFile.cpp
  lldb/source/Symbol/LocateSymbolFileMacOSX.cpp

Index: lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
===
--- lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
+++ lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
@@ -298,7 +298,8 @@
 }
 
 static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
-ModuleSpec &module_spec) {
+ModuleSpec &module_spec,
+Status &error) {
   Log *log = GetLog(LLDBLog::Host);
   bool success = false;
   if (uuid_dict != NULL && CFGetTypeID(uuid_dict) == CFDictionaryGetTypeID()) {
@@ -306,6 +307,14 @@
 CFStringRef cf_str;
 CFDictionaryRef cf_dict;
 
+cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+   CFSTR("DBGError"));
+if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+  if (CFCString::FileSystemRepresentation(cf_str, str)) {
+error.SetErrorString(str);
+  }
+}
+
 cf_str = (CFStringRef)CFDictionaryGetValue(
 (CFDictionaryRef)uuid_dict, CFSTR("DBGSymbolRichExecutable"));
 if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
@@ -337,7 +346,6 @@
 
 std::string DBGBuildSourcePath;
 std::string DBGSourcePath;
-std::string DBGError;
 
 // If DBGVersion 1 or DBGVersion missing, ignore DBGSourcePathRemapping.
 // If DBGVersion 2, strip last two components of path remappings from
@@ -458,7 +466,7 @@
 }
 
 bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
-  bool force_lookup) {
+  Status &error, bool force_lookup) {
   bool success = false;
   const UUID *uuid_ptr = module_spec.GetUUIDPtr();
   const FileSpec *file_spec_ptr = module_spec.GetFileSpecPtr();
@@ -578,7 +586,7 @@
 LLDB_LOGF(log, "Calling %s with file %s to find dSYM",
   g_dsym_for_uuid_exe_path, file_path);
 }
-Status error = Host::RunShellCommand(
+error = Host::RunShellCommand(
 command.GetData(),
 FileSpec(),  // current working directory
 &exit_status,// Exit status
@@ -602,8 +610,8 @@
   CFCString uuid_cfstr(uuid_str.c_str());
   CFDictionaryRef uuid_dict = (CFDictionaryRef)CFDictionaryGetValue(
   plist.get(), uuid_cfstr.get());
-  success =
-  GetModuleSpecInfoFromUUIDDictionary(uuid_dict, module_spec);
+  success = GetModuleSpecInfoFromUUIDDictionary(uuid_dict,
+module_spec, error);
 } else {
   const CFIndex num_values = ::CFDictionaryGetCount(plist.get());
   if (num_values > 0) {
@@ -612,14 +620,14 @@
 ::CFDictionaryGetKeysAndValues(plist.get(), NULL,
(const void **)&values[0]);
 if (num_values == 1) {
-  success = GetModuleSpecInfoFromUUIDDictionary(values[0],
-module_spec);
+  success = GetModuleSpecInfoFromUUIDDictionary(
+  values[0], module_spec, error);
   return success;
 } else {
   for (CFIndex i = 0; i < num_values; ++i) {
 ModuleSpec curr_module_spec;
-if (GetModuleSpecInfoFromUUIDDictionary(values[i],
-curr_module_spec)) {
+if (GetModuleSpecInfoFromUUIDDictionary(
+values[i], curr_module_spec, error)) {
   if (module_spec.GetArchitecture().IsCompatibleMatch(
   curr_module_spec.GetArchitecture())) {
 module_spec = curr_module_spec;
Index: lldb/source/Symbol/LocateSymbolFile.cpp
=

[Lldb-commits] [PATCH] D123743: [lldb] Show the DBGError if dsymForUUID can't find a dSYM

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 422688.
JDevlieghere added a comment.

Add test


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

https://reviews.llvm.org/D123743

Files:
  lldb/include/lldb/Symbol/LocateSymbolFile.h
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Interpreter/CommandReturnObject.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Symbol/LocateSymbolFile.cpp
  lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
  lldb/test/Shell/SymbolFile/Inputs/a.yaml
  lldb/test/Shell/SymbolFile/Inputs/dsymforuuid.sh
  lldb/test/Shell/SymbolFile/add-dsym.test

Index: lldb/test/Shell/SymbolFile/add-dsym.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/add-dsym.test
@@ -0,0 +1,5 @@
+# REQUIRES: system-darwin
+
+# RUN: yaml2obj %S/Inputs/a.yaml -o %t.out
+# RUN: LLDB_APPLE_DSYMFORUUID_EXECUTABLE=%S/Inputs/dsymforuuid.sh %lldb %t.out -o 'add-dsym -u 41945CA4-5D9D-3CDE-82B4-37E4C09750B5' 2>&1 | FileCheck %s
+# CHECK: UUID information was not found
Index: lldb/test/Shell/SymbolFile/Inputs/dsymforuuid.sh
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/Inputs/dsymforuuid.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+echo ""
+echo "http://www.apple.com/DTDs/PropertyList-1.0.dtd\";>"
+echo ""
+echo ""
+echo "41945CA4-5D9D-3CDE-82B4-37E4C09750B5"
+echo ""
+echo "DBGArchitecture"
+echo "x86_64"
+echo "DBGError"
+echo "UUID information was not found"
+echo ""
+echo ""
+echo ""
Index: lldb/test/Shell/SymbolFile/Inputs/a.yaml
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/Inputs/a.yaml
@@ -0,0 +1,204 @@
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x10C
+  cpusubtype:  0x0
+  filetype:0x2
+  ncmds:   16
+  sizeofcmds:  744
+  flags:   0x200085
+  reserved:0x0
+LoadCommands:
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __PAGEZERO
+vmaddr:  0
+vmsize:  4294967296
+fileoff: 0
+filesize:0
+maxprot: 0
+initprot:0
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 232
+segname: __TEXT
+vmaddr:  4294967296
+vmsize:  16384
+fileoff: 0
+filesize:16384
+maxprot: 5
+initprot:5
+nsects:  2
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x13FB0
+size:8
+offset:  0x3FB0
+align:   2
+reloff:  0x0
+nreloc:  0
+flags:   0x8400
+reserved1:   0x0
+reserved2:   0x0
+reserved3:   0x0
+content: 8052C0035FD6
+  - sectname:__unwind_info
+segname: __TEXT
+addr:0x13FB8
+size:72
+offset:  0x3FB8
+align:   2
+reloff:  0x0
+nreloc:  0
+flags:   0x0
+reserved1:   0x0
+reserved2:   0x0
+reserved3:   0x0
+content: 01001C001C001C000200B03F34003400B93F340003000C0001001102
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __LINKEDIT
+vmaddr:  4294983680
+vmsize:  16384
+fileoff: 16384
+filesize:802
+maxprot: 1
+initprot:1
+nsects:  0
+flags:   0
+  - cmd: LC_DYLD_CHAINED_FIXUPS
+cmdsize: 16
+dataoff: 16384
+datasize:56
+  - cmd: LC_DYLD_EXPORTS_TRIE
+cmdsize: 16
+dataoff: 16440
+datasize:48
+  - cmd: LC_SYMTAB
+cmdsize: 24
+symoff:  16496
+nsyms:   10
+stroff:  16656
+strsize: 232
+  - cmd: LC_DYSYMTAB
+cmdsize: 80
+ilocalsym:   0
+nlocalsym:   8
+iextdefsym:  8
+nextdefsym:  2
+iundefsym:   10
+nundefsym:   0
+tocoff:  0
+ntoc:0
+modtaboff:   0
+nmodtab: 0
+extrefsymoff:0
+nextrefsyms: 0
+indirectsymoff:  0
+

[Lldb-commits] [lldb] 80c600f - [lldb] Format LocateSymbolFileMacOSX (NFC)

2022-04-13 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-04-13T16:27:02-07:00
New Revision: 80c600fe98ed1d0be4cc2a34d791cdaffdfb9c8e

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

LOG: [lldb] Format LocateSymbolFileMacOSX (NFC)

Added: 


Modified: 
lldb/source/Symbol/LocateSymbolFileMacOSX.cpp

Removed: 




diff  --git a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp 
b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
index 143a1cc2c3dea..9f19634960b31 100644
--- a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
+++ b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
@@ -40,8 +40,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static CFURLRef (*g_dlsym_DBGCopyFullDSYMURLForUUID)(CFUUIDRef uuid, CFURLRef 
exec_url) = nullptr;
-static CFDictionaryRef (*g_dlsym_DBGCopyDSYMPropertyLists)(CFURLRef dsym_url) 
= nullptr;
+static CFURLRef (*g_dlsym_DBGCopyFullDSYMURLForUUID)(
+CFUUIDRef uuid, CFURLRef exec_url) = nullptr;
+static CFDictionaryRef (*g_dlsym_DBGCopyDSYMPropertyLists)(CFURLRef dsym_url) =
+nullptr;
 
 int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
ModuleSpec &return_module_spec) {
@@ -70,10 +72,15 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec 
&module_spec,
 
   if (g_dlsym_DBGCopyFullDSYMURLForUUID == nullptr ||
   g_dlsym_DBGCopyDSYMPropertyLists == nullptr) {
-void *handle = dlopen 
("/System/Library/PrivateFrameworks/DebugSymbols.framework/DebugSymbols", 
RTLD_LAZY | RTLD_LOCAL);
+void *handle = dlopen(
+
"/System/Library/PrivateFrameworks/DebugSymbols.framework/DebugSymbols",
+RTLD_LAZY | RTLD_LOCAL);
 if (handle) {
-  g_dlsym_DBGCopyFullDSYMURLForUUID = (CFURLRef (*)(CFUUIDRef, CFURLRef)) 
dlsym (handle, "DBGCopyFullDSYMURLForUUID");
-  g_dlsym_DBGCopyDSYMPropertyLists = (CFDictionaryRef (*)(CFURLRef)) dlsym 
(handle, "DBGCopyDSYMPropertyLists");
+  g_dlsym_DBGCopyFullDSYMURLForUUID =
+  (CFURLRef(*)(CFUUIDRef, CFURLRef))dlsym(handle,
+  "DBGCopyFullDSYMURLForUUID");
+  g_dlsym_DBGCopyDSYMPropertyLists = (CFDictionaryRef(*)(CFURLRef))dlsym(
+  handle, "DBGCopyDSYMPropertyLists");
 }
   }
 
@@ -103,8 +110,8 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec 
&module_spec,
 FALSE));
 }
 
-CFCReleaser dsym_url(
-g_dlsym_DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), 
exec_url.get()));
+CFCReleaser dsym_url(g_dlsym_DBGCopyFullDSYMURLForUUID(
+module_uuid_ref.get(), exec_url.get()));
 char path[PATH_MAX];
 
 if (dsym_url.get()) {
@@ -612,8 +619,8 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec 
&module_spec,
 &signo,  // Signal int *
 &command_output, // Command output
 std::chrono::seconds(
-   640), // Large timeout to allow for long dsym download times
-false);  // Don't run in a shell (we don't need shell expansion)
+640), // Large timeout to allow for long dsym download times
+false);   // Don't run in a shell (we don't need shell expansion)
 if (error.Success() && exit_status == 0 && !command_output.empty()) {
   CFCData data(CFDataCreateWithBytesNoCopy(
   NULL, (const UInt8 *)command_output.data(), 
command_output.size(),



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


[Lldb-commits] [lldb] 6443d0d - [lldb] Remove reproducer logic from LocateSymbolFileMacOSX

2022-04-13 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-04-13T16:27:02-07:00
New Revision: 6443d0d413df7b67b149e7618c295c38869ecbcb

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

LOG: [lldb] Remove reproducer logic from LocateSymbolFileMacOSX

Added: 


Modified: 
lldb/source/Symbol/LocateSymbolFileMacOSX.cpp

Removed: 
lldb/test/Shell/Reproducer/Inputs/dsymforuuid.sh
lldb/test/Shell/Reproducer/TestDebugSymbols.test



diff  --git a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp 
b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
index 9f19634960b31..8564bcc2c6bf0 100644
--- a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
+++ b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
@@ -28,7 +28,6 @@
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
-#include "lldb/Utility/ReproducerProvider.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
 #include "lldb/Utility/UUID.h"
@@ -60,14 +59,6 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec 
&module_spec,
   const UUID *uuid = module_spec.GetUUIDPtr();
   const ArchSpec *arch = module_spec.GetArchitecturePtr();
 
-  if (repro::Loader *l = repro::Reproducer::Instance().GetLoader()) {
-static repro::SymbolFileLoader symbol_file_loader(l);
-std::pair paths = symbol_file_loader.GetPaths(uuid);
-return_module_spec.GetFileSpec() = paths.first;
-return_module_spec.GetSymbolFileSpec() = paths.second;
-return 1;
-  }
-
   int items_found = 0;
 
   if (g_dlsym_DBGCopyFullDSYMURLForUUID == nullptr ||
@@ -264,12 +255,6 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec 
&module_spec,
 }
   }
 
-  if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
-g->GetOrCreate().AddSymbolFile(
-uuid, return_module_spec.GetFileSpec(),
-return_module_spec.GetSymbolFileSpec());
-  }
-
   return items_found;
 }
 
@@ -477,25 +462,6 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec 
&module_spec,
   const UUID *uuid_ptr = module_spec.GetUUIDPtr();
   const FileSpec *file_spec_ptr = module_spec.GetFileSpecPtr();
 
-  if (repro::Loader *l = repro::Reproducer::Instance().GetLoader()) {
-static repro::SymbolFileLoader symbol_file_loader(l);
-std::pair paths = 
symbol_file_loader.GetPaths(uuid_ptr);
-if (paths.first)
-  module_spec.GetFileSpec() = paths.first;
-if (paths.second)
-  module_spec.GetSymbolFileSpec() = paths.second;
-return true;
-  }
-
-  // Lambda to capture the state of module_spec before returning from this
-  // function.
-  auto RecordResult = [&]() {
-if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
-  g->GetOrCreate().AddSymbolFile(
-  uuid_ptr, module_spec.GetFileSpec(), 
module_spec.GetSymbolFileSpec());
-}
-  };
-
   // It's expensive to check for the DBGShellCommands defaults setting, only do
   // it once per lldb run and cache the result.
   static bool g_have_checked_for_dbgshell_command = false;
@@ -521,7 +487,6 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec 
&module_spec,
   // When g_dbgshell_command is NULL, the user has not enabled the use of an
   // external program to find the symbols, don't run it for them.
   if (!force_lookup && g_dbgshell_command == NULL) {
-RecordResult();
 return false;
   }
 
@@ -648,7 +613,6 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec 
&module_spec,
 if (num_values == 1) {
   success = GetModuleSpecInfoFromUUIDDictionary(values[0],
 module_spec);
-  RecordResult();
   return success;
 } else {
   for (CFIndex i = 0; i < num_values; ++i) {
@@ -658,7 +622,6 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec 
&module_spec,
   if (module_spec.GetArchitecture().IsCompatibleMatch(
   curr_module_spec.GetArchitecture())) {
 module_spec = curr_module_spec;
-RecordResult();
 return true;
   }
 }
@@ -680,6 +643,5 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec 
&module_spec,
   }
 }
   }
-  RecordResult();
   return success;
 }

diff  --git a/lldb/test/Shell/Reproducer/Inputs/dsymforuuid.sh 
b/lldb/test/Shell/Reproducer/Inputs/dsymforuuid.sh
deleted file mode 100755
index ce5ade741ed65..0
--- a/lldb/test/Shell/Reproducer/Inputs/dsymforuuid.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env bash
-
-echo ""
-echo "http://www.apple.com/DTDs/PropertyList-1.0.dtd\";>"
-echo ""
-echo ""
-echo "AD52358C-94F8-3796-ADD6-B20FFAC00E5C"
-echo "

[Lldb-commits] [PATCH] D123746: [lldb] Prevent crash when adding a stop hook with --shlib

2022-04-13 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: mib.
Herald added a project: All.
JDevlieghere requested review of this revision.

Currently, lldb crashes when adding a stop hook with --shlib because we 
unconditionally use the target in `SymbolContextSpecifier::AddSpecification`. 
Avoid the crash and add a little test.

rdar://68524781


https://reviews.llvm.org/D123746

Files:
  lldb/source/Symbol/SymbolContext.cpp
  lldb/test/Shell/Commands/command-stop-hook-no-target.test


Index: lldb/test/Shell/Commands/command-stop-hook-no-target.test
===
--- /dev/null
+++ lldb/test/Shell/Commands/command-stop-hook-no-target.test
@@ -0,0 +1,3 @@
+# RUN: %lldb -b -o 'target stop-hook add --name test --shlib test' -o 'bt' | 
FileCheck %s
+# CHECK: Stop hook #1 added
+
Index: lldb/source/Symbol/SymbolContext.cpp
===
--- lldb/source/Symbol/SymbolContext.cpp
+++ lldb/source/Symbol/SymbolContext.cpp
@@ -960,8 +960,8 @@
 // See if we can find the Module, if so stick it in the SymbolContext.
 FileSpec module_file_spec(spec_string);
 ModuleSpec module_spec(module_file_spec);
-lldb::ModuleSP module_sp(
-m_target_sp->GetImages().FindFirstModule(module_spec));
+lldb::ModuleSP module_sp = m_target_sp ?
+m_target_sp->GetImages().FindFirstModule(module_spec) : nullptr;
 m_type |= eModuleSpecified;
 if (module_sp)
   m_module_sp = module_sp;


Index: lldb/test/Shell/Commands/command-stop-hook-no-target.test
===
--- /dev/null
+++ lldb/test/Shell/Commands/command-stop-hook-no-target.test
@@ -0,0 +1,3 @@
+# RUN: %lldb -b -o 'target stop-hook add --name test --shlib test' -o 'bt' | FileCheck %s
+# CHECK: Stop hook #1 added
+
Index: lldb/source/Symbol/SymbolContext.cpp
===
--- lldb/source/Symbol/SymbolContext.cpp
+++ lldb/source/Symbol/SymbolContext.cpp
@@ -960,8 +960,8 @@
 // See if we can find the Module, if so stick it in the SymbolContext.
 FileSpec module_file_spec(spec_string);
 ModuleSpec module_spec(module_file_spec);
-lldb::ModuleSP module_sp(
-m_target_sp->GetImages().FindFirstModule(module_spec));
+lldb::ModuleSP module_sp = m_target_sp ?
+m_target_sp->GetImages().FindFirstModule(module_spec) : nullptr;
 m_type |= eModuleSpecified;
 if (module_sp)
   m_module_sp = module_sp;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D123746: [lldb] Prevent crash when adding a stop hook with --shlib

2022-04-13 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This is fine, though the fact that it crashed when you tried to specify the 
shared library means we don't have any tests that the shared library gets 
copied over from the dummy target correctly.  Might be nice to extend the test 
to have a "file not_called_test" and "break set -n main"  and "run" to make 
sure the stop hook doesn't fire.


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

https://reviews.llvm.org/D123746

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