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

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

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
« no previous file with comments | « no previous file | base/android/jni_android.cc » ('j') | base/debug/stack_trace.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef BASE_ANDROID_JNI_ANDROID_H_ 5 #ifndef BASE_ANDROID_JNI_ANDROID_H_
6 #define BASE_ANDROID_JNI_ANDROID_H_ 6 #define BASE_ANDROID_JNI_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
14 #include "base/atomicops.h" 14 #include "base/atomicops.h"
15 #include "base/base_export.h" 15 #include "base/base_export.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/debug/stack_trace.h" 17 #include "base/debug/stack_trace.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 19
20 #if HAVE_TRACE_STACK_FRAME_POINTERS 20 #if HAVE_TRACE_STACK_FRAME_POINTERS()
21 21
22 // When profiling is enabled (enable_profiling=true) this macro is added to 22 // When profiling is enabled (enable_profiling=true) this macro is added to
23 // all generated JNI stubs so that it becomes the last thing that runs before 23 // all generated JNI stubs so that it becomes the last thing that runs before
24 // control goes into Java. 24 // control goes into Java.
25 // 25 //
26 // This macro saves stack frame pointer of the current function. Saved value 26 // This macro saves stack frame pointer of the current function. Saved value
27 // used later by JNI_LINK_SAVED_FRAME_POINTER. 27 // used later by JNI_LINK_SAVED_FRAME_POINTER.
28 #define JNI_SAVE_FRAME_POINTER \ 28 #define JNI_SAVE_FRAME_POINTER \
29 base::android::JNIStackFrameSaver jni_frame_saver(__builtin_frame_address(0)) 29 base::android::JNIStackFrameSaver jni_frame_saver(__builtin_frame_address(0))
30 30
31 // When profiling is enabled (enable_profiling=true) this macro is added to 31 // When profiling is enabled (enable_profiling=true) this macro is added to
32 // all generated JNI callbacks so that it becomes the first thing that runs 32 // all generated JNI callbacks so that it becomes the first thing that runs
33 // after control returns from Java. 33 // after control returns from Java.
34 // 34 //
35 // This macro links stack frame of the current function to the stack frame 35 // This macro links stack frame of the current function to the stack frame
36 // saved by JNI_SAVE_FRAME_POINTER, allowing frame-based unwinding 36 // saved by JNI_SAVE_FRAME_POINTER, allowing frame-based unwinding
37 // (used by the heap profiler) to produce complete traces. 37 // (used by the heap profiler) to produce complete traces.
38 #define JNI_LINK_SAVED_FRAME_POINTER \ 38 #define JNI_LINK_SAVED_FRAME_POINTER \
39 base::debug::ScopedStackFrameLinker jni_frame_linker( \ 39 base::debug::ScopedStackFrameLinker jni_frame_linker( \
40 __builtin_frame_address(0), \ 40 __builtin_frame_address(0), \
41 base::android::JNIStackFrameSaver::SavedFrame()) 41 base::android::JNIStackFrameSaver::SavedFrame())
42 42
43 #else 43 #else
44 44
45 // Frame-based stack unwinding is not supported, do nothing. 45 // Frame-based stack unwinding is not supported, do nothing.
46 #define JNI_SAVE_FRAME_POINTER 46 #define JNI_SAVE_FRAME_POINTER
47 #define JNI_LINK_SAVED_FRAME_POINTER 47 #define JNI_LINK_SAVED_FRAME_POINTER
48 48
49 #endif // HAVE_TRACE_STACK_FRAME_POINTERS 49 #endif // HAVE_TRACE_STACK_FRAME_POINTERS()
50 50
51 namespace base { 51 namespace base {
52 namespace android { 52 namespace android {
53 53
54 // Used to mark symbols to be exported in a shared library's symbol table. 54 // Used to mark symbols to be exported in a shared library's symbol table.
55 #define JNI_EXPORT __attribute__ ((visibility("default"))) 55 #define JNI_EXPORT __attribute__ ((visibility("default")))
56 56
57 // The level of JNI registration required for the current process. 57 // The level of JNI registration required for the current process.
58 enum JniRegistrationType { 58 enum JniRegistrationType {
59 // Register all native methods. 59 // Register all native methods.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // and returns true. 159 // and returns true.
160 BASE_EXPORT bool ClearException(JNIEnv* env); 160 BASE_EXPORT bool ClearException(JNIEnv* env);
161 161
162 // This function will call CHECK() macro if there's any pending exception. 162 // This function will call CHECK() macro if there's any pending exception.
163 BASE_EXPORT void CheckException(JNIEnv* env); 163 BASE_EXPORT void CheckException(JNIEnv* env);
164 164
165 // This returns a string representation of the java stack trace. 165 // This returns a string representation of the java stack trace.
166 BASE_EXPORT std::string GetJavaExceptionInfo(JNIEnv* env, 166 BASE_EXPORT std::string GetJavaExceptionInfo(JNIEnv* env,
167 jthrowable java_throwable); 167 jthrowable java_throwable);
168 168
169 #if HAVE_TRACE_STACK_FRAME_POINTERS 169 #if HAVE_TRACE_STACK_FRAME_POINTERS()
170 170
171 // Saves caller's PC and stack frame in a thread-local variable. 171 // Saves caller's PC and stack frame in a thread-local variable.
172 // Implemented only when profiling is enabled (enable_profiling=true). 172 // Implemented only when profiling is enabled (enable_profiling=true).
173 class BASE_EXPORT JNIStackFrameSaver { 173 class BASE_EXPORT JNIStackFrameSaver {
174 public: 174 public:
175 JNIStackFrameSaver(void* current_fp); 175 JNIStackFrameSaver(void* current_fp);
176 ~JNIStackFrameSaver(); 176 ~JNIStackFrameSaver();
177 static void* SavedFrame(); 177 static void* SavedFrame();
178 178
179 private: 179 private:
180 void* previous_fp_; 180 void* previous_fp_;
181 181
182 DISALLOW_COPY_AND_ASSIGN(JNIStackFrameSaver); 182 DISALLOW_COPY_AND_ASSIGN(JNIStackFrameSaver);
183 }; 183 };
184 184
185 #endif // HAVE_TRACE_STACK_FRAME_POINTERS 185 #endif // HAVE_TRACE_STACK_FRAME_POINTERS()
186 186
187 } // namespace android 187 } // namespace android
188 } // namespace base 188 } // namespace base
189 189
190 #endif // BASE_ANDROID_JNI_ANDROID_H_ 190 #endif // BASE_ANDROID_JNI_ANDROID_H_
OLDNEW
« no previous file with comments | « no previous file | base/android/jni_android.cc » ('j') | base/debug/stack_trace.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698