Interpreter entries and instrumentation as a listener.
Make the instrumentation responsible for whether we want method entry/exit
stubs, and allow it to use interpreter entry stubs when instruction by
instruction instrumentation is required. Improve deoptimization so more JDWP
test cases are passing.
Refactor exception debug posting, in particular improve reporting in the
interpreter. Improve class linker exception throwing so that broken dex files
are more likely to be reported. Fixes the performance issue Bug: 8410519.
Fix some error reporting lock level errors for the large object space. Make
fast object verification faster.
Add some debug mode robustness to finding dex PCs in GC maps.
Add printf attributes to JniAbortF and fix errors.
Expand run-test 044 to test return behaviors and fix issues with not throwing
appropriate exceptions for proxies.
Ensure causes are reported with a class linker NoClassDefFoundError and JNI
NoSuchFieldError.
Remove unused debugMe and updateDebuggerFromCode.
There's a minor sizing tweak to the arg array builder, and an extra reference
array check in the interpreter.
Some clean-up of trace code.
Fix reg type cache destructor if it is called after the reg type cache is
shutdown (as is the case in oatdump).
Change-Id: I6519c7b35df77f978d011999354c864f4918e8ce
diff --git a/src/check_jni.cc b/src/check_jni.cc
index 57ce432..30d5099 100644
--- a/src/check_jni.cc
+++ b/src/check_jni.cc
@@ -44,7 +44,7 @@
static void JniAbort(const char* jni_function_name, const char* msg) {
Thread* self = Thread::Current();
ScopedObjectAccess soa(self);
- mirror::AbstractMethod* current_method = self->GetCurrentMethod();
+ mirror::AbstractMethod* current_method = self->GetCurrentMethod(NULL);
std::ostringstream os;
os << "JNI DETECTED ERROR IN APPLICATION: " << msg;
@@ -401,8 +401,7 @@
*
* Use the kFlag_NullableUtf flag where 'u' field(s) are nullable.
*/
- void Check(bool entry, const char* fmt0, ...)
- SHARED_LOCKS_REQUIRED (Locks::mutator_lock_) {
+ void Check(bool entry, const char* fmt0, ...) SHARED_LOCKS_REQUIRED (Locks::mutator_lock_) {
va_list ap;
const mirror::AbstractMethod* traceMethod = NULL;
@@ -411,7 +410,7 @@
// use DetachCurrentThread or GetEnv on a thread that's not yet attached.
Thread* self = Thread::Current();
if ((flags_ & kFlag_Invocation) == 0 || self != NULL) {
- traceMethod = self->GetCurrentMethod();
+ traceMethod = self->GetCurrentMethod(NULL);
}
}
@@ -812,14 +811,19 @@
// Verify that, if an exception has been raised, the native code doesn't
// make any JNI calls other than the Exception* methods.
if ((flags & kFlag_ExcepOkay) == 0 && self->IsExceptionPending()) {
- std::string type(PrettyTypeOf(self->GetException()));
+ ThrowLocation throw_location;
+ mirror::Throwable* exception = self->GetException(&throw_location);
+ std::string type(PrettyTypeOf(exception));
// TODO: write native code that doesn't require allocation for dumping an exception.
// TODO: do we care any more? art always dumps pending exceptions on aborting threads.
- if (type != "java.lang.OutOfMemoryError") {
- JniAbortF(function_name_, "JNI %s called with pending exception: %s",
- function_name_, type.c_str(), jniGetStackTrace(soa_.Env()).c_str());
+ bool with_stack_trace = (type != "java.lang.OutOfMemoryError");
+ if (with_stack_trace) {
+ JniAbortF(function_name_, "JNI %s called with pending exception '%s' thrown in %s\n%s",
+ function_name_, type.c_str(), throw_location.Dump().c_str(),
+ jniGetStackTrace(soa_.Env()).c_str());
} else {
- JniAbortF(function_name_, "JNI %s called with %s pending", function_name_, type.c_str());
+ JniAbortF(function_name_, "JNI %s called with pending exception '%s' thrown in %s",
+ function_name_, type.c_str(), throw_location.Dump().c_str());
}
return;
}
@@ -1772,7 +1776,7 @@
JniAbortF(__FUNCTION__, "non-nullable address is NULL");
}
if (capacity <= 0) {
- JniAbortF(__FUNCTION__, "capacity must be greater than 0: %d", capacity);
+ JniAbortF(__FUNCTION__, "capacity must be greater than 0: %lld", capacity);
}
return CHECK_JNI_EXIT("L", baseEnv(env)->NewDirectByteBuffer(env, address, capacity));
}