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:
@ -109,6 +109,9 @@ message ("-- CMAKE_BUILD_TYPE = " ${CMAKE_BUILD_TYPE})
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_definitions(-DBH_DEBUG=1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
|
||||
add_definitions(-DWASM_ENABLE_DEBUG_AOT=1)
|
||||
endif()
|
||||
|
||||
# Enable LLVM
|
||||
if (NOT WAMR_BUILD_WITH_CUSTOM_LLVM)
|
||||
@ -133,6 +136,16 @@ add_definitions(${LLVM_DEFINITIONS})
|
||||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
||||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
||||
|
||||
if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
|
||||
if(LLVM_BUILD_MAIN_SRC_DIR)
|
||||
include_directories(${LLVM_BUILD_MAIN_SRC_DIR}/../lldb/include)
|
||||
include_directories(${LLVM_BUILD_BINARY_DIR}/tools/lldb/include)
|
||||
endif()
|
||||
link_directories(${LLVM_LIBRARY_DIRS})
|
||||
find_library(lib_lldb NAMES lldb HINTS ${LLVM_LIBRARY_DIRS})
|
||||
message(STATUS "find lldb ${LLDB_ALL_PLUGINS} in: ${LLVM_LIBRARY_DIRS}")
|
||||
endif()
|
||||
|
||||
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||
if(NOT MSVC)
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
@ -212,7 +225,7 @@ add_library (aotclib ${IWASM_COMPL_SOURCE})
|
||||
add_executable (wamrc main.c)
|
||||
|
||||
if (NOT MSVC)
|
||||
target_link_libraries (wamrc aotclib vmlib LLVMDemangle ${LLVM_AVAILABLE_LIBS} -lm -ldl -lpthread)
|
||||
target_link_libraries (wamrc aotclib vmlib LLVMDemangle ${LLVM_AVAILABLE_LIBS} -lm -ldl -lpthread ${lib_lldb})
|
||||
else()
|
||||
target_link_libraries (wamrc aotclib vmlib ${LLVM_AVAILABLE_LIBS})
|
||||
target_link_libraries (wamrc aotclib vmlib ${lib_lldb} ${LLVM_AVAILABLE_LIBS})
|
||||
endif()
|
||||
|
||||
@ -248,6 +248,12 @@ main(int argc, char *argv[])
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
if (!create_dwarf_extractor(comp_data, wasm_file_name)) {
|
||||
printf("%s:create dwarf extractor failed\n", wasm_file_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
bh_print_time("Begin to create compile context");
|
||||
|
||||
if (!(comp_ctx = aot_create_comp_context(comp_data,
|
||||
|
||||
Reference in New Issue
Block a user