[PATCH] Re: [RFC] introduction of a new language hook for DWARF2 names
Nicolas Setton
setton@adacore.com
Thu May 18 17:02:00 GMT 2006
On May 14, 2006, at 23:20, Mark Mitchell wrote:
>
> While something like the types_compatible_p langhook is bad, I don't
> think that this case is a problem. The LTO draft suggests writing out
> declarations by writing out DWARF2. So, a language-hook to control
> DWARF2 would be OK because it would run during the original
> processing,
> and therefore not be needed when generating the final code.
>
Here is a patch that implements this solution.
It passes the full regression testsuite on x86/linux with all languages.
Nicolas
===================================================================
* dwarf2out.c (dwarf2_name): Make use of the dwarf_name
language hook.
* ada/misc.c (gnat_dwarf_name): New function.
(LANG_HOOKS_DWARF_NAME): Define to gnat_dwarf_name.
* langhooks.c (lhd_dwarf_name): New function.
* langhooks.h (struct lang_hooks): Add language hook
dwarf_name, used to allow languages to specify which string
to use in DWARF2/3 public names for a given tree.
* langhooks-def.h (lhd_dwarf_name): Declare.
(LANG_HOOKS_DWARF_NAME): New macro, defaults to lhd_dwarf_name.
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 113783)
+++ gcc/dwarf2out.c (working copy)
@@ -7232,14 +7232,12 @@
}
}
-/* The DWARF2 pubname for a nested thingy looks like "A::f". The
- output of lang_hooks.decl_printable_name for C++ looks like
- "A::f(int)". Let's drop the argument list, and maybe the scope. */
+/* Return the DWARF2/3 pubname associated with a decl. */
static const char *
dwarf2_name (tree decl, int scope)
{
- return lang_hooks.decl_printable_name (decl, scope ? 1 : 0);
+ return lang_hooks.dwarf_name (decl, scope ? 1 : 0);
}
/* Add a new entry to .debug_pubnames if appropriate. */
Index: gcc/ada/misc.c
===================================================================
--- gcc/ada/misc.c (revision 113783)
+++ gcc/ada/misc.c (working copy)
@@ -94,6 +94,7 @@
static void gnat_print_decl (FILE *, tree, int);
static void gnat_print_type (FILE *, tree, int);
static const char *gnat_printable_name (tree, int);
+static const char *gnat_dwarf_name (tree, int);
static tree gnat_eh_runtime_type (tree);
static int gnat_eh_type_covers (tree, tree);
static void gnat_parse_file (int);
@@ -144,6 +145,8 @@
#define LANG_HOOKS_TYPE_MAX_SIZE gnat_type_max_size
#undef LANG_HOOKS_DECL_PRINTABLE_NAME
#define LANG_HOOKS_DECL_PRINTABLE_NAME gnat_printable_name
+#undef LANG_HOOKS_DWARF_NAME
+#define LANG_HOOKS_DWARF_NAME gnat_dwarf_name
#undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
#define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gnat_expand_body
#undef LANG_HOOKS_GIMPLIFY_EXPR
@@ -596,6 +599,14 @@
return (const char *) ada_name;
}
+static const char *
+gnat_dwarf_name (tree t, int verbosity)
+{
+ gcc_assert (DECL_P (t));
+
+ return (const char *) IDENTIFIER_POINTER (DECL_NAME (t));
+}
+
/* Expands GNAT-specific GCC tree nodes. The only ones we support
here are and NULL_EXPR. */
Index: gcc/langhooks.c
===================================================================
--- gcc/langhooks.c (revision 113783)
+++ gcc/langhooks.c (working copy)
@@ -264,6 +264,17 @@
return IDENTIFIER_POINTER (DECL_NAME (decl));
}
+
+/* This is the default dwarf_name function. */
+
+const char *
+lhd_dwarf_name (tree t, int verbosity)
+{
+ gcc_assert (DECL_P (t));
+
+ return lang_hooks.decl_printable_name (t, verbosity);
+}
+
/* This compares two types for equivalence ("compatible" in C-based
languages).
This routine should only return 1 if it is sure. It should not
be used
in contexts where erroneously returning 0 causes problems. */
Index: gcc/langhooks.h
===================================================================
--- gcc/langhooks.h (revision 113783)
+++ gcc/langhooks.h (working copy)
@@ -382,6 +382,11 @@
types in C++. */
const char *(*decl_printable_name) (tree decl, int verbosity);
+ /* Computes the dwarf-2/3 name for a tree. VERBOSITY determines what
+ information will be printed: 0: DECL_NAME, demangled as
+ necessary. 1: and scope information. */
+ const char *(*dwarf_name) (tree, int verbosity);
+
/* This compares two types for equivalence ("compatible" in C-
based languages).
This routine should only return 1 if it is sure. It should
not be used
in contexts where erroneously returning 0 causes problems. */
Index: gcc/langhooks-def.h
===================================================================
--- gcc/langhooks-def.h (revision 113783)
+++ gcc/langhooks-def.h (working copy)
@@ -53,6 +53,7 @@
extern tree lhd_staticp (tree);
extern void lhd_print_tree_nothing (FILE *, tree, int);
extern const char *lhd_decl_printable_name (tree, int);
+extern const char *lhd_dwarf_name (tree, int);
extern int lhd_types_compatible_p (tree, tree);
extern rtx lhd_expand_expr (tree, rtx, enum machine_mode, int, rtx *);
extern int lhd_expand_decl (tree);
@@ -124,6 +125,7 @@
#define LANG_HOOKS_PRINT_IDENTIFIER lhd_print_tree_nothing
#define LANG_HOOKS_PRINT_ERROR_FUNCTION lhd_print_error_function
#define LANG_HOOKS_DECL_PRINTABLE_NAME lhd_decl_printable_name
+#define LANG_HOOKS_DWARF_NAME lhd_dwarf_name
#define LANG_HOOKS_GET_CALLEE_FNDECL lhd_return_null_tree
#define LANG_HOOKS_EXPR_SIZE lhd_expr_size
#define LANG_HOOKS_TREE_SIZE lhd_tree_size
@@ -309,6 +311,7 @@
LANG_HOOKS_PRINT_TYPE, \
LANG_HOOKS_PRINT_IDENTIFIER, \
LANG_HOOKS_DECL_PRINTABLE_NAME, \
+ LANG_HOOKS_DWARF_NAME, \
LANG_HOOKS_TYPES_COMPATIBLE_P, \
LANG_HOOKS_GET_CALLEE_FNDECL, \
LANG_HOOKS_PRINT_ERROR_FUNCTION, \
More information about the Gcc-patches
mailing list