public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] ir: make 'debug(artefact)' support showing enums
@ 2021-06-10  9:16 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2021-06-10  9:16 UTC (permalink / raw)
  To: libabigail

Hello,

While debugging something else, I realized that 'debug(artifact)'
couldn't show the enumerators of an enum. I also realized that we were
not showing the 'declaration-only-ness' of the artefact either.  This
patch fixes that.

	* src/abg-ir.cc (get_debug_representation): Add support for
	showing details for enums.  Also show declaration-only-ness for
	class or unions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Applied to master.
---
 src/abg-ir.cc | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index f0be0843..fd8cbf27 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -8488,7 +8488,8 @@ get_debug_representation(const type_or_decl_base* artifact)
 	}
       o << std::endl
 	<< "{"
-	<< "  // size in bits: " << c->get_size_in_bits() << "\n"
+	<< "   // size in bits: " << c->get_size_in_bits() << "\n"
+	<< "   // is-declaration-only: " << c->get_is_declaration_only() << "\n"
 	<< "   // definition point: " << get_natural_or_artificial_location(c).expand() << "\n"
 	<< "   // translation unit: " << c->get_translation_unit()->get_absolute_path() << std::endl
 	<< "   // @: " << std::hex << is_type(c)
@@ -8523,6 +8524,32 @@ get_debug_representation(const type_or_decl_base* artifact)
 
       o << "};" << std::endl;
 
+      return o.str();
+    }
+  else if (const enum_type_decl* e = is_enum_type(artifact))
+    {
+      string name = e->get_pretty_representation(/*internal=*/true, true);
+      std::ostringstream o;
+      o << name
+	<< " : "
+	<< e->get_underlying_type()->get_pretty_representation(/*internal=*/false,
+							       true)
+	<< "\n"
+	<< "{\n"
+	<< "  // size in bits: " << e->get_size_in_bits() << "\n"
+	<< "  // is-declaration-only: " << e->get_is_declaration_only() << "\n"
+	<< " // definition point: " << get_natural_or_artificial_location(c).expand() << "\n"
+	<< "  // translation unit: "
+	<< e->get_translation_unit()->get_absolute_path() << "\n"
+	<< "  // @: " << std::hex << is_type(e)
+	<< ", @canonical: " << e->get_canonical_type().get() << std::dec
+	<< "\n\n";
+
+      for (const auto &enom : e->get_enumerators())
+	o << "  " << enom.get_name() << " = " << enom.get_value() << ",\n";
+
+      o << "};\n";
+
       return o.str();
     }
   return artifact->get_pretty_representation(/*internal=*/true,
-- 
2.30.0


-- 
		Dodji


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-10  9:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10  9:16 [PATCH, applied] ir: make 'debug(artefact)' support showing enums Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).