From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27515 invoked by alias); 22 Apr 2003 16:48:12 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 27493 invoked from network); 22 Apr 2003 16:48:12 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 22 Apr 2003 16:48:12 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 6A9952B2F; Tue, 22 Apr 2003 12:48:09 -0400 (EDT) Message-ID: <3EA57249.5020104@redhat.com> Date: Tue, 22 Apr 2003 16:48:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Jacobowitz , Jason Molenda Cc: gdb-patches@sources.redhat.com Subject: Re: PATCH: Add type_sprint() function to return type in string form References: <20030418152426.A93348@molenda.com> <20030422032629.GB5033@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-04/txt/msg00399.txt.bz2 > On Fri, Apr 18, 2003 at 03:24:26PM -0700, Jason Molenda wrote: > >> There are a few places in gdb where code prints an error message >> with a type included in it. The only way for these functions to >> print a type is with type_print(), which takes a ui_file stream to >> print its output to. This means they either have to send the output >> to gdb_stderr, or build up a fake memory ui_file and retrieve the >> contents. >> >> This patch adds a type_sprint() which does the latter and returns the >> xmalloc()'ed string. Good interface choice! Just some tweaks. sprint makes me think of the nasty sprintf family, which this is definitly not. So .. suggest calling it something like type_xstrdup: x-> xmalloc family; strdup -> allocate a string duplicate (like ui_file_xstrdup, but yes pushing it a bit). The alternative would be type_xasprint (&string, ...) but I think that is getting ugly :-) The old error message should never have included a period ("."), might as well remove it while tweaking the code. >> The current code gives bogus data to an MI client. We had a bug that >> gave this output at Apple: >> >> -> 64-var-list-children "var7" 2 >> <- 64^error,msg="." >> -> 65-exec-status >> <- (gdb) >> <- &"Type TWindow has no component named TWindow" >> <- 65^done,status="stopped" >> >> This happens because this particular error reporter looked like this: Ulgh. Testcase tweak? >> fprintf_unfiltered (gdb_stderr, "Type "); >> type_print (type, "", gdb_stderr, -1); >> fprintf_unfiltered (gdb_stderr, " has no component named "); >> fputs_filtered (name, gdb_stderr); >> error ("."); >> >> Similar code shows up in a few places, so it made sense to create a >> single function to format a type into a string and return the string. >> >> I can drop the ada-lang.c part of the patch if that will complicate >> the approval, but given that this code is clearly derived from >> gdbtypes.c, I don't think the change is particularly controversial. >> >> This patch adds no new testsuite failures on RHL7.1 (gcc 2.96, stabs). > > > I think this is OK. Sit on it for another day or two and check it in > if no one objects in that time, please. yup. For ada, a best guess is sufficient. Andrew >> 2003-04-18 Jason Molenda (jmolenda @ apple.com) >> >> * typeprint.c (type_sprint): New function to return string form >> of types. Use as type_print, sans a stream. >> * value.h (type_sprint): Add prototype. >> * ada-lang.c (ada_lookup_struct_elt_type): Use type_sprint() when >> building error message. >> * gdbtypes.c (lookup_struct_elt_type): Ditto. >> * varobj.c (varobj_get_type): Use type_sprint() to get the type >> in a string form. > > > > -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer