From c46516996da53eaf2f9aca516264870e25719d76 Mon Sep 17 00:00:00 2001 From: HarlonWang <81813780@qq.com> Date: Wed, 18 Sep 2024 18:10:24 +0800 Subject: [PATCH] Add JS_DumpObjects support --- quickjs.c | 24 +++++++++++++----------- quickjs.h | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/quickjs.c b/quickjs.c index 642ae3429..4235a6d6a 100644 --- a/quickjs.c +++ b/quickjs.c @@ -2295,17 +2295,7 @@ void JS_FreeContext(JSContext *ctx) JS_DumpShapes(ctx->rt); #endif #ifdef DUMP_OBJECTS - { - struct list_head *el; - JSGCObjectHeader *p; - printf("JSObjects: {\n"); - JS_DumpObjectHeader(ctx->rt); - list_for_each(el, &rt->gc_obj_list) { - p = list_entry(el, JSGCObjectHeader, link); - JS_DumpGCObject(rt, p); - } - printf("}\n"); - } + JS_DumpObjects(ctx-rt); #endif #ifdef DUMP_MEM { @@ -6378,6 +6368,18 @@ void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt) } } +void JS_DumpObjects(JSRuntime *rt){ + struct list_head *el; + JSGCObjectHeader *p; + printf("JSObjects: {\n"); + JS_DumpObjectHeader(rt); + list_for_each(el, &rt->gc_obj_list) { + p = list_entry(el, JSGCObjectHeader, link); + JS_DumpGCObject(rt, p); + } + printf("}\n"); +} + JSValue JS_GetGlobalObject(JSContext *ctx) { return JS_DupValue(ctx, ctx->global_obj); diff --git a/quickjs.h b/quickjs.h index edc7b47b3..fd35db09f 100644 --- a/quickjs.h +++ b/quickjs.h @@ -417,6 +417,7 @@ typedef struct JSMemoryUsage { void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s); void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt); +void JS_DumpObjects(JSRuntime *rt); /* atom support */ #define JS_ATOM_NULL 0