[Lldb-commits] [lldb] r232153 - Fix fetching the architecture of the target on process launch
Tamas Berghammer
tberghammer at google.com
Fri Mar 13 03:32:42 PDT 2015
Author: tberghammer
Date: Fri Mar 13 05:32:42 2015
New Revision: 232153
URL: http://llvm.org/viewvc/llvm-project?rev=232153&view=rev
Log:
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
Modified:
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=232153&r1=232152&r2=232153&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Fri Mar 13 05:32:42 2015
@@ -1071,6 +1071,9 @@ public:
bool
SetArchitecture (const ArchSpec &arch_spec);
+ bool
+ MergeArchitecture (const ArchSpec &arch_spec);
+
Debugger &
GetDebugger ()
{
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=232153&r1=232152&r2=232153&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Mar 13 05:32:42 2015
@@ -939,16 +939,17 @@ ProcessGDBRemote::DoLaunch (Module *exe_
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())
+ {
+ m_target.MergeArchitecture(process_arch);
+ }
+ else
{
- if (m_gdb_comm.GetProcessArchitecture().IsValid())
- {
- m_target.SetArchitecture(m_gdb_comm.GetProcessArchitecture());
- }
- else
- {
- m_target.SetArchitecture(m_gdb_comm.GetHostArchitecture());
- }
+ const ArchSpec &host_arch = m_gdb_comm.GetHostArchitecture();
+ if (host_arch.IsValid())
+ m_target.MergeArchitecture(host_arch);
}
SetPrivateState (SetThreadStopInfo (m_last_stop_packet));
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=232153&r1=232152&r2=232153&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Mar 13 05:32:42 2015
@@ -1189,6 +1189,30 @@ Target::SetArchitecture (const ArchSpec
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)
{
More information about the lldb-commits
mailing list