[m-dev.] A flavour of programming in Opium

Mireille Ducasse Mireille.Ducasse at irisa.fr
Mon Jun 8 17:33:45 AEST 1998


>> > > finish
>> > >         Continues execution until it reaches a final (EXIT or FAIL) port
>> > >         of the call to which the current event refers. Reports an error
>> > >         if the current event refers to a final port.
>> > % This is rather called skip in most of the Prolog tracer
>> > skip_np :-
>> > 	current_pred(PredName),
>> > 	f_get(-,-,-,[exit, port],-, PredName,-,-,-,-).
>> 
>> That's not the correct behaviour.
>> You don't want to skip until a final port for the same PredName,
>> nor even until a final port for the same predicate
>> (= <pred or func> module:predname/arity).  Rather,
>> you want to skip until a final port for the same _call_.
 
Indeed that's why there is an invocation number :

skip_np :-
 	current_call(InvocationNumber),
 	f_get(-,InvocationNumber,-,[exit, fail],-, -,-,-,-,-).

Actually this can be a be more sophisticated. Something like the following may help.

skip_np :-
	(   current_port(fail)
        ->  printf("there are no more events related to this goal\n")
	;
 	    current_call(InvocationNumber),
 	    f_get(-,InvocationNumber,-,[exit, fail],-, -,-,-,-,-)).


You can also decide that skip called at an exit port executes a "next".

You can also decide to print a line only at specific ports (or when any condition is true).

my_skip :-
	skip_np,
	my_condition_on_any_part_of_the_event_info,
	print_line.


The point is that this is very easy to customize.





>> > > continue
>> > >         Continues execution until it reaches the end of the program.
>> > 
>> > continue :-
>> > 	f_get(1,1,1,exit,-,main,-,-,-,-,-,-).
>> 
>> This is not correct behaviour -- you missed part of the spec:
>> 
>> | strict commands:
>> | When a debugger command steps over some events without user interaction at
>> | those events, the *strictness* of the command controls whether the debugger
>> | will stop execution and resume user interaction at events to which a spy point
>> | or break point with state "stop" applies. By default, the debugger will stop
>> | at such events.
>> 
>> "continue" was not specified as being "strict", so it needs to stop at
>> break/spy points .


You do NOT need an extra command if you want to stop at breakpoints or
the last event, this is exactly the default behaviour of leap in
Opium. When the end of the execution is reached, whatever the debugger
command was, Opium stops and prints the last event.





More information about the developers mailing list