fprintf: Fixup const pointers

Before:

  $ pahole -C nft_ctx /home/acme/git/build/v5.1-rc4+/net/netfilter/nft_set_rbtree.o
  struct nft_ctx {
          struct net *               net;                  /*     0     8 */
          struct nft_table *         table;                /*     8     8 */
          struct nft_chain *         chain;                /*    16     8 */
          const const struct nlattr  *  * nla;             /*    24     8 */
          u32                        portid;               /*    32     4 */
          u32                        seq;                  /*    36     4 */
          u8                         family;               /*    40     1 */
          u8                         level;                /*    41     1 */
          bool                       report;               /*    42     1 */

          /* size: 48, cachelines: 1, members: 9 */
          /* padding: 5 */
          /* last cacheline: 48 bytes */
  };
  $

Original:

  struct nft_ctx {
          struct net                      *net;
          struct nft_table                *table;
          struct nft_chain                *chain;
          const struct nlattr * const     *nla;
          u32                             portid;
          u32                             seq;
          u8                              family;
          u8                              level;
          bool                            report;
  };

DWARF tags:

 <1><12c8a>: Abbrev Number: 12 (DW_TAG_structure_type)
    <12c8b>   DW_AT_name        : (indirect string, offset: 0xcc6f): nlattr
    <12c8f>   DW_AT_byte_size   : 4
    <12c93>   DW_AT_sibling     : <0x12cb2>

 <1><12cb2>: Abbrev Number: 17 (DW_TAG_const_type)
    <12cb3>   DW_AT_type        : <0x12c8a>

 <1><12cf9>: Abbrev Number: 4 (DW_TAG_pointer_type)
    <12cfa>   DW_AT_byte_size   : 8
    <12cfb>   DW_AT_type        : <0x12cb2>

 <1><12cff>: Abbrev Number: 17 (DW_TAG_const_type)
    <12d00>   DW_AT_type        : <0x12cf9>

 <1><1d54b>: Abbrev Number: 4 (DW_TAG_pointer_type)
    <1d54c>   DW_AT_byte_size   : 8
    <1d54d>   DW_AT_type        : <0x12cff>

 <2><1e52e>: Abbrev Number: 14 (DW_TAG_member)
    <1e52f>   DW_AT_name        : nla
    <1e536>   DW_AT_type        : <0x1d54b>
    <1e53a>   DW_AT_data_member_location: 24

Fixed now:

  $ pahole -C nft_ctx /home/acme/git/build/v5.1-rc4+/net/netfilter/nft_set_rbtree.o
  struct nft_ctx {
          struct net *               net;                  /*     0     8 */
          struct nft_table *         table;                /*     8     8 */
          struct nft_chain *         chain;                /*    16     8 */
          const struct nlattr  * const * nla;              /*    24     8 */
          u32                        portid;               /*    32     4 */
          u32                        seq;                  /*    36     4 */
          u8                         family;               /*    40     1 */
          u8                         level;                /*    41     1 */
          bool                       report;               /*    42     1 */

          /* size: 48, cachelines: 1, members: 9 */
          /* padding: 5 */
          /* last cacheline: 48 bytes */
  };
  $

So, one more full circled:

  $ fullcircle /home/acme/git/build/v5.1-rc4+/net/netfilter/nft_set_rbtree.o
  $

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2019-04-12 12:07:46 -03:00
parent dc3d441961
commit 1bb4527220
1 changed files with 12 additions and 1 deletions

View File

@ -406,10 +406,21 @@ static const char *tag__ptr_name(const struct tag *tag, const struct cu *cu,
snprintf(bf + l, len - l, " %s", ptr_suffix);
} else if (!tag__has_type_loop(tag, type, bf, len, NULL)) {
char tmpbf[1024];
const char *const_pointer = "";
snprintf(bf, len, "%s %s",
if (tag__is_const(type)) {
struct tag *next_type = cu__type(cu, type->type);
if (next_type && tag__is_pointer(next_type)) {
const_pointer = "const ";
type = next_type;
}
}
snprintf(bf, len, "%s %s%s",
__tag__name(type, cu,
tmpbf, sizeof(tmpbf), NULL),
const_pointer,
ptr_suffix);
}
}