From 83387d63c4a37b7f3ae84666360a1d6f66d90b08 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Tue, 22 Oct 2024 16:20:47 +0000 Subject: Revert "Add VMDebug_getExecutableMethodFileOffsetsNative" Revert submission 3280271-hummingbird-art-lib Reason for revert: Broke art_standalone_compiler_tests and art_standalone_runtime_tests, and blocks presubmit. Reverted changes: /q/submissionid:3280271-hummingbird-art-lib Change-Id: I8fa82ea6306778e6ee6a1988c6403e7aa7b97808 --- runtime/native/dalvik_system_VMDebug.cc | 78 +-------------------------------- 1 file changed, 2 insertions(+), 76 deletions(-) (limited to 'runtime/native/dalvik_system_VMDebug.cc') diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc index 74b9199917..9c007f8b90 100644 --- a/runtime/native/dalvik_system_VMDebug.cc +++ b/runtime/native/dalvik_system_VMDebug.cc @@ -21,6 +21,8 @@ #include +#include "nativehelper/jni_macros.h" + #include "base/file_utils.h" #include "base/histogram-inl.h" #include "base/time_utils.h" @@ -28,8 +30,6 @@ #include "class_root-inl.h" #include "common_throws.h" #include "debugger.h" -#include "dex/class_accessor-inl.h" -#include "dex/descriptors_names.h" #include "gc/space/bump_pointer_space.h" #include "gc/space/dlmalloc_space.h" #include "gc/space/large_object_space.h" @@ -42,14 +42,10 @@ #include "mirror/array-alloc-inl.h" #include "mirror/array-inl.h" #include "mirror/class.h" -#include "mirror/executable-inl.h" #include "mirror/object_array-alloc-inl.h" #include "native_util.h" -#include "nativehelper/jni_macros.h" #include "nativehelper/scoped_local_ref.h" #include "nativehelper/scoped_utf_chars.h" -#include "nativehelper/utils.h" -#include "oat/oat_quick_method_header.h" #include "scoped_fast_native_object_access-inl.h" #include "string_array_utils.h" #include "thread-inl.h" @@ -316,72 +312,6 @@ static jlong VMDebug_countInstancesOfClass(JNIEnv* env, return count; } -static jobject VMDebug_getExecutableMethodFileOffsetsNative(JNIEnv* env, - jclass, - jobject javaMethod) { - ScopedObjectAccess soa(env); - ObjPtr m = soa.Decode(javaMethod); - if (m == nullptr) { - soa.Self()->ThrowNewExceptionF("Ljava/lang/RuntimeException;", - "Could not find mirror::Executable for supplied jobject"); - return nullptr; - } - - ObjPtr c = m->GetDeclaringClass(); - if (c == nullptr) { - soa.Self()->ThrowNewExceptionF("Ljava/lang/RuntimeException;", - "Could not find mirror::Class for supplied jobject"); - return nullptr; - } - - ArtMethod* art_method = m->GetArtMethod(); - auto oat_method_quick_code = - reinterpret_cast(art_method->GetOatMethodQuickCode(kRuntimePointerSize)); - - if (oat_method_quick_code == nullptr) { - LOG(ERROR) << "No OatMethodQuickCode for method " << art_method->PrettyMethod(); - return nullptr; - } - - const OatDexFile* oat_dex_file = c->GetDexFile().GetOatDexFile(); - if (oat_dex_file == nullptr) { - soa.Self()->ThrowNewExceptionF("Ljava/lang/RuntimeException;", "Could not find oat_dex_file"); - return nullptr; - } - - const OatFile* oat_file = oat_dex_file->GetOatFile(); - if (oat_file == nullptr) { - soa.Self()->ThrowNewExceptionF("Ljava/lang/RuntimeException;", "Could not find oat_file"); - return nullptr; - } - - std::string error_msg; - const uint8_t* elf_begin = oat_file->ComputeElfBegin(&error_msg); - if (elf_begin == nullptr) { - soa.Self()->ThrowNewExceptionF( - "Ljava/lang/RuntimeException;", "Could not find elf_begin: %s", error_msg.c_str()); - return nullptr; - } - - size_t adjusted_offset = oat_method_quick_code - elf_begin; - - ScopedLocalRef odex_path = CREATE_UTF_OR_RETURN(env, oat_file->GetLocation()); - auto odex_offset = reinterpret_cast64(elf_begin); - auto method_offset = static_cast(adjusted_offset); - - ScopedLocalRef clazz(env, - env->FindClass("dalvik/system/VMDebug$ExecutableMethodFileOffsets")); - if (clazz == nullptr) { - soa.Self()->ThrowNewExceptionF( - "Ljava/lang/RuntimeException;", - "Could not find dalvik/system/VMDebug$ExecutableMethodFileOffsets"); - return nullptr; - } - - jmethodID constructor_id = env->GetMethodID(clazz.get(), "", "(Ljava/lang/String;JJ)V"); - return env->NewObject(clazz.get(), constructor_id, odex_path.get(), odex_offset, method_offset); -} - static jlongArray VMDebug_countInstancesOfClasses(JNIEnv* env, jclass, jobjectArray javaClasses, @@ -708,10 +638,6 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(VMDebug, stopLowOverheadTraceImpl, "()V"), NATIVE_METHOD(VMDebug, dumpLowOverheadTraceImpl, "(Ljava/lang/String;)V"), NATIVE_METHOD(VMDebug, dumpLowOverheadTraceFdImpl, "(I)V"), - NATIVE_METHOD( - VMDebug, - getExecutableMethodFileOffsetsNative, - "(Ljava/lang/reflect/Method;)Ldalvik/system/VMDebug$ExecutableMethodFileOffsets;"), }; void register_dalvik_system_VMDebug(JNIEnv* env) { -- cgit v1.2.3-59-g8ed1b