Commit Graph

58 Commits

Author SHA1 Message Date
Peter Wang
89e59e7cc8 Delete support for browsing terms as XML.
The 'browse --xml' command has not worked with current versions of
xsltproc for quite some time, but we have not received any bug reports,
nor has anyone tried to fix it. We have a method for interactively
exploring a term in 'browse --web' so IMHO there is no need to keep
support for 'browse --xml'.

browser/browse.m:
browser/browser_info.m:
browser/declarative_user.m:
trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
    Delete code.

doc/mdb_categories:
doc/user_guide.texi:
    Delete documentation.

configure.ac:
    Don't search for a XUL browser and xsltproc.

scripts/mdbrc.in:
    Delete 'xml_browser_cmd' and 'xml_tmp_filename' lines.

scripts/xul_tree.xsl:
    Delete now unused file.

scripts/Mmakefile:
    Conform to deletions.

tests/debugger/Mmakefile:
tests/debugger/browser_test.exp:
tests/debugger/browser_test.exp3:
tests/debugger/browser_test.inp:
tests/debugger/mdb_command_test.inp:
tests/debugger/save.exp2:
tests/declarative_debugger/browse_arg.exp:
tests/declarative_debugger/browse_arg.inp:
    Don't test 'browse --xml' any longer.

extras/xml_stylesheets/README:
    Delete reference to 'browse --xml' command.

NEWS:
    Announce change.
2020-10-14 17:41:54 +11:00
Peter Wang
a22e973025 Let mdb run an external command for 'list'.
browser/listing.m
    Add list_file_with_command which calls an external command to print
    source listings instead of doing it internally. The implementation
    is incomplete in that the external command's standard output and
    standard error streams are not redirected into OutStrm and ErrStrm.

    Rename mercury_stream_to_c_FILE_star to
    mercury_stream_to_c_file_ptr.

    Consolidate some output calls with string.format.

trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
    Add a 'list_cmd' command which sets or prints the current
    external listing command.

trace/mercury_trace_cmd_browsing.c:
    Make 'list' command call list_file_with_command if an external
    listing command was set.

doc/user_guide.texi:
    Document 'list_cmd' command.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
    Update for new command.

NEWS:
    Announce changes.
2020-10-02 19:01:45 +10:00
Peter Wang
0d273769fc Add web browser-based term browsing in the debugger.
browser/browse.m:
    Add save_and_browse_browser_term_web to be called when
    "browse --web" is entered at the mdb prompt.

    Add browser_term_to_html_flat_string, a helper predicate for
    term_to_html.

    Make portray_flat_write_browser_term work take a stream parameter
    instead of writing to the current output stream. It is called by
    browser_term_to_html_flat_string, writing to a string builder
    stream.

browser/browser_info.m:
    Add web_browser_cmd field to browser_persistent_state.

browser/mdb.m:
browser/term_to_html.m:
    Add new module to generate an HTML document. The document contains a
    JavaScript represention of a Mercury term.

    (The JavaScript string escaping code is adapted from Julien's
    mercury-json project.)

browser/percent_encoding.m:
    Add new module to perform percent-encoding.

scripts/mdb_term_browser.css:
scripts/mdb_term_browser.js:
    Add JavaScript and CSS files referenced by the generated HTML file
    to create a tree view of a Mercury term using jstree.

scripts/32px.png:
scripts/40px.png:
scripts/throbber.gif:
scripts/jstree.min.js:
scripts/jstree.style.min.css:
    Add local copy of jstree files <https://www.jstree.com/>

scripts/jquery.slim.min.js:
    Add local copy of jquery <https://jquery.com/>

scripts/Mmakefile:
    Install the new files into the same directory as mdbrc and other
    mdb-related files.

trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
    Add "browse --web" and "web_browser_cmd" commands.

doc/user_guide.texi:
    Document "browse --web" and "web_browser_cmd" commands.

configure.ac:
scripts/mdbrc.in:
    Set a reasonable default command to launch a web browser from mdb.
    (Only tested on Linux.)

NEWS:
    Announce the new feature.

.README.in:
    Mention jquery and jstree licensing.

tests/debugger/Mmakefile:
tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
tests/debugger/save.exp2:
    Update debugger tests for new commands.
2017-08-15 16:14:55 +10:00
Julien Fischer
6f76b20bd4 Add a new developer-only mdb command, trail_details, that prints out
Estimated hours taken: 2
Branches: main

Add a new developer-only mdb command, trail_details, that prints out
low-level information concerning the state of the trail.  This includes
things like the current values of the trail pointer and ticket counter.

trace/mercury_trace_internal.c:
trace/mercury_trace_cmd_developer.c:
	Add the new command.

trace/mercury_trace_cmd_developer.h:
	Add the new command and delete a prototype for a function not defined
	by this module.

runtime/mercury_trail.h:
runtime/mercury_trail.c:
	Add a new function that returns the number of entries on the trail
	(for the currently executing thread).

doc/user_guide.texi:
	Document the new command.

	s/lowlevel/low-level/ in some spots (the latter is consistent with the
	hyphenation used elsewhere in this documentation.)

	Break some over-long lines.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
	Update this for the "trail_details" mdb command.
