Path: blob/master/src/hotspot/os/aix/porting_aix.hpp
40930 views
/*1* Copyright (c) 2012, 2015 SAP SE. 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#ifndef OS_AIX_PORTING_AIX_HPP25#define OS_AIX_PORTING_AIX_HPP2627#include <stddef.h>2829// Header file to contain porting-relevant code which does not have a30// home anywhere else and which can not go into os_<platform>.h because31// that header is included inside the os class definition, hence all32// its content is part of the os class.3334// Aix' own version of dladdr().35// This function tries to mimick dladdr(3) on Linux36// (see http://linux.die.net/man/3/dladdr)37// dladdr(3) is not POSIX but a GNU extension, and is not available on AIX.38//39// Differences between AIX dladdr and Linux dladdr:40//41// 1) Dl_info.dli_fbase: can never work, is disabled.42// A loaded image on AIX is divided in multiple segments, at least two43// (text and data) but potentially also far more. This is because the loader may44// load each member into an own segment, as for instance happens with the libC.a45// 2) Dl_info.dli_sname: This only works for code symbols (functions); for data, a46// zero-length string is returned ("").47// 3) Dl_info.dli_saddr: For code, this will return the entry point of the function,48// not the function descriptor.4950typedef struct {51const char *dli_fname; // file path of loaded library52// void *dli_fbase;53const char *dli_sname; // symbol name; "" if not known54void *dli_saddr; // address of *entry* of function; not function descriptor;55} Dl_info;5657// Note: we export this to use it inside J2se too58#ifdef __cplusplus59extern "C"60#endif61int dladdr(void *addr, Dl_info *info);6263struct tbtable;6465class AixSymbols {66public:6768// Given a program counter, tries to locate the traceback table and returns info from69// it - e.g. function name, displacement of the pc inside the function, and the traceback70// table itself.71static bool get_function_name (72address pc, // [in] program counter73char* p_name, size_t namelen, // [out] optional: user provided buffer for the function name74int* p_displacement, // [out] optional: displacement75const struct tbtable** p_tb, // [out] optional: ptr to traceback table to get further information76bool demangle // [in] whether to demangle the name77);7879// Given a program counter, returns the name of the module (library and module) the pc points to80static bool get_module_name (81address pc, // [in] program counter82char* p_name, size_t namelen // [out] module name83);8485};8687class AixNativeCallstack {88public:89// This function can be used independently from os::init();90static void print_callstack_for_context(outputStream* st, const ucontext_t* uc,91bool demangle,92char* buf, size_t buf_size);93};9495class AixMisc {96public:97struct stackbounds_t {98address base; // high address (stack grows down)99size_t size;100};101102// Invokes pthread_getthrds_np() and returns its values. Note: values are103// not aligned to stack page sizes.104// This function can be used independently from os::init();105static bool query_stack_bounds_for_current_thread(stackbounds_t* out);106107};108109#endif // OS_AIX_PORTING_AIX_HPP110111112