GDB-ADD-INDEX(1)
β¨ NAME β¨
gdb-add-index β it slaps an index file onto your binary so GDB stops making you wait forever π
(this is page GDB-ADD-INDEX(1) from the GNU Development Tools manual, bestie β buckle up π)
πΈ SYNOPSIS πΈ
gdb-add-index [-h | --help] [-v | --version] [--dwarf-5] filename
π¦ DESCRIPTION π¦
okay so picture this: GDB finds a symbol file and then it has to scan all the symbols in it to build its own internal symbol table. that's the whole vibe β it makes most GDB operations go fast, but you pay for it with a little delay at the start π and for big programs? that "little delay" is literally forever. so GDB gives you a way to build an index, which speeds up startup. iconic behavior honestly π
to figure out whether a file already has one of these indexes, run readelf -S filename. the index lives in a section called .gdb_index (pre-DWARF 5) or in .debug_names and .debug_str (DWARF 5). heads up tho β indexes can only be produced on systems that use ELF binaries and DWARF debug info (i.e., sections named .debug_*). no ELF, no DWARF, no index, sorry bb π
by default, gdb-add-index adds a pre-DWARF 5 .gdb_index section to filename. but if you pass --dwarf-5, the DWARF 5 section .debug_names gets added instead β¨
ifilename* must be writable. like, actually. it needs to write to it. π«Ά
gdb-add-index uses the GDB, objcopy, and readelf that it finds in the PATH environment variable. want different versions of those programs? cool, you can point at them with the appropriate environment variables (scroll down, they're right there π).
exit status tea β: gdb-add-index exits with status 0 if it successfully creates the index for filename, or greater than 0 if an error happens. that's it, that's the whole vibe check.
want more? there's more in the GDB manual, node Index Files β shell command:
info -f gdb -n "Index Files"
π OPTIONS π
--dwarf-5β adds DWARF 5 sections instead of the previous.gdb_indexsection. glow-up for your debug info β¨--help,-hβ lists all the options with brief explanations. the "what does anything even do" button π--version,-vβ prints version information and then exits. says hi and dips immediately π
π ENVIRONMENT π
GDBβ full file name of thegdbprogram to use for index generation. if it's not set, thePATHgets searched for agdbprogram πOBJCOPYβ full file name of theobjcopyprogram, used to copy section information into the given file. if it's not set, thePATHgets searched for anobjcopyprogram π§READELFβ full file name of thereadelfprogram, used to inspect properties of the given file. if it's not set, thePATHgets 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, this command:
info gdb
should give you access to the complete manual. no cap, that's the whole manual in there π«Ά
also, Using GDB: A Guide to the GNU Source-Level Debugger, Richard M. Stallman and Roland H. Pesch, July 1991. a classic. we stan a legacy doc π
π 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."
and that's the whole page, bestie! this version is gdb-17.1, dated 2025-12-20 β go forth and index responsibly π¦πβ¨
π¦ where this page comes from
- arch rolling: lm32-elf-gdb 17.1-2 Β· GPL3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms