summaryrefslogtreecommitdiffstats
path: root/libjava/gnu/gcj/runtime/natStackTrace.cc
diff options
context:
space:
mode:
authoraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-14 15:21:13 +0000
committeraph <aph@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-14 15:21:13 +0000
commit8caa0aa0a0b4071cf4d9dd58838556e8a594ba0f (patch)
treef9e1b10a90a60b5918f10b2519f9520b57f64915 /libjava/gnu/gcj/runtime/natStackTrace.cc
parent1624d332ede20a2e626441ef12a674154501cb36 (diff)
downloadppe42-gcc-8caa0aa0a0b4071cf4d9dd58838556e8a594ba0f.tar.gz
ppe42-gcc-8caa0aa0a0b4071cf4d9dd58838556e8a594ba0f.zip
2004-10-13 Andrew Haley <aph@redhat.com>
* interpret.cc (_Jv_InterpMethod::run): Initialize _Jv_StartOfInterpreter. (_Jv_StartOfInterpreter, _Jv_EndOfInterpreter): Functions removed. (_Jv_StartOfInterpreter, _Jv_EndOfInterpreter): New variables. * gnu/gcj/runtime/natStackTrace.cc (fillInStackTrace): Use _Unwind_FindEnclosingFunction to discover whether PC is within the interpreter. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89037 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu/gcj/runtime/natStackTrace.cc')
-rw-r--r--libjava/gnu/gcj/runtime/natStackTrace.cc48
1 files changed, 39 insertions, 9 deletions
diff --git a/libjava/gnu/gcj/runtime/natStackTrace.cc b/libjava/gnu/gcj/runtime/natStackTrace.cc
index 5e5aed87e5c..fbe403a17ef 100644
--- a/libjava/gnu/gcj/runtime/natStackTrace.cc
+++ b/libjava/gnu/gcj/runtime/natStackTrace.cc
@@ -45,6 +45,11 @@ details. */
#include <unwind.h>
+#ifdef INTERPRETER
+extern "C" void *_Unwind_FindEnclosingFunction (void *pc)
+ __attribute__((pure));
+#endif // INTERPRETER
+
// Fill in this stack trace with MAXLEN elements starting at offset.
void
gnu::gcj::runtime::StackTrace::fillInStackTrace (jint maxlen, jint offset)
@@ -58,9 +63,9 @@ gnu::gcj::runtime::StackTrace::fillInStackTrace (jint maxlen, jint offset)
if (len > 0)
{
#ifdef INTERPRETER
- extern void _Jv_StartOfInterpreter (void);
- extern void _Jv_EndOfInterpreter (void);
-
+ extern void *const _Jv_StartOfInterpreter;
+ extern void * _Jv_EndOfInterpreter;
+
java::lang::Thread *thread = java::lang::Thread::currentThread();
_Jv_MethodChain *interp_frame
= (thread ? reinterpret_cast<_Jv_MethodChain *> (thread->interp_frame)
@@ -70,16 +75,41 @@ gnu::gcj::runtime::StackTrace::fillInStackTrace (jint maxlen, jint offset)
frame = (_Jv_frame_info *) _Jv_Malloc (len * sizeof (_Jv_frame_info));
for (int n = 0; n < len; n++)
{
- frame[n].addr = p[n];
+ void *pc = p[n];
+ frame[n].addr = pc;
+
#ifdef INTERPRETER
- if (p[n] >= &_Jv_StartOfInterpreter && p[n] <= &_Jv_EndOfInterpreter)
+ frame[n].interp = 0;
+
+ // If _Jv_StartOfInterpreter is NULL either we've never
+ // entered the intepreter or _Unwind_FindEnclosingFunction
+ // is broken.
+ if (__builtin_expect (_Jv_StartOfInterpreter != NULL, false))
{
- frame[n].interp = (void *) interp_frame->self;
- interp_frame = interp_frame->next;
+ // _Jv_StartOfInterpreter marks the very first
+ // instruction in the interpreter, but
+ // _Jv_EndOfInterpreter is an upper bound. If PC is
+ // less than _Jv_EndOfInterpreter it might be in the
+ // interpreter: we call _Unwind_FindEnclosingFunction to
+ // find out.
+ if ((_Jv_EndOfInterpreter == NULL || pc < _Jv_EndOfInterpreter)
+ && (_Unwind_FindEnclosingFunction (pc)
+ == _Jv_StartOfInterpreter))
+ {
+ frame[n].interp = (void *) interp_frame->self;
+ interp_frame = interp_frame->next;
+ }
+ else
+ {
+ // We've found an address that we know is not within
+ // the interpreter. We use that to refine our upper
+ // bound on where the interpreter ends.
+ if (_Jv_EndOfInterpreter == NULL || pc < _Jv_EndOfInterpreter)
+ _Jv_EndOfInterpreter = pc;
+ }
}
- else
- frame[n].interp = 0;
#endif // INTERPRETER
+
}
}
else
OpenPOWER on IntegriCloud