1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
27 #define SHARE_VM_PRIMS_STACKWALK_HPP |
27 #define SHARE_VM_PRIMS_STACKWALK_HPP |
28 |
28 |
29 #include "oops/oop.hpp" |
29 #include "oops/oop.hpp" |
30 #include "runtime/vframe.hpp" |
30 #include "runtime/vframe.hpp" |
31 |
31 |
32 class StackWalkAnchor : public StackObj { |
32 // |
|
33 // JavaFrameStream is used by StackWalker to iterate through Java stack frames |
|
34 // on the given JavaThread. |
|
35 // |
|
36 class JavaFrameStream : public StackObj { |
33 private: |
37 private: |
34 enum { |
38 enum { |
35 magic_pos = 0 |
39 magic_pos = 0 |
36 }; |
40 }; |
37 |
41 |
38 JavaThread* _thread; |
42 JavaThread* _thread; |
39 vframeStream _vfst; |
43 javaVFrame* _jvf; |
40 jlong _anchor; |
44 jlong _anchor; |
41 public: |
45 public: |
42 StackWalkAnchor(JavaThread* thread) |
46 JavaFrameStream(JavaThread* thread, RegisterMap* rm) |
43 : _thread(thread), _vfst(thread), _anchor(0L) {} |
47 : _thread(thread), _anchor(0L) { |
|
48 _jvf = _thread->last_java_vframe(rm); |
|
49 } |
44 |
50 |
45 vframeStream& vframe_stream() { return _vfst; } |
51 javaVFrame* java_frame() { return _jvf; } |
46 JavaThread* thread() { return _thread; } |
52 void next() { _jvf = _jvf->java_sender(); } |
|
53 bool at_end() { return _jvf == NULL; } |
|
54 |
|
55 Method* method() { return _jvf->method(); } |
|
56 int bci() { return _jvf->bci(); } |
47 |
57 |
48 void setup_magic_on_entry(objArrayHandle frames_array); |
58 void setup_magic_on_entry(objArrayHandle frames_array); |
49 bool check_magic(objArrayHandle frames_array); |
59 bool check_magic(objArrayHandle frames_array); |
50 bool cleanup_magic_on_exit(objArrayHandle frames_array); |
60 bool cleanup_magic_on_exit(objArrayHandle frames_array); |
51 |
61 |
55 |
65 |
56 jlong address_value() { |
66 jlong address_value() { |
57 return (jlong) castable_address(this); |
67 return (jlong) castable_address(this); |
58 } |
68 } |
59 |
69 |
60 static StackWalkAnchor* from_current(JavaThread* thread, jlong anchor, objArrayHandle frames_array); |
70 static JavaFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array); |
61 }; |
71 }; |
62 |
72 |
63 class StackWalk : public AllStatic { |
73 class StackWalk : public AllStatic { |
64 private: |
74 private: |
65 static int fill_in_frames(jlong mode, vframeStream& vfst, |
75 static int fill_in_frames(jlong mode, JavaFrameStream& stream, |
66 int max_nframes, int start_index, |
76 int max_nframes, int start_index, |
67 objArrayHandle frames_array, |
77 objArrayHandle frames_array, |
68 int& end_index, TRAPS); |
78 int& end_index, TRAPS); |
69 |
79 |
70 static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci); |
80 static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci); |