1337 |
1337 |
1338 |
1338 |
1339 #define MACH_MAXSYMLEN 256 |
1339 #define MACH_MAXSYMLEN 256 |
1340 |
1340 |
1341 bool os::dll_address_to_function_name(address addr, char *buf, |
1341 bool os::dll_address_to_function_name(address addr, char *buf, |
1342 int buflen, int *offset) { |
1342 int buflen, int *offset, |
|
1343 bool demangle) { |
1343 // buf is not optional, but offset is optional |
1344 // buf is not optional, but offset is optional |
1344 assert(buf != NULL, "sanity check"); |
1345 assert(buf != NULL, "sanity check"); |
1345 |
1346 |
1346 Dl_info dlinfo; |
1347 Dl_info dlinfo; |
1347 char localbuf[MACH_MAXSYMLEN]; |
1348 char localbuf[MACH_MAXSYMLEN]; |
1348 |
1349 |
1349 if (dladdr((void*)addr, &dlinfo) != 0) { |
1350 if (dladdr((void*)addr, &dlinfo) != 0) { |
1350 // see if we have a matching symbol |
1351 // see if we have a matching symbol |
1351 if (dlinfo.dli_saddr != NULL && dlinfo.dli_sname != NULL) { |
1352 if (dlinfo.dli_saddr != NULL && dlinfo.dli_sname != NULL) { |
1352 if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) { |
1353 if (!(demangle && Decoder::demangle(dlinfo.dli_sname, buf, buflen))) { |
1353 jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); |
1354 jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); |
1354 } |
1355 } |
1355 if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; |
1356 if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; |
1356 return true; |
1357 return true; |
1357 } |
1358 } |
1358 // no matching symbol so try for just file info |
1359 // no matching symbol so try for just file info |
1359 if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) { |
1360 if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) { |
1360 if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), |
1361 if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), |
1361 buf, buflen, offset, dlinfo.dli_fname)) { |
1362 buf, buflen, offset, dlinfo.dli_fname, demangle)) { |
1362 return true; |
1363 return true; |
1363 } |
1364 } |
1364 } |
1365 } |
1365 |
1366 |
1366 // Handle non-dynamic manually: |
1367 // Handle non-dynamic manually: |
1367 if (dlinfo.dli_fbase != NULL && |
1368 if (dlinfo.dli_fbase != NULL && |
1368 Decoder::decode(addr, localbuf, MACH_MAXSYMLEN, offset, dlinfo.dli_fbase)) { |
1369 Decoder::decode(addr, localbuf, MACH_MAXSYMLEN, offset, |
1369 if (!Decoder::demangle(localbuf, buf, buflen)) { |
1370 dlinfo.dli_fbase)) { |
|
1371 if (!(demangle && Decoder::demangle(localbuf, buf, buflen))) { |
1370 jio_snprintf(buf, buflen, "%s", localbuf); |
1372 jio_snprintf(buf, buflen, "%s", localbuf); |
1371 } |
1373 } |
1372 return true; |
1374 return true; |
1373 } |
1375 } |
1374 } |
1376 } |