1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef OS_WINDOWS_VM_DBGHELPLOADER_HPP 26 #define OS_WINDOWS_VM_DBGHELPLOADER_HPP 27 28 #include <windows.h> 29 #include <imagehlp.h> 30 31 // This is a very plain wrapper for loading dbghelp.dll. It does not offer 32 // any additional functionality. It takes care of locking. 33 34 class outputStream; 35 36 // Please note: dbghelp.dll may not have been loaded, or it may have been loaded but not 37 // all functions may be available (because on the target system dbghelp.dll is of an 38 // older version). 39 // In all these cases we return an error from the WindowsDbgHelp::symXXXX() wrapper. We never 40 // assert. It should always be safe to call these functions, but caller has to process the 41 // return code (which he would have to do anyway). 42 namespace WindowsDbgHelp { 43 44 DWORD symSetOptions(DWORD); 45 DWORD symGetOptions(void); 46 BOOL symInitialize(HANDLE, PCTSTR, BOOL); 47 BOOL symGetSymFromAddr64(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64); 48 DWORD unDecorateSymbolName(const char*, char*, DWORD, DWORD); 49 BOOL symSetSearchPath(HANDLE, PCTSTR); 50 BOOL symGetSearchPath(HANDLE, PTSTR, int); 51 BOOL stackWalk64(DWORD MachineType, 52 HANDLE hProcess, 53 HANDLE hThread, 54 LPSTACKFRAME64 StackFrame, 55 PVOID ContextRecord); 56 PVOID symFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase); 57 DWORD64 symGetModuleBase64(HANDLE hProcess, DWORD64 dwAddr); 58 BOOL miniDumpWriteDump(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, 59 MINIDUMP_TYPE DumpType, PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, 60 PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, 61 PMINIDUMP_CALLBACK_INFORMATION CallbackParam); 62 BOOL symGetLineFromAddr64 (HANDLE hProcess, DWORD64 dwAddr, 63 PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line); 64 65 // Print one liner describing state (if library loaded, which functions are 66 // missing - if any, and the dbhelp API version) 67 void print_state_on(outputStream* st); 68 69 // Call at DLL_PROCESS_ATTACH. 70 void pre_initialize(); 71 72 }; 73 74 75 #endif // OS_WINDOWS_VM_DBGHELPLOADER_HPP 76