From patchwork Wed Apr 26 12:24:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 68305 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 5749A3858CDA for ; Wed, 26 Apr 2023 12:24:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5749A3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682511889; bh=HjHhpaLr6L5WCLgIpITa/PglqElIlujKk4VjB5UJJ1k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=cZtepyBUHiQFd+Z8R2e1gRkxfcm+Obz+wPUXs/ZHS3x/nVzjvztL3a0wvyWuQgYM+ D5sbxyvxJOXj2bfgVSSyC7hFWVSh8XPXE+kcXyyAjIfU4QRXMlbvPuHcyPB2yptcfE NbZ1ZRn1c1wYylmYaPPWG171jGYU0s13lqWAaTWM= 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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A5DD23858C27 for ; Wed, 26 Apr 2023 12:24:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5DD23858C27 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-ehwtNOrVOTGZd5uEJdS4rg-1; Wed, 26 Apr 2023 08:24:42 -0400 X-MC-Unique: ehwtNOrVOTGZd5uEJdS4rg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-61648b7419dso20646766d6.3 for ; Wed, 26 Apr 2023 05:24:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682511881; x=1685103881; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HjHhpaLr6L5WCLgIpITa/PglqElIlujKk4VjB5UJJ1k=; b=bmWLEpawaJhElTBOa1JSmFXUWtfYAi5/uBxiVV4X1v2n2PNHY1NqRCuhgM8efrCLZi O5KMagNXJPBpnBCURqO4aSCsYXvzTY3Apn0JL9yD39JWa2VEBK25hIG6PveVuegaGxMy Vl1kAUV/po95ZvMXjWC/plQDm6Yskzx+LYwIyiJViQJADP7Gc5pLR2iYjyQdJnOwWBqj wUHMB1SGyzQvrohTP6N/wISJ1LO3Sz/S4yttathEKvWPTVAyIxiZU1b8MHled7LXqIOC 9tBVqMqwqBerz57QsUU1DRq012lUzG5297VdOxbyC3uCOsXK2dQhxvAkugSIKobOMB9P pLRg== X-Gm-Message-State: AAQBX9fJ8DwX0+tLBXrAH0VxewmwOkjgWszdZGsic3JCneVSO3lr4xNH 3wVCbjargya2sVwa8UaLm7nyaIE91UM3CsLy1iHFMYt/XoNqkRzPABvvTj/H2k7qEMgzf+obz36 EQvlkIOGimWIpzCLe/WkLrNzganVVN6NLSj+Z0HG9TgC1MVAxmrQf0sDa/NzTg3NPX6vlHk7R+A V5 X-Received: by 2002:ad4:5ceb:0:b0:5b3:e172:b63e with SMTP id iv11-20020ad45ceb000000b005b3e172b63emr37382198qvb.22.1682511881637; Wed, 26 Apr 2023 05:24:41 -0700 (PDT) X-Google-Smtp-Source: AKy350Y2Pz/o48FXPl4nKd6nzaB9MF/Ck6rKd7beou+Lny7sqGBUz+Ha5GyIRh/7LetePiC0AmyMDQ== X-Received: by 2002:ad4:5ceb:0:b0:5b3:e172:b63e with SMTP id iv11-20020ad45ceb000000b005b3e172b63emr37382159qvb.22.1682511881208; Wed, 26 Apr 2023 05:24:41 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id i7-20020a056214030700b006041dae6844sm4196778qvu.96.2023.04.26.05.24.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 05:24:40 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 34AE8B5078; Wed, 26 Apr 2023 14:24:38 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH, applied] reader: Recognize variadic parameter type from abixml Organization: Red Hat / France X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Wed, 26 Apr 2023 14:24:38 +0200 Message-ID: <87sfcm7rw9.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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, When reading a variadic parameter type from the ABIXML, the reader forget to recognize it as THE unique variadic parameter type as returned by abigail::ir::environment::get_variadic_parameter_type(). That makes abigil::ir::environment::is_variadic_parameter_type() to fail on the variadic type that is build from ABIXML. Fixed thus. * include/abg-ir.h (environment::get_variadic_parameter_type_name) Declare ... * src/abg-ir.cc (environment::get_variadic_parameter_type_name): ... a new static member function. (environment::get_variadic_parameter_type): Use the new environment::get_variadic_parameter_type_name rather than using an open coded constant here. * src/abg-dwarf-reader.cc (die_return_and_parm_names_from_fn_type_die): Likewise. * src/abg-reader.cc (build_type_decl): For a variadic parameter type, return abigail::ir::environment::get_variadic_parameter_type() rather than building a new type. * tests/data/test-read-ctf/test2.so.abi: Adjust. * tests/data/test-read-ctf/test2.so.hash.abi: Likewise. * tests/data/test-read-ctf/test8.o.abi: Likewise. Signed-off-by: Dodji Seketeli --- include/abg-ir.h | 3 +++ src/abg-dwarf-reader.cc | 2 +- src/abg-ir.cc | 13 +++++++++++-- src/abg-reader.cc | 8 ++++++-- tests/data/test-read-ctf/test2.so.abi | 22 +++++++++++----------- tests/data/test-read-ctf/test2.so.hash.abi | 4 ++-- tests/data/test-read-ctf/test8.o.abi | 8 ++++---- 7 files changed, 38 insertions(+), 22 deletions(-) diff --git a/include/abg-ir.h b/include/abg-ir.h index 8269e885..36b4ac7c 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -165,6 +165,9 @@ public: const type_base_sptr& get_variadic_parameter_type() const; + static string& + get_variadic_parameter_type_name(); + bool canonicalization_is_done() const; diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index ef1d8a45..2942751f 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -9650,7 +9650,7 @@ die_return_and_parm_names_from_fn_type_die(const reader& rdr, else if (child_tag == DW_TAG_unspecified_parameters) { // This is a variadic function parameter. - parm_names.push_back("variadic parameter type"); + parm_names.push_back(rdr.env().get_variadic_parameter_type_name()); // After a DW_TAG_unspecified_parameters tag, we shouldn't // keep reading for parameters. The // unspecified_parameters TAG should be the last parameter diff --git a/src/abg-ir.cc b/src/abg-ir.cc index c899f92e..8bea0a11 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -3539,12 +3539,21 @@ environment::get_variadic_parameter_type() const { if (!priv_->variadic_marker_type_) priv_->variadic_marker_type_. - reset(new type_decl(*this, - intern("variadic parameter type"), + reset(new type_decl(*this, intern(get_variadic_parameter_type_name()), 0, 0, location())); return priv_->variadic_marker_type_; } +/// Getter of the name of the variadic parameter type. +/// +/// @return the name of the variadic parameter type. +string& +environment::get_variadic_parameter_type_name() +{ + static string variadic_parameter_type_name = "variadic parameter type"; + return variadic_parameter_type_name; +} + /// Test if the canonicalization of types created out of the current /// environment is done. /// diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 1a7ccc7d..f318dbb9 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -3753,8 +3753,12 @@ build_type_decl(reader& rdr, } const environment& env = rdr.get_environment(); - type_decl_sptr decl(new type_decl(env, name, size_in_bits, - alignment_in_bits, loc)); + type_decl_sptr decl; + if (name == env.get_variadic_parameter_type_name()) + decl = is_type_decl(env.get_variadic_parameter_type()); + else + decl.reset(new type_decl(env, name, size_in_bits, + alignment_in_bits, loc)); maybe_set_artificial_location(rdr, node, decl); decl->set_is_anonymous(is_anonymous); decl->set_is_declaration_only(is_decl_only); diff --git a/tests/data/test-read-ctf/test2.so.abi b/tests/data/test-read-ctf/test2.so.abi index 5731f73d..18031061 100644 --- a/tests/data/test-read-ctf/test2.so.abi +++ b/tests/data/test-read-ctf/test2.so.abi @@ -17,20 +17,20 @@ - - - - - - + + + + - - + + - - + + - + + + diff --git a/tests/data/test-read-ctf/test2.so.hash.abi b/tests/data/test-read-ctf/test2.so.hash.abi index 7de25228..15286f42 100644 --- a/tests/data/test-read-ctf/test2.so.hash.abi +++ b/tests/data/test-read-ctf/test2.so.hash.abi @@ -17,12 +17,10 @@ - - @@ -31,6 +29,8 @@ + + diff --git a/tests/data/test-read-ctf/test8.o.abi b/tests/data/test-read-ctf/test8.o.abi index cee2b634..bcd40e2a 100644 --- a/tests/data/test-read-ctf/test8.o.abi +++ b/tests/data/test-read-ctf/test8.o.abi @@ -3,11 +3,11 @@ - - - + + - + +