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: trouble with scm_display_backtrace in guile 1.8.3 Date: Mon, 4 Feb 2008 11:30:15 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2874_5184946.1202121015858" X-Trace: ger.gmane.org 1202144862 2908 80.91.229.12 (4 Feb 2008 17:07:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Feb 2008 17:07:42 +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:04 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 1JM4mQ-0006nE-LX for guile-user@m.gmane.org; Mon, 04 Feb 2008 18:06:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM4ly-0007aQ-IP for guile-user@m.gmane.org; Mon, 04 Feb 2008 12:06:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JLyaj-0003sE-1D for guile-user@gnu.org; Mon, 04 Feb 2008 05:30:21 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JLyah-0003rK-Ry for guile-user@gnu.org; Mon, 04 Feb 2008 05:30:19 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JLyah-0003rD-85 for guile-user@gnu.org; Mon, 04 Feb 2008 05:30:19 -0500 Original-Received: from wa-out-1112.google.com ([209.85.146.177]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JLyag-0006dl-FJ for guile-user@gnu.org; Mon, 04 Feb 2008 05:30:19 -0500 Original-Received: by wa-out-1112.google.com with SMTP id k34so2244553wah.10 for ; Mon, 04 Feb 2008 02:30:15 -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=PdRud0IFDxTIAMZmgvmOx5zlk+usx0tvRL5xu4pWQBM=; b=JXzSK5L3EgHMruBONJHSaA1anqHCBzX6b8Kv0kTw378B6pvwcoD4M7egoYC4Oy16Q8YqhzN5/nxrhyKpO1Om8eExC2syanbKztei8sUnxSk7kyCvL099CzGA2CVLo4EaBnnam8basuYVeMi24q6H3+AVL3AE4EFf9wCPB1NULgM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=PP2s1j0azdBP/Q6hFhCZjYmoxs8zSSA8wL8Q6Ql9j2+KvvTYV75Ba85LOPGNCkYZJBhDr78ZJSsD+TcCEDB5tCVOu+Cj0Isaz7MaI0vJDwJm50NGt1kkxIqx4oONvI4cV9mzjr7quWqWy++uu6gs25SmfVYkZRRfiVSwcS39r6Q= Original-Received: by 10.141.86.14 with SMTP id o14mr4594004rvl.148.1202121015871; Mon, 04 Feb 2008 02:30:15 -0800 (PST) Original-Received: by 10.141.40.20 with HTTP; Mon, 4 Feb 2008 02:30:15 -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:6406 Archived-At: ------=_Part_2874_5184946.1202121015858 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_2874_5184946.1202121015858 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_2874_5184946.1202121015858--