for review: add `--debug' grade

Fergus Henderson fjh at cs.mu.OZ.AU
Wed May 20 04:23:13 AEST 1998


Hi,

Zoltan, can you please review this one?

Estimated hours taken: 4

Add a `--debug' option for Mercury-level debugging
using the trace-based debugger.

scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/ml.in:
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
	Split the old `--debug' option into `--low-level-debug'
	(formerly the absence of -DSPEED, now handle by -DLOWLEVEL_DEBUG)
	and `--c-debug' (passes -g to C compiler).
	Delete the old `debug' grade.
	Add support for new options `--require-tracing'
	(makes --trace minimum equivalent to --trace interfaces,
	and passes -DMR_REQUIRE_TRACING to C compiler)
	`--stack-trace' (passes -DMR_STACK_TRACE to C compiler;
	actually this one was already supported)
	and `--debug' (implies previous two),
	with corresponding grade modifiers `.trace', `.strce', and `.debug'.
	Actually I think there's little point in specifying just one
	of `--require-tracing' and `--stack-trace' so for the moment
	I'm just providing `--debug': the code for the more fine-grained
	options and grade modifiers has been added but commented out.

runtime/mercury_conf_param.h:
	Document the new configuration parameter MR_REQUIRE_TRACING
	and the existing but undocumented parameter MR_STACK_TRACE.

runtime/mercury_grade.h:
	Include MR_REQUIRE_TRACING in the mangled grade identifier.

compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
	Allow new tracing type `--trace default', and make it the default.
	This gets replaced with `full' if require_tracing is yes
	or `minimal' if require_tracing is no.
	Also `--trace minimum' gets replaced with `interface' if
	require_tracing is yes.

doc/user_guide.texi:
	Document the new `--debug', `--low-level-debug', and `--c-debug'
	options.

cvs diff  compiler/globals.m compiler/handle_options.m compiler/mercury_compile.m compiler/options.m doc/user_guide.texi runtime/mercury_conf_param.h runtime/mercury_grade.h scripts/init_grade_options.sh-subr scripts/mgnuc.in scripts/ml.in scripts/parse_grade_options.sh-subr
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.28
diff -u -r1.28 globals.m
--- globals.m	1998/05/17 07:18:21	1.28
+++ globals.m	1998/05/19 17:39:48
@@ -56,7 +56,8 @@
 :- pred convert_args_method(string::in, args_method::out) is semidet.
 :- pred convert_prolog_dialect(string::in, prolog_dialect::out) is semidet.
 :- pred convert_termination_norm(string::in, termination_norm::out) is semidet.
-:- pred convert_trace_level(string::in, trace_level::out) is semidet.
+:- pred convert_trace_level(string::in, bool::in, trace_level::out) is semidet.
+	% the bool should be the setting of the `require_tracing' option.
 
 %-----------------------------------------------------------------------------%
 
@@ -191,9 +192,12 @@
 convert_termination_norm("num-data-elems", num_data_elems).
 convert_termination_norm("size-data-elems", size_data_elems).
 
-convert_trace_level("minimum", minimal).
-convert_trace_level("interfaces", interface).
-convert_trace_level("all", full).
+convert_trace_level("minimum", no, minimal).
+convert_trace_level("minimum", yes, interface).
+convert_trace_level("interfaces", _, interface).
+convert_trace_level("all", _, full).
+convert_trace_level("default", no, minimal).
+convert_trace_level("default", yes, full).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.50
diff -u -r1.50 handle_options.m
--- handle_options.m	1998/05/18 02:04:57	1.50
+++ handle_options.m	1998/05/19 18:04:14
@@ -147,16 +147,20 @@
                             { convert_termination_norm(TermNormStr, TermNorm) }
                         ->
                             { map__lookup(OptionTable, trace, Trace) },
+                            { map__lookup(OptionTable, require_tracing,
+			    	RequireTracingOpt) },
                             (
                                 { Trace = string(TraceStr) },
-                                { convert_trace_level(TraceStr, TraceLevel) }
+                                { RequireTracingOpt = bool(RequireTracing) },
+                                { convert_trace_level(TraceStr, RequireTracing,
+				    TraceLevel) }
                             ->
                                 postprocess_options_2(OptionTable,
                                     GC_Method, TagsMethod, ArgsMethod,
                                     PrologDialect, TermNorm, TraceLevel),
                                 { Error = no }
                             ;
-                                { Error = yes("Invalid argument to option `--trace'\n\t(must be `minimum', `interfaces' or  `all').") }
+                                { Error = yes("Invalid argument to option `--trace'\n\t(must be `minimum', `interfaces', `all', or `default').") }
                             )
                         ;
                             { Error = yes("Invalid argument to option `--termination-norm'\n\t(must be `simple', `total' or  `num-data-elems').") }
