[m-rev.] diff: all_procedures -m

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Feb 14 19:08:52 AEDT 2005


For the main branch only.

Zoltan.

trace/mercury_trace_tables.[ch]:
	Extend the functionality of the existing function for dumping lists
	of procedures to allow the caller to specify that only procedures
	from a given module should be dumped.

trace/mercury_trace_internal.c:
	Change the existing "all_procedures" command to take an option
	specifying the module to be dumped.

doc/user_guide.texi:
	Document the changes to the all_procedures command.

cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.418
diff -u -b -r1.418 user_guide.texi
--- doc/user_guide.texi	14 Feb 2005 05:42:31 -0000	1.418
+++ doc/user_guide.texi	14 Feb 2005 05:54:55 -0000
@@ -3865,9 +3865,13 @@
 If the option @samp{-i} or @samp{--print-instance} option is given,
 it also lists all the instances of each type class.
 @sp 1
- at item all_procedures [-su] @var{filename}
+ at item all_procedures [-su] [-m @var{modulename}] @var{filename}
 @kindex all_procedures (mdb command)
-Puts a list of all the debuggable procedures in the program
+In the absence of the @samp{-m} or @samp{--module} option,
+puts a list of all the debuggable procedures in the program
+into the named file.
+In the presence of the @samp{-m} or @samp{--module} option,
+puts a list of all the debuggable procedures in the names module
 into the named file.
 @sp 1
 If the @samp{-s} or @samp{--separate} option is given,
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.193
diff -u -b -r1.193 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	10 Feb 2005 04:10:33 -0000	1.193
+++ trace/mercury_trace_internal.c	13 Feb 2005 04:43:49 -0000
@@ -608,8 +608,8 @@
                         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);
+                        MR_bool *uci, char **module, char ***words,
+                        int *word_count, const char *cat, const char *item);
 static  MR_bool     MR_trace_options_save_to_file(MR_bool *xml,
                         char ***words, int *word_count, const char *cat, 
                         const char *item);
@@ -5324,12 +5324,14 @@
     MR_bool         separate;
     MR_bool         uci;
     FILE            *fp;
+    char            *module;
 
     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,
+    module = NULL;
+    if (! MR_trace_options_all_procedures(&separate, &uci, &module,
         &words, &word_count, "developer", "all_procedures"))
     {
         ; /* the usage message has already been printed */
@@ -5343,7 +5345,7 @@
             return KEEP_INTERACTING;
         }
 
