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 | |
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')
-rw-r--r-- | libjava/ChangeLog | 11 | ||||
-rw-r--r-- | libjava/include/java-stack.h | 3 | ||||
-rw-r--r-- | libjava/java/security/natVMAccessController.cc | 3 | ||||
-rw-r--r-- | libjava/stacktrace.cc | 42 |
4 files changed, 49 insertions, 10 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 7176d1b2102..27061ae8b6d 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,14 @@ +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. + 2006-08-07 Gary Benson <gbenson@redhat.com> PR libgcj/28340: diff --git a/libjava/include/java-stack.h b/libjava/include/java-stack.h index a1b0db670ea..29e4285fa02 100644 --- a/libjava/include/java-stack.h +++ b/libjava/include/java-stack.h @@ -114,6 +114,7 @@ private: static _Unwind_Reason_Code calling_class_trace_fn (_Jv_UnwindState *state); static _Unwind_Reason_Code non_system_trace_fn (_Jv_UnwindState *state); + static _Unwind_Reason_Code accesscontrol_trace_fn (_Jv_UnwindState *state); public: static _Jv_StackTrace *GetStackTrace (void); @@ -124,7 +125,7 @@ public: static void GetCallerInfo (jclass checkClass, jclass *, _Jv_Method **); static JArray<jclass> *GetClassContext (jclass checkClass); static ClassLoader *GetFirstNonSystemClassLoader (void); - static JArray<jobjectArray> *GetClassMethodStack (_Jv_StackTrace *trace); + static JArray<jobjectArray> *GetAccessControlStack (); }; diff --git a/libjava/java/security/natVMAccessController.cc b/libjava/java/security/natVMAccessController.cc index e56ccbd9135..42cfc9cfe68 100644 --- a/libjava/java/security/natVMAccessController.cc +++ b/libjava/java/security/natVMAccessController.cc @@ -19,6 +19,5 @@ details. */ JArray<jobjectArray> * java::security::VMAccessController::getStack () { - _Jv_StackTrace *trace = _Jv_StackTrace::GetStackTrace (); - return _Jv_StackTrace::GetClassMethodStack (trace); + return _Jv_StackTrace::GetAccessControlStack (); } 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; |