Skip to content

Commit f6e771c

Browse files
committed
[lldb][Docs] Convert AArch64 Linux doc to Markdown
Executive decision from me given that I am the sole author of the doc and there's nothing Markdown can't handle here.
1 parent a131fbf commit f6e771c

File tree

1 file changed

+71
-81
lines changed

1 file changed

+71
-81
lines changed
Lines changed: 71 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Using LLDB On AArch64 Linux
2-
===========================
1+
# Using LLDB On AArch64 Linux
32

43
This page explains the details of debugging certain AArch64 extensions using
54
LLDB. If something is not mentioned here, it likely works as you would expect.
@@ -8,43 +7,41 @@ This is not a replacement for ptrace and Linux Kernel documentation. This covers
87
how LLDB has chosen to use those things and how that effects your experience as
98
a user.
109

11-
Scalable Vector Extension (SVE)
12-
-------------------------------
10+
## Scalable Vector Extension (SVE)
1311

14-
See `here <https://developer.arm.com/Architectures/Scalable%20Vector%20Extensions>`__
15-
to learn about the extension and `here <https://kernel.org/doc/html/latest/arch/arm64/sve.html>`__
12+
See [here](https://developer.arm.com/Architectures/Scalable%20Vector%20Extensions)
13+
to learn about the extension and [here](https://kernel.org/doc/html/latest/arch/arm64/sve.html)
1614
for the Linux Kernel's handling of it.
1715

1816
In LLDB you will be able to see the following new registers:
1917

20-
* ``z0-z31`` vector registers, each one has size equal to the vector length.
21-
* ``p0-p15`` predicate registers, each one containing 1 bit per byte in the vector
18+
* `z0-z31` vector registers, each one has size equal to the vector length.
19+
* `p0-p15` predicate registers, each one containing 1 bit per byte in the vector
2220
length. Making each one vector length / 8 sized.
23-
* ``ffr`` the first fault register, same size as a predicate register.
24-
* ``vg``, the vector length in "granules". Each granule is 8 bytes.
25-
26-
.. code-block::
21+
* `ffr` the first fault register, same size as a predicate register.
22+
* `vg`, the vector length in "granules". Each granule is 8 bytes.
2723

24+
```
2825
Scalable Vector Extension Registers:
2926
vg = 0x0000000000000002
3027
z0 = {0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 <...> }
3128
<...>
3229
p0 = {0xff 0xff}
3330
<...>
3431
ffr = {0xff 0xff}
32+
```
3533

3634
The example above has a vector length of 16 bytes. Within LLDB you will always
37-
see "vg" as in the ``vg`` register, which is 2 in this case (8*2 = 16).
35+
see "vg" as in the `vg` register, which is 2 in this case (8*2 = 16).
3836
Elsewhere in kernel code or applications, you may see "vq" which is the vector
3937
length in quadwords (16 bytes). Where you see "vl", it is in bytes.
4038

41-
While you can count the size of a P or Z register, it is intended that ``vg`` be
39+
While you can count the size of a P or Z register, it is intended that `vg` be
4240
used to find the current vector length.
4341

44-
Changing the Vector Length
45-
..........................
42+
### Changing the Vector Length
4643

47-
The ``vg`` register can be written during a debug session. Writing the current
44+
The `vg` register can be written during a debug session. Writing the current
4845
vector length changes nothing. If you increase the vector length, the registers
4946
will likely be reset to 0. If you decrease it, LLDB will truncate the Z
5047
registers but everything else will be reset to 0.
@@ -54,21 +51,20 @@ way the same as it was previously. Whether that is done from within the
5451
debuggee, or by LLDB. If you need to change the vector length, do so before a
5552
function's first use of SVE.
5653

57-
Z Register Presentation
58-
.......................
54+
### Z Register Presentation
5955

6056
LLDB makes no attempt to predict how SVE Z registers will be used. Since LLDB
6157
does not know what sort of elements future instructions will interpret the
6258
register as. It therefore does not change the visualisation of the register
6359
and always defaults to showing a vector of byte sized elements.
6460

65-
If you know what format you are going to use, give a format option::
66-
61+
If you know what format you are going to use, give a format option:
62+
```
6763
(lldb) register read z0 -f uint32_t[]
6864
z0 = {0x01010101 0x01010101 0x01010101 0x01010101}
65+
```
6966

70-
FPSIMD and SVE Modes
71-
....................
67+
### FPSIMD and SVE Modes
7268

7369
Prior to the debugee's first use of SVE, it is in what the Linux Kernel terms
7470
SIMD mode. Only the FPU is being used. In this state LLDB will still show the
@@ -82,56 +78,55 @@ You can also trigger this with LLDB by writing to an SVE register. Note that
8278
there is no way to undo this change from within LLDB. However, the debugee
8379
itself could do something to end up back in SIMD mode.
8480

85-
Expression evaluation
86-
.....................
81+
### Expression evaluation
8782

8883
If you evaluate an expression, all SVE state is saved prior to, and restored
8984
after the expression has been evaluated. Including the register values and
9085
vector length.
9186

92-
Scalable Matrix Extension (SME)
93-
-------------------------------
87+
## Scalable Matrix Extension (SME)
9488

95-
See `here <https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/scalable-matrix-extension-armv9-a-architecture>`__
96-
to learn about the extension and `here <https://kernel.org/doc/html/latest/arch/arm64/sme.html>`__
89+
See [here](https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/scalable-matrix-extension-armv9-a-architecture)
90+
to learn about the extension and [here](https://kernel.org/doc/html/latest/arch/arm64/sme.html)
9791
for the Linux Kernel's handling of it.
9892

9993
SME adds a "Streaming Mode" to SVE, and this mode has its own vector length
10094
known as the "Streaming Vector Length".
10195

10296
In LLDB you will see the following new registers:
10397

104-
* ``tpidr2``, an extra per thread pointer reserved for use by the SME ABI.
98+
* `tpidr2`, an extra per thread pointer reserved for use by the SME ABI.
10599
This is not scalable, just pointer sized aka 64 bit.
106-
* ``z0-z31`` streaming SVE registers. These have the same names as the
100+
* `z0-z31` streaming SVE registers. These have the same names as the
107101
non-streaming registers and therefore you will only see the active set in
108102
LLDB. You cannot read or write the inactive mode's registers. Their size
109103
is the same as the streaming vector length.
110-
* ``za`` the Array Storage register. The "Matrix" part of "Scalable Matrix
104+
* `za` the Array Storage register. The "Matrix" part of "Scalable Matrix
111105
Extension". This is a square made up of rows of length equal to the streaming
112106
vector length (svl). Meaning that the total size is svl * svl.
113-
* ``svcr`` the Streaming Vector Control Register. This is actually a pseduo
114-
register but it matches the content of the architecturaly defined ``SVCR``.
107+
* `svcr` the Streaming Vector Control Register. This is actually a pseduo
108+
register but it matches the content of the architecturaly defined `SVCR`.
115109
This is the register you should use to check whether streaming mode and/or
116-
``za`` is active. This register is read only.
117-
* ``svg`` the streaming vector length in granules. This value is not connected
110+
`za` is active. This register is read only.
111+
* `svg` the streaming vector length in granules. This value is not connected
118112
to the vector length of non-streaming mode and may change independently. This
119113
register is read only.
120114

121-
.. note::
122-
While in non-streaming mode, the ``vg`` register shows the non-streaming
123-
vector length, and the ``svg`` register shows the streaming vector length.
124-
When in streaming mode, both ``vg`` and ``svg`` show the streaming mode vector
115+
```{note}
116+
While in non-streaming mode, the `vg` register shows the non-streaming
117+
vector length, and the `svg` register shows the streaming vector length.
118+
When in streaming mode, both `vg` and `svg` show the streaming mode vector
125119
length. Therefore it is not possible at this time to read the non-streaming
126120
vector length within LLDB, while in streaming mode. This is a limitation of
127121
the LLDB implementation not the architecture, which stores both lengths
128122
independently.
123+
```
129124

130125
In the example below, the streaming vector length is 16 bytes and we are in
131-
streaming mode. Note that bits 0 and 1 of ``svcr`` are set, indicating that we
132-
are in streaming mode and ZA is active. ``vg`` and ``svg`` report the same value
133-
as ``vg`` is showing the streaming mode vector length::
134-
126+
streaming mode. Note that bits 0 and 1 of `svcr` are set, indicating that we
127+
are in streaming mode and ZA is active. `vg` and `svg` report the same value
128+
as `vg` is showing the streaming mode vector length:
129+
```
135130
Scalable Vector Extension Registers:
136131
vg = 0x0000000000000002
137132
z0 = {0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 <...> }
@@ -150,92 +145,87 @@ as ``vg`` is showing the streaming mode vector length::
150145
svg = 0x0000000000000002
151146
svcr = 0x0000000000000003
152147
za = {0x00 <...> 0x00}
148+
```
153149

154-
Changing the Streaming Vector Length
155-
....................................
150+
### Changing the Streaming Vector Length
156151

157-
To reduce complexity for LLDB, ``svg`` is read only. This means that you can
152+
To reduce complexity for LLDB, `svg` is read only. This means that you can
158153
only change the streaming vector length using LLDB when the debugee is in
159154
streaming mode.
160155

161156
As for non-streaming SVE, doing so will essentially make the content of the SVE
162157
registers undefined. It will also disable ZA, which follows what the Linux
163158
Kernel does.
164159

165-
Visibility of an Inactive ZA Register
166-
.....................................
160+
### Visibility of an Inactive ZA Register
167161

168162
LLDB does not handle registers that can come and go at runtime (SVE changes
169-
size but it does not dissappear). Therefore when ``za`` is not enabled, LLDB
163+
size but it does not dissappear). Therefore when `za` is not enabled, LLDB
170164
will return a block of 0s instead. This block will match the expected size of
171-
``za``::
172-
165+
`za`:
166+
```
173167
(lldb) register read za svg svcr
174168
za = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 <...> }
175169
svg = 0x0000000000000002
176170
svcr = 0x0000000000000001
171+
```
177172

178-
Note that ``svcr`` bit 2 is not set, meaning ``za`` is inactive.
173+
Note that `svcr` bit 2 is not set, meaning `za` is inactive.
179174

180-
If you were to write to ``za`` from LLDB, ``za`` will be made active. There is
175+
If you were to write to `za` from LLDB, `za` will be made active. There is
181176
no way from within LLDB to reverse this change. As for changing the vector
182-
length, the debugee could still do something that would disable ``za`` again.
177+
length, the debugee could still do something that would disable `za` again.
183178

184-
If you want to know whether ``za`` is active or not, refer to bit 2 of the
185-
``svcr`` register, otherwise known as ``SVCR.ZA``.
179+
If you want to know whether `za` is active or not, refer to bit 2 of the
180+
`svcr` register, otherwise known as `SVCR.ZA`.
186181

187-
ZA Register Presentation
188-
........................
182+
### ZA Register Presentation
189183

190-
As for SVE, LLDB does not know how the debugee will use ``za``, and therefore
184+
As for SVE, LLDB does not know how the debugee will use `za`, and therefore
191185
does not know how it would be best to display it. At any time any given
192186
instrucion could interpret its contents as many kinds and sizes of data.
193187

194-
So LLDB will default to showing ``za`` as one large vector of individual bytes.
188+
So LLDB will default to showing `za` as one large vector of individual bytes.
195189
You can override this with a format option (see the SVE example above).
196190

197-
Expression Evaluation
198-
.....................
191+
### Expression Evaluation
199192

200193
The mode (streaming or non-streaming), streaming vector length and ZA state will
201194
be restored after expression evaluation. On top of all the things saved for SVE
202195
in general.
203196

204-
Scalable Matrix Extension (SME2)
205-
--------------------------------
197+
## Scalable Matrix Extension (SME2)
206198

207199
The Scalable Matrix Extension 2 is documented in the same architecture
208200
specification as SME, and covered by the same kernel documentation page as SME.
209201

210-
SME2 adds 1 new register, ``zt0``. This register is a fixed size 512 bit
202+
SME2 adds 1 new register, `zt0`. This register is a fixed size 512 bit
211203
register that is used by new instructions added in SME2. It is shown in LLDB in
212204
the existing SME register set.
213205

214-
``zt0`` can be active or inactive, as ``za`` can. The same ``SVCR.ZA`` bit
215-
controls this. An inactive ``zt0`` is shown as 0s, like ``za`` is. Though in
216-
``zt0``'s case, LLDB does not need to fake the value. Ptrace already returns a
217-
block of 0s for an inactive ``zt0``.
206+
`zt0` can be active or inactive, as `za` can. The same `SVCR.ZA` bit
207+
controls this. An inactive `zt0` is shown as 0s, like `za` is. Though in
208+
`zt0`'s case, LLDB does not need to fake the value. Ptrace already returns a
209+
block of 0s for an inactive `zt0`.
218210

219-
Like ``za``, writing to an inactive ``zt0`` will enable it and ``za``. This can
220-
be done from within LLDB. If the write is instead to ``za``, ``zt0`` becomes
211+
Like `za`, writing to an inactive `zt0` will enable it and `za`. This can
212+
be done from within LLDB. If the write is instead to `za`, `zt0` becomes
221213
active but with a value of all 0s.
222214

223-
Since ``svcr`` is read only, there is no way at this time to deactivate the
215+
Since `svcr` is read only, there is no way at this time to deactivate the
224216
registers from within LLDB (though of course a running process can still do
225217
this).
226218

227-
To check whether ``zt0`` is active, refer to ``SVCR.ZA`` and not to the value of
228-
``zt0``.
219+
To check whether `zt0` is active, refer to `SVCR.ZA` and not to the value of
220+
`zt0`.
229221

230-
ZT0 Register Presentation
231-
.........................
222+
### ZT0 Register Presentation
232223

233-
As for ``za``, the meaning of ``zt0`` depends on the instructions used with it,
224+
As for `za`, the meaning of `zt0` depends on the instructions used with it,
234225
so LLDB does not attempt to guess this and defaults to showing it as a vector of
235226
bytes.
236227

237-
Expression Evaluation
238-
.....................
228+
### Expression Evaluation
239229

240-
``zt0``'s value and whether it is active or not will be saved prior to
230+
`zt0`'s value and whether it is active or not will be saved prior to
241231
expression evaluation and restored afterwards.

0 commit comments

Comments
 (0)