|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
25 | 25 | #include <string.h>
|
26 | 26 | #include "JVMTITools.h"
|
27 | 27 |
|
28 |
| -extern "C" { |
29 |
| - |
30 |
| -const char* TranslateState(jint flags) { |
31 |
| - static char str[15 * 20]; |
32 |
| - |
33 |
| - if (flags == 0) |
34 |
| - return "<none>"; |
35 |
| - |
36 |
| - str[0] = '\0'; |
37 |
| - |
38 |
| - if (flags & JVMTI_THREAD_STATE_ALIVE) { |
39 |
| - strcat(str, " ALIVE"); |
40 |
| - } |
41 |
| - |
42 |
| - if (flags & JVMTI_THREAD_STATE_TERMINATED) { |
43 |
| - strcat(str, " TERMINATED"); |
44 |
| - } |
45 |
| - |
46 |
| - if (flags & JVMTI_THREAD_STATE_RUNNABLE) { |
47 |
| - strcat(str, " RUNNABLE"); |
48 |
| - } |
49 |
| - |
50 |
| - if (flags & JVMTI_THREAD_STATE_WAITING) { |
51 |
| - strcat(str, " WAITING"); |
52 |
| - } |
53 |
| - |
54 |
| - if (flags & JVMTI_THREAD_STATE_WAITING_INDEFINITELY) { |
55 |
| - strcat(str, " WAITING_INDEFINITELY"); |
56 |
| - } |
57 |
| - |
58 |
| - if (flags & JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT) { |
59 |
| - strcat(str, " WAITING_WITH_TIMEOUT"); |
60 |
| - } |
61 |
| - |
62 |
| - if (flags & JVMTI_THREAD_STATE_SLEEPING) { |
63 |
| - strcat(str, " SLEEPING"); |
64 |
| - } |
65 |
| - |
66 |
| - if (flags & JVMTI_THREAD_STATE_IN_OBJECT_WAIT) { |
67 |
| - strcat(str, " IN_OBJECT_WAIT"); |
68 |
| - } |
69 |
| - |
70 |
| - if (flags & JVMTI_THREAD_STATE_PARKED) { |
71 |
| - strcat(str, " PARKED"); |
72 |
| - } |
73 |
| - |
74 |
| - if (flags & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) { |
75 |
| - strcat(str, " BLOCKED_ON_MONITOR_ENTER"); |
76 |
| - } |
77 |
| - |
78 |
| - if (flags & JVMTI_THREAD_STATE_SUSPENDED) { |
79 |
| - strcat(str, " SUSPENDED"); |
80 |
| - } |
81 |
| - |
82 |
| - if (flags & JVMTI_THREAD_STATE_INTERRUPTED) { |
83 |
| - strcat(str, " INTERRUPTED"); |
84 |
| - } |
85 |
| - |
86 |
| - if (flags & JVMTI_THREAD_STATE_IN_NATIVE) { |
87 |
| - strcat(str, " IN_NATIVE"); |
88 |
| - } |
89 |
| - |
90 |
| - |
91 |
| - return str; |
92 |
| -} |
93 |
| - |
94 |
| -const char* TranslateEvent(jvmtiEvent event_type) { |
95 |
| - switch (event_type) { |
96 |
| - case JVMTI_EVENT_VM_INIT: |
97 |
| - return ("JVMTI_EVENT_VM_INIT"); |
98 |
| - case JVMTI_EVENT_VM_DEATH: |
99 |
| - return ("JVMTI_EVENT_VM_DEATH"); |
100 |
| - case JVMTI_EVENT_THREAD_START: |
101 |
| - return ("JVMTI_EVENT_THREAD_START"); |
102 |
| - case JVMTI_EVENT_THREAD_END: |
103 |
| - return ("JVMTI_EVENT_THREAD_END"); |
104 |
| - case JVMTI_EVENT_CLASS_FILE_LOAD_HOOK: |
105 |
| - return ("JVMTI_EVENT_CLASS_FILE_LOAD_HOOK"); |
106 |
| - case JVMTI_EVENT_CLASS_LOAD: |
107 |
| - return ("JVMTI_EVENT_CLASS_LOAD"); |
108 |
| - case JVMTI_EVENT_CLASS_PREPARE: |
109 |
| - return ("JVMTI_EVENT_CLASS_PREPARE"); |
110 |
| - case JVMTI_EVENT_VM_START: |
111 |
| - return ("JVMTI_EVENT_VM_START"); |
112 |
| - case JVMTI_EVENT_EXCEPTION: |
113 |
| - return ("JVMTI_EVENT_EXCEPTION"); |
114 |
| - case JVMTI_EVENT_EXCEPTION_CATCH: |
115 |
| - return ("JVMTI_EVENT_EXCEPTION_CATCH"); |
116 |
| - case JVMTI_EVENT_SINGLE_STEP: |
117 |
| - return ("JVMTI_EVENT_SINGLE_STEP"); |
118 |
| - case JVMTI_EVENT_FRAME_POP: |
119 |
| - return ("JVMTI_EVENT_FRAME_POP"); |
120 |
| - case JVMTI_EVENT_BREAKPOINT: |
121 |
| - return ("JVMTI_EVENT_BREAKPOINT"); |
122 |
| - case JVMTI_EVENT_FIELD_ACCESS: |
123 |
| - return ("JVMTI_EVENT_FIELD_ACCESS"); |
124 |
| - case JVMTI_EVENT_FIELD_MODIFICATION: |
125 |
| - return ("JVMTI_EVENT_FIELD_MODIFICATION"); |
126 |
| - case JVMTI_EVENT_METHOD_ENTRY: |
127 |
| - return ("JVMTI_EVENT_METHOD_ENTRY"); |
128 |
| - case JVMTI_EVENT_METHOD_EXIT: |
129 |
| - return ("JVMTI_EVENT_METHOD_EXIT"); |
130 |
| - case JVMTI_EVENT_NATIVE_METHOD_BIND: |
131 |
| - return ("JVMTI_EVENT_NATIVE_METHOD_BIND"); |
132 |
| - case JVMTI_EVENT_COMPILED_METHOD_LOAD: |
133 |
| - return ("JVMTI_EVENT_COMPILED_METHOD_LOAD"); |
134 |
| - case JVMTI_EVENT_COMPILED_METHOD_UNLOAD: |
135 |
| - return ("JVMTI_EVENT_COMPILED_METHOD_UNLOAD"); |
136 |
| - case JVMTI_EVENT_DYNAMIC_CODE_GENERATED: |
137 |
| - return ("JVMTI_EVENT_DYNAMIC_CODE_GENERATED"); |
138 |
| - case JVMTI_EVENT_DATA_DUMP_REQUEST: |
139 |
| - return ("JVMTI_EVENT_DATA_DUMP_REQUEST"); |
140 |
| - case JVMTI_EVENT_MONITOR_WAIT: |
141 |
| - return ("JVMTI_EVENT_MONITOR_WAIT"); |
142 |
| - case JVMTI_EVENT_MONITOR_WAITED: |
143 |
| - return ("JVMTI_EVENT_MONITOR_WAITED"); |
144 |
| - case JVMTI_EVENT_MONITOR_CONTENDED_ENTER: |
145 |
| - return ("JVMTI_EVENT_MONITOR_CONTENDED_ENTER"); |
146 |
| - case JVMTI_EVENT_MONITOR_CONTENDED_ENTERED: |
147 |
| - return ("JVMTI_EVENT_MONITOR_CONTENDED_ENTERED"); |
148 |
| - case JVMTI_EVENT_GARBAGE_COLLECTION_START: |
149 |
| - return ("JVMTI_EVENT_GARBAGE_COLLECTION_START"); |
150 |
| - case JVMTI_EVENT_GARBAGE_COLLECTION_FINISH: |
151 |
| - return ("JVMTI_EVENT_GARBAGE_COLLECTION_FINISH"); |
152 |
| - case JVMTI_EVENT_OBJECT_FREE: |
153 |
| - return ("JVMTI_EVENT_OBJECT_FREE"); |
154 |
| - case JVMTI_EVENT_VM_OBJECT_ALLOC: |
155 |
| - return ("JVMTI_EVENT_VM_OBJECT_ALLOC"); |
156 |
| - default: |
157 |
| - return ("<unknown event>"); |
158 |
| - } |
159 |
| -} |
160 |
| - |
161 |
| -const char* TranslateError(jvmtiError err) { |
162 |
| - switch (err) { |
163 |
| - case JVMTI_ERROR_NONE: |
164 |
| - return ("JVMTI_ERROR_NONE"); |
165 |
| - case JVMTI_ERROR_INVALID_THREAD: |
166 |
| - return ("JVMTI_ERROR_INVALID_THREAD"); |
167 |
| - case JVMTI_ERROR_INVALID_THREAD_GROUP: |
168 |
| - return ("JVMTI_ERROR_INVALID_THREAD_GROUP"); |
169 |
| - case JVMTI_ERROR_INVALID_PRIORITY: |
170 |
| - return ("JVMTI_ERROR_INVALID_PRIORITY"); |
171 |
| - case JVMTI_ERROR_THREAD_NOT_SUSPENDED: |
172 |
| - return ("JVMTI_ERROR_THREAD_NOT_SUSPENDED"); |
173 |
| - case JVMTI_ERROR_THREAD_SUSPENDED: |
174 |
| - return ("JVMTI_ERROR_THREAD_SUSPENDED"); |
175 |
| - case JVMTI_ERROR_THREAD_NOT_ALIVE: |
176 |
| - return ("JVMTI_ERROR_THREAD_NOT_ALIVE"); |
177 |
| - case JVMTI_ERROR_INVALID_OBJECT: |
178 |
| - return ("JVMTI_ERROR_INVALID_OBJECT"); |
179 |
| - case JVMTI_ERROR_INVALID_CLASS: |
180 |
| - return ("JVMTI_ERROR_INVALID_CLASS"); |
181 |
| - case JVMTI_ERROR_CLASS_NOT_PREPARED: |
182 |
| - return ("JVMTI_ERROR_CLASS_NOT_PREPARED"); |
183 |
| - case JVMTI_ERROR_INVALID_METHODID: |
184 |
| - return ("JVMTI_ERROR_INVALID_METHODID"); |
185 |
| - case JVMTI_ERROR_INVALID_LOCATION: |
186 |
| - return ("JVMTI_ERROR_INVALID_LOCATION"); |
187 |
| - case JVMTI_ERROR_INVALID_FIELDID: |
188 |
| - return ("JVMTI_ERROR_INVALID_FIELDID"); |
189 |
| - case JVMTI_ERROR_NO_MORE_FRAMES: |
190 |
| - return ("JVMTI_ERROR_NO_MORE_FRAMES"); |
191 |
| - case JVMTI_ERROR_OPAQUE_FRAME: |
192 |
| - return ("JVMTI_ERROR_OPAQUE_FRAME"); |
193 |
| - case JVMTI_ERROR_TYPE_MISMATCH: |
194 |
| - return ("JVMTI_ERROR_TYPE_MISMATCH"); |
195 |
| - case JVMTI_ERROR_INVALID_SLOT: |
196 |
| - return ("JVMTI_ERROR_INVALID_SLOT"); |
197 |
| - case JVMTI_ERROR_DUPLICATE: |
198 |
| - return ("JVMTI_ERROR_DUPLICATE"); |
199 |
| - case JVMTI_ERROR_NOT_FOUND: |
200 |
| - return ("JVMTI_ERROR_NOT_FOUND"); |
201 |
| - case JVMTI_ERROR_INVALID_MONITOR: |
202 |
| - return ("JVMTI_ERROR_INVALID_MONITOR"); |
203 |
| - case JVMTI_ERROR_NOT_MONITOR_OWNER: |
204 |
| - return ("JVMTI_ERROR_NOT_MONITOR_OWNER"); |
205 |
| - case JVMTI_ERROR_INTERRUPT: |
206 |
| - return ("JVMTI_ERROR_INTERRUPT"); |
207 |
| - case JVMTI_ERROR_INVALID_CLASS_FORMAT: |
208 |
| - return ("JVMTI_ERROR_INVALID_CLASS_FORMAT"); |
209 |
| - case JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION: |
210 |
| - return ("JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION"); |
211 |
| - case JVMTI_ERROR_FAILS_VERIFICATION: |
212 |
| - return ("JVMTI_ERROR_FAILS_VERIFICATION"); |
213 |
| - case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED: |
214 |
| - return ("JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED"); |
215 |
| - case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED: |
216 |
| - return ("JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED"); |
217 |
| - case JVMTI_ERROR_INVALID_TYPESTATE: |
218 |
| - return ("JVMTI_ERROR_INVALID_TYPESTATE"); |
219 |
| - case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED: |
220 |
| - return ("JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED"); |
221 |
| - case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED: |
222 |
| - return ("JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED"); |
223 |
| - case JVMTI_ERROR_UNSUPPORTED_VERSION: |
224 |
| - return ("JVMTI_ERROR_UNSUPPORTED_VERSION"); |
225 |
| - case JVMTI_ERROR_NAMES_DONT_MATCH: |
226 |
| - return ("JVMTI_ERROR_NAMES_DONT_MATCH"); |
227 |
| - case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED: |
228 |
| - return ("JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED"); |
229 |
| - case JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED: |
230 |
| - return ("JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED"); |
231 |
| - case JVMTI_ERROR_UNMODIFIABLE_CLASS: |
232 |
| - return ("JVMTI_ERROR_UNMODIFIABLE_CLASS"); |
233 |
| - case JVMTI_ERROR_NOT_AVAILABLE: |
234 |
| - return ("JVMTI_ERROR_NOT_AVAILABLE"); |
235 |
| - case JVMTI_ERROR_MUST_POSSESS_CAPABILITY: |
236 |
| - return ("JVMTI_ERROR_MUST_POSSESS_CAPABILITY"); |
237 |
| - case JVMTI_ERROR_NULL_POINTER: |
238 |
| - return ("JVMTI_ERROR_NULL_POINTER"); |
239 |
| - case JVMTI_ERROR_ABSENT_INFORMATION: |
240 |
| - return ("JVMTI_ERROR_ABSENT_INFORMATION"); |
241 |
| - case JVMTI_ERROR_INVALID_EVENT_TYPE: |
242 |
| - return ("JVMTI_ERROR_INVALID_EVENT_TYPE"); |
243 |
| - case JVMTI_ERROR_ILLEGAL_ARGUMENT: |
244 |
| - return ("JVMTI_ERROR_ILLEGAL_ARGUMENT"); |
245 |
| - case JVMTI_ERROR_NATIVE_METHOD: |
246 |
| - return ("JVMTI_ERROR_NATIVE_METHOD"); |
247 |
| - case JVMTI_ERROR_OUT_OF_MEMORY: |
248 |
| - return ("JVMTI_ERROR_OUT_OF_MEMORY"); |
249 |
| - case JVMTI_ERROR_ACCESS_DENIED: |
250 |
| - return ("JVMTI_ERROR_ACCESS_DENIED"); |
251 |
| - case JVMTI_ERROR_WRONG_PHASE: |
252 |
| - return ("JVMTI_ERROR_WRONG_PHASE"); |
253 |
| - case JVMTI_ERROR_INTERNAL: |
254 |
| - return ("JVMTI_ERROR_INTERNAL"); |
255 |
| - case JVMTI_ERROR_UNATTACHED_THREAD: |
256 |
| - return ("JVMTI_ERROR_UNATTACHED_THREAD"); |
257 |
| - case JVMTI_ERROR_INVALID_ENVIRONMENT: |
258 |
| - return ("JVMTI_ERROR_INVALID_ENVIRONMENT"); |
259 |
| - default: |
260 |
| - return ("<unknown error>"); |
261 |
| - } |
262 |
| -} |
263 |
| - |
264 |
| -const char* TranslatePhase(jvmtiPhase phase) { |
265 |
| - switch (phase) { |
266 |
| - case JVMTI_PHASE_ONLOAD: |
267 |
| - return ("JVMTI_PHASE_ONLOAD"); |
268 |
| - case JVMTI_PHASE_PRIMORDIAL: |
269 |
| - return ("JVMTI_PHASE_PRIMORDIAL"); |
270 |
| - case JVMTI_PHASE_START: |
271 |
| - return ("JVMTI_PHASE_START"); |
272 |
| - case JVMTI_PHASE_LIVE: |
273 |
| - return ("JVMTI_PHASE_LIVE"); |
274 |
| - case JVMTI_PHASE_DEAD: |
275 |
| - return ("JVMTI_PHASE_DEAD"); |
276 |
| - default: |
277 |
| - return ("<unknown phase>"); |
278 |
| - } |
279 |
| -} |
280 |
| - |
281 |
| -const char* TranslateRootKind(jvmtiHeapRootKind root) { |
282 |
| - switch (root) { |
283 |
| - case JVMTI_HEAP_ROOT_JNI_GLOBAL: |
284 |
| - return ("JVMTI_HEAP_ROOT_JNI_GLOBAL"); |
285 |
| - case JVMTI_HEAP_ROOT_JNI_LOCAL: |
286 |
| - return ("JVMTI_HEAP_ROOT_JNI_LOCAL"); |
287 |
| - case JVMTI_HEAP_ROOT_SYSTEM_CLASS: |
288 |
| - return ("JVMTI_HEAP_ROOT_SYSTEM_CLASS"); |
289 |
| - case JVMTI_HEAP_ROOT_MONITOR: |
290 |
| - return ("JVMTI_HEAP_ROOT_MONITOR"); |
291 |
| - case JVMTI_HEAP_ROOT_STACK_LOCAL: |
292 |
| - return ("JVMTI_HEAP_ROOT_STACK_LOCAL"); |
293 |
| - case JVMTI_HEAP_ROOT_THREAD: |
294 |
| - return ("JVMTI_HEAP_ROOT_THREAD"); |
295 |
| - case JVMTI_HEAP_ROOT_OTHER: |
296 |
| - return ("JVMTI_HEAP_ROOT_OTHER"); |
297 |
| - default: |
298 |
| - return ("<unknown root kind>"); |
299 |
| - } |
300 |
| -} |
301 |
| - |
302 |
| -const char* TranslateObjectRefKind(jvmtiObjectReferenceKind ref) { |
303 |
| - switch (ref) { |
304 |
| - case JVMTI_REFERENCE_CLASS: |
305 |
| - return ("JVMTI_REFERENCE_CLASS"); |
306 |
| - case JVMTI_REFERENCE_FIELD: |
307 |
| - return ("JVMTI_REFERENCE_FIELD"); |
308 |
| - case JVMTI_REFERENCE_ARRAY_ELEMENT: |
309 |
| - return ("JVMTI_REFERENCE_ARRAY_ELEMENT"); |
310 |
| - case JVMTI_REFERENCE_CLASS_LOADER: |
311 |
| - return ("JVMTI_REFERENCE_CLASS_LOADER"); |
312 |
| - case JVMTI_REFERENCE_SIGNERS: |
313 |
| - return ("JVMTI_REFERENCE_SIGNERS"); |
314 |
| - case JVMTI_REFERENCE_PROTECTION_DOMAIN: |
315 |
| - return ("JVMTI_REFERENCE_PROTECTION_DOMAIN"); |
316 |
| - case JVMTI_REFERENCE_INTERFACE: |
317 |
| - return ("JVMTI_REFERENCE_INTERFACE"); |
318 |
| - case JVMTI_REFERENCE_STATIC_FIELD: |
319 |
| - return ("JVMTI_REFERENCE_STATIC_FIELD"); |
320 |
| - case JVMTI_REFERENCE_CONSTANT_POOL: |
321 |
| - return ("JVMTI_REFERENCE_CONSTANT_POOL"); |
322 |
| - default: |
323 |
| - return ("<unknown reference kind>"); |
324 |
| - } |
325 |
| -} |
326 |
| - |
327 |
| -} |
0 commit comments