diff options
Diffstat (limited to 'lldb/source/Plugins/Process')
10 files changed, 76 insertions, 142 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp index 4f6b17c81a2..28a28c71b0d 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.cpp @@ -94,13 +94,6 @@ MachThreadContext_arm::InitializeInstance() } - -uint32_t -MachThreadContext_arm::GetCPUType() -{ - return CPU_TYPE_ARM; -} - void MachThreadContext_arm::ThreadWillResume() { @@ -1879,6 +1872,6 @@ MachThreadContext_arm::Create (const ArchSpec &arch_spec, ThreadMacOSX &thread) void MachThreadContext_arm::Initialize() { - ArchSpec arch_spec(CPU_TYPE_ARM, CPU_TYPE_ANY); + ArchSpec arch_spec(eArchTypeMachO, 12, UINT32_MAX); ProcessMacOSX::AddArchCreateCallback(arch_spec, MachThreadContext_arm::Create); } diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h index 4ec72dfd0d4..333efee00ab 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h +++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_arm.h @@ -46,9 +46,6 @@ public: virtual void RefreshStateAfterStop (); - static uint32_t - GetCPUType (); - protected: kern_return_t EnableHardwareSingleStep (bool enable); diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp index ea148a69f41..03b5c2a4fb2 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp @@ -55,13 +55,6 @@ MachThreadContext_i386::InitializeInstance() m_flags_reg = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS); } - -uint32_t -MachThreadContext_i386::GetCPUType() -{ - return CPU_TYPE_I386; -} - void MachThreadContext_i386::ThreadWillResume() { diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h index 4bee2e7be8f..7da2259af7f 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h +++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.h @@ -40,7 +40,6 @@ public: virtual bool NotifyException(MachException::Data& exc); virtual size_t GetStackFrameData(lldb_private::StackFrame *first_frame, std::vector<std::pair<lldb::addr_t, lldb::addr_t> >& fp_pc_pairs); - static uint32_t GetCPUType(); protected: // kern_return_t EnableHardwareSingleStep (bool enable); diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp index 3ee9eb419de..7eaa8f46aa2 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp @@ -54,12 +54,6 @@ MachThreadContext_x86_64::InitializeInstance() m_flags_reg = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS); } -uint32_t -MachThreadContext_x86_64::GetCPUType() -{ - return CPU_TYPE_X86_64; -} - void MachThreadContext_x86_64::ThreadWillResume() { diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h index 45d5a375052..f4fc130000c 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h +++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.h @@ -54,9 +54,6 @@ public: virtual size_t GetStackFrameData (lldb_private::StackFrame *first_frame, std::vector<std::pair<lldb::addr_t, lldb::addr_t> >& fp_pc_pairs); - static uint32_t - GetCPUType(); - protected: // kern_return_t EnableHardwareSingleStep (bool enable); uint32_t m_flags_reg; diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp index 0116f006ffd..d887b09dd3a 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp @@ -532,31 +532,32 @@ ProcessMacOSX::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site) static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 }; static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC }; - switch (m_arch_spec.GetCPUType()) + ArchSpec::CPU arch_cpu = m_arch_spec.GetGenericCPUType(); + switch (arch_cpu) { - case CPU_TYPE_ARM: + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: + trap_opcode = g_i386_breakpoint_opcode; + trap_opcode_size = sizeof(g_i386_breakpoint_opcode); + break; + + case ArchSpec::eCPU_arm: // TODO: fill this in for ARM. We need to dig up the symbol for // the address in the breakpoint locaiton and figure out if it is // an ARM or Thumb breakpoint. trap_opcode = g_arm_breakpoint_opcode; trap_opcode_size = sizeof(g_arm_breakpoint_opcode); break; - - case CPU_TYPE_POWERPC: - case CPU_TYPE_POWERPC64: + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: trap_opcode = g_ppc_breakpoint_opcode; trap_opcode_size = sizeof(g_ppc_breakpoint_opcode); break; - case CPU_TYPE_I386: - case CPU_TYPE_X86_64: - trap_opcode = g_i386_breakpoint_opcode; - trap_opcode_size = sizeof(g_i386_breakpoint_opcode); - break; - default: assert(!"Unhandled architecture in ProcessMacOSX::GetSoftwareBreakpointTrapOpcode()"); - return 0; + break; } if (trap_opcode && trap_opcode_size) @@ -1721,16 +1722,19 @@ ProcessMacOSX::PosixSpawnChildForPTraceDebugging // We don't need to do this for ARM, and we really shouldn't now that we // have multiple CPU subtypes and no posix_spawnattr call that allows us // to set which CPU subtype to launch... - cpu_type_t cpu = arch_spec.GetCPUType(); - if (cpu != 0 && cpu != CPU_TYPE_ANY && cpu != LLDB_INVALID_CPUTYPE) + if (arch_spec.GetType() == eArchTypeMachO) { - size_t ocount = 0; - err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX); - if (err.Fail() || log) - err.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount); + cpu_type_t cpu = arch_spec.GetCPUType(); + if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE) + { + size_t ocount = 0; + err.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX); + if (err.Fail() || log) + err.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount); - if (err.Fail() != 0 || ocount != 1) - return LLDB_INVALID_PROCESS_ID; + if (err.Fail() != 0 || ocount != 1) + return LLDB_INVALID_PROCESS_ID; + } } #endif diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp index 37472547f55..5909bc42211 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp @@ -1153,38 +1153,14 @@ RegisterContextMach_arm::NumSupportedHardwareBreakpoints () // Set this to zero in case we can't tell if there are any HW breakpoints g_num_supported_hw_breakpoints = 0; - // Read the DBGDIDR to get the number of available hardware breakpoints - // However, in some of our current armv7 processors, hardware - // breakpoints/watchpoints were not properly connected. So detect those - // cases using a field in a sysctl. For now we are using "hw.cpusubtype" - // field to distinguish CPU architectures. This is a hack until we can - // get <rdar://problem/6372672> fixed, at which point we will switch to - // using a different sysctl string that will tell us how many BRPs - // are available to us directly without having to read DBGDIDR. uint32_t register_DBGDIDR; asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR)); - uint32_t numBRPs = bits(register_DBGDIDR, 27, 24); + g_num_supported_hw_breakpoints = bits(register_DBGDIDR, 27, 24); // Zero is reserved for the BRP count, so don't increment it if it is zero - if (numBRPs > 0) - numBRPs++; - ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, numBRPs); - - if (numBRPs > 0) - { - uint32_t cpu_subtype; - size_t len; - len = sizeof(cpusubtype); - // TODO: remove this hack and change to using hw.optional.xx when implmented - if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) - { - ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "hw.cpusubtype=0x%d", cpusubtype); - if (cpusubtype == CPU_SUBTYPE_ARM_V7) - ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "Hardware breakpoints disabled for armv7 (rdar://problem/6372672)"); - else - g_num_supported_hw_breakpoints = numBRPs; - } - } + if (g_num_supported_hw_breakpoints > 0) + g_num_supported_hw_breakpoints++; + ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_breakpoints); } return g_num_supported_hw_breakpoints; @@ -1306,37 +1282,11 @@ RegisterContextMach_arm::NumSupportedHardwareWatchpoints () { // Set this to zero in case we can't tell if there are any HW breakpoints g_num_supported_hw_watchpoints = 0; - // Read the DBGDIDR to get the number of available hardware breakpoints - // However, in some of our current armv7 processors, hardware - // breakpoints/watchpoints were not properly connected. So detect those - // cases using a field in a sysctl. For now we are using "hw.cpusubtype" - // field to distinguish CPU architectures. This is a hack until we can - // get <rdar://problem/6372672> fixed, at which point we will switch to - // using a different sysctl string that will tell us how many WRPs - // are available to us directly without having to read DBGDIDR. uint32_t register_DBGDIDR; asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR)); - uint32_t numWRPs = bits(register_DBGDIDR, 31, 28) + 1; - ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, numWRPs); - - if (numWRPs > 0) - { - uint32_t cpusubtype; - size_t len; - len = sizeof(cpusubtype); - // TODO: remove this hack and change to using hw.optional.xx when implmented - if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) - { - ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "hw.cpusubtype=0x%d", cpusubtype); - - if (cpusubtype == CPU_SUBTYPE_ARM_V7) - ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "Hardware watchpoints disabled for armv7 (rdar://problem/6372672)"); - else - g_num_supported_hw_watchpoints = numWRPs; - } - } - + g_num_supported_hw_watchpoints = bits(register_DBGDIDR, 31, 28) + 1; + ProcessMacOSXLog::LogIf(PD_LOG_THREAD, "DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, g_num_supported_hw_watchpoints); } return g_num_supported_hw_watchpoints; #else diff --git a/lldb/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp b/lldb/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp index 58a7ac043c5..e6c7b354abc 100644 --- a/lldb/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp +++ b/lldb/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp @@ -250,15 +250,16 @@ instruction_length (lldb_private::unw_addr_space_t as, lldb_private::unw_word_t if (arg == 0) return -1; - Thread *th = (Thread *) arg; - const ArchSpec target_arch (th->GetProcess().GetTarget().GetArchitecture ()); + Thread *thread = (Thread *) arg; - if (target_arch.GetCPUType() == CPU_TYPE_I386) + const ArchSpec::CPU arch_cpu = thread->GetProcess().GetTarget().GetArchitecture ().GetGenericCPUType(); + + if (arch_cpu == ArchSpec::eCPU_i386) { if (EDGetDisassembler (&disasm, "i386-apple-darwin", kEDAssemblySyntaxX86ATT) != 0) return -1; } - else if (target_arch.GetCPUType() == CPU_TYPE_X86_64) + else if (arch_cpu == ArchSpec::eCPU_x86_64) { if (EDGetDisassembler (&disasm, "x86_64-apple-darwin", kEDAssemblySyntaxX86ATT) != 0) return -1; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index e8b194e26de..8bf90c2c22b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -875,31 +875,32 @@ ProcessGDBRemote::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site) static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 }; static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC }; - switch (m_arch_spec.GetCPUType()) + ArchSpec::CPU arch_cpu = m_arch_spec.GetGenericCPUType(); + switch (arch_cpu) { - case CPU_TYPE_ARM: - // TODO: fill this in for ARM. We need to dig up the symbol for - // the address in the breakpoint locaiton and figure out if it is - // an ARM or Thumb breakpoint. - trap_opcode = g_arm_breakpoint_opcode; - trap_opcode_size = sizeof(g_arm_breakpoint_opcode); - break; - - case CPU_TYPE_POWERPC: - case CPU_TYPE_POWERPC64: - trap_opcode = g_ppc_breakpoint_opcode; - trap_opcode_size = sizeof(g_ppc_breakpoint_opcode); - break; - - case CPU_TYPE_I386: - case CPU_TYPE_X86_64: - trap_opcode = g_i386_breakpoint_opcode; - trap_opcode_size = sizeof(g_i386_breakpoint_opcode); - break; - - default: - assert(!"Unhandled architecture in ProcessGDBRemote::GetSoftwareBreakpointTrapOpcode()"); - return 0; + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: + trap_opcode = g_i386_breakpoint_opcode; + trap_opcode_size = sizeof(g_i386_breakpoint_opcode); + break; + + case ArchSpec::eCPU_arm: + // TODO: fill this in for ARM. We need to dig up the symbol for + // the address in the breakpoint locaiton and figure out if it is + // an ARM or Thumb breakpoint. + trap_opcode = g_arm_breakpoint_opcode; + trap_opcode_size = sizeof(g_arm_breakpoint_opcode); + break; + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + trap_opcode = g_ppc_breakpoint_opcode; + trap_opcode_size = sizeof(g_ppc_breakpoint_opcode); + break; + + default: + assert(!"Unhandled architecture in ProcessMacOSX::GetSoftwareBreakpointTrapOpcode()"); + break; } if (trap_opcode && trap_opcode_size) @@ -1719,16 +1720,19 @@ ProcessGDBRemote::StartDebugserverProcess // We don't need to do this for ARM, and we really shouldn't now that we // have multiple CPU subtypes and no posix_spawnattr call that allows us // to set which CPU subtype to launch... - cpu_type_t cpu = inferior_arch.GetCPUType(); - if (cpu != 0 && cpu != CPU_TYPE_ANY && cpu != LLDB_INVALID_CPUTYPE) + if (inferior_arch.GetType() == eArchTypeMachO) { - size_t ocount = 0; - error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX); - if (error.Fail() || log) - error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount); + cpu_type_t cpu = inferior_arch.GetCPUType(); + if (cpu != 0 && cpu != UINT32_MAX && cpu != LLDB_INVALID_CPUTYPE) + { + size_t ocount = 0; + error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX); + if (error.Fail() || log) + error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount); - if (error.Fail() != 0 || ocount != 1) - return error; + if (error.Fail() != 0 || ocount != 1) + return error; + } } #endif @@ -2175,9 +2179,11 @@ lldb_private::unw_addr_space_t ProcessGDBRemote::GetLibUnwindAddressSpace () { unw_targettype_t target_type = UNW_TARGET_UNSPECIFIED; - if (m_target.GetArchitecture().GetCPUType() == CPU_TYPE_I386) + + ArchSpec::CPU arch_cpu = m_target.GetArchitecture().GetGenericCPUType(); + if (arch_cpu == ArchSpec::eCPU_i386) target_type = UNW_TARGET_I386; - if (m_target.GetArchitecture().GetCPUType() == CPU_TYPE_X86_64) + else if (arch_cpu == ArchSpec::eCPU_x86_64) target_type = UNW_TARGET_X86_64; if (m_libunwind_addr_space) |

