[Lldb-commits] [lldb] r163868 - in /lldb/trunk/source: Commands/CommandObjectProcess.cpp Host/macosx/Host.mm

Greg Clayton gclayton at apple.com
Thu Sep 13 19:41:36 PDT 2012


Author: gclayton
Date: Thu Sep 13 21:41:36 2012
New Revision: 163868

URL: http://llvm.org/viewvc/llvm-project?rev=163868&view=rev
Log:
<rdar://problem/11374963>

When attaching on ARM hosted debuggers we were incorrectly setting the triple to "arm-apple-ios". This was happening because in the post attach code, we would lookup the process info through the platform, and if successful, we would get the architecture of the process. This code uses sysctl() calls, but we can only get the CPU type, not the subtype, so we would get ARM for CPU type and nothing for the cpu subtype, so this would map to "arm-apple-ios". I fixed the code to get the cpu subtype from "hw.cpusubtype" which is what we really want for ARM, and not the architecture is already correct. "add-dsym" then works like a charm. I also improved the command output when the architecture changes to show the entire triple instead of just the arch name.


Modified:
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Host/macosx/Host.mm

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=163868&r1=163867&r2=163868&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Sep 13 21:41:36 2012
@@ -630,12 +630,13 @@
             
             if (!old_arch_spec.IsValid())
             {
-                result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetArchitectureName());
+                result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
             }
             else if (old_arch_spec != target->GetArchitecture())
             {
                 result.AppendWarningWithFormat("Architecture changed from %s to %s.\n", 
-                                                old_arch_spec.GetArchitectureName(), target->GetArchitecture().GetArchitectureName());
+                                               old_arch_spec.GetTriple().getTriple().c_str(),
+                                               target->GetArchitecture().GetTriple().getTriple().c_str());
             }
 
             // This supports the use-case scenario of immediately continuing the process once attached.

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=163868&r1=163867&r2=163868&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Thu Sep 13 21:41:36 2012
@@ -1039,14 +1039,24 @@
         mib_len++;
     
         cpu_type_t cpu, sub = 0;
-        size_t cpu_len = sizeof(cpu);
-        if (::sysctl (mib, mib_len, &cpu, &cpu_len, 0, 0) == 0)
+        size_t len = sizeof(cpu);
+        if (::sysctl (mib, mib_len, &cpu, &len, 0, 0) == 0)
         {
             switch (cpu)
             {
                 case llvm::MachO::CPUTypeI386:      sub = llvm::MachO::CPUSubType_I386_ALL;     break;
                 case llvm::MachO::CPUTypeX86_64:    sub = llvm::MachO::CPUSubType_X86_64_ALL;   break;
-                default: break;
+                case llvm::MachO::CPUTypeARM:
+                    {
+                        uint32_t cpusubtype = 0;
+                        len = sizeof(cpusubtype);
+                        if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
+                            sub = cpusubtype;
+                    }
+                    break;
+
+                default:
+                    break;
             }
             process_info.GetArchitecture ().SetArchitecture (eArchTypeMachO, cpu, sub);
             return true;





More information about the lldb-commits mailing list