Top


定義場所(file name)

hotspot/src/os/solaris/vm/os_solaris.cpp

説明(description)

// A lightweight implementation that does not suspend the target thread and
// thus returns only a hint. Used for profiling only!

名前(function name)

ExtendedPC os::get_thread_pc(Thread* thread) {

本体部(body)

  {- -------------------------------------------
  (1) (assert)
      ---------------------------------------- -}

      // Make sure that it is called by the watcher and the Threads lock is owned.
      assert(Thread::current()->is_Watcher_thread(), "Must be watcher and own Threads_lock");
      // For now, is only used to profile the VM Thread
      assert(thread->is_VM_thread(), "Can only be called for VMThread");

  {- -------------------------------------------
  (1) (変数宣言など)
      ---------------------------------------- -}

      ExtendedPC epc;

      GetThreadPC_Callback  cb(ProfileVM_lock);
      OSThread *osthread = thread->osthread();
      const int time_to_wait = 400; // 400ms wait for initial response

  {- -------------------------------------------
  (1) OSThread::Sync_Interrupt_Callback::interrupt() を呼び出す
      (この中で, 処理対象のスレッドを停止させて pc を取得し, 再び処理を再開させる作業が行われる).
      ---------------------------------------- -}

      int status = cb.interrupt(thread, time_to_wait);

  {- -------------------------------------------
  (1) OSThread::Sync_Interrupt_Callback::interrupt() が成功していれば, 
      GetThreadPC_Callback::addr() で pc を取得する.
      (失敗していた場合は何もせず epc 変数は NULL のままとする)
      ---------------------------------------- -}

      if (cb.is_done() ) {
        epc = cb.addr();
      } else {
        DEBUG_ONLY(tty->print_cr("Failed to get pc for thread: %d got %d status",
                                  osthread->thread_id(), status););
        // epc is already NULL
      }

  {- -------------------------------------------
  (1) リターン
      ---------------------------------------- -}

      return epc;
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.