[m-rev.] for review: fix two bugs in the management of I/O tabling

Ian MacLarty maclarty at csse.unimelb.edu.au
Mon Sep 24 18:49:56 AEST 2007


On Mon, Sep 24, 2007 at 05:20:57PM +1000, Zoltan Somogyi wrote:
> 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.
> 

I think your diagnosis and fix of the second bug is wrong.  See below.

> 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)

Could you exercise the feature that prints the io actions in chunks.
E.g. create 25 io actions, do "print io" to print the first 20, and then
do "print io" again to print the remaining five?

> 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);
>  

MR_TRACE_CALL_MERCURY and MR_turn_debug_back_on/MR_turn_off_debug seem
to do a lot of the same things (for example they both save and restore
the value of MR_io_tabling_enabled and they both call
MR_update_trace_func_enabled).

At the moment the only thing that MR_turn_off_debug does that
MR_TRACE_CALL_MERCURY doesn't do is save the value of the MR_debugflag
array.

In any case, the declarative debugger does disable tabling of its
own IO actions, because MR_TRACE_CALL_MERCURY sets MR_io_tabling_enabled
to MR_FALSE.

The other changes look fine.

Ian.
--------------------------------------------------------------------------
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