Skip to content

Commit 34dee9a

Browse files
committed
Only set the "low" address masks when only one adressable bits specified
qHostInfo / stop-reply packet / LC_NOTE "addrable bits" can all specify either a single value for all address masks, or separate masks for low and high memory addresses. When the same number of addressing bits are used for all addresses, we use the "low memory" address masks for everything. (or another way, if the high address masks are not set, we use the low address masks with the assumption that all memory is using the same mask -- the most common situation). I was setting low and high address masks when I had a single value from these metadata, but that gave the impression that the high address mask was specified explicitly. After living on the code a bit, it's clearly better to only set the high address masks when we have a distinct high address mask value. This patch is the minor adjustment to behave that way. (cherry picked from commit 10f494d)
1 parent 1992b24 commit 34dee9a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5561,9 +5561,7 @@ AddressableBits ObjectFileMachO::GetAddressableBits() {
55615561
if (m_data.GetU32(&offset, &version, 1) != nullptr) {
55625562
if (version == 3) {
55635563
uint32_t num_addr_bits = m_data.GetU32_unchecked(&offset);
5564-
if (num_addr_bits != 0) {
5565-
addressable_bits.SetAddressableBits(num_addr_bits);
5566-
}
5564+
addressable_bits.SetAddressableBits(num_addr_bits);
55675565
LLDB_LOGF(log,
55685566
"LC_NOTE 'addrable bits' v3 found, value %d "
55695567
"bits",
@@ -5574,7 +5572,10 @@ AddressableBits ObjectFileMachO::GetAddressableBits() {
55745572
uint32_t lo_addr_bits = m_data.GetU32_unchecked(&offset);
55755573
uint32_t hi_addr_bits = m_data.GetU32_unchecked(&offset);
55765574

5577-
addressable_bits.SetAddressableBits(lo_addr_bits, hi_addr_bits);
5575+
if (lo_addr_bits == hi_addr_bits)
5576+
addressable_bits.SetAddressableBits(lo_addr_bits);
5577+
else
5578+
addressable_bits.SetAddressableBits(lo_addr_bits, hi_addr_bits);
55785579
LLDB_LOGF(log,
55795580
"LC_NOTE 'addrable bits' v4 found, value %d & %d bits",
55805581
lo_addr_bits, hi_addr_bits);

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,6 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) {
12611261
++num_keys_decoded;
12621262
} else if (name.equals("addressing_bits")) {
12631263
if (!value.getAsInteger(0, m_low_mem_addressing_bits)) {
1264-
m_high_mem_addressing_bits = m_low_mem_addressing_bits;
12651264
++num_keys_decoded;
12661265
}
12671266
} else if (name.equals("high_mem_addressing_bits")) {
@@ -1417,11 +1416,11 @@ AddressableBits GDBRemoteCommunicationClient::GetAddressableBits() {
14171416
if (m_qHostInfo_is_valid == eLazyBoolCalculate)
14181417
GetHostInfo();
14191418

1420-
// m_low_mem_addressing_bits and m_high_mem_addressing_bits
1421-
// will be 0 if we did not receive values; AddressableBits
1422-
// treats 0 as "unspecified".
1423-
addressable_bits.SetAddressableBits(m_low_mem_addressing_bits,
1424-
m_high_mem_addressing_bits);
1419+
if (m_low_mem_addressing_bits == m_high_mem_addressing_bits)
1420+
addressable_bits.SetAddressableBits(m_low_mem_addressing_bits);
1421+
else
1422+
addressable_bits.SetAddressableBits(m_low_mem_addressing_bits,
1423+
m_high_mem_addressing_bits);
14251424
return addressable_bits;
14261425
}
14271426

0 commit comments

Comments
 (0)