1 /* 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 /* This file is auto-generated */ 26 #include "JvmOffsetsIndex.h" 27 28 #define DEBUG 29 30 #ifdef DEBUG 31 #define MARK_LINE this->line = __LINE__ 32 #else 33 #define MARK_LINE 34 #endif 35 36 #ifdef _LP64 37 #define STACK_BIAS 0x7ff 38 #define pointer uint64_t 39 #else 40 #define STACK_BIAS 0 41 #define pointer uint32_t 42 #endif 43 44 extern pointer __JvmOffsets; 45 46 extern pointer __1cJCodeCacheF_heap_; 47 extern pointer __1cIUniverseO_collectedHeap_; 48 49 extern pointer __1cHnmethodG__vtbl_; 50 extern pointer __1cGMethodG__vtbl_; 51 extern pointer __1cKBufferBlobG__vtbl_; 52 53 #define copyin_ptr(ADDR) *(pointer*) copyin((pointer) (ADDR), sizeof(pointer)) 54 #define copyin_uchar(ADDR) *(uchar_t*) copyin((pointer) (ADDR), sizeof(uchar_t)) 55 #define copyin_uint16(ADDR) *(uint16_t*) copyin((pointer) (ADDR), sizeof(uint16_t)) 56 #define copyin_uint32(ADDR) *(uint32_t*) copyin((pointer) (ADDR), sizeof(uint32_t)) 57 #define copyin_int32(ADDR) *(int32_t*) copyin((pointer) (ADDR), sizeof(int32_t)) 58 #define copyin_uint8(ADDR) *(uint8_t*) copyin((pointer) (ADDR), sizeof(uint8_t)) 59 60 #define SAME(x) x 61 #define copyin_offset(JVM_CONST) JVM_CONST = \ 62 copyin_int32(JvmOffsetsPtr + SAME(IDX_)JVM_CONST * sizeof(int32_t)) 63 64 int init_done; 65 66 dtrace:helper:ustack: 67 { 68 MARK_LINE; 69 this->done = 0; 70 /* 71 * TBD: 72 * Here we initialize init_done, otherwise jhelper does not work. 73 * Therefore, copyin_offset() statements work multiple times now. 74 * There is a hope we could avoid it in the future, and so, 75 * this initialization can be removed. 76 */ 77 init_done = 0; 78 this->error = (char *) NULL; 79 this->result = (char *) NULL; 80 this->isMethod = 0; 81 this->codecache = 0; 82 this->klass = (pointer) NULL; 83 this->vtbl = (pointer) NULL; 84 this->suffix = '\0'; 85 } 86 87 dtrace:helper:ustack: 88 { 89 MARK_LINE; 90 /* Initialization of JvmOffsets constants */ 91 JvmOffsetsPtr = (pointer) &``__JvmOffsets; 92 } 93 94 dtrace:helper:ustack: 95 /!init_done && !this->done/ 96 { 97 MARK_LINE; 98 init_done = 1; 99 100 copyin_offset(COMPILER); 101 copyin_offset(OFFSET_CollectedHeap_reserved); 102 copyin_offset(OFFSET_MemRegion_start); 103 copyin_offset(OFFSET_MemRegion_word_size); 104 copyin_offset(SIZE_HeapWord); 105 106 copyin_offset(OFFSET_interpreter_frame_method); 107 copyin_offset(OFFSET_Klass_name); 108 copyin_offset(OFFSET_ConstantPool_pool_holder); 109 110 copyin_offset(OFFSET_HeapBlockHeader_used); 111 copyin_offset(OFFSET_oopDesc_metadata); 112 113 copyin_offset(OFFSET_Symbol_length); 114 copyin_offset(OFFSET_Symbol_body); 115 116 copyin_offset(OFFSET_Method_constMethod); 117 copyin_offset(OFFSET_ConstMethod_constants); 118 copyin_offset(OFFSET_ConstMethod_name_index); 119 copyin_offset(OFFSET_ConstMethod_signature_index); 120 121 copyin_offset(OFFSET_CodeHeap_memory); 122 copyin_offset(OFFSET_CodeHeap_segmap); 123 copyin_offset(OFFSET_CodeHeap_log2_segment_size); 124 125 copyin_offset(OFFSET_VirtualSpace_low); 126 copyin_offset(OFFSET_VirtualSpace_high); 127 128 copyin_offset(OFFSET_CodeBlob_name); 129 130 copyin_offset(OFFSET_nmethod_method); 131 copyin_offset(SIZE_HeapBlockHeader); 132 copyin_offset(SIZE_oopDesc); 133 copyin_offset(SIZE_ConstantPool); 134 135 copyin_offset(OFFSET_NarrowPtrStruct_base); 136 copyin_offset(OFFSET_NarrowPtrStruct_shift); 137 138 /* 139 * The PC to translate is in arg0. 140 */ 141 this->pc = arg0; 142 143 /* 144 * The methodPtr is in %l2 on SPARC. This can be found at 145 * offset 8 from the frame pointer on 32-bit processes. 146 */ 147 #if defined(__sparc) 148 this->methodPtr = copyin_ptr(arg1 + 2 * sizeof(pointer) + STACK_BIAS); 149 #elif defined(__i386) || defined(__amd64) 150 this->methodPtr = copyin_ptr(arg1 + OFFSET_interpreter_frame_method); 151 #else 152 #error "Don't know architecture" 153 #endif 154 155 this->CodeCache_heap_address = copyin_ptr(&``__1cJCodeCacheF_heap_); 156 157 this->CodeCache_low = copyin_ptr(this->CodeCache_heap_address + 158 OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low); 159 160 this->CodeCache_high = copyin_ptr(this->CodeCache_heap_address + 161 OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high); 162 163 this->CodeCache_segmap_low = copyin_ptr(this->CodeCache_heap_address + 164 OFFSET_CodeHeap_segmap + OFFSET_VirtualSpace_low); 165 166 this->CodeCache_segmap_high = copyin_ptr(this->CodeCache_heap_address + 167 OFFSET_CodeHeap_segmap + OFFSET_VirtualSpace_high); 168 169 this->CodeHeap_log2_segment_size = copyin_uint32( 170 this->CodeCache_heap_address + OFFSET_CodeHeap_log2_segment_size); 171 172 this->Method_vtbl = (pointer) &``__1cGMethodG__vtbl_; 173 174 /* 175 * Get Java heap bounds 176 */ 177 this->Universe_collectedHeap = copyin_ptr(&``__1cIUniverseO_collectedHeap_); 178 this->heap_start = copyin_ptr(this->Universe_collectedHeap + 179 OFFSET_CollectedHeap_reserved + 180 OFFSET_MemRegion_start); 181 this->heap_size = SIZE_HeapWord * 182 copyin_ptr(this->Universe_collectedHeap + 183 OFFSET_CollectedHeap_reserved + 184 OFFSET_MemRegion_word_size 185 ); 186 this->heap_end = this->heap_start + this->heap_size; 187 } 188 189 dtrace:helper:ustack: 190 /!this->done && 191 this->CodeCache_low <= this->pc && this->pc < this->CodeCache_high/ 192 { 193 MARK_LINE; 194 this->codecache = 1; 195 196 /* 197 * Find start. 198 */ 199 this->segment = (this->pc - this->CodeCache_low) >> 200 this->CodeHeap_log2_segment_size; 201 this->block = this->CodeCache_segmap_low; 202 this->tag = copyin_uchar(this->block + this->segment); 203 "second"; 204 } 205 206 dtrace:helper:ustack: 207 /!this->done && this->codecache && this->tag > 0/ 208 { 209 MARK_LINE; 210 this->tag = copyin_uchar(this->block + this->segment); 211 this->segment = this->segment - this->tag; 212 } 213 214 dtrace:helper:ustack: 215 /!this->done && this->codecache && this->tag > 0/ 216 { 217 MARK_LINE; 218 this->tag = copyin_uchar(this->block + this->segment); 219 this->segment = this->segment - this->tag; 220 } 221 222 dtrace:helper:ustack: 223 /!this->done && this->codecache && this->tag > 0/ 224 { 225 MARK_LINE; 226 this->tag = copyin_uchar(this->block + this->segment); 227 this->segment = this->segment - this->tag; 228 } 229 230 dtrace:helper:ustack: 231 /!this->done && this->codecache && this->tag > 0/ 232 { 233 MARK_LINE; 234 this->tag = copyin_uchar(this->block + this->segment); 235 this->segment = this->segment - this->tag; 236 } 237 238 dtrace:helper:ustack: 239 /!this->done && this->codecache && this->tag > 0/ 240 { 241 MARK_LINE; 242 this->tag = copyin_uchar(this->block + this->segment); 243 this->segment = this->segment - this->tag; 244 } 245 246 dtrace:helper:ustack: 247 /!this->done && this->codecache && this->tag > 0/ 248 { 249 MARK_LINE; 250 this->error = "<couldn't find start>"; 251 this->done = 1; 252 } 253 254 dtrace:helper:ustack: 255 /!this->done && this->codecache/ 256 { 257 MARK_LINE; 258 this->block = this->CodeCache_low + 259 (this->segment << this->CodeHeap_log2_segment_size); 260 this->used = copyin_uint32(this->block + OFFSET_HeapBlockHeader_used); 261 } 262 263 dtrace:helper:ustack: 264 /!this->done && this->codecache && !this->used/ 265 { 266 MARK_LINE; 267 this->error = "<block not in use>"; 268 this->done = 1; 269 } 270 271 dtrace:helper:ustack: 272 /!this->done && this->codecache/ 273 { 274 MARK_LINE; 275 this->start = this->block + SIZE_HeapBlockHeader; 276 this->vtbl = copyin_ptr(this->start); 277 278 this->nmethod_vtbl = (pointer) &``__1cHnmethodG__vtbl_; 279 this->BufferBlob_vtbl = (pointer) &``__1cKBufferBlobG__vtbl_; 280 } 281 282 dtrace:helper:ustack: 283 /!this->done && this->vtbl == this->nmethod_vtbl/ 284 { 285 MARK_LINE; 286 this->methodPtr = copyin_ptr(this->start + OFFSET_nmethod_method); 287 this->suffix = '*'; 288 this->isMethod = 1; 289 } 290 291 dtrace:helper:ustack: 292 /!this->done && this->vtbl == this->BufferBlob_vtbl/ 293 { 294 MARK_LINE; 295 this->name = copyin_ptr(this->start + OFFSET_CodeBlob_name); 296 } 297 298 299 dtrace:helper:ustack: 300 /!this->done && this->vtbl == this->BufferBlob_vtbl && this->methodPtr != 0/ 301 { 302 MARK_LINE; 303 this->klass = copyin_ptr(this->methodPtr); 304 this->isMethod = this->klass == this->Method_vtbl; 305 this->done = !this->isMethod; 306 } 307 308 dtrace:helper:ustack: 309 /!this->done && !this->isMethod/ 310 { 311 MARK_LINE; 312 this->name = copyin_ptr(this->start + OFFSET_CodeBlob_name); 313 this->result = this->name != 0 ? copyinstr(this->name) : "<CodeBlob>"; 314 this->done = 1; 315 } 316 317 dtrace:helper:ustack: 318 /!this->done && this->isMethod/ 319 { 320 MARK_LINE; 321 this->constMethod = copyin_ptr(this->methodPtr + 322 OFFSET_Method_constMethod); 323 324 this->nameIndex = copyin_uint16(this->constMethod + 325 OFFSET_ConstMethod_name_index); 326 327 this->signatureIndex = copyin_uint16(this->constMethod + 328 OFFSET_ConstMethod_signature_index); 329 330 this->constantPool = copyin_ptr(this->constMethod + 331 OFFSET_ConstMethod_constants); 332 333 this->nameSymbol = copyin_ptr(this->constantPool + 334 this->nameIndex * sizeof (pointer) + SIZE_ConstantPool); 335 /* The symbol is a CPSlot and has lower bit set to indicate metadata */ 336 this->nameSymbol &= (~1); /* remove metadata lsb */ 337 338 this->nameSymbolLength = copyin_uint16(this->nameSymbol + 339 OFFSET_Symbol_length); 340 341 this->signatureSymbol = copyin_ptr(this->constantPool + 342 this->signatureIndex * sizeof (pointer) + SIZE_ConstantPool); 343 this->signatureSymbol &= (~1); /* remove metadata lsb */ 344 345 this->signatureSymbolLength = copyin_uint16(this->signatureSymbol + 346 OFFSET_Symbol_length); 347 348 this->klassPtr = copyin_ptr(this->constantPool + 349 OFFSET_ConstantPool_pool_holder); 350 351 this->klassSymbol = copyin_ptr(this->klassPtr + 352 OFFSET_Klass_name); 353 354 this->klassSymbolLength = copyin_uint16(this->klassSymbol + 355 OFFSET_Symbol_length); 356 357 /* 358 * Enough for three strings, plus the '.', plus the trailing '\0'. 359 */ 360 this->result = (char *) alloca(this->klassSymbolLength + 361 this->nameSymbolLength + 362 this->signatureSymbolLength + 2 + 1); 363 364 copyinto(this->klassSymbol + OFFSET_Symbol_body, 365 this->klassSymbolLength, this->result); 366 367 /* 368 * Add the '.' between the class and the name. 369 */ 370 this->result[this->klassSymbolLength] = '.'; 371 372 copyinto(this->nameSymbol + OFFSET_Symbol_body, 373 this->nameSymbolLength, 374 this->result + this->klassSymbolLength + 1); 375 376 copyinto(this->signatureSymbol + OFFSET_Symbol_body, 377 this->signatureSymbolLength, 378 this->result + this->klassSymbolLength + 379 this->nameSymbolLength + 1); 380 381 /* 382 * Now we need to add a trailing '\0' and possibly a tag character. 383 */ 384 this->result[this->klassSymbolLength + 1 + 385 this->nameSymbolLength + 386 this->signatureSymbolLength] = this->suffix; 387 this->result[this->klassSymbolLength + 2 + 388 this->nameSymbolLength + 389 this->signatureSymbolLength] = '\0'; 390 391 this->done = 1; 392 } 393 394 dtrace:helper:ustack: 395 /this->done && this->error == (char *) NULL/ 396 { 397 this->result; 398 } 399 400 dtrace:helper:ustack: 401 /this->done && this->error != (char *) NULL/ 402 { 403 this->error; 404 } 405 406 dtrace:helper:ustack: 407 /!this->done && this->codecache/ 408 { 409 this->done = 1; 410 "error"; 411 } 412 413 414 dtrace:helper:ustack: 415 /!this->done/ 416 { 417 NULL; 418 }