[m-rev.] for review: add ll_debug and gcd grade specifiers
Peter Ross
pro at missioncriticalit.com
Sun Oct 1 03:13:30 AEST 2006
Hi,
===================================================================
Estimated hours taken: 4
Branches: main
Enable the new grade specifiers, ll_debug and gcd.
ll_debug means compile with -O0 and -g.
gcd means compile the boehm_gc with #defines that
allow memory leaks to be debugged.
boehm_gc/Makefile:
Use findstring to see which grade specifiers are available.
Only add BOEHM_CFLAGS_FOR_THREADS if par in GRADE.
Only define NO_DEBUGGING if we are not in gcd.
compiler/compile_target_code.m:
compiler/globals.m:
compiler/handle_options.m:
Handle the gc_boehm_debug.
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Handle the new grade specifiers.
scripts/mgnuc.in:
Set the #defines implied by the new grade specifiers.
scripts/ml.in:
Calculate the name of the boehm_gc library.
Index: boehm_gc/Makefile
===================================================================
RCS file: /home/mercury1/repository/mercury/boehm_gc/Makefile,v
retrieving revision 1.63
diff -U5 -r1.63 Makefile
--- boehm_gc/Makefile 15 Aug 2006 04:19:21 -0000 1.63
+++ boehm_gc/Makefile 30 Sep 2006 17:01:49 -0000
@@ -89,15 +89,20 @@
# To build the thread-safe collector on Tru64, add to the above:
# -pthread -DGC_OSF1_THREADS
# Mercury-specific CFLAGS:
CFLAGS= -I$(srcdir)/include -I$(AO_INSTALL_DIR)/include \
- -DNO_DEBUGGING -DNO_EXECUTE_PERMISSION \
+ -DNO_EXECUTE_PERMISSION \
$(BOEHM_CFLAGS) $(CFLAGS_FOR_PIC) $(DLL_CFLAGS) $(EXTRA_CFLAGS)
-ifeq ($(GC_GRADE),par_gc)
+ifeq ($(findstring par,$(GRADE)),par)
CFLAGS += $(BOEHM_CFLAGS_FOR_THREADS)
+endif
+
+# If we are in the gcd grade then don't define -DNO_DEBUGGING
+ifneq ($(findstring gcd,$(GRADE)),gcd)
+CFLAGS += -DNO_DEBUGGING
endif
# We need $(CFLAGS_FOR_PIC) because we might be building a shared library.
# HOSTCC and HOSTCFLAGS are used to build executables that will be run as
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.93
diff -U5 -r1.93 compile_target_code.m
--- compiler/compile_target_code.m 27 Sep 2006 06:16:49 -0000 1.93
+++ compiler/compile_target_code.m 30 Sep 2006 17:01:50 -0000
@@ -453,19 +453,23 @@
;
Parallel = no,
CFLAGS_FOR_THREADS = ""
),
globals.io_get_gc_method(GC_Method, !IO),
+ BoehmGC_Opt = "-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC ",
(
GC_Method = gc_automatic,
GC_Opt = ""
;
GC_Method = gc_none,
GC_Opt = ""
;
GC_Method = gc_boehm,
- GC_Opt = "-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC "
+ GC_Opt = BoehmGC_Opt
+ ;
+ GC_Method = gc_boehm_debug,
+ GC_Opt = BoehmGC_Opt ++ "-DMR_BOEHM_GC_DEBUG -DGC_DEBUG -DKEEP_BACKPTRS "
;
GC_Method = gc_mps,
GC_Opt = "-DMR_CONSERVATIVE_GC -DMR_MPS_GC "
;
GC_Method = gc_accurate,
@@ -1434,29 +1438,36 @@
;
GCMethod = gc_none,
StaticGCLibs = "",
SharedGCLibs = ""
;
- GCMethod = gc_boehm,
+ ( GCMethod = gc_boehm
+ ; GCMethod = gc_boehm_debug
+ ),
+ ( GCMethod = gc_boehm_debug ->
+ GCGrade0 = "gc_debug"
+ ;
+ GCGrade0 = "gc"
+ ),
globals.io_lookup_bool_option(profile_time, ProfTime, !IO),
globals.io_lookup_bool_option(profile_deep, ProfDeep, !IO),
(
( ProfTime = yes
; ProfDeep = yes
)
->
- GCGrade0 = "gc_prof"
+ GCGrade1 = GCGrade0 ++ "_prof"
;
- GCGrade0 = "gc"
+ GCGrade1 = GCGrade0
),
globals.io_lookup_bool_option(parallel, Parallel, !IO),
(
Parallel = yes,
- GCGrade = "par_" ++ GCGrade0
+ GCGrade = "par_" ++ GCGrade1
;
Parallel = no,
- GCGrade = GCGrade0
+ GCGrade = GCGrade1
),
make_link_lib(TargetType, GCGrade, SharedGCLibs, !IO),
StaticGCLibs = quote_arg(StdLibDir/"lib"/
("lib" ++ GCGrade ++ LibExt))
;
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.77
diff -U5 -r1.77 globals.m
--- compiler/globals.m 22 Aug 2006 05:03:45 -0000 1.77
+++ compiler/globals.m 30 Sep 2006 17:01:50 -0000
@@ -85,10 +85,12 @@
% if the --reclaim-heap-on-*failure options are
% set.
; gc_boehm % The Boehm et al conservative collector.
+ ; gc_boehm_debug % Boehm collector with debugging enabled.
+
; gc_mps % A different conservative collector, based on
% Ravenbrook Limited's MPS (Memory Pool System)
% kit. Benchmarking indicated that this one
% performed worse than the Boehm collector,
% so we don't really support this option anymore.
@@ -295,10 +297,11 @@
convert_foreign_language_2("java", lang_java).
convert_gc_method("none", gc_none).
convert_gc_method("conservative", gc_boehm).
convert_gc_method("boehm", gc_boehm).
+convert_gc_method("boehm_debug", gc_boehm_debug).
convert_gc_method("mps", gc_mps).
convert_gc_method("accurate", gc_accurate).
convert_gc_method("automatic", gc_automatic).
convert_tags_method("none", tags_none).
@@ -330,10 +333,11 @@
simple_foreign_language_string(lang_csharp) = "csharp".
simple_foreign_language_string(lang_il) = "il".
simple_foreign_language_string(lang_java) = "java".
gc_is_conservative(gc_boehm) = yes.
+gc_is_conservative(gc_boehm_debug) = yes.
gc_is_conservative(gc_mps) = yes.
gc_is_conservative(gc_none) = no.
gc_is_conservative(gc_accurate) = no.
gc_is_conservative(gc_automatic) = no.
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.273
diff -U5 -r1.273 handle_options.m
--- compiler/handle_options.m 10 Sep 2006 23:38:59 -0000 1.273
+++ compiler/handle_options.m 30 Sep 2006 17:01:50 -0000
@@ -1954,10 +1954,11 @@
; comp_trail % whether or not to use trailing
; comp_tag % whether or not to reserve a tag
; comp_minimal_model % whether we set up for minimal model tabling
; comp_pic % Do we need to reserve a register for
% PIC (position independent code)?
+ ; comp_lowlevel % what to do to target code
; comp_trace % tracing/debugging options
; comp_stack_extend. % automatic stack extension
convert_grade_option(GradeString, Options0, Options) :-
reset_grade_options(Options0, Options1),
@@ -2198,10 +2199,11 @@
% Parallelism/multithreading components.
grade_component_table("par", comp_par, [parallel - bool(yes)], no, yes).
% GC components
grade_component_table("gc", comp_gc, [gc - string("boehm")], no, yes).
+grade_component_table("gcd", comp_gc, [gc - string("boehm_debug")], no, yes).
grade_component_table("mps", comp_gc, [gc - string("mps")], no, yes).
grade_component_table("agc", comp_gc, [gc - string("accurate")], no, yes).
% Profiling components
grade_component_table("prof", comp_prof,
@@ -2272,10 +2274,14 @@
% Debugging/Tracing components
grade_component_table("decldebug", comp_trace,
[exec_trace - bool(yes), decl_debug - bool(yes)], no, yes).
grade_component_table("debug", comp_trace,
[exec_trace - bool(yes), decl_debug - bool(no)], no, yes).
+
+ % Stack extension components
+grade_component_table("ll_debug", comp_lowlevel,
+ [target_debug - bool(yes)], no, yes).
% Stack extension components
grade_component_table("exts", comp_stack_extend,
[extend_stacks_when_needed - bool(yes)], no, yes).
Index: runtime/mercury_grade.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_grade.h,v
retrieving revision 1.63
diff -U5 -r1.63 mercury_grade.h
--- runtime/mercury_grade.h 8 Jun 2006 08:19:59 -0000 1.63
+++ runtime/mercury_grade.h 30 Sep 2006 17:01:56 -0000
@@ -121,10 +121,13 @@
#endif
#if defined(MR_MPS_GC)
#define MR_GRADE_PART_4 MR_PASTE2(MR_GRADE_PART_3, _mps)
#define MR_GRADE_OPT_PART_4 MR_GRADE_OPT_PART_3 ".mps"
+#elif defined(MR_BOEHM_GC_DEBUG)
+ #define MR_GRADE_PART_4 MR_PASTE2(MR_GRADE_PART_3, _gcd)
+ #define MR_GRADE_OPT_PART_4 MR_GRADE_OPT_PART_3 ".gcd"
#elif defined(MR_BOEHM_GC) || defined(MR_CONSERVATIVE_GC)
#define MR_GRADE_PART_4 MR_PASTE2(MR_GRADE_PART_3, _gc)
#define MR_GRADE_OPT_PART_4 MR_GRADE_OPT_PART_3 ".gc"
#elif defined(MR_NATIVE_GC)
#define MR_GRADE_PART_4 MR_PASTE2(MR_GRADE_PART_3, _agc)
@@ -375,23 +378,31 @@
#define MR_GRADE_PART_14 MR_GRADE_PART_13
#define MR_GRADE_OPT_PART_14 MR_GRADE_OPT_PART_13
#endif
#endif
+#if defined(MR_LL_DEBUG)
+ #define MR_GRADE_PART_15 MR_PASTE2(MR_GRADE_PART_14, _ll_debug)
+ #define MR_GRADE_OPT_PART_15 MR_GRADE_OPT_PART_14 ".ll_debug"
+#else
+ #define MR_GRADE_PART_15 MR_GRADE_PART_14
+ #define MR_GRADE_OPT_PART_15 MR_GRADE_OPT_PART_14
+#endif
+
#if defined(MR_EXTEND_STACKS_WHEN_NEEDED)
- #define MR_GRADE_PART_15 MR_PASTE2(MR_GRADE_PART_14, _exts)
- #define MR_GRADE_OPT_PART_15 MR_GRADE_OPT_PART_14 ".exts"
+ #define MR_GRADE_PART_16 MR_PASTE2(MR_GRADE_PART_15, _exts)
+ #define MR_GRADE_OPT_PART_16 MR_GRADE_OPT_PART_15 ".exts"
#if defined(MR_HIGHLEVEL_CODE)
#error "--extend-stacks-when-needed and --high-level-code are not compatible"
#endif
#else
- #define MR_GRADE_PART_15 MR_GRADE_PART_14
- #define MR_GRADE_OPT_PART_15 MR_GRADE_OPT_PART_14
+ #define MR_GRADE_PART_16 MR_GRADE_PART_15
+ #define MR_GRADE_OPT_PART_16 MR_GRADE_OPT_PART_15
#endif
-#define MR_GRADE MR_GRADE_PART_15
-#define MR_GRADE_OPT MR_GRADE_OPT_PART_15
+#define MR_GRADE MR_GRADE_PART_16
+#define MR_GRADE_OPT MR_GRADE_OPT_PART_16
#define MR_GRADE_VAR MR_PASTE2(MR_grade_,MR_GRADE)
#define MR_GRADE_STRING MR_STRINGIFY(MR_GRADE)
extern const char MR_GRADE_VAR;
Index: scripts/canonical_grade.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/canonical_grade.sh-subr,v
retrieving revision 1.14
diff -U5 -r1.14 canonical_grade.sh-subr
--- scripts/canonical_grade.sh-subr 13 Sep 2005 08:25:42 -0000 1.14
+++ scripts/canonical_grade.sh-subr 30 Sep 2006 17:01:59 -0000
@@ -85,10 +85,11 @@
esac
case $gc_method in
conservative) GRADE="$GRADE.gc" ;; # deprecated; alias for boehm
boehm) GRADE="$GRADE.gc" ;;
+ boehm_debug) GRADE="$GRADE.gcd" ;;
mps) GRADE="$GRADE.mps" ;;
accurate) GRADE="$GRADE.agc" ;;
esac
case $profile_time,$profile_calls,$profile_memory,$profile_deep in
@@ -147,10 +148,15 @@
*) progname=`basename $0`
echo "$progname: error: invalid combination of debugging options." 1>&2
exit 1
;;
esac
+
+case $ll_debug in
+ true) GRADE="$GRADE.ll_debug" ;;
+ *) ;;
+esac;
case $extend_stacks in
true) GRADE="$GRADE.exts" ;;
*) ;;
esac
Index: scripts/init_grade_options.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/init_grade_options.sh-subr,v
retrieving revision 1.25
diff -U5 -r1.25 init_grade_options.sh-subr
--- scripts/init_grade_options.sh-subr 13 Sep 2005 08:25:42 -0000 1.25
+++ scripts/init_grade_options.sh-subr 30 Sep 2006 17:01:59 -0000
@@ -28,11 +28,11 @@
--asm-labels
--gcc-non-local-gotos
--gcc-global-registers
-H, --high-level-code
--parallel
- --gc {boehm, mps, accurate, none}
+ --gc {boehm, boehm_debug, mps, accurate, none}
-p, --profiling
--profile-calls
--profile-time
--profile-memory
--profile-deep
@@ -45,10 +45,11 @@
--minimal-model-debug
--pic-reg
--no-stack-trace
--debug
--decl-debug
+ --low-level-debug
--extend-stacks-when-needed
See the documentation in the \"Invocation\" section
of the Mercury User's Guide."
# --gcc-nested-functions is not yet documented because it is not yet stable
@@ -77,10 +78,11 @@
use_minimal_model_own_stacks=false
minimal_model_debug=false
pic_reg=false
debug=false
decl_debug=false
+ll_debug=false
extend_stacks=false
case $# in
0) set - --grade "$DEFAULT_GRADE" ;;
*) set - --grade "$DEFAULT_GRADE" "$@" ;;
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.116
diff -U5 -r1.116 mgnuc.in
--- scripts/mgnuc.in 15 Aug 2006 04:19:39 -0000 1.116
+++ scripts/mgnuc.in 30 Sep 2006 17:01:59 -0000
@@ -298,13 +298,15 @@
esac
else
MSVCRT_OPTS=""
fi
+boehm_opts="-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC "
case $gc_method in
accurate) GC_OPTS="-DMR_NATIVE_GC" ;;
- boehm) GC_OPTS="-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC" ;;
+ boehm) GC_OPTS="$boehm_opts" ;;
+ boehm_debug) GC_OPTS="$boehm_opts -DMR_BOEHM_GC_DEBUG -DGC_DEBUG -DKEEP_BACK_PTRS" ;;
conservative) GC_OPTS="-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC" ;;
mps) GC_OPTS="-DMR_CONSERVATIVE_GC -DMR_MPS_GC" ;;
none) GC_OPTS="" ;;
esac
@@ -385,10 +387,15 @@
case $decl_debug in
true) DECL_DEBUG_OPTS="-DMR_DECL_DEBUG" ;;
false) DECL_DEBUG_OPTS="" ;;
esac
+case $ll_debug in
+ true) LL_DEBUG_OPTS="-DMR_LL_DEBUG $DEBUG_OPT -O0" ;;
+ false) LL_DEBUG_OPTS="" ;;
+esac
+
case $extend_stacks in
true) EXTEND_STACKS_OPTS="-DMR_EXTEND_STACKS_WHEN_NEEDED" ;;
false) EXTEND_STACKS_OPTS="" ;;
esac
@@ -573,10 +580,11 @@
$GC_OPTS\
$DEFINE_OPTS\
$STACK_TRACE_OPTS\
$TRACE_OPTS\
$DECL_DEBUG_OPTS\
+ $LL_DEBUG_OPTS\
$EXTEND_STACKS_OPTS\
$LLDEBUG_OPTS\
$C_DEBUG_OPTS\
$PROF_TIME_OPTS\
$PROF_CALLS_OPTS\
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.116
diff -U5 -r1.116 ml.in
--- scripts/ml.in 2 Aug 2006 06:48:56 -0000 1.116
+++ scripts/ml.in 30 Sep 2006 17:01:59 -0000
@@ -171,10 +171,18 @@
exit 0
esac
# Compute the gc grade from the grade
case "$GRADE" in
+ *.par*.gcd*.prof*)
+ gc_grade=par_gc_debug_prof ;;
+ *.par*.gcd*)
+ gc_grade=par_gc_debug ;;
+ *.gcd*.prof*)
+ gc_grade=gc_debug_prof ;;
+ *.gcd*)
+ gc_grade=gc_debug ;;
*.par*.gc*.prof*)
gc_grade=par_gc_prof ;;
*.par*.gc*)
gc_grade=par_gc ;;
*.gc*.prof*)
Index: scripts/parse_grade_options.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/parse_grade_options.sh-subr,v
retrieving revision 1.31
diff -U5 -r1.31 parse_grade_options.sh-subr
--- scripts/parse_grade_options.sh-subr 13 Sep 2005 08:25:42 -0000 1.31
+++ scripts/parse_grade_options.sh-subr 30 Sep 2006 17:01:59 -0000
@@ -74,11 +74,11 @@
global_regs=false ;;
--gc)
shift
case "$1" in
- accurate|conservative|boehm|mps|none|automatic)
+ accurate|conservative|boehm|boehm_debug|mps|none|automatic)
gc_method=$1 ;;
*)
echo "$0: invalid gc method \`$1'" 1>&2
exit 1
;;
@@ -176,10 +176,15 @@
--decl-debug)
decl_debug=true ;;
--no-decl-debug)
decl_debug=false ;;
+ --low-level-debug)
+ ll_debug= true ;;
+ --no-low-level-debug)
+ ll_debug= false ;;
+
--extend-stacks-when-needed)
extend_stacks=true ;;
--no-extend-stacks-when-needed)
extend_stacks=false ;;
@@ -214,10 +219,11 @@
use_minimal_model_own_stacks=false
minimal_model_debug=false
pic_reg=false
debug=false
decl_debug=false
+ ll_debug=false
extend_stacks=false
grade_pieces=`echo $grade | tr '.' ' '`
for grade_piece in $grade_pieces
do
@@ -347,10 +353,13 @@
gc_method=mps
;;
gc)
gc_method=boehm
;;
+ gcd)
+ gc_method=boehm_debug
+ ;;
nogc)
gc_method=none
;;
memprof)
@@ -446,10 +455,14 @@
debug=true
;;
decldebug)
decl_debug=true
+ ;;
+
+ ll_debug)
+ ll_debug=true
;;
exts)
extend_stacks=true
;;
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list