Mercurial > hg > truffle
comparison src/os/solaris/vm/os_solaris.cpp @ 2022:2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
Summary: Implemented in-process C native stack frame decoding when symbols are available.
Reviewed-by: coleenp, never
author | zgu |
---|---|
date | Sat, 11 Dec 2010 13:20:56 -0500 |
parents | f95d63e2154a |
children | 54f5dd2aa1d9 |
comparison
equal
deleted
inserted
replaced
1972:f95d63e2154a | 2022:2d4762ec74af |
---|---|
56 #include "runtime/threadCritical.hpp" | 56 #include "runtime/threadCritical.hpp" |
57 #include "runtime/timer.hpp" | 57 #include "runtime/timer.hpp" |
58 #include "services/attachListener.hpp" | 58 #include "services/attachListener.hpp" |
59 #include "services/runtimeService.hpp" | 59 #include "services/runtimeService.hpp" |
60 #include "thread_solaris.inline.hpp" | 60 #include "thread_solaris.inline.hpp" |
61 #include "utilities/decoder.hpp" | |
61 #include "utilities/defaultStream.hpp" | 62 #include "utilities/defaultStream.hpp" |
62 #include "utilities/events.hpp" | 63 #include "utilities/events.hpp" |
63 #include "utilities/growableArray.hpp" | 64 #include "utilities/growableArray.hpp" |
64 #include "utilities/vmError.hpp" | 65 #include "utilities/vmError.hpp" |
65 #ifdef TARGET_ARCH_x86 | 66 #ifdef TARGET_ARCH_x86 |
1965 #define RTLD_DL_SYMENT 1 | 1966 #define RTLD_DL_SYMENT 1 |
1966 #endif | 1967 #endif |
1967 Sym * info; | 1968 Sym * info; |
1968 if (dladdr1_func((void *)addr, &dlinfo, (void **)&info, | 1969 if (dladdr1_func((void *)addr, &dlinfo, (void **)&info, |
1969 RTLD_DL_SYMENT)) { | 1970 RTLD_DL_SYMENT)) { |
1970 if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); | 1971 if ((char *)dlinfo.dli_saddr + info->st_size > (char *)addr) { |
1971 if (offset) *offset = addr - (address)dlinfo.dli_saddr; | 1972 if (buf != NULL) { |
1972 | 1973 if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) |
1973 // check if the returned symbol really covers addr | 1974 jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname); |
1974 return ((char *)dlinfo.dli_saddr + info->st_size > (char *)addr); | 1975 } |
1975 } else { | 1976 if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; |
1976 if (buf) buf[0] = '\0'; | 1977 return true; |
1977 if (offset) *offset = -1; | 1978 } |
1978 return false; | |
1979 } | 1979 } |
1980 if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { | |
1981 if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), | |
1982 dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) { | |
1983 return true; | |
1984 } | |
1985 } | |
1986 if (buf != NULL) buf[0] = '\0'; | |
1987 if (offset != NULL) *offset = -1; | |
1988 return false; | |
1980 } else { | 1989 } else { |
1981 // no, only dladdr is available | 1990 // no, only dladdr is available |
1982 if(dladdr((void *)addr, &dlinfo)) { | 1991 if (dladdr((void *)addr, &dlinfo)) { |
1983 if (buf) jio_snprintf(buf, buflen, dlinfo.dli_sname); | 1992 if (buf != NULL) { |
1984 if (offset) *offset = addr - (address)dlinfo.dli_saddr; | 1993 if (!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) |
1994 jio_snprintf(buf, buflen, dlinfo.dli_sname); | |
1995 } | |
1996 if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr; | |
1997 return true; | |
1998 } else if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) { | |
1999 if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase), | |
2000 dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) { | |
1985 return true; | 2001 return true; |
1986 } else { | 2002 } |
1987 if (buf) buf[0] = '\0'; | |
1988 if (offset) *offset = -1; | |
1989 return false; | |
1990 } | 2003 } |
2004 if (buf != NULL) buf[0] = '\0'; | |
2005 if (offset != NULL) *offset = -1; | |
2006 return false; | |
1991 } | 2007 } |
1992 } | 2008 } |
1993 | 2009 |
1994 bool os::dll_address_to_library_name(address addr, char* buf, | 2010 bool os::dll_address_to_library_name(address addr, char* buf, |
1995 int buflen, int* offset) { | 2011 int buflen, int* offset) { |