Skip to content

Commit e414a32

Browse files
authored
Refactor copy callstack feature (#4401)
- Change `WAMR_ENABLE_COPY_CALLSTACK` to `WAMR_BUILD_COPY_CALL_STACK`, as `WAMR_BUILD` is the prefix for a command line option. - Change `WAMR_ENABLE_COPY_CALLSTACK` to `WASM_ENABLE_COPY_CALL_STACK`, as `WASM_ENABLE` is the prefix for a macro in the source code. - Change `CALLSTACK` to `CALL_STACK` to align with the existing `DUMP_CALL_STACK` feature. - Continue using `WASMCApiFrame` instead of `wasm_frame_t` outside of *wasm_c_api.xxx* to avoid a typedef redefinition warning, which is identified by Clang.
1 parent 8289452 commit e414a32

File tree

10 files changed

+27
-34
lines changed

10 files changed

+27
-34
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS)
9999
set (WAMR_BUILD_LIB_WASI_THREADS 0)
100100
endif ()
101101

102-
if (NOT DEFINED WAMR_ENABLE_COPY_CALLSTACK)
102+
if (NOT DEFINED WAMR_BUILD_COPY_CALL_STACK)
103103
# Disable copy callstack by default
104-
set (WAMR_ENABLE_COPY_CALLSTACK 0)
104+
set (WAMR_BUILD_COPY_CALL_STACK 0)
105105
endif()
106106

107107
if (NOT DEFINED WAMR_BUILD_MINI_LOADER)

build-scripts/config_common.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,10 @@ if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
334334
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
335335
message (" Shared heap enabled")
336336
endif()
337-
338-
if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1)
339-
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1)
337+
if (WAMR_BUILD_COPY_CALL_STACK EQUAL 1)
338+
add_definitions (-DWASM_ENABLE_COPY_CALL_STACK=1)
340339
message(" Copy callstack enabled")
341-
else ()
342-
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=0)
343-
message(" Copy callstack disabled")
344340
endif()
345-
346341
if (WAMR_BUILD_MEMORY64 EQUAL 1)
347342
# if native is 32-bit or cross-compiled to 32-bit
348343
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")

core/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@
193193
#error "Heap aux stack allocation must be enabled for WASI threads"
194194
#endif
195195

196-
#ifndef WAMR_ENABLE_COPY_CALLSTACK
197-
#define WAMR_ENABLE_COPY_CALLSTACK 0
196+
#ifndef WASM_ENABLE_COPY_CALL_STACK
197+
#define WASM_ENABLE_COPY_CALL_STACK 0
198198
#endif
199199

200200
#ifndef WASM_ENABLE_BASE_LIB

core/iwasm/aot/aot_runtime.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4137,9 +4137,9 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
41374137
}
41384138
#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
41394139

4140-
#if WAMR_ENABLE_COPY_CALLSTACK != 0
4140+
#if WASM_ENABLE_COPY_CALL_STACK != 0
41414141
uint32
4142-
aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
4142+
aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
41434143
const uint32 length, const uint32 skip_n,
41444144
char *error_buf, uint32 error_buf_size)
41454145
{
@@ -4193,7 +4193,7 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
41934193
}
41944194

41954195
uint32
4196-
aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
4196+
aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
41974197
const uint32 length, const uint32 skip_n,
41984198
char *error_buf, uint32_t error_buf_size)
41994199
{
@@ -4243,7 +4243,7 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
42434243
}
42444244

42454245
uint32
4246-
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
4246+
aot_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
42474247
const uint32 length, const uint32 skip_n, char *error_buf,
42484248
uint32_t error_buf_size)
42494249
{
@@ -4265,7 +4265,7 @@ aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
42654265
error_buf, error_buf_size);
42664266
}
42674267
}
4268-
#endif // WAMR_ENABLE_COPY_CALLSTACK
4268+
#endif // WASM_ENABLE_COPY_CALL_STACK
42694269

42704270
#if WASM_ENABLE_DUMP_CALL_STACK != 0
42714271
bool

core/iwasm/aot/aot_runtime.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,12 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame);
787787
bool
788788
aot_create_call_stack(struct WASMExecEnv *exec_env);
789789

790-
#if WAMR_ENABLE_COPY_CALLSTACK != 0
790+
#if WASM_ENABLE_COPY_CALL_STACK != 0
791791
uint32
792-
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
792+
aot_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
793793
const uint32 length, const uint32 skip_n, char *error_buf,
794794
uint32_t error_buf_size);
795-
#endif // WAMR_ENABLE_COPY_CALLSTACK
795+
#endif // WASM_ENABLE_COPY_CALL_STACK
796796

797797
/**
798798
* @brief Dump wasm call stack or get the size

core/iwasm/common/wasm_runtime_common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,9 +1743,9 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env)
17431743
wasm_exec_env_destroy(exec_env);
17441744
}
17451745

1746-
#if WAMR_ENABLE_COPY_CALLSTACK != 0
1746+
#if WASM_ENABLE_COPY_CALL_STACK != 0
17471747
uint32
1748-
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer,
1748+
wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer,
17491749
const uint32 length, const uint32 skip_n, char *error_buf,
17501750
uint32_t error_buf_size)
17511751
{
@@ -1780,7 +1780,7 @@ wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer,
17801780
strncpy(error_buf, err_msg, error_buf_size);
17811781
return 0;
17821782
}
1783-
#endif // WAMR_ENABLE_COPY_CALLSTACK
1783+
#endif // WASM_ENABLE_COPY_CALL_STACK
17841784

17851785
bool
17861786
wasm_runtime_init_thread_env(void)

core/iwasm/common/wasm_runtime_common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,12 +758,12 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst,
758758
WASM_RUNTIME_API_EXTERN void
759759
wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env);
760760

761-
#if WAMR_ENABLE_COPY_CALLSTACK != 0
761+
#if WASM_ENABLE_COPY_CALL_STACK != 0
762762
WASM_RUNTIME_API_EXTERN uint32_t
763-
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer,
763+
wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer,
764764
const uint32 length, const uint32 skip_n, char *error_buf,
765765
uint32 error_buf_size);
766-
#endif // WAMR_ENABLE_COPY_CALLSTACK
766+
#endif // WASM_ENABLE_COPY_CALL_STACK
767767

768768
/* See wasm_export.h for description */
769769
WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *

core/iwasm/include/wasm_export.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ typedef struct wasm_frame_t {
139139
uint32_t *lp;
140140
} WASMCApiFrame;
141141

142-
typedef WASMCApiFrame wasm_frame_t;
143-
144142
/* WASM section */
145143
typedef struct wasm_section_t {
146144
struct wasm_section_t *next;
@@ -904,7 +902,7 @@ wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env);
904902
* @return number of copied frames
905903
*/
906904
WASM_RUNTIME_API_EXTERN uint32_t
907-
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer,
905+
wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer,
908906
const uint32_t length, const uint32_t skip_n,
909907
char *error_buf, uint32_t error_buf_size);
910908

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4195,9 +4195,9 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst,
41954195
#endif /* end of (WASM_ENABLE_MEMORY_PROFILING != 0) \
41964196
|| (WASM_ENABLE_MEMORY_TRACING != 0) */
41974197

4198-
#if WAMR_ENABLE_COPY_CALLSTACK != 0
4198+
#if WASM_ENABLE_COPY_CALL_STACK != 0
41994199
uint32
4200-
wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
4200+
wasm_interp_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
42014201
uint32 length, uint32 skip_n, char *error_buf,
42024202
uint32_t error_buf_size)
42034203
{
@@ -4242,7 +4242,7 @@ wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
42424242
}
42434243
return count >= skip_n ? count - skip_n : 0;
42444244
}
4245-
#endif // WAMR_ENABLE_COPY_CALLSTACK
4245+
#endif // WASM_ENABLE_COPY_CALL_STACK
42464246

42474247
#if WASM_ENABLE_DUMP_CALL_STACK != 0
42484248
bool

core/iwasm/interpreter/wasm_runtime.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,12 +731,12 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx)
731731

732732
#if WASM_ENABLE_DUMP_CALL_STACK != 0
733733

734-
#if WAMR_ENABLE_COPY_CALLSTACK != 0
734+
#if WASM_ENABLE_COPY_CALL_STACK != 0
735735
uint32
736-
wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
736+
wasm_interp_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
737737
uint32 length, uint32 skip_n, char *error_buf,
738738
uint32_t error_buf_size);
739-
#endif // WAMR_ENABLE_COPY_CALLSTACK
739+
#endif // WASM_ENABLE_COPY_CALL_STACK
740740

741741
bool
742742
wasm_interp_create_call_stack(struct WASMExecEnv *exec_env);

0 commit comments

Comments
 (0)