/* * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #ifndef SHARE_VM_PRIMS_STACKWALK_HPP #define SHARE_VM_PRIMS_STACKWALK_HPP #include "oops/oop.hpp" #include "runtime/vframe.hpp" class StackWalkAnchor : public StackObj { JavaThread* _thread; objArrayHandle _frames; vframeStream _vfst; jlong _anchor; address _last_decoded_frame_pc; public: StackWalkAnchor(JavaThread* thread, objArrayHandle frames_array) : _thread(thread), _frames(frames_array), _vfst(thread), _anchor(0L), _last_decoded_frame_pc(0L) { } vframeStream& vframe_stream() { return _vfst; } JavaThread* thread() { return _thread; } objArrayHandle frames() { return _frames; } address last_decoded_frame_pc() { return _last_decoded_frame_pc; } void setup_magic_on_entry(); bool check_magic(); bool cleanup_magic_on_exit(); bool is_valid_in(Thread* thread) { return (_thread == thread && check_magic()); } jlong address_value() { return (jlong) castable_address(this); } int decode_frames(jlong mode, int decode_limit, int start_index, objArrayHandle classes_array, objArrayHandle frames_array, int& end_index, TRAPS); static StackWalkAnchor* from_current(JavaThread* thread, jlong anchor, objArrayHandle frames_array); }; class StackWalk : public AllStatic { public: enum { magic_pos = 0, fill_class_refs_only = 0x2, fill_method_name = 0x4, fill_frame_buffer_only = 0x8, filter_fillInStackTrace = 0x10, show_hidden_frames = 0x20, fill_locals_operands = 0x100 }; private: // After this many redefines, the stack trace is unreliable. public: static Handle walk(Handle stackStream, jlong mode, int skip_frames, int frame_count, int start_index, objArrayHandle classes_array, objArrayHandle frames_array, TRAPS); static jint moreFrames(Handle stackStream, jlong mode, jlong magic, int frame_count, int start_index, objArrayHandle classes_array, objArrayHandle frames_array, TRAPS); static void fill_stackframe(Handle stackFrame, const methodHandle& method, int bci); static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci, javaVFrame* jvf, TRAPS); static Klass* AbstractStackWalker_klass(TRAPS); static inline bool skip_hidden_frames(int mode) { return (mode & show_hidden_frames) == 0; } static inline bool need_method_info(int mode) { return (mode & fill_class_refs_only) == 0; } static inline bool live_frame_info(int mode) { return (mode & fill_locals_operands) != 0; } static inline bool fill_in_stacktrace(int mode) { return (mode & filter_fillInStackTrace) != 0; } }; #endif // SHARE_VM_PRIMS_STACKWALK_HPP