diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-13 14:40:24 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-13 14:40:24 -0300 |
commit | afca84ff989d97292fd79077439cbf303a8f755e (patch) | |
tree | f198a78cab6354befb009b4de65c0b66f9e3f31f | |
parent | cb7eb753694be3e8aef45ec16ad27708c725eeca (diff) | |
download | dwarves-afca84ff989d97292fd79077439cbf303a8f755e.tar.gz |
fprintf: Add DW_TAG_constant pretty printer (constant__fprintf)
Will be used by pdwtags and then by pahole.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | dwarves_fprintf.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index 818db2d..ef8b82b 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -1930,6 +1930,24 @@ static size_t variable__fprintf(const struct tag *tag, const struct cu *cu, return printed; } +static size_t constant__fprintf(const struct tag *tag, const struct cu *cu, + const struct conf_fprintf *conf, FILE *fp) +{ + struct constant *constant = tag__constant(tag); + const char *name = constant__name(constant); + size_t printed = 0; + + if (name != NULL) { + struct tag *type = cu__type(cu, constant->tag.type); + if (type != NULL) { + printed += fprintf(fp, "const "); + printed += type__fprintf(type, cu, name, conf, fp); + printed += fprintf(fp, " = %" PRIu64, constant__value(constant)); + } + } + return printed; +} + static size_t namespace__fprintf(const struct tag *tag, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp) { @@ -2019,6 +2037,9 @@ size_t tag__fprintf(struct tag *tag, const struct cu *cu, case DW_TAG_variable: printed += variable__fprintf(tag, cu, pconf, fp); break; + case DW_TAG_constant: // First seen in a Go CU + printed += constant__fprintf(tag, cu, pconf, fp); + break; case DW_TAG_imported_declaration: printed += imported_declaration__fprintf(tag, cu, fp); break; |