1 /*
2 * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2019, NTT DATA.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
598 (JNIEnv *env, jobject this_obj, jstring jsym) {
599 int status;
600 jstring result = NULL;
601
602 const char *sym = env->GetStringUTFChars(jsym, NULL);
603 if (sym == NULL) {
604 THROW_NEW_DEBUGGER_EXCEPTION_("Error getting symbol string", NULL);
605 }
606 char *demangled = abi::__cxa_demangle(sym, NULL, 0, &status);
607 env->ReleaseStringUTFChars(jsym, sym);
608 if ((demangled != NULL) && (status == 0)) {
609 result = env->NewStringUTF(demangled);
610 free(demangled);
611 } else if (status == -2) { // not C++ ABI mangling rules - maybe C style
612 result = jsym;
613 } else {
614 THROW_NEW_DEBUGGER_EXCEPTION_("Could not demangle", NULL);
615 }
616
617 return result;
618 }
|
1 /*
2 * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2019, 2020, NTT DATA.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
598 (JNIEnv *env, jobject this_obj, jstring jsym) {
599 int status;
600 jstring result = NULL;
601
602 const char *sym = env->GetStringUTFChars(jsym, NULL);
603 if (sym == NULL) {
604 THROW_NEW_DEBUGGER_EXCEPTION_("Error getting symbol string", NULL);
605 }
606 char *demangled = abi::__cxa_demangle(sym, NULL, 0, &status);
607 env->ReleaseStringUTFChars(jsym, sym);
608 if ((demangled != NULL) && (status == 0)) {
609 result = env->NewStringUTF(demangled);
610 free(demangled);
611 } else if (status == -2) { // not C++ ABI mangling rules - maybe C style
612 result = jsym;
613 } else {
614 THROW_NEW_DEBUGGER_EXCEPTION_("Could not demangle", NULL);
615 }
616
617 return result;
618 }
619
620 /*
621 * Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
622 * Method: findLibPtrByAddress0
623 * Signature: (J)J
624 */
625 extern "C"
626 JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_findLibPtrByAddress0
627 (JNIEnv *env, jobject this_obj, jlong pc) {
628 struct ps_prochandle* ph = get_proc_handle(env, this_obj);
629 return reinterpret_cast<jlong>(find_lib_by_address(ph, pc));
630 }
|