fprintf: Make typedef__fprintf print anonymous structs

For instance, the Dwarf_Op typedef was found but since it is an
anonymous struct we get:

  $ pahole -C Dwarf_Op build/pahole
  typedef struct  Dwarf_Op;
  $

Which is not useful, fix it:

  $ pahole -C Dwarf_Op build/pahole
  typedef struct {
  	uint8_t                    atom;                 /*     0     1 */

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

  	Dwarf_Word                 number;               /*     8     8 */
  	Dwarf_Word                 number2;              /*    16     8 */
  	Dwarf_Word                 offset;               /*    24     8 */

  	/* size: 32, cachelines: 1, members: 4 */
  	/* sum members: 25, holes: 1, sum holes: 7 */
  	/* last cacheline: 32 bytes */
  } Dwarf_Op;
  $

Reported-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2020-11-19 10:32:00 -03:00
parent 4a1479305b
commit 932b84eb45
1 changed files with 7 additions and 3 deletions

View File

@ -181,6 +181,8 @@ size_t tag__fprintf_decl_info(const struct tag *tag,
return 0;
}
static size_t __class__fprintf(struct class *class, const struct cu *cu,
const struct conf_fprintf *conf, FILE *fp);
static size_t type__fprintf(struct tag *type, const struct cu *cu,
const char *name, const struct conf_fprintf *conf,
FILE *fp);
@ -316,6 +318,11 @@ size_t typedef__fprintf(const struct tag *tag, const struct cu *cu,
return fprintf(fp, "typedef struct %s %s",
type__name(ctype, cu),
type__name(type, cu));
struct conf_fprintf tconf = *pconf;
tconf.suffix = type__name(type, cu);
return fprintf(fp, "typedef ") + __class__fprintf(tag__class(tag_type), cu, &tconf, fp);
}
}
@ -595,9 +602,6 @@ static size_t type__fprintf_stats(struct type *type, const struct cu *cu,
static size_t union__fprintf(struct type *type, const struct cu *cu,
const struct conf_fprintf *conf, FILE *fp);
static size_t __class__fprintf(struct class *class, const struct cu *cu,
const struct conf_fprintf *conf, FILE *fp);
static size_t type__fprintf(struct tag *type, const struct cu *cu,
const char *name, const struct conf_fprintf *conf,
FILE *fp)