annotate src/share/vm/prims/jvmtiTrace.cpp @ 6972:bd7a7ce2e264

6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
author minqi
date Mon, 12 Nov 2012 14:03:53 -0800
parents da91efe96a93
children 070d523b96a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 470
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 470
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 470
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "jvmtifiles/jvmtiEnv.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "prims/jvmtiTrace.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 //
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // class JvmtiTrace
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Support for JVMTI tracing code
a61af66fc99e Initial load
duke
parents:
diff changeset
33 //
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // ------------
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Usage:
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // -XX:TraceJVMTI=DESC,DESC,DESC
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // DESC is DOMAIN ACTION KIND
a61af66fc99e Initial load
duke
parents:
diff changeset
39 //
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // DOMAIN is function name
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // event name
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // "all" (all functions and events)
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // "func" (all functions except boring)
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // "allfunc" (all functions)
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // "event" (all events)
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // "ec" (event controller)
a61af66fc99e Initial load
duke
parents:
diff changeset
47 //
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // ACTION is "+" (add)
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // "-" (remove)
a61af66fc99e Initial load
duke
parents:
diff changeset
50 //
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // KIND is
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // for func
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // "i" (input params)
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // "e" (error returns)
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // "o" (output)
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // for event
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // "t" (event triggered aka posted)
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // "s" (event sent)
a61af66fc99e Initial load
duke
parents:
diff changeset
59 //
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Example:
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // -XX:TraceJVMTI=ec+,GetCallerFrame+ie,Breakpoint+s
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 #ifdef JVMTI_TRACE
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 bool JvmtiTrace::_initialized = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 bool JvmtiTrace::_on = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 bool JvmtiTrace::_trace_event_controller = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void JvmtiTrace::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 if (_initialized) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 SafeResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 const char *very_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 const char *curr;
370
885fe0f95828 6744783: HotSpot segfaults if given -XX options with an empty string argument
never
parents: 0
diff changeset
77 if (TraceJVMTI != NULL) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
78 curr = TraceJVMTI;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 curr = ""; // hack in fixed tracing here
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 very_end = curr + strlen(curr);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 while (curr < very_end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 const char *curr_end = strchr(curr, ',');
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (curr_end == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 curr_end = very_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 const char *op_pos = strchr(curr, '+');
a61af66fc99e Initial load
duke
parents:
diff changeset
89 const char *minus_pos = strchr(curr, '-');
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (minus_pos != NULL && (minus_pos < op_pos || op_pos == NULL)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 op_pos = minus_pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 char op;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 const char *flags = op_pos + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 const char *flags_end = curr_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if (op_pos == NULL || op_pos > curr_end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 flags = "ies";
a61af66fc99e Initial load
duke
parents:
diff changeset
98 flags_end = flags + strlen(flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 op_pos = curr_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 op = '+';
a61af66fc99e Initial load
duke
parents:
diff changeset
101 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 op = *op_pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 jbyte bits = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 for (; flags < flags_end; ++flags) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 switch (*flags) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 case 'i':
a61af66fc99e Initial load
duke
parents:
diff changeset
108 bits |= SHOW_IN;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 case 'I':
a61af66fc99e Initial load
duke
parents:
diff changeset
111 bits |= SHOW_IN_DETAIL;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 case 'e':
a61af66fc99e Initial load
duke
parents:
diff changeset
114 bits |= SHOW_ERROR;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 case 'o':
a61af66fc99e Initial load
duke
parents:
diff changeset
117 bits |= SHOW_OUT;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 case 'O':
a61af66fc99e Initial load
duke
parents:
diff changeset
120 bits |= SHOW_OUT_DETAIL;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 case 't':
a61af66fc99e Initial load
duke
parents:
diff changeset
123 bits |= SHOW_EVENT_TRIGGER;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 case 's':
a61af66fc99e Initial load
duke
parents:
diff changeset
126 bits |= SHOW_EVENT_SENT;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
129 tty->print_cr("Invalid trace flag '%c'", *flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 const int FUNC = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 const int EXCLUDE = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 const int ALL_FUNC = 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 const int EVENT = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 const int ALL_EVENT = 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 int domain = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 size_t len = op_pos - curr;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if (op_pos == curr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 domain = ALL_FUNC | FUNC | ALL_EVENT | EVENT | EXCLUDE;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 } else if (len==3 && strncmp(curr, "all", 3)==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 domain = ALL_FUNC | FUNC | ALL_EVENT | EVENT;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 } else if (len==7 && strncmp(curr, "allfunc", 7)==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 domain = ALL_FUNC | FUNC;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 } else if (len==4 && strncmp(curr, "func", 4)==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 domain = ALL_FUNC | FUNC | EXCLUDE;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 } else if (len==8 && strncmp(curr, "allevent", 8)==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 domain = ALL_EVENT | EVENT;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 } else if (len==5 && strncmp(curr, "event", 5)==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 domain = ALL_EVENT | EVENT;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 } else if (len==2 && strncmp(curr, "ec", 2)==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 _trace_event_controller = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 tty->print_cr("JVMTI Tracing the event controller");
a61af66fc99e Initial load
duke
parents:
diff changeset
155 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 domain = FUNC | EVENT; // go searching
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 int exclude_index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 if (domain & FUNC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (domain & ALL_FUNC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (domain & EXCLUDE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 tty->print("JVMTI Tracing all significant functions");
a61af66fc99e Initial load
duke
parents:
diff changeset
164 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 tty->print_cr("JVMTI Tracing all functions");
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 for (int i = 0; i <= _max_function_index; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 if (domain & EXCLUDE && i == _exclude_functions[exclude_index]) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 ++exclude_index;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 bool do_op = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (domain & ALL_FUNC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 do_op = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 const char *fname = function_name(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 if (fname != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 size_t fnlen = strlen(fname);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 if (len==fnlen && strncmp(curr, fname, fnlen)==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 tty->print_cr("JVMTI Tracing the function: %s", fname);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 do_op = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 if (do_op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (op == '+') {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 _trace_flags[i] |= bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 _trace_flags[i] &= ~bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 _on = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 if (domain & EVENT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 if (domain & ALL_EVENT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 tty->print_cr("JVMTI Tracing all events");
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 for (int i = 0; i <= _max_event_index; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 bool do_op = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
202 if (domain & ALL_EVENT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 do_op = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 const char *ename = event_name(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
206 if (ename != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 size_t evtlen = strlen(ename);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if (len==evtlen && strncmp(curr, ename, evtlen)==0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 tty->print_cr("JVMTI Tracing the event: %s", ename);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 do_op = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (do_op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (op == '+') {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 _event_trace_flags[i] |= bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 _event_trace_flags[i] &= ~bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 _on = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 if (!_on && (domain & (FUNC|EVENT))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 tty->print_cr("JVMTI Trace domain not found");
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 curr = curr_end + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229 _initialized = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 void JvmtiTrace::shutdown() {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 _on = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 _trace_event_controller = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 for (i = 0; i <= _max_function_index; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 _trace_flags[i] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 for (i = 0; i <= _max_event_index; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 _event_trace_flags[i] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 const char* JvmtiTrace::enum_name(const char** names, const jint* values, jint value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 for (int index = 0; names[index] != 0; ++index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (values[index] == value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 return names[index];
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return "*INVALID-ENUM-VALUE*";
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // return a valid string no matter what state the thread is in
a61af66fc99e Initial load
duke
parents:
diff changeset
257 const char *JvmtiTrace::safe_get_thread_name(Thread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 if (thread == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return "NULL";
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 if (!thread->is_Java_thread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 return thread->name();
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 JavaThread *java_thread = (JavaThread *)thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 oop threadObj = java_thread->threadObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (threadObj == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 return "NULL";
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269 typeArrayOop name = java_lang_Thread::name(threadObj);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (name == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return "<NOT FILLED IN>";
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 return UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // return the name of the current thread
a61af66fc99e Initial load
duke
parents:
diff changeset
278 const char *JvmtiTrace::safe_get_current_thread_name() {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 if (JvmtiEnv::is_vm_live()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 return JvmtiTrace::safe_get_thread_name(Thread::current());
a61af66fc99e Initial load
duke
parents:
diff changeset
281 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 return "VM not live";
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // return a valid string no matter what the state of k_mirror
a61af66fc99e Initial load
duke
parents:
diff changeset
287 const char * JvmtiTrace::get_class_name(oop k_mirror) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 if (java_lang_Class::is_primitive(k_mirror)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 return "primitive";
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
291 Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
292 if (k_oop == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 return "INVALID";
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295 return Klass::cast(k_oop)->external_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 #endif /*JVMTI_TRACE */