hotspot/src/os/windows/vm/decoder_windows.cpp
changeset 31352 a6ab7217b5cc
parent 25468 5331df506290
child 47086 2b35673f6297
equal deleted inserted replaced
31351:aae7db185576 31352:a6ab7217b5cc
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   160 
   160 
   161      // find out if jvm.dll contains private symbols, by decoding
   161      // find out if jvm.dll contains private symbols, by decoding
   162      // current function and comparing the result
   162      // current function and comparing the result
   163      address addr = (address)Decoder::demangle;
   163      address addr = (address)Decoder::demangle;
   164      char buf[MAX_PATH];
   164      char buf[MAX_PATH];
   165      if (decode(addr, buf, sizeof(buf), NULL)) {
   165      if (decode(addr, buf, sizeof(buf), NULL, NULL, true /* demangle */)) {
   166        _can_decode_in_vm = !strcmp(buf, "Decoder::demangle");
   166        _can_decode_in_vm = !strcmp(buf, "Decoder::demangle");
   167      }
   167      }
   168   }
   168   }
   169 }
   169 }
   170 
   170 
   185 bool WindowsDecoder::can_decode_C_frame_in_vm() const {
   185 bool WindowsDecoder::can_decode_C_frame_in_vm() const {
   186   return  (!has_error() && _can_decode_in_vm);
   186   return  (!has_error() && _can_decode_in_vm);
   187 }
   187 }
   188 
   188 
   189 
   189 
   190 bool WindowsDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* modulepath)  {
   190 bool WindowsDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* modulepath, bool demangle_name)  {
   191   if (_pfnSymGetSymFromAddr64 != NULL) {
   191   if (_pfnSymGetSymFromAddr64 != NULL) {
   192     PIMAGEHLP_SYMBOL64 pSymbol;
   192     PIMAGEHLP_SYMBOL64 pSymbol;
   193     char symbolInfo[MAX_PATH + sizeof(IMAGEHLP_SYMBOL64)];
   193     char symbolInfo[MAX_PATH + sizeof(IMAGEHLP_SYMBOL64)];
   194     pSymbol = (PIMAGEHLP_SYMBOL64)symbolInfo;
   194     pSymbol = (PIMAGEHLP_SYMBOL64)symbolInfo;
   195     pSymbol->MaxNameLength = MAX_PATH;
   195     pSymbol->MaxNameLength = MAX_PATH;
   196     pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
   196     pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
   197     DWORD64 displacement;
   197     DWORD64 displacement;
   198     if (_pfnSymGetSymFromAddr64(::GetCurrentProcess(), (DWORD64)addr, &displacement, pSymbol)) {
   198     if (_pfnSymGetSymFromAddr64(::GetCurrentProcess(), (DWORD64)addr, &displacement, pSymbol)) {
   199       if (buf != NULL) {
   199       if (buf != NULL) {
   200         if (demangle(pSymbol->Name, buf, buflen)) {
   200         if (!(demangle_name && demangle(pSymbol->Name, buf, buflen))) {
   201           jio_snprintf(buf, buflen, "%s", pSymbol->Name);
   201           jio_snprintf(buf, buflen, "%s", pSymbol->Name);
   202         }
   202         }
   203       }
   203       }
   204       if(offset != NULL) *offset = (int)displacement;
   204       if(offset != NULL) *offset = (int)displacement;
   205       return true;
   205       return true;