agent/src/os/solaris/proc/saproc.cpp

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1327
a94af87c3357
child 2838
405c634f4aaa
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

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

mercurial