Separate debug info, from objcopy to debuginfod
This URL used to hold one page of debugger documentation, about splitting debug symbols out of a binary. That page is gone. The problem it solved isn't, so here's where it stands now.
The original text asked a question worth keeping. You're building a C or C++ program that lands on a few hundred machines you own. Nobody outside sees it, so why strip the debug info at all? Leave it in and troubleshooting later is easy. The catch was size: for C++ the debug sections routinely outweigh the code, and multiplying that by every host slowed deployments down. The answer was to keep one copy somewhere and point at it.
What did this domain have to do with it? It sold a debugger, ZeroBUGS, for eight years. The domain history page covers that, and what happened to its central argument is its own page. We have no connection to the author and claim none.
The recipe, and what took its place
2008, on this page
objcopy --only-keep-debug, then strip, then --add-gnu-debuglink
The debuglink section holds a filename and a CRC. The debugger reads it, goes looking for that name, and loads symbols from a network mount. One copy of the debug info, N stripped binaries in production.
Still true
The size argument
C++ debug info is often larger than the code it describes, because mangled names are long and templates instantiate a lot of them. Nothing since 2008 has made that smaller by accident.
What replaced the CRC
Build IDs
GNU ld writes a .note.gnu.build-id section, and the linker default on every mainstream distribution now emits one. Lookup is by that hash rather than by a path someone hard-coded, so a binary found on a machine nobody documented is still resolvable.
What replaced the network mount
debuginfod
An HTTP service that hands back debug info and sources for a build ID on demand. GDB, LLDB, perf, systemtap and the elfutils tools all speak it, and the major distributions run public servers. Set DEBUGINFOD_URLS and the fetch happens when a debugger actually needs it.
What changed the build itself
Split DWARF
Compile with -gsplit-dwarf and the bulk of the debug info lands in .dwo files that the linker never has to read. On a large C++ tree this is a link-time win, not just a disk-space one, and it composes with the two rows above rather than competing with them.
Does the 2008 script still run?
Yes. That's the honest answer, and it's a slightly annoying one. The three commands below do today what they did then, and if you have a small fleet and no appetite for running another service, they remain a defensible choice.
objcopy --only-keep-debug prog prog.dbg
strip prog
objcopy --add-gnu-debuglink=prog.dbg prog What ages badly isn't the commands. It's the assumption underneath them, that you know in advance where the debug file will live. A debuglink is a filename plus a checksum. Move the file, rename the directory, or hand a core dump to somebody on another team, and the link is a dead end. Build IDs removed that assumption, and debuginfod removed the mount.
Is running a debuginfod worth it for five servers? Probably not. For a codebase where an on-call engineer has to symbolicate a core from a release built nine months ago by somebody who has since left, it pays for itself the first time.
Why a code-quality site cares
This blog is about the gates that keep bugs out, not about the tools that find them after the fact. Debug symbols look like the second category. They're really the first, and three ways in particular.
- A build that ships stripped binaries and keeps no debug info anywhere is not lean. It is undebuggable, and you find out during an incident.
- Symbols are a build artifact with a retention policy. Decide the policy on purpose, or your oldest still-running release is the one you cannot symbolicate.
- If your CI uploads a 900 MB artifact per job because nobody passed -gsplit-dwarf, that is a quality gate problem wearing a storage-bill costume.
I'd go further, and this is the part you can argue with: symbol retention belongs in the same review as log retention and backup retention, and it almost never is. Teams write the log policy down. The symbol policy is whatever the build script happened to do in 2019.
If you followed an old link
You were probably sent here by documentation, a mailing-list post or a forum thread from between 2006 and 2012. The debugger those pointed at is gone. This site now writes about code quality gates in any language, and it keeps the old URLs answering the question that was asked rather than dropping you on a homepage.