96 // 97 // Returns the number of frames whose information was transferred into the buffers. 98 // 99 int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream, 100 int max_nframes, int start_index, 101 objArrayHandle frames_array, 102 int& end_index, TRAPS) { 103 if (TraceStackWalk) { 104 tty->print_cr("fill_in_frames limit=%d start=%d frames length=%d", 105 max_nframes, start_index, frames_array->length()); 106 } 107 assert(max_nframes > 0, "invalid max_nframes"); 108 assert(start_index + max_nframes <= frames_array->length(), "oob"); 109 110 int frames_decoded = 0; 111 for (; !stream.at_end(); stream.next()) { 112 Method* method = stream.method(); 113 int bci = stream.bci(); 114 115 if (method == NULL) continue; 116 if (!ShowHiddenFrames && StackWalk::skip_hidden_frames(mode)) { 117 if (method->is_hidden()) { 118 if (TraceStackWalk) { 119 tty->print(" hidden method: "); method->print_short_name(); 120 tty->print("\n"); 121 } 122 continue; 123 } 124 } 125 126 int index = end_index++; 127 if (TraceStackWalk) { 128 tty->print(" %d: frame method: ", index); method->print_short_name(); 129 tty->print_cr(" bci=%d", bci); 130 } 131 132 // fill in StackFrameInfo and initialize MemberName 133 if (live_frame_info(mode)) { 134 assert (use_frames_array(mode), "Bad mode for get live frame"); 135 Handle stackFrame(frames_array->obj_at(index)); 136 fill_live_stackframe(stackFrame, method, bci, stream.java_frame(), CHECK_0); 137 } else if (need_method_info(mode)) { 138 assert (use_frames_array(mode), "Bad mode for get stack frame"); 139 Handle stackFrame(frames_array->obj_at(index)); 140 fill_stackframe(stackFrame, method, bci); 141 } else { 142 assert (use_frames_array(mode) == false, "Bad mode for get caller class"); 143 frames_array->obj_at_put(index, method->method_holder()->java_mirror()); 144 } 145 if (++frames_decoded >= max_nframes) break; 146 } 147 return frames_decoded; 148 } 149 150 static oop create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) { 151 Klass* k = SystemDictionary::resolve_or_null(vmSymbols::java_lang_LiveStackFrameInfo(), CHECK_NULL); 152 instanceKlassHandle ik (THREAD, k); 153 154 JavaValue result(T_OBJECT); 155 JavaCallArguments args; 156 Symbol* signature = NULL; 157 158 // ## TODO: type is only available in LocalVariable table, if present. 159 // ## StackValue type is T_INT or T_OBJECT. 160 switch (values->at(i)->type()) { 161 case T_INT: 162 args.push_int(values->int_at(i)); | 96 // 97 // Returns the number of frames whose information was transferred into the buffers. 98 // 99 int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream, 100 int max_nframes, int start_index, 101 objArrayHandle frames_array, 102 int& end_index, TRAPS) { 103 if (TraceStackWalk) { 104 tty->print_cr("fill_in_frames limit=%d start=%d frames length=%d", 105 max_nframes, start_index, frames_array->length()); 106 } 107 assert(max_nframes > 0, "invalid max_nframes"); 108 assert(start_index + max_nframes <= frames_array->length(), "oob"); 109 110 int frames_decoded = 0; 111 for (; !stream.at_end(); stream.next()) { 112 Method* method = stream.method(); 113 int bci = stream.bci(); 114 115 if (method == NULL) continue; 116 117 // skip hidden frames for default StackWalker option (i.e. SHOW_HIDDEN_FRAMES 118 // not set) and when StackWalker::getCallerClass is called 119 if (!ShowHiddenFrames && (skip_hidden_frames(mode) || get_caller_class(mode))) { 120 if (method->is_hidden()) { 121 if (TraceStackWalk) { 122 tty->print(" hidden method: "); method->print_short_name(); 123 tty->print("\n"); 124 } 125 continue; 126 } 127 } 128 129 int index = end_index++; 130 if (TraceStackWalk) { 131 tty->print(" %d: frame method: ", index); method->print_short_name(); 132 tty->print_cr(" bci=%d", bci); 133 } 134 135 // fill in StackFrameInfo and initialize MemberName 136 if (live_frame_info(mode)) { 137 assert (use_frames_array(mode), "Bad mode for get live frame"); 138 Handle stackFrame(frames_array->obj_at(index)); 139 fill_live_stackframe(stackFrame, method, bci, stream.java_frame(), CHECK_0); 140 } else if (need_method_info(mode)) { 141 assert (use_frames_array(mode), "Bad mode for get stack frame"); 142 Handle stackFrame(frames_array->obj_at(index)); 143 fill_stackframe(stackFrame, method, bci); 144 } else { 145 assert (get_caller_class(mode) == true, "Bad mode for get caller class"); 146 if (index == start_index && method->caller_sensitive()) { 147 THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), 148 err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method", 149 method->name_and_sig_as_C_string())); 150 } 151 152 frames_array->obj_at_put(index, method->method_holder()->java_mirror()); 153 } 154 if (++frames_decoded >= max_nframes) break; 155 } 156 return frames_decoded; 157 } 158 159 static oop create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) { 160 Klass* k = SystemDictionary::resolve_or_null(vmSymbols::java_lang_LiveStackFrameInfo(), CHECK_NULL); 161 instanceKlassHandle ik (THREAD, k); 162 163 JavaValue result(T_OBJECT); 164 JavaCallArguments args; 165 Symbol* signature = NULL; 166 167 // ## TODO: type is only available in LocalVariable table, if present. 168 // ## StackValue type is T_INT or T_OBJECT. 169 switch (values->at(i)->type()) { 170 case T_INT: 171 args.push_int(values->int_at(i)); |