Skip to main content

Programmable debugger

Project description

PyPI CI Status Documentation Status black badge

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.

Documentation can be found at drgn.readthedocs.io.

Installation

Package Manager

drgn can be installed using the package manager on some Linux distributions.

Packaging Status
  • Fedora, RHEL/CentOS Stream >= 9

    $ sudo dnf install drgn
  • RHEL/CentOS < 9

    Enable EPEL. Then:

    $ sudo dnf install drgn
  • Oracle Linux >= 8

    Enable the ol8_addons or ol9_addons repository. Then:

    $ sudo dnf config-manager --enable ol8_addons  # OR: ol9_addons
    $ sudo dnf install drgn

    drgn is also available for Python versions in application streams. For example, use dnf install python3.12-drgn to install drgn for Python 3.12. See the documentation for drgn in Oracle Linux 9 and Oracle Linux 8 for more information.

  • Debian >= 12 (Bookworm)/Ubuntu >= 24.04 (Noble Numbat)

    $ sudo apt install python3-drgn

    To get the latest version on Ubuntu, enable the michel-slm/kernel-utils PPA first.

  • Arch Linux

    $ sudo pacman -S drgn
  • Gentoo

    $ sudo emerge dev-debug/drgn
  • openSUSE

    $ sudo zypper install python3-drgn

pip

If your Linux distribution doesn’t package the latest release of drgn, you can install it with pip.

First, install pip. Then, run:

$ sudo pip3 install drgn

This will install a binary wheel by default. If you get a build error, then pip wasn’t able to use the binary wheel. Install the dependencies listed below and try again.

Note that RHEL/CentOS 7, Debian 10 (“buster”), and Ubuntu 18.04 (“Bionic Beaver”) (and older) ship Python versions which are too old. Python 3.8 or newer must be installed.

From Source

To get the development version of drgn, you will need to build it from source. First, install dependencies:

  • Fedora, RHEL/CentOS Stream >= 9

    $ sudo dnf install autoconf automake check-devel elfutils-debuginfod-client-devel elfutils-devel gcc git json-c-devel libkdumpfile-devel libtool make pcre2-devel pkgconf python3 python3-devel python3-pip python3-setuptools xz-devel
  • RHEL/CentOS < 9, Oracle Linux

    $ sudo dnf install autoconf automake check-devel elfutils-devel gcc git json-c-devel libtool make pcre2-devel pkgconf python3 python3-devel python3-pip python3-setuptools xz-devel

    Optionally, install libkdumpfile-devel from EPEL on RHEL/CentOS >= 8 or install libkdumpfile from source if you want support for the makedumpfile format. For Oracle Linux >= 7, libkdumpfile-devel can be installed directly from the corresponding addons repository (e.g. ol9_addons).

    Replace dnf with yum for RHEL/CentOS/Oracle Linux < 8.

    When building on RHEL/CentOS/Oracle Linux < 8, you may need to use a newer version of GCC, for example, using the devtoolset-12 developer toolset. Check your distribution’s documentation for information on installing and using these newer toolchains.

  • Debian/Ubuntu

    $ sudo apt install autoconf automake check gcc git libdebuginfod-dev libjson-c-dev libkdumpfile-dev liblzma-dev libelf-dev libdw-dev libpcre2-dev libtool make pkgconf python3 python3-dev python3-pip python3-setuptools zlib1g-dev

    On Debian <= 11 (Bullseye) and Ubuntu <= 22.04 (Jammy Jellyfish), libkdumpfile-dev is not available, so you must install libkdumpfile from source if you want support for the makedumpfile format.

  • Arch Linux

    $ sudo pacman -S --needed autoconf automake check gcc git json-c libelf libkdumpfile libtool make pcre2 pkgconf python python-pip python-setuptools xz
  • Gentoo

    $ sudo emerge --noreplace --oneshot dev-build/autoconf dev-build/automake dev-libs/check dev-libs/elfutils dev-libs/json-c dev-libs/libpcre2 sys-devel/gcc dev-vcs/git dev-libs/libkdumpfile dev-build/libtool dev-build/make dev-python/pip virtual/pkgconfig dev-lang/python dev-python/setuptools app-arch/xz-utils
  • openSUSE

    $ sudo zypper install autoconf automake check-devel gcc git libdebuginfod-devel libdw-devel libelf-devel libjson-c-devel libkdumpfile-devel libtool make pcre2-devel pkgconf python3 python3-devel python3-pip python3-setuptools xz-devel

