author | bulasevich |
Wed, 20 Nov 2019 09:29:23 +0300 | |
changeset 59143 | 1037c4d14378 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1 |
/* |
35594 | 2 |
* Copyright (c) 2012, 2015 SAP SE. All rights reserved. |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
8 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
13 |
* accompanied this code). |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
14 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
18 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
21 |
* questions. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
22 |
* |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
23 |
*/ |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
24 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47216
diff
changeset
|
25 |
#ifndef OS_AIX_PORTING_AIX_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47216
diff
changeset
|
26 |
#define OS_AIX_PORTING_AIX_HPP |
30198 | 27 |
|
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
28 |
#include <stddef.h> |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
29 |
|
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
30 |
// Header file to contain porting-relevant code which does not have a |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
31 |
// home anywhere else and which can not go into os_<platform>.h because |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
32 |
// that header is included inside the os class definition, hence all |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
33 |
// its content is part of the os class. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
34 |
|
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
35 |
// Aix' own version of dladdr(). |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
36 |
// This function tries to mimick dladdr(3) on Linux |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
37 |
// (see http://linux.die.net/man/3/dladdr) |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
38 |
// dladdr(3) is not POSIX but a GNU extension, and is not available on AIX. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
39 |
// |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
40 |
// Differences between AIX dladdr and Linux dladdr: |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
41 |
// |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
42 |
// 1) Dl_info.dli_fbase: can never work, is disabled. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
43 |
// A loaded image on AIX is divided in multiple segments, at least two |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
44 |
// (text and data) but potentially also far more. This is because the loader may |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
45 |
// load each member into an own segment, as for instance happens with the libC.a |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
46 |
// 2) Dl_info.dli_sname: This only works for code symbols (functions); for data, a |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
47 |
// zero-length string is returned (""). |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
48 |
// 3) Dl_info.dli_saddr: For code, this will return the entry point of the function, |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
49 |
// not the function descriptor. |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
50 |
|
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
51 |
typedef struct { |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
52 |
const char *dli_fname; // file path of loaded library |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
53 |
// void *dli_fbase; |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
54 |
const char *dli_sname; // symbol name; "" if not known |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
55 |
void *dli_saddr; // address of *entry* of function; not function descriptor; |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
56 |
} Dl_info; |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
57 |
|
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
58 |
// Note: we export this to use it inside J2se too |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
59 |
#ifdef __cplusplus |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
60 |
extern "C" |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
61 |
#endif |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
62 |
int dladdr(void *addr, Dl_info *info); |
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
63 |
|
33743 | 64 |
struct tbtable; |
22831
1e2ba1d62103
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
65 |
|
35515
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
66 |
class AixSymbols { |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
67 |
public: |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
68 |
|
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
69 |
// Given a program counter, tries to locate the traceback table and returns info from |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
70 |
// it - e.g. function name, displacement of the pc inside the function, and the traceback |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
71 |
// table itself. |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
72 |
static bool get_function_name ( |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
73 |
address pc, // [in] program counter |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
74 |
char* p_name, size_t namelen, // [out] optional: user provided buffer for the function name |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
75 |
int* p_displacement, // [out] optional: displacement |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
76 |
const struct tbtable** p_tb, // [out] optional: ptr to traceback table to get further information |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
77 |
bool demangle // [in] whether to demangle the name |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
78 |
); |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
79 |
|
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
80 |
// Given a program counter, returns the name of the module (library and module) the pc points to |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
81 |
static bool get_module_name ( |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
82 |
address pc, // [in] program counter |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
83 |
char* p_name, size_t namelen // [out] module name |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
84 |
); |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
85 |
|
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
86 |
}; |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
87 |
|
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
88 |
class AixNativeCallstack { |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
89 |
public: |
46576
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
90 |
// This function can be used independently from os::init(); |
35515
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
91 |
static void print_callstack_for_context(outputStream* st, const ucontext_t* uc, |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
92 |
bool demangle, |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
93 |
char* buf, size_t buf_size); |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
94 |
}; |
179755aaa4e0
8145184: [aix] Implement os::platform_print_native_stack on AIX
stuefe
parents:
33743
diff
changeset
|
95 |
|
46576
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
96 |
class AixMisc { |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
97 |
public: |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
98 |
struct stackbounds_t { |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
99 |
address base; // high address (stack grows down) |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
100 |
size_t size; |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
101 |
}; |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
102 |
|
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
103 |
// Invokes pthread_getthrds_np() and returns its values. Note: values are |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
104 |
// not aligned to stack page sizes. |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
105 |
// This function can be used independently from os::init(); |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
106 |
static bool query_stack_bounds_for_current_thread(stackbounds_t* out); |
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
107 |
|
0b817584e8a9
8182984: [aix] Make stack traces independent on successful vm initialization
stuefe
parents:
35606
diff
changeset
|
108 |
}; |
30198 | 109 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47216
diff
changeset
|
110 |
#endif // OS_AIX_PORTING_AIX_HPP |