1
- Using LLDB On AArch64 Linux
2
- ===========================
1
+ # Using LLDB On AArch64 Linux
3
2
4
3
This page explains the details of debugging certain AArch64 extensions using
5
4
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
8
7
how LLDB has chosen to use those things and how that effects your experience as
9
8
a user.
10
9
11
- Scalable Vector Extension (SVE)
12
- -------------------------------
10
+ ## Scalable Vector Extension (SVE)
13
11
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 )
16
14
for the Linux Kernel's handling of it.
17
15
18
16
In LLDB you will be able to see the following new registers:
19
17
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
22
20
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.
27
23
24
+ ```
28
25
Scalable Vector Extension Registers:
29
26
vg = 0x0000000000000002
30
27
z0 = {0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 <...> }
31
28
<...>
32
29
p0 = {0xff 0xff}
33
30
<...>
34
31
ffr = {0xff 0xff}
32
+ ```
35
33
36
34
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).
38
36
Elsewhere in kernel code or applications, you may see "vq" which is the vector
39
37
length in quadwords (16 bytes). Where you see "vl", it is in bytes.
40
38
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
42
40
used to find the current vector length.
43
41
44
- Changing the Vector Length
45
- ..........................
42
+ ### Changing the Vector Length
46
43
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
48
45
vector length changes nothing. If you increase the vector length, the registers
49
46
will likely be reset to 0. If you decrease it, LLDB will truncate the Z
50
47
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
54
51
debuggee, or by LLDB. If you need to change the vector length, do so before a
55
52
function's first use of SVE.
56
53
57
- Z Register Presentation
58
- .......................
54
+ ### Z Register Presentation
59
55
60
56
LLDB makes no attempt to predict how SVE Z registers will be used. Since LLDB
61
57
does not know what sort of elements future instructions will interpret the
62
58
register as. It therefore does not change the visualisation of the register
63
59
and always defaults to showing a vector of byte sized elements.
64
60
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
+ ```
67
63
(lldb) register read z0 -f uint32_t[]
68
64
z0 = {0x01010101 0x01010101 0x01010101 0x01010101}
65
+ ```
69
66
70
- FPSIMD and SVE Modes
71
- ....................
67
+ ### FPSIMD and SVE Modes
72
68
73
69
Prior to the debugee's first use of SVE, it is in what the Linux Kernel terms
74
70
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
82
78
there is no way to undo this change from within LLDB. However, the debugee
83
79
itself could do something to end up back in SIMD mode.
84
80
85
- Expression evaluation
86
- .....................
81
+ ### Expression evaluation
87
82
88
83
If you evaluate an expression, all SVE state is saved prior to, and restored
89
84
after the expression has been evaluated. Including the register values and
90
85
vector length.
91
86
92
- Scalable Matrix Extension (SME)
93
- -------------------------------
87
+ ## Scalable Matrix Extension (SME)
94
88
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 )
97
91
for the Linux Kernel's handling of it.
98
92
99
93
SME adds a "Streaming Mode" to SVE, and this mode has its own vector length
100
94
known as the "Streaming Vector Length".
101
95
102
96
In LLDB you will see the following new registers:
103
97
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.
105
99
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
107
101
non-streaming registers and therefore you will only see the active set in
108
102
LLDB. You cannot read or write the inactive mode's registers. Their size
109
103
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
111
105
Extension". This is a square made up of rows of length equal to the streaming
112
106
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 ` .
115
109
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
118
112
to the vector length of non-streaming mode and may change independently. This
119
113
register is read only.
120
114
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
125
119
length. Therefore it is not possible at this time to read the non-streaming
126
120
vector length within LLDB, while in streaming mode. This is a limitation of
127
121
the LLDB implementation not the architecture, which stores both lengths
128
122
independently.
123
+ ```
129
124
130
125
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
+ ```
135
130
Scalable Vector Extension Registers:
136
131
vg = 0x0000000000000002
137
132
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::
150
145
svg = 0x0000000000000002
151
146
svcr = 0x0000000000000003
152
147
za = {0x00 <...> 0x00}
148
+ ```
153
149
154
- Changing the Streaming Vector Length
155
- ....................................
150
+ ### Changing the Streaming Vector Length
156
151
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
158
153
only change the streaming vector length using LLDB when the debugee is in
159
154
streaming mode.
160
155
161
156
As for non-streaming SVE, doing so will essentially make the content of the SVE
162
157
registers undefined. It will also disable ZA, which follows what the Linux
163
158
Kernel does.
164
159
165
- Visibility of an Inactive ZA Register
166
- .....................................
160
+ ### Visibility of an Inactive ZA Register
167
161
168
162
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
170
164
will return a block of 0s instead. This block will match the expected size of
171
- `` za ``: :
172
-
165
+ ` za ` :
166
+ ```
173
167
(lldb) register read za svg svcr
174
168
za = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 <...> }
175
169
svg = 0x0000000000000002
176
170
svcr = 0x0000000000000001
171
+ ```
177
172
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.
179
174
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
181
176
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.
183
178
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 ` .
186
181
187
- ZA Register Presentation
188
- ........................
182
+ ### ZA Register Presentation
189
183
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
191
185
does not know how it would be best to display it. At any time any given
192
186
instrucion could interpret its contents as many kinds and sizes of data.
193
187
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.
195
189
You can override this with a format option (see the SVE example above).
196
190
197
- Expression Evaluation
198
- .....................
191
+ ### Expression Evaluation
199
192
200
193
The mode (streaming or non-streaming), streaming vector length and ZA state will
201
194
be restored after expression evaluation. On top of all the things saved for SVE
202
195
in general.
203
196
204
- Scalable Matrix Extension (SME2)
205
- --------------------------------
197
+ ## Scalable Matrix Extension (SME2)
206
198
207
199
The Scalable Matrix Extension 2 is documented in the same architecture
208
200
specification as SME, and covered by the same kernel documentation page as SME.
209
201
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
211
203
register that is used by new instructions added in SME2. It is shown in LLDB in
212
204
the existing SME register set.
213
205
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 ` .
218
210
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
221
213
active but with a value of all 0s.
222
214
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
224
216
registers from within LLDB (though of course a running process can still do
225
217
this).
226
218
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 ` .
229
221
230
- ZT0 Register Presentation
231
- .........................
222
+ ### ZT0 Register Presentation
232
223
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,
234
225
so LLDB does not attempt to guess this and defaults to showing it as a vector of
235
226
bytes.
236
227
237
- Expression Evaluation
238
- .....................
228
+ ### Expression Evaluation
239
229
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
241
231
expression evaluation and restored afterwards.
0 commit comments