pahole: Show tagged enums as well when no class is specified

The pahole tool initial goal was to show struct holes, which can't
happen with a first level of a tagged union (a union with a name),
so those only were displayed when part of a higher level struct.

Show the first level tagged enums as well, as this is useful when just
wanting to see its members.

E.g.:

  $ pahole ../build/v4.20-rc5/net/core/sock.o | grep ^union
  union fpregs_state {
  union irq_stack_union {
  union sigval {
  union __sifields {
  union thread_union {
  union kernfs_node_id {
  union flowi_uli {
  union ethtool_flow_union {
  union key_payload {
  union bpf_attr {
  union tcp_md5_addr {
  $

Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2018-12-03 12:51:30 -03:00
parent b18354f64c
commit 31664d60ad
2 changed files with 15 additions and 1 deletions

View File

@ -267,6 +267,20 @@ static inline __pure bool cu__is_c_plus_plus(const struct cu *cu)
continue; \
else
/**
* cu__for_each_struct_or_union - iterate thru all the struct and union tags
* @cu: struct cu instance to iterate
* @pos: struct class iterator
* @id: uint16_t tag id
*/
#define cu__for_each_struct_or_union(cu, id, pos) \
for (id = 1; id < cu->types_table.nr_entries; ++id) \
if (!(pos = tag__class(cu->types_table.entries[id])) || \
!(tag__is_struct(class__tag(pos)) || \
tag__is_union(class__tag(pos)))) \
continue; \
else
/**
* cu__for_each_function - iterate thru all the function tags
* @cu: struct cu instance to iterate

View File

@ -279,7 +279,7 @@ static void print_classes(struct cu *cu)
uint16_t id;
struct class *pos;
cu__for_each_struct(cu, id, pos) {
cu__for_each_struct_or_union(cu, id, pos) {
bool existing_entry;
struct structure *str;