コード例 #1
0
ファイル: stackwalk.cpp プロジェクト: netroby/jdk9-dev
// Fill LiveStackFrameInfo with locals, monitors, and expressions
void LiveFrameStream::fill_live_stackframe(Handle stackFrame,
        const methodHandle& method, TRAPS) {
    fill_stackframe(stackFrame, method);
    if (_jvf != NULL) {
        StackValueCollection* locals = _jvf->locals();
        StackValueCollection* expressions = _jvf->expressions();
        GrowableArray<MonitorInfo*>* monitors = _jvf->monitors();

        if (!locals->is_empty()) {
            objArrayHandle locals_h = values_to_object_array(locals, CHECK);
            java_lang_LiveStackFrameInfo::set_locals(stackFrame(), locals_h());
        }
        if (!expressions->is_empty()) {
            objArrayHandle expressions_h = values_to_object_array(expressions, CHECK);
            java_lang_LiveStackFrameInfo::set_operands(stackFrame(), expressions_h());
        }
        if (monitors->length() > 0) {
            objArrayHandle monitors_h = monitors_to_object_array(monitors, CHECK);
            java_lang_LiveStackFrameInfo::set_monitors(stackFrame(), monitors_h());
        }
    }
}
コード例 #2
0
void javaVFrame::print_lock_info(int frame_count) {        
  ResourceMark rm;

  // If this is the first frame, and java.lang.Object.wait(...) then print out the receiver.
  if (frame_count == 0 && method()->name() == vmSymbols::wait_name() && 
      instanceKlass::cast(method()->method_holder())->name() == vmSymbols::java_lang_Object()) {
    StackValueCollection* locs = locals();      
    if (!locs->is_empty()) {
      StackValue* sv = locs->at(0);
      if (sv->type() == T_OBJECT) {
        Handle o = locs->at(0)->get_obj();    
        if (o.not_null()) {
          instanceKlass* ik = instanceKlass::cast(o->klass());
          tty->print_cr("\t- waiting on <" INTPTR_FORMAT "> (a %s)", o(), ik->external_name());
        }
      }
    }        
  }    
  
  // Print out all monitors that we have locked or are trying to lock
  GrowableArray<MonitorInfo*>* mons = monitors();
  if (!mons->is_empty()) {
    bool found_first_monitor = false;
    for (int index = (mons->length()-1); index >= 0; index--) {
      MonitorInfo* monitor = mons->at(index);
      if (monitor->owner() != NULL) {
        //
        // First, assume we have the monitor locked. If we haven't found an
        // owned monitor before and this is the first frame, then we need to
        // see if the thread is blocked.
        //
        const char *lock_state = "locked"; // assume we have the monitor locked
        if (!found_first_monitor && frame_count == 0) {
          switch (thread()->thread_state()) {
          case _thread_blocked:
          case _thread_blocked_trans:
            lock_state = "waiting to lock";
            break;
          }
        }
        found_first_monitor = true;
        instanceKlass* ik = instanceKlass::cast(monitor->owner()->klass());
        tty->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", lock_state, monitor->owner(), ik->external_name());
      }
    }  
  }
}
コード例 #3
0
ファイル: vframe.cpp プロジェクト: 4T-Shirt/OpenJDK-Research
void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
  ResourceMark rm;

  // If this is the first frame, and java.lang.Object.wait(...) then print out the receiver.
  if (frame_count == 0) {
    if (method()->name() == vmSymbols::wait_name() &&
        method()->method_holder()->name() == vmSymbols::java_lang_Object()) {
      StackValueCollection* locs = locals();
      if (!locs->is_empty()) {
        StackValue* sv = locs->at(0);
        if (sv->type() == T_OBJECT) {
          Handle o = locs->at(0)->get_obj();
          print_locked_object_class_name(st, o, "waiting on");
        }
      }
    } else if (thread()->current_park_blocker() != NULL) {
      oop obj = thread()->current_park_blocker();
      Klass* k = obj->klass();
      st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", (address)obj, k->external_name());
    }
  }


  // Print out all monitors that we have locked or are trying to lock
  GrowableArray<MonitorInfo*>* mons = monitors();
  if (!mons->is_empty()) {
    bool found_first_monitor = false;
    for (int index = (mons->length()-1); index >= 0; index--) {
      MonitorInfo* monitor = mons->at(index);
      if (monitor->eliminated() && is_compiled_frame()) { // Eliminated in compiled code
        if (monitor->owner_is_scalar_replaced()) {
          Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
          st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
        } else {
          oop obj = monitor->owner();
          if (obj != NULL) {
            print_locked_object_class_name(st, obj, "eliminated");
          }
        }
        continue;
      }
      if (monitor->owner() != NULL) {

        // First, assume we have the monitor locked. If we haven't found an
        // owned monitor before and this is the first frame, then we need to
        // see if we have completed the lock or we are blocked trying to
        // acquire it - we can only be blocked if the monitor is inflated

        const char *lock_state = "locked"; // assume we have the monitor locked
        if (!found_first_monitor && frame_count == 0) {
          markOop mark = monitor->owner()->mark();
          if (mark->has_monitor() &&
              mark->monitor() == thread()->current_pending_monitor()) {
            lock_state = "waiting to lock";
          }
        }

        found_first_monitor = true;
        print_locked_object_class_name(st, monitor->owner(), lock_state);
      }
    }
  }
}