Implement source debugging for interpreter and AOT (#769)
Implement source debugging feature for classic interpreter and AOT: - use `cmake -DWAMR_BUILD_DEBUG_INTERP=1` to enable interpreter debugging - use `cmake -DWAMR_BUILD_DEBUG_AOT=1` to enable AOT debugging See doc/source_debugging.md for more details.
This commit is contained in:
@ -82,6 +82,17 @@ if (NOT DEFINED WAMR_BUILD_SIMD)
|
||||
set (WAMR_BUILD_SIMD 1)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP)
|
||||
# Disable Debug feature by default
|
||||
set (WAMR_BUILD_DEBUG_INTERP 0)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
|
||||
set (WAMR_BUILD_FAST_INTERP 0)
|
||||
set (WAMR_BUILD_MINI_LOADER 0)
|
||||
set (WAMR_BUILD_SIMD 0)
|
||||
endif ()
|
||||
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-U,_get_ext_lib_export_apis")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
|
||||
|
||||
@ -90,6 +90,17 @@ if (NOT DEFINED WAMR_BUILD_REF_TYPES)
|
||||
set (WAMR_BUILD_REF_TYPES 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP)
|
||||
# Disable Debug feature by default
|
||||
set (WAMR_BUILD_DEBUG_INTERP 0)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
|
||||
set (WAMR_BUILD_FAST_INTERP 0)
|
||||
set (WAMR_BUILD_MINI_LOADER 0)
|
||||
set (WAMR_BUILD_SIMD 0)
|
||||
endif ()
|
||||
|
||||
if (COLLECT_CODE_COVERAGE EQUAL 1)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif ()
|
||||
|
||||
@ -49,6 +49,9 @@ print_help()
|
||||
#endif
|
||||
#if WASM_ENABLE_LIB_PTHREAD != 0
|
||||
printf(" --max-threads=n Set maximum thread number per cluster, default is 4\n");
|
||||
#endif
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
printf(" -g=ip:port Set the debug sever address, default is debug disabled\n");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@ -241,6 +244,11 @@ main(int argc, char *argv[])
|
||||
const char *env_list[8] = { NULL };
|
||||
uint32 env_list_size = 0;
|
||||
#endif
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
char * ip_addr = NULL;
|
||||
//int platform_port = 0;
|
||||
int instance_port = 0;
|
||||
#endif
|
||||
|
||||
/* Process options. */
|
||||
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
||||
@ -321,6 +329,19 @@ main(int argc, char *argv[])
|
||||
return print_help();
|
||||
wasm_runtime_set_max_thread_num(atoi(argv[0] + 14));
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
else if (!strncmp(argv[0], "-g=", 3)) {
|
||||
char * port_str = strchr(argv[0] + 3, ':');
|
||||
char *port_end;
|
||||
if (port_str == NULL)
|
||||
return print_help();
|
||||
*port_str = '\0';
|
||||
instance_port = strtoul(port_str + 1, &port_end, 10);
|
||||
if (port_str[1] == '\0' || *port_end != '\0')
|
||||
return print_help();
|
||||
ip_addr = argv[0] + 3;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
return print_help();
|
||||
@ -346,6 +367,13 @@ main(int argc, char *argv[])
|
||||
init_args.mem_alloc_option.allocator.free_func = free;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
init_args.platform_port = 0;
|
||||
init_args.instance_port = instance_port;
|
||||
if (ip_addr)
|
||||
strcpy(init_args.ip_addr, ip_addr);
|
||||
#endif
|
||||
|
||||
/* initialize runtime environment */
|
||||
if (!wasm_runtime_full_init(&init_args)) {
|
||||
printf("Init runtime environment failed.\n");
|
||||
|
||||
@ -59,6 +59,17 @@ if (NOT DEFINED WAMR_BUILD_LIBC_WASI)
|
||||
set (WAMR_BUILD_LIBC_WASI 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP)
|
||||
# Disable Debug feature by default
|
||||
set (WAMR_BUILD_DEBUG_INTERP 0)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
|
||||
set (WAMR_BUILD_FAST_INTERP 0)
|
||||
set (WAMR_BUILD_MINI_LOADER 0)
|
||||
set (WAMR_BUILD_SIMD 0)
|
||||
endif ()
|
||||
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
|
||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
||||
|
||||
Reference in New Issue
Block a user