本文整理汇总了C++中print_backtrace函数的典型用法代码示例。如果您正苦于以下问题:C++ print_backtrace函数的具体用法?C++ print_backtrace怎么用?C++ print_backtrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_backtrace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chk_free
void *chk_realloc(void *ptr, size_t size)
{
struct hdr *hdr;
// log_message("%s: %s\n", __FILE__, __FUNCTION__);
if (!size) {
chk_free(ptr);
return NULL;
}
if (!ptr)
return chk_malloc(size);
hdr = meta(ptr);
if (del(hdr) < 0) {
intptr_t bt[MAX_BACKTRACE_DEPTH];
int depth;
depth = get_backtrace(bt, MAX_BACKTRACE_DEPTH);
if (hdr->tag == BACKLOG_TAG) {
log_message("+++ REALLOCATION %p SIZE %d OF FREED MEMORY!\n",
user(hdr), size, hdr->size);
log_message("+++ ALLOCATION %p SIZE %d ALLOCATED HERE:\n",
user(hdr), hdr->size);
print_backtrace(hdr->bt, hdr->bt_depth);
/* hdr->freed_bt_depth should be nonzero here */
log_message("+++ ALLOCATION %p SIZE %d FIRST FREED HERE:\n",
user(hdr), hdr->size);
print_backtrace(hdr->freed_bt, hdr->freed_bt_depth);
log_message("+++ ALLOCATION %p SIZE %d NOW BEING REALLOCATED HERE:\n",
user(hdr), hdr->size);
print_backtrace(bt, depth);
/* We take the memory out of the backlog and fall through so the
* reallocation below succeeds. Since we didn't really free it, we
* can default to this behavior.
*/
del_from_backlog(hdr);
}
else {
log_message("+++ REALLOCATION %p SIZE %d IS CORRUPTED OR NOT ALLOCATED VIA TRACKER!\n",
user(hdr), size);
print_backtrace(bt, depth);
// just get a whole new allocation and leak the old one
return dlrealloc(0, size);
// return dlrealloc(user(hdr), size); // assuming it was allocated externally
}
}
hdr = dlrealloc(hdr, sizeof(struct hdr) + size + sizeof(struct ftr));
if (hdr) {
hdr->bt_depth = get_backtrace(hdr->bt, MAX_BACKTRACE_DEPTH);
add(hdr, size);
return user(hdr);
}
return NULL;
}
示例2: segfaultHandler
/// Segmentation fault signal handler.
void
segfaultHandler(int sigtype)
{
nvlog_flush();
print_backtrace(sigtype);
exit(-1);
}
示例3: sigdie
void sigdie(int sig, const char* s)
{
fprintf(stderr,
"------------------------------------------------------------------------\n");
print_backtrace();
#ifndef __APPLE__
/* See http://trac.sagemath.org/13889 for how Apple screwed this up */
fprintf(stderr,
"------------------------------------------------------------------------\n");
print_enhanced_backtrace();
#endif
fprintf(stderr,
"------------------------------------------------------------------------\n"
"%s\n"
"This probably occurred because a *compiled* component of Sage has a bug\n"
"in it and is not properly wrapped with sig_on(), sig_off(). You might\n"
"want to run Sage under gdb with 'sage -gdb' to debug this.\n"
"Sage will now terminate.\n"
"------------------------------------------------------------------------\n",
s);
fflush(stderr);
/* Suicide with signal ``sig`` */
kill(getpid(), sig);
/* We should be dead! */
exit(128 + sig);
}
示例4: MPIDI_CH3_Abort
int MPIDI_CH3_Abort(int exit_code, char *error_msg)
{
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_ABORT);
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_ABORT);
/* print backtrace */
if (show_backtrace) print_backtrace();
PMI_Abort(exit_code, error_msg);
/* if abort returns for some reason, exit here */
MPIU_Error_printf("%s", error_msg);
fflush(stderr);
exit(exit_code);
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#pragma error_messages(off, E_STATEMENT_NOT_REACHED)
#endif /* defined(__SUNPRO_C) || defined(__SUNPRO_CC) */
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3_ABORT);
return MPI_ERR_INTERN;
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#pragma error_messages(default, E_STATEMENT_NOT_REACHED)
#endif /* defined(__SUNPRO_C) || defined(__SUNPRO_CC) */
}
示例5: sage_interrupt_handler
/* Handler for SIGINT */
void sage_interrupt_handler(int sig)
{
#if ENABLE_DEBUG_INTERRUPT
fprintf(stderr, "\n*** SIGINT *** %s sig_on\n", (_signals.sig_on_count > 0) ? "inside" : "outside");
print_backtrace();
#endif
if (_signals.sig_on_count > 0)
{
if (_signals.block_sigint)
{
/* SIGINT is blocked, so simply set _signals.interrupt_received. */
_signals.interrupt_received = 1;
return;
}
/* Raise KeyboardInterrupt */
PyErr_SetNone(PyExc_KeyboardInterrupt);
/* Jump back to sig_on() (the first one if there is a stack) */
reset_CPU();
siglongjmp(_signals.env, sig);
}
else
{
/* Set an internal Python flag that an interrupt has been
* raised. This will not immediately raise an exception, only
* on the next call of PyErr_CheckSignals(). We cannot simply
* raise an exception here because of Python's "global
* interpreter lock" -- Jeroen Demeyer */
PyErr_SetInterrupt();
_signals.interrupt_received = 1;
}
}
示例6: _sig_off_warning
void _sig_off_warning(const char* file, int line)
{
char buf[320];
snprintf(buf, sizeof(buf), "sig_off() without sig_on() at %s:%i", file, line);
PyErr_WarnEx(PyExc_RuntimeWarning, buf, 2);
print_backtrace();
}
示例7: strexit
void strexit(const char* msg, int errval)
{
print_backtrace();
printf("Error: %s: %s\n", msg, strerror(errval));
cleanup();
exit(EXIT_FAILURE);
}
示例8: scheduler_signal_handler
static int scheduler_signal_handler(int sig){
/*quit listening upon signal and do clean up.*/
psignal(sig, "scheduler");
if(sig!=15) print_backtrace();
quit_listen=1;
return 1;
}
示例9: simple_error
void
simple_error(const char *file, int line_num)
{
fprintf(stderr, "FATAL ERROR at %s:%d\n", file, line_num);
print_backtrace();
exit(1);
}
示例10: page_size
void page_aligned_allocator::free(char* const block)
{
#ifdef TORRENT_DEBUG_BUFFERS
int page = page_size();
// make the two surrounding pages non-readable and -writable
mprotect(block - page, page, PROT_READ | PROT_WRITE);
alloc_header* h = (alloc_header*)(block - page);
int num_pages = (h->size + (page-1)) / page + 2;
TORRENT_ASSERT(h->magic == 0x1337);
mprotect(block + (num_pages-2) * page, page, PROT_READ | PROT_WRITE);
// fprintf(stderr, "free: %p head: %p tail: %p size: %d\n", block, block - page, block + h->size, int(h->size));
h->magic = 0;
#if defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
print_backtrace(h->stack, sizeof(h->stack));
#endif
::free(block - page);
return;
#endif
#ifdef TORRENT_WINDOWS
_aligned_free(block);
#elif defined TORRENT_BEOS
area_id id = area_for(block);
if (id < B_OK) return;
delete_area(id);
#else
::free(block);
#endif
}
示例11: print_backtrace
void RubyException::show(STATE) {
std::cout << exception->message_c_str(state) <<
" (" <<
exception->class_object(state)->debug_str(state) <<
") \n";
print_backtrace();
}
示例12: signalHandler
void signalHandler(int type, siginfo_t * si, void* ccontext){
lastErrorWasAssert = 0;
lastErrorWasLoop = 0;
SimulatedCPU cpu;
if (ccontext) {
cpu.set_all(ccontext);
if (cpu.frame == 0) cpu.frame = cpu.stack;
char *addr = (char*)(si->si_addr);
char * minstack = cpu.stack < cpu.frame ? cpu.stack : cpu.frame;
if (type == SIGSEGV && ptrdistance(addr, minstack) < 1024) type = SIGMYSTACKSEGV;
}
if (crashHandlerType & CRASH_HANDLER_PRINT_BACKTRACE || !ccontext) {
print_backtrace(signalIdToName(type));
if (!ccontext) return;
}
if (crashHandlerType & CRASH_HANDLER_RECOVER) {
if (type == SIGMYHANG) {
if (!isAddressInTeXstudio(cpu.pc)) return; //don't mess with library functions
lastLoopContext = *(static_cast<CPU_CONTEXT_TYPE*>(ccontext));
lastErrorWasLoop = 1;
} else if (type == SIGMYSTACKSEGV) cpu.unwindStack();
lastCrashSignal = type;
cpu.call((char*)(&recover));
cpu.get_all(ccontext);
}
}
示例13: scheduler_signal_handler
static int scheduler_signal_handler(int sig){
/*quit listening upon signal and do clean up.*/
info("scheduler: %s", sys_siglist[sig]);
if(sig!=15) print_backtrace();
quit_listen=1;
return 1;
}
示例14: bug
void bug(const char* message, const char* arg) {
std::cerr << "[BUG: " << message
<< ": " << arg
<< "]\n";
print_backtrace();
::abort();
}
示例15: new
void* operator new (std::size_t len) throw(std::bad_alloc)
{
void* data = nullptr;
if (enable_buffer_protection) {
// Allocate requested memory + enough to fit checksum at start and end
data = malloc(len + sizeof(buffer_protection_checksum) * 2);
// Write checksums
auto* temp = reinterpret_cast<char*>(data);
memcpy(temp,
&buffer_protection_checksum,
sizeof(buffer_protection_checksum));
memcpy(temp + sizeof(buffer_protection_checksum) + len,
&buffer_protection_checksum,
sizeof(buffer_protection_checksum));
} else {
data = malloc(len);
}
if (enable_debugging_verbose) {
DPRINTF("malloc(%llu bytes) == %p\n", (unsigned long long) len, data);
safe_print_symbol(1, __builtin_return_address(0));
safe_print_symbol(2, __builtin_return_address(1));
}
if (UNLIKELY(!data)) {
print_backtrace();
DPRINTF("malloc(%llu bytes): FAILED\n", (unsigned long long) len);
throw std::bad_alloc();
}
if (enable_debugging) {
if (!free_allocs.empty()) {
auto* x = free_allocs.pop();
new(x) allocation((char*) data, len,
__builtin_return_address(0),
__builtin_return_address(1),
__builtin_return_address(2));
} else if (!allocs.free_capacity()) {
DPRINTF("[WARNING] Internal fixed vectors are FULL, expect bogus double free messages\n");
} else {
allocs.emplace((char*) data, len,
__builtin_return_address(0),
__builtin_return_address(1),
__builtin_return_address(2));
}
}
if (enable_buffer_protection) {
// We need to return a pointer to the allocated memory + 4
// e.g. after our first checksum
return reinterpret_cast<void*>(reinterpret_cast<char*>(data) +
sizeof(buffer_protection_checksum));
} else {
return data;
}
}