[m-rev.] For review: changes to mdb pretty printing
Ian MacLarty
maclarty at cs.mu.OZ.AU
Fri Nov 5 13:14:41 AEDT 2004
For review by anyone.
Estimated hours taken: 1.5
Branches: main
Rename "pretty" browser format to "raw_pretty" and "raw_pretty" to "pretty".
Make old "pretty" format print function return values. Remove univ_cons
constructor around old "raw_pretty" function return values.
browser/browse.m
Rename "raw_pretty" to "pretty" and vica versa. Use univ value when
creating doc for return value.
browser/sized_pretty.m
If a synthetic term has a return value then include it in the doc.
tests/debugger/browse_pretty.exp
tests/debugger/browse_pretty.inp
tests/debugger/declarative/browse_arg.exp
tests/debugger/declarative/browse_arg.inp
tests/debugger/declarative/dependency.exp
tests/debugger/declarative/dependency.inp
Change input and expected output where pretty or raw_pretty formats
used.
tests/debugger/browser_test.m
tests/debugger/browser_test.exp
tests/debugger/browser_test.inp
Test printing of function applications.
Index: browser/browse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/browse.m,v
retrieving revision 1.46
diff -u -r1.46 browse.m
--- browser/browse.m 27 Oct 2004 02:23:27 -0000 1.46
+++ browser/browse.m 4 Nov 2004 23:35:31 -0000
@@ -690,18 +690,18 @@
Params ^ depth, Params ^ width, Params ^ lines, Str),
write_string_debugger(Debugger, Str, !IO).
-:- pred portray_raw_pretty(debugger::in, browser_term::in, format_params::in,
+:- pred portray_pretty(debugger::in, browser_term::in, format_params::in,
io::di, io::uo) is det.
-portray_raw_pretty(Debugger, BrowserTerm, Params, !IO) :-
- browser_term_to_string_raw_pretty(BrowserTerm, Params ^ width,
+portray_pretty(Debugger, BrowserTerm, Params, !IO) :-
+ browser_term_to_string_pretty(BrowserTerm, Params ^ width,
Params ^ depth, Str),
write_string_debugger(Debugger, Str, !IO).
-:- pred portray_pretty(debugger::in, browser_term::in, format_params::in,
+:- pred portray_raw_pretty(debugger::in, browser_term::in, format_params::in,
io::di, io::uo) is cc_multi.
-portray_pretty(Debugger, BrowserTerm, Params, !IO) :-
+portray_raw_pretty(Debugger, BrowserTerm, Params, !IO) :-
io__get_stream_db(StreamDb, !IO),
BrowserDb = browser_db(StreamDb),
sized_pretty__browser_term_to_string_line(BrowserDb, BrowserTerm,
@@ -1001,14 +1001,14 @@
% provides no way of doing this.
%
-:- pred browser_term_to_string_raw_pretty(browser_term::in, int::in, int::in,
+:- pred browser_term_to_string_pretty(browser_term::in, int::in, int::in,
string::out) is det.
-browser_term_to_string_raw_pretty(plain_term(Univ), Width, MaxDepth, Str) :-
+browser_term_to_string_pretty(plain_term(Univ), Width, MaxDepth, Str) :-
Value = univ_value(Univ),
Doc = to_doc(MaxDepth, Value),
Str = to_string(Width, Doc).
-browser_term_to_string_raw_pretty(synthetic_term(Functor, Args, MaybeReturn),
+browser_term_to_string_pretty(synthetic_term(Functor, Args, MaybeReturn),
Width, MaxDepth, Str) :-
Doc = synthetic_term_to_doc(MaxDepth, Functor, Args, MaybeReturn),
Str = to_string(Width, Doc).
@@ -1602,7 +1602,8 @@
nest(2, ArgDocs)
) `<>`
nest(2, text(" = ") `<>`
- to_doc(Depth - 1, Return)
+ to_doc(Depth - 1,
+ univ_value(Return))
)
)
;
Index: browser/sized_pretty.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/sized_pretty.m,v
retrieving revision 1.9
diff -u -r1.9 sized_pretty.m
--- browser/sized_pretty.m 9 Aug 2004 03:05:20 -0000 1.9
+++ browser/sized_pretty.m 5 Nov 2004 01:32:54 -0000
@@ -272,7 +272,7 @@
LineWidth, Lines, String) :-
Params = measure_params(LineWidth),
functor_browser_term_cc(BrowserDb, BrowserTerm,
- _Functor, Arity, _MaybeReturn),
+ _Functor, Arity, MaybeReturn),
(
Arity \= 0,
Lines \= 0,
@@ -284,7 +284,21 @@
Limit = line_count(Lines)
),
annotate_with_size(BrowserDb, BrowserTerm, Params, Limit, AnnotTerm),
- Doc = to_doc_sized(AnnotTerm),
+ (
+ MaybeReturn = yes,
+ BrowserTerm = synthetic_term(_, _, yes(ReturnValue))
+ ->
+ annotate_with_size(BrowserDb, plain_term(ReturnValue),
+ Params, Limit, AnnotReturn),
+ Doc = group(
+ to_doc_sized(AnnotTerm)
+ `<>` line
+ `<>` nest(2, text(" = ")
+ `<>` to_doc_sized(AnnotReturn))
+ )
+ ;
+ Doc = to_doc_sized(AnnotTerm)
+ ),
String = pprint__to_string(LineWidth, Doc).
%---------------------------------------------------------------------------%
Index: tests/debugger/browse_pretty.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browse_pretty.exp,v
retrieving revision 1.12
diff -u -r1.12 browse_pretty.exp
--- tests/debugger/browse_pretty.exp 17 Jan 2003 05:56:51 -0000 1.12
+++ tests/debugger/browse_pretty.exp 5 Nov 2004 00:09:16 -0000
@@ -6,7 +6,7 @@
mdb> print *
Data (arg 1) big(big(big(small, [|]/2, small), [1, ...], small), [1, 2, 3], big(big/3, [|]/2, small))
mdb> browse 1
-browser> set format raw_pretty
+browser> set format pretty
browser> set depth 10
browser> ls
big(big(big(small, [1], small), [1, 2], small), [1, 2, 3],
@@ -68,7 +68,7 @@
browser> set depth 3
browser> ls
big(big(big(...), ...), [1, ...], ...)
-browser> set format pretty
+browser> set format raw_pretty
browser> set lines 4
browser> set width 40
browser> ls
Index: tests/debugger/browse_pretty.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browse_pretty.inp,v
retrieving revision 1.4
diff -u -r1.4 browse_pretty.inp
--- tests/debugger/browse_pretty.inp 12 Jan 2002 09:08:13 -0000 1.4
+++ tests/debugger/browse_pretty.inp 4 Nov 2004 23:52:26 -0000
@@ -2,7 +2,7 @@
goto 3
print *
browse 1
-set format raw_pretty
+set format pretty
set depth 10
ls
set width 131
@@ -14,7 +14,7 @@
set width 79
set depth 3
ls
-set format pretty
+set format raw_pretty
set lines 4
set width 40
ls
Index: tests/debugger/browser_test.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.exp,v
retrieving revision 1.18
diff -u -r1.18 browser_test.exp
--- tests/debugger/browser_test.exp 25 Oct 2004 05:32:23 -0000 1.18
+++ tests/debugger/browser_test.exp 5 Nov 2004 02:04:51 -0000
@@ -5,13 +5,13 @@
mdb> break big_data
0: + stop interface pred browser_test.big_data/1-0 (det)
mdb> continue
- E2: C2 2 CALL pred browser_test.big_data/1-0 (det) browser_test.m:34 (browser_test.m:20)
+ E2: C2 2 CALL pred browser_test.big_data/1-0 (det) browser_test.m:37 (browser_test.m:20)
mdb> finish
- E3: C2 2 EXIT pred browser_test.big_data/1-0 (det) browser_test.m:34 (browser_test.m:20)
+ E3: C2 2 EXIT pred browser_test.big_data/1-0 (det) browser_test.m:37 (browser_test.m:20)
mdb> delete *
0: E stop interface pred browser_test.big_data/1-0 (det)
mdb> save_to_file 1 browser_test.save.1
-mdb> set format pretty
+mdb> set format raw_pretty
mdb> print *
Data (arg 1)
big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
@@ -32,7 +32,7 @@
mdb> set -AP format flat
mdb> print -f 1
Data (arg 1) big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
-mdb> print -r 1
+mdb> print -p 1
Data (arg 1)
big(big(big(...), ...), 3, ...)
mdb> print -v 1
@@ -54,7 +54,7 @@
2-6
3-small
-mdb> print -p 1
+mdb> print -r 1
Data (arg 1)
big(
big(big(small, 1, small), 2, small),
@@ -119,15 +119,17 @@
mdb> print 1^1^2^3
mdb: the path 3 does not exist.
mdb> retry
- E2: C2 2 CALL pred browser_test.big_data/1-0 (det) browser_test.m:34 (browser_test.m:20)
+ E2: C2 2 CALL pred browser_test.big_data/1-0 (det) browser_test.m:37 (browser_test.m:20)
mdb> break list_data
0: + stop interface pred browser_test.list_data/1-0 (det)
mdb> continue
big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big(small, 5, small)), 6, small)).
- E4: C3 2 CALL pred browser_test.list_data/1-0 (det) browser_test.m:63 (browser_test.m:23)
+ E4: C3 2 CALL pred browser_test.list_data/1-0 (det) browser_test.m:66 (browser_test.m:23)
mdb> finish
- E5: C3 2 EXIT pred browser_test.list_data/1-0 (det) browser_test.m:63 (browser_test.m:23)
+ E5: C3 2 EXIT pred browser_test.list_data/1-0 (det) browser_test.m:66 (browser_test.m:23)
mdb> save_to_file Data browser_test.save.2
+mdb> break a_func
+ 1: + stop interface func browser_test.a_func/1-0 (det)
mdb> continue
seq(1, [big(big(small, 1, small), 2, small), small, big(small, 4, big(small, 5, small))], 5).
browser_test.save.1:
@@ -184,3 +186,45 @@
5
)
+ E6: C4 2 CALL func browser_test.a_func/1-0 (det) browser_test.m:112 (browser_test.m:31)
+mdb> finish
+ E7: C4 2 EXIT func browser_test.a_func/1-0 (det) browser_test.m:112 (browser_test.m:31)
+mdb> print -p
+a_func(big(big(...), ...)) = big(big(...), ...)
+mdb> print -r
+a_func(
+ big(
+ big(big(small, 1, small), 2, small),
+ 3,
+ big(big(small, 4, big(small, 5, small)), 6, small)))
+ = big(
+ big(big(small, 1, small), 2, small),
+ 3,
+ big(big(small, 4, big(small, 5, small)), 6, small))
+mdb> print -v
+a_func
+1-big
+| 1-big
+| | 1-big/3
+| | 2-2
+| | 3-small
+| 2-3
+| 3-big
+| 1-big/3
+| 2-6
+| 3-small
+2-big
+ 1-big
+ | 1-big/3
+ | 2-2
+ | 3-small
+ 2-3
+ 3-big
+ 1-big/3
+ 2-6
+ 3-small
+
+mdb> print -f
+a_func(big(big(big/3, 2, small), 3, big(big/3, 6, small))) = big(big(big/3, 2, small), 3, big(big/3, 6, small))
+mdb> continue
+big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big(small, 5, small)), 6, small))
Index: tests/debugger/browser_test.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.inp,v
retrieving revision 1.10
diff -u -r1.10 browser_test.inp
--- tests/debugger/browser_test.inp 25 Oct 2004 05:32:23 -0000 1.10
+++ tests/debugger/browser_test.inp 5 Nov 2004 01:37:34 -0000
@@ -5,16 +5,16 @@
finish
delete *
save_to_file 1 browser_test.save.1
-set format pretty
+set format raw_pretty
print *
set -A format verbose
print *
browse 1; ls; quit
set -AP format flat
print -f 1
-print -r 1
-print -v 1
print -p 1
+print -v 1
+print -r 1
print --xyzzy 1
browse 1; print; quit
browse -f 1; ls; quit
@@ -48,4 +48,11 @@
continue
finish
save_to_file Data browser_test.save.2
+break a_func
+continue
+finish
+print -p
+print -r
+print -v
+print -f
continue
Index: tests/debugger/browser_test.m
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.m,v
retrieving revision 1.2
diff -u -r1.2 browser_test.m
--- tests/debugger/browser_test.m 13 May 2004 08:50:32 -0000 1.2
+++ tests/debugger/browser_test.m 5 Nov 2004 01:58:41 -0000
@@ -27,7 +27,10 @@
print_file("browser_test.save.2", !IO),
% Clean up after the test.
io__remove_file("browser_test.save.1", _, !IO),
- io__remove_file("browser_test.save.2", _, !IO).
+ io__remove_file("browser_test.save.2", _, !IO),
+ a_func(Data) = Data2,
+ write(Data2, !IO),
+ nl(!IO).
:- pred big_data(big::out) is det.
@@ -103,3 +106,7 @@
OpenRes = error(_),
io__write_string("open failed\n", !IO)
).
+
+:- func a_func(big) = big.
+
+a_func(_) = Big :- big_data(Big).
Index: tests/debugger/declarative/browse_arg.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/browse_arg.exp,v
retrieving revision 1.4
diff -u -r1.4 browse_arg.exp
--- tests/debugger/declarative/browse_arg.exp 27 Oct 2004 02:23:27 -0000 1.4
+++ tests/debugger/declarative/browse_arg.exp 5 Nov 2004 00:12:26 -0000
@@ -8,6 +8,7 @@
2: 2 2 CALL pred browse_arg.p/2-0 (det) browse_arg.m:19 (browse_arg.m:8)
mdb> finish
3: 2 2 EXIT pred browse_arg.p/2-0 (det) browse_arg.m:19 (browse_arg.m:8)
+mdb> set depth 10
mdb> dd
p(1, baz(1, bar))
Valid? browse 2
Index: tests/debugger/declarative/browse_arg.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/browse_arg.inp,v
retrieving revision 1.2
diff -u -r1.2 browse_arg.inp
--- tests/debugger/declarative/browse_arg.inp 27 Oct 2004 02:23:27 -0000 1.2
+++ tests/debugger/declarative/browse_arg.inp 5 Nov 2004 00:00:34 -0000
@@ -3,6 +3,7 @@
break p
continue
finish
+set depth 10
dd
browse 2
ls
Index: tests/debugger/declarative/dependency.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/dependency.exp,v
retrieving revision 1.5
diff -u -r1.5 dependency.exp
--- tests/debugger/declarative/dependency.exp 25 Oct 2004 05:30:18 -0000 1.5
+++ tests/debugger/declarative/dependency.exp 5 Nov 2004 00:12:49 -0000
@@ -18,7 +18,7 @@
18: 3 2 EXIT pred dependency.test/1-0 (cc_multi) dependency.m:19 (dependency.m:13)
mdb> set depth 20
mdb> set size 201
-mdb> set format pretty
+mdb> set format raw_pretty
mdb> p proc_body
proc_rep(
Index: tests/debugger/declarative/dependency.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/dependency.inp,v
retrieving revision 1.2
diff -u -r1.2 dependency.inp
--- tests/debugger/declarative/dependency.inp 20 Oct 2003 07:29:44 -0000 1.2
+++ tests/debugger/declarative/dependency.inp 5 Nov 2004 00:02:16 -0000
@@ -8,7 +8,7 @@
finish
set depth 20
set size 201
-set format pretty
+set format raw_pretty
p proc_body
dd
browse 1
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list