Skip to content

Commit 4fac08f

Browse files
committed
Recognize addressing_bits kv in stop reply packet
If a remote stub provides the addressing_bits kv pair in the stop reply packet, update the Process address masks with that value as it possibly changes during the process runtime. This is an unusual situation, most likely a JTAG remote stub and some very early startup code that is setting up the page tables. Nearly all debug sessions will have a single address mask that cannot change during the lifetime of a Process. Differential Revision: https://reviews.llvm.org/D149803 rdar://61900565
1 parent 09ceb47 commit 4fac08f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lldb/docs/lldb-gdb-remote.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,24 @@ for this region.
16361636
// Example:
16371637
// thread-pcs:dec14,2cf872b0,2cf8681c,2d02d68c,2cf716a8;
16381638
//
1639+
// "addressing_bits" unsigned optional Specifies how many bits in addresses
1640+
// are significant for addressing, base
1641+
// 10. If bits 38..0 in a 64-bit
1642+
// pointer are significant for
1643+
// addressing, then the value is 39.
1644+
// This is needed on e.g. AArch64
1645+
// v8.3 ABIs that use pointer
1646+
// authentication in the high bits.
1647+
// This value is normally sent in the
1648+
// qHostInfo packet response, and if the
1649+
// value cannot change during the process
1650+
// lifetime, it does not need to be
1651+
// duplicated here in the stop packet.
1652+
// For a firmware environment with early
1653+
// start code that may be changing the
1654+
// page table setup, a dynamically set
1655+
// value may be needed.
1656+
//
16391657
// BEST PRACTICES:
16401658
// Since register values can be supplied with this packet, it is often useful
16411659
// to return the PC, SP, FP, LR (if any), and FLAGS registers so that separate

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,13 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
22572257
StreamString ostr;
22582258
ostr.Printf("%" PRIu64 " %" PRIu64, pid_tid->first, pid_tid->second);
22592259
description = std::string(ostr.GetString());
2260+
} else if (key.compare("addressing_bits") == 0) {
2261+
uint64_t addressing_bits;
2262+
if (!value.getAsInteger(0, addressing_bits)) {
2263+
addr_t address_mask = ~((1ULL << addressing_bits) - 1);
2264+
SetCodeAddressMask(address_mask);
2265+
SetDataAddressMask(address_mask);
2266+
}
22602267
} else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) {
22612268
uint32_t reg = UINT32_MAX;
22622269
if (!key.getAsInteger(16, reg))

0 commit comments

Comments
 (0)