[m-dev.] for review: label_stats

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Jan 8 14:46:05 AEDT 2001


Add a new debugger command for developers: label_stats, which prints a
histogram of the ports associated with labels. Its output can be useful
in making predictions about the impact of proposed changes in the structures
of label layouts.

trace/mercury_trace_tables.[ch]:
	Add the code to print the histogram.

trace/mercury_trace_internal.c:
	Add code to recognize the label_stats command.

doc/user_guide.texi:
	Document the label_stats command, as well as the all_regs and table_io
	commands, which were previously not listed.

doc/mdb_categories:
	Update the list of developer commands.

Zoltan.

cvs diff: Diffing .
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/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
Index: doc/mdb_categories
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/mdb_categories,v
retrieving revision 1.8
diff -u -b -r1.8 mdb_categories
--- doc/mdb_categories	2000/10/12 01:48:23	1.8
+++ doc/mdb_categories	2001/01/07 15:25:13
@@ -56,7 +56,8 @@
 document_category 900 developer
 developer  - Commands that are intended to be of use only to developers
              of the Mercury implementation. The developer commands are
-             `nondet_stack' and `stack_regs'.
+             `nondet_stack', `stack_regs', `all_regs', `table_io' and
+	     `label_stats'.
 
 end
 document_category 1000 misc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.229
diff -u -b -r1.229 user_guide.texi
--- doc/user_guide.texi	2001/01/01 04:03:41	1.229
+++ doc/user_guide.texi	2001/01/07 15:25:56
@@ -2428,6 +2428,25 @@
 @sp 1
 @item all_regs
 Prints the contents of all the virtual machine registers.
+ at sp 1
+ at item table_io
+Reports which phase of I/O tabling we are in at the moment.
+ at sp 1
+ at item table_io stats
+Reports statistics about I/O tabling.
+ at sp 1
+ at item table_io start
+Tells the debugger to start tabling I/O actions.
+ at sp 1
+ at item table_io end
+Tells the debugger to stop tabling I/O actions.
+ at sp 1
+ at item label_stats
+Prints statistics about label layout structures in the program.
+ at sp 1
+ at item label_stats @var{filename}
+Prints statistics about label layout structures in the program
+to the file @var{filename}.
 @end table
 @node Miscellaneous commands
 @subsection Miscellaneous commands
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/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
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/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
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/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 library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
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
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/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/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/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.91
diff -u -b -r1.91 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	2000/12/18 05:16:57	1.91
+++ trace/mercury_trace_internal.c	2001/01/07 15:26:50
@@ -1938,6 +1938,26 @@
 		} else {
 			MR_trace_usage("developer", "table_io");
 		}
+	} else if (streq(words[0], "label_stats")) {
+		if (word_count == 1) {
+			MR_label_layout_stats(MR_mdb_out);
+		} else if (word_count == 2) {
+			FILE	*fp;
+
+			fp = fopen(words[1], "w");
+			if (fp == NULL) {
+				fflush(MR_mdb_out);
+				fprintf(MR_mdb_err,
+					"mdb: error opening `%s': %s.\n",
+					words[1], strerror(errno));
+				return KEEP_INTERACTING;
+			}
+
+			MR_label_layout_stats(fp);
+			(void) fclose(fp);
+		} else {
+			MR_trace_usage("developer", "label_stats");
+		}
 	} else if (streq(words[0], "source")) {
 		bool	ignore_errors;
 
@@ -3034,6 +3054,7 @@
 	{ "developer", "stack_regs" },
 	{ "developer", "all_regs" },
 	{ "developer", "table_io" },
+	{ "developer", "label_stats" },
 	{ "misc", "source" },
 	{ "misc", "save" },
 	{ "misc", "quit" },
Index: trace/mercury_trace_tables.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_tables.c,v
retrieving revision 1.12
diff -u -b -r1.12 mercury_trace_tables.c
--- trace/mercury_trace_tables.c	2000/12/04 04:34:32	1.12
+++ trace/mercury_trace_tables.c	2001/01/07 15:24:40
@@ -437,3 +437,49 @@
 	fprintf(fp, "\n");
 }
 
+void
+MR_label_layout_stats(FILE *fp)
+{
+	const MR_Module_Layout		*module_layout;
+	const MR_Module_File_Layout	*file_layout;
+	const MR_Stack_Layout_Label	*label_layout;
+	int				module_num, file_num, label_num;
+	MR_Trace_Port			port;
+	int				total;
+	int				histogram[MR_PORT_PRAGMA_LATER + 1];
+
+	total = 0;
+	for (port = MR_PORT_CALL; port <= MR_PORT_PRAGMA_LATER; port++) {
+		histogram[port] = 0;
+	}
+
+	for (module_num = 0; module_num < MR_module_info_next; module_num++) {
+		module_layout = MR_module_infos[module_num];
+
+		for (file_num = 0;
+			file_num < module_layout->MR_ml_filename_count;
+			file_num++)
+		{
+			file_layout = module_layout->
+				MR_ml_module_file_layout[file_num];
+
+			for (label_num = 0;
+				label_num < file_layout->MR_mfl_label_count;
+				label_num++)
+			{
+				label_layout = file_layout->
+					MR_mfl_label_layout[label_num];
+
+				total++;
+				histogram[label_layout->MR_sll_port]++;
+			}
+		}
+	}
+
+	for (port = MR_PORT_CALL; port <= MR_PORT_PRAGMA_LATER; port++) {
+		fprintf(fp, "%4s %10d\n",
+			MR_port_names[port],
+			histogram[port]);
+	}
+	fprintf(fp, "%s %10d\n", "all ", total);
+}
Index: trace/mercury_trace_tables.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_tables.h,v
retrieving revision 1.7
diff -u -b -r1.7 mercury_trace_tables.h
--- trace/mercury_trace_tables.h	2000/08/25 09:53:37	1.7
+++ trace/mercury_trace_tables.h	2001/01/07 13:23:20
@@ -146,4 +146,11 @@
 extern	void	MR_print_proc_id_for_debugger(FILE *fp,
 			const MR_Stack_Layout_Entry *entry);
 
+/*
+** MR_label_layout_stats(fp):
+**	Prints statistics about the label layout structures of the program.
+*/
+
+extern	void	MR_label_layout_stats(FILE *fp);
+
 #endif	/* not MERCURY_TRACE_TABLES_H */
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list