address comments

This commit is contained in:
Georgii Rylov
2025-02-27 14:32:17 +00:00
parent 99cb6ec27e
commit fc3077b74d
8 changed files with 45 additions and 31 deletions

View File

@ -10,6 +10,7 @@
#include "../common/wasm_runtime_common.h"
#include "../common/wasm_memory.h"
#include "../interpreter/wasm_runtime.h"
#include <string.h>
#if WASM_ENABLE_SHARED_MEMORY != 0
#include "../common/wasm_shared_memory.h"
#endif
@ -4105,8 +4106,8 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
#if WAMR_ENABLE_COPY_CALLSTACK != 0
uint32
aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer,
const uint32 length, const uint32 skip_n)
aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t* buffer,
const uint32 length, const uint32 skip_n, char *error_buf, uint32 error_buf_size)
{
/*
* 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,
bool is_top_index_in_range =
top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame));
if (!is_top_index_in_range) {
return count;
char* err_msg = "Top of the stack pointer is outside of the stack boundaries";
strncpy(error_buf, err_msg, error_buf_size);
return 0;
}
bool is_top_aligned_with_bottom =
(unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0;
if (!is_top_aligned_with_bottom) {
return count;
char* err_msg = "Top of the stack is not aligned with the bottom";
strncpy(error_buf, err_msg, error_buf_size);
return 0;
}
AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame));
@ -4155,8 +4160,8 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer,
uint32
aot_copy_callstack_standard_frame(WASMExecEnv *exec_env,
wasm_frame_ptr_t buffer, const uint32 length,
const uint32 skip_n)
wasm_frame_t* buffer, const uint32 length,
const uint32 skip_n, char *error_buf, uint32_t error_buf_size)
{
/*
* Note for devs: please refrain from such modifications inside of
@ -4203,8 +4208,8 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env,
}
uint32
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_ptr_t buffer,
const uint32 length, const uint32 skip_n)
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t* buffer,
const uint32 length, const uint32 skip_n, char *error_buf, uint32_t error_buf_size)
{
/*
* 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,
*/
if (!is_tiny_frame(exec_env)) {
return aot_copy_callstack_standard_frame(exec_env, buffer, length,
skip_n);
skip_n, error_buf, error_buf_size);
}
else {
return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n);
return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n, error_buf, error_buf_size);
}
}
#endif // WAMR_ENABLE_COPY_CALLSTACK