From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: drow@false.org, cagney@gnu.org
Cc: gdb@sources.redhat.com
Subject: Re: METHOD_PTR_*?
Date: Mon, 29 Nov 2004 15:37:00 -0000 [thread overview]
Message-ID: <OFA02A4FD1.A2CBD8B5-ON41256F5B.004F4BCF-41256F5B.0050CE65@de.ibm.com> (raw)
Daniel Jacobowitz wrote:
>On Tue, Nov 09, 2004 at 03:57:02PM -0500, Andrew Cagney wrote:
>> Hello,
>>
>> From value.h:
>>
>> /* Pointer to member function. Depends on compiler implementation. */
>>
>> #define METHOD_PTR_IS_VIRTUAL(ADDR) ((ADDR) & 0x80000000)
>> #define METHOD_PTR_FROM_VOFFSET(OFFSET) (0x80000000 + (OFFSET))
>> #define METHOD_PTR_TO_VOFFSET(ADDR) (~0x80000000 & (ADDR))
>>
>> It also depends on the underlying architecture - not very 64-bit
>> friendly :-/
>
>Yuck!
>
>If I'm reading this right, it corresponded to some old compiler's
>implementation. But nowadays we fake it in
>value_struct_elt_for_reference. This is a bit tricky to untangle, but
>I think this could be solved entirely in eval.c (and the one place we
>print "virtual" and ditching the remaining bits. I wonder if anything
>in the testsuite exercises this?
This is responsible for these testsuite failures on s390x-ibm-linux:
FAIL: gdb.cp/classes.exp: print Bar::z
FAIL: gdb.cp/printmethod.exp: print virtual method.
(s390x tends to exercise this bug as the default load address for
executables happens to be 0x80000000.)
I don't think this can be handled entirely in eval.c; while there are
some cases where gdb code itself sets up something like a pointer-to-
member-function (which you could conceivably handle internally), you
also need to be able to handle a *real* p-t-m set up by the target
compiler. However, there doesn't appear to be any real testsuite
coverage for that case.
As the format of a pointer-to-member is defined by the platform ABI,
I guess some sort of target callback would be appropriate.
For GNU/Linux using GCC 3.x, the format is defined for IA64 at
http://www.codesourcery.com/cxx-abi/abi.html#member-pointers
and non-IA64 platforms use variants of that scheme; here's what
the GCC internals doc has to say about it:
`TARGET_PTRMEMFUNC_VBIT_LOCATION'
The C++ compiler represents a pointer-to-member-function with a
struct that looks like:
struct {
union {
void (*fn)();
ptrdiff_t vtable_index;
};
ptrdiff_t delta;
};
The C++ compiler must use one bit to indicate whether the function
that will be called through a pointer-to-member-function is
virtual. Normally, we assume that the low-order bit of a function
pointer must always be zero. Then, by ensuring that the
vtable_index is odd, we can distinguish which variant of the union
is in use. But, on some platforms function pointers can be odd,
and so this doesn't work. In that case, we use the low-order bit
of the `delta' field, and shift the remainder of the `delta' field
to the left.
Mit freundlichen Gruessen / Best Regards
Ulrich Weigand
--
Dr. Ulrich Weigand
Linux for S/390 Design & Development
IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
Phone: +49-7031/16-3727 --- Email: Ulrich.Weigand@de.ibm.com
next reply other threads:[~2004-11-29 14:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-29 15:37 Ulrich Weigand [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-11-09 21:54 METHOD_PTR_*? Andrew Cagney
2004-11-10 3:24 ` METHOD_PTR_*? Daniel Jacobowitz
2004-11-16 1:15 ` METHOD_PTR_*? Andrew Cagney
2004-11-16 1:24 ` METHOD_PTR_*? Daniel Jacobowitz
2004-11-16 4:56 ` METHOD_PTR_*? Andrew Cagney
2004-11-17 23:06 ` METHOD_PTR_*? Daniel Jacobowitz
2005-02-09 0:45 ` METHOD_PTR_*? Andrew Cagney
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=OFA02A4FD1.A2CBD8B5-ON41256F5B.004F4BCF-41256F5B.0050CE65@de.ibm.com \
--to=ulrich.weigand@de.ibm.com \
--cc=cagney@gnu.org \
--cc=drow@false.org \
--cc=gdb@sources.redhat.com \
/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