Skip to content

Commit

Permalink
Fix aot debugger compilation error on windows (#3370)
Browse files Browse the repository at this point in the history
Fix aot debugger compilation error on windows as reported in #3184.

And update the stack size configuration for product-mini zephyr sample
since the native stack overflow check was enhanced and the zephyr-sdk
was also upgraded.
  • Loading branch information
wenyongh committed Apr 29, 2024
1 parent 120b965 commit e11eae9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
1 change: 0 additions & 1 deletion core/iwasm/aot/debug/elf_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
Expand Down
13 changes: 10 additions & 3 deletions core/iwasm/aot/debug/jit_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
Expand Down Expand Up @@ -56,16 +55,24 @@ typedef struct JITDescriptor {
JITCodeEntry *first_entry_;
} JITDescriptor;

#if defined(_WIN32) || defined(_WIN32_)
#define attribute_noinline __declspec(noinline)
#else
#define attribute_noinline __attribute__((noinline))
#endif

/* LLVM has already define this */
#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0)
/**
* GDB will place breakpoint into this function.
* To prevent GCC from inlining or removing it we place noinline attribute
* and inline assembler statement inside.
*/
void __attribute__((noinline)) __jit_debug_register_code();
void attribute_noinline
__jit_debug_register_code();

void __attribute__((noinline)) __jit_debug_register_code()
void attribute_noinline
__jit_debug_register_code()
{
int x;
*(char *)&x = '\0';
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/interpreter/wasm_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ execute_malloc_function(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
#endif
{
argc = 1;
argv[0] = size;
argv[0] = (uint32)size;
}

/* if __retain is exported, then this module is compiled by
Expand Down
1 change: 1 addition & 0 deletions product-mini/platforms/zephyr/simple/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
CONFIG_STACK_SENTINEL=y
CONFIG_PRINTK=y
CONFIG_LOG=y
CONFIG_LOG_BUFFER_SIZE=4096
17 changes: 2 additions & 15 deletions product-mini/platforms/zephyr/simple/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,16 @@
#endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */

#if defined(BUILD_TARGET_RISCV64_LP64) || defined(BUILD_TARGET_RISCV32_ILP32)
#if defined(BUILD_TARGET_RISCV64_LP64)
#define CONFIG_GLOBAL_HEAP_BUF_SIZE 4360
#define CONFIG_APP_STACK_SIZE 288
#define CONFIG_MAIN_THREAD_STACK_SIZE 2400
#else
#define CONFIG_GLOBAL_HEAP_BUF_SIZE 5120
#define CONFIG_APP_STACK_SIZE 512
#define CONFIG_MAIN_THREAD_STACK_SIZE 4096
#endif
#define CONFIG_APP_HEAP_SIZE 256
#define CONFIG_APP_HEAP_SIZE 512
#else /* else of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */

#define CONFIG_GLOBAL_HEAP_BUF_SIZE WASM_GLOBAL_HEAP_SIZE
#define CONFIG_APP_STACK_SIZE 8192
#define CONFIG_APP_HEAP_SIZE 8192
#endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */

#ifdef CONFIG_NO_OPTIMIZATIONS
#define CONFIG_MAIN_THREAD_STACK_SIZE 8192
#else
#define CONFIG_MAIN_THREAD_STACK_SIZE 4096
#endif

#endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */

static int app_argc;
static char **app_argv;
Expand Down

0 comments on commit e11eae9

Please sign in to comment.