[m-rev.] for post-commit review: print trail state in mdb

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Jun 10 12:30:59 AEST 2008


For post-commit review by anyone.
(I'm committing this because I need it in order to debug other changes
that I am working on.)

Estimated hours taken: 2
Branches: main

Add a new developer-only mdb command, trail_details, that prints out
low-level information concerning the state of the trail.  This includes
things like the current values of the trail pointer and ticket counter.

trace/mercury_trace_internal.c:
trace/mercury_trace_cmd_developer.c:
 	Add the new command.

trace/mercury_trace_cmd_developer.h:
 	Add the new command and delete a prototype for a function not defined
 	by this module.

runtime/mercury_trail.h:
runtime/mercury_trail.c:
 	Add a new function that returns the number of entries on the trail
 	(for the currently executing thread).

doc/user_guide.texi:
 	Document the new command.

 	s/lowlevel/low-level/ in some spots (the latter is consistent with the
 	hyphenation used elsewhere in this documentation.)

 	Break some over-long lines.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
 	Update this for the "trail_details" mdb command.

Julien.

Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.564
diff -u -r1.564 user_guide.texi
--- doc/user_guide.texi	21 May 2008 02:48:54 -0000	1.564
+++ doc/user_guide.texi	10 Jun 2008 02:19:17 -0000
@@ -873,8 +873,11 @@
  The Mmake variables above can be used by @samp{mmc --make} if they
  are set in a file called @file{Mercury.options}. The @file{Mercury.options}
  file has the same syntax as an Mmakefile, but only variable assignments and
- at samp{include} directives are allowed.  All variables in @file{Mercury.options} are treated as if they are assigned using @samp{:=}. Variables may also
-be set in the environment, overriding settings in options files.
+ at samp{include} directives are allowed.
+All variables in @file{Mercury.options} are treated as if they are
+assigned using @samp{:=}.
+Variables may also be set in the environment, overriding settings in
+options files.

  @samp{mmc --make} can be used in conjunction with Mmake. This is useful
  for projects which include source code written in languages other than
@@ -4356,16 +4359,16 @@
  @c @sp 1
  @item flag
  @kindex flag (mdb command)
-Prints the values of all the runtime lowlevel debugging flags.
+Prints the values of all the runtime low-level debugging flags.
  @sp 1
  @item flag @var{flagname}
-Prints the value of the specified runtime lowlevel debugging flag.
+Prints the value of the specified runtime low-level debugging flag.
  @sp 1
  @item flag @var{flagname} on
-Sets the specified runtime lowlevel debugging flag to true.
+Sets the specified runtime low-level debugging flag to true.
  @sp 1
  @item flag @var{flagname} off
-Sets the specified runtime lowlevel debugging flag to false.
+Sets the specified runtime low-level debugging flag to false.
  @sp 1
  @item subgoal @var{n}
  @kindex subgoal (mdb command)
@@ -4592,6 +4595,11 @@
  or their long equivalents, @samp{--types}, or @samp{--functors},
  this command prints ambiguities only for the indicated kinds of constructs.
  The default is to print all ambiguities.
+ at sp 1
+ at item trail_details
+ at kindex trail_details (mdb command)
+Prints out low-level details of the state of the trail.
+In other grades, it reports an error.
  @end table

  @node Declarative debugging
Index: runtime/mercury_trail.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_trail.c,v
retrieving revision 1.14
diff -u -r1.14 mercury_trail.c
--- runtime/mercury_trail.c	10 May 2007 05:24:16 -0000	1.14
+++ runtime/mercury_trail.c	8 Jun 2008 17:32:41 -0000
@@ -72,7 +72,7 @@
          }

          MR_trail_ptr = tr_ptr;
-        /* not needed, since MR_trail_ptr is never a real reg: */
+        /* Not needed, since MR_trail_ptr is never a real reg: */
          /* MR_save_transient_registers(); */
          break;

@@ -81,6 +81,18 @@
      }
  }

+
+MR_Unsigned
+MR_num_trail_entries(void)
+{
+#if defined(MR_THREAD_SAFE)
+    return MR_trail_ptr -
+        (MR_trailEntry *) MR_CONTEXT(MR_ctxt_trailzone)->MR_zone_min;
+#else
+    return MR_trail_ptr - (MR_TrailEntry *) MR_trail_zone->MR_zone_min;
+#endif /* ! MR_THREAD_SAFE */
+}
+
  #endif /* MR_USE_TRAIL */

  /*---------------------------------------------------------------------------*/
Index: runtime/mercury_trail.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_trail.h,v
retrieving revision 1.28
diff -u -r1.28 mercury_trail.h
--- runtime/mercury_trail.h	22 Jan 2008 02:36:37 -0000	1.28
+++ runtime/mercury_trail.h	8 Jun 2008 17:33:26 -0000
@@ -493,4 +493,14 @@

  #define MR_choicepoint_newer(x, y) ((x) > (y))

+/*---------------------------------------------------------------------------*/
+
+/*
+** Return the number of entries on the trail.  In multi-threaded grades
+** this returns the number of entries on the trail for the current context.
+*/
+extern MR_Unsigned
+MR_num_trail_entries(void);
+
+
  #endif /* not MERCURY_TRAIL_H */
Index: tests/debugger/completion.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/completion.exp,v
retrieving revision 1.37
diff -u -r1.37 completion.exp
--- tests/debugger/completion.exp	8 Nov 2007 06:07:34 -0000	1.37
+++ tests/debugger/completion.exp	10 Jun 2008 02:00:37 -0000
@@ -27,22 +27,22 @@
  current              list                 table_io
  cut_stack            list_context_lines   term_size
  d                    list_path            track
