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:
@ -14,6 +14,10 @@
|
||||
#include "../compilation/aot_llvm.h"
|
||||
#include "../interpreter/wasm_loader.h"
|
||||
#endif
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
#include "debug/elf_parser.h"
|
||||
#include "debug/jit_debug.h"
|
||||
#endif
|
||||
|
||||
#define XMM_PLT_PREFIX "__xmm@"
|
||||
#define REAL_PLT_PREFIX "__real@"
|
||||
@ -1231,7 +1235,6 @@ load_init_data_section(const uint8 *buf, const uint8 *buf_end,
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
@ -1257,12 +1260,30 @@ load_text_section(const uint8 *buf, const uint8 *buf_end,
|
||||
module->code = (void*)(buf + module->literal_size);
|
||||
module->code_size = (uint32)(buf_end - (uint8*)module->code);
|
||||
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
module->elf_size = module->code_size;
|
||||
|
||||
if (is_ELF(module->code)) {
|
||||
/* Now code points to an ELF object, we pull it down to .text section */
|
||||
uint64 offset;
|
||||
uint64 size;
|
||||
char *buf = module->code;
|
||||
module->elf_hdr = buf;
|
||||
if (!get_text_section(buf, &offset, &size)) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"get text section of ELF failed");
|
||||
return false;
|
||||
}
|
||||
module->code = buf + offset;
|
||||
module->code_size -= (uint32)offset;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((module->code_size > 0) && (module->native_symbol_count == 0)) {
|
||||
plt_base = (uint8 *)buf_end - get_plt_table_size();
|
||||
init_plt_table(plt_base);
|
||||
}
|
||||
return true;
|
||||
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
@ -1451,7 +1472,6 @@ load_export_section(const uint8 *buf, const uint8 *buf_end,
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
@ -2247,6 +2267,13 @@ load_from_sections(AOTModule *module, AOTSection *sections,
|
||||
#if WASM_ENABLE_MEMORY_TRACING != 0
|
||||
wasm_runtime_dump_module_mem_consumption((WASMModuleCommon*)module);
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
if (!jit_code_entry_create(module->elf_hdr, module->elf_size)) {
|
||||
set_error_buf(error_buf, error_buf_size, "create jit code entry failed");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2893,6 +2920,9 @@ aot_unload(AOTModule *module)
|
||||
if (module->data_sections)
|
||||
destroy_object_data_sections(module->data_sections,
|
||||
module->data_section_count);
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
jit_code_entry_destroy(module->elf_hdr);
|
||||
#endif
|
||||
|
||||
wasm_runtime_free(module);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user