Supported on windows
Supported on linux
Supported on embedded
Supported on android

set print array command

Enables or disables pretty-printing of arrays.

Syntax

set print array on
set print array off
show print array

Modes

off
GDB will display the values of arrays in a simple one-line format (e.g. $1 = {1, 2, 3}).
off
GDB will display the values of arrays using longer multi-line format.

Default mode

The default value for the print array setting is 'off'.

Remarks

The set print array command can be used together with the set print array-indexes command to further customize the output of the array contents.

Examples

Below is a log of sample GDB session illustrating how set print array command affects the output of the print command:

(gdb) start
Temporary breakpoint 1 at 0x80483f3: file test.cpp, line 5.
Starting program: /home/bazis/test

Temporary breakpoint 1, main (argc=1, argv=0xbffff064) at test.cpp:5
5 int testArray[] = {1, 2, 3};
(gdb) next
6 return 0;
(gdb) print testArray
$1 = {1, 2, 3}
(gdb) show print array
Prettyprinting of arrays is off.
(gdb) set print array on
(gdb) print testArray
$2 = {1,
2,
3}

Compatibility with VisualGDB

Do not use the set print array command with VisualGDB. VisualGDB relies on the default array output format used by GDB and disabling this feature can stop VisualGDB from functioning correctly.

See also