2008-06-10 04:05:01 +00:00
Ian MacLarty
5e7d665e9f Add a --reset-knowledge-base option to the mdb `dd' command. The new option
resets the declarative debugger's knowledge base of previous question answers.

NEWS:
	Mention the new option.

	Move an item that was in the wrong place.

browser/declarative_debugger.m:
browser/declarative_oracle.m:
	Export a procedure to reset the oracle's knowledge base.

doc/user_guide.texi:
	Document the new option.

tests/debugger/declarative/oracle_db.exp:
tests/debugger/declarative/oracle_db.inp:
	Test the new option.

trace/mercury_trace_cmd_dd.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
	Add the new option.
2007-06-07 06:53:54 +00:00
Zoltan Somogyi
45fd0daf5a Implement some of Mark's wish list for making user events more useful.
Estimated hours taken: 20
Branches: main

Implement some of Mark's wish list for making user events more useful.

1. When executing "print *" in mdb, we used to print both the values of all
   attributes and the values of all live variables. Since some attributes'
   values were given directly by live variables, this lead to some things being
   printed twice. This diff eliminates this duplication.

2. At user events, we now print the name of the event. Whether we print the
   other stuff we also print at events (the predicate containing the event,
   and its source location) is now controlled by a new mdb command,
   "user_event_context".

3. We would like different solvers to be compilable independently of one
   another. This means that neither solver's event set should depend on the
   existence of the events needed by the other solvers. This diff therefore
   eliminates the requirement that all modules of the program be compiled with
   the same event set specification. Instead, a program may contain modules
   that were compiled with different event sets. Each event set is named;
   the new requirement is that different named event sets may coexist in the
   program (each being used to compile some modules), but two event sets with
   the same name must be identical in all other respects as well (we need this
   requirement to prevent inconsistencies arising between different versions of
   the same event set).

4. We now generate user events even from modules compiled with --trace shallow.
   The problem here is that user events can occur in procedures that do not
   get caller events and whose ancestors may not get caller events either.
   Yet these procedures must still pass on debugger information such as call
   sequence numbers and the call depth to the predicate with the user event.
   This diff therefore decouples the generation of code for this basic debugger
   infrastructure information from the generation of call events by inventing
   two new trace levels, settable by the compiler only (i.e. not from the
   command line). The trace level "basic_user" is for procedures containing a
   user event whose trace level (in a shallow traced module) would otherwise be
   "none". The trace level "basic" is for procedures not containing a user
   event but which nevertheless may need to transmit information (e.g. depth)
   to a user event. For the foreseeable future, this means that shallow traced
   modules containing user events will have some debugging overhead compiled
   into *all* their procedures.

runtime/mercury_stack_layout.h:
	Add a new field to MR_UserEvent structures, giving the HLDS number of
	the variable representing each attribute.

	Add a new field to module layout structures, giving the name of the
	event set (if any) the module was compiled with.

	Add the new trace levels to the MR_TraceLevel type.

	Update the current layout structure version number.

runtime/mercury_stack_trace.[ch]:
	Allow the printing of the containing predicate's name and/or the
	filename/linenumber context to be turned off when printing contexts.
	Factor out some of the code involved in this printing.

	Give a bunch of variables better names.

	Rename a type to get rid of unnecessary underscores.

compiler/prog_data.m:
compiler/prog_event.m:
	Include the event set name in the information we have about the event
	set.

compiler/simplify.m:
	Mark each procedure and each module that contains user events
	as containing user events.

	Use the same technique to mark each procedure that contains parallel
	conjunctions as containing parallel conjunctions, instead of marking
	the predicate containing the procedure. (Switch detection may eliminate
	arbitrary goals, including parallel conjunctions, from switch arms
	that are unreachable due to initial insts, and in any case we want to
	handle the procedures of a predicate independently from each other
	after mode analysis.)

	Also, change the code handling generic calls to switch on the generic
	call kind, and factor out some common code.

compiler/hlds_module.m:
compiler/hlds_pred.m:
	Provide slots in the proc_info and the module_info for the information
	gathered by simplify.

compiler/trace_params.m:
	Implement the new trace levels described above. This required changing
	the signature of some of the predicates of this module.

compiler/code_info.m:
	Record whether the compiler generated any trace events. We need to know
	this, because if it did, then we must generate a proc layout structure
	for it.

compiler/proc_gen.m:
	Act on the information recorded by code_info.m.

	Factor out the code for generating the call event and its layout
	structure, since the conditions for generating this event have changed.

compiler/continuation_info.m:
compiler/call_gen.m:
	For each user event, record the id of the variables corresponding to
	each argument of a user event.

compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
	Generate the new field (giving the HLDS variable number of each
	attribute) in user event structures, and the new field (event set name)
	in module layout structures.

	Allow the call event's layout structure to be missing. This is needed
	for user events in shallow traced modules.

compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compiler.m:
	Rename the option for specifying event sets from --event-spec-file-name
	to --event-set-file-name, since it specifies only one event set, not
	all events.

compiler/jumpopt.m:
	Give some predicates better names.

compiler/dep_par_conj.m:
compiler/deforest.m:
compiler/granularity.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/liveness.m:
compiler/modes.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/size_proc.m:
compiler/stack_alloc.m:
compiler/store_alloc.m:
compiler/table_gen.m:
compiler/trace_gen.m:
compiler/typecheck.m:
	Conform to the changes above.

doc/mdb_categories:
	Mention the new mdb command.

doc/user_guide.texi:
	Update the documentation of user events to account for the changes
	above.

trace/mercury_event_parser.y:
trace/mercury_event_scanner.l:
	Modify the grammar for event set specifications to a name for the
	event set.

trace/mercury_event_spec.[ch]:
	Instead of recording information about event sets internally
	in this module, return a representation of each event set read in
	to the callers, for them to do with as they please.

	Include the event set name when we print the Mercury term for
	compiler/prog_event.m.

trace/mercury_trace.c:
	Do not assume that every procedure that contains an event contains a
	call event (and hence a call event layout structure), since that
	is not true anymore.

trace/mercury_trace_cmd_parameter.[ch]:
	Implement the new mdb command "user_event_context".

trace/mercury_trace_cmd_internal.[ch]:
	Include "user_event_context" in the list of mdb commands.

	Print the user event name at user events. Let the current setting
	of the user_event_context mdb command determine what else to print
	at such events.

	Instead of reading in one event set on initialization, read in
	all event sets that occur in the program.

trace/mercury_trace_tables.[ch]:
	Allow the gathering of information for more than one event set
	from the modules of the program.

trace/mercury_trace_vars.[ch]:
	For each attribute value of a user event, record what the HLDS variable
	number of the attribute is. When printing all variables at an event,
	mark the variable numbers of printed attributes as being printed
	already, causing the variable with the same number not to be printed.

	Include the name of the variable (if it has one) in the description
	of an attribute. Without this, users may wonder why the value of the
	variable wasn't printed.

trace/mercury_trace_cmd_browsing.[ch]:
	Pass the current setting of the user_event_context mdb command to
	runtime/mercury_stack_trace.c when printing the context of an event.

tests/debugger/user_event_shallow.{m,inp,exp}:
	New test case to test the new functionality. This test case is the same
	as the user_event test case, but it is compiled with shallow tracing,
	and its mdb input exercises the user_event_context mdb command.

tests/debugger/user_event_spec:
tests/invalid/invalid_event_spec:
	Update these event set spec files by adding an event set name.

tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
	Enable the new test case.

tests/debugger/user_event.exp:
	Update the expected output of the old user event test case, which now
	prints event names, but doesn't print attribute values twice.

tests/debugger/completion.exp:
	Expect the new "user_event_context" mdb command in the command list.

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

tests/invalid/Mercury.options:
	Conform to the name change of the --event-spec-file-name option.
2006-12-05 03:51:22 +00:00
Zoltan Somogyi
9ec86d6a6d The objective of this diff is to switch from a table of solver events built
Estimated hours taken: 32
Branches: main

The objective of this diff is to switch from a table of solver events built
into the compiler (and eventually the debugger) into a table of events
defined by a file provided by the user to the compiler, which the compiler
then records in the executable for use by the debugger.

The current design, for speed of implementation, uses temporary files parsed
by a bison-generated parser. Since the compiler needs to be able to invoke
the parser even if it is compiled in a non-debug grade, the parser is in
a new library, the eventspec library, that is always linked into the Mercury
compiler and is always linked into any Mercury program with debugging enabled
(but is of course linked only once into a Mercury compiler which has debugging
enabled).

Modify the debugger to give it the ability to print the attributes of
user-defined events (for now, only the non-synthesized attributes).
Implement a new debugger command, "user", which goes to the next user-defined
event.

configure.in:
	Require flex and and bison to be available.

doc/user_guide.texi:
	Document user defined events and the new debugger capabilities.

doc/mdb_categories:
	Include "user" in the list of forward movement commands.

	Fix some earlier omissions in that list.

runtime/mercury_stack_layout.h:
	Include an event number in the user-defined event structure.

	Include a string representing an event set specification in module
	layout structures.

runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.[ch]:
runtime/mercury_types.h
	Switch from solver events to user events in names.

runtime/mercury_trace_term.[ch]:
	Provide a representation of flat terms, for use in representing
	the calls that generate synthesized attributes.

	Ensure that exported field names have an MR_ prefix.

browser/cterm.m:
	Conform to the change to runtime/mercury_trace_term.h.

scripts/c2init.in:
scripts/ml.in:
	Include the eventspec library in programs compiled with debugging
	enabled.

compiler/Mmakefile:
	Include the eventspec library in the compiler.

compiler/options.m:
	Add a new option, --event-spec-file-name, that allows the user to
	specify the set of user-defined events the program may use.

compiler/handle_options.m:
	Set this optimization from an environment variable (which may be
	set by the mmc script) if the new option is not explicitly given.

compiler/prog_data.m:
	Define the data structures for the compiler's representation of the
	event set specification.

	Move some definitions around to group them more logically.

compiler/hlds_module.m:
	Include the event set specification as a new field in the module_info.

compiler/prog_event.m:
	Add the code for invoking the parser in the eventspec library,
	and for converting the simple term output by the parser to the
	compiler own representation, which contains more information
	(to wit, the types of the function attributes) and which has had
	a whole bunch of semantic checks done on it (e.g. whether synthesized
	attributes depend on themselves or on nonexistent attributes).

	Provide a function to generate a canonicalized version of the event
	specification file.

compiler/module_qual.m:
compiler/equiv_type.m:
	Process event spec specifications as well as items, to module qualify
	the names of the types of event arguments, and expanding out
	equivalence types.

	In equiv_type.m, rename some variables to make clear what kind of info
	they represent.

compiler/mercury_compile.m:
	Process the event set specification file if one has been selected:
	read it in, module qualify it, expand its equivalence types, and add
	to the module_info.

compiler/compile_target_code.m:
	Include the event_spec library when linking debuggable executables.

compiler/call_gen.m:
compiler/continuation_info.m:
compiler/trace_gen.m:
compiler/trace_params.m:
mdbcomp/prim_data.m:
mdbcomp/trace_counts.m:
runtime/mercury_goto.h:
	Generate user-defined events instead of solver events.

compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
	Include a canonicalized version of the event specification file
	in the module layout if the module has any user-defined events.

compiler/code_info.m:
compiler/llds_out.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/typecheck.m:
	Conform to the changes above.

compiler/passes_aux.m:
	Rename a predicate to avoid an ambiguity.

trace/Mmakefile:
	Add the definition and rules required to build the eventspec library.

trace/mercury_event_scanner.l:
trace/mercury_event_parser.y:
	A scanner and a parser for reading in event spec specifications.

trace/mercury_event_spec_missing.h:
	Provide the declarations that should be (but aren't) provided by
	flex and bison.

trace/mercury_event_spec.[ch]:
	The main module of the eventspec library. Provides functions to read
	in event set specifications from a file, and to write them out as a
	Mercury term in the form needed by the compiler.

trace/mercury_trace_tables.c:
	If the module layouts being registered include event set
	specifications, then check their consistency. Make the specification
	and the consistency indication available to other modules.

trace/mercury_trace_internal.c:
	During initialization, if the modules contain a consistent set of event
	set specifications, then read that specification into the debugger.
	(We don't yet make use of this information.)

	Add an extra mdb command, "user", which goes forward to the next
	user-defined event.

trace/mercury_trace.[ch]:
trace/mercury_trace_cmd_forward.[ch]:
	Implement the new mdb command.

trace/mercury_trace_vars.[ch]:
	For user-defined events, include the attributes' values among the
	values that can be printed or browsed.

trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_declarative.c:
	Minor changes.

scripts/scripts/prepare_tmp_dir_grade_part:
	Copy the .y and .l files to the tmp dir we use for installs.

tools/bootcheck:
	Copy the .y and .l files of the trace directory to stage 2.

tools/lmc.in:
	Include the eventspec library when linking debuggable executables.

tests/debugger/user_event.{m,inp,exp}:
tests/debugger/user_event_spec:
	New test case to test the new functionality.

tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
	Enable the new test case.

tests/debugger/completion.exp:
	Expect the new "user" mdb command in the completion output.
2006-11-24 03:48:30 +00:00
Ian MacLarty
2ece43e394 Add a new mdb command, 'shell', that allows users to execute shell commands
Estimated hours taken: 5
Branches: main

Add a new mdb command, 'shell', that allows users to execute shell commands
from within the debugger.

Allow the user to give up to nine additional arguments to the 'source' command.
Occurrences of the strings "$1" through "$9" in the sourced file are replaced
by the corresponding additional arguments, allowing for parameterised scripts.

Use the two new features mentioned above to add two more mdb commands: one
to open a term, goal or exception in an external editor another command
to perform a grep on a term, goal or exception (useful for seeing if a value
occurs in a big map, for example).

NEWS
	Mention the new commands.

doc/mdb_categories:
doc/user_guide.texi:
	Document the new commands.

scripts/Mmakefile:
scripts/mdb_open:
scripts/mdb_vim:
	Add scripts for the new commands.

scripts/mdbrc.in:
	Add aliases for the new shell, emacs, grep and vim commands.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
	Adjust for new commands.

tests/debugger/save.exp:
tests/debugger/save.exp2:
	Adjust for new commands.  Replace system dependent strings
	with ZZZ instead of XXX.

tests/debugger/Mmakefile:
tests/debugger/shell.exp:
tests/debugger/shell.inp:
tests/debugger/shell.m:
tests/debugger/shell_test_script:
	Test the shell and source commands.

trace/mercury_trace_cmd_misc.c:
	Check if there are extra arguments to the source mdb command
	and pass them to MR_trace_source if there are.

trace/mercury_trace_cmd_misc.h:
	Add shell command handling function prototype.

trace/mercury_trace_declarative.c:
	Call MR_trace_call_system_display_error_on_failure instead
	of system when displaying benchmarking statistics for the
	declarative debugger.

trace/mercury_trace_internal.c:
trace/mercury_trace_internal.h:
	Implement the shell command and extend the source command
	to handle the optional extra arguments.

trace/mercury_trace_readline.c:
trace/mercury_trace_readline.h:
	Add a new function to read a line and replace all the
	occurrences of "$[1-9]" with the corresponding value from an array.

	Delete comments in the .c file that are duplicated in the .h file.

trace/mercury_trace_util.c:
trace/mercury_trace_util.h:
	Implement MR_trace_call_system_display_error_on_failure that
	executes a system call and displays an error message if the system
	call terminates abnormally.
2006-06-13 09:49:04 +00:00
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
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
17eb414a8f Add a new mdb command "ambiguity" that prints out ambiguous predicate, function
Estimated hours taken: 3
Branches: main

Add a new mdb command "ambiguity" that prints out ambiguous predicate, function
and type names.

doc/user_guide.texi:
	Document the new command.

doc/mdb_categories:
	Add the new command, as well as some others that should have been added
	previously but weren't.

trace/mercury_trace_internal.c:
	Add the user interface for the new command.

	Fix some old cut-and-paste bugs.

trace/mercury_trace_tables.[ch]:
	Add the implementation of the new command.

runtime/mercury_type_tables.[ch]:
	Change the signature of the function that return the list of all
	type_ctor_infos to also return their number, for use in the new code
	in mercury_trace_tables.c.

	Convert to four-space indentation.

runtime/mercury_layout_util.c:
runtime/mercury_wrapper.c:
	Convert to four-space indentation.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
	Expect the mdb command added by this diff, as well as the ones added
	by Ralph recently.
2005-10-25 04:00:56 +00:00
Ian MacLarty
cfa50105ba Allow the search mode to be changed from within the declarative debugger.
Estimated hours taken: 15
Branches: main

Allow the search mode to be changed from within the declarative debugger.

Make binary search independent of subterm dependency tracking.  The
user can now perform a binary search along the path between the current
question and the root of the search space using the command `mode binary'
(or `m b').

browser/declarative_analyser.m:
	Make reask_last_question fail instead of throwing an exception
	if there is no last question.  If it fails we
	recompute the question.  This happens when the user
	resumes with a new search mode.

	Do not return an analyser response when showing info, since we can
	just call reask_last_question.

	Make set_fallback_search_mode set the last_search_question field to
	no.  This will force the question to be recomputed with the new
	search strategy when analysis continues.

	Add change_search_mode which handles the users request to change the
	current search mode from within a declarative debugging session.

	Do not perform a binary search after tracking a subterm unless
	instructed to do so by the user.

browser/declarative_debugger.m:
	Allow search mode changes to be undone.
	Handle the new change_search oracle response.
	Handle the fact that reask_last_question is now semidet.

browser/declarative_oracle.m:
	Add a change_search oracle response.
	Add a predicate to indicate which oracle responses are undoable.

browser/declarative_user.m:
	Add a change_search user response.

doc/user_guide.texi:
	Rephrase the description of the undo command to take into account that
	search mode changes can be undone.
	Add a section about the binary search mode.
	Rearrange some text and reword some sentences slightly.

tests/debugger/mdb_command_test.inp:
tests/debugger/declarative/Mmakefile:
tests/debugger/declarative/binary_search.exp:
tests/debugger/declarative/binary_search.exp2:
tests/debugger/declarative/binary_search.inp:
tests/debugger/declarative/binary_search.inp2:
tests/debugger/declarative/change_search.exp:
tests/debugger/declarative/change_search.inp:
tests/debugger/declarative/change_search.m:
tests/debugger/declarative/info.exp:
tests/debugger/declarative/info.inp:
	Test the `mode' command and do not expect the declarative debugger to
	automatically go into binary search mode once it has tracked a subterm.
2005-08-19 16:08:31 +00:00
Ian MacLarty
468b4d4945 Include a script to test the performance of the debugger in the tools
Estimated hours taken: 4
Branches: main

Include a script to test the performance of the debugger in the tools
directory.

Add a --test dd command option.  The --test option causes the declarative
debugger to simulate a session where the user answers `no' to all questions
until a bug is found.

Remove the dd_dd mdb command and add a --debug option to the dd command which
does the same thing.  The double maintenance of the dd_dd and dd commands was
becoming onerous.

browser/declarative_debugger.m:
	Export a predicate to set the testing flag in the user state.

browser/declarative_oracle.m:
	Add a predicate to set the testing flag of the user state.

browser/declarative_user.m:
	Add a new flag to the user state which indicates whether user answers
	should be simulated.
	If the new flag is set then simulate answers instead of asking the
	user.

doc/user_guide.texi:
	Document the --test and --debug developer options.

tools/dd_speedtest:
	Script for testing the performance of the declarative debugger.

tools/extract_dd_stats.awk:
	Script for summarizing the output of dd_speedtest.

trace/mercury_trace_declarative.c:
	Add a predicate to set the testing flag of the diagnoser.
	Rename the global variable which says whether the declarative debugger
	is being debugged.
	Use the -p ps option to print the Memory consumption of the current
	process instead of using grep.

trace/mercury_trace_declarative.h:
	Fix a typo.
	Export the predicate to set the testing flag.
	Rename the global variable which says whether the declarative debugger
	is being debugged.

trace/mercury_trace_internal.c:
	Add the --test and --debug options and remove the dd_dd command.
2005-08-09 07:14:02 +00:00
Zoltan Somogyi
09171535a9 Provide a mechanism for gathering statistics about which predicates occur most
Estimated hours taken: 3
Branches: main

Provide a mechanism for gathering statistics about which predicates occur most
frequently in the I/O action table.

Instead of adding a new mdb command, consolidate three existing mdb commands
(proc_stats, label_stats and var_name_stats) into a single "stats" command,
and add a new variant for stats on I/O tabling.

doc/mdb_categories:
doc/user_guide.texi:
	Document the changes in mdb commands.

runtime/mercury_trace_base.[ch]:
	Add a new function for printing stats on the predicate in the I/O
	action table.

	Add headers to each section of this file.

runtime/mercury_hash_table.[ch]:
	Remove the const qualifier from the return type of the lookup function,
	since mercury_trace_base.c now needs to modify a looked-up record.

	Move the documentation on the functions in this module to the header
	file.

trace/mercury_trace_internal.c:
	Merge the three previous mdb commands into one, and add the new
	alternative.

trace/mercury_trace_tables.c:
	Minor change in formatting.

trace/mercury_trace_tables.c:
	Minor style fix.

tests/debugger/completion.{inp,exp}:
tests/debugger/mdb_command_test.inp:
	Change these test cases to account for the disappearance of the
	three old mdb commands and the appearance of the new one.
2005-08-01 02:40:13 +00:00
Ian MacLarty
42ec572494 Add a new method to convert terms to XML using a typeclass.
Estimated hours taken: 6
Branches: main

Add a new method to convert terms to XML using a typeclass.
The new method is more flexible than the previous method in that values can be
converted to arbitrary elements with arbitrary attributes and children
(the previous method mapped a functor to one element with limited attributes).
DTDs cannot be automatically generated using the new method.

library/term_to_xml.m:
	Update the documentation to describe the new method.
	Divide the interface into two parts -- one for the new method and
	one for the old method.
	Rename some function symbols and variables of the old method to
	distinguish them from names used in the new method.
	Implement predicates for writing terms that are members of the xmlable
	typeclass.

tests/hard_coded/Mmakefile:
tests/hard_coded/xmlable_test.exp:
tests/hard_coded/xmlable_test.m:
	Test the new method.

tests/hard_coded/write_xml.m:
	Use attr_from_source instead of attribute.
2005-07-29 01:57:00 +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
cabb22d14f Improve the declarative debugger interface.
Estimated hours taken: 7
Branches: main

Improve the declarative debugger interface.

The two main changes are to use the mdb help system and not re-display
the question after the user issues a command which does not answer the
question.  For example if the user issues an `info' command, then previously
the question would be redisplayed after the requested information and if the
question is big then the information would be scrolled off the screen.

browser/declarative_analyser.m:
	Remove extra new line characters when printing info.  These are
	no longer necessary since the question is not redisplayed.

browser/declarative_debugger.m:
	Pass the help system from mdb to the oracle state when
	initialising the diagnoser.

browser/declarative_oracle.m:
	Pass the help system to the user state when initialising the
	oracle state.

browser/declarative_user.m:
	Add two new fields to the user state: one to keep a reference to
	the help system and one to indicate whether the current question
	should be displayed when getting a user input.

	Allow the user to redisplay the question by issuing a `print' command
	with no arguments.  If the question is not to be displayed the show
	a "dd>" prompt.

	Change the `abort' command to `quit'.  This is more consistent
	with the rest of mdb.

doc/commands:
	Add a script to print all the commands in a section in the
	user guide.

doc/generate_mdb_doc:
	Generate help for the declarative debugger.

doc/mdb_categories:
	Add a category, `decl', for commands that can be executed inside
	the declarative debugger.  Change the `dd' category to mdb_dd,
	because 1) `help dd' used to show help about the `dd' category AND
	the `dd' command and 2) `dd' is too general a category name now that we
	have a `decl' category.

	Add an item, `decl_debug' to the concepts category.

