GDB-ADD-INDEX(1)
π gdb-add-index β bestie edition
okay so this is gdb-add-index from the GNU Development Tools manual suite, section 1 of the man pages, and it's genuinely one of the most underrated little glow-ups in the whole debugging world. sit down, we're building an index. π
β¨ NAME β¨
gdb-add-index β adds index files to your binary so GDB starts up fast. no cap.
π¦ SYNOPSIS π¦
gdb-add-index [-h | --help] [-v | --version] [--dwarf-5] filename
πΈ DESCRIPTION πΈ
so here's the tea: when GDB finds a symbol file, it scans all the symbols in that file to build up an internal symbol table. and like β that's a good thing, because it makes most GDB operations run super quickly. slay. but the tradeoff is a delay at the very beginning. and for large programs? bestie, that delay can be quite lengthy. π
so GDB gives you a way to build an index ahead of time, which speeds up startup. main character energy, honestly.
to check whether a file already has such an index, use readelf -S filename β the index lives in a section named .gdb_index (pre-DWARF 5) or .debug_names and .debug_str (DWARF 5). and heads up: indexes can only be produced on systems that use ELF binaries and DWARF debug information β meaning sections named .debug_*. that's the vibe check, sorry. π
by default gdb-add-index will add a pre-DWARF 5 .gdb_index section to filename. with --dwarf-5, the DWARF 5 section .debug_names is added instead. choose your fighter. β¨
filename must be writable. no writable, no index. periodt.
gdb-add-index uses GDB, objcopy, and readelf found in the PATH environment variable. if you wanna use different versions of these programs β totally valid β you can specify them through the appropriate environment variables (see below, i got you π«Ά).
gdb-add-index exits with status 0 if it succeeds in creating the index for filename, or greater than 0 if an error occurs. simple as.
see more in the GDB manual in node "Index Files" β shell command:
info -f gdb -n "Index Files"
π OPTIONS π
--dwarf-5β adds DWARF 5 sections instead of the previous.gdb_indexsection. the modern choice, lowkey.--help,-hβ lists all the options with brief explanations. the little tour.--version,-vβ prints version information and then exits. bye bestie π
π§ ENVIRONMENT π§
GDBβ full file name of thegdbprogram to use for index generation. if it's not set, thePATHwill be searched for agdbprogram.OBJCOPYβ full file name of theobjcopyprogram used to copy section information into the given file. if it's not set, thePATHwill be searched for anobjcopyprogram.READELFβ full file name of thereadelfprogram used to inspect properties of the given file. if it's not set, thePATHwill be searched for areadelfprogram.
π₯ SEE ALSO π₯
the full documentation for GDB is maintained as a Texinfo manual. if the info and gdb programs and GDB's Texinfo documentation are properly installed at your site, the command
info gdb
should give you access to the complete manual. iconic.
also on the shelf: Using GDB: A Guide to the GNU Source-Level Debugger, by Richard M. Stallman and Roland H. Pesch, July 1991. vintage but still ate. π
π COPYRIGHT π
Copyright (c) 1988-2025 Free Software Foundation, Inc.
permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being "Free Software" and "Free Software Needs Free Documentation", with the Front-Cover Texts being "A GNU Manual," and with the Back-Cover Texts as in (a) below.
(a) the FSF's Back-Cover Text is: "You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom."
π okay that's the whole thing!! go forth and index. this page you just read is from gdb-17.2, dated 2026-05-10 β mwah, sending you the biggest hug, now go debug something cute. ππ¦
π¦ where this page comes from
- arch rolling: aarch64-linux-gnu-gdb 17.2-1 Β· GPL3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms