diff options
author | Jason Molenda <jmolenda@apple.com> | 2013-06-25 06:42:09 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2013-06-25 06:42:09 +0000 |
commit | 63a2648720ab1c245dbafbf00884dd1e1ba22c28 (patch) | |
tree | fb9ab7d32c6ba94d0359d4861cd4b3436339cc04 | |
parent | 59752d199bb19ffde140b67da147b0afa67f2e88 (diff) | |
download | lldb-63a2648720ab1c245dbafbf00884dd1e1ba22c28.tar.gz |
If debugserver fails to interrogate the inferior process CPU type
for any reason, use debugserver own's cputype as a best guess when
we reply to the debugger's qProcessInfo packet or when initializing
our register tables.
<rdar://problem/13406879>
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@184829 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/debugserver/source/RNBRemote.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tools/debugserver/source/RNBRemote.cpp b/tools/debugserver/source/RNBRemote.cpp index e6b030332..2055201d8 100644 --- a/tools/debugserver/source/RNBRemote.cpp +++ b/tools/debugserver/source/RNBRemote.cpp @@ -781,6 +781,29 @@ RNBRemote::ThreadFunctionReadRemoteData(void *arg) } +// If we fail to get back a valid CPU type for the remote process, +// make a best guess for the CPU type based on the currently running +// debugserver binary -- the debugger may not handle the case of an +// un-specified process CPU type correctly. + +static cpu_type_t +best_guess_cpu_type () +{ +#if defined (__arm__) + return CPU_TYPE_ARM; +#elif defined (__i386__) || defined (__x86_64__) + if (sizeof (char*) == 8) + { + return CPU_TYPE_X86_64; + } + else + { + return CPU_TYPE_I386; + } +#endif + return 0; +} + /* Read the bytes in STR which are GDB Remote Protocol binary encoded bytes (8-bit bytes). @@ -1133,6 +1156,12 @@ RNBRemote::InitializeRegisters (bool force) else { uint32_t cpu_type = DNBProcessGetCPUType (pid); + if (cpu_type == 0) + { + DNBLog ("Unable to get the process cpu_type, making a best guess."); + cpu_type = best_guess_cpu_type (); + } + DNBLogThreadedIf (LOG_RNB_PROC, "RNBRemote::%s() getting gdb registers(%s)", __FUNCTION__, m_arch.c_str()); #if defined (__i386__) || defined (__x86_64__) if (cpu_type == CPU_TYPE_X86_64) @@ -1527,7 +1556,6 @@ get_value (std::string &line) return value; } - extern void FileLogCallback(void *baton, uint32_t flags, const char *format, va_list args); extern void ASLLogCallback(void *baton, uint32_t flags, const char *format, va_list args); @@ -3976,6 +4004,12 @@ RNBRemote::HandlePacket_qProcessInfo (const char *p) } cpu_type_t cputype = DNBProcessGetCPUType (pid); + if (cputype == 0) + { + DNBLog ("Unable to get the process cpu_type, making a best guess."); + cputype = best_guess_cpu_type(); + } + if (cputype != 0) { rep << "cputype:" << std::hex << cputype << ";"; |