[m-rev.] for review: add ssdb_builtin.m to std library
Peter Ross
pro at missioncriticalit.com
Fri Sep 28 16:57:23 AEST 2007
Hi,
===================================================================
Estimated hours taken: 8
Branches: main
Add the infrastructure for a new debugger which is implemented purely
in Mercury. This debugger will be used in grades which the current debugger
doesn't support.
compiler/mercury_compile.m:
Add the code to call the ssdb pass.
library/ssdb_builtin.m:
The module which will hold the built-ins used by the source
to source transformation.
library/library.m:
Add ssdb_builtin.
mdbcomp/prim_data.m:
Handle the new builtin module.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.449
diff -u -r1.449 mercury_compile.m
--- compiler/mercury_compile.m 22 Aug 2007 07:14:34 -0000 1.449
+++ compiler/mercury_compile.m 28 Sep 2007 06:47:07 -0000
@@ -2563,6 +2563,9 @@
maybe_termination2(Verbose, Stats, !HLDS, !IO),
maybe_dump_hlds(!.HLDS, 121, "termination2", !DumpInfo, !IO),
+ maybe_ssdb(Verbose, Stats, !HLDS, !IO),
+ maybe_dump_hlds(!.HLDS, 123, "ssdb", !DumpInfo, !IO),
+
maybe_type_ctor_infos(Verbose, Stats, !HLDS, !IO),
maybe_dump_hlds(!.HLDS, 125, "type_ctor_infos", !DumpInfo, !IO),
@@ -3174,6 +3177,26 @@
;
true
).
+
+:- pred maybe_ssdb(bool::in, bool::in,
+ module_info::in, module_info::out, io::di, io::uo) is det.
+
+maybe_ssdb(Verbose, Stats, !HLDS, !IO) :-
+ globals.io_lookup_bool_option(source_to_source_debug, SSDB, !IO),
+ (
+ SSDB = yes,
+ maybe_write_string(Verbose,
+ "% Apply debugging source to source transformation ...\n", !IO),
+ /* XXX for the moment we do nothing.
+ process_all_nonimported_procs(
+ update_module_io(ssdebug.process_proc), !HLDS, !IO),
+ */
+ maybe_write_string(Verbose, "% done.\n", !IO),
+ maybe_report_stats(Stats, !IO)
+ ;
+ SSDB = no
+ ).
+
:- pred maybe_analyse_trail_usage(bool::in, bool::in,
module_info::in, module_info::out, io::di, io::uo) is det.
Index: library/library.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.117
diff -u -r1.117 library.m
--- library/library.m 10 Sep 2007 16:32:24 -0000 1.117
+++ library/library.m 28 Sep 2007 06:47:07 -0000
@@ -154,6 +154,7 @@
:- import_module profiling_builtin.
:- import_module region_builtin.
:- import_module rtti_implementation.
+:- import_module ssdb_builtin.
:- import_module stm_builtin.
:- import_module table_builtin.
:- import_module term_size_prof_builtin.
@@ -285,6 +286,7 @@
mercury_std_library_module("set_unordlist").
mercury_std_library_module("solutions").
mercury_std_library_module("sparse_bitset").
+mercury_std_library_module("ssdb_builtin").
mercury_std_library_module("stack").
mercury_std_library_module("std_util").
mercury_std_library_module("stm_builtin").
Index: library/ssdb_builtin.m
===================================================================
RCS file: library/ssdb_builtin.m
diff -N library/ssdb_builtin.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ library/ssdb_builtin.m 28 Sep 2007 06:47:07 -0000
@@ -0,0 +1,64 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+% Copyright (C) 2007 The University of Melbourne.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+%
+% File: ssdb_builtin.m.
+% Author: oannet.
+%
+% This module is automatically imported into every module that is compiled
+% using --source-to-source-debug.
+%
+% It provides the primitives which are needed by this source-to-source
+% transformation to allow debugging.
+%
+%----------------------------------------------------------------------------%
+%----------------------------------------------------------------------------%
+
+:- module ssdb_builtin.
+:- interface.
+
+
+:- type ssdb_event_type
+ ---> ssdb_call
+ ; ssdb_exit
+ ; ssdb_redo
+ ; ssdb_fail
+ .
+
+ %
+ % This routine is called at each event that occurs
+ %
+:- impure pred handle_event(ssdb_event_type::in) is det.
+
+%----------------------------------------------------------------------------%
+%----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module io.
+
+:- import_module bool.
+:- import_module int.
+:- import_module list.
+:- import_module string.
+
+%----------------------------------------------------------------------------%
+
+ %
+ % For the moment we just write the event out.
+ % Later this will be extended.
+ %
+handle_event(Event) :-
+ promise_impure (
+ trace [io(!IO)] (
+ io.write(Event, !IO),
+ io.nl(!IO)
+ )
+ ).
+
+%----------------------------------------------------------------------------%
+%----------------------------------------------------------------------------%
Index: mdbcomp/prim_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/mdbcomp/prim_data.m,v
retrieving revision 1.24
diff -u -r1.24 prim_data.m
--- mdbcomp/prim_data.m 12 Sep 2007 06:21:14 -0000 1.24
+++ mdbcomp/prim_data.m 28 Sep 2007 06:47:07 -0000
@@ -231,6 +231,11 @@
%
:- func mercury_par_builtin_module = sym_name.
+ % Returns the name of the module containing the builtins for the
+ % source-to-source debugger.
+ %
+:- func mercury_ssdb_builtin_module = sym_name.
+
% Returns the sym_name of the module with the given name in the
% Mercury standard library.
%
@@ -320,7 +325,8 @@
mercury_table_builtin_module,
mercury_profiling_builtin_module,
mercury_term_size_prof_builtin_module,
- mercury_par_builtin_module].
+ mercury_par_builtin_module,
+ mercury_ssdb_builtin_module].
% We may eventually want to put the standard library into a package "std":
% mercury_public_builtin_module = qualified(unqualified("std"), "builtin").
@@ -334,6 +340,7 @@
mercury_profiling_builtin_module = unqualified("profiling_builtin").
mercury_term_size_prof_builtin_module = unqualified("term_size_prof_builtin").
mercury_par_builtin_module = unqualified("par_builtin").
+mercury_ssdb_builtin_module = unqualified("ssdb_builtin").
mercury_std_lib_module_name(Name) = Name.
is_std_lib_module_name(SymName, Name) :-
@@ -348,6 +355,7 @@
; Module = mercury_profiling_builtin_module
; Module = mercury_term_size_prof_builtin_module
; Module = mercury_par_builtin_module
+ ; Module = mercury_ssdb_builtin_module
).
non_traced_mercury_builtin_module(Module) :-
@@ -355,4 +363,5 @@
; Module = mercury_profiling_builtin_module
; Module = mercury_term_size_prof_builtin_module
; Module = mercury_par_builtin_module
+ ; Module = mercury_ssdb_builtin_module
).
--------------------------------------------------------------------------
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