Skip to content

Commit d402645

Browse files
authored
[LLDB] On AArch64, reconfigure register context first (llvm#70742)
On an SVE/SME the register context configuration may change after the inferior process has executed. This was handled via https://reviews.llvm.org/D159504 but it is reconfiguring and clearing the register context after we've parsed any expedited reigster values from the stop reply packet. That results in lldb having to read each register value one at a time while at that stop location, which will be a performance problem on non-local debug setups. The configuration & clearing needs to happen first. Also, update the names of the local variables for a little clarity.
1 parent d4a885f commit d402645

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,9 +1642,22 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
16421642
}
16431643

16441644
ThreadGDBRemote *gdb_thread = static_cast<ThreadGDBRemote *>(thread_sp.get());
1645-
RegisterContextSP gdb_reg_ctx_sp(gdb_thread->GetRegisterContext());
1645+
RegisterContextSP reg_ctx_sp(gdb_thread->GetRegisterContext());
16461646

1647-
gdb_reg_ctx_sp->InvalidateIfNeeded(true);
1647+
reg_ctx_sp->InvalidateIfNeeded(true);
1648+
1649+
// AArch64 SVE/SME specific code below updates SVE and ZA register sizes and
1650+
// offsets if value of VG or SVG registers has changed since last stop.
1651+
const ArchSpec &arch = GetTarget().GetArchitecture();
1652+
if (arch.IsValid() && arch.GetTriple().isAArch64()) {
1653+
GDBRemoteRegisterContext *gdb_remote_reg_ctx =
1654+
static_cast<GDBRemoteRegisterContext *>(reg_ctx_sp.get());
1655+
1656+
if (gdb_remote_reg_ctx) {
1657+
gdb_remote_reg_ctx->AArch64Reconfigure();
1658+
gdb_remote_reg_ctx->InvalidateAllRegisters();
1659+
}
1660+
}
16481661

16491662
auto iter = std::find(m_thread_ids.begin(), m_thread_ids.end(), tid);
16501663
if (iter != m_thread_ids.end())
@@ -1655,25 +1668,10 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
16551668
WritableDataBufferSP buffer_sp(
16561669
new DataBufferHeap(reg_value_extractor.GetStringRef().size() / 2, 0));
16571670
reg_value_extractor.GetHexBytes(buffer_sp->GetData(), '\xcc');
1658-
uint32_t lldb_regnum = gdb_reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
1671+
uint32_t lldb_regnum = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
16591672
eRegisterKindProcessPlugin, pair.first);
16601673
gdb_thread->PrivateSetRegisterValue(lldb_regnum, buffer_sp->GetData());
16611674
}
1662-
1663-
// AArch64 SVE/SME specific code below updates SVE and ZA register sizes and
1664-
// offsets if value of VG or SVG registers has changed since last stop.
1665-
const ArchSpec &arch = GetTarget().GetArchitecture();
1666-
if (arch.IsValid() && arch.GetTriple().isAArch64()) {
1667-
GDBRemoteRegisterContext *reg_ctx_sp =
1668-
static_cast<GDBRemoteRegisterContext *>(
1669-
gdb_thread->GetRegisterContext().get());
1670-
1671-
if (reg_ctx_sp) {
1672-
reg_ctx_sp->AArch64Reconfigure();
1673-
reg_ctx_sp->InvalidateAllRegisters();
1674-
}
1675-
}
1676-
16771675
thread_sp->SetName(thread_name.empty() ? nullptr : thread_name.c_str());
16781676

16791677
gdb_thread->SetThreadDispatchQAddr(thread_dispatch_qaddr);

0 commit comments

Comments
 (0)