From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id 6A2C23858C2C for ; Fri, 22 Apr 2022 14:44:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A2C23858C2C X-IronPort-AV: E=McAfee;i="6400,9594,10324"; a="252019272" X-IronPort-AV: E=Sophos;i="5.90,282,1643702400"; d="scan'208";a="252019272" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 07:44:27 -0700 X-IronPort-AV: E=Sophos;i="5.90,282,1643702400"; d="scan'208";a="703576700" Received: from labpcdell3650-004.iul.intel.com (HELO localhost) ([172.28.50.126]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 07:44:26 -0700 From: Stephan Rohr To: gdb-patches@sourceware.org Cc: stephan.rohr@intel.com, tom@tromey.com Subject: [PATCH 0/1] Fix 'rw_pieced_value' for values casted to different type. Date: Fri, 22 Apr 2022 16:44:19 +0200 Message-Id: <20220422144420.3545190-1-stephan.rohr@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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, 22 Apr 2022 14:44:32 -0000 From: "Rohr, Stephan" This patch provides a fix for the issue when a user wants to print a pieced value, as described by 'DW_OP_piece' or 'DW_OP_bit_piece', casted to a different type, e.g. 'print ( []) ). If a lazy value is fetched, GDB allocates space based on the enclosing type's length and typically reads the 'full' object. This is not implemented for pieced values and causes an internal error if 'type' and 'enclosing_type' of a value are not identical, which is the case if the user explicitly casts the variable. However, GDB can read the value based on its type. Thus, it should be sufficient to check if the type's length (potentially shifted by 'embedded_offset') does not exceed the enclosing type's length which was used for memory allocation. Test-cases are added to 'gdb/testsuite/gdb.dwarf2/shortpiece.exp'. The testsuite was run for the following targets: * unix/-64 * native-gdbserver * native-extended-gdbserver * unix/-m32 Rohr, Stephan (1): gdb/dwarf2: Fix 'rw_pieced_value' for values casted to different type. gdb/dwarf2/expr.c | 6 ++---- gdb/testsuite/gdb.dwarf2/shortpiece.exp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) -- 2.25.1