Then, run:

$ git clone https://github.com/osandov/drgn.git
$ cd drgn
$ python3 setup.py build
$ sudo python3 setup.py install

See the installation documentation for more options.

Quick Start

drgn debugs the running kernel by default; simply run drgn. To debug a running program, run drgn -p $PID. To debug a core dump (either a kernel vmcore or a userspace core dump), run drgn -c $PATH. Make sure to install debugging symbols for whatever you are debugging.

Then, you can access variables in the program with prog["name"] and access structure members with .:

$ drgn
>>> prog["init_task"].comm
(char [16])"swapper/0"

You can use various predefined helpers:

>>> len(list(bpf_prog_for_each()))
11
>>> task = find_task(115)
>>> cmdline(task)
[b'findmnt', b'-p']

You can get stack traces with stack_trace() and access parameters or local variables with trace["name"]:

>>> trace = stack_trace(task)
>>> trace[5]
#5 at 0xffffffff8a5a32d0 (do_sys_poll+0x400/0x578) in do_poll at ./fs/select.c:961:8 (inlined)
>>> poll_list = trace[5]["list"]
>>> file = fget(task, poll_list.entries[0].fd)
>>> d_path(file.f_path.address_of_())
b'/proc/115/mountinfo'

See the user guide for more details and features.

Getting Help

License

Copyright (c) Meta Platforms, Inc. and affiliates.

drgn is licensed under the LGPLv2.1 or later.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drgn-0.2.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

drgn-0.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

drgn-0.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

drgn-0.2.0-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.1 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ x86-64

drgn-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

drgn-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

drgn-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

drgn-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

drgn-0.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

