@@ -23,28 +23,57 @@ void AddressableBits::SetAddressableBits(uint32_t lowmem_addressing_bits,
2323 m_high_memory_addr_bits = highmem_addressing_bits;
2424}
2525
26- void AddressableBits::Clear () {
27- m_low_memory_addr_bits = m_high_memory_addr_bits = 0 ;
26+ void AddressableBits::SetLowmemAddressableBits (
27+ uint32_t lowmem_addressing_bits) {
28+ m_low_memory_addr_bits = lowmem_addressing_bits;
29+ }
30+
31+ void AddressableBits::SetHighmemAddressableBits (
32+ uint32_t highmem_addressing_bits) {
33+ m_high_memory_addr_bits = highmem_addressing_bits;
2834}
2935
3036void AddressableBits::SetProcessMasks (Process &process) {
31- // In case either value is set to 0, indicating it was not set, use the
32- // other value.
33- if (m_low_memory_addr_bits == 0 )
34- m_low_memory_addr_bits = m_high_memory_addr_bits;
35- if (m_high_memory_addr_bits == 0 )
36- m_high_memory_addr_bits = m_low_memory_addr_bits;
37-
38- if (m_low_memory_addr_bits == 0 )
37+ if (m_low_memory_addr_bits == 0 && m_high_memory_addr_bits == 0 )
3938 return ;
4039
41- addr_t address_mask = ~((1ULL << m_low_memory_addr_bits) - 1 );
42- process.SetCodeAddressMask (address_mask);
43- process.SetDataAddressMask (address_mask);
40+ // If we don't have an addressable bits value for low memory,
41+ // see if we have a Code/Data mask already, and use that.
42+ // Or use the high memory addressable bits value as a last
43+ // resort.
44+ addr_t low_addr_mask;
45+ if (m_low_memory_addr_bits == 0 ) {
46+ if (process.GetCodeAddressMask () != UINT64_MAX)
47+ low_addr_mask = process.GetCodeAddressMask ();
48+ else if (process.GetDataAddressMask () != UINT64_MAX)
49+ low_addr_mask = process.GetDataAddressMask ();
50+ else
51+ low_addr_mask = ~((1ULL << m_high_memory_addr_bits) - 1 );
52+ } else {
53+ low_addr_mask = ~((1ULL << m_low_memory_addr_bits) - 1 );
54+ }
55+
56+ // If we don't have an addressable bits value for high memory,
57+ // see if we have a Code/Data mask already, and use that.
58+ // Or use the low memory addressable bits value as a last
59+ // resort.
60+ addr_t hi_addr_mask;
61+ if (m_high_memory_addr_bits == 0 ) {
62+ if (process.GetHighmemCodeAddressMask () != UINT64_MAX)
63+ hi_addr_mask = process.GetHighmemCodeAddressMask ();
64+ else if (process.GetHighmemDataAddressMask () != UINT64_MAX)
65+ hi_addr_mask = process.GetHighmemDataAddressMask ();
66+ else
67+ hi_addr_mask = ~((1ULL << m_low_memory_addr_bits) - 1 );
68+ } else {
69+ hi_addr_mask = ~((1ULL << m_high_memory_addr_bits) - 1 );
70+ }
71+
72+ process.SetCodeAddressMask (low_addr_mask);
73+ process.SetDataAddressMask (low_addr_mask);
4474
45- if (m_low_memory_addr_bits != m_high_memory_addr_bits) {
46- lldb::addr_t hi_address_mask = ~((1ULL << m_high_memory_addr_bits) - 1 );
47- process.SetHighmemCodeAddressMask (hi_address_mask);
48- process.SetHighmemDataAddressMask (hi_address_mask);
75+ if (low_addr_mask != hi_addr_mask) {
76+ process.SetHighmemCodeAddressMask (hi_addr_mask);
77+ process.SetHighmemDataAddressMask (hi_addr_mask);
4978 }
5079}
0 commit comments