From 01f8c46dda6579913074a1d04eca0ad7fc437f47 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 17 Oct 2010 18:49:47 +0000 Subject: [PATCH] gdb/ Fix the `stopped language detection' testcase for gcc-4.5. * dwarf2read.c (read_partial_die): Set also LANGUAGE_OF_MAIN. * symfile.c (set_initial_language): Move variable filename to a more inner block. Prefer LANGUAGE_OF_MAIN. * symtab.c (language_of_main): New variable. (set_main_name): Always reset LANGUAGE_OF_MAIN. * symtab.h (language_of_main): New declaration. --- gdb/ChangeLog | 10 ++++++++++ gdb/dwarf2read.c | 8 +++++++- gdb/symfile.c | 14 ++++++++++---- gdb/symtab.c | 3 +++ gdb/symtab.h | 1 + 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3cdd41c9151..d1f44770ddc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2010-10-17 Jan Kratochvil + + Fix the `stopped language detection' testcase for gcc-4.5. + * dwarf2read.c (read_partial_die): Set also LANGUAGE_OF_MAIN. + * symfile.c (set_initial_language): Move variable filename to a more + inner block. Prefer LANGUAGE_OF_MAIN. + * symtab.c (language_of_main): New variable. + (set_main_name): Always reset LANGUAGE_OF_MAIN. + * symtab.h (language_of_main): New declaration. + 2010-10-17 Jan Kratochvil Pedro Alves diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index e92795b5873..7c784545d39 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -8880,7 +8880,13 @@ read_partial_die (struct partial_die_info *part_die, practice. */ if (DW_UNSND (&attr) == DW_CC_program && cu->language == language_fortran) - set_main_name (part_die->name); + { + set_main_name (part_die->name); + + /* As this DIE has a static linkage the name would be difficult + to look up later. */ + language_of_main = language_fortran; + } break; default: break; diff --git a/gdb/symfile.c b/gdb/symfile.c index cfbfd55e3ff..f1c2941d394 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1568,12 +1568,18 @@ symbol_file_command (char *args, int from_tty) void set_initial_language (void) { - const char *filename; enum language lang = language_unknown; - filename = find_main_filename (); - if (filename != NULL) - lang = deduce_language_from_filename (filename); + if (language_of_main != language_unknown) + lang = language_of_main; + else + { + const char *filename; + + filename = find_main_filename (); + if (filename != NULL) + lang = deduce_language_from_filename (filename); + } if (lang == language_unknown) { diff --git a/gdb/symtab.c b/gdb/symtab.c index baf6d940d76..a6023b9abf2 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4389,6 +4389,7 @@ decode_line_spec (char *string, int funfirstline) /* Track MAIN */ static char *name_of_main; +enum language language_of_main = language_unknown; void set_main_name (const char *name) @@ -4397,10 +4398,12 @@ set_main_name (const char *name) { xfree (name_of_main); name_of_main = NULL; + language_of_main = language_unknown; } if (name != NULL) { name_of_main = xstrdup (name); + language_of_main = language_unknown; } } diff --git a/gdb/symtab.h b/gdb/symtab.h index be1a7461064..a4032f8ec5e 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1238,6 +1238,7 @@ extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search const. */ extern void set_main_name (const char *name); extern /*const */ char *main_name (void); +extern enum language language_of_main; /* Check global symbols in objfile. */ struct symbol *lookup_global_symbol_from_objfile (const struct objfile *objfile, -- 2.30.2