From patchwork Sun Nov 2 21:41:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 39994 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AAA662405B for ; Sun, 2 Nov 2014 21:42:08 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c41sf2194244eek.4 for ; Sun, 02 Nov 2014 13:42:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results; bh=NLfBEJFIFgBtb5uplOfGi8y45oPEsppQwS+hRRkVkrI=; b=Cyl+3flnEe0JgZIDF4k14W1PEJNaQkA7bMyOnuxPM/s5vVduLWg3WVu2OtLdbMHd9D oObAbP93oh4BX/d0eMTyFj+G0j8OYRfsnHsmBMbOsz0Xq/r5BZsvoQTbBiLhR6P3kJDu 2N1pNn/79ODTHfptIJiJkjwyy2oU+RP/B4cZJ9g488aANSEpnHLCPoeSi7wL1686Bsuh Y/uHl75vup5mC86LHzOyxMhPAoEpQw4VDf3N1azNmdvKnBcVIQ6X0XtBRrA+ptyO1zcG //4tPsYA6cfnAp6qQ99hcxLyfnpC0vK+xmo/RfQGSSwZwFAcujR9oRzcSZAoZ+/C0EeK TNFg== X-Gm-Message-State: ALoCoQnR/4GBnjOAS4lhPkm+R9gkI4k+uY/Boc4GlOdu+jSLul7VFDz2Wb4vYGtRnvqjIL1hd+dh X-Received: by 10.180.98.165 with SMTP id ej5mr2075780wib.1.1414964527636; Sun, 02 Nov 2014 13:42:07 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.67 with SMTP id z3ls687971lag.74.gmail; Sun, 02 Nov 2014 13:42:07 -0800 (PST) X-Received: by 10.152.203.139 with SMTP id kq11mr1072724lac.10.1414964527287; Sun, 02 Nov 2014 13:42:07 -0800 (PST) Received: from mail-lb0-x235.google.com (mail-lb0-x235.google.com. [2a00:1450:4010:c04::235]) by mx.google.com with ESMTPS id xt8si29684576lac.122.2014.11.02.13.42.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Nov 2014 13:42:07 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::235 as permitted sender) client-ip=2a00:1450:4010:c04::235; Received: by mail-lb0-f181.google.com with SMTP id l4so1697176lbv.26 for ; Sun, 02 Nov 2014 13:42:07 -0800 (PST) X-Received: by 10.112.218.101 with SMTP id pf5mr9722104lbc.46.1414964527189; Sun, 02 Nov 2014 13:42:07 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp162523lbz; Sun, 2 Nov 2014 13:42:06 -0800 (PST) X-Received: by 10.68.242.67 with SMTP id wo3mr38463627pbc.95.1414964525428; Sun, 02 Nov 2014 13:42:05 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id i10si13897535pdr.145.2014.11.02.13.42.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Nov 2014 13:42:05 -0800 (PST) Received-SPF: pass (google.com: domain of gdb-patches-return-117240-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 4195 invoked by alias); 2 Nov 2014 21:41:50 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 4111 invoked by uid 89); 2 Nov 2014 21:41:50 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f177.google.com Received: from mail-pd0-f177.google.com (HELO mail-pd0-f177.google.com) (209.85.192.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 02 Nov 2014 21:41:47 +0000 Received: by mail-pd0-f177.google.com with SMTP id v10so10213094pde.8 for ; Sun, 02 Nov 2014 13:41:45 -0800 (PST) X-Received: by 10.70.118.1 with SMTP id ki1mr39569394pdb.69.1414964505922; Sun, 02 Nov 2014 13:41:45 -0800 (PST) Received: from kamensky-w530.hsd1.ca.comcast.net ([24.6.79.41]) by mx.google.com with ESMTPSA id ej7sm7913403pdb.88.2014.11.02.13.41.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Nov 2014 13:41:45 -0800 (PST) From: Victor Kamensky To: gdb-patches@sourceware.org Cc: Yao Qi , Victor Kamensky Subject: [COMMITTED PATCH 3/3] read_pieced_value do big endian processing only in case of valid gdb_regnum Date: Sun, 2 Nov 2014 13:41:24 -0800 Message-Id: <1414964484-6270-3-git-send-email-victor.kamensky@linaro.org> In-Reply-To: <1414964484-6270-1-git-send-email-victor.kamensky@linaro.org> References: <1414964484-6270-1-git-send-email-victor.kamensky@linaro.org> X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::235 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 During armv7b testing gdb.base/store.exp test was failling with 'GDB internal error' with the following message: Temporary breakpoint 1, wack_double (u= ../../binutils-gdb/gdb/regcache.c:177: internal-error: register_size: Assertion `regnum >= 0 && regnum < (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch))' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. It turns out that compiler generated DWARF with non-existent register numbers. The compiler issue is present in both little endian (armv7) and big endian (armv7b) (it is separate issue). Here is example for one of formal parameters of wack_double function: <2><792>: Abbrev Number: 10 (DW_TAG_formal_parameter) <793> DW_AT_name : u <795> DW_AT_decl_file : 1 <796> DW_AT_decl_line : 115 <797> DW_AT_type : <0x57c> <79b> DW_AT_location : 6 byte block: 6d 93 4 6c 93 4 (DW_OP_reg29 (r29); DW_OP_piece: 4; DW_OP_reg28 (r28); DW_OP_piece: 4) In both big and little endian cases gdbarch_dwarf2_reg_to_regnum returns -1 which is stored into gdb_regnum. But it causes severe problem only in big endian case because in read_pieced_value and write_pieced_value functions BFD_ENDIAN_BIG related processing happen regardless of gdb_regnum value, for example register_size function is called and in case of gdb_regnum=-1, it cause 'GDB internal error' and crash. Solution is to move BFD_ENDIAN_BIG related processing under (gdb_regnum != -1) branch of processing. gdb/ChangeLog: 2014-11-02 Victor Kamensky * dwarf2loc.c (read_pieced_value): Do big endian processing only if gdb_regnum is not -1. (write_pieced_value): Ditto. --- gdb/dwarf2loc.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 71adc89..6e461bc 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -1683,21 +1683,21 @@ read_pieced_value (struct value *v) { struct gdbarch *arch = get_frame_arch (frame); int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, p->v.regno); - int reg_offset = source_offset; - - if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG - && this_size < register_size (arch, gdb_regnum)) - { - /* Big-endian, and we want less than full size. */ - reg_offset = register_size (arch, gdb_regnum) - this_size; - /* We want the lower-order THIS_SIZE_BITS of the bytes - we extract from the register. */ - source_offset_bits += 8 * this_size - this_size_bits; - } if (gdb_regnum != -1) { int optim, unavail; + int reg_offset = source_offset; + + if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG + && this_size < register_size (arch, gdb_regnum)) + { + /* Big-endian, and we want less than full size. */ + reg_offset = register_size (arch, gdb_regnum) - this_size; + /* We want the lower-order THIS_SIZE_BITS of the bytes + we extract from the register. */ + source_offset_bits += 8 * this_size - this_size_bits; + } if (!get_frame_register_bytes (frame, gdb_regnum, reg_offset, this_size, buffer, @@ -1875,15 +1875,18 @@ write_pieced_value (struct value *to, struct value *from) { struct gdbarch *arch = get_frame_arch (frame); int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, p->v.regno); - int reg_offset = dest_offset; - - if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG - && this_size <= register_size (arch, gdb_regnum)) - /* Big-endian, and we want less than full size. */ - reg_offset = register_size (arch, gdb_regnum) - this_size; if (gdb_regnum != -1) { + int reg_offset = dest_offset; + + if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG + && this_size <= register_size (arch, gdb_regnum)) + { + /* Big-endian, and we want less than full size. */ + reg_offset = register_size (arch, gdb_regnum) - this_size; + } + if (need_bitwise) { int optim, unavail;