author | lkorinth |
Wed, 13 Nov 2019 11:37:29 +0100 | |
changeset 59053 | ba6c248cae19 |
parent 58913 | e2dfab7beccb |
permissions | -rw-r--r-- |
58913
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
1 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
2 |
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
3 |
* Copyright (c) 2019, NTT DATA. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
5 |
* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
9 |
* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
14 |
* accompanied this code). |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
15 |
* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
19 |
* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
22 |
* questions. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
23 |
* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
24 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
25 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
26 |
#include <jni.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
27 |
#include "libproc.h" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
28 |
#include "proc_service.h" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
29 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
30 |
#include <elf.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
31 |
#include <sys/types.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
32 |
#include <sys/stat.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
33 |
#include <fcntl.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
34 |
#include <stdlib.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
35 |
#include <string.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
36 |
#include <limits.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
37 |
#include <cxxabi.h> |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
38 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
39 |
#if defined(x86_64) && !defined(amd64) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
40 |
#define amd64 1 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
41 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
42 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
43 |
#if defined(i386) && !defined(i586) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
44 |
#define i586 1 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
45 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
46 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
47 |
#ifdef i586 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
48 |
#include "sun_jvm_hotspot_debugger_x86_X86ThreadContext.h" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
49 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
50 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
51 |
#ifdef amd64 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
52 |
#include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
53 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
54 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
55 |
#if defined(sparc) || defined(sparcv9) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
56 |
#include "sun_jvm_hotspot_debugger_sparc_SPARCThreadContext.h" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
57 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
58 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
59 |
#if defined(ppc64) || defined(ppc64le) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
60 |
#include "sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext.h" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
61 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
62 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
63 |
#ifdef aarch64 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
64 |
#include "sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext.h" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
65 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
66 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
67 |
static jfieldID p_ps_prochandle_ID = 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
68 |
static jfieldID threadList_ID = 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
69 |
static jfieldID loadObjectList_ID = 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
70 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
71 |
static jmethodID createClosestSymbol_ID = 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
72 |
static jmethodID createLoadObject_ID = 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
73 |
static jmethodID getThreadForThreadId_ID = 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
74 |
static jmethodID listAdd_ID = 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
75 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
76 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
77 |
* SA_ALTROOT environment variable. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
78 |
* This memory holds env string for putenv(3). |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
79 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
80 |
static char *saaltroot = NULL; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
81 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
82 |
#define CHECK_EXCEPTION_(value) if (env->ExceptionOccurred()) { return value; } |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
83 |
#define CHECK_EXCEPTION if (env->ExceptionOccurred()) { return;} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
84 |
#define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; } |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
85 |
#define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
86 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
87 |
void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
88 |
jclass clazz; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
89 |
clazz = env->FindClass("sun/jvm/hotspot/debugger/DebuggerException"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
90 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
91 |
env->ThrowNew(clazz, errMsg); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
92 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
93 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
94 |
struct ps_prochandle* get_proc_handle(JNIEnv* env, jobject this_obj) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
95 |
jlong ptr = env->GetLongField(this_obj, p_ps_prochandle_ID); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
96 |
return (struct ps_prochandle*)(intptr_t)ptr; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
97 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
98 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
99 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
100 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
101 |
* Method: init0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
102 |
* Signature: ()V |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
103 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
104 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
105 |
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_init0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
106 |
(JNIEnv *env, jclass cls) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
107 |
jclass listClass; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
108 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
109 |
if (init_libproc(getenv("LIBSAPROC_DEBUG") != NULL) != true) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
110 |
THROW_NEW_DEBUGGER_EXCEPTION("can't initialize libproc"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
111 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
112 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
113 |
// fields we use |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
114 |
p_ps_prochandle_ID = env->GetFieldID(cls, "p_ps_prochandle", "J"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
115 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
116 |
threadList_ID = env->GetFieldID(cls, "threadList", "Ljava/util/List;"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
117 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
118 |
loadObjectList_ID = env->GetFieldID(cls, "loadObjectList", "Ljava/util/List;"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
119 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
120 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
121 |
// methods we use |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
122 |
createClosestSymbol_ID = env->GetMethodID(cls, "createClosestSymbol", |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
123 |
"(Ljava/lang/String;J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
124 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
125 |
createLoadObject_ID = env->GetMethodID(cls, "createLoadObject", |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
126 |
"(Ljava/lang/String;JJ)Lsun/jvm/hotspot/debugger/cdbg/LoadObject;"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
127 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
128 |
getThreadForThreadId_ID = env->GetMethodID(cls, "getThreadForThreadId", |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
129 |
"(J)Lsun/jvm/hotspot/debugger/ThreadProxy;"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
130 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
131 |
// java.util.List method we call |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
132 |
listClass = env->FindClass("java/util/List"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
133 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
134 |
listAdd_ID = env->GetMethodID(listClass, "add", "(Ljava/lang/Object;)Z"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
135 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
136 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
137 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
138 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
139 |
JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getAddressSize |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
140 |
(JNIEnv *env, jclass cls) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
141 |
{ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
142 |
#ifdef _LP64 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
143 |
return 8; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
144 |
#else |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
145 |
return 4; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
146 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
147 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
148 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
149 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
150 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
151 |
static void fillThreadsAndLoadObjects(JNIEnv* env, jobject this_obj, struct ps_prochandle* ph) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
152 |
int n = 0, i = 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
153 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
154 |
// add threads |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
155 |
n = get_num_threads(ph); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
156 |
for (i = 0; i < n; i++) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
157 |
jobject thread; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
158 |
jobject threadList; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
159 |
lwpid_t lwpid; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
160 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
161 |
lwpid = get_lwp_id(ph, i); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
162 |
thread = env->CallObjectMethod(this_obj, getThreadForThreadId_ID, (jlong)lwpid); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
163 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
164 |
threadList = env->GetObjectField(this_obj, threadList_ID); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
165 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
166 |
env->CallBooleanMethod(threadList, listAdd_ID, thread); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
167 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
168 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
169 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
170 |
// add load objects |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
171 |
n = get_num_libs(ph); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
172 |
for (i = 0; i < n; i++) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
173 |
uintptr_t base; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
174 |
const char* name; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
175 |
jobject loadObject; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
176 |
jobject loadObjectList; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
177 |
jstring str; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
178 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
179 |
base = get_lib_base(ph, i); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
180 |
name = get_lib_name(ph, i); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
181 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
182 |
str = env->NewStringUTF(name); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
183 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
184 |
loadObject = env->CallObjectMethod(this_obj, createLoadObject_ID, str, (jlong)0, (jlong)base); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
185 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
186 |
loadObjectList = env->GetObjectField(this_obj, loadObjectList_ID); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
187 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
188 |
env->CallBooleanMethod(loadObjectList, listAdd_ID, loadObject); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
189 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
190 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
191 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
192 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
193 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
194 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
195 |
* Verify that a named ELF binary file (core or executable) has the same |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
196 |
* bitness as ourselves. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
197 |
* Throw an exception if there is a mismatch or other problem. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
198 |
* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
199 |
* If we proceed using a mismatched debugger/debuggee, the best to hope |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
200 |
* for is a missing symbol, the worst is a crash searching for debug symbols. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
201 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
202 |
void verifyBitness(JNIEnv *env, const char *binaryName) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
203 |
int fd = open(binaryName, O_RDONLY); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
204 |
if (fd < 0) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
205 |
THROW_NEW_DEBUGGER_EXCEPTION("cannot open binary file"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
206 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
207 |
unsigned char elf_ident[EI_NIDENT]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
208 |
int i = read(fd, &elf_ident, sizeof(elf_ident)); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
209 |
close(fd); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
210 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
211 |
if (i < 0) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
212 |
THROW_NEW_DEBUGGER_EXCEPTION("cannot read binary file"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
213 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
214 |
#ifndef _LP64 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
215 |
if (elf_ident[EI_CLASS] == ELFCLASS64) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
216 |
THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 64 bit, use 64-bit java for debugger"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
217 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
218 |
#else |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
219 |
if (elf_ident[EI_CLASS] != ELFCLASS64) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
220 |
THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 32 bit, use 32 bit java for debugger"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
221 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
222 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
223 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
224 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
225 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
226 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
227 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
228 |
* Method: setSAAltRoot0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
229 |
* Signature: (Ljava/lang/String;)V |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
230 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
231 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
232 |
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_setSAAltRoot0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
233 |
(JNIEnv *env, jobject this_obj, jstring altroot) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
234 |
if (saaltroot != NULL) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
235 |
free(saaltroot); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
236 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
237 |
const char *path = env->GetStringUTFChars(altroot, JNI_FALSE); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
238 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
239 |
* `saaltroot` is used for putenv(). |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
240 |
* So we need to keep this memory. |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
241 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
242 |
static const char *PREFIX = "SA_ALTROOT="; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
243 |
size_t len = strlen(PREFIX) + strlen(path) + 1; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
244 |
saaltroot = (char *)malloc(len); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
245 |
snprintf(saaltroot, len, "%s%s", PREFIX, path); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
246 |
putenv(saaltroot); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
247 |
env->ReleaseStringUTFChars(altroot, path); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
248 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
249 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
250 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
251 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
252 |
* Method: attach0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
253 |
* Signature: (I)V |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
254 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
255 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
256 |
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_attach0__I |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
257 |
(JNIEnv *env, jobject this_obj, jint jpid) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
258 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
259 |
// For bitness checking, locate binary at /proc/jpid/exe |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
260 |
char buf[PATH_MAX]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
261 |
snprintf((char *) &buf, PATH_MAX, "/proc/%d/exe", jpid); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
262 |
verifyBitness(env, (char *) &buf); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
263 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
264 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
265 |
char err_buf[200]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
266 |
struct ps_prochandle* ph; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
267 |
if ((ph = Pgrab(jpid, err_buf, sizeof(err_buf))) == NULL) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
268 |
char msg[230]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
269 |
snprintf(msg, sizeof(msg), "Can't attach to the process: %s", err_buf); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
270 |
THROW_NEW_DEBUGGER_EXCEPTION(msg); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
271 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
272 |
env->SetLongField(this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
273 |
fillThreadsAndLoadObjects(env, this_obj, ph); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
274 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
275 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
276 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
277 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
278 |
* Method: attach0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
279 |
* Signature: (Ljava/lang/String;Ljava/lang/String;)V |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
280 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
281 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
282 |
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
283 |
(JNIEnv *env, jobject this_obj, jstring execName, jstring coreName) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
284 |
const char *execName_cstr; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
285 |
const char *coreName_cstr; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
286 |
jboolean isCopy; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
287 |
struct ps_prochandle* ph; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
288 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
289 |
execName_cstr = env->GetStringUTFChars(execName, &isCopy); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
290 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
291 |
coreName_cstr = env->GetStringUTFChars(coreName, &isCopy); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
292 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
293 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
294 |
verifyBitness(env, execName_cstr); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
295 |
CHECK_EXCEPTION; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
296 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
297 |
if ( (ph = Pgrab_core(execName_cstr, coreName_cstr)) == NULL) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
298 |
env->ReleaseStringUTFChars(execName, execName_cstr); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
299 |
env->ReleaseStringUTFChars(coreName, coreName_cstr); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
300 |
THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the core file"); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
301 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
302 |
env->SetLongField(this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
303 |
env->ReleaseStringUTFChars(execName, execName_cstr); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
304 |
env->ReleaseStringUTFChars(coreName, coreName_cstr); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
305 |
fillThreadsAndLoadObjects(env, this_obj, ph); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
306 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
307 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
308 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
309 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
310 |
* Method: detach0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
311 |
* Signature: ()V |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
312 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
313 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
314 |
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_detach0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
315 |
(JNIEnv *env, jobject this_obj) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
316 |
struct ps_prochandle* ph = get_proc_handle(env, this_obj); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
317 |
if (ph != NULL) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
318 |
Prelease(ph); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
319 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
320 |
if (saaltroot != NULL) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
321 |
free(saaltroot); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
322 |
saaltroot = NULL; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
323 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
324 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
325 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
326 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
327 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
328 |
* Method: lookupByName0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
329 |
* Signature: (Ljava/lang/String;Ljava/lang/String;)J |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
330 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
331 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
332 |
JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_lookupByName0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
333 |
(JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
334 |
const char *objectName_cstr, *symbolName_cstr; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
335 |
jlong addr; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
336 |
jboolean isCopy; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
337 |
struct ps_prochandle* ph = get_proc_handle(env, this_obj); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
338 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
339 |
objectName_cstr = NULL; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
340 |
if (objectName != NULL) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
341 |
objectName_cstr = env->GetStringUTFChars(objectName, &isCopy); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
342 |
CHECK_EXCEPTION_(0); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
343 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
344 |
symbolName_cstr = env->GetStringUTFChars(symbolName, &isCopy); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
345 |
CHECK_EXCEPTION_(0); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
346 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
347 |
addr = (jlong) lookup_symbol(ph, objectName_cstr, symbolName_cstr); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
348 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
349 |
if (objectName_cstr != NULL) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
350 |
env->ReleaseStringUTFChars(objectName, objectName_cstr); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
351 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
352 |
env->ReleaseStringUTFChars(symbolName, symbolName_cstr); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
353 |
return addr; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
354 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
355 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
356 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
357 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
358 |
* Method: lookupByAddress0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
359 |
* Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
360 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
361 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
362 |
JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_lookupByAddress0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
363 |
(JNIEnv *env, jobject this_obj, jlong addr) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
364 |
uintptr_t offset; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
365 |
jobject obj; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
366 |
jstring str; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
367 |
const char* sym = NULL; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
368 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
369 |
struct ps_prochandle* ph = get_proc_handle(env, this_obj); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
370 |
sym = symbol_for_pc(ph, (uintptr_t) addr, &offset); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
371 |
if (sym == NULL) return 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
372 |
str = env->NewStringUTF(sym); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
373 |
CHECK_EXCEPTION_(NULL); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
374 |
obj = env->CallObjectMethod(this_obj, createClosestSymbol_ID, str, (jlong)offset); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
375 |
CHECK_EXCEPTION_(NULL); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
376 |
return obj; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
377 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
378 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
379 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
380 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
381 |
* Method: readBytesFromProcess0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
382 |
* Signature: (JJ)Lsun/jvm/hotspot/debugger/ReadResult; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
383 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
384 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
385 |
JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_readBytesFromProcess0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
386 |
(JNIEnv *env, jobject this_obj, jlong addr, jlong numBytes) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
387 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
388 |
jboolean isCopy; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
389 |
jbyteArray array; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
390 |
jbyte *bufPtr; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
391 |
ps_err_e err; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
392 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
393 |
array = env->NewByteArray(numBytes); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
394 |
CHECK_EXCEPTION_(0); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
395 |
bufPtr = env->GetByteArrayElements(array, &isCopy); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
396 |
CHECK_EXCEPTION_(0); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
397 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
398 |
err = ps_pdread(get_proc_handle(env, this_obj), (psaddr_t) (uintptr_t)addr, bufPtr, numBytes); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
399 |
env->ReleaseByteArrayElements(array, bufPtr, 0); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
400 |
return (err == PS_OK)? array : 0; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
401 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
402 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
403 |
#if defined(i586) || defined(amd64) || defined(sparc) || defined(sparcv9) | defined(ppc64) || defined(ppc64le) || defined(aarch64) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
404 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
405 |
JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getThreadIntegerRegisterSet0 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
406 |
(JNIEnv *env, jobject this_obj, jint lwp_id) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
407 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
408 |
struct user_regs_struct gregs; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
409 |
jboolean isCopy; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
410 |
jlongArray array; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
411 |
jlong *regs; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
412 |
int i; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
413 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
414 |
struct ps_prochandle* ph = get_proc_handle(env, this_obj); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
415 |
if (get_lwp_regs(ph, lwp_id, &gregs) != true) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
416 |
THROW_NEW_DEBUGGER_EXCEPTION_("get_thread_regs failed for a lwp", 0); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
417 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
418 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
419 |
#undef NPRGREG |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
420 |
#ifdef i586 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
421 |
#define NPRGREG sun_jvm_hotspot_debugger_x86_X86ThreadContext_NPRGREG |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
422 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
423 |
#ifdef amd64 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
424 |
#define NPRGREG sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_NPRGREG |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
425 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
426 |
#ifdef aarch64 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
427 |
#define NPRGREG sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext_NPRGREG |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
428 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
429 |
#if defined(sparc) || defined(sparcv9) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
430 |
#define NPRGREG sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_NPRGREG |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
431 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
432 |
#if defined(ppc64) || defined(ppc64le) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
433 |
#define NPRGREG sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_NPRGREG |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
434 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
435 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
436 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
437 |
array = env->NewLongArray(NPRGREG); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
438 |
CHECK_EXCEPTION_(0); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
439 |
regs = env->GetLongArrayElements(array, &isCopy); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
440 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
441 |
#undef REG_INDEX |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
442 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
443 |
#ifdef i586 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
444 |
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
445 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
446 |
regs[REG_INDEX(GS)] = (uintptr_t) gregs.xgs; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
447 |
regs[REG_INDEX(FS)] = (uintptr_t) gregs.xfs; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
448 |
regs[REG_INDEX(ES)] = (uintptr_t) gregs.xes; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
449 |
regs[REG_INDEX(DS)] = (uintptr_t) gregs.xds; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
450 |
regs[REG_INDEX(EDI)] = (uintptr_t) gregs.edi; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
451 |
regs[REG_INDEX(ESI)] = (uintptr_t) gregs.esi; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
452 |
regs[REG_INDEX(FP)] = (uintptr_t) gregs.ebp; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
453 |
regs[REG_INDEX(SP)] = (uintptr_t) gregs.esp; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
454 |
regs[REG_INDEX(EBX)] = (uintptr_t) gregs.ebx; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
455 |
regs[REG_INDEX(EDX)] = (uintptr_t) gregs.edx; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
456 |
regs[REG_INDEX(ECX)] = (uintptr_t) gregs.ecx; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
457 |
regs[REG_INDEX(EAX)] = (uintptr_t) gregs.eax; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
458 |
regs[REG_INDEX(PC)] = (uintptr_t) gregs.eip; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
459 |
regs[REG_INDEX(CS)] = (uintptr_t) gregs.xcs; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
460 |
regs[REG_INDEX(SS)] = (uintptr_t) gregs.xss; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
461 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
462 |
#endif /* i586 */ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
463 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
464 |
#ifdef amd64 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
465 |
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
466 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
467 |
regs[REG_INDEX(R15)] = gregs.r15; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
468 |
regs[REG_INDEX(R14)] = gregs.r14; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
469 |
regs[REG_INDEX(R13)] = gregs.r13; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
470 |
regs[REG_INDEX(R12)] = gregs.r12; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
471 |
regs[REG_INDEX(RBP)] = gregs.rbp; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
472 |
regs[REG_INDEX(RBX)] = gregs.rbx; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
473 |
regs[REG_INDEX(R11)] = gregs.r11; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
474 |
regs[REG_INDEX(R10)] = gregs.r10; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
475 |
regs[REG_INDEX(R9)] = gregs.r9; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
476 |
regs[REG_INDEX(R8)] = gregs.r8; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
477 |
regs[REG_INDEX(RAX)] = gregs.rax; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
478 |
regs[REG_INDEX(RCX)] = gregs.rcx; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
479 |
regs[REG_INDEX(RDX)] = gregs.rdx; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
480 |
regs[REG_INDEX(RSI)] = gregs.rsi; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
481 |
regs[REG_INDEX(RDI)] = gregs.rdi; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
482 |
regs[REG_INDEX(RIP)] = gregs.rip; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
483 |
regs[REG_INDEX(CS)] = gregs.cs; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
484 |
regs[REG_INDEX(RSP)] = gregs.rsp; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
485 |
regs[REG_INDEX(SS)] = gregs.ss; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
486 |
regs[REG_INDEX(FSBASE)] = gregs.fs_base; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
487 |
regs[REG_INDEX(GSBASE)] = gregs.gs_base; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
488 |
regs[REG_INDEX(DS)] = gregs.ds; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
489 |
regs[REG_INDEX(ES)] = gregs.es; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
490 |
regs[REG_INDEX(FS)] = gregs.fs; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
491 |
regs[REG_INDEX(GS)] = gregs.gs; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
492 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
493 |
#endif /* amd64 */ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
494 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
495 |
#if defined(sparc) || defined(sparcv9) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
496 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
497 |
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_##reg |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
498 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
499 |
#ifdef _LP64 |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
500 |
regs[REG_INDEX(R_PSR)] = gregs.tstate; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
501 |
regs[REG_INDEX(R_PC)] = gregs.tpc; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
502 |
regs[REG_INDEX(R_nPC)] = gregs.tnpc; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
503 |
regs[REG_INDEX(R_Y)] = gregs.y; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
504 |
#else |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
505 |
regs[REG_INDEX(R_PSR)] = gregs.psr; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
506 |
regs[REG_INDEX(R_PC)] = gregs.pc; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
507 |
regs[REG_INDEX(R_nPC)] = gregs.npc; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
508 |
regs[REG_INDEX(R_Y)] = gregs.y; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
509 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
510 |
regs[REG_INDEX(R_G0)] = 0 ; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
511 |
regs[REG_INDEX(R_G1)] = gregs.u_regs[0]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
512 |
regs[REG_INDEX(R_G2)] = gregs.u_regs[1]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
513 |
regs[REG_INDEX(R_G3)] = gregs.u_regs[2]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
514 |
regs[REG_INDEX(R_G4)] = gregs.u_regs[3]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
515 |
regs[REG_INDEX(R_G5)] = gregs.u_regs[4]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
516 |
regs[REG_INDEX(R_G6)] = gregs.u_regs[5]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
517 |
regs[REG_INDEX(R_G7)] = gregs.u_regs[6]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
518 |
regs[REG_INDEX(R_O0)] = gregs.u_regs[7]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
519 |
regs[REG_INDEX(R_O1)] = gregs.u_regs[8]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
520 |
regs[REG_INDEX(R_O2)] = gregs.u_regs[ 9]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
521 |
regs[REG_INDEX(R_O3)] = gregs.u_regs[10]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
522 |
regs[REG_INDEX(R_O4)] = gregs.u_regs[11]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
523 |
regs[REG_INDEX(R_O5)] = gregs.u_regs[12]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
524 |
regs[REG_INDEX(R_O6)] = gregs.u_regs[13]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
525 |
regs[REG_INDEX(R_O7)] = gregs.u_regs[14]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
526 |
#endif /* sparc */ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
527 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
528 |
#if defined(aarch64) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
529 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
530 |
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext_##reg |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
531 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
532 |
{ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
533 |
int i; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
534 |
for (i = 0; i < 31; i++) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
535 |
regs[i] = gregs.regs[i]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
536 |
regs[REG_INDEX(SP)] = gregs.sp; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
537 |
regs[REG_INDEX(PC)] = gregs.pc; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
538 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
539 |
#endif /* aarch64 */ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
540 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
541 |
#if defined(ppc64) || defined(ppc64le) |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
542 |
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_##reg |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
543 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
544 |
regs[REG_INDEX(LR)] = gregs.link; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
545 |
regs[REG_INDEX(NIP)] = gregs.nip; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
546 |
regs[REG_INDEX(R0)] = gregs.gpr[0]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
547 |
regs[REG_INDEX(R1)] = gregs.gpr[1]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
548 |
regs[REG_INDEX(R2)] = gregs.gpr[2]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
549 |
regs[REG_INDEX(R3)] = gregs.gpr[3]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
550 |
regs[REG_INDEX(R4)] = gregs.gpr[4]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
551 |
regs[REG_INDEX(R5)] = gregs.gpr[5]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
552 |
regs[REG_INDEX(R6)] = gregs.gpr[6]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
553 |
regs[REG_INDEX(R7)] = gregs.gpr[7]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
554 |
regs[REG_INDEX(R8)] = gregs.gpr[8]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
555 |
regs[REG_INDEX(R9)] = gregs.gpr[9]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
556 |
regs[REG_INDEX(R10)] = gregs.gpr[10]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
557 |
regs[REG_INDEX(R11)] = gregs.gpr[11]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
558 |
regs[REG_INDEX(R12)] = gregs.gpr[12]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
559 |
regs[REG_INDEX(R13)] = gregs.gpr[13]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
560 |
regs[REG_INDEX(R14)] = gregs.gpr[14]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
561 |
regs[REG_INDEX(R15)] = gregs.gpr[15]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
562 |
regs[REG_INDEX(R16)] = gregs.gpr[16]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
563 |
regs[REG_INDEX(R17)] = gregs.gpr[17]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
564 |
regs[REG_INDEX(R18)] = gregs.gpr[18]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
565 |
regs[REG_INDEX(R19)] = gregs.gpr[19]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
566 |
regs[REG_INDEX(R20)] = gregs.gpr[20]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
567 |
regs[REG_INDEX(R21)] = gregs.gpr[21]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
568 |
regs[REG_INDEX(R22)] = gregs.gpr[22]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
569 |
regs[REG_INDEX(R23)] = gregs.gpr[23]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
570 |
regs[REG_INDEX(R24)] = gregs.gpr[24]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
571 |
regs[REG_INDEX(R25)] = gregs.gpr[25]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
572 |
regs[REG_INDEX(R26)] = gregs.gpr[26]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
573 |
regs[REG_INDEX(R27)] = gregs.gpr[27]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
574 |
regs[REG_INDEX(R28)] = gregs.gpr[28]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
575 |
regs[REG_INDEX(R29)] = gregs.gpr[29]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
576 |
regs[REG_INDEX(R30)] = gregs.gpr[30]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
577 |
regs[REG_INDEX(R31)] = gregs.gpr[31]; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
578 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
579 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
580 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
581 |
env->ReleaseLongArrayElements(array, regs, JNI_COMMIT); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
582 |
return array; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
583 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
584 |
#endif |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
585 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
586 |
/* |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
587 |
* Class: sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
588 |
* Method: demangle |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
589 |
* Signature: (Ljava/lang/String;)Ljava/lang/String; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
590 |
*/ |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
591 |
extern "C" |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
592 |
JNIEXPORT jstring JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_demangle |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
593 |
(JNIEnv *env, jobject this_obj, jstring jsym) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
594 |
int status; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
595 |
jstring result = NULL; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
596 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
597 |
const char *sym = env->GetStringUTFChars(jsym, JNI_FALSE); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
598 |
char *demangled = abi::__cxa_demangle(sym, NULL, 0, &status); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
599 |
env->ReleaseStringUTFChars(jsym, sym); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
600 |
if ((demangled != NULL) && (status == 0)) { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
601 |
result = env->NewStringUTF(demangled); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
602 |
free(demangled); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
603 |
} else if (status == -2) { // not C++ ABI mangling rules - maybe C style |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
604 |
result = jsym; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
605 |
} else { |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
606 |
THROW_NEW_DEBUGGER_EXCEPTION_("Could not demangle", NULL); |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
607 |
} |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
608 |
|
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
609 |
return result; |
e2dfab7beccb
8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents:
diff
changeset
|
610 |
} |