guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wrong-type-arg in scm_display_backtrace


From: William Morgan
Subject: Re: wrong-type-arg in scm_display_backtrace
Date: Sat, 4 Jan 2003 22:57:42 -0500
User-agent: Mutt/1.4i

Excerpts (reformatted) from Neil Jerram's mail of 31 Dec 2002 (EST):
> Is stack #f on entry to scm_display_backtrace?

Indeed, it is #f after all.

> To get scm_display_backtrace to work in your scenario, you essentially
> need to replicate the kernel of all this in C, i.e.:
> 
> (lazy-catch #t
>             thunk
>             (lambda (args)
>               (fluid-set! the-last-stack (make-stack #t))
>               (apply throw args)))

Ok, this is helpful. I am starting to understand exactly what I need to
be doing. Unfortunately I am still unsuccesful:

>From perusal of throw.c, it seems that scm_internal_stack_catch is what I want
to call, as it sets scm_the_last_stack_fluid_var. However, using, the stack is
always #f at the point that I hit the error handler. So what am I doing wrong
in the code below?

--- snip ---

static SCM guile_safe_apply_handler(void *data, SCM tag, SCM throw_args) {
  SCM port = scm_def_errp;

  if(scm_ilength(throw_args) >= 3) {
    SCM stack = scm_fluid_ref(SCM_VARIABLE_REF(scm_the_last_stack_fluid_var));
    SCM subr = SCM_CAR(throw_args);
    SCM message = SCM_CADR(throw_args);
    SCM args = SCM_CADDR(throw_args);
    
    /* So far, I reach this point with non-user-throws exceptions (e.g.
        undefined variables). But stack is invariably #f. */

    scm_display_backtrace(stack, port, SCM_UNDEFINED, SCM_UNDEFINED);
    return SCM_BOOL_F;
  }

  else {
    /* I reach this point upon user-thrown exceptions. Why? */

    scm_puts("uncaught throw to ", port);
    scm_prin1(tag, port, 0);
  }

  return SCM_BOOL_T;
}

struct guile_body_apply_data {
  SCM proc;
  SCM args;
};

SCM guile_safe_apply_body(struct guile_body_apply_data* data) {
  return scm_apply_0(data->proc, data->args);
}

SCM guile_safe_apply(SCM proc, SCM args) {
  struct guile_body_apply_data data;

  data.proc = proc;
  data.args = args;

  return scm_internal_stack_catch(SCM_BOOL_T, 
(scm_t_catch_body)guile_safe_apply_body, (void*)&data, 
(scm_t_catch_handler)guile_safe_apply_handler, NULL);
}

--- snip ---

Is scm_apply_0 the wrong thing to call in the body?

Any further help would be appreciated.

Thanks,

-- 
William <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]