From: "René Köcher" <shirk87@googlemail.com>
To: guile-user@gnu.org
Subject: Problem with scm_display_backtrace and guile 1.8.3
Date: Mon, 4 Feb 2008 17:38:02 +0100 [thread overview]
Message-ID: <f52e27170802040838x4e567a7i774dfa560c7c9327@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2705 bytes --]
Hi,
as the subject states I encountered some problems while
trying to get a backtrace for a exception. I'm trying to embedd
guile into a C programm which should catch exceptions at
global scope and print usable error messages and backtraces.
After some searching I got to the code below which works fine
except for backtrace display.. (crashes with wrong-type-arg)
Any help on this is much appreciated, all samples and
documentation I found was targeted at guile 1.6.
======================================================================
#include <stdio.h>
#include <libguile.h>
void continue_init (void *data, int argc, char **argv);
SCM guile_catch_exception (SCM key, SCM args);
int
main (int argc, char **argv)
{
if (argc < 2)
{
fprintf(stderr, "%s 'scheme expression'\n", argv[0]);
return 1;
}
scm_boot_guile(argc, argv, 0);
return 0;
}
void
continue_init (void *data, int argc, char **argv)
{
/* NOTE: this is from a guile 1.6 solution but seems not to work */
/* enable backtraces */
SCM_DEVAL_P = 1;
SCM_BACKTRACE_P = 1;
SCM_RECORD_POSITONS_P = 1;
SCM_RESET_DEBUG_MODE;
/* eval and exit */
scm_internal_stack_catch(SCM_BOOL_T,
(scm_t_catch_body)scm_c_eval_string,
(void*)argv[1],
(scm_t_catch_handler)guile_catch_exception,
NULL);
}
SCM
guile_catch_exception (SCM key, SCM args)
{
if (scm_ilength(args) >= 3)
{
SCM stack = scm_fluid_ref(
SCM_VARIABLE_REF(scm_the_last_stack_fluid_var));
SCM subr = SCM_CAR(args);
SCM mesg = SCM_CADR(args);
SCM cargs = SCM_CADDR(args);
#if 1
/* FIXME: still wrong-type-arg error.. */
scm_display_backtrace(stack, scm_current_error_port(),
SCM_UNDEFINED, SCM_UNDEFINED);
#endif
scm_newline(scm_current_error_port());
scm_display_error(stack, scm_current_error_port(),
subr, mesg, cargs, SCM_EOL);
return SCM_BOOL_F;
}
else
{
scm_puts("E991: uncaught throw.",scm_current_error_port());
}
return SCM_BOOL_T;
}
======================================================================
----------------------------------------------------------------------
BitSpinn.org - Don't get twisted up!
----------------------------------------------------------------------
[-- Attachment #2: Type: text/html, Size: 5868 bytes --]
reply other threads:[~2008-02-04 16:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f52e27170802040838x4e567a7i774dfa560c7c9327@mail.gmail.com \
--to=shirk87@googlemail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).