aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2007-02-10 14:22:54 +0000
committerAndrew Haley <aph@redhat.com>2007-02-10 14:22:54 +0000
commit5c94d22c73aab025c8277a550590b16ffca9a174 (patch)
treeb46076778a1fa06db86e1bab8e622bbd3cf616d2
parentae357b3ae17df5d5e96463b0fdca7067d0d70833 (diff)
2007-02-10 Andrew Haley <aph@redhat.com>
PR java/30742 * gnu/classpath/natVMStackWalker.cc (GET_CALLING_CLASS): New. (getCallingClass): Call GET_CALLING_CLASS. (getCallingClassLoader): Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@121798 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog7
-rw-r--r--libjava/gnu/classpath/natVMStackWalker.cc50
2 files changed, 36 insertions, 21 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 544137479bb..1c39b14a916 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,10 @@
+2007-02-10 Andrew Haley <aph@redhat.com>
+
+ PR java/30742
+ * gnu/classpath/natVMStackWalker.cc (GET_CALLING_CLASS): New.
+ (getCallingClass): Call GET_CALLING_CLASS.
+ (getCallingClassLoader): Likewise.
+
2007-02-10 Mohan Embar <gnustuff@thisiscool.com>
* configure: Rebuilt.
diff --git a/libjava/gnu/classpath/natVMStackWalker.cc b/libjava/gnu/classpath/natVMStackWalker.cc
index 621a95b4cc5..f7eb8832f4c 100644
--- a/libjava/gnu/classpath/natVMStackWalker.cc
+++ b/libjava/gnu/classpath/natVMStackWalker.cc
@@ -1,6 +1,6 @@
// natVMStackWalker.cc
-/* Copyright (C) 2006 Free Software Foundation
+/* Copyright (C) 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -19,6 +19,32 @@ details. */
#include <java/lang/ClassLoader.h>
#include <java/lang/Class.h>
+// Return the class of the method that contains PC.
+// This is a macro not a function, since defining it as one would
+// introduce an extra frame on the stack. */
+#define GET_CALLING_CLASS(PC) \
+({ \
+ void *f = _Unwind_FindEnclosingFunction (PC); \
+ \
+ /* FIXME: it might well be a good idea to cache pc values here in \
+ order to avoid repeated invocations of \
+ _Unwind_FindEnclosingFunction, which is quite expensive. On the \
+ other hand, which not simply write a caching version of \
+ _Unwind_FindEnclosingFunction itself? That would probably be \
+ worthwhile. */ \
+ \
+ _Jv_StackTrace::UpdateNCodeMap (); \
+ jclass klass = (jclass) _Jv_StackTrace::ncodeMap->get ((jobject) f); \
+ \
+ /* If the caller is a compiled frame and the caller of the caller is \
+ an interpreted frame then klass will be null and we need to \
+ unwind the stack. */ \
+ if (!klass) \
+ klass = _Jv_StackTrace::GetStackWalkerCallingClass (); \
+ \
+ klass; \
+ })
+
JArray<jclass> *
gnu::classpath::VMStackWalker::getClassContext(void)
{
@@ -40,25 +66,7 @@ jclass
gnu::classpath::VMStackWalker::getCallingClass(::gnu::gcj::RawData *pc)
{
_Jv_InitClass (&::gnu::classpath::VMStackWalker::class$);
- void *f = _Unwind_FindEnclosingFunction (pc);
-
- // FIXME: it might well be a good idea to cache pc values here in
- // order to avoid repeated invocations of
- // _Unwind_FindEnclosingFunction, which is quite expensive. On the
- // other hand, which not simply write a caching version of
- // _Unwind_FindEnclosingFunction itself? That would probably be
- // worthwhile.
-
- _Jv_StackTrace::UpdateNCodeMap ();
- jclass klass = (jclass) _Jv_StackTrace::ncodeMap->get ((jobject) f);
-
- // If the caller is a compiled frame and the caller of the caller
- // is an interpreted frame then klass will be null and we need to
- // unwind the stack.
- if (klass == NULL)
- klass = _Jv_StackTrace::GetStackWalkerCallingClass ();
-
- return klass;
+ return GET_CALLING_CLASS(pc);
}
::java::lang::ClassLoader *
@@ -80,7 +88,7 @@ gnu::classpath::VMStackWalker::getCallingClassLoader(void)
gnu::classpath::VMStackWalker::getCallingClassLoader(::gnu::gcj::RawData *pc)
{
_Jv_InitClass (&::gnu::classpath::VMStackWalker::class$);
- return getCallingClass (pc)->getClassLoaderInternal ();
+ return GET_CALLING_CLASS(pc)->getClassLoaderInternal ();
}
::java::lang::ClassLoader *