]> sourceware.org Git - libabigail.git/commitdiff
ir: make 'debug(artefact)' support showing enums
authorDodji Seketeli <dodji@redhat.com>
Mon, 7 Jun 2021 12:29:10 +0000 (14:29 +0200)
committerDodji Seketeli <dodji@redhat.com>
Wed, 9 Jun 2021 16:37:26 +0000 (18:37 +0200)
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>
src/abg-ir.cc

index f0be0843c9f2adff7dc5db9a470aa9698219a653..fd8cbf272c7b92c333e7cfce4d5befc8d485fc47 100644 (file)
@@ -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,
This page took 0.098472 seconds and 5 git commands to generate.