From jan@swi.psy.uva.nl  Wed Nov  8 09:55:19 2000
Received: from gollem.swi.psy.uva.nl (gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id JAA28889;
	Wed, 8 Nov 2000 09:55:19 +0100 (MET)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id JAA26066;
	Wed, 8 Nov 2000 09:54:17 +0100
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: mike.elston@sss.co.nz
Subject: Re: Exception goal stack
Date: Wed, 8 Nov 2000 09:49:09 +0100
X-Mailer: KMail [version 1.0.28]
Content-Type: text/plain
References: <200011080418.FAA25660@swi.psy.uva.nl>
In-Reply-To: <200011080418.FAA25660@swi.psy.uva.nl>
Cc: prolog@gollem.swi.psy.uva.nl
MIME-Version: 1.0
Message-Id: <00110809541700.26023@gollem>
Content-Transfer-Encoding: 8bit

On Wed, 08 Nov 2000, you wrote:
>Hi Jan
>
>We at SSS have been happily developing with our commercially licenced
>SWI Prolog for quite a while now and we are very pleased with the
>product.
>
>I have a question:
>
>Is it possible to acquire (bind to a variable) the execution stack
>following an exception?  If not, this would be a very useful feature for
>determining exactly where in a large Prolog program an error has
>occurred.  This is particularly true for low level system exceptions
>such as type errors where the predicate raising the exception might be
>called in many different places.

To a certain extend.  Basically you can intercept the Prolog debugger
and use the Prolog stack querying predicates to get access to the stack.
The biggest trouble is generally last-call optimisation that makes you
loose much useful context information.  All predicates you need are
described in the manual.  You can also pick up the sources of the
GUI tracer, which is entirely based on these predicates.

	Regards --- Jan

P.s.	You cannot do anything from the recovery handler of a catch/3:
	the stacks have already gone then.  Only if an exception is not
	caught, the system will activate the debugger and propagate the
	exception frame-by-frame.

