Commit Graph

60 Commits

Author SHA1 Message Date
Zoltan Somogyi
dd44e0ef62 Replace the "set" command of mdb with a bunch of commands: the `format',
Estimated hours taken: 16
Branches: main, release

Replace the "set" command of mdb with a bunch of commands: the `format',
`format_param', `list_context_lines', `list_path', `xml_browser_cmd',
`xml_tmp_filename', `fail_trace_counts', `pass_trace_counts' and
`max_io_actions' commands. Each of these set just one parameter
or one of set of closely related parameters.

Move all these commands, and some existing commands that set parameters
that were elsewhere, to the "parameter" command category.

Extend some of these commands so that if given no arguments, they report
the current values of the parameters they would otherwise set.

Replace the "set" commands of the mdb browser and of the declarative debugger
with a bunch of commands: "format", "depth", "size", "width", "lines",
"actions" and "params" (the last prints the current value of the parameters).

For each category of mdb commands, create files mercury_trace_cmd_<cat>.[ch],
and move the functions dealing with that category of commands there from
mercury_trace_internal.c. Give each of these new files a logical structure
that was sometimes missing from the relevant parts of mercury_trace_internal.c.

NEWS:
	Mention these changes.

doc/mdb_categories:
	Document these changes.

doc/user_guide.texi:
	Document these changes.

	Fix an old documentation bug: you couldn't set listing paramaters
	from a declarative debugger command.

	Fix an old documentation bug: the description of the goal_path step
	for scopes was obsolete.

	Fix some obsolete references to : as module qualifier.

browser/parse.m:
	Update the browser command set along the lines at the top.

browser/declarative_user.m:
	Update the declarative debugger command set along the lines at the top.

	Move the declaration for the type representing declarative debugger
	commands to near the top of the file.

browser/browser_info.m:
	Provide some access predicates.

	Update the predicate that generates mdb commands to save the persistent
	state of the debugger to generate the new forms of parameter commands.

	Move types and predicates for dealing with browser parameters from
	browse.m to here, so that declarative_user.m can use them too.

browser/browse.m:
	Delete the code moved to browser_info.m, and conform to the other
	changes in the other modules.

browser/listing.m:
	Provide a predicate to return the type of listing paths.

scripts/mdbrc.in:
	Update the commands that set the XML parameters.

scripts/Mmakefile:
	Get mmake to rebuild mdbrc from mdbrc.in when mdbrc.in changes.

trace/mercury_trace_internal.c:
trace/mercury_trace_cmds.h:
trace/mercury_trace_cmd_*.[ch]:
	Implement the changes described at the top.

	Fix an old bug: the commands that update the search path for the "list"
	command don't make the search path term permanent, which is needed in
	non-conservative-gc grades.

trace/mercury_trace_spy.c:
	Fix some obsolete references to : as module qualifier.

trace/mercury_trace_browse.[ch]:
	Delete the functionality now moved to mercury_trace_cmd_parameter.c.

tests/debugger/mdb_command_test.inp:
	Update the set of commands being tested.

tests/debugger/save.{inp,exp}:
	Update the parameter commands in this test case.
2006-04-04 07:37:31 +00:00
Zoltan Somogyi
892bf00ce2 XXX: the change to the mdb "set" command is not yet documented; that will be
Estimated hours taken: 3
Branches: main

XXX: the change to the mdb "set" command is not yet documented; that will be
addressed in the next change.

Fix the debugger's save command so that it saves everything it should save
(with one unavoidable exception). Rename the "save_to_file" command to "dump",
as we agreed.

NEWS:
doc/user_guide.texi:
doc/mdb_categories:
	Document these facts.

browser/browser_info.m:
	Provide a predicate to save the entire persistent state of the browser.

	Provide a predicate to set the number of I/O actions printed by the
	declarative debugger.

	Check that the XML browser command and temp file name being set aren't
	empty, since those are not meaningful.

	Rename predicates to avoid ambiguities and excessively long names.
	Simplify some code.

browser/browse.m:
	Generate better error messages if the user tries to use XML browsing
	without setting it up.

browser/browse.m:
browser/declarative_user.m:
	Conform to the changes in browser_info.m

browser/listing.m:
	Use the correct prefix on global C symbols.