@@ -429,7 +433,8 @@
 	globals__lookup_bool_option(Globals, unboxed_float, UnboxedFloat),
 */
 	globals__get_args_method(Globals, ArgsMethod),
-	globals__lookup_bool_option(Globals, debug, Debug),
+	globals__lookup_bool_option(Globals, stack_trace, StackTrace),
+	globals__lookup_bool_option(Globals, require_tracing, RequireTracing),
 /*
 	globals__lookup_bool_option(Globals, pic_reg, PIC_Reg),
 */
@@ -517,10 +522,18 @@
 	; ArgsMethod = simple, Part8 = ".sa"
 	),
 
-	( Debug = yes ->
-		Part9 = ".debug"
+	( StackTrace = yes ->
+		( RequireTracing = yes ->
+			Part9 = ".debug"
+		;
+			Part9 = ".strce"
+		)
 	;
-		Part9 = ""
+		( RequireTracing = yes ->
+			Part9 = ".trace"
+		;
+			Part9 = ""
+		)
 	),
 
 /*******
@@ -553,10 +566,20 @@
 	% part9
 	( { string__remove_suffix(Grade2, ".debug", Grade3) } ->
 		{ Grade4 = Grade3 },
-		set_bool_opt(debug, yes)
+		set_bool_opt(stack_trace, yes),
+		set_bool_opt(require_tracing, yes)
+	; { string__remove_suffix(Grade2, ".trace", Grade3) } ->
+		{ Grade4 = Grade3 },
+		set_bool_opt(stack_trace, no),
+		set_bool_opt(require_tracing, yes)
+	; { string__remove_suffix(Grade2, ".strce", Grade3) } ->
+		{ Grade4 = Grade3 },
+		set_bool_opt(stack_trace, yes),
+		set_bool_opt(require_tracing, no)
 	;
 		{ Grade4 = Grade2 },
-		set_bool_opt(debug, no)
+		set_bool_opt(stack_trace, no),
+		set_bool_opt(require_tracing, no)
 	),
 	% part8
 	( { string__remove_suffix(Grade4, ".sa", Grade5) } ->
@@ -638,44 +661,32 @@
 	is semidet.
 
 convert_grade_option_2("asm_fast") -->
-	set_bool_opt(debug, no),
 	set_bool_opt(c_optimize, yes),
 	set_bool_opt(gcc_non_local_gotos, yes),
 	set_bool_opt(gcc_global_registers, yes),
 	set_bool_opt(asm_labels, yes).
 convert_grade_option_2("fast") -->
-	set_bool_opt(debug, no),
 	set_bool_opt(c_optimize, yes),
 	set_bool_opt(gcc_non_local_gotos, yes),
 	set_bool_opt(gcc_global_registers, yes),
 	set_bool_opt(asm_labels, no).
 convert_grade_option_2("asm_jump") -->
-	set_bool_opt(debug, no),
 	set_bool_opt(c_optimize, yes),
 	set_bool_opt(gcc_non_local_gotos, yes),
 	set_bool_opt(gcc_global_registers, no),
 	set_bool_opt(asm_labels, yes).
 convert_grade_option_2("jump") -->
-	set_bool_opt(debug, no),
 	set_bool_opt(c_optimize, yes),
 	set_bool_opt(gcc_non_local_gotos, yes),
 	set_bool_opt(gcc_global_registers, no),
 	set_bool_opt(asm_labels, no).
 convert_grade_option_2("reg") -->
-	set_bool_opt(debug, no),
 	set_bool_opt(c_optimize, yes),
 	set_bool_opt(gcc_non_local_gotos, no),
 	set_bool_opt(gcc_global_registers, yes),
 	set_bool_opt(asm_labels, no).
 convert_grade_option_2("none") -->
-	set_bool_opt(debug, no),
 	set_bool_opt(c_optimize, yes),
-	set_bool_opt(gcc_non_local_gotos, no),
-	set_bool_opt(gcc_global_registers, no),
-	set_bool_opt(asm_labels, no).
-convert_grade_option_2("debug") -->
-	set_bool_opt(debug, yes),
-	set_bool_opt(c_optimize, no),
 	set_bool_opt(gcc_non_local_gotos, no),
 	set_bool_opt(gcc_global_registers, no),
 	set_bool_opt(asm_labels, no).
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.87
diff -u -r1.87 mercury_compile.m
--- mercury_compile.m	1998/05/16 07:30:23	1.87
+++ mercury_compile.m	1998/05/19 17:33:58
@@ -2030,11 +2030,29 @@
 	{ string__int_to_string(NumTagBits, NumTagBitsString) },
 	{ string__append_list(
 		["-DTAGBITS=", NumTagBitsString, " "], NumTagBitsOpt) },
-	globals__io_lookup_bool_option(debug, Debug),
-	{ Debug = yes ->
-		DebugOpt = "-g "
+	globals__io_lookup_bool_option(require_tracing, RequireTracing),
+	{ RequireTracing = yes ->
+		RequireTracingOpt = "-DMR_REQUIRE_TRACING "
 	;
-		DebugOpt = "-DSPEED "
+		RequireTracingOpt = ""
+	},
+	globals__io_lookup_bool_option(stack_trace, StackTrace),
+	{ StackTrace = yes ->
+		StackTraceOpt = "-DMR_STACK_TRACE "
+	;
+		StackTraceOpt = ""
+	},
+	globals__io_lookup_bool_option(c_debug, C_Debug),
+	{ C_Debug = yes ->
+		C_DebugOpt = "-g "
+	;
+		C_DebugOpt = ""
+	},
+	globals__io_lookup_bool_option(low_level_debug, LL_Debug),
+	{ LL_Debug = yes ->
+		LL_DebugOpt = "-DMR_LOW_LEVEL_DEBUG "
+	;
+		LL_DebugOpt = ""
 	},
 	{ string__sub_string_search(CC, "gcc", _) ->
 		CompilerType = gcc
@@ -2062,7 +2080,7 @@
 		TypeLayoutOpt = ""
 	},
 	globals__io_lookup_bool_option(c_optimize, C_optimize),
-	{ C_optimize = yes, Debug = no ->
+	{ C_optimize = yes, C_Debug = no ->
 		( CompilerType = gcc ->
 			OptimizeOpt = "-O2 -fomit-frame-pointer "
 		; CompilerType = lcc ->
@@ -2101,7 +2119,9 @@
 		RegOpt, GotoOpt, AsmOpt,
 		CFLAGS_FOR_REGS, " ", CFLAGS_FOR_GOTOS, " ",
 		GC_Opt, ProfileCallsOpt, ProfileTimeOpt, ProfileMemoryOpt,
-		PIC_Reg_Opt, TagsOpt, NumTagBitsOpt, DebugOpt,
+		PIC_Reg_Opt, TagsOpt, NumTagBitsOpt,
+		C_DebugOpt, LL_DebugOpt,
+		StackTraceOpt, RequireTracingOpt,
 		UseTrailOpt, ArgsOpt, TypeLayoutOpt,
 		InlineAllocOpt, WarningOpt, CFLAGS,
 		" -c ", C_File, " -o ", O_File], Command) },
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.229
diff -u -r1.229 options.m
--- options.m	1998/05/16 22:32:41	1.229
+++ options.m	1998/05/19 17:46:00
@@ -120,11 +120,11 @@
 		;	profile_calls
 		;	profile_time
 		;	profile_memory
+		;	debug
 		;	stack_trace
+		;	require_tracing
 		;	use_trail
 		;	pic_reg
-		;	debug
-		;	debug_data
 		;	tags
 		;	num_tag_bits
 		;	bits_per_word
@@ -161,6 +161,7 @@
 		;	highlevel_c
 		;	unboxed_float
 	% Code generation options
+		;	low_level_debug
 		;	trad_passes
 		;	polymorphism
 		;	reclaim_heap_on_failure
@@ -176,6 +177,7 @@
 		;	cflags
 		;	cflags_for_regs
 		;	cflags_for_gotos
+		;	c_debug
 		;	c_include_directory
 		;	aditi
 		;	fact_table_max_array_size
@@ -359,7 +361,7 @@
 option_defaults_2(aux_output_option, [
 		% Auxiliary Output Options
 	assume_gmake		-	bool(yes),
-	trace			-	string("minimum"),
+	trace			-	string("default"),
 	generate_bytecode	-	bool(no),
 	generate_prolog		-	bool(no),
 	prolog_dialect		-	string("default"),
@@ -398,10 +400,11 @@
 	profile_calls		-	bool(no),
 	profile_time		-	bool(no),
 	profile_memory		-	bool(no),
+	debug			-	bool_special,
+	require_tracing		-	bool(no),
 	stack_trace		-	bool(no),
 	use_trail		-	bool(no),
 	pic_reg			-	bool(no),
-	debug			-	bool(no),
 	tags			-	string("low"),
 	num_tag_bits		-	int(-1),
 					% -1 is a special value which means
@@ -429,6 +432,7 @@
 ]).
 option_defaults_2(code_gen_option, [
 		% Code Generation Options
+	low_level_debug		-	bool(no),
 	trad_passes		-	bool(yes),
 	polymorphism		-	bool(yes),
 	lazy_code		-	bool(yes),
@@ -456,6 +460,7 @@
 					% the `mmc' script will override the
 					% above two defaults with values
 					% determined at configuration time
+	c_debug			-	bool(no),
 	c_include_directory	-	string(""),
 					% the `mmc' script will override the
 					% above default with a value determined
@@ -713,10 +718,13 @@
 long_option("profile-calls",		profile_calls).
 long_option("profile-time",		profile_time).
 long_option("profile-memory",		profile_memory).
-long_option("stack-trace",		stack_trace).
+long_option("debug",			debug).
+% 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("use-trail",		use_trail).
 long_option("pic-reg",			pic_reg).
-long_option("debug",			debug).
 long_option("tags",			tags).
 long_option("num-tag-bits",		num_tag_bits).
 long_option("bits-per-word",		bits_per_word).
@@ -737,6 +745,7 @@
 long_option("unboxed-float",		unboxed_float).
 
 % code generation options
+long_option("low-level-debug",		low_level_debug).
 long_option("polymorphism",		polymorphism).
 long_option("trad-passes",		trad_passes).
 long_option("lazy-code",		lazy_code).
@@ -756,6 +765,7 @@
 long_option("cflags",			cflags).
 long_option("cflags-for-regs",		cflags_for_regs).
 long_option("cflags-for-gotos",		cflags_for_gotos).
+long_option("c-debug",			c_debug).
 long_option("c-include-directory",	c_include_directory).
 long_option("fact-table-max-array-size",fact_table_max_array_size).
 long_option("fact-table-hash-percent-full",
@@ -1316,9 +1326,11 @@
 	io__write_string("\t\tWhen generating `.dep' files, generate Makefile\n"),
 	io__write_string("\t\tfragments that use only the features of standard make;\n"),
 	io__write_string("\t\tdo not assume the availability of GNU Make extensions.\n"),
-	io__write_string("\t--trace {minimum, interfaces, all}\n"),
+	io__write_string("\t--trace {minimum, interfaces, all, default}\n"),
 	io__write_string("\t\tGenerate code that includes the specified level\n"), 
 	io__write_string("\t\tof execution tracing.\n"),
+	io__write_string("\t\tSee the [XXX not yet written!] chapter of the\n"),
+	io__write_string("\t\tMercury User's Guide for details.\n"),
 	io__write_string("\t--generate-bytecode\n"),
 	io__write_string("\t\tOutput a bytecode form of the module for use\n"),
 	io__write_string("\t\tby an experimental debugger.\n"),
@@ -1497,10 +1509,9 @@
 ********************/
 	io__write_string("\t--debug\t\t\t"),
 	io__write_string("\t(grade modifier: `.debug')\n"),
-	io__write_string("\t\tEnable debugging.\n"),
-	io__write_string("\t\tDebugging support is currently extremely primitive.\n"),
-	io__write_string("\t\tWe recommend that you use instead use `mnp' or `msp'.\n"),
-	io__write_string("\t\tSee the Mercury User's Guide for details.\n"),
+	io__write_string("\t\tEnable Mercury-level debugging.\n"),
+	io__write_string("\t\tSee the [XXX not yet written!] chapter of the\n"),
+	io__write_string("\t\tMercury User's Guide for details.\n"),
 	io__write_string("\t--pic-reg\t\t"),
 	io__write_string("\t(grade modifier: `.pic_reg')\n"),
 	io__write_string("\t[For Unix with intel x86 architecture only]\n"),
@@ -1608,6 +1619,14 @@
 
 options_help_code_generation -->
 	io__write_string("\nCode generation options:\n"),
+	io__write_string("\t--low-level-debug\n"),
+	io__write_string("\t\tEnables various low-level debugging stuff, that was in\n"),
+	io__write_string("\t\tthe distant past used to debug the low-level code generation.\n"),
+	io__write_string("\t\tYou don't want to use this option unless you are hacking\n"),
+	io__write_string("\t\tthe Mercury compiler itself (and probably not even then).\n"),
+	io__write_string("\t\tCauses the generated code to become VERY big and VERY\n"),
+	io__write_string("\t\tinefficient.  Slows down compilation a LOT.\n"),
+
 	io__write_string("\t--no-trad-passes\n"),
 	io__write_string("\t\tThe default `--trad-passes' completely processes each predicate\n"),
 	io__write_string("\t\tbefore going on to the next predicate.\n"),
@@ -1630,6 +1649,14 @@
 	io__write_string("\t\tSpecify the directory containing the Mercury C header files.\n"),
 	io__write_string("\t--cflags <options>\n"),
 	io__write_string("\t\tSpecify options to be passed to the C compiler.\n"),
+		% The --cflags-for-regs and --cflags-for-gotos options
+		% are reserved for use by the `mmc' script;
+		% they are deliberately not documented.
+
+	io__write_string("\t--c-debug\n"),
+	io__write_string("\t\tEnable debugging of the generated C code.\n"),
+	io__write_string("\t\t(This has the same effect as `--cflags -g'.)\n"),
+
 	io__write_string("\t--fact-table-max-array-size <n>\n"),
 	io__write_string("\t\tSpecify the maximum number of elements in a single\n"),
 	io__write_string("\t\t`pragma fact_table' data array (default: 1024).\n"),
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.122
diff -u -r1.122 user_guide.texi
--- user_guide.texi	1998/05/16 08:15:59	1.122
+++ user_guide.texi	1998/05/19 18:09:22
@@ -2062,13 +2062,12 @@
 @sp 1
 @item @code{--debug} (grades: any grade containing @samp{.debug})
 Enable debugging.
-Pass the @samp{-g} flag to the C compiler, instead of @samp{-DSPEED},
-to enable debugging of the generated C code.
-This option also implies @samp{--no-c-optimize}.
-Debugging support is currently extremely primitive -
-this option is probably not useful to anyone except the Mercury implementors.
-We recommend that you use instead use `mnp' or `msp'.
- at xref{Using Prolog} for details.
+
+To try this out, compile your program with @samp{--debug},
+run @samp{mdb @var{program}}, and then type @samp{?}
+at the @samp{mdb} prompt.
+
+XXX We should document this in more detail.
 
 @sp 1
 @item @code{--args @{old, compact@}}
@@ -2108,6 +2107,14 @@
 @section Code generation options
 
 @table @code
+ at item @code{--low-level-debug}
+Enables various low-level debugging stuff that was in the distant past
+used to debug the Mercury compiler's low-level code generation. 
+This option is not likely to be useful to anyone except the Mercury
+implementors.  It causes the generated code to become very big and very
+inefficient, and slows down compilation a lot.
+
+ at sp 1
 @item --no-trad-passes
 The default @samp{--trad-passes} completely processes each predicate
 before going on to the next predicate.
@@ -2140,6 +2147,15 @@
 @sp 1
 @item --cflags @var{options}
 Specify options to be passed to the C compiler.
+
+ at sp 1
+ at item @code{--c-debug}
+Pass the @samp{-g} flag to the C compiler, to enable debugging
+of the generated C code.
+This option also implies @samp{--no-c-optimize}.
+Since the generated C code is very low-level, this option is not likely
+to be useful to anyone except the Mercury implementors, except perhaps
+for debugging code that uses Mercury's C interface extensively.
 
 @sp 1
 @item --fact-table-max-array-size @var{size}
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.3
diff -u -r1.3 mercury_conf_param.h
--- mercury_conf_param.h	1998/05/11 08:23:20	1.3
+++ mercury_conf_param.h	1998/05/19 16:49:53
@@ -90,8 +90,18 @@
 /*
 ** Debugging options:
 **
+** MR_STACK_TRACE
+**	Enable stuff needed so that error/1 (and co.) can print out
+**	stack traces.
+**
+** MR_REQUIRE_TRACING
+**	Require that all Mercury procedures linked in should be compiled
+**	with at least interface tracing.  This effect is achieved
+**	by including MR_REQUIRE_TRACING in the mangled grade
+**	(see mercury_grade.h).
+**
 ** MR_USE_EXTERNAL_DEBUGGER:
-**	Make MR_trace() use an external process debugger
+**	Allow MR_trace() to use an external process debugger
 **	(with communication done via a socket interface)
 **	rather than using the debugger that is part of
 **	the Mercury runtime.
@@ -142,7 +152,7 @@
 **	Enables support for the `-w' (entry point) command
 **	in the MERCURY_OPTIONS environment variable.
 **	(`-w' also happens to work if you set certain other
-**	options instead, include MR_LOWLEVEL_DEBUGGING.)
+**	options instead, include MR_LOWLEVEL_DEBUG.)
 */
 
 /*---------------------------------------------------------------------------*/
Index: runtime/mercury_grade.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_grade.h,v
retrieving revision 1.7
diff -u -r1.7 mercury_grade.h
--- mercury_grade.h	1998/03/16 12:23:29	1.7
+++ mercury_grade.h	1998/05/19 16:07:47
@@ -156,11 +156,20 @@
 ** try to do a stack trace you might find it doesn't work very
 ** well unless all modules are compiled in with --stack-trace.
 ** Hence we consider it effectively binary incompatible.
+** Similar considerations apply to procedure call tracing.
 */
 #if defined(MR_STACK_TRACE)
-  #define MR_GRADE_PART_11	_strce
+  #if defined(MR_REQUIRE_TRACING)
+    #define MR_GRADE_PART_11	_debug
+  #else
+    #define MR_GRADE_PART_11	_strce
+  #endif
 #else
-  #define MR_GRADE_PART_11
+  #if defined(MR_REQUIRE_TRACING)
+    #define MR_GRADE_PART_11	_trace
+  #else
+    #define MR_GRADE_PART_11
+  #endif
 #endif
 
 #define MR_GRADE		MR_PASTE11(			\
Index: scripts/init_grade_options.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/init_grade_options.sh-subr,v
retrieving revision 1.3
diff -u -r1.3 init_grade_options.sh-subr
--- init_grade_options.sh-subr	1998/01/09 03:10:03	1.3
+++ init_grade_options.sh-subr	1998/05/19 15:37:06
@@ -22,7 +22,9 @@
 profile_memory=false
 use_trail=false
 args_method=compact
-debug=false
+stack_trace=false
+require_tracing=false
+low_level_debug=false
 
 case $# in
 	0) set - "--grade $DEFAULT_GRADE" ;;
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.48
diff -u -r1.48 mgnuc.in
--- mgnuc.in	1998/03/11 05:58:58	1.48
+++ mgnuc.in	1998/05/19 17:04:24
@@ -23,17 +23,19 @@
 	--asm-labels
 	--gcc-non-local-gotos
 	--gcc-global-registers
