From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13685 invoked by alias); 23 Jan 2006 16:43:27 -0000 Received: (qmail 13676 invoked by uid 22791); 23 Jan 2006 16:43:26 -0000 X-Spam-Check-By: sourceware.org Received: from w099.z064220152.sjc-ca.dsl.cnc.net (HELO duck.specifix.com) (64.220.152.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 23 Jan 2006 16:43:23 +0000 Received: from diveadx (duck.specifix.com [64.220.152.99]) by duck.specifix.com (Postfix) with ESMTP id 8BC8AFC4E; Mon, 23 Jan 2006 08:43:21 -0800 (PST) From: Fred Fish Reply-To: fnf@specifix.com To: Daniel Jacobowitz Subject: Re: [PATCH] Fix ptype problem printing typedefs defined differently in different compilation units Date: Mon, 23 Jan 2006 16:43:00 -0000 User-Agent: KMail/1.9.1 Cc: Jim Blandy , gdb-patches@sourceware.org, fnf@specifix.com References: <200601031517.50309.fnf@specifix.com> <200601231027.05302.fnf@specifix.com> <20060123161210.GC17767@nevyn.them.org> In-Reply-To: <20060123161210.GC17767@nevyn.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200601231143.22560.fnf@specifix.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00332.txt.bz2 On Monday 23 January 2006 11:12, Daniel Jacobowitz wrote: > I don't understand. What doesn't work? Is it something that works > without the patch, or not? Doesn't work without the patch, as it uses the type for the first symtab it happens to find that has a definition for that type. > I don't understand how your examples relate > to your description of the problem anymore. OK, I've attached a typescript at the bottom of this mail showing how it fails in the presence of a core and/or running executable. > > So something like the following, which currently produces an error: > >=20 > > (gdb) ptype 'main.c'::foo > > Cannot look up value of a typedef >=20 > Well that seems like a reasonable thing to fix anyway; ptype (and > sizeof!) should be using a non-side-effects evaluation anyway. I can look at this, though it may be a week or so. -Fred =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D Here is a simple testcase $ cat main.c typedef long foo; foo longfoo; main () { extern charfoo (char); extern intfoo (int); int a =3D 5; a =3D intfoo (a); a =3D charfoo (a); printf ("a =3D %d (should be 20)\n", a); *(char *)0 =3D 0; } $ cat int.c typedef int foo; intfoo (foo a) { return (2 * a); } $ cat char.c typedef char foo; charfoo (foo a) { return (2 * a); } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D Build testcase on Fedora Core 4 and generate corefile $ make gcc -g --save-temps -c -o main.o main.c main.c: In function =E2=80=98main=E2=80=99: main.c:12: warning: incompatible implicit declaration of built-in function = =E2=80=98printf=E2=80=99 gcc -g --save-temps -c -o char.o char.c gcc -g --save-temps -c -o int.o int.c gcc -o main main.o char.o int.o=20 $ ./main a =3D 20 (should be 20) Segmentation fault (core dumped) $ mv core.* core =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D Use gdb to examine just the executable file $ ../gdb main (gdb) list main 1 typedef long foo; 2 foo longfoo; 3=09 4 main () 5 { 6 extern charfoo (char); 7 extern intfoo (int); 8 int a =3D 5; 9=09 10 a =3D intfoo (a); (gdb) ptype foo type =3D long int <=3D=3D=3D=3D=3D OK (gdb) list charfoo 1 typedef char foo; 2=09 3 charfoo (foo a) 4 { 5 return (2 * a); 6 } (gdb) ptype foo type =3D char <=3D=3D=3D=3D=3D OK (gdb) list intfoo 1 typedef int foo; 2=09 3 intfoo (foo a) 4 { 5 return (2 * a); 6 } (gdb) ptype foo type =3D int <=3D=3D=3D=3D=3D OK (gdb) quit =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D Use gdb to examine the executable file and core file $ ../gdb main core #0 0x080483de in main () at main.c:13 13 *(char *)0 =3D 0; (gdb) list main 1 typedef long foo; 2 foo longfoo; 3=09 4 main () 5 { 6 extern charfoo (char); 7 extern intfoo (int); 8 int a =3D 5; 9=09 10 a =3D intfoo (a); (gdb) ptype foo type =3D long int <=3D=3D=3D=3D=3D OK (gdb) list charfoo 1 typedef char foo; 2=09 3 charfoo (foo a) 4 { 5 return (2 * a); 6 } (gdb) ptype foo type =3D long int <=3D=3D=3D=3D=3D Prints using frame context (gdb) list intfoo 1 typedef int foo; 2=09 3 intfoo (foo a) 4 { 5 return (2 * a); 6 } (gdb) ptype foo type =3D long int <=3D=3D=3D=3D=3D Prints using frame context (gdb) quit =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D