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

Side by Side Diff: base/android/jni_android.cc

Issue 2757123002: Cleaner fall-back stack capture for --enable-heap-profiling=native. (Closed)
Patch Set: Fix OS_NACL Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/android/jni_android.h" 5 #include "base/android/jni_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/android/build_info.h" 11 #include "base/android/build_info.h"
12 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/android/jni_utils.h" 13 #include "base/android/jni_utils.h"
14 #include "base/debug/debugging_flags.h"
15 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
16 #include "base/logging.h" 15 #include "base/logging.h"
17 #include "base/threading/thread_local.h" 16 #include "base/threading/thread_local.h"
18 17
19 namespace { 18 namespace {
20 using base::android::GetClass; 19 using base::android::GetClass;
21 using base::android::MethodID; 20 using base::android::MethodID;
22 using base::android::ScopedJavaLocalRef; 21 using base::android::ScopedJavaLocalRef;
23 22
24 base::android::JniRegistrationType g_jni_registration_type = 23 base::android::JniRegistrationType g_jni_registration_type =
25 base::android::ALL_JNI_REGISTRATION; 24 base::android::ALL_JNI_REGISTRATION;
26 25
27 JavaVM* g_jvm = NULL; 26 JavaVM* g_jvm = NULL;
28 base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject>>::Leaky 27 base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject>>::Leaky
29 g_class_loader = LAZY_INSTANCE_INITIALIZER; 28 g_class_loader = LAZY_INSTANCE_INITIALIZER;
30 jmethodID g_class_loader_load_class_method_id = 0; 29 jmethodID g_class_loader_load_class_method_id = 0;
31 30
32 #if BUILDFLAG(ENABLE_PROFILING) && HAVE_TRACE_STACK_FRAME_POINTERS 31 #if HAVE_TRACE_STACK_FRAME_POINTERS()
33 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky 32 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky
34 g_stack_frame_pointer = LAZY_INSTANCE_INITIALIZER; 33 g_stack_frame_pointer = LAZY_INSTANCE_INITIALIZER;
35 #endif 34 #endif
36 35
37 } // namespace 36 } // namespace
38 37
39 namespace base { 38 namespace base {
40 namespace android { 39 namespace android {
41 40
42 JniRegistrationType GetJniRegistrationType() { 41 JniRegistrationType GetJniRegistrationType() {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 281
283 // Call ByteArrayOutputStream.toString() 282 // Call ByteArrayOutputStream.toString()
284 ScopedJavaLocalRef<jstring> exception_string( 283 ScopedJavaLocalRef<jstring> exception_string(
285 env, static_cast<jstring>( 284 env, static_cast<jstring>(
286 env->CallObjectMethod(bytearray_output_stream.obj(), 285 env->CallObjectMethod(bytearray_output_stream.obj(),
287 bytearray_output_stream_tostring))); 286 bytearray_output_stream_tostring)));
288 287
289 return ConvertJavaStringToUTF8(exception_string); 288 return ConvertJavaStringToUTF8(exception_string);
290 } 289 }
291 290
292 #if BUILDFLAG(ENABLE_PROFILING) && HAVE_TRACE_STACK_FRAME_POINTERS 291 #if HAVE_TRACE_STACK_FRAME_POINTERS()
293 292
294 JNIStackFrameSaver::JNIStackFrameSaver(void* current_fp) { 293 JNIStackFrameSaver::JNIStackFrameSaver(void* current_fp) {
295 previous_fp_ = g_stack_frame_pointer.Pointer()->Get(); 294 previous_fp_ = g_stack_frame_pointer.Pointer()->Get();
296 g_stack_frame_pointer.Pointer()->Set(current_fp); 295 g_stack_frame_pointer.Pointer()->Set(current_fp);
297 } 296 }
298 297
299 JNIStackFrameSaver::~JNIStackFrameSaver() { 298 JNIStackFrameSaver::~JNIStackFrameSaver() {
300 g_stack_frame_pointer.Pointer()->Set(previous_fp_); 299 g_stack_frame_pointer.Pointer()->Set(previous_fp_);
301 } 300 }
302 301
303 void* JNIStackFrameSaver::SavedFrame() { 302 void* JNIStackFrameSaver::SavedFrame() {
304 return g_stack_frame_pointer.Pointer()->Get(); 303 return g_stack_frame_pointer.Pointer()->Get();
305 } 304 }
306 305
307 #endif // ENABLE_PROFILING && HAVE_TRACE_STACK_FRAME_POINTERS 306 #endif // HAVE_TRACE_STACK_FRAME_POINTERS()
308 307
309 } // namespace android 308 } // namespace android
310 } // namespace base 309 } // namespace base
OLDNEW
« no previous file with comments | « base/android/jni_android.h ('k') | base/debug/stack_trace.h » ('j') | base/debug/stack_trace.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698