コード例 #1
0
ファイル: stackwalk.cpp プロジェクト: gaoxiaojun/dync
// Unpacks one or more frames into user-supplied buffers.
// Updates the end index, and returns the number of unpacked frames.
// Always start with the existing vfst.method and bci.
// Do not call vfst.next to advance over the last returned value.
// In other words, do not leave any stale data in the vfst.
//
// Parameters:
//   mode           Restrict which frames to be decoded.
//   vfst           vFrameStream.
//   max_nframes    Maximum number of frames to be filled.
//   start_index    Start index to the user-supplied buffers.
//   classes_array  Buffer to store classes in, starting at start_index.
//   frames_array   Buffer to store StackFrame in, starting at start_index.
//                  NULL if not used.
//   end_index      End index to the user-supplied buffers with unpacked frames.
//
// Returns the number of frames whose information was transferred into the buffers.
//
int StackWalk::fill_in_frames(jlong mode, vframeStream& vfst,
                              int max_nframes, int start_index,
                              objArrayHandle  classes_array,
                              objArrayHandle  frames_array,
                              int& end_index, TRAPS) {
  if (TraceStackWalk) {
    tty->print_cr("fill_in_frames limit=%d start=%d frames length=%d",
                  max_nframes, start_index, classes_array->length());
  }
  assert(max_nframes > 0, "invalid max_nframes");
  assert(start_index + max_nframes <= classes_array->length(), "oob");

  int frames_decoded = 0;
  for (; !vfst.at_end(); vfst.next()) {
    Method* method = vfst.method();
    int bci = vfst.bci();

    if (method == NULL) continue;
    if (!ShowHiddenFrames && StackWalk::skip_hidden_frames(mode)) {
      if (method->is_hidden()) {
        if (TraceStackWalk) {
          tty->print("  hidden method: "); method->print_short_name();
          tty->print("\n");
        }
        continue;
      }
    }

    int index = end_index++;
    if (TraceStackWalk) {
      tty->print("  %d: frame method: ", index); method->print_short_name();
      tty->print_cr(" bci=%d", bci);
    }

    classes_array->obj_at_put(index, method->method_holder()->java_mirror());
    // fill in StackFrameInfo and initialize MemberName
    if (live_frame_info(mode)) {
      Handle stackFrame(frames_array->obj_at(index));
      fill_live_stackframe(stackFrame, method, bci, vfst.java_frame(), CHECK_0);
    } else if (need_method_info(mode)) {
      Handle stackFrame(frames_array->obj_at(index));
      fill_stackframe(stackFrame, method, bci);
    }
    if (++frames_decoded >= max_nframes)  break;
  }
  return frames_decoded;
}
コード例 #2
0
 void next()      { _vfst.next();}