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>
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 @@
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 @@
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;