Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/utilities/decoder.cpp
40949 views
1
/*
2
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2017, 2020 SAP SE. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#include "precompiled.hpp"
27
#include "jvm.h"
28
#include "memory/allocation.inline.hpp"
29
#include "utilities/decoder.hpp"
30
#include "utilities/vmError.hpp"
31
32
#ifndef _WINDOWS
33
#if defined(__APPLE__)
34
#include "decoder_machO.hpp"
35
#elif defined(AIX)
36
#include "decoder_aix.hpp"
37
#else
38
#include "decoder_elf.hpp"
39
#endif
40
41
AbstractDecoder* Decoder::_shared_decoder = NULL;
42
AbstractDecoder* Decoder::_error_handler_decoder = NULL;
43
NullDecoder Decoder::_do_nothing_decoder;
44
45
AbstractDecoder* Decoder::get_shared_instance() {
46
assert(shared_decoder_lock()->owned_by_self(), "Require DecoderLock to enter");
47
48
if (_shared_decoder == NULL) {
49
_shared_decoder = create_decoder();
50
}
51
return _shared_decoder;
52
}
53
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;
64
#if defined (__APPLE__)
65
decoder = new (std::nothrow)MachODecoder();
66
#elif defined(AIX)
67
decoder = new (std::nothrow)AIXDecoder();
68
#else
69
decoder = new (std::nothrow)ElfDecoder();
70
#endif
71
72
if (decoder == NULL || decoder->has_error()) {
73
if (decoder != NULL) {
74
delete decoder;
75
}
76
decoder = &_do_nothing_decoder;
77
}
78
return decoder;
79
}
80
81
Mutex* Decoder::shared_decoder_lock() {
82
assert(SharedDecoder_lock != NULL, "Just check");
83
return SharedDecoder_lock;
84
}
85
86
bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath, bool demangle) {
87
if (VMError::is_error_reported_in_current_thread()) {
88
return get_error_handler_instance()->decode(addr, buf, buflen, offset, modulepath, demangle);
89
} else {
90
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag);
91
return get_shared_instance()->decode(addr, buf, buflen, offset, modulepath, demangle);
92
}
93
}
94
95
bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) {
96
if (VMError::is_error_reported_in_current_thread()) {
97
return get_error_handler_instance()->decode(addr, buf, buflen, offset, base);
98
} else {
99
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag);
100
return get_shared_instance()->decode(addr, buf, buflen, offset, base);
101
}
102
}
103
104
bool Decoder::demangle(const char* symbol, char* buf, int buflen) {
105
if (VMError::is_error_reported_in_current_thread()) {
106
return get_error_handler_instance()->demangle(symbol, buf, buflen);
107
} else {
108
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag);
109
return get_shared_instance()->demangle(symbol, buf, buflen);
110
}
111
}
112
113
void Decoder::print_state_on(outputStream* st) {
114
}
115
116
bool Decoder::get_source_info(address pc, char* buf, size_t buflen, int* line) {
117
return false;
118
}
119
120
#endif // !_WINDOWS
121
122
123