Native Debugging — gdb, Core Dumps and Symbols

Getting an actionable backtrace out of a crash you did not witness — gdb on optimized builds, core dump capture in containers and CI, separate debug info, build-ids, and debuginfod.

Overview

From 'it crashed' to 'this line, this value'

This topic closes the gap between 'the service crashed' and 'here is the line that crashed and the value that caused it'. Most teams lose days there, because the artifacts that close it must be arranged before the crash.

The evidence starts with a core dump: a file holding the memory image and registers of the process at the moment it died. Turning a crash into a symbolized backtrace takes three things, in order. The core must be written, which depends on RLIMIT_CORE and core_pattern. The exact binary must be retrievable. And the matching debug info must be findable by build-id. Only when all three hold does gdb give you a symbolized backtrace.

Key concepts

  • core_pattern
  • coredump_filter
  • build-id
  • Separate debug info
  • debuginfod
  • -Og
  • thread apply all bt
  • Minidump and PDB

Interview questions

  • A production service segfaulted and you have a core file. Walk through getting from that to a root cause.
  • Explain separate debug info and build-ids. Why strip production binaries at all if you need symbols?
  • How do you capture core dumps from a containerized service, and what changes versus a bare-metal host?
  • You are debugging an -O2 build and half the locals show . How do you proceed, and what does -Og change?
  • How do you make a crashing test in CI produce an actionable backtrace instead of an exit code?

Sign up free to read the full topic

More DevOps topics

Start free on Cariara · Coding problems · System design studio