+	--gc {conservative, accurate, none}
 	-p, --profiling
 	--profile-calls
 	--profile-time
 	--profile-memory
 	--debug
+	--low-level-debug
+	-g, --c-debug
 	--use-trail
 	--args {simple, compact}
 	--pic-reg
 	--inline-alloc
 	--split-c-files
-	--stack-trace
 		See the documentation in the \"Invocation\" section
 		of the Mercury User's Guide.
 		
@@ -104,6 +106,7 @@
 
 verbose=false
 assemble=false
+c_debug=false
 
 # include the file `init_grade_options.sh-subr'
 @INIT_GRADE_OPTIONS@
@@ -141,13 +144,6 @@
 		SPLIT_OPTS=
 		;;
 
-	--stack-trace)
-		STACK_TRACE_OPTS=-DMR_STACK_TRACE
-		;;
-	--no-stack-trace)
-		STACK_TRACE_OPTS=
-		;;
-
 	--inline-alloc)
 		INLINE_ALLOC_OPTS="-DINLINE_ALLOC -DSILENT"
 		;;
@@ -155,10 +151,19 @@
 		INLINE_ALLOC_OPTS=""
 		;;
 
-	--no-c-optimize)
-		OPT_OPTS=""
+	-g|--c-debug)
+		c_debug=true
 		;;
 