doc/user_guide.texi:
	Document some dd commands which previously weren't documented here.

	Add a short overview of the declarative debugger.  This is
	displayed when the user issues a `help' command from within the
	dd.

	Move the bit about the behaviour when no command is given to
	before the list of commands.  This is necessary so util/info_to_mdb.c
	doesn't include this in the help of the last command in the list.

tests/debugger/declarative/app.exp:
tests/debugger/declarative/app.inp:
tests/debugger/declarative/browse_arg.exp:
tests/debugger/declarative/browse_arg.inp:
tests/debugger/declarative/browser_mode.exp:
tests/debugger/declarative/browser_mode.inp:
tests/debugger/declarative/confirm_abort.exp:
tests/debugger/declarative/confirm_abort.inp:
tests/debugger/declarative/dependency.exp:
tests/debugger/declarative/dependency.inp:
tests/debugger/declarative/find_origin.exp:
tests/debugger/declarative/find_origin.exp2:
tests/debugger/declarative/info.exp:
tests/debugger/declarative/info.inp:
tests/debugger/declarative/io_stream_test.exp:
tests/debugger/declarative/io_stream_test.exp2:
tests/debugger/declarative/mapinit.exp:
tests/debugger/declarative/mapinit.inp:
tests/debugger/declarative/output_term_dep.exp:
tests/debugger/declarative/output_term_dep.inp:
tests/debugger/declarative/resume.exp:
tests/debugger/declarative/resume.inp:
tests/debugger/declarative/skip.exp:
tests/debugger/declarative/skip.inp:
tests/debugger/declarative/solutions.exp3:
tests/debugger/declarative/tabled_read_decl.exp:
	Update tests.

trace/mercury_trace_declarative.c:
trace/mercury_trace_help.c:
trace/mercury_trace_help.h:
	Pass the help system to the frontend.
2005-05-02 04:21:19 +00:00
Ian MacLarty
b5550df746 Add mdb `dice' command which reads in a set of passing trace counts and a
Estimated hours taken: 40
Branches: main

Add mdb `dice' command which reads in a set of passing trace counts and a
failing trace count and prints a comparison table.  The table can be sorted
by various metrics and is useful for finding parts of a program executed in
a failing run, but not in passing runs.

browser/dice.m
	Add a new module for generating and manipulating a dice.

browser/mdb.m
	Add the dice module.

compiler/special_pred.m
mdbcomp/prim_data.m
	Move special_pred_name_arity/3 from compiler/special_pred.m to
	mdbcomp/prim_data.m so it can be used in dice.m.

doc/user_guide.texi
	Document the `dice' mdb command.  Also document the fact that the
	failing and passing slice file names can be set with the `set' mdb
	command.

	Move the `set' command to the misc section from the browser section
	since it now also sets the passing and failing slice file names, which
	have nothing to do with the browser.

library/list.m
	Add map4, map5 and map6 since map6 is needed in dice.m.

mdbcomp/program_representation.m
	Add a predicate to convert a goal path to a string.

mdbcomp/trace_counts.m
	Convert string_to_trace_port into a predicate and add a new mode so
	that a port can be converted back to a string.

runtime/mercury_trace_base.h
trace/mercury_trace_util.h
	Move the MR_TRACE_USE_HP and MR_TRACE_CALL_MERCURY macros to
	runtime/mercury_trace_base.h, so that they can be called from
	browser/dice.m.

