Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/windows/vm/pdh_interface.hpp
32284 views
/*1* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef OS_WINDOWS_VM_PDH_INTERFACE_HPP25#define OS_WINDOWS_VM_PDH_INTERFACE_HPP2627#include "memory/allocation.hpp"28#include <pdh.h>29#include <pdhmsg.h>3031class PdhDll: public AllStatic {32private:33static LONG _pdh_reference_count;34static LONG _critical_section;35static LONG _initialized;36static HMODULE _hModule;37static void initialize();38static PDH_STATUS (WINAPI *_PdhAddCounter)(HQUERY, LPCSTR, DWORD, HCOUNTER*);39static PDH_STATUS (WINAPI *_PdhOpenQuery)(LPCWSTR, DWORD, HQUERY*);40static DWORD (WINAPI *_PdhCloseQuery)(HQUERY);41static PDH_STATUS (WINAPI *_PdhCollectQueryData)(HQUERY);42static DWORD (WINAPI *_PdhGetFormattedCounterValue)(HCOUNTER, DWORD, LPDWORD, PPDH_FMT_COUNTERVALUE);43static PDH_STATUS (WINAPI *_PdhEnumObjectItems)(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, LPDWORD, LPTSTR, LPDWORD, DWORD, DWORD);44static PDH_STATUS (WINAPI *_PdhRemoveCounter)(HCOUNTER);45static PDH_STATUS (WINAPI *_PdhLookupPerfNameByIndex)(LPCSTR, DWORD, LPSTR, LPDWORD);46static PDH_STATUS (WINAPI *_PdhMakeCounterPath)(PPDH_COUNTER_PATH_ELEMENTS, LPTSTR, LPDWORD, DWORD);4748public:49static PDH_STATUS PdhAddCounter(HQUERY, LPCSTR, DWORD, HCOUNTER*);50static PDH_STATUS PdhOpenQuery(LPCWSTR, DWORD, HQUERY*);51static DWORD PdhCloseQuery(HQUERY);52static PDH_STATUS PdhCollectQueryData(HQUERY);53static DWORD PdhGetFormattedCounterValue(HCOUNTER, DWORD, LPDWORD, PPDH_FMT_COUNTERVALUE);54static PDH_STATUS PdhEnumObjectItems(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, LPDWORD, LPTSTR, LPDWORD, DWORD, DWORD);55static PDH_STATUS PdhRemoveCounter(HCOUNTER);56static PDH_STATUS PdhLookupPerfNameByIndex(LPCSTR, DWORD, LPSTR, LPDWORD);57static PDH_STATUS PdhMakeCounterPath(PPDH_COUNTER_PATH_ELEMENTS, LPTSTR, LPDWORD, DWORD);58static bool PdhStatusFail(PDH_STATUS pdhStat);59static bool PdhAttach();60static bool PdhDetach();61};6263#endif // OS_WINDOWS_VM_PDH_INTERFACE_HPP646566