blob: dc833bfd9090e4d94c5c3b6ff95e11b12353777a [file] [log] [blame]
Alex Light3dea2122017-10-11 15:56:48 +00001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <iostream>
18#include <pthread.h>
19#include <stdio.h>
20#include <vector>
21
22#include "android-base/logging.h"
23#include "jni.h"
24#include "scoped_local_ref.h"
25#include "scoped_primitive_array.h"
26
27#include "jvmti.h"
28
29// Test infrastructure
30#include "jvmti_helper.h"
31#include "test_env.h"
32
33namespace art {
34namespace Test1939ProxyFrames {
35
36extern "C" JNIEXPORT jobject Java_art_Test1939_GetFrameMethod(JNIEnv* env,
37 jclass,
38 jthread thr,
39 jint depth) {
40 jmethodID m = nullptr;
41 jlong loc = -1;
42 if (JvmtiErrorToException(env, jvmti_env, jvmti_env->GetFrameLocation(thr, depth, &m, &loc))) {
43 return nullptr;
44 }
45 jclass klass = nullptr;
46 if (JvmtiErrorToException(env, jvmti_env, jvmti_env->GetMethodDeclaringClass(m, &klass))) {
47 return nullptr;
48 }
49 jobject res = env->ToReflectedMethod(klass, m, false);
50 env->DeleteLocalRef(klass);
51 return res;
52}
53
54extern "C" JNIEXPORT jlong Java_art_Test1939_GetFrameLocation(JNIEnv* env,
55 jclass,
56 jthread thr,
57 jint depth) {
58 jmethodID m = nullptr;
59 jlong loc = -1;
60 JvmtiErrorToException(env, jvmti_env, jvmti_env->GetFrameLocation(thr, depth, &m, &loc));
61 return loc;
62}
63
64} // namespace Test1939ProxyFrames
65} // namespace art
66