From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17840 invoked by alias); 17 May 2009 16:17:51 -0000 Received: (qmail 17831 invoked by uid 22791); 17 May 2009 16:17:50 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout5.012.net.il (HELO mtaout5.012.net.il) (84.95.2.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 17 May 2009 16:17:42 +0000 Received: from conversion-daemon.i_mtaout5.012.net.il by i_mtaout5.012.net.il (HyperSendmail v2004.12) id <0KJS00I00PZHGG00@i_mtaout5.012.net.il> for gdb-patches@sourceware.org; Sun, 17 May 2009 19:16:45 +0300 (IDT) Received: from HOME-C4E4A596F7 ([84.228.115.215]) by i_mtaout5.012.net.il (HyperSendmail v2004.12) with ESMTPA id <0KJS004G6QJWX781@i_mtaout5.012.net.il> for gdb-patches@sourceware.org; Sun, 17 May 2009 19:16:45 +0300 (IDT) Date: Sun, 17 May 2009 16:17:00 -0000 From: Eli Zaretskii Subject: Re: [RFA] More problems with language in printing symbols In-reply-to: <83ab5dq67f.fsf@gnu.org> To: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <833ab3r9g2.fsf@gnu.org> References: <83d4a9q9e5.fsf@gnu.org> <83ab5dq67f.fsf@gnu.org> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-05/txt/msg00344.txt.bz2 > Date: Sat, 16 May 2009 20:59:48 +0300 > From: Eli Zaretskii > Cc: gdb-patches@sourceware.org > > 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? Here's a patch that implements 2 ideas: it uses language_minimal for the "_globals_" pseudo-file, and it makes dump_symtab be defensive about the language of the symtab we are dumping. OK to commit? 2009-05-17 Eli Zaretskii * symmisc.c (dump_symtab): Switch the current language to the language of the symtab we are dumping only if the symtab's language is neither language_auto nor language_unknown. * coffread.c (coff_symtab_read): Set language_minimal as the language for the "_globals_" pseudo-file. --- coffread.c~1 2009-05-16 19:24:27.843781500 +0300 +++ coffread.c 2009-05-17 19:07:34.874125000 +0300 @@ -758,6 +758,11 @@ coff_symtab_read (long symtab_offset, un coff_end_symtab (objfile); coff_start_symtab ("_globals_"); + /* coff_start_symtab will set the language of this symtab to + language_unknown, since such a ``file name'' is not + recognized. Override that with the minimal language to + allow printing values in this symtab. */ + current_subfile->language = language_minimal; complete_symtab ("_globals_", 0, 0); /* done with all files, everything from here on out is globals */ } --- symmisc.c~0 2009-01-03 09:57:53.000000000 +0200 +++ symmisc.c 2009-05-17 19:02:46.139750000 +0300 @@ -496,16 +496,23 @@ static void dump_symtab (struct objfile *objfile, struct symtab *symtab, struct ui_file *outfile) { - enum language saved_lang; - /* 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); + language to print an image of the symbol. We'll restore it later. + But use only real languages, not placeholders. */ + if (symtab->language != language_unknown + && symtab->language != language_auto) + { + enum language saved_lang; + + saved_lang = set_language (symtab->language); - dump_symtab_1 (objfile, symtab, outfile); + dump_symtab_1 (objfile, symtab, outfile); - set_language (saved_lang); + set_language (saved_lang); + } + else + dump_symtab_1 (objfile, symtab, outfile); } void