1 /* |
1 /* |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
1066 if (debug) |
1066 if (debug) |
1067 fprintf(stderr, "name_for_nmethod: FAIL \n\n"); |
1067 fprintf(stderr, "name_for_nmethod: FAIL \n\n"); |
1068 return err; |
1068 return err; |
1069 } |
1069 } |
1070 |
1070 |
1071 int is_bci(intptr_t bcx) { |
|
1072 switch (DATA_MODEL) { |
|
1073 case PR_MODEL_LP64: |
|
1074 return ((uintptr_t) bcx) <= ((uintptr_t) MAX_METHOD_CODE_SIZE) ; |
|
1075 case PR_MODEL_ILP32: |
|
1076 default: |
|
1077 return 0 <= bcx && bcx <= MAX_METHOD_CODE_SIZE; |
|
1078 } |
|
1079 } |
|
1080 |
|
1081 static int |
1071 static int |
1082 name_for_imethod(jvm_agent_t* J, |
1072 name_for_imethod(jvm_agent_t* J, |
1083 uint64_t bcx, |
1073 uint64_t bcp, |
1084 uint64_t method, |
1074 uint64_t method, |
1085 char *result, |
1075 char *result, |
1086 size_t size, |
1076 size_t size, |
1087 Jframe_t *jframe |
1077 Jframe_t *jframe |
1088 ) { |
1078 ) { |
1093 int32_t err; |
1083 int32_t err; |
1094 |
1084 |
1095 err = read_pointer(J, method + OFFSET_Method_constMethod, &constMethod); |
1085 err = read_pointer(J, method + OFFSET_Method_constMethod, &constMethod); |
1096 CHECK_FAIL(err); |
1086 CHECK_FAIL(err); |
1097 |
1087 |
1098 bci = is_bci(bcx) ? bcx : bcx - (constMethod + (uint64_t) SIZE_ConstMethod); |
1088 bci = bcp - (constMethod + (uint64_t) SIZE_ConstMethod); |
1099 |
1089 |
1100 if (debug) |
1090 if (debug) |
1101 fprintf(stderr, "\t name_for_imethod: BEGIN: method: %#llx\n", method); |
1091 fprintf(stderr, "\t name_for_imethod: BEGIN: method: %#llx\n", method); |
1102 |
1092 |
1103 err = name_for_methodPtr(J, method, result, size); |
1093 err = name_for_methodPtr(J, method, result, size); |
1167 * and regular interpreted frames. |
1157 * and regular interpreted frames. |
1168 */ |
1158 */ |
1169 if (err == PS_OK && strncmp(name, "Interpreter", 11) == 0) { |
1159 if (err == PS_OK && strncmp(name, "Interpreter", 11) == 0) { |
1170 *is_interpreted = 1; |
1160 *is_interpreted = 1; |
1171 if (is_method(J, J->methodPtr)) { |
1161 if (is_method(J, J->methodPtr)) { |
1172 return name_for_imethod(J, J->bcx, J->methodPtr, result, size, jframe); |
1162 return name_for_imethod(J, J->bcp, J->methodPtr, result, size, jframe); |
1173 } |
1163 } |
1174 } |
1164 } |
1175 |
1165 |
1176 if (err == PS_OK) { |
1166 if (err == PS_OK) { |
1177 strncpy(result, name, size); |
1167 strncpy(result, name, size); |
1355 /* The following workaround is for SPARC. CALL instruction occupates 8 bytes. |
1345 /* The following workaround is for SPARC. CALL instruction occupates 8 bytes. |
1356 * In the pcDesc structure return pc offset is recorded for CALL instructions. |
1346 * In the pcDesc structure return pc offset is recorded for CALL instructions. |
1357 * regs[R_PC] contains a CALL instruction pc offset. |
1347 * regs[R_PC] contains a CALL instruction pc offset. |
1358 */ |
1348 */ |
1359 pc += 8; |
1349 pc += 8; |
1360 bcx = (uintptr_t) regs[R_L1]; |
1350 bcp = (uintptr_t) regs[R_L1]; |
1361 methodPtr = (uintptr_t) regs[R_L2]; |
1351 methodPtr = (uintptr_t) regs[R_L2]; |
1362 sender_sp = regs[R_I5]; |
1352 sender_sp = regs[R_I5]; |
1363 if (debug > 2) { |
1353 if (debug > 2) { |
1364 fprintf(stderr, "\nregs[R_I1]=%lx, regs[R_I2]=%lx, regs[R_I5]=%lx, regs[R_L1]=%lx, regs[R_L2]=%lx\n", |
1354 fprintf(stderr, "\nregs[R_I1]=%lx, regs[R_I2]=%lx, regs[R_I5]=%lx, regs[R_L1]=%lx, regs[R_L2]=%lx\n", |
1365 regs[R_I1], regs[R_I2], regs[R_I5], regs[R_L1], regs[R_L2]); |
1355 regs[R_I1], regs[R_I2], regs[R_I5], regs[R_L1], regs[R_L2]); |
1383 methodPtr = 0; |
1373 methodPtr = 0; |
1384 } |
1374 } |
1385 if (read_pointer(J, fp + OFFSET_interpreter_frame_sender_sp, &sender_sp) != PS_OK) { |
1375 if (read_pointer(J, fp + OFFSET_interpreter_frame_sender_sp, &sender_sp) != PS_OK) { |
1386 sender_sp = 0; |
1376 sender_sp = 0; |
1387 } |
1377 } |
1388 if (read_pointer(J, fp + OFFSET_interpreter_frame_bcx_offset, &bcx) != PS_OK) { |
1378 if (read_pointer(J, fp + OFFSET_interpreter_frame_bcp_offset, &bcp) != PS_OK) { |
1389 bcx = 0; |
1379 bcp = 0; |
1390 } |
1380 } |
1391 #endif /* i386 */ |
1381 #endif /* i386 */ |
1392 |
1382 |
1393 J->methodPtr = methodPtr; |
1383 J->methodPtr = methodPtr; |
1394 J->bcx = bcx; |
1384 J->bcp = bcp; |
1395 |
1385 |
1396 /* On x86 with C2 JVM: native frame may have wrong regs[R_FP] |
1386 /* On x86 with C2 JVM: native frame may have wrong regs[R_FP] |
1397 * For example: JVM_SuspendThread frame poins to the top interpreted frame. |
1387 * For example: JVM_SuspendThread frame poins to the top interpreted frame. |
1398 * If we call is_method(J, methodPtr) before codecache_contains(J, pc) |
1388 * If we call is_method(J, methodPtr) before codecache_contains(J, pc) |
1399 * then we go over and omit both: nmethod and I2CAdapter frames. |
1389 * then we go over and omit both: nmethod and I2CAdapter frames. |
1400 * Note, that regs[R_PC] is always correct if frame defined correctly. |
1390 * Note, that regs[R_PC] is always correct if frame defined correctly. |
1401 * So it is better to call codecache_contains(J, pc) from the beginning. |
1391 * So it is better to call codecache_contains(J, pc) from the beginning. |
1402 */ |
1392 */ |
1403 #ifndef X86_COMPILER2 |
1393 #ifndef X86_COMPILER2 |
1404 if (is_method(J, J->methodPtr)) { |
1394 if (is_method(J, J->methodPtr)) { |
1405 result = name_for_imethod(J, bcx, J->methodPtr, name, size, jframe); |
1395 result = name_for_imethod(J, bcp, J->methodPtr, name, size, jframe); |
1406 /* If the methodPtr is a method then this is highly likely to be |
1396 /* If the methodPtr is a method then this is highly likely to be |
1407 an interpreter frame */ |
1397 an interpreter frame */ |
1408 if (result >= 0) { |
1398 if (result >= 0) { |
1409 is_interpreted = 1; |
1399 is_interpreted = 1; |
1410 } |
1400 } |
1414 if (codecache_contains(J, pc)) { |
1404 if (codecache_contains(J, pc)) { |
1415 result = name_for_codecache(J, fp, pc, name, size, jframe, &is_interpreted); |
1405 result = name_for_codecache(J, fp, pc, name, size, jframe, &is_interpreted); |
1416 } |
1406 } |
1417 #ifdef X86_COMPILER2 |
1407 #ifdef X86_COMPILER2 |
1418 else if (is_method(J, J->methodPtr)) { |
1408 else if (is_method(J, J->methodPtr)) { |
1419 result = name_for_imethod(J, bcx, J->methodPtr, name, size, jframe); |
1409 result = name_for_imethod(J, bcp, J->methodPtr, name, size, jframe); |
1420 /* If the methodPtr is a method then this is highly likely to be |
1410 /* If the methodPtr is a method then this is highly likely to be |
1421 an interpreter frame */ |
1411 an interpreter frame */ |
1422 if (result >= 0) { |
1412 if (result >= 0) { |
1423 is_interpreted = 1; |
1413 is_interpreted = 1; |
1424 } |
1414 } |