public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14998] New: GDB cannot handle pointer to member functions being encoded with DW_TAG_ptr_to_member_type
@ 2013-01-07  1:10 dblaikie at gmail dot com
  2013-01-07 15:41 ` [Bug c++/14998] " tromey at redhat dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: dblaikie at gmail dot com @ 2013-01-07  1:10 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=14998

             Bug #: 14998
           Summary: GDB cannot handle pointer to member functions being
                    encoded with DW_TAG_ptr_to_member_type
           Product: gdb
           Version: 7.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@sourceware.org
        ReportedBy: dblaikie@gmail.com
                CC: echristo@gmail.com
    Classification: Unclassified


In experimenting with adding support for encoding pointers to members
(functions and variables) in Clang I've prototyped support for encoding these
as DW_TAG_ptr_to_member_type. For member variables this works fine & appears to
be exactly as GCC (4.7) implements debug info.

For pointers to member functions GCC output (& GDB's (7.5) expectation) is a
completely different representation. It seems the member function pointer is
represented as a struct with two members:
1) a non-member function pointer of a type equivalent to the non-member type of
the member function pointer (ie: it includes the hidden initial 'this'
parameter, duly marked as artificial, though GCC doesn't always honor this in
places it seems it should)
2) a long int offset

I would like to encode member function pointers the same way member variable
pointers are encoded, using DW_TAG_ptr_to_member_type. It's simpler to
implement in Clang and the debug info is much smaller.

Also, if this was done, it might address a quirk in the way GDB prints out the
type of member function pointers. Given:

struct foo {
  int bar(int, float) {
  }
};

int (foo::*x)(int, float);

compiled with GCC and debugged in GDB, "ptype x" prints "type = int
(foo::*)(foo * const, int, float)", note the spurious first parameter ("foo
*const") which should not be displayed.

For now, with my experimental Clang output, GDB prints "int foo::*(int, float)"
(missing the extra "()" around "foo::*") and doesn't understand that the type
is a pointer to member function (so it doesn't print out the function name of
the pointers value when printing the pointer, it doesn't support calling the
member function pointer with the usual syntax, etc)

(Related Clang bug: http://llvm.org/bugs/show_bug.cgi?id=14759 )

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-01-31 17:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-07  1:10 [Bug c++/14998] New: GDB cannot handle pointer to member functions being encoded with DW_TAG_ptr_to_member_type dblaikie at gmail dot com
2013-01-07 15:41 ` [Bug c++/14998] " tromey at redhat dot com
2013-01-07 17:11 ` tromey at redhat dot com
2013-01-07 17:57 ` dblaikie at gmail dot com
2013-01-07 17:58 ` dblaikie at gmail dot com
2013-01-07 17:59 ` dblaikie at gmail dot com
2013-01-07 19:01 ` tromey at redhat dot com
2013-01-07 19:11 ` dblaikie at gmail dot com
2013-01-07 19:35 ` tromey at redhat dot com
2013-01-07 19:41 ` dblaikie at gmail dot com
2013-01-08  3:08 ` dblaikie at gmail dot com
2013-01-08  4:48 ` tromey at redhat dot com
2013-01-08 17:12 ` tromey at redhat dot com
2013-01-19 19:22 ` dblaikie at gmail dot com
2013-01-31 17:41 ` cvs-commit at gcc dot gnu.org
2013-01-31 17:42 ` tromey at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).