view agent/src/heapstats-engines/deadlockDetector.hpp @ 247:33a77b567b62

Bug 3293: [REFACTORING] Realtime deadlock detector implementation Reviewed-by: ykubota https://github.com/HeapStats/heapstats/pull/115
author Yasumasa Suenaga <yasuenag@gmail.com>
date Wed, 02 Aug 2017 14:46:00 +0900
parents
children
line wrap: on
line source

/*!
 * \file deadlockDetector.hpp
 * \brief This file is used by find deadlock.
 * Copyright (C) 2017 Yasumasa Suenaga
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA  02110-1301, USA.
 *
 */

#ifndef _DEADLOCK_DETECTOR_H
#define _DEADLOCK_DETECTOR_H

#include <jvmti.h>
#include <jni.h>


namespace dldetector {

  /*!
   * \brief Event handler of JVMTI MonitorContendedEnter for finding deadlock.
   * \param jvmti  [in] JVMTI environment.
   * \param env    [in] JNI environment of the event (current) thread.
   * \param thread [in] JNI local reference to the thread attempting to enter
   *                    the monitor.
   * \param object [in] JNI local reference to the monitor.
   */
  void JNICALL OnMonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv *env,
                                       jthread thread, jobject object);

  /*!
   * \brief Event handler of JVMTI MonitorContendedEntered for finding deadlock.
   * \param jvmti  [in] JVMTI environment.
   * \param env    [in] JNI environment of the event (current) thread.
   * \param thread [in] JNI local reference to the thread attempting to enter
   *                    the monitor.
   * \param object [in] JNI local reference to the monitor.
   */
  void JNICALL OnMonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv *env,
                                         jthread thread, jobject object);

  /*!
   * \brief Deadlock detector initializer.
   * \param jvmti    [in]  JVMTI environment
   * \param isOnLoad [in]  OnLoad phase or not (Live phase).
   * \return Process result.
   * \warning This function MUST be called only once.
   */
  bool initialize(jvmtiEnv *jvmti, bool isOnLoad);

  /*!
   * \brief Deadlock detector finalizer.
   *        This function unregisters JVMTI callback for deadlock detection.
   * \param jvmti [in]  JVMTI environment
   */
  void finalize(jvmtiEnv *jvmti);

};

#endif  // _DEADLOCK_DETECTOR_H