⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbg_mlc.c

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 C
📖 第 1 页 / 共 3 页
字号:
	  case NORMAL:	    GC_err_puts("NORMAL");	    break;	  case UNCOLLECTABLE:	    GC_err_puts("UNCOLLECTABLE");	    break;#	  ifdef ATOMIC_UNCOLLECTABLE	    case AUNCOLLECTABLE:	      GC_err_puts("ATOMIC UNCOLLECTABLE");	      break;#	  endif	  case STUBBORN:	    GC_err_puts("STUBBORN");	    break;	  default:	    GC_err_printf("kind %d, descr 0x%lx", kind,			  (unsigned long)(hhdr -> hb_descr));	}    }}    void GC_print_obj(ptr_t p){    register oh * ohdr = (oh *)GC_base(p);        GC_ASSERT(I_DONT_HOLD_LOCK());    GC_err_printf("%p (", ((ptr_t)ohdr + sizeof(oh)));    GC_err_puts(ohdr -> oh_string);#   ifdef SHORT_DBG_HDRS      GC_err_printf(":%ld, ", (unsigned long)(ohdr -> oh_int));#   else      GC_err_printf(":%ld, sz=%ld, ", (unsigned long)(ohdr -> oh_int),          			        (unsigned long)(ohdr -> oh_sz));#   endif    GC_print_type((ptr_t)(ohdr + 1));    GC_err_puts(")\n");    PRINT_CALL_CHAIN(ohdr);}void GC_debug_print_heap_obj_proc(ptr_t p){    GC_ASSERT(I_DONT_HOLD_LOCK());    if (GC_HAS_DEBUG_INFO(p)) {	GC_print_obj(p);    } else {	GC_default_print_heap_obj_proc(p);    }}#ifndef SHORT_DBG_HDRSvoid GC_print_smashed_obj(ptr_t p, ptr_t clobbered_addr){    register oh * ohdr = (oh *)GC_base(p);        GC_ASSERT(I_DONT_HOLD_LOCK());    GC_err_printf("%p in object at %p(", clobbered_addr, p);    if (clobbered_addr <= (ptr_t)(&(ohdr -> oh_sz))        || ohdr -> oh_string == 0) {        GC_err_printf("<smashed>, appr. sz = %ld)\n",        	       (GC_size((ptr_t)ohdr) - DEBUG_BYTES));    } else {        if (ohdr -> oh_string[0] == '\0') {            GC_err_puts("EMPTY(smashed?)");        } else {            GC_err_puts(ohdr -> oh_string);        }        GC_err_printf(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int),        			          (unsigned long)(ohdr -> oh_sz));        PRINT_CALL_CHAIN(ohdr);    }}#endifvoid GC_check_heap_proc (void);void GC_print_all_smashed_proc (void);void GC_do_nothing(void) {}void GC_start_debugging(void){#   ifndef SHORT_DBG_HDRS      GC_check_heap = GC_check_heap_proc;      GC_print_all_smashed = GC_print_all_smashed_proc;#   else      GC_check_heap = GC_do_nothing;      GC_print_all_smashed = GC_do_nothing;#   endif    GC_print_heap_obj = GC_debug_print_heap_obj_proc;    GC_debugging_started = TRUE;    GC_register_displacement((word)sizeof(oh));}size_t GC_debug_header_size = sizeof(oh);void GC_debug_register_displacement(size_t offset){    GC_register_displacement(offset);    GC_register_displacement((word)sizeof(oh) + offset);}void * GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS){    void * result = GC_malloc(lb + DEBUG_BYTES);        if (result == 0) {        GC_err_printf("GC_debug_malloc(%lu) returning NIL (",        	      (unsigned long) lb);        GC_err_puts(s);        GC_err_printf(":%ld)\n", (unsigned long)i);        return(0);    }    if (!GC_debugging_started) {    	GC_start_debugging();    }    ADD_CALL_CHAIN(result, ra);    return (GC_store_debug_info(result, (word)lb, s, (word)i));}void * GC_debug_malloc_ignore_off_page(size_t lb, GC_EXTRA_PARAMS){    void * result = GC_malloc_ignore_off_page(lb + DEBUG_BYTES);        if (result == 0) {        GC_err_printf("GC_debug_malloc_ignore_off_page(%lu) returning NIL (",        	       (unsigned long) lb);        GC_err_puts(s);        GC_err_printf(":%lu)\n", (unsigned long)i);        return(0);    }    if (!GC_debugging_started) {    	GC_start_debugging();    }    ADD_CALL_CHAIN(result, ra);    return (GC_store_debug_info(result, (word)lb, s, (word)i));}void * GC_debug_malloc_atomic_ignore_off_page(size_t lb, GC_EXTRA_PARAMS){    void * result = GC_malloc_atomic_ignore_off_page(lb + DEBUG_BYTES);        if (result == 0) {        GC_err_printf("GC_debug_malloc_atomic_ignore_off_page(%lu)"		       " returning NIL (", (unsigned long) lb);        GC_err_puts(s);        GC_err_printf(":%lu)\n", (unsigned long)i);        return(0);    }    if (!GC_debugging_started) {    	GC_start_debugging();    }    ADD_CALL_CHAIN(result, ra);    return (GC_store_debug_info(result, (word)lb, s, (word)i));}# ifdef DBG_HDRS_ALL/*  * An allocation function for internal use. * Normally internally allocated objects do not have debug information. * But in this case, we need to make sure that all objects have debug * headers. * We assume debugging was started in collector initialization, * and we already hold the GC lock. */  void * GC_debug_generic_malloc_inner(size_t lb, int k)  {    void * result = GC_generic_malloc_inner(lb + DEBUG_BYTES, k);        if (result == 0) {        GC_err_printf("GC internal allocation (%lu bytes) returning NIL\n",        	       (unsigned long) lb);        return(0);    }    ADD_CALL_CHAIN(result, GC_RETURN_ADDR);    return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", (word)0));  }  void * GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k)  {    void * result = GC_generic_malloc_inner_ignore_off_page(					        lb + DEBUG_BYTES, k);        if (result == 0) {        GC_err_printf("GC internal allocation (%lu bytes) returning NIL\n",        	       (unsigned long) lb);        return(0);    }    ADD_CALL_CHAIN(result, GC_RETURN_ADDR);    return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", (word)0));  }# endif#ifdef STUBBORN_ALLOCvoid * GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS){    void * result = GC_malloc_stubborn(lb + DEBUG_BYTES);        if (result == 0) {        GC_err_printf("GC_debug_malloc(%lu) returning NIL (",        	      (unsigned long) lb);        GC_err_puts(s);        GC_err_printf(":%lu)\n", (unsigned long)i);        return(0);    }    if (!GC_debugging_started) {    	GC_start_debugging();    }    ADD_CALL_CHAIN(result, ra);    return (GC_store_debug_info(result, (word)lb, s, (word)i));}void GC_debug_change_stubborn(void *p){    void * q = GC_base(p);    hdr * hhdr;        if (q == 0) {        GC_err_printf("Bad argument: %p to GC_debug_change_stubborn\n", p);        ABORT("GC_debug_change_stubborn: bad arg");    }    hhdr = HDR(q);    if (hhdr -> hb_obj_kind != STUBBORN) {        GC_err_printf("GC_debug_change_stubborn arg not stubborn: %p\n", p);        ABORT("GC_debug_change_stubborn: arg not stubborn");    }    GC_change_stubborn(q);}void GC_debug_end_stubborn_change(void *p){    register void * q = GC_base(p);    register hdr * hhdr;        if (q == 0) {        GC_err_printf("Bad argument: %p to GC_debug_end_stubborn_change\n", p);        ABORT("GC_debug_end_stubborn_change: bad arg");    }    hhdr = HDR(q);    if (hhdr -> hb_obj_kind != STUBBORN) {        GC_err_printf("debug_end_stubborn_change arg not stubborn: %p\n", p);        ABORT("GC_debug_end_stubborn_change: arg not stubborn");    }    GC_end_stubborn_change(q);}#else /* !STUBBORN_ALLOC */void * GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS){    return GC_debug_malloc(lb, OPT_RA s, i);}void GC_debug_change_stubborn(void *p){}void GC_debug_end_stubborn_change(void *p){}#endif /* !STUBBORN_ALLOC */void * GC_debug_malloc_atomic(size_t lb, GC_EXTRA_PARAMS){    void * result = GC_malloc_atomic(lb + DEBUG_BYTES);        if (result == 0) {        GC_err_printf("GC_debug_malloc_atomic(%lu) returning NIL (",        	      (unsigned long) lb);        GC_err_puts(s);        GC_err_printf(":%lu)\n", (unsigned long)i);        return(0);    }    if (!GC_debugging_started) {        GC_start_debugging();    }    ADD_CALL_CHAIN(result, ra);    return (GC_store_debug_info(result, (word)lb, s, (word)i));}char *GC_debug_strdup(const char *str, GC_EXTRA_PARAMS){    char *copy;    if (str == NULL) return NULL;    copy = GC_debug_malloc_atomic(strlen(str) + 1, OPT_RA s, i);    if (copy == NULL) {      errno = ENOMEM;      return NULL;    }    strcpy(copy, str);    return copy;}void * GC_debug_malloc_uncollectable(size_t lb, GC_EXTRA_PARAMS){    void * result = GC_malloc_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES);        if (result == 0) {        GC_err_printf("GC_debug_malloc_uncollectable(%lu) returning NIL (",        	      (unsigned long) lb);        GC_err_puts(s);        GC_err_printf(":%lu)\n", (unsigned long)i);        return(0);    }    if (!GC_debugging_started) {        GC_start_debugging();    }    ADD_CALL_CHAIN(result, ra);    return (GC_store_debug_info(result, (word)lb, s, (word)i));}#ifdef ATOMIC_UNCOLLECTABLEvoid * GC_debug_malloc_atomic_uncollectable(size_t lb, GC_EXTRA_PARAMS){    void * result =	GC_malloc_atomic_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES);        if (result == 0) {        GC_err_printf(		"GC_debug_malloc_atomic_uncollectable(%lu) returning NIL (",                (unsigned long) lb);        GC_err_puts(s);        GC_err_printf(":%lu)\n", (unsigned long)i);        return(0);    }    if (!GC_debugging_started) {        GC_start_debugging();    }    ADD_CALL_CHAIN(result, ra);    return (GC_store_debug_info(result, (word)lb, s, (word)i));}#endif /* ATOMIC_UNCOLLECTABLE */void GC_debug_free(void * p){    ptr_t base;    ptr_t clobbered;        if (0 == p) return;    base = GC_base(p);    if (base == 0) {        GC_err_printf("Attempt to free invalid pointer %p\n", p);        ABORT("free(invalid pointer)");    }    if ((ptr_t)p - (ptr_t)base != sizeof(oh)) {        GC_err_printf(        	  "GC_debug_free called on pointer %p wo debugging info\n", p);    } else {#     ifndef SHORT_DBG_HDRS        clobbered = GC_check_annotated_obj((oh *)base);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -