[Lldb-commits] [lldb] r184829 - If debugserver fails to interrogate the inferior process CPU type
Jason Molenda
jmolenda at apple.com
Mon Jun 24 23:42:09 PDT 2013
Author: jmolenda
Date: Tue Jun 25 01:42:09 2013
New Revision: 184829
URL: http://llvm.org/viewvc/llvm-project?rev=184829&view=rev
Log:
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>
Modified:
lldb/trunk/tools/debugserver/source/RNBRemote.cpp
Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=184829&r1=184828&r2=184829&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Tue Jun 25 01:42:09 2013
@@ -781,6 +781,29 @@ RNBRemote::ThreadFunctionReadRemoteData(
}
+// 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 for
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 (co
}
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 << ";";
More information about the lldb-commits
mailing list