Пример #1
0
/* Pre-unwind handler called in the context in which the exception was
 * thrown. */
static SCM protected_pre_unwind_handler (void *data, SCM key, SCM args)
{
  /* Capture the stack trace */
  *((SCM *) data) = scm_make_stack (SCM_BOOL_T, SCM_EOL);

  return SCM_BOOL_T;
}
Пример #2
0
static SCM call_callable(SCM scm_args)
{
	SCM stack = scm_make_stack(SCM_BOOL_T, SCM_EOL);
	SCM frame = scm_stack_ref(stack, scm_from_int(0));
	SCM proc = scm_frame_procedure(frame);
	PyObject *callable = scm_to_pointer(scm_assq_ref(gsubr_alist, proc));

	scm_dynwind_begin(0);

	PyObject *py_args = scm2py(scm_args);
	if (py_args == NULL)
		py2scm_exception(); /* does not return */
	scm_dynwind_py_decref(py_args);

	struct call_callable_data data = { callable, py_args };
	PyObject *py_result = (PyObject *)scm_without_guile(
		(void *(*)(void *))call_callable1, &data);
	if (py_result == NULL)
		py2scm_exception(); /* does not return */
	scm_dynwind_py_decref(py_result);

	SCM scm_result = py2scm(py_result);
	scm_dynwind_end();
	return scm_result;
}
Пример #3
0
static SCM
scscm_printing_pre_unwind_handler (void *data, SCM key, SCM args)
{
  SCM stack = scm_make_stack (SCM_BOOL_T, scm_list_1 (scm_from_int (2)));

  gdbscm_print_exception_with_stack (SCM_BOOL_F, stack, key, args);

  return SCM_UNSPECIFIED;
}
Пример #4
0
/*!
 * \brief Get the name of the RC filename being evaluated.
 * \par Function Description
 *
 * Creates a Guile stack object, extracts the topmost frame from that
 * stack and gets the sourcefile name.
 *
 * \returns If the interpreter can resolve the filename, returns a
 * Scheme object with the full path to the RC file, otherwise #f
 */
SCM
g_rc_rc_filename()
{
  SCM stack, frame, source;

  stack = scm_make_stack (SCM_BOOL_T, SCM_EOL);
  if (scm_is_false (stack)) {
    return SCM_BOOL_F;
  }

  frame = scm_stack_ref (stack, scm_from_int(0));
  if (scm_is_false (frame)) {
    return SCM_BOOL_F;
  }

  source = scm_frame_source (frame);
  if (scm_is_false (source)) {
    return SCM_BOOL_F;
  }

  return scm_source_property (source, scm_sym_filename);
}
Пример #5
0
static SCM
scscm_recording_pre_unwind_handler (void *datap, SCM key, SCM args)
{
  struct with_catch_data *data = datap;
  excp_matcher_func *matcher = data->excp_matcher;

  if (matcher != NULL && matcher (key))
    return SCM_UNSPECIFIED;

  /* There's no need to record the whole stack if we're not going to print it.
     However, convention is to still print the stack frame in which the
     exception occurred, even if we're not going to print a full backtrace.
     For now, keep it simple.  */

  data->stack = scm_make_stack (SCM_BOOL_T, scm_list_1 (scm_from_int (2)));

  /* IWBN if we could return the <gdb:exception> here and skip the unwind
     handler, but it doesn't work that way.  If we want to return a
     <gdb:exception> object from the catch it needs to come from the unwind
     handler.  So what we do is save the stack for later use by the unwind
     handler.  */

  return SCM_UNSPECIFIED;
}
Пример #6
0
/* Pre-unwind handler for g_read_file().  Captures the Guile stack for
 * processing in the post-unwind handler. */
SCM
g_read_file__pre_handler (struct g_read_file_data_t *data, SCM key, SCM args)
{
  data->stack = scm_make_stack (SCM_BOOL_T, SCM_EOL);
  return SCM_BOOL_F;
}
Пример #7
0
static SCM grab_stack(void *data, SCM key, SCM parameters) {
	*((SCM *)data) = scm_make_stack(SCM_BOOL_T, SCM_EOL);
	return SCM_UNSPECIFIED;
	}