3 /* Copyright (C) 2006 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
16 #include <java-stack.h>
17 #include <gnu/classpath/VMStackWalker.h>
18 #include <gnu/gcj/RawData.h>
19 #include <java/lang/ClassLoader.h>
22 gnu::classpath::VMStackWalker::getClassContext(void)
24 return _Jv_StackTrace::GetStackWalkerStack ();
28 gnu::classpath::VMStackWalker::getCallingClass(void)
30 return _Jv_StackTrace::GetStackWalkerCallingClass ();
34 gnu::classpath::VMStackWalker::getCallingClass(::gnu::gcj::RawData
*pc
)
36 void *f
= _Unwind_FindEnclosingFunction (pc
);
38 // FIXME: it might well be a good idea to cache pc values here in
39 // order to avoid repeated invocations of
40 // _Unwind_FindEnclosingFunction, which is quite expensive. On the
41 // other hand, which not simply write a caching version of
42 // _Unwind_FindEnclosingFunction itself? That would probably be
45 _Jv_StackTrace::UpdateNCodeMap ();
46 jclass klass
= (jclass
) _Jv_StackTrace::ncodeMap
->get ((jobject
) f
);
48 // If the caller is a compiled frame and the caller of the caller
49 // is an interpreted frame then klass will be null and we need to
52 klass
= _Jv_StackTrace::GetStackWalkerCallingClass ();
57 ::java::lang::ClassLoader
*
58 gnu::classpath::VMStackWalker::getClassLoader(::java::lang::Class
*c
)
60 return c
->getClassLoaderInternal ();
63 ::java::lang::ClassLoader
*
64 gnu::classpath::VMStackWalker::getCallingClassLoader(void)
67 _Jv_StackTrace::GetStackWalkerCallingClass ()->getClassLoaderInternal ();
70 ::java::lang::ClassLoader
*
71 gnu::classpath::VMStackWalker::getCallingClassLoader(::gnu::gcj::RawData
*pc
)
73 return getCallingClass (pc
)->getClassLoaderInternal ();
76 ::java::lang::ClassLoader
*
77 gnu::classpath::VMStackWalker::firstNonNullClassLoader(void)
79 return _Jv_StackTrace::GetStackWalkerFirstNonNullLoader ();