mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 17:10:48 +01:00
Revert "SERVER-5852 use libunwind routines for backtrace on freebsd"
This reverts commit e6f9efc3c3
.
This may be resubmitted as a generic replacement for backtrace()
on all platforms, rather than just FreeBSD.
This commit is contained in:
parent
229931979f
commit
a7be5e92b2
11
SConstruct
11
SConstruct
@ -789,10 +789,7 @@ def doConfigure(myenv):
|
||||
if solaris or conf.CheckDeclaration('clock_gettime', includes='#include <time.h>'):
|
||||
conf.CheckLib('rt')
|
||||
|
||||
if freebsd and conf.CheckCXXHeader( "unwind.h" ):
|
||||
myenv.Append( CPPDEFINES=[ "MONGO_HAVE_UNWIND_BACKTRACE" ] )
|
||||
|
||||
elif (conf.CheckCXXHeader( "execinfo.h" ) and
|
||||
if (conf.CheckCXXHeader( "execinfo.h" ) and
|
||||
conf.CheckDeclaration('backtrace', includes='#include <execinfo.h>') and
|
||||
conf.CheckDeclaration('backtrace_symbols', includes='#include <execinfo.h>')):
|
||||
|
||||
@ -811,11 +808,9 @@ def doConfigure(myenv):
|
||||
if not conf.CheckLib( v8_lib_choices ):
|
||||
Exit(1)
|
||||
|
||||
# requires ports devel/libexecinfo or devel/libunwind to be installed
|
||||
# requires ports devel/libexecinfo to be installed
|
||||
if freebsd or openbsd:
|
||||
# CheckLib actually sets the -l argument, so check in the
|
||||
# order of precedence.
|
||||
if not (conf.CheckLib("unwind") or conf.CheckLib("execinfo")):
|
||||
if not conf.CheckLib("execinfo"):
|
||||
Exit(1)
|
||||
|
||||
# 'tcmalloc' needs to be the last library linked. Please, add new libraries before this
|
||||
|
@ -34,53 +34,6 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
|
||||
#elif MONGO_HAVE_UNWIND_BACKTRACE
|
||||
|
||||
// This makes libunwind only work for within the
|
||||
// current process, but that's what we want anyway.
|
||||
#define UNW_LOCAL_ONLY
|
||||
|
||||
#include <libunwind.h>
|
||||
|
||||
namespace mongo {
|
||||
static const int maxBackTraceFrames = 20;
|
||||
|
||||
void printStackTrace( std::ostream &os ) {
|
||||
unw_context_t stack;
|
||||
unw_cursor_t cursor;
|
||||
|
||||
int status = unw_getcontext(&stack);
|
||||
if (status != 0) {
|
||||
os << "unw_getcontext failed: " << status << std::endl;
|
||||
return;
|
||||
}
|
||||
status = unw_init_local(&cursor, &stack);
|
||||
if (status != 0) {
|
||||
os << "unw_init_local failed: " << status << std::endl;
|
||||
return;
|
||||
}
|
||||
for ( int depth = 0; (depth < maxBackTraceFrames && unw_step(&cursor) != 0); ++depth ) {
|
||||
unw_word_t offset;
|
||||
unw_word_t pc;
|
||||
char fname[128];
|
||||
|
||||
status = unw_get_reg(&cursor, UNW_REG_IP, &pc);
|
||||
if (status != 0) {
|
||||
os << "unw_get_reg failed: " << status << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
fname[0] = '\0';
|
||||
status = unw_get_proc_name(&cursor, fname, sizeof(fname), &offset);
|
||||
if (status != 0) {
|
||||
os << "unw_get_proc_name failed: " << status << std::endl;
|
||||
return;
|
||||
}
|
||||
os << fname << "+0x" << offset << " [0x" << std::hex << pc << std::dec << "]" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace mongo {
|
||||
|
Loading…
Reference in New Issue
Block a user