From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2056.outbound.protection.outlook.com [40.107.220.56]) by sourceware.org (Postfix) with ESMTPS id C5072385840F for ; Thu, 14 Oct 2021 09:33:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C5072385840F ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CPRdFoJRoDzpvYusK+qjQSyTtkWKXGeqd/8Gx8GsPoh5BCt6aX+559tESOVTj4RHxvICN4Sal9ZzIE0T5Z6tr9yzMXLCSLCXA9CFt2laMuEKATp7VMzkc2yQPX+utnpK+vTjR63Go+z+IKCgUaT0hGjxykkDJ07YuscXU4mD/yaSuJcurnGRl/O3lgxwrI9PJCe0xzgH5MRRP/crK5Z75ZSTBeDQ991axWrMqYkuJqSCzsEuqYZPYmWvPwTAGP96ujh+ft+kWthDgGNMFa31F8EmMvr5BentV0k0XpTMGJdIHejbt8Z8XfG17H6OSK3trQ3M07/TWzKzCpBSILk7rQ== 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=kzRyHYGvA59H3gm+aPAmUG2HynyuKF0tfH+yBRDXvnI=; b=bZTmmFwr1fzupd1ri4pFhSL4PPGGkpuSGRqPz1FPmG8ELRUA8/jUUhw3HxliQVcshZ8NG7vc5l5Bohewf3EOcZorZ7Oc9Yd+AFanRTN27x3iNHLUp3n9RPaCAD/cLuqbv1oI32+8BHJdFjqRqqXWADqx7rSWGP7Lxr2IZ3eWSHVPorVLcfyaOCr8cYS+P82VD2NeHvkRr5k9FzEVQgLwORtYsQDIiA8kwDeGckCG6pZjbXDgcKVtQAN+FSxQkUSYCMrA8DWyOrdTXZQdOpdMfvDLjrTO1XypGET5N3pWt5IgnDeGxR/fQN9SO9FYFqYUqvc/oxmksCWUcuXXGW8A9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from DM5PR13CA0038.namprd13.prod.outlook.com (2603:10b6:3:7b::24) by MWHPR12MB1486.namprd12.prod.outlook.com (2603:10b6:301:10::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24; Thu, 14 Oct 2021 09:33:00 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:3:7b:cafe::d9) by DM5PR13CA0038.outlook.office365.com (2603:10b6:3:7b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.8 via Frontend Transport; Thu, 14 Oct 2021 09:33:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT047.mail.protection.outlook.com (10.13.172.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Thu, 14 Oct 2021 09:33:00 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 14 Oct 2021 04:32:58 -0500 From: Zoran Zaric To: Subject: [PATCH v3 05/28] Add to_value method to DWARF entry classes Date: Thu, 14 Oct 2021 10:32:12 +0100 Message-ID: <20211014093235.69756-6-zoran.zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211014093235.69756-1-zoran.zaric@amd.com> References: <20211014093235.69756-1-zoran.zaric@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 524e87e6-0a78-493c-79af-08d98ef59cf4 X-MS-TrafficTypeDiagnostic: MWHPR12MB1486: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lJRIbTfIL5r/J86lb8f418hnhLNfw+L7uiwwBhcQEJb5v/bMVZiLKoTDiaOwxMM0ynyyWLo9PJTfQI+dHBx1FYxPrcqA43k8Twx/4mZYvx6J8y8E/jpxYq2cXmCOnys85L6Uo/P5Cj8W//P5okIKhnH0qReAaC7mau52EF62l+q1hBto+4M2naaieiQ/xfuCNsboXr+qJOWvjX0DiRUmtSID/4uZ8TO7RyLZSzilbc3gndKV35isiChdreqQzMEG6lsK9kC4dijWtQI1HpUSKvNA9V3P8ODDcOBnN6M5DbRnRTAyg6GOeP8K881GMpH62VmaL+pvK3ZQLgqP4i5/UvpgABNa++ik6AbLaXJFtJZm8C0/2+eL2PyftLP9WVtHVIt1rM0tGOkG+wHk2a3mnbF7/QeHcRKyPD3wZ46DnszO8gpJrUJDMFupakW/xmfWnTeVVWCHNt6B2tyuSGPojnKD+Rp691bhMz81XTgoWBmw0uljHNyLZazotpmb3Gf8Vnr22Mlc1c9SxTPNG42tsDn1f30WGhMAV+1Bf/8sOlRrJln/BKOgaWE6UyOQi2QkV2PkX9KvvtRV4wrx6V5mlNOrOg8NVnVOJo9mr4t7E+wRPqRUECnLKGtW4GZ2a3Jzdqfe2/Zk0HdfR5p7Ej9WnOoTcMLlguW5j/cd3pdtJVGhi3CM5t4h+CrCrTxxT8g+/Vw1bsNuOFQQqAZ/gffLbWdOtnu9DHwb3zFHpczfobk= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(4326008)(36860700001)(2906002)(81166007)(356005)(6916009)(86362001)(36756003)(426003)(82310400003)(2616005)(336012)(5660300002)(8676002)(47076005)(44832011)(316002)(16526019)(70586007)(8936002)(6666004)(26005)(70206006)(1076003)(186003)(508600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 09:33:00.0231 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 524e87e6-0a78-493c-79af-08d98ef59cf4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1486 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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: 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: , X-List-Received-Date: Thu, 14 Oct 2021 09:33:05 -0000 From: Zoran Zaric Following the idea from the last patch this patch is adding another conversion method from any DWARF entry object into a DWARF value object. Currently, we only know how to convert from a memory location description into a value, but it is resonable to expect a set of target hooks that would let the target decide on how to do other conversions in the future. gdb/ChangeLog: * dwarf2/expr.c (dwarf_location::to_value): New method. (dwarf_memory::to_value): New method. (ill_formed_expression): New function. --- gdb/dwarf2/expr.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 5d443edfd9d..56f17f52756 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -100,6 +100,14 @@ bits_to_bytes (ULONGEST start, ULONGEST n_bits) return (start % HOST_CHAR_BIT + n_bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; } +/* Throw an exception about the invalid DWARF expression. */ + +static void ATTRIBUTE_NORETURN +ill_formed_expression () +{ + error (_("Ill-formed DWARF expression")); +} + /* See expr.h. */ CORE_ADDR @@ -283,6 +291,7 @@ write_to_memory (CORE_ADDR address, const gdb_byte *buffer, class dwarf_location; class dwarf_memory; +class dwarf_value; /* Base class that describes entries found on a DWARF expression evaluation stack. */ @@ -330,6 +339,16 @@ class dwarf_location : public dwarf_entry m_initialised = initialised; }; + /* Convert DWARF entry into a DWARF value. TYPE defines a desired type of + the returned DWARF value if it doesn't already have one. + + If the conversion from that location description kind to a value is not + supported, throw an error. */ + virtual std::unique_ptr to_value (struct type *type) const + { + ill_formed_expression (); + } + protected: /* Architecture of the location. */ gdbarch *m_arch; @@ -395,6 +414,8 @@ class dwarf_value : public dwarf_entry struct type *m_type; }; +using dwarf_value_up = std::unique_ptr; + /* Undefined location description entry. This is a special location description type that describes the location description that is not known. */ @@ -419,6 +440,8 @@ class dwarf_memory final : public dwarf_location m_stack = stack; }; + dwarf_value_up to_value (struct type *type) const override; + private: /* True if the location belongs to a stack memory region. */ bool m_stack; @@ -439,6 +462,12 @@ dwarf_value::to_location (struct gdbarch *arch) const return make_unique (arch, offset); } +dwarf_value_up +dwarf_memory::to_value (struct type *type) const +{ + return make_unique (m_offset, type); +} + /* Register location description entry. */ class dwarf_register final : public dwarf_location -- 2.17.1