[m-rev.] for review: new mdb command all_procedures
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Dec 8 16:12:32 AEDT 2004
Add an mdb command, all_procedures, for listing all the procedures in the
program. It has two options: -u or --uci for listing unify, compare, index and
init predicates, and -s or --separate for printing the various parts of
procedure names in separate fields, for automatic processing (e.g. by awk
scripts).
trace/mercury_trace_internal.c:
Implement all_procedures.
Fix a couple of small bugs: a wrong help category argument in an option
processing call, and a NULL completer function.
trace/mercury_trace_tables.[ch]:
Provide a function that is the guts of all_procedures.
Fix the code for handling the specification of unify, compare and
index procedures to also handle init procedures.
doc/user_guide.texi:
Document all_procedures.
runtime/mercury_stack_trace.[ch]:
Add a new function for printing procedure ids for all_procedures -s.
Fix the code for printing unify, compare and index predicates to also
handle init predicates.
tests/debugger/solver_test.{m,inp,exp}:
A new test case to test the fix of the printing of init predicates.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Add the new test case.
tests/debugger/mdb_command_test.inp:
tests/debugger/completion.exp:
Update these files to account for the new mdb command.
Zoltan.
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/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
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.398
diff -u -b -r1.398 user_guide.texi
--- doc/user_guide.texi 19 Nov 2004 11:54:21 -0000 1.398
+++ doc/user_guide.texi 6 Dec 2004 13:48:10 -0000
@@ -3538,6 +3538,19 @@
@sp 1
If the option @samp{-i} or @samp{--print-instance} option is given,
it also lists all the instances of each type class.
+ at sp 1
+ at item all_procedures [-su] @var{filename}
+ at kindex all_procedures (mdb command)
+Puts a list of all the debuggable procedures in the program
+into the named file.
+ at sp 1
+If the option @samp{-s} or @samp{--separate} option is given,
+the various components of procedure names are separated by spaces.
+ at sp 1
+If the option @samp{-u} or @samp{--uci} option is given,
+the list will include the procedures of
+compiler generated unify, compare, index and initialization predicates.
+Normally, the list includes the procedures of only user defined predicates.
@end table
@node Declarative debugging
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
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/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
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/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
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/odbc
cvs diff: Diffing extras/posix
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/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
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 profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.68
diff -u -b -r1.68 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c 20 Sep 2004 04:50:23 -0000 1.68
+++ runtime/mercury_stack_trace.c 6 Dec 2004 03:48:27 -0000
@@ -77,7 +77,7 @@
static void MR_print_proc_id_internal(FILE *fp,
const MR_Proc_Layout *entry, MR_bool spec,
- MR_bool print_mode);
+ MR_bool print_mode, MR_bool separate);
static void MR_maybe_print_context(FILE *fp,
const char *filename, int lineno);
@@ -1256,24 +1256,30 @@
void
MR_print_proc_id(FILE *fp, const MR_Proc_Layout *entry)
{
- MR_print_proc_id_internal(fp, entry, MR_FALSE, MR_TRUE);
+ MR_print_proc_id_internal(fp, entry, MR_FALSE, MR_TRUE, MR_FALSE);
}
void
MR_print_pred_id(FILE *fp, const MR_Proc_Layout *entry)
{
- MR_print_proc_id_internal(fp, entry, MR_FALSE, MR_FALSE);
+ MR_print_proc_id_internal(fp, entry, MR_FALSE, MR_FALSE, MR_FALSE);
}
void
MR_print_proc_spec(FILE *fp, const MR_Proc_Layout *entry)
{
- MR_print_proc_id_internal(fp, entry, MR_TRUE, MR_TRUE);
+ MR_print_proc_id_internal(fp, entry, MR_TRUE, MR_TRUE, MR_FALSE);
+}
+
+void
+MR_print_proc_separate(FILE *fp, const MR_Proc_Layout *entry)
+{
+ MR_print_proc_id_internal(fp, entry, MR_TRUE, MR_TRUE, MR_TRUE);
}
static void
MR_print_proc_id_internal(FILE *fp, const MR_Proc_Layout *entry, MR_bool spec,
- MR_bool print_mode)
+ MR_bool print_mode, MR_bool separate)
{
const MR_User_Proc_Id *user;
const MR_UCI_Proc_Id *uci;
@@ -1287,20 +1293,29 @@
if (spec) {
if (MR_streq(uci->MR_uci_pred_name, "__Unify__")) {
- fprintf(fp, "unif*");
+ fprintf(fp, "unif");
} else if (MR_streq(uci->MR_uci_pred_name, "__Compare__")) {
- fprintf(fp, "comp*");
+ fprintf(fp, "comp");
} else if (MR_streq(uci->MR_uci_pred_name, "__Index__")) {
- fprintf(fp, "indx*");
+ fprintf(fp, "indx");
+ } else if (MR_streq(uci->MR_uci_pred_name, "__Initialise__")) {
+ fprintf(fp, "init");
} else {
- MR_fatal_error("uci procedure is not unify, compare or index");
+ MR_fatal_error("uci procedure is not "
+ "unify, compare, index or init");
}
- fprintf(fp, "%s.%s/%ld",
+ if (separate) {
+ fprintf(fp, " %s %s %ld",
uci->MR_uci_type_module,
uci->MR_uci_type_name,
(long) uci->MR_uci_type_arity);
-
+ } else {
+ fprintf(fp, "*%s.%s/%ld",
+ uci->MR_uci_type_module,
+ uci->MR_uci_type_name,
+ (long) uci->MR_uci_type_arity);
+ }
} else {
fprintf(fp, "%s for %s.%s/%ld",
uci->MR_uci_pred_name,
@@ -1310,8 +1325,12 @@
}
if (print_mode) {
+ if (separate) {
+ fprintf(fp, " %ld", (long) uci->MR_uci_mode);
+ } else {
fprintf(fp, "-%ld", (long) uci->MR_uci_mode);
}
+ }
if (strcmp(uci->MR_uci_type_module,
uci->MR_uci_def_module) != 0)
@@ -1329,19 +1348,32 @@
MR_fatal_error("procedure is not pred or func");
}
- if (spec) {
+ if (separate) {
+ fprintf(fp, " ");
+ } else if (spec) {
fprintf(fp, "*");
} else {
fprintf(fp, " ");
}
+ if (separate) {
+ fprintf(fp, "%s %s %ld",
+ user->MR_user_decl_module,
+ user->MR_user_name,
+ (long) MR_sle_user_adjusted_arity(entry));
+ } else {
fprintf(fp, "%s.%s/%ld",
user->MR_user_decl_module,
user->MR_user_name,
(long) MR_sle_user_adjusted_arity(entry));
+ }
if (print_mode) {
+ if (separate) {
+ fprintf(fp, " %ld", (long) user->MR_user_mode);
+ } else {
fprintf(fp, "-%ld", (long) user->MR_user_mode);
+ }
}
if (!spec && strcmp(user->MR_user_decl_module,
Index: runtime/mercury_stack_trace.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_stack_trace.h,v
retrieving revision 1.34
diff -u -b -r1.34 mercury_stack_trace.h
--- runtime/mercury_stack_trace.h 20 Sep 2004 04:50:24 -0000 1.34
+++ runtime/mercury_stack_trace.h 6 Dec 2004 03:01:49 -0000
@@ -256,6 +256,14 @@
extern void MR_print_proc_spec(FILE *fp, const MR_Proc_Layout *entry);
/*
+** MR_print_proc_separate prints a string that uniquely specifies the given
+** procedure to the debugger, with each component of a name in a separate field
+** to allow the output to be processed by tools (e.g. awk scripts).
+*/
+
+extern void MR_print_proc_separate(FILE *fp, const MR_Proc_Layout *entry);
+
+/*
** MR_print_proc_id_trace_and_context prints an identification of the given
** procedure, together with call trace information (if available), a context
** within the procedure, and possibly a context identifying the caller.
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/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
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 tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mercury.options,v
retrieving revision 1.9
diff -u -b -r1.9 Mercury.options
--- tests/debugger/Mercury.options 6 Dec 2004 01:32:47 -0000 1.9
+++ tests/debugger/Mercury.options 8 Dec 2004 02:19:32 -0000
@@ -36,6 +36,11 @@
# asm_fast.gc.debug.tr.
MCFLAGS-uci_index = --compare-specialization 2 --intermodule-optimization
+# Solver_test exercises the printing of a procedure name, and that procedure
+# is dead, so we must prevent it being optimized away. The -O2 is to prevent
+# spurious inconsistencies.
+MCFLAGS-solver_test = -O2 --no-optimize-dead-procs
+
# We need to use shared libraries for interactive queries to work.
# The following is necessary for shared libraries to work on Linux.
GRADEFLAGS-interactive = --pic-reg
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.107
diff -u -b -r1.107 Mmakefile
--- tests/debugger/Mmakefile 6 Dec 2004 01:32:48 -0000 1.107
+++ tests/debugger/Mmakefile 6 Dec 2004 02:57:17 -0000
@@ -39,6 +39,7 @@
print_table \
queens_rep \
resume_typeinfos \
+ solver_test \
type_desc_test \
uci_index
@@ -420,6 +421,9 @@
shallow.out: shallow shallow.inp
$(MDB) ./shallow < shallow.inp > shallow.out 2>&1
+
+solver_test.out: solver_test solver_test.inp
+ $(MDB_STD) ./solver_test < solver_test.inp > solver_test.out 2>&1
tabled_read.out: tabled_read tabled_read.inp tabled_read.data
$(MDB_STD) ./tabled_read < tabled_read.inp > tabled_read.out 2>&1
Index: tests/debugger/completion.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/completion.exp,v
retrieving revision 1.22
diff -u -b -r1.22 completion.exp
--- tests/debugger/completion.exp 19 Nov 2004 05:46:16 -0000 1.22
+++ tests/debugger/completion.exp 6 Dec 2004 11:22:16 -0000
@@ -3,10 +3,11 @@
Command echo enabled.
mdb> register --quiet
mdb>
-? document maxdepth scroll
-P document_category mindepth set
-alias down mm_stacks source
-all_class_decls e mmc_options stack
+? disable level scope
+P document maxdepth scroll
+alias document_category mindepth set
+all_class_decls down mm_stacks source
+all_procedures e mmc_options stack
all_regs echo modules stack_regs
all_type_ctors enable next step
b exception nondet_stack subgoal
@@ -26,7 +27,6 @@
dd_dd ignore s vars
debug_vars io_query save view
delete label_stats save_to_file
-disable level scope
h help histogram_all histogram_exp
var_details var_name_stats vars view
var_details var_name_stats vars
Index: tests/debugger/mdb_command_test.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/mdb_command_test.inp,v
retrieving revision 1.33
diff -u -b -r1.33 mdb_command_test.inp
--- tests/debugger/mdb_command_test.inp 16 Nov 2004 00:45:13 -0000 1.33
+++ tests/debugger/mdb_command_test.inp 8 Dec 2004 04:12:40 -0000
@@ -73,3 +73,4 @@
all_type_ctors xyzzy xyzzy xyzzy xyzzy xyzzy
class_decl xyzzy xyzzy xyzzy xyzzy xyzzy
all_class_decls xyzzy xyzzy xyzzy xyzzy xyzzy
+all_procedures xyzzy xyzzy xyzzy xyzzy xyzzy
Index: tests/debugger/solver_test.exp
===================================================================
RCS file: tests/debugger/solver_test.exp
diff -N tests/debugger/solver_test.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/solver_test.exp 8 Dec 2004 02:01:54 -0000
@@ -0,0 +1,18 @@
+ E1: C1 CALL pred solver_test.main/2-0 (det) solver_test.m:23
+mdb> echo on
+Command echo enabled.
+mdb> register --quiet
+mdb> procedures solver_test
+List of procedures in module `solver_test'
+
+__Initialise__ for solver_test.foo/0-0 (det)
+__Compare__ for solver_test.foo/0-0 (det)
+__Unify__ for solver_test.foo/0-0 (semidet)
+pred solver_test.test_any_free_unify/2-0 (det)
+pred solver_test.init_foo/1-0 (det)
+func solver_test.representation to any foo/0/1-0 (det)
+func solver_test.representation to ground foo/0/1-0 (det)
+func solver_test.representation of any foo/0/1-0 (det)
+func solver_test.representation of ground foo/0/1-0 (det)
+pred solver_test.main/2-0 (det)
+mdb> quit -y
Index: tests/debugger/solver_test.inp
===================================================================
RCS file: tests/debugger/solver_test.inp
diff -N tests/debugger/solver_test.inp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/solver_test.inp 6 Dec 2004 02:53:34 -0000
@@ -0,0 +1,4 @@
+echo on
+register --quiet
+procedures solver_test
+quit -y
Index: tests/debugger/solver_test.m
===================================================================
RCS file: tests/debugger/solver_test.m
diff -N tests/debugger/solver_test.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/solver_test.m 6 Dec 2004 23:51:04 -0000
@@ -0,0 +1,49 @@
+% This is a modified copy of hard_coded/any_free_unify.m.
+
+:- module solver_test.
+
+:- interface.
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+% We export this type to prevent the compiler from optimizing away its
+% initialization predicate.
+
+:- solver type foo
+ where representation is int,
+ initialisation is init_foo,
+ ground is ground,
+ any is ground.
+
+:- implementation.
+
+:- import_module std_util, list, bool.
+
+main -->
+ { test_any_free_unify([], Result1) },
+ io__print(Result1), io__nl.
+
+:- pred init_foo(foo::out(any)) is det.
+:- pragma promise_pure(init_foo/1).
+
+init_foo(X) :-
+ impure X = 'representation to any foo/0'(42).
+
+:- pred test_any_free_unify(list(foo), bool).
+:- mode test_any_free_unify(in(list_skel(any)), out) is det.
+
+% In the unification in the condition of the if-then-else, the variable
+% List has an inst which includes `any' components. Normally, we can't
+% check whether `any' has become further instantiated over a goal so we
+% do not allow it in a negated context. However, in this case, the
+% `any' component is unified with `free' so we know that it cannot have
+% become further instantiated. Therefore we should allow the
+% unification in the condition.
+
+test_any_free_unify(List, Result) :-
+ ( List = [_ | _] ->
+ Result = no
+ ;
+ Result = yes
+ ).
cvs diff: Diffing tests/debugger/declarative
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/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.180
diff -u -b -r1.180 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 16 Nov 2004 00:45:14 -0000 1.180
+++ trace/mercury_trace_internal.c 6 Dec 2004 08:34:43 -0000
@@ -466,6 +466,7 @@
static MR_TraceCmdFunc MR_trace_cmd_class_decl;
static MR_TraceCmdFunc MR_trace_cmd_all_type_ctors;
static MR_TraceCmdFunc MR_trace_cmd_all_class_decls;
+static MR_TraceCmdFunc MR_trace_cmd_all_procedures;
static MR_TraceCmdFunc MR_trace_cmd_save;
static MR_TraceCmdFunc MR_trace_cmd_quit;
static MR_TraceCmdFunc MR_trace_cmd_dd;
@@ -540,6 +541,9 @@
static MR_bool MR_trace_options_class_decl(MR_bool *print_methods,
MR_bool *print_instances, char ***words,
int *word_count, const char *cat, const char *item);
+static MR_bool MR_trace_options_all_procedures(MR_bool *separate,
+ MR_bool *uci, char ***words, int *word_count,
+ const char *cat, const char *item);
static void MR_trace_usage(const char *cat, const char *item);
static void MR_trace_do_noop(void);
@@ -4875,7 +4879,7 @@
print_rep = MR_FALSE;
print_functors = MR_FALSE;
if (! MR_trace_options_type_ctor(&print_rep, &print_functors,
- &words, &word_count, "developer", "all_class_decls"))
+ &words, &word_count, "developer", "all_type_ctors"))
{
; /* the usage message has already been printed */
} else if (word_count == 1 || word_count == 2) {
@@ -4980,6 +4984,52 @@
return KEEP_INTERACTING;
}
+static MR_Next
+MR_trace_cmd_all_procedures(char **words, int word_count,
+ MR_Trace_Cmd_Info *cmd, MR_Event_Info *event_info,
+ MR_Event_Details *event_details, MR_Code **jumpaddr)
+{
+ const char *filename;
+ MR_bool separate;
+ MR_bool uci;
+ FILE *fp;
+
+ MR_register_all_modules_and_procs(MR_mdb_out, MR_TRUE);
+
+ separate = MR_FALSE;
+ uci = MR_FALSE;
+ if (! MR_trace_options_all_procedures(&separate, &uci,
+ &words, &word_count, "developer", "all_procedures"))
+ {
+ ; /* the usage message has already been printed */
+ } else if (word_count == 2) {
+ filename = words[1];
+ fp = fopen(filename, "w");
+ if (fp == NULL) {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err,
+ "mdb: error opening `%s': %s.\n",
+ filename, strerror(errno));
+ return KEEP_INTERACTING;
+ }
+
+ MR_dump_module_tables(fp, separate, uci);
+ if (fclose(fp) != 0) {
+ fprintf(MR_mdb_err,
+ "mdb: error writing to `%s': %s.\n",
+ filename, strerror(errno));
+ return KEEP_INTERACTING;
+ } else {
+ fprintf(MR_mdb_out,
+ "mdb: wrote table to `%s'.\n", filename);
+ }
+ } else {
+ MR_trace_usage("developer", "class_decl");
+ }
+
+ return KEEP_INTERACTING;
+}
+
static void
MR_print_type_ctor_info(FILE *fp, MR_TypeCtorInfo type_ctor_info,
MR_bool print_rep, MR_bool print_functors)
@@ -6475,6 +6525,44 @@
return MR_TRUE;
}
+static struct MR_option MR_trace_all_procedures_opts[] =
+{
+ { "separate", MR_no_argument, NULL, 's' },
+ { "uci", MR_no_argument, NULL, 'u' },
+ { NULL, MR_no_argument, NULL, 0 }
+};
+
+static MR_bool
+MR_trace_options_all_procedures(MR_bool *separate, MR_bool *uci,
+ char ***words, int *word_count, const char *cat, const char *item)
+{
+ int c;
+
+ MR_optind = 0;
+ while ((c = MR_getopt_long(*word_count, *words, "su",
+ MR_trace_all_procedures_opts, NULL)) != EOF)
+ {
+ switch (c) {
+
+ case 's':
+ *separate = MR_TRUE;
+ break;
+
+ case 'u':
+ *uci = MR_TRUE;
+ break;
+
+ default:
+ MR_trace_usage(cat, item);
+ return MR_FALSE;
+ }
+ }
+
+ *words = *words + MR_optind - 1;
+ *word_count = *word_count - MR_optind + 1;
+ return MR_TRUE;
+}
+
static void
MR_trace_usage(const char *cat, const char *item)
/* cat is unused now, but could be used later */
@@ -7324,7 +7412,7 @@
{ "misc", "save", MR_trace_cmd_save,
NULL, MR_trace_filename_completer },
{ "misc", "quit", MR_trace_cmd_quit,
- MR_trace_quit_cmd_args, NULL },
+ MR_trace_quit_cmd_args, MR_trace_null_completer },
{ "exp", "histogram_all", MR_trace_cmd_histogram_all,
NULL, MR_trace_filename_completer },
@@ -7381,6 +7469,8 @@
NULL, MR_trace_null_completer },
{ "developer", "all_class_decls", MR_trace_cmd_all_class_decls,
NULL, MR_trace_null_completer },
+ { "developer", "all_procedures", MR_trace_cmd_all_procedures,
+ NULL, MR_trace_filename_completer },
/* End of doc/mdb_command_list. */
{ NULL, "NUMBER", NULL,
Index: trace/mercury_trace_tables.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_tables.c,v
retrieving revision 1.30
diff -u -b -r1.30 mercury_trace_tables.c
--- trace/mercury_trace_tables.c 20 Sep 2004 04:50:26 -0000 1.30
+++ trace/mercury_trace_tables.c 6 Dec 2004 03:52:52 -0000
@@ -271,17 +271,25 @@
}
void
-MR_dump_module_tables(FILE *fp)
+MR_dump_module_tables(FILE *fp, MR_bool separate, MR_bool uci)
{
int i, j;
+ const char *module_name;
+ const MR_Proc_Layout *proc;
for (i = 0; i < MR_module_info_next; i++) {
- fprintf(fp, "====================\n");
- fprintf(fp, "module %s\n", MR_module_infos[i]->MR_ml_name);
- fprintf(fp, "====================\n");
+ module_name = MR_module_infos[i]->MR_ml_name;
for (j = 0; j < MR_module_infos[i]->MR_ml_proc_count; j++) {
- MR_print_proc_id_and_nl(fp,
- MR_module_infos[i]->MR_ml_procs[j]);
+ proc = MR_module_infos[i]->MR_ml_procs[j];
+ if (uci || !MR_PROC_LAYOUT_IS_UCI(proc)) {
+ if (separate) {
+ MR_print_proc_separate(fp, proc);
+ } else {
+ MR_print_proc_id(fp, proc);
+ }
+
+ fprintf(fp, "\n");
+ }
}
}
}
@@ -405,6 +413,9 @@
} else if (MR_strneq(str, "indx*", 5)) {
spec->MR_proc_prefix = MR_PREFIX_INDX;
str += 5;
+ } else if (MR_strneq(str, "init*", 5)) {
+ spec->MR_proc_prefix = MR_PREFIX_INIT;
+ str += 5;
}
/*
@@ -476,6 +487,7 @@
** On return, `*end' points to the start of the trailing number.
** If no number was found, `*end' is unchanged.
*/
+
static MR_bool
MR_parse_trailing_number(char *start, char **end, int *number)
{
Index: trace/mercury_trace_tables.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_tables.h,v
retrieving revision 1.16
diff -u -b -r1.16 mercury_trace_tables.h
--- trace/mercury_trace_tables.h 20 Sep 2004 04:50:26 -0000 1.16
+++ trace/mercury_trace_tables.h 6 Dec 2004 03:53:30 -0000
@@ -56,21 +56,26 @@
**
** MR_dump_module_tables lists all procedures in all modules.
** Its output can be very big; it should be used only by developers,
-** for debugging the debugger.
+** for debugging the debugger. The components of procedure names will be
+** printed in separate fields if the separate argument is true, while the
+** names of compiler-created (unify/compare/index etc) predicates will be
+** printed if the uci argument is true.
**
** MR_dump_module_list lists the names of all the modules,
** while MR_dump_module_procs lists the names of all the procs in the named
** module. These are intended for ordinary, non-developer users.
*/
-extern void MR_dump_module_tables(FILE *fp);
+extern void MR_dump_module_tables(FILE *fp, MR_bool separate,
+ MR_bool uci);
+
extern void MR_dump_module_list(FILE *fp);
extern void MR_dump_module_procs(FILE *fp, const char *name);
/*
** A procedure specification has several components, the meaning of which
** depends on whether the procedure is from a user defined procedure (user)
-** or from a unify, compare or index procedure (uci).
+** or from a unify, compare, index or init procedure (uci).
**
** The meanings of the components are
**
@@ -93,7 +98,8 @@
MR_PREFIX_FUNC,
MR_PREFIX_UNIF,
MR_PREFIX_COMP,
- MR_PREFIX_INDX
+ MR_PREFIX_INDX,
+ MR_PREFIX_INIT
} MR_Proc_Prefix;
typedef struct {
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: 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