From b6f9d7b8fb2eb6b78ac93ebd5ea4e36c04469285 Mon Sep 17 00:00:00 2001 From: Muhammad Omair Javaid Date: Fri, 6 Dec 2019 22:12:39 +0500 Subject: Cleanup and speedup NativeRegisterContextLinux_arm64 Summary: This patch simplifies register accesses in NativeRegisterContextLinux_arm64 and also adds some bare minimum caching to avoid multiple calls to ptrace during a stop. Linux ptrace returns data in the form of structures containing GPR/FPR data. This means that one single call is enough to read all GPRs or FPRs. We do that once per stop and keep reading from or writing to the buffer that we have in NativeRegisterContextLinux_arm64 class. Before a resume or detach we write all buffers back. This is tested on aarch64 thunder x1 with Ubuntu 18.04. Also tested regressions on x86_64. Reviewers: labath, clayborg Reviewed By: labath Subscribers: kristof.beyls, lldb-commits Differential Revision: https://reviews.llvm.org/D69371 --- lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp') diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index 677aee34a184..b2730e601294 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -241,6 +241,9 @@ Status NativeThreadLinux::Resume(uint32_t signo) { if (signo != LLDB_INVALID_SIGNAL_NUMBER) data = signo; + // Before thread resumes, clear any cached register data structures + GetRegisterContext().InvalidateAllRegisters(); + return NativeProcessLinux::PtraceWrapper(PTRACE_CONT, GetID(), nullptr, reinterpret_cast(data)); } @@ -262,6 +265,9 @@ Status NativeThreadLinux::SingleStep(uint32_t signo) { if (signo != LLDB_INVALID_SIGNAL_NUMBER) data = signo; + // Before thread resumes, clear any cached register data structures + GetRegisterContext().InvalidateAllRegisters(); + // If hardware single-stepping is not supported, we just do a continue. The // breakpoint on the next instruction has been setup in // NativeProcessLinux::Resume. -- cgit v1.2.3