mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-11-28 18:41:06 +00:00
Apply clang-format for interpreter source files (#772)
And update source debugging document.
This commit is contained in:
parent
8d9bf18ac3
commit
6415e1b006
|
|
@ -57,7 +57,6 @@ extern "C" {
|
||||||
#define STORE_PTR(addr, ptr) do { \
|
#define STORE_PTR(addr, ptr) do { \
|
||||||
*(void**)addr = (void*)ptr; \
|
*(void**)addr = (void*)ptr; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define LOAD_PTR(addr) (*(void**)(addr))
|
|
||||||
|
|
||||||
#else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
|
#else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -547,9 +547,10 @@ wasm_type_equal(const WASMType *type1, const WASMType *type2)
|
||||||
return (type1->param_count == type2->param_count
|
return (type1->param_count == type2->param_count
|
||||||
&& type1->result_count == type2->result_count
|
&& type1->result_count == type2->result_count
|
||||||
&& memcmp(type1->types, type2->types,
|
&& memcmp(type1->types, type2->types,
|
||||||
(uint32)(type1->param_count
|
(uint32)(type1->param_count + type1->result_count))
|
||||||
+ type1->result_count)) == 0)
|
== 0)
|
||||||
? true : false;
|
? true
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static uint32
|
inline static uint32
|
||||||
|
|
@ -566,8 +567,7 @@ wasm_get_smallest_type_idx(WASMType **types, uint32 type_count,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32
|
static inline uint32
|
||||||
block_type_get_param_types(BlockType *block_type,
|
block_type_get_param_types(BlockType *block_type, uint8 **p_param_types)
|
||||||
uint8 **p_param_types)
|
|
||||||
{
|
{
|
||||||
uint32 param_count = 0;
|
uint32 param_count = 0;
|
||||||
if (!block_type->is_value_type) {
|
if (!block_type->is_value_type) {
|
||||||
|
|
@ -584,8 +584,7 @@ block_type_get_param_types(BlockType *block_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32
|
static inline uint32
|
||||||
block_type_get_result_types(BlockType *block_type,
|
block_type_get_result_types(BlockType *block_type, uint8 **p_result_types)
|
||||||
uint8 **p_result_types)
|
|
||||||
{
|
{
|
||||||
uint32 result_count = 0;
|
uint32 result_count = 0;
|
||||||
if (block_type->is_value_type) {
|
if (block_type->is_value_type) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ typedef struct WASMInterpFrame {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WASM_ENABLE_FAST_INTERP != 0
|
#if WASM_ENABLE_FAST_INTERP != 0
|
||||||
/* return offset of the first return value of current frame.
|
/* Return offset of the first return value of current frame,
|
||||||
the callee will put return values here continuously */
|
the callee will put return values here continuously */
|
||||||
uint32 ret_offset;
|
uint32 ret_offset;
|
||||||
uint32 *lp;
|
uint32 *lp;
|
||||||
|
|
@ -68,15 +68,15 @@ typedef struct WASMInterpFrame {
|
||||||
static inline unsigned
|
static inline unsigned
|
||||||
wasm_interp_interp_frame_size(unsigned all_cell_num)
|
wasm_interp_interp_frame_size(unsigned all_cell_num)
|
||||||
{
|
{
|
||||||
return align_uint((uint32)offsetof(WASMInterpFrame, lp)
|
return align_uint((uint32)offsetof(WASMInterpFrame, lp) + all_cell_num * 5,
|
||||||
+ all_cell_num * 5, 4);
|
4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wasm_interp_call_wasm(struct WASMModuleInstance *module_inst,
|
wasm_interp_call_wasm(struct WASMModuleInstance *module_inst,
|
||||||
struct WASMExecEnv *exec_env,
|
struct WASMExecEnv *exec_env,
|
||||||
struct WASMFunctionInstance *function,
|
struct WASMFunctionInstance *function, uint32 argc,
|
||||||
uint32 argc, uint32 argv[]);
|
uint32 argv[]);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -24,7 +24,8 @@ extern "C" {
|
||||||
* @return return module loaded, NULL if failed
|
* @return return module loaded, NULL if failed
|
||||||
*/
|
*/
|
||||||
WASMModule *
|
WASMModule *
|
||||||
wasm_loader_load(const uint8 *buf, uint32 size, char *error_buf, uint32 error_buf_size);
|
wasm_loader_load(const uint8 *buf, uint32 size, char *error_buf,
|
||||||
|
uint32 error_buf_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a WASM module from a specified WASM section list.
|
* Load a WASM module from a specified WASM section list.
|
||||||
|
|
@ -36,8 +37,8 @@ wasm_loader_load(const uint8 *buf, uint32 size, char *error_buf, uint32 error_bu
|
||||||
* @return return WASM module loaded, NULL if failed
|
* @return return WASM module loaded, NULL if failed
|
||||||
*/
|
*/
|
||||||
WASMModule *
|
WASMModule *
|
||||||
wasm_loader_load_from_sections(WASMSection *section_list,
|
wasm_loader_load_from_sections(WASMSection *section_list, char *error_buf,
|
||||||
char *error_buf, uint32 error_buf_size);
|
uint32 error_buf_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unload a WASM module.
|
* Unload a WASM module.
|
||||||
|
|
@ -64,12 +65,9 @@ wasm_loader_unload(WASMModule *module);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_loader_find_block_addr(WASMExecEnv *exec_env,
|
wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
||||||
BlockAddr *block_addr_cache,
|
const uint8 *start_addr, const uint8 *code_end_addr,
|
||||||
const uint8 *start_addr,
|
uint8 block_type, uint8 **p_else_addr,
|
||||||
const uint8 *code_end_addr,
|
|
||||||
uint8 block_type,
|
|
||||||
uint8 **p_else_addr,
|
|
||||||
uint8 **p_end_addr);
|
uint8 **p_end_addr);
|
||||||
|
|
||||||
#if WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_REF_TYPES != 0
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -673,14 +673,9 @@ typedef enum WASMAtomicEXTOpcode {
|
||||||
WASM_OP_ATOMIC_RMW_I64_CMPXCHG32_U = 0x4e,
|
WASM_OP_ATOMIC_RMW_I64_CMPXCHG32_U = 0x4e,
|
||||||
} WASMAtomicEXTOpcode;
|
} WASMAtomicEXTOpcode;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||||
#define DEF_DEBUG_BREAK_HANDLE(_name) \
|
#define DEF_DEBUG_BREAK_HANDLE(_name) \
|
||||||
_name[DEBUG_OP_BREAK] = \
|
_name[DEBUG_OP_BREAK] = HANDLE_OPCODE(DEBUG_OP_BREAK); /* 0xd6 */
|
||||||
HANDLE_OPCODE (DEBUG_OP_BREAK); /* 0xd6 */
|
|
||||||
#else
|
#else
|
||||||
#define DEF_DEBUG_BREAK_HANDLE(_name)
|
#define DEF_DEBUG_BREAK_HANDLE(_name)
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -914,5 +909,9 @@ do { \
|
||||||
HANDLE_OPCODE(WASM_OP_ATOMIC_PREFIX); /* 0xfe */ \
|
HANDLE_OPCODE(WASM_OP_ATOMIC_PREFIX); /* 0xfe */ \
|
||||||
DEF_DEBUG_BREAK_HANDLE(_name) \
|
DEF_DEBUG_BREAK_HANDLE(_name) \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif /* end of _WASM_OPCODE_H */
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* end of _WASM_OPCODE_H */
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -268,8 +268,8 @@ static inline uint8*
|
||||||
wasm_get_func_code_end(WASMFunctionInstance *func)
|
wasm_get_func_code_end(WASMFunctionInstance *func)
|
||||||
{
|
{
|
||||||
#if WASM_ENABLE_FAST_INTERP == 0
|
#if WASM_ENABLE_FAST_INTERP == 0
|
||||||
return func->is_import_func
|
return func->is_import_func ? NULL
|
||||||
? NULL : func->u.func->code + func->u.func->code_size;
|
: func->u.func->code + func->u.func->code_size;
|
||||||
#else
|
#else
|
||||||
return func->is_import_func
|
return func->is_import_func
|
||||||
? NULL
|
? NULL
|
||||||
|
|
@ -278,20 +278,19 @@ wasm_get_func_code_end(WASMFunctionInstance *func)
|
||||||
}
|
}
|
||||||
|
|
||||||
WASMModule *
|
WASMModule *
|
||||||
wasm_load(const uint8 *buf, uint32 size,
|
wasm_load(const uint8 *buf, uint32 size, char *error_buf,
|
||||||
char *error_buf, uint32 error_buf_size);
|
uint32 error_buf_size);
|
||||||
|
|
||||||
WASMModule *
|
WASMModule *
|
||||||
wasm_load_from_sections(WASMSection *section_list,
|
wasm_load_from_sections(WASMSection *section_list, char *error_buf,
|
||||||
char *error_buf, uint32_t error_buf_size);
|
uint32_t error_buf_size);
|
||||||
|
|
||||||
void
|
void
|
||||||
wasm_unload(WASMModule *module);
|
wasm_unload(WASMModule *module);
|
||||||
|
|
||||||
WASMModuleInstance *
|
WASMModuleInstance *
|
||||||
wasm_instantiate(WASMModule *module, bool is_sub_inst,
|
wasm_instantiate(WASMModule *module, bool is_sub_inst, uint32 stack_size,
|
||||||
uint32 stack_size, uint32 heap_size,
|
uint32 heap_size, char *error_buf, uint32 error_buf_size);
|
||||||
char *error_buf, uint32 error_buf_size);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wasm_dump_perf_profiling(const WASMModuleInstance *module_inst);
|
wasm_dump_perf_profiling(const WASMModuleInstance *module_inst);
|
||||||
|
|
@ -300,8 +299,8 @@ void
|
||||||
wasm_deinstantiate(WASMModuleInstance *module_inst, bool is_sub_inst);
|
wasm_deinstantiate(WASMModuleInstance *module_inst, bool is_sub_inst);
|
||||||
|
|
||||||
WASMFunctionInstance *
|
WASMFunctionInstance *
|
||||||
wasm_lookup_function(const WASMModuleInstance *module_inst,
|
wasm_lookup_function(const WASMModuleInstance *module_inst, const char *name,
|
||||||
const char *name, const char *signature);
|
const char *signature);
|
||||||
|
|
||||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||||
WASMGlobalInstance *
|
WASMGlobalInstance *
|
||||||
|
|
@ -315,8 +314,7 @@ wasm_lookup_table(const WASMModuleInstance *module_inst, const char *name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_call_function(WASMExecEnv *exec_env,
|
wasm_call_function(WASMExecEnv *exec_env, WASMFunctionInstance *function,
|
||||||
WASMFunctionInstance *function,
|
|
||||||
unsigned argc, uint32 argv[]);
|
unsigned argc, uint32 argv[]);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -345,38 +343,32 @@ void
|
||||||
wasm_module_free(WASMModuleInstance *module_inst, uint32 ptr);
|
wasm_module_free(WASMModuleInstance *module_inst, uint32 ptr);
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
wasm_module_dup_data(WASMModuleInstance *module_inst,
|
wasm_module_dup_data(WASMModuleInstance *module_inst, const char *src,
|
||||||
const char *src, uint32 size);
|
uint32 size);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_validate_app_addr(WASMModuleInstance *module_inst,
|
wasm_validate_app_addr(WASMModuleInstance *module_inst, uint32 app_offset,
|
||||||
uint32 app_offset, uint32 size);
|
uint32 size);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_validate_app_str_addr(WASMModuleInstance *module_inst,
|
wasm_validate_app_str_addr(WASMModuleInstance *module_inst, uint32 app_offset);
|
||||||
uint32 app_offset);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_validate_native_addr(WASMModuleInstance *module_inst,
|
wasm_validate_native_addr(WASMModuleInstance *module_inst, void *native_ptr,
|
||||||
void *native_ptr, uint32 size);
|
uint32 size);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
wasm_addr_app_to_native(WASMModuleInstance *module_inst,
|
wasm_addr_app_to_native(WASMModuleInstance *module_inst, uint32 app_offset);
|
||||||
uint32 app_offset);
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
wasm_addr_native_to_app(WASMModuleInstance *module_inst,
|
wasm_addr_native_to_app(WASMModuleInstance *module_inst, void *native_ptr);
|
||||||
void *native_ptr);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_get_app_addr_range(WASMModuleInstance *module_inst,
|
wasm_get_app_addr_range(WASMModuleInstance *module_inst, uint32 app_offset,
|
||||||
uint32 app_offset,
|
uint32 *p_app_start_offset, uint32 *p_app_end_offset);
|
||||||
uint32 *p_app_start_offset,
|
|
||||||
uint32 *p_app_end_offset);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_get_native_addr_range(WASMModuleInstance *module_inst,
|
wasm_get_native_addr_range(WASMModuleInstance *module_inst, uint8_t *native_ptr,
|
||||||
uint8_t *native_ptr,
|
|
||||||
uint8_t **p_native_start_addr,
|
uint8_t **p_native_start_addr,
|
||||||
uint8_t **p_native_end_addr);
|
uint8_t **p_native_end_addr);
|
||||||
|
|
||||||
|
|
@ -384,19 +376,15 @@ bool
|
||||||
wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count);
|
wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_call_indirect(WASMExecEnv *exec_env,
|
wasm_call_indirect(WASMExecEnv *exec_env, uint32_t tbl_idx,
|
||||||
uint32_t tbl_idx,
|
uint32_t element_indices, uint32_t argc, uint32_t argv[]);
|
||||||
uint32_t element_indices,
|
|
||||||
uint32_t argc, uint32_t argv[]);
|
|
||||||
|
|
||||||
#if WASM_ENABLE_THREAD_MGR != 0
|
#if WASM_ENABLE_THREAD_MGR != 0
|
||||||
bool
|
bool
|
||||||
wasm_set_aux_stack(WASMExecEnv *exec_env,
|
wasm_set_aux_stack(WASMExecEnv *exec_env, uint32 start_offset, uint32 size);
|
||||||
uint32 start_offset, uint32 size);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_get_aux_stack(WASMExecEnv *exec_env,
|
wasm_get_aux_stack(WASMExecEnv *exec_env, uint32 *start_offset, uint32 *size);
|
||||||
uint32 *start_offset, uint32 *size);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -427,13 +415,12 @@ wasm_elem_is_declarative(uint32 mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_enlarge_table(WASMModuleInstance *module_inst,
|
wasm_enlarge_table(WASMModuleInstance *module_inst, uint32 table_idx,
|
||||||
uint32 table_idx, uint32 inc_entries, uint32 init_val);
|
uint32 inc_entries, uint32 init_val);
|
||||||
#endif /* WASM_ENABLE_REF_TYPES != 0 */
|
#endif /* WASM_ENABLE_REF_TYPES != 0 */
|
||||||
|
|
||||||
static inline WASMTableInstance *
|
static inline WASMTableInstance *
|
||||||
wasm_get_table_inst(const WASMModuleInstance *module_inst,
|
wasm_get_table_inst(const WASMModuleInstance *module_inst, const uint32 tbl_idx)
|
||||||
const uint32 tbl_idx)
|
|
||||||
{
|
{
|
||||||
/* careful, it might be a table in another module */
|
/* careful, it might be a table in another module */
|
||||||
WASMTableInstance *tbl_inst = module_inst->tables[tbl_idx];
|
WASMTableInstance *tbl_inst = module_inst->tables[tbl_idx];
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,12 @@ llvm-dwarfdump-12 test.wasm
|
||||||
```
|
```
|
||||||
|
|
||||||
## Debugging with interpreter
|
## Debugging with interpreter
|
||||||
|
1. Install dependent libraries
|
||||||
|
``` bash
|
||||||
|
apt update && apt install cmake make g++ libxml2-dev -y
|
||||||
|
```
|
||||||
|
|
||||||
1. Build iwasm with source debugging feature
|
2. Build iwasm with source debugging feature
|
||||||
``` bash
|
``` bash
|
||||||
cd ${WAMR_ROOT}/product-mini/platforms/linux
|
cd ${WAMR_ROOT}/product-mini/platforms/linux
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
|
|
@ -23,21 +27,21 @@ cmake .. -DWAMR_BUILD_DEBUG_INTERP=1
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Execute iwasm with debug engine enabled
|
3. Execute iwasm with debug engine enabled
|
||||||
``` bash
|
``` bash
|
||||||
iwasm -g=127.0.0.1:1234 test.wasm
|
iwasm -g=127.0.0.1:1234 test.wasm
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Build customized lldb (assume you have already built llvm)
|
4. Build customized lldb (assume you have already cloned llvm)
|
||||||
``` bash
|
``` bash
|
||||||
cd ${WAMR_ROOT}/core/deps/llvm
|
cd ${WAMR_ROOT}/core/deps/llvm
|
||||||
git apply ../../../../build-scripts/lldb-wasm.patch
|
git apply ../../../build-scripts/lldb-wasm.patch
|
||||||
mkdir build && cd build
|
mkdir build_lldb && cd build_lldb
|
||||||
cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang,lldb" -DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly"
|
cmake -DCMAKE_BUILD_TYPE:STRING="Release" -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" -DLLVM_ENABLE_LIBXML2:BOOL=ON ../llvm
|
||||||
make -j $(nproc)
|
make -j $(nproc)
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Launch customized lldb and connect to iwasm
|
5. Launch customized lldb and connect to iwasm
|
||||||
``` bash
|
``` bash
|
||||||
lldb
|
lldb
|
||||||
(lldb) process connect -p wasm connect://127.0.0.1:1234
|
(lldb) process connect -p wasm connect://127.0.0.1:1234
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user