From patchwork Wed Oct 22 05:26:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 39244 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D622202DB for ; Wed, 22 Oct 2014 05:27:09 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id hi2sf176203wib.9 for ; Tue, 21 Oct 2014 22:27:08 -0700 (PDT) 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=MEo0QwEbdx/FWSzK3Xi2X+nsE36UlsJv7maVhIMsFQ4=; b=cdHIy1bhX2ahdMETQgziNHXln6Ad6pTTeFBa8QDvaQkPkUjzVFoX4kMBIxvvR6D+w2 YBPx+Age0NmVFu9b/SZ0mSU+/urROEAslHe5IFpr9ovC77KILDWbkP/BKIU4rQifOQTQ sMgRRaOfuO2Jq0wMg8j9a8CdAdGNsp37jCIAWG/JJOnXSdAD96Kq2mpzkm9BQIjkBIyn 9bWYfmpr1mk/fw8iTgfFr85tUeUf52JN7dl7JtfQ+873nLU9fxc1XBxW3+2LN6rgKKxA GivlvXdI4tduNmorRbVHDP5kxBLs0S/yhH9Fv05fklYmNkNesFjH7+bsZCdqBMPnVCvd 1K9A== X-Gm-Message-State: ALoCoQnXWRkDlpubAK92+N5Fa/FCDk87TbS+/dSMn9OhZTZFuWtiwhCWbJX5NOelvfWvyJbDM4C3 X-Received: by 10.180.76.42 with SMTP id h10mr574387wiw.6.1413955628799; Tue, 21 Oct 2014 22:27:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.178 with SMTP id az18ls138024lab.96.gmail; Tue, 21 Oct 2014 22:27:08 -0700 (PDT) X-Received: by 10.152.22.135 with SMTP id d7mr39130826laf.46.1413955628651; Tue, 21 Oct 2014 22:27:08 -0700 (PDT) Received: from mail-la0-x22b.google.com (mail-la0-x22b.google.com. [2a00:1450:4010:c03::22b]) by mx.google.com with ESMTPS id h5si21782277lam.129.2014.10.21.22.27.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 22:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22b as permitted sender) client-ip=2a00:1450:4010:c03::22b; Received: by mail-la0-f43.google.com with SMTP id mc6so2289978lab.2 for ; Tue, 21 Oct 2014 22:27:08 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr39553209lbb.46.1413955628559; Tue, 21 Oct 2014 22:27:08 -0700 (PDT) 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 c5csp14058lbz; Tue, 21 Oct 2014 22:27:07 -0700 (PDT) X-Received: by 10.66.66.75 with SMTP id d11mr40042399pat.85.1413955626565; Tue, 21 Oct 2014 22:27:06 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ar4si9542596pbc.2.2014.10.21.22.27.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2014 22:27:06 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-116885-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 30821 invoked by alias); 22 Oct 2014 05:26:45 -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 30717 invoked by uid 89); 22 Oct 2014 05:26:45 -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-f176.google.com Received: from mail-pd0-f176.google.com (HELO mail-pd0-f176.google.com) (209.85.192.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 22 Oct 2014 05:26:43 +0000 Received: by mail-pd0-f176.google.com with SMTP id fp1so2811622pdb.21 for ; Tue, 21 Oct 2014 22:26:41 -0700 (PDT) X-Received: by 10.70.128.133 with SMTP id no5mr19972780pdb.122.1413955601565; Tue, 21 Oct 2014 22:26:41 -0700 (PDT) Received: from kamensky-w530.hsd1.ca.comcast.net ([24.6.79.41]) by mx.google.com with ESMTPSA id i16sm13364690pdk.66.2014.10.21.22.26.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2014 22:26:41 -0700 (PDT) From: Victor Kamensky To: gdb-patches@sourceware.org, Yao Qi Cc: Andrew Pinski , victor.kamensky@linaro.org Subject: [PATCH V2 3/4] read_pieced_value do big endian processing only in case of valid gdb_regnum Date: Tue, 21 Oct 2014 22:26:28 -0700 Message-Id: <1413955589-5054-4-git-send-email-victor.kamensky@linaro.org> In-Reply-To: <1413955589-5054-1-git-send-email-victor.kamensky@linaro.org> References: <1413955589-5054-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:c03::22b 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'. 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). In both case gdbarch_dwarf2_reg_to_regnum returns -1 which is stored into gdb_regnum. But it cause 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, 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-10-21 Victor Kamensky * dwarf2loc.c (read_pieced_value): Do BE processing only if gdb_regnum is not -1. (write_pieced_value): Ditto. --- gdb/dwarf2loc.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index e347e59..fbe99bb 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -1686,20 +1686,20 @@ read_pieced_value (struct value *v) 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; + 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, &optim, &unavail)) @@ -1878,13 +1878,13 @@ write_pieced_value (struct value *to, struct value *from) 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) { + 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;