aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-04-13 14:40:24 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-04-13 14:40:24 -0300
commitafca84ff989d97292fd79077439cbf303a8f755e (patch)
treef198a78cab6354befb009b4de65c0b66f9e3f31f
parentcb7eb753694be3e8aef45ec16ad27708c725eeca (diff)
downloaddwarves-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.c21
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;