mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 23:05:21 +00:00
ece0aa1a66cc2651a74c26a90cc1e5f901c81db0
14 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ecdc285bc7 |
Split the existing browser library into two libraries, by making the
Estimated hours taken: 10 Branches: main Split the existing browser library into two libraries, by making the program_representation module into its own library. This is useful because the compiler refers to program_representation.m, whose code thus needs to be linked into compiler executables even if the compiler isn't compiled with debugging enabled. By creating a new library for this module, we avoid any chance of the linker dragging in the rest of the modules in the browser library. (This is a problem with an upcoming diff.). The name of the new library is "mdbcomp", because the intention is that it contain code that is shared between the debugger and the compiler. This means mostly the definitions of data structures that the compiler generates for the debugger, and the predicates that operate on them. Mmake.common.in: Allow MDB_COMP_ as a prefix for symbol names in the browser directory. Mmake.workspace: Add a make variable holding for the name of the new library, and add the name to the relevant lists of libraries. Avoid duplicating the lists of filenames that need to be updated when adding new libraries or changing their names. Mmakefile: Use make variables to refer to library names. browser/mdbcomp.m: browser/mer_mdbcomp.m: Add these files as the top modules of the new library. browser/program_representation.m: Make program_representation.m a submodule of mdbcomp, not mdb. browser/program_representation.m: browser/browser_info.m: Move a predicate from program_representation.m to browser_info.m to avoid the mdbcomp library depend on the browser library, since this would negate the point of the exercise. browser/mdb.m: Delete program_representation.m from the list of submodules. browser/Mmakefile: Update this file to handle the new module. browser/Mercury.options: Mention the new module. browser/*.m: Update the lists of imported modules. Import only one browser module per line. compiler/notes/overall_design.html: Document the new library. compiler/compile_target_code.m: Add the mdbcomp library to the list of libraries we need to link with. compiler/prog_rep.m: trace/mercury_trace_internal.c: Import program_representation.m by its new name. scripts/c2init.in: Centralize knowledge about which files need to be updated when the list of libraries changes here. scripts/c2init.in: scripts/ml.in: tools/binary: tools/binary_step: tools/bootcheck: tools/linear: tools/lml: Update the list of libraries programs are linked with. |
||
|
|
bed904e722 |
Make browsing in the debugger more flexible by adding options to the "ls",
Estimated hours taken: 8 Branches: main Make browsing in the debugger more flexible by adding options to the "ls", "print" and "set" commands of the browser. Make browsing in the debugger less confusing by making the "set" command by default set the parameters used not just by the "ls" command but also by the "print" command, both inside and outside the browser. This is done by making "ls" and "print" synonyms inside the term browser. browser/parse.m: Replace the commands ls/0, ls/1 and print/1 with a single command, print/2. The arguments of print/2 specify - the presence or absence of options controlling which formatter to use, and - the path to the subterm to look at (which the "ls" command had, but not the "print" command). Change the set/1 command into the set/2 command, adding a field specifying the presence or absence of options controlling which caller type and/or which formatter parameters to set. The set/2 command within the browser prompt now functions the same as the "set" command from the mdb prompt, because they now call the same code to update the parameter sets. Change the parsing infrastructure to allow the use of getopt to process the options, by keeping around the word structure even after tokenization. Comment out code that isn't called, but may be needed later for debugging. Update the block comment documenting the command syntax. browser/browse.m: Conform to the change in the type of commands. Change the implementation of the "set" command. Instead of the default being to change only the parameter set used by the "ls" command, make the default the application of the change to all the parameter sets. If users want to restrict the change to apply only to the "ls" command, they can specify the -B option. Change the implementation of the set/0 command to report not just one set of parameters, but all of them, since they can now all be changed by the set/2 command. Update the help message, to show the new options and to group related commands together. browser/browser_info.m: Provide variants of the predicates for changing settings that are specialized for the requirements of mdb and of the term browser. Change the default format for the browser to "flat", to match the default for the mdb "print" command. This was the default for the browser's print command as well. This changes the default behavior of the browser's "ls" command. Since "print" and "ls" had different defaults but are now synonyms, we had to break backward compatibility for one or the other. (Preserving different defaults for these two browser commands would create an unnecessarily complicated user interface with respect to the meaning of their options.) browser/declarative_user.m: Make it possible to switch the parameter set used to by the declarative debugger to print atoms quickly yet consistently. trace/mercury_trace_browse.c: Call the C versions of the parameter setting predicates. (The versions for use from within the term browser specify the parameters a different way). tests/debugger/browser_test.exp: tests/debugger/exception_value.exp: tests/debugger/polymorphic_output.exp: tests/debugger/declarative/browse_arg.exp: Update the expected outputs to comply with the changes above. |
||
|
|
3e766fcd11 |
Print streams sensibly in the debugger.
Estimated hours taken: 6
Branches: main
Print streams sensibly in the debugger.
runtime/mercury_library_types.h:
Define MercuryFilePtr as a shorthand for MercuryFile *.
library/io.m:
Define a user-friendly representation for streams that includes not
just the stream's name but all the info about the stream that user
using mdb may wish to know about the stream, as well as a unique stream
id.
Make the changes required to maintain this improved stream database.
If the program is being executed under mdb, then do not ever delete
items from the stream database, since e.g. the declarative debugger
may need to print the stream's representation even after the stream
is closed. (If executing outside mdb, then we delete a stream's entry
from the stream database when the stream is closed, as before.)
To allow the debugger to detect which variables are I/O streams,
change the stream types from being equivalent to c_pointer (and thus
indistinguishable from other c_pointers) to their own type. Implement
this type as MercuryFilePtr in the C backend. In the IL backend, we
represent it as Object[], the minimum representation change possible.
Use the C type definition to get rid of many casts.
When writing streams, write the user-friendly representation, not
a meaningless <<c_pointer>>.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
runtime/mercury_layout_util.c:
The change in stream's representation changes the types of some of the
arguments of functions exported to C from io.m; conform to those
changes.
browser/browse.m:
browser/sized_pretty.m:
In each of the mechanisms that the debugger can use to display terms,
pass along the stream name database.
browser/browser_info.m:
When deconstructing terms that are streams, return the stream's
user-friendly id, not a c_pointer.
browser/browse_test.m:
Update this test program to test the new way of printing streams.
runtime/mercury_trace_base.[ch]:
Define the MR_trace_ever_enabled variable to let io.m know whether
it is allowed to ever discard stream info.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
Update the types of the functions dealing with streams to use
MercuryFilePtr to refer to streams instead of MR_Word. These functions
are implemented by Mercury predicates exported to C.
runtime/mercury_wrapper.c:
Set MR_trace_ever_enabled to true when execution tracing is enabled.
This is the only assigment to MR_trace_ever_enabled after
initialization to the default (false).
tests/debugger/declarative/io_stream_test.{m,inp,exp,exp}:
A new test case to test the debugger's printing of I/O streams.
tests/debugger/declarative/Mmakefile:
Enable the new test case.
|
||
|
|
b177463322 |
Fix some problems where we were calling the incorrect predicates from
Estimated hours taken: 1
Branches: main
Fix some problems where we were calling the incorrect predicates from
deconstruct.m.
browser/browser_info.m:
Change limited_deconstruct_browser_term_cc to use the
std_util__limited_deconstruct_cc.
Change deconstruct_browser_term_cc to use std_util__deconstruct_cc.
browser/browse.m:
browser/sized_pretty.m:
Handle the changes to limited_deconstruct_browser_term_cc.
|
||
|
|
2040556da6 |
Make it easier to print and browse I/O actions in the declarative debugger.
Estimated hours taken: 6
Branches: main
Make it easier to print and browse I/O actions in the declarative debugger.
browser/browser_info.m:
Add a new component to the debugger's permanent state to record the
user's preference as to how many I/O actions can be printed with each
atom. If an atom has this many I/O actions or fewer, they are printed.
If it has more, only a notice about too many I/O actions to show is
printed, and the user has to look up the actions manually.
browser/browse.m:
Update the help message and the printing of the current settings
accordingly.
browser/parse.m:
Add a new piece of functionality to the "set" browser command,
"set num_io_actions <n>", that allows the user to set the value
of this new parameter.
browser/declarative_user.m:
Delete the old, undocumented command "io <action_num>". Replace with
two new command forms, "print io <from_action_num>[-<to_action_num>]"
and "browse io <action_num>". "browse io" does what the old "io"
command did, but using this to print many I/O actions is clumsy;
that's what "print io" is for.
For symmetry, also add "print <from_arg_num>[-<to_arg_num>]".
Respect the new, user-configurable limit on the number of I/O actions
printed with each atom.
tests/debugger/declarative/tabled_read_decl.{inp,exp}:
Add some tests of the new functionality.
|
||
|
|
70b07845f0 |
Make the commands that update the browser parameters within the browser itself
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. |
||
|
|
b51c742885 |
Allow the debugger to print higher order values and typeinfos, mainly by
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.
|
||
|
|
ed83014595 |
Make the debugger use the committed choice versions of the
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. |
||
|
|
e1778fbc75 |
Give the debugger the ability to print goals.
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.
|
||
|
|
86744fd357 |
Allow the browser to refer to fields by name.
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.
|
||
|
|
d30c239986 |
Set the pretty printing flags (which represent Mercury bools) using
Estimated hours taken: 0.5 Branches: main trace/mercury_trace_browse.c: trace/mercury_trace_browse.h: trace/mercury_trace_internal.c: Set the pretty printing flags (which represent Mercury bools) using functions exported from Mercury code, rather than using TRUE and FALSE. This removes the assumption that Mercury bools have the same representation as C bools, which was causing a problem when --reserve-tag was used. Change the type of these flags to MR_Word. According to the reference manual, this is the type Mercury bools have when passed to C code. browser/browser_info.m: Export functions that construct Mercury bools. |
||
|
|
75a2a90cbb |
This is the second part of a change to support term dependency analysis
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. |
||
|
|
35b80dcc98 |
Added a new pretty printing format to the term browser.
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.
|
||
|
|
6cd413a850 |
Enhance the configuration parameters of the browser.
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. |