Native stack traces
Patrick A Tullmann
tullmann at cs.utah.edu
Wed Jul 15 21:53:30 PDT 1998
Simon J. Gerraty wrote:
> Anyway, kaffe now builds ok on Solaris 2.6 (gcc-2.7.2) but
> dumps core:
....
> #0 0xa18aa0 in ?? ()
> (gdb) bt
> #0 0xa18aa0 in ?? ()
> #1 0xbcd4b0 in ?? ()
> #2 0xa18a58 in ?? ()
> #3 0xb950f0 in ?? ()
> #4 0xbd37e0 in ?? ()
> #5 0xcdec1c in ?? ()
> #6 0xcf6c6c in ?? ()
> #7 0x955d00 in ?? ()
> #8 0x6ea4b4 in ?? ()
> #9 0x446498 in ?? ()
> #10 0xef75ccf8 in callMethodV (meth=0x3b646c, func=0x4f5ac, obj=0xef75ccf0,
> args=0xefffe744, ret=0xefffe5d0)
> at /share/src/kaffe-1.0.b1/kaffe/kaffevm/support.c:518
> #11 0xef76d1ec in Kaffe_CallStaticVoidMethodV (env=0xef79bc58, cls=0x391e08,
> meth=0x3c6fd0, args=0xefffe740)
> at /share/src/kaffe-1.0.b1/kaffe/kaffevm/jni.c:2249
> #12 0xef76d26c in Kaffe_CallStaticVoidMethod (env=0xef79bc58, cls=0x391e08,
> meth=0x3c6fd0) at /share/src/kaffe-1.0.b1/kaffe/kaffevm/jni.c:2262
> #13 0x10f74 in main2 (env=0xef79bc58, argv=0xefffec34, farg=2, argc=3)
> at /share/src/kaffe-1.0.b1/kaffe/kaffe/main.c:188
> #14 0x10e38 in main (argc=4, argv=0xefffec34)
> at /share/src/kaffe-1.0.b1/kaffe/kaffe/main.c:108
> (gdb) q
It looks like Kaffe's blowing up pretty early. I assume (from the
stack trace) that you're using the JIT'r? If not, then you've got me.
Otherwise, you might find the attached gdb macro useful. It takes one
argument, an address, and tries to find the method associated with
that address. For example, "findNativeMethod 0x446498" should print
the name of the class, method and signature of the #9 stack entry.
Major caveat: I haven't tried this macro with the latest Kaffe, and
I've never used it on Solaris (only FreeBSD on x86), but you should
get the idea. Watch out for the long lines, gdb doesn't give
anything approaching good error messages when it finds errors in
macros.
Just stick this in your ~/.gdbinit and it will be there when you need
it.
Hope this is useful!
-Pat
define findNativeMethod
set $addr = $arg0
set $pool = classEntryPool
# Loop through the class pool
set $nel = 255
while $nel > 0
set $class = $pool[$nel]
# Loop thorugh the classes hashed at this index
while $class != 0
set $shClass = $class.class
if ($shClass.state == 10)
# Loop through all the methods defined in this class
set $nmeth = 0
while $nmeth < $shClass.nmethods
set $nat = $shClass.methods[$nmeth].c.ncode
if (($nat.ncode_start) <= $addr) && (($nat.ncode_end) >= $addr)
set $meth = $shClass.methods + $nmeth
printf "%s.%s%s: %p %p\n", $shClass.name.data,$meth.name.data, $meth.signature.data, $nat.ncode_start, $nat.ncode_end
end
set $nmeth = $nmeth + 1
end
end
set $class = $class.next
end
set $nel = $nel - 1
end
set $nel
end
document findNativeMethod
Find the native method objet associated with the given address...
end
More information about the kaffe
mailing list