[Lldb-commits] [lldb] r120618 - in /lldb/trunk/tools/debugserver/source: DNB.cpp DNB.h DNBArch.cpp DNBArch.h MacOSX/MachProcess.cpp MacOSX/MachProcess.h MacOSX/MachThreadList.cpp debugserver.cpp

Greg Clayton gclayton at apple.com
Wed Dec 1 14:45:40 PST 2010


Author: gclayton
Date: Wed Dec  1 16:45:40 2010
New Revision: 120618

URL: http://llvm.org/viewvc/llvm-project?rev=120618&view=rev
Log:
Fixed 32 bit debugging after recent architecture changes to debugserver.


Modified:
    lldb/trunk/tools/debugserver/source/DNB.cpp
    lldb/trunk/tools/debugserver/source/DNB.h
    lldb/trunk/tools/debugserver/source/DNBArch.cpp
    lldb/trunk/tools/debugserver/source/DNBArch.h
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
    lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
    lldb/trunk/tools/debugserver/source/debugserver.cpp

Modified: lldb/trunk/tools/debugserver/source/DNB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=120618&r1=120617&r2=120618&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNB.cpp (original)
+++ lldb/trunk/tools/debugserver/source/DNB.cpp Wed Dec  1 16:45:40 2010
@@ -2019,3 +2019,18 @@
 DNBTerminate()
 {
 }
+
+nub_bool_t
+DNBSetArchitecture (const char *arch)
+{
+    if (arch && arch[0])
+    {
+        if (strcasecmp (arch, "i386") == 0)
+            return DNBArchProtocol::SetArchitecture (CPU_TYPE_I386);
+        else if (strcasecmp (arch, "x86_64") == 0)
+            return DNBArchProtocol::SetArchitecture (CPU_TYPE_X86_64);
+        else if (strstr (arch, "arm") == arch)
+            return DNBArchProtocol::SetArchitecture (CPU_TYPE_ARM);
+    }
+    return false;
+}

Modified: lldb/trunk/tools/debugserver/source/DNB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.h?rev=120618&r1=120617&r2=120618&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNB.h (original)
+++ lldb/trunk/tools/debugserver/source/DNB.h Wed Dec  1 16:45:40 2010
@@ -28,6 +28,8 @@
 void            DNBInitialize ();
 void            DNBTerminate ();
 
+nub_bool_t      DNBSetArchitecture      (const char *arch);
+
 //----------------------------------------------------------------------
 // Process control
 //----------------------------------------------------------------------

Modified: lldb/trunk/tools/debugserver/source/DNBArch.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBArch.cpp?rev=120618&r1=120617&r2=120618&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBArch.cpp (original)
+++ lldb/trunk/tools/debugserver/source/DNBArch.cpp Wed Dec  1 16:45:40 2010
@@ -22,13 +22,13 @@
 typedef std::map<uint32_t, DNBArchPluginInfo> CPUPluginInfoMap;
 
 #if defined (__i386__)
-uint32_t g_current_cpu_type = CPU_TYPE_I386;
+static uint32_t g_current_cpu_type = CPU_TYPE_I386;
 #elif defined (__x86_64__)
-uint32_t g_current_cpu_type = CPU_TYPE_X86_64;
+static uint32_t g_current_cpu_type = CPU_TYPE_X86_64;
 #elif defined (__arm__) 
-uint32_t g_current_cpu_type = CPU_TYPE_ARM;
+static uint32_t g_current_cpu_type = CPU_TYPE_ARM;
 #else
-uint32_t g_current_cpu_type = 0;
+static uint32_t g_current_cpu_type = 0;
 #endif
 
 CPUPluginInfoMap g_arch_plugins;
@@ -43,12 +43,20 @@
     return NULL;
 }
 
