From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27266 invoked by alias); 11 Feb 2006 20:01:24 -0000 Received: (qmail 27256 invoked by uid 22791); 11 Feb 2006 20:01:23 -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; Sat, 11 Feb 2006 20:01:21 +0000 Received: from [::1] (duck.specifix.com [64.220.152.99]) by duck.specifix.com (Postfix) with ESMTP id F17305B09; Sat, 11 Feb 2006 12:01:14 -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: Sat, 11 Feb 2006 20:01:00 -0000 User-Agent: KMail/1.9.1 Cc: Jim Blandy , gdb-patches@sourceware.org, fnf@specifix.com References: <200601031517.50309.fnf@specifix.com> <200602101935.06700.fnf@specifix.com> <20060211183500.GA25132@nevyn.them.org> In-Reply-To: <20060211183500.GA25132@nevyn.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200602111501.01801.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-02/txt/msg00265.txt.bz2 On Saturday 11 February 2006 13:35, Daniel Jacobowitz wrote: > Don't you get a warning compiling this? No, I was building without -O, for better debugging of gdb, and that produces the warning: cc1: warning: -Wuninitialized is not supported without -O for every file, which I ignore. Building with -O does indeed produce a warning about val being uninitialized. > It looks to me like, with objectprint set, ptype and whatis will now > blow up; they call value_rtti_target_type without initializing val. Yup. The fix would be to remove the test of type==NULL and always initialize val, whether or not ptype_eval finds a type to print. Apparently we don't have any test in the gdb testsuite that checks using objectprint, as there we no regressions when I ran it after the change. > Also ptype will now do the RTTI lookup; I'm not sure whether it > should or not. Not sure either, now that you point it out. > The documentation for whatis and ptype leaves me way unenlightened > about what the difference between them is supposed to be; perhaps we > should eliminate the difference. Mainly it appears that ptype is expected to print the entire type, while whatis simply prints the basic info. I.E. (gdb) ptype afoo type = struct foo { int x; int y; } (gdb) whatis afoo type = struct foo (gdb) If we want to keep ptype from doing the RTTI lookup when objectprint is set, it's easy enough to revert the part of the patch that simplifies ptype_command into a simple call to whatis_exp. The meat of the change that makes "ptype 'foo.c'::afoo" work is the change to ptype_eval to add the test for an OP_VAR_VALUE expression. We should probably still keep the patch to whatis_exp, with the fix to avoid a NULL val of course, so that both ptype and whatis can use the 'file'::typename syntax. -Fred