Author: Jonas Devlieghere Date: 2021-04-16T13:49:38-07:00 New Revision: db2da0c8f907c444e0bf8b788d8186c4c67db0b2
URL: https://github.com/llvm/llvm-project/commit/db2da0c8f907c444e0bf8b788d8186c4c67db0b2 DIFF: https://github.com/llvm/llvm-project/commit/db2da0c8f907c444e0bf8b788d8186c4c67db0b2.diff LOG: [lldb] Set addressable bits from qHostInfo Read the number of addressable bits from the qHostInfo packet and use it to set the code and data address mask in the process. The data (addressing_bits) is already present in the packet. Differential revision: https://reviews.llvm.org/D100520 Added: Modified: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index ef6441289fc50..d709716d8e459 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -100,11 +100,11 @@ GDBRemoteCommunicationClient::GDBRemoteCommunicationClient() m_supports_jThreadsInfo(true), m_supports_jModulesInfo(true), m_curr_pid(LLDB_INVALID_PROCESS_ID), m_curr_tid(LLDB_INVALID_THREAD_ID), m_curr_tid_run(LLDB_INVALID_THREAD_ID), - m_num_supported_hardware_watchpoints(0), m_host_arch(), m_process_arch(), - m_os_build(), m_os_kernel(), m_hostname(), m_gdb_server_name(), - m_gdb_server_version(UINT32_MAX), m_default_packet_timeout(0), - m_max_packet_size(0), m_qSupported_response(), - m_supported_async_json_packets_is_valid(false), + m_num_supported_hardware_watchpoints(0), m_addressing_bits(0), + m_host_arch(), m_process_arch(), m_os_build(), m_os_kernel(), + m_hostname(), m_gdb_server_name(), m_gdb_server_version(UINT32_MAX), + m_default_packet_timeout(0), m_max_packet_size(0), + m_qSupported_response(), m_supported_async_json_packets_is_valid(false), m_supported_async_json_packets_sp(), m_qXfer_memory_map(), m_qXfer_memory_map_loaded(false) {} @@ -1202,11 +1202,13 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) { } else if (name.equals("ptrsize")) { if (!value.getAsInteger(0, pointer_byte_size)) ++num_keys_decoded; + } else if (name.equals("addressing_bits")) { + if (!value.getAsInteger(0, m_addressing_bits)) + ++num_keys_decoded; } else if (name.equals("os_version") || - name.equals( - "version")) // Older debugserver binaries used the - // "version" key instead of - // "os_version"... + name.equals("version")) // Older debugserver binaries used + // the "version" key instead of + // "os_version"... { if (!m_os_version.tryParse(value)) ++num_keys_decoded; @@ -1357,6 +1359,11 @@ GDBRemoteCommunicationClient::GetHostArchitecture() { return m_host_arch; } +uint32_t GDBRemoteCommunicationClient::GetAddressingBits() { + if (m_qHostInfo_is_valid == eLazyBoolCalculate) + GetHostInfo(); + return m_addressing_bits; +} seconds GDBRemoteCommunicationClient::GetHostDefaultPacketTimeout() { if (m_qHostInfo_is_valid == eLazyBoolCalculate) GetHostInfo(); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index d559882ed7dc6..1891842a69444 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -275,6 +275,8 @@ class GDBRemoteCommunicationClient : public GDBRemoteClientBase { ArchSpec GetSystemArchitecture(); + uint32_t GetAddressingBits(); + bool GetHostname(std::string &s); lldb::addr_t GetShlibInfoAddr(); @@ -573,6 +575,7 @@ class GDBRemoteCommunicationClient : public GDBRemoteClientBase { // continue, step, etc uint32_t m_num_supported_hardware_watchpoints; + uint32_t m_addressing_bits; ArchSpec m_host_arch; ArchSpec m_process_arch; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 97368d5b0e31e..5ff00f8566990 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1042,6 +1042,12 @@ void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) { process_arch.GetTriple().getTriple()); } + if (int addresssable_bits = m_gdb_comm.GetAddressingBits()) { + lldb::addr_t address_mask = ~((1ULL << addresssable_bits) - 1); + SetCodeAddressMask(address_mask); + SetDataAddressMask(address_mask); + } + if (process_arch.IsValid()) { const ArchSpec &target_arch = GetTarget().GetArchitecture(); if (target_arch.IsValid()) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits