decoder_windows.cpp revision 1929
0N/A/*
1499N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "prims/jvm.h"
1879N/A#include "utilities/decoder.hpp"
1879N/A
1879N/AHMODULE Decoder::_dbghelp_handle = NULL;
1879N/Abool Decoder::_can_decode_in_vm = false;
1879N/Apfn_SymGetSymFromAddr64 Decoder::_pfnSymGetSymFromAddr64 = NULL;
0N/Apfn_UndecorateSymbolName Decoder::_pfnUndecorateSymbolName = NULL;
0N/A
0N/Avoid Decoder::initialize() {
726N/A if (!_initialized) {
0N/A _initialized = true;
726N/A
726N/A HMODULE handle = ::LoadLibrary("dbghelp.dll");
726N/A if (!handle) {
726N/A _decoder_status = helper_not_found;
726N/A return;
3932N/A }
726N/A
726N/A _dbghelp_handle = handle;
726N/A
726N/A pfn_SymSetOptions _pfnSymSetOptions = (pfn_SymSetOptions)::GetProcAddress(handle, "SymSetOptions");
726N/A pfn_SymInitialize _pfnSymInitialize = (pfn_SymInitialize)::GetProcAddress(handle, "SymInitialize");
726N/A _pfnSymGetSymFromAddr64 = (pfn_SymGetSymFromAddr64)::GetProcAddress(handle, "SymGetSymFromAddr64");
726N/A _pfnUndecorateSymbolName = (pfn_UndecorateSymbolName)GetProcAddress(handle, "UnDecorateSymbolName");
726N/A
726N/A if (_pfnSymSetOptions == NULL || _pfnSymInitialize == NULL || _pfnSymGetSymFromAddr64 == NULL) {
726N/A _pfnSymGetSymFromAddr64 = NULL;
726N/A _pfnUndecorateSymbolName = NULL;
1059N/A ::FreeLibrary(handle);
726N/A _dbghelp_handle = NULL;
726N/A _decoder_status = helper_func_error;
726N/A return;
726N/A }
726N/A
726N/A _pfnSymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
1059N/A if (!_pfnSymInitialize(GetCurrentProcess(), NULL, TRUE)) {
1059N/A _pfnSymGetSymFromAddr64 = NULL;
1059N/A _pfnUndecorateSymbolName = NULL;
1059N/A ::FreeLibrary(handle);
1059N/A _dbghelp_handle = NULL;
726N/A _decoder_status = helper_init_error;
1580N/A return;
1580N/A }
1580N/A
1580N/A // find out if jvm.dll contains private symbols, by decoding
1580N/A // current function and comparing the result
1580N/A address addr = (address)Decoder::initialize;
1580N/A char buf[MAX_PATH];
1580N/A if (decode(addr, buf, sizeof(buf), NULL) == no_error) {
1580N/A _can_decode_in_vm = !strcmp(buf, "Decoder::initialize");
1580N/A }
1580N/A }
1580N/A}
1580N/A
1580N/Avoid Decoder::uninitialize() {
1580N/A assert(_initialized, "Decoder not yet initialized");
1580N/A _pfnSymGetSymFromAddr64 = NULL;
726N/A _pfnUndecorateSymbolName = NULL;
1138N/A if (_dbghelp_handle != NULL) {
726N/A ::FreeLibrary(_dbghelp_handle);
Error!

 

There was an error!

null

java.lang.NullPointerException