This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Emit DW_LANG_C99 for C with -std=c99 (PR debug/38757)


On Fri, Apr 16, 2010 at 4:34 PM, Jakub Jelinek <jakub@redhat.com>
wrote:
> Hi!
>
> Here is updated patch to differentiate C89 and C99 in DWARF3+
> DW_TAG_compile_unit. ?I've posted it already a year ago and used in Fedora
> gcc since then, it hasn't been committed to trunk because of fears of
> interaction with LTO, but given that LTO still doesn't have usable
> debugging, I think LTO for the time being outputting always DW_LANG_C89
> instead of DW_LANG_C99 for -std=c99 when it outputs DW_LANG_C89 instead
> of DW_LANG_C_plus_plus etc. for the various languages is the least of
> problems LTO debugging currently has.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Well.  I would like that the frontends build a TRANSLATION_UNIT_DECL
for each translation unit they process and that this kind of information
is stuck there - maybe just as plain DW_LANG_*, set via a
debug hook.  (I'd also like that all global identifiers that currently
have a NULL DECL/TYPE/*/_CONTEXT have this TU DECL as context)

As we are in stage1, can you check how much work the former
would be?

Thanks,
Richard.

> 2010-04-16 ?Jakub Jelinek ?<jakub@redhat.com>
>
> ? ? ? ?PR debug/38757
> ? ? ? ?* langhooks.h (struct lang_hooks): Add source_language langhook.
> ? ? ? ?* langhooks-def.h (LANG_HOOKS_SOURCE_LANGUAGE): Define to NULL.
> ? ? ? ?(LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_SOURCE_LANGUAGE.
> ? ? ? ?* c-lang.c (c_source_language): New function.
> ? ? ? ?(LANG_HOOKS_SOURCE_LANGUAGE): Define.
> ? ? ? ?* dwarf2out.c (add_prototyped_attribute): Add DW_AT_prototype
> ? ? ? ?also for DW_LANG_{C,C99,ObjC}.
> ? ? ? ?(gen_compile_unit_die): Use lang_hooks.source_language () to
> ? ? ? ?determine if DW_LANG_C99 or DW_LANG_C89 should be returned.
>
> --- gcc/langhooks-def.h.jj ? ? ?2010-04-16 14:00:51.000000000 +0200
> +++ gcc/langhooks-def.h 2010-04-16 14:03:11.000000000 +0200
> @@ -106,6 +106,7 @@ extern void lhd_omp_firstprivatize_type_
> ?#define LANG_HOOKS_BUILTIN_FUNCTION ? ?lhd_builtin_function
> ?#define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE ?LANG_HOOKS_BUILTIN_FUNCTION
> ?#define LANG_HOOKS_EXPR_TO_DECL ? ? ? ? ? ? ? ?lhd_expr_to_decl
> +#define LANG_HOOKS_SOURCE_LANGUAGE ? ? NULL
> ?#define LANG_HOOKS_TO_TARGET_CHARSET ? lhd_to_target_charset
> ?#define LANG_HOOKS_INIT_TS ? ? ? ? ? ? lhd_do_nothing
> ?#define LANG_HOOKS_EH_PERSONALITY ? ? ?lhd_gcc_personality
> @@ -298,6 +299,7 @@ extern void lhd_end_section (void);
> ? LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE, \
> ? LANG_HOOKS_INIT_TS, ? ? ? ? ?\
> ? LANG_HOOKS_EXPR_TO_DECL, \
> + ?LANG_HOOKS_SOURCE_LANGUAGE, \
> ? LANG_HOOKS_EH_PERSONALITY, \
> ? LANG_HOOKS_EH_RUNTIME_TYPE, \
> ? LANG_HOOKS_EH_USE_CXA_END_CLEANUP, \
> --- gcc/langhooks.h.jj ?2010-04-16 14:00:51.000000000 +0200
> +++ gcc/langhooks.h ? ? 2010-04-16 14:03:42.000000000 +0200
> @@ -443,6 +443,10 @@ struct lang_hooks
> ? ? ?if in the process TREE_CONSTANT or TREE_SIDE_EFFECTS need updating. ?*/
> ? tree (*expr_to_decl) (tree expr, bool *tc, bool *se);
>
> + ?/* Return year of the source language standard version if the FE supports
> + ? ? multiple versions of the standard. ?*/
> + ?int (*source_language) (void);
> +
> ? /* The EH personality function decl. ?*/
> ? tree (*eh_personality) (void);
>
> --- gcc/dwarf2out.c.jj ?2010-04-16 14:00:51.000000000 +0200
> +++ gcc/dwarf2out.c ? ? 2010-04-16 14:05:57.000000000 +0200
> @@ -16640,9 +16640,18 @@ add_bit_size_attribute (dw_die_ref die,
> ?static inline void
> ?add_prototyped_attribute (dw_die_ref die, tree func_type)
> ?{
> - ?if (get_AT_unsigned (comp_unit_die, DW_AT_language) == DW_LANG_C89
> - ? ? ?&& TYPE_ARG_TYPES (func_type) != NULL)
> - ? ?add_AT_flag (die, DW_AT_prototyped, 1);
> + ?switch (get_AT_unsigned (comp_unit_die, DW_AT_language))
> + ? ?{
> + ? ?case DW_LANG_C:
> + ? ?case DW_LANG_C89:
> + ? ?case DW_LANG_C99:
> + ? ?case DW_LANG_ObjC:
> + ? ? ?if (TYPE_ARG_TYPES (func_type) != NULL)
> + ? ? ? add_AT_flag (die, DW_AT_prototyped, 1);
> + ? ? ?break;
> + ? ?default:
> + ? ? ?break;
> + ? ?}
> ?}
>
> ?/* Add an 'abstract_origin' attribute below a given DIE. ?The DIE is found
> @@ -18711,6 +18720,10 @@ gen_compile_unit_die (const char *filena
> ? ? ? ?language = DW_LANG_ObjC;
> ? ? ? else if (strcmp (language_string, "GNU Objective-C++") == 0)
> ? ? ? ?language = DW_LANG_ObjC_plus_plus;
> + ? ? ?else if (strcmp (language_string, "GNU C") == 0
> + ? ? ? ? ? ? ?&& lang_hooks.source_language
> + ? ? ? ? ? ? ?&& lang_hooks.source_language () >= 1999)
> + ? ? ? language = DW_LANG_C99;
> ? ? }
>
> ? add_AT_unsigned (die, DW_AT_language, language);
> --- gcc/c-lang.c.jj ? ? 2009-09-03 14:02:04.000000000 +0200
> +++ gcc/c-lang.c ? ? ? ?2010-04-16 14:01:30.000000000 +0200
> @@ -37,6 +37,12 @@ along with GCC; see the file COPYING3.
>
> ?enum c_language_kind c_language = clk_c;
>
> +static int
> +c_source_language (void)
> +{
> + ?return flag_isoc99 ? 1999 : 1989;
> +}
> +
> ?/* Lang hooks common to C and ObjC are declared in c-objc-common.h;
> ? ?consequently, there should be very few hooks below. ?*/
>
> @@ -44,6 +50,8 @@ enum c_language_kind c_language = clk_c;
> ?#define LANG_HOOKS_NAME "GNU C"
> ?#undef LANG_HOOKS_INIT
> ?#define LANG_HOOKS_INIT c_objc_common_init
> +#undef LANG_HOOKS_SOURCE_LANGUAGE
> +#define LANG_HOOKS_SOURCE_LANGUAGE c_source_language
>
> ?/* Each front end provides its own lang hook initializer. ?*/
> ?struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
>
> ? ? ? ?Jakub
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]