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: Victor Kamensky X-Patchwork-Id: 3317 Received: (qmail 30821 invoked by alias); 22 Oct 2014 05:26:45 -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 30717 invoked by uid 89); 22 Oct 2014 05:26:45 -0000 Authentication-Results: sourceware.org; auth=none 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MEo0QwEbdx/FWSzK3Xi2X+nsE36UlsJv7maVhIMsFQ4=; b=ifVFpVtX6wcwhZeNyYyEy28YrNxsGlO8B9ZEbQ5AbCwE5wszVzgjZT6nUeiCHzazBJ 62UR2FLSsR2CtVvbkkwj/g8BC+t1cG7VTjuOIF05+pgc0P0iGHcYebMb1lfsMAm0/fBM M/uX5DvSsq7GiEA2t4OeU1wSnp7g6prbyzP4wyYkNQ3CuYO8MTEHgCMf7SBbiOrM/11c 9tzpnhXpXZRtJcPVCqxX8TYs7LlgDl5sZZu5wVdyM6lW9qYkqzMD0gRT/orlLwWCzNii lexFvuGZlgMJS1itewTnr3bfUE0Rvv5YwkD2TrWrkTMVXfYSxF0IAGsKQdJgfgsh4C59 Cxzg== X-Gm-Message-State: ALoCoQn3/wcLORoNByQxIN7vj7JywxUwNZrjSLQSDAlEF6ADJMfXxa5MMaDIYj48cbFZLCQ2Jaso 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> 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;