mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 08:48:33 +00:00
truncate function name if too long
This commit is contained in:
parent
53115b2b37
commit
38fdf917a1
|
@ -3106,6 +3106,7 @@ aot_dump_call_stack(WASMExecEnv *exec_env, bool print, char *buf, uint32 len)
|
||||||
|
|
||||||
while (n < total_frames) {
|
while (n < total_frames) {
|
||||||
WASMCApiFrame frame = { 0 };
|
WASMCApiFrame frame = { 0 };
|
||||||
|
uint32 line_length, i;
|
||||||
|
|
||||||
if (!bh_vector_get(module_inst->frames.ptr, n, &frame)) {
|
if (!bh_vector_get(module_inst->frames.ptr, n, &frame)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3113,12 +3114,21 @@ aot_dump_call_stack(WASMExecEnv *exec_env, bool print, char *buf, uint32 len)
|
||||||
|
|
||||||
/* function name not exported, print number instead */
|
/* function name not exported, print number instead */
|
||||||
if (frame.func_name_wp == NULL) {
|
if (frame.func_name_wp == NULL) {
|
||||||
snprintf(line_buf, sizeof(line_buf), "#%02d $f%d\n", n,
|
line_length = snprintf(line_buf, sizeof(line_buf), "#%02d $f%d\n",
|
||||||
frame.func_index);
|
n, frame.func_index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
snprintf(line_buf, sizeof(line_buf), "#%02d %s\n", n,
|
line_length = snprintf(line_buf, sizeof(line_buf), "#%02d %s\n", n,
|
||||||
frame.func_name_wp);
|
frame.func_name_wp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line_length >= sizeof(line_buf)) {
|
||||||
|
uint32 line_buffer_len = sizeof(line_buf);
|
||||||
|
/* If line too long, ensure the last character is '\n' */
|
||||||
|
for (i = line_buffer_len - 5; i < line_buffer_len - 2; i++) {
|
||||||
|
line_buf[i] = '.';
|
||||||
|
}
|
||||||
|
line_buf[line_buffer_len - 2] = '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_OR_DUMP();
|
PRINT_OR_DUMP();
|
||||||
|
|
|
@ -2616,6 +2616,7 @@ wasm_interp_dump_call_stack(struct WASMExecEnv *exec_env, bool print, char *buf,
|
||||||
|
|
||||||
while (n < total_frames) {
|
while (n < total_frames) {
|
||||||
WASMCApiFrame frame = { 0 };
|
WASMCApiFrame frame = { 0 };
|
||||||
|
uint32 line_length, i;
|
||||||
|
|
||||||
if (!bh_vector_get(module_inst->frames, n, &frame)) {
|
if (!bh_vector_get(module_inst->frames, n, &frame)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2623,12 +2624,21 @@ wasm_interp_dump_call_stack(struct WASMExecEnv *exec_env, bool print, char *buf,
|
||||||
|
|
||||||
/* function name not exported, print number instead */
|
/* function name not exported, print number instead */
|
||||||
if (frame.func_name_wp == NULL) {
|
if (frame.func_name_wp == NULL) {
|
||||||
snprintf(line_buf, sizeof(line_buf), "#%02d $f%d\n", n,
|
line_length = snprintf(line_buf, sizeof(line_buf), "#%02d $f%d\n",
|
||||||
frame.func_index);
|
n, frame.func_index);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
snprintf(line_buf, sizeof(line_buf), "#%02d %s\n", n,
|
line_length = snprintf(line_buf, sizeof(line_buf), "#%02d %s\n", n,
|
||||||
frame.func_name_wp);
|
frame.func_name_wp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line_length >= sizeof(line_buf)) {
|
||||||
|
uint32 line_buffer_len = sizeof(line_buf);
|
||||||
|
/* If line too long, ensure the last character is '\n' */
|
||||||
|
for (i = line_buffer_len - 5; i < line_buffer_len - 2; i++) {
|
||||||
|
line_buf[i] = '.';
|
||||||
|
}
|
||||||
|
line_buf[line_buffer_len - 2] = '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_OR_DUMP();
|
PRINT_OR_DUMP();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user