tests/Mmake.common
	Clean up trace counts (which are generated to test the `dice' command).

tests/debugger/Mmakefile
tests/debugger/dice.exp
tests/debugger/dice.exp2
tests/debugger/dice.inp
tests/debugger/dice.m
tests/debugger/dice.passes
	Test the `dice' command.

trace/mercury_trace_internal.c
	Add the mdb `dice' command and modify the `set' command so the
	`fail_trace_count' and `pass_trace_counts' parameters can be set.

	Add a function to print a dice.

	Move the `set' command to the misc help section.
2005-02-10 04:10:33 +00:00
Zoltan Somogyi
55909bcbaf Implement a new mdb command, "condition", which associates a condition with
Estimated hours taken: 16
Branches: main, release

Implement a new mdb command, "condition", which associates a condition with
an existing breakpoint. The condition is a match between a variable live at
the breakpoint, or a part thereof, and a term provided as part of the condition
command. If execution arrives at the breakpoint but the match doesn't have the
required outcome, execution will continue without stopping.

NEWS:
	Mention the new capability.

doc/user_guide.texi:
	Document the new capability.

runtime/mercury_trace_term.[ch]:
	This new module has facilities for converting strings to a structured
	representation of terms. The debugger uses this representation for the
	term being matched.

runtime/Mmakefile:
	Add the new module to the list of modules in the runtime library.

browser/cterm.m:
	This new module tests whether a value in the program being debugged
	matches a term represented by the data structure defined in
	mercury_trace_term.

browser/mdb.m:
	Include the new module in the browser library.

trace/mercury_trace_spy.[ch]:
	Change the code that checks for breakpoints to check breakpoints'
	conditions.

	Fix an old bug: set the number of the most recent breakpoint
	even when reusing an existing slot.

trace/mercury_trace_vars.c:
	Change the code that checks for breakpoints to also evaluate the
	condition, if any.

	Provide the facilities required to implement conditions. Besides
	exporting some previously private functions, this involved breaking up
	two existing functions into two pieces each, because condition checking
	wanted to reuse only parts of them.

	Modify the implementation of the functions manipulating breakpoints
	to handle the new parts of spy point structures.

	Modify the way we delete spy point structures to make doubly sure
	that we don't free memory twice; it is now MR_delete_spy_point that
	sets the spy_exists field to FALSE, after checking it.

	Give more meaningful names to some variables.

trace/mercury_trace_internal.[ch]:
	Implement the condition command.

	Conform to the changes in mercury_trace_vars.c

	When the condition of a breakpoint cannot be evaluated, print an error
	message.

	Extend the command parser to support double quotes, since this is now
	needed to allow strings in terms in the condition command.

	Flush any error messages resulting from an mdb command immediately
	after the command. This was useful in debugging the change.

tests/debugger/cond.{m,inp,exp*}:
	Add this new test case to test the new capability.

tests/debugger/Mmakefile:
	Include the new test case in the list of test cases.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
	Update to reflect the new command.

tests/debugger/cmd_quote.exp:
	Update the error message.
2005-02-01 03:24:32 +00:00
Ralph Becket
e0744703f7 Undo an unintended change.
Estimated hours taken: 0.1
Branches: main

tests/debugger/mdb_command_test.inp:
	Undo an unintended change.
2005-01-28 01:13:32 +00:00
Ralph Becket
bc957f8cdd Fix a bug in loop-invariant hoisting.
Estimated hours taken: 3
Branches: main

Fix a bug in loop-invariant hoisting.

compiler/common.m:
	Fix common__generate_assign/7 to recognise equivalent
	types for type_infos and type_class_infos.

compiler/loop_inv.m:
	Fixed a bug where goals taking (partly) unique arguments were
	incorrectly being considered for hoisting.
2005-01-28 01:03:19 +00:00
Zoltan Somogyi
387a6c8878 Allow uses to associate with each breakpoint in mdb a list of print actions
Estimated hours taken: 8
Branches: main

Allow uses to associate with each breakpoint in mdb a list of print actions
that should be executed automatically when execution arrives at the breakpoint.

A new print list (a list of things to be printed) can be attached to an
existing breakpoint via the new "break_print" command, or it can be attached
to a breakpoint being created via the existing "break" command.

NEWS:
	Mention the new capability.

doc/user_guide.texi:
	Document the new capability.

trace/mercury_trace_spy.[ch]:
	Keep a print list with every breakpoint, and add functions to
	manipulate print lists.

	Convert this module to four space indentation to keep indent levels
	manageable.

trace/mercury_trace.c:
	Conform to the updated interface of the mercury_trace_spy module.

trace/mercury_trace_internal.[ch]:
	When the internal debugger is invoked at an event, whether
	interactively or not, take an extra parameter specifying the
	print list, if any, to be executed.

	Implement the new "break_print" command and the new options of
	the "break" command.

	Conform to the updated interface of the mercury_trace_spy module.

trace/mercury_trace_declarative.c:
	Conform to the updated interface of the mercury_trace_internal module.

tests/debugger/breakpoints.{inp,exp*}:
	Test the new capability.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
	Update to reflect the new command.
2005-01-27 06:17:41 +00:00
Zoltan Somogyi
4d443a5c9e Make the stack and nondet_stack commands in mdb limit the number of lines
Estimated hours taken: 3
Branches: main

Make the stack and nondet_stack commands in mdb limit the number of lines
printed, instead of the number of stack frames reported on.

runtime/mercury_stack_trace.[ch]:
	Add a mechanism to limit the number of lines printed by stack traces.

trace/mercury_trace_internal.c:
	Change the existing "stack" and "nondet_stack" mdb commands to make the
	integer argument specify the number of lines printed by default, not
	the number of stack frames reported on, since this is usually what is
	wanted. The number of stack frames N to be reported on can still be
	specified, via the new option -fN.

	Add a new mdb command, "stack_default_limit", that specifies the
	default number of lines to print in stack traces.

trace/mercury_trace_external.c:
	Conform to the changed interfaces in mercury_stack_trace.h.

doc/user_guide.texi:
	Document the changes to mdb commands.

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

tests/debugger/completion.exp*:
	Expect to see the new stack_default_limit command listed.

tests/debugger/queens.exp*:
	Expect the new meaning of the stack command.

tests/debugger/nondet_stack.{inp,exp*}
	Use the new -f option of the nondet_stack command to specify the
	printing of the same number of frames as before. Update the expected
	accordingly.
2005-01-17 05:58:10 +00:00
Zoltan Somogyi
f71532a398 Add an mdb command, all_procedures, for listing all the procedures in the
Estimated hours taken: 2
Branches: main

Add an mdb command, all_procedures, for listing all the procedures in the
program. It has two options: -u or --uci for listing unify, compare, index and
init predicates, and -s or --separate for printing the various parts of
procedure names in separate fields, for automatic processing (e.g. by awk
scripts).

trace/mercury_trace_internal.c:
	Implement all_procedures.

	Fix a couple of small bugs: a wrong help category argument in an option
	processing call, and a NULL completer function.

trace/mercury_trace_tables.[ch]:
	Provide a function that is the guts of all_procedures.

	Fix the code for handling the specification of unify, compare and
	index procedures to also handle init procedures.

doc/user_guide.texi:
	Document all_procedures.

runtime/mercury_stack_trace.[ch]:
	Add a new function for printing procedure ids for all_procedures -s.

	Fix the code for printing unify, compare and index predicates to also
	handle init predicates.

tests/debugger/solver_test.{m,inp,exp}:
	A new test case to test the fix of the printing of init predicates.

tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
	Add the new test case.

tests/debugger/mdb_command_test.inp:
tests/debugger/completion.exp:
	Update these files to account for the new mdb command.
2004-12-09 01:03:22 +00:00
Ian MacLarty
e7d6509c95 Trust modules in the Mercury standard library by default in the declarative
Estimated hours taken: 6
Branches: main

Trust modules in the Mercury standard library by default in the declarative
debugger.

Make trusted object id's returned by `trusted' command persistent.  Previously
each trusted object was identified by its position in the ordered list of
trusted objects.  This meant that if an object was removed all objects after
the removed object in the ordered list of trusted objects would have their ids
decremented, so if the user wanted to then delete another object they'd have to
issue another `trusted' command to get the new id first.  The behaviour is now
consistent with the behaviour of breakpoint ids which keep their id for the
life of the breakpoint.

Put the mdb declarative debugger commands in their own section, instead of in
misc to be consistent with the mdb online help categories and so the online
help for the mdb declarative debugger commands is generated properly (the
dd help category wasn't getting any online documentation generated for it).

browser/declarative_debugger.m
	Add and export predicate to add the standard
	library to the set of trusted objects.

browser/declarative_oracle.m
	Add predicate to add the standard library to the set of trusted
	objects.

	Use a bimap to represent the set of trusted objects along with each
	object's id (we need to look up objects both ways).

	Adjust comment formatting to conform to standard.

	Rename trusted_module_or_predicate type to trusted_object.  Add
	constructor for standard_library to trusted_object type.  Include
	standard library when initialising the set of trusted objects.

	Change predicates adding or removing trusted objects to use new
	persistent object id.

	If a module belongs to the standard library and the standard library is
	trusted then trust the module.

compiler/modules.m
library/library.m
	Move definition of mercury_std_library_module/1 from modules.m to
	library.m so it can be used by the debugger.  Adjust comment
	accordingly.

compiler/mlds.m
	Import library module since since mercury_std_library_module/1 now
	resides there.

doc/generate_mdb_doc
	Generate declarative debugger commands documentation.

doc/user_guide.texi
	Document `trust std lib' command.

tests/debugger/declarative/catch.exp2
tests/debugger/declarative/catch.exp3
tests/debugger/declarative/catch.inp2
tests/debugger/declarative/solutions.exp2
tests/debugger/declarative/solutions.inp2
	Untrust the standard library for these tests.

tests/debugger/declarative/trust.inp
tests/debugger/declarative/trust.exp
	Update test to reflect persistent trusted object ids and trusting of
	standard library.

trace/mercury_trace_declarative.c
trace/mercury_trace_declarative.h
	Add function to trust the standard library.

trace/mercury_trace_internal.c
	Allow user to trust the standard library by issuing a `trust std lib'
	command.
2004-11-16 00:45:14 +00:00
Ian MacLarty
e6d82c9bd4 Added trusted' and untrust' commands. Also allowed individual predicates to
Estimated hours taken: 10
Branches: main

Added `trusted' and `untrust' commands.  Also allowed individual predicates to
be trusted.

browser/declarative_debugger.m
	Exported predicates to add a trusted predicate or function, remove
	a trusted object and return a list of the trusted objects.

browser/declarative_oracle.m
	Changed trusted set so it can also contains individual predicates and
	functions.  Added predicates to add a trusted predicate or function
	to the set, remove a trusted object from the set and return a list
	of the trusted objects.

doc/mdb_categories
	Added dd category.

doc/user_guide.texi
	Documented `untrust' and `trusted' commands.

runtime/mercury_stack_trace.c
runtime/mercury_stack_trace.h
	Added a print_mode argument to MR_print_proc_id_internal, so that
	printing of mode information can be turned on or off.  When a list
	of matching predicates for the trust command is shown then mode
	information is superfluous, since a predicate/function is trusted, not
	a procedure.
	Added MR_print_pred_id to print predicate id - i.e. proc id without
	the mode info.

tests/debugger/completion.exp
	New commands shown in completion list.

tests/debugger/completion.inp
	Added a space, since a --More-- prompt is now displayed when showing
	all the commands.

tests/debugger/mdb_command_test.inp
	untrust and trusted added.

tests/debugger/declarative/trust.exp
tests/debugger/declarative/trust.inp
	Testing of new commands.

trace/mercury_trace_declarative.c
trace/mercury_trace_declarative.h
	Added functions to add a trusted predicate and remove a trusted
	object.  Also added a function to print a list of the trusted objects.
	These all call the predicates exported from declarative_debugger.m.

trace/mercury_trace_internal.c
	Added handlers for `trusted' and `untrust' commands.

trace/mercury_trace_tables.c
trace/mercury_trace_tables.h
	Added a function to filter out only the user predicates and functions
	from a list of procedures.  This filters out uci procs and also
	filters out all procs with a mode number > 0 (thus leaving one proc
	for each predicate/function).  This is used when displaying the
	predicates matching an ambiguous proc-spec with a trust command.

NEWS
	Updated NEWS file.
2004-09-20 04:50:26 +00:00
Zoltan Somogyi
f76c4823e5 Fix a problem reported by Ian: the debugger ignored information about the head
Estimated hours taken: 2
Branches: main

Fix a problem reported by Ian: the debugger ignored information about the head
variables of the predicates generated by the compiler from lambda expressions
because they didn't have names.

compiler/hlds_pred.m:
	Add a predicate to ensure that all headvars have names.

compiler/lambda.m:
	Call that predicate to give names to the predicates created from lambda
	expressions.

compiler/code_gen.m:
	Call that predicate to give names to the predicates created from lambda
	expressions, in case other transformations also create predicates
	with unnamed head variables.

doc/user_guide.texi:
	Add a new mdb command, var_details, and a new method of invocation of
	an existing mdb command, flag. I used them to track down this bug.

trace/mercury_trace_internal.c:
	Implement the var_details mdb command, and the new method of invocation
	of the flag command.

trace/mercury_trace_vars.[ch]:
	Add a function to print variable details.

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

tests/debugger/completion.exp:
	Expect the new command.

tests/debugger/lambda_expr.{m,inp,exp}:
	Add the new test case to test for the bug.

tests/debugger/Mmakefile:
	Enable the new test case.
2004-07-19 03:37:55 +00:00
Ian MacLarty
8ea1dbc3b5 Added a `trust' command to mdb which tells the declarative debugger to assume
Estimated hours taken: 35
Branches: main

Added a `trust' command to mdb which tells the declarative debugger to assume
all procedures in a given module are correct.

browser/declarative_debugger.m
	Added function which finds out the atom a given	question relates to.
	Exported a add_trusted_module predicate so modules can be added from
	c code (used by trace/mercury_trace_declarative.c).

browser/declarative_execution.m
	Add module_name field to the atom constructor for the trace_atom type.
	Made necessary changes to predicates that expected 3 fields for the
	atom constructor for the trace_atom type.

browser/declarative_oracle.m
	Added a set of trusted module names to the oracle_state type.

browser/declarative_tree.m
	Updated various predicates that expected the atom constructor to have
	3 fields where now it has 4.

browser/declarative_user.m
	Updated various predicates that expected the atom constructor to have
	3 fields where now it has 4.

trace/mercury_trace_declarative.h
	Added MR_decl_add_trusted_module function to add a module to the set of
	trusted modules for the currect diagnoser.

trace/mercury_trace_declarative.c
	Implemented the MR_decl_add_trusted_module function.  This calls
	MR_trace_decl_ensure_init to make sure the diagnoser is initialised
	first.

	Changed the MR_decl_make_atom function to include the module name
	when constructing an atom.

	Added MR_decl_atom_name_and_module function which extracts the proc
	name and module from a MR_Proc_Layout.  This replaces the
	MR_decl_atom_name function which just extracted the name.  This
	function will also extract the name and module of user defined equality
	and comparison predicates.

trace/mercury_trace_internal.c
	Added MR_trace_cmd_trust function to add a trusted module to the
	current diagnoser when the user issues a `trust' command.

doc/mdb_categories
	Added `trust' command to misc category (will need to make a declarative
	category when there are more commands).

doc/user_guide.texi
	Added some help text for the `trust' command.

tests/debugger/mdb_command_test.inp
	Added `trust' command to list of tests.

tests/debugger/declarative/Mmakefile
	Added calls to the trust.m program to test the `trust' command.

tests/debugger/declarative/trust.m
	Test program for the `trust' command.  This imports 2 modules in the
	and calls a user-defined comparison predicate from the one module and
	a normal predicate from the other.

tests/debugger/declarative/trust_1.m
	Imported by trust.m.  Defines a new type and a user-defined comparison
	predicate on the type.

tests/debugger/declarative/trust_2.m
	Also imported by trust.m.  Defines a predicate using the type defined
	in trust_1.m.

tests/debugger/declarative/trust.inp
	Input to mdb to test the `trust' command.  Contains commands to tell
	mdb to trust the trust_1 and trust_2 modules.

tests/debugger/declarative/trust.exp
	Expected output of mdb when running trust with trust.inp as input.
2004-06-15 05:35:13 +00:00
Zoltan Somogyi
7bf0cd03af Reduce the overhead of all forms of tabling by eliminating in many cases
Estimated hours taken: 32
Branches: main

Reduce the overhead of all forms of tabling by eliminating in many cases
the overhead of transferring data across the C/Mercury boundary. These
involve lots of control transfers as well as assignments to and from
Mercury abstract machine registers, which are not real machine registers
on x86 machines. Benchmarking in Uppsala revealed this overhead to be
a real problem.

The way we do that is by changing the tabling transformation so that instead
of generating sequences of calls to predicates from library/table_builtin.m,
we generate sequences of calls to C macros from runtime/mercury_tabling_pred.h,
and emit the resulting code string as the body of a foreign_proc goal.
(The old transformation is still available via a new option,
--no-tabling-via-extra-args.)

Since the number of inputs and outputs of the resulting C code sequences
are not always fixed (they can depend on the number of input or output
arguments of predicate being transformed), implementing this required
adding to foreign_procs a new field that allows the specification of extra
arguments to be passed to and from the given foreign code fragment. For now,
this mechanism is implemented only by the C backends, since it is needed
only by the C backends. (We don't support yet tabling on other backends.)

To simplify the new implementation of the field on foreign_procs, consolidate
three existing fields into one. Each of these fields was a list with one
element per argument, so turning them into a single list with a combined record
per argument should also improve reliability, since it reduces the likelyhood
of updates leaving the data structure inconsistent.

The goal paths of components of a tabled predicate depend on whether
-no-tabling-via-extra-args was specified. To enable the expected outputs
of the debugger test cases testing tabling, we add a new mdb command,
goal_paths, that controls whether goal paths are printed by the debugger
at events, and turn off the printing of events in the relevant test cases.

Also, prepare for a future change to optimize the trie structure for
user-defined types by handling type_infos (and once we support them,
typeclass_infos) specially.

compiler/table_gen.m:
	Change the tabling transformation along the lines described above.

	To allow us to factor out as much of the new code as possible,
	we change the meaning of the call_table_tip variable for minimal
	model subgoals: instead of the trie node at the end of the answer
	table, it is not now the subgoal reachable from it. This change
	has no effect as yet, because we use call_table_tip variables
	only to perform resets across retries in the debugger, and we
	don't do retries across calls to minimal model tabled predicates.

	Put predicates into logical groups.

library/table_builtin.m:
runtime/mercury_tabling_preds.h:
	When the new transformations in table_gen.m generate foreign_procs
	with variable numbers of arguments, the interfaces of those
	foreign_procs often do not match the interfaces of the existing
	library predicates at their core: they frequently have one more
	or one fewer argument. To prevent any possible confusion, in such
	cases we add a new variant of the predicate. These predicates
	have the suffix _shortcut in their name. Their implementations
	are dummy macros that do nothing; they serve merely as placeholders
	before or after which the macros that actually do the work are
	inserted.

	Move the definitions of the lookup, save and restore predicates
	into mercury_tabling_preds.h. Make the naming scheme of their
	arguments more regular.

runtime/mercury_minimal_model.c:
runtime/mercury_tabling_preds.h:
	Move the definition of a predicate from mercury_minimal_model.c
	to mercury_tabling_preds.h, since the compiler now needs to be
	able to generate an inlined version of it.

compiler/hlds_goal.m:
	Replace the three existing fields describing the arguments of
	foreign_procs with one, and add a new field describing the extra
	arguments that may be inserted by table_gen.m.

	Add utility predicates for processing the arguments of foreign_procs.

	Change the order of some existing groups of declarations make it
	more logical.

compiler/hlds_pred.m:
runtime/mercury_stack_layout.h:
	Extend the data structures recording the structure of tabling tries
	to allow the representation of trie steps for type_infos and
	typeclass_infos.

runtime/mercury_tabling_macros.c:
	Fix a bug regarding the tabling of typeclass_infos, which is now
	required for a clean compile.

compiler/pragma_c_gen.m:
compiler/ml_code_gen.m:
	Modify the generation of code for foreign_procs to handle extra
	arguments, and to conform to the new data structures for foreign_proc
	arguments.

compiler/llds.m:
	The tabling transformations can now generate significantly sized
	foreign_procs bodies, which the LLDS code generator translates to
	pragma_c instructions. Duplicating these by jump optimization
	may lose more by worsening locality than it gains in avoiding jumps,
	so we add an extra field to pragma_c instructions that tells jumpopt
	not to duplicate code sequences containing such pragma_cs.

compiler/jumpopt.m:
	Respect the new flag on pragma_cs.

compiler/goal_util.m:
	Add a predicate to create foreign_procs with specified contents,
	modelled on the existing predicate to create calls.

	Change the order of the arguments of that existing predicate
	to make it more logical.

compiler/polymorphism.m:
	Conform to the new definition of foreign_procs. Try to simplify
	the mechanism for generating the type_info and typeclass_info
	arguments of foreign_proc goals, but it is not clear that this
	code is even ever executed.

compiler/aditi_builtin_ops.m:
compiler/assertion.m:
compiler/bytecode_gen.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/code_util.m:
compiler/constraint.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/dnf.m:
compiler/dupelim.m:
compiler/equiv_type_hlds.m:
compiler/exprn_aux.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/frameopt.m:
compiler/goal_form.m:
compiler/goal_path.m:
compiler/higher_order.m:
compiler/higher_order.m:
compiler/hlds_module.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/ite_gen.m:
compiler/layout_out.m:
compiler/livemap.m:
compiler/liveness.m:
compiler/llds_out.m:
compiler/loop_inv.m:
compiler/magic.m:
compiler/make_hlds.m:
compiler/mark_static_terms.m:
compiler/middle_rec.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/pd_cost.m:
compiler/prog_rep.m:
compiler/purity.m:
compiler/quantification.m:
compiler/reassign.m:
compiler/rl_exprn.m:
compiler/saved_vars.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/store_alloc.m:
compiler/stratify.m:
compiler/switch_detection.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeed_code.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
	Conform to the new definition of foreign_procs, pragma_cs and/or
	table trie steps, or to changed argument orders.

compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/cse_detection.m:
compiler/dead_proc_elim.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/lco.m:
compiler/module_util.m:
compiler/opt_util.m:
compiler/stack_opt.m:
compiler/trans_opt.m:
	Conform to the new definition of foreign_procs.

	Bring these modules up to date with our current code style guidelines,
	using predmode declarations, state variable syntax and unification
	expressions as appropriate.

compiler/mercury_compile.m:
	Conform to the changed argument order of a predicate in trans_opt.m.

compiler/options.m:
	Add the --no-tabling-via-extra-args option, but leave the
	documentation commented out since the option is for developers only.

doc/user_guide.texi:
	Document --no-tabling-via-extra-args option, though leave the
	documentation commented out since the option is for developers only.

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

trace/mercury_trace_internals.c:
	Implement the new goal_paths mdb command.

tests/debugger/completion.exp:
	Conform to the presence of the goal_paths mdb command.

tests/debugger/mdb_command_test.inp:
	Test the existence of documentation for the goal_paths mdb command.

tests/debugger/print_table.{inp,exp*}:
tests/debugger/retry.{inp,exp*}:
	Use the goal_paths command to avoid having the expected output
	depend on the presence or absence of --tabling-via-extra-args.

tests/tabling/table_foreign_output.{m,exp}:
	Add a new test case to test the save/restore of arguments of foreign
	types.

tests/tabling/Mmakefile:
	Enable the new test case.

tests/tabling/test_tabling:
	Make this script more robust.

	Add an option for testing only the standard model forms of tabling.
2004-06-07 09:07: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
6cd0c5a7ba Reduce the size of .c and .o files with debugging enabled by compressing
Estimated hours taken: 8
Branches: main

Reduce the size of .c and .o files with debugging enabled by compressing
tables of variable numbers. Previously, in the array indexed by variable
numbers whose entries gave each variable's name, the number we used to
identify a variable was its HLDS variable number. Variables whose names
weren't needed, or which didn't have names, or which were optimized away,
still had an entry in this array, which took up space in the .c and .o files
and at runtime.

This diff eliminates these unused array elements by identifying each variable
not via its HLDS variable number, but via a unique id number taken from a dense
set. This id number is used nowhere else, but this is OK.

This change reduces the sizes of .c files with debugging enabled by about 1.5%.

compiler/stack_layout.m:
	Implement the change described above.

	Bring most of this module up to date with our coding standards:
	use state variable syntax where appropriate. (Updating the rest
	would cause unnecessary conflicts with another workspace.)

	Use 3-tuples instead of pairs of pairs.

trace/mercury_trace_internals.c:
	Implement a new command, var_name_stats, that displays statistics
	about the amount of space occupied by variable name arrays and the
	string tables they point into.

trace/mercury_trace_tables.[ch]:
	Provide the function implementing the new mdb command.

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

tests/debugger/completion.inp:
tests/debugger/mdb_command_test.{inp}:
	Update these test cases to account for the new mdb command.
	(tests/debugger/completion.exp will be updated later.)
2004-05-04 07:23:25 +00:00
Zoltan Somogyi
8b9d436cbb More improvements for minimal model tabling.
Estimated hours taken: 12
Branches: main

More improvements for minimal model tabling.

runtime/mercury_engine.[ch]:
	Provide a debug flag to control the printing of debug stack slots
	in nondet stack dumps.

runtime/mercury_stack_trace.[ch]:
	Provide a mechanism that allows a dump of the nondet stack to print
	the principal debugging stack slots of the stack frames of procedures
	that were compiled with debugging, to help debug problems where
	these are overwritten during stack segment saves/restores.

	Add a mechanism for limiting the output of a nondet stack trace
	to a segment of the nondet stack.

runtime/mercury_minimal_model.[ch]:
	Limit the output of a diagnostic nondet stack trace to just the
	segment being saved or restored.

	Provide a label layout structure for the entry point of the suspend
	predicate, since this is necessary for correct nondet stack traces
	at suspensions and resumptions.

	Store the layout structure of the top nondet stack frame with each
	saved state, to allow the saved nondet stack segment to be dumped
	at resumptions as well as suspensions.

	Fix an old bug: when extending a saved stack segment, use the same
	algorithm for determining its lower bound as when the stack segment
	was created in the first place.

	Factor out some repeated definitions.

	Note problems to be fixed later.

	Improve debugging output.

runtime/mercury_stacks.[ch]:
	Move the documentation of the generator stack, the cut stack and the
	pneg stack from the source file to the header file, and expand it
	considerably.

	Make the routines for printing entries of these stacks generate more
	consistently formatted output.

	Simplify some code.

runtime/mercury_stack_layout.h:
	Provide a macro for use by mercury_minimal_model.c.

runtime/mercury_trace_base.[ch]:
	Save and restore the global variables holding event numbers,
	call sequence numbers and call depths across debugging Mercury code.
	We already used to do this for Mercury code invoked by the debugger,
	but now that we can invoke Mercury code to print the values of
	variables as diagnostics from within the suspend and resume predicates
	*outside* the debugger, we need to do it more generally.

trace/mercury_trace.c:
	Fix a bug: provide the layout structure of the current procedure
	to the diagnostic routines for minimal model tabling even if the
	debugger doesn't stop at that procedure.

trace/mercury_trace_internal.c:
	Add two new mdb commands to help debug minimal model tabling.

	The "mm_stack" command has the same effect as the existing commands
	"gen_stack", "cut_stack" and "pneg_stack" executed in sequence.

	The "debug_vars" command prints the counters for event numbers,
	call sequence numbers and call depths, both from their global variables
	and their saved copies, for debugging problems where they are
	overwritten, such as the one fixed by the changes to
	mercury_trace_base.[ch] above.

	Reorder some code for consistency.

trace/mercury_trace_util.[ch]:
	Add a function to implement the "debug_vars" command.

doc/user_guide.texi:
	Document the new mdb commands.

doc/mdb_categories:
	Add the new mdb commands to the list of developer commands, as well
	some others previously left out.

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

tests/tabling/combine.m:
	Change the code of this test case to what was intended, so that it now
	matches the old expected output.

tests/tabling/completed_consumer_in_solutions.{m,exp}:
	New test case, an easier version of consumer_in_solutions.

tests/tabling/consumer_in_commit.{m,exp}:
	Extend this test case and update the expected output; we can execute
	both the original code and the extension without runtime exceptions.

tests/tabling/seq2.m:
	Fix Kostis's new test case.

tests/tabling/seq4.exp:
	Fix the expected output of Kostis's new test case.

tests/tabling/Mmakefile:
	Enable the new test cases, and some old test cases that we now pass.
2004-03-12 06:02:19 +00:00
Zoltan Somogyi
666c4b785e Move toward the proposed structures for representing type class information at
Estimated hours taken: 32
Branches: main

Move toward the proposed structures for representing type class information at
runtime by adding code for generating the structures corresponding to
base_typeclass_infos. The structures corresponding to typeclass_infos will
be added in a later change.

Register the new data structures in a table at runtime.

Add four new mdb developer commands for checking the contents of the new
type class table, as well as the contents of the existing type constructor
table: class_decl, type_ctor, all_class_decls and all_type_ctors.

compiler/rtti.m:
	Add the data types required to represent the new runtime data
	structures that will eventually replace base_typeclass_infos
	inside the compiler.

	Add the required function symbols to the data types representing both
	the new RTTI data structures themselves and those representing
	references to them.

	Make the required changes to the predicates operating on the modified
	data types, and add some required new predicates.

compiler/rtti_out.m:
	Add code to write out the new data structures for the LLDS backend.

	Make some changes in existing predicates to allow them to be used
	in the new code.

compiler/layout_out.m:
	Factor out some code that is now common with rtti_out.m.

compiler/type_class_info.m:
	A new module to generate the new RTTI data structures.

compiler/backend_libs.m:
	Include the new module.

compiler/options.m:
	Add a new option, --new-type-class-rtti, to control whether we
	invoke the top level predicate of type_class_info.m to generate
	the new type class RTTI structures. We still generate and use
	base_typeclass_infos regardless of the value of this option.

compiler/mercury_compile.m:
	Invoke the code of the new module if --new-type-class-rtti is given.

compiler/opt_debug.m:
	Add code to dump descriptions of the new rtti_ids.

compiler/mlds_to_gcc.m:
compiler/rtti_to_mlds.m:
	Handle the new alternatives in the rtti data types, mostly by throwing
	exceptions. The actual code should be written later by Fergus.

compiler/pseudo_type_info.m:
	Module qualify the names of builtin types when generating
	pseudo-typeinfos for them. This makes the naming scheme more regular.

compiler/base_typeclass_info.m:
compiler/notes/type_class_transformation.html:
	Document the impending obsolescence of these files.

compiler/notes/work_in_progress.html:
	List type class RTTI as work in progress.

library/list.m:
	Add a utility predicate for use by compiler/rtti_out.m.

runtime/mercury_typeclass_info.h:
	Make some changes in the C data types representing type class
	information that I discovered to be necessary or advantageous
	in the process of generating values of those types automatically.

	Rename some types to make their names be better documentation.

	Change some arrays of pointers to structures into arrays of structures,
	where the structures at different array indexes are the same size.

	Removing consts that rtti_out.m supplies automatically avoids
	duplicate const errors from the C compiler.

	Add #includes to make the file namespace clean.

	Protect against multiple inclusion.

runtime/mercury_typeclass_info_example.c:
	Remove this file. After the changes to mercury_typeclass_info.h, its
	contents are no longer correct examples of the structures in
	mercury_typeclass_info.h, and since the compiler can now generate
	those structures automatically, hand-written examples no longer serve
	any useful pupose.

runtime/mercury_types.h:
	Add a new type, MR_CodePtr, for use in mercury_typeclass_info.h.
	The compiler predicate tc_rtti_name_type wants single-word names
	for types.

runtime/mercury_imp.h:
	#include mercury_typeclass_info.h.

runtime/mercury_type_tables.[ch]:
	Add functions to register and to look up type class declarations and
	type class instances.

	Add the functions and data structures required to look up all type
	constructors and all type classes. The debugger uses these to support
	the commands that let the programmer check the contents of these
	tables.

	Eventually, we should be able to use the type class tables to test
	whether a vector of types is a member of a given type class.

runtime/mercury_wrapper.c:
runtime/mercury_type_info.[ch]:
	Move the array of type_ctor_rep names from the mercury_wrapper module
	to the mercury_type_info module, and make it always-defined and public;
	the debugger also needs access to it now.

runtime/Mmakefile:
	Add mercury_typeclass_info.h to the list of header files that other
	files depend on.

trace/mercury_trace_internal.c:
	Add four new mdb commands: class_decl, type_ctor, all_class_decls
	and all_type_ctors.

	Make some existing code follow our coding conventions.

doc/user_guide.texi:
doc/mdb_categories:
	Document the four new mdb commands.

doc/reference_manual.texi:
	Document (in a comment) the compiler's reliance on each type in an
	instance declaration containing exactly one type constructor.

tests/debugger/class_decl.{m,inp,exp}:
	A new test case to test the new mdb commands.

tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
	Add the new test case.

tests/debugger/completion.exp:
	Expect the new commands to appear in the command name completion.

tests/debugger/mdb_command_test.inp:
	Test the documentation of the new mdb commands.
	Expect the new commands to appear in the command name completion.
2003-10-23 02:02:45 +00:00
Zoltan Somogyi
168500343c This change adds new facilities for debugging minimal model tabling, and
Estimated hours taken: 160
Branches: main

This change adds new facilities for debugging minimal model tabling, and
has several bug fixes found with the aid of those facilities. Most of the
diff affects the behavior of the system only in minimal model grades and/or
when debugging flags are defined.

compiler/ite_gen.m:
	In minimal model grades, surround the conditions of if-then-elses
	with calls to three functions. These functions detect when a
	condition fails due to one or more suspensions, and abort the
	program. (After resumptions, the condition may actually have
	solutions, but by then the computation has committed to the wrong
	path.)

compiler/table_gen.m:
	Change the program transformation for model_non predicates
	to use a switch instead of nested if-then-elses, to avoid the
	overhead of wrapping the condition. The version with switches
	is also a bit easier to debug.

	The transformation for model_det and model_semi predicates
	stays as before, because for such predicates finding the status
	(which we want to switch on) requires computation, not just a lookup.

	Switch to state variable syntax in the affected predicates.

	Make the error message for an internal error in loopcheck predicates
	more precise.

	Mark the code fragments that modify tabling data structures as impure
	and code fragments that examine tabling data structures as semipure.

runtime/mercury_stacks.[ch]:
	Implement the new stack of possibly negated contexts that we use
	to detect false failures due to suspensions in negated contexts.

	Fix a bug: don't refer to MR_cut_stack[-1].

	Shorten the name of the generator stack.

runtime/mercury_context.[ch]:
runtime/mercury_memory.c:
runtime/mercury_wrapper.[ch]:
	Allocate memory for the new stack of possibly negated contexts.

	Use the shortened name of the generator stack.

runtime/mercury_regorder.h:
	Allocate a pointer for the new stack of possibly negated contexts.

runtime/mercury_minimal_model.[ch]:
	A new module holding the part of mercury_tabling.[ch]
	that is specific to minimal model tabling. This version contains
	tools to help debugging of minimal model tabling, as well as some
	bug fixes found with the aid of those tools.

runtime/mercury_tabling.[ch]:
	Remove the code moved to mercury_minimal_model.[ch], and add the
	code moved here from trace/mercury_trace_internal.c.

	Add prefixes to a bunch of structure fields to make it easier
	to read code accessing those fields.

	Add mechanisms to allocate and copy tabling structures with type
	safety.

runtime/mercury_imp.h:
	#include the new header file, if it is needed.

runtime/Mmakefile:
	Mention the new module, and fix sortedness errors.

runtime/mercury_stack_trace.c:
	Fix a bug that sometimes caused stack traces to abort in minimal model
	grades: they were trying to get layout information from labels
	that do not have them, such as do_fail.

	If MR_TABLE_DEBUG is defined, print the locations of stack frames
	when doing stack dumps.

runtime/mercury_trace_base.h:
	Export to mercury_stack_trace.c the labels that we use to let the
	debugger get control at redos and fails, since they don't have
	layout information.

runtime/mercury_types.h:
	Move typedefs here from mercury_tabling.h, and add typedefs for some
	newly added types.

runtime/mercury_engine.[ch]:
	Add a table mapping debugging flags to their offsets in the
	MR_debugflag array, for use in the debugger.

runtime/mercury_misc.c:
	Make the formatting of det stack pointers the same as nondet stack
	pointers in debugging output.

runtime/mercury_debug.[ch]:
	Add conditionally compiled debugging output when creating temp frames
	on the nondet stack.

library/table_builtin.m:
	Conform to the new names of some fields.

	Add a predicate to return the status of a subgoal.

	Add conditionally compiled debugging code.

library/Mmakefile:
	Make table_builtin.m depend on runtime/mercury_minimal_model.h.

trace/mercury_trace.c:
	Conform to the new names of some fields.

trace/mercury_trace_internal.c:
	Add two new mdb commands, to print the cut stack and the new possibly
	negated context stack.

	Add two new mdb commands to print a subgoal and a consumer.

	Move some of the code to print tabling-related
	data structures to runtime/mercury_tabling.[ch].

	Add a new mdb command to report the values of debugging flags and
	to set and clear them. Previously, one had to turn on these debugging
	flags with environment variables, which were problematic because they
	turned on diagnostic printouts even in Mercury programs that *weren't*
	being debugged, such as the Mercury compiler when being used to
	generate the program to be debugged. Now the flags can be turned on
	from a .mdbrc file, which eliminates much setting and unsetting of
	environment variables.

doc/user_guide.tex:
	Document the new mdb commands.

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

tests/debugger/completion.exp:
	Expect the new commands in the command completion test.

tests/debugger//nondet_stack.exp*:
	Expect the new format of det stack pointers.

tests/debugger/all_solutions.exp3:
tests/debugger/exception_value.exp3:
tests/debugger/declarative/catch.exp3:
tests/debugger/declarative/ho5.exp3:
tests/debugger/declarative/throw.exp3:
	New expected test cases for use in minimal model grades. They
	differ from existing expected output files only in the precise
	phrasing of error messages.

tests/debugger/declarative/Mmakefile:
	Disable the untraced_subgoal test case in .mm grades, since we don't
	pass it yet.

tests/tabling/Mmakefile:
	Enable the mday test case, now that we pass it.
2003-03-18 16:39:01 +00:00
Zoltan Somogyi
fc5e29bd00 Make all mdb commands exist regardless of compilation options:
Estimated hours taken: 1
Branches: main

trace/mercury_trace_internal.c:
	Make all mdb commands exist regardless of compilation options:
	make the commands that are meaningful only with some compilation
	options report an error if those options aren't specified. This
	should simplify mdb for users, and should simplify testing (e.g.
	tests/debugger/completion).

doc/user_guide.texi:
	Document the previously conditionally defined commands that weren't
	documented before.

tests/debugger/mdb_command_test.inp:
	Test the documentation of the previously undocumented commands.

tests/debugger/completion.exp:
	Update the expected output of command completion to include the now
	unconditionally defined mdb commands.
2003-03-11 02:44:26 +00:00
Zoltan Somogyi
2bef47ce85 Extend the information we record about procedures when debugging is enabled
Estimated hours taken: 20
Branches: main (for now, after more testing, on release branch too)

Extend the information we record about procedures when debugging is enabled
to include information about the tabling transformation, if the procedure
in question is tabled. This is useful to developers in debugging the tabling
mechanism, and can be useful to general users by helping them understand the
space (and hence time) costs of tabling.

Add a new mdb command "table" that uses this information to print
programmer-selected subsets of the tables of a tabled procedure.

compiler/hlds_pred.m:
	Generalize the existing field in procedures that used to hold
	information about I/O tabling to contain information about tabling
	in general, including forms other than I/O tabling.

compiler/continuation_info.m:
compiler/code_gen.m:
compiler/stack_layout.m:
	Conform to the changes in hlds_pred.m.

compiler/layout.m:
	Provide Mercury parallels for the new data structures in
	mercury_stack_layout.h.

compiler/layout_out.m:
	Generate the new data structures in mercury_stack_layout.h.

compiler/table_gen.m:
	Generate the new data structures in hlds_pred.m.

compiler/llds_common.m:
compiler/opt_debug.m:
	Conform to the changes in layout.m

compiler/llds_out.m:
	Abstract out existing code into a new procedure to make it available
	to layout_out.m.

	Make tabling pointer variables their natural type.

compiler/modules.m:
	Fix an old bug: implicitly import table_builtin.m in .mm grades.

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

runtime/mercury_types.h:
	Move some type definitions here from mercury_tabling.h and
	mercury_stack_layout.h. This was necessary to avoid problems with
	circular #includes, in which a.h #includes b.h to get access to a
	definition, but b.h #includes a.h, which is prevented by the macro
	guarding against duplicate definition, which causes syntax errors
	in the rest of b.h because the rest of b.h depends on typedefs in
	a.h that occur in a.h *after* the #include of b.h.

runtime/mercury_label.h:
	Adjust the list of #includes after the change to mercury_types.h.

runtime/mercury_stack_layout.h:
	Extend the debugging data structures with constructs that describe
	the call tables, answer tables and answer blocks of tabled procedures.

	Delete typedefs that are now in mercury_types.h.

runtime/mercury_tabling.[ch]:
	Add new functions to allow lookups without insertions in hash tables
	containing ints, floats and strings.

	Add new functions to return the entire contents of these hash tables.

	Change to four-space indentation where this wasn't done previously.

runtime/mercury_grade.h:
	Increment the binary compatbility version number, partially to
	account for the change to mercury_stack_layout.h in this diff, but
	mostly to account for all the other diffs to mercury_stack_layout.h
	since the last released version.

trace/mercury_trace_tables.[ch]:
	Rename MR_print_proc_id_for_debugger as MR_print_proc_id_and_nl,
	since this better describes what the function does.

trace/mercury_trace_util.[ch]:
	Add a new function MR_trace_is_integer that reads in signed integers.

	Rename MR_trace_is_number as MR_trace_is_natural_number, since the
	former would now be ambiguous.

	Add a new function MR_trace_is_float that reads in floating point
	values.

library/string.m:
	Document that MR_trace_is_float uses the same logic as
	MR_trace_is_float.

trace/mercury_trace_browse.c:
trace/mercury_trace_vars.c:
	Update calls to MR_trace_is_number.

trace/mercury_trace_internal.c:
	Implement the new mdb command "table".

	Update calls to MR_trace_is_number and to
	MR_print_proc_id_for_debugger.

tests/debugger/print_table.{m,inp,exp}:
	New test case to test the new mdb command.

tests/debugger/Mmakefile:
	Enable the new test case.

	Disable the sensitive test cases in .mm grades.

tests/debugger/completion.exp:
	Update the expected output to include the new mdb command.

tests/debugger/mdb_command_test.inp:
	Update this automatically generated file to include the new mdb
	command.
2002-11-15 04:50:49 +00:00
Zoltan Somogyi
32d4fdef8a Rationalize the mechanisms we use to control retry across I/O.
Estimated hours taken: 8
Branches: main

Rationalize the mechanisms we use to control retry across I/O.

After this change, we never ask questions about retry across I/O if the retry
is guaranteed to be safe. If the I/O is not guaranteed to be safe, there are
three things we can do:

- We ask the user whether they really want to. This is the default, and can be
  asked for explicitly with "retry --interactive".

- We perform the retry without asking questions. This can be asked for
  explicitly with "retry --force".

- We abort the retry automatically without asking questions. This can be asked
  for explicitly with "retry --only-if-safe".

The implicit retries used to implement declarative debugging and the indirect
retries needed in the presence of minimal model tabling use the last option.

We need two conditions for the retry to be guaranteed to be safe:

- All I/O actions must be tabled.
- The retry must be wholly within the tabled region of the execution.

The first is normally assured by a debugging grade. However, to allow test
cases to test the behavior of retries even with --only-if-safe (and hence to
allow the testing of declarative debugging), we have another new flag,
--assume-all-io-is-tabled, which asserts the first condition to be true
even in non-debugging grades. This option applies both to the retry command
and the dd and dd_dd commands.

doc/user_guide.texi:
	Move the misc commands (which are intended for use by everybody)
	before the experimental and developer commands (which are intended
	for use only by developers).

	Document the dd_dd command in the developer section.

	Document the new options of the retry, dd and dd_dd commands, with
	the documentation of the developer-only options commented out.

	Consolidate the documentation of the two variants of the retry command
	into one, in order to reduce duplication.

	Add a cross-reference requested by Fergus.

	Add an XXX asking Mark to document the optional argument of dd_dd.

doc/generate_mdb_doc:
	Switch the order of sections to match the change in user_guide.texi.

doc/mdb_categories:
	Switch the order of sections to match the change in user_guide.texi,
	and include dd and dd_dd in the command lists.

runtime/mercury_trace_base.[ch]:
	Add a pair of global variables recording the event numbers at which
	I/O tabling is turned on and off.

	Make some declarations use the right typedef.

trace/mercury_trace.[ch]:
	Make MR_trace_retry respect the values of the new options
	controlling retries passed to it.

	Convert this file to four-space indentation to reduce the number of
	line-wraps.

trace/mercury_trace_declarative.[ch]:
	Record the value of one of the options controlling retries for the
	current invocation of `dd' in a global variable, since the front end
	can initiate retries even after the initial retry.

	Pass the required option values to retry.