-dd                   max_io_actions       trust
-debug_vars           maxdepth             trusted
-delete               mindepth             type_ctor
-dice                 mm_stacks            unalias
-diff                 mmc_options          unhide_events
-disable              modules              untrust
-document             next                 up
-document_category    nondet_stack         user
-down                 open                 user_event_context
-dump                 p                    v
-e                    pass_trace_counts    var_details
-echo                 pneg_stack           vars
-enable               pop_list_dir         view
-exception            print                xml_browser_cmd
-excp                 print_optionals      xml_tmp_filename
-f                    printlevel 
+dd                   max_io_actions       trail_details
+debug_vars           maxdepth             trust
+delete               mindepth             trusted
+dice                 mm_stacks            type_ctor
+diff                 mmc_options          unalias
+disable              modules              unhide_events
+document             next                 untrust
+document_category    nondet_stack         up
+down                 open                 user
+dump                 p                    user_event_context
+e                    pass_trace_counts    v
+echo                 pneg_stack           var_details
+enable               pop_list_dir         vars
+exception            print                view
+excp                 print_optionals      xml_browser_cmd
+f                    printlevel           xml_tmp_filename
  h              help           histogram_exp
  held_vars      histogram_all  hold
  var_details  vars         view 
Index: tests/debugger/mdb_command_test.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/mdb_command_test.inp,v
retrieving revision 1.54
diff -u -r1.54 mdb_command_test.inp
--- tests/debugger/mdb_command_test.inp	7 Jun 2007 06:53:53 -0000	1.54
+++ tests/debugger/mdb_command_test.inp	9 Jun 2008 16:11:02 -0000
@@ -116,3 +116,4 @@
  all_class_decls      xyzzy xyzzy xyzzy xyzzy xyzzy
  all_procedures       xyzzy xyzzy xyzzy xyzzy xyzzy
  ambiguity            xyzzy xyzzy xyzzy xyzzy xyzzy
+trail_details        xyzzy xyzzy xyzzy xyzzy xyzzy
Index: trace/mercury_trace_cmd_developer.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_cmd_developer.c,v
retrieving revision 1.9
diff -u -r1.9 mercury_trace_cmd_developer.c
--- trace/mercury_trace_cmd_developer.c	31 Dec 2007 10:04:06 -0000	1.9
+++ trace/mercury_trace_cmd_developer.c	10 Jun 2008 02:15:03 -0000
@@ -25,6 +25,7 @@
  #include "mercury_types.h"
  #include "mercury_tabling.h"
  #include "mercury_trace_base.h"
+#include "mercury_regs.h"

  #include "mercury_trace_internal.h"
  #include "mercury_trace_cmds.h"
@@ -1344,6 +1345,31 @@
      return KEEP_INTERACTING;
  }

+MR_Next
+MR_trace_cmd_trail_details(char **words, int word_count,
+    MR_TraceCmdInfo *cmd, MR_EventInfo *event_info, MR_Code **jumpaddr)
+{
+
+#if defined(MR_USE_TRAIL)
+
+    fprintf(MR_mdb_out, "trail pointer    : %ld (%lx)\n",
+        (long) MR_trail_ptr, (long) MR_trail_ptr);
+    fprintf(MR_mdb_out, "ticket counter   : %lu\n",
+        (unsigned long) MR_ticket_counter);
+    fprintf(MR_mdb_out, "ticket high water: %lu\n",
+        (unsigned long) MR_ticket_high_water);
+    fprintf(MR_mdb_out, "number of trail entries: %lu\n",
+        (unsigned long) MR_num_trail_entries());
+#else
+
+    fprintf(MR_mdb_out, "mdb: the `trail_details' command is available "
+        "only in trailing grades.\n");
+
+#endif /* ! MR_USE_TRAIL */
+
+    return KEEP_INTERACTING;
+}
+
  /****************************************************************************/

  static void
Index: trace/mercury_trace_cmd_developer.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_cmd_developer.h,v
retrieving revision 1.1
diff -u -r1.1 mercury_trace_cmd_developer.h
--- trace/mercury_trace_cmd_developer.h	4 Apr 2006 07:37:28 -0000	1.1
+++ trace/mercury_trace_cmd_developer.h	26 Apr 2008 17:55:48 -0000
@@ -34,7 +34,7 @@
  extern  MR_TraceCmdFunc     MR_trace_cmd_all_class_decls;
  extern  MR_TraceCmdFunc     MR_trace_cmd_all_procedures;
  extern  MR_TraceCmdFunc     MR_trace_cmd_ambiguity;
-extern  MR_TraceCmdFunc     MR_trace_cmd_dice;
+extern  MR_TraceCmdFunc     MR_trace_cmd_trail_details;

  extern  const char *const   MR_trace_nondet_stack_cmd_args[];
  extern  const char *const   MR_trace_stats_cmd_args[];
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.242
diff -u -r1.242 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	6 Jun 2008 09:48:57 -0000	1.242
+++ trace/mercury_trace_internal.c	8 Jun 2008 16:08:03 -0000
@@ -1695,6 +1695,8 @@
          NULL, MR_trace_filename_completer },
      { "developer", "ambiguity", MR_trace_cmd_ambiguity,
          NULL, MR_trace_filename_completer },
+    { "developer", "trail_details", MR_trace_cmd_trail_details,
+        NULL, MR_trace_filename_completer },

      /* End of doc/mdb_command_list. */
      { NULL, "NUMBER", NULL,

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