This is the mail archive of the
java-discuss@sources.redhat.com
mailing list for the Java project.
Re: New C++ ABI: patches.
Bryce McKinlay writes:
> (gdb) p _ZN4java4lang7Integer4TYPEE
> $1 = (java.lang.Class *) 0x0
In the case of `int.class', foo() is given `& _Jv_intClass' as an
argument. I ran the code with `dotclass.class', the code before
calling toString(), yields to:
mov 0x8(%ebp),%eax
sub $0xc,%esp
mov (%eax),%edx
Which gets you with
(gdb) x/x $edx
0x8174fe0 <_ZTVN4java4lang5ClassE>: 0x08175020
0x8174fe4 <_ZTVN4java4lang5ClassE+4>: 0x00000002
0x8174fe8 <_ZTVN4java4lang5ClassE+8>: 0x08054230
0x8174fec <_ZTVN4java4lang5ClassE+12>: 0x08056170
0x8174ff0 <_ZTVN4java4lang5ClassE+16>: 0x0805a120
0x8174ff4 <_ZTVN4java4lang5ClassE+20>: 0x08059fb0
And the right function is selected:
add $0x14,%edx
In the case of `int.class', which we can print:
(gdb) p _Jv_intClass
$1 = {<Object> = {<_JvObjectPrefix> = {_vptr.: @8174fe8},
static class$: @8175180, sync_info: @820ce88}, static class$: @8175020,
next: null, name: @8210f20, accflags: 1041, superclass: null, constants: {
size: 0, tags: null, data: null}, methods: null, method_count: 73,
vtable_method_count: 0, fields: null, size_in_bytes: 4, field_count: 0,
static_field_count: 0, vtable: @ffffffff, interfaces: null, loader: null,
interface_count: 0, state: 12, thread: null, depth: -1, ancestors: null,
idt: null, arrayclass: @8218ea0}
We can see that the content of the vtbl isn't right:
(gdb) x/x $edx
0x8174fe8 <_ZTVN4java4lang5ClassE+8>: 0x08054230
0x8174fec <_ZTVN4java4lang5ClassE+12>: 0x08056170
0x8174ff0 <_ZTVN4java4lang5ClassE+16>: 0x0805a120
0x8174ff4 <_ZTVN4java4lang5ClassE+20>: 0x08059fb0
And the wrong method gets selected. Note that:
(gdb) x/x $edx-8
0x8174fe0 <_ZTVN4java4lang5ClassE>: 0x08175020
0x8174fe4 <_ZTVN4java4lang5ClassE+4>: 0x00000002
gives you the missing entry. For some reasons, the first word of
_Jv_intClass points in the middle of the vtbl instead pointing at its
beginning. I guess there's something going wrong with the copy
constructor: I tried this, but it didn't work:
Class (const Class& x) : Object () {
_Jv_VTable *avtable = x.vtable;
+ _Jv_InitClass (this);
Does anybody have a suggestion?
./A