aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2013-06-25 06:42:09 +0000
committerJason Molenda <jmolenda@apple.com>2013-06-25 06:42:09 +0000
commit63a2648720ab1c245dbafbf00884dd1e1ba22c28 (patch)
treefb9ab7d32c6ba94d0359d4861cd4b3436339cc04
parent59752d199bb19ffde140b67da147b0afa67f2e88 (diff)
downloadlldb-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.cpp36
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 << ";";