zgu@2364: /* mikael@4153: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. zgu@2364: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. zgu@2364: * zgu@2364: * This code is free software; you can redistribute it and/or modify it zgu@2364: * under the terms of the GNU General Public License version 2 only, as zgu@2364: * published by the Free Software Foundation. zgu@2364: * zgu@2364: * This code is distributed in the hope that it will be useful, but WITHOUT zgu@2364: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or zgu@2364: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License zgu@2364: * version 2 for more details (a copy is included in the LICENSE file that zgu@2364: * accompanied this code). zgu@2364: * zgu@2364: * You should have received a copy of the GNU General Public License version zgu@2364: * 2 along with this work; if not, write to the Free Software Foundation, zgu@2364: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. zgu@2364: * zgu@2364: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA zgu@2364: * or visit www.oracle.com if you need additional information or have any zgu@2364: * questions. zgu@2364: * zgu@2364: */ zgu@2364: zgu@2364: #include "prims/jvm.h" zgu@3430: #include "utilities/decoder_elf.hpp" zgu@2364: zgu@2364: #include zgu@2364: zgu@3430: bool ElfDecoder::demangle(const char* symbol, char *buf, int buflen) { zgu@2364: int status; zgu@2364: char* result; zgu@2364: size_t size = (size_t)buflen; zgu@2364: simonis@6491: #ifdef PPC64 simonis@6491: // On PPC64 ElfDecoder::decode() may return a dot (.) prefixed name simonis@6491: // (see elfFuncDescTable.hpp for details) simonis@6491: if (symbol && *symbol == '.') symbol += 1; simonis@6491: #endif simonis@6491: zgu@2364: // Don't pass buf to __cxa_demangle. In case of the 'buf' is too small, zgu@2364: // __cxa_demangle will call system "realloc" for additional memory, which zgu@2364: // may use different malloc/realloc mechanism that allocates 'buf'. zgu@2364: if ((result = abi::__cxa_demangle(symbol, NULL, NULL, &status)) != NULL) { zgu@2364: jio_snprintf(buf, buflen, "%s", result); zgu@2364: // call c library's free zgu@2364: ::free(result); zgu@2364: return true; zgu@2364: } zgu@2364: return false; zgu@2364: } zgu@3430: