From patchwork Thu Jun 10 09:16:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 43809 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5858A3840011 for ; Thu, 10 Jun 2021 09:17:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5858A3840011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623316620; bh=CUVDHAsEuP4ADFqbwuQXJmPzikFDvNjmzp9dqWYaj70=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=gIeDZUpEYgDuOjaehty6c0BjIMfQPTZYzL/L/PemmmZ3nLOBTsrqN3/zULyBOp3oC 3IVkXRuMkhjoOUYxmU5UHtJr6Rwt5aTPM84zfSBdH4+JLAlP35XMvhpQlAYEEyavLd ZsSCA6nmQjdE77SPWE2msREO85pC5iJh/hoKl+XE= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 7BEEE3851C0C for ; Thu, 10 Jun 2021 09:16:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7BEEE3851C0C Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-YfnY8NS3OROnk4TTKIdROw-1; Thu, 10 Jun 2021 05:16:53 -0400 X-MC-Unique: YfnY8NS3OROnk4TTKIdROw-1 Received: by mail-wm1-f71.google.com with SMTP id g14-20020a05600c4eceb02901b609849650so3120955wmq.6 for ; Thu, 10 Jun 2021 02:16:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=CUVDHAsEuP4ADFqbwuQXJmPzikFDvNjmzp9dqWYaj70=; b=g/yZytuW9hq/tmDb/NFvmVBu/DHd/Q+bjomzY8NUfeUye9dDGxf/goukU7Rw1lToqP +uTu8vkuIIqFNJBQ1MJ8MHL+Zg6U1zDEuQV5OnxdQVmLX757puiAWk0aqxILYmqGCSVy R5VTJxb2oNaREsD8Ps4Za1CeOJb5IJbXRJAiGgffTcjObeAGRs6d5YqXGbE4AYPf9vlo yoAzImwrNYCttYMOKQK4UVOMradw1Qs3X/IlvodoTW8xoLQJsJjs0gveVCa0qoCGjs3h 7zhEJ7NiKFPNtYSQuBK8cIjq5bhWD60q7eFoDWSUz8sJdHaoi6fnnQo2dlx1zmlHkcTu hMaw== X-Gm-Message-State: AOAM5310r14HAAWDSHR8z6HdlUlgYgxL0kuNVjpaaeEJf/gFNSPbKDKG 964bYVJmjSUJA9o2vgcbSAy1dl+zUb+AaN4MmjDza2Eqa28SbJMlNGrB1U5QEtUWFHV6iPp58pR HQ0nOXHqxrDdKqUQe6hT6oF3AKH6TIIexd22TQjhso/5Lz5ApkvHbDGKGyVp3kQ6Y5WTZ X-Received: by 2002:a05:600c:410a:: with SMTP id j10mr13692824wmi.6.1623316612169; Thu, 10 Jun 2021 02:16:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydyoC8S0NRDPcCidqv751devzdTnROP+ppKUKhXo2Jjxb4k6QN+igg3h0sSPFmLpto6SQbDw== X-Received: by 2002:a05:600c:410a:: with SMTP id j10mr13692798wmi.6.1623316611852; Thu, 10 Jun 2021 02:16:51 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id c7sm3127898wrc.42.2021.06.10.02.16.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 02:16:51 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 6AACE5800FF; Thu, 10 Jun 2021 11:16:50 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH, applied] ir: make 'debug(artefact)' support showing enums Organization: Red Hat / France X-Operating-System: Fedora 35 X-URL: http://www.redhat.com Date: Thu, 10 Jun 2021 11:16:50 +0200 Message-ID: <87r1ha2i65.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "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 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,