Skip to content

Commit

Permalink
include top of call stack in trace when native fn fails
Browse files Browse the repository at this point in the history
  • Loading branch information
p7g committed Dec 14, 2020
1 parent f012510 commit f07b428
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ static int cb_eval(size_t pc, struct cb_frame *frame)
})
#endif

#define RET_WITH_TRACE() ({ \
if (frame->is_function) \
print_stack_function(cb_vm_state.stack[frame->bp]); \
goto end; \
})
#define ERROR(MSG, ...) ({ \
fprintf(stderr, (MSG), ##__VA_ARGS__); \
retval = 1; \
if (frame->is_function) \
print_stack_function( \
cb_vm_state.stack[frame->bp]); \
goto end; \
RET_WITH_TRACE(); \
})
#define READ_SIZE_T() ({ \
int _i = 0; \
Expand Down Expand Up @@ -444,7 +446,7 @@ DO_OP_CALL: {
cb_vm_state.sp - num_args],
&result)) {
retval = 1;
goto end;
RET_WITH_TRACE();
}
assert(cb_vm_state.sp > num_args);
cb_vm_state.sp -= (num_args + 1);
Expand All @@ -459,9 +461,8 @@ DO_OP_CALL: {
else
next_frame.module = NULL;
if (cb_eval(func->value.as_user.address, &next_frame)) {
print_stack_function(cb_vm_state.stack[frame->bp]);
retval = 1;
goto end;
RET_WITH_TRACE();
}
}

Expand Down

0 comments on commit f07b428

Please sign in to comment.