1010#include "../common/wasm_runtime_common.h"
1111#include "../common/wasm_memory.h"
1212#include "../interpreter/wasm_runtime.h"
13+ #include <string.h>
1314#if WASM_ENABLE_SHARED_MEMORY != 0
1415#include "../common/wasm_shared_memory.h"
1516#endif
@@ -4105,8 +4106,8 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
41054106
41064107#if WAMR_ENABLE_COPY_CALLSTACK != 0
41074108uint32
4108- aot_copy_callstack_tiny_frame (WASMExecEnv * exec_env , wasm_frame_ptr_t buffer ,
4109- const uint32 length , const uint32 skip_n )
4109+ aot_copy_callstack_tiny_frame (WASMExecEnv * exec_env , wasm_frame_t * buffer ,
4110+ const uint32 length , const uint32 skip_n , char * error_buf , uint32 error_buf_size )
41104111{
41114112 /*
41124113 * Note for devs: please refrain from such modifications inside of
@@ -4126,12 +4127,16 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer,
41264127 bool is_top_index_in_range =
41274128 top_boundary >= top && top >= (bottom + sizeof (AOTTinyFrame ));
41284129 if (!is_top_index_in_range ) {
4129- return count ;
4130+ char * err_msg = "Top of the stack pointer is outside of the stack boundaries" ;
4131+ strncpy (error_buf , err_msg , error_buf_size );
4132+ return 0 ;
41304133 }
41314134 bool is_top_aligned_with_bottom =
41324135 (unsigned long )(top - bottom ) % sizeof (AOTTinyFrame ) == 0 ;
41334136 if (!is_top_aligned_with_bottom ) {
4134- return count ;
4137+ char * err_msg = "Top of the stack is not aligned with the bottom" ;
4138+ strncpy (error_buf , err_msg , error_buf_size );
4139+ return 0 ;
41354140 }
41364141
41374142 AOTTinyFrame * frame = (AOTTinyFrame * )(top - sizeof (AOTTinyFrame ));
@@ -4155,8 +4160,8 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer,
41554160
41564161uint32
41574162aot_copy_callstack_standard_frame (WASMExecEnv * exec_env ,
4158- wasm_frame_ptr_t buffer , const uint32 length ,
4159- const uint32 skip_n )
4163+ wasm_frame_t * buffer , const uint32 length ,
4164+ const uint32 skip_n , char * error_buf , uint32_t error_buf_size )
41604165{
41614166 /*
41624167 * Note for devs: please refrain from such modifications inside of
@@ -4203,8 +4208,8 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env,
42034208}
42044209
42054210uint32
4206- aot_copy_callstack (WASMExecEnv * exec_env , wasm_frame_ptr_t buffer ,
4207- const uint32 length , const uint32 skip_n )
4211+ aot_copy_callstack (WASMExecEnv * exec_env , wasm_frame_t * buffer ,
4212+ const uint32 length , const uint32 skip_n , char * error_buf , uint32_t error_buf_size )
42084213{
42094214 /*
42104215 * Note for devs: please refrain from such modifications inside of
@@ -4217,10 +4222,10 @@ aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer,
42174222 */
42184223 if (!is_tiny_frame (exec_env )) {
42194224 return aot_copy_callstack_standard_frame (exec_env , buffer , length ,
4220- skip_n );
4225+ skip_n , error_buf , error_buf_size );
42214226 }
42224227 else {
4223- return aot_copy_callstack_tiny_frame (exec_env , buffer , length , skip_n );
4228+ return aot_copy_callstack_tiny_frame (exec_env , buffer , length , skip_n , error_buf , error_buf_size );
42244229 }
42254230}
42264231#endif // WAMR_ENABLE_COPY_CALLSTACK
0 commit comments