Estimated hours taken: 3
Branches: main
Print list terms using list syntax when printing in "flat" format. As
well as the usual functor/arity style abbreviation, list elements can be
replaced by an ellipsis, "...", if beyond the depth or size limit.
browser/browse.m:
Handle the functors [|]/2 and []/0 specially.
doc/user_guide.texi:
Be more explicit with the meaning of "depth" and "size". In
particular, define what they mean for lists.
tests/debugger/*.exp:
tests/debugger/*.exp2:
tests/debugger/declarative/*.exp:
tests/debugger/declarative/*.exp2:
Update test outputs to reflect the change.
Estimated hours taken: 1.5
Branches: main
Change the declarative debugger so it always prints syntactically
correct goals.
browser/declarative_user.m:
Print atoms using browse__print_synthetic. This means that goals
will always be syntactically correct, even if they are printed
in the multi-line form.
Make the predicates write_decl{_init,_final,}_atom take an argument
of type browse_caller_type. When printing a single goal use the
caller type "print", and when printing a sequence of goals use
"print_all".
browser/browse.m:
When writing out a synthetic term using io__write_univ, check for
arguments with type util__unbound. Print such values as a single
unquoted underscore (io__write_univ would print an underscore in
single quotes, which means something different).
browser/util.m:
Export functions is_predicate and is_function to convert values of
type pred_or_func to values of type bool.
tests/debugger/print_goal.exp:
tests/debugger/queens_rep.exp:
Update the output of these tests after the change to browse.m.
tests/debugger/declarative/app.exp:
tests/debugger/declarative/app.exp2:
tests/debugger/declarative/filter.exp:
tests/debugger/declarative/filter.exp2:
tests/debugger/declarative/input_term_dep.exp:
tests/debugger/declarative/input_term_dep.exp2:
tests/debugger/declarative/output_term_dep.exp:
tests/debugger/declarative/output_term_dep.exp2:
tests/debugger/declarative/queens.exp:
tests/debugger/declarative/tabled_read_decl.exp:
tests/debugger/declarative/tabled_read_decl.exp2:
Update the output of these test cases.
Estimated hours taken: 0.2
Branches: main
browser/browse.m:
browser/parse.m:
Add a new browser "command", empty, to represent command lines without
tokens. This allows us to avoid giving an error message if the user
just hits return at a browser prompt.
Use a better variable name.
Estimated hours taken: 3
Branches: main
Make the commands that update the browser parameters within the browser itself
affect the parameter settings only for the current browser caller type (print,
print all, or browse).
browser/browse_info.m:
Add the current call type to the browser state.
Add a more convenient mechanism for setting the parameters only for a
specified caller type.
Make some existing code look nicer.
browser/browse.m:
When setting parameters, set them only for the current caller type.
tests/debugger/browse_pretty.exp:
Update the expected output of this test case.
Estimated hours taken: 50
Branches: main
Allow the debugger to print higher order values and typeinfos, mainly by
making the committed choice modes of the predicates in deconstruct.m to
deconstruct higher order values and typeinfos. (The non committed choice
versions will continue to return only placeholders.)
Having the debugger print typeinfos is occasionally useful but more often
it is just distracting. This change therefore adds a new debugger command,
"print_optionals", that toggles the printing of optional values. For now,
the only optional values are typeinfos.
NEWS:
Mention the new capability and the new predicates in the library.
Mention the predicates added previously that allow the caller to
specify how non-canonical terms should be handled, since the change
in their semantics that we anticipated when they were added has now
happened, and their semantics should now be more stable.
browser/browser_info.m:
Use the predicates in the deconstruct.m instead of std_util,
to make the choice of noncanonical term method handling explicit.
browser/browse.m:
When writing small terms using io__write_univ, explicitly use
the same noncanonical term handling method as browser_info.m
library/io.m:
Add predicates to retrieve the current input and output streams.
Add versions of io__write_univ that specify the stream and maybe
the method of handling noncanonical terms.
Add a mode to io__write_list that allows the closure that prints the
list elements to be cc_multi.
All of these are for the new functionality in the browser.
runtime/mercury_ml_expand_body.h:
In committed choice contexts, deconstruct closures as if they were
ordinary terms, with the function symbol being the name of the
predicate/function and the arguments being the terms stored in
the closure.
In committed choice contexts, deconstruct typeinfos as if they were
ordinary terms, with the function symbol being the name of the type
constructor and the arguments being the type constructor's arguments.
runtime/mercury_type_info.[ch]:
Add a new function, MR_collapse_ctor_equivalences, for use by
mercury_ml_expand_body.h.
Delete a redundant function comment.
library/deconstruct.m:
Document the changes in the behavior of the predicates defined in this
module as a result of the change to mercury_ml_expand_body.h.
runtime/mercury_ho_call.h:
runtime/mercury_stack_layout.h:
Add prefixes on structure field names that did not have them.
browser/dl.m:
Add prefixes where needed by the changes to mercury_ho_call.h.
runtime/mercury_layout_util.[ch]:
Remove the first argument of MR_materialize_closure_typeinfos, since
its correct value is always the same part of the second argument.
runtime/mercury_deep_copy_body.h:
Do not pass the first argument of MR_materialize_closure_typeinfos.
Add field name prefixes where necessary.
compiler/modules.m:
The mercury_builtin module is no longer part of the library.
compiler/pd_debug.m:
compiler/rl_analyze.m:
Minor updates to avoid trying to take the address of io__write_list,
since it now has more than one mode.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
trace/mercury_trace_vars.[ch]:
Add a parameter to MR_trace_browse_all_on_level that specifies
whether we should print values of type type_info.
trace/mercury_trace_vars.c:
Do not ignore predicates and functions anymore.
runtime/mercury_stack_trace.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
Pass the new parameter of MR_trace_browse_all_on_level.
trace/mercury_trace_internal.c:
Implement the "print_optionals" command.
doc/user_guide.texi:
Document the "print_optionals" command.
tests/debugger/mdb_command_test.inp:
Test the documentation of "print_optionals".
tests/debugger/higher_order.{m,inp,exp,exp2}:
A new test case to exercise the ability to print higher order values.
Note that the format of the predicate names in the output should be
improved, but that is a separate change since doing it the right way
requires bootstrapping.
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/nondet_stack.exp*:
Update the expected output to reflect the fact that nondet stack dumps,
being intended for debugging, include type_infos.
tests/debugger/tabled_read_decl.exp*:
Update the expected output to reflect the fact that for maximum
usefulness, the printing of I/O action atoms prints meaningful
type_infos.
tests/hard_coded/deconstruct_arg.*:
tests/hard_coded/write_reg1.*:
Expand these tests to check that we handle higher order values
correctly not just when canonicalizing but also in committed choice
modes.
Estimated hours taken: 2
Branches: main
browser/*.m:
Make the debugger use the committed choice versions of the
deconstruction predicates, and propagate the committed choice
environment up the call chain as far as necessary.
Estimated hours taken: 20
Branches: main
Give the debugger the ability to print goals.
NEWS:
Mention the new ability.
browser/browser_info.m:
Define a new type, browser_term, which represents either a plain term,
or a "synthetic term", which is a string (predicate or function name),
a list of argument values, and an indication of whether the synthetic
term is a predicate goal (i.e. of the form p(a1, ..., an)) or a
function goal (i.e. of the form f(a1, ..., an-1) = an).
Add utility predicates for processing browser_terms.
browser/browse.m:
Add predicates for printing and browsing synthetic terms, and export
them to C code.
browser/browse.m:
browser/size_pretty.m:
Generalize lots of predicates to handle browser_terms, not just plain
terms.
browser/util.m:
Add a new type, "unbound", for use by mercury_trace_vars.c.
library/pprint.m:
Add functions for converting synthetic terms to docs.
Fix a potential efficiency problem: an unnecessary deconstruct.
runtime/mercury_type_info.h:
Add macros for defining static type_infos in C code.
Add macros for computing the names of type_ctor_infos even in non-hlc
grades.
Give C code access to the representation of bools and of values of
the new type "unbound".
trace/mercury_trace_browse.[ch]:
Add functions for printing goals.
trace/mercury_trace_internal.c:
Add code to recognize and handle the commands "print goal" and
"browse goal".
doc/user_guide.texi:
Document the new commands.
trace/mercury_trace_vars.[ch]:
Add a function to compute the components of synthetic terms.
tests/debugger/browse_pretty.{inp,exp*}:
Add new commands to the input to test the printing and browsing of
predicate goals, and update the expected outputs accordingly.
tests/debugger/polymorphic_output.{inp,exp*}:
Add new commands to the input to test the printing and browsing of
function goals, and update the expected outputs accordingly.
Estimated hours taken: 8
Branches: main
Allow the browser to refer to fields by name.
browser/browser_info.m:
Generalize the data structure for recording paths within terms to allow
navigation by field names.
browser/browse.m:
browser/program_representation.m:
Update the algorithms for navigation in terms accordingly.
browser/parse.m:
Update the algorithm for reading in navigation terms.
Allow digits as well as letters and underscores in "names", since
field names may contain digits as well. This should not impact
other uses of names by the other parts of the debugger.
library/std_util.m:
Add new predicates named_argument and det_named_argument. They are
implemented using ML_named_arg, a new C function which is the same
as ML_arg except that it specifies the selected argument by name.
NEWS:
Mention the new predicates.
runtime/mercury_ml_expand_body.h:
Add a new alternative, EXPAND_NAMED_ARG, for use in implementing
ML_named_arg.
tests/debugger/field_names.{m,inp,exp,exp2}:
Expand this test case to exercise the browser.
Estimated hours taken: 0.2
Branches: main
browser/browse.m:
Make the prettyprinters in this file use limited_deconstruct to avoid
performance problems with large arrays.
Estimated hours taken: 4 + 4 in mail
Branches: main
Allow the RTTI routines and the debugger to treat arrays as other types.
The RTTI routines used to pretend that terms of array type had no arguments.
This led the browser to believe that their size was small, and handed them
over to io__write, which then printed the entire array. For large arrays,
this could take minutes. It also led the browser to believe that you can't
"cd" to an element of an array.
The RTTI routines now treat arrays mostly like they treat tuples, which fixes
both problems.
The debugger's prettyprinters do not yet use limited_deconstruct; that is
future work.
library/std_util.m:
Add a new predicate, limited_deconstruct, which usually does what
deconstruct does, but fails (and does not allocate any memory) if
the arity of the supplied term is beyond a given limit. With normal
terms, the memory allocated by deconstruct to hold the typeinfos
of the arguments is not a problem. However, arrays can have millions
of elements, and for them this *is* a problem. Programmers can avoid
this problem by using limited_deconstruct instead of deconstruct.
Make ML_arg (used by the arg and argument predicates) avoid the
construction of a typeinfo vector for all the arguments, for the same
reason.
Since we now need more variants of ML_expand than ever, and we don't
want the new, relatively rarely used functionality to slow down the old
functionality, create several variants of ML_expand, each specialized
to a given use, and choose between them at compile time, not run time.
This should actually speed up the old functionality.
runtime/mercury_ml_expand_body.h:
A new file which is included several times in library/std_util.m,
containing the bodies of the several variants of the old ML_expand.
runtime/Mmakefile:
Mention the new file.
browser/browse.m:
Avoid unlimited deconstructions when checking whether the term fits
within the size range we give to io__write.
Special case path resolution on terms of type array, because while
in the debugger we count arguments from one, array elements start at
index zero, and any other behavior would be misleading.
tests/hard_coded/deconstruct_arg.{m,exp}:
A new test case to check the various variants of ML_expand through
its callers, the predicates functor, argument, deconstruct and
limited_deconstruct, on all kinds of data types.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 40
Branches: main
This is the second part of a change to support term dependency analysis
in the declarative debugger. A `mark' command is implemented for the
term browser, which allows a particular subterm to be selected and
returned from the browser. The declarative debugger interprets this as
a suspicious subterm, and tries to find a child or sibling node from which
this subterm comes. This is used to determine the next question to be
asked of the oracle.
browser/browse.m:
Update the browser interface to allow for marked subterms being
returned from the browser.
Implement and document the mark command.
Rewrite run_command as a switch instead of a chain of if-then-elses.
This forces all unimplemented commands to be explicitly listed,
and gives better error checking.
browser/browser_info.m:
Add a maybe_mark field to the browser_info. It is initially `no',
but is updated when the mark command is given.
browser/declarative_analyser.m:
Select which child or sibling node to ask about next by searching
for the origin of the suspicious subterm. If the subterm has mode
`out' we act as if the oracle had answered no, and if the subterm
has mode `in' we act as if the oracle had answered yes. In future
we may not wish to presume this -- we do so now mainly to keep the
analysis algorithm simpler.
browser/declarative_debugger.m:
Add a functor for suspicious subterms to the decl_answer type.
browser/declarative_oracle.m:
Accommodate the changed answer type. The oracle does not try to
store information about suspicious subterms in the knowledge base,
because in principle this could lead to infinite loops (although
currently this wouldn't be a problem since we don't ever use the
information to move upward in the tree, so no cycle could be
formed).
browser/declarative_user.m:
Accommodate the changed answer type, and interpret marked terms
from the browser as suspicious subterms.
browser/parse.m:
Add the new command.
browser/program_representation.m:
Add a procedure to convert the browser's list(dir) to a term_path.
Change atomic_goal_rep_is_call/2 so it fails for special predicates,
which was originally intended.
trace/mercury_trace_browse.c:
Ignore the extra argument -- marked terms are not currently used in
the main debugger.
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/input_term_dep.*:
tests/debugger/declarative/output_term_dep.*:
tests/debugger/declarative/special_term_dep.*:
New test cases.
Estimated hours taken : 185
Added a new pretty printing format to the term browser. This new format
helps put a limit on the size of the term printed during debugging.
This limit is specified by setting the number of lines you want the term
to be printed on and the width of these lines. Refer to sized_pretty.m for
Examples.
browser/sized_pretty.m:
New file that does what's described above.
browser/browse.m:
browser/browser_info.m:
browser/mdb.m:
browser/parse.m:
trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
trace/mercury_trace_internal.c:
Modified to accommodate the new format.
tests/debugger/browse_pretty.inp:
tests/debugger/browser_test.inp:
Included test cases for the new pretty printing format.
tests/debugger/browse_pretty.exp:
tests/debugger/browser_test.exp:
Changed the expected output.
Estimated hours taken: 10
This change makes univ a user-defined type (in std_util.m) rather than
a builtin type.
The rationale for this is that the code for builtin types needs to be
maintained by hand when the execution model is changed (eg introducing
a new backend), but code for user defined types is modified implicitly.
Note that the semantics of deconstruct/4 have changed. See the NEWS file
for details.
NEWS:
Document the changed semantics of deconstruct/4.
browser/browse.m:
Fix the calls to deconstruct/4 to reflect the changed semantics
of deconstruct.
library/io.m:
Remove the special handling of univ for io__write.
Fix the calls to deconstruct/4 to reflect the changed semantics
of deconstruct.
library/private_builtin.m:
Implement typed_unify and typed_compare in terms of type_of and
unsafe_type_cast instead of univ, so that preds/funcs operating
on univs can be implemented in terms of typed_unify.
Add a new impure predicate var/1 which succeeds/fails depending on the
instantiation of its argument. This is used to implement bidirectional
predicates that require different code for different modes
(cf type_to_univ/2).
This is *not* mentioned in the NEWS file because it should only
be used by implementors. (Well, actually, anyone who wants to do
bidirectional code involving existential types may need it, but
we don't exactly want to encourage its use ;-).
library/std_util.m:
Implement univ/0 as a user-defined type rather than a hand coded
builtin type.
Removed the foreign language code to implement the operations on
univs (include unify/2 and compare/3).
The implementations of deconstruct, et al, now call back to Mercury
to construct/deconstruct univs, so the code of these has changed.
Note that there has been an implicit change in the semantics of
deconstruct/4, which had non-orthogonal handling of univ inputs.
It now handles them orthogonally: deconstruct of a univ yields the
functor "univ_cons" and its one argument which will be the wrapped
value. The non-orthogonal behaviour wasn't documented before, so
deconstruct/4 now behaves as its documentation describes it.
library/term.m:
Fix the call to deconstruct/4 to reflect the changed semantics
of deconstruct.
runtime/mercury.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_mcpp.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.h:
runtime/mercury_unify_compare_body.h:
Remove declarations and definitions for univ since it is now a
user level type rather than a builtin type.
trace/mercury_trace_declarative.h:
trace/mercury_trace_external.h:
trace/mercury_trace_internal.h:
Replace the hand-coded constructions of univs with call backs
to ML_construct_univ.
Estimated hours taken: 25
Enhance the configuration parameters of the browser. The browser is now
sensitive to the type of caller (print, browse, or print *) and can have
different settings for each type. E.g., the default line limit per variable
can be made shorter for `print *' than for `print'. The browser also allows
different settings for each format.
The browser also accepts an optional format, which overrides the current
setting for the duration of the call.
To make use of these features, mdb has a new `set' command that allows the
settings to be updated in various ways. The browser version of `set'
still works, although it doesn't yet accept the options that the former does.
Also, `print' and `browse' can now take options that override the default
format.
browser/browser_info.m:
New module which defines the key browser data structures. The
`browser_state' previously used by browse.m has been split into
two parts: the transient state (browser_info) and the persistent
state (browser_persistent_state). The persistent state is created
when the browser is first called, and is saved between calls to the
browser, whereas a new transient state is created each time the
browser is called, and lasts for the duration of the call.
The persistent state contains settings for each possible combination
of format and caller type.
This module exports C functions that update the persistent state.
browser/browse.m:
Move the browser_state into the new module.
Change the interface so that it allows optional format and caller
type input arguments. This allows its behaviour to vary depending on
whether the caller is implementing `print', `browse', or `print *'.
It also allows the default format to be overridden by options to
these commands.
General rearrangement of the browser code to avoid code duplication.
This addresses the following comment from the module:
% XXX: could abstract out the code common to the following preds.
along with other similar problems.
The code for testing the size of a term and deciding between
`io__write' and a depth limited printer has been moved from `print'
to `portray_flat'. This allows `print' to be used with formats
other than flat.
TODO: allow browser commands to take format options; currently only
mdb commands can.
browser/declarative_user.m:
Update this for the changed interfaces.
browser/mdb.m:
Add the new module.
browser/parse.m:
Move the definitions of `dir', `setting', and `portray_format'
to the interface of the new module.
The argument to the `<' command, which sets the depth limit, is
no longer optional. The default used to be to use the system
default, but now there are multiple system defaults and no way to
select which one.
browser/*.m:
tests/debugger/browse_pretty.inp:
tests/debugger/browse_pretty.exp:
s/clipx/width/g
s/clipy/lines/g
The reason for this change is that the names are used in the
context of all formats, but only verbose format actually clips
the output, so `clipx' and `clipy' are misleading.
tests/debugger/browser_test.inp:
tests/debugger/browser_test.exp:
Test the new features.
doc/user_guide.texi:
Document the new features.
trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
Allow extra arguments for the print and browse functions, to specify
the format and the caller type (in the case of print).
Export the function MR_trace_set_browser_param, which calls the
browser to do the work of mdb's set command.
Export the types MR_Browse_Caller_Type and MR_Browse_Format, which
mirror two of the types in the new browser module.
trace/mercury_trace_external.c:
Update for the change to MR_trace_browse_one: pass `browse' as
the caller type, and always use the default format.
trace/mercury_trace_internal.c:
Add functions to parse the format and caller type options. Update
the print and browse commands to expect format options. Add the
`set' command.
Replace MR_trace_print_var and MR_trace_browse_var with one function,
MR_trace_browse_internal. This function takes the caller type as an
argument, so there is no need for two functions.
Remove occurrences of:
/* XXX should use MR_mdb_in and MR_mdb_out */
since we already do this.
trace/mercury_trace_vars.c:
trace/mercury_trace_vars.h:
Change the function type MR_Browser so that it also expects a caller
type and a format. These arguments are now required by the browser.
This means that some of the functions that take an MR_Browser
argument needed to be updated to also take a caller and/or format,
so they can pass this on to the browser function when it is called.
Estimated hours taken: 8
Use the term browser to print arguments in the declarative debugger.
browser/browse.m:
Remove (unused) io__state arguments from browse__init_state.
Export term_size_left_from_max/3 for use by the declarative
debugger.
browser/declarative_user.m:
Add a browser_state field to the user_state type.
Implement the `browse' command for checking questions as well as
for verifying the bug that is reported at the end of the process.
The original plan was to browse the whole atom at once, but this
is not possible with the current browser, so we instead browse one
argument at a time. The `browse' command now expects an integer
that specifies which argument.
Modify write_decl_atom/5 so that it checks whether the atom size
is below a certain limit. If not, then it calls browse__print/5
to do the output.
tests/debugger/declarative/app.exp:
tests/debugger/declarative/app.exp2:
tests/debugger/declarative/filter.exp:
tests/debugger/declarative/filter.exp2:
Update test cases.
Estimated hours taken: 1
browser/browse.m:
Portray terms using the standard pretty printer. This mode
is not yet used by default, since there is no term size limit.
tests/debugger/Mmakefile:
tests/debugger/browse_pretty.m:
tests/debugger/browse_pretty.inp:
tests/debugger/browse_pretty.exp:
Test case for this new feature.
Estimated hours taken: 0.2
Fix a bug in the term browser: the term size limit was by default
being set to the default depth value, 10. The depth value was
hard-coded to 3. Since 3 is a more sensible depth limit (atleast
for the one-line printing that the internal debugger does), the default
has been changed to that.
browser/parse.m:
Set the intended default depth to 3.
browser/browse.m:
Set the browser defaults in a more readable fashion.
Don't hard-code the default depth limit in the help message.
Estimated hours taken: 40
Clean up the runtime system's handling of type_infos and pseudo_type_infos.
This cleanup has two major aspects. First, it represents type_infos and
pseudo_type_infos with distinct C types, and reducing the use of casts
to the minimum. These casts are in two kinds of places: in a few macros
defined in runtime/mercury_type_info.h, and at the interfaces between C code
and Mercury code (since Mercury code represents (pseudo-)type_infos, like
everything else, as Words). Part of this aspect is the separation of the
type "MR_TypeInfo" from the type "MR_TypeInfoParams"; a MR_TypeInfo can be
used as a source of type parameters directly only when it is first order.
Second, it removes the confusion between the types named "type_info" and
"type_ctor_info" defined by the modules private_builtin.m and std_util.m,
by renaming the types defined in std_util.m to "type_desc" and
"type_ctor_desc".
To avoid doing this cleanup twice, this diff also removes support for the
old type_ctor_info representation. This in turn makes it feasible to provide
conditionally enabled code to support unification and comparison by RTTI.
runtime/mercury_grade.h:
Increment the binary compatibility version number. This is required
by the dropping of support for old type_ctor_info representations.
runtime/mercury_type_info.h:
Define the types MR_TypeInfo, MR_PseudoTypeInfo and MR_TypeInfoParams,
and macros that operate on them.
Remove the types and macros that were useful only with the old RTTI
representation.
Move the section that deals with initializing code addresses in
type_ctor_info structure for grades without static code addresses
to the logical place.
Add a const qualifier to the MR_sectag_alternatives field in
MR_DuPtagLayout, since this simplifies code manipulating du types.
Convert the whole file to 4 space indentation, since it is a nuisance
if only part of it is so indented.
runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_tabling.c:
Clean up the implementation as described above.
runtime/mercury_type_info.c:
runtime/mercury_make_type_info_body.h:
Clean up the implementation as described above.
Eliminate the code duplication between the function MR_make_type_info
and MR_create_type_info, and their helpers, which do the same thing
except for how they allocate memory, by putting the common code into
the new file mercury_make_type_info_body.h, and including it twice
in two different #define contexts.
Move the (updated) documentation of those functions to
mercury_type_info.h, where it belongs.
runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
Clean up the implementation as described above.
Eliminate the code duplication between the implementation of unify
and compare, which do very similar jobs, by putting the common code
into the new file mercury_unify_compare_body.h, and including it three
times in two different #define contexts. The third time is for defining
the body of a C function which does the same thing as compare. This
is necessary for unification and comparison by RTTI, since the
unification or comparison of two structured terms requires comparing
their subterms. (There is no need for a separate C function for
unification; the C comparison function is sufficient.)
mercury_unify_compare_body.h has conditional support for unification
and comparison by RTTI. Although this has been tested and is known
to work, it is turned off for the moment. This may change after
benchmarking.
runtime/Mmakefile:
Add the new include files to the list.
library/std_util.m:
Rename type_info to type_desc and type_ctor_info to type_info_desc.
Keep the old names as equivalence types, for the time being.
Document the representations.
Move the macros that refer to type_descs and type_ctor_descs here from
runtime/mercury_type_info.h, since this is the only place where they
are used. Rename them to conform to the new names of the types.
Clean up the implementation of the RTTI predicates and functions
as described above. In the process, fix some bugs where type variables
were expanded twice, with the second expansion's code being incorrect.
Also factor out some common code, and unfactor some uncommon code
(where a function had two uses, but its implementation was inefficient
overkill for one of them).
library/builtin.m:
library/private_builtin.m:
library/io.m:
library/store.m:
runtime/mercury_layout_util.[ch]:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.[ch]:
When calling C functions involving type_infos, cast them to the new
types.
runtime/mercury_stack_layout.h:
Fix a bug that was masked by casts in its client code.
compiler/rtti_out.m:
Delete from the output a cast made unnecessary by the new const
qualifier on MR_sectag_alternatives.
browser/browse.m:
browser/help.m:
library/io.m:
library/term.m:
tests/hard_coded/construct.m;
tests/hard_coded/existential_types_test.m:
tests/hard_coded/higher_order_type_manip.{m,exp}:
Refer to the types defined in std_util.m by their new names.
tests/hard_coded/existential_rtti.{m,exp}:
Make the test tougher by printing out not just one deconstructed term,
but deconstructed versions of all the terms created by this test.
Estimated hours taken: 1
Make all the modules in the browser library sub-modules of
module `mdb', to avoid link errors when users use module names
such as `parse'.
browser/Mmakefile:
browser/browser_library.m:
browser/mdb.m:
Rename browser_library.m to mdb.m.
Change `:- import_module' declarations to
`:- include_module' declarations.
browser/Mmakefile:
Remove the special case rule for `mer_browser.init' --
it doesn't work when the file names are not the same
as the module name. Instead, the default rule for `mdb.init'
is used and the output is copied to `mer_browser.init'.
browser/.cvsignore:
Rename header files, etc.
browser/*.m:
Add a `mdb__' prefix to the names of modules in the browser library
in `:- module' and `:- import_module' declarations.
trace/*.c:
Rename the header files for the browser library in
`#include' statements.
tests/hard_coded/Mmakefile:
tests/hard_coded/parse.m:
tests/hard_coded/parse.exp:
Test case.
Estimated hours taken: 6
If calling from the internal debugger, use readline input for the
interactive term browser and interactive queries.
browser/browse.m:
Change some if-then-elses to switches, which will help
catch errors if a new functor is added to the debugger type.
browser/parse.m:
browser/util.m:
Return a string from util__trace_getline/4 rather than a
list of chars, which saves converting from a string to a list
of chars and then back again.
browser/util.m:
Add a version of util__trace_getline that also takes I/O
stream arguments. Pass these arguments to MR_trace_getline.
browser/declarative_oracle.m:
Call util__trace_getline/4 to do input via readline (if
available). Improve error handling.
browser/interactive_query.m:
Call util__trace_getline to get user input, instead of
standard library predicates.
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
Add two I/O stream arguments to MR_trace_getline.
Estimated hours taken: 20
Incorporate the term brower stuff in the external debugger.
browser/browse.m:
Define browse__browse_external() which is the same as browse__browse()
but for the case where the term browser is called from the external
debugger.
Add an argument in predicates that need it to indicate whether the term
browser was called from the external or the internal debugger.
Define write_string_debugger/4, nl_debugger/3, write_int_debugger/4,
print_format_debugger/4 predicates and call them in place of
io__write_string/4, io__nl/3, io__write_int/4, and io__print/4
respectively. If the term browser is called from the internal debugger,
those predicates call the predicates they replace; otherwise, they
send their argument to the socket via a term of type
term_browser_response.
browser/debugger_interface.m
Define a new debugger request `browse/1'.
Define get_variable_name/2 that allows to retrieve from
mercury_trace_external.c the name of the variable to browse.
browser/parse.m:
Define parse__read_command_external/3 that parses the browser command
sent through the socket.
runtime/mercury_layout_util.c:
trace/mercury_trace_internal.c:
Move the definition of MR_trace_find_var() and
MR_trace_validate_var_count() from mercury_trace_internal.c to
mercury_layout_util.c to make it available to the external debugger.
runtime/mercury_layout_util.h:
trace/mercury_trace_internal.c:
Move the definition of MR_Var_Spec_Kind and MR_Var_Spec from
mercury_trace_internal.c to mercury_layout_util.h to make it
available to mercury_layout_util.c.
trace/mercury_trace_browse.ch:
Define the function MR_trace_browse_external() which is the same
as MR_trace_browse() except it uses the external debugger socket
instead of mdb_in and mdb_out.
trace/mercury_trace_external.c:
Define MR_trace_browse_one_external(), MR_trace_browse_var_external()
which are the same as MR_trace_browse_one() and MR_trace_browse_var()
of mercury_trace_internal.c, but for the use of the external debugger.
Define MR_get_variable_name() that calls get_variable_name/2 defined
in debugger_interface.m.
Estimated hours taken: 5
Use the same method of input for the browser as for the internal
tracer. Previously, the browser did input via the Mercury library
and the internal tracer did input via readline (if available). This
did not work properly if files were redirected into stdin, which meant
that test cases could not be written for the browser. This change
also adds a test case.
browser/util.m:
Add a predicate, util__trace_getline/4, which does input via
the same method used by the internal debugger.
browser/parse.m:
Call util__trace_getline/4 instead of io__read_line/3.
browser/browse.m:
Pass the prompt to browser/parse.m as a string, rather than
printing it before calling.
trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
Declare MR_trace_getline extern.
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
Make MR_trace_getline available to the browser via a function
pointer.
tests/debugger/Mmakefile:
Add the new test case.
tests/debugger/browser_test.m:
tests/debugger/browser_test.inp:
tests/debugger/browser_test.exp:
The new test case.
runtime/mercury_trace_base.c:
runtime/mercury_trace_base.h:
Export MR_tracing_not_enabled() for use by browser/util.m.
Estimated hours taken: 1
Avoid a two-three second delay in the printing of (the top levels of) large
data structures such as module_infos in the debugger.
browser/browse.m:
Instead of computing the exact size of the term when we check whether
we can print it in full, compute the size only up to the maximum,
and skip the rest. This lets us avoid traversing 99+% of typical
module_infos.
Estimated hours taken: 1
Part 2 of adding support to mdb for doing the debugger I/O in
a different window to the I/O of the program being debugged:
ensure that the browser I/O goes to the debugger I/O streams.
browser/browse.m:
Undo Tyson's changes to add the I/O streams to the browser
state. Instead, add I/O streams as extra arguments to
browse__browse and browse__print.
trace/mercury_trace_browse.c:
Convert the debugger I/O streams from FILE* to MercuryFile*
and pass them to browse__browse and browse__print.
trace/mercury_trace_internal.h:
trace/mercury_trace_internal.c:
Export the variables holding the mdb I/O streams,
for use by mercury_trace_browser.c.
Estimated hours taken: 0.25
browser/browse.m:
Print the output to stdout rather than stderr,
for consistency with the rest of mdb's output,
and to avoid breaking all the test cases in
tests/debugger.
Estimated hours taken: 3
Fix a bug in the debugger -- the term printing wasn't working after
you had changed the output stream -- output would be sent to the
program's output stream instead of the debugger's output stream.
browser/browse.m:
Fix the output and input streams used for the term browser.
Estimated hours taken: 2.75
Change the mdb `print' command so that it invokes the non-interactive
version of the term browser, and change the way the browser is invoked
so that the browser state is preserved across multiple invocations
of `print' or `browse' in a single mdb session.
browser/browse.m:
Make `browser_state' an abstract type.
Add new predicate `browse__init_state' to initialize that ADT.
Change the interface to `browse__browse' so that it takes and
returns the old and new browser_states.
Add a new predicate `browse__print' to replace the old
`browse__portray_root' predicate; this is the non-interactive
version of the browser. It calls io__write_univ if the term
is small enough, and browse__portray (with flat format) otherwise.
Export the `browse__print' and `browse__init_state' predicates to C.
Delete the predicates for formatting terms as strings, since that
code was a potential double-maintenance problem and was not needed.
library/io.m:
Export `io__write_univ', for use by browser/browse.m.
trace/mercury_trace_browse.h:
trace/mercury_trace_browse.c:
New files. These provide an interface to the browser
which preserves the browser state in a C static variable.
trace/Mmakefile:
Add the new files mercury_trace_browse.{h,c} to the appropriate
file lists.
trace/mercury_trace_internal.c:
Change the `browse' and `print' mdb commands to use the new
functions defined in mercury_trace_browse.{h,c} rather than
calling browser__browse and io__print (respectively), and don't
print a newline afterwards, since the browser does that itself.
Delete the old hack to avoid printing out HLDS and ModuleInfo,
since it's not necessary any more.
doc/user_guide.texi:
Update the documentation for the `browse' and `print' commands
to reflect these changes.
tests/debugger/*.exp:
tests/debugger/*.exp2:
Update the expected output from the debugger to reflect these changes.
Estimated hours taken: 2
Add an mdb command to invoke the term browser.
trace/mercury_trace_internal.c:
Add code to implement a new command `browse', which invokes
the interactive term browser in browser/browse.m.
doc/mdb_categories:
doc/user_guide.texi:
Document the new `browse' mdb command.
Also simplify the documentation on the `print' command.
browser/browse.m:
Change browse/3 so that it takes an argument of type `T' rather
than `univ'.
library/std_util.m:
Modify ML_expand() so that it does not abort for values of type
c_pointer, type_info, or array(T). This is to prevent the
browser from aborting when trying to display values of those types.
Estimated hours taken: 40
Add a simple term browser for use by the trace-based debugger.
This is minimal but useful browser. Not included in this version
are a scripting language, Windows Explorer-style tree expansion,
and other features not yet thought of.
N.B. This still needs to be hooked into the debugger.
browser/Mmakefile:
Added target browse_test.
browser/browser_library.m:
Added modules required for the browser.
browser/browse_test.m:
A simple driver for the browser with an example
data structure to browse. (new file)
browser/browse.m:
The browser proper. (new file)
browser/parse.m:
Parser for browser's command language. (new file)
browser/util.m:
Miscellaneous utilities used in the browser code. (new file)
browser/frame.m:
Bare minimal ASCII graphics frames. (new file)