From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32035 invoked by alias); 14 May 2010 17:29:42 -0000 Received: (qmail 32027 invoked by uid 22791); 14 May 2010 17:29:41 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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; Fri, 14 May 2010 17:29:37 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4EHTZxu007986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 May 2010 13:29:35 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4EHTZbp013138; Fri, 14 May 2010 13:29:35 -0400 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 o4EHTYB5011999; Fri, 14 May 2010 13:29:34 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 2D5F8378850; Fri, 14 May 2010 11:29:34 -0600 (MDT) From: Tom Tromey To: Jan Kratochvil Cc: gdb-patches@sourceware.org Subject: Re: RFC: fix bug in pieced value with offset References: <20100514110537.GA25586@host0.dyn.jankratochvil.net> Reply-To: tromey@redhat.com Date: Fri, 14 May 2010 17:54:00 -0000 In-Reply-To: <20100514110537.GA25586@host0.dyn.jankratochvil.net> (Jan Kratochvil's message of "Fri, 14 May 2010 13:05:37 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) 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-05/txt/msg00304.txt.bz2 >>>>> "Jan" == Jan Kratochvil writes: Jan> Thinking now if the BFD_ENDIAN_BIG patch by Ulrich Weigand Jan> [rfc] Handle DWARF-2 value pieces residing in *parts* of a register Jan> http://sourceware.org/ml/gdb-patches/2009-12/msg00305.html Jan> should not have been applied also for DWARF_VALUE_STACK; but this Jan> is outside of the scope of this patch. I must be missing something... I don't see any change to DWARF_VALUE_STACK there. >> - && p->size < register_size (arch, gdb_regnum)) >> + && this_size + reg_offset <= register_size (arch, gdb_regnum)) Jan> I believe it should be instead: Jan> # + reg_offset = (register_size (arch, gdb_regnum) Jan> # + - this_size); Jan> As we should ignore source_offset bytes from the start of register. Jan> register_size = 8 Jan> p-> size = 4 Jan> bytes_to_skip = for example 1 Jan> => Jan> source_offset = 1 Jan> this_size = 3 Jan> From the register occupying bytes <0..7> we thus want to read-in Jan> bytes <5..7>. My thinking was to consider the resulting contents as a sequence of bytes. In this case the register would be laid out from high byte to low byte. The existing 'size' offsetting strips off high bytes (because it is conceptually value-based); but then for 'source_offset' we want to advance through the byte representation -- so, also skipping high bytes. I can't tell if this makes sense or not. >> case DWARF_VALUE_STACK: >> { >> struct gdbarch *gdbarch = get_type_arch (value_type (v)); >> - size_t n = p->size; >> + size_t n = this_size; >> if (n > c->addr_size) >> n = c->addr_size; Jan> Generally I would prefer more sanity checks there instead of quiet data Jan> cutting. In this particular case, I think this is just what DWARF specifies. I think it makes sense to compute a value on the stack and then just select some bits from it. Maybe for DWARF_VALUE_LITERAL it would make sense to issue a complaint if the piece is smaller than the literal. That would be strange compiler output. Jan> There is also missing `- source_offset': Jan> # if (n > c->addr_size - source_offset) Jan> # n = c->addr_size - source_offset; Thanks for this and the other similar things. Jan> Why weren't just simple "main" and standard compilation used? It Jan> works for me. I picked a bad example to copy. I will fix this up. Jan> Isn't missing the ubiquitous FSF copyleft header? And this. thanks, Tom