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 17277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe#include "java_lang_Throwable.h" 18277ccbd200ea43590dfc06a93ae184a765327ad0Andreas Gampe 19a14100ccf51cc63a5c472188d1e2d337627e49ebAndreas Gampe#include "nativehelper/jni_macros.h" 20a14100ccf51cc63a5c472188d1e2d337627e49ebAndreas Gampe 211240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes#include "jni_internal.h" 2287583b3de6e811e141f8c97c1f796eb516e8a751Andreas Gampe#include "native_util.h" 230795f23920ee9aabf28e45c63cd592dcccf00216Mathieu Chartier#include "scoped_fast_native_object_access-inl.h" 24aaa208006d7c8cc0f381c4aa9b525be24066c495Ian Rogers#include "thread.h" 251240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 261240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughesnamespace art { 271240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 280512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic jobject Throwable_nativeFillInStackTrace(JNIEnv* env, jclass) { 2953b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers ScopedFastNativeObjectAccess soa(env); 30ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz return soa.Self()->CreateInternalStackTrace<false>(soa); 311240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 321240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 330512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic jobjectArray Throwable_nativeGetStackTrace(JNIEnv* env, jclass, jobject javaStackState) { 3453b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers if (javaStackState == nullptr) { 3553b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers return nullptr; 3632f8569b58142eb93f6fa88c2cbfc4c619a95ee8Jesse Wilson } 3753b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers ScopedFastNativeObjectAccess soa(env); 3853b8b09fc80329539585dcf43657bc5f4ecefdffIan Rogers return Thread::InternalStackTraceToStackTraceElementArray(soa, javaStackState); 391240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 401240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 410512f02dd6623c0870c11fbf3274d7462f732136Elliott Hughesstatic JNINativeMethod gMethods[] = { 423b6f440dbd066f03a737da6d292074f47b3fbc29Igor Murashkin FAST_NATIVE_METHOD(Throwable, nativeFillInStackTrace, "()Ljava/lang/Object;"), 433b6f440dbd066f03a737da6d292074f47b3fbc29Igor Murashkin FAST_NATIVE_METHOD(Throwable, nativeGetStackTrace, "(Ljava/lang/Object;)[Ljava/lang/StackTraceElement;"), 441240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes}; 451240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 461240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughesvoid register_java_lang_Throwable(JNIEnv* env) { 47eac766769e3114a078c188ea26776a81f0edb3cfElliott Hughes REGISTER_NATIVE_METHODS("java/lang/Throwable"); 481240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} 491240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes 501240dade91d6c4bbf4e367ca608fcdc15348da45Elliott Hughes} // namespace art 51