guile-user
[Top][All Lists]
Advanced

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

Re: Enabling Debugging


From: Volkan YAZICI
Subject: Re: Enabling Debugging
Date: Tue, 1 Aug 2006 13:46:31 +0300
User-agent: Mutt/1.4.2.1i

On Jul 31 10:53, dave wrote:
> I had to work through this a while back, and the problem I had was that
> there are two types of error handler callback - one is called before the
> stack is unwound, the other after. If you only set the error callback
> for after the unwind there is no stack to do the debugging...

Can you send an example working code snippet please?

> I think you can call gh_eval_str_with_stack_saving_handler() or using
> the scm interface you can call scm_c_catch() which allows you to specify
> both handlers.

AFAIK, gh_eval_str_with_stack_saving_handler() isn't present in the 1.6
release and it'd be better if my code would be able to run with 1.6
too. Therefore, I'll try to have same effect with scm_c_catch().

I've considered your "before the stack is unwound and the other after"
explanation and concluded with such a scm_c_catch() call:

  scm_c_catch(SCM_BOOL_T,                       /* tag */
             (scm_t_catch_body) eval_code,      /* body */
             (void *) code,                     /* body data */
             (scm_t_catch_handler) catch_err,   /* handler */
             (void *) code,                     /* handler data */
             (scm_t_catch_handler) unwind_catch,
             (void *) code);

But scm_backtrace(), that's placed in both catch_err() and
unwind_catch(), still complains that "No backtrace available".
(Placing that SCM_DEVAL_P = 1; ... SCM_RESET_DEBUG_MODE; stuff
doesn't affect anything too.)

Doesn't anybody have a working example code snippet? How did ppl achieve
to write so much programs using guile?

Furthermore, I've another problem: How do we receive information from
tag and args variables passed to exception handlers? I was using

  buf = SCM_STRING_CHARS(tag);
  len = SCM_STRING_LENGTH(tag);
  while (len-- > 0)
      putchar(*buf++);

method but, in the new 1.8 release it says that I'm using deprecated
functions. So how can get the pointer pointing to the related text
buffer? I cannot use gh_scm2newstr() in this situation, because it
allocates required buffer itself and just dumps an error to stderr
in case of a failure. Actually, I'm working on a shared memory segment
thus I don't want guile to make any memory allocations on its own.
Can I achieve such a functionality? (I want it to use palloc/pfree
instead of recent malloc/free calls.) Can a macro hack like

  #define malloc palloc
  #define free   pfree

solve that problem?

Moreover, as far as SCM_CONSP(args) says so, the third param (args)
passed to exception handlers is a cons. Despite I've tried some
gh_car(), gh_cdr() tricks, I couldn't manage to figure out how to use
that information too.

I'd be very very appreciated if anybody can help me to solve above
problems. (Pointers to existing projects that use guile are welcome
too.)


Regards.




reply via email to

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