[Lldb-commits] [lldb] r214603 - After you attach, give the process plugin a chance to report back (through

Jim Ingham jingham at apple.com
Fri Aug 1 17:33:35 PDT 2014


Author: jingham
Date: Fri Aug  1 19:33:35 2014
New Revision: 214603

URL: http://llvm.org/viewvc/llvm-project?rev=214603&view=rev
Log:
After you attach, give the process plugin a chance to report back (through
DidAttach) the architecture of the binary you attached to.

<rdar://problem/17891396>

Modified:
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=214603&r1=214602&r2=214603&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Fri Aug  1 19:33:35 2014
@@ -1446,11 +1446,17 @@ public:
     //------------------------------------------------------------------
     /// Called after attaching a process.
     ///
+    /// @param[in] process_arch
+    ///     If you can figure out the process architecture after attach, fill it in here.
+    ///
     /// Allow Process plug-ins to execute some code after attaching to
     /// a process.
     //------------------------------------------------------------------
     virtual void
-    DidAttach () {}
+    DidAttach (ArchSpec &process_arch)
+    {
+        process_arch.Clear();
+    }
 
 
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=214603&r1=214602&r2=214603&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Fri Aug  1 19:33:35 2014
@@ -428,8 +428,10 @@ ProcessKDP::DoAttachToProcessWithName (c
 
 
 void
-ProcessKDP::DidAttach ()
+ProcessKDP::DidAttach (ArchSpec &process_arch)
 {
+    Process::DidAttach(process_arch);
+    
     Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS));
     if (log)
         log->Printf ("ProcessKDP::DidAttach()");

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h?rev=214603&r1=214602&r2=214603&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h Fri Aug  1 19:33:35 2014
@@ -105,7 +105,7 @@ public:
     DoAttachToProcessWithName (const char *process_name, const lldb_private::ProcessAttachInfo &attach_info);
     
     virtual void
-    DidAttach ();
+    DidAttach (lldb_private::ArchSpec &process_arch);
     
     lldb::addr_t
     GetImageInfoAddress();

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=214603&r1=214602&r2=214603&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Aug  1 19:33:35 2014
@@ -1011,7 +1011,7 @@ ProcessGDBRemote::ConnectToDebugserver (
 }
 
 void
-ProcessGDBRemote::DidLaunchOrAttach ()
+ProcessGDBRemote::DidLaunchOrAttach (ArchSpec& process_arch)
 {
     Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
     if (log)
@@ -1022,16 +1022,17 @@ ProcessGDBRemote::DidLaunchOrAttach ()
 
         // See if the GDB server supports the qHostInfo information
 
-        ArchSpec gdb_remote_arch = m_gdb_comm.GetHostArchitecture();
 
         // See if the GDB server supports the qProcessInfo packet, if so
         // prefer that over the Host information as it will be more specific
         // to our process.
 
         if (m_gdb_comm.GetProcessArchitecture().IsValid())
-            gdb_remote_arch = m_gdb_comm.GetProcessArchitecture();
+            process_arch = m_gdb_comm.GetProcessArchitecture();
+        else
+            process_arch = m_gdb_comm.GetHostArchitecture();
 
-        if (gdb_remote_arch.IsValid())
+        if (process_arch.IsValid())
         {
             ArchSpec &target_arch = GetTarget().GetArchitecture();
 
@@ -1044,15 +1045,15 @@ ProcessGDBRemote::DidLaunchOrAttach ()
                 // it has, so we really need to take the remote host architecture as our
                 // defacto architecture in this case.
 
-                if (gdb_remote_arch.GetMachine() == llvm::Triple::arm &&
-                    gdb_remote_arch.GetTriple().getVendor() == llvm::Triple::Apple)
+                if (process_arch.GetMachine() == llvm::Triple::arm &&
+                    process_arch.GetTriple().getVendor() == llvm::Triple::Apple)
                 {
-                    target_arch = gdb_remote_arch;
+                    target_arch = process_arch;
                 }
                 else
                 {
                     // Fill in what is missing in the triple
-                    const llvm::Triple &remote_triple = gdb_remote_arch.GetTriple();
+                    const llvm::Triple &remote_triple = process_arch.GetTriple();
                     llvm::Triple &target_triple = target_arch.GetTriple();
                     if (target_triple.getVendorName().size() == 0)
                     {
@@ -1072,7 +1073,7 @@ ProcessGDBRemote::DidLaunchOrAttach ()
             {
                 // The target doesn't have a valid architecture yet, set it from
                 // the architecture we got from the remote GDB server
-                target_arch = gdb_remote_arch;
+                target_arch = process_arch;
             }
         }
     }
@@ -1081,7 +1082,8 @@ ProcessGDBRemote::DidLaunchOrAttach ()
 void
 ProcessGDBRemote::DidLaunch ()
 {
-    DidLaunchOrAttach ();
+    ArchSpec process_arch;
+    DidLaunchOrAttach (process_arch);
 }
 
 UnixSignals&
@@ -1199,9 +1201,11 @@ ProcessGDBRemote::SetExitStatus (int exi
 }
 
 void
-ProcessGDBRemote::DidAttach ()
+ProcessGDBRemote::DidAttach (ArchSpec &process_arch)
 {
-    DidLaunchOrAttach ();
+    // If you can figure out what the architecture is, fill it in here.
+    process_arch.Clear();
+    DidLaunchOrAttach (process_arch);
 }
 
 

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=214603&r1=214602&r2=214603&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Fri Aug  1 19:33:35 2014
@@ -117,7 +117,7 @@ public:
                                const lldb_private::ProcessAttachInfo &attach_info);
 
     virtual void
-    DidAttach ();
+    DidAttach (lldb_private::ArchSpec &process_arch);
 
     //------------------------------------------------------------------
     // PluginInterface protocol
@@ -389,7 +389,7 @@ protected:
     UpdateThreadIDList ();
 
     void
-    DidLaunchOrAttach ();
+    DidLaunchOrAttach (lldb_private::ArchSpec& process_arch);
 
     lldb_private::Error
     ConnectToDebugserver (const char *host_port);

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=214603&r1=214602&r2=214603&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Aug  1 19:33:35 2014
@@ -3063,7 +3063,11 @@ Process::CompleteAttach ()
 {
     // Let the process subclass figure out at much as it can about the process
     // before we go looking for a dynamic loader plug-in.
-    DidAttach();
+    ArchSpec process_arch;
+    DidAttach(process_arch);
+    
+    if (process_arch.IsValid())
+        m_target.SetArchitecture(process_arch);
 
     // We just attached.  If we have a platform, ask it for the process architecture, and if it isn't
     // the same as the one we've already set, switch architectures.
@@ -3082,7 +3086,7 @@ Process::CompleteAttach ()
                 m_target.SetArchitecture(platform_arch);
             }
         }
-        else
+        else if (!process_arch.IsValid())
         {
             ProcessInstanceInfo process_info;
             platform_sp->GetProcessInfo (GetID(), process_info);





More information about the lldb-commits mailing list