src/os/bsd/vm/os_bsd.cpp

changeset 3961
3b01d0321dfa
parent 3903
65906dc96aa1
child 4136
bf2edd3c9b0f
equal deleted inserted replaced
3940:950ed41429e5 3961:3b01d0321dfa
1944 } 1944 }
1945 1945
1946 return false; 1946 return false;
1947 } 1947 }
1948 1948
1949
1950 #define MACH_MAXSYMLEN 256
1951
1949 bool os::dll_address_to_function_name(address addr, char *buf, 1952 bool os::dll_address_to_function_name(address addr, char *buf,
1950 int buflen, int *offset) { 1953 int buflen, int *offset) {
1951 Dl_info dlinfo; 1954 Dl_info dlinfo;
1952 1955 char localbuf[MACH_MAXSYMLEN];
1956
1957 // dladdr will find names of dynamic functions only, but does
1958 // it set dli_fbase with mach_header address when it "fails" ?
1953 if (dladdr((void*)addr, &dlinfo) && dlinfo.dli_sname != NULL) { 1959 if (dladdr((void*)addr, &dlinfo) && dlinfo.dli_sname != NULL) {
1954 if (buf != NULL) { 1960 if (buf != NULL) {
1955 if(!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) { 1961 if(!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) {
1956 jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); 1962 jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
1957 } 1963 }
1963 buf, buflen, offset, dlinfo.dli_fname)) { 1969 buf, buflen, offset, dlinfo.dli_fname)) {
1964 return true; 1970 return true;
1965 } 1971 }
1966 } 1972 }
1967 1973
1974 // Handle non-dymanic manually:
1975 if (dlinfo.dli_fbase != NULL &&
1976 Decoder::decode(addr, localbuf, MACH_MAXSYMLEN, offset, dlinfo.dli_fbase)) {
1977 if(!Decoder::demangle(localbuf, buf, buflen)) {
1978 jio_snprintf(buf, buflen, "%s", localbuf);
1979 }
1980 return true;
1981 }
1968 if (buf != NULL) buf[0] = '\0'; 1982 if (buf != NULL) buf[0] = '\0';
1969 if (offset != NULL) *offset = -1; 1983 if (offset != NULL) *offset = -1;
1970 return false; 1984 return false;
1971 } 1985 }
1972 1986

mercurial