From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OMeeOXr+PGA3JAAAWB0awg (envelope-from ) for ; Mon, 01 Mar 2021 09:47:22 -0500 Received: by simark.ca (Postfix, from userid 112) id CA7A21E590; Mon, 1 Mar 2021 09:47:22 -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 65FBE1E590 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 7F8E03938C1F; Mon, 1 Mar 2021 14:47:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F8E03938C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614610036; bh=EQokkBfoZIvIjgPMhvCE+BqKsxNI3z9LpxUzZWFUxdM=; 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=uKNTGj2VLKl1ZmNl6ZXurwtmvSzDgcS71ITafFwLcGHyWm/yuAOUm0bIzWIQCvM7X 7ezCtIyaRs5miGLkQkLUzOK/8bLNxh+WD4zhsRUNZcluaRCiOBdhEkfnmUHjMb2twW gRlJ68NhgQu9+7re9u4Ak9V95jPWhfddN9sxYJ1U= Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2075.outbound.protection.outlook.com [40.107.244.75]) by sourceware.org (Postfix) with ESMTPS id 9ACFD3939C0C for ; Mon, 1 Mar 2021 14:47:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9ACFD3939C0C ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N1xymILFphoodMn4R8FYiBpj4KLMcYU4kPyJycSTuJwwoqip4I7wjUz6XnKCmxTzyOhmj3k2mOhfM7jOhHP4fJQYYPTpFi1masNDiHexNJTQTffMzV5y0C47u61EHRREXyzRprmqef6pVHcdID879ZZtevwBMLA8lVRZxEezaV6bOvfNf0WzhUKapnyIz86NDujdJosYYOiR/1xklKRlbI4zrKmZfxWpAQdVVKONuZrbtWLwsQtIaOpoC+NVQuYMHB0LKYEG+2YvkQ7wq0nPK3L6dwELa9RY+VKegkzfjc0lUyGU+Eue9WKPP12pL9CYbGLhU4GvGjgHl1wjdD9afg== 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=EQokkBfoZIvIjgPMhvCE+BqKsxNI3z9LpxUzZWFUxdM=; b=Ri+ZbrvT1+2tDiOxtNHvuX4BfQA7InC/viSKVqlt7znk4gV064i/LJaAzVm0YhP/qN6ILw0Lk664IDBLasIEMOBqxW3prwSgFZvJ0CgJ8iXf7cw5x4VdHGcgkHRxvQwA6stk51OVE9zhsT/UtEBhfumZL/GCkK6rfKd8EcBozBy76HRHsYvWeJ9F32eEsId/zfATih6uAmsgF9V2DqfCfvWVGQTEp9P0SWptguLTqDZLAuRpcg1PlTvNknbQ+NBBPDX6pkD9zRJw4KyXLb3dhhljY5ojDQHrGOtT+LWkAmv9EhVDu74JKEnTArlESfNuCRzOkgI8vOEHvcHNiN0FdA== 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:02 +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 20/43] Add new classes that model DWARF stack element Date: Mon, 1 Mar 2021 14:45:57 +0000 Message-Id: <20210301144620.103016-21-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; 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:47:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 24944762-0d1a-40ef-7e16-08d8dcc0dfa3 X-MS-TrafficTypeDiagnostic: DM6PR12MB3676: X-MS-Exchange-MinimumUrlDomainAge: llvm.org#6197 X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qErX0NCCPuSDcMy85OC/LsLMwThFLe0wXBNTV2CJRu5Oev7NYnbf4ogGOcc1rqUNwClDSYH0Uoit4lJ4eh4b05U1UytbuyCSbnzj/mWoL2bFO2rlhLk/fLU3FQ7RAHDxaFSgkLVrbuLczhOH39cv3JfQWwSPXrWOZJGgBPBejxFFz2XutCO3ILOzHQLelnlfXhYQcKeFoWYntq4s7/Nkg9zbJlvi6mnsUWqxANqLmInJdl5YlS2peKu3x76RdfByoqheW6/GeU0NEaitlz8y9qNlAiKGlNGyMKKVs8j06y9GRKbgQspCiuajcTZeoqJBMZRtTWgRUb9H9N1QlHOeYWgQCZk0Prufbk3OrLH62amfnkp/OYgq6/gOOK9ZeJJeKoVlmzkpe++YBXeb0buBEiC5t93CxOHttLmDYqAa52ulWGKYzVu11GPVfl9y448iF+vIdZgMBKhdHx5LcTkyAwFSdNwMB6YIb/Ysifuu1k9ykrlA+3SMHQP+Zl9ysXdBx3k4WJVyJBu7uqgzfoTvsjg8twNosWlhB1WtWvJeqxchyc2XBnBSZY8P1pPV+ike+p9hwyWqlxbc1k3JnQYtVlaTIUOeeom9XtHmo+39keE= 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)(2906002)(186003)(36756003)(66946007)(966005)(316002)(66476007)(8936002)(52116002)(86362001)(6506007)(478600001)(5660300002)(4326008)(6486002)(8676002)(30864003)(6916009)(6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UlQ?= =?utf-8?B?V05aeXBxSTlURW5HaVNYVjJNTnFrNDFDVDdwSldLZk5BNXRBVHZXU3NBbThD?= =?utf-8?B?eWVPY1h0VmtLZVh5WDhxd1cycytnWFRIQU9aRFhLTmt0cUhtamZzeHFYa1Qz?= =?utf-8?Q?EkR2ObxSh+ZeV?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24944762-0d1a-40ef-7e16-08d8dcc0dfa3 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:01.9469 (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: X6Ci0YOF4Zh+aFlLDAsGhUW6im8WcKhMPc/Q9I47q5iu01VAi+qglJAecg4/AS9oavH5duDIKSeysf+4N+TcKw== 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" The rest of the patch series addresses the issues described in a "Motivation" section of the AMD’s DWARF standard extensions that can be found at: https://llvm.org/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.html The document describes a couple of main issues found when using the current DWARF 5 version to describe optimized code for SIMD and SIMT architectures. Without going much into details described in the document, the main point is that DWARF version 5 does not allow a proper support for address spaces and it does not allow a location description to be part of a DWARF expression, unless it is a leaf node of that expression. Both issues can be solved in a clean way by introducing a new set of classes that describe all entry types which can be placed on a DWARF stack, while keeping a full backward compatibility with the previous standard version. These entry types can now be either a typed value or any location description. Currently, the result of an expression evaluation is kept in a separate data structure, while with the new approach, it will be always found as a top element of the DWARF stack. The reason why this approach is backward compatible is because in version 5, a location description is only allowed to be a leaf node of the expression or a composite piece. Question here is, why do we need a new set of classes and why not just use the struct value instead? As it stands, there are couple of issues with using the struct value to describe a DWARF stack element: - It is not designed to represent a DWARF location description specifically, instead it behaves more like unified debug information format that represents an actual target resource. One example of this is accessing data of a struct value register location description, where if the amount of data accessed is larger then the register, results in accessing more then one register. In DWARF this is not a valid behavior and locations that span more then one register should be described as a composite location description. - There is a tight coupling between struct value and it’s type information, regardless if the data represented is describing a value (not_lval) or a location description. While the type information dictates how the data is accessed for a struct value case, in DWARF, location description doesn’t have a type so data access is not bound by it. - DWARF values only support much simpler base types, while struct value can be linked to any type. Admittedly, new classes are still using the same struct value infrastructure for a value based operations at the moment, but that is planned to change in the near future. - struct value register location description requires a frame id information which makes them unsuitable for CFA expression evaluation. So, there seems to be a lack of separation of concerns in the design of a struct value infrastructure, while the new classes are handling one specific purpose and are completely encapsulated in the expr.c. Additional benefit of this design is that it makes a step in a right direction for being able to evaluate DWARF expressions on a gdbserver side in the near future, which sounds like a desirable thing. It is also worth mentioning that this new location description representation is based on a bit granularity (the bit_suboffset class member) even though the DWARF standard has a very limited support for it (mostly used for DW_OP_bit_piece operation). By allowing any location description to define a bit sub-offset of the location, we are able to give more options for supporting of new concepts (like the existing packed arrays in Ada language). In this patch, a new set of classes that describe a DWARF stack element are added. The new classes are: - Value - describes a numerical value with a DWARF base type. - Location description - describes a DWARF location description. - Undefined location - describes a location that is not defined. - Memory location - describes a location in memory. - Register location - describes a register location in a frame context. - Implicit location - describes a location that implicitly holds a value that it describes. - Implicit pointer - describes a concept of an implicit pointer to a source variable. - Composite location - describes a location that is composed from pieces of other location descriptions. For now, these classes are just defined, and they are planned to be used by the following patches. gdb/ChangeLog: * dwarf2/expr.c (class dwarf_entry): New class. (class dwarf_value): New class. (class dwarf_location): New class. (class dwarf_undefined): New class. (class dwarf_memory): New class. (class dwarf_register): New class. (class dwarf_implicit): New class. (class dwarf_implicit_pointer): New class. (class dwarf_composite): New class. * value.c (pack_unsigned_long): Expose function. * value.h (pack_unsigned_long): Expose function. --- gdb/dwarf2/expr.c | 264 ++++++++++++++++++++++++++++++++++++++++++++++ gdb/value.c | 2 +- gdb/value.h | 2 + 3 files changed, 267 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 1abece7d173..5d47dc83aaa 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -277,6 +277,270 @@ write_to_memory (CORE_ADDR address, const gdb_byte *buffer, length, buffer); } +/* Base class that describes entries found on a DWARF expression + evaluation stack. */ + +class dwarf_entry : public std::enable_shared_from_this +{ +public: + /* Not expected to be called on it's own. */ + dwarf_entry () = default; + + virtual ~dwarf_entry () = 0; +}; + +dwarf_entry::~dwarf_entry () = default; + +/* Location description entry found on a DWARF expression evaluation + stack. + + Types of locations descirbed can be: register location, memory + location, implicit location, implicit pointer location, undefined + location and composite location (composed out of any of the location + types including another composite location). */ + +class dwarf_location : public dwarf_entry +{ +public: + /* Not expected to be called on it's own. */ + dwarf_location (struct gdbarch *arch, LONGEST offset = 0, + LONGEST bit_suboffset = 0) + : m_arch (arch), m_initialised (true) + { + m_offset = offset; + m_offset += bit_suboffset / HOST_CHAR_BIT; + m_bit_suboffset = bit_suboffset % HOST_CHAR_BIT; + } + + virtual ~dwarf_location () = default; + + /* Add bit offset to the location description. */ + void add_bit_offset (LONGEST bit_offset) + { + LONGEST bit_total_offset = m_bit_suboffset + bit_offset; + + m_offset += bit_total_offset / HOST_CHAR_BIT; + m_bit_suboffset = bit_total_offset % HOST_CHAR_BIT; + }; + + void set_initialised (bool initialised) + { + m_initialised = initialised; + }; + +protected: + /* Architecture of the location. */ + struct gdbarch *m_arch; + + /* Byte offset into the location. */ + LONGEST m_offset; + + /* Bit suboffset of the last byte. */ + LONGEST m_bit_suboffset; + + /* Whether the location is initialized. Used for non-standard + DW_OP_GNU_uninit operation. */ + bool m_initialised; +}; + +/* Value entry found on a DWARF expression evaluation stack. */ + +class dwarf_value : public dwarf_entry +{ +public: + dwarf_value (const gdb_byte *contents, struct type *type) + { + size_t type_len = TYPE_LENGTH (type); + m_contents.reset ((gdb_byte *) xzalloc (type_len)); + + memcpy (m_contents.get (), contents, type_len); + m_type = type; + } + + dwarf_value (ULONGEST value, struct type *type) + { + m_contents.reset ((gdb_byte *) xzalloc (TYPE_LENGTH (type))); + + pack_unsigned_long (m_contents.get (), type, value); + m_type = type; + } + + dwarf_value (LONGEST value, struct type *type) + { + m_contents.reset ((gdb_byte *) xzalloc (TYPE_LENGTH (type))); + + pack_long (m_contents.get (), type, value); + m_type = type; + } + + const gdb_byte* get_contents () const + { + return m_contents.get (); + } + + struct type* get_type () const + { + return m_type; + } + + LONGEST to_long () const + { + return unpack_long (m_type, m_contents.get ()); + } + +private: + /* Value contents as a stream of bytes in target byte order. */ + gdb::unique_xmalloc_ptr m_contents; + + /* Type of the value held by the entry. */ + struct type *m_type; +}; + +/* Undefined location description entry. This is a special location + description type that describes the location description that is + not known. */ + +class dwarf_undefined : public dwarf_location +{ +public: + dwarf_undefined (struct gdbarch *arch, LONGEST offset = 0, + LONGEST bit_suboffset = 0) + : dwarf_location (arch, offset, bit_suboffset) + {} +}; + +class dwarf_memory : public dwarf_location +{ +public: + dwarf_memory (struct gdbarch *arch, LONGEST offset, + LONGEST bit_suboffset = 0, bool stack = false) + : dwarf_location (arch, offset, bit_suboffset), + m_stack (stack) + {} + + void set_stack (bool stack) + { + m_stack = stack; + }; + +private: + /* True if the location belongs to a stack memory region. */ + bool m_stack; +}; + +/* Register location description entry. */ + +class dwarf_register : public dwarf_location +{ +public: + dwarf_register (struct gdbarch *arch, unsigned int regnum, + LONGEST offset = 0, LONGEST bit_suboffset = 0) + : dwarf_location (arch, offset, bit_suboffset), + m_regnum (regnum) + {} + +private: + /* DWARF register number. */ + unsigned int m_regnum; +}; + +/* Implicit location description entry. Describes a location + description not found on the target but instead saved in a + gdb-allocated buffer. */ + +class dwarf_implicit : public dwarf_location +{ +public: + + dwarf_implicit (struct gdbarch *arch, const gdb_byte *contents, + size_t size, enum bfd_endian byte_order) + : dwarf_location (arch) + { + m_contents.reset ((gdb_byte *) xzalloc (size)); + + memcpy (m_contents.get (), contents, size); + m_size = size; + m_byte_order = byte_order; + } + +private: + /* Implicit location contents as a stream of bytes in target byte-order. */ + gdb::unique_xmalloc_ptr m_contents; + + /* Contents byte stream size. */ + size_t m_size; + + /* Contents original byte order. */ + enum bfd_endian m_byte_order; +}; + +/* Implicit pointer location description entry. */ + +class dwarf_implicit_pointer : public dwarf_location +{ +public: + dwarf_implicit_pointer (struct gdbarch *arch, + dwarf2_per_objfile *per_objfile, + struct dwarf2_per_cu_data *per_cu, + int addr_size, sect_offset die_offset, + LONGEST offset, LONGEST bit_suboffset = 0) + : dwarf_location (arch, offset, bit_suboffset), + m_per_objfile (per_objfile), m_per_cu (per_cu), + m_addr_size (addr_size), m_die_offset (die_offset) + {} + +private: + /* Per object file data of the implicit pointer. */ + dwarf2_per_objfile *m_per_objfile; + + /* Compilation unit context of the implicit pointer. */ + struct dwarf2_per_cu_data *m_per_cu; + + /* Address size for the evaluation. */ + int m_addr_size; + + /* DWARF die offset pointed by the implicit pointer. */ + sect_offset m_die_offset; +}; + +/* Composite location description entry. */ + +class dwarf_composite : public dwarf_location +{ +public: + dwarf_composite (struct gdbarch *arch, struct dwarf2_per_cu_data *per_cu, + LONGEST offset = 0, LONGEST bit_suboffset = 0) + : dwarf_location (arch, offset, bit_suboffset), m_per_cu (per_cu) + {} + + void add_piece (std::shared_ptr location, ULONGEST bit_size) + { + gdb_assert (location != nullptr); + m_pieces.emplace_back (location, bit_size); + } + +private: + /* Composite piece that contains a piece location + description and it's size. */ + class piece + { + public: + piece (std::shared_ptr location, ULONGEST size) + : m_location (location), + m_size (size) + {} + + std::shared_ptr m_location; + ULONGEST m_size; + }; + + /* Compilation unit context of the pointer. */ + struct dwarf2_per_cu_data *m_per_cu; + + /* Vector of composite pieces. */ + std::vector m_pieces; +}; + struct piece_closure { /* Reference count. */ diff --git a/gdb/value.c b/gdb/value.c index 9f3914a5bc5..52f55f0bb97 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3436,7 +3436,7 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num) /* Pack NUM into BUF using a target format of TYPE. */ -static void +void pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num) { LONGEST len; diff --git a/gdb/value.h b/gdb/value.h index 60a831c38c4..cbb60e2f073 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -678,6 +678,8 @@ extern struct value *value_field_bitfield (struct type *type, int fieldno, const struct value *val); extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num); +extern void pack_unsigned_long (gdb_byte *buf, struct type *type, + ULONGEST num); extern struct value *value_from_longest (struct type *type, LONGEST num); extern struct value *value_from_ulongest (struct type *type, ULONGEST num); -- 2.17.1