From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id XAHwNmO/YmIH5AEAWB0awg (envelope-from ) for ; Fri, 22 Apr 2022 10:44:51 -0400 Received: by simark.ca (Postfix, from userid 112) id D38C01E058; Fri, 22 Apr 2022 10:44:51 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=jzoyMgzz; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 6B5771E00E for ; Fri, 22 Apr 2022 10:44:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E20A1385DC1F for ; Fri, 22 Apr 2022 14:44:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E20A1385DC1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650638690; bh=UPgYVIvH59kzgxcNW3yyRJx6Ct4ilfssVRrAL2RH62g=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=jzoyMgzzIYSTtjoD+1NrefmeMwB3BD1K1YhdwZfOHMwvl3LJcyAdtEd7ooIdMTYSA TbSC1SSyuHZ7Y1zaRPUC+PmRSpGX41fmiiee7LVljnVTlLAuLI+6HC66ibxlf3LxAP L0LI6ZEFORknrxXYlTdJFDVgz5JNq+Q/RMNWygEY= 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 To: gdb-patches@sourceware.org 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-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: Stephan Rohr via Gdb-patches Reply-To: Stephan Rohr Cc: tom@tromey.com, stephan.rohr@intel.com Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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