Index: lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h =================================================================== --- lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -42,6 +42,8 @@ bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override; + static bool UseLegacyPlugin(); + bool CanDebugProcess() override; size_t GetSoftwareBreakpointTrapOpcode(Target &target, Index: lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp =================================================================== --- lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -247,26 +247,24 @@ } } -bool PlatformFreeBSD::CanDebugProcess() { - if (IsHost()) { - llvm::Triple host_triple{llvm::sys::getProcessTriple()}; - bool use_legacy_plugin; - - switch (host_triple.getArch()) { - case llvm::Triple::x86: - case llvm::Triple::x86_64: - // FreeBSDRemote plugin supports x86 only at the moment - use_legacy_plugin = !!getenv("FREEBSD_LEGACY_PLUGIN"); - break; - default: - use_legacy_plugin = true; - } +bool PlatformFreeBSD::UseLegacyPlugin() { + llvm::Triple host_triple{llvm::sys::getProcessTriple()}; + + switch (host_triple.getArch()) { + case llvm::Triple::x86: + case llvm::Triple::x86_64: + // FreeBSDRemote plugin supports x86 only at the moment + return !!getenv("FREEBSD_LEGACY_PLUGIN"); + default: + return true; + } +} - return !use_legacy_plugin; - } else { - // If we're connected, we can debug. +bool PlatformFreeBSD::CanDebugProcess() { + if (IsHost()) // Use DebugProcess() method when using the new plugin + return !UseLegacyPlugin(); + else // If we're connected, we can debug. return IsConnected(); - } } void PlatformFreeBSD::CalculateTrapHandlerSymbolNames() { Index: lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp =================================================================== --- lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -28,6 +28,7 @@ #include "lldb/Utility/State.h" #include "FreeBSDThread.h" +#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" #include "Plugins/Process/Utility/FreeBSDSignals.h" #include "Plugins/Process/Utility/InferiorCallPOSIX.h" @@ -273,6 +274,9 @@ bool ProcessFreeBSD::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) { + if (!platform_freebsd::PlatformFreeBSD::UseLegacyPlugin()) + return false; + // For now we are just making sure the file exists for a given module ModuleSP exe_module_sp(target_sp->GetExecutableModule()); if (exe_module_sp.get()) Index: lldb/test/API/commands/process/attach-resume/TestAttachResume.py =================================================================== --- lldb/test/API/commands/process/attach-resume/TestAttachResume.py +++ lldb/test/API/commands/process/attach-resume/TestAttachResume.py @@ -18,7 +18,6 @@ NO_DEBUG_INFO_TESTCASE = True @skipIfRemote - @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19310') @expectedFailureNetBSD @skipIfWindows # llvm.org/pr24778, llvm.org/pr21753 @skipIfReproducer # FIXME: Unexpected packet during (active) replay Index: lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py =================================================================== --- lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py +++ lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py @@ -16,7 +16,7 @@ NO_DEBUG_INFO_TESTCASE = True @skipIfWindows # cannot delete a running executable - @expectedFailureAll(oslist=["freebsd", "linux"], + @expectedFailureAll(oslist=["linux"], triple=no_match('aarch64-.*-android')) # determining the architecture of the process fails @skipIfReproducer # File synchronization is not supported during replay. Index: lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py =================================================================== --- lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py +++ lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py @@ -36,7 +36,6 @@ self.dbg.GetSelectedPlatform().DisconnectRemote() @skipIfWindows - @expectedFailureAll(oslist=["freebsd"]) def test_process_connect_sync(self): """Test the gdb-remote command in synchronous mode""" try: @@ -48,7 +47,6 @@ self.dbg.GetSelectedPlatform().DisconnectRemote() @skipIfWindows - @expectedFailureAll(oslist=["freebsd"]) @skipIfReproducer # Reproducer don't support async. def test_process_connect_async(self): """Test the gdb-remote command in asynchronous mode""" Index: lldb/test/Shell/Commands/command-process-connect.test =================================================================== --- lldb/test/Shell/Commands/command-process-connect.test +++ lldb/test/Shell/Commands/command-process-connect.test @@ -1,5 +1,4 @@ # UNSUPPORTED: system-windows -# XFAIL: system-freebsd # Synchronous # RUN: %lldb -o 'platform select remote-gdb-server' -o 'process connect connect://localhost:4321' 2>&1 | FileCheck %s