In Clion's debugger, how do I show the entire contents of an int array
Solution 1:
The answer by cubuspl42 works for GDB. But if you're on a Mac using LLDB as your debugger, the correct method is
(MyType(*)[128])myArray
Hope this helps!
Solution 2:
Unfortunately, CLion doesn't currently support such feature. As suggested by JetBrains employee, you can use a workaround. In Evaluate / Watches window use the following expression:
(MyType[128])myArray
You can use arbitrary array size; whatever works for you.
If you array is stored in void *
variable, you need to do something more tricky:
(MyType[128])*(char*)myArray
Solution 3:
Any syntax understood by the underlying debugger should work, actually. In the case of GDB, for example, you could use *array@size
, where array
can be any pointer expression and size
can be any (positive) integer expression, and both can include variables, function calls, registers, anything that GDB understands. Something like this would be valid, for example:
*((int*)$rsp - 0x100)@get_size(data)