### gdb-add-index ¶

gdb-add-index [-dwarf-5] filename

When GDB finds a symbol file, it scans the symbols in the file in order to construct an internal symbol table. This lets most GDB operations work quickly–at the cost of a delay early on. For large programs, this delay can be quite lengthy, so GDB provides a way to build an index, which speeds up startup.

To determine whether a file contains such an index, use the command `readelf -S filename`: the index is stored in a section named `.gdb_index` (pre-DWARF 5) or `.debug_names` and `.debug_str` (DWARF 5). Indexes can only be produced on systems which use ELF binaries and DWARF debug information (i.e., sections named `.debug_*`).

By default `gdb-add-index` will add a pre-DWARF 5 `.gdb_index` section to filename. With `-dwarf-5` DWARF 5 sections are added instead.

filename must be writable.

`gdb-add-index` uses GDB, `objcopy`, and `readelf` found in the `PATH` environment variable. If you want to use different versions of these programs, you can specify them through the appropriate environment variables (see below).

`gdb-add-index` exits with status 0 if it succeeds in creating the index for filename or greater than 0 if an error occurs.

See more in Index Files Speed Up GDB.

`-dwarf-5`

  Add DWARF 5 sections instead of previous `.debug_index` section.

`GDB`

  Full file name of the `gdb` program to use for index generation. If not set, the `PATH` will be searched for a `gdb` program.

`OBJCOPY`

  Full file name of the `objcopy` program to use to copy section information into the given file. If not set, the `PATH` will be searched for a `objcopy` program.

`READELF`

  Full file name of the `readelf` program to use to inspect properties of the given file. If not set, the `PATH` will be searched for a `readelf` program.