From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2068.outbound.protection.outlook.com [40.107.93.68]) by sourceware.org (Postfix) with ESMTPS id 163493858036 for ; Fri, 5 Nov 2021 11:39:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 163493858036 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mn1wccaYaZ43/of4TdbytDXdLBjmKD6ckafaLkP4wIGJFJAepH989hRbwrXB43CJEEjxvpikBt59A8kNePGLMxRLPfdgWw0ldeFVVlUten3A4UPwbW7bAGG0zQudGlF3x05LeoOcsqtEDc63gtsdxPdpxgrgAdkceUl8i0mdBJxm7U73I0bVufTMu7un40qeuLA7js5EPjdKsc4qd2bMx8XqZ83+ot+gd5kyKACfCkZIMdG0DoQvxoSdOSkEu2U4QamgUoOLhgeM9x+m0xK4d+pXMwq69H1lvZNV235ZmliQNmZgMESGiu9aEJB0kW/4th8EIbDCM+bkUFnVlqvZaw== 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=yXVzyPec7fd8bBOqvPOxNhhZ0LIukvhSCrEqLwSziYE=; b=h+2DiCM+htInP4d+LKIRlatoizMo05M6dyonYAeWUI5QydglGOjwPNLqjf4mUtiKE9EuzEmrKY+lTnsBVWCi7qD+QOPAe91A6RK8bESpcIp0/uBie1mmL2y36nbndqQoM3Td1IBKKplnt2Clg41RvmSOO/bC5HCRfMDrNl2H/462DYyNCx9KE+C+yTAXfj8HwrIKcxqpE5AMXGWVoFMAdMnfTE0Kfj6KcEUp7hXQCpeBSnJ7ePU5NpWESeykAWeajtbP8LPvYtY9CnFWHffUBP0uA3OYtzqs/+TJftB2vHVx7ktCbb7HmmyfrXNtembPNcYCvmBnc5KwS+cSrUpHDw== 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 MW4PR04CA0159.namprd04.prod.outlook.com (2603:10b6:303:85::14) by SN1PR12MB2384.namprd12.prod.outlook.com (2603:10b6:802:25::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Fri, 5 Nov 2021 11:39:14 +0000 Received: from CO1NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::c0) by MW4PR04CA0159.outlook.office365.com (2603:10b6:303:85::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Fri, 5 Nov 2021 11:39:14 +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 CO1NAM11FT047.mail.protection.outlook.com (10.13.174.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 11:39:13 +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.15; Fri, 5 Nov 2021 06:39:09 -0500 From: Zoran Zaric To: Subject: [PATCH v4 05/28] Add to_value method to dwarf_location class Date: Fri, 5 Nov 2021 11:38:26 +0000 Message-ID: <20211105113849.118800-6-zoran.zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211105113849.118800-1-zoran.zaric@amd.com> References: <20211105113849.118800-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f7c91210-b1d2-45e9-9009-08d9a050e472 X-MS-TrafficTypeDiagnostic: SN1PR12MB2384: 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: iuRBCu0KLzDFf+h4pixUPl46qSRO2H4yeAB5Du7kVU1cMJult1lyRH9E6AN69rmpbj/Ax7Rybx9xrRS12pa1K1ybXnC8aYn1KoIzoh0N6+HCrho8btRflpHykgRQRQ3JEWz1w2sUae9AoOhna90+UyPsFcvLBBLqdwbetNIwiFcsK0krKAPcz5pWk6ZvozV4CgVUU3SYe3/c4w+GEu/ATEgwQP+lxusHth5JOLvHEkyocb+rVthAGhLfq/O/HDpJrnw13dAoZwKnEh4q2wQl7izdXIzGrEY3XQX/gwpdDtNo+ijWIw3V4XMtqv8PfH7wbNcr7jxnsA8ZPJp5tAUfW+kCLJK6QVDLfLtqsyGKvExdRjiLzFGnc34pu0kRHdRxR1NNiriGrmeaIOXMG74Hl+/SCXKltMiTmuzSrVcaPZ07HsBRAe9pVooszg5oxUUW/SoY33r+p7jk3drqzUyDLv8oTSiB5UInDcUjX/kcLSG9yiBjku/Kdanvpypj5aGz+D9TRm1Bd8fGyd6mb3TgJ0NjyTLCQeVs7hZCE0U6I5N7zBLYix2//xm3Evt9FJTS84JHwqOM4jihOl/GQQuJAVvjDUXPYTNOOkrVQCW7Yox0QzWeumxuVUYfxrmWUT90olYy2FD8GCsSVR3I++HBQE3Fw8Q4D79vW1kLRsXmNa9PVUAz+d3BXNoOKmsaUWfn79mO9xfxjUU1k2WxC5+uzknXkgKOrWwD8tPPReyWUo0= 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)(2616005)(26005)(70206006)(186003)(82310400003)(1076003)(44832011)(426003)(6916009)(316002)(356005)(2906002)(86362001)(36860700001)(81166007)(47076005)(6666004)(8676002)(336012)(508600001)(36756003)(8936002)(5660300002)(16526019)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 11:39:13.8487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7c91210-b1d2-45e9-9009-08d9a050e472 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: CO1NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2384 X-Spam-Status: No, score=-12.3 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: Fri, 05 Nov 2021 11:39:18 -0000 From: Zoran Zaric Following the idea from the last patch this patch is adding a conversion method from any dwarf_location derived 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 2cb93706ac4..e9e5e55ca61 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -90,6 +90,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 @@ -272,6 +280,7 @@ write_to_memory (CORE_ADDR address, const gdb_byte *buffer, } class dwarf_location; +class dwarf_value; /* Base class that describes entries found on a DWARF expression evaluation stack. */ @@ -321,6 +330,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; @@ -391,6 +410,8 @@ class dwarf_value final : 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. */ @@ -415,6 +436,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; @@ -435,6 +458,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