src/hotspot/os/windows/windbghelp.hpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 53244 9807daeb47c4
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47086
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49039
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
47086
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
49039
0f81d08a578e 8197827: [windows] Small cleanups after JDK-8185712
stuefe
parents: 47666
diff changeset
    25
#ifndef OS_WINDOWS_WINDBGHELP_HPP
0f81d08a578e 8197827: [windows] Small cleanups after JDK-8185712
stuefe
parents: 47666
diff changeset
    26
#define OS_WINDOWS_WINDBGHELP_HPP
47086
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
47666
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47216
diff changeset
    69
  // Call at DLL_PROCESS_ATTACH.
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47216
diff changeset
    70
  void pre_initialize();
19219ec3f176 8185712: [windows] Improve native symbol decoder
goetz
parents: 47216
diff changeset
    71
47086
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents:
diff changeset
    72
};
2b35673f6297 8186349: [windows] Centralize dbghelp handling code
stuefe
parents:
diff changeset
    73
49039
0f81d08a578e 8197827: [windows] Small cleanups after JDK-8185712
stuefe
parents: 47666
diff changeset
    74
#endif // OS_WINDOWS_WINDBGHELP_HPP