Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/aix/vm/porting_aix.hpp
32284 views
/*1* Copyright 2012, 2013 SAP AG. 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 <stddef.h>2526// Header file to contain porting-relevant code which does not have a27// home anywhere else and which can not go into os_<platform>.h because28// that header is included inside the os class definition, hence all29// its content is part of the os class.3031// Aix' own version of dladdr().32// This function tries to mimick dladdr(3) on Linux33// (see http://linux.die.net/man/3/dladdr)34// dladdr(3) is not POSIX but a GNU extension, and is not available on AIX.35//36// Differences between AIX dladdr and Linux dladdr:37//38// 1) Dl_info.dli_fbase: can never work, is disabled.39// A loaded image on AIX is divided in multiple segments, at least two40// (text and data) but potentially also far more. This is because the loader may41// load each member into an own segment, as for instance happens with the libC.a42// 2) Dl_info.dli_sname: This only works for code symbols (functions); for data, a43// zero-length string is returned ("").44// 3) Dl_info.dli_saddr: For code, this will return the entry point of the function,45// not the function descriptor.4647typedef struct {48const char *dli_fname; // file path of loaded library49// void *dli_fbase;50const char *dli_sname; // symbol name; "" if not known51void *dli_saddr; // address of *entry* of function; not function descriptor;52} Dl_info;5354// Note: we export this to use it inside J2se too55#ifdef __cplusplus56extern "C"57#endif58int dladdr(void *addr, Dl_info *info);596061// The semantics in this file are thus that codeptr_t is a *real code ptr*.62// This means that any function taking codeptr_t as arguments will assume63// a real codeptr and won't handle function descriptors (eg getFuncName),64// whereas functions taking address as args will deal with function65// descriptors (eg os::dll_address_to_library_name).66typedef unsigned int* codeptr_t;6768// helper function - given a program counter, tries to locate the traceback table and69// returns info from it (like, most importantly, function name, displacement of the70// pc inside the function, and the traceback table itself.71#ifdef __cplusplus72extern "C"73#endif74int getFuncName(75codeptr_t pc, // [in] program counter76char* p_name, size_t namelen, // [out] optional: user provided buffer for the function name77int* p_displacement, // [out] optional: displacement78const struct tbtable** p_tb, // [out] optional: ptr to traceback table to get further information79char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages80);818283