+	-g-|--no-c-debug)
+		c_debug=false
+		;;
+
+	--low-level-debug)
+		low_level_debug=true ;;
+	--no-low-level-debug)
+		low_level_debug=false ;;
+
 	# include the file `parse_grade_options.sh-subr'
 	@PARSE_GRADE_OPTIONS@
 
@@ -195,9 +200,24 @@
 	false)		REG_OPTS="" ;;
 esac
 
-case $debug in
-	true)		DEBUG_OPTS="-g" ;;
-	false)		DEBUG_OPTS="$OPT_OPTS -DSPEED" ;;
+case $stack_trace in
+	true)		STACK_TRACE_OPTS="-DMR_STACK_TRACE" ;;
+	false)		STACK_TRACE_OPTS="" ;;
+esac
+
+case $require_tracing in
+	true)		TRACE_OPTS="-DMR_REQUIRE_TRACING" ;;
+	false)		TRACE_OPTS="" ;;
+esac
+
+case $c_debug in
+	true)		C_DEBUG_OPTS="-g" ;;
+	false)		C_DEBUG_OPTS="$OPT_OPTS" ;;
+esac
+
+case $low_level_debug in
+	true)		LLDEBUG_OPTS="-DMR_LOWLEVEL_DEBUG" ;;
+	false)		LLDEBUG_OPTS="" ;;
 esac
 
 case $gc_method in
