Esempio n. 1
0
void duk_debug_dump_heap(duk_heap *heap) {
	char buf[64+1];

	DUK_DPRINT("=== heap %p ===", (void *) heap);
	DUK_DPRINT("  flags: 0x%08x", (int) heap->flags);

	/* Note: there is no standard formatter for function pointers */
#ifdef DUK_USE_GCC_PRAGMAS
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-pedantic"
#endif
	duk_debug_format_funcptr(buf, sizeof(buf), (unsigned char *) &heap->alloc_func, sizeof(heap->alloc_func));
	DUK_DPRINT("  alloc_func: %s", buf);
	duk_debug_format_funcptr(buf, sizeof(buf), (unsigned char *) &heap->realloc_func, sizeof(heap->realloc_func));
	DUK_DPRINT("  realloc_func: %s", buf);
	duk_debug_format_funcptr(buf, sizeof(buf), (unsigned char *) &heap->free_func, sizeof(heap->free_func));
	DUK_DPRINT("  free_func: %s", buf);
#ifdef DUK_USE_GCC_PRAGMAS
#pragma GCC diagnostic pop
#endif

	DUK_DPRINT("  alloc_udata: %p", (void *) heap->alloc_udata);

#ifdef DUK_USE_MARK_AND_SWEEP
	DUK_DPRINT("  mark-and-sweep trig counter: %d", heap->mark_and_sweep_trigger_counter);
	DUK_DPRINT("  mark-and-sweep trig limit: %d", heap->mark_and_sweep_trigger_limit);
	DUK_DPRINT("  mark-and-sweep rec depth: %d", heap->mark_and_sweep_recursion_depth);
	DUK_DPRINT("  mark-and-sweep rec limit: %d", heap->mark_and_sweep_recursion_limit);
	DUK_DPRINT("  mark-and-sweep base flags: 0x%08x", heap->mark_and_sweep_base_flags);
#endif

	/* FIXME: heap->fatal_func */

	DUK_DPRINT("  lj.jmpbuf_ptr: %p", (void *) heap->lj.jmpbuf_ptr);
	DUK_DPRINT("  lj.errhandler: %!@O", (duk_heaphdr *) heap->lj.errhandler);
	DUK_DPRINT("  lj.type: %d", heap->lj.type);
	DUK_DPRINT("  lj.value1: %!T", &heap->lj.value1);
	DUK_DPRINT("  lj.value2: %!T", &heap->lj.value2);
	DUK_DPRINT("  lj.iserror: %d", heap->lj.iserror);

	DUK_DPRINT("  handling_error: %d", heap->handling_error);

	DUK_DPRINT("  heap_thread: %!@O", (duk_heaphdr *) heap->heap_thread);
	DUK_DPRINT("  curr_thread: %!@O", (duk_heaphdr *) heap->curr_thread);
	DUK_DPRINT("  heap_object: %!@O", (duk_heaphdr *) heap->heap_object);

	DUK_DPRINT("  call_recursion_depth: %d", heap->call_recursion_depth);
	DUK_DPRINT("  call_recursion_limit: %d", heap->call_recursion_limit);

	DUK_DPRINT("  hash_seed: 0x%08x", (int) heap->hash_seed);
	DUK_DPRINT("  rnd_state: 0x%08x", (int) heap->rnd_state);

	dump_strcache(heap);

	dump_heaphdr_list(heap, heap->heap_allocated, "heap allocated");

#ifdef DUK_USE_REFERENCE_COUNTING
	dump_heaphdr_list(heap, heap->refzero_list, "refcounting refzero list");
#endif

#ifdef DUK_USE_MARK_AND_SWEEP
	dump_heaphdr_list(heap, heap->finalize_list, "mark-and-sweep finalize list");
#endif

	dump_stringtable(heap);

	/* heap->strs: not worth dumping */
}
Esempio n. 2
0
/*
 *****************************************************************************
 * Function	: dump_resources
 * Syntax	: void dump_resources(const resource_t *top)
 * Input	:
 *	top	- Top of the resource tree
 * Output	:
 *	nop
 * Description	: Dump the parsed resource-tree to stdout
 * Remarks	:
 *****************************************************************************
*/
void dump_resources(const resource_t *top)
{
	printf("Internal resource-tree dump:\n");
	while(top)
	{
		printf("Resource: %s\nId: %s\n",
		       get_typename(top),
		       get_nameid_str(top->name));
		switch(top->type)
		{
		case res_acc:
			dump_accelerator(top->res.acc);
			break;
		case res_bmp:
			dump_bitmap(top->res.bmp);
			break;
		case res_cur:
			dump_cursor(top->res.cur);
			break;
		case res_curg:
			dump_cursor_group(top->res.curg);
			break;
		case res_dlg:
			dump_dialog(top->res.dlg);
			break;
		case res_dlgex:
			dump_dialogex(top->res.dlgex);
			break;
		case res_fnt:
			dump_font(top->res.fnt);
			break;
		case res_icog:
			dump_icon_group(top->res.icog);
			break;
		case res_ico:
			dump_icon(top->res.ico);
			break;
		case res_men:
			dump_menu(top->res.men);
			break;
		case res_menex:
			dump_menuex(top->res.menex);
			break;
		case res_rdt:
			dump_rcdata(top->res.rdt);
			break;
		case res_stt:
			dump_stringtable(top->res.stt);
			break;
		case res_usr:
			dump_user(top->res.usr);
			break;
		case res_msg:
			dump_messagetable(top->res.msg);
			break;
		case res_ver:
			dump_versioninfo(top->res.ver);
			break;
		case res_dlginit:
			dump_dlginit(top->res.dlgi);
			break;
		case res_toolbar:
			dump_toolbar(top->res.tbt);
			break;
		case res_anicur:
		case res_aniico:
			dump_ani_curico(top->res.ani);
			break;
		default:
			printf("Report this: Unknown resource type parsed %08x\n", top->type);
		}
		printf("\n");
		top = top->next;
	}
}