From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yC5GLHj+PGA3JAAAWB0awg (envelope-from ) for ; Mon, 01 Mar 2021 09:47:20 -0500 Received: by simark.ca (Postfix, from userid 112) id A72331EF7E; Mon, 1 Mar 2021 09:47:20 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A20291EF78 for ; Mon, 1 Mar 2021 09:47:17 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 051B3393A43F; Mon, 1 Mar 2021 14:47:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 051B3393A43F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614610037; bh=AqkpnD4h71LKYMBTPAwUpq0uBMtxQuyHnzJ0ijXTwdA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=IW7lZIPBFBECwA6AvI6WV6TxqKMFGwxlgewC5zk9IIkuNMNnlEzJ9TpWok6Oa2fbW 5CxKpb1ynedQI4+/02rnSVTrdw2Kbb/hfDcud4tqdzzCC/4CpJVDOUTecriz6NCE/Y Jtc4OtWSZbDfQKaR+Soa0IQkLkZ4+gJSbXiErjWY= Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2056.outbound.protection.outlook.com [40.107.244.56]) by sourceware.org (Postfix) with ESMTPS id 9CD54393A42A for ; Mon, 1 Mar 2021 14:47:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9CD54393A42A ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IdOM7gW5ITBw1rBJxNm9h4k33s8nij8wLLqxhT+lSPYHET84L6B/DvKqM90+/2SLaXFgURHKXt/1TY9eb35XPG879VvCah29CMLNx2pDStKbrGHRzyItjfTI1kDEQsh34y2wZCIJscRo7PPIduYUroQfdlhSGAjxr+3Rc9BID12yFOXUax9T2K1zVdwDFlLUjLaUC2Dt/0ipgEL/8+F+l/6wRzqeGBszQtTgcvF05L3CjBAN14ZD//W6GKJtsSl2N3YA5wf/+VySpL6/IXTkK946q1vIPHMew5ETBahO3VMnWb9lBRTN9WbWPDgOVLsYrFQFDn7k0AIRpKiyoOliYA== 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-SenderADCheck; bh=AqkpnD4h71LKYMBTPAwUpq0uBMtxQuyHnzJ0ijXTwdA=; b=bPJJ7fQvpm3086ixb5fs5D5CBS6QshpaO2YTDVD/C3q4t8peEdDFF6YYXzw/PkrvcDRaqoIA6JezD7GlvI8SEOQvwSE6prZiuFZn74DnSICxtpA3jMmUCyeQM84neaXkB9VxARBMyNdc6O2RLRuy40KSzO86ltiZzDcesOa+eUWo+hnM2/XaKE8zxhhophMUb1367dUr1s461DaKLdsWd13UK6PLsQYIIQa9rMVarh+Psisnq/l4lVj+yxRQEGr6C9PBk40miow/UIsVjgLqVxXLh9jt61Mhn4cZdq/H5OkBLFfR2GuajnAzdO/7aCVK9PrMHDwg489bDuX70FTS1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none Received: from DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) by DM6PR12MB3676.namprd12.prod.outlook.com (2603:10b6:5:1c7::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Mon, 1 Mar 2021 14:47:03 +0000 Received: from DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44]) by DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44%3]) with mapi id 15.20.3868.033; Mon, 1 Mar 2021 14:47:02 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 21/43] Add to_location method to DWARF entry classes Date: Mon, 1 Mar 2021 14:45:58 +0000 Message-Id: <20210301144620.103016-22-Zoran.Zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210301144620.103016-1-Zoran.Zaric@amd.com> References: <20210301144620.103016-1-Zoran.Zaric@amd.com> Content-Type: text/plain X-Originating-IP: [2a00:23c7:5a85:6801:b4ed:fe7b:8064:d4d] X-ClientProxiedBy: AM0PR04CA0073.eurprd04.prod.outlook.com (2603:10a6:208:be::14) To DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a00:23c7:5a85:6801:b4ed:fe7b:8064:d4d) by AM0PR04CA0073.eurprd04.prod.outlook.com (2603:10a6:208:be::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19 via Frontend Transport; Mon, 1 Mar 2021 14:47:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e527fe3f-48fa-4653-c548-08d8dcc0e043 X-MS-TrafficTypeDiagnostic: DM6PR12MB3676: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v88RLOlMun3B2keHxcmsyNRQBeH/KDGhGwUUckesGw7APAJ+M0gt1x44ghGrTRqXDaS9yiu/LC4wzXoFlGeqMp5TBIj2iRGI9z9rratAA79ILj4p5hy+kQW2cg2iD36rG/8oHRgN2h4+RrA0pPd/RY/hn66bVscbY7SFcaxksyxdIDlALs8EFFR105230iIYoDz97twQRJw8ODcRF6PiunKzkD4SHCrCQIVNy449pubChWh9aqmL/uI1wG/Bi5C0jrYfRqv5o8FxWFFlNCcEZRFn2pkji4mSpnRRZHySjAPmMg7vbmxiJeoYJSe54mVzotoUtuAfG4SNomGCotErz83MjweRwW562OdglNf3PrrV0el7ge6N8IZDFmcGFMANL3qCAfFK+Mkm4NDYdveKoUGN184FQgnABSh/hyIbUxoXAtxbX9X3h1YeJ/DtC7tWURgRXi8/iTWo+Yy63aEl8X9fRsGAAWft9boPXX1SOE0Ngn6KHH99v8kReFmEhkiryEjRO/shHP2hE1HucMt+1vIbMUEwMSIltM1Hgs9eJYGiZVMnMpJLv6gyPc1KqmcLAod2gssfoKL2ttp8LwDXHg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB2762.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(346002)(136003)(39860400002)(6666004)(16526019)(1076003)(83380400001)(2616005)(69590400012)(2906002)(186003)(36756003)(66946007)(316002)(66476007)(8936002)(52116002)(86362001)(6506007)(478600001)(5660300002)(4326008)(6486002)(8676002)(6916009)(6512007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?PbGzCOhDPH7h3eozozGjZKOWGPD6UwbNFvw8RdS4bdoFQAqGbrPnHd66yxPW?= =?us-ascii?Q?ZH37NofOrZcCKE7QjwYXAfiYRfHVy/pUtOrB397NQlhvfNoDnstQCKdi+dca?= =?us-ascii?Q?Du82UMNs3J0A3LzZkMVRa9+WEgkcj7EWD9/zeBH5vWdzJ29n8MlTh9cStve5?= =?us-ascii?Q?PV3j3GTUObHd82epAO7lLvYho0PGSB+RcvkSzS4PblmI3juiIcpEZxjYFRtN?= =?us-ascii?Q?5/rha5/GUTOtT8qbYEPKx/MNBr4dA5JjiI30f29lTI/qj8AkxpV6VDI/RplC?= =?us-ascii?Q?wXxyKauQdp3gixboO1YEbv5pNlc61P/VZvqq+m4o0MuRG/SFU+BsqF44XMpq?= =?us-ascii?Q?yiB523+qvsDsamSZ5eb503I00raAM6+r09557gAE1g862aQI5M34AWrBv8RT?= =?us-ascii?Q?QCMZXvPtwYKraU+c5Ndu6nbbEcuN/TOgUx2klcIhONMaWab/nPJRZid269yF?= =?us-ascii?Q?/620lSt8PeW0riV5AQchFTpZVQxFXeuejiWRSc2a5G13qvnWNfBMK8gk+kTj?= =?us-ascii?Q?Fol0tjWsH+g0iybGTm8ngCLyMxBFa6aGJSdjd3CwJW5cwzPpxhT87YsAj/BR?= =?us-ascii?Q?O3vRcLH2VUcuMnYGoHDJ44qsBrQh83kMRC/IoQYEd+kTefF1Io0kx9NII70J?= =?us-ascii?Q?L5PGLWT6mudXOur8KnGBqCbqpVmaecefiYjBAT6DGlwWoScG79Gi4MgI90dC?= =?us-ascii?Q?P7yjYXtseB+/+fuBqHOirbpaOf4fcoam0Q2Uy+PUDbJVvPo/2pZf573th6wJ?= =?us-ascii?Q?m/b07qYpuyR1mfwW5m4O0Tjw1NbDlTwOIk1i+u2r/JySAhaUZqqEVUfanzBl?= =?us-ascii?Q?Zdtfmo44h/BTWnvg2anBH5xyG06DkDO6iDF9U4fNGHLAoUm9H98SovEu5wy2?= =?us-ascii?Q?usF9G4RWTH3mhmKoVb2kcKnYIsCCQq/d43uFcdMvrh4nS5qmPA00S5ugoPeG?= =?us-ascii?Q?0Rm987NE2HpUm5xlW8BldxwisK5/esdCmvVS9GTlgoqoCczRNV0FG1OSinBm?= =?us-ascii?Q?7+IAVcPiJ+QC3FmUUEmCIfUGZN/AYkl/VtHivvDayojBfd82EPuyE7U7UO16?= =?us-ascii?Q?h348+CpKNav4Sq5PRROcyJOlUWGrI6Tw/SSMwH/gOJ43I84B+VkXqygULRdj?= =?us-ascii?Q?xB1+DoSLwCN2AALG+0PQsKWr+wS/mXfnFb04dPHY7xgRhGLeWw7pNbzakLub?= =?us-ascii?Q?5iZeP+lbT3wPeZyrQ0+zYr1Gn+tnz1YOl4mcuRNpYKZYhe0kGGe8FEc0Fd6f?= =?us-ascii?Q?EBc8YabWW9Hl90IfnHN/GfrUVTMAf+5bahFuM9pjOP/c9ic//6g4OD92em4W?= =?us-ascii?Q?APN/bYcDZfuItYJhnPP/FKmFep61fwwHac9eJt+AkYELyJ26NPyHW41D6A+H?= =?us-ascii?Q?r5vNVHjrymhIRA8YRYVDx5Ayfdl7?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e527fe3f-48fa-4653-c548-08d8dcc0e043 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2021 14:47:02.8653 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jAORFGB4Op3tAGdVA6LXOBWLxHDCOa75I5OJsdPV7BduW1GaN5DtBhb05L6IEeoOiueVpfay/GGBRWQZD4dm9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3676 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zoran Zaric via Gdb-patches Reply-To: Zoran Zaric Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" DWARF standard already contains an implicit conversion between location description and a DWARF value. In the DWARF 5 version, the only place where this can happen is at the very end of the evaluation where a client decides if the result is expected to be in a form of a value or a location description (as_lval argument of the new evaluation method). By allowing any location description to be on the DWARF stack, these implicit conversions are expected on per operation basis which means that the new DWARF entry classes need to have a support for those. This patch adds a conversion method from any DWARF entry object into a location description object. gdb/ChangeLog: * dwarf2/expr.c (class dwarf_entry::to_location): New method. (class dwarf_value::to_location): New method. (class dwarf_location::to_location): New method. --- gdb/dwarf2/expr.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 5d47dc83aaa..d0c0efd2d31 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -277,6 +277,9 @@ write_to_memory (CORE_ADDR address, const gdb_byte *buffer, length, buffer); } +class dwarf_location; +class dwarf_memory; + /* Base class that describes entries found on a DWARF expression evaluation stack. */ @@ -287,6 +290,11 @@ class dwarf_entry : public std::enable_shared_from_this dwarf_entry () = default; virtual ~dwarf_entry () = 0; + + /* Convert DWARF entry into a DWARF location description. ARCH + defines an architecture of the location described. */ + virtual std::shared_ptr to_location + (struct gdbarch *arch) = 0; }; dwarf_entry::~dwarf_entry () = default; @@ -328,6 +336,15 @@ class dwarf_location : public dwarf_entry m_initialised = initialised; }; + /* Convert DWARF entry into a DWARF location description. If the + entry is already a location description, it will be returned as a + result and no conversion will be applied to it. ARCH defines an + architecture of the location described. */ + std::shared_ptr to_location (struct gdbarch *arch) override + { + return std::dynamic_pointer_cast (shared_from_this ()); + } + protected: /* Architecture of the location. */ struct gdbarch *m_arch; @@ -388,6 +405,10 @@ class dwarf_value : public dwarf_entry return unpack_long (m_type, m_contents.get ()); } + /* Convert DWARF value into a DWARF memory location description. + ARCH defines an architecture of the location described. */ + std::shared_ptr to_location (struct gdbarch *arch) override; + private: /* Value contents as a stream of bytes in target byte order. */ gdb::unique_xmalloc_ptr m_contents; @@ -396,6 +417,21 @@ class dwarf_value : public dwarf_entry struct type *m_type; }; +std::shared_ptr +dwarf_value::to_location (struct gdbarch *arch) +{ + LONGEST offset; + + if (gdbarch_integer_to_address_p (arch)) + offset = gdbarch_integer_to_address (arch, m_type, m_contents.get ()); + else + offset = extract_unsigned_integer (m_contents.get (), TYPE_LENGTH (m_type), + type_byte_order (m_type)); + + auto memory = std::make_shared (arch, offset); + return std::dynamic_pointer_cast (memory); +} + /* Undefined location description entry. This is a special location description type that describes the location description that is not known. */ -- 2.17.1