void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
- LLDB_LOGF(log, "ProcessGDBRemote::%s()", __FUNCTION__);
- if (GetID() != LLDB_INVALID_PROCESS_ID) {
- BuildDynamicRegisterInfo(false);
+ BuildDynamicRegisterInfo(false);
- // See if the GDB server supports the qHostInfo information
+ // See if the GDB server supports qHostInfo or qProcessInfo packets. Prefer
+ // qProcessInfo as it will be more specific to our process.
- // See if the GDB server supports the qProcessInfo packet, if so prefer
- // that over the Host information as it will be more specific to our
- // process.
+ const ArchSpec &remote_process_arch = m_gdb_comm.GetProcessArchitecture();
+ if (remote_process_arch.IsValid()) {
+ process_arch = remote_process_arch;
+ LLDB_LOG(log, "gdb-remote had process architecture, using {0} {1}",
+ process_arch.GetArchitectureName(),
+ process_arch.GetTriple().getTriple());
+ } else {
+ process_arch = m_gdb_comm.GetHostArchitecture();
+ LLDB_LOG(log,
+ "gdb-remote did not have process architecture, using gdb-remote "
+ "host architecture {0} {1}",
+ process_arch.GetArchitectureName(),
+ process_arch.GetTriple().getTriple());
+ }
- const ArchSpec &remote_process_arch = m_gdb_comm.GetProcessArchitecture();
- if (remote_process_arch.IsValid()) {
- process_arch = remote_process_arch;
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s gdb-remote had process architecture, "
- "using %s %s",
- __FUNCTION__,
- process_arch.GetArchitectureName()
- ? process_arch.GetArchitectureName()
- : "<null>",
- process_arch.GetTriple().getTriple().c_str()
- ? process_arch.GetTriple().getTriple().c_str()
- : "<null>");
- } else {
- process_arch = m_gdb_comm.GetHostArchitecture();
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s gdb-remote did not have process "
- "architecture, using gdb-remote host architecture %s %s",
- __FUNCTION__,
- process_arch.GetArchitectureName()
- ? process_arch.GetArchitectureName()
- : "<null>",
- process_arch.GetTriple().getTriple().c_str()
- ? process_arch.GetTriple().getTriple().c_str()
- : "<null>");
- }
+ if (process_arch.IsValid()) {
+ const ArchSpec &target_arch = GetTarget().GetArchitecture();
+ if (target_arch.IsValid()) {
+ LLDB_LOG(log, "analyzing target arch, currently {0} {1}",
+ target_arch.GetArchitectureName(),
+ target_arch.GetTriple().getTriple());
+
+ // If the remote host is ARM and we have apple as the vendor, then
+ // ARM executables and shared libraries can have mixed ARM
+ // architectures.
+ // You can have an armv6 executable, and if the host is armv7, then the
+ // system will load the best possible architecture for all shared
+ // libraries it has, so we really need to take the remote host
+ // architecture as our defacto architecture in this case.
+
+ if ((process_arch.GetMachine() == llvm::Triple::arm ||
+ process_arch.GetMachine() == llvm::Triple::thumb) &&
+ process_arch.GetTriple().getVendor() == llvm::Triple::Apple) {
+ GetTarget().SetArchitecture(process_arch);
+ LLDB_LOG(log,
+ "remote process is ARM/Apple, "
+ "setting target arch to {0} {1}",
+ process_arch.GetArchitectureName(),
+ process_arch.GetTriple().getTriple());
+ } else {
+ // Fill in what is missing in the triple
+ const llvm::Triple &remote_triple = process_arch.GetTriple();
+ llvm::Triple new_target_triple = target_arch.GetTriple();
+ if (new_target_triple.getVendorName().size() == 0) {
+ new_target_triple.setVendor(remote_triple.getVendor());
- if (process_arch.IsValid()) {
- const ArchSpec &target_arch = GetTarget().GetArchitecture();
- if (target_arch.IsValid()) {
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s analyzing target arch, currently %s %s",
- __FUNCTION__,
- target_arch.GetArchitectureName()
- ? target_arch.GetArchitectureName()
- : "<null>",
- target_arch.GetTriple().getTriple().c_str()
- ? target_arch.GetTriple().getTriple().c_str()
- : "<null>");
-
- // If the remote host is ARM and we have apple as the vendor, then
- // ARM executables and shared libraries can have mixed ARM
- // architectures.
- // You can have an armv6 executable, and if the host is armv7, then the
- // system will load the best possible architecture for all shared
- // libraries it has, so we really need to take the remote host
- // architecture as our defacto architecture in this case.
-
- if ((process_arch.GetMachine() == llvm::Triple::arm ||
- process_arch.GetMachine() == llvm::Triple::thumb) &&
- process_arch.GetTriple().getVendor() == llvm::Triple::Apple) {
- GetTarget().SetArchitecture(process_arch);
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s remote process is ARM/Apple, "
- "setting target arch to %s %s",
- __FUNCTION__,
- process_arch.GetArchitectureName()
- ? process_arch.GetArchitectureName()
- : "<null>",
- process_arch.GetTriple().getTriple().c_str()
- ? process_arch.GetTriple().getTriple().c_str()
- : "<null>");
- } else {
- // Fill in what is missing in the triple
- const llvm::Triple &remote_triple = process_arch.GetTriple();
- llvm::Triple new_target_triple = target_arch.GetTriple();
- if (new_target_triple.getVendorName().size() == 0) {
- new_target_triple.setVendor(remote_triple.getVendor());
-
- if (new_target_triple.getOSName().size() == 0) {
- new_target_triple.setOS(remote_triple.getOS());
-
- if (new_target_triple.getEnvironmentName().size() == 0)
- new_target_triple.setEnvironment(
- remote_triple.getEnvironment());
- }
+ if (new_target_triple.getOSName().size() == 0) {
+ new_target_triple.setOS(remote_triple.getOS());
- ArchSpec new_target_arch = target_arch;
- new_target_arch.SetTriple(new_target_triple);
- GetTarget().SetArchitecture(new_target_arch);
+ if (new_target_triple.getEnvironmentName().size() == 0)
+ new_target_triple.setEnvironment(remote_triple.getEnvironment());
}
- }
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s final target arch after "
- "adjustments for remote architecture: %s %s",
- __FUNCTION__,
- target_arch.GetArchitectureName()
- ? target_arch.GetArchitectureName()
- : "<null>",
- target_arch.GetTriple().getTriple().c_str()
- ? target_arch.GetTriple().getTriple().c_str()
- : "<null>");
- } else {
- // The target doesn't have a valid architecture yet, set it from the
- // architecture we got from the remote GDB server
- GetTarget().SetArchitecture(process_arch);
+ ArchSpec new_target_arch = target_arch;
+ new_target_arch.SetTriple(new_target_triple);
+ GetTarget().SetArchitecture(new_target_arch);
+ }
}
- }
- // Find out which StructuredDataPlugins are supported by the debug monitor.
- // These plugins transmit data over async $J packets.
- auto supported_packets_array =
- m_gdb_comm.GetSupportedStructuredDataPlugins();
- if (supported_packets_array)
- MapSupportedStructuredDataPlugins(*supported_packets_array);
+ LLDB_LOG(log,
+ "final target arch after adjustments for remote architecture: "
+ "{0} {1}",
+ target_arch.GetArchitectureName(),
+ target_arch.GetTriple().getTriple());
+ } else {
+ // The target doesn't have a valid architecture yet, set it from the
+ // architecture we got from the remote GDB server
+ GetTarget().SetArchitecture(process_arch);
+ }
}
+
+ // Find out which StructuredDataPlugins are supported by the debug monitor.
+ // These plugins transmit data over async $J packets.
+ if (StructuredData::Array *supported_packets =
+ m_gdb_comm.GetSupportedStructuredDataPlugins())
+ MapSupportedStructuredDataPlugins(*supported_packets);
}
void ProcessGDBRemote::DidLaunch() {