aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2020-01-14 14:04:09 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2020-01-14 14:04:09 -0300
commitdcba200367f7475b7a4794d35eb14efca8a69052 (patch)
tree93b3354c480a00db758687d7cd402fe2a53ad477
parent1944de0c93e6ff3f6807ef2d2157c77d00ef0f76 (diff)
downloadpahole-dcba200367f7475b7a4794d35eb14efca8a69052.tar.gz
pahole: When the sole argument passed isn't a file, take it as a class name
With that it becomes as compact as it gets for kernel data structures, just state the name of the struct and it'll try to find that as a file, not being a file it'll use /sys/kernel/btf/vmlinux and the argument as a list of structs, i.e.: $ pahole skb_ext,list_head struct list_head { struct list_head * next; /* 0 8 */ struct list_head * prev; /* 8 8 */ /* size: 16, cachelines: 1, members: 2 */ /* last cacheline: 16 bytes */ }; struct skb_ext { refcount_t refcnt; /* 0 4 */ u8 offset[3]; /* 4 3 */ u8 chunks; /* 7 1 */ char data[]; /* 8 0 */ /* size: 8, cachelines: 1, members: 4 */ /* last cacheline: 8 bytes */ }; $ pahole hlist_node struct hlist_node { struct hlist_node * next; /* 0 8 */ struct hlist_node * * pprev; /* 8 8 */ /* size: 16, cachelines: 1, members: 2 */ /* last cacheline: 16 bytes */ }; $ Of course -C continues to work: $ pahole -C inode | tail __u32 i_fsnotify_mask; /* 556 4 */ struct fsnotify_mark_connector * i_fsnotify_marks; /* 560 8 */ struct fscrypt_info * i_crypt_info; /* 568 8 */ /* --- cacheline 9 boundary (576 bytes) --- */ struct fsverity_info * i_verity_info; /* 576 8 */ void * i_private; /* 584 8 */ /* size: 592, cachelines: 10, members: 53 */ /* last cacheline: 16 bytes */ }; $ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--pahole.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/pahole.c b/pahole.c
index b7fc5a9..f843163 100644
--- a/pahole.c
+++ b/pahole.c
@@ -1280,9 +1280,6 @@ int main(int argc, char *argv[])
goto out;
}
- if (class_name && populate_class_names())
- goto out_dwarves_exit;
-
struct cus *cus = cus__new();
if (cus == NULL) {
fputs("pahole: insufficient memory\n", stderr);
@@ -1291,8 +1288,17 @@ int main(int argc, char *argv[])
conf_load.steal = pahole_stealer;
+try_sole_arg_as_class_names:
+ if (class_name && populate_class_names())
+ goto out_dwarves_exit;
+
err = cus__load_files(cus, &conf_load, argv + remaining);
if (err != 0) {
+ if (class_name == NULL) {
+ class_name = argv[remaining];
+ remaining = argc;
+ goto try_sole_arg_as_class_names;
+ }
cus__fprintf_load_files_err(cus, "pahole", argv + remaining, err, stderr);
goto out_cus_delete;
}