annotate agent/src/os/solaris/proc/saproc.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 405c634f4aaa
children f6a055fcf47d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3306
diff changeset
2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 892
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 892
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 892
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "salibproc.h"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal.h"
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
27 #ifndef SOLARIS_11_B159_OR_LATER
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
28 #include <sys/utsname.h>
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
29 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 #include <thread_db.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
31 #include <strings.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
32 #include <limits.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
33 #include <demangle.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
34 #include <stdarg.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
35 #include <stdlib.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
36 #include <errno.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 #define CHECK_EXCEPTION_(value) if(env->ExceptionOccurred()) { return value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
39 #define CHECK_EXCEPTION if(env->ExceptionOccurred()) { return;}
a61af66fc99e Initial load
duke
parents:
diff changeset
40 #define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throwNewDebuggerException(env, str); return value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
41 #define THROW_NEW_DEBUGGER_EXCEPTION(str) { throwNewDebuggerException(env, str); return;}
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 #define SYMBOL_BUF_SIZE 256
a61af66fc99e Initial load
duke
parents:
diff changeset
44 #define ERR_MSG_SIZE (PATH_MAX + 256)
a61af66fc99e Initial load
duke
parents:
diff changeset
45
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
46 // debug modes
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 static int _libsaproc_debug = 0;
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
48 #ifndef SOLARIS_11_B159_OR_LATER
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
49 static bool _Pstack_iter_debug = false;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
50
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
51 static void dprintf_2(const char* format,...) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
52 if (_Pstack_iter_debug) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
53 va_list alist;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
54
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
55 va_start(alist, format);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
56 fputs("Pstack_iter DEBUG: ", stderr);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
57 vfprintf(stderr, format, alist);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
58 va_end(alist);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
59 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
60 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
61 #endif // !SOLARIS_11_B159_OR_LATER
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 static void print_debug(const char* format,...) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 if (_libsaproc_debug) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 va_list alist;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 va_start(alist, format);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 fputs("libsaproc DEBUG: ", stderr);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 vfprintf(stderr, format, alist);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 va_end(alist);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 struct Debugger {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 JNIEnv* env;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 jobject this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 };
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 struct DebuggerWithObject : Debugger {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 jobject obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 };
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 struct DebuggerWith2Objects : DebuggerWithObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 jobject obj2;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 };
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
88 * Portions of user thread level detail gathering code is from pstack source
a61af66fc99e Initial load
duke
parents:
diff changeset
89 * code. See pstack.c in Solaris 2.8 user commands source code.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 */
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 static void throwNewDebuggerException(JNIEnv* env, const char* errMsg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 env->ThrowNew(env->FindClass("sun/jvm/hotspot/debugger/DebuggerException"), errMsg);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // JNI ids for some fields, methods
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // libproc handler pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
99 static jfieldID p_ps_prochandle_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // libthread.so dlopen handle, thread agent ptr and function pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
102 static jfieldID libthread_db_handle_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 static jfieldID p_td_thragent_t_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 static jfieldID p_td_init_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 static jfieldID p_td_ta_new_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 static jfieldID p_td_ta_delete_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 static jfieldID p_td_ta_thr_iter_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 static jfieldID p_td_thr_get_info_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 static jfieldID p_td_ta_map_id2thr_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 static jfieldID p_td_thr_getgregs_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // reg index fields
a61af66fc99e Initial load
duke
parents:
diff changeset
113 static jfieldID pcRegIndex_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 static jfieldID fpRegIndex_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // part of the class sharing workaround
a61af66fc99e Initial load
duke
parents:
diff changeset
117 static jfieldID classes_jsa_fd_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 static jfieldID p_file_map_header_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // method ids
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 static jmethodID getThreadForThreadId_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 static jmethodID createSenderFrame_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 static jmethodID createLoadObject_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 static jmethodID createClosestSymbol_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 static jmethodID listAdd_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
129 * Functions we need from libthread_db
a61af66fc99e Initial load
duke
parents:
diff changeset
130 */
a61af66fc99e Initial load
duke
parents:
diff changeset
131 typedef td_err_e
a61af66fc99e Initial load
duke
parents:
diff changeset
132 (*p_td_init_t)(void);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 typedef td_err_e
a61af66fc99e Initial load
duke
parents:
diff changeset
134 (*p_td_ta_new_t)(void *, td_thragent_t **);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 typedef td_err_e
a61af66fc99e Initial load
duke
parents:
diff changeset
136 (*p_td_ta_delete_t)(td_thragent_t *);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 typedef td_err_e
a61af66fc99e Initial load
duke
parents:
diff changeset
138 (*p_td_ta_thr_iter_t)(const td_thragent_t *, td_thr_iter_f *, void *,
a61af66fc99e Initial load
duke
parents:
diff changeset
139 td_thr_state_e, int, sigset_t *, unsigned);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 typedef td_err_e
a61af66fc99e Initial load
duke
parents:
diff changeset
141 (*p_td_thr_get_info_t)(const td_thrhandle_t *, td_thrinfo_t *);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 typedef td_err_e
a61af66fc99e Initial load
duke
parents:
diff changeset
143 (*p_td_ta_map_id2thr_t)(const td_thragent_t *, thread_t, td_thrhandle_t *);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 typedef td_err_e
a61af66fc99e Initial load
duke
parents:
diff changeset
145 (*p_td_thr_getgregs_t)(const td_thrhandle_t *, prgregset_t);
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 static void
a61af66fc99e Initial load
duke
parents:
diff changeset
148 clear_libthread_db_ptrs(JNIEnv* env, jobject this_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // release libthread_db agent, if we had created
a61af66fc99e Initial load
duke
parents:
diff changeset
150 p_td_ta_delete_t p_td_ta_delete = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 p_td_ta_delete = (p_td_ta_delete_t) env->GetLongField(this_obj, p_td_ta_delete_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 td_thragent_t *p_td_thragent_t = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 p_td_thragent_t = (td_thragent_t*) env->GetLongField(this_obj, p_td_thragent_t_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
155 if (p_td_thragent_t != 0 && p_td_ta_delete != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 p_td_ta_delete(p_td_thragent_t);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // dlclose libthread_db.so
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void* libthread_db_handle = (void*) env->GetLongField(this_obj, libthread_db_handle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (libthread_db_handle != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 dlclose(libthread_db_handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 env->SetLongField(this_obj, libthread_db_handle_ID, (jlong)0);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 env->SetLongField(this_obj, p_td_init_ID, (jlong)0);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 env->SetLongField(this_obj, p_td_ta_new_ID, (jlong)0);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 env->SetLongField(this_obj, p_td_ta_delete_ID, (jlong)0);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 env->SetLongField(this_obj, p_td_ta_thr_iter_ID, (jlong)0);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 env->SetLongField(this_obj, p_td_thr_get_info_ID, (jlong)0);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 env->SetLongField(this_obj, p_td_ta_map_id2thr_ID, (jlong)0);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 env->SetLongField(this_obj, p_td_thr_getgregs_ID, (jlong)0);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 static void detach_internal(JNIEnv* env, jobject this_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // clear libthread_db stuff
a61af66fc99e Initial load
duke
parents:
diff changeset
178 clear_libthread_db_ptrs(env, this_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // release ptr to ps_prochandle
a61af66fc99e Initial load
duke
parents:
diff changeset
181 jlong p_ps_prochandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 if (p_ps_prochandle != 0L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 Prelease((struct ps_prochandle*) p_ps_prochandle, PRELEASE_CLEAR);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // part of the class sharing workaround
a61af66fc99e Initial load
duke
parents:
diff changeset
188 int classes_jsa_fd = env->GetIntField(this_obj, classes_jsa_fd_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (classes_jsa_fd != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 close(classes_jsa_fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 struct FileMapHeader* pheader = (struct FileMapHeader*) env->GetLongField(this_obj, p_file_map_header_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if (pheader != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 free(pheader);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Is it okay to ignore libthread_db failure? Set env var to ignore
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // libthread_db failure. You can still debug, but will miss threads
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // related functionality.
a61af66fc99e Initial load
duke
parents:
diff changeset
201 static bool sa_ignore_threaddb = (getenv("SA_IGNORE_THREADDB") != 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 #define HANDLE_THREADDB_FAILURE(msg) \
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (sa_ignore_threaddb) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
205 printf("libsaproc WARNING: %s\n", msg); \
a61af66fc99e Initial load
duke
parents:
diff changeset
206 return; \
a61af66fc99e Initial load
duke
parents:
diff changeset
207 } else { \
a61af66fc99e Initial load
duke
parents:
diff changeset
208 THROW_NEW_DEBUGGER_EXCEPTION(msg); \
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 #define HANDLE_THREADDB_FAILURE_(msg, ret) \
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (sa_ignore_threaddb) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
213 printf("libsaproc WARNING: %s\n", msg); \
a61af66fc99e Initial load
duke
parents:
diff changeset
214 return ret; \
a61af66fc99e Initial load
duke
parents:
diff changeset
215 } else { \
a61af66fc99e Initial load
duke
parents:
diff changeset
216 THROW_NEW_DEBUGGER_EXCEPTION_(msg, ret); \
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 static const char * alt_root = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 static int alt_root_len = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 #define SA_ALTROOT "SA_ALTROOT"
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 static void init_alt_root() {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 if (alt_root_len == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 alt_root = getenv(SA_ALTROOT);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (alt_root)
a61af66fc99e Initial load
duke
parents:
diff changeset
228 alt_root_len = strlen(alt_root);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 else
a61af66fc99e Initial load
duke
parents:
diff changeset
230 alt_root_len = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
892
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
234 // This function is a complete substitute for the open system call
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
235 // since it's also used to override open calls from libproc to
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
236 // implement as a pathmap style facility for the SA. If libproc
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
237 // starts using other interfaces then this might have to extended to
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
238 // cover other calls.
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
239 extern "C" int libsaproc_open(const char * name, int oflag, ...) {
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
240 if (oflag == O_RDONLY) {
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
241 init_alt_root();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
242
892
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
243 if (_libsaproc_debug) {
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
244 printf("libsaproc DEBUG: libsaproc_open %s\n", name);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
892
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
247 if (alt_root_len > 0) {
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
248 int fd = -1;
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
249 char alt_path[PATH_MAX+1];
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
250
0
a61af66fc99e Initial load
duke
parents:
diff changeset
251 strcpy(alt_path, alt_root);
892
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
252 strcat(alt_path, name);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
253 fd = open(alt_path, O_RDONLY);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 if (fd >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 if (_libsaproc_debug) {
892
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
256 printf("libsaproc DEBUG: libsaproc_open substituted %s\n", alt_path);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return fd;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
892
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
260
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
261 if (strrchr(name, '/')) {
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
262 strcpy(alt_path, alt_root);
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
263 strcat(alt_path, strrchr(name, '/'));
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
264 fd = open(alt_path, O_RDONLY);
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
265 if (fd >= 0) {
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
266 if (_libsaproc_debug) {
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
267 printf("libsaproc DEBUG: libsaproc_open substituted %s\n", alt_path);
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
268 }
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
269 return fd;
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
270 }
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
271 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
892
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
274
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
275 {
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
276 mode_t mode;
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
277 va_list ap;
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
278 va_start(ap, oflag);
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
279 mode = va_arg(ap, mode_t);
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
280 va_end(ap);
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
281
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
282 return open(name, oflag, mode);
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
283 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 static void * pathmap_dlopen(const char * name, int mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 init_alt_root();
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 if (_libsaproc_debug) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 printf("libsaproc DEBUG: pathmap_dlopen %s\n", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 void * handle = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
295 if (alt_root_len > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 char alt_path[PATH_MAX+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
297 strcpy(alt_path, alt_root);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 strcat(alt_path, name);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 handle = dlopen(alt_path, mode);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 if (_libsaproc_debug && handle) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (handle == NULL && strrchr(name, '/')) {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 strcpy(alt_path, alt_root);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 strcat(alt_path, strrchr(name, '/'));
a61af66fc99e Initial load
duke
parents:
diff changeset
307 handle = dlopen(alt_path, mode);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if (_libsaproc_debug && handle) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313 if (handle == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 handle = dlopen(name, mode);
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316 if (_libsaproc_debug) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 printf("libsaproc DEBUG: pathmap_dlopen %s return 0x%x\n", name, handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319 return handle;
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // libproc and libthread_db callback functions
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 extern "C" {
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 static int
a61af66fc99e Initial load
duke
parents:
diff changeset
327 init_libthread_db_ptrs(void *cd, const prmap_t *pmp, const char *object_name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 Debugger* dbg = (Debugger*) cd;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 JNIEnv* env = dbg->env;
a61af66fc99e Initial load
duke
parents:
diff changeset
330 jobject this_obj = dbg->this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
331 struct ps_prochandle* ph = (struct ps_prochandle*) env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 char *s1 = 0, *s2 = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
334 char libthread_db[PATH_MAX];
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 if (strstr(object_name, "/libthread.so.") == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
337 return (0);
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
340 * We found a libthread.
a61af66fc99e Initial load
duke
parents:
diff changeset
341 * dlopen() the matching libthread_db and get the thread agent handle.
a61af66fc99e Initial load
duke
parents:
diff changeset
342 */
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if (Pstatus(ph)->pr_dmodel == PR_MODEL_NATIVE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 (void) strcpy(libthread_db, object_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
345 s1 = (char*) strstr(object_name, ".so.");
a61af66fc99e Initial load
duke
parents:
diff changeset
346 s2 = (char*) strstr(libthread_db, ".so.");
a61af66fc99e Initial load
duke
parents:
diff changeset
347 (void) strcpy(s2, "_db");
a61af66fc99e Initial load
duke
parents:
diff changeset
348 s2 += 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
349 (void) strcpy(s2, s1);
a61af66fc99e Initial load
duke
parents:
diff changeset
350 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
352 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
353 * The victim process is 32-bit, we are 64-bit.
a61af66fc99e Initial load
duke
parents:
diff changeset
354 * We have to find the 64-bit version of libthread_db
a61af66fc99e Initial load
duke
parents:
diff changeset
355 * that matches the victim's 32-bit version of libthread.
a61af66fc99e Initial load
duke
parents:
diff changeset
356 */
a61af66fc99e Initial load
duke
parents:
diff changeset
357 (void) strcpy(libthread_db, object_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
358 s1 = (char*) strstr(object_name, "/libthread.so.");
a61af66fc99e Initial load
duke
parents:
diff changeset
359 s2 = (char*) strstr(libthread_db, "/libthread.so.");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 (void) strcpy(s2, "/64");
a61af66fc99e Initial load
duke
parents:
diff changeset
361 s2 += 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 (void) strcpy(s2, s1);
a61af66fc99e Initial load
duke
parents:
diff changeset
363 s1 = (char*) strstr(s1, ".so.");
a61af66fc99e Initial load
duke
parents:
diff changeset
364 s2 = (char*) strstr(s2, ".so.");
a61af66fc99e Initial load
duke
parents:
diff changeset
365 (void) strcpy(s2, "_db");
a61af66fc99e Initial load
duke
parents:
diff changeset
366 s2 += 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
367 (void) strcpy(s2, s1);
a61af66fc99e Initial load
duke
parents:
diff changeset
368 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
369 return (0);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 #endif /* _LP64 */
a61af66fc99e Initial load
duke
parents:
diff changeset
371 }
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 void* libthread_db_handle = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
374 if ((libthread_db_handle = pathmap_dlopen(libthread_db, RTLD_LAZY|RTLD_LOCAL)) == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
375 char errMsg[PATH_MAX + 256];
a61af66fc99e Initial load
duke
parents:
diff changeset
376 sprintf(errMsg, "Can't load %s!", libthread_db);
a61af66fc99e Initial load
duke
parents:
diff changeset
377 HANDLE_THREADDB_FAILURE_(errMsg, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
378 }
a61af66fc99e Initial load
duke
parents:
diff changeset
379 env->SetLongField(this_obj, libthread_db_handle_ID, (jlong)(uintptr_t)libthread_db_handle);
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 void* tmpPtr = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
382 tmpPtr = dlsym(libthread_db_handle, "td_init");
a61af66fc99e Initial load
duke
parents:
diff changeset
383 if (tmpPtr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
384 HANDLE_THREADDB_FAILURE_("dlsym failed on td_init!", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386 env->SetLongField(this_obj, p_td_init_ID, (jlong)(uintptr_t) tmpPtr);
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 tmpPtr =dlsym(libthread_db_handle, "td_ta_new");
a61af66fc99e Initial load
duke
parents:
diff changeset
389 if (tmpPtr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
390 HANDLE_THREADDB_FAILURE_("dlsym failed on td_ta_new!", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392 env->SetLongField(this_obj, p_td_ta_new_ID, (jlong)(uintptr_t) tmpPtr);
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394 tmpPtr = dlsym(libthread_db_handle, "td_ta_delete");
a61af66fc99e Initial load
duke
parents:
diff changeset
395 if (tmpPtr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 HANDLE_THREADDB_FAILURE_("dlsym failed on td_ta_delete!", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
398 env->SetLongField(this_obj, p_td_ta_delete_ID, (jlong)(uintptr_t) tmpPtr);
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 tmpPtr = dlsym(libthread_db_handle, "td_ta_thr_iter");
a61af66fc99e Initial load
duke
parents:
diff changeset
401 if (tmpPtr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
402 HANDLE_THREADDB_FAILURE_("dlsym failed on td_ta_thr_iter!", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404 env->SetLongField(this_obj, p_td_ta_thr_iter_ID, (jlong)(uintptr_t) tmpPtr);
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406 tmpPtr = dlsym(libthread_db_handle, "td_thr_get_info");
a61af66fc99e Initial load
duke
parents:
diff changeset
407 if (tmpPtr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 HANDLE_THREADDB_FAILURE_("dlsym failed on td_thr_get_info!", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
410 env->SetLongField(this_obj, p_td_thr_get_info_ID, (jlong)(uintptr_t) tmpPtr);
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412 tmpPtr = dlsym(libthread_db_handle, "td_ta_map_id2thr");
a61af66fc99e Initial load
duke
parents:
diff changeset
413 if (tmpPtr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
414 HANDLE_THREADDB_FAILURE_("dlsym failed on td_ta_map_id2thr!", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416 env->SetLongField(this_obj, p_td_ta_map_id2thr_ID, (jlong)(uintptr_t) tmpPtr);
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 tmpPtr = dlsym(libthread_db_handle, "td_thr_getgregs");
a61af66fc99e Initial load
duke
parents:
diff changeset
419 if (tmpPtr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 HANDLE_THREADDB_FAILURE_("dlsym failed on td_thr_getgregs!", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
a61af66fc99e Initial load
duke
parents:
diff changeset
422 env->SetLongField(this_obj, p_td_thr_getgregs_ID, (jlong)(uintptr_t) tmpPtr);
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
425 }
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 static int
a61af66fc99e Initial load
duke
parents:
diff changeset
428 fill_thread_list(const td_thrhandle_t *p_td_thragent_t, void* cd) {
a61af66fc99e Initial load
duke
parents:
diff changeset
429 DebuggerWithObject* dbgo = (DebuggerWithObject*) cd;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 JNIEnv* env = dbgo->env;
a61af66fc99e Initial load
duke
parents:
diff changeset
431 jobject this_obj = dbgo->this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
432 jobject list = dbgo->obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 td_thrinfo_t thrinfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
435 p_td_thr_get_info_t p_td_thr_get_info = (p_td_thr_get_info_t) env->GetLongField(this_obj, p_td_thr_get_info_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 if (p_td_thr_get_info(p_td_thragent_t, &thrinfo) != TD_OK)
a61af66fc99e Initial load
duke
parents:
diff changeset
438 return (0);
a61af66fc99e Initial load
duke
parents:
diff changeset
439
a61af66fc99e Initial load
duke
parents:
diff changeset
440 jobject threadProxy = env->CallObjectMethod(this_obj, getThreadForThreadId_ID, (jlong)(uintptr_t) thrinfo.ti_tid);
a61af66fc99e Initial load
duke
parents:
diff changeset
441 CHECK_EXCEPTION_(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
442 env->CallBooleanMethod(list, listAdd_ID, threadProxy);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 CHECK_EXCEPTION_(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
444 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
445 }
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 static int
a61af66fc99e Initial load
duke
parents:
diff changeset
448 fill_load_object_list(void *cd, const prmap_t* pmp, const char* obj_name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 if (obj_name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 DebuggerWithObject* dbgo = (DebuggerWithObject*) cd;
a61af66fc99e Initial load
duke
parents:
diff changeset
452 JNIEnv* env = dbgo->env;
a61af66fc99e Initial load
duke
parents:
diff changeset
453 jobject this_obj = dbgo->this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 jobject list = dbgo->obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
455
a61af66fc99e Initial load
duke
parents:
diff changeset
456 jstring objectName = env->NewStringUTF(obj_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
457 CHECK_EXCEPTION_(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
458
a61af66fc99e Initial load
duke
parents:
diff changeset
459 jlong mapSize = (jlong) pmp->pr_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
460 jobject sharedObject = env->CallObjectMethod(this_obj, createLoadObject_ID,
a61af66fc99e Initial load
duke
parents:
diff changeset
461 objectName, mapSize, (jlong)(uintptr_t)pmp->pr_vaddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
462 CHECK_EXCEPTION_(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
463 env->CallBooleanMethod(list, listAdd_ID, sharedObject);
a61af66fc99e Initial load
duke
parents:
diff changeset
464 CHECK_EXCEPTION_(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
466
a61af66fc99e Initial load
duke
parents:
diff changeset
467 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
469
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
470 // Pstack_iter() proc_stack_f callback prior to Nevada-B159
0
a61af66fc99e Initial load
duke
parents:
diff changeset
471 static int
a61af66fc99e Initial load
duke
parents:
diff changeset
472 fill_cframe_list(void *cd, const prgregset_t regs, uint_t argc, const long *argv) {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 DebuggerWith2Objects* dbgo2 = (DebuggerWith2Objects*) cd;
a61af66fc99e Initial load
duke
parents:
diff changeset
474 JNIEnv* env = dbgo2->env;
a61af66fc99e Initial load
duke
parents:
diff changeset
475 jobject this_obj = dbgo2->this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
476 jobject curFrame = dbgo2->obj2;
a61af66fc99e Initial load
duke
parents:
diff changeset
477
a61af66fc99e Initial load
duke
parents:
diff changeset
478 jint pcRegIndex = env->GetIntField(this_obj, pcRegIndex_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 jint fpRegIndex = env->GetIntField(this_obj, fpRegIndex_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 jlong pc = (jlong) (uintptr_t) regs[pcRegIndex];
a61af66fc99e Initial load
duke
parents:
diff changeset
482 jlong fp = (jlong) (uintptr_t) regs[fpRegIndex];
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 dbgo2->obj2 = env->CallObjectMethod(this_obj, createSenderFrame_ID,
a61af66fc99e Initial load
duke
parents:
diff changeset
485 curFrame, pc, fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
486 CHECK_EXCEPTION_(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
487 if (dbgo2->obj == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
488 dbgo2->obj = dbgo2->obj2;
a61af66fc99e Initial load
duke
parents:
diff changeset
489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
490 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
491 }
a61af66fc99e Initial load
duke
parents:
diff changeset
492
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
493 // Pstack_iter() proc_stack_f callback in Nevada-B159 or later
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
494 /*ARGSUSED*/
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
495 static int
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
496 wrapper_fill_cframe_list(void *cd, const prgregset_t regs, uint_t argc,
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
497 const long *argv, int frame_flags, int sig) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
498 return(fill_cframe_list(cd, regs, argc, argv));
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
499 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
500
0
a61af66fc99e Initial load
duke
parents:
diff changeset
501 // part of the class sharing workaround
a61af66fc99e Initial load
duke
parents:
diff changeset
502
a61af66fc99e Initial load
duke
parents:
diff changeset
503 // FIXME: !!HACK ALERT!!
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // The format of sharing achive file header is needed to read shared heap
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // file mappings. For now, I am hard coding portion of FileMapHeader here.
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // Refer to filemap.hpp.
a61af66fc99e Initial load
duke
parents:
diff changeset
508
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // FileMapHeader describes the shared space data in the file to be
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // mapped. This structure gets written to a file. It is not a class, so
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // that the compilers don't add any compiler-private data to it.
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 const int NUM_SHARED_MAPS = 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
514
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // Refer to FileMapInfo::_current_version in filemap.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
516 const int CURRENT_ARCHIVE_VERSION = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
517
a61af66fc99e Initial load
duke
parents:
diff changeset
518 struct FileMapHeader {
a61af66fc99e Initial load
duke
parents:
diff changeset
519 int _magic; // identify file type.
a61af66fc99e Initial load
duke
parents:
diff changeset
520 int _version; // (from enum, above.)
a61af66fc99e Initial load
duke
parents:
diff changeset
521 size_t _alignment; // how shared archive should be aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
522
a61af66fc99e Initial load
duke
parents:
diff changeset
523
a61af66fc99e Initial load
duke
parents:
diff changeset
524 struct space_info {
a61af66fc99e Initial load
duke
parents:
diff changeset
525 int _file_offset; // sizeof(this) rounded to vm page size
a61af66fc99e Initial load
duke
parents:
diff changeset
526 char* _base; // copy-on-write base address
a61af66fc99e Initial load
duke
parents:
diff changeset
527 size_t _capacity; // for validity checking
a61af66fc99e Initial load
duke
parents:
diff changeset
528 size_t _used; // for setting space top on read
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 bool _read_only; // read only space?
a61af66fc99e Initial load
duke
parents:
diff changeset
531 bool _allow_exec; // executable code in space?
a61af66fc99e Initial load
duke
parents:
diff changeset
532
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3306
diff changeset
533 } _space[NUM_SHARED_MAPS];
0
a61af66fc99e Initial load
duke
parents:
diff changeset
534
a61af66fc99e Initial load
duke
parents:
diff changeset
535 // Ignore the rest of the FileMapHeader. We don't need those fields here.
a61af66fc99e Initial load
duke
parents:
diff changeset
536 };
a61af66fc99e Initial load
duke
parents:
diff changeset
537
a61af66fc99e Initial load
duke
parents:
diff changeset
538 static bool
529
8db2b3e46c38 6786948: SA on core file fails on solaris-amd64 if vm started with -XX:+StartAttachListener
swamyv
parents: 0
diff changeset
539 read_jboolean(struct ps_prochandle* ph, psaddr_t addr, jboolean* pvalue) {
8db2b3e46c38 6786948: SA on core file fails on solaris-amd64 if vm started with -XX:+StartAttachListener
swamyv
parents: 0
diff changeset
540 jboolean i;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
541 if (ps_pread(ph, addr, &i, sizeof(i)) == PS_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
542 *pvalue = i;
a61af66fc99e Initial load
duke
parents:
diff changeset
543 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
544 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
545 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
546 }
a61af66fc99e Initial load
duke
parents:
diff changeset
547 }
a61af66fc99e Initial load
duke
parents:
diff changeset
548
a61af66fc99e Initial load
duke
parents:
diff changeset
549 static bool
a61af66fc99e Initial load
duke
parents:
diff changeset
550 read_pointer(struct ps_prochandle* ph, psaddr_t addr, uintptr_t* pvalue) {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 uintptr_t uip;
a61af66fc99e Initial load
duke
parents:
diff changeset
552 if (ps_pread(ph, addr, &uip, sizeof(uip)) == PS_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
553 *pvalue = uip;
a61af66fc99e Initial load
duke
parents:
diff changeset
554 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
555 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
556 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
557 }
a61af66fc99e Initial load
duke
parents:
diff changeset
558 }
a61af66fc99e Initial load
duke
parents:
diff changeset
559
a61af66fc99e Initial load
duke
parents:
diff changeset
560 static bool
a61af66fc99e Initial load
duke
parents:
diff changeset
561 read_string(struct ps_prochandle* ph, psaddr_t addr, char* buf, size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
562 char ch = ' ';
a61af66fc99e Initial load
duke
parents:
diff changeset
563 size_t i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 while (ch != '\0') {
a61af66fc99e Initial load
duke
parents:
diff changeset
566 if (ps_pread(ph, addr, &ch, sizeof(ch)) != PS_OK)
a61af66fc99e Initial load
duke
parents:
diff changeset
567 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 if (i < size - 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
570 buf[i] = ch;
a61af66fc99e Initial load
duke
parents:
diff changeset
571 } else { // smaller buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
572 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
573 }
a61af66fc99e Initial load
duke
parents:
diff changeset
574
a61af66fc99e Initial load
duke
parents:
diff changeset
575 i++; addr++;
a61af66fc99e Initial load
duke
parents:
diff changeset
576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
577
a61af66fc99e Initial load
duke
parents:
diff changeset
578 buf[i] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
579 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
580 }
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 #define USE_SHARED_SPACES_SYM "UseSharedSpaces"
a61af66fc99e Initial load
duke
parents:
diff changeset
583 // mangled symbol name for Arguments::SharedArchivePath
a61af66fc99e Initial load
duke
parents:
diff changeset
584 #define SHARED_ARCHIVE_PATH_SYM "__1cJArgumentsRSharedArchivePath_"
a61af66fc99e Initial load
duke
parents:
diff changeset
585
a61af66fc99e Initial load
duke
parents:
diff changeset
586 static int
a61af66fc99e Initial load
duke
parents:
diff changeset
587 init_classsharing_workaround(void *cd, const prmap_t* pmap, const char* obj_name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
588 Debugger* dbg = (Debugger*) cd;
a61af66fc99e Initial load
duke
parents:
diff changeset
589 JNIEnv* env = dbg->env;
a61af66fc99e Initial load
duke
parents:
diff changeset
590 jobject this_obj = dbg->this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
591 const char* jvm_name = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
592 if ((jvm_name = strstr(obj_name, "libjvm.so")) != NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
593 (jvm_name = strstr(obj_name, "libjvm_g.so")) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
594 jvm_name = obj_name;
a61af66fc99e Initial load
duke
parents:
diff changeset
595 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
596 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
597 }
a61af66fc99e Initial load
duke
parents:
diff changeset
598
a61af66fc99e Initial load
duke
parents:
diff changeset
599 struct ps_prochandle* ph = (struct ps_prochandle*) env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
600
a61af66fc99e Initial load
duke
parents:
diff changeset
601 // initialize classes[_g].jsa file descriptor field.
a61af66fc99e Initial load
duke
parents:
diff changeset
602 dbg->env->SetIntField(this_obj, classes_jsa_fd_ID, -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
603
a61af66fc99e Initial load
duke
parents:
diff changeset
604 // check whether class sharing is on by reading variable "UseSharedSpaces"
a61af66fc99e Initial load
duke
parents:
diff changeset
605 psaddr_t useSharedSpacesAddr = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
606 ps_pglobal_lookup(ph, jvm_name, USE_SHARED_SPACES_SYM, &useSharedSpacesAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
607 if (useSharedSpacesAddr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
608 THROW_NEW_DEBUGGER_EXCEPTION_("can't find 'UseSharedSpaces' flag\n", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
610
a61af66fc99e Initial load
duke
parents:
diff changeset
611 // read the value of the flag "UseSharedSpaces"
529
8db2b3e46c38 6786948: SA on core file fails on solaris-amd64 if vm started with -XX:+StartAttachListener
swamyv
parents: 0
diff changeset
612 // Since hotspot types are not available to build this library. So
8db2b3e46c38 6786948: SA on core file fails on solaris-amd64 if vm started with -XX:+StartAttachListener
swamyv
parents: 0
diff changeset
613 // equivalent type "jboolean" is used to read the value of "UseSharedSpaces"
8db2b3e46c38 6786948: SA on core file fails on solaris-amd64 if vm started with -XX:+StartAttachListener
swamyv
parents: 0
diff changeset
614 // which is same as hotspot type "bool".
8db2b3e46c38 6786948: SA on core file fails on solaris-amd64 if vm started with -XX:+StartAttachListener
swamyv
parents: 0
diff changeset
615 jboolean value = 0;
8db2b3e46c38 6786948: SA on core file fails on solaris-amd64 if vm started with -XX:+StartAttachListener
swamyv
parents: 0
diff changeset
616 if (read_jboolean(ph, useSharedSpacesAddr, &value) != true) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
617 THROW_NEW_DEBUGGER_EXCEPTION_("can't read 'UseSharedSpaces' flag", 1);
529
8db2b3e46c38 6786948: SA on core file fails on solaris-amd64 if vm started with -XX:+StartAttachListener
swamyv
parents: 0
diff changeset
618 } else if ((int)value == 0) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
619 print_debug("UseSharedSpaces is false, assuming -Xshare:off!\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
620 return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
622
a61af66fc99e Initial load
duke
parents:
diff changeset
623 char classes_jsa[PATH_MAX];
a61af66fc99e Initial load
duke
parents:
diff changeset
624 psaddr_t sharedArchivePathAddrAddr = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
625 ps_pglobal_lookup(ph, jvm_name, SHARED_ARCHIVE_PATH_SYM, &sharedArchivePathAddrAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
626 if (sharedArchivePathAddrAddr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
627 print_debug("can't find symbol 'Arguments::SharedArchivePath'\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
628 THROW_NEW_DEBUGGER_EXCEPTION_("can't get shared archive path from debuggee", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
629 }
a61af66fc99e Initial load
duke
parents:
diff changeset
630
a61af66fc99e Initial load
duke
parents:
diff changeset
631 uintptr_t sharedArchivePathAddr = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
632 if (read_pointer(ph, sharedArchivePathAddrAddr, &sharedArchivePathAddr) != true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
633 print_debug("can't find read pointer 'Arguments::SharedArchivePath'\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
634 THROW_NEW_DEBUGGER_EXCEPTION_("can't get shared archive path from debuggee", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
636
a61af66fc99e Initial load
duke
parents:
diff changeset
637 if (read_string(ph, (psaddr_t)sharedArchivePathAddr, classes_jsa, sizeof(classes_jsa)) != true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
638 print_debug("can't find read 'Arguments::SharedArchivePath' value\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
639 THROW_NEW_DEBUGGER_EXCEPTION_("can't get shared archive path from debuggee", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
640 }
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 print_debug("looking for %s\n", classes_jsa);
a61af66fc99e Initial load
duke
parents:
diff changeset
643
a61af66fc99e Initial load
duke
parents:
diff changeset
644 // open the classes[_g].jsa
892
a94af87c3357 6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents: 579
diff changeset
645 int fd = libsaproc_open(classes_jsa, O_RDONLY);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
646 if (fd < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
647 char errMsg[ERR_MSG_SIZE];
a61af66fc99e Initial load
duke
parents:
diff changeset
648 sprintf(errMsg, "can't open shared archive file %s", classes_jsa);
a61af66fc99e Initial load
duke
parents:
diff changeset
649 THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
650 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
651 print_debug("opened shared archive file %s\n", classes_jsa);
a61af66fc99e Initial load
duke
parents:
diff changeset
652 }
a61af66fc99e Initial load
duke
parents:
diff changeset
653
a61af66fc99e Initial load
duke
parents:
diff changeset
654 // parse classes[_g].jsa
a61af66fc99e Initial load
duke
parents:
diff changeset
655 struct FileMapHeader* pheader = (struct FileMapHeader*) malloc(sizeof(struct FileMapHeader));
a61af66fc99e Initial load
duke
parents:
diff changeset
656 if (pheader == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
657 close(fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
658 THROW_NEW_DEBUGGER_EXCEPTION_("can't allocate memory for shared file map header", 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
659 }
a61af66fc99e Initial load
duke
parents:
diff changeset
660
a61af66fc99e Initial load
duke
parents:
diff changeset
661 memset(pheader, 0, sizeof(struct FileMapHeader));
a61af66fc99e Initial load
duke
parents:
diff changeset
662 // read FileMapHeader
a61af66fc99e Initial load
duke
parents:
diff changeset
663 size_t n = read(fd, pheader, sizeof(struct FileMapHeader));
a61af66fc99e Initial load
duke
parents:
diff changeset
664 if (n != sizeof(struct FileMapHeader)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
665 free(pheader);
a61af66fc99e Initial load
duke
parents:
diff changeset
666 close(fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
667 char errMsg[ERR_MSG_SIZE];
a61af66fc99e Initial load
duke
parents:
diff changeset
668 sprintf(errMsg, "unable to read shared archive file map header from %s", classes_jsa);
a61af66fc99e Initial load
duke
parents:
diff changeset
669 THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
671
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // check file magic
a61af66fc99e Initial load
duke
parents:
diff changeset
673 if (pheader->_magic != 0xf00baba2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 free(pheader);
a61af66fc99e Initial load
duke
parents:
diff changeset
675 close(fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
676 char errMsg[ERR_MSG_SIZE];
a61af66fc99e Initial load
duke
parents:
diff changeset
677 sprintf(errMsg, "%s has bad shared archive magic 0x%x, expecting 0xf00baba2",
a61af66fc99e Initial load
duke
parents:
diff changeset
678 classes_jsa, pheader->_magic);
a61af66fc99e Initial load
duke
parents:
diff changeset
679 THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
680 }
a61af66fc99e Initial load
duke
parents:
diff changeset
681
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // check version
a61af66fc99e Initial load
duke
parents:
diff changeset
683 if (pheader->_version != CURRENT_ARCHIVE_VERSION) {
a61af66fc99e Initial load
duke
parents:
diff changeset
684 free(pheader);
a61af66fc99e Initial load
duke
parents:
diff changeset
685 close(fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
686 char errMsg[ERR_MSG_SIZE];
a61af66fc99e Initial load
duke
parents:
diff changeset
687 sprintf(errMsg, "%s has wrong shared archive version %d, expecting %d",
a61af66fc99e Initial load
duke
parents:
diff changeset
688 classes_jsa, pheader->_version, CURRENT_ARCHIVE_VERSION);
a61af66fc99e Initial load
duke
parents:
diff changeset
689 THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
691
a61af66fc99e Initial load
duke
parents:
diff changeset
692 if (_libsaproc_debug) {
a61af66fc99e Initial load
duke
parents:
diff changeset
693 for (int m = 0; m < NUM_SHARED_MAPS; m++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
694 print_debug("shared file offset %d mapped at 0x%lx, size = %ld, read only? = %d\n",
a61af66fc99e Initial load
duke
parents:
diff changeset
695 pheader->_space[m]._file_offset, pheader->_space[m]._base,
a61af66fc99e Initial load
duke
parents:
diff changeset
696 pheader->_space[m]._used, pheader->_space[m]._read_only);
a61af66fc99e Initial load
duke
parents:
diff changeset
697 }
a61af66fc99e Initial load
duke
parents:
diff changeset
698 }
a61af66fc99e Initial load
duke
parents:
diff changeset
699
a61af66fc99e Initial load
duke
parents:
diff changeset
700 // FIXME: For now, omitting other checks such as VM version etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
701
a61af66fc99e Initial load
duke
parents:
diff changeset
702 // store class archive file fd and map header in debugger object fields
a61af66fc99e Initial load
duke
parents:
diff changeset
703 dbg->env->SetIntField(this_obj, classes_jsa_fd_ID, fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
704 dbg->env->SetLongField(this_obj, p_file_map_header_ID, (jlong)(uintptr_t) pheader);
a61af66fc99e Initial load
duke
parents:
diff changeset
705 return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
706 }
a61af66fc99e Initial load
duke
parents:
diff changeset
707
a61af66fc99e Initial load
duke
parents:
diff changeset
708 } // extern "C"
a61af66fc99e Initial load
duke
parents:
diff changeset
709
a61af66fc99e Initial load
duke
parents:
diff changeset
710 // error messages for proc_arg_grab failure codes. The messages are
a61af66fc99e Initial load
duke
parents:
diff changeset
711 // modified versions of comments against corresponding #defines in
a61af66fc99e Initial load
duke
parents:
diff changeset
712 // libproc.h.
a61af66fc99e Initial load
duke
parents:
diff changeset
713 static const char* proc_arg_grab_errmsgs[] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
714 "",
a61af66fc99e Initial load
duke
parents:
diff changeset
715 /* G_NOPROC */ "No such process",
a61af66fc99e Initial load
duke
parents:
diff changeset
716 /* G_NOCORE */ "No such core file",
a61af66fc99e Initial load
duke
parents:
diff changeset
717 /* G_NOPROCORCORE */ "No such process or core",
a61af66fc99e Initial load
duke
parents:
diff changeset
718 /* G_NOEXEC */ "Cannot locate executable file",
a61af66fc99e Initial load
duke
parents:
diff changeset
719 /* G_ZOMB */ "Zombie processs",
a61af66fc99e Initial load
duke
parents:
diff changeset
720 /* G_PERM */ "No permission to attach",
a61af66fc99e Initial load
duke
parents:
diff changeset
721 /* G_BUSY */ "Another process has already attached",
a61af66fc99e Initial load
duke
parents:
diff changeset
722 /* G_SYS */ "System process - can not attach",
a61af66fc99e Initial load
duke
parents:
diff changeset
723 /* G_SELF */ "Process is self - can't debug myself!",
a61af66fc99e Initial load
duke
parents:
diff changeset
724 /* G_INTR */ "Interrupt received while grabbing",
a61af66fc99e Initial load
duke
parents:
diff changeset
725 /* G_LP64 */ "debuggee is 64 bit, use java -d64 for debugger",
a61af66fc99e Initial load
duke
parents:
diff changeset
726 /* G_FORMAT */ "File is not an ELF format core file - corrupted core?",
a61af66fc99e Initial load
duke
parents:
diff changeset
727 /* G_ELF */ "Libelf error while parsing an ELF file",
a61af66fc99e Initial load
duke
parents:
diff changeset
728 /* G_NOTE */ "Required PT_NOTE Phdr not present - corrupted core?",
a61af66fc99e Initial load
duke
parents:
diff changeset
729 };
a61af66fc99e Initial load
duke
parents:
diff changeset
730
a61af66fc99e Initial load
duke
parents:
diff changeset
731 static void attach_internal(JNIEnv* env, jobject this_obj, jstring cmdLine, jboolean isProcess) {
a61af66fc99e Initial load
duke
parents:
diff changeset
732 jboolean isCopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
733 int gcode;
a61af66fc99e Initial load
duke
parents:
diff changeset
734 const char* cmdLine_cstr = env->GetStringUTFChars(cmdLine, &isCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
735 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
736
a61af66fc99e Initial load
duke
parents:
diff changeset
737 // some older versions of libproc.so crash when trying to attach 32 bit
a61af66fc99e Initial load
duke
parents:
diff changeset
738 // debugger to 64 bit core file. check and throw error.
a61af66fc99e Initial load
duke
parents:
diff changeset
739 #ifndef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
740 atoi(cmdLine_cstr);
a61af66fc99e Initial load
duke
parents:
diff changeset
741 if (errno) {
a61af66fc99e Initial load
duke
parents:
diff changeset
742 // core file
a61af66fc99e Initial load
duke
parents:
diff changeset
743 int core_fd;
a61af66fc99e Initial load
duke
parents:
diff changeset
744 if ((core_fd = open64(cmdLine_cstr, O_RDONLY)) >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
745 Elf32_Ehdr e32;
a61af66fc99e Initial load
duke
parents:
diff changeset
746 if (pread64(core_fd, &e32, sizeof (e32), 0) == sizeof (e32) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
747 memcmp(&e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
748 e32.e_type == ET_CORE && e32.e_ident[EI_CLASS] == ELFCLASS64) {
a61af66fc99e Initial load
duke
parents:
diff changeset
749 close(core_fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
750 THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 64 bit, use java -d64 for debugger");
a61af66fc99e Initial load
duke
parents:
diff changeset
751 }
a61af66fc99e Initial load
duke
parents:
diff changeset
752 close(core_fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
753 }
a61af66fc99e Initial load
duke
parents:
diff changeset
754 // all other conditions are handled by libproc.so.
a61af66fc99e Initial load
duke
parents:
diff changeset
755 }
a61af66fc99e Initial load
duke
parents:
diff changeset
756 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
757
a61af66fc99e Initial load
duke
parents:
diff changeset
758 // connect to process/core
a61af66fc99e Initial load
duke
parents:
diff changeset
759 struct ps_prochandle* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode);
a61af66fc99e Initial load
duke
parents:
diff changeset
760 env->ReleaseStringUTFChars(cmdLine, cmdLine_cstr);
a61af66fc99e Initial load
duke
parents:
diff changeset
761 if (! ph) {
a61af66fc99e Initial load
duke
parents:
diff changeset
762 if (gcode > 0 && gcode < sizeof(proc_arg_grab_errmsgs)/sizeof(const char*)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
763 char errMsg[ERR_MSG_SIZE];
a61af66fc99e Initial load
duke
parents:
diff changeset
764 sprintf(errMsg, "Attach failed : %s", proc_arg_grab_errmsgs[gcode]);
a61af66fc99e Initial load
duke
parents:
diff changeset
765 THROW_NEW_DEBUGGER_EXCEPTION(errMsg);
a61af66fc99e Initial load
duke
parents:
diff changeset
766 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
767 if (_libsaproc_debug && gcode == G_STRANGE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
768 perror("libsaproc DEBUG: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
770 if (isProcess) {
a61af66fc99e Initial load
duke
parents:
diff changeset
771 THROW_NEW_DEBUGGER_EXCEPTION("Not able to attach to process!");
a61af66fc99e Initial load
duke
parents:
diff changeset
772 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
773 THROW_NEW_DEBUGGER_EXCEPTION("Not able to attach to core file!");
a61af66fc99e Initial load
duke
parents:
diff changeset
774 }
a61af66fc99e Initial load
duke
parents:
diff changeset
775 }
a61af66fc99e Initial load
duke
parents:
diff changeset
776 }
a61af66fc99e Initial load
duke
parents:
diff changeset
777
a61af66fc99e Initial load
duke
parents:
diff changeset
778 // even though libproc.so supports 64 bit debugger and 32 bit debuggee, we don't
a61af66fc99e Initial load
duke
parents:
diff changeset
779 // support such cross-bit-debugging. check for that combination and throw error.
a61af66fc99e Initial load
duke
parents:
diff changeset
780 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
781 int data_model;
a61af66fc99e Initial load
duke
parents:
diff changeset
782 if (ps_pdmodel(ph, &data_model) != PS_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
783 Prelease(ph, PRELEASE_CLEAR);
a61af66fc99e Initial load
duke
parents:
diff changeset
784 THROW_NEW_DEBUGGER_EXCEPTION("can't determine debuggee data model (ILP32? or LP64?)");
a61af66fc99e Initial load
duke
parents:
diff changeset
785 }
a61af66fc99e Initial load
duke
parents:
diff changeset
786 if (data_model == PR_MODEL_ILP32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
787 Prelease(ph, PRELEASE_CLEAR);
a61af66fc99e Initial load
duke
parents:
diff changeset
788 THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 32 bit, use 32 bit java for debugger");
a61af66fc99e Initial load
duke
parents:
diff changeset
789 }
a61af66fc99e Initial load
duke
parents:
diff changeset
790 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
791
a61af66fc99e Initial load
duke
parents:
diff changeset
792 env->SetLongField(this_obj, p_ps_prochandle_ID, (jlong)(uintptr_t)ph);
a61af66fc99e Initial load
duke
parents:
diff changeset
793
a61af66fc99e Initial load
duke
parents:
diff changeset
794 Debugger dbg;
a61af66fc99e Initial load
duke
parents:
diff changeset
795 dbg.env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
796 dbg.this_obj = this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
797 jthrowable exception = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
798 if (! isProcess) {
a61af66fc99e Initial load
duke
parents:
diff changeset
799 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
800 * With class sharing, shared perm. gen heap is allocated in with MAP_SHARED|PROT_READ.
a61af66fc99e Initial load
duke
parents:
diff changeset
801 * These pages are mapped from the file "classes[_g].jsa". MAP_SHARED pages are not dumped
a61af66fc99e Initial load
duke
parents:
diff changeset
802 * in Solaris core.To read shared heap pages, we have to read classes[_g].jsa file.
a61af66fc99e Initial load
duke
parents:
diff changeset
803 */
a61af66fc99e Initial load
duke
parents:
diff changeset
804 Pobject_iter(ph, init_classsharing_workaround, &dbg);
a61af66fc99e Initial load
duke
parents:
diff changeset
805 exception = env->ExceptionOccurred();
a61af66fc99e Initial load
duke
parents:
diff changeset
806 if (exception) {
a61af66fc99e Initial load
duke
parents:
diff changeset
807 env->ExceptionClear();
a61af66fc99e Initial load
duke
parents:
diff changeset
808 detach_internal(env, this_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
809 env->Throw(exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
810 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
811 }
a61af66fc99e Initial load
duke
parents:
diff changeset
812 }
a61af66fc99e Initial load
duke
parents:
diff changeset
813
a61af66fc99e Initial load
duke
parents:
diff changeset
814 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
815 * Iterate over the process mappings looking
a61af66fc99e Initial load
duke
parents:
diff changeset
816 * for libthread and then dlopen the appropriate
a61af66fc99e Initial load
duke
parents:
diff changeset
817 * libthread_db and get function pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
818 */
a61af66fc99e Initial load
duke
parents:
diff changeset
819 Pobject_iter(ph, init_libthread_db_ptrs, &dbg);
a61af66fc99e Initial load
duke
parents:
diff changeset
820 exception = env->ExceptionOccurred();
a61af66fc99e Initial load
duke
parents:
diff changeset
821 if (exception) {
a61af66fc99e Initial load
duke
parents:
diff changeset
822 env->ExceptionClear();
a61af66fc99e Initial load
duke
parents:
diff changeset
823 if (!sa_ignore_threaddb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
824 detach_internal(env, this_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
825 env->Throw(exception);
a61af66fc99e Initial load
duke
parents:
diff changeset
826 }
a61af66fc99e Initial load
duke
parents:
diff changeset
827 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
828 }
a61af66fc99e Initial load
duke
parents:
diff changeset
829
a61af66fc99e Initial load
duke
parents:
diff changeset
830 // init libthread_db and create thread_db agent
a61af66fc99e Initial load
duke
parents:
diff changeset
831 p_td_init_t p_td_init = (p_td_init_t) env->GetLongField(this_obj, p_td_init_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
832 if (p_td_init == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
833 if (!sa_ignore_threaddb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
834 detach_internal(env, this_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
835 }
a61af66fc99e Initial load
duke
parents:
diff changeset
836 HANDLE_THREADDB_FAILURE("Did not find libthread in target process/core!");
a61af66fc99e Initial load
duke
parents:
diff changeset
837 }
a61af66fc99e Initial load
duke
parents:
diff changeset
838
a61af66fc99e Initial load
duke
parents:
diff changeset
839 if (p_td_init() != TD_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
840 if (!sa_ignore_threaddb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
841 detach_internal(env, this_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
842 }
a61af66fc99e Initial load
duke
parents:
diff changeset
843 HANDLE_THREADDB_FAILURE("Can't initialize thread_db!");
a61af66fc99e Initial load
duke
parents:
diff changeset
844 }
a61af66fc99e Initial load
duke
parents:
diff changeset
845
a61af66fc99e Initial load
duke
parents:
diff changeset
846 p_td_ta_new_t p_td_ta_new = (p_td_ta_new_t) env->GetLongField(this_obj, p_td_ta_new_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
847
a61af66fc99e Initial load
duke
parents:
diff changeset
848 td_thragent_t *p_td_thragent_t = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
849 if (p_td_ta_new(ph, &p_td_thragent_t) != TD_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
850 if (!sa_ignore_threaddb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
851 detach_internal(env, this_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
852 }
a61af66fc99e Initial load
duke
parents:
diff changeset
853 HANDLE_THREADDB_FAILURE("Can't create thread_db agent!");
a61af66fc99e Initial load
duke
parents:
diff changeset
854 }
a61af66fc99e Initial load
duke
parents:
diff changeset
855 env->SetLongField(this_obj, p_td_thragent_t_ID, (jlong)(uintptr_t) p_td_thragent_t);
a61af66fc99e Initial load
duke
parents:
diff changeset
856
a61af66fc99e Initial load
duke
parents:
diff changeset
857 }
a61af66fc99e Initial load
duke
parents:
diff changeset
858
a61af66fc99e Initial load
duke
parents:
diff changeset
859 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
860 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
861 * Method: attach0
a61af66fc99e Initial load
duke
parents:
diff changeset
862 * Signature: (Ljava/lang/String;)V
a61af66fc99e Initial load
duke
parents:
diff changeset
863 * Description: process detach
a61af66fc99e Initial load
duke
parents:
diff changeset
864 */
a61af66fc99e Initial load
duke
parents:
diff changeset
865 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_attach0__Ljava_lang_String_2
a61af66fc99e Initial load
duke
parents:
diff changeset
866 (JNIEnv *env, jobject this_obj, jstring pid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
867 attach_internal(env, this_obj, pid, JNI_TRUE);
a61af66fc99e Initial load
duke
parents:
diff changeset
868 }
a61af66fc99e Initial load
duke
parents:
diff changeset
869
a61af66fc99e Initial load
duke
parents:
diff changeset
870 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
871 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
872 * Method: attach0
a61af66fc99e Initial load
duke
parents:
diff changeset
873 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
a61af66fc99e Initial load
duke
parents:
diff changeset
874 * Description: core file detach
a61af66fc99e Initial load
duke
parents:
diff changeset
875 */
a61af66fc99e Initial load
duke
parents:
diff changeset
876 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2
a61af66fc99e Initial load
duke
parents:
diff changeset
877 (JNIEnv *env, jobject this_obj, jstring executable, jstring corefile) {
a61af66fc99e Initial load
duke
parents:
diff changeset
878 // ignore executable file name, libproc.so can detect a.out name anyway.
a61af66fc99e Initial load
duke
parents:
diff changeset
879 attach_internal(env, this_obj, corefile, JNI_FALSE);
a61af66fc99e Initial load
duke
parents:
diff changeset
880 }
a61af66fc99e Initial load
duke
parents:
diff changeset
881
a61af66fc99e Initial load
duke
parents:
diff changeset
882
a61af66fc99e Initial load
duke
parents:
diff changeset
883 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
884 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
885 * Method: detach0
a61af66fc99e Initial load
duke
parents:
diff changeset
886 * Signature: ()V
a61af66fc99e Initial load
duke
parents:
diff changeset
887 * Description: process/core file detach
a61af66fc99e Initial load
duke
parents:
diff changeset
888 */
a61af66fc99e Initial load
duke
parents:
diff changeset
889 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_detach0
a61af66fc99e Initial load
duke
parents:
diff changeset
890 (JNIEnv *env, jobject this_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
891 detach_internal(env, this_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
892 }
a61af66fc99e Initial load
duke
parents:
diff changeset
893
a61af66fc99e Initial load
duke
parents:
diff changeset
894 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
895 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
896 * Method: getRemoteProcessAddressSize0
a61af66fc99e Initial load
duke
parents:
diff changeset
897 * Signature: ()I
a61af66fc99e Initial load
duke
parents:
diff changeset
898 * Description: get process/core address size
a61af66fc99e Initial load
duke
parents:
diff changeset
899 */
a61af66fc99e Initial load
duke
parents:
diff changeset
900 JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_getRemoteProcessAddressSize0
a61af66fc99e Initial load
duke
parents:
diff changeset
901 (JNIEnv *env, jobject this_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
902 jlong p_ps_prochandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
903 p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
904 int data_model = PR_MODEL_ILP32;
a61af66fc99e Initial load
duke
parents:
diff changeset
905 ps_pdmodel((struct ps_prochandle*) p_ps_prochandle, &data_model);
a61af66fc99e Initial load
duke
parents:
diff changeset
906 print_debug("debuggee is %d bit\n", data_model == PR_MODEL_ILP32? 32 : 64);
a61af66fc99e Initial load
duke
parents:
diff changeset
907 return (jint) data_model == PR_MODEL_ILP32? 32 : 64;
a61af66fc99e Initial load
duke
parents:
diff changeset
908 }
a61af66fc99e Initial load
duke
parents:
diff changeset
909
a61af66fc99e Initial load
duke
parents:
diff changeset
910 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
911 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
912 * Method: getPageSize0
a61af66fc99e Initial load
duke
parents:
diff changeset
913 * Signature: ()I
a61af66fc99e Initial load
duke
parents:
diff changeset
914 * Description: get process/core page size
a61af66fc99e Initial load
duke
parents:
diff changeset
915 */
a61af66fc99e Initial load
duke
parents:
diff changeset
916 JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_getPageSize0
a61af66fc99e Initial load
duke
parents:
diff changeset
917 (JNIEnv *env, jobject this_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
918
a61af66fc99e Initial load
duke
parents:
diff changeset
919 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
920 We are not yet attached to a java process or core file. getPageSize is called from
a61af66fc99e Initial load
duke
parents:
diff changeset
921 the constructor of ProcDebuggerLocal. The following won't work!
a61af66fc99e Initial load
duke
parents:
diff changeset
922
a61af66fc99e Initial load
duke
parents:
diff changeset
923 jlong p_ps_prochandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
924 p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
925 CHECK_EXCEPTION_(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
926 struct ps_prochandle* prochandle = (struct ps_prochandle*) p_ps_prochandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
927 return (Pstate(prochandle) == PS_DEAD) ? Pgetauxval(prochandle, AT_PAGESZ)
a61af66fc99e Initial load
duke
parents:
diff changeset
928 : getpagesize();
a61af66fc99e Initial load
duke
parents:
diff changeset
929
a61af66fc99e Initial load
duke
parents:
diff changeset
930 So even though core may have been generated with a different page size settings, for now
a61af66fc99e Initial load
duke
parents:
diff changeset
931 call getpagesize.
a61af66fc99e Initial load
duke
parents:
diff changeset
932 */
a61af66fc99e Initial load
duke
parents:
diff changeset
933
a61af66fc99e Initial load
duke
parents:
diff changeset
934 return getpagesize();
a61af66fc99e Initial load
duke
parents:
diff changeset
935 }
a61af66fc99e Initial load
duke
parents:
diff changeset
936
a61af66fc99e Initial load
duke
parents:
diff changeset
937 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
938 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
939 * Method: getThreadIntegerRegisterSet0
a61af66fc99e Initial load
duke
parents:
diff changeset
940 * Signature: (J)[J
a61af66fc99e Initial load
duke
parents:
diff changeset
941 * Description: get gregset for a given thread specified by thread id
a61af66fc99e Initial load
duke
parents:
diff changeset
942 */
a61af66fc99e Initial load
duke
parents:
diff changeset
943 JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_getThreadIntegerRegisterSet0
a61af66fc99e Initial load
duke
parents:
diff changeset
944 (JNIEnv *env, jobject this_obj, jlong tid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
945 // map the thread id to thread handle
a61af66fc99e Initial load
duke
parents:
diff changeset
946 p_td_ta_map_id2thr_t p_td_ta_map_id2thr = (p_td_ta_map_id2thr_t) env->GetLongField(this_obj, p_td_ta_map_id2thr_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
947
a61af66fc99e Initial load
duke
parents:
diff changeset
948 td_thragent_t* p_td_thragent_t = (td_thragent_t*) env->GetLongField(this_obj, p_td_thragent_t_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
949 if (p_td_thragent_t == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
950 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
951 }
a61af66fc99e Initial load
duke
parents:
diff changeset
952
a61af66fc99e Initial load
duke
parents:
diff changeset
953 td_thrhandle_t thr_handle;
a61af66fc99e Initial load
duke
parents:
diff changeset
954 if (p_td_ta_map_id2thr(p_td_thragent_t, (thread_t) tid, &thr_handle) != TD_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
955 THROW_NEW_DEBUGGER_EXCEPTION_("can't map thread id to thread handle!", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
956 }
a61af66fc99e Initial load
duke
parents:
diff changeset
957
a61af66fc99e Initial load
duke
parents:
diff changeset
958 p_td_thr_getgregs_t p_td_thr_getgregs = (p_td_thr_getgregs_t) env->GetLongField(this_obj, p_td_thr_getgregs_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
959 prgregset_t gregs;
a61af66fc99e Initial load
duke
parents:
diff changeset
960 p_td_thr_getgregs(&thr_handle, gregs);
a61af66fc99e Initial load
duke
parents:
diff changeset
961
a61af66fc99e Initial load
duke
parents:
diff changeset
962 jlongArray res = env->NewLongArray(NPRGREG);
a61af66fc99e Initial load
duke
parents:
diff changeset
963 CHECK_EXCEPTION_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
964 jboolean isCopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
965 jlong* ptr = env->GetLongArrayElements(res, &isCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
966 for (int i = 0; i < NPRGREG; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
967 ptr[i] = (jlong) (uintptr_t) gregs[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
968 }
a61af66fc99e Initial load
duke
parents:
diff changeset
969 env->ReleaseLongArrayElements(res, ptr, JNI_COMMIT);
a61af66fc99e Initial load
duke
parents:
diff changeset
970 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
971 }
a61af66fc99e Initial load
duke
parents:
diff changeset
972
a61af66fc99e Initial load
duke
parents:
diff changeset
973 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
974 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
975 * Method: fillThreadList0
a61af66fc99e Initial load
duke
parents:
diff changeset
976 * Signature: (Ljava/util/List;)V
a61af66fc99e Initial load
duke
parents:
diff changeset
977 * Description: fills thread list of the debuggee process/core
a61af66fc99e Initial load
duke
parents:
diff changeset
978 */
a61af66fc99e Initial load
duke
parents:
diff changeset
979 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_fillThreadList0
a61af66fc99e Initial load
duke
parents:
diff changeset
980 (JNIEnv *env, jobject this_obj, jobject list) {
a61af66fc99e Initial load
duke
parents:
diff changeset
981
a61af66fc99e Initial load
duke
parents:
diff changeset
982 td_thragent_t* p_td_thragent_t = (td_thragent_t*) env->GetLongField(this_obj, p_td_thragent_t_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
983 if (p_td_thragent_t == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
984 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
985 }
a61af66fc99e Initial load
duke
parents:
diff changeset
986
a61af66fc99e Initial load
duke
parents:
diff changeset
987 p_td_ta_thr_iter_t p_td_ta_thr_iter = (p_td_ta_thr_iter_t) env->GetLongField(this_obj, p_td_ta_thr_iter_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
988
a61af66fc99e Initial load
duke
parents:
diff changeset
989 DebuggerWithObject dbgo;
a61af66fc99e Initial load
duke
parents:
diff changeset
990 dbgo.env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
991 dbgo.this_obj = this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
992 dbgo.obj = list;
a61af66fc99e Initial load
duke
parents:
diff changeset
993
a61af66fc99e Initial load
duke
parents:
diff changeset
994 p_td_ta_thr_iter(p_td_thragent_t, fill_thread_list, &dbgo,
a61af66fc99e Initial load
duke
parents:
diff changeset
995 TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
a61af66fc99e Initial load
duke
parents:
diff changeset
996 }
a61af66fc99e Initial load
duke
parents:
diff changeset
997
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
998 #ifndef SOLARIS_11_B159_OR_LATER
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
999 // building on Nevada-B158 or earlier so more hoops to jump through
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1000 static bool has_newer_Pstack_iter = false; // older version by default
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1001 #endif
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1002
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 * Method: fillCFrameList0
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 * Signature: ([J)Lsun/jvm/hotspot/debugger/proc/ProcCFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 * Description: fills CFrame list for a given thread
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_fillCFrameList0
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 (JNIEnv *env, jobject this_obj, jlongArray regsArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1012
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 DebuggerWith2Objects dbgo2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 dbgo2.env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 dbgo2.this_obj = this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 dbgo2.obj = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 dbgo2.obj2 = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1018
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 jboolean isCopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 jlong* ptr = env->GetLongArrayElements(regsArray, &isCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 CHECK_EXCEPTION_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1022
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 prgregset_t gregs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 for (int i = 0; i < NPRGREG; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 gregs[i] = (uintptr_t) ptr[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1027
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 env->ReleaseLongArrayElements(regsArray, ptr, JNI_ABORT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 CHECK_EXCEPTION_(0);
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1030
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1031 #ifdef SOLARIS_11_B159_OR_LATER
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1032 // building on Nevada-B159 or later so use the new callback
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1033 Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1034 wrapper_fill_cframe_list, &dbgo2);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1035 #else
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1036 // building on Nevada-B158 or earlier so figure out which callback to use
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1037
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1038 if (has_newer_Pstack_iter) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1039 // Since we're building on Nevada-B158 or earlier, we have to
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1040 // cast wrapper_fill_cframe_list to make the compiler happy.
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1041 Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1042 (proc_stack_f *)wrapper_fill_cframe_list, &dbgo2);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1043 } else {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1044 Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs,
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1045 fill_cframe_list, &dbgo2);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1046 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1047 #endif // SOLARIS_11_B159_OR_LATER
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 return dbgo2.obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1050
a61af66fc99e Initial load
duke
parents:
diff changeset
1051 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 * Method: fillLoadObjectList0
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 * Signature: (Ljava/util/List;)V
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 * Description: fills shared objects of the debuggee process/core
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_fillLoadObjectList0
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 (JNIEnv *env, jobject this_obj, jobject list) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 DebuggerWithObject dbgo;
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 dbgo.env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 dbgo.this_obj = this_obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 dbgo.obj = list;
a61af66fc99e Initial load
duke
parents:
diff changeset
1063
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 Pobject_iter((struct ps_prochandle*) p_ps_prochandle, fill_load_object_list, &dbgo);
a61af66fc99e Initial load
duke
parents:
diff changeset
1066 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1067
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 * Method: readBytesFromProcess0
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 * Signature: (JJ)[B
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 * Description: read bytes from debuggee process/core
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_readBytesFromProcess0
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 (JNIEnv *env, jobject this_obj, jlong address, jlong numBytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1076
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 jbyteArray array = env->NewByteArray(numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 CHECK_EXCEPTION_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 jboolean isCopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 jbyte* bufPtr = env->GetByteArrayElements(array, &isCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 CHECK_EXCEPTION_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1082
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 ps_err_e ret = ps_pread((struct ps_prochandle*) p_ps_prochandle,
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 (psaddr_t)address, bufPtr, (size_t)numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
1086
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 if (ret != PS_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 // part of the class sharing workaround. try shared heap area
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 int classes_jsa_fd = env->GetIntField(this_obj, classes_jsa_fd_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1090 if (classes_jsa_fd != -1 && address != (jlong)0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 print_debug("read failed at 0x%lx, attempting shared heap area\n", (long) address);
a61af66fc99e Initial load
duke
parents:
diff changeset
1092
a61af66fc99e Initial load
duke
parents:
diff changeset
1093 struct FileMapHeader* pheader = (struct FileMapHeader*) env->GetLongField(this_obj, p_file_map_header_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 // walk through the shared mappings -- we just have 4 of them.
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 // so, linear walking is okay.
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 for (int m = 0; m < NUM_SHARED_MAPS; m++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1097
a61af66fc99e Initial load
duke
parents:
diff changeset
1098 // We can skip the non-read-only maps. These are mapped as MAP_PRIVATE
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 // and hence will be read by libproc. Besides, the file copy may be
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 // stale because the process might have modified those pages.
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 if (pheader->_space[m]._read_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 jlong baseAddress = (jlong) (uintptr_t) pheader->_space[m]._base;
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 size_t usedSize = pheader->_space[m]._used;
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 if (address >= baseAddress && address < (baseAddress + usedSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 // the given address falls in this shared heap area
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 print_debug("found shared map at 0x%lx\n", (long) baseAddress);
a61af66fc99e Initial load
duke
parents:
diff changeset
1107
a61af66fc99e Initial load
duke
parents:
diff changeset
1108
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 // If more data is asked than actually mapped from file, we need to zero fill
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 // till the end-of-page boundary. But, java array new does that for us. we just
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 // need to read as much as data available.
a61af66fc99e Initial load
duke
parents:
diff changeset
1112
a61af66fc99e Initial load
duke
parents:
diff changeset
1113 #define MIN2(x, y) (((x) < (y))? (x) : (y))
a61af66fc99e Initial load
duke
parents:
diff changeset
1114
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 jlong diff = address - baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 jlong bytesToRead = MIN2(numBytes, usedSize - diff);
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 off_t offset = pheader->_space[m]._file_offset + off_t(diff);
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 ssize_t bytesRead = pread(classes_jsa_fd, bufPtr, bytesToRead, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 if (bytesRead != bytesToRead) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 env->ReleaseByteArrayElements(array, bufPtr, JNI_ABORT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 print_debug("shared map read failed\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 return jbyteArray(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1124 print_debug("shared map read succeeded\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 env->ReleaseByteArrayElements(array, bufPtr, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 return array;
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 } // is in current map
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 } // is read only map
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 } // for shared maps
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 } // classes_jsa_fd != -1
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 env->ReleaseByteArrayElements(array, bufPtr, JNI_ABORT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 return jbyteArray(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 env->ReleaseByteArrayElements(array, bufPtr, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 return array;
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1139
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 * Method: writeBytesToProcess0
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 * Signature: (JJ[B)V
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 * Description: write bytes into debugger process
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_writeBytesToProcess0
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 (JNIEnv *env, jobject this_obj, jlong address, jlong numBytes, jbyteArray data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 jboolean isCopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 jbyte* ptr = env->GetByteArrayElements(data, &isCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1152
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 if (ps_pwrite((struct ps_prochandle*) p_ps_prochandle, address, ptr, numBytes) != PS_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 THROW_NEW_DEBUGGER_EXCEPTION("Process write failed!");
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1157
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1160
a61af66fc99e Initial load
duke
parents:
diff changeset
1161 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 * Method: suspend0
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 * Signature: ()V
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_suspend0
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 (JNIEnv *env, jobject this_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 // for now don't check return value. revisit this again.
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 Pstop((struct ps_prochandle*) p_ps_prochandle, 1000);
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1172
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 * Method: resume0
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 * Signature: ()V
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_resume0
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 (JNIEnv *env, jobject this_obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1181 // for now don't check return value. revisit this again.
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 Psetrun((struct ps_prochandle*) p_ps_prochandle, 0, PRCFAULT|PRSTOP);
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1184
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 * Method: lookupByName0
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 * Signature: (Ljava/lang/String;Ljava/lang/String;)J
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 * Description: symbol lookup by name
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_lookupByName0
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 (JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 jlong p_ps_prochandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1195
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 jboolean isCopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 const char* objectName_cstr = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 if (objectName != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 objectName_cstr = env->GetStringUTFChars(objectName, &isCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 CHECK_EXCEPTION_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 objectName_cstr = PR_OBJ_EVERY;
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1204
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 const char* symbolName_cstr = env->GetStringUTFChars(symbolName, &isCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 CHECK_EXCEPTION_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1207
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 psaddr_t symbol_addr = (psaddr_t) 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 ps_pglobal_lookup((struct ps_prochandle*) p_ps_prochandle, objectName_cstr,
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 symbolName_cstr, &symbol_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1211
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 if (symbol_addr == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 print_debug("lookup for %s in %s failed\n", symbolName_cstr, objectName_cstr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1215
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 if (objectName_cstr != PR_OBJ_EVERY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 env->ReleaseStringUTFChars(objectName, objectName_cstr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 env->ReleaseStringUTFChars(symbolName, symbolName_cstr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 return (jlong) (uintptr_t) symbol_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1222
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 * Method: lookupByAddress0
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 * Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;
a61af66fc99e Initial load
duke
parents:
diff changeset
1227 * Description: lookup symbol name for a given address
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_lookupByAddress0
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 (JNIEnv *env, jobject this_obj, jlong address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 jlong p_ps_prochandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID);
a61af66fc99e Initial load
duke
parents:
diff changeset
1233
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 char nameBuf[SYMBOL_BUF_SIZE + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 GElf_Sym sym;
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 int res = Plookup_by_addr((struct ps_prochandle*) p_ps_prochandle, (uintptr_t) address,
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 nameBuf, sizeof(nameBuf), &sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 if (res != 0) { // failed
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1241
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 jstring resSym = env->NewStringUTF(nameBuf);
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 CHECK_EXCEPTION_(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1244
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 return env->CallObjectMethod(this_obj, createClosestSymbol_ID, resSym, (address - sym.st_value));
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1247
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 * Method: demangle0
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 * Signature: (Ljava/lang/String;)Ljava/lang/String;
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 JNIEXPORT jstring JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_demangle0
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 (JNIEnv *env, jobject this_object, jstring name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 jboolean isCopy;
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 const char* ptr = env->GetStringUTFChars(name, &isCopy);
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 char buf[2*SYMBOL_BUF_SIZE + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 jstring res = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 if (cplus_demangle((char*) ptr, buf, sizeof(buf)) != DEMANGLE_ESPACE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 res = env->NewStringUTF(buf);
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 res = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 env->ReleaseStringUTFChars(name, ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1267
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1268 #ifndef SOLARIS_11_B159_OR_LATER
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1269 // Determine if the OS we're running on has the newer version
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1270 // of libproc's Pstack_iter.
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1271 //
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1272 // Set env var PSTACK_ITER_DEBUG=true to debug this logic.
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1273 // Set env var PSTACK_ITER_DEBUG_RELEASE to simulate a 'release' value.
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1274 // Set env var PSTACK_ITER_DEBUG_VERSION to simulate a 'version' value.
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1275 //
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1276 // frankenputer 'uname -r -v': 5.10 Generic_141445-09
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1277 // jurassic 'uname -r -v': 5.11 snv_164
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1278 // lonepeak 'uname -r -v': 5.11 snv_127
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1279 //
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1280 static void set_has_newer_Pstack_iter(JNIEnv *env) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1281 static bool done_set = false;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1282
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1283 if (done_set) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1284 // already set has_newer_Pstack_iter
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1285 return;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1286 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1287
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1288 struct utsname name;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1289 if (uname(&name) == -1) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1290 THROW_NEW_DEBUGGER_EXCEPTION("uname() failed!");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1291 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1292 dprintf_2("release='%s' version='%s'\n", name.release, name.version);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1293
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1294 if (_Pstack_iter_debug) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1295 char *override = getenv("PSTACK_ITER_DEBUG_RELEASE");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1296 if (override != NULL) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1297 strncpy(name.release, override, SYS_NMLN - 1);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1298 name.release[SYS_NMLN - 2] = '\0';
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1299 dprintf_2("overriding with release='%s'\n", name.release);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1300 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1301 override = getenv("PSTACK_ITER_DEBUG_VERSION");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1302 if (override != NULL) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1303 strncpy(name.version, override, SYS_NMLN - 1);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1304 name.version[SYS_NMLN - 2] = '\0';
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1305 dprintf_2("overriding with version='%s'\n", name.version);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1306 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1307 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1308
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1309 // the major number corresponds to the old SunOS major number
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1310 int major = atoi(name.release);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1311 if (major >= 6) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1312 dprintf_2("release is SunOS 6 or later\n");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1313 has_newer_Pstack_iter = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1314 done_set = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1315 return;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1316 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1317 if (major < 5) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1318 dprintf_2("release is SunOS 4 or earlier\n");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1319 done_set = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1320 return;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1321 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1322
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1323 // some SunOS 5.* build so now check for Solaris versions
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1324 char *dot = strchr(name.release, '.');
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1325 int minor = 0;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1326 if (dot != NULL) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1327 // release is major.minor format
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1328 *dot = NULL;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1329 minor = atoi(dot + 1);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1330 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1331
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1332 if (minor <= 10) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1333 dprintf_2("release is Solaris 10 or earlier\n");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1334 done_set = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1335 return;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1336 } else if (minor >= 12) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1337 dprintf_2("release is Solaris 12 or later\n");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1338 has_newer_Pstack_iter = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1339 done_set = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1340 return;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1341 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1342
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1343 // some Solaris 11 build so now check for internal build numbers
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1344 if (strncmp(name.version, "snv_", 4) != 0) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1345 dprintf_2("release is Solaris 11 post-GA or later\n");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1346 has_newer_Pstack_iter = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1347 done_set = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1348 return;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1349 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1350
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1351 // version begins with "snv_" so a pre-GA build of Solaris 11
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1352 int build = atoi(&name.version[4]);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1353 if (build >= 159) {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1354 dprintf_2("release is Nevada-B159 or later\n");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1355 has_newer_Pstack_iter = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1356 } else {
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1357 dprintf_2("release is Nevada-B158 or earlier\n");
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1358 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1359
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1360 done_set = true;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1361 }
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1362 #endif // !SOLARIS_11_B159_OR_LATER
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1363
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 * Method: initIDs
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 * Signature: ()V
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 * Description: get JNI ids for fields and methods of ProcDebuggerLocal class
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 */
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_initIDs
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 (JNIEnv *env, jclass clazz) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 _libsaproc_debug = getenv("LIBSAPROC_DEBUG") != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 if (_libsaproc_debug) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 // propagate debug mode to libproc.so
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 static const char* var = "LIBPROC_DEBUG=1";
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 putenv((char*)var);
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1378
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 void* libproc_handle = dlopen("libproc.so", RTLD_LAZY | RTLD_GLOBAL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 if (libproc_handle == 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 THROW_NEW_DEBUGGER_EXCEPTION("can't load libproc.so, if you are using Solaris 5.7 or below, copy libproc.so from 5.8!");
a61af66fc99e Initial load
duke
parents:
diff changeset
1382
3306
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1383 #ifndef SOLARIS_11_B159_OR_LATER
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1384 _Pstack_iter_debug = getenv("PSTACK_ITER_DEBUG") != NULL;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1385
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1386 set_has_newer_Pstack_iter(env);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1387 CHECK_EXCEPTION;
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1388 dprintf_2("has_newer_Pstack_iter=%d\n", has_newer_Pstack_iter);
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1389 #endif
405c634f4aaa 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 1552
diff changeset
1390
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 p_ps_prochandle_ID = env->GetFieldID(clazz, "p_ps_prochandle", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1393
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 libthread_db_handle_ID = env->GetFieldID(clazz, "libthread_db_handle", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1396
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 p_td_thragent_t_ID = env->GetFieldID(clazz, "p_td_thragent_t", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1399
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 p_td_init_ID = env->GetFieldID(clazz, "p_td_init", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1402
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 p_td_ta_new_ID = env->GetFieldID(clazz, "p_td_ta_new", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1405
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 p_td_ta_delete_ID = env->GetFieldID(clazz, "p_td_ta_delete", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1408
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 p_td_ta_thr_iter_ID = env->GetFieldID(clazz, "p_td_ta_thr_iter", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1411
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 p_td_thr_get_info_ID = env->GetFieldID(clazz, "p_td_thr_get_info", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1414
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 p_td_ta_map_id2thr_ID = env->GetFieldID(clazz, "p_td_ta_map_id2thr", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1417
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 p_td_thr_getgregs_ID = env->GetFieldID(clazz, "p_td_thr_getgregs", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1420
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 getThreadForThreadId_ID = env->GetMethodID(clazz,
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 "getThreadForThreadId", "(J)Lsun/jvm/hotspot/debugger/ThreadProxy;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1424
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 pcRegIndex_ID = env->GetFieldID(clazz, "pcRegIndex", "I");
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1427
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 fpRegIndex_ID = env->GetFieldID(clazz, "fpRegIndex", "I");
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1430
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 createSenderFrame_ID = env->GetMethodID(clazz,
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 "createSenderFrame", "(Lsun/jvm/hotspot/debugger/proc/ProcCFrame;JJ)Lsun/jvm/hotspot/debugger/proc/ProcCFrame;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1434
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 createLoadObject_ID = env->GetMethodID(clazz,
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 "createLoadObject", "(Ljava/lang/String;JJ)Lsun/jvm/hotspot/debugger/cdbg/LoadObject;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1438
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 createClosestSymbol_ID = env->GetMethodID(clazz,
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 "createClosestSymbol", "(Ljava/lang/String;J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;");
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1442
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 listAdd_ID = env->GetMethodID(env->FindClass("java/util/List"), "add", "(Ljava/lang/Object;)Z");
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1445
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 // part of the class sharing workaround
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 classes_jsa_fd_ID = env->GetFieldID(clazz, "classes_jsa_fd", "I");
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 p_file_map_header_ID = env->GetFieldID(clazz, "p_file_map_header", "J");
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 CHECK_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 }