diff options
author | Pierre Muller <muller@sourceware.org> | 2007-10-09 06:59:27 +0000 |
---|---|---|
committer | Pierre Muller <muller@sourceware.org> | 2007-10-09 06:59:27 +0000 |
commit | cd6c7346a611f2b9f937c9d1e14fb565ab217a3c (patch) | |
tree | fe40acb9d57780958b1fa455802561c69ddbe051 | |
parent | 944d6884eaa85a1376240bfcc934d17f6f99a483 (diff) | |
download | fsf-binutils-gdb-cd6c7346a611f2b9f937c9d1e14fb565ab217a3c.zip fsf-binutils-gdb-cd6c7346a611f2b9f937c9d1e14fb565ab217a3c.tar.gz fsf-binutils-gdb-cd6c7346a611f2b9f937c9d1e14fb565ab217a3c.tar.bz2 |
2007-10-09 Pierre Muller <muller@ics.u-strasbg.fr>
* 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): Add call to pascal_main_name.
* Makefile.in (symtab.o): Add dependency on p-lang.h.
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/Makefile.in | 2 | ||||
-rw-r--r-- | gdb/p-lang.c | 50 | ||||
-rw-r--r-- | gdb/p-lang.h | 3 | ||||
-rw-r--r-- | gdb/symtab.c | 10 |
5 files changed, 73 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 05d9688..d909550 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2007-10-09 Pierre Muller <muller@ics.u-strasbg.fr> + + * 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): Add call to pascal_main_name. + * Makefile.in (symtab.o): Add dependency on p-lang.h. + 2007-10-09 Pedro Alves <pedro_alves@portugalmail.pt> * stabsread.c (read_huge_number): Fix handling of octal diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 863b200..3090558 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -2751,7 +2751,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_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) \ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index ab204a1..4b18720 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -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 * +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 compiled with GPC. */ + 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. diff --git a/gdb/p-lang.h b/gdb/p-lang.h index d6fe9b2..994d9ad 100644 --- a/gdb/p-lang.h +++ b/gdb/p-lang.h @@ -21,6 +21,9 @@ struct value; +/* Defined in p-lang.c */ +extern const 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 */ diff --git a/gdb/symtab.c b/gdb/symtab.c index c2726d4..eeddddd 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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" @@ -4126,7 +4127,7 @@ set_main_name (const char *name) static void find_main_name (void) { - char *new_main_name; + const char *new_main_name; /* Try to see if the main procedure is in Ada. */ /* FIXME: brobecker/2005-03-07: Another way of doing this would @@ -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"); |