From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] ir: make 'debug(artefact)' support showing enums
Date: Thu, 10 Jun 2021 11:16:50 +0200 [thread overview]
Message-ID: <87r1ha2i65.fsf@redhat.com> (raw)
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
reply other threads:[~2021-06-10 9:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1ha2i65.fsf@redhat.com \
--to=dodji@redhat.com \
--cc=libabigail@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).