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

set print elements command

Specifies the maximum amount of array elements (or string characters) displayed by the print comand.

Syntax

set print elements [Elements]
set print elements 0
show print elements

Parameters

Elements
Specifies the maximum amount of array elements (or string characters) that the print command will display when displaying array/string contents. If this parameter is 0, GDB will have no limit on the amount of elements/characters to display.

Default mode

The default value for the print elements setting is 200.

Remarks

It is not recommended to remove the element limit completely, to avoid delays when evaluating null-terminated strings that were not null-terminated properly.

Examples

Below is a log of sample GDB session illustrating how set print elements command affects the display of arrays and strings using the print command:

(gdb) set args arg1 arg2 arg3 arg4
(gdb) start
Temporary breakpoint 1 at 0x80483f0: file test.cpp, line 5.
Starting program: /home/bazis/test arg1 arg2 arg3 arg4

Temporary breakpoint 1, main (argc=5, argv=0xbffff034) at test.cpp:5
5 return 0;
(gdb) print *argv@argc
$1 = {0xbffff21e "/home/bazis/test", 0xbffff22f "arg1", 0xbffff234 "arg2", 0xbffff239 "arg3", 0xbffff23e "arg4"}
(gdb) show print elements
Limit on string chars or array elements to print is 200.
(gdb) set print elements 3
(gdb) print *argv@argc
$2 = {0xbffff21e "/ho"..., 0xbffff22f "arg"..., 0xbffff234 "arg"......}
(gdb) set print elements 5
(gdb) print *argv@argc
$3 = {0xbffff21e "/home"..., 0xbffff22f "arg1", 0xbffff234 "arg2", 0xbffff239 "arg3", 0xbffff23e "arg4"}
(gdb) set print elements 0
(gdb) show print elements
Limit on string chars or array elements to print is unlimited.
(gdb) print *argv@argc
$4 = {0xbffff21e "/home/bazis/test", 0xbffff22f "arg1", 0xbffff234 "arg2", 0xbffff239 "arg3", 0xbffff23e "arg4"}

Compatibility with VisualGDB

You can issue the set print elements command via the GDB Session window to control how many array elements VisualGDB will display.

See also