trace/mercury_trace_internal.c:
	Change the save command to save everything of the persistent debugger
	state that can be saved.

	Allow the set command to set the number of I/O actions printed by the
	declarative debugger. Without this, there would be no way to restore
	this part of the debugger persistent state, since a source command
	cannot start the declarative debugger.

	Rename save_to_file as dump.

	Use the correct prefix on global C symbols.

	Avoid misleading capitalization.

trace/mercury_trace_spy.c:
	Extend the code that saves the state of breakpoints to save conditions
	on breakpoints as well.

trace/mercury_trace_browser.[ch]:
	Add a utility function for saving the persistent browser state.

	Conform to the changes in browser/browser_info.m.

trace/mercury_trace_alias.[ch]
	Convert to four-space indentation.

tests/debugger/browser_test.{inp,exp}:
tests/debugger/mdb_command_test.inp:
	Use dump instead of save_to_file.

tests/debugger/save.{m,inp,exp}:
	New test case to test the new behavior of the save command.

tests/debugger/Mmakefile:
	Enable the new test case.
2006-03-31 05:12:19 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
ef55b420fd Remove from std_util.m the predicates that merely call predicates in
Estimated hours taken: 12
Branches: main

Remove from std_util.m the predicates that merely call predicates in
the type_desc, construct and deconstruct modules, to reduce clutter
in std_util.m.

library/std_util.m:
	Remove those predicates from std_util.m.

library/deconstruct.m:
	Add a type we need that was previously defined in std_util.m.

library/construct.m:
	Delete some module qualifications that have now become unnecessary,

browser/browse.m:
browser/browser_info.m:
browser/declarative_tree.m:
browser/dl.m:
browser/help.m:
browser/sized_pretty.m:
browser/term_rep.m:
compiler/bytecode_gen.m:
compiler/llds_out.m:
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
library/assoc_list.m:
library/hash_table.m:
library/io.m:
library/pprint.m:
library/private_builtin.m:
library/prolog.m:
library/require.m:
library/rtti_implementation.m:
library/store.m:
library/term.m:
library/term_to_xml.m:
library/version_hash_table.m:
mdbcomp/program_representation.m:
	Import type_desc.m, construct.m and/or deconstruct.m to provide
	definitions of functions or predicates that up till now were in
	std_util.m. Modify the calls if the called function or predicate
	had a slightly different interface in std_util.m.

	Also, convert term_to_xml.m to four-space indentation, and delete
	unnecessary module qualifications in term.m.

tests/debugger/polymorphic_output.{m,inp,exp,exp2}:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
tests/hard_coded/deconstruct_arg.m:
tests/hard_coded/elim_special_pred.m:
tests/hard_coded/existential_bound_tvar.m:
tests/hard_coded/expand.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/higher_order_type_manip.m:
tests/hard_coded/nullary_ho_func.m:
tests/hard_coded/tuple_test.m:
tests/hard_coded/type_ctor_desc.m:
tests/hard_coded/type_qual.m:
tests/hard_coded/write_xml.m:
tests/hard_coded/sub-modules/class.m:
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested2.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
tests/hard_coded/sub-modules/parent2.child.m:
tests/hard_coded/typeclasses/existential_rtti.m:
tests/recompilation/type_qual_re.m.1:
cvs update: Updating tests/submodules
cvs update: Updating tests/tabling
cvs update: Updating tests/term
cvs update: Updating tests/tools
cvs update: Updating tests/trailing
cvs update: Updating tests/typeclasses
cvs update: Updating tests/valid
tests/valid/agc_unbound_typevars.m:
tests/valid/agc_unbound_typevars2.m:
tests/valid/agc_unused_in.m:
	Replace references to the deleted predicates in std_util with
	references to the equivalent predicates in type_desc, construct
	and/or deconstruct. In test cases that already tested both the
	functionality in std_util and in the other modules, simply delete
	the part exercising std_util.
2006-03-22 02:56:44 +00:00
Zoltan Somogyi
7822554732 Replace __ with . as the module qualifier everywhere in all the modules
Estimated hours taken: 2
Branches: main

