diff options
author | gary <gary@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-09 08:38:28 +0000 |
---|---|---|
committer | gary <gary@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-09 08:38:28 +0000 |
commit | 13a5e3ff86ec543c9e033ad31c4c6706502425dc (patch) | |
tree | 5d3d1d26ab20351d70765360f80f9bc8939ddd20 /libjava/stacktrace.cc | |
parent | 96414f01336cd217caf5920893f03de27809c305 (diff) | |
download | gcc-13a5e3ff86ec543c9e033ad31c4c6706502425dc.tar.gz |
2006-08-09 Gary Benson <gbenson@redhat.com>
* include/java-stack.h (accesscontrol_trace_fn): Declare.
(GetAccessControlStack): Likewise.
(GetClassMethodStack): Remove.
* stacktrace.cc (accesscontrol_trace_fn): New method.
(GetAccessControlStack): Likewise.
(GetClassMethodStack): Remove.
* java/security/natVMAccessController.cc (getStack): Use
GetAccessControlStack.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116032 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/stacktrace.cc')
-rw-r--r-- | libjava/stacktrace.cc | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/libjava/stacktrace.cc b/libjava/stacktrace.cc index 843c5124e7e..e81294ddf69 100644 --- a/libjava/stacktrace.cc +++ b/libjava/stacktrace.cc @@ -20,6 +20,7 @@ details. */ #include <java/lang/Class.h> #include <java/lang/Long.h> +#include <java/security/AccessController.h> #include <java/util/ArrayList.h> #include <java/util/IdentityHashMap.h> #include <gnu/java/lang/MainThread.h> @@ -535,16 +536,43 @@ _Jv_StackTrace::GetFirstNonSystemClassLoader () return NULL; } +_Unwind_Reason_Code +_Jv_StackTrace::accesscontrol_trace_fn (_Jv_UnwindState *state) +{ + _Jv_StackFrame *frame = &state->frames[state->pos]; + FillInFrameInfo (frame); + + bool *stopping = (bool *) state->trace_data; + if (*stopping) + return _URC_NORMAL_STOP; + + if (frame->klass == &::java::security::AccessController::class$ + && frame->meth + && strcmp (frame->meth->name->chars(), "doPrivileged") == 0) + *stopping = true; + + return _URC_NO_REASON; +} + JArray<jobjectArray> * -_Jv_StackTrace::GetClassMethodStack (_Jv_StackTrace *trace) +_Jv_StackTrace::GetAccessControlStack (void) { - jint length = 0; + int trace_size = 100; + _Jv_StackFrame frames[trace_size]; + _Jv_UnwindState state (trace_size); + state.frames = (_Jv_StackFrame *) &frames; + state.trace_function = accesscontrol_trace_fn; + bool stopping = false; + state.trace_data = (void *) &stopping; UpdateNCodeMap(); - for (int i = 0; i < trace->length; i++) + _Unwind_Backtrace (UnwindTraceFn, &state); + + jint length = 0; + + for (int i = 0; i < state.pos; i++) { - _Jv_StackFrame *frame = &trace->frames[i]; - FillInFrameInfo (frame); + _Jv_StackFrame *frame = &state.frames[i]; if (frame->klass && frame->meth) length++; @@ -560,9 +588,9 @@ _Jv_StackTrace::GetClassMethodStack (_Jv_StackTrace *trace) jclass *c = elements (classes); jstring *m = elements (methods); - for (int i = 0, j = 0; i < trace->length; i++) + for (int i = 0, j = 0; i < state.pos; i++) { - _Jv_StackFrame *frame = &trace->frames[i]; + _Jv_StackFrame *frame = &state.frames[i]; if (!frame->klass || !frame->meth) continue; c[j] = frame->klass; |