Mercurial > hg > graal-compiler
annotate src/os/aix/vm/porting_aix.cpp @ 21619:b14a218c5471
Fix in the dominator based conditional elimination for the corner case of a loop exit merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 31 May 2015 22:48:50 +0200 |
parents | 666e6ce3976c |
children |
rev | line source |
---|---|
14415
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
1 /* |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
2 * Copyright 2012, 2013 SAP AG. All rights reserved. |
666e6ce3976c
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. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
4 * |
666e6ce3976c
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 |
666e6ce3976c
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 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
8 * |
666e6ce3976c
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 |
666e6ce3976c
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 |
666e6ce3976c
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 |
666e6ce3976c
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 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
13 * accompanied this code). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
14 * |
666e6ce3976c
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 |
666e6ce3976c
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, |
666e6ce3976c
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. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
18 * |
666e6ce3976c
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 |
666e6ce3976c
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 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
21 * questions. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
22 * |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
23 */ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
24 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
25 #include "asm/assembler.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
26 #include "loadlib_aix.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
27 #include "porting_aix.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
28 #include "utilities/debug.hpp" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
29 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
30 #include <demangle.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
31 #include <sys/debug.h> |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
32 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
33 ////////////////////////////////// |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
34 // Provide implementation for dladdr based on LoadedLibraries pool and |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
35 // traceback table scan (see getFuncName). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
36 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
37 // Search traceback table in stack, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
38 // return procedure name from trace back table. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
39 #define MAX_FUNC_SEARCH_LEN 0x10000 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
40 // Any PC below this value is considered toast. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
41 #define MINIMUM_VALUE_FOR_PC ((unsigned int*)0x1024) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
42 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
43 #define PTRDIFF_BYTES(p1,p2) (((ptrdiff_t)p1) - ((ptrdiff_t)p2)) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
44 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
45 // Align a pointer without having to cast. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
46 inline char* align_ptr_up(char* ptr, intptr_t alignment) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
47 return (char*) align_size_up((intptr_t)ptr, alignment); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
48 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
49 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
50 // Trace if verbose to tty. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
51 // I use these now instead of the Xtrace system because the latter is |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
52 // not available at init time, hence worthless. Until we fix this, all |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
53 // tracing here is done with -XX:+Verbose. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
54 #define trcVerbose(fmt, ...) { \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
55 if (Verbose) { \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
56 fprintf(stderr, fmt, ##__VA_ARGS__); \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
57 fputc('\n', stderr); fflush(stderr); \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
58 } \ |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
59 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
60 #define ERRBYE(s) { trcVerbose(s); return -1; } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
61 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
62 // Unfortunately, the interface of dladdr makes the implementator |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
63 // responsible for maintaining memory for function name/library |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
64 // name. I guess this is because most OS's keep those values as part |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
65 // of the mapped executable image ready to use. On AIX, this doesn't |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
66 // work, so I have to keep the returned strings. For now, I do this in |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
67 // a primitive string map. Should this turn out to be a performance |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
68 // problem, a better hashmap has to be used. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
69 class fixed_strings { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
70 struct node { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
71 char* v; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
72 node* next; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
73 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
74 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
75 node* first; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
76 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
77 public: |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
78 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
79 fixed_strings() : first(0) {} |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
80 ~fixed_strings() { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
81 node* n = first; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
82 while (n) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
83 node* p = n; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
84 n = n->next; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
85 free(p->v); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
86 delete p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
87 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
88 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
89 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
90 char* intern(const char* s) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
91 for (node* n = first; n; n = n->next) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
92 if (strcmp(n->v, s) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
93 return n->v; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
94 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
95 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
96 node* p = new node; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
97 p->v = strdup(s); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
98 p->next = first; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
99 first = p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
100 return p->v; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
101 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
102 }; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
103 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
104 static fixed_strings dladdr_fixed_strings; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
105 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
106 // Given a code pointer, returns the function name and the displacement. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
107 // Function looks for the traceback table at the end of the function. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
108 extern "C" int getFuncName( |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
109 codeptr_t pc, // [in] program counter |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
110 char* p_name, size_t namelen, // [out] optional: function name ("" if not available) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
111 int* p_displacement, // [out] optional: displacement (-1 if not available) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
112 const struct tbtable** p_tb, // [out] optional: ptr to traceback table to get further |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
113 // information (NULL if not available) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
114 char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
115 ) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
116 struct tbtable* tb = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
117 unsigned int searchcount = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
118 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
119 // initialize output parameters |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
120 if (p_name && namelen > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
121 *p_name = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
122 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
123 if (p_errmsg && errmsglen > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
124 *p_errmsg = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
125 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
126 if (p_displacement) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
127 *p_displacement = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
128 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
129 if (p_tb) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
130 *p_tb = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
131 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
132 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
133 // weed out obvious bogus states |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
134 if (pc < MINIMUM_VALUE_FOR_PC) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
135 ERRBYE("invalid program counter"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
136 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
137 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
138 codeptr_t pc2 = pc; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
139 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
140 // make sure the pointer is word aligned. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
141 pc2 = (codeptr_t) align_ptr_up((char*)pc2, 4); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
142 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
143 // Find start of traceback table. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
144 // (starts after code, is marked by word-aligned (32bit) zeros) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
145 while ((*pc2 != NULL) && (searchcount++ < MAX_FUNC_SEARCH_LEN)) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
146 pc2++; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
147 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
148 if (*pc2 != 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
149 ERRBYE("could not find traceback table within 5000 bytes of program counter"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
150 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
151 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
152 // Set up addressability to the traceback table |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
153 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
154 tb = (struct tbtable*) (pc2 + 1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
155 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
156 // Is this really a traceback table? No way to be sure but |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
157 // some indicators we can check. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
158 if (tb->tb.lang >= 0xf && tb->tb.lang <= 0xfb) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
159 // Language specifiers, go from 0 (C) to 14 (Objective C). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
160 // According to spec, 0xf-0xfa reserved, 0xfb-0xff reserved for ibm. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
161 ERRBYE("not a traceback table"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
162 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
163 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
164 // Existence of fields in the tbtable extension are contingent upon |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
165 // specific fields in the base table. Check for their existence so |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
166 // that we can address the function name if it exists. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
167 pc2 = (codeptr_t) tb + |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
168 sizeof(struct tbtable_short)/sizeof(int); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
169 if (tb->tb.fixedparms != 0 || tb->tb.floatparms != 0) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
170 pc2++; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
171 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
172 if (tb->tb.has_tboff == TRUE) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
173 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
174 // I want to know the displacement |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
175 const unsigned int tb_offset = *pc2; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
176 codeptr_t start_of_procedure = |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
177 (codeptr_t)(((char*)tb) - 4 - tb_offset); // (-4 to omit leading 0000) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
178 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
179 // Weed out the cases where we did find the wrong traceback table. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
180 if (pc < start_of_procedure) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
181 ERRBYE("could not find (the real) traceback table within 5000 bytes of program counter"); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
182 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
183 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
184 // return the displacement |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
185 if (p_displacement) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
186 (*p_displacement) = (int) PTRDIFF_BYTES(pc, start_of_procedure); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
187 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
188 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
189 pc2++; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
190 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
191 // return -1 for displacement |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
192 if (p_displacement) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
193 (*p_displacement) = -1; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
194 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
195 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
196 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
197 if (tb->tb.int_hndl == TRUE) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
198 pc2++; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
199 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
200 if (tb->tb.has_ctl == TRUE) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
201 pc2 += (*pc2) + 1; // don't care |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
202 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
203 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
204 // return function name if it exists. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
205 // |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
206 if (p_name && namelen > 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
207 if (tb->tb.name_present) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
208 char buf[256]; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
209 const short l = MIN2<short>(*((short*)pc2), sizeof(buf) - 1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
210 memcpy(buf, (char*)pc2 + sizeof(short), l); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
211 buf[l] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
212 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
213 p_name[0] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
214 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
215 // If it is a C++ name, try and demangle it using the Demangle interface (see demangle.h). |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
216 char* rest; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
217 Name* const name = Demangle(buf, rest); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
218 if (name) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
219 const char* const demangled_name = name->Text(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
220 if (demangled_name) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
221 strncpy(p_name, demangled_name, namelen-1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
222 p_name[namelen-1] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
223 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
224 delete name; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
225 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
226 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
227 // Fallback: if demangling did not work, just provide the unmangled name. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
228 if (p_name[0] == '\0') { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
229 strncpy(p_name, buf, namelen-1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
230 p_name[namelen-1] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
231 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
232 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
233 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
234 strncpy(p_name, "<nameless function>", namelen-1); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
235 p_name[namelen-1] = '\0'; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
236 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
237 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
238 // Return traceback table, if user wants it. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
239 if (p_tb) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
240 (*p_tb) = tb; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
241 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
242 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
243 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
244 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
245 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
246 // Special implementation of dladdr for Aix based on LoadedLibraries |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
247 // Note: dladdr returns non-zero for ok, 0 for error! |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
248 // Note: dladdr is not posix, but a non-standard GNU extension. So this tries to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
249 // fulfill the contract of dladdr on Linux (see http://linux.die.net/man/3/dladdr) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
250 // Note: addr may be both an AIX function descriptor or a real code pointer |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
251 // to the entry of a function. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
252 extern "C" |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
253 int dladdr(void* addr, Dl_info* info) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
254 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
255 if (!addr) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
256 return 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
257 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
258 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
259 assert(info, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
260 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
261 int rc = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
262 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
263 const char* const ZEROSTRING = ""; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
264 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
265 // Always return a string, even if a "" one. Linux dladdr manpage |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
266 // does not say anything about returning NULL |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
267 info->dli_fname = ZEROSTRING; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
268 info->dli_sname = ZEROSTRING; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
269 info->dli_saddr = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
270 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
271 address p = (address) addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
272 const LoadedLibraryModule* lib = NULL; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
273 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
274 enum { noclue, code, data } type = noclue; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
275 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
276 trcVerbose("dladdr(%p)...", p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
277 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
278 // Note: input address may be a function. I accept both a pointer to |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
279 // the entry of a function and a pointer to the function decriptor. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
280 // (see ppc64 ABI) |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
281 lib = LoadedLibraries::find_for_text_address(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
282 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
283 type = code; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
284 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
285 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
286 if (!lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
287 // Not a pointer into any text segment. Is it a function descriptor? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
288 const FunctionDescriptor* const pfd = (const FunctionDescriptor*) p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
289 p = pfd->entry(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
290 if (p) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
291 lib = LoadedLibraries::find_for_text_address(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
292 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
293 type = code; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
294 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
295 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
296 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
297 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
298 if (!lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
299 // Neither direct code pointer nor function descriptor. A data ptr? |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
300 p = (address)addr; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
301 lib = LoadedLibraries::find_for_data_address(p); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
302 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
303 type = data; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
304 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
305 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
306 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
307 // If we did find the shared library this address belongs to (either |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
308 // code or data segment) resolve library path and, if possible, the |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
309 // symbol name. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
310 if (lib) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
311 const char* const interned_libpath = |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
312 dladdr_fixed_strings.intern(lib->get_fullpath()); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
313 if (interned_libpath) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
314 info->dli_fname = interned_libpath; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
315 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
316 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
317 if (type == code) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
318 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
319 // For code symbols resolve function name and displacement. Use |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
320 // displacement to calc start of function. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
321 char funcname[256] = ""; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
322 int displacement = 0; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
323 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
324 if (getFuncName((codeptr_t) p, funcname, sizeof(funcname), &displacement, |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
325 NULL, NULL, 0) == 0) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
326 if (funcname[0] != '\0') { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
327 const char* const interned = dladdr_fixed_strings.intern(funcname); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
328 info->dli_sname = interned; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
329 trcVerbose("... function name: %s ...", interned); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
330 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
331 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
332 // From the displacement calculate the start of the function. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
333 if (displacement != -1) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
334 info->dli_saddr = p - displacement; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
335 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
336 info->dli_saddr = p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
337 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
338 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
339 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
340 // No traceback table found. Just assume the pointer is it. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
341 info->dli_saddr = p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
342 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
343 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
344 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
345 } else if (type == data) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
346 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
347 // For data symbols. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
348 info->dli_saddr = p; |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
349 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
350 } else { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
351 ShouldNotReachHere(); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
352 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
353 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
354 rc = 1; // success: return 1 [sic] |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
355 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
356 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
357 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
358 // sanity checks. |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
359 if (rc) { |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
360 assert(info->dli_fname, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
361 assert(info->dli_sname, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
362 assert(info->dli_saddr, ""); |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
363 } |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
364 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
365 return rc; // error: return 0 [sic] |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
366 |
666e6ce3976c
8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff
changeset
|
367 } |