Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
5e86daf9
Commit
5e86daf9
authored
Nov 24, 2018
by
David Carlier
Committed by
antirez
Dec 11, 2018
Browse files
Backtrace/register dump on BSD.
FreeBSD/DragonFlyBSD does have backtrace only it does not belong to libc.
parent
7c8cf5ac
Changes
3
Show whitespace changes
Inline
Side-by-side
src/Makefile
View file @
5e86daf9
...
@@ -105,11 +105,11 @@ ifeq ($(uname_S),OpenBSD)
...
@@ -105,11 +105,11 @@ ifeq ($(uname_S),OpenBSD)
else
else
ifeq
($(uname_S),FreeBSD)
ifeq
($(uname_S),FreeBSD)
# FreeBSD
# FreeBSD
FINAL_LIBS
+=
-lpthread
FINAL_LIBS
+=
-lpthread
-lexecinfo
else
else
ifeq
($(uname_S),DragonFly)
ifeq
($(uname_S),DragonFly)
# FreeBSD
# FreeBSD
FINAL_LIBS
+=
-lpthread
FINAL_LIBS
+=
-lpthread
-lexecinfo
else
else
# All the other OSes (notably Linux)
# All the other OSes (notably Linux)
FINAL_LDFLAGS
+=
-rdynamic
FINAL_LDFLAGS
+=
-rdynamic
...
...
src/config.h
View file @
5e86daf9
...
@@ -62,7 +62,8 @@
...
@@ -62,7 +62,8 @@
#endif
#endif
/* Test for backtrace() */
/* Test for backtrace() */
#if defined(__APPLE__) || (defined(__linux__) && defined(__GLIBC__))
#if defined(__APPLE__) || (defined(__linux__) && defined(__GLIBC__)) || \
defined(__FreeBSD__) || defined(__DragonFly__)
#define HAVE_BACKTRACE 1
#define HAVE_BACKTRACE 1
#endif
#endif
...
...
src/debug.c
View file @
5e86daf9
...
@@ -729,6 +729,15 @@ static void *getMcontextEip(ucontext_t *uc) {
...
@@ -729,6 +729,15 @@ static void *getMcontextEip(ucontext_t *uc) {
#elif defined(__aarch64__)
/* Linux AArch64 */
#elif defined(__aarch64__)
/* Linux AArch64 */
return
(
void
*
)
uc
->
uc_mcontext
.
pc
;
return
(
void
*
)
uc
->
uc_mcontext
.
pc
;
#endif
#endif
#elif defined(__FreeBSD__)
/* FreeBSD */
#if defined(__i386__)
return
(
void
*
)
uc
->
uc_mcontext
.
mc_eip
;
#elif defined(__x86_64__)
return
(
void
*
)
uc
->
uc_mcontext
.
mc_rip
;
#endif
#elif defined(__DragonFly__)
return
(
void
*
)
uc
->
uc_mcontext
.
mc_rip
;
#else
#else
return
NULL
;
return
NULL
;
#endif
#endif
...
@@ -870,6 +879,90 @@ void logRegisters(ucontext_t *uc) {
...
@@ -870,6 +879,90 @@ void logRegisters(ucontext_t *uc) {
);
);
logStackContent
((
void
**
)
uc
->
uc_mcontext
.
gregs
[
15
]);
logStackContent
((
void
**
)
uc
->
uc_mcontext
.
gregs
[
15
]);
#endif
#endif
#elif defined(__FreeBSD__)
#if defined(__x86_64__)
serverLog
(
LL_WARNING
,
"
\n
"
"RAX:%016lx RBX:%016lx
\n
RCX:%016lx RDX:%016lx
\n
"
"RDI:%016lx RSI:%016lx
\n
RBP:%016lx RSP:%016lx
\n
"
"R8 :%016lx R9 :%016lx
\n
R10:%016lx R11:%016lx
\n
"
"R12:%016lx R13:%016lx
\n
R14:%016lx R15:%016lx
\n
"
"RIP:%016lx EFL:%016lx
\n
CSGSFS:%016lx"
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rax
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rbx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rcx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rdx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rdi
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rsi
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rbp
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rsp
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r8
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r9
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r10
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r11
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r12
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r13
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r14
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r15
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rip
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rflags
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_cs
);
logStackContent
((
void
**
)
uc
->
uc_mcontext
.
mc_rsp
);
#elif defined(__i386__)
serverLog
(
LL_WARNING
,
"
\n
"
"EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx
\n
"
"EDI:%08lx ESI:%08lx EBP:%08lx ESP:%08lx
\n
"
"SS :%08lx EFL:%08lx EIP:%08lx CS:%08lx
\n
"
"DS :%08lx ES :%08lx FS :%08lx GS:%08lx"
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_eax
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_ebx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_ebx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_edx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_edi
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_esi
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_ebp
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_esp
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_ss
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_eflags
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_eip
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_cs
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_es
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_fs
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_gs
);
logStackContent
((
void
**
)
uc
->
uc_mcontext
.
mc_esp
);
#endif
#elif defined(__DragonFly__)
serverLog
(
LL_WARNING
,
"
\n
"
"RAX:%016lx RBX:%016lx
\n
RCX:%016lx RDX:%016lx
\n
"
"RDI:%016lx RSI:%016lx
\n
RBP:%016lx RSP:%016lx
\n
"
"R8 :%016lx R9 :%016lx
\n
R10:%016lx R11:%016lx
\n
"
"R12:%016lx R13:%016lx
\n
R14:%016lx R15:%016lx
\n
"
"RIP:%016lx EFL:%016lx
\n
CSGSFS:%016lx"
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rax
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rbx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rcx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rdx
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rdi
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rsi
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rbp
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rsp
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r8
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r9
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r10
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r11
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r12
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r13
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r14
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_r15
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rip
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_rflags
,
(
unsigned
long
)
uc
->
uc_mcontext
.
mc_cs
);
logStackContent
((
void
**
)
uc
->
uc_mcontext
.
mc_rsp
);
#else
#else
serverLog
(
LL_WARNING
,
serverLog
(
LL_WARNING
,
" Dumping of registers not supported for this OS/arch"
);
" Dumping of registers not supported for this OS/arch"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment