From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18832 invoked by alias); 5 Oct 2007 18:16:35 -0000 Received: (qmail 18821 invoked by uid 22791); 5 Oct 2007 18:16:33 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 05 Oct 2007 18:16:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CE6AD2AA0CD; Fri, 5 Oct 2007 14:16:25 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ntEYpl5oGSTd; Fri, 5 Oct 2007 14:16:25 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 3C7152AB58F; Fri, 5 Oct 2007 14:16:25 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id F2BBEE7B58; Fri, 5 Oct 2007 11:16:20 -0700 (PDT) Date: Fri, 05 Oct 2007 18:16:00 -0000 From: Joel Brobecker To: Pierre Muller Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Handle GPC specific name for main function Message-ID: <20071005181620.GB3570@adacore.com> References: <001701c805a0$1da99b60$58fcd220$@u-strasbg.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001701c805a0$1da99b60$58fcd220$@u-strasbg.fr> User-Agent: Mutt/1.4.2.2i 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: 2007-10/txt/msg00071.txt.bz2 Hi Pierre, > 2007-10-03 Pierre Muller > > * p-lang.h (pascal_main_name): New function. > p-lang.c (GPC_P_INITIALIZE, GPC_MAIN_PROGRAM_NAME_1), > (GPC_MAIN_PROGRAM_NAME_2): New char array constants > corresponding to the three minimal symbols used > by GPC compiler. > (pascal_main_name): Try to find minimal symbol > corresponding to the entry of GPC compiled programs. > symtab.c: New include p-lang.h. > (find_main_name): Try to find pascal specific main name > by calling pascal_main_name. > * Makefile.in (symtab.o): Add dependency on p-lang header. This is mostly OK. I feel like I am being a perfectionist on you, and I apologize, but I think I might have missed something that feels wrong somehow: You're having to cast your global static const char into (char *) inside pascal_main_name. I can tell from the code that everything will be fine, but perhaps we could do better. What do others think of this cast? static const char GPC_MAIN_PROGRAM_NAME_1[] = "_p__M0_main_program"; char * pascal_main_name (void) { [...] return (char *) GPC_MAIN_PROGRAM_NAME_1[]; } One way I can see to avoid having to do the cast is to return the SYMBOL_LINKAGE_NAME of the msym we found. Something like this: char * pascal_main_name (void) { struct minimal_symbol *msym; msym = lookup_minimal_symbol (GPC_P_INITIALIZE, NULL, NULL); /* If '_p_initialize' was not found, the program doesn't seem to be compiled with GPC. Thus default name "main" should work. */ if (msym == NULL) return NULL; msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_1, NULL, NULL); if (msym == NULL) msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_2, NULL, NULL); if (msym != NULL) return SYMBOL_LINKAGE_NAME (msym); return NULL; } This is only a small detail, and I can't see anything wrong happening with your patch, so I suggest you go ahead and commit the change, and we can adjust it if others also feel the same way. Just one adjustment: > +/* No known entry procedure found, use default 'main' name. > + According to Waldek Hebish, this should not happen for any GPC version > + after June 2000 and up to 2007-09-27. */ This comment assumes that the main program is actually always written in Pascal. But this is not true. This function will also be called for programs written in any other language. I suggest: /* No known entry procedure found. The main program is probably not written in Pascal. */ The rest of the patch is great! Thank you, -- Joel