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¶
- Installation
- User Guide
- Advanced Usage
- API Reference
- Helpers
ValidationError
- Common
- Experimental
- Linux Kernel
- Bit Operations
- Block Layer
- Boot
- BPF
- Cgroup
- CPU Masks
- Devices
- Virtual Filesystem Layer
- IDR
- Kconfig
- Kernfs
- 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
- Users
- Wait Queues
- XArrays
- Support Matrix
- Case Studies
- Getting Debugging Symbols
- Release Highlights