This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix language of compilation unit with unknown file extension (Re: [PATCH] Guard compile tests from running when unsupported + harden feature support check)
- From: Doug Evans <dje at google dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Luis Machado <lgustavo at codesourcery dot com>, gdb-patches <gdb-patches at sourceware dot org>
- Date: Wed, 19 Aug 2015 13:42:19 -0700
- Subject: Re: [PATCH] Fix language of compilation unit with unknown file extension (Re: [PATCH] Guard compile tests from running when unsupported + harden feature support check)
- Authentication-results: sourceware.org; auth=none
- References: <1439988825-19754-1-git-send-email-lgustavo at codesourcery dot com> <55D48179 dot 2030000 at redhat dot com> <55D485D1 dot 8040802 at codesourcery dot com> <55D48891 dot 7050808 at redhat dot com> <55D4C47F dot 6080902 at codesourcery dot com> <55D4DF8C dot 1000408 at redhat dot com> <55D4E0CB dot 7070404 at redhat dot com>
On Wed, Aug 19, 2015 at 1:02 PM, Pedro Alves <palves@redhat.com> wrote:
> On 08/19/2015 08:57 PM, Pedro Alves wrote:
>> On 08/19/2015 07:01 PM, Luis Machado wrote:
>>> It could be either a GDB bug for not honoring the language in the DIE
>>> itself or a testcase issue for not naming the source file with the
>>> correct language extension.
>>
>> I think it's a GDB bug. See patch below.
>
> I had left some unnecessary bits in the test's assembly (copy/paste, and
> then insufficient trimming). Here's a leaner version.
>
> ---
> From 8451d7202d4126bfaec5a49fe555989b6fd9b2b1 Mon Sep 17 00:00:00 2001
> From: Pedro Alves <palves@redhat.com>
> Date: Wed, 19 Aug 2015 20:52:44 +0100
> Subject: [PATCH] Fix language of compilation unit with unknown file extension
>
> Here, in dwarfread.c:process_full_comp_unit:
>
> /* Set symtab language to language from DW_AT_language. If the
> compilation is from a C file generated by language preprocessors, do
> not set the language if it was already deduced by start_subfile. */
> if (!(cu->language == language_c
> && COMPUNIT_FILETABS (cust)->language != language_c))
> COMPUNIT_FILETABS (cust)->language = cu->language;
>
> in case start_subfile doesn't manage to deduce a language
> COMPUNIT_FILETABS(cust)->language ends up as language_unknown, not
> language_c. So the condition above evals false and we never set the
> language from the cu's language.
>
> gdb/ChangeLog:
> 2015-08-19 Pedro Alves <palves@redhat.com>
>
> * dwarf2read.c (process_full_comp_unit): To tell whether
> start_subfile managed to deduce a language, test for
> language_unknown instead of language_c.
>
> gdb/testsuite/ChangeLog:
> 2015-08-19 Pedro Alves <palves@redhat.com>
>
> * gdb.dwarf2/comp-unit-lang.exp: New file.
> * gdb.dwarf2/comp-unit-lang.c: New file.
LGTM.
I'm assuming the "global lang" in the test is necessary.
Didn't verify it though.