-void
-DNBArchProtocol::SetDefaultArchitecture (uint32_t cpu_type)
+
+uint32_t
+DNBArchProtocol::GetArchitecture ()
+{
+    return g_current_cpu_type;
+}
+
+bool
+DNBArchProtocol::SetArchitecture (uint32_t cpu_type)
 {
-    DNBLogThreadedIf (LOG_PROCESS, "DNBArchProtocol::SetDefaultArchitecture (cpu_type=0x%8.8x)", cpu_type);
     g_current_cpu_type = cpu_type;
-    assert (g_arch_plugins.find(g_current_cpu_type) != g_arch_plugins.end());
+    bool result = g_arch_plugins.find(g_current_cpu_type) != g_arch_plugins.end();
+    DNBLogThreadedIf (LOG_PROCESS, "DNBArchProtocol::SetDefaultArchitecture (cpu_type=0x%8.8x) => %i", cpu_type, result);
+    return result;
 }
 
 void

Modified: lldb/trunk/tools/debugserver/source/DNBArch.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBArch.h?rev=120618&r1=120617&r2=120618&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBArch.h (original)
+++ lldb/trunk/tools/debugserver/source/DNBArch.h Wed Dec  1 16:45:40 2010
@@ -52,9 +52,12 @@
     static void
     RegisterArchPlugin (const DNBArchPluginInfo &arch_info);
 
-    static void
-    SetDefaultArchitecture (uint32_t cpu_type);
+    static uint32_t
+    GetArchitecture ();
 
+    static bool
+    SetArchitecture (uint32_t cpu_type);
+    
     virtual bool            GetRegisterValue (int set, int reg, DNBRegisterValue *value) = 0;
     virtual bool            SetRegisterValue (int set, int reg, const DNBRegisterValue *value) = 0;
     virtual nub_size_t      GetRegisterContext (void *buf, nub_size_t buf_len) = 0;

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=120618&r1=120617&r2=120618&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Wed Dec  1 16:45:40 2010
@@ -115,7 +115,6 @@
     m_image_infos_baton(NULL)
 {
     DNBLogThreadedIf(LOG_PROCESS | LOG_VERBOSE, "%s", __PRETTY_FUNCTION__);
-    bzero(&m_arch_plugin_info, sizeof(m_arch_plugin_info));
 }
 
 MachProcess::~MachProcess()
@@ -1517,7 +1516,7 @@
 
     case eLaunchFlavorPosixSpawn:
         m_pid = MachProcess::PosixSpawnChildForPTraceDebugging (path, 
-                                                                m_arch_plugin_info.cpu_type,
+                                                                DNBArchProtocol::GetArchitecture (),
                                                                 argv, 
                                                                 envp, 
                                                                 stdio_path, 

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=120618&r1=120617&r2=120618&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Wed Dec  1 16:45:40 2010
@@ -254,7 +254,6 @@
     DNBCallbackCopyExecutableImageInfos
                                 m_image_infos_callback;
     void *                      m_image_infos_baton;
-    DNBArchPluginInfo           m_arch_plugin_info;
 };
 
 

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=120618&r1=120617&r2=120618&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Wed Dec  1 16:45:40 2010
@@ -230,9 +230,9 @@
                 is_64_bit = true;
         }
         if (is_64_bit)
-            DNBArchProtocol::SetDefaultArchitecture(CPU_TYPE_X86_64);
+            DNBArchProtocol::SetArchitecture(CPU_TYPE_X86_64);
         else
-            DNBArchProtocol::SetDefaultArchitecture(CPU_TYPE_I386);
+            DNBArchProtocol::SetArchitecture(CPU_TYPE_I386);
     }
 #endif
     

Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=120618&r1=120617&r2=120618&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/debugserver.cpp (original)
+++ lldb/trunk/tools/debugserver/source/debugserver.cpp Wed Dec  1 16:45:40 2010
@@ -886,6 +886,10 @@
         arch_name.assign ("arm");
 #endif
     }
+    else
+    {
+        DNBSetArchitecture (arch_name.c_str());
+    }
 
     if (arch_name.empty())
     {
@@ -897,6 +901,8 @@
     argv += optind;
 
     g_remoteSP.reset (new RNBRemote (use_native_registers, arch_name.c_str()));
+    
+    
 
     RNBRemote *remote = g_remoteSP.get();
     if (remote == NULL)





More information about the lldb-commits mailing list