diff options
Diffstat (limited to 'lldb')
3 files changed, 49 insertions, 26 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 625418c508a..18a6a987388 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -4768,16 +4768,22 @@ ObjectFileMachO::GetArchitecture (const llvm::MachO::mach_header &header, if (arch.IsValid()) { llvm::Triple &triple = arch.GetTriple(); + + // Set OS to an unspecified unknown or a "*" so it can match any OS + triple.setOS(llvm::Triple::UnknownOS); + triple.setOSName(llvm::StringRef()); + if (header.filetype == MH_PRELOAD) { - // Set OS to "unknown" - this is a standalone binary with no dyld et al - triple.setOS(llvm::Triple::UnknownOS); + // Set vendor to an unspecified unknown or a "*" so it can match any vendor + triple.setVendor(llvm::Triple::UnknownVendor); + triple.setVendorName(llvm::StringRef()); return true; } else { struct load_command load_cmd; - + lldb::offset_t offset = lc_offset; for (uint32_t i=0; i<header.ncmds; ++i) { @@ -4802,14 +4808,13 @@ ObjectFileMachO::GetArchitecture (const llvm::MachO::mach_header &header, offset = cmd_offset + load_cmd.cmdsize; } - // Only set the OS to iOS for ARM, we don't want to set it for x86 and x86_64. - // We do this because we now have MacOSX or iOS as the OS value for x86 and - // x86_64 for normal desktop (MacOSX) and simulator (iOS) binaries. And if - // we compare a "x86_64-apple-ios" to a "x86_64-apple-" triple, it will say - // it is compatible (because the OS is unspecified in the second one and will - // match anything in the first - if (header.cputype == CPU_TYPE_ARM || header.cputype == CPU_TYPE_ARM64) - triple.setOS (llvm::Triple::IOS); + if (header.filetype != MH_KEXT_BUNDLE) + { + // We didn't find a LC_VERSION_MIN load command and this isn't a KEXT + // so lets not say our Vendor is Apple, leave it as an unspecified unknown + triple.setVendor(llvm::Triple::UnknownVendor); + triple.setVendorName(llvm::StringRef()); + } } } return arch.IsValid(); 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); } } diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h index 6eff228b260..fe9a4e2844b 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h @@ -218,7 +218,10 @@ protected: { return state == lldb::eStateExited; } - + + bool + GetHostArchitecture (lldb_private::ArchSpec &arch); + bool ProcessIDIsValid ( ) const; |