There are two ways to do this in lldb.
Most commonly, you use the parray
lldb command which takes a COUNT
and an EXPRESSION
; EXPRESSION
is evaluated and should result in a pointer to memory. lldb will then print COUNT
items of that type at that address. e.g.
parray 10 ptr
where ptr
is of type int *
.
Alternatively, it can be done by casting the pointer to a pointer-to-array.
For example, if you have a int* ptr
, and you want to view it as an array of ten integers, you can do
p *(int(*)[10])ptr
Because it relies only on standard C features, this method works without any plugins or special settings. It likewise works with other debuggers like GDB or CDB, even though they also have specialized syntaxes for printing arrays.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…