debug_call.pl -- Debugging with calls.

Avoids running goals to produce output that is only relevant while debugging. Includes pre-canned often used calls.


?- debug( ex ).
?- debug_call( ex, length, '', list1/[x,y,z] ).
% Length for list, list1: 3

?- debug_call( ex, length, 'some prefix', [list1,list2]/[[x,y,z],[a,b,c]] ).
% some prefix lengths for lists, list1: 3, list2: 3

?- debug_call( ex, dims, [m1,m2]/[[a(x),a(y),a(z)],[xy(a,b),xy(c,d),xy(e,f)]] ).
%  Dimensions for matrices,  (m1) nR: 3, nC: 1. (m2) nR: 3, nC: 2.

?- debug_call( ex, wrote, loc(file,csv) ).
% Could not locate wrote on file specified by: file, and extensions: csv
?- csv_write_file( 'file.csv', [] ).

?- debug_call( ex, wrote, loc(file,csv) ).
% Wrote on file: '/home/nicos/pl/lib/src/trace/file.csv'

?- debug_call( ex, task(stop), 'write on file' ).
At 15:44:1 on 2nd of Jul 2014 finished task: write on file.
author
- nicos angelopoulos
See also
- http://stoics.org.uk/~nicos/sware/debug_call/
To be done
- options_debug( Opts, Mess, Args ) only writes if Opts contains debug(true). maybe this should be part of pack(options)
debug_call_version(-Version, -Date)
Current version and release date for the library.
debug_call(+Topic, +Goal)
Only call debug if we are debugging Topic.

propose this to be included to debug.pl

debug_chain(+TopicCond, +TopicDep)
debug_chain(+TopicCond, +TopicDep, -TDprior)
If already debugging TopicCond, then also start debugging TopicDep ). TDprior is true if TopicDep was already debugging, else is false. Current implementation sets TDprior to true whenever Topic is not debugged, as it assumes that this value best suit independent fluctuation of TopicDep. Only in the case of debug_chain/2, TopicDep can be a list.
author
- nicos angelopoulos
version
- 0.1 2014/4/4
See also
- debug_reset/2
debugging_status(+Topic, -Status)
Status == true iff debugging(Topic) succeeds. Else, it is false. Similar to debugging/2, but does not fail for undefined Topic.
 ?- debug( something ).
 true.
 ?- debugging_status( something, Some ).
 Some = true.
 ?- debugging_status( some_else, Else ).
 Else = false.
author
- nicos angelopoulos
version
- 0.1 2014/7/23
debug_reset(+Prior, +Topic)
Reset Topic according to Prior: true does nothing, false turns Topic off.
 ?- nodebug( chained ).
 true.
 ?- debug( testo ).
 Warning: testo: no matching debug topic (yet)
 true.
 ?- debug( chained, 'debugs chains 1', [] ).
 true.
 ?- debug_chain( testo, chained, Prior ).
 Prior = false.
 ?- debug( chained, 'debugs chains 2', [] ).
 % debugs chains 2
 true.
 ?- Prior = false, debug_reset( Prior, chained ).
 Prior = false.
 ?- debug( chained, 'debugs chains 3', [] ).
 true
author
- nicos angelopoulos
version
- 0.1 2014/7/23
See also
- debug_chain/3
debug_topic(+Flag, +Topic)
Start debugging Topic if Flag == true.
 ?- debug_topic( true, example ).
author
- nicos angelopoulos
version
- 0.1 2014/12/10
See also
- options_append/4
debug_on(+Topic)
As debug/1, but do not print warning if topic is not known.
debug_portray(+Topic, +Term)
Call portray_clause(Term) if we are debugging Topic.
author
- nicos angelopoulos
version
- 0.1
debug_call(+Topic, +Goal, +Args)
debug_call(+Topic, +Goal, +Mess, +Args)
Automates often used debug calls. When Mess is missing it is assumed to be ''.

Goal in:

  ?- debug( ex ).
  ?- debug_call( ex, length, '', list1/[x,y,z] ).
  % Length for list, list1: 3
 
  ?- debug_call( ex, length, 'some prefix', [list1,list2]/[[x,y,z],[a,b,c]] ).
  % some prefix lengths for lists, list1: 3, list2: 3
     
  ?- debug_call( ex, wrote, loc(file,csv) ).
  % Could not locate wrote on file specified by: file, and extensions: csv
  ?- csv_write_file( 'file.csv', [] ).

  ?- debug_call( ex, wrote, loc(file,csv) ).
  % Wrote on file: '/home/nicos/pl/lib/src/trace/file.csv'

   ?- debug_call( ex, task(stop), 'write on file' )
   % At 15:44:1 on 2nd of Jul 2014 finished task: write on file.
   
   ?- debug_call( ex, (length([a,b,c],L),write(len(L)),nl) ).
   len(3)
   L = 3.
author
- nicos angelopoulos
version
- 0.1 2014/03/27
- 0.2 2014/04/24 added wrote
- 0.3 2014/07/2 added task
- 0.4 2014/09/22 added renamed from debug_call/3
debug_chain(+TopicCond, +TopicDep)
debug_chain(+TopicCond, +TopicDep, -TDprior)
If already debugging TopicCond, then also start debugging TopicDep ). TDprior is true if TopicDep was already debugging, else is false. Current implementation sets TDprior to true whenever Topic is not debugged, as it assumes that this value best suit independent fluctuation of TopicDep. Only in the case of debug_chain/2, TopicDep can be a list.
author
- nicos angelopoulos
version
- 0.1 2014/4/4
See also
- debug_reset/2
debug_call(+Topic, +Goal, +Args)
debug_call(+Topic, +Goal, +Mess, +Args)
Automates often used debug calls. When Mess is missing it is assumed to be ''.

Goal in:

  ?- debug( ex ).
  ?- debug_call( ex, length, '', list1/[x,y,z] ).
  % Length for list, list1: 3
 
  ?- debug_call( ex, length, 'some prefix', [list1,list2]/[[x,y,z],[a,b,c]] ).
  % some prefix lengths for lists, list1: 3, list2: 3
     
  ?- debug_call( ex, wrote, loc(file,csv) ).
  % Could not locate wrote on file specified by: file, and extensions: csv
  ?- csv_write_file( 'file.csv', [] ).

  ?- debug_call( ex, wrote, loc(file,csv) ).
  % Wrote on file: '/home/nicos/pl/lib/src/trace/file.csv'

   ?- debug_call( ex, task(stop), 'write on file' )
   % At 15:44:1 on 2nd of Jul 2014 finished task: write on file.
   
   ?- debug_call( ex, (length([a,b,c],L),write(len(L)),nl) ).
   len(3)
   L = 3.
author
- nicos angelopoulos
version
- 0.1 2014/03/27
- 0.2 2014/04/24 added wrote
- 0.3 2014/07/2 added task
- 0.4 2014/09/22 added renamed from debug_call/3