From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wCM4G+t7zl9ETQAAWB0awg (envelope-from ) for ; Mon, 07 Dec 2020 14:00:59 -0500 Received: by simark.ca (Postfix, from userid 112) id 6D87E1F071; Mon, 7 Dec 2020 14:00:59 -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 4247A1EF4B for ; Mon, 7 Dec 2020 14:00:57 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EE93D393D01D; Mon, 7 Dec 2020 19:00:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE93D393D01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607367657; bh=zOIeLhtLmkZuH/U21dqOvSyFJJVRRD/JOXU8aEGQOF8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=a7+2pL4U3SHzB4Q9DjhgE9JY/sRkKyaHqFxdCJh39lBFiNsZxvpwPRjhEGfxEXIYp 7h60+9jG/lb1AQWFu1/s0g5QQXhgBLD842cOyX3SIP+tObjP6oeN+SnSZI5ekHs3Cl oXZO9Ah6eTAfECdgLYeVq42q2vK3fvuvr3q6LDfk= Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by sourceware.org (Postfix) with ESMTPS id 14BE73896837 for ; Mon, 7 Dec 2020 19:00:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 14BE73896837 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g+tdGHOhuHrNI+im0GnU0fmMVj7johzGyOeTpOhtvJaDzQF9/qjkDleeyi2fWRejRtDYKW/1Lr9ziC+HKO7oTyXtsFSZQAw2a7OvaVTvaUBArcHSF0PQeiYqnALZLeAMKljz364Eh/qZInc4GNuTLsU6Hvllb/KWQg62T4otigFucdAKP5M+kVLNKPP/olfiVbTfoUjdHvu4zNGf0lP7iRRWUUaDnnWBqOGysesqTH78YIZ2Cb6w70wQT1OO9V5u4Rcj153fLgGdKsYDqQ0Bl8RDPcO9JYdteHWSrpH3Qf8kkGknsMLuMKv2036PGkJYdVo+beyFTsguPYuaZXERyg== 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=zOIeLhtLmkZuH/U21dqOvSyFJJVRRD/JOXU8aEGQOF8=; b=jW59sqr2vYnLv1YuWi5Ql2nSn4rBHFlZ1rQljKK+flkwYrTRWlsYmz81xpNTVe8gXIxcJgDzu/y2zOcKV7a0uaF/eHYqtXIOXOTYia6T0QKcSCO1luMREl+gYREU9fvZJ3E6tZBFBYjodjYS/jNIkAZnmoscsToDemFHKrpOcFsxOVPXi4Zr4F17ploUpXHQf/3K7fs82O9Pd6gDIao8NtYTTuVr6ip3Mf+cc3+WSLSmrXKoDJ4pAaL0xfUxGjHjM68wsHZ3Wj9aajMzY1JXcex3fvnZXY/l8Ia+3+G7daKe0JVl6bbsF4Qil9OEAH1gPaXOJFwbibd83JQV5meAZQ== 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 DM6PR12MB4561.namprd12.prod.outlook.com (2603:10b6:5:2ac::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Mon, 7 Dec 2020 19:00:50 +0000 Received: from DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::6841:61df:984b:b3c]) by DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::6841:61df:984b:b3c%3]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 19:00:50 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 00/30] Allow location description on the DWARF stack Date: Mon, 7 Dec 2020 19:00:01 +0000 Message-Id: <20201207190031.13341-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:5c7:2db6:d2c2:ae4e] X-ClientProxiedBy: AM4PR0101CA0053.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::21) 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:5c7:2db6:d2c2:ae4e) by AM4PR0101CA0053.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Mon, 7 Dec 2020 19:00:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 50c3d370-d3a7-4ba8-cf4b-08d89ae26a2d X-MS-TrafficTypeDiagnostic: DM6PR12MB4561: 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: BT1tA/wrBtKng2cGmxvp3QyLca77hLKbbOJcjJ74uiHqAo7diiv0sgW7YHBWq2FPCs5m40OGT3rdVyo5f3qTmpLvUqKM1L/R42aqEntyMSmOrGhn0f/JuJTm69S/aqWNJMsslgFgnwheuYv+Ek3JfOZxSpwB1ARUItOZuc/A0ysC6d8cbdESEHXms7sY7AN4e5zWU3Y1wgkSGkbufbkEz0+cvpXBpTUHwAwTFSZwIwjn5/YoeXzYx8Ovu8qi3Ah6elQ4iaIp+VJbIWdxwONfcPTjD2Zq0skjjBy0y006+sFl6QlD6D7wcH9KQgMOqDS41PM8TmzEVQk2psl6+hUm57y7UPbgeGOnq6kesF9NiI4r3HRFEgQO/xvfTkgANyFQIpk8NuhXrg2spgNsKz3nRA== 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)(346002)(39860400002)(366004)(136003)(396003)(1076003)(83380400001)(86362001)(6506007)(4326008)(52116002)(36756003)(2906002)(6512007)(8676002)(966005)(6486002)(16526019)(2616005)(66946007)(66476007)(66556008)(6916009)(5660300002)(186003)(8936002)(478600001)(6666004)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?WjRQUlBGVmIvZ0xCYzNNMXNHZHlrek5SUm83Z0pZaTBpejdDQkhsSzdQVDcz?= =?utf-8?B?ZnQ5dGVXWTN0OTIvT3N4ZC92WXdlb3h3YWt3Uk95aURPR3ZjSTBETDRKdkxo?= =?utf-8?B?K2FyM0o3eVFWZElOa2FjSC9FRkU4L001djJ2K2l2NmNBYllqNXA3aGRsK0ha?= =?utf-8?B?bzR5SFRaNmxwR29ObGgzTnlDVG56SldLS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3dHcWFYQzFyd21RbGROMjNrc3IycnR2dzZnSkxMYzl3NGVWQk9m?= =?utf-8?B?b2d4aVFJTWllbTh0UjFDRm8yUVJCZjJpakw3UHdVakE4NmRsc21sNXV2SVVT?= =?utf-8?B?cmZXdlptdTBYNzFwNjQweEYxcTVMRHBNaHFRZm9ldHRkS0RiUTB4d29QSzM3?= =?utf-8?B?MTB1S3NFUDVrbllSZXB0NDZsS0xXN3BzejY3TTVQbmtic2VDVERTakM2NFpq?= =?utf-8?B?amZudXNieVpDSE5YWHJ4a2dZS1Z3VWdmRlJkRWdoTXFqSDNHSzRjZ0F6VnlG?= =?utf-8?B?dWxURDNYbnVZL3pld2xqQk4vT1lHU052RVFoRzMzWVRJU3RqRVMyNmt6V25j?= =?utf-8?Q?Z2eiGbJW?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 19:00:50.4470 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: 50c3d370-d3a7-4ba8-cf4b-08d89ae26a2d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pMzpk+QZTGJ9WWq4wX+iGZJC4XN09vRcN8+aTVLUC53WzQ3uA+WAoz8o1qUsAgLsDRxb1nNKF+8QrwT6hb7qwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4561 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 Cc: Zoran Zaric Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Based on gdb master: 13f11b0b61ca2620611b08eeaece0ce62c862f4b 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 fifteen patches could be viewed as a standalone subset that introduces a welcome cleanup of the DWARF expression evaluator module. The patch series is based on a patch that is already in the review process, so it had to be included in this series as well. The review for that patch can be found here: https://sourceware.org/pipermail/gdb-patches/2020-November/173638.html But I don't mind it being discussed as a part of this patch series. Zoran Zaric (30): Replace the symbol needs evaluator with a parser 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 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 new location description access interface Add dwarf_entry factory class to expr.c Change DWARF stack to use new dwarf_entry classes Remove dwarf_expr_context from expr.h interface Rename and update the piece_closure structure Move read_addr_from_reg function to frame.c Add frame info check to DW_OP_reg operations Remove DWARF expression composition check 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 | 3406 +++++++++++++++-- gdb/dwarf2/expr.h | 275 +- gdb/dwarf2/frame.c | 163 +- gdb/dwarf2/loc.c | 1885 +++------ gdb/dwarf2/loc.h | 34 +- gdb/f-lang.c | 2 +- gdb/findvar.c | 4 +- gdb/frame.c | 36 +- gdb/testsuite/gdb.dwarf2/dw2-llvm-offset.exp | 328 ++ .../gdb.dwarf2/dw2-llvm-piece-end.exp | 191 + .../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.python/py-framefilter-invalidarg.exp | 2 +- gdb/testsuite/lib/dwarf.exp | 8 + gdb/valops.c | 123 +- gdb/value.c | 68 +- gdb/value.h | 6 +- include/dwarf2.def | 6 + 23 files changed, 4841 insertions(+), 2114 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