From patchwork Wed Apr 27 17:38:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 11912 Received: (qmail 119002 invoked by alias); 27 Apr 2016 17:38:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 118990 invoked by uid 89); 27 Apr 2016 17:38:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=817, 7, 8177, policy X-HELO: e06smtp05.uk.ibm.com Received: from e06smtp05.uk.ibm.com (HELO e06smtp05.uk.ibm.com) (195.75.94.101) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 27 Apr 2016 17:38:48 +0000 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Apr 2016 18:38:45 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 27 Apr 2016 18:38:44 +0100 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: arnez@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 012F3219004D for ; Wed, 27 Apr 2016 18:38:21 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3RHchqS2818328 for ; Wed, 27 Apr 2016 17:38:43 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3RHchSv008577 for ; Wed, 27 Apr 2016 11:38:43 -0600 Received: from oc1027705133.ibm.com (dyn-9-152-212-143.boeblingen.de.ibm.com [9.152.212.143]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3RHchGt008563 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 27 Apr 2016 11:38:43 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH] Allow DW_OP_GNU_uninit in dwarf_expr_require_composition Date: Wed, 27 Apr 2016 19:38:43 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16042717-0021-0000-0000-000019D223F7 X-IsSubscribed: yes In DWARF expression handling, some operators are required to be either at the end of an expression or followed by a composition operator. So far only the operators DW_OP_reg0-31 were allowed to be followed by DW_OP_GNU_uninit instead, and particularly DW_OP_regx was not, which is obviously inconsistent. This patch allows DW_OP_GNU_uninit after all operators requiring a composition, to simplify the code and make it more consistent. This policy may be more permissive than necessary, but in the worst case just leads to a DWARF location description resulting in an uninitialized value instead of an error message. gdb/ChangeLog: * dwarf2expr.c (dwarf_expr_require_composition): Allow DW_OP_GNU_uninit. (execute_stack_op): Use dwarf_expr_require_composition instead of copying its logic. --- gdb/dwarf2expr.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c index 7bf3c78..bf2107a 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c @@ -401,16 +401,15 @@ safe_skip_leb128 (const gdb_byte *buf, const gdb_byte *buf_end) /* Check that the current operator is either at the end of an - expression, or that it is followed by a composition operator. */ + expression, or that it is followed by a composition operator or by + DW_OP_GNU_uninit (which should terminate the expression). */ void dwarf_expr_require_composition (const gdb_byte *op_ptr, const gdb_byte *op_end, const char *op_name) { - /* It seems like DW_OP_GNU_uninit should be handled here. However, - it doesn't seem to make sense for DW_OP_*_value, and it was not - checked at the other place that this function is called. */ - if (op_ptr != op_end && *op_ptr != DW_OP_piece && *op_ptr != DW_OP_bit_piece) + if (op_ptr != op_end && *op_ptr != DW_OP_piece && *op_ptr != DW_OP_bit_piece + && *op_ptr != DW_OP_GNU_uninit) error (_("DWARF-2 expression error: `%s' operations must be " "used either alone or in conjunction with DW_OP_piece " "or DW_OP_bit_piece."), @@ -818,13 +817,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, case DW_OP_reg29: case DW_OP_reg30: case DW_OP_reg31: - if (op_ptr != op_end - && *op_ptr != DW_OP_piece - && *op_ptr != DW_OP_bit_piece - && *op_ptr != DW_OP_GNU_uninit) - error (_("DWARF-2 expression error: DW_OP_reg operations must be " - "used either alone or in conjunction with DW_OP_piece " - "or DW_OP_bit_piece.")); + dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_reg"); result = op - DW_OP_reg0; result_val = value_from_ulongest (address_type, result);