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.
propose this to be included to debug.pl
lib(debug)
does not create a record by inspecting the term (via expansion).
Particularly useful in sending uninstantiated Topics.
lib(debug)
does not create a record by inspecting the term (via expansion).
Particularly useful in sending uninstantiated Topics.
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.
?- 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_set( Prior, chained ). Prior = false. ?- debug( chained, 'debugs chains 3', [] ). true
options(debug(true),Opts)
, with Restore
being instantiated to a term that can be used to restore the
original debug state of Topic (see options_restore/2). If options(debug(false),Opts)
then Topic is stopped from being debugged (Restore still holds the
correct term for restoring debugging state for topic to precall status).
?- assert( ( on_t(I,Topic) :- (debugging(Topic) -> write(I-y(Topic)) ; write(I-n(Topic))), nl ) ). ?- T = options, debug(T), on_t(1,T), debug_topic(T,[debug(false)],R), on_t(2,T), debug_set(R,T), on_t(3,T). 1-y(options) 2-n(options) 3-y(options) T = options, R = true. ?- T = options, nodebug(T), on_t(1,T), debug_topic(T,[debug(true)],R), on_t(2,T), debug_set(R,T), on_t(3,T). 1-n(options) 2-y(options) 3-n(options) T = options, R = false.
?- debug_topic( true, example ).
portray_clause(Term)
if we are debugging Topic.
When Goal is a known abbreviation, then Arg usually qualifies the output generated.
When Goal is of the form call(Goal)
, Arg will be passed to debug(Topic,Mess,Arg)
.
Goal in:
loc(File,Exts)
or simply File in which case Exts = ''.loc(File,Exts)
or simply File in which case Exts = ''.task(Wch)
time of start/stop of a task. Other values are allowed put printed as is.call(Goal)
call Goal before printing debugging message debug( Topic, Mess, Args)
. (Goal is called in non-deterministic context).call(Goal)
?- 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.