< prev index next >

src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp

Print this page


   1 /*
   2  * Copyright (c) 2002, 2019, 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  *


 590  */
 591 extern "C"
 592 JNIEXPORT jstring JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_demangle
 593   (JNIEnv *env, jobject this_obj, jstring jsym) {
 594   int status;
 595   jstring result = NULL;
 596 
 597   const char *sym = env->GetStringUTFChars(jsym, JNI_FALSE);
 598   char *demangled = abi::__cxa_demangle(sym, NULL, 0, &status);
 599   env->ReleaseStringUTFChars(jsym, sym);
 600   if ((demangled != NULL) && (status == 0)) {
 601     result = env->NewStringUTF(demangled);
 602     free(demangled);
 603   } else if (status == -2) { // not C++ ABI mangling rules - maybe C style
 604     result = jsym;
 605   } else {
 606     THROW_NEW_DEBUGGER_EXCEPTION_("Could not demangle", NULL);
 607   }
 608 
 609   return result;












 610 }
   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  *


 590  */
 591 extern "C"
 592 JNIEXPORT jstring JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_demangle
 593   (JNIEnv *env, jobject this_obj, jstring jsym) {
 594   int status;
 595   jstring result = NULL;
 596 
 597   const char *sym = env->GetStringUTFChars(jsym, JNI_FALSE);
 598   char *demangled = abi::__cxa_demangle(sym, NULL, 0, &status);
 599   env->ReleaseStringUTFChars(jsym, sym);
 600   if ((demangled != NULL) && (status == 0)) {
 601     result = env->NewStringUTF(demangled);
 602     free(demangled);
 603   } else if (status == -2) { // not C++ ABI mangling rules - maybe C style
 604     result = jsym;
 605   } else {
 606     THROW_NEW_DEBUGGER_EXCEPTION_("Could not demangle", NULL);
 607   }
 608 
 609   return result;
 610 }
 611 
 612 /*
 613  * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
 614  * Method:    findLibPtrByAddress0
 615  * Signature: (J)J
 616  */
 617 extern "C"
 618 JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_findLibPtrByAddress0
 619   (JNIEnv *env, jobject this_obj, jlong pc) {
 620   struct ps_prochandle* ph = get_proc_handle(env, this_obj);
 621   return reinterpret_cast<jlong>(find_lib_by_address(ph, pc));
 622 }
< prev index next >