New C++ ABI: patches.

Alexandre Petit-Bianco apbianco@cygnus.com
Thu Jan 11 17:11:00 GMT 2001


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 0ドルxc,%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 0ドルx14,%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


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /