Skip to content

GDB - GNU Debugger#

GDB is a command line debugger installed on all our systems.

Resolving "could not open an executable file" or "can't open read symbols" after attaching to a process#

If you use GDB inside a Slurm job to attach to a process with gdb -p/--pid=<pid> or the GDB command attach <pid> you might encounter errors or warnings related to executable and library files than cannot be opened or symbols that cannot be read, like in the following:

warning: "target:<executable>": could not open as an executable file: Operation not permitted.
warning: `target:<executable>': can't open to read symbols: Operation not permitted.
warning: Could not load vsyscall page because no executable was specified

As a workaround execute the command set sysroot / inside GDB:

  • With gdb -p <pid>:

    gdb -p <pid>`
    # errors/warnings ...
    (gdb) set sysroot /
    # Reading symbols ...
    

  • With gdb <executable>:

    $ gdb <executable>
    (gdb) set sysroot /
    (gdb) attach <pid>
    

Thanks to SURFsara for figuring this out.