2010-12-11 13:20:56 -05:00
|
|
|
/*
|
2019-04-25 10:56:31 -04:00
|
|
|
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
2010-12-11 13:20:56 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.hpp"
|
2017-10-31 11:55:09 -04:00
|
|
|
#include "jvm.h"
|
2017-11-28 21:43:45 +01:00
|
|
|
#include "memory/allocation.inline.hpp"
|
2012-02-09 10:16:26 -05:00
|
|
|
#include "runtime/os.hpp"
|
2010-12-11 13:20:56 -05:00
|
|
|
#include "utilities/decoder.hpp"
|
2012-02-09 10:16:26 -05:00
|
|
|
#include "utilities/vmError.hpp"
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2017-09-20 15:12:11 +02:00
|
|
|
#ifndef _WINDOWS
|
|
|
|
#if defined(__APPLE__)
|
2012-01-17 13:08:52 -05:00
|
|
|
#include "decoder_machO.hpp"
|
2013-08-22 09:39:54 -07:00
|
|
|
#elif defined(AIX)
|
|
|
|
#include "decoder_aix.hpp"
|
2012-01-17 13:08:52 -05:00
|
|
|
#else
|
|
|
|
#include "decoder_elf.hpp"
|
|
|
|
#endif
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2012-02-09 10:16:26 -05:00
|
|
|
AbstractDecoder* Decoder::_shared_decoder = NULL;
|
|
|
|
AbstractDecoder* Decoder::_error_handler_decoder = NULL;
|
|
|
|
NullDecoder Decoder::_do_nothing_decoder;
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2012-02-09 10:16:26 -05:00
|
|
|
AbstractDecoder* Decoder::get_shared_instance() {
|
2018-11-08 07:42:08 -05:00
|
|
|
assert(shared_decoder_lock()->owned_by_self(), "Require DecoderLock to enter");
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2012-02-09 10:16:26 -05:00
|
|
|
if (_shared_decoder == NULL) {
|
|
|
|
_shared_decoder = create_decoder();
|
2012-01-17 13:08:52 -05:00
|
|
|
}
|
2012-02-09 10:16:26 -05:00
|
|
|
return _shared_decoder;
|
|
|
|
}
|
|
|
|
|
|
|
|
AbstractDecoder* Decoder::get_error_handler_instance() {
|
|
|
|
if (_error_handler_decoder == NULL) {
|
|
|
|
_error_handler_decoder = create_decoder();
|
|
|
|
}
|
|
|
|
return _error_handler_decoder;
|
|
|
|
}
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2012-02-09 10:16:26 -05:00
|
|
|
|
|
|
|
AbstractDecoder* Decoder::create_decoder() {
|
|
|
|
AbstractDecoder* decoder;
|
2017-09-20 15:12:11 +02:00
|
|
|
#if defined (__APPLE__)
|
2012-02-09 10:16:26 -05:00
|
|
|
decoder = new (std::nothrow)MachODecoder();
|
2013-08-22 09:39:54 -07:00
|
|
|
#elif defined(AIX)
|
|
|
|
decoder = new (std::nothrow)AIXDecoder();
|
2012-01-17 13:08:52 -05:00
|
|
|
#else
|
2012-02-09 10:16:26 -05:00
|
|
|
decoder = new (std::nothrow)ElfDecoder();
|
2012-01-17 13:08:52 -05:00
|
|
|
#endif
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2012-02-09 10:16:26 -05:00
|
|
|
if (decoder == NULL || decoder->has_error()) {
|
|
|
|
if (decoder != NULL) {
|
|
|
|
delete decoder;
|
2012-01-17 13:08:52 -05:00
|
|
|
}
|
2012-02-09 10:16:26 -05:00
|
|
|
decoder = &_do_nothing_decoder;
|
2010-12-11 13:20:56 -05:00
|
|
|
}
|
2012-02-09 10:16:26 -05:00
|
|
|
return decoder;
|
2010-12-11 13:20:56 -05:00
|
|
|
}
|
|
|
|
|
2013-09-06 08:42:42 -07:00
|
|
|
Mutex* Decoder::shared_decoder_lock() {
|
2018-11-08 07:42:08 -05:00
|
|
|
assert(SharedDecoder_lock != NULL, "Just check");
|
|
|
|
return SharedDecoder_lock;
|
2013-09-06 08:42:42 -07:00
|
|
|
}
|
|
|
|
|
2015-06-16 11:58:25 +02:00
|
|
|
bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath, bool demangle) {
|
2019-10-14 08:59:12 +02:00
|
|
|
bool error_handling_thread = os::current_thread_id() == VMError::get_first_error_tid();
|
2019-05-01 07:12:14 -04:00
|
|
|
if (error_handling_thread) {
|
|
|
|
return get_error_handler_instance()->decode(addr, buf, buflen, offset, modulepath, demangle);
|
|
|
|
} else {
|
|
|
|
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
return get_shared_instance()->decode(addr, buf, buflen, offset, modulepath, demangle);
|
|
|
|
}
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2012-01-17 13:08:52 -05:00
|
|
|
}
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2012-07-30 10:25:52 -04:00
|
|
|
bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) {
|
2019-10-14 08:59:12 +02:00
|
|
|
bool error_handling_thread = os::current_thread_id() == VMError::get_first_error_tid();
|
2019-05-01 07:12:14 -04:00
|
|
|
if (error_handling_thread) {
|
|
|
|
return get_error_handler_instance()->decode(addr, buf, buflen, offset, base);
|
|
|
|
} else {
|
|
|
|
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
return get_shared_instance()->decode(addr, buf, buflen, offset, base);
|
|
|
|
}
|
2012-07-30 10:25:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-17 13:08:52 -05:00
|
|
|
bool Decoder::demangle(const char* symbol, char* buf, int buflen) {
|
2019-10-14 08:59:12 +02:00
|
|
|
bool error_handling_thread = os::current_thread_id() == VMError::get_first_error_tid();
|
2019-05-01 07:12:14 -04:00
|
|
|
if (error_handling_thread) {
|
|
|
|
return get_error_handler_instance()->demangle(symbol, buf, buflen);
|
|
|
|
} else {
|
|
|
|
MutexLocker locker(shared_decoder_lock(), Mutex::_no_safepoint_check_flag);
|
|
|
|
return get_shared_instance()->demangle(symbol, buf, buflen);
|
|
|
|
}
|
2010-12-11 13:20:56 -05:00
|
|
|
}
|
|
|
|
|
2017-09-20 15:12:11 +02:00
|
|
|
void Decoder::print_state_on(outputStream* st) {
|
2012-01-17 13:08:52 -05:00
|
|
|
}
|
2010-12-11 13:20:56 -05:00
|
|
|
|
2017-09-20 15:12:11 +02:00
|
|
|
bool Decoder::get_source_info(address pc, char* buf, size_t buflen, int* line) {
|
|
|
|
return false;
|
2010-12-11 13:20:56 -05:00
|
|
|
}
|
|
|
|
|
2017-09-20 15:12:11 +02:00
|
|
|
#endif // !_WINDOWS
|
2017-08-18 09:05:42 +02:00
|
|
|
|