[Lldb-commits] [lldb] 4db7832 - [LLDB] Make API tests to run using MSYS tools

2022-09-01 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2022-09-01T14:00:46+05:00
New Revision: 4db78322031ffbd5ea607d7ff66fed5fafb40d68

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

LOG: [LLDB] Make API tests to run using MSYS tools

MSYS 'uname' on windows returns "MSYS_NT*" instead of windows32 and also
MSYS 'pwd' returns non-windows path string.
This patch fixes Makefile.rules to make adjustments required to run LLDB
API tests using MSYS tools.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 36ef02810152..937a2ae06fc4 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -49,8 +49,9 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #--
 # If OS is not defined, use 'uname -s' to determine the OS name.
 #
-# uname on Windows gives "windows32" or "server version windows32", but most
-# environments standardize on "Windows_NT", so we'll make it consistent here.
+# GNUWin32 uname gives "windows32" or "server version windows32" while
+# some versions of MSYS uname return "MSYS_NT*", but most environments
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -58,6 +59,11 @@ HOST_OS := $(shell uname -s)
 ifneq (,$(findstring windows32,$(HOST_OS)))
HOST_OS := Windows_NT
 endif
+
+ifneq (,$(findstring MSYS_NT,$(HOST_OS)))
+   HOST_OS := Windows_NT
+endif
+
 ifeq "$(OS)" ""
OS := $(HOST_OS)
 endif
@@ -68,9 +74,12 @@ endif
 # Some versions of make on Windows will search for other shells such as
 # C:\cygwin\bin\sh.exe. This shell fails for numerous 
diff erent reasons
 # so default to using cmd.exe.
+# Also reset BUILDDIR value because "pwd" returns cygwin or msys path
+# which needs to be converted to windows path.
 #--
 ifeq "$(OS)" "Windows_NT"
SHELL = $(WINDIR)\system32\cmd.exe
+   BUILDDIR := $(shell echo %cd%)
 endif
 
 #--



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


[Lldb-commits] [lldb] 0e6a71e - [LLDB] Make build.py use uname to set platform

2022-09-01 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2022-09-01T14:00:47+05:00
New Revision: 0e6a71e6a3d11f6d9c9664b56f304757edf1c82e

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

LOG: [LLDB] Make build.py use uname to set platform

This patch makes build helper script build.py to use platform.uname for
machine/architecture detection. Visual studio environment when set using
various batch files like vcvars*.bat set PLATFORM environment variable
however VsDevCmd.bat does not set PLATFORM variable.

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

Added: 


Modified: 
lldb/test/Shell/helper/build.py

Removed: 




diff  --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index 4b1fe239239a..96684b7b3e66 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -2,6 +2,7 @@
 
 import argparse
 import os
+import platform
 import shutil
 import signal
 import subprocess
@@ -274,7 +275,7 @@ class MsvcBuilder(Builder):
 def __init__(self, toolchain_type, args):
 Builder.__init__(self, toolchain_type, args, '.obj')
 
-if os.getenv('PLATFORM') == 'arm64':
+if platform.uname().machine.lower() == 'arm64':
 self.msvc_arch_str = 'arm' if self.arch == '32' else 'arm64'
 else:
 self.msvc_arch_str = 'x86' if self.arch == '32' else 'x64'



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


[Lldb-commits] [PATCH] D133002: [LLDB] Make API tests to run using MSYS tools

2022-09-01 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4db78322031f: [LLDB] Make API tests to run using MSYS tools 
(authored by omjavaid).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133002

Files:
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -49,8 +49,9 @@
 #--
 # If OS is not defined, use 'uname -s' to determine the OS name.
 #
-# uname on Windows gives "windows32" or "server version windows32", but most
-# environments standardize on "Windows_NT", so we'll make it consistent here.
+# GNUWin32 uname gives "windows32" or "server version windows32" while
+# some versions of MSYS uname return "MSYS_NT*", but most environments
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -58,6 +59,11 @@
 ifneq (,$(findstring windows32,$(HOST_OS)))
HOST_OS := Windows_NT
 endif
+
+ifneq (,$(findstring MSYS_NT,$(HOST_OS)))
+   HOST_OS := Windows_NT
+endif
+
 ifeq "$(OS)" ""
OS := $(HOST_OS)
 endif
@@ -68,9 +74,12 @@
 # Some versions of make on Windows will search for other shells such as
 # C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons
 # so default to using cmd.exe.
+# Also reset BUILDDIR value because "pwd" returns cygwin or msys path
+# which needs to be converted to windows path.
 #--
 ifeq "$(OS)" "Windows_NT"
SHELL = $(WINDIR)\system32\cmd.exe
+   BUILDDIR := $(shell echo %cd%)
 endif
 
 #--


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -49,8 +49,9 @@
 #--
 # If OS is not defined, use 'uname -s' to determine the OS name.
 #
-# uname on Windows gives "windows32" or "server version windows32", but most
-# environments standardize on "Windows_NT", so we'll make it consistent here.
+# GNUWin32 uname gives "windows32" or "server version windows32" while
+# some versions of MSYS uname return "MSYS_NT*", but most environments
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -58,6 +59,11 @@
 ifneq (,$(findstring windows32,$(HOST_OS)))
 	HOST_OS := Windows_NT
 endif
+
+ifneq (,$(findstring MSYS_NT,$(HOST_OS)))
+	HOST_OS := Windows_NT
+endif
+
 ifeq "$(OS)" ""
 	OS := $(HOST_OS)
 endif
@@ -68,9 +74,12 @@
 # Some versions of make on Windows will search for other shells such as
 # C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons
 # so default to using cmd.exe.
+# Also reset BUILDDIR value because "pwd" returns cygwin or msys path
+# which needs to be converted to windows path.
 #--
 ifeq "$(OS)" "Windows_NT"
 	SHELL = $(WINDIR)\system32\cmd.exe
+	BUILDDIR := $(shell echo %cd%)
 endif
 
 #--
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133011: [LLDB] Make build.py use uname to set platform

2022-09-01 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e6a71e6a3d1: [LLDB] Make build.py use uname to set platform 
(authored by omjavaid).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133011

Files:
  lldb/test/Shell/helper/build.py


Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -2,6 +2,7 @@
 
 import argparse
 import os
+import platform
 import shutil
 import signal
 import subprocess
@@ -274,7 +275,7 @@
 def __init__(self, toolchain_type, args):
 Builder.__init__(self, toolchain_type, args, '.obj')
 
-if os.getenv('PLATFORM') == 'arm64':
+if platform.uname().machine.lower() == 'arm64':
 self.msvc_arch_str = 'arm' if self.arch == '32' else 'arm64'
 else:
 self.msvc_arch_str = 'x86' if self.arch == '32' else 'x64'


Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -2,6 +2,7 @@
 
 import argparse
 import os
+import platform
 import shutil
 import signal
 import subprocess
@@ -274,7 +275,7 @@
 def __init__(self, toolchain_type, args):
 Builder.__init__(self, toolchain_type, args, '.obj')
 
-if os.getenv('PLATFORM') == 'arm64':
+if platform.uname().machine.lower() == 'arm64':
 self.msvc_arch_str = 'arm' if self.arch == '32' else 'arm64'
 else:
 self.msvc_arch_str = 'x86' if self.arch == '32' else 'x64'
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133024: [LLDB] Simplify cmake for instruction emulation unit tests

