1 /* |
1 /* |
2 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
239 } |
240 } |
240 |
241 |
241 /* |
242 /* |
242 * Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
243 * Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
243 * Method: attach0 |
244 * Method: attach0 |
244 * Signature: (IZ)V |
245 * Signature: (I)V |
245 */ |
246 */ |
246 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_attach0__IZ |
247 JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_attach0__I |
247 (JNIEnv *env, jobject this_obj, jint jpid, jboolean is_in_container) { |
248 (JNIEnv *env, jobject this_obj, jint jpid) { |
248 |
249 |
249 // For bitness checking, locate binary at /proc/jpid/exe |
250 // For bitness checking, locate binary at /proc/jpid/exe |
250 char buf[PATH_MAX]; |
251 char buf[PATH_MAX]; |
251 snprintf((char *) &buf, PATH_MAX, "/proc/%d/exe", jpid); |
252 snprintf((char *) &buf, PATH_MAX, "/proc/%d/exe", jpid); |
252 verifyBitness(env, (char *) &buf); |
253 verifyBitness(env, (char *) &buf); |
253 CHECK_EXCEPTION; |
254 CHECK_EXCEPTION; |
254 |
255 |
255 char err_buf[200]; |
256 char err_buf[200]; |
256 struct ps_prochandle* ph; |
257 struct ps_prochandle* ph; |
257 if ((ph = Pgrab(jpid, err_buf, sizeof(err_buf), is_in_container)) == NULL) { |
258 if ((ph = Pgrab(jpid, err_buf, sizeof(err_buf))) == NULL) { |
258 char msg[230]; |
259 char msg[230]; |
259 snprintf(msg, sizeof(msg), "Can't attach to the process: %s", err_buf); |
260 snprintf(msg, sizeof(msg), "Can't attach to the process: %s", err_buf); |
260 THROW_NEW_DEBUGGER_EXCEPTION(msg); |
261 THROW_NEW_DEBUGGER_EXCEPTION(msg); |
261 } |
262 } |
262 (*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph); |
263 (*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph); |