[Lldb-commits] [lldb] r241688 - Revert r241672, which breaks the OS X build by introducing a dependency on

Sean Callanan scallanan at apple.com
Wed Jul 8 09:33:46 PDT 2015


Author: spyffe
Date: Wed Jul  8 11:33:46 2015
New Revision: 241688

URL: http://llvm.org/viewvc/llvm-project?rev=241688&view=rev
Log:
Revert r241672, which breaks the OS X build by introducing a dependency on
platform-specific symbols that are not implemented on OS X.

The build error that caused this is

Undefined symbols for architecture x86_64:
  "lldb_private::NativeProcessProtocol::Attach(unsigned long long, lldb_private::NativeProcessProtocol::NativeDelegate&, std::__1::shared_ptr<lldb_private::NativeProcessProtocol>&)", referenced from:
      lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::AttachToProcess(unsigned long long) in liblldb-core.a(GDBRemoteCommunicationServerLLGS.o)
  "lldb_private::NativeProcessProtocol::Launch(lldb_private::ProcessLaunchInfo&, lldb_private::NativeProcessProtocol::NativeDelegate&, std::__1::shared_ptr<lldb_private::NativeProcessProtocol>&)", referenced from:
      lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::LaunchProcess() in liblldb-core.a(GDBRemoteCommunicationServerLLGS.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Modified:
    lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
    lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h
    lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
    lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h
    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
    lldb/trunk/source/Target/Platform.cpp

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Wed Jul  8 11:33:46 2015
@@ -35,6 +35,8 @@ namespace lldb_private
         friend class SoftwareBreakpoint;
 
     public:
+        static NativeProcessProtocol *
+        CreateInstance (lldb::pid_t pid);
 
         // lldb_private::Host calls should be used to launch a process for debugging, and
         // then the process should be attached to. When attaching to a process
@@ -42,6 +44,7 @@ namespace lldb_private
         // and then this function should be called.
         NativeProcessProtocol (lldb::pid_t pid);
 
+    public:
         virtual ~NativeProcessProtocol ()
         {
         }
@@ -294,62 +297,6 @@ namespace lldb_private
         virtual Error
         GetFileLoadAddress(const llvm::StringRef& file_name, lldb::addr_t& load_addr) = 0;
 
-        //------------------------------------------------------------------
-        /// Launch a process for debugging. This method will create an concrete
-        /// instance of NativeProcessProtocol, based on the host platform.
-        /// (e.g. NativeProcessLinux on linux, etc.)
-        ///
-        /// @param[in] launch_info
-        ///     Information required to launch the process.
-        ///
-        /// @param[in] native_delegate
-        ///     The delegate that will receive messages regarding the
-        ///     inferior.  Must outlive the NativeProcessProtocol
-        ///     instance.
-        ///
-        /// @param[out] process_sp
-        ///     On successful return from the method, this parameter
-        ///     contains the shared pointer to the
-        ///     NativeProcessProtocol that can be used to manipulate
-        ///     the native process.
-        ///
-        /// @return
-        ///     An error object indicating if the operation succeeded,
-        ///     and if not, what error occurred.
-        //------------------------------------------------------------------
-        static Error
-        Launch (ProcessLaunchInfo &launch_info,
-                NativeDelegate &native_delegate,
-                NativeProcessProtocolSP &process_sp);
-
-        //------------------------------------------------------------------
-        /// Attach to an existing process. This method will create an concrete
-        /// instance of NativeProcessProtocol, based on the host platform.
-        /// (e.g. NativeProcessLinux on linux, etc.)
-        ///
-        /// @param[in] pid
-        ///     pid of the process locatable
-        ///
-        /// @param[in] native_delegate
-        ///     The delegate that will receive messages regarding the
-        ///     inferior.  Must outlive the NativeProcessProtocol
-        ///     instance.
-        ///
-        /// @param[out] process_sp
-        ///     On successful return from the method, this parameter
-        ///     contains the shared pointer to the
-        ///     NativeProcessProtocol that can be used to manipulate
-        ///     the native process.
-        ///
-        /// @return
-        ///     An error object indicating if the operation succeeded,
-        ///     and if not, what error occurred.
-        //------------------------------------------------------------------
-        static Error
-        Attach (lldb::pid_t pid,
-                NativeDelegate &native_delegate,
-                NativeProcessProtocolSP &process_sp);
-
     protected:
         lldb::pid_t m_pid;
 

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Wed Jul  8 11:33:46 2015
@@ -939,6 +939,65 @@ class ModuleCache;
         virtual const std::vector<ConstString> &
         GetTrapHandlerSymbolNames ();
 
+        //------------------------------------------------------------------
+        /// Launch a process for debugging.
+        ///
+        /// This differs from Launch in that it returns a NativeProcessProtocol.
+        /// Currently used by lldb-gdbserver.
+        ///
+        /// @param[in] launch_info
+        ///     Information required to launch the process.
+        ///
+        /// @param[in] native_delegate
+        ///     The delegate that will receive messages regarding the
+        ///     inferior.  Must outlive the NativeProcessProtocol
+        ///     instance.
+        ///
+        /// @param[out] process_sp
+        ///     On successful return from the method, this parameter
+        ///     contains the shared pointer to the
+        ///     NativeProcessProtocol that can be used to manipulate
+        ///     the native process.
+        ///
+        /// @return
+        ///     An error object indicating if the operation succeeded,
+        ///     and if not, what error occurred.
+        //------------------------------------------------------------------
+        virtual Error
+        LaunchNativeProcess (
+            ProcessLaunchInfo &launch_info,
+            lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
+            NativeProcessProtocolSP &process_sp);
+
+        //------------------------------------------------------------------
+        /// Attach to an existing process on the given platform.
+        ///
+        /// This method differs from Attach() in that it returns a
+        /// NativeProcessProtocol.  Currently this is used by lldb-gdbserver.
+        ///
+        /// @param[in] pid
+        ///     pid of the process locatable by the platform.
+        ///
+        /// @param[in] native_delegate
+        ///     The delegate that will receive messages regarding the
+        ///     inferior.  Must outlive the NativeProcessProtocol
+        ///     instance.
+        ///
+        /// @param[out] process_sp
+        ///     On successful return from the method, this parameter
+        ///     contains the shared pointer to the
+        ///     NativeProcessProtocol that can be used to manipulate
+        ///     the native process.
+        ///
+        /// @return
+        ///     An error object indicating if the operation succeeded,
+        ///     and if not, what error occurred.
+        //------------------------------------------------------------------
+        virtual Error
+        AttachNativeProcess (lldb::pid_t pid,
+                             lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
+                             NativeProcessProtocolSP &process_sp);
+
     protected:
         bool m_is_host;
         // Set to true when we are able to actually set the OS version while 

Modified: lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp Wed Jul  8 11:33:46 2015
@@ -322,3 +322,21 @@ PlatformKalimba::CalculateTrapHandlerSym
 {   
     // TODO Research this sometime.
 }   
+
+Error
+PlatformKalimba::LaunchNativeProcess (
+    ProcessLaunchInfo &,
+    lldb_private::NativeProcessProtocol::NativeDelegate &,
+    NativeProcessProtocolSP &)
+{
+    return Error();
+}
+
+Error
+PlatformKalimba::AttachNativeProcess (lldb::pid_t,
+                                    lldb_private::NativeProcessProtocol::NativeDelegate &,
+                                    NativeProcessProtocolSP &)
+{
+    return Error();
+}
+

Modified: lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h (original)
+++ lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.h Wed Jul  8 11:33:46 2015
@@ -89,6 +89,17 @@ namespace lldb_private {
 
         void CalculateTrapHandlerSymbolNames() override;
 
+        Error
+        LaunchNativeProcess (
+            ProcessLaunchInfo &launch_info,
+            lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
+            NativeProcessProtocolSP &process_sp) override;
+
+        Error
+        AttachNativeProcess (lldb::pid_t pid,
+                             lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
+                             NativeProcessProtocolSP &process_sp) override;
+
     protected:
         lldb::PlatformSP m_remote_platform_sp;
 

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Wed Jul  8 11:33:46 2015
@@ -36,6 +36,10 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Process.h"
 
+#if defined(__linux__)
+#include "../../Process/Linux/NativeProcessLinux.h"
+#endif
+
 // Define these constants from Linux mman.h for use when targeting
 // remote linux systems even when host has different values.
 #define MAP_PRIVATE 2
@@ -838,6 +842,59 @@ PlatformLinux::CalculateTrapHandlerSymbo
     m_trap_handlers.push_back (ConstString ("_sigtramp"));
 }
 
+Error
+PlatformLinux::LaunchNativeProcess (ProcessLaunchInfo &launch_info,
+                                    NativeProcessProtocol::NativeDelegate &native_delegate,
+                                    NativeProcessProtocolSP &process_sp)
+{
+#if !defined(__linux__)
+    return Error("Only implemented on Linux hosts");
+#else
+    if (!IsHost ())
+        return Error("PlatformLinux::%s (): cannot launch a debug process when not the host", __FUNCTION__);
+
+    // Retrieve the exe module.
+    lldb::ModuleSP exe_module_sp;
+    ModuleSpec exe_module_spec(launch_info.GetExecutableFile(), launch_info.GetArchitecture());
+
+    Error error = ResolveExecutable (
+        exe_module_spec,
+        exe_module_sp,
+        NULL);
+
+    if (!error.Success ())
+        return error;
+
+    if (!exe_module_sp)
+        return Error("exe_module_sp could not be resolved for %s", launch_info.GetExecutableFile ().GetPath ().c_str ());
+
+    // Launch it for debugging
+    error = process_linux::NativeProcessLinux::LaunchProcess (
+        exe_module_sp.get (),
+        launch_info,
+        native_delegate,
+        process_sp);
+
+    return error;
+#endif
+}
+
+Error
+PlatformLinux::AttachNativeProcess (lldb::pid_t pid,
+                                    NativeProcessProtocol::NativeDelegate &native_delegate,
+                                    NativeProcessProtocolSP &process_sp)
+{
+#if !defined(__linux__)
+    return Error("Only implemented on Linux hosts");
+#else
+    if (!IsHost ())
+        return Error("PlatformLinux::%s (): cannot attach to a debug process when not the host", __FUNCTION__);
+
+    // Launch it for debugging
+    return process_linux::NativeProcessLinux::AttachToProcess (pid, native_delegate, process_sp);
+#endif
+}
+
 uint64_t
 PlatformLinux::ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags)
 {

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Wed Jul  8 11:33:46 2015
@@ -108,6 +108,17 @@ namespace platform_linux {
         void
         CalculateTrapHandlerSymbolNames () override;
 
+        Error
+        LaunchNativeProcess (
+            ProcessLaunchInfo &launch_info,
+            NativeProcessProtocol::NativeDelegate &native_delegate,
+            NativeProcessProtocolSP &process_sp) override;
+
+        Error
+        AttachNativeProcess (lldb::pid_t pid,
+                             NativeProcessProtocol::NativeDelegate &native_delegate,
+                             NativeProcessProtocolSP &process_sp) override;
+
         uint64_t
         ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags) override;
 

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Wed Jul  8 11:33:46 2015
@@ -824,22 +824,15 @@ NativeProcessLinux::LaunchArgs::~LaunchA
 // -----------------------------------------------------------------------------
 
 Error
-NativeProcessProtocol::Launch (
+NativeProcessLinux::LaunchProcess (
+    Module *exe_module,
     ProcessLaunchInfo &launch_info,
     NativeProcessProtocol::NativeDelegate &native_delegate,
     NativeProcessProtocolSP &native_process_sp)
 {
     Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
 
-    lldb::ModuleSP exe_module_sp;
-    PlatformSP platform_sp (Platform::GetHostPlatform ());
-    Error error = platform_sp->ResolveExecutable(
-            ModuleSpec(launch_info.GetExecutableFile(), launch_info.GetArchitecture()),
-            exe_module_sp,
-            nullptr);
-
-    if (! error.Success())
-        return error;
+    Error error;
 
     // Verify the working directory is valid if one was specified.
     FileSpec working_dir{launch_info.GetWorkingDirectory()};
@@ -913,7 +906,7 @@ NativeProcessProtocol::Launch (
     }
 
     std::static_pointer_cast<NativeProcessLinux> (native_process_sp)->LaunchInferior (
-            exe_module_sp.get(),
+            exe_module,
             launch_info.GetArguments ().GetConstArgumentVector (),
             launch_info.GetEnvironmentEntries ().GetConstArgumentVector (),
             stdin_file_spec,
@@ -937,7 +930,7 @@ NativeProcessProtocol::Launch (
 }
 
 Error
-NativeProcessProtocol::Attach (
+NativeProcessLinux::AttachToProcess (
     lldb::pid_t pid,
     NativeProcessProtocol::NativeDelegate &native_delegate,
     NativeProcessProtocolSP &native_process_sp)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h Wed Jul  8 11:33:46 2015
@@ -40,17 +40,21 @@ namespace process_linux {
     /// Changes in the inferior process state are broadcasted.
     class NativeProcessLinux: public NativeProcessProtocol
     {
-        friend Error
-        NativeProcessProtocol::Launch (ProcessLaunchInfo &launch_info,
-                NativeDelegate &native_delegate,
-                NativeProcessProtocolSP &process_sp);
+    public:
 
-        friend Error
-        NativeProcessProtocol::Attach (lldb::pid_t pid,
+        static Error
+        LaunchProcess (
+            Module *exe_module,
+            ProcessLaunchInfo &launch_info,
+            NativeProcessProtocol::NativeDelegate &native_delegate,
+            NativeProcessProtocolSP &native_process_sp);
+
+        static Error
+        AttachToProcess (
+            lldb::pid_t pid,
             NativeProcessProtocol::NativeDelegate &native_delegate,
             NativeProcessProtocolSP &native_process_sp);
 
-    public:
         //------------------------------------------------------------------------------
         /// @class Operation
         /// @brief Represents a NativeProcessLinux operation.

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp Wed Jul  8 11:33:46 2015
@@ -218,7 +218,7 @@ GDBRemoteCommunicationServerLLGS::Launch
     {
         Mutex::Locker locker (m_debugged_process_mutex);
         assert (!m_debugged_process_sp && "lldb-gdbserver creating debugged process but one already exists");
-        error = NativeProcessProtocol::Launch(
+        error = m_platform_sp->LaunchNativeProcess (
             m_process_launch_info,
             *this,
             m_debugged_process_sp);
@@ -306,7 +306,7 @@ GDBRemoteCommunicationServerLLGS::Attach
         }
 
         // Try to attach.
-        error = NativeProcessProtocol::Attach(pid, *this, m_debugged_process_sp);
+        error = m_platform_sp->AttachNativeProcess (pid, *this, m_debugged_process_sp);
         if (!error.Success ())
         {
             fprintf (stderr, "%s: failed to attach to process %" PRIu64 ": %s", __FUNCTION__, pid, error.AsCString ());

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=241688&r1=241687&r2=241688&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Wed Jul  8 11:33:46 2015
@@ -1536,6 +1536,27 @@ Platform::CalculateMD5 (const FileSpec&
         return false;
 }
 
+Error
+Platform::LaunchNativeProcess (
+    ProcessLaunchInfo &launch_info,
+    lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
+    NativeProcessProtocolSP &process_sp)
+{
+    // Platforms should override this implementation if they want to
+    // support lldb-gdbserver.
+    return Error("unimplemented");
+}
+
+Error
+Platform::AttachNativeProcess (lldb::pid_t pid,
+                               lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
+                               NativeProcessProtocolSP &process_sp)
+{
+    // Platforms should override this implementation if they want to
+    // support lldb-gdbserver.
+    return Error("unimplemented");
+}
+
 void
 Platform::SetLocalCacheDirectory (const char* local)
 {





More information about the lldb-commits mailing list