From 83183333044cb81073d9233681ce2f5904d4c4a9 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 26 Dec 2023 17:56:34 +0900 Subject: [PATCH] nuttx: Add CONFIG_INTERPRETERS_WAMR_DEBUG_AOT (#2929) At least it's sometimes useful for nuttx sim. eg. (modified a bit to avoid github autolinks) ``` spacetanuki% lldb ./nuttx (lldb) target create "./nuttx" Current executable set to '/Users/yamamoto/git/nuttx/nuttx/nuttx' (x86_64). (lldb) settings set plugin.jit-loader.gdb.enable on (lldb) b foo Breakpoint 1: no locations (pending). WARNING: Unable to resolve breakpoint to any actual locations. (lldb) r Process 37011 launched: '/Users/yamamoto/git/nuttx/nuttx/nuttx' (x86_64) NuttShell (NSH) NuttX-10.4.0 nsh> mount -t hostfs -o fs=/tmp/wasm /mnt nsh> iwasm /mnt/test.aot 1 location added to breakpoint 1 Process 37011 stopped * thread #_1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #_0: 0x0000000105800673 JIT(0x1058002d4)`foo(exenv=0x0000000101284280) at test.c:5 2 3 __attribute__((noinline)) 4 void foo() -> 5 { 6 printf("hello from %s\n", __func__); 7 } 8 Target 0: (nuttx) stopped. (lldb) bt * thread #_1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 * frame #_0: 0x0000000105800673 JIT(0x1058002d4)`foo(exenv=0x0000000101284280) at test.c:5 frame #_1: 0x000000010580077a JIT(0x1058002d4)`bar(exenv=0x0000000101284280) at test.c:12:2 frame #_2: 0x000000010580086a JIT(0x1058002d4)`baz(exenv=0x0000000101284280) at test.c:19:2 frame #_3: 0x0000000105800972 JIT(0x1058002d4)`__main_argc_argv(exenv=, argc=, argv=) at test.c:26:3 frame #_4: 0x00000001058061aa JIT(0x1058002d4)`aot_func#14 + 278 ... ``` --- product-mini/platforms/nuttx/wamr.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/product-mini/platforms/nuttx/wamr.mk b/product-mini/platforms/nuttx/wamr.mk index b91fac9a8..ad921157c 100644 --- a/product-mini/platforms/nuttx/wamr.mk +++ b/product-mini/platforms/nuttx/wamr.mk @@ -133,6 +133,11 @@ CSRCS += aot_loader.c \ $(AOT_RELOC) \ aot_intrinsic.c \ aot_runtime.c +ifeq ($(CONFIG_INTERPRETERS_WAMR_DEBUG_AOT),y) +CFLAGS += -DWASM_ENABLE_DEBUG_AOT=1 +CSRCS += elf_parser.c \ + jit_debug.c +endif else CFLAGS += -DWASM_ENABLE_AOT=0 endif @@ -412,3 +417,4 @@ VPATH += $(IWASM_ROOT)/libraries/lib-pthread VPATH += $(IWASM_ROOT)/common/arch VPATH += $(IWASM_ROOT)/aot VPATH += $(IWASM_ROOT)/aot/arch +VPATH += $(IWASM_ROOT)/aot/debug