[m-rev.] review: make source to source debugging available in any grade
Peter Wang
novalazy at gmail.com
Thu Jul 19 16:07:42 AEST 2012
On Thu, 19 Jul 2012 02:03:58 +0200, Peter Ross <pro at missioncriticalit.com> wrote:
> Hi,
>
> The following code makes a much more useful source to source debugger
> for me in the csharp grade.
>
> Note the ssdb is currently undocumented, so I haven't had to modify
> much documentation.
> ===================================================================
>
>
> Estimated hours taken: 4
> Branches: main
>
> Make source to source debugging available in any grade. This
> is becuase ssdb doesn't require libraries to built with any
> special extra information, so no need to an extra grade.
because
It's only true for the standard library, though. You wouldn't be able
to install 3rd party libraries in ssdebug-enabled and non-ssdebug
enabled grades, for example.
Probably no one else is using the ssdebug grade so if it's easier for
you to remove the grade component, then that's fine by me.
>
> Also allow the user to specify different levels of tracing
> in the ssdb engine.
>
> README.ssdebug:
> Document the new way to use source to source debugging.
>
> compiler/globals.m:
> compiler/handle_options.m:
> compiler/options.m:
> Add the ss_trace_level concept.
>
> compiler/mercury_compile_middle_passes.m:
> Always run the source to source debugging phase, as now the
> ss_trace_level is used to control which procedures are traced.
>
> compiler/module_imports.m:
> If a module is traced then import the ssdb module.
>
> compiler/prog_data.m:
> compiler/simplify.m:
> Remove code for handling the .ssdebug grade componennt.
>
> compiler/ssdebug.m:
> Handle the three different tracing levels. Note when a shallowly
> traced procedure calls another procedure that procedure is traced, this
> still has to be fixed.
>
> compiler/trace_params.m:
> Add the ss_trace_level concept.
>
> doc/reference_manual.texi:
> Remove .ssdebug from the manual.
>
The ssdebug grade also appears in configure, scripts and runtime
files at least.
> Index: README.ssdebug
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/README.ssdebug,v
> retrieving revision 1.7
> diff -u -r1.7 README.ssdebug
> --- README.ssdebug 4 Nov 2010 01:36:05 -0000 1.7
> +++ README.ssdebug 18 Jul 2012 23:50:57 -0000
> @@ -15,18 +15,27 @@
>
> INSTALLATION
>
> -To use the source-to-source debugger you must install grades containing the
> -".ssdebug" grade component. One way to do this is to invoke configure
> -with the option `--enable-ssdebug-grades'. This will add the grades
> -hlc.gc.ssdebug, csharp.ssdebug and java.ssdebug to the set of library grades
> -to install.
> +To use the source-to-source debugger you must use `mmc --make' to compile your
> +program. You need to set the option `--ssdb' and
> +on at least one file set
> +`--ss-trace' to be either shallow or deep.
> +
and build at least one module with `--ssdebug-trace' set to `shallow'
or `deep'.
Wouldn't it be better for the default trace level to be `deep'?
> -----------------------------------------------------------------------------
>
> -THE .ssdebug GRADE COMPONENT
> +TRACING LEVELS
> +
> +--ss-trace none
> + None of the module will cause trace events
None of the procedures in the module will generate trace events.
>
> -Compile your program in a grade with the ".ssdebug" grade component,
> -e.g. java.ssdebug or hlc.gc.ssdebug.
> +--ss-trace shallow
> + Predicates in the interface will generate events.
I think you mean something like `--trace shallow' but that's not what's
described. You should indicate that it doesn't work yet.
> +--ss-trace deep
> + All predicates will generate events
All predicates in the module will generate events.
> +-----------------------------------------------------------------------------
> +
> +USING THE SOURCE TO SOURCE DEBUGGER
>
> You may run the program as usual. To bring up the debugger prompt, set
> the environment variable SSDB beforehand.
> @@ -35,6 +44,9 @@
> 1: 1 1 CALL calculator.main
> ssdb>
>
> +If you set SSDB to be 0. Then you will need to explicitly enable the
> +debugger later in your code by calling ssdb.enable_debugging/2.
> +
If you set SSDB=0 then you will ...
> Index: compiler/globals.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/globals.m,v
> retrieving revision 1.105
> diff -u -r1.105 globals.m
> --- compiler/globals.m 15 Jan 2012 23:38:20 -0000 1.105
> +++ compiler/globals.m 18 Jul 2012 23:50:58 -0000
> @@ -223,7 +223,7 @@
>
> :- pred globals_init(option_table::in, compilation_target::in, gc_method::in,
> tags_method::in, termination_norm::in, termination_norm::in,
> - trace_level::in, trace_suppress_items::in,
> + trace_level::in, trace_suppress_items::in, ss_trace_level::in,
> may_be_thread_safe::in, c_compiler_type::in, csharp_compiler_type::in,
> reuse_strategy::in,
> maybe(il_version_number)::in, maybe(feedback_info)::in, env_type::in,
> @@ -239,6 +239,7 @@
> :- pred get_termination2_norm(globals::in, termination_norm::out) is det.
> :- pred get_trace_level(globals::in, trace_level::out) is det.
> :- pred get_trace_suppress(globals::in, trace_suppress_items::out) is det.
> +:- pred get_ss_trace_level(globals::in, ss_trace_level::out) is det.
I think you shound name it ssdebug_trace_level here and elsewhere, and
the option to `--ssdebug-trace'/`--ssdb-trace'
> Index: compiler/mercury_compile_middle_passes.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile_middle_passes.m,v
> retrieving revision 1.17
> diff -u -r1.17 mercury_compile_middle_passes.m
> --- compiler/mercury_compile_middle_passes.m 13 Feb 2012 00:11:41 -0000 1.17
> +++ compiler/mercury_compile_middle_passes.m 18 Jul 2012 23:50:58 -0000
> @@ -859,11 +859,9 @@
>
> maybe_ssdb(Verbose, Stats, !HLDS, !IO) :-
> module_info_get_globals(!.HLDS, Globals),
> - globals.lookup_bool_option(Globals, source_to_source_debug, SSDB),
> globals.lookup_bool_option(Globals, force_disable_ssdebug,
> ForceDisableSSDB),
> (
> - SSDB = yes,
> ForceDisableSSDB = no
> ->
> maybe_write_string(Verbose,
I guess --force-disable-ssdebug can be removed in favour of
--ssdebug-level none, but that can be done in a separate change.
> Index: compiler/options.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
> retrieving revision 1.716
> diff -u -r1.716 options.m
> --- compiler/options.m 8 Jun 2012 15:36:59 -0000 1.716
> +++ compiler/options.m 18 Jul 2012 23:50:59 -0000
> @@ -234,6 +234,7 @@
>
> ; generate_mmc_make_module_dependencies
> ; assume_gmake
> + ; ss_trace_level
> ; trace_level
> ; trace_optimized
> ; trace_prof
> @@ -1209,6 +1210,7 @@
> generate_item_version_numbers - bool(no),
> generate_mmc_make_module_dependencies - bool(no),
> assume_gmake - bool(yes),
> + ss_trace_level - string("none"),
> trace_level - string("default"),
> trace_optimized - bool(no),
> trace_prof - bool(no),
> @@ -2102,6 +2104,7 @@
> long_option("generate-mmc-make-module-dependencies",
> generate_mmc_make_module_dependencies).
> long_option("generate-mmc-deps", generate_mmc_make_module_dependencies).
> +long_option("ss-trace", ss_trace_level).
> long_option("trace", trace_level).
> long_option("trace-optimised", trace_optimized).
> long_option("trace-optimized", trace_optimized).
Move these down to where force_disable_ssdebug lines are now.
> @@ -3859,6 +3862,15 @@
> "\twhen using Mmake. This is recommended when building a",
> "\tlibrary for installation.",
>
> + "--ssdb",
> + "--ss-debug",
> + "--source-to-source-debug",
> + "\tLink the source to source debugging libraries into the",
> + "\tthe executable.",
> + "--ss-trace {none, shallow, deep}",
> + "\tThe trace level to use for source to source debugging of",
> + "\tthe given module.",
> +
> % "--trace decl" is not documented, because it is for backwards
> % compatibility only. It is now equivalent to `--trace rep'.
> % "--trace {minimum, shallow, deep, decl, rep, default}",
Move it down to the commented out documentation for
`--force-disable-ssdebug' as well. source-to-source should be
hyphenated.
Add `--ssdebug' as a synonym (not necessarily documented).
> Index: compiler/ssdebug.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/ssdebug.m,v
> retrieving revision 1.38
> diff -u -r1.38 ssdebug.m
> --- compiler/ssdebug.m 2 Jul 2012 01:16:37 -0000 1.38
> +++ compiler/ssdebug.m 18 Jul 2012 23:51:01 -0000
> @@ -201,6 +201,9 @@
> :- import_module hlds.passes_aux.
> :- import_module hlds.pred_table.
> :- import_module hlds.quantification.
> +:- import_module libs.
> +:- import_module libs.globals.
> +:- import_module libs.trace_params.
> :- import_module mdbcomp.prim_data.
> :- import_module parse_tree.builtin_lib_types.
> :- import_module parse_tree.file_names.
> @@ -220,9 +223,30 @@
> %-----------------------------------------------------------------------------%
>
> ssdebug_transform_module(!ModuleInfo, !IO) :-
> - ssdebug_first_pass(!ModuleInfo),
> - process_all_nonimported_procs(update_module(ssdebug_process_proc),
> - !ModuleInfo).
> + module_info_ss_trace_level(!.ModuleInfo, SSTraceLevel),
> + (
> + SSTraceLevel = none,
> + true
> + ;
> + SSTraceLevel = shallow,
> + % In the shallow trace level we never enter the body of a procedures
> + % so no need to transform the library methods in the body.
??
> + process_all_nonimported_procs(
> + update_module(ssdebug_process_proc(SSTraceLevel)),
> + !ModuleInfo)
> + ;
> + SSTraceLevel = deep,
> + ssdebug_first_pass(!ModuleInfo),
> + process_all_nonimported_procs(
> + update_module(ssdebug_process_proc(SSTraceLevel)),
> + !ModuleInfo)
> + ).
> +
> +:- pred module_info_ss_trace_level(module_info::in, ss_trace_level::out) is det.
> +
> +module_info_ss_trace_level(ModuleInfo, SSTraceLevel) :-
> + module_info_get_globals(ModuleInfo, Globals),
> + globals.get_ss_trace_level(Globals, SSTraceLevel).
>
> %-----------------------------------------------------------------------------%
> %
> @@ -478,10 +502,31 @@
> % The main transformation.
> %
>
> -:- pred ssdebug_process_proc(pred_proc_id::in, proc_info::in, proc_info::out,
> +:- pred ssdebug_process_proc(ss_trace_level::in,
> + pred_proc_id::in, proc_info::in, proc_info::out,
> + module_info::in, module_info::out) is det.
> +
> +ssdebug_process_proc(none, proc(_PredId, _ProcId), !ProcInfo, !ModuleInfo).
> +ssdebug_process_proc(shallow, proc(PredId, ProcId), !ProcInfo, !ModuleInfo) :-
> + % Only transform the procedures in the interface
> + % XXX We still need to fix the ssdb so that events generated
> + % below the shallow call event aren't seen.
Hard?
> Index: compiler/trace_params.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/trace_params.m,v
> retrieving revision 1.45
> diff -u -r1.45 trace_params.m
> --- compiler/trace_params.m 11 Jun 2012 03:13:22 -0000 1.45
> +++ compiler/trace_params.m 18 Jul 2012 23:51:01 -0000
> @@ -124,6 +124,16 @@
> :- func encode_suppressed_events(trace_suppress_items) = int.
>
> %-----------------------------------------------------------------------------%
> +
> +:- type ss_trace_level
> + ---> none % No tracing of this module
> + ; shallow % Only trace the interface of this module
> + ; deep % Trace all procedures of this module
> + .
> +
> +:- pred ss_trace_level(string::in, ss_trace_level::out) is semidet.
> +
> +%-----------------------------------------------------------------------------%
> %-----------------------------------------------------------------------------%
>
> :- implementation.
> @@ -655,3 +665,12 @@
> port_number(port_disj_later) = 13.
> port_number(port_switch) = 14.
> port_number(port_user) = 15.
> +
> +%-----------------------------------------------------------------------------%
> +
> +ss_trace_level("none", none).
> +ss_trace_level("shallow", shallow).
> +ss_trace_level("deep", deep).
> +
> +%-----------------------------------------------------------------------------%
> +%-----------------------------------------------------------------------------%
The ssdebug stuff is unrelated. I think you can place them in globals.m
Peter
--------------------------------------------------------------------------
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