More problems with language in printing symbols

Eli Zaretskii
2009-05-16T18:00:12Z

There's a similar, but different problem with printing symbols in
"maint print symbols". When the program is compiled with COFF debug
info, "maint print symbols" throws an error for some symbols:

Error printing symbol:
internal error - unimplemented function unk_lang_print_type called.

This happens because of this change:

2005-06-03 Joel Brobecker <brobecker@adacore.com>

* symmisc.c (dump_symtab_1): Renamed from dump_symtab.
(dump_symtab): New function.

The new dump_symtab does this:

/* Set the current language to the language of the symtab we're dumping
because certain routines used during dump_symtab() use the current
language to print an image of the symbol. We'll restore it later. */
saved_lang = set_language (symtab->language);

dump_symtab_1 (objfile, symtab, outfile);

set_language (saved_lang);

However, it does not check what is the value of symtab->language. It
so happens that coffread.c creates a symtab for a "_globals_"
pseudo-file, whose symtab gets its language set to language_unknown,
because deduce_language_from_filename does not recognize such a file
name. And, of course, trying to print symbols with language_unknown
as the current language does not give good results...

I'm unsure how best to fix that. We could try recognizing "_globals_"
in deduce_language_from_filename, but what language to use for it? Or
we could add some defensive fallback in dump_symtab which would not
switch the language if it is language_unknown.

Comments? ideas?