From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "=?ISO-8859-1?Q?Ren=E9_K=F6cher?=" Newsgroups: gmane.lisp.guile.user Subject: Problem with scm_display_backtrace and guile 1.8.3 Date: Mon, 4 Feb 2008 17:38:02 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4102_8709770.1202143082201" X-Trace: ger.gmane.org 1202144873 2943 80.91.229.12 (4 Feb 2008 17:07:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Feb 2008 17:07:53 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Feb 04 18:08:14 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JM4mp-0006yh-Qb for guile-user@m.gmane.org; Mon, 04 Feb 2008 18:07:16 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM4mN-00088Q-PL for guile-user@m.gmane.org; Mon, 04 Feb 2008 12:06:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JM4Kb-00077W-SH for guile-user@gnu.org; Mon, 04 Feb 2008 11:38:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JM4Ka-00075h-Qb for guile-user@gnu.org; Mon, 04 Feb 2008 11:38:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM4Ka-00075O-M9 for guile-user@gnu.org; Mon, 04 Feb 2008 11:38:04 -0500 Original-Received: from wx-out-0506.google.com ([66.249.82.237]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JM4Ka-000619-7T for guile-user@gnu.org; Mon, 04 Feb 2008 11:38:04 -0500 Original-Received: by wx-out-0506.google.com with SMTP id s7so1942413wxc.24 for ; Mon, 04 Feb 2008 08:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=PzwSsZ/J8wo35kKNwrKruwaW9qM2FzOJImn8c6KEBlM=; b=g8Fnp0vvcepkf3DWf9qCWvsRHMkrEMOVivATw9bxl/WV565kRbmLKkZyf4u3vEnkbT6zi6x1SDgVVe6QgF0jGDMcvCv4snS2DREC8LYSBVxWEleK/Hn4G7Yem0aN95Y2agZXrdKJTb3wDIJOyaXJnncN0oSZ7poKLg/eVVkZxM4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=ffKLSDQ3cvuOY3fQ7W5YJpzM35htC8QNspQshc8UG2TUhDEuGP5qxHnlZRPDUmkSbbhLP6JCpuq/4TNla/7+wjKUow3a4p2hqmURdS386a82QOLK2J05gToY4pX/mEO2Lmh856NI6ugSJAZoDrqigoJ4/fYL+Y9elEzSyh68Fn4= Original-Received: by 10.140.251.1 with SMTP id y1mr4868309rvh.102.1202143082218; Mon, 04 Feb 2008 08:38:02 -0800 (PST) Original-Received: by 10.141.40.20 with HTTP; Mon, 4 Feb 2008 08:38:02 -0800 (PST) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-Mailman-Approved-At: Mon, 04 Feb 2008 12:03:59 -0500 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6407 Archived-At: ------=_Part_4102_8709770.1202143082201 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 #include 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! ---------------------------------------------------------------------- ------=_Part_4102_8709770.1202143082201 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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!
----------------------------------------------------------------------

------=_Part_4102_8709770.1202143082201--