summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-10-28 23:26:59 +0000
committerGreg Clayton <gclayton@apple.com>2015-10-28 23:26:59 +0000
commita37068885a516c7e3a5df8b0b0f8c5b95c9bfc9d (patch)
tree7ef0602f9c61740bd332e71ffe658d53b7bc4c7c /lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
parent21e36c4f89b0ca6e6516a48e15b3a5aed497f001 (diff)
downloadbcm5719-llvm-a37068885a516c7e3a5df8b0b0f8c5b95c9bfc9d.tar.gz
bcm5719-llvm-a37068885a516c7e3a5df8b0b0f8c5b95c9bfc9d.zip
Make sure we don't over specify an architecture when we connect to KDP and use the CPU type and subtype to fill out an architecture. We do this by letting the vendor be an unspecified unknown, or any. We also grab the target architecture, get the KDP host arch, and then merge the two before putting it back into the target.
Also change MH_PRELOAD to be use "unspecified unknown" (any) for the OS and vendor since these mach files can really be anything. llvm-svn: 251579
Diffstat (limited to 'lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp')
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp43
1 files changed, 29 insertions, 14 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index b0961e5278c..b6684370f85 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -244,6 +244,23 @@ ProcessKDP::WillAttachToProcessWithName (const char *process_name, bool wait_for
return error;
}
+bool
+ProcessKDP::GetHostArchitecture(ArchSpec &arch)
+{
+ uint32_t cpu = m_comm.GetCPUType();
+ if (cpu)
+ {
+ uint32_t sub = m_comm.GetCPUSubtype();
+ arch.SetArchitecture(eArchTypeMachO, cpu, sub);
+ // Leave architecture vendor as unspecified unknown
+ arch.GetTriple().setVendor(llvm::Triple::UnknownVendor);
+ arch.GetTriple().setVendorName(llvm::StringRef());
+ return true;
+ }
+ arch.Clear();
+ return false;
+}
+
Error
ProcessKDP::DoConnectRemote (Stream *strm, const char *remote_url)
{
@@ -288,13 +305,16 @@ ProcessKDP::DoConnectRemote (Stream *strm, const char *remote_url)
if (m_comm.SendRequestConnect(reply_port, reply_port, "Greetings from LLDB..."))
{
m_comm.GetVersion();
- uint32_t cpu = m_comm.GetCPUType();
- uint32_t sub = m_comm.GetCPUSubtype();
- ArchSpec kernel_arch;
- kernel_arch.SetArchitecture(eArchTypeMachO, cpu, sub);
+
Target &target = GetTarget();
-
- target.SetArchitecture(kernel_arch);
+ ArchSpec kernel_arch;
+ // The host architecture
+ GetHostArchitecture(kernel_arch);
+ ArchSpec target_arch = target.GetArchitecture();
+ // Merge in any unspecified stuff into the target architecture in
+ // case the target arch isn't set at all or incompletely.
+ target_arch.MergeFrom(kernel_arch);
+ target.SetArchitecture(target_arch);
/* Get the kernel's UUID and load address via KDP_KERNELVERSION packet. */
/* An EFI kdp session has neither UUID nor load address. */
@@ -333,8 +353,8 @@ ProcessKDP::DoConnectRemote (Stream *strm, const char *remote_url)
if (module_spec.GetFileSpec().Exists())
{
- ModuleSP module_sp(new Module (module_spec.GetFileSpec(), target.GetArchitecture()));
- if (module_sp.get() && module_sp->MatchesModuleSpec (module_spec))
+ ModuleSP module_sp(new Module (module_spec));
+ if (module_sp.get() && module_sp->GetObjectFile())
{
// Get the current target executable
ModuleSP exe_module_sp (target.GetExecutableModule ());
@@ -441,12 +461,7 @@ ProcessKDP::DidAttach (ArchSpec &process_arch)
log->Printf ("ProcessKDP::DidAttach()");
if (GetID() != LLDB_INVALID_PROCESS_ID)
{
- uint32_t cpu = m_comm.GetCPUType();
- if (cpu)
- {
- uint32_t sub = m_comm.GetCPUSubtype();
- process_arch.SetArchitecture(eArchTypeMachO, cpu, sub);
- }
+ GetHostArchitecture(process_arch);
}
}
OpenPOWER on IntegriCloud