@@ -236,6 +256,7 @@
 	false)		PICREG_OPTS="" ;;
 esac
 
+GRADE_OPTS="$ASM_OPTS $GOTO_OPTS $REG_OPTS"
 
 # check that special grades are only used with gcc
 case $COMPILER in
@@ -243,13 +264,11 @@
 	*)	case "$GRADE_OPTS" in
 			*USE_GCC*)
 		echo "$0: For compilers other than GNU C, the only" 1>&2
-		echo "$0: grades allowed are \`debug' and \`none'" 1>&2
+		echo "$0: base grade allowed is \`none'" 1>&2
 					;;
 		esac
 esac
 
-GRADE_OPTS="$DEBUG_OPTS $ASM_OPTS $GOTO_OPTS $REG_OPTS"
-
 # if we're using global registers, add CFLAGS_FOR_REGS
 case $global_regs in
 	true)	GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_REGS" ;;
@@ -352,10 +371,12 @@
 esac
 
 
-ALL_CC_OPTS="$ALL_C_INCL_DIRS $ANSI_OPTS $CHECK_OPTS $GRADE_OPTS $GC_OPTS \
+ALL_CC_OPTS="$ALL_C_INCL_DIRS $ANSI_OPTS $CHECK_OPTS \
+		$GRADE_OPTS $GC_OPTS \
+		$TRACE_OPTS $STACK_TRACE_OPTS $LLDEBUG_OPTS $C_DEBUG_OPTS \
 		$PROF_TIME_OPTS $PROF_CALLS_OPTS $PROF_MEMORY_OPTS \
 		$INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS \
