hotspot/src/os/solaris/vm/os_solaris.cpp
changeset 31352 a6ab7217b5cc
parent 31026 b87ccf34b54c
child 31357 0cef600ba9b7
equal deleted inserted replaced
31351:aae7db185576 31352:a6ab7217b5cc
  1625 
  1625 
  1626 typedef int (*dladdr1_func_type)(void *, Dl_info *, void **, int);
  1626 typedef int (*dladdr1_func_type)(void *, Dl_info *, void **, int);
  1627 static dladdr1_func_type dladdr1_func = NULL;
  1627 static dladdr1_func_type dladdr1_func = NULL;
  1628 
  1628 
  1629 bool os::dll_address_to_function_name(address addr, char *buf,
  1629 bool os::dll_address_to_function_name(address addr, char *buf,
  1630                                       int buflen, int * offset) {
  1630                                       int buflen, int * offset,
       
  1631                                       bool demangle) {
  1631   // buf is not optional, but offset is optional
  1632   // buf is not optional, but offset is optional
  1632   assert(buf != NULL, "sanity check");
  1633   assert(buf != NULL, "sanity check");
  1633 
  1634 
  1634   Dl_info dlinfo;
  1635   Dl_info dlinfo;
  1635 
  1636 
  1653                      RTLD_DL_SYMENT) != 0) {
  1654                      RTLD_DL_SYMENT) != 0) {
  1654       // see if we have a matching symbol that covers our address
  1655       // see if we have a matching symbol that covers our address
  1655       if (dlinfo.dli_saddr != NULL &&
  1656       if (dlinfo.dli_saddr != NULL &&
  1656           (char *)dlinfo.dli_saddr + info->st_size > (char *)addr) {
  1657           (char *)dlinfo.dli_saddr + info->st_size > (char *)addr) {
  1657         if (dlinfo.dli_sname != NULL) {
  1658         if (dlinfo.dli_sname != NULL) {
  1658           if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) {
  1659           if (!(demangle && Decoder::demangle(dlinfo.dli_sname, buf, buflen))) {
  1659             jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
  1660             jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
  1660           }
  1661           }
  1661           if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr;
  1662           if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr;
  1662           return true;
  1663           return true;
  1663         }
  1664         }
  1664       }
  1665       }
  1665       // no matching symbol so try for just file info
  1666       // no matching symbol so try for just file info
  1666       if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) {
  1667       if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) {
  1667         if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
  1668         if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
  1668                             buf, buflen, offset, dlinfo.dli_fname)) {
  1669                             buf, buflen, offset, dlinfo.dli_fname, demangle)) {
  1669           return true;
  1670           return true;
  1670         }
  1671         }
  1671       }
  1672       }
  1672     }
  1673     }
  1673     buf[0] = '\0';
  1674     buf[0] = '\0';
  1677 
  1678 
  1678   // no, only dladdr is available
  1679   // no, only dladdr is available
  1679   if (dladdr((void *)addr, &dlinfo) != 0) {
  1680   if (dladdr((void *)addr, &dlinfo) != 0) {
  1680     // see if we have a matching symbol
  1681     // see if we have a matching symbol
  1681     if (dlinfo.dli_saddr != NULL && dlinfo.dli_sname != NULL) {
  1682     if (dlinfo.dli_saddr != NULL && dlinfo.dli_sname != NULL) {
  1682       if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) {
  1683       if (!(demangle && Decoder::demangle(dlinfo.dli_sname, buf, buflen))) {
  1683         jio_snprintf(buf, buflen, dlinfo.dli_sname);
  1684         jio_snprintf(buf, buflen, dlinfo.dli_sname);
  1684       }
  1685       }
  1685       if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr;
  1686       if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr;
  1686       return true;
  1687       return true;
  1687     }
  1688     }
  1688     // no matching symbol so try for just file info
  1689     // no matching symbol so try for just file info
  1689     if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) {
  1690     if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) {
  1690       if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
  1691       if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
  1691                           buf, buflen, offset, dlinfo.dli_fname)) {
  1692                           buf, buflen, offset, dlinfo.dli_fname, demangle)) {
  1692         return true;
  1693         return true;
  1693       }
  1694       }
  1694     }
  1695     }
  1695   }
  1696   }
  1696   buf[0] = '\0';
  1697   buf[0] = '\0';