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