79813035

Date: 2025-11-08 08:01:03
Score: 0.5
Natty:
Report link

Yes, `set print elements unlimited` is the correct command to display the full string in GDB without truncation.

However, if you want this setting to persist across all your GDB sessions (make it "stick"), you need to add it to your GDB configuration file.

**Steps to make it permanent:**

1. Create or edit the `.gdbinit` file in your home directory:

nano ~/.gdbinit

On Windows: notepad %USERPROFILE%.gdbinit

2. Add these lines:

set print elements unlimited
set print repeats unlimited

3. Save and exit

Now every time you start GDB, these settings will be automatically applied.

**Additional useful tips:**

- `set print elements 0` is equivalent to unlimited

- To verify current setting: `show print elements`

- For project-specific settings, create a `.gdbinit` file in your project directory

**Security Note:** By default, GDB may not load local `.gdbinit` files for security reasons. To enable it, add this to your `~/.gdbinit`:

set auto-load safe-path /

Or for specific directories:

add-auto-load-safe-path /path/to/your/project

undefined

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Suman Dutta