author | zgu |
Wed, 09 Jan 2013 14:46:55 -0500 | |
changeset 15186 | 1a255c84cf6a |
parent 13963 | e5b53c306fb5 |
child 15855 | 2ac9ebea17f3 |
permissions | -rw-r--r-- |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
1 |
/* |
13963
e5b53c306fb5
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
13340
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
4 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
8 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
13 |
* accompanied this code). |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
14 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
18 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
21 |
* questions. |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
22 |
* |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
23 |
*/ |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
24 |
|
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
26 |
#include "prims/jvm.h" |
11483 | 27 |
#include "decoder_windows.hpp" |
28 |
||
29 |
WindowsDecoder::WindowsDecoder() { |
|
30 |
_dbghelp_handle = NULL; |
|
31 |
_can_decode_in_vm = false; |
|
32 |
_pfnSymGetSymFromAddr64 = NULL; |
|
33 |
_pfnUndecorateSymbolName = NULL; |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
34 |
|
11483 | 35 |
_decoder_status = no_error; |
36 |
initialize(); |
|
37 |
} |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
38 |
|
11483 | 39 |
void WindowsDecoder::initialize() { |
40 |
if (!has_error() && _dbghelp_handle == NULL) { |
|
41 |
HMODULE handle = ::LoadLibrary("dbghelp.dll"); |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
42 |
if (!handle) { |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
43 |
_decoder_status = helper_not_found; |
11483 | 44 |
return; |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
45 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
46 |
|
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
47 |
_dbghelp_handle = handle; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
48 |
|
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
49 |
pfn_SymSetOptions _pfnSymSetOptions = (pfn_SymSetOptions)::GetProcAddress(handle, "SymSetOptions"); |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
50 |
pfn_SymInitialize _pfnSymInitialize = (pfn_SymInitialize)::GetProcAddress(handle, "SymInitialize"); |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
51 |
_pfnSymGetSymFromAddr64 = (pfn_SymGetSymFromAddr64)::GetProcAddress(handle, "SymGetSymFromAddr64"); |
15186
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
52 |
_pfnUndecorateSymbolName = (pfn_UndecorateSymbolName)::GetProcAddress(handle, "UnDecorateSymbolName"); |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
53 |
|
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
54 |
if (_pfnSymSetOptions == NULL || _pfnSymInitialize == NULL || _pfnSymGetSymFromAddr64 == NULL) { |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
55 |
_pfnSymGetSymFromAddr64 = NULL; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
56 |
_pfnUndecorateSymbolName = NULL; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
57 |
::FreeLibrary(handle); |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
58 |
_dbghelp_handle = NULL; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
59 |
_decoder_status = helper_func_error; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
60 |
return; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
61 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
62 |
|
15186
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
63 |
HANDLE hProcess = ::GetCurrentProcess(); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
64 |
_pfnSymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_EXACT_SYMBOLS); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
65 |
if (!_pfnSymInitialize(hProcess, NULL, TRUE)) { |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
66 |
_pfnSymGetSymFromAddr64 = NULL; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
67 |
_pfnUndecorateSymbolName = NULL; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
68 |
::FreeLibrary(handle); |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
69 |
_dbghelp_handle = NULL; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
70 |
_decoder_status = helper_init_error; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
71 |
return; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
72 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
73 |
|
15186
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
74 |
// set pdb search paths |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
75 |
pfn_SymSetSearchPath _pfn_SymSetSearchPath = |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
76 |
(pfn_SymSetSearchPath)::GetProcAddress(handle, "SymSetSearchPath"); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
77 |
pfn_SymGetSearchPath _pfn_SymGetSearchPath = |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
78 |
(pfn_SymGetSearchPath)::GetProcAddress(handle, "SymGetSearchPath"); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
79 |
if (_pfn_SymSetSearchPath != NULL && _pfn_SymGetSearchPath != NULL) { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
80 |
char paths[MAX_PATH]; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
81 |
int len = sizeof(paths); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
82 |
if (!_pfn_SymGetSearchPath(hProcess, paths, len)) { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
83 |
paths[0] = '\0'; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
84 |
} else { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
85 |
// available spaces in path buffer |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
86 |
len -= (int)strlen(paths); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
87 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
88 |
|
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
89 |
char tmp_path[MAX_PATH]; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
90 |
DWORD dwSize; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
91 |
HMODULE hJVM = ::GetModuleHandle("jvm.dll"); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
92 |
tmp_path[0] = '\0'; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
93 |
// append the path where jvm.dll is located |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
94 |
if (hJVM != NULL && (dwSize = ::GetModuleFileName(hJVM, tmp_path, sizeof(tmp_path))) > 0) { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
95 |
while (dwSize > 0 && tmp_path[dwSize] != '\\') { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
96 |
dwSize --; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
97 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
98 |
|
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
99 |
tmp_path[dwSize] = '\0'; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
100 |
|
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
101 |
if (dwSize > 0 && len > (int)dwSize + 1) { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
102 |
strncat(paths, os::path_separator(), 1); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
103 |
strncat(paths, tmp_path, dwSize); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
104 |
len -= dwSize + 1; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
105 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
106 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
107 |
|
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
108 |
// append $JRE/bin. Arguments::get_java_home actually returns $JRE |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
109 |
// path |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
110 |
char *p = Arguments::get_java_home(); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
111 |
assert(p != NULL, "empty java home"); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
112 |
size_t java_home_len = strlen(p); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
113 |
if (len > (int)java_home_len + 5) { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
114 |
strncat(paths, os::path_separator(), 1); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
115 |
strncat(paths, p, java_home_len); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
116 |
strncat(paths, "\\bin", 4); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
117 |
len -= (int)(java_home_len + 5); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
118 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
119 |
|
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
120 |
// append $JDK/bin path if it exists |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
121 |
assert(java_home_len < MAX_PATH, "Invalid path length"); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
122 |
// assume $JRE is under $JDK, construct $JDK/bin path and |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
123 |
// see if it exists or not |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
124 |
if (strncmp(&p[java_home_len - 3], "jre", 3) == 0) { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
125 |
strncpy(tmp_path, p, java_home_len - 3); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
126 |
tmp_path[java_home_len - 3] = '\0'; |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
127 |
strncat(tmp_path, "bin", 3); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
128 |
|
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
129 |
// if the directory exists |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
130 |
DWORD dwAttrib = GetFileAttributes(tmp_path); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
131 |
if (dwAttrib != INVALID_FILE_ATTRIBUTES && |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
132 |
(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
133 |
// tmp_path should have the same length as java_home_len, since we only |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
134 |
// replaced 'jre' with 'bin' |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
135 |
if (len > (int)java_home_len + 1) { |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
136 |
strncat(paths, os::path_separator(), 1); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
137 |
strncat(paths, tmp_path, java_home_len); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
138 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
139 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
140 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
141 |
|
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
142 |
_pfn_SymSetSearchPath(hProcess, paths); |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
143 |
} |
1a255c84cf6a
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
13963
diff
changeset
|
144 |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
145 |
// find out if jvm.dll contains private symbols, by decoding |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
146 |
// current function and comparing the result |
13340 | 147 |
address addr = (address)Decoder::demangle; |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
148 |
char buf[MAX_PATH]; |
11483 | 149 |
if (decode(addr, buf, sizeof(buf), NULL)) { |
13340 | 150 |
_can_decode_in_vm = !strcmp(buf, "Decoder::demangle"); |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
151 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
152 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
153 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
154 |
|
11483 | 155 |
void WindowsDecoder::uninitialize() { |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
156 |
_pfnSymGetSymFromAddr64 = NULL; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
157 |
_pfnUndecorateSymbolName = NULL; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
158 |
if (_dbghelp_handle != NULL) { |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
159 |
::FreeLibrary(_dbghelp_handle); |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
160 |
} |
11483 | 161 |
_dbghelp_handle = NULL; |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
162 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
163 |
|
11483 | 164 |
bool WindowsDecoder::can_decode_C_frame_in_vm() const { |
165 |
return (!has_error() && _can_decode_in_vm); |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
166 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
167 |
|
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
168 |
|
11483 | 169 |
bool WindowsDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* modulepath) { |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
170 |
if (_pfnSymGetSymFromAddr64 != NULL) { |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
171 |
PIMAGEHLP_SYMBOL64 pSymbol; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
172 |
char symbolInfo[MAX_PATH + sizeof(IMAGEHLP_SYMBOL64)]; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
173 |
pSymbol = (PIMAGEHLP_SYMBOL64)symbolInfo; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
174 |
pSymbol->MaxNameLength = MAX_PATH; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
175 |
pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64); |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
176 |
DWORD64 displacement; |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
177 |
if (_pfnSymGetSymFromAddr64(::GetCurrentProcess(), (DWORD64)addr, &displacement, pSymbol)) { |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
178 |
if (buf != NULL) { |
11483 | 179 |
if (demangle(pSymbol->Name, buf, buflen)) { |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
180 |
jio_snprintf(buf, buflen, "%s", pSymbol->Name); |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
181 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
182 |
} |
11483 | 183 |
if(offset != NULL) *offset = (int)displacement; |
184 |
return true; |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
185 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
186 |
} |
11483 | 187 |
if (buf != NULL && buflen > 0) buf[0] = '\0'; |
188 |
if (offset != NULL) *offset = -1; |
|
189 |
return false; |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
190 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
191 |
|
11483 | 192 |
bool WindowsDecoder::demangle(const char* symbol, char *buf, int buflen) { |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
193 |
return _pfnUndecorateSymbolName != NULL && |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
194 |
_pfnUndecorateSymbolName(symbol, buf, buflen, UNDNAME_COMPLETE); |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
195 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
196 |