I am mostly concerned about the effect on the other languages. I just want to make sure that the rest of the testsuite results stay unchanged. If you don't have access to a machine where you can run the testsuite, then let me know, and I'll give it a quick run on one of our fast machines for you. Your change looks relatively straightforward, but it never hurts to be cautious.
I finally ran the testsuite on Ubuntu (inside VMWare)
The outcome is a bit better after the patch, but I do NOT understand how this patch could have any influence on 'help' behavior. Thus I suspect that this is just non-reproducable...
Pierre
gdb.sum.before is for a clean CVS, gdb.sum is after applying the patch.
fpc@ubuntu:/usr/local/src/build/gdb/testsuite$ diff gdb.sum.before gdb.sum 1c1 < Test Run By fpc on Wed Sep 26 22:41:20 2007 ---
Test Run By fpc on Wed Sep 26 23:37:23 2007
3056,3060c3056,3060 < FAIL: gdb.base/help.exp: help clear (timeout) < FAIL: gdb.base/help.exp: help commands < FAIL: gdb.base/help.exp: help condition < FAIL: gdb.base/help.exp: help core-file < FAIL: gdb.base/help.exp: help delete "d" abbreviation ---
PASS: gdb.base/help.exp: help clear PASS: gdb.base/help.exp: help commands PASS: gdb.base/help.exp: help condition PASS: gdb.base/help.exp: help core-file PASS: gdb.base/help.exp: help delete "d" abbreviation
11129,11130c11129,11130 < # of expected passes 10489 < # of unexpected failures 38 ---
# of expected passes 10494 # of unexpected failures 33
I updated my patch according to the comments from Eli and Joel. Thanks to both.
Eli, I added a comment in p-lang.c that is not really conform to standards, but the whole file uses similar comments. Should I reformat them? In a separate patch?
To GPC developers: there is a blank in the patch: Joel proposed to tell up to which version of GPC, the old name was used. I have no idea about that, could someone please tell me. By the way, is there some publically readable CVS tree for GPC sources?
As stated in a previous email, the patch does not seem to generate new failures in the testsuite.
Pierre
ChangeLog entry:
2007-09-26 Pierre Muller muller@ics.u-strasbg.fr
* p-lang.h (pascal_main_name): New function. p-lang.c (GPC_MAIN_PROGRAM_NAME_1), (GPC_MAIN_PROGRAM_NAME_2): New char array constants corresponding to the two 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.
$ cvs diff -up p-lang.h p-lang.c symtab.c Makefile.in 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 26 Sep 2007 22:30:59 -0000 @@ -21,6 +21,9 @@
struct value;
+/* Defined in p-lang.c */ +extern char *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 26 Sep 2007 22:31:00 -0000 @@ -35,6 +35,43 @@ extern void _initialize_pascal_language (void);
+/* The name of the symbol that GPC uses as the name of the main + subprogram (since version ...). */ +static const char GPC_MAIN_PROGRAM_NAME_1[] + = "_p__M0_main_program"; + +/* Older versions of GPC (version ... and older) were using + a different name for the main subprogram. */ +static const char GPC_MAIN_PROGRAM_NAME_2[] + = "pascal_main_program"; + +/* Function returning the special symbol name used + by GPC if it is found in minimal symbol list. */ + +char * +pascal_main_name (void) +{ + struct minimal_symbol *msym; + + msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_1, NULL, NULL); + + if (msym != NULL) + { + return (char *)GPC_MAIN_PROGRAM_NAME_1; + } + + msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_2, NULL, NULL); + + if (msym != NULL) + { + return (char *)GPC_MAIN_PROGRAM_NAME_2; + } + +/* The main procedure doesn't seem to be compiled with GPC. + Thus default name "main" should work. */ + 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: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.165 diff -u -p -r1.165 symtab.c --- symtab.c 24 Sep 2007 07:40:32 -0000 1.165 +++ symtab.c 26 Sep 2007 22:31:02 -0000 @@ -40,6 +40,7 @@ #include "filenames.h" /* for FILENAME_CMP */ #include "objc-lang.h" #include "ada-lang.h" +#include "p-lang.h"
#include "hashtab.h"
@@ -4151,6 +4152,13 @@ find_main_name (void) return; }
+ new_main_name = pascal_main_name (); + if (new_main_name != NULL) + { + set_main_name (new_main_name); + return; + } + /* The languages above didn't identify the name of the main procedure. Fallback to "main". */ set_main_name ("main"); Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.938 diff -u -p -r1.938 Makefile.in --- Makefile.in 17 Sep 2007 19:32:53 -0000 1.938 +++ Makefile.in 26 Sep 2007 22:31:04 -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) \