Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/utilities/decoder_elf.cpp
32285 views
/*1* Copyright (c) 2011, 2012, 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"2829ElfDecoder::~ElfDecoder() {30if (_opened_elf_files != NULL) {31delete _opened_elf_files;32_opened_elf_files = NULL;33}34}3536bool ElfDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* filepath) {37assert(filepath, "null file path");38assert(buf != NULL && buflen > 0, "Invalid buffer");39if (has_error()) return false;40ElfFile* file = get_elf_file(filepath);41if (file == NULL) {42return false;43}4445if (!file->decode(addr, buf, buflen, offset)) {46return false;47}48if (buf[0] != '\0') {49demangle(buf, buf, buflen);50}51return true;52}5354ElfFile* ElfDecoder::get_elf_file(const char* filepath) {55ElfFile* file;5657file = _opened_elf_files;58while (file != NULL) {59if (file->same_elf_file(filepath)) {60return file;61}62file = file->next();63}6465file = new (std::nothrow)ElfFile(filepath);66if (file != NULL) {67if (_opened_elf_files != NULL) {68file->set_next(_opened_elf_files);69}70_opened_elf_files = file;71}7273return file;74}75#endif // !_WINDOWS && !__APPLE__767778