[m-dev.] for review: changes to make `--debug' work

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jul 1 16:01:17 AEST 1998


On 30-Jun-1998, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> > +	% --debug (i.e. --stack-trace plus --require-tracing)
> > +	% implies --use-trail.
> 
> This is fine, except this means that according to our conventions this means
> that there is no such thing as a grade asm_fast.g.c.debug; it will be
> asm_fast.g.c.debug.tr (or maybe asm_fast.g.c.tr.debug) instead.

Yes, if you use the option `--grade asm_fast.gc.debug' then the compiler
will actually use grade `asm_fast.gc.debug.tr'.

But your comment made me realize that I need to also modify mgnuc and ml to
follow the same logic.

Here's a new diff that addresses that, and your comments.
I'll commit this one.

--------------------

Various changes to make the `--debug' option work.

compiler/options.m:
	Fix an omission in a previous change of mine:
	add a special_handler for the `--debug' option.

compiler/handle_options.m:	
scripts/mgnuc.in:
scripts/ml.in:
	Make the .debug grade imply --use-trail.  The reason for this is
	to avoid unnecessary proliferation in the number of different grades.
	If you're using .debug, you've already taken a major performance
	hit, so you should be able to afford the performance hit caused
	by --use-trail.
	
configure.in:
	Include a `.tr.debug' grade in LIBGRADES, which holds the set of
	library grades that get installed.

scripts/mdb:
NEWS:
	Update some obsolete documentation referring to the old
	`--generate-trace' option.

NEWS:
	Update some more obsolete documentation listing the commands
	supported by the debugger and describing how to build programs
	with debugging enabled.

Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.105
diff -u -r1.105 NEWS
--- NEWS	1998/06/18 06:05:31	1.105
+++ NEWS	1998/07/01 05:51:16
@@ -359,19 +359,12 @@
 
 * We've added some primitive debugging support.
 
-  The runtime system now includes a *very* rudimentary "four-port" debugger
-  (actually with seven ports).
-  To use this debugger, you need to compile the modules that
-  you wish to debug with the `--generate-trace' option enabled.
-
-  The debugger supports the following commands:
-	a: abort the current execution.
-	c: continue to end, not printing the trace.
-	d: continue to end, printing the trace.
-	n: go to the next trace event.
-	s: skip the current call, not printing trace.
-	p: print the values of the arguments for the current procedure call.
-	j: jump to end of current call, printing trace.
+  The runtime system now includes a rudimentary "four-port" style debugger
+  (actually with eight ports).
+  To use this debugger, you need to build your program with debugging
+  enabled, which is normally done using the `--debug' (or `-g') option,
+  and then run it using the `mdb' command, e.g. `mdb a.out'.
+  Type `h' at the `mtrace>' prompt for a list of the available commands.
 
   XXX We should document this in the Mercury User's Guide.
 
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.132
diff -u -r1.132 configure.in
--- configure.in	1998/06/26 01:17:10	1.132
+++ configure.in	1998/06/30 08:55:19
@@ -1412,6 +1412,9 @@
 	fi
 fi
 
+# add `.debug' (--debug) grades
+LIBGRADES="$LIBGRADES $DEFAULT_GRADE.tr.debug"
+
 # remove GRADE from LIBGRADES
 LIBGRADES=` echo " $LIBGRADES " | sed "s/ $GRADE / /" `
 MERCURY_MSG("using \`LIBGRADES=$LIBGRADES' as the set of library grades to install")
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.56
diff -u -r1.56 handle_options.m
--- handle_options.m	1998/06/18 06:06:11	1.56
+++ handle_options.m	1998/07/01 05:57:25
@@ -266,6 +266,23 @@
 		[]
 	),
 
+	% The `.debug' grade (i.e. --stack-trace plus --require-tracing)
+	% implies --use-trail.
+	%
+	% The reason for this is to avoid unnecessary proliferation in
+	% the number of different grades.  If you're using --debug,
+	% you've already taken a major performance hit, so you should
+	% be able to afford the minor performance hit caused by
+	% --use-trail.
+
+	globals__io_lookup_bool_option(stack_trace, StackTrace),
+	globals__io_lookup_bool_option(require_tracing, RequireTracing),
+	( { StackTrace = yes, RequireTracing = yes } ->
+		globals__io_set_option(use_trail, bool(yes))
+	;
+		[]
+	),
+
 	% Tracing requires 
 	% 	- disabling optimizations that would change 
 	% 	  the trace being generated
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.233
diff -u -r1.233 options.m
--- options.m	1998/06/22 01:06:28	1.233
+++ options.m	1998/07/01 05:53:31
@@ -733,7 +733,7 @@
 % The following options are not allowed, because they're
 % not very useful and would probably only confuse people.
 % long_option("stack-trace",		stack_trace).
-% long_option("require-tracing",		require_tracking).
+% long_option("require-tracing",	require_tracing).
 long_option("use-trail",		use_trail).
 long_option("pic-reg",			pic_reg).
 long_option("tags",			tags).
@@ -943,6 +943,9 @@
 	map__set(OptionTable0, profile_time, bool(no), OptionTable1),
 	map__set(OptionTable1, profile_calls, bool(yes), OptionTable2),
         map__set(OptionTable2, profile_memory, bool(yes), OptionTable).
+special_handler(debug, bool(Value), OptionTable0, ok(OptionTable)) :-
+	map__set(OptionTable0, stack_trace, bool(Value), OptionTable1),
+	map__set(OptionTable1, require_tracing, bool(Value), OptionTable).
 special_handler(inlining, bool(Value), OptionTable0, ok(OptionTable)) :-
 	map__set(OptionTable0, inline_simple, bool(Value), OptionTable1),
 	map__set(OptionTable1, inline_single_use, bool(Value), OptionTable2),
Index: scripts/mdb
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mdb,v
retrieving revision 1.1
diff -u -r1.1 mdb
--- mdb	1998/04/08 11:34:44	1.1
+++ mdb	1998/06/30 09:37:32
@@ -14,8 +14,9 @@
 Description:
 	The arguments of this command form a command line.
 	If the executable named by this command line is a Mercury program
-	compiled with \`--generate-trace', mdb will cause this program to be
-	executed under the supervision of the Mercury internal debugger.
+	compiled with debugging enabled (e.g. via the \`--debug' option),
+	or if it invokes such a program, then mdb will cause the program
+	to be executed under the supervision of the Mercury internal debugger.
 	Otherwise, mdb will execute the command line as if the mdb prefix
 	weren't there.
 Environment variables:
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.51
diff -u -r1.51 mgnuc.in
--- mgnuc.in	1998/06/11 02:42:47	1.51
+++ mgnuc.in	1998/07/01 05:41:49
@@ -187,6 +187,15 @@
 done
 
 #
+# .debug grade implies --use-trail
+#	(see comment in compiler/handle_options.m for rationale)
+#
+case $stack_trace,$require_tracing in
+	true,true)
+		use_trail=true ;;
+esac
+
+#
 # convert mgnuc options into gcc options
 #
 # IMPORTANT: any changes here will require similar changes to
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.44
diff -u -r1.44 ml.in
--- ml.in	1998/06/28 07:46:08	1.44
+++ ml.in	1998/07/01 05:41:26
@@ -250,6 +250,14 @@
 	esac
 esac
 
+#
+# .debug grade implies --use-trail
+#	(see comment in compiler/handle_options.m for rationale)
+#
+case $stack_trace,$require_tracing in
+	true,true)
+		use_trail=true ;;
+esac
 
 #
 # compute the grade from the options settings

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list