[PATCH] Fix language of compilation unit with unknown file extension (Re: [PATCH] Guard compile tests from running when unsupported + harden feature support check)
Doug Evans
dje@google.com
Wed Aug 19 20:43:00 GMT 2015
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.
More information about the Gdb-patches
mailing list