34253
|
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 |
|
37438
|
48 |
void setup_magic_on_entry(objArrayHandle frames_array);
|
|
49 |
bool check_magic(objArrayHandle frames_array);
|
|
50 |
bool cleanup_magic_on_exit(objArrayHandle frames_array);
|
34253
|
51 |
|
37438
|
52 |
bool is_valid_in(Thread* thread, objArrayHandle frames_array) {
|
|
53 |
return (_thread == thread && check_magic(frames_array));
|
34253
|
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 frames_array,
|
|
68 |
int& end_index, TRAPS);
|
|
69 |
|
|
70 |
static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci);
|
|
71 |
|
|
72 |
static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci,
|
|
73 |
javaVFrame* jvf, TRAPS);
|
|
74 |
|
|
75 |
static inline bool skip_hidden_frames(int mode) {
|
|
76 |
return (mode & JVM_STACKWALK_SHOW_HIDDEN_FRAMES) == 0;
|
|
77 |
}
|
|
78 |
static inline bool need_method_info(int mode) {
|
|
79 |
return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
|
|
80 |
}
|
|
81 |
static inline bool live_frame_info(int mode) {
|
|
82 |
return (mode & JVM_STACKWALK_FILL_LIVE_STACK_FRAMES) != 0;
|
|
83 |
}
|
|
84 |
|
|
85 |
public:
|
37438
|
86 |
static inline bool use_frames_array(int mode) {
|
|
87 |
return (mode & JVM_STACKWALK_FILL_CLASS_REFS_ONLY) == 0;
|
|
88 |
}
|
34253
|
89 |
static oop walk(Handle stackStream, jlong mode,
|
|
90 |
int skip_frames, int frame_count, int start_index,
|
|
91 |
objArrayHandle frames_array,
|
|
92 |
TRAPS);
|
|
93 |
|
|
94 |
static jint moreFrames(Handle stackStream, jlong mode, jlong magic,
|
|
95 |
int frame_count, int start_index,
|
|
96 |
objArrayHandle frames_array,
|
|
97 |
TRAPS);
|
|
98 |
};
|
|
99 |
#endif // SHARE_VM_PRIMS_STACKWALK_HPP
|