drgn-0.2.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (10.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

drgn-0.2.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file drgn-0.2.0.tar.gz.

File metadata

  • Download URL: drgn-0.2.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for drgn-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6940ccd06f435b44a0d27864359eda9c8c3e4c5ceaf8f43cf994280796f3296c
MD5 90be23756e5c86b5c9a5ac26bc22ca02
BLAKE2b-256 404594db62a757575c31df3d71fc326e5aba41f4ad7734a1be6b288dac8bbf17

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bf93ed3d4a1fcb313419a984c4ea8dc4325bdadda291c98941bc8a4a57f940b0
MD5 31ce931fc687e8f6db44740584a33b06
BLAKE2b-256 877c9fcaa59ea1ff3b2d63b03bd2142fcbe582c1743dc68a753363e8213328df

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d13b639a01a7603534fb76911ec5d89ea0a6b9a6e710e2af474c86b2b20c47b2
MD5 62d77c53c8e484e989c46eaeafcc12e3
BLAKE2b-256 5bcfabce70ef3cc69be406ea13d4727a9b8db50b8b18c17d70c3f9ce5b24a2ae

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6cacc069933e9a1897906d2a3b6f122b0ba0dd6478a30b41042302d4bfbb4445
MD5 a0e1571f74c7b2729456bca9ed191594
BLAKE2b-256 8dd26fe0dffcbaf1c93b434fc4285f0935a997de96ccf228aff178fad07675d5

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 bf52317e28224ca4241b5394f1cf91c6faa8227b3e9b0232e16b3064f80b0d5a
MD5 cd97f9dce451a58a711353fc04bbf8b5
BLAKE2b-256 3216816cd1ad381edfd34627c26b76751e5526a356223fc77b51a2083d509892

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 19b7d053cc58646226c91ae914f7309074c5ebe8fa1bd5f81fc31ad849b146c2
MD5 8676721c6f81bd1388052013889d5a09
BLAKE2b-256 0b16e0bf1a7496ce94c01f1fc0f455231165fe9c89482483f685ba837db64248

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9cf8cc33769e6d0ee4f0fc5577871b313806ae3271b00a23bc2f25524f190009
MD5 ed8460761e5ea820972066a639b62dbc
BLAKE2b-256 5954b67a9fc6ca67906a29e7f333b48ba04fc73003db7a8f659a3045ea50fd62

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2ceb731f7ef8aa702295f2b412c0af0cc0d04a18fc9af8663a930234550e5d39
MD5 4b509a69d9ddffa94b4f0a7af0e68efa
BLAKE2b-256 96b63593ae276fbe24419376daf7c9773ae9bf29e247d8e683a5f567ad832e88

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 af514b16abc0ff6e5e4c754c3a502a08acc152692dfb97e02c8f7f320a4c7e4b
MD5 a6d591d6270fd050b7fd8ac95a64ffcc
BLAKE2b-256 99cefaf57a0584f505cdeb172c74fabd79ab35dda33fad06dca6a3d174a702d1

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 19247a02d0b6c6cdc42e509288f2aad992446edd2a0ccdb70146d9a1306730ef
MD5 baf6659a6ae58b4b70cbef1689a8239e
BLAKE2b-256 05be5cb82792dad1391d4e023280d57da285430f0c744ee76cbf858f712cc5ce

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c67961e04e337c55d9dd72c883e82ae737722252b8904d2b06ad6b5d787d9946
MD5 242d55bff37b83a15da26343fe929116
BLAKE2b-256 24130b9ea5d0d525f601f3288b56bbf1c927f98eb683701edccc8544df0fc2b1

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1fc34efadff37ec9b153a103c6efe4e49f9edb745423a90e8d5ed47ef2238713
MD5 0f26e5a655ae8be252f045b7643793f7
BLAKE2b-256 d0fb61b4179d689f5e569d6626084e499d174732593fa772e1ea333f58e40462

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 2e90cd31df9e5234c702634a436f83ea2beaa53f2db4a7c65d21b1dd11845ddc
MD5 ed21fed3f0e30091b182690ab2d583c8
BLAKE2b-256 5273372e10e1d4aebe2beb9feec331b18d45a991cce27d632e1ad8aba019c874

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5563a5e2c4715340d4ce4b996c61ae714ab0fb1725e0fbc065964b321878cb8a
MD5 fe56a3fd80a12904eb04f3c715c66009
BLAKE2b-256 7e6e539045efbbfd787a14118ca1463458aefc1d59511398ad8645a505bac848

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 71945cd290086aac9aa9f6cdbbdbfd423b2bb53aa27367c575c9cdee9f99dafc
MD5 c194f335536639f8d79fe817f9db941c
BLAKE2b-256 6dd248ea887cdb3ed7153d0cea9337c06c3c17c165e9db5542472bac52caaf71

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e568675538e8cffbcd002189016a9f5f9885868c4d846545194df0d888d2e0d4
MD5 f276409e6609203c159347b203612a9a
BLAKE2b-256 5b00cdc3ed83f5e3d0f6e53739d4dc07782a0136b7826bbe1e12f62ab71d3c31

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 b5e0771969e28e2491050eb4dc6abeb4ef12ff714df0e3a24325ce7eff41479e
MD5 6059ffcc58cb38cbba3bd2a711f5ca1b
BLAKE2b-256 3a8ae271f3e0355c1353c7b34f7d4741a1f36ad2e599b3ff25998bde215a5766

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9b15d3e37bcd902157fdc65e5e65f8495b5b056eb1bbdf9dd6977da26f90357f
MD5 237ed2d5280b793f21a4b3ececec4831
BLAKE2b-256 84ce53b100c52800a61a84a55ab627fcbbe8d0cfb2cdeb873acd20e7c38f7111

See more details on using hashes here.

File details

Details for the file drgn-0.2.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for drgn-0.2.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 54e01ce14047d0f5234af2eed547518b1bb5095f7aae00aad6213a119fd02345
MD5 09ee420d6af74541ea84e71f60a22980
BLAKE2b-256 996b2fcade56c2fdea212ab6bad0728881121a31323e95d391f1559a66235527

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page