fprintf: Print relative offsets for inner pointer structs

I.e. before:

      $ pahole -C parsed_partitions /home/acme/git/build/v5.1-rc4+/block/partitions/check.o > a.c ; head -29 a.c
      struct parsed_partitions {
            struct block_device * bdev;                      /*     0     8 */
            char                       name[32];             /*     8    32 */
            struct {
                    sector_t           from;                 /*    40     8 */
                    sector_t           size;                 /*    48     8 */
                    int                flags;                /*    56     4 */
                    bool               has_info;             /*    60     1 */
                    struct partition_meta_info info;         /*    61   101 */
            } * parts; /*    40     8 */
            int                        next;                 /*    48     4 */
            int                        limit;                /*    52     4 */
            bool                       access_beyond_eod;    /*    56     1 */

            /* XXX 7 bytes hole, try to pack */

            /* --- cacheline 1 boundary (64 bytes) --- */
            char *                     pp_buf;               /*    64     8 */

            /* size: 72, cachelines: 2, members: 7 */
            /* sum members: 65, holes: 1, sum holes: 7 */
            /* last cacheline: 8 bytes */
      };
      $

Now:

  $ pahole -C parsed_partitions /home/acme/git/build/v5.1-rc4+/block/partitions/check.o
  struct parsed_partitions {
  	struct block_device * bdev;                      /*     0     8 */
  	char                       name[32];             /*     8    32 */
  	struct {
  		sector_t           from;                 /*     0     8 */
  		sector_t           size;                 /*     8     8 */
  		int                flags;                /*    16     4 */
  		bool               has_info;             /*    20     1 */
  		struct partition_meta_info info;         /*    21   101 */
  	} * parts; /*    40     8 */
  	int                        next;                 /*    48     4 */
  	int                        limit;                /*    52     4 */
  	bool                       access_beyond_eod;    /*    56     1 */

  	/* XXX 7 bytes hole, try to pack */

  	/* --- cacheline 1 boundary (64 bytes) --- */
  	char *                     pp_buf;               /*    64     8 */

  	/* size: 72, cachelines: 2, members: 7 */
  	/* sum members: 65, holes: 1, sum holes: 7 */
  	/* last cacheline: 8 bytes */
  };
  $

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2019-04-16 14:39:51 -03:00
parent cfa377c238
commit 30526e2848
1 changed files with 1 additions and 0 deletions

View File

@ -703,6 +703,7 @@ next_type:
if (tag__is_struct(ptype) || tag__is_union(ptype) ||
tag__is_enumeration(ptype)) {
snprintf(namebfptr, sizeof(namebfptr), "* %s", name);
tconf.rel_offset = 1;
name = namebfptr;
type = ptype;
goto inner_struct;