• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ print_backtrace函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中print_backtrace函数的典型用法代码示例。如果您正苦于以下问题:C++ print_backtrace函数的具体用法?C++ print_backtrace怎么用?C++ print_backtrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了print_backtrace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:PhungXuanAnh,项目名称:mza-v3.0-bsp,代码行数:59,代码来源:malloc_debug_check.c


示例2: segfaultHandler

/// Segmentation fault signal handler.
void
segfaultHandler(int sigtype)
{
    nvlog_flush();
    print_backtrace(sigtype);
    exit(-1);
}
开发者ID:AXLEproject,项目名称:nvram-sim,代码行数:8,代码来源:main.cpp


示例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);
}
开发者ID:chos9,项目名称:sage,代码行数:30,代码来源:interrupt.c


示例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) */
}
开发者ID:hpc,项目名称:mvapich2-cce,代码行数:25,代码来源:ch3_abort.c


示例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;
    }
}
开发者ID:antworteffekt,项目名称:sage,代码行数:35,代码来源:interrupt.c


示例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();
}
开发者ID:antworteffekt,项目名称:sage,代码行数:7,代码来源:interrupt.c


示例7: strexit

void strexit(const char* msg, int errval)
{
	print_backtrace();
	printf("Error: %s: %s\n", msg, strerror(errval));
	cleanup();
	exit(EXIT_FAILURE);
}
开发者ID:rdspring1,项目名称:finalproject-cs380l,代码行数:7,代码来源:laiocopy.c


示例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;
}
开发者ID:bitursa,项目名称:maos,代码行数:7,代码来源:sock.c


示例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);
}
开发者ID:bloom-lang,项目名称:c4,代码行数:7,代码来源:error.c


示例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
	}
开发者ID:SiderZhang,项目名称:p2pns3,代码行数:31,代码来源:allocator.cpp


示例11: print_backtrace

 void RubyException::show(STATE) {
   std::cout << exception->message_c_str(state) <<
       " (" <<
       exception->class_object(state)->debug_str(state) <<
       ") \n";
   print_backtrace();
 }
开发者ID:NateBarnes,项目名称:rubinius,代码行数:7,代码来源:exception.cpp


示例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);
	}
}
开发者ID:svn2github,项目名称:texstudio,代码行数:30,代码来源:debughelper.cpp


示例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;
}
开发者ID:lianqiw,项目名称:maos,代码行数:7,代码来源:sock.c


示例14: bug

 void bug(const char* message, const char* arg) {
   std::cerr << "[BUG: " << message
             << ": " << arg
             << "]\n";
   print_backtrace();
   ::abort();
 }
开发者ID:NateBarnes,项目名称:rubinius,代码行数:7,代码来源:exception.cpp


示例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;
  }
}
开发者ID:tanisman,项目名称:IncludeOS,代码行数:60,代码来源:heap_debugging.cpp


示例16: _exception

void
_exception(int signr, struct pt_regs *regs)
{
    show_regs(regs);
    print_backtrace((unsigned long *)regs->gpr[1]);
    panic("Exception");
}
开发者ID:idCache,项目名称:rt-thread,代码行数:7,代码来源:traps.c


示例17: signal_handler

static void
signal_handler(int sig)
{
	fprintf(stderr, "Signal %d:\n", sig);
	print_backtrace();
	exit(1);
}
开发者ID:dansanduleac,项目名称:TESLA,代码行数:7,代码来源:helpers.c


示例18: MachineCheckException

void MachineCheckException(struct pt_regs *regs)
{
    unsigned long fixup, val;

    if ((fixup = search_exception_table(regs->nip)) != 0) {
        regs->nip = fixup;
        val = mfspr(MCSR);
        /* Clear MCSR */
        mtspr(SPRN_MCSR, val);
        return;
    }

    rt_kprintf("Machine Check Exception.\n");
    rt_kprintf("Caused by (from msr): ");
    rt_kprintf("regs %p ", regs);

    val = get_esr();

    if (val& ESR_IMCP) {
        rt_kprintf("Instruction");
        mtspr(ESR, val & ~ESR_IMCP);
    } else {
        rt_kprintf("Data");
    }
    rt_kprintf(" machine check.\n");

    show_regs(regs);
    print_backtrace((unsigned long *)regs->gpr[1]);
    panic("machine check");
}
开发者ID:idCache,项目名称:rt-thread,代码行数:30,代码来源:traps.c


示例19: heaptracker_free_leaked_memory

static void heaptracker_free_leaked_memory(void)
{
    struct hdr *del; int cnt;

    if (num)
        log_message("+++ THERE ARE %d LEAKED ALLOCATIONS\n", num);

    while (head) {
        int safe;
        del = head;
        log_message("+++ DELETING %d BYTES OF LEAKED MEMORY AT %p (%d REMAINING)\n",
                del->size, user(del), num);
        if (del_leak(del, &safe)) {
            /* safe == 1, because the allocation is valid */
            log_message("+++ ALLOCATION %p SIZE %d ALLOCATED HERE:\n",
                        user(del), del->size);
            print_backtrace(del->bt, del->bt_depth);
        }
        dlfree(del);
    }

//  log_message("+++ DELETING %d BACKLOGGED ALLOCATIONS\n", backlog_num);
    while (backlog_head) {
	del = backlog_tail;
        del_from_backlog(del);
        dlfree(del);
    }
}
开发者ID:PhungXuanAnh,项目名称:mza-v3.0-bsp,代码行数:28,代码来源:malloc_debug_check.c


示例20: hammer2_inode_drop

/*
 * Drop an inode reference, freeing the inode when the last reference goes
 * away.
 */
void
hammer2_inode_drop(hammer2_inode_t *ip)
{
	hammer2_pfs_t *pmp;
	u_int refs;

	while (ip) {
		if (hammer2_debug & 0x80000) {
			kprintf("INODE-1 %p (%d->%d)\n",
				ip, ip->refs, ip->refs - 1);
			print_backtrace(8);
		}
		refs = ip->refs;
		cpu_ccfence();
		if (refs == 1) {
			/*
			 * Transition to zero, must interlock with
			 * the inode inumber lookup tree (if applicable).
			 * It should not be possible for anyone to race
			 * the transition to 0.
			 */
			pmp = ip->pmp;
			KKASSERT(pmp);
			hammer2_spin_ex(&pmp->inum_spin);

			if (atomic_cmpset_int(&ip->refs, 1, 0)) {
				KKASSERT(hammer2_mtx_refs(&ip->lock) == 0);
				if (ip->flags & HAMMER2_INODE_ONRBTREE) {
					atomic_clear_int(&ip->flags,
						     HAMMER2_INODE_ONRBTREE);
					RB_REMOVE(hammer2_inode_tree,
						  &pmp->inum_tree, ip);
					--pmp->inum_count;
				}
				hammer2_spin_unex(&pmp->inum_spin);

				ip->pmp = NULL;

				/*
				 * Cleaning out ip->cluster isn't entirely
				 * trivial.
				 */
				hammer2_inode_repoint(ip, NULL, NULL);

				kfree(ip, pmp->minode);
				atomic_add_long(&pmp->inmem_inodes, -1);
				ip = NULL;	/* will terminate loop */
			} else {
				hammer2_spin_unex(&ip->pmp->inum_spin);
			}
		} else {
			/*
			 * Non zero transition
			 */
			if (atomic_cmpset_int(&ip->refs, refs, refs - 1))
				break;
		}
	}
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:63,代码来源:hammer2_inode.c



注:本文中的print_backtrace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ print_begin_test函数代码示例发布时间:2022-05-30
下一篇:
C++ print_attributes函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap