|
@@ -10,6 +10,7 @@
|
|
|
#include "../common/wasm_runtime_common.h"
|
|
#include "../common/wasm_runtime_common.h"
|
|
|
#include "../common/wasm_memory.h"
|
|
#include "../common/wasm_memory.h"
|
|
|
#include "../interpreter/wasm_runtime.h"
|
|
#include "../interpreter/wasm_runtime.h"
|
|
|
|
|
+#include <stdbool.h>
|
|
|
#if WASM_ENABLE_SHARED_MEMORY != 0
|
|
#if WASM_ENABLE_SHARED_MEMORY != 0
|
|
|
#include "../common/wasm_shared_memory.h"
|
|
#include "../common/wasm_shared_memory.h"
|
|
|
#endif
|
|
#endif
|
|
@@ -4104,6 +4105,48 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
|
|
|
#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
|
|
#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
|
|
|
|
|
|
|
|
#if WASM_ENABLE_DUMP_CALL_STACK != 0
|
|
#if WASM_ENABLE_DUMP_CALL_STACK != 0
|
|
|
|
|
+void
|
|
|
|
|
+aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data)
|
|
|
|
|
+{
|
|
|
|
|
+/*
|
|
|
|
|
+* Note for devs: please refrain from such modifications inside of aot_iterate_callstack
|
|
|
|
|
+ * - any allocations/freeing memory
|
|
|
|
|
+ * - dereferencing any pointers other than: exec_env, exec_env->module_inst,
|
|
|
|
|
+ * exec_env->module_inst->module, pointers between stack's bottom and top_boundary
|
|
|
|
|
+ * For more details check wasm_iterate_callstack in wasm_export.h
|
|
|
|
|
+*/
|
|
|
|
|
+ if (!is_tiny_frame(exec_env)) {
|
|
|
|
|
+ //TODO: support standard frames
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ uint8* top_boundary = exec_env->wasm_stack.top_boundary;
|
|
|
|
|
+ uint8* top = exec_env->wasm_stack.top;
|
|
|
|
|
+ uint8* bottom = exec_env->wasm_stack.bottom;
|
|
|
|
|
+
|
|
|
|
|
+ bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame));
|
|
|
|
|
+ if (!is_top_index_in_range) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0;
|
|
|
|
|
+ if (!is_top_aligned_with_bottom) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AOTTinyFrame* frame = (AOTTinyFrame*)(top - sizeof(AOTTinyFrame));
|
|
|
|
|
+ WASMCApiFrame record_frame;
|
|
|
|
|
+ while (frame &&
|
|
|
|
|
+ (uint8_t*)frame >= bottom) {
|
|
|
|
|
+ record_frame.instance = exec_env->module_inst;
|
|
|
|
|
+ record_frame.module_offset = 0;
|
|
|
|
|
+ record_frame.func_index = frame->func_index;
|
|
|
|
|
+ record_frame.func_offset = frame->ip_offset;
|
|
|
|
|
+ if (!frame_handler(user_data, &record_frame)) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ frame -= 1;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
bool
|
|
bool
|
|
|
aot_create_call_stack(struct WASMExecEnv *exec_env)
|
|
aot_create_call_stack(struct WASMExecEnv *exec_env)
|
|
|
{
|
|
{
|