summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
AgeCommit message (Collapse)Author
2025-07-29[lldb][AArch64] Fix arm64 hardware breakpoint/watchpoint to arm32 process. ↵b10902118
(#147198) When debugging arm32 process on arm64 machine, arm64 lldb-server will use `NativeRegisterContextLinux_arm`, but the server should keep using 64-bit ptrace commands for hardware watchpoint/breakpoint, even when debugging a 32-bit tracee. See: https://github.com/torvalds/linux/commit/5d220ff9420f8b1689805ba2d938bedf9e0860a4 There have been many conditional compilation handling arm32 tracee on arm64, but this one is missed out. To reuse the 64-bit implementation, I separate the shared code from `NativeRegisterContextLinux_arm64.cpp` to `NativeRegisterContextLinux_arm64dbreg.cpp`, with other adjustments to share data structures of debug registers.
2025-07-28[lldb][AArch64] Add HWCAP3 to register field detection (#145029)David Spickett
This will be used to detect the presence of Arm's new Memory Tagging store only checking feature. This commit just adds the plumbing to get that value into the detection function. FreeBSD has not allocated a number for HWCAP3 and already has AT_ARGV defined as 29. So instead of attempting to read from FreeBSD processes, I've explicitly passed 0. We don't want to be reading some other entry accidentally. If/when FreeBSD adds HWCAP3 we can handle it like we do for AUXV_FREEBSD_AT_HWCAP. No extra tests here, those will be coming with the next change for MTE support.
2025-01-27[lldb][AArch64] Fix expression evaluation with Guarded Control Stacks (#123918)David Spickett
When the Guarded Control Stack (GCS) is enabled, returns cause the processor to validate that the address at the location pointed to by gcspr_el0 matches the one in the link register. ``` ret (lr=A) << pc | GCS | +=====+ | A | | B | << gcspr_el0 Fault: tried to return to A when you should have returned to B. ``` Therefore when an expression wrapper function tries to return to the expression return address (usually `_start` if there is a libc), it would fault. ``` ret (lr=_start) << pc | GCS | +============+ | user_func1 | | user_func2 | << gcspr_el0 Fault: tried to return to _start when you should have returned to user_func2. ``` To fix this we must push that return address to the GCS in PrepareTrivialCall. This value is then consumed by the final return and the expression completes as expected. If for some reason that fails, we will manually restore the value of gcspr_el0, because it turns out that PrepareTrivialCall does not restore registers if it fails at all. So for now I am handling gcspr_el0 specifically, but I have filed https://github.com/llvm/llvm-project/issues/124269 to address the general problem. (the other things PrepareTrivialCall does are exceedingly likely to not fail, so we have never noticed this) ``` ret (lr=_start) << pc | GCS | +============+ | user_func1 | | user_func2 | | _start | << gcspr_el0 No fault, we return to _start as normal. ``` The gcspr_el0 register will be restored after expression evaluation so that the program can continue correctly. However, due to restrictions in the Linux GCS ABI, we will not restore the enable bit of gcs_features_enabled. Re-enabling GCS via ptrace is not supported because it requires memory to be allocated by the kernel. We could disable GCS if the expression enabled GCS, however this would use up that state transition that the program might later rely on. And generally it is cleaner to ignore the enable bit, rather than one state transition of it. We will also not restore the GCS entry that was overwritten with the expression's return address. On the grounds that: * This entry will never be used by the program. If the program branches, the entry will be overwritten. If the program returns, gcspr_el0 will point to the entry before the expression return address and that entry will instead be validated. * Any expression that calls functions will overwrite even more entries, so the user needs to be aware of that anyway if they want to preserve the contents of the GCS for inspection. * An expression could leave the program in a state where restoring the value makes the situation worse. Especially if we ever support this in bare metal debugging. I will later document all this on https://lldb.llvm.org/use/aarch64-linux.html. Tests have been added for: * A function call that does not interact with GCS. * A call that does, and disables it (we do not re-enable it). * A call that does, and enables it (we do not disable it again). * Failure to push an entry to the GCS stack.
2025-01-24[lldb][AArch64] Add Guarded Control Stack registers (#123720)David Spickett
The Guarded Control Stack extension implements a shadow stack and the Linux kernel provides access to 3 registers for it via ptrace. struct user_gcs { __u64 features_enabled; __u64 features_locked; __u64 gcspr_el0; }; This commit adds support for reading those from a live process. The first 2 are pseudo registers based on the real control register and the 3rd is a real register. This is the stack pointer for the guarded stack. I have added a "gcs_" prefix to the "features" registers so that they have a clear name when shown individually. Also this means they will tab complete from "gcs", and be next to gcspr_el0 in any sorted lists of registers. Guarded Control Stack Registers: gcs_features_enabled = 0x0000000000000000 gcs_features_locked = 0x0000000000000000 gcspr_el0 = 0x0000000000000000 Testing is more of the usual, where possible I'm writing a register then doing something in the program to confirm the value was actually sent to ptrace.
2024-09-25[lldb][AArch64][Linux] Add Floating Point Mode Register (#106695)David Spickett
Otherwise known as FEAT_FPMR. This register controls the behaviour of floating point operations. https://developer.arm.com/documentation/ddi0601/2024-06/AArch64-Registers/FPMR--Floating-point-Mode-Register As the current floating point register contexts are fixed size, this has been placed in a new set. Linux kernel patches have landed already, so you can cross check with those. To simplify testing we're not going to do any floating point operations, just read and write from the program and debugger to make sure each sees the other's values correctly.
2024-08-27[lldb] Turn lldb_private::Status into a value type. (#106163)Adrian Prantl
This patch removes all of the Set.* methods from Status. This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor. This patch is largely NFC, the more interesting next steps this enables is to: 1. remove Status.Clear() 2. assert that Status::operator=() never overwrites an error 3. remove Status::operator=() Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form ` ResultTy DoFoo(Status& error) ` to ` llvm::Expected<ResultTy> DoFoo() ` How to read this patch? The interesting changes are in Status.h and Status.cpp, all other changes are mostly ` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source) ` plus the occasional manual cleanup.
2024-07-01[lldb][FreeBSD][AArch64] Enable register field detection (#85058)David Spickett
This extends the existing register fields support from AArch64 Linux to AArch64 FreeBSD. So you will now see output like this: ``` (lldb) register read cpsr cpsr = 0x60000200 = (N = 0, Z = 1, C = 1, V = 0, DIT = 0, SS = 0, IL = 0, SSBS = 0, D = 1, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0) ``` Linux and FreeBSD both have HWCAP/HWCAP2 so the detection mechanism is the same and I've renamed the detector class to reflect that. I have confirmed that FreeBSD's treatment of CPSR (spsr as the kernel calls it) is similair enough that we can use the same field information. (see `sys/arm64/include/armreg.h` and `PSR_SETTABLE_64`) For testing I've enabled the same live process test as Linux and added a shell test using an existing FreeBSD core file. Note that the latter does not need XML support because when reading a core file we are not sending the information via target.xml, it's just internal to LLDB.
2024-06-13[llvm-project] Fix typo "seperate" (#95373)Jay Foad
2023-11-08[lldb][AArch64][Linux] Add field information for the CPSR register (#70300)David Spickett
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.
2023-11-01[lldb][AArch64] Add SME2's ZT0 register (#70205)David Spickett
SME2 is documented as part of the main SME supplement: https://developer.arm.com/documentation/ddi0616/latest/ The one change for debug is this new ZT0 register. This register contains data to be used with new table lookup instructions. It's size is always 512 bits (not scalable) and can be interpreted in many different ways depending on the instructions that use it. The kernel has implemented this as a new register set containing this single register. It always returns register data (with no header, unlike ZA which does have a header). https://docs.kernel.org/arch/arm64/sme.html ZT0 is only active when ZA is active (when SVCR.ZA is 1). In the inactive state the kernel returns 0s for its contents. Therefore lldb doesn't need to create 0s like it does for ZA. However, we will skip restoring the value of ZT0 if we know that ZA is inactive. As writing to an inactive ZT0 sets SVCR.ZA to 1, which is not desireable as it would activate ZA also. Whether SVCR.ZA is set will be determined only by the ZA data we restore. Due to this, I've added a new save/restore kind SME2. This is easier than accounting for the variable length ZA in the SME data. We'll only save an SME2 data block if ZA is active. If it's not we can get fresh 0s back from the kernel for ZT0 anyway so there's nothing for us to restore. This new register will only show up if the system has SME2 therefore the SME set presented to the user may change, and I've had to account for that in in a few places. I've referred to it internally as simply "ZT" as the kernel does in NT_ARM_ZT, but the architecture refers to the specific register as "ZT0" so that's what you'll see in lldb. ``` (lldb) register read -s 6 Scalable Matrix Extension Registers: svcr = 0x0000000000000000 svg = 0x0000000000000004 za = {0x00 <...> 0x00} zt0 = {0x00 <...> 0x00} ```
2023-10-30[lldb][AArch64][Linux] Rename Is<ext>Enabled to Is<ext>Present (#70303)David Spickett
For most register sets, if it was enabled this meant you could use it, it was present in the process. There was no present but turned off state. So "enabled" made sense. Then ZA came along (and soon to be ZT0) where ZA can be present in the hardware when you have SME, but ZA itself can be made inactive. This means that "IsZAEnabled()" doesn't mean is it active, it means do you have SME. Which is very confusing when we actually want to know if ZA is active. So instead say "IsZAPresent", to make these checks more specific. For things that can't be made inactive, present will imply "active" as they're never inactive.
2023-09-20[lldb][AArch64] Add SME's streaming vector control registerDavid Spickett
Software can tell if it is in streaming SVE mode by checking the Streaming Vector Control Register (SVCR). "E3.1.9 SVCR, Streaming Vector Control Register" in "Arm® Architecture Reference Manual Supplement, The Scalable Matrix Extension (SME), for Armv9-A" https://developer.arm.com/documentation/ddi0616/latest/ This is especially useful for debug because the names of the SVE registers are the same betweeen non-streaming and streaming mode. The Linux Kernel chose to not put this register behind ptrace, and it can be read from EL0. However, this would mean running code in process to read it. That can be done but we already know all the information just from ptrace. So this is a pseudo register that matches the architectural content. The name is just "svcr", which aligns with GDB's proposed naming, and it's added to the existing SME register set. The SVCR register contains two bits: 0 : Whether streaming SVE mode is enabled (SM) 1 : Whether the array storage is enabled (ZA) Array storage can be active when streaming mode is not, so this register can have any permutation of those bits. This register is currently read only. We can emulate the result of writing to it, using ptrace. However at this point the utility of that is not obvious. Existing tests have been updated to check for appropriate SVCR values at various points. Given that this register is a read only pseudo, there is no need to save and restore it around expressions. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D154927
2023-09-19[lldb][AArch64] Add SME streaming vector length pseduo registerDavid Spickett
This adds a register "svg" which mirrors SVE's "vg" register. This reports the streaming vector length at all times, read from the ZA ptrace header. This register is needed first to implement ZA resizing as the streaming vector length changes. Like vg, svg will be expedited to the client so it can reconfigure its register definitions. The other use is for users to be able to know the streaming vector length without resorting to counting the (many, many) bytes in ZA, or temporarily entering streaming mode (which would be destructive). Some refactoring has been done so we don't have to recalculate the register offsets twice. Testing for this will come in a later patch. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D159503
2023-09-19[lldb][AArch64] Add SME's Array Storage (ZA) registerDavid Spickett
Note: This requires later commits for ZA to function properly, it is split for ease of review. Testing is also in a later patch. The "Matrix" part of the Scalable Matrix Extension is a new register "ZA". You can think of this as a square matrix made up of scalable rows, where each row is one scalable vector long. However it is not made of the existing scalable vector registers, it is its own register. Meaning that the size of ZA is the vector length in bytes * the vector length in bytes. https://developer.arm.com/documentation/ddi0616/latest/ It uses the streaming vector length, even when streaming mode itself is not active. For this reason, it's register data header always includes the streaming vector length. Due to it's size I've changed kMaxRegisterByteSize to the maximum possible ZA size and kTypicalRegisterByteSize will be the maximum possible scalable vector size. Therefore ZA transactions will cause heap allocations, and non ZA registers will perform exactly as before. ZA can be enabled and disabled independently of streaming mode. The way this works in ptrace is different to SVE versus streaming SVE. Writing NT_ARM_ZA without register data disables ZA, writing NT_ARM_ZA with register data enables ZA (LLDB will only support the latter, and only because it's convenient for us to do so). https://kernel.org/doc/html/v6.2/arm64/sme.html LLDB does not handle registers that can appear and dissappear at runtime. Rather than add complexity to implement that, LLDB will show a block of 0s when ZA is disabled. The alternative is not only updating the vector lengths every stop, but every register definition. It's possible but I'm not sure it's worth pursuing. Users should refer to the SVCR register (added in later patches) for the final word on whether ZA is active or not. Writing to "VG" during streaming mode will change the size of the streaming sve registers and ZA. LLDB will not attempt to preserve register values in this case, we'll just read back the undefined content the kernel shows. This is in line with, as stated, the kernel ABIs and the prospective software ABIs look like. ZA is defined as a vector of size SVL*SVL, so the display in lldb is very basic. A giant block of values. This is no worse than SVE, just larger. There is scope to improve this but that can wait until we see some use cases. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D159502
2023-09-11[lldb][AArch64] Add type marker to ReadAll/WriteALLRegisterValues dataDavid Spickett
While working in support for SME's ZA register, I found a circumstance where restoring ZA after SVE, when the current SVE mode is non-streaming, will kick the process back into FPSIMD mode. Meaning the SVE values that you just wrote are now cut off at 128 bit. The fix for that is to write ZA then SVE. Problem with that is, the current ReadAll/WriteAll makes a lot of assumptions about the saved data length. This patch changes the format so there is a "type" written before each data block. This tells WriteAllRegisterValues what it's looking at without brittle checks on length, or assumptions about ordering. If we want to change the order of restoration, all we now have to do is change the order of saving. This exposes a bug where the TLS registers are not restored. This will be fixed by https://reviews.llvm.org/D156512 in some form, depending on what lands first. Existing SVE tests certainly check restoration and when I got this wrong, many, many tests failed. So I think we have enough coverage already, and more will be coming with future ZA changes. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D156687
2023-08-03[lldb][AArch64] Save/restore TLS registers around expressionsDavid Spickett
Previously lldb was storing them but not restoring them. Meaning that this function: ``` void expr(uint64_t value) { __asm__ volatile("msr tpidr_el0, %0" ::"r"(value)); } ``` When run from lldb: ``` (lldb) expression expr() ``` Would leave tpidr as `value` instead of the original value of the register. A check for this scenario has been added to TestAArch64LinuxTLSRegisters.py, which covers tpidr and the SME excluisve tpidr2 register when it's present. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D156512
2023-07-26[lldb][AArch64] Add the tpidr2 TLS register that comes with SMEDavid Spickett
This changes the TLS regset to not only be dynamic in that it could exist or not (though it always does) but also of a dynamic size. If SME is present then the regset is 16 bytes and contains both tpidr and tpidr2. Testing is the same as tpidr. Write from assembly, read from lldb and vice versa since we have no way to predict what its value should be by just running a program. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D154930
2023-07-26[lldb][AArch64] Add support for SME's SVE streaming mode registersDavid Spickett
The Scalable Matrix Extension (SME) adds a new Scalable Vector mode called "streaming SVE mode". In this mode a lot of things change, but my understanding overall is that this mode assumes you are not going to move data out of the vector unit very often or read flags. Based on "E1.3" of "Arm® Architecture Reference Manual Supplement, The Scalable Matrix Extension (SME), for Armv9-A". https://developer.arm.com/documentation/ddi0616/latest/ The important details for debug are that this adds another set of SVE registers. This set is only active when we are in streaming mode and is read from a new ptrace regset NT_ARM_SSVE. We are able to read the header of either mode at all times but only one will be active and contain register data. For this reason, I have reused the existing SVE state. Streaming mode is just another mode value attached to that state. The streaming mode registers do not have different names in the architecture, so I do not plan to allow users to read or write the inactive mode's registers. "z0" will always mean "z0" of the active mode. Ptrace does allow reading inactive modes, but the data is of little use. Writing to inactive modes will switch to that mode which would not be what a debugger user would expect. So lldb will do neither. Existing SVE tests have been updated to check streaming mode and mode switches. However, we are limited in what we can check given that state for the other mode is invalidated on mode switch. The only way to know what mode you are in for testing purposes would be to execute a streaming only, or non-streaming only instruction in the opposite mode. However, the CPU feature smefa64 actually allows all non-streaming mode instructions in streaming mode. This is enabled by default in QEMU emulation and rather than mess about trying to disable it I'm just going to use the pseduo streaming control register added in a later patch to make these tests more robust. A new test has been added to check SIMD read/write from all the modes as there is a subtlety there that needs noting, though lldb doesn't have to make extra effort to do so. If you are in streaming mode and write to v0, when you later exit streaming mode that value may not be in the non-streaming state. This can depend on how the core works but is a valid behaviour. For example, say I am stopped here: mov x0, v0.d[0] And I want to update v0 in lldb. "register write v0 ..." should update the v0 that this instruction is about to see. Not the potential other copy of v0 in the non-streaming state (which is what I attempted in earlier versions of this patch). Not to mention, switching out of streaming mode here would be unexpected and difficult to signal to the user. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D154926
2023-06-19[lldb][AArch64] Add thread local storage tpidr registerDavid Spickett
This register is used as the pointer to the current thread local storage block and is read from NT_ARM_TLS on Linux. Though tpidr will be present on all AArch64 Linux, I am soon going to add a second register tpidr2 to this set. tpidr is only present when SME is implemented, therefore the NT_ARM_TLS set will change size. This is why I've added this as a dynamic register set to save changes later. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D152516
2023-04-27lldb: Fix usage of sve functions on arm64Manoj Gupta
Use correct internal sve functions for arm64. Otherwise, when cross-compling lld for AArch64 there are build errors like: NativeRegisterContextLinux_arm64.cpp:936:11: error: use of undeclared identifier 'sve_vl_valid NativeRegisterContextLinux_arm64.cpp:63:28: error: variable has incomplete type 'struct user_sve_header' Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D148752
2023-01-07[lldb] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-07[lldb] Add #include <optional> (NFC)Kazu Hirata
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-10-12[LLDB] Change RegisterValue::SetFromMemoryData to const RegisterInfo&David Spickett
All callers were either assuming their pointer was not null before calling this, or checking beforehand. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D135668
2022-08-03[lldb] Fix TestDeletedExecutable on linuxPavel Labath
Currently, lldb-server was opening the executable file to determine the process architecture (to differentiate between 32 and 64 bit architecture flavours). This isn't a particularly trustworthy source of information (the file could have been changed since the process was started) and it is not always available (file could be deleted or otherwise inaccessible). Unfortunately, ptrace does not give us a direct API to access the process architecture, but we can still infer it via some of its responses -- given that the general purpose register set of 64-bit applications is larger [citation needed] than the GPR set of 32-bit ones, we can just ask for the application GPR set and check its size. This is what this patch does. Differential Revision: https://reviews.llvm.org/D130985
2022-07-25[lldb][ARM/AArch64] Use sys/uio.h instead of socket.h in native register contextDavid Spickett
We only want iovec and uio.h is just that without a lot of other stuff. Saves me wondering why this code might want to open sockets. https://pubs.opengroup.org/onlinepubs/007904975/basedefs/sys/uio.h.html
2022-04-05[lldb] Add missing const to NativeRegisterContextLinux_armBenjamin Kramer
2022-04-05[lldb] Update the NativeRegisterContext to take a WritableMemoryBufferJonas Devlieghere
2021-09-09AArch64 SVE restore SVE registers after expressionMuhammad Omair Javaid
This patch fixes register save/restore on expression call to also include SVE registers. This will fix expression calls like: re re p1 <Register Value P1 before expression> p <var-name or function call> re re p1 <Register Value P1 after expression> In above example register P1 should remain the same before and after the expression evaluation. Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D108739
2021-08-25[LLDB] Remove typos from NativeRegisterContextLinux_arm*Muhammad Omair Javaid
This patch removed some typos from NativeRegisterContextLinux_arm and NativeRegisterContextLinux_arm64. Some of the log/error messages were being reported as x86_64.
2021-07-12Support AArch64/Linux watchpoint on tagged addressesMuhammad Omair Javaid
AArch64 architecture support virtual addresses with some of the top bits ignored. These ignored bits can host memory tags or bit masks that can serve to check for authentication of address integrity. We need to clear away the top ignored bits from watchpoint address to reliably hit and set watchpoints on addresses containing tags or masks in their top bits. This patch adds support to watch tagged addresses on AArch64/Linux. Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D101361
2021-06-30[lldb] Replace SVE_PT* macros in NativeRegisterContextLinux_arm64.{cpp,h} ↵Caroline Tice
with their equivalent defintions in LinuxPTraceDefines_arm64sve.h Commit 090306fc80dbf (August 2020) changed most of the arm64 SVE_PT* macros, but apparently did not make the changes in the NativeRegisterContextLinux_arm64.* files (or those files were pulled over from someplace else after that commit). This change replaces the macros NativeRegisterContextLinux_arm64.cpp with the replacement definitions in LinuxPTraceDefines_arm64sve.h. It also includes LinuxPTraceDefines_arm64sve.h in NativeRegisterContextLinux_arm64.h. Differential Revision: https://reviews.llvm.org/D104826
2021-06-24[lldb][AArch64] Add memory tag reading to lldb-serverDavid Spickett
This adds memory tag reading using the new "qMemTags" packet and ptrace on AArch64 Linux. This new packet is following the one used by GDB. (https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html) On AArch64 Linux we use ptrace's PEEKMTETAGS to read tags and we assume that lldb has already checked that the memory region actually has tagging enabled. We do not assume that lldb has expanded the requested range to granules and expand it again to be sure. (although lldb will be sending aligned ranges because it happens to need them client side anyway) Also we don't assume untagged addresses. So for AArch64 we'll remove the top byte before using them. (the top byte includes MTE and other non address data) To do the ptrace read NativeProcessLinux will ask the native register context for a memory tag manager based on the type in the packet. This also gives you the ptrace numbers you need. (it's called a register context but it also has non register data, so it saves adding another per platform sub class) The only supported platform for this is AArch64 Linux and the only supported tag type is MTE allocation tags. Anything else will error. Ptrace can return a partial result but for lldb-server we will be treating that as an error. To succeed we need to get all the tags we expect. (Note that the protocol leaves room for logical tags to be read via qMemTags but this is not going to be implemented for lldb at this time.) Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D95601
2021-04-01Revert "Revert "[LLDB] Arm64/Linux Add MTE and Pointer Authentication ↵Muhammad Omair Javaid
registers"" This reverts commit 71b648f7158c7a0b4918eaa3e94d307e4bbfce97. There was a typo in the last commit which was causing LLDB AArch64 Linux buildbot testsuite failures. Now fixed in current version.
2021-04-01[lldb] Fix build errors from 3bea7306e8Pavel Labath
The addition of the dummy constructors requires matching changes in os- and arch-specific files, which I forgot about.
2021-03-31Revert "[LLDB] Arm64/Linux Add MTE and Pointer Authentication registers"Muhammad Omair Javaid
This reverts commit 1164b4e2957290e814c3dd781a68e504dd39148e. Reason: LLDB AArch64 Linux buildbot failure
2021-03-31[LLDB] Arm64/Linux Add MTE and Pointer Authentication registersMuhammad Omair Javaid
This patch adds two new dynamic register sets for AArch64 MTE and Pointer Authentication features. These register sets are dynamic and will only be available if underlying hardware support either of these features. LLDB will pull in Aux vector information and create register infos based on that information. A follow up patch will add a test case to test these feature registers. Reviewed By: labath, DavidSpickett Differential Revision: https://reviews.llvm.org/D96460
2021-03-31[LLDB] Add support for Arm64/Linux dynamic register setsMuhammad Omair Javaid
This is patch adds support for adding dynamic register sets for AArch64 dynamic features in LLDB. AArch64 has optional features like SVE, Pointer Authentication and MTE which means LLDB needs to decide at run time which registers it needs to pull in for the current executable based on underlying support for a certain feature. This patch makes necessary adjustments to make way for dynamic register infos and dynamic register sets. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D96458
2021-03-30[lldb] Change CreateHostNativeRegisterContextLinux argument typePavel Labath
to NativeThreadLinux. This avoid casts down the line.
2021-03-10[lldb] [Process/FreeBSD] Introduce aarch64 hw break/watchpoint supportMichał Górny
Split out the common base of Linux hardware breakpoint/watchpoint support for AArch64 into a Utility class, and use it to implement the matching support on FreeBSD. Differential Revision: https://reviews.llvm.org/D96548
2021-01-19[LLDB] Add support to resize SVE registers at run-timeMuhammad Omair Javaid
This patch builds on previously submitted SVE patches regarding expedited register set and per thread register infos. (D82853 D82855 and D82857) We need to resize SVE register based on value received in expedited list. Also we need to resize SVE registers when we write vg register using register write vg command. The resize will result in a updated offset for all of fpr and sve register set. This offset will be configured in native register context by RegisterInfoInterface and will also be be updated on client side in GDBRemoteRegisterContext. A follow up patch will provide a API test to verify this change. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D82863
2020-12-02RegisterInfoPOSIX_arm64 remove unused bytes from g/G packetMuhammad Omair Javaid
This came up while putting together our new strategy to create g/G packets in compliance with GDB RSP protocol where register offsets are calculated in increasing order of register numbers without any unused spacing. RegisterInfoPOSIX_arm64::GPR size was being calculated after alignment correction to 8 bytes which meant there was a 4 bytes unused space between last gpr (cpsr) and first vector register V. We have put LLVM_PACKED_START decorator on RegisterInfoPOSIX_arm64::GPR to make sure single byte alignment is enforced. Moreover we are now doing to use arm64 user_pt_regs struct defined in ptrace.h for accessing ptrace user registers. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D92063
2020-11-30Send SVE vg register in custom expedited registersetMuhammad Omair Javaid
This patch ovverides GetExpeditedRegisterSet for NativeRegisterContextLinux_arm64 to send vector granule register in expedited register set if SVE mode is selected. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D82855
2020-11-17[LLDB] Fix SVE reginfo for sequential offset in g packetMuhammad Omair Javaid
This moves in the direction of our effort to synchronize register descriptions between LLDB and GDB xml description. We want to able to send registers in a way that their offset fields can be re-constructed based on register sizes in the increasing order of register number. In context to Arm64 SVE, FPCR and FPSR are same registers in FPU regset and SVE regset. Previously FPSR/FPCR offset was set at the end of SVE data because Linux ptrace data placed FPCR and FPSR at the end of SVE register set. Considering interoperability with other stubs like QEMU and that g packets should generate register data in increasing order of register numbers. We have to move FPCR/FPSR offset up to its original location according to register numbering scheme of ARM64 registers with SVE registers included. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D90741
2020-10-26[lldb] [Process/Linux] Reuse NativeRegisterContextWatchpoint_x86Michał Górny
Differential Revision: https://reviews.llvm.org/D90119
2020-08-25[LLDB] Fix SVE offset calculation in NativeRegisterContextLinux_arm64Muhammad Omair Javaid
There was typo left from changes in CalculateSVEOffset where we moved FPSR/FPCR offset calculation into WriteRegister and ReadRegister. Differential Revision: https://reviews.llvm.org/D79699
2020-08-19[LLDB] Add ptrace register access for AArch64 SVE registersMuhammad Omair Javaid
This patch adds NativeRegisterContext_arm64 ptrace routines to access AArch64 SVE register set. This patch also adds a test-case to test AArch64 SVE register access and dynamic size configuration capability. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D79699
2020-07-07Combine multiple defs of arm64 register setsMuhammad Omair Javaid
Summary: This patch aims to combine similar arm64 register set definitions defined in NativeRegisterContextLinux_arm64 and RegisterContextPOSIX_arm64. I have implemented a register set interface out of RegisterInfoInterface class and moved arm64 register sets into RegisterInfosPOSIX_arm64 which is similar to Utility/RegisterContextLinux_* implemented by various other targets. This will help in managing register sets of new ARM64 architecture features in one place. Built and tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabihf targets. Reviewers: labath Reviewed By: labath Subscribers: mhorne, emaste, kristof.beyls, atanasyan, danielkiss, lldb-commits Differential Revision: https://reviews.llvm.org/D80105
2020-04-07[lldb] NFC: Fix trivial typo in comments, documents, and messagesKazuaki Ishizaki
Differential Revision: https://reviews.llvm.org/D77460
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2019-12-06Cleanup and speedup NativeRegisterContextLinux_arm64Muhammad Omair Javaid
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