author | mr |
Tue, 29 Oct 2019 13:52:04 -0700 | |
changeset 58850 | f4290bf1cc21 |
parent 58579 | 05dd6144d434 |
permissions | -rw-r--r-- |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
1 |
/* |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
52448
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, 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" |
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47666
diff
changeset
|
26 |
#include "jvm.h" |
48157 | 27 |
#include "memory/allocation.inline.hpp" |
11761 | 28 |
#include "runtime/os.hpp" |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
29 |
#include "utilities/decoder.hpp" |
11761 | 30 |
#include "utilities/vmError.hpp" |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
31 |
|
47666 | 32 |
#ifndef _WINDOWS |
33 |
#if defined(__APPLE__) |
|
11483 | 34 |
#include "decoder_machO.hpp" |
22827 | 35 |
#elif defined(AIX) |
36 |
#include "decoder_aix.hpp" |
|
11483 | 37 |
#else |
38 |
#include "decoder_elf.hpp" |
|
39 |
#endif |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
40 |
|
11761 | 41 |
AbstractDecoder* Decoder::_shared_decoder = NULL; |
42 |
AbstractDecoder* Decoder::_error_handler_decoder = NULL; |
|
43 |
NullDecoder Decoder::_do_nothing_decoder; |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
44 |
|
11761 | 45 |
AbstractDecoder* Decoder::get_shared_instance() { |
52448
bc5c7f63dbae
8213137: Remove static initialization of monitor/mutex instances
dholmes
parents:
48157
diff
changeset
|
46 |
assert(shared_decoder_lock()->owned_by_self(), "Require DecoderLock to enter"); |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
47 |
|
11761 | 48 |
if (_shared_decoder == NULL) { |
49 |
_shared_decoder = create_decoder(); |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
50 |
} |
11761 | 51 |
return _shared_decoder; |
52 |
} |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
53 |
|
11761 | 54 |
AbstractDecoder* Decoder::get_error_handler_instance() { |
55 |
if (_error_handler_decoder == NULL) { |
|
56 |
_error_handler_decoder = create_decoder(); |
|
57 |
} |
|
58 |
return _error_handler_decoder; |
|
59 |
} |
|
60 |
||
61 |
||
62 |
AbstractDecoder* Decoder::create_decoder() { |
|
63 |
AbstractDecoder* decoder; |
|
47666 | 64 |
#if defined (__APPLE__) |
11761 | 65 |
decoder = new (std::nothrow)MachODecoder(); |
22827 | 66 |
#elif defined(AIX) |
67 |
decoder = new (std::nothrow)AIXDecoder(); |
|
11483 | 68 |
#else |
11761 | 69 |
decoder = new (std::nothrow)ElfDecoder(); |
11483 | 70 |
#endif |
71 |
||
11761 | 72 |
if (decoder == NULL || decoder->has_error()) { |
73 |
if (decoder != NULL) { |
|
74 |
delete decoder; |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
75 |
} |
11761 | 76 |
decoder = &_do_nothing_decoder; |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
77 |
} |
11761 | 78 |
return decoder; |
11483 | 79 |
} |
80 |
||
19952
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
13963
diff
changeset
|
81 |
Mutex* Decoder::shared_decoder_lock() { |
52448
bc5c7f63dbae
8213137: Remove static initialization of monitor/mutex instances
dholmes
parents:
48157
diff
changeset
|
82 |
assert(SharedDecoder_lock != NULL, "Just check"); |
bc5c7f63dbae
8213137: Remove static initialization of monitor/mutex instances
dholmes
parents:
48157
diff
changeset
|
83 |
return SharedDecoder_lock; |
19952
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
13963
diff
changeset
|
84 |
} |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
13963
diff
changeset
|
85 |
|
31352
a6ab7217b5cc
8079473: allow demangling to be optional in dll_address_to_function_name
bdelsart
parents:
28163
diff
changeset
|
86 |
bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath, bool demangle) { |
58579
05dd6144d434
8218543: ThreadsList handling during error reporting can crash
rehn
parents:
54662
diff
changeset
|
87 |
bool error_handling_thread = os::current_thread_id() == VMError::get_first_error_tid(); |
54662 | 88 |
if (error_handling_thread) { |
89 |
return get_error_handler_instance()->decode(addr, buf, buflen, offset, modulepath, demangle); |
|
90 |
} else { |
|
91 |
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag); |
|
92 |
return get_shared_instance()->decode(addr, buf, buflen, offset, modulepath, demangle); |
|
93 |
} |
|
11483 | 94 |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
95 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
96 |
|
13340 | 97 |
bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) { |
58579
05dd6144d434
8218543: ThreadsList handling during error reporting can crash
rehn
parents:
54662
diff
changeset
|
98 |
bool error_handling_thread = os::current_thread_id() == VMError::get_first_error_tid(); |
54662 | 99 |
if (error_handling_thread) { |
100 |
return get_error_handler_instance()->decode(addr, buf, buflen, offset, base); |
|
101 |
} else { |
|
102 |
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag); |
|
103 |
return get_shared_instance()->decode(addr, buf, buflen, offset, base); |
|
104 |
} |
|
13340 | 105 |
} |
106 |
||
107 |
||
11483 | 108 |
bool Decoder::demangle(const char* symbol, char* buf, int buflen) { |
58579
05dd6144d434
8218543: ThreadsList handling during error reporting can crash
rehn
parents:
54662
diff
changeset
|
109 |
bool error_handling_thread = os::current_thread_id() == VMError::get_first_error_tid(); |
54662 | 110 |
if (error_handling_thread) { |
111 |
return get_error_handler_instance()->demangle(symbol, buf, buflen); |
|
112 |
} else { |
|
113 |
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag); |
|
114 |
return get_shared_instance()->demangle(symbol, buf, buflen); |
|
115 |
} |
|
11483 | 116 |
} |
117 |
||
47666 | 118 |
void Decoder::print_state_on(outputStream* st) { |
11483 | 119 |
} |
120 |
||
47666 | 121 |
bool Decoder::get_source_info(address pc, char* buf, size_t buflen, int* line) { |
122 |
return false; |
|
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
123 |
} |
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
diff
changeset
|
124 |
|
47666 | 125 |
#endif // !_WINDOWS |
47086
2b35673f6297
8186349: [windows] Centralize dbghelp handling code
stuefe
parents:
31352
diff
changeset
|
126 |