drgn¶
drgn (pronounced “dragon”) is a debugger with an emphasis on programmability. drgn exposes the types and variables in a program for easy, expressive scripting in Python. For example, you can debug the Linux kernel:
>>> from drgn.helpers.linux import list_for_each_entry
>>> for mod in list_for_each_entry('struct module',
... prog['modules'].address_of_(),
... 'list'):
... if mod.refcnt.counter > 10:
... print(mod.name)
...
(char [56])"snd"
(char [56])"evdev"
(char [56])"i915"
Although other debuggers like GDB have scripting support, drgn aims to make scripting as natural as possible so that debugging feels like coding. This makes it well-suited for introspecting the complex, inter-connected state in large programs.
Additionally, drgn is designed as a library that can be used to build debugging and introspection tools; see the official tools.
drgn was developed at Meta for debugging the Linux kernel (as an alternative to the crash utility), but it can also debug userspace programs written in C. C++ support is in progress.
In addition to the main Python API, an experimental C library, libdrgn
, is
also available.
See the Installation instructions. Then, start with the User Guide.
Getting Help¶
The GitHub issue tracker is the preferred method to report issues.
There is also a Linux Kernel Debuggers Matrix room.
License¶
Copyright (c) Meta Platforms, Inc. and affiliates.
drgn is licensed under the LGPLv2.1 or later.
Acknowledgements¶
Table of Contents¶
Using drgn
Tutorials
Reference
- API Reference
- Programs
- Objects
- Symbols
- Stack Traces
- Types
- Modules
- Miscellaneous
- Exceptions
- CLI
- Commands
run_command()
CommandError
CommandArgumentError
CommandExitStatusError
CommandNotFoundError
CommandNamespace
DEFAULT_COMMAND_NAMESPACE
Command
command()
CommandFunc
argument
drgn_argument
argument_group
mutually_exclusive_group
custom_command()
CustomCommandFunc
CRASH_COMMAND_NAMESPACE
crash_command()
crash_custom_command()
crash_get_context()
linux_kernel_command()
linux_kernel_custom_command()
- Plugins
- Logging
- Thread Safety
- Helpers
ValidationError
- Common
- Linux Kernel
- Bitmaps
- Bit Operations
- Block Layer
- Boot
- BPF
- Cgroup
- CPU Masks
- Devices
- Virtual Filesystem Layer
- IDR
- Kallsyms
- Kconfig
- Kernfs
- Kernel Threads
- Linked Lists
- Nulls Lists
- Lockless Lists
- Maple Trees
- Memory Management
- Modules
- Networking
- NUMA Node Masks
- Per-CPU
- Process IDS
- Priority-Sorted Lists
- Log Buffer
- Radix Trees
- Red-Black Trees
- CPU Scheduler
- Slab Allocator
- Stack Depot
- Traffic Control (TC)
- TCP
- Timekeeping
- Users
- Wait Queues
- XArrays
- Experimental
- Commands
- Crash Compatibility
- Man Page
- Support Matrix
- Release Highlights
- 0.0.32 (Released June 18th, 2025)
- 0.0.31 (Released April 16th, 2025)
- 0.0.30 (Released December 18th, 2024)
- 0.0.28 & 0.0.29 (Released October 7th & 8th, 2024)
- 0.0.27 (Released July 1st, 2024)
- 0.0.26 (Released March 11th, 2024)
- 0.0.25 (Released December 1st, 2023)
- 0.0.24 (Released September 8th, 2023)
- 0.0.23 (Released June 28th, 2023)
- 0.0.22 (Released January 5th, 2023)