author | mchung |
Wed, 14 Sep 2016 11:53:20 -0700 | |
changeset 41095 | 97cca074c2be |
parent 40001 | f37246e66d2b |
child 41280 | 74b314ad1e9a |
permissions | -rw-r--r-- |
34253 | 1 |
/* |
40001 | 2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
34253 | 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 |
||
38213
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
32 |
// |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
33 |
// JavaFrameStream is used by StackWalker to iterate through Java stack frames |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
34 |
// on the given JavaThread. |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
35 |
// |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
36 |
class JavaFrameStream : public StackObj { |
34253 | 37 |
private: |
38 |
enum { |
|
39 |
magic_pos = 0 |
|
40 |
}; |
|
41 |
||
42 |
JavaThread* _thread; |
|
38213
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
43 |
javaVFrame* _jvf; |
34253 | 44 |
jlong _anchor; |
45 |
public: |
|
38213
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
46 |
JavaFrameStream(JavaThread* thread, RegisterMap* rm) |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
47 |
: _thread(thread), _anchor(0L) { |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
48 |
_jvf = _thread->last_java_vframe(rm); |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
49 |
} |
34253 | 50 |
|
38213
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
51 |
javaVFrame* java_frame() { return _jvf; } |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
52 |
void next() { _jvf = _jvf->java_sender(); } |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
53 |
bool at_end() { return _jvf == NULL; } |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
54 |
|
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
55 |
Method* method() { return _jvf->method(); } |
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
56 |
int bci() { return _jvf->bci(); } |
34253 | 57 |
|
37438 | 58 |
void setup_magic_on_entry(objArrayHandle frames_array); |
59 |
bool check_magic(objArrayHandle frames_array); |
|
60 |
bool cleanup_magic_on_exit(objArrayHandle frames_array); |
|
34253 | 61 |
|
37438 | 62 |
bool is_valid_in(Thread* thread, objArrayHandle frames_array) { |
63 |
return (_thread == thread && check_magic(frames_array)); |
|
34253 | 64 |
} |
65 |
||
66 |
jlong address_value() { |
|
67 |
return (jlong) castable_address(this); |
|
68 |
} |
|
69 |
||
38213
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
70 |
static JavaFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array); |
34253 | 71 |
}; |
72 |
||
73 |
class StackWalk : public AllStatic { |
|
74 |
private: |
|
38213
2f32787e31b1
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
37438
diff
changeset
|
75 |
static int fill_in_frames(jlong mode, JavaFrameStream& stream, |
34253 | 76 |
int max_nframes, int start_index, |
77 |
objArrayHandle frames_array, |
|
78 |
int& end_index, TRAPS); |
|
79 |
||
80 |
static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci); |
|
81 |
||
82 |
static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci, |
|
83 |
javaVFrame* jvf, TRAPS); |
|
84 |
||
41095
97cca074c2be
8157464: Disallow StackWalker.getCallerClass() be called by caller-sensitive method
mchung
parents:
40001
diff
changeset
|
85 |
static inline bool get_caller_class(int mode) { |
97cca074c2be
8157464: Disallow StackWalker.getCallerClass() be called by caller-sensitive method
mchung
parents:
40001
diff
changeset
|
86 |
return (mode & JVM_STACKWALK_GET_CALLER_CLASS) != 0; |
97cca074c2be
8157464: Disallow StackWalker.getCallerClass() be called by caller-sensitive method
mchung
parents:
40001
diff
changeset
|
87 |
} |
34253 | 88 |
static inline bool skip_hidden_frames(int mode) { |
89 |
return (mode & JVM_STACKWALK_SHOW_HIDDEN_FRAMES) == 0; |
|
90 |
} |
|
91 |
static inline bool need_method_info(int mode) { |
|
92 |
return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0; |
|
93 |
} |
|
94 |
static inline bool live_frame_info(int mode) { |
|
95 |
return (mode & JVM_STACKWALK_FILL_LIVE_STACK_FRAMES) != 0; |
|
96 |
} |
|
97 |
||
98 |
public: |
|
37438 | 99 |
static inline bool use_frames_array(int mode) { |
100 |
return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0; |
|
101 |
} |
|
34253 | 102 |
static oop walk(Handle stackStream, jlong mode, |
103 |
int skip_frames, int frame_count, int start_index, |
|
104 |
objArrayHandle frames_array, |
|
105 |
TRAPS); |
|
106 |
||
107 |
static jint moreFrames(Handle stackStream, jlong mode, jlong magic, |
|
108 |
int frame_count, int start_index, |
|
109 |
objArrayHandle frames_array, |
|
110 |
TRAPS); |
|
111 |
}; |
|
112 |
#endif // SHARE_VM_PRIMS_STACKWALK_HPP |