mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-10-11 03:24:08 +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 { \
|
||||
*(void**)addr = (void*)ptr; \
|
||||
} while (0)
|
||||
#define LOAD_PTR(addr) (*(void**)(addr))
|
||||
|
||||
#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
|
||||
&& type1->result_count == type2->result_count
|
||||
&& memcmp(type1->types, type2->types,
|
||||
(uint32)(type1->param_count
|
||||
+ type1->result_count)) == 0)
|
||||
? true : false;
|
||||
(uint32)(type1->param_count + type1->result_count))
|
||||
== 0)
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
inline static uint32
|
||||
|
@ -566,8 +567,7 @@ wasm_get_smallest_type_idx(WASMType **types, uint32 type_count,
|
|||
}
|
||||
|
||||
static inline uint32
|
||||
block_type_get_param_types(BlockType *block_type,
|
||||
uint8 **p_param_types)
|
||||
block_type_get_param_types(BlockType *block_type, uint8 **p_param_types)
|
||||
{
|
||||
uint32 param_count = 0;
|
||||
if (!block_type->is_value_type) {
|
||||
|
@ -584,8 +584,7 @@ block_type_get_param_types(BlockType *block_type,
|
|||
}
|
||||
|
||||
static inline uint32
|
||||
block_type_get_result_types(BlockType *block_type,
|
||||
uint8 **p_result_types)
|
||||
block_type_get_result_types(BlockType *block_type, uint8 **p_result_types)
|
||||
{
|
||||
uint32 result_count = 0;
|
||||
if (block_type->is_value_type) {
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef struct WASMInterpFrame {
|
|||
#endif
|
||||
|
||||
#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 */
|
||||
uint32 ret_offset;
|
||||
uint32 *lp;
|
||||
|
@ -68,15 +68,15 @@ typedef struct WASMInterpFrame {
|
|||
static inline unsigned
|
||||
wasm_interp_interp_frame_size(unsigned all_cell_num)
|
||||
{
|
||||
return align_uint((uint32)offsetof(WASMInterpFrame, lp)
|
||||
+ all_cell_num * 5, 4);
|
||||
return align_uint((uint32)offsetof(WASMInterpFrame, lp) + all_cell_num * 5,
|
||||
4);
|
||||
}
|
||||
|
||||
void
|
||||
wasm_interp_call_wasm(struct WASMModuleInstance *module_inst,
|
||||
struct WASMExecEnv *exec_env,
|
||||
struct WASMFunctionInstance *function,
|
||||
uint32 argc, uint32 argv[]);
|
||||
struct WASMFunctionInstance *function, uint32 argc,
|
||||
uint32 argv[]);
|
||||
|
||||
#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
|
||||
*/
|
||||
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.
|
||||
|
@ -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
|
||||
*/
|
||||
WASMModule *
|
||||
wasm_loader_load_from_sections(WASMSection *section_list,
|
||||
char *error_buf, uint32 error_buf_size);
|
||||
wasm_loader_load_from_sections(WASMSection *section_list, char *error_buf,
|
||||
uint32 error_buf_size);
|
||||
|
||||
/**
|
||||
* Unload a WASM module.
|
||||
|
@ -64,12 +65,9 @@ wasm_loader_unload(WASMModule *module);
|
|||
*/
|
||||
|
||||
bool
|
||||
wasm_loader_find_block_addr(WASMExecEnv *exec_env,
|
||||
BlockAddr *block_addr_cache,
|
||||
const uint8 *start_addr,
|
||||
const uint8 *code_end_addr,
|
||||
uint8 block_type,
|
||||
uint8 **p_else_addr,
|
||||
wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
||||
const uint8 *start_addr, const uint8 *code_end_addr,
|
||||
uint8 block_type, uint8 **p_else_addr,
|
||||
uint8 **p_end_addr);
|
||||
|
||||
#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,
|
||||
} WASMAtomicEXTOpcode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
#define DEF_DEBUG_BREAK_HANDLE(_name) \
|
||||
_name[DEBUG_OP_BREAK] = \
|
||||
HANDLE_OPCODE (DEBUG_OP_BREAK); /* 0xd6 */
|
||||
_name[DEBUG_OP_BREAK] = HANDLE_OPCODE(DEBUG_OP_BREAK); /* 0xd6 */
|
||||
#else
|
||||
#define DEF_DEBUG_BREAK_HANDLE(_name)
|
||||
#endif
|
||||
|
@ -914,5 +909,9 @@ do { \
|
|||
HANDLE_OPCODE(WASM_OP_ATOMIC_PREFIX); /* 0xfe */ \
|
||||
DEF_DEBUG_BREAK_HANDLE(_name) \
|
||||
} 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)
|
||||
{
|
||||
#if WASM_ENABLE_FAST_INTERP == 0
|
||||
return func->is_import_func
|
||||
? NULL : func->u.func->code + func->u.func->code_size;
|
||||
return func->is_import_func ? NULL
|
||||
: func->u.func->code + func->u.func->code_size;
|
||||
#else
|
||||
return func->is_import_func
|
||||
? NULL
|
||||
|
@ -278,20 +278,19 @@ wasm_get_func_code_end(WASMFunctionInstance *func)
|
|||
}
|
||||
|
||||
WASMModule *
|
||||
wasm_load(const uint8 *buf, uint32 size,
|
||||
char *error_buf, uint32 error_buf_size);
|
||||
wasm_load(const uint8 *buf, uint32 size, char *error_buf,
|
||||
uint32 error_buf_size);
|
||||
|
||||
WASMModule *
|
||||
wasm_load_from_sections(WASMSection *section_list,
|
||||
char *error_buf, uint32_t error_buf_size);
|
||||
wasm_load_from_sections(WASMSection *section_list, char *error_buf,
|
||||
uint32_t error_buf_size);
|
||||
|
||||
void
|
||||
wasm_unload(WASMModule *module);
|
||||
|
||||
WASMModuleInstance *
|
||||
wasm_instantiate(WASMModule *module, bool is_sub_inst,
|
||||
uint32 stack_size, uint32 heap_size,
|
||||
char *error_buf, uint32 error_buf_size);
|
||||
wasm_instantiate(WASMModule *module, bool is_sub_inst, uint32 stack_size,
|
||||
uint32 heap_size, char *error_buf, uint32 error_buf_size);
|
||||
|
||||
void
|
||||
wasm_dump_perf_profiling(const WASMModuleInstance *module_inst);
|
||||
|
@ -300,8 +299,8 @@ void
|
|||
wasm_deinstantiate(WASMModuleInstance *module_inst, bool is_sub_inst);
|
||||
|
||||
WASMFunctionInstance *
|
||||
wasm_lookup_function(const WASMModuleInstance *module_inst,
|
||||
const char *name, const char *signature);
|
||||
wasm_lookup_function(const WASMModuleInstance *module_inst, const char *name,
|
||||
const char *signature);
|
||||
|
||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||
WASMGlobalInstance *
|
||||
|
@ -315,8 +314,7 @@ wasm_lookup_table(const WASMModuleInstance *module_inst, const char *name);
|
|||
#endif
|
||||
|
||||
bool
|
||||
wasm_call_function(WASMExecEnv *exec_env,
|
||||
WASMFunctionInstance *function,
|
||||
wasm_call_function(WASMExecEnv *exec_env, WASMFunctionInstance *function,
|
||||
unsigned argc, uint32 argv[]);
|
||||
|
||||
bool
|
||||
|
@ -345,38 +343,32 @@ void
|
|||
wasm_module_free(WASMModuleInstance *module_inst, uint32 ptr);
|
||||
|
||||
uint32
|
||||
wasm_module_dup_data(WASMModuleInstance *module_inst,
|
||||
const char *src, uint32 size);
|
||||
wasm_module_dup_data(WASMModuleInstance *module_inst, const char *src,
|
||||
uint32 size);
|
||||
|
||||
bool
|
||||
wasm_validate_app_addr(WASMModuleInstance *module_inst,
|
||||
uint32 app_offset, uint32 size);
|
||||
wasm_validate_app_addr(WASMModuleInstance *module_inst, uint32 app_offset,
|
||||
uint32 size);
|
||||
|
||||
bool
|
||||
wasm_validate_app_str_addr(WASMModuleInstance *module_inst,
|
||||
uint32 app_offset);
|
||||
wasm_validate_app_str_addr(WASMModuleInstance *module_inst, uint32 app_offset);
|
||||
|
||||
bool
|
||||
wasm_validate_native_addr(WASMModuleInstance *module_inst,
|
||||
void *native_ptr, uint32 size);
|
||||
wasm_validate_native_addr(WASMModuleInstance *module_inst, void *native_ptr,
|
||||
uint32 size);
|
||||
|
||||
void *
|
||||
wasm_addr_app_to_native(WASMModuleInstance *module_inst,
|
||||
uint32 app_offset);
|
||||
wasm_addr_app_to_native(WASMModuleInstance *module_inst, uint32 app_offset);
|
||||
|
||||
uint32
|
||||
wasm_addr_native_to_app(WASMModuleInstance *module_inst,
|
||||
void *native_ptr);
|
||||
wasm_addr_native_to_app(WASMModuleInstance *module_inst, void *native_ptr);
|
||||
|
||||
bool
|
||||
wasm_get_app_addr_range(WASMModuleInstance *module_inst,
|
||||
uint32 app_offset,
|
||||
uint32 *p_app_start_offset,
|
||||
uint32 *p_app_end_offset);
|
||||
wasm_get_app_addr_range(WASMModuleInstance *module_inst, uint32 app_offset,
|
||||
uint32 *p_app_start_offset, uint32 *p_app_end_offset);
|
||||
|
||||
bool
|
||||
wasm_get_native_addr_range(WASMModuleInstance *module_inst,
|
||||
uint8_t *native_ptr,
|
||||
wasm_get_native_addr_range(WASMModuleInstance *module_inst, uint8_t *native_ptr,
|
||||
uint8_t **p_native_start_addr,
|
||||
uint8_t **p_native_end_addr);
|
||||
|
||||
|
@ -384,19 +376,15 @@ bool
|
|||
wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count);
|
||||
|
||||
bool
|
||||
wasm_call_indirect(WASMExecEnv *exec_env,
|
||||
uint32_t tbl_idx,
|
||||
uint32_t element_indices,
|
||||
uint32_t argc, uint32_t argv[]);
|
||||
wasm_call_indirect(WASMExecEnv *exec_env, uint32_t tbl_idx,
|
||||
uint32_t element_indices, uint32_t argc, uint32_t argv[]);
|
||||
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
bool
|
||||
wasm_set_aux_stack(WASMExecEnv *exec_env,
|
||||
uint32 start_offset, uint32 size);
|
||||
wasm_set_aux_stack(WASMExecEnv *exec_env, uint32 start_offset, uint32 size);
|
||||
|
||||
bool
|
||||
wasm_get_aux_stack(WASMExecEnv *exec_env,
|
||||
uint32 *start_offset, uint32 *size);
|
||||
wasm_get_aux_stack(WASMExecEnv *exec_env, uint32 *start_offset, uint32 *size);
|
||||
#endif
|
||||
|
||||
void
|
||||
|
@ -427,13 +415,12 @@ wasm_elem_is_declarative(uint32 mode)
|
|||
}
|
||||
|
||||
bool
|
||||
wasm_enlarge_table(WASMModuleInstance *module_inst,
|
||||
uint32 table_idx, uint32 inc_entries, uint32 init_val);
|
||||
wasm_enlarge_table(WASMModuleInstance *module_inst, uint32 table_idx,
|
||||
uint32 inc_entries, uint32 init_val);
|
||||
#endif /* WASM_ENABLE_REF_TYPES != 0 */
|
||||
|
||||
static inline WASMTableInstance *
|
||||
wasm_get_table_inst(const WASMModuleInstance *module_inst,
|
||||
const uint32 tbl_idx)
|
||||
wasm_get_table_inst(const WASMModuleInstance *module_inst, const uint32 tbl_idx)
|
||||
{
|
||||
/* careful, it might be a table in another module */
|
||||
WASMTableInstance *tbl_inst = module_inst->tables[tbl_idx];
|
||||
|
|
|
@ -14,8 +14,12 @@ llvm-dwarfdump-12 test.wasm
|
|||
```
|
||||
|
||||
## 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
|
||||
cd ${WAMR_ROOT}/product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
|
@ -23,21 +27,21 @@ cmake .. -DWAMR_BUILD_DEBUG_INTERP=1
|
|||
make
|
||||
```
|
||||
|
||||
2. Execute iwasm with debug engine enabled
|
||||
3. Execute iwasm with debug engine enabled
|
||||
``` bash
|
||||
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
|
||||
cd ${WAMR_ROOT}/core/deps/llvm
|
||||
git apply ../../../../build-scripts/lldb-wasm.patch
|
||||
mkdir build && cd build
|
||||
cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang,lldb" -DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly"
|
||||
git apply ../../../build-scripts/lldb-wasm.patch
|
||||
mkdir build_lldb && cd build_lldb
|
||||
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)
|
||||
```
|
||||
|
||||
4. Launch customized lldb and connect to iwasm
|
||||
5. Launch customized lldb and connect to iwasm
|
||||
``` bash
|
||||
lldb
|
||||
(lldb) process connect -p wasm connect://127.0.0.1:1234
|
||||
|
|
Loading…
Reference in New Issue
Block a user