trace/mercury_trace_external.c:
	Pass the required option values to retry.

trace/mercury_trace_internal.c:
	Implement the new options of the retry, dd and dd_dd commands.
	Pass the required option values to retry.

	Make "table_io start" and "table_io stop" record the relevant event
	numbers in the global variables designed to hold them, for use in
	mercury_trace.c in deciding whether a retry is safe.

	Make indirect retries (used only in minimal model grades) use only safe
	retries.

	Make the dd and dd_dd commands use the help system to print usage
	messages, now that they are both documented.

	To make this possible, make the dd command part of the "misc" category
	and the dd_dd command part of the "developer" category, which are the
	categories they are documented under in user_guide.texi.

tests/debugger/mdb_command_test.inp:
	Update this automatically generated list of commands.

tests/debugger/tabled_read.{inp,exp}:
tests/debugger/tabled_read_decl.{inp,exp}:
	Update the retry commands in these tests to use the new options
	where relevant.

tests/debugger/declarative/tabled_read_decl.{inp,exp}:
	Update the dd commands in these tests to use the new options
	where relevant.
2002-11-06 02:02:38 +00:00
Zoltan Somogyi
d9122a1b30 Document I/O tabling, after cleaning it up for public use.
Estimated hours taken: 6
Branches: main

Document I/O tabling, after cleaning it up for public use.

