This is a surprising place where file references can be hiding that I've
run into before. There are some beginnings of an lsof-like script here.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
It's difficult to automatically detect calling an invalid, non-NULL
pointer when getting a stack trace. This manually recreates what we do
for calls to NULL since commit 412ce956b0 ("libdrgn: x86_64: unwind
call when pc is 0"). This was used to debug the issue fixed by "net:
tcp: fix crashes trying to free half-baked MTU probes" [1].
1: https://lore.kernel.org/all/20231010173651.3990234-1-kuba@kernel.org/T/
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Completion of drgn Objects *is* already possible in ptpython, but
unfortunately the list of completions is alphabetical (except for
underscored attributes, which are last). This means that default Object
fields like "absent_" and "type_" are not distinguished from the Object
member fields.
Resolve this by detecting when the first completion is "absent_" and
then moving all the non-default completions to the beginning of the
list. The result is that Object members are enumerated first, followed
by the default Object fields.
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
ptpython is a really excellent REPL library which provides great
multiline history and editing support, as well as syntax highlighting,
and a nice code completion UI.
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Enhanced the `ps.py` script and made it more modular to support the
following options:
[-a | --active] thread on each CPU
[-c | --childs] processes info
[--cpus] Ready/running proccesses for the given cpu
[-d | --detailed] information (in addition to standard)
[--hierarchy] of all parent processes
[-k | --kthread] information on the given kernel threads
[-u | --uthread] information on the given user-space threads
[-t | --threads] information on the given threads
These options make the scipt more versatile and useful.
Signed-off-by: Jay Patel <jaypatel@linux.ibm.com>
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
Signed-off-by: Piyush Sachdeva <piyushs@linux.ibm.com>
btrfs_tree.py is a pile of helpers Omar gave me once that I have
cherished ever since. It mostly deals with walking and parsing btrees.
btrfs_tree_mod_log.py is a script I wrote to do a tree mod log search
and rewind while debugging a btrfs issue.
Signed-off-by: Boris Burkov <boris@bur.io>
Since Linux kernel commit 8dbd76e79a16 ("tcp/dccp: fix possible race
__inet_lookup_established()") (in v5.5), it's actually hlist_nulls_head
what is used for items of inet_hashinfo::listening_hash. This commit was
also backported to stable kernels, so with the change it works for all
releases starting with v4.9. The version 4.4 is not supported right now
(nulls head list is probably not known at the time).
Fixes: #268
Signed-off-by: Martin Liska <mliska@suse.cz>
This script mimics crash>sys and provides the following output:
CPUS 16
DATE Fri Jan 27 20:26:24 2023
UPTIME 1 day, 7:29:37
LOAD AVERAGE 0.00, 0.00, 0.00
TASKS 317
NODENAME tw
RELEASE 6.1.7-1-default
VERSION #1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE x86_64
MEMORY 12.67 GiB
Signed-off-by: Martin Liska <mliska@suse.cz>
Since Linux kernel commit cae3873c5b3a ("net: inet: Retire port only
listening_hash") (in v5.19), listening_hash is removed and we need
to iterate lhash2 table.
The script reports now:
LISTEN [::]:22 [::]:0 /system.slice/sshd.service
LISTEN 0.0.0.0:22 0.0.0.0:0 /system.slice/sshd.service
LISTEN [::1]:631 [::]:0 /system.slice/cups.service
LISTEN 127.0.0.1:25 0.0.0.0:0 /system.slice/postfix.service
LISTEN [::1]:25 [::]:0 /system.slice/postfix.service
LISTEN 127.0.0.1:631 0.0.0.0:0 /system.slice/cups.service
ESTABLISHED 192.168.122.99:22 192.168.122.1:45906 /system.slice/sshd.service
ESTABLISHED 192.168.122.99:22 192.168.122.1:48066 /system.slice/sshd.service
ESTABLISHED 192.168.122.99:22 192.168.122.1:41128 /system.slice/sshd.service
Signed-off-by: Martin Liska <mliska@suse.cz>
New output:
PID PPID CPU ST COMM
1 0 4 S systemd
2 0 13 S [kthreadd]
3 2 0 I [rcu_gp]
4 2 0 I [rcu_par_gp]
5 2 0 I [slub_flushwq]
6 2 0 I [netns]
8 2 0 I [kworker/0:0H]
10 2 0 I [mm_percpu_wq]
11 2 0 I [rcu_tasks_kthre]
...
Signed-off-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Omar Sandoval <osandov@osandov.com>
When inode_path returns None and it's passed to fsdecode,
I get TypeError exception:
```
File "/usr/lib64/python3.10/os.py", line 823, in fsdecode
filename = fspath(filename) # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType
```
Thus catch both exception types.
Signed-off-by: Martin Liska <mliska@suse.cz>
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>