2022-09-01 Thread David Spickett via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd46ea783e6fa: [LLDB] Simplify cmake for instruction 
emulation unit tests (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133024

Files:
  lldb/unittests/Instruction/CMakeLists.txt


Index: lldb/unittests/Instruction/CMakeLists.txt
===
--- lldb/unittests/Instruction/CMakeLists.txt
+++ lldb/unittests/Instruction/CMakeLists.txt
@@ -1,29 +1,14 @@
-set(FILES "")
-set(DEPS "")
-
-if ("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
-  list(APPEND FILES ARM64/TestAArch64Emulator.cpp)
-  list(APPEND DEPS lldbPluginInstructionARM64)
-endif ()
-
-if ("RISCV" IN_LIST LLVM_TARGETS_TO_BUILD)
-  list(APPEND FILES RISCV/TestRISCVEmulator.cpp)
-  list(APPEND DEPS lldbPluginInstructionRISCV)
-endif ()
-
-list(LENGTH FILES LISTLEN)
-
-if (LISTLEN GREATER 0)
-  add_lldb_unittest(EmulatorTests
-${FILES}
-
-LINK_LIBS
-  lldbCore
-  lldbSymbol
-  lldbTarget
-  ${DEPS}
-LINK_COMPONENTS
-  Support
-  ${LLVM_TARGETS_TO_BUILD}
-)
-endif ()
+add_lldb_unittest(EmulatorTests
+  ARM64/TestAArch64Emulator.cpp
+  RISCV/TestRISCVEmulator.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginInstructionARM64
+lldbPluginInstructionRISCV
+
+  LINK_COMPONENTS
+Support
+  )
\ No newline at end of file


Index: lldb/unittests/Instruction/CMakeLists.txt
===
--- lldb/unittests/Instruction/CMakeLists.txt
+++ lldb/unittests/Instruction/CMakeLists.txt
@@ -1,29 +1,14 @@
-set(FILES "")
-set(DEPS "")
-
-if ("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
-  list(APPEND FILES ARM64/TestAArch64Emulator.cpp)
-  list(APPEND DEPS lldbPluginInstructionARM64)
-endif ()
-
-if ("RISCV" IN_LIST LLVM_TARGETS_TO_BUILD)
-  list(APPEND FILES RISCV/TestRISCVEmulator.cpp)
-  list(APPEND DEPS lldbPluginInstructionRISCV)
-endif ()
-
-list(LENGTH FILES LISTLEN)
-
-if (LISTLEN GREATER 0)
-  add_lldb_unittest(EmulatorTests
-${FILES}
-
-LINK_LIBS
-  lldbCore
-  lldbSymbol
-  lldbTarget
-  ${DEPS}
-LINK_COMPONENTS
-  Support
-  ${LLVM_TARGETS_TO_BUILD}
-)
-endif ()
+add_lldb_unittest(EmulatorTests
+  ARM64/TestAArch64Emulator.cpp
+  RISCV/TestRISCVEmulator.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginInstructionARM64
+lldbPluginInstructionRISCV
+
+  LINK_COMPONENTS
+Support
+  )
\ No newline at end of file
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d46ea78 - [LLDB] Simplify cmake for instruction emulation unit tests

2022-09-01 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-09-01T09:40:04Z
New Revision: d46ea783e6fad5d92f9f0aaa96f979ca826403e3

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

LOG: [LLDB] Simplify cmake for instruction emulation unit tests

I got suspicious because of checking "ARM" for an "ARM64" plugin.
As far as I can tell these never needed an llvm target to function.

Looking at the corresponding cmake for the libraries under test they
don't reference target libraries either.

Reviewed By: labath

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

Added: 


Modified: 
lldb/unittests/Instruction/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/Instruction/CMakeLists.txt 
b/lldb/unittests/Instruction/CMakeLists.txt
index c02afe95617eb..1d011d5f7c5b8 100644
--- a/lldb/unittests/Instruction/CMakeLists.txt
+++ b/lldb/unittests/Instruction/CMakeLists.txt
@@ -1,29 +1,14 @@
-set(FILES "")
-set(DEPS "")
-
-if ("ARM" IN_LIST LLVM_TARGETS_TO_BUILD)
-  list(APPEND FILES ARM64/TestAArch64Emulator.cpp)
-  list(APPEND DEPS lldbPluginInstructionARM64)
-endif ()
-
-if ("RISCV" IN_LIST LLVM_TARGETS_TO_BUILD)
-  list(APPEND FILES RISCV/TestRISCVEmulator.cpp)
-  list(APPEND DEPS lldbPluginInstructionRISCV)
-endif ()
-
-list(LENGTH FILES LISTLEN)
-
-if (LISTLEN GREATER 0)
-  add_lldb_unittest(EmulatorTests
-${FILES}
-
-LINK_LIBS
-  lldbCore
-  lldbSymbol
-  lldbTarget
-  ${DEPS}
-LINK_COMPONENTS
-  Support
-  ${LLVM_TARGETS_TO_BUILD}
-)
-endif ()
+add_lldb_unittest(EmulatorTests
+  ARM64/TestAArch64Emulator.cpp
+  RISCV/TestRISCVEmulator.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbPluginInstructionARM64
+lldbPluginInstructionRISCV
+
+  LINK_COMPONENTS
+Support
+  )
\ No newline at end of file



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


[Lldb-commits] [PATCH] D132283: [lldb] [Core] Reimplement Communication::ReadThread using MainLoop

2022-09-01 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/source/Core/Communication.cpp:427
   // Notify the read thread.
-  m_connection_sp->InterruptRead();
 

labath wrote:
> mgorny wrote:
> > labath wrote:
> > > Have you considered putting this code (some version of it) inside 
> > > `InterruptRead`? Basically replacing the `select` call inside 
> > > BytesAvailable with something MainLoop-based ?
> > To be honest, I've been considering removing `InterruptRead()` entirely, 
> > now that the read loop is triggered by available input rather than 
> > read-with-timeout. However, it's still used by editline support.
> > 
> > That said, I'm not sure what's your idea, given that `Connection` does not 
> > have awareness of `Communication` that's using it. I suppose I could pass 
> > the `MainLoop` instance as a parameter but we'd still have to maintain a 
> > separate version for editline support, and we only have a single caller 
> > here.
> > To be honest, I've been considering removing `InterruptRead()` entirely, 
> > now that the read loop is triggered by available input rather than 
> > read-with-timeout. However, it's still used by editline support.
> If we could do that, then it would be even better. And it looks like it 
> should be possible to use a MainLoop instance inside the Editline class, 
> instead of the built-in interruption support.
> 
> > That said, I'm not sure what's your idea, given that `Connection` does not 
> > have awareness of `Communication` that's using it. I suppose I could pass 
> > the `MainLoop` instance as a parameter but we'd still have to maintain a 
> > separate version for editline support, and we only have a single caller 
> > here.
> 
> I don't claim to have thought this out completely, but I was imagining that 
> the MainLoop instance would be internal to the Connection class. The external 
> interface of the Connection class would remain unchanged (so the 
> Communication class would not need to change), and the InterruptRead function 
> would be implemented using the MainLoop functionality.
> > That said, I'm not sure what's your idea, given that `Connection` does not 
> > have awareness of `Communication` that's using it. I suppose I could pass 
> > the `MainLoop` instance as a parameter but we'd still have to maintain a 
> > separate version for editline support, and we only have a single caller 
> > here.
> 
> I don't claim to have thought this out completely, but I was imagining that 
> the MainLoop instance would be internal to the Connection class. The external 
> interface of the Connection class would remain unchanged (so the 
> Communication class would not need to change), and the InterruptRead function 
> would be implemented using the MainLoop functionality.

So basically make `ConnectionFileDescriptor::BytesAvailable()` use a main loop 
to wait for some event, and make `ConnectionFileDescriptor::InterruptRead()` 
interrupt that?

I suppose both options are feasible but I don't have sufficient foresight to 
tell which one is better. That said, I have no clue about 
`ConnectionGenericFileWindows` and I feel that using `MainLoop` would make it 
possible to reduce code duplication between it and CFD. Though I'd preferred 
that someone with access to a Windows environment done that.


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

https://reviews.llvm.org/D132283

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


[Lldb-commits] [lldb] 39e0a87 - [lldb] [Core] Pass error/status from Communication::ReadThread()

2022-09-01 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-09-01T14:16:38+02:00
New Revision: 39e0a87c26e0d2b7498186a446dda4ec3d9b709d

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

LOG: [lldb] [Core] Pass error/status from Communication::ReadThread()

Ensure that the ConnectionStatus and Status from
Communication::ReadThread() is correctly passed to ::Read() in order
to fix further discrepancies between ::Read() calls in non-threaded
and threaded modes.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D132577

Added: 


Modified: 
lldb/include/lldb/Core/Communication.h
lldb/source/Core/Communication.cpp
lldb/unittests/Core/CommunicationTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Communication.h 
b/lldb/include/lldb/Core/Communication.h
index 44b3a16a05269..c07b06a6c2509 100644
--- a/lldb/include/lldb/Core/Communication.h
+++ b/lldb/include/lldb/Core/Communication.h
@@ -324,6 +324,9 @@ class Communication : public Broadcaster {
   m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
   std::recursive_mutex m_bytes_mutex; ///< A mutex to protect multi-threaded
   ///access to the cached bytes.
+  lldb::ConnectionStatus m_pass_status; ///< Connection status passthrough
+///from read thread.
+  Status m_pass_error; ///< Error passthrough from read thread.
   std::mutex
   m_write_mutex; ///< Don't let multiple threads write at the same time...
   std::mutex m_synchronize_mutex;

diff  --git a/lldb/source/Core/Communication.cpp 
b/lldb/source/Core/Communication.cpp
index 56f0990d8c7f7..3606d92a9d4e0 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -162,14 +162,10 @@ size_t Communication::Read(void *dst, size_t dst_len,
 
   if (event_type & eBroadcastBitReadThreadDidExit) {
 // If the thread exited of its own accord, it either means it
-// hit an end-of-file condition or lost connection
-// (we verified that we had an connection above).
-if (!m_connection_sp) {
-  if (error_ptr)
-error_ptr->SetErrorString("Lost connection.");
-  status = eConnectionStatusLostConnection;
-} else
-  status = eConnectionStatusEndOfFile;
+// hit an end-of-file condition or an error.
+status = m_pass_status;
+if (error_ptr)
+  *error_ptr = std::move(m_pass_error);
 
 if (GetCloseOnEOF())
   Disconnect(nullptr);
@@ -384,7 +380,8 @@ lldb::thread_result_t Communication::ReadThread() {
   break;
 }
   }
-  log = GetLog(LLDBLog::Communication);
+  m_pass_status = status;
+  m_pass_error = std::move(error);
   LLDB_LOG(log, "Communication({0}) thread exiting...", this);
 
   // Handle threads wishing to synchronize with us.

diff  --git a/lldb/unittests/Core/CommunicationTest.cpp 
b/lldb/unittests/Core/CommunicationTest.cpp
index 5cb1d4a3bbbf0..a6da6302e5e14 100644
--- a/lldb/unittests/Core/CommunicationTest.cpp
+++ b/lldb/unittests/Core/CommunicationTest.cpp
@@ -15,6 +15,7 @@
 #include "TestingSupport/Host/SocketTestUtilities.h"
 #include "TestingSupport/SubsystemRAII.h"
 
+#include 
 #include 
 
 #if LLDB_ENABLE_POSIX
@@ -78,9 +79,31 @@ static void CommunicationReadTest(bool use_read_thread) {
   EXPECT_EQ(status, lldb::eConnectionStatusEndOfFile);
   EXPECT_THAT_ERROR(error.ToError(), llvm::Succeeded());
 
-  // JoinReadThread() should just return immediately since there was no read
+  // JoinReadThread() should just return immediately if there was no read
   // thread started.
   EXPECT_TRUE(comm.JoinReadThread());
+
+  // Test using Communication that is disconnected.
+  ASSERT_EQ(comm.Disconnect(), lldb::eConnectionStatusSuccess);
+  if (use_read_thread)
+ASSERT_TRUE(comm.StartReadThread());
+  error.Clear();
+  EXPECT_EQ(
+  comm.Read(buf, sizeof(buf), std::chrono::seconds(5), status, &error), 
0U);
+  EXPECT_EQ(status, lldb::eConnectionStatusLostConnection);
+  EXPECT_THAT_ERROR(error.ToError(), llvm::Failed());
+  EXPECT_TRUE(comm.JoinReadThread());
+
+  // Test using Communication without a connection.
+  comm.SetConnection(nullptr);
+  if (use_read_thread)
+ASSERT_TRUE(comm.StartReadThread());
+  error.Clear();
+  EXPECT_EQ(
+  comm.Read(buf, sizeof(buf), std::chrono::seconds(5), status, &error), 
0U);
+  EXPECT_EQ(status, lldb::eConnectionStatusNoConnection);
+  EXPECT_THAT_ERROR(error.ToError(), llvm::Failed());
+  EXPECT_TRUE(comm.JoinReadThread());
 }
 
 TEST_F(CommunicationTest, Read) {



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


[Lldb-commits] [PATCH] D132577: [lldb] [Core] Pass error/status from Communication::ReadThread()

2022-09-01 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39e0a87c26e0: [lldb] [Core] Pass error/status from 
Communication::ReadThread() (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D132577?vs=455950&id=457233#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132577

Files:
  lldb/include/lldb/Core/Communication.h
  lldb/source/Core/Communication.cpp
  lldb/unittests/Core/CommunicationTest.cpp


Index: lldb/unittests/Core/CommunicationTest.cpp
===
--- lldb/unittests/Core/CommunicationTest.cpp
+++ lldb/unittests/Core/CommunicationTest.cpp
@@ -15,6 +15,7 @@
 #include "TestingSupport/Host/SocketTestUtilities.h"
 #include "TestingSupport/SubsystemRAII.h"
 
+#include 
 #include 
 
 #if LLDB_ENABLE_POSIX
@@ -78,9 +79,31 @@
   EXPECT_EQ(status, lldb::eConnectionStatusEndOfFile);
   EXPECT_THAT_ERROR(error.ToError(), llvm::Succeeded());
 
-  // JoinReadThread() should just return immediately since there was no read
+  // JoinReadThread() should just return immediately if there was no read
   // thread started.
   EXPECT_TRUE(comm.JoinReadThread());
+
+  // Test using Communication that is disconnected.
+  ASSERT_EQ(comm.Disconnect(), lldb::eConnectionStatusSuccess);
+  if (use_read_thread)
+ASSERT_TRUE(comm.StartReadThread());
+  error.Clear();
+  EXPECT_EQ(
+  comm.Read(buf, sizeof(buf), std::chrono::seconds(5), status, &error), 
0U);
+  EXPECT_EQ(status, lldb::eConnectionStatusLostConnection);
+  EXPECT_THAT_ERROR(error.ToError(), llvm::Failed());
+  EXPECT_TRUE(comm.JoinReadThread());
+
+  // Test using Communication without a connection.
+  comm.SetConnection(nullptr);
+  if (use_read_thread)
+ASSERT_TRUE(comm.StartReadThread());
+  error.Clear();
+  EXPECT_EQ(
+  comm.Read(buf, sizeof(buf), std::chrono::seconds(5), status, &error), 
0U);
+  EXPECT_EQ(status, lldb::eConnectionStatusNoConnection);
+  EXPECT_THAT_ERROR(error.ToError(), llvm::Failed());
+  EXPECT_TRUE(comm.JoinReadThread());
 }
 
 TEST_F(CommunicationTest, Read) {
Index: lldb/source/Core/Communication.cpp
===
--- lldb/source/Core/Communication.cpp
+++ lldb/source/Core/Communication.cpp
@@ -162,14 +162,10 @@
 
   if (event_type & eBroadcastBitReadThreadDidExit) {
 // If the thread exited of its own accord, it either means it
-// hit an end-of-file condition or lost connection
-// (we verified that we had an connection above).
-if (!m_connection_sp) {
-  if (error_ptr)
-error_ptr->SetErrorString("Lost connection.");
-  status = eConnectionStatusLostConnection;
-} else
-  status = eConnectionStatusEndOfFile;
+// hit an end-of-file condition or an error.
+status = m_pass_status;
+if (error_ptr)
+  *error_ptr = std::move(m_pass_error);
 
 if (GetCloseOnEOF())
   Disconnect(nullptr);
@@ -384,7 +380,8 @@
   break;
 }
   }
-  log = GetLog(LLDBLog::Communication);
+  m_pass_status = status;
+  m_pass_error = std::move(error);
   LLDB_LOG(log, "Communication({0}) thread exiting...", this);
 
   // Handle threads wishing to synchronize with us.
Index: lldb/include/lldb/Core/Communication.h
===
--- lldb/include/lldb/Core/Communication.h
+++ lldb/include/lldb/Core/Communication.h
@@ -324,6 +324,9 @@
   m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
   std::recursive_mutex m_bytes_mutex; ///< A mutex to protect multi-threaded
   ///access to the cached bytes.
+  lldb::ConnectionStatus m_pass_status; ///< Connection status passthrough
+///from read thread.
+  Status m_pass_error; ///< Error passthrough from read thread.
   std::mutex
   m_write_mutex; ///< Don't let multiple threads write at the same time...
   std::mutex m_synchronize_mutex;


Index: lldb/unittests/Core/CommunicationTest.cpp
===
--- lldb/unittests/Core/CommunicationTest.cpp
+++ lldb/unittests/Core/CommunicationTest.cpp
@@ -15,6 +15,7 @@
 #include "TestingSupport/Host/SocketTestUtilities.h"
 #include "TestingSupport/SubsystemRAII.h"
 
+#include 
 #include 
 
 #if LLDB_ENABLE_POSIX
@@ -78,9 +79,31 @@
   EXPECT_EQ(status, lldb::eConnectionStatusEndOfFile);
   EXPECT_THAT_ERROR(error.ToError(), llvm::Succeeded());
 
-  // JoinReadThread() should just return immediately since there was no read
+  // JoinReadThread() should just return immediately if there was no read
   // thread started.
   EXPECT_TRUE(comm.JoinReadThread());
+
+  // Test using Communication that is disconnected.
+  ASSERT_EQ(comm.Disconnect(), 

[Lldb-commits] [PATCH] D132940: [lldb] Use just-built libcxx for tests when available

2022-09-01 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve added a comment.



> is used by (a lot) more tests than just TestAppleSimulatorOSType. In that 
> case, I would say that this argument should be passed directly from python, 
> as a part of the `self.build` command (the test already passes a bunch of 
> arguments there anyway).

Good catch! Will change it in the next revision




Comment at: lldb/packages/Python/lldbsuite/test/make/Makefile.rules:381-386
+ifneq ($(and $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+   $(error Libcxx and Libstdc++ cannot be used together)
+endif
+
+ifeq (1, $(USE_SYSTEM_STDLIB))
+   ifneq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP)),)

labath wrote:
> Instead of three distinct variables, it might be nicer to just have one 
> argument (STDLIB_KIND ?) which can take three different values...
I think this could be an improvement, but since it would involve changing _all_ 
makefiles that define these variables, IMO it would be better to do it in a 
separate NFC change, if that's ok


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132940

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


[Lldb-commits] [PATCH] D132940: [lldb] Use just-built libcxx for tests when available

2022-09-01 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve updated this revision to Diff 457252.
fdeazeve added a comment.

Addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132940

Files:
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/test/API/lang/objc/exceptions/Makefile
  lldb/test/API/macosx/macCatalyst/Makefile
  lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py


Index: lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
===
--- lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -70,6 +70,7 @@
 'SDKROOT': sdkroot.strip(),
 'ARCH': arch,
 'ARCH_CFLAGS': '-target {} {}'.format(triple, version_min),
+'USE_SYSTEM_STDLIB': 1,
 })
 exe_path = os.path.realpath(self.getBuildArtifact(exe_name))
 cmd = [
Index: lldb/test/API/macosx/macCatalyst/Makefile
===
--- lldb/test/API/macosx/macCatalyst/Makefile
+++ lldb/test/API/macosx/macCatalyst/Makefile
@@ -3,6 +3,8 @@
 override TRIPLE := $(ARCH)-apple-ios13.1-macabi
 CFLAGS_EXTRAS := -target $(TRIPLE)
 
+USE_SYSTEM_STDLIB := 1
+
 # FIXME: rdar://problem/54986190
 # There is a Clang driver change missing on llvm.org.
 override CC=xcrun clang
Index: lldb/test/API/lang/objc/exceptions/Makefile
===
--- lldb/test/API/lang/objc/exceptions/Makefile
+++ lldb/test/API/lang/objc/exceptions/Makefile
@@ -2,7 +2,7 @@
 
 CFLAGS_EXTRAS := -w
 
-
+USE_SYSTEM_STDLIB := 1
 
 LD_EXTRAS := -framework Foundation
 include Makefile.rules
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -378,6 +378,16 @@
 #--
 # C++ standard library options
 #--
+ifneq ($(and $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+   $(error Libcxx and Libstdc++ cannot be used together)
+endif
+
+ifeq (1, $(USE_SYSTEM_STDLIB))
+   ifneq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+   $(error Cannot use system's library and a custom library 
together)
+   endif
+endif
+
 ifeq (1,$(USE_LIBSTDCPP))
# Clang requires an extra flag: -stdlib=libstdc++
ifneq (,$(findstring clang,$(CC)))
@@ -406,6 +416,15 @@
endif
 endif
 
+# If no explicit request was made, but we have paths to a custom libcxx, use
+# them.
+ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), $(USE_SYSTEM_STDLIB)),)
+   ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
+   CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem 
$(LIBCPP_INCLUDE_DIR)
+   LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) 
-lc++
+   endif
+endif
+
 #--
 # Additional system libraries
 #--


Index: lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
===
--- lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -70,6 +70,7 @@
 'SDKROOT': sdkroot.strip(),
 'ARCH': arch,
 'ARCH_CFLAGS': '-target {} {}'.format(triple, version_min),
+'USE_SYSTEM_STDLIB': 1,
 })
 exe_path = os.path.realpath(self.getBuildArtifact(exe_name))
 cmd = [
Index: lldb/test/API/macosx/macCatalyst/Makefile
===
--- lldb/test/API/macosx/macCatalyst/Makefile
+++ lldb/test/API/macosx/macCatalyst/Makefile
@@ -3,6 +3,8 @@
 override TRIPLE := $(ARCH)-apple-ios13.1-macabi
 CFLAGS_EXTRAS := -target $(TRIPLE)
 
+USE_SYSTEM_STDLIB := 1
+
 # FIXME: rdar://problem/54986190
 # There is a Clang driver change missing on llvm.org.
 override CC=xcrun clang
Index: lldb/test/API/lang/objc/exceptions/Makefile
===
--- lldb/test/API/lang/objc/exceptions/Makefile
+++ lldb/test/API/lang/objc/exceptions/Makefile
@@ -2,7 +2,7 @@
 
 CFLAGS_EXTRAS := -w
 
-
+USE_SYSTEM_STDLIB := 1
 
 LD_EXTRAS := -framework Foundation
 include Makefile.rules
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@

[Lldb-commits] [PATCH] D131160: [WIP][lldb] Add "event" capability to the MainLoop class

2022-09-01 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

In D131160#3738805 , @labath wrote:

> What's the reasoning behind `TriggerPendingCallbacks`? I was assuming that 
> the addition of a callback would cause it to run automatically...

To be honest, I didn't think about it much. The original idea is that we can 
either have "non-important" callbacks that will be run at some point in the 
future, and "important" callbacks that should be run ASAP. However, I'm not 
really married to this idea, so I can make them triggered immediately if you 
prefer that.

In D131160#3761163 , @labath wrote:

> In D131160#3751959 , @mgorny wrote:
>
>> In that case, is there something more I should do about this patch or are 
>> you going to take over from here?
>
> It wasn't clear to me whether you intend to finish this patch (and I was 
> waiting on your response to this ). 
> That said, if you don't have any strong opinions there, then I can try to 
> finish this.

Ah, sorry, missed that comment. I can change that logic if you prefer. 
Otherwise, I think the next thing that needs to be here is testing/fixing the 
Windows code, and I'd be grateful if you could do that.


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

https://reviews.llvm.org/D131160

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


[Lldb-commits] [PATCH] D133129: [lldb] Add boilerplate for debugger interrupts

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

Jim is looking into adding support for interrupts to the SB API. Part of that 
work requires clearing the interrupt bit once we return from the SB API. 
Luckily, this is already tracked by the API instrumentation. This patch adds 
the necessary interruption boilerplate to hook it up with the SB API 
instrumentation.


https://reviews.llvm.org/D133129

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Utility/Instrumentation.h
  lldb/source/Core/Debugger.cpp
  lldb/source/Utility/Instrumentation.cpp
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/InstrumentationTest.cpp

Index: lldb/unittests/Utility/InstrumentationTest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/InstrumentationTest.cpp
@@ -0,0 +1,49 @@
+//===-- InstrumentationTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/Instrumentation.h"
+
+using namespace llvm;
+using namespace lldb_private;
+using namespace lldb_private::instrumentation;
+
+TEST(InsturmentationTest, Callback) {
+  size_t entry = 0;
+  size_t exit = 0;
+
+  Instrumenter::UnregisterCallbacks();
+
+  Instrumenter::RegisterEntryCallback([&]() { entry++; });
+  Instrumenter::RegisterExitCallback([&]() { exit++; });
+
+  EXPECT_EQ(entry, 0UL);
+  EXPECT_EQ(exit, 0UL);
+
+  {
+Instrumenter foo("foo");
+EXPECT_EQ(entry, 1UL);
+EXPECT_EQ(exit, 0UL);
+  }
+
+  EXPECT_EQ(entry, 1UL);
+  EXPECT_EQ(exit, 1UL);
+
+  {
+Instrumenter bar("bar");
+EXPECT_EQ(entry, 2UL);
+EXPECT_EQ(exit, 1UL);
+  }
+
+  EXPECT_EQ(entry, 2UL);
+  EXPECT_EQ(exit, 2UL);
+
+  Instrumenter::UnregisterCallbacks();
+}
Index: lldb/unittests/Utility/CMakeLists.txt
===
--- lldb/unittests/Utility/CMakeLists.txt
+++ lldb/unittests/Utility/CMakeLists.txt
@@ -13,6 +13,7 @@
   EventTest.cpp
   FileSpecTest.cpp
   FlagsTest.cpp
+  InstrumentationTest.cpp
   ListenerTest.cpp
   LogTest.cpp
   NameMatchesTest.cpp
Index: lldb/source/Utility/Instrumentation.cpp
===
--- lldb/source/Utility/Instrumentation.cpp
+++ lldb/source/Utility/Instrumentation.cpp
@@ -23,12 +23,20 @@
 // Instrument SB API calls with singposts when supported.
 static llvm::ManagedStatic g_api_signposts;
 
+// Callbacks for entering the instrumentation boundary.
+static std::vector g_entry_callbacks;
+
+// Callbacks for leaving the instrumentation boundary.
+static std::vector g_exit_callbacks;
+
 Instrumenter::Instrumenter(llvm::StringRef pretty_func,
std::string &&pretty_args)
 : m_pretty_func(pretty_func) {
   if (!g_global_boundary) {
 g_global_boundary = true;
 m_local_boundary = true;
+for (Callback callback : g_entry_callbacks)
+  callback();
 g_api_signposts->startInterval(this, m_pretty_func);
   }
   LLDB_LOG(GetLog(LLDBLog::API), "[{0}] {1} ({2})",
@@ -39,6 +47,21 @@
 Instrumenter::~Instrumenter() {
   if (m_local_boundary) {
 g_global_boundary = false;
+for (Callback callback : g_exit_callbacks)
+  callback();
 g_api_signposts->endInterval(this, m_pretty_func);
   }
 }
+
+void Instrumenter::RegisterEntryCallback(Instrumenter::Callback callback) {
+  g_entry_callbacks.emplace_back(std::move(callback));
+}
+
+void Instrumenter::RegisterExitCallback(Instrumenter::Callback callback) {
+  g_exit_callbacks.emplace_back(std::move(callback));
+}
+
+void Instrumenter::UnregisterCallbacks() {
+  g_entry_callbacks.clear();
+  g_exit_callbacks.clear();
+}
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -45,6 +45,7 @@
 #include "lldb/Target/ThreadList.h"
 #include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/Event.h"
+#include "lldb/Utility/Instrumentation.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Listener.h"
 #include "lldb/Utility/Log.h"
@@ -542,6 +543,7 @@
   g_debugger_list_ptr = new DebuggerList();
   g_thread_pool = new llvm::ThreadPool(llvm::optimal_concurrency());
   g_load_plugin_callback = load_plugin_callback;
+  instrumentation::Instrumenter::RegisterExitCallback([]() { Debugger::ClearInterrupts(); });
 }
 
 void Debugger::Terminate() {
@@ -1303,6 +1305,23 @@
   std::make_shared(log_callback, baton);
 }
 
+void Debugger::Requ

[Lldb-commits] [PATCH] D133130: [lldb][bindings] Fix module_access handling of regex

2022-09-01 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: mib, JDevlieghere.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Fixes broken support for: `target.module[re.compile("libFoo")]`

There were two issues:

1. The type check was expecting `re.SRE_Pattern`
2. The expression to search the module path had a typo

In the first case, `re.SRE_Pattern` does not exist in Python 3, and is replaced
with `re.Pattern`.

While editing this code, I changed the type checks to us `isinstance`, which is
the conventional way of type checking.

>From the docs on `type()`:

> The `isinstance()` built-in function is recommended for testing the type of 
> an object, because it takes subclasses into account.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133130

Files:
  lldb/bindings/interface/SBTarget.i


Index: lldb/bindings/interface/SBTarget.i
===
--- lldb/bindings/interface/SBTarget.i
+++ lldb/bindings/interface/SBTarget.i
@@ -1000,10 +1000,10 @@
 
 def __getitem__(self, key):
 num_modules = self.sbtarget.GetNumModules()
-if type(key) is int:
+if isinstance(key, int):
 if key < num_modules:
 return self.sbtarget.GetModuleAtIndex(key)
-elif type(key) is str:
+elif isinstance(key, str):
 if key.find('/') == -1:
 for idx in range(num_modules):
 module = self.sbtarget.GetModuleAtIndex(idx)
@@ -1024,16 +1024,16 @@
 return module
 except:
 return None
-elif type(key) is uuid.UUID:
+elif isinstance(key, uuid.UUID):
 for idx in range(num_modules):
 module = self.sbtarget.GetModuleAtIndex(idx)
 if module.uuid == key:
 return module
-elif type(key) is re.SRE_Pattern:
+elif isinstance(key, re.Pattern):
 matching_modules = []
 for idx in range(num_modules):
 module = self.sbtarget.GetModuleAtIndex(idx)
-re_match = key.search(module.path.fullpath)
+re_match = key.search(module.file.fullpath)
 if re_match:
 matching_modules.append(module)
 return matching_modules


Index: lldb/bindings/interface/SBTarget.i
===
--- lldb/bindings/interface/SBTarget.i
+++ lldb/bindings/interface/SBTarget.i
@@ -1000,10 +1000,10 @@
 
 def __getitem__(self, key):
 num_modules = self.sbtarget.GetNumModules()
-if type(key) is int:
+if isinstance(key, int):
 if key < num_modules:
 return self.sbtarget.GetModuleAtIndex(key)
-elif type(key) is str:
+elif isinstance(key, str):
 if key.find('/') == -1:
 for idx in range(num_modules):
 module = self.sbtarget.GetModuleAtIndex(idx)
@@ -1024,16 +1024,16 @@
 return module
 except:
 return None
-elif type(key) is uuid.UUID:
+elif isinstance(key, uuid.UUID):
 for idx in range(num_modules):
 module = self.sbtarget.GetModuleAtIndex(idx)
 if module.uuid == key:
 return module
-elif type(key) is re.SRE_Pattern:
+elif isinstance(key, re.Pattern):
 matching_modules = []
 for idx in range(num_modules):
 module = self.sbtarget.GetModuleAtIndex(idx)
-re_match = key.search(module.path.fullpath)
+re_match = key.search(module.file.fullpath)
 if re_match:
 matching_modules.append(module)
 return matching_modules
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133130: [lldb][bindings] Fix module_access handling of regex

2022-09-01 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.

Makes sense, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133130

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


[Lldb-commits] [PATCH] D133130: [lldb][bindings] Fix module_access handling of regex

2022-09-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.

LGTM! I guess this API was not exercised (since no one noticed the `path` -> 
`file` typo) ... Could you add a test before landing this ? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133130

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


[Lldb-commits] [PATCH] D133130: [lldb][bindings] Fix module_access handling of regex

2022-09-01 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

@mib will do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133130

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


[Lldb-commits] [PATCH] D133038: Add GetSourceMap public API

2022-09-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/bindings/interface/SBTarget.i:969
 
+lldb::SBStructuredData GetSourceMap();
+

Do we want to actually have something more like this:
```
lldb::SBStructuredData GetSetting(const char *setting);
```
That allows us to get any setting as structured data? We have a lot of settings 
and I would rather not have an API for each one of these added to the public 
API as we need them. 

Eventually we could also have:

```
void SetSetting(lldb::SBStructuredData &data);
```

This would allow the output to contain multiple settings if needed. Hopefully 
the output would be in the format of:
```
{ "target.source-map": [["", ""], ...] }
```
This would allow us to export all settings, and then import them.



Comment at: lldb/source/Target/PathMappingList.cpp:138
+llvm::json::Object entry;
+entry.try_emplace("first", pair.first.GetStringRef().str());
+entry.try_emplace("second", pair.second.GetStringRef().str());

jingham wrote:
> Can we call these something more instructive than "first" and "second"?  
> These are the "original" path and the "substitution" path, maybe those would 
> be good keys?
We can either do this as a key/value pair thing or just as a array of array 
path pairs in JSON? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133038

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


[Lldb-commits] [PATCH] D132578: [lldb] [Core] Use thread for Communication::Write() as well

2022-09-01 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Well, my "baseline" idea was something like that: having a shared (e.g. via 
`shared_ptr`) `m_gdb_comm`, and running async thread as part of that. The 
thread would read packets from remote and split them into two groups: 
asynchronous events (i.e. stop reasons and related packets) and synchronous 
replies. This is reasonably easy for non-stop protocol since the former are 
always sent as `%` notification, while the latter as regular packets. For 
non-nonstop case, I suppose we would just trigger some explicit switch on 
resuming/leaving resume. Asynchronous events would be passed (e.g. via 
callback) to process instances that are currently resumed. Synchronous replies 
would be just passed to whichever process is currently waiting for the reply.

However, the problem with that design is that it requires a lot of different 
changes, and the gdb-remote plugin code is not exactly friendly to that. So I 
was trying to split it into smaller steps that would be testable and reviewable 
on their own, i.e. basically refactor, refactor, get multiprocess working, 
cleanup, cleanup. What these changes were aiming at was basically moving all 
the reads and writes from gdb-remote into a dedicated thread reusing the code 
already in LLDB, so I could initially add support for the new "async" thread 
and handling the resume-related packets there without having to immediately 
replace the existing code for synchronous packets that reads and writes to 
`m_gdb_comm` directly from a lot of places. However, now that I think of it, I 
didn't really think it through and using read thread along with some trivial 
locking and queues won't be sufficient to be able to cleanly supports reading 
these two kinds of packets from different threads.

At this point I'm basically lost in the woods and I'm not really sure how to 
proceed, or how much of this code is actually worth further consideration.


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

https://reviews.llvm.org/D132578

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


[Lldb-commits] [lldb] afeb2d0 - [LLDB][NativePDB] Fix a minor bug.

2022-09-01 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2022-09-01T13:10:57-07:00
New Revision: afeb2d0a21e383b5436b539f311ea00803d24e24

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

LOG: [LLDB][NativePDB] Fix a minor bug.

llvm::codeview::visitMemberRecordStream in CompleteTagDecl will call
GetOrCreateType create type if not seen before, which inserts new entries
into m_decl_to_status. This may invalidates status which is a reference to
std::pair::second from DenseMapIterator.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp 
b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index b8848839f24f7..21b1cb2384994 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -776,7 +776,7 @@ bool PdbAstBuilder::CompleteTagDecl(clang::TagDecl &tag) {
   llvm::codeview::visitMemberRecordStream(field_list.Data, completer);
   completer.complete();
 
-  status.resolved = true;
+  m_decl_to_status[&tag].resolved = true;
   if (error) {
 llvm::consumeError(std::move(error));
 return false;



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


[Lldb-commits] [PATCH] D133069: Fix inconsistent target arch when attaching to arm64 binaries on arm64e platforms.

2022-09-01 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 457416.
aprantl added a comment.

Address feedback!


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

https://reviews.llvm.org/D133069

Files:
  lldb/include/lldb/Target/Target.h
  lldb/packages/Python/lldbsuite/test/gdbclientutils.py
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py
@@ -0,0 +1,143 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import *
+
+images = """
+{"images":[
+{"load_address":4370792448,
+ "mod_date":0,
+ "pathname":"/usr/lib/dyld",
+ "uuid":"75627683-A780-32AD-AE34-CF86DD23A26B",
+ "min_version_os_name":"macosx",
+ "min_version_os_sdk":"12.5",
+ "mach_header":{
+ "magic":4277009103,
+ "cputype":16777228,
+ "cpusubtype":2,
+ "filetype":7,
+ "flags":133},
+"segments":[
+{"name":"__TEXT",
+ "vmaddr":0,
+ "vmsize":393216,
+ "fileoff":0,
+ "filesize":393216,
+ "maxprot":5},
+{"name":"__DATA_CONST",
+ "vmaddr":393216,
+ "vmsize":98304,
+ "fileoff":393216,
+ "filesize":98304,
+ "maxprot":3},
+{"name":"__DATA",
+ "vmaddr":491520,
+ "vmsize":16384,
+ "fileoff":491520,
+ "filesize":16384,
+ "maxprot":3},
+{"name":"__LINKEDIT",
+ "vmaddr":507904,
+ "vmsize":229376,
+ "fileoff":507904,
+ "filesize":227520,
+ "maxprot":1}
+]
+},
+{"load_address":4369842176,
+ "mod_date":0,
+ "pathname":"/tmp/a.out",
+ "uuid":"536A0A09-792A-377C-BEBA-FFB00A787C38",
+ "min_version_os_name":"macosx",
+ "min_version_os_sdk":"12.0",
+ "mach_header":{
+ "magic":4277009103,
+ "cputype":16777228,
+ "cpusubtype":%s,
+ "filetype":2,
+ "flags":2097285
+ },
+ "segments":[
+ {"name":"__PAGEZERO",
+  "vmaddr":0,
+  "vmsize":4294967296,
+  "fileoff":0,
+  "filesize":0,
+  "maxprot":0},
+ {"name":"__TEXT",
+  "vmaddr":4294967296,
+  "vmsize":16384,
+  "fileoff":0,
+  "filesize":16384,
+  "maxprot":5},
+ {"name":"__DATA_CONST",
+  "vmaddr":4294983680,
+  "vmsize":16384,
+  "fileoff":16384,
+  "filesize":16384,
+  "maxprot":3},
+ {"name":"__LINKEDIT",
+  "vmaddr":429564,
+  "vmsize":32768,
+  "fileoff":32768,
+  "filesize":19488,
+  "maxprot":1}]
+}
+]
+}
+"""
+
+arm64_binary = "cffaedfe0c0102001000e80285002000190048005f5f504147455a45524f01001900e8005f5f54455854014000400500050002005f5f746578745f5f54455854b03f01000800b03f020400805f5f756e77696e645f696e666f005f5f54455854b83f01004800b83f0200190048005f5f4c494e4b45444954004001400040b801010001003480104038003380100038403200180070400100804018000b00510001000e002c002f7573722f6c69622f64796c64001b001800a9981092eb3632f4afd9957e769160d9320021000c050c000100030633032a00100028801800b03f0c0038001800020001781f0501002f7573722f6c69622f6c696253797374656d2e422e64796c696226001000684008002900100070401d001000a0401801" + '0'*16384
+
+class TestDynamicLoaderDarwin(GDBRemoteTestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+class MyResponder(MockGDBServerResponder):
+
+def __init__(self, cpusubtype):
+self.cpusubtype = cpusubtype
+MockGDBServerResponder.__init__(self)
+
+def respond(self, packet):
+if packet == 

[Lldb-commits] [PATCH] D133164: Add the ability to show when variables fails to be available when debug info is valid.

2022-09-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, jingham, aadsm, yinghuitan.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
Herald added a project: LLDB.

Many times when debugging variables might not be available even though a user 
can successfully set breakpoints and stops somewhere. Letting the user know 
will help users fix these kinds of issues and have a better debugging 
experience.

Examples of this include:

- enabling -gline-tables-only and being able to set file and line breakpoints 
and yet see no variables
- unable to open object file for DWARF in .o file debugging for darwin targets 
due to modification time mismatch or not being able to locate the N_OSO file.

This patch adds an new API to SBValueList:

  lldb::SBError lldb::SBValueList::GetError();

object so that if you request a stack frame's variables using SBValueList 
SBFrame::GetVariables(...), you can get an error the describes why the 
variables were not available.

This patch adds the ability to get an error back when requesting variables from 
a lldb_private::StackFrame when calling GetVariableList.

It also now shows an error in response to "frame variable" if we have debug 
info and are unable to get varialbes due to an error as mentioned above:

(lldb) frame variable
error: "a.o" object from the "/tmp/libfoo.a" archive: either the .o file 
doesn't exist in the archive or the modification time (0x63111541) of the .o 
file doesn't match


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133164

Files:
  lldb/bindings/interface/SBValueList.i
  lldb/include/lldb/API/SBError.h
  lldb/include/lldb/API/SBValueList.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/StackFrame.h
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBFrame.cpp
  lldb/source/API/SBValueList.cpp
  lldb/source/Commands/CommandObjectFrame.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Symbol/Variable.cpp
  lldb/source/Target/StackFrame.cpp
  lldb/test/API/commands/frame/var/TestFrameVar.py
  lldb/test/API/functionalities/archives/Makefile
  lldb/test/API/functionalities/archives/TestBSDArchives.py

Index: lldb/test/API/functionalities/archives/TestBSDArchives.py
===
--- lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -6,10 +6,16 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
-
+import os
+import time
 
 class BSDArchivesTestCase(TestBase):
 
+# If your test case doesn't stress debug info, then
+# set this to true.  That way it won't be run once for
+# each debug info format.
+NO_DEBUG_INFO_TESTCASE = True
+
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
@@ -17,8 +23,6 @@
 self.line = line_number(
 'a.c', '// Set file and line breakpoint inside a().')
 
-# Doesn't depend on any specific debug information.
-@no_debug_info_test
 @expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24527.  Makefile.rules doesn't know how to build static libs on Windows")
@@ -65,3 +69,80 @@
 num_specs = module_specs.GetSize()
 self.assertEqual(num_specs, 1)
 self.assertEqual(module_specs.GetSpecAtIndex(0).GetObjectName(), "c.o")
+
+
+def check_frame_variable_errors(self, thread, error_strings):
+command_result = lldb.SBCommandReturnObject()
+interp = self.dbg.GetCommandInterpreter()
+result = interp.HandleCommand("frame variable", command_result)
+self.assertEqual(result, lldb.eReturnStatusFailed,
+ "frame var succeeded unexpectedly")
+command_error = command_result.GetError()
+
+frame = thread.GetFrameAtIndex(0)
+var_list = frame.GetVariables(True, True, False, True)
+self.assertEqual(var_list.GetSize(), 0)
+api_error = var_list.GetError().GetCString()
+
+for s in error_strings:
+self.assertTrue(s in command_error, 'Make sure "%s" exists in the command error "%s"' % (s, command_error))
+for s in error_strings:
+self.assertTrue(s in api_error, 'Make sure "%s" exists in the API error "%s"' % (s, api_error))
+
+@skipIfRemote
+@skipUnlessDarwin
+def test_frame_var_errors_when_archive_missing(self):
+"""
+ 

[Lldb-commits] [PATCH] D133069: Fix inconsistent target arch when attaching to arm64 binaries on arm64e platforms.

2022-09-01 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.

That test is not going to win any beauty pageants but it looks like it gets the 
job done. LGTM.


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

https://reviews.llvm.org/D133069

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


[Lldb-commits] [lldb] ced4e00 - Fix inconsistent target arch when attaching to arm64 binaries on

2022-09-01 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2022-09-01T16:39:35-07:00
New Revision: ced4e0006fab22f37a165635896a6776f79bc4a9

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

LOG: Fix inconsistent target arch when attaching to arm64 binaries on
arm64e platforms.

On arm64e-capable Apple platforms, the system libraries are always
arm64e, but applications often are arm64. When a target is created
from file, LLDB recognizes it as an arm64 target, but debugserver will
still (technically correct) report the process as being arm64e. For
consistency, set the target to arm64 here.

rdar://92248684

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

Added: 
lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py

Modified: 
lldb/include/lldb/Target/Target.h
lldb/packages/Python/lldbsuite/test/gdbclientutils.py
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 796e98ddb6342..89688ad52a7df 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1009,9 +1009,14 @@ class Target : public 
std::enable_shared_from_this,
   /// currently selected platform isn't compatible (in case it might be
   /// manually set following this function call).
   ///
+  /// \param[in] merged
+  /// If true, arch_spec is merged with the current
+  /// architecture. Otherwise it's replaced.
+  ///
   /// \return
   /// \b true if the architecture was successfully set, \b false otherwise.
-  bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false);
+  bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false,
+   bool merge = true);
 
   bool MergeArchitecture(const ArchSpec &arch_spec);
 

diff  --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py 
b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
index 68ac0e07b4a14..7e78963a1571f 100644
--- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
+++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py
@@ -185,6 +185,8 @@ def respond(self, packet):
 return self.qsProcessInfo()
 if packet.startswith("qfProcessInfo"):
 return self.qfProcessInfo(packet)
+if packet.startswith("jGetLoadedDynamicLibrariesInfos"):
+return self.jGetLoadedDynamicLibrariesInfos(packet)
 if packet.startswith("qPathComplete:"):
 return self.qPathComplete()
 if packet.startswith("vFile:"):
@@ -211,6 +213,9 @@ def qsProcessInfo(self):
 def qfProcessInfo(self, packet):
 return "E04"
 
+def jGetLoadedDynamicLibrariesInfos(self, packet):
+return ""
+
 def qGetWorkingDir(self):
 return "2f"
 

diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index d6c890c64b98e..a54d4c062f375 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -567,8 +567,27 @@ void 
DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
 exe_module_sp->GetFileSpec().GetPath().c_str());
   target.GetImages().AppendIfNeeded(exe_module_sp);
   UpdateImageLoadAddress(exe_module_sp.get(), image_infos[exe_idx]);
-  if (exe_module_sp.get() != target.GetExecutableModulePointer()) {
+  if (exe_module_sp.get() != target.GetExecutableModulePointer())
 target.SetExecutableModule(exe_module_sp, eLoadDependentsNo);
+
+  // Update the target executable's arch if necessary.
+  auto exe_triple = exe_module_sp->GetArchitecture().GetTriple();
+  if (target_arch.GetTriple().isArm64e() &&
+  exe_triple.getArch() == llvm::Triple::aarch64 &&
+  !exe_triple.isArm64e()) {
+// On arm64e-capable Apple platforms, the system libraries are
+// always arm64e, but applications often are arm64. When a
+// target is created from a file, LLDB recognizes it as an
+// arm64 target, but debugserver will still (technically
+// correct) report the process as being arm64e. For
+// consistency, set the target to arm64 here, so attaching to
+// a live process behaves the same as creating a process from
+// file.
+auto triple = target_arch.GetTriple();
+triple.setArchName(exe_triple.getArchName());
+target_arch.SetTriple(triple);
+target.SetArchitecture(target_arch, /*set_platform=*/false,
+   /*merge=*/false);
   }
 }
   }

diff  --git a/lldb/

[Lldb-commits] [PATCH] D133069: Fix inconsistent target arch when attaching to arm64 binaries on arm64e platforms.

2022-09-01 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGced4e0006fab: Fix inconsistent target arch when attaching to 
arm64 binaries on (authored by aprantl).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133069

Files:
  lldb/include/lldb/Target/Target.h
  lldb/packages/Python/lldbsuite/test/gdbclientutils.py
  lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py
@@ -0,0 +1,143 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import *
+
+images = """
+{"images":[
+{"load_address":4370792448,
+ "mod_date":0,
+ "pathname":"/usr/lib/dyld",
+ "uuid":"75627683-A780-32AD-AE34-CF86DD23A26B",
+ "min_version_os_name":"macosx",
+ "min_version_os_sdk":"12.5",
+ "mach_header":{
+ "magic":4277009103,
+ "cputype":16777228,
+ "cpusubtype":2,
+ "filetype":7,
+ "flags":133},
+"segments":[
+{"name":"__TEXT",
+ "vmaddr":0,
+ "vmsize":393216,
+ "fileoff":0,
+ "filesize":393216,
+ "maxprot":5},
+{"name":"__DATA_CONST",
+ "vmaddr":393216,
+ "vmsize":98304,
+ "fileoff":393216,
+ "filesize":98304,
+ "maxprot":3},
+{"name":"__DATA",
+ "vmaddr":491520,
+ "vmsize":16384,
+ "fileoff":491520,
+ "filesize":16384,
+ "maxprot":3},
+{"name":"__LINKEDIT",
+ "vmaddr":507904,
+ "vmsize":229376,
+ "fileoff":507904,
+ "filesize":227520,
+ "maxprot":1}
+]
+},
+{"load_address":4369842176,
+ "mod_date":0,
+ "pathname":"/tmp/a.out",
+ "uuid":"536A0A09-792A-377C-BEBA-FFB00A787C38",
+ "min_version_os_name":"macosx",
+ "min_version_os_sdk":"12.0",
+ "mach_header":{
+ "magic":4277009103,
+ "cputype":16777228,
+ "cpusubtype":%s,
+ "filetype":2,
+ "flags":2097285
+ },
+ "segments":[
+ {"name":"__PAGEZERO",
+  "vmaddr":0,
+  "vmsize":4294967296,
+  "fileoff":0,
+  "filesize":0,
+  "maxprot":0},
+ {"name":"__TEXT",
+  "vmaddr":4294967296,
+  "vmsize":16384,
+  "fileoff":0,
+  "filesize":16384,
+  "maxprot":5},
+ {"name":"__DATA_CONST",
+  "vmaddr":4294983680,
+  "vmsize":16384,
+  "fileoff":16384,
+  "filesize":16384,
+  "maxprot":3},
+ {"name":"__LINKEDIT",
+  "vmaddr":429564,
+  "vmsize":32768,
+  "fileoff":32768,
+  "filesize":19488,
+  "maxprot":1}]
+}
+]
+}
+"""
+
+arm64_binary = "cffaedfe0c0102001000e80285002000190048005f5f504147455a45524f01001900e8005f5f54455854014000400500050002005f5f746578745f5f54455854b03f01000800b03f020400805f5f756e77696e645f696e666f005f5f54455854b83f01004800b83f0200190048005f5f4c494e4b45444954004001400040b801010001003480104038003380100038403200180070400100804018000b00510001000e002c002f7573722f6c69622f64796c64001b001800a9981092eb3632f4afd9957e769160d9320021000c050c000100030633032a00100028801800b03f0c0038001800020001781f0501002f7573722f6c69622f6c696253797374656d2e422e64796c696226001000684008002900100070401d001000a0401801" + '0'*16384
+
+class TestDynamicLoaderDarwin(GDBRemoteTestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+class MyResponder(MockGDBSer

[Lldb-commits] [lldb] ff7b876 - [LLDB][RISCV] Add more instruction decode and execute for EmulateInstructionRISCV

2022-09-01 Thread via lldb-commits

Author: Emmmer
Date: 2022-09-02T10:17:09+08:00
New Revision: ff7b876aa75d1d4df581ada78befb707dfdbb129

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

LOG: [LLDB][RISCV] Add more instruction decode and execute for 
EmulateInstructionRISCV

Add:
- most of instructions from RVI base instructions set.
- some instruction decode tests from objdump.

Further work:
- implement riscv imac extension.

Reviewed By: DavidSpickett

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

Added: 


Modified: 
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp 
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
index 10aefc6d9dc08..4ca017dd98bbe 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -32,12 +32,6 @@ LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionRISCV, 
InstructionRISCV)
 
 namespace lldb_private {
 
-// Masks for detecting instructions types. According to riscv-spec Chap 26.
-constexpr uint32_t I_MASK = 0b1110111;
-constexpr uint32_t J_MASK = 0b111;
-// no funct3 in the b-mask because the logic executing B is quite similar.
-constexpr uint32_t B_MASK = 0b111;
-
 // The funct3 is the type of compare in B instructions.
 // funct3 means "3-bits function selector", which RISC-V ISA uses as minor
 // opcode. It reuses the major opcode encoding space.
@@ -48,13 +42,26 @@ constexpr uint32_t BGE = 0b101;
 constexpr uint32_t BLTU = 0b110;
 constexpr uint32_t BGEU = 0b111;
 
-constexpr uint32_t DecodeRD(uint32_t inst) { return (inst & 0xF80) >> 7; }
-constexpr uint32_t DecodeRS1(uint32_t inst) { return (inst & 0xF8000) >> 15; }
-constexpr uint32_t DecodeRS2(uint32_t inst) { return (inst & 0x1F0) >> 20; 
}
+constexpr uint32_t DecodeSHAMT5(uint32_t inst) { return DecodeRS2(inst); }
+constexpr uint32_t DecodeSHAMT7(uint32_t inst) {
+  return (inst & 0x7F0) >> 20;
+}
 constexpr uint32_t DecodeFunct3(uint32_t inst) { return (inst & 0x7000) >> 12; 
}
 
+// used in decoder
 constexpr int32_t SignExt(uint32_t imm) { return int32_t(imm); }
 
+// used in executor
+template 
+constexpr std::enable_if_t SextW(T value) {
+  return uint64_t(int64_t(int32_t(value)));
+}
+
+// used in executor
+template  constexpr uint64_t ZextD(T value) {
+  return uint64_t(value);
+}
+
 constexpr uint32_t DecodeJImm(uint32_t inst) {
   return (uint64_t(int64_t(int32_t(inst & 0x8000)) >> 11)) // imm[20]
  | (inst & 0xff000)// imm[19:12]
@@ -73,6 +80,15 @@ constexpr uint32_t DecodeBImm(uint32_t inst) {
  | ((inst >> 7) & 0x1e);   // imm[4:1]
 }
 
+constexpr uint32_t DecodeSImm(uint32_t inst) {
+  return (uint64_t(int64_t(int32_t(inst & 0xFE0)) >> 20)) // imm[11:5]
+ | ((inst & 0xF80) >> 7); // imm[4:0]
+}
+
+constexpr uint32_t DecodeUImm(uint32_t inst) {
+  return SextW(inst & 0xF000); // imm[31:12]
+}
+
 static uint32_t GPREncodingToLLDB(uint32_t reg_encode) {
   if (reg_encode == 0)
 return gpr_x0_riscv;
@@ -81,43 +97,43 @@ static uint32_t GPREncodingToLLDB(uint32_t reg_encode) {
   return LLDB_INVALID_REGNUM;
 }
 
-static bool ReadRegister(EmulateInstructionRISCV *emulator, uint32_t 
reg_encode,
+static bool ReadRegister(EmulateInstructionRISCV &emulator, uint32_t 
reg_encode,
  RegisterValue &value) {
   uint32_t lldb_reg = GPREncodingToLLDB(reg_encode);
-  return emulator->ReadRegister(eRegisterKindLLDB, lldb_reg, value);
+  return emulator.ReadRegister(eRegisterKindLLDB, lldb_reg, value);
 }
 
-static bool WriteRegister(EmulateInstructionRISCV *emulator,
+static bool WriteRegister(EmulateInstructionRISCV &emulator,
   uint32_t reg_encode, const RegisterValue &value) {
   uint32_t lldb_reg = GPREncodingToLLDB(reg_encode);
   EmulateInstruction::Context ctx;
   ctx.type = EmulateInstruction::eContextRegisterStore;
   ctx.SetNoArgs();
-  return emulator->WriteRegister(ctx, eRegisterKindLLDB, lldb_reg, value);
+  return emulator.WriteRegister(ctx, eRegisterKindLLDB, lldb_reg, value);
 }
 
-static bool ExecJAL(EmulateInstructionRISCV *emulator, uint32_t inst, bool) {
+static bool ExecJAL(EmulateInstructionRISCV &emulator, uint32_t inst, bool) {
   bool success = false;
   int64_t offset = SignExt(DecodeJImm(inst));
-  int64_t pc = emulator->ReadPC(&success);
-  return success && emulator->WritePC(pc + offset) &&
+  int64_t pc = emulator.ReadPC(&success);
+  r

[Lldb-commits] [PATCH] D132789: [LLDB][RISCV] Add more instruction decode and execute for EmulateInstructionRISCV

2022-09-01 Thread Emmmer S via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGff7b876aa75d: [LLDB][RISCV] Add more instruction decode and 
execute for… (authored by Emmmer).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132789

Files:
  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
  lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp

Index: lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
===
--- lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
+++ lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
@@ -157,6 +157,37 @@
 testBranch(this, name, false, rs1, rs2_continued); \
   }
 
+void CheckRD(RISCVEmulatorTester *tester, uint64_t rd, uint64_t value) {
+  ASSERT_EQ(tester->gpr.gpr[rd], value);
+}
+
+using RS1 = uint64_t;
+using RS2 = uint64_t;
+using PC = uint64_t;
+using RDComputer = std::function;
+
+void TestInst(RISCVEmulatorTester *tester, uint64_t inst, bool has_rs2,
+  RDComputer rd_val) {
+
+  lldb::addr_t old_pc = 0x114514;
+  tester->WritePC(old_pc);
+  auto rd = DecodeRD(inst);
+  auto rs1 = DecodeRS1(inst);
+  auto rs2 = 0;
+  if (rs1)
+tester->gpr.gpr[rs1] = 0x1919;
+
+  if (has_rs2) {
+rs2 = DecodeRS2(inst);
+if (rs2)
+  tester->gpr.gpr[rs2] = 0x8181;
+  }
+
+  ASSERT_TRUE(tester->DecodeAndExecute(inst, false));
+  CheckRD(tester, rd,
+  rd_val(tester->gpr.gpr[rs1], rs2 ? tester->gpr.gpr[rs2] : 0, old_pc));
+}
+
 // GEN_BRANCH_TEST(opcode, imm1, imm2, imm3):
 // It should branch for instruction `opcode imm1, imm2`
 // It should do nothing for instruction `opcode imm1, imm3`
@@ -167,30 +198,34 @@
 GEN_BRANCH_TEST(BLTU, -2, -1, 1)
 GEN_BRANCH_TEST(BGEU, -2, 1, -1)
 
-void testNothing(RISCVEmulatorTester *tester, uint32_t inst) {
-  lldb::addr_t old_pc = 0x114514;
-  tester->WritePC(old_pc);
-  tester->SetInstruction(Opcode(inst, tester->GetByteOrder()),
- LLDB_INVALID_ADDRESS, nullptr);
-  ASSERT_TRUE(tester->EvaluateInstruction(0));
-  bool success = false;
-  auto pc = tester->ReadPC(&success);
-  ASSERT_TRUE(success);
-  ASSERT_EQ(pc, old_pc);
-  ASSERT_TRUE(
-  tester->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC));
-  pc = tester->ReadPC(&success);
-  ASSERT_TRUE(success);
-  ASSERT_EQ(pc, old_pc + 4);
-}
-
-#define GEN_NOTHING_TEST(name, inst)   \
-  TEST_F(RISCVEmulatorTester, testDoNothing_##name) { testNothing(this, inst); }
+struct TestData {
+  uint32_t inst;
+  std::string name;
+  bool has_rs2;
+  RDComputer rd_val;
+};
 
-// GEN_NOTHING_TEST(name, inst):
-// It should do nothing (except increasing pc) for instruction `inst`
-GEN_NOTHING_TEST(mv, 0x01813083)   // mv a0, a5
-GEN_NOTHING_TEST(li, 0x00078513)   // li a5, 0
-GEN_NOTHING_TEST(sd, 0x02010413)   // sd s0, sp(16)
-GEN_NOTHING_TEST(lw, 0x0007879b)   // lw a5, s0(-20)
-GEN_NOTHING_TEST(addi, 0x00113423) // addi sp, sp, -16
+TEST_F(RISCVEmulatorTester, TestDecodeAndExcute) {
+
+  std::vector tests = {
+  {0x00010113, "ADDI", false, [](RS1 rs1, RS2, PC) { return rs1 + 0; }},
+  {0x00023517, "AUIPC", false, [](RS1, RS2, PC pc) { return pc + 143360; }},
+  {0x0006079b, "ADDIW", false, [](RS1 rs1, RS2, PC) { return rs1 + 0; }},
+  {0x00110837, "LUI", false, [](RS1, RS2, PC pc) { return 1114112; }},
+  {0x00147513, "ANDI", false, [](RS1 rs1, RS2, PC) { return rs1 & 1; }},
+  {0x00153513, "SLTIU", false, [](RS1 rs1, RS2, PC) { return rs1 != 0; }},
+  {0x00256513, "ORI", false, [](RS1 rs1, RS2, PC) { return rs1 | 1; }},
+  {0x00451a13, "SLLI", false, [](RS1 rs1, RS2, PC) { return rs1 << 4; }},
+  {0x00455693, "SRLI", false, [](RS1 rs1, RS2, PC) { return rs1 >> 4; }},
+  {0x00a035b3, "SLTU", true, [](RS1 rs1, RS2 rs2, PC) { return rs2 != 0; }},
+  {0x00b50633, "ADD", true, [](RS1 rs1, RS2 rs2, PC) { return rs1 + rs2; }},
+  {0x40d507b3, "SUB", true, [](RS1 rs1, RS2 rs2, PC) { return rs1 - rs2; }},
+  };
+  for (auto i : tests) {
+const InstrPattern *pattern = this->Decode(i.inst);
+ASSERT_TRUE(pattern != nullptr);
+std::string name = pattern->name;
+ASSERT_EQ(name, i.name);
+TestInst(this, i.inst, i.has_rs2, i.rd_val);
+  }
+}
Index: lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
===
--- lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
+++ lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
@@ -16,6 +16,22 @@
 
 namespace lldb_private {
 
+constexpr uint32_t DecodeRD(uint32_t inst) { return (inst & 0xF80) >> 7; }
+constexpr uint32_t DecodeRS1(uint32_t inst) { return (inst & 0xF8000) >> 15; }
+constexpr uint32_t

[Lldb-commits] [PATCH] D133181: [test] Ensure MainLoop has time to start listening for signals.

2022-09-01 Thread Jordan Rupprecht via Phabricator via lldb-commits
rupprecht created this revision.
Herald added a project: All.
rupprecht requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This test, specifically `TwoSignalCallbacks`, can be a little bit flaky, 
failing in around 5/2000 runs. My suspicion is around this pattern:

  kill(getpid(), SIGUSR1);
  ASSERT_TRUE(loop.Run().Success());

First we send the signal, and _then_ we call `loop.Run()`, which resets the 
"please terminate me" bit and waits for the signal handler to flip it on again. 
AFAICT `kill` is entirely asynchronous and not much is happening here, and so 
we almost always get to the point in `loop.Run()` where we spin and wait for 
termination. But sometimes we get unlucky, the signal gets delivered before we 
start waiting for it, and this test deadlocks.

This changes the test to sleep a second before sending the signal, and the test 
passes in 1 runs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133181

Files:
  lldb/unittests/Host/MainLoopTest.cpp


Index: lldb/unittests/Host/MainLoopTest.cpp
===
--- lldb/unittests/Host/MainLoopTest.cpp
+++ lldb/unittests/Host/MainLoopTest.cpp
@@ -174,8 +174,13 @@
 
   auto handle = loop.RegisterSignal(SIGUSR1, make_callback(), error);
   ASSERT_TRUE(error.Success());
-  kill(getpid(), SIGUSR1);
+  std::thread killer([]() {
+sleep(1);
+kill(getpid(), SIGUSR1);
+  });
   ASSERT_TRUE(loop.Run().Success());
+  killer.join();
+
   ASSERT_EQ(1u, callback_count);
 }
 
@@ -220,8 +225,12 @@
 SIGUSR1, [&](MainLoopBase &loop) { ++callback2_count; }, error);
 ASSERT_TRUE(error.Success());
 
-kill(getpid(), SIGUSR1);
+std::thread killer([]() {
+  sleep(1);
+  kill(getpid(), SIGUSR1);
+});
 ASSERT_TRUE(loop.Run().Success());
+killer.join();
 ASSERT_EQ(1u, callback_count);
 ASSERT_EQ(1u, callback2_count);
 ASSERT_EQ(0u, callback3_count);
@@ -233,18 +242,28 @@
 SIGUSR1, [&](MainLoopBase &loop) { ++callback3_count; }, error);
 ASSERT_TRUE(error.Success());
 
-kill(getpid(), SIGUSR1);
+std::thread killer([]() {
+  sleep(1);
+  kill(getpid(), SIGUSR1);
+});
 ASSERT_TRUE(loop.Run().Success());
+killer.join();
 ASSERT_EQ(2u, callback_count);
 ASSERT_EQ(1u, callback2_count);
 ASSERT_EQ(1u, callback3_count);
   }
 
   // Both extra callbacks should be unregistered now.
-  kill(getpid(), SIGUSR1);
-  ASSERT_TRUE(loop.Run().Success());
-  ASSERT_EQ(3u, callback_count);
-  ASSERT_EQ(1u, callback2_count);
-  ASSERT_EQ(1u, callback3_count);
+  {
+std::thread killer([]() {
+  sleep(1);
+  kill(getpid(), SIGUSR1);
+});
+ASSERT_TRUE(loop.Run().Success());
+killer.join();
+ASSERT_EQ(3u, callback_count);
+ASSERT_EQ(1u, callback2_count);
+ASSERT_EQ(1u, callback3_count);
+  }
 }
 #endif


Index: lldb/unittests/Host/MainLoopTest.cpp
===
--- lldb/unittests/Host/MainLoopTest.cpp
+++ lldb/unittests/Host/MainLoopTest.cpp
@@ -174,8 +174,13 @@
 
   auto handle = loop.RegisterSignal(SIGUSR1, make_callback(), error);
   ASSERT_TRUE(error.Success());
-  kill(getpid(), SIGUSR1);
+  std::thread killer([]() {
+sleep(1);
+kill(getpid(), SIGUSR1);
+  });
   ASSERT_TRUE(loop.Run().Success());
+  killer.join();
+
   ASSERT_EQ(1u, callback_count);
 }
 
@@ -220,8 +225,12 @@
 SIGUSR1, [&](MainLoopBase &loop) { ++callback2_count; }, error);
 ASSERT_TRUE(error.Success());
 
-kill(getpid(), SIGUSR1);
+std::thread killer([]() {
+  sleep(1);
+  kill(getpid(), SIGUSR1);
+});
 ASSERT_TRUE(loop.Run().Success());
+killer.join();
 ASSERT_EQ(1u, callback_count);
 ASSERT_EQ(1u, callback2_count);
 ASSERT_EQ(0u, callback3_count);
@@ -233,18 +242,28 @@
 SIGUSR1, [&](MainLoopBase &loop) { ++callback3_count; }, error);
 ASSERT_TRUE(error.Success());
 
-kill(getpid(), SIGUSR1);
+std::thread killer([]() {
+  sleep(1);
+  kill(getpid(), SIGUSR1);
+});
 ASSERT_TRUE(loop.Run().Success());
+killer.join();
 ASSERT_EQ(2u, callback_count);
 ASSERT_EQ(1u, callback2_count);
 ASSERT_EQ(1u, callback3_count);
   }
 
   // Both extra callbacks should be unregistered now.
-  kill(getpid(), SIGUSR1);
-  ASSERT_TRUE(loop.Run().Success());
-  ASSERT_EQ(3u, callback_count);
-  ASSERT_EQ(1u, callback2_count);
-  ASSERT_EQ(1u, callback3_count);
+  {
+std::thread killer([]() {
+  sleep(1);
+  kill(getpid(), SIGUSR1);
+});
+ASSERT_TRUE(loop.Run().Success());
+killer.join();
+ASSERT_EQ(3u, callback_count);
+ASSERT_EQ(1u, callback2_count);
+ASSERT_EQ(1u, callback3_count);
+  }
 }
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 4535dbd - [lldb] Fix a warning

2022-09-01 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-09-01T22:14:25-07:00
New Revision: 4535dbd55962989e16f0f7208fae9ce75ed9863c

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

LOG: [lldb] Fix a warning

This patch fixes:

  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h:51:5:
  error: default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

Added: 


Modified: 
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h

Removed: 




diff  --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h 
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
index 2ed049ffac990..07dfcf692fca8 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
@@ -48,8 +48,6 @@ class EmulateInstructionRISCV : public EmulateInstruction {
 case eInstructionTypePrologueEpilogue:
 case eInstructionTypeAll:
   return false;
-default:
-  llvm_unreachable("Unhandled instruction type");
 }
 llvm_unreachable("Fully covered switch above!");
   }



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