Merge "Binder: Add more logging on Error" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ab934ae8e6
@@ -29,6 +29,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <android-base/stringprintf.h>
|
||||||
#include <binder/IInterface.h>
|
#include <binder/IInterface.h>
|
||||||
#include <binder/IServiceManager.h>
|
#include <binder/IServiceManager.h>
|
||||||
#include <binder/IPCThreadState.h>
|
#include <binder/IPCThreadState.h>
|
||||||
@@ -194,10 +195,34 @@ static void report_exception(JNIEnv* env, jthrowable excep, const char* msg)
|
|||||||
/*
|
/*
|
||||||
* It's an Error: Reraise the exception and ask the runtime to abort.
|
* It's an Error: Reraise the exception and ask the runtime to abort.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Try to get the exception string. Sometimes logcat isn't available,
|
||||||
|
// so try to add it to the abort message.
|
||||||
|
std::string exc_msg = "(Unknown exception message)";
|
||||||
|
{
|
||||||
|
ScopedLocalRef<jclass> exc_class(env, env->GetObjectClass(excep));
|
||||||
|
jmethodID method_id = env->GetMethodID(exc_class.get(),
|
||||||
|
"toString",
|
||||||
|
"()Ljava/lang/String;");
|
||||||
|
ScopedLocalRef<jstring> jstr(
|
||||||
|
env,
|
||||||
|
reinterpret_cast<jstring>(
|
||||||
|
env->CallObjectMethod(excep, method_id)));
|
||||||
|
env->ExceptionClear(); // Just for good measure.
|
||||||
|
if (jstr.get() != nullptr) {
|
||||||
|
ScopedUtfChars jstr_utf(env, jstr.get());
|
||||||
|
exc_msg = jstr_utf.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
env->Throw(excep);
|
env->Throw(excep);
|
||||||
ALOGE("java.lang.Error thrown during binder transaction (stack trace follows) : ");
|
ALOGE("java.lang.Error thrown during binder transaction (stack trace follows) : ");
|
||||||
env->ExceptionDescribe();
|
env->ExceptionDescribe();
|
||||||
env->FatalError("java.lang.Error thrown during binder transaction.");
|
|
||||||
|
std::string error_msg = base::StringPrintf(
|
||||||
|
"java.lang.Error thrown during binder transaction: %s",
|
||||||
|
exc_msg.c_str());
|
||||||
|
env->FatalError(error_msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
|
|||||||
Reference in New Issue
Block a user