New hotspot/src/share/vm/prims/stackwalk.hpp (original) (raw)

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 JavaThread _thread; 34 objArrayHandle _frames; 35 vframeStream _vfst; 36 jlong _anchor; 37 address _last_decoded_frame_pc; 38 public: 39 StackWalkAnchor(JavaThread* thread, objArrayHandle frames_array) 40 : _thread(thread), _frames(frames_array), _vfst(thread), _anchor(0L), _last_decoded_frame_pc(0L) 41 { 42 } 43 44 vframeStream& vframe_stream() { return _vfst; } 45 JavaThread* thread() { return _thread; } 46 objArrayHandle frames() { return _frames; } 47 address last_decoded_frame_pc() { return _last_decoded_frame_pc; } 48 49 void setup_magic_on_entry(); 50 bool check_magic(); 51 bool cleanup_magic_on_exit(); 52 53 bool is_valid_in(Thread* thread) { 54 return (_thread == thread && check_magic()); 55 } 56 57 jlong address_value() { 58 return (jlong) castable_address(this); 59 } 60 61 int decode_frames(jlong mode, int decode_limit, int start_index, 62 objArrayHandle classes_array, 63 objArrayHandle frames_array, 64 int& end_index, TRAPS); 65 static StackWalkAnchor* from_current(JavaThread* thread, jlong anchor, objArrayHandle frames_array); 66 }; 67 68 class StackWalk : public AllStatic { 69 public: 70 enum { 71 magic_pos = 0, 72 fill_class_refs_only = 0x2, 73 fill_method_name = 0x4, 74 fill_frame_buffer_only = 0x8, 75 filter_fillInStackTrace = 0x10, 76 show_hidden_frames = 0x20, 77 fill_locals_operands = 0x100 78 }; 79 private: 80 81 // After this many redefines, the stack trace is unreliable. 82 public: 83 static Handle walk(Handle stackStream, jlong mode, 84 int skip_frames, int frame_count, int start_index, 85 objArrayHandle classes_array, 86 objArrayHandle frames_array, 87 TRAPS); 88 89 static jint moreFrames(Handle stackStream, jlong mode, jlong magic, 90 int frame_count, int start_index, 91 objArrayHandle classes_array, 92 objArrayHandle frames_array, 93 TRAPS); 94 95 static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci); 96 97 static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci, 98 javaVFrame* jvf, TRAPS); 99 100 static Klass* AbstractStackWalker_klass(TRAPS); 101 102 static inline bool skip_hidden_frames(int mode) { return (mode & show_hidden_frames) == 0; } 103 static inline bool need_method_info(int mode) { return (mode & fill_class_refs_only) == 0; } 104 static inline bool live_frame_info(int mode) { return (mode & fill_locals_operands) != 0; } 105 static inline bool fill_in_stacktrace(int mode) { return (mode & filter_fillInStackTrace) != 0; } 106 107 }; 108 #endif // SHARE_VM_PRIMS_STACKWALK_HPP