From Joachim.Katzer@icn.siemens.de  Fri Mar 24 17:31:03 2000
Received: from gorilla.mchh.siemens.de (gorilla.mchh.siemens.de [194.138.158.18])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id RAA03762
	for <prolog@swi.psy.uva.nl>; Fri, 24 Mar 2000 17:31:02 +0100 (MET)
Received: from blues.mchh.siemens.de (mail3.mchh.siemens.de [194.138.158.227] (may be forged))
	by gorilla.mchh.siemens.de (8.9.3/8.9.3) with ESMTP id RAA05371
	for <prolog@swi.psy.uva.nl>; Fri, 24 Mar 2000 17:30:17 +0100 (MET)
Received: from mchh247e.demchh201e.icn.siemens.de ([218.1.68.147])
	by blues.mchh.siemens.de (8.9.1/8.9.1) with ESMTP id RAA09056
	for <prolog@swi.psy.uva.nl>; Fri, 24 Mar 2000 17:28:30 +0100 (MET)
Received: by MCHH247E with Internet Mail Service (5.5.2448.0)
	id <GHPY5BCZ>; Fri, 24 Mar 2000 17:32:16 +0100
Message-ID: <7BDA29C947B9D3118AC50008C728B70405DE73@MCHH220E>
From: Katzer Joachim <Joachim.Katzer@icn.siemens.de>
To: "'prolog@swi.psy.uva.nl'" <prolog@swi.psy.uva.nl>
Subject: Debugging catched exceptions
Date: Fri, 24 Mar 2000 17:32:09 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)
Content-Type: text/plain

Hi,

I'm using SWI-Prolog 3.3.4.
How can I trace/debug catched exceptions like in the following sample:

	a_predicate_causing_an_exception :- A is B.
	a_predicate :- a_predicate_causing_an_exception.
	main :-  catch(a_predicate, A, format(user_error, 'EXCEPTION: ~w~n',
A)).

If I call "a_predicate", the exception is catched by the tracer and I can
examine the call stack.

	?- trace, a_predicate.
	   Call: (8) a_predicate ? leap
	ERROR: Arguments are not sufficiently instantiated
	^  Exception: (10) _G300 is _G301 ? goals
	     [10] _G309 is _G310
	      [9] a_predicate_causing_an_exception
	      [8] a_predicate

But if I try to debug "main", the exception is handled by main and the trace
mode not entered:

	?- trace, main.
	   Call: (8) main ? leap
	EXCEPTION: error(instantiation_error, _G250)

Is there a possibility to configure SWI-Prolog that it enteres trace mode
when the exeption is raised - without replacing the catch statements in the
program?
Otherwise it is hard to locate bugs causing exceptions in larger Prolog
programs which use catch (and throw) statements extensively.

Regards

Joachim Katzer


