[all-commits] [llvm/llvm-project] e28157: [lldb][AArch64][Linux] Add field information for t...

David Spickett via All-commits all-commits at lists.llvm.org
Wed Nov 8 02:17:51 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e28157e778423fd9d39c9065ef06e841fc320f09
      https://github.com/llvm/llvm-project/commit/e28157e778423fd9d39c9065ef06e841fc320f09
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2023-11-08 (Wed, 08 Nov 2023)

  Changed paths:
    M lldb/include/lldb/Target/RegisterFlags.h
    M lldb/include/lldb/lldb-private-types.h
    M lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
    M lldb/source/Plugins/Process/Utility/CMakeLists.txt
    A lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.cpp
    A lldb/source/Plugins/Process/Utility/RegisterFlagsLinux_arm64.h
    M lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
    M lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
    M lldb/source/Target/RegisterFlags.cpp
    M lldb/test/API/commands/register/register/register_command/TestRegisters.py
    M lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py

  Log Message:
  -----------
  [lldb][AArch64][Linux] Add field information for the CPSR register (#70300)

The contents of which are mostly SPSR_EL1 as shown in the Arm manual,
with a few adjustments for things Linux says userspace shouldn't concern
itself with.

```
(lldb) register read cpsr
    cpsr = 0x80001000
         = (N = 1, Z = 0, C = 0, V = 0, SS = 0, IL = 0, ...
```

Some fields are always present, some depend on extensions. I've checked
for those extensions using HWCAP and HWCAP2.

To provide this for core files and live processes I've added a new class
LinuxArm64RegisterFlags. This is a container for all the registers we'll
want to have fields and handles detecting fields and updating register
info.

This is used by the native process as follows:
* There is a global LinuxArm64RegisterFlags object.
* The first thread takes a mutex on it, and updates the fields.
* Subsequent threads see that detection is already done, and skip it.
* All threads then update their own copy of the register information
with pointers to the field information contained in the global object.

This means that even though every thread will have the same fields, we
only detect them once and have one copy of the information.

Core files instead have a LinuxArm64RegisterFlags as a member, because
each core file could have different saved capabilities. The logic from
there is the same but we get HWACP values from the corefile note.

This handler class is Linux specific right now, but it can easily be
made more generic if needed. For example by using LLVM's FeatureBitset
instead of HWCAPs.

Updating register info is done with string comparison, which isn't
ideal. For CPSR, we do know the register number ahead of time but we do
not for other registers in dynamic register sets. So in the interest of
consistency, I'm going to use string comparison for all registers
including cpsr.

I've added tests with a core file and live process. Only checking for
fields that are always present to account for CPU variance.




More information about the All-commits mailing list