mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 09:43:06 +00:00
a0a54edc1f
It's come up several times that it'd be nice to have somewhere to dump drgn scripts that people write while debugging without requiring them to be cleaned up and scrutinized in code review. Serapheim Dimitropoulos noted that several projects have a "contrib" directory for this purpose. See [1]. Let's create one, document it, exclude it from pre-commit, and move our (mostly unmaintained) examples there. 1: https://drewdevault.com/2020/06/06/Add-a-contrib-directory.html Signed-off-by: Omar Sandoval <osandov@osandov.com>
14 lines
381 B
Python
Executable File
14 lines
381 B
Python
Executable File
#!/usr/bin/env drgn
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
"""A simplified implementation of ps(1) using drgn"""
|
|
|
|
from drgn.helpers.linux.pid import for_each_task
|
|
|
|
print("PID COMM")
|
|
for task in for_each_task(prog):
|
|
pid = task.pid.value_()
|
|
comm = task.comm.string_().decode()
|
|
print(f"{pid:<10} {comm}")
|