Mercurial > hg > truffle
annotate src/os/windows/vm/decoder_windows.cpp @ 11361:07625ef93345
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 19 Aug 2013 14:11:10 +0200 |
parents | 63e54c37ac64 |
children | 38f750491293 |
rev | line source |
---|---|
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
1 /* |
8675
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7580
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2022
2d4762ec74af
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. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
4 * |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
8 * |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
13 * accompanied this code). |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
14 * |
2d4762ec74af
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 |
2d4762ec74af
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, |
2d4762ec74af
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. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
18 * |
2d4762ec74af
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 |
2d4762ec74af
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 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
21 * questions. |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
22 * |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
23 */ |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
24 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
26 #include "prims/jvm.h" |
8675
63e54c37ac64
8008959: Fix non-PCH build on Linux, Windows and MacOS X
simonis
parents:
7580
diff
changeset
|
27 #include "runtime/arguments.hpp" |
4803 | 28 #include "decoder_windows.hpp" |
29 | |
30 WindowsDecoder::WindowsDecoder() { | |
31 _dbghelp_handle = NULL; | |
32 _can_decode_in_vm = false; | |
33 _pfnSymGetSymFromAddr64 = NULL; | |
34 _pfnUndecorateSymbolName = NULL; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
35 |
4803 | 36 _decoder_status = no_error; |
37 initialize(); | |
38 } | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
39 |
4803 | 40 void WindowsDecoder::initialize() { |
41 if (!has_error() && _dbghelp_handle == NULL) { | |
42 HMODULE handle = ::LoadLibrary("dbghelp.dll"); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
43 if (!handle) { |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
44 _decoder_status = helper_not_found; |
4803 | 45 return; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
46 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
47 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
48 _dbghelp_handle = handle; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
49 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
50 pfn_SymSetOptions _pfnSymSetOptions = (pfn_SymSetOptions)::GetProcAddress(handle, "SymSetOptions"); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
51 pfn_SymInitialize _pfnSymInitialize = (pfn_SymInitialize)::GetProcAddress(handle, "SymInitialize"); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
52 _pfnSymGetSymFromAddr64 = (pfn_SymGetSymFromAddr64)::GetProcAddress(handle, "SymGetSymFromAddr64"); |
7580
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
53 _pfnUndecorateSymbolName = (pfn_UndecorateSymbolName)::GetProcAddress(handle, "UnDecorateSymbolName"); |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
54 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
55 if (_pfnSymSetOptions == NULL || _pfnSymInitialize == NULL || _pfnSymGetSymFromAddr64 == NULL) { |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
56 _pfnSymGetSymFromAddr64 = NULL; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
57 _pfnUndecorateSymbolName = NULL; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
58 ::FreeLibrary(handle); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
59 _dbghelp_handle = NULL; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
60 _decoder_status = helper_func_error; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
61 return; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
62 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
63 |
7580
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
64 HANDLE hProcess = ::GetCurrentProcess(); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
65 _pfnSymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_EXACT_SYMBOLS); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
66 if (!_pfnSymInitialize(hProcess, NULL, TRUE)) { |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
67 _pfnSymGetSymFromAddr64 = NULL; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
68 _pfnUndecorateSymbolName = NULL; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
69 ::FreeLibrary(handle); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
70 _dbghelp_handle = NULL; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
71 _decoder_status = helper_init_error; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
72 return; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
73 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
74 |
7580
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
75 // set pdb search paths |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
76 pfn_SymSetSearchPath _pfn_SymSetSearchPath = |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
77 (pfn_SymSetSearchPath)::GetProcAddress(handle, "SymSetSearchPath"); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
78 pfn_SymGetSearchPath _pfn_SymGetSearchPath = |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
79 (pfn_SymGetSearchPath)::GetProcAddress(handle, "SymGetSearchPath"); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
80 if (_pfn_SymSetSearchPath != NULL && _pfn_SymGetSearchPath != NULL) { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
81 char paths[MAX_PATH]; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
82 int len = sizeof(paths); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
83 if (!_pfn_SymGetSearchPath(hProcess, paths, len)) { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
84 paths[0] = '\0'; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
85 } else { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
86 // available spaces in path buffer |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
87 len -= (int)strlen(paths); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
88 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
89 |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
90 char tmp_path[MAX_PATH]; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
91 DWORD dwSize; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
92 HMODULE hJVM = ::GetModuleHandle("jvm.dll"); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
93 tmp_path[0] = '\0'; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
94 // append the path where jvm.dll is located |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
95 if (hJVM != NULL && (dwSize = ::GetModuleFileName(hJVM, tmp_path, sizeof(tmp_path))) > 0) { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
96 while (dwSize > 0 && tmp_path[dwSize] != '\\') { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
97 dwSize --; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
98 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
99 |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
100 tmp_path[dwSize] = '\0'; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
101 |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
102 if (dwSize > 0 && len > (int)dwSize + 1) { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
103 strncat(paths, os::path_separator(), 1); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
104 strncat(paths, tmp_path, dwSize); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
105 len -= dwSize + 1; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
106 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
107 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
108 |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
109 // append $JRE/bin. Arguments::get_java_home actually returns $JRE |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
110 // path |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
111 char *p = Arguments::get_java_home(); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
112 assert(p != NULL, "empty java home"); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
113 size_t java_home_len = strlen(p); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
114 if (len > (int)java_home_len + 5) { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
115 strncat(paths, os::path_separator(), 1); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
116 strncat(paths, p, java_home_len); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
117 strncat(paths, "\\bin", 4); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
118 len -= (int)(java_home_len + 5); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
119 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
120 |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
121 // append $JDK/bin path if it exists |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
122 assert(java_home_len < MAX_PATH, "Invalid path length"); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
123 // assume $JRE is under $JDK, construct $JDK/bin path and |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
124 // see if it exists or not |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
125 if (strncmp(&p[java_home_len - 3], "jre", 3) == 0) { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
126 strncpy(tmp_path, p, java_home_len - 3); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
127 tmp_path[java_home_len - 3] = '\0'; |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
128 strncat(tmp_path, "bin", 3); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
129 |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
130 // if the directory exists |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
131 DWORD dwAttrib = GetFileAttributes(tmp_path); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
132 if (dwAttrib != INVALID_FILE_ATTRIBUTES && |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
133 (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
134 // tmp_path should have the same length as java_home_len, since we only |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
135 // replaced 'jre' with 'bin' |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
136 if (len > (int)java_home_len + 1) { |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
137 strncat(paths, os::path_separator(), 1); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
138 strncat(paths, tmp_path, java_home_len); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
139 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
140 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
141 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
142 |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
143 _pfn_SymSetSearchPath(hProcess, paths); |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
144 } |
dd7248d3e151
7152671: RFE: Windows decoder should add some std dirs to the symbol search path
zgu
parents:
6842
diff
changeset
|
145 |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
146 // find out if jvm.dll contains private symbols, by decoding |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
147 // current function and comparing the result |
6258 | 148 address addr = (address)Decoder::demangle; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
149 char buf[MAX_PATH]; |
4803 | 150 if (decode(addr, buf, sizeof(buf), NULL)) { |
6258 | 151 _can_decode_in_vm = !strcmp(buf, "Decoder::demangle"); |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
152 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
153 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
154 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
155 |
4803 | 156 void WindowsDecoder::uninitialize() { |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
157 _pfnSymGetSymFromAddr64 = NULL; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
158 _pfnUndecorateSymbolName = NULL; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
159 if (_dbghelp_handle != NULL) { |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
160 ::FreeLibrary(_dbghelp_handle); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
161 } |
4803 | 162 _dbghelp_handle = NULL; |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
163 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
164 |
4803 | 165 bool WindowsDecoder::can_decode_C_frame_in_vm() const { |
166 return (!has_error() && _can_decode_in_vm); | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
167 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
168 |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
169 |
4803 | 170 bool WindowsDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* modulepath) { |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
171 if (_pfnSymGetSymFromAddr64 != NULL) { |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
172 PIMAGEHLP_SYMBOL64 pSymbol; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
173 char symbolInfo[MAX_PATH + sizeof(IMAGEHLP_SYMBOL64)]; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
174 pSymbol = (PIMAGEHLP_SYMBOL64)symbolInfo; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
175 pSymbol->MaxNameLength = MAX_PATH; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
176 pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
177 DWORD64 displacement; |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
178 if (_pfnSymGetSymFromAddr64(::GetCurrentProcess(), (DWORD64)addr, &displacement, pSymbol)) { |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
179 if (buf != NULL) { |
4803 | 180 if (demangle(pSymbol->Name, buf, buflen)) { |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
181 jio_snprintf(buf, buflen, "%s", pSymbol->Name); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
182 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
183 } |
4803 | 184 if(offset != NULL) *offset = (int)displacement; |
185 return true; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
186 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
187 } |
4803 | 188 if (buf != NULL && buflen > 0) buf[0] = '\0'; |
189 if (offset != NULL) *offset = -1; | |
190 return false; | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
191 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
192 |
4803 | 193 bool WindowsDecoder::demangle(const char* symbol, char *buf, int buflen) { |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
194 return _pfnUndecorateSymbolName != NULL && |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
195 _pfnUndecorateSymbolName(symbol, buf, buflen, UNDNAME_COMPLETE); |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
196 } |
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
197 |