Next: Symbol Errors, Previous: Separate Debug Files, Up: GDB Files

### 18.3 Index Files Speed Up gdb

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.

The index is stored as a section in the symbol file. gdb can write the index to a file, then you can put it into the symbol file using `objcopy`.

To create an index file, use the `save gdb-index` command:

`save gdb-index` directory
  Create an index file for each symbol file currently known by gdb. Each file is named after its corresponding symbol file, with ‘`.gdb-index`’ appended, and is written into the given directory.

Once you have created an index file you can merge it into your symbol file, here named `symfile`, using `objcopy`:

         $ objcopy --add-section .gdb_index=symfile.gdb-index \
             --set-section-flags .gdb_index=readonly symfile symfile

There are currently some limitation on indices. They only work when for DWARF debugging information, not stabs. And, they do not currently work for programs using Ada.