We have previously implemented two forms of I/O tabling. One tables
only the output arguments of each primitive; this allows transparent
retries across I/O. The other tables all the arguments and the name
of the predicate; this allows transparent retries across I/O, the
declarative debugging of code that does I/O, and the printing of tabled
I/O actions. Since we now support declarative debugging in the standard
debugging grades, standardize on the second form of I/O tabling, and
make the first form accessible to implementors only, via a deliberately
undocumented option. This option, --trace-table-io-only-retry, is sort of
the inverse of the old option --trace-table-io-decl, which this change
deletes. (Only "sort of" because --trace-table-io-decl used to turn on
I/O tabling, whereas --trace-table-io-only-retry is consulted only if
I/O tabling is turned on by some other mechanism.)

NEWS:
	Mention I/O tabling.

compiler/options.m:
	Delete --trace-table-io-decl, and add --trace-table-io-only-retry.

	Update documentation.

compiler/table_gen.m:
	Base decisions on --trace-table-io-only-retry, not
	--trace-table-io-decl.

compiler/handle_options.m:
	Delete an implication involving --trace-table-io-decl that is now
	unnecessary.

doc/user_guide.texi:
	Document the idea of I/O tabling, and move the table_io command
	out of the list of developer only commands into a category of its own
	(since it doesn't naturally fit anywhere else).

	Change the old mismatched "table_io start" "table_io end" pair to
	the matched "table_io start" "table_io stop" pair.

	Document the variants of the print and browse commands that print and
	browse I/O actions.

	Be consistent about formatting of categories of mdb commands.

	Comment out some obsolete material in the documentation of retry.

doc/generate_mdb_doc:
	Include the new table_io category in the list of mdb command
	categories.

	Squeeze out repeated blank lines in the automatically generated
	documentation, to make maximum use of screen real estate.

doc/squeeze:
	A new script to do the squeezing.

doc/mdb_categories:
	Include the new table_io category in the list of mdb command
	categories.

runtime/mercury_trace_base.[ch]:
	Add a new global variable MR_io_tabling_allowed. It is initialized
	to TRUE in debugging grades and FALSE in other grades.

trace/mercury_trace_internal.c:
	Accept "table_io begin" and "table_io end" as well as "table_io start"
	and "table_io stop". Consistently use "start" and "stop" in output.

	Make "table_io" print a message saying the executable is not set up
	for I/O tabling unless MR_io_tabling_allowed is set.

	Add a new command, "table allow", that sets MR_io_tabling_allowed to
	TRUE. In debugging grades, this has no effect. In other grades, it
	allows I/O tabling, even though some parts of the program may have
	been compiled with --trace-table-io and some without. This
	inconsistency can yield weird results, which is why this command is
	deliberately undocumented. However, we can use it in a disciplined
	fashion to test I/O tabling even in nondebugging grades, thus spotting
	any regression in this area more quickly than if we tested I/O tabling
	only in debugging grades.

tests/debugger/Mercury.options:
tests/debugger/declarative/Mercury.options:
	Delete all occurrences of --trace-table-io-decl, since its effect is
	now the default.

tests/debugger/mdb_command_test.inp:
	Move the location of the table_io command test in this autogenerated
	file to reflect its move to a new category.

tests/debugger/tabled_read*.{inp,exp}:
tests/debugger/declarative/tabled_read*.{inp,exp}:
	Execute "table_io allow" before trying to turn on I/O tabling, since
	this is now required in non-debugging grades.

	Reflect the change in terminology: expect "stopped", not "ended",
2002-10-22 04:36:26 +00:00
Zoltan Somogyi
d869c5505b Hide the events associated with the goals inserted by tabling transformations,
Estimated hours taken: 2
Branches: main

Hide the events associated with the goals inserted by tabling transformations,
since ordinary programmers shouldn't be exposed to the details of the
transformation. (A later diff will adjust the goal paths of the events
associated with the original code back to what they would have been without
the transformation.)

Add a new mdb command, unhide_events, that allows the programmer to expose
hidden events. This is intended for implementors only.

compiler/hlds_goal.m:
	Add a new goal feature, hide_debug_event. If a nonatomic goal has this
	feature, then the associated trace events will be hidden.

compiler/trace.m:
	Respect the new goal feature.

compiler/table_gen.m:
	Add the new goal feature to the compound goals created by tabling
	transformations.

compiler/code_gen.m:
compiler/dense_switch.m:
compiler/disj_gen.m:
compiler/ite_gen.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
	Pass the required goal_info to trace.m, to allow it to hide events as
	required.

runtime/mercury_trace_base.[ch]:
	Add two global boolean variables. One says whether we are exposing
	hidden events, the other says whether we have ever exposed hidden
	events.

trace/mercury_trace.c:
	Hide hidden events, unless the programmer has asked for them to be
	exposed.

trace/mercury_trace_internal.c:
	Implement the unhide_events command.

	Make "dd" check whether we have ever exposed hidden events.

	Fix some unclear code in "print_optionals".

doc/user_guide.texi:
	Doument the unhide_events command.

doc/mdb_categories:
	Mention the unhide_events command.

tests/debugger/mdb_command_test.inp:
	Test the documentation of the unhide_events command.
2002-09-09 07:48:25 +00:00
Zoltan Somogyi
a4bec98cd8 Test the documentation of the dd command, since it is now documented.
Estimated hours taken: 0.1
Branches: main

tests/debugger/mdb_command_test.inp:
	Test the documentation of the dd command, since it is now documented.
2002-08-30 04:02:52 +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
Mark Brown
9991b4974d Implement source-linking commands for mdb, using the new client/server
Estimated hours taken: 7.5
Branches: main

Implement source-linking commands for mdb, using the new client/server
feature of vim.  New commands added to mdb are 'view', which opens a
source-linked window if there is not one already open, and 'view -c'
which shuts any open source window.

This feature requires a version of vim compiled with '+clientserver'.
If such a program cannot be found, the mdb commands produce an error
message and do nothing else.

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

	Add a new global variable which stores the information required
	for one source server.

	Every time mdb stops at an event, synchronise the source window
	if present with the source context of the event.  At interface
	events, we use the parent context if possible, since that is more
	useful information.

	When leaving mdb, close the source window if there is one open.

trace/mercury_trace_source.c:
trace/mercury_trace_source.h:
	Code for starting up and manipulating a source-server in a vim
	window.

trace/Mmakefile:
	Add the new module to the trace library.

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

configure.in:
runtime/mercury_conf.h.in:
	Test for the functions getpid() and gethostname().  Without
	these functions mdb uses an inferior method to generate a unique
	server name.
2001-10-31 17:53:52 +00:00
Zoltan Somogyi
bbccf83461 Associate optional ignore counts with breakpoints.
Estimated hours taken: 12
Branches: main

Associate optional ignore counts with breakpoints.

trace/mercury_trace_spy.[ch]:
	Add a mechanism for ignoring break points until execution has gone
	through a given number of events matching the breakpoint; these events
	may be required to be of a given port type (call events or interface
	events).

trace/mercury_trace_internal.c:
	Add options to the break command to allow the ignore type and count to
	be set when a breakpoint is created.

	Add a new command, ignore, to allow the ignore type and count to be set
	when the breakpoint already exists.

	Add a new command, scope, to specify the default scope of new
	breakpoints.

doc/user_guide.texi:
	Document the ignore and scope commands and the new options of the
	break command.

configure.in:
runtime/mercury_conf.h.in:
	Check whether the system has the snprintf function.

runtime/RESERVED_MACRO_NAMES:
	Add HAVE_SNPRINTF to the list.

tests/debugger/mdb_command_test.inp:
	Test the new ignore commands' documentation.

tests/debugger/breakpoints.{inp,exp}:
	Extend this test case to test ignore counts.
2001-08-07 02:16:07 +00:00
Zoltan Somogyi
2dc4df5631 Add a proc_stats command to mdb.
Estimated hours taken: 2

Add a proc_stats command to mdb.

trace/mercury_trace_tables.[ch]:
	Add a function for printing statistics about procedure layout
	structures.

	Print out percentages both for proc_stats and for the old label_stats
	command.

trace/mercury_trace_internal.c:
	Add code to recognize the proc_stats command.

runtime/mercury_stack_layout.h:
	Add a macro giving the number of determinism codes.

doc/user_guide.texi:
	Document the proc_stats command.

doc/mdb_categories:
	Include the proc_stats command in the list of developer commands.

tests/debugger/mdb_command_test.inp:
	Include the proc_stats command in the list of commands to have their
	help text tested.
2001-01-18 03:01:56 +00:00
Mark Brown
0b062bc60f This is the first part of a change to support term dependency analysis
Estimated hours taken: 80

This is the first part of a change to support term dependency analysis
in the declarative debugger.  A method is added to the mercury_edt
typeclass which finds the origin of a selected subterm in an EDT node,
somewhere in the body of the call or in the body of the parent.  The
other parts of the change required before this can be useful are to
modify the search strategy (in browser/declarative_analyser.m) to make
use of the new information, and to modify the user interface to allow
a subterm to be selected.  They will be committed as separate changes.

The typeclass method first traverses one or more contours, matching the
contour events up with goals in a procedure representation.  This matching
process requires a left to right traversal, because we need to know which
disjunct/arm/branch was taken before we can match subgoals, and the
DISJ/SWTCH/THEN/ELSE events which tell us this information occur at the
left edge of the subgoals to which they apply.  But we must always start
from the right hand side of the contour being traversed, so this means
that a right to left traversal is required before the matching can start.

Using the contour matched up with the atomic goals, we track the location
of a subterm by looking at which variables are bound, while scanning right
to left along the contour.  Because this must happen after the matching,
this must be a separate right to left traversal than the earlier one.
Therefore the algorithm implemented here requires two passes over the
contours in order to find the origin of the selected subterm.

browser/declarative_execution.m:
	Add a maybe(goal_rep) to call nodes in the annotated trace.  This
	is `no' if the relevant module was compiled below trace level `rep'.

trace/mercury_trace_declarative.c:
	If the information is available, fill in the goal_rep when
	constructing call nodes.

browser/declarative_analyser.m:
	Add the new method to the mercury_edt typeclass.

browser/declarative_debugger.m:
	Implement the new method.  Update for the changed call nodes.

browser/program_representation.m:
	Add a version of goal_paths to be used by the declarative debugger,
	and a predicate to parse these from goal_path_strings.  Add the
	types arg_pos and term_path to represent a subterm of a call or exit.

browser/program_representation.m:
compiler/prog_rep.m:
	No longer store conjunctions in reverse order in the goal_rep; we now
	store them in the same order as in the HLDS.

	Although we search conjunctions in reverse order, we need to match
	them up with contour events before doing that.  This can only be
	done in the forwards direction, so it turns out that there is no
	advantage in storing them in reverse order.

compiler/hlds_goal.m:
compiler/trace.m:
	Add comments to the existing definitions of goal_path and
	path_step_to_string.
2001-01-16 15:44:25 +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
Zoltan Somogyi
e60f641d9b Make it possible to save the state of a debugger session wrt break points
Estimated hours taken: 6

Make it possible to save the state of a debugger session wrt break points
and aliases in a file that can be sourced in another debugger session to
restore the state.

trace/mercury_trace_internal.c:
	Add a new mdb command, "save <filename>", to save mdb's state to the
	named file.

	Allow the "disable", "enable" and "delete" commands to be given without
	arguments; such invocations refer to the most recently created
	breakpoint. The extension to "disable" is required by the
	implementation of the "save" command; the others are for symmetry.

	Allow the user to speficy an option to the source command that tells
	mdb not to complain if the named file cannot be processed. This should
	allow people to put into .mdbrc files commands to source saved state
	files if they exist and not get complaints if they don't.

	Make several messages conform to our convention that error messages
	start with "mdb: ".

trace/mercury_trace_spy.[ch]:
	Add code to implement the part of the "save" command concerned with
	breakpoints. Unfortunately, there is no simple way to save the
	specification of breakpoints created with "break here", so for the time
	being they are not saved. This should not be too much of a problem,
	since such breakpoints are rarely used.

	Maintain a variable that identifies the most recently added breakpoint,
	if any.

	Also move the function to print out breakpoints here from
	mercury_trace_internal.c, in order to centralize knowledge
	about breakpoints here.

trace/mercury_trace_alias.[ch]:
	Add code to implement the part of the "save" command concerned with
	aliases.

	Fix some occurrences of an old bug: use MR_free, not free, to free
	strings allocated with MR_copy_string.

trace/mercury_stack_trace.[ch]:
	Add a version of MR_print_proc_id that prints proc ids in a form
	suitable for mdb procedure specifications.

doc/user_guide.texi:
	Document the "save" command and the new usage modes of the other
	modified commands.

tests/debugger/mdb_command_test.inp:
	Test the existence of documentation for the "save" command.

tests/debugger/polymorphic_output.exp:
	Update an expected error message.
2000-09-01 00:50:29 +00:00
Zoltan Somogyi
0a9ab65b53 Add a new debugger command, next, which steps to the next event from the
Estimated hours taken: 2

Add a new debugger command, next, which steps to the next event from the
current call or its selected ancestor, thus stepping over events in called
procedures. In concept it is therefore like gdb's next command. The
implementation is very similar to the implementation of mdb's finish command,
without the latter's requirement for the stopping event being a final event.

trace/mercury_trace.[ch]:
	Add the MR_CMD_NEXT movement command.

trace/mercury_trace_internal.c:
	Check for the "next" command, and implement it.

tests/debugger/mdb_command_test.inp:
	Include "next" in the list of commands whose documentation is checked.

doc/user_guide.texi:
	Document the next command.

doc/mdb_categories:
	Update the list of forward movement commands to include "next"
	and (a little late) "exception".
2000-08-08 04:58:38 +00:00
Zoltan Somogyi
408e993002 Test the command name "exception", not "excp".
Estimated hours taken: 0.1

tests/debugger/mdb_command_test.inp:
	Test the command name "exception", not "excp".
2000-07-20 03:43:58 +00:00