|
1 /* |
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 |
|
26 #ifndef SHARE_VM_PRIMS_STACKWALK_HPP |
|
27 #define SHARE_VM_PRIMS_STACKWALK_HPP |
|
28 |
|
29 #include "oops/oop.hpp" |
|
30 #include "runtime/vframe.hpp" |
|
31 |
|
32 class StackWalkAnchor : public StackObj { |
|
33 private: |
|
34 enum { |
|
35 magic_pos = 0 |
|
36 }; |
|
37 |
|
38 JavaThread* _thread; |
|
39 vframeStream _vfst; |
|
40 jlong _anchor; |
|
41 public: |
|
42 StackWalkAnchor(JavaThread* thread) |
|
43 : _thread(thread), _vfst(thread), _anchor(0L) {} |
|
44 |
|
45 vframeStream& vframe_stream() { return _vfst; } |
|
46 JavaThread* thread() { return _thread; } |
|
47 |
|
48 void setup_magic_on_entry(objArrayHandle classes_array); |
|
49 bool check_magic(objArrayHandle classes_array); |
|
50 bool cleanup_magic_on_exit(objArrayHandle classes_array); |
|
51 |
|
52 bool is_valid_in(Thread* thread, objArrayHandle classes_array) { |
|
53 return (_thread == thread && check_magic(classes_array)); |
|
54 } |
|
55 |
|
56 jlong address_value() { |
|
57 return (jlong) castable_address(this); |
|
58 } |
|
59 |
|
60 static StackWalkAnchor* from_current(JavaThread* thread, jlong anchor, objArrayHandle frames_array); |
|
61 }; |
|
62 |
|
63 class StackWalk : public AllStatic { |
|
64 private: |
|
65 static int fill_in_frames(jlong mode, vframeStream& vfst, |
|
66 int max_nframes, int start_index, |
|
67 objArrayHandle classes_array, |
|
68 objArrayHandle frames_array, |
|
69 int& end_index, TRAPS); |
|
70 |
|
71 static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci); |
|
72 |
|
73 static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci, |
|
74 javaVFrame* jvf, TRAPS); |
|
75 |
|
76 static inline bool skip_hidden_frames(int mode) { |
|
77 return (mode & JVM_STACKWALK_SHOW_HIDDEN_FRAMES) == 0; |
|
78 } |
|
79 static inline bool need_method_info(int mode) { |
|
80 return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0; |
|
81 } |
|
82 static inline bool live_frame_info(int mode) { |
|
83 return (mode & JVM_STACKWALK_FILL_LIVE_STACK_FRAMES) != 0; |
|
84 } |
|
85 static inline bool fill_in_stacktrace(int mode) { |
|
86 return (mode & JVM_STACKWALK_FILTER_FILL_IN_STACK_TRACE) != 0; |
|
87 } |
|
88 |
|
89 public: |
|
90 static oop walk(Handle stackStream, jlong mode, |
|
91 int skip_frames, int frame_count, int start_index, |
|
92 objArrayHandle classes_array, |
|
93 objArrayHandle frames_array, |
|
94 TRAPS); |
|
95 |
|
96 static jint moreFrames(Handle stackStream, jlong mode, jlong magic, |
|
97 int frame_count, int start_index, |
|
98 objArrayHandle classes_array, |
|
99 objArrayHandle frames_array, |
|
100 TRAPS); |
|
101 }; |
|
102 #endif // SHARE_VM_PRIMS_STACKWALK_HPP |