From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8554 invoked by alias); 23 Feb 2010 16:08:41 -0000 Received: (qmail 8539 invoked by uid 22791); 23 Feb 2010 16:08:40 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Feb 2010 16:08:36 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1NG8Y1C014269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Feb 2010 11:08:34 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1NG8YvW031404; Tue, 23 Feb 2010 11:08:34 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o1NG8XnV029333; Tue, 23 Feb 2010 11:08:33 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id B2F49378190; Tue, 23 Feb 2010 09:08:32 -0700 (MST) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: fix big-endian bug with DWARF_VALUE_STACK Reply-To: Tom Tromey Date: Tue, 23 Feb 2010 16:08:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00567.txt.bz2 I'm checking this in on the trunk and the 7.1 branch. Jakub noticed a bug with DWARF expressions on big-endian machines. This is https://bugzilla.redhat.com/show_bug.cgi?id=567251 Built and regtested on x86-64 (compile farm) -- little-endian, of course, so I also ran the relevant tests on a PPC64 box in the farm. I do have a test case (see the bugzilla link), but it only works on PPC64, and it relies on having a very new version of gas, so I did not include it in the patch. Tom 2010-02-23 Tom Tromey * dwarf2loc.c (read_pieced_value) : Correctly handle big-endian values. (dwarf2_evaluate_loc_desc) : Likewise. diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 6679d74..1c4d057 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -298,16 +298,14 @@ read_pieced_value (struct value *v) case DWARF_VALUE_STACK: { - gdb_byte bytes[sizeof (ULONGEST)]; size_t n; int addr_size = gdbarch_addr_bit (c->arch) / 8; - store_unsigned_integer (bytes, addr_size, - gdbarch_byte_order (c->arch), - p->v.expr.value); n = p->size; if (n > addr_size) n = addr_size; - memcpy (contents + offset, bytes, n); + store_unsigned_integer (contents + offset, n, + gdbarch_byte_order (c->arch), + p->v.expr.value); } break; @@ -476,19 +474,17 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame, case DWARF_VALUE_STACK: { - gdb_byte bytes[sizeof (ULONGEST)]; ULONGEST value = (ULONGEST) dwarf_expr_fetch (ctx, 0); bfd_byte *contents; size_t n = ctx->addr_size; - store_unsigned_integer (bytes, ctx->addr_size, - gdbarch_byte_order (ctx->gdbarch), - value); retval = allocate_value (SYMBOL_TYPE (var)); contents = value_contents_raw (retval); if (n > TYPE_LENGTH (SYMBOL_TYPE (var))) n = TYPE_LENGTH (SYMBOL_TYPE (var)); - memcpy (contents, bytes, n); + store_unsigned_integer (contents, n, + gdbarch_byte_order (ctx->gdbarch), + value); } break;