[m-rev.] for review: fix two bugs in the management of I/O tabling
Zoltan Somogyi
zs at csse.unimelb.edu.au
Mon Sep 24 17:20:57 AEST 2007
For review by anyone.
Zoltan.
Fix two related bugs in the handling of I/O actions by the debugger. The first
bug was that the procedural debugger didn't implement the documented commands
for printing I/O actions. The second bug was that the declarative debugger
didn't disable the tabling of its own I/O actions.
runtime/mercury_trace_base.[ch]:
Move the code for disabling/enabling deep profiling to the code that
does disabling/enabling of I/O actions, since we now want to do this
from more than one place.
Add a const qualifier to an argument.
trace/mercury_trace_cmd_browsing.c:
Fix the first bug: update the code of the "print" and "browse" mdb
commands to implement their documented capabilities with respect to
printing I/O actions.
Add a new capability: "print io" (or "print action") will now print
a bunch of I/O actions, starting with the first available one, and on
successive invocations will print successive bunches. This is an easy
way to print all I/O actions (without being overwhelmed by a huge
printout if there are too many).
Add a new capability: "print io limits" will now print the numbers of
the first and last I/O actions.
doc/user_guide.texi:
Document the new capabilities.
trace/mercury_trace_declarative.c:
Fix the second bug: disable debugging and then restore the old state
around calls to Mercury code from the declarative debugger.
My guess is that the bug was introduced when we gave declarative
debugging its own trace function; the one it used to share with
the procedural debugger still does the same disable/restore pair.
trace/mercury_trace_internal.c:
Delete the code now moved to mercury_trace_base.c.
trace/mercury_trace_util.[ch]:
Add a utility function for use by the new code in
mercury_trace_cmd_browsing.c, and increase robustness by more
precise representation of unsigned values.
trace/mercury_trace_cmd_dd.c:
Cosmetic fixes.
tests/debugger/declarative/tabled_read_decl.m:
Update this test case to our current coding standards. There are no
changes in the code.
tests/debugger/declarative/tabled_read_decl.{inp,out}:
Test the bug fixes by printing out a bunch of I/O actions.
tests/debugger/declarative/builtin_call_rep.exp:
Update this expected output file to conform for my recent change to
procedure representations.
tests/EXPECT_FAIL_TESTS.asm_fast.gc.decldebug:
Expect the big_array_from_list test to fail in decldebug grades,
since we in that grade we can never get tail recursion, even in the
standard library.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.544
diff -u -b -r1.544 user_guide.texi
--- doc/user_guide.texi 12 Sep 2007 06:21:12 -0000 1.544
+++ doc/user_guide.texi 24 Sep 2007 04:34:25 -0000
@@ -4826,6 +4826,14 @@
@item print io @var{n}- at var{m}
Print the @var{n}th to @var{m}th IO actions (inclusive).
@sp 1
+ at item print io limits
+Print the values for which @samp{print @var{n}} makes sense.
+ at sp 1
+ at item print io
+Print some I/O actions,
+starting just after the last action printed (if there was one)
+or at the first available action (if there was not).
+ at sp 1
@item format @var{format}
Set the default format to @var{format},
which should be one of @samp{flat}, @samp{verbose} and @samp{pretty}.
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_trace_base.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.83
diff -u -b -r1.83 mercury_trace_base.c
--- runtime/mercury_trace_base.c 12 Sep 2007 06:21:16 -0000 1.83
+++ runtime/mercury_trace_base.c 24 Sep 2007 01:39:49 -0000
@@ -1075,10 +1075,14 @@
saved_state->MR_sds_trace_call_seqno = MR_trace_call_seqno;
saved_state->MR_sds_trace_call_depth = MR_trace_call_depth;
saved_state->MR_sds_trace_event_number = MR_trace_event_number;
+
+#if defined(MR_DEEP_PROFILING) && defined(MR_EXEC_TRACE)
+ MR_disable_deep_profiling_in_debugger = MR_TRUE;
+#endif
}
void
-MR_turn_debug_back_on(MR_SavedDebugState *saved_state)
+MR_turn_debug_back_on(const MR_SavedDebugState *saved_state)
{
int i;
@@ -1086,7 +1090,7 @@
MR_update_trace_func_enabled();
MR_io_tabling_enabled = saved_state->MR_sds_io_tabling_enabled;
- for (i = 0; i < MR_MAXFLAG ; i++) {
+ for (i = 0; i < MR_MAXFLAG; i++) {
MR_debugflag[i] = saved_state->MR_sds_debugflags[i];
}
@@ -1095,6 +1099,10 @@
MR_trace_call_depth = saved_state->MR_sds_trace_call_depth;
MR_trace_event_number = saved_state->MR_sds_trace_event_number;
}
+
+#if defined(MR_DEEP_PROFILING) && defined(MR_EXEC_TRACE)
+ MR_disable_deep_profiling_in_debugger = MR_FALSE;
+#endif
}
/**************************************************************************/
Index: runtime/mercury_trace_base.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_trace_base.h,v
retrieving revision 1.61
diff -u -b -r1.61 mercury_trace_base.h
--- runtime/mercury_trace_base.h 12 Sep 2007 06:21:16 -0000 1.61
+++ runtime/mercury_trace_base.h 24 Sep 2007 01:38:13 -0000
@@ -545,7 +545,7 @@
extern void MR_turn_off_debug(MR_SavedDebugState *saved_state,
MR_bool include_counter_vars);
-extern void MR_turn_debug_back_on(MR_SavedDebugState *saved_state);
+extern void MR_turn_debug_back_on(const MR_SavedDebugState *saved_state);
/*
** These functions allow library/exceptions.m to tell the debuggers
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing tests
Index: tests/EXPECT_FAIL_TESTS.asm_fast.gc.decldebug
===================================================================
RCS file: tests/EXPECT_FAIL_TESTS.asm_fast.gc.decldebug
diff -N tests/EXPECT_FAIL_TESTS.asm_fast.gc.decldebug
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/EXPECT_FAIL_TESTS.asm_fast.gc.decldebug 24 Sep 2007 07:15:32 -0000
@@ -0,0 +1 @@
+hard_coded/big_array_from_list
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
Index: tests/debugger/declarative/builtin_call_rep.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/builtin_call_rep.exp,v
retrieving revision 1.3
diff -u -b -r1.3 builtin_call_rep.exp
--- tests/debugger/declarative/builtin_call_rep.exp 20 May 2005 05:40:21 -0000 1.3
+++ tests/debugger/declarative/builtin_call_rep.exp 24 Sep 2007 05:52:17 -0000
@@ -5,7 +5,7 @@
mdb> step
E2: C2 CALL func int.+/2-0 (det)
mdb> print proc_body
- proc_rep([1, 2, 3], atomic_goal_rep(det_rep, "int.m", NN, [3], builtin_call_rep/3))
+ proc_defn_rep([1, 2, 3], atomic_goal_rep(det_rep, "int.m", NN, [3], builtin_call_rep/3))
mdb> browse proc_body
browser> cd 2
browser> ls
Index: tests/debugger/declarative/tabled_read_decl.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/tabled_read_decl.exp,v
retrieving revision 1.17
diff -u -b -r1.17 tabled_read_decl.exp
--- tests/debugger/declarative/tabled_read_decl.exp 22 Aug 2006 02:33:52 -0000 1.17
+++ tests/debugger/declarative/tabled_read_decl.exp 24 Sep 2007 05:51:47 -0000
@@ -1,4 +1,4 @@
- E1: C1 CALL pred tabled_read_decl.main/2-0 (det) tabled_read_decl.m:17
+ E1: C1 CALL pred tabled_read_decl.main/2-0 (det) tabled_read_decl.m:19
mdb> echo on
Command echo enabled.
mdb> register --quiet
@@ -118,6 +118,35 @@
write_int(1789)
Is this a bug? y
E7: C3 EXIT pred tabled_read_decl.part_2/3-0 (det)
+mdb> print io limits
+I/O tabling has recorded actions 0 to 15.
+mdb> print io
+action 0: open_input("tabled_read_decl.data", 0, c_pointer(0xXXXX))
+action 1: read_char_code(c_pointer(0xXXXX), 49)
+action 2: read_char_code(c_pointer(0xXXXX), 50)
+action 3: read_char_code(c_pointer(0xXXXX), 51)
+action 4: read_char_code(c_pointer(0xXXXX), 10)
+action 5: write_int(1123)
+action 6: poly_read_char_code(list(character), c_pointer(0xXXXX), ['a', 'b', 'c'], 52)
+action 7: poly_read_char_code(list(character), c_pointer(0xXXXX), ['a', 'b', 'c'], 53)
+action 8: poly_read_char_code(list(character), c_pointer(0xXXXX), ['a', 'b', 'c'], 54)
+action 9: poly_read_char_code(list(character), c_pointer(0xXXXX), ['a', 'b', 'c'], 10)
+action 10: write_int(1456)
+action 11: read_char_code(c_pointer(0xXXXX), 55)
+action 12: read_char_code(c_pointer(0xXXXX), 56)
+action 13: read_char_code(c_pointer(0xXXXX), 57)
+action 14: read_char_code(c_pointer(0xXXXX), 10)
+action 15: write_int(1789)
+mdb> print io 8
+poly_read_char_code(list(character), c_pointer(0xXXXX), ['a', 'b', 'c'], 54)
+mdb> print action 10-12
+action 10: write_int(1456)
+action 11: read_char_code(c_pointer(0xXXXX), 55)
+action 12: read_char_code(c_pointer(0xXXXX), 56)
+mdb> browse io 9
+browser> p
+poly_read_char_code(list(character), c_pointer(0xXXXX), ['a', 'b', 'c'], 10)
+browser> quit
mdb> break tabled_read_decl.part_3
0: + stop interface pred tabled_read_decl.part_3/2-0 (det)
mdb> c
Index: tests/debugger/declarative/tabled_read_decl.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/tabled_read_decl.inp,v
retrieving revision 1.7
diff -u -b -r1.7 tabled_read_decl.inp
--- tests/debugger/declarative/tabled_read_decl.inp 4 Apr 2006 07:37:24 -0000 1.7
+++ tests/debugger/declarative/tabled_read_decl.inp 24 Sep 2007 04:27:10 -0000
@@ -32,6 +32,13 @@
n
y
y
+print io limits
+print io
+print io 8
+print action 10-12
+browse io 9
+p
+quit
break tabled_read_decl.part_3
c
break tabled_read_decl.fake_io
Index: tests/debugger/declarative/tabled_read_decl.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/tabled_read_decl.m,v
retrieving revision 1.3
diff -u -b -r1.3 tabled_read_decl.m
--- tests/debugger/declarative/tabled_read_decl.m 6 Apr 2005 01:11:31 -0000 1.3
+++ tests/debugger/declarative/tabled_read_decl.m 24 Sep 2007 01:58:00 -0000
@@ -1,3 +1,4 @@
+% vim: ts=4 sw=4 et ft=mercury
% We define our own I/O primitives, in case the library was compiled without
% IO tabling.
@@ -7,97 +8,95 @@
:- import_module io.
-:- pred main(io__state, io__state).
-:- mode main(di, uo) is det.
+:- pred main(io::di, io::uo) is det.
:- implementation.
-:- import_module list, char, int.
-
-main -->
- tabled_read_decl__open_input("tabled_read_decl.data", Res, Stream),
- ( { Res = 0 } ->
- tabled_read_decl__part_1(Stream),
- tabled_read_decl__part_2(Stream),
- tabled_read_decl__part_3
+:- import_module list.
+:- import_module char.
+:- import_module int.
+
+main(!IO) :-
+ tabled_read_decl.open_input("tabled_read_decl.data", Res, Stream, !IO),
+ ( Res = 0 ->
+ tabled_read_decl.part_1(Stream, !IO),
+ tabled_read_decl.part_2(Stream, !IO),
+ tabled_read_decl.part_3(!IO)
;
- io__write_string("could not open tabled_read.data\n")
+ io.write_string("could not open tabled_read.data\n", !IO)
).
-:- pred tabled_read_decl__part_1(c_pointer::in, io__state::di, io__state::uo)
- is det.
+:- pred tabled_read_decl.part_1(c_pointer::in, io::di, io::uo) is det.
-tabled_read_decl__part_1(Stream) -->
- tabled_read_decl__test(Stream, A),
- tabled_read_decl__write_int(A),
- tabled_read_decl__poly_test(Stream, ['a', 'b', 'c'], B),
- tabled_read_decl__write_int(B).
+tabled_read_decl.part_1(Stream, !IO) :-
+ tabled_read_decl.test(Stream, A, !IO),
+ tabled_read_decl.write_int(A, !IO),
+ tabled_read_decl.poly_test(Stream, ['a', 'b', 'c'], B, !IO),
+ tabled_read_decl.write_int(B, !IO).
-:- pred tabled_read_decl__part_2(c_pointer::in, io__state::di, io__state::uo)
- is det.
+:- pred tabled_read_decl.part_2(c_pointer::in, io::di, io::uo) is det.
-tabled_read_decl__part_2(Stream) -->
- tabled_read_decl__test(Stream, A),
- tabled_read_decl__write_int(A).
+tabled_read_decl.part_2(Stream, !IO) :-
+ tabled_read_decl.test(Stream, A, !IO),
+ tabled_read_decl.write_int(A, !IO).
-:- pred tabled_read_decl__part_3(io__state::di, io__state::uo) is det.
+:- pred tabled_read_decl.part_3(io::di, io::uo) is det.
-tabled_read_decl__part_3(!IO) :-
- tabled_read_decl__fake_io(X, !IO),
- tabled_read_decl__write_int(X, !IO).
+tabled_read_decl.part_3(!IO) :-
+ tabled_read_decl.fake_io(X, !IO),
+ tabled_read_decl.write_int(X, !IO).
-:- pred tabled_read_decl__test(c_pointer::in, int::out,
- io__state::di, io__state::uo) is det.
+:- pred tabled_read_decl.test(c_pointer::in, int::out, io::di, io::uo) is det.
-tabled_read_decl__test(Stream, N) -->
+tabled_read_decl.test(Stream, N, !IO) :-
% BUG: the 1 should be 0
- tabled_read_decl__test_2(Stream, 1, N).
+ tabled_read_decl.test_2(Stream, 1, N, !IO).
-:- pred tabled_read_decl__test_2(c_pointer::in, int::in, int::out,
- io__state::di, io__state::uo) is det.
+:- pred tabled_read_decl.test_2(c_pointer::in, int::in, int::out,
+ io::di, io::uo) is det.
-tabled_read_decl__test_2(Stream, SoFar, N) -->
- tabled_read_decl__read_char_code(Stream, CharCode),
+tabled_read_decl.test_2(Stream, SoFar, N, !IO) :-
+ tabled_read_decl.read_char_code(Stream, CharCode, !IO),
(
- { char__to_int(Char, CharCode) },
- { char__is_digit(Char) },
- { char__digit_to_int(Char, CharInt) }
+ char.to_int(Char, CharCode),
+ char.is_digit(Char),
+ char.digit_to_int(Char, CharInt)
->
- tabled_read_decl__test_2(Stream, SoFar * 10 + CharInt, N)
+ tabled_read_decl.test_2(Stream, SoFar * 10 + CharInt, N, !IO)
;
- { N = SoFar }
+ N = SoFar
).
-:- pred tabled_read_decl__poly_test(c_pointer::in, T::in, int::out,
- io__state::di, io__state::uo) is det.
+:- pred tabled_read_decl.poly_test(c_pointer::in, T::in, int::out,
+ io::di, io::uo) is det.
-tabled_read_decl__poly_test(Stream, Unused, N) -->
+tabled_read_decl.poly_test(Stream, Unused, N, !IO) :-
% BUG: the 1 should be 0
- tabled_read_decl__poly_test_2(Stream, Unused, 1, N).
+ tabled_read_decl.poly_test_2(Stream, Unused, 1, N, !IO).
-:- pred tabled_read_decl__poly_test_2(c_pointer::in, T::in, int::in, int::out,
- io__state::di, io__state::uo) is det.
+:- pred tabled_read_decl.poly_test_2(c_pointer::in, T::in, int::in, int::out,
+ io::di, io::uo) is det.
-tabled_read_decl__poly_test_2(Stream, Unused, SoFar, N) -->
- tabled_read_decl__poly_read_char_code(Stream, Unused, CharCode),
+tabled_read_decl.poly_test_2(Stream, Unused, SoFar, N, !IO) :-
+ tabled_read_decl.poly_read_char_code(Stream, Unused, CharCode, !IO),
(
- { char__to_int(Char, CharCode) },
- { char__is_digit(Char) },
- { char__digit_to_int(Char, CharInt) }
+ char.to_int(Char, CharCode),
+ char.is_digit(Char),
+ char.digit_to_int(Char, CharInt)
->
- tabled_read_decl__poly_test_2(Stream, Unused,
- SoFar * 10 + CharInt, N)
+ tabled_read_decl.poly_test_2(Stream, Unused, SoFar * 10 + CharInt, N,
+ !IO)
;
- { N = SoFar }
+ N = SoFar
).
:- pragma c_header_code("#include <stdio.h>").
-:- pred tabled_read_decl__open_input(string::in, int::out, c_pointer::out,
- io__state::di, io__state::uo) is det.
+:- pred tabled_read_decl.open_input(string::in, int::out, c_pointer::out,
+ io::di, io::uo) is det.
:- pragma foreign_proc("C",
- tabled_read_decl__open_input(FileName::in, Res::out, Stream::out,
+ tabled_read_decl.open_input(FileName::in, Res::out, Stream::out,
IO0::di, IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
@@ -106,11 +105,11 @@
IO = IO0;
").
-:- pred tabled_read_decl__read_char_code(c_pointer::in, int::out,
- io__state::di, io__state::uo) is det.
+:- pred tabled_read_decl.read_char_code(c_pointer::in, int::out,
+ io::di, io::uo) is det.
:- pragma foreign_proc("C",
- tabled_read_decl__read_char_code(Stream::in, CharCode::out,
+ tabled_read_decl.read_char_code(Stream::in, CharCode::out,
IO0::di, IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
@@ -118,11 +117,11 @@
IO = IO0;
").
-:- pred tabled_read_decl__poly_read_char_code(c_pointer::in, T::in, int::out,
- io__state::di, io__state::uo) is det.
+:- pred tabled_read_decl.poly_read_char_code(c_pointer::in, T::in, int::out,
+ io::di, io::uo) is det.
:- pragma foreign_proc("C",
- tabled_read_decl__poly_read_char_code(Stream::in, Unused::in,
+ tabled_read_decl.poly_read_char_code(Stream::in, Unused::in,
CharCode::out, IO0::di, IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
@@ -131,21 +130,20 @@
IO = IO0;
").
-:- pred tabled_read_decl__write_int(int::in, io__state::di, io__state::uo)
- is det.
+:- pred tabled_read_decl.write_int(int::in, io::di, io::uo) is det.
:- pragma foreign_proc("C",
- tabled_read_decl__write_int(N::in, IO0::di, IO::uo),
+ tabled_read_decl.write_int(N::in, IO0::di, IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"{
printf(""%d\\n"", (int) N);
IO = IO0;
}").
-:- pred tabled_read_decl__fake_io(int::out, io::di, io::uo) is det.
+:- pred tabled_read_decl.fake_io(int::out, io::di, io::uo) is det.
:- pragma foreign_proc("C",
- tabled_read_decl__fake_io(X::out, IO0::di, IO::uo),
+ tabled_read_decl.fake_io(X::out, IO0::di, IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"{
X = 1;
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_cmd_browsing.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_cmd_browsing.c,v
retrieving revision 1.7
diff -u -b -r1.7 mercury_trace_cmd_browsing.c
--- trace/mercury_trace_cmd_browsing.c 12 Sep 2007 06:21:20 -0000 1.7
+++ trace/mercury_trace_cmd_browsing.c 24 Sep 2007 03:36:30 -0000
@@ -179,13 +179,20 @@
return KEEP_INTERACTING;
}
+#define MR_MAX_NUM_IO_ACTIONS_TO_PRINT 20
+
MR_Next
MR_trace_cmd_print(char **words, int word_count, MR_TraceCmdInfo *cmd,
MR_EventInfo *event_info, MR_Code **jumpaddr)
{
MR_BrowseFormat format;
MR_bool xml;
- int n;
+ const char *problem;
+ MR_Unsigned action;
+ MR_Unsigned lo_action;
+ MR_Unsigned hi_action;
+ static MR_bool have_next_io_action = MR_FALSE;
+ static MR_Unsigned next_io_action = 0;
if (! MR_trace_options_format(&format, &xml, &words, &word_count)) {
; /* the usage message has already been printed */
@@ -193,8 +200,6 @@
/* the --xml option is not valid for print */
MR_trace_usage_cur_cmd();
} else if (word_count == 1) {
- const char *problem;
-
problem = MR_trace_browse_one_goal(MR_mdb_out,
MR_trace_browse_goal_internal, MR_BROWSE_CALLER_PRINT, format);
@@ -203,8 +208,6 @@
fprintf(MR_mdb_err, "mdb: %s.\n", problem);
}
} else if (word_count == 2) {
- const char *problem;
-
if (MR_streq(words[1], "*")) {
problem = MR_trace_browse_all(MR_mdb_out,
MR_trace_browse_internal, format);
@@ -217,6 +220,66 @@
} else if (MR_streq(words[1], "proc_body")) {
problem = MR_trace_browse_proc_body(event_info,
MR_trace_browse_internal, MR_BROWSE_CALLER_PRINT, format);
+ } else if ((MR_streq(words[1], "io") || MR_streq(words[1], "action")))
+ {
+ MR_Unsigned num_printed_actions;
+
+ if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE) {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err,
+ "mdb: I/O tabling has not yet started.\n",
+ MR_io_tabling_start, MR_io_tabling_counter_hwm);
+ return KEEP_INTERACTING;
+ }
+
+ if (MR_io_tabling_counter_hwm == 0) {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err,
+ "mdb: There are no tabled I/O actions yet.\n",
+ MR_io_tabling_start, MR_io_tabling_counter_hwm);
+ return KEEP_INTERACTING;
+ }
+
+ if (have_next_io_action && (!
+ (MR_io_tabling_start <= next_io_action
+ && next_io_action < MR_io_tabling_counter_hwm)))
+ {
+ have_next_io_action = MR_FALSE;
+ }
+
+ if (have_next_io_action) {
+ lo_action = next_io_action;
+ } else {
+ lo_action = MR_io_tabling_start;
+ }
+
+ hi_action = lo_action + MR_MAX_NUM_IO_ACTIONS_TO_PRINT;
+ if (hi_action >= MR_io_tabling_counter_hwm) {
+ hi_action = MR_io_tabling_counter_hwm - 1;
+ }
+
+ num_printed_actions = hi_action - lo_action + 1;
+ if (num_printed_actions <= 0) {
+ fprintf(MR_mdb_out, "There are no I/O actions to print\n");
+ have_next_io_action = MR_FALSE;
+ } else {
+ for (action = lo_action; action <= hi_action; action++) {
+ fprintf(MR_mdb_out,
+ "action %" MR_INTEGER_LENGTH_MODIFIER "u: ", action);
+ problem = MR_trace_browse_action(MR_mdb_out, action,
+ MR_trace_browse_goal_internal,
+ MR_BROWSE_CALLER_PRINT, format);
+
+ if (problem != NULL) {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err, "mdb: %s.\n", problem);
+ return KEEP_INTERACTING;
+ }
+ }
+
+ next_io_action = hi_action + 1;
+ have_next_io_action = MR_TRUE;
+ }
} else {
problem = MR_trace_parse_browse_one(MR_mdb_out, MR_TRUE, words[1],
MR_trace_browse_internal, MR_BROWSE_CALLER_PRINT, format,
@@ -227,18 +290,88 @@
fflush(MR_mdb_out);
fprintf(MR_mdb_err, "mdb: %s.\n", problem);
}
- } else if (word_count == 3 && MR_streq(words[1], "action")
- && MR_trace_is_natural_number(words[2], &n))
+ } else if (word_count == 3 &&
+ (MR_streq(words[1], "io") || MR_streq(words[1], "action")))
{
- const char *problem;
+ if (MR_io_tabling_phase == MR_IO_TABLING_BEFORE) {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err,
+ "mdb: I/O tabling has not yet started.\n",
+ MR_io_tabling_start, MR_io_tabling_counter_hwm);
+ return KEEP_INTERACTING;
+ }
+
+ if (MR_io_tabling_counter_hwm == 0) {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err,
+ "mdb: There are no tabled I/O actions yet.\n",
+ MR_io_tabling_start, MR_io_tabling_counter_hwm);
+ return KEEP_INTERACTING;
+ }
- problem = MR_trace_browse_action(MR_mdb_out, n,
+ if (MR_streq(words[2], "limits")) {
+ fprintf(MR_mdb_out,
+ "I/O tabling has recorded actions "
+ "%" MR_INTEGER_LENGTH_MODIFIER "u to "
+ "%" MR_INTEGER_LENGTH_MODIFIER "u.\n",
+ MR_io_tabling_start, MR_io_tabling_counter_hwm - 1);
+ fflush(MR_mdb_out);
+ } else if (MR_trace_is_natural_number(words[2], &action)) {
+ problem = MR_trace_browse_action(MR_mdb_out, action,
MR_trace_browse_goal_internal,
MR_BROWSE_CALLER_PRINT, format);
if (problem != NULL) {
fflush(MR_mdb_out);
fprintf(MR_mdb_err, "mdb: %s.\n", problem);
+ have_next_io_action = MR_FALSE;
+ }
+
+ next_io_action = action + 1;
+ have_next_io_action = MR_TRUE;
+ } else if (MR_trace_is_natural_number_pair(words[2],
+ &lo_action, &hi_action))
+ {
+ if (lo_action >= hi_action) {
+ /* swap lo_action and hi_action */
+ MR_Unsigned tmp;
+
+ tmp = lo_action;
+ lo_action = hi_action;
+ hi_action = tmp;
+ }
+
+ if (! (MR_io_tabling_start <= lo_action
+ && hi_action < MR_io_tabling_counter_hwm))
+ {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err,
+ "I/O tabling has only recorded actions "
+ "%" MR_INTEGER_LENGTH_MODIFIER "u to "
+ "%" MR_INTEGER_LENGTH_MODIFIER "u.\n",
+ MR_io_tabling_start, MR_io_tabling_counter_hwm - 1);
+ have_next_io_action = MR_FALSE;
+ return KEEP_INTERACTING;
+ }
+
+ for (action = lo_action; action <= hi_action; action++) {
+ fprintf(MR_mdb_out,
+ "action %" MR_INTEGER_LENGTH_MODIFIER "u: ", action);
+ problem = MR_trace_browse_action(MR_mdb_out, action,
+ MR_trace_browse_goal_internal,
+ MR_BROWSE_CALLER_PRINT, format);
+
+ if (problem != NULL) {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err, "mdb: %s.\n", problem);
+ return KEEP_INTERACTING;
+ }
+ }
+
+ next_io_action = hi_action + 1;
+ have_next_io_action = MR_TRUE;
+ } else {
+ MR_trace_usage_cur_cmd();
}
} else {
MR_trace_usage_cur_cmd();
@@ -253,9 +386,10 @@
{
MR_BrowseFormat format;
MR_bool xml;
- int n;
+ int action;
MR_GoalBrowser goal_browser;
MR_Browser browser;
+ const char *problem;
if (! MR_trace_options_format(&format, &xml, &words, &word_count)) {
; /* the usage message has already been printed */
@@ -269,8 +403,6 @@
}
if (word_count == 1) {
- const char *problem;
-
problem = MR_trace_browse_one_goal(MR_mdb_out, goal_browser,
MR_BROWSE_CALLER_BROWSE, format);
@@ -279,8 +411,6 @@
fprintf(MR_mdb_err, "mdb: %s.\n", problem);
}
} else if (word_count == 2) {
- const char *problem;
-
if (MR_streq(words[1], "goal")) {
problem = MR_trace_browse_one_goal(MR_mdb_out, goal_browser,
MR_BROWSE_CALLER_BROWSE, format);
@@ -300,12 +430,11 @@
fflush(MR_mdb_out);
fprintf(MR_mdb_err, "mdb: %s.\n", problem);
}
- } else if (word_count == 3 && MR_streq(words[1], "action")
- && MR_trace_is_natural_number(words[2], &n))
+ } else if (word_count == 3 &&
+ (MR_streq(words[1], "io") || MR_streq(words[1], "action"))
+ && MR_trace_is_natural_number(words[2], &action))
{
- const char *problem;
-
- problem = MR_trace_browse_action(MR_mdb_out, n, goal_browser,
+ problem = MR_trace_browse_action(MR_mdb_out, action, goal_browser,
MR_BROWSE_CALLER_BROWSE, format);
if (problem != NULL) {
Index: trace/mercury_trace_cmd_dd.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_cmd_dd.c,v
retrieving revision 1.3
diff -u -b -r1.3 mercury_trace_cmd_dd.c
--- trace/mercury_trace_cmd_dd.c 7 Jun 2007 06:53:54 -0000 1.3
+++ trace/mercury_trace_cmd_dd.c 24 Sep 2007 01:26:33 -0000
@@ -87,12 +87,14 @@
decl_mode = MR_DECL_NODUMP;
filename = (const char *) NULL;
}
+
if (MR_trace_have_unhid_events) {
fflush(MR_mdb_out);
fprintf(MR_mdb_err,
"mdb: dd doesn't work after `unhide_events on'.\n");
return KEEP_INTERACTING;
}
+
if (search_mode_requires_trace_counts && (
pass_trace_counts_file == NULL || fail_trace_counts_file == NULL))
{
@@ -102,6 +104,7 @@
"files\nbefore using the specified search mode.\n");
return KEEP_INTERACTING;
}
+
if (pass_trace_counts_file != NULL && fail_trace_counts_file != NULL) {
if (! MR_trace_decl_init_suspicion_table(pass_trace_counts_file,
fail_trace_counts_file, &problem))
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.112
diff -u -b -r1.112 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c 31 Jul 2007 05:48:21 -0000 1.112
+++ trace/mercury_trace_declarative.c 24 Sep 2007 01:42:41 -0000
@@ -1722,6 +1722,7 @@
MR_RetryResult retry_result;
int retry_distance;
MR_bool unsafe_retry;
+ int counter_depth;
MR_edt_unsafe_retry_already_asked = MR_FALSE;
@@ -1798,8 +1799,8 @@
** the number of desired nodes divided by two, since the minimum
** number of events at each depth will be 2 (the CALL and EXIT).
*/
- MR_trace_init_implicit_subtree_counters(
- MR_edt_desired_nodes_in_subtree / 2 + 1);
+ counter_depth = (MR_edt_desired_nodes_in_subtree / 2) + 1;
+ MR_trace_init_implicit_subtree_counters(counter_depth);
/*
** Single step through every event.
@@ -1831,6 +1832,7 @@
MR_TraceNode call_preceding;
MercuryFile stream;
MR_Integer requested_subtree_depth;
+ MR_SavedDebugState saved_debug_state;
if (MR_edt_compiler_flag_warning) {
fflush(MR_mdb_out);
@@ -1841,6 +1843,7 @@
}
if (MR_decl_mode == MR_DECL_DUMP && new_tree) {
+ MR_turn_off_debug(&saved_debug_state, MR_TRUE);
MR_mercuryfile_init(MR_trace_store_file, 1, &stream);
MR_TRACE_CALL_MERCURY(
@@ -1848,6 +1851,8 @@
MR_trace_node_store, root);
);
+ MR_turn_debug_back_on(&saved_debug_state);
+
fclose(MR_trace_store_file);
MR_selected_trace_func_ptr = MR_trace_real;
MR_debug_enabled = MR_TRUE;
@@ -1869,6 +1874,7 @@
MR_selected_trace_func_ptr = MR_trace_real_decl;
}
+ MR_turn_off_debug(&saved_debug_state, MR_TRUE);
MR_TRACE_CALL_MERCURY(
if (new_tree) {
MR_DD_decl_diagnosis_new_tree(MR_trace_node_store,
@@ -1899,6 +1905,7 @@
(MR_Integer *) &final_event,
(MR_Integer *) &topmost_seqno);
);
+ MR_turn_debug_back_on(&saved_debug_state);
/*
** Turn off interactive debugging after the diagnosis in case a new
@@ -1918,8 +1925,8 @@
if (no_bug_found) {
/*
- ** No bug found. Return to the procedural debugger at the
- ** event where the `dd' command was initially given.
+ ** No bug found. Return to the procedural debugger at the event
+ ** where the `dd' command was initially given.
*/
return MR_decl_go_to_selected_event(MR_edt_initial_event, cmd,
event_info);
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.236
diff -u -b -r1.236 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 19 Jun 2007 03:12:50 -0000 1.236
+++ trace/mercury_trace_internal.c 24 Sep 2007 01:40:50 -0000
@@ -216,9 +216,6 @@
*/
MR_turn_off_debug(&MR_saved_debug_state, MR_FALSE);
-#if defined(MR_DEEP_PROFILING) && defined(MR_EXEC_TRACE)
- MR_disable_deep_profiling_in_debugger = MR_TRUE;
-#endif
MR_trace_internal_ensure_init();
MR_trace_browse_ensure_init();
@@ -260,9 +257,6 @@
MR_scroll_next = 0;
MR_turn_debug_back_on(&MR_saved_debug_state);
-#if defined(MR_DEEP_PROFILING) && defined(MR_EXEC_TRACE)
- MR_disable_deep_profiling_in_debugger = MR_FALSE;
-#endif
return jumpaddr;
}
Index: trace/mercury_trace_util.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_util.c,v
retrieving revision 1.22
diff -u -b -r1.22 mercury_trace_util.c
--- trace/mercury_trace_util.c 29 Nov 2006 05:18:41 -0000 1.22
+++ trace/mercury_trace_util.c 24 Sep 2007 04:31:53 -0000
@@ -29,7 +29,7 @@
}
MR_bool
-MR_trace_is_natural_number(const char *word, int *value)
+MR_trace_is_natural_number(const char *word, MR_Unsigned *value)
{
if (word != NULL && MR_isdigit(*word)) {
*value = *word - '0';
@@ -48,6 +48,39 @@
}
MR_bool
+MR_trace_is_natural_number_pair(const char *word,
+ MR_Unsigned *value1, MR_Unsigned *value2)
+{
+ if (word != NULL && MR_isdigit(*word)) {
+ *value1 = *word - '0';
+ word++;
+ while (MR_isdigit(*word)) {
+ *value1 = (*value1 * 10) + *word - '0';
+ word++;
+ }
+
+ if (*word == '-') {
+ word++;
+
+ if (MR_isdigit(*word)) {
+ *value2 = *word - '0';
+ word++;
+ while (MR_isdigit(*word)) {
+ *value2 = (*value2 * 10) + *word - '0';
+ word++;
+ }
+
+ if (*word == '\0') {
+ return MR_TRUE;
+ }
+ }
+ }
+ }
+
+ return MR_FALSE;
+}
+
+MR_bool
MR_trace_is_unsigned(const char *word, MR_Unsigned *value)
{
if (word != NULL && MR_isdigit(*word)) {
Index: trace/mercury_trace_util.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_util.h,v
retrieving revision 1.18
diff -u -b -r1.18 mercury_trace_util.h
--- trace/mercury_trace_util.h 29 Nov 2006 05:18:41 -0000 1.18
+++ trace/mercury_trace_util.h 24 Sep 2007 02:02:58 -0000
@@ -38,6 +38,9 @@
** number, i.e. a sequence of digits. If yes, it puts the value of the number
** in *value (an int) and returns MR_TRUE, otherwise it returns MR_FALSE.
**
+** MR_trace_is_natural_number_pair looks for a pair of natural numbers
+** separated by a '-' character.
+**
** MR_trace_is_unsigned is similar, but puts the value of the number in a
** location of type MR_Unsigned.
**
@@ -52,7 +55,11 @@
** type. MR_trace_is_integer doesn't even work for MININT.
*/
-extern MR_bool MR_trace_is_natural_number(const char *word, int *value);
+extern MR_bool MR_trace_is_natural_number(const char *word,
+ MR_Unsigned *value);
+
+extern MR_bool MR_trace_is_natural_number_pair(const char *word,
+ MR_Unsigned *value1, MR_Unsigned *value2);
extern MR_bool MR_trace_is_unsigned(const char *word, MR_Unsigned *value);
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list