-		$STACK_TRACE_OPTS $PICREG_OPTS $ARCH_OPTS $ARG_OPTS"
+		$PICREG_OPTS $ARCH_OPTS $ARG_OPTS"
 
 case $verbose in true)
 	echo $CC $ALL_CC_OPTS "$@" $OVERRIDE_OPTS ;;
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.36
diff -u -r1.36 ml.in
--- ml.in	1997/12/05 15:58:30	1.36
+++ ml.in	1998/05/19 16:29:44
@@ -46,17 +46,19 @@
 	--no-demangle
 		Don't pipe the output of the linker through the Mercury
 		demangler.
-	-g, --no-strip
+	-g, --no-strip, --c-debug
 		Do not strip debugging information.
 	-s <grade>, --grade <grade>
 	--asm-labels
 	--gcc-non-local-gotos
 	--gcc-global-registers
+	--gc {conservative, accurate, none}
 	-p, --profiling
 	--profile-calls
 	--profile-time
 	--profile-memory
 	--debug
+	--low-level-debug
 	--use-trail
 	--args {simple, compact}
 	--pic-reg
@@ -114,10 +116,10 @@
 	--no-demangle)
 		demangle=false
 		;;
-	--strip)
+	-g-|--no-c-debug|--strip)
 		strip=true
 		;;
