Subject: Re: Exception goal stack

From: Jan Wielemaker <[email-masked]>
Date: Wed, 8 Nov 2000 09:49:09 +0100

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.