From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23618 invoked by alias); 7 Oct 2007 07:17:24 -0000 Received: (qmail 23606 invoked by uid 22791); 7 Oct 2007 07:17:22 -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; Sun, 07 Oct 2007 07:17:17 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C7AAF1E653C; Sun, 7 Oct 2007 03:17:15 -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 iTgJfsHBcRnC; Sun, 7 Oct 2007 03:17:15 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 5C29A1E6539; Sun, 7 Oct 2007 03:17:15 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 3359EE7B58; Sun, 7 Oct 2007 00:17:13 -0700 (PDT) Date: Sun, 07 Oct 2007 07:17:00 -0000 From: Joel Brobecker To: Eli Zaretskii Cc: muller@ics.u-strasbg.fr, gdb-patches@sourceware.org Subject: Re: [RFA] Handle GPC specific name for main function Message-ID: <20071007071713.GG3570@adacore.com> References: <001701c805a0$1da99b60$58fcd220$@u-strasbg.fr> <20071005181620.GB3570@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline In-Reply-To: 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/msg00097.txt.bz2 --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1346 Hi Eli, > Yuck! Can't we make pascal_main_name return `const char *'? If not, > why not? That's a good idea. What do you think about this revised version of Pierre's patch? 2007-10-07 Pierre Muller * p-lang.h (pascal_main_name): Add declaration. * p-lang.c (GPC_P_INITIALIZE, GPC_MAIN_PROGRAM_NAME_1) (GPC_MAIN_PROGRAM_NAME_2): New constants. (pascal_main_name): New function. * symtab.c: Include p-lang.h. (find_main_name): New function. * Makefile.in (symtab.o): Add dependency on p-lang.h. Pierre, This patch also implements the adjustments in the comments that I suggested. The way you wrote these commments made me think that you were implicitly thinking that your function is called only when the program is written in Pascal (and only in Pascal). But in fact, this is not the case, and the program could actually be multi-language! I also noticed some formatting issues, which I also fixed. I also just now noticed that I had some comments on your ChangeLog entry. Above is how I would write it: You were missing the '*' for each new file; And I made the text more concise (no need to explain what the function does for instance). I should have noticed that the first time around, but being new at reviewing patch, I'm still learning. -- Joel --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pascal.diff" Content-length: 3498 Index: p-lang.h =================================================================== RCS file: /cvs/src/src/gdb/p-lang.h,v retrieving revision 1.12 diff -u -p -r1.12 p-lang.h --- p-lang.h 23 Aug 2007 18:08:36 -0000 1.12 +++ p-lang.h 7 Oct 2007 07:13:41 -0000 @@ -21,6 +21,9 @@ struct value; +/* Defined in p-lang.c */ +extern const char const *pascal_main_name (void); + extern int pascal_parse (void); /* Defined in p-exp.y */ extern void pascal_error (char *); /* Defined in p-exp.y */ Index: p-lang.c =================================================================== RCS file: /cvs/src/src/gdb/p-lang.c,v retrieving revision 1.33 diff -u -p -r1.33 p-lang.c --- p-lang.c 23 Sep 2007 16:25:05 -0000 1.33 +++ p-lang.c 7 Oct 2007 07:13:41 -0000 @@ -35,6 +35,56 @@ extern void _initialize_pascal_language (void); +/* All GPC versions until now (2007-09-27) also define a symbol called + '_p_initialize'. Check for the presence of this symbol first. */ +static const char GPC_P_INITIALIZE[] = "_p_initialize"; + +/* The name of the symbol that GPC uses as the name of the main + procedure (since version 20050212). */ +static const char GPC_MAIN_PROGRAM_NAME_1[] = "_p__M0_main_program"; + +/* Older versions of GPC (versions older than 20050212) were using + a different name for the main procedure. */ +static const char GPC_MAIN_PROGRAM_NAME_2[] = "pascal_main_program"; + +/* Function returning the special symbol name used + by GPC for the main procedure in the main program + if it is found in minimal symbol list. + This function tries to find minimal symbols generated by GPC + so that it finds the even if the program was compiled + without debugging information. + According to information supplied by Waldeck Hebisch, + this should work for all versions posterior to June 2000. */ + +const char const * +pascal_main_name (void) +{ + struct minimal_symbol *msym; + + msym = lookup_minimal_symbol (GPC_P_INITIALIZE, NULL, NULL); + + /* If '_p_initialize' was not found, the main program is likely not + written in Pascal. */ + if (msym == NULL) + return NULL; + + msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_1, NULL, NULL); + if (msym != NULL) + { + return GPC_MAIN_PROGRAM_NAME_1; + } + + msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_2, NULL, NULL); + if (msym != NULL) + { + return GPC_MAIN_PROGRAM_NAME_2; + } + + /* No known entry procedure found, the main program is probably + not in pascal. */ + return NULL; +} + /* Determines if type TYPE is a pascal string type. Returns 1 if the type is a known pascal type This function is used by p-valprint.c code to allow better string display. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.939 diff -u -p -r1.939 Makefile.in --- Makefile.in 27 Sep 2007 18:48:32 -0000 1.939 +++ Makefile.in 7 Oct 2007 07:13:42 -0000 @@ -2751,7 +2751,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h) $(filenames_h) $(objc_lang_h) $(ada_lang_h) $(hashtab_h) \ $(gdb_obstack_h) $(block_h) $(dictionary_h) $(gdb_string_h) \ $(gdb_stat_h) $(cp_abi_h) $(observer_h) $(gdb_assert_h) \ - $(solist_h) $(ada_lang_h) + $(solist_h) $(p_lang_h) target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \ $(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \ $(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) $(gdbcore_h) \ --Q68bSM7Ycu6FN28Q--