-	-g|--no-strip)
+	-g|--c-debug|--no-strip)
 		strip=false
 		;;
 	--make-shared-lib)
@@ -251,9 +253,11 @@
 	simple)		GRADE="$GRADE.sa" ;;
 	compact)	;;
 esac
-case $debug in
-	true)		GRADE="$GRADE.debug" ;;
-	false)		;;
+case $stack_trace,$require_tracing in
+	true,true)	GRADE="$GRADE.debug" ;;
+	false,true)	GRADE="$GRADE.trace" ;;
+	true,false)	GRADE="$GRADE.strce" ;;
+	false,false)	;;
 esac
 
 case "$GRADE" in
Index: scripts/parse_grade_options.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/parse_grade_options.sh-subr,v
retrieving revision 1.2
diff -u -r1.2 parse_grade_options.sh-subr
--- parse_grade_options.sh-subr	1997/12/05 15:58:34	1.2
+++ parse_grade_options.sh-subr	1998/05/19 17:02:56
@@ -29,9 +29,24 @@
 		global_regs=false ;;
 
 	--debug)
-		debug=true ;;
+		stack_trace=true 
+		require_tracing=true
+		;;
 	--no-debug)
-		debug=false ;;
+		stack_trace=false 
+		require_tracing=false
+		;;
+# The following more fine-grained options have been omitted
+# since they are not very useful and would probably only
+# confuse people.
+#	--stack-trace)
+#		stack_trace=true ;;
+#	--no-stack-trace)
+#		stack_trace=false ;;
+#	--require-tracing)
+#		require_tracing=true ;;
+#	--no-require-tracing)
+#		require_tracing=false ;;
 
 	--gc)
 		shift
@@ -109,10 +124,25 @@
 
 		case "$grade" in
 			*.debug)
-				debug=true
+				stack_trace=true
+				require_tracing=false
 				grade="` expr $grade : '\(.*\).debug' `"
 				;;
-			*)	debug=false
+# The following alternatives have been omitted since
+# they're not very useful and would probably just confuse people.
+#			*.trace)
+#				stack_trace=false
+#				require_tracing=true
+#				grade="` expr $grade : '\(.*\).trace' `"
+#				;;
+#			*.strce)
+#				stack_trace=true
+#				require_tracing=false
+#				grade="` expr $grade : '\(.*\).strce' `"
+#				;;
+			*)	
+				stack_trace=false
+				require_tracing=false
 				;;
 		esac
 
@@ -209,12 +239,6 @@
 				non_local_gotos=true
 				;;
 			none)
-				global_regs=false
-				asm_labels=false
-				non_local_gotos=false
-				;;
-			debug)
-				debug=true
 				global_regs=false
 				asm_labels=false
 				non_local_gotos=false

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