11240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes/* 21240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * Copyright (C) 2008 The Android Open Source Project 31240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * 41240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 51240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * you may not use this file except in compliance with the License. 61240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * You may obtain a copy of the License at 71240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * 81240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 91240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * 101240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * Unless required by applicable law or agreed to in writing, software 111240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 121240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * See the License for the specific language governing permissions and 141240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes * limitations under the License. 151240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes */ 161240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 171240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes#include "jni_internal.h" 1800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers#include "scoped_thread_state_change.h" 19aaa208006d7c8cc0f381c4aa9b525be24066c495Ian Rogers#include "thread.h" 201240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 211240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughesnamespace art { 221240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 230512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic jobject Throwable_nativeFillInStackTrace(JNIEnv* env, jclass) { 2400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers ScopedObjectAccess soa(env); 2500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers return soa.Self()->CreateInternalStackTrace(soa); 261240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 271240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 280512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic jobjectArray Throwable_nativeGetStackTrace(JNIEnv* env, jclass, jobject javaStackState) { 2932f8569b58142eb93f6fa88c2cbfc4c619a95ee8Jesse Wilson if (javaStackState == NULL) { 3032f8569b58142eb93f6fa88c2cbfc4c619a95ee8Jesse Wilson return NULL; 3132f8569b58142eb93f6fa88c2cbfc4c619a95ee8Jesse Wilson } 3201158d7a57c8321370667a6045220237d16e0da8Elliott Hughes return Thread::InternalStackTraceToStackTraceElementArray(env, javaStackState); 331240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 341240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 350512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic JNINativeMethod gMethods[] = { 361240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes NATIVE_METHOD(Throwable, nativeFillInStackTrace, "()Ljava/lang/Object;"), 371240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes NATIVE_METHOD(Throwable, nativeGetStackTrace, "(Ljava/lang/Object;)[Ljava/lang/StackTraceElement;"), 381240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes}; 391240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 401240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughesvoid register_java_lang_Throwable(JNIEnv* env) { 41eac766769e3114a078c188ea26776a81f0edb3cfElliott Hughes REGISTER_NATIVE_METHODS("java/lang/Throwable"); 421240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 431240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 441240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} // namespace art 45