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

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 964
8db2b3e46c38
child 1327
a94af87c3357
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

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

mercurial