Bug 28767 - GCC should output DW_TAG_ptr_to_member for member functions
Summary: GCC should output DW_TAG_ptr_to_member for member functions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Dodji Seketeli
URL:
Keywords: wrong-debug
: 43312 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-18 04:07 UTC by Daniel Jacobowitz
Modified: 2016-11-04 19:50 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-08-21 05:00:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Jacobowitz 2006-08-18 04:07:07 UTC
For this code:
class A {
  int f(void);
};
int (A::*ptr) (void);

GCC will output debug information claiming that the type of PTR is:

struct {
  void (*__pfn) (args, ...);
  ptrdiff_t __delta;
};

At least for dwarf2, GCC should output DW_TAG_ptr_to_member, just like it does for data members.

The definition in the spec of DW_AT_use_location is pretty meaningless for function members (that's come up on the dwarf list before, but was never resolved, as far as I know), so it should probably be omitted.

This does not affect GDB much.  Versions up to 6.5 have poor pointer to member support.  The next release will be better, but will also recognize GCC's current broken debug information.
Comment 1 Andrew Pinski 2006-08-18 04:15:24 UTC
Confirmed, I am adding the keyword wrong-debug which almost true.
Comment 2 Andrew Pinski 2010-03-09 22:16:39 UTC
*** Bug 43312 has been marked as a duplicate of this bug. ***
Comment 3 Dodji Seketeli 2010-12-16 22:02:10 UTC
Mine.
Comment 4 Dodji Seketeli 2011-03-16 20:24:29 UTC
Patch posted to http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00949.html
Comment 5 Mark Wielaard 2014-03-26 12:13:25 UTC
Some discussion of the patch in comment #4 can be found here: http://gcc.gnu.org/ml/gcc-patches/2011-05/threads.html#00225
Comment 6 Jakub Jelinek 2016-11-03 21:19:21 UTC
Author: jakub
Date: Thu Nov  3 21:18:49 2016
New Revision: 241832

URL: https://gcc.gnu.org/viewcvs?rev=241832&root=gcc&view=rev
Log:
	PR debug/28767
	PR debug/56974
	* langhooks.h (struct lang_hooks_for_types): Add type_dwarf_attribute
	langhook.
	* langhooks.c (lhd_type_dwarf_attribute): New function.
	* langhooks-def.h (lhd_type_dwarf_attribute): Declare.
	(LANG_HOOKS_TYPE_DWARF_ATTRIBUTE): Define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add
	LANG_HOOKS_TYPE_DWARF_ATTRIBUTE.
	(check_qualified_type, check_aligned_type): Call it.
	* dwarf2out.c (modified_type_die): Don't use type_main_variant
	for FUNCTION_TYPE or METHOD_TYPE, instead walk over variants with
	check_base_type and check_lang_type.
	(gen_ptr_to_mbr_type_die): If lookup_type_die is already non-NULL,
	return early.  For pointer-to-data-member add DW_AT_use_location
	attribute.
	(gen_subroutine_type_die): Add DW_AT_{,rvalue_}reference attribute
	if needed.
	(gen_type_die_with_usage): Don't use type_main_variant
	for FUNCTION_TYPE or METHOD_TYPE, instead walk over variants with
	check_base_type and check_lang_type.  Formatting fixes. Call
	get_debug_type langhook.
cp/
	* tree.c (cp_check_qualified_type): Use check_base_type and
	TYPE_QUALS comparison instead of check_qualified_type.
	(cxx_type_hash_eq): Return false if type_memfn_rqual don't match.
	* cp-objcp-common.c (cp_get_debug_type): New function.
	(cp_decl_dwarf_attribute): Don't handle types here.
	(cp_type_dwarf_attribute): New function.
	* cp-objcp-common.h (cp_get_debug_type, cp_type_dwarf_attribute):
	Declare.
	(LANG_HOOKS_GET_DEBUG_TYPE, LANG_HOOKS_TYPE_DWARF_ATTRIBUTE):
	Define.
testsuite/
	* g++.dg/debug/dwarf2/ptrdmem-1.C: New test.
	* g++.dg/debug/dwarf2/ref-3.C: New test.
	* g++.dg/debug/dwarf2/ref-4.C: New test.
	* g++.dg/debug/dwarf2/refqual-1.C: New test.
	* g++.dg/debug/dwarf2/refqual-2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/ptrdmem-1.C
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/ref-3.C
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/ref-4.C
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/refqual-1.C
    trunk/gcc/testsuite/g++.dg/debug/dwarf2/refqual-2.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-objcp-common.c
    trunk/gcc/cp/cp-objcp-common.h
    trunk/gcc/dwarf2out.c
    trunk/gcc/langhooks-def.h
    trunk/gcc/langhooks.c
    trunk/gcc/langhooks.h
    trunk/gcc/testsuite/ChangeLog
Comment 7 Jakub Jelinek 2016-11-04 19:50:08 UTC
Fixed for 7+.