Path: blob/master/src/hotspot/share/utilities/decoder_elf.cpp
40949 views
/*1* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"2526#if !defined(_WINDOWS) && !defined(__APPLE__)27#include "decoder_elf.hpp"28#include "memory/allocation.inline.hpp"2930ElfDecoder::~ElfDecoder() {31if (_opened_elf_files != NULL) {32delete _opened_elf_files;33_opened_elf_files = NULL;34}35}3637bool ElfDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* filepath, bool demangle_name) {38assert(filepath, "null file path");39assert(buf != NULL && buflen > 0, "Invalid buffer");40if (has_error()) return false;41ElfFile* file = get_elf_file(filepath);42if (file == NULL) {43return false;44}4546if (!file->decode(addr, buf, buflen, offset)) {47return false;48}49if (demangle_name && (buf[0] != '\0')) {50demangle(buf, buf, buflen);51}52return true;53}5455ElfFile* ElfDecoder::get_elf_file(const char* filepath) {56ElfFile* file;5758file = _opened_elf_files;59while (file != NULL) {60if (file->same_elf_file(filepath)) {61return file;62}63file = file->next();64}6566file = new (std::nothrow)ElfFile(filepath);67if (file != NULL) {68if (_opened_elf_files != NULL) {69file->set_next(_opened_elf_files);70}71_opened_elf_files = file;72}7374return file;75}76#endif // !_WINDOWS && !__APPLE__777879