drgn
drgn copied to clipboard
example not working
this example in your article is not working: https://developers.facebook.com/blog/post/2021/12/09/drgn-how-linux-kernel-team-meta-debugs-kernel-scale/
What am I missing?
>>> path_lookup(prog, "/etc/hosts")
(struct path){
.mnt = (struct vfsmount *)0xffff9806008557e0,
.dentry = (struct dentry *)0xffff980601678900,
}
I got this error:
>>> path_lookup(prog, "/etc/hosts")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/........./site-packages/drgn/helpers/linux/fs.py", line 103, in path_lookup
prog_or_root = prog_or_root["init_task"].fs.root
AttributeError: 'struct fs_struct' has no member 'root'
>>> prog["init_task"].fs
(struct fs_struct *)init_fs+0x0 = 0xffffffffba877ae0
>>> prog["init_task"].fs.root
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'struct fs_struct' has no member 'root'
>>> prog.type("struct fs_struct")
struct fs_struct {
int users;
spinlock_t lock;
seqcount_spinlock_t seq;
int umask;
int in_exec;
struct path root;
struct path pwd;
}
I have a suspicion of what's happening here. Can you run drgn with --main-symbols and see if this still happens?
Additionally, if you are able to build drgn from source, can you please test the issue-186-hack branch that I just pushed? To do that, install the dependencies listed here: https://github.com/osandov/drgn#from-source and run
$ git clone https://github.com/osandov/drgn.git -b issue-186-hack
$ cd drgn
$ python3 setup.py build_ext -i
$ sudo python3 -Bm drgn
>>> path_lookup(prog, "/etc/hosts")
If these work, it may be that some external kernel module that was built in a different location from the base kernel is confusing drgn into thinking that there are two definitions of struct fs_struct. If that's the case, I'll have to improve drgn's heuristic.
if using '--main-symbols', it started working on one host with different kernel version, output shown below (but it still failed on another host even with this flag in place):
>>> path_lookup(prog, "/etc/hosts")
(struct path){
.mnt = (struct vfsmount *)0xffff912771561ca0,
.dentry = (struct dentry *)0xffff91226005ad80,
}
on the still failed host, after trying the above 'issue-186-hack' branch, then this is working on that host. So it seems this is a fix for this one?