From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20865 invoked by alias); 5 Jul 2010 01:52:13 -0000 Received: (qmail 20854 invoked by uid 22791); 5 Jul 2010 01:52:11 -0000 X-SWARE-Spam-Status: No, hits=3.3 required=5.0 tests=BAYES_50,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_SORBS_WEB,SPF_NEUTRAL,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail1-relais-roc.national.inria.fr (HELO mail1-relais-roc.national.inria.fr) (192.134.164.82) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Jul 2010 01:52:07 +0000 Received: from 225.129.201-77.rev.gaoland.net (HELO truffe.loria.fr) ([77.201.129.225]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 05 Jul 2010 03:52:04 +0200 Received: from thome by truffe.loria.fr with local (Exim 4.71) (envelope-from ) id 1OVaqo-0000gR-7z for gdb-patches@sourceware.org; Mon, 05 Jul 2010 03:52:02 +0200 Date: Mon, 05 Jul 2010 01:52:00 -0000 From: Emmanuel =?iso-8859-1?Q?Thom=E9?= To: gdb-patches@sourceware.org Subject: embedded_offset missing in c-valprint.c Message-ID: <20100705015202.GA2419@truffe.loria.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="IJpNTDwzlM2Ie8A6" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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-07/txt/msg00074.txt.bz2 --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 905 Hi, Could you please consider the attached patch to c-valprint.c ? Unless I am mistaken (which is possible), the function c_val_print does not correctly track the inferior addresses of struct members. This affects pretty-printing via python scripting, which may require this address. I actually tested the version from the ubuntu package 7.1-1ubuntu2, but the defect seems also present in the git head version. Here is an example of a session transcript illustrating the misbehaviour/ $ gdb v GNU gdb (GDB) 7.1-ubuntu [...] (gdb) b 19 Breakpoint 1 at 0x4004fb: file v.c, line 19. (gdb) r Starting program: /home/thome/Curves/CM/complex_analytic/regis/v Breakpoint 1, main () at v.c:19 19 return 0; (gdb) p x $1 = {{l = 42, a = {{{x = 0}}, {{x = 1}}}}} (gdb) source u.py (gdb) p x $2 = {{l = 42, a = {42, 0}}} v.c and u.py are attached (as well as the patch itself of course). Best, E. --IJpNTDwzlM2Ie8A6 Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="v.c" Content-length: 221 struct bar { int x; }; typedef struct bar xbar[1]; struct foo { int l; xbar a[2]; }; int main() { struct foo x[1]; x->l = 42; for(int i = 0 ; i < 2 ; i++) x->a[i]->x=i; return 0; } --IJpNTDwzlM2Ie8A6 Content-Type: text/x-python; charset=us-ascii Content-Disposition: attachment; filename="u.py" Content-length: 560 import gdb from gmpy import mpz,mpf class bar_printer: def __init__(self, val): self.val = val def to_string(self): X = self.val # There's apparently a bug in array member of structs. Their # starting address seems to be constantly equal to the starting # address of the struct itself... return str(int(X['x'])) def make_my_printer_objects(val): t=str(val.type) if t == 'struct bar [1]': return bar_printer(val[0]) return None gdb.pretty_printers.append(make_my_printer_objects) --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Description: c-valprint-patch Content-Disposition: attachment; filename=p Content-length: 415 --- c-valprint.c 2010-07-04 23:06:32.000000000 +0200 +++ /tmp/c-valprint.c 2010-07-05 03:29:39.000000000 +0200 @@ -216,7 +216,7 @@ { i = 0; } - val_print_array_elements (type, valaddr + embedded_offset, address, stream, + val_print_array_elements (type, valaddr + embedded_offset, address + embedded_offset, stream, recurse, options, i); fprintf_filtered (stream, "}"); } --IJpNTDwzlM2Ie8A6--