From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0BQeDFb+PGAGJAAAWB0awg (envelope-from ) for ; Mon, 01 Mar 2021 09:46:46 -0500 Received: by simark.ca (Postfix, from userid 112) id 2D6CA1EF78; Mon, 1 Mar 2021 09:46:46 -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 ED2361E590 for ; Mon, 1 Mar 2021 09:46:43 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AAC1E3938C00; Mon, 1 Mar 2021 14:46:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAC1E3938C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614610003; bh=r3T+YQ5wHmkyoLHO81ZSmL5I6Oz/2oO17vmfH8MecbQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dhBPxWD+5H8dHcn4cJAQJ62FliYdXzHhQM22IJGYzc8spH8rwdUKAYzaDtANIhU9x o4d1WNc8CaskPhYrGHTH4/aK7KpkE+6IrCdkn3e44ErLPp9zgyyl4vGUpyUyVRFOaB /4+iMUOUAtul8tBRdQyLnX7wpBPTIc415S8T6xt4= Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2066.outbound.protection.outlook.com [40.107.236.66]) by sourceware.org (Postfix) with ESMTPS id 61B5138A28BF for ; Mon, 1 Mar 2021 14:46:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 61B5138A28BF ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dw77Hfo+tCwGZqL1MBSsxWN9k6ysAXNKAAAifMQ8PFtbor8lPY5g1sme6l1WQThmqvh95zwZoz3jlpszL3Xk4wzwZBEhlWRI0XWK+dw2mMYpm2AH8MWc0LCMmkwYb3PQAO4i9uqHQv1WbFPygmYH4kbfv4GPtgqXDUMp1C7aTWSUoTorgXt9nZZP8fJWgPWhuyq8pwOlT2o2pl4MOb2T/ipyhNIfruOY6oyIXCSng5VF0wbx5fElUeBBIYShJGApk7HCwzwvwov7jlSxWkA3iibH8QIRjFWqUbRO5mI9VaCncInYfHix3/eVd2qH+NeE4PsrCSQKlH1j5bbLAW+aCA== 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=r3T+YQ5wHmkyoLHO81ZSmL5I6Oz/2oO17vmfH8MecbQ=; b=Nv5yaynI7Hh6X9tUnkzgCe1xeBSjkZHEOUI0PDHuxeTHP59XPwS+DBRl1G9aqhD56QXhN+fykXrQEgUYS9HrZTxmaYqvVK037j3ffcoYfLsEO+0LgUxOs+ntn5wC/wyyseyEGVzg/rVaWiLfYq+RleVuiF1bUAqfez4/Pd1LY41kxEkzGE2nr8rzkWxmKZNH6Y3FiSK9uYgYJP586AFs8qve3NDVlCNxnqu9CCjYhFj8WiGyoSMCkUZaOrzAzsAjr85aiAWzNFIaJBIC/wWFTR0fxdzHQksLIGXR+UpHoRlK6BOnHFYKta+FD13Gjn80rSn6nUzWMG5NHsnbDvls5g== 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 DM5PR1201MB0236.namprd12.prod.outlook.com (2603:10b6:4:57::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.28; Mon, 1 Mar 2021 14:46:39 +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:46:39 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 00/43 V2] Allow location description on the DWARF stack Date: Mon, 1 Mar 2021 14:45:37 +0000 Message-Id: <20210301144620.103016-1-Zoran.Zaric@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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:46:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d2c310d1-6cc3-4aba-8f83-08d8dcc0d1d9 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0236: X-MS-Exchange-MinimumUrlDomainAge: llvm.org#6197 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: Mt5Wq7tat0aczOxYtUTKwBsUtF75jbrchFbMY3cSKYJPMeqt7jWKSVTH2WYiFgovKK+6G8exaL6DIk4S2mKofEPa3KkgdtOC6qbTX9mHfYhuhz4VMRwMzqluJMtGdo828cgZy1vGMfC5EcwJUh+U6FXOBPQLaC1dGwd30G8ynvf5kHB6OUK97nRG5DEzSy+K5ZWixYrZHXSI4DVfTRxq7hmzYKSXsnLxaGOE5hvjxP2kxadAjKl2KGbSQKo9prrVvHwS4rkwmMVNs/47p0vcC7JbqrdmtXHd8Pr441Jq1CSakV0xxeodX8yHUwevi0+SbCtE9OdCAT9sVRTizv+u6zLxRPwKFSxNJ+RNZ6tYGTlmGvgPuznVaRoOlpn4dctjRPP0ZJVQ90eHLP34QUe0TaIJG+RmYhDbWxLjTw05KuBjmx9Xb0xxbeVLKrkMt8GK3oVnRBWDJHmhN1cbupswISl/tmO65mG+/4cJYbZdn4rvaujqe0c+3//wBLnJUMFHP86/DmyjvEgETMD7lKQKAR6gxa2mf/CN2DEF2OYFFXSMC0xMfq/d4sU04jDwYZNUxuADdEVnvMEc8lXw6P226ISuD7UD6gOnwQ0k4HBa7II= 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)(136003)(39860400002)(396003)(346002)(5660300002)(16526019)(1076003)(8936002)(52116002)(966005)(478600001)(83380400001)(2906002)(6486002)(66476007)(6916009)(86362001)(4326008)(2616005)(316002)(66946007)(8676002)(6506007)(36756003)(66556008)(6512007)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?VC96L1hha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khaUHdLWmx3WjRu?= =?utf-8?B?SHJaZFJmamRnOG5RNEMrUnpqRzlTejg3VzFUdStmOExkd1loaUU0Rys3cTZq?= =?utf-8?Q?Zqnkmn0fNBV8/?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2c310d1-6cc3-4aba-8f83-08d8dcc0d1d9 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:46:38.8561 (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: qxzbDjzTMX/L/3Ke+LfqEmoSsOz5lxUCwQW2Z4BVvtmJjtGPV+U/fr3zgZp1lKB1GAn/WnMVMsWIuB0msypMLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0236 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" Based on gdb master: 8255cf421c513747b7e189f932ca6e5b450e0d46 The idea of this patch series is to cleanup the design of the DWARF expression evaluator (dwarf_expr_context class) and allow a future extensions of that evaluator needed for the upcoming vendor specific DWARF extensions. Main motivation behind this series of patches is AMD’s effort to improve DWARF support for heavily optimized code, but more specifically, optimized code for SIMD and SIMT architectures. These patches are part of the AMD’s DWARF standard extensions that can be found at: https://llvm.org/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.html While trying to support optimized code for these architectures, we found couple of restriction imposed by the version 5 of the standard: - CFI describes restoring callee saved registers that are spilled. Currently CFI only allows a location description that is a register, memory address, or implicit location description. AMDGPU optimized code may spill scalar registers into portions of vector registers. This requires extending CFI to allow any location description. - Optimized code may need to describe a variable that resides in pieces that are in different kinds of storage which may include parts that are in different kinds of memory address spaces. DWARF has the concept of segment addresses. However, the segment cannot be specified within a DWARF expression, which is only able to specify the offset portion of a segment address. The segment index is only provided by the entity that specifies the DWARF expression. Therefore, the segment index is a property that can only be put on complete objects, such as a variable. Another problem is with DWARF DW_OP_xderef* operations, which allow a value to be converted into an address of a specified address space which is then read. But it provides no way to create a memory location description for an address in the non-default address space. - DW_OP_breg* treats the register as containing an address in the default address space. It is required to be able to specify the address space of the register value. - There is really limited support for bit offsets of location description. This issue was already found by others who worked on packed array support for ADA language. The array could be packed in such a way that their start is not byte alligned. There is no way to describe this in DWARF, so gdb implementation in required for the packed array to be copied to the byte alligned addresses and then passed that buffer in the expression evaluator. This approach is restrictive for more complex scenarios. All these restriction are caused by the fact that DWARF stack can only hold values which size is not bigger then the size of the DWARF generic type. This means that intermediate result of any DWARF operation needs to fit in such a small representation. DWARF Version 5 does not allow location descriptions to be entries on the DWARF stack. They can only be the final result of the evaluation of a DWARF expression. However, by allowing a location description to be a first-class entry on the DWARF stack it becomes possible to compose expressions containing both values and location descriptions naturally. It allows objects to be located in any kind of memory address space, in registers, be implicit values, be undefined, or a composite of any of these. This approach unifies the location description operations with general operations. This in turn allows addition of new DWARF operations which can push a memory location description with any offset and in any kind of memory address space. The number of registers and the cost of memory operations is much higher for some architectures than a typical CPU. The compiler attempts to optimize whole variables and arrays into registers. Currently DWARF only allows DW_OP_push_object_address and related operations to work with a global memory location. With this change, push object address mechanism can be modified to work with any location description. This would also removed the need for the passed in buffer mechanism that ADA and GO languages currently use. The proposed implementation in this patch series is completely backward compatible with the DWARF 5 standard. Although the patch series is designed as a whole, the first sixteen patches could be viewed as a standalone subset that introduces a welcome cleanup of the DWARF expression evaluator module. Zoran Zaric (43): Replace the symbol needs evaluator with a parser Cleanup of the dwarf_expr_context constructor Move frame context info to dwarf_expr_context Remove get_frame_cfa from dwarf_expr_context Move compilation unit info to dwarf_expr_context Move dwarf_call to dwarf_expr_context Move get_object_address to dwarf_expr_context Move read_mem to dwarf_expr_context Move push_dwarf_reg_entry_value to expr.c Inline get_reg_value method of dwarf_expr_context Remove empty frame and full evaluators Merge evaluate_for_locexpr_baton evaluator Move piece_closure and its support to expr.c Make value_copy also copy the stack data member Make DWARF evaluator return a single struct value Simplify dwarf_expr_context class interface Add as_lval argument to expression evaluator Add new register access interface to expr.c Add new memory access interface to expr.c Add new classes that model DWARF stack element Add to_location method to DWARF entry classes Add to_value method to DWARF entry classes Add read method to location description classes Add write method to location description classes Add deref method to location description classes Add read_from_gdb_value method to dwarf_location Add write_to_gdb_value method to dwarf_location Add is_implicit_ptr_at method to dwarf_location Add indirect_implicit_ptr to dwarf_location class Add new computed struct value callback interface Add to_gdb_value method to DWARF entry class Change DWARF stack to use new dwarf_entry classes Remove old computed struct value callbacks Comments cleanup between expr.h and expr.c Remove dwarf_expr_context from expr.h interface Move read_addr_from_reg function to frame.c Add frame info check to DW_OP_reg operations Remove DWARF expression composition check Change back the symbol needs to use the evaluator Add support for any location description in CFI Add DWARF operations for byte and bit offset Add support for DW_OP_LLVM_undefined operation Add support for nested composite locations gdb/ada-lang.c | 2 +- gdb/compile/compile-loc2c.c | 11 + gdb/dwarf2/expr.c | 3419 +++++++++++++++-- gdb/dwarf2/expr.h | 275 +- gdb/dwarf2/frame.c | 163 +- gdb/dwarf2/loc.c | 1271 +----- gdb/dwarf2/loc.h | 34 +- gdb/f-lang.c | 4 +- gdb/findvar.c | 4 +- gdb/frame.c | 37 +- gdb/testsuite/gdb.dwarf2/dw2-llvm-offset.exp | 328 ++ .../gdb.dwarf2/dw2-llvm-piece-end.exp | 192 + .../gdb.dwarf2/dw2-llvm-undefined.exp | 144 + gdb/testsuite/gdb.dwarf2/symbol_needs_eval.c | 25 + .../gdb.dwarf2/symbol_needs_eval_fail.exp | 108 + .../gdb.dwarf2/symbol_needs_eval_timeout.exp | 127 + .../amd64-py-framefilter-invalidarg.S | 1 - gdb/testsuite/lib/dwarf.exp | 8 + gdb/valops.c | 129 +- gdb/value.c | 69 +- gdb/value.h | 4 +- include/dwarf2.def | 6 + 22 files changed, 4329 insertions(+), 2032 deletions(-) create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-llvm-offset.exp create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-llvm-piece-end.exp create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-llvm-undefined.exp create mode 100644 gdb/testsuite/gdb.dwarf2/symbol_needs_eval.c create mode 100644 gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp create mode 100644 gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp -- 2.17.1