Add print_stack_trace function for debug