register debug support on illumos/solaris. (#11335)

This commit is contained in:
David CARLIER 2022-10-02 14:36:31 +01:00 committed by GitHub
parent 3469c6509c
commit ff80809053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View File

@ -139,6 +139,9 @@ ifeq ($(uname_S),SunOS)
INSTALL=cp -pf
FINAL_CFLAGS+= -D__EXTENSIONS__ -D_XPG6
FINAL_LIBS+= -ldl -lnsl -lsocket -lresolv -lpthread -lrt
ifeq ($(USE_BACKTRACE),yes)
FINAL_CFLAGS+= -DUSE_BACKTRACE
endif
else
ifeq ($(uname_S),Darwin)
# Darwin

View File

@ -72,7 +72,7 @@
/* Test for backtrace() */
#if defined(__APPLE__) || (defined(__linux__) && defined(__GLIBC__)) || \
defined(__FreeBSD__) || ((defined(__OpenBSD__) || defined(__NetBSD__)) && defined(USE_BACKTRACE))\
defined(__FreeBSD__) || ((defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun)) && defined(USE_BACKTRACE))\
|| defined(__DragonFly__) || (defined(__UCLIBC__) && defined(__UCLIBC_HAS_BACKTRACE__))
#define HAVE_BACKTRACE 1
#endif

View File

@ -1205,6 +1205,8 @@ static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) {
#endif
#elif defined(__DragonFly__)
GET_SET_RETURN(uc->uc_mcontext.mc_rip, eip);
#elif defined(__sun) && defined(__x86_64__)
GET_SET_RETURN(uc->uc_mcontext.gregs[REG_RIP], eip);
#else
NOT_SUPPORTED();
#endif
@ -1658,6 +1660,37 @@ void logRegisters(ucontext_t *uc) {
(unsigned long) uc->uc_mcontext.mc_cs
);
logStackContent((void**)uc->uc_mcontext.mc_rsp);
#elif defined(__sun)
#if defined(__x86_64__)
serverLog(LL_WARNING,
"\n"
"RAX:%016lx RBX:%016lx\nRCX:%016lx RDX:%016lx\n"
"RDI:%016lx RSI:%016lx\nRBP:%016lx RSP:%016lx\n"
"R8 :%016lx R9 :%016lx\nR10:%016lx R11:%016lx\n"
"R12:%016lx R13:%016lx\nR14:%016lx R15:%016lx\n"
"RIP:%016lx EFL:%016lx\nCSGSFS:%016lx",
(unsigned long) uc->uc_mcontext.gregs[REG_RAX],
(unsigned long) uc->uc_mcontext.gregs[REG_RBX],
(unsigned long) uc->uc_mcontext.gregs[REG_RCX],
(unsigned long) uc->uc_mcontext.gregs[REG_RDX],
(unsigned long) uc->uc_mcontext.gregs[REG_RDI],
(unsigned long) uc->uc_mcontext.gregs[REG_RSI],
(unsigned long) uc->uc_mcontext.gregs[REG_RBP],
(unsigned long) uc->uc_mcontext.gregs[REG_RSP],
(unsigned long) uc->uc_mcontext.gregs[REG_R8],
(unsigned long) uc->uc_mcontext.gregs[REG_R9],
(unsigned long) uc->uc_mcontext.gregs[REG_R10],
(unsigned long) uc->uc_mcontext.gregs[REG_R11],
(unsigned long) uc->uc_mcontext.gregs[REG_R12],
(unsigned long) uc->uc_mcontext.gregs[REG_R13],
(unsigned long) uc->uc_mcontext.gregs[REG_R14],
(unsigned long) uc->uc_mcontext.gregs[REG_R15],
(unsigned long) uc->uc_mcontext.gregs[REG_RIP],
(unsigned long) uc->uc_mcontext.gregs[REG_RFL],
(unsigned long) uc->uc_mcontext.gregs[REG_CS]
);
logStackContent((void**)uc->uc_mcontext.gregs[REG_RSP]);
#endif
#else
NOT_SUPPORTED();
#endif