-        MR_dump_module_tables(fp, separate, uci);
+        MR_dump_module_tables(fp, separate, uci, module);
         if (fclose(fp) != 0) {
             fprintf(MR_mdb_err, "mdb: error writing to `%s': %s.\n",
                 filename, strerror(errno));
@@ -7163,17 +7165,18 @@
 {
     { "separate",   MR_no_argument,     NULL,   's' },
     { "uci",        MR_no_argument,     NULL,   'u' },
+    { "module",     MR_required_argument,   NULL,   'm' },
     { NULL,         MR_no_argument,     NULL,   0 }
 };
 
 static MR_bool
-MR_trace_options_all_procedures(MR_bool *separate, MR_bool *uci,
+MR_trace_options_all_procedures(MR_bool *separate, MR_bool *uci, char **module,
     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",
+    while ((c = MR_getopt_long(*word_count, *words, "sum:",
         MR_trace_all_procedures_opts, NULL)) != EOF)
     {
         switch (c) {
@@ -7184,6 +7187,10 @@
 
             case 'u':
                 *uci = MR_TRUE;
+                break;
+
+            case 'm':
+                *module = MR_optarg;
                 break;
 
             default:
Index: trace/mercury_trace_tables.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_tables.c,v
retrieving revision 1.33
diff -u -b -r1.33 mercury_trace_tables.c
--- trace/mercury_trace_tables.c	28 Jan 2005 02:47:44 -0000	1.33
+++ trace/mercury_trace_tables.c	13 Feb 2005 04:55:38 -0000
@@ -54,6 +54,10 @@
 static  const MR_Module_Layout
                         *MR_search_module_info_by_name(const char *name);
 static  MR_Dlist        *MR_search_module_info_by_nickname(const char *name);
+static  const MR_Module_Layout
+                        *MR_search_module_info_by_unique_name(FILE *fp,
+                            const char *name);
+
 static  void            MR_insert_module_info(const MR_Module_Layout *module);
 static  void            MR_process_matching_procedures_in_module(
                             const MR_Module_Layout *module, MR_Proc_Spec *spec,
@@ -183,6 +187,37 @@
     }
 }
 
+static const MR_Module_Layout *
+MR_search_module_info_by_unique_name(FILE *fp, const char *name)
+{
+    const MR_Module_Layout  *module;
+    const MR_Dlist          *modules;
+    const MR_Dlist          *element_ptr;
+
+    module = MR_search_module_info_by_name(name);
+    if (module == NULL) {
+        modules = MR_search_module_info_by_nickname(name);
+        if (modules == NULL) {
+            fprintf(fp,
+                "There is no debugging info about module `%s'\n", name);
+            return NULL;
+        } else if (MR_dlist_length(modules) != 1) {
+            fprintf(fp, "Module name `%s' is ambiguous.\n", name);
+            fprintf(fp, "The matches are:\n");
+            MR_for_dlist (element_ptr, modules) {
+                module = (const MR_Module_Layout *) MR_dlist_data(element_ptr);
+                fprintf(fp, "%s\n", module->MR_ml_name);
+            }
+
+            return NULL;
+        } else {
+            module = (const MR_Module_Layout *) MR_dlist_first(modules);
+        }
+    }
+
+    return module;
+}
+
 static void
 MR_insert_module_info(const MR_Module_Layout *module)
 {
@@ -265,12 +300,25 @@
 }
 
 void
-MR_dump_module_tables(FILE *fp, MR_bool separate, MR_bool uci)
+MR_dump_module_tables(FILE *fp, MR_bool separate, MR_bool uci,
+    char *module_name)
 {
     int                     i, j;
+    const MR_Module_Layout  *module;
     const MR_Proc_Layout    *proc;
 
+    if (module_name != NULL) {
+        module = MR_search_module_info_by_unique_name(fp, module_name);
+        if (module == NULL) {
+            /* The error message has already been printed */
+            return;
+        }
+    } else {
+        module = NULL;
+    }
+
     for (i = 0; i < MR_module_info_next; i++) {
+        if (module == NULL || module == MR_module_infos[i]) {
         for (j = 0; j < MR_module_infos[i]->MR_ml_proc_count; j++) {
             proc = MR_module_infos[i]->MR_ml_procs[j];
             if (uci || !MR_PROC_LAYOUT_IS_UCI(proc)) {
@@ -284,6 +332,7 @@
             }
         }
     }
+    }
 }
 
 void
@@ -301,33 +350,17 @@
 MR_dump_module_procs(FILE *fp, const char *name)
 {
     const MR_Module_Layout  *module;
-    const MR_Dlist          *modules;
-    const MR_Dlist          *element_ptr;
-    int                     j;
+    int                     i;
 
-    module = MR_search_module_info_by_name(name);
+    module = MR_search_module_info_by_unique_name(fp, name);
     if (module == NULL) {
-        modules = MR_search_module_info_by_nickname(name);
-        if (modules == NULL) {
-            fprintf(fp,
-                "There is no debugging info about module `%s'\n", name);
-            return;
-        } else if (MR_dlist_length(modules) != 1) {
-            fprintf(fp, "Module name `%s' is ambiguous.\n", name);
-            fprintf(fp, "The matches are:\n");
-            MR_for_dlist (element_ptr, modules) {
-                module = (const MR_Module_Layout *) MR_dlist_data(element_ptr);
-                fprintf(fp, "%s\n", module->MR_ml_name);
-            }
+        /* The error message has already been printed */
             return;
-        } else {
-            module = (const MR_Module_Layout *) MR_dlist_first(modules);
-        }
     }
 
     fprintf(fp, "List of procedures in module `%s'\n\n", name);
-    for (j = 0; j < module->MR_ml_proc_count; j++) {
-        MR_print_proc_id_and_nl(fp, module->MR_ml_procs[j]);
+    for (i = 0; i < module->MR_ml_proc_count; i++) {
+        MR_print_proc_id_and_nl(fp, module->MR_ml_procs[i]);
     }
 }
 
Index: trace/mercury_trace_tables.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_tables.h,v
retrieving revision 1.17
diff -u -b -r1.17 mercury_trace_tables.h
--- trace/mercury_trace_tables.h	9 Dec 2004 01:03:22 -0000	1.17
+++ trace/mercury_trace_tables.h	13 Feb 2005 04:44:41 -0000
@@ -54,7 +54,8 @@
 /*
 ** These functions print (parts of) the module info table.
 **
-** MR_dump_module_tables lists all procedures in all modules.
+** MR_dump_module_tables lists all procedures in all modules, unless
+** module is not NULL, in which case lists only procedures in the named module.
 ** Its output can be very big; it should be used only by developers,
 ** for debugging the debugger. The components of procedure names will be
 ** printed in separate fields if the separate argument is true, while the
@@ -67,7 +68,7 @@
 */
 
 extern	void		MR_dump_module_tables(FILE *fp, MR_bool separate,
-				MR_bool uci);
+				MR_bool uci, char *module);
 
 extern	void		MR_dump_module_list(FILE *fp);
 extern	void		MR_dump_module_procs(FILE *fp, const char *name);
--------------------------------------------------------------------------
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