aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2020-01-15 12:41:28 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2020-01-15 12:41:28 -0300
commit88d99562e55c5ef8b93fb3755ab3fb8687f6864b (patch)
treeec96db50a79c49b8cc0b4f3aed875eba44c6cf0a
parent0b444cf1118cc15f68861f5d3017df9cc2289b18 (diff)
downloadpahole-88d99562e55c5ef8b9.tar.gz
pahole: Add --structs to ask just for structs, counterpart of --unions
The default is to show structs and unions, if just structs should be considered, use --structs, just don't use it together with --unions or nothing will be shown 8-) $ pahole --find_pointers_to ehci_qh ehci_hcd: qh_scan_next ehci_hcd: async ehci_hcd: dummy ehci_shadow: qh $ pahole --structs --find_pointers_to ehci_qh ehci_hcd: qh_scan_next ehci_hcd: async ehci_hcd: dummy $ pahole --unions --find_pointers_to ehci_qh ehci_shadow: qh $ pahole --structs --unions --find_pointers_to ehci_qh $ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--man-pages/pahole.15
-rw-r--r--pahole.c14
2 files changed, 18 insertions, 1 deletions
diff --git a/man-pages/pahole.1 b/man-pages/pahole.1
index 29966da..6a14ffd 100644
--- a/man-pages/pahole.1
+++ b/man-pages/pahole.1
@@ -219,6 +219,11 @@ Include PREFIXed classes.
Show only structs with at least one hole greater or equal to HOLE_SIZE.
.TP
+.B \-\-structs
+Show only structs, all the other filters apply, i.e. to show just the sizes of all structs
+coimbine --structs with --sizes, etc.
+
+.TP
.B \-\-unions
Show only unions, all the other filters apply, i.e. to show just the sizes of all unions
coimbine --union with --sizes, etc.
diff --git a/pahole.c b/pahole.c
index 508ce7f..a1f6a6b 100644
--- a/pahole.c
+++ b/pahole.c
@@ -54,6 +54,7 @@ static int reorganize;
static bool show_private_classes;
static bool defined_in;
static bool just_unions;
+static bool just_structs;
static int show_reorg_steps;
static char *class_name;
static struct strlist *class_names;
@@ -363,6 +364,9 @@ static struct class *class__filter(struct class *class, struct cu *cu,
if (just_unions && !tag__is_union(tag))
return NULL;
+ if (just_structs && !tag__is_struct(tag))
+ return NULL;
+
if (!tag->top_level) {
class__find_holes(class);
@@ -426,7 +430,7 @@ static struct class *class__filter(struct class *class, struct cu *cu,
* that need finding holes, like --packable, --nr_holes, etc
*/
if (!tag__is_struct(tag))
- return (show_packable || nr_holes || nr_bit_holes || hole_size_ge) ? NULL : class;
+ return (just_structs || show_packable || nr_holes || nr_bit_holes || hole_size_ge) ? NULL : class;
if (tag->top_level)
class__find_holes(class);
@@ -773,6 +777,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
#define ARGP_suppress_force_paddings 307
#define ARGP_suppress_packed 308
#define ARGP_just_unions 309
+#define ARGP_just_structs 310
static const struct argp_option pahole__options[] = {
{
@@ -1016,6 +1021,11 @@ static const struct argp_option pahole__options[] = {
.doc = "Encode as BTF",
},
{
+ .name = "structs",
+ .key = ARGP_just_structs,
+ .doc = "Show just structs",
+ },
+ {
.name = "unions",
.key = ARGP_just_unions,
.doc = "Show just unions",
@@ -1109,6 +1119,8 @@ static error_t pahole__options_parser(int key, char *arg,
conf.hex_fmt = 1; break;
case ARGP_just_unions:
just_unions = true; break;
+ case ARGP_just_structs:
+ just_structs = true; break;
default:
return ARGP_ERR_UNKNOWN;
}