summaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-08-07 20:03:51 +0000
committerTom Tromey <tromey@redhat.com>2013-08-07 20:03:51 +0000
commit2851c5f32ef2fafa14f453c605d9d7d1b1b0ebc6 (patch)
treec08fe003e948502648eb5e3c9886fc661e419056 /gdb/symfile.c
parent004afad6580339ea2058e2e57844f9c4cec045d4 (diff)
downloadgdb-2851c5f32ef2fafa14f453c605d9d7d1b1b0ebc6.tar.gz
use language of the main symbol
With "dwz -m", "main" appears in both the PU and the importing CU when running anon-struct.exp. However, the PU does not have a file name. So, find_main_filename returns the empty string, making deduce_language_from_filename return language_unknown. This patch fixes this problem by changing gdb to use the ordinary symbol-lookup functions to find "main"'s symbol. Then, it examines the symbol's language. I think this is cleaner than the current approach. For one thing it avoids trying to guess the language based on the source file name, instead deferring to the presumably more reliable debuginfo. Another possible fix would have been to change how the file name is found via the "qf" methods. However, I think the approach given is preferable for the reason outlined above. This required a minor test suite change, as now a symtab is expanded during the search for "main". Built and regtested (both ways) on x86-64 Fedora 18. * symfile.c (set_initial_language): Look up "main" symbol and use its language. * symtab.c (find_main_filename): Remove. * symtab.h (find_main_filename): Remove. * gdb.base/maint.exp: Allow zero symtabs to be expanded.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 33286487555..3dd550927f7 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1612,11 +1612,11 @@ set_initial_language (void)
lang = language_of_main;
else
{
- const char *filename;
+ char *name = main_name ();
+ struct symbol *sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL);
- filename = find_main_filename ();
- if (filename != NULL)
- lang = deduce_language_from_filename (filename);
+ if (sym != NULL)
+ lang = SYMBOL_LANGUAGE (sym);
}
if (lang == language_unknown)