This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] DW_TAG_ptr_to_member_type for PMF and DW_AT_{,rvalue_}reference for those
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Alexandre Oliva <aoliva at redhat dot com>, Keith Seitz <keiths at redhat dot com>, Jan Kratochvil <jan dot kratochvil at redhat dot com>, Pierre-Marie de Rodat <derodat at adacore dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 2 Nov 2016 16:44:05 +0100
- Subject: Re: [PATCH] DW_TAG_ptr_to_member_type for PMF and DW_AT_{,rvalue_}reference for those
- Authentication-results: sourceware.org; auth=none
- References: <20161102143100.GU3541@tucnak.redhat.com> <CADzB+2=MjeQ-W3vrDSDRVhbuFhgJQZJ3wFBMv0rz=3A8YATTmw@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Nov 02, 2016 at 11:31:25AM -0400, Jason Merrill wrote:
> On Wed, Nov 2, 2016 at 10:31 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > It uses Alex' LANG_HOOKS_GET_PTRMEMFN_TYPE langhook. I've tried
> > to think about https://gcc.gnu.org/ml/gcc-patches/2011-05/msg00227.html
> > and we even have such a langhook now, modified_type_die
> > uses lang_hooks.types.get_debug_type, but
> > 1) it is just called in modified_type_die and not in
> > gen_type_die_with_usage, that looks weird
>
> How much of a problem is that? modified_type_die calls gen_type_die,
> does that not cover the cases needed here?
If e.g. on the ref-3.C testcase from the patch I put breakpoint on
both gen_ptr_to_mbr_type_die and modified_type_die (the latter only for
type->base.code == RECORD_TYPE), then I see first:
#0 gen_ptr_to_mbr_type_die (type=<record_type 0x7ffff1727150>,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>,
class_type=<record_type 0x7ffff1709540 S>, member_type=<method_type 0x7ffff1709738>) at ../../gcc/dwarf2out.c:23128
#1 0x0000000000c3a7e5 in gen_type_die_with_usage (type=<record_type 0x7ffff1727150>,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>, usage=DINFO_USAGE_DIR_USE)
at ../../gcc/dwarf2out.c:24428
#2 0x0000000000c3ab92 in gen_type_die (type=<record_type 0x7ffff1727150>,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:24491
#3 0x0000000000c3caed in gen_decl_die (decl=<var_decl 0x7ffff7ff9ea0 o1>, origin=<tree 0x0>, ctx=0x0,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:25117
#4 0x0000000000c3b13e in process_scope_var (stmt=<block 0x7ffff17129c0>, decl=<var_decl 0x7ffff7ff9ea0 o1>, origin=<tree 0x0>,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:24620
#5 0x0000000000c3b1bb in decls_for_scope (stmt=<block 0x7ffff17129c0>,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:24645
and only afterwards:
#0 modified_type_die (type=<record_type 0x7ffff1727150>, cv_quals=0, reverse=false,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:12328
#1 0x0000000000c2f03b in add_type_attribute (object_die=<dw_die_ref 0x7ffff1738aa0 DW_TAG_variable <parent=0x7ffff1738910 DW_TAG_subprogram>>,
type=<record_type 0x7ffff1727150>, cv_quals=0, reverse=false,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:20346
#2 0x0000000000c354f4 in gen_variable_die (decl=<var_decl 0x7ffff7ff9ea0 o1>, origin=<tree 0x0>,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:22688
#3 0x0000000000c3cb8e in gen_decl_die (decl=<var_decl 0x7ffff7ff9ea0 o1>, origin=<tree 0x0>, ctx=0x0,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:25138
#4 0x0000000000c3b13e in process_scope_var (stmt=<block 0x7ffff17129c0>, decl=<var_decl 0x7ffff7ff9ea0 o1>, origin=<tree 0x0>,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:24620
#5 0x0000000000c3b1bb in decls_for_scope (stmt=<block 0x7ffff17129c0>,
context_die=<dw_die_ref 0x7ffff1738910 DW_TAG_subprogram <parent=0x7ffff15c7000 DW_TAG_compile_unit>>) at ../../gcc/dwarf2out.c:24645
which means if gen_type_die or gen_type_die_with_usage doesn't
use the langhook, then we'd emit a completely useless { __pfn; __delta }
struct into debug info first, and then in modified_type_die used
the langhook, get OFFSET_TYPE and probably create the
DW_TAG_ptr_to_member_type. So I think we really need that.
> > 2) it is used for something Ada-ish I really don't know how to test etc.
> > to be able to find out if it is safe to call it in
> > gen_type_die_with_usage too
>
> You could find an Ada test that uses the code and verify that the
> output stays the same?
I can try to find the patch that introduced it and if it contained any
testcases.
> > 3) most importantly, if the C++ version of this langhook would create
> > OFFSET_TYPE on the fly, I don't know how to ensure effective sharing
> > of DW_TAG_ptr_to_member_type nodes with the same DW_AT_type
> > and DW_AT_containing_type; unless the C++ langhook adds some extra
> > hash table that caches already created OFFSET_TYPEs or something similar,
> > it would create a new OFFSET_TYPE each time it is called
>
> build_offset_type already uses a hash table.
Ah, ok.
> > Also, I really don't know how well does GDB (especially older releases)
> > handle DW_TAG_ptr_to_member_type for PMF, so the patch wraps that currently
> > with if (dwarf_version >= 5). Quick grep revealed that GDB has code to
> > handle the __pfn/__delta fields. So, can I ask somebody from the GDB
> > team to test this patch with that if (dwarf_version >= 5) replaced
> > with if (1) and see if it works properly with current GDB as well as say
> > 4-5 years old one (e.g. with -gdwarf-2 or -gdwarf-3)? If yes, we
> > should emit it unconditionally.
>
> This all makes sense to me.
>
> > + if (dwarf_version >= 5)
> > + {
> > + tree class_type = lang_hooks.types.get_ptrmemfn_type (type, 0);
> > + if (class_type != NULL_TREE)
>
> This can be
>
> if (dwarf_version >= 5)
> if (tree class_type = lang_hooks.types.get_ptrmemfn_type (type, 0))
Ok.
Jakub