Message ID | 20211118232330.16310-3-guillermo.e.martinez@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <libabigail-bounces+patchwork=sourceware.org@sourceware.org> 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 2E9A8385801A for <patchwork@sourceware.org>; Thu, 18 Nov 2021 23:24:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E9A8385801A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637277854; bh=rJC94ql9kTcPYHCzY6/ujx5Y4byimilPqriHfOEA+Uw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:From; b=VdBbq8Imd4QPE4tR8GZzJjgCZBfn3vrb1xT0kavzy/NX0ANKb3xF2K3qSKWY54k1o k0LgPu8oxJwrdI07kLs7hw9YY6Pt1BaJmhPFLQrAPLQnusqADh5LtNF9/mHc7/nvJR PFjsG8lFW8CkDSo8PloXamzzh4jAUjsCo2upXW+M= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 9A2E2385801D for <libabigail@sourceware.org>; Thu, 18 Nov 2021 23:24:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A2E2385801D Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AIMB6le009987 for <libabigail@sourceware.org>; Thu, 18 Nov 2021 23:24:01 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3cd382kw2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <libabigail@sourceware.org>; Thu, 18 Nov 2021 23:24:01 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1AINKX7l184319 for <libabigail@sourceware.org>; Thu, 18 Nov 2021 23:23:58 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2170.outbound.protection.outlook.com [104.47.73.170]) by aserp3030.oracle.com with ESMTP id 3ccccsjghg-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <libabigail@sourceware.org>; Thu, 18 Nov 2021 23:23:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cvNU51K6LtbEzkW6imJRakQqmPfw7EFWpYtFNA5xyRF448Th4m3JeZlD/jfcUICoLRpPsDBTJyi+Xv3kShCSksv7anSmDkeXRjCzwh+DsSYJIPIw0YENCgxPRs5fHKkWAHKGggOVd5Wu4TRVqaW1dpDXIIXU3Dk7EW8REZrqkHLT0Qgs0VXeUNZ+q92Du9/MSzXi3CxrWC02dYZmci7/oGu55szI9hCIx2LVylmOMHhLpdXyoQHuhQCiuQL30ifKjvavaDm2tc5bUqSkJnH7NHCD1XpF8aLSIdBU6hohLpG9sl19OgeNBMg2QGn0mzBXU0YyvscY7ZKV0JOIQP+aFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rJC94ql9kTcPYHCzY6/ujx5Y4byimilPqriHfOEA+Uw=; b=EC8NEfqkJzdFIRLzpJCY0lzZVe0nK85+DF1+p3uTwK1UFLCn2nBS8QWHls9wlGEGm6yZsfbZzf11w6EzYR4rt+sZXB4yGdwWGrU7tpIvmac2w7PT756Cpid6VnGoUYAem2HgQIs14K/OBTq5HXEz0AkWM7BwXvYRshGu7EW3BUKWSesaYh9N85ryNEJ3mOLKnXdN44CDHdVhjH24MDP8BY8FF+ZU6Fm0PlB14LY7oXq5h7w7m3dCCkUWmTnAWt3DFTtZ55xqwH6rZsoKFHsunoxDTUNWHTot1CdkhYYRA6yIOzSNNBFuhQk1AqxjHEaUO8bskVfMG2U+QGBqSnKibg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from BL0PR10MB2852.namprd10.prod.outlook.com (2603:10b6:208:76::22) by MN2PR10MB4045.namprd10.prod.outlook.com (2603:10b6:208:1b7::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Thu, 18 Nov 2021 23:23:57 +0000 Received: from BL0PR10MB2852.namprd10.prod.outlook.com ([fe80::7126:e98e:9cff:8765]) by BL0PR10MB2852.namprd10.prod.outlook.com ([fe80::7126:e98e:9cff:8765%7]) with mapi id 15.20.4713.021; Thu, 18 Nov 2021 23:23:57 +0000 To: libabigail@sourceware.org Subject: [PATCH 2/3] ctf-reader: Use smart pointers in create_read_context Date: Thu, 18 Nov 2021 17:23:29 -0600 Message-Id: <20211118232330.16310-3-guillermo.e.martinez@oracle.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211118232330.16310-1-guillermo.e.martinez@oracle.com> References: <20211118025606.554809-1-guillermo.e.martinez@oracle.com> <20211118232330.16310-1-guillermo.e.martinez@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SA0PR11CA0189.namprd11.prod.outlook.com (2603:10b6:806:1bc::14) To BL0PR10MB2852.namprd10.prod.outlook.com (2603:10b6:208:76::22) MIME-Version: 1.0 Received: from sali.us.oracle.com (2606:b400:8004:44::1a) by SA0PR11CA0189.namprd11.prod.outlook.com (2603:10b6:806:1bc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Thu, 18 Nov 2021 23:23:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 29393574-070d-4f2b-ed69-08d9aaea7e64 X-MS-TrafficTypeDiagnostic: MN2PR10MB4045: X-Microsoft-Antispam-PRVS: <MN2PR10MB4045D03D3884276945AFE15BBA9B9@MN2PR10MB4045.namprd10.prod.outlook.com> X-MS-Oob-TLC-OOBClassifiers: OLM:220; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k3ViNa+TCm3karFRDglwpi/KcyWtHhS3Jm1TT4e7JQSeSlMSmLyJQ4gJNg1QIhNRpUX8t2JnD4W1YY4PMOKtGqleJNp4VXG/8ch57R9xMj7bRzTvT4CroivLimAk4S8bfI/srG4mNQ6VgV3LdW0e2aKkGnMO22EtVBQpp9UgT64ee8DBgxpN/id8qeN93a/IL0McrKwv4iYQ07/sdfRaoFX9A/eWMRvYPQ/tPrqQyrlFVWjRJoa20tH3hXQDmUSdFjzpMR5nZ/jbHQwhpL3Dh0T2ZGQO+ZePA2IDtdknGsYbpp1aXk1tYMT4wrQCeEcypwV6135WXgE4WjONBbylNZiqFZ5GmDvg+5apeQTDixG6P19jnE5zkEiW7q8NHWgVdiuRXSBVXXEhkPy7swS7HbC/1SjU2xFDx2G2KNtTj8f+4yoyrKBKybzl+tYWNWZ8K3PdYlmy4UbBWF7Di5Zb7Px5RVoJCCkQK3nTbgIMINlJ7/BFqBGH6NZBvJPe52BQENBSW6Ze1y28iTaA9iOzvYfEqhb7W6uH9ZMPPflO+/yju12cnZdLhpxQkFJZJMLl9lx2sprxuDAiWFzJLl5Doa/1EWyKQq/oGqSldhUvWvyDrYUtCfFQJp3Ca08ItHg4YsKgCLDQQ54gyFb5mhTYSQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR10MB2852.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6666004)(6486002)(36756003)(107886003)(38100700002)(83380400001)(86362001)(5660300002)(52116002)(8936002)(8676002)(7696005)(2906002)(6916009)(508600001)(103116003)(66556008)(66946007)(316002)(66476007)(4326008)(2616005)(186003)(1076003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /pwFXt7DGje7O3SizuyggDM3e4aOyAWa913ug78EskZAQrbsjc/vn48roHBId6+EESN1F/u4kSwAGbjJlzYSy4vt89JsRcd1TlPvjqZft268APNs2XW2cM3nxje/GqAr/C3vOXM2s1ji+vQ054oR+xop7o08D+G7EE7U67VMdA5kU1JCPZS70iN58e8y5y1R/117Mni3iP3NJlmq5wcFd5Hg1j3nmEVgljwWDfTFHCKcUXb99xss5iAr0PTl2aYhVaGAkdBmw1N4lJ4w8m1UQNJdIfKHxoFQrSqZukrhGGpRz3DsxHrc60AuFSc+4jplSckAQVJTkeuvhUYTcAa8SR7JQtEVnW/yY3BxXCkmlRoOLF/BIyigc6lgtwTDmO2+5LDd0vL9SSvxVMzTJpfTtdIVwclJSemr/7x/DckuWDXGrBF5a6XTuwJrP/mLMV73ZryDGi6bnjBz5Nq/hfp9S6gwvgChZvedXC4+O8yXHaiMeozquxSfTyrHhTf86zJ1z9x+NpxoftFEIZYiavUjCakTvBhHpYd1cnRtsEBUN0SgETy84NYHQbPElZPqtPT0CMw9N+GpCmh1a6LfxQOcI0KGnsdlc5JlL+TN/5Ebofectvj4HAZ6YL6XQZHYbpKQjMFFeFWFOx5kLjwuV/ZAys3A1RFVnic6pCU1C/6ATQxOhADLGNF4bFBQBI0xb4IW+QgTCIb5a4HuNSG7/f/8O02c6Jydru82Oxa5/yYPJ671s5h6fMyNTGvP80nNujv3+R1K7T4R8QlMpaVkRNyc2l1Yb4/2ksSY9c8Nl8D0BU3dD2Yhs5Fwa8wrU7ukZa+r57cqMe0u+s1VMg0FPL6LVahUxtuU1KFAiU29njr/GEC6/Xd3r9fweOs4bzqpJE9P54QCReE6Yom1AlElJSBswmaHjcDOaLRHY9Yccjwa3ZSE6LyXeCNBCj6LOB001LeR14K+FaO+HJ2buMRELvQgbAdtvQ5hE+RuNp7HCy6IExwAn9ur1W8mmo3dK7JA6lyXFWWa3xrIzn9IkoUmBwc3FzGrPunjcbl/GeZHcDMGnSnfVOEp6pp65iOcEVSaqK4NQr9Fe8fmBXJiD0wKZ7UADE+gbglgB+2yX637NHq4rU/XrvVLtS6EaVcM7ivHBErvThcvFpCVpocmTu9HFZbKw9FZOKvZ4iH142v0IwzQ/3a2o/KTKDVXOAk9DzaPjN9ntvI2Ui1DBPJ+OArJh2yJrvEGPW7xYUH48XiaylqcKdtsp7fIJ7tFn4It4QSTSDcFcnwV3R68bW5tJ2YO5CSE9Z4Raiy+4HuzGUROo/qBemD2jmM9E9LtdZOWcuyBP5wipu7t7MCqkQBPwA5kWxlibuAIBVMetMAM/ZqLNpm5LeFdOjCfbQQGqBLLmFNKky5jWgDrMqrlfmZXL9ladrUROITSL4F60T1elv5GtnoS4MgJPwpvM2Lg+J3r+11f5oZ2B+yfkKpiCYYEL8SFciarbiiqO8vg0U97bE9lscOsf4O34Eu6cS9Yu4AU8lyCbDb3cSzro6CWaDGJEIdrN76r+hrpnyoLTtyUJjPPWJhkNvEN3T4WlLQxj2T4khou1+cXvIZ/cBfS8EX5819u4MNmhQwfkPKR2Ec9Rzhba62Z7tnoK0n651wRDRoM/rItVxmnkPLj/qtONzKeo0nCYv8jPfzqpyRg1jYrtkGj0qdRZ0o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29393574-070d-4f2b-ed69-08d9aaea7e64 X-MS-Exchange-CrossTenant-AuthSource: BL0PR10MB2852.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 23:23:57.0867 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qQ/oK3si8Glq9IyGltoZF2HyHHYfNh1dsDEVKhIV4d+T+f2skMCeQUewBCzg6+h+ohEcGzrPw216pxI6+byBISxO6ATiCCoxz7plbQPLhkU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB4045 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10172 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111180120 X-Proofpoint-ORIG-GUID: GCo1G2VRsaZrLLcD9CgKCnUWio-4Q3o0 X-Proofpoint-GUID: GCo1G2VRsaZrLLcD9CgKCnUWio-4Q3o0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 <libabigail.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libabigail>, <mailto:libabigail-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libabigail/> List-Help: <mailto:libabigail-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libabigail>, <mailto:libabigail-request@sourceware.org?subject=subscribe> From: "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> Reply-To: "Guillermo E. Martinez" <guillermo.e.martinez@oracle.com> Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" <libabigail-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Some improvements in ctf-reader.
|
|
Commit Message
Guillermo E. Martinez
Nov. 18, 2021, 11:23 p.m. UTC
* include/abg-ctf-reader.h (read_context_sptr): New typedef.
(create_read_context): Use read_context_sptr as return value.
* src/abg-ctf-reader.cc (create_read_context): Likewise.
* tools/abidiff.cc (main): Use read_context_sptr.
* tools/abilint.cc: Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
---
include/abg-ctf-reader.h | 7 +++++--
src/abg-ctf-reader.cc | 5 +++--
tools/abidiff.cc | 18 ++++++++++--------
tools/abilint.cc | 8 ++++----
4 files changed, 22 insertions(+), 16 deletions(-)
Comments
Hello Guillermo, "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a écrit: [...] > diff --git a/include/abg-ctf-reader.h b/include/abg-ctf-reader.h > index 56b2bf91..c527c2ff 100644 > --- a/include/abg-ctf-reader.h > +++ b/include/abg-ctf-reader.h > @@ -25,8 +25,11 @@ namespace ctf_reader > { > > class read_context; > -read_context *create_read_context(const std::string& elf_path, > - ir::environment *env); > +typedef shared_ptr<read_context> read_context_sptr; > + > +read_context_sptr > +create_read_context(const std::string& elf_path, > + ir::environment *env); > corpus_sptr read_corpus(read_context *ctxt, > elf_reader::status& status); I appears that read_corpus that takes a read_context* now needs an overload function that takes a "const read_context&" too. That is needed in abidw, at least, where read_corpus is used in that capacity. I amended abg-ctf-reader.{h,cc} to declare and define that new overload. abidw.cc doesn't need any adjustment in that regard. [...] > * include/abg-ctf-reader.h (read_context_sptr): New typedef. > (create_read_context): Use read_context_sptr as return value. > * src/abg-ctf-reader.cc (create_read_context): Likewise. > * tools/abidiff.cc (main): Use read_context_sptr. > * tools/abilint.cc: Likewise. I have updated the ChangeLog accordingly. > > Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> I have applied the amended patch to the master branch of the git repository and am providing it below. Thanks! From 7f60fbc96b16507a4097a0c1a86c27279d9cab5d Mon Sep 17 00:00:00 2001 From: "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> Date: Thu, 18 Nov 2021 17:23:29 -0600 Subject: [PATCH] ctf-reader: Make create_read_context return a smart pointer. * include/abg-ctf-reader.h (read_context_sptr): New typedef. (create_read_context): Use read_context_sptr as return value. (read_corpus): New overload that takes a read_context_sptr. * src/abg-ctf-reader.cc (create_read_context): Use read_context_sptr as return value. (read_corpus): New overload that takes a read_context_sptr. * tools/abidiff.cc (main): Use read_context_sptr. * tools/abidw.cc (load_corpus_and_write_abixml): Adjust call to create_read_context. * tools/abilint.cc: Likewise. Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> --- include/abg-ctf-reader.h | 12 ++++++++---- src/abg-ctf-reader.cc | 19 +++++++++++++++++-- tools/abidiff.cc | 18 ++++++++++-------- tools/abidw.cc | 2 +- tools/abilint.cc | 8 ++++---- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/include/abg-ctf-reader.h b/include/abg-ctf-reader.h index 56b2bf91..3343f0d8 100644 --- a/include/abg-ctf-reader.h +++ b/include/abg-ctf-reader.h @@ -25,11 +25,15 @@ namespace ctf_reader { class read_context; -read_context *create_read_context(const std::string& elf_path, - ir::environment *env); -corpus_sptr read_corpus(read_context *ctxt, - elf_reader::status& status); +typedef shared_ptr<read_context> read_context_sptr; +read_context_sptr +create_read_context(const std::string& elf_path, + ir::environment *env); +corpus_sptr +read_corpus(read_context *ctxt, elf_reader::status& status); +corpus_sptr +read_corpus(const read_context_sptr &ctxt, elf_reader::status &status); } // end namespace ctf_reader } // end namespace abigail diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc index fd53f8a1..6829e4c0 100644 --- a/src/abg-ctf-reader.cc +++ b/src/abg-ctf-reader.cc @@ -1058,11 +1058,12 @@ slurp_elf_info(read_context *ctxt, corpus_sptr corp) /// @param elf_path the patch of some ELF file. /// @param env a libabigail IR environment. -read_context * +read_context_sptr create_read_context(const std::string& elf_path, ir::environment *env) { - return new read_context(elf_path, env); + read_context_sptr result(new read_context(elf_path, env)); + return result; } /// Read the CTF information from some source described by a given @@ -1116,5 +1117,19 @@ read_corpus(read_context *ctxt, elf_reader::status &status) return corp; } +/// Read the CTF information from some source described by a given +/// read context and process it to create a libabigail IR corpus. +/// Store the corpus in the same read context. +/// +/// @param ctxt the read context to use. +/// +/// @param status the resulting status of the corpus read. +/// +/// @return a shared pointer to the read corpus. + +corpus_sptr +read_corpus(const read_context_sptr &ctxt, elf_reader::status &status) +{return read_corpus(ctxt.get(), status);} + } // End of namespace ctf_reader } // End of namespace abigail diff --git a/tools/abidiff.cc b/tools/abidiff.cc index f145f4f1..30959616 100644 --- a/tools/abidiff.cc +++ b/tools/abidiff.cc @@ -1169,12 +1169,13 @@ main(int argc, char* argv[]) #ifdef WITH_CTF if (opts.use_ctf) { - abigail::ctf_reader::read_context *ctxt - = abigail::ctf_reader::create_read_context (opts.file1, - env.get()); + abigail::ctf_reader::read_context_sptr ctxt + = abigail::ctf_reader::create_read_context(opts.file1, + env.get()); assert (ctxt); - c1 = abigail::ctf_reader::read_corpus (ctxt, c1_status); + c1 = abigail::ctf_reader::read_corpus(ctxt.get(), + c1_status); } else #endif @@ -1252,12 +1253,13 @@ main(int argc, char* argv[]) #ifdef WITH_CTF if (opts.use_ctf) { - abigail::ctf_reader::read_context *ctxt - = abigail::ctf_reader::create_read_context (opts.file2, - env.get()); + abigail::ctf_reader::read_context_sptr ctxt + = abigail::ctf_reader::create_read_context(opts.file2, + env.get()); assert (ctxt); - c2 = abigail::ctf_reader::read_corpus (ctxt, c2_status); + c2 = abigail::ctf_reader::read_corpus (ctxt.get(), + c2_status); } else #endif diff --git a/tools/abidw.cc b/tools/abidw.cc index d2bc029b..f7a8937d 100644 --- a/tools/abidw.cc +++ b/tools/abidw.cc @@ -539,7 +539,7 @@ load_corpus_and_write_abixml(char* argv[], #ifdef WITH_CTF if (opts.use_ctf) { - abigail::ctf_reader::read_context *ctxt + abigail::ctf_reader::read_context_sptr ctxt = abigail::ctf_reader::create_read_context (opts.in_file_path, env.get()); diff --git a/tools/abilint.cc b/tools/abilint.cc index 49643b66..2e9bae49 100644 --- a/tools/abilint.cc +++ b/tools/abilint.cc @@ -370,12 +370,12 @@ main(int argc, char* argv[]) #ifdef WITH_CTF if (opts.use_ctf) { - abigail::ctf_reader::read_context *ctxt - = abigail::ctf_reader::create_read_context (opts.file_path, - env.get()); + abigail::ctf_reader::read_context_sptr ctxt + = abigail::ctf_reader::create_read_context(opts.file_path, + env.get()); assert (ctxt); - corp = abigail::ctf_reader::read_corpus (ctxt, s); + corp = abigail::ctf_reader::read_corpus (ctxt.get(), s); } else #endif
On Tuesday, November 23, 2021 8:35:55 AM CST Dodji Seketeli wrote: > Hello Guillermo, Hello Dodji > "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a écrit: > > [...] > > > diff --git a/include/abg-ctf-reader.h b/include/abg-ctf-reader.h > > index 56b2bf91..c527c2ff 100644 > > --- a/include/abg-ctf-reader.h > > +++ b/include/abg-ctf-reader.h > > @@ -25,8 +25,11 @@ namespace ctf_reader > > { > > > > class read_context; > > -read_context *create_read_context(const std::string& elf_path, > > - ir::environment *env); > > +typedef shared_ptr<read_context> read_context_sptr; > > + > > +read_context_sptr > > +create_read_context(const std::string& elf_path, > > + ir::environment *env); > > corpus_sptr read_corpus(read_context *ctxt, > > elf_reader::status& status); > > I appears that read_corpus that takes a read_context* now needs an > overload function that takes a "const read_context&" too. That is > needed in abidw, at least, where read_corpus is used in that capacity. Ok, I see, thanks for add it. > I amended abg-ctf-reader.{h,cc} to declare and define that new overload. > abidw.cc doesn't need any adjustment in that regard. > > [...] > > > > * include/abg-ctf-reader.h (read_context_sptr): New typedef. > > (create_read_context): Use read_context_sptr as return value. > > * src/abg-ctf-reader.cc (create_read_context): Likewise. > > * tools/abidiff.cc (main): Use read_context_sptr. > > * tools/abilint.cc: Likewise. > > I have updated the ChangeLog accordingly. Thanks, > > > > Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> > > I have applied the amended patch to the master branch of the git > repository and am providing it below. > > Thanks! Great, thanks! > From 7f60fbc96b16507a4097a0c1a86c27279d9cab5d Mon Sep 17 00:00:00 2001 > From: "Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> > Date: Thu, 18 Nov 2021 17:23:29 -0600 > Subject: [PATCH] ctf-reader: Make create_read_context return a smart pointer. > > * include/abg-ctf-reader.h (read_context_sptr): New typedef. > (create_read_context): Use read_context_sptr as return value. > (read_corpus): New overload that takes a read_context_sptr. > * src/abg-ctf-reader.cc (create_read_context): Use > read_context_sptr as return value. > (read_corpus): New overload that takes a read_context_sptr. > * tools/abidiff.cc (main): Use read_context_sptr. > * tools/abidw.cc (load_corpus_and_write_abixml): Adjust call to > create_read_context. > * tools/abilint.cc: Likewise. > > Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com> > Signed-off-by: Dodji Seketeli <dodji@redhat.com> > --- > include/abg-ctf-reader.h | 12 ++++++++---- > src/abg-ctf-reader.cc | 19 +++++++++++++++++-- > tools/abidiff.cc | 18 ++++++++++-------- > tools/abidw.cc | 2 +- > tools/abilint.cc | 8 ++++---- > 5 files changed, 40 insertions(+), 19 deletions(-) > > diff --git a/include/abg-ctf-reader.h b/include/abg-ctf-reader.h > index 56b2bf91..3343f0d8 100644 > --- a/include/abg-ctf-reader.h > +++ b/include/abg-ctf-reader.h > @@ -25,11 +25,15 @@ namespace ctf_reader > { > > class read_context; > -read_context *create_read_context(const std::string& elf_path, > - ir::environment *env); > -corpus_sptr read_corpus(read_context *ctxt, > - elf_reader::status& status); > +typedef shared_ptr<read_context> read_context_sptr; > > +read_context_sptr > +create_read_context(const std::string& elf_path, > + ir::environment *env); > +corpus_sptr > +read_corpus(read_context *ctxt, elf_reader::status& status); > +corpus_sptr > +read_corpus(const read_context_sptr &ctxt, elf_reader::status &status); > } // end namespace ctf_reader > } // end namespace abigail > > diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc > index fd53f8a1..6829e4c0 100644 > --- a/src/abg-ctf-reader.cc > +++ b/src/abg-ctf-reader.cc > @@ -1058,11 +1058,12 @@ slurp_elf_info(read_context *ctxt, corpus_sptr corp) > /// @param elf_path the patch of some ELF file. > /// @param env a libabigail IR environment. > > -read_context * > +read_context_sptr > create_read_context(const std::string& elf_path, > ir::environment *env) > { > - return new read_context(elf_path, env); > + read_context_sptr result(new read_context(elf_path, env)); > + return result; > } > > /// Read the CTF information from some source described by a given > @@ -1116,5 +1117,19 @@ read_corpus(read_context *ctxt, elf_reader::status &status) > return corp; > } > > +/// Read the CTF information from some source described by a given > +/// read context and process it to create a libabigail IR corpus. > +/// Store the corpus in the same read context. > +/// > +/// @param ctxt the read context to use. > +/// > +/// @param status the resulting status of the corpus read. > +/// > +/// @return a shared pointer to the read corpus. > + > +corpus_sptr > +read_corpus(const read_context_sptr &ctxt, elf_reader::status &status) > +{return read_corpus(ctxt.get(), status);} > + > } // End of namespace ctf_reader > } // End of namespace abigail > diff --git a/tools/abidiff.cc b/tools/abidiff.cc > index f145f4f1..30959616 100644 > --- a/tools/abidiff.cc > +++ b/tools/abidiff.cc > @@ -1169,12 +1169,13 @@ main(int argc, char* argv[]) > #ifdef WITH_CTF > if (opts.use_ctf) > { > - abigail::ctf_reader::read_context *ctxt > - = abigail::ctf_reader::create_read_context (opts.file1, > - env.get()); > + abigail::ctf_reader::read_context_sptr ctxt > + = abigail::ctf_reader::create_read_context(opts.file1, > + env.get()); > > assert (ctxt); > - c1 = abigail::ctf_reader::read_corpus (ctxt, c1_status); > + c1 = abigail::ctf_reader::read_corpus(ctxt.get(), > + c1_status); > } > else > #endif > @@ -1252,12 +1253,13 @@ main(int argc, char* argv[]) > #ifdef WITH_CTF > if (opts.use_ctf) > { > - abigail::ctf_reader::read_context *ctxt > - = abigail::ctf_reader::create_read_context (opts.file2, > - env.get()); > + abigail::ctf_reader::read_context_sptr ctxt > + = abigail::ctf_reader::create_read_context(opts.file2, > + env.get()); > > assert (ctxt); > - c2 = abigail::ctf_reader::read_corpus (ctxt, c2_status); > + c2 = abigail::ctf_reader::read_corpus (ctxt.get(), > + c2_status); > } > else > #endif > diff --git a/tools/abidw.cc b/tools/abidw.cc > index d2bc029b..f7a8937d 100644 > --- a/tools/abidw.cc > +++ b/tools/abidw.cc > @@ -539,7 +539,7 @@ load_corpus_and_write_abixml(char* argv[], > #ifdef WITH_CTF > if (opts.use_ctf) > { > - abigail::ctf_reader::read_context *ctxt > + abigail::ctf_reader::read_context_sptr ctxt > = abigail::ctf_reader::create_read_context (opts.in_file_path, > env.get()); > > diff --git a/tools/abilint.cc b/tools/abilint.cc > index 49643b66..2e9bae49 100644 > --- a/tools/abilint.cc > +++ b/tools/abilint.cc > @@ -370,12 +370,12 @@ main(int argc, char* argv[]) > #ifdef WITH_CTF > if (opts.use_ctf) > { > - abigail::ctf_reader::read_context *ctxt > - = abigail::ctf_reader::create_read_context (opts.file_path, > - env.get()); > + abigail::ctf_reader::read_context_sptr ctxt > + = abigail::ctf_reader::create_read_context(opts.file_path, > + env.get()); > > assert (ctxt); > - corp = abigail::ctf_reader::read_corpus (ctxt, s); > + corp = abigail::ctf_reader::read_corpus (ctxt.get(), s); > } > else > #endif >
diff --git a/include/abg-ctf-reader.h b/include/abg-ctf-reader.h index 56b2bf91..c527c2ff 100644 --- a/include/abg-ctf-reader.h +++ b/include/abg-ctf-reader.h @@ -25,8 +25,11 @@ namespace ctf_reader { class read_context; -read_context *create_read_context(const std::string& elf_path, - ir::environment *env); +typedef shared_ptr<read_context> read_context_sptr; + +read_context_sptr +create_read_context(const std::string& elf_path, + ir::environment *env); corpus_sptr read_corpus(read_context *ctxt, elf_reader::status& status); diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc index 2c2c204d..3e17e049 100644 --- a/src/abg-ctf-reader.cc +++ b/src/abg-ctf-reader.cc @@ -1059,11 +1059,12 @@ slurp_elf_info(read_context *ctxt, corpus_sptr corp) /// @param elf_path the patch of some ELF file. /// @param env a libabigail IR environment. -read_context * +read_context_sptr create_read_context(const std::string& elf_path, ir::environment *env) { - return new read_context(elf_path, env); + read_context_sptr result(new read_context(elf_path, env)); + return result; } /// Read the CTF information from some source described by a given diff --git a/tools/abidiff.cc b/tools/abidiff.cc index f145f4f1..30959616 100644 --- a/tools/abidiff.cc +++ b/tools/abidiff.cc @@ -1169,12 +1169,13 @@ main(int argc, char* argv[]) #ifdef WITH_CTF if (opts.use_ctf) { - abigail::ctf_reader::read_context *ctxt - = abigail::ctf_reader::create_read_context (opts.file1, - env.get()); + abigail::ctf_reader::read_context_sptr ctxt + = abigail::ctf_reader::create_read_context(opts.file1, + env.get()); assert (ctxt); - c1 = abigail::ctf_reader::read_corpus (ctxt, c1_status); + c1 = abigail::ctf_reader::read_corpus(ctxt.get(), + c1_status); } else #endif @@ -1252,12 +1253,13 @@ main(int argc, char* argv[]) #ifdef WITH_CTF if (opts.use_ctf) { - abigail::ctf_reader::read_context *ctxt - = abigail::ctf_reader::create_read_context (opts.file2, - env.get()); + abigail::ctf_reader::read_context_sptr ctxt + = abigail::ctf_reader::create_read_context(opts.file2, + env.get()); assert (ctxt); - c2 = abigail::ctf_reader::read_corpus (ctxt, c2_status); + c2 = abigail::ctf_reader::read_corpus (ctxt.get(), + c2_status); } else #endif diff --git a/tools/abilint.cc b/tools/abilint.cc index 49643b66..2e9bae49 100644 --- a/tools/abilint.cc +++ b/tools/abilint.cc @@ -370,12 +370,12 @@ main(int argc, char* argv[]) #ifdef WITH_CTF if (opts.use_ctf) { - abigail::ctf_reader::read_context *ctxt - = abigail::ctf_reader::create_read_context (opts.file_path, - env.get()); + abigail::ctf_reader::read_context_sptr ctxt + = abigail::ctf_reader::create_read_context(opts.file_path, + env.get()); assert (ctxt); - corp = abigail::ctf_reader::read_corpus (ctxt, s); + corp = abigail::ctf_reader::read_corpus (ctxt.get(), s); } else #endif