browser/*.m:
	Replace __ with . as the module qualifier everywhere in all the modules
	of the browser directory. Convert the currently tab-indented modules
	to four-space indentation. Delete some unnecessary module
	qualifications. Change some type names and function symbols to avoid
	ambiguities. Replace a bunch of uses of DCGs with state variable
	notation.
2006-03-10 06:31:06 +00:00
Ian MacLarty
11042e060c Allow field names to be used in the paths used with subterm dependency
Estimated hours taken: 5
Branches: main

Allow field names to be used in the paths used with subterm dependency
tracking.

Allow the user to cd to the return value of a function by giving the
number of arguments plus one as an argument to the `cd' command.

browser/browse.m:
	Export the predicate that removed ".." from paths.
	Make the return value of this predicate a subtype, so we can be
	sure the simplification has been applied to the path.

	Allow the user to do `cd N', where N is the number of arguments of
	a function plus one.  This will cd to the return value of the function.

	Add some more aliases for the directory name of the return value of a
	function.

browser/browser_info.m:
	Use the new simplified_dirs inst.
	When converting a list of directories to a term path, look at the
	value the path applies to to resolve field names in the path.

browser/declarative_user.m:
	Report an error if the user tries to track an I/O action.
	Call the new version of convert_dirs_to_term_path which handles
	field names in the path.

browser/term_rep.m:
	Add predicates to lookup a subterm in a term representation and
	also to look up a named field in a term representation.

tests/debugger/declarative/Mercury.options:
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/named_fields.exp:
tests/debugger/declarative/named_fields.inp:
tests/debugger/declarative/named_fields.m:
	Test tracking of subterms using a path with a field name.

tests/debugger/polymorphic_output.exp*
	The output of this test has changed, because cd's to the return value
	of a function, using a number, are now allowed.
2006-02-08 21:48:36 +00:00
Ian MacLarty
521967f39f Implement a second version of the subterm dependency tracking algorithm
Estimated hours taken: 20
Branches: main

Implement a second version of the subterm dependency tracking algorithm
that uses the following heuristic to speed things up: If the subterm is being
tracked through an output argument, and there is an input argument with the
same name as the output argumnet, except for a numerical suffix, then the new
algorithm will check if the subterm appears in the same position in the input
argument.  If it does then it will continue tracking the subterm in the input
argument, thus bypassing the subtree rooted at the call.  Since dereferencing a
subterm in a large structure can be expensive, the new algorithm will only try
to bypass calls to procedures it has not tried to bypass before.  The set of
procedures it has tried is reset each time a new explicit subtree or supertree
is generated.

Add a `track' command that behaves in the same way as `mark', except that
it doesn't assert that the node is erroneous or inadmissible.
Add an optional `--accurate' argument which tells the declarative debugger to
use the original tracking algorithm.
We still allow the old algorithm to be used, because there
are situations where the new algorithm could find the wrong call (i.e.
when a subterm appears in the same position in an input argument,
but the subterm in the output argument is actually bound by a descendent call
-- it just happens to be bound to the same value as the input subterm).

doc/user_guide.texi:
	Change the documentation accordingly.

browser/browse.m:
browser/browser_info.m:
browser/parse.m:
browser/declarative_user.m:
	Add a `track' command that does the same thing as a `mark' command,
	except it doesn't assert the atom to be erroneous or inadmissible.
	Allow an `--accurate' or `-a' argument for the `mark' and `track'
	commands which indicates that the old subterm dependency tracking
	algorithm should be used.
	Pass information about tracked subterms to the declarative debugger.
	Do not allow a whole atom to be tracked or marked as this doesn't
	make sense.

browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_edt.m:
browser/declarative_oracle.m:
	Implement the new tracking algorithm.

browser/term_rep.m:
	Add a predicate to dereference a subterm in another term.

mdbcomp/rtti_access.m:
	Add a predicate to find a candidate input argument on which to
	apply the new heuristic.

runtime/Mmakefile:
runtime/mercury_layout_util.h:
runtime/mercury_stack_layout.h:
trace/mercury_trace_vars.c:
trace/mercury_trace_vars.h:
	Move the function for finding the name of a variable to the runtime,
	so that it can be called from the declarative debugger.

tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/nodescend_tracking.exp:
tests/debugger/declarative/nodescend_tracking.inp:
tests/debugger/declarative/nodescend_tracking.m:
	Test the new heuristic.

tests/debugger/declarative/closure_dependency.inp2:
tests/debugger/declarative/closure_dependency.exp2:
	Expect an error message when marking a whole atom.
2005-11-02 14:02:16 +00:00
Zoltan Somogyi
d7554de953 Convert a bunch more modules to four-space indentation.
Estimated hours taken: 5
Branches: main

browser/*.m:
compiler/*.m:
mdbcomp/*.m:
	Convert a bunch more modules to four-space indentation.
2005-10-19 05:39:08 +00:00
Zoltan Somogyi
a77588f6d2 Add two new capabilities to the debugger.
Estimated hours taken: 8
Branches: main

Add two new capabilities to the debugger.

The first capability is the idea of "held variables", variables that the
debugger holds onto even when execution has left the event they came from.
You can hold onto a variable via the mdb command "hold varname heldvarname".
You can suffix the name of the existing variable with a term path, in which
case the new held variable will refer only to the specified part of the term.
Later mdb commands can refer to the held variable by prefixing its name with
a dollar sign. For example, after "hold HeadVar__1^2 x", "$x" will refer to
the term that was the second argument of HeadVar__1 at the program point
at which the "hold" command was executed.

The second capability is the ability to compute the diff of two terms and
express those diffs as the term paths of the function symbols at which the two
terms differ, instead of the line numbers you get by using save_to_file and the
usual Unix diff command. The mdb command is "diff var1 var2". We limit the
number of term paths of difference sites that we display at any one time;
the mdb diff command has options to control this.

NEWS:
	Mention the new capabilities.

doc/user_guide.texi:
	Document the new mdb commands "hold" and "diff", the new mdb command
	"held_vars" which simply lists the names of all the held variables
	(just as "vars" lists the names of all the nonheld variables currently
	accessible), and the concept of held variables.

doc/mdb_categories:
	Update this file for the new mdb commands and concepts.

browser/browse_diff.m:
	This new module implements the diff operation on terms.

browser/mdb.m:
	Add the new module to the list of submodules of the mdb package.

browser/*.m:
	Minor cleanups, such as importing only one module per line; there
	are no algorithmic changes.

trace/mercury_trace_hold_vars.[ch]:
	This new module implements the database of held variables.

trace/Mmakefile:
	Mention the new module.

trace/mercury_trace_internal.c:
	Implement the three new mdb commands.

trace/mercury_trace_vars.[ch]:
	Modify the functions that recognize variable specifications or
	process them to work with held variables as well as variables from
	the current environment. This required some reorganization of the
	internals of this module.

	Provide some a utility function, MR_trace_parse_lookup_var_path,
	for converting a string representing the specification of a term
	(a variable and possibly some path within it) to the type and value
	of that term. Make the utility function this is based upon,
	MR_lookup_unambiguous_var_spec, replace the previous but less capable
	MR_convert_var_spec_to_type_value.

trace/mercury_trace_spy.c:
	Conform to the change in mercury_trace_vars.c.

trace/mercury_trace_util.c:
	Make a utility function more robust.

trace/mercury_trace_alias.c:
	Minor cleanups.

tests/debugger/queens.{inp,exp*}:
	Update this test case to test the debugger's new capabilities.

tests/debugger/completion.{inp,exp*}:
	Update this test case to expect the new mdb commands, and avoid the
	ambiguity between "help" and "held_vars".
2005-07-11 07:30:31 +00:00
Ian MacLarty
b4b2807529 Allow an XML term browser to be called from the declarative debugger.
Estimated hours taken: 6
Branches: main

Allow an XML term browser to be called from the declarative debugger.

browser/browse.m
	Add a predicate to save a term to an XML file and then launch an
	XML browser.

	Add a predicate that saves a term to an XML file and doesn't print
	any error messages, but just returns an io.res result.  Use this
	in save_term_to_file_xml and the predicate mentioned above.

browser/browser_info.m
	Add two fields to the browser's persistent state - one to record the
	temporary filename to use when saving a term to an XML file and one
	to hold the command to launch the XML browser.  Previously these were
	stored in C global variables which were not accessible from the
	declarative debugger.

	Export the browser_persistent_state type so the field access functions
	can be used from browse.m.

browser/declarative_user.m
	Allow the user to give an -x or --xml option to the browse command from
	within the declarative debugger.

	Reformat the user_command type and add a new functor: browse_xml_arg/1.

	Describe the -x or --xml browse option in the help message and reformat
	the trust command help message as it was looking a bit untidy.

tests/debugger/browser_test.exp
tests/debugger/browser_test.inp
	Test the --xml option from within the declarative debugger.

trace/mercury_trace_browse.c
trace/mercury_trace_browse.h
trace/mercury_trace_internal.c
	Move MR_trace_save_and_invoke_xml_browser from mercury_trace_internal.c
	to mercury_trace_browse.c so it can call the new Mercury code in
	browser/browse.m.

	Handle the `set xml_browser_cmd' and `set xml_tmp_filename' commands by
	calling Mercury code to set the appropriate fields in the persistent
	browser state.
2005-02-22 22:27:50 +00:00
Zoltan Somogyi
67895b0b65 Fix the current mixture of __ and . to module qualify module names
Estimated hours taken: 0.2
Branches: main

browser/*.m:
	Fix the current mixture of __ and . to module qualify module names
	by standardizing on the latter.
2005-01-24 07:41:05 +00:00
Ian MacLarty
ba2c9002e4 Add `mode' command to interactive term browser to display the mode of a
Estimated hours taken: 5
Branches: main

Add `mode' command to interactive term browser to display the mode of a
sub-term.  At the moment this command only works when the term browser is
invoked from inside the declarative debugger.

browser/browser_info.m
	Allow a function to be passed to the browser which it can call to
	work out the mode of a sub-term.

browser/browse.m
	Export versions of the browser invocation predicates that don't
	accept a mode function.

	Handle the `mode' browser command by calling the supplied function
	if it's present.

	Document the `mode' command in the browser help message.

browser/declarative_debugger.m
	To determine the mode of a sub-term we compare the state of
	instantiation of the sub-term at the CALL event and at the EXIT, FAIL
	or EXCP event.  To do this we need the initial and final
	atoms for incorrect contour bugs and wrong answer nodes (for
	other nodes the initial and final atoms are the same).

browser/declarative_oracle.m
	Conform to the fact that wrong answers now also have the
	initial atom.

browser/declarative_tree.m
	Export trace_atom_subterm_is_ground/3 for use in declarative_user.m.

	Include the initial atom in wrong answer nodes and incorrect contour
	bugs.

browser/declarative_user.m
	Add function arg_num_to_arg_pos to replace some duplicated code.

	Alter the edt_node_trace_atom predicate to find the initial and the
	final atoms for a question.

	Add a function to find the mode of a sub-term given the path to the
	sub-term and the initial and final atoms.  Pass this function to
	the browser so it can work out the mode of a sub-term.

browser/parse.m
	Parse `mode' command.

tests/debugger/declarative/Mmakefile
tests/debugger/declarative/browser_mode.exp
tests/debugger/declarative/browser_mode.inp
tests/debugger/declarative/browser_mode.m
	Test the `mode' command.
2005-01-18 03:56:53 +00:00
Ian MacLarty
c5c53432fb Allow terms to be saved as XML in mdb and allow an XML browser to be invoked on
Estimated hours taken: 5
Branches: main

Allow terms to be saved as XML in mdb and allow an XML browser to be invoked on
browsable objects in mdb.  The user can set two options which control where the
XML is dumped and the command used to browse the XML.  The defaults assume
xsltproc and mozilla are installed.

configure.in
	Check for mozilla/firefox and xsltproc so default the mdb XML browser
	command can be set if they are found.

browser/browse.m
	Add a predicate to save a browser term as XML to a file.

doc/user_guide.texi
	Document new --xml option for the mdb `browse' command.
	Document new --xml option for the mdb `save_to_file' command.
	Document the `set xml_tmp_filename' and `set xml_browser_cmd' commands.

scripts/Mmakefile
	Copy extras/xml_stylesheets/xul_tree.xsl to the mdb install
	directory so it can be used by the default XML browser command.

scripts/mdbrc.in
	Set default values for xml_browser_cmd and xml_tmp_filename.

scripts/xul_tree.xsl
	Copy this stylesheet here so there isn't a dependency on the extras
	directory.

tests/debugger/browser_test.inp
tests/debugger/browser_test.exp
	Test --xml option for `browse' command.

trace/mercury_trace_browse.c
trace/mercury_trace_browse.h
	Add functions to save a term as XML to a file and then
	invoke the user's XML browser.

trace/mercury_trace_internal.c
	Add --xml option to `browse' and `save_to_file' mdb commands and
	handle this option.
2004-12-11 01:59:52 +00:00
Ian MacLarty
d80b69485c Rename "pretty" browser format to "raw_pretty" and "raw_pretty" to "pretty".
Estimated hours taken: 1.5
Branches: main

Rename "pretty" browser format to "raw_pretty" and "raw_pretty" to "pretty".
Make old "pretty" format print function return values.  Remove univ_cons
constructor around old "raw_pretty" function return values.

Add extra note in NEWS about declarative debugger `trust' command.

browser/browse.m
	Rename "raw_pretty" to "pretty" and vica versa.  Use univ value when
	creating doc for return value.

browser/sized_pretty.m
	If a synthetic term has a return value then include it in the doc.

NEWS
	Add note about print format name change.
	Also add note about declarative debugger `trust' command.

tests/debugger/browse_pretty.exp
tests/debugger/browse_pretty.inp
tests/debugger/declarative/browse_arg.exp
tests/debugger/declarative/browse_arg.inp
tests/debugger/declarative/dependency.exp
tests/debugger/declarative/dependency.inp
	Change input and expected output where pretty or raw_pretty formats
	used.

tests/debugger/browser_test.m
tests/debugger/browser_test.exp
tests/debugger/browser_test.inp
	Test printing of function applications.
2004-11-05 06:30:21 +00:00
Ian MacLarty
1974e66710 Make `set' mdb command work from within the declarative debugger.
Estimated hours taken: 2
Branches: main

Make `set' mdb command work from within the declarative debugger.

browser/browse.m
	Make set_browse_param call a new predicate set_param/5 in
	browser_info.m.

browser/browser_info.m
	Add set_param/5 to set browser parameters from an option table.

browser/declarative_user.m
	Add and handle `set' command.
	Add help text.

browser/parse.m
	Make parse/2 public so it can be called from the declarative debugger.

tests/debugger/declarative/browse_arg.exp
tests/debugger/declarative/browse_arg.inp
	Add test case.
2004-10-27 02:23:27 +00:00
Ian MacLarty
667d2ba70f Added a `cdr' command to the interactive term browser.
Estimated hours taken: 1
Branches: main

Added a `cdr' command to the interactive term browser.  This repeatedly cds
into a path and is useful for accessing deep structures (like long lists).

browser/browse.m
	Rewrote simplify_dirs predicate which removes redundant `..'
	directories.  The previous method was too inefficient and caused
	commands like `cdr 10000 ..' to take a long time.
	Added help text.

browser/parse.m
	Added handler for `cdr' command which is just translated into a `cd'
	command with the path repeated the appropriate number of times.

tests/debugger/browser_test.inp
tests/debugger/browser_test.exp
	Added test for cdr command.
2004-10-25 05:32:23 +00:00
Zoltan Somogyi
d48544ed7f Factor out common code in the handling of plain terms and synthetic terms.
Estimated hours taken: 2
Branches: main

Factor out common code in the handling of plain terms and synthetic terms.
We already had a mechanism (the browser_term type and operations on it) for
handling them in a unified manner, we just didn't use them everywhere we could.

browser/browser_term.m:
	Add this new module to hold the browser_term type and the operations
	on it, which previously were in two different modules (browser_info
	and browse respectively).

	Make the operations function, since that is their natural form.

browser/mdb.m:
	Add the new module.

browser/browser_into.m:
	Delete the type moved to browser_term.m.

browser/browse.m:
	Delete the operations moved to browser_term.m.

	Replace operation pairs on plain terms and synthetic terms with
	generalized operations on browser terms.

browser/declarative_user.m:
browser/io_action.m:
browser/sized_pretty.m:
trace/mercury_trace_browser.c:
	Conform to the changes listed above.
2004-08-09 03:05:23 +00:00
Zoltan Somogyi
ea2c2ebeee Add an mdb command to save a term from the program being debugged to a file.
Estimated hours taken: 3
Branches: main

Add an mdb command to save a term from the program being debugged to a file.

browser/browse.m:
	Provide mechanisms to create browser terms from their components,
	and to save browser terms to a named file.

trace/mercury_trace_browse.[ch]:
	Provide access to these predicates from C code.

trace/mercury_trace_internal.c:
	Implement a new mdb command, save_to_file, which saves a goal,
	exception, procedure body or specified variable to a file.

doc/user_guide.texi:
doc/mdb_categories:
	Document the new mdb command.

trace/mercury_trace_vars.[ch]:
	Factor out the code for constructing the (components of) browser terms
	from goals and variables from the code for browsing the resulting
	terms, to allow them to be used also for saving those terms to a file.

tests/debugger/mdb_command_test.inp:
	Test the documentation of the new command.

tests/debugger/completion.exp:
	Update this test case both for the new command and for the previous one
	I added (var_name_stats).

tests/debugger/browser_test.{m,inp,exp}:
	Extend this test case to also test the behavior of the new command.
2004-05-13 08:50:34 +00:00
Zoltan Somogyi
0942716fe7 Fix a bug that caused a runtime abort if you called the library
Estimated hours taken: 3
Branches: main

runtime/mercury_ml_expand_body.h:
	Fix a bug that caused a runtime abort if you called the library
	function named_argument (which is implemented in this file) on
	a value of a type which has no field name information at all.

browser/browse.m:
	Generate better error messages when an attempt to change to a subterm
	fails: say which step failed, and which ones succeeded.

tests/debugger/field_names.{m,inp,exp}:
	Strengthen the test case to cover types with no field names at all:
	a regression test to check for the bug in mercury_ml_expand_body.h.

	Strengthen the test case using several unsuccessful commands, to test
	the improved error messsages.

tests/debugger/polymorphic_output.exp*:
	Update the expected outputs of this test case to account for the new
	error messages.
2004-04-05 07:18:58 +00:00
Zoltan Somogyi
ff60134ee9 Bring these modules up to our current coding standards.
Estimated hours taken: 8
Branches: main

analysis/analysis.m:
browser/browse.m:
compiler/accumulator.m:
compiler/assertion.m:
compiler/atsort.m:
compiler/c_util.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_model.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/dead_proc_elim.m:
compiler/delay_construct.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/follow_code.m:
compiler/graph_colour.m:
compiler/hlds_module.m:
compiler/inlining.m:
compiler/llds.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/ml_tailcall.m:
compiler/ml_unify_gen.m:
compiler/mmc_analysis.m:
compiler/mode_errors.m:
compiler/passes_aux.m:
compiler/post_typecheck.m:
compiler/size_prof.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_errors.m:
compiler/transform_llds.m:
compiler/type_util.m:
compiler/unify_gen.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
	Bring these modules up to our current coding standards. Use predmode
	declarations and state variable syntax where relevant. Reorder
	arguments where this is needed for the use state variables. Make the
	orders of predicate definitions correspond to the order of their
	declarations. Replace some overly large lambda expressions with named
	predicates. Convert some predicates to functions where this makes
	their use more convenient. Use field access notation where convenient.
	Fix any inconsistent indentation. Remove module prefixes on predicate
	names where this is necessary to allow sane indentation.

	In several places, use predicates from error_util.m to print error
	messages. Apart from this, there are no changes in algorithms.

	In some places, conform to the changes below.

compiler/error_util.m:
compiler/hlds_error_util.m:
	Add new variants of existing predicates for use in some of the
	changed modules above.

compiler/hlds_out.m:
	Add some functions to convert values of some HLDS types as strings,
	for use in preparing the arguments of the new calls to predicates in
	error_util.m. Change the implementations of the predicates that print
	values of those types to call those functions instead of allowing
	code duplication.

compiler/llds.m:
	Add some field names to allow use of field updates where relevant.

tests/invalid/assert_in_interface.err_exp:
tests/invalid/multisoln_func.err_exp:
tests/invalid/tricky_assert1.err_exp:
	Update the expected outputs of these test cases to allow for them being
	generated by error_util.m, and hence being better formatted than
	before.
2004-04-05 05:07:49 +00:00
Zoltan Somogyi
9045968ade Conform to the convention of importing only one browser module
Estimated hours taken: 0.2
Branches: main

browser/browse.m:
browser/declarative_test.m:
browser/set_cc.m:
	Conform to the convention of importing only one browser module
	per line.
2003-10-27 06:19:09 +00:00
Zoltan Somogyi
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.
2003-10-13 08:02:18 +00:00
Zoltan Somogyi
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.
2003-09-14 22:24:41 +00:00
Zoltan Somogyi
6554ef7daa Replace "is" with "=".
Estimated hours taken: 2
Branches: main

Replace "is" with "=".
Add field names where relevant.
Replace integers with counters where relevant.
2003-05-26 09:01:46 +00:00
Fergus Henderson
1ba1647088 Deprecate io__current_(binary_)?(input|output)_stream,
Estimated hours taken: 1
Branches: main

library/io.m:
	Deprecate io__current_(binary_)?(input|output)_stream,
	because these procedures were identical with the
	procedures named io__(binary_)?(input|output)_stream.

browser/browse.m:
	Use io__output_stream instead of io__current_output_stream.

deep_profiler/mdprof_cgi.m:
	Use io__binary_(in|out)put_stream instead of
	io__current_binary_(in|out)put_stream.

NEWS:
	Mention the changes to library/io.m.
2003-02-24 05:49:31 +00:00
Peter Ross
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.
2002-12-03 10:21:17 +00:00
Peter Ross
138f778aca Update to use the new type signature and determinism of
Estimated hours taken: 0.5
Branches: main

browser/browse.m:
	Update to use the new type signature and determinism of
	limited_deconstruct_cc.
2002-12-02 16:27:50 +00:00
Zoltan Somogyi
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.
2002-11-01 07:45:04 +00:00
Mark Brown
ff53936dbc Print list terms using list syntax when printing in "flat" format.
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.
2002-10-31 08:21:20 +00:00
Mark Brown
2faeb0cf70 Address an XXX question by answering it in the affirmative.
Estimated hours taken: 0.1
Branches: main

browser/browse.m:
	Address an XXX question by answering it in the affirmative.
2002-10-22 16:06:35 +00:00
Mark Brown
2fe0dfa705 Change the declarative debugger so it always prints syntactically
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.
2002-10-16 03:15:33 +00:00
Zoltan Somogyi
4951ae07e0 Add a new browser "command", empty, to represent command lines without
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.
2002-07-03 08:25:03 +00:00
Zoltan Somogyi
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.
2002-04-16 13:54:32 +00:00
Zoltan Somogyi
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.
2002-02-24 11:53:46 +00:00
Zoltan Somogyi
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.
2002-01-28 07:20:10 +00:00
Zoltan Somogyi
6b88144d9a Fix a comment.
Estimated hours taken: 0.1
Branches: main

browser/browse.m:
	Fix a comment.
2002-01-17 11:28:54 +00:00
Zoltan Somogyi
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.
2002-01-12 09:08:15 +00:00
Zoltan Somogyi
91effad5e7 Fix indentation.
Estimated hours taken: 0.1
Branches: main

browser/browse.m:
	Fix indentation.
2001-12-19 06:50:18 +00:00
Zoltan Somogyi
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.
2001-12-19 06:44:51 +00:00
Zoltan Somogyi
60405b3a24 Make the prettyprinters in this file use limited_deconstruct to avoid
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.
2001-06-22 08:28:55 +00:00
Zoltan Somogyi
7c526ed15e Allow the RTTI routines and the debugger to treat arrays as other types.
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.
2001-06-22 03:14:33 +00:00
Mark Brown
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.
2001-04-23 16:26:38 +00:00
Sarvamanan Thurairatnam
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.
2001-02-23 04:15:24 +00:00
Thomas Conway
de80683489 This change makes univ a user-defined type (in std_util.m) rather than
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.
2001-01-09 23:30:26 +00:00
Mark Brown
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.
2000-10-27 08:38:58 +00:00
Mark Brown
7092b0f4a8 Use the term browser to print arguments in the declarative debugger.
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.
2000-08-17 08:07:06 +00:00
Mark Brown
f6c9d93c5b Portray terms using the standard pretty printer.
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.
2000-05-22 06:46:13 +00:00
Mark Brown
ff589ad0f6 Fix a bug in the term browser: the term size limit was by default
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.
2000-05-11 07:44:34 +00:00
Zoltan Somogyi
c2a696d8b6 Clean up the runtime system's handling of type_infos and pseudo_type_infos.
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.
2000-03-24 10:28:07 +00:00
Simon Taylor
9ba3b14098 Make all the modules in the browser library sub-modules of
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.
2000-02-04 03:45:53 +00:00