diff options
author | Tamas Berghammer <tberghammer@google.com> | 2015-03-13 10:32:42 +0000 |
---|---|---|
committer | Tamas Berghammer <tberghammer@google.com> | 2015-03-13 10:32:42 +0000 |
commit | e9f4dfe6fbe2a2ab85974180e691af304c49da75 (patch) | |
tree | 79900fbd9072651e8f1cd6d5473aab1fd8c8a8e0 | |
parent | e724af10b67b91a594568444772a9c4f7d705f80 (diff) | |
download | bcm5719-llvm-e9f4dfe6fbe2a2ab85974180e691af304c49da75.tar.gz bcm5719-llvm-e9f4dfe6fbe2a2ab85974180e691af304c49da75.zip |
Fix fetching the architecture of the target on process launch
Previously it was fetched only if the architecture isn't valid, but the
architecture can be valid without containing all information about the
current target (e.g. missing os).
Differential revision: http://reviews.llvm.org/D8057
llvm-svn: 232153
-rw-r--r-- | lldb/include/lldb/Target/Target.h | 3 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 19 | ||||
-rw-r--r-- | lldb/source/Target/Target.cpp | 24 |
3 files changed, 37 insertions, 9 deletions
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 6785c3e87dd..426f038e5f4 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -1071,6 +1071,9 @@ public: bool SetArchitecture (const ArchSpec &arch_spec); + bool + MergeArchitecture (const ArchSpec &arch_spec); + Debugger & GetDebugger () { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 67dcfad5cf7..365180a1097 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -939,16 +939,17 @@ ProcessGDBRemote::DoLaunch (Module *exe_module, ProcessLaunchInfo &launch_info) if (m_gdb_comm.SendPacketAndWaitForResponse("?", 1, m_last_stop_packet, false) == GDBRemoteCommunication::PacketResult::Success) { - if (!m_target.GetArchitecture().IsValid()) + const ArchSpec &process_arch = m_gdb_comm.GetProcessArchitecture(); + + if (process_arch.IsValid()) { - if (m_gdb_comm.GetProcessArchitecture().IsValid()) - { - m_target.SetArchitecture(m_gdb_comm.GetProcessArchitecture()); - } - else - { - m_target.SetArchitecture(m_gdb_comm.GetHostArchitecture()); - } + m_target.MergeArchitecture(process_arch); + } + else + { + const ArchSpec &host_arch = m_gdb_comm.GetHostArchitecture(); + if (host_arch.IsValid()) + m_target.MergeArchitecture(host_arch); } SetPrivateState (SetThreadStopInfo (m_last_stop_packet)); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 823fba00434..beca40376ea 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -1189,6 +1189,30 @@ Target::SetArchitecture (const ArchSpec &arch_spec) return false; } +bool +Target::MergeArchitecture (const ArchSpec &arch_spec) +{ + if (arch_spec.IsValid()) + { + if (m_arch.IsCompatibleMatch(arch_spec)) + { + // The current target arch is compatible with "arch_spec", see if we + // can improve our current architecture using bits from "arch_spec" + + // Merge bits from arch_spec into "merged_arch" and set our architecture + ArchSpec merged_arch (m_arch); + merged_arch.MergeFrom (arch_spec); + return SetArchitecture(merged_arch); + } + else + { + // The new architecture is different, we just need to replace it + return SetArchitecture(arch_spec); + } + } + return false; +} + void Target::WillClearList (const ModuleList& module_list) { |