Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(694)

Unified Diff: base/android/jni_android.cc

Issue 2361353002: Link stack frames of JNI stubs to JNI callbacks. (Closed)
Patch Set: git cl format Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/jni_android.h ('k') | base/android/jni_generator/golden_sample_for_tests_jni.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_android.cc
diff --git a/base/android/jni_android.cc b/base/android/jni_android.cc
index c342218bf4563f3a67048be9eba22b21127ce265..02e264c05703494444a23bae5fabc8875e7ec1f2 100644
--- a/base/android/jni_android.cc
+++ b/base/android/jni_android.cc
@@ -11,8 +11,10 @@
#include "base/android/build_info.h"
#include "base/android/jni_string.h"
#include "base/android/jni_utils.h"
+#include "base/debug/debugging_flags.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/threading/thread_local.h"
namespace {
using base::android::GetClass;
@@ -26,6 +28,11 @@ base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >::Leaky
g_class_loader = LAZY_INSTANCE_INITIALIZER;
jmethodID g_class_loader_load_class_method_id = 0;
+#if BUILDFLAG(ENABLE_PROFILING) && HAVE_TRACE_STACK_FRAME_POINTERS
+base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky
+ g_stack_frame_pointer = LAZY_INSTANCE_INITIALIZER;
+#endif
+
} // namespace
namespace base {
@@ -282,6 +289,22 @@ std::string GetJavaExceptionInfo(JNIEnv* env, jthrowable java_throwable) {
return ConvertJavaStringToUTF8(exception_string);
}
+#if BUILDFLAG(ENABLE_PROFILING) && HAVE_TRACE_STACK_FRAME_POINTERS
+
+JNIStackFrameSaver::JNIStackFrameSaver(void* current_fp) {
+ previous_fp_ = g_stack_frame_pointer.Pointer()->Get();
+ g_stack_frame_pointer.Pointer()->Set(current_fp);
+}
+
+JNIStackFrameSaver::~JNIStackFrameSaver() {
+ g_stack_frame_pointer.Pointer()->Set(previous_fp_);
+}
+
+void* JNIStackFrameSaver::SavedFrame() {
+ return g_stack_frame_pointer.Pointer()->Get();
+}
+
+#endif // ENABLE_PROFILING && HAVE_TRACE_STACK_FRAME_POINTERS
} // namespace android
} // namespace base
« no previous file with comments | « base/android/jni_android.h ('k') | base/android/jni_generator/golden_sample_for_tests_jni.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698