mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 10:53:40 +00:00
Rename mmc and mgnuc options that set this grade component to --c-debug-grade.
Let the options named --c-debug of both mmc and mgnuc enable C level debugging
of only the module being compiled.
runtime/mercury_grade.h:
Rename the .ll_debug grade component to .c_debug. Also rename the C macro
that controls the presence or absence of this grade component
from MR_LL_DEBUG to MR_C_DEBUG_GRADE.
runtime/mercury_conf_param.h:
runtime/mercury_debug.c:
runtime/mercury_debug.h:
runtime/mercury_engine.c:
runtime/mercury_label.c:
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
runtime/mercury_overflow.c:
runtime/mercury_std.h:
runtime/mercury_wrapper.c:
Rename the MR_LOWLEVEL_DEBUG macro to MR_DEBUG_THE_RUNTIME.
Previously, the name of this macro wrongly implied that it had
something to do with the old .ll_debug grade component, even though
- the MR_LOWLEVEL_DEBUG macro was designed to debug LLDS grades,
since only these existed when it was created, while
- the .ll_debug grade component (now .c_debug) is useful only for
MLDS grades targeting C.
compiler/options.m:
Rename the old confusingly named low_level_debug option to c_debug_grade.
Move it to the list of grade options, and fix its documentation, which
was completely wrong:
- code in compile_target_code.m treated it as being a synonym of
the .ll_debug (now .c_debug) grade component, while
- its (commented out) documentation here in options.m said it called for
the enabling of what is now MR_DEBUG_THE_RUNTIME.
compiler/compile_target_code.m:
Conform to the rename just above.
Define MR_C_DEBUG_GRADE instead of MR_LL_DEBUG if c_debug_grade is enabled.
Pass -g to the C compiler if either c_debug_grade or target_debug
is enabled.
Add an XXX about a missing safety check for an obsolete experimental
feature.
compiler/compute_grade.m:
When given a grade with a .c_debug grade component, set only the
c_debug_grade option; don't set the target_debug option, which is NOT
a grade option. The change to compile_target_code.m above handles the
only situation in which this implication was formerly required.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Look for and process the .c_debug grade component instead of .ll_debug.
Use a sh variable named c_debug_grade to record its absence/presence.
Look for and process the --c-debug-grade grade-component option,
setting the same sh variable, c_debug_grade. (All grade components
can be set piecemeal using sh options to the scripts using these
subroutines.) This replaces the old, confusingly named option
--low-level-debug.
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
Consistently use the sh variable c_debug to record the presence of
the (non-grade) --c-debug option to mgnuc, and the sh variable
c_debug_grade to record the presence of the .c_debug grade component.
Stop looking for and handling the --low-level-debug option, which
mgnuc used to document, even though this duplicated the same documentation
in init_grade_options.sh-subr, which mgnuc includes. The difference was
that init_grade_options.sh-subr meant it to represent the old .ll_debug
MLDS grade component, while mgnuc treated it as specifying what is now
MR_DEBUG_THE_RUNTIME for LLDS grades. It didn't help that two sh variables
with quite different semantics had names that differed only in an
underscore: LLDEBUG_OPTS vs LL_DEBUG_OPTS.
scripts/Mmakefile:
Add a missing dependency to force the rebuild of mgnuc after each update
of its sh subroutine mgnuc_file_ops.sh-subr.
doc/user_guide.texi:
Document the --c-debug-grade option of mmc. This option was not publicly
documented under its original misleading name (--low-level-debug), but
its documentation is now possible without contorted dancing around the
name.
Clarify the documentation of mgnuc's --c-debug option.
README.sanitizers:
configure.ac:
Conform to the rename of the grade component.
grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/try_all_grade_structs.m:
Conform to the rename of the grade component .ll_debug to .c_debug.
Don't allow the .c_debug grade component in LLDS grades.
In grade_string.m, add some obvious implications of some grade components.
grade_lib/choose_grade.m:
grade_lib/grade_lib.m:
grade_lib/test_grades.m:
grade_lib/var_value_names.m:
Fix white space.
scripts/ml.in:
tools/lmc.in:
tools/test_mercury:
Conform to the change in compile_target_code.m to the naming of
Boehm gc library variants.
322 lines
11 KiB
Mathematica
322 lines
11 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 2016, 2018 The Mercury team.
|
|
% This file is distributed under the terms specified in COPYING.LIB.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% A test program that checks whether all the possible values of the grade
|
|
% structure type are valid. It does this by generating all those values,
|
|
% and then checking, for each value, whether
|
|
%
|
|
% - converting it to a grade string,
|
|
% - converting the grade string to a partial grade specification,
|
|
% - solving that specification, and
|
|
% - converting the solution back to a grade structure
|
|
%
|
|
% (a) succeeds, and (b) yields the exact same grade structure that
|
|
% we started with.
|
|
%
|
|
% Besides testing whether the grade structure type is "tight" in the sense
|
|
% of being unable to express any invalid grades, this round-trip test also
|
|
% stress-tests all the parts of the grade library except those that explain
|
|
% the inconsistencies in invalid grade specifications.
|
|
%
|
|
|
|
:- module try_all_grade_structs.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module grade_lib.
|
|
:- import_module grade_lib.grade_setup.
|
|
:- import_module grade_lib.grade_solver.
|
|
:- import_module grade_lib.grade_spec.
|
|
:- import_module grade_lib.grade_state.
|
|
:- import_module grade_lib.grade_string.
|
|
:- import_module grade_lib.grade_structure.
|
|
:- import_module grade_lib.grade_vars.
|
|
|
|
:- import_module int.
|
|
:- import_module list.
|
|
:- import_module map.
|
|
:- import_module maybe.
|
|
:- import_module solutions.
|
|
:- import_module string.
|
|
|
|
main(!IO) :-
|
|
SpecsVersion = specs_version_0,
|
|
AutoconfResults = autoconf_results(autoconf_gcc_regs_avail_yes,
|
|
autoconf_gcc_gotos_avail_yes, autoconf_gcc_labels_avail_yes,
|
|
autoconf_low_tag_bits_avail_3, autoconf_size_of_double_eq_ptr,
|
|
autoconf_merc_file_no),
|
|
setup_solver_info(SpecsVersion, AutoconfResults, SolverInfo0),
|
|
|
|
solutions(generate_all_tests, GradeStructures),
|
|
list.length(GradeStructures, NumGradeStructures),
|
|
io.format("There are %d grade structures to test.\n",
|
|
[i(NumGradeStructures)], !IO),
|
|
list.foldl2(check_grade_struct(SolverInfo0), GradeStructures, 0, _, !IO).
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- pred generate_all_tests(grade_structure::out) is multi.
|
|
|
|
generate_all_tests(GradeStructure) :-
|
|
( generate_pregen_tests(GradeStructure)
|
|
; generate_llds_tests(GradeStructure)
|
|
; generate_mlds_tests(GradeStructure)
|
|
).
|
|
|
|
%---------------------%
|
|
|
|
:- pred generate_pregen_tests(grade_structure::out) is multi.
|
|
|
|
generate_pregen_tests(GradeStructure) :-
|
|
( PregenKind = pregen_mlds_hlc
|
|
; PregenKind = pregen_llds_none
|
|
; PregenKind = pregen_llds_reg
|
|
; PregenKind = pregen_llds_asm_fast
|
|
),
|
|
GradeStructure = grade_pregen(PregenKind).
|
|
|
|
%---------------------%
|
|
|
|
:- pred generate_llds_tests(grade_structure::out) is multi.
|
|
|
|
generate_llds_tests(GradeStructure) :-
|
|
( GccConf = grade_var_gcc_conf_none
|
|
; GccConf = grade_var_gcc_conf_reg
|
|
; GccConf = grade_var_gcc_conf_jump
|
|
; GccConf = grade_var_gcc_conf_fast
|
|
; GccConf = grade_var_gcc_conf_asm_jump
|
|
; GccConf = grade_var_gcc_conf_asm_fast
|
|
),
|
|
( StackLen = grade_var_stack_len_std
|
|
; StackLen = grade_var_stack_len_segments
|
|
; StackLen = grade_var_stack_len_extend
|
|
),
|
|
(
|
|
generate_c_gc(CGc),
|
|
( CTrail = c_trail_no
|
|
; CTrail = c_trail_yes
|
|
),
|
|
(
|
|
LLDSPerfProf = llds_perf_prof_none
|
|
;
|
|
LLDSPerfProf = llds_perf_prof_deep
|
|
;
|
|
( MProfTime = grade_var_mprof_time_no
|
|
; MProfTime = grade_var_mprof_time_yes
|
|
),
|
|
( MProfMemory = grade_var_mprof_memory_no
|
|
; MProfMemory = grade_var_mprof_memory_yes
|
|
),
|
|
LLDSPerfProf = llds_perf_prof_mprof(MProfTime, MProfMemory)
|
|
),
|
|
( TermSizeProf = grade_var_term_size_prof_no
|
|
; TermSizeProf = grade_var_term_size_prof_cells
|
|
; TermSizeProf = grade_var_term_size_prof_words
|
|
),
|
|
( Debug = grade_var_debug_none
|
|
; Debug = grade_var_debug_debug
|
|
; Debug = grade_var_debug_decldebug
|
|
),
|
|
(
|
|
RBMM = llds_rbmm_no
|
|
;
|
|
( RBMMDebug = grade_var_rbmm_debug_no
|
|
; RBMMDebug = grade_var_rbmm_debug_yes
|
|
),
|
|
( RBMMProf = grade_var_rbmm_prof_no
|
|
; RBMMProf = grade_var_rbmm_prof_yes
|
|
),
|
|
RBMM = llds_rbmm_yes(RBMMDebug, RBMMProf)
|
|
),
|
|
LLDSTSMinModel = llds_thread_safe_no_minmodel_no(CGc, CTrail,
|
|
LLDSPerfProf, TermSizeProf, Debug, RBMM)
|
|
;
|
|
( MinModelKind = lmk_stack_copy
|
|
; MinModelKind = lmk_stack_copy_debug
|
|
; MinModelKind = lmk_own_stack
|
|
; MinModelKind = lmk_own_stack_debug
|
|
),
|
|
( LLDSMMGc = llds_mm_gc_bdw
|
|
; LLDSMMGc = llds_mm_gc_bdw_debug
|
|
),
|
|
( Debug = grade_var_debug_none
|
|
; Debug = grade_var_debug_debug
|
|
; Debug = grade_var_debug_decldebug
|
|
),
|
|
LLDSTSMinModel = llds_thread_safe_no_minmodel_yes(MinModelKind,
|
|
LLDSMMGc, Debug)
|
|
;
|
|
generate_thread_safe_c_gc(ThreadSafeCGc),
|
|
( CTrail = c_trail_no
|
|
; CTrail = c_trail_yes
|
|
),
|
|
( TScopeProf = grade_var_tscope_prof_no
|
|
; TScopeProf = grade_var_tscope_prof_yes
|
|
),
|
|
LLDSTSMinModel = llds_thread_safe_yes_minmodel_no(ThreadSafeCGc,
|
|
CTrail, TScopeProf)
|
|
),
|
|
MercFile = grade_var_merc_file_no,
|
|
generate_grade_var_low_tag_bits_use(LowTagBitsUse),
|
|
generate_grade_var_merc_float(MercFloat),
|
|
GradeStructure = grade_llds(GccConf, StackLen, LLDSTSMinModel,
|
|
MercFile, LowTagBitsUse, MercFloat).
|
|
|
|
%---------------------%
|
|
|
|
:- pred generate_mlds_tests(grade_structure::out) is multi.
|
|
|
|
generate_mlds_tests(GradeStructure) :-
|
|
(
|
|
generate_mlds_c_target(MLDSTarget)
|
|
;
|
|
generate_grade_var_ssdebug(SSDebug),
|
|
MLDSTarget = mlds_target_csharp(SSDebug)
|
|
;
|
|
generate_grade_var_ssdebug(SSDebug),
|
|
MLDSTarget = mlds_target_java(SSDebug)
|
|
),
|
|
generate_grade_var_target_debug(TargetDebug),
|
|
GradeStructure = grade_mlds(MLDSTarget, TargetDebug).
|
|
|
|
:- pred generate_mlds_c_target(mlds_target::out) is multi.
|
|
|
|
generate_mlds_c_target(MLDSCTarget) :-
|
|
(
|
|
generate_c_gc(CGc),
|
|
(
|
|
MLDSCPerfProf = mlds_c_perf_prof_none
|
|
;
|
|
( MProfTime = grade_var_mprof_time_no
|
|
; MProfTime = grade_var_mprof_time_yes
|
|
),
|
|
( MProfMemory = grade_var_mprof_memory_no
|
|
; MProfMemory = grade_var_mprof_memory_yes
|
|
),
|
|
MLDSCPerfProf = mlds_c_perf_prof_mprof(MProfTime, MProfMemory)
|
|
),
|
|
generate_grade_var_ssdebug(SSDebug),
|
|
MLDSCThreadSafe = mlds_c_thread_safe_no(CGc, MLDSCPerfProf, SSDebug)
|
|
;
|
|
generate_thread_safe_c_gc(ThreadSafeCGc),
|
|
MLDSCThreadSafe = mlds_c_thread_safe_yes(ThreadSafeCGc)
|
|
),
|
|
( CTrail = c_trail_no
|
|
; CTrail = c_trail_yes
|
|
),
|
|
MercFile = grade_var_merc_file_no,
|
|
generate_grade_var_low_tag_bits_use(LowTagBitsUse),
|
|
generate_grade_var_merc_float(MercFloat),
|
|
MLDSCTarget = mlds_target_c(MLDSCThreadSafe, CTrail, MercFile,
|
|
LowTagBitsUse, MercFloat).
|
|
|
|
%---------------------%
|
|
|
|
:- pred generate_c_gc(c_gc::out) is multi.
|
|
|
|
generate_c_gc(c_gc_none).
|
|
generate_c_gc(c_gc_bdw).
|
|
generate_c_gc(c_gc_bdw_debug).
|
|
generate_c_gc(c_gc_accurate).
|
|
generate_c_gc(c_gc_history).
|
|
|
|
:- pred generate_thread_safe_c_gc(thread_safe_c_gc::out) is multi.
|
|
|
|
generate_thread_safe_c_gc(thread_safe_c_gc_none).
|
|
generate_thread_safe_c_gc(thread_safe_c_gc_bdw).
|
|
generate_thread_safe_c_gc(thread_safe_c_gc_bdw_debug).
|
|
|
|
:- pred generate_grade_var_ssdebug(grade_var_ssdebug::out) is multi.
|
|
|
|
generate_grade_var_ssdebug(grade_var_ssdebug_no).
|
|
generate_grade_var_ssdebug(grade_var_ssdebug_yes).
|
|
|
|
:- pred generate_grade_var_target_debug(grade_var_target_debug::out) is multi.
|
|
|
|
generate_grade_var_target_debug(grade_var_target_debug_no).
|
|
generate_grade_var_target_debug(grade_var_target_debug_yes).
|
|
|
|
:- pred generate_grade_var_low_tag_bits_use(grade_var_low_tag_bits_use::out)
|
|
is multi.
|
|
:- pragma no_determinism_warning(pred(generate_grade_var_low_tag_bits_use/1)).
|
|
|
|
generate_grade_var_low_tag_bits_use(LowTagBitsUse) :-
|
|
% ( LowTagBitsUse = grade_var_low_tag_bits_use_0
|
|
% ; LowTagBitsUse = grade_var_low_tag_bits_use_2
|
|
% ; LowTagBitsUse = grade_var_low_tag_bits_use_3
|
|
% ),
|
|
LowTagBitsUse = grade_var_low_tag_bits_use_3.
|
|
|
|
:- pred generate_grade_var_merc_float(grade_var_merc_float::out) is multi.
|
|
|
|
generate_grade_var_merc_float(grade_var_merc_float_is_unboxed_c_double).
|
|
generate_grade_var_merc_float(grade_var_merc_float_is_unboxed_c_float).
|
|
% As long as we generate only grade_var_low_tag_bits_use_3,
|
|
% returning grade_var_merc_float_is_boxed_c_double would NOT make sense.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- pred check_grade_struct(solver_info::in, grade_structure::in,
|
|
int::in, int::out, io::di, io::uo) is det.
|
|
|
|
check_grade_struct(SolverInfo0, GradeStructure, !N, !IO) :-
|
|
GradeStr = grade_structure_to_grade_string(grade_string_user,
|
|
GradeStructure),
|
|
!:N = !.N + 1,
|
|
io.format( "TEST %d: grade struct %s\n", [i(!.N), s(GradeStr)], !IO),
|
|
|
|
MaybeSpecSuccMap = grade_string_to_succ_soln(GradeStr),
|
|
(
|
|
MaybeSpecSuccMap = error(HeadErrorMsg, TailErrorMsgs),
|
|
CombinedErrorMsg =
|
|
string.join_list(", ", [HeadErrorMsg | TailErrorMsgs]),
|
|
io.format("ERROR: cannot convert to succ soln: %s\n",
|
|
[s(CombinedErrorMsg)], !IO)
|
|
;
|
|
MaybeSpecSuccMap = ok(SpecSuccMap),
|
|
SolverVarMap0 = SolverInfo0 ^ si_solver_var_map,
|
|
map.foldl(assign_var_in_map(npw_config), SpecSuccMap,
|
|
SolverVarMap0, SolverVarMap),
|
|
SolverInfo = SolverInfo0 ^ si_solver_var_map := SolverVarMap,
|
|
solve_absolute(SolverInfo, _SolveCounts, Soln),
|
|
(
|
|
Soln = soln_failure(_),
|
|
FailureStr0 = soln_to_str(" ", Soln),
|
|
string.replace_all(FailureStr0, "\n", " ", FailureStr),
|
|
io.format("ERROR: cannot solve succ soln\n%s\n",
|
|
[s(FailureStr)], !IO)
|
|
;
|
|
Soln = soln_success(StdSuccMap),
|
|
StdGradeVars = success_map_to_grade_vars(StdSuccMap),
|
|
StdGradeStructure = grade_vars_to_grade_structure(StdGradeVars),
|
|
( if StdGradeStructure = GradeStructure then
|
|
true
|
|
else
|
|
StdGradeStr =
|
|
grade_structure_to_grade_string(grade_string_user,
|
|
StdGradeStructure),
|
|
io.format("ERROR: round trip does not match: %s\n",
|
|
[s(StdGradeStr)], !IO),
|
|
io.write(GradeStructure, !IO),
|
|
io.nl(!IO),
|
|
io.write(StdGradeStructure, !IO),
|
|
io.nl(!IO)
|
|
)
|
|
)
|
|
).
|
|
|
|
%---------------------------------------------------------------------------%
|
|
:- end_module try_all_grade_structs.
|
|
%---------------------------------------------------------------------------%
|