src/os/aix/vm/porting_aix.hpp

changeset 6465
666e6ce3976c
parent 0
f90c822e73f8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/os/aix/vm/porting_aix.hpp	Fri Sep 06 20:16:09 2013 +0200
     1.3 @@ -0,0 +1,81 @@
     1.4 +/*
     1.5 + * Copyright 2012, 2013 SAP AG. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include <stddef.h>
    1.29 +
    1.30 +// Header file to contain porting-relevant code which does not have a
    1.31 +// home anywhere else and which can not go into os_<platform>.h because
    1.32 +// that header is included inside the os class definition, hence all
    1.33 +// its content is part of the os class.
    1.34 +
    1.35 +// Aix' own version of dladdr().
    1.36 +// This function tries to mimick dladdr(3) on Linux
    1.37 +// (see http://linux.die.net/man/3/dladdr)
    1.38 +// dladdr(3) is not POSIX but a GNU extension, and is not available on AIX.
    1.39 +//
    1.40 +// Differences between AIX dladdr and Linux dladdr:
    1.41 +//
    1.42 +// 1) Dl_info.dli_fbase: can never work, is disabled.
    1.43 +//   A loaded image on AIX is divided in multiple segments, at least two
    1.44 +//   (text and data) but potentially also far more. This is because the loader may
    1.45 +//   load each member into an own segment, as for instance happens with the libC.a
    1.46 +// 2) Dl_info.dli_sname: This only works for code symbols (functions); for data, a
    1.47 +//   zero-length string is returned ("").
    1.48 +// 3) Dl_info.dli_saddr: For code, this will return the entry point of the function,
    1.49 +//   not the function descriptor.
    1.50 +
    1.51 +typedef struct {
    1.52 +  const char *dli_fname; // file path of loaded library
    1.53 +  // void *dli_fbase;
    1.54 +  const char *dli_sname; // symbol name; "" if not known
    1.55 +  void *dli_saddr;       // address of *entry* of function; not function descriptor;
    1.56 +} Dl_info;
    1.57 +
    1.58 +// Note: we export this to use it inside J2se too
    1.59 +#ifdef __cplusplus
    1.60 +extern "C"
    1.61 +#endif
    1.62 +int dladdr(void *addr, Dl_info *info);
    1.63 +
    1.64 +
    1.65 +// The semantics in this file are thus that codeptr_t is a *real code ptr*.
    1.66 +// This means that any function taking codeptr_t as arguments will assume
    1.67 +// a real codeptr and won't handle function descriptors (eg getFuncName),
    1.68 +// whereas functions taking address as args will deal with function
    1.69 +// descriptors (eg os::dll_address_to_library_name).
    1.70 +typedef unsigned int* codeptr_t;
    1.71 +
    1.72 +// helper function - given a program counter, tries to locate the traceback table and
    1.73 +// returns info from it (like, most importantly, function name, displacement of the
    1.74 +// pc inside the function, and the traceback table itself.
    1.75 +#ifdef __cplusplus
    1.76 +extern "C"
    1.77 +#endif
    1.78 +int getFuncName(
    1.79 +      codeptr_t pc,                    // [in] program counter
    1.80 +      char* p_name, size_t namelen,    // [out] optional: user provided buffer for the function name
    1.81 +      int* p_displacement,             // [out] optional: displacement
    1.82 +      const struct tbtable** p_tb,     // [out] optional: ptr to traceback table to get further information
    1.83 +      char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages
    1.84 +    );

mercurial