public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "dblaikie at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug c++/14998] New: GDB cannot handle pointer to member functions being encoded with DW_TAG_ptr_to_member_type
Date: Mon, 07 Jan 2013 01:10:00 -0000	[thread overview]
Message-ID: <bug-14998-4717@http.sourceware.org/bugzilla/> (raw)

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.


             reply	other threads:[~2013-01-07  1:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07  1:10 dblaikie at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-14998-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).