From 389be9558fdd632bcc460da265db9d30484f3ced Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 8 Jul 2014 21:45:21 +0000 Subject: [PATCH] Make sure that qProcessInfo packet returns correct cpu type/subtype for processes on Haswell machines with a Haswell enabled kernel. llvm-svn: 212567 --- lldb/tools/debugserver/source/RNBRemote.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index 0dc514f..407f2e7 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -4379,20 +4379,25 @@ RNBRemote::HandlePacket_qProcessInfo (const char *p) size_t cpusubtype_len = sizeof(cpusubtype); if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &cpusubtype_len, NULL, 0) == 0) { - if (cputype == CPU_TYPE_X86_64 && cpusubtype == CPU_SUBTYPE_486) + // If a process is CPU_TYPE_X86, then ignore the cpusubtype that we detected + // from the host and use CPU_SUBTYPE_I386_ALL because we don't want the + // CPU_SUBTYPE_X86_ARCH1 or CPU_SUBTYPE_X86_64_H to be used as the cpu subtype + // for i386... + if (host_cpu_is_64bit) { - cpusubtype = CPU_SUBTYPE_X86_64_ALL; - } - - // We can query a process' cputype but we cannot query a process' cpusubtype. - // If the process has cputype CPU_TYPE_ARM, then it is an armv7 (32-bit process) and we - // need to override the host cpusubtype (which is in the CPU_SUBTYPE_ARM64 subtype namespace) - // with a reasonable CPU_SUBTYPE_ARMV7 subtype. - if (host_cpu_is_64bit && cputype == CPU_TYPE_ARM) - { - cpusubtype = 11; //CPU_SUBTYPE_ARM_V7S; + if (cputype == CPU_TYPE_X86) + { + cpusubtype = 3; // CPU_SUBTYPE_I386_ALL + } + else if (cputype == CPU_TYPE_ARM) + { + // We can query a process' cputype but we cannot query a process' cpusubtype. + // If the process has cputype CPU_TYPE_ARM, then it is an armv7 (32-bit process) and we + // need to override the host cpusubtype (which is in the CPU_SUBTYPE_ARM64 subtype namespace) + // with a reasonable CPU_SUBTYPE_ARMV7 subtype. + cpusubtype = 11; // CPU_SUBTYPE_ARM_V7S + } } - rep << "cpusubtype:" << std::hex << cpusubtype << ';'; } -- 2.7.4