MongoDB
1
Вклад в тег
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#include <cxxabi.h>
#include <stdio.h>
#include <stdlib.h>
void backtrace()
{
unw_cursor_t cursor;
unw_context_t context;
unw_getcontext(&context);
unw_init_local(&cursor, &context);
int n=0;
while ( unw_step(&cursor) ) {
unw_word_t ip, sp, off;
unw_get_reg(&cursor, UNW_REG_IP, &ip);
unw_get_reg(&cursor, UNW_REG_SP, &sp);
char symbol[256] = {"<unknown>"};
char *name = symbol;
if ( !unw_get_proc_name(&cursor, symbol, sizeof(symbol), &off) ) {
int status;
if ( (name = abi::__cxa_demangle(symbol, NULL, NULL, &status)) == 0 )
name = symbol;
}
printf("#%-2d 0x%016" PRIxPTR " sp=0x%016" PRIxPTR " %s + 0x%" PRIxPTR "\n",
++n,
static_cast<uintptr_t>(ip),
static_cast<uintptr_t>(sp),
name,
static_cast<uintptr_t>(off));
if ( name != symbol )
free(name);
}
}
#1 0x00000000003f909c sp=0x00000000afdfd348 OtherObjectName::OtherObjectName(long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0xcb8
#2 0x00000000001f6974 sp=0x00000000afdfd8c0 ObjectName::dothat(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0xa98
#3 0x00000000001e7c94 sp=0x00000000afdfe218 ObjectName::doit(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool) + 0x63f8
#4 0x00000000001d52f4 sp=0x00000000afdfeb08 ObjectName::justdo(ObjectNameTable_entry_s&, unsigned short) + 0xd524
#5 0x00000000001c7bc8 sp=0x00000000afdfec98 ObjectName::run() + 0x9f8